@askexenow/exe-os 0.9.64 → 0.9.66

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 (105) hide show
  1. package/deploy/stack-manifests/v0.9.json +4 -4
  2. package/dist/bin/backfill-conversations.js +22 -0
  3. package/dist/bin/backfill-responses.js +22 -0
  4. package/dist/bin/backfill-vectors.js +22 -0
  5. package/dist/bin/cleanup-stale-review-tasks.js +22 -0
  6. package/dist/bin/cli.js +2280 -1199
  7. package/dist/bin/exe-agent-config.js +4 -0
  8. package/dist/bin/exe-agent.js +16 -0
  9. package/dist/bin/exe-assign.js +22 -0
  10. package/dist/bin/exe-boot.js +116 -7
  11. package/dist/bin/exe-call.js +16 -0
  12. package/dist/bin/exe-cloud.js +6671 -464
  13. package/dist/bin/exe-dispatch.js +24 -0
  14. package/dist/bin/exe-doctor.js +2845 -1223
  15. package/dist/bin/exe-export-behaviors.js +24 -0
  16. package/dist/bin/exe-forget.js +22 -0
  17. package/dist/bin/exe-gateway.js +24 -0
  18. package/dist/bin/exe-heartbeat.js +23 -0
  19. package/dist/bin/exe-kill.js +22 -0
  20. package/dist/bin/exe-launch-agent.js +24 -0
  21. package/dist/bin/exe-link.js +310 -178
  22. package/dist/bin/exe-new-employee.js +127 -1
  23. package/dist/bin/exe-pending-messages.js +22 -0
  24. package/dist/bin/exe-pending-notifications.js +22 -0
  25. package/dist/bin/exe-pending-reviews.js +22 -0
  26. package/dist/bin/exe-rename.js +22 -0
  27. package/dist/bin/exe-review.js +22 -0
  28. package/dist/bin/exe-search.js +24 -0
  29. package/dist/bin/exe-session-cleanup.js +24 -0
  30. package/dist/bin/exe-settings.js +10 -0
  31. package/dist/bin/exe-start-codex.js +135 -1
  32. package/dist/bin/exe-start-opencode.js +149 -1
  33. package/dist/bin/exe-status.js +22 -0
  34. package/dist/bin/exe-team.js +22 -0
  35. package/dist/bin/git-sweep.js +24 -0
  36. package/dist/bin/graph-backfill.js +22 -0
  37. package/dist/bin/graph-export.js +22 -0
  38. package/dist/bin/install.js +115 -1
  39. package/dist/bin/intercom-check.js +24 -0
  40. package/dist/bin/scan-tasks.js +24 -0
  41. package/dist/bin/setup.js +412 -157
  42. package/dist/bin/shard-migrate.js +22 -0
  43. package/dist/bin/update.js +4 -0
  44. package/dist/gateway/index.js +24 -0
  45. package/dist/hooks/bug-report-worker.js +135 -42
  46. package/dist/hooks/codex-stop-task-finalizer.js +24 -0
  47. package/dist/hooks/commit-complete.js +24 -0
  48. package/dist/hooks/error-recall.js +24 -0
  49. package/dist/hooks/exe-heartbeat-hook.js +4 -0
  50. package/dist/hooks/ingest-worker.js +4 -0
  51. package/dist/hooks/ingest.js +23 -0
  52. package/dist/hooks/instructions-loaded.js +22 -0
  53. package/dist/hooks/notification.js +22 -0
  54. package/dist/hooks/post-compact.js +22 -0
  55. package/dist/hooks/post-tool-combined.js +24 -0
  56. package/dist/hooks/pre-compact.js +260 -109
  57. package/dist/hooks/pre-tool-use.js +22 -0
  58. package/dist/hooks/prompt-submit.js +24 -0
  59. package/dist/hooks/session-end.js +161 -122
  60. package/dist/hooks/session-start.js +142 -0
  61. package/dist/hooks/stop.js +23 -0
  62. package/dist/hooks/subagent-stop.js +22 -0
  63. package/dist/hooks/summary-worker.js +195 -79
  64. package/dist/index.js +24 -0
  65. package/dist/lib/agent-config.js +4 -0
  66. package/dist/lib/cloud-sync.js +50 -6
  67. package/dist/lib/config.js +12 -0
  68. package/dist/lib/consolidation.js +4 -0
  69. package/dist/lib/database.js +4 -0
  70. package/dist/lib/db-daemon-client.js +4 -0
  71. package/dist/lib/db.js +4 -0
  72. package/dist/lib/device-registry.js +4 -0
  73. package/dist/lib/embedder.js +12 -0
  74. package/dist/lib/employee-templates.js +16 -0
  75. package/dist/lib/employees.js +4 -0
  76. package/dist/lib/exe-daemon-client.js +4 -0
  77. package/dist/lib/exe-daemon.js +1144 -480
  78. package/dist/lib/hybrid-search.js +24 -0
  79. package/dist/lib/identity.js +4 -0
  80. package/dist/lib/license.js +4 -0
  81. package/dist/lib/messaging.js +4 -0
  82. package/dist/lib/reminders.js +4 -0
  83. package/dist/lib/schedules.js +22 -0
  84. package/dist/lib/skill-learning.js +12 -0
  85. package/dist/lib/status-brief.js +39 -0
  86. package/dist/lib/store.js +22 -0
  87. package/dist/lib/task-router.js +4 -0
  88. package/dist/lib/tasks.js +12 -0
  89. package/dist/lib/tmux-routing.js +12 -0
  90. package/dist/lib/token-spend.js +4 -0
  91. package/dist/mcp/server.js +1045 -427
  92. package/dist/mcp/tools/complete-reminder.js +4 -0
  93. package/dist/mcp/tools/create-reminder.js +4 -0
  94. package/dist/mcp/tools/create-task.js +12 -0
  95. package/dist/mcp/tools/deactivate-behavior.js +4 -0
  96. package/dist/mcp/tools/list-reminders.js +4 -0
  97. package/dist/mcp/tools/list-tasks.js +4 -0
  98. package/dist/mcp/tools/send-message.js +4 -0
  99. package/dist/mcp/tools/update-task.js +12 -0
  100. package/dist/runtime/index.js +24 -0
  101. package/dist/tui/App.js +24 -0
  102. package/package.json +3 -2
  103. package/src/commands/exe/cloud.md +15 -8
  104. package/src/commands/exe/link.md +7 -6
  105. package/stack.release.json +2 -2
@@ -188,6 +188,11 @@ function normalizeAutoUpdate(raw) {
188
188
  const userAU = raw.autoUpdate ?? {};
189
189
  raw.autoUpdate = { ...defaultAU, ...userAU };
190
190
  }
191
+ function normalizeOrchestration(raw) {
192
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
193
+ const userOrg = raw.orchestration ?? {};
194
+ raw.orchestration = { ...defaultOrg, ...userOrg };
195
+ }
191
196
  async function loadConfig() {
192
197
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
193
198
  await ensurePrivateDir(dir);
@@ -212,6 +217,7 @@ async function loadConfig() {
212
217
  normalizeScalingRoadmap(migratedCfg);
213
218
  normalizeSessionLifecycle(migratedCfg);
214
219
  normalizeAutoUpdate(migratedCfg);
220
+ normalizeOrchestration(migratedCfg);
215
221
  const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
216
222
  if (config.dbPath.startsWith("~")) {
217
223
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
@@ -287,6 +293,10 @@ var init_config = __esm({
287
293
  checkOnBoot: true,
288
294
  autoInstall: false,
289
295
  checkIntervalMs: 24 * 60 * 60 * 1e3
296
+ },
297
+ orchestration: {
298
+ phase: "phase_1_coo",
299
+ phaseSetBy: "default"
290
300
  }
291
301
  };
292
302
  CONFIG_MIGRATIONS = [
@@ -3151,6 +3161,12 @@ var init_platform_procedures = __esm({
3151
3161
  priority: "p0",
3152
3162
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
3153
3163
  },
3164
+ {
3165
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
3166
+ domain: "workflow",
3167
+ priority: "p1",
3168
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
3169
+ },
3154
3170
  {
3155
3171
  title: "Single dispatch path \u2014 create_task only",
3156
3172
  domain: "workflow",
@@ -3209,6 +3225,12 @@ var init_platform_procedures = __esm({
3209
3225
  priority: "p0",
3210
3226
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
3211
3227
  },
3228
+ {
3229
+ title: "Commit discipline \u2014 never leave verified work floating",
3230
+ domain: "workflow",
3231
+ priority: "p1",
3232
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
3233
+ },
3212
3234
  {
3213
3235
  title: "Desktop and TUI are the same product",
3214
3236
  domain: "architecture",
@@ -111,6 +111,10 @@ var init_config = __esm({
111
111
  checkOnBoot: true,
112
112
  autoInstall: false,
113
113
  checkIntervalMs: 24 * 60 * 60 * 1e3
114
+ },
115
+ orchestration: {
116
+ phase: "phase_1_coo",
117
+ phaseSetBy: "default"
114
118
  }
115
119
  };
116
120
  }
@@ -515,6 +515,11 @@ function normalizeAutoUpdate(raw) {
515
515
  const userAU = raw.autoUpdate ?? {};
516
516
  raw.autoUpdate = { ...defaultAU, ...userAU };
517
517
  }
518
+ function normalizeOrchestration(raw) {
519
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
520
+ const userOrg = raw.orchestration ?? {};
521
+ raw.orchestration = { ...defaultOrg, ...userOrg };
522
+ }
518
523
  async function loadConfig() {
519
524
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
520
525
  await ensurePrivateDir(dir);
@@ -539,6 +544,7 @@ async function loadConfig() {
539
544
  normalizeScalingRoadmap(migratedCfg);
540
545
  normalizeSessionLifecycle(migratedCfg);
541
546
  normalizeAutoUpdate(migratedCfg);
547
+ normalizeOrchestration(migratedCfg);
542
548
  const config2 = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
543
549
  if (config2.dbPath.startsWith("~")) {
544
550
  config2.dbPath = config2.dbPath.replace(/^~/, os.homedir());
@@ -562,6 +568,7 @@ function loadConfigSync() {
562
568
  normalizeScalingRoadmap(migratedCfg);
563
569
  normalizeSessionLifecycle(migratedCfg);
564
570
  normalizeAutoUpdate(migratedCfg);
571
+ normalizeOrchestration(migratedCfg);
565
572
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
566
573
  } catch {
567
574
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -583,6 +590,7 @@ async function loadConfigFrom(configPath) {
583
590
  normalizeScalingRoadmap(migratedCfg);
584
591
  normalizeSessionLifecycle(migratedCfg);
585
592
  normalizeAutoUpdate(migratedCfg);
593
+ normalizeOrchestration(migratedCfg);
586
594
  return { ...DEFAULT_CONFIG, ...migratedCfg };
587
595
  } catch {
588
596
  return { ...DEFAULT_CONFIG };
@@ -654,6 +662,10 @@ var init_config = __esm({
654
662
  checkOnBoot: true,
655
663
  autoInstall: false,
656
664
  checkIntervalMs: 24 * 60 * 60 * 1e3
665
+ },
666
+ orchestration: {
667
+ phase: "phase_1_coo",
668
+ phaseSetBy: "default"
657
669
  }
658
670
  };
659
671
  CONFIG_MIGRATIONS = [
@@ -4496,6 +4508,12 @@ var init_platform_procedures = __esm({
4496
4508
  priority: "p0",
4497
4509
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
4498
4510
  },
4511
+ {
4512
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
4513
+ domain: "workflow",
4514
+ priority: "p1",
4515
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
4516
+ },
4499
4517
  {
4500
4518
  title: "Single dispatch path \u2014 create_task only",
4501
4519
  domain: "workflow",
@@ -4554,6 +4572,12 @@ var init_platform_procedures = __esm({
4554
4572
  priority: "p0",
4555
4573
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
4556
4574
  },
4575
+ {
4576
+ title: "Commit discipline \u2014 never leave verified work floating",
4577
+ domain: "workflow",
4578
+ priority: "p1",
4579
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
4580
+ },
4557
4581
  {
4558
4582
  title: "Desktop and TUI are the same product",
4559
4583
  domain: "architecture",
@@ -204,6 +204,11 @@ function normalizeAutoUpdate(raw) {
204
204
  const userAU = raw.autoUpdate ?? {};
205
205
  raw.autoUpdate = { ...defaultAU, ...userAU };
206
206
  }
207
+ function normalizeOrchestration(raw) {
208
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
209
+ const userOrg = raw.orchestration ?? {};
210
+ raw.orchestration = { ...defaultOrg, ...userOrg };
211
+ }
207
212
  async function loadConfig() {
208
213
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
209
214
  await ensurePrivateDir(dir);
@@ -228,6 +233,7 @@ async function loadConfig() {
228
233
  normalizeScalingRoadmap(migratedCfg);
229
234
  normalizeSessionLifecycle(migratedCfg);
230
235
  normalizeAutoUpdate(migratedCfg);
236
+ normalizeOrchestration(migratedCfg);
231
237
  const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
232
238
  if (config.dbPath.startsWith("~")) {
233
239
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
@@ -251,6 +257,7 @@ function loadConfigSync() {
251
257
  normalizeScalingRoadmap(migratedCfg);
252
258
  normalizeSessionLifecycle(migratedCfg);
253
259
  normalizeAutoUpdate(migratedCfg);
260
+ normalizeOrchestration(migratedCfg);
254
261
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
255
262
  } catch {
256
263
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -272,6 +279,7 @@ async function loadConfigFrom(configPath) {
272
279
  normalizeScalingRoadmap(migratedCfg);
273
280
  normalizeSessionLifecycle(migratedCfg);
274
281
  normalizeAutoUpdate(migratedCfg);
282
+ normalizeOrchestration(migratedCfg);
275
283
  return { ...DEFAULT_CONFIG, ...migratedCfg };
276
284
  } catch {
277
285
  return { ...DEFAULT_CONFIG };
@@ -343,6 +351,10 @@ var init_config = __esm({
343
351
  checkOnBoot: true,
344
352
  autoInstall: false,
345
353
  checkIntervalMs: 24 * 60 * 60 * 1e3
354
+ },
355
+ orchestration: {
356
+ phase: "phase_1_coo",
357
+ phaseSetBy: "default"
346
358
  }
347
359
  };
348
360
  CONFIG_MIGRATIONS = [
@@ -4238,6 +4250,12 @@ var init_platform_procedures = __esm({
4238
4250
  priority: "p0",
4239
4251
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
4240
4252
  },
4253
+ {
4254
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
4255
+ domain: "workflow",
4256
+ priority: "p1",
4257
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
4258
+ },
4241
4259
  {
4242
4260
  title: "Single dispatch path \u2014 create_task only",
4243
4261
  domain: "workflow",
@@ -4296,6 +4314,12 @@ var init_platform_procedures = __esm({
4296
4314
  priority: "p0",
4297
4315
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
4298
4316
  },
4317
+ {
4318
+ title: "Commit discipline \u2014 never leave verified work floating",
4319
+ domain: "workflow",
4320
+ priority: "p1",
4321
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
4322
+ },
4299
4323
  {
4300
4324
  title: "Desktop and TUI are the same product",
4301
4325
  domain: "architecture",
@@ -8892,54 +8916,98 @@ async function fastDbInit() {
8892
8916
  // src/adapters/claude/hooks/bug-report-worker.ts
8893
8917
  init_database();
8894
8918
  init_tasks();
8895
- async function main() {
8896
- const toolName = process.env.BUG_TOOL_NAME ?? "unknown";
8897
- const errorText = process.env.BUG_ERROR_TEXT ?? "";
8898
- const toolInput = process.env.BUG_TOOL_INPUT ?? "{}";
8899
- const fingerprint = process.env.BUG_FINGERPRINT ?? "";
8900
- const agentId = process.env.BUG_AGENT_ID ?? "unknown";
8901
- const agentRole = process.env.BUG_AGENT_ROLE ?? "employee";
8902
- const projectName = process.env.BUG_PROJECT_NAME ?? "unknown";
8903
- await fastDbInit();
8904
- const fpPrefix = fingerprint.slice(0, 8);
8905
- const client = getClient();
8906
- const { loadEmployeesSync: loadEmployeesSync2, getEmployeeByRole: getEmployeeByRole2, getCoordinatorName: getCoordinatorName2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
8907
- const employees = loadEmployeesSync2();
8908
- const coordinatorName = getCoordinatorName2(employees);
8909
- const ctoName = getEmployeeByRole2(employees, "CTO")?.name ?? coordinatorName;
8910
- const existing = await client.execute({
8911
- sql: `SELECT id FROM tasks
8912
- WHERE assigned_to = ?
8913
- AND status IN ('open', 'in_progress')
8914
- AND title LIKE '[auto-bug]%'
8915
- AND task_file LIKE ?
8916
- LIMIT 1`,
8917
- args: [ctoName, `%${fpPrefix}%`]
8919
+
8920
+ // src/lib/bug-intake.ts
8921
+ import { createHash as createHash3, randomUUID as randomUUID4 } from "crypto";
8922
+ var BUG_INTAKE_SCHEMA_VERSION = 1;
8923
+ function firstMeaningfulLine(text) {
8924
+ return text.split("\n").find((line) => line.trim().length > 0)?.trim().slice(0, 80) ?? "unknown error";
8925
+ }
8926
+ function stableFingerprint(input) {
8927
+ const basis = [
8928
+ input.source,
8929
+ input.toolName ?? "unknown",
8930
+ firstMeaningfulLine(input.errorText ?? ""),
8931
+ input.projectName ?? "unknown"
8932
+ ].join("|");
8933
+ return createHash3("sha256").update(basis).digest("hex").slice(0, 16);
8934
+ }
8935
+ function hashLicense(licenseKey) {
8936
+ if (!licenseKey) return void 0;
8937
+ return createHash3("sha256").update(licenseKey).digest("hex").slice(0, 16);
8938
+ }
8939
+ function buildBugIntake(input) {
8940
+ const toolName = input.toolName ?? "unknown";
8941
+ const errorText = input.errorText ?? "";
8942
+ const summary = firstMeaningfulLine(errorText);
8943
+ const fingerprint = input.fingerprint && input.fingerprint.trim().length > 0 ? input.fingerprint.trim() : stableFingerprint(input);
8944
+ return {
8945
+ schemaVersion: BUG_INTAKE_SCHEMA_VERSION,
8946
+ id: randomUUID4(),
8947
+ source: input.source,
8948
+ createdAt: input.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
8949
+ fingerprint,
8950
+ severity: input.severity ?? "p1",
8951
+ title: `[auto-bug] ${toolName}: ${summary.slice(0, 60)}`,
8952
+ summary,
8953
+ reporterAgentId: input.reporterAgentId ?? "unknown",
8954
+ reporterAgentRole: input.reporterAgentRole ?? "employee",
8955
+ projectName: input.projectName ?? "unknown",
8956
+ toolName,
8957
+ errorText,
8958
+ toolInput: input.toolInput ?? "{}",
8959
+ runtime: input.runtime,
8960
+ repo: input.repo,
8961
+ licenseKeyHash: hashLicense(input.licenseKey),
8962
+ labels: ["auto-bug", input.source, toolName].filter(Boolean)
8963
+ };
8964
+ }
8965
+ function buildBugIntakeFromEnv(env = process.env) {
8966
+ return buildBugIntake({
8967
+ source: "hook",
8968
+ toolName: env.BUG_TOOL_NAME,
8969
+ errorText: env.BUG_ERROR_TEXT,
8970
+ toolInput: env.BUG_TOOL_INPUT,
8971
+ fingerprint: env.BUG_FINGERPRINT,
8972
+ reporterAgentId: env.BUG_AGENT_ID,
8973
+ reporterAgentRole: env.BUG_AGENT_ROLE,
8974
+ projectName: env.BUG_PROJECT_NAME,
8975
+ runtime: env.EXE_RUNTIME,
8976
+ repo: env.EXE_REPO,
8977
+ licenseKey: env.EXE_LICENSE_KEY
8918
8978
  });
8919
- if (existing.rows.length > 0) {
8920
- process.stderr.write(`[bug-report-worker] Duplicate found for fingerprint ${fingerprint}, skipping
8921
- `);
8922
- return;
8923
- }
8924
- const errorSummary = errorText.split("\n").find((line) => line.trim().length > 0)?.trim().slice(0, 60) ?? "unknown error";
8925
- const context = [
8979
+ }
8980
+ function formatBugIntakeTaskContext(record) {
8981
+ return [
8926
8982
  "## Auto-detected system bug",
8927
8983
  "",
8928
- `**Detected by:** ${agentId} (${agentRole})`,
8929
- `**Tool:** ${toolName}`,
8930
- `**Timestamp:** ${(/* @__PURE__ */ new Date()).toISOString()}`,
8931
- `**Fingerprint:** ${fingerprint}`,
8984
+ `**Schema:** bug-intake/v${record.schemaVersion}`,
8985
+ `**Source:** ${record.source}`,
8986
+ `**Detected by:** ${record.reporterAgentId} (${record.reporterAgentRole})`,
8987
+ `**Tool:** ${record.toolName}`,
8988
+ `**Timestamp:** ${record.createdAt}`,
8989
+ `**Fingerprint:** ${record.fingerprint}`,
8990
+ `**Severity:** ${record.severity}`,
8991
+ record.runtime ? `**Runtime:** ${record.runtime}` : void 0,
8992
+ record.repo ? `**Repo:** ${record.repo}` : void 0,
8993
+ record.licenseKeyHash ? `**License hash:** ${record.licenseKeyHash}` : void 0,
8932
8994
  "",
8933
8995
  "## Error output",
8934
8996
  "",
8935
8997
  "```",
8936
- errorText.slice(0, 1e3),
8998
+ record.errorText.slice(0, 2e3),
8937
8999
  "```",
8938
9000
  "",
8939
9001
  "## Tool input (reproduction context)",
8940
9002
  "",
8941
9003
  "```json",
8942
- toolInput.slice(0, 500),
9004
+ record.toolInput.slice(0, 1e3),
9005
+ "```",
9006
+ "",
9007
+ "## Normalized intake JSON",
9008
+ "",
9009
+ "```json",
9010
+ JSON.stringify(record, null, 2),
8943
9011
  "```",
8944
9012
  "",
8945
9013
  "## Triage notes",
@@ -8947,19 +9015,44 @@ async function main() {
8947
9015
  "- Classification: system bug (auto-detected)",
8948
9016
  "- Review this error \u2014 fix if real, close if false positive",
8949
9017
  "- If false positive: add the error pattern to USER_ERROR_PATTERNS in error-detector.ts"
8950
- ].join("\n");
9018
+ ].filter((line) => line !== void 0).join("\n");
9019
+ }
9020
+
9021
+ // src/adapters/claude/hooks/bug-report-worker.ts
9022
+ async function main() {
9023
+ const intake = buildBugIntakeFromEnv(process.env);
9024
+ await fastDbInit();
9025
+ const client = getClient();
9026
+ const { loadEmployeesSync: loadEmployeesSync2, getEmployeeByRole: getEmployeeByRole2, getCoordinatorName: getCoordinatorName2 } = await Promise.resolve().then(() => (init_employees(), employees_exports));
9027
+ const employees = loadEmployeesSync2();
9028
+ const coordinatorName = getCoordinatorName2(employees);
9029
+ const ctoName = getEmployeeByRole2(employees, "CTO")?.name ?? coordinatorName;
9030
+ const existing = await client.execute({
9031
+ sql: `SELECT id FROM tasks
9032
+ WHERE assigned_to = ?
9033
+ AND status IN ('open', 'in_progress')
9034
+ AND title LIKE '[auto-bug]%'
9035
+ AND (context LIKE ? OR task_file LIKE ?)
9036
+ LIMIT 1`,
9037
+ args: [ctoName, `%${intake.fingerprint}%`, `%${intake.fingerprint.slice(0, 8)}%`]
9038
+ });
9039
+ if (existing.rows.length > 0) {
9040
+ process.stderr.write(`[bug-report-worker] Duplicate found for fingerprint ${intake.fingerprint}, skipping
9041
+ `);
9042
+ return;
9043
+ }
8951
9044
  await createTask({
8952
- title: `[auto-bug] ${toolName}: ${errorSummary}`,
9045
+ title: intake.title,
8953
9046
  assignedTo: ctoName,
8954
9047
  assignedBy: "system",
8955
- projectName,
8956
- priority: "p1",
8957
- context,
9048
+ projectName: intake.projectName,
9049
+ priority: intake.severity,
9050
+ context: formatBugIntakeTaskContext(intake),
8958
9051
  baseDir: process.cwd(),
8959
9052
  skipDispatch: true,
8960
9053
  reviewer: coordinatorName
8961
9054
  });
8962
- process.stderr.write(`[bug-report-worker] Created auto-bug task for ${toolName}: ${errorSummary}
9055
+ process.stderr.write(`[bug-report-worker] Created auto-bug task for ${intake.toolName}: ${intake.summary}
8963
9056
  `);
8964
9057
  }
8965
9058
  main().catch((err) => {
@@ -149,6 +149,11 @@ function normalizeAutoUpdate(raw) {
149
149
  const userAU = raw.autoUpdate ?? {};
150
150
  raw.autoUpdate = { ...defaultAU, ...userAU };
151
151
  }
152
+ function normalizeOrchestration(raw) {
153
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
154
+ const userOrg = raw.orchestration ?? {};
155
+ raw.orchestration = { ...defaultOrg, ...userOrg };
156
+ }
152
157
  async function loadConfig() {
153
158
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
154
159
  await ensurePrivateDir(dir);
@@ -173,6 +178,7 @@ async function loadConfig() {
173
178
  normalizeScalingRoadmap(migratedCfg);
174
179
  normalizeSessionLifecycle(migratedCfg);
175
180
  normalizeAutoUpdate(migratedCfg);
181
+ normalizeOrchestration(migratedCfg);
176
182
  const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
177
183
  if (config.dbPath.startsWith("~")) {
178
184
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
@@ -196,6 +202,7 @@ function loadConfigSync() {
196
202
  normalizeScalingRoadmap(migratedCfg);
197
203
  normalizeSessionLifecycle(migratedCfg);
198
204
  normalizeAutoUpdate(migratedCfg);
205
+ normalizeOrchestration(migratedCfg);
199
206
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
200
207
  } catch {
201
208
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -217,6 +224,7 @@ async function loadConfigFrom(configPath) {
217
224
  normalizeScalingRoadmap(migratedCfg);
218
225
  normalizeSessionLifecycle(migratedCfg);
219
226
  normalizeAutoUpdate(migratedCfg);
227
+ normalizeOrchestration(migratedCfg);
220
228
  return { ...DEFAULT_CONFIG, ...migratedCfg };
221
229
  } catch {
222
230
  return { ...DEFAULT_CONFIG };
@@ -288,6 +296,10 @@ var init_config = __esm({
288
296
  checkOnBoot: true,
289
297
  autoInstall: false,
290
298
  checkIntervalMs: 24 * 60 * 60 * 1e3
299
+ },
300
+ orchestration: {
301
+ phase: "phase_1_coo",
302
+ phaseSetBy: "default"
291
303
  }
292
304
  };
293
305
  CONFIG_MIGRATIONS = [
@@ -3921,6 +3933,12 @@ var init_platform_procedures = __esm({
3921
3933
  priority: "p0",
3922
3934
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
3923
3935
  },
3936
+ {
3937
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
3938
+ domain: "workflow",
3939
+ priority: "p1",
3940
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
3941
+ },
3924
3942
  {
3925
3943
  title: "Single dispatch path \u2014 create_task only",
3926
3944
  domain: "workflow",
@@ -3979,6 +3997,12 @@ var init_platform_procedures = __esm({
3979
3997
  priority: "p0",
3980
3998
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
3981
3999
  },
4000
+ {
4001
+ title: "Commit discipline \u2014 never leave verified work floating",
4002
+ domain: "workflow",
4003
+ priority: "p1",
4004
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
4005
+ },
3982
4006
  {
3983
4007
  title: "Desktop and TUI are the same product",
3984
4008
  domain: "architecture",
@@ -441,6 +441,11 @@ function normalizeAutoUpdate(raw) {
441
441
  const userAU = raw.autoUpdate ?? {};
442
442
  raw.autoUpdate = { ...defaultAU, ...userAU };
443
443
  }
444
+ function normalizeOrchestration(raw) {
445
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
446
+ const userOrg = raw.orchestration ?? {};
447
+ raw.orchestration = { ...defaultOrg, ...userOrg };
448
+ }
444
449
  async function loadConfig() {
445
450
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
446
451
  await ensurePrivateDir(dir);
@@ -465,6 +470,7 @@ async function loadConfig() {
465
470
  normalizeScalingRoadmap(migratedCfg);
466
471
  normalizeSessionLifecycle(migratedCfg);
467
472
  normalizeAutoUpdate(migratedCfg);
473
+ normalizeOrchestration(migratedCfg);
468
474
  const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
469
475
  if (config.dbPath.startsWith("~")) {
470
476
  config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
@@ -488,6 +494,7 @@ function loadConfigSync() {
488
494
  normalizeScalingRoadmap(migratedCfg);
489
495
  normalizeSessionLifecycle(migratedCfg);
490
496
  normalizeAutoUpdate(migratedCfg);
497
+ normalizeOrchestration(migratedCfg);
491
498
  return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
492
499
  } catch {
493
500
  return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
@@ -509,6 +516,7 @@ async function loadConfigFrom(configPath) {
509
516
  normalizeScalingRoadmap(migratedCfg);
510
517
  normalizeSessionLifecycle(migratedCfg);
511
518
  normalizeAutoUpdate(migratedCfg);
519
+ normalizeOrchestration(migratedCfg);
512
520
  return { ...DEFAULT_CONFIG, ...migratedCfg };
513
521
  } catch {
514
522
  return { ...DEFAULT_CONFIG };
@@ -580,6 +588,10 @@ var init_config = __esm({
580
588
  checkOnBoot: true,
581
589
  autoInstall: false,
582
590
  checkIntervalMs: 24 * 60 * 60 * 1e3
591
+ },
592
+ orchestration: {
593
+ phase: "phase_1_coo",
594
+ phaseSetBy: "default"
583
595
  }
584
596
  };
585
597
  CONFIG_MIGRATIONS = [
@@ -7609,6 +7621,12 @@ var init_platform_procedures = __esm({
7609
7621
  priority: "p0",
7610
7622
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
7611
7623
  },
7624
+ {
7625
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
7626
+ domain: "workflow",
7627
+ priority: "p1",
7628
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
7629
+ },
7612
7630
  {
7613
7631
  title: "Single dispatch path \u2014 create_task only",
7614
7632
  domain: "workflow",
@@ -7667,6 +7685,12 @@ var init_platform_procedures = __esm({
7667
7685
  priority: "p0",
7668
7686
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
7669
7687
  },
7688
+ {
7689
+ title: "Commit discipline \u2014 never leave verified work floating",
7690
+ domain: "workflow",
7691
+ priority: "p1",
7692
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
7693
+ },
7670
7694
  {
7671
7695
  title: "Desktop and TUI are the same product",
7672
7696
  domain: "architecture",
@@ -138,6 +138,11 @@ function normalizeAutoUpdate(raw) {
138
138
  const userAU = raw.autoUpdate ?? {};
139
139
  raw.autoUpdate = { ...defaultAU, ...userAU };
140
140
  }
141
+ function normalizeOrchestration(raw) {
142
+ const defaultOrg = DEFAULT_CONFIG.orchestration;
143
+ const userOrg = raw.orchestration ?? {};
144
+ raw.orchestration = { ...defaultOrg, ...userOrg };
145
+ }
141
146
  async function loadConfig() {
142
147
  const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
143
148
  await ensurePrivateDir(dir);
@@ -162,6 +167,7 @@ async function loadConfig() {
162
167
  normalizeScalingRoadmap(migratedCfg);
163
168
  normalizeSessionLifecycle(migratedCfg);
164
169
  normalizeAutoUpdate(migratedCfg);
170
+ normalizeOrchestration(migratedCfg);
165
171
  const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
166
172
  if (config.dbPath.startsWith("~")) {
167
173
  config.dbPath = config.dbPath.replace(/^~/, os.homedir());
@@ -185,6 +191,7 @@ function loadConfigSync() {
185
191
  normalizeScalingRoadmap(migratedCfg);
186
192
  normalizeSessionLifecycle(migratedCfg);
187
193
  normalizeAutoUpdate(migratedCfg);
194
+ normalizeOrchestration(migratedCfg);
188
195
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
189
196
  } catch {
190
197
  return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
@@ -206,6 +213,7 @@ async function loadConfigFrom(configPath) {
206
213
  normalizeScalingRoadmap(migratedCfg);
207
214
  normalizeSessionLifecycle(migratedCfg);
208
215
  normalizeAutoUpdate(migratedCfg);
216
+ normalizeOrchestration(migratedCfg);
209
217
  return { ...DEFAULT_CONFIG, ...migratedCfg };
210
218
  } catch {
211
219
  return { ...DEFAULT_CONFIG };
@@ -277,6 +285,10 @@ var init_config = __esm({
277
285
  checkOnBoot: true,
278
286
  autoInstall: false,
279
287
  checkIntervalMs: 24 * 60 * 60 * 1e3
288
+ },
289
+ orchestration: {
290
+ phase: "phase_1_coo",
291
+ phaseSetBy: "default"
280
292
  }
281
293
  };
282
294
  CONFIG_MIGRATIONS = [
@@ -3829,6 +3841,12 @@ var init_platform_procedures = __esm({
3829
3841
  priority: "p0",
3830
3842
  content: "Founder -> coordinator (the executive agent, internally routed as 'COO') -> CTO/CMO. CTO -> engineers. CMO -> content production. Never skip levels: the coordinator does not bypass managers for specialist work. Specialists report to their manager. If you need cross-team info, use ask_team_memory \u2014 don't read other agents' task folders. Each level owns dispatch downward and review upward."
3831
3843
  },
3844
+ {
3845
+ title: "Customer orchestration maturity \u2014 recommend, never trap",
3846
+ domain: "workflow",
3847
+ priority: "p1",
3848
+ content: "New customers start best in Phase 1: founder \u2194 coordinator/Chief of Staff, building company context. Suggest Phase 2 executives when domain work repeats; suggest Phase 3 parallel execution only when review/permission gates are ready. This is guidance, not a blocker: users may jump phases anytime. Never overwrite their phase, role titles, identities, or custom org design."
3849
+ },
3832
3850
  {
3833
3851
  title: "Single dispatch path \u2014 create_task only",
3834
3852
  domain: "workflow",
@@ -3887,6 +3905,12 @@ var init_platform_procedures = __esm({
3887
3905
  priority: "p0",
3888
3906
  content: "exe-build-adv is MANDATORY for ALL work touching 3+ files. Run /exe-build-adv --auto BEFORE implementation. Pipeline: Spec \u2192 AC \u2192 Tests \u2192 Evaluate \u2192 Fix. No multi-file feature ships without pipeline artifacts. No exceptions \u2014 managers reject work without them."
3889
3907
  },
3908
+ {
3909
+ title: "Commit discipline \u2014 never leave verified work floating",
3910
+ domain: "workflow",
3911
+ priority: "p1",
3912
+ content: "After any code-change batch passes typecheck/tests/build, run git status, summarize changed files, and commit with a clear message before ending the session. If work must remain uncommitted for review/dogfood, explicitly say so, list the files, and state the blocker. Never imply work is complete while verified changes are still floating locally."
3913
+ },
3890
3914
  {
3891
3915
  title: "Desktop and TUI are the same product",
3892
3916
  domain: "architecture",
@@ -99,6 +99,10 @@ var init_config = __esm({
99
99
  checkOnBoot: true,
100
100
  autoInstall: false,
101
101
  checkIntervalMs: 24 * 60 * 60 * 1e3
102
+ },
103
+ orchestration: {
104
+ phase: "phase_1_coo",
105
+ phaseSetBy: "default"
102
106
  }
103
107
  };
104
108
  }
@@ -102,6 +102,10 @@ var DEFAULT_CONFIG = {
102
102
  checkOnBoot: true,
103
103
  autoInstall: false,
104
104
  checkIntervalMs: 24 * 60 * 60 * 1e3
105
+ },
106
+ orchestration: {
107
+ phase: "phase_1_coo",
108
+ phaseSetBy: "default"
105
109
  }
106
110
  };
107
111