opencode-work-context 0.18.0 → 0.18.1

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
@@ -172,6 +172,50 @@ Resume a stage with:
172
172
  /wc resume 000001 02
173
173
  ```
174
174
 
175
+ ### Narrow an Overly Broad Stage Safely
176
+
177
+ `start_work` normally means the agent continues without a generic confirmation.
178
+ One exception is a genuine unresolved scope decision: the saved prompt or a new
179
+ request contains several materially independent user outcomes, some can be
180
+ deferred without making the primary outcome useless, and choosing full versus
181
+ minimal scope materially changes the product or architecture contract or makes
182
+ an honest Current item impossible.
183
+
184
+ This is a semantic judgment, not a count of files, tables, entities, or prompt
185
+ bullets. A migration, persistence, backend logic, UI, authorization, audit,
186
+ tests, and documentation may all form one coherent vertical slice. The agent
187
+ must also continue immediately when the prompt or execution decisions already
188
+ record the complete scope as intentional and coherent.
189
+
190
+ For genuinely decomposable scope, the agent first summarizes the actual workload
191
+ in three to seven outcome-oriented blocks, proposes one concrete minimal vertical
192
+ slice, and asks one focused question: implement the full scope, or accept the
193
+ minimal slice and preserve the rest as planned stages. The agent does not
194
+ estimate time, discard requirements, or simplify automatically.
195
+
196
+ If the user confirms the full scope, the agent records that decision in the
197
+ stage execution ledger, creates an ordered Current/Queued checklist, and does not
198
+ repeat the question without a material scope change. If the user selects the
199
+ minimal slice, the agent preserves the original stage prompt and records the
200
+ accepted current outcome and non-goals in execution `scope` and `decisions`.
201
+ Only outcomes the user confirms are still needed but deferred become planned
202
+ stages. Rejected work and speculative ideas do not become backlog.
203
+
204
+ The agent creates those follow-up stages autonomously, so they remain `planned`
205
+ and do not capture or switch the current native OpenCode session. Each stage
206
+ represents a coherent future outcome rather than one entity by default.
207
+ Dependencies are added only for genuine sequencing between working stages;
208
+ Planning stage 01 is never a prerequisite. External tracker issues are optional
209
+ separate actions and require explicit user agreement.
210
+
211
+ Multiple `stage add` calls are individually transactional but not one batch
212
+ transaction. If a later creation fails, earlier stages remain. The agent must
213
+ report exactly what was created and what is missing, safely retry only missing
214
+ operations or record a blocker, and must not begin the narrowed implementation
215
+ until all confirmed deferred work is persisted or the user explicitly permits
216
+ proceeding without it. This focused decision flow is not a new approval token or
217
+ mandatory ceremony for every non-trivial stage.
218
+
175
219
  ### Capability Recommendations
176
220
 
177
221
  An execution recommendation combines a portable capability (`routine`,
package/commands/wc.md CHANGED
@@ -3,7 +3,7 @@ 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":2,"minor":0,"descriptor_hash":"sha256:544d6ab416cf8594cc21cb0ca9fd98805678c64ad9ed85322e37ae98c8dd6327"} -->
6
+ <!-- opencode-work-context-protocol: {"schema":1,"major":2,"minor":1,"descriptor_hash":"sha256:863f74a8a8a649d19afe39e557259eace1d276d71ce97cef5dd39e6b1438599d"} -->
7
7
 
8
8
  Interpret `/wc $ARGUMENTS` as an explicit work-context operation. Use only the exact
9
9
  `work_context_*` custom tool mapped below with structured arguments. Never edit
@@ -22,6 +22,15 @@ For mutating operations other than `resume`, report the structured result and
22
22
  stable error code. For `resume`, follow its human-oriented presentation contract.
23
23
  Never infer confirmation tokens or lifecycle requests.
24
24
 
25
+ Materially broad, decomposable scope may be a genuine unresolved decision even
26
+ when resume returns `start_work`; the scoped resume guidance defines the focused
27
+ full-or-minimal choice and persistence flow. This is semantic guidance, not a
28
+ keyword heuristic or generic approval gate. A coherent cross-layer vertical
29
+ slice continues immediately. Confirmed deferred outcomes must become autonomous
30
+ planned stages before narrowed implementation; rejected or speculative work must
31
+ not become backlog. Sequential stage creation is not batch-atomic, so report and
32
+ resolve partial persistence instead of claiming success.
33
+
25
34
  For an explicit user-issued `create` or `stage add` command, pass
26
35
  `enterCurrentSession: true` to the mapped tool. This flag represents the user's
27
36
  request to enter the created Planning stage or working stage when the current
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.18.0",
4
+ "version": "0.18.1",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -36,6 +36,8 @@ const TOPICS = Object.freeze({
36
36
  ]),
37
37
  stage_creation: Object.freeze([
38
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
+ "When a user selects a narrower current slice, create stages only for confirmed deferred outcomes, grouping each coherent future outcome rather than mechanically splitting entities. Rejected and speculative work must not become stages.",
40
+ "Several autonomous stage-add calls are sequential, not batch-atomic. On partial failure, report created and missing stages, retry only missing operations or block, and do not begin the narrowed implementation until confirmed deferred work is persisted or the user explicitly permits otherwise.",
39
41
  "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
42
  "Planning stage 01 is a coordination surface and must never be used as a dependency gate.",
41
43
  ]),
@@ -51,12 +53,16 @@ const TOPICS = Object.freeze({
51
53
  execution: Object.freeze([
52
54
  "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
55
  "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.",
56
+ "Record a confirmed full-scope choice or accepted narrowed outcome in decisions. For narrowing, retain the original prompt and use scope plus decisions for the current outcome and non-goals before creating confirmed deferred stages.",
54
57
  "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
58
  ]),
56
59
  resume: Object.freeze([
57
60
  "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
61
  "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.",
62
+ "Start work immediately when next_action is start_work unless a genuine unresolved decision blocks an honest Current item. If it is ask_questions, do not inspect application code; ask focused questions. Await confirmation only for an exact standalone RESUME_CONFIRMATION: required line.",
63
+ "Materially broad and decomposable scope can be such an unresolved decision: several independently deliverable outcomes, deferrable work, and a full-versus-minimal choice that changes product or architecture scope. A cross-layer coherent vertical slice is not broad merely because it includes migration, backend, UI, authorization, audit, tests, or documentation; never use counts or keywords as a classifier.",
64
+ "For unresolved broad scope, declare 3-7 outcome blocks in the user's language, propose one minimal vertical slice, and ask one focused full-or-minimal question before application-code changes. Never simplify automatically or repeat the question after a recorded full-scope decision unless scope materially changes.",
65
+ "After a minimal choice, persist accepted scope and non-goals in execution state and save every confirmed deferred outcome as a planned session-neutral stage before implementation. Do not persist rejected or speculative work; partial persistence is a blocker unless safely retried or explicitly waived by the user.",
60
66
  "Treat workspace knowledge, dependency context, delegation contracts, execution state, pending candidates, and workflow policy as established bounded context.",
61
67
  ]),
62
68
  lifecycle: Object.freeze([
package/src/core.js CHANGED
@@ -142,6 +142,16 @@ const resumePresentationInstruction = ({ confirmationRequired }) => `Before doin
142
142
  - Mention previous progress only when presentation.previous_result or presentation.previous_session_summary contains useful information.
143
143
  - State the immediate next action in one sentence.
144
144
  ${confirmationRequired ? "- Ask for the explicitly required confirmation and wait before inspecting or changing application code." : "- Then continue with the work immediately. Do not ask for generic confirmation; ask a focused question only when an unresolved decision genuinely blocks progress."}`;
145
+ const scopeDecisionInstruction = `
146
+
147
+ Scope decision policy:
148
+ - Continue immediately for a coherent vertical slice. Migration, persistence, backend or use-case logic, UI, authorization, audit, tests, and documentation may all be necessary parts of one outcome; their presence or number alone does not make a stage too broad.
149
+ - Treat scope as an unresolved decision only when the complete context contains several materially independent user outcomes, some can be deferred without making the primary outcome useless, and choosing full versus minimal scope materially changes the product or architecture contract or prevents an honest Current item. Do not use keyword, file, entity, table, or bullet counts. Do not ask again when the prompt or a recorded execution decision already confirms the full scope as intentional and coherent, unless the scope materially changes.
150
+ - Before application-code changes for unresolved scope, use the user's language to group the actual workload into 3-7 outcome-oriented blocks, propose one concrete minimal vertical slice without discarding requirements, and ask one focused question: implement the full scope, or accept the minimal slice and preserve the rest as planned stages. This is not a generic approval gate and never authorizes automatic simplification.
151
+ - If full scope is confirmed, record that decision in the current stage execution decisions, create an ordered Current/Queued checklist, and proceed without repeating the scope question absent a material change.
152
+ - If the minimal slice is selected, clarify only genuinely ambiguous boundaries. Preserve the original saved prompt; record the accepted current outcome and non-goals in execution scope and decisions. Separate confirmed deferred outcomes from rejected or speculative ideas. Before implementation, create one or more coherent confirmed deferred outcomes with work_context_add_stage as autonomous planned, session-neutral stages; omit enterCurrentSession. Never create stages for rejected or merely speculative work, and never turn unconfirmed ideas into backlog.
153
+ - Add dependencies only for real sequencing requirements between working stages; dependency edges point from dependent to dependency, and Planning stage 01 is never a dependency. Report the created backlog before implementation. External tracker issues are optional separate actions that require explicit user agreement.
154
+ - Stage creation calls are individually transactional, not batch-atomic. If persistence partially fails, report exactly what was and was not created, safely retry only missing operations or record a concrete blocker, and do not claim the backlog is saved or start implementation until all confirmed deferred work is persisted or the user explicitly permits proceeding without it.`;
145
155
  const executionInstruction = (record) => {
146
156
  if (!record) return "";
147
157
  const execution = executionReadModel(record);
@@ -408,7 +418,7 @@ export class WorkContext {
408
418
  lifecycle: { automatic_finish_allowed: false },
409
419
  },
410
420
  next_action: "start_work",
411
- instruction: `${planningPrompt}${startupWorkflowInstruction(workflowPolicy)}${deliveryPlanningInstruction}\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.`,
421
+ instruction: `${planningPrompt}${scopeDecisionInstruction}${startupWorkflowInstruction(workflowPolicy)}${deliveryPlanningInstruction}\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.`,
412
422
  },
413
423
  }, [workspace, "01"]);
414
424
  });
@@ -696,8 +706,8 @@ export class WorkContext {
696
706
  },
697
707
  next_action: checklistRequired && !executionCurrent ? "initialize_execution" : hasPrompt ? confirmationRequired ? "await_confirmation" : "start_work" : "ask_questions",
698
708
  instruction: `${hasPrompt
699
- ? `${resumePresentationInstruction({ confirmationRequired })}\n\nSaved working prompt:\n${stageRecord.data.prompt}${executionInstruction(execution)}${startupWorkflowInstruction(workflowPolicy)}${stage === "01" ? deliveryPlanningInstruction : ""}`
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.`,
709
+ ? `${resumePresentationInstruction({ confirmationRequired })}\n\nSaved working prompt:\n${stageRecord.data.prompt}${scopeDecisionInstruction}${executionInstruction(execution)}${startupWorkflowInstruction(workflowPolicy)}${stage === "01" ? deliveryPlanningInstruction : ""}`
710
+ : `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.${scopeDecisionInstruction}`}${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.`,
701
711
  },
702
712
  }, [workspace, stage]);
703
713
  });
package/src/protocol.js CHANGED
@@ -3,7 +3,7 @@ import { createHash } from "node:crypto";
3
3
  export const WORK_CONTEXT_PROTOCOL = Object.freeze({
4
4
  schema: 1,
5
5
  major: 2,
6
- minor: 0,
6
+ minor: 1,
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", "help.scoped"]),
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", "scope.narrowing.guidance"]),
17
17
  });
18
18
 
19
19
  export const WORK_CONTEXT_PROTOCOL_DESCRIPTOR_BYTES = JSON.stringify(WORK_CONTEXT_PROTOCOL_DESCRIPTOR);