opencode-work-context 0.15.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.
@@ -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
@@ -17,8 +17,44 @@ import { CAPABILITY_CLASSIFICATIONS, CAPABILITY_DEPTHS, CAPABILITY_PROFILES, cap
17
17
  import { acknowledgeGitCommit, initializeGitCheckpoint } from "./git-acknowledgement.js";
18
18
  import { isCommitAncestor, repositoryState, rollbackCommitRef } from "./git-candidates.js";
19
19
  import { enqueueIntegrationNotice } from "./integration-notices.js";
20
+ import { DependencyHandoffStore } from "./dependency-handoffs.js";
21
+ import { commandHelp } from "./command-help.js";
20
22
 
21
23
  const actor = (options) => options.actor || "OpenCode";
24
+ const directDependents = (stages, sourceStage) => stages.filter((item) => item.depends_on.includes(sourceStage)).map((item) => item.stage).sort();
25
+ const dependencyEpochs = (stage, timestamp) => ({
26
+ ...Object.fromEntries((stage.depends_on || []).map((dependency) => [dependency, { generation: 1, added_at: stage.created_at || timestamp }])),
27
+ ...(stage.dependency_epochs || {}),
28
+ });
29
+ const targetGenerations = (stages, sourceStage, targets) => Object.fromEntries(targets.map((target) => {
30
+ const dependent = stages.find((stage) => stage.stage === target);
31
+ return [target, dependent.dependency_epochs?.[sourceStage]?.generation || 1];
32
+ }));
33
+ const assertProspectiveDependencyGraph = (stages) => {
34
+ const byId = new Map(stages.map((stage) => [stage.stage, stage]));
35
+ const visiting = new Set();
36
+ const visited = new Set();
37
+ const visit = (stage) => {
38
+ if (visiting.has(stage)) fail(ERROR_CODES.DEPENDENCY_CYCLE, "Stage dependency cycle detected", { stage });
39
+ if (visited.has(stage)) return;
40
+ visiting.add(stage);
41
+ for (const dependency of byId.get(stage).depends_on) {
42
+ if (!byId.has(dependency)) fail(ERROR_CODES.NOT_FOUND, `Stage dependency not found: ${dependency}`, { dependency });
43
+ visit(dependency);
44
+ }
45
+ visiting.delete(stage);
46
+ visited.add(stage);
47
+ };
48
+ for (const stage of byId.keys()) visit(stage);
49
+ };
50
+ const assertDependencyMutationStage = (stage, role) => {
51
+ if (!["planned", "in_progress"].includes(stage.status)) fail(ERROR_CODES.INVALID_STATE, `${role} stage must be planned or in progress`, { stage: stage.stage, status: stage.status });
52
+ };
53
+ const boundedList = (value, name) => {
54
+ if (value === undefined) return [];
55
+ if (!Array.isArray(value) || value.length > 20 || value.some((item) => typeof item !== "string" || !item.trim() || item.trim().length > 500)) fail(ERROR_CODES.INVALID_ARGUMENT, `${name} must contain at most 20 bounded non-empty strings`);
56
+ return value.map((item) => item.trim());
57
+ };
22
58
  const enqueueCoverageNotices = (storage, publication) => {
23
59
  const coverage = publication?.candidate_record?.coverage;
24
60
  if (!coverage) return { queued: 0, skipped: 0 };
@@ -224,6 +260,7 @@ export class WorkContext {
224
260
  return { ...stage, description: stage.goal };
225
261
  });
226
262
  const ids = new Set(stages.map((item) => item.stage));
263
+ for (const stage of stages) if (stage.delegation && !ids.has(stage.delegation.dependent_stage)) fail(ERROR_CODES.STORAGE_ERROR, `Missing delegation dependent stage: ${stage.delegation.dependent_stage}`);
227
264
  const visiting = new Set();
228
265
  const visited = new Set();
229
266
  const visit = (stage) => {
@@ -425,6 +462,7 @@ export class WorkContext {
425
462
 
426
463
  candidates() { return new CandidateStore(this); }
427
464
  deliveries() { return new DeliveryStore(this); }
465
+ handoffs() { return new DependencyHandoffStore(this.storage); }
428
466
 
429
467
  createCandidate(workspace, title, message = null, options = {}) {
430
468
  return this.transact("candidate-create", () => this.result(this.candidates().create(workspace, title, message, options), ["local:candidates"]));
@@ -591,8 +629,9 @@ export class WorkContext {
591
629
  const committedCoverage = workflowPolicy ? this.candidates().committedCoverageProjection(workspace).by_stage[stage] || null : null;
592
630
  const deliveryContext = stage === "01" ? this.deliveries().projection(workspace) : null;
593
631
  const hasDeliveryContext = deliveryContext && (deliveryContext.committed.count || deliveryContext.environments.length || deliveryContext.unavailable);
594
- const workspaceKnowledge = activeKnowledge(this.listKnowledge(workspace).data);
595
- const execution = this.storage.readStageExecution(workspace, stage);
632
+ const workspaceKnowledge = activeKnowledge(this.listKnowledge(workspace).data);
633
+ const execution = this.storage.readStageExecution(workspace, stage);
634
+ const dependencyContext = stageRecord.data.depends_on.length ? this.handoffs().context(workspace, stage, this.listStages(workspace).data.stages) : null;
596
635
  const automaticFinish = automaticFinishAllowed(this.storage, workspace);
597
636
  const recommendations = capabilityRecommendations(this.storage, stageRecord.data, readCapabilityMappings(this.storage, { homeDir: this.options.capabilityProfilesHome }));
598
637
  return this.result({
@@ -630,6 +669,8 @@ export class WorkContext {
630
669
  ...(recommendations ? { capability_profiles: recommendations } : {}),
631
670
  ...(pendingCandidates ? { pending_candidates: pendingCandidates } : {}),
632
671
  ...(committedCoverage ? { committed_integration_coverage: committedCoverage } : {}),
672
+ ...(stageRecord.data.delegation ? { delegation_contract: stageRecord.data.delegation } : {}),
673
+ ...(dependencyContext ? { dependency_context: dependencyContext } : {}),
633
674
  ...(hasDeliveryContext ? { delivery_context: deliveryContext } : {}),
634
675
  ...(workflowPolicy ? { workflow_policy: workflowPolicy } : {}),
635
676
  lifecycle: { automatic_finish_allowed: automaticFinish },
@@ -683,6 +724,139 @@ export class WorkContext {
683
724
  });
684
725
  }
685
726
 
727
+ delegateStage(workspace, delegatorStage, sessionId, title, requestedOutcome, options = {}) {
728
+ workspace = normalizeWorkspaceId(workspace);
729
+ delegatorStage = normalizeStageId(delegatorStage);
730
+ if (delegatorStage === "01") fail(ERROR_CODES.PLANNING_DEPENDENCY_FORBIDDEN, "Planning stage 01 cannot depend on delegated working stages");
731
+ if (!title?.trim()) fail(ERROR_CODES.INVALID_ARGUMENT, "Title is required");
732
+ if (!requestedOutcome?.trim() || requestedOutcome.trim().length > 4000) fail(ERROR_CODES.INVALID_ARGUMENT, "requestedOutcome must be a bounded non-empty string");
733
+ const dependsOn = (options.dependsOn || []).map(normalizeStageId);
734
+ if (!Array.isArray(options.dependsOn || []) || new Set(dependsOn).size !== dependsOn.length) fail(ERROR_CODES.INVALID_ARGUMENT, "dependsOn must contain unique stage IDs");
735
+ if (dependsOn.includes("01")) fail(ERROR_CODES.PLANNING_DEPENDENCY_FORBIDDEN, "Working stages cannot depend on Planning stage 01");
736
+ assertCapabilityProfile(options.executionProfile, "executionProfile");
737
+ assertCapabilityDepth(options.executionDepth, "executionDepth");
738
+ assertCapabilityClassification(options.classification);
739
+ assertCapabilityProfile(options.reviewProfile, "reviewProfile");
740
+ if (Boolean(options.executionProfile) !== Boolean(options.executionDepth)) fail(ERROR_CODES.INVALID_ARGUMENT, "executionProfile and executionDepth must be provided together");
741
+ return this.transact(`workspace-${workspace}`, () => {
742
+ const stages = this.listStages(workspace).data.stages;
743
+ const delegator = stages.find((item) => item.stage === delegatorStage);
744
+ if (!delegator) fail(ERROR_CODES.NOT_FOUND, "Delegating stage not found");
745
+ assertDependencyMutationStage(delegator, "Delegating");
746
+ assertActive(this.storage.readEvents(), workspace, delegatorStage, sessionId);
747
+ if (stages.length >= 99) fail(ERROR_CODES.INVALID_STATE, "A workspace cannot contain more than 99 stages");
748
+ const stage = String(Math.max(0, ...stages.map((item) => Number(item.stage))) + 1).padStart(2, "0");
749
+ if (dependsOn.includes(stage)) fail(ERROR_CODES.INVALID_ARGUMENT, "A stage cannot depend on itself");
750
+ if (dependsOn.some((dependency) => !stages.some((item) => item.stage === dependency))) fail(ERROR_CODES.NOT_FOUND, "dependsOn must reference existing stages");
751
+ if (dependsOn.some((dependency) => stages.find((item) => item.stage === dependency).status === "cancelled")) fail(ERROR_CODES.INVALID_STATE, "A delegated stage cannot depend on a cancelled stage");
752
+ const now = new Date().toISOString();
753
+ const prompt = options.prompt?.trim() || undefined;
754
+ const metadata = { schema: 1, workspace, stage, title: title.trim(), status: "planned", goal: options.goal || title.trim(), ...(prompt ? { prompt } : {}), depends_on: dependsOn, delegation: { schema: 1, dependent_stage: delegatorStage, requested_outcome: requestedOutcome.trim(), created_at: now }, owner: options.owner || actor(this.options), ...(options.executionProfile ? { execution_profile: options.executionProfile, execution_depth: options.executionDepth, execution_classification: options.classification || "explicit" } : {}), ...(options.reviewProfile ? { review_profile: options.reviewProfile } : {}), created_at: now, updated_at: now, tracker_links: [] };
755
+ const delegatorRecord = this.storage.readStage(workspace, delegatorStage);
756
+ delegatorRecord.data.depends_on = [...delegatorRecord.data.depends_on, stage].sort();
757
+ delegatorRecord.data.dependency_epochs = { ...dependencyEpochs(delegatorRecord.data, now), [stage]: { generation: 1, added_at: now } };
758
+ delegatorRecord.data.updated_at = now;
759
+ assertProspectiveDependencyGraph([...stages.filter((item) => item.stage !== delegatorStage), { ...delegator, depends_on: delegatorRecord.data.depends_on }, metadata]);
760
+ this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), metadata, body(title, options.goal || title, prompt));
761
+ this.storage.writeMarkdown(this.storage.stageFile(workspace, delegatorStage), delegatorRecord.data, delegatorRecord.body);
762
+ generateProjections(this.storage);
763
+ return this.result({ workspace, delegator_stage: delegatorStage, stage, status: "planned", dependency_added: true, delegation_contract: metadata.delegation, session_started: false, resume_required: true }, [workspace, delegatorStage, stage]);
764
+ });
765
+ }
766
+
767
+ addStageDependency(workspace, stage, dependency) {
768
+ workspace = normalizeWorkspaceId(workspace);
769
+ stage = normalizeStageId(stage);
770
+ dependency = normalizeStageId(dependency);
771
+ if (stage === "01") fail(ERROR_CODES.PLANNING_DEPENDENCY_FORBIDDEN, "Planning stage 01 cannot depend on working stages");
772
+ if (dependency === "01") fail(ERROR_CODES.PLANNING_DEPENDENCY_FORBIDDEN, "Working stages cannot depend on Planning stage 01");
773
+ if (stage === dependency) fail(ERROR_CODES.INVALID_ARGUMENT, "A stage cannot depend on itself");
774
+ return this.transact(`workspace-${workspace}`, () => {
775
+ const stages = this.listStages(workspace).data.stages;
776
+ const dependent = stages.find((item) => item.stage === stage);
777
+ const source = stages.find((item) => item.stage === dependency);
778
+ if (!dependent || !source) fail(ERROR_CODES.NOT_FOUND, "Both dependency stages must exist");
779
+ assertDependencyMutationStage(dependent, "Dependent");
780
+ if (source.status === "cancelled") fail(ERROR_CODES.INVALID_STATE, "A cancelled stage cannot become a dependency", { stage: dependency, status: source.status });
781
+ if (dependent.depends_on.includes(dependency)) fail(ERROR_CODES.DEPENDENCY_EDGE_EXISTS, "Stage dependency already exists", { stage, dependency });
782
+ const nextDependencies = [...dependent.depends_on, dependency].sort();
783
+ assertProspectiveDependencyGraph(stages.map((item) => item.stage === stage ? { ...item, depends_on: nextDependencies } : item));
784
+ const record = this.storage.readStage(workspace, stage);
785
+ const epochs = dependencyEpochs(record.data, new Date().toISOString());
786
+ const previous = epochs[dependency];
787
+ const addedAt = new Date().toISOString();
788
+ record.data.depends_on = nextDependencies;
789
+ record.data.dependency_epochs = { ...epochs, [dependency]: { generation: (previous?.generation || 0) + 1, added_at: addedAt } };
790
+ record.data.updated_at = addedAt;
791
+ this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), record.data, record.body);
792
+ generateProjections(this.storage);
793
+ return this.result({ workspace, stage, dependency, depends_on: nextDependencies, blocked: !isDependencySatisfied(source) }, [workspace, stage]);
794
+ });
795
+ }
796
+
797
+ removeStageDependency(workspace, stage, dependency) {
798
+ workspace = normalizeWorkspaceId(workspace);
799
+ stage = normalizeStageId(stage);
800
+ dependency = normalizeStageId(dependency);
801
+ return this.transact(`workspace-${workspace}`, () => {
802
+ const stages = this.listStages(workspace).data.stages;
803
+ const dependent = stages.find((item) => item.stage === stage);
804
+ if (!dependent) fail(ERROR_CODES.NOT_FOUND, "Dependent stage not found");
805
+ assertDependencyMutationStage(dependent, "Dependent");
806
+ if (!dependent.depends_on.includes(dependency)) fail(ERROR_CODES.DEPENDENCY_EDGE_NOT_FOUND, "Stage dependency does not exist", { stage, dependency });
807
+ const nextDependencies = dependent.depends_on.filter((item) => item !== dependency);
808
+ const record = this.storage.readStage(workspace, stage);
809
+ const removedAt = new Date().toISOString();
810
+ const epochs = dependencyEpochs(record.data, removedAt);
811
+ record.data.depends_on = nextDependencies;
812
+ record.data.dependency_epochs = { ...epochs, [dependency]: { ...epochs[dependency], removed_at: removedAt } };
813
+ record.data.updated_at = removedAt;
814
+ this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), record.data, record.body);
815
+ generateProjections(this.storage);
816
+ return this.result({ workspace, stage, dependency, depends_on: nextDependencies, historical_handoffs_retained: true }, [workspace, stage]);
817
+ });
818
+ }
819
+
820
+ handoffEvidence(workspace, input = {}) {
821
+ const candidateIds = input.candidateIds || [];
822
+ const commits = input.commits || [];
823
+ if (!Array.isArray(candidateIds) || candidateIds.length > 20 || candidateIds.some((item) => typeof item !== "string" || !/^CC-\d{6}$/.test(item)) || new Set(candidateIds).size !== candidateIds.length) fail(ERROR_CODES.INVALID_ARGUMENT, "candidateIds must contain unique candidate IDs");
824
+ if (!Array.isArray(commits) || commits.length > 20 || commits.some((item) => typeof item !== "string" || !/^[0-9a-f]{40,64}$/.test(item)) || new Set(commits).size !== commits.length) fail(ERROR_CODES.INVALID_ARGUMENT, "commits must contain unique full lowercase commit hashes");
825
+ const committed = this.candidates().projectionRecords(workspace).filter((candidate) => candidateIds.includes(candidate.candidate));
826
+ if (committed.length !== candidateIds.length || committed.some((candidate) => candidate.status !== "committed")) fail(ERROR_CODES.INVALID_STATE, "Handoff candidate evidence must reference committed candidates");
827
+ if (commits.length || committed.length) {
828
+ const repository = repositoryState(this.storage.projectRoot);
829
+ const evidenceCommits = [...commits, ...committed.map((candidate) => candidate.commit_hash)];
830
+ if (evidenceCommits.some((commit) => !isCommitAncestor(repository.root, commit, repository.head))) fail(ERROR_CODES.INVALID_STATE, "Handoff evidence must reference committed ancestors of HEAD");
831
+ }
832
+ return { candidates: committed.map((candidate) => ({ candidate: candidate.candidate, commit_hash: candidate.commit_hash })), commits };
833
+ }
834
+
835
+ publishDependencyHandoff(workspace, stage, sessionId, input = {}) {
836
+ workspace = normalizeWorkspaceId(workspace);
837
+ stage = normalizeStageId(stage);
838
+ if (!input.outcome?.trim() || input.outcome.trim().length > 4000) fail(ERROR_CODES.INVALID_ARGUMENT, "outcome must be a bounded non-empty string");
839
+ return this.transact(`workspace-${workspace}`, () => {
840
+ const stages = this.listStages(workspace).data.stages;
841
+ const source = stages.find((item) => item.stage === stage);
842
+ if (!source) fail(ERROR_CODES.NOT_FOUND, "Source stage not found");
843
+ assertDependencyMutationStage(source, "Source");
844
+ assertActive(this.storage.readEvents(), workspace, stage, sessionId);
845
+ const targets = directDependents(stages, stage);
846
+ if (!targets.length) fail(ERROR_CODES.DEPENDENCY_TARGET_REQUIRED, "The source stage has no formal direct dependents");
847
+ const record = this.handoffs().append(workspace, { type: "handoff", kind: "intermediate", sourceStage: stage, targetStages: targets, targetGenerations: targetGenerations(stages, stage, targets), outcome: input.outcome, evidence: this.handoffEvidence(workspace, input), verification: boundedList(input.verification, "verification"), blockers: boundedList(input.blockers, "blockers"), actor: actor(this.options), sourceSessionId: sessionId });
848
+ generateProjections(this.storage);
849
+ return this.result({ workspace, stage, handoff: record }, [workspace, this.storage.dependencyHandoffsFile(workspace)]);
850
+ });
851
+ }
852
+
853
+ readDependencyContext(workspace, stage) {
854
+ workspace = normalizeWorkspaceId(workspace);
855
+ stage = normalizeStageId(stage);
856
+ const stages = this.listStages(workspace).data.stages;
857
+ return { ok: true, data: { workspace, stage, ...this.handoffs().context(workspace, stage, stages) } };
858
+ }
859
+
686
860
  setStageProfiles(workspace, stage, profiles = {}) {
687
861
  workspace = normalizeWorkspaceId(workspace);
688
862
  stage = normalizeStageId(stage);
@@ -973,14 +1147,18 @@ export class WorkContext {
973
1147
  const record = this.storage.readStage(workspace, stage);
974
1148
  if (record.data.status === "archived") return this.result({ workspace, stage, status: "archived" }, []);
975
1149
  if (activeSession(this.storage.readEvents(), workspace, stage)) fail(ERROR_CODES.ACTIVE_SESSION_EXISTS, "Cannot archive a stage with an active session");
1150
+ const stages = this.listStages(workspace).data.stages;
1151
+ const wasSatisfied = isDependencySatisfied(record.data);
1152
+ const targets = directDependents(stages, stage);
976
1153
  const archivedAt = new Date().toISOString();
977
1154
  const entry = { action: "archived", at: archivedAt, actor: actor(this.options), previous_status: record.data.status };
978
1155
  record.data.status = "archived";
979
1156
  record.data.archive_history = [...(record.data.archive_history || []), entry];
980
1157
  record.data.updated_at = archivedAt;
981
1158
  this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), record.data, appendHistory(record.body, "Archive History", `${archivedAt}: archived from ${entry.previous_status}`));
1159
+ const dependencyStatus = !wasSatisfied && targets.length ? this.handoffs().append(workspace, { type: "status", sourceStage: stage, targetStages: targets, targetGenerations: targetGenerations(stages, stage, targets), satisfied: true, reason: "archived", createdAt: archivedAt, actor: actor(this.options) }) : null;
982
1160
  generateProjections(this.storage);
983
- return this.result({ workspace, stage, status: "archived" }, [workspace, stage]);
1161
+ return this.result({ workspace, stage, status: "archived", ...(dependencyStatus ? { dependency_status: dependencyStatus } : {}) }, [workspace, stage, ...(dependencyStatus ? [this.storage.dependencyHandoffsFile(workspace)] : [])]);
984
1162
  });
985
1163
  }
986
1164
 
@@ -1003,13 +1181,16 @@ export class WorkContext {
1003
1181
  record.data.archive_history = [...(record.data.archive_history || []), entry];
1004
1182
  record.data.updated_at = restoredAt;
1005
1183
  this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), record.data, appendHistory(record.body, "Archive History", `${restoredAt}: restored to ${restoredStatus}; ${reason.trim()}`));
1184
+ const stages = this.listStages(workspace).data.stages;
1185
+ const targets = directDependents(stages, stage);
1186
+ const dependencyStatus = !isDependencySatisfied(record.data) && targets.length ? this.handoffs().append(workspace, { type: "status", sourceStage: stage, targetStages: targets, targetGenerations: targetGenerations(stages, stage, targets), satisfied: false, reason: "restored", createdAt: restoredAt, actor: actor(this.options) }) : null;
1006
1187
  if (workspaceRecord.data.status === "completed" && ["planned", "in_progress"].includes(restoredStatus)) {
1007
1188
  workspaceRecord.data.status = "in_progress";
1008
1189
  workspaceRecord.data.updated_at = restoredAt;
1009
1190
  this.storage.writeMarkdown(this.storage.workspaceFile(workspace), workspaceRecord.data, workspaceRecord.body);
1010
1191
  }
1011
1192
  generateProjections(this.storage);
1012
- return this.result({ workspace, stage, status: restoredStatus, restore: entry, session_started: false, resume_required: ["planned", "in_progress"].includes(restoredStatus) }, [workspace, stage]);
1193
+ return this.result({ workspace, stage, status: restoredStatus, restore: entry, session_started: false, resume_required: ["planned", "in_progress"].includes(restoredStatus), ...(dependencyStatus ? { dependency_status: dependencyStatus } : {}) }, [workspace, stage, ...(dependencyStatus ? [this.storage.dependencyHandoffsFile(workspace)] : [])]);
1013
1194
  });
1014
1195
  }
1015
1196
 
@@ -1159,6 +1340,8 @@ export class WorkContext {
1159
1340
  if (record.data.status !== "completed") fail(ERROR_CODES.INVALID_STATE, "Only completed stages can be reopened", { status: record.data.status });
1160
1341
  const reopenedAt = new Date().toISOString();
1161
1342
  const previousResult = stageResult(record);
1343
+ const stages = this.listStages(workspace).data.stages;
1344
+ const targets = directDependents(stages, stage);
1162
1345
  const entry = { at: reopenedAt, reason: reason.trim(), actor: actor(this.options), ...(previousResult ? { previous_result: previousResult } : {}) };
1163
1346
  record.data.status = "in_progress";
1164
1347
  record.data.reopen_history = [...(record.data.reopen_history || []), entry];
@@ -1168,13 +1351,14 @@ export class WorkContext {
1168
1351
  const priorResult = previousResult ? `\n Previous result: ${previousResult}` : "";
1169
1352
  const archiveHistory = record.body.match(/\n## Archive History[\s\S]*?(?=\n## (?:Result|Reopen History)|$)/)?.[0] || "";
1170
1353
  this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), record.data, `${body(record.data.title, record.data.goal, record.data.prompt).trimEnd()}${history}\n- ${reopenedAt}: ${reason.trim()}${priorResult}\n${archiveHistory}`);
1354
+ const dependencyStatus = targets.length ? this.handoffs().append(workspace, { type: "status", sourceStage: stage, targetStages: targets, targetGenerations: targetGenerations(stages, stage, targets), satisfied: false, reason: "reopened", createdAt: reopenedAt, actor: actor(this.options) }) : null;
1171
1355
  if (workspaceRecord.data.status === "completed") {
1172
1356
  workspaceRecord.data.status = "in_progress";
1173
1357
  workspaceRecord.data.updated_at = reopenedAt;
1174
1358
  this.storage.writeMarkdown(this.storage.workspaceFile(workspace), workspaceRecord.data, workspaceRecord.body);
1175
1359
  }
1176
1360
  generateProjections(this.storage);
1177
- return this.result({ workspace, stage, status: "in_progress", reopen: entry, session_started: false, resume_required: true }, [workspace, stage]);
1361
+ return this.result({ workspace, stage, status: "in_progress", reopen: entry, session_started: false, resume_required: true, ...(dependencyStatus ? { dependency_status: dependencyStatus } : {}) }, [workspace, stage, ...(dependencyStatus ? [this.storage.dependencyHandoffsFile(workspace)] : [])]);
1178
1362
  });
1179
1363
  }
1180
1364
 
@@ -1202,15 +1386,24 @@ export class WorkContext {
1202
1386
  ] : [];
1203
1387
  const active = activeSession(events, workspace, stage);
1204
1388
  if (!active || active.session_id !== sessionId) fail(active ? ERROR_CODES.ACTIVE_SESSION_EXISTS : ERROR_CODES.SESSION_NOT_ACTIVE, active ? "Another active session owns this stage" : "Session is not active");
1389
+ const stages = this.listStages(workspace).data.stages;
1390
+ const targets = directDependents(stages, stage);
1391
+ const result = options.result?.trim() || "Stage completed.";
1392
+ const handoffOutcome = options.handoffOutcome?.trim() || result;
1393
+ if (targets.length && (!handoffOutcome || handoffOutcome.length > 4000)) fail(ERROR_CODES.INVALID_ARGUMENT, "handoffOutcome must be a bounded non-empty summary when the final result exceeds the handoff limit");
1394
+ const evidence = this.handoffEvidence(workspace, options);
1395
+ const verification = boundedList(options.verification, "verification");
1396
+ const blockers = boundedList(options.blockers, "blockers");
1205
1397
  this.writeEvents([event("session.closed", workspace, stage, active.ordinal, sessionId, actor(this.options), { reason: "stage_completed" })]);
1206
1398
  current.data.status = "completed";
1207
1399
  current.data.updated_at = new Date().toISOString();
1208
- this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), current.data, `${current.body}\n\n## Result\n\n${options.result || "Stage completed."}`);
1400
+ this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), current.data, `${current.body}\n\n## Result\n\n${result}`);
1401
+ const finalHandoff = targets.length ? this.handoffs().append(workspace, { type: "handoff", kind: "final", sourceStage: stage, targetStages: targets, targetGenerations: targetGenerations(stages, stage, targets), outcome: handoffOutcome, evidence, verification, blockers, createdAt: current.data.updated_at, actor: actor(this.options), sourceSessionId: sessionId }) : null;
1209
1402
  generateProjections(this.storage);
1210
1403
  const promptReview = this.listStages(workspace).data.stages
1211
1404
  .filter((item) => Number(item.stage) > Number(stage) && !["completed", "archived"].includes(item.status))
1212
1405
  .map(({ stage: id, title, description, prompt, status }) => ({ stage: id, title, description, prompt: prompt || null, status }));
1213
- const data = { session_id: sessionId, workspace, stage, state: "closed", status: "completed", next_stage_started: false, knowledge_review: knowledgeReview, knowledge_entries: knowledgeEntries.length, active_knowledge_entries: activeKnowledge(knowledgeEntries).length, prompt_review: promptReview, ...(executionData ? { execution_state: executionData, execution_warnings: executionWarnings } : {}) };
1406
+ const data = { session_id: sessionId, workspace, stage, state: "closed", status: "completed", next_stage_started: false, knowledge_review: knowledgeReview, knowledge_entries: knowledgeEntries.length, active_knowledge_entries: activeKnowledge(knowledgeEntries).length, prompt_review: promptReview, ...(finalHandoff ? { final_handoff: finalHandoff } : {}), ...(executionData ? { execution_state: executionData, execution_warnings: executionWarnings } : {}) };
1214
1407
  const incompleteStages = this.listStages(workspace).data.stages.filter((item) => !["completed", "archived"].includes(item.status));
1215
1408
  const next = incompleteStages.length ? null : {
1216
1409
  action: "workspace_finish",
@@ -1218,16 +1411,12 @@ export class WorkContext {
1218
1411
  command: `/wc workspace finish ${workspace}`,
1219
1412
  reason: "All workspace stages are completed",
1220
1413
  };
1221
- return this.result(data, [workspace, stage], next);
1414
+ return this.result(data, [workspace, stage, ...(finalHandoff ? [this.storage.dependencyHandoffsFile(workspace)] : [])], next);
1222
1415
  });
1223
1416
  }
1224
1417
 
1225
1418
  help(command = "") {
1226
- return this.result({
1227
- command,
1228
- 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 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]",
1229
- 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. 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.",
1230
- }, []);
1419
+ return this.result(commandHelp(command), []);
1231
1420
  }
1232
1421
 
1233
1422
  result(data, changed, next = null) {