@yemi33/minions 0.1.2364 → 0.1.2366

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,87 @@
1
+ # Tutorial 1: Install and Connect a Project
2
+
3
+ You will install Minions, verify the default Copilot runtime, link one Git
4
+ repository, and start the engine and dashboard.
5
+
6
+ ## Prerequisites
7
+
8
+ - Node.js 22.5 or newer
9
+ - Git
10
+ - GitHub Copilot CLI, Claude Code, or Codex CLI with working authentication
11
+ - A local Git repository with an `origin` remote
12
+
13
+ Minions defaults to GitHub Copilot CLI. Install it if you have not selected a
14
+ different runtime:
15
+
16
+ ```bash
17
+ npm install -g @github/copilot
18
+ ```
19
+
20
+ ## 1. Install and initialize
21
+
22
+ ```bash
23
+ npm install -g @yemi33/minions
24
+ minions init
25
+ ```
26
+
27
+ Initialization creates the operator home at `~/.minions/`, including agent
28
+ charters, playbooks, routing, prompts, and the SQLite state database.
29
+
30
+ ## 2. Verify the host
31
+
32
+ ```bash
33
+ minions doctor
34
+ ```
35
+
36
+ Resolve every `FAIL` before dispatching. Warnings are non-blocking but should be
37
+ read: a permission-flag warning can mean that the selected CLI will stop for an
38
+ interactive prompt during a headless dispatch.
39
+
40
+ To choose another runtime:
41
+
42
+ ```bash
43
+ minions config set-cli claude
44
+ # or
45
+ minions config set-cli codex
46
+ ```
47
+
48
+ Run `minions doctor` again after switching.
49
+
50
+ ## 3. Link a repository
51
+
52
+ ```bash
53
+ minions add C:\code\sample-project
54
+ ```
55
+
56
+ On macOS or Linux, use the corresponding path such as
57
+ `~/code/sample-project`. Confirm the detected host, repository, main branch,
58
+ and description. The description helps agents route project-agnostic work, so
59
+ describe the repository's responsibility rather than its implementation
60
+ language.
61
+
62
+ Confirm the result:
63
+
64
+ ```bash
65
+ minions list
66
+ ```
67
+
68
+ ## 4. Start Minions
69
+
70
+ ```bash
71
+ minions start --open
72
+ ```
73
+
74
+ `start` is idempotent and starts both the engine and dashboard. If browser
75
+ launch is blocked, run `minions dash`.
76
+
77
+ ## Checkpoint
78
+
79
+ ```bash
80
+ minions status
81
+ ```
82
+
83
+ You should see the engine running, your project listed, and no failed
84
+ dispatches. In the dashboard, verify that the project appears in the project
85
+ picker and that the agent cards are idle.
86
+
87
+ Next: [ship your first task](02-first-task.md).
@@ -0,0 +1,73 @@
1
+ # Tutorial 2: Ship Your First Task
2
+
3
+ You will queue a small documentation change, observe routing and live output,
4
+ and inspect the resulting work item and pull request.
5
+
6
+ ## 1. Choose a bounded task
7
+
8
+ Start with a task that has one clear result and a cheap validation step:
9
+
10
+ ```bash
11
+ minions work "Add a short Development section to README.md that names the existing test command"
12
+ ```
13
+
14
+ For precise project selection, use the dashboard's **Work** page or Command
15
+ Center and select the linked project instead of Auto. A project-scoped task is
16
+ better than auto-routing while learning the lifecycle.
17
+
18
+ ## 2. Wake and inspect the queue
19
+
20
+ The engine checks for work on its normal tick. You can wake it immediately:
21
+
22
+ ```bash
23
+ minions dispatch
24
+ minions queue
25
+ ```
26
+
27
+ The item normally moves from `pending` to `dispatched`. If it remains pending,
28
+ open its detail view and read `_pendingReason`; common reasons are an unmet
29
+ dependency, no available agent, cooldown, or concurrency limits.
30
+
31
+ ## 3. Follow the agent
32
+
33
+ In the dashboard:
34
+
35
+ 1. Open **Home** and select the working agent.
36
+ 2. Watch **Live Output** for repository exploration, edits, and checks.
37
+ 3. Open **Work** and select the item to inspect its branch, output, and
38
+ artifacts.
39
+
40
+ The engine chooses an agent from `routing.md`, creates an isolated worktree for
41
+ mutating work, renders the work-type playbook, and invokes the configured
42
+ runtime adapter.
43
+
44
+ ## 4. Inspect the outcome
45
+
46
+ ```bash
47
+ minions status
48
+ minions queue
49
+ ```
50
+
51
+ A successful code-changing task should finish with a branch and pull request.
52
+ If the runtime reports success without the required artifact, the work item can
53
+ still be flagged for lifecycle follow-up.
54
+
55
+ If the item fails, read its failure class and output before retrying:
56
+
57
+ ```bash
58
+ minions wi show <work-item-id>
59
+ minions wi retry <work-item-id>
60
+ ```
61
+
62
+ Do not retry authentication, invalid configuration, or workspace-permission
63
+ failures without correcting the cause first.
64
+
65
+ ## Checkpoint
66
+
67
+ You have observed the full path:
68
+
69
+ ```text
70
+ work item -> routing -> worktree -> runtime -> checks -> branch/PR -> completion
71
+ ```
72
+
73
+ Next: [build a feature from a plan](03-plan-driven-feature.md).
@@ -0,0 +1,73 @@
1
+ # Tutorial 3: Build a Feature from a Plan
2
+
3
+ Use a plan when the outcome spans several independently verifiable changes.
4
+ You will create a plan, review its PRD, approve it, and follow dependency-aware
5
+ implementation through verification.
6
+
7
+ ## 1. Draft the request
8
+
9
+ Open Command Center and enter:
10
+
11
+ ```text
12
+ /plan Add a health endpoint to SampleProject, document it, and add automated
13
+ tests. Keep implementation, tests, and documentation as separate items with
14
+ explicit dependencies.
15
+ ```
16
+
17
+ The plan agent writes Markdown under `plans/`. The plan-to-PRD step then creates
18
+ structured items under `prd/` with acceptance criteria and `depends_on`
19
+ relationships.
20
+
21
+ You can also provide plan text from the CLI:
22
+
23
+ ```bash
24
+ minions plan "Add a health endpoint, tests, and operator documentation" SampleProject
25
+ ```
26
+
27
+ ## 2. Review before approval
28
+
29
+ Open **Plans** and inspect:
30
+
31
+ - every item has a concrete deliverable;
32
+ - acceptance criteria can be tested;
33
+ - dependencies use item IDs and are acyclic;
34
+ - each item names the correct project;
35
+ - rejected or out-of-scope ideas are explicit.
36
+
37
+ Use **Discuss & Revise** for corrections. Approval is the human gate that
38
+ materializes work items, so do not approve a vague PRD and expect routing to
39
+ repair it.
40
+
41
+ ## 3. Approve and observe dependency gating
42
+
43
+ Approve the plan, then inspect **Work**. Independent items can dispatch in
44
+ parallel. Dependent items stay pending until their prerequisites are done.
45
+
46
+ At spawn time, Minions resolves completed dependencies to their pull-request
47
+ branches and merges those branches into the dependent item's worktree. This
48
+ lets later items build on code that has not reached the main branch yet.
49
+
50
+ ## 4. Follow verification
51
+
52
+ When all implementation items finish, Minions creates a `verify` work item.
53
+ Verification builds and tests the combined result and must attach a pull
54
+ request when its contract requires one. A completed plan remains visible until
55
+ you archive it manually.
56
+
57
+ Archive only after reviewing the verify result:
58
+
59
+ ```bash
60
+ minions plans list
61
+ minions plans archive <plan-or-prd-id>
62
+ ```
63
+
64
+ Archived PRDs remain retained in place; the source plan Markdown moves to
65
+ `plans/archive/`.
66
+
67
+ ## Checkpoint
68
+
69
+ You should have an approved PRD, materialized work items, dependency-aware
70
+ branches, and a final verification result. See
71
+ [Plan Lifecycle](../plan-lifecycle.md) for status and archive details.
72
+
73
+ Next: [configure runtimes and project tools](04-runtimes-and-harness.md).
@@ -0,0 +1,77 @@
1
+ # Tutorial 4: Choose Runtimes and Propagate Project Tools
2
+
3
+ Minions can dispatch with Copilot CLI, Claude Code, or Codex. This tutorial
4
+ switches the fleet runtime, separates Command Center from agent settings, and
5
+ checks which skills, commands, and MCP configurations reach a worktree.
6
+
7
+ ## 1. Inspect the current fleet
8
+
9
+ ```bash
10
+ minions status
11
+ minions doctor --harness
12
+ ```
13
+
14
+ The harness report is read-only. It lists runtime asset directories, skill
15
+ roots, slash-command roots, and MCP configuration paths.
16
+
17
+ ## 2. Select a fleet runtime
18
+
19
+ ```bash
20
+ minions config set-cli copilot --model gpt-5.4
21
+ minions restart
22
+ ```
23
+
24
+ Use a model ID supported by your installed CLI. Omit `--model` to let the CLI
25
+ choose its default. To clear a persisted model while switching:
26
+
27
+ ```bash
28
+ minions restart --cli claude --model ""
29
+ ```
30
+
31
+ Fleet resolution is:
32
+
33
+ ```text
34
+ agent.cli -> engine.defaultCli -> copilot
35
+ agent.model -> engine.defaultModel -> runtime default
36
+ ```
37
+
38
+ Command Center has independent `engine.ccCli` and `engine.ccModel` overrides.
39
+ Changing CC does not silently switch dispatched agents.
40
+
41
+ ## 3. Add a project-local skill
42
+
43
+ In the linked repository's main checkout, create a committed skill under:
44
+
45
+ ```text
46
+ .claude/skills/<skill-name>/SKILL.md
47
+ ```
48
+
49
+ Describe when the skill applies and provide the exact existing project command
50
+ to run. Commit the skill if every worktree should receive it. Uncommitted
51
+ project-local assets can be propagated from the live checkout when
52
+ `engine.harnessPropagateProjectLocal` is enabled, but committed assets are more
53
+ reproducible.
54
+
55
+ ## 4. Verify propagation
56
+
57
+ ```bash
58
+ minions doctor --harness
59
+ ```
60
+
61
+ Dispatch a small task that clearly matches the skill. The completion report's
62
+ `harnessUsed` section distinguishes assets that were available from those the
63
+ agent reports actually using.
64
+
65
+ For a known-empty execution environment, enable `hermeticHarness` for an agent
66
+ or the fleet. This removes user asset directories and project harness
67
+ propagation; use it for reproducibility tests, not as an MCP process-launch
68
+ control.
69
+
70
+ ## Checkpoint
71
+
72
+ The selected runtime passes doctor, your project asset appears in the harness
73
+ survey, and a matching dispatch reports whether it used that asset.
74
+
75
+ Reference: [Runtime Adapters](../runtime-adapters.md),
76
+ [Harness Propagation](../harness-propagation.md), and
77
+ [Harness Transparency](../harness-transparency.md).
@@ -0,0 +1,71 @@
1
+ # Tutorial 5: Automate Recurring Work and Follow-Ups
2
+
3
+ Schedules create work at a time; watches react to state changes. You will create
4
+ one of each and verify them without waiting for the clock.
5
+
6
+ ## 1. Explore the live schemas
7
+
8
+ ```bash
9
+ minions schedule --help
10
+ minions watch --help
11
+ minions watch target-types
12
+ minions watch action-types
13
+ ```
14
+
15
+ Use the dashboard forms for your first records. They validate against the same
16
+ server-side schemas as the CLI JSON commands.
17
+
18
+ ## 2. Create a schedule
19
+
20
+ Open **Schedule**, create a disabled schedule named `weekly-doc-check`, select
21
+ your sample project, and use a task such as:
22
+
23
+ ```text
24
+ Review README.md for commands that no longer match the CLI. Correct only
25
+ verified stale claims and report the source lines used.
26
+ ```
27
+
28
+ Use the natural-language parser or cron builder to choose a weekly time. Save
29
+ the schedule disabled, then use **Run now** to test it.
30
+
31
+ From the CLI:
32
+
33
+ ```bash
34
+ minions schedule list
35
+ minions schedule run-now <schedule-id>
36
+ ```
37
+
38
+ Confirm that a work item appears before enabling the recurring schedule.
39
+
40
+ ## 3. Create a watch
41
+
42
+ Open **Watches** and create a watch for the test work item:
43
+
44
+ - target type: `work-item`
45
+ - target: the work-item ID
46
+ - condition: `completed`
47
+ - owner: `human`
48
+ - stop after: `0`
49
+
50
+ For an absolute condition such as `completed`, `stopAfter: 0` means fire once
51
+ and expire. For change conditions, zero means continue indefinitely.
52
+
53
+ Choose the default inbox notification first. Follow-up actions can dispatch
54
+ work, call a webhook, trigger a pipeline, run a skill, or invoke CC triage, but
55
+ they should be added only after the condition itself is proven.
56
+
57
+ ## 4. Observe the trigger
58
+
59
+ ```bash
60
+ minions watch list
61
+ minions watch show <watch-id>
62
+ ```
63
+
64
+ Watches are evaluated on their polling cadence, not every engine tick. After
65
+ the work item completes, confirm the watch records a trigger and an inbox note.
66
+
67
+ ## Checkpoint
68
+
69
+ You have tested time-based creation and condition-based reaction independently.
70
+ See [Watches](../watches.md) for predicates, plugins, templating, guards, and
71
+ action chains.
@@ -0,0 +1,85 @@
1
+ # Tutorial 6: Keep a Development Service Running
2
+
3
+ Use managed spawn when later agents need a dev server, emulator, or daemon to
4
+ survive the creating agent's exit. The engine owns the process, checks health,
5
+ and exposes it to later dispatches.
6
+
7
+ ## 1. Prove the service manually
8
+
9
+ In the worktree that will host the service:
10
+
11
+ 1. Install its existing dependencies.
12
+ 2. Run the real start command for at least five seconds.
13
+ 3. Probe the intended health endpoint and verify the expected status.
14
+ 4. Stop the test process.
15
+
16
+ Do not derive a managed-spawn spec from package names or guessed monorepo
17
+ filters. A command that exits immediately will not become reliable because the
18
+ engine starts it.
19
+
20
+ ## 2. Dispatch a managed-spawn work item
21
+
22
+ Create a project-scoped work item through the API so the opt-in metadata is
23
+ explicit. Save a temporary `managed-work-item.json`:
24
+
25
+ ```json
26
+ {
27
+ "title": "Start the sample development service",
28
+ "description": "Start the existing development service and leave it available for downstream validation.",
29
+ "project": "SampleProject",
30
+ "type": "implement",
31
+ "meta": {
32
+ "managed_spawn": true,
33
+ "managed_spawn_ttl_minutes": 120
34
+ }
35
+ }
36
+ ```
37
+
38
+ Submit it, then delete the temporary file:
39
+
40
+ ```bash
41
+ minions api POST /api/work-items --body-file managed-work-item.json
42
+ ```
43
+
44
+ The rendered playbook tells the agent where to write
45
+ `agents/<id>/managed-spawn.json` and includes the current executable allowlist
46
+ and schema. The declared `cwd` must be an absolute path that exists when the
47
+ agent exits; the agent should derive it from its current worktree.
48
+
49
+ ## 3. Require a healthcheck
50
+
51
+ For a web service, use an HTTP healthcheck:
52
+
53
+ ```json
54
+ {
55
+ "type": "http",
56
+ "url": "http://localhost:3000/health",
57
+ "expect_status": 200,
58
+ "interval_s": 1,
59
+ "timeout_s": 60
60
+ }
61
+ ```
62
+
63
+ For an emulator or non-HTTP daemon, use a command healthcheck that exits zero
64
+ and matches a stable readiness signal.
65
+
66
+ ## 4. Inspect and use the service
67
+
68
+ Open **Engine** and find **Managed Processes**, or query:
69
+
70
+ ```bash
71
+ minions api GET /api/managed-processes
72
+ ```
73
+
74
+ Confirm the process is healthy, its log path is populated, and its expiration
75
+ time is correct. Dispatch a second work item in the same project and verify
76
+ that the live managed-process context is included in its prompt.
77
+
78
+ Use `meta.keep_processes` instead when the agent itself must retain an ad-hoc
79
+ child with no health endpoint. Prefer managed spawn for named services.
80
+
81
+ ## Checkpoint
82
+
83
+ The service remains healthy after the creating agent exits and is visible to a
84
+ later dispatch. Read [Managed Spawn](../managed-spawn.md) for the full sidecar,
85
+ allowlist, restart, log-stream, and partial-failure contracts.
@@ -0,0 +1,56 @@
1
+ # Tutorial 7: Coordinate a Cross-Repository Change
2
+
3
+ Cross-repository plans keep one product outcome together while materializing
4
+ each item into the project that owns its code.
5
+
6
+ ## 1. Link and name both projects
7
+
8
+ ```bash
9
+ minions add C:\code\sample-api
10
+ minions add C:\code\sample-web
11
+ minions list
12
+ ```
13
+
14
+ Give each project a distinct responsibility in its description. Cross-repo
15
+ routing is much easier to review when `sample-api` and `sample-web` do not both
16
+ say only "application code."
17
+
18
+ ## 2. Request a cross-repo plan
19
+
20
+ In Command Center:
21
+
22
+ ```text
23
+ /plan Add an API capability in sample-api and consume it from sample-web.
24
+ Create separately testable items, assign every item to one project, and make
25
+ the web integration depend on the API contract item.
26
+ ```
27
+
28
+ The plan must declare both target projects, and every PRD item must have a valid
29
+ `project` value matching a configured project name.
30
+
31
+ ## 3. Review the dependency boundary
32
+
33
+ Before approval, confirm:
34
+
35
+ - shared contracts are explicit acceptance criteria;
36
+ - each item edits only one repository;
37
+ - cross-repo `depends_on` records sequencing intent;
38
+ - each repository has its own verification responsibility.
39
+
40
+ Cross-repo dependencies are advisory for merge coordination. They do not make
41
+ separate repositories share a Git history or automatically merge one repo's
42
+ branch into another.
43
+
44
+ ## 4. Approve and observe fan-out
45
+
46
+ Approval materializes items into each project's work-item store. Minions creates
47
+ one verify work item per touched project after implementation completes.
48
+ Inspect both project filters in **Work** and **Plans** rather than assuming the
49
+ central plan card shows every repository-specific detail.
50
+
51
+ ## Checkpoint
52
+
53
+ Both projects have correctly scoped work items and independent verification
54
+ results, while the source plan remains one reviewable artifact.
55
+
56
+ Reference: [Cross-Repo Plans](../cross-repo-plans.md).
@@ -0,0 +1,76 @@
1
+ # Tutorial 8: Operate and Recover Minions
2
+
3
+ This tutorial builds a repeatable triage order for engine, dispatch, runtime,
4
+ and worktree failures.
5
+
6
+ ## 1. Start with supported summaries
7
+
8
+ ```bash
9
+ minions status
10
+ minions queue
11
+ minions sources
12
+ ```
13
+
14
+ Use the dashboard **Engine** page for dispatch logs, metrics, managed processes,
15
+ and worktree state. Read JSON sidecars only as diagnostics; migrated runtime
16
+ state is canonical in `engine/state.db`.
17
+
18
+ ## 2. Classify before acting
19
+
20
+ For a pending item, inspect `_pendingReason`. For a failed item, inspect its
21
+ failure class and final output. Correct non-retryable causes such as
22
+ authentication, invalid manifests, bad managed-spawn schemas, or dirty live
23
+ checkouts before retrying.
24
+
25
+ ```bash
26
+ minions wi show <work-item-id>
27
+ minions wi retry <work-item-id>
28
+ ```
29
+
30
+ ## 3. Restart safely
31
+
32
+ `minions start` is idempotent. Use `minions restart` after changing engine
33
+ configuration or playbooks:
34
+
35
+ ```bash
36
+ minions restart
37
+ minions status
38
+ ```
39
+
40
+ Agents are independent child processes. A restart loses in-memory process
41
+ handles, so Minions uses persisted dispatch state, PID data, live-output
42
+ activity, and a restart grace period to recover or classify orphans. Do not
43
+ delete worktrees or dispatch rows to force recovery.
44
+
45
+ ## 4. Use targeted recovery commands
46
+
47
+ ```bash
48
+ minions dispatch # wake the daemon; does not run a second tick loop
49
+ minions cleanup # run the supported cleanup path
50
+ minions kill # kill active agents and reset dispatches to pending
51
+ ```
52
+
53
+ Use `kill` only when agents are genuinely wedged. Quiet output is not enough:
54
+ tracked agents are allowed to be silent during long builds and tests.
55
+
56
+ ## 5. Protect against process-level outages
57
+
58
+ For unattended installations, inspect and optionally install the external
59
+ watchdog:
60
+
61
+ ```bash
62
+ minions watchdog status
63
+ minions watchdog install --interval=5
64
+ ```
65
+
66
+ The watchdog complements the in-process supervisor by probing and recovering
67
+ the engine through the operating system scheduler.
68
+
69
+ ## Checkpoint
70
+
71
+ You can distinguish pending, failed, orphaned, and stopped states and can choose
72
+ the least destructive supported action for each.
73
+
74
+ References: [Engine Restart](../engine-restart.md),
75
+ [Timeouts and Liveness](../timeouts-and-liveness.md), and
76
+ [Worktree Lifecycle](../worktree-lifecycle.md).
@@ -0,0 +1,29 @@
1
+ # Minions Tutorial Track
2
+
3
+ These tutorials build on one another. Complete the first two before jumping to
4
+ an advanced topic. Each tutorial ends with an observable result rather than
5
+ only describing configuration.
6
+
7
+ | Tutorial | Outcome | Time |
8
+ |---|---|---:|
9
+ | [1. Install and connect a project](01-install-and-connect.md) | A healthy engine, dashboard, and linked repository | 15 min |
10
+ | [2. Ship your first task](02-first-task.md) | One scoped work item dispatched and tracked to completion | 15 min |
11
+ | [3. Build a feature from a plan](03-plan-driven-feature.md) | An approved PRD with dependency-aware implementation and verification | 25 min |
12
+ | [4. Choose runtimes and propagate project tools](04-runtimes-and-harness.md) | A configured fleet with verified skills, commands, and MCP visibility | 20 min |
13
+ | [5. Automate recurring work and follow-ups](05-schedules-and-watches.md) | A schedule and a condition-based watch | 25 min |
14
+ | [6. Keep a development service running](06-managed-services.md) | An engine-owned, health-checked development service | 25 min |
15
+ | [7. Coordinate a cross-repository change](07-cross-repo-plan.md) | One plan fanned out safely across multiple projects | 30 min |
16
+ | [8. Operate and recover Minions](08-operations-and-recovery.md) | A practical status, restart, retry, and diagnostics workflow | 20 min |
17
+
18
+ ## How to use the tutorials
19
+
20
+ - Use a disposable repository for the first task if you do not want an agent to
21
+ open a real pull request.
22
+ - Keep the dashboard open while following CLI steps. It is the easiest place to
23
+ see routing, pending reasons, live output, and artifacts together.
24
+ - Treat JSON files under `engine/` and `projects/` as diagnostic mirrors.
25
+ `engine/state.db` is the primary store for migrated runtime state.
26
+ - Use the linked reference docs when you need the full schema or lifecycle.
27
+ Tutorials intentionally focus on a successful path.
28
+
29
+ For a shorter setup-only path, use [the first-30-minutes guide](../onboarding.md).
package/docs/watches.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Watches
2
2
 
3
- Persistent monitoring jobs that fire inbox notifications and follow-up actions when a target hits a condition. Watches survive engine restarts and are checked every 3 ticks (~3 minutes by default).
3
+ Persistent monitoring jobs that fire inbox notifications and follow-up actions when a target hits a condition. Watches survive engine restarts and are checked every 18 ticks (~3 minutes at the default 10-second tick).
4
4
 
5
5
  ## What a Watch Is
6
6
 
7
- A watch is a small JSON record persisted to `engine/watches.json`. It binds:
7
+ A watch is a record persisted in `engine/state.db`; `engine/watches.json` is a passive diagnostic mirror. It binds:
8
8
 
9
9
  | Field | Purpose |
10
10
  |--------------|-------------------------------------------------------------------------|
@@ -20,7 +20,7 @@ A watch is a small JSON record persisted to `engine/watches.json`. It binds:
20
20
  | `requires` | Optional guard: array of predicate objects evaluated against `state` / `entity` / `prevState`; trigger is suppressed when any guard fails (false-or-error). Used to gate a watch on "PR is mergeable AND build passing" etc. |
21
21
  | `status` | `WATCH_STATUS.ACTIVE` \| `PAUSED` \| `TRIGGERED` \| `EXPIRED` |
22
22
 
23
- `createWatch()` allocates a `watch-<uid>` id, defaults the fields above, and persists atomically via `mutateJsonFileLocked` *(source: `engine/watches.js:184-248`)*.
23
+ `createWatch()` allocates a `watch-<uid>` id, defaults the fields above, and persists through the watch store *(source: `engine/watches.js` and `engine/watches-store.js`)*.
24
24
 
25
25
  ## Lifecycle (`WATCH_STATUS`)
26
26
 
@@ -94,7 +94,7 @@ The eight built-ins are registered at module load *(source: `engine/watches.js`
94
94
 
95
95
  | `targetType` | Target value | Conditions | Notes |
96
96
  |---------------|--------------------------------------|----------------------------------------------------------------------------|-------|
97
- | `pr` | PR number, canonical id, or display id | `merged`, `build-fail`, `build-pass`, `status-change`, `any`, `new-comments`, `vote-change`, `head-commit-change`, `mergeable-flipped`, `ready-for-merge`, `behind-master`, `draft-flipped` | Reads from `pull-requests.json` for any project; `new-comments` watches `humanFeedback.lastProcessedCommentDate`; `behind-master` requires `engine.watchesIncludeBehindBy: true` so the GH poller populates `pr.behindBy` |
97
+ | `pr` | PR number, canonical id, or display id | `merged`, `build-fail`, `build-pass`, `status-change`, `any`, `new-comments`, `vote-change`, `head-commit-change`, `mergeable-flipped`, `ready-for-merge`, `behind-master`, `draft-flipped` | Reads project PR state; `new-comments` watches `humanFeedback.lastProcessedCommentDate`; `behind-master` requires `engine.watchesIncludeBehindBy: true` so the GH poller populates `pr.behindBy` |
98
98
  | `work-item` | Work item id | `completed`, `failed`, `status-change`, `any`, `stalled`, `retry-limit-reached`, `dependency-met` | `completed` matches `DONE_STATUSES`; `failed` matches `WI_STATUS.FAILED`; `stalled` fires after N unchanged captures (default 12 ≈ 60 min); `retry-limit-reached` fires when `_retryCount >= ENGINE_DEFAULTS.maxRetries` |
99
99
  | `meeting` | Meeting id | `concluded`, `status-change`, `any` | `concluded` fires on terminal status (`completed`, `archived`) |
100
100
  | `plan` | PRD JSON filename or plan id | `approved`, `rejected`, `completed`, `status-change`, `any`, `all-items-done`, `item-failed-n-times` | Looked up by `_source` (PRD file), `_sourcePlan` (.md), or `id`; uses `PLAN_STATUS` |
@@ -145,7 +145,7 @@ Resolution is `path.join(shared.MINIONS_DIR, 'watches.d')` so it works in both d
145
145
  }
146
146
  ```
147
147
 
148
- `checkWatches` walks every active watch and, inside a single `mutateJsonFileLocked` callback *(source: `engine/watches.js:410-561`)*:
148
+ `checkWatches` walks every active watch and persists updates through the watch store:
149
149
 
150
150
  1. Skips paused/expired watches and any watch checked within its `interval`.
151
151
  2. Captures a baseline `_lastState` on first check (so change conditions have something to diff).
@@ -166,7 +166,7 @@ I/O happens **outside the lock**: notifications via `writeToInbox`, follow-up ac
166
166
  | Action type | What it does |
167
167
  |------------------------|-----------------------------------------------------------------------------------------------|
168
168
  | `notify` | Explicit inbox write; lets you customize `owner`/`body` instead of the default trigger string |
169
- | `dispatch-work-item` | Append a new WI to the project (or central) `work-items.json` with `createdBy: "watch:<id>"` |
169
+ | `dispatch-work-item` | Add a new project or central work item with `createdBy: "watch:<id>"` |
170
170
  | `run-skill` | Wrapper around `dispatch-work-item` that asks the agent to run a specific `.claude` skill |
171
171
  | `webhook` | `http`/`https` request to an arbitrary URL (10s safety timeout, JSON or string body) |
172
172
  | `minions-api` | Loopback call to the in-process dashboard at `http://127.0.0.1:${shared.readDashboardPortFile(MINIONS_DIR)?.port \|\| 7331}` (reads the bound-port beacon file, not the `MINIONS_PORT` env, so it still resolves after an `EADDRINUSE` port scan) — `endpoint` must start with `/api/`; sets `X-Minions-Internal: 1`; returns `{ok, status, summary, response}` for chain-step templating |