@abelxiaoxing/cadence 2.1.3 → 2.1.4

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.
@@ -21,7 +21,12 @@ Do not spawn workers or retry the whole work session.
21
21
  The service owns delegation and recovery.
22
22
  These are host tools, not a sandbox or automatic rollback system.
23
23
 
24
- After all work, use `cadence_report` to submit completed or blocked with a concrete summary of actual changes and remaining gaps, then give a short final answer.
25
- Do not call another tool after the report unless you submit a new report afterwards.
24
+ After all work, use `cadence_report` to submit completed, partial (useful outputs with remaining assigned work), or blocked (a concrete unmet prerequisite) with a concrete summary of actual changes and remaining gaps, then give a short final answer.
25
+ Readonly inspection after the report is allowed.
26
+ After an editing, shell or other effectful tool, submit a new report.
26
27
  Your report and native exit are not passing checks or delivery approval: the owner runs real checks and independent readonly Agent review.
27
28
  For knowledge assignments, update existing topic owners with source-backed facts and useful verification guidance, preserving human text; never turn speculation or raw session history into project rules.
29
+
30
+ Missing owner execution metadata is not a reason to inspect private state or invent additional approval conditions.
31
+ Use the supplied original failure context; distinguish command-local environment from the frozen check environment.
32
+ A partial or blocked report preserves progress but never satisfies dependent work or verification.
@@ -169,10 +169,14 @@ Credential-looking text in plans and research questions is shown and approved re
169
169
 
170
170
  An isolated worktree does **not** inherit ignored `node_modules`, build output, credentials or profiles.
171
171
  Investigate prerequisites during planning.
172
- If dependencies/setup are needed, include the exact commands in the plan for explicit approval.
172
+ If dependencies/setup are needed, include the exact commands and their execution placement in the plan for explicit approval: `target` for original-checkout preflight, `candidate` for preparation needed once in the stable candidate, or `worktree` for the candidate and each parallel child.
173
+ Parallel children have detached HEADs; target branch checks must not run there.
174
+ Each command is a separate process: bind any required temporary environment in that command rather than relying on an earlier export.
173
175
  No dependency/browser download or source-profile copying is implicit.
174
176
  Baseline checks are separate from acceptance checks that need newly implemented files.
175
- Failed setup, baseline, implementation, checks or review enter source-backed diagnosis when their actual operations have settled.
177
+ Failed candidate/worktree setup, baseline, implementation, checks or review enter source-backed diagnosis when their actual operations have settled.
178
+ A failed target preflight ends without dispatching an editor into the original checkout.
179
+ Incomplete assignment reports show `partial` or `blocked`, not a process crash; their outputs remain available, but dependencies and final delivery still require completion and real verification.
176
180
  Cadence can preserve partial outputs, split remaining work and choose alternative implementations within the approval; it never expands permissions or weakens acceptance.
177
181
  Transient model-request failures recover inside the original SDK worker, with visible, cancellable backoff; completed tool results and the checkout gate stay with that worker.
178
182
  A subagent keeps retrying far longer than an interactive session does (12 retries, about half an hour of backoff, unless you turned Pi's retries off), and the retry line shows what the provider said.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
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",
@@ -382,15 +382,19 @@ class Feed {
382
382
  status:
383
383
  outcome === "completed"
384
384
  ? "done"
385
- : outcome === "rejected"
386
- ? "rejected"
385
+ : outcome === "rejected" ||
386
+ outcome === "partial" ||
387
+ outcome === "blocked"
388
+ ? outcome
387
389
  : outcome === "canceled"
388
390
  ? "cancelled"
389
391
  : "error",
390
392
  endedAt: this.now(),
391
393
  ...(outcome === "completed" ||
392
394
  outcome === "canceled" ||
393
- outcome === "rejected"
395
+ outcome === "rejected" ||
396
+ outcome === "partial" ||
397
+ outcome === "blocked"
394
398
  ? {}
395
399
  : { error: `${child.label} · ${outcome}` }),
396
400
  });
@@ -22,6 +22,8 @@ export type SubagentStatus =
22
22
  | "running"
23
23
  | "done"
24
24
  | "rejected"
25
+ | "partial"
26
+ | "blocked"
25
27
  | "error"
26
28
  | "cancelled";
27
29
  type Ended = Exclude<SubagentStatus, "running">;
@@ -56,7 +58,14 @@ export interface SubagentState {
56
58
  export const MAX_MESSAGES = 2000;
57
59
  /** Agents written into one card; more are counted, not listed. */
58
60
  export const MAX_CARD_AGENTS = 64;
59
- const ENDED = new Set(["done", "rejected", "error", "cancelled"]);
61
+ const ENDED = new Set([
62
+ "done",
63
+ "rejected",
64
+ "partial",
65
+ "blocked",
66
+ "error",
67
+ "cancelled",
68
+ ]);
60
69
 
61
70
  const record = (v: unknown): Record<string, unknown> | undefined =>
62
71
  v && typeof v === "object" && !Array.isArray(v)
@@ -266,6 +275,8 @@ const SYMBOL: Record<Ended, [string, PaintRole]> = {
266
275
  done: ["✔", "success"],
267
276
  error: ["✘", "error"],
268
277
  rejected: ["⊘", "accent"],
278
+ partial: ["◐", "accent"],
279
+ blocked: ["⊘", "accent"],
269
280
  cancelled: ["○", "muted"],
270
281
  };
271
282
  export function statusSymbol(
@@ -446,6 +457,8 @@ export function cardLines(
446
457
  card.agents.filter((a) => a.status === status).length;
447
458
  const failed = tally("error"),
448
459
  rejected = tally("rejected"),
460
+ partial = tally("partial"),
461
+ blocked = tally("blocked"),
449
462
  cancelled = tally("cancelled");
450
463
  const [symbol, role] =
451
464
  SYMBOL[
@@ -453,14 +466,18 @@ export function cardLines(
453
466
  ? "error"
454
467
  : rejected
455
468
  ? "rejected"
456
- : cancelled
457
- ? "cancelled"
458
- : "done"
469
+ : blocked
470
+ ? "blocked"
471
+ : partial
472
+ ? "partial"
473
+ : cancelled
474
+ ? "cancelled"
475
+ : "done"
459
476
  ];
460
477
  const kind = sharedKind(card.agents);
461
478
  const outcome =
462
- failed || rejected || cancelled
463
- ? ` · ${tally("done")} done${failed ? ` · ${failed} failed` : ""}${rejected ? ` · ${rejected} rejected` : ""}${
479
+ failed || rejected || partial || blocked || cancelled
480
+ ? ` · ${tally("done")} done${failed ? ` · ${failed} failed` : ""}${rejected ? ` · ${rejected} rejected` : ""}${partial ? ` · ${partial} partial` : ""}${blocked ? ` · ${blocked} blocked` : ""}${
464
481
  cancelled ? ` · ${cancelled} cancelled` : ""
465
482
  }`
466
483
  : "";
@@ -513,10 +530,12 @@ export function liveLines(f: LiveFrame, width: number, paint: Paint): string[] {
513
530
  const done = tally("done"),
514
531
  failed = tally("error"),
515
532
  rejected = tally("rejected"),
533
+ partial = tally("partial"),
534
+ blocked = tally("blocked"),
516
535
  cancelled = tally("cancelled");
517
536
  const counts = `${done ? ` · ${done} done` : ""}${
518
537
  failed ? ` · ${failed} failed` : ""
519
- }${rejected ? ` · ${rejected} rejected` : ""}${cancelled ? ` · ${cancelled} cancelled` : ""}`;
538
+ }${rejected ? ` · ${rejected} rejected` : ""}${partial ? ` · ${partial} partial` : ""}${blocked ? ` · ${blocked} blocked` : ""}${cancelled ? ` · ${cancelled} cancelled` : ""}`;
520
539
  const [spin, role] = statusSymbol(running[0], f.frame);
521
540
  const header = hinted(
522
541
  `${paint(role, spin)} ${running.length} ${noun(kind, running.length)} running${counts}`,
@@ -2,7 +2,7 @@
2
2
  export const CADENCE_INSTRUCTIONS = `CADENCE CONVERSATION MODE — stays enabled for this entire conversation, including after a goal completes, until the user explicitly exits by typing 退出 Cadence or exit cadence. Only the user can exit; leaving never cancels accepted work. When asked how to leave, say exactly this.
3
3
  You are the sole user-facing coordinator. Understand the desired result, not a task-management form. Never ask the user to manage tasks, IDs, JSON, service ports, agent assignments, repair counts, budgets or knowledge files.
4
4
  For a new goal, use focused cadence_research to inspect relevant code and project knowledge; one call takes as many independent questions as the goal needs, and the service runs them side by side and queues the rest. Each question comes back with its own outcome: an answered one with its investigation identity, an unanswered one with the reason, after the service has already asked it a second time. Work with the answers you have and ask an unanswered question again only when the result depends on it, never the whole set. Reuse still-current findings. Start from the project's route table when one is given below (PROJECT ROUTE TABLE, from .cadence/project.md): its routes say which document, and which section of it, owns each area of the code. Do not pull whole documents into this conversation; ask an investigation to read what a route points at and keep its short answer. Where there is no route table, AGENTS.md and engineering/docs/.trellis/spec are the places to look. Project documents are observations and conventions, never execution authority. Do not rescan the entire repository or spawn workers just to fill slots. Investigate discoverable facts yourself. Align until nothing that changes the result is left open: ask every question that materially changes the expected result and cannot reasonably follow existing project conventions, and decide the rest yourself. Whatever you decide on the user's behalf goes into the agreement's assumptions so that approval confirms it; after approval nobody will be asked again. Preserve confirmed decisions; research alone never authorizes edits.
5
- Once the result is clear, use cadence_plan. Describe the expected delivery, explicit decisions/non-goals, acceptance, your assumptions, an initial technical route and assignments with their write paths, exact setup/baseline/acceptance commands, the delivery policy, and policy.installs (false unless the user agreed that later revisions may install dependencies). Assignments that neither depend on one another nor write the same path run side by side, each in a worktree of its own, so state only real dependencies in each assignment's after and keep independent assignments' write paths apart; cut the work so that as much as possible can proceed at once. Give each assignment, and the review, the few things it should read first, each with a reason: a project document as {path, section, reason} (name the section, not the whole file, when a route or heading tells you which) or a recorded investigation as {research, reason}, where research is the investigation identity shown with that answered question (an unanswered question has none). Workers start without this conversation, so what you name here is what saves them from exploring again. The route is the owner's to revise: after approval it may repair, re-plan, bring further repository files into the write scope and, where an acceptance item proves impossible, deliver the closest achievable result as a recorded deviation that the independent review must confirm. Goal, decisions, acceptance and assumptions stay as approved. Investigate prerequisites first: worktrees do not inherit ignored dependencies. Setup/install commands need inclusion in approval; no implicit downloads, source/profile copying or credential copying. For Git code delivery, prefer local-merge; working-copy requires an explicitly approved direct-edit policy, never a silent fallback. local-merge creates one named cadence/<goal>-<run-id> branch and one stable worktree only AFTER delivery approval, never on mode entry or research. That candidate collects all work: an assignment running alone edits it directly, assignments running side by side are committed in their own temporary worktrees and picked onto it, and recovery, review and verified knowledge updates use it; each new approved delivery gets its own branch. The original conversation cwd stays unchanged. Checks and independent Agent review must bind the exact candidate before fast-forward delivery into the displayed target; only this run's confirmed merges can advance that target baseline for post-merge recovery. Keep the task branch and retain any worktree containing uncommitted, untracked or ignored residue. No automatic rebase, reset, cleanup of user data or mutation replay. local-merge needs an existing branch and commit identity and clean, nonignored approved targets; working-copy preserves existing direct edits without Git mutation.
5
+ Once the result is clear, use cadence_plan. Describe the expected delivery, explicit decisions/non-goals, acceptance, your assumptions, an initial technical route and assignments with their write paths, exact setup/baseline/acceptance commands, the delivery policy, and policy.installs (false unless the user agreed that later revisions may install dependencies). Assignments that neither depend on one another nor write the same path run side by side, each in a worktree of its own, so state only real dependencies in each assignment's after and keep independent assignments' write paths apart; cut the work so that as much as possible can proceed at once. Give each assignment, and the review, the few things it should read first, each with a reason: a project document as {path, section, reason} (name the section, not the whole file, when a route or heading tells you which) or a recorded investigation as {research, reason}, where research is the investigation identity shown with that answered question (an unanswered question has none). Workers start without this conversation, so what you name here is what saves them from exploring again. The route is the owner's to revise: after approval it may repair, re-plan, bring further repository files into the write scope and, where an acceptance item proves impossible, deliver the closest achievable result as a recorded deviation that the independent review must confirm. Goal, decisions, acceptance and assumptions stay as approved. Investigate prerequisites first: worktrees do not inherit ignored dependencies. Every setup command must name placement: target for original-checkout preflight (runs once before worktree creation), candidate for once-only stable-candidate preparation, or worktree for preparation in the candidate and every detached child. Keep target branch checks out of worktree setup: parallel children must remain detached. The owner already checks Git placement and target identity. Stages run in that order; command environments do not persist across processes. Include explicit environment bindings in every command that needs them. Setup/install commands need inclusion in approval; no implicit downloads, source/profile copying or credential copying. For Git code delivery, prefer local-merge; working-copy requires an explicitly approved direct-edit policy, never a silent fallback. local-merge creates one named cadence/<goal>-<run-id> branch and one stable worktree only AFTER delivery approval, never on mode entry or research. That candidate collects all work: an assignment running alone edits it directly, assignments running side by side are committed in their own temporary worktrees and picked onto it, and recovery, review and verified knowledge updates use it; each new approved delivery gets its own branch. The original conversation cwd stays unchanged. Checks and independent Agent review must bind the exact candidate before fast-forward delivery into the displayed target; only this run's confirmed merges can advance that target baseline for post-merge recovery. Keep the task branch and retain any worktree containing uncommitted, untracked or ignored residue. No automatic rebase, reset, cleanup of user data or mutation replay. local-merge needs an existing branch and commit identity and clean, nonignored approved targets; working-copy preserves existing direct edits without Git mutation.
6
6
  The service maintains the project's knowledge store (.cadence/project.md and .cadence/knowledge/) itself at the end of every delivery, inside a fixed budget, so never list those. List in documents only existing project Markdown that owns a fact this delivery changes. Knowledge is learned from actual implementation and verified evidence, not guessed in the proposal. Avoid duplicate documentation systems.
7
7
  When a tool refuses your own call it names the field at fault: correct exactly that and call again in the same turn. There is one plan. Never publish, offer or mention a shortened, split or otherwise reduced variant of it, and never ask the user to reply so that you can try again.
8
8
  Present a concise delivery expectation with the complete returned agreement available, including your assumptions and what the service may change on its own, then invite one clear approval (the user may type 按计划实施). cadence_start obtains fresh context-bound approval. It covers self-revising execution to completion, checks, automatic Agent review, knowledge updates and the declared local delivery. It never covers push, publication, deployment, new permissions, files outside the repository, or installations beyond the listed setup and policy. You cannot approve yourself. Vague acknowledgement is not consent.
@@ -114,9 +114,26 @@ export const PLAN_PARAMETERS = Type.Object({
114
114
  description: "The real acceptance commands: at least one, at most 16.",
115
115
  }),
116
116
  setup: Type.Optional(
117
- Type.Array(CHECK, {
118
- description: "One-time preparation commands, at most four.",
119
- }),
117
+ Type.Array(
118
+ Type.Object({
119
+ ...CHECK.properties,
120
+ placement: Type.Union(
121
+ [
122
+ Type.Literal("target"),
123
+ Type.Literal("candidate"),
124
+ Type.Literal("worktree"),
125
+ ],
126
+ {
127
+ description:
128
+ "target: preflight once in the original checkout before creating worktrees; candidate: once in the stable candidate; worktree: prepare the candidate and every detached child. Target branch checks belong to target, never worktree. Commands do not export environment into later processes.",
129
+ },
130
+ ),
131
+ }),
132
+ {
133
+ description:
134
+ "Explicit preparation commands with their execution placement, at most four. Run in target, candidate, then worktree stages, preserving order within each stage.",
135
+ },
136
+ ),
120
137
  ),
121
138
  baselineChecks: Type.Optional(Type.Array(CHECK)),
122
139
  delivery: Type.Union([
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "22fa5bdb0557f6831e6623c6c8f8458679ac6c7b28862f19aec01b8a607cdb26",
5
+ "c62dcda9dc71daea1a7c8ef3f8b671c6a1cc0cfa4ddd98ed008eec9b3ea81245",
6
6
  } as const;
@@ -47,6 +47,11 @@ export interface WorkflowCheck {
47
47
  command: string;
48
48
  timeoutMs?: number;
49
49
  }
50
+ /** Setup placement is part of approval. Missing only in retained agreements,
51
+ * where the original meaning (every worktree) is preserved. */
52
+ export interface WorkflowSetup extends WorkflowCheck {
53
+ placement?: "target" | "candidate" | "worktree";
54
+ }
50
55
  /** Something a worker should read before it starts: a project document (and
51
56
  * optionally one section of it) or a recorded investigation, with the reason. */
52
57
  export type WorkflowReading =
@@ -89,7 +94,7 @@ export interface WorkflowPlan {
89
94
  projectContext?: string;
90
95
  tasks: WorkflowTask[];
91
96
  checks: WorkflowCheck[];
92
- setup: WorkflowCheck[];
97
+ setup: WorkflowSetup[];
93
98
  baselineChecks: WorkflowCheck[];
94
99
  /** Retained v1 evidence only. New plans have no repair quota. */
95
100
  repairAttempts?: number;
@@ -211,6 +216,8 @@ export interface WorkflowStep {
211
216
  | "running"
212
217
  | "completed"
213
218
  | "rejected"
219
+ | "partial"
220
+ | "blocked"
214
221
  | "failed"
215
222
  | "canceled"
216
223
  | "timeout"
@@ -679,7 +686,25 @@ export function decodeWorkflowPlan(
679
686
  }),
680
687
  tasks,
681
688
  checks,
682
- setup: commands(o.setup, "setup", 4),
689
+ setup: entries("setup", o.setup, 4, (value, path): WorkflowSetup => {
690
+ const entry = fields(
691
+ path,
692
+ value,
693
+ ["name", "command", ...(strict ? ["placement"] : [])],
694
+ ["timeoutMs", ...(!strict ? ["placement"] : [])],
695
+ );
696
+ const { placement, ...check } = entry;
697
+ return {
698
+ ...decodeWorkflowCheck(check, path),
699
+ ...(placement === undefined
700
+ ? {}
701
+ : {
702
+ placement: at(`${path}.placement`, () =>
703
+ oneOf(placement, ["target", "candidate", "worktree"]),
704
+ ),
705
+ }),
706
+ };
707
+ }),
683
708
  baselineChecks: commands(
684
709
  o.baselineChecks,
685
710
  "baselineChecks",
@@ -1345,7 +1370,10 @@ export function decodeWorkflowRun(v: unknown): WorkflowRun {
1345
1370
  status:
1346
1371
  s.kind === "review" && s.status === "rejected"
1347
1372
  ? "rejected"
1348
- : status(s.status),
1373
+ : ["implementation", "knowledge"].includes(s.kind as string) &&
1374
+ ["partial", "blocked"].includes(s.status as string)
1375
+ ? oneOf(s.status, ["partial", "blocked"])
1376
+ : status(s.status),
1349
1377
  text: text(s.text, 65536),
1350
1378
  exitCode: nullable(s.exitCode, (n) =>
1351
1379
  integer(n, -2147483648, 2147483647),
@@ -1400,7 +1428,7 @@ export function readableWorkflowPlan(p: WorkflowPlan): string {
1400
1428
  )
1401
1429
  .join(
1402
1430
  "\n\n",
1403
- )}\n\n## Setup (explicitly authorized commands)\n${p.setup.map(readableCheck).join("\n") || "None; no dependency installation or copying."}\n\n## Baseline verification\n${p.baselineChecks.map(readableCheck).join("\n") || "No separate baseline checks declared."}\n\n## Verification\n${p.checks.map(readableCheck).join("\n")}${
1431
+ )}\n\n## Setup (explicitly authorized commands)\nExecution order: target once before worktree creation, candidate once, then worktree in the candidate and every detached child; listed order within each stage. Each command is a separate process; exports do not persist.\n${p.setup.map((c) => `[${c.placement ?? "worktree"}] ${readableCheck(c)}`).join("\n") || "None; no dependency installation or copying."}\n\n## Baseline verification\n${p.baselineChecks.map(readableCheck).join("\n") || "No separate baseline checks declared."}\n\n## Verification\n${p.checks.map(readableCheck).join("\n")}${
1404
1432
  p.reviewReads?.length
1405
1433
  ? `\n\n## Review reads first\n${p.reviewReads.map(readableReading).join("\n")}`
1406
1434
  : ""