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.
- package/dist/cli.js +324 -5150
- package/dist/index.js +364 -235
- package/dist/lib/addCommand.d.ts +9 -0
- package/dist/lib/addCommand.js +103 -0
- package/dist/lib/addStructuredCommand.d.ts +16 -0
- package/dist/lib/addStructuredCommand.js +103 -0
- package/dist/lib/ambiguityCommand.d.ts +4 -0
- package/dist/lib/ambiguityCommand.js +36 -0
- package/dist/lib/apiKeyVault.d.ts +78 -0
- package/dist/lib/apiKeyVault.js +447 -0
- package/dist/lib/askCommand.d.ts +13 -0
- package/dist/lib/askCommand.js +145 -0
- package/dist/lib/audioExtract.js +4 -1
- package/dist/lib/auditCommand.d.ts +7 -0
- package/dist/lib/auditCommand.js +27 -0
- package/dist/lib/backupCommand.d.ts +6 -0
- package/dist/lib/backupCommand.js +54 -0
- package/dist/lib/bootstrapCommand.d.ts +15 -0
- package/dist/lib/bootstrapCommand.js +51 -0
- package/dist/lib/briefingCommand.d.ts +7 -0
- package/dist/lib/briefingCommand.js +92 -0
- package/dist/lib/centralizeCommand.d.ts +5 -0
- package/dist/lib/centralizeCommand.js +16 -0
- package/dist/lib/chatCommand.d.ts +12 -0
- package/dist/lib/chatCommand.js +46 -0
- package/dist/lib/checkCommand.d.ts +4 -0
- package/dist/lib/checkCommand.js +133 -0
- package/dist/lib/clientReadOverlay.d.ts +27 -0
- package/dist/lib/clientReadOverlay.js +73 -0
- package/dist/lib/clientReadResolve.d.ts +32 -0
- package/dist/lib/clientReadResolve.js +84 -0
- package/dist/lib/commitContextCommand.d.ts +9 -0
- package/dist/lib/commitContextCommand.js +142 -0
- package/dist/lib/config.d.ts +43 -3
- package/dist/lib/config.js +58 -57
- package/dist/lib/configCommand.d.ts +10 -0
- package/dist/lib/configCommand.js +321 -0
- package/dist/lib/connectCommand.d.ts +8 -0
- package/dist/lib/connectCommand.js +19 -0
- package/dist/lib/db.d.ts +52 -0
- package/dist/lib/db.js +169 -1
- package/dist/lib/dearchiveCommand.d.ts +7 -0
- package/dist/lib/dearchiveCommand.js +41 -0
- package/dist/lib/discoverCommand.d.ts +9 -0
- package/dist/lib/discoverCommand.js +87 -0
- package/dist/lib/doctorCommand.d.ts +6 -0
- package/dist/lib/doctorCommand.js +256 -0
- package/dist/lib/dream.d.ts +42 -2
- package/dist/lib/dream.js +290 -30
- package/dist/lib/dreamCommand.d.ts +10 -0
- package/dist/lib/dreamCommand.js +195 -0
- package/dist/lib/dreamLaunchd.d.ts +2 -0
- package/dist/lib/dreamLaunchd.js +72 -0
- package/dist/lib/dreamLogCommand.d.ts +10 -0
- package/dist/lib/dreamLogCommand.js +58 -0
- package/dist/lib/dreamReport.d.ts +7 -0
- package/dist/lib/dreamReport.js +114 -0
- package/dist/lib/dreamRunLog.d.ts +121 -0
- package/dist/lib/dreamRunLog.js +212 -0
- package/dist/lib/embeddings.js +3 -0
- package/dist/lib/exportCommand.d.ts +18 -0
- package/dist/lib/exportCommand.js +101 -0
- package/dist/lib/fsearchCommand.d.ts +8 -0
- package/dist/lib/fsearchCommand.js +44 -0
- package/dist/lib/graphCommand.d.ts +4 -0
- package/dist/lib/graphCommand.js +68 -0
- package/dist/lib/helperGenerateCommand.d.ts +5 -0
- package/dist/lib/helperGenerateCommand.js +27 -0
- package/dist/lib/historyCommand.d.ts +5 -0
- package/dist/lib/historyCommand.js +51 -0
- package/dist/lib/hybridSearchCommand.d.ts +12 -0
- package/dist/lib/hybridSearchCommand.js +95 -0
- package/dist/lib/importCommand.d.ts +16 -0
- package/dist/lib/importCommand.js +89 -0
- package/dist/lib/importProjectCommand.d.ts +6 -0
- package/dist/lib/importProjectCommand.js +43 -0
- package/dist/lib/ingestCommand.d.ts +13 -0
- package/dist/lib/ingestCommand.js +95 -0
- package/dist/lib/installOutput.d.ts +36 -0
- package/dist/lib/installOutput.js +55 -0
- package/dist/lib/lensCommand.d.ts +20 -0
- package/dist/lib/lensCommand.js +61 -0
- package/dist/lib/lensing.d.ts +1 -0
- package/dist/lib/lensing.js +50 -9
- package/dist/lib/linksCommand.d.ts +7 -0
- package/dist/lib/linksCommand.js +48 -0
- package/dist/lib/listCommand.d.ts +8 -0
- package/dist/lib/listCommand.js +74 -0
- package/dist/lib/llm.d.ts +1 -1
- package/dist/lib/llm.js +26 -8
- package/dist/lib/localDiskCheck.d.ts +17 -0
- package/dist/lib/localDiskCheck.js +54 -0
- package/dist/lib/machineConfig.d.ts +11 -1
- package/dist/lib/machineConfig.js +16 -0
- package/dist/lib/machineRegistry.d.ts +61 -0
- package/dist/lib/machineRegistry.js +80 -0
- package/dist/lib/maintainCommand.d.ts +8 -0
- package/dist/lib/maintainCommand.js +34 -0
- package/dist/lib/masterLease.d.ts +20 -0
- package/dist/lib/masterLease.js +68 -0
- package/dist/lib/migrateCommand.d.ts +7 -0
- package/dist/lib/migrateCommand.js +158 -0
- package/dist/lib/migrateDbCommand.d.ts +9 -0
- package/dist/lib/migrateDbCommand.js +94 -0
- package/dist/lib/modelValidation.d.ts +5 -0
- package/dist/lib/modelValidation.js +27 -0
- package/dist/lib/openrouterTiers.d.ts +29 -0
- package/dist/lib/openrouterTiers.js +113 -0
- package/dist/lib/prefCommand.d.ts +10 -0
- package/dist/lib/prefCommand.js +118 -0
- package/dist/lib/projectsCommand.d.ts +8 -0
- package/dist/lib/projectsCommand.js +131 -0
- package/dist/lib/readCommand.d.ts +7 -0
- package/dist/lib/readCommand.js +62 -0
- package/dist/lib/recall.d.ts +3 -0
- package/dist/lib/recall.js +19 -4
- package/dist/lib/recallCommand.d.ts +11 -0
- package/dist/lib/recallCommand.js +112 -0
- package/dist/lib/reflectCommand.d.ts +8 -0
- package/dist/lib/reflectCommand.js +61 -0
- package/dist/lib/reindexCommand.d.ts +4 -0
- package/dist/lib/reindexCommand.js +34 -0
- package/dist/lib/reindexGraphCommand.d.ts +4 -0
- package/dist/lib/reindexGraphCommand.js +12 -0
- package/dist/lib/reinforceCommand.d.ts +8 -0
- package/dist/lib/reinforceCommand.js +40 -0
- package/dist/lib/remote.d.ts +5 -1
- package/dist/lib/remote.js +5 -1
- package/dist/lib/remoteWizard.d.ts +24 -5
- package/dist/lib/remoteWizard.js +308 -319
- package/dist/lib/restoreCommand.d.ts +5 -0
- package/dist/lib/restoreCommand.js +35 -0
- package/dist/lib/sandboxStartCommand.d.ts +6 -0
- package/dist/lib/sandboxStartCommand.js +25 -0
- package/dist/lib/sandboxStatusCommand.d.ts +4 -0
- package/dist/lib/sandboxStatusCommand.js +24 -0
- package/dist/lib/sandboxStopCommand.d.ts +4 -0
- package/dist/lib/sandboxStopCommand.js +21 -0
- package/dist/lib/searchCommand.d.ts +9 -0
- package/dist/lib/searchCommand.js +90 -0
- package/dist/lib/semanticSearchCommand.d.ts +8 -0
- package/dist/lib/semanticSearchCommand.js +52 -0
- package/dist/lib/setup/configSetRender.js +2 -0
- package/dist/lib/setup/providerGlyphs.d.ts +19 -0
- package/dist/lib/setup/providerGlyphs.js +42 -0
- package/dist/lib/setup/remoteRender.d.ts +31 -1
- package/dist/lib/setup/remoteRender.js +95 -4
- package/dist/lib/setup/sections/providers.d.ts +17 -0
- package/dist/lib/setup/sections/providers.js +255 -0
- package/dist/lib/setup/sections/routing.d.ts +2 -6
- package/dist/lib/setup/sections/routing.js +33 -85
- package/dist/lib/setup/sections/taskRoutingEditor.d.ts +17 -0
- package/dist/lib/setup/sections/taskRoutingEditor.js +149 -0
- package/dist/lib/setup/summary.d.ts +9 -0
- package/dist/lib/setup/summary.js +51 -37
- package/dist/lib/setup/ui/status.d.ts +1 -0
- package/dist/lib/setup/ui/status.js +2 -0
- package/dist/lib/setup.d.ts +108 -3
- package/dist/lib/setup.js +762 -157
- package/dist/lib/setupKeys.d.ts +42 -0
- package/dist/lib/setupKeys.js +564 -0
- package/dist/lib/setupRemoteCommand.d.ts +4 -0
- package/dist/lib/setupRemoteCommand.js +28 -0
- package/dist/lib/setupRemotePullCommand.d.ts +5 -0
- package/dist/lib/setupRemotePullCommand.js +52 -0
- package/dist/lib/setupRemotePushCommand.d.ts +5 -0
- package/dist/lib/setupRemotePushCommand.js +57 -0
- package/dist/lib/setupRemoteResolveCommand.d.ts +4 -0
- package/dist/lib/setupRemoteResolveCommand.js +48 -0
- package/dist/lib/setupRemoteStatusCommand.d.ts +4 -0
- package/dist/lib/setupRemoteStatusCommand.js +73 -0
- package/dist/lib/setupRemoteSyncCommand.d.ts +6 -0
- package/dist/lib/setupRemoteSyncCommand.js +65 -0
- package/dist/lib/setupSyncProjectsCommand.d.ts +4 -0
- package/dist/lib/setupSyncProjectsCommand.js +292 -0
- package/dist/lib/staleCommand.d.ts +8 -0
- package/dist/lib/staleCommand.js +34 -0
- package/dist/lib/statsCommand.d.ts +6 -0
- package/dist/lib/statsCommand.js +142 -0
- package/dist/lib/statusCommand.d.ts +18 -0
- package/dist/lib/statusCommand.js +250 -0
- package/dist/lib/storesCommand.d.ts +2 -0
- package/dist/lib/storesCommand.js +4 -0
- package/dist/lib/syncClient.d.ts +47 -0
- package/dist/lib/syncClient.js +212 -0
- package/dist/lib/syncCommand.d.ts +6 -0
- package/dist/lib/syncCommand.js +57 -0
- package/dist/lib/syncDoctorCommand.d.ts +5 -0
- package/dist/lib/syncDoctorCommand.js +100 -0
- package/dist/lib/syncIngest.d.ts +19 -0
- package/dist/lib/syncIngest.js +152 -0
- package/dist/lib/syncIngestLaunchd.d.ts +8 -0
- package/dist/lib/syncIngestLaunchd.js +93 -0
- package/dist/lib/syncIngestStartup.d.ts +5 -0
- package/dist/lib/syncIngestStartup.js +29 -0
- package/dist/lib/syncIngestSystemd.d.ts +10 -0
- package/dist/lib/syncIngestSystemd.js +97 -0
- package/dist/lib/syncIngestTimer.d.ts +8 -0
- package/dist/lib/syncIngestTimer.js +27 -0
- package/dist/lib/syncIngestTimerCommand.d.ts +7 -0
- package/dist/lib/syncIngestTimerCommand.js +83 -0
- package/dist/lib/syncLock.d.ts +6 -0
- package/dist/lib/syncLock.js +74 -0
- package/dist/lib/syncSnapshot.d.ts +30 -0
- package/dist/lib/syncSnapshot.js +184 -0
- package/dist/lib/syncStaging.d.ts +81 -0
- package/dist/lib/syncStaging.js +239 -0
- package/dist/lib/tagsAddCommand.d.ts +8 -0
- package/dist/lib/tagsAddCommand.js +18 -0
- package/dist/lib/tagsCommand.d.ts +4 -0
- package/dist/lib/tagsCommand.js +16 -0
- package/dist/lib/timelineCommand.d.ts +7 -0
- package/dist/lib/timelineCommand.js +49 -0
- package/dist/lib/traceCommand.d.ts +6 -0
- package/dist/lib/traceCommand.js +39 -0
- package/dist/lib/traverseCommand.d.ts +6 -0
- package/dist/lib/traverseCommand.js +58 -0
- package/dist/lib/updateCommand.d.ts +13 -0
- package/dist/lib/updateCommand.js +67 -0
- package/dist/lib/updateStatusCommand.d.ts +5 -0
- package/dist/lib/updateStatusCommand.js +38 -0
- package/dist/lib/webAddCommand.d.ts +8 -0
- package/dist/lib/webAddCommand.js +55 -0
- package/dist/lib/webBuildCommand.d.ts +10 -0
- package/dist/lib/webBuildCommand.js +65 -0
- package/dist/lib/webBuildIndexCommand.d.ts +8 -0
- package/dist/lib/webBuildIndexCommand.js +37 -0
- package/dist/lib/webIngestCommand.d.ts +11 -0
- package/dist/lib/webIngestCommand.js +51 -0
- package/dist/lib/webInitCommand.d.ts +9 -0
- package/dist/lib/webInitCommand.js +167 -0
- package/dist/lib/webRemoveCommand.d.ts +5 -0
- package/dist/lib/webRemoveCommand.js +41 -0
- package/dist/lib/webStatusCommand.d.ts +5 -0
- package/dist/lib/webStatusCommand.js +94 -0
- package/dist/lib/webUpdateCommand.d.ts +7 -0
- package/dist/lib/webUpdateCommand.js +72 -0
- package/dist/lib/workingSetCommand.d.ts +6 -0
- package/dist/lib/workingSetCommand.js +37 -0
- package/package.json +2 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { copyFileSync, existsSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { GnosysDB } from "./db.js";
|
|
4
|
+
export async function runBackupCommand(opts) {
|
|
5
|
+
let centralDb = null;
|
|
6
|
+
try {
|
|
7
|
+
centralDb = GnosysDB.openCentral();
|
|
8
|
+
if (!centralDb.isAvailable()) {
|
|
9
|
+
console.error("Central DB not available (better-sqlite3 missing).");
|
|
10
|
+
process.exitCode = 1;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const outputDir = opts.to || opts.output;
|
|
14
|
+
const backupPath = await centralDb.backup(outputDir);
|
|
15
|
+
const counts = centralDb.getMemoryCount();
|
|
16
|
+
const projectCount = centralDb.getAllProjects().length;
|
|
17
|
+
const centralDir = GnosysDB.getCentralDbDir();
|
|
18
|
+
const copiedFiles = [backupPath];
|
|
19
|
+
const backupDir = path.dirname(backupPath);
|
|
20
|
+
const sandboxLog = path.join(centralDir, "sandbox", "sandbox.log");
|
|
21
|
+
if (existsSync(sandboxLog)) {
|
|
22
|
+
const logDest = path.join(backupDir, "sandbox.log.bak");
|
|
23
|
+
copyFileSync(sandboxLog, logDest);
|
|
24
|
+
copiedFiles.push(logDest);
|
|
25
|
+
}
|
|
26
|
+
if (opts.json) {
|
|
27
|
+
console.log(JSON.stringify({
|
|
28
|
+
ok: true, backupPath, memories: counts.total,
|
|
29
|
+
active: counts.active, archived: counts.archived,
|
|
30
|
+
projects: projectCount, files: copiedFiles,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
console.log(`Backup created: ${backupPath}`);
|
|
35
|
+
console.log(` Memories: ${counts.total} (${counts.active} active, ${counts.archived} archived)`);
|
|
36
|
+
console.log(` Projects: ${projectCount}`);
|
|
37
|
+
if (copiedFiles.length > 1)
|
|
38
|
+
console.log(` Additional files: ${copiedFiles.length - 1}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (opts.json) {
|
|
43
|
+
console.log(JSON.stringify({ ok: false, error: err instanceof Error ? err.message : String(err) }));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.error(`Backup failed: ${err instanceof Error ? err.message : err}`);
|
|
47
|
+
}
|
|
48
|
+
process.exitCode = 1;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
centralDb?.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { GnosysResolver } from "./resolver.js";
|
|
2
|
+
export type BootstrapCommandOptions = {
|
|
3
|
+
pattern?: string[];
|
|
4
|
+
skipExisting?: boolean;
|
|
5
|
+
category: string;
|
|
6
|
+
author: string;
|
|
7
|
+
authority: string;
|
|
8
|
+
confidence: string;
|
|
9
|
+
preserveFrontmatter?: boolean;
|
|
10
|
+
dryRun?: boolean;
|
|
11
|
+
store?: string;
|
|
12
|
+
};
|
|
13
|
+
type GetResolver = () => Promise<GnosysResolver>;
|
|
14
|
+
export declare function runBootstrapCommand(getResolver: GetResolver, sourceDir: string, opts: BootstrapCommandOptions): Promise<void>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export async function runBootstrapCommand(getResolver, sourceDir, opts) {
|
|
2
|
+
const resolver = await getResolver();
|
|
3
|
+
const writeTarget = resolver.getWriteTarget(opts.store || undefined);
|
|
4
|
+
if (!writeTarget) {
|
|
5
|
+
console.error("No writable store found.");
|
|
6
|
+
process.exit(1);
|
|
7
|
+
}
|
|
8
|
+
// Show what we'll scan
|
|
9
|
+
const { bootstrap, discoverFiles } = await import("./bootstrap.js");
|
|
10
|
+
const files = await discoverFiles(sourceDir, opts.pattern);
|
|
11
|
+
console.log(`Found ${files.length} files in ${sourceDir}\n`);
|
|
12
|
+
if (files.length === 0) {
|
|
13
|
+
console.log("Nothing to import.");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const result = await bootstrap(writeTarget.store, {
|
|
17
|
+
sourceDir,
|
|
18
|
+
patterns: opts.pattern,
|
|
19
|
+
skipExisting: opts.skipExisting,
|
|
20
|
+
defaultCategory: opts.category,
|
|
21
|
+
defaultAuthor: opts.author,
|
|
22
|
+
defaultAuthority: opts.authority,
|
|
23
|
+
defaultConfidence: parseFloat(opts.confidence),
|
|
24
|
+
preserveFrontmatter: opts.preserveFrontmatter,
|
|
25
|
+
dryRun: opts.dryRun,
|
|
26
|
+
});
|
|
27
|
+
const mode = opts.dryRun ? "DRY RUN" : "COMPLETE";
|
|
28
|
+
console.log(`\nBootstrap ${mode}:`);
|
|
29
|
+
console.log(` Scanned: ${result.totalScanned}`);
|
|
30
|
+
console.log(` ${opts.dryRun ? "Would import" : "Imported"}: ${result.imported.length}`);
|
|
31
|
+
console.log(` Skipped: ${result.skipped.length}`);
|
|
32
|
+
console.log(` Failed: ${result.failed.length}`);
|
|
33
|
+
if (result.imported.length > 0) {
|
|
34
|
+
console.log(`\n${opts.dryRun ? "Would import" : "Imported"}:`);
|
|
35
|
+
for (const f of result.imported) {
|
|
36
|
+
console.log(` + ${f}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (result.skipped.length > 0) {
|
|
40
|
+
console.log(`\nSkipped (already exist):`);
|
|
41
|
+
for (const f of result.skipped) {
|
|
42
|
+
console.log(` ⏭ ${f}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (result.failed.length > 0) {
|
|
46
|
+
console.log(`\nFailed:`);
|
|
47
|
+
for (const f of result.failed) {
|
|
48
|
+
console.log(` ❌ ${f.path}: ${f.error}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { GnosysDB } from "./db.js";
|
|
2
|
+
export async function runBriefingCommand(projectNameOrId, opts) {
|
|
3
|
+
let centralDb = null;
|
|
4
|
+
try {
|
|
5
|
+
centralDb = GnosysDB.openCentral();
|
|
6
|
+
if (!centralDb.isAvailable()) {
|
|
7
|
+
console.error("Central DB not available.");
|
|
8
|
+
process.exitCode = 1;
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const { generateBriefing, generateAllBriefings, detectCurrentProject } = await import("./federated.js");
|
|
12
|
+
if (opts.all) {
|
|
13
|
+
const briefings = generateAllBriefings(centralDb);
|
|
14
|
+
if (opts.json) {
|
|
15
|
+
console.log(JSON.stringify({ count: briefings.length, briefings }, null, 2));
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (briefings.length === 0) {
|
|
19
|
+
console.log("No projects registered.");
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const b of briefings) {
|
|
23
|
+
console.log(`\n## ${b.projectName}`);
|
|
24
|
+
console.log(b.summary);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// v5.7.0: accept project name as positional argument in addition to --project <id>.
|
|
30
|
+
// Resolution order: positional name → --project flag → cwd auto-detect.
|
|
31
|
+
let pid = opts.project ?? null;
|
|
32
|
+
if (!pid && projectNameOrId) {
|
|
33
|
+
const byId = centralDb.getProject(projectNameOrId);
|
|
34
|
+
if (byId) {
|
|
35
|
+
pid = byId.id;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const all = centralDb.getAllProjects();
|
|
39
|
+
const byName = all.find((p) => p.name === projectNameOrId);
|
|
40
|
+
if (byName)
|
|
41
|
+
pid = byName.id;
|
|
42
|
+
}
|
|
43
|
+
if (!pid) {
|
|
44
|
+
console.error(`Project not found: "${projectNameOrId}". Run 'gnosys projects' to list registered projects.`);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (!pid)
|
|
50
|
+
pid = await detectCurrentProject(centralDb, opts.directory || undefined);
|
|
51
|
+
if (!pid) {
|
|
52
|
+
console.error("No project specified and none detected.");
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const briefing = generateBriefing(centralDb, pid);
|
|
57
|
+
if (!briefing) {
|
|
58
|
+
console.error(`Project not found: ${pid}`);
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (opts.json) {
|
|
63
|
+
console.log(JSON.stringify(briefing, null, 2));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
console.log(`# Briefing: ${briefing.projectName}`);
|
|
67
|
+
console.log(`Directory: ${briefing.workingDirectory}`);
|
|
68
|
+
console.log(`Active memories: ${briefing.activeMemories} / ${briefing.totalMemories}`);
|
|
69
|
+
console.log(`\nCategories:`);
|
|
70
|
+
for (const [cat, count] of Object.entries(briefing.categories).sort((a, b) => b[1] - a[1])) {
|
|
71
|
+
console.log(` ${cat}: ${count}`);
|
|
72
|
+
}
|
|
73
|
+
console.log(`\nRecent activity (7d):`);
|
|
74
|
+
if (briefing.recentActivity.length === 0) {
|
|
75
|
+
console.log(" None");
|
|
76
|
+
}
|
|
77
|
+
for (const r of briefing.recentActivity) {
|
|
78
|
+
console.log(` - ${r.title} (${r.modified})`);
|
|
79
|
+
}
|
|
80
|
+
console.log(`\nTop tags: ${briefing.topTags.slice(0, 10).map((t) => `${t.tag}(${t.count})`).join(", ") || "None"}`);
|
|
81
|
+
console.log(`\n${briefing.summary}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
console.error(`Error: ${err instanceof Error ? err.message : err}`);
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
centralDb?.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { centralizeDb } from "./centralize.js";
|
|
2
|
+
export async function runCentralizeCommand(opts) {
|
|
3
|
+
try {
|
|
4
|
+
const r = await centralizeDb({ to: opts.to, force: opts.force });
|
|
5
|
+
const mb = (r.bytes / 1024 / 1024).toFixed(1);
|
|
6
|
+
console.log("✓ Seeded central brain:");
|
|
7
|
+
console.log(` from: ${r.source}`);
|
|
8
|
+
console.log(` to: ${r.target} (${mb} MB)`);
|
|
9
|
+
console.log("");
|
|
10
|
+
console.log(`Run the server against it with GNOSYS_HOME=${opts.to}, or mount this dir as the container's /data volume.`);
|
|
11
|
+
}
|
|
12
|
+
catch (e) {
|
|
13
|
+
console.error(`centralize failed: ${e instanceof Error ? e.message : e}`);
|
|
14
|
+
process.exitCode = 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GnosysResolver } from "./resolver.js";
|
|
2
|
+
export type ChatCommandOptions = {
|
|
3
|
+
resume?: string;
|
|
4
|
+
list?: boolean;
|
|
5
|
+
search?: string;
|
|
6
|
+
provider?: string;
|
|
7
|
+
model?: string;
|
|
8
|
+
limit: string;
|
|
9
|
+
};
|
|
10
|
+
type GetResolver = () => Promise<GnosysResolver>;
|
|
11
|
+
export declare function runChatCommand(getResolver: GetResolver, opts: ChatCommandOptions): Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DEFAULT_CONFIG, loadConfig, resolveTaskModel, } from "./config.js";
|
|
2
|
+
export async function runChatCommand(getResolver, opts) {
|
|
3
|
+
const limit = parseInt(opts.limit, 10) || 20;
|
|
4
|
+
const chat = await import("./chat/index.js");
|
|
5
|
+
if (opts.list) {
|
|
6
|
+
chat.printSessionList(limit);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (opts.search) {
|
|
10
|
+
chat.printSearchResults(opts.search, limit);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const resolver = await getResolver();
|
|
14
|
+
const stores = resolver.getStores();
|
|
15
|
+
const storePath = stores[0]?.path ?? process.cwd();
|
|
16
|
+
let cliConfig;
|
|
17
|
+
try {
|
|
18
|
+
cliConfig = await loadConfig(storePath);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
cliConfig = DEFAULT_CONFIG;
|
|
22
|
+
}
|
|
23
|
+
// Fail-fast on missing API key before TUI render.
|
|
24
|
+
{
|
|
25
|
+
const chatTask = resolveTaskModel(cliConfig, "chat");
|
|
26
|
+
const provider = opts.provider ?? chatTask.provider;
|
|
27
|
+
if (provider !== "ollama" && provider !== "lmstudio") {
|
|
28
|
+
const { getApiKeyForProvider } = await import("./setup.js");
|
|
29
|
+
const key = await getApiKeyForProvider(provider);
|
|
30
|
+
if (!key) {
|
|
31
|
+
const { Status } = await import("./setup/ui/status.js");
|
|
32
|
+
const envVar = `${provider.toUpperCase()}_API_KEY`;
|
|
33
|
+
process.stderr.write(`${Status("fail", `no API key for ${provider} (the configured chat provider)`)}\n`);
|
|
34
|
+
process.stderr.write(` fix: gnosys setup pick a provider with a key, or add one\n`);
|
|
35
|
+
process.stderr.write(` export ${envVar}=...\n`);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
await chat.startChat({
|
|
41
|
+
config: cliConfig,
|
|
42
|
+
resume: opts.resume,
|
|
43
|
+
providerName: opts.provider,
|
|
44
|
+
modelName: opts.model,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { loadConfig, DEFAULT_CONFIG, resolveTaskModel, } from "./config.js";
|
|
3
|
+
import { getGnosysHome } from "./paths.js";
|
|
4
|
+
import { getLLMProvider, isProviderAvailable } from "./llm.js";
|
|
5
|
+
export async function runCheckCommand(opts) {
|
|
6
|
+
const projectDir = process.cwd();
|
|
7
|
+
const storePath = path.join(projectDir, ".gnosys");
|
|
8
|
+
const globalStorePath = getGnosysHome();
|
|
9
|
+
// Load config: try project-level first, fall back to global ~/.gnosys/
|
|
10
|
+
let cfg;
|
|
11
|
+
let configSource;
|
|
12
|
+
try {
|
|
13
|
+
const projectCfg = await loadConfig(storePath);
|
|
14
|
+
// Check if it's just defaults (no actual config file) by seeing if dream has been configured
|
|
15
|
+
const hasProjectConfig = projectCfg.dream?.provider !== DEFAULT_CONFIG.dream?.provider ||
|
|
16
|
+
projectCfg.llm?.defaultProvider !== DEFAULT_CONFIG.llm?.defaultProvider;
|
|
17
|
+
if (hasProjectConfig) {
|
|
18
|
+
cfg = projectCfg;
|
|
19
|
+
configSource = storePath;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
cfg = await loadConfig(globalStorePath);
|
|
23
|
+
configSource = globalStorePath;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
cfg = await loadConfig(globalStorePath);
|
|
28
|
+
configSource = globalStorePath;
|
|
29
|
+
}
|
|
30
|
+
const GREEN = "\x1b[32m";
|
|
31
|
+
const RED = "\x1b[31m";
|
|
32
|
+
const YELLOW = "\x1b[33m";
|
|
33
|
+
const DIM = "\x1b[2m";
|
|
34
|
+
const BOLD = "\x1b[1m";
|
|
35
|
+
const RESET = "\x1b[0m";
|
|
36
|
+
const CHECK = `${GREEN}✓${RESET}`;
|
|
37
|
+
const CROSS = `${RED}✗${RESET}`;
|
|
38
|
+
const WARN = `${YELLOW}⚠${RESET}`;
|
|
39
|
+
console.log(`\n${BOLD}Gnosys LLM Check${RESET} ${DIM}(config: ${configSource})${RESET}\n`);
|
|
40
|
+
const tasks = [
|
|
41
|
+
{
|
|
42
|
+
name: "structuring",
|
|
43
|
+
description: "adding memories, tagging",
|
|
44
|
+
resolve: () => resolveTaskModel(cfg, "structuring"),
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "synthesis",
|
|
48
|
+
description: "Q&A answers (gnosys ask)",
|
|
49
|
+
resolve: () => resolveTaskModel(cfg, "synthesis"),
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "chat",
|
|
53
|
+
description: "interactive chat (gnosys chat)",
|
|
54
|
+
// Chat reuses the synthesis task's model — surface it under its own name
|
|
55
|
+
// so users can see exactly what their TUI will use.
|
|
56
|
+
resolve: () => resolveTaskModel(cfg, "synthesis"),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "vision",
|
|
60
|
+
description: "images, PDFs",
|
|
61
|
+
resolve: () => resolveTaskModel(cfg, "vision"),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "transcription",
|
|
65
|
+
description: "audio files",
|
|
66
|
+
resolve: () => resolveTaskModel(cfg, "transcription"),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "dream",
|
|
70
|
+
description: "overnight consolidation",
|
|
71
|
+
resolve: () => ({
|
|
72
|
+
provider: cfg.dream?.provider || "ollama",
|
|
73
|
+
model: cfg.dream?.model || "llama3.2",
|
|
74
|
+
}),
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
let passed = 0;
|
|
78
|
+
let failed = 0;
|
|
79
|
+
let skipped = 0;
|
|
80
|
+
// Filter to a single task if --task was given.
|
|
81
|
+
const filteredTasks = opts.task
|
|
82
|
+
? tasks.filter((t) => t.name === opts.task)
|
|
83
|
+
: tasks;
|
|
84
|
+
if (opts.task && filteredTasks.length === 0) {
|
|
85
|
+
console.error(`Unknown task: ${opts.task}. Pick one of: ${tasks.map((t) => t.name).join(", ")}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
for (const task of filteredTasks) {
|
|
89
|
+
const { provider, model } = task.resolve();
|
|
90
|
+
const label = `${task.name.padEnd(16)} ${DIM}${provider} / ${model}${RESET}`;
|
|
91
|
+
const desc = `${DIM}(${task.description})${RESET}`;
|
|
92
|
+
// Special handling for dream — check if enabled
|
|
93
|
+
if (task.name === "dream" && !cfg.dream?.enabled) {
|
|
94
|
+
console.log(` ${WARN} ${label} disabled ${desc}`);
|
|
95
|
+
skipped++;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
// Check provider availability (API key, etc.)
|
|
99
|
+
const availability = isProviderAvailable(cfg, provider);
|
|
100
|
+
if (!availability.available) {
|
|
101
|
+
console.log(` ${CROSS} ${label} ${RED}${availability.error}${RESET} ${desc}`);
|
|
102
|
+
failed++;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
// Test actual connection with timing
|
|
106
|
+
const start = Date.now();
|
|
107
|
+
try {
|
|
108
|
+
const llmProvider = getLLMProvider({ ...cfg, llm: { ...cfg.llm, defaultProvider: provider } });
|
|
109
|
+
await llmProvider.testConnection();
|
|
110
|
+
const ms = Date.now() - start;
|
|
111
|
+
console.log(` ${CHECK} ${label} ${GREEN}${ms}ms${RESET} ${desc}`);
|
|
112
|
+
passed++;
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
const ms = Date.now() - start;
|
|
116
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
117
|
+
// Truncate long error messages
|
|
118
|
+
const shortErr = errMsg.length > 60 ? errMsg.slice(0, 57) + "..." : errMsg;
|
|
119
|
+
console.log(` ${CROSS} ${label} ${RED}${shortErr}${RESET} (${ms}ms) ${desc}`);
|
|
120
|
+
failed++;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
console.log();
|
|
124
|
+
const total = passed + failed + skipped;
|
|
125
|
+
if (failed === 0) {
|
|
126
|
+
console.log(`${CHECK} All ${passed}/${total} tasks connected.`);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
console.log(`${passed}/${total} connected, ${failed} failed${skipped > 0 ? `, ${skipped} skipped` : ""}.`);
|
|
130
|
+
console.log(`\n${DIM}Fix: Run 'gnosys setup' to configure providers and API keys.${RESET}`);
|
|
131
|
+
}
|
|
132
|
+
console.log();
|
|
133
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v13 client read overlay — merge pending-adds into read results.
|
|
3
|
+
*/
|
|
4
|
+
import type { DbMemory } from "./db.js";
|
|
5
|
+
export type PendingAddRow = {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
category: string;
|
|
9
|
+
content: string;
|
|
10
|
+
tags: string;
|
|
11
|
+
project_id: string | null;
|
|
12
|
+
scope: string;
|
|
13
|
+
created: string;
|
|
14
|
+
};
|
|
15
|
+
export interface OverlayReadResult {
|
|
16
|
+
memories: DbMemory[];
|
|
17
|
+
overlayCount: number;
|
|
18
|
+
source: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function pendingAddToDbMemory(p: PendingAddRow): DbMemory;
|
|
21
|
+
export declare function applyPendingOverlay(baseMemories: DbMemory[], pendingAdds: PendingAddRow[], ingestedUlids: Set<string>): OverlayReadResult;
|
|
22
|
+
export declare function mergeOverlayDiscoverResults<T extends {
|
|
23
|
+
id: string;
|
|
24
|
+
}>(base: T[], pendingAdds: PendingAddRow[], query: string, limit: number, toRow: (p: PendingAddRow) => T): T[];
|
|
25
|
+
export declare function mergeOverlaySearchResults<T extends {
|
|
26
|
+
id: string;
|
|
27
|
+
}>(base: T[], pendingAdds: PendingAddRow[], query: string, limit: number, toRow: (p: PendingAddRow) => T): T[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v13 client read overlay — merge pending-adds into read results.
|
|
3
|
+
*/
|
|
4
|
+
export function pendingAddToDbMemory(p) {
|
|
5
|
+
return {
|
|
6
|
+
id: p.id,
|
|
7
|
+
title: p.title,
|
|
8
|
+
category: p.category,
|
|
9
|
+
content: p.content,
|
|
10
|
+
summary: null,
|
|
11
|
+
tags: p.tags,
|
|
12
|
+
relevance: "",
|
|
13
|
+
author: "user",
|
|
14
|
+
authority: "user",
|
|
15
|
+
confidence: 0.8,
|
|
16
|
+
reinforcement_count: 0,
|
|
17
|
+
content_hash: "",
|
|
18
|
+
status: "active",
|
|
19
|
+
tier: "active",
|
|
20
|
+
supersedes: null,
|
|
21
|
+
superseded_by: null,
|
|
22
|
+
last_reinforced: null,
|
|
23
|
+
created: p.created,
|
|
24
|
+
modified: p.created,
|
|
25
|
+
embedding: null,
|
|
26
|
+
source_path: null,
|
|
27
|
+
source_file: null,
|
|
28
|
+
source_page: null,
|
|
29
|
+
source_timerange: null,
|
|
30
|
+
project_id: p.project_id,
|
|
31
|
+
scope: p.scope,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function applyPendingOverlay(baseMemories, pendingAdds, ingestedUlids) {
|
|
35
|
+
const stillPending = pendingAdds.filter((p) => !ingestedUlids.has(p.id));
|
|
36
|
+
const overlayMemories = stillPending.map(pendingAddToDbMemory);
|
|
37
|
+
const seen = new Set(baseMemories.map((m) => m.id));
|
|
38
|
+
const merged = [...baseMemories];
|
|
39
|
+
for (const m of overlayMemories) {
|
|
40
|
+
if (!seen.has(m.id)) {
|
|
41
|
+
merged.push(m);
|
|
42
|
+
seen.add(m.id);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
memories: merged,
|
|
47
|
+
overlayCount: overlayMemories.length,
|
|
48
|
+
source: "merged",
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function pendingMatchesQuery(p, query) {
|
|
52
|
+
const q = query.replace(/['"]/g, "").trim().toLowerCase();
|
|
53
|
+
if (!q)
|
|
54
|
+
return true;
|
|
55
|
+
const hay = `${p.title} ${p.content} ${p.tags} ${p.category}`.toLowerCase();
|
|
56
|
+
return q.split(/\s+/).every((term) => hay.includes(term));
|
|
57
|
+
}
|
|
58
|
+
export function mergeOverlayDiscoverResults(base, pendingAdds, query, limit, toRow) {
|
|
59
|
+
const seen = new Set(base.map((r) => r.id));
|
|
60
|
+
const merged = [...base];
|
|
61
|
+
for (const p of pendingAdds) {
|
|
62
|
+
if (merged.length >= limit)
|
|
63
|
+
break;
|
|
64
|
+
if (seen.has(p.id) || !pendingMatchesQuery(p, query))
|
|
65
|
+
continue;
|
|
66
|
+
merged.push(toRow(p));
|
|
67
|
+
seen.add(p.id);
|
|
68
|
+
}
|
|
69
|
+
return merged;
|
|
70
|
+
}
|
|
71
|
+
export function mergeOverlaySearchResults(base, pendingAdds, query, limit, toRow) {
|
|
72
|
+
return mergeOverlayDiscoverResults(base, pendingAdds, query, limit, toRow);
|
|
73
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared client read-path resolution for MCP tools and CLI commands.
|
|
3
|
+
*/
|
|
4
|
+
import { GnosysDB } from "./db.js";
|
|
5
|
+
import { type ClientReadContext } from "./syncClient.js";
|
|
6
|
+
import type { PendingAddRow } from "./clientReadOverlay.js";
|
|
7
|
+
import type { DbMemory } from "./db.js";
|
|
8
|
+
export interface ResolvedClientRead {
|
|
9
|
+
db: GnosysDB;
|
|
10
|
+
localDb: GnosysDB;
|
|
11
|
+
pendingOverlay: PendingAddRow[];
|
|
12
|
+
clientRead: ClientReadContext | null;
|
|
13
|
+
release: () => void;
|
|
14
|
+
}
|
|
15
|
+
/** Open central DB and apply v13 client read context when role is client. */
|
|
16
|
+
export declare function resolveClientRead(): ResolvedClientRead | null;
|
|
17
|
+
export declare function listMemoriesWithOverlay(resolved: ResolvedClientRead, fetch: (db: GnosysDB) => DbMemory[]): DbMemory[];
|
|
18
|
+
export declare function getMemoryWithOverlay(resolved: ResolvedClientRead, id: string): DbMemory | null;
|
|
19
|
+
export declare function discoverWithOverlay(resolved: ResolvedClientRead, query: string, limit: number): Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
title: string;
|
|
22
|
+
relevance: string;
|
|
23
|
+
rank: number;
|
|
24
|
+
project_id: string | null;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function searchWithOverlay(resolved: ResolvedClientRead, query: string, limit: number): Array<{
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
snippet: string;
|
|
30
|
+
rank: number;
|
|
31
|
+
project_id: string | null;
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared client read-path resolution for MCP tools and CLI commands.
|
|
3
|
+
*/
|
|
4
|
+
import { GnosysDB } from "./db.js";
|
|
5
|
+
import { readMachineConfig } from "./machineConfig.js";
|
|
6
|
+
import { getConfiguredRemotePath } from "./remote.js";
|
|
7
|
+
import { closeClientReadContext, openClientReadContext, } from "./syncClient.js";
|
|
8
|
+
import { applyPendingOverlay, mergeOverlayDiscoverResults, mergeOverlaySearchResults, pendingAddToDbMemory, } from "./clientReadOverlay.js";
|
|
9
|
+
/** Open central DB and apply v13 client read context when role is client. */
|
|
10
|
+
export function resolveClientRead() {
|
|
11
|
+
const localDb = GnosysDB.openCentral();
|
|
12
|
+
if (!localDb.isAvailable()) {
|
|
13
|
+
localDb.close();
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const mc = readMachineConfig();
|
|
17
|
+
if (!mc?.remote.enabled || mc.remote.role !== "client") {
|
|
18
|
+
return {
|
|
19
|
+
db: localDb,
|
|
20
|
+
localDb,
|
|
21
|
+
pendingOverlay: [],
|
|
22
|
+
clientRead: null,
|
|
23
|
+
release: () => localDb.close(),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const masterPath = getConfiguredRemotePath(localDb);
|
|
27
|
+
if (!masterPath) {
|
|
28
|
+
return {
|
|
29
|
+
db: localDb,
|
|
30
|
+
localDb,
|
|
31
|
+
pendingOverlay: [],
|
|
32
|
+
clientRead: null,
|
|
33
|
+
release: () => localDb.close(),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const clientRead = openClientReadContext(localDb, masterPath, mc.machineId);
|
|
37
|
+
return {
|
|
38
|
+
db: clientRead.db,
|
|
39
|
+
localDb,
|
|
40
|
+
pendingOverlay: clientRead.pendingOverlay,
|
|
41
|
+
clientRead,
|
|
42
|
+
release: () => {
|
|
43
|
+
closeClientReadContext(clientRead);
|
|
44
|
+
localDb.close();
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function listMemoriesWithOverlay(resolved, fetch) {
|
|
49
|
+
const base = fetch(resolved.db);
|
|
50
|
+
if (resolved.pendingOverlay.length === 0)
|
|
51
|
+
return base;
|
|
52
|
+
return applyPendingOverlay(base, resolved.pendingOverlay, new Set()).memories;
|
|
53
|
+
}
|
|
54
|
+
export function getMemoryWithOverlay(resolved, id) {
|
|
55
|
+
const fromDb = resolved.db.getMemory(id);
|
|
56
|
+
if (fromDb)
|
|
57
|
+
return fromDb;
|
|
58
|
+
const pending = resolved.pendingOverlay.find((p) => p.id === id);
|
|
59
|
+
return pending ? pendingAddToDbMemory(pending) : null;
|
|
60
|
+
}
|
|
61
|
+
export function discoverWithOverlay(resolved, query, limit) {
|
|
62
|
+
const base = resolved.db.discoverFts(query, limit);
|
|
63
|
+
if (resolved.pendingOverlay.length === 0)
|
|
64
|
+
return base;
|
|
65
|
+
return mergeOverlayDiscoverResults(base, resolved.pendingOverlay, query, limit, (p) => ({
|
|
66
|
+
id: p.id,
|
|
67
|
+
title: p.title,
|
|
68
|
+
relevance: "",
|
|
69
|
+
rank: 0,
|
|
70
|
+
project_id: p.project_id,
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
export function searchWithOverlay(resolved, query, limit) {
|
|
74
|
+
const base = resolved.db.searchFts(query, limit);
|
|
75
|
+
if (resolved.pendingOverlay.length === 0)
|
|
76
|
+
return base;
|
|
77
|
+
return mergeOverlaySearchResults(base, resolved.pendingOverlay, query, limit, (p) => ({
|
|
78
|
+
id: p.id,
|
|
79
|
+
title: p.title,
|
|
80
|
+
snippet: p.content.substring(0, 200),
|
|
81
|
+
rank: 0,
|
|
82
|
+
project_id: p.project_id,
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GnosysResolver } from "./resolver.js";
|
|
2
|
+
export type CommitContextOptions = {
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
store?: string;
|
|
5
|
+
};
|
|
6
|
+
type GetResolver = () => Promise<GnosysResolver>;
|
|
7
|
+
type ResolveProjectId = (dir?: string) => Promise<string | null>;
|
|
8
|
+
export declare function runCommitContextCommand(getResolver: GetResolver, resolveProjectId: ResolveProjectId, context: string, opts: CommitContextOptions): Promise<void>;
|
|
9
|
+
export {};
|