@ulpi/cli 0.1.0

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 (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +200 -0
  3. package/dist/auth-PN7TMQHV-2W4ICG64.js +15 -0
  4. package/dist/chunk-247GVVKK.js +2259 -0
  5. package/dist/chunk-2CLNOKPA.js +793 -0
  6. package/dist/chunk-2HEE5OKX.js +79 -0
  7. package/dist/chunk-2MZER6ND.js +415 -0
  8. package/dist/chunk-3SBPZRB5.js +772 -0
  9. package/dist/chunk-4VNS5WPM.js +42 -0
  10. package/dist/chunk-6JCMYYBT.js +1546 -0
  11. package/dist/chunk-6OCEY7JY.js +422 -0
  12. package/dist/chunk-74WVVWJ4.js +375 -0
  13. package/dist/chunk-7AL4DOEJ.js +131 -0
  14. package/dist/chunk-7LXY5UVC.js +330 -0
  15. package/dist/chunk-DBMUNBNB.js +3048 -0
  16. package/dist/chunk-JWUUVXIV.js +13694 -0
  17. package/dist/chunk-KIKPIH6N.js +4048 -0
  18. package/dist/chunk-KLEASXUR.js +70 -0
  19. package/dist/chunk-MIAQVCFW.js +39 -0
  20. package/dist/chunk-NNUWU6CV.js +1610 -0
  21. package/dist/chunk-PKD4ASEM.js +115 -0
  22. package/dist/chunk-Q4HIY43N.js +4230 -0
  23. package/dist/chunk-QJ5GSMEC.js +146 -0
  24. package/dist/chunk-SIAQVRKG.js +2163 -0
  25. package/dist/chunk-SPOI23SB.js +197 -0
  26. package/dist/chunk-YM2HV4IA.js +505 -0
  27. package/dist/codemap-RRJIDBQ5.js +636 -0
  28. package/dist/config-EGAXXCGL.js +127 -0
  29. package/dist/dist-6G7JC2RA.js +90 -0
  30. package/dist/dist-7LHZ65GC.js +418 -0
  31. package/dist/dist-LZKZFPVX.js +140 -0
  32. package/dist/dist-R5F4MX3I.js +107 -0
  33. package/dist/dist-R5ZJ4LX5.js +56 -0
  34. package/dist/dist-RJGCUS3L.js +87 -0
  35. package/dist/dist-RKOGLK7R.js +151 -0
  36. package/dist/dist-W7K4WPAF.js +597 -0
  37. package/dist/export-import-4A5MWLIA.js +53 -0
  38. package/dist/history-ATTUKOHO.js +934 -0
  39. package/dist/index.js +2120 -0
  40. package/dist/init-AY5C2ZAS.js +393 -0
  41. package/dist/launchd-LF2QMSKZ.js +148 -0
  42. package/dist/log-TVTUXAYD.js +75 -0
  43. package/dist/mcp-installer-NQCGKQ23.js +124 -0
  44. package/dist/memory-J3G24QHS.js +406 -0
  45. package/dist/ollama-3XCUZMZT-FYKHW4TZ.js +7 -0
  46. package/dist/openai-E7G2YAHU-UYY4ZWON.js +8 -0
  47. package/dist/projects-ATHDD3D6.js +271 -0
  48. package/dist/review-ADUPV3PN.js +152 -0
  49. package/dist/rules-E427DKYJ.js +134 -0
  50. package/dist/server-MOYPE4SM-N7SE2AN7.js +18 -0
  51. package/dist/server-X5P6WH2M-7K2RY34N.js +11 -0
  52. package/dist/skills/ulpi-generate-guardian/SKILL.md +511 -0
  53. package/dist/skills/ulpi-generate-guardian/references/framework-rules.md +692 -0
  54. package/dist/skills/ulpi-generate-guardian/references/language-rules.md +596 -0
  55. package/dist/skills-CX73O3IV.js +76 -0
  56. package/dist/status-4DFHDJMN.js +66 -0
  57. package/dist/templates/biome.yml +24 -0
  58. package/dist/templates/conventional-commits.yml +18 -0
  59. package/dist/templates/django.yml +30 -0
  60. package/dist/templates/docker.yml +30 -0
  61. package/dist/templates/eslint.yml +13 -0
  62. package/dist/templates/express.yml +20 -0
  63. package/dist/templates/fastapi.yml +23 -0
  64. package/dist/templates/git-flow.yml +26 -0
  65. package/dist/templates/github-flow.yml +27 -0
  66. package/dist/templates/go.yml +33 -0
  67. package/dist/templates/jest.yml +24 -0
  68. package/dist/templates/laravel.yml +30 -0
  69. package/dist/templates/monorepo.yml +26 -0
  70. package/dist/templates/nestjs.yml +21 -0
  71. package/dist/templates/nextjs.yml +31 -0
  72. package/dist/templates/nodejs.yml +33 -0
  73. package/dist/templates/npm.yml +15 -0
  74. package/dist/templates/php.yml +25 -0
  75. package/dist/templates/pnpm.yml +15 -0
  76. package/dist/templates/prettier.yml +23 -0
  77. package/dist/templates/prisma.yml +21 -0
  78. package/dist/templates/python.yml +33 -0
  79. package/dist/templates/quality-of-life.yml +111 -0
  80. package/dist/templates/ruby.yml +25 -0
  81. package/dist/templates/rust.yml +34 -0
  82. package/dist/templates/typescript.yml +14 -0
  83. package/dist/templates/vitest.yml +24 -0
  84. package/dist/templates/yarn.yml +15 -0
  85. package/dist/templates-U7T6MARD.js +156 -0
  86. package/dist/ui-L7UAWXDY.js +167 -0
  87. package/dist/ui.html +698 -0
  88. package/dist/ulpi-RMMCUAGP-JCJ273T6.js +161 -0
  89. package/dist/uninstall-6SW35IK4.js +25 -0
  90. package/dist/update-M2B4RLGH.js +61 -0
  91. package/dist/version-checker-ANCS3IHR.js +10 -0
  92. package/package.json +92 -0
@@ -0,0 +1,124 @@
1
+ import {
2
+ getBinaryPath
3
+ } from "./chunk-7LXY5UVC.js";
4
+ import "./chunk-4VNS5WPM.js";
5
+
6
+ // src/mcp-installer.ts
7
+ import * as fs from "fs";
8
+ import * as path from "path";
9
+ function installMcpServer(projectDir) {
10
+ const settingsDir = path.join(projectDir, ".claude");
11
+ const settingsPath = path.join(settingsDir, "settings.local.json");
12
+ let settings = {};
13
+ if (fs.existsSync(settingsPath)) {
14
+ try {
15
+ settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
16
+ } catch {
17
+ }
18
+ }
19
+ const mcpServers = settings.mcpServers ?? {};
20
+ if (mcpServers["codemap"]) {
21
+ return { installed: false, message: "CodeMap MCP server already registered" };
22
+ }
23
+ const binary = getBinaryPath();
24
+ const parts = binary.split(" ");
25
+ const command = parts[0];
26
+ const baseArgs = parts.length > 1 ? [...parts.slice(1).map((a) => a.replace(/"/g, "")), "codemap", "serve"] : ["codemap", "serve"];
27
+ mcpServers["codemap"] = {
28
+ command,
29
+ args: baseArgs
30
+ };
31
+ settings.mcpServers = mcpServers;
32
+ fs.mkdirSync(settingsDir, { recursive: true });
33
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
34
+ return { installed: true, message: "CodeMap MCP server registered in .claude/settings.local.json" };
35
+ }
36
+ function uninstallMcpServer(projectDir) {
37
+ const settingsPath = path.join(projectDir, ".claude", "settings.local.json");
38
+ if (!fs.existsSync(settingsPath)) return;
39
+ try {
40
+ const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
41
+ const mcpServers = settings.mcpServers;
42
+ if (mcpServers?.["codemap"]) {
43
+ delete mcpServers["codemap"];
44
+ if (Object.keys(mcpServers).length === 0) {
45
+ delete settings.mcpServers;
46
+ }
47
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
48
+ }
49
+ } catch {
50
+ }
51
+ }
52
+ function isMcpServerInstalled(projectDir) {
53
+ const settingsPath = path.join(projectDir, ".claude", "settings.local.json");
54
+ if (!fs.existsSync(settingsPath)) return false;
55
+ try {
56
+ const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
57
+ const mcpServers = settings.mcpServers;
58
+ return !!mcpServers?.["codemap"];
59
+ } catch {
60
+ return false;
61
+ }
62
+ }
63
+ function installMemoryMcpServer(projectDir) {
64
+ const settingsDir = path.join(projectDir, ".claude");
65
+ const settingsPath = path.join(settingsDir, "settings.local.json");
66
+ let settings = {};
67
+ if (fs.existsSync(settingsPath)) {
68
+ try {
69
+ settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
70
+ } catch {
71
+ }
72
+ }
73
+ const mcpServers = settings.mcpServers ?? {};
74
+ if (mcpServers["memory"]) {
75
+ return { installed: false, message: "Memory MCP server already registered" };
76
+ }
77
+ const binary = getBinaryPath();
78
+ const parts = binary.split(" ");
79
+ const command = parts[0];
80
+ const baseArgs = parts.length > 1 ? [...parts.slice(1).map((a) => a.replace(/"/g, "")), "memory", "serve"] : ["memory", "serve"];
81
+ mcpServers["memory"] = {
82
+ command,
83
+ args: baseArgs
84
+ };
85
+ settings.mcpServers = mcpServers;
86
+ fs.mkdirSync(settingsDir, { recursive: true });
87
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
88
+ return { installed: true, message: "Memory MCP server registered in .claude/settings.local.json" };
89
+ }
90
+ function uninstallMemoryMcpServer(projectDir) {
91
+ const settingsPath = path.join(projectDir, ".claude", "settings.local.json");
92
+ if (!fs.existsSync(settingsPath)) return;
93
+ try {
94
+ const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
95
+ const mcpServers = settings.mcpServers;
96
+ if (mcpServers?.["memory"]) {
97
+ delete mcpServers["memory"];
98
+ if (Object.keys(mcpServers).length === 0) {
99
+ delete settings.mcpServers;
100
+ }
101
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + "\n", "utf-8");
102
+ }
103
+ } catch {
104
+ }
105
+ }
106
+ function isMemoryMcpServerInstalled(projectDir) {
107
+ const settingsPath = path.join(projectDir, ".claude", "settings.local.json");
108
+ if (!fs.existsSync(settingsPath)) return false;
109
+ try {
110
+ const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
111
+ const mcpServers = settings.mcpServers;
112
+ return !!mcpServers?.["memory"];
113
+ } catch {
114
+ return false;
115
+ }
116
+ }
117
+ export {
118
+ installMcpServer,
119
+ installMemoryMcpServer,
120
+ isMcpServerInstalled,
121
+ isMemoryMcpServerInstalled,
122
+ uninstallMcpServer,
123
+ uninstallMemoryMcpServer
124
+ };
@@ -0,0 +1,406 @@
1
+ import "./chunk-4VNS5WPM.js";
2
+
3
+ // src/commands/memory.ts
4
+ import chalk from "chalk";
5
+ async function runMemory(args, projectDir) {
6
+ const subcommand = args[0];
7
+ switch (subcommand) {
8
+ case "init":
9
+ return await initSubcommand(projectDir);
10
+ case "search":
11
+ return await searchSubcommand(args.slice(1), projectDir);
12
+ case "remember":
13
+ return await rememberSubcommand(args.slice(1), projectDir);
14
+ case "status":
15
+ return await statusSubcommand(projectDir);
16
+ case "export":
17
+ return await exportSubcommand(projectDir);
18
+ case "import":
19
+ return await importSubcommand(projectDir);
20
+ case "serve":
21
+ return await serveSubcommand(projectDir);
22
+ case "classify":
23
+ return await classifySubcommand(args.slice(1), projectDir);
24
+ case "enable":
25
+ return await enableSubcommand(projectDir);
26
+ case "disable":
27
+ return await disableSubcommand(projectDir);
28
+ default:
29
+ console.log(`
30
+ Usage: ulpi memory <subcommand>
31
+
32
+ Subcommands:
33
+ init Initialize memory for this project
34
+ search <query> Search memories semantically
35
+ remember <text> Store an explicit memory
36
+ status Show memory stats dashboard
37
+ export Push memories to git branch
38
+ import Pull memories from git branch
39
+ serve Start MCP server (stdio)
40
+ classify [session-id] Run classifier on a captured session
41
+ enable Enable memory capture
42
+ disable Disable memory capture
43
+ `.trim());
44
+ }
45
+ }
46
+ async function initSubcommand(projectDir) {
47
+ console.log(chalk.bold("\nAgent Memory -- Initialize\n"));
48
+ const { isMemoryInitialized, saveMemoryConfig, DEFAULT_MEMORY_CONFIG } = await import("./dist-R5F4MX3I.js");
49
+ const { projectMemoryDir } = await import("./dist-RKOGLK7R.js");
50
+ const fs = await import("fs");
51
+ if (isMemoryInitialized(projectDir)) {
52
+ console.log(chalk.yellow("Memory is already initialized for this project."));
53
+ console.log(chalk.dim(` Path: ${projectMemoryDir(projectDir)}`));
54
+ return;
55
+ }
56
+ const memDir = projectMemoryDir(projectDir);
57
+ fs.mkdirSync(memDir, { recursive: true });
58
+ const config = { ...DEFAULT_MEMORY_CONFIG, enabled: true };
59
+ saveMemoryConfig(projectDir, config);
60
+ console.log(chalk.green("\u2713 Memory initialized"));
61
+ console.log(chalk.dim(` Path: ${memDir}`));
62
+ console.log(chalk.dim(` Capture mode: ${config.captureMode}`));
63
+ console.log(chalk.dim(` Classifier: ${config.classifier.enabled ? "enabled" : "disabled"}`));
64
+ console.log(chalk.dim(` Surface: ${config.surfaceOnStart ? `on start (limit ${config.surfaceLimit})` : "disabled"}`));
65
+ const { installMemoryMcpServer } = await import("./mcp-installer-NQCGKQ23.js");
66
+ const mcp = installMemoryMcpServer(projectDir);
67
+ if (mcp.installed) {
68
+ console.log(chalk.green("\u2713 MCP server registered"));
69
+ console.log(chalk.dim(" Claude Code will auto-start the memory MCP server"));
70
+ } else {
71
+ console.log(chalk.dim(` MCP: ${mcp.message}`));
72
+ }
73
+ console.log(chalk.dim("\nNext: memories will be captured automatically during sessions."));
74
+ console.log(chalk.dim(' Manual: ulpi memory remember "your insight here"'));
75
+ console.log(chalk.dim(' Search: ulpi memory search "query"'));
76
+ }
77
+ async function searchSubcommand(args, projectDir) {
78
+ const queryParts = [];
79
+ const flags = [];
80
+ for (const a of args) {
81
+ if (a.startsWith("--")) {
82
+ flags.push(a);
83
+ } else {
84
+ queryParts.push(a);
85
+ }
86
+ }
87
+ const query = queryParts.join(" ");
88
+ if (!query) {
89
+ console.log(chalk.red("Usage: ulpi memory search <query>"));
90
+ console.log(chalk.dim(' Example: ulpi memory search "authentication flow"'));
91
+ return;
92
+ }
93
+ let limit = 10;
94
+ const limitFlag = flags.find((f) => f.startsWith("--limit"));
95
+ if (limitFlag) {
96
+ const val = limitFlag.includes("=") ? limitFlag.split("=")[1] : args[args.indexOf(limitFlag) + 1];
97
+ if (val) limit = parseInt(val, 10) || 10;
98
+ }
99
+ const ora = (await import("ora")).default;
100
+ const spinner = ora("Searching memories...").start();
101
+ try {
102
+ const { searchMemory, isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
103
+ if (!isMemoryInitialized(projectDir)) {
104
+ spinner.fail("Memory not initialized");
105
+ console.log(chalk.dim("Run 'ulpi memory init' first."));
106
+ return;
107
+ }
108
+ const result = await searchMemory(projectDir, { query, limit });
109
+ spinner.stop();
110
+ if (result.results.length === 0) {
111
+ console.log(chalk.yellow("No matching memories found."));
112
+ console.log(chalk.dim(` Query: "${query}"`));
113
+ console.log(chalk.dim(` Duration: ${result.durationMs}ms`));
114
+ return;
115
+ }
116
+ console.log(chalk.bold(`
117
+ Memory Search -- "${query}"
118
+ `));
119
+ console.log(chalk.dim(` ${result.results.length} results in ${result.durationMs}ms
120
+ `));
121
+ for (let i = 0; i < result.results.length; i++) {
122
+ const r = result.results[i];
123
+ const score = (r.finalScore * 100).toFixed(1);
124
+ const badge = formatTypeBadge(r.entry.type);
125
+ const importance = formatImportance(r.entry.importance);
126
+ console.log(
127
+ chalk.cyan(` ${i + 1}. `) + badge + " " + chalk.white(truncate(r.entry.summary, 70)) + chalk.dim(` (${score}%)`)
128
+ );
129
+ const details = [importance];
130
+ if (r.entry.tags.length > 0) {
131
+ details.push(chalk.dim(r.entry.tags.slice(0, 3).join(", ")));
132
+ }
133
+ console.log(chalk.dim(` ${details.join(" | ")}`));
134
+ }
135
+ console.log("");
136
+ } catch (err) {
137
+ const message = err instanceof Error ? err.message : String(err);
138
+ spinner.fail(`Search failed: ${message}`);
139
+ }
140
+ }
141
+ async function rememberSubcommand(args, projectDir) {
142
+ let memType = "CONTEXT";
143
+ let importance = "medium";
144
+ const textParts = [];
145
+ for (let i = 0; i < args.length; i++) {
146
+ if (args[i] === "--type" && args[i + 1]) {
147
+ memType = args[i + 1];
148
+ i++;
149
+ } else if (args[i].startsWith("--type=")) {
150
+ memType = args[i].split("=")[1];
151
+ } else if (args[i] === "--importance" && args[i + 1]) {
152
+ importance = args[i + 1];
153
+ i++;
154
+ } else if (args[i].startsWith("--importance=")) {
155
+ importance = args[i].split("=")[1];
156
+ } else if (!args[i].startsWith("--")) {
157
+ textParts.push(args[i]);
158
+ }
159
+ }
160
+ const text = textParts.join(" ");
161
+ if (!text) {
162
+ console.log(chalk.red("Usage: ulpi memory remember <text> [--type TYPE] [--importance LEVEL]"));
163
+ console.log(chalk.dim("\nTypes: DECISION, PATTERN, BUG_ROOT_CAUSE, PREFERENCE, CONSTRAINT, CONTEXT, LESSON, RELATIONSHIP"));
164
+ console.log(chalk.dim("Importance: critical, high, medium, low"));
165
+ console.log(chalk.dim('\nExample: ulpi memory remember "Always run tests before committing" --type PREFERENCE --importance high'));
166
+ return;
167
+ }
168
+ const { isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
169
+ if (!isMemoryInitialized(projectDir)) {
170
+ console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
171
+ return;
172
+ }
173
+ const validTypes = ["DECISION", "PATTERN", "BUG_ROOT_CAUSE", "PREFERENCE", "CONSTRAINT", "CONTEXT", "LESSON", "RELATIONSHIP"];
174
+ if (!validTypes.includes(memType)) {
175
+ console.log(chalk.red(`Error: Invalid type "${memType}".`));
176
+ console.log(chalk.dim(` Valid types: ${validTypes.join(", ")}`));
177
+ return;
178
+ }
179
+ const validImportance = ["critical", "high", "medium", "low"];
180
+ if (!validImportance.includes(importance)) {
181
+ console.log(chalk.red(`Error: Invalid importance "${importance}".`));
182
+ console.log(chalk.dim(` Valid values: ${validImportance.join(", ")}`));
183
+ return;
184
+ }
185
+ const ora = (await import("ora")).default;
186
+ const spinner = ora("Storing memory...").start();
187
+ try {
188
+ const { generateMemoryId, rememberMemory } = await import("./dist-R5F4MX3I.js");
189
+ const now = (/* @__PURE__ */ new Date()).toISOString();
190
+ const entry = {
191
+ id: generateMemoryId(memType, text),
192
+ type: memType,
193
+ summary: text,
194
+ detail: null,
195
+ importance,
196
+ tags: [],
197
+ relatedFiles: [],
198
+ source: { type: "explicit" },
199
+ createdAt: now,
200
+ updatedAt: now,
201
+ accessCount: 0
202
+ };
203
+ await rememberMemory(projectDir, entry);
204
+ spinner.succeed("Memory stored");
205
+ console.log(chalk.dim(` Type: ${memType}`));
206
+ console.log(chalk.dim(` Importance: ${importance}`));
207
+ console.log(chalk.dim(` ID: ${entry.id.slice(0, 12)}...`));
208
+ } catch (err) {
209
+ const message = err instanceof Error ? err.message : String(err);
210
+ spinner.fail(`Failed to store memory: ${message}`);
211
+ }
212
+ }
213
+ async function statusSubcommand(projectDir) {
214
+ const { isMemoryInitialized, getMemoryStats, isMemoryEnabled, loadMemoryConfig } = await import("./dist-R5F4MX3I.js");
215
+ console.log(chalk.bold("\nAgent Memory Status\n"));
216
+ if (!isMemoryInitialized(projectDir)) {
217
+ console.log(chalk.yellow(" Not initialized"));
218
+ console.log(chalk.dim(" Run 'ulpi memory init' to set up memory for this project.\n"));
219
+ return;
220
+ }
221
+ const config = loadMemoryConfig(projectDir);
222
+ const enabled = isMemoryEnabled(projectDir);
223
+ console.log(` ${chalk.dim("Enabled:")} ${enabled ? chalk.green("yes") : chalk.red("no")}`);
224
+ console.log(` ${chalk.dim("Capture mode:")} ${config.captureMode}`);
225
+ console.log(` ${chalk.dim("Classifier:")} ${config.classifier.enabled ? chalk.green("enabled") : chalk.dim("disabled")}`);
226
+ console.log(` ${chalk.dim("Surface:")} ${config.surfaceOnStart ? `on start (limit ${config.surfaceLimit})` : "disabled"}`);
227
+ console.log("");
228
+ try {
229
+ const stats = await getMemoryStats(projectDir);
230
+ console.log(chalk.bold(" Memories"));
231
+ console.log(` ${chalk.dim("Total:")} ${stats.totalMemories}`);
232
+ if (Object.keys(stats.memoriesByType).length > 0) {
233
+ const typeEntries = Object.entries(stats.memoriesByType);
234
+ for (const [type, count] of typeEntries) {
235
+ console.log(` ${chalk.dim(padRight(type + ":", 18))} ${count}`);
236
+ }
237
+ }
238
+ console.log("");
239
+ console.log(chalk.bold(" Activity"));
240
+ console.log(` ${chalk.dim("Total accesses:")} ${stats.totalAccesses}`);
241
+ console.log(` ${chalk.dim("Sessions captured:")} ${stats.sessionsCaptured}`);
242
+ console.log(` ${chalk.dim("Classified:")} ${stats.sessionsClassified}`);
243
+ console.log(` ${chalk.dim("Index size:")} ${formatBytes(stats.indexSizeBytes)}`);
244
+ if (stats.lastClassifiedAt) {
245
+ console.log(` ${chalk.dim("Last classified:")} ${stats.lastClassifiedAt}`);
246
+ }
247
+ console.log("");
248
+ } catch (err) {
249
+ const message = err instanceof Error ? err.message : String(err);
250
+ console.log(chalk.red(` Error loading stats: ${message}`));
251
+ }
252
+ }
253
+ async function exportSubcommand(projectDir) {
254
+ console.log(chalk.bold("\nAgent Memory -- Export\n"));
255
+ const { isMemoryInitialized, exportMemories } = await import("./dist-R5F4MX3I.js");
256
+ if (!isMemoryInitialized(projectDir)) {
257
+ console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
258
+ return;
259
+ }
260
+ try {
261
+ const result = exportMemories(projectDir);
262
+ console.log(chalk.green("\u2713 Export complete"));
263
+ console.log(chalk.dim(` Branch: ${result.branchName}`));
264
+ console.log(chalk.dim(` Commit: ${result.commitSha.slice(0, 8)}`));
265
+ console.log(chalk.dim(` Memories: ${result.memoriesExported}`));
266
+ console.log("");
267
+ } catch (err) {
268
+ const message = err instanceof Error ? err.message : String(err);
269
+ console.log(chalk.red(`Error: ${message}`));
270
+ }
271
+ }
272
+ async function importSubcommand(projectDir) {
273
+ console.log(chalk.bold("\nAgent Memory -- Import\n"));
274
+ const { importMemories } = await import("./dist-R5F4MX3I.js");
275
+ try {
276
+ const result = importMemories(projectDir);
277
+ if (!result.success) {
278
+ console.log(chalk.yellow(`Import skipped: ${result.message}`));
279
+ return;
280
+ }
281
+ console.log(chalk.green("\u2713 Import complete"));
282
+ console.log(chalk.dim(` Imported: ${result.memoriesImported}`));
283
+ console.log(chalk.dim(` ${result.message}`));
284
+ console.log("");
285
+ } catch (err) {
286
+ const message = err instanceof Error ? err.message : String(err);
287
+ console.log(chalk.red(`Error: ${message}`));
288
+ }
289
+ }
290
+ async function serveSubcommand(projectDir) {
291
+ const { isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
292
+ if (!isMemoryInitialized(projectDir)) {
293
+ console.error(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
294
+ process.exit(1);
295
+ }
296
+ console.error(chalk.dim("[memory-mcp] Starting MCP server..."));
297
+ console.error(chalk.dim(`[memory-mcp] Project: ${projectDir}`));
298
+ const { startMemoryMcpServer } = await import("./dist-7LHZ65GC.js");
299
+ await startMemoryMcpServer({ projectDir });
300
+ }
301
+ async function classifySubcommand(args, projectDir) {
302
+ const { isMemoryInitialized, listCapturedSessions, classifySession } = await import("./dist-R5F4MX3I.js");
303
+ if (!isMemoryInitialized(projectDir)) {
304
+ console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
305
+ return;
306
+ }
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."));
313
+ return;
314
+ }
315
+ const latest = sessions[sessions.length - 1];
316
+ sessionId = latest.sessionId;
317
+ console.log(chalk.dim(`Using latest session: ${sessionId}`));
318
+ }
319
+ console.log(chalk.bold(`
320
+ Agent Memory -- Classify Session
321
+ `));
322
+ console.log(chalk.dim(` Session: ${sessionId}
323
+ `));
324
+ const ora = (await import("ora")).default;
325
+ const spinner = ora("Starting classification...").start();
326
+ try {
327
+ const result = await classifySession(projectDir, sessionId, (progress) => {
328
+ const pct = progress.total > 0 ? ` (${Math.round(progress.current / progress.total * 100)}%)` : "";
329
+ spinner.text = `${progress.message}${pct}`;
330
+ });
331
+ spinner.succeed("Classification complete");
332
+ console.log(chalk.dim(` Windows processed: ${result.windowsProcessed}`));
333
+ console.log(chalk.dim(` Memories extracted: ${result.memoriesExtracted}`));
334
+ console.log(chalk.dim(` Memories stored: ${result.memoriesStored}`));
335
+ console.log(chalk.dim(` Duration: ${(result.durationMs / 1e3).toFixed(1)}s`));
336
+ console.log("");
337
+ } catch (err) {
338
+ const message = err instanceof Error ? err.message : String(err);
339
+ spinner.fail(`Classification failed: ${message}`);
340
+ }
341
+ }
342
+ async function enableSubcommand(projectDir) {
343
+ const { loadMemoryConfig, saveMemoryConfig, isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
344
+ if (!isMemoryInitialized(projectDir)) {
345
+ console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
346
+ return;
347
+ }
348
+ const config = loadMemoryConfig(projectDir);
349
+ config.enabled = true;
350
+ saveMemoryConfig(projectDir, config);
351
+ console.log(chalk.green("\u2713 Memory capture enabled"));
352
+ }
353
+ async function disableSubcommand(projectDir) {
354
+ const { loadMemoryConfig, saveMemoryConfig, isMemoryInitialized } = await import("./dist-R5F4MX3I.js");
355
+ if (!isMemoryInitialized(projectDir)) {
356
+ console.log(chalk.red("Error: Memory not initialized. Run 'ulpi memory init' first."));
357
+ return;
358
+ }
359
+ const config = loadMemoryConfig(projectDir);
360
+ config.enabled = false;
361
+ saveMemoryConfig(projectDir, config);
362
+ console.log(chalk.yellow("\u2713 Memory capture disabled"));
363
+ }
364
+ function truncate(str, maxLen) {
365
+ if (str.length <= maxLen) return str;
366
+ return str.slice(0, maxLen - 3) + "...";
367
+ }
368
+ function padRight(str, len) {
369
+ return str.length >= len ? str : str + " ".repeat(len - str.length);
370
+ }
371
+ function formatBytes(bytes) {
372
+ if (bytes === 0) return "0 B";
373
+ const units = ["B", "KB", "MB", "GB"];
374
+ const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
375
+ const val = bytes / Math.pow(1024, i);
376
+ return `${val.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
377
+ }
378
+ var TYPE_COLORS = {
379
+ DECISION: chalk.magenta,
380
+ PATTERN: chalk.blue,
381
+ BUG_ROOT_CAUSE: chalk.red,
382
+ PREFERENCE: chalk.cyan,
383
+ CONSTRAINT: chalk.yellow,
384
+ CONTEXT: chalk.green,
385
+ LESSON: chalk.hex("#FFA500"),
386
+ RELATIONSHIP: chalk.hex("#9370DB")
387
+ };
388
+ function formatTypeBadge(type) {
389
+ const colorFn = TYPE_COLORS[type] ?? chalk.dim;
390
+ return colorFn(`[${type}]`);
391
+ }
392
+ function formatImportance(imp) {
393
+ switch (imp) {
394
+ case "critical":
395
+ return chalk.red("critical");
396
+ case "high":
397
+ return chalk.yellow("high");
398
+ case "medium":
399
+ return chalk.dim("medium");
400
+ case "low":
401
+ return chalk.dim("low");
402
+ }
403
+ }
404
+ export {
405
+ runMemory
406
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ OllamaEmbedder
3
+ } from "./chunk-KLEASXUR.js";
4
+ import "./chunk-4VNS5WPM.js";
5
+ export {
6
+ OllamaEmbedder
7
+ };
@@ -0,0 +1,8 @@
1
+ import {
2
+ OpenAIEmbedder
3
+ } from "./chunk-2HEE5OKX.js";
4
+ import "./chunk-7LXY5UVC.js";
5
+ import "./chunk-4VNS5WPM.js";
6
+ export {
7
+ OpenAIEmbedder
8
+ };