Skip to content

feat: add global loop tasks — dual ~/.pi-loop.json and local .pi-loop.json - #2

Open
ta3pks wants to merge 1 commit into
ArtemisAI:mainfrom
ta3pks:main
Open

feat: add global loop tasks — dual ~/.pi-loop.json and local .pi-loop.json#2
ta3pks wants to merge 1 commit into
ArtemisAI:mainfrom
ta3pks:main

Conversation

@ta3pks

@ta3pks ta3pks commented May 21, 2026

Copy link
Copy Markdown

Summary

Adds a global field to LoopTask. When true, the task persists to ~/.pi-loop.json instead of the CWD-based .pi-loop.json. The cron_create tool accepts a new optional global (boolean) parameter.

How it works

  • Loading: On session_start, reads tasks from both {cwd}/.pi-loop.json (local) and ~/.pi-loop.json (global). No recursive tree walk — just two well-known locations.
  • Dedup: When CWD == $HOME, the global path is skipped to avoid loading the same file twice.
  • Writing: Tasks with global: true go to ~/.pi-loop.json; others go to {cwd}/.pi-loop.json. Empty files are cleaned up.
  • Locking: Separate file locks (w/ stale-PID detection) for both local and global files.
  • File watching: Both files are watched for external changes.

Changes

File Change
src/types.ts Added global?: boolean to LoopTask
src/store.ts Dual-path loadDurableTasks / writeDurableTasks, isGlobal arg on acquireLock/releaseLock
src/index.ts session_start loads from both paths and acquires both locks; session_shutdown releases both
src/tools/cron-tools.ts cron_create accepts global param

Use case

cron_create {
  cron: "0 10 * * *",
  prompt: "morning check",
  durable: true,
  global: true
}

This task persists to ~/.pi-loop.json and fires regardless of which directory pi runs from.

….json

Adds a 'global' field to LoopTask. When true, persists to ~/.pi-loop.json
instead of the CWD-based .pi-loop.json. On startup both files are loaded
and merged (skips global path when CWD == $HOME to avoid dupes).

cron_create accepts a new optional 'global' (bool) parameter.
No tree walking — just local CWD + global $HOME.
@ta3pks

ta3pks commented May 25, 2026

Copy link
Copy Markdown
Author

👋 gentle bump — this has been tested and is working well on our end. Any interest in reviewing? Happy to address any feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant