@tekmidian/pai 1.0.0 → 1.0.3
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/.claude-plugin/plugin.json +1 -1
- package/README.md +67 -5
- package/dist/aibroker-client-BxzeEHPF.mjs +3 -0
- package/dist/{aibroker-client-CXEYBzbf.mjs → aibroker-client-CQPGqLxL.mjs} +1 -1
- package/dist/atomic-file-BorMa4T3.mjs +21 -0
- package/dist/{auto-route-D5SXrMpB.mjs → auto-route-B7Yu6Uam.mjs} +3 -3
- package/dist/auto-route-CjjQqU1o.mjs +11 -0
- package/dist/budget-Dod6rnA9.mjs +15 -0
- package/dist/{caller-identity-CVTuiLSs.mjs → caller-identity-yLFb7CKq.mjs} +6 -5
- package/dist/{capacity-DaXrVj3J.mjs → capacity-DEveQdFV.mjs} +3 -3
- package/dist/{chain-BcQlIlEd.mjs → chain-7n9Gx56r.mjs} +5 -5
- package/dist/cli/index.mjs +1628 -370
- package/dist/{cockpit-actions-ODmt8yF9.mjs → cockpit-actions-BBHeyEZI.mjs} +84 -42
- package/dist/cockpit-actions-DR9X514g.mjs +20 -0
- package/dist/cockpit-memory--dnShXBA.mjs +20 -0
- package/dist/{config-BSXKyeJ1.mjs → config-Bu1_vbY8.mjs} +42 -3
- package/dist/{config-B955yYmo.mjs → config-Cxi-aBf4.mjs} +2 -2
- package/dist/{config-TaWmdTLx.mjs → config-DtENJ6cL.mjs} +1 -1
- package/dist/{config-D5chi2LO.mjs → config-XpZWOYOG.mjs} +2 -2
- package/dist/{controls-BGkK_Bdi.mjs → controls-CPoeudou.mjs} +37 -22
- package/dist/daemon/index.mjs +43 -42
- package/dist/daemon-DKdBNKfa.mjs +45 -0
- package/dist/{daemon-CorGh6Ub.mjs → daemon-DPAo6WTa.mjs} +103 -55
- package/dist/daemon-mcp/index.mjs +40 -39
- package/dist/{define-DGFu-sCf.mjs → define-CjJsmq-6.mjs} +1 -1
- package/dist/{detect-C1d5cUkT.mjs → detect-9CZNO0yf.mjs} +2 -2
- package/dist/detect-D1ziFFfA.mjs +10 -0
- package/dist/{embed-pass-CeQD8kRE.mjs → embed-pass-DIWjA68P.mjs} +5 -5
- package/dist/{embedding-gate-BHuBsgHD.mjs → embedding-gate-6rZrWRXa.mjs} +5 -5
- package/dist/{embedding-gate-Z7CJSOJk.mjs → embedding-gate-Cnk4YCyX.mjs} +3 -3
- package/dist/{embeddings-D4t6L-EH.mjs → embeddings-BVq3esBF.mjs} +1 -1
- package/dist/{embeddings-OF9Pt4by.mjs → embeddings-CIkJBKd-.mjs} +1 -1
- package/dist/{endreason-x1KOSrcO.mjs → endreason-C577xIQz.mjs} +7 -6
- package/dist/{env-DArqGq-Z.mjs → env-BE8mrsxr.mjs} +1 -1
- package/dist/factory-Bsib-qDG.mjs +9 -0
- package/dist/{factory-BtjbQ0np.mjs → factory-DjAAsqr_.mjs} +15 -13
- package/dist/{fallback-BIyEpPsQ.mjs → fallback-DFlItw1Z.mjs} +5 -5
- package/dist/{fmt-age-BiSHrTKN.mjs → fmt-age-ByDkvkoU.mjs} +1 -1
- package/dist/{health-C6jZWvRG.mjs → health-Dnym-qcT.mjs} +4 -4
- package/dist/{helpers-DFmYRCOa.mjs → helpers-BD6V-p9w.mjs} +2 -2
- package/dist/helpers-CMGjy_0N.mjs +10 -0
- package/dist/{helpers-CJpb_MNB.mjs → helpers-CRuBUas3.mjs} +87 -38
- package/dist/hooks/capture-all-events.mjs +52 -11
- package/dist/hooks/capture-session-summary.mjs +64 -47
- package/dist/hooks/capture-tool-output.mjs +49 -8
- package/dist/hooks/context-compression-hook.mjs +30 -10
- package/dist/hooks/initialize-session.mjs +1 -0
- package/dist/hooks/load-core-context.mjs +1 -1
- package/dist/hooks/load-project-context.mjs +32 -29
- package/dist/hooks/security-validator.mjs +45 -13
- package/dist/hooks/stop-hook.mjs +54 -16
- package/dist/hooks/supervision-banner.mjs +9 -0
- package/dist/hooks/sync-todo-to-md.mjs +147 -113
- package/dist/hooks/worker-edit-repair.mjs +2 -1
- package/dist/hooks/worker-guard.mjs +40 -16
- package/dist/hooks/worker-note.mjs +12 -5
- package/dist/hooks/worker-path-repair.mjs +1 -1
- package/dist/hooks/worker-pool-host.mjs +329 -231
- package/dist/hooks/worker-status-line.mjs +195 -114
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +12 -12
- package/dist/{indexer-backend-BM2CUSu8.mjs → indexer-backend-Cll7le4P.mjs} +149 -96
- package/dist/{ipc-client-BMqWw_gv.mjs → ipc-client-CaiGJnSM.mjs} +1 -1
- package/dist/{ipc-client-YYDD6zzU.mjs → ipc-client-ZRmDKd5Z.mjs} +1 -1
- package/dist/kill-tree-BG7dRVtp.mjs +10 -0
- package/dist/{kill-tree-BjYz5BxK.mjs → kill-tree-EWYaEk5v.mjs} +8 -8
- package/dist/{launch-CLp0OJxV.mjs → launch-CXVlZjHt.mjs} +8 -8
- package/dist/{launch-DgqQdAjI.mjs → launch-Jh5NVeNe.mjs} +3 -3
- package/dist/local-candidate-DLdwQt0s.mjs +112 -0
- package/dist/local-instances-DOxSgT_L.mjs +210 -0
- package/dist/local-instances-ZeRkkuS5.mjs +6 -0
- package/dist/{local-tiers-DPZYqv9m.mjs → local-tiers-BE4jGaMa.mjs} +2 -2
- package/dist/{local-tiers-DnBIAkbK.mjs → local-tiers-DNMI5W86.mjs} +3 -3
- package/dist/{main-config-ops-C0SflOWk.mjs → main-config-ops-BEMpuhDz.mjs} +3 -3
- package/dist/{main-resolver-DVPpSWVy.mjs → main-resolver-3Ns1HPmS.mjs} +18 -17
- package/dist/{migrate-BUJHadA8.mjs → migrate-DrA_OwlZ.mjs} +45 -14
- package/dist/min-max-DrSRUaWQ.mjs +16 -0
- package/dist/{model-inventory-Dasber3S.mjs → model-inventory-BFVSNFT3.mjs} +13 -12
- package/dist/{models-add-Bt7aUHDs.mjs → models-add-C1QIc1DA.mjs} +39 -38
- package/dist/operator-BTqvTIc8.mjs +7 -0
- package/dist/{operator-DZxcP-g8.mjs → operator-CyuB3aVw.mjs} +3 -3
- package/dist/{pai-marker-kIYuNt3c.mjs → pai-marker-BcZyJguM.mjs} +7 -6
- package/dist/{pane-audit-OGYrOAik.mjs → pane-audit-DKQt71s4.mjs} +7 -7
- package/dist/{paths-DoRuFc60.mjs → paths-CFHTloSe.mjs} +3 -3
- package/dist/{paths-DoIyRnhx.mjs → paths-CHifubDh.mjs} +3 -3
- package/dist/{planner-DLGOYlVb.mjs → planner-BmFACdLa.mjs} +31 -30
- package/dist/{pool-CZ5MZaXg.mjs → pool-Dh-q3iJi.mjs} +45 -6
- package/dist/{pool-cli-BxNSPzzY.mjs → pool-cli-BggU8GRp.mjs} +5 -5
- package/dist/{pool-cli-CbJfl37y.mjs → pool-cli-DQ6OzRy2.mjs} +6 -6
- package/dist/postgres-BdBNkL_l.mjs +7 -0
- package/dist/{postgres-CDnd_k5f.mjs → postgres-C6ti4haA.mjs} +55 -34
- package/dist/{project-setup-DM4npnL3.mjs → project-setup-jvfONJTQ.mjs} +131 -74
- package/dist/providers-BeDiVEb-.mjs +16 -0
- package/dist/{providers-UsKtLcUR.mjs → providers-CblTFrhz.mjs} +6 -6
- package/dist/{query-feedback-I-txSnld.mjs → query-feedback-BRfPtqki.mjs} +2 -2
- package/dist/registrable-BzH4TObg.mjs +9 -0
- package/dist/{registrable-LrRIVYQc.mjs → registrable-DpyTtajg.mjs} +4 -4
- package/dist/{render-BDbb4CF-.mjs → render-BYmQkuLd.mjs} +8 -8
- package/dist/render-CoMvwMPs.mjs +13 -0
- package/dist/{reranker-B4r4vykM.mjs → reranker-8g6xMwP7.mjs} +1 -1
- package/dist/{reranker-DxxMCtA0.mjs → reranker-CqCbpGnX.mjs} +1 -1
- package/dist/root-FtJsxYnm.mjs +36 -0
- package/dist/{root-BMeJuHOb.mjs → root-Xglu0OPD.mjs} +11 -11
- package/dist/route-table-B7zpoypi.mjs +15 -0
- package/dist/{router-L8Nu-OHF.mjs → router-CQSc3lk3.mjs} +17 -7
- package/dist/{router-D6Ec6Fid.mjs → router-DwHJRgG9.mjs} +1 -1
- package/dist/{routing-CUyiglfu.mjs → routing-BAAST9vT.mjs} +27 -308
- package/dist/{routing-ZuGlc0ge.mjs → routing-CENt4HH1.mjs} +13 -12
- package/dist/{run-ulAi5dFD.mjs → run-CSC7mgPf.mjs} +35 -33
- package/dist/{scan-B7I0gPe-.mjs → scan-C_Y5W9py.mjs} +6 -6
- package/dist/{local-candidate-jOjTNlOL.mjs → scheduler-CtUyWJ3O.mjs} +7 -109
- package/dist/scheduler-dmHXoRvm.mjs +3 -0
- package/dist/{scope-D5VSQxe4.mjs → scope-D-h6F6DN.mjs} +4 -4
- package/dist/{search-CPoE0830.mjs → search-RSyeQqj1.mjs} +18 -18
- package/dist/{session-CNXF6DLP.mjs → session-8iqQDkqb.mjs} +55 -31
- package/dist/session-BeqAbNPd.mjs +35 -0
- package/dist/session-scan-BJI_ZO8M.mjs +9 -0
- package/dist/{session-scan-BDLEc4w1.mjs → session-scan-W-gbwJHM.mjs} +6 -6
- package/dist/{sources-CjhUKKtO.mjs → sources-ESUkZaWv.mjs} +1 -1
- package/dist/{status-DYydKQUI.mjs → status-Dm4dYciN.mjs} +4 -4
- package/dist/{status-CvVi9cDf.mjs → status-ggJ7lgVg.mjs} +17 -9
- package/dist/{stop-words-SdSL1WKH.mjs → stop-words-DSEYQdNe.mjs} +1 -1
- package/dist/{test-isolation-CoDeOVXb.mjs → test-isolation-lqSmYxr0.mjs} +1 -1
- package/dist/{timeouts-OwEONmc8.mjs → timeouts-1MLooEBB.mjs} +1 -1
- package/dist/{tool-errors-AeRQuG3Y.mjs → tool-errors-7E13StWd.mjs} +4 -3
- package/dist/{tool-errors-R5E0fCgf.mjs → tool-errors-CJWODvlo.mjs} +6 -6
- package/dist/viewer-CqozWW39.mjs +22 -0
- package/dist/{viewer-DtWj5Vti.mjs → viewer-mDXUNHNy.mjs} +15 -15
- package/dist/{wait-BMUR-U-U.mjs → wait-ByV0OyMZ.mjs} +3 -3
- package/dist/{worker-config-BLqa1yiD.mjs → worker-config-CJhEMk19.mjs} +294 -92
- package/dist/worker-config-DESkIjMF.mjs +41 -0
- package/dist/{workers-config-DEI9lrV4.mjs → workers-config-f8KrkY4L.mjs} +2 -2
- package/dist/{worktree-zmRf556h.mjs → worktree-CRs2gyg0.mjs} +37 -7
- package/dist/{zettelkasten-nigq7fqs.mjs → zettelkasten-B_rRRRvD.mjs} +5 -5
- package/dist/{zettelkasten-Cr_Xj0mG.mjs → zettelkasten-BzMm8REH.mjs} +29 -19
- package/docs/README.md +2 -0
- package/docs/cockpit.md +10 -4
- package/docs/commands/README.md +4 -4
- package/docs/commands/backup.md +2 -0
- package/docs/commands/install.md +29 -4
- package/docs/commands/providers.md +1 -1
- package/docs/commands/restore.md +4 -0
- package/docs/commands/setup.md +29 -4
- package/docs/commands/worker.md +1 -1
- package/docs/config.md +2 -0
- package/docs/features.md +299 -0
- package/docs/images/architecture.drawio +51 -0
- package/docs/images/architecture.png +0 -0
- package/docs/images/architecture.svg +3 -0
- package/docs/images/cockpit-01-system-tokens.jpg +0 -0
- package/docs/images/cockpit-02-totals-cache.jpg +0 -0
- package/docs/images/cockpit-03-local-servers-models-pool.jpg +0 -0
- package/docs/images/cockpit-04-workers-memory.jpg +0 -0
- package/docs/images/cockpit-05-performance.jpg +0 -0
- package/docs/images/cockpit-06-runs-speed-routing.jpg +0 -0
- package/docs/images/cockpit-07-settings-registry.jpg +0 -0
- package/docs/install/index.md +29 -0
- package/docs/three-tier-coding.md +1 -1
- package/gemini-extension.json +1 -1
- package/package.json +1 -5
- package/pai-plugin.json +1 -1
- package/plugins/context-preservation/plugin.json +1 -1
- package/plugins/core/plugin.json +1 -1
- package/plugins/core/skills/setup/SKILL.md +41 -9
- package/plugins/creative/plugin.json +1 -1
- package/plugins/observability/plugin.json +1 -1
- package/plugins/productivity/plugin.json +1 -1
- package/plugins/semantic-search/plugin.json +1 -1
- package/plugins/ui/plugin.json +1 -1
- package/plugins/zettelkasten/plugin.json +1 -1
- package/src/hooks/session-autosave.sh +8 -1
- package/src/hooks/session-stop.sh +8 -1
- package/src/hooks/ts/capture-all-events.ts +7 -12
- package/src/hooks/ts/lib/context-fill.ts +2 -1
- package/src/hooks/ts/lib/path-repair.ts +1 -1
- package/src/hooks/ts/lib/project-utils/notify.ts +1 -0
- package/src/hooks/ts/lib/project-utils/session-notes.ts +23 -6
- package/src/hooks/ts/lib/raw-capture.ts +36 -0
- package/src/hooks/ts/lib/session-summary.ts +129 -0
- package/src/hooks/ts/lib/todo-sync.ts +120 -0
- package/src/hooks/ts/lib/worker-git-guard.ts +1 -1
- package/src/hooks/ts/post-tool-use/capture-tool-output.ts +6 -10
- package/src/hooks/ts/post-tool-use/sync-todo-to-md.ts +5 -105
- package/src/hooks/ts/pre-compact/context-compression-hook.ts +1 -1
- package/src/hooks/ts/pre-tool-use/security-validator.ts +35 -14
- package/src/hooks/ts/session-end/capture-session-summary.ts +20 -128
- package/src/hooks/ts/session-start/load-core-context.ts +3 -3
- package/src/hooks/ts/session-start/load-project-context.ts +18 -22
- package/src/hooks/ts/stop/stop-hook.ts +13 -5
- package/src/hooks/ztk-auto.sh +7 -2
- package/dist/aibroker-client-JjE74jo0.mjs +0 -3
- package/dist/auto-route-BRk8NEFv.mjs +0 -11
- package/dist/budget-DuhQ2zzG.mjs +0 -14
- package/dist/cockpit-actions-DcQ-ucU8.mjs +0 -19
- package/dist/cockpit-memory-KV45PPO2.mjs +0 -19
- package/dist/daemon-C7yt_ptC.mjs +0 -44
- package/dist/detect-DRUkmHnb.mjs +0 -10
- package/dist/factory-DAGG9_n8.mjs +0 -9
- package/dist/helpers-DPJEHPq6.mjs +0 -10
- package/dist/kill-tree-LV0Q7Mte.mjs +0 -10
- package/dist/operator-CfL0HiBK.mjs +0 -7
- package/dist/postgres-DgqWyqhN.mjs +0 -7
- package/dist/providers-CTu2s1z2.mjs +0 -15
- package/dist/registrable-D9aNZOTh.mjs +0 -9
- package/dist/render-BSfVlYHj.mjs +0 -13
- package/dist/root-xI9DqVIe.mjs +0 -35
- package/dist/route-table-HjvnLVEU.mjs +0 -14
- package/dist/session-BJHzmUg2.mjs +0 -34
- package/dist/session-scan-YORKE1NO.mjs +0 -9
- package/dist/viewer-B8709jDN.mjs +0 -22
- package/dist/worker-config-D8tRuvo7.mjs +0 -40
- package/docs/images/cockpit-limits-routing.jpg +0 -0
- package/docs/images/cockpit-models.jpg +0 -0
- package/docs/images/cockpit-usage.jpg +0 -0
- package/docs/images/cockpit-workers-system.jpg +0 -0
- package/scripts/build-docs.mjs +0 -41
- package/scripts/build-hooks.mjs +0 -311
- package/scripts/build-skill-stubs.mjs +0 -216
- package/scripts/copy-defaults.mjs +0 -46
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "./config-XpZWOYOG.mjs";
|
|
2
|
+
import "./config-Bu1_vbY8.mjs";
|
|
3
|
+
import "./paths-CHifubDh.mjs";
|
|
4
|
+
import "./status-ggJ7lgVg.mjs";
|
|
5
|
+
import { n as operatorSocketPath, r as sayToWorker, t as createOperatorServer } from "./operator-CyuB3aVw.mjs";
|
|
6
|
+
|
|
7
|
+
export { sayToWorker };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as isLive, v as loadStatus } from "./status-
|
|
1
|
+
import { g as isLive, v as loadStatus } from "./status-ggJ7lgVg.mjs";
|
|
2
2
|
import { existsSync, unlinkSync } from "node:fs";
|
|
3
|
-
import { join } from "node:path";
|
|
4
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import { join } from "node:path";
|
|
5
5
|
import { connect, createServer } from "node:net";
|
|
6
6
|
|
|
7
7
|
//#region src/workers/operator.ts
|
|
@@ -95,4 +95,4 @@ function sayToWorker(logDir, id, text, timeoutMs = 4e3) {
|
|
|
95
95
|
|
|
96
96
|
//#endregion
|
|
97
97
|
export { operatorSocketPath as n, sayToWorker as r, createOperatorServer as t };
|
|
98
|
-
//# sourceMappingURL=operator-
|
|
98
|
+
//# sourceMappingURL=operator-CyuB3aVw.mjs.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as writeFileAtomic } from "./atomic-file-BorMa4T3.mjs";
|
|
2
|
+
import { s as worktreeReason } from "./registrable-DpyTtajg.mjs";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
3
4
|
import { join, resolve } from "node:path";
|
|
4
5
|
import { homedir } from "node:os";
|
|
5
6
|
|
|
@@ -153,20 +154,20 @@ function ensurePaiMarker(projectRoot, slug, displayName) {
|
|
|
153
154
|
if (!existsSync(markerPath)) {
|
|
154
155
|
if (isContainerDirectory(projectRoot)) return;
|
|
155
156
|
mkdirSync(notesDir, { recursive: true });
|
|
156
|
-
|
|
157
|
+
writeFileAtomic(markerPath, renderTemplate(slug, name));
|
|
157
158
|
return;
|
|
158
159
|
}
|
|
159
160
|
const raw = readFileSync(markerPath, "utf8");
|
|
160
161
|
const parsed = parseFrontmatter(raw);
|
|
161
162
|
if (!parsed) {
|
|
162
|
-
|
|
163
|
+
writeFileAtomic(markerPath, `---\n${buildPaiBlock(slug, isoDate(), null, "active")}---\n\n${raw}`);
|
|
163
164
|
return;
|
|
164
165
|
}
|
|
165
166
|
const { frontmatter, body } = parsed;
|
|
166
167
|
const existingRegistered = extractYamlValue(frontmatter, "registered") ?? isoDate();
|
|
167
168
|
const rawLastIndexed = extractYamlValue(frontmatter, "last_indexed");
|
|
168
169
|
const newFrontmatter = replacePaiBlock(frontmatter, buildPaiBlock(slug, existingRegistered, rawLastIndexed === null || rawLastIndexed === "null" ? null : rawLastIndexed, extractYamlValue(frontmatter, "status") ?? "active"));
|
|
169
|
-
|
|
170
|
+
writeFileAtomic(markerPath, `---\n${newFrontmatter.endsWith("\n") ? newFrontmatter : newFrontmatter + "\n"}---\n${body}`);
|
|
170
171
|
}
|
|
171
172
|
/**
|
|
172
173
|
* Read PAI marker data from `<projectRoot>/Notes/PAI.md`.
|
|
@@ -227,4 +228,4 @@ function discoverPaiMarkers(searchDirs) {
|
|
|
227
228
|
|
|
228
229
|
//#endregion
|
|
229
230
|
export { ensurePaiMarker as n, readPaiMarker as r, discoverPaiMarkers as t };
|
|
230
|
-
//# sourceMappingURL=pai-marker-
|
|
231
|
+
//# sourceMappingURL=pai-marker-BcZyJguM.mjs.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
|
|
2
|
-
import { wt as appendLedger } from "./config-
|
|
3
|
-
import { i as ledgerPath } from "./paths-
|
|
4
|
-
import { C as nowStamp, M as spawnTimeOf, T as ownsPidCached, b as loadStatusesCached, g as isLive, h as isChatPane, v as loadStatus, w as ownsPid } from "./status-
|
|
5
|
-
import { i as itermUuid } from "./scope-
|
|
6
|
-
import { At as recordPath, Ct as PANE_EXEC_PID_ENV, Dt as pidAlive, L as fmtElapsed, Mt as panePolicy, Ot as readExit, St as PANE_EXEC_ENV, Tt as listRecords, V as loadPlanStatuses, _t as paneTitle, dt as osascript, kt as readRecord, mt as realPaneOps, nt as closePaneForWorker, st as loadRegistry, tt as closeOwnPane, vt as writePaneTitle, wt as exitFilePath } from "./controls-
|
|
7
|
-
import { i as killTree } from "./kill-tree-
|
|
2
|
+
import { wt as appendLedger } from "./config-XpZWOYOG.mjs";
|
|
3
|
+
import { i as ledgerPath } from "./paths-CHifubDh.mjs";
|
|
4
|
+
import { C as nowStamp, M as spawnTimeOf, T as ownsPidCached, b as loadStatusesCached, g as isLive, h as isChatPane, v as loadStatus, w as ownsPid } from "./status-ggJ7lgVg.mjs";
|
|
5
|
+
import { i as itermUuid } from "./scope-D-h6F6DN.mjs";
|
|
6
|
+
import { At as recordPath, Ct as PANE_EXEC_PID_ENV, Dt as pidAlive, L as fmtElapsed, Mt as panePolicy, Ot as readExit, St as PANE_EXEC_ENV, Tt as listRecords, V as loadPlanStatuses, _t as paneTitle, dt as osascript, kt as readRecord, mt as realPaneOps, nt as closePaneForWorker, st as loadRegistry, tt as closeOwnPane, vt as writePaneTitle, wt as exitFilePath } from "./controls-CPoeudou.mjs";
|
|
7
|
+
import { i as killTree } from "./kill-tree-EWYaEk5v.mjs";
|
|
8
8
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
import { execFileSync, spawn } from "node:child_process";
|
|
@@ -743,4 +743,4 @@ function renderPaneAudit(verdicts) {
|
|
|
743
743
|
|
|
744
744
|
//#endregion
|
|
745
745
|
export { readAudit as a, followPaneRun as c, loadPaneRunStatuses as d, paneRunRows as f, listItermTabs as i, isPaneRunId as l, runInPane as m, auditTick as n, renderPaneAudit as o, renderPaneRunLines as p, closeFinishedPanes as r, runningProcs as s, auditPanes as t, loadPaneRunStatus as u };
|
|
746
|
-
//# sourceMappingURL=pane-audit-
|
|
746
|
+
//# sourceMappingURL=pane-audit-DKQt71s4.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./config-
|
|
2
|
-
import "./config-
|
|
3
|
-
import { a as noMcpConfigPath, c as slotCurrentPath, i as ledgerPath, l as statusPath, n as ensureNoMcpConfig, o as panesDir, r as eventsPath, s as routingStatePath, t as WORKER_ID_RE, u as workersLogDir } from "./paths-
|
|
1
|
+
import "./config-XpZWOYOG.mjs";
|
|
2
|
+
import "./config-Bu1_vbY8.mjs";
|
|
3
|
+
import { a as noMcpConfigPath, c as slotCurrentPath, i as ledgerPath, l as statusPath, n as ensureNoMcpConfig, o as panesDir, r as eventsPath, s as routingStatePath, t as WORKER_ID_RE, u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
4
4
|
|
|
5
5
|
export { WORKER_ID_RE, ensureNoMcpConfig, eventsPath, ledgerPath, noMcpConfigPath, panesDir, routingStatePath, slotCurrentPath, statusPath, workersLogDir };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as resolvePaiFile, g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
|
|
2
|
-
import { d as defaultWorkersConfig } from "./config-
|
|
3
|
-
import { o as expandHome } from "./config-
|
|
2
|
+
import { d as defaultWorkersConfig } from "./config-XpZWOYOG.mjs";
|
|
3
|
+
import { o as expandHome } from "./config-Bu1_vbY8.mjs";
|
|
4
4
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
|
|
@@ -65,4 +65,4 @@ function slotCurrentPath(logDir, slot) {
|
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
67
|
export { noMcpConfigPath as a, slotCurrentPath as c, ledgerPath as i, statusPath as l, ensureNoMcpConfig as n, panesDir as o, eventsPath as r, routingStatePath as s, WORKER_ID_RE as t, workersLogDir as u };
|
|
68
|
-
//# sourceMappingURL=paths-
|
|
68
|
+
//# sourceMappingURL=paths-CHifubDh.mjs.map
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import { j as readWorkersSection, wt as appendLedger } from "./config-
|
|
2
|
-
import "./config-
|
|
3
|
-
import { i as ledgerPath, u as workersLogDir } from "./paths-
|
|
4
|
-
import { g as mergeWorker, n as MergeConflictError } from "./worktree-
|
|
5
|
-
import { S as newWorkerId, nt as shortText, tt as parseRunnerArgs, v as loadStatus } from "./status-
|
|
6
|
-
import "./pool-
|
|
7
|
-
import "./helpers-
|
|
8
|
-
import "./scope-
|
|
9
|
-
import "./routing-
|
|
10
|
-
import "./tool-errors-
|
|
11
|
-
import "./wait-
|
|
12
|
-
import "./local-tiers-
|
|
13
|
-
import "./caller-identity-
|
|
14
|
-
import "./
|
|
15
|
-
import "./
|
|
16
|
-
import "./
|
|
17
|
-
import "./
|
|
18
|
-
import "./
|
|
19
|
-
import "./
|
|
20
|
-
import "./
|
|
21
|
-
import "./
|
|
22
|
-
import
|
|
23
|
-
import "./
|
|
24
|
-
import "./
|
|
25
|
-
import "./
|
|
26
|
-
import "./
|
|
27
|
-
import "./
|
|
28
|
-
import "./
|
|
29
|
-
import
|
|
1
|
+
import { j as readWorkersSection, wt as appendLedger } from "./config-XpZWOYOG.mjs";
|
|
2
|
+
import "./config-Bu1_vbY8.mjs";
|
|
3
|
+
import { i as ledgerPath, u as workersLogDir } from "./paths-CHifubDh.mjs";
|
|
4
|
+
import { g as mergeWorker, n as MergeConflictError } from "./worktree-CRs2gyg0.mjs";
|
|
5
|
+
import { S as newWorkerId, nt as shortText, tt as parseRunnerArgs, v as loadStatus } from "./status-ggJ7lgVg.mjs";
|
|
6
|
+
import "./pool-Dh-q3iJi.mjs";
|
|
7
|
+
import "./helpers-CRuBUas3.mjs";
|
|
8
|
+
import "./scope-D-h6F6DN.mjs";
|
|
9
|
+
import "./routing-BAAST9vT.mjs";
|
|
10
|
+
import "./tool-errors-7E13StWd.mjs";
|
|
11
|
+
import "./wait-ByV0OyMZ.mjs";
|
|
12
|
+
import "./local-tiers-BE4jGaMa.mjs";
|
|
13
|
+
import "./caller-identity-yLFb7CKq.mjs";
|
|
14
|
+
import "./capacity-DEveQdFV.mjs";
|
|
15
|
+
import "./local-instances-DOxSgT_L.mjs";
|
|
16
|
+
import "./local-candidate-DLdwQt0s.mjs";
|
|
17
|
+
import "./factory-DjAAsqr_.mjs";
|
|
18
|
+
import "./postgres-C6ti4haA.mjs";
|
|
19
|
+
import "./embedding-gate-6rZrWRXa.mjs";
|
|
20
|
+
import "./embeddings-BVq3esBF.mjs";
|
|
21
|
+
import "./router-CQSc3lk3.mjs";
|
|
22
|
+
import "./launch-Jh5NVeNe.mjs";
|
|
23
|
+
import { V as printResult, t as runWorker } from "./run-CSC7mgPf.mjs";
|
|
24
|
+
import "./controls-CPoeudou.mjs";
|
|
25
|
+
import "./endreason-C577xIQz.mjs";
|
|
26
|
+
import "./render-BYmQkuLd.mjs";
|
|
27
|
+
import "./operator-CyuB3aVw.mjs";
|
|
28
|
+
import "./kill-tree-EWYaEk5v.mjs";
|
|
29
|
+
import "./pool-cli-BggU8GRp.mjs";
|
|
30
|
+
import { n as swapPromptArg } from "./chain-7n9Gx56r.mjs";
|
|
30
31
|
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
|
31
32
|
import { join } from "node:path";
|
|
32
33
|
|
|
@@ -306,4 +307,4 @@ function printPlannerSummary(logDir, plannerId, results, merged, conflicted, fmt
|
|
|
306
307
|
|
|
307
308
|
//#endregion
|
|
308
309
|
export { runPlanner };
|
|
309
|
-
//# sourceMappingURL=planner-
|
|
310
|
+
//# sourceMappingURL=planner-BmFACdLa.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Et as parseLedger, I as LOOPBACK_HOST, c as WorkersConfigError, d as defaultWorkersConfig, i as DEFAULT_POOL_PORT, t as ANTHROPIC_NATIVE } from "./config-
|
|
2
|
-
import { t as assertTestWriteAllowed } from "./test-isolation-
|
|
3
|
-
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { Et as parseLedger, I as LOOPBACK_HOST, c as WorkersConfigError, d as defaultWorkersConfig, i as DEFAULT_POOL_PORT, t as ANTHROPIC_NATIVE } from "./config-XpZWOYOG.mjs";
|
|
2
|
+
import { t as assertTestWriteAllowed } from "./test-isolation-lqSmYxr0.mjs";
|
|
3
|
+
import { appendFileSync, copyFileSync, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { request } from "node:http";
|
|
7
7
|
|
|
@@ -105,6 +105,45 @@ function trustProjectPath(absPath) {
|
|
|
105
105
|
});
|
|
106
106
|
return true;
|
|
107
107
|
}
|
|
108
|
+
/** Canonical form of a script path: realpath when it exists, else the resolved text. */
|
|
109
|
+
function canonicalScript(p) {
|
|
110
|
+
try {
|
|
111
|
+
return realpathSync(p);
|
|
112
|
+
} catch {
|
|
113
|
+
return resolve(p);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/** True when an mcpServers entry runs `script`, comparing by realpath (symlinked repo paths match). */
|
|
117
|
+
function mcpEntryRunsScript(entry, script) {
|
|
118
|
+
const args = entry?.args;
|
|
119
|
+
if (!Array.isArray(args)) return false;
|
|
120
|
+
const want = canonicalScript(script);
|
|
121
|
+
return args.some((a) => typeof a === "string" && canonicalScript(a) === want);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Point `servers[name]` at `script`. An existing entry running the same file
|
|
125
|
+
* (by realpath) is updated in place; a genuinely different one is kept as
|
|
126
|
+
* `<name>-legacy`.
|
|
127
|
+
*/
|
|
128
|
+
function registerMcpScript(servers, name, script) {
|
|
129
|
+
const existing = servers[name];
|
|
130
|
+
const entry = {
|
|
131
|
+
command: "node",
|
|
132
|
+
args: [script]
|
|
133
|
+
};
|
|
134
|
+
if (!existing) {
|
|
135
|
+
servers[name] = entry;
|
|
136
|
+
return "added";
|
|
137
|
+
}
|
|
138
|
+
if (mcpEntryRunsScript(existing, script)) {
|
|
139
|
+
const same = JSON.stringify(existing) === JSON.stringify(entry);
|
|
140
|
+
servers[name] = entry;
|
|
141
|
+
return same ? "unchanged" : "updated";
|
|
142
|
+
}
|
|
143
|
+
servers[`${name}-legacy`] = existing;
|
|
144
|
+
servers[name] = entry;
|
|
145
|
+
return "legacy-kept";
|
|
146
|
+
}
|
|
108
147
|
|
|
109
148
|
//#endregion
|
|
110
149
|
//#region src/workers/mcp.ts
|
|
@@ -589,5 +628,5 @@ function spareStats(ledgerText) {
|
|
|
589
628
|
}
|
|
590
629
|
|
|
591
630
|
//#endregion
|
|
592
|
-
export {
|
|
593
|
-
//# sourceMappingURL=pool-
|
|
631
|
+
export { readClaudeJson as A, describeMcp as C, readMcpServers as D, mcpServersFromToolGrants as E, trustProjectPath as M, writeClaudeJson as N, writeMcpConfig as O, inputSideTokens as S, grantsChrome as T, readPoolMetrics as _, formatCarryByProvider as a, spareStats as b, poolHostAlive as c, poolIneligibleReason as d, poolMetricsPath as f, postTaskToPool as g, poolSettings as h, bundleBuildStamp as i, registerMcpScript as j, mcpEntryRunsScript as k, poolHostProbe as l, poolPort as m, SLOT_TOOLS as n, poolCarry as o, poolPidPath as p, UNIT_MARKER as r, poolDir as s, SHARED_MARKER as t, poolHostStale as u, readPoolState as v, expandMcpNames as w, warmOrCold as x, reloadInProgress as y };
|
|
632
|
+
//# sourceMappingURL=pool-Dh-q3iJi.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Et as parseLedger, F as writeWorkersSection, I as LOOPBACK_HOST, j as readWorkersSection, wt as appendLedger } from "./config-
|
|
2
|
-
import { i as ledgerPath } from "./paths-
|
|
3
|
-
import { m as fmtTokens } from "./status-
|
|
4
|
-
import { _ as readPoolMetrics, a as formatCarryByProvider, b as spareStats, c as poolHostAlive, f as poolMetricsPath, h as poolSettings, i as bundleBuildStamp, l as poolHostProbe, m as poolPort, o as poolCarry, p as poolPidPath, s as poolDir, u as poolHostStale, v as readPoolState, y as reloadInProgress } from "./pool-
|
|
1
|
+
import { Et as parseLedger, F as writeWorkersSection, I as LOOPBACK_HOST, j as readWorkersSection, wt as appendLedger } from "./config-XpZWOYOG.mjs";
|
|
2
|
+
import { i as ledgerPath } from "./paths-CHifubDh.mjs";
|
|
3
|
+
import { m as fmtTokens } from "./status-ggJ7lgVg.mjs";
|
|
4
|
+
import { _ as readPoolMetrics, a as formatCarryByProvider, b as spareStats, c as poolHostAlive, f as poolMetricsPath, h as poolSettings, i as bundleBuildStamp, l as poolHostProbe, m as poolPort, o as poolCarry, p as poolPidPath, s as poolDir, u as poolHostStale, v as readPoolState, y as reloadInProgress } from "./pool-Dh-q3iJi.mjs";
|
|
5
5
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
@@ -313,4 +313,4 @@ function spareStatusLines(state, logDir) {
|
|
|
313
313
|
|
|
314
314
|
//#endregion
|
|
315
315
|
export { poolOff as a, poolStatusText as c, spareStatusLines as d, standalonePoolHostPath as f, hostBuildText as i, reloadPoolHost as l, diskBundleMtime as n, poolOn as o, ensurePoolHost as r, poolReloadLive as s, POOL_HEAL_GAP_MS as t, skipReasonLine as u };
|
|
316
|
-
//# sourceMappingURL=pool-cli-
|
|
316
|
+
//# sourceMappingURL=pool-cli-BggU8GRp.mjs.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./config-
|
|
2
|
-
import "./config-
|
|
3
|
-
import "./paths-
|
|
4
|
-
import "./status-
|
|
5
|
-
import "./pool-
|
|
6
|
-
import { a as poolOff, c as poolStatusText, d as spareStatusLines, f as standalonePoolHostPath, i as hostBuildText, l as reloadPoolHost, n as diskBundleMtime, o as poolOn, r as ensurePoolHost, s as poolReloadLive, t as POOL_HEAL_GAP_MS, u as skipReasonLine } from "./pool-cli-
|
|
1
|
+
import "./config-XpZWOYOG.mjs";
|
|
2
|
+
import "./config-Bu1_vbY8.mjs";
|
|
3
|
+
import "./paths-CHifubDh.mjs";
|
|
4
|
+
import "./status-ggJ7lgVg.mjs";
|
|
5
|
+
import "./pool-Dh-q3iJi.mjs";
|
|
6
|
+
import { a as poolOff, c as poolStatusText, d as spareStatusLines, f as standalonePoolHostPath, i as hostBuildText, l as reloadPoolHost, n as diskBundleMtime, o as poolOn, r as ensurePoolHost, s as poolReloadLive, t as POOL_HEAL_GAP_MS, u as skipReasonLine } from "./pool-cli-BggU8GRp.mjs";
|
|
7
7
|
|
|
8
8
|
export { poolOff, poolOn, poolStatusText };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as parseSessionTitleChunk, c as yieldToEventLoop, f as fileContentHash, h as sha256File, i as isPathTooBroadForContentScan, m as sha256, n as chunkId, o as walkContentFiles, r as detectTier, s as walkMdFiles, t as INDEX_YIELD_EVERY, u as chunkMarkdown } from "./helpers-
|
|
3
|
-
import { t as STOP_WORDS } from "./stop-words-
|
|
4
|
-
import { p as LEGACY_EMBEDDING_BINDING, r as gateBackend } from "./embedding-gate-
|
|
5
|
-
import { s as serializeEmbedding } from "./embeddings-
|
|
1
|
+
import { M as postgresConnectionString, k as DEFAULT_PG_CONNECTION_TIMEOUT_MS } from "./config-Bu1_vbY8.mjs";
|
|
2
|
+
import { a as parseSessionTitleChunk, c as yieldToEventLoop, f as fileContentHash, h as sha256File, i as isPathTooBroadForContentScan, m as sha256, n as chunkId, o as walkContentFiles, r as detectTier, s as walkMdFiles, t as INDEX_YIELD_EVERY, u as chunkMarkdown } from "./helpers-CRuBUas3.mjs";
|
|
3
|
+
import { t as STOP_WORDS } from "./stop-words-DSEYQdNe.mjs";
|
|
4
|
+
import { p as LEGACY_EMBEDDING_BINDING, r as gateBackend } from "./embedding-gate-6rZrWRXa.mjs";
|
|
5
|
+
import { s as serializeEmbedding } from "./embeddings-BVq3esBF.mjs";
|
|
6
6
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
7
8
|
import { basename, dirname, join, relative } from "node:path";
|
|
8
9
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
10
|
import pg from "pg";
|
|
11
11
|
|
|
12
12
|
//#region src/module-paths.ts
|
|
@@ -67,13 +67,17 @@ function bufferToVector(buf) {
|
|
|
67
67
|
* semantics are too strict for multi-word queries because all terms rarely
|
|
68
68
|
* co-occur in a single chunk.
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
70
|
+
* The query is reduced to plain words (letters, digits, underscore, any script)
|
|
71
|
+
* and each word is single-quoted, so no user text can form a tsquery operator
|
|
72
|
+
* (& | ! < > - * ~ : parentheses, backslash).
|
|
73
|
+
*
|
|
74
|
+
* Example: "Acme interview follow-up Alice"
|
|
75
|
+
* → "'acme' | 'interview' | 'follow' | 'alice'"
|
|
72
76
|
*/
|
|
73
77
|
function buildPgTsQuery(query) {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
return tokens.join(" | ");
|
|
78
|
+
const long = (query.toLowerCase().match(/[\p{L}\p{N}_]+/gu) ?? []).filter((t) => t.length >= 2);
|
|
79
|
+
const tokens = long.filter((t) => !STOP_WORDS.has(t));
|
|
80
|
+
return (tokens.length > 0 ? tokens : long).map((t) => `'${t}'`).join(" | ");
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
//#endregion
|
|
@@ -86,11 +90,8 @@ function buildPgTsQuery(query) {
|
|
|
86
90
|
* and a genuine miss were BYTE-IDENTICAL at the call site — `memory_search`
|
|
87
91
|
* reported "No results found for query: …" either way.
|
|
88
92
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* cleanly empty. A sibling session searched for an open DMARC point, got nothing,
|
|
92
|
-
* and told the owner nothing was recorded. The search had run against a dead
|
|
93
|
-
* backend and was worthless — and nothing in the reply could have revealed that.
|
|
93
|
+
* A stopped backend therefore made every search look like a genuine miss, and
|
|
94
|
+
* a caller could conclude "nothing recorded" from a search that never ran.
|
|
94
95
|
*
|
|
95
96
|
* So: throw. The MCP shim already turns a thrown error into a visible message, and
|
|
96
97
|
* an error the user can act on beats an empty result they cannot distinguish from
|
|
@@ -130,6 +131,7 @@ async function searchKeyword(pool, query, opts) {
|
|
|
130
131
|
const limitParam = `$${paramIdx}`;
|
|
131
132
|
const sql = `
|
|
132
133
|
SELECT
|
|
134
|
+
id,
|
|
133
135
|
project_id,
|
|
134
136
|
path,
|
|
135
137
|
start_line,
|
|
@@ -137,6 +139,8 @@ async function searchKeyword(pool, query, opts) {
|
|
|
137
139
|
text AS snippet,
|
|
138
140
|
tier,
|
|
139
141
|
source,
|
|
142
|
+
updated_at,
|
|
143
|
+
last_accessed_at,
|
|
140
144
|
ts_rank(fts_vector, to_tsquery('simple', $1)) AS rank_score
|
|
141
145
|
FROM pai_chunks
|
|
142
146
|
WHERE ${conditions.join(" AND ")}
|
|
@@ -144,7 +148,10 @@ async function searchKeyword(pool, query, opts) {
|
|
|
144
148
|
LIMIT ${limitParam}
|
|
145
149
|
`;
|
|
146
150
|
try {
|
|
147
|
-
|
|
151
|
+
const result = await pool.query(sql, params);
|
|
152
|
+
const minScore = opts?.minScore ?? 0;
|
|
153
|
+
return result.rows.map((row) => ({
|
|
154
|
+
chunkId: row.id,
|
|
148
155
|
projectId: row.project_id,
|
|
149
156
|
path: row.path,
|
|
150
157
|
startLine: row.start_line,
|
|
@@ -152,8 +159,10 @@ async function searchKeyword(pool, query, opts) {
|
|
|
152
159
|
snippet: row.snippet,
|
|
153
160
|
score: row.rank_score,
|
|
154
161
|
tier: row.tier,
|
|
155
|
-
source: row.source
|
|
156
|
-
|
|
162
|
+
source: row.source,
|
|
163
|
+
updatedAt: Number(row.updated_at),
|
|
164
|
+
lastAccessedAt: row.last_accessed_at != null ? Number(row.last_accessed_at) : void 0
|
|
165
|
+
})).filter((r) => r.score >= minScore);
|
|
157
166
|
} catch (e) {
|
|
158
167
|
process.stderr.write(`[pai-postgres] searchKeyword error: ${e}\n`);
|
|
159
168
|
throw searchFailure("keyword", e);
|
|
@@ -633,12 +642,15 @@ function defaultLogger(attempt, delayMs, error) {
|
|
|
633
642
|
* The SQLite path still uses sync.ts directly (which is faster for SQLite
|
|
634
643
|
* due to synchronous transactions).
|
|
635
644
|
*/
|
|
645
|
+
/** Path namespace for memory files from the claude project dir (avoids clashing with the project root's memory/). */
|
|
646
|
+
const CLAUDE_MEMORY_PREFIX = ".claude-memory/";
|
|
636
647
|
/**
|
|
637
648
|
* Index a single file through the StorageBackend interface.
|
|
638
649
|
* Returns true if the file was re-indexed (changed or new), false if skipped.
|
|
639
650
|
*/
|
|
640
|
-
async function indexFileWithBackend(backend, projectId, rootPath, relativePath, source, tier) {
|
|
651
|
+
async function indexFileWithBackend(backend, projectId, rootPath, relativePath, source, tier, pathPrefix = "") {
|
|
641
652
|
const absPath = join(rootPath, relativePath);
|
|
653
|
+
const dbPath = pathPrefix + relativePath;
|
|
642
654
|
let content;
|
|
643
655
|
let stat;
|
|
644
656
|
try {
|
|
@@ -650,16 +662,16 @@ async function indexFileWithBackend(backend, projectId, rootPath, relativePath,
|
|
|
650
662
|
const hash = fileContentHash(content);
|
|
651
663
|
const mtime = Math.floor(stat.mtimeMs);
|
|
652
664
|
const size = stat.size;
|
|
653
|
-
if (await backend.getFileHash(projectId,
|
|
654
|
-
await backend.deleteChunksForFile(projectId,
|
|
665
|
+
if (await backend.getFileHash(projectId, dbPath) === hash) return false;
|
|
666
|
+
await backend.deleteChunksForFile(projectId, dbPath);
|
|
655
667
|
const rawChunks = chunkMarkdown(content);
|
|
656
668
|
const updatedAt = Date.now();
|
|
657
669
|
const chunks = rawChunks.map((c, i) => ({
|
|
658
|
-
id: chunkId(projectId,
|
|
670
|
+
id: chunkId(projectId, dbPath, i, c.startLine, c.endLine),
|
|
659
671
|
projectId,
|
|
660
672
|
source,
|
|
661
673
|
tier,
|
|
662
|
-
path:
|
|
674
|
+
path: dbPath,
|
|
663
675
|
startLine: c.startLine,
|
|
664
676
|
endLine: c.endLine,
|
|
665
677
|
hash: c.hash,
|
|
@@ -670,7 +682,7 @@ async function indexFileWithBackend(backend, projectId, rootPath, relativePath,
|
|
|
670
682
|
await backend.insertChunks(chunks);
|
|
671
683
|
await backend.upsertFile({
|
|
672
684
|
projectId,
|
|
673
|
-
path:
|
|
685
|
+
path: dbPath,
|
|
674
686
|
source,
|
|
675
687
|
tier,
|
|
676
688
|
hash,
|
|
@@ -730,6 +742,7 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
|
|
|
730
742
|
embedding: null
|
|
731
743
|
};
|
|
732
744
|
try {
|
|
745
|
+
if ((await backend.getChunkIds(projectId, syntheticPath)).length > 0) continue;
|
|
733
746
|
await backend.insertChunks([titleChunk]);
|
|
734
747
|
} catch {}
|
|
735
748
|
}
|
|
@@ -767,6 +780,7 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
|
|
|
767
780
|
embedding: null
|
|
768
781
|
};
|
|
769
782
|
try {
|
|
783
|
+
if ((await backend.getChunkIds(projectId, syntheticPath)).length > 0) continue;
|
|
770
784
|
await backend.insertChunks([titleChunk]);
|
|
771
785
|
} catch {}
|
|
772
786
|
}
|
|
@@ -778,7 +792,8 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
|
|
|
778
792
|
absPath: claudeMemoryMd,
|
|
779
793
|
rootBase: claudeProjectDir,
|
|
780
794
|
source: "memory",
|
|
781
|
-
tier: "evergreen"
|
|
795
|
+
tier: "evergreen",
|
|
796
|
+
pathPrefix: CLAUDE_MEMORY_PREFIX
|
|
782
797
|
});
|
|
783
798
|
const claudeMemoryDir = join(claudeProjectDir, "memory");
|
|
784
799
|
for (const absPath of walkMdFiles(claudeMemoryDir)) {
|
|
@@ -787,14 +802,15 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
|
|
|
787
802
|
absPath,
|
|
788
803
|
rootBase: claudeProjectDir,
|
|
789
804
|
source: "memory",
|
|
790
|
-
tier
|
|
805
|
+
tier,
|
|
806
|
+
pathPrefix: CLAUDE_MEMORY_PREFIX
|
|
791
807
|
});
|
|
792
808
|
}
|
|
793
809
|
}
|
|
794
810
|
}
|
|
795
811
|
await yieldToEventLoop();
|
|
796
812
|
let filesSinceYield = 0;
|
|
797
|
-
for (const { absPath, rootBase, source, tier } of filesToIndex) {
|
|
813
|
+
for (const { absPath, rootBase, source, tier, pathPrefix = "" } of filesToIndex) {
|
|
798
814
|
if (filesSinceYield >= INDEX_YIELD_EVERY) {
|
|
799
815
|
await yieldToEventLoop();
|
|
800
816
|
filesSinceYield = 0;
|
|
@@ -802,8 +818,8 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
|
|
|
802
818
|
filesSinceYield++;
|
|
803
819
|
const relPath = relative(rootBase, absPath);
|
|
804
820
|
try {
|
|
805
|
-
if (await indexFileWithBackend(backend, projectId, rootBase, relPath, source, tier)) {
|
|
806
|
-
const ids = await backend.getChunkIds(projectId, relPath);
|
|
821
|
+
if (await indexFileWithBackend(backend, projectId, rootBase, relPath, source, tier, pathPrefix)) {
|
|
822
|
+
const ids = await backend.getChunkIds(projectId, pathPrefix + relPath);
|
|
807
823
|
result.filesProcessed++;
|
|
808
824
|
result.chunksCreated += ids.length;
|
|
809
825
|
} else result.filesSkipped++;
|
|
@@ -812,7 +828,7 @@ async function indexProjectWithBackend(backend, projectId, rootPath, claudeNotes
|
|
|
812
828
|
}
|
|
813
829
|
}
|
|
814
830
|
const livePaths = /* @__PURE__ */ new Set();
|
|
815
|
-
for (const { absPath, rootBase } of filesToIndex) livePaths.add(relative(rootBase, absPath));
|
|
831
|
+
for (const { absPath, rootBase, pathPrefix = "" } of filesToIndex) livePaths.add(pathPrefix + relative(rootBase, absPath));
|
|
816
832
|
const dbChunkPaths = await backend.getDistinctChunkPaths(projectId);
|
|
817
833
|
const stalePaths = [];
|
|
818
834
|
for (const p of dbChunkPaths) {
|
|
@@ -1860,6 +1876,7 @@ var PostgresBackend = class PostgresBackend {
|
|
|
1860
1876
|
async insertChunks(chunks) {
|
|
1861
1877
|
if (chunks.length === 0) return;
|
|
1862
1878
|
const client = await this.pool.connect();
|
|
1879
|
+
let releaseErr;
|
|
1863
1880
|
try {
|
|
1864
1881
|
await client.query("BEGIN");
|
|
1865
1882
|
for (const c of chunks) {
|
|
@@ -1894,10 +1911,14 @@ var PostgresBackend = class PostgresBackend {
|
|
|
1894
1911
|
}
|
|
1895
1912
|
await client.query("COMMIT");
|
|
1896
1913
|
} catch (e) {
|
|
1897
|
-
|
|
1914
|
+
try {
|
|
1915
|
+
await client.query("ROLLBACK");
|
|
1916
|
+
} catch (rollbackErr) {
|
|
1917
|
+
releaseErr = rollbackErr instanceof Error ? rollbackErr : new Error(String(rollbackErr));
|
|
1918
|
+
}
|
|
1898
1919
|
throw e;
|
|
1899
1920
|
} finally {
|
|
1900
|
-
client.release();
|
|
1921
|
+
client.release(releaseErr);
|
|
1901
1922
|
}
|
|
1902
1923
|
}
|
|
1903
1924
|
async getDistinctChunkPaths(projectId) {
|
|
@@ -2288,4 +2309,4 @@ function rowToKgEntity(row) {
|
|
|
2288
2309
|
|
|
2289
2310
|
//#endregion
|
|
2290
2311
|
export { entityContentId as a, resolveFromModule as c, retryTransient as i, embedChunksWithBackend as n, buildPgTsQuery as o, indexProjectWithBackend as r, packageRoot as s, PostgresBackend as t };
|
|
2291
|
-
//# sourceMappingURL=postgres-
|
|
2312
|
+
//# sourceMappingURL=postgres-C6ti4haA.mjs.map
|