gnosys 5.11.3 → 5.12.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 (244) hide show
  1. package/dist/cli.js +332 -5151
  2. package/dist/index.js +364 -235
  3. package/dist/lib/addCommand.d.ts +9 -0
  4. package/dist/lib/addCommand.js +103 -0
  5. package/dist/lib/addStructuredCommand.d.ts +16 -0
  6. package/dist/lib/addStructuredCommand.js +103 -0
  7. package/dist/lib/ambiguityCommand.d.ts +4 -0
  8. package/dist/lib/ambiguityCommand.js +36 -0
  9. package/dist/lib/apiKeyVault.d.ts +78 -0
  10. package/dist/lib/apiKeyVault.js +447 -0
  11. package/dist/lib/askCommand.d.ts +13 -0
  12. package/dist/lib/askCommand.js +145 -0
  13. package/dist/lib/audioExtract.js +4 -1
  14. package/dist/lib/auditCommand.d.ts +7 -0
  15. package/dist/lib/auditCommand.js +27 -0
  16. package/dist/lib/backupCommand.d.ts +6 -0
  17. package/dist/lib/backupCommand.js +54 -0
  18. package/dist/lib/bootstrapCommand.d.ts +15 -0
  19. package/dist/lib/bootstrapCommand.js +51 -0
  20. package/dist/lib/briefingCommand.d.ts +7 -0
  21. package/dist/lib/briefingCommand.js +92 -0
  22. package/dist/lib/centralizeCommand.d.ts +5 -0
  23. package/dist/lib/centralizeCommand.js +16 -0
  24. package/dist/lib/chatCommand.d.ts +12 -0
  25. package/dist/lib/chatCommand.js +46 -0
  26. package/dist/lib/checkCommand.d.ts +4 -0
  27. package/dist/lib/checkCommand.js +133 -0
  28. package/dist/lib/clientReadOverlay.d.ts +27 -0
  29. package/dist/lib/clientReadOverlay.js +73 -0
  30. package/dist/lib/clientReadResolve.d.ts +32 -0
  31. package/dist/lib/clientReadResolve.js +84 -0
  32. package/dist/lib/commitContextCommand.d.ts +9 -0
  33. package/dist/lib/commitContextCommand.js +142 -0
  34. package/dist/lib/config.d.ts +43 -3
  35. package/dist/lib/config.js +58 -57
  36. package/dist/lib/configCommand.d.ts +10 -0
  37. package/dist/lib/configCommand.js +321 -0
  38. package/dist/lib/connectCommand.d.ts +8 -0
  39. package/dist/lib/connectCommand.js +19 -0
  40. package/dist/lib/db.d.ts +52 -0
  41. package/dist/lib/db.js +169 -1
  42. package/dist/lib/dearchiveCommand.d.ts +7 -0
  43. package/dist/lib/dearchiveCommand.js +41 -0
  44. package/dist/lib/discoverCommand.d.ts +9 -0
  45. package/dist/lib/discoverCommand.js +87 -0
  46. package/dist/lib/doctorCommand.d.ts +6 -0
  47. package/dist/lib/doctorCommand.js +256 -0
  48. package/dist/lib/dream.d.ts +42 -2
  49. package/dist/lib/dream.js +290 -30
  50. package/dist/lib/dreamCommand.d.ts +10 -0
  51. package/dist/lib/dreamCommand.js +195 -0
  52. package/dist/lib/dreamLaunchd.d.ts +2 -0
  53. package/dist/lib/dreamLaunchd.js +72 -0
  54. package/dist/lib/dreamLogCommand.d.ts +10 -0
  55. package/dist/lib/dreamLogCommand.js +58 -0
  56. package/dist/lib/dreamReport.d.ts +7 -0
  57. package/dist/lib/dreamReport.js +114 -0
  58. package/dist/lib/dreamRunLog.d.ts +121 -0
  59. package/dist/lib/dreamRunLog.js +212 -0
  60. package/dist/lib/embeddings.js +3 -0
  61. package/dist/lib/exportCommand.d.ts +18 -0
  62. package/dist/lib/exportCommand.js +101 -0
  63. package/dist/lib/fsearchCommand.d.ts +8 -0
  64. package/dist/lib/fsearchCommand.js +44 -0
  65. package/dist/lib/graphCommand.d.ts +4 -0
  66. package/dist/lib/graphCommand.js +68 -0
  67. package/dist/lib/helperGenerateCommand.d.ts +5 -0
  68. package/dist/lib/helperGenerateCommand.js +27 -0
  69. package/dist/lib/historyCommand.d.ts +5 -0
  70. package/dist/lib/historyCommand.js +51 -0
  71. package/dist/lib/hybridSearchCommand.d.ts +12 -0
  72. package/dist/lib/hybridSearchCommand.js +95 -0
  73. package/dist/lib/ideMcpInstall.d.ts +30 -0
  74. package/dist/lib/ideMcpInstall.js +102 -0
  75. package/dist/lib/importCommand.d.ts +16 -0
  76. package/dist/lib/importCommand.js +89 -0
  77. package/dist/lib/importProjectCommand.d.ts +6 -0
  78. package/dist/lib/importProjectCommand.js +43 -0
  79. package/dist/lib/ingestCommand.d.ts +13 -0
  80. package/dist/lib/ingestCommand.js +95 -0
  81. package/dist/lib/installOutput.d.ts +36 -0
  82. package/dist/lib/installOutput.js +55 -0
  83. package/dist/lib/lensCommand.d.ts +20 -0
  84. package/dist/lib/lensCommand.js +61 -0
  85. package/dist/lib/lensing.d.ts +1 -0
  86. package/dist/lib/lensing.js +50 -9
  87. package/dist/lib/linksCommand.d.ts +7 -0
  88. package/dist/lib/linksCommand.js +48 -0
  89. package/dist/lib/listCommand.d.ts +8 -0
  90. package/dist/lib/listCommand.js +74 -0
  91. package/dist/lib/llm.d.ts +1 -1
  92. package/dist/lib/llm.js +26 -8
  93. package/dist/lib/localDiskCheck.d.ts +17 -0
  94. package/dist/lib/localDiskCheck.js +54 -0
  95. package/dist/lib/machineConfig.d.ts +11 -1
  96. package/dist/lib/machineConfig.js +16 -0
  97. package/dist/lib/machineRegistry.d.ts +61 -0
  98. package/dist/lib/machineRegistry.js +80 -0
  99. package/dist/lib/maintainCommand.d.ts +8 -0
  100. package/dist/lib/maintainCommand.js +34 -0
  101. package/dist/lib/masterLease.d.ts +20 -0
  102. package/dist/lib/masterLease.js +68 -0
  103. package/dist/lib/migrateCommand.d.ts +7 -0
  104. package/dist/lib/migrateCommand.js +158 -0
  105. package/dist/lib/migrateDbCommand.d.ts +9 -0
  106. package/dist/lib/migrateDbCommand.js +94 -0
  107. package/dist/lib/modelValidation.d.ts +5 -0
  108. package/dist/lib/modelValidation.js +27 -0
  109. package/dist/lib/openrouterTiers.d.ts +29 -0
  110. package/dist/lib/openrouterTiers.js +113 -0
  111. package/dist/lib/prefCommand.d.ts +10 -0
  112. package/dist/lib/prefCommand.js +118 -0
  113. package/dist/lib/projectsCommand.d.ts +8 -0
  114. package/dist/lib/projectsCommand.js +131 -0
  115. package/dist/lib/readCommand.d.ts +7 -0
  116. package/dist/lib/readCommand.js +62 -0
  117. package/dist/lib/recall.d.ts +3 -0
  118. package/dist/lib/recall.js +19 -4
  119. package/dist/lib/recallCommand.d.ts +11 -0
  120. package/dist/lib/recallCommand.js +112 -0
  121. package/dist/lib/reflectCommand.d.ts +8 -0
  122. package/dist/lib/reflectCommand.js +61 -0
  123. package/dist/lib/reindexCommand.d.ts +4 -0
  124. package/dist/lib/reindexCommand.js +34 -0
  125. package/dist/lib/reindexGraphCommand.d.ts +4 -0
  126. package/dist/lib/reindexGraphCommand.js +12 -0
  127. package/dist/lib/reinforceCommand.d.ts +8 -0
  128. package/dist/lib/reinforceCommand.js +40 -0
  129. package/dist/lib/remote.d.ts +5 -1
  130. package/dist/lib/remote.js +5 -1
  131. package/dist/lib/remoteWizard.d.ts +24 -5
  132. package/dist/lib/remoteWizard.js +308 -319
  133. package/dist/lib/restoreCommand.d.ts +5 -0
  134. package/dist/lib/restoreCommand.js +35 -0
  135. package/dist/lib/sandboxStartCommand.d.ts +6 -0
  136. package/dist/lib/sandboxStartCommand.js +25 -0
  137. package/dist/lib/sandboxStatusCommand.d.ts +4 -0
  138. package/dist/lib/sandboxStatusCommand.js +24 -0
  139. package/dist/lib/sandboxStopCommand.d.ts +4 -0
  140. package/dist/lib/sandboxStopCommand.js +21 -0
  141. package/dist/lib/searchCommand.d.ts +9 -0
  142. package/dist/lib/searchCommand.js +90 -0
  143. package/dist/lib/semanticSearchCommand.d.ts +8 -0
  144. package/dist/lib/semanticSearchCommand.js +52 -0
  145. package/dist/lib/setup/configSetRender.js +2 -0
  146. package/dist/lib/setup/providerGlyphs.d.ts +19 -0
  147. package/dist/lib/setup/providerGlyphs.js +42 -0
  148. package/dist/lib/setup/remoteRender.d.ts +31 -1
  149. package/dist/lib/setup/remoteRender.js +95 -4
  150. package/dist/lib/setup/sections/ides.d.ts +7 -0
  151. package/dist/lib/setup/sections/ides.js +24 -2
  152. package/dist/lib/setup/sections/providers.d.ts +17 -0
  153. package/dist/lib/setup/sections/providers.js +255 -0
  154. package/dist/lib/setup/sections/routing.d.ts +2 -6
  155. package/dist/lib/setup/sections/routing.js +33 -85
  156. package/dist/lib/setup/sections/taskRoutingEditor.d.ts +17 -0
  157. package/dist/lib/setup/sections/taskRoutingEditor.js +149 -0
  158. package/dist/lib/setup/summary.d.ts +9 -0
  159. package/dist/lib/setup/summary.js +51 -37
  160. package/dist/lib/setup/ui/status.d.ts +1 -0
  161. package/dist/lib/setup/ui/status.js +2 -0
  162. package/dist/lib/setup.d.ts +108 -3
  163. package/dist/lib/setup.js +813 -303
  164. package/dist/lib/setupKeys.d.ts +42 -0
  165. package/dist/lib/setupKeys.js +564 -0
  166. package/dist/lib/setupRemoteCommand.d.ts +4 -0
  167. package/dist/lib/setupRemoteCommand.js +28 -0
  168. package/dist/lib/setupRemotePullCommand.d.ts +5 -0
  169. package/dist/lib/setupRemotePullCommand.js +52 -0
  170. package/dist/lib/setupRemotePushCommand.d.ts +5 -0
  171. package/dist/lib/setupRemotePushCommand.js +57 -0
  172. package/dist/lib/setupRemoteResolveCommand.d.ts +4 -0
  173. package/dist/lib/setupRemoteResolveCommand.js +48 -0
  174. package/dist/lib/setupRemoteStatusCommand.d.ts +4 -0
  175. package/dist/lib/setupRemoteStatusCommand.js +73 -0
  176. package/dist/lib/setupRemoteSyncCommand.d.ts +6 -0
  177. package/dist/lib/setupRemoteSyncCommand.js +65 -0
  178. package/dist/lib/setupSyncProjectsCommand.d.ts +4 -0
  179. package/dist/lib/setupSyncProjectsCommand.js +292 -0
  180. package/dist/lib/staleCommand.d.ts +8 -0
  181. package/dist/lib/staleCommand.js +34 -0
  182. package/dist/lib/statsCommand.d.ts +6 -0
  183. package/dist/lib/statsCommand.js +142 -0
  184. package/dist/lib/statusCommand.d.ts +18 -0
  185. package/dist/lib/statusCommand.js +250 -0
  186. package/dist/lib/storesCommand.d.ts +2 -0
  187. package/dist/lib/storesCommand.js +4 -0
  188. package/dist/lib/syncClient.d.ts +47 -0
  189. package/dist/lib/syncClient.js +212 -0
  190. package/dist/lib/syncCommand.d.ts +6 -0
  191. package/dist/lib/syncCommand.js +57 -0
  192. package/dist/lib/syncDoctorCommand.d.ts +5 -0
  193. package/dist/lib/syncDoctorCommand.js +100 -0
  194. package/dist/lib/syncIngest.d.ts +19 -0
  195. package/dist/lib/syncIngest.js +152 -0
  196. package/dist/lib/syncIngestLaunchd.d.ts +8 -0
  197. package/dist/lib/syncIngestLaunchd.js +93 -0
  198. package/dist/lib/syncIngestStartup.d.ts +5 -0
  199. package/dist/lib/syncIngestStartup.js +29 -0
  200. package/dist/lib/syncIngestSystemd.d.ts +10 -0
  201. package/dist/lib/syncIngestSystemd.js +97 -0
  202. package/dist/lib/syncIngestTimer.d.ts +8 -0
  203. package/dist/lib/syncIngestTimer.js +27 -0
  204. package/dist/lib/syncIngestTimerCommand.d.ts +7 -0
  205. package/dist/lib/syncIngestTimerCommand.js +83 -0
  206. package/dist/lib/syncLock.d.ts +6 -0
  207. package/dist/lib/syncLock.js +74 -0
  208. package/dist/lib/syncSnapshot.d.ts +30 -0
  209. package/dist/lib/syncSnapshot.js +184 -0
  210. package/dist/lib/syncStaging.d.ts +81 -0
  211. package/dist/lib/syncStaging.js +239 -0
  212. package/dist/lib/tagsAddCommand.d.ts +8 -0
  213. package/dist/lib/tagsAddCommand.js +18 -0
  214. package/dist/lib/tagsCommand.d.ts +4 -0
  215. package/dist/lib/tagsCommand.js +16 -0
  216. package/dist/lib/timelineCommand.d.ts +7 -0
  217. package/dist/lib/timelineCommand.js +49 -0
  218. package/dist/lib/traceCommand.d.ts +6 -0
  219. package/dist/lib/traceCommand.js +39 -0
  220. package/dist/lib/traverseCommand.d.ts +6 -0
  221. package/dist/lib/traverseCommand.js +58 -0
  222. package/dist/lib/updateCommand.d.ts +13 -0
  223. package/dist/lib/updateCommand.js +67 -0
  224. package/dist/lib/updateStatusCommand.d.ts +5 -0
  225. package/dist/lib/updateStatusCommand.js +38 -0
  226. package/dist/lib/webAddCommand.d.ts +8 -0
  227. package/dist/lib/webAddCommand.js +55 -0
  228. package/dist/lib/webBuildCommand.d.ts +10 -0
  229. package/dist/lib/webBuildCommand.js +65 -0
  230. package/dist/lib/webBuildIndexCommand.d.ts +8 -0
  231. package/dist/lib/webBuildIndexCommand.js +37 -0
  232. package/dist/lib/webIngestCommand.d.ts +11 -0
  233. package/dist/lib/webIngestCommand.js +51 -0
  234. package/dist/lib/webInitCommand.d.ts +9 -0
  235. package/dist/lib/webInitCommand.js +167 -0
  236. package/dist/lib/webRemoveCommand.d.ts +5 -0
  237. package/dist/lib/webRemoveCommand.js +41 -0
  238. package/dist/lib/webStatusCommand.d.ts +5 -0
  239. package/dist/lib/webStatusCommand.js +94 -0
  240. package/dist/lib/webUpdateCommand.d.ts +7 -0
  241. package/dist/lib/webUpdateCommand.js +72 -0
  242. package/dist/lib/workingSetCommand.d.ts +6 -0
  243. package/dist/lib/workingSetCommand.js +37 -0
  244. package/package.json +2 -1
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared stdio MCP install helpers for IDE setup (`gnosys setup ides`).
3
+ */
4
+ /** IDE keys handled by `setupIDE()`. */
5
+ export declare const SUPPORTED_IDE_KEYS: readonly ["claude", "claude-desktop", "cursor", "codex", "gemini-cli", "antigravity", "grok-build"];
6
+ export type SupportedIde = (typeof SUPPORTED_IDE_KEYS)[number];
7
+ /** User-facing aliases → canonical IDE key. */
8
+ export declare const IDE_ALIASES: Record<string, SupportedIde>;
9
+ export declare function normalizeIdeKey(ide: string): SupportedIde | null;
10
+ /** Absolute path to `gnosys-mcp` when on PATH, else bare name. */
11
+ export declare function resolveGnosysMcpCommand(): string;
12
+ export declare function gnosysStdioMcpEntry(): {
13
+ command: string;
14
+ args: string[];
15
+ };
16
+ /** True when an existing JSON MCP entry still points at broken `gnosys serve`. */
17
+ export declare function isStaleGnosysMcpEntry(entry: unknown): boolean;
18
+ /** Merge (or replace) the gnosys stdio entry in a JSON MCP config file. */
19
+ export declare function installStdioMcpJson(file: string): Promise<void>;
20
+ /** Project + user-global Cursor MCP paths. */
21
+ export declare function cursorMcpPaths(projectDir: string): {
22
+ project: string;
23
+ user: string;
24
+ };
25
+ /** Run a CLI with argv (safe for paths containing spaces). */
26
+ export declare function runCli(command: string, args: string[], opts?: {
27
+ allowFailure?: boolean;
28
+ }): string;
29
+ /** Remove a `[section]` block from hand-rolled TOML text. */
30
+ export declare function removeTomlSection(existing: string, sectionHeader: string): string;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Shared stdio MCP install helpers for IDE setup (`gnosys setup ides`).
3
+ */
4
+ import { execFileSync, execSync } from "child_process";
5
+ import path from "path";
6
+ import os from "os";
7
+ import { mergeJsonMcpServer } from "./mcpClientConfig.js";
8
+ /** IDE keys handled by `setupIDE()`. */
9
+ export const SUPPORTED_IDE_KEYS = [
10
+ "claude",
11
+ "claude-desktop",
12
+ "cursor",
13
+ "codex",
14
+ "gemini-cli",
15
+ "antigravity",
16
+ "grok-build",
17
+ ];
18
+ /** User-facing aliases → canonical IDE key. */
19
+ export const IDE_ALIASES = {
20
+ grok: "grok-build",
21
+ "grok-build": "grok-build",
22
+ };
23
+ export function normalizeIdeKey(ide) {
24
+ const key = ide.toLowerCase();
25
+ if (SUPPORTED_IDE_KEYS.includes(key)) {
26
+ return key;
27
+ }
28
+ return IDE_ALIASES[key] ?? null;
29
+ }
30
+ /** Absolute path to `gnosys-mcp` when on PATH, else bare name. */
31
+ export function resolveGnosysMcpCommand() {
32
+ try {
33
+ const p = execSync("command -v gnosys-mcp", { encoding: "utf-8" }).trim();
34
+ if (p)
35
+ return p;
36
+ }
37
+ catch {
38
+ // Fall back to bare name on PATH.
39
+ }
40
+ return "gnosys-mcp";
41
+ }
42
+ export function gnosysStdioMcpEntry() {
43
+ return { command: resolveGnosysMcpCommand(), args: [] };
44
+ }
45
+ /** True when an existing JSON MCP entry still points at broken `gnosys serve`. */
46
+ export function isStaleGnosysMcpEntry(entry) {
47
+ if (!entry || typeof entry !== "object")
48
+ return false;
49
+ const e = entry;
50
+ const cmd = String(e.command ?? "");
51
+ const args = Array.isArray(e.args) ? e.args.map(String) : [];
52
+ if (cmd.includes("gnosys-mcp"))
53
+ return false;
54
+ if (cmd.endsWith("/gnosys") || cmd === "gnosys") {
55
+ return args.includes("serve") || args.length === 0;
56
+ }
57
+ return false;
58
+ }
59
+ /** Merge (or replace) the gnosys stdio entry in a JSON MCP config file. */
60
+ export async function installStdioMcpJson(file) {
61
+ await mergeJsonMcpServer(file, gnosysStdioMcpEntry());
62
+ }
63
+ /** Project + user-global Cursor MCP paths. */
64
+ export function cursorMcpPaths(projectDir) {
65
+ return {
66
+ project: path.join(projectDir, ".cursor", "mcp.json"),
67
+ user: path.join(os.homedir(), ".cursor", "mcp.json"),
68
+ };
69
+ }
70
+ /** Run a CLI with argv (safe for paths containing spaces). */
71
+ export function runCli(command, args, opts) {
72
+ try {
73
+ return execFileSync(command, args, {
74
+ encoding: "utf-8",
75
+ stdio: ["pipe", "pipe", "pipe"],
76
+ });
77
+ }
78
+ catch (err) {
79
+ if (opts?.allowFailure) {
80
+ return err instanceof Error && "stdout" in err ? String(err.stdout ?? "") : "";
81
+ }
82
+ throw err;
83
+ }
84
+ }
85
+ /** Remove a `[section]` block from hand-rolled TOML text. */
86
+ export function removeTomlSection(existing, sectionHeader) {
87
+ const lines = existing.split("\n");
88
+ const headerIdx = lines.findIndex((line) => line.trim() === sectionHeader);
89
+ if (headerIdx === -1)
90
+ return existing;
91
+ let endIdx = lines.length;
92
+ for (let i = headerIdx + 1; i < lines.length; i++) {
93
+ if (/^\s*\[/.test(lines[i])) {
94
+ endIdx = i;
95
+ break;
96
+ }
97
+ }
98
+ const before = lines.slice(0, headerIdx).join("\n");
99
+ const after = lines.slice(endIdx).join("\n");
100
+ const merged = [before, after].filter((s) => s.length > 0).join("\n");
101
+ return merged.length > 0 ? `${merged.replace(/\n{3,}/g, "\n\n")}\n` : "";
102
+ }
@@ -0,0 +1,16 @@
1
+ import type { GnosysResolver } from "./resolver.js";
2
+ export type ImportCommandOptions = {
3
+ format?: string;
4
+ mapping?: string;
5
+ mode: string;
6
+ limit?: number;
7
+ offset?: number;
8
+ skipExisting?: boolean;
9
+ batchCommit: boolean;
10
+ concurrency?: number;
11
+ dryRun?: boolean;
12
+ store: string;
13
+ };
14
+ type GetResolver = () => Promise<GnosysResolver>;
15
+ export declare function runImportCommand(getResolver: GetResolver, fileOrUrl: string | undefined, opts: ImportCommandOptions): Promise<void>;
16
+ export {};
@@ -0,0 +1,89 @@
1
+ import { GnosysTagRegistry } from "./tags.js";
2
+ export async function runImportCommand(getResolver, fileOrUrl, opts) {
3
+ if (!fileOrUrl) {
4
+ console.error("Usage:");
5
+ console.error(" gnosys import <file> --format csv|json|jsonl --mapping '{...}' (bulk)");
6
+ console.error(" gnosys import project <bundle.json.gz> (project bundle)");
7
+ process.exit(1);
8
+ }
9
+ if (!opts.format || !opts.mapping) {
10
+ console.error("Error: --format and --mapping are required for bulk imports.");
11
+ console.error(" For project bundles, use 'gnosys import project <bundle>'.");
12
+ process.exit(1);
13
+ }
14
+ // Parse mapping JSON
15
+ let mapping;
16
+ try {
17
+ mapping = JSON.parse(opts.mapping);
18
+ }
19
+ catch {
20
+ console.error("Error: --mapping must be valid JSON. Example: '{\"name\":\"title\",\"group\":\"category\"}'");
21
+ process.exit(1);
22
+ }
23
+ const resolver = await getResolver();
24
+ const writeTarget = resolver.getWriteTarget(opts.store);
25
+ if (!writeTarget) {
26
+ console.error("No writable store found.");
27
+ process.exit(1);
28
+ }
29
+ const tagRegistry = new GnosysTagRegistry(writeTarget.store.getStorePath());
30
+ await tagRegistry.load();
31
+ const { GnosysIngestion } = await import("./ingest.js");
32
+ const { performImport, formatImportSummary } = await import("./import.js");
33
+ const ingestion = new GnosysIngestion(writeTarget.store, tagRegistry);
34
+ const format = opts.format;
35
+ const mode = opts.mode;
36
+ const concurrency = opts.concurrency || 5;
37
+ // Show estimate for LLM mode
38
+ if (mode === "llm") {
39
+ console.error(`Mode: LLM (concurrency: ${concurrency})`);
40
+ }
41
+ else {
42
+ console.error("Mode: structured (no LLM calls)");
43
+ }
44
+ if (opts.dryRun) {
45
+ console.error("DRY RUN — no files will be written\n");
46
+ }
47
+ // Progress tracking
48
+ let lastLine = "";
49
+ const onProgress = (p) => {
50
+ const pct = p.total > 0 ? Math.round((p.processed / p.total) * 100) : 0;
51
+ const bar = "█".repeat(Math.floor(pct / 5)) +
52
+ "░".repeat(20 - Math.floor(pct / 5));
53
+ const line = `[${bar}] ${p.processed}/${p.total} | ${p.current.substring(0, 40)}`;
54
+ if (line !== lastLine) {
55
+ process.stderr.write(`\r${line}`);
56
+ lastLine = line;
57
+ }
58
+ };
59
+ try {
60
+ const result = await performImport(writeTarget.store, ingestion, {
61
+ format,
62
+ data: fileOrUrl,
63
+ mapping,
64
+ mode,
65
+ limit: opts.limit,
66
+ offset: opts.offset,
67
+ dryRun: opts.dryRun,
68
+ skipExisting: opts.skipExisting,
69
+ batchCommit: opts.batchCommit,
70
+ concurrency,
71
+ onProgress,
72
+ });
73
+ // Clear progress line
74
+ process.stderr.write("\r" + " ".repeat(80) + "\r");
75
+ // Reindex search after import
76
+ if (!opts.dryRun && result.imported.length > 0) {
77
+ const search = new (await import("./search.js")).GnosysSearch(writeTarget.store.getStorePath());
78
+ for (const s of resolver.getStores()) {
79
+ await search.addStoreMemories(s.store, s.label);
80
+ }
81
+ }
82
+ console.log((opts.dryRun ? "DRY RUN — " : "✓ ") +
83
+ formatImportSummary(result));
84
+ }
85
+ catch (err) {
86
+ console.error(`\nImport failed: ${err instanceof Error ? err.message : String(err)}`);
87
+ process.exit(1);
88
+ }
89
+ }
@@ -0,0 +1,6 @@
1
+ export type ImportProjectCommandOptions = {
2
+ strategy: string;
3
+ workingDirectory?: string;
4
+ json?: boolean;
5
+ };
6
+ export declare function runImportProjectCommand(bundlePath: string, opts: ImportProjectCommandOptions): Promise<void>;
@@ -0,0 +1,43 @@
1
+ import path from "path";
2
+ const validStrategies = ["merge", "replace", "new-id"];
3
+ export async function runImportProjectCommand(bundlePath, opts) {
4
+ if (!validStrategies.includes(opts.strategy)) {
5
+ console.error(`Invalid strategy: ${opts.strategy}. Use one of: ${validStrategies.join(", ")}`);
6
+ process.exitCode = 1;
7
+ return;
8
+ }
9
+ let centralDb = null;
10
+ try {
11
+ const { GnosysDB: DbClass } = await import("./db.js");
12
+ const { importProject } = await import("./importProject.js");
13
+ centralDb = DbClass.openCentral();
14
+ if (!centralDb.isAvailable()) {
15
+ console.error("Central DB unavailable.");
16
+ process.exitCode = 1;
17
+ return;
18
+ }
19
+ const result = importProject(centralDb, {
20
+ bundlePath: path.resolve(bundlePath),
21
+ strategy: opts.strategy,
22
+ workingDirectoryOverride: opts.workingDirectory,
23
+ });
24
+ if (opts.json) {
25
+ console.log(JSON.stringify(result, null, 2));
26
+ }
27
+ else {
28
+ console.log(`Imported project ${result.projectName} (${result.projectId})`);
29
+ console.log(` Strategy: ${result.strategy}`);
30
+ console.log(` Memories: ${result.memoriesInserted} inserted, ${result.memoriesSkipped} skipped, ${result.memoriesReplaced} replaced`);
31
+ console.log(` Relationships: ${result.relationshipsInserted}`);
32
+ console.log(` Audit entries: ${result.auditEntriesInserted}`);
33
+ }
34
+ }
35
+ catch (err) {
36
+ console.error(`Import failed: ${err instanceof Error ? err.message : String(err)}`);
37
+ process.exitCode = 1;
38
+ return;
39
+ }
40
+ finally {
41
+ centralDb?.close();
42
+ }
43
+ }
@@ -0,0 +1,13 @@
1
+ import type { GnosysResolver } from "./resolver.js";
2
+ export type IngestCommandOptions = {
3
+ mode: string;
4
+ store?: string;
5
+ author: string;
6
+ authority: string;
7
+ dryRun?: boolean;
8
+ listAttachments?: boolean;
9
+ directory?: string;
10
+ };
11
+ type GetResolver = () => Promise<GnosysResolver>;
12
+ export declare function runIngestCommand(getResolver: GetResolver, fileOrGlob: string, opts: IngestCommandOptions): Promise<void>;
13
+ export {};
@@ -0,0 +1,95 @@
1
+ import path from "path";
2
+ import fs from "fs/promises";
3
+ export async function runIngestCommand(getResolver, fileOrGlob, opts) {
4
+ // List attachments mode
5
+ if (opts.listAttachments) {
6
+ const { listAttachments } = await import("./attachments.js");
7
+ const resolver = await getResolver();
8
+ const writeTarget = resolver.getWriteTarget(opts.store || undefined);
9
+ if (!writeTarget) {
10
+ console.error("No writable store found.");
11
+ process.exit(1);
12
+ }
13
+ const attachments = await listAttachments(writeTarget.store.getStorePath());
14
+ if (attachments.length === 0) {
15
+ console.log("No attachments found.");
16
+ return;
17
+ }
18
+ console.log(`Found ${attachments.length} attachment(s):\n`);
19
+ for (const a of attachments) {
20
+ const sizeMb = (a.sizeBytes / (1024 * 1024)).toFixed(2);
21
+ console.log(` ${a.originalName} (${sizeMb}MB, ${a.extension})`);
22
+ console.log(` UUID: ${a.uuid}`);
23
+ console.log(` Hash: ${a.contentHash.slice(0, 16)}...`);
24
+ console.log(` Memories: ${a.memoryIds.length > 0 ? a.memoryIds.join(", ") : "none"}`);
25
+ console.log(` Created: ${a.createdAt}\n`);
26
+ }
27
+ return;
28
+ }
29
+ // Resolve the file path
30
+ const resolvedPath = path.resolve(opts.directory || process.cwd(), fileOrGlob);
31
+ // Check the file exists
32
+ try {
33
+ await fs.access(resolvedPath);
34
+ }
35
+ catch {
36
+ console.error(`File not found: ${resolvedPath}`);
37
+ process.exit(1);
38
+ }
39
+ // Resolve the store
40
+ const resolver = await getResolver();
41
+ const writeTarget = resolver.getWriteTarget(opts.store || undefined);
42
+ if (!writeTarget) {
43
+ console.error("No writable store found. Create a .gnosys/ directory or set GNOSYS_PERSONAL.");
44
+ process.exit(1);
45
+ }
46
+ const storePath = writeTarget.store.getStorePath();
47
+ // Run ingestion
48
+ const { ingestFile } = await import("./multimodalIngest.js");
49
+ console.log(`Ingesting: ${path.basename(resolvedPath)}`);
50
+ if (opts.dryRun) {
51
+ console.log("(dry run — no files will be written)\n");
52
+ }
53
+ try {
54
+ const result = await ingestFile({
55
+ filePath: resolvedPath,
56
+ storePath,
57
+ mode: opts.mode,
58
+ store: opts.store || undefined,
59
+ author: opts.author,
60
+ authority: opts.authority,
61
+ dryRun: opts.dryRun,
62
+ projectRoot: opts.directory,
63
+ onProgress: (p) => {
64
+ process.stdout.write(`\r Processing chunk ${p.current}/${p.total}...`);
65
+ },
66
+ });
67
+ // Clear the progress line
68
+ if (result.memories.length > 0) {
69
+ process.stdout.write("\r" + " ".repeat(60) + "\r");
70
+ }
71
+ // Print results
72
+ console.log(`\nFile type: ${result.fileType}`);
73
+ console.log(`Attachment: ${result.attachment.originalName} (${result.attachment.uuid.slice(0, 8)}...)`);
74
+ console.log(`Duration: ${(result.duration / 1000).toFixed(1)}s`);
75
+ console.log(`Memories created: ${result.memories.length}`);
76
+ if (result.memories.length > 0) {
77
+ console.log("\nMemories:");
78
+ for (const m of result.memories) {
79
+ const extra = m.page ? ` [page ${m.page}]` : "";
80
+ console.log(` ${m.id}: ${m.title}${extra}`);
81
+ console.log(` Path: ${m.path}`);
82
+ }
83
+ }
84
+ if (result.errors.length > 0) {
85
+ console.log(`\nErrors (${result.errors.length}):`);
86
+ for (const e of result.errors) {
87
+ console.log(` Chunk ${e.chunk}: ${e.error}`);
88
+ }
89
+ }
90
+ }
91
+ catch (err) {
92
+ console.error(`\nIngestion failed: ${err instanceof Error ? err.message : err}`);
93
+ process.exit(1);
94
+ }
95
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Filter for the npm output that `gnosys upgrade` streams to the user.
3
+ *
4
+ * `npm install -g gnosys@latest` prints two deprecation warnings that we can
5
+ * do nothing about and that are harmless:
6
+ *
7
+ * npm warn deprecated prebuild-install@7.1.3: No longer maintained ...
8
+ * npm warn deprecated boolean@3.2.0: Package no longer supported ...
9
+ *
10
+ * Both come from OPTIONAL native dependencies, and both packages are deprecated
11
+ * at their latest published version with no non-deprecated successor:
12
+ * - prebuild-install ← better-sqlite3 (the SQLite engine; even the newest
13
+ * better-sqlite3 still depends on prebuild-install)
14
+ * - boolean ← global-agent ← onnxruntime-node ← @huggingface/transformers
15
+ *
16
+ * Since there's no version we can move to, we strip exactly these two lines
17
+ * from the upgrade output so it stays clean. We deliberately match the specific
18
+ * package names: any OTHER deprecation (a genuinely new one we'd want to act
19
+ * on) still passes through untouched.
20
+ */
21
+ /** Transitive packages whose deprecation warning we knowingly suppress. */
22
+ export declare const SUPPRESSED_DEPRECATED_PACKAGES: string[];
23
+ /** True if `line` is one of the known-benign npm deprecation warnings. */
24
+ export declare function isSuppressedNpmLine(line: string): boolean;
25
+ export interface NpmStderrFilter {
26
+ /** Feed a raw stderr chunk; complete non-suppressed lines are written out. */
27
+ feed(chunk: string): void;
28
+ /** Flush any trailing partial line at process end. */
29
+ end(): void;
30
+ }
31
+ /**
32
+ * Line-buffered stderr filter. npm streams warnings as it resolves the tree, so
33
+ * we buffer partial lines across chunks, drop the suppressed ones, and forward
34
+ * everything else immediately (no waiting for the whole install to finish).
35
+ */
36
+ export declare function makeNpmStderrFilter(write: (text: string) => void): NpmStderrFilter;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Filter for the npm output that `gnosys upgrade` streams to the user.
3
+ *
4
+ * `npm install -g gnosys@latest` prints two deprecation warnings that we can
5
+ * do nothing about and that are harmless:
6
+ *
7
+ * npm warn deprecated prebuild-install@7.1.3: No longer maintained ...
8
+ * npm warn deprecated boolean@3.2.0: Package no longer supported ...
9
+ *
10
+ * Both come from OPTIONAL native dependencies, and both packages are deprecated
11
+ * at their latest published version with no non-deprecated successor:
12
+ * - prebuild-install ← better-sqlite3 (the SQLite engine; even the newest
13
+ * better-sqlite3 still depends on prebuild-install)
14
+ * - boolean ← global-agent ← onnxruntime-node ← @huggingface/transformers
15
+ *
16
+ * Since there's no version we can move to, we strip exactly these two lines
17
+ * from the upgrade output so it stays clean. We deliberately match the specific
18
+ * package names: any OTHER deprecation (a genuinely new one we'd want to act
19
+ * on) still passes through untouched.
20
+ */
21
+ /** Transitive packages whose deprecation warning we knowingly suppress. */
22
+ export const SUPPRESSED_DEPRECATED_PACKAGES = ["prebuild-install", "boolean"];
23
+ /** True if `line` is one of the known-benign npm deprecation warnings. */
24
+ export function isSuppressedNpmLine(line) {
25
+ if (!/npm warn deprecated/i.test(line))
26
+ return false;
27
+ return SUPPRESSED_DEPRECATED_PACKAGES.some((pkg) => line.includes(`deprecated ${pkg}@`));
28
+ }
29
+ /**
30
+ * Line-buffered stderr filter. npm streams warnings as it resolves the tree, so
31
+ * we buffer partial lines across chunks, drop the suppressed ones, and forward
32
+ * everything else immediately (no waiting for the whole install to finish).
33
+ */
34
+ export function makeNpmStderrFilter(write) {
35
+ let leftover = "";
36
+ return {
37
+ feed(chunk) {
38
+ leftover += chunk;
39
+ const lines = leftover.split("\n");
40
+ // The last element is an incomplete line (no trailing newline yet).
41
+ leftover = lines.pop() ?? "";
42
+ for (const line of lines) {
43
+ if (!isSuppressedNpmLine(line))
44
+ write(`${line}\n`);
45
+ }
46
+ },
47
+ end() {
48
+ if (leftover.length > 0) {
49
+ if (!isSuppressedNpmLine(leftover))
50
+ write(leftover);
51
+ leftover = "";
52
+ }
53
+ },
54
+ };
55
+ }
@@ -0,0 +1,20 @@
1
+ import type { GnosysResolver } from "./resolver.js";
2
+ export type LensCommandOptions = {
3
+ category?: string;
4
+ tag?: string[];
5
+ match: string;
6
+ status?: string[];
7
+ author?: string[];
8
+ authority?: string[];
9
+ minConfidence?: string;
10
+ maxConfidence?: string;
11
+ createdAfter?: string;
12
+ createdBefore?: string;
13
+ modifiedAfter?: string;
14
+ modifiedBefore?: string;
15
+ or?: boolean;
16
+ json?: boolean;
17
+ };
18
+ type GetResolver = () => Promise<GnosysResolver>;
19
+ export declare function runLensCommand(getResolver: GetResolver, opts: LensCommandOptions): Promise<void>;
20
+ export {};
@@ -0,0 +1,61 @@
1
+ import { applyLens } from "./lensing.js";
2
+ function outputResult(json, data, humanFn) {
3
+ if (json) {
4
+ console.log(JSON.stringify(data, null, 2));
5
+ }
6
+ else {
7
+ humanFn();
8
+ }
9
+ }
10
+ export async function runLensCommand(getResolver, opts) {
11
+ const resolver = await getResolver();
12
+ const allMemories = await resolver.getAllMemories();
13
+ const lens = {};
14
+ if (opts.or)
15
+ lens.operator = "OR";
16
+ if (opts.category)
17
+ lens.category = opts.category;
18
+ if (opts.tag) {
19
+ lens.tags = opts.tag;
20
+ lens.tagMatchMode = opts.match;
21
+ }
22
+ if (opts.status)
23
+ lens.status = opts.status;
24
+ if (opts.author)
25
+ lens.author = opts.author;
26
+ if (opts.authority)
27
+ lens.authority = opts.authority;
28
+ if (opts.minConfidence)
29
+ lens.minConfidence = parseFloat(opts.minConfidence);
30
+ if (opts.maxConfidence)
31
+ lens.maxConfidence = parseFloat(opts.maxConfidence);
32
+ if (opts.createdAfter)
33
+ lens.createdAfter = opts.createdAfter;
34
+ if (opts.createdBefore)
35
+ lens.createdBefore = opts.createdBefore;
36
+ if (opts.modifiedAfter)
37
+ lens.modifiedAfter = opts.modifiedAfter;
38
+ if (opts.modifiedBefore)
39
+ lens.modifiedBefore = opts.modifiedBefore;
40
+ const result = applyLens(allMemories, lens);
41
+ const items = result.map((m) => ({
42
+ title: m.frontmatter.title,
43
+ status: m.frontmatter.status,
44
+ confidence: m.frontmatter.confidence,
45
+ sourceLabel: m.sourceLabel || "",
46
+ relativePath: m.relativePath,
47
+ }));
48
+ outputResult(!!opts.json, { count: items.length, items }, () => {
49
+ if (result.length === 0) {
50
+ console.log("No memories match the lens filter.");
51
+ return;
52
+ }
53
+ console.log(`${result.length} memories match:\n`);
54
+ for (const m of result) {
55
+ const src = m.sourceLabel || "";
56
+ console.log(` [${m.frontmatter.status}] ${m.frontmatter.title} (${m.frontmatter.confidence})`);
57
+ console.log(` ${src ? src + ":" : ""}${m.relativePath}`);
58
+ console.log();
59
+ }
60
+ });
61
+ }
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { Memory } from "./store.js";
8
8
  export interface LensFilter {
9
+ operator?: "AND" | "OR";
9
10
  category?: string;
10
11
  tags?: string[];
11
12
  tagMatchMode?: "any" | "all";