opencode-work-context 0.11.0 → 0.11.2
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 +5 -3
- package/commands/wc.md +1 -0
- package/package.json +1 -1
- package/plugin/session-model.js +22 -0
- package/plugin/stages-tui.js +9 -11
- package/plugin/work-context-modal.js +5 -4
- package/src/capability-profiles.js +1 -1
- package/src/core.js +2 -1
- package/src/errors.js +1 -0
- package/src/stages-renderer.js +2 -2
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ Workspace: Add CSV export to analytics report
|
|
|
33
33
|
|
|
34
34
|
- **Workspace** is one concrete task, such as adding CSV export.
|
|
35
35
|
- **Stage** is one step in that task.
|
|
36
|
-
- **Planning** is normally the first stage.
|
|
36
|
+
- **Planning** is normally the first stage and remains a continuously available coordination surface. Working stages must never depend on it; add dependencies only between working stages with a genuine ordering requirement.
|
|
37
37
|
- **Resume** starts a new session at a selected stage.
|
|
38
38
|
- **Handoff** preserves the context when moving work to another session.
|
|
39
39
|
|
|
@@ -169,8 +169,10 @@ The resulting user-local mappings live only in the ignored
|
|
|
169
169
|
```
|
|
170
170
|
|
|
171
171
|
Expanded stage details render one compact line such as `implementation · deep ·
|
|
172
|
-
Sol
|
|
173
|
-
|
|
172
|
+
Sol`. Without a mapping, the TUI shows the actual model name for the current
|
|
173
|
+
OpenCode session; other stages show only capability and depth rather than an
|
|
174
|
+
ambiguous `current model` label. Optional `review_profile` metadata neither
|
|
175
|
+
resolves a model nor controls separately configured subagents.
|
|
174
176
|
Targets are bounded opaque labels and never enter tracked data. Invalid entries
|
|
175
177
|
produce bounded warnings. The plugin never changes an active model or agent,
|
|
176
178
|
invokes a reviewer, creates a replacement session, or blocks resume. `init`,
|
package/commands/wc.md
CHANGED
|
@@ -124,6 +124,7 @@ Supported syntax:
|
|
|
124
124
|
- explicit workspace and stage positions accept canonical padded IDs or unpadded positive integers (`1..999999` and `1..99`); results and generated commands remain padded
|
|
125
125
|
- zero, signs, decimals, whitespace, overlong values, and other non-digit identifier forms are invalid; a lone unpadded workspace ID is not reinterpreted under the one-identifier rule
|
|
126
126
|
- `stage update-result` replaces an existing result and does not create a result for an unfinished stage
|
|
127
|
+
- Planning stage 01 is a continuously available coordination surface, not a prerequisite gate; implementation, research, review, and other working stages must never depend on it
|
|
127
128
|
- execution recommendations have two independent portable fields: capability (`routine`, `implementation`, `architecture`, `security`, `review`) and depth (`light`, `standard`, `deep`)
|
|
128
129
|
- when stage creation does not explicitly name capability and depth, infer both from title, description, prompt, dependencies, active workspace knowledge, and current execution state; pass `classification: inferred`; explicit user values pass `classification: explicit`
|
|
129
130
|
- core and read-only UI never infer classifications; do not use keyword heuristics, mutate during resume, or invent values when the stage prompt is not actionable
|
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const modelRef = (session) => session?.model || (session?.modelID || session?.providerID ? session : null);
|
|
2
|
+
|
|
3
|
+
export const sessionModelLabel = (api, sessionId) => {
|
|
4
|
+
if (!sessionId) return null;
|
|
5
|
+
const session = api?.data?.session?.get?.(sessionId);
|
|
6
|
+
const ref = modelRef(session);
|
|
7
|
+
const modelID = ref?.id || ref?.modelID;
|
|
8
|
+
if (!modelID) return null;
|
|
9
|
+
const providerID = ref.providerID;
|
|
10
|
+
const models = api?.data?.location?.model?.list?.(session?.location) || [];
|
|
11
|
+
const model = models.find((item) => (!providerID || item.providerID === providerID)
|
|
12
|
+
&& (item.id === modelID || item.modelID === modelID));
|
|
13
|
+
return model?.name || [providerID, modelID].filter(Boolean).join("/");
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
|
|
17
|
+
|
|
18
|
+
export const capabilitySummaryText = (stage, sessionModel) => {
|
|
19
|
+
if (!stage?.execution_profile || !stage.execution_depth) return null;
|
|
20
|
+
const model = stage.recommended_model ? capitalize(stage.recommended_model) : sessionModel;
|
|
21
|
+
return [capitalize(stage.execution_profile), capitalize(stage.execution_depth), model].filter(Boolean).join(" · ");
|
|
22
|
+
};
|
package/plugin/stages-tui.js
CHANGED
|
@@ -9,6 +9,7 @@ import { attentionSummaryText } from "./attention.js";
|
|
|
9
9
|
import { createStageSwitcherFlow } from "./stage-switcher.js";
|
|
10
10
|
import { readTuiState, updateTuiState } from "./tui-state.js";
|
|
11
11
|
import { resolveProjectRoot, withProjectRoot } from "./project-root.js";
|
|
12
|
+
import { capabilitySummaryText, sessionModelLabel } from "./session-model.js";
|
|
12
13
|
|
|
13
14
|
const DEBOUNCE_MS = 150;
|
|
14
15
|
const POLL_MS = 1000;
|
|
@@ -56,7 +57,6 @@ export const checklistSummaryText = (execution) => {
|
|
|
56
57
|
if (execution.blockers?.length) parts.push(`! ${execution.blockers.length}`);
|
|
57
58
|
return parts.length ? `Todo · ${parts.join(" · ")}` : null;
|
|
58
59
|
};
|
|
59
|
-
const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
|
|
60
60
|
const visibleAttentionSnapshot = (attention, workspace, stages) => {
|
|
61
61
|
const byStage = new Map(stages.map((stage) => [stage.id, attention?.attentionForStage?.(workspace, stage.id) || null]));
|
|
62
62
|
const bySession = new Map();
|
|
@@ -70,7 +70,7 @@ const visibleAttentionSnapshot = (attention, workspace, stages) => {
|
|
|
70
70
|
export { readStagesSnapshot, renderStagesPanel };
|
|
71
71
|
|
|
72
72
|
const defaultRuntime = { jsx };
|
|
73
|
-
const renderStagesContent = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame = () => LOADER_FRAMES[0]) => {
|
|
73
|
+
const renderStagesContent = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame = () => LOADER_FRAMES[0], currentModel = () => null) => {
|
|
74
74
|
if (!result?.ok || !result.data?.workspace) return [
|
|
75
75
|
runtime.jsx("text", { children: runtime.jsx("b", { children: "Stages" }) }),
|
|
76
76
|
...renderStagesPanel(result).split("\n").slice(1).map((line) => runtime.jsx("text", { children: line })),
|
|
@@ -97,16 +97,14 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
|
|
|
97
97
|
...result.data.stages.flatMap((stage) => {
|
|
98
98
|
const unread = attentionSnapshot.byStage.get(stage.id);
|
|
99
99
|
const working = attention?.activityForStage?.(result.data.workspace.id, stage.id);
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
: null;
|
|
100
|
+
const current = stage.current || stage.id === result.data.currentStage;
|
|
101
|
+
const recommendation = capabilitySummaryText(stage, current ? currentModel() : null);
|
|
103
102
|
const stageMetadata = [
|
|
104
103
|
stage.tracker_links?.length && `Tasks: ${stage.tracker_links.map(trackerLinkText).join(", ")}`,
|
|
105
104
|
stage.depends_on?.length && `Deps: ${formatStageIds(stage.depends_on)}`,
|
|
106
105
|
].filter(Boolean).join(" · ");
|
|
107
106
|
const metadata = showDependencies ? [recommendation, stageMetadata, stageCandidateText(stage), stage.current && checklistSummaryText(stage.execution)].filter(Boolean).join("\n") : "";
|
|
108
107
|
const attentionSignal = attentionSummaryText(unread);
|
|
109
|
-
const current = stage.current || stage.id === result.data.currentStage;
|
|
110
108
|
const onMouseDown = (event) => {
|
|
111
109
|
if (event?.button != null && event.button !== 0) return;
|
|
112
110
|
return onStageSelect?.(stage);
|
|
@@ -138,10 +136,10 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
|
|
|
138
136
|
];
|
|
139
137
|
};
|
|
140
138
|
|
|
141
|
-
export const renderStagesElement = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame) => {
|
|
139
|
+
export const renderStagesElement = (result, theme, runtime = defaultRuntime, attention, showDependencies = true, onStageSelect, activityFrame, currentModel) => {
|
|
142
140
|
return runtime.jsx("box", {
|
|
143
141
|
flexDirection: "column",
|
|
144
|
-
children: () => renderStagesContent(typeof result === "function" ? result() : result, theme, runtime, attention, typeof showDependencies === "function" ? showDependencies() : showDependencies, onStageSelect, activityFrame),
|
|
142
|
+
children: () => renderStagesContent(typeof result === "function" ? result() : result, theme, runtime, attention, typeof showDependencies === "function" ? showDependencies() : showDependencies, onStageSelect, activityFrame, currentModel),
|
|
145
143
|
});
|
|
146
144
|
};
|
|
147
145
|
|
|
@@ -303,9 +301,9 @@ export const createStagesTuiController = ({ projectRoot, read = readStagesSnapsh
|
|
|
303
301
|
|
|
304
302
|
export { resolveProjectRoot } from "./project-root.js";
|
|
305
303
|
|
|
306
|
-
const renderStagesSlot = (controller, theme, sessionId, runtime = defaultRuntime, attention, onStageSelect) => runtime.jsx("box", {
|
|
304
|
+
const renderStagesSlot = (controller, theme, sessionId, runtime = defaultRuntime, attention, onStageSelect, currentModel) => runtime.jsx("box", {
|
|
307
305
|
flexDirection: "column",
|
|
308
|
-
children: renderStagesElement(() => controller.resultFor(sessionId), theme, runtime, attention, controller.showDependencies, onStageSelect, controller.activityFrame),
|
|
306
|
+
children: renderStagesElement(() => controller.resultFor(sessionId), theme, runtime, attention, controller.showDependencies, onStageSelect, controller.activityFrame, currentModel),
|
|
309
307
|
});
|
|
310
308
|
|
|
311
309
|
const updateSessionTitle = async (api, projectRoot) => {
|
|
@@ -486,7 +484,7 @@ export const tui = async (api, options = {}) => {
|
|
|
486
484
|
sidebar_content: (slotContext = {}, slotState = {}) => {
|
|
487
485
|
const sessionId = sessionIdForSlot(api, initialSessionId, slotContext, slotState) || ACTIVE_WORKSPACE_SESSION;
|
|
488
486
|
currentSessionId = sessionId;
|
|
489
|
-
return renderStagesSlot(controller, api.theme, sessionId, options.runtime, api.workContextAttention, (stage) => stageSwitcher.select(stage.id));
|
|
487
|
+
return renderStagesSlot(controller, api.theme, sessionId, options.runtime, api.workContextAttention, (stage) => stageSwitcher.select(stage.id), () => sessionModelLabel(api, sessionId));
|
|
490
488
|
},
|
|
491
489
|
},
|
|
492
490
|
});
|
|
@@ -9,6 +9,7 @@ import { openWorkspaceSwitcher } from "./workspace-switcher.js";
|
|
|
9
9
|
import { openSessionSwitcher } from "./session-switcher.js";
|
|
10
10
|
import { attentionForSession, attentionIndicatorText, attentionReasonText } from "./attention.js";
|
|
11
11
|
import { resolveProjectRoot, withProjectRoot } from "./project-root.js";
|
|
12
|
+
import { capabilitySummaryText, sessionModelLabel } from "./session-model.js";
|
|
12
13
|
|
|
13
14
|
const COMMAND_NAME = "work_context.open";
|
|
14
15
|
const ACTIONS_COMMAND_NAME = "work_context.actions";
|
|
@@ -21,7 +22,6 @@ const POLL_MS = 1000;
|
|
|
21
22
|
const MARKERS = { planned: "[ ]", in_progress: "[•]", completed: "[✓]", cancelled: "[!]" };
|
|
22
23
|
const COMMANDS = { list: "list", resume: "resume", handoff: "stage handoff", finish: "stage finish" };
|
|
23
24
|
const activeTuiInstances = new WeakMap();
|
|
24
|
-
const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
|
|
25
25
|
|
|
26
26
|
export const WORK_CONTEXT_ACTIONS = [
|
|
27
27
|
{ value: "help", title: "Help", description: "Show work-context command help", category: "General" },
|
|
@@ -224,7 +224,7 @@ export const createWorkContextModalController = ({
|
|
|
224
224
|
const line = (runtime, children, props = {}) => runtime.jsx("text", { ...props, children });
|
|
225
225
|
const marker = (status) => MARKERS[status] || "[?]";
|
|
226
226
|
|
|
227
|
-
export const renderWorkContextModal = (controller, theme, runtime = { jsx }, { maxListHeight = 24 } = {}) => {
|
|
227
|
+
export const renderWorkContextModal = (controller, theme, runtime = { jsx }, { maxListHeight = 24, currentModel = () => null } = {}) => {
|
|
228
228
|
let workspaceScroll;
|
|
229
229
|
let stageScroll;
|
|
230
230
|
controller.onSelectionChange?.(() => queueMicrotask(() => {
|
|
@@ -239,6 +239,7 @@ export const renderWorkContextModal = (controller, theme, runtime = { jsx }, { m
|
|
|
239
239
|
const selected = controller.selectedWorkspace();
|
|
240
240
|
const stage = controller.selectedStage();
|
|
241
241
|
const data = result?.data;
|
|
242
|
+
const capability = capabilitySummaryText(stage, stage?.current ? currentModel() : null);
|
|
242
243
|
const status = result?.stale ? `STALE · ${result.error?.code || "STORAGE_ERROR"}` : result?.ok === false ? `ERROR · ${result.error?.code || "STORAGE_ERROR"}` : "LIVE";
|
|
243
244
|
const muted = theme?.current?.textMuted;
|
|
244
245
|
const selectedWorkspaceIndex = selected ? workspaces.indexOf(selected) : -1;
|
|
@@ -290,7 +291,7 @@ export const renderWorkContextModal = (controller, theme, runtime = { jsx }, { m
|
|
|
290
291
|
...(controller.details() && stage ? [
|
|
291
292
|
line(runtime, "Details", { marginTop: 1, fg: muted }),
|
|
292
293
|
line(runtime, stage.description || "No description.", { wrapMode: "word", fg: theme?.current?.text }),
|
|
293
|
-
|
|
294
|
+
capability && line(runtime, capability, { wrapMode: "word", fg: muted }),
|
|
294
295
|
line(runtime, `Sessions ${(selected.sessions || []).length}`, { fg: muted }),
|
|
295
296
|
...(selected.sessions || []).map((session) => {
|
|
296
297
|
const unread = controller.attention?.attentionFor?.(session.opencode_session_id);
|
|
@@ -583,7 +584,7 @@ export const openCompatibilityDialog = (api, runtime = {}, options = {}) => {
|
|
|
583
584
|
const controller = createWorkContextModalController({ projectRoot, sessionId, read: options.read || readWorkContextSnapshot, createSignal: runtime.createSignal, attention: api.workContextAttention, onClose: close, onCommand: (command) => insertPromptCommand(api, command) });
|
|
584
585
|
try { watcher = projectRoot && fs.watch(path.join(projectRoot, ".work-context"), { recursive: true }, () => controller.scheduleRefresh?.()); } catch {}
|
|
585
586
|
const maxListHeight = Math.max(8, Math.floor((api.renderer?.height || 60) / 2) - 6);
|
|
586
|
-
const render = () => renderWorkContextModal(controller, api.theme, runtime, { maxListHeight });
|
|
587
|
+
const render = () => renderWorkContextModal(controller, api.theme, runtime, { maxListHeight, currentModel: () => sessionModelLabel(api, sessionId) });
|
|
587
588
|
stack.replace(render, close);
|
|
588
589
|
return true;
|
|
589
590
|
};
|
|
@@ -68,7 +68,7 @@ export const stageCapabilityProfiles = (storage, stage, localMappings) => {
|
|
|
68
68
|
...(stage.execution_depth ? { execution_depth: stage.execution_depth } : {}),
|
|
69
69
|
...(stage.execution_classification ? { execution_classification: stage.execution_classification } : {}),
|
|
70
70
|
...(stage.review_profile ? { review_profile: stage.review_profile } : {}),
|
|
71
|
-
...(recommendation ? { recommended_model: recommendation.target
|
|
71
|
+
...(recommendation?.target ? { recommended_model: recommendation.target } : {}),
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
|
package/src/core.js
CHANGED
|
@@ -240,7 +240,7 @@ export class WorkContext {
|
|
|
240
240
|
fs.mkdirSync(path.join(this.storage.workspaceDir(workspace), "stages"), { recursive: true });
|
|
241
241
|
this.storage.writeMarkdown(this.storage.workspaceFile(workspace), { schema: 1, workspace, title: title.trim(), status: "in_progress", mode, created_at: now, updated_at: now, tracker_links: [] }, body(title));
|
|
242
242
|
const planningGoal = "Clarify the work goal and constraints";
|
|
243
|
-
const planningPrompt = "Diagnose and plan the task without functional changes. Discuss possible solutions, record durable workspace-wide facts, decisions, constraints, important files, and risks through explicit knowledge operations, and decompose the work into the following stages. For each new implementation stage, write a separate detailed prompt with local context, concrete actions, constraints, completion criteria, and the expected result; do not duplicate shared knowledge that every stage receives in resume.context.workspace_knowledge. Ask clarifying questions only when genuinely blocked. Stages must remain in progress until the user explicitly requests stage finish. If the user explicitly agrees to automatic completion for this workspace, add the exact standalone line AUTO_STAGE_FINISH: allowed to this Planning-stage prompt.";
|
|
243
|
+
const planningPrompt = "Diagnose and plan the task without functional changes. Planning stage 01 is a continuously available coordination surface, never a prerequisite gate: do not make implementation, research, review, or other working stages depend on it. Discuss possible solutions, record durable workspace-wide facts, decisions, constraints, important files, and risks through explicit knowledge operations, and decompose the work into the following stages. For each new implementation stage, write a separate detailed prompt with local context, concrete actions, constraints, completion criteria, and the expected result; do not duplicate shared knowledge that every stage receives in resume.context.workspace_knowledge. Ask clarifying questions only when genuinely blocked. Stages must remain in progress until the user explicitly requests stage finish. If the user explicitly agrees to automatic completion for this workspace, add the exact standalone line AUTO_STAGE_FINISH: allowed to this Planning-stage prompt.";
|
|
244
244
|
this.storage.writeMarkdown(this.storage.stageFile(workspace, "01"), { schema: 1, workspace, stage: "01", title: "Planning", status: "in_progress", goal: planningGoal, prompt: planningPrompt, depends_on: [], owner: actor(this.options), created_at: now, updated_at: now, tracker_links: [] }, body("Planning", planningGoal, planningPrompt));
|
|
245
245
|
const sessionId = options.sessionId || randomUUID();
|
|
246
246
|
const workflowPolicy = mode === "startup" && options.opencodeSessionId ? startupWorkflowPolicy() : null;
|
|
@@ -471,6 +471,7 @@ export class WorkContext {
|
|
|
471
471
|
if (!Array.isArray(options.dependsOn || [])) fail(ERROR_CODES.INVALID_ARGUMENT, "dependsOn must contain unique stage IDs");
|
|
472
472
|
const dependsOn = (options.dependsOn || []).map(normalizeStageId);
|
|
473
473
|
if (new Set(dependsOn).size !== dependsOn.length) fail(ERROR_CODES.INVALID_ARGUMENT, "dependsOn must contain unique stage IDs");
|
|
474
|
+
if (dependsOn.includes("01")) fail(ERROR_CODES.PLANNING_DEPENDENCY_FORBIDDEN, "Working stages cannot depend on Planning stage 01");
|
|
474
475
|
assertCapabilityProfile(options.executionProfile, "executionProfile");
|
|
475
476
|
assertCapabilityDepth(options.executionDepth, "executionDepth");
|
|
476
477
|
assertCapabilityClassification(options.classification);
|
package/src/errors.js
CHANGED
|
@@ -17,6 +17,7 @@ export const ERROR_CODES = Object.freeze({
|
|
|
17
17
|
DELIVERY_INVALID_RANGE: "DELIVERY_INVALID_RANGE", DELIVERY_RANGE_TOO_LARGE: "DELIVERY_RANGE_TOO_LARGE",
|
|
18
18
|
DELIVERY_INVALID_FINDINGS: "DELIVERY_INVALID_FINDINGS", DELIVERY_DIAGNOSTIC_TOO_LARGE: "DELIVERY_DIAGNOSTIC_TOO_LARGE",
|
|
19
19
|
DELIVERY_COMMAND_PROTOCOL_MISMATCH: "DELIVERY_COMMAND_PROTOCOL_MISMATCH",
|
|
20
|
+
PLANNING_DEPENDENCY_FORBIDDEN: "PLANNING_DEPENDENCY_FORBIDDEN",
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
export class WorkContextError extends Error {
|
package/src/stages-renderer.js
CHANGED
|
@@ -57,8 +57,8 @@ export const formatStageIds = (ids = []) => {
|
|
|
57
57
|
return ranges.join(", ");
|
|
58
58
|
};
|
|
59
59
|
const profileSummary = (stage) => {
|
|
60
|
-
return stage.execution_profile && stage.execution_depth
|
|
61
|
-
?
|
|
60
|
+
return stage.execution_profile && stage.execution_depth
|
|
61
|
+
? [capitalize(stage.execution_profile), capitalize(stage.execution_depth), stage.recommended_model && capitalize(stage.recommended_model)].filter(Boolean).join(" · ")
|
|
62
62
|
: null;
|
|
63
63
|
};
|
|
64
64
|
|