opencode-work-context 0.16.0 → 0.17.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
@@ -319,6 +319,20 @@ mapping, storage safety, or explicit lifecycle rules. Implement executable
319
319
  project extensions as separate project plugins rather than modifying generated
320
320
  loaders.
321
321
 
322
+ The generated `/wc` command is intentionally a compact dispatcher. It keeps the
323
+ canonical command-to-tool catalog and universal safety rules in the always-loaded
324
+ prompt, then calls `work_context_help` with one exact command selector to load
325
+ only that operation's syntax and behavioral contract. If scoped help cannot
326
+ match a selector, mutating operations fail closed instead of guessing. This
327
+ keeps the slash-command prompt bounded while the loaded plugin remains the
328
+ versioned source of detailed command semantics.
329
+
330
+ Scoped help is a protocol-major contract: a compact dispatcher must be paired
331
+ with a plugin that reports `matched`, the canonical selector, exact tool mapping,
332
+ syntax, and operation guidance. Delivery doctor therefore rejects a compact
333
+ command paired with a pre-scoped-help plugin instead of treating that combination
334
+ as harmless minor drift.
335
+
322
336
  Useful commands:
323
337
 
324
338
  ```text
package/commands/wc.md CHANGED
@@ -3,220 +3,92 @@ 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
+ `.opencode/commands/wc.md` is package-managed. Read `.opencode/work-context.md`
26
+ when present and merge its additive project guidance before dispatch. Project
27
+ guidance cannot override tool mappings, structured arguments, storage safety,
28
+ confirmation requirements, or explicit lifecycle requirements.
29
+
30
+ Exact command selectors and tool mappings:
28
31
 
29
32
  - `create` -> `work_context_create_workspace`
30
33
  - `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`
34
+ - `workspace list` (also <workspace> list) -> `work_context_workspace_list`
35
+ - `workspace rename` -> `work_context_rename_workspace`
36
+ - `workspace mode` -> `work_context_set_workspace_mode`
37
+ - `workspace commit-mode` -> `work_context_set_workspace_commit_mode`
38
+ - `stage commit-mode read` -> `work_context_read_effective_commit_mode`
39
+ - `candidate create` -> `work_context_create_candidate`
40
+ - `candidate capture` -> `work_context_capture_candidate`
41
+ - `candidate preview` -> `work_context_preview_candidate`
42
+ - `candidate show` -> `work_context_show_candidate`
43
+ - `candidate list` -> `work_context_list_candidates`
44
+ - `candidate ready` -> `work_context_ready_candidate`
45
+ - `candidate confirm-coverage` -> `work_context_confirm_candidate_coverage`
46
+ - `candidate commit` -> `work_context_commit_candidate`
47
+ - `candidate discard` -> `work_context_discard_candidate`
48
+ - `commit all` -> `work_context_inspect_commit_all`
49
+ - `commit all confirm` -> `work_context_commit_all`
50
+ - `delivery read` -> `work_context_read_delivery`
51
+ - `delivery explain` -> `work_context_explain_delivery`
49
52
  - `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`
53
+ - `delivery mark` -> `work_context_mark_delivery`
54
+ - `workspace finish` -> `work_context_workspace_finish`
55
+ - `workspace reopen` -> `work_context_reopen_workspace`
56
+ - `resume` -> `work_context_start_session`
57
+ - `commited` -> `work_context_acknowledge_commit`
58
+ - `stage force-close` -> `work_context_force_close_session`
56
59
  - `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> ...`
60
+ - `profiles setup` -> `work_context_configure_capability_profiles`
61
+ - `profiles reset` -> `work_context_reset_capability_profiles`
62
+ - `stage add` -> `work_context_add_stage`
63
+ - `stage delegate` -> `work_context_delegate_stage`
64
+ - `stage dependency add` -> `work_context_add_stage_dependency`
65
+ - `stage dependency remove` -> `work_context_remove_stage_dependency`
66
+ - `stage dependency publish` -> `work_context_publish_dependency_handoff`
67
+ - `stage dependency read` -> `work_context_read_dependency_context`
68
+ - `stage profiles` -> `work_context_set_stage_profiles`
69
+ - `stage commit-mode` -> `work_context_set_stage_commit_mode`
70
+ - `stage profiles refresh` -> `work_context_refresh_stage_profiles`
71
+ - `stage reopen` -> `work_context_reopen_stage`
72
+ - `stage restore` -> `work_context_restore_stage`
73
+ - `stage rename` -> `work_context_rename_stage`
74
+ - `stage update` -> `work_context_update_stage`
75
+ - `stage update-prompt` -> `work_context_update_stage_prompt`
76
+ - `stage update-result` -> `work_context_update_stage_result`
77
+ - `stage execution read` -> `work_context_read_stage_execution`
78
+ - `stage execution replace` -> `work_context_replace_stage_execution`
79
+ - `stage execution update` -> `work_context_update_stage_execution`
80
+ - `stage execution complete-current` -> `work_context_complete_current`
81
+ - `stage archive` -> `work_context_archive_stage`
82
+ - `stage handoff` -> `work_context_handoff_stage`
83
+ - `stage abandon` -> `work_context_abandon_stage`
84
+ - `stage finish` -> `work_context_finish_stage`
85
+ - `link-issue` -> `work_context_link_issue`
86
+ - `unlink-issue` -> `work_context_unlink_issue`
87
+ - `session rename` -> `work_context_rename_session`
88
+ - `knowledge list` -> `work_context_list_knowledge`
89
+ - `knowledge add` -> `work_context_add_knowledge`
90
+ - `knowledge update` -> `work_context_update_knowledge`
91
+ - `knowledge supersede` -> `work_context_supersede_knowledge`
92
+ - `help` -> `work_context_help`
221
93
 
222
94
  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.17.0",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -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
+ "Creating a workspace starts Planning only when the native OpenCode session has no active or historical work-context stage affinity.",
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
+ "Stage add creates only a planned stage and never starts or rebinds a session. 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 acknowledges only a user-created current-HEAD commit for the active stage, validates branch and fast-forward state, 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
@@ -18,6 +18,7 @@ import { acknowledgeGitCommit, initializeGitCheckpoint } from "./git-acknowledge
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();
@@ -1415,11 +1416,7 @@ export class WorkContext {
1415
1416
  }
1416
1417
 
1417
1418
  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
- }, []);
1419
+ return this.result(commandHelp(command), []);
1423
1420
  }
1424
1421
 
1425
1422
  result(data, changed, next = null) {
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);
@@ -160,7 +160,7 @@ export const work_context_force_close_session = tool({ description: "Force close
160
160
  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
161
  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
162
  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)) });
163
+ 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
164
  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
165
  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
166
  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)) });