opencode-work-context 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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,
@@ -472,6 +525,8 @@ workspace, every resume also supplies the agent with the startup policy:
472
525
  - a shared dirty worktree and concurrent stages are expected;
473
526
  - stages do not own files or commits;
474
527
  - ready work is captured promptly as an explicit commit candidate;
528
+ - once a coherent commit intent exists, its draft candidate is created or
529
+ refreshed before switching stages or handing off;
475
530
  - exact, shared-foundation, and integration candidates express the intended
476
531
  commit boundary without claiming stage ownership;
477
532
  - mixed-stage provenance and complete files containing unrelated stage work are
@@ -515,10 +570,21 @@ records without strategy or stage-reference metadata remain readable; new
515
570
  candidates default to `exact` with no related stages.
516
571
 
517
572
  The sidebar reads only candidate metadata and shows a compact
518
- `Candidates · pending <count> · ready <count>` line when either count is nonzero.
519
- It does not inspect Git state, patches, paths, or candidate freshness. A `ready`
520
- label therefore means lifecycle status, not a guarantee that a later publication
521
- cannot encounter a conflict.
573
+ `Candidates · <count> draft · <count> ready` line when either count is nonzero.
574
+ With sidebar details enabled (`Ctrl+X D`), a stage with explicitly related active
575
+ candidates also shows `Pending:` metadata. One related candidate includes its
576
+ lifecycle status, strategy, and other related stage IDs; several candidates are
577
+ shown as draft and ready counts. Resume exposes the same bounded metadata in
578
+ `resume.context.pending_candidates`, so an agent can continue an existing commit
579
+ intent instead of creating a duplicate. These projections do not assign
580
+ ownership. They never inspect Git state, patches, selected paths, or candidate
581
+ freshness. A `ready` label therefore means lifecycle status, not a guarantee that
582
+ a later publication cannot encounter a conflict, and uncaptured worktree changes
583
+ remain outside this projection. Per-stage projection counts remain complete, but
584
+ resume and snapshot item details are bounded to 10 candidates with titles limited
585
+ to 120 characters. Malformed local candidate records remain strict errors for
586
+ candidate operations but are omitted from best-effort sidebar and resume
587
+ projections so they cannot block unrelated stage work.
522
588
 
523
589
  Capture accepts either complete repository paths or one exact Git unified patch,
524
590
  which permits selecting individual hunks. Candidate metadata and patches are
@@ -542,6 +608,67 @@ separate those edits by provenance. Use an integration candidate only when the
542
608
  combined patch is coherent and verified; otherwise stop and establish a safe
543
609
  candidate boundary before publication.
544
610
 
611
+ ### Delivery context
612
+
613
+ Committing or pushing does not prove that an environment was updated. Delivery is
614
+ a workspace-level concern that may aggregate committed candidates related to many
615
+ stages. Planning-stage resume receives a bounded `delivery_context` when committed
616
+ candidates or environment checkpoints exist. The sidebar renders metadata only:
617
+
618
+ ```text
619
+ Delivery · 4 commits · plan needed
620
+ Delivery · production · 2 tracked pending
621
+ Delivery · production · 0 tracked pending
622
+ ```
623
+
624
+ `tracked pending` compares committed candidate metadata with the recorded local
625
+ checkpoint; it is not a live Git reachability claim. A reset, rebase, force-push,
626
+ or external deployment change requires an explicit range inspection before acting.
627
+ Malformed or inconsistent checkpoint metadata renders `Delivery · unavailable`
628
+ instead of claiming a clean delivery state.
629
+
630
+ When asked how to deploy, the Planning agent must inspect the exact commit range
631
+ and the repository's own deployment documentation, scripts, infrastructure,
632
+ migrations, container definitions, configuration examples, and CI. It then
633
+ produces an ordered plan with prerequisites, deployment, verification, rollback,
634
+ and unresolved blockers. The package does not encode stack-specific commands and
635
+ does not assume that a push or one release command is sufficient.
636
+
637
+ Delivery state is local and mode-neutral under
638
+ `.work-context/local/delivery/<workspace>.json`. It stores only environment names,
639
+ confirmed commit hashes, timestamps, and committed candidate ID/hash pairs.
640
+ It never stores deployment commands, command output, hostnames, URLs, credentials,
641
+ tokens, or secret values. Secret and configuration requirements may be discussed
642
+ by name only. Each checkpoint carries an integrity checksum; malformed or edited
643
+ checkpoint data fails closed as unavailable.
644
+
645
+ Read metadata without inspecting Git:
646
+
647
+ ```text
648
+ /wc delivery read 000123 production
649
+ ```
650
+
651
+ Inspect one explicit immutable range:
652
+
653
+ ```text
654
+ /wc delivery read 000123 production range <from-commit> <to-commit>
655
+ ```
656
+
657
+ The range result is bounded to 500 commits and 500 changed paths and is returned
658
+ only to the explicit operation; changed-path output also has a 4 MiB subprocess
659
+ limit and fails with `DELIVERY_RANGE_TOO_LARGE` instead of consuming unbounded
660
+ memory. Snapshots and sidebar renderers never invoke Git.
661
+ After the user confirms that the target environment was updated successfully,
662
+ record the checkpoint explicitly:
663
+
664
+ ```text
665
+ /wc delivery mark 000123 production <deployed-commit> DELIVERY_CONFIRMED
666
+ ```
667
+
668
+ Marking validates that the commit is reachable from current `HEAD`, records which
669
+ committed candidates are included, and performs no deployment action. Checkpoints
670
+ are per environment, so staging and production can advance independently.
671
+
545
672
  Candidate publication is serialized by the repository-scoped `candidate-git`
546
673
  lock. Any operation that needs both locks acquires `candidate-git` before the
547
674
  work-context `write` lock; integrations must preserve this ordering to avoid
package/commands/wc.md CHANGED
@@ -37,11 +37,18 @@ Use these exact tool mappings; do not invent shortened tool names:
37
37
  - `candidate ready <workspace> <candidateId>` -> `work_context_ready_candidate`
38
38
  - `candidate commit <workspace> <candidateId> ["message"]` -> `work_context_commit_candidate`
39
39
  - `candidate discard <workspace> <candidateId>` -> `work_context_discard_candidate`
40
+ - `delivery read <workspace> [<environment>] [range <from> <to>]` -> `work_context_read_delivery`
41
+ - `delivery mark <workspace> <environment> <commit> DELIVERY_CONFIRMED` -> `work_context_mark_delivery`
40
42
  - `workspace finish <workspace>` -> `work_context_workspace_finish`
41
43
  - `workspace reopen <workspace> "reason"` -> `work_context_reopen_workspace`
42
44
  - `resume <workspace> <stage>` -> `work_context_start_session`
43
45
  - `stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE` -> `work_context_force_close_session`
44
- - `stage add [<workspace>] ...` -> `work_context_add_stage` (optional `prompt`; a detailed local prompt is expected for stages created from planning, while shared context belongs in workspace knowledge)
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`
45
52
  - `stage reopen <workspace> <stage> "reason"` -> `work_context_reopen_stage`
46
53
  - `stage restore <workspace> <stage> "reason"` -> `work_context_restore_stage`
47
54
  - `stage rename [<workspace>] [<stage>] "title"` -> `work_context_rename_stage`
@@ -74,11 +81,18 @@ Supported syntax:
74
81
  - `candidate ready <workspace> <candidateId>`
75
82
  - `candidate commit <workspace> <candidateId> ["message"]`
76
83
  - `candidate discard <workspace> <candidateId>`
84
+ - `delivery read <workspace> [<environment>] [range <from> <to>]`
85
+ - `delivery mark <workspace> <environment> <commit> DELIVERY_CONFIRMED`
77
86
  - `workspace finish <workspace>`
78
87
  - `workspace reopen <workspace> "reason"`
79
88
  - `resume <workspace> <stage>`
80
89
  - `stage force-close <workspace> <stage> <sessionId> "reason" FORCE_CLOSE`
81
- - `stage add [<workspace>] "title" ["prompt"]`
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]`
82
96
  - `stage reopen <workspace> <stage> "reason"`
83
97
  - `stage restore <workspace> <stage> "reason"`
84
98
  - `stage rename [<workspace>] [<stage>] "title"`
@@ -102,6 +116,16 @@ Supported syntax:
102
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
103
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
104
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
105
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
106
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
107
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
@@ -111,7 +135,10 @@ Supported syntax:
111
135
  - do not expose raw workspace/stage/session identifiers, ordinals, `ok` flags, or absent error codes in the user-facing resume summary
112
136
  - `resume.context.workspace_knowledge` contains every active durable knowledge entry for the workspace; treat it as established shared context, and do not repeat earlier analysis unless an entry is incomplete, contradicted, or needs verification
113
137
  - when stage execution state exists, `resume.context.execution_state` is the current stage-local operational checkpoint; continue from it without rewriting the original prompt, and never copy it automatically into workspace knowledge or unrelated stages
114
- - an associated OpenCode session resumed in a `startup` workspace receives `resume.context.workflow_policy`; follow it as active agent policy: a shared dirty worktree and concurrent stages are expected, stages do not own files or commits, and ready work should be captured promptly into an explicit candidate; prefer an `exact` candidate when safely separable, use `shared_foundation` when several stages use one coherent change, and use `integration` when intertwined changes form one reviewable and testable result; mixed provenance and complete files containing unrelated stage work are not reasons to require prior commits or stop; stop only for a concrete patch conflict, an incoherent candidate boundary, or failed required verification
138
+ - Planning-stage resume may include `resume.context.delivery_context`, a bounded workspace-level summary of committed candidates and environment checkpoints; it is release coordination context, not stage ownership
139
+ - when the user asks how to deploy from Planning, inspect the exact commit range and the repository's own deployment documentation, scripts, infrastructure, migrations, container definitions, configuration examples, and CI; produce ordered prerequisites, deployment, verification, rollback, and unresolved blockers instead of assuming that push or one generic command is sufficient
140
+ - delivery planning must never persist secret values; mention only required secret or configuration names, ask one focused question when environment or baseline is ambiguous, and never mark delivery merely because commit, push, or CI succeeded
141
+ - an associated OpenCode session resumed in a `startup` workspace receives `resume.context.workflow_policy`; follow it as active agent policy: a shared dirty worktree and concurrent stages are expected, stages do not own files or commits, and ready work should be captured promptly into an explicit candidate; once a coherent commit intent exists, create or refresh its draft candidate before switching stages or handing off; on resume inspect `resume.context.pending_candidates` before creating a duplicate or another commit boundary; prefer an `exact` candidate when safely separable, use `shared_foundation` when several stages use one coherent change, and use `integration` when intertwined changes form one reviewable and testable result; mixed provenance and complete files containing unrelated stage work are not reasons to require prior commits or stop; stop only for a concrete patch conflict, an incoherent candidate boundary, or failed required verification
115
142
  - standard-mode and unassociated core sessions do not receive startup policy; retain the existing conservative worktree behavior there
116
143
  - after presenting the summary, continue work immediately when `resume.next_action` is `start_work`; do not ask for generic confirmation
117
144
  - a stage may require confirmation only with an exact standalone `RESUME_CONFIRMATION: required` line in its saved prompt; when `resume.next_action` is `await_confirmation`, present the summary and wait before inspecting or modifying application code
@@ -129,7 +156,8 @@ Supported syntax:
129
156
  - `stage reopen <workspace> <stage> "reason"` applies only to a completed stage, preserves its result and completion history, records the reason, changes it to `in_progress`, and does not start a session or affect downstream stages; use an explicit separate-session `resume` to work on it again
130
157
  - `stage restore <workspace> <stage> "reason"` applies only to an archived stage and restores its saved pre-archive status. New archives preserve that status; legacy archives restore to `in_progress`. It records the reason, preserves stage content and results, does not start a session, and requires explicit separate-session `resume` when restored to `planned` or `in_progress`.
131
158
  - `workspace reopen <workspace> "reason"` applies only to a completed workspace, changes it to `in_progress`, and records durable recovery history. Cancelled workspaces cannot be reopened.
132
- - candidate operations require `startup` workflow mode and store metadata and patch payloads only under `.work-context/local/`; create accepts an optional strategy and related stages, which are normalized references for traceability only and never ownership or lifecycle; capture requires exactly one explicit list of complete paths or one Git unified patch and never infers stage ownership; commit requires a ready candidate, uses its stored message unless a non-empty override is supplied, serializes Git publication, bypasses hooks and signing, and never uses the ordinary Git index
159
+ - candidate operations require `startup` workflow mode and store metadata and patch payloads only under `.work-context/local/`; create accepts an optional strategy and related stages, which are normalized references for traceability only and never ownership or lifecycle; active candidates explicitly related to the resumed stage appear as bounded metadata in `resume.context.pending_candidates` and in expanded sidebar details; capture requires exactly one explicit list of complete paths or one Git unified patch and never infers stage ownership; commit requires a ready candidate, uses its stored message unless a non-empty override is supplied, serializes Git publication, bypasses hooks and signing, and never uses the ordinary Git index
160
+ - delivery operations are mode-neutral local operational state and never execute deployment; `delivery read` without a range returns metadata only, exact Git inspection requires both immutable `from` and `to` hashes, and `delivery mark` requires the exact `DELIVERY_CONFIRMED` token only after the user confirms successful delivery to that environment
133
161
  - `knowledge list|add|update|supersede <workspace> ...`
134
162
 
135
163
  Arguments: $ARGUMENTS
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opencode-work-context",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.10.0",
5
5
  "description": "Filesystem work-context core and OpenCode adapter",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -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";
@@ -35,8 +35,29 @@ const trackerLinkText = (link) => {
35
35
  return `JIRA ${identifier}`;
36
36
  };
37
37
  const candidateSummaryText = (workspace) => workspace.candidates && (workspace.candidates.pending || workspace.candidates.ready)
38
- ? `Candidates · pending ${workspace.candidates.pending} · ready ${workspace.candidates.ready}`
38
+ ? `Candidates · ${workspace.candidates.pending} draft · ${workspace.candidates.ready} ready`
39
39
  : null;
40
+ const deliverySummaryText = (workspace) => {
41
+ const delivery = workspace.delivery;
42
+ if (!delivery) return null;
43
+ if (delivery.unavailable) return "Delivery · unavailable";
44
+ if (delivery.plan_needed) return `Delivery · ${delivery.committed} commits · plan needed`;
45
+ if (delivery.environments.length === 1) {
46
+ const [environment] = delivery.environments;
47
+ return `Delivery · ${environment.environment} · ${environment.pending} tracked pending`;
48
+ }
49
+ const pending = delivery.environments.reduce((total, environment) => total + environment.pending, 0);
50
+ return `Delivery · ${delivery.environments.length} environments · ${pending} tracked pending`;
51
+ };
52
+ const stageCandidateText = (stage) => {
53
+ const projection = stage.candidates;
54
+ if (!projection || !(projection.draft || projection.ready)) return null;
55
+ if (projection.draft + projection.ready > 1) return `Pending: ${projection.draft} draft · ${projection.ready} ready`;
56
+ const [candidate] = projection.items;
57
+ const others = candidate.related_stages.filter((related) => related !== stage.id);
58
+ return `Pending: ${candidate.status} · ${candidate.strategy}${others.length ? ` · also ${others.join(", ")}` : ""}`;
59
+ };
60
+ const capitalize = (value) => value ? `${value[0].toUpperCase()}${value.slice(1)}` : value;
40
61
 
41
62
  export { readStagesSnapshot, renderStagesPanel };
42
63
 
@@ -56,6 +77,7 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
56
77
  runtime.jsx("text", { fg: theme?.current?.textMuted, children: `Workflow · ${result.data.workspace.mode || "standard"}` }),
57
78
  workspaceAttention && runtime.jsx("text", { children: ["Attention · ", runtime.jsx("b", { children: workspaceAttention })] }),
58
79
  candidateSummaryText(result.data.workspace) && runtime.jsx("text", { fg: theme?.current?.textMuted, children: candidateSummaryText(result.data.workspace) }),
80
+ deliverySummaryText(result.data.workspace) && runtime.jsx("text", { fg: theme?.current?.textMuted, children: deliverySummaryText(result.data.workspace) }),
59
81
  ].filter(Boolean),
60
82
  }),
61
83
  runtime.jsx("box", {
@@ -65,35 +87,47 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
65
87
  runtime.jsx("text", { fg: theme?.current?.textMuted, children: ` · ${result.data.workspace.status}` }),
66
88
  ],
67
89
  }),
68
- ...result.data.stages.map((stage) => {
90
+ ...result.data.stages.flatMap((stage) => {
69
91
  const unread = attention?.attentionForStage?.(result.data.workspace.id, stage.id);
70
92
  const working = attention?.activityForStage?.(result.data.workspace.id, stage.id);
71
- const metadata = showDependencies ? [
93
+ const recommendation = stage.execution_profile && stage.execution_depth && stage.recommended_model
94
+ ? `${capitalize(stage.execution_profile)} · ${capitalize(stage.execution_depth)} · ${capitalize(stage.recommended_model)}`
95
+ : null;
96
+ const stageMetadata = [
72
97
  stage.tracker_links?.length && `Tasks: ${stage.tracker_links.map(trackerLinkText).join(", ")}`,
73
- stage.depends_on?.length && `Deps: ${stage.depends_on.join(", ")}`,
74
- ].filter(Boolean).join(" · ") : "";
98
+ stage.depends_on?.length && `Deps: ${formatStageIds(stage.depends_on)}`,
99
+ ].filter(Boolean).join(" · ");
100
+ const metadata = showDependencies ? [recommendation, stageMetadata, stageCandidateText(stage)].filter(Boolean).join("\n") : "";
75
101
  const attentionSignal = attentionSummaryText(unread);
76
- const stageText = [
77
- `${stage.id}. ${stage.title}`,
78
- metadata,
79
- ].filter(Boolean).join("\n");
80
- return runtime.jsx("box", {
102
+ const current = stage.current || stage.id === result.data.currentStage;
103
+ const onMouseDown = (event) => {
104
+ if (event?.button != null && event.button !== 0) return;
105
+ return onStageSelect?.(stage);
106
+ };
107
+ const titleRow = runtime.jsx("box", {
81
108
  flexDirection: "row",
82
- onMouseDown: (event) => {
83
- if (event?.button != null && event.button !== 0) return;
84
- return onStageSelect?.(stage);
85
- },
109
+ onMouseDown,
86
110
  children: [
87
111
  runtime.jsx("text", {
88
112
  flexShrink: 0,
89
113
  marginRight: 1,
90
- fg: working || stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted,
114
+ fg: working || current ? theme?.current?.warning : theme?.current?.textMuted,
91
115
  children: working ? activityFrame() : attentionSignal ? runtime.jsx("b", { children: attentionSignal }) : " ",
92
116
  }),
93
- runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: statusMarker(stage.status) }),
94
- runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: stage.current || stage.id === result.data.currentStage ? theme?.current?.warning : theme?.current?.textMuted, children: stageText }),
117
+ runtime.jsx("text", { flexShrink: 0, marginRight: 1, fg: current ? theme?.current?.warning : theme?.current?.textMuted, children: statusMarker(stage.status) }),
118
+ runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: current ? theme?.current?.warning : theme?.current?.text, children: `${stage.id}. ${stage.title}` }),
119
+ ],
120
+ });
121
+ const metadataRow = metadata && runtime.jsx("box", {
122
+ flexDirection: "row",
123
+ onMouseDown,
124
+ children: [
125
+ runtime.jsx("text", { flexShrink: 0, marginRight: 1, children: " " }),
126
+ runtime.jsx("text", { flexShrink: 0, marginRight: 1, children: " " }),
127
+ runtime.jsx("text", { flexGrow: 1, flexShrink: 1, wrapMode: "word", fg: theme?.current?.textMuted, children: metadata }),
95
128
  ],
96
129
  });
130
+ return [titleRow, metadataRow].filter(Boolean);
97
131
  }),
98
132
  ];
99
133
  };
@@ -286,8 +320,8 @@ const registerDependencyToggle = (api, controller, projectRoot) => {
286
320
  if (typeof api?.keymap?.registerLayer !== "function") return () => {};
287
321
  const command = {
288
322
  name: DEPENDENCIES_COMMAND,
289
- title: "Toggle sidebar dependencies",
290
- desc: "Show or hide dependency IDs in the stages sidebar",
323
+ title: "Toggle sidebar details",
324
+ desc: "Show or hide stage tasks, dependencies, and pending candidates",
291
325
  category: "Work Context",
292
326
  namespace: "palette",
293
327
  run: () => {
@@ -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);
package/src/candidates.js CHANGED
@@ -8,6 +8,9 @@ import { capturePatch, capturePaths, commitPatch, previewPatch, repositoryState
8
8
  const candidatePattern = /^CC-(\d{6})$/;
9
9
  const statuses = new Set(["draft", "ready", "discarded", "committed"]);
10
10
  const strategies = new Set(["exact", "shared_foundation", "integration"]);
11
+ const projectionCandidateLimit = 10;
12
+ const projectionTitleLimit = 120;
13
+ const deliveryCandidateLimit = 20;
11
14
  const timestamp = (value) => typeof value === "string" && !Number.isNaN(Date.parse(value)) && new Date(value).toISOString() === value;
12
15
  const metadataKeys = ["schema", "candidate", "workspace", "title", "message", "base_head", "status", "created_at", "updated_at", "selected_paths", "patch_file"];
13
16
  const optionalMetadataKeys = ["strategy", "related_stages"];
@@ -106,11 +109,63 @@ export class CandidateStore {
106
109
  }
107
110
 
108
111
  summary(workspace) {
109
- return this.list(workspace).reduce((summary, candidate) => {
110
- if (candidate.status === "draft") summary.pending += 1;
111
- if (candidate.status === "ready") summary.ready += 1;
112
- return summary;
113
- }, { pending: 0, ready: 0 });
112
+ return this.activeProjection(workspace).summary;
113
+ }
114
+
115
+ projectionRecords(workspace) {
116
+ workspace = normalizeWorkspaceId(workspace);
117
+ this.context.storage.readWorkspace(workspace);
118
+ if (!fs.existsSync(this.directory)) return [];
119
+ return fs.readdirSync(this.directory)
120
+ .filter((file) => candidatePattern.test(file.slice(0, -5)) && file.endsWith(".json"))
121
+ .sort()
122
+ .flatMap((file) => {
123
+ try {
124
+ const data = JSON.parse(fs.readFileSync(path.join(this.directory, file), "utf8"));
125
+ if (data?.workspace !== workspace) return [];
126
+ return [validateCandidate(data, file.slice(0, -5))];
127
+ } catch { return []; }
128
+ });
129
+ }
130
+
131
+ activeProjection(workspace) {
132
+ const projection = { summary: { pending: 0, ready: 0 }, by_stage: {} };
133
+ workspace = this.assertStartup(workspace);
134
+ for (const candidate of this.projectionRecords(workspace)) {
135
+ if (!["draft", "ready"].includes(candidate.status)) continue;
136
+ if (candidate.status === "draft") projection.summary.pending += 1;
137
+ if (candidate.status === "ready") projection.summary.ready += 1;
138
+ const related = {
139
+ candidate: candidate.candidate,
140
+ title: candidate.title.slice(0, projectionTitleLimit),
141
+ status: candidate.status,
142
+ strategy: candidate.strategy || "exact",
143
+ related_stages: candidate.related_stages || [],
144
+ };
145
+ for (const stage of related.related_stages) {
146
+ const stageProjection = projection.by_stage[stage] ||= { draft: 0, ready: 0, items: [] };
147
+ stageProjection[candidate.status] += 1;
148
+ if (stageProjection.items.length < projectionCandidateLimit) stageProjection.items.push(related);
149
+ }
150
+ }
151
+ return projection;
152
+ }
153
+
154
+ committedProjection(workspace) {
155
+ const records = this.projectionRecords(workspace)
156
+ .filter((candidate) => candidate.status === "committed")
157
+ .sort((left, right) => left.committed_at.localeCompare(right.committed_at) || left.candidate.localeCompare(right.candidate));
158
+ return {
159
+ count: records.length,
160
+ items: records.slice(-deliveryCandidateLimit).map((candidate) => ({
161
+ candidate: candidate.candidate,
162
+ title: candidate.title.slice(0, projectionTitleLimit),
163
+ strategy: candidate.strategy || "exact",
164
+ related_stages: candidate.related_stages || [],
165
+ commit_hash: candidate.commit_hash,
166
+ committed_at: candidate.committed_at,
167
+ })),
168
+ };
114
169
  }
115
170
 
116
171
  capture(workspace, id, input) {
@@ -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
+ }