unforgit 0.5.2 → 0.5.5
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/chunk-CKUDYQYP.js +3652 -0
- package/dist/chunk-CKUDYQYP.js.map +1 -0
- package/dist/index.js +167 -238
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +26 -19
- package/dist/mcp.js.map +1 -1
- package/package.json +15 -8
- package/dist/chunk-7OCVIDC7.js +0 -12
- package/dist/chunk-7OCVIDC7.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
LocalStore,
|
|
4
|
+
RemoteClient,
|
|
5
|
+
applyLifecycleDefaults,
|
|
6
|
+
applyTemplate,
|
|
7
|
+
defaultConfig,
|
|
8
|
+
detectGitInfo,
|
|
9
|
+
executeConsolidation,
|
|
10
|
+
findConsolidationCandidates,
|
|
11
|
+
formatCandidatePreview,
|
|
12
|
+
formatTemplateList,
|
|
13
|
+
generateEmbedding,
|
|
14
|
+
generateSuggestions,
|
|
15
|
+
getConfigPath,
|
|
16
|
+
getDataDir,
|
|
17
|
+
getDbPath,
|
|
18
|
+
getTemplate,
|
|
19
|
+
isInitialized,
|
|
20
|
+
loadConfig,
|
|
21
|
+
mergeAndRank,
|
|
22
|
+
parseConfidence,
|
|
23
|
+
parsePositiveInt,
|
|
24
|
+
parseThreshold,
|
|
25
|
+
parseTtl,
|
|
26
|
+
persistReviewableSuggestions,
|
|
27
|
+
resolveLifecycleConfig,
|
|
28
|
+
resolveVisibility,
|
|
29
|
+
runLocalLifecycleMaintenance,
|
|
30
|
+
saveConfig,
|
|
31
|
+
validateMemoryType
|
|
32
|
+
} from "./chunk-CKUDYQYP.js";
|
|
3
33
|
|
|
4
34
|
// src/index.ts
|
|
5
35
|
import { Command as Command31 } from "commander";
|
|
@@ -98,18 +128,6 @@ var logger = {
|
|
|
98
128
|
}
|
|
99
129
|
};
|
|
100
130
|
|
|
101
|
-
// src/commands/init.ts
|
|
102
|
-
import {
|
|
103
|
-
getDataDir,
|
|
104
|
-
getConfigPath,
|
|
105
|
-
getDbPath,
|
|
106
|
-
defaultConfig,
|
|
107
|
-
saveConfig,
|
|
108
|
-
isInitialized,
|
|
109
|
-
detectGitInfo
|
|
110
|
-
} from "unforgit-config";
|
|
111
|
-
import { LocalStore } from "unforgit-db";
|
|
112
|
-
|
|
113
131
|
// src/ide-integration.ts
|
|
114
132
|
import fs from "fs";
|
|
115
133
|
import path from "path";
|
|
@@ -405,7 +423,6 @@ var initCommand = new Command("init").description("Initialize Unforgit in the cu
|
|
|
405
423
|
|
|
406
424
|
// src/commands/add.ts
|
|
407
425
|
import { Command as Command2 } from "commander";
|
|
408
|
-
import { loadConfig, getDbPath as getDbPath2 } from "unforgit-config";
|
|
409
426
|
|
|
410
427
|
// src/exit-codes.ts
|
|
411
428
|
var EXIT_ERROR = 1;
|
|
@@ -414,11 +431,6 @@ var EXIT_SIGINT = 130;
|
|
|
414
431
|
var EXIT_SIGTERM = 143;
|
|
415
432
|
|
|
416
433
|
// src/commands/add.ts
|
|
417
|
-
import { LocalStore as LocalStore2 } from "unforgit-db";
|
|
418
|
-
import { resolveVisibility } from "unforgit-core";
|
|
419
|
-
import { applyLifecycleDefaults } from "unforgit-core";
|
|
420
|
-
import { getTemplate, applyTemplate, formatTemplateList } from "unforgit-core";
|
|
421
|
-
import { validateMemoryType, parseConfidence, parseTtl } from "unforgit-config";
|
|
422
434
|
var addCommand = new Command2("add").description("Add a memory (local by default)").argument("<text>", "Memory text content").option(
|
|
423
435
|
"-t, --type <type>",
|
|
424
436
|
"Memory type (episodic|semantic|procedural)"
|
|
@@ -439,7 +451,7 @@ Examples:
|
|
|
439
451
|
process.exit(EXIT_ERROR);
|
|
440
452
|
}
|
|
441
453
|
const config = loadConfig();
|
|
442
|
-
const store = new
|
|
454
|
+
const store = new LocalStore(getDbPath());
|
|
443
455
|
try {
|
|
444
456
|
let userTags = [...new Set(
|
|
445
457
|
opts.tags ? opts.tags.split(",").map((t) => t.trim()).filter(Boolean) : []
|
|
@@ -503,12 +515,6 @@ Examples:
|
|
|
503
515
|
|
|
504
516
|
// src/commands/recall.ts
|
|
505
517
|
import { Command as Command3 } from "commander";
|
|
506
|
-
import { loadConfig as loadConfig2, getDbPath as getDbPath3 } from "unforgit-config";
|
|
507
|
-
import { LocalStore as LocalStore3 } from "unforgit-db";
|
|
508
|
-
import { RemoteClient } from "unforgit-config";
|
|
509
|
-
import { mergeAndRank } from "unforgit-core";
|
|
510
|
-
import { resolveLifecycleConfig } from "unforgit-core";
|
|
511
|
-
import { parsePositiveInt } from "unforgit-config";
|
|
512
518
|
var recallCommand = new Command3("recall").description("Recall memories matching a query").argument("<query>", "Search query").option(
|
|
513
519
|
"--types <types>",
|
|
514
520
|
"Comma-separated types (episodic,semantic,procedural)"
|
|
@@ -522,7 +528,7 @@ Examples:
|
|
|
522
528
|
logger.error("Search query cannot be empty.");
|
|
523
529
|
process.exit(EXIT_ERROR);
|
|
524
530
|
}
|
|
525
|
-
const config =
|
|
531
|
+
const config = loadConfig();
|
|
526
532
|
const usageTrackingLimit = resolveLifecycleConfig(config.lifecycle).usageBoost.topKToRecord;
|
|
527
533
|
const k = parsePositiveInt(opts.limit, "limit");
|
|
528
534
|
const VALID_TYPES = ["episodic", "semantic", "procedural"];
|
|
@@ -550,7 +556,7 @@ Examples:
|
|
|
550
556
|
if (!opts.remoteOnly) {
|
|
551
557
|
let store;
|
|
552
558
|
try {
|
|
553
|
-
store = new
|
|
559
|
+
store = new LocalStore(getDbPath());
|
|
554
560
|
localResults = store.recall(recallQuery);
|
|
555
561
|
const idsToRecord = localResults.slice(0, usageTrackingLimit).map((result) => result.id);
|
|
556
562
|
if (idsToRecord.length > 0) {
|
|
@@ -620,19 +626,16 @@ Examples:
|
|
|
620
626
|
|
|
621
627
|
// src/commands/promote.ts
|
|
622
628
|
import { Command as Command4 } from "commander";
|
|
623
|
-
import { loadConfig as loadConfig3, getDbPath as getDbPath4 } from "unforgit-config";
|
|
624
|
-
import { LocalStore as LocalStore4 } from "unforgit-db";
|
|
625
|
-
import { RemoteClient as RemoteClient2 } from "unforgit-config";
|
|
626
629
|
var promoteCommand = new Command4("promote").description("Promote a local memory to remote (shared)").argument("<id>", "Memory ID to promote").option("--to <scope>", "Target scope", "repo").option("--source-pr <url>", "Source PR URL").option("--source-commit <sha>", "Source commit SHA").addHelpText("after", `
|
|
627
630
|
Examples:
|
|
628
631
|
unforgit promote abc123
|
|
629
632
|
unforgit promote abc123 --source-pr https://github.com/org/repo/pull/42`).action(async (id, opts) => {
|
|
630
|
-
const config =
|
|
633
|
+
const config = loadConfig();
|
|
631
634
|
if (!config.remote.url) {
|
|
632
635
|
logger.error("Remote URL not configured. Update unforgit.yaml.");
|
|
633
636
|
process.exit(EXIT_ERROR);
|
|
634
637
|
}
|
|
635
|
-
const store = new
|
|
638
|
+
const store = new LocalStore(getDbPath());
|
|
636
639
|
try {
|
|
637
640
|
const memory = store.getById(id);
|
|
638
641
|
if (!memory) {
|
|
@@ -642,7 +645,7 @@ Examples:
|
|
|
642
645
|
const sourceRefs = { ...memory.sourceRefs ?? {} };
|
|
643
646
|
if (opts.sourcePr) sourceRefs.pr_url = opts.sourcePr;
|
|
644
647
|
if (opts.sourceCommit) sourceRefs.commit_sha = opts.sourceCommit;
|
|
645
|
-
const client = new
|
|
648
|
+
const client = new RemoteClient(config.remote.url);
|
|
646
649
|
const result = await client.store({
|
|
647
650
|
orgId: config.remote.orgId || memory.orgId,
|
|
648
651
|
repoId: config.remote.repoId || memory.repoId,
|
|
@@ -670,16 +673,13 @@ Examples:
|
|
|
670
673
|
|
|
671
674
|
// src/commands/consolidate.ts
|
|
672
675
|
import { Command as Command5 } from "commander";
|
|
673
|
-
import { loadConfig as loadConfig4 } from "unforgit-config";
|
|
674
|
-
import { RemoteClient as RemoteClient3 } from "unforgit-config";
|
|
675
|
-
import { parsePositiveInt as parsePositiveInt2 } from "unforgit-config";
|
|
676
676
|
var consolidateCommand = new Command5("consolidate").description("Consolidate episodic memories into semantic/procedural").option("--from-pr <url>", "PR URL to consolidate from").option("--from-commit <sha>", "Commit SHA to consolidate from").option("--last-n <n>", "Consolidate the last N memories").action(async (opts) => {
|
|
677
|
-
const config =
|
|
677
|
+
const config = loadConfig();
|
|
678
678
|
if (!config.remote.url) {
|
|
679
679
|
logger.error("Remote URL not configured. Update unforgit.yaml.");
|
|
680
680
|
process.exit(EXIT_CONFIG_ERROR);
|
|
681
681
|
}
|
|
682
|
-
const client = new
|
|
682
|
+
const client = new RemoteClient(config.remote.url);
|
|
683
683
|
const body = {
|
|
684
684
|
orgId: config.remote.orgId,
|
|
685
685
|
repoId: config.remote.repoId
|
|
@@ -691,7 +691,7 @@ var consolidateCommand = new Command5("consolidate").description("Consolidate ep
|
|
|
691
691
|
};
|
|
692
692
|
}
|
|
693
693
|
if (opts.lastN) {
|
|
694
|
-
body.lastN =
|
|
694
|
+
body.lastN = parsePositiveInt(opts.lastN, "last-n");
|
|
695
695
|
}
|
|
696
696
|
try {
|
|
697
697
|
const result = await client.consolidate(body);
|
|
@@ -715,16 +715,13 @@ var consolidateCommand = new Command5("consolidate").description("Consolidate ep
|
|
|
715
715
|
|
|
716
716
|
// src/commands/deprecate.ts
|
|
717
717
|
import { Command as Command6 } from "commander";
|
|
718
|
-
import { loadConfig as loadConfig5, getDbPath as getDbPath5 } from "unforgit-config";
|
|
719
|
-
import { LocalStore as LocalStore5 } from "unforgit-db";
|
|
720
|
-
import { RemoteClient as RemoteClient4 } from "unforgit-config";
|
|
721
718
|
var deprecateCommand = new Command6("deprecate").description("Mark a memory as deprecated").argument("<id>", "Memory ID to deprecate").option("--reason <reason>", "Reason for deprecation").option("--remote", "Deprecate on remote").addHelpText("after", `
|
|
722
719
|
Examples:
|
|
723
720
|
unforgit deprecate abc123 --reason "No longer relevant"
|
|
724
721
|
unforgit deprecate abc123 --remote`).action(async (id, opts) => {
|
|
725
722
|
if (opts.remote) {
|
|
726
|
-
const config =
|
|
727
|
-
const client = new
|
|
723
|
+
const config = loadConfig();
|
|
724
|
+
const client = new RemoteClient(config.remote.url);
|
|
728
725
|
try {
|
|
729
726
|
await client.deprecate(id, opts.reason);
|
|
730
727
|
logger.info(`Deprecated remote memory ${id.slice(0, 8)}...`);
|
|
@@ -737,7 +734,7 @@ Examples:
|
|
|
737
734
|
}
|
|
738
735
|
return;
|
|
739
736
|
}
|
|
740
|
-
const store = new
|
|
737
|
+
const store = new LocalStore(getDbPath());
|
|
741
738
|
try {
|
|
742
739
|
const memory = store.getById(id);
|
|
743
740
|
if (!memory) {
|
|
@@ -762,9 +759,6 @@ Examples:
|
|
|
762
759
|
|
|
763
760
|
// src/commands/supersede.ts
|
|
764
761
|
import { Command as Command7 } from "commander";
|
|
765
|
-
import { loadConfig as loadConfig6, getDbPath as getDbPath6 } from "unforgit-config";
|
|
766
|
-
import { LocalStore as LocalStore6 } from "unforgit-db";
|
|
767
|
-
import { RemoteClient as RemoteClient5 } from "unforgit-config";
|
|
768
762
|
var supersedeCommand = new Command7("supersede").description("Mark a memory as superseded by another").argument("<old-id>", "Memory ID being superseded").requiredOption("--with <new-id>", "ID of the new memory that replaces it").option("--remote", "Supersede on remote").option("--force", "Skip confirmation").addHelpText("after", `
|
|
769
763
|
Examples:
|
|
770
764
|
unforgit supersede abc123 --with def456
|
|
@@ -783,8 +777,8 @@ Examples:
|
|
|
783
777
|
}
|
|
784
778
|
}
|
|
785
779
|
if (opts.remote) {
|
|
786
|
-
const config =
|
|
787
|
-
const client = new
|
|
780
|
+
const config = loadConfig();
|
|
781
|
+
const client = new RemoteClient(config.remote.url);
|
|
788
782
|
try {
|
|
789
783
|
await client.supersede(oldId, opts.with);
|
|
790
784
|
logger.info(
|
|
@@ -798,7 +792,7 @@ Examples:
|
|
|
798
792
|
}
|
|
799
793
|
return;
|
|
800
794
|
}
|
|
801
|
-
const store = new
|
|
795
|
+
const store = new LocalStore(getDbPath());
|
|
802
796
|
try {
|
|
803
797
|
const ok = store.supersede(oldId, opts.with);
|
|
804
798
|
if (!ok) {
|
|
@@ -815,9 +809,6 @@ Examples:
|
|
|
815
809
|
|
|
816
810
|
// src/commands/delete.ts
|
|
817
811
|
import { Command as Command8 } from "commander";
|
|
818
|
-
import { loadConfig as loadConfig7, getDbPath as getDbPath7 } from "unforgit-config";
|
|
819
|
-
import { LocalStore as LocalStore7 } from "unforgit-db";
|
|
820
|
-
import { RemoteClient as RemoteClient6 } from "unforgit-config";
|
|
821
812
|
var deleteCommand = new Command8("delete").description("Soft delete a memory (can be restored)").argument("<id>", "Memory ID to delete").option("--hard", "Permanently delete (cannot be restored)").option("--remote", "Delete on remote").option("--by <author>", "Author of the deletion").option("--force", "Skip confirmation for hard delete").addHelpText("after", `
|
|
822
813
|
Examples:
|
|
823
814
|
unforgit delete abc12345 Soft delete (can be restored)
|
|
@@ -833,8 +824,8 @@ Examples:
|
|
|
833
824
|
}
|
|
834
825
|
}
|
|
835
826
|
if (opts.remote) {
|
|
836
|
-
const config =
|
|
837
|
-
const client = new
|
|
827
|
+
const config = loadConfig();
|
|
828
|
+
const client = new RemoteClient(config.remote.url);
|
|
838
829
|
try {
|
|
839
830
|
await client.delete(id, opts.by, opts.hard);
|
|
840
831
|
const action = opts.hard ? "Hard deleted" : "Soft deleted";
|
|
@@ -847,7 +838,7 @@ Examples:
|
|
|
847
838
|
}
|
|
848
839
|
return;
|
|
849
840
|
}
|
|
850
|
-
const store = new
|
|
841
|
+
const store = new LocalStore(getDbPath());
|
|
851
842
|
try {
|
|
852
843
|
let ok;
|
|
853
844
|
if (opts.hard) {
|
|
@@ -870,8 +861,8 @@ Examples:
|
|
|
870
861
|
});
|
|
871
862
|
var restoreCommand = new Command8("restore").description("Restore a soft-deleted memory").argument("<id>", "Memory ID to restore").option("--remote", "Restore on remote").action(async (id, opts) => {
|
|
872
863
|
if (opts.remote) {
|
|
873
|
-
const config =
|
|
874
|
-
const client = new
|
|
864
|
+
const config = loadConfig();
|
|
865
|
+
const client = new RemoteClient(config.remote.url);
|
|
875
866
|
try {
|
|
876
867
|
await client.restore(id);
|
|
877
868
|
logger.info(`Restored remote memory ${id.slice(0, 8)}...`);
|
|
@@ -883,7 +874,7 @@ var restoreCommand = new Command8("restore").description("Restore a soft-deleted
|
|
|
883
874
|
}
|
|
884
875
|
return;
|
|
885
876
|
}
|
|
886
|
-
const store = new
|
|
877
|
+
const store = new LocalStore(getDbPath());
|
|
887
878
|
try {
|
|
888
879
|
const ok = store.restore(id);
|
|
889
880
|
if (!ok) {
|
|
@@ -901,10 +892,9 @@ import { Command as Command9 } from "commander";
|
|
|
901
892
|
import { spawn } from "child_process";
|
|
902
893
|
import path2 from "path";
|
|
903
894
|
import fs3 from "fs";
|
|
904
|
-
import { isInitialized as isInitialized2 } from "unforgit-config";
|
|
905
895
|
var webCommand = new Command9("web").description("Start the Unforgit web dashboard").option("-p, --port <port>", "Port to run on", "3838").option("--no-open", "Don't open browser automatically").action(async (opts) => {
|
|
906
896
|
const cwd4 = process.cwd();
|
|
907
|
-
if (!
|
|
897
|
+
if (!isInitialized(cwd4)) {
|
|
908
898
|
logger.error("Unforgit not initialized in this directory. Run 'unforgit init' first.");
|
|
909
899
|
process.exit(EXIT_CONFIG_ERROR);
|
|
910
900
|
}
|
|
@@ -971,9 +961,6 @@ function findWebDir() {
|
|
|
971
961
|
|
|
972
962
|
// src/commands/link.ts
|
|
973
963
|
import { Command as Command10 } from "commander";
|
|
974
|
-
import { loadConfig as loadConfig8, getDbPath as getDbPath8 } from "unforgit-config";
|
|
975
|
-
import { LocalStore as LocalStore8 } from "unforgit-db";
|
|
976
|
-
import { RemoteClient as RemoteClient7 } from "unforgit-config";
|
|
977
964
|
var VALID_LINK_TYPES = [
|
|
978
965
|
"related_to",
|
|
979
966
|
"derived_from",
|
|
@@ -998,8 +985,8 @@ Examples:
|
|
|
998
985
|
process.exit(EXIT_ERROR);
|
|
999
986
|
}
|
|
1000
987
|
if (opts.remote) {
|
|
1001
|
-
const config =
|
|
1002
|
-
const client = new
|
|
988
|
+
const config = loadConfig();
|
|
989
|
+
const client = new RemoteClient(config.remote.url);
|
|
1003
990
|
try {
|
|
1004
991
|
const result = await client.link(sourceId, targetId, opts.type);
|
|
1005
992
|
logger.info(
|
|
@@ -1013,7 +1000,7 @@ Examples:
|
|
|
1013
1000
|
}
|
|
1014
1001
|
return;
|
|
1015
1002
|
}
|
|
1016
|
-
const store = new
|
|
1003
|
+
const store = new LocalStore(getDbPath());
|
|
1017
1004
|
try {
|
|
1018
1005
|
const source = store.getById(sourceId);
|
|
1019
1006
|
if (!source) {
|
|
@@ -1061,8 +1048,8 @@ var unlinkCommand = new Command10("unlink").description("Remove a link between t
|
|
|
1061
1048
|
process.exit(EXIT_ERROR);
|
|
1062
1049
|
}
|
|
1063
1050
|
if (opts.remote) {
|
|
1064
|
-
const config =
|
|
1065
|
-
const client = new
|
|
1051
|
+
const config = loadConfig();
|
|
1052
|
+
const client = new RemoteClient(config.remote.url);
|
|
1066
1053
|
try {
|
|
1067
1054
|
await client.unlink(sourceId, targetId, opts.type);
|
|
1068
1055
|
logger.info(
|
|
@@ -1076,7 +1063,7 @@ var unlinkCommand = new Command10("unlink").description("Remove a link between t
|
|
|
1076
1063
|
}
|
|
1077
1064
|
return;
|
|
1078
1065
|
}
|
|
1079
|
-
const store = new
|
|
1066
|
+
const store = new LocalStore(getDbPath());
|
|
1080
1067
|
try {
|
|
1081
1068
|
const ok = store.unlink(sourceId, targetId, opts.type);
|
|
1082
1069
|
if (!ok) {
|
|
@@ -1101,8 +1088,8 @@ var linksCommand = new Command10("links").description("List all links for a memo
|
|
|
1101
1088
|
process.exit(EXIT_ERROR);
|
|
1102
1089
|
}
|
|
1103
1090
|
if (opts.remote) {
|
|
1104
|
-
const config =
|
|
1105
|
-
const client = new
|
|
1091
|
+
const config = loadConfig();
|
|
1092
|
+
const client = new RemoteClient(config.remote.url);
|
|
1106
1093
|
try {
|
|
1107
1094
|
const result = await client.getLinks(memoryId, opts.type);
|
|
1108
1095
|
if (isJsonMode()) {
|
|
@@ -1127,7 +1114,7 @@ var linksCommand = new Command10("links").description("List all links for a memo
|
|
|
1127
1114
|
}
|
|
1128
1115
|
return;
|
|
1129
1116
|
}
|
|
1130
|
-
const store = new
|
|
1117
|
+
const store = new LocalStore(getDbPath());
|
|
1131
1118
|
try {
|
|
1132
1119
|
const links = store.getLinks({
|
|
1133
1120
|
memoryId,
|
|
@@ -1161,13 +1148,6 @@ var linksCommand = new Command10("links").description("List all links for a memo
|
|
|
1161
1148
|
|
|
1162
1149
|
// src/commands/merge.ts
|
|
1163
1150
|
import { Command as Command11 } from "commander";
|
|
1164
|
-
import { LocalStore as LocalStore9 } from "unforgit-db";
|
|
1165
|
-
import { loadConfig as loadConfig9, getDbPath as getDbPath9, isInitialized as isInitialized3 } from "unforgit-config";
|
|
1166
|
-
import {
|
|
1167
|
-
parseThreshold,
|
|
1168
|
-
parsePositiveInt as parsePositiveInt3,
|
|
1169
|
-
validateMemoryType as validateMemoryType2
|
|
1170
|
-
} from "unforgit-config";
|
|
1171
1151
|
var cwd = process.cwd();
|
|
1172
1152
|
var mergeCommand = new Command11("merge").description(
|
|
1173
1153
|
"Consolidate multiple local memories into one unified memory while preserving history"
|
|
@@ -1181,7 +1161,7 @@ var mergeCommand = new Command11("merge").description(
|
|
|
1181
1161
|
"--no-supersede",
|
|
1182
1162
|
"Do not mark original memories as superseded"
|
|
1183
1163
|
).action(async (ids, opts) => {
|
|
1184
|
-
if (!
|
|
1164
|
+
if (!isInitialized(cwd)) {
|
|
1185
1165
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
1186
1166
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1187
1167
|
}
|
|
@@ -1189,12 +1169,12 @@ var mergeCommand = new Command11("merge").description(
|
|
|
1189
1169
|
logger.error("At least 2 memory IDs are required for merge.");
|
|
1190
1170
|
process.exit(EXIT_ERROR);
|
|
1191
1171
|
}
|
|
1192
|
-
if (opts.type && !
|
|
1172
|
+
if (opts.type && !validateMemoryType(opts.type)) {
|
|
1193
1173
|
logger.error("--type must be one of: episodic, semantic, procedural");
|
|
1194
1174
|
process.exit(EXIT_ERROR);
|
|
1195
1175
|
}
|
|
1196
|
-
const config =
|
|
1197
|
-
const store = new
|
|
1176
|
+
const config = loadConfig(cwd);
|
|
1177
|
+
const store = new LocalStore(getDbPath(cwd));
|
|
1198
1178
|
try {
|
|
1199
1179
|
for (const id of ids) {
|
|
1200
1180
|
const mem = store.getById(id);
|
|
@@ -1247,12 +1227,12 @@ var remergeCommand = new Command11("remerge").description(
|
|
|
1247
1227
|
"--add <ids>",
|
|
1248
1228
|
"Comma-separated IDs of additional memories to include"
|
|
1249
1229
|
).option("--tags <tags>", "Comma-separated tags (keeps existing if not provided)").action(async (consolidationId, opts) => {
|
|
1250
|
-
if (!
|
|
1230
|
+
if (!isInitialized(cwd)) {
|
|
1251
1231
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
1252
1232
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1253
1233
|
}
|
|
1254
|
-
const config =
|
|
1255
|
-
const store = new
|
|
1234
|
+
const config = loadConfig(cwd);
|
|
1235
|
+
const store = new LocalStore(getDbPath(cwd));
|
|
1256
1236
|
try {
|
|
1257
1237
|
const result = store.reconsolidate({
|
|
1258
1238
|
orgId: config.remote.orgId || "local",
|
|
@@ -1292,19 +1272,19 @@ var similarCommand = new Command11("similar").description("Find memories similar
|
|
|
1292
1272
|
Examples:
|
|
1293
1273
|
unforgit similar abc123
|
|
1294
1274
|
unforgit similar abc123 --threshold 0.5 -k 5`).action(async (memoryId, opts) => {
|
|
1295
|
-
if (!
|
|
1275
|
+
if (!isInitialized(cwd)) {
|
|
1296
1276
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
1297
1277
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1298
1278
|
}
|
|
1299
|
-
const config =
|
|
1300
|
-
const store = new
|
|
1279
|
+
const config = loadConfig(cwd);
|
|
1280
|
+
const store = new LocalStore(getDbPath(cwd));
|
|
1301
1281
|
try {
|
|
1302
1282
|
const similar = store.findSimilar({
|
|
1303
1283
|
orgId: config.remote.orgId || "local",
|
|
1304
1284
|
repoId: config.remote.repoId || "local",
|
|
1305
1285
|
memoryId,
|
|
1306
1286
|
threshold: parseThreshold(opts.threshold),
|
|
1307
|
-
k:
|
|
1287
|
+
k: parsePositiveInt(opts.limit, "limit")
|
|
1308
1288
|
});
|
|
1309
1289
|
if (isJsonMode()) {
|
|
1310
1290
|
outputJson({
|
|
@@ -1345,11 +1325,11 @@ Examples:
|
|
|
1345
1325
|
}
|
|
1346
1326
|
});
|
|
1347
1327
|
var historyCommand = new Command11("history").description("Show consolidation history for a memory").argument("<memory-id>", "Memory ID to show history for").action(async (memoryId) => {
|
|
1348
|
-
if (!
|
|
1328
|
+
if (!isInitialized(cwd)) {
|
|
1349
1329
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
1350
1330
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1351
1331
|
}
|
|
1352
|
-
const store = new
|
|
1332
|
+
const store = new LocalStore(getDbPath(cwd));
|
|
1353
1333
|
try {
|
|
1354
1334
|
const memory = store.getById(memoryId);
|
|
1355
1335
|
if (!memory) {
|
|
@@ -1410,19 +1390,7 @@ var historyCommand = new Command11("history").description("Show consolidation hi
|
|
|
1410
1390
|
|
|
1411
1391
|
// src/commands/auto-consolidate.ts
|
|
1412
1392
|
import { Command as Command12 } from "commander";
|
|
1413
|
-
import { LocalStore as LocalStore10 } from "unforgit-db";
|
|
1414
|
-
import { loadConfig as loadConfig10, getDbPath as getDbPath10, isInitialized as isInitialized4 } from "unforgit-config";
|
|
1415
|
-
import {
|
|
1416
|
-
findConsolidationCandidates,
|
|
1417
|
-
executeConsolidation,
|
|
1418
|
-
formatCandidatePreview
|
|
1419
|
-
} from "unforgit-core";
|
|
1420
1393
|
import * as readline2 from "readline";
|
|
1421
|
-
import {
|
|
1422
|
-
parseThreshold as parseThreshold2,
|
|
1423
|
-
parsePositiveInt as parsePositiveInt4,
|
|
1424
|
-
validateMemoryType as validateMemoryType3
|
|
1425
|
-
} from "unforgit-config";
|
|
1426
1394
|
var cwd2 = process.cwd();
|
|
1427
1395
|
function createReadlineInterface() {
|
|
1428
1396
|
return readline2.createInterface({
|
|
@@ -1468,21 +1436,21 @@ var autoConsolidateCommand = new Command12("auto-consolidate").description(
|
|
|
1468
1436
|
"--no-preserve",
|
|
1469
1437
|
"Do not preserve original memories (hard delete)"
|
|
1470
1438
|
).action(async (opts) => {
|
|
1471
|
-
if (!
|
|
1439
|
+
if (!isInitialized(cwd2)) {
|
|
1472
1440
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
1473
1441
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1474
1442
|
}
|
|
1475
|
-
if (opts.type && !
|
|
1443
|
+
if (opts.type && !validateMemoryType(opts.type)) {
|
|
1476
1444
|
logger.error("--type must be one of: episodic, semantic, procedural");
|
|
1477
1445
|
process.exit(EXIT_ERROR);
|
|
1478
1446
|
}
|
|
1479
|
-
const config =
|
|
1480
|
-
const store = new
|
|
1447
|
+
const config = loadConfig(cwd2);
|
|
1448
|
+
const store = new LocalStore(getDbPath(cwd2));
|
|
1481
1449
|
const orgId = config.remote.orgId || "local";
|
|
1482
1450
|
const repoId = config.remote.repoId || "local";
|
|
1483
|
-
const threshold =
|
|
1484
|
-
const minGroupSize =
|
|
1485
|
-
const maxGroups =
|
|
1451
|
+
const threshold = parseThreshold(opts.threshold);
|
|
1452
|
+
const minGroupSize = parsePositiveInt(opts.minGroup, "min-group");
|
|
1453
|
+
const maxGroups = parsePositiveInt(opts.maxGroups, "max-groups");
|
|
1486
1454
|
const types = opts.type ? [opts.type] : void 0;
|
|
1487
1455
|
try {
|
|
1488
1456
|
logger.info("Scanning memories for consolidation candidates...\n");
|
|
@@ -1603,19 +1571,17 @@ Original memories are preserved with status 'superseded'.`
|
|
|
1603
1571
|
|
|
1604
1572
|
// src/commands/unconsolidate.ts
|
|
1605
1573
|
import { Command as Command13 } from "commander";
|
|
1606
|
-
import { getDbPath as getDbPath11, isInitialized as isInitialized5 } from "unforgit-config";
|
|
1607
|
-
import { LocalStore as LocalStore11 } from "unforgit-db";
|
|
1608
1574
|
var unconsolidateCommand = new Command13("unconsolidate").description("Revert a consolidation, restoring original memories to active status").argument("<consolidation-id>", "ID of the consolidated memory to revert").option("--dry-run", "Show what would be restored without making changes").option("--force", "Skip confirmation").addHelpText("after", `
|
|
1609
1575
|
Examples:
|
|
1610
1576
|
unforgit unconsolidate abc123 --dry-run Preview what would be restored
|
|
1611
1577
|
unforgit unconsolidate abc123 Revert a consolidation`).action(async (consolidationId, opts) => {
|
|
1612
1578
|
const cwd4 = process.cwd();
|
|
1613
|
-
if (!
|
|
1579
|
+
if (!isInitialized(cwd4)) {
|
|
1614
1580
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
1615
1581
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1616
1582
|
}
|
|
1617
|
-
const dbPath =
|
|
1618
|
-
const store = new
|
|
1583
|
+
const dbPath = getDbPath(cwd4);
|
|
1584
|
+
const store = new LocalStore(dbPath);
|
|
1619
1585
|
try {
|
|
1620
1586
|
const memory = store.getById(consolidationId);
|
|
1621
1587
|
if (!memory) {
|
|
@@ -1680,20 +1646,18 @@ Examples:
|
|
|
1680
1646
|
|
|
1681
1647
|
// src/commands/status.ts
|
|
1682
1648
|
import { Command as Command14 } from "commander";
|
|
1683
|
-
import { loadConfig as loadConfig11, getDbPath as getDbPath12, isInitialized as isInitialized6 } from "unforgit-config";
|
|
1684
|
-
import { LocalStore as LocalStore12 } from "unforgit-db";
|
|
1685
1649
|
var statusCommand = new Command14("status").description("Show the working tree status (pending sync state)").option("-s, --short", "Give the output in short format").addHelpText("after", `
|
|
1686
1650
|
Examples:
|
|
1687
1651
|
unforgit status Show full sync status
|
|
1688
1652
|
unforgit status -s Short format
|
|
1689
1653
|
unforgit status --json Machine-readable output`).action((opts) => {
|
|
1690
|
-
if (!
|
|
1654
|
+
if (!isInitialized()) {
|
|
1691
1655
|
logger.fatal("not an unforgit repository (or any of the parent directories)");
|
|
1692
1656
|
logger.fatal("Run 'unforgit init' to initialize.");
|
|
1693
1657
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1694
1658
|
}
|
|
1695
|
-
const config =
|
|
1696
|
-
const store = new
|
|
1659
|
+
const config = loadConfig();
|
|
1660
|
+
const store = new LocalStore(getDbPath());
|
|
1697
1661
|
try {
|
|
1698
1662
|
const orgId = config.remote.orgId || "local";
|
|
1699
1663
|
const repoId = config.remote.repoId || "local";
|
|
@@ -1782,16 +1746,13 @@ function printLongStatus(remoteName, remoteUrl, pendingPush, conflicts, untracke
|
|
|
1782
1746
|
|
|
1783
1747
|
// src/commands/push.ts
|
|
1784
1748
|
import { Command as Command15 } from "commander";
|
|
1785
|
-
import { loadConfig as loadConfig12, getDbPath as getDbPath13, isInitialized as isInitialized7 } from "unforgit-config";
|
|
1786
|
-
import { LocalStore as LocalStore13 } from "unforgit-db";
|
|
1787
|
-
import { RemoteClient as RemoteClient8 } from "unforgit-config";
|
|
1788
1749
|
var pushCommand = new Command15("push").description("Push local memories to remote").argument("[remote]", "Remote name to push to", "origin").option("-f, --force", "Force push, overwriting remote conflicts").option("--dry-run", "Show what would be pushed without actually pushing").option("-a, --all", "Push all memories including untracked ones").action(async (remote, opts) => {
|
|
1789
|
-
if (!
|
|
1750
|
+
if (!isInitialized()) {
|
|
1790
1751
|
logger.fatal("not an unforgit repository");
|
|
1791
1752
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1792
1753
|
}
|
|
1793
|
-
const config =
|
|
1794
|
-
const store = new
|
|
1754
|
+
const config = loadConfig();
|
|
1755
|
+
const store = new LocalStore(getDbPath());
|
|
1795
1756
|
try {
|
|
1796
1757
|
const orgId = config.remote.orgId || "local";
|
|
1797
1758
|
const repoId = config.remote.repoId || "local";
|
|
@@ -1800,7 +1761,7 @@ var pushCommand = new Command15("push").description("Push local memories to remo
|
|
|
1800
1761
|
logger.error("Use 'unforgit remote add origin <url>' to add a remote.");
|
|
1801
1762
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1802
1763
|
}
|
|
1803
|
-
const client = new
|
|
1764
|
+
const client = new RemoteClient(config.remote.url);
|
|
1804
1765
|
const pendingPush = store.getPendingPush();
|
|
1805
1766
|
const untracked = opts.all ? store.getUntrackedMemories(orgId, repoId) : [];
|
|
1806
1767
|
for (const memory of untracked) {
|
|
@@ -1930,16 +1891,13 @@ Total: ${allToPush.length} memories, ${supersededToSync.length} status updates,
|
|
|
1930
1891
|
|
|
1931
1892
|
// src/commands/pull.ts
|
|
1932
1893
|
import { Command as Command16 } from "commander";
|
|
1933
|
-
import { loadConfig as loadConfig13, getDbPath as getDbPath14, isInitialized as isInitialized8 } from "unforgit-config";
|
|
1934
|
-
import { LocalStore as LocalStore14 } from "unforgit-db";
|
|
1935
|
-
import { RemoteClient as RemoteClient9 } from "unforgit-config";
|
|
1936
1894
|
var pullCommand = new Command16("pull").description("Pull remote memories to local").argument("[remote]", "Remote name to pull from", "origin").option("-f, --force", "Force pull, overwriting local conflicts").option("--dry-run", "Show what would be pulled without actually pulling").action(async (remote, opts) => {
|
|
1937
|
-
if (!
|
|
1895
|
+
if (!isInitialized()) {
|
|
1938
1896
|
logger.fatal("not an unforgit repository");
|
|
1939
1897
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1940
1898
|
}
|
|
1941
|
-
const config =
|
|
1942
|
-
const store = new
|
|
1899
|
+
const config = loadConfig();
|
|
1900
|
+
const store = new LocalStore(getDbPath());
|
|
1943
1901
|
try {
|
|
1944
1902
|
const orgId = config.remote.orgId || "local";
|
|
1945
1903
|
const repoId = config.remote.repoId || "local";
|
|
@@ -1948,7 +1906,7 @@ var pullCommand = new Command16("pull").description("Pull remote memories to loc
|
|
|
1948
1906
|
logger.fatal("Use 'unforgit remote add origin <url>' to add a remote.");
|
|
1949
1907
|
process.exit(EXIT_CONFIG_ERROR);
|
|
1950
1908
|
}
|
|
1951
|
-
const client = new
|
|
1909
|
+
const client = new RemoteClient(config.remote.url);
|
|
1952
1910
|
logger.info(`Fetching from ${remote} (${config.remote.url})...`);
|
|
1953
1911
|
const response = await client.recall({
|
|
1954
1912
|
orgId,
|
|
@@ -2079,17 +2037,16 @@ Would pull:`);
|
|
|
2079
2037
|
|
|
2080
2038
|
// src/commands/remote.ts
|
|
2081
2039
|
import { Command as Command17 } from "commander";
|
|
2082
|
-
import { isInitialized as isInitialized9, loadConfig as loadConfig14, saveConfig as saveConfig2 } from "unforgit-config";
|
|
2083
2040
|
var remoteCommand = new Command17("remote").description("Manage set of tracked remote repositories").addHelpText("after", `
|
|
2084
2041
|
Examples:
|
|
2085
2042
|
unforgit remote List remotes
|
|
2086
2043
|
unforgit remote add origin <url> Add a remote
|
|
2087
2044
|
unforgit remote show origin Show remote details`).action(() => {
|
|
2088
|
-
if (!
|
|
2045
|
+
if (!isInitialized()) {
|
|
2089
2046
|
logger.fatal("not an unforgit repository");
|
|
2090
2047
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2091
2048
|
}
|
|
2092
|
-
const config =
|
|
2049
|
+
const config = loadConfig();
|
|
2093
2050
|
const remotes = getRemotes(config);
|
|
2094
2051
|
if (Object.keys(remotes).length === 0) {
|
|
2095
2052
|
logger.info("No remotes configured.");
|
|
@@ -2101,11 +2058,11 @@ Examples:
|
|
|
2101
2058
|
}
|
|
2102
2059
|
});
|
|
2103
2060
|
var remoteAddCommand = new Command17("add").description("Add a new remote").argument("<name>", "Name for the remote (e.g., origin)").argument("<url>", "URL of the remote unforgit server").option("--org <orgId>", "Organization ID").option("--repo <repoId>", "Repository ID").action((name, url, opts) => {
|
|
2104
|
-
if (!
|
|
2061
|
+
if (!isInitialized()) {
|
|
2105
2062
|
logger.fatal("not an unforgit repository");
|
|
2106
2063
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2107
2064
|
}
|
|
2108
|
-
const config =
|
|
2065
|
+
const config = loadConfig();
|
|
2109
2066
|
const remotes = getRemotes(config);
|
|
2110
2067
|
if (remotes[name]) {
|
|
2111
2068
|
logger.fatal(`remote '${name}' already exists.`);
|
|
@@ -2121,11 +2078,11 @@ var remoteAddCommand = new Command17("add").description("Add a new remote").argu
|
|
|
2121
2078
|
logger.info(`Remote '${name}' added: ${url}`);
|
|
2122
2079
|
});
|
|
2123
2080
|
var remoteRemoveCommand = new Command17("remove").alias("rm").description("Remove a remote").argument("<name>", "Name of the remote to remove").action((name) => {
|
|
2124
|
-
if (!
|
|
2081
|
+
if (!isInitialized()) {
|
|
2125
2082
|
logger.fatal("not an unforgit repository");
|
|
2126
2083
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2127
2084
|
}
|
|
2128
|
-
const config =
|
|
2085
|
+
const config = loadConfig();
|
|
2129
2086
|
const remotes = getRemotes(config);
|
|
2130
2087
|
if (!remotes[name]) {
|
|
2131
2088
|
logger.fatal(`No such remote: '${name}'`);
|
|
@@ -2136,11 +2093,11 @@ var remoteRemoveCommand = new Command17("remove").alias("rm").description("Remov
|
|
|
2136
2093
|
logger.info(`Remote '${name}' removed.`);
|
|
2137
2094
|
});
|
|
2138
2095
|
var remoteSetUrlCommand = new Command17("set-url").description("Change the URL for a remote").argument("<name>", "Name of the remote").argument("<newurl>", "New URL for the remote").action((name, newurl) => {
|
|
2139
|
-
if (!
|
|
2096
|
+
if (!isInitialized()) {
|
|
2140
2097
|
logger.fatal("not an unforgit repository");
|
|
2141
2098
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2142
2099
|
}
|
|
2143
|
-
const config =
|
|
2100
|
+
const config = loadConfig();
|
|
2144
2101
|
const remotes = getRemotes(config);
|
|
2145
2102
|
if (!remotes[name]) {
|
|
2146
2103
|
logger.fatal(`No such remote: '${name}'`);
|
|
@@ -2152,11 +2109,11 @@ var remoteSetUrlCommand = new Command17("set-url").description("Change the URL f
|
|
|
2152
2109
|
logger.info(`Remote '${name}' URL changed to: ${newurl}`);
|
|
2153
2110
|
});
|
|
2154
2111
|
var remoteShowCommand = new Command17("show").description("Show information about a remote").argument("<name>", "Name of the remote").action((name) => {
|
|
2155
|
-
if (!
|
|
2112
|
+
if (!isInitialized()) {
|
|
2156
2113
|
logger.fatal("not an unforgit repository");
|
|
2157
2114
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2158
2115
|
}
|
|
2159
|
-
const config =
|
|
2116
|
+
const config = loadConfig();
|
|
2160
2117
|
const remotes = getRemotes(config);
|
|
2161
2118
|
if (!remotes[name]) {
|
|
2162
2119
|
logger.fatal(`No such remote: '${name}'`);
|
|
@@ -2197,14 +2154,11 @@ function saveRemotes(config, remotes) {
|
|
|
2197
2154
|
repoId: remotes.origin.repoId
|
|
2198
2155
|
};
|
|
2199
2156
|
}
|
|
2200
|
-
|
|
2157
|
+
saveConfig(config);
|
|
2201
2158
|
}
|
|
2202
2159
|
|
|
2203
2160
|
// src/commands/log.ts
|
|
2204
2161
|
import { Command as Command18 } from "commander";
|
|
2205
|
-
import { loadConfig as loadConfig15, getDbPath as getDbPath15, isInitialized as isInitialized10 } from "unforgit-config";
|
|
2206
|
-
import { LocalStore as LocalStore15 } from "unforgit-db";
|
|
2207
|
-
import { parsePositiveInt as parsePositiveInt5, validateMemoryType as validateMemoryType4 } from "unforgit-config";
|
|
2208
2162
|
var logCommand = new Command18("log").description("Show memory history log").option("-n, --max-count <n>", "Limit the number of memories shown", "20").option("--oneline", "Show each memory on a single line").option("--all", "Show all memories including deprecated/superseded").option("--type <type>", "Filter by memory type (episodic|semantic|procedural)").option("--tags <tags>", "Filter by tags (comma-separated)").option("--page <n>", "Page number for pagination", "1").option("--per-page <n>", "Items per page", "20").addHelpText("after", `
|
|
2209
2163
|
Examples:
|
|
2210
2164
|
unforgit log Show recent memories
|
|
@@ -2212,17 +2166,17 @@ Examples:
|
|
|
2212
2166
|
unforgit log --type semantic Filter by type
|
|
2213
2167
|
unforgit log --oneline Compact output
|
|
2214
2168
|
unforgit log --page 2 Second page of results`).action((opts) => {
|
|
2215
|
-
if (!
|
|
2169
|
+
if (!isInitialized()) {
|
|
2216
2170
|
logger.fatal("not an unforgit repository");
|
|
2217
2171
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2218
2172
|
}
|
|
2219
|
-
const config =
|
|
2220
|
-
const store = new
|
|
2173
|
+
const config = loadConfig();
|
|
2174
|
+
const store = new LocalStore(getDbPath());
|
|
2221
2175
|
try {
|
|
2222
2176
|
const orgId = config.remote.orgId || "local";
|
|
2223
2177
|
const repoId = config.remote.repoId || "local";
|
|
2224
|
-
const limit =
|
|
2225
|
-
if (opts.type && !
|
|
2178
|
+
const limit = parsePositiveInt(opts.maxCount, "max-count");
|
|
2179
|
+
if (opts.type && !validateMemoryType(opts.type)) {
|
|
2226
2180
|
logger.error(`Invalid memory type "${opts.type}". Must be one of: episodic, semantic, procedural`);
|
|
2227
2181
|
process.exit(EXIT_ERROR);
|
|
2228
2182
|
}
|
|
@@ -2244,8 +2198,8 @@ Examples:
|
|
|
2244
2198
|
(m) => m.tags.some((t) => filterTags.includes(t))
|
|
2245
2199
|
);
|
|
2246
2200
|
}
|
|
2247
|
-
const page =
|
|
2248
|
-
const perPage =
|
|
2201
|
+
const page = parsePositiveInt(opts.page, "page");
|
|
2202
|
+
const perPage = parsePositiveInt(opts.perPage, "per-page");
|
|
2249
2203
|
const paged = paginate(filteredMemories, page, perPage);
|
|
2250
2204
|
if (isJsonMode()) {
|
|
2251
2205
|
outputJson({
|
|
@@ -2298,20 +2252,17 @@ Examples:
|
|
|
2298
2252
|
|
|
2299
2253
|
// src/commands/diff.ts
|
|
2300
2254
|
import { Command as Command19 } from "commander";
|
|
2301
|
-
import { loadConfig as loadConfig16, getDbPath as getDbPath16, isInitialized as isInitialized11 } from "unforgit-config";
|
|
2302
|
-
import { LocalStore as LocalStore16 } from "unforgit-db";
|
|
2303
|
-
import { RemoteClient as RemoteClient10 } from "unforgit-config";
|
|
2304
2255
|
var diffCommand = new Command19("diff").description("Show differences between local and remote memories").argument("[memoryId]", "Specific memory ID to diff").option("--stat", "Show only statistics").addHelpText("after", `
|
|
2305
2256
|
Examples:
|
|
2306
2257
|
unforgit diff Show all differences
|
|
2307
2258
|
unforgit diff --stat Show difference statistics only
|
|
2308
2259
|
unforgit diff abc12345 Diff a specific memory`).action(async (memoryId, opts) => {
|
|
2309
|
-
if (!
|
|
2260
|
+
if (!isInitialized()) {
|
|
2310
2261
|
logger.fatal("not an unforgit repository");
|
|
2311
2262
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2312
2263
|
}
|
|
2313
|
-
const config =
|
|
2314
|
-
const store = new
|
|
2264
|
+
const config = loadConfig();
|
|
2265
|
+
const store = new LocalStore(getDbPath());
|
|
2315
2266
|
try {
|
|
2316
2267
|
const orgId = config.remote.orgId || "local";
|
|
2317
2268
|
const repoId = config.remote.repoId || "local";
|
|
@@ -2319,7 +2270,7 @@ Examples:
|
|
|
2319
2270
|
logger.fatal("No remote configured.");
|
|
2320
2271
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2321
2272
|
}
|
|
2322
|
-
const client = new
|
|
2273
|
+
const client = new RemoteClient(config.remote.url);
|
|
2323
2274
|
if (memoryId) {
|
|
2324
2275
|
await diffSingleMemory(store, client, memoryId, orgId, repoId);
|
|
2325
2276
|
} else {
|
|
@@ -2468,14 +2419,12 @@ function findFullId(store, partialId, orgId, repoId) {
|
|
|
2468
2419
|
|
|
2469
2420
|
// src/commands/keys.ts
|
|
2470
2421
|
import { Command as Command20 } from "commander";
|
|
2471
|
-
import { loadConfig as loadConfig17, isInitialized as isInitialized12 } from "unforgit-config";
|
|
2472
|
-
import { RemoteClient as RemoteClient11 } from "unforgit-config";
|
|
2473
2422
|
function requireRemote() {
|
|
2474
|
-
if (!
|
|
2423
|
+
if (!isInitialized()) {
|
|
2475
2424
|
logger.fatal("not an unforgit repository");
|
|
2476
2425
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2477
2426
|
}
|
|
2478
|
-
const config =
|
|
2427
|
+
const config = loadConfig();
|
|
2479
2428
|
if (!config.remote.url) {
|
|
2480
2429
|
logger.fatal("No remote configured.");
|
|
2481
2430
|
logger.error("Use 'unforgit remote add origin <url>' to add a remote.");
|
|
@@ -2495,7 +2444,7 @@ Examples:
|
|
|
2495
2444
|
unforgit keys create --name "CI pipeline" --org my-org
|
|
2496
2445
|
unforgit keys list --org my-org`).action(async (opts) => {
|
|
2497
2446
|
const { url, apiKey } = requireRemote();
|
|
2498
|
-
const client = new
|
|
2447
|
+
const client = new RemoteClient(url, apiKey);
|
|
2499
2448
|
try {
|
|
2500
2449
|
const result = await client.createApiKey(opts.name, opts.org);
|
|
2501
2450
|
if (isJsonMode()) {
|
|
@@ -2521,7 +2470,7 @@ Examples:
|
|
|
2521
2470
|
});
|
|
2522
2471
|
keysCommand.command("list").description("List all API keys").option("--org <orgId>", "Filter by organization ID").action(async (opts) => {
|
|
2523
2472
|
const { url, apiKey } = requireRemote();
|
|
2524
|
-
const client = new
|
|
2473
|
+
const client = new RemoteClient(url, apiKey);
|
|
2525
2474
|
try {
|
|
2526
2475
|
const result = await client.listApiKeys(opts.org);
|
|
2527
2476
|
if (isJsonMode()) {
|
|
@@ -2547,7 +2496,7 @@ keysCommand.command("list").description("List all API keys").option("--org <orgI
|
|
|
2547
2496
|
});
|
|
2548
2497
|
keysCommand.command("revoke").description("Revoke an API key").argument("<id>", "API key ID to revoke").action(async (id) => {
|
|
2549
2498
|
const { url, apiKey } = requireRemote();
|
|
2550
|
-
const client = new
|
|
2499
|
+
const client = new RemoteClient(url, apiKey);
|
|
2551
2500
|
try {
|
|
2552
2501
|
await client.revokeApiKey(id);
|
|
2553
2502
|
logger.info(`API key ${id.slice(0, 8)}... revoked successfully.`);
|
|
@@ -2559,14 +2508,13 @@ keysCommand.command("revoke").description("Revoke an API key").argument("<id>",
|
|
|
2559
2508
|
|
|
2560
2509
|
// src/commands/auth.ts
|
|
2561
2510
|
import { Command as Command21 } from "commander";
|
|
2562
|
-
import { loadConfig as loadConfig18, isInitialized as isInitialized13 } from "unforgit-config";
|
|
2563
2511
|
var authCommand = new Command21("auth").description("Check authentication status for remote server and APIs");
|
|
2564
2512
|
authCommand.command("status").description("Check authentication status").action(async () => {
|
|
2565
|
-
if (!
|
|
2513
|
+
if (!isInitialized()) {
|
|
2566
2514
|
logger.fatal("not an unforgit repository");
|
|
2567
2515
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2568
2516
|
}
|
|
2569
|
-
const config =
|
|
2517
|
+
const config = loadConfig();
|
|
2570
2518
|
logger.info("Authentication status:");
|
|
2571
2519
|
logger.info(` Remote URL: ${config.remote.url || "(not configured)"}`);
|
|
2572
2520
|
logger.info(` Org ID: ${config.remote.orgId || "(not configured)"}`);
|
|
@@ -2612,14 +2560,13 @@ authCommand.command("status").description("Check authentication status").action(
|
|
|
2612
2560
|
|
|
2613
2561
|
// src/commands/config.ts
|
|
2614
2562
|
import { Command as Command22 } from "commander";
|
|
2615
|
-
import { isInitialized as isInitialized14, loadConfig as loadConfig19, saveConfig as saveConfig3 } from "unforgit-config";
|
|
2616
2563
|
var configCommand = new Command22("config").description("Manage unforgit configuration");
|
|
2617
2564
|
configCommand.command("list").alias("ls").description("List all configuration values").action(() => {
|
|
2618
|
-
if (!
|
|
2565
|
+
if (!isInitialized()) {
|
|
2619
2566
|
logger.fatal("not an unforgit repository");
|
|
2620
2567
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2621
2568
|
}
|
|
2622
|
-
const config =
|
|
2569
|
+
const config = loadConfig();
|
|
2623
2570
|
if (isJsonMode()) {
|
|
2624
2571
|
outputJson(config);
|
|
2625
2572
|
return;
|
|
@@ -2647,11 +2594,11 @@ configCommand.command("list").alias("ls").description("List all configuration va
|
|
|
2647
2594
|
logger.info(`lifecycle.maintenance.debounceMs = ${config.lifecycle?.maintenance?.debounceMs ?? "(not set)"}`);
|
|
2648
2595
|
});
|
|
2649
2596
|
configCommand.command("get").description("Get a configuration value").argument("<key>", "Configuration key (e.g., remote.url, defaults.memoryType)").action((key) => {
|
|
2650
|
-
if (!
|
|
2597
|
+
if (!isInitialized()) {
|
|
2651
2598
|
logger.fatal("not an unforgit repository");
|
|
2652
2599
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2653
2600
|
}
|
|
2654
|
-
const config =
|
|
2601
|
+
const config = loadConfig();
|
|
2655
2602
|
const value = getConfigValue(config, key);
|
|
2656
2603
|
if (value === void 0) {
|
|
2657
2604
|
logger.fatal(`key '${key}' not found`);
|
|
@@ -2695,7 +2642,7 @@ Valid keys: ${VALID_CONFIG_KEYS.join(", ")}
|
|
|
2695
2642
|
Examples:
|
|
2696
2643
|
unforgit config set remote.url http://my-server:3737
|
|
2697
2644
|
unforgit config set defaults.memoryType semantic`).action((key, value) => {
|
|
2698
|
-
if (!
|
|
2645
|
+
if (!isInitialized()) {
|
|
2699
2646
|
logger.fatal("not an unforgit repository");
|
|
2700
2647
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2701
2648
|
}
|
|
@@ -2705,19 +2652,19 @@ Examples:
|
|
|
2705
2652
|
);
|
|
2706
2653
|
process.exit(EXIT_ERROR);
|
|
2707
2654
|
}
|
|
2708
|
-
const config =
|
|
2655
|
+
const config = loadConfig();
|
|
2709
2656
|
setConfigValue(config, key, value);
|
|
2710
|
-
|
|
2657
|
+
saveConfig(config);
|
|
2711
2658
|
logger.info(`${key} = ${value}`);
|
|
2712
2659
|
});
|
|
2713
2660
|
configCommand.command("unset").description("Remove a configuration value").argument("<key>", "Configuration key to remove").action((key) => {
|
|
2714
|
-
if (!
|
|
2661
|
+
if (!isInitialized()) {
|
|
2715
2662
|
logger.fatal("not an unforgit repository");
|
|
2716
2663
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2717
2664
|
}
|
|
2718
|
-
const config =
|
|
2665
|
+
const config = loadConfig();
|
|
2719
2666
|
unsetConfigValue(config, key);
|
|
2720
|
-
|
|
2667
|
+
saveConfig(config);
|
|
2721
2668
|
logger.info(`Unset ${key}`);
|
|
2722
2669
|
});
|
|
2723
2670
|
function getConfigValue(config, key) {
|
|
@@ -2775,26 +2722,22 @@ function coerceConfigValue(value) {
|
|
|
2775
2722
|
|
|
2776
2723
|
// src/commands/embeddings.ts
|
|
2777
2724
|
import { Command as Command23 } from "commander";
|
|
2778
|
-
import { LocalStore as LocalStore17 } from "unforgit-db";
|
|
2779
|
-
import { loadConfig as loadConfig20, getDbPath as getDbPath17, isInitialized as isInitialized15 } from "unforgit-config";
|
|
2780
|
-
import { generateEmbedding } from "unforgit-core";
|
|
2781
|
-
import { parsePositiveInt as parsePositiveInt6 } from "unforgit-config";
|
|
2782
2725
|
var cwd3 = process.cwd();
|
|
2783
2726
|
var embeddingsCommand = new Command23("embeddings").description("Manage memory embeddings for semantic search");
|
|
2784
2727
|
embeddingsCommand.command("backfill").description("Generate embeddings for memories that don't have them").option("--batch-size <n>", "Number of memories to process in parallel", "5").option("--delay <ms>", "Delay between batches (ms)", "500").option("--dry-run", "Show what would be done without making changes").option("--model <model>", "OpenAI embedding model", "text-embedding-3-small").action(async (opts) => {
|
|
2785
|
-
if (!
|
|
2728
|
+
if (!isInitialized(cwd3)) {
|
|
2786
2729
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
2787
2730
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2788
2731
|
}
|
|
2789
|
-
const config =
|
|
2732
|
+
const config = loadConfig(cwd3);
|
|
2790
2733
|
const apiKey = process.env.OPENAI_API_KEY;
|
|
2791
2734
|
if (!apiKey && !opts.dryRun) {
|
|
2792
2735
|
logger.error("OpenAI API key not set.");
|
|
2793
2736
|
logger.error("Set the OPENAI_API_KEY environment variable.");
|
|
2794
2737
|
process.exit(EXIT_ERROR);
|
|
2795
2738
|
}
|
|
2796
|
-
const dbPath =
|
|
2797
|
-
const store = new
|
|
2739
|
+
const dbPath = getDbPath(cwd3);
|
|
2740
|
+
const store = new LocalStore(dbPath);
|
|
2798
2741
|
const orgId = config.remote.orgId || "local";
|
|
2799
2742
|
const repoId = config.remote.repoId || "local";
|
|
2800
2743
|
try {
|
|
@@ -2821,8 +2764,8 @@ embeddingsCommand.command("backfill").description("Generate embeddings for memor
|
|
|
2821
2764
|
}
|
|
2822
2765
|
return;
|
|
2823
2766
|
}
|
|
2824
|
-
const batchSize =
|
|
2825
|
-
const delay =
|
|
2767
|
+
const batchSize = parsePositiveInt(opts.batchSize, "batch-size");
|
|
2768
|
+
const delay = parsePositiveInt(opts.delay, "delay");
|
|
2826
2769
|
let processed = 0;
|
|
2827
2770
|
let errors = 0;
|
|
2828
2771
|
logger.info(`
|
|
@@ -2858,13 +2801,13 @@ Backfill complete:`);
|
|
|
2858
2801
|
}
|
|
2859
2802
|
});
|
|
2860
2803
|
embeddingsCommand.command("stats").description("Show embedding statistics").action(async () => {
|
|
2861
|
-
if (!
|
|
2804
|
+
if (!isInitialized(cwd3)) {
|
|
2862
2805
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
2863
2806
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2864
2807
|
}
|
|
2865
|
-
const config =
|
|
2866
|
-
const dbPath =
|
|
2867
|
-
const store = new
|
|
2808
|
+
const config = loadConfig(cwd3);
|
|
2809
|
+
const dbPath = getDbPath(cwd3);
|
|
2810
|
+
const store = new LocalStore(dbPath);
|
|
2868
2811
|
const orgId = config.remote.orgId || "local";
|
|
2869
2812
|
const repoId = config.remote.repoId || "local";
|
|
2870
2813
|
try {
|
|
@@ -2889,7 +2832,7 @@ Run 'unforgit embeddings backfill' to generate missing embeddings.`);
|
|
|
2889
2832
|
}
|
|
2890
2833
|
});
|
|
2891
2834
|
embeddingsCommand.command("clear").description("Remove all embeddings (requires regeneration)").option("--yes", "Skip confirmation").action(async (opts) => {
|
|
2892
|
-
if (!
|
|
2835
|
+
if (!isInitialized(cwd3)) {
|
|
2893
2836
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
2894
2837
|
process.exit(EXIT_CONFIG_ERROR);
|
|
2895
2838
|
}
|
|
@@ -2898,8 +2841,8 @@ embeddingsCommand.command("clear").description("Remove all embeddings (requires
|
|
|
2898
2841
|
logger.info("Use --yes to confirm.");
|
|
2899
2842
|
return;
|
|
2900
2843
|
}
|
|
2901
|
-
const dbPath =
|
|
2902
|
-
const store = new
|
|
2844
|
+
const dbPath = getDbPath(cwd3);
|
|
2845
|
+
const store = new LocalStore(dbPath);
|
|
2903
2846
|
try {
|
|
2904
2847
|
const deleted = store.clearEmbeddings();
|
|
2905
2848
|
logger.info(`All embeddings cleared (${deleted} removed).`);
|
|
@@ -2910,15 +2853,11 @@ embeddingsCommand.command("clear").description("Remove all embeddings (requires
|
|
|
2910
2853
|
|
|
2911
2854
|
// src/commands/reset.ts
|
|
2912
2855
|
import { Command as Command25 } from "commander";
|
|
2913
|
-
import { loadConfig as loadConfig21, getDbPath as getDbPath19 } from "unforgit-config";
|
|
2914
|
-
import { LocalStore as LocalStore18 } from "unforgit-db";
|
|
2915
|
-
import { RemoteClient as RemoteClient12 } from "unforgit-config";
|
|
2916
2856
|
|
|
2917
2857
|
// src/commands/backups.ts
|
|
2918
2858
|
import fs4 from "fs";
|
|
2919
2859
|
import path3 from "path";
|
|
2920
2860
|
import { Command as Command24 } from "commander";
|
|
2921
|
-
import { getDbPath as getDbPath18 } from "unforgit-config";
|
|
2922
2861
|
function formatBackupTimestamp(date) {
|
|
2923
2862
|
return date.toISOString().replace(/[-:]/g, "").replace("T", "-").replace(/\.\d{3}Z$/, "");
|
|
2924
2863
|
}
|
|
@@ -2997,7 +2936,7 @@ function restoreLocalResetBackup(dbPath, backupName, now = /* @__PURE__ */ new D
|
|
|
2997
2936
|
}
|
|
2998
2937
|
var backupsCommand = new Command24("backups").description("List and restore local reset backups");
|
|
2999
2938
|
backupsCommand.command("list").description("List local backups created before destructive resets/restores").action(() => {
|
|
3000
|
-
const backups = listLocalResetBackups(
|
|
2939
|
+
const backups = listLocalResetBackups(getDbPath());
|
|
3001
2940
|
if (backups.length === 0) {
|
|
3002
2941
|
logger.info("No local reset backups found.");
|
|
3003
2942
|
return;
|
|
@@ -3017,7 +2956,7 @@ backupsCommand.command("restore").argument("<name>", "Backup directory name, for
|
|
|
3017
2956
|
}
|
|
3018
2957
|
}
|
|
3019
2958
|
try {
|
|
3020
|
-
const result = restoreLocalResetBackup(
|
|
2959
|
+
const result = restoreLocalResetBackup(getDbPath(), name);
|
|
3021
2960
|
logger.info(`Restored local database from ${result.restoredFrom.name}`);
|
|
3022
2961
|
if (result.safetyBackup) {
|
|
3023
2962
|
logger.info(`Previous local database safety backup: ${result.safetyBackup.dir}`);
|
|
@@ -3053,9 +2992,9 @@ Examples:
|
|
|
3053
2992
|
return;
|
|
3054
2993
|
}
|
|
3055
2994
|
}
|
|
3056
|
-
const config =
|
|
2995
|
+
const config = loadConfig();
|
|
3057
2996
|
if (resetLocal) {
|
|
3058
|
-
const dbPath =
|
|
2997
|
+
const dbPath = getDbPath();
|
|
3059
2998
|
if (opts.backup !== false) {
|
|
3060
2999
|
try {
|
|
3061
3000
|
const backup = createLocalResetBackup(dbPath);
|
|
@@ -3069,7 +3008,7 @@ Examples:
|
|
|
3069
3008
|
process.exit(EXIT_ERROR);
|
|
3070
3009
|
}
|
|
3071
3010
|
}
|
|
3072
|
-
const store = new
|
|
3011
|
+
const store = new LocalStore(dbPath);
|
|
3073
3012
|
try {
|
|
3074
3013
|
const result = store.resetAll();
|
|
3075
3014
|
logger.info(`Local reset complete:`);
|
|
@@ -3089,7 +3028,7 @@ Examples:
|
|
|
3089
3028
|
logger.info("No remote configured, skipping remote reset.");
|
|
3090
3029
|
return;
|
|
3091
3030
|
}
|
|
3092
|
-
const client = new
|
|
3031
|
+
const client = new RemoteClient(config.remote.url);
|
|
3093
3032
|
const orgId = config.remote.orgId;
|
|
3094
3033
|
const repoId = config.remote.repoId;
|
|
3095
3034
|
if (!orgId || !repoId) {
|
|
@@ -3208,14 +3147,11 @@ Examples:
|
|
|
3208
3147
|
|
|
3209
3148
|
// src/commands/doctor.ts
|
|
3210
3149
|
import { Command as Command27 } from "commander";
|
|
3211
|
-
import { loadConfig as loadConfig22, getDbPath as getDbPath20, isInitialized as isInitialized16, getConfigPath as getConfigPath2 } from "unforgit-config";
|
|
3212
|
-
import { LocalStore as LocalStore19 } from "unforgit-db";
|
|
3213
|
-
import { RemoteClient as RemoteClient13 } from "unforgit-config";
|
|
3214
3150
|
import fs6 from "fs";
|
|
3215
3151
|
import YAML from "yaml";
|
|
3216
3152
|
var doctorCommand = new Command27("doctor").description("Check system health and diagnose common issues").action(async () => {
|
|
3217
3153
|
const results = [];
|
|
3218
|
-
if (!
|
|
3154
|
+
if (!isInitialized()) {
|
|
3219
3155
|
results.push({
|
|
3220
3156
|
check: "initialization",
|
|
3221
3157
|
status: "error",
|
|
@@ -3230,9 +3166,9 @@ var doctorCommand = new Command27("doctor").description("Check system health and
|
|
|
3230
3166
|
process.exit(EXIT_CONFIG_ERROR);
|
|
3231
3167
|
}
|
|
3232
3168
|
results.push({ check: "initialization", status: "ok", message: "Repository initialized" });
|
|
3233
|
-
const configPath =
|
|
3169
|
+
const configPath = getConfigPath();
|
|
3234
3170
|
try {
|
|
3235
|
-
const config =
|
|
3171
|
+
const config = loadConfig();
|
|
3236
3172
|
results.push({ check: "config", status: "ok", message: `Valid config at ${configPath}` });
|
|
3237
3173
|
const deprecatedConfigKeys = findDeprecatedConfigKeys(configPath);
|
|
3238
3174
|
if (deprecatedConfigKeys.length > 0) {
|
|
@@ -3263,7 +3199,7 @@ var doctorCommand = new Command27("doctor").description("Check system health and
|
|
|
3263
3199
|
results.push({ check: "config-permissions", status: "warn", message: "Could not check config file permissions" });
|
|
3264
3200
|
}
|
|
3265
3201
|
}
|
|
3266
|
-
const store = new
|
|
3202
|
+
const store = new LocalStore(getDbPath());
|
|
3267
3203
|
try {
|
|
3268
3204
|
const orgId = config.remote.orgId || "local";
|
|
3269
3205
|
const repoId = config.remote.repoId || "local";
|
|
@@ -3342,7 +3278,7 @@ var doctorCommand = new Command27("doctor").description("Check system health and
|
|
|
3342
3278
|
if (res.ok) {
|
|
3343
3279
|
results.push({ check: "remote", status: "ok", message: `Server reachable at ${config.remote.url}` });
|
|
3344
3280
|
if (apiKey) {
|
|
3345
|
-
const client = new
|
|
3281
|
+
const client = new RemoteClient(config.remote.url);
|
|
3346
3282
|
try {
|
|
3347
3283
|
await client.listApiKeys();
|
|
3348
3284
|
results.push({ check: "remote-auth", status: "ok", message: "API key is valid" });
|
|
@@ -3629,10 +3565,6 @@ Examples:
|
|
|
3629
3565
|
|
|
3630
3566
|
// src/commands/curate.ts
|
|
3631
3567
|
import { Command as Command29 } from "commander";
|
|
3632
|
-
import { getDbPath as getDbPath21, isInitialized as isInitialized17, loadConfig as loadConfig23 } from "unforgit-config";
|
|
3633
|
-
import { LocalStore as LocalStore20 } from "unforgit-db";
|
|
3634
|
-
import { RemoteClient as RemoteClient14 } from "unforgit-config";
|
|
3635
|
-
import { runLocalLifecycleMaintenance } from "unforgit-core";
|
|
3636
3568
|
function formatCandidatePreview2(candidate) {
|
|
3637
3569
|
const lines = [
|
|
3638
3570
|
`Group: ${candidate.reason}`,
|
|
@@ -3650,11 +3582,11 @@ Examples:
|
|
|
3650
3582
|
unforgit curate
|
|
3651
3583
|
unforgit curate --execute
|
|
3652
3584
|
unforgit curate --remote --execute --model gpt-5.4`).action(async (opts) => {
|
|
3653
|
-
if (!
|
|
3585
|
+
if (!isInitialized()) {
|
|
3654
3586
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
3655
3587
|
process.exit(EXIT_CONFIG_ERROR);
|
|
3656
3588
|
}
|
|
3657
|
-
const config =
|
|
3589
|
+
const config = loadConfig();
|
|
3658
3590
|
const orgId = config.remote.orgId || "local";
|
|
3659
3591
|
const repoId = config.remote.repoId || "local";
|
|
3660
3592
|
const dryRun = opts.execute ? false : void 0;
|
|
@@ -3665,7 +3597,7 @@ Examples:
|
|
|
3665
3597
|
dryRun,
|
|
3666
3598
|
model: opts.model,
|
|
3667
3599
|
preserveOriginals: opts.preserve !== false
|
|
3668
|
-
}) : await runLocalCurate(
|
|
3600
|
+
}) : await runLocalCurate(getDbPath(), orgId, repoId, {
|
|
3669
3601
|
dryRun,
|
|
3670
3602
|
model: opts.model,
|
|
3671
3603
|
preserveOriginals: opts.preserve !== false,
|
|
@@ -3726,7 +3658,7 @@ Examples:
|
|
|
3726
3658
|
}
|
|
3727
3659
|
});
|
|
3728
3660
|
async function runLocalCurate(dbPath, orgId, repoId, options) {
|
|
3729
|
-
const store = new
|
|
3661
|
+
const store = new LocalStore(dbPath);
|
|
3730
3662
|
try {
|
|
3731
3663
|
return await runLocalLifecycleMaintenance(store, orgId, repoId, options);
|
|
3732
3664
|
} finally {
|
|
@@ -3737,26 +3669,23 @@ async function runRemoteCurate(remoteUrl, options) {
|
|
|
3737
3669
|
if (!remoteUrl) {
|
|
3738
3670
|
throw new Error("Remote URL not configured. Update unforgit.yaml or omit --remote.");
|
|
3739
3671
|
}
|
|
3740
|
-
const client = new
|
|
3672
|
+
const client = new RemoteClient(remoteUrl);
|
|
3741
3673
|
return client.runLifecycle(options);
|
|
3742
3674
|
}
|
|
3743
3675
|
|
|
3744
3676
|
// src/commands/suggestions.ts
|
|
3745
3677
|
import { Command as Command30 } from "commander";
|
|
3746
|
-
import { getDbPath as getDbPath22, isInitialized as isInitialized18, loadConfig as loadConfig24 } from "unforgit-config";
|
|
3747
|
-
import { LocalStore as LocalStore21 } from "unforgit-db";
|
|
3748
|
-
import { generateSuggestions, persistReviewableSuggestions } from "unforgit-core";
|
|
3749
3678
|
function openStore() {
|
|
3750
|
-
if (!
|
|
3679
|
+
if (!isInitialized()) {
|
|
3751
3680
|
logger.error("Unforgit not initialized. Run 'unforgit init' first.");
|
|
3752
3681
|
process.exit(EXIT_CONFIG_ERROR);
|
|
3753
3682
|
}
|
|
3754
|
-
const config =
|
|
3683
|
+
const config = loadConfig();
|
|
3755
3684
|
return {
|
|
3756
3685
|
config,
|
|
3757
3686
|
orgId: config.remote.orgId || "local",
|
|
3758
3687
|
repoId: config.remote.repoId || "local",
|
|
3759
|
-
store: new
|
|
3688
|
+
store: new LocalStore(getDbPath())
|
|
3760
3689
|
};
|
|
3761
3690
|
}
|
|
3762
3691
|
function formatSuggestionLine(suggestion) {
|