@peakinfer/cli 1.0.133

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 (367) hide show
  1. package/.claude/settings.local.json +8 -0
  2. package/.env.example +6 -0
  3. package/.github/workflows/peakinfer.yml +64 -0
  4. package/CHANGELOG.md +31 -0
  5. package/LICENSE +190 -0
  6. package/README.md +335 -0
  7. package/data/inferencemax.json +274 -0
  8. package/dist/agent-analyzer.d.ts +45 -0
  9. package/dist/agent-analyzer.d.ts.map +1 -0
  10. package/dist/agent-analyzer.js +374 -0
  11. package/dist/agent-analyzer.js.map +1 -0
  12. package/dist/agent.d.ts +76 -0
  13. package/dist/agent.d.ts.map +1 -0
  14. package/dist/agent.js +965 -0
  15. package/dist/agent.js.map +1 -0
  16. package/dist/agents/correlation-analyzer.d.ts +34 -0
  17. package/dist/agents/correlation-analyzer.d.ts.map +1 -0
  18. package/dist/agents/correlation-analyzer.js +261 -0
  19. package/dist/agents/correlation-analyzer.js.map +1 -0
  20. package/dist/agents/index.d.ts +91 -0
  21. package/dist/agents/index.d.ts.map +1 -0
  22. package/dist/agents/index.js +111 -0
  23. package/dist/agents/index.js.map +1 -0
  24. package/dist/agents/runtime-analyzer.d.ts +38 -0
  25. package/dist/agents/runtime-analyzer.d.ts.map +1 -0
  26. package/dist/agents/runtime-analyzer.js +244 -0
  27. package/dist/agents/runtime-analyzer.js.map +1 -0
  28. package/dist/analysis-types.d.ts +500 -0
  29. package/dist/analysis-types.d.ts.map +1 -0
  30. package/dist/analysis-types.js +11 -0
  31. package/dist/analysis-types.js.map +1 -0
  32. package/dist/analytics.d.ts +25 -0
  33. package/dist/analytics.d.ts.map +1 -0
  34. package/dist/analytics.js +94 -0
  35. package/dist/analytics.js.map +1 -0
  36. package/dist/analyzer.d.ts +48 -0
  37. package/dist/analyzer.d.ts.map +1 -0
  38. package/dist/analyzer.js +547 -0
  39. package/dist/analyzer.js.map +1 -0
  40. package/dist/artifacts.d.ts +44 -0
  41. package/dist/artifacts.d.ts.map +1 -0
  42. package/dist/artifacts.js +165 -0
  43. package/dist/artifacts.js.map +1 -0
  44. package/dist/benchmarks/index.d.ts +88 -0
  45. package/dist/benchmarks/index.d.ts.map +1 -0
  46. package/dist/benchmarks/index.js +205 -0
  47. package/dist/benchmarks/index.js.map +1 -0
  48. package/dist/cli.d.ts +3 -0
  49. package/dist/cli.d.ts.map +1 -0
  50. package/dist/cli.js +427 -0
  51. package/dist/cli.js.map +1 -0
  52. package/dist/commands/ci.d.ts +19 -0
  53. package/dist/commands/ci.d.ts.map +1 -0
  54. package/dist/commands/ci.js +253 -0
  55. package/dist/commands/ci.js.map +1 -0
  56. package/dist/commands/config.d.ts +16 -0
  57. package/dist/commands/config.d.ts.map +1 -0
  58. package/dist/commands/config.js +249 -0
  59. package/dist/commands/config.js.map +1 -0
  60. package/dist/commands/demo.d.ts +15 -0
  61. package/dist/commands/demo.d.ts.map +1 -0
  62. package/dist/commands/demo.js +106 -0
  63. package/dist/commands/demo.js.map +1 -0
  64. package/dist/commands/export.d.ts +14 -0
  65. package/dist/commands/export.d.ts.map +1 -0
  66. package/dist/commands/export.js +209 -0
  67. package/dist/commands/export.js.map +1 -0
  68. package/dist/commands/history.d.ts +15 -0
  69. package/dist/commands/history.d.ts.map +1 -0
  70. package/dist/commands/history.js +389 -0
  71. package/dist/commands/history.js.map +1 -0
  72. package/dist/commands/template.d.ts +14 -0
  73. package/dist/commands/template.d.ts.map +1 -0
  74. package/dist/commands/template.js +341 -0
  75. package/dist/commands/template.js.map +1 -0
  76. package/dist/commands/validate-map.d.ts +12 -0
  77. package/dist/commands/validate-map.d.ts.map +1 -0
  78. package/dist/commands/validate-map.js +274 -0
  79. package/dist/commands/validate-map.js.map +1 -0
  80. package/dist/commands/whatif.d.ts +17 -0
  81. package/dist/commands/whatif.d.ts.map +1 -0
  82. package/dist/commands/whatif.js +206 -0
  83. package/dist/commands/whatif.js.map +1 -0
  84. package/dist/comparison.d.ts +38 -0
  85. package/dist/comparison.d.ts.map +1 -0
  86. package/dist/comparison.js +223 -0
  87. package/dist/comparison.js.map +1 -0
  88. package/dist/config.d.ts +42 -0
  89. package/dist/config.d.ts.map +1 -0
  90. package/dist/config.js +158 -0
  91. package/dist/config.js.map +1 -0
  92. package/dist/connectors/helicone.d.ts +9 -0
  93. package/dist/connectors/helicone.d.ts.map +1 -0
  94. package/dist/connectors/helicone.js +106 -0
  95. package/dist/connectors/helicone.js.map +1 -0
  96. package/dist/connectors/index.d.ts +37 -0
  97. package/dist/connectors/index.d.ts.map +1 -0
  98. package/dist/connectors/index.js +65 -0
  99. package/dist/connectors/index.js.map +1 -0
  100. package/dist/connectors/langsmith.d.ts +9 -0
  101. package/dist/connectors/langsmith.d.ts.map +1 -0
  102. package/dist/connectors/langsmith.js +122 -0
  103. package/dist/connectors/langsmith.js.map +1 -0
  104. package/dist/connectors/types.d.ts +83 -0
  105. package/dist/connectors/types.d.ts.map +1 -0
  106. package/dist/connectors/types.js +98 -0
  107. package/dist/connectors/types.js.map +1 -0
  108. package/dist/cost-estimator.d.ts +46 -0
  109. package/dist/cost-estimator.d.ts.map +1 -0
  110. package/dist/cost-estimator.js +104 -0
  111. package/dist/cost-estimator.js.map +1 -0
  112. package/dist/costs.d.ts +57 -0
  113. package/dist/costs.d.ts.map +1 -0
  114. package/dist/costs.js +251 -0
  115. package/dist/costs.js.map +1 -0
  116. package/dist/counterfactuals.d.ts +29 -0
  117. package/dist/counterfactuals.d.ts.map +1 -0
  118. package/dist/counterfactuals.js +448 -0
  119. package/dist/counterfactuals.js.map +1 -0
  120. package/dist/enhancement-prompts.d.ts +41 -0
  121. package/dist/enhancement-prompts.d.ts.map +1 -0
  122. package/dist/enhancement-prompts.js +88 -0
  123. package/dist/enhancement-prompts.js.map +1 -0
  124. package/dist/envelopes.d.ts +20 -0
  125. package/dist/envelopes.d.ts.map +1 -0
  126. package/dist/envelopes.js +790 -0
  127. package/dist/envelopes.js.map +1 -0
  128. package/dist/format-normalizer.d.ts +71 -0
  129. package/dist/format-normalizer.d.ts.map +1 -0
  130. package/dist/format-normalizer.js +1331 -0
  131. package/dist/format-normalizer.js.map +1 -0
  132. package/dist/history.d.ts +79 -0
  133. package/dist/history.d.ts.map +1 -0
  134. package/dist/history.js +313 -0
  135. package/dist/history.js.map +1 -0
  136. package/dist/html.d.ts +11 -0
  137. package/dist/html.d.ts.map +1 -0
  138. package/dist/html.js +463 -0
  139. package/dist/html.js.map +1 -0
  140. package/dist/impact.d.ts +42 -0
  141. package/dist/impact.d.ts.map +1 -0
  142. package/dist/impact.js +443 -0
  143. package/dist/impact.js.map +1 -0
  144. package/dist/index.d.ts +26 -0
  145. package/dist/index.d.ts.map +1 -0
  146. package/dist/index.js +34 -0
  147. package/dist/index.js.map +1 -0
  148. package/dist/insights.d.ts +5 -0
  149. package/dist/insights.d.ts.map +1 -0
  150. package/dist/insights.js +271 -0
  151. package/dist/insights.js.map +1 -0
  152. package/dist/joiner.d.ts +9 -0
  153. package/dist/joiner.d.ts.map +1 -0
  154. package/dist/joiner.js +247 -0
  155. package/dist/joiner.js.map +1 -0
  156. package/dist/orchestrator.d.ts +34 -0
  157. package/dist/orchestrator.d.ts.map +1 -0
  158. package/dist/orchestrator.js +827 -0
  159. package/dist/orchestrator.js.map +1 -0
  160. package/dist/pdf.d.ts +26 -0
  161. package/dist/pdf.d.ts.map +1 -0
  162. package/dist/pdf.js +84 -0
  163. package/dist/pdf.js.map +1 -0
  164. package/dist/prediction.d.ts +33 -0
  165. package/dist/prediction.d.ts.map +1 -0
  166. package/dist/prediction.js +316 -0
  167. package/dist/prediction.js.map +1 -0
  168. package/dist/prompts/loader.d.ts +38 -0
  169. package/dist/prompts/loader.d.ts.map +1 -0
  170. package/dist/prompts/loader.js +60 -0
  171. package/dist/prompts/loader.js.map +1 -0
  172. package/dist/renderer.d.ts +64 -0
  173. package/dist/renderer.d.ts.map +1 -0
  174. package/dist/renderer.js +923 -0
  175. package/dist/renderer.js.map +1 -0
  176. package/dist/runid.d.ts +57 -0
  177. package/dist/runid.d.ts.map +1 -0
  178. package/dist/runid.js +199 -0
  179. package/dist/runid.js.map +1 -0
  180. package/dist/runtime.d.ts +29 -0
  181. package/dist/runtime.d.ts.map +1 -0
  182. package/dist/runtime.js +366 -0
  183. package/dist/runtime.js.map +1 -0
  184. package/dist/scanner.d.ts +11 -0
  185. package/dist/scanner.d.ts.map +1 -0
  186. package/dist/scanner.js +426 -0
  187. package/dist/scanner.js.map +1 -0
  188. package/dist/templates.d.ts +120 -0
  189. package/dist/templates.d.ts.map +1 -0
  190. package/dist/templates.js +429 -0
  191. package/dist/templates.js.map +1 -0
  192. package/dist/tools/index.d.ts +153 -0
  193. package/dist/tools/index.d.ts.map +1 -0
  194. package/dist/tools/index.js +177 -0
  195. package/dist/tools/index.js.map +1 -0
  196. package/dist/types.d.ts +3647 -0
  197. package/dist/types.d.ts.map +1 -0
  198. package/dist/types.js +703 -0
  199. package/dist/types.js.map +1 -0
  200. package/dist/version.d.ts +7 -0
  201. package/dist/version.d.ts.map +1 -0
  202. package/dist/version.js +23 -0
  203. package/dist/version.js.map +1 -0
  204. package/docs/demo-guide.md +423 -0
  205. package/docs/events-format.md +295 -0
  206. package/docs/inferencemap-spec.md +344 -0
  207. package/docs/migration-v2.md +293 -0
  208. package/fixtures/demo/precomputed.json +142 -0
  209. package/fixtures/demo-project/README.md +52 -0
  210. package/fixtures/demo-project/ai-service.ts +65 -0
  211. package/fixtures/demo-project/sample-events.jsonl +15 -0
  212. package/fixtures/demo-project/src/ai-service.ts +128 -0
  213. package/fixtures/demo-project/src/llm-client.ts +155 -0
  214. package/package.json +65 -0
  215. package/prompts/agent-analyzer.yaml +47 -0
  216. package/prompts/ci-gate.yaml +98 -0
  217. package/prompts/correlation-analyzer.yaml +178 -0
  218. package/prompts/format-normalizer.yaml +46 -0
  219. package/prompts/peak-performance.yaml +180 -0
  220. package/prompts/pr-comment.yaml +111 -0
  221. package/prompts/runtime-analyzer.yaml +189 -0
  222. package/prompts/unified-analyzer.yaml +241 -0
  223. package/schemas/inference-map.v0.1.json +215 -0
  224. package/scripts/benchmark.ts +394 -0
  225. package/scripts/demo-v1.5.sh +158 -0
  226. package/scripts/sync-from-site.sh +197 -0
  227. package/scripts/validate-sync.sh +178 -0
  228. package/src/agent-analyzer.ts +481 -0
  229. package/src/agent.ts +1232 -0
  230. package/src/agents/correlation-analyzer.ts +353 -0
  231. package/src/agents/index.ts +235 -0
  232. package/src/agents/runtime-analyzer.ts +343 -0
  233. package/src/analysis-types.ts +558 -0
  234. package/src/analytics.ts +100 -0
  235. package/src/analyzer.ts +692 -0
  236. package/src/artifacts.ts +218 -0
  237. package/src/benchmarks/index.ts +309 -0
  238. package/src/cli.ts +503 -0
  239. package/src/commands/ci.ts +336 -0
  240. package/src/commands/config.ts +288 -0
  241. package/src/commands/demo.ts +175 -0
  242. package/src/commands/export.ts +297 -0
  243. package/src/commands/history.ts +425 -0
  244. package/src/commands/template.ts +385 -0
  245. package/src/commands/validate-map.ts +324 -0
  246. package/src/commands/whatif.ts +272 -0
  247. package/src/comparison.ts +283 -0
  248. package/src/config.ts +188 -0
  249. package/src/connectors/helicone.ts +164 -0
  250. package/src/connectors/index.ts +93 -0
  251. package/src/connectors/langsmith.ts +179 -0
  252. package/src/connectors/types.ts +180 -0
  253. package/src/cost-estimator.ts +146 -0
  254. package/src/costs.ts +347 -0
  255. package/src/counterfactuals.ts +516 -0
  256. package/src/enhancement-prompts.ts +118 -0
  257. package/src/envelopes.ts +814 -0
  258. package/src/format-normalizer.ts +1486 -0
  259. package/src/history.ts +400 -0
  260. package/src/html.ts +512 -0
  261. package/src/impact.ts +522 -0
  262. package/src/index.ts +83 -0
  263. package/src/insights.ts +341 -0
  264. package/src/joiner.ts +289 -0
  265. package/src/orchestrator.ts +1015 -0
  266. package/src/pdf.ts +110 -0
  267. package/src/prediction.ts +392 -0
  268. package/src/prompts/loader.ts +88 -0
  269. package/src/renderer.ts +1045 -0
  270. package/src/runid.ts +261 -0
  271. package/src/runtime.ts +450 -0
  272. package/src/scanner.ts +508 -0
  273. package/src/templates.ts +561 -0
  274. package/src/tools/index.ts +214 -0
  275. package/src/types.ts +873 -0
  276. package/src/version.ts +24 -0
  277. package/templates/context-accumulation.yaml +23 -0
  278. package/templates/cost-concentration.yaml +20 -0
  279. package/templates/dead-code.yaml +20 -0
  280. package/templates/latency-explainer.yaml +23 -0
  281. package/templates/optimizations/ab-testing-framework.yaml +74 -0
  282. package/templates/optimizations/api-gateway-optimization.yaml +81 -0
  283. package/templates/optimizations/api-model-routing-strategy.yaml +126 -0
  284. package/templates/optimizations/auto-scaling-optimization.yaml +85 -0
  285. package/templates/optimizations/batch-utilization-diagnostic.yaml +142 -0
  286. package/templates/optimizations/comprehensive-apm.yaml +76 -0
  287. package/templates/optimizations/context-window-optimization.yaml +91 -0
  288. package/templates/optimizations/cost-sensitive-batch-processing.yaml +77 -0
  289. package/templates/optimizations/distributed-training-optimization.yaml +77 -0
  290. package/templates/optimizations/document-analysis-edge.yaml +77 -0
  291. package/templates/optimizations/document-pipeline-optimization.yaml +78 -0
  292. package/templates/optimizations/domain-specific-distillation.yaml +78 -0
  293. package/templates/optimizations/error-handling-optimization.yaml +76 -0
  294. package/templates/optimizations/gptq-4bit-quantization.yaml +96 -0
  295. package/templates/optimizations/long-context-memory-management.yaml +78 -0
  296. package/templates/optimizations/max-tokens-optimization.yaml +76 -0
  297. package/templates/optimizations/memory-bandwidth-optimization.yaml +73 -0
  298. package/templates/optimizations/multi-framework-resilience.yaml +75 -0
  299. package/templates/optimizations/multi-tenant-optimization.yaml +75 -0
  300. package/templates/optimizations/prompt-caching-optimization.yaml +143 -0
  301. package/templates/optimizations/pytorch-to-onnx-migration.yaml +109 -0
  302. package/templates/optimizations/quality-monitoring.yaml +74 -0
  303. package/templates/optimizations/realtime-budget-controls.yaml +74 -0
  304. package/templates/optimizations/realtime-latency-optimization.yaml +74 -0
  305. package/templates/optimizations/sglang-concurrency-optimization.yaml +78 -0
  306. package/templates/optimizations/smart-model-routing.yaml +96 -0
  307. package/templates/optimizations/streaming-batch-selection.yaml +167 -0
  308. package/templates/optimizations/system-prompt-optimization.yaml +75 -0
  309. package/templates/optimizations/tensorrt-llm-performance.yaml +77 -0
  310. package/templates/optimizations/vllm-high-throughput-optimization.yaml +93 -0
  311. package/templates/optimizations/vllm-migration-memory-bound.yaml +78 -0
  312. package/templates/overpowered-extraction.yaml +32 -0
  313. package/templates/overpowered-model.yaml +31 -0
  314. package/templates/prompt-bloat.yaml +24 -0
  315. package/templates/retry-explosion.yaml +28 -0
  316. package/templates/schema/insight.schema.json +113 -0
  317. package/templates/schema/optimization.schema.json +180 -0
  318. package/templates/streaming-drift.yaml +30 -0
  319. package/templates/throughput-gap.yaml +21 -0
  320. package/templates/token-underutilization.yaml +28 -0
  321. package/templates/untested-fallback.yaml +21 -0
  322. package/tests/accuracy/drift-detection.test.ts +184 -0
  323. package/tests/accuracy/false-positives.test.ts +166 -0
  324. package/tests/accuracy/templates.test.ts +205 -0
  325. package/tests/action/commands.test.ts +125 -0
  326. package/tests/action/comments.test.ts +347 -0
  327. package/tests/cli.test.ts +203 -0
  328. package/tests/comparison.test.ts +309 -0
  329. package/tests/correlation-analyzer.test.ts +534 -0
  330. package/tests/counterfactuals.test.ts +347 -0
  331. package/tests/fixtures/events/missing-id.jsonl +1 -0
  332. package/tests/fixtures/events/missing-input.jsonl +1 -0
  333. package/tests/fixtures/events/missing-latency.jsonl +1 -0
  334. package/tests/fixtures/events/missing-model.jsonl +1 -0
  335. package/tests/fixtures/events/missing-output.jsonl +1 -0
  336. package/tests/fixtures/events/missing-provider.jsonl +1 -0
  337. package/tests/fixtures/events/missing-ts.jsonl +1 -0
  338. package/tests/fixtures/events/valid.csv +3 -0
  339. package/tests/fixtures/events/valid.json +1 -0
  340. package/tests/fixtures/events/valid.jsonl +2 -0
  341. package/tests/fixtures/events/with-callsite.jsonl +1 -0
  342. package/tests/fixtures/events/with-intent.jsonl +1 -0
  343. package/tests/fixtures/events/wrong-type.jsonl +1 -0
  344. package/tests/fixtures/repos/empty/.gitkeep +0 -0
  345. package/tests/fixtures/repos/hybrid-router/router.py +35 -0
  346. package/tests/fixtures/repos/saas-anthropic/agent.ts +27 -0
  347. package/tests/fixtures/repos/saas-openai/assistant.js +33 -0
  348. package/tests/fixtures/repos/saas-openai/client.py +26 -0
  349. package/tests/fixtures/repos/self-hosted-vllm/inference.py +22 -0
  350. package/tests/github-action.test.ts +292 -0
  351. package/tests/insights.test.ts +878 -0
  352. package/tests/joiner.test.ts +168 -0
  353. package/tests/performance/action-latency.test.ts +132 -0
  354. package/tests/performance/benchmark.test.ts +189 -0
  355. package/tests/performance/cli-latency.test.ts +102 -0
  356. package/tests/pr-comment.test.ts +313 -0
  357. package/tests/prediction.test.ts +296 -0
  358. package/tests/runtime-analyzer.test.ts +375 -0
  359. package/tests/runtime.test.ts +205 -0
  360. package/tests/scanner.test.ts +122 -0
  361. package/tests/template-conformance.test.ts +526 -0
  362. package/tests/unit/cost-calculator.test.ts +303 -0
  363. package/tests/unit/credits.test.ts +180 -0
  364. package/tests/unit/inference-map.test.ts +276 -0
  365. package/tests/unit/schema.test.ts +300 -0
  366. package/tsconfig.json +20 -0
  367. package/vitest.config.ts +14 -0
@@ -0,0 +1,426 @@
1
+ import { glob } from 'glob';
2
+ import ignoreDefault from 'ignore';
3
+ import { readFileSync, existsSync, statSync } from 'fs';
4
+ import { join, relative, extname } from 'path';
5
+ // Handle ESM default import with type assertion for NodeNext resolution
6
+ const ignore = ignoreDefault;
7
+ // =============================================================================
8
+ // CONSTANTS
9
+ // =============================================================================
10
+ const DEFAULT_IGNORES = [
11
+ 'node_modules/**',
12
+ 'dist/**',
13
+ '.git/**',
14
+ '__pycache__/**',
15
+ '*.pyc',
16
+ '.venv/**',
17
+ 'venv/**',
18
+ '.env/**',
19
+ 'env/**',
20
+ 'build/**',
21
+ 'target/**',
22
+ '.next/**',
23
+ '.nuxt/**',
24
+ 'coverage/**',
25
+ ];
26
+ // v1.9.5: Files to skip for cost optimization
27
+ const SKIP_PATTERNS = [
28
+ // Test files
29
+ '**/*.test.*',
30
+ '**/*.spec.*',
31
+ '**/__tests__/**',
32
+ '**/test/**',
33
+ '**/tests/**',
34
+ '**/*.test.ts',
35
+ '**/*.test.js',
36
+ '**/*.spec.ts',
37
+ '**/*.spec.js',
38
+ '**/test_*.py',
39
+ '**/*_test.py',
40
+ '**/*_test.go',
41
+ // Config files
42
+ '**/jest.config.*',
43
+ '**/vitest.config.*',
44
+ '**/webpack.config.*',
45
+ '**/rollup.config.*',
46
+ '**/vite.config.*',
47
+ '**/tsconfig.json',
48
+ '**/package.json',
49
+ '**/package-lock.json',
50
+ '**/yarn.lock',
51
+ '**/pnpm-lock.yaml',
52
+ // Documentation
53
+ '**/*.md',
54
+ '**/docs/**',
55
+ '**/documentation/**',
56
+ // Generated files
57
+ '**/generated/**',
58
+ '**/*.generated.*',
59
+ '**/*.d.ts',
60
+ // Fixtures and mocks
61
+ '**/fixtures/**',
62
+ '**/mocks/**',
63
+ '**/__mocks__/**',
64
+ '**/snapshots/**',
65
+ '**/__snapshots__/**',
66
+ ];
67
+ // v1.9.5: Maximum file size in bytes (50KB)
68
+ const MAX_FILE_SIZE = 50 * 1024;
69
+ const LANGUAGE_MAP = {
70
+ '.py': 'python',
71
+ '.ts': 'typescript',
72
+ '.tsx': 'typescript',
73
+ '.js': 'javascript',
74
+ '.jsx': 'javascript',
75
+ '.mjs': 'javascript',
76
+ '.cjs': 'javascript',
77
+ '.go': 'go',
78
+ '.java': 'java',
79
+ '.kt': 'kotlin',
80
+ '.rs': 'rust',
81
+ '.rb': 'ruby',
82
+ '.php': 'php',
83
+ '.cs': 'csharp',
84
+ '.swift': 'swift',
85
+ '.scala': 'scala',
86
+ };
87
+ const CODE_EXTENSIONS = Object.keys(LANGUAGE_MAP);
88
+ // Patterns that indicate LLM inference calls
89
+ const INFERENCE_PATTERNS = [
90
+ // ==========================================================================
91
+ // OpenAI SDK
92
+ // ==========================================================================
93
+ /\.chat\.completions\.create\(/,
94
+ /openai\.completions\.create\(/,
95
+ /\.completions\.create\(/,
96
+ // NOTE: Removed /OpenAI\(\)/ - client initialization, not an inference call
97
+ // NOTE: Removed /AsyncOpenAI\(\)/ - client initialization, not an inference call
98
+ /openai\.ChatCompletion\.create\(/,
99
+ /openai\.Completion\.create\(/,
100
+ /\.embeddings\.create\(/, // OpenAI embeddings API
101
+ // ==========================================================================
102
+ // Anthropic SDK
103
+ // ==========================================================================
104
+ /\.messages\.create\(/,
105
+ /anthropic\.messages\(/,
106
+ /\.create_message\(/,
107
+ // NOTE: Removed /Anthropic\(\)/ - client initialization, not an inference call
108
+ // NOTE: Removed /AsyncAnthropic\(\)/ - client initialization, not an inference call
109
+ /anthropic\.completions\(/,
110
+ // ==========================================================================
111
+ // Google AI / Vertex AI
112
+ // ==========================================================================
113
+ /\.generate_content\(/,
114
+ /genai\.GenerativeModel\(/,
115
+ /GenerativeModel\(/,
116
+ /vertexai\.generative_models/,
117
+ /aiplatform\.gapic/,
118
+ // ==========================================================================
119
+ // Mistral
120
+ // ==========================================================================
121
+ /MistralClient\(/,
122
+ /mistral\.chat\(/,
123
+ /mistral\.complete\(/,
124
+ // ==========================================================================
125
+ // Cohere
126
+ // ==========================================================================
127
+ /cohere\.chat\(/,
128
+ /cohere\.generate\(/,
129
+ /CohereClient\(/,
130
+ // ==========================================================================
131
+ // Together AI
132
+ // ==========================================================================
133
+ /together\.chat\./,
134
+ /Together\(\)/,
135
+ /together\.completions/,
136
+ /together_ai/,
137
+ // ==========================================================================
138
+ // Fireworks AI
139
+ // ==========================================================================
140
+ /fireworks\.chat\./,
141
+ /Fireworks\(/,
142
+ /fireworks\.completions/,
143
+ /fireworks_ai/,
144
+ // ==========================================================================
145
+ // Groq
146
+ // ==========================================================================
147
+ /groq\.chat\./,
148
+ /Groq\(\)/,
149
+ /groq\.completions/,
150
+ // ==========================================================================
151
+ // Replicate
152
+ // ==========================================================================
153
+ /replicate\.run\(/,
154
+ /replicate\.predictions\.create\(/,
155
+ /Replicate\(\)/,
156
+ // ==========================================================================
157
+ // Perplexity
158
+ // ==========================================================================
159
+ /perplexity\.chat\./,
160
+ /PerplexityClient\(/,
161
+ // ==========================================================================
162
+ // AWS Bedrock
163
+ // ==========================================================================
164
+ /bedrock-runtime/,
165
+ /invoke_model\(/,
166
+ /InvokeModel/,
167
+ /BedrockRuntime\(/,
168
+ /bedrock\.converse\(/,
169
+ // ==========================================================================
170
+ // Azure OpenAI
171
+ // ==========================================================================
172
+ /AzureOpenAI\(/,
173
+ /azure\.openai/,
174
+ /openai\.azure/,
175
+ // ==========================================================================
176
+ // LangChain
177
+ // ==========================================================================
178
+ /ChatOpenAI\(/,
179
+ /ChatAnthropic\(/,
180
+ /ChatGoogleGenerativeAI\(/,
181
+ /ChatMistralAI\(/,
182
+ /ChatCohere\(/,
183
+ /ChatGroq\(/,
184
+ /ChatFireworks\(/,
185
+ /ChatTogether\(/,
186
+ /ChatBedrock\(/,
187
+ /ChatVertexAI\(/,
188
+ /ChatOllama\(/,
189
+ /LLMChain\(/,
190
+ /ConversationChain\(/,
191
+ // ==========================================================================
192
+ // LlamaIndex
193
+ // ==========================================================================
194
+ /llama_index\.llms/,
195
+ /OpenAILike\(/,
196
+ /Ollama\(/,
197
+ /LlamaCPP\(/,
198
+ // ==========================================================================
199
+ // DSPy Framework
200
+ // ==========================================================================
201
+ /dspy\.Predict\(/,
202
+ /dspy\.ChainOfThought\(/,
203
+ /dspy\.ProgramOfThought\(/,
204
+ /dspy\.ReAct\(/,
205
+ /dspy\.Retrieve\(/,
206
+ /dspy\.generate\(/,
207
+ /dspy\.forward\(/,
208
+ /\.forward\(.*question/, // DSPy module forward calls with question param
209
+ // ==========================================================================
210
+ // vLLM (Self-hosted)
211
+ // ==========================================================================
212
+ /vllm\.generate/,
213
+ /vllm\.LLM\(/,
214
+ /from vllm import/,
215
+ /vllm\.SamplingParams/,
216
+ /vllm\.AsyncLLMEngine/,
217
+ /vllm\.entrypoints/,
218
+ /\/v1\/completions/, // OpenAI-compatible endpoint
219
+ // ==========================================================================
220
+ // SGLang (Self-hosted)
221
+ // ==========================================================================
222
+ /sglang\.generate/,
223
+ /sglang\.Engine\(/,
224
+ /from sglang import/,
225
+ /sglang\.RuntimeEndpoint/,
226
+ /sglang\.function/,
227
+ /sglang\.gen\(/,
228
+ // ==========================================================================
229
+ // TGI - Text Generation Inference (Self-hosted)
230
+ // ==========================================================================
231
+ /text-generation-inference/,
232
+ /InferenceClient\(/,
233
+ /huggingface_hub\.inference/,
234
+ /text_generation\(/,
235
+ /HuggingFaceEndpoint\(/,
236
+ /tgi\.generate/,
237
+ // ==========================================================================
238
+ // Ollama (Local inference)
239
+ // ==========================================================================
240
+ /ollama\.generate/,
241
+ /ollama\.chat/,
242
+ /ollama\.create\(/,
243
+ /ollama\.pull\(/,
244
+ /from ollama import/,
245
+ /Ollama\(\)/,
246
+ /localhost:11434/, // Default Ollama port
247
+ /127\.0\.0\.1:11434/,
248
+ // ==========================================================================
249
+ // llama.cpp / llama-cpp-python (Bare metal)
250
+ // ==========================================================================
251
+ /llama_cpp/,
252
+ /Llama\(/,
253
+ /llama\.generate/,
254
+ /llama\.create_completion/,
255
+ /llama\.create_chat_completion/,
256
+ /from llama_cpp import/,
257
+ /LlamaCpp\(/,
258
+ // ==========================================================================
259
+ // Transformers / HuggingFace (Bare metal)
260
+ // ==========================================================================
261
+ /pipeline\("text-generation"/,
262
+ /pipeline\('text-generation'/,
263
+ /AutoModelForCausalLM/,
264
+ /AutoModelForSeq2SeqLM/,
265
+ /\.generate\(input_ids/,
266
+ /transformers\.pipeline/,
267
+ /model\.generate\(/,
268
+ // ==========================================================================
269
+ // GGUF / GGML models
270
+ // ==========================================================================
271
+ /\.gguf/,
272
+ /\.ggml/,
273
+ /ctransformers/,
274
+ /CTransformers\(/,
275
+ // ==========================================================================
276
+ // ExLlama / ExLlamaV2 (Bare metal, GPU optimized)
277
+ // ==========================================================================
278
+ /exllama/,
279
+ /ExLlama/,
280
+ /exllamav2/,
281
+ /ExLlamaV2/,
282
+ // ==========================================================================
283
+ // Generic patterns (conservative - only match with LLM context)
284
+ // ==========================================================================
285
+ // NOTE: Removed overly generic patterns that cause false positives:
286
+ // - /\.invoke\(/ - too generic, matches any invoke method
287
+ // - /\.generate\(/ - too generic, matches generators, UUIDs, etc.
288
+ // - /\.chat\(/ - too generic, matches any chat method
289
+ // - /llm\./i - case-insensitive, matches "film.", variable names
290
+ // - /\.llm\(/ - too generic without context
291
+ // - /LLM\(/ - only keep if clearly a class instantiation
292
+ /\.ainvoke\(/, // LangChain async invoke - specific enough
293
+ /\.complete\(/, // Usually LLM-specific
294
+ /ChatModel\(/, // Usually LLM-specific class
295
+ /completion_tokens/, // OpenAI response field
296
+ /prompt_tokens/, // OpenAI response field
297
+ ];
298
+ // =============================================================================
299
+ // HELPERS
300
+ // =============================================================================
301
+ function detectLanguage(filePath) {
302
+ const ext = extname(filePath).toLowerCase();
303
+ return LANGUAGE_MAP[ext] || 'unknown';
304
+ }
305
+ function countLines(content) {
306
+ if (!content)
307
+ return 0;
308
+ return content.split('\n').filter(line => line.trim().length > 0).length;
309
+ }
310
+ function loadGitignore(root, skipOptimization = true) {
311
+ const ig = ignore();
312
+ // Add default ignores
313
+ ig.add(DEFAULT_IGNORES);
314
+ // v1.9.5: Add cost optimization skip patterns
315
+ if (skipOptimization) {
316
+ ig.add(SKIP_PATTERNS);
317
+ }
318
+ // Load .gitignore if exists
319
+ const gitignorePath = join(root, '.gitignore');
320
+ if (existsSync(gitignorePath)) {
321
+ try {
322
+ const content = readFileSync(gitignorePath, 'utf-8');
323
+ ig.add(content);
324
+ }
325
+ catch {
326
+ // Ignore errors reading .gitignore
327
+ }
328
+ }
329
+ return ig;
330
+ }
331
+ function findCandidatesInContent(filePath, content) {
332
+ const candidates = [];
333
+ const lines = content.split('\n');
334
+ for (let i = 0; i < lines.length; i++) {
335
+ const line = lines[i];
336
+ for (const pattern of INFERENCE_PATTERNS) {
337
+ if (pattern.test(line)) {
338
+ candidates.push({
339
+ file: filePath,
340
+ line: i + 1, // 1-indexed
341
+ snippet: line.trim().slice(0, 100), // First 100 chars
342
+ });
343
+ break; // Only one candidate per line
344
+ }
345
+ }
346
+ }
347
+ return candidates;
348
+ }
349
+ export async function scan(root, options = {}) {
350
+ const { skipOptimization = true, maxFileSize = MAX_FILE_SIZE, includeAll = false, } = options;
351
+ // Validate directory exists
352
+ if (!existsSync(root)) {
353
+ throw new Error(`Directory not found: ${root}`);
354
+ }
355
+ const stat = statSync(root);
356
+ if (!stat.isDirectory()) {
357
+ throw new Error(`Not a directory: ${root}`);
358
+ }
359
+ const ig = loadGitignore(root, skipOptimization);
360
+ // Build glob pattern for code files
361
+ const patterns = CODE_EXTENSIONS.map(ext => `**/*${ext}`);
362
+ // Find all matching files
363
+ const absolutePaths = await glob(patterns, {
364
+ cwd: root,
365
+ absolute: true,
366
+ nodir: true,
367
+ dot: false,
368
+ });
369
+ // Process files
370
+ const files = [];
371
+ const candidates = [];
372
+ const languageSet = new Set();
373
+ let skippedLargeFiles = 0;
374
+ let skippedByPattern = 0;
375
+ for (const absPath of absolutePaths) {
376
+ const relPath = relative(root, absPath);
377
+ // Check against ignore patterns
378
+ if (ig.ignores(relPath)) {
379
+ skippedByPattern++;
380
+ continue;
381
+ }
382
+ try {
383
+ // v1.9.5: Check file size before reading
384
+ const fileStat = statSync(absPath);
385
+ if (fileStat.size > maxFileSize) {
386
+ skippedLargeFiles++;
387
+ continue;
388
+ }
389
+ const content = readFileSync(absPath, 'utf-8');
390
+ const language = detectLanguage(absPath);
391
+ const loc = countLines(content);
392
+ // Find inference call candidates
393
+ const fileCandidates = findCandidatesInContent(relPath, content);
394
+ // v1.9.5: Only include files with candidates (unless includeAll)
395
+ if (includeAll || fileCandidates.length > 0) {
396
+ files.push({
397
+ path: relPath,
398
+ language,
399
+ loc,
400
+ });
401
+ languageSet.add(language);
402
+ candidates.push(...fileCandidates);
403
+ }
404
+ }
405
+ catch {
406
+ // Skip files that can't be read
407
+ }
408
+ }
409
+ // Calculate summary
410
+ const totalLoc = files.reduce((sum, f) => sum + f.loc, 0);
411
+ return {
412
+ root,
413
+ files,
414
+ candidates,
415
+ summary: {
416
+ totalFiles: files.length,
417
+ totalLoc,
418
+ languages: Array.from(languageSet).sort(),
419
+ totalCandidates: candidates.length,
420
+ // v1.9.5: Cost optimization stats
421
+ skippedLargeFiles,
422
+ skippedByPattern,
423
+ },
424
+ };
425
+ }
426
+ //# sourceMappingURL=scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,aAAa,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAG/C,wEAAwE;AACxE,MAAM,MAAM,GAAG,aAGd,CAAC;AAOF,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,eAAe,GAAG;IACtB,iBAAiB;IACjB,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,OAAO;IACP,UAAU;IACV,SAAS;IACT,SAAS;IACT,QAAQ;IACR,UAAU;IACV,WAAW;IACX,UAAU;IACV,UAAU;IACV,aAAa;CACd,CAAC;AAEF,8CAA8C;AAC9C,MAAM,aAAa,GAAG;IACpB,aAAa;IACb,aAAa;IACb,aAAa;IACb,iBAAiB;IACjB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,cAAc;IACd,eAAe;IACf,kBAAkB;IAClB,oBAAoB;IACpB,qBAAqB;IACrB,oBAAoB;IACpB,kBAAkB;IAClB,kBA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OAAO,CAAC,CAAC;YACzC,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;YAEhC,iCAAiC;YACjC,MAAM,cAAc,GAAG,uBAAuB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAEjE,iEAAiE;YACjE,IAAI,UAAU,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5C,KAAK,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,OAAO;oBACb,QAAQ;oBACR,GAAG;iBACJ,CAAC,CAAC;gBAEH,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC1B,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,gCAAgC;QAClC,CAAC;IACH,CAAC;IAED,oBAAoB;IACpB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAE1D,OAAO;QACL,IAAI;QACJ,KAAK;QACL,UAAU;QACV,OAAO,EAAE;YACP,UAAU,EAAE,KAAK,CAAC,MAAM;YACxB,QAAQ;YACR,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE;YACzC,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,kCAAkC;YAClC,iBAAiB;YACjB,gBAAgB;SACjB;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { InsightTemplate, OptimizationTemplate } from './types.js';
2
+ /**
3
+ * Analysis prompt configuration loaded from YAML
4
+ * Used for LLM-based code analysis with configurable focus areas
5
+ */
6
+ export interface AnalysisPrompt {
7
+ id: string;
8
+ name: string;
9
+ version: string;
10
+ description: string;
11
+ prompt: string;
12
+ categories: string[];
13
+ defaults?: {
14
+ expensive_models?: string[];
15
+ cheap_models?: string[];
16
+ latency_critical_threshold_ms?: number;
17
+ batch_opportunity_threshold?: number;
18
+ };
19
+ }
20
+ export interface LoadOptions {
21
+ offline?: boolean;
22
+ }
23
+ export declare function loadTemplates(opts?: LoadOptions): Promise<InsightTemplate[]>;
24
+ /**
25
+ * Get a single template by ID
26
+ */
27
+ export declare function getTemplate(id: string, opts?: LoadOptions): Promise<InsightTemplate | null>;
28
+ /**
29
+ * Clear template cache
30
+ */
31
+ export declare function clearCache(): void;
32
+ /**
33
+ * Load bundled optimization templates from templates/optimizations/
34
+ * These are community optimization runbooks with implementation steps
35
+ */
36
+ export declare function loadOptimizationTemplates(): OptimizationTemplate[];
37
+ /**
38
+ * Get a single optimization template by ID
39
+ */
40
+ export declare function getOptimizationTemplate(id: string): OptimizationTemplate | null;
41
+ /**
42
+ * Load an analysis prompt by ID from the prompts directory
43
+ * @param id - Prompt ID (e.g., 'peak-performance')
44
+ * @returns AnalysisPrompt or null if not found
45
+ */
46
+ export declare function loadPrompt(id: string): AnalysisPrompt | null;
47
+ /**
48
+ * List all available analysis prompts
49
+ * @returns Array of prompt IDs
50
+ */
51
+ export declare function listPrompts(): string[];
52
+ /**
53
+ * Get the default analysis prompt (peak-performance)
54
+ * @returns AnalysisPrompt
55
+ * @throws Error if default prompt not found
56
+ */
57
+ export declare function getDefaultPrompt(): AnalysisPrompt;
58
+ /**
59
+ * PeakInfer configuration schema
60
+ */
61
+ export interface PeakInferConfig {
62
+ id: string;
63
+ version: string;
64
+ description: string;
65
+ analysis: {
66
+ mode: 'agent' | 'llm' | 'regex';
67
+ cascade: boolean;
68
+ };
69
+ models: {
70
+ agent: {
71
+ primary: string;
72
+ fallback: string;
73
+ };
74
+ llm: {
75
+ primary: string;
76
+ fallback: string;
77
+ };
78
+ };
79
+ agent: {
80
+ max_iterations: number;
81
+ verbose: boolean;
82
+ };
83
+ scanner: {
84
+ extensions: string[];
85
+ max_file_size: number;
86
+ ignore: string[];
87
+ };
88
+ output: {
89
+ format: 'json' | 'yaml' | 'markdown';
90
+ include_confidence: boolean;
91
+ min_confidence: number;
92
+ };
93
+ }
94
+ /**
95
+ * Load PeakInfer configuration from config/peakinfer.yaml
96
+ * Environment variables override file settings:
97
+ * - PEAKINFER_MODE: analysis mode (agent, llm, regex)
98
+ * - PEAKINFER_MODEL: primary model override
99
+ * - PEAKINFER_VERBOSE: enable verbose output
100
+ * @returns PeakInferConfig
101
+ */
102
+ export declare function loadConfig(): PeakInferConfig;
103
+ /**
104
+ * Get the configured model for a given analysis type
105
+ * @param type - 'agent' or 'llm'
106
+ * @param fallback - whether to return fallback model
107
+ * @returns model name
108
+ */
109
+ export declare function getConfiguredModel(type: 'agent' | 'llm', fallback?: boolean): string;
110
+ /**
111
+ * Get the configured analysis mode
112
+ * @returns analysis mode
113
+ */
114
+ export declare function getConfiguredMode(): 'agent' | 'llm' | 'regex';
115
+ /**
116
+ * Check if cascade fallback is enabled
117
+ * @returns true if cascade is enabled
118
+ */
119
+ export declare function isCascadeEnabled(): boolean;
120
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAiCnE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,6BAA6B,CAAC,EAAE,MAAM,CAAC;QACvC,2BAA2B,CAAC,EAAE,MAAM,CAAC;KACtC,CAA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