@mono-labs/tracker 0.1.274 → 0.1.280
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/dashboard/cli.js +42 -0
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +466 -3
- package/dist/dashboard/watcher.d.ts +1 -1
- package/dist/dashboard/watcher.d.ts.map +1 -1
- package/dist/dashboard/watcher.js +1 -1
- package/dist/executor/action-executor.d.ts +3 -3
- package/dist/executor/action-executor.d.ts.map +1 -1
- package/dist/executor/action-executor.js +2 -2
- package/dist/executor/actions/extract-action.d.ts +4 -0
- package/dist/executor/actions/extract-action.d.ts.map +1 -0
- package/dist/executor/actions/extract-action.js +85 -0
- package/dist/executor/actions/index.d.ts +4 -0
- package/dist/executor/actions/index.d.ts.map +1 -1
- package/dist/executor/actions/index.js +9 -1
- package/dist/executor/actions/insert-action.d.ts +4 -0
- package/dist/executor/actions/insert-action.d.ts.map +1 -0
- package/dist/executor/actions/insert-action.js +74 -0
- package/dist/executor/actions/move-action.d.ts +4 -0
- package/dist/executor/actions/move-action.d.ts.map +1 -0
- package/dist/executor/actions/move-action.js +83 -0
- package/dist/executor/actions/remove-action.d.ts +2 -2
- package/dist/executor/actions/remove-action.d.ts.map +1 -1
- package/dist/executor/actions/remove-action.js +70 -6
- package/dist/executor/actions/rename-action.d.ts +2 -2
- package/dist/executor/actions/rename-action.d.ts.map +1 -1
- package/dist/executor/actions/rename-action.js +69 -6
- package/dist/executor/actions/replace-action.d.ts +2 -2
- package/dist/executor/actions/replace-action.d.ts.map +1 -1
- package/dist/executor/actions/replace-action.js +65 -6
- package/dist/executor/actions/wrap-action.d.ts +4 -0
- package/dist/executor/actions/wrap-action.d.ts.map +1 -0
- package/dist/executor/actions/wrap-action.js +97 -0
- package/dist/executor/index.d.ts +1 -1
- package/dist/executor/index.d.ts.map +1 -1
- package/dist/executor/index.js +21 -1
- package/dist/governance/deprecation-tracker.d.ts +21 -0
- package/dist/governance/deprecation-tracker.d.ts.map +1 -0
- package/dist/governance/deprecation-tracker.js +55 -0
- package/dist/governance/index.d.ts +5 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/index.js +7 -0
- package/dist/governance/security-gate.d.ts +15 -0
- package/dist/governance/security-gate.d.ts.map +1 -0
- package/dist/governance/security-gate.js +40 -0
- package/dist/governance/security-gate.test.d.ts +2 -0
- package/dist/governance/security-gate.test.d.ts.map +1 -0
- package/dist/governance/security-gate.test.js +67 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -1
- package/dist/integrations/ai-suggest.d.ts +8 -0
- package/dist/integrations/ai-suggest.d.ts.map +1 -0
- package/dist/integrations/ai-suggest.js +106 -0
- package/dist/integrations/github-issues.d.ts +8 -0
- package/dist/integrations/github-issues.d.ts.map +1 -0
- package/dist/integrations/github-issues.js +84 -0
- package/dist/integrations/index.d.ts +5 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +9 -0
- package/dist/integrations/jira-issues.d.ts +8 -0
- package/dist/integrations/jira-issues.d.ts.map +1 -0
- package/dist/integrations/jira-issues.js +93 -0
- package/dist/manager/health-score.d.ts +3 -0
- package/dist/manager/health-score.d.ts.map +1 -0
- package/dist/manager/health-score.js +32 -0
- package/dist/manager/index.d.ts +3 -0
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +5 -1
- package/dist/manager/notation-manager.test.js +5 -1
- package/dist/manager/projection.d.ts +15 -0
- package/dist/manager/projection.d.ts.map +1 -0
- package/dist/manager/projection.js +56 -0
- package/dist/scanner/action-serializer.d.ts +4 -0
- package/dist/scanner/action-serializer.d.ts.map +1 -0
- package/dist/scanner/action-serializer.js +54 -0
- package/dist/scanner/attribute-parser.d.ts +2 -0
- package/dist/scanner/attribute-parser.d.ts.map +1 -1
- package/dist/scanner/attribute-parser.js +11 -0
- package/dist/scanner/git-blame.d.ts +3 -0
- package/dist/scanner/git-blame.d.ts.map +1 -0
- package/dist/scanner/git-blame.js +81 -0
- package/dist/scanner/index.d.ts +1 -0
- package/dist/scanner/index.d.ts.map +1 -1
- package/dist/scanner/index.js +4 -1
- package/dist/scanner/notation-parser.d.ts.map +1 -1
- package/dist/scanner/notation-parser.js +3 -1
- package/dist/storage/config-loader.d.ts +6 -0
- package/dist/storage/config-loader.d.ts.map +1 -1
- package/dist/storage/config-loader.js +10 -0
- package/dist/storage/index.d.ts +4 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +4 -1
- package/dist/storage/snapshot-storage.d.ts +16 -0
- package/dist/storage/snapshot-storage.d.ts.map +1 -0
- package/dist/storage/snapshot-storage.js +106 -0
- package/dist/storage/snapshot-storage.test.d.ts +2 -0
- package/dist/storage/snapshot-storage.test.d.ts.map +1 -0
- package/dist/storage/snapshot-storage.test.js +117 -0
- package/dist/types/config.d.ts +22 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +5 -1
- package/dist/types/enums.d.ts +1 -0
- package/dist/types/enums.d.ts.map +1 -1
- package/dist/types/enums.js +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/notation.d.ts +9 -0
- package/dist/types/notation.d.ts.map +1 -1
- package/dist-dashboard/assets/index-CzsCRhkp.js +197 -0
- package/dist-dashboard/assets/index-DUqAN9SG.css +1 -0
- package/dist-dashboard/index.html +12 -1
- package/package.json +33 -8
- package/dist-dashboard/assets/index-Bi4tCz8P.js +0 -62
|
@@ -0,0 +1,97 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.handleWrap = handleWrap;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
async function handleWrap(action, notation, projectRoot) {
|
|
40
|
+
const args = action.args;
|
|
41
|
+
if (!args.target || !args.wrapper) {
|
|
42
|
+
return { success: false, message: 'WrapIn action requires target and wrapper', verb: 'wrapIn' };
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const filePath = path.resolve(projectRoot, notation.location.file);
|
|
46
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
47
|
+
const lines = content.split('\n');
|
|
48
|
+
const startLine = notation.location.line - 1;
|
|
49
|
+
const endLine = (notation.location.endLine ?? notation.location.line + notation.codeContext.length) - 1;
|
|
50
|
+
const searchEnd = Math.min(endLine + 10, lines.length - 1);
|
|
51
|
+
let targetLine = -1;
|
|
52
|
+
for (let i = startLine; i <= searchEnd; i++) {
|
|
53
|
+
if (lines[i].includes(args.target)) {
|
|
54
|
+
targetLine = i;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (targetLine === -1) {
|
|
59
|
+
return { success: false, message: `Target "${args.target}" not found in code context`, verb: 'wrapIn' };
|
|
60
|
+
}
|
|
61
|
+
const indent = lines[targetLine].match(/^(\s*)/)?.[1] || '';
|
|
62
|
+
const originalLine = lines[targetLine];
|
|
63
|
+
// Common wrapper patterns
|
|
64
|
+
const wrapper = args.wrapper.toLowerCase();
|
|
65
|
+
let wrapped;
|
|
66
|
+
if (wrapper === 'trycatch' || wrapper === 'try-catch' || wrapper === 'try/catch') {
|
|
67
|
+
wrapped = [
|
|
68
|
+
`${indent}try {`,
|
|
69
|
+
`${indent}\t${originalLine.trim()}`,
|
|
70
|
+
`${indent}} catch (err) {`,
|
|
71
|
+
`${indent}\t// Handle error`,
|
|
72
|
+
`${indent}}`,
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
else if (wrapper.startsWith('function') || wrapper.startsWith('const')) {
|
|
76
|
+
wrapped = [
|
|
77
|
+
`${indent}${args.wrapper} {`,
|
|
78
|
+
`${indent}\t${originalLine.trim()}`,
|
|
79
|
+
`${indent}}`,
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Generic wrapper: use the wrapper as a function call
|
|
84
|
+
wrapped = [
|
|
85
|
+
`${indent}${args.wrapper}(`,
|
|
86
|
+
`${indent}\t${originalLine.trim()}`,
|
|
87
|
+
`${indent})`,
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
lines.splice(targetLine, 1, ...wrapped);
|
|
91
|
+
fs.writeFileSync(filePath, lines.join('\n'), 'utf-8');
|
|
92
|
+
return { success: true, message: `Wrapped "${args.target}" with ${args.wrapper}`, verb: 'wrapIn' };
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
return { success: false, message: `WrapIn failed: ${err.message}`, verb: 'wrapIn' };
|
|
96
|
+
}
|
|
97
|
+
}
|
package/dist/executor/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { executeAction, registerActionHandler } from './action-executor';
|
|
2
2
|
export type { ActionResult, ActionHandler } from './action-executor';
|
|
3
|
-
export { handleReplace, handleRemove, handleRename } from './actions';
|
|
3
|
+
export { handleReplace, handleRemove, handleRename, handleInsert, handleExtract, handleMove, handleWrap } from './actions';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACxE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/executor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AACxE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/executor/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleRename = exports.handleRemove = exports.handleReplace = exports.registerActionHandler = exports.executeAction = void 0;
|
|
3
|
+
exports.handleWrap = exports.handleMove = exports.handleExtract = exports.handleInsert = exports.handleRename = exports.handleRemove = exports.handleReplace = exports.registerActionHandler = exports.executeAction = void 0;
|
|
4
4
|
var action_executor_1 = require("./action-executor");
|
|
5
5
|
Object.defineProperty(exports, "executeAction", { enumerable: true, get: function () { return action_executor_1.executeAction; } });
|
|
6
6
|
Object.defineProperty(exports, "registerActionHandler", { enumerable: true, get: function () { return action_executor_1.registerActionHandler; } });
|
|
@@ -8,3 +8,23 @@ var actions_1 = require("./actions");
|
|
|
8
8
|
Object.defineProperty(exports, "handleReplace", { enumerable: true, get: function () { return actions_1.handleReplace; } });
|
|
9
9
|
Object.defineProperty(exports, "handleRemove", { enumerable: true, get: function () { return actions_1.handleRemove; } });
|
|
10
10
|
Object.defineProperty(exports, "handleRename", { enumerable: true, get: function () { return actions_1.handleRename; } });
|
|
11
|
+
Object.defineProperty(exports, "handleInsert", { enumerable: true, get: function () { return actions_1.handleInsert; } });
|
|
12
|
+
Object.defineProperty(exports, "handleExtract", { enumerable: true, get: function () { return actions_1.handleExtract; } });
|
|
13
|
+
Object.defineProperty(exports, "handleMove", { enumerable: true, get: function () { return actions_1.handleMove; } });
|
|
14
|
+
Object.defineProperty(exports, "handleWrap", { enumerable: true, get: function () { return actions_1.handleWrap; } });
|
|
15
|
+
// Auto-register all handlers
|
|
16
|
+
const action_executor_2 = require("./action-executor");
|
|
17
|
+
const replace_action_1 = require("./actions/replace-action");
|
|
18
|
+
const remove_action_1 = require("./actions/remove-action");
|
|
19
|
+
const rename_action_1 = require("./actions/rename-action");
|
|
20
|
+
const insert_action_1 = require("./actions/insert-action");
|
|
21
|
+
const extract_action_1 = require("./actions/extract-action");
|
|
22
|
+
const move_action_1 = require("./actions/move-action");
|
|
23
|
+
const wrap_action_1 = require("./actions/wrap-action");
|
|
24
|
+
(0, action_executor_2.registerActionHandler)('replace', replace_action_1.handleReplace);
|
|
25
|
+
(0, action_executor_2.registerActionHandler)('remove', remove_action_1.handleRemove);
|
|
26
|
+
(0, action_executor_2.registerActionHandler)('rename', rename_action_1.handleRename);
|
|
27
|
+
(0, action_executor_2.registerActionHandler)('insert', insert_action_1.handleInsert);
|
|
28
|
+
(0, action_executor_2.registerActionHandler)('extract', extract_action_1.handleExtract);
|
|
29
|
+
(0, action_executor_2.registerActionHandler)('move', move_action_1.handleMove);
|
|
30
|
+
(0, action_executor_2.registerActionHandler)('wrapIn', wrap_action_1.handleWrap);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Notation } from '../types';
|
|
2
|
+
export interface DeprecationEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
description: string;
|
|
5
|
+
eolDate?: string;
|
|
6
|
+
replacement?: string;
|
|
7
|
+
file: string;
|
|
8
|
+
line: number;
|
|
9
|
+
status: 'past-eol' | 'approaching-eol' | 'future' | 'unknown';
|
|
10
|
+
daysUntilEol?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface DeprecationSummary {
|
|
13
|
+
total: number;
|
|
14
|
+
pastEol: number;
|
|
15
|
+
approachingEol: number;
|
|
16
|
+
future: number;
|
|
17
|
+
unknown: number;
|
|
18
|
+
entries: DeprecationEntry[];
|
|
19
|
+
}
|
|
20
|
+
export declare function computeDeprecationSummary(notations: Notation[]): DeprecationSummary;
|
|
21
|
+
//# sourceMappingURL=deprecation-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation-tracker.d.ts","sourceRoot":"","sources":["../../src/governance/deprecation-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,UAAU,GAAG,iBAAiB,GAAG,QAAQ,GAAG,SAAS,CAAA;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IAClC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC3B;AAID,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAqDnF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeDeprecationSummary = computeDeprecationSummary;
|
|
4
|
+
const APPROACHING_DAYS = 30;
|
|
5
|
+
function computeDeprecationSummary(notations) {
|
|
6
|
+
const deprecations = notations.filter((n) => n.type === 'DEPRECATION');
|
|
7
|
+
const now = new Date();
|
|
8
|
+
const entries = [];
|
|
9
|
+
let pastEol = 0;
|
|
10
|
+
let approachingEol = 0;
|
|
11
|
+
let future = 0;
|
|
12
|
+
let unknown = 0;
|
|
13
|
+
for (const n of deprecations) {
|
|
14
|
+
const entry = {
|
|
15
|
+
id: n.id,
|
|
16
|
+
description: n.description,
|
|
17
|
+
eolDate: n.eolDate,
|
|
18
|
+
replacement: n.replacement,
|
|
19
|
+
file: n.location.file,
|
|
20
|
+
line: n.location.line,
|
|
21
|
+
status: 'unknown',
|
|
22
|
+
};
|
|
23
|
+
if (!n.eolDate) {
|
|
24
|
+
entry.status = 'unknown';
|
|
25
|
+
unknown++;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const eolDate = new Date(n.eolDate + 'T23:59:59');
|
|
29
|
+
const diffMs = eolDate.getTime() - now.getTime();
|
|
30
|
+
const diffDays = Math.ceil(diffMs / (1000 * 60 * 60 * 24));
|
|
31
|
+
entry.daysUntilEol = diffDays;
|
|
32
|
+
if (diffDays < 0) {
|
|
33
|
+
entry.status = 'past-eol';
|
|
34
|
+
pastEol++;
|
|
35
|
+
}
|
|
36
|
+
else if (diffDays <= APPROACHING_DAYS) {
|
|
37
|
+
entry.status = 'approaching-eol';
|
|
38
|
+
approachingEol++;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
entry.status = 'future';
|
|
42
|
+
future++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
entries.push(entry);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
total: deprecations.length,
|
|
49
|
+
pastEol,
|
|
50
|
+
approachingEol,
|
|
51
|
+
future,
|
|
52
|
+
unknown,
|
|
53
|
+
entries,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { evaluateSecurityGate } from './security-gate';
|
|
2
|
+
export type { GateResult, GateViolation } from './security-gate';
|
|
3
|
+
export { computeDeprecationSummary } from './deprecation-tracker';
|
|
4
|
+
export type { DeprecationSummary, DeprecationEntry } from './deprecation-tracker';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/governance/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACtD,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACjE,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeDeprecationSummary = exports.evaluateSecurityGate = void 0;
|
|
4
|
+
var security_gate_1 = require("./security-gate");
|
|
5
|
+
Object.defineProperty(exports, "evaluateSecurityGate", { enumerable: true, get: function () { return security_gate_1.evaluateSecurityGate; } });
|
|
6
|
+
var deprecation_tracker_1 = require("./deprecation-tracker");
|
|
7
|
+
Object.defineProperty(exports, "computeDeprecationSummary", { enumerable: true, get: function () { return deprecation_tracker_1.computeDeprecationSummary; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Notation, TrackerConfig } from '../types';
|
|
2
|
+
export interface GateViolation {
|
|
3
|
+
notationId: string;
|
|
4
|
+
description: string;
|
|
5
|
+
priority: string;
|
|
6
|
+
file: string;
|
|
7
|
+
line: number;
|
|
8
|
+
}
|
|
9
|
+
export interface GateResult {
|
|
10
|
+
passed: boolean;
|
|
11
|
+
violations: GateViolation[];
|
|
12
|
+
summary: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function evaluateSecurityGate(notations: Notation[], config: TrackerConfig): GateResult;
|
|
15
|
+
//# sourceMappingURL=security-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-gate.d.ts","sourceRoot":"","sources":["../../src/governance/security-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEvD,MAAM,WAAW,aAAa;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,UAAU;IAC1B,MAAM,EAAE,OAAO,CAAA;IACf,UAAU,EAAE,aAAa,EAAE,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,aAAa,GAAG,UAAU,CAyC7F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.evaluateSecurityGate = evaluateSecurityGate;
|
|
4
|
+
function evaluateSecurityGate(notations, config) {
|
|
5
|
+
if (!config.securityGate.enabled) {
|
|
6
|
+
return { passed: true, violations: [], summary: 'Security gate disabled' };
|
|
7
|
+
}
|
|
8
|
+
const violations = [];
|
|
9
|
+
for (const n of notations) {
|
|
10
|
+
if (n.type !== 'SECURITY')
|
|
11
|
+
continue;
|
|
12
|
+
if (n.status === 'resolved')
|
|
13
|
+
continue;
|
|
14
|
+
const isCritical = n.priority === 'critical';
|
|
15
|
+
const isHigh = n.priority === 'high';
|
|
16
|
+
if (isCritical && config.securityGate.blockOnCritical) {
|
|
17
|
+
violations.push({
|
|
18
|
+
notationId: n.id,
|
|
19
|
+
description: n.description,
|
|
20
|
+
priority: 'critical',
|
|
21
|
+
file: n.location.file,
|
|
22
|
+
line: n.location.line,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (isHigh && config.securityGate.blockOnHigh) {
|
|
26
|
+
violations.push({
|
|
27
|
+
notationId: n.id,
|
|
28
|
+
description: n.description,
|
|
29
|
+
priority: 'high',
|
|
30
|
+
file: n.location.file,
|
|
31
|
+
line: n.location.line,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const passed = violations.length === 0;
|
|
36
|
+
const summary = passed
|
|
37
|
+
? `Security gate passed (${notations.filter((n) => n.type === 'SECURITY').length} SECURITY notations checked)`
|
|
38
|
+
: `Security gate failed: ${violations.length} blocking violation(s)`;
|
|
39
|
+
return { passed, violations, summary };
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-gate.test.d.ts","sourceRoot":"","sources":["../../src/governance/security-gate.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const security_gate_1 = require("./security-gate");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
function makeNotation(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
id: 'N-test',
|
|
9
|
+
type: 'SECURITY',
|
|
10
|
+
description: 'Test security issue',
|
|
11
|
+
body: [],
|
|
12
|
+
codeContext: [],
|
|
13
|
+
location: { file: 'test.ts', line: 1, column: 1 },
|
|
14
|
+
status: 'open',
|
|
15
|
+
tags: [],
|
|
16
|
+
actions: [],
|
|
17
|
+
relationships: [],
|
|
18
|
+
rawBlock: '',
|
|
19
|
+
scannedAt: new Date().toISOString(),
|
|
20
|
+
...overrides,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function makeConfig(overrides = {}) {
|
|
24
|
+
return {
|
|
25
|
+
...types_1.DEFAULT_CONFIG,
|
|
26
|
+
securityGate: { ...types_1.DEFAULT_CONFIG.securityGate, ...overrides },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
(0, vitest_1.describe)('evaluateSecurityGate', () => {
|
|
30
|
+
(0, vitest_1.it)('returns passed when gate is disabled', () => {
|
|
31
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([makeNotation({ priority: 'critical' })], makeConfig({ enabled: false }));
|
|
32
|
+
(0, vitest_1.expect)(result.passed).toBe(true);
|
|
33
|
+
(0, vitest_1.expect)(result.violations).toHaveLength(0);
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)('passes when no security notations exist', () => {
|
|
36
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([makeNotation({ type: 'BUG', priority: 'critical' })], makeConfig({ enabled: true, blockOnCritical: true }));
|
|
37
|
+
(0, vitest_1.expect)(result.passed).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
(0, vitest_1.it)('fails on critical security notations when blockOnCritical is true', () => {
|
|
40
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([makeNotation({ priority: 'critical' })], makeConfig({ enabled: true, blockOnCritical: true }));
|
|
41
|
+
(0, vitest_1.expect)(result.passed).toBe(false);
|
|
42
|
+
(0, vitest_1.expect)(result.violations).toHaveLength(1);
|
|
43
|
+
(0, vitest_1.expect)(result.violations[0].priority).toBe('critical');
|
|
44
|
+
});
|
|
45
|
+
(0, vitest_1.it)('passes on high security notations when only blockOnCritical is true', () => {
|
|
46
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([makeNotation({ priority: 'high' })], makeConfig({ enabled: true, blockOnCritical: true, blockOnHigh: false }));
|
|
47
|
+
(0, vitest_1.expect)(result.passed).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
(0, vitest_1.it)('fails on high security notations when blockOnHigh is true', () => {
|
|
50
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([makeNotation({ priority: 'high' })], makeConfig({ enabled: true, blockOnHigh: true }));
|
|
51
|
+
(0, vitest_1.expect)(result.passed).toBe(false);
|
|
52
|
+
(0, vitest_1.expect)(result.violations).toHaveLength(1);
|
|
53
|
+
});
|
|
54
|
+
(0, vitest_1.it)('ignores resolved security notations', () => {
|
|
55
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([makeNotation({ priority: 'critical', status: 'resolved' })], makeConfig({ enabled: true, blockOnCritical: true }));
|
|
56
|
+
(0, vitest_1.expect)(result.passed).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
(0, vitest_1.it)('reports multiple violations', () => {
|
|
59
|
+
const result = (0, security_gate_1.evaluateSecurityGate)([
|
|
60
|
+
makeNotation({ id: 'N-1', priority: 'critical' }),
|
|
61
|
+
makeNotation({ id: 'N-2', priority: 'high' }),
|
|
62
|
+
makeNotation({ id: 'N-3', priority: 'critical' }),
|
|
63
|
+
], makeConfig({ enabled: true, blockOnCritical: true, blockOnHigh: true }));
|
|
64
|
+
(0, vitest_1.expect)(result.passed).toBe(false);
|
|
65
|
+
(0, vitest_1.expect)(result.violations).toHaveLength(3);
|
|
66
|
+
});
|
|
67
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
export { MarkerType, Priority, RiskLevel, Status, CompoundingRate } from './types';
|
|
2
2
|
export { ActionVerbEnum as ActionVerb } from './types';
|
|
3
|
-
export type { Notation, SourceLocation, PerformanceImpact, TechnicalDebt, NotationQuery, NotationStats, NotationAction, ActionArgs, ReplaceArgs, RemoveArgs, RenameArgs, InsertArgs, ExtractArgs, MoveArgs, WrapInArgs, GenericArgs, TrackerConfig, } from './types';
|
|
3
|
+
export type { Notation, SourceLocation, PerformanceImpact, TechnicalDebt, NotationQuery, NotationStats, NotationAction, ActionArgs, ReplaceArgs, RemoveArgs, RenameArgs, InsertArgs, ExtractArgs, MoveArgs, WrapInArgs, GenericArgs, TrackerConfig, SecurityGateConfig, IntegrationsConfig, } from './types';
|
|
4
4
|
export { DEFAULT_CONFIG } from './types';
|
|
5
5
|
export { generateId, generateStableId, parseDate, isOverdue } from './utils';
|
|
6
|
-
export { JsonlStorage } from './storage';
|
|
7
|
-
export { loadConfig } from './storage';
|
|
6
|
+
export { JsonlStorage, SnapshotStorage } from './storage';
|
|
7
|
+
export { loadConfig, loadSecrets } from './storage';
|
|
8
|
+
export type { Snapshot, ResolvedSecrets } from './storage';
|
|
8
9
|
export { parseAttributes, parseActions, parseFileContent, scanFiles } from './scanner';
|
|
9
10
|
export type { ParsedAttributes } from './scanner';
|
|
10
11
|
export { NotationManager } from './manager';
|
|
11
12
|
export { getBlockers, isBlocked, detectCircularDependencies } from './manager';
|
|
12
13
|
export { updateStatus, addTag, removeTag, setAssignee } from './manager';
|
|
13
|
-
export { validateNotation, validateAll, computeStats } from './manager';
|
|
14
|
-
export type { ValidationError } from './manager';
|
|
14
|
+
export { validateNotation, validateAll, computeStats, computeHealthScore, computeBurnDown } from './manager';
|
|
15
|
+
export type { ValidationError, BurnDownData, BurnDownPoint } from './manager';
|
|
15
16
|
export { executeAction, registerActionHandler } from './executor';
|
|
16
17
|
export type { ActionResult, ActionHandler } from './executor';
|
|
17
|
-
export { handleReplace, handleRemove, handleRename } from './executor';
|
|
18
|
+
export { handleReplace, handleRemove, handleRename, handleInsert, handleExtract, handleMove, handleWrap } from './executor';
|
|
19
|
+
export { evaluateSecurityGate, computeDeprecationSummary } from './governance';
|
|
20
|
+
export type { GateResult, GateViolation, DeprecationSummary, DeprecationEntry } from './governance';
|
|
21
|
+
export { createGitHubIssue } from './integrations';
|
|
22
|
+
export { createJiraIssue } from './integrations';
|
|
23
|
+
export { suggestFix } from './integrations';
|
|
24
|
+
export type { SuggestedFix } from './integrations';
|
|
18
25
|
export { startDashboard } from './dashboard';
|
|
19
26
|
export type { DashboardConfig, DashboardServer } from './dashboard';
|
|
20
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAClF,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AACtD,YAAY,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAClF,OAAO,EAAE,cAAc,IAAI,UAAU,EAAE,MAAM,SAAS,CAAA;AACtD,YAAY,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,UAAU,EACV,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,GAClB,MAAM,SAAS,CAAA;AAChB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGxC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAG5E,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACnD,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG1D,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACtF,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAGjD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACxE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC5G,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAG7E,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACjE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAG3H,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAC9E,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAGnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startDashboard = exports.handleRename = exports.handleRemove = exports.handleReplace = exports.registerActionHandler = exports.executeAction = exports.computeStats = exports.validateAll = exports.validateNotation = exports.setAssignee = exports.removeTag = exports.addTag = exports.updateStatus = exports.detectCircularDependencies = exports.isBlocked = exports.getBlockers = exports.NotationManager = exports.scanFiles = exports.parseFileContent = exports.parseActions = exports.parseAttributes = exports.loadConfig = exports.JsonlStorage = exports.isOverdue = exports.parseDate = exports.generateStableId = exports.generateId = exports.DEFAULT_CONFIG = exports.ActionVerb = exports.CompoundingRate = exports.Status = exports.RiskLevel = exports.Priority = exports.MarkerType = void 0;
|
|
3
|
+
exports.startDashboard = exports.suggestFix = exports.createJiraIssue = exports.createGitHubIssue = exports.computeDeprecationSummary = exports.evaluateSecurityGate = exports.handleWrap = exports.handleMove = exports.handleExtract = exports.handleInsert = exports.handleRename = exports.handleRemove = exports.handleReplace = exports.registerActionHandler = exports.executeAction = exports.computeBurnDown = exports.computeHealthScore = exports.computeStats = exports.validateAll = exports.validateNotation = exports.setAssignee = exports.removeTag = exports.addTag = exports.updateStatus = exports.detectCircularDependencies = exports.isBlocked = exports.getBlockers = exports.NotationManager = exports.scanFiles = exports.parseFileContent = exports.parseActions = exports.parseAttributes = exports.loadSecrets = exports.loadConfig = exports.SnapshotStorage = exports.JsonlStorage = exports.isOverdue = exports.parseDate = exports.generateStableId = exports.generateId = exports.DEFAULT_CONFIG = exports.ActionVerb = exports.CompoundingRate = exports.Status = exports.RiskLevel = exports.Priority = exports.MarkerType = void 0;
|
|
4
4
|
// Types
|
|
5
5
|
var types_1 = require("./types");
|
|
6
6
|
Object.defineProperty(exports, "MarkerType", { enumerable: true, get: function () { return types_1.MarkerType; } });
|
|
@@ -21,8 +21,10 @@ Object.defineProperty(exports, "isOverdue", { enumerable: true, get: function ()
|
|
|
21
21
|
// Storage
|
|
22
22
|
var storage_1 = require("./storage");
|
|
23
23
|
Object.defineProperty(exports, "JsonlStorage", { enumerable: true, get: function () { return storage_1.JsonlStorage; } });
|
|
24
|
+
Object.defineProperty(exports, "SnapshotStorage", { enumerable: true, get: function () { return storage_1.SnapshotStorage; } });
|
|
24
25
|
var storage_2 = require("./storage");
|
|
25
26
|
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return storage_2.loadConfig; } });
|
|
27
|
+
Object.defineProperty(exports, "loadSecrets", { enumerable: true, get: function () { return storage_2.loadSecrets; } });
|
|
26
28
|
// Scanner
|
|
27
29
|
var scanner_1 = require("./scanner");
|
|
28
30
|
Object.defineProperty(exports, "parseAttributes", { enumerable: true, get: function () { return scanner_1.parseAttributes; } });
|
|
@@ -45,6 +47,8 @@ var manager_4 = require("./manager");
|
|
|
45
47
|
Object.defineProperty(exports, "validateNotation", { enumerable: true, get: function () { return manager_4.validateNotation; } });
|
|
46
48
|
Object.defineProperty(exports, "validateAll", { enumerable: true, get: function () { return manager_4.validateAll; } });
|
|
47
49
|
Object.defineProperty(exports, "computeStats", { enumerable: true, get: function () { return manager_4.computeStats; } });
|
|
50
|
+
Object.defineProperty(exports, "computeHealthScore", { enumerable: true, get: function () { return manager_4.computeHealthScore; } });
|
|
51
|
+
Object.defineProperty(exports, "computeBurnDown", { enumerable: true, get: function () { return manager_4.computeBurnDown; } });
|
|
48
52
|
// Executor
|
|
49
53
|
var executor_1 = require("./executor");
|
|
50
54
|
Object.defineProperty(exports, "executeAction", { enumerable: true, get: function () { return executor_1.executeAction; } });
|
|
@@ -53,6 +57,21 @@ var executor_2 = require("./executor");
|
|
|
53
57
|
Object.defineProperty(exports, "handleReplace", { enumerable: true, get: function () { return executor_2.handleReplace; } });
|
|
54
58
|
Object.defineProperty(exports, "handleRemove", { enumerable: true, get: function () { return executor_2.handleRemove; } });
|
|
55
59
|
Object.defineProperty(exports, "handleRename", { enumerable: true, get: function () { return executor_2.handleRename; } });
|
|
60
|
+
Object.defineProperty(exports, "handleInsert", { enumerable: true, get: function () { return executor_2.handleInsert; } });
|
|
61
|
+
Object.defineProperty(exports, "handleExtract", { enumerable: true, get: function () { return executor_2.handleExtract; } });
|
|
62
|
+
Object.defineProperty(exports, "handleMove", { enumerable: true, get: function () { return executor_2.handleMove; } });
|
|
63
|
+
Object.defineProperty(exports, "handleWrap", { enumerable: true, get: function () { return executor_2.handleWrap; } });
|
|
64
|
+
// Governance
|
|
65
|
+
var governance_1 = require("./governance");
|
|
66
|
+
Object.defineProperty(exports, "evaluateSecurityGate", { enumerable: true, get: function () { return governance_1.evaluateSecurityGate; } });
|
|
67
|
+
Object.defineProperty(exports, "computeDeprecationSummary", { enumerable: true, get: function () { return governance_1.computeDeprecationSummary; } });
|
|
68
|
+
// Integrations
|
|
69
|
+
var integrations_1 = require("./integrations");
|
|
70
|
+
Object.defineProperty(exports, "createGitHubIssue", { enumerable: true, get: function () { return integrations_1.createGitHubIssue; } });
|
|
71
|
+
var integrations_2 = require("./integrations");
|
|
72
|
+
Object.defineProperty(exports, "createJiraIssue", { enumerable: true, get: function () { return integrations_2.createJiraIssue; } });
|
|
73
|
+
var integrations_3 = require("./integrations");
|
|
74
|
+
Object.defineProperty(exports, "suggestFix", { enumerable: true, get: function () { return integrations_3.suggestFix; } });
|
|
56
75
|
// Dashboard
|
|
57
76
|
var dashboard_1 = require("./dashboard");
|
|
58
77
|
Object.defineProperty(exports, "startDashboard", { enumerable: true, get: function () { return dashboard_1.startDashboard; } });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Notation } from '../types';
|
|
2
|
+
export interface SuggestedFix {
|
|
3
|
+
explanation: string;
|
|
4
|
+
diff: string;
|
|
5
|
+
confidence: 'low' | 'medium' | 'high';
|
|
6
|
+
}
|
|
7
|
+
export declare function suggestFix(apiKey: string, model: string, notation: Notation, sourceContext: string): Promise<SuggestedFix>;
|
|
8
|
+
//# sourceMappingURL=ai-suggest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-suggest.d.ts","sourceRoot":"","sources":["../../src/integrations/ai-suggest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,WAAW,YAAY;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;CACrC;AAED,wBAAsB,UAAU,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,MAAM,GACnB,OAAO,CAAC,YAAY,CAAC,CAgBvB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.suggestFix = suggestFix;
|
|
7
|
+
const https_1 = __importDefault(require("https"));
|
|
8
|
+
async function suggestFix(apiKey, model, notation, sourceContext) {
|
|
9
|
+
const prompt = buildPrompt(notation, sourceContext);
|
|
10
|
+
const data = JSON.stringify({
|
|
11
|
+
model,
|
|
12
|
+
max_tokens: 2048,
|
|
13
|
+
messages: [
|
|
14
|
+
{
|
|
15
|
+
role: 'user',
|
|
16
|
+
content: prompt,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
const response = await callAnthropicAPI(apiKey, data);
|
|
21
|
+
return parseResponse(response);
|
|
22
|
+
}
|
|
23
|
+
function buildPrompt(notation, sourceContext) {
|
|
24
|
+
return `You are a code analysis assistant. A code notation of type "${notation.type}" was found in the source code.
|
|
25
|
+
|
|
26
|
+
Notation ID: ${notation.id}
|
|
27
|
+
Description: ${notation.description}
|
|
28
|
+
${notation.body.length > 0 ? `Details:\n${notation.body.join('\n')}` : ''}
|
|
29
|
+
File: ${notation.location.file}:${notation.location.line}
|
|
30
|
+
|
|
31
|
+
Code context around the notation:
|
|
32
|
+
\`\`\`
|
|
33
|
+
${sourceContext}
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
Please suggest a fix for this ${notation.type} notation. Respond in exactly this JSON format:
|
|
37
|
+
{
|
|
38
|
+
"explanation": "Brief explanation of what the fix does and why",
|
|
39
|
+
"diff": "A unified diff showing the changes needed",
|
|
40
|
+
"confidence": "low|medium|high"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Only respond with the JSON object, nothing else.`;
|
|
44
|
+
}
|
|
45
|
+
function callAnthropicAPI(apiKey, data) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const req = https_1.default.request({
|
|
48
|
+
hostname: 'api.anthropic.com',
|
|
49
|
+
path: '/v1/messages',
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
'x-api-key': apiKey,
|
|
54
|
+
'anthropic-version': '2023-06-01',
|
|
55
|
+
'Content-Length': Buffer.byteLength(data),
|
|
56
|
+
},
|
|
57
|
+
timeout: 30000,
|
|
58
|
+
}, (res) => {
|
|
59
|
+
let body = '';
|
|
60
|
+
res.on('data', (chunk) => { body += chunk; });
|
|
61
|
+
res.on('end', () => {
|
|
62
|
+
if (res.statusCode === 200) {
|
|
63
|
+
resolve(body);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
reject(new Error(`Anthropic API error: ${res.statusCode} ${body}`));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
req.on('error', reject);
|
|
71
|
+
req.on('timeout', () => {
|
|
72
|
+
req.destroy();
|
|
73
|
+
reject(new Error('Anthropic API timeout (30s)'));
|
|
74
|
+
});
|
|
75
|
+
req.write(data);
|
|
76
|
+
req.end();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function parseResponse(responseBody) {
|
|
80
|
+
try {
|
|
81
|
+
const parsed = JSON.parse(responseBody);
|
|
82
|
+
const content = parsed.content?.[0]?.text || '';
|
|
83
|
+
// Try to parse the JSON from the response
|
|
84
|
+
const jsonMatch = content.match(/\{[\s\S]*\}/);
|
|
85
|
+
if (jsonMatch) {
|
|
86
|
+
const fix = JSON.parse(jsonMatch[0]);
|
|
87
|
+
return {
|
|
88
|
+
explanation: fix.explanation || 'No explanation provided',
|
|
89
|
+
diff: fix.diff || '',
|
|
90
|
+
confidence: ['low', 'medium', 'high'].includes(fix.confidence) ? fix.confidence : 'low',
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
explanation: content || 'Unable to parse AI response',
|
|
95
|
+
diff: '',
|
|
96
|
+
confidence: 'low',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return {
|
|
101
|
+
explanation: 'Failed to parse AI response',
|
|
102
|
+
diff: '',
|
|
103
|
+
confidence: 'low',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Notation } from '../types';
|
|
2
|
+
interface GitHubConfig {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createGitHubIssue(config: GitHubConfig, token: string, notation: Notation): Promise<string>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=github-issues.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-issues.d.ts","sourceRoot":"","sources":["../../src/integrations/github-issues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,UAAU,YAAY;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;CACZ;AAED,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,YAAY,EACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,MAAM,CAAC,CAmDjB"}
|