dreamcontext 0.8.0 → 0.8.2
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.
- package/dist/dashboard/assets/{BrainCanvas3D-BZyWrW3J.js → BrainCanvas3D-CNDjMlun.js} +1 -1
- package/dist/dashboard/assets/{_baseUniq-C55dCpzj.js → _baseUniq-DtoPVYjz.js} +1 -1
- package/dist/dashboard/assets/{ar-SA-G6X2FPQ2-BTWWh58_.js → ar-SA-G6X2FPQ2-D_dXe_8i.js} +1 -1
- package/dist/dashboard/assets/{arc-BhcvtD7_.js → arc-8LFYH4lG.js} +1 -1
- package/dist/dashboard/assets/{architectureDiagram-Q4EWVU46-BlVAz3vP.js → architectureDiagram-Q4EWVU46-BIgEpM4v.js} +1 -1
- package/dist/dashboard/assets/{az-AZ-76LH7QW2-DEPuxlle.js → az-AZ-76LH7QW2-C30ZBwgT.js} +1 -1
- package/dist/dashboard/assets/{bg-BG-XCXSNQG7-CdwdScdW.js → bg-BG-XCXSNQG7-D0R9pSdG.js} +1 -1
- package/dist/dashboard/assets/{blockDiagram-DXYQGD6D-CAzEduT-.js → blockDiagram-DXYQGD6D-DRTa0DpJ.js} +1 -1
- package/dist/dashboard/assets/{bn-BD-2XOGV67Q-Cx2p_HrL.js → bn-BD-2XOGV67Q-vkWxteG3.js} +1 -1
- package/dist/dashboard/assets/{c4Diagram-AHTNJAMY-C_5GcHxG.js → c4Diagram-AHTNJAMY-Do_gB8Cs.js} +1 -1
- package/dist/dashboard/assets/{ca-ES-6MX7JW3Y-BLVJKLW3.js → ca-ES-6MX7JW3Y-CTyxGdzW.js} +1 -1
- package/dist/dashboard/assets/channel-C5p1t-nJ.js +1 -0
- package/dist/dashboard/assets/{chunk-4BX2VUAB-DYYyKwKp.js → chunk-4BX2VUAB-DJlttKoY.js} +1 -1
- package/dist/dashboard/assets/{chunk-4TB4RGXK-B9ZDNs0v.js → chunk-4TB4RGXK-BdixZX4J.js} +1 -1
- package/dist/dashboard/assets/{chunk-55IACEB6-0chbuP2q.js → chunk-55IACEB6-CPhKaTLr.js} +1 -1
- package/dist/dashboard/assets/{chunk-EDXVE4YY-BM3tX5V3.js → chunk-EDXVE4YY-Bv0bQVvi.js} +1 -1
- package/dist/dashboard/assets/{chunk-FMBD7UC4-D7fWQyLU.js → chunk-FMBD7UC4-DGjRdLDd.js} +1 -1
- package/dist/dashboard/assets/{chunk-OYMX7WX6-DRSMwRfw.js → chunk-OYMX7WX6-B-wzkRri.js} +1 -1
- package/dist/dashboard/assets/{chunk-QZHKN3VN-BkySqi6f.js → chunk-QZHKN3VN-BwK1NqpV.js} +1 -1
- package/dist/dashboard/assets/{chunk-YZCP3GAM-DWxX_bg1.js → chunk-YZCP3GAM-DjEwJGlh.js} +1 -1
- package/dist/dashboard/assets/classDiagram-6PBFFD2Q-sTJpbWV4.js +1 -0
- package/dist/dashboard/assets/classDiagram-v2-HSJHXN6E-sTJpbWV4.js +1 -0
- package/dist/dashboard/assets/clone-DTslXBzp.js +1 -0
- package/dist/dashboard/assets/core-Cn4yfEqx.js +1 -0
- package/dist/dashboard/assets/{cose-bilkent-S5V4N54A-CK3SaOdF.js → cose-bilkent-S5V4N54A-BJXUn11L.js} +1 -1
- package/dist/dashboard/assets/{cs-CZ-2BRQDIVT-2wFJFdY3.js → cs-CZ-2BRQDIVT-BjRikaNe.js} +1 -1
- package/dist/dashboard/assets/{da-DK-5WZEPLOC-PZ4S5fLH.js → da-DK-5WZEPLOC-Cn3GTxbV.js} +1 -1
- package/dist/dashboard/assets/{dagre-KV5264BT-C_O4CkRN.js → dagre-KV5264BT-BHn2c24z.js} +1 -1
- package/dist/dashboard/assets/{de-DE-XR44H4JA-COgQyNpE.js → de-DE-XR44H4JA-IvGsdpTt.js} +1 -1
- package/dist/dashboard/assets/{diagram-5BDNPKRD-CY7cwksh.js → diagram-5BDNPKRD-YrlF3B5a.js} +1 -1
- package/dist/dashboard/assets/{diagram-G4DWMVQ6-BBaegF2E.js → diagram-G4DWMVQ6-DHONF1OD.js} +1 -1
- package/dist/dashboard/assets/{diagram-MMDJMWI5-Dtp-QpeD.js → diagram-MMDJMWI5-B1vJLt5b.js} +1 -1
- package/dist/dashboard/assets/{diagram-TYMM5635-h-YHhXz4.js → diagram-TYMM5635-C8P5-4A3.js} +1 -1
- package/dist/dashboard/assets/{el-GR-BZB4AONW-DzTJgcWa.js → el-GR-BZB4AONW-B9GA8_lO.js} +1 -1
- package/dist/dashboard/assets/{erDiagram-SMLLAGMA-C8WadTdS.js → erDiagram-SMLLAGMA-CjWWTCWe.js} +1 -1
- package/dist/dashboard/assets/{es-ES-U4NZUMDT-BMzFbvDd.js → es-ES-U4NZUMDT-Ct1wP_9r.js} +1 -1
- package/dist/dashboard/assets/{eu-ES-A7QVB2H4-CnpRhfeI.js → eu-ES-A7QVB2H4-C-49gWlR.js} +1 -1
- package/dist/dashboard/assets/{fa-IR-HGAKTJCU-DJozguNj.js → fa-IR-HGAKTJCU-DUo8t-xv.js} +1 -1
- package/dist/dashboard/assets/{fi-FI-Z5N7JZ37-4vlr1zEE.js → fi-FI-Z5N7JZ37-DCObnr3i.js} +1 -1
- package/dist/dashboard/assets/{flowDiagram-DWJPFMVM-BDU_Bd0P.js → flowDiagram-DWJPFMVM-OQ_IRMqG.js} +1 -1
- package/dist/dashboard/assets/{fr-FR-RHASNOE6-BIMGBozN.js → fr-FR-RHASNOE6-0EGg3zhN.js} +1 -1
- package/dist/dashboard/assets/{ganttDiagram-T4ZO3ILL-DI9axi76.js → ganttDiagram-T4ZO3ILL-DPTSBcnu.js} +1 -1
- package/dist/dashboard/assets/{gitGraphDiagram-UUTBAWPF-BuhQ28fO.js → gitGraphDiagram-UUTBAWPF-BxfeiCqm.js} +1 -1
- package/dist/dashboard/assets/{gl-ES-HMX3MZ6V-C5wE26uu.js → gl-ES-HMX3MZ6V-WtVwXY6x.js} +1 -1
- package/dist/dashboard/assets/{graph-Djm-nnL-.js → graph-Du_3_o8q.js} +1 -1
- package/dist/dashboard/assets/{he-IL-6SHJWFNN-B0U2BY4u.js → he-IL-6SHJWFNN-CfgspIku.js} +1 -1
- package/dist/dashboard/assets/{hi-IN-IWLTKZ5I-Ddqmbdc3.js → hi-IN-IWLTKZ5I-CS9l2g3B.js} +1 -1
- package/dist/dashboard/assets/{hu-HU-A5ZG7DT2-Bql7W1FB.js → hu-HU-A5ZG7DT2-BQ46AerM.js} +1 -1
- package/dist/dashboard/assets/{id-ID-SAP4L64H-BgPUuH6X.js → id-ID-SAP4L64H-BeShJyKQ.js} +1 -1
- package/dist/dashboard/assets/{index-DpzkIBIK.js → index-BK87l45R.js} +1 -1
- package/dist/dashboard/assets/index-C9VT2u9E.js +480 -0
- package/dist/dashboard/assets/index-D-gsCv2F.js +1 -0
- package/dist/dashboard/assets/{index-DMgrVZGf.js → index-D7dWmypK.js} +1 -1
- package/dist/dashboard/assets/index-DoFaQKCx.css +1 -0
- package/dist/dashboard/assets/{infoDiagram-42DDH7IO-FlC8UXlC.js → infoDiagram-42DDH7IO-CcFhyaQp.js} +1 -1
- package/dist/dashboard/assets/{ishikawaDiagram-UXIWVN3A-CM7RkOdA.js → ishikawaDiagram-UXIWVN3A-9QJeD00p.js} +1 -1
- package/dist/dashboard/assets/{it-IT-JPQ66NNP-B8JStDkT.js → it-IT-JPQ66NNP-csyvfk0t.js} +1 -1
- package/dist/dashboard/assets/{ja-JP-DBVTYXUO-CjqVt-yD.js → ja-JP-DBVTYXUO-DctpJ2yz.js} +1 -1
- package/dist/dashboard/assets/{journeyDiagram-VCZTEJTY-CmXt_usI.js → journeyDiagram-VCZTEJTY-CU4EYedt.js} +1 -1
- package/dist/dashboard/assets/{kaa-6HZHGXH3-qlfTF570.js → kaa-6HZHGXH3-D0tWzHt3.js} +1 -1
- package/dist/dashboard/assets/{kab-KAB-ZGHBKWFO-B1jcf86v.js → kab-KAB-ZGHBKWFO-BC-g4xJU.js} +1 -1
- package/dist/dashboard/assets/{kanban-definition-6JOO6SKY-DfUTCwbu.js → kanban-definition-6JOO6SKY-BxXqVmz1.js} +1 -1
- package/dist/dashboard/assets/{kk-KZ-P5N5QNE5-CDGZZuGX.js → kk-KZ-P5N5QNE5-TLB3Lxri.js} +1 -1
- package/dist/dashboard/assets/{km-KH-HSX4SM5Z-VJhAICPS.js → km-KH-HSX4SM5Z-DCh7cRAS.js} +1 -1
- package/dist/dashboard/assets/{ko-KR-MTYHY66A-DTsCW-6Q.js → ko-KR-MTYHY66A-BPIl5ido.js} +1 -1
- package/dist/dashboard/assets/{ku-TR-6OUDTVRD-B7sBU8-V.js → ku-TR-6OUDTVRD-TUpeN1Tm.js} +1 -1
- package/dist/dashboard/assets/{layout-LL6b15MZ.js → layout-CyrgfqIp.js} +1 -1
- package/dist/dashboard/assets/{linear-th65CRN7.js → linear-B6cMUkoc.js} +1 -1
- package/dist/dashboard/assets/{lt-LT-XHIRWOB4-DLwGTeYc.js → lt-LT-XHIRWOB4-BRKyR_Xw.js} +1 -1
- package/dist/dashboard/assets/{lv-LV-5QDEKY6T-Df5ujP3N.js → lv-LV-5QDEKY6T-BANbTe4s.js} +1 -1
- package/dist/dashboard/assets/{min-C1cE6N2D.js → min-lcwVZhZ7.js} +1 -1
- package/dist/dashboard/assets/{mindmap-definition-QFDTVHPH-n-x0bf17.js → mindmap-definition-QFDTVHPH-fVIbdlXp.js} +1 -1
- package/dist/dashboard/assets/{mr-IN-CRQNXWMA-B0504Lxj.js → mr-IN-CRQNXWMA-DLFutdXk.js} +1 -1
- package/dist/dashboard/assets/{my-MM-5M5IBNSE-CTTz1o7j.js → my-MM-5M5IBNSE-CGWrcNBC.js} +1 -1
- package/dist/dashboard/assets/{nb-NO-T6EIAALU-C423tdvs.js → nb-NO-T6EIAALU-CGRDupuc.js} +1 -1
- package/dist/dashboard/assets/{nl-NL-IS3SIHDZ-BGX4T5hB.js → nl-NL-IS3SIHDZ-BKwBfrzp.js} +1 -1
- package/dist/dashboard/assets/{nn-NO-6E72VCQL-e7Z1mG0i.js → nn-NO-6E72VCQL-DDQkGe44.js} +1 -1
- package/dist/dashboard/assets/{oc-FR-POXYY2M6-CPEhofz-.js → oc-FR-POXYY2M6-DufeHCWh.js} +1 -1
- package/dist/dashboard/assets/{pa-IN-N4M65BXN-Dmdt2Etw.js → pa-IN-N4M65BXN-BUzelJDX.js} +1 -1
- package/dist/dashboard/assets/{percentages-BXMCSKIN-D36vqrao.js → percentages-BXMCSKIN-FxAvjywS.js} +7 -7
- package/dist/dashboard/assets/{pica-DyXfovKp.js → pica-Cek5bFnr.js} +1 -1
- package/dist/dashboard/assets/{pieDiagram-DEJITSTG-DFDPs7b_.js → pieDiagram-DEJITSTG-PgIrKPnB.js} +1 -1
- package/dist/dashboard/assets/{pl-PL-T2D74RX3-G1JddCZF.js → pl-PL-T2D74RX3-Bd-rxZs3.js} +1 -1
- package/dist/dashboard/assets/{pt-BR-5N22H2LF-pu4YiRox.js → pt-BR-5N22H2LF-D0QJGoo5.js} +1 -1
- package/dist/dashboard/assets/{pt-PT-UZXXM6DQ-BOYLmU0S.js → pt-PT-UZXXM6DQ-DjumltMq.js} +1 -1
- package/dist/dashboard/assets/{quadrantDiagram-34T5L4WZ-D7Ov5Uju.js → quadrantDiagram-34T5L4WZ-C30tZOBh.js} +1 -1
- package/dist/dashboard/assets/{requirementDiagram-MS252O5E-Blqx-X0l.js → requirementDiagram-MS252O5E-D3vhi-ZB.js} +1 -1
- package/dist/dashboard/assets/{ro-RO-JPDTUUEW-DlBiDeMi.js → ro-RO-JPDTUUEW-DmEo8cEd.js} +1 -1
- package/dist/dashboard/assets/{ru-RU-B4JR7IUQ-D0J18l95.js → ru-RU-B4JR7IUQ-ZHCu1nBu.js} +1 -1
- package/dist/dashboard/assets/{sankeyDiagram-XADWPNL6-BQbQa_T1.js → sankeyDiagram-XADWPNL6-Cmbs-PxO.js} +1 -1
- package/dist/dashboard/assets/{sequenceDiagram-FGHM5R23-DhJhyglC.js → sequenceDiagram-FGHM5R23-DlBqk4uQ.js} +1 -1
- package/dist/dashboard/assets/{si-LK-N5RQ5JYF-4JT6EDIh.js → si-LK-N5RQ5JYF-iuqtpRqI.js} +1 -1
- package/dist/dashboard/assets/{sk-SK-C5VTKIMK-Bx5AqQi7.js → sk-SK-C5VTKIMK-BWFUWdaQ.js} +1 -1
- package/dist/dashboard/assets/{sl-SI-NN7IZMDC-Duy44AJo.js → sl-SI-NN7IZMDC-irYTfiq_.js} +1 -1
- package/dist/dashboard/assets/{stateDiagram-FHFEXIEX-B3lrGt3B.js → stateDiagram-FHFEXIEX-B6T9ib8G.js} +1 -1
- package/dist/dashboard/assets/stateDiagram-v2-QKLJ7IA2-CN0hAOp7.js +1 -0
- package/dist/dashboard/assets/{subset-shared.chunk-DWRxaQue.js → subset-shared.chunk-LTgWgeng.js} +1 -1
- package/dist/dashboard/assets/{subset-worker.chunk-nm8TiAaC.js → subset-worker.chunk-CT_2iDuG.js} +1 -1
- package/dist/dashboard/assets/{sv-SE-XGPEYMSR-_WPtf9Fs.js → sv-SE-XGPEYMSR-BvDzjArd.js} +1 -1
- package/dist/dashboard/assets/{ta-IN-2NMHFXQM-BZEYawlk.js → ta-IN-2NMHFXQM-DdsS_3Yq.js} +1 -1
- package/dist/dashboard/assets/{th-TH-HPSO5L25-C_ugiLaK.js → th-TH-HPSO5L25-Duadkok3.js} +1 -1
- package/dist/dashboard/assets/{timeline-definition-GMOUNBTQ-D0RPX8Ye.js → timeline-definition-GMOUNBTQ-CHTQqVpC.js} +1 -1
- package/dist/dashboard/assets/{tr-TR-DEFEU3FU-DkmWDwcW.js → tr-TR-DEFEU3FU-CTnPpl_3.js} +1 -1
- package/dist/dashboard/assets/{uk-UA-QMV73CPH-l2YUg_fY.js → uk-UA-QMV73CPH-CAqmQ01_.js} +1 -1
- package/dist/dashboard/assets/{vennDiagram-DHZGUBPP-BxCgJ4Ig.js → vennDiagram-DHZGUBPP-tWl34rwo.js} +1 -1
- package/dist/dashboard/assets/{vi-VN-M7AON7JQ-Chu_8vm0.js → vi-VN-M7AON7JQ-Cz7FDG8R.js} +1 -1
- package/dist/dashboard/assets/{wardley-RL74JXVD-B74rcv6j.js → wardley-RL74JXVD-UjdnBcpJ.js} +1 -1
- package/dist/dashboard/assets/{wardleyDiagram-NUSXRM2D-BZex7ruR.js → wardleyDiagram-NUSXRM2D-KhVWSzPf.js} +1 -1
- package/dist/dashboard/assets/webviewWindow-Dlc9MvRw.js +1 -0
- package/dist/dashboard/assets/window-D0tFurhp.js +1 -0
- package/dist/dashboard/assets/{xychartDiagram-5P7HB3ND-BACIDW_J.js → xychartDiagram-5P7HB3ND-SwtVQYTW.js} +1 -1
- package/dist/dashboard/assets/{zh-CN-LNUGB5OW-cY5Hv8ht.js → zh-CN-LNUGB5OW-B7cbFS35.js} +1 -1
- package/dist/dashboard/assets/{zh-HK-E62DVLB3-BdyhmSC7.js → zh-HK-E62DVLB3-CLi9BFmp.js} +1 -1
- package/dist/dashboard/assets/{zh-TW-RAJ6MFWO-CTjI4bec.js → zh-TW-RAJ6MFWO-XAcgJHay.js} +1 -1
- package/dist/dashboard/index.html +2 -2
- package/dist/index.js +429 -179
- package/install.sh +18 -0
- package/package.json +1 -1
- package/dist/dashboard/assets/channel-13cbKCMF.js +0 -1
- package/dist/dashboard/assets/classDiagram-6PBFFD2Q-BX19A8jH.js +0 -1
- package/dist/dashboard/assets/classDiagram-v2-HSJHXN6E-BX19A8jH.js +0 -1
- package/dist/dashboard/assets/clone-CiHddu7Q.js +0 -1
- package/dist/dashboard/assets/core-RciSkj6z.js +0 -1
- package/dist/dashboard/assets/index-BZEr0UdA.css +0 -1
- package/dist/dashboard/assets/index-CCBqToG8.js +0 -480
- package/dist/dashboard/assets/stateDiagram-v2-QKLJ7IA2-oO_Mw_KF.js +0 -1
- package/dist/dashboard/assets/webviewWindow-BHsy7FSR.js +0 -1
package/dist/index.js
CHANGED
|
@@ -34695,6 +34695,7 @@ function freshDefaults() {
|
|
|
34695
34695
|
dashboard_changes: [],
|
|
34696
34696
|
compaction_log: [],
|
|
34697
34697
|
recall_mode: "haiku",
|
|
34698
|
+
consolidation_depth: null,
|
|
34698
34699
|
pendingMigrationNotices: []
|
|
34699
34700
|
};
|
|
34700
34701
|
}
|
|
@@ -34757,18 +34758,6 @@ function bumpKnowledgeAccess(state, slug) {
|
|
|
34757
34758
|
state.knowledge_access[slug].last_accessed = today();
|
|
34758
34759
|
state.knowledge_access[slug].count++;
|
|
34759
34760
|
}
|
|
34760
|
-
function getSleepinessLevel(debt) {
|
|
34761
|
-
if (debt <= 3) return "Alert";
|
|
34762
|
-
if (debt <= 6) return "Drowsy";
|
|
34763
|
-
if (debt <= 9) return "Sleepy";
|
|
34764
|
-
return "Must Sleep";
|
|
34765
|
-
}
|
|
34766
|
-
function getSleepinessRange(debt) {
|
|
34767
|
-
if (debt <= 3) return "0-3";
|
|
34768
|
-
if (debt <= 6) return "4-6";
|
|
34769
|
-
if (debt <= 9) return "7-9";
|
|
34770
|
-
return "10+";
|
|
34771
|
-
}
|
|
34772
34761
|
function registerSleepCommand(program2) {
|
|
34773
34762
|
const sleep2 = program2.command("sleep").description("Track sleep debt and consolidation state");
|
|
34774
34763
|
sleep2.command("status").description("Show current sleep debt level and history").action(() => {
|
|
@@ -41091,8 +41080,8 @@ async function handleCoreGet(_req, res, params, contextRoot) {
|
|
|
41091
41080
|
return;
|
|
41092
41081
|
}
|
|
41093
41082
|
if (filename.endsWith(".json")) {
|
|
41094
|
-
const { readFileSync:
|
|
41095
|
-
const raw2 =
|
|
41083
|
+
const { readFileSync: readFileSync66 } = await import("fs");
|
|
41084
|
+
const raw2 = readFileSync66(filePath, "utf-8");
|
|
41096
41085
|
try {
|
|
41097
41086
|
const data = JSON.parse(raw2);
|
|
41098
41087
|
sendJson(res, 200, { filename, type: "json", data });
|
|
@@ -41126,8 +41115,8 @@ async function handleCoreGet(_req, res, params, contextRoot) {
|
|
|
41126
41115
|
});
|
|
41127
41116
|
return;
|
|
41128
41117
|
}
|
|
41129
|
-
const { readFileSync:
|
|
41130
|
-
const raw =
|
|
41118
|
+
const { readFileSync: readFileSync65 } = await import("fs");
|
|
41119
|
+
const raw = readFileSync65(filePath, "utf-8");
|
|
41131
41120
|
sendJson(res, 200, { filename, type: "text", content: raw });
|
|
41132
41121
|
}
|
|
41133
41122
|
async function handleCoreUpdate(req, res, params, contextRoot) {
|
|
@@ -41177,8 +41166,8 @@ async function handleCoreUpdate(req, res, params, contextRoot) {
|
|
|
41177
41166
|
return;
|
|
41178
41167
|
}
|
|
41179
41168
|
changedParts.push("content");
|
|
41180
|
-
const { writeFileSync:
|
|
41181
|
-
|
|
41169
|
+
const { writeFileSync: writeFileSync44 } = await import("fs");
|
|
41170
|
+
writeFileSync44(filePath, body.content, "utf-8");
|
|
41182
41171
|
}
|
|
41183
41172
|
const what = changedParts.length > 0 ? changedParts.join(" and ") : "file";
|
|
41184
41173
|
recordDashboardChange(contextRoot, {
|
|
@@ -42394,8 +42383,9 @@ var init_config = __esm({
|
|
|
42394
42383
|
|
|
42395
42384
|
// src/server/routes/vaults.ts
|
|
42396
42385
|
import { dirname as dirname28, resolve as resolve14 } from "path";
|
|
42386
|
+
import { existsSync as existsSync62 } from "fs";
|
|
42397
42387
|
async function handleVaultsGet(_req, res, _params, contextRoot) {
|
|
42398
|
-
const vaults = listVaults();
|
|
42388
|
+
const vaults = listVaults().map((v) => ({ ...v, exists: existsSync62(resolve14(v.path)) }));
|
|
42399
42389
|
const current = contextRoot ? vaults.find((v) => resolve14(v.path) === resolve14(dirname28(contextRoot)))?.name ?? null : null;
|
|
42400
42390
|
sendJson(res, 200, { vaults, current });
|
|
42401
42391
|
}
|
|
@@ -42491,10 +42481,22 @@ var init_ensure_cli = __esm({
|
|
|
42491
42481
|
|
|
42492
42482
|
// src/server/routes/launcher.ts
|
|
42493
42483
|
import { basename as basename18, isAbsolute, join as join59, resolve as resolve15, sep as sep9 } from "path";
|
|
42494
|
-
import { existsSync as
|
|
42484
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync25, readdirSync as readdirSync15, statSync as statSync10, createReadStream, readFileSync as readFileSync45, writeFileSync as writeFileSync32 } from "fs";
|
|
42495
42485
|
import { homedir as homedir3 } from "os";
|
|
42496
|
-
import { execFile as execFile2 } from "child_process";
|
|
42486
|
+
import { execFile as execFile2, spawn as spawn4 } from "child_process";
|
|
42497
42487
|
import { promisify as promisify2 } from "util";
|
|
42488
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
42489
|
+
function pruneCaptureRuns() {
|
|
42490
|
+
const now = Date.now();
|
|
42491
|
+
for (const [id, run2] of captureRuns) {
|
|
42492
|
+
if (run2.endedAt && now - run2.endedAt > CAPTURE_RUN_TTL_MS) captureRuns.delete(id);
|
|
42493
|
+
}
|
|
42494
|
+
while (captureRuns.size > CAPTURE_RUNS_MAX) {
|
|
42495
|
+
const oldest = captureRuns.keys().next().value;
|
|
42496
|
+
if (oldest === void 0) break;
|
|
42497
|
+
captureRuns.delete(oldest);
|
|
42498
|
+
}
|
|
42499
|
+
}
|
|
42498
42500
|
async function handleLauncherDiscover(req, res, _params, _contextRoot) {
|
|
42499
42501
|
const url = new URL(req.url || "/", `http://${req.headers.host}`);
|
|
42500
42502
|
const root = url.searchParams.get("root");
|
|
@@ -42503,7 +42505,7 @@ async function handleLauncherDiscover(req, res, _params, _contextRoot) {
|
|
|
42503
42505
|
return;
|
|
42504
42506
|
}
|
|
42505
42507
|
const resolvedRoot = resolve15(root);
|
|
42506
|
-
if (!
|
|
42508
|
+
if (!existsSync63(resolvedRoot)) {
|
|
42507
42509
|
sendError(res, 400, "invalid_root", `Path does not exist: ${resolvedRoot}`);
|
|
42508
42510
|
return;
|
|
42509
42511
|
}
|
|
@@ -42554,6 +42556,10 @@ function isNonEmptyDir(dir) {
|
|
|
42554
42556
|
async function scaffoldProject(a, runner = defaultCliRunner, home) {
|
|
42555
42557
|
const name = (a.name ?? "").trim();
|
|
42556
42558
|
if (!name) throw new ScaffoldError("name must be a non-empty string.");
|
|
42559
|
+
const platforms = ensurePlatformSelection(normalizePlatforms(a.platforms ?? []));
|
|
42560
|
+
const platformArg = platforms.join(",");
|
|
42561
|
+
const knownPackNames = new Set((loadCatalog()?.catalog.packs ?? []).map((p) => p.name));
|
|
42562
|
+
const packs = (a.packs ?? []).map((p) => String(p).trim()).filter((p) => knownPackNames.has(p));
|
|
42557
42563
|
let target;
|
|
42558
42564
|
if (a.mode === "new") {
|
|
42559
42565
|
if (!SAFE_NAME_RE.test(name)) {
|
|
@@ -42567,14 +42573,14 @@ async function scaffoldProject(a, runner = defaultCliRunner, home) {
|
|
|
42567
42573
|
throw new ScaffoldError("parentDir must be an absolute path.");
|
|
42568
42574
|
}
|
|
42569
42575
|
const resolvedParent = resolve15(parentDir);
|
|
42570
|
-
if (!
|
|
42576
|
+
if (!existsSync63(resolvedParent) || !statSync10(resolvedParent).isDirectory()) {
|
|
42571
42577
|
throw new ScaffoldError(`Parent directory does not exist: ${resolvedParent}`);
|
|
42572
42578
|
}
|
|
42573
42579
|
target = resolve15(resolvedParent, name);
|
|
42574
42580
|
if (target !== join59(resolvedParent, name) || !target.startsWith(resolvedParent + sep9)) {
|
|
42575
42581
|
throw new ScaffoldError("Resolved project path escapes the parent directory.");
|
|
42576
42582
|
}
|
|
42577
|
-
if (isNonEmptyDir(target) && !
|
|
42583
|
+
if (isNonEmptyDir(target) && !existsSync63(join59(target, "_dream_context"))) {
|
|
42578
42584
|
throw new ScaffoldError(`A non-empty folder already exists at ${target}.`);
|
|
42579
42585
|
}
|
|
42580
42586
|
mkdirSync25(target, { recursive: true });
|
|
@@ -42584,20 +42590,24 @@ async function scaffoldProject(a, runner = defaultCliRunner, home) {
|
|
|
42584
42590
|
throw new ScaffoldError("projectPath must be an absolute path.");
|
|
42585
42591
|
}
|
|
42586
42592
|
target = resolve15(projectPath);
|
|
42587
|
-
if (!
|
|
42593
|
+
if (!existsSync63(target) || !statSync10(target).isDirectory()) {
|
|
42588
42594
|
throw new ScaffoldError(`Folder does not exist: ${target}`);
|
|
42589
42595
|
}
|
|
42590
42596
|
} else {
|
|
42591
42597
|
throw new ScaffoldError("mode must be 'new' or 'existing'.");
|
|
42592
42598
|
}
|
|
42593
|
-
|
|
42594
|
-
|
|
42599
|
+
const alreadyProject = existsSync63(join59(target, "_dream_context"));
|
|
42600
|
+
if (!alreadyProject) {
|
|
42601
|
+
const initArgs = ["init", "--yes", "--platforms", platformArg, "--name", name];
|
|
42595
42602
|
if (a.description?.trim()) initArgs.push("--description", a.description.trim());
|
|
42596
42603
|
if (a.targetUser?.trim()) initArgs.push("--user", a.targetUser.trim());
|
|
42597
42604
|
if (a.stack?.trim()) initArgs.push("--stack", a.stack.trim());
|
|
42598
42605
|
if (a.priority?.trim()) initArgs.push("--priority", a.priority.trim());
|
|
42599
42606
|
await runner(initArgs, target);
|
|
42600
|
-
|
|
42607
|
+
}
|
|
42608
|
+
await runner(["setup", "--defaults", "--platforms", platformArg], target);
|
|
42609
|
+
if (packs.length > 0) {
|
|
42610
|
+
await runner(["install-skill", "--packs", ...packs, "--platforms", platformArg], target);
|
|
42601
42611
|
}
|
|
42602
42612
|
const vault = addVault(name, target, home);
|
|
42603
42613
|
return { vault, vaults: listVaults(home) };
|
|
@@ -42616,7 +42626,9 @@ async function handleLauncherScaffold(req, res, _params, _contextRoot) {
|
|
|
42616
42626
|
stack: typeof body.stack === "string" ? body.stack : void 0,
|
|
42617
42627
|
priority: typeof body.priority === "string" ? body.priority : void 0,
|
|
42618
42628
|
parentDir: typeof body.parentDir === "string" ? body.parentDir : void 0,
|
|
42619
|
-
projectPath: typeof body.projectPath === "string" ? body.projectPath : void 0
|
|
42629
|
+
projectPath: typeof body.projectPath === "string" ? body.projectPath : void 0,
|
|
42630
|
+
platforms: Array.isArray(body.platforms) ? body.platforms.filter((p) => typeof p === "string") : void 0,
|
|
42631
|
+
packs: Array.isArray(body.packs) ? body.packs.filter((p) => typeof p === "string") : void 0
|
|
42620
42632
|
};
|
|
42621
42633
|
try {
|
|
42622
42634
|
const result = await scaffoldProject(answers);
|
|
@@ -42639,21 +42651,244 @@ async function handleLauncherDetect(req, res, _params, _contextRoot) {
|
|
|
42639
42651
|
return;
|
|
42640
42652
|
}
|
|
42641
42653
|
const resolved = resolve15(path2);
|
|
42642
|
-
if (!
|
|
42654
|
+
if (!existsSync63(resolved)) {
|
|
42643
42655
|
sendError(res, 400, "invalid_path", `Path does not exist: ${resolved}`);
|
|
42644
42656
|
return;
|
|
42645
42657
|
}
|
|
42646
42658
|
sendJson(res, 200, {
|
|
42647
42659
|
stack: detectTechStack(resolved) ?? "",
|
|
42648
|
-
hasContext:
|
|
42660
|
+
hasContext: existsSync63(join59(resolved, "_dream_context")),
|
|
42649
42661
|
name: basename18(resolved)
|
|
42650
42662
|
});
|
|
42651
42663
|
}
|
|
42664
|
+
async function handleLauncherCatalog(_req, res, _params, _contextRoot) {
|
|
42665
|
+
const recommended = new Set(DEFAULT_PLATFORMS);
|
|
42666
|
+
const platforms = PLATFORM_CATALOG.map((p) => ({
|
|
42667
|
+
id: p.id,
|
|
42668
|
+
label: p.label,
|
|
42669
|
+
description: p.description,
|
|
42670
|
+
recommended: recommended.has(p.id)
|
|
42671
|
+
}));
|
|
42672
|
+
const packs = (loadCatalog()?.catalog.packs ?? []).map((p) => ({
|
|
42673
|
+
name: p.name,
|
|
42674
|
+
description: p.description,
|
|
42675
|
+
tags: p.tags
|
|
42676
|
+
}));
|
|
42677
|
+
sendJson(res, 200, { platforms, packs });
|
|
42678
|
+
}
|
|
42679
|
+
function sleepyConfigPath() {
|
|
42680
|
+
return join59(homedir3(), ".dreamcontext", "sleepy.json");
|
|
42681
|
+
}
|
|
42682
|
+
async function handleSleepyConfigGet(_req, res, _params, _contextRoot) {
|
|
42683
|
+
let enabled = false;
|
|
42684
|
+
let hotkey = "Alt+Cmd+S";
|
|
42685
|
+
try {
|
|
42686
|
+
const p = sleepyConfigPath();
|
|
42687
|
+
if (existsSync63(p)) {
|
|
42688
|
+
const raw = JSON.parse(readFileSync45(p, "utf-8"));
|
|
42689
|
+
enabled = raw.enabled === true;
|
|
42690
|
+
if (typeof raw.hotkey === "string" && raw.hotkey.trim()) hotkey = raw.hotkey;
|
|
42691
|
+
}
|
|
42692
|
+
} catch {
|
|
42693
|
+
}
|
|
42694
|
+
sendJson(res, 200, { enabled, hotkey });
|
|
42695
|
+
}
|
|
42696
|
+
async function handleSleepyConfigSet(req, res, _params, _contextRoot) {
|
|
42697
|
+
const body = await parseJsonBody(req);
|
|
42698
|
+
if (!body) {
|
|
42699
|
+
sendError(res, 400, "invalid_body", "Request body must be valid JSON.");
|
|
42700
|
+
return;
|
|
42701
|
+
}
|
|
42702
|
+
const enabled = body.enabled === true;
|
|
42703
|
+
const hotkey = typeof body.hotkey === "string" && body.hotkey.trim() ? body.hotkey.trim() : "Alt+Cmd+S";
|
|
42704
|
+
try {
|
|
42705
|
+
const p = sleepyConfigPath();
|
|
42706
|
+
mkdirSync25(join59(homedir3(), ".dreamcontext"), { recursive: true });
|
|
42707
|
+
writeFileSync32(p, JSON.stringify({ enabled, hotkey }, null, 2) + "\n", "utf-8");
|
|
42708
|
+
sendJson(res, 200, { enabled, hotkey });
|
|
42709
|
+
} catch (err) {
|
|
42710
|
+
console.error("[launcher] sleepy-config write failed:", err);
|
|
42711
|
+
sendError(res, 500, "write_failed", "Failed to persist Sleepy config.");
|
|
42712
|
+
}
|
|
42713
|
+
}
|
|
42714
|
+
async function handleSleepyVideo(req, res, _params, _contextRoot) {
|
|
42715
|
+
const url = new URL(req.url || "/", `http://${req.headers.host}`);
|
|
42716
|
+
const mode = url.searchParams.get("mode") || "idle";
|
|
42717
|
+
if (!SLEEPY_MODES.has(mode)) {
|
|
42718
|
+
sendError(res, 400, "bad_mode", "mode must be idle, sleepy, or sleeps.");
|
|
42719
|
+
return;
|
|
42720
|
+
}
|
|
42721
|
+
const dir = process.env.DREAMCONTEXT_SLEEPY_DIR;
|
|
42722
|
+
if (!dir) {
|
|
42723
|
+
res.writeHead(404);
|
|
42724
|
+
res.end();
|
|
42725
|
+
return;
|
|
42726
|
+
}
|
|
42727
|
+
const file = join59(dir, `${mode}.mp4`);
|
|
42728
|
+
if (!existsSync63(file)) {
|
|
42729
|
+
res.writeHead(404);
|
|
42730
|
+
res.end();
|
|
42731
|
+
return;
|
|
42732
|
+
}
|
|
42733
|
+
const size = statSync10(file).size;
|
|
42734
|
+
const range = req.headers.range;
|
|
42735
|
+
if (range) {
|
|
42736
|
+
const m = /bytes=(\d+)-(\d*)/.exec(range);
|
|
42737
|
+
const start = m ? parseInt(m[1], 10) : 0;
|
|
42738
|
+
const end = m && m[2] ? Math.min(parseInt(m[2], 10), size - 1) : size - 1;
|
|
42739
|
+
res.writeHead(206, {
|
|
42740
|
+
"Content-Type": "video/mp4",
|
|
42741
|
+
"Accept-Ranges": "bytes",
|
|
42742
|
+
"Content-Range": `bytes ${start}-${end}/${size}`,
|
|
42743
|
+
"Content-Length": end - start + 1
|
|
42744
|
+
});
|
|
42745
|
+
createReadStream(file, { start, end }).pipe(res);
|
|
42746
|
+
} else {
|
|
42747
|
+
res.writeHead(200, { "Content-Type": "video/mp4", "Accept-Ranges": "bytes", "Content-Length": size });
|
|
42748
|
+
createReadStream(file).pipe(res);
|
|
42749
|
+
}
|
|
42750
|
+
}
|
|
42751
|
+
async function handleSleepyAnim(req, res, _params, _contextRoot) {
|
|
42752
|
+
const url = new URL(req.url || "/", `http://${req.headers.host}`);
|
|
42753
|
+
const mode = url.searchParams.get("mode") || "idle";
|
|
42754
|
+
if (!SLEEPY_MODES.has(mode)) {
|
|
42755
|
+
sendError(res, 400, "bad_mode", "mode must be idle, sleepy, or sleeps.");
|
|
42756
|
+
return;
|
|
42757
|
+
}
|
|
42758
|
+
const dir = process.env.DREAMCONTEXT_SLEEPY_DIR;
|
|
42759
|
+
const file = dir ? join59(dir, `${mode}.webp`) : "";
|
|
42760
|
+
if (!file || !existsSync63(file)) {
|
|
42761
|
+
res.writeHead(404);
|
|
42762
|
+
res.end();
|
|
42763
|
+
return;
|
|
42764
|
+
}
|
|
42765
|
+
const size = statSync10(file).size;
|
|
42766
|
+
res.writeHead(200, {
|
|
42767
|
+
"Content-Type": "image/webp",
|
|
42768
|
+
"Content-Length": size,
|
|
42769
|
+
"Cache-Control": "public, max-age=86400"
|
|
42770
|
+
});
|
|
42771
|
+
createReadStream(file).pipe(res);
|
|
42772
|
+
}
|
|
42773
|
+
function buildCapturePrompt(note) {
|
|
42774
|
+
return `Think hard. A quick-capture note was just saved to this project's dreamcontext memory:
|
|
42775
|
+
|
|
42776
|
+
"${note}"
|
|
42777
|
+
|
|
42778
|
+
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.`;
|
|
42779
|
+
}
|
|
42780
|
+
function buildAskPrompt(question) {
|
|
42781
|
+
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.
|
|
42782
|
+
|
|
42783
|
+
Question: "${question}"`;
|
|
42784
|
+
}
|
|
42785
|
+
function buildSleepPrompt() {
|
|
42786
|
+
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.`;
|
|
42787
|
+
}
|
|
42788
|
+
async function handleLauncherCapture(req, res, _params, _contextRoot) {
|
|
42789
|
+
const body = await parseJsonBody(req);
|
|
42790
|
+
if (!body) {
|
|
42791
|
+
sendError(res, 400, "invalid_body", "Request body must be valid JSON.");
|
|
42792
|
+
return;
|
|
42793
|
+
}
|
|
42794
|
+
const vaultName = typeof body.vault === "string" ? body.vault.trim() : "";
|
|
42795
|
+
const text = typeof body.text === "string" ? body.text.trim() : "";
|
|
42796
|
+
if (!vaultName) {
|
|
42797
|
+
sendError(res, 400, "invalid_vault", "vault must be a non-empty string.");
|
|
42798
|
+
return;
|
|
42799
|
+
}
|
|
42800
|
+
const mode = body.mode === "ask" ? "ask" : body.mode === "sleep" ? "sleep" : "learn";
|
|
42801
|
+
if (mode !== "sleep" && !text) {
|
|
42802
|
+
sendError(res, 400, "invalid_text", "text must be a non-empty string.");
|
|
42803
|
+
return;
|
|
42804
|
+
}
|
|
42805
|
+
const vault = listVaults().find((v) => v.name === vaultName);
|
|
42806
|
+
if (!vault) {
|
|
42807
|
+
sendError(res, 400, "unknown_vault", `No registered vault named "${vaultName}".`);
|
|
42808
|
+
return;
|
|
42809
|
+
}
|
|
42810
|
+
const cwd = resolve15(vault.path);
|
|
42811
|
+
if (!existsSync63(cwd)) {
|
|
42812
|
+
sendError(res, 400, "missing_vault", `Vault path no longer exists: ${cwd}`);
|
|
42813
|
+
return;
|
|
42814
|
+
}
|
|
42815
|
+
if (mode === "learn") {
|
|
42816
|
+
try {
|
|
42817
|
+
const changelogPath = join59(cwd, "_dream_context", "core", "CHANGELOG.json");
|
|
42818
|
+
if (!existsSync63(changelogPath)) {
|
|
42819
|
+
sendError(res, 400, "not_initialized", `"${vaultName}" has no _dream_context \u2014 run init first.`);
|
|
42820
|
+
return;
|
|
42821
|
+
}
|
|
42822
|
+
const summary = text.length > 200 ? text.slice(0, 197) + "..." : text;
|
|
42823
|
+
insertToJsonArray(changelogPath, {
|
|
42824
|
+
date: today(),
|
|
42825
|
+
type: "note",
|
|
42826
|
+
scope: "quick",
|
|
42827
|
+
summary,
|
|
42828
|
+
description: text,
|
|
42829
|
+
breaking: false
|
|
42830
|
+
});
|
|
42831
|
+
} catch (err) {
|
|
42832
|
+
console.error("[launcher] capture changelog write failed:", err);
|
|
42833
|
+
const detail = err instanceof Error ? err.message : "unknown error";
|
|
42834
|
+
sendError(res, 500, "capture_failed", `Failed to save the note: ${detail}`);
|
|
42835
|
+
return;
|
|
42836
|
+
}
|
|
42837
|
+
}
|
|
42838
|
+
pruneCaptureRuns();
|
|
42839
|
+
const captureId = randomUUID2();
|
|
42840
|
+
const run2 = { state: "running", output: "", stderr: "", startedAt: Date.now() };
|
|
42841
|
+
captureRuns.set(captureId, run2);
|
|
42842
|
+
try {
|
|
42843
|
+
const shell = process.env.SHELL || "/bin/zsh";
|
|
42844
|
+
const prompt = mode === "sleep" ? buildSleepPrompt() : mode === "ask" ? buildAskPrompt(text) : buildCapturePrompt(text);
|
|
42845
|
+
const child = spawn4(shell, ["-ilc", 'exec claude --model sonnet -p "$0"', prompt], {
|
|
42846
|
+
cwd,
|
|
42847
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
42848
|
+
});
|
|
42849
|
+
child.stdout?.on("data", (chunk) => {
|
|
42850
|
+
run2.output = (run2.output + chunk.toString("utf-8")).slice(-8e3);
|
|
42851
|
+
});
|
|
42852
|
+
child.stderr?.on("data", (chunk) => {
|
|
42853
|
+
run2.stderr = (run2.stderr + chunk.toString("utf-8")).slice(-4e3);
|
|
42854
|
+
});
|
|
42855
|
+
child.on("error", (err) => {
|
|
42856
|
+
run2.state = "error";
|
|
42857
|
+
run2.output = `Couldn't start claude: ${err.message}`;
|
|
42858
|
+
run2.endedAt = Date.now();
|
|
42859
|
+
});
|
|
42860
|
+
child.on("close", (code) => {
|
|
42861
|
+
if (run2.state !== "running") return;
|
|
42862
|
+
if (code === 0) {
|
|
42863
|
+
run2.state = "done";
|
|
42864
|
+
} else {
|
|
42865
|
+
run2.state = "error";
|
|
42866
|
+
if (!run2.output.trim()) run2.output = run2.stderr.trim() || `claude exited with code ${code}`;
|
|
42867
|
+
}
|
|
42868
|
+
run2.endedAt = Date.now();
|
|
42869
|
+
});
|
|
42870
|
+
} catch (err) {
|
|
42871
|
+
run2.state = "error";
|
|
42872
|
+
run2.output = `Couldn't start claude: ${err instanceof Error ? err.message : "spawn failed"}`;
|
|
42873
|
+
run2.endedAt = Date.now();
|
|
42874
|
+
}
|
|
42875
|
+
sendJson(res, 200, { ok: true, captureId });
|
|
42876
|
+
}
|
|
42877
|
+
async function handleLauncherCaptureStatus(req, res, _params, _contextRoot) {
|
|
42878
|
+
const url = new URL(req.url || "/", `http://${req.headers.host}`);
|
|
42879
|
+
const id = url.searchParams.get("id") ?? "";
|
|
42880
|
+
const run2 = id ? captureRuns.get(id) : void 0;
|
|
42881
|
+
if (!run2) {
|
|
42882
|
+
sendJson(res, 200, { state: "unknown", output: "" });
|
|
42883
|
+
return;
|
|
42884
|
+
}
|
|
42885
|
+
sendJson(res, 200, { state: run2.state, output: run2.output.trim() });
|
|
42886
|
+
}
|
|
42652
42887
|
async function handleLauncherDefaults(_req, res, _params, _contextRoot) {
|
|
42653
42888
|
const home = homedir3();
|
|
42654
42889
|
sendJson(res, 200, { home, defaultParent: join59(home, "projects") });
|
|
42655
42890
|
}
|
|
42656
|
-
var execFileAsync2, ScaffoldError, defaultCliRunner, SAFE_NAME_RE;
|
|
42891
|
+
var execFileAsync2, captureRuns, CAPTURE_RUN_TTL_MS, CAPTURE_RUNS_MAX, ScaffoldError, defaultCliRunner, SAFE_NAME_RE, SLEEPY_MODES;
|
|
42657
42892
|
var init_launcher = __esm({
|
|
42658
42893
|
"src/server/routes/launcher.ts"() {
|
|
42659
42894
|
"use strict";
|
|
@@ -42662,7 +42897,14 @@ var init_launcher = __esm({
|
|
|
42662
42897
|
init_vaults();
|
|
42663
42898
|
init_tech_stack();
|
|
42664
42899
|
init_ensure_cli();
|
|
42900
|
+
init_platforms();
|
|
42901
|
+
init_catalog();
|
|
42902
|
+
init_json_file();
|
|
42903
|
+
init_id();
|
|
42665
42904
|
execFileAsync2 = promisify2(execFile2);
|
|
42905
|
+
captureRuns = /* @__PURE__ */ new Map();
|
|
42906
|
+
CAPTURE_RUN_TTL_MS = 10 * 60 * 1e3;
|
|
42907
|
+
CAPTURE_RUNS_MAX = 50;
|
|
42666
42908
|
ScaffoldError = class extends Error {
|
|
42667
42909
|
constructor(message) {
|
|
42668
42910
|
super(message);
|
|
@@ -42683,6 +42925,7 @@ var init_launcher = __esm({
|
|
|
42683
42925
|
});
|
|
42684
42926
|
};
|
|
42685
42927
|
SAFE_NAME_RE = /^[^/\\]+$/;
|
|
42928
|
+
SLEEPY_MODES = /* @__PURE__ */ new Set(["idle", "sleepy", "sleeps"]);
|
|
42686
42929
|
}
|
|
42687
42930
|
});
|
|
42688
42931
|
|
|
@@ -42874,7 +43117,7 @@ var init_connections2 = __esm({
|
|
|
42874
43117
|
});
|
|
42875
43118
|
|
|
42876
43119
|
// src/lib/federation-digest.ts
|
|
42877
|
-
import { existsSync as
|
|
43120
|
+
import { existsSync as existsSync64 } from "fs";
|
|
42878
43121
|
import { join as join60 } from "path";
|
|
42879
43122
|
function buildInterestProfile(peerRoot, topics) {
|
|
42880
43123
|
if (topics && topics.length > 0) {
|
|
@@ -42895,7 +43138,7 @@ function buildInterestProfile(peerRoot, topics) {
|
|
|
42895
43138
|
}
|
|
42896
43139
|
function activeTaskTerms(peerRoot) {
|
|
42897
43140
|
const stateDir = join60(peerRoot, "state");
|
|
42898
|
-
if (!
|
|
43141
|
+
if (!existsSync64(stateDir)) return [];
|
|
42899
43142
|
let files;
|
|
42900
43143
|
try {
|
|
42901
43144
|
files = import_fast_glob17.default.sync("*.md", { cwd: stateDir, absolute: true });
|
|
@@ -43260,8 +43503,15 @@ function buildRouter() {
|
|
|
43260
43503
|
router.get("/api/launcher/discover", handleLauncherDiscover);
|
|
43261
43504
|
router.get("/api/launcher/detect", handleLauncherDetect);
|
|
43262
43505
|
router.get("/api/launcher/defaults", handleLauncherDefaults);
|
|
43506
|
+
router.get("/api/launcher/catalog", handleLauncherCatalog);
|
|
43263
43507
|
router.post("/api/launcher/register", handleLauncherRegister);
|
|
43264
43508
|
router.post("/api/launcher/scaffold", handleLauncherScaffold);
|
|
43509
|
+
router.post("/api/launcher/capture", handleLauncherCapture);
|
|
43510
|
+
router.get("/api/launcher/capture/status", handleLauncherCaptureStatus);
|
|
43511
|
+
router.get("/api/launcher/sleepy-config", handleSleepyConfigGet);
|
|
43512
|
+
router.post("/api/launcher/sleepy-config", handleSleepyConfigSet);
|
|
43513
|
+
router.get("/api/sleepy/video", handleSleepyVideo);
|
|
43514
|
+
router.get("/api/sleepy/anim", handleSleepyAnim);
|
|
43265
43515
|
router.get("/api/vaults", handleVaultsGet);
|
|
43266
43516
|
router.get("/api/connections", handleConnectionsList);
|
|
43267
43517
|
router.post("/api/connections", handleConnectionsCreate);
|
|
@@ -43399,7 +43649,7 @@ var init_server = __esm({
|
|
|
43399
43649
|
init_version_check2();
|
|
43400
43650
|
init_taxonomy2();
|
|
43401
43651
|
init_vaults();
|
|
43402
|
-
VAULT_AGNOSTIC_PREFIXES = ["/api/health", "/api/vaults", "/api/launcher"];
|
|
43652
|
+
VAULT_AGNOSTIC_PREFIXES = ["/api/health", "/api/vaults", "/api/launcher", "/api/sleepy"];
|
|
43403
43653
|
}
|
|
43404
43654
|
});
|
|
43405
43655
|
|
|
@@ -43583,7 +43833,7 @@ var init_trigger = __esm({
|
|
|
43583
43833
|
});
|
|
43584
43834
|
|
|
43585
43835
|
// src/lib/reflection.ts
|
|
43586
|
-
import { existsSync as
|
|
43836
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync26, writeFileSync as writeFileSync33 } from "fs";
|
|
43587
43837
|
import { join as join62, dirname as dirname36 } from "path";
|
|
43588
43838
|
function buildExclusionSet(corpus, excludedExtra) {
|
|
43589
43839
|
const excluded = new Set(excludedExtra);
|
|
@@ -43765,7 +44015,7 @@ function reflectionPath(root) {
|
|
|
43765
44015
|
function writeReflection(root, md) {
|
|
43766
44016
|
const outPath = reflectionPath(root);
|
|
43767
44017
|
const dir = dirname36(outPath);
|
|
43768
|
-
if (!
|
|
44018
|
+
if (!existsSync65(dir)) {
|
|
43769
44019
|
mkdirSync26(dir, { recursive: true });
|
|
43770
44020
|
}
|
|
43771
44021
|
const tsMatch = md.match(/Generated: ([^\n]+)/);
|
|
@@ -43777,7 +44027,7 @@ function writeReflection(root, md) {
|
|
|
43777
44027
|
"---",
|
|
43778
44028
|
""
|
|
43779
44029
|
].join("\n");
|
|
43780
|
-
|
|
44030
|
+
writeFileSync33(outPath, frontmatter + md, "utf-8");
|
|
43781
44031
|
return outPath;
|
|
43782
44032
|
}
|
|
43783
44033
|
var MAX_REFLECTION_BYTES, DEFAULT_MIN_SESSIONS, DEFAULT_MAX_CANDIDATES, REFLECTION_NOISE;
|
|
@@ -43941,14 +44191,14 @@ var init_reflection = __esm({
|
|
|
43941
44191
|
});
|
|
43942
44192
|
|
|
43943
44193
|
// src/cli/commands/reflect.ts
|
|
43944
|
-
import { existsSync as
|
|
44194
|
+
import { existsSync as existsSync66, readFileSync as readFileSync48 } from "fs";
|
|
43945
44195
|
import { join as join63 } from "path";
|
|
43946
44196
|
function buildBookmarkSessions(root) {
|
|
43947
44197
|
const sleepPath = join63(root, "state", ".sleep.json");
|
|
43948
44198
|
const result = /* @__PURE__ */ new Map();
|
|
43949
|
-
if (!
|
|
44199
|
+
if (!existsSync66(sleepPath)) return result;
|
|
43950
44200
|
try {
|
|
43951
|
-
const parsed = JSON.parse(
|
|
44201
|
+
const parsed = JSON.parse(readFileSync48(sleepPath, "utf-8"));
|
|
43952
44202
|
const bookmarks = parsed.bookmarks ?? [];
|
|
43953
44203
|
for (const b of bookmarks) {
|
|
43954
44204
|
if (b.id && b.session_id) {
|
|
@@ -43966,9 +44216,9 @@ function buildExcludedExtra(root) {
|
|
|
43966
44216
|
join63(root, "core", "1.user.md")
|
|
43967
44217
|
];
|
|
43968
44218
|
for (const filePath of coreFiles) {
|
|
43969
|
-
if (!
|
|
44219
|
+
if (!existsSync66(filePath)) continue;
|
|
43970
44220
|
try {
|
|
43971
|
-
const content =
|
|
44221
|
+
const content = readFileSync48(filePath, "utf-8");
|
|
43972
44222
|
for (const tok of tokenize(content)) {
|
|
43973
44223
|
excluded.add(tok);
|
|
43974
44224
|
}
|
|
@@ -44019,7 +44269,7 @@ var init_reflect = __esm({
|
|
|
44019
44269
|
});
|
|
44020
44270
|
|
|
44021
44271
|
// src/cli/commands/council.ts
|
|
44022
|
-
import { existsSync as
|
|
44272
|
+
import { existsSync as existsSync67, mkdirSync as mkdirSync27, readFileSync as readFileSync49, writeFileSync as writeFileSync34 } from "fs";
|
|
44023
44273
|
import { join as join64 } from "path";
|
|
44024
44274
|
function roundRunningStatus(n) {
|
|
44025
44275
|
return `round_${n}_running`;
|
|
@@ -44065,8 +44315,8 @@ function registerCreate(council) {
|
|
|
44065
44315
|
mkdirSync27(dir, { recursive: true });
|
|
44066
44316
|
const template = loadTemplate("council-debate.md");
|
|
44067
44317
|
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
|
-
|
|
44069
|
-
|
|
44318
|
+
writeFileSync34(join64(dir, "debate.md"), content, "utf-8");
|
|
44319
|
+
writeFileSync34(
|
|
44070
44320
|
join64(dir, "round-log.md"),
|
|
44071
44321
|
`# Round log \u2014 ${id}
|
|
44072
44322
|
|
|
@@ -44110,7 +44360,7 @@ function registerAgent(council) {
|
|
|
44110
44360
|
}
|
|
44111
44361
|
const personaDir = getPersonaDir(debateId, slug);
|
|
44112
44362
|
const personaFile = join64(personaDir, "context-and-persona.md");
|
|
44113
|
-
if (
|
|
44363
|
+
if (existsSync67(personaFile) && !opts.force) {
|
|
44114
44364
|
error(`Persona already exists: ${slug}`, "Use --force to overwrite.");
|
|
44115
44365
|
process.exit(1);
|
|
44116
44366
|
}
|
|
@@ -44123,10 +44373,10 @@ function registerAgent(council) {
|
|
|
44123
44373
|
mkdirSync27(personaDir, { recursive: true });
|
|
44124
44374
|
const template = loadTemplate("council-persona.md");
|
|
44125
44375
|
const personaContent = template.replaceAll("{{SLUG}}", slug).replaceAll("{{MODEL}}", opts.model).replaceAll("{{ASPECTS}}", JSON.stringify(aspects)).replaceAll("{{PERSONA_BODY}}", body.trim());
|
|
44126
|
-
|
|
44376
|
+
writeFileSync34(personaFile, personaContent, "utf-8");
|
|
44127
44377
|
const reportTemplate = loadTemplate("council-report.md");
|
|
44128
44378
|
const reportContent = reportTemplate.replaceAll("{{SLUG}}", slug);
|
|
44129
|
-
|
|
44379
|
+
writeFileSync34(join64(personaDir, "report.md"), reportContent, "utf-8");
|
|
44130
44380
|
const debateFile = join64(getDebateDir(debateId), "debate.md");
|
|
44131
44381
|
const { data } = readFrontmatter(debateFile);
|
|
44132
44382
|
const personas = Array.isArray(data.personas) ? data.personas.slice() : [];
|
|
@@ -44166,8 +44416,8 @@ function registerRound(council) {
|
|
|
44166
44416
|
if (n >= 2) {
|
|
44167
44417
|
for (const persona of personas) {
|
|
44168
44418
|
const personaFile = join64(getPersonaDir(debateId, persona), "context-and-persona.md");
|
|
44169
|
-
if (!
|
|
44170
|
-
const existing =
|
|
44419
|
+
if (!existsSync67(personaFile)) continue;
|
|
44420
|
+
const existing = readFileSync49(personaFile, "utf-8");
|
|
44171
44421
|
if (existing.includes(crossContextHeader)) {
|
|
44172
44422
|
continue;
|
|
44173
44423
|
}
|
|
@@ -44189,7 +44439,7 @@ _(no round ${n - 1} report submitted)_`);
|
|
|
44189
44439
|
|
|
44190
44440
|
${peerLines.join("\n\n")}`;
|
|
44191
44441
|
const updated = existing.trimEnd() + "\n\n" + newSection + "\n";
|
|
44192
|
-
|
|
44442
|
+
writeFileSync34(personaFile, updated, "utf-8");
|
|
44193
44443
|
}
|
|
44194
44444
|
}
|
|
44195
44445
|
updateFrontmatterFields(debateFile, {
|
|
@@ -44198,12 +44448,12 @@ ${peerLines.join("\n\n")}`;
|
|
|
44198
44448
|
updated_at: today()
|
|
44199
44449
|
});
|
|
44200
44450
|
const logFile = join64(getDebateDir(debateId), "round-log.md");
|
|
44201
|
-
const logExisting =
|
|
44451
|
+
const logExisting = existsSync67(logFile) ? readFileSync49(logFile, "utf-8") : "";
|
|
44202
44452
|
const logEntry = `
|
|
44203
44453
|
## Round ${n} started \u2014 ${today()}
|
|
44204
44454
|
- Personas: ${formatPersonaList(personas)}
|
|
44205
44455
|
`;
|
|
44206
|
-
|
|
44456
|
+
writeFileSync34(logFile, logExisting.trimEnd() + "\n" + logEntry + "\n", "utf-8");
|
|
44207
44457
|
upsertCouncilIndex({
|
|
44208
44458
|
id: debateId,
|
|
44209
44459
|
topic: data.topic,
|
|
@@ -44243,12 +44493,12 @@ ${peerLines.join("\n\n")}`;
|
|
|
44243
44493
|
updated_at: today()
|
|
44244
44494
|
});
|
|
44245
44495
|
const logFile = join64(getDebateDir(debateId), "round-log.md");
|
|
44246
|
-
const logExisting =
|
|
44496
|
+
const logExisting = existsSync67(logFile) ? readFileSync49(logFile, "utf-8") : "";
|
|
44247
44497
|
const logEntry = `
|
|
44248
44498
|
## Round ${n} complete \u2014 ${today()}
|
|
44249
44499
|
- All ${personas.length} personas submitted reports.
|
|
44250
44500
|
`;
|
|
44251
|
-
|
|
44501
|
+
writeFileSync34(logFile, logExisting.trimEnd() + "\n" + logEntry + "\n", "utf-8");
|
|
44252
44502
|
upsertCouncilIndex({
|
|
44253
44503
|
id: debateId,
|
|
44254
44504
|
topic: data.topic,
|
|
@@ -44272,7 +44522,7 @@ function registerRoundContext(council) {
|
|
|
44272
44522
|
const data = readDebateFrontmatter(debateId);
|
|
44273
44523
|
ensurePersonaExists(debateId, personaSlug);
|
|
44274
44524
|
const personaFile = join64(getPersonaDir(debateId, personaSlug), "context-and-persona.md");
|
|
44275
|
-
const personaContent =
|
|
44525
|
+
const personaContent = readFileSync49(personaFile, "utf-8");
|
|
44276
44526
|
console.log(`# Council debate: ${data.topic}`);
|
|
44277
44527
|
console.log(`Debate ID: ${debateId}`);
|
|
44278
44528
|
console.log(`Current round: ${data.current_round}/${data.rounds_planned}`);
|
|
@@ -44282,7 +44532,7 @@ function registerRoundContext(council) {
|
|
|
44282
44532
|
console.log("");
|
|
44283
44533
|
console.log(personaContent);
|
|
44284
44534
|
const debateFile = join64(getDebateDir(debateId), "debate.md");
|
|
44285
|
-
const debateRaw =
|
|
44535
|
+
const debateRaw = readFileSync49(debateFile, "utf-8");
|
|
44286
44536
|
const questionMatch = debateRaw.match(/##\s+Question\s*\n([\s\S]*?)(?=\n##\s|\Z)/);
|
|
44287
44537
|
const constraintsMatch = debateRaw.match(/##\s+Constraints & Known Facts\s*\n([\s\S]*?)(?=\n##\s|\Z)/);
|
|
44288
44538
|
if (questionMatch) {
|
|
@@ -44393,10 +44643,10 @@ function registerResearch(council) {
|
|
|
44393
44643
|
const researchesDir = join64(getPersonaDir(debateId, personaSlug), "researches");
|
|
44394
44644
|
mkdirSync27(researchesDir, { recursive: true });
|
|
44395
44645
|
const indexPath2 = join64(researchesDir, "index.json");
|
|
44396
|
-
if (!
|
|
44646
|
+
if (!existsSync67(indexPath2)) writeJsonArray(indexPath2, []);
|
|
44397
44647
|
const slug = slugify(topic);
|
|
44398
44648
|
const file = join64(researchesDir, `${slug}.md`);
|
|
44399
|
-
if (
|
|
44649
|
+
if (existsSync67(file)) {
|
|
44400
44650
|
error(`Research note already exists: ${slug}.md`);
|
|
44401
44651
|
process.exit(1);
|
|
44402
44652
|
}
|
|
@@ -44411,7 +44661,7 @@ _Added ${today()} by ${personaSlug}_
|
|
|
44411
44661
|
|
|
44412
44662
|
${body.trim()}
|
|
44413
44663
|
`;
|
|
44414
|
-
|
|
44664
|
+
writeFileSync34(file, noteContent, "utf-8");
|
|
44415
44665
|
insertToJsonArray(indexPath2, {
|
|
44416
44666
|
slug,
|
|
44417
44667
|
topic,
|
|
@@ -44428,7 +44678,7 @@ ${body.trim()}
|
|
|
44428
44678
|
ensurePersonaExists(debateId, personaSlug);
|
|
44429
44679
|
const researchesDir = join64(getPersonaDir(debateId, personaSlug), "researches");
|
|
44430
44680
|
const indexPath2 = join64(researchesDir, "index.json");
|
|
44431
|
-
if (!
|
|
44681
|
+
if (!existsSync67(indexPath2)) {
|
|
44432
44682
|
console.log(source_default.dim("(no researches)"));
|
|
44433
44683
|
return;
|
|
44434
44684
|
}
|
|
@@ -44473,7 +44723,7 @@ function registerSynthesize(council) {
|
|
|
44473
44723
|
manifest.push(`_dream_context/council/${debateId}/${persona}/context-and-persona.md`);
|
|
44474
44724
|
manifest.push(`_dream_context/council/${debateId}/${persona}/report.md`);
|
|
44475
44725
|
const researchesIndex = join64(personaDir, "researches", "index.json");
|
|
44476
|
-
if (
|
|
44726
|
+
if (existsSync67(researchesIndex)) {
|
|
44477
44727
|
manifest.push(`_dream_context/council/${debateId}/${persona}/researches/`);
|
|
44478
44728
|
}
|
|
44479
44729
|
}
|
|
@@ -44492,7 +44742,7 @@ function registerComplete(council) {
|
|
|
44492
44742
|
try {
|
|
44493
44743
|
const data = readDebateFrontmatter(debateId);
|
|
44494
44744
|
const finalReport = join64(getDebateDir(debateId), "final-report.md");
|
|
44495
|
-
if (!
|
|
44745
|
+
if (!existsSync67(finalReport)) {
|
|
44496
44746
|
error("final-report.md not found.", "Synthesizer must write it before calling `council complete`.");
|
|
44497
44747
|
process.exit(1);
|
|
44498
44748
|
}
|
|
@@ -44529,7 +44779,7 @@ function registerPromote(council) {
|
|
|
44529
44779
|
process.exit(1);
|
|
44530
44780
|
}
|
|
44531
44781
|
const finalReport = join64(getDebateDir(debateId), "final-report.md");
|
|
44532
|
-
if (!
|
|
44782
|
+
if (!existsSync67(finalReport)) {
|
|
44533
44783
|
error("final-report.md not found.");
|
|
44534
44784
|
process.exit(1);
|
|
44535
44785
|
}
|
|
@@ -44547,7 +44797,7 @@ ${sec.body.trim()}` : null;
|
|
|
44547
44797
|
const slug = slugify(data.topic).slice(0, 80) || debateId;
|
|
44548
44798
|
const filename = `decision-${slug}.md`;
|
|
44549
44799
|
const target = join64(knowledgeDir, filename);
|
|
44550
|
-
if (
|
|
44800
|
+
if (existsSync67(target) && !opts.force) {
|
|
44551
44801
|
error(`Knowledge file exists: ${filename}`, "Use --force to overwrite.");
|
|
44552
44802
|
process.exit(1);
|
|
44553
44803
|
}
|
|
@@ -44634,9 +44884,9 @@ function registerShow(council) {
|
|
|
44634
44884
|
console.log(` created: ${data.created_at}`);
|
|
44635
44885
|
console.log(` updated: ${data.updated_at}`);
|
|
44636
44886
|
const logFile = join64(getDebateDir(debateId), "round-log.md");
|
|
44637
|
-
if (
|
|
44887
|
+
if (existsSync67(logFile)) {
|
|
44638
44888
|
console.log("\n" + source_default.dim("\u2500\u2500\u2500 Round log \u2500\u2500\u2500"));
|
|
44639
|
-
console.log(
|
|
44889
|
+
console.log(readFileSync49(logFile, "utf-8"));
|
|
44640
44890
|
}
|
|
44641
44891
|
} catch (err) {
|
|
44642
44892
|
error(err.message);
|
|
@@ -44828,12 +45078,12 @@ var init_env_loader = __esm({
|
|
|
44828
45078
|
});
|
|
44829
45079
|
|
|
44830
45080
|
// src/lib/marketing/config.ts
|
|
44831
|
-
import { existsSync as
|
|
45081
|
+
import { existsSync as existsSync68, readFileSync as readFileSync50, writeFileSync as writeFileSync35, mkdirSync as mkdirSync28 } from "fs";
|
|
44832
45082
|
import { dirname as dirname37 } from "path";
|
|
44833
45083
|
function readEnvFile() {
|
|
44834
45084
|
const path2 = MARKETING_PATHS.envFile();
|
|
44835
|
-
if (!
|
|
44836
|
-
const raw =
|
|
45085
|
+
if (!existsSync68(path2)) return {};
|
|
45086
|
+
const raw = readFileSync50(path2, "utf8");
|
|
44837
45087
|
const parsed = parseEnv(raw);
|
|
44838
45088
|
if (parsed.errors.length > 0) {
|
|
44839
45089
|
for (const e of parsed.errors) {
|
|
@@ -44877,9 +45127,9 @@ function requireEnv(keys = REQUIRED_KEYS) {
|
|
|
44877
45127
|
}
|
|
44878
45128
|
function loadConfig() {
|
|
44879
45129
|
const path2 = MARKETING_PATHS.configFile();
|
|
44880
|
-
if (!
|
|
45130
|
+
if (!existsSync68(path2)) return { ...EMPTY_CONFIG, feature_flags: { ...EMPTY_CONFIG.feature_flags } };
|
|
44881
45131
|
try {
|
|
44882
|
-
const raw =
|
|
45132
|
+
const raw = readFileSync50(path2, "utf8");
|
|
44883
45133
|
const parsed = JSON.parse(raw);
|
|
44884
45134
|
return {
|
|
44885
45135
|
default_profile: parsed.default_profile ?? null,
|
|
@@ -44895,20 +45145,20 @@ function loadConfig() {
|
|
|
44895
45145
|
function writeConfig(cfg) {
|
|
44896
45146
|
const path2 = MARKETING_PATHS.configFile();
|
|
44897
45147
|
mkdirSync28(dirname37(path2), { recursive: true });
|
|
44898
|
-
|
|
45148
|
+
writeFileSync35(path2, JSON.stringify(cfg, null, 2) + "\n", "utf8");
|
|
44899
45149
|
}
|
|
44900
45150
|
function ensureConfigFile() {
|
|
44901
45151
|
const path2 = MARKETING_PATHS.configFile();
|
|
44902
|
-
if (
|
|
45152
|
+
if (existsSync68(path2)) return loadConfig();
|
|
44903
45153
|
const cfg = { ...EMPTY_CONFIG, feature_flags: { ...EMPTY_CONFIG.feature_flags } };
|
|
44904
45154
|
writeConfig(cfg);
|
|
44905
45155
|
return cfg;
|
|
44906
45156
|
}
|
|
44907
45157
|
function ensureEnvFile() {
|
|
44908
45158
|
const path2 = MARKETING_PATHS.envFile();
|
|
44909
|
-
if (
|
|
45159
|
+
if (existsSync68(path2)) return;
|
|
44910
45160
|
mkdirSync28(marketingRoot(), { recursive: true });
|
|
44911
|
-
|
|
45161
|
+
writeFileSync35(path2, ENV_TEMPLATE, { encoding: "utf8", mode: 384 });
|
|
44912
45162
|
}
|
|
44913
45163
|
var DEFAULT_API_VERSION, EMPTY_CONFIG, REQUIRED_KEYS, OPTIONAL_KEYS, ENV_TEMPLATE;
|
|
44914
45164
|
var init_config2 = __esm({
|
|
@@ -44948,8 +45198,8 @@ REINFLUENCE_BIN= # optional override; default uses .venv
|
|
|
44948
45198
|
});
|
|
44949
45199
|
|
|
44950
45200
|
// src/lib/marketing/bootstrap.ts
|
|
44951
|
-
import { spawn as
|
|
44952
|
-
import { existsSync as
|
|
45201
|
+
import { spawn as spawn5, spawnSync as spawnSync2 } from "child_process";
|
|
45202
|
+
import { existsSync as existsSync69, mkdirSync as mkdirSync29, cpSync as cpSync3 } from "fs";
|
|
44953
45203
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
44954
45204
|
import { dirname as dirname38, resolve as resolve17, join as join65 } from "path";
|
|
44955
45205
|
function findBundledReinfluence() {
|
|
@@ -44961,7 +45211,7 @@ function findBundledReinfluence() {
|
|
|
44961
45211
|
resolve17(__dirname7, "..", "..", "..", "tools", "reinfluence")
|
|
44962
45212
|
];
|
|
44963
45213
|
for (const c of candidates) {
|
|
44964
|
-
if (
|
|
45214
|
+
if (existsSync69(join65(c, "__main__.py"))) return c;
|
|
44965
45215
|
}
|
|
44966
45216
|
throw new Error(
|
|
44967
45217
|
"Bundled reinfluence not found. Reinstall dreamcontext or set REINFLUENCE_BIN."
|
|
@@ -45003,7 +45253,7 @@ async function bootstrapMarketing(opts = {}) {
|
|
|
45003
45253
|
throw new Error("python3 not found on PATH. Install Python 3.10+ and retry.");
|
|
45004
45254
|
}
|
|
45005
45255
|
const venv = MARKETING_PATHS.venvDir();
|
|
45006
|
-
if (!
|
|
45256
|
+
if (!existsSync69(MARKETING_PATHS.venvPython())) {
|
|
45007
45257
|
log(`creating venv \u2192 ${venv}`);
|
|
45008
45258
|
const r2 = runBlocking(py, ["-m", "venv", venv]);
|
|
45009
45259
|
if (r2.code !== 0) {
|
|
@@ -45040,7 +45290,7 @@ ${r.stderr.trim() || r.stdout.trim()}`);
|
|
|
45040
45290
|
function primeWhisper(model) {
|
|
45041
45291
|
return new Promise((resolveP) => {
|
|
45042
45292
|
const env2 = subprocessEnv();
|
|
45043
|
-
const proc =
|
|
45293
|
+
const proc = spawn5(MARKETING_PATHS.venvPython(), [
|
|
45044
45294
|
"-c",
|
|
45045
45295
|
`import whisper; whisper.load_model(${JSON.stringify(model)})`
|
|
45046
45296
|
], {
|
|
@@ -45074,7 +45324,7 @@ function subprocessEnv() {
|
|
|
45074
45324
|
};
|
|
45075
45325
|
}
|
|
45076
45326
|
function isBootstrapped() {
|
|
45077
|
-
return
|
|
45327
|
+
return existsSync69(MARKETING_PATHS.venvPython()) && existsSync69(join65(MARKETING_PATHS.reinfluenceDir(), "__main__.py"));
|
|
45078
45328
|
}
|
|
45079
45329
|
var __filename, __dirname7;
|
|
45080
45330
|
var init_bootstrap = __esm({
|
|
@@ -45151,7 +45401,7 @@ var init_init2 = __esm({
|
|
|
45151
45401
|
});
|
|
45152
45402
|
|
|
45153
45403
|
// src/lib/marketing/vision.ts
|
|
45154
|
-
import { existsSync as
|
|
45404
|
+
import { existsSync as existsSync70, readFileSync as readFileSync51, writeFileSync as writeFileSync36 } from "fs";
|
|
45155
45405
|
import { dirname as dirname39, join as join66 } from "path";
|
|
45156
45406
|
function pickVisionProvider(env2 = process.env) {
|
|
45157
45407
|
const oai = env2.OPENAI_VISION_API_KEY;
|
|
@@ -45191,11 +45441,11 @@ function parseLabelsFromText(text, allowlist = LABEL_ALLOWLIST) {
|
|
|
45191
45441
|
return out;
|
|
45192
45442
|
}
|
|
45193
45443
|
async function readImageAsBase64(framePath) {
|
|
45194
|
-
const buf =
|
|
45444
|
+
const buf = readFileSync51(framePath);
|
|
45195
45445
|
return buf.toString("base64");
|
|
45196
45446
|
}
|
|
45197
45447
|
async function labelHookFrame(framePath, opts) {
|
|
45198
|
-
if (!
|
|
45448
|
+
if (!existsSync70(framePath)) return [];
|
|
45199
45449
|
const fetcher = opts.fetcher ?? defaultFetcher;
|
|
45200
45450
|
const prompt = opts.promptOverride ?? PROMPT;
|
|
45201
45451
|
const b64 = await readImageAsBase64(framePath);
|
|
@@ -45245,7 +45495,7 @@ async function labelHookFrame(framePath, opts) {
|
|
|
45245
45495
|
return parseLabelsFromText(text);
|
|
45246
45496
|
}
|
|
45247
45497
|
async function runVisionPassOnPost(postJsonPath, opts = {}) {
|
|
45248
|
-
const raw =
|
|
45498
|
+
const raw = readFileSync51(postJsonPath, "utf-8");
|
|
45249
45499
|
const post = JSON.parse(raw);
|
|
45250
45500
|
const shortcode = post.shortcode ?? "?";
|
|
45251
45501
|
const provider = opts.provider && opts.apiKey ? { provider: opts.provider, apiKey: opts.apiKey } : pickVisionProvider();
|
|
@@ -45284,15 +45534,15 @@ async function runVisionPassOnPost(postJsonPath, opts = {}) {
|
|
|
45284
45534
|
post.pattern_tags = [...aggregated].sort();
|
|
45285
45535
|
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
45536
|
const tmp = postJsonPath + ".tmp";
|
|
45287
|
-
|
|
45537
|
+
writeFileSync36(tmp, JSON.stringify(post, null, 2) + "\n", "utf-8");
|
|
45288
45538
|
const fs = await import("fs");
|
|
45289
45539
|
fs.renameSync(tmp, postJsonPath);
|
|
45290
45540
|
const mdPath = join66(dirname39(postJsonPath), `${shortcode}.md`);
|
|
45291
|
-
if (
|
|
45541
|
+
if (existsSync70(mdPath)) {
|
|
45292
45542
|
try {
|
|
45293
|
-
const md =
|
|
45543
|
+
const md = readFileSync51(mdPath, "utf-8");
|
|
45294
45544
|
const refreshed = updatePatternTagsInBridge(md, post.pattern_tags);
|
|
45295
|
-
|
|
45545
|
+
writeFileSync36(mdPath, refreshed, "utf-8");
|
|
45296
45546
|
} catch {
|
|
45297
45547
|
}
|
|
45298
45548
|
}
|
|
@@ -45365,9 +45615,9 @@ Example output: ["talking-head","prop-driven"]`;
|
|
|
45365
45615
|
});
|
|
45366
45616
|
|
|
45367
45617
|
// src/lib/marketing/competitors.ts
|
|
45368
|
-
import { spawn as
|
|
45618
|
+
import { spawn as spawn6 } from "child_process";
|
|
45369
45619
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
45370
|
-
import { existsSync as
|
|
45620
|
+
import { existsSync as existsSync71, mkdirSync as mkdirSync31, statfsSync } from "fs";
|
|
45371
45621
|
import { dirname as dirname40, join as join67, basename as basename20, extname as extname4 } from "path";
|
|
45372
45622
|
function which(cmd) {
|
|
45373
45623
|
const r = spawnSync3(process.platform === "win32" ? "where" : "which", [cmd], { encoding: "utf8" });
|
|
@@ -45467,7 +45717,7 @@ ${h.installHints.join("\n")}`);
|
|
|
45467
45717
|
let postsIngested = 0;
|
|
45468
45718
|
try {
|
|
45469
45719
|
await new Promise((resolveP, rejectP) => {
|
|
45470
|
-
const proc =
|
|
45720
|
+
const proc = spawn6(MARKETING_PATHS.venvPython(), args, {
|
|
45471
45721
|
env: subprocessEnv(),
|
|
45472
45722
|
stdio: ["ignore", "pipe", "pipe"]
|
|
45473
45723
|
});
|
|
@@ -45578,7 +45828,7 @@ function persistPost(evt) {
|
|
|
45578
45828
|
const bridgePath = join67(postsDir, `${evt.shortcode}.md`);
|
|
45579
45829
|
writeJsonWithBridge(jsonPath, bridgePath, json, renderPostBridge(json));
|
|
45580
45830
|
const metaPath = join67(handleDir, "meta.json");
|
|
45581
|
-
if (!
|
|
45831
|
+
if (!existsSync71(metaPath)) {
|
|
45582
45832
|
writeJsonWithBridge(
|
|
45583
45833
|
metaPath,
|
|
45584
45834
|
join67(handleDir, "meta.md"),
|
|
@@ -45598,7 +45848,7 @@ First seen: ${(/* @__PURE__ */ new Date()).toISOString()}
|
|
|
45598
45848
|
return jsonPath;
|
|
45599
45849
|
}
|
|
45600
45850
|
function moveAsset(src, dest) {
|
|
45601
|
-
if (!
|
|
45851
|
+
if (!existsSync71(src)) return dest;
|
|
45602
45852
|
mkdirSync31(dirname40(dest), { recursive: true });
|
|
45603
45853
|
const fs = __require("fs");
|
|
45604
45854
|
try {
|
|
@@ -45660,7 +45910,7 @@ var init_competitors = __esm({
|
|
|
45660
45910
|
});
|
|
45661
45911
|
|
|
45662
45912
|
// src/cli/commands/marketing/competitor.ts
|
|
45663
|
-
import { existsSync as
|
|
45913
|
+
import { existsSync as existsSync72, readdirSync as readdirSync16, statSync as statSync11 } from "fs";
|
|
45664
45914
|
import { join as join68 } from "path";
|
|
45665
45915
|
function registerMarketingCompetitor(parent) {
|
|
45666
45916
|
const cmd = parent.command("competitor").description("Ingest competitor IG / YouTube content (Reinfluence pipeline).");
|
|
@@ -45711,7 +45961,7 @@ function registerMarketingCompetitor(parent) {
|
|
|
45711
45961
|
});
|
|
45712
45962
|
cmd.command("list").description("List ingested competitor handles.").action(() => {
|
|
45713
45963
|
const dir = MARKETING_PATHS.competitorsDir();
|
|
45714
|
-
if (!
|
|
45964
|
+
if (!existsSync72(dir)) {
|
|
45715
45965
|
info("No competitors ingested yet.");
|
|
45716
45966
|
return;
|
|
45717
45967
|
}
|
|
@@ -45731,7 +45981,7 @@ function registerMarketingCompetitor(parent) {
|
|
|
45731
45981
|
console.log(header("Competitors"));
|
|
45732
45982
|
for (const handle of handles) {
|
|
45733
45983
|
const postsDir = join68(dir, handle, "posts");
|
|
45734
|
-
const postCount =
|
|
45984
|
+
const postCount = existsSync72(postsDir) ? readdirSync16(postsDir).filter((f) => f.endsWith(".json")).length : 0;
|
|
45735
45985
|
console.log(` ${source_default.cyan("@" + handle)} ${source_default.dim(`${postCount} post(s)`)}`);
|
|
45736
45986
|
}
|
|
45737
45987
|
});
|
|
@@ -45744,11 +45994,11 @@ function registerMarketingCompetitor(parent) {
|
|
|
45744
45994
|
}
|
|
45745
45995
|
info(`Provider: ${provider.provider}`);
|
|
45746
45996
|
const competitorsDir = MARKETING_PATHS.competitorsDir();
|
|
45747
|
-
const handles = opts.handle ? [opts.handle] :
|
|
45997
|
+
const handles = opts.handle ? [opts.handle] : existsSync72(competitorsDir) ? readdirSync16(competitorsDir).filter((h) => !h.startsWith("_") && statSync11(join68(competitorsDir, h)).isDirectory()) : [];
|
|
45748
45998
|
const matches = [];
|
|
45749
45999
|
for (const h of handles) {
|
|
45750
46000
|
const candidate = join68(competitorsDir, h, "posts", `${shortcode}.json`);
|
|
45751
|
-
if (
|
|
46001
|
+
if (existsSync72(candidate)) matches.push(candidate);
|
|
45752
46002
|
}
|
|
45753
46003
|
if (matches.length === 0) {
|
|
45754
46004
|
error(`No post JSON found for shortcode "${shortcode}".`);
|
|
@@ -45783,7 +46033,7 @@ function registerMarketingCompetitor(parent) {
|
|
|
45783
46033
|
process.exit(1);
|
|
45784
46034
|
}
|
|
45785
46035
|
const competitorsDir = MARKETING_PATHS.competitorsDir();
|
|
45786
|
-
if (!
|
|
46036
|
+
if (!existsSync72(competitorsDir)) {
|
|
45787
46037
|
warn("No competitors directory yet \u2014 nothing to relabel.");
|
|
45788
46038
|
return;
|
|
45789
46039
|
}
|
|
@@ -45792,7 +46042,7 @@ function registerMarketingCompetitor(parent) {
|
|
|
45792
46042
|
let skipped = 0;
|
|
45793
46043
|
for (const h of handles) {
|
|
45794
46044
|
const postsDir = join68(competitorsDir, h, "posts");
|
|
45795
|
-
if (!
|
|
46045
|
+
if (!existsSync72(postsDir)) continue;
|
|
45796
46046
|
for (const f of readdirSync16(postsDir).filter((n) => n.endsWith(".json"))) {
|
|
45797
46047
|
const path2 = join68(postsDir, f);
|
|
45798
46048
|
if (opts.dryRun) {
|
|
@@ -45841,9 +46091,9 @@ var init_competitor = __esm({
|
|
|
45841
46091
|
});
|
|
45842
46092
|
|
|
45843
46093
|
// src/lib/marketing/meta-fetch.ts
|
|
45844
|
-
import { existsSync as
|
|
46094
|
+
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
46095
|
import { dirname as dirname41, basename as basename21 } from "path";
|
|
45846
|
-
import { randomUUID as
|
|
46096
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
45847
46097
|
function getQueue(accountId) {
|
|
45848
46098
|
let q = writeQueues.get(accountId);
|
|
45849
46099
|
if (!q) {
|
|
@@ -45892,9 +46142,9 @@ function idemCachePath(key) {
|
|
|
45892
46142
|
}
|
|
45893
46143
|
function readIdem(key) {
|
|
45894
46144
|
const p = idemCachePath(key);
|
|
45895
|
-
if (!
|
|
46145
|
+
if (!existsSync73(p)) return null;
|
|
45896
46146
|
try {
|
|
45897
|
-
return JSON.parse(
|
|
46147
|
+
return JSON.parse(readFileSync52(p, "utf8"));
|
|
45898
46148
|
} catch {
|
|
45899
46149
|
return null;
|
|
45900
46150
|
}
|
|
@@ -45902,7 +46152,7 @@ function readIdem(key) {
|
|
|
45902
46152
|
function writeIdem(rec) {
|
|
45903
46153
|
const p = idemCachePath(rec.key);
|
|
45904
46154
|
mkdirSync32(dirname41(p), { recursive: true });
|
|
45905
|
-
|
|
46155
|
+
writeFileSync37(p, JSON.stringify(rec, null, 2) + "\n", "utf8");
|
|
45906
46156
|
}
|
|
45907
46157
|
function backoffMs(attempt, hintSec) {
|
|
45908
46158
|
if (hintSec != null && Number.isFinite(hintSec) && hintSec > 0) {
|
|
@@ -46017,7 +46267,7 @@ async function metaFetch(ctx, init) {
|
|
|
46017
46267
|
}
|
|
46018
46268
|
let idemKey;
|
|
46019
46269
|
if (isCreate(init)) {
|
|
46020
|
-
idemKey =
|
|
46270
|
+
idemKey = randomUUID3();
|
|
46021
46271
|
const cached = readIdem(idemKey);
|
|
46022
46272
|
if (cached) {
|
|
46023
46273
|
logLine(ctx, `[idem] cache hit ${idemKey} on ${init.path}`);
|
|
@@ -46170,7 +46420,7 @@ async function singleShotVideoUpload(ctx, filepath, fields) {
|
|
|
46170
46420
|
if (fields.name) form.set("name", fields.name);
|
|
46171
46421
|
if (fields.title) form.set("title", fields.title);
|
|
46172
46422
|
if (fields.description) form.set("description", fields.description);
|
|
46173
|
-
const buffer =
|
|
46423
|
+
const buffer = readFileSync52(filepath);
|
|
46174
46424
|
const blob = new Blob([new Uint8Array(buffer)], { type: "video/mp4" });
|
|
46175
46425
|
form.set("source", blob, basename21(filepath));
|
|
46176
46426
|
const resp = await fetch(url, {
|
|
@@ -46219,7 +46469,7 @@ async function uploadImageFile(ctx, filepath) {
|
|
|
46219
46469
|
return withWriteSlot(ctx.adAccountId, async () => {
|
|
46220
46470
|
const url = buildUrl(ctx, { method: "POST", path: `${ctx.adAccountId}/adimages` });
|
|
46221
46471
|
const form = new FormData();
|
|
46222
|
-
const buffer =
|
|
46472
|
+
const buffer = readFileSync52(filepath);
|
|
46223
46473
|
const blob = new Blob([new Uint8Array(buffer)], { type: "image/png" });
|
|
46224
46474
|
form.set("filename", blob, basename21(filepath));
|
|
46225
46475
|
const resp = await fetch(url, {
|
|
@@ -46638,7 +46888,7 @@ var init_account = __esm({
|
|
|
46638
46888
|
});
|
|
46639
46889
|
|
|
46640
46890
|
// src/lib/marketing/hypothesis.ts
|
|
46641
|
-
import { existsSync as
|
|
46891
|
+
import { existsSync as existsSync74, readFileSync as readFileSync53 } from "fs";
|
|
46642
46892
|
function validateHypothesis(raw, options2 = {}) {
|
|
46643
46893
|
const errors = [];
|
|
46644
46894
|
const fieldErrors = {};
|
|
@@ -46705,12 +46955,12 @@ function validateHypothesis(raw, options2 = {}) {
|
|
|
46705
46955
|
};
|
|
46706
46956
|
}
|
|
46707
46957
|
function loadHypothesisFile(path2, options2 = {}) {
|
|
46708
|
-
if (!
|
|
46958
|
+
if (!existsSync74(path2)) {
|
|
46709
46959
|
return { ok: false, errors: [`Hypothesis file not found: ${path2}`] };
|
|
46710
46960
|
}
|
|
46711
46961
|
let parsed;
|
|
46712
46962
|
try {
|
|
46713
|
-
parsed = JSON.parse(
|
|
46963
|
+
parsed = JSON.parse(readFileSync53(path2, "utf8"));
|
|
46714
46964
|
} catch (e) {
|
|
46715
46965
|
return { ok: false, errors: [`Failed to parse JSON at ${path2}: ${e.message}`] };
|
|
46716
46966
|
}
|
|
@@ -46898,7 +47148,7 @@ var init_cohort2 = __esm({
|
|
|
46898
47148
|
});
|
|
46899
47149
|
|
|
46900
47150
|
// src/lib/marketing/insights-cache.ts
|
|
46901
|
-
import { existsSync as
|
|
47151
|
+
import { existsSync as existsSync75, readFileSync as readFileSync54, mkdirSync as mkdirSync33, writeFileSync as writeFileSync38, readdirSync as readdirSync17, statSync as statSync13 } from "fs";
|
|
46902
47152
|
import { join as join69 } from "path";
|
|
46903
47153
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
46904
47154
|
function snapshotFilename(entityId, pulledAt) {
|
|
@@ -46914,9 +47164,9 @@ function indexPath() {
|
|
|
46914
47164
|
}
|
|
46915
47165
|
function readIndex() {
|
|
46916
47166
|
const p = indexPath();
|
|
46917
|
-
if (!
|
|
47167
|
+
if (!existsSync75(p)) return { latest: {}, updated_at: "1970-01-01T00:00:00Z" };
|
|
46918
47168
|
try {
|
|
46919
|
-
return JSON.parse(
|
|
47169
|
+
return JSON.parse(readFileSync54(p, "utf8"));
|
|
46920
47170
|
} catch {
|
|
46921
47171
|
return { latest: {}, updated_at: "1970-01-01T00:00:00Z" };
|
|
46922
47172
|
}
|
|
@@ -46925,7 +47175,7 @@ function writeIndex(idx) {
|
|
|
46925
47175
|
const p = indexPath();
|
|
46926
47176
|
mkdirSync33(MARKETING_PATHS.insightsDir(), { recursive: true });
|
|
46927
47177
|
const tmp = `${p}.tmp.${process.pid}.${randomBytes3(4).toString("hex")}`;
|
|
46928
|
-
|
|
47178
|
+
writeFileSync38(tmp, JSON.stringify(idx, null, 2) + "\n", "utf8");
|
|
46929
47179
|
__require("fs").renameSync(tmp, p);
|
|
46930
47180
|
}
|
|
46931
47181
|
function saveInsightsSnapshot(snap) {
|
|
@@ -46933,7 +47183,7 @@ function saveInsightsSnapshot(snap) {
|
|
|
46933
47183
|
const filename = snapshotFilename(snap.entity_id, new Date(snap.pulled_at));
|
|
46934
47184
|
const fullPath = join69(MARKETING_PATHS.insightsDir(), filename);
|
|
46935
47185
|
const tmp = `${fullPath}.tmp.${process.pid}.${randomBytes3(4).toString("hex")}`;
|
|
46936
|
-
|
|
47186
|
+
writeFileSync38(tmp, JSON.stringify(snap, null, 2) + "\n", "utf8");
|
|
46937
47187
|
__require("fs").renameSync(tmp, fullPath);
|
|
46938
47188
|
const idx = readIndex();
|
|
46939
47189
|
idx.latest[snap.entity_id] = filename;
|
|
@@ -46946,9 +47196,9 @@ function getCachedInsights(entityId) {
|
|
|
46946
47196
|
const filename = idx.latest[entityId];
|
|
46947
47197
|
if (!filename) return null;
|
|
46948
47198
|
const fullPath = join69(MARKETING_PATHS.insightsDir(), filename);
|
|
46949
|
-
if (!
|
|
47199
|
+
if (!existsSync75(fullPath)) return null;
|
|
46950
47200
|
try {
|
|
46951
|
-
const snap = JSON.parse(
|
|
47201
|
+
const snap = JSON.parse(readFileSync54(fullPath, "utf8"));
|
|
46952
47202
|
const ageMs = Date.now() - new Date(snap.pulled_at).getTime();
|
|
46953
47203
|
if (ageMs > INSIGHTS_TTL_MS) return null;
|
|
46954
47204
|
return snap;
|
|
@@ -46961,16 +47211,16 @@ function getLatestSnapshot(entityId) {
|
|
|
46961
47211
|
const filename = idx.latest[entityId];
|
|
46962
47212
|
if (!filename) return null;
|
|
46963
47213
|
const fullPath = join69(MARKETING_PATHS.insightsDir(), filename);
|
|
46964
|
-
if (!
|
|
47214
|
+
if (!existsSync75(fullPath)) return null;
|
|
46965
47215
|
try {
|
|
46966
|
-
return JSON.parse(
|
|
47216
|
+
return JSON.parse(readFileSync54(fullPath, "utf8"));
|
|
46967
47217
|
} catch {
|
|
46968
47218
|
return null;
|
|
46969
47219
|
}
|
|
46970
47220
|
}
|
|
46971
47221
|
function getPriorSnapshot(entityId, beforeMs) {
|
|
46972
47222
|
const dir = MARKETING_PATHS.insightsDir();
|
|
46973
|
-
if (!
|
|
47223
|
+
if (!existsSync75(dir)) return null;
|
|
46974
47224
|
const safe = entityId.replace(/[^A-Za-z0-9_-]/g, "_");
|
|
46975
47225
|
const candidates = readdirSync17(dir).filter((f) => f.startsWith(`${safe}__`) && f.endsWith(".json")).map((f) => {
|
|
46976
47226
|
const p = join69(dir, f);
|
|
@@ -46981,7 +47231,7 @@ function getPriorSnapshot(entityId, beforeMs) {
|
|
|
46981
47231
|
for (const c of candidates) {
|
|
46982
47232
|
if (c.mtimeMs <= cutoff) {
|
|
46983
47233
|
try {
|
|
46984
|
-
return JSON.parse(
|
|
47234
|
+
return JSON.parse(readFileSync54(c.p, "utf8"));
|
|
46985
47235
|
} catch {
|
|
46986
47236
|
continue;
|
|
46987
47237
|
}
|
|
@@ -47617,7 +47867,7 @@ var init_kill = __esm({
|
|
|
47617
47867
|
});
|
|
47618
47868
|
|
|
47619
47869
|
// src/cli/commands/marketing/doctor.ts
|
|
47620
|
-
import { readFileSync as
|
|
47870
|
+
import { readFileSync as readFileSync55, readdirSync as readdirSync18, statSync as statSync14 } from "fs";
|
|
47621
47871
|
import { join as join70 } from "path";
|
|
47622
47872
|
function registerMarketingDoctor(parent) {
|
|
47623
47873
|
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 +47949,7 @@ function scanForSecrets(root) {
|
|
|
47699
47949
|
for (const file of walkText(root)) {
|
|
47700
47950
|
let txt;
|
|
47701
47951
|
try {
|
|
47702
|
-
txt =
|
|
47952
|
+
txt = readFileSync55(file, "utf8");
|
|
47703
47953
|
} catch {
|
|
47704
47954
|
continue;
|
|
47705
47955
|
}
|
|
@@ -47764,7 +48014,7 @@ var init_doctor2 = __esm({
|
|
|
47764
48014
|
});
|
|
47765
48015
|
|
|
47766
48016
|
// src/lib/marketing/entity-store.ts
|
|
47767
|
-
import { existsSync as
|
|
48017
|
+
import { existsSync as existsSync77, readFileSync as readFileSync56, readdirSync as readdirSync19 } from "fs";
|
|
47768
48018
|
import { join as join71 } from "path";
|
|
47769
48019
|
function dirFor(kind) {
|
|
47770
48020
|
switch (kind) {
|
|
@@ -47788,20 +48038,20 @@ function entityPaths(kind, id) {
|
|
|
47788
48038
|
}
|
|
47789
48039
|
function loadEntity(kind, id) {
|
|
47790
48040
|
const { json } = entityPaths(kind, id);
|
|
47791
|
-
if (!
|
|
48041
|
+
if (!existsSync77(json)) return null;
|
|
47792
48042
|
try {
|
|
47793
|
-
return JSON.parse(
|
|
48043
|
+
return JSON.parse(readFileSync56(json, "utf8"));
|
|
47794
48044
|
} catch {
|
|
47795
48045
|
return null;
|
|
47796
48046
|
}
|
|
47797
48047
|
}
|
|
47798
48048
|
function listEntities(kind) {
|
|
47799
48049
|
const d = dirFor(kind);
|
|
47800
|
-
if (!
|
|
48050
|
+
if (!existsSync77(d)) return [];
|
|
47801
48051
|
const out = [];
|
|
47802
48052
|
for (const f of readdirSync19(d).filter((x) => x.endsWith(".json"))) {
|
|
47803
48053
|
try {
|
|
47804
|
-
out.push(JSON.parse(
|
|
48054
|
+
out.push(JSON.parse(readFileSync56(join71(d, f), "utf8")));
|
|
47805
48055
|
} catch {
|
|
47806
48056
|
}
|
|
47807
48057
|
}
|
|
@@ -47995,7 +48245,7 @@ var init_campaign = __esm({
|
|
|
47995
48245
|
});
|
|
47996
48246
|
|
|
47997
48247
|
// src/cli/commands/marketing/adset.ts
|
|
47998
|
-
import { existsSync as
|
|
48248
|
+
import { existsSync as existsSync78, readFileSync as readFileSync57 } from "fs";
|
|
47999
48249
|
function registerMarketingAdSet(parent) {
|
|
48000
48250
|
const cmd = parent.command("adset").description("Manage adsets.");
|
|
48001
48251
|
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 +48265,13 @@ function registerMarketingAdSet(parent) {
|
|
|
48015
48265
|
}
|
|
48016
48266
|
throw e;
|
|
48017
48267
|
}
|
|
48018
|
-
if (!
|
|
48268
|
+
if (!existsSync78(opts.targeting)) {
|
|
48019
48269
|
error(`Targeting file not found: ${opts.targeting}`);
|
|
48020
48270
|
process.exit(1);
|
|
48021
48271
|
}
|
|
48022
48272
|
let targeting;
|
|
48023
48273
|
try {
|
|
48024
|
-
targeting = JSON.parse(
|
|
48274
|
+
targeting = JSON.parse(readFileSync57(opts.targeting, "utf8"));
|
|
48025
48275
|
} catch (e) {
|
|
48026
48276
|
error(`Failed to parse targeting JSON: ${e.message}`);
|
|
48027
48277
|
process.exit(1);
|
|
@@ -48278,12 +48528,12 @@ var init_creative = __esm({
|
|
|
48278
48528
|
});
|
|
48279
48529
|
|
|
48280
48530
|
// src/cli/commands/marketing/asset.ts
|
|
48281
|
-
import { existsSync as
|
|
48531
|
+
import { existsSync as existsSync79, statSync as statSync15 } from "fs";
|
|
48282
48532
|
import { extname as extname5 } from "path";
|
|
48283
48533
|
function registerMarketingAsset(parent) {
|
|
48284
48534
|
const cmd = parent.command("asset").description("Upload creative assets to Meta.");
|
|
48285
48535
|
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 (!
|
|
48536
|
+
if (!existsSync79(path2)) {
|
|
48287
48537
|
error(`File not found: ${path2}`);
|
|
48288
48538
|
process.exit(1);
|
|
48289
48539
|
}
|
|
@@ -48451,7 +48701,7 @@ var init_ad = __esm({
|
|
|
48451
48701
|
});
|
|
48452
48702
|
|
|
48453
48703
|
// src/lib/marketing/launch.ts
|
|
48454
|
-
import { existsSync as
|
|
48704
|
+
import { existsSync as existsSync80, readFileSync as readFileSync58, writeFileSync as writeFileSync39, mkdirSync as mkdirSync34, renameSync as renameSync8, readdirSync as readdirSync20 } from "fs";
|
|
48455
48705
|
import { dirname as dirname42, join as join72, basename as basename22 } from "path";
|
|
48456
48706
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
48457
48707
|
function buildLaunchSummary(cohortId) {
|
|
@@ -48498,13 +48748,13 @@ function isoTs2() {
|
|
|
48498
48748
|
function atomicWriteFile3(path2, data) {
|
|
48499
48749
|
mkdirSync34(dirname42(path2), { recursive: true });
|
|
48500
48750
|
const tmp = `${path2}.tmp.${process.pid}.${randomBytes4(4).toString("hex")}`;
|
|
48501
|
-
|
|
48751
|
+
writeFileSync39(tmp, data, "utf8");
|
|
48502
48752
|
renameSync8(tmp, path2);
|
|
48503
48753
|
}
|
|
48504
48754
|
function readWal(path2) {
|
|
48505
|
-
if (!
|
|
48755
|
+
if (!existsSync80(path2)) return null;
|
|
48506
48756
|
try {
|
|
48507
|
-
return JSON.parse(
|
|
48757
|
+
return JSON.parse(readFileSync58(path2, "utf8"));
|
|
48508
48758
|
} catch {
|
|
48509
48759
|
return null;
|
|
48510
48760
|
}
|
|
@@ -48514,7 +48764,7 @@ function writeWal(path2, wal) {
|
|
|
48514
48764
|
}
|
|
48515
48765
|
function findWalByRunId(runId) {
|
|
48516
48766
|
const dir = MARKETING_PATHS.runsDir();
|
|
48517
|
-
if (!
|
|
48767
|
+
if (!existsSync80(dir)) return null;
|
|
48518
48768
|
for (const f of readdirSync20(dir)) {
|
|
48519
48769
|
if (!f.endsWith(".json")) continue;
|
|
48520
48770
|
if (f.startsWith("by-idem")) continue;
|
|
@@ -48791,7 +49041,7 @@ var init_launch2 = __esm({
|
|
|
48791
49041
|
});
|
|
48792
49042
|
|
|
48793
49043
|
// src/cli/commands/marketing/learnings.ts
|
|
48794
|
-
import { existsSync as
|
|
49044
|
+
import { existsSync as existsSync81, readFileSync as readFileSync59 } from "fs";
|
|
48795
49045
|
function registerMarketingLearnings(parent) {
|
|
48796
49046
|
const cmd = parent.command("learnings").description("Performance Monitor learnings ledger (per-day .md + index).");
|
|
48797
49047
|
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 +49184,8 @@ async function resolveBody(body, bodyFile) {
|
|
|
48934
49184
|
if (body) return body;
|
|
48935
49185
|
if (bodyFile === "-") return readStdin3();
|
|
48936
49186
|
if (bodyFile) {
|
|
48937
|
-
if (!
|
|
48938
|
-
return
|
|
49187
|
+
if (!existsSync81(bodyFile)) throw new Error(`Body file not found: ${bodyFile}`);
|
|
49188
|
+
return readFileSync59(bodyFile, "utf8");
|
|
48939
49189
|
}
|
|
48940
49190
|
return null;
|
|
48941
49191
|
}
|
|
@@ -48965,10 +49215,10 @@ var init_learnings2 = __esm({
|
|
|
48965
49215
|
|
|
48966
49216
|
// src/lib/marketing/rem-sleep.ts
|
|
48967
49217
|
import {
|
|
48968
|
-
existsSync as
|
|
49218
|
+
existsSync as existsSync82,
|
|
48969
49219
|
mkdirSync as mkdirSync35,
|
|
48970
|
-
readFileSync as
|
|
48971
|
-
writeFileSync as
|
|
49220
|
+
readFileSync as readFileSync60,
|
|
49221
|
+
writeFileSync as writeFileSync40,
|
|
48972
49222
|
readdirSync as readdirSync21,
|
|
48973
49223
|
statSync as statSync16,
|
|
48974
49224
|
unlinkSync as unlinkSync3,
|
|
@@ -48979,13 +49229,13 @@ import { randomBytes as randomBytes5 } from "crypto";
|
|
|
48979
49229
|
function atomicWriteFile4(path2, data) {
|
|
48980
49230
|
mkdirSync35(dirname43(path2), { recursive: true });
|
|
48981
49231
|
const tmp = `${path2}.tmp.${process.pid}.${randomBytes5(4).toString("hex")}`;
|
|
48982
|
-
|
|
49232
|
+
writeFileSync40(tmp, data, "utf8");
|
|
48983
49233
|
renameSync9(tmp, path2);
|
|
48984
49234
|
}
|
|
48985
49235
|
function pruneRuns(opts = {}) {
|
|
48986
49236
|
const keepLast = opts.keepLast ?? 100;
|
|
48987
49237
|
const dir = MARKETING_PATHS.runsDir();
|
|
48988
|
-
if (!
|
|
49238
|
+
if (!existsSync82(dir)) return { scanned: 0, kept: 0, deleted: 0, deletedFiles: [] };
|
|
48989
49239
|
const files = readdirSync21(dir).filter((f) => f.endsWith(".json")).map((f) => {
|
|
48990
49240
|
const p = join73(dir, f);
|
|
48991
49241
|
try {
|
|
@@ -49021,7 +49271,7 @@ function compactInsights(opts = {}) {
|
|
|
49021
49271
|
const weeklyAfterDays = opts.weeklyAfterDays ?? 14;
|
|
49022
49272
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
49023
49273
|
const dir = MARKETING_PATHS.insightsDir();
|
|
49024
|
-
if (!
|
|
49274
|
+
if (!existsSync82(dir)) return { scanned: 0, kept: 0, deleted: 0, deletedFiles: [] };
|
|
49025
49275
|
const files = [];
|
|
49026
49276
|
for (const f of readdirSync21(dir)) {
|
|
49027
49277
|
if (!f.endsWith(".json") || f.startsWith("_")) continue;
|
|
@@ -49093,7 +49343,7 @@ function mergeDailyLearnings(opts = {}) {
|
|
|
49093
49343
|
const retainDays = opts.retainDays ?? 7;
|
|
49094
49344
|
const now = opts.now ?? /* @__PURE__ */ new Date();
|
|
49095
49345
|
const dir = MARKETING_PATHS.learningsDir();
|
|
49096
|
-
if (!
|
|
49346
|
+
if (!existsSync82(dir)) {
|
|
49097
49347
|
return { scanned: 0, merged: 0, archivePath: null, droppedRejected: 0, mergedFiles: [] };
|
|
49098
49348
|
}
|
|
49099
49349
|
const dayMs = 24 * 60 * 60 * 1e3;
|
|
@@ -49121,7 +49371,7 @@ function mergeDailyLearnings(opts = {}) {
|
|
|
49121
49371
|
const archivePath = join73(dir, `_archive-${q}.md`);
|
|
49122
49372
|
list.sort((a, b) => a.date.localeCompare(b.date));
|
|
49123
49373
|
for (const c of list) {
|
|
49124
|
-
const existingArchive =
|
|
49374
|
+
const existingArchive = existsSync82(archivePath) ? readFileSync60(archivePath, "utf8") : `# Marketing learnings archive \u2014 ${q}
|
|
49125
49375
|
`;
|
|
49126
49376
|
const dateMarker = `# Marketing learnings \u2014 ${c.date}`;
|
|
49127
49377
|
const alreadyMerged = existingArchive.includes(dateMarker);
|
|
@@ -49130,7 +49380,7 @@ function mergeDailyLearnings(opts = {}) {
|
|
|
49130
49380
|
continue;
|
|
49131
49381
|
}
|
|
49132
49382
|
if (!alreadyMerged) {
|
|
49133
|
-
const body =
|
|
49383
|
+
const body = readFileSync60(c.p, "utf8").trimEnd();
|
|
49134
49384
|
const next2 = existingArchive.trimEnd() + "\n\n" + body + "\n";
|
|
49135
49385
|
atomicWriteFile4(archivePath, next2);
|
|
49136
49386
|
}
|
|
@@ -49173,14 +49423,14 @@ function quarterKey(yyyymmdd) {
|
|
|
49173
49423
|
}
|
|
49174
49424
|
function redactRunsSweep(opts = {}) {
|
|
49175
49425
|
const dir = MARKETING_PATHS.runsDir();
|
|
49176
|
-
if (!
|
|
49426
|
+
if (!existsSync82(dir)) return { scanned: 0, rewritten: 0, rewrittenFiles: [] };
|
|
49177
49427
|
const files = readdirSync21(dir).filter((f) => f.endsWith(".json"));
|
|
49178
49428
|
const rewrittenFiles = [];
|
|
49179
49429
|
for (const f of files) {
|
|
49180
49430
|
const p = join73(dir, f);
|
|
49181
49431
|
let raw;
|
|
49182
49432
|
try {
|
|
49183
|
-
raw =
|
|
49433
|
+
raw = readFileSync60(p, "utf8");
|
|
49184
49434
|
} catch {
|
|
49185
49435
|
continue;
|
|
49186
49436
|
}
|
|
@@ -49202,7 +49452,7 @@ function redactRunsSweep(opts = {}) {
|
|
|
49202
49452
|
function runRemSleep(opts = {}) {
|
|
49203
49453
|
const ranAt = (opts.now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
49204
49454
|
const root = marketingRootIfExists();
|
|
49205
|
-
if (!root || !
|
|
49455
|
+
if (!root || !existsSync82(root)) {
|
|
49206
49456
|
return {
|
|
49207
49457
|
ranAt,
|
|
49208
49458
|
marketingPresent: false,
|
|
@@ -49321,7 +49571,7 @@ var init_git_guard = __esm({
|
|
|
49321
49571
|
});
|
|
49322
49572
|
|
|
49323
49573
|
// src/cli/commands/marketing/hooks.ts
|
|
49324
|
-
import { existsSync as
|
|
49574
|
+
import { existsSync as existsSync83, readFileSync as readFileSync61, writeFileSync as writeFileSync41, chmodSync as chmodSync3, mkdirSync as mkdirSync36, statSync as statSync17 } from "fs";
|
|
49325
49575
|
import { execFileSync as execFileSync6 } from "child_process";
|
|
49326
49576
|
import { join as join74 } from "path";
|
|
49327
49577
|
function findGitDir(cwd = process.cwd()) {
|
|
@@ -49366,8 +49616,8 @@ function registerMarketingHooks(parent) {
|
|
|
49366
49616
|
const hooksDir = join74(gitDir, "hooks");
|
|
49367
49617
|
mkdirSync36(hooksDir, { recursive: true });
|
|
49368
49618
|
const target = join74(hooksDir, "pre-commit");
|
|
49369
|
-
if (
|
|
49370
|
-
const existing =
|
|
49619
|
+
if (existsSync83(target)) {
|
|
49620
|
+
const existing = readFileSync61(target, "utf-8");
|
|
49371
49621
|
if (existing.includes(MANAGED_MARKER)) {
|
|
49372
49622
|
info("pre-commit hook already managed by dreamcontext \u2014 refreshing.");
|
|
49373
49623
|
} else if (!opts.force) {
|
|
@@ -49379,7 +49629,7 @@ function registerMarketingHooks(parent) {
|
|
|
49379
49629
|
warn("Overwriting existing pre-commit hook (--force).");
|
|
49380
49630
|
}
|
|
49381
49631
|
}
|
|
49382
|
-
|
|
49632
|
+
writeFileSync41(target, HOOK_LAUNCHER, "utf-8");
|
|
49383
49633
|
try {
|
|
49384
49634
|
chmodSync3(target, 493);
|
|
49385
49635
|
} catch {
|
|
@@ -49418,7 +49668,7 @@ exec dreamcontext mk hooks check-staged
|
|
|
49418
49668
|
});
|
|
49419
49669
|
|
|
49420
49670
|
// src/lib/marketing/council-personas.ts
|
|
49421
|
-
import { existsSync as
|
|
49671
|
+
import { existsSync as existsSync84, readFileSync as readFileSync62, readdirSync as readdirSync22 } from "fs";
|
|
49422
49672
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
49423
49673
|
import { join as join75, dirname as dirname44 } from "path";
|
|
49424
49674
|
function findPersonasDir() {
|
|
@@ -49432,12 +49682,12 @@ function findPersonasDir() {
|
|
|
49432
49682
|
join75(__dirname_local, "..", "..", PERSONA_SUBPATH)
|
|
49433
49683
|
];
|
|
49434
49684
|
for (const candidate of candidates) {
|
|
49435
|
-
if (
|
|
49685
|
+
if (existsSync84(candidate)) return candidate;
|
|
49436
49686
|
}
|
|
49437
49687
|
return null;
|
|
49438
49688
|
}
|
|
49439
49689
|
function parsePersonaFile(filePath) {
|
|
49440
|
-
const raw =
|
|
49690
|
+
const raw = readFileSync62(filePath, "utf-8");
|
|
49441
49691
|
const parsed = (0, import_gray_matter5.default)(raw);
|
|
49442
49692
|
const data = parsed.data;
|
|
49443
49693
|
const slug = typeof data.slug === "string" ? data.slug.trim() : "";
|
|
@@ -49457,7 +49707,7 @@ function parsePersonaFile(filePath) {
|
|
|
49457
49707
|
}
|
|
49458
49708
|
function loadAllPersonas(personasDir) {
|
|
49459
49709
|
const dir = personasDir ?? findPersonasDir();
|
|
49460
|
-
if (!dir || !
|
|
49710
|
+
if (!dir || !existsSync84(dir)) return [];
|
|
49461
49711
|
const files = readdirSync22(dir).filter((n) => n.endsWith(".md")).sort();
|
|
49462
49712
|
return files.map((name) => parsePersonaFile(join75(dir, name)));
|
|
49463
49713
|
}
|
|
@@ -49490,11 +49740,11 @@ var init_council_personas = __esm({
|
|
|
49490
49740
|
|
|
49491
49741
|
// src/cli/commands/marketing/council.ts
|
|
49492
49742
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
49493
|
-
import { existsSync as
|
|
49743
|
+
import { existsSync as existsSync85 } from "fs";
|
|
49494
49744
|
function resolveDreamcontextEntry() {
|
|
49495
49745
|
const node = process.argv[0];
|
|
49496
49746
|
const script = process.argv[1];
|
|
49497
|
-
if (script &&
|
|
49747
|
+
if (script && existsSync85(script)) {
|
|
49498
49748
|
return { node, script };
|
|
49499
49749
|
}
|
|
49500
49750
|
return { node, script: null };
|
|
@@ -49666,7 +49916,7 @@ var init_marketing = __esm({
|
|
|
49666
49916
|
});
|
|
49667
49917
|
|
|
49668
49918
|
// src/cli/commands/memory.ts
|
|
49669
|
-
import { existsSync as
|
|
49919
|
+
import { existsSync as existsSync86, unlinkSync as unlinkSync4 } from "fs";
|
|
49670
49920
|
import { join as join76, dirname as dirname45 } from "path";
|
|
49671
49921
|
function collectVault(value, previous) {
|
|
49672
49922
|
return [...previous, value];
|
|
@@ -49851,7 +50101,7 @@ function registerMemoryCommand(program2) {
|
|
|
49851
50101
|
async (slug, opts) => {
|
|
49852
50102
|
const root = ensureContextRoot();
|
|
49853
50103
|
const filePath = join76(root, "knowledge", `${slug}.md`);
|
|
49854
|
-
if (!
|
|
50104
|
+
if (!existsSync86(filePath)) {
|
|
49855
50105
|
error(`Knowledge file not found: ${slug}.md`);
|
|
49856
50106
|
return;
|
|
49857
50107
|
}
|
|
@@ -49899,7 +50149,7 @@ ${opts.append}
|
|
|
49899
50149
|
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
50150
|
const root = ensureContextRoot();
|
|
49901
50151
|
const filePath = join76(root, "knowledge", `${slug}.md`);
|
|
49902
|
-
if (!
|
|
50152
|
+
if (!existsSync86(filePath)) {
|
|
49903
50153
|
error(`Knowledge file not found: ${slug}.md`);
|
|
49904
50154
|
return;
|
|
49905
50155
|
}
|
|
@@ -50420,17 +50670,17 @@ var init_connections3 = __esm({
|
|
|
50420
50670
|
});
|
|
50421
50671
|
|
|
50422
50672
|
// src/lib/federation-ingest.ts
|
|
50423
|
-
import { existsSync as
|
|
50673
|
+
import { existsSync as existsSync87, mkdirSync as mkdirSync37 } from "fs";
|
|
50424
50674
|
import { join as join77 } from "path";
|
|
50425
50675
|
function ingestEntry(contextRoot, entry) {
|
|
50426
50676
|
const knowledgeDir = join77(contextRoot, "knowledge");
|
|
50427
50677
|
mkdirSync37(knowledgeDir, { recursive: true });
|
|
50428
50678
|
const baseSlug = slugFromTitle(entry.title);
|
|
50429
50679
|
const canonicalPath = join77(knowledgeDir, `${baseSlug}.md`);
|
|
50430
|
-
const collided =
|
|
50680
|
+
const collided = existsSync87(canonicalPath);
|
|
50431
50681
|
const slug = collided ? `${baseSlug}--from-${sanitizeVault(entry.origin.vault)}` : baseSlug;
|
|
50432
50682
|
const targetPath = join77(knowledgeDir, `${slug}.md`);
|
|
50433
|
-
if (!
|
|
50683
|
+
if (!existsSync87(targetPath)) {
|
|
50434
50684
|
writeFrontmatter(
|
|
50435
50685
|
targetPath,
|
|
50436
50686
|
{
|
|
@@ -50722,7 +50972,7 @@ var init_people = __esm({
|
|
|
50722
50972
|
|
|
50723
50973
|
// src/cli/commands/config.ts
|
|
50724
50974
|
import { dirname as dirname49 } from "path";
|
|
50725
|
-
import { existsSync as
|
|
50975
|
+
import { existsSync as existsSync88, readFileSync as readFileSync64, writeFileSync as writeFileSync43 } from "fs";
|
|
50726
50976
|
import { join as join78 } from "path";
|
|
50727
50977
|
function resolveProjectRoot() {
|
|
50728
50978
|
const contextRoot = resolveContextRoot();
|
|
@@ -50984,12 +51234,12 @@ function registerConfigCommand(program2) {
|
|
|
50984
51234
|
let userMdSynced = false;
|
|
50985
51235
|
if (contextRoot) {
|
|
50986
51236
|
const userMdPath = join78(contextRoot, "core", "1.user.md");
|
|
50987
|
-
if (
|
|
51237
|
+
if (existsSync88(userMdPath)) {
|
|
50988
51238
|
try {
|
|
50989
|
-
const before =
|
|
51239
|
+
const before = readFileSync64(userMdPath, "utf-8");
|
|
50990
51240
|
const after = ensurePeopleSection(before, roster);
|
|
50991
51241
|
if (after !== before) {
|
|
50992
|
-
|
|
51242
|
+
writeFileSync43(userMdPath, after, "utf-8");
|
|
50993
51243
|
userMdSynced = true;
|
|
50994
51244
|
}
|
|
50995
51245
|
} catch (err) {
|
|
@@ -51074,8 +51324,8 @@ function registerConfigCommand(program2) {
|
|
|
51074
51324
|
if (!value) {
|
|
51075
51325
|
if (!process.stdin.isTTY) {
|
|
51076
51326
|
try {
|
|
51077
|
-
const { readFileSync:
|
|
51078
|
-
value =
|
|
51327
|
+
const { readFileSync: readFileSync65 } = await import("fs");
|
|
51328
|
+
value = readFileSync65(0, "utf-8").trim();
|
|
51079
51329
|
} catch {
|
|
51080
51330
|
value = "";
|
|
51081
51331
|
}
|