cadr-cli 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adr/adr.d.ts +17 -0
- package/dist/adr/adr.d.ts.map +1 -0
- package/dist/{adr.js → adr/adr.js} +4 -44
- package/dist/adr/adr.js.map +1 -0
- package/dist/adr/adr.test.d.ts +5 -0
- package/dist/{adr.test.d.ts.map → adr/adr.test.d.ts.map} +1 -1
- package/dist/{adr.test.js → adr/adr.test.js} +0 -14
- package/dist/adr/adr.test.js.map +1 -0
- package/dist/adr/index.d.ts +2 -0
- package/dist/adr/index.d.ts.map +1 -0
- package/dist/adr/index.js +18 -0
- package/dist/adr/index.js.map +1 -0
- package/dist/analysis/analysis.orchestrator.d.ts +14 -0
- package/dist/analysis/analysis.orchestrator.d.ts.map +1 -0
- package/dist/analysis/analysis.orchestrator.js +175 -0
- package/dist/analysis/analysis.orchestrator.js.map +1 -0
- package/dist/analysis/strategies/git-strategy.d.ts +22 -0
- package/dist/analysis/strategies/git-strategy.d.ts.map +1 -0
- package/dist/analysis/strategies/git-strategy.js +114 -0
- package/dist/analysis/strategies/git-strategy.js.map +1 -0
- package/dist/commands/analyze.js +3 -3
- package/dist/commands/analyze.js.map +1 -1
- package/dist/git/git.errors.d.ts +6 -0
- package/dist/git/git.errors.d.ts.map +1 -0
- package/dist/git/git.errors.js +15 -0
- package/dist/git/git.errors.js.map +1 -0
- package/dist/git/git.operations.d.ts +12 -0
- package/dist/git/git.operations.d.ts.map +1 -0
- package/dist/git/git.operations.js +64 -0
- package/dist/git/git.operations.js.map +1 -0
- package/dist/git/index.d.ts +4 -0
- package/dist/git/index.d.ts.map +1 -0
- package/dist/git/index.js +19 -0
- package/dist/git/index.js.map +1 -0
- package/dist/llm/index.d.ts +3 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +19 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm.d.ts +35 -0
- package/dist/llm/llm.d.ts.map +1 -0
- package/dist/{llm.js → llm/llm.js} +16 -58
- package/dist/llm/llm.js.map +1 -0
- package/dist/{prompts.d.ts → llm/prompts.d.ts} +1 -38
- package/dist/llm/prompts.d.ts.map +1 -0
- package/dist/{prompts.js → llm/prompts.js} +9 -54
- package/dist/llm/prompts.js.map +1 -0
- package/dist/llm/response-parser.d.ts +9 -0
- package/dist/llm/response-parser.d.ts.map +1 -0
- package/dist/llm/response-parser.js +67 -0
- package/dist/llm/response-parser.js.map +1 -0
- package/dist/presenters/console-presenter.d.ts +35 -0
- package/dist/presenters/console-presenter.d.ts.map +1 -0
- package/dist/presenters/console-presenter.js +114 -0
- package/dist/presenters/console-presenter.js.map +1 -0
- package/package.json +1 -1
- package/src/{adr.test.ts → adr/adr.test.ts} +10 -23
- package/src/{adr.ts → adr/adr.ts} +7 -48
- package/src/adr/index.ts +1 -0
- package/src/analysis/analysis.orchestrator.ts +175 -0
- package/src/analysis/strategies/git-strategy.ts +106 -0
- package/src/commands/analyze.ts +8 -9
- package/src/git/git.errors.ts +10 -0
- package/src/git/git.operations.ts +85 -0
- package/src/git/index.ts +3 -0
- package/src/llm/index.ts +2 -0
- package/src/{llm.ts → llm/llm.ts} +46 -107
- package/src/{prompts.ts → llm/prompts.ts} +30 -72
- package/src/llm/response-parser.ts +90 -0
- package/src/presenters/console-presenter.ts +152 -0
- package/dist/adr.d.ts +0 -50
- package/dist/adr.d.ts.map +0 -1
- package/dist/adr.js.map +0 -1
- package/dist/adr.test.d.ts +0 -8
- package/dist/adr.test.js.map +0 -1
- package/dist/analysis.d.ts +0 -24
- package/dist/analysis.d.ts.map +0 -1
- package/dist/analysis.js +0 -281
- package/dist/analysis.js.map +0 -1
- package/dist/analysis.test.d.ts +0 -8
- package/dist/analysis.test.d.ts.map +0 -1
- package/dist/analysis.test.js +0 -351
- package/dist/analysis.test.js.map +0 -1
- package/dist/git.d.ts +0 -54
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -204
- package/dist/git.js.map +0 -1
- package/dist/llm.d.ts +0 -73
- package/dist/llm.d.ts.map +0 -1
- package/dist/llm.js.map +0 -1
- package/dist/llm.test.d.ts +0 -2
- package/dist/llm.test.d.ts.map +0 -1
- package/dist/llm.test.js +0 -592
- package/dist/llm.test.js.map +0 -1
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js.map +0 -1
- package/dist/prompts.test.d.ts +0 -2
- package/dist/prompts.test.d.ts.map +0 -1
- package/dist/prompts.test.js +0 -427
- package/dist/prompts.test.js.map +0 -1
- package/src/analysis.test.ts +0 -396
- package/src/analysis.ts +0 -262
- package/src/git.ts +0 -300
- package/src/llm.test.ts +0 -701
- package/src/prompts.test.ts +0 -515
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/commands/analyze.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAYH,wCAqCC;AA/CD,
|
|
1
|
+
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../src/commands/analyze.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAYH,wCAqCC;AA/CD,6EAAgE;AAEhE,sCAAqD;AAErD;;;;;GAKG;AACI,KAAK,UAAU,cAAc,CAAC,OAAiB,EAAE;IACtD,IAAI,CAAC;QACH,qDAAqD;QACrD,MAAM,WAAW,GAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,6BAA6B;QAE/E,mDAAmD;QACnD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzC,IAAI,SAAS,KAAK,CAAC,CAAC,IAAI,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YACpD,WAAW,CAAC,IAAI,GAAG,aAAa,CAAC;YACjC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;YAEvC,iCAAiC;YACjC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,SAAS,KAAK,CAAC,CAAC,IAAI,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;gBACpD,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;YACzC,CAAC;QACH,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACrC,WAAW,CAAC,IAAI,GAAG,QAAQ,CAAC;QAC9B,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,WAAW,CAAC,IAAI,GAAG,KAAK,CAAC;QAC3B,CAAC;QAED,uBAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE;YACrC,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,IAAI,EAAE,WAAW,CAAC,IAAI;SACvB,CAAC,CAAC;QACH,MAAM,IAAA,mCAAW,EAAC,WAAW,CAAC,CAAC;QAC/B,uBAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uCAAuC;QACvC,uBAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAClD,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAC7C,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare class GitError extends Error {
|
|
2
|
+
readonly code: 'NOT_GIT_REPO' | 'GIT_NOT_FOUND' | 'GIT_ERROR';
|
|
3
|
+
readonly originalError?: Error | undefined;
|
|
4
|
+
constructor(message: string, code: 'NOT_GIT_REPO' | 'GIT_NOT_FOUND' | 'GIT_ERROR', originalError?: Error | undefined);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=git.errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.errors.d.ts","sourceRoot":"","sources":["../../src/git/git.errors.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;aAGf,IAAI,EAAE,cAAc,GAAG,eAAe,GAAG,WAAW;aACpD,aAAa,CAAC,EAAE,KAAK;gBAFrC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,cAAc,GAAG,eAAe,GAAG,WAAW,EACpD,aAAa,CAAC,EAAE,KAAK,YAAA;CAKxC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GitError = void 0;
|
|
4
|
+
class GitError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
originalError;
|
|
7
|
+
constructor(message, code, originalError) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.originalError = originalError;
|
|
11
|
+
this.name = 'GitError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.GitError = GitError;
|
|
15
|
+
//# sourceMappingURL=git.errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.errors.js","sourceRoot":"","sources":["../../src/git/git.errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IAGf;IACA;IAHlB,YACE,OAAe,EACC,IAAoD,EACpD,aAAqB;QAErC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAgD;QACpD,kBAAa,GAAb,aAAa,CAAQ;QAGrC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AATD,4BASC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface DiffOptions {
|
|
2
|
+
mode: 'staged' | 'all' | 'branch-diff';
|
|
3
|
+
base?: string;
|
|
4
|
+
head?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function getStagedFiles(): Promise<string[]>;
|
|
7
|
+
export declare function getStagedDiff(): Promise<string>;
|
|
8
|
+
export declare function getAllChanges(): Promise<string[]>;
|
|
9
|
+
export declare function getAllDiff(): Promise<string>;
|
|
10
|
+
export declare function getChangedFiles(options: DiffOptions): Promise<string[]>;
|
|
11
|
+
export declare function getDiff(options: DiffOptions): Promise<string>;
|
|
12
|
+
//# sourceMappingURL=git.operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.operations.d.ts","sourceRoot":"","sources":["../../src/git/git.operations.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,aAAa,CAAC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA4CD,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAGxD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAErD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAGvD;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAElD;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAK7E;AAED,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAKnE"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStagedFiles = getStagedFiles;
|
|
4
|
+
exports.getStagedDiff = getStagedDiff;
|
|
5
|
+
exports.getAllChanges = getAllChanges;
|
|
6
|
+
exports.getAllDiff = getAllDiff;
|
|
7
|
+
exports.getChangedFiles = getChangedFiles;
|
|
8
|
+
exports.getDiff = getDiff;
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
const git_errors_1 = require("./git.errors");
|
|
12
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
13
|
+
function handleGitError(error, operation) {
|
|
14
|
+
const errorWithCode = error;
|
|
15
|
+
if (errorWithCode.code === 128) {
|
|
16
|
+
throw new git_errors_1.GitError(`Not in a Git repository. Please run 'cadr' from within a Git repository.`, 'NOT_GIT_REPO', error instanceof Error ? error : new Error(String(error)));
|
|
17
|
+
}
|
|
18
|
+
if (errorWithCode.code === 127) {
|
|
19
|
+
throw new git_errors_1.GitError('Git is not installed. Please install Git and try again.', 'GIT_NOT_FOUND', error instanceof Error ? error : new Error(String(error)));
|
|
20
|
+
}
|
|
21
|
+
throw new git_errors_1.GitError(`Unable to ${operation}. Please check repository permissions.`, 'GIT_ERROR', error instanceof Error ? error : new Error(String(error)));
|
|
22
|
+
}
|
|
23
|
+
async function execGitCommand(command) {
|
|
24
|
+
try {
|
|
25
|
+
const { stdout } = await execAsync(command);
|
|
26
|
+
return stdout;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
handleGitError(error, command.split(' ')[1] || 'execute git command');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function parseFileList(stdout) {
|
|
33
|
+
return stdout
|
|
34
|
+
.split('\n')
|
|
35
|
+
.map((file) => file.trim())
|
|
36
|
+
.filter((file) => file.length > 0);
|
|
37
|
+
}
|
|
38
|
+
async function getStagedFiles() {
|
|
39
|
+
const stdout = await execGitCommand('git diff --cached --name-only');
|
|
40
|
+
return parseFileList(stdout);
|
|
41
|
+
}
|
|
42
|
+
async function getStagedDiff() {
|
|
43
|
+
return execGitCommand('git diff --cached --unified=1');
|
|
44
|
+
}
|
|
45
|
+
async function getAllChanges() {
|
|
46
|
+
const stdout = await execGitCommand('git diff HEAD --name-only');
|
|
47
|
+
return parseFileList(stdout);
|
|
48
|
+
}
|
|
49
|
+
async function getAllDiff() {
|
|
50
|
+
return execGitCommand('git diff HEAD --unified=1');
|
|
51
|
+
}
|
|
52
|
+
async function getChangedFiles(options) {
|
|
53
|
+
if (options.mode === 'staged') {
|
|
54
|
+
return getStagedFiles();
|
|
55
|
+
}
|
|
56
|
+
return getAllChanges();
|
|
57
|
+
}
|
|
58
|
+
async function getDiff(options) {
|
|
59
|
+
if (options.mode === 'staged') {
|
|
60
|
+
return getStagedDiff();
|
|
61
|
+
}
|
|
62
|
+
return getAllDiff();
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=git.operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.operations.js","sourceRoot":"","sources":["../../src/git/git.operations.ts"],"names":[],"mappings":";;AAsDA,wCAGC;AAED,sCAEC;AAED,sCAGC;AAED,gCAEC;AAED,0CAKC;AAED,0BAKC;AApFD,iDAAqC;AACrC,+BAAiC;AACjC,6CAAwC;AAExC,MAAM,SAAS,GAAG,IAAA,gBAAS,EAAC,oBAAI,CAAC,CAAC;AAQlC,SAAS,cAAc,CAAC,KAAc,EAAE,SAAiB;IACvD,MAAM,aAAa,GAAG,KAA0B,CAAC;IAEjD,IAAI,aAAa,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;QAC/B,MAAM,IAAI,qBAAQ,CAChB,0EAA0E,EAC1E,cAAc,EACd,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;IACJ,CAAC;IAED,IAAI,aAAa,CAAC,IAAI,KAAK,GAAG,EAAE,CAAC;QAC/B,MAAM,IAAI,qBAAQ,CAChB,yDAAyD,EACzD,eAAe,EACf,KAAK,YAAY,KAAK,CAAC,CA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AAC,CAAC;AAC/B,CAAC;AAEM,KAAK,UAAU,UAAU;IAC9B,OAAO,cAAc,CAAC,2BAA2B,CAAC,CAAC;AACrD,CAAC;AAEM,KAAK,UAAU,eAAe,CAAC,OAAoB;IACxD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,cAAc,EAAE,CAAC;IAC1B,CAAC;IACD,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC;AAEM,KAAK,UAAU,OAAO,CAAC,OAAoB;IAChD,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,aAAa,EAAE,CAAC;IACzB,CAAC;IACD,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./git.errors"), exports);
|
|
18
|
+
__exportStar(require("./git.operations"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/git/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,mDAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./llm"), exports);
|
|
18
|
+
__exportStar(require("./prompts"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAsB;AACtB,4CAA0B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AnalysisConfig } from '../config';
|
|
2
|
+
export interface AnalysisRequest {
|
|
3
|
+
file_paths: string[];
|
|
4
|
+
diff_content: string;
|
|
5
|
+
repository_context: string;
|
|
6
|
+
analysis_prompt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AnalysisResult {
|
|
9
|
+
is_significant: boolean;
|
|
10
|
+
reason: string;
|
|
11
|
+
confidence?: number;
|
|
12
|
+
timestamp: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AnalysisResponse {
|
|
15
|
+
result: AnalysisResult | null;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface GenerationRequest {
|
|
19
|
+
file_paths: string[];
|
|
20
|
+
diff_content: string;
|
|
21
|
+
reason: string;
|
|
22
|
+
generation_prompt: string;
|
|
23
|
+
}
|
|
24
|
+
export interface GenerationResult {
|
|
25
|
+
content: string;
|
|
26
|
+
title: string;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
}
|
|
29
|
+
export interface GenerationResponse {
|
|
30
|
+
result: GenerationResult | null;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function analyzeChanges(config: AnalysisConfig, request: AnalysisRequest): Promise<AnalysisResponse>;
|
|
34
|
+
export declare function generateADRContent(config: AnalysisConfig, request: GenerationRequest): Promise<GenerationResponse>;
|
|
35
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAMD,wBAAsB,cAAc,CAClC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAoJ3B;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAiF7B"}
|
|
@@ -1,32 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* LLM Client Module
|
|
4
|
-
*
|
|
5
|
-
* Provider-based wrapper for analyzing code changes.
|
|
6
|
-
* Implements fail-open error handling per constitution requirements.
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.analyzeChanges = analyzeChanges;
|
|
10
4
|
exports.generateADRContent = generateADRContent;
|
|
11
|
-
const providers_1 = require("
|
|
12
|
-
const logger_1 = require("
|
|
13
|
-
/**
|
|
14
|
-
* Rough token estimation (1 token ≈ 4 characters for English text)
|
|
15
|
-
* This is a conservative estimate
|
|
16
|
-
*/
|
|
5
|
+
const providers_1 = require("../providers");
|
|
6
|
+
const logger_1 = require("../logger");
|
|
17
7
|
function estimateTokens(text) {
|
|
18
8
|
return Math.ceil(text.length / 4);
|
|
19
9
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Analyze staged changes using OpenAI LLM
|
|
22
|
-
*
|
|
23
|
-
* @param config - Analysis configuration with API settings
|
|
24
|
-
* @param request - Analysis request with code changes
|
|
25
|
-
* @returns Promise resolving to analysis response with result or error
|
|
26
|
-
*/
|
|
27
10
|
async function analyzeChanges(config, request) {
|
|
28
11
|
try {
|
|
29
|
-
// Check if API key is available
|
|
30
12
|
const apiKey = process.env[config.api_key_env];
|
|
31
13
|
if (!apiKey) {
|
|
32
14
|
logger_1.loggerInstance.warn('API key not found in environment', {
|
|
@@ -34,10 +16,9 @@ async function analyzeChanges(config, request) {
|
|
|
34
16
|
});
|
|
35
17
|
return {
|
|
36
18
|
result: null,
|
|
37
|
-
error: `API key not found: ${config.api_key_env} environment variable is not set
|
|
19
|
+
error: `API key not found: ${config.api_key_env} environment variable is not set`,
|
|
38
20
|
};
|
|
39
21
|
}
|
|
40
|
-
// Estimate tokens for logging and validation
|
|
41
22
|
const estimatedTokens = estimateTokens(request.analysis_prompt);
|
|
42
23
|
logger_1.loggerInstance.info('Sending analysis request to LLM', {
|
|
43
24
|
provider: config.provider,
|
|
@@ -45,7 +26,6 @@ async function analyzeChanges(config, request) {
|
|
|
45
26
|
file_count: request.file_paths.length,
|
|
46
27
|
estimated_tokens: estimatedTokens,
|
|
47
28
|
});
|
|
48
|
-
// Warn if token estimate is high (most models have 8k-32k limits)
|
|
49
29
|
if (estimatedTokens > 7000) {
|
|
50
30
|
logger_1.loggerInstance.warn('High token count detected', {
|
|
51
31
|
estimated_tokens: estimatedTokens,
|
|
@@ -63,20 +43,16 @@ async function analyzeChanges(config, request) {
|
|
|
63
43
|
logger_1.loggerInstance.warn('No response content from LLM', { provider: config.provider });
|
|
64
44
|
return {
|
|
65
45
|
result: null,
|
|
66
|
-
error: 'No response content from LLM'
|
|
46
|
+
error: 'No response content from LLM',
|
|
67
47
|
};
|
|
68
48
|
}
|
|
69
|
-
// Parse JSON response - handle markdown-wrapped JSON
|
|
70
49
|
let parsedResponse;
|
|
71
50
|
try {
|
|
72
|
-
// Try to extract JSON from markdown code blocks if present
|
|
73
51
|
let jsonContent = responseContent.trim();
|
|
74
|
-
// Remove markdown code block if present: ```json ... ``` or ``` ... ```
|
|
75
52
|
const codeBlockMatch = jsonContent.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
76
53
|
if (codeBlockMatch) {
|
|
77
54
|
jsonContent = codeBlockMatch[1].trim();
|
|
78
55
|
}
|
|
79
|
-
// Try to find JSON object if there's surrounding text
|
|
80
56
|
const jsonMatch = jsonContent.match(/\{[\s\S]*\}/);
|
|
81
57
|
if (jsonMatch) {
|
|
82
58
|
jsonContent = jsonMatch[0];
|
|
@@ -90,10 +66,9 @@ async function analyzeChanges(config, request) {
|
|
|
90
66
|
});
|
|
91
67
|
return {
|
|
92
68
|
result: null,
|
|
93
|
-
error: `Failed to parse LLM response as JSON. Response was:\n${responseContent.substring(0, 200)}
|
|
69
|
+
error: `Failed to parse LLM response as JSON. Response was:\n${responseContent.substring(0, 200)}...`,
|
|
94
70
|
};
|
|
95
71
|
}
|
|
96
|
-
// Validate response format
|
|
97
72
|
if (typeof parsedResponse.is_significant !== 'boolean' ||
|
|
98
73
|
typeof parsedResponse.reason !== 'string') {
|
|
99
74
|
logger_1.loggerInstance.warn('Invalid response format from LLM', {
|
|
@@ -101,26 +76,23 @@ async function analyzeChanges(config, request) {
|
|
|
101
76
|
});
|
|
102
77
|
return {
|
|
103
78
|
result: null,
|
|
104
|
-
error: `Invalid response format from LLM. Expected {is_significant: boolean, reason: string}, got: ${JSON.stringify(parsedResponse).substring(0, 150)}
|
|
79
|
+
error: `Invalid response format from LLM. Expected {is_significant: boolean, reason: string}, got: ${JSON.stringify(parsedResponse).substring(0, 150)}...`,
|
|
105
80
|
};
|
|
106
81
|
}
|
|
107
|
-
// Reason is required when is_significant is true, but can be empty when false
|
|
108
82
|
if (parsedResponse.is_significant && !parsedResponse.reason) {
|
|
109
83
|
logger_1.loggerInstance.warn('Missing reason for significant change', {
|
|
110
84
|
response: parsedResponse,
|
|
111
85
|
});
|
|
112
86
|
return {
|
|
113
87
|
result: null,
|
|
114
|
-
error: 'LLM indicated significant change but provided no reason'
|
|
88
|
+
error: 'LLM indicated significant change but provided no reason',
|
|
115
89
|
};
|
|
116
90
|
}
|
|
117
|
-
// Build result with timestamp
|
|
118
91
|
const result = {
|
|
119
92
|
is_significant: parsedResponse.is_significant,
|
|
120
93
|
reason: parsedResponse.reason,
|
|
121
94
|
timestamp: new Date().toISOString(),
|
|
122
95
|
};
|
|
123
|
-
// Include confidence if provided
|
|
124
96
|
if (typeof parsedResponse.confidence === 'number' &&
|
|
125
97
|
parsedResponse.confidence >= 0 &&
|
|
126
98
|
parsedResponse.confidence <= 1) {
|
|
@@ -133,21 +105,19 @@ async function analyzeChanges(config, request) {
|
|
|
133
105
|
return { result, error: undefined };
|
|
134
106
|
}
|
|
135
107
|
catch (error) {
|
|
136
|
-
// Fail-open: log error and return descriptive error message
|
|
137
108
|
const errorObj = error;
|
|
138
109
|
let errorMessage;
|
|
139
|
-
// Check for specific error types and provide helpful messages
|
|
140
110
|
if (errorObj.status === 401) {
|
|
141
111
|
errorMessage = 'Invalid API key - please check your API key configuration';
|
|
142
112
|
logger_1.loggerInstance.warn('LLM API authentication failed', { error: errorObj });
|
|
143
113
|
}
|
|
144
114
|
else if (errorObj.status === 400 && errorObj.message?.includes('maximum context length')) {
|
|
145
|
-
// Extract token counts from error message if available
|
|
146
115
|
const tokenMatch = errorObj.message.match(/(\d+)\s+tokens/g);
|
|
147
|
-
errorMessage =
|
|
148
|
-
'
|
|
149
|
-
|
|
150
|
-
|
|
116
|
+
errorMessage =
|
|
117
|
+
'Diff too large for model context window. Try:\n' +
|
|
118
|
+
' • Stage fewer files at once\n' +
|
|
119
|
+
' • Use a model with larger context window in cadr.yaml\n' +
|
|
120
|
+
' • Add ignore patterns to filter large files';
|
|
151
121
|
logger_1.loggerInstance.warn('LLM context length exceeded', {
|
|
152
122
|
error: errorObj,
|
|
153
123
|
tokens: tokenMatch,
|
|
@@ -172,16 +142,8 @@ async function analyzeChanges(config, request) {
|
|
|
172
142
|
return { result: null, error: errorMessage };
|
|
173
143
|
}
|
|
174
144
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Generate ADR content using LLM
|
|
177
|
-
*
|
|
178
|
-
* @param config - Analysis configuration with API settings
|
|
179
|
-
* @param request - Generation request with code changes
|
|
180
|
-
* @returns Promise resolving to generation response with result or error
|
|
181
|
-
*/
|
|
182
145
|
async function generateADRContent(config, request) {
|
|
183
146
|
try {
|
|
184
|
-
// Check if API key is available
|
|
185
147
|
const apiKey = process.env[config.api_key_env];
|
|
186
148
|
if (!apiKey) {
|
|
187
149
|
logger_1.loggerInstance.warn('API key not found in environment for generation', {
|
|
@@ -189,7 +151,7 @@ async function generateADRContent(config, request) {
|
|
|
189
151
|
});
|
|
190
152
|
return {
|
|
191
153
|
result: null,
|
|
192
|
-
error: `API key not found: ${config.api_key_env} environment variable is not set
|
|
154
|
+
error: `API key not found: ${config.api_key_env} environment variable is not set`,
|
|
193
155
|
};
|
|
194
156
|
}
|
|
195
157
|
logger_1.loggerInstance.info('Sending generation request to LLM', {
|
|
@@ -200,26 +162,23 @@ async function generateADRContent(config, request) {
|
|
|
200
162
|
const provider = (0, providers_1.getProvider)(config.provider);
|
|
201
163
|
const responseContent = await provider.analyze(request.generation_prompt, {
|
|
202
164
|
apiKey,
|
|
203
|
-
model: config.analysis_model,
|
|
165
|
+
model: config.analysis_model,
|
|
204
166
|
timeoutMs: config.timeout_seconds * 1000,
|
|
205
167
|
});
|
|
206
168
|
if (!responseContent) {
|
|
207
169
|
logger_1.loggerInstance.warn('No response content from LLM for generation', {
|
|
208
|
-
provider: config.provider
|
|
170
|
+
provider: config.provider,
|
|
209
171
|
});
|
|
210
172
|
return {
|
|
211
173
|
result: null,
|
|
212
|
-
error: 'No response content from LLM'
|
|
174
|
+
error: 'No response content from LLM',
|
|
213
175
|
};
|
|
214
176
|
}
|
|
215
|
-
// Clean up the response - remove markdown code fences if LLM added them
|
|
216
177
|
let cleanedContent = responseContent.trim();
|
|
217
|
-
// Remove markdown code block if present
|
|
218
178
|
const codeBlockMatch = cleanedContent.match(/```(?:markdown|md)?\s*\n?([\s\S]*?)\n?```/);
|
|
219
179
|
if (codeBlockMatch) {
|
|
220
180
|
cleanedContent = codeBlockMatch[1].trim();
|
|
221
181
|
}
|
|
222
|
-
// Extract title from first line (should be # Title)
|
|
223
182
|
const titleMatch = cleanedContent.match(/^#\s+(.+)$/m);
|
|
224
183
|
const title = titleMatch ? titleMatch[1].trim() : 'Untitled Decision';
|
|
225
184
|
const result = {
|
|
@@ -234,7 +193,6 @@ async function generateADRContent(config, request) {
|
|
|
234
193
|
return { result, error: undefined };
|
|
235
194
|
}
|
|
236
195
|
catch (error) {
|
|
237
|
-
// Fail-open: log error and return descriptive error message
|
|
238
196
|
const errorObj = error;
|
|
239
197
|
let errorMessage;
|
|
240
198
|
if (errorObj.status === 401) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":";;AA6CA,wCAuJC;AAED,gDAoFC;AA1RD,4CAA2C;AAE3C,sCAAqD;AAuCrD,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAEM,KAAK,UAAU,cAAc,C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pF,CAAC;aAAM,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACnC,YAAY,GAAG,8CAA8C,CAAC;YAC9D,uBAAM,CAAC,IAAI,CAAC,+CAA+C,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACpF,CAAC;aAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,IAAI,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAClF,YAAY,GAAG,oBAAoB,MAAM,CAAC,eAAe,IAAI,CAAC;YAC9D,uBAAM,CAAC,IAAI,CAAC,2CAA2C,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChF,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,cAAc,QAAQ,CAAC,OAAO,IAAI,wBAAwB,EAAE,CAAC;YAC5E,uBAAM,CAAC,IAAI,CAAC,0CAA0C,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -1,49 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prompts Module
|
|
3
|
-
*
|
|
4
|
-
* Contains versioned prompt templates for LLM analysis and ADR generation.
|
|
5
|
-
* Follows the constitution requirement for versioned prompts.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Version 1 of the analysis prompt template.
|
|
9
|
-
*
|
|
10
|
-
* This prompt is designed to analyze code changes for architectural significance.
|
|
11
|
-
* It uses specific criteria for determining significance and enforces strict JSON output.
|
|
12
|
-
*/
|
|
13
1
|
export declare const ANALYSIS_PROMPT_V1 = "\nYou are an expert principal engineer and software architect acting as a meticulous code reviewer. Your sole task is to determine if the provided git diff represents an architecturally significant change that warrants an Architectural Decision Record (ADR).\n\nGiven the following staged changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nA change is considered architecturally significant if it:\n- Introduces a new external dependency, library, or service.\n- Adds, removes, or modifies infrastructure components (e.g., databases, caches, queues, Docker services).\n- Changes a public API contract, a data schema, or a critical data model.\n- Alters authentication, authorization, or other core security patterns.\n- Modifies cross-cutting concerns like logging, observability, or CI/CD pipelines.\n\nRespond ONLY with a single, minified JSON object with no preamble, no markdown, and no additional text. The JSON object must adhere to the following schema:\n{\"is_significant\": boolean, \"reason\": string}\n\nThe \"reason\" should be a concise, one-sentence explanation for your decision, suitable for showing to a developer. If the change is not significant, the reason should be an empty string.\n";
|
|
14
|
-
|
|
15
|
-
* Formats a prompt template by replacing placeholders with actual data.
|
|
16
|
-
*
|
|
17
|
-
* @param template - The prompt template with placeholders
|
|
18
|
-
* @param data - Object containing file_paths and diff_content
|
|
19
|
-
* @returns Formatted prompt with placeholders replaced
|
|
20
|
-
*/
|
|
2
|
+
export declare const GENERATION_PROMPT_V1 = "\nYou are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.\n\nGiven the following code changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nGenerate an ADR that follows this EXACT structure:\n\n# [Short title of solved problem and solution]\n\n* Status: [proposed | rejected | accepted | deprecated | superseded by [ADR-0005](0005-example.md)]\n* Date: {current_date}\n\n## Context and Problem Statement\n\n[Describe the context and problem statement in 2-3 sentences. What is the issue that we're addressing?]\n\n## Decision Drivers\n\n* [decision driver 1, e.g., a force, constraint, requirement]\n* [decision driver 2]\n* [etc.]\n\n## Considered Options\n\n* [option 1]\n* [option 2]\n* [option 3]\n\n## Decision Outcome\n\nChosen option: \"[option 1]\", because [justification. e.g., only option which meets KO criterion decision driver | which resolves force 1 | etc.].\n\n### Consequences\n\n* Good, because [positive consequence 1]\n* Good, because [positive consequence 2]\n* Bad, because [negative consequence 1]\n* Bad, because [negative consequence 2]\n\n## More Information\n\n[Any additional context, links to related discussions, or implementation notes]\n\nIMPORTANT INSTRUCTIONS:\n1. Use the EXACT markdown structure shown above\n2. Set Status to \"accepted\" (since this change is being committed)\n3. The title should be concise, action-oriented, and describe the decision made\n4. Keep Context and Problem Statement brief but clear (2-4 sentences)\n5. List at least 2-3 decision drivers that influenced this choice\n6. Include at least 2 considered options (including the chosen one)\n7. Be specific about consequences - list both benefits and drawbacks\n8. In \"More Information\", mention any technical details, related files, or future considerations\n\nRespond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.\n";
|
|
21
3
|
export declare function formatPrompt(template: string, data: {
|
|
22
4
|
file_paths: string[];
|
|
23
5
|
diff_content: string;
|
|
24
6
|
}): string;
|
|
25
|
-
/**
|
|
26
|
-
* Version 1 of the generation prompt template.
|
|
27
|
-
*
|
|
28
|
-
* This prompt generates ADRs following the MADR (Markdown Architectural Decision Records) format.
|
|
29
|
-
* MADR is a lean template for documenting architectural decisions in a structured way.
|
|
30
|
-
*/
|
|
31
|
-
export declare const GENERATION_PROMPT_V1 = "\nYou are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.\n\nGiven the following code changes:\n{file_paths}\n\nDiff content:\n{diff_content}\n\nGenerate an ADR that follows this EXACT structure:\n\n# [Short title of solved problem and solution]\n\n* Status: [proposed | rejected | accepted | deprecated | superseded by [ADR-0005](0005-example.md)]\n* Date: {current_date}\n\n## Context and Problem Statement\n\n[Describe the context and problem statement in 2-3 sentences. What is the issue that we're addressing?]\n\n## Decision Drivers\n\n* [decision driver 1, e.g., a force, constraint, requirement]\n* [decision driver 2]\n* [etc.]\n\n## Considered Options\n\n* [option 1]\n* [option 2]\n* [option 3]\n\n## Decision Outcome\n\nChosen option: \"[option 1]\", because [justification. e.g., only option which meets KO criterion decision driver | which resolves force 1 | etc.].\n\n### Consequences\n\n* Good, because [positive consequence 1]\n* Good, because [positive consequence 2]\n* Bad, because [negative consequence 1]\n* Bad, because [negative consequence 2]\n\n## More Information\n\n[Any additional context, links to related discussions, or implementation notes]\n\nIMPORTANT INSTRUCTIONS:\n1. Use the EXACT markdown structure shown above\n2. Set Status to \"accepted\" (since this change is being committed)\n3. The title should be concise, action-oriented, and describe the decision made\n4. Keep Context and Problem Statement brief but clear (2-4 sentences)\n5. List at least 2-3 decision drivers that influenced this choice\n6. Include at least 2 considered options (including the chosen one)\n7. Be specific about consequences - list both benefits and drawbacks\n8. In \"More Information\", mention any technical details, related files, or future considerations\n\nRespond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.\n";
|
|
32
|
-
/**
|
|
33
|
-
* Formats the generation prompt with actual diff data
|
|
34
|
-
*
|
|
35
|
-
* @param data - Object containing file_paths and diff_content
|
|
36
|
-
* @returns Formatted generation prompt
|
|
37
|
-
*/
|
|
38
7
|
export declare function formatGenerationPrompt(data: {
|
|
39
8
|
file_paths: string[];
|
|
40
9
|
diff_content: string;
|
|
41
10
|
}): string;
|
|
42
|
-
/**
|
|
43
|
-
* Prompt user for ADR generation confirmation
|
|
44
|
-
*
|
|
45
|
-
* @param reason - The reason why this change is architecturally significant
|
|
46
|
-
* @returns Promise<boolean> - true if user wants to generate, false otherwise
|
|
47
|
-
*/
|
|
48
11
|
export declare function promptForGeneration(reason: string): Promise<boolean>;
|
|
49
12
|
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/llm/prompts.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB,ksCAoB9B,CAAC;AAEF,eAAO,MAAM,oBAAoB,ihEA0DhC,CAAC;AAEF,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACnD,MAAM,CAMR;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAQT;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAuB1E"}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Prompts Module
|
|
4
|
-
*
|
|
5
|
-
* Contains versioned prompt templates for LLM analysis and ADR generation.
|
|
6
|
-
* Follows the constitution requirement for versioned prompts.
|
|
7
|
-
*/
|
|
8
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
3
|
if (k2 === undefined) k2 = k;
|
|
10
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -44,12 +38,6 @@ exports.formatPrompt = formatPrompt;
|
|
|
44
38
|
exports.formatGenerationPrompt = formatGenerationPrompt;
|
|
45
39
|
exports.promptForGeneration = promptForGeneration;
|
|
46
40
|
const readline = __importStar(require("readline"));
|
|
47
|
-
/**
|
|
48
|
-
* Version 1 of the analysis prompt template.
|
|
49
|
-
*
|
|
50
|
-
* This prompt is designed to analyze code changes for architectural significance.
|
|
51
|
-
* It uses specific criteria for determining significance and enforces strict JSON output.
|
|
52
|
-
*/
|
|
53
41
|
exports.ANALYSIS_PROMPT_V1 = `
|
|
54
42
|
You are an expert principal engineer and software architect acting as a meticulous code reviewer. Your sole task is to determine if the provided git diff represents an architecturally significant change that warrants an Architectural Decision Record (ADR).
|
|
55
43
|
|
|
@@ -71,29 +59,6 @@ Respond ONLY with a single, minified JSON object with no preamble, no markdown,
|
|
|
71
59
|
|
|
72
60
|
The "reason" should be a concise, one-sentence explanation for your decision, suitable for showing to a developer. If the change is not significant, the reason should be an empty string.
|
|
73
61
|
`;
|
|
74
|
-
/**
|
|
75
|
-
* Formats a prompt template by replacing placeholders with actual data.
|
|
76
|
-
*
|
|
77
|
-
* @param template - The prompt template with placeholders
|
|
78
|
-
* @param data - Object containing file_paths and diff_content
|
|
79
|
-
* @returns Formatted prompt with placeholders replaced
|
|
80
|
-
*/
|
|
81
|
-
function formatPrompt(template, data) {
|
|
82
|
-
// Format file paths as a readable list
|
|
83
|
-
const formattedFilePaths = data.file_paths.length > 0
|
|
84
|
-
? data.file_paths.join('\n')
|
|
85
|
-
: 'No files';
|
|
86
|
-
// Replace placeholders with actual data
|
|
87
|
-
return template
|
|
88
|
-
.replace('{file_paths}', formattedFilePaths)
|
|
89
|
-
.replace('{diff_content}', data.diff_content);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Version 1 of the generation prompt template.
|
|
93
|
-
*
|
|
94
|
-
* This prompt generates ADRs following the MADR (Markdown Architectural Decision Records) format.
|
|
95
|
-
* MADR is a lean template for documenting architectural decisions in a structured way.
|
|
96
|
-
*/
|
|
97
62
|
exports.GENERATION_PROMPT_V1 = `
|
|
98
63
|
You are an expert software architect. Your task is to write a comprehensive Architectural Decision Record (ADR) following the MADR (Markdown Architectural Decision Records) template.
|
|
99
64
|
|
|
@@ -153,40 +118,30 @@ IMPORTANT INSTRUCTIONS:
|
|
|
153
118
|
|
|
154
119
|
Respond ONLY with the markdown content of the ADR. Do not include any preamble, explanation, or markdown code fences. Start directly with the # title.
|
|
155
120
|
`;
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
121
|
+
function formatPrompt(template, data) {
|
|
122
|
+
const formattedFilePaths = data.file_paths.length > 0 ? data.file_paths.join('\n') : 'No files';
|
|
123
|
+
return template
|
|
124
|
+
.replace('{file_paths}', formattedFilePaths)
|
|
125
|
+
.replace('{diff_content}', data.diff_content);
|
|
126
|
+
}
|
|
162
127
|
function formatGenerationPrompt(data) {
|
|
163
|
-
const formattedFilePaths = data.file_paths.length > 0
|
|
164
|
-
? data.file_paths.join('\n')
|
|
165
|
-
: 'No files';
|
|
128
|
+
const formattedFilePaths = data.file_paths.length > 0 ? data.file_paths.join('\n') : 'No files';
|
|
166
129
|
const currentDate = new Date().toISOString().split('T')[0];
|
|
167
|
-
return exports.GENERATION_PROMPT_V1
|
|
168
|
-
.replace('{file_paths}', formattedFilePaths)
|
|
130
|
+
return exports.GENERATION_PROMPT_V1.replace('{file_paths}', formattedFilePaths)
|
|
169
131
|
.replace('{diff_content}', data.diff_content)
|
|
170
132
|
.replace('{current_date}', currentDate);
|
|
171
133
|
}
|
|
172
|
-
/**
|
|
173
|
-
* Prompt user for ADR generation confirmation
|
|
174
|
-
*
|
|
175
|
-
* @param reason - The reason why this change is architecturally significant
|
|
176
|
-
* @returns Promise<boolean> - true if user wants to generate, false otherwise
|
|
177
|
-
*/
|
|
178
134
|
async function promptForGeneration(reason) {
|
|
179
135
|
return new Promise((resolve) => {
|
|
180
136
|
const rl = readline.createInterface({
|
|
181
137
|
input: process.stdin,
|
|
182
138
|
output: process.stdout,
|
|
183
139
|
});
|
|
184
|
-
|
|
140
|
+
/* eslint-disable-next-line no-console */
|
|
185
141
|
console.log(`\n💭 ${reason}\n`);
|
|
186
142
|
rl.question('📝 Would you like to generate an ADR for this change? (Press ENTER or type "yes" to confirm, "no" to skip): ', (answer) => {
|
|
187
143
|
rl.close();
|
|
188
144
|
const normalized = answer.trim().toLowerCase();
|
|
189
|
-
// Accept: empty (ENTER), "y", "yes"
|
|
190
145
|
const confirmed = normalized === '' || normalized === 'y' || normalized === 'yes';
|
|
191
146
|
resolve(confirmed);
|
|
192
147
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/llm/prompts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,oCASC;AAED,wDAWC;AAED,kDAuBC;AAnID,mDAAqC;AAExB,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;CAoBjC,CAAC;AAEW,QAAA,oBAAoB,G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