@neurcode-ai/cli 0.9.50 → 0.9.59
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/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +307 -31
- package/dist/commands/fix.js.map +1 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +264 -13
- package/dist/commands/verify.js.map +1 -1
- package/dist/daemon/server.d.ts +23 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +222 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/intent-engine/coverage.d.ts +69 -0
- package/dist/intent-engine/coverage.d.ts.map +1 -0
- package/dist/intent-engine/coverage.js +140 -0
- package/dist/intent-engine/coverage.js.map +1 -0
- package/dist/intent-engine/flow-rules.d.ts +21 -0
- package/dist/intent-engine/flow-rules.d.ts.map +1 -0
- package/dist/intent-engine/flow-rules.js +83 -0
- package/dist/intent-engine/flow-rules.js.map +1 -0
- package/dist/intent-engine/flow-validator.d.ts +29 -0
- package/dist/intent-engine/flow-validator.d.ts.map +1 -0
- package/dist/intent-engine/flow-validator.js +202 -0
- package/dist/intent-engine/flow-validator.js.map +1 -0
- package/dist/intent-engine/graph.d.ts +33 -0
- package/dist/intent-engine/graph.d.ts.map +1 -0
- package/dist/intent-engine/graph.js +67 -0
- package/dist/intent-engine/graph.js.map +1 -0
- package/dist/intent-engine/index.d.ts +35 -0
- package/dist/intent-engine/index.d.ts.map +1 -0
- package/dist/intent-engine/index.js +94 -0
- package/dist/intent-engine/index.js.map +1 -0
- package/dist/intent-engine/indexer.d.ts +18 -0
- package/dist/intent-engine/indexer.d.ts.map +1 -0
- package/dist/intent-engine/indexer.js +100 -0
- package/dist/intent-engine/indexer.js.map +1 -0
- package/dist/intent-engine/matcher.d.ts +35 -0
- package/dist/intent-engine/matcher.d.ts.map +1 -0
- package/dist/intent-engine/matcher.js +522 -0
- package/dist/intent-engine/matcher.js.map +1 -0
- package/dist/intent-engine/parser.d.ts +12 -0
- package/dist/intent-engine/parser.d.ts.map +1 -0
- package/dist/intent-engine/parser.js +93 -0
- package/dist/intent-engine/parser.js.map +1 -0
- package/dist/intent-engine/regression.d.ts +32 -0
- package/dist/intent-engine/regression.d.ts.map +1 -0
- package/dist/intent-engine/regression.js +166 -0
- package/dist/intent-engine/regression.js.map +1 -0
- package/dist/intent-engine/requirements.d.ts +22 -0
- package/dist/intent-engine/requirements.d.ts.map +1 -0
- package/dist/intent-engine/requirements.js +147 -0
- package/dist/intent-engine/requirements.js.map +1 -0
- package/dist/intent-engine/state.d.ts +44 -0
- package/dist/intent-engine/state.d.ts.map +1 -0
- package/dist/intent-engine/state.js +83 -0
- package/dist/intent-engine/state.js.map +1 -0
- package/dist/utils/ai-debt-budget.d.ts +3 -2
- package/dist/utils/ai-debt-budget.d.ts.map +1 -1
- package/dist/utils/ai-debt-budget.js +83 -2
- package/dist/utils/ai-debt-budget.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coverage.js","sourceRoot":"","sources":["../../src/intent-engine/coverage.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAoEH,0DAkBC;AAeD,0CA0CC;AAQD,oDAkDC;AAID,8CAGC;AAED,oDAEC;AAlND,iDAMwB;AAkDxB,iFAAiF;AAEjF,SAAS,sBAAsB,CAAC,QAAgB;IAC9C,IAAI,QAAQ,IAAI,GAAG;QAAE,OAAO,MAAM,CAAC;IACnC,IAAI,QAAQ,IAAI,GAAG;QAAE,OAAO,QAAQ,CAAC;IACrC,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iFAAiF;AAEjF,SAAgB,uBAAuB,CACrC,MAAc,EACd,eAAyB;IAEzB,MAAM,QAAQ,GAAG,IAAA,oCAAqB,EAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAA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,CAAC,CAAC;IAEtE,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO,EAAE,eAAe;QACxB,gBAAgB,EAAE,uBAAuB;QACzC,MAAM;QACN,eAAe;QACf,YAAY;QACZ,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,iFAAiF;AAEjF,SAAgB,iBAAiB,CAAC,GAAW,EAAE,KAAK,GAAG,EAAE;IACvD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,oBAAoB,CAAC,GAAiB;IACpD,OAAO,IAAA,gCAAiB,EAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Rules — per-domain rules that describe how components must be
|
|
3
|
+
* connected to each other to form a correct end-to-end implementation.
|
|
4
|
+
*
|
|
5
|
+
* These rules are evaluated by flow-validator.ts against the dependency
|
|
6
|
+
* graph built from indexed diff files. They describe connectivity
|
|
7
|
+
* requirements, NOT presence requirements (presence is handled by matcher.ts).
|
|
8
|
+
*/
|
|
9
|
+
export type FlowRuleType = 'missing-flow' | 'misplaced-flow' | 'disconnected-flow';
|
|
10
|
+
export interface FlowRule {
|
|
11
|
+
/** Unique identifier used as the rule key in FlowIssue and fix mappings. */
|
|
12
|
+
id: string;
|
|
13
|
+
description: string;
|
|
14
|
+
type: FlowRuleType;
|
|
15
|
+
severity: 'high' | 'medium';
|
|
16
|
+
domain: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const FLOW_RULES: Record<string, FlowRule[]>;
|
|
19
|
+
/** Returns all flow rules for a given domain, or [] if the domain is unknown. */
|
|
20
|
+
export declare function flowRulesForDomain(domain: string): FlowRule[];
|
|
21
|
+
//# sourceMappingURL=flow-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-rules.d.ts","sourceRoot":"","sources":["../../src/intent-engine/flow-rules.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;AAEnF,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAiEjD,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CAE7D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Flow Rules — per-domain rules that describe how components must be
|
|
4
|
+
* connected to each other to form a correct end-to-end implementation.
|
|
5
|
+
*
|
|
6
|
+
* These rules are evaluated by flow-validator.ts against the dependency
|
|
7
|
+
* graph built from indexed diff files. They describe connectivity
|
|
8
|
+
* requirements, NOT presence requirements (presence is handled by matcher.ts).
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.FLOW_RULES = void 0;
|
|
12
|
+
exports.flowRulesForDomain = flowRulesForDomain;
|
|
13
|
+
exports.FLOW_RULES = {
|
|
14
|
+
auth: [
|
|
15
|
+
{
|
|
16
|
+
id: 'flow:token-not-validated-in-middleware',
|
|
17
|
+
description: 'Token must be validated in middleware before reaching route handlers',
|
|
18
|
+
type: 'missing-flow',
|
|
19
|
+
severity: 'high',
|
|
20
|
+
domain: 'auth',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'flow:middleware-not-applied-to-routes',
|
|
24
|
+
description: 'Auth middleware must be applied to protected route definitions',
|
|
25
|
+
type: 'disconnected-flow',
|
|
26
|
+
severity: 'high',
|
|
27
|
+
domain: 'auth',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'flow:auth-in-ui-layer',
|
|
31
|
+
description: 'Auth / crypto logic should not be implemented in UI layer components',
|
|
32
|
+
type: 'misplaced-flow',
|
|
33
|
+
severity: 'medium',
|
|
34
|
+
domain: 'auth',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
api: [
|
|
38
|
+
{
|
|
39
|
+
id: 'flow:validation-before-handler',
|
|
40
|
+
description: 'Input validation middleware must run before route handler business logic',
|
|
41
|
+
type: 'missing-flow',
|
|
42
|
+
severity: 'high',
|
|
43
|
+
domain: 'api',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 'flow:service-not-separated',
|
|
47
|
+
description: 'Route handlers should delegate to a service layer rather than calling DB directly',
|
|
48
|
+
type: 'misplaced-flow',
|
|
49
|
+
severity: 'medium',
|
|
50
|
+
domain: 'api',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
payment: [
|
|
54
|
+
{
|
|
55
|
+
id: 'flow:webhook-handler-without-verification',
|
|
56
|
+
description: 'Webhook payload must be verified before processing payment events',
|
|
57
|
+
type: 'missing-flow',
|
|
58
|
+
severity: 'high',
|
|
59
|
+
domain: 'payment',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'flow:payment-no-idempotency-gate',
|
|
63
|
+
description: 'Idempotency key must be checked before executing a charge or mutation',
|
|
64
|
+
type: 'missing-flow',
|
|
65
|
+
severity: 'high',
|
|
66
|
+
domain: 'payment',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
file: [
|
|
70
|
+
{
|
|
71
|
+
id: 'flow:file-stored-without-type-check',
|
|
72
|
+
description: 'File type and MIME type must be validated before storage or further processing',
|
|
73
|
+
type: 'missing-flow',
|
|
74
|
+
severity: 'high',
|
|
75
|
+
domain: 'file',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
/** Returns all flow rules for a given domain, or [] if the domain is unknown. */
|
|
80
|
+
function flowRulesForDomain(domain) {
|
|
81
|
+
return exports.FLOW_RULES[domain.toLowerCase()] ?? [];
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=flow-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-rules.js","sourceRoot":"","sources":["../../src/intent-engine/flow-rules.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAiFH,gDAEC;AAtEY,QAAA,UAAU,GAA+B;IACpD,IAAI,EAAE;QACJ;YACE,EAAE,EAAE,wCAAwC;YAC5C,WAAW,EAAE,sEAAsE;YACnF,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,MAAM;SACf;QACD;YACE,EAAE,EAAE,uCAAuC;YAC3C,WAAW,EAAE,gEAAgE;YAC7E,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,MAAM;SACf;QACD;YACE,EAAE,EAAE,uBAAuB;YAC3B,WAAW,EAAE,sEAAsE;YACnF,IAAI,EAAE,gBAAgB;YACtB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,MAAM;SACf;KACF;IACD,GAAG,EAAE;QACH;YACE,EAAE,EAAE,gCAAgC;YACpC,WAAW,EAAE,0EAA0E;YACvF,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,KAAK;SACd;QACD;YACE,EAAE,EAAE,4BAA4B;YAChC,WAAW,EAAE,mFAAmF;YAChG,IAAI,EAAE,gBAAgB;YACtB,QAAQ,EAAE,QAAQ;YAClB,MAAM,EAAE,KAAK;SACd;KACF;IACD,OAAO,EAAE;QACP;YACE,EAAE,EAAE,2CAA2C;YAC/C,WAAW,EAAE,mEAAmE;YAChF,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,SAAS;SAClB;QACD;YACE,EAAE,EAAE,kCAAkC;YACtC,WAAW,EAAE,uEAAuE;YACpF,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,SAAS;SAClB;KACF;IACD,IAAI,EAAE;QACJ;YACE,EAAE,EAAE,qCAAqC;YACzC,WAAW,EAAE,gFAAgF;YAC7F,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,MAAM;YAChB,MAAM,EAAE,MAAM;SACf;KACF;CACF,CAAC;AAEF,iFAAiF;AACjF,SAAgB,kBAAkB,CAAC,MAAc;IAC/C,OAAO,kBAAU,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Validator — checks whether detected components are correctly connected
|
|
3
|
+
* to each other to form a functioning end-to-end system.
|
|
4
|
+
*
|
|
5
|
+
* This is orthogonal to presence checking (matcher.ts). A component can be
|
|
6
|
+
* present but disconnected (e.g. middleware defined but never applied to routes).
|
|
7
|
+
*
|
|
8
|
+
* All checks are deterministic. No LLM calls. No disk I/O — operates only
|
|
9
|
+
* on data already produced by the indexer and graph builder.
|
|
10
|
+
*/
|
|
11
|
+
import type { FileNode } from './graph';
|
|
12
|
+
export interface FlowIssue {
|
|
13
|
+
/** Unique rule identifier — used for fix mapping and deduplication. */
|
|
14
|
+
rule: string;
|
|
15
|
+
type: 'missing-flow' | 'misplaced-flow' | 'disconnected-flow';
|
|
16
|
+
message: string;
|
|
17
|
+
files?: string[];
|
|
18
|
+
severity: 'high' | 'medium';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Run all flow validators for the given domains.
|
|
22
|
+
*
|
|
23
|
+
* @param domains - Domains inferred from plan intent (e.g. ['auth', 'api'])
|
|
24
|
+
* @param componentMap - Component key → file paths (from matcher.ts)
|
|
25
|
+
* @param graph - Dependency graph built from indexed diff files
|
|
26
|
+
* @returns Deduplicated list of FlowIssue
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateFlows(domains: string[], componentMap: Record<string, string[]>, graph: Map<string, FileNode>): FlowIssue[];
|
|
29
|
+
//# sourceMappingURL=flow-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-validator.d.ts","sourceRoot":"","sources":["../../src/intent-engine/flow-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKxC,MAAM,WAAW,SAAS;IACxB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,GAAG,gBAAgB,GAAG,mBAAmB,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;CAC7B;AA4ND;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EAAE,EACjB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACtC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAC3B,SAAS,EAAE,CAuBb"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Flow Validator — checks whether detected components are correctly connected
|
|
4
|
+
* to each other to form a functioning end-to-end system.
|
|
5
|
+
*
|
|
6
|
+
* This is orthogonal to presence checking (matcher.ts). A component can be
|
|
7
|
+
* present but disconnected (e.g. middleware defined but never applied to routes).
|
|
8
|
+
*
|
|
9
|
+
* All checks are deterministic. No LLM calls. No disk I/O — operates only
|
|
10
|
+
* on data already produced by the indexer and graph builder.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.validateFlows = validateFlows;
|
|
14
|
+
const graph_1 = require("./graph");
|
|
15
|
+
// ── Regex constants ───────────────────────────────────────────────────────────
|
|
16
|
+
// Token generation
|
|
17
|
+
const RE_TOKEN_SIGN = /jwt\.sign\s*\(|signToken\s*\(|signJWT\s*\(/i;
|
|
18
|
+
// Token validation (as used in middleware)
|
|
19
|
+
const RE_TOKEN_VERIFY = /jwt\.verify\s*\(|verifyToken\s*\(|validateToken\s*\(|verify(JWT|Token|Auth)\s*\(/i;
|
|
20
|
+
// Middleware being applied to routes
|
|
21
|
+
const RE_MIDDLEWARE_APPLY = /router\.(use|get|post|put|delete|patch)\s*\([^,)]*,\s*(auth|protect|verify|guard|middleware)/i;
|
|
22
|
+
const RE_APP_MIDDLEWARE = /app\.(use|get|post|put|delete|patch)\s*\([^,)]*,?\s*(auth|protect|verify|guard|require)/i;
|
|
23
|
+
// Auth / crypto in UI
|
|
24
|
+
const RE_AUTH_IN_UI = /jwt\.(sign|verify)\s*\(|bcrypt\.(hash|compare)\s*\(/i;
|
|
25
|
+
// Webhook handling
|
|
26
|
+
const RE_WEBHOOK_HANDLER = /webhook|stripe.*event|paypal.*webhook/i;
|
|
27
|
+
const RE_WEBHOOK_VERIFY = /stripe\.webhooks\.constructEvent\s*\(|verifyWebhookSignature\s*\(|createHmac\s*\(/i;
|
|
28
|
+
// Payment charge
|
|
29
|
+
const RE_PAYMENT_CHARGE = /stripe\.charges\.create\s*\(|stripe\.paymentIntents\.create\s*\(|charge\s*\(/i;
|
|
30
|
+
const RE_IDEMPOTENCY = /idempotencyKey\s*:|idempotency.key\s*:|findOrCreate/i;
|
|
31
|
+
// File storage
|
|
32
|
+
const RE_FILE_STORE = /\.(save|write|upload|put)\s*\(|multer|diskStorage|s3\.(upload|putObject)/i;
|
|
33
|
+
const RE_FILE_TYPE_CHECK = /mimetype.*valid|allowedMimeTypes|fileFilter\s*\(|mime\.getType/i;
|
|
34
|
+
// DB direct in routes
|
|
35
|
+
const RE_DB_DIRECT = /\b(prisma|db|knex|sequelize|pool)\s*\.\s*(query|findMany|findFirst|findUnique|create|update|delete|execute)\b/i;
|
|
36
|
+
// Import from service layer
|
|
37
|
+
const RE_SERVICE_IMPORT = /import\s+.*from\s+['"][^'"]*\/(service|repository|repo|use[-_]?case)[^'"]*['"]/i;
|
|
38
|
+
// ── Domain validators ─────────────────────────────────────────────────────────
|
|
39
|
+
function validateAuthFlow(componentMap, graph) {
|
|
40
|
+
const issues = [];
|
|
41
|
+
// A. Token → Middleware: token generated but never verified in the diff
|
|
42
|
+
const tokenGenFiles = componentMap['token-generation'] ?? [];
|
|
43
|
+
const middlewareNodes = (0, graph_1.nodesOfLayer)(graph, 'middleware', 'api');
|
|
44
|
+
if (tokenGenFiles.length > 0) {
|
|
45
|
+
const verificationExists = middlewareNodes.some((n) => RE_TOKEN_VERIFY.test(n.addedContent));
|
|
46
|
+
if (!verificationExists) {
|
|
47
|
+
// Also check all diff nodes — verification may be in a service file
|
|
48
|
+
const anyVerification = (0, graph_1.anyNodeMatches)(graph, RE_TOKEN_VERIFY);
|
|
49
|
+
if (!anyVerification) {
|
|
50
|
+
issues.push({
|
|
51
|
+
rule: 'flow:token-not-validated-in-middleware',
|
|
52
|
+
type: 'missing-flow',
|
|
53
|
+
message: 'Token is generated but not validated in middleware — add jwt.verify() / verifyToken() in an auth middleware',
|
|
54
|
+
files: tokenGenFiles,
|
|
55
|
+
severity: 'high',
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// B. Middleware → Routes: middleware defined or found but never applied in route files
|
|
61
|
+
const middlewareProtectionFiles = componentMap['middleware-protection'] ?? [];
|
|
62
|
+
const authMiddlewareFiles = componentMap['auth-middleware'] ?? [];
|
|
63
|
+
const knownMiddlewareFiles = [...new Set([...middlewareProtectionFiles, ...authMiddlewareFiles])];
|
|
64
|
+
if (knownMiddlewareFiles.length > 0) {
|
|
65
|
+
const routeNodes = (0, graph_1.nodesOfLayer)(graph, 'api');
|
|
66
|
+
// Check if any route node applies middleware via router.use/app.use/inline
|
|
67
|
+
const middlewareApplied = routeNodes.some((n) => RE_MIDDLEWARE_APPLY.test(n.addedContent)) ||
|
|
68
|
+
routeNodes.some((n) => RE_APP_MIDDLEWARE.test(n.addedContent)) ||
|
|
69
|
+
// Or imports the middleware file
|
|
70
|
+
routeNodes.some((n) => knownMiddlewareFiles.some((mf) => (0, graph_1.nodeImportsFile)(n, mf)));
|
|
71
|
+
if (!middlewareApplied && routeNodes.length > 0) {
|
|
72
|
+
issues.push({
|
|
73
|
+
rule: 'flow:middleware-not-applied-to-routes',
|
|
74
|
+
type: 'disconnected-flow',
|
|
75
|
+
message: 'Auth middleware is defined but not applied to any routes — wire it into route definitions with router.use(authMiddleware)',
|
|
76
|
+
files: [...routeNodes.map((n) => n.file), ...knownMiddlewareFiles],
|
|
77
|
+
severity: 'high',
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// C. Layer violation: auth logic found in UI components
|
|
82
|
+
const uiNodes = (0, graph_1.nodesOfLayer)(graph, 'ui');
|
|
83
|
+
const uiOffenders = uiNodes.filter((n) => RE_AUTH_IN_UI.test(n.addedContent));
|
|
84
|
+
if (uiOffenders.length > 0) {
|
|
85
|
+
issues.push({
|
|
86
|
+
rule: 'flow:auth-in-ui-layer',
|
|
87
|
+
type: 'misplaced-flow',
|
|
88
|
+
message: 'Auth / crypto logic found in UI layer — JWT signing, verification, and bcrypt calls must live in the API or service layer',
|
|
89
|
+
files: uiOffenders.map((n) => n.file),
|
|
90
|
+
severity: 'medium',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return issues;
|
|
94
|
+
}
|
|
95
|
+
function validateApiFlow(componentMap, graph) {
|
|
96
|
+
const issues = [];
|
|
97
|
+
// Route handler calls DB directly without going through a service layer
|
|
98
|
+
const routeNodes = (0, graph_1.nodesOfLayer)(graph, 'api');
|
|
99
|
+
const directDbRoutes = routeNodes.filter((n) => RE_DB_DIRECT.test(n.addedContent) && !RE_SERVICE_IMPORT.test(n.addedContent));
|
|
100
|
+
if (directDbRoutes.length > 0) {
|
|
101
|
+
issues.push({
|
|
102
|
+
rule: 'flow:service-not-separated',
|
|
103
|
+
type: 'misplaced-flow',
|
|
104
|
+
message: 'Route handler(s) access the database directly — extract DB logic into a service or repository module',
|
|
105
|
+
files: directDbRoutes.map((n) => n.file),
|
|
106
|
+
severity: 'medium',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return issues;
|
|
110
|
+
}
|
|
111
|
+
function validatePaymentFlow(componentMap, graph) {
|
|
112
|
+
const issues = [];
|
|
113
|
+
// D. Webhook handler without signature verification
|
|
114
|
+
const hasWebhookHandler = (0, graph_1.anyNodeMatches)(graph, RE_WEBHOOK_HANDLER);
|
|
115
|
+
const hasWebhookVerify = (0, graph_1.anyNodeMatches)(graph, RE_WEBHOOK_VERIFY);
|
|
116
|
+
if (hasWebhookHandler && !hasWebhookVerify) {
|
|
117
|
+
const webhookFiles = [...graph.values()]
|
|
118
|
+
.filter((n) => RE_WEBHOOK_HANDLER.test(n.addedContent))
|
|
119
|
+
.map((n) => n.file);
|
|
120
|
+
issues.push({
|
|
121
|
+
rule: 'flow:webhook-handler-without-verification',
|
|
122
|
+
type: 'missing-flow',
|
|
123
|
+
message: 'Webhook handler added but signature is not verified — use stripe.webhooks.constructEvent() or createHmac() to authenticate the payload',
|
|
124
|
+
files: webhookFiles,
|
|
125
|
+
severity: 'high',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// E. Payment charge without idempotency gate
|
|
129
|
+
const hasPaymentCharge = (0, graph_1.anyNodeMatches)(graph, RE_PAYMENT_CHARGE);
|
|
130
|
+
const hasIdempotency = (0, graph_1.anyNodeMatches)(graph, RE_IDEMPOTENCY);
|
|
131
|
+
if (hasPaymentCharge && !hasIdempotency) {
|
|
132
|
+
const chargeFiles = [...graph.values()]
|
|
133
|
+
.filter((n) => RE_PAYMENT_CHARGE.test(n.addedContent))
|
|
134
|
+
.map((n) => n.file);
|
|
135
|
+
issues.push({
|
|
136
|
+
rule: 'flow:payment-no-idempotency-gate',
|
|
137
|
+
type: 'missing-flow',
|
|
138
|
+
message: 'Payment charge code found without idempotency key handling — add idempotency checks to prevent duplicate charges',
|
|
139
|
+
files: chargeFiles,
|
|
140
|
+
severity: 'high',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return issues;
|
|
144
|
+
}
|
|
145
|
+
function validateFileFlow(componentMap, graph) {
|
|
146
|
+
const issues = [];
|
|
147
|
+
const hasFileStore = (0, graph_1.anyNodeMatches)(graph, RE_FILE_STORE);
|
|
148
|
+
const hasTypeCheck = (0, graph_1.anyNodeMatches)(graph, RE_FILE_TYPE_CHECK);
|
|
149
|
+
if (hasFileStore && !hasTypeCheck) {
|
|
150
|
+
const storeFiles = [...graph.values()]
|
|
151
|
+
.filter((n) => RE_FILE_STORE.test(n.addedContent))
|
|
152
|
+
.map((n) => n.file);
|
|
153
|
+
issues.push({
|
|
154
|
+
rule: 'flow:file-stored-without-type-check',
|
|
155
|
+
type: 'missing-flow',
|
|
156
|
+
message: 'File storage code found but MIME type / file-type validation is absent — validate mimetype before accepting uploads',
|
|
157
|
+
files: storeFiles,
|
|
158
|
+
severity: 'high',
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return issues;
|
|
162
|
+
}
|
|
163
|
+
// ── Domain dispatch ───────────────────────────────────────────────────────────
|
|
164
|
+
const DOMAIN_VALIDATORS = {
|
|
165
|
+
auth: validateAuthFlow,
|
|
166
|
+
api: validateApiFlow,
|
|
167
|
+
payment: validatePaymentFlow,
|
|
168
|
+
file: validateFileFlow,
|
|
169
|
+
};
|
|
170
|
+
// ── Public API ────────────────────────────────────────────────────────────────
|
|
171
|
+
/**
|
|
172
|
+
* Run all flow validators for the given domains.
|
|
173
|
+
*
|
|
174
|
+
* @param domains - Domains inferred from plan intent (e.g. ['auth', 'api'])
|
|
175
|
+
* @param componentMap - Component key → file paths (from matcher.ts)
|
|
176
|
+
* @param graph - Dependency graph built from indexed diff files
|
|
177
|
+
* @returns Deduplicated list of FlowIssue
|
|
178
|
+
*/
|
|
179
|
+
function validateFlows(domains, componentMap, graph) {
|
|
180
|
+
if (domains.length === 0 || graph.size === 0)
|
|
181
|
+
return [];
|
|
182
|
+
const issueMap = new Map();
|
|
183
|
+
for (const domain of domains) {
|
|
184
|
+
const validator = DOMAIN_VALIDATORS[domain.toLowerCase()];
|
|
185
|
+
if (!validator)
|
|
186
|
+
continue;
|
|
187
|
+
try {
|
|
188
|
+
const domainIssues = validator(componentMap, graph);
|
|
189
|
+
for (const issue of domainIssues) {
|
|
190
|
+
// Deduplicate by rule — first reporter wins
|
|
191
|
+
if (!issueMap.has(issue.rule)) {
|
|
192
|
+
issueMap.set(issue.rule, issue);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
// Non-fatal: a buggy validator must never break verification
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return [...issueMap.values()];
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=flow-validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-validator.js","sourceRoot":"","sources":["../../src/intent-engine/flow-validator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AAkPH,sCA2BC;AA1QD,mCAAwE;AAaxE,iFAAi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file relationships from an already-built FileMeta index.
|
|
4
|
+
*
|
|
5
|
+
* No disk I/O. Purely derived from the diff data the indexer has already
|
|
6
|
+
* parsed, so it adds negligible time to verification.
|
|
7
|
+
*/
|
|
8
|
+
import type { FileMeta, FileLayer } from './indexer';
|
|
9
|
+
/**
|
|
10
|
+
* Refined layer type — extends the indexer's FileLayer with 'middleware'
|
|
11
|
+
* so the flow validator can distinguish middleware files from generic API files.
|
|
12
|
+
*/
|
|
13
|
+
export type GraphLayer = FileLayer | 'middleware';
|
|
14
|
+
export interface FileNode {
|
|
15
|
+
file: string;
|
|
16
|
+
/** Module specifiers from import / require statements in added diff lines. */
|
|
17
|
+
imports: string[];
|
|
18
|
+
layer: GraphLayer;
|
|
19
|
+
addedContent: string;
|
|
20
|
+
keywords: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a FileNode graph from the FileMeta index produced by indexDiffFiles().
|
|
24
|
+
* Returns Map<filePath, FileNode>.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildFlowGraph(index: Map<string, FileMeta>): Map<string, FileNode>;
|
|
27
|
+
/** Returns nodes whose layer matches any of the given layers. */
|
|
28
|
+
export declare function nodesOfLayer(graph: Map<string, FileNode>, ...layers: GraphLayer[]): FileNode[];
|
|
29
|
+
/** Returns true when any node in the graph has content matching the pattern. */
|
|
30
|
+
export declare function anyNodeMatches(graph: Map<string, FileNode>, re: RegExp): boolean;
|
|
31
|
+
/** Returns true when node `a` imports something that matches the path of node `b`. */
|
|
32
|
+
export declare function nodeImportsFile(a: FileNode, bPath: string): boolean;
|
|
33
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/intent-engine/graph.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAIrD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,YAAY,CAAC;AAElD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,8EAA8E;IAC9E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,UAAU,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAiBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAclF;AAID,iEAAiE;AACjE,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,CAG9F;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAKhF;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQnE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dependency Graph Builder — constructs a lightweight, in-memory graph of
|
|
4
|
+
* file relationships from an already-built FileMeta index.
|
|
5
|
+
*
|
|
6
|
+
* No disk I/O. Purely derived from the diff data the indexer has already
|
|
7
|
+
* parsed, so it adds negligible time to verification.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.buildFlowGraph = buildFlowGraph;
|
|
11
|
+
exports.nodesOfLayer = nodesOfLayer;
|
|
12
|
+
exports.anyNodeMatches = anyNodeMatches;
|
|
13
|
+
exports.nodeImportsFile = nodeImportsFile;
|
|
14
|
+
// ── Layer refinement ──────────────────────────────────────────────────────────
|
|
15
|
+
const MIDDLEWARE_PATH = /\bmiddleware\b/i;
|
|
16
|
+
// Signature patterns that indicate a file exports middleware functions
|
|
17
|
+
const MIDDLEWARE_EXPORT_RE = /\b(RequestHandler|NextFunction|express\.Request)\b|module\.exports\s*=\s*\w*[Mm]iddleware|\bexport\s+(default\s+)?function\s+\w*[Mm]iddleware/i;
|
|
18
|
+
function refineLayer(meta) {
|
|
19
|
+
if (MIDDLEWARE_PATH.test(meta.path))
|
|
20
|
+
return 'middleware';
|
|
21
|
+
if (MIDDLEWARE_EXPORT_RE.test(meta.addedContent))
|
|
22
|
+
return 'middleware';
|
|
23
|
+
return meta.layer;
|
|
24
|
+
}
|
|
25
|
+
// ── Public API ────────────────────────────────────────────────────────────────
|
|
26
|
+
/**
|
|
27
|
+
* Build a FileNode graph from the FileMeta index produced by indexDiffFiles().
|
|
28
|
+
* Returns Map<filePath, FileNode>.
|
|
29
|
+
*/
|
|
30
|
+
function buildFlowGraph(index) {
|
|
31
|
+
const graph = new Map();
|
|
32
|
+
for (const [path, meta] of index) {
|
|
33
|
+
graph.set(path, {
|
|
34
|
+
file: path,
|
|
35
|
+
imports: meta.imports,
|
|
36
|
+
layer: refineLayer(meta),
|
|
37
|
+
addedContent: meta.addedContent,
|
|
38
|
+
keywords: meta.keywords,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return graph;
|
|
42
|
+
}
|
|
43
|
+
// ── Query helpers ─────────────────────────────────────────────────────────────
|
|
44
|
+
/** Returns nodes whose layer matches any of the given layers. */
|
|
45
|
+
function nodesOfLayer(graph, ...layers) {
|
|
46
|
+
const set = new Set(layers);
|
|
47
|
+
return [...graph.values()].filter((n) => set.has(n.layer));
|
|
48
|
+
}
|
|
49
|
+
/** Returns true when any node in the graph has content matching the pattern. */
|
|
50
|
+
function anyNodeMatches(graph, re) {
|
|
51
|
+
for (const node of graph.values()) {
|
|
52
|
+
if (re.test(node.addedContent))
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/** Returns true when node `a` imports something that matches the path of node `b`. */
|
|
58
|
+
function nodeImportsFile(a, bPath) {
|
|
59
|
+
// Strip extension + leading './' so "import from '../auth/auth.middleware'"
|
|
60
|
+
// matches a file at 'src/auth/auth.middleware.ts'.
|
|
61
|
+
const bBasename = bPath.replace(/\.[jt]sx?$/, '').replace(/.*[/\\]/, '');
|
|
62
|
+
return a.imports.some((imp) => {
|
|
63
|
+
const impBasename = imp.replace(/.*[/\\]/, '');
|
|
64
|
+
return impBasename === bBasename || imp.includes(bBasename);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/intent-engine/graph.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAwCH,wCAcC;AAKD,oCAGC;AAGD,wCAKC;AAGD,0CAQC;AA5DD,iFAAiF;AAEjF,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAC1C,uEAAuE;AACvE,MAAM,oBAAoB,GACxB,gJAAgJ,CAAC;AAEnJ,SAAS,WAAW,CAAC,IAAc;IACjC,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,YAAY,CAAC;IACzD,IAAI,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,OAAO,YAAY,CAAC;IACtE,OAAO,IAAI,CAAC,KAAK,CAAC;AACpB,CAAC;AAED,iFAAiF;AAEjF;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAA4B;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE1C,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACjC,KAAK,CAAC,GAAG,CAAC,IAAI,E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AAC,SAAS,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export { parseIntent, type ParsedIntent } from './parser';
|
|
2
|
+
export { indexDiffFiles, type FileMeta, type FileLayer } from './indexer';
|
|
3
|
+
export { matchIntentToCode, type IntentIssue, type MatchResult, type ComponentQualityLevel, } from './matcher';
|
|
4
|
+
export { computeCoverage, computeIntentSummary, formatCoverageBar, formatComponentLabel, type DomainCoverage, type IntentSummary, type ConfidenceLevel, type SystemStatus, } from './coverage';
|
|
5
|
+
export { requirementsForDomain, labelForComponent, type ComponentKey } from './requirements';
|
|
6
|
+
export { buildFlowGraph, type FileNode, type GraphLayer } from './graph';
|
|
7
|
+
export { validateFlows, type FlowIssue } from './flow-validator';
|
|
8
|
+
export { type FlowRule, type FlowRuleType } from './flow-rules';
|
|
9
|
+
export { loadPreviousState, saveCurrentState, buildCurrentState, type IntentState } from './state';
|
|
10
|
+
export { detectRegressions, type RegressionIssue, type RegressionType } from './regression';
|
|
11
|
+
import type { DiffFile } from '@neurcode-ai/diff-parser';
|
|
12
|
+
import { type IntentIssue, type ComponentQualityLevel } from './matcher';
|
|
13
|
+
import { type IntentSummary } from './coverage';
|
|
14
|
+
import { type FlowIssue } from './flow-validator';
|
|
15
|
+
import { type RegressionIssue } from './regression';
|
|
16
|
+
export interface IntentEngineResult {
|
|
17
|
+
intentIssues: IntentIssue[];
|
|
18
|
+
checkedDomains: string[];
|
|
19
|
+
foundComponents: Record<string, string[]>;
|
|
20
|
+
componentMap: Record<string, string[]>;
|
|
21
|
+
componentQuality: Record<string, ComponentQualityLevel>;
|
|
22
|
+
intentSummary: IntentSummary | null;
|
|
23
|
+
/** V5: wiring and connectivity issues between components */
|
|
24
|
+
flowIssues: FlowIssue[];
|
|
25
|
+
/** V6: previously-working behaviour that has now degraded */
|
|
26
|
+
regressions: RegressionIssue[];
|
|
27
|
+
intentText: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Single entry point: parse intent → index → match → coverage → flow → regression.
|
|
31
|
+
* Returns empty result if intent is blank or diff is empty.
|
|
32
|
+
* Never throws — errors are caught and return a safe empty result.
|
|
33
|
+
*/
|
|
34
|
+
export declare function runIntentEngine(intentText: string, diffFiles: DiffFile[], projectRoot?: string): IntentEngineResult;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/intent-engine/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EACL,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,qBAAqB,GAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,cAAc,EAAE,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAC5F,OAAO,EAAwB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1C,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACxD,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,4DAA4D;IAC5D,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,6DAA6D;IAC7D,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;CACpB;AAaD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,QAAQ,EAAE,EACrB,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB,CA2DpB"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectRegressions = exports.buildCurrentState = exports.saveCurrentState = exports.loadPreviousState = exports.validateFlows = exports.buildFlowGraph = exports.labelForComponent = exports.requirementsForDomain = exports.formatComponentLabel = exports.formatCoverageBar = exports.computeIntentSummary = exports.computeCoverage = exports.matchIntentToCode = exports.indexDiffFiles = exports.parseIntent = void 0;
|
|
4
|
+
exports.runIntentEngine = runIntentEngine;
|
|
5
|
+
var parser_1 = require("./parser");
|
|
6
|
+
Object.defineProperty(exports, "parseIntent", { enumerable: true, get: function () { return parser_1.parseIntent; } });
|
|
7
|
+
var indexer_1 = require("./indexer");
|
|
8
|
+
Object.defineProperty(exports, "indexDiffFiles", { enumerable: true, get: function () { return indexer_1.indexDiffFiles; } });
|
|
9
|
+
var matcher_1 = require("./matcher");
|
|
10
|
+
Object.defineProperty(exports, "matchIntentToCode", { enumerable: true, get: function () { return matcher_1.matchIntentToCode; } });
|
|
11
|
+
var coverage_1 = require("./coverage");
|
|
12
|
+
Object.defineProperty(exports, "computeCoverage", { enumerable: true, get: function () { return coverage_1.computeCoverage; } });
|
|
13
|
+
Object.defineProperty(exports, "computeIntentSummary", { enumerable: true, get: function () { return coverage_1.computeIntentSummary; } });
|
|
14
|
+
Object.defineProperty(exports, "formatCoverageBar", { enumerable: true, get: function () { return coverage_1.formatCoverageBar; } });
|
|
15
|
+
Object.defineProperty(exports, "formatComponentLabel", { enumerable: true, get: function () { return coverage_1.formatComponentLabel; } });
|
|
16
|
+
var requirements_1 = require("./requirements");
|
|
17
|
+
Object.defineProperty(exports, "requirementsForDomain", { enumerable: true, get: function () { return requirements_1.requirementsForDomain; } });
|
|
18
|
+
Object.defineProperty(exports, "labelForComponent", { enumerable: true, get: function () { return requirements_1.labelForComponent; } });
|
|
19
|
+
var graph_1 = require("./graph");
|
|
20
|
+
Object.defineProperty(exports, "buildFlowGraph", { enumerable: true, get: function () { return graph_1.buildFlowGraph; } });
|
|
21
|
+
var flow_validator_1 = require("./flow-validator");
|
|
22
|
+
Object.defineProperty(exports, "validateFlows", { enumerable: true, get: function () { return flow_validator_1.validateFlows; } });
|
|
23
|
+
var state_1 = require("./state");
|
|
24
|
+
Object.defineProperty(exports, "loadPreviousState", { enumerable: true, get: function () { return state_1.loadPreviousState; } });
|
|
25
|
+
Object.defineProperty(exports, "saveCurrentState", { enumerable: true, get: function () { return state_1.saveCurrentState; } });
|
|
26
|
+
Object.defineProperty(exports, "buildCurrentState", { enumerable: true, get: function () { return state_1.buildCurrentState; } });
|
|
27
|
+
var regression_1 = require("./regression");
|
|
28
|
+
Object.defineProperty(exports, "detectRegressions", { enumerable: true, get: function () { return regression_1.detectRegressions; } });
|
|
29
|
+
const parser_2 = require("./parser");
|
|
30
|
+
const indexer_2 = require("./indexer");
|
|
31
|
+
const matcher_2 = require("./matcher");
|
|
32
|
+
const coverage_2 = require("./coverage");
|
|
33
|
+
const graph_2 = require("./graph");
|
|
34
|
+
const flow_validator_2 = require("./flow-validator");
|
|
35
|
+
const state_2 = require("./state");
|
|
36
|
+
const regression_2 = require("./regression");
|
|
37
|
+
const EMPTY_RESULT = {
|
|
38
|
+
intentIssues: [],
|
|
39
|
+
checkedDomains: [],
|
|
40
|
+
foundComponents: {},
|
|
41
|
+
componentMap: {},
|
|
42
|
+
componentQuality: {},
|
|
43
|
+
intentSummary: null,
|
|
44
|
+
flowIssues: [],
|
|
45
|
+
regressions: [],
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Single entry point: parse intent → index → match → coverage → flow → regression.
|
|
49
|
+
* Returns empty result if intent is blank or diff is empty.
|
|
50
|
+
* Never throws — errors are caught and return a safe empty result.
|
|
51
|
+
*/
|
|
52
|
+
function runIntentEngine(intentText, diffFiles, projectRoot) {
|
|
53
|
+
try {
|
|
54
|
+
const parsed = (0, parser_2.parseIntent)(intentText);
|
|
55
|
+
if (parsed.domains.length === 0) {
|
|
56
|
+
return { ...EMPTY_RESULT, intentText };
|
|
57
|
+
}
|
|
58
|
+
const index = (0, indexer_2.indexDiffFiles)(diffFiles);
|
|
59
|
+
const { intentIssues, checkedDomains, foundComponents, componentMap, componentQuality } = (0, matcher_2.matchIntentToCode)(parsed, index);
|
|
60
|
+
const intentSummary = (0, coverage_2.computeIntentSummary)(checkedDomains, foundComponents, componentMap, componentQuality);
|
|
61
|
+
// V5: build dependency graph and run flow validation
|
|
62
|
+
const graph = (0, graph_2.buildFlowGraph)(index);
|
|
63
|
+
const flowIssues = (0, flow_validator_2.validateFlows)(checkedDomains, componentMap, graph);
|
|
64
|
+
// V6: regression detection
|
|
65
|
+
let regressions = [];
|
|
66
|
+
if (projectRoot) {
|
|
67
|
+
try {
|
|
68
|
+
const previousState = (0, state_2.loadPreviousState)(projectRoot);
|
|
69
|
+
regressions = (0, regression_2.detectRegressions)(previousState, intentSummary, flowIssues, componentMap, intentText);
|
|
70
|
+
// Persist current state for the next run
|
|
71
|
+
const flowIssueIds = flowIssues.map((fi) => fi.rule);
|
|
72
|
+
(0, state_2.saveCurrentState)(projectRoot, (0, state_2.buildCurrentState)(intentText, intentSummary, flowIssueIds, componentMap));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Non-fatal: regression errors must never break verification
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
intentIssues,
|
|
80
|
+
checkedDomains,
|
|
81
|
+
foundComponents,
|
|
82
|
+
componentMap,
|
|
83
|
+
componentQuality,
|
|
84
|
+
intentSummary,
|
|
85
|
+
flowIssues,
|
|
86
|
+
regressions,
|
|
87
|
+
intentText,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return { ...EMPTY_RESULT, intentText };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/intent-engine/index.ts"],"names":[],"mappings":";;;AAiEA,0CA+DC;AAhID,mCAA0D;AAAjD,qGAAA,WAAW,OAAA;AACpB,qCAA0E;AAAjE,yGAAA,cAAc,OAAA;AACvB,qCAKmB;AAJjB,4GAAA,iBAAiB,OAAA;AAKnB,uCASoB;AARlB,2GAAA,eAAe,OAAA;AACf,gHAAA,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