@ulpi/cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +139 -20
  2. package/dist/{chunk-6JCMYYBT.js → chunk-FNPD3V2X.js} +194 -110
  3. package/dist/{chunk-PKD4ASEM.js → chunk-S253WCQJ.js} +1 -1
  4. package/dist/{chunk-Q4HIY43N.js → chunk-UA6EFK64.js} +7 -11
  5. package/dist/{chunk-DBMUNBNB.js → chunk-VGZLMUNO.js} +148 -18
  6. package/dist/{chunk-247GVVKK.js → chunk-ZLYRPD7I.js} +18 -16
  7. package/dist/{codemap-RRJIDBQ5.js → codemap-3BVYMMVM.js} +49 -17
  8. package/dist/{dist-7LHZ65GC.js → dist-3SNTTNM3.js} +4 -3
  9. package/dist/{dist-R5F4MX3I.js → dist-57UMTPGR.js} +4 -3
  10. package/dist/{dist-LZKZFPVX.js → dist-MFFX7TZW.js} +5 -2
  11. package/dist/{dist-W7K4WPAF.js → dist-QYFQYSXP.js} +41 -13
  12. package/dist/{dist-R5ZJ4LX5.js → dist-YA2BWZB2.js} +1 -1
  13. package/dist/{history-ATTUKOHO.js → history-UG65BCO6.js} +5 -2
  14. package/dist/index.js +32 -20
  15. package/dist/{init-AY5C2ZAS.js → init-22PO3EQB.js} +2 -2
  16. package/dist/{memory-J3G24QHS.js → memory-IT4H3WRD.js} +114 -24
  17. package/dist/{server-MOYPE4SM-N7SE2AN7.js → server-KYER5KX3-43RQQ4MY.js} +1 -1
  18. package/dist/skills/ulpi-generate-guardian/SKILL.md +246 -7
  19. package/dist/skills/ulpi-generate-guardian/references/framework-rules.md +161 -4
  20. package/dist/skills/ulpi-generate-guardian/references/language-rules.md +13 -18
  21. package/dist/{ui-L7UAWXDY.js → ui-3EFREFSY.js} +2 -2
  22. package/dist/ui.html +99 -99
  23. package/dist/{update-M2B4RLGH.js → update-364RHTAO.js} +1 -1
  24. package/dist/{version-checker-ANCS3IHR.js → version-checker-DTAS4ZYK.js} +1 -1
  25. package/package.json +29 -28
  26. package/LICENSE +0 -21
@@ -46,6 +46,7 @@ import {
46
46
  parseSourceWithLanguage,
47
47
  processIncremental,
48
48
  queryBM25,
49
+ rebuildDepgraph,
49
50
  recallAtK,
50
51
  releaseCodemapLock,
51
52
  removeDocuments,
@@ -60,18 +61,19 @@ import {
60
61
  searchCode,
61
62
  searchSymbols,
62
63
  tokenize
63
- } from "./chunk-DBMUNBNB.js";
64
+ } from "./chunk-VGZLMUNO.js";
64
65
  import "./chunk-NNUWU6CV.js";
65
66
  import "./chunk-YM2HV4IA.js";
66
67
  import "./chunk-74WVVWJ4.js";
67
68
  import "./chunk-KIKPIH6N.js";
69
+ import "./chunk-ZLYRPD7I.js";
68
70
  import {
69
71
  OpenAIEmbedder
70
72
  } from "./chunk-2HEE5OKX.js";
73
+ import "./chunk-7LXY5UVC.js";
71
74
  import {
72
75
  OllamaEmbedder
73
76
  } from "./chunk-KLEASXUR.js";
74
- import "./chunk-7LXY5UVC.js";
75
77
  import "./chunk-4VNS5WPM.js";
76
78
  export {
77
79
  CodemapStore,
@@ -123,6 +125,7 @@ export {
123
125
  parseSourceWithLanguage,
124
126
  processIncremental,
125
127
  queryBM25,
128
+ rebuildDepgraph,
126
129
  recallAtK,
127
130
  releaseCodemapLock,
128
131
  removeDocuments,
@@ -4,32 +4,33 @@ import {
4
4
  Server,
5
5
  StdioServerTransport
6
6
  } from "./chunk-JWUUVXIV.js";
7
- import {
8
- getIncomingEdges,
9
- getOutgoingEdges,
10
- getTransitiveDeps,
11
- getTransitiveRdeps,
12
- loadGraph,
13
- loadMetrics,
14
- loadPageRank
15
- } from "./chunk-247GVVKK.js";
16
7
  import {
17
8
  getCodemapStatus,
18
9
  loadManifest,
19
10
  loadSymbolIndex,
11
+ rebuildDepgraph,
20
12
  runInitPipeline,
21
13
  searchCode,
22
14
  searchSymbols
23
- } from "./chunk-DBMUNBNB.js";
15
+ } from "./chunk-VGZLMUNO.js";
24
16
  import "./chunk-NNUWU6CV.js";
25
17
  import "./chunk-YM2HV4IA.js";
26
18
  import "./chunk-74WVVWJ4.js";
27
19
  import "./chunk-KIKPIH6N.js";
20
+ import {
21
+ getIncomingEdges,
22
+ getOutgoingEdges,
23
+ getTransitiveDeps,
24
+ getTransitiveRdeps,
25
+ loadGraph,
26
+ loadMetrics,
27
+ loadPageRank
28
+ } from "./chunk-ZLYRPD7I.js";
28
29
  import "./chunk-2HEE5OKX.js";
29
- import "./chunk-KLEASXUR.js";
30
30
  import {
31
31
  getCurrentBranch
32
32
  } from "./chunk-7LXY5UVC.js";
33
+ import "./chunk-KLEASXUR.js";
33
34
  import "./chunk-4VNS5WPM.js";
34
35
 
35
36
  // ../../packages/codemap-mcp/dist/index.js
@@ -531,6 +532,31 @@ async function handleGetDepgraphStats(projectDir, _args, branch) {
531
532
  content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
532
533
  };
533
534
  }
535
+ var rebuildDepgraphTool = {
536
+ name: "rebuild_depgraph",
537
+ description: "Rebuild the dependency graph (tags, PageRank, cycles, coupling) without re-embedding. Faster than full reindex when only the depgraph is missing or stale.",
538
+ inputSchema: {
539
+ type: "object",
540
+ properties: {}
541
+ }
542
+ };
543
+ async function handleRebuildDepgraph(projectDir, _args, branch) {
544
+ const result = await rebuildDepgraph(projectDir, void 0, branch);
545
+ const payload = {
546
+ nodeCount: result.nodeCount,
547
+ edgeCount: result.edgeCount,
548
+ definitionCount: result.definitionCount,
549
+ referenceCount: result.referenceCount,
550
+ cycleCount: result.cycleCount,
551
+ taggedFiles: result.taggedFiles,
552
+ totalFiles: result.totalFiles,
553
+ durationMs: result.durationMs,
554
+ summary: `Rebuilt depgraph: ${result.nodeCount} nodes, ${result.edgeCount} edges, ${result.definitionCount} defs, ${result.referenceCount} refs, ${result.cycleCount} cycles (${result.taggedFiles}/${result.totalFiles} files tagged) in ${(result.durationMs / 1e3).toFixed(1)}s`
555
+ };
556
+ return {
557
+ content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
558
+ };
559
+ }
534
560
  var ALL_TOOLS = [
535
561
  searchCodeTool,
536
562
  searchSymbolsTool,
@@ -542,7 +568,8 @@ var ALL_TOOLS = [
542
568
  getFileRankTool,
543
569
  findCyclesTool,
544
570
  getCouplingMetricsTool,
545
- getDepgraphStatsTool
571
+ getDepgraphStatsTool,
572
+ rebuildDepgraphTool
546
573
  ];
547
574
  var HANDLERS = {
548
575
  search_code: handleSearchCode,
@@ -555,7 +582,8 @@ var HANDLERS = {
555
582
  get_file_rank: handleGetFileRank,
556
583
  find_cycles: handleFindCycles,
557
584
  get_coupling_metrics: handleGetCouplingMetrics,
558
- get_depgraph_stats: handleGetDepgraphStats
585
+ get_depgraph_stats: handleGetDepgraphStats,
586
+ rebuild_depgraph: handleRebuildDepgraph
559
587
  };
560
588
  function createMcpServer(options) {
561
589
  const server = new Server(
@@ -24,7 +24,7 @@ import {
24
24
  savePageRank,
25
25
  saveTagsCache,
26
26
  updateCacheEntry
27
- } from "./chunk-247GVVKK.js";
27
+ } from "./chunk-ZLYRPD7I.js";
28
28
  import "./chunk-7LXY5UVC.js";
29
29
  import "./chunk-4VNS5WPM.js";
30
30
  export {
@@ -318,6 +318,8 @@ function enrichEntry(entry, rawEvents, model = DEFAULT_AI_MODEL) {
318
318
  reject(new Error("Claude CLI not found"));
319
319
  return;
320
320
  }
321
+ const env = { ...process.env };
322
+ delete env.CLAUDECODE;
321
323
  const proc = spawn(claudePath, [
322
324
  "--print",
323
325
  "--model",
@@ -329,7 +331,8 @@ function enrichEntry(entry, rawEvents, model = DEFAULT_AI_MODEL) {
329
331
  "--permission-mode",
330
332
  "bypassPermissions"
331
333
  ], {
332
- stdio: ["pipe", "pipe", "pipe"]
334
+ stdio: ["pipe", "pipe", "pipe"],
335
+ env
333
336
  });
334
337
  let stdout = "";
335
338
  let stderr = "";
@@ -412,7 +415,7 @@ async function initSubcommand(projectDir) {
412
415
  }
413
416
  const projectName = path2.basename(projectDir);
414
417
  try {
415
- initHistoryBranch(projectDir, projectName, "0.1.0");
418
+ initHistoryBranch(projectDir, projectName, "0.1.2");
416
419
  } catch (err) {
417
420
  const message = err instanceof Error ? err.message : String(err);
418
421
  console.log(chalk.red(`Error: ${message}`));
package/dist/index.js CHANGED
@@ -138,10 +138,10 @@ async function handleSessionStart(ctx) {
138
138
  if (shouldPromptForGeneration(projectDir2)) {
139
139
  outputGenerationPrompt();
140
140
  }
141
- import("./version-checker-ANCS3IHR.js").then((m) => m.checkForUpdates()).catch(() => {
141
+ import("./version-checker-DTAS4ZYK.js").then((m) => m.checkForUpdates()).catch(() => {
142
142
  });
143
143
  try {
144
- const { isMemoryEnabled, loadMemoryConfig, getTopMemories, formatMemoriesForAgent } = await import("./dist-R5F4MX3I.js");
144
+ const { isMemoryEnabled, loadMemoryConfig, getTopMemories, formatMemoriesForAgent } = await import("./dist-57UMTPGR.js");
145
145
  if (isMemoryEnabled(projectDir2)) {
146
146
  const config = loadMemoryConfig(projectDir2);
147
147
  if (config.surfaceOnStart) {
@@ -155,7 +155,7 @@ async function handleSessionStart(ctx) {
155
155
  } catch {
156
156
  }
157
157
  try {
158
- const { loadCodemapConfig } = await import("./dist-LZKZFPVX.js");
158
+ const { loadCodemapConfig } = await import("./dist-MFFX7TZW.js");
159
159
  const { getCodemapBranch, getCurrentBranch } = await import("./dist-RKOGLK7R.js");
160
160
  const { historyBranchExists: historyBranchExists2 } = await import("./dist-RJGCUS3L.js");
161
161
  const codemapConfig = loadCodemapConfig(projectDir2);
@@ -163,7 +163,7 @@ async function handleSessionStart(ctx) {
163
163
  const branch = state.branch ?? getCurrentBranch(projectDir2);
164
164
  const shadowBranch = getCodemapBranch(branch);
165
165
  if (historyBranchExists2(projectDir2, shadowBranch)) {
166
- const { importIndex } = await import("./dist-LZKZFPVX.js");
166
+ const { importIndex } = await import("./dist-MFFX7TZW.js");
167
167
  await importIndex(projectDir2, branch);
168
168
  }
169
169
  }
@@ -1473,7 +1473,7 @@ ${failureFeedback.join("\n\n")}`
1473
1473
  }
1474
1474
  }
1475
1475
  try {
1476
- const { isMemoryEnabled, loadMemoryConfig, appendMemoryEvent, toClassificationEvent } = await import("./dist-R5F4MX3I.js");
1476
+ const { isMemoryEnabled, loadMemoryConfig, appendMemoryEvent, toClassificationEvent } = await import("./dist-57UMTPGR.js");
1477
1477
  if (isMemoryEnabled(projectDir2)) {
1478
1478
  const memConfig = loadMemoryConfig(projectDir2);
1479
1479
  if (memConfig.captureMode === "continuous") {
@@ -1493,7 +1493,7 @@ ${failureFeedback.join("\n\n")}`
1493
1493
  }
1494
1494
  if (input.tool_name === "Bash" && /\bgit\s+push\b/.test(String(input.tool_input?.command ?? ""))) {
1495
1495
  try {
1496
- const { loadCodemapConfig, getCodemapStatus, exportIndex } = await import("./dist-LZKZFPVX.js");
1496
+ const { loadCodemapConfig, getCodemapStatus, exportIndex } = await import("./dist-MFFX7TZW.js");
1497
1497
  const { getCurrentBranch } = await import("./dist-RKOGLK7R.js");
1498
1498
  const codemapConfig = loadCodemapConfig(projectDir2);
1499
1499
  if (codemapConfig.autoExport) {
@@ -1747,6 +1747,7 @@ ${warnings.map((w) => ` - ${w}`).join("\n")}`
1747
1747
  }
1748
1748
 
1749
1749
  // src/hooks/session-end.ts
1750
+ import { spawn } from "child_process";
1750
1751
  async function captureSessionCommits(ctx) {
1751
1752
  const { input, state, projectDir: projectDir2 } = ctx;
1752
1753
  if (!state.headAtStart) return;
@@ -1834,24 +1835,35 @@ async function handleSessionEnd(ctx) {
1834
1835
  } catch {
1835
1836
  }
1836
1837
  try {
1837
- const memEngine = await import("./dist-R5F4MX3I.js");
1838
+ const memEngine = await import("./dist-57UMTPGR.js");
1838
1839
  if (memEngine.isMemoryEnabled(projectDir2)) {
1839
1840
  const config = memEngine.loadMemoryConfig(projectDir2);
1840
1841
  memEngine.finalizeCapture(input.session_id, state, projectDir2);
1841
1842
  if (config.classifier.enabled) {
1842
- await memEngine.classifySession(projectDir2, input.session_id);
1843
- }
1844
- if (config.autoExport) {
1845
1843
  try {
1846
- memEngine.exportMemories(projectDir2);
1844
+ const args2 = ["memory", "classify", "-p", projectDir2, "--session", input.session_id];
1845
+ if (config.autoExport) args2.push("--export");
1846
+ const child = spawn(process.execPath, [process.argv[1], ...args2], {
1847
+ detached: true,
1848
+ stdio: "ignore",
1849
+ env: { ...process.env, ULPI_BG_CLASSIFY: "1" }
1850
+ });
1851
+ child.unref();
1852
+ } catch {
1853
+ }
1854
+ } else if (config.autoExport) {
1855
+ try {
1856
+ await memEngine.exportMemories(projectDir2);
1847
1857
  } catch {
1848
1858
  }
1849
1859
  }
1850
1860
  }
1851
- } catch {
1861
+ } catch (err) {
1862
+ const msg = err instanceof Error ? err.message : String(err);
1863
+ console.error(`[ulpi] Memory capture failed: ${msg}`);
1852
1864
  }
1853
1865
  try {
1854
- const { loadCodemapConfig, getCodemapStatus, exportIndex } = await import("./dist-LZKZFPVX.js");
1866
+ const { loadCodemapConfig, getCodemapStatus, exportIndex } = await import("./dist-MFFX7TZW.js");
1855
1867
  const { getCurrentBranch } = await import("./dist-RKOGLK7R.js");
1856
1868
  const codemapConfig = loadCodemapConfig(projectDir2);
1857
1869
  if (codemapConfig.autoExport) {
@@ -2022,7 +2034,7 @@ async function main() {
2022
2034
  switch (command) {
2023
2035
  case "init": {
2024
2036
  const initDir = rawArgs.some((a) => a === "--project" || a === "-p") ? projectDir : process.cwd();
2025
- return (await import("./init-AY5C2ZAS.js")).runInit([initDir, ...args.slice(1)]);
2037
+ return (await import("./init-22PO3EQB.js")).runInit([initDir, ...args.slice(1)]);
2026
2038
  }
2027
2039
  case "rules":
2028
2040
  return (await import("./rules-E427DKYJ.js")).runRules(args.slice(1), projectDir);
@@ -2041,24 +2053,24 @@ async function main() {
2041
2053
  case "uninstall":
2042
2054
  return (await import("./uninstall-6SW35IK4.js")).runUninstall(args.slice(1), projectDir);
2043
2055
  case "ui":
2044
- return (await import("./ui-L7UAWXDY.js")).runUI(args.slice(1), projectDir);
2056
+ return (await import("./ui-3EFREFSY.js")).runUI(args.slice(1), projectDir);
2045
2057
  case "update":
2046
- return (await import("./update-M2B4RLGH.js")).runUpdate(args.slice(1));
2058
+ return (await import("./update-364RHTAO.js")).runUpdate(args.slice(1));
2047
2059
  case "history":
2048
- return (await import("./history-ATTUKOHO.js")).runHistory(args.slice(1), projectDir);
2060
+ return (await import("./history-UG65BCO6.js")).runHistory(args.slice(1), projectDir);
2049
2061
  case "review":
2050
2062
  return (await import("./review-ADUPV3PN.js")).runReview(args.slice(1), projectDir);
2051
2063
  case "config":
2052
2064
  return (await import("./config-EGAXXCGL.js")).runConfig(args.slice(1));
2053
2065
  case "codemap":
2054
- return (await import("./codemap-RRJIDBQ5.js")).runCodemap(args.slice(1), projectDir);
2066
+ return (await import("./codemap-3BVYMMVM.js")).runCodemap(args.slice(1), projectDir);
2055
2067
  case "memory":
2056
- return (await import("./memory-J3G24QHS.js")).runMemory(args.slice(1), projectDir);
2068
+ return (await import("./memory-IT4H3WRD.js")).runMemory(args.slice(1), projectDir);
2057
2069
  case "projects":
2058
2070
  return (await import("./projects-ATHDD3D6.js")).runProjects(args.slice(1));
2059
2071
  case "--version":
2060
2072
  case "-v":
2061
- console.log("0.1.0");
2073
+ console.log("0.1.2");
2062
2074
  return;
2063
2075
  case "--help":
2064
2076
  case "-h":
@@ -121,8 +121,8 @@ async function runInit(args) {
121
121
  } catch {
122
122
  }
123
123
  try {
124
- const { runInitPipeline } = await import("./dist-LZKZFPVX.js");
125
- const { initMemoryBranch } = await import("./dist-R5F4MX3I.js");
124
+ const { runInitPipeline } = await import("./dist-MFFX7TZW.js");
125
+ const { initMemoryBranch } = await import("./dist-57UMTPGR.js");
126
126
  console.log(chalk.cyan("\nInitializing code index..."));
127
127
  try {
128
128
  await runInitPipeline(projectDir, (progress) => {
@@ -37,7 +37,7 @@ Subcommands:
37
37
  export Push memories to git branch
38
38
  import Pull memories from git branch
39
39
  serve Start MCP server (stdio)
40
- classify [session-id] Run classifier on a captured session
40
+ classify [session-id] Classify session(s) \u2014 all unclassified if no ID given
41
41
  enable Enable memory capture
42
42
  disable Disable memory capture
43
43
  `.trim());
@@ -45,7 +45,7 @@ Subcommands:
45
45
  }
46
46
  async function initSubcommand(projectDir) {
47
47
  console.log(chalk.bold("\nAgent Memory -- Initialize\n"));
48
- const { isMemoryInitialized, saveMemoryConfig, DEFAULT_MEMORY_CONFIG } = await import("./dist-R5F4MX3I.js");
48
+ const { isMemoryInitialized, saveMemoryConfig, DEFAULT_MEMORY_CONFIG } = await import("./dist-57UMTPGR.js");
49
49
  const { projectMemoryDir } = await import("./dist-RKOGLK7R.js");
50
50
  const fs = await import("fs");
51
51
  if (isMemoryInitialized(projectDir)) {
@@ -99,7 +99,7 @@ async function searchSubcommand(args, projectDir) {
99
99
  const ora = (await import("ora")).default;
100
100
  const spinner = ora("Searching memories...").start();
101
101
  try {
102
- const { searchMemory, isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
102
+ const { searchMemory, isMemoryInitialized } = await import("./dist-57UMTPGR.js");
103
103
  if (!isMemoryInitialized(projectDir)) {
104
104
  spinner.fail("Memory not initialized");
105
105
  console.log(chalk.dim("Run 'ulpi memory init' first."));
@@ -165,7 +165,7 @@ async function rememberSubcommand(args, projectDir) {
165
165
  console.log(chalk.dim('\nExample: ulpi memory remember "Always run tests before committing" --type PREFERENCE --importance high'));
166
166
  return;
167
167
  }
168
- const { isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
168
+ const { isMemoryInitialized } = await import("./dist-57UMTPGR.js");
169
169
  if (!isMemoryInitialized(projectDir)) {
170
170
  console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
171
171
  return;
@@ -185,7 +185,7 @@ async function rememberSubcommand(args, projectDir) {
185
185
  const ora = (await import("ora")).default;
186
186
  const spinner = ora("Storing memory...").start();
187
187
  try {
188
- const { generateMemoryId, rememberMemory } = await import("./dist-R5F4MX3I.js");
188
+ const { generateMemoryId, rememberMemory } = await import("./dist-57UMTPGR.js");
189
189
  const now = (/* @__PURE__ */ new Date()).toISOString();
190
190
  const entry = {
191
191
  id: generateMemoryId(memType, text),
@@ -211,7 +211,7 @@ async function rememberSubcommand(args, projectDir) {
211
211
  }
212
212
  }
213
213
  async function statusSubcommand(projectDir) {
214
- const { isMemoryInitialized, getMemoryStats, isMemoryEnabled, loadMemoryConfig } = await import("./dist-R5F4MX3I.js");
214
+ const { isMemoryInitialized, getMemoryStats, isMemoryEnabled, loadMemoryConfig } = await import("./dist-57UMTPGR.js");
215
215
  console.log(chalk.bold("\nAgent Memory Status\n"));
216
216
  if (!isMemoryInitialized(projectDir)) {
217
217
  console.log(chalk.yellow(" Not initialized"));
@@ -252,17 +252,18 @@ async function statusSubcommand(projectDir) {
252
252
  }
253
253
  async function exportSubcommand(projectDir) {
254
254
  console.log(chalk.bold("\nAgent Memory -- Export\n"));
255
- const { isMemoryInitialized, exportMemories } = await import("./dist-R5F4MX3I.js");
255
+ const { isMemoryInitialized, exportMemories } = await import("./dist-57UMTPGR.js");
256
256
  if (!isMemoryInitialized(projectDir)) {
257
257
  console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
258
258
  return;
259
259
  }
260
260
  try {
261
- const result = exportMemories(projectDir);
261
+ const result = await exportMemories(projectDir);
262
262
  console.log(chalk.green("\u2713 Export complete"));
263
263
  console.log(chalk.dim(` Branch: ${result.branchName}`));
264
264
  console.log(chalk.dim(` Commit: ${result.commitSha.slice(0, 8)}`));
265
265
  console.log(chalk.dim(` Memories: ${result.memoriesExported}`));
266
+ console.log(chalk.dim(` Files: ${result.filesExported}`));
266
267
  console.log("");
267
268
  } catch (err) {
268
269
  const message = err instanceof Error ? err.message : String(err);
@@ -271,15 +272,16 @@ async function exportSubcommand(projectDir) {
271
272
  }
272
273
  async function importSubcommand(projectDir) {
273
274
  console.log(chalk.bold("\nAgent Memory -- Import\n"));
274
- const { importMemories } = await import("./dist-R5F4MX3I.js");
275
+ const { importMemories } = await import("./dist-57UMTPGR.js");
275
276
  try {
276
- const result = importMemories(projectDir);
277
+ const result = await importMemories(projectDir);
277
278
  if (!result.success) {
278
279
  console.log(chalk.yellow(`Import skipped: ${result.message}`));
279
280
  return;
280
281
  }
281
282
  console.log(chalk.green("\u2713 Import complete"));
282
283
  console.log(chalk.dim(` Imported: ${result.memoriesImported}`));
284
+ console.log(chalk.dim(` Files: ${result.filesImported}`));
283
285
  console.log(chalk.dim(` ${result.message}`));
284
286
  console.log("");
285
287
  } catch (err) {
@@ -288,34 +290,122 @@ async function importSubcommand(projectDir) {
288
290
  }
289
291
  }
290
292
  async function serveSubcommand(projectDir) {
291
- const { isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
293
+ const { isMemoryInitialized } = await import("./dist-57UMTPGR.js");
292
294
  if (!isMemoryInitialized(projectDir)) {
293
295
  console.error(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
294
296
  process.exit(1);
295
297
  }
296
298
  console.error(chalk.dim("[memory-mcp] Starting MCP server..."));
297
299
  console.error(chalk.dim(`[memory-mcp] Project: ${projectDir}`));
298
- const { startMemoryMcpServer } = await import("./dist-7LHZ65GC.js");
300
+ const { startMemoryMcpServer } = await import("./dist-3SNTTNM3.js");
299
301
  await startMemoryMcpServer({ projectDir });
300
302
  }
301
303
  async function classifySubcommand(args, projectDir) {
302
- const { isMemoryInitialized, listCapturedSessions, classifySession } = await import("./dist-R5F4MX3I.js");
304
+ const { isMemoryInitialized, listCapturedSessions, classifySession, loadWatermark } = await import("./dist-57UMTPGR.js");
303
305
  if (!isMemoryInitialized(projectDir)) {
304
306
  console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
305
307
  return;
306
308
  }
307
- let sessionId = args.filter((a) => !a.startsWith("--"))[0];
308
- if (!sessionId) {
309
- const sessions = listCapturedSessions(projectDir);
310
- if (sessions.length === 0) {
311
- console.log(chalk.yellow("No captured sessions found."));
312
- console.log(chalk.dim("Sessions are captured automatically at session end when memory is enabled."));
309
+ const ora = (await import("ora")).default;
310
+ const doExport = args.includes("--export");
311
+ const isBg = !!process.env.ULPI_BG_CLASSIFY;
312
+ let sessionId;
313
+ const sessionFlagIdx = args.indexOf("--session");
314
+ if (sessionFlagIdx !== -1 && args[sessionFlagIdx + 1]) {
315
+ sessionId = args[sessionFlagIdx + 1];
316
+ } else {
317
+ const skipNext = /* @__PURE__ */ new Set();
318
+ if (sessionFlagIdx !== -1) skipNext.add(sessionFlagIdx + 1);
319
+ for (let i = 0; i < args.length; i++) {
320
+ if (skipNext.has(i) || args[i].startsWith("--")) continue;
321
+ sessionId = args[i];
322
+ break;
323
+ }
324
+ }
325
+ if (sessionId) {
326
+ if (isBg) {
327
+ try {
328
+ await classifySession(projectDir, sessionId);
329
+ } catch {
330
+ }
331
+ if (doExport) {
332
+ try {
333
+ const { exportMemories } = await import("./dist-57UMTPGR.js");
334
+ await exportMemories(projectDir);
335
+ } catch {
336
+ }
337
+ }
313
338
  return;
314
339
  }
315
- const latest = sessions[sessions.length - 1];
316
- sessionId = latest.sessionId;
317
- console.log(chalk.dim(`Using latest session: ${sessionId}`));
340
+ await classifySingleSession(projectDir, sessionId, classifySession);
341
+ if (doExport) {
342
+ try {
343
+ const { exportMemories } = await import("./dist-57UMTPGR.js");
344
+ const result = await exportMemories(projectDir);
345
+ console.log(chalk.green(`\u2713 Exported ${result.memoriesExported} memories to ${result.branchName}`));
346
+ } catch (err) {
347
+ const msg = err instanceof Error ? err.message : String(err);
348
+ console.log(chalk.yellow(` Export skipped: ${msg}`));
349
+ }
350
+ }
351
+ return;
352
+ }
353
+ const sessions = listCapturedSessions(projectDir);
354
+ if (sessions.length === 0) {
355
+ console.log(chalk.yellow("No captured sessions found."));
356
+ console.log(chalk.dim("Sessions are captured automatically at session end when memory is enabled."));
357
+ return;
358
+ }
359
+ const unclassified = sessions.filter((s) => {
360
+ const wm = loadWatermark(projectDir, s.sessionId);
361
+ return !wm;
362
+ });
363
+ if (unclassified.length === 0) {
364
+ console.log(chalk.yellow("All captured sessions have been classified."));
365
+ console.log(chalk.dim(` Total sessions: ${sessions.length}`));
366
+ return;
367
+ }
368
+ console.log(chalk.bold(`
369
+ Agent Memory -- Classify Sessions
370
+ `));
371
+ console.log(chalk.dim(` Found ${unclassified.length} unclassified session(s)
372
+ `));
373
+ let totalExtracted = 0;
374
+ let totalStored = 0;
375
+ let succeeded = 0;
376
+ let failed = 0;
377
+ for (let i = 0; i < unclassified.length; i++) {
378
+ const session = unclassified[i];
379
+ const label = `[${i + 1}/${unclassified.length}] ${session.sessionId.slice(0, 8)}... (${session.filesWritten} writes, ${session.commandsRun} cmds)`;
380
+ const spinner = ora(label).start();
381
+ try {
382
+ const result = await classifySession(projectDir, session.sessionId, (progress) => {
383
+ const pct = progress.total > 0 ? ` (${Math.round(progress.current / progress.total * 100)}%)` : "";
384
+ spinner.text = `${label} \u2014 ${progress.message}${pct}`;
385
+ });
386
+ totalExtracted += result.memoriesExtracted;
387
+ totalStored += result.memoriesStored;
388
+ succeeded++;
389
+ if (result.memoriesStored > 0) {
390
+ spinner.succeed(`${label} \u2014 ${result.memoriesStored} memories stored`);
391
+ } else {
392
+ spinner.info(`${label} \u2014 no new memories`);
393
+ }
394
+ } catch (err) {
395
+ failed++;
396
+ const message = err instanceof Error ? err.message : String(err);
397
+ spinner.fail(`${label} \u2014 ${message}`);
398
+ }
318
399
  }
400
+ console.log("");
401
+ console.log(chalk.bold(" Summary"));
402
+ console.log(chalk.dim(` Sessions processed: ${succeeded}/${unclassified.length}`));
403
+ if (failed > 0) console.log(chalk.red(` Failed: ${failed}`));
404
+ console.log(chalk.dim(` Memories extracted: ${totalExtracted}`));
405
+ console.log(chalk.dim(` Memories stored: ${totalStored}`));
406
+ console.log("");
407
+ }
408
+ async function classifySingleSession(projectDir, sessionId, classifySession) {
319
409
  console.log(chalk.bold(`
320
410
  Agent Memory -- Classify Session
321
411
  `));
@@ -340,7 +430,7 @@ Agent Memory -- Classify Session
340
430
  }
341
431
  }
342
432
  async function enableSubcommand(projectDir) {
343
- const { loadMemoryConfig, saveMemoryConfig, isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
433
+ const { loadMemoryConfig, saveMemoryConfig, isMemoryInitialized } = await import("./dist-57UMTPGR.js");
344
434
  if (!isMemoryInitialized(projectDir)) {
345
435
  console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
346
436
  return;
@@ -351,7 +441,7 @@ async function enableSubcommand(projectDir) {
351
441
  console.log(chalk.green("\u2713 Memory capture enabled"));
352
442
  }
353
443
  async function disableSubcommand(projectDir) {
354
- const { loadMemoryConfig, saveMemoryConfig, isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
444
+ const { loadMemoryConfig, saveMemoryConfig, isMemoryInitialized } = await import("./dist-57UMTPGR.js");
355
445
  if (!isMemoryInitialized(projectDir)) {
356
446
  console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
357
447
  return;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createApiServer
3
- } from "./chunk-Q4HIY43N.js";
3
+ } from "./chunk-UA6EFK64.js";
4
4
  import "./chunk-MIAQVCFW.js";
5
5
  import "./chunk-2MZER6ND.js";
6
6
  import "./chunk-3SBPZRB5.js";