@abelxiaoxing/cadence 2.1.5 → 2.1.7

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.
@@ -19,6 +19,7 @@ Browser conversation mode is retained by the project owner, not by a browser-onl
19
19
  The automatic review must confirm each deviation, and a run that deviated says so first when it completes; the task branch is kept, so the merge can be undone.
20
20
  4. Type `按计划实施` after the plan to authorize those exact bytes.
21
21
  In the browser, click **Implement this plan** or send that exact approval phrase for the currently displayed plan.
22
+ If execution is stopped or its plan binding is outdated, this first restores and validates the plan instead; review the updated context and choose **Confirm implementation** afterward (see below).
22
23
  In Pi, the Start tool can alternatively present one native confirmation of the complete plan.
23
24
  Native confirmation retains its raw-terminal guard.
24
25
  Quoted/generated text, an old session entry and vague agreement are not approval; browser authentication alone is not consent.
@@ -43,6 +44,24 @@ Opening a different conversation does not enable Cadence there.
43
44
  Restore never replays a command or automatically resumes an interrupted queue.
44
45
  When an observation reply is lost, ask for status; do not infer that the action was absent.
45
46
 
47
+ ## Restore a saved plan without sending a message
48
+
49
+ A stopped or restarted execution service does not require another discussion or a model-generated replacement plan.
50
+ Use **Restore execution and validate plan** on the plan card; if the service is already running, **Validate plan again** refreshes its execution context.
51
+ The exact `按计划实施` input follows the same validation path when the service or model binding is not current.
52
+
53
+ Validation may start or reuse the selected project's owner and applies the model shown in the composer, without substituting another model or changing the account's default.
54
+ It keeps the plan content, records a fresh execution binding and leaves the original snapshot intact.
55
+ It sends no chat message, calls no model, creates no task branch/worktree and approves no implementation.
56
+ Review the displayed model, runtime and target branch/base; changed environment evidence is labelled, and this tab also shows the previous context for comparison.
57
+ Then click **Confirm implementation** or send the approval phrase again to approve that fresh snapshot.
58
+ A current plan remains directly approvable; validation is not an extra step for every ordinary approval.
59
+
60
+ An unknown turn outcome, unreadable plan, changed conversation or unavailable selected model still blocks safely.
61
+ If an approval reply is lost, the page observes its original request rather than submitting another execution; reloading does not repeat it.
62
+ Browsing, reconnecting and choosing a model alone never start the execution service.
63
+ `CADENCE_AUTOSTART=0` still refuses on-demand startup, not healthy reuse.
64
+
46
65
  ## Messages while a reply is running
47
66
 
48
67
  The service accepts a further message for a reply that is still running, in one of two ways.
@@ -64,7 +83,7 @@ A link grants neither access nor plan approval: authenticate normally and make a
64
83
  Without that complete link, the other browser is not promised an automatic return to the first browser's last conversation.
65
84
 
66
85
  Opening the link only observes; browsing never prepares or starts the project's execution service.
67
- Only an explicit **Send** may prepare it on demand.
86
+ Only an explicit **Send** or plan-validation action may prepare it on demand.
68
87
  Leaving, closing or disconnecting a viewer does not cancel accepted work; reconnecting does not resend a message, resume an interrupted queue or inherit approval.
69
88
  A stale or unavailable observation keeps readable history but cannot establish that work stopped; distinguish connection freshness from the workflow's last observed status.
70
89
 
@@ -106,7 +125,7 @@ A choice on the folder-less entry carries into the next new conversation you ope
106
125
  Send starts or reuses the project service, verifies that exact selection and only then submits the message; if it is unavailable, the draft stays and no other model is substituted.
107
126
  The picker reuses its already-read preview when reopened; **Refresh models** reads the configuration again without starting execution.
108
127
  A preview read failure has a **Read again** action, not a requirement to start a service.
109
- The browser restores an available saved preference on explicit Send and shows it dimmed until then; reads/login do not install a choice.
128
+ The browser restores an available saved preference on explicit Send or plan validation and shows it dimmed until then; reads/login do not install a choice.
110
129
  With no choice and no saved preference, Send opens the model list and continues the original message after your choice when the same service connection is ready.
111
130
  Closing the picker or stopping/replacing that service ends the unsent continuation; your draft stays, and choosing a model never restarts a stopped service.
112
131
  Exiting Cadence changes mode, not your pending model choice.
@@ -114,7 +133,7 @@ If no usable preference exists, choose once; an unreadable preference file falls
114
133
  An accepted message or workflow keeps its original directory and exact model, including while queued.
115
134
  Different subdirectories of one repository can have independent conversations while sharing one checkout owner and execution gate.
116
135
  Tools and check commands use the conversation directory; a plan's declared write paths stay relative to the displayed checkout root, including in isolated Git worktrees.
117
- Changing the current conversation's model makes its older unaccepted plan require fresh planning/approval; changing another conversation's model does not.
136
+ Changing the current conversation's model makes its older unaccepted plan require fresh validation and approval in the browser, not another chat message; changing another conversation's model does not.
118
137
  An unavailable remembered model is not silently substituted.
119
138
  Pi's original model and authentication sources remain authoritative; Cadence does not copy credentials.
120
139
 
@@ -220,7 +239,7 @@ If a native dialogue stops, distinguish exhausted retries from disabled/overridd
220
239
 
221
240
  ## Service and compatibility
222
241
 
223
- An explicit native mode entry/current user Send may start or reuse its local project owner on demand.
242
+ An explicit native mode entry, current user Send or browser plan-validation action may start or reuse its local project owner on demand.
224
243
  It does not install a system service, enable boot startup, select another account's credentials or expose a public listener.
225
244
  Pi says once which command stops an owner it started; when Pi runs on Bun, Node must be on `PATH`.
226
245
  An existing owner/configuration is reused, not silently replaced after a connection failure.
@@ -60,7 +60,8 @@ If the conversation cannot be read, Send can prepare execution but cannot infer
60
60
  Preparation failure keeps the draft; an owner may already have started, but the message was not sent.
61
61
  If the actual Send reply is lost instead, its original command is observed, never resubmitted automatically.
62
62
  Project navigation remounts only the browser client; the original owner's work continues.
63
- Browser proxy traffic keeps browser authority and the owner's own attachments, CSRF/build checks, grants and history proofs; native management routes and local-capability headers are not forwarded.
63
+ Browser proxy traffic keeps browser authority and the owner's own attachments, CSRF checks, grants and history proofs; native management routes and local-capability headers are not forwarded.
64
+ Build differences never block an authenticated page or require restarting work.
64
65
  The gateway also refuses the legacy project-level Open command, so every Send preparation is associated through the workbench instead of returning an independent backend token link.
65
66
  The gateway's token, backend cookies and native capabilities are never returned in project DTOs or stored in browser localStorage.
66
67
  Token rotation retires and detaches its exact browser attachments without cancelling admitted work.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
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",
@@ -16,7 +16,6 @@ import { LIMITS } from "./service-contract.ts";
16
16
  export interface FeedConnection {
17
17
  attach(cwd: string): Promise<FeedClient>;
18
18
  refresh(): Promise<unknown>;
19
- compatible(): boolean;
20
19
  detach(): Promise<void>;
21
20
  forgetSuperseded?(cwd: string): boolean;
22
21
  }
@@ -243,7 +242,6 @@ class Feed {
243
242
  await this.connection.detach().catch(() => {});
244
243
  return;
245
244
  }
246
- if (!this.connection.compatible()) throw new Error("incompatible");
247
245
  this.client = client;
248
246
  }
249
247
  await this.observe(this.client);
@@ -435,9 +435,7 @@ export function registerCadenceMode(pi: ExtensionAPI): void {
435
435
  if (generation !== expected) throw new ContractError("stale");
436
436
  };
437
437
  const operation = (async () => {
438
- const broken =
439
- !!connection.client &&
440
- (reattach || !connection.session || !connection.compatible());
438
+ const broken = !!connection.client && (reattach || !connection.session);
441
439
  if (connection.client && !broken) return;
442
440
  reattach = false;
443
441
  if (broken) connection.forgetSuperseded(ctx.cwd);
@@ -548,18 +546,7 @@ export function registerCadenceMode(pi: ExtensionAPI): void {
548
546
  active(ctx);
549
547
  await ensureAttached(ctx);
550
548
  if (generation !== expected) throw new ContractError("stale");
551
- if (!connection.client || !connection.compatible()) {
552
- reattach = true;
553
- let stop = "its explicit stop command";
554
- try {
555
- stop = projectStopCommand(effectiveWorkspace(ctx.cwd).workspace);
556
- } catch {
557
- // The guidance keeps its generic wording.
558
- }
559
- throw new Error(
560
- `unsupported-context: the running Cadence project owner does not match this Cadence build or its WebUI assets. Nothing was started or replaced. When no accepted work is running, stop it with ${stop}; the next Cadence use starts the matching version.`,
561
- );
562
- }
549
+ if (!connection.client) throw new ContractError("unavailable");
563
550
  if (selectModel) await ensureModel(ctx);
564
551
  if (generation !== expected) throw new ContractError("stale");
565
552
  };
@@ -295,7 +295,6 @@ export function registerHistoryShell(pi: ExtensionAPI): void {
295
295
  attached = true;
296
296
  const session = connection.session;
297
297
  if (!session) throw new ContractError("unavailable");
298
- if (!connection.compatible()) ui.notify(MANAGEMENT_GUIDANCE);
299
298
  const workspace = value(await client.workspace(signal));
300
299
  current();
301
300
  if (
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "c62dcda9dc71daea1a7c8ef3f8b671c6a1cc0cfa4ddd98ed008eec9b3ea81245",
5
+ "6aa819700494584b707a8e1b44428c532cd7ac7b1c8a28126e401b43f527543b",
6
6
  } as const;
@@ -8,16 +8,12 @@ import { Agent, Dispatcher1Wrapper } from "undici";
8
8
  import { nativeBuild } from "./native-build.ts";
9
9
  import { ServiceCoordination } from "./service/coordination.ts";
10
10
  import { ServiceClient } from "./service-client.ts";
11
- import {
12
- ContractError,
13
- compatibleBuild,
14
- type SessionBootstrap,
15
- } from "./service-contract.ts";
11
+ import { ContractError, type SessionBootstrap } from "./service-contract.ts";
16
12
  import { HttpServiceTransport } from "./service-http-client.ts";
17
13
  import { effectiveWorkspace } from "./workspace.ts";
18
14
 
19
15
  export const MANAGEMENT_GUIDANCE =
20
- "Cadence owner absent, unavailable or incompatible. Start it with cadence start --workspace <path> (it recovers automatically from an unclean shutdown), or see what is wrong with cadence doctor --workspace <path>. Stop older Cadence sessions first. No service was started and no embedded executor is available.";
16
+ "Cadence owner absent or unavailable. Start it with cadence start --workspace <path> (it recovers automatically from an unclean shutdown), or see what is wrong with cadence doctor --workspace <path>. No service was started and no embedded executor is available.";
21
17
 
22
18
  const UNIT = "cadence.service";
23
19
  const LABEL = "com.abelxiaoxing.cadence";
@@ -249,9 +245,6 @@ export class NativeConnection {
249
245
  this.session = reply.value;
250
246
  return reply.value;
251
247
  }
252
- compatible(safety = false): boolean {
253
- return compatibleBuild(this.session?.build, nativeBuild, safety);
254
- }
255
248
  /** Forget an attachment only when the registry proves its owner instance is
256
249
  * gone: absent, stopped, or replaced by another epoch. Its slot ended with
257
250
  * that process, so no detach request is sent and a later attach may proceed.
@@ -1,4 +1,4 @@
1
- /** Compatibility is independent of authentication and of task confirmation. */
1
+ /** Build provenance for diagnostics and packaged assets, never access authority. */
2
2
  import { closed, decodeHash, oneOf } from "./core.ts";
3
3
  export interface BrowserBuild {
4
4
  sourceHash: string;
@@ -49,19 +49,3 @@ export function decodeServiceBuild(value: unknown): ServiceBuild {
49
49
  assets: decodeBrowserBuild(o.assets),
50
50
  };
51
51
  }
52
- export function compatibleBuild(
53
- server: ServiceBuild | undefined,
54
- client: ClientBuild | null,
55
- safety = false,
56
- ): boolean {
57
- return (
58
- !!server &&
59
- !!client &&
60
- client.contractHash === server.contractHash &&
61
- (safety ||
62
- (server.assets.contractHash === server.contractHash &&
63
- (client.kind === "native" ||
64
- (client.buildId === server.assets.buildId &&
65
- client.sourceHash === server.assets.sourceHash))))
66
- );
67
- }
@@ -221,6 +221,19 @@ export type WorkbenchCommand =
221
221
  revision: number;
222
222
  intent: "message" | "enter" | "exit";
223
223
  }
224
+ | {
225
+ /** Explicitly refresh an unchanged agreement's execution binding. No grant or execution. */
226
+ kind: "cadence-revalidate";
227
+ commandId: string;
228
+ conversationId: string;
229
+ revision: number;
230
+ proposalId: string;
231
+ digest: string;
232
+ head: string | null;
233
+ context: ConversationContext;
234
+ expected: ChoiceVersion;
235
+ model: ModelSelector;
236
+ }
224
237
  | {
225
238
  kind: "cadence-prepare";
226
239
  commandId: string;
@@ -552,6 +565,11 @@ export type WorkbenchResult =
552
565
  turn: ChatTurn | null;
553
566
  }
554
567
  | { kind: "cadence-conversation"; state: CadenceConversation }
568
+ | {
569
+ kind: "cadence-revalidated";
570
+ commandId: string;
571
+ state: CadenceConversation;
572
+ }
555
573
  | {
556
574
  kind: "workflow-active";
557
575
  runs: WorkflowRun[];
@@ -973,6 +991,35 @@ export function decodeWorkbenchCommand(v: unknown): WorkbenchCommand {
973
991
  intent: oneOf(o.intent, ["message", "enter", "exit"]),
974
992
  };
975
993
  }
994
+ if (kind === "cadence-revalidate") {
995
+ const o = closed(v, [
996
+ "kind",
997
+ "commandId",
998
+ "conversationId",
999
+ "revision",
1000
+ "proposalId",
1001
+ "digest",
1002
+ "head",
1003
+ "context",
1004
+ "expected",
1005
+ "model",
1006
+ ]);
1007
+ const conversationId = decodeSessionId(o.conversationId);
1008
+ const context = decodeConversationContext(o.context);
1009
+ if (context.id !== conversationId) throw new ContractError("invalid");
1010
+ return {
1011
+ kind,
1012
+ commandId: decodeId(o.commandId),
1013
+ conversationId,
1014
+ revision: integer(o.revision, 0),
1015
+ proposalId: decodeId(o.proposalId),
1016
+ digest: decodeHash(o.digest),
1017
+ head: nullable(o.head, decodeEntryId),
1018
+ context,
1019
+ expected: decodeChoiceVersion(o.expected),
1020
+ model: decodeModelSelector(o.model),
1021
+ };
1022
+ }
976
1023
  if (kind === "cadence-prepare" || kind === "cadence-approve") {
977
1024
  const keys = [
978
1025
  "kind",
@@ -1411,6 +1458,14 @@ export function decodeWorkbenchResult(v: unknown): WorkbenchResult {
1411
1458
  throw new ContractError("invalid");
1412
1459
  return { kind: k, runs, links };
1413
1460
  }
1461
+ if (k === "cadence-revalidated") {
1462
+ const o = closed(v, ["kind", "commandId", "state"]);
1463
+ return {
1464
+ kind: k,
1465
+ commandId: decodeId(o.commandId),
1466
+ state: decodeCadenceConversation(o.state),
1467
+ };
1468
+ }
1414
1469
  if (k === "cadence-grant") {
1415
1470
  const o = closed(v, [
1416
1471
  "kind",
@@ -159,6 +159,8 @@ export interface DeliveryObservation {
159
159
  cleanup: { status: "pending" | "removed" | "retained"; reason: string };
160
160
  }
161
161
  export interface WorkflowProposal {
162
+ /** Immutable prior binding of the same plan; never inherited execution consent. */
163
+ revalidatedFrom?: string;
162
164
  delivery?: DeliveryBinding;
163
165
  id: string;
164
166
  epoch: string;
@@ -1113,9 +1115,13 @@ export function decodeWorkflowProposal(v: unknown): WorkflowProposal {
1113
1115
  "cwd",
1114
1116
  ...(Object.hasOwn(v ?? {}, "checkoutRoot") ? ["checkoutRoot"] : []),
1115
1117
  ...(Object.hasOwn(v ?? {}, "delivery") ? ["delivery"] : []),
1118
+ ...(Object.hasOwn(v ?? {}, "revalidatedFrom") ? ["revalidatedFrom"] : []),
1116
1119
  ...(modern ? ["display"] : []),
1117
1120
  ]);
1118
1121
  return {
1122
+ ...(o.revalidatedFrom === undefined
1123
+ ? {}
1124
+ : { revalidatedFrom: decodeId(o.revalidatedFrom) }),
1119
1125
  ...(o.delivery === undefined
1120
1126
  ? {}
1121
1127
  : { delivery: decodeDeliveryBinding(o.delivery) }),