@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,8 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(xargs ls:*)",
5
+ "Bash(head:*)"
6
+ ]
7
+ }
8
+ }
package/.env.example ADDED
@@ -0,0 +1,6 @@
1
+ # PeakInfer Environment Configuration
2
+ # Copy this file to .env and add your API key
3
+
4
+ # Anthropic API Key (required for LLM-based semantic analysis)
5
+ # Without this, PeakInfer falls back to regex-based detection only
6
+ ANTHROPIC_API_KEY=sk-ant-api03-your-key-here
@@ -0,0 +1,64 @@
1
+ # PeakInfer Analysis Workflow
2
+ # Add this to your repository to analyze LLM inference on every PR
3
+ # Supports comment commands: /peakinfer, /fix N, /fix all, /dismiss N
4
+
5
+ name: PeakInfer Analysis
6
+
7
+ on:
8
+ pull_request:
9
+ branches: [main, master]
10
+ paths:
11
+ - 'src/**'
12
+ - 'lib/**'
13
+ - 'app/**'
14
+
15
+ # Enable comment commands
16
+ issue_comment:
17
+ types: [created]
18
+
19
+ permissions:
20
+ contents: write # Needed for /fix commands to create commits
21
+ pull-requests: write
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze Inference
26
+ runs-on: ubuntu-latest
27
+
28
+ # Run on PR events, or on PR comments containing peakinfer commands
29
+ if: >
30
+ github.event_name == 'pull_request' ||
31
+ (github.event_name == 'issue_comment' &&
32
+ github.event.issue.pull_request &&
33
+ (contains(github.event.comment.body, '/peakinfer') ||
34
+ contains(github.event.comment.body, '/fix') ||
35
+ contains(github.event.comment.body, '/dismiss')))
36
+
37
+ steps:
38
+ - name: Checkout
39
+ uses: actions/checkout@v4
40
+ with:
41
+ # For issue_comment, we need to checkout the PR branch
42
+ ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || '' }}
43
+
44
+ - name: Run PeakInfer
45
+ uses: Kalmantic/peakinfer@v1
46
+ with:
47
+ path: './src'
48
+ inline-comments: 'true'
49
+ fail-on-regression: 'false'
50
+ # Pass the event type so action knows if this is a command
51
+ event-type: ${{ github.event_name }}
52
+ comment-body: ${{ github.event.comment.body || '' }}
53
+ env:
54
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
56
+
57
+ # Optional: Upload artifacts
58
+ - name: Upload Analysis
59
+ uses: actions/upload-artifact@v4
60
+ if: always()
61
+ with:
62
+ name: peakinfer-results
63
+ path: .peakinfer/
64
+ retention-days: 30
package/CHANGELOG.md ADDED
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to PeakInfer will be documented in this file.
4
+
5
+ ## [1.0.129] - 2025-12-26
6
+
7
+ ### Changed
8
+ - Moved GitHub Action to separate repository (`peakinfer-action`)
9
+ - CLI is now fully BYOK (Bring Your Own Key) focused
10
+
11
+ ## [1.0.0] - 2025-12-24
12
+
13
+ ### Added
14
+ - Initial public release
15
+ - Claude Agent SDK integration for semantic code analysis
16
+ - 4-dimension analysis: cost, latency, throughput, reliability
17
+ - Drift detection between code and runtime behavior
18
+ - 12 insight templates
19
+ - 31 optimization templates
20
+ - Runtime event correlation (JSONL, OTEL, Jaeger, Zipkin, LangSmith, LiteLLM)
21
+ - Historical comparison and baseline tracking
22
+ - HTML/PDF report generation
23
+
24
+ ### Architecture
25
+ - Unified single-call analyzer (60% faster than multi-phase)
26
+ - BYOK mode (user provides Anthropic API key)
27
+ - Fully auditable - all analysis code visible in public repo
28
+
29
+ ---
30
+
31
+ For earlier changes, see [releases](https://github.com/Kalmantic/peakinfer/releases).
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2024 Kalmantic AI Labs
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,335 @@
1
+ # PeakInfer
2
+
3
+ **Run AI inference at peak performance.**
4
+
5
+ PeakInfer scans your code. Finds every LLM call. Shows you exactly what's holding back your latency, throughput, and reliability.
6
+
7
+ 30 seconds. Zero config. Real numbers.
8
+
9
+ ```bash
10
+ npm install -g @kalmantic/peakinfer
11
+ peakinfer analyze .
12
+ ```
13
+
14
+ ---
15
+
16
+ ## The Problem
17
+
18
+ Your code says `streaming: true`. Your runtime shows 0% streams.
19
+
20
+ That's **drift**—and it's killing your latency.
21
+
22
+ | What You Think | What's Actually Happening |
23
+ |----------------|---------------------------|
24
+ | Streaming enabled | Blocking calls |
25
+ | Fast responses | p95 latency 5x slower than benchmarks |
26
+ | Retry logic works | Never triggered |
27
+ | Fallbacks ready | Never tested |
28
+
29
+ Static analysis sees code. Monitoring sees requests. **Neither sees the gap.**
30
+
31
+ PeakInfer sees both.
32
+
33
+ ---
34
+
35
+ ## What Is Peak Inference Performance?
36
+
37
+ **Peak Inference Performance means:** Improving latency, throughput, reliability, and cost *without changing evaluated behavior*.
38
+
39
+ No one else correlates what PeakInfer sees together:
40
+
41
+ ```
42
+ CODE RUNTIME BENCHMARKS EVALS
43
+ ──── ─────── ────────── ─────
44
+
45
+ What you What actually The upper bound Your quality
46
+ declared happened of possible gate
47
+
48
+ streaming: true 0% streaming InferenceMAX: "extraction" 94%
49
+ model: gpt-4o p95: 2400ms gpt-4o p95: 1200ms accuracy
50
+
51
+ └───────────────────┴────────────────────┴───────────────────┘
52
+
53
+
54
+ PEAKINFER
55
+ (correlation)
56
+ ```
57
+
58
+ ---
59
+
60
+ ## The Four Dimensions
61
+
62
+ PeakInfer analyzes every inference point across four dimensions:
63
+
64
+ | Dimension | What We Find | Typical Improvement |
65
+ |-----------|--------------|---------------------|
66
+ | **Latency** | Missing streaming, blocking calls, p95 gaps | 50-80% faster |
67
+ | **Throughput** | Sequential loops, no batching | 10-50x improvement |
68
+ | **Reliability** | No retry, no fallback, no timeout | 99%+ uptime |
69
+ | **Cost** | Wrong model for the job | 60-90% reduction |
70
+
71
+ ---
72
+
73
+ ## How It Works
74
+
75
+ ### 1. Scan Your Code
76
+
77
+ ```bash
78
+ peakinfer analyze ./src
79
+ ```
80
+
81
+ Finds every inference point. OpenAI, Anthropic, Azure, Bedrock, self-hosted. All of them.
82
+
83
+ ### 2. See What's Holding You Back
84
+
85
+ ```
86
+ 7 inference points found
87
+ 39 issues detected
88
+
89
+ LATENCY:
90
+ - Streaming configured but not consumed (p95: 2400ms, should be 400ms)
91
+ - Blocking calls in hot path (6x latency penalty)
92
+
93
+ THROUGHPUT:
94
+ - Sequential batch processing (50x throughput opportunity)
95
+
96
+ RELIABILITY:
97
+ - Zero error handling across all LLM calls
98
+ - No fallback on critical inference path
99
+
100
+ QUICK WINS:
101
+ - Enable streaming consumption: -80% latency
102
+ - Add retry logic: +99% reliability
103
+ - Parallelize batch: 50x throughput
104
+ ```
105
+
106
+ ### 3. Catch Drift Before Production
107
+
108
+ Add to every PR:
109
+
110
+ ```yaml
111
+ - uses: kalmantic/peakinfer-action@v1
112
+ with:
113
+ path: ./src
114
+ token: ${{ secrets.PEAKINFER_TOKEN }}
115
+ ```
116
+
117
+ ---
118
+
119
+ ## Installation
120
+
121
+ ```bash
122
+ npm install -g @kalmantic/peakinfer
123
+ ```
124
+
125
+ Requires Node.js 18+.
126
+
127
+ ---
128
+
129
+ ## First-Time Setup
130
+
131
+ PeakInfer uses Claude for semantic analysis. You provide your own Anthropic API key (BYOK mode).
132
+
133
+ ### Step 1: Get an Anthropic API Key
134
+
135
+ 1. Go to [console.anthropic.com](https://console.anthropic.com/)
136
+ 2. Create an account or sign in
137
+ 3. Navigate to API Keys and create a new key
138
+ 4. Copy the key (starts with `sk-ant-`)
139
+
140
+ ### Step 2: Configure Your API Key
141
+
142
+ **Option A: Environment File (Recommended)**
143
+
144
+ ```bash
145
+ # .env
146
+ ANTHROPIC_API_KEY=sk-ant-your-key-here
147
+ ```
148
+
149
+ **Option B: Shell Export**
150
+
151
+ ```bash
152
+ export ANTHROPIC_API_KEY=sk-ant-your-key-here
153
+ ```
154
+
155
+ ### Step 3: Verify Setup
156
+
157
+ ```bash
158
+ peakinfer analyze . --verbose
159
+ ```
160
+
161
+ **BYOK Mode**: Your API key, your costs, full transparency. Analysis runs locally. No data sent to PeakInfer servers.
162
+
163
+ ---
164
+
165
+ ## Commands
166
+
167
+ ```bash
168
+ # Basic scan
169
+ peakinfer analyze .
170
+
171
+ # With code fix suggestions
172
+ peakinfer analyze . --fixes
173
+
174
+ # With HTML report
175
+ peakinfer analyze . --html --open
176
+
177
+ # Compare to InferenceMAX benchmarks
178
+ peakinfer analyze . --benchmark
179
+
180
+ # With runtime correlation (drift detection)
181
+ peakinfer analyze . --events production.jsonl
182
+
183
+ # Fetch runtime from observability platforms
184
+ peakinfer analyze . --runtime helicone --runtime-key $HELICONE_KEY
185
+
186
+ # Full analysis
187
+ peakinfer analyze . --fixes --benchmark --html --open
188
+ ```
189
+
190
+ ### CLI Options
191
+
192
+ | Flag | Description |
193
+ |------|-------------|
194
+ | **Output** | |
195
+ | `--fixes` | Show code fix suggestions for each issue |
196
+ | `--html` | Generate HTML report |
197
+ | `--pdf` | Generate PDF report |
198
+ | `--open` | Auto-open report in browser/viewer |
199
+ | `--output <format>` | Output format: `text`, `json`, or `inference-map` |
200
+ | `--verbose` | Show detailed analysis logs |
201
+ | **Runtime Data** | |
202
+ | `--events <file>` | Path to runtime events file (JSONL) |
203
+ | `--events-url <url>` | URL to fetch runtime events |
204
+ | `--runtime <source>` | Fetch from: `helicone`, `langsmith` |
205
+ | `--runtime-key <key>` | API key for runtime source |
206
+ | `--runtime-days <n>` | Days of runtime data (default: 7) |
207
+ | **Comparison** | |
208
+ | `--compare [runId]` | Compare with previous analysis run |
209
+ | `--benchmark` | Compare to InferenceMAX benchmarks |
210
+ | `--predict` | Generate deploy-time latency predictions |
211
+ | `--target-p95 <ms>` | Target p95 latency for budget calculation |
212
+ | **Cost Control** | |
213
+ | `--estimate` | Show cost estimate before analysis |
214
+ | `--yes` | Auto-proceed without confirmation |
215
+ | `--max-cost <dollars>` | Skip if estimated cost exceeds threshold |
216
+ | `--cached` | View previous analysis (offline) |
217
+
218
+ ---
219
+
220
+ ## GitHub Action
221
+
222
+ Every PR. Every merge. Automatic.
223
+
224
+ ```yaml
225
+ name: PeakInfer
226
+ on: [pull_request]
227
+
228
+ permissions:
229
+ contents: read
230
+ pull-requests: write
231
+
232
+ jobs:
233
+ analyze:
234
+ runs-on: ubuntu-latest
235
+ steps:
236
+ - uses: actions/checkout@v4
237
+ - uses: kalmantic/peakinfer-action@v1
238
+ with:
239
+ token: ${{ secrets.PEAKINFER_TOKEN }}
240
+ github-token: ${{ github.token }}
241
+ ```
242
+
243
+ See [peakinfer-action](https://github.com/Kalmantic/peakinfer-action) for full documentation.
244
+
245
+ ---
246
+
247
+ ## Runtime Drift Detection
248
+
249
+ PeakInfer's real power: correlating code with runtime behavior.
250
+
251
+ ```bash
252
+ # From file
253
+ peakinfer analyze ./src --events events.jsonl
254
+
255
+ # From Helicone
256
+ peakinfer analyze ./src --runtime helicone --runtime-key $HELICONE_KEY
257
+
258
+ # From LangSmith
259
+ peakinfer analyze ./src --runtime langsmith --runtime-key $LANGSMITH_KEY
260
+ ```
261
+
262
+ Supported formats: JSONL, JSON, CSV, OpenTelemetry, Jaeger, Zipkin, LangSmith, LiteLLM, Helicone.
263
+
264
+ ---
265
+
266
+ ## Supported Providers
267
+
268
+ | Provider | Status |
269
+ |----------|--------|
270
+ | OpenAI | Full support |
271
+ | Anthropic | Full support |
272
+ | Azure OpenAI | Full support |
273
+ | AWS Bedrock | Full support |
274
+ | Google Vertex | Full support |
275
+ | vLLM / TensorRT-LLM | HTTP detection |
276
+ | LangChain / LlamaIndex | Framework support |
277
+
278
+ ---
279
+
280
+ ## Community Templates
281
+
282
+ **43 templates** across two categories:
283
+
284
+ ### Insight Templates (12)
285
+
286
+ Detect issues: streaming drift, overpowered model, context accumulation, token underutilization, retry explosion, untested fallback, dead code, and more.
287
+
288
+ ### Optimization Templates (31)
289
+
290
+ Actionable fixes: model routing, batch utilization, prompt caching, vLLM high-throughput, GPTQ quantization, TensorRT-LLM, multi-provider fallback, auto-scaling, and more.
291
+
292
+ ---
293
+
294
+ ## Pricing
295
+
296
+ **CLI**: Free forever. BYOK — you provide your Anthropic API key.
297
+
298
+ **GitHub Action**:
299
+ - **Free**: 50 credits one-time (6-month expiry)
300
+ - **Starter**: $19 for 200 credits
301
+ - **Growth**: $49 for 600 credits
302
+ - **Scale**: $149 for 2,000 credits
303
+ - **Mega**: $499 for 10,000 credits
304
+
305
+ No subscriptions. No per-seat pricing. Team pooling.
306
+
307
+ [View pricing →](https://peakinfer.com/pricing)
308
+
309
+ ---
310
+
311
+ ## What's Included
312
+
313
+ | Feature | Status |
314
+ |---------|--------|
315
+ | Unified Prompt-Based Analysis | ✅ |
316
+ | GitHub Action with PR Comments | ✅ |
317
+ | Code Fix Suggestions | ✅ |
318
+ | Runtime Drift Detection | ✅ |
319
+ | InferenceMAX Benchmark Comparison | ✅ |
320
+ | 43 Optimization Templates | ✅ |
321
+ | Run History & Comparison | ✅ |
322
+ | BYOK Mode (CLI) | ✅ |
323
+
324
+ ---
325
+
326
+ ## Links
327
+
328
+ - [VS Code Extension](https://github.com/Kalmantic/peakinfer-vscode)
329
+ - [MCP Server (Claude Desktop)](https://github.com/Kalmantic/peakinfer-mcp)
330
+ - [GitHub Action](https://github.com/Kalmantic/peakinfer-action)
331
+ - [Report Issues](https://github.com/Kalmantic/peakinfer/issues)
332
+
333
+ ---
334
+
335
+ Built by [Kalmantic](https://kalmantic.com). Apache-2.0 license.