dreamcontext 0.8.0 → 0.8.1

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 (127) hide show
  1. package/dist/dashboard/assets/{BrainCanvas3D-BZyWrW3J.js → BrainCanvas3D-CNDjMlun.js} +1 -1
  2. package/dist/dashboard/assets/{_baseUniq-C55dCpzj.js → _baseUniq-DtoPVYjz.js} +1 -1
  3. package/dist/dashboard/assets/{ar-SA-G6X2FPQ2-BTWWh58_.js → ar-SA-G6X2FPQ2-D_dXe_8i.js} +1 -1
  4. package/dist/dashboard/assets/{arc-BhcvtD7_.js → arc-8LFYH4lG.js} +1 -1
  5. package/dist/dashboard/assets/{architectureDiagram-Q4EWVU46-BlVAz3vP.js → architectureDiagram-Q4EWVU46-BIgEpM4v.js} +1 -1
  6. package/dist/dashboard/assets/{az-AZ-76LH7QW2-DEPuxlle.js → az-AZ-76LH7QW2-C30ZBwgT.js} +1 -1
  7. package/dist/dashboard/assets/{bg-BG-XCXSNQG7-CdwdScdW.js → bg-BG-XCXSNQG7-D0R9pSdG.js} +1 -1
  8. package/dist/dashboard/assets/{blockDiagram-DXYQGD6D-CAzEduT-.js → blockDiagram-DXYQGD6D-DRTa0DpJ.js} +1 -1
  9. package/dist/dashboard/assets/{bn-BD-2XOGV67Q-Cx2p_HrL.js → bn-BD-2XOGV67Q-vkWxteG3.js} +1 -1
  10. package/dist/dashboard/assets/{c4Diagram-AHTNJAMY-C_5GcHxG.js → c4Diagram-AHTNJAMY-Do_gB8Cs.js} +1 -1
  11. package/dist/dashboard/assets/{ca-ES-6MX7JW3Y-BLVJKLW3.js → ca-ES-6MX7JW3Y-CTyxGdzW.js} +1 -1
  12. package/dist/dashboard/assets/channel-C5p1t-nJ.js +1 -0
  13. package/dist/dashboard/assets/{chunk-4BX2VUAB-DYYyKwKp.js → chunk-4BX2VUAB-DJlttKoY.js} +1 -1
  14. package/dist/dashboard/assets/{chunk-4TB4RGXK-B9ZDNs0v.js → chunk-4TB4RGXK-BdixZX4J.js} +1 -1
  15. package/dist/dashboard/assets/{chunk-55IACEB6-0chbuP2q.js → chunk-55IACEB6-CPhKaTLr.js} +1 -1
  16. package/dist/dashboard/assets/{chunk-EDXVE4YY-BM3tX5V3.js → chunk-EDXVE4YY-Bv0bQVvi.js} +1 -1
  17. package/dist/dashboard/assets/{chunk-FMBD7UC4-D7fWQyLU.js → chunk-FMBD7UC4-DGjRdLDd.js} +1 -1
  18. package/dist/dashboard/assets/{chunk-OYMX7WX6-DRSMwRfw.js → chunk-OYMX7WX6-B-wzkRri.js} +1 -1
  19. package/dist/dashboard/assets/{chunk-QZHKN3VN-BkySqi6f.js → chunk-QZHKN3VN-BwK1NqpV.js} +1 -1
  20. package/dist/dashboard/assets/{chunk-YZCP3GAM-DWxX_bg1.js → chunk-YZCP3GAM-DjEwJGlh.js} +1 -1
  21. package/dist/dashboard/assets/classDiagram-6PBFFD2Q-sTJpbWV4.js +1 -0
  22. package/dist/dashboard/assets/classDiagram-v2-HSJHXN6E-sTJpbWV4.js +1 -0
  23. package/dist/dashboard/assets/clone-DTslXBzp.js +1 -0
  24. package/dist/dashboard/assets/core-Cn4yfEqx.js +1 -0
  25. package/dist/dashboard/assets/{cose-bilkent-S5V4N54A-CK3SaOdF.js → cose-bilkent-S5V4N54A-BJXUn11L.js} +1 -1
  26. package/dist/dashboard/assets/{cs-CZ-2BRQDIVT-2wFJFdY3.js → cs-CZ-2BRQDIVT-BjRikaNe.js} +1 -1
  27. package/dist/dashboard/assets/{da-DK-5WZEPLOC-PZ4S5fLH.js → da-DK-5WZEPLOC-Cn3GTxbV.js} +1 -1
  28. package/dist/dashboard/assets/{dagre-KV5264BT-C_O4CkRN.js → dagre-KV5264BT-BHn2c24z.js} +1 -1
  29. package/dist/dashboard/assets/{de-DE-XR44H4JA-COgQyNpE.js → de-DE-XR44H4JA-IvGsdpTt.js} +1 -1
  30. package/dist/dashboard/assets/{diagram-5BDNPKRD-CY7cwksh.js → diagram-5BDNPKRD-YrlF3B5a.js} +1 -1
  31. package/dist/dashboard/assets/{diagram-G4DWMVQ6-BBaegF2E.js → diagram-G4DWMVQ6-DHONF1OD.js} +1 -1
  32. package/dist/dashboard/assets/{diagram-MMDJMWI5-Dtp-QpeD.js → diagram-MMDJMWI5-B1vJLt5b.js} +1 -1
  33. package/dist/dashboard/assets/{diagram-TYMM5635-h-YHhXz4.js → diagram-TYMM5635-C8P5-4A3.js} +1 -1
  34. package/dist/dashboard/assets/{el-GR-BZB4AONW-DzTJgcWa.js → el-GR-BZB4AONW-B9GA8_lO.js} +1 -1
  35. package/dist/dashboard/assets/{erDiagram-SMLLAGMA-C8WadTdS.js → erDiagram-SMLLAGMA-CjWWTCWe.js} +1 -1
  36. package/dist/dashboard/assets/{es-ES-U4NZUMDT-BMzFbvDd.js → es-ES-U4NZUMDT-Ct1wP_9r.js} +1 -1
  37. package/dist/dashboard/assets/{eu-ES-A7QVB2H4-CnpRhfeI.js → eu-ES-A7QVB2H4-C-49gWlR.js} +1 -1
  38. package/dist/dashboard/assets/{fa-IR-HGAKTJCU-DJozguNj.js → fa-IR-HGAKTJCU-DUo8t-xv.js} +1 -1
  39. package/dist/dashboard/assets/{fi-FI-Z5N7JZ37-4vlr1zEE.js → fi-FI-Z5N7JZ37-DCObnr3i.js} +1 -1
  40. package/dist/dashboard/assets/{flowDiagram-DWJPFMVM-BDU_Bd0P.js → flowDiagram-DWJPFMVM-OQ_IRMqG.js} +1 -1
  41. package/dist/dashboard/assets/{fr-FR-RHASNOE6-BIMGBozN.js → fr-FR-RHASNOE6-0EGg3zhN.js} +1 -1
  42. package/dist/dashboard/assets/{ganttDiagram-T4ZO3ILL-DI9axi76.js → ganttDiagram-T4ZO3ILL-DPTSBcnu.js} +1 -1
  43. package/dist/dashboard/assets/{gitGraphDiagram-UUTBAWPF-BuhQ28fO.js → gitGraphDiagram-UUTBAWPF-BxfeiCqm.js} +1 -1
  44. package/dist/dashboard/assets/{gl-ES-HMX3MZ6V-C5wE26uu.js → gl-ES-HMX3MZ6V-WtVwXY6x.js} +1 -1
  45. package/dist/dashboard/assets/{graph-Djm-nnL-.js → graph-Du_3_o8q.js} +1 -1
  46. package/dist/dashboard/assets/{he-IL-6SHJWFNN-B0U2BY4u.js → he-IL-6SHJWFNN-CfgspIku.js} +1 -1
  47. package/dist/dashboard/assets/{hi-IN-IWLTKZ5I-Ddqmbdc3.js → hi-IN-IWLTKZ5I-CS9l2g3B.js} +1 -1
  48. package/dist/dashboard/assets/{hu-HU-A5ZG7DT2-Bql7W1FB.js → hu-HU-A5ZG7DT2-BQ46AerM.js} +1 -1
  49. package/dist/dashboard/assets/{id-ID-SAP4L64H-BgPUuH6X.js → id-ID-SAP4L64H-BeShJyKQ.js} +1 -1
  50. package/dist/dashboard/assets/{index-DpzkIBIK.js → index-BK87l45R.js} +1 -1
  51. package/dist/dashboard/assets/index-C9VT2u9E.js +480 -0
  52. package/dist/dashboard/assets/index-D-gsCv2F.js +1 -0
  53. package/dist/dashboard/assets/{index-DMgrVZGf.js → index-D7dWmypK.js} +1 -1
  54. package/dist/dashboard/assets/index-DoFaQKCx.css +1 -0
  55. package/dist/dashboard/assets/{infoDiagram-42DDH7IO-FlC8UXlC.js → infoDiagram-42DDH7IO-CcFhyaQp.js} +1 -1
  56. package/dist/dashboard/assets/{ishikawaDiagram-UXIWVN3A-CM7RkOdA.js → ishikawaDiagram-UXIWVN3A-9QJeD00p.js} +1 -1
  57. package/dist/dashboard/assets/{it-IT-JPQ66NNP-B8JStDkT.js → it-IT-JPQ66NNP-csyvfk0t.js} +1 -1
  58. package/dist/dashboard/assets/{ja-JP-DBVTYXUO-CjqVt-yD.js → ja-JP-DBVTYXUO-DctpJ2yz.js} +1 -1
  59. package/dist/dashboard/assets/{journeyDiagram-VCZTEJTY-CmXt_usI.js → journeyDiagram-VCZTEJTY-CU4EYedt.js} +1 -1
  60. package/dist/dashboard/assets/{kaa-6HZHGXH3-qlfTF570.js → kaa-6HZHGXH3-D0tWzHt3.js} +1 -1
  61. package/dist/dashboard/assets/{kab-KAB-ZGHBKWFO-B1jcf86v.js → kab-KAB-ZGHBKWFO-BC-g4xJU.js} +1 -1
  62. package/dist/dashboard/assets/{kanban-definition-6JOO6SKY-DfUTCwbu.js → kanban-definition-6JOO6SKY-BxXqVmz1.js} +1 -1
  63. package/dist/dashboard/assets/{kk-KZ-P5N5QNE5-CDGZZuGX.js → kk-KZ-P5N5QNE5-TLB3Lxri.js} +1 -1
  64. package/dist/dashboard/assets/{km-KH-HSX4SM5Z-VJhAICPS.js → km-KH-HSX4SM5Z-DCh7cRAS.js} +1 -1
  65. package/dist/dashboard/assets/{ko-KR-MTYHY66A-DTsCW-6Q.js → ko-KR-MTYHY66A-BPIl5ido.js} +1 -1
  66. package/dist/dashboard/assets/{ku-TR-6OUDTVRD-B7sBU8-V.js → ku-TR-6OUDTVRD-TUpeN1Tm.js} +1 -1
  67. package/dist/dashboard/assets/{layout-LL6b15MZ.js → layout-CyrgfqIp.js} +1 -1
  68. package/dist/dashboard/assets/{linear-th65CRN7.js → linear-B6cMUkoc.js} +1 -1
  69. package/dist/dashboard/assets/{lt-LT-XHIRWOB4-DLwGTeYc.js → lt-LT-XHIRWOB4-BRKyR_Xw.js} +1 -1
  70. package/dist/dashboard/assets/{lv-LV-5QDEKY6T-Df5ujP3N.js → lv-LV-5QDEKY6T-BANbTe4s.js} +1 -1
  71. package/dist/dashboard/assets/{min-C1cE6N2D.js → min-lcwVZhZ7.js} +1 -1
  72. package/dist/dashboard/assets/{mindmap-definition-QFDTVHPH-n-x0bf17.js → mindmap-definition-QFDTVHPH-fVIbdlXp.js} +1 -1
  73. package/dist/dashboard/assets/{mr-IN-CRQNXWMA-B0504Lxj.js → mr-IN-CRQNXWMA-DLFutdXk.js} +1 -1
  74. package/dist/dashboard/assets/{my-MM-5M5IBNSE-CTTz1o7j.js → my-MM-5M5IBNSE-CGWrcNBC.js} +1 -1
  75. package/dist/dashboard/assets/{nb-NO-T6EIAALU-C423tdvs.js → nb-NO-T6EIAALU-CGRDupuc.js} +1 -1
  76. package/dist/dashboard/assets/{nl-NL-IS3SIHDZ-BGX4T5hB.js → nl-NL-IS3SIHDZ-BKwBfrzp.js} +1 -1
  77. package/dist/dashboard/assets/{nn-NO-6E72VCQL-e7Z1mG0i.js → nn-NO-6E72VCQL-DDQkGe44.js} +1 -1
  78. package/dist/dashboard/assets/{oc-FR-POXYY2M6-CPEhofz-.js → oc-FR-POXYY2M6-DufeHCWh.js} +1 -1
  79. package/dist/dashboard/assets/{pa-IN-N4M65BXN-Dmdt2Etw.js → pa-IN-N4M65BXN-BUzelJDX.js} +1 -1
  80. package/dist/dashboard/assets/{percentages-BXMCSKIN-D36vqrao.js → percentages-BXMCSKIN-FxAvjywS.js} +7 -7
  81. package/dist/dashboard/assets/{pica-DyXfovKp.js → pica-Cek5bFnr.js} +1 -1
  82. package/dist/dashboard/assets/{pieDiagram-DEJITSTG-DFDPs7b_.js → pieDiagram-DEJITSTG-PgIrKPnB.js} +1 -1
  83. package/dist/dashboard/assets/{pl-PL-T2D74RX3-G1JddCZF.js → pl-PL-T2D74RX3-Bd-rxZs3.js} +1 -1
  84. package/dist/dashboard/assets/{pt-BR-5N22H2LF-pu4YiRox.js → pt-BR-5N22H2LF-D0QJGoo5.js} +1 -1
  85. package/dist/dashboard/assets/{pt-PT-UZXXM6DQ-BOYLmU0S.js → pt-PT-UZXXM6DQ-DjumltMq.js} +1 -1
  86. package/dist/dashboard/assets/{quadrantDiagram-34T5L4WZ-D7Ov5Uju.js → quadrantDiagram-34T5L4WZ-C30tZOBh.js} +1 -1
  87. package/dist/dashboard/assets/{requirementDiagram-MS252O5E-Blqx-X0l.js → requirementDiagram-MS252O5E-D3vhi-ZB.js} +1 -1
  88. package/dist/dashboard/assets/{ro-RO-JPDTUUEW-DlBiDeMi.js → ro-RO-JPDTUUEW-DmEo8cEd.js} +1 -1
  89. package/dist/dashboard/assets/{ru-RU-B4JR7IUQ-D0J18l95.js → ru-RU-B4JR7IUQ-ZHCu1nBu.js} +1 -1
  90. package/dist/dashboard/assets/{sankeyDiagram-XADWPNL6-BQbQa_T1.js → sankeyDiagram-XADWPNL6-Cmbs-PxO.js} +1 -1
  91. package/dist/dashboard/assets/{sequenceDiagram-FGHM5R23-DhJhyglC.js → sequenceDiagram-FGHM5R23-DlBqk4uQ.js} +1 -1
  92. package/dist/dashboard/assets/{si-LK-N5RQ5JYF-4JT6EDIh.js → si-LK-N5RQ5JYF-iuqtpRqI.js} +1 -1
  93. package/dist/dashboard/assets/{sk-SK-C5VTKIMK-Bx5AqQi7.js → sk-SK-C5VTKIMK-BWFUWdaQ.js} +1 -1
  94. package/dist/dashboard/assets/{sl-SI-NN7IZMDC-Duy44AJo.js → sl-SI-NN7IZMDC-irYTfiq_.js} +1 -1
  95. package/dist/dashboard/assets/{stateDiagram-FHFEXIEX-B3lrGt3B.js → stateDiagram-FHFEXIEX-B6T9ib8G.js} +1 -1
  96. package/dist/dashboard/assets/stateDiagram-v2-QKLJ7IA2-CN0hAOp7.js +1 -0
  97. package/dist/dashboard/assets/{subset-shared.chunk-DWRxaQue.js → subset-shared.chunk-LTgWgeng.js} +1 -1
  98. package/dist/dashboard/assets/{subset-worker.chunk-nm8TiAaC.js → subset-worker.chunk-CT_2iDuG.js} +1 -1
  99. package/dist/dashboard/assets/{sv-SE-XGPEYMSR-_WPtf9Fs.js → sv-SE-XGPEYMSR-BvDzjArd.js} +1 -1
  100. package/dist/dashboard/assets/{ta-IN-2NMHFXQM-BZEYawlk.js → ta-IN-2NMHFXQM-DdsS_3Yq.js} +1 -1
  101. package/dist/dashboard/assets/{th-TH-HPSO5L25-C_ugiLaK.js → th-TH-HPSO5L25-Duadkok3.js} +1 -1
  102. package/dist/dashboard/assets/{timeline-definition-GMOUNBTQ-D0RPX8Ye.js → timeline-definition-GMOUNBTQ-CHTQqVpC.js} +1 -1
  103. package/dist/dashboard/assets/{tr-TR-DEFEU3FU-DkmWDwcW.js → tr-TR-DEFEU3FU-CTnPpl_3.js} +1 -1
  104. package/dist/dashboard/assets/{uk-UA-QMV73CPH-l2YUg_fY.js → uk-UA-QMV73CPH-CAqmQ01_.js} +1 -1
  105. package/dist/dashboard/assets/{vennDiagram-DHZGUBPP-BxCgJ4Ig.js → vennDiagram-DHZGUBPP-tWl34rwo.js} +1 -1
  106. package/dist/dashboard/assets/{vi-VN-M7AON7JQ-Chu_8vm0.js → vi-VN-M7AON7JQ-Cz7FDG8R.js} +1 -1
  107. package/dist/dashboard/assets/{wardley-RL74JXVD-B74rcv6j.js → wardley-RL74JXVD-UjdnBcpJ.js} +1 -1
  108. package/dist/dashboard/assets/{wardleyDiagram-NUSXRM2D-BZex7ruR.js → wardleyDiagram-NUSXRM2D-KhVWSzPf.js} +1 -1
  109. package/dist/dashboard/assets/webviewWindow-Dlc9MvRw.js +1 -0
  110. package/dist/dashboard/assets/window-D0tFurhp.js +1 -0
  111. package/dist/dashboard/assets/{xychartDiagram-5P7HB3ND-BACIDW_J.js → xychartDiagram-5P7HB3ND-SwtVQYTW.js} +1 -1
  112. package/dist/dashboard/assets/{zh-CN-LNUGB5OW-cY5Hv8ht.js → zh-CN-LNUGB5OW-B7cbFS35.js} +1 -1
  113. package/dist/dashboard/assets/{zh-HK-E62DVLB3-BdyhmSC7.js → zh-HK-E62DVLB3-CLi9BFmp.js} +1 -1
  114. package/dist/dashboard/assets/{zh-TW-RAJ6MFWO-CTjI4bec.js → zh-TW-RAJ6MFWO-XAcgJHay.js} +1 -1
  115. package/dist/dashboard/index.html +2 -2
  116. package/dist/index.js +428 -167
  117. package/install.sh +18 -0
  118. package/package.json +1 -1
  119. package/dist/dashboard/assets/channel-13cbKCMF.js +0 -1
  120. package/dist/dashboard/assets/classDiagram-6PBFFD2Q-BX19A8jH.js +0 -1
  121. package/dist/dashboard/assets/classDiagram-v2-HSJHXN6E-BX19A8jH.js +0 -1
  122. package/dist/dashboard/assets/clone-CiHddu7Q.js +0 -1
  123. package/dist/dashboard/assets/core-RciSkj6z.js +0 -1
  124. package/dist/dashboard/assets/index-BZEr0UdA.css +0 -1
  125. package/dist/dashboard/assets/index-CCBqToG8.js +0 -480
  126. package/dist/dashboard/assets/stateDiagram-v2-QKLJ7IA2-oO_Mw_KF.js +0 -1
  127. package/dist/dashboard/assets/webviewWindow-BHsy7FSR.js +0 -1
package/dist/index.js CHANGED
@@ -41091,8 +41091,8 @@ async function handleCoreGet(_req, res, params, contextRoot) {
41091
41091
  return;
41092
41092
  }
41093
41093
  if (filename.endsWith(".json")) {
41094
- const { readFileSync: readFileSync65 } = await import("fs");
41095
- const raw2 = readFileSync65(filePath, "utf-8");
41094
+ const { readFileSync: readFileSync66 } = await import("fs");
41095
+ const raw2 = readFileSync66(filePath, "utf-8");
41096
41096
  try {
41097
41097
  const data = JSON.parse(raw2);
41098
41098
  sendJson(res, 200, { filename, type: "json", data });
@@ -41126,8 +41126,8 @@ async function handleCoreGet(_req, res, params, contextRoot) {
41126
41126
  });
41127
41127
  return;
41128
41128
  }
41129
- const { readFileSync: readFileSync64 } = await import("fs");
41130
- const raw = readFileSync64(filePath, "utf-8");
41129
+ const { readFileSync: readFileSync65 } = await import("fs");
41130
+ const raw = readFileSync65(filePath, "utf-8");
41131
41131
  sendJson(res, 200, { filename, type: "text", content: raw });
41132
41132
  }
41133
41133
  async function handleCoreUpdate(req, res, params, contextRoot) {
@@ -41177,8 +41177,8 @@ async function handleCoreUpdate(req, res, params, contextRoot) {
41177
41177
  return;
41178
41178
  }
41179
41179
  changedParts.push("content");
41180
- const { writeFileSync: writeFileSync43 } = await import("fs");
41181
- writeFileSync43(filePath, body.content, "utf-8");
41180
+ const { writeFileSync: writeFileSync44 } = await import("fs");
41181
+ writeFileSync44(filePath, body.content, "utf-8");
41182
41182
  }
41183
41183
  const what = changedParts.length > 0 ? changedParts.join(" and ") : "file";
41184
41184
  recordDashboardChange(contextRoot, {
@@ -42394,8 +42394,9 @@ var init_config = __esm({
42394
42394
 
42395
42395
  // src/server/routes/vaults.ts
42396
42396
  import { dirname as dirname28, resolve as resolve14 } from "path";
42397
+ import { existsSync as existsSync62 } from "fs";
42397
42398
  async function handleVaultsGet(_req, res, _params, contextRoot) {
42398
- const vaults = listVaults();
42399
+ const vaults = listVaults().map((v) => ({ ...v, exists: existsSync62(resolve14(v.path)) }));
42399
42400
  const current = contextRoot ? vaults.find((v) => resolve14(v.path) === resolve14(dirname28(contextRoot)))?.name ?? null : null;
42400
42401
  sendJson(res, 200, { vaults, current });
42401
42402
  }
@@ -42491,10 +42492,22 @@ var init_ensure_cli = __esm({
42491
42492
 
42492
42493
  // src/server/routes/launcher.ts
42493
42494
  import { basename as basename18, isAbsolute, join as join59, resolve as resolve15, sep as sep9 } from "path";
42494
- import { existsSync as existsSync62, mkdirSync as mkdirSync25, readdirSync as readdirSync15, statSync as statSync10 } from "fs";
42495
+ import { existsSync as existsSync63, mkdirSync as mkdirSync25, readdirSync as readdirSync15, statSync as statSync10, createReadStream, readFileSync as readFileSync45, writeFileSync as writeFileSync32 } from "fs";
42495
42496
  import { homedir as homedir3 } from "os";
42496
- import { execFile as execFile2 } from "child_process";
42497
+ import { execFile as execFile2, spawn as spawn4 } from "child_process";
42497
42498
  import { promisify as promisify2 } from "util";
42499
+ import { randomUUID as randomUUID2 } from "crypto";
42500
+ function pruneCaptureRuns() {
42501
+ const now = Date.now();
42502
+ for (const [id, run2] of captureRuns) {
42503
+ if (run2.endedAt && now - run2.endedAt > CAPTURE_RUN_TTL_MS) captureRuns.delete(id);
42504
+ }
42505
+ while (captureRuns.size > CAPTURE_RUNS_MAX) {
42506
+ const oldest = captureRuns.keys().next().value;
42507
+ if (oldest === void 0) break;
42508
+ captureRuns.delete(oldest);
42509
+ }
42510
+ }
42498
42511
  async function handleLauncherDiscover(req, res, _params, _contextRoot) {
42499
42512
  const url = new URL(req.url || "/", `http://${req.headers.host}`);
42500
42513
  const root = url.searchParams.get("root");
@@ -42503,7 +42516,7 @@ async function handleLauncherDiscover(req, res, _params, _contextRoot) {
42503
42516
  return;
42504
42517
  }
42505
42518
  const resolvedRoot = resolve15(root);
42506
- if (!existsSync62(resolvedRoot)) {
42519
+ if (!existsSync63(resolvedRoot)) {
42507
42520
  sendError(res, 400, "invalid_root", `Path does not exist: ${resolvedRoot}`);
42508
42521
  return;
42509
42522
  }
@@ -42554,6 +42567,10 @@ function isNonEmptyDir(dir) {
42554
42567
  async function scaffoldProject(a, runner = defaultCliRunner, home) {
42555
42568
  const name = (a.name ?? "").trim();
42556
42569
  if (!name) throw new ScaffoldError("name must be a non-empty string.");
42570
+ const platforms = ensurePlatformSelection(normalizePlatforms(a.platforms ?? []));
42571
+ const platformArg = platforms.join(",");
42572
+ const knownPackNames = new Set((loadCatalog()?.catalog.packs ?? []).map((p) => p.name));
42573
+ const packs = (a.packs ?? []).map((p) => String(p).trim()).filter((p) => knownPackNames.has(p));
42557
42574
  let target;
42558
42575
  if (a.mode === "new") {
42559
42576
  if (!SAFE_NAME_RE.test(name)) {
@@ -42567,14 +42584,14 @@ async function scaffoldProject(a, runner = defaultCliRunner, home) {
42567
42584
  throw new ScaffoldError("parentDir must be an absolute path.");
42568
42585
  }
42569
42586
  const resolvedParent = resolve15(parentDir);
42570
- if (!existsSync62(resolvedParent) || !statSync10(resolvedParent).isDirectory()) {
42587
+ if (!existsSync63(resolvedParent) || !statSync10(resolvedParent).isDirectory()) {
42571
42588
  throw new ScaffoldError(`Parent directory does not exist: ${resolvedParent}`);
42572
42589
  }
42573
42590
  target = resolve15(resolvedParent, name);
42574
42591
  if (target !== join59(resolvedParent, name) || !target.startsWith(resolvedParent + sep9)) {
42575
42592
  throw new ScaffoldError("Resolved project path escapes the parent directory.");
42576
42593
  }
42577
- if (isNonEmptyDir(target) && !existsSync62(join59(target, "_dream_context"))) {
42594
+ if (isNonEmptyDir(target) && !existsSync63(join59(target, "_dream_context"))) {
42578
42595
  throw new ScaffoldError(`A non-empty folder already exists at ${target}.`);
42579
42596
  }
42580
42597
  mkdirSync25(target, { recursive: true });
@@ -42584,20 +42601,24 @@ async function scaffoldProject(a, runner = defaultCliRunner, home) {
42584
42601
  throw new ScaffoldError("projectPath must be an absolute path.");
42585
42602
  }
42586
42603
  target = resolve15(projectPath);
42587
- if (!existsSync62(target) || !statSync10(target).isDirectory()) {
42604
+ if (!existsSync63(target) || !statSync10(target).isDirectory()) {
42588
42605
  throw new ScaffoldError(`Folder does not exist: ${target}`);
42589
42606
  }
42590
42607
  } else {
42591
42608
  throw new ScaffoldError("mode must be 'new' or 'existing'.");
42592
42609
  }
42593
- if (!existsSync62(join59(target, "_dream_context"))) {
42594
- const initArgs = ["init", "--yes", "--platforms", "claude", "--name", name];
42610
+ const alreadyProject = existsSync63(join59(target, "_dream_context"));
42611
+ if (!alreadyProject) {
42612
+ const initArgs = ["init", "--yes", "--platforms", platformArg, "--name", name];
42595
42613
  if (a.description?.trim()) initArgs.push("--description", a.description.trim());
42596
42614
  if (a.targetUser?.trim()) initArgs.push("--user", a.targetUser.trim());
42597
42615
  if (a.stack?.trim()) initArgs.push("--stack", a.stack.trim());
42598
42616
  if (a.priority?.trim()) initArgs.push("--priority", a.priority.trim());
42599
42617
  await runner(initArgs, target);
42600
- await runner(["setup", "--defaults", "--platforms", "claude"], target);
42618
+ }
42619
+ await runner(["setup", "--defaults", "--platforms", platformArg], target);
42620
+ if (packs.length > 0) {
42621
+ await runner(["install-skill", "--packs", ...packs, "--platforms", platformArg], target);
42601
42622
  }
42602
42623
  const vault = addVault(name, target, home);
42603
42624
  return { vault, vaults: listVaults(home) };
@@ -42616,7 +42637,9 @@ async function handleLauncherScaffold(req, res, _params, _contextRoot) {
42616
42637
  stack: typeof body.stack === "string" ? body.stack : void 0,
42617
42638
  priority: typeof body.priority === "string" ? body.priority : void 0,
42618
42639
  parentDir: typeof body.parentDir === "string" ? body.parentDir : void 0,
42619
- projectPath: typeof body.projectPath === "string" ? body.projectPath : void 0
42640
+ projectPath: typeof body.projectPath === "string" ? body.projectPath : void 0,
42641
+ platforms: Array.isArray(body.platforms) ? body.platforms.filter((p) => typeof p === "string") : void 0,
42642
+ packs: Array.isArray(body.packs) ? body.packs.filter((p) => typeof p === "string") : void 0
42620
42643
  };
42621
42644
  try {
42622
42645
  const result = await scaffoldProject(answers);
@@ -42639,21 +42662,244 @@ async function handleLauncherDetect(req, res, _params, _contextRoot) {
42639
42662
  return;
42640
42663
  }
42641
42664
  const resolved = resolve15(path2);
42642
- if (!existsSync62(resolved)) {
42665
+ if (!existsSync63(resolved)) {
42643
42666
  sendError(res, 400, "invalid_path", `Path does not exist: ${resolved}`);
42644
42667
  return;
42645
42668
  }
42646
42669
  sendJson(res, 200, {
42647
42670
  stack: detectTechStack(resolved) ?? "",
42648
- hasContext: existsSync62(join59(resolved, "_dream_context")),
42671
+ hasContext: existsSync63(join59(resolved, "_dream_context")),
42649
42672
  name: basename18(resolved)
42650
42673
  });
42651
42674
  }
42675
+ async function handleLauncherCatalog(_req, res, _params, _contextRoot) {
42676
+ const recommended = new Set(DEFAULT_PLATFORMS);
42677
+ const platforms = PLATFORM_CATALOG.map((p) => ({
42678
+ id: p.id,
42679
+ label: p.label,
42680
+ description: p.description,
42681
+ recommended: recommended.has(p.id)
42682
+ }));
42683
+ const packs = (loadCatalog()?.catalog.packs ?? []).map((p) => ({
42684
+ name: p.name,
42685
+ description: p.description,
42686
+ tags: p.tags
42687
+ }));
42688
+ sendJson(res, 200, { platforms, packs });
42689
+ }
42690
+ function sleepyConfigPath() {
42691
+ return join59(homedir3(), ".dreamcontext", "sleepy.json");
42692
+ }
42693
+ async function handleSleepyConfigGet(_req, res, _params, _contextRoot) {
42694
+ let enabled = false;
42695
+ let hotkey = "Alt+Cmd+S";
42696
+ try {
42697
+ const p = sleepyConfigPath();
42698
+ if (existsSync63(p)) {
42699
+ const raw = JSON.parse(readFileSync45(p, "utf-8"));
42700
+ enabled = raw.enabled === true;
42701
+ if (typeof raw.hotkey === "string" && raw.hotkey.trim()) hotkey = raw.hotkey;
42702
+ }
42703
+ } catch {
42704
+ }
42705
+ sendJson(res, 200, { enabled, hotkey });
42706
+ }
42707
+ async function handleSleepyConfigSet(req, res, _params, _contextRoot) {
42708
+ const body = await parseJsonBody(req);
42709
+ if (!body) {
42710
+ sendError(res, 400, "invalid_body", "Request body must be valid JSON.");
42711
+ return;
42712
+ }
42713
+ const enabled = body.enabled === true;
42714
+ const hotkey = typeof body.hotkey === "string" && body.hotkey.trim() ? body.hotkey.trim() : "Alt+Cmd+S";
42715
+ try {
42716
+ const p = sleepyConfigPath();
42717
+ mkdirSync25(join59(homedir3(), ".dreamcontext"), { recursive: true });
42718
+ writeFileSync32(p, JSON.stringify({ enabled, hotkey }, null, 2) + "\n", "utf-8");
42719
+ sendJson(res, 200, { enabled, hotkey });
42720
+ } catch (err) {
42721
+ console.error("[launcher] sleepy-config write failed:", err);
42722
+ sendError(res, 500, "write_failed", "Failed to persist Sleepy config.");
42723
+ }
42724
+ }
42725
+ async function handleSleepyVideo(req, res, _params, _contextRoot) {
42726
+ const url = new URL(req.url || "/", `http://${req.headers.host}`);
42727
+ const mode = url.searchParams.get("mode") || "idle";
42728
+ if (!SLEEPY_MODES.has(mode)) {
42729
+ sendError(res, 400, "bad_mode", "mode must be idle, sleepy, or sleeps.");
42730
+ return;
42731
+ }
42732
+ const dir = process.env.DREAMCONTEXT_SLEEPY_DIR;
42733
+ if (!dir) {
42734
+ res.writeHead(404);
42735
+ res.end();
42736
+ return;
42737
+ }
42738
+ const file = join59(dir, `${mode}.mp4`);
42739
+ if (!existsSync63(file)) {
42740
+ res.writeHead(404);
42741
+ res.end();
42742
+ return;
42743
+ }
42744
+ const size = statSync10(file).size;
42745
+ const range = req.headers.range;
42746
+ if (range) {
42747
+ const m = /bytes=(\d+)-(\d*)/.exec(range);
42748
+ const start = m ? parseInt(m[1], 10) : 0;
42749
+ const end = m && m[2] ? Math.min(parseInt(m[2], 10), size - 1) : size - 1;
42750
+ res.writeHead(206, {
42751
+ "Content-Type": "video/mp4",
42752
+ "Accept-Ranges": "bytes",
42753
+ "Content-Range": `bytes ${start}-${end}/${size}`,
42754
+ "Content-Length": end - start + 1
42755
+ });
42756
+ createReadStream(file, { start, end }).pipe(res);
42757
+ } else {
42758
+ res.writeHead(200, { "Content-Type": "video/mp4", "Accept-Ranges": "bytes", "Content-Length": size });
42759
+ createReadStream(file).pipe(res);
42760
+ }
42761
+ }
42762
+ async function handleSleepyAnim(req, res, _params, _contextRoot) {
42763
+ const url = new URL(req.url || "/", `http://${req.headers.host}`);
42764
+ const mode = url.searchParams.get("mode") || "idle";
42765
+ if (!SLEEPY_MODES.has(mode)) {
42766
+ sendError(res, 400, "bad_mode", "mode must be idle, sleepy, or sleeps.");
42767
+ return;
42768
+ }
42769
+ const dir = process.env.DREAMCONTEXT_SLEEPY_DIR;
42770
+ const file = dir ? join59(dir, `${mode}.webp`) : "";
42771
+ if (!file || !existsSync63(file)) {
42772
+ res.writeHead(404);
42773
+ res.end();
42774
+ return;
42775
+ }
42776
+ const size = statSync10(file).size;
42777
+ res.writeHead(200, {
42778
+ "Content-Type": "image/webp",
42779
+ "Content-Length": size,
42780
+ "Cache-Control": "public, max-age=86400"
42781
+ });
42782
+ createReadStream(file).pipe(res);
42783
+ }
42784
+ function buildCapturePrompt(note) {
42785
+ return `Think hard. A quick-capture note was just saved to this project's dreamcontext memory:
42786
+
42787
+ "${note}"
42788
+
42789
+ Do NOT ask any follow-up questions. Review it and, if warranted, organize or enrich it into the appropriate dreamcontext knowledge/memory via the dreamcontext CLI WITHOUT duplicating the raw note. Then stop.`;
42790
+ }
42791
+ function buildAskPrompt(question) {
42792
+ return `Think hard, then answer the following question about THIS project. Format the answer as GitHub-flavored Markdown. Be SHORT and CLEAR \u2014 at most a few sentences or a tight bullet list, no preamble, do not restate the question. Use the project's dreamcontext context and code as needed. Do NOT ask any follow-up questions and do NOT make any file changes. Give ONE direct answer, then stop.
42793
+
42794
+ Question: "${question}"`;
42795
+ }
42796
+ function buildSleepPrompt() {
42797
+ return `Think hard. Run a dreamcontext memory consolidation ("sleep") for THIS project now, fully autonomously \u2014 do NOT ask any questions. Follow the project's dreamcontext sleep/consolidation flow: pin the epoch with \`dreamcontext sleep start\`, reconcile the task/changelog/knowledge/feature files to current truth as warranted (prefer updating existing entities over creating new ones), then close the cycle with \`dreamcontext sleep done "<one-paragraph summary>"\` to reset the debt. When finished, reply with a SHORT GitHub-flavored Markdown summary (a few bullets) of what was consolidated. Keep it concise.`;
42798
+ }
42799
+ async function handleLauncherCapture(req, res, _params, _contextRoot) {
42800
+ const body = await parseJsonBody(req);
42801
+ if (!body) {
42802
+ sendError(res, 400, "invalid_body", "Request body must be valid JSON.");
42803
+ return;
42804
+ }
42805
+ const vaultName = typeof body.vault === "string" ? body.vault.trim() : "";
42806
+ const text = typeof body.text === "string" ? body.text.trim() : "";
42807
+ if (!vaultName) {
42808
+ sendError(res, 400, "invalid_vault", "vault must be a non-empty string.");
42809
+ return;
42810
+ }
42811
+ const mode = body.mode === "ask" ? "ask" : body.mode === "sleep" ? "sleep" : "learn";
42812
+ if (mode !== "sleep" && !text) {
42813
+ sendError(res, 400, "invalid_text", "text must be a non-empty string.");
42814
+ return;
42815
+ }
42816
+ const vault = listVaults().find((v) => v.name === vaultName);
42817
+ if (!vault) {
42818
+ sendError(res, 400, "unknown_vault", `No registered vault named "${vaultName}".`);
42819
+ return;
42820
+ }
42821
+ const cwd = resolve15(vault.path);
42822
+ if (!existsSync63(cwd)) {
42823
+ sendError(res, 400, "missing_vault", `Vault path no longer exists: ${cwd}`);
42824
+ return;
42825
+ }
42826
+ if (mode === "learn") {
42827
+ try {
42828
+ const changelogPath = join59(cwd, "_dream_context", "core", "CHANGELOG.json");
42829
+ if (!existsSync63(changelogPath)) {
42830
+ sendError(res, 400, "not_initialized", `"${vaultName}" has no _dream_context \u2014 run init first.`);
42831
+ return;
42832
+ }
42833
+ const summary = text.length > 200 ? text.slice(0, 197) + "..." : text;
42834
+ insertToJsonArray(changelogPath, {
42835
+ date: today(),
42836
+ type: "note",
42837
+ scope: "quick",
42838
+ summary,
42839
+ description: text,
42840
+ breaking: false
42841
+ });
42842
+ } catch (err) {
42843
+ console.error("[launcher] capture changelog write failed:", err);
42844
+ const detail = err instanceof Error ? err.message : "unknown error";
42845
+ sendError(res, 500, "capture_failed", `Failed to save the note: ${detail}`);
42846
+ return;
42847
+ }
42848
+ }
42849
+ pruneCaptureRuns();
42850
+ const captureId = randomUUID2();
42851
+ const run2 = { state: "running", output: "", stderr: "", startedAt: Date.now() };
42852
+ captureRuns.set(captureId, run2);
42853
+ try {
42854
+ const shell = process.env.SHELL || "/bin/zsh";
42855
+ const prompt = mode === "sleep" ? buildSleepPrompt() : mode === "ask" ? buildAskPrompt(text) : buildCapturePrompt(text);
42856
+ const child = spawn4(shell, ["-ilc", 'exec claude --model sonnet -p "$0"', prompt], {
42857
+ cwd,
42858
+ stdio: ["ignore", "pipe", "pipe"]
42859
+ });
42860
+ child.stdout?.on("data", (chunk) => {
42861
+ run2.output = (run2.output + chunk.toString("utf-8")).slice(-8e3);
42862
+ });
42863
+ child.stderr?.on("data", (chunk) => {
42864
+ run2.stderr = (run2.stderr + chunk.toString("utf-8")).slice(-4e3);
42865
+ });
42866
+ child.on("error", (err) => {
42867
+ run2.state = "error";
42868
+ run2.output = `Couldn't start claude: ${err.message}`;
42869
+ run2.endedAt = Date.now();
42870
+ });
42871
+ child.on("close", (code) => {
42872
+ if (run2.state !== "running") return;
42873
+ if (code === 0) {
42874
+ run2.state = "done";
42875
+ } else {
42876
+ run2.state = "error";
42877
+ if (!run2.output.trim()) run2.output = run2.stderr.trim() || `claude exited with code ${code}`;
42878
+ }
42879
+ run2.endedAt = Date.now();
42880
+ });
42881
+ } catch (err) {
42882
+ run2.state = "error";
42883
+ run2.output = `Couldn't start claude: ${err instanceof Error ? err.message : "spawn failed"}`;
42884
+ run2.endedAt = Date.now();
42885
+ }
42886
+ sendJson(res, 200, { ok: true, captureId });
42887
+ }
42888
+ async function handleLauncherCaptureStatus(req, res, _params, _contextRoot) {
42889
+ const url = new URL(req.url || "/", `http://${req.headers.host}`);
42890
+ const id = url.searchParams.get("id") ?? "";
42891
+ const run2 = id ? captureRuns.get(id) : void 0;
42892
+ if (!run2) {
42893
+ sendJson(res, 200, { state: "unknown", output: "" });
42894
+ return;
42895
+ }
42896
+ sendJson(res, 200, { state: run2.state, output: run2.output.trim() });
42897
+ }
42652
42898
  async function handleLauncherDefaults(_req, res, _params, _contextRoot) {
42653
42899
  const home = homedir3();
42654
42900
  sendJson(res, 200, { home, defaultParent: join59(home, "projects") });
42655
42901
  }
42656
- var execFileAsync2, ScaffoldError, defaultCliRunner, SAFE_NAME_RE;
42902
+ var execFileAsync2, captureRuns, CAPTURE_RUN_TTL_MS, CAPTURE_RUNS_MAX, ScaffoldError, defaultCliRunner, SAFE_NAME_RE, SLEEPY_MODES;
42657
42903
  var init_launcher = __esm({
42658
42904
  "src/server/routes/launcher.ts"() {
42659
42905
  "use strict";
@@ -42662,7 +42908,14 @@ var init_launcher = __esm({
42662
42908
  init_vaults();
42663
42909
  init_tech_stack();
42664
42910
  init_ensure_cli();
42911
+ init_platforms();
42912
+ init_catalog();
42913
+ init_json_file();
42914
+ init_id();
42665
42915
  execFileAsync2 = promisify2(execFile2);
42916
+ captureRuns = /* @__PURE__ */ new Map();
42917
+ CAPTURE_RUN_TTL_MS = 10 * 60 * 1e3;
42918
+ CAPTURE_RUNS_MAX = 50;
42666
42919
  ScaffoldError = class extends Error {
42667
42920
  constructor(message) {
42668
42921
  super(message);
@@ -42683,6 +42936,7 @@ var init_launcher = __esm({
42683
42936
  });
42684
42937
  };
42685
42938
  SAFE_NAME_RE = /^[^/\\]+$/;
42939
+ SLEEPY_MODES = /* @__PURE__ */ new Set(["idle", "sleepy", "sleeps"]);
42686
42940
  }
42687
42941
  });
42688
42942
 
@@ -42874,7 +43128,7 @@ var init_connections2 = __esm({
42874
43128
  });
42875
43129
 
42876
43130
  // src/lib/federation-digest.ts
42877
- import { existsSync as existsSync63 } from "fs";
43131
+ import { existsSync as existsSync64 } from "fs";
42878
43132
  import { join as join60 } from "path";
42879
43133
  function buildInterestProfile(peerRoot, topics) {
42880
43134
  if (topics && topics.length > 0) {
@@ -42895,7 +43149,7 @@ function buildInterestProfile(peerRoot, topics) {
42895
43149
  }
42896
43150
  function activeTaskTerms(peerRoot) {
42897
43151
  const stateDir = join60(peerRoot, "state");
42898
- if (!existsSync63(stateDir)) return [];
43152
+ if (!existsSync64(stateDir)) return [];
42899
43153
  let files;
42900
43154
  try {
42901
43155
  files = import_fast_glob17.default.sync("*.md", { cwd: stateDir, absolute: true });
@@ -43260,8 +43514,15 @@ function buildRouter() {
43260
43514
  router.get("/api/launcher/discover", handleLauncherDiscover);
43261
43515
  router.get("/api/launcher/detect", handleLauncherDetect);
43262
43516
  router.get("/api/launcher/defaults", handleLauncherDefaults);
43517
+ router.get("/api/launcher/catalog", handleLauncherCatalog);
43263
43518
  router.post("/api/launcher/register", handleLauncherRegister);
43264
43519
  router.post("/api/launcher/scaffold", handleLauncherScaffold);
43520
+ router.post("/api/launcher/capture", handleLauncherCapture);
43521
+ router.get("/api/launcher/capture/status", handleLauncherCaptureStatus);
43522
+ router.get("/api/launcher/sleepy-config", handleSleepyConfigGet);
43523
+ router.post("/api/launcher/sleepy-config", handleSleepyConfigSet);
43524
+ router.get("/api/sleepy/video", handleSleepyVideo);
43525
+ router.get("/api/sleepy/anim", handleSleepyAnim);
43265
43526
  router.get("/api/vaults", handleVaultsGet);
43266
43527
  router.get("/api/connections", handleConnectionsList);
43267
43528
  router.post("/api/connections", handleConnectionsCreate);
@@ -43399,7 +43660,7 @@ var init_server = __esm({
43399
43660
  init_version_check2();
43400
43661
  init_taxonomy2();
43401
43662
  init_vaults();
43402
- VAULT_AGNOSTIC_PREFIXES = ["/api/health", "/api/vaults", "/api/launcher"];
43663
+ VAULT_AGNOSTIC_PREFIXES = ["/api/health", "/api/vaults", "/api/launcher", "/api/sleepy"];
43403
43664
  }
43404
43665
  });
43405
43666
 
@@ -43583,7 +43844,7 @@ var init_trigger = __esm({
43583
43844
  });
43584
43845
 
43585
43846
  // src/lib/reflection.ts
43586
- import { existsSync as existsSync64, mkdirSync as mkdirSync26, writeFileSync as writeFileSync32 } from "fs";
43847
+ import { existsSync as existsSync65, mkdirSync as mkdirSync26, writeFileSync as writeFileSync33 } from "fs";
43587
43848
  import { join as join62, dirname as dirname36 } from "path";
43588
43849
  function buildExclusionSet(corpus, excludedExtra) {
43589
43850
  const excluded = new Set(excludedExtra);
@@ -43765,7 +44026,7 @@ function reflectionPath(root) {
43765
44026
  function writeReflection(root, md) {
43766
44027
  const outPath = reflectionPath(root);
43767
44028
  const dir = dirname36(outPath);
43768
- if (!existsSync64(dir)) {
44029
+ if (!existsSync65(dir)) {
43769
44030
  mkdirSync26(dir, { recursive: true });
43770
44031
  }
43771
44032
  const tsMatch = md.match(/Generated: ([^\n]+)/);
@@ -43777,7 +44038,7 @@ function writeReflection(root, md) {
43777
44038
  "---",
43778
44039
  ""
43779
44040
  ].join("\n");
43780
- writeFileSync32(outPath, frontmatter + md, "utf-8");
44041
+ writeFileSync33(outPath, frontmatter + md, "utf-8");
43781
44042
  return outPath;
43782
44043
  }
43783
44044
  var MAX_REFLECTION_BYTES, DEFAULT_MIN_SESSIONS, DEFAULT_MAX_CANDIDATES, REFLECTION_NOISE;
@@ -43941,14 +44202,14 @@ var init_reflection = __esm({
43941
44202
  });
43942
44203
 
43943
44204
  // src/cli/commands/reflect.ts
43944
- import { existsSync as existsSync65, readFileSync as readFileSync47 } from "fs";
44205
+ import { existsSync as existsSync66, readFileSync as readFileSync48 } from "fs";
43945
44206
  import { join as join63 } from "path";
43946
44207
  function buildBookmarkSessions(root) {
43947
44208
  const sleepPath = join63(root, "state", ".sleep.json");
43948
44209
  const result = /* @__PURE__ */ new Map();
43949
- if (!existsSync65(sleepPath)) return result;
44210
+ if (!existsSync66(sleepPath)) return result;
43950
44211
  try {
43951
- const parsed = JSON.parse(readFileSync47(sleepPath, "utf-8"));
44212
+ const parsed = JSON.parse(readFileSync48(sleepPath, "utf-8"));
43952
44213
  const bookmarks = parsed.bookmarks ?? [];
43953
44214
  for (const b of bookmarks) {
43954
44215
  if (b.id && b.session_id) {
@@ -43966,9 +44227,9 @@ function buildExcludedExtra(root) {
43966
44227
  join63(root, "core", "1.user.md")
43967
44228
  ];
43968
44229
  for (const filePath of coreFiles) {
43969
- if (!existsSync65(filePath)) continue;
44230
+ if (!existsSync66(filePath)) continue;
43970
44231
  try {
43971
- const content = readFileSync47(filePath, "utf-8");
44232
+ const content = readFileSync48(filePath, "utf-8");
43972
44233
  for (const tok of tokenize(content)) {
43973
44234
  excluded.add(tok);
43974
44235
  }
@@ -44019,7 +44280,7 @@ var init_reflect = __esm({
44019
44280
  });
44020
44281
 
44021
44282
  // src/cli/commands/council.ts
44022
- import { existsSync as existsSync66, mkdirSync as mkdirSync27, readFileSync as readFileSync48, writeFileSync as writeFileSync33 } from "fs";
44283
+ import { existsSync as existsSync67, mkdirSync as mkdirSync27, readFileSync as readFileSync49, writeFileSync as writeFileSync34 } from "fs";
44023
44284
  import { join as join64 } from "path";
44024
44285
  function roundRunningStatus(n) {
44025
44286
  return `round_${n}_running`;
@@ -44065,8 +44326,8 @@ function registerCreate(council) {
44065
44326
  mkdirSync27(dir, { recursive: true });
44066
44327
  const template = loadTemplate("council-debate.md");
44067
44328
  const content = template.replaceAll("{{ID}}", id).replaceAll("{{TOPIC}}", topic.replace(/"/g, '\\"')).replaceAll("{{ROUNDS}}", String(rounds)).replaceAll("{{INTERRUPT}}", opts.interrupt ? "true" : "false").replaceAll("{{DATE}}", today());
44068
- writeFileSync33(join64(dir, "debate.md"), content, "utf-8");
44069
- writeFileSync33(
44329
+ writeFileSync34(join64(dir, "debate.md"), content, "utf-8");
44330
+ writeFileSync34(
44070
44331
  join64(dir, "round-log.md"),
44071
44332
  `# Round log \u2014 ${id}
44072
44333
 
@@ -44110,7 +44371,7 @@ function registerAgent(council) {
44110
44371
  }
44111
44372
  const personaDir = getPersonaDir(debateId, slug);
44112
44373
  const personaFile = join64(personaDir, "context-and-persona.md");
44113
- if (existsSync66(personaFile) && !opts.force) {
44374
+ if (existsSync67(personaFile) && !opts.force) {
44114
44375
  error(`Persona already exists: ${slug}`, "Use --force to overwrite.");
44115
44376
  process.exit(1);
44116
44377
  }
@@ -44123,10 +44384,10 @@ function registerAgent(council) {
44123
44384
  mkdirSync27(personaDir, { recursive: true });
44124
44385
  const template = loadTemplate("council-persona.md");
44125
44386
  const personaContent = template.replaceAll("{{SLUG}}", slug).replaceAll("{{MODEL}}", opts.model).replaceAll("{{ASPECTS}}", JSON.stringify(aspects)).replaceAll("{{PERSONA_BODY}}", body.trim());
44126
- writeFileSync33(personaFile, personaContent, "utf-8");
44387
+ writeFileSync34(personaFile, personaContent, "utf-8");
44127
44388
  const reportTemplate = loadTemplate("council-report.md");
44128
44389
  const reportContent = reportTemplate.replaceAll("{{SLUG}}", slug);
44129
- writeFileSync33(join64(personaDir, "report.md"), reportContent, "utf-8");
44390
+ writeFileSync34(join64(personaDir, "report.md"), reportContent, "utf-8");
44130
44391
  const debateFile = join64(getDebateDir(debateId), "debate.md");
44131
44392
  const { data } = readFrontmatter(debateFile);
44132
44393
  const personas = Array.isArray(data.personas) ? data.personas.slice() : [];
@@ -44166,8 +44427,8 @@ function registerRound(council) {
44166
44427
  if (n >= 2) {
44167
44428
  for (const persona of personas) {
44168
44429
  const personaFile = join64(getPersonaDir(debateId, persona), "context-and-persona.md");
44169
- if (!existsSync66(personaFile)) continue;
44170
- const existing = readFileSync48(personaFile, "utf-8");
44430
+ if (!existsSync67(personaFile)) continue;
44431
+ const existing = readFileSync49(personaFile, "utf-8");
44171
44432
  if (existing.includes(crossContextHeader)) {
44172
44433
  continue;
44173
44434
  }
@@ -44189,7 +44450,7 @@ _(no round ${n - 1} report submitted)_`);
44189
44450
 
44190
44451
  ${peerLines.join("\n\n")}`;
44191
44452
  const updated = existing.trimEnd() + "\n\n" + newSection + "\n";
44192
- writeFileSync33(personaFile, updated, "utf-8");
44453
+ writeFileSync34(personaFile, updated, "utf-8");
44193
44454
  }
44194
44455
  }
44195
44456
  updateFrontmatterFields(debateFile, {
@@ -44198,12 +44459,12 @@ ${peerLines.join("\n\n")}`;
44198
44459
  updated_at: today()
44199
44460
  });
44200
44461
  const logFile = join64(getDebateDir(debateId), "round-log.md");
44201
- const logExisting = existsSync66(logFile) ? readFileSync48(logFile, "utf-8") : "";
44462
+ const logExisting = existsSync67(logFile) ? readFileSync49(logFile, "utf-8") : "";
44202
44463
  const logEntry = `
44203
44464
  ## Round ${n} started \u2014 ${today()}
44204
44465
  - Personas: ${formatPersonaList(personas)}
44205
44466
  `;
44206
- writeFileSync33(logFile, logExisting.trimEnd() + "\n" + logEntry + "\n", "utf-8");
44467
+ writeFileSync34(logFile, logExisting.trimEnd() + "\n" + logEntry + "\n", "utf-8");
44207
44468
  upsertCouncilIndex({
44208
44469
  id: debateId,
44209
44470
  topic: data.topic,
@@ -44243,12 +44504,12 @@ ${peerLines.join("\n\n")}`;
44243
44504
  updated_at: today()
44244
44505
  });
44245
44506
  const logFile = join64(getDebateDir(debateId), "round-log.md");
44246
- const logExisting = existsSync66(logFile) ? readFileSync48(logFile, "utf-8") : "";
44507
+ const logExisting = existsSync67(logFile) ? readFileSync49(logFile, "utf-8") : "";
44247
44508
  const logEntry = `
44248
44509
  ## Round ${n} complete \u2014 ${today()}
44249
44510
  - All ${personas.length} personas submitted reports.
44250
44511
  `;
44251
- writeFileSync33(logFile, logExisting.trimEnd() + "\n" + logEntry + "\n", "utf-8");
44512
+ writeFileSync34(logFile, logExisting.trimEnd() + "\n" + logEntry + "\n", "utf-8");
44252
44513
  upsertCouncilIndex({
44253
44514
  id: debateId,
44254
44515
  topic: data.topic,
@@ -44272,7 +44533,7 @@ function registerRoundContext(council) {
44272
44533
  const data = readDebateFrontmatter(debateId);
44273
44534
  ensurePersonaExists(debateId, personaSlug);
44274
44535
  const personaFile = join64(getPersonaDir(debateId, personaSlug), "context-and-persona.md");
44275
- const personaContent = readFileSync48(personaFile, "utf-8");
44536
+ const personaContent = readFileSync49(personaFile, "utf-8");
44276
44537
  console.log(`# Council debate: ${data.topic}`);
44277
44538
  console.log(`Debate ID: ${debateId}`);
44278
44539
  console.log(`Current round: ${data.current_round}/${data.rounds_planned}`);
@@ -44282,7 +44543,7 @@ function registerRoundContext(council) {
44282
44543
  console.log("");
44283
44544
  console.log(personaContent);
44284
44545
  const debateFile = join64(getDebateDir(debateId), "debate.md");
44285
- const debateRaw = readFileSync48(debateFile, "utf-8");
44546
+ const debateRaw = readFileSync49(debateFile, "utf-8");
44286
44547
  const questionMatch = debateRaw.match(/##\s+Question\s*\n([\s\S]*?)(?=\n##\s|\Z)/);
44287
44548
  const constraintsMatch = debateRaw.match(/##\s+Constraints & Known Facts\s*\n([\s\S]*?)(?=\n##\s|\Z)/);
44288
44549
  if (questionMatch) {
@@ -44393,10 +44654,10 @@ function registerResearch(council) {
44393
44654
  const researchesDir = join64(getPersonaDir(debateId, personaSlug), "researches");
44394
44655
  mkdirSync27(researchesDir, { recursive: true });
44395
44656
  const indexPath2 = join64(researchesDir, "index.json");
44396
- if (!existsSync66(indexPath2)) writeJsonArray(indexPath2, []);
44657
+ if (!existsSync67(indexPath2)) writeJsonArray(indexPath2, []);
44397
44658
  const slug = slugify(topic);
44398
44659
  const file = join64(researchesDir, `${slug}.md`);
44399
- if (existsSync66(file)) {
44660
+ if (existsSync67(file)) {
44400
44661
  error(`Research note already exists: ${slug}.md`);
44401
44662
  process.exit(1);
44402
44663
  }
@@ -44411,7 +44672,7 @@ _Added ${today()} by ${personaSlug}_
44411
44672
 
44412
44673
  ${body.trim()}
44413
44674
  `;
44414
- writeFileSync33(file, noteContent, "utf-8");
44675
+ writeFileSync34(file, noteContent, "utf-8");
44415
44676
  insertToJsonArray(indexPath2, {
44416
44677
  slug,
44417
44678
  topic,
@@ -44428,7 +44689,7 @@ ${body.trim()}
44428
44689
  ensurePersonaExists(debateId, personaSlug);
44429
44690
  const researchesDir = join64(getPersonaDir(debateId, personaSlug), "researches");
44430
44691
  const indexPath2 = join64(researchesDir, "index.json");
44431
- if (!existsSync66(indexPath2)) {
44692
+ if (!existsSync67(indexPath2)) {
44432
44693
  console.log(source_default.dim("(no researches)"));
44433
44694
  return;
44434
44695
  }
@@ -44473,7 +44734,7 @@ function registerSynthesize(council) {
44473
44734
  manifest.push(`_dream_context/council/${debateId}/${persona}/context-and-persona.md`);
44474
44735
  manifest.push(`_dream_context/council/${debateId}/${persona}/report.md`);
44475
44736
  const researchesIndex = join64(personaDir, "researches", "index.json");
44476
- if (existsSync66(researchesIndex)) {
44737
+ if (existsSync67(researchesIndex)) {
44477
44738
  manifest.push(`_dream_context/council/${debateId}/${persona}/researches/`);
44478
44739
  }
44479
44740
  }
@@ -44492,7 +44753,7 @@ function registerComplete(council) {
44492
44753
  try {
44493
44754
  const data = readDebateFrontmatter(debateId);
44494
44755
  const finalReport = join64(getDebateDir(debateId), "final-report.md");
44495
- if (!existsSync66(finalReport)) {
44756
+ if (!existsSync67(finalReport)) {
44496
44757
  error("final-report.md not found.", "Synthesizer must write it before calling `council complete`.");
44497
44758
  process.exit(1);
44498
44759
  }
@@ -44529,7 +44790,7 @@ function registerPromote(council) {
44529
44790
  process.exit(1);
44530
44791
  }
44531
44792
  const finalReport = join64(getDebateDir(debateId), "final-report.md");
44532
- if (!existsSync66(finalReport)) {
44793
+ if (!existsSync67(finalReport)) {
44533
44794
  error("final-report.md not found.");
44534
44795
  process.exit(1);
44535
44796
  }
@@ -44547,7 +44808,7 @@ ${sec.body.trim()}` : null;
44547
44808
  const slug = slugify(data.topic).slice(0, 80) || debateId;
44548
44809
  const filename = `decision-${slug}.md`;
44549
44810
  const target = join64(knowledgeDir, filename);
44550
- if (existsSync66(target) && !opts.force) {
44811
+ if (existsSync67(target) && !opts.force) {
44551
44812
  error(`Knowledge file exists: ${filename}`, "Use --force to overwrite.");
44552
44813
  process.exit(1);
44553
44814
  }
@@ -44634,9 +44895,9 @@ function registerShow(council) {
44634
44895
  console.log(` created: ${data.created_at}`);
44635
44896
  console.log(` updated: ${data.updated_at}`);
44636
44897
  const logFile = join64(getDebateDir(debateId), "round-log.md");
44637
- if (existsSync66(logFile)) {
44898
+ if (existsSync67(logFile)) {
44638
44899
  console.log("\n" + source_default.dim("\u2500\u2500\u2500 Round log \u2500\u2500\u2500"));
44639
- console.log(readFileSync48(logFile, "utf-8"));
44900
+ console.log(readFileSync49(logFile, "utf-8"));
44640
44901
  }
44641
44902
  } catch (err) {
44642
44903
  error(err.message);
@@ -44828,12 +45089,12 @@ var init_env_loader = __esm({
44828
45089
  });
44829
45090
 
44830
45091
  // src/lib/marketing/config.ts
44831
- import { existsSync as existsSync67, readFileSync as readFileSync49, writeFileSync as writeFileSync34, mkdirSync as mkdirSync28 } from "fs";
45092
+ import { existsSync as existsSync68, readFileSync as readFileSync50, writeFileSync as writeFileSync35, mkdirSync as mkdirSync28 } from "fs";
44832
45093
  import { dirname as dirname37 } from "path";
44833
45094
  function readEnvFile() {
44834
45095
  const path2 = MARKETING_PATHS.envFile();
44835
- if (!existsSync67(path2)) return {};
44836
- const raw = readFileSync49(path2, "utf8");
45096
+ if (!existsSync68(path2)) return {};
45097
+ const raw = readFileSync50(path2, "utf8");
44837
45098
  const parsed = parseEnv(raw);
44838
45099
  if (parsed.errors.length > 0) {
44839
45100
  for (const e of parsed.errors) {
@@ -44877,9 +45138,9 @@ function requireEnv(keys = REQUIRED_KEYS) {
44877
45138
  }
44878
45139
  function loadConfig() {
44879
45140
  const path2 = MARKETING_PATHS.configFile();
44880
- if (!existsSync67(path2)) return { ...EMPTY_CONFIG, feature_flags: { ...EMPTY_CONFIG.feature_flags } };
45141
+ if (!existsSync68(path2)) return { ...EMPTY_CONFIG, feature_flags: { ...EMPTY_CONFIG.feature_flags } };
44881
45142
  try {
44882
- const raw = readFileSync49(path2, "utf8");
45143
+ const raw = readFileSync50(path2, "utf8");
44883
45144
  const parsed = JSON.parse(raw);
44884
45145
  return {
44885
45146
  default_profile: parsed.default_profile ?? null,
@@ -44895,20 +45156,20 @@ function loadConfig() {
44895
45156
  function writeConfig(cfg) {
44896
45157
  const path2 = MARKETING_PATHS.configFile();
44897
45158
  mkdirSync28(dirname37(path2), { recursive: true });
44898
- writeFileSync34(path2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
45159
+ writeFileSync35(path2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
44899
45160
  }
44900
45161
  function ensureConfigFile() {
44901
45162
  const path2 = MARKETING_PATHS.configFile();
44902
- if (existsSync67(path2)) return loadConfig();
45163
+ if (existsSync68(path2)) return loadConfig();
44903
45164
  const cfg = { ...EMPTY_CONFIG, feature_flags: { ...EMPTY_CONFIG.feature_flags } };
44904
45165
  writeConfig(cfg);
44905
45166
  return cfg;
44906
45167
  }
44907
45168
  function ensureEnvFile() {
44908
45169
  const path2 = MARKETING_PATHS.envFile();
44909
- if (existsSync67(path2)) return;
45170
+ if (existsSync68(path2)) return;
44910
45171
  mkdirSync28(marketingRoot(), { recursive: true });
44911
- writeFileSync34(path2, ENV_TEMPLATE, { encoding: "utf8", mode: 384 });
45172
+ writeFileSync35(path2, ENV_TEMPLATE, { encoding: "utf8", mode: 384 });
44912
45173
  }
44913
45174
  var DEFAULT_API_VERSION, EMPTY_CONFIG, REQUIRED_KEYS, OPTIONAL_KEYS, ENV_TEMPLATE;
44914
45175
  var init_config2 = __esm({
@@ -44948,8 +45209,8 @@ REINFLUENCE_BIN= # optional override; default uses .venv
44948
45209
  });
44949
45210
 
44950
45211
  // src/lib/marketing/bootstrap.ts
44951
- import { spawn as spawn4, spawnSync as spawnSync2 } from "child_process";
44952
- import { existsSync as existsSync68, mkdirSync as mkdirSync29, cpSync as cpSync3 } from "fs";
45212
+ import { spawn as spawn5, spawnSync as spawnSync2 } from "child_process";
45213
+ import { existsSync as existsSync69, mkdirSync as mkdirSync29, cpSync as cpSync3 } from "fs";
44953
45214
  import { fileURLToPath as fileURLToPath8 } from "url";
44954
45215
  import { dirname as dirname38, resolve as resolve17, join as join65 } from "path";
44955
45216
  function findBundledReinfluence() {
@@ -44961,7 +45222,7 @@ function findBundledReinfluence() {
44961
45222
  resolve17(__dirname7, "..", "..", "..", "tools", "reinfluence")
44962
45223
  ];
44963
45224
  for (const c of candidates) {
44964
- if (existsSync68(join65(c, "__main__.py"))) return c;
45225
+ if (existsSync69(join65(c, "__main__.py"))) return c;
44965
45226
  }
44966
45227
  throw new Error(
44967
45228
  "Bundled reinfluence not found. Reinstall dreamcontext or set REINFLUENCE_BIN."
@@ -45003,7 +45264,7 @@ async function bootstrapMarketing(opts = {}) {
45003
45264
  throw new Error("python3 not found on PATH. Install Python 3.10+ and retry.");
45004
45265
  }
45005
45266
  const venv = MARKETING_PATHS.venvDir();
45006
- if (!existsSync68(MARKETING_PATHS.venvPython())) {
45267
+ if (!existsSync69(MARKETING_PATHS.venvPython())) {
45007
45268
  log(`creating venv \u2192 ${venv}`);
45008
45269
  const r2 = runBlocking(py, ["-m", "venv", venv]);
45009
45270
  if (r2.code !== 0) {
@@ -45040,7 +45301,7 @@ ${r.stderr.trim() || r.stdout.trim()}`);
45040
45301
  function primeWhisper(model) {
45041
45302
  return new Promise((resolveP) => {
45042
45303
  const env2 = subprocessEnv();
45043
- const proc = spawn4(MARKETING_PATHS.venvPython(), [
45304
+ const proc = spawn5(MARKETING_PATHS.venvPython(), [
45044
45305
  "-c",
45045
45306
  `import whisper; whisper.load_model(${JSON.stringify(model)})`
45046
45307
  ], {
@@ -45074,7 +45335,7 @@ function subprocessEnv() {
45074
45335
  };
45075
45336
  }
45076
45337
  function isBootstrapped() {
45077
- return existsSync68(MARKETING_PATHS.venvPython()) && existsSync68(join65(MARKETING_PATHS.reinfluenceDir(), "__main__.py"));
45338
+ return existsSync69(MARKETING_PATHS.venvPython()) && existsSync69(join65(MARKETING_PATHS.reinfluenceDir(), "__main__.py"));
45078
45339
  }
45079
45340
  var __filename, __dirname7;
45080
45341
  var init_bootstrap = __esm({
@@ -45151,7 +45412,7 @@ var init_init2 = __esm({
45151
45412
  });
45152
45413
 
45153
45414
  // src/lib/marketing/vision.ts
45154
- import { existsSync as existsSync69, readFileSync as readFileSync50, writeFileSync as writeFileSync35 } from "fs";
45415
+ import { existsSync as existsSync70, readFileSync as readFileSync51, writeFileSync as writeFileSync36 } from "fs";
45155
45416
  import { dirname as dirname39, join as join66 } from "path";
45156
45417
  function pickVisionProvider(env2 = process.env) {
45157
45418
  const oai = env2.OPENAI_VISION_API_KEY;
@@ -45191,11 +45452,11 @@ function parseLabelsFromText(text, allowlist = LABEL_ALLOWLIST) {
45191
45452
  return out;
45192
45453
  }
45193
45454
  async function readImageAsBase64(framePath) {
45194
- const buf = readFileSync50(framePath);
45455
+ const buf = readFileSync51(framePath);
45195
45456
  return buf.toString("base64");
45196
45457
  }
45197
45458
  async function labelHookFrame(framePath, opts) {
45198
- if (!existsSync69(framePath)) return [];
45459
+ if (!existsSync70(framePath)) return [];
45199
45460
  const fetcher = opts.fetcher ?? defaultFetcher;
45200
45461
  const prompt = opts.promptOverride ?? PROMPT;
45201
45462
  const b64 = await readImageAsBase64(framePath);
@@ -45245,7 +45506,7 @@ async function labelHookFrame(framePath, opts) {
45245
45506
  return parseLabelsFromText(text);
45246
45507
  }
45247
45508
  async function runVisionPassOnPost(postJsonPath, opts = {}) {
45248
- const raw = readFileSync50(postJsonPath, "utf-8");
45509
+ const raw = readFileSync51(postJsonPath, "utf-8");
45249
45510
  const post = JSON.parse(raw);
45250
45511
  const shortcode = post.shortcode ?? "?";
45251
45512
  const provider = opts.provider && opts.apiKey ? { provider: opts.provider, apiKey: opts.apiKey } : pickVisionProvider();
@@ -45284,15 +45545,15 @@ async function runVisionPassOnPost(postJsonPath, opts = {}) {
45284
45545
  post.pattern_tags = [...aggregated].sort();
45285
45546
  post.vision_summary = post.pattern_tags.length > 0 ? `Vision-tagged ${framesLabeled}/${hookFrames.length} hook frames; patterns: ${post.pattern_tags.join(", ")}.` : `Vision pass found no allowlisted patterns across ${hookFrames.length} hook frames.`;
45286
45547
  const tmp = postJsonPath + ".tmp";
45287
- writeFileSync35(tmp, JSON.stringify(post, null, 2) + "\n", "utf-8");
45548
+ writeFileSync36(tmp, JSON.stringify(post, null, 2) + "\n", "utf-8");
45288
45549
  const fs = await import("fs");
45289
45550
  fs.renameSync(tmp, postJsonPath);
45290
45551
  const mdPath = join66(dirname39(postJsonPath), `${shortcode}.md`);
45291
- if (existsSync69(mdPath)) {
45552
+ if (existsSync70(mdPath)) {
45292
45553
  try {
45293
- const md = readFileSync50(mdPath, "utf-8");
45554
+ const md = readFileSync51(mdPath, "utf-8");
45294
45555
  const refreshed = updatePatternTagsInBridge(md, post.pattern_tags);
45295
- writeFileSync35(mdPath, refreshed, "utf-8");
45556
+ writeFileSync36(mdPath, refreshed, "utf-8");
45296
45557
  } catch {
45297
45558
  }
45298
45559
  }
@@ -45365,9 +45626,9 @@ Example output: ["talking-head","prop-driven"]`;
45365
45626
  });
45366
45627
 
45367
45628
  // src/lib/marketing/competitors.ts
45368
- import { spawn as spawn5 } from "child_process";
45629
+ import { spawn as spawn6 } from "child_process";
45369
45630
  import { spawnSync as spawnSync3 } from "child_process";
45370
- import { existsSync as existsSync70, mkdirSync as mkdirSync31, statfsSync } from "fs";
45631
+ import { existsSync as existsSync71, mkdirSync as mkdirSync31, statfsSync } from "fs";
45371
45632
  import { dirname as dirname40, join as join67, basename as basename20, extname as extname4 } from "path";
45372
45633
  function which(cmd) {
45373
45634
  const r = spawnSync3(process.platform === "win32" ? "where" : "which", [cmd], { encoding: "utf8" });
@@ -45467,7 +45728,7 @@ ${h.installHints.join("\n")}`);
45467
45728
  let postsIngested = 0;
45468
45729
  try {
45469
45730
  await new Promise((resolveP, rejectP) => {
45470
- const proc = spawn5(MARKETING_PATHS.venvPython(), args, {
45731
+ const proc = spawn6(MARKETING_PATHS.venvPython(), args, {
45471
45732
  env: subprocessEnv(),
45472
45733
  stdio: ["ignore", "pipe", "pipe"]
45473
45734
  });
@@ -45578,7 +45839,7 @@ function persistPost(evt) {
45578
45839
  const bridgePath = join67(postsDir, `${evt.shortcode}.md`);
45579
45840
  writeJsonWithBridge(jsonPath, bridgePath, json, renderPostBridge(json));
45580
45841
  const metaPath = join67(handleDir, "meta.json");
45581
- if (!existsSync70(metaPath)) {
45842
+ if (!existsSync71(metaPath)) {
45582
45843
  writeJsonWithBridge(
45583
45844
  metaPath,
45584
45845
  join67(handleDir, "meta.md"),
@@ -45598,7 +45859,7 @@ First seen: ${(/* @__PURE__ */ new Date()).toISOString()}
45598
45859
  return jsonPath;
45599
45860
  }
45600
45861
  function moveAsset(src, dest) {
45601
- if (!existsSync70(src)) return dest;
45862
+ if (!existsSync71(src)) return dest;
45602
45863
  mkdirSync31(dirname40(dest), { recursive: true });
45603
45864
  const fs = __require("fs");
45604
45865
  try {
@@ -45660,7 +45921,7 @@ var init_competitors = __esm({
45660
45921
  });
45661
45922
 
45662
45923
  // src/cli/commands/marketing/competitor.ts
45663
- import { existsSync as existsSync71, readdirSync as readdirSync16, statSync as statSync11 } from "fs";
45924
+ import { existsSync as existsSync72, readdirSync as readdirSync16, statSync as statSync11 } from "fs";
45664
45925
  import { join as join68 } from "path";
45665
45926
  function registerMarketingCompetitor(parent) {
45666
45927
  const cmd = parent.command("competitor").description("Ingest competitor IG / YouTube content (Reinfluence pipeline).");
@@ -45711,7 +45972,7 @@ function registerMarketingCompetitor(parent) {
45711
45972
  });
45712
45973
  cmd.command("list").description("List ingested competitor handles.").action(() => {
45713
45974
  const dir = MARKETING_PATHS.competitorsDir();
45714
- if (!existsSync71(dir)) {
45975
+ if (!existsSync72(dir)) {
45715
45976
  info("No competitors ingested yet.");
45716
45977
  return;
45717
45978
  }
@@ -45731,7 +45992,7 @@ function registerMarketingCompetitor(parent) {
45731
45992
  console.log(header("Competitors"));
45732
45993
  for (const handle of handles) {
45733
45994
  const postsDir = join68(dir, handle, "posts");
45734
- const postCount = existsSync71(postsDir) ? readdirSync16(postsDir).filter((f) => f.endsWith(".json")).length : 0;
45995
+ const postCount = existsSync72(postsDir) ? readdirSync16(postsDir).filter((f) => f.endsWith(".json")).length : 0;
45735
45996
  console.log(` ${source_default.cyan("@" + handle)} ${source_default.dim(`${postCount} post(s)`)}`);
45736
45997
  }
45737
45998
  });
@@ -45744,11 +46005,11 @@ function registerMarketingCompetitor(parent) {
45744
46005
  }
45745
46006
  info(`Provider: ${provider.provider}`);
45746
46007
  const competitorsDir = MARKETING_PATHS.competitorsDir();
45747
- const handles = opts.handle ? [opts.handle] : existsSync71(competitorsDir) ? readdirSync16(competitorsDir).filter((h) => !h.startsWith("_") && statSync11(join68(competitorsDir, h)).isDirectory()) : [];
46008
+ const handles = opts.handle ? [opts.handle] : existsSync72(competitorsDir) ? readdirSync16(competitorsDir).filter((h) => !h.startsWith("_") && statSync11(join68(competitorsDir, h)).isDirectory()) : [];
45748
46009
  const matches = [];
45749
46010
  for (const h of handles) {
45750
46011
  const candidate = join68(competitorsDir, h, "posts", `${shortcode}.json`);
45751
- if (existsSync71(candidate)) matches.push(candidate);
46012
+ if (existsSync72(candidate)) matches.push(candidate);
45752
46013
  }
45753
46014
  if (matches.length === 0) {
45754
46015
  error(`No post JSON found for shortcode "${shortcode}".`);
@@ -45783,7 +46044,7 @@ function registerMarketingCompetitor(parent) {
45783
46044
  process.exit(1);
45784
46045
  }
45785
46046
  const competitorsDir = MARKETING_PATHS.competitorsDir();
45786
- if (!existsSync71(competitorsDir)) {
46047
+ if (!existsSync72(competitorsDir)) {
45787
46048
  warn("No competitors directory yet \u2014 nothing to relabel.");
45788
46049
  return;
45789
46050
  }
@@ -45792,7 +46053,7 @@ function registerMarketingCompetitor(parent) {
45792
46053
  let skipped = 0;
45793
46054
  for (const h of handles) {
45794
46055
  const postsDir = join68(competitorsDir, h, "posts");
45795
- if (!existsSync71(postsDir)) continue;
46056
+ if (!existsSync72(postsDir)) continue;
45796
46057
  for (const f of readdirSync16(postsDir).filter((n) => n.endsWith(".json"))) {
45797
46058
  const path2 = join68(postsDir, f);
45798
46059
  if (opts.dryRun) {
@@ -45841,9 +46102,9 @@ var init_competitor = __esm({
45841
46102
  });
45842
46103
 
45843
46104
  // src/lib/marketing/meta-fetch.ts
45844
- import { existsSync as existsSync72, mkdirSync as mkdirSync32, readFileSync as readFileSync51, writeFileSync as writeFileSync36, statSync as statSync12, openSync as openSync2, readSync, closeSync as closeSync2 } from "fs";
46105
+ import { existsSync as existsSync73, mkdirSync as mkdirSync32, readFileSync as readFileSync52, writeFileSync as writeFileSync37, statSync as statSync12, openSync as openSync2, readSync, closeSync as closeSync2 } from "fs";
45845
46106
  import { dirname as dirname41, basename as basename21 } from "path";
45846
- import { randomUUID as randomUUID2 } from "crypto";
46107
+ import { randomUUID as randomUUID3 } from "crypto";
45847
46108
  function getQueue(accountId) {
45848
46109
  let q = writeQueues.get(accountId);
45849
46110
  if (!q) {
@@ -45892,9 +46153,9 @@ function idemCachePath(key) {
45892
46153
  }
45893
46154
  function readIdem(key) {
45894
46155
  const p = idemCachePath(key);
45895
- if (!existsSync72(p)) return null;
46156
+ if (!existsSync73(p)) return null;
45896
46157
  try {
45897
- return JSON.parse(readFileSync51(p, "utf8"));
46158
+ return JSON.parse(readFileSync52(p, "utf8"));
45898
46159
  } catch {
45899
46160
  return null;
45900
46161
  }
@@ -45902,7 +46163,7 @@ function readIdem(key) {
45902
46163
  function writeIdem(rec) {
45903
46164
  const p = idemCachePath(rec.key);
45904
46165
  mkdirSync32(dirname41(p), { recursive: true });
45905
- writeFileSync36(p, JSON.stringify(rec, null, 2) + "\n", "utf8");
46166
+ writeFileSync37(p, JSON.stringify(rec, null, 2) + "\n", "utf8");
45906
46167
  }
45907
46168
  function backoffMs(attempt, hintSec) {
45908
46169
  if (hintSec != null && Number.isFinite(hintSec) && hintSec > 0) {
@@ -46017,7 +46278,7 @@ async function metaFetch(ctx, init) {
46017
46278
  }
46018
46279
  let idemKey;
46019
46280
  if (isCreate(init)) {
46020
- idemKey = randomUUID2();
46281
+ idemKey = randomUUID3();
46021
46282
  const cached = readIdem(idemKey);
46022
46283
  if (cached) {
46023
46284
  logLine(ctx, `[idem] cache hit ${idemKey} on ${init.path}`);
@@ -46170,7 +46431,7 @@ async function singleShotVideoUpload(ctx, filepath, fields) {
46170
46431
  if (fields.name) form.set("name", fields.name);
46171
46432
  if (fields.title) form.set("title", fields.title);
46172
46433
  if (fields.description) form.set("description", fields.description);
46173
- const buffer = readFileSync51(filepath);
46434
+ const buffer = readFileSync52(filepath);
46174
46435
  const blob = new Blob([new Uint8Array(buffer)], { type: "video/mp4" });
46175
46436
  form.set("source", blob, basename21(filepath));
46176
46437
  const resp = await fetch(url, {
@@ -46219,7 +46480,7 @@ async function uploadImageFile(ctx, filepath) {
46219
46480
  return withWriteSlot(ctx.adAccountId, async () => {
46220
46481
  const url = buildUrl(ctx, { method: "POST", path: `${ctx.adAccountId}/adimages` });
46221
46482
  const form = new FormData();
46222
- const buffer = readFileSync51(filepath);
46483
+ const buffer = readFileSync52(filepath);
46223
46484
  const blob = new Blob([new Uint8Array(buffer)], { type: "image/png" });
46224
46485
  form.set("filename", blob, basename21(filepath));
46225
46486
  const resp = await fetch(url, {
@@ -46638,7 +46899,7 @@ var init_account = __esm({
46638
46899
  });
46639
46900
 
46640
46901
  // src/lib/marketing/hypothesis.ts
46641
- import { existsSync as existsSync73, readFileSync as readFileSync52 } from "fs";
46902
+ import { existsSync as existsSync74, readFileSync as readFileSync53 } from "fs";
46642
46903
  function validateHypothesis(raw, options2 = {}) {
46643
46904
  const errors = [];
46644
46905
  const fieldErrors = {};
@@ -46705,12 +46966,12 @@ function validateHypothesis(raw, options2 = {}) {
46705
46966
  };
46706
46967
  }
46707
46968
  function loadHypothesisFile(path2, options2 = {}) {
46708
- if (!existsSync73(path2)) {
46969
+ if (!existsSync74(path2)) {
46709
46970
  return { ok: false, errors: [`Hypothesis file not found: ${path2}`] };
46710
46971
  }
46711
46972
  let parsed;
46712
46973
  try {
46713
- parsed = JSON.parse(readFileSync52(path2, "utf8"));
46974
+ parsed = JSON.parse(readFileSync53(path2, "utf8"));
46714
46975
  } catch (e) {
46715
46976
  return { ok: false, errors: [`Failed to parse JSON at ${path2}: ${e.message}`] };
46716
46977
  }
@@ -46898,7 +47159,7 @@ var init_cohort2 = __esm({
46898
47159
  });
46899
47160
 
46900
47161
  // src/lib/marketing/insights-cache.ts
46901
- import { existsSync as existsSync74, readFileSync as readFileSync53, mkdirSync as mkdirSync33, writeFileSync as writeFileSync37, readdirSync as readdirSync17, statSync as statSync13 } from "fs";
47162
+ import { existsSync as existsSync75, readFileSync as readFileSync54, mkdirSync as mkdirSync33, writeFileSync as writeFileSync38, readdirSync as readdirSync17, statSync as statSync13 } from "fs";
46902
47163
  import { join as join69 } from "path";
46903
47164
  import { randomBytes as randomBytes3 } from "crypto";
46904
47165
  function snapshotFilename(entityId, pulledAt) {
@@ -46914,9 +47175,9 @@ function indexPath() {
46914
47175
  }
46915
47176
  function readIndex() {
46916
47177
  const p = indexPath();
46917
- if (!existsSync74(p)) return { latest: {}, updated_at: "1970-01-01T00:00:00Z" };
47178
+ if (!existsSync75(p)) return { latest: {}, updated_at: "1970-01-01T00:00:00Z" };
46918
47179
  try {
46919
- return JSON.parse(readFileSync53(p, "utf8"));
47180
+ return JSON.parse(readFileSync54(p, "utf8"));
46920
47181
  } catch {
46921
47182
  return { latest: {}, updated_at: "1970-01-01T00:00:00Z" };
46922
47183
  }
@@ -46925,7 +47186,7 @@ function writeIndex(idx) {
46925
47186
  const p = indexPath();
46926
47187
  mkdirSync33(MARKETING_PATHS.insightsDir(), { recursive: true });
46927
47188
  const tmp = `${p}.tmp.${process.pid}.${randomBytes3(4).toString("hex")}`;
46928
- writeFileSync37(tmp, JSON.stringify(idx, null, 2) + "\n", "utf8");
47189
+ writeFileSync38(tmp, JSON.stringify(idx, null, 2) + "\n", "utf8");
46929
47190
  __require("fs").renameSync(tmp, p);
46930
47191
  }
46931
47192
  function saveInsightsSnapshot(snap) {
@@ -46933,7 +47194,7 @@ function saveInsightsSnapshot(snap) {
46933
47194
  const filename = snapshotFilename(snap.entity_id, new Date(snap.pulled_at));
46934
47195
  const fullPath = join69(MARKETING_PATHS.insightsDir(), filename);
46935
47196
  const tmp = `${fullPath}.tmp.${process.pid}.${randomBytes3(4).toString("hex")}`;
46936
- writeFileSync37(tmp, JSON.stringify(snap, null, 2) + "\n", "utf8");
47197
+ writeFileSync38(tmp, JSON.stringify(snap, null, 2) + "\n", "utf8");
46937
47198
  __require("fs").renameSync(tmp, fullPath);
46938
47199
  const idx = readIndex();
46939
47200
  idx.latest[snap.entity_id] = filename;
@@ -46946,9 +47207,9 @@ function getCachedInsights(entityId) {
46946
47207
  const filename = idx.latest[entityId];
46947
47208
  if (!filename) return null;
46948
47209
  const fullPath = join69(MARKETING_PATHS.insightsDir(), filename);
46949
- if (!existsSync74(fullPath)) return null;
47210
+ if (!existsSync75(fullPath)) return null;
46950
47211
  try {
46951
- const snap = JSON.parse(readFileSync53(fullPath, "utf8"));
47212
+ const snap = JSON.parse(readFileSync54(fullPath, "utf8"));
46952
47213
  const ageMs = Date.now() - new Date(snap.pulled_at).getTime();
46953
47214
  if (ageMs > INSIGHTS_TTL_MS) return null;
46954
47215
  return snap;
@@ -46961,16 +47222,16 @@ function getLatestSnapshot(entityId) {
46961
47222
  const filename = idx.latest[entityId];
46962
47223
  if (!filename) return null;
46963
47224
  const fullPath = join69(MARKETING_PATHS.insightsDir(), filename);
46964
- if (!existsSync74(fullPath)) return null;
47225
+ if (!existsSync75(fullPath)) return null;
46965
47226
  try {
46966
- return JSON.parse(readFileSync53(fullPath, "utf8"));
47227
+ return JSON.parse(readFileSync54(fullPath, "utf8"));
46967
47228
  } catch {
46968
47229
  return null;
46969
47230
  }
46970
47231
  }
46971
47232
  function getPriorSnapshot(entityId, beforeMs) {
46972
47233
  const dir = MARKETING_PATHS.insightsDir();
46973
- if (!existsSync74(dir)) return null;
47234
+ if (!existsSync75(dir)) return null;
46974
47235
  const safe = entityId.replace(/[^A-Za-z0-9_-]/g, "_");
46975
47236
  const candidates = readdirSync17(dir).filter((f) => f.startsWith(`${safe}__`) && f.endsWith(".json")).map((f) => {
46976
47237
  const p = join69(dir, f);
@@ -46981,7 +47242,7 @@ function getPriorSnapshot(entityId, beforeMs) {
46981
47242
  for (const c of candidates) {
46982
47243
  if (c.mtimeMs <= cutoff) {
46983
47244
  try {
46984
- return JSON.parse(readFileSync53(c.p, "utf8"));
47245
+ return JSON.parse(readFileSync54(c.p, "utf8"));
46985
47246
  } catch {
46986
47247
  continue;
46987
47248
  }
@@ -47617,7 +47878,7 @@ var init_kill = __esm({
47617
47878
  });
47618
47879
 
47619
47880
  // src/cli/commands/marketing/doctor.ts
47620
- import { readFileSync as readFileSync54, readdirSync as readdirSync18, statSync as statSync14 } from "fs";
47881
+ import { readFileSync as readFileSync55, readdirSync as readdirSync18, statSync as statSync14 } from "fs";
47621
47882
  import { join as join70 } from "path";
47622
47883
  function registerMarketingDoctor(parent) {
47623
47884
  parent.command("doctor").description("Run diagnostics: env, FK integrity, retroactive secret scan, Reinfluence health.").option("--scan", "Run retroactive secret scan over the entire _dream_context/ tree", false).action(async (opts) => {
@@ -47699,7 +47960,7 @@ function scanForSecrets(root) {
47699
47960
  for (const file of walkText(root)) {
47700
47961
  let txt;
47701
47962
  try {
47702
- txt = readFileSync54(file, "utf8");
47963
+ txt = readFileSync55(file, "utf8");
47703
47964
  } catch {
47704
47965
  continue;
47705
47966
  }
@@ -47764,7 +48025,7 @@ var init_doctor2 = __esm({
47764
48025
  });
47765
48026
 
47766
48027
  // src/lib/marketing/entity-store.ts
47767
- import { existsSync as existsSync76, readFileSync as readFileSync55, readdirSync as readdirSync19 } from "fs";
48028
+ import { existsSync as existsSync77, readFileSync as readFileSync56, readdirSync as readdirSync19 } from "fs";
47768
48029
  import { join as join71 } from "path";
47769
48030
  function dirFor(kind) {
47770
48031
  switch (kind) {
@@ -47788,20 +48049,20 @@ function entityPaths(kind, id) {
47788
48049
  }
47789
48050
  function loadEntity(kind, id) {
47790
48051
  const { json } = entityPaths(kind, id);
47791
- if (!existsSync76(json)) return null;
48052
+ if (!existsSync77(json)) return null;
47792
48053
  try {
47793
- return JSON.parse(readFileSync55(json, "utf8"));
48054
+ return JSON.parse(readFileSync56(json, "utf8"));
47794
48055
  } catch {
47795
48056
  return null;
47796
48057
  }
47797
48058
  }
47798
48059
  function listEntities(kind) {
47799
48060
  const d = dirFor(kind);
47800
- if (!existsSync76(d)) return [];
48061
+ if (!existsSync77(d)) return [];
47801
48062
  const out = [];
47802
48063
  for (const f of readdirSync19(d).filter((x) => x.endsWith(".json"))) {
47803
48064
  try {
47804
- out.push(JSON.parse(readFileSync55(join71(d, f), "utf8")));
48065
+ out.push(JSON.parse(readFileSync56(join71(d, f), "utf8")));
47805
48066
  } catch {
47806
48067
  }
47807
48068
  }
@@ -47995,7 +48256,7 @@ var init_campaign = __esm({
47995
48256
  });
47996
48257
 
47997
48258
  // src/cli/commands/marketing/adset.ts
47998
- import { existsSync as existsSync77, readFileSync as readFileSync56 } from "fs";
48259
+ import { existsSync as existsSync78, readFileSync as readFileSync57 } from "fs";
47999
48260
  function registerMarketingAdSet(parent) {
48000
48261
  const cmd = parent.command("adset").description("Manage adsets.");
48001
48262
  cmd.command("create").description("Create an adset (PAUSED). --daily-budget required (no fallback).").requiredOption("--campaign <id>", "parent campaign local id").requiredOption("--name <name>", "adset name").requiredOption("--daily-budget <amount>", "daily budget (major-currency units)").requiredOption("--targeting <file>", "JSON file with Meta targeting spec").option("--currency <code>", "currency code", "TRY").option("--optimization-goal <goal>", "OFFSITE_CONVERSIONS|LINK_CLICKS|...", "OFFSITE_CONVERSIONS").option("--billing-event <event>", "IMPRESSIONS|LINK_CLICKS|THRUPLAY", "IMPRESSIONS").option("--custom-event-type <evt>", "e.g. PURCHASE, COMPLETE_REGISTRATION (for OFFSITE_CONVERSIONS)").option("--no-dry-run", "Actually create on Meta").action(async (opts) => {
@@ -48015,13 +48276,13 @@ function registerMarketingAdSet(parent) {
48015
48276
  }
48016
48277
  throw e;
48017
48278
  }
48018
- if (!existsSync77(opts.targeting)) {
48279
+ if (!existsSync78(opts.targeting)) {
48019
48280
  error(`Targeting file not found: ${opts.targeting}`);
48020
48281
  process.exit(1);
48021
48282
  }
48022
48283
  let targeting;
48023
48284
  try {
48024
- targeting = JSON.parse(readFileSync56(opts.targeting, "utf8"));
48285
+ targeting = JSON.parse(readFileSync57(opts.targeting, "utf8"));
48025
48286
  } catch (e) {
48026
48287
  error(`Failed to parse targeting JSON: ${e.message}`);
48027
48288
  process.exit(1);
@@ -48278,12 +48539,12 @@ var init_creative = __esm({
48278
48539
  });
48279
48540
 
48280
48541
  // src/cli/commands/marketing/asset.ts
48281
- import { existsSync as existsSync78, statSync as statSync15 } from "fs";
48542
+ import { existsSync as existsSync79, statSync as statSync15 } from "fs";
48282
48543
  import { extname as extname5 } from "path";
48283
48544
  function registerMarketingAsset(parent) {
48284
48545
  const cmd = parent.command("asset").description("Upload creative assets to Meta.");
48285
48546
  cmd.command("upload <path>").description("Upload a video (>50MB \u2192 chunked) or image to Meta. Returns id/hash.").option("--type <type>", "override auto-detection (video|image)").option("--name <name>", "asset name (videos)").option("--no-dry-run", "Actually upload to Meta").action(async (path2, opts) => {
48286
- if (!existsSync78(path2)) {
48547
+ if (!existsSync79(path2)) {
48287
48548
  error(`File not found: ${path2}`);
48288
48549
  process.exit(1);
48289
48550
  }
@@ -48451,7 +48712,7 @@ var init_ad = __esm({
48451
48712
  });
48452
48713
 
48453
48714
  // src/lib/marketing/launch.ts
48454
- import { existsSync as existsSync79, readFileSync as readFileSync57, writeFileSync as writeFileSync38, mkdirSync as mkdirSync34, renameSync as renameSync8, readdirSync as readdirSync20 } from "fs";
48715
+ import { existsSync as existsSync80, readFileSync as readFileSync58, writeFileSync as writeFileSync39, mkdirSync as mkdirSync34, renameSync as renameSync8, readdirSync as readdirSync20 } from "fs";
48455
48716
  import { dirname as dirname42, join as join72, basename as basename22 } from "path";
48456
48717
  import { randomBytes as randomBytes4 } from "crypto";
48457
48718
  function buildLaunchSummary(cohortId) {
@@ -48498,13 +48759,13 @@ function isoTs2() {
48498
48759
  function atomicWriteFile3(path2, data) {
48499
48760
  mkdirSync34(dirname42(path2), { recursive: true });
48500
48761
  const tmp = `${path2}.tmp.${process.pid}.${randomBytes4(4).toString("hex")}`;
48501
- writeFileSync38(tmp, data, "utf8");
48762
+ writeFileSync39(tmp, data, "utf8");
48502
48763
  renameSync8(tmp, path2);
48503
48764
  }
48504
48765
  function readWal(path2) {
48505
- if (!existsSync79(path2)) return null;
48766
+ if (!existsSync80(path2)) return null;
48506
48767
  try {
48507
- return JSON.parse(readFileSync57(path2, "utf8"));
48768
+ return JSON.parse(readFileSync58(path2, "utf8"));
48508
48769
  } catch {
48509
48770
  return null;
48510
48771
  }
@@ -48514,7 +48775,7 @@ function writeWal(path2, wal) {
48514
48775
  }
48515
48776
  function findWalByRunId(runId) {
48516
48777
  const dir = MARKETING_PATHS.runsDir();
48517
- if (!existsSync79(dir)) return null;
48778
+ if (!existsSync80(dir)) return null;
48518
48779
  for (const f of readdirSync20(dir)) {
48519
48780
  if (!f.endsWith(".json")) continue;
48520
48781
  if (f.startsWith("by-idem")) continue;
@@ -48791,7 +49052,7 @@ var init_launch2 = __esm({
48791
49052
  });
48792
49053
 
48793
49054
  // src/cli/commands/marketing/learnings.ts
48794
- import { existsSync as existsSync80, readFileSync as readFileSync58 } from "fs";
49055
+ import { existsSync as existsSync81, readFileSync as readFileSync59 } from "fs";
48795
49056
  function registerMarketingLearnings(parent) {
48796
49057
  const cmd = parent.command("learnings").description("Performance Monitor learnings ledger (per-day .md + index).");
48797
49058
  cmd.command("show").description("Show today's (or specified day's) learnings file.").option("--date <YYYY-MM-DD>", "Day to show (default: today UTC)").option("--id <id>", "Show a single entry by id").action((opts) => {
@@ -48934,8 +49195,8 @@ async function resolveBody(body, bodyFile) {
48934
49195
  if (body) return body;
48935
49196
  if (bodyFile === "-") return readStdin3();
48936
49197
  if (bodyFile) {
48937
- if (!existsSync80(bodyFile)) throw new Error(`Body file not found: ${bodyFile}`);
48938
- return readFileSync58(bodyFile, "utf8");
49198
+ if (!existsSync81(bodyFile)) throw new Error(`Body file not found: ${bodyFile}`);
49199
+ return readFileSync59(bodyFile, "utf8");
48939
49200
  }
48940
49201
  return null;
48941
49202
  }
@@ -48965,10 +49226,10 @@ var init_learnings2 = __esm({
48965
49226
 
48966
49227
  // src/lib/marketing/rem-sleep.ts
48967
49228
  import {
48968
- existsSync as existsSync81,
49229
+ existsSync as existsSync82,
48969
49230
  mkdirSync as mkdirSync35,
48970
- readFileSync as readFileSync59,
48971
- writeFileSync as writeFileSync39,
49231
+ readFileSync as readFileSync60,
49232
+ writeFileSync as writeFileSync40,
48972
49233
  readdirSync as readdirSync21,
48973
49234
  statSync as statSync16,
48974
49235
  unlinkSync as unlinkSync3,
@@ -48979,13 +49240,13 @@ import { randomBytes as randomBytes5 } from "crypto";
48979
49240
  function atomicWriteFile4(path2, data) {
48980
49241
  mkdirSync35(dirname43(path2), { recursive: true });
48981
49242
  const tmp = `${path2}.tmp.${process.pid}.${randomBytes5(4).toString("hex")}`;
48982
- writeFileSync39(tmp, data, "utf8");
49243
+ writeFileSync40(tmp, data, "utf8");
48983
49244
  renameSync9(tmp, path2);
48984
49245
  }
48985
49246
  function pruneRuns(opts = {}) {
48986
49247
  const keepLast = opts.keepLast ?? 100;
48987
49248
  const dir = MARKETING_PATHS.runsDir();
48988
- if (!existsSync81(dir)) return { scanned: 0, kept: 0, deleted: 0, deletedFiles: [] };
49249
+ if (!existsSync82(dir)) return { scanned: 0, kept: 0, deleted: 0, deletedFiles: [] };
48989
49250
  const files = readdirSync21(dir).filter((f) => f.endsWith(".json")).map((f) => {
48990
49251
  const p = join73(dir, f);
48991
49252
  try {
@@ -49021,7 +49282,7 @@ function compactInsights(opts = {}) {
49021
49282
  const weeklyAfterDays = opts.weeklyAfterDays ?? 14;
49022
49283
  const now = opts.now ?? /* @__PURE__ */ new Date();
49023
49284
  const dir = MARKETING_PATHS.insightsDir();
49024
- if (!existsSync81(dir)) return { scanned: 0, kept: 0, deleted: 0, deletedFiles: [] };
49285
+ if (!existsSync82(dir)) return { scanned: 0, kept: 0, deleted: 0, deletedFiles: [] };
49025
49286
  const files = [];
49026
49287
  for (const f of readdirSync21(dir)) {
49027
49288
  if (!f.endsWith(".json") || f.startsWith("_")) continue;
@@ -49093,7 +49354,7 @@ function mergeDailyLearnings(opts = {}) {
49093
49354
  const retainDays = opts.retainDays ?? 7;
49094
49355
  const now = opts.now ?? /* @__PURE__ */ new Date();
49095
49356
  const dir = MARKETING_PATHS.learningsDir();
49096
- if (!existsSync81(dir)) {
49357
+ if (!existsSync82(dir)) {
49097
49358
  return { scanned: 0, merged: 0, archivePath: null, droppedRejected: 0, mergedFiles: [] };
49098
49359
  }
49099
49360
  const dayMs = 24 * 60 * 60 * 1e3;
@@ -49121,7 +49382,7 @@ function mergeDailyLearnings(opts = {}) {
49121
49382
  const archivePath = join73(dir, `_archive-${q}.md`);
49122
49383
  list.sort((a, b) => a.date.localeCompare(b.date));
49123
49384
  for (const c of list) {
49124
- const existingArchive = existsSync81(archivePath) ? readFileSync59(archivePath, "utf8") : `# Marketing learnings archive \u2014 ${q}
49385
+ const existingArchive = existsSync82(archivePath) ? readFileSync60(archivePath, "utf8") : `# Marketing learnings archive \u2014 ${q}
49125
49386
  `;
49126
49387
  const dateMarker = `# Marketing learnings \u2014 ${c.date}`;
49127
49388
  const alreadyMerged = existingArchive.includes(dateMarker);
@@ -49130,7 +49391,7 @@ function mergeDailyLearnings(opts = {}) {
49130
49391
  continue;
49131
49392
  }
49132
49393
  if (!alreadyMerged) {
49133
- const body = readFileSync59(c.p, "utf8").trimEnd();
49394
+ const body = readFileSync60(c.p, "utf8").trimEnd();
49134
49395
  const next2 = existingArchive.trimEnd() + "\n\n" + body + "\n";
49135
49396
  atomicWriteFile4(archivePath, next2);
49136
49397
  }
@@ -49173,14 +49434,14 @@ function quarterKey(yyyymmdd) {
49173
49434
  }
49174
49435
  function redactRunsSweep(opts = {}) {
49175
49436
  const dir = MARKETING_PATHS.runsDir();
49176
- if (!existsSync81(dir)) return { scanned: 0, rewritten: 0, rewrittenFiles: [] };
49437
+ if (!existsSync82(dir)) return { scanned: 0, rewritten: 0, rewrittenFiles: [] };
49177
49438
  const files = readdirSync21(dir).filter((f) => f.endsWith(".json"));
49178
49439
  const rewrittenFiles = [];
49179
49440
  for (const f of files) {
49180
49441
  const p = join73(dir, f);
49181
49442
  let raw;
49182
49443
  try {
49183
- raw = readFileSync59(p, "utf8");
49444
+ raw = readFileSync60(p, "utf8");
49184
49445
  } catch {
49185
49446
  continue;
49186
49447
  }
@@ -49202,7 +49463,7 @@ function redactRunsSweep(opts = {}) {
49202
49463
  function runRemSleep(opts = {}) {
49203
49464
  const ranAt = (opts.now ?? /* @__PURE__ */ new Date()).toISOString();
49204
49465
  const root = marketingRootIfExists();
49205
- if (!root || !existsSync81(root)) {
49466
+ if (!root || !existsSync82(root)) {
49206
49467
  return {
49207
49468
  ranAt,
49208
49469
  marketingPresent: false,
@@ -49321,7 +49582,7 @@ var init_git_guard = __esm({
49321
49582
  });
49322
49583
 
49323
49584
  // src/cli/commands/marketing/hooks.ts
49324
- import { existsSync as existsSync82, readFileSync as readFileSync60, writeFileSync as writeFileSync40, chmodSync as chmodSync3, mkdirSync as mkdirSync36, statSync as statSync17 } from "fs";
49585
+ import { existsSync as existsSync83, readFileSync as readFileSync61, writeFileSync as writeFileSync41, chmodSync as chmodSync3, mkdirSync as mkdirSync36, statSync as statSync17 } from "fs";
49325
49586
  import { execFileSync as execFileSync6 } from "child_process";
49326
49587
  import { join as join74 } from "path";
49327
49588
  function findGitDir(cwd = process.cwd()) {
@@ -49366,8 +49627,8 @@ function registerMarketingHooks(parent) {
49366
49627
  const hooksDir = join74(gitDir, "hooks");
49367
49628
  mkdirSync36(hooksDir, { recursive: true });
49368
49629
  const target = join74(hooksDir, "pre-commit");
49369
- if (existsSync82(target)) {
49370
- const existing = readFileSync60(target, "utf-8");
49630
+ if (existsSync83(target)) {
49631
+ const existing = readFileSync61(target, "utf-8");
49371
49632
  if (existing.includes(MANAGED_MARKER)) {
49372
49633
  info("pre-commit hook already managed by dreamcontext \u2014 refreshing.");
49373
49634
  } else if (!opts.force) {
@@ -49379,7 +49640,7 @@ function registerMarketingHooks(parent) {
49379
49640
  warn("Overwriting existing pre-commit hook (--force).");
49380
49641
  }
49381
49642
  }
49382
- writeFileSync40(target, HOOK_LAUNCHER, "utf-8");
49643
+ writeFileSync41(target, HOOK_LAUNCHER, "utf-8");
49383
49644
  try {
49384
49645
  chmodSync3(target, 493);
49385
49646
  } catch {
@@ -49418,7 +49679,7 @@ exec dreamcontext mk hooks check-staged
49418
49679
  });
49419
49680
 
49420
49681
  // src/lib/marketing/council-personas.ts
49421
- import { existsSync as existsSync83, readFileSync as readFileSync61, readdirSync as readdirSync22 } from "fs";
49682
+ import { existsSync as existsSync84, readFileSync as readFileSync62, readdirSync as readdirSync22 } from "fs";
49422
49683
  import { fileURLToPath as fileURLToPath9 } from "url";
49423
49684
  import { join as join75, dirname as dirname44 } from "path";
49424
49685
  function findPersonasDir() {
@@ -49432,12 +49693,12 @@ function findPersonasDir() {
49432
49693
  join75(__dirname_local, "..", "..", PERSONA_SUBPATH)
49433
49694
  ];
49434
49695
  for (const candidate of candidates) {
49435
- if (existsSync83(candidate)) return candidate;
49696
+ if (existsSync84(candidate)) return candidate;
49436
49697
  }
49437
49698
  return null;
49438
49699
  }
49439
49700
  function parsePersonaFile(filePath) {
49440
- const raw = readFileSync61(filePath, "utf-8");
49701
+ const raw = readFileSync62(filePath, "utf-8");
49441
49702
  const parsed = (0, import_gray_matter5.default)(raw);
49442
49703
  const data = parsed.data;
49443
49704
  const slug = typeof data.slug === "string" ? data.slug.trim() : "";
@@ -49457,7 +49718,7 @@ function parsePersonaFile(filePath) {
49457
49718
  }
49458
49719
  function loadAllPersonas(personasDir) {
49459
49720
  const dir = personasDir ?? findPersonasDir();
49460
- if (!dir || !existsSync83(dir)) return [];
49721
+ if (!dir || !existsSync84(dir)) return [];
49461
49722
  const files = readdirSync22(dir).filter((n) => n.endsWith(".md")).sort();
49462
49723
  return files.map((name) => parsePersonaFile(join75(dir, name)));
49463
49724
  }
@@ -49490,11 +49751,11 @@ var init_council_personas = __esm({
49490
49751
 
49491
49752
  // src/cli/commands/marketing/council.ts
49492
49753
  import { spawnSync as spawnSync4 } from "child_process";
49493
- import { existsSync as existsSync84 } from "fs";
49754
+ import { existsSync as existsSync85 } from "fs";
49494
49755
  function resolveDreamcontextEntry() {
49495
49756
  const node = process.argv[0];
49496
49757
  const script = process.argv[1];
49497
- if (script && existsSync84(script)) {
49758
+ if (script && existsSync85(script)) {
49498
49759
  return { node, script };
49499
49760
  }
49500
49761
  return { node, script: null };
@@ -49666,7 +49927,7 @@ var init_marketing = __esm({
49666
49927
  });
49667
49928
 
49668
49929
  // src/cli/commands/memory.ts
49669
- import { existsSync as existsSync85, unlinkSync as unlinkSync4 } from "fs";
49930
+ import { existsSync as existsSync86, unlinkSync as unlinkSync4 } from "fs";
49670
49931
  import { join as join76, dirname as dirname45 } from "path";
49671
49932
  function collectVault(value, previous) {
49672
49933
  return [...previous, value];
@@ -49851,7 +50112,7 @@ function registerMemoryCommand(program2) {
49851
50112
  async (slug, opts) => {
49852
50113
  const root = ensureContextRoot();
49853
50114
  const filePath = join76(root, "knowledge", `${slug}.md`);
49854
- if (!existsSync85(filePath)) {
50115
+ if (!existsSync86(filePath)) {
49855
50116
  error(`Knowledge file not found: ${slug}.md`);
49856
50117
  return;
49857
50118
  }
@@ -49899,7 +50160,7 @@ ${opts.append}
49899
50160
  memory.command("delete").argument("<slug>", "Knowledge file slug to delete (without .md)").option("-f, --force", "Skip confirmation prompt").description("Delete a knowledge file (irreversible; use git to recover)").action(async (slug, opts) => {
49900
50161
  const root = ensureContextRoot();
49901
50162
  const filePath = join76(root, "knowledge", `${slug}.md`);
49902
- if (!existsSync85(filePath)) {
50163
+ if (!existsSync86(filePath)) {
49903
50164
  error(`Knowledge file not found: ${slug}.md`);
49904
50165
  return;
49905
50166
  }
@@ -50420,17 +50681,17 @@ var init_connections3 = __esm({
50420
50681
  });
50421
50682
 
50422
50683
  // src/lib/federation-ingest.ts
50423
- import { existsSync as existsSync86, mkdirSync as mkdirSync37 } from "fs";
50684
+ import { existsSync as existsSync87, mkdirSync as mkdirSync37 } from "fs";
50424
50685
  import { join as join77 } from "path";
50425
50686
  function ingestEntry(contextRoot, entry) {
50426
50687
  const knowledgeDir = join77(contextRoot, "knowledge");
50427
50688
  mkdirSync37(knowledgeDir, { recursive: true });
50428
50689
  const baseSlug = slugFromTitle(entry.title);
50429
50690
  const canonicalPath = join77(knowledgeDir, `${baseSlug}.md`);
50430
- const collided = existsSync86(canonicalPath);
50691
+ const collided = existsSync87(canonicalPath);
50431
50692
  const slug = collided ? `${baseSlug}--from-${sanitizeVault(entry.origin.vault)}` : baseSlug;
50432
50693
  const targetPath = join77(knowledgeDir, `${slug}.md`);
50433
- if (!existsSync86(targetPath)) {
50694
+ if (!existsSync87(targetPath)) {
50434
50695
  writeFrontmatter(
50435
50696
  targetPath,
50436
50697
  {
@@ -50722,7 +50983,7 @@ var init_people = __esm({
50722
50983
 
50723
50984
  // src/cli/commands/config.ts
50724
50985
  import { dirname as dirname49 } from "path";
50725
- import { existsSync as existsSync87, readFileSync as readFileSync63, writeFileSync as writeFileSync42 } from "fs";
50986
+ import { existsSync as existsSync88, readFileSync as readFileSync64, writeFileSync as writeFileSync43 } from "fs";
50726
50987
  import { join as join78 } from "path";
50727
50988
  function resolveProjectRoot() {
50728
50989
  const contextRoot = resolveContextRoot();
@@ -50984,12 +51245,12 @@ function registerConfigCommand(program2) {
50984
51245
  let userMdSynced = false;
50985
51246
  if (contextRoot) {
50986
51247
  const userMdPath = join78(contextRoot, "core", "1.user.md");
50987
- if (existsSync87(userMdPath)) {
51248
+ if (existsSync88(userMdPath)) {
50988
51249
  try {
50989
- const before = readFileSync63(userMdPath, "utf-8");
51250
+ const before = readFileSync64(userMdPath, "utf-8");
50990
51251
  const after = ensurePeopleSection(before, roster);
50991
51252
  if (after !== before) {
50992
- writeFileSync42(userMdPath, after, "utf-8");
51253
+ writeFileSync43(userMdPath, after, "utf-8");
50993
51254
  userMdSynced = true;
50994
51255
  }
50995
51256
  } catch (err) {
@@ -51074,8 +51335,8 @@ function registerConfigCommand(program2) {
51074
51335
  if (!value) {
51075
51336
  if (!process.stdin.isTTY) {
51076
51337
  try {
51077
- const { readFileSync: readFileSync64 } = await import("fs");
51078
- value = readFileSync64(0, "utf-8").trim();
51338
+ const { readFileSync: readFileSync65 } = await import("fs");
51339
+ value = readFileSync65(0, "utf-8").trim();
51079
51340
  } catch {
51080
51341
  value = "";
51081
51342
  }