opencode-work-context 0.16.0 → 0.18.0

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.
package/README.md CHANGED
@@ -55,12 +55,17 @@ Then create a task and its first stage in OpenCode:
55
55
  /wc resume 000001 02
56
56
  ```
57
57
 
58
- `stage add` only creates a `planned` stage. It never starts a stage session or
59
- changes the invoking OpenCode session's current stage, regardless of whether
60
- that session is already associated with a workspace. Use
61
- `/wc resume <workspace> <stage>` in a separate OpenCode session to enter the new
62
- stage. Multiple sessions may work on the same non-terminal stage through
63
- explicit resume and handoff operations.
58
+ An explicit user-issued `/wc create` enters Planning, and an explicit
59
+ user-issued `/wc stage add` enters the new stage, when the invoking native
60
+ OpenCode session has no historical work-context affinity. This supports opening
61
+ a fresh native session before issuing either command. If the session already
62
+ has an affinity, creation remains session-neutral and the result directs the
63
+ user to resume in a separate native session.
64
+
65
+ Autonomous agent calls remain different: creating a workspace or adding a stage
66
+ without explicit user command intent never captures the invoking session. An
67
+ agent-added stage stays `planned`. Multiple sessions may work on the same
68
+ non-terminal stage through explicit resume and handoff operations.
64
69
 
65
70
  Stages remain in progress until the user explicitly requests `/wc stage finish`.
66
71
  Do not infer that request from completed work. Automatic completion is allowed
@@ -281,9 +286,19 @@ each direct commit or candidate fallback, the agent must read the effective mode
281
286
  again and proceed only while it returns `per_item`. This is an agent-policy
282
287
  preflight, not atomic Git enforcement. Before completing Current, the agent must
283
288
  define an explicit patch boundary, run relevant verification, and create a safe
284
- direct commit. Candidate publication remains separate. The user-only
285
- `commited <SHA>` acknowledgement contract is independent of agent-created
286
- per-item commits.
289
+ direct commit. Candidate publication remains separate. After a direct commit,
290
+ `commited <SHA>` validates current HEAD and records publication against the exact
291
+ Current item. A committed exact candidate related only to the stage records the
292
+ same evidence automatically.
293
+
294
+ For a non-Planning working stage, `startup` plus effective `per_item` mode makes
295
+ the execution ledger mandatory. The agent must establish Current before changing
296
+ application code, work only on Current, verify and publish its explicit patch,
297
+ complete Current, and only then begin the next item. Native OpenCode Todos do not
298
+ replace the work-context execution ledger. A compact system instruction repeats
299
+ this policy throughout the associated session, and `complete-current` requires
300
+ publication evidence bound to the exact Current item. Planning remains a
301
+ coordination surface rather than a per-item publication gate.
287
302
 
288
303
  In startup mode, the agent first inspects pending candidates related to the
289
304
  current stage and assesses direct publication. Only a ready `exact` candidate
@@ -319,6 +334,20 @@ mapping, storage safety, or explicit lifecycle rules. Implement executable
319
334
  project extensions as separate project plugins rather than modifying generated
320
335
  loaders.
321
336
 
337
+ The generated `/wc` command is intentionally a compact dispatcher. It keeps the
338
+ canonical command-to-tool catalog and universal safety rules in the always-loaded
339
+ prompt, then calls `work_context_help` with one exact command selector to load
340
+ only that operation's syntax and behavioral contract. If scoped help cannot
341
+ match a selector, mutating operations fail closed instead of guessing. This
342
+ keeps the slash-command prompt bounded while the loaded plugin remains the
343
+ versioned source of detailed command semantics.
344
+
345
+ Scoped help is a protocol-major contract: a compact dispatcher must be paired
346
+ with a plugin that reports `matched`, the canonical selector, exact tool mapping,
347
+ syntax, and operation guidance. Delivery doctor therefore rejects a compact
348
+ command paired with a pre-scoped-help plugin instead of treating that combination
349
+ as harmless minor drift.
350
+
322
351
  Useful commands:
323
352
 
324
353
  ```text
package/commands/wc.md CHANGED
@@ -3,220 +3,98 @@ description: Explicit work-context lifecycle commands backed by structured tools
3
3
  subtask: false
4
4
  ---
5
5
 
6
- <!-- opencode-work-context-protocol: {"schema":1,"major":1,"minor":7,"descriptor_hash":"sha256:b3c01c7ef3cad00e9c75f13a20fdb8785922afbfb2d240b9925d7bf9fe28209f"} -->
6
+ <!-- opencode-work-context-protocol: {"schema":1,"major":2,"minor":0,"descriptor_hash":"sha256:544d6ab416cf8594cc21cb0ca9fd98805678c64ad9ed85322e37ae98c8dd6327"} -->
7
7
 
8
- Interpret `/wc $ARGUMENTS` as an explicit work-context operation. Use the matching
9
- `work_context_*` custom tool registered by the installed package plugin with structured arguments. Never edit work-context
10
- Markdown, JSONL, INDEX, or SESSIONS projections directly. For mutating operations
11
- other than `resume`, report the structured result and stable error code. For
12
- `resume`, follow its human-oriented presentation rules instead. Use `work_context_help` when
13
- the syntax is missing or ambiguous.
8
+ Interpret `/wc $ARGUMENTS` as an explicit work-context operation. Use only the exact
9
+ `work_context_*` custom tool mapped below with structured arguments. Never edit
10
+ work-context Markdown, JSONL, INDEX, SESSIONS, or execution projections directly.
14
11
 
15
- `.opencode/commands/wc.md` is package-managed and may be replaced during install,
16
- activation, or `sync-command`. Never store project-specific workflow logic in this
17
- file or generated plugin loaders. Keep additive project instructions in
18
- `.opencode/work-context.md`; when that file exists, read it before dispatching the
19
- operation and merge its guidance into this command context. Project guidance may
20
- specialize local workflow, but it must not override this tool mapping, structured
21
- arguments, storage safety, or explicit lifecycle requirements.
12
+ Before dispatching any operation except `help`, call `work_context_help` with the
13
+ canonical command selector from the left side of the mapping, without arguments
14
+ (for example, `stage restore` or `delivery mark`). Follow its returned scoped
15
+ contract, then call the mapped tool. If help does not return `matched: true`, do
16
+ not perform a mutating operation; ask a focused question or show the command
17
+ catalog. Use `work_context_help` directly when syntax is missing or ambiguous.
18
+ For `/wc help`, call it without `command`; for `/wc help <selector>`, pass only
19
+ the exact selector as `command` (for example, `stage restore`).
22
20
 
23
- For `workspace list <workspace>` (or `<workspace> list`), report the workspace
24
- status and workflow mode, then every stage as
25
- `stage - status - title - description`.
21
+ For mutating operations other than `resume`, report the structured result and
22
+ stable error code. For `resume`, follow its human-oriented presentation contract.
23
+ Never infer confirmation tokens or lifecycle requests.
26
24
 
27
- Use these exact tool mappings; do not invent shortened tool names:
25
+ For an explicit user-issued `create` or `stage add` command, pass
26
+ `enterCurrentSession: true` to the mapped tool. This flag represents the user's
27
+ request to enter the created Planning stage or working stage when the current
28
+ native session has no historical work-context affinity. Never pass it for an
29
+ autonomous agent-created workspace or stage.
30
+
31
+ `.opencode/commands/wc.md` is package-managed. Read `.opencode/work-context.md`
32
+ when present and merge its additive project guidance before dispatch. Project
33
+ guidance cannot override tool mappings, structured arguments, storage safety,
34
+ confirmation requirements, or explicit lifecycle requirements.
35
+
36
+ Exact command selectors and tool mappings:
28
37
 
29
38
  - `create` -> `work_context_create_workspace`
30
39
  - `list` -> `work_context_list_workspaces`
31
- - `workspace list <workspace>` or `<workspace> list` -> `work_context_workspace_list`
32
- - `workspace rename <workspace> "title"` -> `work_context_rename_workspace`
33
- - `workspace mode <workspace> <standard|startup>` -> `work_context_set_workspace_mode`
34
- - `workspace commit-mode <workspace> <manual|per_item>` -> `work_context_set_workspace_commit_mode`
35
- - `stage commit-mode read [<workspace>] [<stage>]` -> `work_context_read_effective_commit_mode`
36
- - `candidate create <workspace> "title" ["message"] [strategy <exact|shared_foundation|integration>] [stages <stage>...]` -> `work_context_create_candidate`
37
- - `candidate capture <workspace> <candidateId> paths <path>...` or `candidate capture <workspace> <candidateId> patch "patch"` -> `work_context_capture_candidate`
38
- - `candidate preview <workspace> <candidateId>` -> `work_context_preview_candidate`
39
- - `candidate show <workspace> <candidateId>` -> `work_context_show_candidate`
40
- - `candidate list <workspace>` -> `work_context_list_candidates`
41
- - `candidate ready <workspace> <candidateId>` -> `work_context_ready_candidate`
42
- - `candidate confirm-coverage <workspace> <candidateId> stages <stage>... INTEGRATION_COVERAGE_CONFIRMED` -> `work_context_confirm_candidate_coverage`
43
- - `candidate commit <workspace> <candidateId> ["message"]` -> `work_context_commit_candidate`
44
- - `candidate discard <workspace> <candidateId>` -> `work_context_discard_candidate`
45
- - `commit all <workspace> ["message"] [stages <stage>...] [exclude <path>...]` -> `work_context_inspect_commit_all`
46
- - `commit all confirm <workspace> <fingerprint> COMMIT_ALL_CONFIRMED ["message"] [stages <stage>...] [exclude <path>...]` -> `work_context_commit_all`
47
- - `delivery read <workspace> [<environment>] [range <from> <to>]` -> `work_context_read_delivery`
48
- - `delivery explain <workspace> <from> <to> [findings JSON]` -> `work_context_explain_delivery`
40
+ - `workspace list` (also <workspace> list) -> `work_context_workspace_list`
41
+ - `workspace rename` -> `work_context_rename_workspace`
42
+ - `workspace mode` -> `work_context_set_workspace_mode`
43
+ - `workspace commit-mode` -> `work_context_set_workspace_commit_mode`
44
+ - `stage commit-mode read` -> `work_context_read_effective_commit_mode`
45
+ - `candidate create` -> `work_context_create_candidate`
46
+ - `candidate capture` -> `work_context_capture_candidate`
47
+ - `candidate preview` -> `work_context_preview_candidate`
48
+ - `candidate show` -> `work_context_show_candidate`
49
+ - `candidate list` -> `work_context_list_candidates`
50
+ - `candidate ready` -> `work_context_ready_candidate`
51
+ - `candidate confirm-coverage` -> `work_context_confirm_candidate_coverage`
52
+ - `candidate commit` -> `work_context_commit_candidate`
53
+ - `candidate discard` -> `work_context_discard_candidate`
54
+ - `commit all` -> `work_context_inspect_commit_all`
55
+ - `commit all confirm` -> `work_context_commit_all`
56
+ - `delivery read` -> `work_context_read_delivery`
57
+ - `delivery explain` -> `work_context_explain_delivery`
49
58
  - `delivery doctor` -> `work_context_doctor_delivery`
50
- - `delivery mark <workspace> <environment> <commit> DELIVERY_CONFIRMED` -> `work_context_mark_delivery`
51
- - `workspace finish <workspace>` -> `work_context_workspace_finish`
52
- - `workspace reopen <workspace> "reason"` -> `work_context_reopen_workspace`
53
- - `resume <workspace> <stage>` -> `work_context_start_session`
54
- - `commited <short-or-full-SHA>` -> `work_context_acknowledge_commit`
55
- - `stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE` -> `work_context_force_close_session`
59
+ - `delivery mark` -> `work_context_mark_delivery`
60
+ - `workspace finish` -> `work_context_workspace_finish`
61
+ - `workspace reopen` -> `work_context_reopen_workspace`
62
+ - `resume` -> `work_context_start_session`
63
+ - `commited` -> `work_context_acknowledge_commit`
64
+ - `stage force-close` -> `work_context_force_close_session`
56
65
  - `profiles show` -> `work_context_show_capability_profiles`
57
- - `profiles setup` -> ask for global or project scope and mapping values, then `work_context_configure_capability_profiles`
58
- - `profiles reset` -> ask for global or project scope and confirmation, then `work_context_reset_capability_profiles`
59
- - `stage add [<workspace>] ...` -> `work_context_add_stage` (optional `prompt`; infer missing execution capability and depth from the complete stage context before calling the tool)
60
- - `stage delegate [<workspace>] [<stage>] "title" "requested outcome" ["prompt"] ...` -> `work_context_delegate_stage`
61
- - `stage dependency add [<workspace>] [<stage>] <dependency>` -> `work_context_add_stage_dependency`
62
- - `stage dependency remove [<workspace>] [<stage>] <dependency>` -> `work_context_remove_stage_dependency`
63
- - `stage dependency publish [<workspace>] [<stage>] "outcome" [candidates <candidateId>...] [commits <sha>...] [verification JSON] [blockers JSON]` -> `work_context_publish_dependency_handoff`
64
- - `stage dependency read [<workspace>] [<stage>]` -> `work_context_read_dependency_context`
65
- - `stage profiles [<workspace>] [<stage>] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>|clear] [review <routine|implementation|architecture|security|review|clear>]` -> `work_context_set_stage_profiles`
66
- - `stage commit-mode [<workspace>] [<stage>] <manual|per_item|clear>` -> `work_context_set_stage_commit_mode`
67
- - `stage profiles refresh <workspace> [<stage>] [--include-explicit]` -> inspect current stage context, infer classifications, then `work_context_refresh_stage_profiles`
68
- - `stage reopen <workspace> <stage> "reason"` -> `work_context_reopen_stage`
69
- - `stage restore <workspace> <stage> "reason"` -> `work_context_restore_stage`
70
- - `stage rename [<workspace>] [<stage>] "title"` -> `work_context_rename_stage`
71
- - `stage update [<workspace>] [<stage>] "description"` -> `work_context_update_stage`
72
- - `stage update-prompt [<workspace>] [<stage>] "prompt"` -> `work_context_update_stage_prompt`
73
- - `stage update-result [<workspace>] [<stage>] "result"` -> `work_context_update_stage_result`
74
- - `stage execution read [<workspace>] [<stage>]` -> `work_context_read_stage_execution`
75
- - `stage execution replace [<workspace>] [<stage>] <expectedRevision> "state JSON"` -> `work_context_replace_stage_execution`
76
- - `stage execution update [<workspace>] [<stage>] <expectedRevision> "changes JSON"` -> `work_context_update_stage_execution`
77
- - `stage execution complete-current [<workspace>] [<stage>] <expectedRevision>` -> `work_context_complete_current`
78
- - `stage archive [<workspace>] [<stage>]` -> `work_context_archive_stage`
79
- - `stage handoff [<workspace>] [<stage>]` -> `work_context_handoff_stage`
80
- - `stage abandon [<workspace>] [<stage>]` -> `work_context_abandon_stage`
81
- - `stage finish [<workspace>] [<stage>]` -> `work_context_finish_stage`
82
- - `<workspace> [<stage>] unlink-issue <URL>` -> `work_context_unlink_issue`
83
-
84
- Supported syntax:
85
-
86
- - `help [command]`
87
- - `create "title"`
88
- - `list` or `<workspace> list`
89
- - `workspace list <workspace>`
90
- - `workspace rename <workspace> "title"`
91
- - `workspace mode <workspace> <standard|startup>`
92
- - `workspace commit-mode <workspace> <manual|per_item>`
93
- - `stage commit-mode read [<workspace>] [<stage>]`
94
- - `candidate create <workspace> "title" ["message"] [strategy <exact|shared_foundation|integration>] [stages <stage>...]`
95
- - `candidate capture <workspace> <candidateId> paths <path>...`
96
- - `candidate capture <workspace> <candidateId> patch "patch"`
97
- - `candidate preview <workspace> <candidateId>`
98
- - `candidate show <workspace> <candidateId>`
99
- - `candidate list <workspace>`
100
- - `candidate ready <workspace> <candidateId>`
101
- - `candidate confirm-coverage <workspace> <candidateId> stages <stage>... INTEGRATION_COVERAGE_CONFIRMED`
102
- - `candidate commit <workspace> <candidateId> ["message"]`
103
- - `candidate discard <workspace> <candidateId>`
104
- - `commit all <workspace> ["message"] [stages <stage>...] [exclude <path>...]`
105
- - `commit all confirm <workspace> <fingerprint> COMMIT_ALL_CONFIRMED ["message"] [stages <stage>...] [exclude <path>...]`
106
- - `delivery read <workspace> [<environment>] [range <from> <to>]`
107
- - `delivery explain <workspace> <from> <to> [findings JSON]`
108
- - `delivery doctor`
109
- - `delivery mark <workspace> <environment> <commit> DELIVERY_CONFIRMED`
110
- - `workspace finish <workspace>`
111
- - `workspace reopen <workspace> "reason"`
112
- - `resume <workspace> <stage>`
113
- - `commited <short-or-full-SHA>`
114
- - `stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE`
115
- - `profiles show`
116
- - `profiles setup`
117
- - `profiles reset`
118
- - `stage add [<workspace>] "title" ["prompt"] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>] [review <routine|implementation|architecture|security|review>]`
119
- - `stage delegate [<workspace>] [<stage>] "title" "requested outcome" ["prompt"] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>] [review <routine|implementation|architecture|security|review>]`
120
- - `stage dependency add [<workspace>] [<stage>] <dependency>`
121
- - `stage dependency remove [<workspace>] [<stage>] <dependency>`
122
- - `stage dependency publish [<workspace>] [<stage>] "outcome" [candidates <candidateId>...] [commits <sha>...] [verification JSON] [blockers JSON]`
123
- - `stage dependency read [<workspace>] [<stage>]`
124
- - `stage profiles [<workspace>] [<stage>] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>|clear] [review <routine|implementation|architecture|security|review|clear>]`
125
- - `stage commit-mode [<workspace>] [<stage>] <manual|per_item|clear>`
126
- - `stage profiles refresh <workspace> [<stage>] [--include-explicit]`
127
- - `stage reopen <workspace> <stage> "reason"`
128
- - `stage restore <workspace> <stage> "reason"`
129
- - `stage rename [<workspace>] [<stage>] "title"`
130
- - `stage update [<workspace>] [<stage>] "description"`
131
- - `stage update-prompt [<workspace>] [<stage>] "prompt"`
132
- - `stage update-result [<workspace>] [<stage>] "result"`
133
- - `stage execution read [<workspace>] [<stage>]`
134
- - `stage execution replace [<workspace>] [<stage>] <expectedRevision> "state JSON"`
135
- - `stage execution update [<workspace>] [<stage>] <expectedRevision> "changes JSON"`
136
- - `stage execution complete-current [<workspace>] [<stage>] <expectedRevision>`
137
- - `stage archive [<workspace>] [<stage>]`
138
- - `stage handoff [<workspace>] [<stage>]`
139
- - `stage abandon [<workspace>] [<stage>]`
140
- - `stage finish [<workspace>] [<stage>]`
141
- - `<workspace> [<stage>] link-issue <URL>`
142
- - `<workspace> [<stage>] unlink-issue <URL>`
143
- - `session rename "summary"`
144
- - `stage handoff [<workspace>] <stage>`
145
- - `stage abandon [<workspace>] <stage>`
146
- - `stage finish [<workspace>] <stage>` automatically reviews the Knowledge Base (`auto` by default)
147
- - stage lifecycle commands may omit stage, using the current OpenCode session; with one numeric identifier, six digits mean workspace and one or two digits mean stage
148
- - explicit workspace and stage positions accept canonical padded IDs or unpadded positive integers (`1..999999` and `1..99`); results and generated commands remain padded
149
- - zero, signs, decimals, whitespace, overlong values, and other non-digit identifier forms are invalid; a lone unpadded workspace ID is not reinterpreted under the one-identifier rule
150
- - `stage update-result` replaces an existing result and does not create a result for an unfinished stage
151
- - Planning stage 01 is a continuously available coordination surface, not a prerequisite gate; implementation, research, review, and other working stages must never depend on it
152
- - `stage delegate` requires the active delegating working-stage session and atomically creates one planned stage plus the edge from the delegator to that new dependency. The new stage receives a bounded delegation contract; the delegator remains active but may become blocked. A failure must leave neither a partial stage nor a partial edge
153
- - `stage dependency add|remove` applies only to planned or in-progress dependents, preserves the canonical dependent-to-dependency graph direction, rejects Planning, missing/cancelled sources, duplicates, self-edges, and cycles, and never stops an active dependent session. Every add creates a monotonically increasing edge generation; removal retires current delivery and projection, and re-adding the pair cannot resurrect older handoffs. Sufficiently old non-current audit records may be compacted into a bounded content-digest summary
154
- - `stage dependency publish` requires the active source-stage session and at least one formal direct dependent. It publishes an intermediate bounded outcome to every direct dependent without satisfying the dependency or changing any execution or lifecycle state. Candidate and commit evidence must be explicit and already committed
155
- - `stage dependency read` returns only direct dependency satisfaction and bounded current handoffs. Do not recursively inject another stage's prompt, execution ledger, or dependency tree
156
- - explicit `stage finish` atomically publishes one immutable final handoff when direct dependents exist. A later `stage update-result` changes the authoritative result but never rewrites the delivered final handoff; use a bounded `handoffOutcome` when a long result cannot fit the handoff contract
157
- - dependency handoffs and satisfied-boundary status changes use targeted at-most-once system notices for already-active unambiguous dependent sessions. Resume and sidebar context are the durable fallback. Delivery never submits a prompt, starts work, advances Current, changes lifecycle, or determines dependency satisfaction
158
- - execution recommendations have two independent portable fields: capability (`routine`, `implementation`, `architecture`, `security`, `review`) and depth (`light`, `standard`, `deep`)
159
- - when stage creation does not explicitly name capability and depth, infer both from title, description, prompt, dependencies, active workspace knowledge, and current execution state; pass `classification: inferred`; explicit user values pass `classification: explicit`
160
- - core and read-only UI never infer classifications; do not use keyword heuristics, mutate during resume, or invent values when the stage prompt is not actionable
161
- - `stage profiles` makes an explicit assignment; execution capability and depth are set or cleared together, omitted fields remain unchanged, and review remains optional metadata that does not control subagents or resolve a model
162
- - `stage profiles refresh` re-evaluates actionable missing/inferred stages from their complete current context and applies all computed recommendations in one structured call; skip completed/archived stages and preserve explicit assignments unless `--include-explicit` was requested
163
- - `capability_profiles.mode` in `.work-context/config.yaml` is `advisory` by default or `off`; off mode preserves metadata but omits profile presentation, resolution, and mapping warnings
164
- - advisory mappings are layered depth-to-model labels: tracked project mappings in `.opencode/capability-profiles.json` override global mappings in `~/.config/opencode/capability-profiles.json`; invalid entries are ignored with bounded warnings and missing mappings resolve to `current model`
165
- - `profiles setup` must use interactive questions for mode and light/standard/deep labels, apply mode and mappings in separate atomic structured calls, then offer to refresh unfinished stages; `profiles reset` requires explicit confirmation and removes mappings without changing stage metadata or mode
166
- - expanded stage details show one unlabeled line `<capability> · <depth> · <model>`; review metadata is not displayed as a model recommendation
167
- - capability recommendations never select a model or agent, create a replacement session, block resume, or persist mapping targets in tracked workspace data
168
- - stage execution state preserves string-array section compatibility while exposing stable `{ id, text, details? }` identities in `items`; `text` is the compact label and optional `details` contains self-contained guidance. `current` is the first remaining item and `queued` contains later remaining items in order. `replace` accepts strings or structured items, while `update` accepts `add`, `remove`, and `edit` changes; use IDs for duplicate or reworded text, and set an edit's `details` to `null` to clear it
169
- - read stage execution state first and pass its revision as `expectedRevision`; absent legacy state has revision `0`, and a stale mutation returns `EXECUTION_REVISION_CONFLICT` without changing newer state
170
- - execution mutations require the active stage session, trim and deduplicate items, reject overlap between `completed` and `remaining`, and enforce bounded item counts, lengths, and serialized size
171
- - update execution state after meaningful scope changes, decisions, substantial work, blockers, or verification changes and before handoff; do not update it for every trivial edit or tool call
172
- - work only on Current by default. Do not combine Queued items into one change set unless the user explicitly asks to batch them
173
- - after completing a meaningful Current item, read the latest revision and call `stage execution complete-current`; it atomically moves only Current to Completed and promotes the next queued item. Retain ordering and briefly report the transition in normal output
174
- - workspace `commit_mode` is persistent checklist commit authorization with `manual` as the default and `per_item` as the only commit policy. A stage may override it or use `clear` to inherit. It does not make `stage execution complete-current` perform Git work.
175
- - in effective `per_item` mode, immediately before each direct commit or candidate fallback, call `stage commit-mode read` and proceed only when it still returns `per_item`. This is an agent-policy preflight, not atomic Git enforcement. Define an explicit patch boundary, run relevant verification, and create a safe direct commit before complete-current. Candidate publication remains separate.
176
- - in startup plus `per_item` mode, inspect pending candidates related to the current stage and assess direct publication first. Only a ready `exact` candidate explicitly related to the current stage may substitute when direct publication is unsafe but separable. An ordinary `shared_foundation` or `integration` candidate does not satisfy Current completion. The narrow exception is committed, confirmed integration coverage described below. Reconcile stale related candidate intent after a direct commit. A true patch or merge conflict, failed verification, or incoherent boundary is a blocker: record it and do not complete Current. Authorization never includes unrelated changes.
177
- - `candidate confirm-coverage` is available only in a startup workspace for one ready `integration` candidate. It requires an explicit selection of 2-20 unique actionable stages, the exact `INTEGRATION_COVERAGE_CONFIRMED` token, effective `per_item` mode, and a Current item for every selected stage. It snapshots each selected stage's stable Current item ID and execution revision. `relatedStages` remains traceability-only and neither selects nor authorizes coverage.
178
- - candidate publication revalidates confirmed coverage before any Git mutation. A changed Current item, execution revision, effective mode, or terminal stage returns `CANDIDATE_COVERAGE_STALE`; the candidate remains ready and no commit is created. A successful publication stores the durable coverage and commit SHA but never advances execution state or stage lifecycle. Each selected stage verifies its remaining integration result and calls `complete-current` separately.
179
- - committed coverage remains visible for exactly the covered Current item, then disappears for that stage when that Current advances. An already-active, unambiguous native session receives one bounded system notice before its next model request. Inactive or new sessions receive the durable resume/sidebar coverage fallback. Coverage never repurposes prompts, turns, or attention signals.
180
- - before discarding an existing exact draft in favor of an integration candidate, prove the integration replacement covers the exact draft's intended work through capture, preview, readiness, and, when it substitutes for multiple Current items, explicit coverage confirmation. Do not discard the exact draft based only on related-stage metadata.
181
- - `resume` returns `resume.presentation` and `resume.context`; before doing any work, report a concise human-oriented summary in the user's language with the stage title, a plain-language Goal, previous progress when useful, and the immediate next action
182
- - when the saved prompt contains several clear deliverables, add `In this stage we will` with 2-5 short outcome-oriented bullets derived only from the prompt, previous result, and workspace knowledge; do not invent scope, and omit this block for a small stage
183
- - do not expose raw workspace/stage/session identifiers, ordinals, `ok` flags, or absent error codes in the user-facing resume summary
184
- - `resume.context.workspace_knowledge` contains every active durable knowledge entry for the workspace; treat it as established shared context, and do not repeat earlier analysis unless an entry is incomplete, contradicted, or needs verification
185
- - `resume.context.delegation_contract` gives a delegated source stage its bounded requested outcome. `resume.context.dependency_context` gives a dependent only direct lifecycle satisfaction plus bounded current handoffs. Treat both as established structured context, not permission to infer ownership or mutate another stage
186
- - when stage execution state exists, `resume.context.execution_state` is the current stage-local operational checkpoint. Its structured `current` and `queued` fields identify the active item and its ordered backlog; Current details are explicit on resume while queued presentation remains compact. Continue from it without rewriting the original prompt, and never copy it automatically into workspace knowledge or unrelated stages
187
- - Planning-stage resume may include `resume.context.delivery_context`, a bounded workspace-level summary of committed candidates and environment checkpoints; it is release coordination context, not stage ownership
188
- - when the user asks how to deploy from Planning, inspect the exact commit range and the repository's own deployment documentation, scripts, infrastructure, migrations, container definitions, configuration examples, and CI; produce ordered prerequisites, deployment, verification, rollback, and unresolved blockers instead of assuming that push or one generic command is sufficient
189
- - delivery planning must never persist secret values; mention only required secret or configuration names, ask one focused question when environment or baseline is ambiguous, and never mark delivery merely because commit, push, or CI succeeded
190
- - an associated OpenCode session resumed in a `startup` workspace receives `resume.context.workflow_policy`; follow it as active agent policy. Under effective `manual` commit mode, a shared dirty worktree and concurrent stages are expected, stages do not own files or commits, and ready work should be captured promptly into an explicit candidate; once a coherent commit intent exists, create or refresh its draft candidate before switching stages or handing off; on resume inspect `resume.context.pending_candidates` before creating a duplicate or another commit boundary; prefer an `exact` candidate when safely separable, use `shared_foundation` when several stages use one coherent change, and use `integration` when intertwined changes form one reviewable and testable result; mixed provenance and complete files containing unrelated stage work are not reasons to require prior commits or stop; stop only for a concrete patch conflict, an incoherent candidate boundary, or failed required verification. Under effective `per_item` mode, use the direct-first and exact-related fallback policy above instead.
191
- - standard-mode and unassociated core sessions do not receive startup policy; retain the existing conservative worktree behavior there
192
- - after presenting the summary, continue work immediately when `resume.next_action` is `start_work`; do not ask for generic confirmation
193
- - a stage may require confirmation only with an exact standalone `RESUME_CONFIRMATION: required` line in its saved prompt; when `resume.next_action` is `await_confirmation`, present the summary and wait before inspecting or modifying application code
194
- - `create` enters the new workspace's Planning stage in the current OpenCode session only when that native session has no active or historical work-context stage affinity; otherwise it creates the workspace without rebinding the current OpenCode session
195
- - `stage add` only creates a planned stage; it never starts a stage session or changes the invoking OpenCode session's current stage, regardless of whether that session is associated with a workspace. Enter the new stage later with an explicit `resume <workspace> <stage>` in a separate OpenCode session
196
- - `resume` never rebinds the OpenCode session that invokes it: the first associated work-context stage becomes that native session's immutable affinity, and attempting to start any different stage must fail atomically with `CURRENT_OPENCODE_SESSION_ALREADY_ASSOCIATED`; open a separate OpenCode session for the requested stage. Handoff, close, finish, abandon, archive, workspace completion, stage reopen, and stage restore never transfer or clear affinity
197
- - a repeated `resume` for the stage already associated with the current OpenCode session returns the existing typed `ACTIVE_SESSION_EXISTS` result and must not create a duplicate stage session
198
- - read-only session diagnostics report a legacy active association that conflicts with the earliest historical affinity as `SESSION_ASSOCIATION_SPLIT_BRAIN`; preserve the earliest historical association as the presumed original affinity, explicitly hand off or close only the incorrect later active association, and never force-close the presumed original merely because the conflict exists
199
- - while `SESSION_ASSOCIATION_SPLIT_BRAIN` is present, contextual mutations must fail closed when omitted identifiers are ambiguous; recovery must explicitly name both the incorrect workspace and stage before handoff or close
200
- - `resume` returns `resume.next_action` and `resume.instruction`; begin or continue implementation when the stage prompt is non-empty unless it explicitly requires confirmation or contains an unresolved decision that genuinely blocks progress
201
- - `commited` is intentionally spelled with one `t`. It is a deterministic light control-plane acknowledgement for a user-created current-HEAD commit in the active stage session. Call the structured tool directly and return its compact result without a second analysis response. It validates the supplied short or full SHA, attached branch, fast-forward checkpoint, and absence of Git operations; it never infers ownership or changes candidates.
202
- - when `resume.next_action` is `ask_questions`, do not inspect or modify application code and ask the user focused questions needed to make the prompt actionable
203
- - before `stage finish`, review durable findings: add new knowledge, update changed knowledge, supersede obsolete knowledge, or explicitly use `knowledgeReview=none` when the stage produced no durable findings; use `knowledgeReview=added` after ledger changes
204
- - invoke `stage finish` only when the user explicitly requests that lifecycle command; do not infer the request from completed work, tests, or a final report
205
- - automatic completion is allowed only when the current workspace's Planning-stage prompt contains an exact standalone line `AUTO_STAGE_FINISH: allowed`; otherwise leave the stage in progress and report that the work is ready for the user's lifecycle decision
206
- - `stage finish` closes and completes only the current stage session; it never starts, resumes, or binds the same OpenCode session to a downstream stage
207
- - `stage finish` always validates the Knowledge Base and returns total and active entry counts plus downstream unfinished stages for informational prompt review; do not begin a downstream stage until the user explicitly resumes it in a separate OpenCode session
208
- - execution checklist state never finishes a stage; explicit `stage finish` reports remaining items, blockers, and pending verification as warnings and preserves the final execution record for history
209
- - `stage reopen <workspace> <stage> "reason"` applies only to a completed stage, preserves its result and completion history, records the reason, changes it to `in_progress`, and does not start a session or affect downstream stages; use an explicit separate-session `resume` to work on it again
210
- - `stage restore <workspace> <stage> "reason"` applies only to an archived stage and restores its saved pre-archive status. New archives preserve that status; legacy archives restore to `in_progress`. It records the reason, preserves stage content and results, does not start a session, and requires explicit separate-session `resume` when restored to `planned` or `in_progress`.
211
- - `workspace reopen <workspace> "reason"` applies only to a completed workspace, changes it to `in_progress`, and records durable recovery history. Cancelled workspaces cannot be reopened.
212
- - candidate operations require `startup` workflow mode and store metadata and patch payloads only under `.work-context/local/`; create accepts an optional strategy and related stages, which are normalized references for traceability only and never ownership or lifecycle; active candidates explicitly related to the resumed stage appear as bounded metadata in `resume.context.pending_candidates` and in expanded sidebar details; capture requires exactly one explicit list of complete paths or one Git unified patch and never infers stage ownership; commit requires a ready candidate, uses its stored message unless a non-empty override is supplied, serializes Git publication, bypasses hooks and signing, and never uses the ordinary Git index. Confirmed integration coverage is an additional startup-only, per-item contract; it does not broaden standard-mode candidates, manual mode, or `commit all`.
213
- - `commit all` is an explicit two-phase repository-local integration operation available in standard and startup workspaces: first call inspection, report its included and excluded paths, traceability, proposed message, verification summary, and fingerprint, then wait for the user's exact `COMMIT_ALL_CONFIRMED` confirmation before calling publication with the same message, stages, exclusions, and fingerprint
214
- - commit-all inspection is read-only and never treats stages as file ownership; user-selected stages are traceability and message context, paths without defensible attribution remain explicit, `exclude` leaves known unrelated work outside the patch, and an omitted message uses the diff-derived proposal
215
- - commit-all publication re-inspects under the Git lock and returns `COMMIT_ALL_STALE_PLAN` when HEAD, patch content, exclusions, traceability, or message no longer match the confirmed fingerprint; never infer confirmation from tests, candidate readiness, preview success, or lifecycle state
216
- - commit-all is bounded to the current Git root and never includes sibling or external repositories, nested repositories, submodules, local operational state, suspicious generated paths, or probable secrets; those exclusions remain visible in the structured result and work in another repository must be committed there independently
217
- - delivery operations are mode-neutral local operational state and never execute deployment; `delivery read` without a range returns metadata only, exact Git inspection requires both immutable `from` and `to` hashes, and `delivery mark` requires the exact `DELIVERY_CONFIRMED` token only after the user confirms successful delivery to that environment
218
- - `delivery explain` is strictly read-only, accepts findings as structured JSON data, inspects only the explicit immutable range, and preserves stable errors, contract version, completeness, and omission of recommendations when incomplete
219
- - `delivery doctor` is strictly read-only, compares generated-command, declared, installed, self-reported, and host-attested or unavailable runtime evidence, and fails fast only when command and loaded-plugin protocol majors differ
220
- - `knowledge list|add|update|supersede <workspace> ...`
66
+ - `profiles setup` -> `work_context_configure_capability_profiles`
67
+ - `profiles reset` -> `work_context_reset_capability_profiles`
68
+ - `stage add` -> `work_context_add_stage`
69
+ - `stage delegate` -> `work_context_delegate_stage`
70
+ - `stage dependency add` -> `work_context_add_stage_dependency`
71
+ - `stage dependency remove` -> `work_context_remove_stage_dependency`
72
+ - `stage dependency publish` -> `work_context_publish_dependency_handoff`
73
+ - `stage dependency read` -> `work_context_read_dependency_context`
74
+ - `stage profiles` -> `work_context_set_stage_profiles`
75
+ - `stage commit-mode` -> `work_context_set_stage_commit_mode`
76
+ - `stage profiles refresh` -> `work_context_refresh_stage_profiles`
77
+ - `stage reopen` -> `work_context_reopen_stage`
78
+ - `stage restore` -> `work_context_restore_stage`
79
+ - `stage rename` -> `work_context_rename_stage`
80
+ - `stage update` -> `work_context_update_stage`
81
+ - `stage update-prompt` -> `work_context_update_stage_prompt`
82
+ - `stage update-result` -> `work_context_update_stage_result`
83
+ - `stage execution read` -> `work_context_read_stage_execution`
84
+ - `stage execution replace` -> `work_context_replace_stage_execution`
85
+ - `stage execution update` -> `work_context_update_stage_execution`
86
+ - `stage execution complete-current` -> `work_context_complete_current`
87
+ - `stage archive` -> `work_context_archive_stage`
88
+ - `stage handoff` -> `work_context_handoff_stage`
89
+ - `stage abandon` -> `work_context_abandon_stage`
90
+ - `stage finish` -> `work_context_finish_stage`
91
+ - `link-issue` -> `work_context_link_issue`
92
+ - `unlink-issue` -> `work_context_unlink_issue`
93
+ - `session rename` -> `work_context_rename_session`
94
+ - `knowledge list` -> `work_context_list_knowledge`
95
+ - `knowledge add` -> `work_context_add_knowledge`
96
+ - `knowledge update` -> `work_context_update_knowledge`
97
+ - `knowledge supersede` -> `work_context_supersede_knowledge`
98
+ - `help` -> `work_context_help`
221
99
 
222
100
  Arguments: $ARGUMENTS
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.16.0",
4
+ "version": "0.18.0",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -19,19 +19,21 @@ export default async ({ client, directory, worktree }) => ({
19
19
  if (!fs.existsSync(context.storage.root)) return;
20
20
  const notices = withLock(context.storage.lockPath("write"), () => {
21
21
  const finding = context.diagnoseSessionAssociations(sessionID).data.findings[0];
22
- if (finding) return { integration: [], dependency: [] };
22
+ if (finding) return { integration: [], dependency: [], reminder: null };
23
23
  const session = context.sessionByOpenCodeId(sessionID);
24
- if (!session) return { integration: [], dependency: [] };
24
+ if (!session) return { integration: [], dependency: [], reminder: null };
25
25
  const coverage = context.candidates().committedCoverageProjection(session.workspace).by_stage[session.stage]?.items || [];
26
26
  const stages = context.listStages(session.workspace).data.stages;
27
27
  const stage = stages.find((item) => item.stage === session.stage);
28
28
  return {
29
29
  integration: consumeIntegrationNotices(projectRoot, sessionID, { personalRoot: context.storage.personalRoot, coverage }),
30
30
  dependency: consumeDependencyNotices(projectRoot, sessionID, { personalRoot: context.storage.personalRoot, records: context.handoffs().read(session.workspace).records, dependencies: stage?.depends_on || [], dependencyGenerations: Object.fromEntries((stage?.depends_on || []).map((dependency) => [dependency, stage.dependency_epochs?.[dependency]?.generation || 1])) }),
31
+ reminder: context.mandatoryChecklistReminder(session.workspace, session.stage),
31
32
  };
32
33
  }, { owner: "work-context integration notice", session: sessionID });
33
34
  appendIntegrationNotices(output.system, notices.integration);
34
35
  appendDependencyNotices(output.system, notices.dependency);
36
+ if (notices.reminder) output.system.push(notices.reminder);
35
37
  } catch {
36
38
  // Local notice delivery is best effort and must not interrupt a model request.
37
39
  }
package/src/candidates.js CHANGED
@@ -17,7 +17,7 @@ const coverageStageLimit = 20;
17
17
  const executionItemPattern = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|legacy-[0-9a-f]{24})$/;
18
18
  const timestamp = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) && new Date(value).toISOString() === value;
19
19
  const metadataKeys = ["schema", "candidate", "workspace", "title", "message", "base_head", "status", "created_at", "updated_at", "selected_paths", "patch_file"];
20
- const optionalMetadataKeys = ["strategy", "related_stages", "coverage"];
20
+ const optionalMetadataKeys = ["strategy", "related_stages", "coverage", "publication"];
21
21
 
22
22
  const validCoverage = (coverage) => coverage && typeof coverage === "object" && !Array.isArray(coverage)
23
23
  && Object.keys(coverage).every((key) => ["schema", "confirmed_at", "entries"].includes(key))
@@ -29,6 +29,11 @@ const validCoverage = (coverage) => coverage && typeof coverage === "object" &&
29
29
  && Number.isInteger(entry.execution_revision) && entry.execution_revision >= 0)
30
30
  && new Set(coverage.entries.map((entry) => entry.stage)).size === coverage.entries.length
31
31
  && coverage.entries.every((entry, index) => index === 0 || coverage.entries[index - 1].stage.localeCompare(entry.stage) < 0);
32
+ const validPublication = (publication) => publication && typeof publication === "object" && !Array.isArray(publication)
33
+ && Object.keys(publication).every((key) => ["schema", "stage", "current_item_id", "execution_revision"].includes(key))
34
+ && publication.schema === 1 && /^\d{2}$/.test(publication.stage) && publication.stage !== "00"
35
+ && executionItemPattern.test(publication.current_item_id)
36
+ && Number.isInteger(publication.execution_revision) && publication.execution_revision >= 0;
32
37
 
33
38
  function validateCandidate(data, expectedId = null) {
34
39
  const valid = data && typeof data === "object" && !Array.isArray(data)
@@ -47,6 +52,7 @@ function validateCandidate(data, expectedId = null) {
47
52
  && Array.isArray(data.related_stages) && data.related_stages.every((stage) => /^\d{2}$/.test(stage) && stage !== "00")
48
53
  && new Set(data.related_stages).size === data.related_stages.length))
49
54
  && (!Object.hasOwn(data, "coverage") || (data.strategy === "integration" && validCoverage(data.coverage)))
55
+ && (!Object.hasOwn(data, "publication") || (data.strategy === "exact" && data.related_stages.length === 1 && validPublication(data.publication) && data.publication.stage === data.related_stages[0]))
50
56
  && (data.status === "committed"
51
57
  ? /^[0-9a-f]{40,64}$/.test(data.commit_hash) && timestamp(data.committed_at)
52
58
  : !Object.hasOwn(data, "commit_hash") && !Object.hasOwn(data, "committed_at"));
@@ -289,6 +295,28 @@ export class CandidateStore {
289
295
  return projection;
290
296
  }
291
297
 
298
+ exactPublicationEntry(workspace, data) {
299
+ if (data.strategy !== "exact" || data.related_stages.length !== 1 || data.related_stages[0] === "01") return null;
300
+ const stage = data.related_stages[0];
301
+ const workspaceRecord = this.context.storage.readWorkspace(workspace).data;
302
+ const stageRecord = this.context.storage.readStage(workspace, stage).data;
303
+ if (this.effectiveCommitMode(workspaceRecord, stageRecord) !== "per_item") return null;
304
+ const execution = this.context.storage.readStageExecution(workspace, stage);
305
+ const current = execution ? this.context.readStageExecution(workspace, stage).data.current : null;
306
+ return current ? { schema: 1, stage, current_item_id: current.id, execution_revision: execution.revision } : null;
307
+ }
308
+
309
+ publicationForCurrent(workspace, stage, currentItemId, executionRevision) {
310
+ const matches = this.projectionRecords(workspace).filter((candidate) => candidate.status === "committed").flatMap((candidate) => {
311
+ if (candidate.publication?.stage === stage && candidate.publication.current_item_id === currentItemId && candidate.publication.execution_revision === executionRevision) {
312
+ return [{ candidate: candidate.candidate, commit_hash: candidate.commit_hash, source: "exact_candidate" }];
313
+ }
314
+ const covered = candidate.coverage?.entries?.find((entry) => entry.stage === stage && entry.current_item_id === currentItemId && entry.execution_revision === executionRevision);
315
+ return covered ? [{ candidate: candidate.candidate, commit_hash: candidate.commit_hash, source: "integration_coverage" }] : [];
316
+ });
317
+ return matches.at(-1) || null;
318
+ }
319
+
292
320
  capture(workspace, id, input, options = {}) {
293
321
  workspace = options.allowStandard ? this.assertWorkspace(workspace) : this.assertStartup(workspace);
294
322
  const data = this.read(id, workspace);
@@ -334,6 +362,8 @@ export class CandidateStore {
334
362
  if (message !== undefined && (typeof message !== "string" || !message.trim())) fail(ERROR_CODES.INVALID_ARGUMENT, "Commit message must be a non-empty string");
335
363
  const commitMessage = message === undefined ? data.message : message.trim();
336
364
  this.validateCoverage(workspace, data);
365
+ const publication = this.exactPublicationEntry(workspace, data);
366
+ if (publication) data.publication = publication;
337
367
  let metadata;
338
368
  const published = commitPatch(this.context.storage.projectRoot, data.base_head, data.patch, commitMessage, {
339
369
  expectedHead: options.expectedHead,
@@ -0,0 +1,185 @@
1
+ const COMMON_GUIDANCE = Object.freeze([
2
+ "Use the mapped structured tool and its registered schema for exact argument names; command syntax tokens are not structured argument names. Never edit work-context projections directly.",
3
+ "Explicit workspace and stage identifiers accept canonical padded IDs or unpadded positive integers; contextual stage commands may omit identifiers only when the current OpenCode session is unambiguous.",
4
+ "For mutating operations, report the structured result and stable error code. Never infer a confirmation token or lifecycle request.",
5
+ ]);
6
+
7
+ const TOPICS = Object.freeze({
8
+ basic: Object.freeze([
9
+ "Workspace list output includes workspace status and workflow mode, followed by every stage as: stage - status - title - description.",
10
+ "For an explicit user-issued /wc create operation, pass enterCurrentSession: true. It starts Planning only when the native OpenCode session has no active or historical work-context stage affinity. Autonomous agent creation must omit this flag and remain session-neutral.",
11
+ ]),
12
+ commit_mode: Object.freeze([
13
+ "Workspace commit mode is manual or per_item; a stage override may be cleared to inherit the workspace value.",
14
+ "Immediately before each direct commit or candidate fallback, read the effective mode. Per-item authorization covers only an explicit coherent Current-item boundary and never makes complete-current perform Git work.",
15
+ ]),
16
+ candidates: Object.freeze([
17
+ "Candidate operations require startup mode. Related stages are traceability only and never imply ownership or lifecycle authority; capture accepts either explicit complete paths or one exact unified patch.",
18
+ "Before committing, require a ready candidate. Publication uses an isolated Git index, revalidates state, and never advances execution or stage lifecycle.",
19
+ "Integration coverage requires a ready integration candidate, 2-20 explicitly selected actionable stages in effective per_item mode, a Current item for every stage, and the exact INTEGRATION_COVERAGE_CONFIRMED token. Changed snapshots return CANDIDATE_COVERAGE_STALE without Git mutation.",
20
+ "Do not replace an exact candidate with an integration boundary without explicit user direction and proven captured, previewed, ready replacement coverage.",
21
+ ]),
22
+ commit_all: Object.freeze([
23
+ "Commit all is a two-phase repository-local operation. Inspect first, report included and excluded paths, traceability, proposed message, verification summary, and fingerprint, then wait for the exact COMMIT_ALL_CONFIRMED token.",
24
+ "Publication must reuse the inspected message, stages, exclusions, and fingerprint. Drift returns COMMIT_ALL_STALE_PLAN; tests, readiness, or lifecycle state never imply confirmation.",
25
+ "The boundary excludes other repositories, nested repositories, submodules, local operational state, suspicious generated paths, and probable secrets.",
26
+ ]),
27
+ delivery: Object.freeze([
28
+ "Delivery operations never deploy. Read without a range returns metadata only; exact Git inspection requires both immutable from and to hashes.",
29
+ "Delivery explain is strictly read-only and preserves contract completeness. Delivery mark requires the exact DELIVERY_CONFIRMED token only after the user confirms successful delivery to the named environment.",
30
+ "Delivery doctor is read-only and fails fast only when the generated command and loaded plugin protocol majors differ.",
31
+ ]),
32
+ profiles: Object.freeze([
33
+ "Execution recommendations combine a vendor-neutral capability and light, standard, or deep depth; they never select a model or agent or change a session.",
34
+ "Infer missing capability and depth from complete stage context and use classification inferred; explicit user values use classification explicit. Refresh skips terminal stages and preserves explicit values unless includeExplicit was requested.",
35
+ "Profiles setup asks interactively for scope, mode, and depth mappings, applies mode and mappings separately, then offers to refresh unfinished stages. Profiles reset asks for scope and requires the exact RESET_PROFILES confirmation token before removing mappings.",
36
+ ]),
37
+ stage_creation: Object.freeze([
38
+ "For an explicit user-issued /wc stage add operation, pass enterCurrentSession: true. It enters the new stage only when the native OpenCode session has no historical affinity. Autonomous agent stage creation must omit this flag and remain planned and session-neutral. Infer missing execution capability and depth from complete context and pass classification inferred.",
39
+ "Stage delegate requires the active delegating working-stage session and atomically creates the delegated stage plus the dependency edge; failure leaves neither partial state.",
40
+ "Planning stage 01 is a coordination surface and must never be used as a dependency gate.",
41
+ ]),
42
+ dependencies: Object.freeze([
43
+ "Dependency edges point from dependent to dependency. Add and remove reject Planning, terminal or missing sources, duplicates, self-edges, and cycles; re-adding an edge receives a new generation and cannot resurrect stale handoffs.",
44
+ "Publishing requires the active source session and at least one formal direct dependent. Intermediate and final handoffs are bounded context only: they never advance Current, start work, or determine dependency satisfaction.",
45
+ "Dependency read returns only direct lifecycle satisfaction and bounded current handoffs; do not recursively inject another stage's prompt, ledger, or dependency tree.",
46
+ ]),
47
+ stage_metadata: Object.freeze([
48
+ "Stage rename, description, and prompt updates preserve stage identity and history. Stage update-result replaces an existing result and cannot create one for an unfinished stage.",
49
+ "Explicit stage profile assignment sets or clears execution capability and depth together; omitted fields remain unchanged and review metadata is optional.",
50
+ ]),
51
+ execution: Object.freeze([
52
+ "Read execution state first and pass its revision as expectedRevision. Missing legacy state has revision 0; stale mutations return EXECUTION_REVISION_CONFLICT without changing newer state.",
53
+ "Execution state uses stable item IDs, with Current as the first remaining item and Queued as the ordered remainder. Work only on Current unless the user explicitly requests batching.",
54
+ "After meaningful Current completion, read the latest revision and call complete-current. It moves only Current to Completed and never commits Git work or finishes the stage.",
55
+ ]),
56
+ resume: Object.freeze([
57
+ "Resume never rebinds a native OpenCode session. The earliest stage affinity is permanent; a different stage requires a separate OpenCode session, and repeated resume of the active association returns ACTIVE_SESSION_EXISTS.",
58
+ "Present the returned human-oriented stage title, plain-language goal, useful previous progress, and immediate next action without exposing raw IDs, ordinals, ok flags, or absent error codes.",
59
+ "Start work immediately when next_action is start_work. If it is ask_questions, do not inspect application code; ask focused questions. Await confirmation only for an exact standalone RESUME_CONFIRMATION: required line.",
60
+ "Treat workspace knowledge, dependency context, delegation contracts, execution state, pending candidates, and workflow policy as established bounded context.",
61
+ ]),
62
+ lifecycle: Object.freeze([
63
+ "Stage finish requires an explicit user lifecycle request unless the Planning prompt contains the exact standalone line AUTO_STAGE_FINISH: allowed. Before finish, review durable knowledge and pass knowledgeReview added or none as appropriate.",
64
+ "Finish closes only the current stage session, publishes one immutable final handoff to direct dependents, preserves execution warnings, and never starts a downstream stage. Workspace finish requires all stages completed or archived.",
65
+ "Handoff closes the current session without finishing the stage; abandon closes it as abandoned. Neither transfers native session affinity.",
66
+ "Stage reopen applies only to completed stages. Stage restore applies only to archived stages and restores the saved pre-archive status. Both require a reason, preserve history, start no session, and require separate-session resume for actionable work.",
67
+ "Workspace reopen applies only to a completed workspace, requires a reason, and preserves recovery history; cancelled workspaces cannot be reopened.",
68
+ ]),
69
+ force_close: Object.freeze([
70
+ "Force close is only for a stale active association after explicit diagnosis. It requires the exact FORCE_CLOSE token and must never close the presumed original affinity merely because split-brain diagnostics exist.",
71
+ ]),
72
+ acknowledge: Object.freeze([
73
+ "The command is intentionally spelled commited with one t. It validates a current-HEAD direct commit for the active stage, records exact Current publication in mandatory startup per-item mode, performs no Git operation, and returns its compact structured result without a second analysis response.",
74
+ ]),
75
+ issues: Object.freeze([
76
+ "Issue links are explicit workspace or stage metadata. Do not infer a stage when the command supplies only a workspace.",
77
+ ]),
78
+ session: Object.freeze([
79
+ "Session rename changes only the current active session summary and requires an unambiguous active stage association.",
80
+ ]),
81
+ knowledge: Object.freeze([
82
+ "Knowledge operations maintain the canonical durable workspace ledger. Add new durable findings, update changed entries, and supersede obsolete entries through structured tools only.",
83
+ ]),
84
+ });
85
+
86
+ const route = (selector, syntax, tool, topic = "basic") => Object.freeze({ selector, syntax, tool, topic });
87
+
88
+ export const WORK_CONTEXT_COMMAND_ROUTES = Object.freeze([
89
+ route("create", 'create "title"', "work_context_create_workspace"),
90
+ route("list", "list", "work_context_list_workspaces"),
91
+ route("workspace list", "workspace list <workspace> | <workspace> list", "work_context_workspace_list"),
92
+ route("workspace rename", 'workspace rename <workspace> "title"', "work_context_rename_workspace"),
93
+ route("workspace mode", "workspace mode <workspace> <standard|startup>", "work_context_set_workspace_mode"),
94
+ route("workspace commit-mode", "workspace commit-mode <workspace> <manual|per_item>", "work_context_set_workspace_commit_mode", "commit_mode"),
95
+ route("stage commit-mode read", "stage commit-mode read [<workspace>] [<stage>]", "work_context_read_effective_commit_mode", "commit_mode"),
96
+ route("candidate create", 'candidate create <workspace> "title" ["message"] [strategy <exact|shared_foundation|integration>] [stages <stage>...]', "work_context_create_candidate", "candidates"),
97
+ route("candidate capture", 'candidate capture <workspace> <candidateId> paths <path>... | candidate capture <workspace> <candidateId> patch "patch"', "work_context_capture_candidate", "candidates"),
98
+ route("candidate preview", "candidate preview <workspace> <candidateId>", "work_context_preview_candidate", "candidates"),
99
+ route("candidate show", "candidate show <workspace> <candidateId>", "work_context_show_candidate", "candidates"),
100
+ route("candidate list", "candidate list <workspace>", "work_context_list_candidates", "candidates"),
101
+ route("candidate ready", "candidate ready <workspace> <candidateId>", "work_context_ready_candidate", "candidates"),
102
+ route("candidate confirm-coverage", "candidate confirm-coverage <workspace> <candidateId> stages <stage>... INTEGRATION_COVERAGE_CONFIRMED", "work_context_confirm_candidate_coverage", "candidates"),
103
+ route("candidate commit", 'candidate commit <workspace> <candidateId> ["message"]', "work_context_commit_candidate", "candidates"),
104
+ route("candidate discard", "candidate discard <workspace> <candidateId>", "work_context_discard_candidate", "candidates"),
105
+ route("commit all", 'commit all <workspace> ["message"] [stages <stage>...] [exclude <path>...]', "work_context_inspect_commit_all", "commit_all"),
106
+ route("commit all confirm", 'commit all confirm <workspace> <fingerprint> COMMIT_ALL_CONFIRMED ["message"] [stages <stage>...] [exclude <path>...]', "work_context_commit_all", "commit_all"),
107
+ route("delivery read", "delivery read <workspace> [<environment>] [range <from> <to>]", "work_context_read_delivery", "delivery"),
108
+ route("delivery explain", "delivery explain <workspace> <from> <to> [findings JSON]", "work_context_explain_delivery", "delivery"),
109
+ route("delivery doctor", "delivery doctor", "work_context_doctor_delivery", "delivery"),
110
+ route("delivery mark", "delivery mark <workspace> <environment> <commit> DELIVERY_CONFIRMED", "work_context_mark_delivery", "delivery"),
111
+ route("workspace finish", "workspace finish <workspace>", "work_context_workspace_finish", "lifecycle"),
112
+ route("workspace reopen", 'workspace reopen <workspace> "reason"', "work_context_reopen_workspace", "lifecycle"),
113
+ route("resume", "resume <workspace> <stage>", "work_context_start_session", "resume"),
114
+ route("commited", "commited <short-or-full-SHA>", "work_context_acknowledge_commit", "acknowledge"),
115
+ route("stage force-close", 'stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE', "work_context_force_close_session", "force_close"),
116
+ route("profiles show", "profiles show", "work_context_show_capability_profiles", "profiles"),
117
+ route("profiles setup", "profiles setup", "work_context_configure_capability_profiles", "profiles"),
118
+ route("profiles reset", "profiles reset", "work_context_reset_capability_profiles", "profiles"),
119
+ route("stage add", 'stage add [<workspace>] "title" ["prompt"] [execution <profile> depth <depth>] [review <profile>]', "work_context_add_stage", "stage_creation"),
120
+ route("stage delegate", 'stage delegate [<workspace>] [<stage>] "title" "requested outcome" ["prompt"] [execution <profile> depth <depth>] [review <profile>]', "work_context_delegate_stage", "stage_creation"),
121
+ route("stage dependency add", "stage dependency add [<workspace>] [<stage>] <dependency>", "work_context_add_stage_dependency", "dependencies"),
122
+ route("stage dependency remove", "stage dependency remove [<workspace>] [<stage>] <dependency>", "work_context_remove_stage_dependency", "dependencies"),
123
+ route("stage dependency publish", 'stage dependency publish [<workspace>] [<stage>] "outcome" [candidates <candidateId>...] [commits <sha>...] [verification JSON] [blockers JSON]', "work_context_publish_dependency_handoff", "dependencies"),
124
+ route("stage dependency read", "stage dependency read [<workspace>] [<stage>]", "work_context_read_dependency_context", "dependencies"),
125
+ route("stage profiles", "stage profiles [<workspace>] [<stage>] [execution <profile> depth <depth>|clear] [review <profile>|clear]", "work_context_set_stage_profiles", "stage_metadata"),
126
+ route("stage commit-mode", "stage commit-mode [<workspace>] [<stage>] <manual|per_item|clear>", "work_context_set_stage_commit_mode", "commit_mode"),
127
+ route("stage profiles refresh", "stage profiles refresh <workspace> [<stage>] [--include-explicit]", "work_context_refresh_stage_profiles", "profiles"),
128
+ route("stage reopen", 'stage reopen <workspace> <stage> "reason"', "work_context_reopen_stage", "lifecycle"),
129
+ route("stage restore", 'stage restore <workspace> <stage> "reason"', "work_context_restore_stage", "lifecycle"),
130
+ route("stage rename", 'stage rename [<workspace>] [<stage>] "title"', "work_context_rename_stage", "stage_metadata"),
131
+ route("stage update", 'stage update [<workspace>] [<stage>] "description"', "work_context_update_stage", "stage_metadata"),
132
+ route("stage update-prompt", 'stage update-prompt [<workspace>] [<stage>] "prompt"', "work_context_update_stage_prompt", "stage_metadata"),
133
+ route("stage update-result", 'stage update-result [<workspace>] [<stage>] "result"', "work_context_update_stage_result", "stage_metadata"),
134
+ route("stage execution read", "stage execution read [<workspace>] [<stage>]", "work_context_read_stage_execution", "execution"),
135
+ route("stage execution replace", 'stage execution replace [<workspace>] [<stage>] <expectedRevision> "state JSON"', "work_context_replace_stage_execution", "execution"),
136
+ route("stage execution update", 'stage execution update [<workspace>] [<stage>] <expectedRevision> "changes JSON"', "work_context_update_stage_execution", "execution"),
137
+ route("stage execution complete-current", "stage execution complete-current [<workspace>] [<stage>] <expectedRevision>", "work_context_complete_current", "execution"),
138
+ route("stage archive", "stage archive [<workspace>] [<stage>]", "work_context_archive_stage", "lifecycle"),
139
+ route("stage handoff", "stage handoff [<workspace>] [<stage>]", "work_context_handoff_stage", "lifecycle"),
140
+ route("stage abandon", "stage abandon [<workspace>] [<stage>]", "work_context_abandon_stage", "lifecycle"),
141
+ route("stage finish", "stage finish [<workspace>] [<stage>]", "work_context_finish_stage", "lifecycle"),
142
+ route("link-issue", "<workspace> [<stage>] link-issue <URL>", "work_context_link_issue", "issues"),
143
+ route("unlink-issue", "<workspace> [<stage>] unlink-issue <URL>", "work_context_unlink_issue", "issues"),
144
+ route("session rename", 'session rename "summary"', "work_context_rename_session", "session"),
145
+ route("knowledge list", "knowledge list <workspace>", "work_context_list_knowledge", "knowledge"),
146
+ route("knowledge add", 'knowledge add <workspace> "title" "text" [kind <kind>] [sources <source>...]', "work_context_add_knowledge", "knowledge"),
147
+ route("knowledge update", "knowledge update <workspace> <knowledgeId> [title <title>] [kind <kind>] [status <status>] [text <text>] [sources <source>...] [replacement <replacement>]", "work_context_update_knowledge", "knowledge"),
148
+ route("knowledge supersede", 'knowledge supersede <workspace> <knowledgeId> "replacement"', "work_context_supersede_knowledge", "knowledge"),
149
+ route("help", "help [command]", "work_context_help"),
150
+ ]);
151
+
152
+ const GENERAL_SYNTAX = `/wc [${WORK_CONTEXT_COMMAND_ROUTES.map((item) => item.selector).join("|")}]`;
153
+
154
+ export function commandHelp(command = "") {
155
+ const requested = typeof command === "string" ? command.trim() : "";
156
+ if (!requested) return {
157
+ command: "",
158
+ matched: false,
159
+ syntax: GENERAL_SYNTAX,
160
+ note: "Pass one exact command selector, such as stage restore or delivery mark, to receive its structured tool mapping and scoped contract before dispatch.",
161
+ selectors: WORK_CONTEXT_COMMAND_ROUTES.map((item) => item.selector),
162
+ };
163
+ const selector = requested.toLowerCase().replace(/\s+/g, " ");
164
+ const selected = WORK_CONTEXT_COMMAND_ROUTES.find((item) => item.selector === selector);
165
+ if (!selected) return {
166
+ command: requested,
167
+ matched: false,
168
+ syntax: GENERAL_SYNTAX,
169
+ note: "No exact command selector matched. Do not perform a mutating operation; use the selector catalog or ask the user to clarify.",
170
+ selectors: WORK_CONTEXT_COMMAND_ROUTES.map((item) => item.selector),
171
+ };
172
+ const topicGuidance = TOPICS[selected.topic];
173
+ if (!topicGuidance) throw new Error(`Missing work-context help topic: ${selected.topic}`);
174
+ const guidance = [...COMMON_GUIDANCE, ...topicGuidance];
175
+ return {
176
+ command: requested,
177
+ matched: true,
178
+ selector: selected.selector,
179
+ syntax: `/wc ${selected.syntax}`,
180
+ tool: selected.tool,
181
+ topic: selected.topic,
182
+ guidance,
183
+ note: guidance.join(" "),
184
+ };
185
+ }
package/src/core.js CHANGED
@@ -14,10 +14,11 @@ import { DeliveryStore } from "./delivery.js";
14
14
  import { doctorDelivery as runDeliveryDoctor } from "./delivery-doctor.js";
15
15
  import { applyExecutionItemPatch, applyExecutionTextPatchItems, assertExecutionSize, EXECUTION_SECTIONS, executionInputUsesItems, executionItems, executionItemsFromState, executionPatchUsesItems, executionReadModel, executionSchemaFor, normalizeExecutionItemState, normalizeExecutionState } from "./stage-execution.js";
16
16
  import { CAPABILITY_CLASSIFICATIONS, CAPABILITY_DEPTHS, CAPABILITY_PROFILES, capabilityProfileMode, capabilityRecommendations, configureCapabilityMappings, readCapabilityMappings, resetCapabilityMappings, validateCapabilityMappings } from "./capability-profiles.js";
17
- import { acknowledgeGitCommit, initializeGitCheckpoint } from "./git-acknowledgement.js";
17
+ import { acknowledgeGitCommit, gitPublicationReceipt, initializeGitCheckpoint } from "./git-acknowledgement.js";
18
18
  import { isCommitAncestor, repositoryState, rollbackCommitRef } from "./git-candidates.js";
19
19
  import { enqueueIntegrationNotice } from "./integration-notices.js";
20
20
  import { DependencyHandoffStore } from "./dependency-handoffs.js";
21
+ import { commandHelp } from "./command-help.js";
21
22
 
22
23
  const actor = (options) => options.actor || "OpenCode";
23
24
  const directDependents = (stages, sourceStage) => stages.filter((item) => item.depends_on.includes(sourceStage)).map((item) => item.stage).sort();
@@ -113,7 +114,8 @@ const startupWorkflowPolicy = (commitMode = { mode: "manual" }) => ({
113
114
  guidance: commitMode.mode === "per_item" ? [
114
115
  "A shared dirty worktree and concurrent stages are expected; stages do not own files or commits.",
115
116
  "When changes appear mixed or overlapping, report only a bounded, explicitly uncertain list of likely affected stages supported by deterministic local evidence; never infer file or hunk ownership.",
116
- "Before each direct commit or candidate fallback, read the effective commit mode again. Proceed only while per_item remains effective; this is an agent policy preflight, not atomic Git enforcement.",
117
+ "Work only on the authoritative Current execution item. Native OpenCode Todos never replace the work-context ledger or authorize Queued work.",
118
+ "Before each direct commit or candidate fallback, read the effective commit mode again. Proceed only while per_item remains effective.",
117
119
  "Inspect pending candidates related to this stage, then assess direct publication of the explicit Current-item patch first.",
118
120
  "Only a ready exact candidate explicitly related to this stage may ordinarily substitute when direct publication is unsafe but the patch is separable. Shared foundation and unconfirmed integration candidates do not satisfy Current completion.",
119
121
  "A committed integration candidate satisfies publication only when explicit coverage still names this exact Current item. Do not republish or reconstruct provenance; perform remaining verification and complete Current separately.",
@@ -151,7 +153,13 @@ const executionInstruction = (record) => {
151
153
  };
152
154
  const commitModeInstruction = (commitMode) => {
153
155
  if (commitMode.mode !== "per_item") return "";
154
- return `\n\nChecklist commit policy: per_item (${commitMode.source}). This is persistent authorization to publish an explicit, coherent Current-item patch; it never authorizes unrelated changes. Immediately before each direct commit or candidate fallback, call work_context_read_effective_commit_mode and proceed only if it still returns per_item. This is an agent policy preflight, not atomic Git enforcement. Before completing Current, define its explicit patch boundary and run relevant verification. When a direct commit is safe, create it before complete-current. Candidate publication remains separate. A committed integration candidate is a narrow substitute only when explicit durable coverage still names this exact Current item; do not publish it again, and complete Current only after remaining verification. Ordinary integration relations are traceability-only. A true patch or merge conflict, failed verification, or incoherent boundary is a blocker: record it and do not complete Current.`;
156
+ return `\n\nChecklist commit policy: per_item (${commitMode.source}). This is persistent authorization to publish an explicit, coherent Current-item patch; it never authorizes unrelated changes. Immediately before each direct commit or candidate fallback, call work_context_read_effective_commit_mode and proceed only if it still returns per_item. Before completing Current, define its explicit patch boundary and run relevant verification. When a direct commit is safe, create it, then call work_context_acknowledge_commit to bind publication to Current before complete-current. Candidate publication remains separate. A committed exact candidate related only to this stage records the same Current-bound evidence automatically. A committed integration candidate is a narrow substitute only when explicit durable coverage still names this exact Current item; do not publish it again. Ordinary integration relations are traceability-only. A true patch or merge conflict, failed verification, or incoherent boundary is a blocker: record it and do not complete Current.`;
157
+ };
158
+ const mandatoryChecklist = (workspaceRecord, stage, commitMode) => stage !== "01" && workspaceMode(workspaceRecord) === "startup" && commitMode.mode === "per_item";
159
+ const mandatoryChecklistInstruction = (execution) => {
160
+ const current = execution ? executionReadModel(execution).current : null;
161
+ if (!current) return `\n\nMandatory startup per-item checklist: no Current item exists. Do not inspect or modify application code. First create or repair the authoritative work-context execution ledger with one bounded Current item and ordered Queued items. Native OpenCode Todos do not replace this ledger.`;
162
+ return `\n\nMandatory startup per-item checklist: work only on Current (${current.text}). Do not begin a Queued item. After implementation, record verification, re-read effective commit mode, publish the exact Current patch, record publication when using a direct commit, then call complete-current before starting the next item. Native OpenCode Todos do not replace this ledger.`;
155
163
  };
156
164
  const deliveryPlanningInstruction = `\n\nDelivery planning policy:\n- When the user asks how to deploy, treat this as workspace-level delivery planning across all relevant committed changes, not as ownership by the current stage.\n- Inspect the exact commit range and the repository's own deployment documentation, scripts, infrastructure, migrations, container definitions, configuration examples, and CI before proposing commands.\n- Produce an ordered plan covering prerequisites, deployment, verification, rollback, and unresolved blockers. Ask one focused question when the target environment or baseline is genuinely ambiguous.\n- Never persist secret values. Mention only required secret or configuration names.\n- Never mark delivery from a successful commit or push alone. Use explicit delivery confirmation only after the user confirms that the target environment was updated successfully.`;
157
165
  const assertOpenCodeSessionAvailable = (events, opencodeSessionId, workspace, stage) => {
@@ -459,6 +467,16 @@ export class WorkContext {
459
467
  return { ok: true, data: { workspace, stage, mode: effective.mode, source: effective.source } };
460
468
  }
461
469
 
470
+ mandatoryChecklistReminder(workspace, stage) {
471
+ workspace = normalizeWorkspaceId(workspace);
472
+ stage = normalizeStageId(stage);
473
+ const workspaceRecord = this.storage.readWorkspace(workspace).data;
474
+ const stageRecord = this.storage.readStage(workspace, stage).data;
475
+ const commitMode = effectiveCommitMode(workspaceRecord, stageRecord);
476
+ if (!mandatoryChecklist(workspaceRecord, stage, commitMode)) return null;
477
+ return mandatoryChecklistInstruction(this.storage.readStageExecution(workspace, stage)).trim();
478
+ }
479
+
462
480
  candidates() { return new CandidateStore(this); }
463
481
  deliveries() { return new DeliveryStore(this); }
464
482
  handoffs() { return new DependencyHandoffStore(this.storage); }
@@ -628,8 +646,10 @@ export class WorkContext {
628
646
  const committedCoverage = workflowPolicy ? this.candidates().committedCoverageProjection(workspace).by_stage[stage] || null : null;
629
647
  const deliveryContext = stage === "01" ? this.deliveries().projection(workspace) : null;
630
648
  const hasDeliveryContext = deliveryContext && (deliveryContext.committed.count || deliveryContext.environments.length || deliveryContext.unavailable);
631
- const workspaceKnowledge = activeKnowledge(this.listKnowledge(workspace).data);
632
- const execution = this.storage.readStageExecution(workspace, stage);
649
+ const workspaceKnowledge = activeKnowledge(this.listKnowledge(workspace).data);
650
+ const execution = this.storage.readStageExecution(workspace, stage);
651
+ const checklistRequired = mandatoryChecklist(workspaceRecord, stage, commitMode);
652
+ const executionCurrent = execution ? executionReadModel(execution).current : null;
633
653
  const dependencyContext = stageRecord.data.depends_on.length ? this.handoffs().context(workspace, stage, this.listStages(workspace).data.stages) : null;
634
654
  const automaticFinish = automaticFinishAllowed(this.storage, workspace);
635
655
  const recommendations = capabilityRecommendations(this.storage, stageRecord.data, readCapabilityMappings(this.storage, { homeDir: this.options.capabilityProfilesHome }));
@@ -674,10 +694,10 @@ export class WorkContext {
674
694
  ...(workflowPolicy ? { workflow_policy: workflowPolicy } : {}),
675
695
  lifecycle: { automatic_finish_allowed: automaticFinish },
676
696
  },
677
- next_action: hasPrompt ? confirmationRequired ? "await_confirmation" : "start_work" : "ask_questions",
697
+ next_action: checklistRequired && !executionCurrent ? "initialize_execution" : hasPrompt ? confirmationRequired ? "await_confirmation" : "start_work" : "ask_questions",
678
698
  instruction: `${hasPrompt
679
699
  ? `${resumePresentationInstruction({ confirmationRequired })}\n\nSaved working prompt:\n${stageRecord.data.prompt}${executionInstruction(execution)}${startupWorkflowInstruction(workflowPolicy)}${stage === "01" ? deliveryPlanningInstruction : ""}`
680
- : `This stage has no non-empty prompt. Give the user a concise plain-language summary of the stage title and goal, then ask focused questions needed to define the intended outcome and scope. Do not inspect or modify application code yet. Do not report raw operation metadata or identifiers.`}${commitModeInstruction(commitMode)}\n\nDo not invoke stage finish unless the user explicitly requests the lifecycle command. Automatic completion is permitted only when lifecycle.automatic_finish_allowed is true, which requires the exact AUTO_STAGE_FINISH: allowed line in this workspace's Planning-stage prompt.`,
700
+ : `This stage has no non-empty prompt. Give the user a concise plain-language summary of the stage title and goal, then ask focused questions needed to define the intended outcome and scope. Do not inspect or modify application code yet. Do not report raw operation metadata or identifiers.`}${commitModeInstruction(commitMode)}${checklistRequired ? mandatoryChecklistInstruction(execution) : ""}\n\nDo not invoke stage finish unless the user explicitly requests the lifecycle command. Automatic completion is permitted only when lifecycle.automatic_finish_allowed is true, which requires the exact AUTO_STAGE_FINISH: allowed line in this workspace's Planning-stage prompt.`,
681
701
  },
682
702
  }, [workspace, stage]);
683
703
  });
@@ -689,7 +709,16 @@ export class WorkContext {
689
709
  this.storage.assertSafeRoots();
690
710
  return withLock(this.storage.lockPath("git-acknowledgement"), () => {
691
711
  assertActive(this.storage.readEvents(), workspace, stage, sessionId);
692
- return this.result(acknowledgeGitCommit(this.storage, { workspace, stage, sessionId, sha }), ["local:git-checkpoint"]);
712
+ const workspaceRecord = this.storage.readWorkspace(workspace).data;
713
+ const stageRecord = this.storage.readStage(workspace, stage).data;
714
+ const commitMode = effectiveCommitMode(workspaceRecord, stageRecord);
715
+ const execution = this.storage.readStageExecution(workspace, stage);
716
+ const current = execution ? executionReadModel(execution).current : null;
717
+ if (mandatoryChecklist(workspaceRecord, stage, commitMode) && !current) fail(ERROR_CODES.EXECUTION_CURRENT_REQUIRED, "A Current execution item is required before recording per-item publication");
718
+ const publication = mandatoryChecklist(workspaceRecord, stage, commitMode)
719
+ ? { schema: 1, workspace, stage, current_item_id: current.id, execution_revision: execution.revision }
720
+ : null;
721
+ return this.result(acknowledgeGitCommit(this.storage, { workspace, stage, sessionId, sha, publication }), ["local:git-checkpoint"]);
693
722
  }, { session: sessionId, owner: actor(this.options) });
694
723
  }
695
724
 
@@ -1129,6 +1158,20 @@ export class WorkContext {
1129
1158
  const items = current && executionItems(current);
1130
1159
  const currentItem = items?.remaining.shift();
1131
1160
  if (!currentItem) fail(ERROR_CODES.INVALID_STATE, "No current execution item to complete");
1161
+ const workspaceRecord = this.storage.readWorkspace(workspace).data;
1162
+ const commitMode = effectiveCommitMode(workspaceRecord, stageRecord.data);
1163
+ if (mandatoryChecklist(workspaceRecord, stage, commitMode)) {
1164
+ const candidatePublication = this.candidates().publicationForCurrent(workspace, stage, currentItem.id, revision);
1165
+ const directPublication = gitPublicationReceipt(this.storage, sessionId);
1166
+ const matchingDirect = directPublication?.workspace === workspace && directPublication.stage === stage
1167
+ && directPublication.current_item_id === currentItem.id && directPublication.execution_revision === revision
1168
+ ? { commit_hash: directPublication.commit, source: "direct_commit" }
1169
+ : null;
1170
+ const publication = candidatePublication || matchingDirect;
1171
+ if (!publication) fail(ERROR_CODES.EXECUTION_PUBLICATION_REQUIRED, "Current must have publication evidence bound to its exact item and revision before completion", { current_item_id: currentItem.id, execution_revision: revision });
1172
+ const repository = repositoryState(this.storage.projectRoot);
1173
+ if (!isCommitAncestor(repository.root, publication.commit_hash, repository.head)) fail(ERROR_CODES.EXECUTION_PUBLICATION_REQUIRED, "Current publication commit is not reachable from HEAD", { commit: publication.commit_hash, current_head: repository.head });
1174
+ }
1132
1175
  items.completed.push(currentItem);
1133
1176
  const nextItems = normalizeExecutionItemState(items, current);
1134
1177
  const timestamp = new Date().toISOString();
@@ -1415,11 +1458,7 @@ export class WorkContext {
1415
1458
  }
1416
1459
 
1417
1460
  help(command = "") {
1418
- return this.result({
1419
- command,
1420
- syntax: "/wc [create|list|workspace list|workspace rename|workspace mode|workspace commit-mode|stage commit-mode|candidate create|candidate capture|candidate preview|candidate show|candidate list|candidate ready|candidate confirm-coverage|candidate commit|candidate discard|commit all|commit all confirm|delivery read|delivery explain|delivery doctor|delivery mark|profiles show|profiles setup|profiles reset|workspace finish|workspace reopen|resume|stage add|stage delegate|stage dependency add|stage dependency remove|stage dependency publish|stage dependency read|stage profiles|stage profiles refresh|stage reopen|stage restore|stage rename|stage update|stage update-prompt|stage update-result|stage execution read|stage execution replace|stage execution update|stage execution complete-current|stage force-close|stage archive|stage handoff|stage abandon|stage finish|link-issue|unlink-issue|session rename|knowledge list|knowledge add|knowledge update|knowledge supersede|help]",
1421
- note: "Workspace commit mode is manual or per_item; stages may override or clear to inherit it. Read the effective mode immediately before each direct commit or candidate fallback because this agent-policy preflight is not atomic Git enforcement. Per-item mode authorizes commits only for explicit coherent Current-item boundaries and does not make complete-current perform Git work. A committed integration candidate is a narrow substitute only after explicit revision-safe multi-stage coverage confirmation; relations alone remain traceability. Dependency delegation atomically creates a source stage and edge; explicit intermediate and final handoffs are bounded context only, while lifecycle states remain authoritative for satisfaction and no notice advances execution or lifecycle. Execution recommendations combine a vendor-neutral capability with light, standard, or deep depth; Planning agents infer missing values before stage creation, ordinary refresh updates missing/inferred classifications while preserving explicit assignments, and local depth mappings resolve only an advisory model label; profiles setup gathers mode and mappings through questions, off mode suppresses presentation and resolution, and no profile operation changes a model, agent, reviewer, or session; delivery context is workspace-level local operational state; exact Git range inspection runs only for explicit immutable hashes; stage execution state is a bounded stage-local operational checkpoint; associated startup sessions receive the shared-worktree candidate policy; stage finish requires an explicit user lifecycle request unless Planning contains AUTO_STAGE_FINISH: allowed; recovery operations preserve lifecycle history.",
1422
- }, []);
1461
+ return this.result(commandHelp(command), []);
1423
1462
  }
1424
1463
 
1425
1464
  result(data, changed, next = null) {
package/src/errors.js CHANGED
@@ -22,6 +22,7 @@ export const ERROR_CODES = Object.freeze({
22
22
  COMMIT_ALL_UNSAFE_STATE: "COMMIT_ALL_UNSAFE_STATE", COMMIT_ALL_INCOHERENT_BOUNDARY: "COMMIT_ALL_INCOHERENT_BOUNDARY",
23
23
  COMMIT_ALL_STALE_PLAN: "COMMIT_ALL_STALE_PLAN", COMMIT_ALL_VERIFICATION_FAILED: "COMMIT_ALL_VERIFICATION_FAILED",
24
24
  EXECUTION_REVISION_CONFLICT: "EXECUTION_REVISION_CONFLICT", EXECUTION_LIMIT_EXCEEDED: "EXECUTION_LIMIT_EXCEEDED",
25
+ EXECUTION_CURRENT_REQUIRED: "EXECUTION_CURRENT_REQUIRED", EXECUTION_PUBLICATION_REQUIRED: "EXECUTION_PUBLICATION_REQUIRED",
25
26
  DELIVERY_INVALID_RANGE: "DELIVERY_INVALID_RANGE", DELIVERY_RANGE_TOO_LARGE: "DELIVERY_RANGE_TOO_LARGE",
26
27
  DELIVERY_INVALID_FINDINGS: "DELIVERY_INVALID_FINDINGS", DELIVERY_DIAGNOSTIC_TOO_LARGE: "DELIVERY_DIAGNOSTIC_TOO_LARGE",
27
28
  DELIVERY_COMMAND_PROTOCOL_MISMATCH: "DELIVERY_COMMAND_PROTOCOL_MISMATCH",
@@ -31,7 +31,14 @@ const checkpointFor = (personalRoot, sessionId) => {
31
31
  const file = checkpointPath(personalRoot, sessionId);
32
32
  try {
33
33
  const value = JSON.parse(fs.readFileSync(file, "utf8"));
34
- if (!value || value.schema !== 1 || value.session_id !== sessionId || typeof value.head !== "string" || !/^[0-9a-f]{40,64}$/.test(value.head) || typeof value.ref !== "string" || !value.ref.startsWith("refs/heads/")) {
34
+ const publication = value?.publication;
35
+ const validPublication = publication === undefined || (publication && publication.schema === 1
36
+ && typeof publication.workspace === "string" && /^\d{6}$/.test(publication.workspace)
37
+ && typeof publication.stage === "string" && /^\d{2}$/.test(publication.stage)
38
+ && typeof publication.current_item_id === "string" && publication.current_item_id.length <= 100
39
+ && Number.isInteger(publication.execution_revision) && publication.execution_revision >= 0
40
+ && typeof publication.commit === "string" && /^[0-9a-f]{40,64}$/.test(publication.commit));
41
+ if (!value || value.schema !== 1 || value.session_id !== sessionId || typeof value.head !== "string" || !/^[0-9a-f]{40,64}$/.test(value.head) || typeof value.ref !== "string" || !value.ref.startsWith("refs/heads/") || !validPublication) {
35
42
  fail(ERROR_CODES.STORAGE_ERROR, "Invalid Git acknowledgement checkpoint");
36
43
  }
37
44
  return { file, value };
@@ -78,7 +85,7 @@ export function initializeGitCheckpoint(storage, { workspace, stage, sessionId }
78
85
  return value;
79
86
  }
80
87
 
81
- export function acknowledgeGitCommit(storage, { workspace, stage, sessionId, sha }) {
88
+ export function acknowledgeGitCommit(storage, { workspace, stage, sessionId, sha, publication = null }) {
82
89
  const input = assertAcknowledgementHash(sha);
83
90
  const checkpoint = checkpointFor(storage.personalRoot, sessionId);
84
91
  if (!checkpoint.value) fail(ERROR_CODES.GIT_ACKNOWLEDGEMENT_CHECKPOINT_MISSING, "No Git checkpoint exists for this active session");
@@ -93,7 +100,11 @@ export function acknowledgeGitCommit(storage, { workspace, stage, sessionId, sha
93
100
  if (verified.head !== state.head || verified.ref !== state.ref || gitOperationInProgress(verified.root)) {
94
101
  fail(ERROR_CODES.GIT_ACKNOWLEDGEMENT_REF_CHANGED, "Git state changed while acknowledging the commit");
95
102
  }
96
- const value = { ...checkpoint.value, head: state.head, updated_at: new Date().toISOString() };
103
+ const value = { ...checkpoint.value, head: state.head, updated_at: new Date().toISOString(), ...(publication ? { publication: { ...publication, commit: state.head } } : {}) };
97
104
  atomicWrite(checkpoint.file, `${JSON.stringify(value, null, 2)}\n`);
98
- return { acknowledged: true, commit: state.head };
105
+ return { acknowledged: true, commit: state.head, ...(value.publication ? { publication: value.publication } : {}) };
106
+ }
107
+
108
+ export function gitPublicationReceipt(storage, sessionId) {
109
+ return checkpointFor(storage.personalRoot, sessionId).value?.publication || null;
99
110
  }
package/src/protocol.js CHANGED
@@ -2,8 +2,8 @@ import { createHash } from "node:crypto";
2
2
 
3
3
  export const WORK_CONTEXT_PROTOCOL = Object.freeze({
4
4
  schema: 1,
5
- major: 1,
6
- minor: 7,
5
+ major: 2,
6
+ minor: 0,
7
7
  });
8
8
 
9
9
  export const WORK_CONTEXT_PROTOCOL_DESCRIPTOR = Object.freeze({
@@ -13,7 +13,7 @@ export const WORK_CONTEXT_PROTOCOL_DESCRIPTOR = Object.freeze({
13
13
  major: WORK_CONTEXT_PROTOCOL.major,
14
14
  minor: WORK_CONTEXT_PROTOCOL.minor,
15
15
  }),
16
- operations: Object.freeze(["delivery.doctor", "commit.acknowledge", "commit.inspect_all", "commit.all", "candidate.confirm_coverage", "commit_mode.workspace.set", "commit_mode.stage.set", "commit_mode.effective.read", "execution.complete_current", "stage.delegate", "dependency.add", "dependency.remove", "dependency.handoff.publish", "dependency.context.read"]),
16
+ operations: Object.freeze(["delivery.doctor", "commit.acknowledge", "commit.inspect_all", "commit.all", "candidate.confirm_coverage", "commit_mode.workspace.set", "commit_mode.stage.set", "commit_mode.effective.read", "execution.complete_current", "stage.delegate", "dependency.add", "dependency.remove", "dependency.handoff.publish", "dependency.context.read", "help.scoped"]),
17
17
  });
18
18
 
19
19
  export const WORK_CONTEXT_PROTOCOL_DESCRIPTOR_BYTES = JSON.stringify(WORK_CONTEXT_PROTOCOL_DESCRIPTOR);
@@ -84,9 +84,26 @@ const activeSessionFromContext = (ctx, workspace, stage) => {
84
84
  return direct?.workspace === workspace && direct.stage === stage && direct.state === "active" ? direct : null;
85
85
  };
86
86
  const sessionFor = (ctx, oc, workspace, stage) => activeSessionFromContext(ctx, workspace, stage)?.session_id || oc.sessionID;
87
- const addStageFromTool = (ctx, args) => {
87
+ const addStageFromTool = (ctx, args, oc) => {
88
88
  const workspace = workspaceFromSession(ctx, args.workspace);
89
- return ctx.addStage(workspace, args.title, { goal: args.goal, prompt: args.prompt, dependsOn: args.dependsOn, executionProfile: args.executionProfile, executionDepth: args.executionDepth, classification: args.classification, reviewProfile: args.reviewProfile });
89
+ const created = ctx.addStage(workspace, args.title, { goal: args.goal, prompt: args.prompt, dependsOn: args.dependsOn, executionProfile: args.executionProfile, executionDepth: args.executionDepth, classification: args.classification, reviewProfile: args.reviewProfile });
90
+ if (!args.enterCurrentSession) return created;
91
+ if (ctx.sessionAffinityByOpenCodeId(oc.sessionID)) return {
92
+ ...created,
93
+ data: { ...created.data, next_action: "start_new_opencode_session_and_resume" },
94
+ };
95
+ const started = ctx.startSession(workspace, created.data.stage, { sessionId: randomUUID(), opencodeSessionId: oc.sessionID });
96
+ return {
97
+ ...started,
98
+ data: {
99
+ ...started.data,
100
+ created: true,
101
+ status: "in_progress",
102
+ session_started: true,
103
+ resume_required: false,
104
+ },
105
+ changed: [...new Set([...(created.changed || []), ...(started.changed || [])])],
106
+ };
90
107
  };
91
108
  export const work_context_list_workspaces = tool({ description: "List work-context workspaces.", args: {}, execute: run((ctx) => ctx.listWorkspaces()) });
92
109
  export const work_context_workspace_list = tool({ description: "List a workspace with stage descriptions and sessions.", args: { workspace: tool.schema.string() }, execute: run((ctx, a) => ctx.listStages(a.workspace)) });
@@ -118,18 +135,19 @@ export const work_context_doctor_delivery = createDoctorDeliveryTool();
118
135
  export const work_context_mark_delivery = tool({ description: "Record a confirmed environment delivery checkpoint without executing deployment. Requires DELIVERY_CONFIRMED.", args: { workspace: tool.schema.string(), environment: tool.schema.string(), commit: tool.schema.string(), confirmation: tool.schema.string() }, execute: run((ctx, a) => ctx.markDelivery(a.workspace, a.environment, a.commit, a.confirmation)) });
119
136
  export const work_context_workspace_finish = tool({ description: "Finish a workspace after all stages are completed.", args: { workspace: tool.schema.string() }, execute: run((ctx, a) => ctx.finishWorkspace(a.workspace)) });
120
137
  export const work_context_reopen_workspace = tool({ description: "Reopen a completed workspace with a required reason and durable history.", args: { workspace: tool.schema.string(), reason: tool.schema.string() }, execute: run((ctx, a) => ctx.reopenWorkspace(a.workspace, a.reason)) });
121
- export const work_context_create_workspace = tool({ description: "Create a workspace; enter its planning stage only when the native OpenCode session has no active or historical work-context stage affinity.", args: { title: tool.schema.string(), mode: tool.schema.enum(["standard", "startup"]).optional() }, execute: run((ctx, a, oc) => {
138
+ export const work_context_create_workspace = tool({ description: "Create a workspace. Pass enterCurrentSession only for an explicit user-issued /wc create operation; autonomous agent creation remains session-neutral.", args: { title: tool.schema.string(), mode: tool.schema.enum(["standard", "startup"]).optional(), enterCurrentSession: tool.schema.boolean().optional() }, execute: run((ctx, a, oc) => {
122
139
  const currentSession = ctx.sessionAffinityByOpenCodeId(oc.sessionID);
123
- return ctx.createWorkspace(a.title, { mode: a.mode, ...(currentSession ? { startSession: false } : { sessionId: randomUUID(), opencodeSessionId: oc.sessionID }) });
140
+ const enterCurrentSession = a.enterCurrentSession === true && !currentSession;
141
+ return ctx.createWorkspace(a.title, { mode: a.mode, ...(enterCurrentSession ? { sessionId: randomUUID(), opencodeSessionId: oc.sessionID } : { startSession: false }) });
124
142
  }) });
125
143
  export const work_context_start_session = tool({ description: "Start a new active session for the stage permanently associated with this OpenCode session and return its human-oriented presentation, prompt, active workspace knowledge, and startup policy when applicable. A different stage requires a separate OpenCode session.", args: { ...common, summary: tool.schema.string().optional() }, execute: run((ctx, a, oc) => ctx.startSession(a.workspace, a.stage, { sessionId: randomUUID(), opencodeSessionId: oc.sessionID, summary: a.summary, takeover: true })) });
126
- export const work_context_acknowledge_commit = tool({ description: "Acknowledge a user-created current-HEAD commit for the active session using a short or full commit hash. This is a deterministic light control-plane operation and does not infer ownership.", args: { sha: tool.schema.string() }, execute: run((ctx, a) => {
144
+ export const work_context_acknowledge_commit = tool({ description: "Validate and record a current-HEAD direct commit for the active session using a short or full commit hash. In mandatory startup per-item mode this binds publication to the exact Current item and revision.", args: { sha: tool.schema.string() }, execute: run((ctx, a) => {
127
145
  const affinity = sessionFromContext(ctx);
128
146
  const session = affinity && activeSessionFromContext(ctx, affinity.workspace, affinity.stage);
129
147
  if (!session) fail(ERROR_CODES.STAGE_CONTEXT_REQUIRED, "An active work-context stage is required to acknowledge a commit");
130
148
  return ctx.acknowledgeCommit(session.workspace, session.stage, session.session_id, a.sha);
131
149
  }) });
132
- export const work_context_add_stage = tool({ description: "Add a planned stage without starting or changing a stage session. When the user did not specify execution capability and depth, infer both from the prompt and pass classification: inferred. Explicit user choices use classification: explicit.", args: { workspace: tool.schema.string().optional(), title: tool.schema.string(), goal: tool.schema.string().optional(), prompt: tool.schema.string().optional(), dependsOn: tool.schema.array(tool.schema.string()).optional(), executionProfile: capabilityProfile.optional(), executionDepth: capabilityDepth.optional(), classification: tool.schema.enum(["inferred", "explicit"]).optional(), reviewProfile: capabilityProfile.optional() }, execute: run(addStageFromTool) });
150
+ export const work_context_add_stage = tool({ description: "Add a stage. Pass enterCurrentSession only for an explicit user-issued /wc stage add operation; autonomous agent creation remains planned and session-neutral. When the user did not specify execution capability and depth, infer both from the prompt and pass classification: inferred. Explicit user choices use classification: explicit.", args: { workspace: tool.schema.string().optional(), title: tool.schema.string(), goal: tool.schema.string().optional(), prompt: tool.schema.string().optional(), dependsOn: tool.schema.array(tool.schema.string()).optional(), executionProfile: capabilityProfile.optional(), executionDepth: capabilityDepth.optional(), classification: tool.schema.enum(["inferred", "explicit"]).optional(), reviewProfile: capabilityProfile.optional(), enterCurrentSession: tool.schema.boolean().optional() }, execute: run(addStageFromTool) });
133
151
  export const work_context_delegate_stage = tool({ description: "Atomically create a delegated working stage and add it as a dependency of the active delegating stage.", args: { ...contextualStage, title: tool.schema.string(), requestedOutcome: tool.schema.string(), goal: tool.schema.string().optional(), prompt: tool.schema.string().optional(), dependsOn: tool.schema.array(tool.schema.string()).optional(), executionProfile: capabilityProfile.optional(), executionDepth: capabilityDepth.optional(), classification: tool.schema.enum(["inferred", "explicit"]).optional(), reviewProfile: capabilityProfile.optional() }, execute: run((ctx, a, oc) => { const workspace = workspaceFromSession(ctx, a.workspace); const stage = stageFromSession(ctx, workspace, a.stage); return ctx.delegateStage(workspace, stage, sessionFor(ctx, oc, workspace, stage), a.title, a.requestedOutcome, a); }) });
134
152
  export const work_context_add_stage_dependency = tool({ description: "Add one explicit cycle-safe dependency edge to an actionable dependent stage.", args: { ...contextualStage, dependency: tool.schema.string() }, execute: run((ctx, a) => { const workspace = workspaceFromSession(ctx, a.workspace); return ctx.addStageDependency(workspace, stageFromSession(ctx, workspace, a.stage), a.dependency); }) });
135
153
  export const work_context_remove_stage_dependency = tool({ description: "Remove one explicit dependency edge while retaining historical handoffs.", args: { ...contextualStage, dependency: tool.schema.string() }, execute: run((ctx, a) => { const workspace = workspaceFromSession(ctx, a.workspace); return ctx.removeStageDependency(workspace, stageFromSession(ctx, workspace, a.stage), a.dependency); }) });
@@ -160,7 +178,7 @@ export const work_context_force_close_session = tool({ description: "Force close
160
178
  export const work_context_handoff_stage = tool({ description: "Hand off the current stage by closing the current session; workspace and stage can be omitted in the current OpenCode session.", args: contextualStage, execute: run((ctx, a, oc) => { const workspace = workspaceFromSession(ctx, a.workspace); const stage = stageFromSession(ctx, workspace, a.stage); return ctx.handoff(workspace, stage, sessionFor(ctx, oc, workspace, stage)); }) });
161
179
  export const work_context_abandon_stage = tool({ description: "Abandon the current stage session without completing the stage; workspace and stage can be omitted in the current OpenCode session.", args: contextualStage, execute: run((ctx, a, oc) => { const workspace = workspaceFromSession(ctx, a.workspace); const stage = stageFromSession(ctx, workspace, a.stage); return ctx.abandon(workspace, stage, sessionFor(ctx, oc, workspace, stage)); }) });
162
180
  export const work_context_finish_stage = tool({ description: "Finish a stage only for an explicit user lifecycle request, unless the Planning-stage prompt explicitly permits automatic completion. Direct dependents receive one immutable final handoff. Review durable workspace knowledge; use knowledgeReview=added after changes or none when no durable findings exist.", args: { ...contextualStage, result: tool.schema.string().optional(), handoffOutcome: tool.schema.string().optional(), knowledgeReview: tool.schema.string().optional(), candidateIds: tool.schema.array(tool.schema.string()).optional(), commits: tool.schema.array(tool.schema.string()).optional(), verification: tool.schema.array(tool.schema.string()).optional(), blockers: tool.schema.array(tool.schema.string()).optional() }, execute: run((ctx, a, oc) => { const workspace = workspaceFromSession(ctx, a.workspace); const stage = stageFromSession(ctx, workspace, a.stage); return ctx.finish(workspace, stage, sessionFor(ctx, oc, workspace, stage), a); }) });
163
- export const work_context_help = tool({ description: "Show work-context command help.", args: { command: tool.schema.string().optional() }, execute: run((ctx, a) => ctx.help(a.command)) });
181
+ export const work_context_help = tool({ description: "Show the command catalog or return the exact tool mapping and scoped contract for one canonical work-context command selector.", args: { command: tool.schema.string().optional() }, execute: run((ctx, a) => ctx.help(a.command)) });
164
182
  export const work_context_list_knowledge = tool({ description: "List durable knowledge entries for a workspace.", args: { workspace: tool.schema.string() }, execute: run((ctx, a) => ctx.listKnowledge(a.workspace)) });
165
183
  export const work_context_add_knowledge = tool({ description: "Add a durable knowledge entry.", args: { workspace: tool.schema.string(), title: tool.schema.string(), kind: tool.schema.string().optional(), text: tool.schema.string(), sources: tool.schema.array(tool.schema.string()).optional() }, execute: run((ctx, a) => ctx.addKnowledge(a.workspace, a)) });
166
184
  export const work_context_update_knowledge = tool({ description: "Update a durable knowledge entry.", args: { workspace: tool.schema.string(), knowledgeId: tool.schema.string(), title: tool.schema.string().optional(), kind: tool.schema.string().optional(), status: tool.schema.string().optional(), text: tool.schema.string().optional(), sources: tool.schema.array(tool.schema.string()).optional(), replacement: tool.schema.string().optional() }, execute: run((ctx, a) => ctx.updateKnowledge(a.workspace, a.knowledgeId, a)) });