opencode-work-context 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/commands/wc.md +22 -2
- package/package.json +1 -1
- package/plugin/stages-tui.js +40 -18
- package/plugin/work-context-modal.js +2 -0
- package/src/capability-profiles.js +78 -0
- package/src/core.js +154 -7
- package/src/index.js +1 -0
- package/src/stages-renderer.js +24 -1
- package/src/stages-snapshot.js +3 -0
- package/src/storage.js +13 -4
- package/src/tool-definitions.js +10 -3
- package/src/work-context-snapshot.js +5 -2
- package/tools/work_context_configure_capability_profiles.js +2 -0
- package/tools/work_context_refresh_stage_profiles.js +2 -0
- package/tools/work_context_reset_capability_profiles.js +2 -0
- package/tools/work_context_set_stage_profiles.js +2 -0
- package/tools/work_context_show_capability_profiles.js +2 -0
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ Then create a task and its first stage in OpenCode:
|
|
|
51
51
|
/wc create "Add CSV export to analytics report"
|
|
52
52
|
/wc stage rename 000001 01 "Planning"
|
|
53
53
|
/wc stage add 000001 "Update the export endpoint" "Inspect the current endpoint, implement CSV export, add regression tests, and verify the result."
|
|
54
|
+
/wc stage profiles 000001 02 execution implementation depth standard
|
|
54
55
|
/wc resume 000001 02
|
|
55
56
|
```
|
|
56
57
|
|
|
@@ -101,6 +102,58 @@ Resume a stage with:
|
|
|
101
102
|
/wc resume 000001 02
|
|
102
103
|
```
|
|
103
104
|
|
|
105
|
+
### Capability Recommendations
|
|
106
|
+
|
|
107
|
+
An execution recommendation combines a portable capability (`routine`,
|
|
108
|
+
`implementation`, `architecture`, `security`, or `review`) with a model depth
|
|
109
|
+
(`light`, `standard`, or `deep`). During Planning, the agent infers missing
|
|
110
|
+
values from the complete stage context and records the classification as
|
|
111
|
+
`inferred`. Explicit user choices are preserved until deliberately replaced:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
/wc stage profiles 000001 02 execution implementation depth deep
|
|
115
|
+
/wc stage profiles 000001 02 execution clear
|
|
116
|
+
/wc stage profiles refresh 000001
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Ordinary refresh updates missing and inferred classifications for actionable
|
|
120
|
+
stages and preserves explicit assignments. Add `--include-explicit` only when
|
|
121
|
+
the user deliberately requests a complete reassessment. Core, resume, and
|
|
122
|
+
read-only UI never classify stages or use keyword heuristics.
|
|
123
|
+
|
|
124
|
+
Avoid editing configuration by hand:
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
/wc profiles setup
|
|
128
|
+
/wc profiles show
|
|
129
|
+
/wc profiles reset
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`profiles setup` asks for advisory/off mode and the local model label for each
|
|
133
|
+
depth, then offers to refresh unfinished stages. Profiles are advisory by
|
|
134
|
+
default. Off mode hides and skips resolution while preserving stage metadata.
|
|
135
|
+
The resulting user-local mappings live only in the ignored
|
|
136
|
+
`.work-context/local/capability-profiles.json` file:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"schema": 1,
|
|
141
|
+
"mappings": {
|
|
142
|
+
"light": "Luna",
|
|
143
|
+
"standard": "Terra",
|
|
144
|
+
"deep": "Sol"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Expanded stage details render one compact line such as `implementation · deep ·
|
|
150
|
+
Sol`; an absent mapping renders `current model`. Optional `review_profile`
|
|
151
|
+
metadata neither resolves a model nor controls separately configured subagents.
|
|
152
|
+
Targets are bounded opaque labels and never enter tracked data. Invalid entries
|
|
153
|
+
produce bounded warnings. The plugin never changes an active model or agent,
|
|
154
|
+
invokes a reviewer, creates a replacement session, or blocks resume. `init`,
|
|
155
|
+
`activate`, and `sync-command` preserve files below `.work-context/local/`.
|
|
156
|
+
|
|
104
157
|
Long-running stages may keep a bounded execution ledger separate from the
|
|
105
158
|
original prompt, workspace knowledge, session summaries, and final result. It
|
|
106
159
|
tracks current scope, completed and remaining work, stage-local decisions,
|
package/commands/wc.md
CHANGED
|
@@ -43,7 +43,12 @@ Use these exact tool mappings; do not invent shortened tool names:
|
|
|
43
43
|
- `workspace reopen <workspace> "reason"` -> `work_context_reopen_workspace`
|
|
44
44
|
- `resume <workspace> <stage>` -> `work_context_start_session`
|
|
45
45
|
- `stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE` -> `work_context_force_close_session`
|
|
46
|
-
- `
|
|
46
|
+
- `profiles show` -> `work_context_show_capability_profiles`
|
|
47
|
+
- `profiles setup` -> ask the user questions, then `work_context_configure_capability_profiles`
|
|
48
|
+
- `profiles reset` -> ask for confirmation, then `work_context_reset_capability_profiles`
|
|
49
|
+
- `stage add [<workspace>] ...` -> `work_context_add_stage` (optional `prompt`; infer missing execution capability and depth from the complete stage context before calling the tool)
|
|
50
|
+
- `stage profiles [<workspace>] [<stage>] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>|clear] [review <routine|implementation|architecture|security|review|clear>]` -> `work_context_set_stage_profiles`
|
|
51
|
+
- `stage profiles refresh <workspace> [<stage>] [--include-explicit]` -> inspect current stage context, infer classifications, then `work_context_refresh_stage_profiles`
|
|
47
52
|
- `stage reopen <workspace> <stage> "reason"` -> `work_context_reopen_stage`
|
|
48
53
|
- `stage restore <workspace> <stage> "reason"` -> `work_context_restore_stage`
|
|
49
54
|
- `stage rename [<workspace>] [<stage>] "title"` -> `work_context_rename_stage`
|
|
@@ -82,7 +87,12 @@ Supported syntax:
|
|
|
82
87
|
- `workspace reopen <workspace> "reason"`
|
|
83
88
|
- `resume <workspace> <stage>`
|
|
84
89
|
- `stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE`
|
|
85
|
-
- `
|
|
90
|
+
- `profiles show`
|
|
91
|
+
- `profiles setup`
|
|
92
|
+
- `profiles reset`
|
|
93
|
+
- `stage add [<workspace>] "title" ["prompt"] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>] [review <routine|implementation|architecture|security|review>]`
|
|
94
|
+
- `stage profiles [<workspace>] [<stage>] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>|clear] [review <routine|implementation|architecture|security|review|clear>]`
|
|
95
|
+
- `stage profiles refresh <workspace> [<stage>] [--include-explicit]`
|
|
86
96
|
- `stage reopen <workspace> <stage> "reason"`
|
|
87
97
|
- `stage restore <workspace> <stage> "reason"`
|
|
88
98
|
- `stage rename [<workspace>] [<stage>] "title"`
|
|
@@ -106,6 +116,16 @@ Supported syntax:
|
|
|
106
116
|
- explicit workspace and stage positions accept canonical padded IDs or unpadded positive integers (`1..999999` and `1..99`); results and generated commands remain padded
|
|
107
117
|
- 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
|
|
108
118
|
- `stage update-result` replaces an existing result and does not create a result for an unfinished stage
|
|
119
|
+
- execution recommendations have two independent portable fields: capability (`routine`, `implementation`, `architecture`, `security`, `review`) and depth (`light`, `standard`, `deep`)
|
|
120
|
+
- 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`
|
|
121
|
+
- 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
|
|
122
|
+
- `stage profiles` makes an explicit assignment; execution capability and depth are set or cleared together, omitted fields remain unchanged, and review remains optional metadata that does not control subagents or resolve a model
|
|
123
|
+
- `stage profiles refresh` re-evaluates actionable missing/inferred stages from their complete current context and applies all computed recommendations in one structured call; skip completed/archived stages and preserve explicit assignments unless `--include-explicit` was requested
|
|
124
|
+
- `capability_profiles.mode` in `.work-context/config.yaml` is `advisory` by default or `off`; off mode preserves metadata but omits profile presentation, resolution, and mapping warnings
|
|
125
|
+
- advisory mappings are local depth-to-model labels, for example `{ "schema": 1, "mappings": { "light": "Luna", "standard": "Terra", "deep": "Sol" } }`; invalid entries are ignored with bounded warnings and missing mappings resolve to `current model`
|
|
126
|
+
- `profiles setup` must use interactive questions for mode and light/standard/deep labels, apply mode and mappings in separate atomic structured calls, then offer to refresh unfinished stages; `profiles reset` requires explicit confirmation and removes mappings without changing stage metadata or mode
|
|
127
|
+
- expanded stage details show one unlabeled line `<capability> · <depth> · <model>`; review metadata is not displayed as a model recommendation
|
|
128
|
+
- capability recommendations never select a model or agent, create a replacement session, block resume, or persist mapping targets in tracked workspace data
|
|
109
129
|
- stage execution state has `scope`, `completed`, `remaining`, `decisions`, `blockers`, and `verification` string-array sections; `replace` accepts the complete state object, while `update` accepts an object with `add` and/or `remove` section objects
|
|
110
130
|
- read stage execution state first and pass its revision as `expectedRevision`; absent legacy state has revision `0`, and a stale mutation returns `EXECUTION_REVISION_CONFLICT` without changing newer state
|
|
111
131
|
- execution mutations require the active stage session, trim and deduplicate items, reject overlap between `completed` and `remaining`, and enforce bounded item counts, lengths, and serialized size
|
package/package.json
CHANGED
package/plugin/stages-tui.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { readStagesSnapshot } from "../src/stages-snapshot.js";
|
|
4
4
|
import { contextFor, titleFor } from "../src/opencode-adapter.js";
|
|
5
|
-
import { renderDependencyTree, renderStagesPanel } from "../src/stages-renderer.js";
|
|
5
|
+
import { formatStageIds, renderDependencyTree, renderStagesPanel } from "../src/stages-renderer.js";
|
|
6
6
|
import { jsx } from "@opentui/solid/jsx-runtime";
|
|
7
7
|
import { createSignal } from "solid-js";
|
|
8
8
|
import { attentionSummaryText } from "./attention.js";
|
|
@@ -57,6 +57,16 @@ const stageCandidateText = (stage) => {
|
|
|
57
57
|
const others = candidate.related_stages.filter((related) => related !== stage.id);
|
|
58
58
|
return `Pending: ${candidate.status} · ${candidate.strategy}${others.length ? ` · also ${others.join(", ")}` : ""}`;
|
|
59
59
|
};
|
|
60
|
+
const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
|
|
61
|
+
const visibleAttentionSnapshot = (attention, workspace, stages) => {
|
|
62
|
+
const byStage = new Map(stages.map((stage) => [stage.id, attention?.attentionForStage?.(workspace, stage.id) || null]));
|
|
63
|
+
const bySession = new Map();
|
|
64
|
+
for (const unread of byStage.values()) {
|
|
65
|
+
for (const item of unread?.items || []) bySession.set(item.sessionId, item);
|
|
66
|
+
}
|
|
67
|
+
const items = [...bySession.values()];
|
|
68
|
+
return { byStage, workspace: items.length ? { count: items.length, items } : null };
|
|
69
|
+
};
|
|
60
70
|
|
|
61
71
|
export { readStagesSnapshot, renderStagesPanel };
|
|
62
72
|
|
|
@@ -66,7 +76,8 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
|
|
|
66
76
|
runtime.jsx("text", { children: runtime.jsx("b", { children: "Stages" }) }),
|
|
67
77
|
...renderStagesPanel(result).split("\n").slice(1).map((line) => runtime.jsx("text", { children: line })),
|
|
68
78
|
];
|
|
69
|
-
const
|
|
79
|
+
const attentionSnapshot = visibleAttentionSnapshot(attention, result.data.workspace.id, result.data.stages);
|
|
80
|
+
const workspaceAttention = attentionSummaryText(attentionSnapshot.workspace, { alwaysCount: true });
|
|
70
81
|
return [
|
|
71
82
|
runtime.jsx("box", {
|
|
72
83
|
marginBottom: 1,
|
|
@@ -86,36 +97,47 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
|
|
|
86
97
|
runtime.jsx("text", { fg: theme?.current?.textMuted, children: ` · ${result.data.workspace.status}` }),
|
|
87
98
|
],
|
|
88
99
|
}),
|
|
89
|
-
...result.data.stages.
|
|
90
|
-
const unread =
|
|
100
|
+
...result.data.stages.flatMap((stage) => {
|
|
101
|
+
const unread = attentionSnapshot.byStage.get(stage.id);
|
|
91
102
|
const working = attention?.activityForStage?.(result.data.workspace.id, stage.id);
|
|
103
|
+
const recommendation = stage.execution_profile && stage.execution_depth && stage.recommended_model
|
|
104
|
+
? `${capitalize(stage.execution_profile)} · ${capitalize(stage.execution_depth)} · ${capitalize(stage.recommended_model)}`
|
|
105
|
+
: null;
|
|
92
106
|
const stageMetadata = [
|
|
93
107
|
stage.tracker_links?.length && `Tasks: ${stage.tracker_links.map(trackerLinkText).join(", ")}`,
|
|
94
|
-
stage.depends_on?.length && `Deps: ${stage.depends_on
|
|
108
|
+
stage.depends_on?.length && `Deps: ${formatStageIds(stage.depends_on)}`,
|
|
95
109
|
].filter(Boolean).join(" · ");
|
|
96
|
-
const metadata = showDependencies ? [stageMetadata, stageCandidateText(stage)].filter(Boolean).join("\n") : "";
|
|
110
|
+
const metadata = showDependencies ? [recommendation, stageMetadata, stageCandidateText(stage)].filter(Boolean).join("\n") : "";
|
|
97
111
|
const attentionSignal = attentionSummaryText(unread);
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
112
|
+
const current = stage.current || stage.id === result.data.currentStage;
|
|
113
|
+
const onMouseDown = (event) => {
|
|
114
|
+
if (event?.button != null && event.button !== 0) return;
|
|
115
|
+
return onStageSelect?.(stage);
|
|
116
|
+
};
|
|
117
|
+
const titleRow = runtime.jsx("box", {
|
|
103
118
|
flexDirection: "row",
|
|
104
|
-
onMouseDown
|
|
105
|
-
if (event?.button != null && event.button !== 0) return;
|
|
106
|
-
return onStageSelect?.(stage);
|
|
107
|
-
},
|
|
119
|
+
onMouseDown,
|
|
108
120
|
children: [
|
|
109
121
|
runtime.jsx("text", {
|
|
110
122
|
flexShrink: 0,
|
|
111
123
|
marginRight: 1,
|
|
112
|
-
fg: working ||
|
|
124
|
+
fg: working || current ? theme?.current?.warning : theme?.current?.textMuted,
|
|
113
125
|
children: working ? activityFrame() : attentionSignal ? runtime.jsx("b", { children: attentionSignal }) : " ",
|
|
114
126
|
}),
|
|
115
|
-
runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg:
|
|
116
|
-
runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg:
|
|
127
|
+
runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: current ? theme?.current?.warning : theme?.current?.textMuted, children: statusMarker(stage.status) }),
|
|
128
|
+
runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: current ? theme?.current?.warning : theme?.current?.text, children: `${stage.id}. ${stage.title}` }),
|
|
129
|
+
],
|
|
130
|
+
});
|
|
131
|
+
const metadataRow = metadata && runtime.jsx("box", {
|
|
132
|
+
flexDirection: "row",
|
|
133
|
+
onMouseDown,
|
|
134
|
+
children: [
|
|
135
|
+
runtime.jsx("text", { flexShrink: 0, marginRight: 1, children: " " }),
|
|
136
|
+
runtime.jsx("text", { flexShrink: 0, marginRight: 1, children: " " }),
|
|
137
|
+
runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: theme?.current?.textMuted, children: metadata }),
|
|
117
138
|
],
|
|
118
139
|
});
|
|
140
|
+
return [titleRow, metadataRow].filter(Boolean);
|
|
119
141
|
}),
|
|
120
142
|
];
|
|
121
143
|
};
|
|
@@ -21,6 +21,7 @@ const POLL_MS = 1000;
|
|
|
21
21
|
const MARKERS = { planned: "[ ]", in_progress: "[•]", completed: "[✓]", cancelled: "[!]" };
|
|
22
22
|
const COMMANDS = { list: "list", resume: "resume", handoff: "stage handoff", finish: "stage finish" };
|
|
23
23
|
const activeTuiInstances = new WeakMap();
|
|
24
|
+
const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
|
|
24
25
|
|
|
25
26
|
export const WORK_CONTEXT_ACTIONS = [
|
|
26
27
|
{ value: "help", title: "Help", description: "Show work-context command help", category: "General" },
|
|
@@ -289,6 +290,7 @@ export const renderWorkContextModal = (controller, theme, runtime = { jsx }, { m
|
|
|
289
290
|
...(controller.details() && stage ? [
|
|
290
291
|
line(runtime, "Details", { marginTop: 1, fg: muted }),
|
|
291
292
|
line(runtime, stage.description || "No description.", { wrapMode: "word", fg: theme?.current?.text }),
|
|
293
|
+
stage.execution_profile && stage.execution_depth && stage.recommended_model && line(runtime, `${capitalize(stage.execution_profile)} · ${capitalize(stage.execution_depth)} · ${capitalize(stage.recommended_model)}`, { wrapMode: "word", fg: muted }),
|
|
292
294
|
line(runtime, `Sessions ${(selected.sessions || []).length}`, { fg: muted }),
|
|
293
295
|
...(selected.sessions || []).map((session) => {
|
|
294
296
|
const unread = controller.attention?.attentionFor?.(session.opencode_session_id);
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
export const CAPABILITY_PROFILES = Object.freeze(["routine", "implementation", "architecture", "security", "review"]);
|
|
5
|
+
export const CAPABILITY_DEPTHS = Object.freeze(["light", "standard", "deep"]);
|
|
6
|
+
export const CAPABILITY_CLASSIFICATIONS = Object.freeze(["inferred", "explicit"]);
|
|
7
|
+
export const CAPABILITY_PROFILE_MODES = Object.freeze(["advisory", "off"]);
|
|
8
|
+
export const CAPABILITY_MAPPINGS_FILE = "capability-profiles.json";
|
|
9
|
+
const MAX_MAPPING_BYTES = 16 * 1024;
|
|
10
|
+
const MAX_WARNINGS = 5;
|
|
11
|
+
|
|
12
|
+
export const capabilityProfileMode = (storage) => storage.config.capability_profiles?.mode || "advisory";
|
|
13
|
+
|
|
14
|
+
const warning = (message) => ({ code: "INVALID_CAPABILITY_MAPPING", message });
|
|
15
|
+
const validTarget = (value) => typeof value === "string"
|
|
16
|
+
&& value.length <= 200
|
|
17
|
+
&& value.trim() === value
|
|
18
|
+
&& value.length > 0
|
|
19
|
+
&& !/[\u0000-\u001f\u007f]/.test(value);
|
|
20
|
+
|
|
21
|
+
export function readCapabilityMappings(storage) {
|
|
22
|
+
const file = path.join(storage.personalRoot, CAPABILITY_MAPPINGS_FILE);
|
|
23
|
+
if (!fs.existsSync(file)) return { mappings: {}, warnings: [] };
|
|
24
|
+
try {
|
|
25
|
+
const stat = fs.lstatSync(file);
|
|
26
|
+
if (!stat.isFile() || stat.size > MAX_MAPPING_BYTES) return { mappings: {}, warnings: [warning(`Ignoring ${CAPABILITY_MAPPINGS_FILE}; expected a regular file no larger than ${MAX_MAPPING_BYTES} bytes.`)] };
|
|
27
|
+
} catch { return { mappings: {}, warnings: [warning(`Cannot inspect ${CAPABILITY_MAPPINGS_FILE}; continuing without local mappings.`)] }; }
|
|
28
|
+
let input;
|
|
29
|
+
try { input = JSON.parse(fs.readFileSync(file, "utf8")); }
|
|
30
|
+
catch { return { mappings: {}, warnings: [warning(`Invalid ${CAPABILITY_MAPPINGS_FILE}; expected JSON with schema and mappings.`)] }; }
|
|
31
|
+
|
|
32
|
+
if (!input || typeof input !== "object" || Array.isArray(input) || input.schema !== 1 || !input.mappings || typeof input.mappings !== "object" || Array.isArray(input.mappings)) {
|
|
33
|
+
return { mappings: {}, warnings: [warning(`Invalid ${CAPABILITY_MAPPINGS_FILE}; expected { "schema": 1, "mappings": { ... } }.`)] };
|
|
34
|
+
}
|
|
35
|
+
const warnings = [];
|
|
36
|
+
const addWarning = (message) => { if (warnings.length < MAX_WARNINGS) warnings.push(warning(message)); };
|
|
37
|
+
if (Object.keys(input).some((key) => !["schema", "mappings"].includes(key))) addWarning(`Ignoring unknown top-level keys in ${CAPABILITY_MAPPINGS_FILE}.`);
|
|
38
|
+
const mappings = {};
|
|
39
|
+
for (const [depth, target] of Object.entries(input.mappings)) {
|
|
40
|
+
const safeDepth = depth.replace(/[\u0000-\u001f\u007f]/g, "?").slice(0, 40);
|
|
41
|
+
if (!CAPABILITY_DEPTHS.includes(depth)) addWarning(`Ignoring unknown capability depth mapping: ${safeDepth}.`);
|
|
42
|
+
else if (!validTarget(target)) addWarning(`Ignoring invalid target for capability depth mapping: ${depth}.`);
|
|
43
|
+
else mappings[depth] = target;
|
|
44
|
+
}
|
|
45
|
+
return { mappings, warnings };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function capabilityRecommendations(storage, stage, localMappings) {
|
|
49
|
+
if (capabilityProfileMode(storage) === "off") return null;
|
|
50
|
+
if (!stage.execution_profile || !stage.execution_depth) return null;
|
|
51
|
+
const { mappings, warnings } = localMappings || readCapabilityMappings(storage);
|
|
52
|
+
const target = mappings[stage.execution_depth];
|
|
53
|
+
return {
|
|
54
|
+
mode: "advisory",
|
|
55
|
+
execution: target
|
|
56
|
+
? { profile: stage.execution_profile, depth: stage.execution_depth, classification: stage.execution_classification || "explicit", source: "mapping", target }
|
|
57
|
+
: { profile: stage.execution_profile, depth: stage.execution_depth, classification: stage.execution_classification || "explicit", source: "current", message: "No mapping configured; continuing with the current model." },
|
|
58
|
+
...(stage.review_profile ? { review: { profile: stage.review_profile } } : {}),
|
|
59
|
+
...(warnings.length ? { warnings } : {}),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const stageCapabilityProfiles = (storage, stage, localMappings) => {
|
|
64
|
+
if (capabilityProfileMode(storage) !== "advisory") return {};
|
|
65
|
+
const recommendation = capabilityRecommendations(storage, stage, localMappings)?.execution;
|
|
66
|
+
return {
|
|
67
|
+
...(stage.execution_profile ? { execution_profile: stage.execution_profile } : {}),
|
|
68
|
+
...(stage.execution_depth ? { execution_depth: stage.execution_depth } : {}),
|
|
69
|
+
...(stage.execution_classification ? { execution_classification: stage.execution_classification } : {}),
|
|
70
|
+
...(stage.review_profile ? { review_profile: stage.review_profile } : {}),
|
|
71
|
+
...(recommendation ? { recommended_model: recommendation.target || "current model" } : {}),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export function validateCapabilityMappings(mappings) {
|
|
76
|
+
if (!mappings || typeof mappings !== "object" || Array.isArray(mappings) || Object.keys(mappings).some((key) => !CAPABILITY_DEPTHS.includes(key))) return false;
|
|
77
|
+
return Object.values(mappings).every(validTarget);
|
|
78
|
+
}
|
package/src/core.js
CHANGED
|
@@ -11,9 +11,20 @@ import { isDependencySatisfied } from "./stage-status.js";
|
|
|
11
11
|
import { CandidateStore } from "./candidates.js";
|
|
12
12
|
import { DeliveryStore } from "./delivery.js";
|
|
13
13
|
import { applyExecutionPatch, assertExecutionSize, executionState, normalizeExecutionState } from "./stage-execution.js";
|
|
14
|
+
import { CAPABILITY_CLASSIFICATIONS, CAPABILITY_DEPTHS, CAPABILITY_MAPPINGS_FILE, CAPABILITY_PROFILES, capabilityProfileMode, capabilityRecommendations, readCapabilityMappings, validateCapabilityMappings } from "./capability-profiles.js";
|
|
14
15
|
|
|
15
16
|
const actor = (options) => options.actor || "OpenCode";
|
|
16
17
|
const workspaceMode = (data) => data.mode || "standard";
|
|
18
|
+
const assertCapabilityProfile = (value, name) => {
|
|
19
|
+
if (value !== undefined && value !== null && !CAPABILITY_PROFILES.includes(value)) fail(ERROR_CODES.INVALID_ARGUMENT, `${name} must be one of: ${CAPABILITY_PROFILES.join(", ")}`);
|
|
20
|
+
};
|
|
21
|
+
const assertCapabilityDepth = (value, name) => {
|
|
22
|
+
if (value !== undefined && value !== null && !CAPABILITY_DEPTHS.includes(value)) fail(ERROR_CODES.INVALID_ARGUMENT, `${name} must be one of: ${CAPABILITY_DEPTHS.join(", ")}`);
|
|
23
|
+
};
|
|
24
|
+
const assertCapabilityClassification = (value) => {
|
|
25
|
+
if (value !== undefined && !CAPABILITY_CLASSIFICATIONS.includes(value)) fail(ERROR_CODES.INVALID_ARGUMENT, `classification must be one of: ${CAPABILITY_CLASSIFICATIONS.join(", ")}`);
|
|
26
|
+
};
|
|
27
|
+
const capabilityData = (storage, stage) => ({ mode: capabilityProfileMode(storage), ...(stage.execution_profile ? { execution_profile: stage.execution_profile } : {}), ...(stage.execution_depth ? { execution_depth: stage.execution_depth } : {}), ...(stage.execution_classification ? { execution_classification: stage.execution_classification } : {}), ...(stage.review_profile ? { review_profile: stage.review_profile } : {}) });
|
|
17
28
|
const activeKnowledge = (records) => records
|
|
18
29
|
.filter((record) => record.status === "active")
|
|
19
30
|
.map(({ id: knowledgeId, title, kind, text, sources }) => ({ id: knowledgeId, title, kind, text, sources }));
|
|
@@ -381,7 +392,8 @@ export class WorkContext {
|
|
|
381
392
|
const hasDeliveryContext = deliveryContext && (deliveryContext.committed.count || deliveryContext.environments.length || deliveryContext.unavailable);
|
|
382
393
|
const workspaceKnowledge = activeKnowledge(this.listKnowledge(workspace).data);
|
|
383
394
|
const execution = this.storage.readStageExecution(workspace, stage);
|
|
384
|
-
|
|
395
|
+
const automaticFinish = automaticFinishAllowed(this.storage, workspace);
|
|
396
|
+
const recommendations = capabilityRecommendations(this.storage, stageRecord.data);
|
|
385
397
|
return this.result({
|
|
386
398
|
workspace,
|
|
387
399
|
stage,
|
|
@@ -403,14 +415,16 @@ export class WorkContext {
|
|
|
403
415
|
scope: stageRecord.data.prompt || null,
|
|
404
416
|
previous_result: previousResult,
|
|
405
417
|
previous_session_summary: previousSessionSummary,
|
|
406
|
-
|
|
418
|
+
...(execution ? { execution_state: execution } : {}),
|
|
419
|
+
...(recommendations ? { capability_profiles: recommendations } : {}),
|
|
407
420
|
},
|
|
408
421
|
context: {
|
|
409
422
|
essence: stageRecord.data.goal || stageRecord.data.title,
|
|
410
423
|
previous: previousSessionSummary || previousResult || "No previous progress was recorded.",
|
|
411
424
|
now: hasPrompt ? stageRecord.data.prompt : "First clarify the task and work plan with the user.",
|
|
412
425
|
workspace_knowledge: workspaceKnowledge,
|
|
413
|
-
|
|
426
|
+
...(execution ? { execution_state: execution } : {}),
|
|
427
|
+
...(recommendations ? { capability_profiles: recommendations } : {}),
|
|
414
428
|
...(pendingCandidates ? { pending_candidates: pendingCandidates } : {}),
|
|
415
429
|
...(hasDeliveryContext ? { delivery_context: deliveryContext } : {}),
|
|
416
430
|
...(workflowPolicy ? { workflow_policy: workflowPolicy } : {}),
|
|
@@ -431,6 +445,11 @@ export class WorkContext {
|
|
|
431
445
|
if (!Array.isArray(options.dependsOn || [])) fail(ERROR_CODES.INVALID_ARGUMENT, "dependsOn must contain unique stage IDs");
|
|
432
446
|
const dependsOn = (options.dependsOn || []).map(normalizeStageId);
|
|
433
447
|
if (new Set(dependsOn).size !== dependsOn.length) fail(ERROR_CODES.INVALID_ARGUMENT, "dependsOn must contain unique stage IDs");
|
|
448
|
+
assertCapabilityProfile(options.executionProfile, "executionProfile");
|
|
449
|
+
assertCapabilityDepth(options.executionDepth, "executionDepth");
|
|
450
|
+
assertCapabilityClassification(options.classification);
|
|
451
|
+
assertCapabilityProfile(options.reviewProfile, "reviewProfile");
|
|
452
|
+
if (Boolean(options.executionProfile) !== Boolean(options.executionDepth)) fail(ERROR_CODES.INVALID_ARGUMENT, "executionProfile and executionDepth must be provided together");
|
|
434
453
|
return this.transact(`workspace-${workspace}`, () => {
|
|
435
454
|
const stages = this.listStages(workspace).data.stages;
|
|
436
455
|
if (stages.length >= 99) fail(ERROR_CODES.INVALID_STATE, "A workspace cannot contain more than 99 stages");
|
|
@@ -439,10 +458,138 @@ export class WorkContext {
|
|
|
439
458
|
if (dependsOn.some((dependency) => !stages.some((item) => item.stage === dependency))) fail(ERROR_CODES.INVALID_ARGUMENT, "dependsOn must reference existing stages");
|
|
440
459
|
const now = new Date().toISOString();
|
|
441
460
|
const prompt = options.prompt?.trim() || undefined;
|
|
442
|
-
const metadata = { schema: 1, workspace, stage, title: title.trim(), status: "planned", goal: options.goal || title.trim(), ...(prompt ? { prompt } : {}), depends_on: dependsOn, owner: options.owner || actor(this.options), created_at: now, updated_at: now, tracker_links: [] };
|
|
461
|
+
const metadata = { schema: 1, workspace, stage, title: title.trim(), status: "planned", goal: options.goal || title.trim(), ...(prompt ? { prompt } : {}), depends_on: dependsOn, 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: [] };
|
|
443
462
|
this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), metadata, body(title, options.goal || title, prompt));
|
|
444
463
|
generateProjections(this.storage);
|
|
445
|
-
|
|
464
|
+
const capabilityProfiles = metadata.execution_profile || metadata.review_profile
|
|
465
|
+
? { capability_profiles: capabilityData(this.storage, metadata) }
|
|
466
|
+
: {};
|
|
467
|
+
return this.result({ workspace, stage, status: "planned", session_started: false, resume_required: true, ...capabilityProfiles }, [stage]);
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
setStageProfiles(workspace, stage, profiles = {}) {
|
|
472
|
+
workspace = normalizeWorkspaceId(workspace);
|
|
473
|
+
stage = normalizeStageId(stage);
|
|
474
|
+
const hasExecution = Object.hasOwn(profiles, "executionProfile");
|
|
475
|
+
const hasDepth = Object.hasOwn(profiles, "executionDepth");
|
|
476
|
+
const hasReview = Object.hasOwn(profiles, "reviewProfile");
|
|
477
|
+
if (!hasExecution && !hasDepth && !hasReview) fail(ERROR_CODES.INVALID_ARGUMENT, "At least one profile or depth must be set or cleared");
|
|
478
|
+
assertCapabilityProfile(profiles.executionProfile, "executionProfile");
|
|
479
|
+
assertCapabilityDepth(profiles.executionDepth, "executionDepth");
|
|
480
|
+
assertCapabilityProfile(profiles.reviewProfile, "reviewProfile");
|
|
481
|
+
if ((profiles.executionProfile === null) !== (profiles.executionDepth === null) && (profiles.executionProfile === null || profiles.executionDepth === null)) fail(ERROR_CODES.INVALID_ARGUMENT, "Clear executionProfile and executionDepth together");
|
|
482
|
+
return this.transact(`stage-${workspace}-${stage}`, () => {
|
|
483
|
+
const record = this.storage.readStage(workspace, stage);
|
|
484
|
+
let changed = false;
|
|
485
|
+
for (const [provided, input, key] of [[hasExecution, profiles.executionProfile, "execution_profile"], [hasDepth, profiles.executionDepth, "execution_depth"], [hasReview, profiles.reviewProfile, "review_profile"]]) {
|
|
486
|
+
if (!provided) continue;
|
|
487
|
+
if (input === null) {
|
|
488
|
+
if (record.data[key] !== undefined) { delete record.data[key]; changed = true; }
|
|
489
|
+
} else if (record.data[key] !== input) { record.data[key] = input; changed = true; }
|
|
490
|
+
}
|
|
491
|
+
if ((hasExecution || hasDepth) && record.data.execution_profile && record.data.execution_depth && record.data.execution_classification !== "explicit") { record.data.execution_classification = "explicit"; changed = true; }
|
|
492
|
+
if ((hasExecution || hasDepth) && !record.data.execution_profile && !record.data.execution_depth && record.data.execution_classification !== undefined) { delete record.data.execution_classification; changed = true; }
|
|
493
|
+
if (Boolean(record.data.execution_profile) !== Boolean(record.data.execution_depth)) fail(ERROR_CODES.INVALID_ARGUMENT, "executionProfile and executionDepth must both be set or cleared");
|
|
494
|
+
if (changed) {
|
|
495
|
+
record.data.updated_at = new Date().toISOString();
|
|
496
|
+
this.storage.writeMarkdown(this.storage.stageFile(workspace, stage), record.data, record.body);
|
|
497
|
+
generateProjections(this.storage);
|
|
498
|
+
}
|
|
499
|
+
return this.result({ workspace, stage, capability_profiles: capabilityData(this.storage, record.data) }, changed ? [workspace, stage] : []);
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
refreshStageProfiles(workspace, recommendations, options = {}) {
|
|
504
|
+
workspace = normalizeWorkspaceId(workspace);
|
|
505
|
+
if (!Array.isArray(recommendations) || !recommendations.length || recommendations.length > 99) fail(ERROR_CODES.INVALID_ARGUMENT, "recommendations must contain 1 to 99 stage classifications");
|
|
506
|
+
const normalized = recommendations.map((item) => {
|
|
507
|
+
const stage = normalizeStageId(item.stage);
|
|
508
|
+
assertCapabilityProfile(item.executionProfile, "executionProfile");
|
|
509
|
+
assertCapabilityDepth(item.executionDepth, "executionDepth");
|
|
510
|
+
if (!item.executionProfile || !item.executionDepth) fail(ERROR_CODES.INVALID_ARGUMENT, "Each recommendation requires executionProfile and executionDepth");
|
|
511
|
+
return { stage, executionProfile: item.executionProfile, executionDepth: item.executionDepth };
|
|
512
|
+
});
|
|
513
|
+
if (new Set(normalized.map((item) => item.stage)).size !== normalized.length) fail(ERROR_CODES.INVALID_ARGUMENT, "recommendations must contain unique stage IDs");
|
|
514
|
+
return this.transact(`workspace-${workspace}`, () => {
|
|
515
|
+
const updated = [];
|
|
516
|
+
const unchanged = [];
|
|
517
|
+
const skipped = [];
|
|
518
|
+
for (const recommendation of normalized) {
|
|
519
|
+
const record = this.storage.readStage(workspace, recommendation.stage);
|
|
520
|
+
if (["completed", "archived", "cancelled"].includes(record.data.status)) { skipped.push({ stage: recommendation.stage, reason: "terminal" }); continue; }
|
|
521
|
+
if (record.data.execution_classification === "explicit" && !options.includeExplicit) { skipped.push({ stage: recommendation.stage, reason: "explicit" }); continue; }
|
|
522
|
+
const before = { profile: record.data.execution_profile || null, depth: record.data.execution_depth || null, classification: record.data.execution_classification || null };
|
|
523
|
+
const after = { profile: recommendation.executionProfile, depth: recommendation.executionDepth, classification: "inferred" };
|
|
524
|
+
if (before.profile === after.profile && before.depth === after.depth && before.classification === after.classification) { unchanged.push(recommendation.stage); continue; }
|
|
525
|
+
record.data.execution_profile = after.profile;
|
|
526
|
+
record.data.execution_depth = after.depth;
|
|
527
|
+
record.data.execution_classification = after.classification;
|
|
528
|
+
record.data.updated_at = new Date().toISOString();
|
|
529
|
+
this.storage.writeMarkdown(this.storage.stageFile(workspace, recommendation.stage), record.data, record.body);
|
|
530
|
+
updated.push({ stage: recommendation.stage, before, after });
|
|
531
|
+
}
|
|
532
|
+
if (updated.length) generateProjections(this.storage);
|
|
533
|
+
return this.result({ workspace, updated, unchanged, skipped }, updated.length ? [workspace, ...updated.map((item) => item.stage)] : []);
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
showCapabilityProfiles() {
|
|
538
|
+
const local = readCapabilityMappings(this.storage);
|
|
539
|
+
return this.result({ mode: capabilityProfileMode(this.storage), mappings: local.mappings, warnings: local.warnings }, []);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
configureCapabilityProfiles(options = {}) {
|
|
543
|
+
if (options.mode === undefined && options.mappings === undefined) fail(ERROR_CODES.INVALID_ARGUMENT, "mode or mappings is required");
|
|
544
|
+
if (options.mode !== undefined && options.mappings !== undefined) fail(ERROR_CODES.INVALID_ARGUMENT, "Configure mode and mappings in separate atomic calls");
|
|
545
|
+
if (options.mode !== undefined && !["advisory", "off"].includes(options.mode)) fail(ERROR_CODES.INVALID_ARGUMENT, "mode must be advisory or off");
|
|
546
|
+
if (options.mappings !== undefined && !validateCapabilityMappings(options.mappings)) fail(ERROR_CODES.INVALID_ARGUMENT, `mappings may contain only ${CAPABILITY_DEPTHS.join(", ")} with bounded non-empty string values`);
|
|
547
|
+
return withLock(this.storage.lockPath("capability-profiles"), () => {
|
|
548
|
+
this.storage.assertNoSymlinks();
|
|
549
|
+
const changed = [];
|
|
550
|
+
const configFile = path.join(this.storage.projectRoot, ".work-context", "config.yaml");
|
|
551
|
+
const mappingFile = path.join(this.storage.personalRoot, CAPABILITY_MAPPINGS_FILE);
|
|
552
|
+
const previousConfig = fs.readFileSync(configFile);
|
|
553
|
+
let previousMapping = null;
|
|
554
|
+
if (fs.existsSync(mappingFile)) {
|
|
555
|
+
if (!fs.lstatSync(mappingFile).isFile()) fail(ERROR_CODES.STORAGE_ERROR, `Invalid ${CAPABILITY_MAPPINGS_FILE} path`);
|
|
556
|
+
previousMapping = fs.readFileSync(mappingFile);
|
|
557
|
+
}
|
|
558
|
+
try {
|
|
559
|
+
if (options.mode !== undefined && options.mode !== capabilityProfileMode(this.storage)) {
|
|
560
|
+
const current = fs.readFileSync(configFile, "utf8");
|
|
561
|
+
const section = `capability_profiles:\n mode: ${options.mode}\n`;
|
|
562
|
+
const next = /^capability_profiles:\n(?: .*\n)*/m.test(current)
|
|
563
|
+
? current.replace(/^capability_profiles:\n(?: .*\n)*/m, section)
|
|
564
|
+
: `${current.trimEnd()}\n${section}`;
|
|
565
|
+
atomicWrite(configFile, next);
|
|
566
|
+
changed.push(configFile);
|
|
567
|
+
}
|
|
568
|
+
if (options.mappings !== undefined) {
|
|
569
|
+
atomicWrite(mappingFile, `${JSON.stringify({ schema: 1, mappings: options.mappings }, null, 2)}\n`);
|
|
570
|
+
changed.push(mappingFile);
|
|
571
|
+
}
|
|
572
|
+
} catch (error) {
|
|
573
|
+
try { atomicWrite(configFile, previousConfig.toString("utf8")); } catch {}
|
|
574
|
+
try {
|
|
575
|
+
if (previousMapping) atomicWrite(mappingFile, previousMapping.toString("utf8"));
|
|
576
|
+
else fs.rmSync(mappingFile, { force: true });
|
|
577
|
+
} catch {}
|
|
578
|
+
throw error;
|
|
579
|
+
}
|
|
580
|
+
if (options.mode !== undefined) this.storage.config.capability_profiles.mode = options.mode;
|
|
581
|
+
const local = readCapabilityMappings(this.storage);
|
|
582
|
+
return this.result({ mode: capabilityProfileMode(this.storage), mappings: local.mappings, warnings: local.warnings }, changed);
|
|
583
|
+
}, { owner: actor(this.options), session: this.options.sessionId || null });
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
resetCapabilityProfiles(confirmation) {
|
|
587
|
+
if (confirmation !== "RESET_PROFILES") fail(ERROR_CODES.CONFIRMATION_REQUIRED, "Reset requires RESET_PROFILES confirmation");
|
|
588
|
+
return this.transact("capability-profiles", () => {
|
|
589
|
+
const file = path.join(this.storage.personalRoot, CAPABILITY_MAPPINGS_FILE);
|
|
590
|
+
const existed = fs.existsSync(file);
|
|
591
|
+
if (existed) fs.rmSync(file);
|
|
592
|
+
return this.result({ mode: capabilityProfileMode(this.storage), mappings: {} }, existed ? [file] : []);
|
|
446
593
|
});
|
|
447
594
|
}
|
|
448
595
|
|
|
@@ -824,8 +971,8 @@ export class WorkContext {
|
|
|
824
971
|
help(command = "") {
|
|
825
972
|
return this.result({
|
|
826
973
|
command,
|
|
827
|
-
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|delivery read|delivery mark|workspace finish|workspace reopen|resume|stage add|stage reopen|stage restore|stage rename|stage update|stage update-prompt|stage update-result|stage execution read|stage execution replace|stage execution update|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]",
|
|
828
|
-
note: "
|
|
974
|
+
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|delivery read|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 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]",
|
|
975
|
+
note: "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.",
|
|
829
976
|
}, []);
|
|
830
977
|
}
|
|
831
978
|
|
package/src/index.js
CHANGED
package/src/stages-renderer.js
CHANGED
|
@@ -26,6 +26,28 @@ const deliverySummary = (delivery) => {
|
|
|
26
26
|
const pending = delivery.environments.reduce((total, environment) => total + environment.pending, 0);
|
|
27
27
|
return `Delivery · ${delivery.environments.length} environments · ${pending} tracked pending`;
|
|
28
28
|
};
|
|
29
|
+
const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
|
|
30
|
+
export const formatStageIds = (ids = []) => {
|
|
31
|
+
const ranges = [];
|
|
32
|
+
let run = [];
|
|
33
|
+
const flush = () => {
|
|
34
|
+
if (!run.length) return;
|
|
35
|
+
ranges.push(run.length >= 3 ? `${run[0]}—${run.at(-1)}` : run.join(", "));
|
|
36
|
+
run = [];
|
|
37
|
+
};
|
|
38
|
+
for (const id of ids) {
|
|
39
|
+
const previous = run.at(-1);
|
|
40
|
+
if (previous && Number(id) !== Number(previous) + 1) flush();
|
|
41
|
+
run.push(id);
|
|
42
|
+
}
|
|
43
|
+
flush();
|
|
44
|
+
return ranges.join(", ");
|
|
45
|
+
};
|
|
46
|
+
const profileSummary = (stage) => {
|
|
47
|
+
return stage.execution_profile && stage.execution_depth && stage.recommended_model
|
|
48
|
+
? `${capitalize(stage.execution_profile)} · ${capitalize(stage.execution_depth)} · ${capitalize(stage.recommended_model)}`
|
|
49
|
+
: null;
|
|
50
|
+
};
|
|
29
51
|
|
|
30
52
|
/**
|
|
31
53
|
* Render normalized stages as a dependency-to-dependent forest. A stage may
|
|
@@ -84,7 +106,8 @@ export function renderStagesPanel(result) {
|
|
|
84
106
|
lines.push("", `Stages · ${snapshot.workspace.status}`);
|
|
85
107
|
for (const stage of snapshot.stages) {
|
|
86
108
|
const pending = candidateSummary(stage);
|
|
87
|
-
|
|
109
|
+
const profiles = profileSummary(stage);
|
|
110
|
+
lines.push(`${statusMarker(stage.status)} ${stage.id}. ${stage.title}${profiles ? `\n${profiles}` : ""}${stage.depends_on?.length ? `\nDeps: ${formatStageIds(stage.depends_on)}` : ""}${pending ? `\n${pending}` : ""}`);
|
|
88
111
|
}
|
|
89
112
|
if (result.stale) lines.push(`! stale: ${result.error?.code || "STORAGE_ERROR"}`);
|
|
90
113
|
return lines.join("\n");
|
package/src/stages-snapshot.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WorkContext } from "./core.js";
|
|
2
|
+
import { capabilityProfileMode, readCapabilityMappings, stageCapabilityProfiles } from "./capability-profiles.js";
|
|
2
3
|
|
|
3
4
|
const emptySnapshot = () => ({
|
|
4
5
|
schema: 1,
|
|
@@ -44,6 +45,7 @@ export function readStagesSnapshot({ projectRoot, sessionId }) {
|
|
|
44
45
|
.filter((stage) => stage.status !== "archived")
|
|
45
46
|
.sort((left, right) => Number(left.stage) - Number(right.stage));
|
|
46
47
|
const visibleStageIds = new Set(visibleStages.map((stage) => stage.stage));
|
|
48
|
+
const capabilityMappings = capabilityProfileMode(context.storage) === "advisory" ? readCapabilityMappings(context.storage) : null;
|
|
47
49
|
const stages = visibleStages
|
|
48
50
|
.map((stage) => ({
|
|
49
51
|
id: stage.stage,
|
|
@@ -52,6 +54,7 @@ export function readStagesSnapshot({ projectRoot, sessionId }) {
|
|
|
52
54
|
description: stage.description,
|
|
53
55
|
depends_on: stage.depends_on.filter((dependency) => visibleStageIds.has(dependency)),
|
|
54
56
|
tracker_links: stage.tracker_links || [],
|
|
57
|
+
...stageCapabilityProfiles(context.storage, stage, capabilityMappings),
|
|
55
58
|
...(candidateProjection?.by_stage[stage.stage] ? { candidates: candidateProjection.by_stage[stage.stage] } : {}),
|
|
56
59
|
current: stage.stage === session.stage,
|
|
57
60
|
}));
|
package/src/storage.js
CHANGED
|
@@ -4,6 +4,7 @@ import { randomUUID } from "node:crypto";
|
|
|
4
4
|
import { WorkContextError, ERROR_CODES, fail } from "./errors.js";
|
|
5
5
|
import { parseFrontmatter, renderMarkdown } from "./markdown.js";
|
|
6
6
|
import { validateExecutionRecord } from "./stage-execution.js";
|
|
7
|
+
import { CAPABILITY_CLASSIFICATIONS, CAPABILITY_DEPTHS, CAPABILITY_PROFILES } from "./capability-profiles.js";
|
|
7
8
|
|
|
8
9
|
const now = () => new Date().toISOString();
|
|
9
10
|
const ensure = (dir) => fs.mkdirSync(dir, { recursive: true });
|
|
@@ -89,7 +90,7 @@ const validateEventStream = (events) => {
|
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
92
|
function validateMetadata(data, kind, workspace, stage = null) {
|
|
92
|
-
const allowed = kind === "workspace" ? ["schema", "workspace", "title", "status", "mode", "created_at", "updated_at", "tracker_links", "reopen_history"] : ["schema", "workspace", "stage", "title", "status", "goal", "prompt", "depends_on", "owner", "created_at", "updated_at", "tracker_links", "reopen_history", "archive_history"];
|
|
93
|
+
const allowed = kind === "workspace" ? ["schema", "workspace", "title", "status", "mode", "created_at", "updated_at", "tracker_links", "reopen_history"] : ["schema", "workspace", "stage", "title", "status", "goal", "prompt", "depends_on", "owner", "execution_profile", "execution_depth", "execution_classification", "review_profile", "created_at", "updated_at", "tracker_links", "reopen_history", "archive_history"];
|
|
93
94
|
if (Object.keys(data).some((key) => !allowed.includes(key)) || data.schema !== 1 || !requiredString(data, "workspace") || !/^\d{6}$/.test(data.workspace) || data.workspace !== workspace) fail(ERROR_CODES.STORAGE_ERROR, `Invalid ${kind} metadata`);
|
|
94
95
|
if (!requiredString(data, "title") || !validTimestamp(data.created_at) || !validTimestamp(data.updated_at) || Date.parse(data.updated_at) < Date.parse(data.created_at) || !Array.isArray(data.tracker_links)) fail(ERROR_CODES.STORAGE_ERROR, `Invalid ${kind} metadata`);
|
|
95
96
|
if (!validTrackerLinks(data.tracker_links) || data.tracker_links.some((link) => !link.provider.trim() || !link.project.trim() || ((link.provider === "gitlab" || link.provider === "github") ? (!Number.isInteger(link.iid) || link.iid < 1) : !link.key?.trim()))) fail(ERROR_CODES.STORAGE_ERROR, `Invalid ${kind} tracker links`);
|
|
@@ -103,6 +104,13 @@ function validateMetadata(data, kind, workspace, stage = null) {
|
|
|
103
104
|
|| data.depends_on.includes(data.stage) || data.depends_on.some((item) => typeof item !== "string" || !/^\d{2}$/.test(item))
|
|
104
105
|
|| (data.reopen_history !== undefined && !validReopenHistory(data.reopen_history))
|
|
105
106
|
|| (data.archive_history !== undefined && !validArchiveHistory(data.archive_history))
|
|
107
|
+
|| (data.execution_profile !== undefined && !CAPABILITY_PROFILES.includes(data.execution_profile))
|
|
108
|
+
|| (data.execution_depth !== undefined && !CAPABILITY_DEPTHS.includes(data.execution_depth))
|
|
109
|
+
|| (data.execution_classification !== undefined && !CAPABILITY_CLASSIFICATIONS.includes(data.execution_classification))
|
|
110
|
+
|| (data.review_profile !== undefined && !CAPABILITY_PROFILES.includes(data.review_profile))
|
|
111
|
+
|| (data.execution_depth !== undefined && data.execution_profile === undefined)
|
|
112
|
+
|| (data.execution_classification !== undefined && (data.execution_profile === undefined || data.execution_depth === undefined))
|
|
113
|
+
|| (data.execution_profile !== undefined && data.execution_depth !== undefined && data.execution_classification === undefined)
|
|
106
114
|
);
|
|
107
115
|
if (invalidWorkspaceHistory || invalidStageMetadata) fail(ERROR_CODES.STORAGE_ERROR, `Invalid ${kind} metadata`);
|
|
108
116
|
}
|
|
@@ -134,7 +142,7 @@ export class FileStorage {
|
|
|
134
142
|
constructor(projectRoot, config = {}) {
|
|
135
143
|
this.projectRoot = projectRoot;
|
|
136
144
|
const storage = config.storage || {};
|
|
137
|
-
this.config = { mode: "hybrid", root: ".work-context", personal_root: ".work-context/local", title: { issue_prefix: "short" }, tracker: { provider: null }, ...config, ...storage, title: { issue_prefix: "short", ...(config.title || {}) }, tracker: { provider: null, ...(config.tracker || {}) } };
|
|
145
|
+
this.config = { mode: "hybrid", root: ".work-context", personal_root: ".work-context/local", title: { issue_prefix: "short" }, tracker: { provider: null }, capability_profiles: { mode: "advisory" }, ...config, ...storage, title: { issue_prefix: "short", ...(config.title || {}) }, tracker: { provider: null, ...(config.tracker || {}) }, capability_profiles: { mode: "advisory", ...(config.capability_profiles || {}) } };
|
|
138
146
|
this.root = path.resolve(projectRoot, this.config.root);
|
|
139
147
|
this.personalRoot = path.resolve(projectRoot, this.config.personal_root);
|
|
140
148
|
const project = path.resolve(projectRoot);
|
|
@@ -302,7 +310,7 @@ export class FileStorage {
|
|
|
302
310
|
|
|
303
311
|
export function loadConfig(projectRoot, configFile = path.resolve(projectRoot, ".work-context", "config.yaml")) {
|
|
304
312
|
if (!fs.existsSync(configFile)) return {};
|
|
305
|
-
const data = Object.assign(Object.create(null), { storage: Object.create(null), title: Object.create(null), tracker: Object.create(null), notifications: Object.create(null) });
|
|
313
|
+
const data = Object.assign(Object.create(null), { storage: Object.create(null), title: Object.create(null), tracker: Object.create(null), notifications: Object.create(null), capability_profiles: Object.create(null) });
|
|
306
314
|
let section = null;
|
|
307
315
|
for (const line of fs.readFileSync(configFile, "utf8").split("\n")) {
|
|
308
316
|
if (!line.trim() || line.trim().startsWith("#")) continue;
|
|
@@ -310,7 +318,8 @@ export function loadConfig(projectRoot, configFile = path.resolve(projectRoot, "
|
|
|
310
318
|
if (!match[1]) { section = match[3] ? null : match[2]; if (match[3]) data[match[2]] = scalarConfig(match[3]); else if (!data[match[2]] || typeof data[match[2]] !== "object") data[match[2]] = Object.create(null); continue; }
|
|
311
319
|
if (section && data[section] && typeof data[section] === "object") data[section][match[2]] = scalarConfig(match[3]);
|
|
312
320
|
}
|
|
313
|
-
if (Object.keys(data).some((key) => !["schema", "storage", "title", "tracker", "notifications"].includes(key)) || Object.keys(data.storage).some((key) => !["mode", "root", "personal_root"].includes(key)) || Object.keys(data.title).some((key) => key !== "issue_prefix") || Object.keys(data.tracker).some((key) => key !== "provider") || !data.notifications || typeof data.notifications !== "object" || Array.isArray(data.notifications) || Object.keys(data.notifications).some((key) => key !== "desktop") || data.schema !== 1 || !data.storage || !["personal", "shared-git", "hybrid"].includes(data.storage.mode) || typeof data.storage.root !== "string" || typeof data.storage.personal_root !== "string" || !data.title || !["none", "short", "full"].includes(data.title.issue_prefix) || !data.tracker || (data.tracker.provider !== null && typeof data.tracker.provider !== "string") || (data.notifications.desktop !== undefined && typeof data.notifications.desktop !== "boolean")) fail(ERROR_CODES.STORAGE_ERROR, "Invalid work-context config");
|
|
321
|
+
if (Object.keys(data).some((key) => !["schema", "storage", "title", "tracker", "notifications", "capability_profiles"].includes(key)) || Object.keys(data.storage).some((key) => !["mode", "root", "personal_root"].includes(key)) || Object.keys(data.title).some((key) => key !== "issue_prefix") || Object.keys(data.tracker).some((key) => key !== "provider") || !data.notifications || typeof data.notifications !== "object" || Array.isArray(data.notifications) || Object.keys(data.notifications).some((key) => key !== "desktop") || !data.capability_profiles || typeof data.capability_profiles !== "object" || Array.isArray(data.capability_profiles) || Object.keys(data.capability_profiles).some((key) => key !== "mode") || (data.capability_profiles.mode !== undefined && !["advisory", "off"].includes(data.capability_profiles.mode)) || data.schema !== 1 || !data.storage || !["personal", "shared-git", "hybrid"].includes(data.storage.mode) || typeof data.storage.root !== "string" || typeof data.storage.personal_root !== "string" || !data.title || !["none", "short", "full"].includes(data.title.issue_prefix) || !data.tracker || (data.tracker.provider !== null && typeof data.tracker.provider !== "string") || (data.notifications.desktop !== undefined && typeof data.notifications.desktop !== "boolean")) fail(ERROR_CODES.STORAGE_ERROR, "Invalid work-context config");
|
|
322
|
+
data.capability_profiles.mode ||= "advisory";
|
|
314
323
|
return data;
|
|
315
324
|
}
|
|
316
325
|
const scalarConfig = (value) => value === "null" ? null : value === "[]" ? [] : value === "{}" ? {} : /^(true|false)$/.test(value) ? value === "true" : /^-?\d+(\.\d+)?$/.test(value) ? Number(value) : value;
|
package/src/tool-definitions.js
CHANGED
|
@@ -19,6 +19,8 @@ const run = (fn) => async (args, context) => {
|
|
|
19
19
|
};
|
|
20
20
|
const common = { workspace: tool.schema.string(), stage: tool.schema.string() };
|
|
21
21
|
const contextualStage = { workspace: tool.schema.string().optional(), stage: tool.schema.string().optional() };
|
|
22
|
+
const capabilityProfile = tool.schema.enum(["routine", "implementation", "architecture", "security", "review"]);
|
|
23
|
+
const capabilityDepth = tool.schema.enum(["light", "standard", "deep"]);
|
|
22
24
|
const executionSections = {
|
|
23
25
|
scope: tool.schema.array(tool.schema.string()).optional(),
|
|
24
26
|
completed: tool.schema.array(tool.schema.string()).optional(),
|
|
@@ -48,7 +50,7 @@ const sessionFor = (ctx, oc, workspace, stage) => ctx.sessionById(oc.sessionID)?
|
|
|
48
50
|
const addStageFromTool = (ctx, args, oc) => {
|
|
49
51
|
const currentSession = sessionFromContext(ctx);
|
|
50
52
|
const workspace = workspaceFromSession(ctx, args.workspace);
|
|
51
|
-
const created = ctx.addStage(workspace, args.title, { goal: args.goal, prompt: args.prompt, dependsOn: args.dependsOn });
|
|
53
|
+
const created = ctx.addStage(workspace, args.title, { goal: args.goal, prompt: args.prompt, dependsOn: args.dependsOn, executionProfile: args.executionProfile, executionDepth: args.executionDepth, classification: args.classification, reviewProfile: args.reviewProfile });
|
|
52
54
|
if (currentSession) return created;
|
|
53
55
|
|
|
54
56
|
const started = ctx.startSession(workspace, created.data.stage, {
|
|
@@ -82,7 +84,12 @@ export const work_context_create_workspace = tool({ description: "Create a works
|
|
|
82
84
|
return ctx.createWorkspace(a.title, { sessionId: randomUUID(), mode: a.mode, ...(currentSession ? {} : { opencodeSessionId: oc.sessionID }) });
|
|
83
85
|
}) });
|
|
84
86
|
export const work_context_start_session = tool({ description: "Start a new active session for a stage and return its human-oriented presentation, prompt, active workspace knowledge, and startup policy when applicable.", args: { ...common, summary: tool.schema.string().optional() }, execute: run((ctx, a, oc) => ctx.startSession(a.workspace, a.stage, { sessionId: randomUUID(), opencodeSessionId: oc.sessionID, summary: a.summary, takeover: true })) });
|
|
85
|
-
export const work_context_add_stage = tool({ description: "Add a stage
|
|
87
|
+
export const work_context_add_stage = tool({ description: "Add a stage with an optional execution capability and depth. When the user did not specify them, infer both from the prompt and pass classification: inferred. Explicit user choices use classification: explicit.", args: { workspace: tool.schema.string().optional(), title: tool.schema.string(), goal: tool.schema.string().optional(), prompt: tool.schema.string().optional(), dependsOn: tool.schema.array(tool.schema.string()).optional(), executionProfile: capabilityProfile.optional(), executionDepth: capabilityDepth.optional(), classification: tool.schema.enum(["inferred", "explicit"]).optional(), reviewProfile: capabilityProfile.optional() }, execute: run(addStageFromTool) });
|
|
88
|
+
export const work_context_set_stage_profiles = tool({ description: "Explicitly set or clear a stage execution capability and depth. Omitted fields are unchanged; pass null for both execution fields to clear them. Review profile remains optional metadata.", args: { ...contextualStage, executionProfile: capabilityProfile.nullable().optional(), executionDepth: capabilityDepth.nullable().optional(), reviewProfile: capabilityProfile.nullable().optional() }, execute: run((ctx, a) => { const workspace = workspaceFromSession(ctx, a.workspace); return ctx.setStageProfiles(workspace, stageFromSession(ctx, workspace, a.stage), { ...(Object.hasOwn(a, "executionProfile") ? { executionProfile: a.executionProfile } : {}), ...(Object.hasOwn(a, "executionDepth") ? { executionDepth: a.executionDepth } : {}), ...(Object.hasOwn(a, "reviewProfile") ? { reviewProfile: a.reviewProfile } : {}) }); }) });
|
|
89
|
+
export const work_context_refresh_stage_profiles = tool({ description: "Atomically apply agent-inferred execution capability and depth recommendations. Ordinary refresh preserves explicit classifications; includeExplicit permits an explicitly requested override.", args: { workspace: tool.schema.string(), recommendations: tool.schema.array(tool.schema.object({ stage: tool.schema.string(), executionProfile: capabilityProfile, executionDepth: capabilityDepth })), includeExplicit: tool.schema.boolean().optional() }, execute: run((ctx, a) => ctx.refreshStageProfiles(a.workspace, a.recommendations, { includeExplicit: a.includeExplicit })) });
|
|
90
|
+
export const work_context_show_capability_profiles = tool({ description: "Show capability recommendation mode and validated user-local depth mappings.", args: {}, execute: run((ctx) => ctx.showCapabilityProfiles()) });
|
|
91
|
+
export const work_context_configure_capability_profiles = tool({ description: "Atomically configure either capability recommendation mode or user-local light, standard, and deep model labels. Interactive setup calls it separately for mode and mappings after gathering preferences.", args: { mode: tool.schema.enum(["advisory", "off"]).optional(), mappings: tool.schema.object({ light: tool.schema.string().optional(), standard: tool.schema.string().optional(), deep: tool.schema.string().optional() }).strict().optional() }, execute: run((ctx, a) => ctx.configureCapabilityProfiles(a)) });
|
|
92
|
+
export const work_context_reset_capability_profiles = tool({ description: "Remove all user-local model mappings after explicit RESET_PROFILES confirmation. Stage classifications and project mode remain unchanged.", args: { confirmation: tool.schema.string() }, execute: run((ctx, a) => ctx.resetCapabilityProfiles(a.confirmation)) });
|
|
86
93
|
export const work_context_rename_stage = tool({ description: "Rename a stage while preserving its ID and history; workspace and stage can be omitted in the current OpenCode session.", args: { ...contextualStage, title: tool.schema.string() }, execute: run((ctx, a) => { const workspace = workspaceFromSession(ctx, a.workspace); return ctx.renameStage(workspace, stageFromSession(ctx, workspace, a.stage), a.title); }) });
|
|
87
94
|
export const work_context_update_stage = tool({ description: "Update an existing stage description; workspace and stage can be omitted in the current OpenCode session.", args: { ...contextualStage, description: tool.schema.string() }, execute: run((ctx, a) => { const workspace = workspaceFromSession(ctx, a.workspace); return ctx.updateStage(workspace, stageFromSession(ctx, workspace, a.stage), a.description); }) });
|
|
88
95
|
export const work_context_update_stage_prompt = tool({ description: "Update the optional working prompt of an existing stage; workspace and stage can be omitted in the current OpenCode session.", args: { ...contextualStage, prompt: tool.schema.string() }, execute: run((ctx, a) => { const workspace = workspaceFromSession(ctx, a.workspace); return ctx.updateStagePrompt(workspace, stageFromSession(ctx, workspace, a.stage), a.prompt); }) });
|
|
@@ -107,4 +114,4 @@ export const work_context_add_knowledge = tool({ description: "Add a durable kno
|
|
|
107
114
|
export const work_context_update_knowledge = tool({ description: "Update a durable knowledge entry.", args: { workspace: tool.schema.string(), knowledgeId: tool.schema.string(), title: tool.schema.string().optional(), kind: tool.schema.string().optional(), status: tool.schema.string().optional(), text: tool.schema.string().optional(), sources: tool.schema.array(tool.schema.string()).optional(), replacement: tool.schema.string().optional() }, execute: run((ctx, a) => ctx.updateKnowledge(a.workspace, a.knowledgeId, a)) });
|
|
108
115
|
export const work_context_supersede_knowledge = tool({ description: "Supersede a durable knowledge entry.", args: { workspace: tool.schema.string(), knowledgeId: tool.schema.string(), replacement: tool.schema.string() }, execute: run((ctx, a) => ctx.supersedeKnowledge(a.workspace, a.knowledgeId, a.replacement) ) });
|
|
109
116
|
|
|
110
|
-
export default { work_context_list_workspaces, work_context_workspace_list, work_context_rename_workspace, work_context_set_workspace_mode, work_context_create_candidate, work_context_capture_candidate, work_context_preview_candidate, work_context_show_candidate, work_context_list_candidates, work_context_ready_candidate, work_context_commit_candidate, work_context_discard_candidate, work_context_read_delivery, work_context_mark_delivery, work_context_workspace_finish, work_context_reopen_workspace, work_context_create_workspace, work_context_start_session, work_context_add_stage, work_context_rename_stage, work_context_update_stage, work_context_update_stage_prompt, work_context_update_stage_result, work_context_read_stage_execution, work_context_replace_stage_execution, work_context_update_stage_execution, work_context_archive_stage, work_context_reopen_stage, work_context_restore_stage, work_context_link_issue, work_context_unlink_issue, work_context_rename_session, work_context_close_session, work_context_force_close_session, work_context_handoff_stage, work_context_abandon_stage, work_context_finish_stage, work_context_help, work_context_list_knowledge, work_context_add_knowledge, work_context_update_knowledge, work_context_supersede_knowledge };
|
|
117
|
+
export default { work_context_list_workspaces, work_context_workspace_list, work_context_rename_workspace, work_context_set_workspace_mode, work_context_create_candidate, work_context_capture_candidate, work_context_preview_candidate, work_context_show_candidate, work_context_list_candidates, work_context_ready_candidate, work_context_commit_candidate, work_context_discard_candidate, work_context_read_delivery, work_context_mark_delivery, work_context_workspace_finish, work_context_reopen_workspace, work_context_create_workspace, work_context_start_session, work_context_add_stage, work_context_set_stage_profiles, work_context_refresh_stage_profiles, work_context_show_capability_profiles, work_context_configure_capability_profiles, work_context_reset_capability_profiles, work_context_rename_stage, work_context_update_stage, work_context_update_stage_prompt, work_context_update_stage_result, work_context_read_stage_execution, work_context_replace_stage_execution, work_context_update_stage_execution, work_context_archive_stage, work_context_reopen_stage, work_context_restore_stage, work_context_link_issue, work_context_unlink_issue, work_context_rename_session, work_context_close_session, work_context_force_close_session, work_context_handoff_stage, work_context_abandon_stage, work_context_finish_stage, work_context_help, work_context_list_knowledge, work_context_add_knowledge, work_context_update_knowledge, work_context_supersede_knowledge };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { WorkContext } from "./core.js";
|
|
2
|
+
import { capabilityProfileMode, readCapabilityMappings, stageCapabilityProfiles } from "./capability-profiles.js";
|
|
2
3
|
|
|
3
4
|
const emptySnapshot = () => ({
|
|
4
5
|
schema: 1,
|
|
@@ -24,7 +25,7 @@ const sessionFor = (context, sessionId) => {
|
|
|
24
25
|
|| context.sessionByOpenCodeId(sessionId, null, null, null);
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
const readWorkspace = (context, record, currentSession) => {
|
|
28
|
+
const readWorkspace = (context, record, currentSession, capabilityMappings) => {
|
|
28
29
|
const listed = context.listStages(record.workspace).data;
|
|
29
30
|
const sessions = listed.sessions;
|
|
30
31
|
const matchingSession = currentSession?.workspace === record.workspace
|
|
@@ -56,6 +57,7 @@ const readWorkspace = (context, record, currentSession) => {
|
|
|
56
57
|
description: stage.description,
|
|
57
58
|
depends_on: stage.depends_on.filter((dependency) => visibleStageIds.has(dependency)),
|
|
58
59
|
tracker_links: stage.tracker_links || [],
|
|
60
|
+
...stageCapabilityProfiles(context.storage, stage, capabilityMappings),
|
|
59
61
|
...(candidateProjection?.by_stage[stage.stage] ? { candidates: candidateProjection.by_stage[stage.stage] } : {}),
|
|
60
62
|
current: stage.stage === currentStage,
|
|
61
63
|
})),
|
|
@@ -70,9 +72,10 @@ export function readWorkContextSnapshot({ projectRoot, sessionId } = {}) {
|
|
|
70
72
|
try {
|
|
71
73
|
const context = WorkContext.openExisting(projectRoot, { sessionId, actor: "OpenCode TUI" });
|
|
72
74
|
const currentSession = sessionFor(context, sessionId);
|
|
75
|
+
const capabilityMappings = capabilityProfileMode(context.storage) === "advisory" ? readCapabilityMappings(context.storage) : null;
|
|
73
76
|
const workspaces = context.listWorkspaces().data
|
|
74
77
|
.sort((left, right) => left.workspace.localeCompare(right.workspace))
|
|
75
|
-
.map((record) => readWorkspace(context, record, currentSession));
|
|
78
|
+
.map((record) => readWorkspace(context, record, currentSession, capabilityMappings));
|
|
76
79
|
const currentWorkspace = currentSession?.workspace
|
|
77
80
|
&& workspaces.some((workspace) => workspace.id === currentSession.workspace)
|
|
78
81
|
? currentSession.workspace
|