opencode-work-context 0.11.0 → 0.11.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 +4 -2
- 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/stages-renderer.js +2 -2
package/README.md
CHANGED
|
@@ -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/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/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
|
|