@malindar/whyline 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.
- package/.claude/settings.local.json +33 -0
- package/.github/workflows/ci.yml +35 -0
- package/.github/workflows/publish.yml +37 -0
- package/.prettierrc.json +7 -0
- package/CLAUDE.md +74 -0
- package/LICENSE +21 -0
- package/README.md +359 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +125 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/delete.d.ts +3 -0
- package/dist/commands/delete.js +42 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +111 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/edit.d.ts +1 -0
- package/dist/commands/edit.js +78 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/export.d.ts +8 -0
- package/dist/commands/export.js +90 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +1 -0
- package/dist/commands/import.js +110 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +23 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install-claude.d.ts +3 -0
- package/dist/commands/install-claude.js +180 -0
- package/dist/commands/install-claude.js.map +1 -0
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.js +35 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +10 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/save.d.ts +4 -0
- package/dist/commands/save.js +74 -0
- package/dist/commands/save.js.map +1 -0
- package/dist/commands/search.d.ts +7 -0
- package/dist/commands/search.js +46 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/show.d.ts +3 -0
- package/dist/commands/show.js +30 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/stats.d.ts +1 -0
- package/dist/commands/stats.js +27 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/summarize.d.ts +3 -0
- package/dist/commands/summarize.js +140 -0
- package/dist/commands/summarize.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/db/connection.d.ts +2 -0
- package/dist/db/connection.js +8 -0
- package/dist/db/connection.js.map +1 -0
- package/dist/db/migrations.d.ts +2 -0
- package/dist/db/migrations.js +19 -0
- package/dist/db/migrations.js.map +1 -0
- package/dist/db/schema.d.ts +5 -0
- package/dist/db/schema.js +64 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/git/diff.d.ts +2 -0
- package/dist/git/diff.js +45 -0
- package/dist/git/diff.js.map +1 -0
- package/dist/git/git.d.ts +3 -0
- package/dist/git/git.js +25 -0
- package/dist/git/git.js.map +1 -0
- package/dist/git/repoId.d.ts +3 -0
- package/dist/git/repoId.js +49 -0
- package/dist/git/repoId.js.map +1 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.js +296 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +119 -0
- package/dist/mcp/tools.js +43 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/memory/parseSummary.d.ts +14 -0
- package/dist/memory/parseSummary.js +53 -0
- package/dist/memory/parseSummary.js.map +1 -0
- package/dist/memory/qualityCheck.d.ts +13 -0
- package/dist/memory/qualityCheck.js +78 -0
- package/dist/memory/qualityCheck.js.map +1 -0
- package/dist/memory/redactSecrets.d.ts +7 -0
- package/dist/memory/redactSecrets.js +29 -0
- package/dist/memory/redactSecrets.js.map +1 -0
- package/dist/memory/repoContext.d.ts +2 -0
- package/dist/memory/repoContext.js +23 -0
- package/dist/memory/repoContext.js.map +1 -0
- package/dist/memory/saveMemory.d.ts +40 -0
- package/dist/memory/saveMemory.js +223 -0
- package/dist/memory/saveMemory.js.map +1 -0
- package/dist/memory/searchMemory.d.ts +17 -0
- package/dist/memory/searchMemory.js +122 -0
- package/dist/memory/searchMemory.js.map +1 -0
- package/dist/memory/types.d.ts +48 -0
- package/dist/memory/types.js +2 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/output/format.d.ts +3 -0
- package/dist/output/format.js +43 -0
- package/dist/output/format.js.map +1 -0
- package/docs/architecture.md +387 -0
- package/docs/ec6ab3bf-60cf-4629-ad9e-3048e8e3c43a.png +0 -0
- package/docs/logo.png +0 -0
- package/eslint.config.js +16 -0
- package/how-to-run/01-install.md +69 -0
- package/how-to-run/02-wire-up-your-repo.md +80 -0
- package/how-to-run/03-test-it-manually.md +91 -0
- package/how-to-run/04-test-with-claude-code.md +70 -0
- package/how-to-run/CLAUDE.md.template +72 -0
- package/how-to-run/README.md +49 -0
- package/package.json +60 -0
- package/src/cli.ts +142 -0
- package/src/commands/delete.ts +47 -0
- package/src/commands/doctor.ts +128 -0
- package/src/commands/edit.ts +80 -0
- package/src/commands/export.ts +95 -0
- package/src/commands/import.ts +119 -0
- package/src/commands/init.ts +31 -0
- package/src/commands/install-claude.ts +203 -0
- package/src/commands/list.ts +41 -0
- package/src/commands/mcp.ts +12 -0
- package/src/commands/save.ts +85 -0
- package/src/commands/search.ts +56 -0
- package/src/commands/show.ts +37 -0
- package/src/commands/stats.ts +31 -0
- package/src/commands/summarize.ts +183 -0
- package/src/config.ts +26 -0
- package/src/db/connection.ts +8 -0
- package/src/db/migrations.ts +26 -0
- package/src/db/schema.ts +68 -0
- package/src/git/diff.ts +43 -0
- package/src/git/git.ts +25 -0
- package/src/git/repoId.ts +49 -0
- package/src/hooks/post-commit.sample.sh +9 -0
- package/src/mcp/server.ts +326 -0
- package/src/mcp/tools.ts +53 -0
- package/src/memory/parseSummary.ts +72 -0
- package/src/memory/qualityCheck.ts +102 -0
- package/src/memory/redactSecrets.ts +32 -0
- package/src/memory/repoContext.ts +25 -0
- package/src/memory/saveMemory.ts +369 -0
- package/src/memory/searchMemory.ts +153 -0
- package/src/memory/types.ts +57 -0
- package/src/output/format.ts +44 -0
- package/src/skill/SKILL.md +95 -0
- package/tests/cliV02.test.ts +213 -0
- package/tests/doctor.test.ts +253 -0
- package/tests/exportImport.test.ts +248 -0
- package/tests/fileRename.test.ts +156 -0
- package/tests/gitHelpers.test.ts +94 -0
- package/tests/init.test.ts +93 -0
- package/tests/installClaude.test.ts +157 -0
- package/tests/parseSummary.test.ts +111 -0
- package/tests/qualityCheck.test.ts +182 -0
- package/tests/redactSecrets.test.ts +75 -0
- package/tests/saveMemory.test.ts +196 -0
- package/tests/searchFilters.test.ts +139 -0
- package/tests/searchMemory.test.ts +273 -0
- package/tests/stale.test.ts +47 -0
- package/tsconfig.json +18 -0
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const SearchMemoryInput: z.ZodObject<{
|
|
3
|
+
repoPath: z.ZodOptional<z.ZodString>;
|
|
4
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
since: z.ZodOptional<z.ZodString>;
|
|
9
|
+
before: z.ZodOptional<z.ZodString>;
|
|
10
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
query: string;
|
|
13
|
+
limit: number;
|
|
14
|
+
tags?: string[] | undefined;
|
|
15
|
+
files?: string[] | undefined;
|
|
16
|
+
repoId?: string | undefined;
|
|
17
|
+
repoPath?: string | undefined;
|
|
18
|
+
since?: string | undefined;
|
|
19
|
+
before?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
query: string;
|
|
22
|
+
tags?: string[] | undefined;
|
|
23
|
+
files?: string[] | undefined;
|
|
24
|
+
repoId?: string | undefined;
|
|
25
|
+
repoPath?: string | undefined;
|
|
26
|
+
since?: string | undefined;
|
|
27
|
+
before?: string | undefined;
|
|
28
|
+
limit?: number | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare const SaveMemoryInput: z.ZodObject<{
|
|
31
|
+
repoPath: z.ZodOptional<z.ZodString>;
|
|
32
|
+
commitSha: z.ZodOptional<z.ZodString>;
|
|
33
|
+
files: z.ZodArray<z.ZodString, "many">;
|
|
34
|
+
task: z.ZodOptional<z.ZodString>;
|
|
35
|
+
intent: z.ZodString;
|
|
36
|
+
summary: z.ZodString;
|
|
37
|
+
decision: z.ZodString;
|
|
38
|
+
why: z.ZodString;
|
|
39
|
+
alternativesRejected: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
40
|
+
risks: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
followUps: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
43
|
+
source: z.ZodDefault<z.ZodEnum<["manual", "claude-code", "cli", "hook"]>>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
intent: string;
|
|
46
|
+
summary: string;
|
|
47
|
+
decision: string;
|
|
48
|
+
why: string;
|
|
49
|
+
risks: string[];
|
|
50
|
+
tags: string[];
|
|
51
|
+
alternativesRejected: string[];
|
|
52
|
+
followUps: string[];
|
|
53
|
+
files: string[];
|
|
54
|
+
source: "manual" | "claude-code" | "cli" | "hook";
|
|
55
|
+
task?: string | undefined;
|
|
56
|
+
commitSha?: string | undefined;
|
|
57
|
+
repoPath?: string | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
intent: string;
|
|
60
|
+
summary: string;
|
|
61
|
+
decision: string;
|
|
62
|
+
why: string;
|
|
63
|
+
files: string[];
|
|
64
|
+
task?: string | undefined;
|
|
65
|
+
risks?: string[] | undefined;
|
|
66
|
+
tags?: string[] | undefined;
|
|
67
|
+
alternativesRejected?: string[] | undefined;
|
|
68
|
+
followUps?: string[] | undefined;
|
|
69
|
+
commitSha?: string | undefined;
|
|
70
|
+
repoPath?: string | undefined;
|
|
71
|
+
source?: "manual" | "claude-code" | "cli" | "hook" | undefined;
|
|
72
|
+
}>;
|
|
73
|
+
export declare const GetCommitMemoryInput: z.ZodObject<{
|
|
74
|
+
repoPath: z.ZodOptional<z.ZodString>;
|
|
75
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
commitSha: z.ZodString;
|
|
77
|
+
}, "strip", z.ZodTypeAny, {
|
|
78
|
+
commitSha: string;
|
|
79
|
+
repoId?: string | undefined;
|
|
80
|
+
repoPath?: string | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
commitSha: string;
|
|
83
|
+
repoId?: string | undefined;
|
|
84
|
+
repoPath?: string | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
export declare const GetFileMemoriesInput: z.ZodObject<{
|
|
87
|
+
repoPath: z.ZodOptional<z.ZodString>;
|
|
88
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
89
|
+
filePath: z.ZodString;
|
|
90
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
limit: number;
|
|
93
|
+
filePath: string;
|
|
94
|
+
repoId?: string | undefined;
|
|
95
|
+
repoPath?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
filePath: string;
|
|
98
|
+
repoId?: string | undefined;
|
|
99
|
+
repoPath?: string | undefined;
|
|
100
|
+
limit?: number | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
export declare const GetRecentMemoriesInput: z.ZodObject<{
|
|
103
|
+
repoPath: z.ZodOptional<z.ZodString>;
|
|
104
|
+
repoId: z.ZodOptional<z.ZodString>;
|
|
105
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
106
|
+
}, "strip", z.ZodTypeAny, {
|
|
107
|
+
limit: number;
|
|
108
|
+
repoId?: string | undefined;
|
|
109
|
+
repoPath?: string | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
repoId?: string | undefined;
|
|
112
|
+
repoPath?: string | undefined;
|
|
113
|
+
limit?: number | undefined;
|
|
114
|
+
}>;
|
|
115
|
+
export type SearchMemoryInputType = z.infer<typeof SearchMemoryInput>;
|
|
116
|
+
export type SaveMemoryInputType = z.infer<typeof SaveMemoryInput>;
|
|
117
|
+
export type GetCommitMemoryInputType = z.infer<typeof GetCommitMemoryInput>;
|
|
118
|
+
export type GetFileMemoriesInputType = z.infer<typeof GetFileMemoriesInput>;
|
|
119
|
+
export type GetRecentMemoriesInputType = z.infer<typeof GetRecentMemoriesInput>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const SearchMemoryInput = z.object({
|
|
3
|
+
repoPath: z.string().optional(),
|
|
4
|
+
repoId: z.string().optional(),
|
|
5
|
+
query: z.string(),
|
|
6
|
+
files: z.array(z.string()).optional(),
|
|
7
|
+
tags: z.array(z.string()).optional(),
|
|
8
|
+
since: z.string().optional(),
|
|
9
|
+
before: z.string().optional(),
|
|
10
|
+
limit: z.number().int().positive().default(10),
|
|
11
|
+
});
|
|
12
|
+
export const SaveMemoryInput = z.object({
|
|
13
|
+
repoPath: z.string().optional(),
|
|
14
|
+
commitSha: z.string().optional(),
|
|
15
|
+
files: z.array(z.string()),
|
|
16
|
+
task: z.string().optional(),
|
|
17
|
+
intent: z.string(),
|
|
18
|
+
summary: z.string(),
|
|
19
|
+
decision: z.string(),
|
|
20
|
+
why: z.string(),
|
|
21
|
+
alternativesRejected: z.array(z.string()).default([]),
|
|
22
|
+
risks: z.array(z.string()).default([]),
|
|
23
|
+
followUps: z.array(z.string()).default([]),
|
|
24
|
+
tags: z.array(z.string()).default([]),
|
|
25
|
+
source: z.enum(["manual", "claude-code", "cli", "hook"]).default("claude-code"),
|
|
26
|
+
});
|
|
27
|
+
export const GetCommitMemoryInput = z.object({
|
|
28
|
+
repoPath: z.string().optional(),
|
|
29
|
+
repoId: z.string().optional(),
|
|
30
|
+
commitSha: z.string(),
|
|
31
|
+
});
|
|
32
|
+
export const GetFileMemoriesInput = z.object({
|
|
33
|
+
repoPath: z.string().optional(),
|
|
34
|
+
repoId: z.string().optional(),
|
|
35
|
+
filePath: z.string(),
|
|
36
|
+
limit: z.number().int().positive().default(10),
|
|
37
|
+
});
|
|
38
|
+
export const GetRecentMemoriesInput = z.object({
|
|
39
|
+
repoPath: z.string().optional(),
|
|
40
|
+
repoId: z.string().optional(),
|
|
41
|
+
limit: z.number().int().positive().default(5),
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC/C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,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EAAE;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC/C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;CAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ParsedSummary = {
|
|
2
|
+
task?: string;
|
|
3
|
+
intent: string;
|
|
4
|
+
summary: string;
|
|
5
|
+
decision: string;
|
|
6
|
+
why: string;
|
|
7
|
+
alternativesRejected: string[];
|
|
8
|
+
risks: string[];
|
|
9
|
+
followUps: string[];
|
|
10
|
+
tags: string[];
|
|
11
|
+
};
|
|
12
|
+
declare const HEADING_REGEX: RegExp;
|
|
13
|
+
export declare function parseSummary(markdown: string): ParsedSummary;
|
|
14
|
+
export { HEADING_REGEX };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const HEADING_REGEX = /^([A-Za-z][A-Za-z\- ]+):\s*$/m;
|
|
2
|
+
function extractSections(text) {
|
|
3
|
+
const lines = text.split("\n");
|
|
4
|
+
const sections = {};
|
|
5
|
+
let currentHeading = null;
|
|
6
|
+
const buffer = [];
|
|
7
|
+
const flush = () => {
|
|
8
|
+
if (currentHeading !== null) {
|
|
9
|
+
sections[currentHeading] = buffer.join("\n").trim();
|
|
10
|
+
buffer.length = 0;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
const match = line.match(/^([A-Za-z][A-Za-z\- ]+):\s*$/);
|
|
15
|
+
if (match) {
|
|
16
|
+
flush();
|
|
17
|
+
currentHeading = match[1].toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
if (currentHeading !== null) {
|
|
21
|
+
buffer.push(line);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
flush();
|
|
26
|
+
return sections;
|
|
27
|
+
}
|
|
28
|
+
function parseBullets(text) {
|
|
29
|
+
return text
|
|
30
|
+
.split("\n")
|
|
31
|
+
.map((l) => l.replace(/^[-*]\s*/, "").trim())
|
|
32
|
+
.filter(Boolean);
|
|
33
|
+
}
|
|
34
|
+
export function parseSummary(markdown) {
|
|
35
|
+
// Remove markdown h1 title lines before parsing sections
|
|
36
|
+
const text = markdown.replace(/^#[^#].*$/m, "").trim();
|
|
37
|
+
const sections = extractSections(text);
|
|
38
|
+
const get = (key) => sections[key];
|
|
39
|
+
return {
|
|
40
|
+
task: get("task")?.trim() || undefined,
|
|
41
|
+
intent: get("intent")?.trim() || "Unspecified intent",
|
|
42
|
+
summary: get("summary")?.trim() || markdown.trim(),
|
|
43
|
+
decision: get("decision")?.trim() || "Unspecified decision",
|
|
44
|
+
why: get("why")?.trim() || "Unspecified rationale",
|
|
45
|
+
alternativesRejected: parseBullets(get("alternatives rejected") ?? ""),
|
|
46
|
+
risks: parseBullets(get("risks") ?? ""),
|
|
47
|
+
followUps: parseBullets(get("follow-ups") ?? get("follow ups") ?? ""),
|
|
48
|
+
tags: parseBullets(get("tags") ?? ""),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
// Keep HEADING_REGEX exported for potential reuse
|
|
52
|
+
export { HEADING_REGEX };
|
|
53
|
+
//# sourceMappingURL=parseSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseSummary.js","sourceRoot":"","sources":["../../src/memory/parseSummary.ts"],"names":[],"mappings":"AAYA,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAEtD,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,IAAI,cAAc,GAAkB,IAAI,CAAC;IACzC,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,KAAK,GAAG,GAAG,EAAE;QACjB,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;YAC5B,QAAQ,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;YACpD,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACzD,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,EAAE,CAAC;YACR,cAAc,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1C,CAAC;aAAM,CAAC;YACN,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC;IAER,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,IAAI;SACR,KAAK,CAAC,IAAI,CAAC;SACX,GA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AE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { CodingMemory } from "./types.js";
|
|
3
|
+
export type QualityWarning = {
|
|
4
|
+
field: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
export type DuplicateWarning = {
|
|
8
|
+
type: "same-commit" | "similar-intent";
|
|
9
|
+
existingId: string;
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function checkQuality(memory: Pick<CodingMemory, "intent" | "decision" | "why">): QualityWarning[];
|
|
13
|
+
export declare function checkDuplicates(db: Database.Database, memory: Pick<CodingMemory, "repoId" | "commitSha" | "files" | "intent">): DuplicateWarning[];
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getMemoriesByRepoId } from "./saveMemory.js";
|
|
2
|
+
const FILLER_PHRASES = [
|
|
3
|
+
"done", "fixed", "fixed it", "updated", "changed", "refactored",
|
|
4
|
+
"wip", "misc", "test", "testing", "cleanup", "fix", "update",
|
|
5
|
+
"unspecified intent", "unspecified decision", "unspecified rationale",
|
|
6
|
+
];
|
|
7
|
+
const MIN_FIELD_LENGTH = 20;
|
|
8
|
+
export function checkQuality(memory) {
|
|
9
|
+
const warnings = [];
|
|
10
|
+
const checks = [
|
|
11
|
+
{ field: "intent", value: memory.intent },
|
|
12
|
+
{ field: "decision", value: memory.decision },
|
|
13
|
+
{ field: "why", value: memory.why },
|
|
14
|
+
];
|
|
15
|
+
for (const { field, value } of checks) {
|
|
16
|
+
const trimmed = value.trim().toLowerCase();
|
|
17
|
+
if (trimmed.length < MIN_FIELD_LENGTH) {
|
|
18
|
+
warnings.push({
|
|
19
|
+
field,
|
|
20
|
+
message: `"${field}" is very short (${trimmed.length} chars) — future searches may not find this memory`,
|
|
21
|
+
});
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (FILLER_PHRASES.some((phrase) => trimmed === phrase || trimmed.startsWith(phrase + " "))) {
|
|
25
|
+
warnings.push({
|
|
26
|
+
field,
|
|
27
|
+
message: `"${field}" looks like filler text ("${value.trim()}") — consider adding more detail`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return warnings;
|
|
32
|
+
}
|
|
33
|
+
function jaccardSimilarity(a, b) {
|
|
34
|
+
const setA = new Set(a.toLowerCase().split(/\s+/).filter((w) => w.length > 2));
|
|
35
|
+
const setB = new Set(b.toLowerCase().split(/\s+/).filter((w) => w.length > 2));
|
|
36
|
+
if (setA.size === 0 && setB.size === 0)
|
|
37
|
+
return 1;
|
|
38
|
+
if (setA.size === 0 || setB.size === 0)
|
|
39
|
+
return 0;
|
|
40
|
+
const intersection = [...setA].filter((w) => setB.has(w)).length;
|
|
41
|
+
const union = new Set([...setA, ...setB]).size;
|
|
42
|
+
return intersection / union;
|
|
43
|
+
}
|
|
44
|
+
export function checkDuplicates(db, memory) {
|
|
45
|
+
const warnings = [];
|
|
46
|
+
const existing = getMemoriesByRepoId(db, memory.repoId);
|
|
47
|
+
// Same commit SHA
|
|
48
|
+
if (memory.commitSha) {
|
|
49
|
+
const sameCommit = existing.find((m) => m.commitSha === memory.commitSha);
|
|
50
|
+
if (sameCommit) {
|
|
51
|
+
warnings.push({
|
|
52
|
+
type: "same-commit",
|
|
53
|
+
existingId: sameCommit.id,
|
|
54
|
+
message: `A memory already exists for commit ${memory.commitSha.slice(0, 8)} (${sameCommit.id}) — saving anyway but you may want to delete the old one`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Similar intent + overlapping files
|
|
59
|
+
const fileSet = new Set(memory.files);
|
|
60
|
+
for (const m of existing) {
|
|
61
|
+
if (memory.commitSha && m.commitSha === memory.commitSha)
|
|
62
|
+
continue; // already caught above
|
|
63
|
+
const fileOverlap = m.files.filter((f) => fileSet.has(f)).length;
|
|
64
|
+
if (fileOverlap === 0)
|
|
65
|
+
continue;
|
|
66
|
+
const similarity = jaccardSimilarity(memory.intent, m.intent);
|
|
67
|
+
if (similarity >= 0.4) {
|
|
68
|
+
warnings.push({
|
|
69
|
+
type: "similar-intent",
|
|
70
|
+
existingId: m.id,
|
|
71
|
+
message: `A similar memory exists (${m.id}) with ${Math.round(similarity * 100)}% intent similarity on the same files — consider editing it instead`,
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return warnings;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=qualityCheck.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qualityCheck.js","sourceRoot":"","sources":["../../src/memory/qualityCheck.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,cAAc,GAAG;IACrB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY;IAC/D,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ;IAC5D,oBAAoB,EAAE,sBAAsB,EAAE,uBAAuB;CACtE,CAAC;AAEF,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAa5B,MAAM,UAAU,YAAY,CAAC,MAAyD;IACpF,MAAM,QAAQ,GAAqB,EAAE,CAAC;IAEtC,MAAM,MAAM,GAA4C;QACtD,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QACzC,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE;QAC7C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE;KACpC,CAAC;IAEF,KAAK,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,C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C,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACjE,IAAI,WAAW,KAAK,CAAC;YAAE,SAAS;QAChC,MAAM,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;QAC9D,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;YACtB,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,gBAAgB;gBACtB,UAAU,EAAE,CAAC,CAAC,EAAE;gBAChB,OAAO,EAAE,4BAA4B,CAAC,CAAC,EAAE,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,GAAG,CAAC,qEAAqE;aACrJ,CAAC,CAAC;YACH,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const SECRET_PATTERNS = [
|
|
2
|
+
{ name: "github_token", pattern: /ghp_[A-Za-z0-9]{36}/g },
|
|
3
|
+
{ name: "github_oauth", pattern: /gho_[A-Za-z0-9]{36}/g },
|
|
4
|
+
{ name: "github_app_token", pattern: /ghs_[A-Za-z0-9]{36}/g },
|
|
5
|
+
{ name: "npm_token", pattern: /npm_[A-Za-z0-9]{36}/g },
|
|
6
|
+
{ name: "aws_access_key", pattern: /AKIA[0-9A-Z]{16}/g },
|
|
7
|
+
{
|
|
8
|
+
name: "bearer_token",
|
|
9
|
+
pattern: /\bBearer\s+[A-Za-z0-9\-._~+/]+=*/gi,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "dotenv_secret",
|
|
13
|
+
pattern: /(?:API_KEY|SECRET|TOKEN|PASSWORD|PRIVATE_KEY|ACCESS_KEY|AUTH_KEY)\s*=\s*\S+/gi,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "private_key_block",
|
|
17
|
+
pattern: /-----BEGIN [A-Z ]+PRIVATE KEY-----[\s\S]*?-----END [A-Z ]+PRIVATE KEY-----/g,
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
export function redactSecrets(input) {
|
|
21
|
+
let output = input;
|
|
22
|
+
for (const { pattern } of SECRET_PATTERNS) {
|
|
23
|
+
// Reset lastIndex for global regexes to avoid stateful bugs
|
|
24
|
+
pattern.lastIndex = 0;
|
|
25
|
+
output = output.replace(pattern, "[REDACTED_SECRET]");
|
|
26
|
+
}
|
|
27
|
+
return output;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=redactSecrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redactSecrets.js","sourceRoot":"","sources":["../../src/memory/redactSecrets.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,sBAAsB,EAAE;IACzD,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,sBAAsB,EAAE;IACzD,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,sBAAsB,EAAE;IAC7D,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,sBAAsB,EAAE;IACtD,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE;IACxD;QACE,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,oCAAoC;KAC9C;IACD;QACE,IAAI,EAAE,eAAe;QACrB,OAAO,EACL,+EAA+E;KAClF;IACD;QACE,IAAI,EAAE,mBAAmB;QACzB,OAAO,EAAE,6EAA6E;KACvF;CACF,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,KAAK,MAAM,EAAE,OAAO,EAAE,IAAI,eAAe,EAAE,CAAC;QAC1C,4DAA4D;QAC5D,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;QACtB,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getRepoRoot, getCurrentBranch, resolveCommit } from "../git/git.js";
|
|
2
|
+
import { getRepoId, getRepoName } from "../git/repoId.js";
|
|
3
|
+
import { getChangedFilesForCommit } from "../git/diff.js";
|
|
4
|
+
export function getRepoContext(cwd, commitRef) {
|
|
5
|
+
const repoRoot = getRepoRoot(cwd);
|
|
6
|
+
if (!repoRoot)
|
|
7
|
+
throw new Error("Not inside a git repository");
|
|
8
|
+
const commitSha = resolveCommit(repoRoot, commitRef);
|
|
9
|
+
const repoId = getRepoId(repoRoot);
|
|
10
|
+
const repoName = getRepoName(repoRoot);
|
|
11
|
+
const branch = getCurrentBranch(repoRoot);
|
|
12
|
+
const changedFiles = getChangedFilesForCommit(repoRoot, commitSha);
|
|
13
|
+
return {
|
|
14
|
+
repoRoot,
|
|
15
|
+
repoId,
|
|
16
|
+
repoPath: repoRoot,
|
|
17
|
+
repoName,
|
|
18
|
+
branch,
|
|
19
|
+
commitSha,
|
|
20
|
+
changedFiles,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=repoContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repoContext.js","sourceRoot":"","sources":["../../src/memory/repoContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAG1D,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,SAAiB;IAC3D,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAE9D,MAAM,SAAS,GAAG,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,wBAAwB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEnE,OAAO;QACL,QAAQ;QACR,MAAM;QACN,QAAQ,EAAE,QAAQ;QAClB,QAAQ;QACR,MAAM;QACN,SAAS;QACT,YAAY;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type Database from "better-sqlite3";
|
|
2
|
+
import type { CodingMemory } from "./types.js";
|
|
3
|
+
export declare function generateMemoryId(): string;
|
|
4
|
+
export declare function buildEmbeddingText(memory: Pick<CodingMemory, "intent" | "summary" | "decision" | "why" | "alternativesRejected" | "risks" | "followUps" | "tags" | "files" | "commitSha">): string;
|
|
5
|
+
export declare function saveMemory(db: Database.Database, memory: CodingMemory): void;
|
|
6
|
+
export declare function getMemoryById(db: Database.Database, id: string): CodingMemory | null;
|
|
7
|
+
export declare function getMemoryByCommit(db: Database.Database, commitSha: string): CodingMemory | null;
|
|
8
|
+
export declare function getMemoriesByCommit(db: Database.Database, commitSha: string): CodingMemory[];
|
|
9
|
+
export declare function getMemoriesByFile(db: Database.Database, repoId: string | null, filePaths: string | string[], limit: number): CodingMemory[];
|
|
10
|
+
export declare function getAllMemories(db: Database.Database): CodingMemory[];
|
|
11
|
+
export declare function getMemoriesByRepoId(db: Database.Database, repoId: string): CodingMemory[];
|
|
12
|
+
export declare function getMemoriesByRepoPath(db: Database.Database, repoPath: string): CodingMemory[];
|
|
13
|
+
export declare function listMemories(db: Database.Database, options: {
|
|
14
|
+
repoId?: string;
|
|
15
|
+
limit: number;
|
|
16
|
+
}): CodingMemory[];
|
|
17
|
+
export declare function deleteMemory(db: Database.Database, id: string): void;
|
|
18
|
+
export type MemoryStats = {
|
|
19
|
+
total: number;
|
|
20
|
+
repos: number;
|
|
21
|
+
oldest: string;
|
|
22
|
+
newest: string;
|
|
23
|
+
topFiles: {
|
|
24
|
+
filePath: string;
|
|
25
|
+
count: number;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
export declare function getStats(db: Database.Database): MemoryStats;
|
|
29
|
+
export declare function updateMemory(db: Database.Database, id: string, updates: {
|
|
30
|
+
intent?: string;
|
|
31
|
+
summary?: string;
|
|
32
|
+
decision?: string;
|
|
33
|
+
why?: string;
|
|
34
|
+
task?: string;
|
|
35
|
+
alternativesRejected?: string[];
|
|
36
|
+
risks?: string[];
|
|
37
|
+
followUps?: string[];
|
|
38
|
+
tags?: string[];
|
|
39
|
+
embeddingText?: string;
|
|
40
|
+
}): void;
|