cgraphx 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/.claude-template/hooks/precommit-check/precommit-check.cjs +90 -0
  2. package/dist/.claude-template/skills/cgraphx-guide/how-to-use.html +100 -78
  3. package/dist/.claude-template/skills/precommit-review/SKILL.md +50 -0
  4. package/dist/.claude-template/skills/run-api-test/SKILL.md +187 -0
  5. package/dist/.claude-template/skills/run-api-test/assets/template-test-report.md +103 -0
  6. package/dist/.claude-template/skills/run-api-test/assets/template-test-verify.jsonl +5 -0
  7. package/dist/.claude-template/skills/run-api-test/references/bru-run.md +60 -0
  8. package/dist/.claude-template/skills/run-api-test/references/db-verification.md +81 -0
  9. package/dist/.claude-template/skills/run-api-test/references/report-format.md +104 -0
  10. package/dist/.claude-template/skills/run-api-test/references/service-readiness.md +61 -0
  11. package/dist/.claude-template/skills/run-api-test/references/test-scope.md +64 -0
  12. package/dist/.claude-template/skills/write-api/SKILL.md +150 -0
  13. package/dist/.claude-template/skills/write-api/assets/template-api-spec.md +112 -0
  14. package/dist/.claude-template/skills/write-api/assets/template-request.bru +72 -0
  15. package/dist/.claude-template/skills/write-api/references/ai-prompts.md +133 -0
  16. package/dist/.claude-template/skills/write-api/references/api-spec-format.md +108 -0
  17. package/dist/.claude-template/skills/write-api/references/bru-format.md +139 -0
  18. package/dist/.claude-template/skills/write-api/references/collection-layout.md +90 -0
  19. package/dist/.claude-template/skills/write-api/references/environment-setup.md +105 -0
  20. package/dist/.claude-template/skills/write-api/references/interface-scope.md +74 -0
  21. package/dist/api-test/ai-fields.d.ts +37 -0
  22. package/dist/api-test/ai-fields.d.ts.map +1 -0
  23. package/dist/api-test/ai-fields.js +114 -0
  24. package/dist/api-test/ai-fields.js.map +1 -0
  25. package/dist/api-test/assemble.d.ts +76 -0
  26. package/dist/api-test/assemble.d.ts.map +1 -0
  27. package/dist/api-test/assemble.js +185 -0
  28. package/dist/api-test/assemble.js.map +1 -0
  29. package/dist/api-test/bru-cli-invoker.d.ts +72 -0
  30. package/dist/api-test/bru-cli-invoker.d.ts.map +1 -0
  31. package/dist/api-test/bru-cli-invoker.js +169 -0
  32. package/dist/api-test/bru-cli-invoker.js.map +1 -0
  33. package/dist/api-test/bru-report-parser.d.ts +24 -0
  34. package/dist/api-test/bru-report-parser.d.ts.map +1 -0
  35. package/dist/api-test/bru-report-parser.js +110 -0
  36. package/dist/api-test/bru-report-parser.js.map +1 -0
  37. package/dist/api-test/bru-runner.d.ts +101 -0
  38. package/dist/api-test/bru-runner.d.ts.map +1 -0
  39. package/dist/api-test/bru-runner.js +316 -0
  40. package/dist/api-test/bru-runner.js.map +1 -0
  41. package/dist/api-test/bru-writer.d.ts +52 -0
  42. package/dist/api-test/bru-writer.d.ts.map +1 -0
  43. package/dist/api-test/bru-writer.js +159 -0
  44. package/dist/api-test/bru-writer.js.map +1 -0
  45. package/dist/api-test/call-chain-extractor.d.ts +80 -0
  46. package/dist/api-test/call-chain-extractor.d.ts.map +1 -0
  47. package/dist/api-test/call-chain-extractor.js +179 -0
  48. package/dist/api-test/call-chain-extractor.js.map +1 -0
  49. package/dist/api-test/cli.d.ts +133 -0
  50. package/dist/api-test/cli.d.ts.map +1 -0
  51. package/dist/api-test/cli.js +1009 -0
  52. package/dist/api-test/cli.js.map +1 -0
  53. package/dist/api-test/config.d.ts +75 -0
  54. package/dist/api-test/config.d.ts.map +1 -0
  55. package/dist/api-test/config.js +406 -0
  56. package/dist/api-test/config.js.map +1 -0
  57. package/dist/api-test/db-query-cli.d.ts +51 -0
  58. package/dist/api-test/db-query-cli.d.ts.map +1 -0
  59. package/dist/api-test/db-query-cli.js +119 -0
  60. package/dist/api-test/db-query-cli.js.map +1 -0
  61. package/dist/api-test/enhance-prepare.d.ts +111 -0
  62. package/dist/api-test/enhance-prepare.d.ts.map +1 -0
  63. package/dist/api-test/enhance-prepare.js +425 -0
  64. package/dist/api-test/enhance-prepare.js.map +1 -0
  65. package/dist/api-test/enhance-write.d.ts +28 -0
  66. package/dist/api-test/enhance-write.d.ts.map +1 -0
  67. package/dist/api-test/enhance-write.js +145 -0
  68. package/dist/api-test/enhance-write.js.map +1 -0
  69. package/dist/api-test/errors.d.ts +48 -0
  70. package/dist/api-test/errors.d.ts.map +1 -0
  71. package/dist/api-test/errors.js +76 -0
  72. package/dist/api-test/errors.js.map +1 -0
  73. package/dist/api-test/field-extractor.d.ts +98 -0
  74. package/dist/api-test/field-extractor.d.ts.map +1 -0
  75. package/dist/api-test/field-extractor.js +327 -0
  76. package/dist/api-test/field-extractor.js.map +1 -0
  77. package/dist/api-test/impl-finder.d.ts +37 -0
  78. package/dist/api-test/impl-finder.d.ts.map +1 -0
  79. package/dist/api-test/impl-finder.js +54 -0
  80. package/dist/api-test/impl-finder.js.map +1 -0
  81. package/dist/api-test/index.d.ts +41 -0
  82. package/dist/api-test/index.d.ts.map +1 -0
  83. package/dist/api-test/index.js +124 -0
  84. package/dist/api-test/index.js.map +1 -0
  85. package/dist/api-test/java-parser.d.ts +89 -0
  86. package/dist/api-test/java-parser.d.ts.map +1 -0
  87. package/dist/api-test/java-parser.js +508 -0
  88. package/dist/api-test/java-parser.js.map +1 -0
  89. package/dist/api-test/md-writer.d.ts +49 -0
  90. package/dist/api-test/md-writer.d.ts.map +1 -0
  91. package/dist/api-test/md-writer.js +202 -0
  92. package/dist/api-test/md-writer.js.map +1 -0
  93. package/dist/api-test/parser-httpservice.d.ts +91 -0
  94. package/dist/api-test/parser-httpservice.d.ts.map +1 -0
  95. package/dist/api-test/parser-httpservice.js +271 -0
  96. package/dist/api-test/parser-httpservice.js.map +1 -0
  97. package/dist/api-test/report.d.ts +188 -0
  98. package/dist/api-test/report.d.ts.map +1 -0
  99. package/dist/api-test/report.js +522 -0
  100. package/dist/api-test/report.js.map +1 -0
  101. package/dist/api-test/snapshot.d.ts +26 -0
  102. package/dist/api-test/snapshot.d.ts.map +1 -0
  103. package/dist/api-test/snapshot.js +150 -0
  104. package/dist/api-test/snapshot.js.map +1 -0
  105. package/dist/api-test/test-history.d.ts +48 -0
  106. package/dist/api-test/test-history.d.ts.map +1 -0
  107. package/dist/api-test/test-history.js +122 -0
  108. package/dist/api-test/test-history.js.map +1 -0
  109. package/dist/api-test/types.d.ts +174 -0
  110. package/dist/api-test/types.d.ts.map +1 -0
  111. package/dist/api-test/types.js +13 -0
  112. package/dist/api-test/types.js.map +1 -0
  113. package/dist/api-test/verify-prepare.d.ts +30 -0
  114. package/dist/api-test/verify-prepare.d.ts.map +1 -0
  115. package/dist/api-test/verify-prepare.js +150 -0
  116. package/dist/api-test/verify-prepare.js.map +1 -0
  117. package/dist/api-test/verify-write.d.ts +31 -0
  118. package/dist/api-test/verify-write.d.ts.map +1 -0
  119. package/dist/api-test/verify-write.js +159 -0
  120. package/dist/api-test/verify-write.js.map +1 -0
  121. package/dist/dbquery/dump-schema.d.ts +46 -0
  122. package/dist/dbquery/dump-schema.d.ts.map +1 -0
  123. package/dist/dbquery/dump-schema.js +379 -0
  124. package/dist/dbquery/dump-schema.js.map +1 -0
  125. package/dist/installer/targets/claude.d.ts +15 -0
  126. package/dist/installer/targets/claude.d.ts.map +1 -1
  127. package/dist/installer/targets/claude.js +53 -0
  128. package/dist/installer/targets/claude.js.map +1 -1
  129. package/package.json +1 -1
  130. package/scripts/agent-eval/block-cgraphx-and-gitnexus-cli-hook.sh +0 -43
  131. package/scripts/agent-eval/block-cgraphx-cli-hook.sh +0 -32
  132. package/scripts/agent-eval/block-cgraphx-cli-settings.json +0 -16
  133. package/scripts/agent-eval/cli-vs-mcp-3arm.sh +0 -121
  134. package/scripts/agent-eval/multi-tool-eval.sh +0 -171
  135. package/scripts/agent-eval/parse-cli-vs-mcp.mjs +0 -232
  136. package/scripts/agent-eval/parse-multi-tool.mjs +0 -242
@@ -1,242 +0,0 @@
1
- #!/usr/bin/env node
2
- // Parse multi-tool-eval transcripts (3 arms × 3 tasks × n reps).
3
- //
4
- // File-name contract: <repo>-<task>-<arm>-<rep>.jsonl
5
- // task ∈ {flow, onboarding, impact}
6
- // arm ∈ {cgraphx-cli, cgraphx-mcp, gitnexus-mcp}
7
- //
8
- // Output:
9
- // 1. <out-dir>/results.jsonl — one JSON line per transcript
10
- // 2. stdout:
11
- // - PER TASK × ARM × REP (detail)
12
- // - AGGREGATE PER TASK × ARM (mean across reps)
13
- // - AGGREGATE PER ARM (mean across task × reps — overall tool ranking)
14
- import { readFileSync, readdirSync, existsSync, writeFileSync } from 'fs';
15
- import { join } from 'path';
16
-
17
- const OUT = process.argv[2] || '/tmp/cg-multi-tool';
18
- const RUNS_DIR = join(OUT, 'runs');
19
- const RESULTS = join(OUT, 'results.jsonl');
20
-
21
- if (!existsSync(RUNS_DIR)) {
22
- console.error(`no runs dir at ${RUNS_DIR}`);
23
- process.exit(1);
24
- }
25
-
26
- function parse(file) {
27
- const lines = readFileSync(file, 'utf8').split('\n').filter(Boolean);
28
- const toolCounts = {};
29
- const cliCommands = { cgraphx: [], gitnexus: [] };
30
- const hookDenies = { cgraphx: 0, gitnexus: 0 };
31
- let result = null;
32
-
33
- for (const line of lines) {
34
- let ev;
35
- try { ev = JSON.parse(line); } catch { continue; }
36
-
37
- if (ev.type === 'assistant' && Array.isArray(ev.message?.content)) {
38
- for (const b of ev.message.content) {
39
- if (b.type !== 'tool_use') continue;
40
- toolCounts[b.name] = (toolCounts[b.name] || 0) + 1;
41
- if (b.name === 'Bash' && typeof b.input?.command === 'string') {
42
- const cmd = b.input.command;
43
- if (/^cgraphx /.test(cmd) || / cgraphx /.test(cmd) || /codegraph\.js/.test(cmd)) {
44
- cliCommands.cgraphx.push(cmd.slice(0, 80));
45
- }
46
- if (/gitnexus\/dist\/cli\/index\.js/.test(cmd) || /gitnexus\/run\.cjs/.test(cmd) || /^gitnexus /.test(cmd) || / gitnexus /.test(cmd)) {
47
- cliCommands.gitnexus.push(cmd.slice(0, 80));
48
- }
49
- }
50
- }
51
- }
52
-
53
- if (ev.type === 'user' && Array.isArray(ev.message?.content)) {
54
- for (const b of ev.message.content) {
55
- if (b.type !== 'tool_result') continue;
56
- const text = typeof b.content === 'string'
57
- ? b.content
58
- : Array.isArray(b.content)
59
- ? b.content.map(c => (typeof c === 'string' ? c : c?.text || '')).join('')
60
- : '';
61
- if (/禁用 cgraphx CLI/.test(text)) hookDenies.cgraphx++;
62
- if (/禁用 gitnexus CLI/.test(text)) hookDenies.gitnexus++;
63
- }
64
- }
65
-
66
- if (ev.type === 'result') result = ev;
67
- }
68
-
69
- let skillCgraphx = 0, skillGitnexus = 0;
70
- for (const line of lines) {
71
- let ev;
72
- try { ev = JSON.parse(line); } catch { continue; }
73
- if (ev.type === 'assistant' && Array.isArray(ev.message?.content)) {
74
- for (const b of ev.message.content) {
75
- if (b.type !== 'tool_use' || b.name !== 'Skill') continue;
76
- const s = b.input?.skill || '';
77
- if (s === 'cgraphx-search' || s === 'cgraphx') skillCgraphx++;
78
- if (s.startsWith('gitnexus')) skillGitnexus++;
79
- }
80
- }
81
- }
82
-
83
- const u = result?.usage || {};
84
- const tokGen = u.output_tokens || 0;
85
- const tokFresh = (u.input_tokens || 0) + (u.cache_creation_input_tokens || 0);
86
- const tokCached = u.cache_read_input_tokens || 0;
87
-
88
- const get = (n) => toolCounts[n] || 0;
89
- const mcpCalls = Object.keys(toolCounts)
90
- .filter(k => /^mcp__(cgraphx|gitnexus)__/.test(k))
91
- .reduce((s, k) => s + toolCounts[k], 0);
92
- // Per-tool MCP breakdown
93
- const mcpByServer = {};
94
- for (const k of Object.keys(toolCounts)) {
95
- const m = k.match(/^mcp__(cgraphx|gitnexus)__/);
96
- if (m) mcpByServer[m[1]] = (mcpByServer[m[1]] || 0) + toolCounts[k];
97
- }
98
-
99
- return {
100
- read: get('Read'),
101
- grep: get('Grep') + get('Glob'),
102
- bash: get('Bash'),
103
- cliCallsCgraphx: cliCommands.cgraphx.length,
104
- cliCallsGitnexus: cliCommands.gitnexus.length,
105
- mcpCalls,
106
- mcpCgraphx: mcpByServer.cgraphx || 0,
107
- mcpGitnexus: mcpByServer.gitnexus || 0,
108
- skillCgraphx,
109
- skillGitnexus,
110
- hookDeniesCgraphx: hookDenies.cgraphx,
111
- hookDeniesGitnexus: hookDenies.gitnexus,
112
- durationSec: result ? Math.floor(result.duration_ms / 1000) : null,
113
- numTurns: result?.num_turns ?? null,
114
- costUsdMain: result ? +(result.total_cost_usd || 0).toFixed(4) : null,
115
- tokGen,
116
- tokFresh,
117
- tokCached,
118
- tokBillable: tokGen + tokFresh,
119
- ok: result?.subtype === 'success',
120
- };
121
- }
122
-
123
- // task -> arm -> [runs]
124
- const data = {};
125
- const allMetrics = [];
126
- for (const f of readdirSync(RUNS_DIR)) {
127
- const m = f.match(/^(.+)-(\w+)-(\w+-\w+)-(\d+)\.jsonl$/);
128
- if (!m) continue;
129
- const [, repo, task, arm, repStr] = m;
130
- const parsed = parse(join(RUNS_DIR, f));
131
- const rep = Number(repStr);
132
- const record = { repo, task, arm, rep, file: f, ...parsed };
133
- allMetrics.push(record);
134
- (((data[task] ??= {})[arm]) ??= []).push(record);
135
- }
136
-
137
- writeFileSync(RESULTS, allMetrics
138
- .sort((a, b) => a.task.localeCompare(b.task) || a.arm.localeCompare(b.arm) || a.rep - b.rep)
139
- .map(r => JSON.stringify(r))
140
- .join('\n') + '\n'
141
- );
142
-
143
- const pad = (s, n) => String(s).padEnd(n);
144
- const TASKS = ['flow', 'onboarding', 'impact'];
145
- const ARMS = ['cgraphx-cli', 'cgraphx-mcp', 'gitnexus-mcp'];
146
- const LABEL = {
147
- 'cgraphx-cli': 'A1 cgraphx-cli',
148
- 'cgraphx-mcp': 'A2 cgraphx-mcp',
149
- 'gitnexus-mcp': 'A3 gitnexus-mcp',
150
- };
151
-
152
- // ---- PER TASK × ARM × REP ----
153
- console.log('\n=== PER TASK × ARM × REP (detail) ===');
154
- console.log(
155
- pad('task', 11), pad('arm', 18), pad('rep', 4),
156
- pad('dur', 5), pad('read', 5), pad('grep', 5), pad('bash', 5),
157
- pad('cgCli', 5), pad('gnCli', 5),
158
- pad('cgMcp', 5), pad('gnMcp', 5),
159
- pad('deny', 5),
160
- pad('tokBill', 8), pad('cost', 8), 'ok'
161
- );
162
- for (const task of TASKS) {
163
- for (const arm of ARMS) {
164
- const runs = data[task]?.[arm] || [];
165
- for (const r of runs) {
166
- console.log(
167
- pad(task, 11), pad(LABEL[arm], 18), pad(r.rep, 4),
168
- pad(r.durationSec ?? '?', 5),
169
- pad(r.read, 5), pad(r.grep, 5), pad(r.bash, 5),
170
- pad(r.cliCallsCgraphx, 5), pad(r.cliCallsGitnexus, 5),
171
- pad(r.mcpCgraphx, 5), pad(r.mcpGitnexus, 5),
172
- pad(r.hookDeniesCgraphx + r.hookDeniesGitnexus, 5),
173
- pad(r.tokBillable, 8),
174
- pad('$' + (r.costUsdMain ?? 0).toFixed(4), 8),
175
- r.ok ? '✓' : '✗'
176
- );
177
- }
178
- }
179
- }
180
-
181
- const avg = (a, f) => a.length ? a.reduce((s, x) => s + (f(x) || 0), 0) / a.length : 0;
182
-
183
- // ---- AGGREGATE PER TASK × ARM ----
184
- console.log('\n=== AGGREGATE PER TASK × ARM (mean across reps) ===');
185
- console.log(
186
- pad('task', 11), pad('arm', 18),
187
- pad('read', 6), pad('grep', 6), pad('bash', 6),
188
- pad('cgCli', 5), pad('gnCli', 5),
189
- pad('cgMcp', 5), pad('gnMcp', 5),
190
- pad('dur', 6), pad('tokBill', 8), pad('cost', 8), 'n'
191
- );
192
- for (const task of TASKS) {
193
- for (const arm of ARMS) {
194
- const runs = data[task]?.[arm] || [];
195
- if (!runs.length) continue;
196
- console.log(
197
- pad(task, 11), pad(LABEL[arm], 18),
198
- pad(avg(runs, r => r.read).toFixed(1), 6),
199
- pad(avg(runs, r => r.grep).toFixed(1), 6),
200
- pad(avg(runs, r => r.bash).toFixed(1), 6),
201
- pad(avg(runs, r => r.cliCallsCgraphx).toFixed(1), 5),
202
- pad(avg(runs, r => r.cliCallsGitnexus).toFixed(1), 5),
203
- pad(avg(runs, r => r.mcpCgraphx).toFixed(1), 5),
204
- pad(avg(runs, r => r.mcpGitnexus).toFixed(1), 5),
205
- pad(avg(runs, r => r.durationSec).toFixed(0) + 's', 6),
206
- pad(avg(runs, r => r.tokBillable).toFixed(0), 8),
207
- pad('$' + avg(runs, r => r.costUsdMain).toFixed(4), 8),
208
- runs.length
209
- );
210
- }
211
- }
212
-
213
- // ---- AGGREGATE PER ARM (across all tasks × reps) ----
214
- console.log('\n=== AGGREGATE PER ARM (mean across all tasks × reps) ===');
215
- console.log(
216
- pad('arm', 18),
217
- pad('read', 6), pad('grep', 6), pad('bash', 6),
218
- pad('cgCli', 5), pad('gnCli', 5),
219
- pad('cgMcp', 5), pad('gnMcp', 5),
220
- pad('dur', 6), pad('tokBill', 8), pad('cost', 8), 'n'
221
- );
222
- for (const arm of ARMS) {
223
- const all = [];
224
- for (const task of TASKS) for (const r of (data[task]?.[arm] || [])) all.push(r);
225
- if (!all.length) continue;
226
- console.log(
227
- pad(LABEL[arm], 18),
228
- pad(avg(all, r => r.read).toFixed(1), 6),
229
- pad(avg(all, r => r.grep).toFixed(1), 6),
230
- pad(avg(all, r => r.bash).toFixed(1), 6),
231
- pad(avg(all, r => r.cliCallsCgraphx).toFixed(1), 5),
232
- pad(avg(all, r => r.cliCallsGitnexus).toFixed(1), 5),
233
- pad(avg(all, r => r.mcpCgraphx).toFixed(1), 5),
234
- pad(avg(all, r => r.mcpGitnexus).toFixed(1), 5),
235
- pad(avg(all, r => r.durationSec).toFixed(0) + 's', 6),
236
- pad(avg(all, r => r.tokBillable).toFixed(0), 8),
237
- pad('$' + avg(all, r => r.costUsdMain).toFixed(4), 8),
238
- all.length
239
- );
240
- }
241
-
242
- console.log(`\nresults.jsonl: ${RESULTS}`);