@tekmidian/pai 0.66.2 → 0.66.4
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/{aibroker-client-CHEEvJZW.mjs → aibroker-client-Ck3p3k_-.mjs} +1 -1
- package/dist/{aibroker-client-Dfv7j1Od.mjs → aibroker-client-WCZi_tn-.mjs} +2 -2
- package/dist/{aibroker-client-Dfv7j1Od.mjs.map → aibroker-client-WCZi_tn-.mjs.map} +1 -1
- package/dist/{chain-D5876UQX.mjs → chain-BhPwBDXB.mjs} +3 -3
- package/dist/{chain-D5876UQX.mjs.map → chain-BhPwBDXB.mjs.map} +1 -1
- package/dist/cli/index.mjs +13 -13
- package/dist/cli/program.mjs +13 -13
- package/dist/{config-DKIA7wgF.mjs → config-CnsDMETf.mjs} +1 -1
- package/dist/{config-C-LiGlop.mjs → config-Ddc4DIPk.mjs} +5 -3
- package/dist/config-Ddc4DIPk.mjs.map +1 -0
- package/dist/{context-handover-cache-9PGvXRIw.mjs → context-handover-cache-BbCYQUGo.mjs} +244 -10
- package/dist/context-handover-cache-BbCYQUGo.mjs.map +1 -0
- package/dist/daemon/index.mjs +11 -11
- package/dist/{daemon-BUgNvMUh.mjs → daemon-DzXOfieK.mjs} +37 -18
- package/dist/daemon-DzXOfieK.mjs.map +1 -0
- package/dist/daemon-UJtRscyO.mjs +18 -0
- package/dist/daemon-mcp/index.mjs +9 -9
- package/dist/{embeddings-CEBGrzwu.mjs → embeddings-D0WOQpYR.mjs} +1 -1
- package/dist/{embeddings-DOLZnT1X.mjs → embeddings-DMVzpvRZ.mjs} +18 -9
- package/dist/embeddings-DMVzpvRZ.mjs.map +1 -0
- package/dist/{factory-Ypf8r0fK.mjs → factory-CXFHwvcv.mjs} +5 -5
- package/dist/{factory-Ypf8r0fK.mjs.map → factory-CXFHwvcv.mjs.map} +1 -1
- package/dist/{factory-DrBg24UT.mjs → factory-CnKsU6zX.mjs} +4 -4
- package/dist/{fallback-D51R4shY.mjs → fallback-CoooFqyA.mjs} +4 -4
- package/dist/{fallback-D51R4shY.mjs.map → fallback-CoooFqyA.mjs.map} +1 -1
- package/dist/hooks/block-sleep-poll.mjs +6 -5
- package/dist/hooks/block-sleep-poll.mjs.map +3 -3
- package/dist/hooks/context-compression-hook.mjs +1 -0
- package/dist/hooks/context-compression-hook.mjs.map +2 -2
- package/dist/hooks/load-project-context.mjs +6 -5
- package/dist/hooks/load-project-context.mjs.map +3 -3
- package/dist/hooks/post-compact-inject.mjs +6 -5
- package/dist/hooks/post-compact-inject.mjs.map +3 -3
- package/dist/hooks/route-agents-to-worker.mjs +6 -5
- package/dist/hooks/route-agents-to-worker.mjs.map +3 -3
- package/dist/hooks/security-validator.mjs +1 -0
- package/dist/hooks/security-validator.mjs.map +2 -2
- package/dist/hooks/whisper-rules.mjs +1 -0
- package/dist/hooks/whisper-rules.mjs.map +2 -2
- package/dist/hooks/worker-guard.mjs +6 -5
- package/dist/hooks/worker-guard.mjs.map +3 -3
- package/dist/hooks/worker-proxy.mjs +6 -5
- package/dist/hooks/worker-proxy.mjs.map +3 -3
- package/dist/hooks/worker-status-line.mjs +6 -5
- package/dist/hooks/worker-status-line.mjs.map +3 -3
- package/dist/hooks/worker-supervision.mjs +6 -5
- package/dist/hooks/worker-supervision.mjs.map +3 -3
- package/dist/{ipc-client-BLYX51nG.mjs → ipc-client-DkxRay-o.mjs} +2 -2
- package/dist/{ipc-client-BLYX51nG.mjs.map → ipc-client-DkxRay-o.mjs.map} +1 -1
- package/dist/main-resolver-DrHtx8iW.mjs +7 -0
- package/dist/{main-resolver-kVkMJZUD.mjs → main-resolver-SfGGg1DB.mjs} +6 -6
- package/dist/{main-resolver-kVkMJZUD.mjs.map → main-resolver-SfGGg1DB.mjs.map} +1 -1
- package/dist/{pai-home-Cm9rcJgX.mjs → pai-home-UncxWxlX.mjs} +1 -1
- package/dist/{pai-home-Cm9rcJgX.mjs.map → pai-home-UncxWxlX.mjs.map} +1 -1
- package/dist/{planner-D5yt0EfA.mjs → planner-C43lzcw5.mjs} +8 -8
- package/dist/{planner-D5yt0EfA.mjs.map → planner-C43lzcw5.mjs.map} +1 -1
- package/dist/postgres-B2BEBT-J.mjs +5 -0
- package/dist/{postgres-D3xc2RB4.mjs → postgres-BxmyQHoA.mjs} +53 -5
- package/dist/postgres-BxmyQHoA.mjs.map +1 -0
- package/dist/{program-DIXRtAFy.mjs → program-DB-hoyfW.mjs} +124 -172
- package/dist/program-DB-hoyfW.mjs.map +1 -0
- package/dist/{query-feedback-B7FYE4JR.mjs → query-feedback-BPdapXKd.mjs} +2 -2
- package/dist/{query-feedback-B7FYE4JR.mjs.map → query-feedback-BPdapXKd.mjs.map} +1 -1
- package/dist/{run-env-Bnmf6bRI.mjs → run-env-CQRnxNht.mjs} +3 -3
- package/dist/{run-env-Bnmf6bRI.mjs.map → run-env-CQRnxNht.mjs.map} +1 -1
- package/dist/{run-CLYTOm0x.mjs → run-wi5NEkJd.mjs} +118 -9
- package/dist/run-wi5NEkJd.mjs.map +1 -0
- package/dist/{runtime-paths-D3FKAm69.mjs → runtime-paths-Bw3Jk8qJ.mjs} +4 -2
- package/dist/runtime-paths-Bw3Jk8qJ.mjs.map +1 -0
- package/dist/{zettelkasten-BhZMvmoK.mjs → zettelkasten-BRIaHzFm.mjs} +2 -2
- package/dist/{zettelkasten-BhZMvmoK.mjs.map → zettelkasten-BRIaHzFm.mjs.map} +1 -1
- package/dist/{zettelkasten-BwV1pluL.mjs → zettelkasten-G0-ZTybr.mjs} +3 -3
- package/docs/commands/memory.md +2 -0
- package/package.json +1 -1
- package/dist/config-C-LiGlop.mjs.map +0 -1
- package/dist/context-handover-cache-9PGvXRIw.mjs.map +0 -1
- package/dist/daemon-BUgNvMUh.mjs.map +0 -1
- package/dist/daemon-DL0eglMJ.mjs +0 -18
- package/dist/embeddings-DOLZnT1X.mjs.map +0 -1
- package/dist/main-resolver-BYgP86C1.mjs +0 -7
- package/dist/postgres-BmLr0MUm.mjs +0 -5
- package/dist/postgres-D3xc2RB4.mjs.map +0 -1
- package/dist/program-DIXRtAFy.mjs.map +0 -1
- package/dist/run-CLYTOm0x.mjs.map +0 -1
- package/dist/runtime-paths-D3FKAm69.mjs.map +0 -1
|
@@ -3,20 +3,20 @@ import { a as slugify$1, i as parseSessionFilename } from "./migrate-Bq0esMOa.mj
|
|
|
3
3
|
import { n as ensurePaiMarker } from "./pai-marker-DXVpFsYz.mjs";
|
|
4
4
|
import { t as STOP_WORDS } from "./stop-words-DtxaTWU_.mjs";
|
|
5
5
|
import { t as applyRecencyBoost } from "./search-CNAGTiJP.mjs";
|
|
6
|
-
import {
|
|
7
|
-
import { a as getStorageBackend, c as MergeError, f as humanDuration, i as getRegistryBackend, l as federationDbPath, o as oldRegistryPath, r as createStorageBackend, s as registryDbPath, u as oldFederationPath } from "./factory-
|
|
8
|
-
import { b as OWNER_LABEL_PREFIX, c as migrateConfigFile, d as readMainConfigRaw, f as writeMainConfigRaw, h as resolvedMainConfigPath, l as paiConfigFilePath, m as migrateMainConfigToYaml, n as CONFIG_FILE$2, o as expandHome, p as MainConfigError, s as loadConfig, t as CONFIG_DIR, u as paiConfigYamlFilePath, v as readJsonStrict, x as UNROUTED, y as writeJsonAtomic } from "./config-
|
|
9
|
-
import { a as
|
|
10
|
-
import { a as
|
|
11
|
-
import { At as
|
|
12
|
-
import { B as DEFAULT_CONTEXT_WINDOW, C as maskKey, D as readWorkersSection, F as needsWorkersYamlRelocation, H as stripModelVariant, I as parseWorkersYamlDocument, L as relocateWorkersYaml, M as initWorkersYaml, N as inlineWorkersYamlKeys, P as migrateWorkersToYaml, R as workersYamlLegacyNotice, V as contextWindowFromModelId, b as getProviderOrNative, d as MODEL_CAPABILITIES, h as WorkersConfigError, p as PROVIDER_TAGS, r as ANTHROPIC_NATIVE, t as buildRunEnv, w as nativeAnthropicProvider, x as isModelCapability, y as expandHome$1, z as workersYamlPath } from "./run-env-
|
|
13
|
-
import { $ as
|
|
14
|
-
import { t as PaiClient } from "./ipc-client-
|
|
15
|
-
import { A as getConfigValueOp, C as setWorkersEnabled, D as useProvider, E as updateProvider, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as setProviderModel, T as unsetClass, _ as removeProvider, a as followWorkers, b as setClass, c as statusLineOutput, d as addProvider, f as classTargetText, g as modelPrefsText, h as describeProviders, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as readSpecPrompt, m as describeModels, n as fallbackOn, o as psOutput, p as describeCapabilities, r as fallbackStatus, s as replayOutput, t as fallbackOff, u as resolveSpecPath, v as resolveProviderName, w as unsetCapabilityPreference, x as setProviderEnabled, y as setCapabilityPreference } from "./fallback-
|
|
16
|
-
import { _ as resolveSessionByNameOrId, a as buildDeduped, c as hasConversation, d as providerResumePlan, f as restoreTopLevel, g as migrateSessionScanCache, h as fmtAge
|
|
17
|
-
import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-
|
|
18
|
-
import { i as sendToSession, n as fetchLiveSessions, r as revealItermSession, t as callAiBroker } from "./aibroker-client-
|
|
19
|
-
import { t as runChain } from "./chain-
|
|
6
|
+
import { c as resolveFromModule, i as retryTransient, n as embedChunksWithBackend, r as indexProjectWithBackend, s as packageRoot } from "./postgres-BxmyQHoA.mjs";
|
|
7
|
+
import { a as getStorageBackend, c as MergeError, f as humanDuration, i as getRegistryBackend, l as federationDbPath, o as oldRegistryPath, r as createStorageBackend, s as registryDbPath, u as oldFederationPath } from "./factory-CXFHwvcv.mjs";
|
|
8
|
+
import { b as OWNER_LABEL_PREFIX, c as migrateConfigFile, d as readMainConfigRaw, f as writeMainConfigRaw, h as resolvedMainConfigPath, l as paiConfigFilePath, m as migrateMainConfigToYaml, n as CONFIG_FILE$2, o as expandHome, p as MainConfigError, s as loadConfig, t as CONFIG_DIR, u as paiConfigYamlFilePath, v as readJsonStrict, x as UNROUTED, y as writeJsonAtomic } from "./config-Ddc4DIPk.mjs";
|
|
9
|
+
import { a as paiHomePath, i as paiHomeDir, n as migratePaiDir, o as resolvePaiFile, r as migratePaiFile, t as PaiFileMigrationError } from "./pai-home-UncxWxlX.mjs";
|
|
10
|
+
import { a as schedulerLogPath, i as paiSocketPath, n as daemonLogPath } from "./runtime-paths-Bw3Jk8qJ.mjs";
|
|
11
|
+
import { At as claudeProjectsDir, Ct as loadScanConfig, Dt as saveScanConfig, Et as resolveHome, Ft as formatDetection, It as formatDetectionJson, Mt as scanTranscriptFolders, Nt as transcriptFiles, Ot as upsertProject, Pt as detectProject, St as cmdScan, a as sessionKeepaliveLedgerSummary, bt as reexecBackground, ct as findLatestNote, jt as findMovedProjects, kt as upsertSession, l as resolveDaemonPid, lt as findNotesDir$1, o as parseSessionUsage, ot as appendCheckpointToNote, r as loadSessionKeepaliveState, rt as extractAndStoreTriples, s as totalUsageTokens, st as applyContinue, t as readContextHandoverCache, ut as readBodyFile, vt as migrateIdentityFile, w as migrateSummaryCooldowns, wt as migrateScanConfig, y as migrateWorkQueue } from "./context-handover-cache-BbCYQUGo.mjs";
|
|
12
|
+
import { B as DEFAULT_CONTEXT_WINDOW, C as maskKey, D as readWorkersSection, F as needsWorkersYamlRelocation, H as stripModelVariant, I as parseWorkersYamlDocument, L as relocateWorkersYaml, M as initWorkersYaml, N as inlineWorkersYamlKeys, P as migrateWorkersToYaml, R as workersYamlLegacyNotice, V as contextWindowFromModelId, b as getProviderOrNative, d as MODEL_CAPABILITIES, h as WorkersConfigError, p as PROVIDER_TAGS, r as ANTHROPIC_NATIVE, t as buildRunEnv, w as nativeAnthropicProvider, x as isModelCapability, y as expandHome$1, z as workersYamlPath } from "./run-env-CQRnxNht.mjs";
|
|
13
|
+
import { $ as setWorkerLabel, F as pendingGate, G as isChatPane, I as pendingResults, J as loadStatuses, K as isLive, L as appendLedger, M as verifyWorker, O as discardWorker, P as formatPending, Q as saveStatus, Z as ownsPid, _ as markControlsHeld, _t as describeMcp, at as ensureProxyRunning, b as requestKill, c as handoffFromInside, dt as ensureNoMcpConfig, et as waitForTerminalStatus, f as checkPaneForWorker, ft as eventsPath, g as clickrControlsArgv, gt as projectLaunchConfig, h as openPaneForWorker, ht as pinNotices, i as usageContextTokens, it as DEFAULT_PROXY_PORT, j as mergeWorker, k as gcWorktrees, m as openFollowPane, mt as workersLogDir, n as runWorker, nt as parseRunnerArgs, o as parseWorkerReport, ot as stopProxy, p as closeEndedPanes, pt as ledgerPath, q as loadStatus, r as testProvider, tt as longInlinePromptHint, u as sayToWorker, v as callerDescription, vt as expandMcpNames, z as UNLABELED } from "./run-wi5NEkJd.mjs";
|
|
14
|
+
import { t as PaiClient } from "./ipc-client-DkxRay-o.mjs";
|
|
15
|
+
import { A as getConfigValueOp, C as setWorkersEnabled, D as useProvider, E as updateProvider, M as setConfigValueOp, N as unsetConfigValueOp, O as MainConfigOpsError, S as setProviderModel, T as unsetClass, _ as removeProvider, a as followWorkers, b as setClass, c as statusLineOutput, d as addProvider, f as classTargetText, g as modelPrefsText, h as describeProviders, i as fallbackStatusText, j as listConfigOp, k as formatConfigGetOutput, l as readSpecPrompt, m as describeModels, n as fallbackOn, o as psOutput, p as describeCapabilities, r as fallbackStatus, s as replayOutput, t as fallbackOff, u as resolveSpecPath, v as resolveProviderName, w as unsetCapabilityPreference, x as setProviderEnabled, y as setCapabilityPreference } from "./fallback-CoooFqyA.mjs";
|
|
16
|
+
import { _ as resolveSessionByNameOrId, a as buildDeduped, c as hasConversation, d as providerResumePlan, f as restoreTopLevel, g as migrateSessionScanCache, h as fmtAge, l as launchInDir, m as printExitDir, o as normalizeName$2, p as resumeArgvText, s as renderDedupedSessions, t as cmdMain, u as launchPrompt, v as scanCacheFilePath, y as scanSessions } from "./main-resolver-SfGGg1DB.mjs";
|
|
17
|
+
import { n as queriesDirPath, t as migrateQueriesDir } from "./query-feedback-BPdapXKd.mjs";
|
|
18
|
+
import { i as sendToSession, n as fetchLiveSessions, r as revealItermSession, t as callAiBroker } from "./aibroker-client-WCZi_tn-.mjs";
|
|
19
|
+
import { t as runChain } from "./chain-BhPwBDXB.mjs";
|
|
20
20
|
import { appendFileSync, chmodSync, closeSync, copyFileSync, cpSync, createReadStream, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, renameSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
21
21
|
import { homedir, platform, tmpdir, userInfo } from "node:os";
|
|
22
22
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
@@ -155,7 +155,7 @@ async function cmdPromote(opts) {
|
|
|
155
155
|
console.error(dim$1(` Pick a durable location for the new project.`));
|
|
156
156
|
process.exit(1);
|
|
157
157
|
}
|
|
158
|
-
const { getRegistryBackend } = await import("./factory-
|
|
158
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
159
159
|
const registryBackend = await getRegistryBackend();
|
|
160
160
|
const encodedDir = encodeDir(targetPath);
|
|
161
161
|
if (await registryBackend.getProjectBySlug(slug) ?? await registryBackend.getProjectByRootPath(targetPath) ?? await registryBackend.getProjectByEncodedDir(encodedDir)) {
|
|
@@ -2039,7 +2039,7 @@ async function cmdUnregister(slug, opts = {}) {
|
|
|
2039
2039
|
//#region src/cli/commands/project/projects-index.ts
|
|
2040
2040
|
function registerProjectsCommands(projectsCmd) {
|
|
2041
2041
|
projectsCmd.command("list", { isDefault: true }).description("Show the unified deduped listing (same as `pai`).\nUse --all to include cold / zero-session / archived projects.").option("--all", "Show all entries including cold / zero-session / archived projects").option("-n, --n <count>", "Max rows to show", "20").action(async (opts) => {
|
|
2042
|
-
const { cmdMain } = await import("./main-resolver-
|
|
2042
|
+
const { cmdMain } = await import("./main-resolver-DrHtx8iW.mjs");
|
|
2043
2043
|
await cmdMain(void 0, void 0, opts);
|
|
2044
2044
|
});
|
|
2045
2045
|
projectsCmd.command("list-raw").description("Raw registry listing with slug, path, status, last_active columns").option("--all", "Include archived projects (default: active only)").option("--status <status>", "Filter by status: active | archived").option("--tag <tag>", "Filter by tag").option("--type <type>", "Filter by type").action(async (opts) => {
|
|
@@ -2905,17 +2905,17 @@ const DEFAULT_PAGE_SIZE = 500;
|
|
|
2905
2905
|
async function runEmbed(backend, projectId, projectSlug, batchSize = 50, pageSize = DEFAULT_PAGE_SIZE) {
|
|
2906
2906
|
const label = projectSlug ? `project ${projectSlug}` : "all projects";
|
|
2907
2907
|
console.log(dim$1(`Generating embeddings for ${label} (this may take a while on first run)...`));
|
|
2908
|
-
const { generateEmbeddings, serializeEmbedding } = await import("./embeddings-
|
|
2908
|
+
const { generateEmbeddings, serializeEmbedding } = await import("./embeddings-D0WOQpYR.mjs");
|
|
2909
2909
|
const { chunks: totalEstimate } = projectId !== void 0 ? await backend.getProjectStats(projectId) : await backend.getStats();
|
|
2910
2910
|
let done = 0;
|
|
2911
2911
|
let after = null;
|
|
2912
2912
|
while (true) {
|
|
2913
|
-
const page = await backend.getUnembeddedChunkIds(projectId, pageSize, after);
|
|
2913
|
+
const page = await retryTransient(() => backend.getUnembeddedChunkIds(projectId, pageSize, after));
|
|
2914
2914
|
if (page.length === 0) break;
|
|
2915
2915
|
for (let i = 0; i < page.length; i += batchSize) {
|
|
2916
2916
|
const batch = page.slice(i, i + batchSize);
|
|
2917
2917
|
const vecs = await generateEmbeddings(batch.map((r) => r.text));
|
|
2918
|
-
await Promise.all(batch.map((row, j) => backend.updateEmbedding(row.id, serializeEmbedding(vecs[j]))));
|
|
2918
|
+
await Promise.all(batch.map((row, j) => retryTransient(() => backend.updateEmbedding(row.id, serializeEmbedding(vecs[j])))));
|
|
2919
2919
|
done += batch.length;
|
|
2920
2920
|
process.stdout.write(`\r ${done} / ~${totalEstimate} chunks embedded...`);
|
|
2921
2921
|
}
|
|
@@ -2929,7 +2929,8 @@ async function runEmbed(backend, projectId, projectSlug, batchSize = 50, pageSiz
|
|
|
2929
2929
|
console.log(ok$1(`Done.`) + ` ${bold$1(String(done))} chunks embedded`);
|
|
2930
2930
|
}
|
|
2931
2931
|
function registerEmbedCommand(memoryCmd) {
|
|
2932
|
-
memoryCmd.command("embed [project-slug]").description("Generate embeddings for un-embedded chunks (Phase 2.5)").option("--batch-size <n>", "Chunks to embed per batch", "50").action(async (projectSlug, opts) => {
|
|
2932
|
+
memoryCmd.command("embed [project-slug]").description("Generate embeddings for un-embedded chunks (Phase 2.5)").option("--batch-size <n>", "Chunks to embed per batch", "50").option("--background", "Run at background priority (taskpolicy -b + nice)").action(async (projectSlug, opts) => {
|
|
2933
|
+
if (opts.background) reexecBackground();
|
|
2933
2934
|
let backend;
|
|
2934
2935
|
try {
|
|
2935
2936
|
backend = await getStorageBackend();
|
|
@@ -2976,7 +2977,11 @@ async function indexAllProjects(backend) {
|
|
|
2976
2977
|
};
|
|
2977
2978
|
}
|
|
2978
2979
|
function registerIndexCommand(memoryCmd) {
|
|
2979
|
-
memoryCmd.command("index [project-slug]").description("Index memory files for one project or all projects").option("--all", "Index all active projects (default when no slug given)").option("--embed", "Also generate embeddings for newly indexed chunks (Phase 2.5)").option("--direct", "Skip daemon IPC and run index directly (for debugging)").action(async (projectSlug, opts) => {
|
|
2980
|
+
memoryCmd.command("index [project-slug]").description("Index memory files for one project or all projects").option("--all", "Index all active projects (default when no slug given)").option("--embed", "Also generate embeddings for newly indexed chunks (Phase 2.5)").option("--direct", "Skip daemon IPC and run index directly (for debugging)").option("--background", "Run at background priority (taskpolicy -b + nice); implies --direct").action(async (projectSlug, opts) => {
|
|
2981
|
+
if (opts.background) {
|
|
2982
|
+
opts.direct = true;
|
|
2983
|
+
reexecBackground();
|
|
2984
|
+
}
|
|
2980
2985
|
if (!opts.direct && !projectSlug) try {
|
|
2981
2986
|
await new PaiClient(loadConfig().socketPath).triggerIndex();
|
|
2982
2987
|
console.log(ok$1("Index triggered in daemon.") + dim$1(" Check daemon logs for progress."));
|
|
@@ -3069,7 +3074,7 @@ function registerSearchCommand(memoryCmd) {
|
|
|
3069
3074
|
let results;
|
|
3070
3075
|
if (mode === "keyword") results = await backend.searchKeyword(query, searchOpts);
|
|
3071
3076
|
else {
|
|
3072
|
-
const { generateEmbedding } = await import("./embeddings-
|
|
3077
|
+
const { generateEmbedding } = await import("./embeddings-D0WOQpYR.mjs");
|
|
3073
3078
|
console.log(dim$1("Generating query embedding..."));
|
|
3074
3079
|
const queryEmbedding = await generateEmbedding(query, true);
|
|
3075
3080
|
if (mode === "semantic") results = await backend.searchSemantic(queryEmbedding, searchOpts);
|
|
@@ -3254,8 +3259,8 @@ function registerStatsCommands(memoryCmd) {
|
|
|
3254
3259
|
//#region src/cli/commands/memory/sources-cmd.ts
|
|
3255
3260
|
function registerSourcesCommand(memoryCmd) {
|
|
3256
3261
|
memoryCmd.command("sources").description("Show what the indexer has taken in: composition by source, which roots\ncontent enters from, the heaviest single files, and how many chunks are\nrewritten per day (which distinguishes a finite backlog from a treadmill).").option("--limit <n>", "Rows per section (default 8)", "8").action(async (opts) => {
|
|
3257
|
-
const { createStorageBackend } = await import("./factory-
|
|
3258
|
-
const { loadConfig } = await import("./config-
|
|
3262
|
+
const { createStorageBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
3263
|
+
const { loadConfig } = await import("./config-CnsDMETf.mjs");
|
|
3259
3264
|
const { cmdMemorySources } = await import("./sources-CM2g-CLT.mjs");
|
|
3260
3265
|
let backend;
|
|
3261
3266
|
try {
|
|
@@ -3274,6 +3279,45 @@ function registerSourcesCommand(memoryCmd) {
|
|
|
3274
3279
|
});
|
|
3275
3280
|
}
|
|
3276
3281
|
|
|
3282
|
+
//#endregion
|
|
3283
|
+
//#region src/cli/commands/memory/pass.ts
|
|
3284
|
+
/** Budget for one embed pass; mirrors the daemon's in-process budget. */
|
|
3285
|
+
const EMBED_MAX_MILLIS = 24e4;
|
|
3286
|
+
async function runPass(name, sleepMs) {
|
|
3287
|
+
if (name === "noop") {
|
|
3288
|
+
await new Promise((r) => setTimeout(r, sleepMs));
|
|
3289
|
+
return { pid: process.pid };
|
|
3290
|
+
}
|
|
3291
|
+
const storage = await getStorageBackend();
|
|
3292
|
+
const registry = await getRegistryBackend();
|
|
3293
|
+
if (name === "index") return await storage.indexAll(registry);
|
|
3294
|
+
const projectNames = /* @__PURE__ */ new Map();
|
|
3295
|
+
try {
|
|
3296
|
+
for (const r of await registry.listProjects({ status: "active" })) projectNames.set(r.id, r.slug);
|
|
3297
|
+
} catch {}
|
|
3298
|
+
return { count: await embedChunksWithBackend(storage, () => false, projectNames, { maxMillis: EMBED_MAX_MILLIS }) };
|
|
3299
|
+
}
|
|
3300
|
+
function registerPassCommand(memoryCmd) {
|
|
3301
|
+
memoryCmd.command("pass <name>", { hidden: true }).option("--sleep <ms>", "noop pass: sleep this long", "0").action(async (name, opts) => {
|
|
3302
|
+
reexecBackground();
|
|
3303
|
+
try {
|
|
3304
|
+
const result = await runPass(name, parseInt(opts.sleep, 10));
|
|
3305
|
+
process.stdout.write(JSON.stringify({
|
|
3306
|
+
ok: true,
|
|
3307
|
+
result
|
|
3308
|
+
}) + "\n");
|
|
3309
|
+
process.exitCode = 0;
|
|
3310
|
+
} catch (e) {
|
|
3311
|
+
process.stdout.write(JSON.stringify({
|
|
3312
|
+
ok: false,
|
|
3313
|
+
error: e instanceof Error ? e.message : String(e)
|
|
3314
|
+
}) + "\n");
|
|
3315
|
+
process.exitCode = 1;
|
|
3316
|
+
}
|
|
3317
|
+
process.exit();
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3277
3321
|
//#endregion
|
|
3278
3322
|
//#region src/cli/commands/memory/index.ts
|
|
3279
3323
|
function registerMemoryCommands(memoryCmd) {
|
|
@@ -3282,6 +3326,7 @@ function registerMemoryCommands(memoryCmd) {
|
|
|
3282
3326
|
registerSearchCommand(memoryCmd);
|
|
3283
3327
|
registerStatsCommands(memoryCmd);
|
|
3284
3328
|
registerSourcesCommand(memoryCmd);
|
|
3329
|
+
registerPassCommand(memoryCmd);
|
|
3285
3330
|
}
|
|
3286
3331
|
|
|
3287
3332
|
//#endregion
|
|
@@ -3957,7 +4002,7 @@ async function escalate(task, headline, detail, state, now, opts) {
|
|
|
3957
4002
|
let delivered = false;
|
|
3958
4003
|
try {
|
|
3959
4004
|
const { routeNotification } = await import("./router-BK-hFeQ6.mjs");
|
|
3960
|
-
const { loadConfig } = await import("./config-
|
|
4005
|
+
const { loadConfig } = await import("./config-CnsDMETf.mjs");
|
|
3961
4006
|
delivered = (await routeNotification({
|
|
3962
4007
|
event: "error",
|
|
3963
4008
|
title: `PAI: ${headline}`,
|
|
@@ -3992,7 +4037,7 @@ async function escalate(task, headline, detail, state, now, opts) {
|
|
|
3992
4037
|
async function alertParked(task, reason) {
|
|
3993
4038
|
const text = `PAI parked "${task.title}" (${task.id}) — the scheduler will not retry it.\nReason: ${reason}\nTo release it: fix the cause, then move the due date — due_string, natural language only (e.g. "tomorrow 9am").`;
|
|
3994
4039
|
try {
|
|
3995
|
-
const { callAiBroker } = await import("./aibroker-client-
|
|
4040
|
+
const { callAiBroker } = await import("./aibroker-client-Ck3p3k_-.mjs");
|
|
3996
4041
|
await callAiBroker("pailot_send", { text }, 8e3);
|
|
3997
4042
|
} catch (e) {
|
|
3998
4043
|
console.error(`[pai-poller] parked-task alert not delivered to PAILot (${e instanceof Error ? e.message : String(e)}): ${text}`);
|
|
@@ -6778,6 +6823,7 @@ async function cmdStatus$1() {
|
|
|
6778
6823
|
console.log(bold$1(" PAI Daemon Status"));
|
|
6779
6824
|
console.log();
|
|
6780
6825
|
console.log(ok$1(` Daemon running`));
|
|
6826
|
+
console.log(dim$1(` PID: ${resolveDaemonPid() ?? "unknown"}`));
|
|
6781
6827
|
console.log(dim$1(` Uptime: ${s["uptime"]}s`));
|
|
6782
6828
|
console.log(dim$1(` Socket: ${s["socketPath"]}`));
|
|
6783
6829
|
const health = formatStorageHealth(s);
|
|
@@ -6811,12 +6857,13 @@ async function cmdStatus$1() {
|
|
|
6811
6857
|
function cmdRestart() {
|
|
6812
6858
|
if (!serviceManagerAllowed("pai daemon restart")) return;
|
|
6813
6859
|
if (process.platform === "linux") {
|
|
6860
|
+
const before = resolveDaemonPid();
|
|
6814
6861
|
const result = spawnSync("systemctl", [
|
|
6815
6862
|
"--user",
|
|
6816
6863
|
"restart",
|
|
6817
6864
|
SYSTEMD_UNIT_NAME
|
|
6818
6865
|
], { encoding: "utf8" });
|
|
6819
|
-
if (result.status === 0) console.log(ok$1(
|
|
6866
|
+
if (result.status === 0) console.log(ok$1(`Restarted daemon pid ${before ?? "?"} -> ${resolveDaemonPid() ?? "?"}`));
|
|
6820
6867
|
else {
|
|
6821
6868
|
console.error(err(`systemctl restart failed: ${(result.stderr || "").trim()}`));
|
|
6822
6869
|
process.exitCode = 1;
|
|
@@ -6829,25 +6876,16 @@ function cmdRestart() {
|
|
|
6829
6876
|
return;
|
|
6830
6877
|
}
|
|
6831
6878
|
try {
|
|
6832
|
-
const
|
|
6833
|
-
if (
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
], { encoding: "utf8" }).status === 0) console.log(ok$1("Sent kickstart to launchd."));
|
|
6840
|
-
else console.log(dim$1("Not managed by launchd either. Run: pai daemon serve"));
|
|
6879
|
+
const before = resolveDaemonPid();
|
|
6880
|
+
if (spawnSync("launchctl", [
|
|
6881
|
+
"kickstart",
|
|
6882
|
+
"-k",
|
|
6883
|
+
`gui/${process.getuid?.() ?? 501}/${PLIST_LABEL}`
|
|
6884
|
+
], { encoding: "utf8" }).status !== 0) {
|
|
6885
|
+
console.log(dim$1("Not managed by launchd. Run: pai daemon serve"));
|
|
6841
6886
|
return;
|
|
6842
6887
|
}
|
|
6843
|
-
|
|
6844
|
-
for (const pid of pids) try {
|
|
6845
|
-
process.kill(parseInt(pid, 10), "SIGTERM");
|
|
6846
|
-
console.log(ok$1(`Sent SIGTERM to pid ${pid}.`));
|
|
6847
|
-
} catch {
|
|
6848
|
-
console.log(warn$1(`Could not signal pid ${pid}.`));
|
|
6849
|
-
}
|
|
6850
|
-
console.log(dim$1("launchd will restart the daemon automatically."));
|
|
6888
|
+
console.log(ok$1(`Restarted daemon pid ${before ?? "?"} -> ${resolveDaemonPid() ?? "?"}`));
|
|
6851
6889
|
} catch (e) {
|
|
6852
6890
|
const msg = e instanceof Error ? e.message : String(e);
|
|
6853
6891
|
console.error(err(`restart error: ${msg}`));
|
|
@@ -7094,8 +7132,8 @@ function cmdLogs(opts) {
|
|
|
7094
7132
|
}
|
|
7095
7133
|
function registerDaemonCommands(daemonCmd) {
|
|
7096
7134
|
daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
|
|
7097
|
-
const { serve } = await import("./daemon-
|
|
7098
|
-
const { loadConfig: lc, ensureConfigDir } = await import("./config-
|
|
7135
|
+
const { serve } = await import("./daemon-UJtRscyO.mjs");
|
|
7136
|
+
const { loadConfig: lc, ensureConfigDir } = await import("./config-CnsDMETf.mjs");
|
|
7099
7137
|
ensureConfigDir();
|
|
7100
7138
|
await serve(lc());
|
|
7101
7139
|
});
|
|
@@ -9721,7 +9759,7 @@ async function cmdExplore(note, opts) {
|
|
|
9721
9759
|
const depth = parseInt(opts.depth ?? "3", 10);
|
|
9722
9760
|
const direction = opts.direction ?? "both";
|
|
9723
9761
|
const mode = opts.mode ?? "all";
|
|
9724
|
-
const { zettelExplore } = await import("./zettelkasten-
|
|
9762
|
+
const { zettelExplore } = await import("./zettelkasten-G0-ZTybr.mjs");
|
|
9725
9763
|
const result = await zettelExplore(await getFedBackend(), {
|
|
9726
9764
|
startNote: note,
|
|
9727
9765
|
depth,
|
|
@@ -9786,7 +9824,7 @@ async function cmdHealth(opts) {
|
|
|
9786
9824
|
const projectPath = opts.project;
|
|
9787
9825
|
const recentDays = parseInt(opts.days ?? "30", 10);
|
|
9788
9826
|
const includeTypes = opts.include ? opts.include.split(",").map((s) => s.trim()) : void 0;
|
|
9789
|
-
const { zettelHealth } = await import("./zettelkasten-
|
|
9827
|
+
const { zettelHealth } = await import("./zettelkasten-G0-ZTybr.mjs");
|
|
9790
9828
|
const result = await zettelHealth(await getFedBackend(), {
|
|
9791
9829
|
scope,
|
|
9792
9830
|
projectPath,
|
|
@@ -9857,7 +9895,7 @@ async function cmdSurprise(note, opts) {
|
|
|
9857
9895
|
const limit = parseInt(opts.limit ?? "10", 10);
|
|
9858
9896
|
const minSimilarity = parseFloat(opts.minSimilarity ?? "0.3");
|
|
9859
9897
|
const minGraphDistance = parseInt(opts.minDistance ?? "3", 10);
|
|
9860
|
-
const { zettelSurprise } = await import("./zettelkasten-
|
|
9898
|
+
const { zettelSurprise } = await import("./zettelkasten-G0-ZTybr.mjs");
|
|
9861
9899
|
const backend = await getFedBackend();
|
|
9862
9900
|
console.log();
|
|
9863
9901
|
console.log(header(" PAI Zettel Surprise"));
|
|
@@ -9912,7 +9950,7 @@ async function cmdSuggest(note, opts) {
|
|
|
9912
9950
|
const vaultProjectId = parseInt(opts.vaultProjectId, 10);
|
|
9913
9951
|
const limit = parseInt(opts.limit ?? "5", 10);
|
|
9914
9952
|
const excludeLinked = opts.excludeLinked !== false;
|
|
9915
|
-
const { zettelSuggest } = await import("./zettelkasten-
|
|
9953
|
+
const { zettelSuggest } = await import("./zettelkasten-G0-ZTybr.mjs");
|
|
9916
9954
|
const backend = await getFedBackend();
|
|
9917
9955
|
console.log();
|
|
9918
9956
|
console.log(header(" PAI Zettel Suggest"));
|
|
@@ -9965,7 +10003,7 @@ async function cmdConverse(question, opts) {
|
|
|
9965
10003
|
const vaultProjectId = parseInt(opts.vaultProjectId, 10);
|
|
9966
10004
|
const depth = parseInt(opts.depth ?? "2", 10);
|
|
9967
10005
|
const limit = parseInt(opts.limit ?? "15", 10);
|
|
9968
|
-
const { zettelConverse } = await import("./zettelkasten-
|
|
10006
|
+
const { zettelConverse } = await import("./zettelkasten-G0-ZTybr.mjs");
|
|
9969
10007
|
const backend = await getFedBackend();
|
|
9970
10008
|
console.log();
|
|
9971
10009
|
console.log(header(" PAI Zettel Converse"));
|
|
@@ -10028,7 +10066,7 @@ async function cmdThemes(opts) {
|
|
|
10028
10066
|
const minClusterSize = parseInt(opts.minSize ?? "3", 10);
|
|
10029
10067
|
const maxThemes = parseInt(opts.maxThemes ?? "10", 10);
|
|
10030
10068
|
const similarityThreshold = parseFloat(opts.threshold ?? "0.65");
|
|
10031
|
-
const { zettelThemes } = await import("./zettelkasten-
|
|
10069
|
+
const { zettelThemes } = await import("./zettelkasten-G0-ZTybr.mjs");
|
|
10032
10070
|
const backend = await getFedBackend();
|
|
10033
10071
|
console.log();
|
|
10034
10072
|
console.log(header(" PAI Zettel Themes"));
|
|
@@ -13990,16 +14028,13 @@ function stepBuild(repoDir) {
|
|
|
13990
14028
|
*/
|
|
13991
14029
|
function stepRestartDaemon(repoDir) {
|
|
13992
14030
|
step("Restarting PAI daemon...");
|
|
13993
|
-
const
|
|
13994
|
-
if (
|
|
13995
|
-
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
success(`Sent SIGHUP to daemon (PID ${pid}).`);
|
|
13999
|
-
return;
|
|
14000
|
-
}
|
|
14031
|
+
const pid = resolveDaemonPid();
|
|
14032
|
+
if (pid) {
|
|
14033
|
+
if (capture(`kill -HUP ${pid}`) !== null) {
|
|
14034
|
+
success(`Sent SIGHUP to daemon (PID ${pid}).`);
|
|
14035
|
+
return;
|
|
14001
14036
|
}
|
|
14002
|
-
}
|
|
14037
|
+
}
|
|
14003
14038
|
if (spawnSync("pai", ["daemon", "restart"], {
|
|
14004
14039
|
cwd: repoDir,
|
|
14005
14040
|
stdio: "pipe",
|
|
@@ -16103,7 +16138,7 @@ async function migrateToPostgres(opts = {}) {
|
|
|
16103
16138
|
const dump = pgDump(container, pgConfig, dumpPath);
|
|
16104
16139
|
if (!dump.ok) return refused(dump.reason, dryRun);
|
|
16105
16140
|
}
|
|
16106
|
-
const { PostgresBackend } = await import("./postgres-
|
|
16141
|
+
const { PostgresBackend } = await import("./postgres-B2BEBT-J.mjs");
|
|
16107
16142
|
await PostgresBackend.ensureDatabase(pgConfig);
|
|
16108
16143
|
const sqlite = new BetterSqlite3(sqliteFederationPath, { readonly: true });
|
|
16109
16144
|
const registrySqlite = sqliteRegistryPath === sqliteFederationPath ? sqlite : new BetterSqlite3(sqliteRegistryPath, { readonly: true });
|
|
@@ -16674,7 +16709,7 @@ async function getSessionTags(registryBackend, sessionId) {
|
|
|
16674
16709
|
* Session CRUD commands: list, info, rename, slug, tag, route, active, auto-route.
|
|
16675
16710
|
*/
|
|
16676
16711
|
async function cmdList(projectSlug, opts) {
|
|
16677
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16712
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16678
16713
|
const registryBackend = await getRegistryBackend();
|
|
16679
16714
|
const limit = parseInt(opts.limit ?? "20", 10);
|
|
16680
16715
|
let project;
|
|
@@ -16739,7 +16774,7 @@ async function cmdList(projectSlug, opts) {
|
|
|
16739
16774
|
console.log(dim$1(` ${rows.length} session(s) shown (limit: ${limit})`));
|
|
16740
16775
|
}
|
|
16741
16776
|
async function cmdInfo(projectSlug, sessionNumber) {
|
|
16742
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16777
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16743
16778
|
const registryBackend = await getRegistryBackend();
|
|
16744
16779
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16745
16780
|
if (!project) {
|
|
@@ -16763,7 +16798,7 @@ async function cmdInfo(projectSlug, sessionNumber) {
|
|
|
16763
16798
|
console.log();
|
|
16764
16799
|
}
|
|
16765
16800
|
async function cmdRename(projectSlug, numberOrLatest, newSlug) {
|
|
16766
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16801
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16767
16802
|
await cmdRenameWith(await getRegistryBackend(), projectSlug, numberOrLatest, newSlug);
|
|
16768
16803
|
}
|
|
16769
16804
|
async function cmdRenameWith(registryBackend, projectSlug, numberOrLatest, newSlug) {
|
|
@@ -16826,7 +16861,7 @@ async function cmdRenameWith(registryBackend, projectSlug, numberOrLatest, newSl
|
|
|
16826
16861
|
console.log();
|
|
16827
16862
|
}
|
|
16828
16863
|
async function cmdSlug(projectSlug, numberOrLatest, opts) {
|
|
16829
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16864
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16830
16865
|
const registryBackend = await getRegistryBackend();
|
|
16831
16866
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16832
16867
|
if (!project) {
|
|
@@ -16856,7 +16891,7 @@ async function cmdSlug(projectSlug, numberOrLatest, opts) {
|
|
|
16856
16891
|
}
|
|
16857
16892
|
}
|
|
16858
16893
|
async function cmdTag(projectSlug, sessionNumber, rawTags) {
|
|
16859
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16894
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16860
16895
|
const registryBackend = await getRegistryBackend();
|
|
16861
16896
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16862
16897
|
if (!project) {
|
|
@@ -16896,7 +16931,7 @@ async function cmdTag(projectSlug, sessionNumber, rawTags) {
|
|
|
16896
16931
|
console.log();
|
|
16897
16932
|
}
|
|
16898
16933
|
async function cmdRoute(projectSlug, sessionNumber, targetProjectSlug, opts) {
|
|
16899
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16934
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16900
16935
|
const registryBackend = await getRegistryBackend();
|
|
16901
16936
|
const project = await getProject$1(registryBackend, projectSlug);
|
|
16902
16937
|
if (!project) {
|
|
@@ -16938,7 +16973,7 @@ async function cmdRoute(projectSlug, sessionNumber, targetProjectSlug, opts) {
|
|
|
16938
16973
|
console.log();
|
|
16939
16974
|
}
|
|
16940
16975
|
async function cmdActive(opts) {
|
|
16941
|
-
const { getRegistryBackend } = await import("./factory-
|
|
16976
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
16942
16977
|
const registryBackend = await getRegistryBackend();
|
|
16943
16978
|
const minutes = parseInt(opts.minutes ?? "60", 10);
|
|
16944
16979
|
const cutoff = Date.now() - minutes * 60 * 1e3;
|
|
@@ -17026,8 +17061,8 @@ async function cmdActive(opts) {
|
|
|
17026
17061
|
}
|
|
17027
17062
|
async function cmdAutoRoute(opts) {
|
|
17028
17063
|
const { autoRoute, formatAutoRouteJson } = await import("./auto-route-D6fW1Q8z.mjs");
|
|
17029
|
-
const { getRegistryBackend, createStorageBackend } = await import("./factory-
|
|
17030
|
-
const { loadConfig } = await import("./config-
|
|
17064
|
+
const { getRegistryBackend, createStorageBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
17065
|
+
const { loadConfig } = await import("./config-CnsDMETf.mjs");
|
|
17031
17066
|
const config = loadConfig();
|
|
17032
17067
|
const registryBackend = await getRegistryBackend();
|
|
17033
17068
|
const federation = await createStorageBackend(config);
|
|
@@ -17263,7 +17298,7 @@ async function cmdPause(opts) {
|
|
|
17263
17298
|
process.exitCode = 1;
|
|
17264
17299
|
return;
|
|
17265
17300
|
}
|
|
17266
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17301
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
17267
17302
|
const registryBackend = await getRegistryBackend();
|
|
17268
17303
|
const cwd = process.cwd();
|
|
17269
17304
|
const project = await resolveProjectByCwd(registryBackend, cwd);
|
|
@@ -17658,7 +17693,7 @@ function buildStopBody(project, sessionId) {
|
|
|
17658
17693
|
}
|
|
17659
17694
|
}
|
|
17660
17695
|
async function cmdHandover(projectSlug, numberOrLatest, sessionId) {
|
|
17661
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17696
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
17662
17697
|
const registryBackend = await getRegistryBackend();
|
|
17663
17698
|
let project;
|
|
17664
17699
|
if (projectSlug) {
|
|
@@ -17954,7 +17989,7 @@ function touchSentinel(rootPath) {
|
|
|
17954
17989
|
async function cmdAutosave(opts) {
|
|
17955
17990
|
const minGap = parseInt(opts.minGap ?? String(DEFAULT_MIN_GAP), 10);
|
|
17956
17991
|
const cwd = process.cwd();
|
|
17957
|
-
const { getRegistryBackend } = await import("./factory-
|
|
17992
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
17958
17993
|
const registryBackend = await getRegistryBackend();
|
|
17959
17994
|
const project = await resolveProjectByCwd(registryBackend, cwd);
|
|
17960
17995
|
if (!project) return;
|
|
@@ -18079,7 +18114,7 @@ async function cmdRecent(opts) {
|
|
|
18079
18114
|
shortId: s.shortId,
|
|
18080
18115
|
resumable: s.resumable,
|
|
18081
18116
|
sessionStatus: s.sessionStatus,
|
|
18082
|
-
age: fmtAge
|
|
18117
|
+
age: fmtAge(s.mtime),
|
|
18083
18118
|
mtime: s.mtime,
|
|
18084
18119
|
name: s.friendlyName,
|
|
18085
18120
|
lastUserPrompt: s.lastUserPrompt,
|
|
@@ -18117,7 +18152,7 @@ async function cmdRecent(opts) {
|
|
|
18117
18152
|
return [
|
|
18118
18153
|
chalk.dim(String(idx + 1)),
|
|
18119
18154
|
chalk.cyan(s.shortId),
|
|
18120
|
-
dim$1(fmtAge
|
|
18155
|
+
dim$1(fmtAge(s.mtime)),
|
|
18121
18156
|
name.length > 26 ? name.slice(0, 25) + "…" : name,
|
|
18122
18157
|
prompt,
|
|
18123
18158
|
s.userLines > 0 ? String(s.userLines) : dim$1("—"),
|
|
@@ -18217,7 +18252,7 @@ async function cmdGoto(query, opts) {
|
|
|
18217
18252
|
console.log(` fallback: ${chalk.yellow(argvFresh)}`);
|
|
18218
18253
|
if (resumableSession) {
|
|
18219
18254
|
console.log(`\n uuid: ${resumableSession.uuid}`);
|
|
18220
|
-
console.log(` age: ${fmtAge
|
|
18255
|
+
console.log(` age: ${fmtAge(resumableSession.mtime)}`);
|
|
18221
18256
|
console.log(` status: ${resumableSession.sessionStatus}`);
|
|
18222
18257
|
console.log(` sys: ${resumableSession.topLevelSystemLines} system lines`);
|
|
18223
18258
|
}
|
|
@@ -19027,89 +19062,6 @@ function registerWorkerConfigCommands(workerCmd) {
|
|
|
19027
19062
|
});
|
|
19028
19063
|
}
|
|
19029
19064
|
|
|
19030
|
-
//#endregion
|
|
19031
|
-
//#region src/workers/pending.ts
|
|
19032
|
-
/**
|
|
19033
|
-
* Pending worker results: finished workers whose worktree branch still holds
|
|
19034
|
-
* work that never reached the repo (commits not in HEAD, or uncommitted
|
|
19035
|
-
* files). Surfaced by `pai worker ps/pending`, the SessionStart hook, the
|
|
19036
|
-
* status line and the prepublish gate so an unmerged fix cannot be forgotten.
|
|
19037
|
-
*/
|
|
19038
|
-
/** Stale after this long: `pai worker gc` (archive) instead of merge. */
|
|
19039
|
-
const STALE_HOURS = 24;
|
|
19040
|
-
function toplevel(dir) {
|
|
19041
|
-
try {
|
|
19042
|
-
return git(dir, ["rev-parse", "--show-toplevel"]);
|
|
19043
|
-
} catch {
|
|
19044
|
-
return null;
|
|
19045
|
-
}
|
|
19046
|
-
}
|
|
19047
|
-
function fmtAge(ms) {
|
|
19048
|
-
const h = Math.floor(ms / 36e5);
|
|
19049
|
-
return h >= 48 ? `${Math.floor(h / 24)}d` : h >= 1 ? `${h}h` : `${Math.floor(ms / 6e4)}m`;
|
|
19050
|
-
}
|
|
19051
|
-
/** Finished workers with unmerged work; `repoRoot` limits to one repo, else every repo. */
|
|
19052
|
-
function pendingResults(logDir, repoRoot, now = Date.now()) {
|
|
19053
|
-
const want = repoRoot ? toplevel(repoRoot) : null;
|
|
19054
|
-
if (repoRoot && !want) return [];
|
|
19055
|
-
const out = [];
|
|
19056
|
-
for (const st of loadStatuses(logDir)) {
|
|
19057
|
-
if (st.archived || st.merged || isLive(st)) continue;
|
|
19058
|
-
if (!st.worktreeDir || !existsSync(st.worktreeDir)) continue;
|
|
19059
|
-
const repo = toplevel(st.cwd);
|
|
19060
|
-
if (!repo || want && repo !== want) continue;
|
|
19061
|
-
let commits = 0;
|
|
19062
|
-
let dirty = 0;
|
|
19063
|
-
try {
|
|
19064
|
-
if (st.branch) commits = git(repo, [
|
|
19065
|
-
"cherry",
|
|
19066
|
-
"HEAD",
|
|
19067
|
-
`refs/heads/${st.branch}`
|
|
19068
|
-
]).split("\n").filter((l) => l.startsWith("+")).length;
|
|
19069
|
-
dirty = uncommittedPaths(st.worktreeDir).filter((p) => !/(^|\/)node_modules(\/|$)/.test(p)).length;
|
|
19070
|
-
} catch {
|
|
19071
|
-
continue;
|
|
19072
|
-
}
|
|
19073
|
-
if (!commits && !dirty) continue;
|
|
19074
|
-
let ageMs = 0;
|
|
19075
|
-
try {
|
|
19076
|
-
ageMs = Math.max(0, now - statSync(statusPath(logDir, st.id)).mtimeMs);
|
|
19077
|
-
} catch {}
|
|
19078
|
-
out.push({
|
|
19079
|
-
id: st.id,
|
|
19080
|
-
label: st.label,
|
|
19081
|
-
repo,
|
|
19082
|
-
ageMs,
|
|
19083
|
-
age: fmtAge(ageMs),
|
|
19084
|
-
commits,
|
|
19085
|
-
dirty
|
|
19086
|
-
});
|
|
19087
|
-
}
|
|
19088
|
-
return out;
|
|
19089
|
-
}
|
|
19090
|
-
/** One human line per result, with the exact next command. */
|
|
19091
|
-
function formatPending(results, showRepo = false) {
|
|
19092
|
-
return results.map((r) => {
|
|
19093
|
-
const next = r.ageMs > STALE_HOURS * 36e5 ? "pai worker gc" : `pai worker merge ${r.id}`;
|
|
19094
|
-
const repo = showRepo ? ` ${r.repo}` : "";
|
|
19095
|
-
return `${r.id} ${r.age} ${r.commits} commit(s), ${r.dirty} dirty ${r.label}${repo} -> ${next}`;
|
|
19096
|
-
}).join("\n");
|
|
19097
|
-
}
|
|
19098
|
-
/**
|
|
19099
|
-
* Release gate: exit code and message for `pai worker pending --gate`.
|
|
19100
|
-
* PAI_ALLOW_PENDING=1 overrides.
|
|
19101
|
-
*/
|
|
19102
|
-
function pendingGate(results, env = process.env) {
|
|
19103
|
-
if (!results.length || env.PAI_ALLOW_PENDING === "1") return {
|
|
19104
|
-
code: 0,
|
|
19105
|
-
message: ""
|
|
19106
|
-
};
|
|
19107
|
-
return {
|
|
19108
|
-
code: 1,
|
|
19109
|
-
message: `${results.length} unmerged worker result(s) in this repo — merge or discard before publishing:\n${formatPending(results)}\nOverride deliberately with PAI_ALLOW_PENDING=1.`
|
|
19110
|
-
};
|
|
19111
|
-
}
|
|
19112
|
-
|
|
19113
19065
|
//#endregion
|
|
19114
19066
|
//#region src/workers/wait.ts
|
|
19115
19067
|
/**
|
|
@@ -20401,8 +20353,8 @@ async function analyzeProject(registryBackend, project) {
|
|
|
20401
20353
|
async function countVectorDbPaths(oldPaths) {
|
|
20402
20354
|
if (oldPaths.length === 0) return 0;
|
|
20403
20355
|
try {
|
|
20404
|
-
const { loadConfig } = await import("./config-
|
|
20405
|
-
const { createStorageBackend } = await import("./factory-
|
|
20356
|
+
const { loadConfig } = await import("./config-CnsDMETf.mjs");
|
|
20357
|
+
const { createStorageBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
20406
20358
|
const config = loadConfig();
|
|
20407
20359
|
if (config.storageBackend !== "postgres") return 0;
|
|
20408
20360
|
const backend = await createStorageBackend(config);
|
|
@@ -20419,8 +20371,8 @@ async function countVectorDbPaths(oldPaths) {
|
|
|
20419
20371
|
async function updateVectorDbPaths(moves) {
|
|
20420
20372
|
if (moves.length === 0) return 0;
|
|
20421
20373
|
try {
|
|
20422
|
-
const { loadConfig } = await import("./config-
|
|
20423
|
-
const { createStorageBackend } = await import("./factory-
|
|
20374
|
+
const { loadConfig } = await import("./config-CnsDMETf.mjs");
|
|
20375
|
+
const { createStorageBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
20424
20376
|
const config = loadConfig();
|
|
20425
20377
|
if (config.storageBackend !== "postgres") return 0;
|
|
20426
20378
|
const backend = await createStorageBackend(config);
|
|
@@ -20507,7 +20459,7 @@ async function displayDryRun(plans) {
|
|
|
20507
20459
|
console.log();
|
|
20508
20460
|
}
|
|
20509
20461
|
async function executeCleanup(plans, skipReindex) {
|
|
20510
|
-
const { getRegistryBackend } = await import("./factory-
|
|
20462
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
20511
20463
|
const registryBackend = await getRegistryBackend();
|
|
20512
20464
|
let deleted = 0;
|
|
20513
20465
|
let renamed = 0;
|
|
@@ -20704,7 +20656,7 @@ async function executeCleanup(plans, skipReindex) {
|
|
|
20704
20656
|
//#region src/cli/commands/session-cleanup/index.ts
|
|
20705
20657
|
function registerSessionCleanupCommand(sessionCmd) {
|
|
20706
20658
|
sessionCmd.command("cleanup [project-slug]").description("Clean up session notes: delete empties, auto-name unnamed, move into YYYY/MM/ hierarchy, renumber").option("--execute", "Actually perform the cleanup (default is dry-run)").option("--no-renumber", "Skip renumbering sessions after deletions").option("--no-reindex", "Skip triggering memory re-index after moves").action(async (projectSlug, opts) => {
|
|
20707
|
-
const { getRegistryBackend } = await import("./factory-
|
|
20659
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
20708
20660
|
const registryBackend = await getRegistryBackend();
|
|
20709
20661
|
const dryRun = !opts.execute;
|
|
20710
20662
|
const skipReindex = opts.reindex === false;
|
|
@@ -20774,7 +20726,7 @@ function finalizeNote(notePath) {
|
|
|
20774
20726
|
}
|
|
20775
20727
|
async function cmdEnd(opts) {
|
|
20776
20728
|
await cmdPause(opts);
|
|
20777
|
-
const { getRegistryBackend } = await import("./factory-
|
|
20729
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
20778
20730
|
const registryBackend = await getRegistryBackend();
|
|
20779
20731
|
const cwd = process.cwd();
|
|
20780
20732
|
const project = await registryBackend.findProjectByCwdPrefix(cwd);
|
|
@@ -21222,7 +21174,7 @@ async function cmdFind(query, opts) {
|
|
|
21222
21174
|
*/
|
|
21223
21175
|
async function getProjects(includeArchived) {
|
|
21224
21176
|
try {
|
|
21225
|
-
const { getRegistryBackend } = await import("./factory-
|
|
21177
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
21226
21178
|
const rows = await (await getRegistryBackend()).listProjectsWithSessionStats();
|
|
21227
21179
|
return includeArchived ? rows : rows.filter((p) => p.status === "active");
|
|
21228
21180
|
} catch {
|
|
@@ -21363,7 +21315,7 @@ function buildFeedFrom(allSessions, projects, liveSessions, allProjects) {
|
|
|
21363
21315
|
const tag = tagFor(e.status);
|
|
21364
21316
|
const name = chalk.white(pad(e.name, 22));
|
|
21365
21317
|
const where = dir ? dim$1(shorten(dir, 40)) : chalk.green("(running in another tab)");
|
|
21366
|
-
const age = e.status === "live" ? chalk.green("now") : e.lastActivity > 0 ? dim$1(fmtAge
|
|
21318
|
+
const age = e.status === "live" ? chalk.green("now") : e.lastActivity > 0 ? dim$1(fmtAge(e.lastActivity)) : dim$1("—");
|
|
21367
21319
|
const kwDisp = kw ? dim$1(" " + kw) : "";
|
|
21368
21320
|
const display = `${tag} ${name} ${pad(age, 5)} ${where}${kwDisp}`;
|
|
21369
21321
|
const search = `${e.name} ${dir ?? ""} ${kw}`.toLowerCase();
|
|
@@ -21429,7 +21381,7 @@ function contextFor(rec) {
|
|
|
21429
21381
|
const notes = recentMarkdown(rec.dir, 4);
|
|
21430
21382
|
if (notes.length) {
|
|
21431
21383
|
lines.push(dim$1("recent notes:"));
|
|
21432
|
-
for (const n of notes) lines.push(" " + dim$1(n.rel.slice(0, 60)) + " " + dim$1(fmtAge
|
|
21384
|
+
for (const n of notes) lines.push(" " + dim$1(n.rel.slice(0, 60)) + " " + dim$1(fmtAge(n.mtime)));
|
|
21433
21385
|
} else lines.push(dim$1("(no notes here yet)"));
|
|
21434
21386
|
ctxCache.set(rec.dir, lines);
|
|
21435
21387
|
return lines;
|
|
@@ -21696,7 +21648,7 @@ async function cmdPick(opts = {}) {
|
|
|
21696
21648
|
const onRemove = async (rec) => {
|
|
21697
21649
|
if (!rec.slug) return false;
|
|
21698
21650
|
try {
|
|
21699
|
-
const { getRegistryBackend } = await import("./factory-
|
|
21651
|
+
const { getRegistryBackend } = await import("./factory-CnKsU6zX.mjs");
|
|
21700
21652
|
const registryBackend = await getRegistryBackend();
|
|
21701
21653
|
const project = await registryBackend.getProjectBySlug(rec.slug);
|
|
21702
21654
|
if (!project || project.status !== "active") return false;
|
|
@@ -21981,4 +21933,4 @@ claude() {
|
|
|
21981
21933
|
|
|
21982
21934
|
//#endregion
|
|
21983
21935
|
export { drainStdio as n, buildProgram as t };
|
|
21984
|
-
//# sourceMappingURL=program-
|
|
21936
|
+
//# sourceMappingURL=program-DB-hoyfW.mjs.map
|