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