@tekmidian/pai 0.8.3 → 0.8.5

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.
@@ -13,7 +13,7 @@ import { n as formatDetection, r as formatDetectionJson, t as detectProject } fr
13
13
  import "../indexer-D53l5d1U.mjs";
14
14
  import { t as PaiClient } from "../ipc-client-CoyUHPod.mjs";
15
15
  import { a as expandHome, i as ensureConfigDir, n as CONFIG_FILE$2, o as loadConfig, t as CONFIG_DIR } from "../config-BuhHWyOK.mjs";
16
- import { t as createStorageBackend } from "../factory-Ygqe_bVZ.mjs";
16
+ import { t as createStorageBackend } from "../factory-BzWfxsvK.mjs";
17
17
  import { appendFileSync, chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
18
18
  import { homedir, platform, tmpdir } from "node:os";
19
19
  import { basename, dirname, join, relative, resolve } from "node:path";
@@ -1683,7 +1683,7 @@ function cmdActive(db, opts) {
1683
1683
  async function cmdAutoRoute(opts) {
1684
1684
  const { autoRoute, formatAutoRoute, formatAutoRouteJson } = await import("../auto-route-C-DrW6BL.mjs");
1685
1685
  const { openRegistry } = await import("../db-BtuN768f.mjs").then((n) => n.t);
1686
- const { createStorageBackend } = await import("../factory-Ygqe_bVZ.mjs").then((n) => n.n);
1686
+ const { createStorageBackend } = await import("../factory-BzWfxsvK.mjs").then((n) => n.n);
1687
1687
  const { loadConfig } = await import("../config-BuhHWyOK.mjs").then((n) => n.r);
1688
1688
  const config = loadConfig();
1689
1689
  const registryDb = openRegistry();
@@ -2302,7 +2302,7 @@ async function countVectorDbPaths(oldPaths) {
2302
2302
  if (oldPaths.length === 0) return 0;
2303
2303
  try {
2304
2304
  const { loadConfig } = await import("../config-BuhHWyOK.mjs").then((n) => n.r);
2305
- const { PostgresBackend } = await import("../postgres-CKf-EDtS.mjs");
2305
+ const { PostgresBackend } = await import("../postgres-DbUXNuy_.mjs");
2306
2306
  const config = loadConfig();
2307
2307
  if (config.storageBackend !== "postgres") return 0;
2308
2308
  const pgBackend = new PostgresBackend(config.postgres ?? {});
@@ -2323,7 +2323,7 @@ async function updateVectorDbPaths(moves) {
2323
2323
  if (moves.length === 0) return 0;
2324
2324
  try {
2325
2325
  const { loadConfig } = await import("../config-BuhHWyOK.mjs").then((n) => n.r);
2326
- const { PostgresBackend } = await import("../postgres-CKf-EDtS.mjs");
2326
+ const { PostgresBackend } = await import("../postgres-DbUXNuy_.mjs");
2327
2327
  const config = loadConfig();
2328
2328
  if (config.storageBackend !== "postgres") return 0;
2329
2329
  const pgBackend = new PostgresBackend(config.postgres ?? {});
@@ -3793,7 +3793,7 @@ function cmdLogs(opts) {
3793
3793
  }
3794
3794
  function registerDaemonCommands(daemonCmd) {
3795
3795
  daemonCmd.command("serve").description("Start the PAI daemon in the foreground").action(async () => {
3796
- const { serve } = await import("../daemon-Ds9dTptY.mjs").then((n) => n.t);
3796
+ const { serve } = await import("../daemon-BaYX-w_d.mjs").then((n) => n.t);
3797
3797
  const { loadConfig: lc, ensureConfigDir } = await import("../config-BuhHWyOK.mjs").then((n) => n.r);
3798
3798
  ensureConfigDir();
3799
3799
  await serve(lc());
@@ -6411,7 +6411,7 @@ async function cmdExplore(note, opts) {
6411
6411
  const depth = parseInt(opts.depth ?? "3", 10);
6412
6412
  const direction = opts.direction ?? "both";
6413
6413
  const mode = opts.mode ?? "all";
6414
- const { zettelExplore } = await import("../zettelkasten-cdajbnPr.mjs");
6414
+ const { zettelExplore } = await import("../zettelkasten-DhBKZQHF.mjs");
6415
6415
  const result = zettelExplore(getFedDb(), {
6416
6416
  startNote: note,
6417
6417
  depth,
@@ -6475,7 +6475,7 @@ async function cmdHealth(opts) {
6475
6475
  const projectPath = opts.project;
6476
6476
  const recentDays = parseInt(opts.days ?? "30", 10);
6477
6477
  const includeTypes = opts.include ? opts.include.split(",").map((s) => s.trim()) : void 0;
6478
- const { zettelHealth } = await import("../zettelkasten-cdajbnPr.mjs");
6478
+ const { zettelHealth } = await import("../zettelkasten-DhBKZQHF.mjs");
6479
6479
  const result = zettelHealth(getFedDb(), {
6480
6480
  scope,
6481
6481
  projectPath,
@@ -6544,7 +6544,7 @@ async function cmdSurprise(note, opts) {
6544
6544
  const limit = parseInt(opts.limit ?? "10", 10);
6545
6545
  const minSimilarity = parseFloat(opts.minSimilarity ?? "0.3");
6546
6546
  const minGraphDistance = parseInt(opts.minDistance ?? "3", 10);
6547
- const { zettelSurprise } = await import("../zettelkasten-cdajbnPr.mjs");
6547
+ const { zettelSurprise } = await import("../zettelkasten-DhBKZQHF.mjs");
6548
6548
  const db = getFedDb();
6549
6549
  console.log();
6550
6550
  console.log(header(" PAI Zettel Surprise"));
@@ -6597,7 +6597,7 @@ async function cmdSuggest(note, opts) {
6597
6597
  const vaultProjectId = parseInt(opts.vaultProjectId, 10);
6598
6598
  const limit = parseInt(opts.limit ?? "5", 10);
6599
6599
  const excludeLinked = opts.excludeLinked !== false;
6600
- const { zettelSuggest } = await import("../zettelkasten-cdajbnPr.mjs");
6600
+ const { zettelSuggest } = await import("../zettelkasten-DhBKZQHF.mjs");
6601
6601
  const db = getFedDb();
6602
6602
  console.log();
6603
6603
  console.log(header(" PAI Zettel Suggest"));
@@ -6648,7 +6648,7 @@ async function cmdConverse(question, opts) {
6648
6648
  const vaultProjectId = parseInt(opts.vaultProjectId, 10);
6649
6649
  const depth = parseInt(opts.depth ?? "2", 10);
6650
6650
  const limit = parseInt(opts.limit ?? "15", 10);
6651
- const { zettelConverse } = await import("../zettelkasten-cdajbnPr.mjs");
6651
+ const { zettelConverse } = await import("../zettelkasten-DhBKZQHF.mjs");
6652
6652
  const db = getFedDb();
6653
6653
  console.log();
6654
6654
  console.log(header(" PAI Zettel Converse"));
@@ -6709,7 +6709,7 @@ async function cmdThemes(opts) {
6709
6709
  const minClusterSize = parseInt(opts.minSize ?? "3", 10);
6710
6710
  const maxThemes = parseInt(opts.maxThemes ?? "10", 10);
6711
6711
  const similarityThreshold = parseFloat(opts.threshold ?? "0.65");
6712
- const { zettelThemes } = await import("../zettelkasten-cdajbnPr.mjs");
6712
+ const { zettelThemes } = await import("../zettelkasten-DhBKZQHF.mjs");
6713
6713
  const db = getFedDb();
6714
6714
  console.log();
6715
6715
  console.log(header(" PAI Zettel Themes"));
@@ -7,10 +7,10 @@ import "../search-DC1qhkKn.mjs";
7
7
  import "../indexer-D53l5d1U.mjs";
8
8
  import { t as PaiClient } from "../ipc-client-CoyUHPod.mjs";
9
9
  import { i as ensureConfigDir, o as loadConfig } from "../config-BuhHWyOK.mjs";
10
- import "../factory-Ygqe_bVZ.mjs";
11
- import { n as serve } from "../daemon-Ds9dTptY.mjs";
10
+ import "../factory-BzWfxsvK.mjs";
11
+ import { n as serve } from "../daemon-BaYX-w_d.mjs";
12
12
  import "../state-C6_vqz7w.mjs";
13
- import "../tools-DcaJlYDN.mjs";
13
+ import "../tools-BXSwlzeH.mjs";
14
14
  import "../detector-jGBuYQJM.mjs";
15
15
  import { Command } from "commander";
16
16
 
@@ -4,9 +4,9 @@ import { d as sha256 } from "./helpers-BEST-4Gx.mjs";
4
4
  import { n as indexAll } from "./sync-BOsnEj2-.mjs";
5
5
  import { t as configureEmbeddingModel } from "./embeddings-DGRAPAYb.mjs";
6
6
  import { n as CONFIG_FILE, s as DEFAULT_NOTIFICATION_CONFIG, t as CONFIG_DIR } from "./config-BuhHWyOK.mjs";
7
- import { t as createStorageBackend } from "./factory-Ygqe_bVZ.mjs";
7
+ import { t as createStorageBackend } from "./factory-BzWfxsvK.mjs";
8
8
  import { C as setStorageBackend, E as startTime, O as storageBackend, S as setStartTime, T as shutdownRequested, _ as setLastIndexTime, a as indexSchedulerTimer, b as setRegistryDb, c as lastVaultIndexTime, d as setDaemonConfig, f as setEmbedInProgress, g as setLastEmbedTime, h as setIndexSchedulerTimer, i as indexInProgress, k as vaultIndexInProgress, l as notificationConfig, m as setIndexInProgress, n as embedInProgress, o as lastEmbedTime, p as setEmbedSchedulerTimer, r as embedSchedulerTimer, s as lastIndexTime, t as daemonConfig, u as registryDb, v as setLastVaultIndexTime, w as setVaultIndexInProgress, x as setShutdownRequested, y as setNotificationConfig } from "./state-C6_vqz7w.mjs";
9
- import { a as toolProjectDetect, c as toolProjectList, d as toolMemorySearch, i as toolSessionRoute, l as toolProjectTodo, n as toolRegistrySearch, o as toolProjectHealth, r as toolSessionList, s as toolProjectInfo, u as toolMemoryGet } from "./tools-DcaJlYDN.mjs";
9
+ import { a as toolProjectDetect, c as toolProjectList, d as toolMemorySearch, i as toolSessionRoute, l as toolProjectTodo, n as toolRegistrySearch, o as toolProjectHealth, r as toolSessionList, s as toolProjectInfo, u as toolMemoryGet } from "./tools-BXSwlzeH.mjs";
10
10
  import { t as detectTopicShift } from "./detector-jGBuYQJM.mjs";
11
11
  import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
12
12
  import { homedir, setPriority } from "node:os";
@@ -161,7 +161,7 @@ async function runVaultIndex() {
161
161
  const t0 = Date.now();
162
162
  process.stderr.write("[pai-daemon] Starting vault index run...\n");
163
163
  try {
164
- const { indexVault } = await import("./vault-indexer-Bi2cRmn7.mjs");
164
+ const { indexVault } = await import("./vault-indexer-B-aJpRZC.mjs");
165
165
  const r = await indexVault(storageBackend, vaultProjectId, daemonConfig.vaultPath);
166
166
  const elapsed = Date.now() - t0;
167
167
  setLastVaultIndexTime(Date.now());
@@ -697,8 +697,10 @@ async function dispatchTool(method, params) {
697
697
  case "zettel_surprise":
698
698
  case "zettel_suggest":
699
699
  case "zettel_converse":
700
- case "zettel_themes": {
701
- const { toolZettelExplore, toolZettelHealth, toolZettelSurprise, toolZettelSuggest, toolZettelConverse, toolZettelThemes } = await import("./tools-DcaJlYDN.mjs").then((n) => n.t);
700
+ case "zettel_themes":
701
+ case "zettel_god_notes":
702
+ case "zettel_communities": {
703
+ const { toolZettelExplore, toolZettelHealth, toolZettelSurprise, toolZettelSuggest, toolZettelConverse, toolZettelThemes, toolZettelGodNotes, toolZettelCommunities } = await import("./tools-BXSwlzeH.mjs").then((n) => n.t);
702
704
  switch (method) {
703
705
  case "zettel_explore": return toolZettelExplore(storageBackend, p);
704
706
  case "zettel_health": return toolZettelHealth(storageBackend, p);
@@ -706,6 +708,8 @@ async function dispatchTool(method, params) {
706
708
  case "zettel_suggest": return toolZettelSuggest(storageBackend, p);
707
709
  case "zettel_converse": return toolZettelConverse(storageBackend, p);
708
710
  case "zettel_themes": return toolZettelThemes(storageBackend, p);
711
+ case "zettel_god_notes": return toolZettelGodNotes(storageBackend, p);
712
+ case "zettel_communities": return toolZettelCommunities(storageBackend, p);
709
713
  }
710
714
  break;
711
715
  }
@@ -1820,12 +1824,19 @@ function extractTopic(summaryText) {
1820
1824
  return match[1].trim();
1821
1825
  }
1822
1826
  /**
1823
- * Extract the title/topic from an existing session note.
1824
- * Looks at the H1 "# Session NNNN: Title" line.
1827
+ * Extract the topic from an existing session note.
1828
+ * First checks for a <!-- TOPIC: ... --> comment (stored by previous summaries).
1829
+ * Falls back to the H1 "# Session NNNN: Title" line.
1830
+ *
1831
+ * The HTML comment is the reliable source because the H1 gets renamed by
1832
+ * renameSessionNote, which can add/change words and cause false topic shifts.
1825
1833
  */
1826
1834
  function extractExistingNoteTitle(notePath) {
1827
1835
  try {
1828
- const match = readFileSync(notePath, "utf-8").match(/^# Session \d+:\s*(.+)$/m);
1836
+ const content = readFileSync(notePath, "utf-8");
1837
+ const topicComment = content.match(/<!-- TOPIC:\s*(.+?)\s*-->/);
1838
+ if (topicComment) return topicComment[1].trim();
1839
+ const match = content.match(/^# Session \d+:\s*(.+)$/m);
1829
1840
  if (match) return match[1].trim();
1830
1841
  } catch {}
1831
1842
  return null;
@@ -1967,6 +1978,9 @@ function writeSessionNote(cwd, summaryText, filesModified) {
1967
1978
  function updateNoteWithSummary(notePath, summaryText) {
1968
1979
  if (!existsSync(notePath)) return;
1969
1980
  let content = readFileSync(notePath, "utf-8");
1981
+ const newTopic = extractTopic(summaryText);
1982
+ if (newTopic) if (content.includes("<!-- TOPIC:")) content = content.replace(/<!-- TOPIC:.*?-->/, `<!-- TOPIC: ${newTopic} -->`);
1983
+ else content = content.replace(/^(# Session .+)$/m, `$1\n<!-- TOPIC: ${newTopic} -->`);
1970
1984
  const workDoneMatch = summaryText.match(/## Work Done\n\n([\s\S]*?)(?=\n## Key Decisions|\n## Known Issues|\n\*\*Tags|\n$)/);
1971
1985
  if (workDoneMatch) {
1972
1986
  const aiWorkContent = workDoneMatch[1].trim();
@@ -2006,14 +2020,19 @@ function createNoteFromSummary(notesDir, summaryText) {
2006
2020
  const numberMatch = noteFilename.match(/^(\d+)/);
2007
2021
  const noteNumber = numberMatch ? numberMatch[1] : "0000";
2008
2022
  const titleMatch = summaryText.match(/^# Session:\s*(.+)$/m);
2009
- writeFileSync(notePath, `# Session ${noteNumber}: ${titleMatch ? titleMatch[1].trim() : "New Session"}
2023
+ const title = titleMatch ? titleMatch[1].trim() : "New Session";
2024
+ const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
2025
+ const topic = extractTopic(summaryText);
2026
+ const aiBody = summaryText.replace(/^TOPIC:.*$/m, "").replace(/^# Session:.*$/m, "").replace(/^\*\*Date:\*\*.*$/m, "").replace(/^\*\*Status:\*\*.*$/m, "").replace(/^---$/m, "").trim();
2027
+ writeFileSync(notePath, `# Session ${noteNumber}: ${title}
2028
+ ${topic ? `<!-- TOPIC: ${topic} -->` : ""}
2010
2029
 
2011
- **Date:** ${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}
2030
+ **Date:** ${date}
2012
2031
  **Status:** In Progress
2013
2032
 
2014
2033
  ---
2015
2034
 
2016
- ${summaryText.replace(/^TOPIC:.*$/m, "").replace(/^# Session:.*$/m, "").replace(/^\*\*Date:\*\*.*$/m, "").replace(/^\*\*Status:\*\*.*$/m, "").replace(/^---$/m, "").trim()}
2035
+ ${aiBody}
2017
2036
 
2018
2037
  ---
2019
2038
 
@@ -3043,4 +3062,4 @@ var daemon_exports = /* @__PURE__ */ __exportAll({ serve: () => serve });
3043
3062
 
3044
3063
  //#endregion
3045
3064
  export { serve as n, daemon_exports as t };
3046
- //# sourceMappingURL=daemon-Ds9dTptY.mjs.map
3065
+ //# sourceMappingURL=daemon-BaYX-w_d.mjs.map