@abelxiaoxing/cadence 2.0.36 → 2.0.38

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.
Files changed (55) hide show
  1. package/README.de.md +4 -4
  2. package/README.es.md +4 -4
  3. package/README.fr.md +4 -4
  4. package/README.ja.md +4 -4
  5. package/README.ko.md +4 -4
  6. package/README.md +11 -9
  7. package/README.pt-BR.md +4 -4
  8. package/README.ru.md +4 -4
  9. package/README.zh-CN.md +12 -10
  10. package/THIRD_PARTY_NOTICES.md +9 -1
  11. package/agents/design-explorer.md +4 -2
  12. package/agents/diagnosis-worker.md +5 -2
  13. package/agents/implementation-worker.md +19 -12
  14. package/docs/conversation-mode.md +46 -18
  15. package/docs/reuse-and-distribution.md +1 -1
  16. package/docs/service-management.md +35 -9
  17. package/package.json +16 -8
  18. package/src/agent-browser/labeled-rule.ts +74 -0
  19. package/src/agent-browser/session-navigator.ts +214 -0
  20. package/src/agent-browser/source.ts +174 -0
  21. package/src/agent-browser/transcript-content.ts +442 -0
  22. package/src/agent-browser/transcript-pane.ts +324 -0
  23. package/src/agent-panel-cadence.ts +147 -628
  24. package/src/agent-panel-model.ts +34 -267
  25. package/src/agent-panel.ts +139 -437
  26. package/src/cadence-instructions.ts +8 -7
  27. package/src/cadence-mode.ts +30 -9
  28. package/src/change-tools.mjs +268 -0
  29. package/src/coordinator-tools.mjs +44 -16
  30. package/src/git-environment.d.mts +2 -0
  31. package/src/git-environment.mjs +24 -0
  32. package/src/image-content.mjs +7 -28
  33. package/src/index.ts +1 -1
  34. package/src/native-build.ts +1 -1
  35. package/src/native-workflow-history.ts +20 -3
  36. package/src/operator-cli.mjs +18 -11
  37. package/src/research-scan.mjs +393 -0
  38. package/src/research-tools.mjs +406 -342
  39. package/src/sdk-worker.mjs +42 -55
  40. package/src/service/contracts/core.ts +0 -1
  41. package/src/service/contracts/workbench.ts +21 -19
  42. package/src/service/contracts/workflow.ts +283 -16
  43. package/src/service/coordination.ts +7 -0
  44. package/src/service-cli.mjs +652 -149
  45. package/src/service-host.mjs +2745 -1137
  46. package/src/worker-capture.mjs +24 -1
  47. package/src/worker-public.mjs +19 -2
  48. package/src/worker-redaction.mjs +11 -0
  49. package/src/worker-toolkit.mjs +157 -0
  50. package/src/worker-workspace.d.mts +13 -0
  51. package/src/worker-workspace.mjs +48 -0
  52. package/src/workspace.ts +4 -24
  53. package/web/dist/assets/cadence.css +1 -1
  54. package/web/dist/assets/cadence.js +18 -17
  55. package/web/dist/manifest.json +7 -7
@@ -11,7 +11,8 @@ Browser conversation mode is retained by the project owner, not by a browser-onl
11
11
 
12
12
  1. Cadence delegates focused readonly repository investigations, reuses existing project documentation, and consolidates questions in the main conversation.
13
13
  2. Discuss requirements and decisions until the implementation and acceptance criteria are clear.
14
- 3. Cadence presents one readable plan: scope, dependencies, setup, baseline checks, acceptance checks, repair budget and delivery policy.
14
+ 3. Cadence presents one readable delivery agreement: expected result, acceptance, scope, setup/check commands, project knowledge and delivery policy.
15
+ The technical route is an initial suggestion; routine recovery and in-scope implementation changes need no further approval.
15
16
  4. Type `按计划实施` after the plan to authorize those exact bytes.
16
17
  In the browser, click **Implement this plan** or send that exact approval phrase for the currently displayed plan.
17
18
  In Pi, the Start tool can alternatively present one native confirmation of the complete plan.
@@ -26,7 +27,12 @@ Native mode is branch-aware; browser mode follows its server-owned conversation
26
27
  The browser and the terminal share the conversation itself (it is the same Pi session), but each keeps its own Cadence mode and plan approval: entering Cadence in one does not enter it in the other.
27
28
  A workflow started in either place appears in that conversation in the browser as one line after the turn it started in.
28
29
  A saved native mode is active only in a trusted interactive terminal; print/RPC sessions keep ordinary tools and can still exit with `/cadence exit`.
29
- In Pi, the agent panel lists workflow subagents and opens their transcripts; `cadence_status` can read one step's transcript.
30
+ In Pi, the agent panel shows only running subagents belonging to the current conversation, not other Pi conversations in the same directory.
31
+ With an empty focused input, press ↓ to choose a running agent and Enter to read it; ended agents leave the list automatically.
32
+ A transcript you already opened stays readable when its agent finishes, without further background queries.
33
+ With none running, ↓ stays with the editor.
34
+ Completion keeps a compact summary; use `/cadence-history` (or `cadence_status` for one step) when you explicitly need retained results/transcripts.
35
+ Resuming the same Pi conversation can observe its ongoing work; new and forked conversations do not inherit that live display.
30
36
  Resume and compaction retain the mode/context, not execution grants.
31
37
  Opening a different conversation does not enable Cadence there.
32
38
  Restore never replays a command or automatically resumes an interrupted queue.
@@ -54,7 +60,8 @@ An uncertain final Send keeps its original command identity for observation only
54
60
 
55
61
  Use **Add images**, paste a screenshot, or drop image files onto the composer.
56
62
  Preview and remove images before Send; a message can contain images without text.
57
- PNG, JPEG and WebP are supported; the composer shows the current count and size limits.
63
+ PNG, JPEG and WebP are supported.
64
+ Cadence imposes no image count or size limit; available browser/host memory and the selected model provider still constrain what can be sent.
58
65
  Choose a model whose catalog supports image input.
59
66
  An incompatible model refuses the message rather than dropping its images.
60
67
  Ordinary and Cadence conversations use the same image input.
@@ -65,7 +72,7 @@ Only Send uploads them, bound to that exact conversation, branch, model and mess
65
72
  Unsent pictures are not saved in browser storage and disappear on refresh; the text draft remains.
66
73
  After Pi records a sent image, it appears in the conversation history and remains viewable after refresh (including retained reads when the project owner is stopped).
67
74
  Click a history thumbnail to open it at full size.
68
- Unsupported or over-limit media from existing Pi sessions remains omitted; unavailable images show a notice without changing their session files.
75
+ Unsupported media from existing Pi sessions remains omitted; unavailable images show a notice without changing their session files.
69
76
  Images are private conversation content, not public download links.
70
77
  Text redaction does not sanitize words or secrets inside pixels: inspect screenshots before sending them to a model.
71
78
 
@@ -86,10 +93,13 @@ An unavailable remembered model is not silently substituted.
86
93
  Pi's original model and authentication sources remain authoritative; Cadence does not copy credentials.
87
94
 
88
95
  Repository investigation and discussion do not edit business code.
89
- Approved work publishes a managed region in `.cadence/project.md` and readable plan/result notes under `.cadence/assistant/workflows/<run-id>/`.
90
- Existing human text outside the managed region is preserved.
91
- Existing architecture and development documents should be referenced, not duplicated.
92
- Each worker receives the approved goal/design/decisions/acceptance and its exact assignment; oversized context is refused rather than silently clipped.
96
+ Approved work maintains the relevant existing project documents named in the agreement and publishes readable workflow notes under `.cadence/assistant/workflows/<run-id>/`.
97
+ `.cadence/project.md` is a compact knowledge index; optional `.cadence/knowledge/` topics fill gaps, not duplicate existing `engineering/`, `docs/` or `.trellis/spec/`.
98
+ Human text and unrelated conventions are preserved.
99
+ Workers receive actual selected project knowledge, the approved goal/decisions/acceptance, their assignment and relevant failure/check evidence.
100
+ Source paths and partial coverage are recorded; longer documents remain available for on-demand reads.
101
+ After implementation, Cadence extracts useful source-backed lessons and updates approved documentation automatically, then checks and reviews the combined candidate.
102
+ No knowledge-maintenance or finish command is required.
93
103
  Private proposals, grants, native/auth outcomes and transcripts stay outside the checkout.
94
104
  Markdown is not execution authority.
95
105
  Old task summaries and history are neither imported nor reset.
@@ -99,8 +109,10 @@ Old task summaries and history are neither imported nor reset.
99
109
  The plan chooses one delivery policy:
100
110
 
101
111
  - **Local merge:** requires an existing Git branch and configured commit identity.
102
- Independent tasks use separate worktrees, up to two at once; dependencies are applied before their consumers.
103
- The owner commits only declared file changes, integrates them into a separate candidate, runs independent readonly Agent review and real checks, then fast-forwards the unchanged target branch.
112
+ After approval, each delivery creates its own `cadence/<goal>-<run-id>` branch and one stable worktree; mode entry and research create neither.
113
+ Assignments, diagnosis, recovery and knowledge updates reuse that candidate, preserving partial work.
114
+ The target is the current local branch displayed in the agreement, not necessarily `main`; the conversation stays in its original directory.
115
+ The owner commits only declared file changes, runs independent readonly Agent review and real checks, then fast-forwards the unchanged target branch.
104
116
  Local task commits and the merge are included in the plan approval.
105
117
  Git hooks and commit signing are disabled for these internal commits; verification is explicitly declared instead.
106
118
  No remote push occurs.
@@ -114,10 +126,15 @@ A write path naming a directory covers the files below it; in Git, working-copy
114
126
  Unresolved conflicts or a changed target stop integration.
115
127
  Cadence never resets, stashes, force-pushes or silently cleans uncertain worktrees.
116
128
  Ignored generated Markdown remains ignored and is published without forcing it into Git.
117
- Clean worktrees are removed after a successful merge (plain `git worktree remove`, which also deletes their ignored setup output such as `node_modules`); dirty or moved ones and all results are retained.
129
+ The named task branch is kept.
130
+ Only owned worktrees at the delivered commit, after successful post-merge checks and without any residue, are removed with plain `git worktree remove`.
131
+ Ignored setup/build output such as `node_modules` also retains the worktree; failures, cancellation and unknown outcomes never trigger cleanup.
118
132
  Only one approved implementation runs at a time; approving a second while one is active is refused with `conflict`.
119
- The 90-minute budget starts when the run acquires the checkout; Cancel/Stop never interrupt the final fast-forward (a hung `git merge` therefore delays Stop until Git exits).
120
- Local-merge plans cannot declare files that Git ignores; use working-copy delivery for those.
133
+ There is no fixed delivery-duration or repair-round quota.
134
+ Individual workers/checks retain their process deadlines; a settled failure can trigger diagnosis and continuation, not automatic goal termination.
135
+ Cancel/Stop never interrupt the final fast-forward (a hung `git merge` therefore delays Stop until Git exits).
136
+ Local-merge plans need clean, nonignored code and knowledge targets; use working-copy delivery for dirty or ignored documentation.
137
+ Generated workflow notes remain separate.
121
138
  After an owner restart, an unfinished run is shown as `unknown` with its retained worktrees; it is never resumed.
122
139
  Credential-looking text in plans and research questions is shown and approved redacted.
123
140
 
@@ -126,10 +143,17 @@ Investigate prerequisites during planning.
126
143
  If dependencies/setup are needed, include the exact commands in the plan for explicit approval.
127
144
  No dependency/browser download or source-profile copying is implicit.
128
145
  Baseline checks are separate from acceptance checks that need newly implemented files.
129
- Failed declared baseline checks stop before editing.
130
- At most two approved repair rounds may follow failed review/checks; repairs cannot expand scope or weaken acceptance.
146
+ Failed setup, baseline, implementation, checks or review enter source-backed diagnosis when their actual operations have settled.
147
+ Cadence can preserve partial outputs, split remaining work and choose alternative implementations within the approval; it never expands permissions or weakens acceptance.
148
+ Known transient provider HTTP failures back off automatically after actual cleanup, without holding the checkout while waiting; re-entry checks that the approved files have not changed.
149
+ An unchanged failure and identical recovery strategy cannot become an endless replay loop.
150
+ A concrete external blocker is reported with preserved work, not a generic request to type “continue”.
131
151
  Final candidate checks must pass before merge.
132
- Post-merge failures remain failures and report the actual merge commit; no rollback is fabricated.
152
+ Post-merge failures retain the actual merge commit.
153
+ Repairs stay in the same named candidate, invalidate its earlier acceptance, and are checked/reviewed against a new exact candidate.
154
+ Only this run’s last confirmed merge can serve as the next integration baseline; external target movement or branch switching blocks integration.
155
+ Repairs can fast-forward that unchanged target again; the user’s unrelated index is never committed.
156
+ Unresolved failures remain failures; no rollback is fabricated.
133
157
  Automatic review is never recorded as human review.
134
158
 
135
159
  To request orderly closure, ask Cadence to cancel in Pi, or use **Cancel workflow — request stop** in the browser (the browser coordinator cannot cancel).
@@ -146,9 +170,9 @@ System-service installation and remote access remain separate explicit operation
146
170
 
147
171
  `/cadence-history [run-id]` provides readonly diagnostics without model calls or service startup; see [History and diagnostics](history.md).
148
172
  The WebUI uses the same execution engine with a separate, context-bound browser confirmation path.
149
- Its main composer stays in the same conversation; the plan card appears inline, and each workflow is one line after the turn it started in, showing what it is doing (with **Stop**) or how it ended: its merge commit, or the reason it did not complete.
173
+ Its main composer stays in the same conversation; the agreement card appears inline, and each workflow is one line after the turn it started in, showing what it is doing (with **Stop**) or how it ended: its merge commit, or the reason it did not complete.
150
174
  Select the line to open the workflow's steps, checks, delivery and diagnostics in the main area; while it runs, the conversation's status names its phase.
151
- Research, implementation and review subagents are listed in the lower-left **Subagents** dock, together with legacy task children; selecting one (or **Open subagent context** on a step) opens its full transcript and retained result in the main area, and **Back to conversation** returns.
175
+ Research, implementation, diagnosis, knowledge and review subagents are listed in the lower-left **Subagents** dock, together with legacy task children; selecting one (or **Open subagent context** on a step) opens its full transcript and retained result in the main area, and **Back to conversation** returns.
152
176
  Active workflows are listed under **Running conversations** with **Cancel workflow — request stop**; this includes native-started workflows, and an unavailable observation is not proof of no work.
153
177
  The old task creation/Save/Start/check/human-Review controls are retired on both clients and refused by the service.
154
178
  Existing task records remain readonly; they are not converted into workflows.
@@ -177,3 +201,7 @@ Ask for `cadence_status` with the exact `runId`, `stepId`, and optionally `trans
177
201
  Selecting a retained run is readonly and does not replace the current run or restart work.
178
202
  Native status/history and the browser's **Owner timing and runtime** details show the actual owner build/epoch and recorded queue/worker timestamps; the worker SDK version can differ from the terminal Pi host.
179
203
  A parent session may record a whole batch of tool results together, so those timestamps are not the service's completion times.
204
+
205
+ Long workflows retain earlier steps in readonly pages rather than stopping at a step count.
206
+ Open **Earlier workflow steps** in the WebUI, **Earlier steps** in native history, or use `cadence_status` with the returned `stepsBefore` as `before`.
207
+ Route revisions and failed attempts remain visible; a later successful attempt never rewrites their original outcomes.
@@ -14,7 +14,7 @@ Provisioned official notice bodies were reused locally; builds never download li
14
14
  ## Runtime/package closure
15
15
 
16
16
  Only the native extension's explicit import closure, maintained SDK worker/shared JS capture modules, generated management/host/operator executables, Agents, independent skills/configuration, documentation, notices and complete built assets ship.
17
- Service/worker execution uses ordinary Node with exact production `undici` and `ws` and the Pi SDK (`pi-coding-agent`, `pi-ai`) from exact 0.84.3 optional dependencies, because Pi's installer omits peers; no source-tree or TypeScript fallback, SDK bundle or consumer compilation.
17
+ Service/worker execution uses ordinary Node with exact production `undici` and `ws` and the Pi SDK (`pi-coding-agent`, `pi-ai`) from the exact optional dependency versions in `package.json`, because Pi's installer omits peers; no source-tree or TypeScript fallback, SDK bundle or consumer compilation.
18
18
  Pi's package installer omits peers and aliases only its own packages and Typebox, so every other runtime import reachable from `src/index.ts` must be a production dependency; otherwise Pi fails to load the extension at startup.
19
19
  The retired shell-local controller is not a shipped competing executor.
20
20
 
@@ -107,7 +107,7 @@ A successful manager start request is not owner readiness: an unready owner repo
107
107
  Status also retains the manager's `active`/`activating`/`failed` observation separately.
108
108
  A definition whose project directory was removed gets a readable refusal (exit78, so the unit does not restart in a loop); `cadence server install` switches it to the workbench.
109
109
  `restart` rewrites an existing definition with the current Node and package paths, keeping its workspace and the user's disable choices, and starts it; run it after an npm upgrade, a Node change or a `models.json` edit.
110
- The `upgrade` command (Linux) installs the latest version, or exactly `--to VERSION`, with npm and restarts; see [Restart and upgrade from the WebUI](#restart-and-upgrade-from-the-webui) for its steps.
110
+ The `upgrade` command (Linux) installs the latest version, or exactly `--to VERSION`, with the detected installation's package manager and restarts; see [Restart and upgrade from the WebUI](#restart-and-upgrade-from-the-webui) for its steps.
111
111
  Commands that change the service (`install`, `restart`, `stop`, `uninstall`, `upgrade`) refuse with `inside-service` when they run inside the service they would stop, for example from a tool of its own agent: stopping a systemd unit ends every process in it, so the command would die before it started the service again.
112
112
  Use the WebUI or a terminal outside the service instead.
113
113
  `stop` joins the workbench's accepted Send preparations and associated exact-epoch project owners, then closes the entry; unrelated project owners stay independent.
@@ -123,7 +123,7 @@ The generated registration stays for the next boot or login.
123
123
  Because npm runs no uninstall script, uninstall the service before `npm uninstall -g`; a left-behind definition fails to start once its CLI path disappears.
124
124
  A definition Cadence did not generate is left unchanged (`foreign`), and `status` reports `absent` when none is registered.
125
125
 
126
- Pi's installer omits peers, so the standalone owner and workers load the Pi SDK (`pi-coding-agent`, `pi-ai`) from exact 0.84.3 optional dependencies.
126
+ Pi's installer omits peers, so the standalone owner and workers load the Pi SDK (`pi-coding-agent`, `pi-ai`) from the exact optional dependency versions in `package.json`.
127
127
  Package files may be hard links into the package manager's store (Bun's default install); Cadence binds their exact content, not their link count.
128
128
  Missing or unusable Pi sources refuse before an owner registers; an owner that cannot load the SDK refuses at stage `pi-runtime` and exits.
129
129
  The no-project workbench starts without either an SDK runtime or Pi authentication; missing sources are reported only when a project is explicitly opened.
@@ -137,7 +137,7 @@ A machine without a supported user service manager and `CADENCE_AUTOSTART=0` kee
137
137
  ### Restart and upgrade from the WebUI
138
138
 
139
139
  On Linux the workbench has a **Cadence service** dialog: the server button on the entry page, or **More → Cadence service** in a project.
140
- It shows the running version and its systemd unit, asks npm for the latest version only when you press **Check for updates**, and offers **Restart service** and **Upgrade to VERSION**.
140
+ It shows the running version and its systemd unit, shows its installation method, asks that package manager for the latest version only when you press **Check for updates**, and offers **Restart service** and **Upgrade to VERSION**.
141
141
  The confirmation names the running workflows and conversations the restart stops; they stop through the orderly Stop, never by a signal.
142
142
  If work starts or ends before you confirm, the request is refused as stale and the dialog reads the service again.
143
143
 
@@ -145,17 +145,43 @@ The request runs outside the service, in a transient unit `cadence.maintenance.s
145
145
  It runs the same `cadence server restart` or `cadence server upgrade`, then records its outcome; the page waits for that record and offers to reload.
146
146
  If it reports nothing, see `journalctl --user -u cadence.maintenance.service` (without `--user` for a system service) and `cadence server status`.
147
147
 
148
- An upgrade fetches the exact release while the service still runs, so an unreachable registry changes nothing.
149
- Then it stops the service, installs the release with `npm install --global` and starts the new copy's own `server restart`.
150
- A new version that does not become ready is replaced by the previous version again from npm's cache.
151
- The npm calls use npm's own configuration (`~/.npmrc` registry, proxy and prefix).
152
- Only a copy that `npm root --global` names, and that the service account can write, upgrades itself; the dialog says when another installation (Pi's own copy, a checkout, Bun, a root-owned prefix) has to be upgraded the way it was installed, followed by `cadence server restart`.
148
+ An upgrade fetches the exact release and previous version while the service still runs, so an unreachable registry changes nothing.
149
+ Then it stops the service, installs the release in the **same prefix with the same package manager** and starts the new copy's own `server restart`.
150
+ A failed/partial installation is replaced by the prefetched previous version, using that same manager.
151
+ After a new copy has attempted startup but has not confirmed readiness, its own orderly Stop must succeed before rollback can replace its files; an unconfirmed Stop leaves that copy untouched for diagnosis.
152
+ Readiness requires both a successful restart command exit and an alive-owner result; printed JSON alone cannot make a failed command successful.
153
+ Prefetch is not a transactional or fully offline dependency installation: a later install or rollback may still fail, and the recorded outcome keeps that failure.
154
+ No Pi settings, credentials or profiles are copied or rewritten.
155
+
156
+ Supported installations:
157
+
158
+ | Installed with | Update route |
159
+ | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
160
+ | `pi install npm:@abelxiaoxing/cadence` | The selected Pi agent directory's `npm` prefix, using npm with `--legacy-peer-deps` |
161
+ | The same Pi command with `npmCommand: ["bun"]` | That same prefix, using Bun with `--omit=peer` |
162
+ | `npm install -g @abelxiaoxing/cadence` | npm's actual global prefix |
163
+ | `bun add -g @abelxiaoxing/cadence` | Bun's actual global directory, including a custom user `bunfig.toml` location |
164
+ | `npm install @abelxiaoxing/cadence` or `bun add @abelxiaoxing/cadence` | The local prefix, when its manifest directly declares Cadence and its lockfile identifies one manager |
165
+
166
+ Bun's directory listing alone is not proof of a Bun installation: its prefix must have an unambiguous Bun lockfile.
167
+ Local npm prefixes also recognize `npm-shrinkwrap.json`.
168
+ Pi's default and custom `PI_CODING_AGENT_DIR` are supported; its string and object package declarations and resource filters stay unchanged.
169
+ A versioned Pi declaration (including `@latest`) is pinned: change it explicitly in Pi before using self-upgrade.
170
+ A Pi-managed prefix from another agent or a temporary Pi install is never treated as an ordinary local dependency to bypass that declaration.
171
+ Custom Pi `npmCommand` wrappers, project-local/temporary Pi installs, source checkouts, linked/isolated-store copies, mixed lockfiles, and prefixes the service account cannot write require a terminal update using the original installation method, followed by that copy's `server restart`.
172
+ Bun uses a fresh private staging directory with install scripts disabled to warm its cache; it removes only that staging directory.
173
+ Bun prefixes with their own `.npmrc` or `bunfig.toml` also require a terminal update: Cadence will not copy those potentially credential-bearing files into staging or silently fetch from another registry.
174
+ The managers read their account's own configuration (`~/.npmrc`, Bun's user `bunfig.toml` and npm's prefix-local configuration); npm/Bun binaries must be available on the service's saved PATH.
175
+ Every npm query, fetch and install explicitly selects the same prefix and global/local scope, overriding an inherited `global=true`.
176
+ A pinned, unwritable or unidentified installation reports that update information is unavailable rather than silently consulting another manager's registry.
177
+ Newly generated definitions retain absolute `XDG_CONFIG_HOME`, `BUN_INSTALL`, `BUN_INSTALL_GLOBAL_DIR`, `BUN_INSTALL_BIN`, and npm prefix/userconfig environment paths when explicitly supplied; registry tokens are never baked into the unit.
178
+ If an older service definition lacks those locations, restart it once from a terminal with the correct environment before using WebUI updates.
153
179
  A workbench that was not started by its systemd service, and services on macOS and Windows, show the version only; restart and upgrade them in a terminal.
154
180
 
155
181
  ### One copy for Pi and the service
156
182
 
157
183
  After `npm install -g`, `pi install "$(npm root -g)/@abelxiaoxing/cadence"` records that path and loads it in place, so an npm upgrade updates the service and native `/cadence` together.
158
- Pi's own package install (`pi install npm:@abelxiaoxing/cadence`) also loads the native client, but its copy puts no `cadence` on `PATH`; if you want the optional boot service, register it with `node ~/.pi/agent/npm/node_modules/@abelxiaoxing/cadence/src/service-cli.mjs server install`.
184
+ Pi's own package install (`pi install npm:@abelxiaoxing/cadence`) also loads the native client and supports the WebUI update route above, but its copy puts no `cadence` on `PATH`; if you want the optional boot service, register it with `node ~/.pi/agent/npm/node_modules/@abelxiaoxing/cadence/src/service-cli.mjs server install`.
159
185
  Keep one copy: two copies drift apart on upgrade, and a native client refuses an owner whose service contract differs from its own.
160
186
  A unit registered by an earlier version's Pi install hook keeps running; `cadence server restart` from the copy you keep rewrites it, and `pi update` no longer restarts it.
161
187
  Opening the private link once leaves an HttpOnly cookie in that browser; the address without the token only explains how to get the link.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.0.36",
3
+ "version": "2.0.38",
4
4
  "description": "Conversation-driven Pi workspace: persistent native and WebUI workflows, explicit plan approval, checks and local delivery.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -54,7 +54,14 @@
54
54
  "src/worker-public.mjs",
55
55
  "src/worker-redaction.mjs",
56
56
  "src/worker-tools.mjs",
57
+ "src/change-tools.mjs",
58
+ "src/git-environment.mjs",
59
+ "src/git-environment.d.mts",
57
60
  "src/research-tools.mjs",
61
+ "src/research-scan.mjs",
62
+ "src/worker-toolkit.mjs",
63
+ "src/worker-workspace.mjs",
64
+ "src/worker-workspace.d.mts",
58
65
  "web/dist",
59
66
  "docs",
60
67
  "README.md",
@@ -83,7 +90,8 @@
83
90
  "src/workspace.ts",
84
91
  "src/data-shapes.ts",
85
92
  "src/service/checkout-lock.ts",
86
- "src/service/liveness.ts"
93
+ "src/service/liveness.ts",
94
+ "src/agent-browser"
87
95
  ],
88
96
  "pi": {
89
97
  "extensions": [
@@ -115,14 +123,14 @@
115
123
  "check:notices": "node scripts/audit-notices.mjs"
116
124
  },
117
125
  "peerDependencies": {
118
- "@earendil-works/pi-coding-agent": "*",
119
- "@earendil-works/pi-tui": "*",
126
+ "@earendil-works/pi-coding-agent": "^1.5.0",
127
+ "@earendil-works/pi-tui": "^1.5.0",
120
128
  "typebox": "*",
121
- "@earendil-works/pi-ai": "*"
129
+ "@earendil-works/pi-ai": "^1.5.0"
122
130
  },
123
131
  "devDependencies": {
124
132
  "@biomejs/biome": "^2.4.16",
125
- "@earendil-works/pi-tui": "0.84.3",
133
+ "@earendil-works/pi-tui": "1.5.0",
126
134
  "@types/node": "^22.15.3",
127
135
  "rumdl": "^0.2.10",
128
136
  "typescript": "^6.0.3",
@@ -165,8 +173,8 @@
165
173
  "ws": "8.21.3"
166
174
  },
167
175
  "optionalDependencies": {
168
- "@earendil-works/pi-ai": "0.84.3",
169
- "@earendil-works/pi-coding-agent": "0.84.3"
176
+ "@earendil-works/pi-ai": "1.5.0",
177
+ "@earendil-works/pi-coding-agent": "1.5.0"
170
178
  },
171
179
  "bin": {
172
180
  "cadence": "./src/service-cli.mjs",
@@ -0,0 +1,74 @@
1
+ /** Adapted from gotgenes/pi-packages @ 52854c12d590142e61a4f6a6947be9084035300d.
2
+ * MIT; see licenses/pi-subagents-MIT.txt and provenance/agent-browser-reuse.json. */
3
+ /**
4
+ * labeled-rule.ts — a full-width horizontal rule with labels embedded in it, in
5
+ * the style of Pi's editor border (`── ⠋ Working ─────`).
6
+ *
7
+ * `── <left> ─────── <right> ──`: the left label follows a two-dash lead-in, the
8
+ * optional right label precedes a two-dash trailer, and dashes fill the gap.
9
+ * Labels arrive already styled; `paint` colours only the rule's own characters,
10
+ * so a caller can tint the rule without re-colouring the text it carries.
11
+ *
12
+ * Each label is a list of fallbacks in preference order. The right label is
13
+ * dropped before the left one falls back, and when no left candidate fits, the
14
+ * last is truncated with an ellipsis. The result always spans exactly `width`
15
+ * columns: pi-tui rejects a wider row, and a narrower one leaves the rule short.
16
+ */
17
+
18
+ import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
19
+
20
+ const LEAD = "── ";
21
+ const TRAIL = " ──";
22
+ const DASH = "─";
23
+
24
+ /** Paint a rule of exactly `width` columns carrying the first labels that fit. */
25
+ export function labeledRule(
26
+ width: number,
27
+ paint: (rule: string) => string,
28
+ left: readonly string[],
29
+ right: readonly string[] = [],
30
+ ): string {
31
+ for (const leftLabel of left) {
32
+ for (const rightLabel of [...right, undefined]) {
33
+ if (fits(width, leftLabel, rightLabel))
34
+ return compose(width, paint, leftLabel, rightLabel);
35
+ }
36
+ }
37
+ const lastLeft = left.at(-1) ?? "";
38
+ // Leave room for the lead-in, the space after the label, and one dash.
39
+ const truncated = truncateToWidth(
40
+ lastLeft,
41
+ Math.max(0, width - LEAD.length - 2),
42
+ "…",
43
+ );
44
+ return compose(width, paint, truncated, undefined);
45
+ }
46
+
47
+ /** Whether both labels fit with at least one dash of fill between them. */
48
+ function fits(width: number, left: string, right: string | undefined): boolean {
49
+ return LEAD.length + visibleWidth(left) + 1 + 1 + rightWidth(right) <= width;
50
+ }
51
+
52
+ function compose(
53
+ width: number,
54
+ paint: (rule: string) => string,
55
+ left: string,
56
+ right: string | undefined,
57
+ ): string {
58
+ const fill = DASH.repeat(
59
+ Math.max(
60
+ 1,
61
+ width - LEAD.length - visibleWidth(left) - 1 - rightWidth(right),
62
+ ),
63
+ );
64
+ const tail =
65
+ right === undefined
66
+ ? paint(` ${fill}`)
67
+ : `${paint(` ${fill} `)}${right}${paint(TRAIL)}`;
68
+ return `${paint(LEAD)}${left}${tail}`;
69
+ }
70
+
71
+ /** Columns the right label costs, including its leading space and the trailer. */
72
+ function rightWidth(right: string | undefined): number {
73
+ return right === undefined ? 0 : 1 + visibleWidth(right) + TRAIL.length;
74
+ }
@@ -0,0 +1,214 @@
1
+ /** Agent selection → readonly transcript navigation, adapted from
2
+ * gotgenes/pi-packages @ 52854c12d590142e61a4f6a6947be9084035300d,
3
+ * packages/pi-subagents/src/ui/session-navigator.ts (MIT).
4
+ * See provenance/agent-browser-reuse.json and licenses/pi-subagents-MIT.txt.
5
+ *
6
+ * Cadence supplies entries rather than the upstream manager/file readers.
7
+ * The upstream TranscriptPane and TranscriptContent own the reading experience;
8
+ * Pi's SelectList replaces ui.select so a live list retains selection by id and
9
+ * Esc returns to that same list without starting another modal interaction. */
10
+ import {
11
+ getMarkdownTheme,
12
+ type KeybindingsManager,
13
+ type Theme,
14
+ } from "@earendil-works/pi-coding-agent";
15
+ import {
16
+ type Component,
17
+ isKeyRelease,
18
+ SelectList,
19
+ type TUI,
20
+ type TuiMouseEvent,
21
+ truncateToWidth,
22
+ } from "@earendil-works/pi-tui";
23
+ import { labeledRule } from "./labeled-rule.ts";
24
+ import type { BrowserSource, NavigationEntry } from "./source.ts";
25
+ import {
26
+ type ReadingPosition,
27
+ TranscriptPane,
28
+ VIEWPORT_HEIGHT_PCT,
29
+ } from "./transcript-pane.ts";
30
+
31
+ export class SessionNavigator implements Component {
32
+ readonly capturesViewportInput = true;
33
+ selected: string | undefined;
34
+ viewing: string | undefined;
35
+ private list: SelectList | undefined;
36
+ private pane: TranscriptPane | undefined;
37
+ private entries: NavigationEntry[] = [];
38
+ private signature = "";
39
+ private disposed = false;
40
+ private readonly unsubscribe: () => void;
41
+
42
+ constructor(
43
+ private readonly tui: TUI,
44
+ private readonly theme: Theme,
45
+ private readonly keys: Pick<KeybindingsManager, "matches" | "getKeys">,
46
+ private readonly source: BrowserSource,
47
+ private readonly cwd: string,
48
+ private readonly positions: Map<string, ReadingPosition>,
49
+ private readonly done: () => void,
50
+ ) {
51
+ this.unsubscribe = source.subscribe(() => {
52
+ if (!this.disposed) this.tui.requestRender();
53
+ });
54
+ this.refresh();
55
+ }
56
+
57
+ private refresh(): void {
58
+ const entries = this.source.entries();
59
+ const maxRows = Math.max(
60
+ 1,
61
+ Math.min(
62
+ 10,
63
+ Math.floor((this.tui.terminal.rows * VIEWPORT_HEIGHT_PCT) / 100) - 3,
64
+ ),
65
+ );
66
+ const signature = JSON.stringify([
67
+ maxRows,
68
+ entries.map(({ id, label }) => [id, label]),
69
+ ]);
70
+ if (this.signature === signature) return;
71
+ this.signature = signature;
72
+ const previousIndex = this.entries.findIndex(
73
+ (entry) => entry.id === this.selected,
74
+ );
75
+ // Keep an already-open transcript as a reading snapshot, but release the
76
+ // producer as soon as it leaves the live list. No historical rereads.
77
+ if (this.viewing && !entries.some((entry) => entry.id === this.viewing)) {
78
+ this.viewing = undefined;
79
+ this.source.view(null);
80
+ }
81
+ this.entries = entries;
82
+ const selectedIndex = entries.findIndex(
83
+ (entry) => entry.id === this.selected,
84
+ );
85
+ const index =
86
+ selectedIndex >= 0
87
+ ? selectedIndex
88
+ : Math.max(0, Math.min(previousIndex, entries.length - 1));
89
+ this.selected = entries[index]?.id;
90
+ this.list = new SelectList(
91
+ entries.map(({ id, label }) => ({ value: id, label })),
92
+ maxRows,
93
+ {
94
+ selectedPrefix: (text) => this.theme.fg("accent", text),
95
+ selectedText: (text) => this.theme.inverse(text),
96
+ description: (text) => this.theme.fg("muted", text),
97
+ scrollInfo: (text) => this.theme.fg("dim", text),
98
+ noMatch: (text) => this.theme.fg("dim", text),
99
+ },
100
+ );
101
+ this.list.setSelectedIndex(index);
102
+ this.list.onSelectionChange = (item) => {
103
+ this.selected = item.value;
104
+ };
105
+ this.list.onSelect = (item) => this.open(item.value);
106
+ this.list.onCancel = this.done;
107
+ }
108
+
109
+ private open(id: string): void {
110
+ // Mouse input can still name a row painted before its end. Recheck that
111
+ // exact id, rather than redirecting the click to a different live row.
112
+ this.refresh();
113
+ const entry = this.entries.find((candidate) => candidate.id === id);
114
+ if (!entry) {
115
+ this.tui.requestRender();
116
+ return;
117
+ }
118
+ this.viewing = id;
119
+ let position = this.positions.get(id);
120
+ if (!position) {
121
+ position = { offset: 0, follow: true };
122
+ this.positions.set(id, position);
123
+ }
124
+ this.pane = new TranscriptPane({
125
+ tui: this.tui,
126
+ theme: this.theme,
127
+ keys: this.keys,
128
+ source: entry.source,
129
+ heading: entry.heading,
130
+ cwd: this.cwd,
131
+ position,
132
+ markdownTheme: getMarkdownTheme(),
133
+ done: () => {
134
+ this.pane?.dispose();
135
+ this.pane = undefined;
136
+ this.viewing = undefined;
137
+ this.source.view(null);
138
+ this.refresh();
139
+ this.tui.requestRender();
140
+ },
141
+ });
142
+ this.source.view(id);
143
+ }
144
+
145
+ render(width: number): string[] {
146
+ this.refresh();
147
+ if (this.pane) {
148
+ try {
149
+ return this.pane.render(width);
150
+ } catch {
151
+ return [
152
+ truncateToWidth(
153
+ "Transcript could not be rendered · Esc returns to agents",
154
+ width,
155
+ ),
156
+ ];
157
+ }
158
+ }
159
+ if (width < 6) return [truncateToWidth("Agents", width)];
160
+ const at = this.entries.findIndex((entry) => entry.id === this.selected);
161
+ return [
162
+ labeledRule(
163
+ width,
164
+ (text) => this.theme.fg("border", text),
165
+ ["Running agents"],
166
+ [`${at + 1} / ${this.entries.length}`],
167
+ ),
168
+ ...(this.entries.length
169
+ ? (this.list?.render(width) ?? [])
170
+ : [
171
+ truncateToWidth(
172
+ this.theme.fg("dim", "No agents running in this session"),
173
+ width,
174
+ ),
175
+ ]),
176
+ truncateToWidth(
177
+ this.theme.fg("dim", "↑↓ select · Enter view · Esc return to input"),
178
+ width,
179
+ ),
180
+ ];
181
+ }
182
+
183
+ handleInput(data: string): void {
184
+ if (isKeyRelease(data)) return;
185
+ // An end can arrive between the last paint and Enter: never open a stale row.
186
+ this.refresh();
187
+ if (this.pane) this.pane.handleInput(data);
188
+ else this.list?.handleInput(data);
189
+ this.tui.requestRender();
190
+ }
191
+
192
+ handleMouse(event: TuiMouseEvent) {
193
+ if (this.pane) return this.pane.handleMouse(event);
194
+ return this.list?.handleMouse({
195
+ ...event,
196
+ y: event.y - 1,
197
+ height: Math.max(0, event.height - 2),
198
+ });
199
+ }
200
+
201
+ invalidate(): void {
202
+ this.signature = "";
203
+ this.list?.invalidate();
204
+ this.pane?.invalidate();
205
+ }
206
+
207
+ dispose(): void {
208
+ if (this.disposed) return;
209
+ this.disposed = true;
210
+ this.unsubscribe();
211
+ this.pane?.dispose();
212
+ this.source.view(null);
213
+ }
214
+ }