@fabersep/memory 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/dist/src/bm25.d.ts +2 -0
- package/dist/src/bm25.js +6 -0
- package/dist/src/cli.js +158 -13
- package/dist/src/config.js +1 -0
- package/dist/src/doctor.js +98 -2
- package/dist/src/hygiene.js +10 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/mcp.d.ts +1 -0
- package/dist/src/mcp.js +27 -2
- package/dist/src/personal-remote.d.ts +48 -0
- package/dist/src/personal-remote.js +282 -0
- package/dist/src/proposals.d.ts +2 -0
- package/dist/src/proposals.js +11 -0
- package/dist/src/sync.js +3 -0
- package/dist/src/types.d.ts +8 -0
- package/dist/src/types.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@fabersep/memory`. Versions follow [Semantic Versioning](https://semver.org/).
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.3.0 (2026-11-29)
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Personal remote (feature 03):** `remote add <url>` / `remote remove`, `setup --remote`, `init --remote`. A public GitHub or GitLab repository is refused unless `--allow-public`.
|
|
9
|
+
- **Push after approve:** `pushMode` `ask` (default) / `auto` / `never` (`config set-push-mode`); `push` command; `--yes` on `review` and `approve` skips the question.
|
|
10
|
+
- **Unpushed reminder** in `status`, the first MCP answer of a session, and a new `doctor` check "Personal remote" (also `WARN` when the personal repo has no remote).
|
|
11
|
+
- **Two writing machines:** approve pulls with rebase before committing; a rejected push is rebased and retried once; a conflict keeps the local commit and is reported.
|
|
12
|
+
- **`memory_propose` says what the similarity check found:** a staged `create` carries `similar` (entries between `similarityHintFloor`, default `0.25`, and the threshold) and a short note when one is related.
|
|
13
|
+
- **Hygiene fix hints:** a blocked machine path says `write ~/ or $HOME instead of /Users/<name>/`; a blocked secret says to store a pointer instead.
|
|
14
|
+
- **`doctor` warns about a second memory index** loaded outside the managed block in `~/.claude/CLAUDE.md` or `~/.gemini/GEMINI.md`.
|
|
15
|
+
- **Read-only hosts:** `setup --read-only <url> [path]` for servers and CI; proposals, approvals and pushes are refused there.
|
|
16
|
+
|
|
17
|
+
## 0.2.1 (2026-11-28)
|
|
6
18
|
|
|
7
19
|
### Fixed
|
|
8
20
|
- Docs pointed to `~/.faber/memory-state/` for config and state; the real location is `~/.config/faber-memory/`.
|
package/dist/src/bm25.d.ts
CHANGED
|
@@ -24,3 +24,5 @@ export interface NearDuplicateMatch {
|
|
|
24
24
|
}
|
|
25
25
|
export declare function computeSimilarity(textA: string, textB: string): number;
|
|
26
26
|
export declare function findNearDuplicates(candidateSummary: string, candidateBody: string, activeEntries: MemoryEntry[], pendingProposals: Proposal[], threshold: number): NearDuplicateMatch[];
|
|
27
|
+
/** Entries scoring in [floor, threshold): related but not blocking (01 FR-04 amendment). */
|
|
28
|
+
export declare function findRelatedEntries(candidateSummary: string, candidateBody: string, activeEntries: MemoryEntry[], pendingProposals: Proposal[], floor: number, threshold: number, limit?: number): NearDuplicateMatch[];
|
package/dist/src/bm25.js
CHANGED
|
@@ -181,3 +181,9 @@ export function findNearDuplicates(candidateSummary, candidateBody, activeEntrie
|
|
|
181
181
|
matches.sort((a, b) => b.similarity - a.similarity);
|
|
182
182
|
return matches;
|
|
183
183
|
}
|
|
184
|
+
/** Entries scoring in [floor, threshold): related but not blocking (01 FR-04 amendment). */
|
|
185
|
+
export function findRelatedEntries(candidateSummary, candidateBody, activeEntries, pendingProposals, floor, threshold, limit = 3) {
|
|
186
|
+
return findNearDuplicates(candidateSummary, candidateBody, activeEntries, pendingProposals, floor)
|
|
187
|
+
.filter((m) => m.similarity < threshold)
|
|
188
|
+
.slice(0, limit);
|
|
189
|
+
}
|
package/dist/src/cli.js
CHANGED
|
@@ -13,13 +13,14 @@ import { approveProposalsBatch, findProposalById, reconcileAwaitingCommitProposa
|
|
|
13
13
|
import { buildShareableBenchmark, computeStats, formatShareableMarkdown, formatStatsReport, validateDaysArg, } from './stats.js';
|
|
14
14
|
import { loadAllScopes, resolveProjectRoot } from './store.js';
|
|
15
15
|
import { syncAllRoots } from './sync.js';
|
|
16
|
+
import { addPersonalRemote, DEFAULT_READ_ONLY_PATH, getAheadInfo, getPushMode, getUnpushedReminder, isReadOnlyRoot, pushPersonalRoot, READ_ONLY_MESSAGE, removePersonalRemote, } from './personal-remote.js';
|
|
16
17
|
import { getPackageVersion } from './version.js';
|
|
17
18
|
import { c, hr, inferErrorAnchor, normalizeTeamUrl, troubleshootingLink, } from './ui.js';
|
|
18
19
|
// Flags that never take a value, so `init --preview ~/notes` keeps ~/notes as a positional.
|
|
19
20
|
const BOOLEAN_FLAGS = new Set([
|
|
20
21
|
'apply', 'undo', 'preview', 'dry-run', 'check', 'json', 'strict', 'cache', 'share', 'yes',
|
|
21
22
|
'all', 'approve', 'approve-all', 'split-headings', 'normalize-paths', 'project-hint',
|
|
22
|
-
'include-personal-repo', 'help',
|
|
23
|
+
'include-personal-repo', 'help', 'allow-public',
|
|
23
24
|
]);
|
|
24
25
|
function parseFlags(args) {
|
|
25
26
|
const positional = [];
|
|
@@ -67,6 +68,36 @@ function printErrorWithHelp(errMsg) {
|
|
|
67
68
|
console.error(c.dim(` Details: ${troubleshootingLink(anchor)}`));
|
|
68
69
|
}
|
|
69
70
|
}
|
|
71
|
+
// Feature 03 FR-02: an interactive terminal (tests set FABER_MEMORY_ASSUME_TTY=1 to drive the prompt).
|
|
72
|
+
function isInteractive() {
|
|
73
|
+
return Boolean(process.stdin.isTTY) || process.env.FABER_MEMORY_ASSUME_TTY === '1';
|
|
74
|
+
}
|
|
75
|
+
// After an approve committed to the personal root: push per pushMode, or say what is left.
|
|
76
|
+
async function afterPersonalCommit(config, homeDir, ask) {
|
|
77
|
+
const root = config.roots.personal;
|
|
78
|
+
if (!root || isReadOnlyRoot(root))
|
|
79
|
+
return;
|
|
80
|
+
const info = getAheadInfo(root.path);
|
|
81
|
+
if (!info.hasRemote || info.ahead === 0)
|
|
82
|
+
return;
|
|
83
|
+
const mode = getPushMode(root);
|
|
84
|
+
if (mode === 'never')
|
|
85
|
+
return;
|
|
86
|
+
let push = mode === 'auto';
|
|
87
|
+
if (mode === 'ask' && ask) {
|
|
88
|
+
const answer = await ask(`Push ${info.ahead} commit(s) to origin now? [Y/n] `);
|
|
89
|
+
push = answer !== null && ['', 'y', 'yes'].includes(answer.trim().toLowerCase());
|
|
90
|
+
}
|
|
91
|
+
if (push) {
|
|
92
|
+
const res = await pushPersonalRoot(root, homeDir);
|
|
93
|
+
console.log(res.ok ? c.green(res.message) : c.red(res.message));
|
|
94
|
+
if (res.ok)
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const reminder = getUnpushedReminder(config, homeDir);
|
|
98
|
+
if (reminder)
|
|
99
|
+
console.log(c.yellow(reminder));
|
|
100
|
+
}
|
|
70
101
|
function createPersonalRoot(config, personalPath, homeDir) {
|
|
71
102
|
const existed = isGitRepo(personalPath);
|
|
72
103
|
gitInitSoloRepo(personalPath, 'main');
|
|
@@ -114,6 +145,28 @@ async function main() {
|
|
|
114
145
|
}
|
|
115
146
|
if (cmd === 'setup') {
|
|
116
147
|
const config = loadConfig(homeDir);
|
|
148
|
+
if (flags['read-only']) {
|
|
149
|
+
const url = String(flags['read-only']);
|
|
150
|
+
if (url === 'true') {
|
|
151
|
+
console.error('Usage: faber-memory setup --read-only <git-url> [path]');
|
|
152
|
+
return 1;
|
|
153
|
+
}
|
|
154
|
+
const dest = typeof flags.path === 'string' ? path.resolve(flags.path) : positional[0] ? path.resolve(positional[0]) : DEFAULT_READ_ONLY_PATH;
|
|
155
|
+
const branch = isGitRepo(dest) ? getDefaultBranch(dest) : gitCloneTeamRepo(url, dest);
|
|
156
|
+
config.roots.personal = {
|
|
157
|
+
uuid: config.roots.personal?.uuid || generateUuid(),
|
|
158
|
+
path: dest,
|
|
159
|
+
scope: 'personal',
|
|
160
|
+
defaultBranch: branch,
|
|
161
|
+
readOnly: true,
|
|
162
|
+
};
|
|
163
|
+
saveConfig(config, homeDir);
|
|
164
|
+
const res = await syncAllRoots(config, { homeDir, recompile: true });
|
|
165
|
+
for (const e of res.errors)
|
|
166
|
+
printErrorWithHelp(e);
|
|
167
|
+
console.log(c.green(`Configured a read-only personal root at ${dest} (branch: ${branch}). This host only pulls; propose changes on a writing machine.`));
|
|
168
|
+
return res.ok ? 0 : 1;
|
|
169
|
+
}
|
|
117
170
|
if (flags.team) {
|
|
118
171
|
const rawUrl = String(flags.team);
|
|
119
172
|
const { url, normalized } = normalizeTeamUrl(rawUrl);
|
|
@@ -147,8 +200,56 @@ async function main() {
|
|
|
147
200
|
createPersonalRoot(config, personalPath, homeDir);
|
|
148
201
|
console.log(c.green(`Initialized personal memory root at ${personalPath} (uuid: ${config.roots.personal.uuid})`));
|
|
149
202
|
printUncommittedNotesHint(personalPath);
|
|
203
|
+
if (typeof flags.remote === 'string') {
|
|
204
|
+
const res = await addPersonalRemote(config, flags.remote, { allowPublic: Boolean(flags['allow-public']), homeDir });
|
|
205
|
+
for (const m of res.messages)
|
|
206
|
+
console.log(m);
|
|
207
|
+
for (const e of res.errors)
|
|
208
|
+
printErrorWithHelp(e);
|
|
209
|
+
saveConfig(config, homeDir);
|
|
210
|
+
return res.ok ? 0 : 1;
|
|
211
|
+
}
|
|
150
212
|
return 0;
|
|
151
213
|
}
|
|
214
|
+
if (cmd === 'remote') {
|
|
215
|
+
const config = loadConfig(homeDir);
|
|
216
|
+
const sub = positional[0];
|
|
217
|
+
if (sub === 'add' && positional[1]) {
|
|
218
|
+
const res = await addPersonalRemote(config, positional[1], { allowPublic: Boolean(flags['allow-public']), homeDir });
|
|
219
|
+
for (const m of res.messages)
|
|
220
|
+
console.log(m);
|
|
221
|
+
for (const e of res.errors)
|
|
222
|
+
printErrorWithHelp(e);
|
|
223
|
+
if (res.ok)
|
|
224
|
+
saveConfig(config, homeDir);
|
|
225
|
+
return res.ok ? 0 : 1;
|
|
226
|
+
}
|
|
227
|
+
if (sub === 'remove') {
|
|
228
|
+
const res = removePersonalRemote(config, homeDir);
|
|
229
|
+
for (const m of res.messages)
|
|
230
|
+
console.log(m);
|
|
231
|
+
for (const e of res.errors)
|
|
232
|
+
printErrorWithHelp(e);
|
|
233
|
+
return res.ok ? 0 : 1;
|
|
234
|
+
}
|
|
235
|
+
console.error('Usage: faber-memory remote add <git-url> [--allow-public] | faber-memory remote remove');
|
|
236
|
+
return 1;
|
|
237
|
+
}
|
|
238
|
+
if (cmd === 'push') {
|
|
239
|
+
const config = loadConfig(homeDir);
|
|
240
|
+
const root = config.roots.personal;
|
|
241
|
+
if (!root) {
|
|
242
|
+
printErrorWithHelp('Personal memory root is not configured.');
|
|
243
|
+
return 1;
|
|
244
|
+
}
|
|
245
|
+
const res = await pushPersonalRoot(root, homeDir);
|
|
246
|
+
if (res.ok) {
|
|
247
|
+
console.log(c.green(res.message));
|
|
248
|
+
return 0;
|
|
249
|
+
}
|
|
250
|
+
printErrorWithHelp(res.message);
|
|
251
|
+
return 1;
|
|
252
|
+
}
|
|
152
253
|
if (cmd === 'config') {
|
|
153
254
|
const sub = positional[0];
|
|
154
255
|
const config = loadConfig(homeDir);
|
|
@@ -180,6 +281,17 @@ async function main() {
|
|
|
180
281
|
console.log(c.green(`Updated team submit mode to ${mode}`));
|
|
181
282
|
return 0;
|
|
182
283
|
}
|
|
284
|
+
if (sub === 'set-push-mode') {
|
|
285
|
+
const mode = positional[1];
|
|
286
|
+
if (!['ask', 'auto', 'never'].includes(mode) || !config.roots.personal) {
|
|
287
|
+
console.error('Usage: faber-memory config set-push-mode <ask|auto|never> (needs a personal root)');
|
|
288
|
+
return 1;
|
|
289
|
+
}
|
|
290
|
+
config.roots.personal.pushMode = mode;
|
|
291
|
+
saveConfig(config, homeDir);
|
|
292
|
+
console.log(c.green(`Updated personal push mode to ${mode}`));
|
|
293
|
+
return 0;
|
|
294
|
+
}
|
|
183
295
|
if (sub === 'unset') {
|
|
184
296
|
const scope = positional[1];
|
|
185
297
|
if (!scope || !['personal', 'team'].includes(scope)) {
|
|
@@ -243,6 +355,10 @@ async function main() {
|
|
|
243
355
|
}
|
|
244
356
|
if (cmd === 'approve') {
|
|
245
357
|
const config = loadConfig(homeDir);
|
|
358
|
+
if (isReadOnlyRoot(config.roots.personal)) {
|
|
359
|
+
printErrorWithHelp(READ_ONLY_MESSAGE);
|
|
360
|
+
return 1;
|
|
361
|
+
}
|
|
246
362
|
const ids = positional;
|
|
247
363
|
if (ids.length === 0) {
|
|
248
364
|
console.error('Usage: faber-memory approve <proposal-id> [...]');
|
|
@@ -269,6 +385,10 @@ async function main() {
|
|
|
269
385
|
printErrorWithHelp(e);
|
|
270
386
|
return 1;
|
|
271
387
|
}
|
|
388
|
+
if (outcome.personalCommitted) {
|
|
389
|
+
const ask = isInteractive() && !flags.yes ? (q) => promptLine(q) : undefined;
|
|
390
|
+
await afterPersonalCommit(config, homeDir, ask);
|
|
391
|
+
}
|
|
272
392
|
return 0;
|
|
273
393
|
}
|
|
274
394
|
if (cmd === 'reject') {
|
|
@@ -344,32 +464,44 @@ async function main() {
|
|
|
344
464
|
}
|
|
345
465
|
if (cmd === 'review') {
|
|
346
466
|
const config = loadConfig(homeDir);
|
|
467
|
+
if (isReadOnlyRoot(config.roots.personal)) {
|
|
468
|
+
printErrorWithHelp(READ_ONLY_MESSAGE);
|
|
469
|
+
return 1;
|
|
470
|
+
}
|
|
347
471
|
const proposals = reconcileAwaitingCommitProposals(homeDir).filter((p) => p.status !== 'awaiting_commit');
|
|
348
472
|
if (proposals.length === 0) {
|
|
349
473
|
console.log('No pending proposals to review.');
|
|
350
474
|
return 0;
|
|
351
475
|
}
|
|
352
476
|
const decisions = new Map();
|
|
477
|
+
// One readline for the whole review, so the push question (feature 03 FR-02) reads the same input.
|
|
478
|
+
let rl;
|
|
479
|
+
let askPush;
|
|
353
480
|
if (flags['approve-all']) {
|
|
354
481
|
for (const p of proposals)
|
|
355
482
|
decisions.set(p.id, 'approve');
|
|
356
483
|
}
|
|
357
484
|
else {
|
|
358
|
-
const
|
|
485
|
+
const reviewRl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
486
|
+
rl = reviewRl;
|
|
359
487
|
let interrupted = false;
|
|
360
|
-
|
|
488
|
+
reviewRl.on('SIGINT', () => {
|
|
361
489
|
interrupted = true;
|
|
362
490
|
console.log(c.yellow('\nInterrupted — saving decisions made so far...'));
|
|
363
|
-
|
|
491
|
+
reviewRl.close();
|
|
364
492
|
});
|
|
365
|
-
const lineIter =
|
|
493
|
+
const lineIter = reviewRl[Symbol.asyncIterator]();
|
|
366
494
|
const ask = async (q) => {
|
|
495
|
+
if (interrupted)
|
|
496
|
+
return null;
|
|
367
497
|
process.stdout.write(q);
|
|
368
498
|
const next = await lineIter.next();
|
|
369
499
|
if (next.done)
|
|
370
500
|
return null;
|
|
371
501
|
return String(next.value);
|
|
372
502
|
};
|
|
503
|
+
if (isInteractive() && !flags.yes)
|
|
504
|
+
askPush = ask;
|
|
373
505
|
const MAX_PREVIEW_LINES = 12;
|
|
374
506
|
try {
|
|
375
507
|
let idx = 0;
|
|
@@ -472,8 +604,9 @@ async function main() {
|
|
|
472
604
|
}
|
|
473
605
|
}
|
|
474
606
|
}
|
|
475
|
-
|
|
476
|
-
|
|
607
|
+
catch (err) {
|
|
608
|
+
reviewRl.close();
|
|
609
|
+
throw err;
|
|
477
610
|
}
|
|
478
611
|
}
|
|
479
612
|
const toApprove = [];
|
|
@@ -498,7 +631,11 @@ async function main() {
|
|
|
498
631
|
printErrorWithHelp(e);
|
|
499
632
|
exitCode = 1;
|
|
500
633
|
}
|
|
634
|
+
else if (outcome.personalCommitted) {
|
|
635
|
+
await afterPersonalCommit(config, homeDir, askPush);
|
|
636
|
+
}
|
|
501
637
|
}
|
|
638
|
+
rl?.close();
|
|
502
639
|
const remainingCount = proposals.length - toApprove.length - toReject.length;
|
|
503
640
|
console.log(`\n${c.bold('Review summary:')} ` +
|
|
504
641
|
`${c.green(`${toApprove.length} approved`)} | ` +
|
|
@@ -519,7 +656,12 @@ async function main() {
|
|
|
519
656
|
console.log(` Team root: ${config.roots.team.path} (HEAD: ${getHeadSha(config.roots.team.path)?.slice(0, 8) || 'none'}, mode: ${config.roots.team.submitMode || 'auto'})`);
|
|
520
657
|
}
|
|
521
658
|
if (config.roots.personal) {
|
|
522
|
-
|
|
659
|
+
const pr = config.roots.personal;
|
|
660
|
+
const mode = pr.readOnly ? 'read-only host' : `push: ${getPushMode(pr)}`;
|
|
661
|
+
console.log(` Personal root: ${pr.path} (HEAD: ${getHeadSha(pr.path)?.slice(0, 8) || 'none'}, ${mode})`);
|
|
662
|
+
const reminder = getUnpushedReminder(config, homeDir);
|
|
663
|
+
if (reminder)
|
|
664
|
+
console.log(c.yellow(` ${reminder}`));
|
|
523
665
|
}
|
|
524
666
|
console.log(` Project root: ${projectRes.projectRoot || 'none'} (source: ${projectRes.source})`);
|
|
525
667
|
if (loaded.uncommittedWarnings.length > 0) {
|
|
@@ -746,16 +888,19 @@ function printHelp() {
|
|
|
746
888
|
console.log(`@fabersep/memory (faber-memory)
|
|
747
889
|
|
|
748
890
|
Commands:
|
|
749
|
-
setup [path] [--team <git-url|org/repo> --path <dir> --submit-mode auto|pr]
|
|
750
|
-
|
|
751
|
-
|
|
891
|
+
setup [path] [--remote <git-url>] [--team <git-url|org/repo> --path <dir> --submit-mode auto|pr]
|
|
892
|
+
setup --read-only <git-url> [path] (a host that only reads, e.g. a server)
|
|
893
|
+
remote add <git-url> [--allow-public] | remote remove
|
|
894
|
+
push
|
|
895
|
+
config [set-path <personal|team> <new-path> | set-submit-mode <auto|pr> | set-push-mode <ask|auto|never> | unset <personal|team>]
|
|
896
|
+
init [folder] [--remote <git-url>] [--preview | --undo] [--engine claude-code,antigravity,claude-desktop,cursor,codex] [--project-hint]
|
|
752
897
|
compile [--check] [--repo <dir>]
|
|
753
898
|
sync [--timeout <ms>]
|
|
754
899
|
status
|
|
755
900
|
stats [--days 1..90] [--json] [--cache] [--engine claude-code|antigravity|all] [--log-dir <path>] [--share]
|
|
756
901
|
doctor [--json] [--strict]
|
|
757
|
-
review [--approve-all]
|
|
758
|
-
approve <proposal-id> [...] [--mode auto|pr]
|
|
902
|
+
review [--approve-all] [--yes]
|
|
903
|
+
approve <proposal-id> [...] [--mode auto|pr] [--yes]
|
|
759
904
|
reject <proposal-id> | reject --all [--yes]
|
|
760
905
|
reset [--include-personal-repo] [--yes]
|
|
761
906
|
import --from <markdown-dir|claude-memory|agents-md|cursor-rules> <path> [--scope personal|team|project] [--split-headings] [--normalize-paths] [--approve]
|
package/dist/src/config.js
CHANGED
|
@@ -66,6 +66,7 @@ export function loadConfig(homeDir = getHomeDir()) {
|
|
|
66
66
|
similarityThreshold: typeof raw.similarityThreshold === 'number'
|
|
67
67
|
? raw.similarityThreshold
|
|
68
68
|
: DEFAULT_SIMILARITY_THRESHOLD,
|
|
69
|
+
...(typeof raw.similarityHintFloor === 'number' ? { similarityHintFloor: raw.similarityHintFloor } : {}),
|
|
69
70
|
roots: raw.roots || {},
|
|
70
71
|
};
|
|
71
72
|
}
|
package/dist/src/doctor.js
CHANGED
|
@@ -2,10 +2,11 @@ import * as crypto from 'node:crypto';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import { estimateTokens, renderGlobalL0 } from './compiler.js';
|
|
4
4
|
import { getCompiledL0Path, getConfigPath, getHomeDir, loadConfig } from './config.js';
|
|
5
|
-
import { getHeadSha, getUncommittedFiles, isGitRepo, readHeadFile } from './git.js';
|
|
5
|
+
import { getDefaultBranch, getHeadSha, getUncommittedFiles, gitSync, hasRemote, isGitRepo, readHeadFile } from './git.js';
|
|
6
6
|
import { scanHygiene } from './hygiene.js';
|
|
7
7
|
import { BLOCK_END, BLOCK_START, getEngineSpecs, getUserHome } from './init.js';
|
|
8
8
|
import { readMetrics } from './metrics.js';
|
|
9
|
+
import { getAheadInfo, getUnpushedReminder, readPersonalRemoteState } from './personal-remote.js';
|
|
9
10
|
import { listAllProposals } from './proposals.js';
|
|
10
11
|
import { L0_CHURN_WARN_THRESHOLD } from './stats.js';
|
|
11
12
|
import { loadScopeFromHead, PROJECT_MEMORY_REL_DIR, resolveProjectRoot } from './store.js';
|
|
@@ -37,6 +38,31 @@ function hasFaberMemoryMcpEntry(filePath) {
|
|
|
37
38
|
return false;
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
// 02 FR-06 amendment: memory indexes an engine file loads outside the managed block.
|
|
42
|
+
function extraMemoryIndexes(filePath, engine) {
|
|
43
|
+
if (!fs.existsSync(filePath))
|
|
44
|
+
return [];
|
|
45
|
+
let content;
|
|
46
|
+
try {
|
|
47
|
+
content = fs.readFileSync(filePath, 'utf8');
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const start = content.indexOf(BLOCK_START);
|
|
53
|
+
const end = start === -1 ? -1 : content.indexOf(BLOCK_END, start + BLOCK_START.length);
|
|
54
|
+
const outside = start !== -1 && end !== -1 ? content.slice(0, start) + content.slice(end + BLOCK_END.length) : content;
|
|
55
|
+
const found = new Set();
|
|
56
|
+
if (engine === 'claude-code') {
|
|
57
|
+
for (const m of outside.matchAll(/^\s*@(\S*MEMORY\.md)\s*$/gim))
|
|
58
|
+
found.add(m[1]);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
for (const m of outside.matchAll(/(?:^|[\s`'"(])([~$\w./\\-]*[\/\\]MEMORY\.md)\b/gim))
|
|
62
|
+
found.add(m[1]);
|
|
63
|
+
}
|
|
64
|
+
return [...found];
|
|
65
|
+
}
|
|
40
66
|
export function runDoctor(options = {}) {
|
|
41
67
|
const homeDir = options.homeDir || getHomeDir();
|
|
42
68
|
const userHome = options.userHome || getUserHome();
|
|
@@ -265,6 +291,7 @@ export function runDoctor(options = {}) {
|
|
|
265
291
|
const specs = getEngineSpecs();
|
|
266
292
|
const wiredEngines = [];
|
|
267
293
|
const mismatchedEngines = [];
|
|
294
|
+
const extraIndexEngines = [];
|
|
268
295
|
for (const engineName of ['claude-code', 'claude-desktop', 'antigravity', 'cursor']) {
|
|
269
296
|
const spec = specs[engineName];
|
|
270
297
|
const mcpWired = spec.mcpConfigFile ? hasFaberMemoryMcpEntry(spec.mcpConfigFile(userHome)) : false;
|
|
@@ -296,6 +323,13 @@ export function runDoctor(options = {}) {
|
|
|
296
323
|
}
|
|
297
324
|
}
|
|
298
325
|
}
|
|
326
|
+
if (spec.instructionFile && (engineName === 'claude-code' || engineName === 'antigravity')) {
|
|
327
|
+
const extras = extraMemoryIndexes(spec.instructionFile(userHome), engineName);
|
|
328
|
+
if (extras.length > 0) {
|
|
329
|
+
extraIndexEngines.push(engineName);
|
|
330
|
+
wiringDetails.push(`${engineName}: loads another memory index outside the managed block: ${extras.join(', ')}.`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
299
333
|
if (instrMismatch) {
|
|
300
334
|
mismatchedEngines.push(engineName);
|
|
301
335
|
wiringDetails.push(`${engineName}: managed L0 block path does not match ${l0Path}.`);
|
|
@@ -309,9 +343,19 @@ export function runDoctor(options = {}) {
|
|
|
309
343
|
wiredEngines.push(`${engineName} (${parts.join('+')})`);
|
|
310
344
|
}
|
|
311
345
|
}
|
|
346
|
+
if (extraIndexEngines.length > 0) {
|
|
347
|
+
wiringStatus = 'WARN';
|
|
348
|
+
wiringHint =
|
|
349
|
+
'Remove the other memory index lines so only the faber-memory managed block loads memory.';
|
|
350
|
+
}
|
|
312
351
|
if (mismatchedEngines.length > 0) {
|
|
313
352
|
wiringStatus = 'WARN';
|
|
314
|
-
wiringHint = 'Run "faber-memory init" to update engine pointers to the current compiled MEMORY.md path.'
|
|
353
|
+
wiringHint = [wiringHint, 'Run "faber-memory init" to update engine pointers to the current compiled MEMORY.md path.']
|
|
354
|
+
.filter(Boolean)
|
|
355
|
+
.join(' ');
|
|
356
|
+
}
|
|
357
|
+
else if (extraIndexEngines.length > 0) {
|
|
358
|
+
// already WARN with its hint
|
|
315
359
|
}
|
|
316
360
|
else if (wiredEngines.length === 0) {
|
|
317
361
|
wiringStatus = 'WARN';
|
|
@@ -408,6 +452,58 @@ export function runDoctor(options = {}) {
|
|
|
408
452
|
details: stabilityDetails,
|
|
409
453
|
...(stabilityHint ? { hint: stabilityHint } : {}),
|
|
410
454
|
});
|
|
455
|
+
// 7. Personal remote (feature 03 FR-03, FR-05); only when a personal root is configured.
|
|
456
|
+
const personal = config?.roots.personal;
|
|
457
|
+
if (personal && isGitRepo(personal.path)) {
|
|
458
|
+
const details = [];
|
|
459
|
+
let status = 'PASS';
|
|
460
|
+
let hint;
|
|
461
|
+
const warn = (detail, fix) => {
|
|
462
|
+
status = 'WARN';
|
|
463
|
+
details.push(detail);
|
|
464
|
+
hint = hint ? `${hint} ${fix}` : fix;
|
|
465
|
+
};
|
|
466
|
+
if (personal.readOnly) {
|
|
467
|
+
details.push('Read-only host: this machine only pulls the personal memory.');
|
|
468
|
+
if (!hasRemote(personal.path))
|
|
469
|
+
warn('The read-only clone has no origin.', 'Re-run faber-memory setup --read-only <url>.');
|
|
470
|
+
if (getUncommittedFiles(personal.path).length > 0) {
|
|
471
|
+
warn('The read-only clone has local edits; sync will not pull it.', `Discard the edits in ${personal.path}.`);
|
|
472
|
+
}
|
|
473
|
+
const branch = gitSync(['--no-optional-locks', '-C', personal.path, 'rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim();
|
|
474
|
+
const expected = personal.defaultBranch || getDefaultBranch(personal.path);
|
|
475
|
+
if (branch && branch !== expected) {
|
|
476
|
+
warn(`The read-only clone is on ${branch}, not ${expected}.`, `Run git -C ${personal.path} checkout ${expected}.`);
|
|
477
|
+
}
|
|
478
|
+
if (getAheadInfo(personal.path).ahead > 0) {
|
|
479
|
+
warn('The read-only clone has local commits.', 'Reset it to origin; a read-only host never commits.');
|
|
480
|
+
}
|
|
481
|
+
const lastPull = readPersonalRemoteState(homeDir).lastPullAt;
|
|
482
|
+
const ageDays = lastPull ? Math.floor((nowMs - Date.parse(lastPull)) / 86400000) : null;
|
|
483
|
+
if (ageDays === null) {
|
|
484
|
+
warn('No successful pull recorded yet.', 'Run faber-memory sync.');
|
|
485
|
+
}
|
|
486
|
+
else if (ageDays > 7) {
|
|
487
|
+
warn(`Last successful pull was ${ageDays} days ago.`, 'Run faber-memory sync and check the host can reach origin.');
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
details.push(`Last successful pull ${ageDays} day(s) ago.`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else if (!hasRemote(personal.path)) {
|
|
494
|
+
warn('The personal root has no remote; approved memory stays on this machine.', 'Run faber-memory remote add <url> with a private repository.');
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
const reminder = config ? getUnpushedReminder(config, homeDir) : null;
|
|
498
|
+
if (reminder) {
|
|
499
|
+
warn(reminder, 'Run faber-memory push.');
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
details.push('The personal root is in step with origin.');
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
checks.push({ id: 'personal-remote', name: 'Personal remote', status, details, ...(hint ? { hint } : {}) });
|
|
506
|
+
}
|
|
411
507
|
const hasFail = checks.some((ch) => ch.status === 'FAIL');
|
|
412
508
|
const hasWarn = checks.some((ch) => ch.status === 'WARN');
|
|
413
509
|
const overall = hasFail ? 'FAIL' : hasWarn ? 'WARN' : 'PASS';
|
package/dist/src/hygiene.js
CHANGED
|
@@ -1,51 +1,60 @@
|
|
|
1
|
+
const SECRET_FIX = 'remove the value; store a pointer to where it lives instead';
|
|
1
2
|
const RULES = [
|
|
2
3
|
{
|
|
3
4
|
category: 'secret',
|
|
4
5
|
pattern: 'private-key',
|
|
5
6
|
regex: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/,
|
|
6
7
|
label: 'Private key header detected',
|
|
8
|
+
fix: SECRET_FIX,
|
|
7
9
|
},
|
|
8
10
|
{
|
|
9
11
|
category: 'secret',
|
|
10
12
|
pattern: 'jwt',
|
|
11
13
|
regex: /\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/,
|
|
12
14
|
label: 'JWT token detected',
|
|
15
|
+
fix: SECRET_FIX,
|
|
13
16
|
},
|
|
14
17
|
{
|
|
15
18
|
category: 'secret',
|
|
16
19
|
pattern: 'bearer-token',
|
|
17
20
|
regex: /\bBearer\s+[A-Za-z0-9._~+/-]{12,}/i,
|
|
18
21
|
label: 'Bearer token detected',
|
|
22
|
+
fix: SECRET_FIX,
|
|
19
23
|
},
|
|
20
24
|
{
|
|
21
25
|
category: 'secret',
|
|
22
26
|
pattern: 'api-key-prefix',
|
|
23
27
|
regex: /\b(?:sk-[A-Za-z0-9_-]{16,}|sk_live_[A-Za-z0-9]{12,}|ghp_[A-Za-z0-9]{20,}|gho_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,}|xox[baprs]-[A-Za-z0-9-]{10,})\b/,
|
|
24
28
|
label: 'Known API key prefix detected',
|
|
29
|
+
fix: SECRET_FIX,
|
|
25
30
|
},
|
|
26
31
|
{
|
|
27
32
|
category: 'secret',
|
|
28
33
|
pattern: 'credential-assignment',
|
|
29
34
|
regex: /\b(?:api[_-]?key|secret[_-]?key|access[_-]?token|auth[_-]?token|client[_-]?secret|password|passwd)\s*[:=]\s*["']?[A-Za-z0-9._~+/=-]{12,}["']?/i,
|
|
30
35
|
label: 'Credential assignment detected',
|
|
36
|
+
fix: SECRET_FIX,
|
|
31
37
|
},
|
|
32
38
|
{
|
|
33
39
|
category: 'machine-path',
|
|
34
40
|
pattern: 'macos-user-path',
|
|
35
41
|
regex: /\/Users\/[A-Za-z0-9._-]+\//,
|
|
36
42
|
label: 'Machine-specific macOS home path detected',
|
|
43
|
+
fix: 'write ~/ or $HOME instead of /Users/<name>/',
|
|
37
44
|
},
|
|
38
45
|
{
|
|
39
46
|
category: 'machine-path',
|
|
40
47
|
pattern: 'linux-user-path',
|
|
41
48
|
regex: /\/home\/[A-Za-z0-9._-]+\//,
|
|
42
49
|
label: 'Machine-specific Linux home path detected',
|
|
50
|
+
fix: 'write ~/ or $HOME instead of /home/<name>/',
|
|
43
51
|
},
|
|
44
52
|
{
|
|
45
53
|
category: 'machine-path',
|
|
46
54
|
pattern: 'windows-user-path',
|
|
47
55
|
regex: /\b[A-Za-z]:\\Users\\[A-Za-z0-9._-]+\\/,
|
|
48
56
|
label: 'Machine-specific Windows home path detected',
|
|
57
|
+
fix: 'write ~\\ or %USERPROFILE% instead of C:\\Users\\<name>\\',
|
|
49
58
|
},
|
|
50
59
|
];
|
|
51
60
|
export function scanHygiene(content) {
|
|
@@ -64,7 +73,7 @@ export function scanHygiene(content) {
|
|
|
64
73
|
line: i + 1,
|
|
65
74
|
category: rule.category,
|
|
66
75
|
pattern: rule.pattern,
|
|
67
|
-
message: `${rule.label} (${rule.category}/${rule.pattern}) at line ${i + 1}`,
|
|
76
|
+
message: `${rule.label} (${rule.category}/${rule.pattern}) at line ${i + 1}; fix: ${rule.fix}`,
|
|
68
77
|
redactedSnippet,
|
|
69
78
|
});
|
|
70
79
|
break;
|
package/dist/src/index.d.ts
CHANGED
package/dist/src/index.js
CHANGED
package/dist/src/mcp.d.ts
CHANGED
package/dist/src/mcp.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import * as readline from 'node:readline';
|
|
3
|
-
import { BM25Index, findNearDuplicates } from './bm25.js';
|
|
3
|
+
import { BM25Index, findNearDuplicates, findRelatedEntries } from './bm25.js';
|
|
4
4
|
import { getCompiledL0Path, getHomeDir, loadConfig } from './config.js';
|
|
5
5
|
import { compileGlobalL0 } from './compiler.js';
|
|
6
6
|
import { getHeadSha } from './git.js';
|
|
7
7
|
import { formatHygieneErrors, scanHygiene } from './hygiene.js';
|
|
8
|
+
import { getUnpushedReminder, isReadOnlyRoot, READ_ONLY_MESSAGE } from './personal-remote.js';
|
|
8
9
|
import { appendMetric, MAX_GET_FOUND_IDS } from './metrics.js';
|
|
9
10
|
import { createProposal, reconcileAwaitingCommitProposals } from './proposals.js';
|
|
10
11
|
import { loadAllScopes, resolveProjectRoot } from './store.js';
|
|
11
12
|
import { syncAllRoots } from './sync.js';
|
|
12
13
|
import { getPackageVersion } from './version.js';
|
|
13
|
-
import { VALID_TYPES, } from './types.js';
|
|
14
|
+
import { DEFAULT_SIMILARITY_HINT_FLOOR, VALID_TYPES, } from './types.js';
|
|
14
15
|
export const MCP_TOOLS = [
|
|
15
16
|
{
|
|
16
17
|
name: 'memory_search',
|
|
@@ -67,6 +68,7 @@ export class FaberMemoryMcpServer {
|
|
|
67
68
|
lastHeadSignature = '';
|
|
68
69
|
lastLoaded = null;
|
|
69
70
|
startupWarnings = [];
|
|
71
|
+
unpushedReminderShown = false;
|
|
70
72
|
startupPullPromise = null;
|
|
71
73
|
constructor(options = {}) {
|
|
72
74
|
this.homeDir = options.homeDir || getHomeDir();
|
|
@@ -125,6 +127,13 @@ export class FaberMemoryMcpServer {
|
|
|
125
127
|
drainWarnings(loaded) {
|
|
126
128
|
const warnings = [...this.startupWarnings, ...loaded.uncommittedWarnings, ...loaded.shadowWarnings];
|
|
127
129
|
this.startupWarnings = [];
|
|
130
|
+
if (!this.unpushedReminderShown) {
|
|
131
|
+
// Feature 03 FR-03: once per server process, never in L0 or the tool list.
|
|
132
|
+
this.unpushedReminderShown = true;
|
|
133
|
+
const reminder = getUnpushedReminder(loadConfig(this.homeDir), this.homeDir);
|
|
134
|
+
if (reminder)
|
|
135
|
+
warnings.push(reminder);
|
|
136
|
+
}
|
|
128
137
|
return warnings;
|
|
129
138
|
}
|
|
130
139
|
listTools() {
|
|
@@ -270,6 +279,10 @@ export class FaberMemoryMcpServer {
|
|
|
270
279
|
recordPropose('validation_error');
|
|
271
280
|
return errorResponse('body is required.');
|
|
272
281
|
}
|
|
282
|
+
if (scope === 'personal' && isReadOnlyRoot(config.roots.personal)) {
|
|
283
|
+
recordPropose('validation_error');
|
|
284
|
+
return errorResponse(READ_ONLY_MESSAGE);
|
|
285
|
+
}
|
|
273
286
|
// Validate target_id for update / supersede (AC-08c1, AC-08c2)
|
|
274
287
|
if (action === 'update' || action === 'supersede') {
|
|
275
288
|
if (!targetId) {
|
|
@@ -329,6 +342,10 @@ export class FaberMemoryMcpServer {
|
|
|
329
342
|
projectRootPath: scope === 'project' ? loaded.projectResolution.projectRoot : undefined,
|
|
330
343
|
}, this.homeDir);
|
|
331
344
|
recordPropose('staged');
|
|
345
|
+
// 01 FR-04 amendment: say what the similarity check found, without blocking.
|
|
346
|
+
const similar = action === 'create'
|
|
347
|
+
? findRelatedEntries(summary, body, loaded.activeEntries, reconcileAwaitingCommitProposals(this.homeDir).filter((p) => p.id !== proposal.id), config.similarityHintFloor ?? DEFAULT_SIMILARITY_HINT_FLOOR, config.similarityThreshold).map((m) => ({ id: m.id, scope: m.scope, summary: m.summary, pending: m.pending, similarity: m.similarity }))
|
|
348
|
+
: [];
|
|
332
349
|
this.lastHeadSignature = '';
|
|
333
350
|
const warnings = this.drainWarnings(loaded);
|
|
334
351
|
return {
|
|
@@ -340,6 +357,14 @@ export class FaberMemoryMcpServer {
|
|
|
340
357
|
proposal_id: proposal.id,
|
|
341
358
|
entry_id: proposal.entryId,
|
|
342
359
|
scope: proposal.scope,
|
|
360
|
+
...(action === 'create'
|
|
361
|
+
? {
|
|
362
|
+
similar,
|
|
363
|
+
...(similar.length > 0
|
|
364
|
+
? { similar_note: 'a related entry exists; prefer update if it is the same fact' }
|
|
365
|
+
: {}),
|
|
366
|
+
}
|
|
367
|
+
: {}),
|
|
343
368
|
warnings,
|
|
344
369
|
}, null, 2),
|
|
345
370
|
},
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { PushMode, RootConfig, UserConfig } from './types.js';
|
|
2
|
+
export declare const READ_ONLY_MESSAGE = "read-only host: propose changes on a writing machine";
|
|
3
|
+
export declare const DEFAULT_READ_ONLY_PATH: string;
|
|
4
|
+
export declare function getPushMode(root: RootConfig | undefined): PushMode;
|
|
5
|
+
export declare function isReadOnlyRoot(root: RootConfig | undefined): boolean;
|
|
6
|
+
interface PersonalRemoteState {
|
|
7
|
+
pushFailed?: {
|
|
8
|
+
reason: string;
|
|
9
|
+
at: string;
|
|
10
|
+
};
|
|
11
|
+
lastPullAt?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function readPersonalRemoteState(homeDir?: string): PersonalRemoteState;
|
|
14
|
+
export declare function recordPushFailure(reason: string, homeDir?: string): void;
|
|
15
|
+
export declare function clearPushFailure(homeDir?: string): void;
|
|
16
|
+
export declare function recordSuccessfulPull(homeDir?: string, at?: Date): void;
|
|
17
|
+
export interface AheadInfo {
|
|
18
|
+
hasRemote: boolean;
|
|
19
|
+
ahead: number;
|
|
20
|
+
oldest?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function getAheadInfo(repoDir: string): AheadInfo;
|
|
23
|
+
/** The one-line unpushed reminder (`FR-03`), or null when the personal root is in step. */
|
|
24
|
+
export declare function getUnpushedReminder(config: UserConfig, homeDir?: string): string | null;
|
|
25
|
+
export declare function pullRebaseBeforeCommit(root: RootConfig): Promise<string | null>;
|
|
26
|
+
export interface PushResult {
|
|
27
|
+
ok: boolean;
|
|
28
|
+
pushed: number;
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function pushPersonalRoot(root: RootConfig, homeDir?: string): Promise<PushResult>;
|
|
32
|
+
export type Visibility = 'public' | 'private' | 'unknown';
|
|
33
|
+
export declare function parseHostedRepo(url: string): {
|
|
34
|
+
host: 'github.com' | 'gitlab.com';
|
|
35
|
+
repo: string;
|
|
36
|
+
} | null;
|
|
37
|
+
export declare function checkRepoVisibility(url: string, timeoutMs?: number): Promise<Visibility>;
|
|
38
|
+
export interface RemoteAddResult {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
messages: string[];
|
|
41
|
+
errors: string[];
|
|
42
|
+
}
|
|
43
|
+
export declare function addPersonalRemote(config: UserConfig, url: string, options?: {
|
|
44
|
+
allowPublic?: boolean;
|
|
45
|
+
homeDir?: string;
|
|
46
|
+
}): Promise<RemoteAddResult>;
|
|
47
|
+
export declare function removePersonalRemote(config: UserConfig, homeDir?: string): RemoteAddResult;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { getStateDir, getHomeDir } from './config.js';
|
|
5
|
+
import { getDefaultBranch, gitAsync, gitSync, hasRemote, isDirty } from './git.js';
|
|
6
|
+
// Feature 03: personal remote, push after approve, unpushed reminder, many hosts, read-only hosts.
|
|
7
|
+
export const READ_ONLY_MESSAGE = 'read-only host: propose changes on a writing machine';
|
|
8
|
+
export const DEFAULT_READ_ONLY_PATH = path.join(os.homedir(), 'faber-memory');
|
|
9
|
+
const PUSH_TIMEOUT_MS = 15000;
|
|
10
|
+
const PULL_TIMEOUT_MS = 5000;
|
|
11
|
+
export function getPushMode(root) {
|
|
12
|
+
return root?.pushMode === 'auto' || root?.pushMode === 'never' ? root.pushMode : 'ask';
|
|
13
|
+
}
|
|
14
|
+
export function isReadOnlyRoot(root) {
|
|
15
|
+
return Boolean(root?.readOnly);
|
|
16
|
+
}
|
|
17
|
+
function statePath(homeDir) {
|
|
18
|
+
return path.join(getStateDir(homeDir), 'personal-remote.json');
|
|
19
|
+
}
|
|
20
|
+
export function readPersonalRemoteState(homeDir = getHomeDir()) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(fs.readFileSync(statePath(homeDir), 'utf8'));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function writePersonalRemoteState(state, homeDir) {
|
|
29
|
+
try {
|
|
30
|
+
fs.mkdirSync(getStateDir(homeDir), { recursive: true });
|
|
31
|
+
fs.writeFileSync(statePath(homeDir), `${JSON.stringify(state, null, 2)}\n`, 'utf8');
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// State is advisory; never fail a command for it.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function recordPushFailure(reason, homeDir = getHomeDir()) {
|
|
38
|
+
const state = readPersonalRemoteState(homeDir);
|
|
39
|
+
state.pushFailed = { reason, at: new Date().toISOString() };
|
|
40
|
+
writePersonalRemoteState(state, homeDir);
|
|
41
|
+
}
|
|
42
|
+
export function clearPushFailure(homeDir = getHomeDir()) {
|
|
43
|
+
const state = readPersonalRemoteState(homeDir);
|
|
44
|
+
if (!state.pushFailed)
|
|
45
|
+
return;
|
|
46
|
+
delete state.pushFailed;
|
|
47
|
+
writePersonalRemoteState(state, homeDir);
|
|
48
|
+
}
|
|
49
|
+
export function recordSuccessfulPull(homeDir = getHomeDir(), at = new Date()) {
|
|
50
|
+
const state = readPersonalRemoteState(homeDir);
|
|
51
|
+
state.lastPullAt = at.toISOString();
|
|
52
|
+
writePersonalRemoteState(state, homeDir);
|
|
53
|
+
}
|
|
54
|
+
function upstreamRef(repoDir) {
|
|
55
|
+
const up = gitSync(['-C', repoDir, 'rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}']);
|
|
56
|
+
if (up.ok && up.stdout.trim())
|
|
57
|
+
return up.stdout.trim();
|
|
58
|
+
const branch = gitSync(['-C', repoDir, 'rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim() || 'main';
|
|
59
|
+
const remoteBranch = `origin/${branch}`;
|
|
60
|
+
return gitSync(['-C', repoDir, 'rev-parse', '--verify', '--quiet', remoteBranch]).ok ? remoteBranch : null;
|
|
61
|
+
}
|
|
62
|
+
export function getAheadInfo(repoDir) {
|
|
63
|
+
if (!fs.existsSync(repoDir) || !hasRemote(repoDir))
|
|
64
|
+
return { hasRemote: false, ahead: 0 };
|
|
65
|
+
const upstream = upstreamRef(repoDir);
|
|
66
|
+
const range = upstream ? `${upstream}..HEAD` : 'HEAD';
|
|
67
|
+
const count = gitSync(['-C', repoDir, 'rev-list', '--count', range]);
|
|
68
|
+
const ahead = count.ok ? Number(count.stdout.trim()) || 0 : 0;
|
|
69
|
+
if (ahead === 0)
|
|
70
|
+
return { hasRemote: true, ahead: 0 };
|
|
71
|
+
const dates = gitSync(['-C', repoDir, 'log', '--reverse', '--format=%cs', range]);
|
|
72
|
+
const oldest = dates.ok ? dates.stdout.split('\n')[0]?.trim() : undefined;
|
|
73
|
+
return { hasRemote: true, ahead, oldest: oldest || undefined };
|
|
74
|
+
}
|
|
75
|
+
/** The one-line unpushed reminder (`FR-03`), or null when the personal root is in step. */
|
|
76
|
+
export function getUnpushedReminder(config, homeDir = getHomeDir()) {
|
|
77
|
+
const root = config.roots.personal;
|
|
78
|
+
if (!root || isReadOnlyRoot(root))
|
|
79
|
+
return null;
|
|
80
|
+
const info = getAheadInfo(root.path);
|
|
81
|
+
if (!info.hasRemote)
|
|
82
|
+
return null;
|
|
83
|
+
const state = readPersonalRemoteState(homeDir);
|
|
84
|
+
if (state.pushFailed && info.ahead > 0) {
|
|
85
|
+
return `personal memory: push failed (${state.pushFailed.reason}); ${info.ahead} commit(s) not pushed to origin; resolve it, then run faber-memory push`;
|
|
86
|
+
}
|
|
87
|
+
if (info.ahead === 0)
|
|
88
|
+
return null;
|
|
89
|
+
return `personal memory: ${info.ahead} commit(s) not pushed to origin (oldest ${info.oldest || 'unknown'}); run faber-memory push`;
|
|
90
|
+
}
|
|
91
|
+
// ---- pull before commit, push with one rebase retry (FR-04) ------------------------------
|
|
92
|
+
export async function pullRebaseBeforeCommit(root) {
|
|
93
|
+
if (!hasRemote(root.path) || isDirty(root.path))
|
|
94
|
+
return null;
|
|
95
|
+
if (!upstreamRef(root.path))
|
|
96
|
+
return null;
|
|
97
|
+
const res = await gitAsync(['-C', root.path, 'pull', '--rebase', '--quiet'], undefined, PULL_TIMEOUT_MS);
|
|
98
|
+
if (res.ok)
|
|
99
|
+
return null;
|
|
100
|
+
gitSync(['-C', root.path, 'rebase', '--abort']);
|
|
101
|
+
return `could not pull before commit (${res.timedOut ? 'timed out' : firstLine(res.stderr) || 'pull failed'}); committing locally`;
|
|
102
|
+
}
|
|
103
|
+
function firstLine(text) {
|
|
104
|
+
return (text
|
|
105
|
+
.split('\n')
|
|
106
|
+
.map((l) => l.replace(/^(error|fatal|hint|remote):\s*/i, '').trim())
|
|
107
|
+
.find((l) => l.length > 0) || '');
|
|
108
|
+
}
|
|
109
|
+
function conflictFiles(repoDir) {
|
|
110
|
+
const res = gitSync(['-C', repoDir, 'diff', '--name-only', '--diff-filter=U']);
|
|
111
|
+
return res.ok ? res.stdout.split('\n').map((s) => s.trim()).filter(Boolean) : [];
|
|
112
|
+
}
|
|
113
|
+
export async function pushPersonalRoot(root, homeDir = getHomeDir()) {
|
|
114
|
+
if (isReadOnlyRoot(root))
|
|
115
|
+
return { ok: false, pushed: 0, message: READ_ONLY_MESSAGE };
|
|
116
|
+
if (!hasRemote(root.path)) {
|
|
117
|
+
return { ok: false, pushed: 0, message: 'personal memory has no remote; run faber-memory remote add <url>' };
|
|
118
|
+
}
|
|
119
|
+
const before = getAheadInfo(root.path).ahead;
|
|
120
|
+
const branch = gitSync(['-C', root.path, 'rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim() || 'main';
|
|
121
|
+
const push = () => gitAsync(['-C', root.path, 'push', '-u', 'origin', `HEAD:${branch}`], undefined, PUSH_TIMEOUT_MS);
|
|
122
|
+
let res = await push();
|
|
123
|
+
if (!res.ok && /non-fast-forward|fetch first|rejected/i.test(res.stderr)) {
|
|
124
|
+
const fetch = await gitAsync(['-C', root.path, 'fetch', 'origin'], undefined, PUSH_TIMEOUT_MS);
|
|
125
|
+
if (fetch.ok) {
|
|
126
|
+
const rebase = gitSync(['-C', root.path, 'rebase', `origin/${branch}`]);
|
|
127
|
+
if (!rebase.ok) {
|
|
128
|
+
const files = conflictFiles(root.path);
|
|
129
|
+
gitSync(['-C', root.path, 'rebase', '--abort']);
|
|
130
|
+
const reason = files.length > 0 ? `conflict in ${files.join(', ')}` : firstLine(rebase.stderr) || 'rebase failed';
|
|
131
|
+
recordPushFailure(reason, homeDir);
|
|
132
|
+
return {
|
|
133
|
+
ok: false,
|
|
134
|
+
pushed: 0,
|
|
135
|
+
message: `Push failed: ${reason}. Your commit is kept locally. Merge origin/${branch} by hand in ${root.path}, then run faber-memory push.`,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
res = await push();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (!res.ok) {
|
|
142
|
+
const reason = res.timedOut ? 'push timed out' : firstLine(res.stderr) || 'push failed';
|
|
143
|
+
recordPushFailure(reason, homeDir);
|
|
144
|
+
return { ok: false, pushed: 0, message: `Push failed: ${reason}. Your commit is kept locally; run faber-memory push later.` };
|
|
145
|
+
}
|
|
146
|
+
clearPushFailure(homeDir);
|
|
147
|
+
return { ok: true, pushed: before, message: `Pushed ${before} commit(s) to origin.` };
|
|
148
|
+
}
|
|
149
|
+
export function parseHostedRepo(url) {
|
|
150
|
+
const m = /^(?:https?:\/\/(?:[^@/]+@)?|git@|ssh:\/\/git@)(github\.com|gitlab\.com)[:/](.+?)(?:\.git)?\/?$/i.exec(url.trim());
|
|
151
|
+
if (!m)
|
|
152
|
+
return null;
|
|
153
|
+
return { host: m[1].toLowerCase(), repo: m[2] };
|
|
154
|
+
}
|
|
155
|
+
export async function checkRepoVisibility(url, timeoutMs = 5000) {
|
|
156
|
+
const forced = process.env.FABER_MEMORY_VISIBILITY_OVERRIDE;
|
|
157
|
+
if (forced === 'public' || forced === 'private' || forced === 'unknown')
|
|
158
|
+
return forced;
|
|
159
|
+
const hosted = parseHostedRepo(url);
|
|
160
|
+
if (!hosted)
|
|
161
|
+
return 'unknown';
|
|
162
|
+
const api = hosted.host === 'github.com'
|
|
163
|
+
? `https://api.github.com/repos/${hosted.repo}`
|
|
164
|
+
: `https://gitlab.com/api/v4/projects/${encodeURIComponent(hosted.repo)}`;
|
|
165
|
+
try {
|
|
166
|
+
const ctrl = new AbortController();
|
|
167
|
+
const timer = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
168
|
+
const res = await fetch(api, { signal: ctrl.signal, headers: { 'User-Agent': 'faber-memory' } });
|
|
169
|
+
clearTimeout(timer);
|
|
170
|
+
if (res.status === 404)
|
|
171
|
+
return 'private';
|
|
172
|
+
if (!res.ok)
|
|
173
|
+
return 'unknown';
|
|
174
|
+
const body = (await res.json());
|
|
175
|
+
if (hosted.host === 'github.com')
|
|
176
|
+
return body.private === false ? 'public' : 'private';
|
|
177
|
+
return body.visibility === 'public' ? 'public' : 'private';
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return 'unknown';
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function remoteEntryFiles(repoDir, ref) {
|
|
184
|
+
const res = gitSync(['-C', repoDir, 'ls-tree', '-r', '--name-only', ref]);
|
|
185
|
+
if (!res.ok)
|
|
186
|
+
return [];
|
|
187
|
+
return res.stdout
|
|
188
|
+
.split('\n')
|
|
189
|
+
.map((s) => s.trim())
|
|
190
|
+
.filter((f) => f.toLowerCase().endsWith('.md') && path.basename(f).toLowerCase() !== 'readme.md');
|
|
191
|
+
}
|
|
192
|
+
export async function addPersonalRemote(config, url, options = {}) {
|
|
193
|
+
const homeDir = options.homeDir || getHomeDir();
|
|
194
|
+
const messages = [];
|
|
195
|
+
const root = config.roots.personal;
|
|
196
|
+
if (!root)
|
|
197
|
+
return { ok: false, messages, errors: ['Personal memory root is not configured; run faber-memory init first.'] };
|
|
198
|
+
if (isReadOnlyRoot(root))
|
|
199
|
+
return { ok: false, messages, errors: [READ_ONLY_MESSAGE] };
|
|
200
|
+
if (hasRemote(root.path)) {
|
|
201
|
+
return { ok: false, messages, errors: ['The personal root already has an origin; run faber-memory remote remove first.'] };
|
|
202
|
+
}
|
|
203
|
+
if (isDirty(root.path)) {
|
|
204
|
+
return { ok: false, messages, errors: [`The personal root has uncommitted edits in ${root.path}; commit or remove them first.`] };
|
|
205
|
+
}
|
|
206
|
+
const visibility = await checkRepoVisibility(url);
|
|
207
|
+
if (visibility === 'public' && !options.allowPublic) {
|
|
208
|
+
return {
|
|
209
|
+
ok: false,
|
|
210
|
+
messages,
|
|
211
|
+
errors: ['This repository is public: anyone can read your personal memory. Use a private repository, or pass --allow-public.'],
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
if (visibility === 'unknown')
|
|
215
|
+
messages.push('Repository visibility was not checked (unknown host or offline).');
|
|
216
|
+
const add = gitSync(['-C', root.path, 'remote', 'add', 'origin', url]);
|
|
217
|
+
if (!add.ok)
|
|
218
|
+
return { ok: false, messages, errors: [`git remote add failed: ${firstLine(add.stderr)}`] };
|
|
219
|
+
const undo = (error) => {
|
|
220
|
+
gitSync(['-C', root.path, 'remote', 'remove', 'origin']);
|
|
221
|
+
return { ok: false, messages, errors: [error] };
|
|
222
|
+
};
|
|
223
|
+
const fetch = await gitAsync(['-C', root.path, 'fetch', 'origin'], undefined, PUSH_TIMEOUT_MS);
|
|
224
|
+
if (!fetch.ok)
|
|
225
|
+
return undo(`git fetch failed: ${fetch.timedOut ? 'timed out' : firstLine(fetch.stderr)}`);
|
|
226
|
+
const branch = gitSync(['-C', root.path, 'rev-parse', '--abbrev-ref', 'HEAD']).stdout.trim() || 'main';
|
|
227
|
+
const remoteRef = `origin/${branch}`;
|
|
228
|
+
const remoteHasBranch = gitSync(['-C', root.path, 'rev-parse', '--verify', '--quiet', remoteRef]).ok;
|
|
229
|
+
if (remoteHasBranch) {
|
|
230
|
+
const base = gitSync(['-C', root.path, 'merge-base', 'HEAD', remoteRef]);
|
|
231
|
+
if (base.ok && base.stdout.trim()) {
|
|
232
|
+
const rebase = gitSync(['-C', root.path, 'rebase', remoteRef]);
|
|
233
|
+
if (!rebase.ok) {
|
|
234
|
+
gitSync(['-C', root.path, 'rebase', '--abort']);
|
|
235
|
+
return undo(`Your history and ${remoteRef} conflict; merge them by hand, then run faber-memory remote add again.`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const entries = remoteEntryFiles(root.path, remoteRef);
|
|
240
|
+
if (entries.length > 0) {
|
|
241
|
+
return undo(`The remote already holds ${entries.length} memory entr${entries.length === 1 ? 'y' : 'ies'} with an unrelated history. ` +
|
|
242
|
+
`To merge by hand: cd ${root.path} && git remote add origin ${url} && git fetch origin && ` +
|
|
243
|
+
`git merge --allow-unrelated-histories ${remoteRef}, resolve any conflicts, then git push -u origin ${branch}.`);
|
|
244
|
+
}
|
|
245
|
+
const merge = gitSync([
|
|
246
|
+
'-C', root.path, 'merge', '--allow-unrelated-histories', '--no-edit',
|
|
247
|
+
'-m', `chore: join the personal root with ${remoteRef}`, remoteRef,
|
|
248
|
+
]);
|
|
249
|
+
if (!merge.ok) {
|
|
250
|
+
gitSync(['-C', root.path, 'merge', '--abort']);
|
|
251
|
+
return undo(`Could not join the remote's history: ${firstLine(merge.stderr)}`);
|
|
252
|
+
}
|
|
253
|
+
messages.push(`Joined ${remoteRef} (it held no memory entries).`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
const push = await gitAsync(['-C', root.path, 'push', '-u', 'origin', `HEAD:${branch}`], undefined, PUSH_TIMEOUT_MS);
|
|
257
|
+
if (!push.ok) {
|
|
258
|
+
gitSync(['-C', root.path, 'config', `branch.${branch}.remote`, 'origin']);
|
|
259
|
+
gitSync(['-C', root.path, 'config', `branch.${branch}.merge`, `refs/heads/${branch}`]);
|
|
260
|
+
recordPushFailure(push.timedOut ? 'push timed out' : firstLine(push.stderr) || 'push failed', homeDir);
|
|
261
|
+
messages.push(`Linked origin, but the first push failed: ${firstLine(push.stderr) || 'timed out'}. Run faber-memory push later.`);
|
|
262
|
+
return { ok: true, messages, errors: [] };
|
|
263
|
+
}
|
|
264
|
+
clearPushFailure(homeDir);
|
|
265
|
+
root.defaultBranch = getDefaultBranch(root.path);
|
|
266
|
+
messages.push(`Linked the personal root to ${url} and pushed ${branch}.`);
|
|
267
|
+
return { ok: true, messages, errors: [] };
|
|
268
|
+
}
|
|
269
|
+
export function removePersonalRemote(config, homeDir = getHomeDir()) {
|
|
270
|
+
const root = config.roots.personal;
|
|
271
|
+
if (!root)
|
|
272
|
+
return { ok: false, messages: [], errors: ['Personal memory root is not configured.'] };
|
|
273
|
+
if (isReadOnlyRoot(root))
|
|
274
|
+
return { ok: false, messages: [], errors: [READ_ONLY_MESSAGE] };
|
|
275
|
+
if (!hasRemote(root.path))
|
|
276
|
+
return { ok: true, messages: ['The personal root has no origin.'], errors: [] };
|
|
277
|
+
const res = gitSync(['-C', root.path, 'remote', 'remove', 'origin']);
|
|
278
|
+
if (!res.ok)
|
|
279
|
+
return { ok: false, messages: [], errors: [`git remote remove failed: ${firstLine(res.stderr)}`] };
|
|
280
|
+
clearPushFailure(homeDir);
|
|
281
|
+
return { ok: true, messages: ['Removed origin from the personal root (files and history kept).'], errors: [] };
|
|
282
|
+
}
|
package/dist/src/proposals.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface ApproveOutcome {
|
|
|
27
27
|
errors: string[];
|
|
28
28
|
compareUrl?: string;
|
|
29
29
|
recompiledL0?: boolean;
|
|
30
|
+
/** True when approved entries were committed to the personal root (feature 03 push step). */
|
|
31
|
+
personalCommitted?: boolean;
|
|
30
32
|
}
|
|
31
33
|
export declare function approveProposalsBatch(config: UserConfig, proposals: Proposal[], options?: {
|
|
32
34
|
homeDir?: string;
|
package/dist/src/proposals.js
CHANGED
|
@@ -5,6 +5,7 @@ import { compileGlobalL0 } from './compiler.js';
|
|
|
5
5
|
import { parseMarkdownWithFrontmatter, serializeEntryMarkdown, slugify, } from './frontmatter.js';
|
|
6
6
|
import { buildCompareUrl, createThrowawayWorktree, getDefaultBranch, getRemoteUrl, gitCommitFiles, gitPullFfOnly, gitSync, isBranchProtectionRejection, readHeadFile, removeThrowawayWorktree, } from './git.js';
|
|
7
7
|
import { formatHygieneErrors, scanHygiene } from './hygiene.js';
|
|
8
|
+
import { isReadOnlyRoot, pullRebaseBeforeCommit, READ_ONLY_MESSAGE } from './personal-remote.js';
|
|
8
9
|
import { appendMetric } from './metrics.js';
|
|
9
10
|
import { PROJECT_MEMORY_REL_DIR } from './store.js';
|
|
10
11
|
export const CACHE_GUIDANCE_NOTE = 'Note: Updated L0 applies to new sessions; batching reviews at session end maximizes prompt-cache reuse.';
|
|
@@ -179,6 +180,7 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
|
|
|
179
180
|
const approvedIds = [];
|
|
180
181
|
let compareUrl;
|
|
181
182
|
let recompiledL0 = false;
|
|
183
|
+
let personalCommitted = false;
|
|
182
184
|
if (proposals.length === 0) {
|
|
183
185
|
return { ok: true, approvedIds: [], messages: ['No proposals to approve.'], errors: [] };
|
|
184
186
|
}
|
|
@@ -207,6 +209,13 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
|
|
|
207
209
|
errors.push('Personal memory root is not configured.');
|
|
208
210
|
return { ok: false, approvedIds, messages, errors };
|
|
209
211
|
}
|
|
212
|
+
if (isReadOnlyRoot(root)) {
|
|
213
|
+
errors.push(READ_ONLY_MESSAGE);
|
|
214
|
+
return { ok: false, approvedIds, messages, errors };
|
|
215
|
+
}
|
|
216
|
+
const pullWarning = await pullRebaseBeforeCommit(root);
|
|
217
|
+
if (pullWarning)
|
|
218
|
+
messages.push(pullWarning);
|
|
210
219
|
const touched = [];
|
|
211
220
|
for (const p of personalProps) {
|
|
212
221
|
touched.push(...applyProposalFilesToDir(root.path, '', p));
|
|
@@ -231,6 +240,7 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
|
|
|
231
240
|
return { ok: false, approvedIds, messages, errors };
|
|
232
241
|
}
|
|
233
242
|
recompiledL0 = true;
|
|
243
|
+
personalCommitted = true;
|
|
234
244
|
messages.push(`Approved ${personalProps.length} personal proposal(s) in 1 commit and recompiled L0 (${comp.estimatedTokens}/${comp.budget} tokens).`);
|
|
235
245
|
}
|
|
236
246
|
// 2. Project scope: write uncommitted file(s) and mark awaiting_commit
|
|
@@ -288,6 +298,7 @@ export async function approveProposalsBatch(config, proposals, options = {}) {
|
|
|
288
298
|
errors: [],
|
|
289
299
|
compareUrl,
|
|
290
300
|
recompiledL0,
|
|
301
|
+
personalCommitted,
|
|
291
302
|
};
|
|
292
303
|
}
|
|
293
304
|
async function approveTeamBatch(config, root, teamProps, homeDir, overrideMode) {
|
package/dist/src/sync.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getHomeDir } from './config.js';
|
|
2
2
|
import { compileGlobalL0 } from './compiler.js';
|
|
3
3
|
import { getHeadSha, gitPullFfOnly, hasRemote } from './git.js';
|
|
4
|
+
import { recordSuccessfulPull } from './personal-remote.js';
|
|
4
5
|
export async function syncAllRoots(config, options = {}) {
|
|
5
6
|
const homeDir = options.homeDir || getHomeDir();
|
|
6
7
|
const timeoutMs = options.timeoutMs ?? 5000;
|
|
@@ -22,6 +23,8 @@ export async function syncAllRoots(config, options = {}) {
|
|
|
22
23
|
warnings.push(msg);
|
|
23
24
|
continue;
|
|
24
25
|
}
|
|
26
|
+
if (root.scope === 'personal')
|
|
27
|
+
recordSuccessfulPull(homeDir);
|
|
25
28
|
const afterSha = getHeadSha(root.path);
|
|
26
29
|
if (beforeSha !== afterSha) {
|
|
27
30
|
advanced = true;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type EntryType = 'rule' | 'decision' | 'lesson' | 'preference' | 'referen
|
|
|
3
3
|
export type EntryStatus = 'active' | 'deprecated' | 'superseded';
|
|
4
4
|
export type L0Mode = 'none' | 'line' | 'body';
|
|
5
5
|
export type TeamSubmitMode = 'auto' | 'pr';
|
|
6
|
+
export type PushMode = 'ask' | 'auto' | 'never';
|
|
6
7
|
export type ProposalAction = 'create' | 'update' | 'supersede';
|
|
7
8
|
export type ProposalStatus = 'pending' | 'awaiting_commit' | 'push_failed';
|
|
8
9
|
export type ProjectRootSource = 'mcp-roots' | 'cwd' | 'none';
|
|
@@ -10,6 +11,7 @@ export declare const COMPILER_VERSION: string;
|
|
|
10
11
|
export declare const DEFAULT_TOKEN_BUDGET = 1500;
|
|
11
12
|
export declare const DEFAULT_STALE_DAYS = 14;
|
|
12
13
|
export declare const DEFAULT_SIMILARITY_THRESHOLD = 0.45;
|
|
14
|
+
export declare const DEFAULT_SIMILARITY_HINT_FLOOR = 0.25;
|
|
13
15
|
export declare const VALID_TYPES: readonly EntryType[];
|
|
14
16
|
export declare const VALID_STATUSES: readonly EntryStatus[];
|
|
15
17
|
export declare const VALID_L0_MODES: readonly L0Mode[];
|
|
@@ -20,6 +22,10 @@ export interface RootConfig {
|
|
|
20
22
|
remote?: string;
|
|
21
23
|
defaultBranch?: string;
|
|
22
24
|
submitMode?: TeamSubmitMode;
|
|
25
|
+
/** Personal root only: what happens after an approve commits (feature 03 `FR-02`). */
|
|
26
|
+
pushMode?: PushMode;
|
|
27
|
+
/** Personal root only: a host that only reads (feature 03 `FR-05`). */
|
|
28
|
+
readOnly?: boolean;
|
|
23
29
|
}
|
|
24
30
|
export interface UserConfig {
|
|
25
31
|
version: 1;
|
|
@@ -27,6 +33,8 @@ export interface UserConfig {
|
|
|
27
33
|
tokenBudget: number;
|
|
28
34
|
staleDays: number;
|
|
29
35
|
similarityThreshold: number;
|
|
36
|
+
/** Lower bound for the related-entry notice on a staged create (01 FR-04 amendment). */
|
|
37
|
+
similarityHintFloor?: number;
|
|
30
38
|
roots: {
|
|
31
39
|
personal?: RootConfig;
|
|
32
40
|
team?: RootConfig;
|
package/dist/src/types.js
CHANGED
|
@@ -3,6 +3,7 @@ export const COMPILER_VERSION = getPackageVersion();
|
|
|
3
3
|
export const DEFAULT_TOKEN_BUDGET = 1500;
|
|
4
4
|
export const DEFAULT_STALE_DAYS = 14;
|
|
5
5
|
export const DEFAULT_SIMILARITY_THRESHOLD = 0.45;
|
|
6
|
+
export const DEFAULT_SIMILARITY_HINT_FLOOR = 0.25;
|
|
6
7
|
export const VALID_TYPES = [
|
|
7
8
|
'rule',
|
|
8
9
|
'decision',
|
package/package.json
CHANGED