@teamlens/core 0.1.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.
Files changed (49) hide show
  1. package/dist/analytics/analytics-engine.d.ts +45 -0
  2. package/dist/analytics/analytics-engine.d.ts.map +1 -0
  3. package/dist/analytics/analytics-engine.js +176 -0
  4. package/dist/analytics/analytics-engine.js.map +1 -0
  5. package/dist/distribution/distributor.d.ts +19 -0
  6. package/dist/distribution/distributor.d.ts.map +1 -0
  7. package/dist/distribution/distributor.js +220 -0
  8. package/dist/distribution/distributor.js.map +1 -0
  9. package/dist/extractor/git-extractor.d.ts +36 -0
  10. package/dist/extractor/git-extractor.d.ts.map +1 -0
  11. package/dist/extractor/git-extractor.js +198 -0
  12. package/dist/extractor/git-extractor.js.map +1 -0
  13. package/dist/index.d.ts +118 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +313 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/retrieval/retriever.d.ts +33 -0
  18. package/dist/retrieval/retriever.d.ts.map +1 -0
  19. package/dist/retrieval/retriever.js +126 -0
  20. package/dist/retrieval/retriever.js.map +1 -0
  21. package/dist/session/insight-detector.d.ts +10 -0
  22. package/dist/session/insight-detector.d.ts.map +1 -0
  23. package/dist/session/insight-detector.js +87 -0
  24. package/dist/session/insight-detector.js.map +1 -0
  25. package/dist/session/session-manager.d.ts +49 -0
  26. package/dist/session/session-manager.d.ts.map +1 -0
  27. package/dist/session/session-manager.js +228 -0
  28. package/dist/session/session-manager.js.map +1 -0
  29. package/dist/staleness/staleness-engine.d.ts +36 -0
  30. package/dist/staleness/staleness-engine.d.ts.map +1 -0
  31. package/dist/staleness/staleness-engine.js +141 -0
  32. package/dist/staleness/staleness-engine.js.map +1 -0
  33. package/dist/store/database.d.ts +121 -0
  34. package/dist/store/database.d.ts.map +1 -0
  35. package/dist/store/database.js +677 -0
  36. package/dist/store/database.js.map +1 -0
  37. package/dist/store/embeddings.d.ts +21 -0
  38. package/dist/store/embeddings.d.ts.map +1 -0
  39. package/dist/store/embeddings.js +70 -0
  40. package/dist/store/embeddings.js.map +1 -0
  41. package/dist/sync/team-sync.d.ts +77 -0
  42. package/dist/sync/team-sync.d.ts.map +1 -0
  43. package/dist/sync/team-sync.js +230 -0
  44. package/dist/sync/team-sync.js.map +1 -0
  45. package/dist/types.d.ts +223 -0
  46. package/dist/types.d.ts.map +1 -0
  47. package/dist/types.js +24 -0
  48. package/dist/types.js.map +1 -0
  49. package/package.json +39 -0
@@ -0,0 +1,198 @@
1
+ import simpleGit from 'simple-git';
2
+ /**
3
+ * Extracts memories from git history — commits, diffs, and file changes.
4
+ *
5
+ * Uses heuristic pattern matching (no LLM required).
6
+ * Detects architectural decisions, migrations, refactors, and conventions
7
+ * from commit messages and diff patterns.
8
+ */
9
+ export class GitExtractor {
10
+ git;
11
+ constructor(repoPath) {
12
+ this.git = simpleGit(repoPath);
13
+ }
14
+ /** Get recent commits not yet tracked. */
15
+ async getRecentCommits(since) {
16
+ const options = { '--no-merges': null };
17
+ if (since)
18
+ options['--since'] = since;
19
+ const log = await this.git.log(options);
20
+ return log.all.map((entry) => ({
21
+ sha: entry.hash,
22
+ message: entry.message,
23
+ author: entry.author_name,
24
+ date: entry.date,
25
+ files: [],
26
+ processed: false,
27
+ }));
28
+ }
29
+ /** Get files changed in a specific commit. */
30
+ async getCommitFiles(sha) {
31
+ try {
32
+ const result = await this.git.raw(['diff-tree', '--no-commit-id', '--name-only', '-r', sha]);
33
+ return result.split('\n').filter(Boolean);
34
+ }
35
+ catch {
36
+ return [];
37
+ }
38
+ }
39
+ /** Get the diff stat for a specific file in a commit. */
40
+ async getFileDiffStat(sha, filePath) {
41
+ try {
42
+ const diff = await this.git.diffSummary([`${sha}^`, sha, '--', filePath]);
43
+ const file = diff.files[0];
44
+ if (!file || file.binary)
45
+ return null;
46
+ return { insertions: file.insertions, deletions: file.deletions };
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ }
52
+ /** Extract memories from a single commit. */
53
+ async extractFromCommit(commit) {
54
+ const memories = [];
55
+ const files = await this.getCommitFiles(commit.sha);
56
+ const message = commit.message.toLowerCase();
57
+ // Detect architectural decisions
58
+ if (this.isArchitecturalCommit(message)) {
59
+ memories.push({
60
+ content: `Architecture change: ${commit.message}`,
61
+ category: 'architecture',
62
+ relatedFiles: files,
63
+ tags: this.extractTags(message),
64
+ confidence: 0.7,
65
+ commitSha: commit.sha,
66
+ });
67
+ }
68
+ // Detect migrations / breaking changes
69
+ if (this.isMigrationCommit(message)) {
70
+ memories.push({
71
+ content: `Migration: ${commit.message}`,
72
+ category: 'active_context',
73
+ relatedFiles: files,
74
+ tags: ['migration', ...this.extractTags(message)],
75
+ confidence: 0.8,
76
+ commitSha: commit.sha,
77
+ });
78
+ }
79
+ // Detect convention-setting commits
80
+ if (this.isConventionCommit(message)) {
81
+ memories.push({
82
+ content: `Convention: ${commit.message}`,
83
+ category: 'convention',
84
+ relatedFiles: files,
85
+ tags: ['convention', ...this.extractTags(message)],
86
+ confidence: 0.6,
87
+ commitSha: commit.sha,
88
+ });
89
+ }
90
+ // Detect decisions from commit messages with "because", "instead of", "chose"
91
+ const decision = this.extractDecision(commit.message);
92
+ if (decision) {
93
+ memories.push({
94
+ content: decision,
95
+ category: 'decision',
96
+ relatedFiles: files,
97
+ tags: this.extractTags(message),
98
+ confidence: 0.75,
99
+ commitSha: commit.sha,
100
+ });
101
+ }
102
+ // Large commits that touch many files → likely refactor
103
+ if (files.length > 10) {
104
+ memories.push({
105
+ content: `Large refactor (${files.length} files): ${commit.message}`,
106
+ category: 'architecture',
107
+ relatedFiles: files.slice(0, 20),
108
+ tags: ['refactor', ...this.extractTags(message)],
109
+ confidence: 0.5,
110
+ commitSha: commit.sha,
111
+ });
112
+ }
113
+ return memories;
114
+ }
115
+ /** Get current file hash for staleness tracking. */
116
+ async getFileHash(filePath) {
117
+ try {
118
+ const result = await this.git.raw(['hash-object', filePath]);
119
+ return result.trim();
120
+ }
121
+ catch {
122
+ return null;
123
+ }
124
+ }
125
+ /** Get all tracked files in the repo. */
126
+ async getTrackedFiles() {
127
+ const result = await this.git.raw(['ls-files']);
128
+ return result.split('\n').filter(Boolean);
129
+ }
130
+ /** Get diff summary between HEAD and a previous state. */
131
+ async getDiffSummary(fromRef, toRef = 'HEAD') {
132
+ return this.git.diffSummary([fromRef, toRef]);
133
+ }
134
+ // ── Pattern Matchers ──
135
+ isArchitecturalCommit(message) {
136
+ const patterns = [
137
+ /\b(architect|restructur|reorganiz|overhaul|rewrite|redesign)\b/,
138
+ /\b(add|create|setup|init).*(module|service|layer|system|engine|framework)\b/,
139
+ /\b(move|split|extract|decouple).*(into|from|to)\b/,
140
+ ];
141
+ return patterns.some((p) => p.test(message));
142
+ }
143
+ isMigrationCommit(message) {
144
+ const patterns = [
145
+ /\b(migrat|upgrade|downgrade|breaking)\b/,
146
+ /\b(switch|move|convert).*(from|to)\b/,
147
+ /\b(deprecat|replac|swap)\b/,
148
+ ];
149
+ return patterns.some((p) => p.test(message));
150
+ }
151
+ isConventionCommit(message) {
152
+ const patterns = [
153
+ /\b(lint|format|style|convention|standard)\b/,
154
+ /\b(enforce|require|configure).*(rule|pattern|style)\b/,
155
+ /\b(eslint|prettier|editorconfig)\b/,
156
+ ];
157
+ return patterns.some((p) => p.test(message));
158
+ }
159
+ extractDecision(message) {
160
+ const patterns = [
161
+ /\bbecause\s+(.+)/i,
162
+ /\binstead of\s+(.+)/i,
163
+ /\bchose\s+(.+)/i,
164
+ /\breason:\s*(.+)/i,
165
+ /\bwhy:\s*(.+)/i,
166
+ ];
167
+ for (const p of patterns) {
168
+ const match = message.match(p);
169
+ if (match)
170
+ return `Decision: ${message}`;
171
+ }
172
+ return null;
173
+ }
174
+ extractTags(message) {
175
+ const tags = [];
176
+ const keywords = {
177
+ auth: 'auth',
178
+ api: 'api',
179
+ database: 'database',
180
+ db: 'database',
181
+ ui: 'ui',
182
+ test: 'testing',
183
+ ci: 'ci-cd',
184
+ deploy: 'deployment',
185
+ security: 'security',
186
+ performance: 'performance',
187
+ perf: 'performance',
188
+ config: 'config',
189
+ docs: 'documentation',
190
+ };
191
+ for (const [keyword, tag] of Object.entries(keywords)) {
192
+ if (message.includes(keyword))
193
+ tags.push(tag);
194
+ }
195
+ return [...new Set(tags)];
196
+ }
197
+ }
198
+ //# sourceMappingURL=git-extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-extractor.js","sourceRoot":"","sources":["../../src/extractor/git-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,SAA8C,MAAM,YAAY,CAAC;AAGxE;;;;;;GAMG;AACH,MAAM,OAAO,YAAY;IACf,GAAG,CAAY;IAEvB,YAAY,QAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAED,0CAA0C;IAC1C,KAAK,CAAC,gBAAgB,CAAC,KAAc;QACnC,MAAM,OAAO,GAAkC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QACvE,IAAI,KAAK;YAAE,OAAO,CAAC,SAAS,CAAC,GAAG,KAAK,CAAC;QAEtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAExC,OAAO,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7B,GAAG,EAAE,KAAK,CAAC,IAAI;YACf,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,WAAW;YACzB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC,CAAC;IACN,CAAC;IAED,8CAA8C;IAC9C,KAAK,CAAC,cAAc,CAAC,GAAW;QAC9B,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,C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AK;YACV,QAAQ,EAAE,UAAU;YACpB,EAAE,EAAE,UAAU;YACd,EAAE,EAAE,IAAI;YACR,IAAI,EAAE,SAAS;YACf,EAAE,EAAE,OAAO;YACX,MAAM,EAAE,YAAY;YACpB,QAAQ,EAAE,UAAU;YACpB,WAAW,EAAE,aAAa;YAC1B,IAAI,EAAE,aAAa;YACnB,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,eAAe;SACtB,CAAC;QAEF,KAAK,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtD,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChD,CAAC;QAED,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,118 @@
1
+ export * from './types.js';
2
+ export { MemoryDatabase } from './store/database.js';
3
+ export { EmbeddingProvider } from './store/embeddings.js';
4
+ export { GitExtractor } from './extractor/git-extractor.js';
5
+ export { StalenessEngine } from './staleness/staleness-engine.js';
6
+ export { MemoryRetriever } from './retrieval/retriever.js';
7
+ export { TeamSync } from './sync/team-sync.js';
8
+ export { Distributor } from './distribution/distributor.js';
9
+ export { SessionManager } from './session/session-manager.js';
10
+ export { InsightDetector } from './session/insight-detector.js';
11
+ export { AnalyticsEngine } from './analytics/analytics-engine.js';
12
+ import type { TeamLensConfig, ExtractedMemory, MemoryCategory, MemoryTier, RulePriority, DistributionTarget } from './types.js';
13
+ import { MemoryDatabase } from './store/database.js';
14
+ import { EmbeddingProvider } from './store/embeddings.js';
15
+ import { GitExtractor } from './extractor/git-extractor.js';
16
+ import { StalenessEngine } from './staleness/staleness-engine.js';
17
+ import { MemoryRetriever } from './retrieval/retriever.js';
18
+ import { TeamSync } from './sync/team-sync.js';
19
+ import { Distributor } from './distribution/distributor.js';
20
+ import { SessionManager } from './session/session-manager.js';
21
+ import { AnalyticsEngine } from './analytics/analytics-engine.js';
22
+ /**
23
+ * TeamLens — the main entry point.
24
+ *
25
+ * Wires together the database, extractor, staleness engine, retriever,
26
+ * team sync, distributor, session manager, and analytics engine.
27
+ *
28
+ * Use the async factory: `const tl = await TeamLens.create(repoPath)`
29
+ */
30
+ export declare class TeamLens {
31
+ readonly db: MemoryDatabase;
32
+ readonly git: GitExtractor;
33
+ readonly staleness: StalenessEngine;
34
+ readonly retriever: MemoryRetriever;
35
+ readonly embeddings: EmbeddingProvider;
36
+ readonly team: TeamSync;
37
+ readonly distributor: Distributor;
38
+ readonly sessions: SessionManager;
39
+ readonly analytics: AnalyticsEngine;
40
+ readonly config: TeamLensConfig;
41
+ readonly repoPath: string;
42
+ private constructor();
43
+ /** Async factory — required because sql.js needs async initialization. */
44
+ static create(repoPath: string, userConfig?: Partial<TeamLensConfig>): Promise<TeamLens>;
45
+ /** Scan the repo and build initial memory from git history. */
46
+ init(options?: {
47
+ extractFromGit?: boolean;
48
+ }): Promise<{
49
+ memoriesCreated: number;
50
+ filesTracked: number;
51
+ teamImported: number;
52
+ }>;
53
+ /** Agent or user stores a new memory (personal by default). */
54
+ remember(content: string, category: ExtractedMemory['category'], relatedFiles?: string[], tags?: string[], tier?: MemoryTier): Promise<string>;
55
+ /** Add a team rule — stored as source='rule', tier='team', confidence=1.0. */
56
+ addRule(content: string, category: MemoryCategory, options?: {
57
+ scope?: string[];
58
+ priority?: RulePriority;
59
+ good?: string;
60
+ bad?: string;
61
+ }): Promise<string>;
62
+ /** Distribute rules to agent config files. */
63
+ distribute(targets?: DistributionTarget[]): {
64
+ generated: string[];
65
+ warnings: string[];
66
+ };
67
+ /** Promote a personal memory to team (shared with everyone). */
68
+ share(memoryId: string): {
69
+ success: boolean;
70
+ error?: string;
71
+ };
72
+ /** Import new team memories from team.jsonl (call after git pull). */
73
+ syncTeam(): number;
74
+ /** Get memories by a specific team member. */
75
+ getByAuthor(author: string): import("./types.js").Memory[];
76
+ /** Get all team authors and their memory counts. */
77
+ getTeamAuthors(): {
78
+ author: string;
79
+ count: number;
80
+ }[];
81
+ /** Find who on the team has context about a topic. */
82
+ whoKnows(query: string): Promise<{
83
+ author: string;
84
+ memories: number;
85
+ topMemory: string;
86
+ }[]>;
87
+ /** Process any unprocessed commits and update staleness. */
88
+ processNewCommits(): Promise<{
89
+ newMemories: number;
90
+ stalenessUpdates: number;
91
+ teamImported: number;
92
+ }>;
93
+ /** Query memories with multi-signal ranking. */
94
+ query(queryText: string, scope?: string, limit?: number, tier?: MemoryTier): Promise<import("./types.js").ScoredMemory[]>;
95
+ /** Get all conventions. */
96
+ getConventions(): Promise<import("./types.js").Memory[]>;
97
+ /** Get decisions for a scope. */
98
+ getDecisions(scope?: string): Promise<import("./types.js").Memory[]>;
99
+ confirm(memoryId: string): void;
100
+ markStale(memoryId: string): void;
101
+ forget(memoryId: string): void;
102
+ stats(): {
103
+ total: number;
104
+ stale: number;
105
+ fresh: number;
106
+ team: number;
107
+ personal: number;
108
+ };
109
+ close(): void;
110
+ private static detectGitAuthor;
111
+ /** Ensure .teamlens/memory.db is gitignored but team.jsonl is NOT. */
112
+ private ensureGitignore;
113
+ private embedAllMemories;
114
+ private buildIgnoreMatcher;
115
+ }
116
+ /** @deprecated Use TeamLens instead */
117
+ export declare const CodeMemory: typeof TeamLens;
118
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EA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embeddings.js';
4
+ export { GitExtractor } from './extractor/git-extractor.js';
5
+ export { StalenessEngine } from './staleness/staleness-engine.js';
6
+ export { MemoryRetriever } from './retrieval/retriever.js';
7
+ export { TeamSync } from './sync/team-sync.js';
8
+ export { Distributor } from './distribution/distributor.js';
9
+ export { SessionManager } from './session/session-manager.js';
10
+ export { InsightDetector } from './session/insight-detector.js';
11
+ export { AnalyticsEngine } from './analytics/analytics-engine.js';
12
+ import path from 'node:path';
13
+ import fs from 'node:fs';
14
+ import { execSync } from 'node:child_process';
15
+ import { DEFAULT_CONFIG } from './types.js';
16
+ import { MemoryDatabase } from './store/database.js';
17
+ import { EmbeddingProvider } from './store/embeddings.js';
18
+ import { GitExtractor } from './extractor/git-extractor.js';
19
+ import { StalenessEngine } from './staleness/staleness-engine.js';
20
+ import { MemoryRetriever } from './retrieval/retriever.js';
21
+ import { TeamSync } from './sync/team-sync.js';
22
+ import { Distributor } from './distribution/distributor.js';
23
+ import { SessionManager } from './session/session-manager.js';
24
+ import { AnalyticsEngine } from './analytics/analytics-engine.js';
25
+ /**
26
+ * TeamLens — the main entry point.
27
+ *
28
+ * Wires together the database, extractor, staleness engine, retriever,
29
+ * team sync, distributor, session manager, and analytics engine.
30
+ *
31
+ * Use the async factory: `const tl = await TeamLens.create(repoPath)`
32
+ */
33
+ export class TeamLens {
34
+ db;
35
+ git;
36
+ staleness;
37
+ retriever;
38
+ embeddings;
39
+ team;
40
+ distributor;
41
+ sessions;
42
+ analytics;
43
+ config;
44
+ repoPath;
45
+ constructor(repoPath, db, config) {
46
+ this.repoPath = repoPath;
47
+ this.config = config;
48
+ this.db = db;
49
+ const storageDir = path.resolve(repoPath, config.storageDir);
50
+ this.embeddings = new EmbeddingProvider(this.config);
51
+ this.git = new GitExtractor(repoPath);
52
+ this.staleness = new StalenessEngine(this.db, this.git);
53
+ this.retriever = new MemoryRetriever(this.db, this.embeddings, this.config);
54
+ this.team = new TeamSync(this.db, storageDir, repoPath);
55
+ this.distributor = new Distributor(this.db, repoPath);
56
+ this.sessions = new SessionManager(this.db, this.config, this.team, this.embeddings);
57
+ this.analytics = new AnalyticsEngine(this.db);
58
+ }
59
+ /** Async factory — required because sql.js needs async initialization. */
60
+ static async create(repoPath, userConfig) {
61
+ const config = { ...DEFAULT_CONFIG, ...userConfig };
62
+ // Auto-detect git author if not set
63
+ if (config.author === 'unknown') {
64
+ config.author = TeamLens.detectGitAuthor(repoPath);
65
+ }
66
+ // Developer defaults to author
67
+ if (config.developer === 'unknown') {
68
+ config.developer = config.author;
69
+ }
70
+ // Storage dir migration: prefer .teamlens, fallback to .codememory
71
+ const teamlensDir = path.resolve(repoPath, '.teamlens');
72
+ const codememoryDir = path.resolve(repoPath, '.codememory');
73
+ if (!fs.existsSync(teamlensDir) && fs.existsSync(codememoryDir)) {
74
+ // Migrate: rename .codememory to .teamlens
75
+ fs.renameSync(codememoryDir, teamlensDir);
76
+ config.storageDir = '.teamlens';
77
+ }
78
+ const storageDir = path.resolve(repoPath, config.storageDir);
79
+ const db = await MemoryDatabase.create(storageDir);
80
+ return new TeamLens(repoPath, db, config);
81
+ }
82
+ // ── Init ──
83
+ /** Scan the repo and build initial memory from git history. */
84
+ async init(options) {
85
+ const extractFromGit = options?.extractFromGit ?? true;
86
+ let memoriesCreated = 0;
87
+ // Ensure .gitignore has memory.db
88
+ this.ensureGitignore();
89
+ // Import any existing team memories from team.jsonl
90
+ const teamImported = this.team.importFromShared();
91
+ // Track all current files
92
+ const files = await this.git.getTrackedFiles();
93
+ const ignoreMatcher = this.buildIgnoreMatcher();
94
+ for (const file of files) {
95
+ if (ignoreMatcher(file))
96
+ continue;
97
+ const hash = await this.git.getFileHash(file);
98
+ if (hash) {
99
+ this.db.upsertTrackedFile({
100
+ path: file,
101
+ hash,
102
+ lastModified: new Date().toISOString(),
103
+ });
104
+ }
105
+ }
106
+ // Extract memories from recent commits (last 90 days) — only if opted in
107
+ if (extractFromGit) {
108
+ const since = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString();
109
+ const commits = await this.git.getRecentCommits(since);
110
+ for (const commit of commits) {
111
+ commit.files = await this.git.getCommitFiles(commit.sha);
112
+ this.db.upsertCommit(commit);
113
+ const memories = await this.git.extractFromCommit(commit);
114
+ for (const mem of memories) {
115
+ this.db.insertMemory(mem, commit.author, 'team');
116
+ memoriesCreated++;
117
+ }
118
+ this.db.markCommitProcessed(commit.sha);
119
+ }
120
+ // Export git-extracted team memories to team.jsonl
121
+ if (memoriesCreated > 0) {
122
+ this.team.exportToShared();
123
+ }
124
+ // Generate embeddings for all memories
125
+ await this.embedAllMemories();
126
+ }
127
+ const filesTracked = files.filter((f) => !ignoreMatcher(f)).length;
128
+ return { memoriesCreated, filesTracked, teamImported };
129
+ }
130
+ // ── Remember ──
131
+ /** Agent or user stores a new memory (personal by default). */
132
+ async remember(content, category, relatedFiles = [], tags = [], tier = 'personal') {
133
+ const memory = this.db.insertMemory({ content, category, relatedFiles, tags, confidence: 0.9, commitSha: null }, this.config.author, tier);
134
+ // Generate embedding
135
+ const embedding = await this.embeddings.embed(content);
136
+ if (embedding) {
137
+ this.db.updateEmbedding(memory.id, embedding);
138
+ }
139
+ // If team tier, also write to team.jsonl
140
+ if (tier === 'team') {
141
+ this.team.exportToShared();
142
+ }
143
+ return memory.id;
144
+ }
145
+ // ── Rules (Governance) ──
146
+ /** Add a team rule — stored as source='rule', tier='team', confidence=1.0. */
147
+ async addRule(content, category, options) {
148
+ const memory = this.db.insertMemory({ content, category, relatedFiles: [], tags: [], confidence: 1.0, commitSha: null }, this.config.author, 'team');
149
+ // Set rule-specific fields
150
+ const examples = (options?.good || options?.bad)
151
+ ? { good: options?.good, bad: options?.bad }
152
+ : null;
153
+ this.db.updateRuleFields(memory.id, {
154
+ source: 'rule',
155
+ scope: options?.scope ?? null,
156
+ priority: options?.priority ?? 'normal',
157
+ examples,
158
+ });
159
+ // Export to team.jsonl
160
+ this.team.exportToShared();
161
+ return memory.id;
162
+ }
163
+ /** Distribute rules to agent config files. */
164
+ distribute(targets) {
165
+ return this.distributor.distribute(targets);
166
+ }
167
+ // ── Team ──
168
+ /** Promote a personal memory to team (shared with everyone). */
169
+ share(memoryId) {
170
+ return this.team.share(memoryId);
171
+ }
172
+ /** Import new team memories from team.jsonl (call after git pull). */
173
+ syncTeam() {
174
+ const imported = this.team.importFromShared();
175
+ return imported;
176
+ }
177
+ /** Get memories by a specific team member. */
178
+ getByAuthor(author) {
179
+ return this.db.getMemoriesByAuthor(author);
180
+ }
181
+ /** Get all team authors and their memory counts. */
182
+ getTeamAuthors() {
183
+ return this.db.getTeamAuthors();
184
+ }
185
+ /** Find who on the team has context about a topic. */
186
+ async whoKnows(query) {
187
+ const results = await this.retriever.query({ query, limit: 50 });
188
+ const teamResults = results.filter((r) => r.memory.tier === 'team');
189
+ // Group by author
190
+ const authorMap = new Map();
191
+ for (const r of teamResults) {
192
+ const existing = authorMap.get(r.memory.author);
193
+ if (!existing || r.score > existing.topScore) {
194
+ authorMap.set(r.memory.author, {
195
+ count: (existing?.count ?? 0) + 1,
196
+ topMemory: r.memory.content,
197
+ topScore: r.score,
198
+ });
199
+ }
200
+ else {
201
+ existing.count++;
202
+ }
203
+ }
204
+ return Array.from(authorMap.entries())
205
+ .map(([author, data]) => ({
206
+ author,
207
+ memories: data.count,
208
+ topMemory: data.topMemory,
209
+ }))
210
+ .sort((a, b) => b.memories - a.memories);
211
+ }
212
+ // ── Process New Commits ──
213
+ /** Process any unprocessed commits and update staleness. */
214
+ async processNewCommits() {
215
+ // First, import any team memories from team.jsonl (teammate may have pushed)
216
+ const teamImported = this.team.importFromShared();
217
+ const unprocessed = this.db.getUnprocessedCommits();
218
+ let newMemories = 0;
219
+ for (const commit of unprocessed) {
220
+ commit.files = await this.git.getCommitFiles(commit.sha);
221
+ const memories = await this.git.extractFromCommit(commit);
222
+ for (const mem of memories) {
223
+ this.db.insertMemory(mem, commit.author, 'team');
224
+ newMemories++;
225
+ }
226
+ this.db.markCommitProcessed(commit.sha);
227
+ }
228
+ // Check staleness for files changed in these commits
229
+ const changedFiles = unprocessed.flatMap((c) => c.files);
230
+ const uniqueFiles = [...new Set(changedFiles)];
231
+ const checks = await this.staleness.processChangedFiles(uniqueFiles);
232
+ // Export updated team memories
233
+ if (newMemories > 0) {
234
+ this.team.exportToShared();
235
+ }
236
+ // Embed new memories
237
+ await this.embedAllMemories();
238
+ return { newMemories, stalenessUpdates: checks.length, teamImported };
239
+ }
240
+ // ── Query ──
241
+ /** Query memories with multi-signal ranking. */
242
+ async query(queryText, scope, limit, tier) {
243
+ return this.retriever.query({ query: queryText, scope, limit, tier });
244
+ }
245
+ /** Get all conventions. */
246
+ async getConventions() {
247
+ return this.retriever.getConventions();
248
+ }
249
+ /** Get decisions for a scope. */
250
+ async getDecisions(scope) {
251
+ return this.retriever.getDecisions(scope);
252
+ }
253
+ // ── Memory Management ──
254
+ confirm(memoryId) {
255
+ this.db.validateMemory(memoryId);
256
+ }
257
+ markStale(memoryId) {
258
+ this.db.updateStaleness(memoryId, 1.0);
259
+ }
260
+ forget(memoryId) {
261
+ this.db.deleteMemory(memoryId);
262
+ }
263
+ stats() {
264
+ return this.db.getMemoryCount();
265
+ }
266
+ close() {
267
+ this.db.close();
268
+ }
269
+ // ── Private ──
270
+ static detectGitAuthor(repoPath) {
271
+ try {
272
+ return execSync('git config user.name', { cwd: repoPath, encoding: 'utf-8' }).trim() || 'unknown';
273
+ }
274
+ catch {
275
+ return 'unknown';
276
+ }
277
+ }
278
+ /** Ensure .teamlens/memory.db is gitignored but team.jsonl is NOT. */
279
+ ensureGitignore() {
280
+ const gitignorePath = path.join(this.repoPath, this.config.storageDir, '.gitignore');
281
+ const content = '# Local database — gitignored (team sync uses team.jsonl)\nmemory.db\nmemory.db-wal\nmemory.db-shm\nhooks.jsonl\n';
282
+ if (!fs.existsSync(gitignorePath)) {
283
+ fs.mkdirSync(path.dirname(gitignorePath), { recursive: true });
284
+ fs.writeFileSync(gitignorePath, content);
285
+ }
286
+ }
287
+ async embedAllMemories() {
288
+ if (!(await this.embeddings.isAvailable()))
289
+ return;
290
+ const memories = this.db.getAllMemories(true);
291
+ for (const mem of memories) {
292
+ if (mem.embedding)
293
+ continue;
294
+ const embedding = await this.embeddings.embed(mem.content);
295
+ if (embedding) {
296
+ this.db.updateEmbedding(mem.id, embedding);
297
+ }
298
+ }
299
+ }
300
+ buildIgnoreMatcher() {
301
+ const patterns = this.config.ignorePatterns.map((p) => {
302
+ const regex = p
303
+ .replace(/\./g, '\\.')
304
+ .replace(/\*\*/g, '.*')
305
+ .replace(/\*/g, '[^/]*');
306
+ return new RegExp(`^${regex}$`);
307
+ });
308
+ return (filePath) => patterns.some((r) => r.test(filePath));
309
+ }
310
+ }
311
+ /** @deprecated Use TeamLens instead */
312
+ export const CodeMemory = TeamLens;
313
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAA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