@aperant/framework 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/CHANGELOG.md +236 -1
  2. package/agents/apt-planner.md +15 -0
  3. package/agents/apt-verifier.md +15 -10
  4. package/bin/apt-proof-video.mjs +256 -76
  5. package/dist/cli/commands/apply-recipe.d.mts +6 -0
  6. package/dist/cli/commands/apply-recipe.d.mts.map +1 -0
  7. package/dist/cli/commands/apply-recipe.mjs +98 -0
  8. package/dist/cli/commands/apply-recipe.mjs.map +1 -0
  9. package/dist/cli/commands/catch-up.d.mts +9 -0
  10. package/dist/cli/commands/catch-up.d.mts.map +1 -0
  11. package/dist/cli/commands/catch-up.mjs +64 -0
  12. package/dist/cli/commands/catch-up.mjs.map +1 -0
  13. package/dist/cli/commands/mobile-prepare.d.mts +53 -0
  14. package/dist/cli/commands/mobile-prepare.d.mts.map +1 -0
  15. package/dist/cli/commands/mobile-prepare.mjs +139 -0
  16. package/dist/cli/commands/mobile-prepare.mjs.map +1 -0
  17. package/dist/cli/commands/pr-review.d.mts +16 -4
  18. package/dist/cli/commands/pr-review.d.mts.map +1 -1
  19. package/dist/cli/commands/pr-review.mjs +30 -11
  20. package/dist/cli/commands/pr-review.mjs.map +1 -1
  21. package/dist/cli/commands/recipe-diff.d.mts +6 -0
  22. package/dist/cli/commands/recipe-diff.d.mts.map +1 -0
  23. package/dist/cli/commands/recipe-diff.mjs +75 -0
  24. package/dist/cli/commands/recipe-diff.mjs.map +1 -0
  25. package/dist/cli/commands/roadmap.d.mts.map +1 -1
  26. package/dist/cli/commands/roadmap.mjs +53 -0
  27. package/dist/cli/commands/roadmap.mjs.map +1 -1
  28. package/dist/cli/commands/route.d.mts.map +1 -1
  29. package/dist/cli/commands/route.mjs +92 -2
  30. package/dist/cli/commands/route.mjs.map +1 -1
  31. package/dist/cli/commands/verify-sandbox.d.mts +6 -0
  32. package/dist/cli/commands/verify-sandbox.d.mts.map +1 -0
  33. package/dist/cli/commands/verify-sandbox.mjs +200 -0
  34. package/dist/cli/commands/verify-sandbox.mjs.map +1 -0
  35. package/dist/cli/config/share-policy.d.mts.map +1 -1
  36. package/dist/cli/config/share-policy.mjs +1 -0
  37. package/dist/cli/config/share-policy.mjs.map +1 -1
  38. package/dist/cli/config/upgrade-gitignore.d.mts.map +1 -1
  39. package/dist/cli/config/upgrade-gitignore.mjs +1 -0
  40. package/dist/cli/config/upgrade-gitignore.mjs.map +1 -1
  41. package/dist/cli/consistency/parse-qa.d.mts.map +1 -1
  42. package/dist/cli/consistency/parse-qa.mjs +18 -4
  43. package/dist/cli/consistency/parse-qa.mjs.map +1 -1
  44. package/dist/cli/consistency/rules/r5-verdict-consistency.d.mts.map +1 -1
  45. package/dist/cli/consistency/rules/r5-verdict-consistency.mjs +11 -10
  46. package/dist/cli/consistency/rules/r5-verdict-consistency.mjs.map +1 -1
  47. package/dist/cli/coordination/catch-up.d.mts +26 -0
  48. package/dist/cli/coordination/catch-up.d.mts.map +1 -0
  49. package/dist/cli/coordination/catch-up.mjs +239 -0
  50. package/dist/cli/coordination/catch-up.mjs.map +1 -0
  51. package/dist/cli/coordination/last-seen.d.mts +45 -0
  52. package/dist/cli/coordination/last-seen.d.mts.map +1 -0
  53. package/dist/cli/coordination/last-seen.mjs +128 -0
  54. package/dist/cli/coordination/last-seen.mjs.map +1 -0
  55. package/dist/cli/coordination/store.d.mts +15 -0
  56. package/dist/cli/coordination/store.d.mts.map +1 -1
  57. package/dist/cli/coordination/store.mjs +16 -0
  58. package/dist/cli/coordination/store.mjs.map +1 -1
  59. package/dist/cli/coverage-check/user-outcomes.d.mts +7 -2
  60. package/dist/cli/coverage-check/user-outcomes.d.mts.map +1 -1
  61. package/dist/cli/coverage-check/user-outcomes.mjs +50 -17
  62. package/dist/cli/coverage-check/user-outcomes.mjs.map +1 -1
  63. package/dist/cli/dispatch.d.mts.map +1 -1
  64. package/dist/cli/dispatch.mjs +30 -0
  65. package/dist/cli/dispatch.mjs.map +1 -1
  66. package/dist/cli/gate/gates/verify-approved.d.mts +0 -48
  67. package/dist/cli/gate/gates/verify-approved.d.mts.map +1 -1
  68. package/dist/cli/gate/gates/verify-approved.mjs +23 -80
  69. package/dist/cli/gate/gates/verify-approved.mjs.map +1 -1
  70. package/dist/cli/git/default-branch.d.mts +51 -0
  71. package/dist/cli/git/default-branch.d.mts.map +1 -0
  72. package/dist/cli/git/default-branch.mjs +234 -0
  73. package/dist/cli/git/default-branch.mjs.map +1 -0
  74. package/dist/cli/git/identity.d.mts +3 -5
  75. package/dist/cli/git/identity.d.mts.map +1 -1
  76. package/dist/cli/git/identity.mjs +10 -4
  77. package/dist/cli/git/identity.mjs.map +1 -1
  78. package/dist/cli/install/legacy-paths.d.mts.map +1 -1
  79. package/dist/cli/install/legacy-paths.mjs +2 -0
  80. package/dist/cli/install/legacy-paths.mjs.map +1 -1
  81. package/dist/cli/install/mcp-server-specs.d.mts +6 -5
  82. package/dist/cli/install/mcp-server-specs.d.mts.map +1 -1
  83. package/dist/cli/install/mcp-server-specs.mjs +22 -4
  84. package/dist/cli/install/mcp-server-specs.mjs.map +1 -1
  85. package/dist/cli/roadmap/backend-adapter.d.mts +43 -0
  86. package/dist/cli/roadmap/backend-adapter.d.mts.map +1 -0
  87. package/dist/cli/roadmap/backend-adapter.mjs +222 -0
  88. package/dist/cli/roadmap/backend-adapter.mjs.map +1 -0
  89. package/dist/cli/util/runtime-capabilities.d.mts +7 -0
  90. package/dist/cli/util/runtime-capabilities.d.mts.map +1 -1
  91. package/dist/cli/util/runtime-capabilities.mjs +65 -0
  92. package/dist/cli/util/runtime-capabilities.mjs.map +1 -1
  93. package/dist/cli/verify-proof/manifest-validator.mjs +13 -0
  94. package/dist/cli/verify-proof/manifest-validator.mjs.map +1 -1
  95. package/dist/cli/verify-proof/resolver.d.mts +10 -7
  96. package/dist/cli/verify-proof/resolver.d.mts.map +1 -1
  97. package/dist/cli/verify-proof/resolver.mjs +28 -7
  98. package/dist/cli/verify-proof/resolver.mjs.map +1 -1
  99. package/dist/cli/verify-proof/sandbox/apply.d.mts +64 -0
  100. package/dist/cli/verify-proof/sandbox/apply.d.mts.map +1 -0
  101. package/dist/cli/verify-proof/sandbox/apply.mjs +379 -0
  102. package/dist/cli/verify-proof/sandbox/apply.mjs.map +1 -0
  103. package/dist/cli/verify-proof/sandbox/gate-predicate.d.mts +63 -0
  104. package/dist/cli/verify-proof/sandbox/gate-predicate.d.mts.map +1 -0
  105. package/dist/cli/verify-proof/sandbox/gate-predicate.mjs +115 -0
  106. package/dist/cli/verify-proof/sandbox/gate-predicate.mjs.map +1 -0
  107. package/dist/cli/verify-proof/sandbox/pattern-matcher.d.mts +57 -0
  108. package/dist/cli/verify-proof/sandbox/pattern-matcher.d.mts.map +1 -0
  109. package/dist/cli/verify-proof/sandbox/pattern-matcher.mjs +124 -0
  110. package/dist/cli/verify-proof/sandbox/pattern-matcher.mjs.map +1 -0
  111. package/dist/cli/verify-proof/sandbox/recipe-diff.d.mts +28 -0
  112. package/dist/cli/verify-proof/sandbox/recipe-diff.d.mts.map +1 -0
  113. package/dist/cli/verify-proof/sandbox/recipe-diff.mjs +190 -0
  114. package/dist/cli/verify-proof/sandbox/recipe-diff.mjs.map +1 -0
  115. package/dist/cli/verify-proof/sandbox/sandbox-config.d.mts +25 -0
  116. package/dist/cli/verify-proof/sandbox/sandbox-config.d.mts.map +1 -0
  117. package/dist/cli/verify-proof/sandbox/sandbox-config.mjs +85 -0
  118. package/dist/cli/verify-proof/sandbox/sandbox-config.mjs.map +1 -0
  119. package/dist/cli/verify-proof/sandbox/self-test.d.mts +39 -0
  120. package/dist/cli/verify-proof/sandbox/self-test.d.mts.map +1 -0
  121. package/dist/cli/verify-proof/sandbox/self-test.mjs +248 -0
  122. package/dist/cli/verify-proof/sandbox/self-test.mjs.map +1 -0
  123. package/dist/plugin/.claude-plugin/plugin.json +2 -1
  124. package/dist/plugin/agents/apt-planner.md +15 -0
  125. package/dist/plugin/agents/apt-verifier.md +15 -10
  126. package/dist/plugin/skills/apt/SKILL.md +29 -0
  127. package/dist/plugin/skills/apt-catch-up/SKILL.md +79 -0
  128. package/dist/plugin/skills/apt-plan/SKILL.md +23 -0
  129. package/dist/plugin/skills/apt-pr-review/SKILL.md +5 -4
  130. package/dist/plugin/skills/apt-run/SKILL.md +1 -1
  131. package/dist/plugin/skills/apt-setup/SKILL.md +132 -0
  132. package/dist/plugin/skills/apt-verify/SKILL.md +20 -15
  133. package/dist/plugin/skills/apt-verify-proof/SKILL.md +146 -11
  134. package/dist/proof-report.d.ts.map +1 -1
  135. package/dist/proof-report.js +4 -1
  136. package/dist/proof-report.js.map +1 -1
  137. package/dist/types/config.d.ts +42 -4
  138. package/dist/types/config.d.ts.map +1 -1
  139. package/dist/types/qa-scoring.d.ts +45 -9
  140. package/dist/types/qa-scoring.d.ts.map +1 -1
  141. package/dist/types/qa-scoring.js +34 -13
  142. package/dist/types/qa-scoring.js.map +1 -1
  143. package/dist/types/state.d.ts +7 -2
  144. package/dist/types/state.d.ts.map +1 -1
  145. package/dist/types/task-record.d.ts +10 -2
  146. package/dist/types/task-record.d.ts.map +1 -1
  147. package/drivers/mobile/README.md +40 -0
  148. package/drivers/mobile/driver.mjs +106 -0
  149. package/drivers/mobile/manifest.json +49 -0
  150. package/package.json +1 -1
  151. package/prompts/inbox-clarification.md +11 -0
  152. package/prompts/inbox-triage.md +20 -0
  153. package/prompts/qa_orchestrator_agentic.md +18 -17
  154. package/prompts/qa_reviewer.md +17 -15
  155. package/skills/apt/SKILL.md +29 -0
  156. package/skills/apt-catch-up/SKILL.md +79 -0
  157. package/skills/apt-plan/SKILL.md +23 -0
  158. package/skills/apt-pr-review/SKILL.md +5 -4
  159. package/skills/apt-run/SKILL.md +1 -1
  160. package/skills/apt-setup/SKILL.md +132 -0
  161. package/skills/apt-verifier.md +7 -4
  162. package/skills/apt-verify/SKILL.md +20 -15
  163. package/skills/apt-verify-proof/SKILL.md +146 -11
  164. package/src/cli/commands/apply-recipe.mjs +105 -0
  165. package/src/cli/commands/catch-up.mjs +67 -0
  166. package/src/cli/commands/mobile-prepare.mjs +151 -0
  167. package/src/cli/commands/pr-review.mjs +32 -11
  168. package/src/cli/commands/recipe-diff.mjs +81 -0
  169. package/src/cli/commands/roadmap.mjs +54 -0
  170. package/src/cli/commands/route.mjs +92 -1
  171. package/src/cli/commands/verify-sandbox.mjs +231 -0
  172. package/src/cli/config/share-policy.mjs +1 -0
  173. package/src/cli/config/upgrade-gitignore.mjs +1 -0
  174. package/src/cli/consistency/parse-qa.mjs +20 -4
  175. package/src/cli/consistency/rules/r5-verdict-consistency.mjs +11 -13
  176. package/src/cli/coordination/catch-up.mjs +231 -0
  177. package/src/cli/coordination/last-seen.mjs +131 -0
  178. package/src/cli/coordination/store.mjs +18 -0
  179. package/src/cli/coverage-check/user-outcomes.mjs +52 -17
  180. package/src/cli/dispatch.mjs +29 -0
  181. package/src/cli/gate/gates/verify-approved.mjs +22 -81
  182. package/src/cli/git/default-branch.mjs +250 -0
  183. package/src/cli/git/identity.mjs +9 -3
  184. package/src/cli/install/legacy-paths.mjs +2 -0
  185. package/src/cli/install/mcp-server-specs.mjs +24 -4
  186. package/src/cli/roadmap/backend-adapter.mjs +231 -0
  187. package/src/cli/util/runtime-capabilities.mjs +67 -0
  188. package/src/cli/verify-proof/manifest-validator.mjs +15 -0
  189. package/src/cli/verify-proof/resolver.mjs +27 -7
  190. package/src/cli/verify-proof/sandbox/apply.mjs +401 -0
  191. package/src/cli/verify-proof/sandbox/gate-predicate.mjs +126 -0
  192. package/src/cli/verify-proof/sandbox/pattern-matcher.mjs +127 -0
  193. package/src/cli/verify-proof/sandbox/recipe-diff.mjs +208 -0
  194. package/src/cli/verify-proof/sandbox/sandbox-config.mjs +82 -0
  195. package/src/cli/verify-proof/sandbox/sandbox-schema.json +33 -0
  196. package/src/cli/verify-proof/sandbox/self-test.mjs +265 -0
  197. package/templates/config.json +21 -1
  198. package/templates/proof-verification.md +27 -8
  199. package/workflows/verify-proof.md +376 -302
@@ -0,0 +1,239 @@
1
+ /**
2
+ * @internal
3
+ * coordination/catch-up.mjs — composes the combined catch-up panel: the
4
+ * Welcome-Back Summary (your own half-finished work, local-only) and the
5
+ * gated Team-Change Digest (what teammates merged while you were away).
6
+ *
7
+ * Composition order is fixed: welcome_back first, then team_digest (LD-10).
8
+ * The renderer (apt/SKILL.md) enforces display order; this module only sets
9
+ * the field order on the returned object.
10
+ *
11
+ * Both halves diff against one Last-Seen Marker:
12
+ * - Welcome-Back fires on a staleness threshold (now - last_run_at), reads
13
+ * only local state.active_tasks, and is ALWAYS-ON regardless of visibility
14
+ * (LD-08/09).
15
+ * - Team-Change Digest fires only when share.visibility is team/oss AND the
16
+ * local default-branch sha has moved since last_main_sha (LD-04/06/07).
17
+ *
18
+ * Returns null when neither half fires. This module is `@internal` — reached
19
+ * via the route.mjs lazy-compute path and the apt-tools catch-up command, not
20
+ * from bin/apt-tools.mjs directly.
21
+ */
22
+ import { existsSync, readFileSync } from 'node:fs';
23
+ import { join } from 'node:path';
24
+ import { resolveSharePolicy } from '../config/share-policy.mjs';
25
+ import { listMergedPullRequests } from '../git/default-branch.mjs';
26
+ import { getGitIdentity } from '../git/identity.mjs';
27
+ import { resolveSharedRoot } from './agent-identity.mjs';
28
+ const HOUR_MS = 60 * 60 * 1000;
29
+ /**
30
+ * Best-available per-task activity timestamp (ms). Prefers an explicit
31
+ * updated_at, then the most recent history entry, then created_at.
32
+ *
33
+ * @param {object} task
34
+ * @returns {number} epoch ms, or 0 when no timestamp is parseable.
35
+ */
36
+ function taskActivityMs(task) {
37
+ const candidates = [];
38
+ if (task?.updated_at)
39
+ candidates.push(Date.parse(task.updated_at));
40
+ if (Array.isArray(task?.history)) {
41
+ for (const h of task.history) {
42
+ if (h?.at)
43
+ candidates.push(Date.parse(h.at));
44
+ }
45
+ }
46
+ if (task?.created_at)
47
+ candidates.push(Date.parse(task.created_at));
48
+ const valid = candidates.filter((n) => Number.isFinite(n));
49
+ return valid.length ? Math.max(...valid) : 0;
50
+ }
51
+ /**
52
+ * A coarse "x ago" relative-time string. Kept dependency-free and stable for
53
+ * tests — granularity is minutes/hours/days.
54
+ *
55
+ * @param {number} deltaMs
56
+ * @returns {string}
57
+ */
58
+ function relativeTime(deltaMs) {
59
+ if (!Number.isFinite(deltaMs) || deltaMs < 0)
60
+ return 'just now';
61
+ const mins = Math.floor(deltaMs / 60000);
62
+ if (mins < 1)
63
+ return 'just now';
64
+ if (mins < 60)
65
+ return `${mins}m ago`;
66
+ const hours = Math.floor(mins / 60);
67
+ if (hours < 24)
68
+ return `${hours}h ago`;
69
+ const days = Math.floor(hours / 24);
70
+ return `${days}d ago`;
71
+ }
72
+ /**
73
+ * Read the first actionable next-step line from a task's CONTINUE note, if one
74
+ * exists at `.aperant/tasks/{taskId}/CONTINUE.md`. Parses the first non-empty
75
+ * item under the `## Next Steps` heading (the pause-note format).
76
+ *
77
+ * @param {string} sharedRoot
78
+ * @param {string} taskId
79
+ * @returns {string|null}
80
+ */
81
+ function readNextStepLine(sharedRoot, taskId) {
82
+ if (!taskId)
83
+ return null;
84
+ const notePath = join(sharedRoot, '.aperant', 'tasks', taskId, 'CONTINUE.md');
85
+ if (!existsSync(notePath))
86
+ return null;
87
+ let text;
88
+ try {
89
+ text = readFileSync(notePath, 'utf-8');
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ const lines = text.split('\n');
95
+ const headingIdx = lines.findIndex((l) => /^##\s+Next Steps\s*$/i.test(l.trim()));
96
+ if (headingIdx === -1)
97
+ return null;
98
+ for (let i = headingIdx + 1; i < lines.length; i++) {
99
+ const raw = lines[i].trim();
100
+ if (raw.startsWith('##'))
101
+ break; // next section
102
+ if (raw.length === 0)
103
+ continue;
104
+ // Strip a leading list marker: "1. ", "- ", "* ".
105
+ const cleaned = raw.replace(/^(\d+\.|[-*])\s+/, '').trim();
106
+ if (cleaned.length > 0)
107
+ return cleaned;
108
+ }
109
+ return null;
110
+ }
111
+ /**
112
+ * Build the Welcome-Back half from local state (LD-08/09). Returns null when
113
+ * the threshold has not elapsed or there is no active task.
114
+ *
115
+ * @param {object} params
116
+ * @param {object} params.config
117
+ * @param {number} params.now epoch ms
118
+ * @param {object|null} params.marker
119
+ * @param {object|null} params.state raw state.json (for active_tasks)
120
+ * @param {string} params.sharedRoot
121
+ * @returns {object|null}
122
+ */
123
+ function buildWelcomeBack({ config, now, marker, state, sharedRoot }) {
124
+ const wb = config?.collaboration?.welcome_back;
125
+ if (wb?.enabled === false)
126
+ return null;
127
+ const lastRunAt = marker?.last_run_at ? Date.parse(marker.last_run_at) : NaN;
128
+ const thresholdHours = Number.isFinite(wb?.threshold_hours) ? wb.threshold_hours : 16;
129
+ // Only fire when we have a baseline AND the gap strictly exceeds the threshold.
130
+ if (!Number.isFinite(lastRunAt))
131
+ return null;
132
+ if (now - lastRunAt <= thresholdHours * HOUR_MS)
133
+ return null;
134
+ const activeTasks = state?.active_tasks && typeof state.active_tasks === 'object' ? state.active_tasks : {};
135
+ const ids = Object.keys(activeTasks);
136
+ if (ids.length === 0)
137
+ return null;
138
+ // Pick the single most-recently-active task.
139
+ let bestId = null;
140
+ let bestMs = -1;
141
+ for (const id of ids) {
142
+ const ms = taskActivityMs(activeTasks[id]);
143
+ if (ms > bestMs) {
144
+ bestMs = ms;
145
+ bestId = id;
146
+ }
147
+ }
148
+ if (!bestId)
149
+ return null;
150
+ const task = activeTasks[bestId];
151
+ const currentSubtask = task?.progress?.current_subtask ?? task?.current_subtask ?? null;
152
+ return {
153
+ task_id: bestId,
154
+ description: task?.description ?? bestId,
155
+ lifecycle_phase: task?.lifecycle_phase ?? null,
156
+ current_subtask: currentSubtask,
157
+ progress: task?.progress ?? null,
158
+ relative_time: bestMs > 0 ? relativeTime(now - bestMs) : null,
159
+ next_step: readNextStepLine(sharedRoot, bestId),
160
+ others_count: Math.max(0, ids.length - 1),
161
+ };
162
+ }
163
+ /**
164
+ * Build the Team-Change Digest half (LD-04/06/07). Returns null when the
165
+ * visibility gate is closed (solo), the digest is disabled, or the
166
+ * default-branch sha has not moved since the marker.
167
+ *
168
+ * @param {object} params
169
+ * @param {string} params.projectRoot
170
+ * @param {object} params.config
171
+ * @param {object|null} params.marker
172
+ * @param {{ branch: string, sha: string }|null} params.defaultBranch
173
+ * @returns {object|null}
174
+ */
175
+ function buildTeamDigest({ projectRoot, config, marker, defaultBranch }) {
176
+ const td = config?.collaboration?.team_digest;
177
+ if (td?.enabled === false)
178
+ return null;
179
+ const visibility = resolveSharePolicy(config).visibility;
180
+ if (visibility !== 'team' && visibility !== 'oss')
181
+ return null;
182
+ if (!defaultBranch?.sha)
183
+ return null;
184
+ // Only fire when main has actually moved since the recorded baseline.
185
+ if (marker?.last_main_sha && marker.last_main_sha === defaultBranch.sha)
186
+ return null;
187
+ const maxEntries = Number.isInteger(td?.max_entries) && td.max_entries > 0 ? td.max_entries : 7;
188
+ const identity = (() => {
189
+ try {
190
+ return getGitIdentity(projectRoot);
191
+ }
192
+ catch {
193
+ return null;
194
+ }
195
+ })();
196
+ const { entries, more_count } = listMergedPullRequests(projectRoot, {
197
+ sinceSha: marker?.last_main_sha || null,
198
+ defaultBranch: defaultBranch.branch,
199
+ currentUserEmail: identity?.email || '',
200
+ maxEntries,
201
+ });
202
+ if (entries.length === 0 && more_count === 0)
203
+ return null;
204
+ return { entries, more_count };
205
+ }
206
+ /**
207
+ * Compose the combined catch-up panel. Returns null when neither half fires.
208
+ *
209
+ * @param {string} projectRoot
210
+ * @param {object} params
211
+ * @param {object} params.config
212
+ * @param {number} params.now epoch ms
213
+ * @param {object|null} params.marker Last-Seen Marker
214
+ * @param {{ branch: string, sha: string }|null} params.defaultBranch
215
+ * @returns {{ welcome_back: object|null, team_digest: object|null }|null}
216
+ *
217
+ * @internal
218
+ */
219
+ export function computeCatchUpPanel(projectRoot, { config, now, marker, defaultBranch } = {}) {
220
+ const sharedRoot = resolveSharedRoot(projectRoot);
221
+ const state = (() => {
222
+ const statePath = join(sharedRoot, '.aperant', 'state.json');
223
+ if (!existsSync(statePath))
224
+ return null;
225
+ try {
226
+ return JSON.parse(readFileSync(statePath, 'utf-8'));
227
+ }
228
+ catch {
229
+ return null;
230
+ }
231
+ })();
232
+ const welcome_back = buildWelcomeBack({ config, now, marker, state, sharedRoot });
233
+ const team_digest = buildTeamDigest({ projectRoot, config, marker, defaultBranch });
234
+ if (!welcome_back && !team_digest)
235
+ return null;
236
+ // Fixed field order: welcome_back first (LD-10).
237
+ return { welcome_back, team_digest };
238
+ }
239
+ //# sourceMappingURL=catch-up.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catch-up.mjs","sourceRoot":"","sources":["../../../src/cli/coordination/catch-up.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;AAE9B;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,IAAI;IAC3B,MAAM,UAAU,GAAG,EAAE,CAAA;IACrB,IAAI,IAAI,EAAE,UAAU;QAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAClE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;QAClC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC9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AI,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA;QACpD,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,IAAI,CAAA;QACZ,CAAC;IACF,CAAC,CAAC,EAAE,CAAA;IAEJ,MAAM,YAAY,GAAG,gBAAgB,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAA;IACjF,MAAM,WAAW,GAAG,eAAe,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAA;IAEnF,IAAI,CAAC,YAAY,IAAI,CAAC,WAAW;QAAE,OAAO,IAAI,CAAA;IAC9C,iDAAiD;IACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAA;AACrC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Slug a git email into a filesystem-safe key: lowercase, every run of
3
+ * non-[a-z0-9] characters collapsed to a single '-'.
4
+ *
5
+ * @param {string} email
6
+ * @returns {string}
7
+ */
8
+ export function slugFromEmail(email: string): string;
9
+ /**
10
+ * Read the current user's Last-Seen Marker. Returns null when the git email is
11
+ * absent (no identity → no key) or the file does not yet exist / is malformed.
12
+ *
13
+ * @param {string} projectRoot
14
+ * @returns {{ last_run_at: string|null, last_main_sha: string|null, last_active_task: string|null }|null}
15
+ *
16
+ * @internal
17
+ */
18
+ export function readLastSeen(projectRoot: string): {
19
+ last_run_at: string | null;
20
+ last_main_sha: string | null;
21
+ last_active_task: string | null;
22
+ } | null;
23
+ /**
24
+ * Advance the marker, merging partial fields onto any existing record.
25
+ *
26
+ * Marker-advance semantics (LD-02):
27
+ * - last_run_at is always settable (it measures engagement).
28
+ * - last_main_sha is optional — the caller passes it only AFTER the digest
29
+ * was computed (even when empty). When undefined, the existing sha is kept.
30
+ * - last_active_task is optional — the welcome-back task id, kept otherwise.
31
+ *
32
+ * No-op (returns null) when the git email is absent — there is no key to write.
33
+ *
34
+ * @param {string} projectRoot
35
+ * @param {{ last_run_at?: string, last_main_sha?: string|null, last_active_task?: string|null }} fields
36
+ * @returns {object|null} the written record, or null when there is no identity key.
37
+ *
38
+ * @internal
39
+ */
40
+ export function advanceLastSeen(projectRoot: string, fields?: {
41
+ last_run_at?: string;
42
+ last_main_sha?: string | null;
43
+ last_active_task?: string | null;
44
+ }): object | null;
45
+ //# sourceMappingURL=last-seen.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"last-seen.d.mts","sourceRoot":"","sources":["../../../src/cli/coordination/last-seen.mjs"],"names":[],"mappings":"AAiCA;;;;;;GAMG;AACH,qCAHW,MAAM,GACJ,MAAM,CAOlB;AAgBD;;;;;;;;GAQG;AACH,0CALW,MAAM,GACJ;IAAE,WAAW,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,aAAa,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,gBAAgB,EAAE,MAAM,GAAC,IAAI,CAAA;CAAE,GAAC,IAAI,CAkBxG;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,6CANW,MAAM,WACN;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,GAAC,IAAI,CAAA;CAAE,GACnF,MAAM,GAAC,IAAI,CA+BvB"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @internal
3
+ * last-seen.mjs — per-machine, per-git-identity Last-Seen Marker (LD-01).
4
+ *
5
+ * The collaboration catch-up surfaces (Welcome-Back Summary + Team-Change
6
+ * Digest) both diff against one baseline record per human/machine:
7
+ *
8
+ * .aperant/last-seen/{email-slug}.json → { last_run_at, last_main_sha, last_active_task }
9
+ *
10
+ * The slug is derived from the git `user.email` (stable per human/machine),
11
+ * lowercased with every non-[a-z0-9] run collapsed to '-'. The directory is
12
+ * gitignored in the same per-machine ephemeral class as `team-status/` and
13
+ * `events/` (see upgrade-gitignore.mjs / share-policy.mjs).
14
+ *
15
+ * Modeled on team-status.mjs: resolveSharedRoot-based path so the marker lives
16
+ * in the main repo even when called from a worktree; atomicWriteJson +
17
+ * mkdirSync(recursive) for durable writes.
18
+ *
19
+ * This module is `@internal` — consumed only through the CoordinationStore
20
+ * seam (store.readLastSeen / store.advanceLastSeen). Do NOT import it from
21
+ * bin/apt-tools.mjs.
22
+ */
23
+ import { existsSync, mkdirSync, readFileSync } from 'node:fs';
24
+ import { join } from 'node:path';
25
+ import { getGitIdentity } from '../git/identity.mjs';
26
+ import { atomicWriteJson } from '../util/io.mjs';
27
+ import { resolveSharedRoot } from './agent-identity.mjs';
28
+ function lastSeenDir(projectRoot) {
29
+ return join(resolveSharedRoot(projectRoot), '.aperant', 'last-seen');
30
+ }
31
+ /**
32
+ * Slug a git email into a filesystem-safe key: lowercase, every run of
33
+ * non-[a-z0-9] characters collapsed to a single '-'.
34
+ *
35
+ * @param {string} email
36
+ * @returns {string}
37
+ */
38
+ export function slugFromEmail(email) {
39
+ return String(email)
40
+ .toLowerCase()
41
+ .replace(/[^a-z0-9]+/g, '-')
42
+ .replace(/^-+|-+$/g, '');
43
+ }
44
+ function markerPath(projectRoot) {
45
+ const identity = (() => {
46
+ try {
47
+ return getGitIdentity(projectRoot);
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ })();
53
+ if (!identity?.email)
54
+ return null;
55
+ const slug = slugFromEmail(identity.email);
56
+ if (!slug)
57
+ return null;
58
+ return join(lastSeenDir(projectRoot), `${slug}.json`);
59
+ }
60
+ /**
61
+ * Read the current user's Last-Seen Marker. Returns null when the git email is
62
+ * absent (no identity → no key) or the file does not yet exist / is malformed.
63
+ *
64
+ * @param {string} projectRoot
65
+ * @returns {{ last_run_at: string|null, last_main_sha: string|null, last_active_task: string|null }|null}
66
+ *
67
+ * @internal
68
+ */
69
+ export function readLastSeen(projectRoot) {
70
+ const path = markerPath(projectRoot);
71
+ if (!path || !existsSync(path))
72
+ return null;
73
+ try {
74
+ const record = JSON.parse(readFileSync(path, 'utf-8'));
75
+ if (!record || typeof record !== 'object')
76
+ return null;
77
+ return {
78
+ last_run_at: record.last_run_at ?? null,
79
+ last_main_sha: record.last_main_sha ?? null,
80
+ last_active_task: record.last_active_task ?? null,
81
+ };
82
+ }
83
+ catch {
84
+ return null;
85
+ }
86
+ }
87
+ /**
88
+ * Advance the marker, merging partial fields onto any existing record.
89
+ *
90
+ * Marker-advance semantics (LD-02):
91
+ * - last_run_at is always settable (it measures engagement).
92
+ * - last_main_sha is optional — the caller passes it only AFTER the digest
93
+ * was computed (even when empty). When undefined, the existing sha is kept.
94
+ * - last_active_task is optional — the welcome-back task id, kept otherwise.
95
+ *
96
+ * No-op (returns null) when the git email is absent — there is no key to write.
97
+ *
98
+ * @param {string} projectRoot
99
+ * @param {{ last_run_at?: string, last_main_sha?: string|null, last_active_task?: string|null }} fields
100
+ * @returns {object|null} the written record, or null when there is no identity key.
101
+ *
102
+ * @internal
103
+ */
104
+ export function advanceLastSeen(projectRoot, fields = {}) {
105
+ const path = markerPath(projectRoot);
106
+ if (!path)
107
+ return null;
108
+ let existing = {};
109
+ if (existsSync(path)) {
110
+ try {
111
+ existing = JSON.parse(readFileSync(path, 'utf-8')) || {};
112
+ }
113
+ catch {
114
+ existing = {};
115
+ }
116
+ }
117
+ const record = {
118
+ last_run_at: fields.last_run_at !== undefined ? fields.last_run_at : (existing.last_run_at ?? null),
119
+ last_main_sha: fields.last_main_sha !== undefined ? fields.last_main_sha : (existing.last_main_sha ?? null),
120
+ last_active_task: fields.last_active_task !== undefined
121
+ ? fields.last_active_task
122
+ : (existing.last_active_task ?? null),
123
+ };
124
+ mkdirSync(lastSeenDir(projectRoot), { recursive: true });
125
+ atomicWriteJson(path, record);
126
+ return record;
127
+ }
128
+ //# sourceMappingURL=last-seen.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"last-seen.mjs","sourceRoot":"","sources":["../../../src/cli/coordination/last-seen.mjs"],"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,MAAM,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,IAAI,IAAI,CAAC;QAC7F,gBAAgB,EACf,MAAM,CAAC,gBAAgB,KAAK,SAAS;YACpC,CAAC,CAAC,MAAM,CAAC,gBAAgB;YACzB,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,IAAI,IAAI,CAAC;KACvC,CAAA;IAED,SAAS,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACxD,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC7B,OAAO,MAAM,CAAA;AACd,CAAC"}
@@ -58,6 +58,21 @@ export function createCoordinationStore(projectRoot: any): {
58
58
  data: any;
59
59
  };
60
60
  } | null;
61
+ /**
62
+ * @internal — LD-01: read the per-machine Last-Seen Marker. Returns
63
+ * null when the git email is absent or the marker has not been written.
64
+ */
65
+ readLastSeen(): {
66
+ last_run_at: string | null;
67
+ last_main_sha: string | null;
68
+ last_active_task: string | null;
69
+ } | null;
70
+ /**
71
+ * @internal — LD-02: advance the Last-Seen Marker. `last_run_at` is
72
+ * always settable; `last_main_sha` / `last_active_task` are optional
73
+ * partial fields merged onto the existing record.
74
+ */
75
+ advanceLastSeen(fields?: {}): object | null;
61
76
  /** @internal */
62
77
  getIdentity(): any;
63
78
  };
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.mts","sourceRoot":"","sources":["../../../src/cli/coordination/store.mjs"],"names":[],"mappings":"AAyCA;;;;;;GAMG;AACH;IAKE,gBAAgB;;IAGhB,sEAAsE;;IAUtE;;;OAGG;;IAWH;;;OAGG;;IAqBH;;;;OAIG;;IAKH,wCAAwC;;IAKxC;;;;OAIG;;IAKH;;;;;;;;;;OAUG;;;;;;;;;;;;;;IAiBH,gBAAgB;;EAKjB"}
1
+ {"version":3,"file":"store.d.mts","sourceRoot":"","sources":["../../../src/cli/coordination/store.mjs"],"names":[],"mappings":"AA0CA;;;;;;GAMG;AACH;IAKE,gBAAgB;;IAGhB,sEAAsE;;IAUtE;;;OAGG;;IAWH;;;OAGG;;IAqBH;;;;OAIG;;IAKH,wCAAwC;;IAKxC;;;;OAIG;;IAKH;;;;;;;;;;OAUG;;;;;;;;;;;;;;IAiBH;;;OAGG;;;;;;IAKH;;;;OAIG;;IAKH,gBAAgB;;EAKjB"}
@@ -32,6 +32,7 @@ import { atomicWriteJson } from '../util/io.mjs';
32
32
  import { getAgentIdentity, resolveSharedRoot } from './agent-identity.mjs';
33
33
  import { appendLifecycleEvent } from './event-log.mjs';
34
34
  import { validateConductorEvent } from './event-schema.mjs';
35
+ import { advanceLastSeen as lastSeenAdvance, readLastSeen as lastSeenRead } from './last-seen.mjs';
35
36
  import { listActive as teamStatusListActive, removeSelf as teamStatusRemoveSelf, upsertSelf as teamStatusUpsertSelf, } from './team-status.mjs';
36
37
  /**
37
38
  * Construct a coordination store bound to a specific project root. The
@@ -134,6 +135,21 @@ export function createCoordinationStore(projectRoot) {
134
135
  return null;
135
136
  }
136
137
  },
138
+ /**
139
+ * @internal — LD-01: read the per-machine Last-Seen Marker. Returns
140
+ * null when the git email is absent or the marker has not been written.
141
+ */
142
+ readLastSeen() {
143
+ return lastSeenRead(projectRoot);
144
+ },
145
+ /**
146
+ * @internal — LD-02: advance the Last-Seen Marker. `last_run_at` is
147
+ * always settable; `last_main_sha` / `last_active_task` are optional
148
+ * partial fields merged onto the existing record.
149
+ */
150
+ advanceLastSeen(fields = {}) {
151
+ return lastSeenAdvance(projectRoot, fields);
152
+ },
137
153
  /** @internal */
138
154
  getIdentity() {
139
155
  return getAgentIdentity(projectRoot);
@@ -1 +1 @@
1
- {"version":3,"file":"store.mjs","sourceRoot":"","sources":["../../../src/cli/coordination/store.mjs"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,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thesized positional ID (O1, O2, ...)
4
- * @property {('electron'|'web'|'cli'|'api'|'electron+web')} surface
4
+ * @property {('electron'|'web'|'cli'|'api'|'mobile'|'electron+web')} surface
5
5
  * @property {string} text — outcome prose (sans the surface tag and requires suffix)
6
+ * @property {string[]} inferred — v0.9.0 — indented child bullets under the parent outcome (raw prose, no further parsing). Defaults to [] when no children are present.
6
7
  * @property {number} [requires] — the digit captured from `*(requires ON N)*`, when present and valid
7
8
  */
8
9
  /**
@@ -49,11 +50,15 @@ export type UserOutcome = {
49
50
  * — synthesized positional ID (O1, O2, ...)
50
51
  */
51
52
  id: string;
52
- surface: ("electron" | "web" | "cli" | "api" | "electron+web");
53
+ surface: ("electron" | "web" | "cli" | "api" | "mobile" | "electron+web");
53
54
  /**
54
55
  * — outcome prose (sans the surface tag and requires suffix)
55
56
  */
56
57
  text: string;
58
+ /**
59
+ * — v0.9.0 — indented child bullets under the parent outcome (raw prose, no further parsing). Defaults to [] when no children are present.
60
+ */
61
+ inferred: string[];
57
62
  /**
58
63
  * — the digit captured from `*(requires ON N)*`, when present and valid
59
64
  */
@@ -1 +1 @@
1
- {"version":3,"file":"user-outcomes.d.mts","sourceRoot":"","sources":["../../../src/cli/coverage-check/user-outcomes.mjs"],"names":[],"mappings":"AA4CA;;;;;;GAMG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,+CAHW,MAAM,GACJ,uBAAuB,CAwJnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,+CAJW,uBAAuB,oBACvB,MAAM,GACJ,CAAC,MAAM,GAAC,MAAM,GAAC,OAAO,CAAC,CAiBnC;;;;;QApNa,MAAM;aACN,CAAC,UAAU,GAAC,KAAK,GAAC,KAAK,GAAC,KAAK,GAAC,cAAc,CAAC;;;;UAC7C,MAAM;;;;;;;UAMN,yBAAyB;;;;gBACzB,MAAM;;;;cACN,MAAM;;;;YACN,MAAM;;;oBAKN,OAAO;eACP,CAAC,QAAQ,GAAC,OAAO,GAAC,iBAAiB,GAAC,UAAU,CAAC;;cAE/C,WAAW,EAAE"}
1
+ {"version":3,"file":"user-outcomes.d.mts","sourceRoot":"","sources":["../../../src/cli/coverage-check/user-outcomes.mjs"],"names":[],"mappings":"AA4CA;;;;;;;GAOG;AAEH;;;;;;GAMG;AAEH;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,+CAHW,MAAM,GACJ,uBAAuB,CA0LnC;AAED;;;;;;;;;;;;;;;GAeG;AACH,+CAJW,uBAAuB,oBACvB,MAAM,GACJ,CAAC,MAAM,GAAC,MAAM,GAAC,OAAO,CAAC,CAiBnC;;;;;QAvPa,MAAM;aACN,CAAC,UAAU,GAAC,KAAK,GAAC,KAAK,GAAC,KAAK,GAAC,QAAQ,GAAC,cAAc,CAAC;;;;UACtD,MAAM;;;;cACN,MAAM,EAAE;;;;;;;UAMR,yBAAyB;;;;gBACzB,MAAM;;;;cACN,MAAM;;;;YACN,MAAM;;;oBAKN,OAAO;eACP,CAAC,QAAQ,GAAC,OAAO,GAAC,iBAAiB,GAAC,UAAU,CAAC;;cAE/C,WAAW,EAAE"}
@@ -32,17 +32,18 @@
32
32
  * See packages/framework/skills/apt-plan/SKILL.md Section 5.B for the
33
33
  * authoring contract.
34
34
  */
35
- const VALID_SURFACES = new Set(['electron', 'web', 'cli', 'api', 'electron+web']);
35
+ const VALID_SURFACES = new Set(['electron', 'web', 'cli', 'api', 'mobile', 'electron+web']);
36
36
  const HEADING_RE = /^(#{1,6})\s+(.*)$/;
37
37
  const USER_OUTCOMES_HEADING_RE = /^user\s+outcomes\s*$/i;
38
38
  const EPIC_RE = /^\*\*Epic:\*\*\s+(.+)$/;
39
39
  const EMPTY_WITH_NOTE_RE = /^_No user-observable changes — pure refactor\._\s*$/;
40
- const OUTCOME_RE = /^-\s+\*\*ON\*\*\s+\[(electron|web|cli|api|electron\+web)\]:\s+(.+?)(\s+\*\(requires\s+ON\s+(\d+)\)\*)?\s*$/;
40
+ const OUTCOME_RE = /^-\s+\*\*ON\*\*\s+\[(electron|web|cli|api|mobile|electron\+web)\]:\s+(.+?)(\s+\*\(requires\s+ON\s+(\d+)\)\*)?\s*$/;
41
41
  /**
42
42
  * @typedef {Object} UserOutcome
43
43
  * @property {string} id — synthesized positional ID (O1, O2, ...)
44
- * @property {('electron'|'web'|'cli'|'api'|'electron+web')} surface
44
+ * @property {('electron'|'web'|'cli'|'api'|'mobile'|'electron+web')} surface
45
45
  * @property {string} text — outcome prose (sans the surface tag and requires suffix)
46
+ * @property {string[]} inferred — v0.9.0 — indented child bullets under the parent outcome (raw prose, no further parsing). Defaults to [] when no children are present.
46
47
  * @property {number} [requires] — the digit captured from `*(requires ON N)*`, when present and valid
47
48
  */
48
49
  /**
@@ -151,26 +152,58 @@ export function parseUserOutcomes(specContent) {
151
152
  result.epic = epic;
152
153
  return result;
153
154
  }
154
- // Parse outcome rows in document order. Skip non-matching lines (e.g.
155
- // stray prose between outcomes) they don't count as outcomes.
155
+ // Parse outcome rows in document order. v0.9.0 walk the raw body lines
156
+ // (not the trimmed `outcomeLines`) so we preserve indentation of child
157
+ // bullets. A `**ON**` parent row is followed by zero or more indented
158
+ // child bullets (lines starting with at least 2 spaces + `- `); those
159
+ // children attach to the parent as `inferred: string[]` (raw prose, no
160
+ // further parsing). The children block ends at the next `**ON**` row,
161
+ // a non-indented line, or a section terminator (blank line followed by
162
+ // another non-bullet non-blank line is fine; the next `**ON**` always
163
+ // resets ownership).
156
164
  /** @type {UserOutcome[]} */
157
165
  const outcomes = [];
158
166
  const rawRequires = [];
159
- for (const line of outcomeLines) {
160
- const m = line.match(OUTCOME_RE);
161
- if (!m)
167
+ const CHILD_RE = /^(?: {2}|\t)+- (.+)$/;
168
+ let currentOutcomeIndex = -1;
169
+ for (let i = 0; i < bodyLines.length; i++) {
170
+ const rawLine = bodyLines[i];
171
+ const trimmed = rawLine.trim();
172
+ if (trimmed.length === 0) {
173
+ // Blank lines don't close the parent — children may resume after
174
+ // a blank line (loose-list markdown). The next non-blank line
175
+ // decides ownership.
162
176
  continue;
163
- const surface = /** @type {UserOutcome['surface']} */ (m[1]);
164
- if (!VALID_SURFACES.has(surface))
177
+ }
178
+ const onMatch = trimmed.match(OUTCOME_RE);
179
+ if (onMatch) {
180
+ const surface = /** @type {UserOutcome['surface']} */ (onMatch[1]);
181
+ if (!VALID_SURFACES.has(surface)) {
182
+ currentOutcomeIndex = -1;
183
+ continue;
184
+ }
185
+ const text = onMatch[2].trim();
186
+ const id = 'O' + (outcomes.length + 1);
187
+ const outcome = /** @type {UserOutcome} */ ({ id, surface, text, inferred: [] });
188
+ if (onMatch[4]) {
189
+ const n = Number.parseInt(onMatch[4], 10);
190
+ rawRequires.push({ outcomeIndex: outcomes.length, requires: n });
191
+ }
192
+ outcomes.push(outcome);
193
+ currentOutcomeIndex = outcomes.length - 1;
194
+ continue;
195
+ }
196
+ // Non-`**ON**` non-blank line. If it's an indented child bullet AND
197
+ // we have a current outcome, attach it. Otherwise (e.g. Epic line,
198
+ // sentinel, stray prose), drop ownership.
199
+ const childMatch = rawLine.match(CHILD_RE);
200
+ if (childMatch && currentOutcomeIndex >= 0) {
201
+ outcomes[currentOutcomeIndex].inferred.push(childMatch[1].trim());
165
202
  continue;
166
- const text = m[2].trim();
167
- const id = 'O' + (outcomes.length + 1);
168
- const outcome = /** @type {UserOutcome} */ ({ id, surface, text });
169
- if (m[4]) {
170
- const n = Number.parseInt(m[4], 10);
171
- rawRequires.push({ outcomeIndex: outcomes.length, requires: n });
172
203
  }
173
- outcomes.push(outcome);
204
+ // Non-indented, non-`**ON**` line — closes the current outcome's
205
+ // child block. (The next `**ON**` will start a new block.)
206
+ currentOutcomeIndex = -1;
174
207
  }
175
208
  if (outcomes.length === 0) {
176
209
  // Header present, prose present, but no parseable `**ON**` rows —