@oyasmi/pipiclaw 0.9.3-beta.5 → 0.9.3

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 (144) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/agent/channel-runner.d.ts +4 -8
  4. package/dist/agent/channel-runner.js +14 -34
  5. package/dist/agent/job-manager.d.ts +12 -0
  6. package/dist/agent/job-manager.js +42 -1
  7. package/dist/agent/prompt/sections.js +2 -2
  8. package/dist/agent/runner-factory.d.ts +2 -2
  9. package/dist/agent/types.d.ts +11 -7
  10. package/dist/channel/channel-index.d.ts +9 -2
  11. package/dist/channel/channel-index.js +25 -6
  12. package/dist/channel/project-scope-store.d.ts +20 -0
  13. package/dist/channel/project-scope-store.js +22 -7
  14. package/dist/commands/catalog.js +6 -12
  15. package/dist/events/event-commands.js +2 -2
  16. package/dist/events/events.d.ts +51 -30
  17. package/dist/events/events.js +70 -98
  18. package/dist/memory/journal.d.ts +2 -3
  19. package/dist/memory/journal.js +2 -3
  20. package/dist/memory/maintenance-tuning.d.ts +0 -1
  21. package/dist/memory/maintenance-tuning.js +0 -1
  22. package/dist/memory/scheduler.js +8 -16
  23. package/dist/memory/search.js +2 -3
  24. package/dist/memory/session-search.js +3 -9
  25. package/dist/memory/store.d.ts +1 -1
  26. package/dist/memory/store.js +9 -1
  27. package/dist/memory/task-digest.js +10 -11
  28. package/dist/memory/tombstones.js +2 -4
  29. package/dist/models/provider-login.d.ts +1 -1
  30. package/dist/models/provider-login.js +1 -1
  31. package/dist/playbooks/agent-delegation.md +6 -6
  32. package/dist/playbooks/background-jobs.md +1 -1
  33. package/dist/playbooks/event-scheduling.md +22 -13
  34. package/dist/playbooks/memory-and-learning.md +2 -2
  35. package/dist/playbooks/outbound-media.md +1 -1
  36. package/dist/playbooks/runtime-orientation.md +3 -3
  37. package/dist/playbooks/task-lead.md +82 -0
  38. package/dist/runtime/bootstrap.js +94 -187
  39. package/dist/runtime/durable-dispatch.js +30 -3
  40. package/dist/runtime/report-commands.d.ts +30 -0
  41. package/dist/runtime/report-commands.js +71 -0
  42. package/dist/runtime/subagent-commands.js +1 -1
  43. package/dist/runtime/task-commands.d.ts +0 -8
  44. package/dist/runtime/task-commands.js +48 -85
  45. package/dist/runtime/task-driver.d.ts +15 -10
  46. package/dist/runtime/task-driver.js +36 -41
  47. package/dist/runtime/task-migration.d.ts +23 -29
  48. package/dist/runtime/task-migration.js +364 -183
  49. package/dist/runtime/task-spawn.d.ts +24 -0
  50. package/dist/runtime/task-spawn.js +49 -0
  51. package/dist/runtime/task-wake.d.ts +33 -46
  52. package/dist/runtime/task-wake.js +15 -90
  53. package/dist/security/network.js +44 -9
  54. package/dist/settings.d.ts +1 -8
  55. package/dist/settings.js +1 -8
  56. package/dist/subagents/discovery.js +3 -15
  57. package/dist/subagents/external/run.d.ts +3 -1
  58. package/dist/subagents/external/run.js +2 -20
  59. package/dist/subagents/external/settlement.d.ts +4 -16
  60. package/dist/subagents/external/settlement.js +16 -67
  61. package/dist/subagents/runs.d.ts +15 -29
  62. package/dist/subagents/runs.js +70 -158
  63. package/dist/subagents/tool.d.ts +20 -4
  64. package/dist/subagents/tool.js +63 -87
  65. package/dist/subagents/verification-outcome.d.ts +13 -19
  66. package/dist/subagents/verification-outcome.js +8 -22
  67. package/dist/subagents/workspace-summary.d.ts +8 -0
  68. package/dist/subagents/workspace-summary.js +29 -0
  69. package/dist/tasks/board.d.ts +43 -0
  70. package/dist/tasks/board.js +134 -0
  71. package/dist/tasks/brief.d.ts +10 -5
  72. package/dist/tasks/brief.js +78 -26
  73. package/dist/tasks/budget.d.ts +13 -14
  74. package/dist/tasks/budget.js +21 -40
  75. package/dist/tasks/contract-input.d.ts +19 -0
  76. package/dist/tasks/contract-input.js +55 -0
  77. package/dist/tasks/create.d.ts +17 -0
  78. package/dist/tasks/create.js +36 -0
  79. package/dist/tasks/frontmatter.d.ts +20 -27
  80. package/dist/tasks/frontmatter.js +18 -31
  81. package/dist/tasks/ledger.d.ts +61 -117
  82. package/dist/tasks/ledger.js +78 -223
  83. package/dist/tasks/log.d.ts +62 -35
  84. package/dist/tasks/log.js +51 -29
  85. package/dist/tasks/session-path.d.ts +3 -3
  86. package/dist/tasks/session-path.js +4 -5
  87. package/dist/tasks/store.d.ts +27 -28
  88. package/dist/tasks/store.js +89 -83
  89. package/dist/tasks/ticket.d.ts +33 -66
  90. package/dist/tasks/ticket.js +31 -120
  91. package/dist/tasks/work-log.d.ts +20 -0
  92. package/dist/tasks/work-log.js +42 -0
  93. package/dist/tools/bash.d.ts +1 -1
  94. package/dist/tools/bash.js +1 -1
  95. package/dist/tools/event-manage.d.ts +16 -2
  96. package/dist/tools/event-manage.js +30 -12
  97. package/dist/tools/index.d.ts +5 -3
  98. package/dist/tools/index.js +5 -5
  99. package/dist/tools/registry.d.ts +6 -4
  100. package/dist/tools/registry.js +1 -4
  101. package/dist/tools/subagent-manage.js +4 -2
  102. package/dist/tools/task-manage/create.js +11 -27
  103. package/dist/tools/task-manage/lifecycle.d.ts +6 -7
  104. package/dist/tools/task-manage/lifecycle.js +23 -106
  105. package/dist/tools/task-manage/log-view.d.ts +3 -2
  106. package/dist/tools/task-manage/log-view.js +6 -6
  107. package/dist/tools/task-manage/schema.d.ts +10 -30
  108. package/dist/tools/task-manage/schema.js +33 -49
  109. package/dist/tools/task-manage/shared.d.ts +35 -42
  110. package/dist/tools/task-manage/shared.js +53 -192
  111. package/dist/tools/task-manage/step-end.d.ts +6 -6
  112. package/dist/tools/task-manage/step-end.js +61 -98
  113. package/dist/tools/task-manage/types.d.ts +8 -9
  114. package/dist/tools/task-manage.js +5 -5
  115. package/dist/tui/app.js +11 -38
  116. package/dist/tui/commands.d.ts +18 -8
  117. package/dist/tui/commands.js +2 -9
  118. package/dist/tui/turn-controller.d.ts +2 -14
  119. package/dist/tui/turn-controller.js +1 -17
  120. package/dist/web/client.js +9 -1
  121. package/examples/sub-agents/README.md +7 -4
  122. package/examples/sub-agents/agents/codex-flash.md +2 -2
  123. package/examples/sub-agents/agents/codex-high.md +1 -1
  124. package/examples/sub-agents/agents/codex-main.md +1 -1
  125. package/examples/sub-agents/agents/codex-review.md +23 -0
  126. package/examples/sub-agents/roles/verifier.md +1 -1
  127. package/package.json +1 -1
  128. package/dist/memory/maintenance-migration.d.ts +0 -5
  129. package/dist/memory/maintenance-migration.js +0 -91
  130. package/dist/memory/migrate.d.ts +0 -15
  131. package/dist/memory/migrate.js +0 -364
  132. package/dist/playbooks/task-loop.md +0 -90
  133. package/dist/tasks/artifact-subject.d.ts +0 -40
  134. package/dist/tasks/artifact-subject.js +0 -334
  135. package/dist/tasks/cycle.d.ts +0 -48
  136. package/dist/tasks/cycle.js +0 -94
  137. package/dist/tasks/rounds.d.ts +0 -41
  138. package/dist/tasks/rounds.js +0 -53
  139. package/dist/tasks/task-events.d.ts +0 -6
  140. package/dist/tasks/task-events.js +0 -14
  141. package/dist/tasks/task-schedule.d.ts +0 -18
  142. package/dist/tasks/task-schedule.js +0 -50
  143. package/dist/tasks/verification.d.ts +0 -114
  144. package/dist/tasks/verification.js +0 -226
@@ -3,7 +3,9 @@ import { isPlainObject } from "../shared/type-guards.js";
3
3
  import { parseTicket } from "./ticket.js";
4
4
  const STATES = ["open", "parked", "done"];
5
5
  /** Fixed render order, so a diff of a task file reads the same way every time. */
6
- const FIELD_ORDER = ["state", "paused", "schedule", "ticket", "cycle", "budget", "verify"];
6
+ const FIELD_ORDER = ["state", "paused", "origin", "ticket", "usage", "budget"];
7
+ /** v3 frontmatter keys; their presence means the one-time conversion has not run on this file. */
8
+ const LEGACY_KEYS = new Set(["status", "enabled", "control", "wake", "schedule"]);
7
9
  function parseJsonObject(raw) {
8
10
  try {
9
11
  const value = JSON.parse(raw);
@@ -27,15 +29,13 @@ function parsePaused(raw) {
27
29
  function nonNegativeNumber(value, fallback) {
28
30
  return typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
29
31
  }
30
- function parseCycle(raw) {
32
+ function parseUsage(raw) {
31
33
  const value = parseJsonObject(raw);
32
- if (!value || typeof value.id !== "string" || !value.id.trim())
34
+ if (!value)
33
35
  return undefined;
34
36
  return {
35
- id: value.id.trim(),
36
37
  startedAt: typeof value.startedAt === "string" && value.startedAt ? value.startedAt : formatLocalTime(),
37
38
  steps: nonNegativeNumber(value.steps, 0),
38
- rounds: nonNegativeNumber(value.rounds, 0),
39
39
  usd: nonNegativeNumber(value.usd, 0),
40
40
  usdEstimated: value.usdEstimated === true,
41
41
  expired: nonNegativeNumber(value.expired, 0),
@@ -48,22 +48,16 @@ function parseBudget(raw) {
48
48
  const budget = {};
49
49
  if (typeof value.steps === "number" && value.steps > 0)
50
50
  budget.steps = value.steps;
51
- if (typeof value.wallMin === "number" && value.wallMin > 0)
52
- budget.wallMin = value.wallMin;
53
51
  if (typeof value.usd === "number" && value.usd > 0)
54
52
  budget.usd = value.usd;
55
- if (typeof value.rounds === "number" && value.rounds > 0)
56
- budget.rounds = value.rounds;
57
- if (typeof value.until === "string" && value.until.trim())
58
- budget.until = value.until.trim();
59
53
  return Object.keys(budget).length > 0 ? budget : undefined;
60
54
  }
61
55
  /**
62
56
  * Read the leading frontmatter block. Unreadable input fails **open** to a live `open` task: a
63
57
  * corrupt file has to surface as work the runtime tries to touch, not silently disappear from the
64
- * ledger — the same fail-open stance v3 took, for the same reason.
58
+ * ledger.
65
59
  */
66
- export function parseTaskFrontmatterV4(content) {
60
+ export function parseTaskFrontmatter(content) {
67
61
  if (!content.startsWith("---"))
68
62
  return { fields: { state: "open" }, readable: false, legacy: false };
69
63
  const end = content.indexOf("\n---", 3);
@@ -88,21 +82,17 @@ export function parseTaskFrontmatterV4(content) {
88
82
  case "paused":
89
83
  fields.paused = parsePaused(value);
90
84
  break;
91
- case "schedule":
92
- fields.schedule = value || undefined;
93
- break;
94
85
  case "ticket":
95
86
  fields.ticket = parseTicket(value);
96
87
  break;
97
- case "cycle":
98
- fields.cycle = parseCycle(value);
88
+ case "usage":
89
+ fields.usage = parseUsage(value);
99
90
  break;
100
91
  case "budget":
101
92
  fields.budget = parseBudget(value);
102
93
  break;
103
- case "verify":
104
- if (value === "required")
105
- fields.verify = "required";
94
+ case "origin":
95
+ fields.origin = value || undefined;
106
96
  break;
107
97
  case "outcome":
108
98
  if (value === "completed" || value === "cancelled")
@@ -111,20 +101,15 @@ export function parseTaskFrontmatterV4(content) {
111
101
  case "closedAt":
112
102
  fields.closedAt = value || undefined;
113
103
  break;
114
- // v3 leftovers: their presence is the migrator's trigger, their values are its input.
115
- case "status":
116
- case "enabled":
117
- case "control":
118
- case "wake":
119
- legacy = true;
120
- break;
121
104
  default:
105
+ if (LEGACY_KEYS.has(key))
106
+ legacy = true;
122
107
  break;
123
108
  }
124
109
  }
125
110
  if (fields.outcome)
126
111
  fields.state = "done";
127
- // A file with no recognizable v4 or v3 marker is not frontmatter we understand.
112
+ // A file with no recognizable marker is not frontmatter we understand.
128
113
  const readable = sawState || fields.outcome !== undefined || legacy;
129
114
  return { fields: normalizeTaskFrontmatter(fields), readable, legacy };
130
115
  }
@@ -155,8 +140,10 @@ export function renderTaskFrontmatter(fields) {
155
140
  lines.push(`outcome: ${document.outcome}`);
156
141
  if (document.closedAt)
157
142
  lines.push(`closedAt: ${document.closedAt}`);
158
- if (document.cycle)
159
- lines.push(`cycle: ${JSON.stringify(document.cycle)}`);
143
+ if (document.origin)
144
+ lines.push(`origin: ${document.origin}`);
145
+ if (document.usage)
146
+ lines.push(`usage: ${JSON.stringify(document.usage)}`);
160
147
  lines.push("---");
161
148
  return lines.join("\n");
162
149
  }
@@ -1,145 +1,95 @@
1
- import { type TaskFrontmatterV4 } from "./frontmatter.js";
1
+ import { type TaskFrontmatter } from "./frontmatter.js";
2
2
  /**
3
3
  * Shared reader for the task ledger (`workspace/<channelId>/tasks/*.md`).
4
4
  *
5
- * This is the sole implementation of the frontmatter contract documented in
6
- * `docs/tasks.md`. The parsing stays deliberately literal (flat `key: value` fields,
7
- * live-vs-archived, fail-open on unreadable frontmatter) because task files are hand-editable
8
- * and must degrade toward "wake me up so I can be fixed". `/tasks`, the task digest, and
9
- * `task_list` all read through here.
5
+ * The parsing stays deliberately literal (flat `key: value` fields, live-vs-archived, fail-open
6
+ * on unreadable frontmatter) because task files are hand-editable and must degrade toward "wake
7
+ * me up so I can be fixed". `/tasks`, the task digest, and `task_list` all read through here.
10
8
  *
11
- * Spec 051 split the frontmatter contract itself into `frontmatter.ts` (fields) and `ticket.ts`
12
- * (the waiting claim); what stays here is the *body*: sections, Plan, DoD, and the skeleton.
9
+ * Frontmatter lives in `frontmatter.ts` and the waiting claim in `ticket.ts`; what stays here is
10
+ * the *body*: sections, Work Items, DoD, and the skeleton.
13
11
  */
14
12
  export interface TaskLedgerEntry {
15
13
  /** Filename without `.md`; the task id. */
16
14
  id: string;
17
15
  /** First `# ` heading in the body, or the id when none. */
18
16
  title: string;
19
- fields: TaskFrontmatterV4;
17
+ fields: TaskFrontmatter;
20
18
  /** false => frontmatter could not be read; the task is surfaced rather than skipped. */
21
19
  readable: boolean;
22
- /** True when this file still carries v3 `status`/`control` frontmatter. */
20
+ /** True when this file still carries v3 frontmatter the conversion should have removed; it is never run. */
23
21
  legacy: boolean;
24
22
  /** The driver may schedule a step for this task right now. */
25
23
  runnable: boolean;
26
- /** When a driver-polled ticket (`time`/`schedule`) comes due, if it has not already. */
24
+ /** When a driver-polled `time` ticket comes due, if it has not already. */
27
25
  dueMs?: number;
28
- /** True when a parked task's backstop has passed and the runtime owes it a reopen (D2). */
26
+ /** True when a parked task's backstop has passed and the runtime owes it a reopen. */
29
27
  expired: boolean;
30
- /** Parsed `## Plan` section, if the task has one (spec 037, D2). */
31
- plan?: TaskPlanSummary;
28
+ /** Parsed `## Work Items` section, if the task has one. */
29
+ items?: TaskItemsSummary;
32
30
  }
33
- export interface TaskSkeletonInput {
31
+ export interface TaskContractInput {
34
32
  title: string;
35
33
  goal: string;
36
34
  dod: string;
37
- manual?: string;
38
- verificationPlan?: string;
39
- verificationRequired?: boolean;
40
- /** Optional initial `## Plan` steps, one per line; a missing `P<n>` prefix is auto-assigned. */
41
- plan?: string;
35
+ /** Initial Work Items; ids are assigned `W1…Wn` in order. */
36
+ items?: readonly {
37
+ text: string;
38
+ }[];
42
39
  }
43
- export declare const DEFAULT_TASK_MANUAL = "- Follow the DoD, record evidence in every step note, and park on a ticket when waiting.";
44
- export declare const STANDARD_TASK_SECTIONS: readonly [{
45
- readonly label: "Goal";
46
- readonly names: readonly ["Goal", "目标"];
47
- }, {
48
- readonly label: "DoD";
49
- readonly names: readonly ["DoD"];
50
- }, {
51
- readonly label: "Manual";
52
- readonly names: readonly ["Manual", "手册"];
53
- }, {
54
- readonly label: "Verification";
55
- readonly names: readonly ["Verification", "验收"];
56
- }];
57
- /**
58
- * The single historical paragraph a v4 contract keeps (spec 051, D5). Declared here rather than
59
- * in `cycle.ts` so `taskContractSegment` can end the contract at it without a circular import.
60
- */
61
- export declare const LAST_RESULT_SECTION_NAMES: readonly ["上次结果", "Last Result"];
62
40
  /** Validate/normalize a task id (filename without `.md`), rejecting path traversal. */
63
41
  export declare function normalizeTaskId(id: string): string;
64
42
  /** The document body after the leading frontmatter block, or the whole content when there is none. */
65
43
  export declare function taskBody(content: string): string;
66
- /**
67
- * The task's *contract* segment: the body up to (excluding) whichever of "Plan" or "上次结果"
68
- * appears first — i.e. the H1 title, Goal, DoD (with its checkbox state), Manual and
69
- * Verification (spec 029, D4).
70
- *
71
- * Verification PASS binds to this segment, not the whole body, so routine `progress` notes
72
- * (Current Cycle, and — spec 037, D1 — Plan step status) never invalidate a PASS; only a change
73
- * to what the task promises to do and how it is checked does.
74
- * Plan is deliberately excluded from the contract even though it always precedes Current Cycle
75
- * in a freshly rendered skeleton: it is the task's *means*, not its promise, and is meant to be
76
- * revised without re-triggering verification. This also means a task with an existing PASS can
77
- * have `## Plan` inserted between Verification and Current Cycle with the contract segment
78
- * unchanged byte-for-byte, as long as nothing before it changed.
79
- * A body without either heading (non-standard) falls back to the whole body.
80
- */
81
- export declare function taskContractSegment(body: string): string;
82
- /**
83
- * Hash the task's *contract* segment (Goal/DoD/Manual/Verification), not the whole body, so a
84
- * verification PASS survives routine step logging and only breaks when the contract itself
85
- * changes (spec 029, D4). Lives next to `taskContractSegment` because it is that function's
86
- * only real consumer.
87
- */
88
- export declare function taskBodyHash(body: string): string;
89
- export type TaskPlanStepStatus = "todo" | "done" | "blocked" | "dropped";
90
- export interface TaskPlanStep {
91
- /** `P<n>` by convention; a hand-written step without one gets its position as a fallback. */
44
+ export type TaskItemStatus = "todo" | "done" | "blocked" | "dropped";
45
+ export interface TaskItem {
46
+ /** `W<n>` (a task converted from v3 may still carry `P<n>`). */
92
47
  id: string;
93
- status: TaskPlanStepStatus;
48
+ status: TaskItemStatus;
94
49
  text: string;
95
- /** DoD item numbers this step claims to cover, from a trailing `→ dod:1,2` (or `-> dod:1,2`). */
50
+ /** DoD checklist items (1-based) this item delivers, from a trailing `→ dod:1,2`. */
96
51
  dodRefs: number[];
52
+ /** Line index within the parsed content; used to patch a line in place. */
97
53
  lineIndex: number;
98
54
  }
99
- export interface TaskPlanSummary {
100
- steps: TaskPlanStep[];
101
- /** Count of steps, excluding `dropped` ones. */
55
+ export interface TaskItemsSummary {
56
+ items: TaskItem[];
57
+ /** Count of items, excluding `dropped` ones. */
102
58
  total: number;
103
59
  done: number;
104
- /** The first `todo` or `blocked` step in document order; `undefined` once nothing is left to do. */
105
- current?: TaskPlanStep;
60
+ /** The first `todo` or `blocked` item in document order; `undefined` once nothing is left to do. */
61
+ current?: TaskItem;
106
62
  }
107
63
  /**
108
- * Parse the optional `## Plan` section: a fourth, hand-maintained layer between the contract
109
- * (Goal/DoD/Manual/Verification) and the append-only Current Cycle/History log (spec 037, D2).
64
+ * Parse the optional `## Work Items` section: the leader's hand-maintained list of independently
65
+ * deliverable pieces of the project. Four checkbox states — `[ ]` todo, `[x]` done, `[!]`
66
+ * blocked, `[~]` dropped — and no separate "doing" marker: the current item is *derived* (first
67
+ * `todo`/`blocked` in document order), not self-reported. The runtime never ticks an item itself
68
+ * (spec 052, D4): "the delegate says it is done" and "the leader checked it" are different facts.
110
69
  *
111
- * Four checkbox states — `[ ]` todo, `[x]` done, `[!]` blocked, `[~]` dropped — and no separate
112
- * "doing" marker: the current step is *derived* (first `todo`/`blocked` in document order), not
113
- * self-reported, for the same reason `task-driver.ts`'s fingerprint excludes the model's own
114
- * progress notes — a runtime-derived signal cannot be talked into lying about itself.
115
- *
116
- * Returns `undefined` when there is no Plan heading, or the heading has no checkbox lines under
117
- * it (nothing to summarize) — both read the same as "this task has no Plan yet".
70
+ * Returns `undefined` when there is no such heading, or it has no checkbox lines under it.
118
71
  */
119
- export declare function parseTaskPlan(content: string): TaskPlanSummary | undefined;
120
- export interface TaskPlanStepPatch {
72
+ export declare function parseTaskItems(content: string): TaskItemsSummary | undefined;
73
+ export interface TaskItemPatch {
121
74
  id: string;
122
- status?: TaskPlanStepStatus;
75
+ status?: TaskItemStatus;
123
76
  text?: string;
124
77
  }
125
- export interface ApplyTaskPlanPatchResult {
78
+ export interface ApplyTaskItemsPatchResult {
126
79
  body: string;
127
- /** Human-readable delta, meant to be folded into the caller's Current Cycle note; `""` if nothing changed. */
80
+ /** Human-readable delta for the tool's notice; `""` if nothing changed. */
128
81
  summary: string;
129
82
  }
130
83
  /**
131
- * Update or append Plan steps by id (spec 037, D3). An id that already exists gets its
132
- * status/text patched in place, preserving its `dod` refs and position; an unseen id is appended
133
- * as a new step (`text` is then required — there is nothing sensible to append otherwise). A task
134
- * with no `## Plan` section yet gets an empty one inserted before Current Cycle first, so the
135
- * very first `planSteps` call on a task is also the one that creates its Plan.
136
- *
137
- * The returned `summary` is deliberately not a new persisted field (see the file-level doc on
138
- * `TaskPlanSummary`): it is meant to be appended to the caller's own Current Cycle note, so the
139
- * change history rides on the log `startTaskCycle` already folds into History — no second,
140
- * unconsumed revision counter.
84
+ * Update or append Work Items by id. An id that already exists gets its status/text patched in
85
+ * place, preserving its `dod` refs and position; an unseen id is appended as a new item (`text`
86
+ * is then required — there is nothing sensible to append otherwise). A task with no section yet
87
+ * gets an empty one first, so the very first `items` call on a task is also the one that creates
88
+ * its list.
141
89
  */
142
- export declare function applyTaskPlanPatch(body: string, patches: readonly TaskPlanStepPatch[]): ApplyTaskPlanPatchResult;
90
+ export declare function applyTaskItemsPatch(body: string, patches: readonly TaskItemPatch[]): ApplyTaskItemsPatchResult;
91
+ /** Whether `id` names an existing Work Item of the task body (case-insensitive). */
92
+ export declare function findTaskItem(body: string, id: string): TaskItem | undefined;
143
93
  /** First `# ` heading after the frontmatter block, or the id when there is none. */
144
94
  export declare function extractTaskTitle(content: string, fallbackId: string): string;
145
95
  export declare function matchesTaskSectionTitle(title: string, names: readonly string[]): boolean;
@@ -154,33 +104,27 @@ export interface TaskSectionBounds {
154
104
  /**
155
105
  * Find the first heading matching one of `names` and the exclusive end of its body — the next
156
106
  * heading at the same or a shallower level, or end of document. Every task-document section scan
157
- * (Plan, Current Cycle, DoD, Verification) shares this exact rule; only what a caller does with
107
+ * (Work Items, DoD) shares this exact rule; only what a caller does with
158
108
  * the bounds differs.
159
109
  */
160
110
  export declare function findTaskSectionBounds(lines: readonly string[], names: readonly string[]): TaskSectionBounds | undefined;
161
- export declare function hasTaskHeading(content: string, names: readonly string[]): boolean;
162
- export declare function missingStandardTaskSections(content: string): string[];
163
- export declare function uncheckedTaskAcceptanceItems(content: string): string[];
164
111
  /**
165
- * Count of checkbox items (checked or not) under the DoD heading, for cross-referencing a Plan
166
- * step's `→ dod:N` refs (spec 037, D4 — `/tasks doctor`'s drift checks).
167
- */
168
- export declare function countTaskDodItems(content: string): number;
169
- /**
170
- * The v4 task skeleton: contract only (spec 051, D5). `## Current Cycle` and `## History` are
171
- * gone — the per-step record lives in `<id>.jsonl`, and the one paragraph the contract keeps
172
- * (`## 上次结果`) is written by the cycle-close path, not by the skeleton.
112
+ * Unchecked Markdown acceptance boxes under the DoD section, plus a synthetic entry when DoD has
113
+ * content but no checkbox syntax at all.
114
+ *
115
+ * Without the "no checklist items" case, a DoD written as prose or a numbered list (no `- [ ]`
116
+ * anywhere) makes this function return an empty array — indistinguishable from "everything is
117
+ * checked" — which would silently let a task close with nothing ever actually checked.
173
118
  */
174
- export declare function renderStandardTaskBody(input: TaskSkeletonInput): string;
175
- /** Serialize a task document: v4 frontmatter block plus the body, unchanged. */
176
- export declare function renderTaskDocument(fields: TaskFrontmatterV4, rawBody: string): string;
119
+ export declare function uncheckedTaskAcceptanceItems(content: string): string[];
177
120
  /**
178
- * Reset a recurring task's per-cycle checkboxes: DoD/Verification acceptance items and Plan
179
- * steps both go back to unchecked, so cycle N+1 can never pass its acceptance gate on cycle N's
180
- * evidence. `[~]` dropped plan steps are left alone — that step was deliberately abandoned, not
181
- * merely finished, and a new cycle should not resurrect it.
121
+ * The task skeleton: Goal, DoD and (optionally) Work Items (spec 052, §3.4). The runtime never
122
+ * rewrites the body afterwards, so there is no history section here — the per-step record lives
123
+ * in `<id>.jsonl`.
182
124
  */
183
- export declare function resetTaskPlanForCycle(body: string): string;
125
+ export declare function renderStandardTaskBody(input: TaskContractInput): string;
126
+ /** Serialize a task document: frontmatter block plus the body, unchanged. */
127
+ export declare function renderTaskDocument(fields: TaskFrontmatter, rawBody: string): string;
184
128
  /**
185
129
  * Runnable first; then a parked task whose backstop already expired (the runtime owes it a
186
130
  * reopen); then earliest due ticket; then id. Sorting expired parks ahead of ordinary parks is