@fabersep/memory 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +399 -2
- package/dist/src/bm25.d.ts +26 -0
- package/dist/src/bm25.js +183 -0
- package/dist/src/cache-logs.d.ts +47 -0
- package/dist/src/cache-logs.js +433 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +701 -0
- package/dist/src/compiler.d.ts +23 -0
- package/dist/src/compiler.js +211 -0
- package/dist/src/config.d.ts +20 -0
- package/dist/src/config.js +134 -0
- package/dist/src/doctor.d.ts +23 -0
- package/dist/src/doctor.js +447 -0
- package/dist/src/frontmatter.d.ts +22 -0
- package/dist/src/frontmatter.js +199 -0
- package/dist/src/git.d.ts +33 -0
- package/dist/src/git.js +251 -0
- package/dist/src/hygiene.d.ts +7 -0
- package/dist/src/hygiene.js +89 -0
- package/dist/src/importer.d.ts +34 -0
- package/dist/src/importer.js +261 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.js +18 -0
- package/dist/src/init.d.ts +43 -0
- package/dist/src/init.js +280 -0
- package/dist/src/mcp.d.ts +218 -0
- package/dist/src/mcp.js +437 -0
- package/dist/src/metrics.d.ts +72 -0
- package/dist/src/metrics.js +179 -0
- package/dist/src/proposals.d.ts +34 -0
- package/dist/src/proposals.js +420 -0
- package/dist/src/stats.d.ts +165 -0
- package/dist/src/stats.js +579 -0
- package/dist/src/store.d.ts +23 -0
- package/dist/src/store.js +161 -0
- package/dist/src/sync.d.ts +15 -0
- package/dist/src/sync.js +47 -0
- package/dist/src/types.d.ts +100 -0
- package/dist/src/types.js +17 -0
- package/dist/src/ui.d.ts +19 -0
- package/dist/src/ui.js +74 -0
- package/package.json +50 -4
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { extractLinks, parseMarkdownWithFrontmatter, validateFrontmatter, } from './frontmatter.js';
|
|
5
|
+
import { findGitRoot, getHeadSha, getUncommittedFiles, isGitRepo, listHeadMarkdownFiles, readHeadFile, } from './git.js';
|
|
6
|
+
export const PROJECT_MEMORY_REL_DIR = '.faber/memory';
|
|
7
|
+
export function resolveProjectRoot(mcpRoots, cwd = process.cwd()) {
|
|
8
|
+
if (mcpRoots && mcpRoots.length > 0) {
|
|
9
|
+
for (const rawRoot of mcpRoots) {
|
|
10
|
+
const fsPath = rawRoot.startsWith('file://') ? safeFileUriToPath(rawRoot) : rawRoot;
|
|
11
|
+
if (!fsPath)
|
|
12
|
+
continue;
|
|
13
|
+
const memDir = path.join(fsPath, PROJECT_MEMORY_REL_DIR);
|
|
14
|
+
if (fs.existsSync(memDir) && fs.statSync(memDir).isDirectory()) {
|
|
15
|
+
return { source: 'mcp-roots', projectRoot: fsPath, memoryDir: memDir };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const gitRoot = findGitRoot(cwd);
|
|
20
|
+
if (gitRoot) {
|
|
21
|
+
const memDir = path.join(gitRoot, PROJECT_MEMORY_REL_DIR);
|
|
22
|
+
if (fs.existsSync(memDir) && fs.statSync(memDir).isDirectory()) {
|
|
23
|
+
return { source: 'cwd', projectRoot: gitRoot, memoryDir: memDir };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { source: 'none' };
|
|
27
|
+
}
|
|
28
|
+
function safeFileUriToPath(uri) {
|
|
29
|
+
try {
|
|
30
|
+
return fileURLToPath(uri);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function loadScopeFromHead(repoDir, scope, subPath = '') {
|
|
37
|
+
if (!fs.existsSync(repoDir) || !isGitRepo(repoDir)) {
|
|
38
|
+
return {
|
|
39
|
+
scope,
|
|
40
|
+
rootPath: repoDir,
|
|
41
|
+
headSha: null,
|
|
42
|
+
entries: [],
|
|
43
|
+
errors: [],
|
|
44
|
+
uncommittedFiles: [],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const headSha = getHeadSha(repoDir);
|
|
48
|
+
const uncommittedFiles = getUncommittedFiles(repoDir, subPath);
|
|
49
|
+
if (!headSha) {
|
|
50
|
+
return {
|
|
51
|
+
scope,
|
|
52
|
+
rootPath: repoDir,
|
|
53
|
+
headSha: null,
|
|
54
|
+
entries: [],
|
|
55
|
+
errors: [],
|
|
56
|
+
uncommittedFiles,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const mdFiles = listHeadMarkdownFiles(repoDir, subPath);
|
|
60
|
+
const entries = [];
|
|
61
|
+
const errors = [];
|
|
62
|
+
for (const relPath of mdFiles) {
|
|
63
|
+
const base = path.basename(relPath);
|
|
64
|
+
if (base.toLowerCase() === 'readme.md') {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const rawContent = readHeadFile(repoDir, relPath);
|
|
68
|
+
if (rawContent === null)
|
|
69
|
+
continue;
|
|
70
|
+
const parsed = parseMarkdownWithFrontmatter(rawContent);
|
|
71
|
+
if (!parsed.hasFrontmatter) {
|
|
72
|
+
errors.push({
|
|
73
|
+
scope,
|
|
74
|
+
filePath: relPath,
|
|
75
|
+
message: 'missing YAML frontmatter (required fields: summary, type)',
|
|
76
|
+
});
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const validated = validateFrontmatter(parsed.rawFrontmatter, scope);
|
|
80
|
+
if (validated.errors.length > 0 || !validated.frontmatter) {
|
|
81
|
+
for (const msg of validated.errors) {
|
|
82
|
+
errors.push({ scope, filePath: relPath, message: msg });
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const id = base.replace(/\.md$/i, '');
|
|
87
|
+
entries.push({
|
|
88
|
+
id,
|
|
89
|
+
scope,
|
|
90
|
+
filePath: relPath,
|
|
91
|
+
...validated.frontmatter,
|
|
92
|
+
body: parsed.body.trim(),
|
|
93
|
+
links: extractLinks(parsed.body),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
scope,
|
|
98
|
+
rootPath: repoDir,
|
|
99
|
+
headSha,
|
|
100
|
+
entries,
|
|
101
|
+
errors,
|
|
102
|
+
uncommittedFiles,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export function loadAllScopes(config, projectResolution) {
|
|
106
|
+
const team = config.roots.team
|
|
107
|
+
? loadScopeFromHead(config.roots.team.path, 'team')
|
|
108
|
+
: undefined;
|
|
109
|
+
const personal = config.roots.personal
|
|
110
|
+
? loadScopeFromHead(config.roots.personal.path, 'personal')
|
|
111
|
+
: undefined;
|
|
112
|
+
const project = projectResolution.source !== 'none' && projectResolution.projectRoot
|
|
113
|
+
? loadScopeFromHead(projectResolution.projectRoot, 'project', PROJECT_MEMORY_REL_DIR)
|
|
114
|
+
: undefined;
|
|
115
|
+
const globalIds = new Map();
|
|
116
|
+
for (const e of team?.entries || []) {
|
|
117
|
+
if (e.status === 'active')
|
|
118
|
+
globalIds.set(e.id, 'team');
|
|
119
|
+
}
|
|
120
|
+
for (const e of personal?.entries || []) {
|
|
121
|
+
if (e.status === 'active')
|
|
122
|
+
globalIds.set(e.id, 'personal');
|
|
123
|
+
}
|
|
124
|
+
const shadowWarnings = [];
|
|
125
|
+
if (project) {
|
|
126
|
+
for (const e of project.entries) {
|
|
127
|
+
if (e.status === 'active' && globalIds.has(e.id)) {
|
|
128
|
+
const globalScope = globalIds.get(e.id);
|
|
129
|
+
e.shadowed = true;
|
|
130
|
+
e.shadowWarning = `Project entry "${e.id}" collides with active ${globalScope} entry "${e.id}" and is marked shadowed.`;
|
|
131
|
+
shadowWarnings.push(e.shadowWarning);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const allEntries = [
|
|
136
|
+
...(team?.entries || []),
|
|
137
|
+
...(personal?.entries || []),
|
|
138
|
+
...(project?.entries || []),
|
|
139
|
+
];
|
|
140
|
+
const activeEntries = allEntries.filter((e) => e.status === 'active');
|
|
141
|
+
const uncommittedWarnings = [];
|
|
142
|
+
if (team && team.uncommittedFiles.length > 0) {
|
|
143
|
+
uncommittedWarnings.push(`Uncommitted edits in team memory root (${team.uncommittedFiles.join(', ')}); serving committed HEAD only.`);
|
|
144
|
+
}
|
|
145
|
+
if (personal && personal.uncommittedFiles.length > 0) {
|
|
146
|
+
uncommittedWarnings.push(`Uncommitted edits in personal memory root (${personal.uncommittedFiles.join(', ')}); serving committed HEAD only.`);
|
|
147
|
+
}
|
|
148
|
+
if (project && project.uncommittedFiles.length > 0) {
|
|
149
|
+
uncommittedWarnings.push(`Uncommitted edits in project memory (${project.uncommittedFiles.join(', ')}); run "git add ${project.uncommittedFiles.join(' ')} && git commit" to activate.`);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
team,
|
|
153
|
+
personal,
|
|
154
|
+
project,
|
|
155
|
+
projectResolution,
|
|
156
|
+
allEntries,
|
|
157
|
+
activeEntries,
|
|
158
|
+
shadowWarnings,
|
|
159
|
+
uncommittedWarnings,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CompileTrigger } from './metrics.js';
|
|
2
|
+
import { UserConfig } from './types.js';
|
|
3
|
+
export interface SyncResult {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
advanced: boolean;
|
|
6
|
+
warnings: string[];
|
|
7
|
+
errors: string[];
|
|
8
|
+
recompiled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function syncAllRoots(config: UserConfig, options?: {
|
|
11
|
+
homeDir?: string;
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
recompile?: boolean;
|
|
14
|
+
trigger?: CompileTrigger;
|
|
15
|
+
}): Promise<SyncResult>;
|
package/dist/src/sync.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { getHomeDir } from './config.js';
|
|
2
|
+
import { compileGlobalL0 } from './compiler.js';
|
|
3
|
+
import { getHeadSha, gitPullFfOnly, hasRemote } from './git.js';
|
|
4
|
+
export async function syncAllRoots(config, options = {}) {
|
|
5
|
+
const homeDir = options.homeDir || getHomeDir();
|
|
6
|
+
const timeoutMs = options.timeoutMs ?? 5000;
|
|
7
|
+
const shouldRecompile = options.recompile !== false;
|
|
8
|
+
const warnings = [];
|
|
9
|
+
const errors = [];
|
|
10
|
+
let advanced = false;
|
|
11
|
+
const roots = [config.roots.team, config.roots.personal].filter(Boolean);
|
|
12
|
+
for (const root of roots) {
|
|
13
|
+
if (!root)
|
|
14
|
+
continue;
|
|
15
|
+
if (!hasRemote(root.path))
|
|
16
|
+
continue;
|
|
17
|
+
const beforeSha = getHeadSha(root.path);
|
|
18
|
+
const pull = await gitPullFfOnly(root.path, timeoutMs);
|
|
19
|
+
if (!pull.ok) {
|
|
20
|
+
const msg = `[${root.scope}] ${pull.error || 'pull failed'}`;
|
|
21
|
+
errors.push(msg);
|
|
22
|
+
warnings.push(msg);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const afterSha = getHeadSha(root.path);
|
|
26
|
+
if (beforeSha !== afterSha) {
|
|
27
|
+
advanced = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
let recompiled = false;
|
|
31
|
+
if (shouldRecompile && errors.length === 0) {
|
|
32
|
+
const comp = compileGlobalL0(config, { homeDir, trigger: options.trigger || 'sync' });
|
|
33
|
+
if (comp.ok) {
|
|
34
|
+
recompiled = true;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
errors.push(...comp.errors);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
ok: errors.length === 0,
|
|
42
|
+
advanced,
|
|
43
|
+
warnings,
|
|
44
|
+
errors,
|
|
45
|
+
recompiled,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export type Scope = 'personal' | 'team' | 'project';
|
|
2
|
+
export type EntryType = 'rule' | 'decision' | 'lesson' | 'preference' | 'reference';
|
|
3
|
+
export type EntryStatus = 'active' | 'deprecated' | 'superseded';
|
|
4
|
+
export type L0Mode = 'none' | 'line' | 'body';
|
|
5
|
+
export type TeamSubmitMode = 'auto' | 'pr';
|
|
6
|
+
export type ProposalAction = 'create' | 'update' | 'supersede';
|
|
7
|
+
export type ProposalStatus = 'pending' | 'awaiting_commit' | 'push_failed';
|
|
8
|
+
export type ProjectRootSource = 'mcp-roots' | 'cwd' | 'none';
|
|
9
|
+
export declare const COMPILER_VERSION = "0.1.0";
|
|
10
|
+
export declare const DEFAULT_TOKEN_BUDGET = 1500;
|
|
11
|
+
export declare const DEFAULT_STALE_DAYS = 14;
|
|
12
|
+
export declare const DEFAULT_SIMILARITY_THRESHOLD = 0.45;
|
|
13
|
+
export declare const VALID_TYPES: readonly EntryType[];
|
|
14
|
+
export declare const VALID_STATUSES: readonly EntryStatus[];
|
|
15
|
+
export declare const VALID_L0_MODES: readonly L0Mode[];
|
|
16
|
+
export interface RootConfig {
|
|
17
|
+
uuid: string;
|
|
18
|
+
path: string;
|
|
19
|
+
scope: 'personal' | 'team';
|
|
20
|
+
remote?: string;
|
|
21
|
+
defaultBranch?: string;
|
|
22
|
+
submitMode?: TeamSubmitMode;
|
|
23
|
+
}
|
|
24
|
+
export interface UserConfig {
|
|
25
|
+
version: 1;
|
|
26
|
+
userTag: string;
|
|
27
|
+
tokenBudget: number;
|
|
28
|
+
staleDays: number;
|
|
29
|
+
similarityThreshold: number;
|
|
30
|
+
roots: {
|
|
31
|
+
personal?: RootConfig;
|
|
32
|
+
team?: RootConfig;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface EntryFrontmatter {
|
|
36
|
+
summary: string;
|
|
37
|
+
type: EntryType;
|
|
38
|
+
tags: string[];
|
|
39
|
+
status: EntryStatus;
|
|
40
|
+
superseded_by?: string;
|
|
41
|
+
l0: L0Mode;
|
|
42
|
+
last_verified?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface MemoryEntry extends EntryFrontmatter {
|
|
45
|
+
id: string;
|
|
46
|
+
scope: Scope;
|
|
47
|
+
filePath: string;
|
|
48
|
+
body: string;
|
|
49
|
+
links: string[];
|
|
50
|
+
shadowed?: boolean;
|
|
51
|
+
shadowWarning?: string;
|
|
52
|
+
}
|
|
53
|
+
export interface ValidationError {
|
|
54
|
+
scope: Scope;
|
|
55
|
+
filePath: string;
|
|
56
|
+
message: string;
|
|
57
|
+
}
|
|
58
|
+
export interface HygieneFinding {
|
|
59
|
+
line: number;
|
|
60
|
+
category: 'secret' | 'machine-path';
|
|
61
|
+
pattern: string;
|
|
62
|
+
message: string;
|
|
63
|
+
redactedSnippet: string;
|
|
64
|
+
}
|
|
65
|
+
export interface Proposal {
|
|
66
|
+
id: string;
|
|
67
|
+
rootUuid: string;
|
|
68
|
+
scope: Scope;
|
|
69
|
+
action: ProposalAction;
|
|
70
|
+
entryId: string;
|
|
71
|
+
targetId?: string;
|
|
72
|
+
summary: string;
|
|
73
|
+
type: EntryType;
|
|
74
|
+
tags: string[];
|
|
75
|
+
l0?: L0Mode;
|
|
76
|
+
body: string;
|
|
77
|
+
forceNew?: boolean;
|
|
78
|
+
reason?: string;
|
|
79
|
+
status: ProposalStatus;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
error?: string;
|
|
82
|
+
projectRootPath?: string;
|
|
83
|
+
targetFilePath?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface ProjectRootResolution {
|
|
86
|
+
source: ProjectRootSource;
|
|
87
|
+
projectRoot?: string;
|
|
88
|
+
memoryDir?: string;
|
|
89
|
+
}
|
|
90
|
+
export interface SearchResultItem {
|
|
91
|
+
id: string;
|
|
92
|
+
scope: Scope;
|
|
93
|
+
type: EntryType;
|
|
94
|
+
summary: string;
|
|
95
|
+
tags: string[];
|
|
96
|
+
pending?: boolean;
|
|
97
|
+
proposal_id?: string;
|
|
98
|
+
shadowed?: boolean;
|
|
99
|
+
shadow_warning?: string;
|
|
100
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const COMPILER_VERSION = '0.1.0';
|
|
2
|
+
export const DEFAULT_TOKEN_BUDGET = 1500;
|
|
3
|
+
export const DEFAULT_STALE_DAYS = 14;
|
|
4
|
+
export const DEFAULT_SIMILARITY_THRESHOLD = 0.45;
|
|
5
|
+
export const VALID_TYPES = [
|
|
6
|
+
'rule',
|
|
7
|
+
'decision',
|
|
8
|
+
'lesson',
|
|
9
|
+
'preference',
|
|
10
|
+
'reference',
|
|
11
|
+
];
|
|
12
|
+
export const VALID_STATUSES = [
|
|
13
|
+
'active',
|
|
14
|
+
'deprecated',
|
|
15
|
+
'superseded',
|
|
16
|
+
];
|
|
17
|
+
export const VALID_L0_MODES = ['none', 'line', 'body'];
|
package/dist/src/ui.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const DOCS_TROUBLESHOOTING_URL = "https://github.com/fabersep/memory/blob/main/docs/troubleshooting.md";
|
|
2
|
+
export declare function troubleshootingLink(anchor: string): string;
|
|
3
|
+
export declare function shouldUseColor(stream?: NodeJS.WriteStream): boolean;
|
|
4
|
+
export declare const c: {
|
|
5
|
+
bold: (s: string, on?: boolean) => string;
|
|
6
|
+
dim: (s: string, on?: boolean) => string;
|
|
7
|
+
red: (s: string, on?: boolean) => string;
|
|
8
|
+
green: (s: string, on?: boolean) => string;
|
|
9
|
+
yellow: (s: string, on?: boolean) => string;
|
|
10
|
+
blue: (s: string, on?: boolean) => string;
|
|
11
|
+
magenta: (s: string, on?: boolean) => string;
|
|
12
|
+
cyan: (s: string, on?: boolean) => string;
|
|
13
|
+
};
|
|
14
|
+
export declare function hr(char?: string, width?: number): string;
|
|
15
|
+
export declare function normalizeTeamUrl(input: string): {
|
|
16
|
+
url: string;
|
|
17
|
+
normalized: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function inferErrorAnchor(message: string): string | null;
|
package/dist/src/ui.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
export const DOCS_TROUBLESHOOTING_URL = 'https://github.com/fabersep/memory/blob/main/docs/troubleshooting.md';
|
|
3
|
+
export function troubleshootingLink(anchor) {
|
|
4
|
+
return `${DOCS_TROUBLESHOOTING_URL}#${anchor}`;
|
|
5
|
+
}
|
|
6
|
+
export function shouldUseColor(stream = process.stdout) {
|
|
7
|
+
if (process.env.NO_COLOR !== undefined)
|
|
8
|
+
return false;
|
|
9
|
+
if (process.env.FORCE_COLOR !== undefined && process.env.FORCE_COLOR !== '0')
|
|
10
|
+
return true;
|
|
11
|
+
return Boolean(stream.isTTY);
|
|
12
|
+
}
|
|
13
|
+
function wrap(code, text, enabled = shouldUseColor()) {
|
|
14
|
+
return enabled ? `\x1b[${code}m${text}\x1b[0m` : text;
|
|
15
|
+
}
|
|
16
|
+
export const c = {
|
|
17
|
+
bold: (s, on) => wrap('1', s, on),
|
|
18
|
+
dim: (s, on) => wrap('2', s, on),
|
|
19
|
+
red: (s, on) => wrap('31', s, on),
|
|
20
|
+
green: (s, on) => wrap('32', s, on),
|
|
21
|
+
yellow: (s, on) => wrap('33', s, on),
|
|
22
|
+
blue: (s, on) => wrap('34', s, on),
|
|
23
|
+
magenta: (s, on) => wrap('35', s, on),
|
|
24
|
+
cyan: (s, on) => wrap('36', s, on),
|
|
25
|
+
};
|
|
26
|
+
export function hr(char = '─', width = 64) {
|
|
27
|
+
return char.repeat(width);
|
|
28
|
+
}
|
|
29
|
+
export function normalizeTeamUrl(input) {
|
|
30
|
+
const trimmed = input.trim();
|
|
31
|
+
if (!trimmed)
|
|
32
|
+
return { url: trimmed, normalized: false };
|
|
33
|
+
// Already a full URL or SSH git spec
|
|
34
|
+
if (/^(?:https?|ssh|git|file):\/\//i.test(trimmed) ||
|
|
35
|
+
/^git@[^:]+:.+/.test(trimmed)) {
|
|
36
|
+
return { url: trimmed, normalized: false };
|
|
37
|
+
}
|
|
38
|
+
// Local path (relative, absolute, home, or existing directory)
|
|
39
|
+
if (trimmed.startsWith('/') ||
|
|
40
|
+
trimmed.startsWith('./') ||
|
|
41
|
+
trimmed.startsWith('../') ||
|
|
42
|
+
trimmed.startsWith('~') ||
|
|
43
|
+
fs.existsSync(trimmed)) {
|
|
44
|
+
return { url: trimmed, normalized: false };
|
|
45
|
+
}
|
|
46
|
+
// Host + path without protocol, e.g. github.com/org/repo or gitlab.com/org/repo.git
|
|
47
|
+
if (/^[A-Za-z0-9.-]+\.[A-Za-z]{2,}\/[^/\s]+\/[^/\s]+/.test(trimmed)) {
|
|
48
|
+
const withGit = trimmed.endsWith('.git') ? trimmed : `${trimmed}.git`;
|
|
49
|
+
return { url: `https://${withGit}`, normalized: true };
|
|
50
|
+
}
|
|
51
|
+
// GitHub shorthand: org/repo
|
|
52
|
+
if (/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(trimmed)) {
|
|
53
|
+
const clean = trimmed.endsWith('.git') ? trimmed : `${trimmed}.git`;
|
|
54
|
+
return { url: `https://github.com/${clean}`, normalized: true };
|
|
55
|
+
}
|
|
56
|
+
return { url: trimmed, normalized: false };
|
|
57
|
+
}
|
|
58
|
+
export function inferErrorAnchor(message) {
|
|
59
|
+
const lower = message.toLowerCase();
|
|
60
|
+
if (lower.includes('machine-path') || lower.includes('home path'))
|
|
61
|
+
return 'machine-specific-paths';
|
|
62
|
+
if (lower.includes('secret') || lower.includes('private key') || lower.includes('api key') || lower.includes('token')) {
|
|
63
|
+
return 'secrets-detected';
|
|
64
|
+
}
|
|
65
|
+
if (lower.includes('budget') || lower.includes('1500'))
|
|
66
|
+
return 'l0-budget-exceeded';
|
|
67
|
+
if (lower.includes('duplicate') || lower.includes('collision'))
|
|
68
|
+
return 'duplicate-ids';
|
|
69
|
+
if (lower.includes('dirty') || lower.includes('uncommitted'))
|
|
70
|
+
return 'dirty-serving-clone';
|
|
71
|
+
if (lower.includes('push') && lower.includes('fail'))
|
|
72
|
+
return 'push-failed';
|
|
73
|
+
return null;
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabersep/memory",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Prefix-cache-first, Git-backed Markdown memory MCP server, pre-memory staging, and import CLI for AI coding agents.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/fabersep/memory.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/fabersep/memory#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/fabersep/memory/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"fabersep",
|
|
17
|
+
"ai-agents",
|
|
18
|
+
"memory",
|
|
19
|
+
"mcp",
|
|
20
|
+
"prompt-caching",
|
|
21
|
+
"markdown",
|
|
22
|
+
"git"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"bin": {
|
|
26
|
+
"faber-memory": "dist/src/cli.js"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": "./dist/src/index.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist/src",
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"README.md"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"prepublishOnly": "npm run build",
|
|
45
|
+
"test": "npm run build && node --test dist/test/*.test.js",
|
|
46
|
+
"faber-memory": "node dist/src/cli.js"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^22.10.2",
|
|
50
|
+
"typescript": "^5.8.3"
|
|
51
|
+
}
|
|
52
|
+
}
|