gnosys 5.11.4 → 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 (240) hide show
  1. package/dist/cli.js +324 -5150
  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/importCommand.d.ts +16 -0
  74. package/dist/lib/importCommand.js +89 -0
  75. package/dist/lib/importProjectCommand.d.ts +6 -0
  76. package/dist/lib/importProjectCommand.js +43 -0
  77. package/dist/lib/ingestCommand.d.ts +13 -0
  78. package/dist/lib/ingestCommand.js +95 -0
  79. package/dist/lib/installOutput.d.ts +36 -0
  80. package/dist/lib/installOutput.js +55 -0
  81. package/dist/lib/lensCommand.d.ts +20 -0
  82. package/dist/lib/lensCommand.js +61 -0
  83. package/dist/lib/lensing.d.ts +1 -0
  84. package/dist/lib/lensing.js +50 -9
  85. package/dist/lib/linksCommand.d.ts +7 -0
  86. package/dist/lib/linksCommand.js +48 -0
  87. package/dist/lib/listCommand.d.ts +8 -0
  88. package/dist/lib/listCommand.js +74 -0
  89. package/dist/lib/llm.d.ts +1 -1
  90. package/dist/lib/llm.js +26 -8
  91. package/dist/lib/localDiskCheck.d.ts +17 -0
  92. package/dist/lib/localDiskCheck.js +54 -0
  93. package/dist/lib/machineConfig.d.ts +11 -1
  94. package/dist/lib/machineConfig.js +16 -0
  95. package/dist/lib/machineRegistry.d.ts +61 -0
  96. package/dist/lib/machineRegistry.js +80 -0
  97. package/dist/lib/maintainCommand.d.ts +8 -0
  98. package/dist/lib/maintainCommand.js +34 -0
  99. package/dist/lib/masterLease.d.ts +20 -0
  100. package/dist/lib/masterLease.js +68 -0
  101. package/dist/lib/migrateCommand.d.ts +7 -0
  102. package/dist/lib/migrateCommand.js +158 -0
  103. package/dist/lib/migrateDbCommand.d.ts +9 -0
  104. package/dist/lib/migrateDbCommand.js +94 -0
  105. package/dist/lib/modelValidation.d.ts +5 -0
  106. package/dist/lib/modelValidation.js +27 -0
  107. package/dist/lib/openrouterTiers.d.ts +29 -0
  108. package/dist/lib/openrouterTiers.js +113 -0
  109. package/dist/lib/prefCommand.d.ts +10 -0
  110. package/dist/lib/prefCommand.js +118 -0
  111. package/dist/lib/projectsCommand.d.ts +8 -0
  112. package/dist/lib/projectsCommand.js +131 -0
  113. package/dist/lib/readCommand.d.ts +7 -0
  114. package/dist/lib/readCommand.js +62 -0
  115. package/dist/lib/recall.d.ts +3 -0
  116. package/dist/lib/recall.js +19 -4
  117. package/dist/lib/recallCommand.d.ts +11 -0
  118. package/dist/lib/recallCommand.js +112 -0
  119. package/dist/lib/reflectCommand.d.ts +8 -0
  120. package/dist/lib/reflectCommand.js +61 -0
  121. package/dist/lib/reindexCommand.d.ts +4 -0
  122. package/dist/lib/reindexCommand.js +34 -0
  123. package/dist/lib/reindexGraphCommand.d.ts +4 -0
  124. package/dist/lib/reindexGraphCommand.js +12 -0
  125. package/dist/lib/reinforceCommand.d.ts +8 -0
  126. package/dist/lib/reinforceCommand.js +40 -0
  127. package/dist/lib/remote.d.ts +5 -1
  128. package/dist/lib/remote.js +5 -1
  129. package/dist/lib/remoteWizard.d.ts +24 -5
  130. package/dist/lib/remoteWizard.js +308 -319
  131. package/dist/lib/restoreCommand.d.ts +5 -0
  132. package/dist/lib/restoreCommand.js +35 -0
  133. package/dist/lib/sandboxStartCommand.d.ts +6 -0
  134. package/dist/lib/sandboxStartCommand.js +25 -0
  135. package/dist/lib/sandboxStatusCommand.d.ts +4 -0
  136. package/dist/lib/sandboxStatusCommand.js +24 -0
  137. package/dist/lib/sandboxStopCommand.d.ts +4 -0
  138. package/dist/lib/sandboxStopCommand.js +21 -0
  139. package/dist/lib/searchCommand.d.ts +9 -0
  140. package/dist/lib/searchCommand.js +90 -0
  141. package/dist/lib/semanticSearchCommand.d.ts +8 -0
  142. package/dist/lib/semanticSearchCommand.js +52 -0
  143. package/dist/lib/setup/configSetRender.js +2 -0
  144. package/dist/lib/setup/providerGlyphs.d.ts +19 -0
  145. package/dist/lib/setup/providerGlyphs.js +42 -0
  146. package/dist/lib/setup/remoteRender.d.ts +31 -1
  147. package/dist/lib/setup/remoteRender.js +95 -4
  148. package/dist/lib/setup/sections/providers.d.ts +17 -0
  149. package/dist/lib/setup/sections/providers.js +255 -0
  150. package/dist/lib/setup/sections/routing.d.ts +2 -6
  151. package/dist/lib/setup/sections/routing.js +33 -85
  152. package/dist/lib/setup/sections/taskRoutingEditor.d.ts +17 -0
  153. package/dist/lib/setup/sections/taskRoutingEditor.js +149 -0
  154. package/dist/lib/setup/summary.d.ts +9 -0
  155. package/dist/lib/setup/summary.js +51 -37
  156. package/dist/lib/setup/ui/status.d.ts +1 -0
  157. package/dist/lib/setup/ui/status.js +2 -0
  158. package/dist/lib/setup.d.ts +108 -3
  159. package/dist/lib/setup.js +762 -157
  160. package/dist/lib/setupKeys.d.ts +42 -0
  161. package/dist/lib/setupKeys.js +564 -0
  162. package/dist/lib/setupRemoteCommand.d.ts +4 -0
  163. package/dist/lib/setupRemoteCommand.js +28 -0
  164. package/dist/lib/setupRemotePullCommand.d.ts +5 -0
  165. package/dist/lib/setupRemotePullCommand.js +52 -0
  166. package/dist/lib/setupRemotePushCommand.d.ts +5 -0
  167. package/dist/lib/setupRemotePushCommand.js +57 -0
  168. package/dist/lib/setupRemoteResolveCommand.d.ts +4 -0
  169. package/dist/lib/setupRemoteResolveCommand.js +48 -0
  170. package/dist/lib/setupRemoteStatusCommand.d.ts +4 -0
  171. package/dist/lib/setupRemoteStatusCommand.js +73 -0
  172. package/dist/lib/setupRemoteSyncCommand.d.ts +6 -0
  173. package/dist/lib/setupRemoteSyncCommand.js +65 -0
  174. package/dist/lib/setupSyncProjectsCommand.d.ts +4 -0
  175. package/dist/lib/setupSyncProjectsCommand.js +292 -0
  176. package/dist/lib/staleCommand.d.ts +8 -0
  177. package/dist/lib/staleCommand.js +34 -0
  178. package/dist/lib/statsCommand.d.ts +6 -0
  179. package/dist/lib/statsCommand.js +142 -0
  180. package/dist/lib/statusCommand.d.ts +18 -0
  181. package/dist/lib/statusCommand.js +250 -0
  182. package/dist/lib/storesCommand.d.ts +2 -0
  183. package/dist/lib/storesCommand.js +4 -0
  184. package/dist/lib/syncClient.d.ts +47 -0
  185. package/dist/lib/syncClient.js +212 -0
  186. package/dist/lib/syncCommand.d.ts +6 -0
  187. package/dist/lib/syncCommand.js +57 -0
  188. package/dist/lib/syncDoctorCommand.d.ts +5 -0
  189. package/dist/lib/syncDoctorCommand.js +100 -0
  190. package/dist/lib/syncIngest.d.ts +19 -0
  191. package/dist/lib/syncIngest.js +152 -0
  192. package/dist/lib/syncIngestLaunchd.d.ts +8 -0
  193. package/dist/lib/syncIngestLaunchd.js +93 -0
  194. package/dist/lib/syncIngestStartup.d.ts +5 -0
  195. package/dist/lib/syncIngestStartup.js +29 -0
  196. package/dist/lib/syncIngestSystemd.d.ts +10 -0
  197. package/dist/lib/syncIngestSystemd.js +97 -0
  198. package/dist/lib/syncIngestTimer.d.ts +8 -0
  199. package/dist/lib/syncIngestTimer.js +27 -0
  200. package/dist/lib/syncIngestTimerCommand.d.ts +7 -0
  201. package/dist/lib/syncIngestTimerCommand.js +83 -0
  202. package/dist/lib/syncLock.d.ts +6 -0
  203. package/dist/lib/syncLock.js +74 -0
  204. package/dist/lib/syncSnapshot.d.ts +30 -0
  205. package/dist/lib/syncSnapshot.js +184 -0
  206. package/dist/lib/syncStaging.d.ts +81 -0
  207. package/dist/lib/syncStaging.js +239 -0
  208. package/dist/lib/tagsAddCommand.d.ts +8 -0
  209. package/dist/lib/tagsAddCommand.js +18 -0
  210. package/dist/lib/tagsCommand.d.ts +4 -0
  211. package/dist/lib/tagsCommand.js +16 -0
  212. package/dist/lib/timelineCommand.d.ts +7 -0
  213. package/dist/lib/timelineCommand.js +49 -0
  214. package/dist/lib/traceCommand.d.ts +6 -0
  215. package/dist/lib/traceCommand.js +39 -0
  216. package/dist/lib/traverseCommand.d.ts +6 -0
  217. package/dist/lib/traverseCommand.js +58 -0
  218. package/dist/lib/updateCommand.d.ts +13 -0
  219. package/dist/lib/updateCommand.js +67 -0
  220. package/dist/lib/updateStatusCommand.d.ts +5 -0
  221. package/dist/lib/updateStatusCommand.js +38 -0
  222. package/dist/lib/webAddCommand.d.ts +8 -0
  223. package/dist/lib/webAddCommand.js +55 -0
  224. package/dist/lib/webBuildCommand.d.ts +10 -0
  225. package/dist/lib/webBuildCommand.js +65 -0
  226. package/dist/lib/webBuildIndexCommand.d.ts +8 -0
  227. package/dist/lib/webBuildIndexCommand.js +37 -0
  228. package/dist/lib/webIngestCommand.d.ts +11 -0
  229. package/dist/lib/webIngestCommand.js +51 -0
  230. package/dist/lib/webInitCommand.d.ts +9 -0
  231. package/dist/lib/webInitCommand.js +167 -0
  232. package/dist/lib/webRemoveCommand.d.ts +5 -0
  233. package/dist/lib/webRemoveCommand.js +41 -0
  234. package/dist/lib/webStatusCommand.d.ts +5 -0
  235. package/dist/lib/webStatusCommand.js +94 -0
  236. package/dist/lib/webUpdateCommand.d.ts +7 -0
  237. package/dist/lib/webUpdateCommand.js +72 -0
  238. package/dist/lib/workingSetCommand.d.ts +6 -0
  239. package/dist/lib/workingSetCommand.js +37 -0
  240. package/package.json +2 -1
@@ -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";
@@ -8,37 +8,33 @@
8
8
  * Apply a single lens filter to an array of memories.
9
9
  */
10
10
  export function applyLens(memories, lens) {
11
- return memories.filter((m) => matchesLens(m, lens));
11
+ return memories.filter((m) => (lens.operator ?? "AND") === "OR"
12
+ ? matchesAnyLensCriterion(m, lens)
13
+ : matchesLens(m, lens));
12
14
  }
13
15
  /**
14
- * Check if a single memory matches a lens filter.
16
+ * Check if a single memory matches a lens filter (AND semantics).
15
17
  */
16
18
  function matchesLens(m, lens) {
17
19
  const fm = m.frontmatter;
18
- // Category filter
19
20
  if (lens.category && fm.category !== lens.category)
20
21
  return false;
21
- // Status filter (array — memory must match one of the listed statuses)
22
22
  if (lens.status && lens.status.length > 0) {
23
23
  if (!lens.status.includes(fm.status))
24
24
  return false;
25
25
  }
26
- // Author filter
27
26
  if (lens.author && lens.author.length > 0) {
28
27
  if (!lens.author.includes(fm.author))
29
28
  return false;
30
29
  }
31
- // Authority filter
32
30
  if (lens.authority && lens.authority.length > 0) {
33
31
  if (!lens.authority.includes(fm.authority))
34
32
  return false;
35
33
  }
36
- // Confidence range
37
34
  if (lens.minConfidence !== undefined && fm.confidence < lens.minConfidence)
38
35
  return false;
39
36
  if (lens.maxConfidence !== undefined && fm.confidence > lens.maxConfidence)
40
37
  return false;
41
- // Tag matching
42
38
  if (lens.tags && lens.tags.length > 0) {
43
39
  const memTags = flattenTags(fm.tags);
44
40
  const mode = lens.tagMatchMode ?? "any";
@@ -48,7 +44,6 @@ function matchesLens(m, lens) {
48
44
  if (mode === "any" && matches.length === 0)
49
45
  return false;
50
46
  }
51
- // Date filters
52
47
  if (lens.createdAfter && fm.created < lens.createdAfter)
53
48
  return false;
54
49
  if (lens.createdBefore && fm.created > lens.createdBefore)
@@ -59,6 +54,52 @@ function matchesLens(m, lens) {
59
54
  return false;
60
55
  return true;
61
56
  }
57
+ /**
58
+ * Check if a memory matches any active lens criterion (OR semantics).
59
+ */
60
+ function matchesAnyLensCriterion(m, lens) {
61
+ const fm = m.frontmatter;
62
+ const checks = [];
63
+ if (lens.category) {
64
+ checks.push(fm.category === lens.category);
65
+ }
66
+ if (lens.status && lens.status.length > 0) {
67
+ checks.push(lens.status.includes(fm.status));
68
+ }
69
+ if (lens.author && lens.author.length > 0) {
70
+ checks.push(lens.author.includes(fm.author));
71
+ }
72
+ if (lens.authority && lens.authority.length > 0) {
73
+ checks.push(lens.authority.includes(fm.authority));
74
+ }
75
+ if (lens.minConfidence !== undefined) {
76
+ checks.push(fm.confidence >= lens.minConfidence);
77
+ }
78
+ if (lens.maxConfidence !== undefined) {
79
+ checks.push(fm.confidence <= lens.maxConfidence);
80
+ }
81
+ if (lens.tags && lens.tags.length > 0) {
82
+ const memTags = flattenTags(fm.tags);
83
+ const mode = lens.tagMatchMode ?? "any";
84
+ const matches = lens.tags.filter((t) => memTags.includes(t));
85
+ checks.push(mode === "all" ? matches.length === lens.tags.length : matches.length > 0);
86
+ }
87
+ if (lens.createdAfter) {
88
+ checks.push(fm.created >= lens.createdAfter);
89
+ }
90
+ if (lens.createdBefore) {
91
+ checks.push(fm.created <= lens.createdBefore);
92
+ }
93
+ if (lens.modifiedAfter) {
94
+ checks.push(fm.modified >= lens.modifiedAfter);
95
+ }
96
+ if (lens.modifiedBefore) {
97
+ checks.push(fm.modified <= lens.modifiedBefore);
98
+ }
99
+ if (checks.length === 0)
100
+ return true;
101
+ return checks.some(Boolean);
102
+ }
62
103
  /**
63
104
  * Flatten tags from either format to a simple string array.
64
105
  */
@@ -0,0 +1,7 @@
1
+ import type { GnosysResolver } from "./resolver.js";
2
+ export type LinksCommandOptions = {
3
+ json?: boolean;
4
+ };
5
+ type GetResolver = () => Promise<GnosysResolver>;
6
+ export declare function runLinksCommand(getResolver: GetResolver, memoryPath: string, opts: LinksCommandOptions): Promise<void>;
7
+ export {};
@@ -0,0 +1,48 @@
1
+ import { getBacklinks, getOutgoingLinks } from "./wikilinks.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 runLinksCommand(getResolver, memoryPath, opts) {
11
+ const resolver = await getResolver();
12
+ const memory = await resolver.readMemory(memoryPath);
13
+ if (!memory) {
14
+ console.error(`Memory not found: ${memoryPath}`);
15
+ process.exit(1);
16
+ }
17
+ const allMemories = await resolver.getAllMemories();
18
+ const outgoing = getOutgoingLinks(allMemories, memory.relativePath);
19
+ const backlinks = getBacklinks(allMemories, memory.relativePath);
20
+ outputResult(!!opts.json, {
21
+ memoryPath,
22
+ title: memory.frontmatter.title,
23
+ outgoing,
24
+ backlinks,
25
+ }, () => {
26
+ console.log(`Links for ${memory.frontmatter.title}:\n`);
27
+ if (outgoing.length > 0) {
28
+ console.log(` Outgoing (${outgoing.length}):`);
29
+ for (const link of outgoing) {
30
+ const display = link.displayText ? ` (${link.displayText})` : "";
31
+ console.log(` → [[${link.target}]]${display}`);
32
+ }
33
+ }
34
+ else {
35
+ console.log(" No outgoing links.");
36
+ }
37
+ console.log();
38
+ if (backlinks.length > 0) {
39
+ console.log(` Backlinks (${backlinks.length}):`);
40
+ for (const link of backlinks) {
41
+ console.log(` ← ${link.sourceTitle} (${link.sourcePath})`);
42
+ }
43
+ }
44
+ else {
45
+ console.log(" No backlinks.");
46
+ }
47
+ });
48
+ }
@@ -0,0 +1,8 @@
1
+ export type ListCommandOptions = {
2
+ category?: string;
3
+ tag?: string;
4
+ store?: string;
5
+ json?: boolean;
6
+ idFormat?: string;
7
+ };
8
+ export declare function runListCommand(opts: ListCommandOptions): Promise<void>;