cgraphx 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.claude-template/hooks/precommit-check/precommit-check.cjs +90 -0
- package/dist/.claude-template/skills/cgraphx-guide/how-to-use.html +99 -78
- package/dist/.claude-template/skills/precommit-review/SKILL.md +50 -0
- package/dist/.claude-template/skills/run-api-test/SKILL.md +187 -0
- package/dist/.claude-template/skills/run-api-test/assets/template-test-report.md +103 -0
- package/dist/.claude-template/skills/run-api-test/assets/template-test-verify.jsonl +5 -0
- package/dist/.claude-template/skills/run-api-test/references/bru-run.md +60 -0
- package/dist/.claude-template/skills/run-api-test/references/db-verification.md +81 -0
- package/dist/.claude-template/skills/run-api-test/references/report-format.md +104 -0
- package/dist/.claude-template/skills/run-api-test/references/service-readiness.md +61 -0
- package/dist/.claude-template/skills/run-api-test/references/test-scope.md +64 -0
- package/dist/.claude-template/skills/write-api/SKILL.md +150 -0
- package/dist/.claude-template/skills/write-api/assets/template-api-spec.md +112 -0
- package/dist/.claude-template/skills/write-api/assets/template-request.bru +75 -0
- package/dist/.claude-template/skills/write-api/references/ai-prompts.md +133 -0
- package/dist/.claude-template/skills/write-api/references/api-spec-format.md +108 -0
- package/dist/.claude-template/skills/write-api/references/bru-format.md +144 -0
- package/dist/.claude-template/skills/write-api/references/collection-layout.md +81 -0
- package/dist/.claude-template/skills/write-api/references/environment-setup.md +105 -0
- package/dist/.claude-template/skills/write-api/references/interface-scope.md +74 -0
- package/dist/api-test/ai-fields.d.ts +37 -0
- package/dist/api-test/ai-fields.d.ts.map +1 -0
- package/dist/api-test/ai-fields.js +114 -0
- package/dist/api-test/ai-fields.js.map +1 -0
- package/dist/api-test/assemble.d.ts +76 -0
- package/dist/api-test/assemble.d.ts.map +1 -0
- package/dist/api-test/assemble.js +185 -0
- package/dist/api-test/assemble.js.map +1 -0
- package/dist/api-test/bru-cli-invoker.d.ts +72 -0
- package/dist/api-test/bru-cli-invoker.d.ts.map +1 -0
- package/dist/api-test/bru-cli-invoker.js +169 -0
- package/dist/api-test/bru-cli-invoker.js.map +1 -0
- package/dist/api-test/bru-report-parser.d.ts +24 -0
- package/dist/api-test/bru-report-parser.d.ts.map +1 -0
- package/dist/api-test/bru-report-parser.js +110 -0
- package/dist/api-test/bru-report-parser.js.map +1 -0
- package/dist/api-test/bru-runner.d.ts +101 -0
- package/dist/api-test/bru-runner.d.ts.map +1 -0
- package/dist/api-test/bru-runner.js +316 -0
- package/dist/api-test/bru-runner.js.map +1 -0
- package/dist/api-test/bru-writer.d.ts +52 -0
- package/dist/api-test/bru-writer.d.ts.map +1 -0
- package/dist/api-test/bru-writer.js +159 -0
- package/dist/api-test/bru-writer.js.map +1 -0
- package/dist/api-test/call-chain-extractor.d.ts +80 -0
- package/dist/api-test/call-chain-extractor.d.ts.map +1 -0
- package/dist/api-test/call-chain-extractor.js +179 -0
- package/dist/api-test/call-chain-extractor.js.map +1 -0
- package/dist/api-test/cli.d.ts +133 -0
- package/dist/api-test/cli.d.ts.map +1 -0
- package/dist/api-test/cli.js +1009 -0
- package/dist/api-test/cli.js.map +1 -0
- package/dist/api-test/config.d.ts +75 -0
- package/dist/api-test/config.d.ts.map +1 -0
- package/dist/api-test/config.js +406 -0
- package/dist/api-test/config.js.map +1 -0
- package/dist/api-test/db-query-cli.d.ts +51 -0
- package/dist/api-test/db-query-cli.d.ts.map +1 -0
- package/dist/api-test/db-query-cli.js +119 -0
- package/dist/api-test/db-query-cli.js.map +1 -0
- package/dist/api-test/enhance-prepare.d.ts +111 -0
- package/dist/api-test/enhance-prepare.d.ts.map +1 -0
- package/dist/api-test/enhance-prepare.js +425 -0
- package/dist/api-test/enhance-prepare.js.map +1 -0
- package/dist/api-test/enhance-write.d.ts +28 -0
- package/dist/api-test/enhance-write.d.ts.map +1 -0
- package/dist/api-test/enhance-write.js +145 -0
- package/dist/api-test/enhance-write.js.map +1 -0
- package/dist/api-test/errors.d.ts +48 -0
- package/dist/api-test/errors.d.ts.map +1 -0
- package/dist/api-test/errors.js +76 -0
- package/dist/api-test/errors.js.map +1 -0
- package/dist/api-test/field-extractor.d.ts +98 -0
- package/dist/api-test/field-extractor.d.ts.map +1 -0
- package/dist/api-test/field-extractor.js +327 -0
- package/dist/api-test/field-extractor.js.map +1 -0
- package/dist/api-test/impl-finder.d.ts +37 -0
- package/dist/api-test/impl-finder.d.ts.map +1 -0
- package/dist/api-test/impl-finder.js +54 -0
- package/dist/api-test/impl-finder.js.map +1 -0
- package/dist/api-test/index.d.ts +41 -0
- package/dist/api-test/index.d.ts.map +1 -0
- package/dist/api-test/index.js +124 -0
- package/dist/api-test/index.js.map +1 -0
- package/dist/api-test/java-parser.d.ts +89 -0
- package/dist/api-test/java-parser.d.ts.map +1 -0
- package/dist/api-test/java-parser.js +508 -0
- package/dist/api-test/java-parser.js.map +1 -0
- package/dist/api-test/md-writer.d.ts +49 -0
- package/dist/api-test/md-writer.d.ts.map +1 -0
- package/dist/api-test/md-writer.js +202 -0
- package/dist/api-test/md-writer.js.map +1 -0
- package/dist/api-test/parser-httpservice.d.ts +91 -0
- package/dist/api-test/parser-httpservice.d.ts.map +1 -0
- package/dist/api-test/parser-httpservice.js +271 -0
- package/dist/api-test/parser-httpservice.js.map +1 -0
- package/dist/api-test/report.d.ts +188 -0
- package/dist/api-test/report.d.ts.map +1 -0
- package/dist/api-test/report.js +522 -0
- package/dist/api-test/report.js.map +1 -0
- package/dist/api-test/snapshot.d.ts +26 -0
- package/dist/api-test/snapshot.d.ts.map +1 -0
- package/dist/api-test/snapshot.js +150 -0
- package/dist/api-test/snapshot.js.map +1 -0
- package/dist/api-test/test-history.d.ts +48 -0
- package/dist/api-test/test-history.d.ts.map +1 -0
- package/dist/api-test/test-history.js +122 -0
- package/dist/api-test/test-history.js.map +1 -0
- package/dist/api-test/types.d.ts +174 -0
- package/dist/api-test/types.d.ts.map +1 -0
- package/dist/api-test/types.js +13 -0
- package/dist/api-test/types.js.map +1 -0
- package/dist/api-test/verify-prepare.d.ts +30 -0
- package/dist/api-test/verify-prepare.d.ts.map +1 -0
- package/dist/api-test/verify-prepare.js +150 -0
- package/dist/api-test/verify-prepare.js.map +1 -0
- package/dist/api-test/verify-write.d.ts +31 -0
- package/dist/api-test/verify-write.d.ts.map +1 -0
- package/dist/api-test/verify-write.js +159 -0
- package/dist/api-test/verify-write.js.map +1 -0
- package/dist/dbquery/dump-schema.d.ts +46 -0
- package/dist/dbquery/dump-schema.d.ts.map +1 -0
- package/dist/dbquery/dump-schema.js +379 -0
- package/dist/dbquery/dump-schema.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +15 -0
- package/dist/installer/targets/claude.d.ts.map +1 -1
- package/dist/installer/targets/claude.js +53 -0
- package/dist/installer/targets/claude.js.map +1 -1
- package/package.json +1 -1
- package/scripts/agent-eval/block-cgraphx-and-gitnexus-cli-hook.sh +0 -43
- package/scripts/agent-eval/block-cgraphx-cli-hook.sh +0 -32
- package/scripts/agent-eval/block-cgraphx-cli-settings.json +0 -16
- package/scripts/agent-eval/cli-vs-mcp-3arm.sh +0 -121
- package/scripts/agent-eval/multi-tool-eval.sh +0 -171
- package/scripts/agent-eval/parse-cli-vs-mcp.mjs +0 -232
- package/scripts/agent-eval/parse-multi-tool.mjs +0 -242
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* L-T-50: snapshot — capture dep_tables row snapshots before `bru run`,
|
|
4
|
+
* stored as `.cgraphx/api-test/runs/<run-id>-before.json`.
|
|
5
|
+
*
|
|
6
|
+
* Part of the single-endpoint closed loop (enhance → snapshot → bru run → verify).
|
|
7
|
+
* Mechanical subcommand — no AI logic.
|
|
8
|
+
*
|
|
9
|
+
* Spec: docs/features/2026-07-07-api-test-skill-bruno自动化接口测试/api-test-layer2-spec.md §7.1 (snapshot is the
|
|
10
|
+
* realization of decision #2 option (d): skill calls snapshot before bru run, verify-prepare reads it)
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.__INTERNAL_SNAPSHOT = void 0;
|
|
47
|
+
exports.snapshot = snapshot;
|
|
48
|
+
const fs = __importStar(require("node:fs"));
|
|
49
|
+
const path = __importStar(require("node:path"));
|
|
50
|
+
const report_1 = require("./report");
|
|
51
|
+
const db_query_cli_1 = require("./db-query-cli");
|
|
52
|
+
const DEFAULT_DOCS_DIR = 'docs';
|
|
53
|
+
const DEFAULT_API_TEST_DIR = 'api-test';
|
|
54
|
+
const DEFAULT_SERVICE = 'inst-service';
|
|
55
|
+
const RUNS_SUBDIR = 'runs';
|
|
56
|
+
const SNAPSHOT_LIMIT = 5;
|
|
57
|
+
async function snapshot(projectRoot, endpoint, runId, service = DEFAULT_SERVICE) {
|
|
58
|
+
const resolvedRoot = path.resolve(projectRoot);
|
|
59
|
+
// 1. Read .md frontmatter for dep_tables
|
|
60
|
+
const mdPath = path.join(resolvedRoot, DEFAULT_DOCS_DIR, DEFAULT_API_TEST_DIR, service, `${endpoint}.md`);
|
|
61
|
+
if (!fs.existsSync(mdPath)) {
|
|
62
|
+
throw new Error(`[snapshot] .md not found: ${mdPath}`);
|
|
63
|
+
}
|
|
64
|
+
const mdContent = fs.readFileSync(mdPath, 'utf8');
|
|
65
|
+
const fm = (0, report_1.parseFrontmatter)(mdContent);
|
|
66
|
+
const depTablesRaw = fm.dep_tables ?? '';
|
|
67
|
+
const depTables = parseDepTables(depTablesRaw, mdContent);
|
|
68
|
+
// 2. Snapshot each dep_table
|
|
69
|
+
const snapshots = {};
|
|
70
|
+
const errors = [];
|
|
71
|
+
for (const table of depTables) {
|
|
72
|
+
if (!table)
|
|
73
|
+
continue;
|
|
74
|
+
const sql = `SELECT * FROM ${table} LIMIT ${SNAPSHOT_LIMIT}`;
|
|
75
|
+
const result = await (0, db_query_cli_1.runDbQueryCli)(sql, resolvedRoot);
|
|
76
|
+
if (result.ok) {
|
|
77
|
+
snapshots[table] = result.rows;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
snapshots[table] = [];
|
|
81
|
+
errors.push(`db query failed for ${table}: ${result.reason}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// 3. Write before.json
|
|
85
|
+
const snapshotAt = new Date().toISOString();
|
|
86
|
+
const runsDir = path.join(resolvedRoot, '.cgraphx', DEFAULT_API_TEST_DIR, RUNS_SUBDIR);
|
|
87
|
+
fs.mkdirSync(runsDir, { recursive: true });
|
|
88
|
+
const beforeJsonPath = path.join(runsDir, `${runId}-before.json`);
|
|
89
|
+
const payload = {
|
|
90
|
+
endpoint,
|
|
91
|
+
runId,
|
|
92
|
+
depTables,
|
|
93
|
+
snapshots,
|
|
94
|
+
snapshotAt,
|
|
95
|
+
};
|
|
96
|
+
fs.writeFileSync(beforeJsonPath, JSON.stringify(payload, null, 2) + '\n', 'utf8');
|
|
97
|
+
return {
|
|
98
|
+
endpoint,
|
|
99
|
+
runId,
|
|
100
|
+
depTables,
|
|
101
|
+
snapshots,
|
|
102
|
+
snapshotAt,
|
|
103
|
+
beforeJsonPath,
|
|
104
|
+
errors,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parse dep_tables from frontmatter. parseFrontmatter returns a flat string map,
|
|
109
|
+
* so arrays like `dep_tables: [cust, order]` or multi-line YAML lists need special handling.
|
|
110
|
+
* Fall back to scanning the raw .md content for `- <table>` lines under `dep_tables:`.
|
|
111
|
+
*/
|
|
112
|
+
function parseDepTables(rawValue, fullMdContent) {
|
|
113
|
+
// Try the flat value first (single-table case: `dep_tables: cust`)
|
|
114
|
+
if (rawValue && rawValue.trim() && !rawValue.includes('[')) {
|
|
115
|
+
return [rawValue.trim()];
|
|
116
|
+
}
|
|
117
|
+
// Try inline array: `dep_tables: [cust, order]`
|
|
118
|
+
if (rawValue && rawValue.includes('[')) {
|
|
119
|
+
const inner = rawValue.replace(/^\[/, '').replace(/\]$/, '');
|
|
120
|
+
return inner.split(',').map((s) => s.trim()).filter(Boolean);
|
|
121
|
+
}
|
|
122
|
+
// Fall back to scanning multi-line YAML list in full content
|
|
123
|
+
const tables = [];
|
|
124
|
+
const lines = fullMdContent.split('\n');
|
|
125
|
+
let inDepTables = false;
|
|
126
|
+
for (const line of lines) {
|
|
127
|
+
if (/^dep_tables:/.test(line)) {
|
|
128
|
+
inDepTables = true;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (inDepTables) {
|
|
132
|
+
if (/^\s+-\s+/.test(line)) {
|
|
133
|
+
const t = line.replace(/^\s+-\s+/, '').trim().replace(/['"]/g, '');
|
|
134
|
+
if (t)
|
|
135
|
+
tables.push(t);
|
|
136
|
+
}
|
|
137
|
+
else if (/^\S/.test(line)) {
|
|
138
|
+
// Next field starts — stop
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return tables;
|
|
144
|
+
}
|
|
145
|
+
exports.__INTERNAL_SNAPSHOT = {
|
|
146
|
+
DEFAULT_SERVICE,
|
|
147
|
+
RUNS_SUBDIR,
|
|
148
|
+
SNAPSHOT_LIMIT,
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/api-test/snapshot.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBH,4BAyDC;AA/ED,4CAA8B;AAC9B,gDAAkC;AAElC,qCAA4C;AAC5C,iDAA+C;AAE/C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,oBAAoB,GAAG,UAAU,CAAC;AACxC,MAAM,eAAe,GAAG,cAAc,CAAC;AACvC,MAAM,WAAW,GAAG,MAAM,CAAC;AAC3B,MAAM,cAAc,GAAG,CAAC,CAAC;AAYlB,KAAK,UAAU,QAAQ,CAC5B,WAAmB,EACnB,QAAgB,EAChB,KAAa,EACb,UAAkB,eAAe;IAEjC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAE/C,yCAAyC;IACzC,MAAM,MAAM,GAAG,IAAI,CA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6D;IAC7D,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxC,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,WAAW,GAAG,IAAI,CAAC;YACnB,SAAS;QACX,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBACnE,IAAI,CAAC;oBAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;iBAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,2BAA2B;gBAC3B,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAEY,QAAA,mBAAmB,GAAG;IACjC,eAAe;IACf,WAAW;IACX,cAAc;CACf,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test history — JSONL append for every test run (spec §5.5).
|
|
3
|
+
*
|
|
4
|
+
* One file per day: `.cgraphx/api-test/runs/YYYY-MM-DD.jsonl`. Each line is a
|
|
5
|
+
* single `TestRun` record. Append-only — never rewrites history.
|
|
6
|
+
*
|
|
7
|
+
* Independent subsystem — only depends on `node:fs` / `node:path` and the
|
|
8
|
+
* subsystem's own `types.ts`. No imports from `src/extraction/` /
|
|
9
|
+
* `src/resolution/` / `src/db/`.
|
|
10
|
+
*/
|
|
11
|
+
import type { TestRun } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Append a single `TestRun` record to the day's JSONL file.
|
|
14
|
+
*
|
|
15
|
+
* File path: `<projectRoot>/.cgraphx/api-test/runs/YYYY-MM-DD.jsonl` where
|
|
16
|
+
* the date is taken from `run.ranAt` (ISO-8601). The directory tree is
|
|
17
|
+
* created on demand. Existing files are appended to (never truncated).
|
|
18
|
+
*
|
|
19
|
+
* Each line is a compact JSON object with stable key order matching spec §5.5:
|
|
20
|
+
* {"endpoint":"...","service":"...","ran_at":"...","http_status":200,
|
|
21
|
+
* "biz_code":"0","duration_ms":234,"passed":true,"error":null}
|
|
22
|
+
*/
|
|
23
|
+
export declare function appendTestRun(run: TestRun, projectRoot: string): Promise<void>;
|
|
24
|
+
/** Synchronous variant — used by the CLI layer to avoid an unawaited write. */
|
|
25
|
+
export declare function appendTestRunSync(run: TestRun, projectRoot: string): void;
|
|
26
|
+
/** Resolve the runs directory path for a project root. */
|
|
27
|
+
export declare function runsDirPath(projectRoot: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Extract the `YYYY-MM-DD` date segment from an ISO-8601 timestamp.
|
|
30
|
+
* Falls back to `1970-01-01` when the input is malformed.
|
|
31
|
+
*/
|
|
32
|
+
declare function dateFromIso(iso: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Serialize a `TestRun` into the spec §5.5 JSONL line format.
|
|
35
|
+
* Key order is fixed to match the spec example.
|
|
36
|
+
*/
|
|
37
|
+
declare function serializeRun(run: TestRun): string;
|
|
38
|
+
/** Internal helpers re-exported for tests. */
|
|
39
|
+
export declare const __INTERNAL_TEST_HISTORY: {
|
|
40
|
+
runsDirPath: typeof runsDirPath;
|
|
41
|
+
dateFromIso: typeof dateFromIso;
|
|
42
|
+
serializeRun: typeof serializeRun;
|
|
43
|
+
RUNS_DIRNAME: string;
|
|
44
|
+
DATA_DIR: string;
|
|
45
|
+
API_TEST_DIR: string;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=test-history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-history.d.ts","sourceRoot":"","sources":["../../src/api-test/test-history.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AASvC;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAMzE;AAED,0DAA0D;AAC1D,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,iBAAS,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAGxC;AAED;;;GAGG;AACH,iBAAS,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAY1C;AAED,8CAA8C;AAC9C,eAAO,MAAM,uBAAuB;;;;;;;CAOnC,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Test history — JSONL append for every test run (spec §5.5).
|
|
4
|
+
*
|
|
5
|
+
* One file per day: `.cgraphx/api-test/runs/YYYY-MM-DD.jsonl`. Each line is a
|
|
6
|
+
* single `TestRun` record. Append-only — never rewrites history.
|
|
7
|
+
*
|
|
8
|
+
* Independent subsystem — only depends on `node:fs` / `node:path` and the
|
|
9
|
+
* subsystem's own `types.ts`. No imports from `src/extraction/` /
|
|
10
|
+
* `src/resolution/` / `src/db/`.
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.__INTERNAL_TEST_HISTORY = void 0;
|
|
47
|
+
exports.appendTestRun = appendTestRun;
|
|
48
|
+
exports.appendTestRunSync = appendTestRunSync;
|
|
49
|
+
exports.runsDirPath = runsDirPath;
|
|
50
|
+
const fs = __importStar(require("node:fs"));
|
|
51
|
+
const path = __importStar(require("node:path"));
|
|
52
|
+
/** Directory under the project root where run history lives. */
|
|
53
|
+
const RUNS_DIRNAME = 'runs';
|
|
54
|
+
/** Project data root directory (fork renamed `.codegraph` → `.cgraphx`). */
|
|
55
|
+
const DATA_DIR = '.cgraphx';
|
|
56
|
+
/** api-test subsystem directory under the data root. */
|
|
57
|
+
const API_TEST_DIR = 'api-test';
|
|
58
|
+
/**
|
|
59
|
+
* Append a single `TestRun` record to the day's JSONL file.
|
|
60
|
+
*
|
|
61
|
+
* File path: `<projectRoot>/.cgraphx/api-test/runs/YYYY-MM-DD.jsonl` where
|
|
62
|
+
* the date is taken from `run.ranAt` (ISO-8601). The directory tree is
|
|
63
|
+
* created on demand. Existing files are appended to (never truncated).
|
|
64
|
+
*
|
|
65
|
+
* Each line is a compact JSON object with stable key order matching spec §5.5:
|
|
66
|
+
* {"endpoint":"...","service":"...","ran_at":"...","http_status":200,
|
|
67
|
+
* "biz_code":"0","duration_ms":234,"passed":true,"error":null}
|
|
68
|
+
*/
|
|
69
|
+
async function appendTestRun(run, projectRoot) {
|
|
70
|
+
const dir = runsDirPath(projectRoot);
|
|
71
|
+
await fs.promises.mkdir(dir, { recursive: true });
|
|
72
|
+
const filePath = path.join(dir, `${dateFromIso(run.ranAt)}.jsonl`);
|
|
73
|
+
const line = serializeRun(run) + '\n';
|
|
74
|
+
await fs.promises.appendFile(filePath, line, 'utf8');
|
|
75
|
+
}
|
|
76
|
+
/** Synchronous variant — used by the CLI layer to avoid an unawaited write. */
|
|
77
|
+
function appendTestRunSync(run, projectRoot) {
|
|
78
|
+
const dir = runsDirPath(projectRoot);
|
|
79
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
80
|
+
const filePath = path.join(dir, `${dateFromIso(run.ranAt)}.jsonl`);
|
|
81
|
+
const line = serializeRun(run) + '\n';
|
|
82
|
+
fs.appendFileSync(filePath, line, 'utf8');
|
|
83
|
+
}
|
|
84
|
+
/** Resolve the runs directory path for a project root. */
|
|
85
|
+
function runsDirPath(projectRoot) {
|
|
86
|
+
return path.join(projectRoot, DATA_DIR, API_TEST_DIR, RUNS_DIRNAME);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extract the `YYYY-MM-DD` date segment from an ISO-8601 timestamp.
|
|
90
|
+
* Falls back to `1970-01-01` when the input is malformed.
|
|
91
|
+
*/
|
|
92
|
+
function dateFromIso(iso) {
|
|
93
|
+
const m = /^(\d{4}-\d{2}-\d{2})/.exec(iso);
|
|
94
|
+
return m && m[1] ? m[1] : '1970-01-01';
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Serialize a `TestRun` into the spec §5.5 JSONL line format.
|
|
98
|
+
* Key order is fixed to match the spec example.
|
|
99
|
+
*/
|
|
100
|
+
function serializeRun(run) {
|
|
101
|
+
const obj = {
|
|
102
|
+
endpoint: run.endpoint,
|
|
103
|
+
service: run.service,
|
|
104
|
+
ran_at: run.ranAt,
|
|
105
|
+
http_status: run.httpStatus,
|
|
106
|
+
biz_code: run.bizCode,
|
|
107
|
+
duration_ms: run.durationMs,
|
|
108
|
+
passed: run.passed,
|
|
109
|
+
error: run.error,
|
|
110
|
+
};
|
|
111
|
+
return JSON.stringify(obj);
|
|
112
|
+
}
|
|
113
|
+
/** Internal helpers re-exported for tests. */
|
|
114
|
+
exports.__INTERNAL_TEST_HISTORY = {
|
|
115
|
+
runsDirPath,
|
|
116
|
+
dateFromIso,
|
|
117
|
+
serializeRun,
|
|
118
|
+
RUNS_DIRNAME,
|
|
119
|
+
DATA_DIR,
|
|
120
|
+
API_TEST_DIR,
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=test-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-history.js","sourceRoot":"","sources":["../../src/api-test/test-history.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBH,sCASC;AAGD,8CAMC;AAGD,kCAEC;AA9CD,4CAA8B;AAC9B,gDAAkC;AAIlC,gEAAgE;AAChE,MAAM,YA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AAE,YAAY,EAAE,YAAY,CAAC,CAAC;AACtE,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAY;IAChC,MAAM,GAAG,GAA4B;QACnC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,MAAM,EAAE,GAAG,CAAC,KAAK;QACjB,WAAW,EAAE,GAAG,CAAC,UAAU;QAC3B,QAAQ,EAAE,GAAG,CAAC,OAAO;QACrB,WAAW,EAAE,GAAG,CAAC,UAAU;QAC3B,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,KAAK,EAAE,GAAG,CAAC,KAAK;KACjB,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,8CAA8C;AACjC,QAAA,uBAAuB,GAAG;IACrC,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,QAAQ;IACR,YAAY;CACb,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the api-test subsystem.
|
|
3
|
+
*
|
|
4
|
+
* Independent subsystem — does NOT import from `src/extraction/`,
|
|
5
|
+
* `src/resolution/`, or `src/db/`. The Java parser (T-11) will live in
|
|
6
|
+
* `src/api-test/` and reuse only the `tree-sitter-java.wasm` grammar, never
|
|
7
|
+
* the main code-graph extractor.
|
|
8
|
+
*
|
|
9
|
+
* Spec: docs/features/2026-07-07-api-test-skill-bruno自动化接口测试/
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* A discovered HTTP endpoint (one row in the eventual `.bru`/`.md` pair).
|
|
13
|
+
*
|
|
14
|
+
* `svcId` is the short numeric id encoded into the URL template's `{svc_id}`
|
|
15
|
+
* placeholder (hx convention — derived from the `@Center` annotation's `id`
|
|
16
|
+
* attribute). `service` is the resolved service-group name (e.g.
|
|
17
|
+
* `order-service`) computed by applying `serviceGroupingRegex` +
|
|
18
|
+
* `serviceNameMap` to the interface's package.
|
|
19
|
+
*/
|
|
20
|
+
export interface Endpoint {
|
|
21
|
+
svcId: string;
|
|
22
|
+
service: string;
|
|
23
|
+
interfaceFqn: string;
|
|
24
|
+
method: string;
|
|
25
|
+
signature: string;
|
|
26
|
+
urlPattern: string;
|
|
27
|
+
httpMethod: string;
|
|
28
|
+
status: 'active' | 'skip';
|
|
29
|
+
skipReason: string | null;
|
|
30
|
+
authRequired: boolean;
|
|
31
|
+
/** Tables referenced (directly or transitively) by the method body. */
|
|
32
|
+
depTables: string[];
|
|
33
|
+
fields: Field[];
|
|
34
|
+
/** Qualified call chain leading from the controller method to DB access. */
|
|
35
|
+
callChain: string[];
|
|
36
|
+
javadoc: string | null;
|
|
37
|
+
notes: string | null;
|
|
38
|
+
/**
|
|
39
|
+
* `@MethodAttr` annotation attributes on the interface method (hx convention).
|
|
40
|
+
* Controls request construction in the assemble phase. Defaults reflect a
|
|
41
|
+
* missing annotation or unset attributes.
|
|
42
|
+
*/
|
|
43
|
+
methodAttr: {
|
|
44
|
+
resolveParam: boolean;
|
|
45
|
+
handleReturn: boolean;
|
|
46
|
+
open: boolean;
|
|
47
|
+
};
|
|
48
|
+
bruPath: string;
|
|
49
|
+
mdPath: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* A single method parameter and how its value is sourced at test time.
|
|
53
|
+
*
|
|
54
|
+
* Exactly one of `literal` / `sourceTable`+`sourceColumn` / `sourceFilter`
|
|
55
|
+
* is expected to be set; `fixtureOnly` marks params that must come from a
|
|
56
|
+
* manual fixture entry (no automatic source).
|
|
57
|
+
*/
|
|
58
|
+
export interface Field {
|
|
59
|
+
paramIndex: number;
|
|
60
|
+
name: string;
|
|
61
|
+
javaType: string;
|
|
62
|
+
sourceTable: string | null;
|
|
63
|
+
sourceColumn: string | null;
|
|
64
|
+
/** A filter expression used to select the source row, e.g. `status=1 LIMIT 1`. */
|
|
65
|
+
sourceFilter: string | null;
|
|
66
|
+
/** Inline literal value (used by `bodyTemplate` or fixed-value params). */
|
|
67
|
+
literal: string | null;
|
|
68
|
+
/** True when no automatic source was discoverable — fixture must supply it. */
|
|
69
|
+
fixtureOnly: boolean;
|
|
70
|
+
required: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** Result of running one endpoint against the live target. */
|
|
73
|
+
export interface TestRun {
|
|
74
|
+
endpoint: string;
|
|
75
|
+
service: string;
|
|
76
|
+
/** ISO-8601 timestamp of when the request was fired. */
|
|
77
|
+
ranAt: string;
|
|
78
|
+
httpStatus: number;
|
|
79
|
+
/** Business code extracted from the response body via `bizCodeField`. */
|
|
80
|
+
bizCode: string | null;
|
|
81
|
+
durationMs: number;
|
|
82
|
+
passed: boolean;
|
|
83
|
+
error: string | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Static, project-wide config — controls scan + assemble behavior.
|
|
87
|
+
* Lives in `.cgraphx/api-test/config.json`. Missing file falls back to
|
|
88
|
+
* `DEFAULT_CONFIG`. Existing file with a missing/typo'd required field is a
|
|
89
|
+
* hard `ConfigError` (spec §5.6).
|
|
90
|
+
*/
|
|
91
|
+
export interface ApiTestConfig {
|
|
92
|
+
/** Fully-qualified Java annotation that marks a service interface. */
|
|
93
|
+
providerAnnotationFqn: string;
|
|
94
|
+
/** Regex with one capture group — extracts the service-group key from the
|
|
95
|
+
* interface's package name. */
|
|
96
|
+
serviceGroupingRegex: string;
|
|
97
|
+
/** Maps the captured group → concrete service hostname (e.g. `order` → `order-service`). */
|
|
98
|
+
serviceNameMap: Record<string, string>;
|
|
99
|
+
/** URL template. `{{baseUrl}}`, `{service}`, `{pathSegment}`, `{svc_id}`, `{methodName}` are substituted. */
|
|
100
|
+
urlTemplate: string;
|
|
101
|
+
/** Per-service URL path segment (e.g. `inst-service` → `service`, `so-pub-service` → `openapi`).
|
|
102
|
+
* Falls back to `service` when service not listed. hx: east-west (inst) uses `service`,
|
|
103
|
+
* north-south (so-pub, external web) uses `openapi`. */
|
|
104
|
+
serviceUrlPaths?: Record<string, string>;
|
|
105
|
+
defaultHttpMethod: string;
|
|
106
|
+
defaultHeaders: Record<string, string>;
|
|
107
|
+
/** Body template — a JSON string, usually `"[{}]"` for hx's array-wrapped convention. */
|
|
108
|
+
bodyTemplate: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Per-environment runtime profile — base URL, auth variables, biz-code rule.
|
|
112
|
+
* Lives in `.cgraphx/api-test/profile.json`. REQUIRED — missing file (in both
|
|
113
|
+
* project and user tier) is a `ConfigError`, no silent default.
|
|
114
|
+
*/
|
|
115
|
+
export interface ApiTestProfile {
|
|
116
|
+
env: string;
|
|
117
|
+
baseUrl: string;
|
|
118
|
+
/** Variables substituted into `defaultHeaders` / `urlTemplate` via `{{var}}`. */
|
|
119
|
+
variables: Record<string, string>;
|
|
120
|
+
/** JSON key in the response body that carries the business status code.
|
|
121
|
+
* `null` means "don't check biz code, rely on HTTP status only". */
|
|
122
|
+
bizCodeField: string | null;
|
|
123
|
+
/** Values of `bizCodeField` considered a success. */
|
|
124
|
+
bizCodeSuccessValues: string[];
|
|
125
|
+
}
|
|
126
|
+
/** One fixture entry — overrides / supplies values for a specific endpoint. */
|
|
127
|
+
export interface FixtureEntry {
|
|
128
|
+
/** Positional parameter values, in method-declaration order. */
|
|
129
|
+
params: unknown[];
|
|
130
|
+
headers?: Record<string, string>;
|
|
131
|
+
notes?: string;
|
|
132
|
+
}
|
|
133
|
+
/** Fixtures map keyed by endpoint identifier (`<service>.<method>`). */
|
|
134
|
+
export type Fixtures = Record<string, FixtureEntry>;
|
|
135
|
+
/**
|
|
136
|
+
* Result of the `enhance-prepare` phase (L-T-10). Aggregates everything an
|
|
137
|
+
* AI needs to infer `fields` for one endpoint: the catalog metadata from the
|
|
138
|
+
* Layer 1 scan `.md` file, the impl class file path (located via
|
|
139
|
+
* `findImplFor`), sample rows from each dependent table, and any previously
|
|
140
|
+
* AI-inferred fields persisted in `.cgraphx/api-test/ai-fields/`.
|
|
141
|
+
*/
|
|
142
|
+
export interface EnhancePrepareResult {
|
|
143
|
+
/** Endpoint identifier: `<svc_id>_<method>` (the .md filename stem). */
|
|
144
|
+
endpoint: string;
|
|
145
|
+
service: string;
|
|
146
|
+
interfaceFqn: string;
|
|
147
|
+
method: string;
|
|
148
|
+
signature: string;
|
|
149
|
+
urlPattern: string;
|
|
150
|
+
/** `@MethodAttr` attributes parsed from the frontmatter `method_attr` block. */
|
|
151
|
+
methodAttr: {
|
|
152
|
+
resolveParam: boolean;
|
|
153
|
+
handleReturn: boolean;
|
|
154
|
+
open: boolean;
|
|
155
|
+
};
|
|
156
|
+
/** Fields from the .md `fields:` block (empty when scan left them `[]`). */
|
|
157
|
+
fields: Field[];
|
|
158
|
+
/** Qualified call chain strings. */
|
|
159
|
+
callChain: string[];
|
|
160
|
+
/** Tables referenced by the impl method (from the .md `dep_tables:`). */
|
|
161
|
+
depTables: string[];
|
|
162
|
+
javadoc: string | null;
|
|
163
|
+
/** Absolute path to the impl `.java` file, or null when no impl found. */
|
|
164
|
+
implPath: string | null;
|
|
165
|
+
/** Sample rows per dep table (up to 5). Empty array on query failure. */
|
|
166
|
+
dbSamples: Record<string, unknown[]>;
|
|
167
|
+
}
|
|
168
|
+
/** Persisted AI-inferred fields for one endpoint, written by the enhance phase. */
|
|
169
|
+
export interface AiFields {
|
|
170
|
+
endpoint: string;
|
|
171
|
+
fields: Field[];
|
|
172
|
+
updatedAt: string;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,OAAO,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,UAAU,EAAE;QAAE,YAAY,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5E,4EAA4E;IAC5E,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,oCAAoC;IACpC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yEAAyE;IACzE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,yEAAyE;IACzE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;CACtC;AAED,mFAAmF;AACnF,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for the api-test subsystem.
|
|
4
|
+
*
|
|
5
|
+
* Independent subsystem — does NOT import from `src/extraction/`,
|
|
6
|
+
* `src/resolution/`, or `src/db/`. The Java parser (T-11) will live in
|
|
7
|
+
* `src/api-test/` and reuse only the `tree-sitter-java.wasm` grammar, never
|
|
8
|
+
* the main code-graph extractor.
|
|
9
|
+
*
|
|
10
|
+
* Spec: docs/features/2026-07-07-api-test-skill-bruno自动化接口测试/
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api-test/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L-T-30: verify-prepare — read bru run report + before.json + post-run db snapshot,
|
|
3
|
+
* output structured JSON for AI to infer db_verify expectations.
|
|
4
|
+
*
|
|
5
|
+
* Mechanical subcommand — no AI logic.
|
|
6
|
+
*
|
|
7
|
+
* Spec: docs/features/2026-07-07-api-test-skill-bruno自动化接口测试/api-test-layer2-spec.md §7.1.3
|
|
8
|
+
*/
|
|
9
|
+
export interface VerifyPrepareResult {
|
|
10
|
+
endpoint: string;
|
|
11
|
+
service: string;
|
|
12
|
+
implPath: string | null;
|
|
13
|
+
response: {
|
|
14
|
+
httpStatus: number;
|
|
15
|
+
body: string;
|
|
16
|
+
tests: unknown[];
|
|
17
|
+
durationMs: number;
|
|
18
|
+
error: string | null;
|
|
19
|
+
};
|
|
20
|
+
dbBefore: Record<string, unknown[]> | null;
|
|
21
|
+
dbAfter: Record<string, unknown[]>;
|
|
22
|
+
depTables: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare function verifyPrepare(projectRoot: string, endpoint: string, resultsFile: string, runId: string, service?: string): Promise<VerifyPrepareResult>;
|
|
25
|
+
export declare const __INTERNAL_VERIFY_PREPARE: {
|
|
26
|
+
DEFAULT_SERVICE: string;
|
|
27
|
+
RUNS_SUBDIR: string;
|
|
28
|
+
SNAPSHOT_LIMIT: number;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=verify-prepare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-prepare.d.ts","sourceRoot":"","sources":["../../src/api-test/verify-prepare.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAeH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,OAAO,EAAE,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,MAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC,CA6D9B;AA8BD,eAAO,MAAM,yBAAyB;;;;CAIrC,CAAC"}
|