opencode-work-context 0.6.1 → 0.7.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
@@ -326,13 +326,16 @@ disable this TUI loader; the package does not use an internal keymap fallback.
326
326
  The optional TUI loader tracks linked OpenCode sessions that need attention.
327
327
  Questions, permission requests, errors, and a background session becoming idle
328
328
  after observed work remain marked until that native session is opened. Compact
329
- markers retain both a symbol and a textual reason: `[✓ response complete]`,
330
- `[? question]`, `[! permission]`, or `[x error]`. Aggregated markers append an
331
- `xN` session count. Attention does not change workspace or stage lifecycle state.
329
+ markers retain both a symbol and a textual reason in modals and switchers:
330
+ `[✓ response complete]`, `[? question]`, `[! permission]`, or `[x error]`.
331
+ The compact stages sidebar uses a dedicated signal column with `✓`, `?`, `!`,
332
+ or `×` and appends a numeric count when needed. Its workspace header groups
333
+ mixed unread reasons by priority, for example `Attention · ×1 !2 ?1 ✓3`.
334
+ Attention does not change workspace or stage lifecycle state.
332
335
 
333
336
  The stages sidebar separately observes live `busy` and `retry` events for active
334
- OpenCode sessions mapped to visible work-context stages. A braille loader appears
335
- beside the lifecycle marker while any such session is working and stops on idle,
337
+ OpenCode sessions mapped to visible work-context stages. A braille loader uses
338
+ the signal column before the lifecycle marker while any such session is working and stops on idle,
336
339
  question, permission, or error events. This live state is never persisted or
337
340
  inferred from stage status, historical sessions, or unread attention, so startup
338
341
  and missed mappings fail closed without a stale loader.
@@ -438,15 +441,18 @@ workspace, every resume also supplies the agent with the startup policy:
438
441
  - a shared dirty worktree and concurrent stages are expected;
439
442
  - stages do not own files or commits;
440
443
  - ready work is captured promptly as an explicit commit candidate;
441
- - mixed-stage provenance alone is not a reason to stop;
442
- - a concrete overlapping or stale candidate patch is a reason to stop and report
443
- the conflict.
444
+ - exact, shared-foundation, and integration candidates express the intended
445
+ commit boundary without claiming stage ownership;
446
+ - mixed-stage provenance and complete files containing unrelated stage work are
447
+ not reasons to require prior commits or stop;
448
+ - only a concrete patch conflict, an incoherent candidate boundary, or failed
449
+ required verification stops candidate publication.
444
450
 
445
451
  Startup-mode workspaces can snapshot an explicit ready subset as a local commit
446
452
  candidate without creating a commit or modifying the ordinary Git index:
447
453
 
448
454
  ```text
449
- /wc candidate create 000123 "Ship parser fix" "Fix parser edge cases"
455
+ /wc candidate create 000123 "Ship parser fix" "Fix parser edge cases" strategy exact stages 02
450
456
  /wc candidate capture 000123 CC-000001 paths src/parser.js test/parser.test.js
451
457
  /wc candidate preview 000123 CC-000001
452
458
  /wc candidate ready 000123 CC-000001
@@ -460,6 +466,23 @@ A typical shared-tree sequence can keep unrelated work moving:
460
466
  3. Preview and mark candidate A ready, then commit it explicitly.
461
467
  4. The new commit contains `a.txt`; `b.txt` remains unchanged as working-tree WIP.
462
468
 
469
+ Choose the candidate strategy by the coherent repository change being published,
470
+ not by which stage touched each file:
471
+
472
+ - `exact` is the default and is preferred when the intended patch can be safely
473
+ separated from other WIP;
474
+ - `shared_foundation` captures one coherent prerequisite used by several stages;
475
+ - `integration` captures already-intertwined work from several stages when it
476
+ forms one reviewable and testable result and cannot be split safely.
477
+
478
+ Candidate creation may include several related stage IDs. They are normalized
479
+ and validated within the candidate workspace, then returned by create, list,
480
+ show, preview, ready, and commit operations. These references provide
481
+ traceability only: they do not assign files or hunks, change stage lifecycle or
482
+ dependencies, or infer relations from Git or session history. Existing candidate
483
+ records without strategy or stage-reference metadata remain readable; new
484
+ candidates default to `exact` with no related stages.
485
+
463
486
  The sidebar reads only candidate metadata and shows a compact
464
487
  `Candidates · pending <count> · ready <count>` line when either count is nonzero.
465
488
  It does not inspect Git state, patches, paths, or candidate freshness. A `ready`
@@ -483,6 +506,11 @@ metadata, the worktree, the ordinary index, and the branch ref unchanged by the
483
506
  operation. Commit publication uses `git commit-tree`, so it deliberately bypasses
484
507
  Git hooks and signing rather than invoking interactive policy.
485
508
 
509
+ If multiple stages have edited the same lines, Work Context cannot retrospectively
510
+ separate those edits by provenance. Use an integration candidate only when the
511
+ combined patch is coherent and verified; otherwise stop and establish a safe
512
+ candidate boundary before publication.
513
+
486
514
  Candidate publication is serialized by the repository-scoped `candidate-git`
487
515
  lock. Any operation that needs both locks acquires `candidate-git` before the
488
516
  work-context `write` lock; integrations must preserve this ordering to avoid
package/commands/wc.md CHANGED
@@ -29,7 +29,7 @@ Use these exact tool mappings; do not invent shortened tool names:
29
29
  - `workspace list <workspace>` or `<workspace> list` -> `work_context_workspace_list`
30
30
  - `workspace rename <workspace> "title"` -> `work_context_rename_workspace`
31
31
  - `workspace mode <workspace> <standard|startup>` -> `work_context_set_workspace_mode`
32
- - `candidate create <workspace> "title" ["message"]` -> `work_context_create_candidate`
32
+ - `candidate create <workspace> "title" ["message"] [strategy <exact|shared_foundation|integration>] [stages <stage>...]` -> `work_context_create_candidate`
33
33
  - `candidate capture <workspace> <candidateId> paths <path>...` or `candidate capture <workspace> <candidateId> patch "patch"` -> `work_context_capture_candidate`
34
34
  - `candidate preview <workspace> <candidateId>` -> `work_context_preview_candidate`
35
35
  - `candidate show <workspace> <candidateId>` -> `work_context_show_candidate`
@@ -62,7 +62,7 @@ Supported syntax:
62
62
  - `workspace list <workspace>`
63
63
  - `workspace rename <workspace> "title"`
64
64
  - `workspace mode <workspace> <standard|startup>`
65
- - `candidate create <workspace> "title" ["message"]`
65
+ - `candidate create <workspace> "title" ["message"] [strategy <exact|shared_foundation|integration>] [stages <stage>...]`
66
66
  - `candidate capture <workspace> <candidateId> paths <path>...`
67
67
  - `candidate capture <workspace> <candidateId> patch "patch"`
68
68
  - `candidate preview <workspace> <candidateId>`
@@ -100,7 +100,7 @@ Supported syntax:
100
100
  - 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
101
101
  - do not expose raw workspace/stage/session identifiers, ordinals, `ok` flags, or absent error codes in the user-facing resume summary
102
102
  - `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
103
- - an associated OpenCode session resumed in a `startup` workspace receives `resume.context.workflow_policy`; follow it as active agent policy: a shared dirty worktree and concurrent stages are expected, stages do not own files or commits, ready work should be captured promptly into an explicit candidate, mixed-stage provenance alone is not a reason to stop, and an actual overlapping or stale candidate conflict must stop with a concrete report
103
+ - an associated OpenCode session resumed in a `startup` workspace receives `resume.context.workflow_policy`; follow it as active agent policy: 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; 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
104
104
  - standard-mode and unassociated core sessions do not receive startup policy; retain the existing conservative worktree behavior there
105
105
  - after presenting the summary, continue work immediately when `resume.next_action` is `start_work`; do not ask for generic confirmation
106
106
  - 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
@@ -117,7 +117,7 @@ Supported syntax:
117
117
  - `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
118
118
  - `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`.
119
119
  - `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.
120
- - candidate operations require `startup` workflow mode and store metadata and patch payloads only under `.work-context/local/`; 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
120
+ - 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; 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
121
121
  - `knowledge list|add|update|supersede <workspace> ...`
122
122
 
123
123
  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.6.1",
4
+ "version": "0.7.0",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -16,6 +16,7 @@ const activeControllers = new WeakMap();
16
16
  const PRIORITY = { idle: 1, question: 2, permission: 3, error: 4 };
17
17
  const REASON_TEXT = { idle: "response complete", question: "question", permission: "permission", error: "error" };
18
18
  const REASON_MARKER = { idle: "✓", question: "?", permission: "!", error: "x" };
19
+ const REASON_SIGNAL = { idle: "✓", question: "?", permission: "!", error: "×" };
19
20
  const EVENT_TYPES = [
20
21
  "session.status",
21
22
  "session.idle",
@@ -75,6 +76,21 @@ export const attentionReasonText = (reason) => REASON_TEXT[reason] || "attention
75
76
  export const attentionIndicatorText = (attention) => attention
76
77
  ? `[${REASON_MARKER[attention.reason] || "!"} ${attentionReasonText(attention.reason)}${attention.count > 1 ? ` x${attention.count}` : ""}]`
77
78
  : "";
79
+ export const attentionSignalText = (attention, { alwaysCount = false } = {}) => attention
80
+ ? `${REASON_SIGNAL[attention.reason] || "!"}${alwaysCount || attention.count > 1 ? attention.count : ""}`
81
+ : "";
82
+ export const attentionSummaryText = (attention, options = {}) => {
83
+ if (!attention) return "";
84
+ if (!attention.items?.length) return attentionSignalText(attention, options);
85
+ const counts = attention.items.reduce((summary, item) => {
86
+ summary[item.reason] = (summary[item.reason] || 0) + 1;
87
+ return summary;
88
+ }, {});
89
+ return ["error", "permission", "question", "idle"]
90
+ .filter((reason) => counts[reason])
91
+ .map((reason) => attentionSignalText({ reason, count: counts[reason] }, options))
92
+ .join(" ");
93
+ };
78
94
  export const globalAttentionToast = (event) => {
79
95
  const context = [event?.projectTitle, event?.workspaceTitle, event?.stageTitle].filter(Boolean).join(" / ");
80
96
  return {
@@ -5,7 +5,7 @@ import { contextFor, titleFor } from "../src/opencode-adapter.js";
5
5
  import { renderDependencyTree, renderStagesPanel } from "../src/stages-renderer.js";
6
6
  import { jsx } from "@opentui/solid/jsx-runtime";
7
7
  import { createSignal } from "solid-js";
8
- import { attentionIndicatorText } from "./attention.js";
8
+ import { attentionSummaryText } from "./attention.js";
9
9
  import { createStageSwitcherFlow } from "./stage-switcher.js";
10
10
  import { readTuiState, updateTuiState } from "./tui-state.js";
11
11
 
@@ -42,28 +42,22 @@ const candidateSummaryText = (workspace) => workspace.candidates && (workspace.c
42
42
  export { readStagesSnapshot, renderStagesPanel };
43
43
 
44
44
  const defaultRuntime = { jsx };
45
- const renderAttentionText = (value, indicator, runtime) => {
46
- if (!indicator) return value;
47
- const parts = value.split(indicator);
48
- return parts.length === 1 ? value : parts.flatMap((part, index) => index
49
- ? [runtime.jsx("b", { children: indicator }), part]
50
- : [part]).filter(Boolean);
51
- };
52
-
53
- const renderStagesContent = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame = () => LOADER_FRAMES[0]) => !result?.ok || !result.data?.workspace
54
- ? [
45
+ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame = () => LOADER_FRAMES[0]) => {
46
+ if (!result?.ok || !result.data?.workspace) return [
55
47
  runtime.jsx("text", { children: runtime.jsx("b", { children: "Stages" }) }),
56
48
  ...renderStagesPanel(result).split("\n").slice(1).map((line) => runtime.jsx("text", { children: line })),
57
- ]
58
- : [
49
+ ];
50
+ const workspaceAttention = attentionSummaryText(attention?.attentionForWorkspace?.(result.data.workspace.id), { alwaysCount: true });
51
+ return [
59
52
  runtime.jsx("box", {
60
53
  marginBottom: 1,
61
54
  flexDirection: "column",
62
55
  children: [
63
- runtime.jsx("text", { wrapMode: "word", children: runtime.jsx("b", { children: `${attentionIndicatorText(attention?.attentionForWorkspace?.(result.data.workspace.id))} ${result.data.workspace.title}`.trim() }) }),
56
+ runtime.jsx("text", { wrapMode: "word", children: runtime.jsx("b", { children: result.data.workspace.title }) }),
64
57
  runtime.jsx("text", { fg: theme?.current?.textMuted, children: `Workflow · ${result.data.workspace.mode || "standard"}` }),
58
+ workspaceAttention && runtime.jsx("text", { children: ["Attention · ", runtime.jsx("b", { children: workspaceAttention })] }),
65
59
  candidateSummaryText(result.data.workspace) && runtime.jsx("text", { fg: theme?.current?.textMuted, children: candidateSummaryText(result.data.workspace) }),
66
- ],
60
+ ].filter(Boolean),
67
61
  }),
68
62
  runtime.jsx("box", {
69
63
  flexDirection: "row",
@@ -79,11 +73,10 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
79
73
  stage.tracker_links?.length && `Tasks: ${stage.tracker_links.map(trackerLinkText).join(", ")}`,
80
74
  stage.depends_on?.length && `Deps: ${stage.depends_on.join(", ")}`,
81
75
  ].filter(Boolean).join(" · ") : "";
82
- const attentionText = attentionIndicatorText(unread);
76
+ const attentionSignal = attentionSummaryText(unread);
83
77
  const stageText = [
84
78
  `${stage.id}. ${stage.title}`,
85
79
  metadata,
86
- attentionText,
87
80
  ].filter(Boolean).join("\n");
88
81
  return runtime.jsx("box", {
89
82
  flexDirection: "row",
@@ -92,13 +85,19 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
92
85
  return onStageSelect?.(stage);
93
86
  },
94
87
  children: [
95
- working && runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: theme?.current?.warning, children: activityFrame() }),
88
+ runtime.jsx("text", {
89
+ flexShrink: 0,
90
+ marginRight: 1,
91
+ fg: working || stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted,
92
+ children: working ? activityFrame() : attentionSignal ? runtime.jsx("b", { children: attentionSignal }) : " ",
93
+ }),
96
94
  runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: statusMarker(stage.status) }),
97
- runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: renderAttentionText(stageText, attentionText, runtime) }),
98
- ].filter(Boolean),
95
+ runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: stageText }),
96
+ ],
99
97
  });
100
98
  }),
101
99
  ];
100
+ };
102
101
 
103
102
  export const renderStagesElement = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame) => {
104
103
  return runtime.jsx("box", {
package/src/candidates.js CHANGED
@@ -2,18 +2,20 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { atomicWrite } from "./storage.js";
4
4
  import { ERROR_CODES, fail } from "./errors.js";
5
- import { normalizeWorkspaceId } from "./identifiers.js";
5
+ import { normalizeStageId, normalizeWorkspaceId } from "./identifiers.js";
6
6
  import { capturePatch, capturePaths, commitPatch, previewPatch, repositoryState } from "./git-candidates.js";
7
7
 
8
8
  const candidatePattern = /^CC-(\d{6})$/;
9
9
  const statuses = new Set(["draft", "ready", "discarded", "committed"]);
10
+ const strategies = new Set(["exact", "shared_foundation", "integration"]);
10
11
  const timestamp = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) && new Date(value).toISOString() === value;
11
12
  const metadataKeys = ["schema", "candidate", "workspace", "title", "message", "base_head", "status", "created_at", "updated_at", "selected_paths", "patch_file"];
13
+ const optionalMetadataKeys = ["strategy", "related_stages"];
12
14
 
13
15
  function validateCandidate(data, expectedId = null) {
14
16
  const valid = data && typeof data === "object" && !Array.isArray(data)
15
17
  && metadataKeys.every((key) => Object.hasOwn(data, key))
16
- && Object.keys(data).every((key) => metadataKeys.includes(key) || ["commit_hash", "committed_at"].includes(key))
18
+ && Object.keys(data).every((key) => metadataKeys.includes(key) || optionalMetadataKeys.includes(key) || ["commit_hash", "committed_at"].includes(key))
17
19
  && data.schema === 1 && candidatePattern.test(data.candidate) && (!expectedId || data.candidate === expectedId)
18
20
  && /^\d{6}$/.test(data.workspace) && typeof data.title === "string" && data.title.trim()
19
21
  && typeof data.message === "string" && data.message.trim() && /^[0-9a-f]{40,64}$/.test(data.base_head)
@@ -22,6 +24,10 @@ function validateCandidate(data, expectedId = null) {
22
24
  && Array.isArray(data.selected_paths) && data.selected_paths.every((item) => typeof item === "string" && item && !path.isAbsolute(item) && !item.split("/").includes(".."))
23
25
  && new Set(data.selected_paths).size === data.selected_paths.length
24
26
  && data.patch_file === `${data.candidate}.patch`
27
+ && (Object.hasOwn(data, "strategy") === Object.hasOwn(data, "related_stages"))
28
+ && (!Object.hasOwn(data, "strategy") || (strategies.has(data.strategy)
29
+ && Array.isArray(data.related_stages) && data.related_stages.every((stage) => /^\d{2}$/.test(stage) && stage !== "00")
30
+ && new Set(data.related_stages).size === data.related_stages.length))
25
31
  && (data.status === "committed"
26
32
  ? /^[0-9a-f]{40,64}$/.test(data.commit_hash) && timestamp(data.committed_at)
27
33
  : !Object.hasOwn(data, "commit_hash") && !Object.hasOwn(data, "committed_at"));
@@ -74,13 +80,19 @@ export class CandidateStore {
74
80
  if (patch !== null) atomicWrite(this.patchFile(data.candidate), patch);
75
81
  }
76
82
 
77
- create(workspace, title, message = null) {
83
+ create(workspace, title, message = null, options = {}) {
78
84
  workspace = this.assertStartup(workspace);
79
85
  if (!title?.trim()) fail(ERROR_CODES.INVALID_ARGUMENT, "Candidate title is required");
86
+ const strategy = options.strategy ?? "exact";
87
+ if (!strategies.has(strategy)) fail(ERROR_CODES.INVALID_ARGUMENT, "Candidate strategy must be 'exact', 'shared_foundation' or 'integration'");
88
+ if (options.relatedStages !== undefined && !Array.isArray(options.relatedStages)) fail(ERROR_CODES.INVALID_ARGUMENT, "Related stages must be an array");
89
+ const relatedStages = (options.relatedStages || []).map(normalizeStageId);
90
+ if (new Set(relatedStages).size !== relatedStages.length) fail(ERROR_CODES.INVALID_ARGUMENT, "Related stages must be unique");
91
+ for (const stage of relatedStages) this.context.storage.readStage(workspace, stage);
80
92
  const repository = repositoryState(this.context.storage.projectRoot);
81
93
  const id = this.nextId();
82
94
  const now = new Date().toISOString();
83
- const data = { schema: 1, candidate: id, workspace, title: title.trim(), message: message?.trim() || title.trim(), base_head: repository.head, status: "draft", created_at: now, updated_at: now, selected_paths: [], patch_file: `${id}.patch` };
95
+ const data = { schema: 1, candidate: id, workspace, title: title.trim(), message: message?.trim() || title.trim(), strategy, related_stages: relatedStages, base_head: repository.head, status: "draft", created_at: now, updated_at: now, selected_paths: [], patch_file: `${id}.patch` };
84
96
  this.write(data, "");
85
97
  return data;
86
98
  }
package/src/core.js CHANGED
@@ -34,8 +34,9 @@ const startupWorkflowPolicy = () => ({
34
34
  guidance: [
35
35
  "A shared dirty worktree and concurrent stages are expected; stages do not own files or commits.",
36
36
  "Capture ready work promptly as an explicit commit candidate while unrelated work remains in progress.",
37
- "Mixed-stage provenance alone is not a reason to stop; do not reconstruct ownership after the fact.",
38
- "Stop only for a concrete overlapping or stale candidate conflict, and report that conflict explicitly.",
37
+ "Choose an exact candidate when separable, a shared foundation candidate when several stages use one change, or an integration candidate when intertwined changes form one coherent reviewable result.",
38
+ "Mixed-stage provenance or complete files containing unrelated stage work are not reasons to stop, require prior commits, or reconstruct ownership after the fact.",
39
+ "Stop only for a concrete patch conflict, an incoherent candidate boundary, or failed required verification, and report it explicitly.",
39
40
  ],
40
41
  });
41
42
  const startupWorkflowInstruction = (policy) => policy ? `\n\nStartup workflow policy:\n${policy.guidance.map((item) => `- ${item}`).join("\n")}` : "";
@@ -282,8 +283,8 @@ export class WorkContext {
282
283
 
283
284
  candidates() { return new CandidateStore(this); }
284
285
 
285
- createCandidate(workspace, title, message = null) {
286
- return this.transact("candidate-create", () => this.result(this.candidates().create(workspace, title, message), ["local:candidates"]));
286
+ createCandidate(workspace, title, message = null, options = {}) {
287
+ return this.transact("candidate-create", () => this.result(this.candidates().create(workspace, title, message, options), ["local:candidates"]));
287
288
  }
288
289
 
289
290
  listCandidates(workspace) { return { ok: true, data: this.candidates().list(workspace) }; }
@@ -743,7 +744,7 @@ export class WorkContext {
743
744
  return this.result({
744
745
  command,
745
746
  syntax: "/wc [create|list|workspace list|workspace rename|workspace mode|candidate create|candidate capture|candidate preview|candidate show|candidate list|candidate ready|candidate commit|candidate discard|workspace finish|workspace reopen|resume|stage add|stage reopen|stage restore|stage rename|stage update|stage update-prompt|stage update-result|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]",
746
- note: "associated OpenCode sessions in startup-mode workspaces receive the shared-worktree and commit-candidate policy on resume; standard mode remains conservative; commit candidates are local-only and require startup workflow mode; capture and commit use isolated Git indexes and never alter the ordinary index; candidate commit uses the stored message unless an explicit non-empty override is provided, and bypasses Git hooks and signing; stage finish requires an explicit user lifecycle request unless the Planning-stage prompt contains the exact line AUTO_STAGE_FINISH: allowed; stage reopen requires a completed stage and a reason; stage restore requires an archived stage and a reason, returns its saved pre-archive status (or in_progress for legacy archives), and requires explicit separate-session resume when actionable; workspace reopen requires a completed workspace and a reason.",
747
+ note: "associated OpenCode sessions in startup-mode workspaces receive the shared-worktree and commit-candidate policy on resume; standard mode remains conservative; candidate strategies are exact, shared_foundation, and integration, with optional related stage references for traceability only; commit candidates are local-only and require startup workflow mode; capture and commit use isolated Git indexes and never alter the ordinary index; candidate commit uses the stored message unless an explicit non-empty override is provided, and bypasses Git hooks and signing; stage finish requires an explicit user lifecycle request unless the Planning-stage prompt contains the exact line AUTO_STAGE_FINISH: allowed; stage reopen requires a completed stage and a reason; stage restore requires an archived stage and a reason, returns its saved pre-archive status (or in_progress for legacy archives), and requires explicit separate-session resume when actionable; workspace reopen requires a completed workspace and a reason.",
747
748
  }, []);
748
749
  }
749
750
 
@@ -57,7 +57,7 @@ export const work_context_list_workspaces = tool({ description: "List work-conte
57
57
  export const work_context_workspace_list = tool({ description: "List a workspace with stage descriptions and sessions.", args: { workspace: tool.schema.string() }, execute: run((ctx, a) => ctx.listStages(a.workspace)) });
58
58
  export const work_context_rename_workspace = tool({ description: "Rename a workspace.", args: { workspace: tool.schema.string(), title: tool.schema.string() }, execute: run((ctx, a) => ctx.renameWorkspace(a.workspace, a.title)) });
59
59
  export const work_context_set_workspace_mode = tool({ description: "Set a workspace workflow mode.", args: { workspace: tool.schema.string(), mode: tool.schema.enum(["standard", "startup"]) }, execute: run((ctx, a) => ctx.setWorkspaceMode(a.workspace, a.mode)) });
60
- export const work_context_create_candidate = tool({ description: "Create a local draft commit candidate for a startup-mode workspace.", args: { workspace: tool.schema.string(), title: tool.schema.string(), message: tool.schema.string().optional() }, execute: run((ctx, a) => ctx.createCandidate(a.workspace, a.title, a.message)) });
60
+ export const work_context_create_candidate = tool({ description: "Create an exact, shared-foundation, or integration draft candidate. Related stages are optional traceability and never ownership.", args: { workspace: tool.schema.string(), title: tool.schema.string(), message: tool.schema.string().optional(), strategy: tool.schema.enum(["exact", "shared_foundation", "integration"]).optional(), relatedStages: tool.schema.array(tool.schema.string()).optional() }, execute: run((ctx, a) => ctx.createCandidate(a.workspace, a.title, a.message, { strategy: a.strategy, relatedStages: a.relatedStages })) });
61
61
  export const work_context_capture_candidate = tool({ description: "Capture explicit complete paths or an exact unified patch into a draft commit candidate.", args: { workspace: tool.schema.string(), candidateId: tool.schema.string(), paths: tool.schema.array(tool.schema.string()).optional(), patch: tool.schema.string().optional() }, execute: run((ctx, a) => ctx.captureCandidate(a.workspace, a.candidateId, { paths: a.paths, patch: a.patch })) });
62
62
  export const work_context_preview_candidate = tool({ description: "Preview a candidate using an isolated temporary Git index.", args: { workspace: tool.schema.string(), candidateId: tool.schema.string() }, execute: run((ctx, a) => ctx.previewCandidate(a.workspace, a.candidateId)) });
63
63
  export const work_context_show_candidate = tool({ description: "Show local candidate metadata and its exact captured patch.", args: { workspace: tool.schema.string(), candidateId: tool.schema.string() }, execute: run((ctx, a) => ctx.showCandidate(a.workspace, a.candidateId)) });