opencode-work-context 0.14.1 → 0.16.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 +110 -21
- package/commands/wc.md +30 -8
- package/package.json +1 -1
- package/plugin/attention.js +3 -2
- package/plugin/session-switcher.js +12 -11
- package/plugin/stage-switcher.js +6 -5
- package/plugin/stages-tui.js +24 -5
- package/plugin/work-context-modal.js +13 -10
- package/plugin/work-context.js +32 -1
- package/plugin/workspace-switcher.js +4 -3
- package/src/candidates.js +116 -2
- package/src/core.js +307 -35
- package/src/dependency-handoffs.js +204 -0
- package/src/errors.js +6 -0
- package/src/index.js +1 -0
- package/src/integration-notices.js +317 -0
- package/src/protocol.js +2 -2
- package/src/session-diagnostics.js +22 -14
- package/src/sessions.js +5 -0
- package/src/stages-snapshot.js +8 -4
- package/src/storage.js +18 -2
- package/src/tool-definitions.js +26 -28
- package/src/work-context-snapshot.js +4 -4
- package/tools/work_context_add_stage_dependency.js +2 -0
- package/tools/work_context_confirm_candidate_coverage.js +1 -0
- package/tools/work_context_delegate_stage.js +2 -0
- package/tools/work_context_publish_dependency_handoff.js +2 -0
- package/tools/work_context_read_dependency_context.js +2 -0
- package/tools/work_context_remove_stage_dependency.js +2 -0
package/README.md
CHANGED
|
@@ -55,12 +55,12 @@ Then create a task and its first stage in OpenCode:
|
|
|
55
55
|
/wc resume 000001 02
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
`stage add` creates a stage
|
|
59
|
-
|
|
60
|
-
session
|
|
61
|
-
|
|
62
|
-
Multiple sessions may work on the same non-terminal stage through
|
|
63
|
-
resume and handoff operations.
|
|
58
|
+
`stage add` only creates a `planned` stage. It never starts a stage session or
|
|
59
|
+
changes the invoking OpenCode session's current stage, regardless of whether
|
|
60
|
+
that session is already associated with a workspace. Use
|
|
61
|
+
`/wc resume <workspace> <stage>` in a separate OpenCode session to enter the new
|
|
62
|
+
stage. Multiple sessions may work on the same non-terminal stage through
|
|
63
|
+
explicit resume and handoff operations.
|
|
64
64
|
|
|
65
65
|
Stages remain in progress until the user explicitly requests `/wc stage finish`.
|
|
66
66
|
Do not infer that request from completed work. Automatic completion is allowed
|
|
@@ -70,6 +70,49 @@ only when the workspace Planning-stage prompt includes this standalone line:
|
|
|
70
70
|
AUTO_STAGE_FINISH: allowed
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
### Delegate Work Between Stages
|
|
74
|
+
|
|
75
|
+
An active working stage can atomically create a delegated stage and become
|
|
76
|
+
formally dependent on it:
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
/wc stage delegate 000001 02 "Research compatibility" "Return a verified compatibility finding" "Inspect the supported versions and run focused checks."
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The new stage receives a bounded delegation contract. The delegating stage
|
|
83
|
+
keeps its active session, but becomes blocked for resume and finish until the
|
|
84
|
+
new dependency reaches a lifecycle-satisfied state. Planning stage 01 cannot
|
|
85
|
+
participate in working-stage dependencies. Existing actionable stages can be
|
|
86
|
+
linked or unlinked explicitly with `stage dependency add` and `stage dependency
|
|
87
|
+
remove`; cycle checks and the repository transaction prevent partial graph
|
|
88
|
+
updates.
|
|
89
|
+
|
|
90
|
+
While work is still in progress, the active dependency stage may publish a
|
|
91
|
+
bounded intermediate result without finishing:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
/wc stage dependency publish 000001 03 "Compatibility is viable; browser coverage remains"
|
|
95
|
+
/wc stage dependency read 000001 02
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
An explicit `stage finish` publishes exactly one immutable final handoff to all
|
|
99
|
+
formal direct dependents. Handoffs contain only a concise outcome, explicit
|
|
100
|
+
committed candidate or commit evidence, verification, blockers, source and
|
|
101
|
+
target stages, and identity/timestamp fields. They never contain transcripts,
|
|
102
|
+
raw diffs, secrets, or an unbounded copy of another stage's execution state.
|
|
103
|
+
Updating a completed stage result later does not rewrite the historical final
|
|
104
|
+
handoff.
|
|
105
|
+
|
|
106
|
+
An already-active dependent receives a targeted one-time system notice before
|
|
107
|
+
its next model request. Resume context and expanded sidebar details provide the
|
|
108
|
+
durable fallback. Intermediate handoffs do not satisfy dependencies, and no
|
|
109
|
+
handoff advances Current, finishes a stage, starts downstream work, switches a
|
|
110
|
+
session, or submits an unsolicited prompt. Removing an edge retires its pending
|
|
111
|
+
delivery and current projection. Re-adding the same edge creates a new
|
|
112
|
+
generation, so old handoffs do not reappear. The bounded audit trail compacts
|
|
113
|
+
sufficiently old non-current records into a content-digest summary before
|
|
114
|
+
storage limits could block lifecycle work.
|
|
115
|
+
|
|
73
116
|
### Acknowledge A Manual Commit
|
|
74
117
|
|
|
75
118
|
When you commit shared in-progress work while an active stage is running, tell
|
|
@@ -245,10 +288,12 @@ per-item commits.
|
|
|
245
288
|
In startup mode, the agent first inspects pending candidates related to the
|
|
246
289
|
current stage and assesses direct publication. Only a ready `exact` candidate
|
|
247
290
|
explicitly related to the current stage may substitute when direct publication
|
|
248
|
-
is unsafe but the patch is separable. `shared_foundation` and
|
|
249
|
-
candidates do not satisfy Current completion.
|
|
250
|
-
|
|
251
|
-
|
|
291
|
+
is unsafe but the patch is separable. Ordinary `shared_foundation` and
|
|
292
|
+
`integration` candidates do not satisfy Current completion. The narrow
|
|
293
|
+
multi-stage integration-coverage exception is described below. A real patch or
|
|
294
|
+
merge conflict, failed verification, or incoherent boundary remains a blocker
|
|
295
|
+
and Current must not be completed. This policy never authorizes unrelated
|
|
296
|
+
changes.
|
|
252
297
|
|
|
253
298
|
`complete-current` remains an atomic ledger-only operation: it never runs Git
|
|
254
299
|
or creates a commit itself.
|
|
@@ -474,26 +519,30 @@ when the host supports deletion; a navigation failure leaves the new linked
|
|
|
474
519
|
session available for a later switch.
|
|
475
520
|
|
|
476
521
|
`work_context_start_session` never rebinds the OpenCode session that invokes it.
|
|
477
|
-
|
|
478
|
-
|
|
522
|
+
The first work-context stage associated with a native OpenCode session becomes
|
|
523
|
+
that session's immutable stage affinity. If the session later requests any
|
|
524
|
+
other stage, the operation fails atomically with
|
|
479
525
|
`CURRENT_OPENCODE_SESSION_ALREADY_ASSOCIATED`. The error identifies the current
|
|
480
526
|
and requested stage sessions and directs the caller to open a separate OpenCode
|
|
481
|
-
session
|
|
482
|
-
|
|
527
|
+
session. Handoff, close, finish, abandon, archive, workspace completion, and
|
|
528
|
+
stage restoration never transfer or clear affinity. Repeating the operation
|
|
529
|
+
for the already-associated stage retains the existing
|
|
483
530
|
`ACTIVE_SESSION_EXISTS` result and never creates a duplicate.
|
|
484
531
|
The same association invariant applies when the core creates a workspace; the
|
|
485
532
|
structured create tool leaves a new workspace unassociated when invoked from an
|
|
486
|
-
|
|
533
|
+
OpenCode session with either an active or historical affinity.
|
|
487
534
|
|
|
488
535
|
Read-only stage and workspace snapshots include `sessionDiagnostics`. Legacy
|
|
489
|
-
event streams in which
|
|
490
|
-
|
|
491
|
-
recovery guidance. Recovery treats the earliest
|
|
492
|
-
presumed original
|
|
493
|
-
|
|
536
|
+
event streams in which an active association conflicts with the earliest
|
|
537
|
+
historical affinity report `SESSION_ASSOCIATION_SPLIT_BRAIN` and non-destructive
|
|
538
|
+
recovery guidance. Recovery treats the earliest historical association as the
|
|
539
|
+
presumed original affinity and never recommends force-closing it merely because
|
|
540
|
+
a later conflicting association exists.
|
|
494
541
|
Contextual mutations that omit an ambiguous workspace or stage fail with the
|
|
495
542
|
same `SESSION_ASSOCIATION_SPLIT_BRAIN` code. Recovery must name the incorrect
|
|
496
|
-
workspace and stage explicitly before handing it off or closing it.
|
|
543
|
+
workspace and stage explicitly before handing it off or closing it. Closing the
|
|
544
|
+
incorrect association restores normal access to the original affinity but does
|
|
545
|
+
not authorize the native session to bind to the incorrect stage again.
|
|
497
546
|
|
|
498
547
|
The command palette still exposes `work_context.actions` for the broader action
|
|
499
548
|
modal. Its command actions only prepare visible `/wc` commands and never submit
|
|
@@ -720,6 +769,46 @@ separate those edits by provenance. Use an integration candidate only when the
|
|
|
720
769
|
combined patch is coherent and verified; otherwise stop and establish a safe
|
|
721
770
|
candidate boundary before publication.
|
|
722
771
|
|
|
772
|
+
### Confirmed Integration Coverage
|
|
773
|
+
|
|
774
|
+
Confirmed coverage is the only exception that lets one integration candidate
|
|
775
|
+
stand in for the Current work of multiple `per_item` stages. It is available
|
|
776
|
+
only in a startup workspace and requires one ready `integration` candidate,
|
|
777
|
+
2-20 explicit unique selected stages, and a Current execution item in every
|
|
778
|
+
selected stage:
|
|
779
|
+
|
|
780
|
+
```text
|
|
781
|
+
/wc candidate confirm-coverage 000123 CC-000001 stages 02 04 INTEGRATION_COVERAGE_CONFIRMED
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
The confirmation snapshots each selected stage's stable Current item ID and
|
|
785
|
+
execution revision. Every selected stage must have effective `per_item` mode and
|
|
786
|
+
be actionable. Candidate `relatedStages` remains traceability only: it does not
|
|
787
|
+
select stages, prove coverage, or authorize completion. At publication, Work
|
|
788
|
+
Context revalidates the snapshots before any Git mutation. If a Current item,
|
|
789
|
+
execution revision, effective mode, or stage status changed, it returns
|
|
790
|
+
`CANDIDATE_COVERAGE_STALE`, leaves the candidate ready, and creates no commit.
|
|
791
|
+
|
|
792
|
+
On success, the committed candidate durably records the selected coverage and
|
|
793
|
+
commit SHA, but does not advance a checklist or stage lifecycle. Each selected
|
|
794
|
+
stage must verify the remaining integration result and separately run
|
|
795
|
+
`complete-current`. Coverage remains visible in resume and sidebar state only
|
|
796
|
+
while that exact Current item remains current; it clears for a stage as soon as
|
|
797
|
+
that stage advances Current.
|
|
798
|
+
|
|
799
|
+
An already-active, unambiguous native session receives one bounded system notice
|
|
800
|
+
before its next model request after covered publication. Inactive and newly
|
|
801
|
+
resumed sessions use the durable resume/sidebar coverage state instead. This
|
|
802
|
+
notice never changes prompts, turns, or attention indicators. Standard-mode
|
|
803
|
+
workspaces, manual commit mode, ordinary unconfirmed integration or
|
|
804
|
+
shared-foundation candidates, and repository-local `commit all` retain their
|
|
805
|
+
existing behavior.
|
|
806
|
+
|
|
807
|
+
Before discarding an exact draft for an integration candidate, prove the
|
|
808
|
+
replacement covers the exact draft's intended work through capture, preview,
|
|
809
|
+
readiness, and explicit coverage confirmation when it will substitute for
|
|
810
|
+
multiple Current items. Related-stage metadata alone is not proof.
|
|
811
|
+
|
|
723
812
|
### Repository-local commit all
|
|
724
813
|
|
|
725
814
|
`commit all` is the explicit fast path for one coherent repository-wide
|
package/commands/wc.md
CHANGED
|
@@ -3,7 +3,7 @@ description: Explicit work-context lifecycle commands backed by structured tools
|
|
|
3
3
|
subtask: false
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
<!-- opencode-work-context-protocol: {"schema":1,"major":1,"minor":
|
|
6
|
+
<!-- opencode-work-context-protocol: {"schema":1,"major":1,"minor":7,"descriptor_hash":"sha256:b3c01c7ef3cad00e9c75f13a20fdb8785922afbfb2d240b9925d7bf9fe28209f"} -->
|
|
7
7
|
|
|
8
8
|
Interpret `/wc $ARGUMENTS` as an explicit work-context operation. Use the matching
|
|
9
9
|
`work_context_*` custom tool registered by the installed package plugin with structured arguments. Never edit work-context
|
|
@@ -39,6 +39,7 @@ Use these exact tool mappings; do not invent shortened tool names:
|
|
|
39
39
|
- `candidate show <workspace> <candidateId>` -> `work_context_show_candidate`
|
|
40
40
|
- `candidate list <workspace>` -> `work_context_list_candidates`
|
|
41
41
|
- `candidate ready <workspace> <candidateId>` -> `work_context_ready_candidate`
|
|
42
|
+
- `candidate confirm-coverage <workspace> <candidateId> stages <stage>... INTEGRATION_COVERAGE_CONFIRMED` -> `work_context_confirm_candidate_coverage`
|
|
42
43
|
- `candidate commit <workspace> <candidateId> ["message"]` -> `work_context_commit_candidate`
|
|
43
44
|
- `candidate discard <workspace> <candidateId>` -> `work_context_discard_candidate`
|
|
44
45
|
- `commit all <workspace> ["message"] [stages <stage>...] [exclude <path>...]` -> `work_context_inspect_commit_all`
|
|
@@ -56,6 +57,11 @@ Use these exact tool mappings; do not invent shortened tool names:
|
|
|
56
57
|
- `profiles setup` -> ask for global or project scope and mapping values, then `work_context_configure_capability_profiles`
|
|
57
58
|
- `profiles reset` -> ask for global or project scope and confirmation, then `work_context_reset_capability_profiles`
|
|
58
59
|
- `stage add [<workspace>] ...` -> `work_context_add_stage` (optional `prompt`; infer missing execution capability and depth from the complete stage context before calling the tool)
|
|
60
|
+
- `stage delegate [<workspace>] [<stage>] "title" "requested outcome" ["prompt"] ...` -> `work_context_delegate_stage`
|
|
61
|
+
- `stage dependency add [<workspace>] [<stage>] <dependency>` -> `work_context_add_stage_dependency`
|
|
62
|
+
- `stage dependency remove [<workspace>] [<stage>] <dependency>` -> `work_context_remove_stage_dependency`
|
|
63
|
+
- `stage dependency publish [<workspace>] [<stage>] "outcome" [candidates <candidateId>...] [commits <sha>...] [verification JSON] [blockers JSON]` -> `work_context_publish_dependency_handoff`
|
|
64
|
+
- `stage dependency read [<workspace>] [<stage>]` -> `work_context_read_dependency_context`
|
|
59
65
|
- `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`
|
|
60
66
|
- `stage commit-mode [<workspace>] [<stage>] <manual|per_item|clear>` -> `work_context_set_stage_commit_mode`
|
|
61
67
|
- `stage profiles refresh <workspace> [<stage>] [--include-explicit]` -> inspect current stage context, infer classifications, then `work_context_refresh_stage_profiles`
|
|
@@ -92,6 +98,7 @@ Supported syntax:
|
|
|
92
98
|
- `candidate show <workspace> <candidateId>`
|
|
93
99
|
- `candidate list <workspace>`
|
|
94
100
|
- `candidate ready <workspace> <candidateId>`
|
|
101
|
+
- `candidate confirm-coverage <workspace> <candidateId> stages <stage>... INTEGRATION_COVERAGE_CONFIRMED`
|
|
95
102
|
- `candidate commit <workspace> <candidateId> ["message"]`
|
|
96
103
|
- `candidate discard <workspace> <candidateId>`
|
|
97
104
|
- `commit all <workspace> ["message"] [stages <stage>...] [exclude <path>...]`
|
|
@@ -109,6 +116,11 @@ Supported syntax:
|
|
|
109
116
|
- `profiles setup`
|
|
110
117
|
- `profiles reset`
|
|
111
118
|
- `stage add [<workspace>] "title" ["prompt"] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>] [review <routine|implementation|architecture|security|review>]`
|
|
119
|
+
- `stage delegate [<workspace>] [<stage>] "title" "requested outcome" ["prompt"] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>] [review <routine|implementation|architecture|security|review>]`
|
|
120
|
+
- `stage dependency add [<workspace>] [<stage>] <dependency>`
|
|
121
|
+
- `stage dependency remove [<workspace>] [<stage>] <dependency>`
|
|
122
|
+
- `stage dependency publish [<workspace>] [<stage>] "outcome" [candidates <candidateId>...] [commits <sha>...] [verification JSON] [blockers JSON]`
|
|
123
|
+
- `stage dependency read [<workspace>] [<stage>]`
|
|
112
124
|
- `stage profiles [<workspace>] [<stage>] [execution <routine|implementation|architecture|security|review> depth <light|standard|deep>|clear] [review <routine|implementation|architecture|security|review|clear>]`
|
|
113
125
|
- `stage commit-mode [<workspace>] [<stage>] <manual|per_item|clear>`
|
|
114
126
|
- `stage profiles refresh <workspace> [<stage>] [--include-explicit]`
|
|
@@ -137,6 +149,12 @@ Supported syntax:
|
|
|
137
149
|
- 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
|
|
138
150
|
- `stage update-result` replaces an existing result and does not create a result for an unfinished stage
|
|
139
151
|
- Planning stage 01 is a continuously available coordination surface, not a prerequisite gate; implementation, research, review, and other working stages must never depend on it
|
|
152
|
+
- `stage delegate` requires the active delegating working-stage session and atomically creates one planned stage plus the edge from the delegator to that new dependency. The new stage receives a bounded delegation contract; the delegator remains active but may become blocked. A failure must leave neither a partial stage nor a partial edge
|
|
153
|
+
- `stage dependency add|remove` applies only to planned or in-progress dependents, preserves the canonical dependent-to-dependency graph direction, rejects Planning, missing/cancelled sources, duplicates, self-edges, and cycles, and never stops an active dependent session. Every add creates a monotonically increasing edge generation; removal retires current delivery and projection, and re-adding the pair cannot resurrect older handoffs. Sufficiently old non-current audit records may be compacted into a bounded content-digest summary
|
|
154
|
+
- `stage dependency publish` requires the active source-stage session and at least one formal direct dependent. It publishes an intermediate bounded outcome to every direct dependent without satisfying the dependency or changing any execution or lifecycle state. Candidate and commit evidence must be explicit and already committed
|
|
155
|
+
- `stage dependency read` returns only direct dependency satisfaction and bounded current handoffs. Do not recursively inject another stage's prompt, execution ledger, or dependency tree
|
|
156
|
+
- explicit `stage finish` atomically publishes one immutable final handoff when direct dependents exist. A later `stage update-result` changes the authoritative result but never rewrites the delivered final handoff; use a bounded `handoffOutcome` when a long result cannot fit the handoff contract
|
|
157
|
+
- dependency handoffs and satisfied-boundary status changes use targeted at-most-once system notices for already-active unambiguous dependent sessions. Resume and sidebar context are the durable fallback. Delivery never submits a prompt, starts work, advances Current, changes lifecycle, or determines dependency satisfaction
|
|
140
158
|
- execution recommendations have two independent portable fields: capability (`routine`, `implementation`, `architecture`, `security`, `review`) and depth (`light`, `standard`, `deep`)
|
|
141
159
|
- 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`
|
|
142
160
|
- 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
|
|
@@ -155,11 +173,16 @@ Supported syntax:
|
|
|
155
173
|
- after completing a meaningful Current item, read the latest revision and call `stage execution complete-current`; it atomically moves only Current to Completed and promotes the next queued item. Retain ordering and briefly report the transition in normal output
|
|
156
174
|
- workspace `commit_mode` is persistent checklist commit authorization with `manual` as the default and `per_item` as the only commit policy. A stage may override it or use `clear` to inherit. It does not make `stage execution complete-current` perform Git work.
|
|
157
175
|
- in effective `per_item` mode, immediately before each direct commit or candidate fallback, call `stage commit-mode read` and proceed only when it still returns `per_item`. This is an agent-policy preflight, not atomic Git enforcement. Define an explicit patch boundary, run relevant verification, and create a safe direct commit before complete-current. Candidate publication remains separate.
|
|
158
|
-
- in startup plus `per_item` mode, inspect pending candidates related to the current stage and assess direct publication first. Only a ready `exact` candidate explicitly related to the current stage may substitute when direct publication is unsafe but separable
|
|
176
|
+
- in startup plus `per_item` mode, inspect pending candidates related to the current stage and assess direct publication first. Only a ready `exact` candidate explicitly related to the current stage may substitute when direct publication is unsafe but separable. An ordinary `shared_foundation` or `integration` candidate does not satisfy Current completion. The narrow exception is committed, confirmed integration coverage described below. Reconcile stale related candidate intent after a direct commit. A true patch or merge conflict, failed verification, or incoherent boundary is a blocker: record it and do not complete Current. Authorization never includes unrelated changes.
|
|
177
|
+
- `candidate confirm-coverage` is available only in a startup workspace for one ready `integration` candidate. It requires an explicit selection of 2-20 unique actionable stages, the exact `INTEGRATION_COVERAGE_CONFIRMED` token, effective `per_item` mode, and a Current item for every selected stage. It snapshots each selected stage's stable Current item ID and execution revision. `relatedStages` remains traceability-only and neither selects nor authorizes coverage.
|
|
178
|
+
- candidate publication revalidates confirmed coverage before any Git mutation. A changed Current item, execution revision, effective mode, or terminal stage returns `CANDIDATE_COVERAGE_STALE`; the candidate remains ready and no commit is created. A successful publication stores the durable coverage and commit SHA but never advances execution state or stage lifecycle. Each selected stage verifies its remaining integration result and calls `complete-current` separately.
|
|
179
|
+
- committed coverage remains visible for exactly the covered Current item, then disappears for that stage when that Current advances. An already-active, unambiguous native session receives one bounded system notice before its next model request. Inactive or new sessions receive the durable resume/sidebar coverage fallback. Coverage never repurposes prompts, turns, or attention signals.
|
|
180
|
+
- before discarding an existing exact draft in favor of an integration candidate, prove the integration replacement covers the exact draft's intended work through capture, preview, readiness, and, when it substitutes for multiple Current items, explicit coverage confirmation. Do not discard the exact draft based only on related-stage metadata.
|
|
159
181
|
- `resume` returns `resume.presentation` and `resume.context`; before doing any work, report a concise human-oriented summary in the user's language with the stage title, a plain-language Goal, previous progress when useful, and the immediate next action
|
|
160
182
|
- when the saved prompt contains several clear deliverables, add `In this stage we will` with 2-5 short outcome-oriented bullets derived only from the prompt, previous result, and workspace knowledge; do not invent scope, and omit this block for a small stage
|
|
161
183
|
- do not expose raw workspace/stage/session identifiers, ordinals, `ok` flags, or absent error codes in the user-facing resume summary
|
|
162
184
|
- `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
|
|
185
|
+
- `resume.context.delegation_contract` gives a delegated source stage its bounded requested outcome. `resume.context.dependency_context` gives a dependent only direct lifecycle satisfaction plus bounded current handoffs. Treat both as established structured context, not permission to infer ownership or mutate another stage
|
|
163
186
|
- when stage execution state exists, `resume.context.execution_state` is the current stage-local operational checkpoint. Its structured `current` and `queued` fields identify the active item and its ordered backlog; Current details are explicit on resume while queued presentation remains compact. Continue from it without rewriting the original prompt, and never copy it automatically into workspace knowledge or unrelated stages
|
|
164
187
|
- 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
|
|
165
188
|
- 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
|
|
@@ -168,12 +191,11 @@ Supported syntax:
|
|
|
168
191
|
- standard-mode and unassociated core sessions do not receive startup policy; retain the existing conservative worktree behavior there
|
|
169
192
|
- after presenting the summary, continue work immediately when `resume.next_action` is `start_work`; do not ask for generic confirmation
|
|
170
193
|
- 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
|
|
171
|
-
- `create` enters the new workspace's Planning stage in the current OpenCode session only when that session
|
|
172
|
-
- `stage add` creates a stage;
|
|
173
|
-
-
|
|
174
|
-
- `resume` never rebinds the OpenCode session that invokes it: while that session is associated with active stage A, attempting to start stage B must fail atomically with `CURRENT_OPENCODE_SESSION_ALREADY_ASSOCIATED`; open a separate OpenCode session or explicitly hand off or close A first, and never hide the transition behind automatic handoff
|
|
194
|
+
- `create` enters the new workspace's Planning stage in the current OpenCode session only when that native session has no active or historical work-context stage affinity; otherwise it creates the workspace without rebinding the current OpenCode session
|
|
195
|
+
- `stage add` only creates a planned stage; it never starts a stage session or changes the invoking OpenCode session's current stage, regardless of whether that session is associated with a workspace. Enter the new stage later with an explicit `resume <workspace> <stage>` in a separate OpenCode session
|
|
196
|
+
- `resume` never rebinds the OpenCode session that invokes it: the first associated work-context stage becomes that native session's immutable affinity, and attempting to start any different stage must fail atomically with `CURRENT_OPENCODE_SESSION_ALREADY_ASSOCIATED`; open a separate OpenCode session for the requested stage. Handoff, close, finish, abandon, archive, workspace completion, stage reopen, and stage restore never transfer or clear affinity
|
|
175
197
|
- a repeated `resume` for the stage already associated with the current OpenCode session returns the existing typed `ACTIVE_SESSION_EXISTS` result and must not create a duplicate stage session
|
|
176
|
-
- read-only session diagnostics report legacy
|
|
198
|
+
- read-only session diagnostics report a legacy active association that conflicts with the earliest historical affinity as `SESSION_ASSOCIATION_SPLIT_BRAIN`; preserve the earliest historical association as the presumed original affinity, explicitly hand off or close only the incorrect later active association, and never force-close the presumed original merely because the conflict exists
|
|
177
199
|
- while `SESSION_ASSOCIATION_SPLIT_BRAIN` is present, contextual mutations must fail closed when omitted identifiers are ambiguous; recovery must explicitly name both the incorrect workspace and stage before handoff or close
|
|
178
200
|
- `resume` returns `resume.next_action` and `resume.instruction`; begin or continue implementation when the stage prompt is non-empty unless it explicitly requires confirmation or contains an unresolved decision that genuinely blocks progress
|
|
179
201
|
- `commited` is intentionally spelled with one `t`. It is a deterministic light control-plane acknowledgement for a user-created current-HEAD commit in the active stage session. Call the structured tool directly and return its compact result without a second analysis response. It validates the supplied short or full SHA, attached branch, fast-forward checkpoint, and absence of Git operations; it never infers ownership or changes candidates.
|
|
@@ -187,7 +209,7 @@ Supported syntax:
|
|
|
187
209
|
- `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
|
|
188
210
|
- `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`.
|
|
189
211
|
- `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.
|
|
190
|
-
- 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
|
|
212
|
+
- 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. Confirmed integration coverage is an additional startup-only, per-item contract; it does not broaden standard-mode candidates, manual mode, or `commit all`.
|
|
191
213
|
- `commit all` is an explicit two-phase repository-local integration operation available in standard and startup workspaces: first call inspection, report its included and excluded paths, traceability, proposed message, verification summary, and fingerprint, then wait for the user's exact `COMMIT_ALL_CONFIRMED` confirmation before calling publication with the same message, stages, exclusions, and fingerprint
|
|
192
214
|
- commit-all inspection is read-only and never treats stages as file ownership; user-selected stages are traceability and message context, paths without defensible attribution remain explicit, `exclude` leaves known unrelated work outside the patch, and an omitted message uses the diff-derived proposal
|
|
193
215
|
- commit-all publication re-inspects under the Git lock and returns `COMMIT_ALL_STALE_PLAN` when HEAD, patch content, exclusions, traceability, or message no longer match the confirmed fingerprint; never infer confirmation from tests, candidate readiness, preview success, or lifecycle state
|
package/package.json
CHANGED
package/plugin/attention.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { loadConfig } from "../src/storage.js";
|
|
4
4
|
import { readWorkContextSnapshot } from "../src/work-context-snapshot.js";
|
|
5
|
+
import { nativeSessionId } from "../src/sessions.js";
|
|
5
6
|
import { createGlobalAttentionChannel } from "./global-attention.js";
|
|
6
7
|
import { createAttentionActivator } from "./attention-activation.js";
|
|
7
8
|
import { createDesktopNotifier } from "./notifier.js";
|
|
@@ -293,13 +294,13 @@ const currentSessionId = (api) => api?.route?.current?.name === "session"
|
|
|
293
294
|
? api.route.current.params?.sessionID || api.route.current.params?.sessionId || api.route.current.params?.session_id
|
|
294
295
|
: undefined;
|
|
295
296
|
const linkedSessionIds = (snapshot) => new Set((snapshot?.data?.workspaces || []).flatMap((workspace) =>
|
|
296
|
-
(workspace.sessions || []).map(
|
|
297
|
+
(workspace.sessions || []).map(nativeSessionId).filter(Boolean)));
|
|
297
298
|
const visibleSessionRecords = (snapshot, sessionId) => (snapshot?.workspaces || []).flatMap((workspace) => {
|
|
298
299
|
const visibleStages = new Set((workspace.stages || [])
|
|
299
300
|
.filter((stage) => stage.status !== "archived")
|
|
300
301
|
.map((stage) => stage.id));
|
|
301
302
|
return (workspace.sessions || [])
|
|
302
|
-
.filter((session) => session
|
|
303
|
+
.filter((session) => nativeSessionId(session) === sessionId && visibleStages.has(session.stage))
|
|
303
304
|
.map((session) => ({ workspace, session }));
|
|
304
305
|
});
|
|
305
306
|
const activeVisibleSessionRecords = (snapshot, sessionId) => visibleSessionRecords(snapshot, sessionId)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readWorkContextSnapshot } from "../src/work-context-snapshot.js";
|
|
2
|
+
import { nativeSessionId } from "../src/sessions.js";
|
|
2
3
|
import { acknowledgeNavigation, attentionForSession, attentionIndicatorText, attentionReasonText } from "./attention.js";
|
|
3
4
|
|
|
4
5
|
const SESSION_STATE_RANK = { active: 0, handed_off: 1, abandoned: 2, closed: 3 };
|
|
@@ -9,11 +10,11 @@ const projectRoot = (api) => api?.state?.path?.worktree || api?.state?.path?.dir
|
|
|
9
10
|
const sessionTime = (session) => String(session.updated_at || session.started_at || "");
|
|
10
11
|
|
|
11
12
|
const compareSessions = (left, right, currentId, attention) => {
|
|
12
|
-
const leftCurrent = left
|
|
13
|
-
const rightCurrent = right
|
|
13
|
+
const leftCurrent = nativeSessionId(left) === currentId;
|
|
14
|
+
const rightCurrent = nativeSessionId(right) === currentId;
|
|
14
15
|
if (leftCurrent !== rightCurrent) return leftCurrent ? -1 : 1;
|
|
15
|
-
const leftAttention = Boolean(attention?.(left
|
|
16
|
-
const rightAttention = Boolean(attention?.(right
|
|
16
|
+
const leftAttention = Boolean(attention?.(nativeSessionId(left)));
|
|
17
|
+
const rightAttention = Boolean(attention?.(nativeSessionId(right)));
|
|
17
18
|
if (leftAttention !== rightAttention) return leftAttention ? -1 : 1;
|
|
18
19
|
return (SESSION_STATE_RANK[left.state] ?? 9) - (SESSION_STATE_RANK[right.state] ?? 9)
|
|
19
20
|
|| sessionTime(right).localeCompare(sessionTime(left))
|
|
@@ -26,7 +27,7 @@ const compareSessions = (left, right, currentId, attention) => {
|
|
|
26
27
|
export const sortSessionSwitcherEntries = (entries = [], currentId = null, attention) => {
|
|
27
28
|
const selected = new Map();
|
|
28
29
|
for (const entry of entries) {
|
|
29
|
-
const id = entry.session
|
|
30
|
+
const id = nativeSessionId(entry.session || {});
|
|
30
31
|
if (!id || selected.has(id) && compareSessions(selected.get(id).session, entry.session, currentId, attention) <= 0) continue;
|
|
31
32
|
selected.set(id, entry);
|
|
32
33
|
}
|
|
@@ -36,7 +37,7 @@ export const sortSessionSwitcherEntries = (entries = [], currentId = null, atten
|
|
|
36
37
|
export const selectSession = (entries = [], currentId = null) => sortSessionSwitcherEntries(entries, currentId)[0]?.session || null;
|
|
37
38
|
|
|
38
39
|
export const switchToSession = (api, session) => {
|
|
39
|
-
const sessionID = session
|
|
40
|
+
const sessionID = session ? nativeSessionId(session) : null;
|
|
40
41
|
if (!sessionID) return errorResult("SESSION_OPENCODE_ID_MISSING", "This work-context session has no OpenCode session ID", { session_id: session?.session_id });
|
|
41
42
|
if (typeof api?.route?.navigate !== "function") return errorResult("SESSION_SWITCH_UNAVAILABLE", "This OpenCode host cannot switch sessions from a TUI plugin");
|
|
42
43
|
try {
|
|
@@ -66,7 +67,7 @@ export const createSessionSwitcherFlow = (api, { read = readWorkContextSnapshot
|
|
|
66
67
|
const currentId = currentSessionId(api);
|
|
67
68
|
const attention = (id) => attentionForSession(api, id);
|
|
68
69
|
const available = sortSessionSwitcherEntries(entries, currentId, attention);
|
|
69
|
-
const unavailable = entries.filter(({ session }) => !session
|
|
70
|
+
const unavailable = entries.filter(({ session }) => !nativeSessionId(session));
|
|
70
71
|
const labels = { active: "Active", handed_off: "Handed off", abandoned: "Abandoned", closed: "Closed" };
|
|
71
72
|
api.ui.dialog.setSize?.("medium");
|
|
72
73
|
api.ui.dialog.replace(() => api.ui.DialogSelect({
|
|
@@ -74,10 +75,10 @@ export const createSessionSwitcherFlow = (api, { read = readWorkContextSnapshot
|
|
|
74
75
|
placeholder: "Search sessions",
|
|
75
76
|
options: [
|
|
76
77
|
...available.map(({ workspace, session }) => ({
|
|
77
|
-
title: `${attentionIndicatorText(attention(session
|
|
78
|
-
description: `${attention(session
|
|
79
|
-
footer: session
|
|
80
|
-
category: session
|
|
78
|
+
title: `${attentionIndicatorText(attention(nativeSessionId(session)))} ${workspace.id} ${session.stage || "-"}/${String(session.ordinal || 0).padStart(2, "0")} ${session.summary || "Work session"} · ${workspace.title}`.trim(),
|
|
79
|
+
description: `${attention(nativeSessionId(session)) ? `needs attention: ${attentionReasonText(attention(nativeSessionId(session)).reason)} · ` : ""}${session.state || "unknown"} · ${session.session_id || "unknown"}`,
|
|
80
|
+
footer: nativeSessionId(session),
|
|
81
|
+
category: nativeSessionId(session) === currentId ? "Current" : labels[session.state] || session.state || "Unknown",
|
|
81
82
|
value: session,
|
|
82
83
|
})),
|
|
83
84
|
...unavailable.map(({ workspace, session }) => ({
|
package/plugin/stage-switcher.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { contextFor } from "../src/opencode-adapter.js";
|
|
2
|
+
import { nativeSessionId } from "../src/sessions.js";
|
|
2
3
|
import { isDependencySatisfied } from "../src/stage-status.js";
|
|
3
4
|
import { readTuiState, updateTuiState } from "./tui-state.js";
|
|
4
5
|
import { acknowledgeNavigation, attentionForSession, attentionIndicatorText, attentionReasonText } from "./attention.js";
|
|
@@ -46,8 +47,8 @@ export const rememberRecentStage = (api, workspace, stage) => {
|
|
|
46
47
|
export const recentStageIds = (api, workspace) => [...(recentStageStore(api).get(workspace) || [])];
|
|
47
48
|
|
|
48
49
|
export const selectStageSession = (sessions = [], attention) => sessions
|
|
49
|
-
.filter((session) => session
|
|
50
|
-
.sort((left, right) => Number(Boolean(attention?.(right
|
|
50
|
+
.filter((session) => nativeSessionId(session))
|
|
51
|
+
.sort((left, right) => Number(Boolean(attention?.(nativeSessionId(right)))) - Number(Boolean(attention?.(nativeSessionId(left))))
|
|
51
52
|
|| (SESSION_STATE_RANK[left.state] ?? 9) - (SESSION_STATE_RANK[right.state] ?? 9)
|
|
52
53
|
|| String(right.updated_at || right.started_at || "").localeCompare(String(left.updated_at || left.started_at || ""))
|
|
53
54
|
|| Number(right.ordinal || 0) - Number(left.ordinal || 0))[0] || null;
|
|
@@ -56,7 +57,7 @@ export const selectStageSession = (sessions = [], attention) => sessions
|
|
|
56
57
|
export const readStageSwitcherSnapshot = ({ projectRoot: root, sessionId } = {}) => {
|
|
57
58
|
try {
|
|
58
59
|
const context = contextFor(root, sessionId, "OpenCode TUI");
|
|
59
|
-
const current = context.
|
|
60
|
+
const current = context.sessionAffinityByOpenCodeId(sessionId) || context.sessionById(sessionId);
|
|
60
61
|
if (!current) return errorResult("STAGE_CONTEXT_REQUIRED", "The current OpenCode session is not associated with a work-context stage");
|
|
61
62
|
const listed = context.listStages(current.workspace).data;
|
|
62
63
|
const workspace = context.listWorkspaces().data.find((item) => item.workspace === current.workspace);
|
|
@@ -141,7 +142,7 @@ export const switchToStage = async (api, stage, options = {}) => {
|
|
|
141
142
|
if (typeof api?.route?.navigate !== "function") return errorResult("SESSION_SWITCH_UNAVAILABLE", "This OpenCode host cannot switch sessions from a TUI plugin");
|
|
142
143
|
const existing = stage.selectedSession || selectStageSession(stage.sessions);
|
|
143
144
|
if (existing) {
|
|
144
|
-
const switched = navigateToSession(api, existing
|
|
145
|
+
const switched = navigateToSession(api, nativeSessionId(existing));
|
|
145
146
|
if (switched.ok) {
|
|
146
147
|
rememberRecentStage(api, options.workspace, stage.id);
|
|
147
148
|
rememberRecentStage(api, options.workspace, options.currentStage);
|
|
@@ -204,7 +205,7 @@ export const createStageSwitcherFlow = (api, { read = readStageSwitcherSnapshot,
|
|
|
204
205
|
const needsAttention = decorated.filter((stage) => !stage.current && stage.attention);
|
|
205
206
|
const ordinary = decorated.filter((stage) => !stage.current && !stage.attention);
|
|
206
207
|
const optionFor = (stage, category) => {
|
|
207
|
-
const available = (stage.sessions || []).filter((session) => session
|
|
208
|
+
const available = (stage.sessions || []).filter((session) => nativeSessionId(session)).length;
|
|
208
209
|
const state = stage.blocked ? `blocked by ${stage.blockers.join(", ")}` : stage.status;
|
|
209
210
|
return {
|
|
210
211
|
title: `${stage.current ? ">" : " "} ${attentionIndicatorText(stage.attention)} ${stage.id}. ${stage.title}`.replace(/ +/g, " "),
|
package/plugin/stages-tui.js
CHANGED
|
@@ -45,6 +45,22 @@ const stageCandidateText = (stage) => {
|
|
|
45
45
|
const others = candidate.related_stages.filter((related) => related !== stage.id);
|
|
46
46
|
return `Pending: ${candidate.status} · ${candidate.strategy}${others.length ? ` · also ${others.join(", ")}` : ""}`;
|
|
47
47
|
};
|
|
48
|
+
const stageCoverageText = (stage) => {
|
|
49
|
+
const coverage = stage.committed_coverage;
|
|
50
|
+
if (!coverage?.count) return null;
|
|
51
|
+
if (coverage.count > 1) return `Published Current: ${coverage.count} integration commits${coverage.truncated ? " (details truncated)" : ""}`;
|
|
52
|
+
const [item] = coverage.items;
|
|
53
|
+
const others = item.covered_stages.filter((covered) => covered !== stage.id);
|
|
54
|
+
return `Published Current: ${item.candidate} · ${item.commit_hash.slice(0, 8)}${others.length ? ` · also ${others.join(", ")}` : ""}`;
|
|
55
|
+
};
|
|
56
|
+
const stageHandoffText = (stage) => {
|
|
57
|
+
const context = stage.dependency_context;
|
|
58
|
+
if (!context) return null;
|
|
59
|
+
const state = context.blocked ? "blocked" : "satisfied";
|
|
60
|
+
if (!context.handoffs?.count) return `Dependencies: ${state}`;
|
|
61
|
+
const latest = context.handoffs.items[0];
|
|
62
|
+
return `Dependencies: ${state} · Handoff: ${latest.kind} from ${latest.source_stage}${context.handoffs.count > 1 ? ` · ${context.handoffs.count} total` : ""}`;
|
|
63
|
+
};
|
|
48
64
|
export const checklistSummaryText = (execution) => {
|
|
49
65
|
if (!execution) return null;
|
|
50
66
|
const done = execution.completed?.length || 0;
|
|
@@ -103,7 +119,7 @@ const renderStagesContent = (result, theme, runtime = defaultRuntime, attention,
|
|
|
103
119
|
stage.tracker_links?.length && `Tasks: ${stage.tracker_links.map(trackerLinkText).join(", ")}`,
|
|
104
120
|
stage.depends_on?.length && `Deps: ${formatStageIds(stage.depends_on)}`,
|
|
105
121
|
].filter(Boolean).join(" · ");
|
|
106
|
-
const metadata = showDependencies ? [recommendation, stage.commit_mode && `Commits: ${stage.commit_mode.replace("_", "-")} (override)`, stageMetadata, stageCandidateText(stage), stage.current && checklistSummaryText(stage.execution)].filter(Boolean).join("\n") : "";
|
|
122
|
+
const metadata = showDependencies ? [recommendation, stage.commit_mode && `Commits: ${stage.commit_mode.replace("_", "-")} (override)`, stageMetadata, stageHandoffText(stage), stageCandidateText(stage), stageCoverageText(stage), stage.current && checklistSummaryText(stage.execution)].filter(Boolean).join("\n") : "";
|
|
107
123
|
const attentionSignal = attentionSummaryText(unread);
|
|
108
124
|
const onMouseDown = (event) => {
|
|
109
125
|
if (event?.button != null && event.button !== 0) return;
|
|
@@ -313,7 +329,10 @@ const updateSessionTitle = async (api, projectRoot) => {
|
|
|
313
329
|
if (!sessionId || typeof api?.client?.session?.update !== "function") return;
|
|
314
330
|
try {
|
|
315
331
|
const context = contextFor(projectRoot, sessionId);
|
|
316
|
-
const
|
|
332
|
+
const affinity = context.sessionAffinityByOpenCodeId(sessionId);
|
|
333
|
+
const session = affinity
|
|
334
|
+
? context.sessionByOpenCodeId(sessionId, affinity.workspace, affinity.stage) || affinity
|
|
335
|
+
: context.sessionById(sessionId);
|
|
317
336
|
if (!session) return;
|
|
318
337
|
const title = titleFor(context, session.workspace, session.stage, sessionId, session, readTuiState(projectRoot).sidebar_dependencies === true);
|
|
319
338
|
await api.client.session.update({ path: { id: sessionId }, query: { directory: projectRoot }, body: { title } });
|
|
@@ -381,7 +400,7 @@ export const checklistOptions = (execution, width = 80) => {
|
|
|
381
400
|
: value;
|
|
382
401
|
const option = (value, section, index, title, category) => {
|
|
383
402
|
const entry = item(value, section, index);
|
|
384
|
-
return { title: title(entry.text), value: `execution-${entry.id}`, category, ...(entry.details ? {
|
|
403
|
+
return { title: title(entry.text), value: `execution-${entry.id}`, category, ...(entry.details ? { guidance: entry.details } : {}) };
|
|
385
404
|
};
|
|
386
405
|
const options = [];
|
|
387
406
|
const current = execution.current || structuredItems("remaining")[0];
|
|
@@ -434,10 +453,10 @@ export const openChecklistDialog = (api, result) => {
|
|
|
434
453
|
options: checklistOptions(current.execution, width),
|
|
435
454
|
onSelect: (option) => {
|
|
436
455
|
if (option.value === "close") api.ui.dialog.clear?.();
|
|
437
|
-
else if (option.
|
|
456
|
+
else if (option.guidance) api.ui.dialog.replace(() => api.ui.DialogSelect({
|
|
438
457
|
title: `Checklist details · ${option.title}`,
|
|
439
458
|
placeholder: "Details",
|
|
440
|
-
options: checklistDetailsOptions(option.
|
|
459
|
+
options: checklistDetailsOptions(option.guidance, width),
|
|
441
460
|
onSelect: (detailOption) => { if (detailOption.value === "back") showChecklist(); },
|
|
442
461
|
}));
|
|
443
462
|
},
|
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { readWorkContextSnapshot } from "../src/work-context-snapshot.js";
|
|
4
4
|
import { normalizeStageId, normalizeWorkspaceId } from "../src/identifiers.js";
|
|
5
|
+
import { nativeSessionId } from "../src/sessions.js";
|
|
5
6
|
import { jsx } from "@opentui/solid/jsx-runtime";
|
|
6
7
|
import { createSignal } from "solid-js";
|
|
7
8
|
import { openStageSwitcher } from "./stage-switcher.js";
|
|
@@ -294,7 +295,7 @@ export const renderWorkContextModal = (controller, theme, runtime = { jsx }, { m
|
|
|
294
295
|
capability && line(runtime, capability, { wrapMode: "word", fg: muted }),
|
|
295
296
|
line(runtime, `Sessions ${(selected.sessions || []).length}`, { fg: muted }),
|
|
296
297
|
...(selected.sessions || []).map((session) => {
|
|
297
|
-
const unread = controller.attention?.attentionFor?.(session
|
|
298
|
+
const unread = controller.attention?.attentionFor?.(nativeSessionId(session));
|
|
298
299
|
return line(runtime, `${unread ? `${attentionIndicatorText(unread)} ` : ""}${session.state || "unknown"} ${session.session_id || "unknown"} stage ${session.stage || "-"}`, { wrapMode: "word", fg: muted });
|
|
299
300
|
}),
|
|
300
301
|
] : []),
|
|
@@ -498,7 +499,7 @@ export const createWorkContextActionFlow = (api, { projectRoot, sessionId, read
|
|
|
498
499
|
{ title: `State ${session.state || "unknown"}`, value: "state", category: "Details", disabled: true },
|
|
499
500
|
{ title: `Summary ${session.summary || "No summary"}`, value: "summary", category: "Details", disabled: true },
|
|
500
501
|
{ title: `Session ${session.session_id}`, value: "session", category: "Details", disabled: true },
|
|
501
|
-
...(session
|
|
502
|
+
...(nativeSessionId(session) ? [{ title: `OpenCode ${nativeSessionId(session)}`, value: "opencode", category: "Details", disabled: true }] : []),
|
|
502
503
|
...(session.branch ? [{ title: `Branch ${session.branch}`, value: "branch", category: "Details", disabled: true }] : []),
|
|
503
504
|
...(session.updated_at ? [{ title: `Updated ${session.updated_at}`, value: "updated", category: "Details", disabled: true }] : []),
|
|
504
505
|
];
|
|
@@ -513,21 +514,23 @@ export const createWorkContextActionFlow = (api, { projectRoot, sessionId, read
|
|
|
513
514
|
const rank = { active: 0, handed_off: 1, abandoned: 2, closed: 3 };
|
|
514
515
|
const entries = loaded.workspaces.flatMap((workspace) => (workspace.sessions || []).map((session) => ({ workspace, session })));
|
|
515
516
|
if (!entries.length) { toast("No sessions found"); return; }
|
|
517
|
+
const currentRecord = entries.filter(({ session }) => nativeSessionId(session) === sessionId)
|
|
518
|
+
.sort((left, right) => (rank[left.session.state] ?? 9) - (rank[right.session.state] ?? 9)
|
|
519
|
+
|| String(right.session.updated_at || "").localeCompare(String(left.session.updated_at || "")))[0]?.session;
|
|
516
520
|
entries.sort((left, right) => {
|
|
517
|
-
const leftCurrent = left.session
|
|
518
|
-
const rightCurrent = right.session
|
|
519
|
-
if (leftCurrent) return -1;
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
const rightAttention = attentionForSession(api, right.session.opencode_session_id);
|
|
521
|
+
const leftCurrent = left.session === currentRecord;
|
|
522
|
+
const rightCurrent = right.session === currentRecord;
|
|
523
|
+
if (leftCurrent !== rightCurrent) return leftCurrent ? -1 : 1;
|
|
524
|
+
const leftAttention = attentionForSession(api, nativeSessionId(left.session));
|
|
525
|
+
const rightAttention = attentionForSession(api, nativeSessionId(right.session));
|
|
523
526
|
if (Boolean(leftAttention) !== Boolean(rightAttention)) return leftAttention ? -1 : 1;
|
|
524
527
|
return (rank[left.session.state] ?? 9) - (rank[right.session.state] ?? 9)
|
|
525
528
|
|| String(right.session.updated_at || "").localeCompare(String(left.session.updated_at || ""));
|
|
526
529
|
});
|
|
527
530
|
const labels = { active: "Active", handed_off: "Handed off", abandoned: "Abandoned", closed: "Closed" };
|
|
528
531
|
showSelect("Sessions", entries.map(({ workspace, session }) => {
|
|
529
|
-
const current = session
|
|
530
|
-
const unread = attentionForSession(api, session
|
|
532
|
+
const current = session === currentRecord;
|
|
533
|
+
const unread = attentionForSession(api, nativeSessionId(session));
|
|
531
534
|
return {
|
|
532
535
|
title: `${attentionIndicatorText(unread)} ${workspace.id} ${sessionOrdinal(session)} ${session.summary || "Work session"} · ${workspace.title}`.trim(),
|
|
533
536
|
description: `${unread ? `needs attention: ${attentionReasonText(unread.reason)} · ` : ""}${session.state || "unknown"} · ${session.session_id}`,
|