@ouro.bot/cli 0.1.0-alpha.21 → 0.1.0-alpha.211

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 (233) hide show
  1. package/README.md +187 -191
  2. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/agent.json +3 -2
  3. package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/SOUL.md +1 -1
  4. package/changelog.json +1318 -0
  5. package/dist/arc/attention-types.js +8 -0
  6. package/dist/arc/cares.js +140 -0
  7. package/dist/arc/episodes.js +119 -0
  8. package/dist/arc/intentions.js +133 -0
  9. package/dist/arc/json-store.js +120 -0
  10. package/dist/arc/obligations.js +237 -0
  11. package/dist/arc/presence.js +185 -0
  12. package/dist/heart/active-work.js +832 -0
  13. package/dist/heart/agent-entry.js +37 -2
  14. package/dist/heart/auth/auth-flow.js +444 -0
  15. package/dist/heart/bridges/manager.js +358 -0
  16. package/dist/heart/bridges/state-machine.js +135 -0
  17. package/dist/heart/bridges/store.js +123 -0
  18. package/dist/heart/commitments.js +111 -0
  19. package/dist/heart/config-registry.js +305 -0
  20. package/dist/heart/config.js +59 -30
  21. package/dist/heart/core.js +606 -131
  22. package/dist/heart/cross-chat-delivery.js +146 -0
  23. package/dist/heart/daemon/agent-config-check.js +149 -0
  24. package/dist/heart/daemon/agent-discovery.js +81 -0
  25. package/dist/heart/daemon/agent-service.js +360 -0
  26. package/dist/heart/daemon/cadence.js +70 -0
  27. package/dist/heart/daemon/cli-defaults.js +557 -0
  28. package/dist/heart/daemon/cli-exec.js +1847 -0
  29. package/dist/heart/daemon/cli-parse.js +759 -0
  30. package/dist/heart/daemon/cli-render.js +316 -0
  31. package/dist/heart/daemon/cli-types.js +8 -0
  32. package/dist/heart/daemon/daemon-cli.js +29 -1163
  33. package/dist/heart/daemon/daemon-entry.js +182 -4
  34. package/dist/heart/daemon/daemon-health.js +136 -0
  35. package/dist/heart/daemon/daemon-runtime-sync.js +153 -12
  36. package/dist/heart/daemon/daemon-tombstone.js +123 -0
  37. package/dist/heart/daemon/daemon.js +491 -18
  38. package/dist/heart/daemon/hooks/agent-config-v2.js +33 -0
  39. package/dist/heart/daemon/hooks/bundle-meta.js +206 -0
  40. package/dist/heart/daemon/inner-status.js +89 -0
  41. package/dist/heart/daemon/launchd.js +165 -0
  42. package/dist/heart/daemon/log-tailer.js +4 -3
  43. package/dist/heart/daemon/message-router.js +17 -8
  44. package/dist/heart/daemon/os-cron-deps.js +134 -0
  45. package/dist/heart/daemon/ouro-bot-entry.js +1 -1
  46. package/dist/heart/daemon/process-manager.js +123 -0
  47. package/dist/heart/daemon/run-hooks.js +39 -0
  48. package/dist/heart/daemon/runtime-logging.js +58 -15
  49. package/dist/heart/daemon/runtime-metadata.js +101 -0
  50. package/dist/heart/daemon/runtime-mode.js +67 -0
  51. package/dist/heart/daemon/safe-mode.js +161 -0
  52. package/dist/heart/daemon/sense-manager.js +71 -2
  53. package/dist/heart/daemon/session-id-resolver.js +131 -0
  54. package/dist/heart/daemon/skill-management-installer.js +94 -0
  55. package/dist/heart/daemon/socket-client.js +202 -0
  56. package/dist/heart/daemon/task-scheduler.js +3 -25
  57. package/dist/heart/daemon/thoughts.js +507 -0
  58. package/dist/heart/delegation.js +62 -0
  59. package/dist/heart/habits/habit-migration.js +181 -0
  60. package/dist/heart/habits/habit-parser.js +119 -0
  61. package/dist/heart/habits/habit-scheduler.js +369 -0
  62. package/dist/heart/{daemon → hatch}/hatch-flow.js +29 -119
  63. package/dist/heart/{daemon → hatch}/hatch-specialist.js +3 -3
  64. package/dist/heart/{daemon → hatch}/specialist-prompt.js +10 -7
  65. package/dist/heart/{daemon → hatch}/specialist-tools.js +49 -3
  66. package/dist/heart/identity.js +144 -55
  67. package/dist/heart/kicks.js +2 -20
  68. package/dist/heart/mcp/mcp-server.js +608 -0
  69. package/dist/heart/migrate-config.js +127 -0
  70. package/dist/heart/model-capabilities.js +48 -0
  71. package/dist/heart/outlook/outlook-http.js +439 -0
  72. package/dist/heart/outlook/outlook-read.js +1618 -0
  73. package/dist/heart/outlook/outlook-render.js +1032 -0
  74. package/dist/heart/outlook/outlook-types.js +7 -0
  75. package/dist/heart/outlook/outlook-view.js +194 -0
  76. package/dist/heart/progress-story.js +42 -0
  77. package/dist/heart/provider-failover.js +88 -0
  78. package/dist/heart/provider-ping.js +162 -0
  79. package/dist/heart/providers/anthropic-token.js +163 -0
  80. package/dist/heart/providers/anthropic.js +187 -41
  81. package/dist/heart/providers/azure.js +116 -10
  82. package/dist/heart/providers/github-copilot.js +157 -0
  83. package/dist/heart/providers/minimax.js +33 -3
  84. package/dist/heart/providers/openai-codex.js +51 -16
  85. package/dist/heart/session-activity.js +172 -0
  86. package/dist/heart/session-recall.js +216 -0
  87. package/dist/heart/start-of-turn-packet.js +330 -0
  88. package/dist/heart/streaming.js +36 -27
  89. package/dist/heart/sync.js +217 -0
  90. package/dist/heart/target-resolution.js +127 -0
  91. package/dist/heart/tempo.js +93 -0
  92. package/dist/heart/temporal-view.js +41 -0
  93. package/dist/heart/tool-activity-callbacks.js +36 -0
  94. package/dist/heart/tool-description.js +135 -0
  95. package/dist/heart/tool-loop.js +200 -0
  96. package/dist/heart/turn-context.js +358 -0
  97. package/dist/heart/turn-coordinator.js +28 -0
  98. package/dist/heart/versioning/ouro-bot-global-installer.js +128 -0
  99. package/dist/heart/{daemon → versioning}/ouro-bot-wrapper.js +1 -1
  100. package/dist/heart/{daemon → versioning}/ouro-path-installer.js +78 -35
  101. package/dist/heart/versioning/ouro-version-manager.js +171 -0
  102. package/dist/heart/versioning/staged-restart.js +138 -0
  103. package/dist/heart/versioning/update-checker.js +111 -0
  104. package/dist/heart/versioning/update-hooks.js +138 -0
  105. package/dist/heart/{daemon → versioning}/wrapper-publish-guard.js +41 -3
  106. package/dist/mind/associative-recall.js +126 -66
  107. package/dist/mind/bundle-manifest.js +19 -1
  108. package/dist/mind/context.js +125 -14
  109. package/dist/mind/{memory.js → diary.js} +73 -96
  110. package/dist/mind/embedding-provider.js +60 -0
  111. package/dist/mind/file-state.js +179 -0
  112. package/dist/mind/first-impressions.js +16 -2
  113. package/dist/mind/friends/channel.js +56 -0
  114. package/dist/mind/friends/group-context.js +144 -0
  115. package/dist/mind/friends/store-file.js +36 -0
  116. package/dist/mind/friends/trust-explanation.js +74 -0
  117. package/dist/mind/friends/types.js +8 -0
  118. package/dist/mind/journal-index.js +161 -0
  119. package/dist/mind/obligation-steering.js +221 -0
  120. package/dist/mind/pending.js +76 -9
  121. package/dist/mind/phrases.js +1 -0
  122. package/dist/mind/prompt.js +795 -108
  123. package/dist/mind/scrutiny.js +173 -0
  124. package/dist/mind/token-estimate.js +8 -12
  125. package/dist/nerves/coverage/audit.js +1 -1
  126. package/dist/nerves/coverage/file-completeness.js +47 -5
  127. package/dist/nerves/coverage/run-artifacts.js +1 -1
  128. package/dist/nerves/event-buffer.js +111 -0
  129. package/dist/nerves/index.js +63 -3
  130. package/dist/nerves/observation.js +20 -0
  131. package/dist/nerves/runtime.js +5 -1
  132. package/dist/outlook-ui/assets/index-Ck8agNeO.js +61 -0
  133. package/dist/outlook-ui/assets/index-LwChZTgL.css +1 -0
  134. package/dist/outlook-ui/index.html +15 -0
  135. package/dist/repertoire/ado-client.js +15 -56
  136. package/dist/repertoire/ado-semantic.js +11 -5
  137. package/dist/repertoire/api-client.js +71 -0
  138. package/dist/repertoire/coding/codex-jsonl.js +64 -0
  139. package/dist/repertoire/coding/context-pack.js +330 -0
  140. package/dist/repertoire/coding/feedback.js +197 -30
  141. package/dist/repertoire/coding/manager.js +149 -2
  142. package/dist/repertoire/coding/spawner.js +55 -9
  143. package/dist/repertoire/coding/tools.js +170 -7
  144. package/dist/repertoire/github-client.js +14 -55
  145. package/dist/repertoire/graph-client.js +11 -52
  146. package/dist/repertoire/guardrails.js +291 -0
  147. package/dist/repertoire/mcp-client.js +254 -0
  148. package/dist/repertoire/mcp-manager.js +251 -0
  149. package/dist/repertoire/shell-sessions.js +133 -0
  150. package/dist/repertoire/skills.js +14 -23
  151. package/dist/repertoire/tasks/board.js +43 -5
  152. package/dist/repertoire/tasks/fix.js +182 -0
  153. package/dist/repertoire/tasks/index.js +28 -10
  154. package/dist/repertoire/tasks/lifecycle.js +2 -2
  155. package/dist/repertoire/tasks/parser.js +3 -2
  156. package/dist/repertoire/tasks/scanner.js +194 -37
  157. package/dist/repertoire/tasks/transitions.js +11 -28
  158. package/dist/repertoire/tools-base.js +31 -771
  159. package/dist/repertoire/tools-bluebubbles.js +94 -0
  160. package/dist/repertoire/tools-bridge.js +141 -0
  161. package/dist/repertoire/tools-config.js +266 -0
  162. package/dist/repertoire/tools-continuity.js +248 -0
  163. package/dist/repertoire/tools-files.js +342 -0
  164. package/dist/repertoire/tools-flow.js +62 -0
  165. package/dist/repertoire/tools-github.js +1 -6
  166. package/dist/repertoire/tools-memory.js +347 -0
  167. package/dist/repertoire/tools-session.js +682 -0
  168. package/dist/repertoire/tools-shell.js +120 -0
  169. package/dist/repertoire/tools-surface.js +228 -0
  170. package/dist/repertoire/tools-teams.js +12 -59
  171. package/dist/repertoire/tools.js +132 -124
  172. package/dist/scripts/claude-code-hook.js +41 -0
  173. package/dist/scripts/claude-code-stop-hook.js +47 -0
  174. package/dist/senses/attention-queue.js +97 -0
  175. package/dist/senses/bluebubbles-client.js +102 -3
  176. package/dist/senses/bluebubbles-entry.js +2 -0
  177. package/dist/senses/bluebubbles-inbound-log.js +109 -0
  178. package/dist/senses/bluebubbles-media.js +118 -23
  179. package/dist/senses/bluebubbles-model.js +12 -4
  180. package/dist/senses/bluebubbles-mutation-log.js +45 -5
  181. package/dist/senses/bluebubbles-runtime-state.js +109 -0
  182. package/dist/senses/bluebubbles-session-cleanup.js +72 -0
  183. package/dist/senses/bluebubbles.js +1008 -102
  184. package/dist/senses/cli/adapter.js +274 -0
  185. package/dist/senses/cli/ink-app.js +156 -0
  186. package/dist/senses/cli/inline-diff.js +64 -0
  187. package/dist/senses/cli/message-list.js +51 -0
  188. package/dist/senses/cli/ouro-tui.js +358 -0
  189. package/dist/senses/cli/spinner-imperative.js +135 -0
  190. package/dist/senses/cli/spinner.js +101 -0
  191. package/dist/senses/cli/status-line.js +60 -0
  192. package/dist/senses/cli/streaming-markdown.js +526 -0
  193. package/dist/senses/cli/tool-display.js +83 -0
  194. package/dist/senses/cli/tool-render.js +85 -0
  195. package/dist/senses/cli/tui-store.js +198 -0
  196. package/dist/senses/cli/virtual-list.js +35 -0
  197. package/dist/senses/cli-entry.js +1 -1
  198. package/dist/senses/cli-layout.js +187 -0
  199. package/dist/senses/cli.js +508 -243
  200. package/dist/senses/commands.js +65 -1
  201. package/dist/senses/continuity.js +94 -0
  202. package/dist/senses/habit-turn-message.js +108 -0
  203. package/dist/senses/inner-dialog-worker.js +112 -19
  204. package/dist/senses/inner-dialog.js +591 -84
  205. package/dist/senses/pipeline.js +559 -0
  206. package/dist/senses/shared-turn.js +196 -0
  207. package/dist/senses/surface-tool.js +68 -0
  208. package/dist/senses/teams.js +667 -120
  209. package/dist/senses/trust-gate.js +112 -2
  210. package/package.json +16 -6
  211. package/skills/configure-dev-tools.md +81 -0
  212. package/subagents/README.md +4 -70
  213. package/dist/heart/daemon/subagent-installer.js +0 -134
  214. package/dist/senses/debug-activity.js +0 -107
  215. package/subagents/work-doer.md +0 -235
  216. package/subagents/work-merger.md +0 -618
  217. package/subagents/work-planner.md +0 -382
  218. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/basilisk.md +0 -0
  219. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jafar.md +0 -0
  220. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/jormungandr.md +0 -0
  221. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/kaa.md +0 -0
  222. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/medusa.md +0 -0
  223. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/monty.md +0 -0
  224. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/nagini.md +0 -0
  225. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/ouroboros.md +0 -0
  226. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/python.md +0 -0
  227. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/quetzalcoatl.md +0 -0
  228. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/sir-hiss.md +0 -0
  229. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-serpent.md +0 -0
  230. /package/{AdoptionSpecialist.ouro → SerpentGuide.ouro}/psyche/identities/the-snake.md +0 -0
  231. /package/dist/heart/{daemon → hatch}/hatch-animation.js +0 -0
  232. /package/dist/heart/{daemon → hatch}/specialist-orchestrator.js +0 -0
  233. /package/dist/heart/{daemon → versioning}/ouro-uti.js +0 -0
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.addKindToLegacyCard = addKindToLegacyCard;
37
+ exports.applyFixes = applyFixes;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const runtime_1 = require("../../nerves/runtime");
41
+ const scanner_1 = require("./scanner");
42
+ const parser_1 = require("./parser");
43
+ function issueId(issue) {
44
+ return `${issue.code}:${issue.target}`;
45
+ }
46
+ function addKindToLegacyCard(root, issue) {
47
+ (0, runtime_1.emitNervesEvent)({
48
+ event: "repertoire.fix_apply_start",
49
+ component: "repertoire",
50
+ message: "adding kind: task to legacy card",
51
+ meta: { target: issue.target },
52
+ });
53
+ const filePath = path.join(root, issue.target);
54
+ if (!fs.existsSync(filePath))
55
+ return false;
56
+ const content = fs.readFileSync(filePath, "utf-8");
57
+ const frontmatter = (0, scanner_1.tryExtractFrontmatter)(content);
58
+ if (!frontmatter)
59
+ return false;
60
+ // Add kind: task to frontmatter
61
+ frontmatter.kind = "task";
62
+ // Extract body (everything after the second ---)
63
+ const lines = content.split(/\r?\n/);
64
+ const firstDelim = lines.findIndex((line) => line.trim() === "---");
65
+ const secondDelim = lines.findIndex((line, idx) => idx > firstDelim && line.trim() === "---");
66
+ const body = lines.slice(secondDelim + 1).join("\n").replace(/^\n/, "");
67
+ const rendered = (0, parser_1.renderTaskFile)(frontmatter, body);
68
+ fs.writeFileSync(filePath, rendered, "utf-8");
69
+ return true;
70
+ }
71
+ function applySingleFix(root, issue) {
72
+ switch (issue.code) {
73
+ case "schema-missing-kind":
74
+ return addKindToLegacyCard(root, issue);
75
+ default:
76
+ return false;
77
+ }
78
+ }
79
+ function applyFixes(options, root) {
80
+ (0, runtime_1.emitNervesEvent)({
81
+ event: "repertoire.fix_start",
82
+ component: "repertoire",
83
+ message: `applying fixes in ${options.mode} mode`,
84
+ meta: { mode: options.mode, root },
85
+ });
86
+ (0, scanner_1.clearTaskScanCache)();
87
+ const index = (0, scanner_1.scanTasks)(root);
88
+ const issues = index.issues;
89
+ if (options.mode === "dry-run") {
90
+ (0, runtime_1.emitNervesEvent)({
91
+ event: "repertoire.fix_complete",
92
+ component: "repertoire",
93
+ message: "dry-run complete, no changes made",
94
+ meta: { issueCount: issues.length },
95
+ });
96
+ const health = issues.length === 0 ? "clean" : buildHealthSummary(issues);
97
+ return {
98
+ applied: [],
99
+ remaining: issues,
100
+ skipped: [],
101
+ health,
102
+ };
103
+ }
104
+ if (options.mode === "single") {
105
+ const targetId = options.issueId ?? "";
106
+ const match = issues.find((i) => issueId(i) === targetId);
107
+ if (!match) {
108
+ (0, runtime_1.emitNervesEvent)({
109
+ event: "repertoire.fix_complete",
110
+ component: "repertoire",
111
+ message: "single fix: issue not found",
112
+ meta: { issueId: targetId },
113
+ });
114
+ const health = issues.length === 0 ? "clean" : buildHealthSummary(issues);
115
+ return {
116
+ applied: [],
117
+ remaining: issues,
118
+ skipped: [],
119
+ health,
120
+ };
121
+ }
122
+ const success = applySingleFix(root, match);
123
+ (0, scanner_1.clearTaskScanCache)();
124
+ const afterIndex = (0, scanner_1.scanTasks)(root);
125
+ const afterIssues = afterIndex.issues;
126
+ const health = afterIssues.length === 0 ? "clean" : buildHealthSummary(afterIssues);
127
+ (0, runtime_1.emitNervesEvent)({
128
+ event: "repertoire.fix_complete",
129
+ component: "repertoire",
130
+ message: `single fix ${success ? "applied" : "failed"}`,
131
+ meta: { issueId: targetId, success },
132
+ });
133
+ return {
134
+ applied: success ? [match] : [],
135
+ remaining: afterIssues,
136
+ skipped: success ? [] : [match],
137
+ health,
138
+ };
139
+ }
140
+ // safe mode: apply all safe-confidence fixes
141
+ const applied = [];
142
+ const skipped = [];
143
+ for (const issue of issues) {
144
+ if (issue.confidence !== "safe") {
145
+ skipped.push(issue);
146
+ continue;
147
+ }
148
+ const success = applySingleFix(root, issue);
149
+ if (success) {
150
+ applied.push(issue);
151
+ }
152
+ else {
153
+ skipped.push(issue);
154
+ }
155
+ }
156
+ (0, scanner_1.clearTaskScanCache)();
157
+ const afterIndex = (0, scanner_1.scanTasks)(root);
158
+ const afterIssues = afterIndex.issues;
159
+ const health = afterIssues.length === 0 ? "clean" : buildHealthSummary(afterIssues);
160
+ (0, runtime_1.emitNervesEvent)({
161
+ event: "repertoire.fix_complete",
162
+ component: "repertoire",
163
+ message: `safe fixes complete: ${applied.length} applied, ${skipped.length} skipped`,
164
+ meta: { applied: applied.length, skipped: skipped.length },
165
+ });
166
+ return {
167
+ applied,
168
+ remaining: afterIssues,
169
+ skipped,
170
+ health,
171
+ };
172
+ }
173
+ function buildHealthSummary(issues) {
174
+ const liveCount = issues.filter((i) => i.category === "live").length;
175
+ const migrationCount = issues.filter((i) => i.category === "migration").length;
176
+ const parts = [];
177
+ if (liveCount > 0)
178
+ parts.push(`${liveCount} live`);
179
+ if (migrationCount > 0)
180
+ parts.push(`${migrationCount} migration`);
181
+ return parts.join(", ");
182
+ }
@@ -37,8 +37,10 @@ exports.getTaskModule = getTaskModule;
37
37
  exports.resetTaskModule = resetTaskModule;
38
38
  const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
+ const config_1 = require("../../heart/config");
40
41
  const runtime_1 = require("../../nerves/runtime");
41
42
  const board_1 = require("./board");
43
+ const fix_1 = require("./fix");
42
44
  const lifecycle_1 = require("./lifecycle");
43
45
  const parser_1 = require("./parser");
44
46
  const scanner_1 = require("./scanner");
@@ -55,14 +57,6 @@ function formatStemTimestamp(now = new Date()) {
55
57
  const minutes = String(now.getMinutes()).padStart(2, "0");
56
58
  return `${year}-${month}-${day}-${hours}${minutes}`;
57
59
  }
58
- function slugify(input) {
59
- return input
60
- .toLowerCase()
61
- .replace(/[^a-z0-9]+/g, "-")
62
- .replace(/^-+/, "")
63
- .replace(/-+$/, "")
64
- .slice(0, 64);
65
- }
66
60
  function findTask(index, nameOrStem) {
67
61
  return (index.tasks.find((task) => task.stem === nameOrStem || task.name === nameOrStem) ??
68
62
  index.tasks.find((task) => task.stem.endsWith(nameOrStem)) ??
@@ -98,12 +92,13 @@ class FileTaskModule {
98
92
  throw new Error(`invalid task status: ${String(input.status)}`);
99
93
  }
100
94
  const collection = (0, transitions_1.canonicalCollectionForTaskType)(type);
101
- const stem = `${formatStemTimestamp()}-${slugify(input.title) || "task"}`;
95
+ const stem = `${formatStemTimestamp()}-${(0, config_1.slugify)(input.title).slice(0, 64) || "task"}`;
102
96
  const filename = `${stem}.md`;
103
97
  const root = (0, scanner_1.getTaskRoot)();
104
98
  const filePath = path.join(root, collection, filename);
105
99
  const today = formatDate();
106
100
  const frontmatter = {
101
+ kind: "task",
107
102
  type,
108
103
  category: input.category || "infrastructure",
109
104
  title: input.title,
@@ -115,13 +110,18 @@ class FileTaskModule {
115
110
  lastRun: input.lastRun ?? null,
116
111
  created: today,
117
112
  updated: today,
118
- child_tasks: [],
119
113
  artifacts: [],
120
114
  };
121
115
  if (type === "one-shot") {
122
116
  frontmatter.parent_task = null;
123
117
  frontmatter.depends_on = [];
124
118
  }
119
+ if (input.activeBridge && input.activeBridge.trim()) {
120
+ frontmatter.active_bridge = input.activeBridge.trim();
121
+ }
122
+ if (Array.isArray(input.bridgeSessions) && input.bridgeSessions.length > 0) {
123
+ frontmatter.bridge_sessions = input.bridgeSessions.filter((value) => typeof value === "string" && value.trim());
124
+ }
125
125
  const content = (0, parser_1.renderTaskFile)(frontmatter, input.body);
126
126
  const validation = (0, middleware_1.validateWrite)(filePath, content);
127
127
  if (!validation.ok) {
@@ -132,6 +132,21 @@ class FileTaskModule {
132
132
  (0, scanner_1.clearTaskScanCache)();
133
133
  return filePath;
134
134
  }
135
+ bindBridge(name, input) {
136
+ const task = this.getTask(name);
137
+ if (!task) {
138
+ return { ok: false, reason: `task not found: ${name}` };
139
+ }
140
+ const content = fs.readFileSync(task.path, "utf-8");
141
+ const parsed = (0, parser_1.parseTaskFile)(content, task.path);
142
+ const frontmatter = removeRuntimeFrontmatter(parsed.frontmatter);
143
+ frontmatter.active_bridge = input.bridgeId.trim();
144
+ frontmatter.bridge_sessions = input.sessionRefs.filter((value) => value.trim().length > 0);
145
+ frontmatter.updated = formatDate();
146
+ fs.writeFileSync(task.path, (0, parser_1.renderTaskFile)(frontmatter, parsed.body), "utf-8");
147
+ (0, scanner_1.clearTaskScanCache)();
148
+ return { ok: true, path: task.path };
149
+ }
135
150
  updateStatus(name, toStatus) {
136
151
  const normalized = (0, transitions_1.normalizeTaskStatus)(toStatus);
137
152
  if (!normalized) {
@@ -178,6 +193,9 @@ class FileTaskModule {
178
193
  }
179
194
  return (0, middleware_1.validateSpawn)(task, spawnType);
180
195
  }
196
+ fix(options) {
197
+ return (0, fix_1.applyFixes)(options, (0, scanner_1.getTaskRoot)());
198
+ }
181
199
  detectStale(thresholdDays) {
182
200
  return (0, lifecycle_1.detectStaleTasks)(this.scan(), thresholdDays);
183
201
  }
@@ -48,7 +48,7 @@ function archiveCompletedTasks(index) {
48
48
  const archived = [];
49
49
  const failures = [];
50
50
  for (const task of index.tasks) {
51
- if (task.status !== "done")
51
+ if (task.status !== "done" && task.status !== "cancelled")
52
52
  continue;
53
53
  const archiveDir = path.join(index.root, "archive", task.collection);
54
54
  const archiveFile = path.join(archiveDir, task.name);
@@ -73,7 +73,7 @@ function detectStaleTasks(index, thresholdDays, now = new Date()) {
73
73
  const updated = Date.parse(task.updated);
74
74
  if (Number.isNaN(updated))
75
75
  return false;
76
- if (task.status === "done")
76
+ if (task.status === "done" || task.status === "cancelled")
77
77
  return false;
78
78
  return updated < staleCutoffMs;
79
79
  });
@@ -96,8 +96,6 @@ function collectionFromPath(taskPath, type) {
96
96
  return "one-shots";
97
97
  if (parts.includes("ongoing"))
98
98
  return "ongoing";
99
- if (parts.includes("habits"))
100
- return "habits";
101
99
  return (0, transitions_1.canonicalCollectionForTaskType)(type);
102
100
  }
103
101
  function parseTaskFile(content, filePath) {
@@ -138,6 +136,9 @@ function parseTaskFile(content, filePath) {
138
136
  _isCanonicalFilename: (0, transitions_1.isCanonicalTaskFilename)(name),
139
137
  },
140
138
  body: parsed.body,
139
+ hasWorkDir: false,
140
+ workDirFiles: [],
141
+ derivedChildren: [],
141
142
  };
142
143
  }
143
144
  function formatFrontmatterValue(value) {
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.getTaskRoot = getTaskRoot;
37
37
  exports.ensureTaskLayout = ensureTaskLayout;
38
+ exports.tryExtractFrontmatter = tryExtractFrontmatter;
38
39
  exports.clearTaskScanCache = clearTaskScanCache;
39
40
  exports.scanTasks = scanTasks;
40
41
  const fs = __importStar(require("fs"));
@@ -59,30 +60,57 @@ function ensureTaskLayout(root = getTaskRoot()) {
59
60
  fs.mkdirSync(dir, { recursive: true });
60
61
  }
61
62
  }
62
- function walkMarkdownFiles(dir, acc) {
63
- if (!fs.existsSync(dir))
64
- return;
65
- const entries = fs.readdirSync(dir, { withFileTypes: true });
66
- for (const entry of entries) {
67
- if (entry.isDirectory()) {
68
- if (transitions_1.TASK_RESERVED_DIRECTORIES.includes(entry.name)) {
63
+ /**
64
+ * Attempt to extract frontmatter from markdown content.
65
+ * Returns parsed frontmatter dict or null. Never throws.
66
+ */
67
+ function tryExtractFrontmatter(content) {
68
+ (0, runtime_1.emitNervesEvent)({
69
+ event: "repertoire.frontmatter_extract_start",
70
+ component: "repertoire",
71
+ message: "attempting frontmatter extraction",
72
+ });
73
+ const lines = content.split(/\r?\n/);
74
+ if (lines[0]?.trim() !== "---") {
75
+ return null;
76
+ }
77
+ const closing = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
78
+ if (closing === -1) {
79
+ return null;
80
+ }
81
+ const rawFrontmatter = lines.slice(1, closing).join("\n");
82
+ return (0, parser_1.parseFrontmatter)(rawFrontmatter);
83
+ }
84
+ const LEGACY_TASK_TYPES = ["one-shot", "ongoing", "habit"];
85
+ function buildFingerprint(root) {
86
+ (0, runtime_1.emitNervesEvent)({
87
+ event: "repertoire.fingerprint_build_start",
88
+ component: "repertoire",
89
+ message: "building scan fingerprint",
90
+ meta: { root },
91
+ });
92
+ const segments = [];
93
+ for (const collection of transitions_1.TASK_CANONICAL_COLLECTIONS) {
94
+ const collDir = path.join(root, collection);
95
+ const entries = fs.readdirSync(collDir, { withFileTypes: true });
96
+ for (const entry of entries) {
97
+ if (!entry.isFile() || !entry.name.endsWith(".md"))
69
98
  continue;
70
- }
71
- walkMarkdownFiles(path.join(dir, entry.name), acc);
72
- continue;
73
- }
74
- if (entry.name.endsWith(".md")) {
75
- acc.push(path.join(dir, entry.name));
99
+ const filePath = path.join(collDir, entry.name);
100
+ const stat = fs.statSync(filePath);
101
+ segments.push(`${filePath}:${stat.mtimeMs}:${stat.size}`);
76
102
  }
77
103
  }
78
- }
79
- function buildFingerprint(paths) {
80
- const segments = paths
81
- .map((filePath) => {
104
+ // Also include root-level md files for orphan detection fingerprinting
105
+ const rootEntries = fs.readdirSync(root, { withFileTypes: true });
106
+ for (const entry of rootEntries) {
107
+ if (!entry.isFile() || !entry.name.endsWith(".md"))
108
+ continue;
109
+ const filePath = path.join(root, entry.name);
82
110
  const stat = fs.statSync(filePath);
83
- return `${filePath}:${stat.mtimeMs}:${stat.size}`;
84
- })
85
- .sort();
111
+ segments.push(`${filePath}:${stat.mtimeMs}:${stat.size}`);
112
+ }
113
+ segments.sort();
86
114
  return segments.join("|");
87
115
  }
88
116
  function clearTaskScanCache() {
@@ -96,35 +124,164 @@ function scanTasks(root = getTaskRoot()) {
96
124
  meta: { root },
97
125
  });
98
126
  ensureTaskLayout(root);
99
- const files = [];
100
- for (const collection of transitions_1.TASK_CANONICAL_COLLECTIONS) {
101
- walkMarkdownFiles(path.join(root, collection), files);
102
- }
103
- const fingerprint = buildFingerprint(files);
127
+ const fingerprint = buildFingerprint(root);
104
128
  if (scanCache && scanCache.fingerprint === fingerprint) {
105
129
  return scanCache.index;
106
130
  }
107
131
  const tasks = [];
108
- const parseErrors = [];
109
- const invalidFilenames = [];
110
- for (const filePath of files) {
111
- const base = path.basename(filePath);
112
- if (!(0, transitions_1.isCanonicalTaskFilename)(base)) {
113
- invalidFilenames.push(filePath);
132
+ const issues = [];
133
+ // Scan each collection with flat directory reads (no recursion)
134
+ for (const collection of transitions_1.TASK_CANONICAL_COLLECTIONS) {
135
+ const collDir = path.join(root, collection);
136
+ const entries = fs.readdirSync(collDir, { withFileTypes: true });
137
+ const dirNames = new Set();
138
+ // Collect directory names for work dir detection
139
+ for (const entry of entries) {
140
+ if (entry.isDirectory()) {
141
+ dirNames.add(entry.name);
142
+ }
114
143
  }
115
- try {
144
+ // Process only .md files at collection root (flat, no recursion)
145
+ let supportDocCount = 0;
146
+ for (const entry of entries) {
147
+ if (!entry.isFile() || !entry.name.endsWith(".md"))
148
+ continue;
149
+ const filePath = path.join(collDir, entry.name);
116
150
  const content = fs.readFileSync(filePath, "utf-8");
117
- tasks.push((0, parser_1.parseTaskFile)(content, filePath));
151
+ // Step 1: Try to extract frontmatter
152
+ const frontmatter = tryExtractFrontmatter(content);
153
+ if (!frontmatter) {
154
+ // No frontmatter — not a task, count as support doc clutter
155
+ supportDocCount += 1;
156
+ continue;
157
+ }
158
+ // Step 2: Check kind: task
159
+ const isKindTask = frontmatter.kind === "task";
160
+ const fmType = typeof frontmatter.type === "string" ? frontmatter.type.trim().toLowerCase() : "";
161
+ const isLegacyTask = !isKindTask && LEGACY_TASK_TYPES.includes(fmType);
162
+ if (!isKindTask && !isLegacyTask) {
163
+ // Has frontmatter but not a task — skip silently
164
+ continue;
165
+ }
166
+ // Step 3: Emit migration issue for legacy task
167
+ if (isLegacyTask) {
168
+ const relPath = path.relative(root, filePath);
169
+ issues.push({
170
+ target: relPath,
171
+ code: "schema-missing-kind",
172
+ description: "Task card missing kind: task field",
173
+ fix: "Add kind: task to frontmatter",
174
+ confidence: "safe",
175
+ category: "migration",
176
+ });
177
+ }
178
+ // Step 4: Parse the task file
179
+ try {
180
+ const task = (0, parser_1.parseTaskFile)(content, filePath);
181
+ // Check filename canonicality
182
+ const base = path.basename(filePath);
183
+ if (!(0, transitions_1.isCanonicalTaskFilename)(base)) {
184
+ const relPath = path.relative(root, filePath);
185
+ issues.push({
186
+ target: relPath,
187
+ code: "filename-not-canonical",
188
+ description: `Non-canonical filename: ${base}`,
189
+ fix: `Rename to canonical format (YYYY-MM-DD-HHMM-slug.md)`,
190
+ confidence: "safe",
191
+ category: "migration",
192
+ });
193
+ }
194
+ // Work dir detection
195
+ const stem = base.replace(/\.md$/i, "");
196
+ if (dirNames.has(stem)) {
197
+ task.hasWorkDir = true;
198
+ const workDirPath = path.join(collDir, stem);
199
+ task.workDirFiles = fs.readdirSync(workDirPath).sort();
200
+ }
201
+ tasks.push(task);
202
+ }
203
+ catch (error) {
204
+ // Parse error on a file we identified as a task — real issue
205
+ const relPath = path.relative(root, filePath);
206
+ issues.push({
207
+ target: relPath,
208
+ code: "schema-invalid",
209
+ description: `Parse error: ${error instanceof Error ? error.message : String(error)}`,
210
+ fix: "Fix the task card schema (ensure required fields: type, status, etc.)",
211
+ confidence: "needs_review",
212
+ category: "live",
213
+ });
214
+ }
215
+ }
216
+ // Summarize non-task support docs at collection root as one migration issue
217
+ if (supportDocCount > 0) {
218
+ (0, runtime_1.emitNervesEvent)({
219
+ event: "repertoire.support_docs_detected",
220
+ component: "repertoire",
221
+ message: "non-task support documents at collection root",
222
+ meta: { collection, count: supportDocCount },
223
+ });
224
+ issues.push({
225
+ target: collection,
226
+ code: "org-collection-root-clutter",
227
+ description: `${supportDocCount} non-task file${supportDocCount === 1 ? "" : "s"} at ${collection}/ root (doing docs, planning docs, etc.)`,
228
+ fix: "Move support docs into same-stem work directories for their parent tasks",
229
+ confidence: "needs_review",
230
+ category: "migration",
231
+ });
232
+ }
233
+ }
234
+ // Orphan detection: root-level .md files outside any canonical collection
235
+ const rootEntries = fs.readdirSync(root, { withFileTypes: true });
236
+ const collectionSet = new Set(transitions_1.TASK_CANONICAL_COLLECTIONS);
237
+ for (const entry of rootEntries) {
238
+ if (!entry.isFile() || !entry.name.endsWith(".md"))
239
+ continue;
240
+ const filePath = path.join(root, entry.name);
241
+ const content = fs.readFileSync(filePath, "utf-8");
242
+ const frontmatter = tryExtractFrontmatter(content);
243
+ // Only flag as orphan if it has task-like frontmatter
244
+ if (!frontmatter)
245
+ continue;
246
+ const fmType = typeof frontmatter.type === "string" ? frontmatter.type.trim().toLowerCase() : "";
247
+ const hasTaskLikeContent = frontmatter.kind === "task" ||
248
+ LEGACY_TASK_TYPES.includes(fmType) ||
249
+ (typeof frontmatter.status === "string" && typeof frontmatter.title === "string");
250
+ if (hasTaskLikeContent) {
251
+ (0, runtime_1.emitNervesEvent)({
252
+ event: "repertoire.orphan_detected",
253
+ component: "repertoire",
254
+ message: "root-level orphan document detected",
255
+ meta: { filePath },
256
+ });
257
+ issues.push({
258
+ target: entry.name,
259
+ code: "org-root-level-doc",
260
+ description: `Root-level document outside any collection: ${entry.name}`,
261
+ fix: `Move to appropriate collection directory (${[...collectionSet].join(", ")})`,
262
+ confidence: "needs_review",
263
+ category: "migration",
264
+ });
118
265
  }
119
- catch (error) {
120
- parseErrors.push(`${filePath}: ${error instanceof Error ? error.message : String(error)}`);
266
+ }
267
+ // Populate derivedChildren from parent_task links
268
+ const stemToTask = new Map();
269
+ for (const task of tasks) {
270
+ stemToTask.set(task.stem, task);
271
+ }
272
+ for (const task of tasks) {
273
+ const parentStem = typeof task.frontmatter.parent_task === "string"
274
+ ? task.frontmatter.parent_task.trim()
275
+ : "";
276
+ if (parentStem && stemToTask.has(parentStem)) {
277
+ const parent = stemToTask.get(parentStem);
278
+ parent.derivedChildren.push(task.stem);
121
279
  }
122
280
  }
123
281
  const index = {
124
282
  root,
125
283
  tasks,
126
- invalidFilenames,
127
- parseErrors,
284
+ issues,
128
285
  fingerprint,
129
286
  };
130
287
  scanCache = { fingerprint, index };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TASK_REQUIRED_TEMPLATE_FIELDS = exports.TASK_FILENAME_PATTERN = exports.TASK_STEM_PATTERN = exports.TASK_RESERVED_DIRECTORIES = exports.TASK_TYPE_TO_COLLECTION = exports.TASK_CANONICAL_COLLECTIONS = exports.TASK_CANONICAL_TYPES = exports.TASK_STATUS_TRANSITIONS = exports.TASK_VALID_STATUSES = void 0;
3
+ exports.TASK_REQUIRED_TEMPLATE_FIELDS = exports.TASK_FILENAME_PATTERN = exports.TASK_RESERVED_DIRECTORIES = exports.TASK_TYPE_TO_COLLECTION = exports.TASK_CANONICAL_COLLECTIONS = exports.TASK_CANONICAL_TYPES = exports.TASK_STATUS_TRANSITIONS = exports.TASK_VALID_STATUSES = void 0;
4
4
  exports.canonicalCollectionForTaskType = canonicalCollectionForTaskType;
5
5
  exports.normalizeTaskType = normalizeTaskType;
6
6
  exports.normalizeTaskStatus = normalizeTaskStatus;
@@ -16,36 +16,35 @@ exports.TASK_VALID_STATUSES = [
16
16
  "paused",
17
17
  "blocked",
18
18
  "done",
19
+ "cancelled",
19
20
  ];
20
21
  exports.TASK_STATUS_TRANSITIONS = {
21
- drafting: ["processing", "collaborating"],
22
- processing: ["validating", "paused", "blocked"],
23
- validating: ["done", "processing", "collaborating"],
24
- collaborating: ["processing", "validating", "paused"],
25
- paused: ["processing", "blocked"],
26
- blocked: ["processing", "paused"],
22
+ drafting: ["processing", "collaborating", "cancelled"],
23
+ processing: ["validating", "paused", "blocked", "cancelled"],
24
+ validating: ["done", "processing", "collaborating", "cancelled"],
25
+ collaborating: ["processing", "validating", "paused", "cancelled"],
26
+ paused: ["processing", "blocked", "cancelled"],
27
+ blocked: ["processing", "paused", "cancelled"],
27
28
  done: [],
29
+ cancelled: [],
28
30
  };
29
31
  exports.TASK_CANONICAL_TYPES = [
30
32
  "one-shot",
31
33
  "ongoing",
32
- "habit",
33
34
  ];
34
35
  exports.TASK_CANONICAL_COLLECTIONS = [
35
36
  "one-shots",
36
37
  "ongoing",
37
- "habits",
38
38
  ];
39
39
  exports.TASK_TYPE_TO_COLLECTION = {
40
40
  "one-shot": "one-shots",
41
41
  ongoing: "ongoing",
42
- habit: "habits",
43
42
  };
44
43
  exports.TASK_RESERVED_DIRECTORIES = ["templates", ".trash", "archive"];
45
- exports.TASK_STEM_PATTERN = /^\d{4}-\d{2}-\d{2}-\d{4}-[a-z0-9][a-z0-9-]*$/;
46
44
  exports.TASK_FILENAME_PATTERN = /^\d{4}-\d{2}-\d{2}-\d{4}-[a-z0-9][a-z0-9-]*\.md$/;
47
45
  exports.TASK_REQUIRED_TEMPLATE_FIELDS = {
48
46
  "one-shot": [
47
+ "kind",
49
48
  "type",
50
49
  "category",
51
50
  "title",
@@ -59,10 +58,10 @@ exports.TASK_REQUIRED_TEMPLATE_FIELDS = {
59
58
  "updated",
60
59
  "parent_task",
61
60
  "depends_on",
62
- "child_tasks",
63
61
  "artifacts",
64
62
  ],
65
63
  ongoing: [
64
+ "kind",
66
65
  "type",
67
66
  "category",
68
67
  "title",
@@ -74,22 +73,6 @@ exports.TASK_REQUIRED_TEMPLATE_FIELDS = {
74
73
  "lastRun",
75
74
  "created",
76
75
  "updated",
77
- "child_tasks",
78
- "artifacts",
79
- ],
80
- habit: [
81
- "type",
82
- "category",
83
- "title",
84
- "status",
85
- "validator",
86
- "requester",
87
- "cadence",
88
- "scheduledAt",
89
- "lastRun",
90
- "created",
91
- "updated",
92
- "child_tasks",
93
76
  "artifacts",
94
77
  ],
95
78
  };