@hassangameryt/freeflow 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +4 -4
  3. package/{plugins/freeflow/.claude-plugin → .claude-plugin}/plugin.json +5 -2
  4. package/{plugins/freeflow/.codex-plugin → .codex-plugin}/plugin.json +8 -9
  5. package/README.md +194 -127
  6. package/assets/feedback-loop.png +0 -0
  7. package/assets/freeflow-plugin-icon.png +0 -0
  8. package/assets/freeflow_workflow_map.png +0 -0
  9. package/assets/workflow.png +0 -0
  10. package/command-surface.json +129 -0
  11. package/hooks/freeflow-runtime-context.mjs +419 -0
  12. package/hooks/tests/check-runtime-context-hook.sh +223 -0
  13. package/package.json +41 -22
  14. package/pi-extension/dist/index.js +269 -0
  15. package/pi-extension/dist/integrations/mcp-config.js +29 -0
  16. package/pi-extension/dist/output-router/host-producer-identification.js +232 -0
  17. package/pi-extension/dist/output-router/native-safety-net.js +216 -0
  18. package/pi-extension/dist/output-router/observed-tool-routing.js +122 -0
  19. package/pi-extension/dist/output-router/renderers.js +1023 -0
  20. package/pi-extension/dist/output-router/router-tools.js +554 -0
  21. package/pi-extension/dist/output-router/schemas.js +383 -0
  22. package/pi-extension/dist/output-router/status.js +744 -0
  23. package/pi-extension/dist/output-router/utils.js +502 -0
  24. package/pi-extension/dist/runtime/runtime-context.js +798 -0
  25. package/pi-extension/dist/settings/settings-tui.js +314 -0
  26. package/pi-extension/dist/settings/settings-ui.js +1487 -0
  27. package/pi-extension/freeflow/index.js +1 -0
  28. package/pi-extension/src/index.ts +295 -0
  29. package/pi-extension/src/integrations/mcp-config.ts +32 -0
  30. package/pi-extension/src/output-router/host-producer-identification.ts +256 -0
  31. package/pi-extension/src/output-router/native-safety-net.ts +248 -0
  32. package/pi-extension/src/output-router/observed-tool-routing.ts +134 -0
  33. package/pi-extension/src/output-router/renderers.ts +1108 -0
  34. package/pi-extension/src/output-router/router-tools.ts +579 -0
  35. package/pi-extension/src/output-router/schemas.ts +387 -0
  36. package/pi-extension/src/output-router/status.ts +791 -0
  37. package/pi-extension/src/output-router/utils.ts +554 -0
  38. package/pi-extension/src/runtime/runtime-context.ts +895 -0
  39. package/pi-extension/src/settings/settings-tui.ts +408 -0
  40. package/pi-extension/src/settings/settings-ui.ts +1730 -0
  41. package/pi-extension/tests/integration/pi-extension.test.js +4018 -0
  42. package/pi-extension/tests/output-router/observed-producers.test.js +132 -0
  43. package/pi-extension/tests/output-router/search.test.js +722 -0
  44. package/pi-extension/tests/settings/settings-tui.test.js +243 -0
  45. package/pi-extension/tsconfig.json +16 -0
  46. package/{plugins/freeflow/router/dist → router/dist/benchmarks}/benchmark-harness.d.ts +16 -13
  47. package/router/dist/benchmarks/benchmark-harness.js +92 -0
  48. package/router/dist/benchmarks/benchmarks.d.ts +109 -0
  49. package/router/dist/benchmarks/benchmarks.js +979 -0
  50. package/router/dist/benchmarks/codex-qa-benchmarks.d.ts +95 -0
  51. package/router/dist/benchmarks/codex-qa-benchmarks.js +500 -0
  52. package/router/dist/benchmarks/command-benchmarks.d.ts +143 -0
  53. package/router/dist/benchmarks/command-benchmarks.js +698 -0
  54. package/router/dist/benchmarks/context-mode-normalized-benchmarks.d.ts +82 -0
  55. package/router/dist/benchmarks/context-mode-normalized-benchmarks.js +773 -0
  56. package/router/dist/benchmarks/context-mode-real-deep-benchmark.d.ts +132 -0
  57. package/router/dist/benchmarks/context-mode-real-deep-benchmark.js +1380 -0
  58. package/router/dist/benchmarks/context-saving-baseline.d.ts +60 -0
  59. package/router/dist/benchmarks/context-saving-baseline.js +470 -0
  60. package/router/dist/benchmarks/index-benchmarks.d.ts +103 -0
  61. package/router/dist/benchmarks/index-benchmarks.js +862 -0
  62. package/router/dist/benchmarks/storage-policy-benchmarks.d.ts +101 -0
  63. package/router/dist/benchmarks/storage-policy-benchmarks.js +618 -0
  64. package/router/dist/benchmarks/vault-index-benchmarks.d.ts +56 -0
  65. package/router/dist/benchmarks/vault-index-benchmarks.js +322 -0
  66. package/router/dist/config/config.d.ts +103 -0
  67. package/router/dist/config/config.js +632 -0
  68. package/{plugins/freeflow/router/dist → router/dist/config}/router-contract.d.ts +2 -2
  69. package/router/dist/config/router-contract.js +54 -0
  70. package/{plugins/freeflow/router/dist → router/dist/config}/schema.d.ts +19 -10
  71. package/router/dist/config/schema.js +648 -0
  72. package/router/dist/config/types.d.ts +573 -0
  73. package/router/dist/config/types.js +41 -0
  74. package/router/dist/evidence/bounded-evidence.d.ts +40 -0
  75. package/router/dist/evidence/bounded-evidence.js +323 -0
  76. package/router/dist/evidence/evidence-range-selector.d.ts +24 -0
  77. package/router/dist/evidence/evidence-range-selector.js +232 -0
  78. package/router/dist/evidence/evidence-search.d.ts +27 -0
  79. package/router/dist/evidence/evidence-search.js +490 -0
  80. package/{plugins/freeflow/router/dist → router/dist/evidence}/evidence.d.ts +18 -18
  81. package/router/dist/evidence/evidence.js +200 -0
  82. package/router/dist/evidence/failure-contracts.d.ts +37 -0
  83. package/router/dist/evidence/failure-contracts.js +166 -0
  84. package/router/dist/evidence/line-ranges.d.ts +24 -0
  85. package/router/dist/evidence/line-ranges.js +22 -0
  86. package/router/dist/experiments/local-index.d.ts +64 -0
  87. package/router/dist/experiments/local-index.js +581 -0
  88. package/router/dist/index.d.ts +30 -0
  89. package/router/dist/index.js +32 -0
  90. package/router/dist/local/local-traversal.d.ts +18 -0
  91. package/router/dist/local/local-traversal.js +334 -0
  92. package/router/dist/processing/engine.d.ts +132 -0
  93. package/router/dist/processing/engine.js +533 -0
  94. package/router/dist/processing/reducers.d.ts +280 -0
  95. package/router/dist/processing/reducers.js +1673 -0
  96. package/router/dist/processing/renderers.d.ts +31 -0
  97. package/router/dist/processing/renderers.js +195 -0
  98. package/router/dist/processing/scripts.d.ts +91 -0
  99. package/router/dist/processing/scripts.js +386 -0
  100. package/{plugins/freeflow/router/dist → router/dist/repo}/repo-traversal.d.ts +9 -9
  101. package/router/dist/repo/repo-traversal.js +245 -0
  102. package/router/dist/routing/observed-reducers.d.ts +41 -0
  103. package/router/dist/routing/observed-reducers.js +661 -0
  104. package/router/dist/routing/observed-routing.d.ts +26 -0
  105. package/router/dist/routing/observed-routing.js +378 -0
  106. package/router/dist/routing/parsers.d.ts +16 -0
  107. package/router/dist/routing/parsers.js +521 -0
  108. package/router/dist/routing/run-filters.d.ts +60 -0
  109. package/router/dist/routing/run-filters.js +238 -0
  110. package/router/dist/routing/run-reducers.d.ts +49 -0
  111. package/router/dist/routing/run-reducers.js +122 -0
  112. package/router/dist/sandbox/adapter-roots.d.ts +46 -0
  113. package/router/dist/sandbox/adapter-roots.js +66 -0
  114. package/router/dist/sandbox/eryx-python-adapter.d.ts +13 -0
  115. package/router/dist/sandbox/eryx-python-adapter.js +868 -0
  116. package/router/dist/sandbox/jq-wasm-adapter.d.ts +9 -0
  117. package/router/dist/sandbox/jq-wasm-adapter.js +429 -0
  118. package/router/dist/sandbox/quickjs-wasi-adapter.d.ts +13 -0
  119. package/router/dist/sandbox/quickjs-wasi-adapter.js +384 -0
  120. package/router/dist/sandbox/script-sandbox.d.ts +134 -0
  121. package/router/dist/sandbox/script-sandbox.js +337 -0
  122. package/router/dist/setup/script-transform-adapters.d.ts +32 -0
  123. package/router/dist/setup/script-transform-adapters.js +278 -0
  124. package/router/dist/tools/batch.d.ts +33 -0
  125. package/router/dist/tools/batch.js +586 -0
  126. package/router/dist/tools/run.d.ts +62 -0
  127. package/router/dist/tools/run.js +1304 -0
  128. package/router/dist/tools/search.d.ts +66 -0
  129. package/router/dist/tools/search.js +1364 -0
  130. package/router/dist/transform/engine.d.ts +168 -0
  131. package/router/dist/transform/engine.js +2072 -0
  132. package/router/dist/vault/vault-index.d.ts +125 -0
  133. package/router/dist/vault/vault-index.js +416 -0
  134. package/router/dist/vault/vault.d.ts +138 -0
  135. package/router/dist/vault/vault.js +630 -0
  136. package/runtime/interaction-contract.md +16 -0
  137. package/skills/bypass/SKILL.md +82 -0
  138. package/skills/commit-work/SKILL.md +106 -0
  139. package/skills/commit-work/references/staging-decisions.md +73 -0
  140. package/skills/decision-gate/SKILL.md +48 -0
  141. package/skills/design-for-depth/SKILL.md +106 -0
  142. package/skills/design-for-depth/references/design-pressure-signals.md +314 -0
  143. package/skills/design-for-depth/references/interface-design-loop.md +156 -0
  144. package/skills/design-for-depth/references/software-design-philosophy.md +248 -0
  145. package/skills/diagnose-failure/SKILL.md +105 -0
  146. package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +36 -0
  147. package/skills/diagnose-failure/references/flaky-and-performance.md +43 -0
  148. package/skills/discuss/SKILL.md +121 -0
  149. package/skills/discuss/references/checkpoints.md +66 -0
  150. package/skills/evaluate-skill/SKILL.md +105 -0
  151. package/skills/evaluate-skill/references/definition-schema.md +345 -0
  152. package/skills/evaluate-skill/references/evaluation-design.md +86 -0
  153. package/skills/evaluate-skill/references/execution-and-evidence.md +85 -0
  154. package/skills/evaluate-skill/references/review-and-revision.md +51 -0
  155. package/skills/evaluate-skill/scripts/lib/definitions.mjs +296 -0
  156. package/skills/evaluate-skill/scripts/lib/evidence.mjs +46 -0
  157. package/skills/evaluate-skill/scripts/lib/grade-comparison.mjs +60 -0
  158. package/skills/evaluate-skill/scripts/lib/grade-interaction.mjs +148 -0
  159. package/skills/evaluate-skill/scripts/lib/grade-support.mjs +126 -0
  160. package/skills/evaluate-skill/scripts/lib/grade-workspace.mjs +192 -0
  161. package/skills/evaluate-skill/scripts/lib/grade.mjs +56 -0
  162. package/skills/evaluate-skill/scripts/lib/pi.mjs +489 -0
  163. package/skills/evaluate-skill/scripts/lib/process.mjs +79 -0
  164. package/skills/evaluate-skill/scripts/lib/rpc.mjs +444 -0
  165. package/skills/evaluate-skill/scripts/lib/runner.mjs +346 -0
  166. package/skills/evaluate-skill/scripts/lib/sandbox.mjs +409 -0
  167. package/skills/evaluate-skill/scripts/lib/view.mjs +337 -0
  168. package/skills/evaluate-skill/scripts/pi-guard.mjs +164 -0
  169. package/skills/evaluate-skill/scripts/skill-eval.mjs +101 -0
  170. package/skills/execute-work/SKILL.md +99 -0
  171. package/skills/execute-work/references/code-practices.md +78 -0
  172. package/skills/execute-work/references/execution-loop.md +77 -0
  173. package/skills/finish-branch/SKILL.md +117 -0
  174. package/skills/finish-branch/references/integration-options.md +80 -0
  175. package/skills/handoff/SKILL.md +92 -0
  176. package/skills/handoff/references/templates.md +141 -0
  177. package/skills/launch-work/SKILL.md +116 -0
  178. package/skills/launch-work/references/launch-readiness.md +85 -0
  179. package/skills/migration-work/SKILL.md +115 -0
  180. package/skills/migration-work/references/migration-lifecycle.md +82 -0
  181. package/skills/mode-contract/SKILL.md +82 -0
  182. package/skills/output-router/SKILL.md +206 -0
  183. package/skills/output-router/references/safety-policy.md +40 -0
  184. package/skills/release-work/SKILL.md +118 -0
  185. package/skills/release-work/references/release-evidence.md +78 -0
  186. package/skills/review-artifact/SKILL.md +126 -0
  187. package/skills/review-artifact/references/reviewer-prompt.md +148 -0
  188. package/skills/review-work/SKILL.md +126 -0
  189. package/skills/review-work/references/reviewer-prompt.md +134 -0
  190. package/skills/review-work/references/security-risk-lens.md +67 -0
  191. package/skills/setup-freeflow/SKILL.md +98 -0
  192. package/skills/setup-freeflow/references/activation-contract.md +120 -0
  193. package/skills/setup-freeflow/references/host-setup.md +72 -0
  194. package/skills/setup-freeflow/references/output-router-setup.md +110 -0
  195. package/skills/simplify-code/SKILL.md +80 -0
  196. package/skills/simplify-code/references/simplification-patterns.md +70 -0
  197. package/skills/tdd/SKILL.md +96 -0
  198. package/skills/tdd/references/test-design.md +96 -0
  199. package/skills/track-work/SKILL.md +84 -0
  200. package/skills/track-work/references/working-record-schema.md +378 -0
  201. package/skills/verify-work/SKILL.md +85 -0
  202. package/skills/verify-work/references/browser-runtime-evidence.md +55 -0
  203. package/skills/verify-work/references/integration-evidence.md +51 -0
  204. package/skills/verify-work/references/performance-evidence.md +57 -0
  205. package/skills/workflow/SKILL.md +91 -0
  206. package/skills/workflow/references/domain-skill-composition.md +57 -0
  207. package/skills/workflow/references/workflow-loop.md +92 -0
  208. package/skills/write-plan/SKILL.md +123 -0
  209. package/skills/write-plan/references/plan-shapes.md +156 -0
  210. package/skills/write-skill/SKILL.md +119 -0
  211. package/skills/write-skill/references/activation-boundaries.md +62 -0
  212. package/skills/write-skill/references/agent-first-instructions.md +87 -0
  213. package/skills/write-skill/references/progressive-disclosure.md +63 -0
  214. package/skills/write-skill/scripts/lib/skill-author.mjs +653 -0
  215. package/skills/write-skill/scripts/skill-author.mjs +104 -0
  216. package/skills/write-spec/SKILL.md +104 -0
  217. package/skills/write-spec/references/artifact-standards.md +86 -0
  218. package/skills/write-spec/references/decision-records.md +77 -0
  219. package/skills/write-spec/references/spec-shapes.md +128 -0
  220. package/plugins/freeflow/command-surface.json +0 -77
  221. package/plugins/freeflow/docs/README.md +0 -40
  222. package/plugins/freeflow/docs/adr/0001-three-modes.md +0 -27
  223. package/plugins/freeflow/docs/adr/0002-evals-before-hooks.md +0 -17
  224. package/plugins/freeflow/docs/adr/0003-release-boundary.md +0 -21
  225. package/plugins/freeflow/docs/adr/0004-research-replaces-shallow-discovery-skills.md +0 -26
  226. package/plugins/freeflow/docs/adr/README.md +0 -8
  227. package/plugins/freeflow/docs/architecture.md +0 -86
  228. package/plugins/freeflow/docs/output-router.md +0 -212
  229. package/plugins/freeflow/docs/release-evidence.md +0 -69
  230. package/plugins/freeflow/docs/skills.md +0 -43
  231. package/plugins/freeflow/docs/workflow.md +0 -57
  232. package/plugins/freeflow/hooks/freeflow-runtime-context.mjs +0 -257
  233. package/plugins/freeflow/pi-extension/index.js +0 -1176
  234. package/plugins/freeflow/router/dist/benchmark-harness.js +0 -92
  235. package/plugins/freeflow/router/dist/benchmarks.d.ts +0 -102
  236. package/plugins/freeflow/router/dist/benchmarks.js +0 -880
  237. package/plugins/freeflow/router/dist/bounded-evidence.d.ts +0 -40
  238. package/plugins/freeflow/router/dist/bounded-evidence.js +0 -310
  239. package/plugins/freeflow/router/dist/codex-qa-benchmarks.d.ts +0 -91
  240. package/plugins/freeflow/router/dist/codex-qa-benchmarks.js +0 -461
  241. package/plugins/freeflow/router/dist/command-benchmarks.d.ts +0 -128
  242. package/plugins/freeflow/router/dist/command-benchmarks.js +0 -652
  243. package/plugins/freeflow/router/dist/config.d.ts +0 -22
  244. package/plugins/freeflow/router/dist/config.js +0 -114
  245. package/plugins/freeflow/router/dist/evidence-range-selector.d.ts +0 -22
  246. package/plugins/freeflow/router/dist/evidence-range-selector.js +0 -180
  247. package/plugins/freeflow/router/dist/evidence-search.d.ts +0 -25
  248. package/plugins/freeflow/router/dist/evidence-search.js +0 -450
  249. package/plugins/freeflow/router/dist/evidence.js +0 -196
  250. package/plugins/freeflow/router/dist/experimental-local-index.d.ts +0 -1
  251. package/plugins/freeflow/router/dist/experimental-local-index.js +0 -1
  252. package/plugins/freeflow/router/dist/experiments/local-index.d.ts +0 -58
  253. package/plugins/freeflow/router/dist/experiments/local-index.js +0 -562
  254. package/plugins/freeflow/router/dist/index-benchmarks.d.ts +0 -84
  255. package/plugins/freeflow/router/dist/index-benchmarks.js +0 -458
  256. package/plugins/freeflow/router/dist/index.d.ts +0 -12
  257. package/plugins/freeflow/router/dist/index.js +0 -12
  258. package/plugins/freeflow/router/dist/line-ranges.d.ts +0 -22
  259. package/plugins/freeflow/router/dist/line-ranges.js +0 -22
  260. package/plugins/freeflow/router/dist/parsers.d.ts +0 -16
  261. package/plugins/freeflow/router/dist/parsers.js +0 -473
  262. package/plugins/freeflow/router/dist/repo-traversal.js +0 -242
  263. package/plugins/freeflow/router/dist/retrieve.d.ts +0 -33
  264. package/plugins/freeflow/router/dist/retrieve.js +0 -855
  265. package/plugins/freeflow/router/dist/router-contract.js +0 -54
  266. package/plugins/freeflow/router/dist/run.d.ts +0 -26
  267. package/plugins/freeflow/router/dist/run.js +0 -356
  268. package/plugins/freeflow/router/dist/schema.js +0 -354
  269. package/plugins/freeflow/router/dist/types.d.ts +0 -234
  270. package/plugins/freeflow/router/dist/types.js +0 -9
  271. package/plugins/freeflow/router/dist/vault.d.ts +0 -80
  272. package/plugins/freeflow/router/dist/vault.js +0 -484
  273. package/plugins/freeflow/skills/bypass/SKILL.md +0 -68
  274. package/plugins/freeflow/skills/commit-work/SKILL.md +0 -98
  275. package/plugins/freeflow/skills/commit-work/references/staging-decisions.md +0 -51
  276. package/plugins/freeflow/skills/diagnose-failure/SKILL.md +0 -95
  277. package/plugins/freeflow/skills/diagnose-failure/references/feedback-loop-catalog.md +0 -25
  278. package/plugins/freeflow/skills/diagnose-failure/references/flaky-and-performance.md +0 -31
  279. package/plugins/freeflow/skills/evaluate-skill/SKILL.md +0 -96
  280. package/plugins/freeflow/skills/evaluate-skill/references/eval-patterns.md +0 -41
  281. package/plugins/freeflow/skills/evaluate-skill/references/grading-priority.md +0 -33
  282. package/plugins/freeflow/skills/execute-plan/SKILL.md +0 -132
  283. package/plugins/freeflow/skills/execute-plan/references/execution-map.md +0 -122
  284. package/plugins/freeflow/skills/handoff/SKILL.md +0 -66
  285. package/plugins/freeflow/skills/handoff/references/templates.md +0 -64
  286. package/plugins/freeflow/skills/interview-gate/SKILL.md +0 -90
  287. package/plugins/freeflow/skills/mode-contract/SKILL.md +0 -79
  288. package/plugins/freeflow/skills/output-router/SKILL.md +0 -69
  289. package/plugins/freeflow/skills/output-router/references/safety-policy.md +0 -33
  290. package/plugins/freeflow/skills/research/ARTIFACT-DESTINATIONS.md +0 -58
  291. package/plugins/freeflow/skills/research/CHECKPOINTS.md +0 -74
  292. package/plugins/freeflow/skills/research/LANGUAGE.md +0 -61
  293. package/plugins/freeflow/skills/research/SKILL.md +0 -128
  294. package/plugins/freeflow/skills/review-artifact/SKILL.md +0 -115
  295. package/plugins/freeflow/skills/review-artifact/references/reviewer-prompt.md +0 -56
  296. package/plugins/freeflow/skills/review-work/SKILL.md +0 -96
  297. package/plugins/freeflow/skills/review-work/references/reviewer-prompt.md +0 -97
  298. package/plugins/freeflow/skills/setup-freeflow/SKILL.md +0 -94
  299. package/plugins/freeflow/skills/setup-freeflow/references/activation-contract.md +0 -99
  300. package/plugins/freeflow/skills/setup-freeflow/references/host-setup.md +0 -35
  301. package/plugins/freeflow/skills/setup-freeflow/references/output-router-setup.md +0 -52
  302. package/plugins/freeflow/skills/verify-work/SKILL.md +0 -62
  303. package/plugins/freeflow/skills/workflow/SKILL.md +0 -95
  304. package/plugins/freeflow/skills/workflow/references/workflow-map.md +0 -102
  305. package/plugins/freeflow/skills/write-plan/SKILL.md +0 -88
  306. package/plugins/freeflow/skills/write-plan/references/plan-shapes.md +0 -70
  307. package/plugins/freeflow/skills/write-skill/SKILL.md +0 -88
  308. package/plugins/freeflow/skills/write-spec/SKILL.md +0 -90
  309. package/plugins/freeflow/skills/write-spec/references/artifact-standards.md +0 -67
  310. package/plugins/freeflow/skills/write-spec/references/spec-shapes.md +0 -69
  311. /package/{plugins/freeflow/assets → assets}/freeflow-plugin-icon-transparent.png +0 -0
  312. /package/{plugins/freeflow/hooks → hooks}/hooks.json +0 -0
@@ -1,58 +0,0 @@
1
- export interface ExperimentalLocalIndexOptions {
2
- root: string;
3
- cacheRoot?: string;
4
- generatedPathGlobs?: readonly string[];
5
- }
6
- export interface ExperimentalIndexLoadResult {
7
- mode: ExperimentalIndexLoadMode;
8
- index: ExperimentalRepoIndex;
9
- cachePath: string;
10
- buildMs: number;
11
- refreshReason?: string;
12
- }
13
- export type ExperimentalIndexLoadMode = "cold-built" | "warm-loaded" | "stale-refreshed";
14
- export interface ExperimentalRepoIndex {
15
- version: 1;
16
- root: string;
17
- builtAt: string;
18
- files: Record<string, ExperimentalIndexedFile>;
19
- chunks: ExperimentalIndexedChunk[];
20
- tokenDocumentFrequency: Record<string, number>;
21
- averageChunkTokens: number;
22
- cachePath: string;
23
- }
24
- export interface ExperimentalIndexedFile {
25
- path: string;
26
- hashSha256: string;
27
- sizeBytes: number;
28
- lineCount: number;
29
- chunkIds: number[];
30
- }
31
- export interface ExperimentalIndexedChunk {
32
- id: number;
33
- path: string;
34
- startLine: number;
35
- endLine: number;
36
- kind: "section" | "window";
37
- text: string;
38
- tokens: string[];
39
- tokenCounts: Record<string, number>;
40
- heading?: string;
41
- }
42
- export interface ExperimentalIndexQueryOptions {
43
- topK?: number;
44
- }
45
- export interface ExperimentalIndexCandidate {
46
- path: string;
47
- lines: string;
48
- excerpt: string;
49
- score: number;
50
- reason: string;
51
- chunkKind: ExperimentalIndexedChunk["kind"];
52
- hashSha256: string;
53
- contextBytes: number;
54
- }
55
- export declare function defaultExperimentalIndexCacheRoot(): string;
56
- export declare function experimentalIndexCachePath(options: ExperimentalLocalIndexOptions): Promise<string>;
57
- export declare function buildOrLoadExperimentalRepoIndex(options: ExperimentalLocalIndexOptions): Promise<ExperimentalIndexLoadResult>;
58
- export declare function queryExperimentalRepoIndex(index: ExperimentalRepoIndex, query: string, options?: ExperimentalIndexQueryOptions): ExperimentalIndexCandidate[];
@@ -1,562 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { mkdir, readdir, readFile, realpath, stat, writeFile } from "node:fs/promises";
3
- import { homedir } from "node:os";
4
- import { dirname, join, relative, resolve } from "node:path";
5
- import { performance } from "node:perf_hooks";
6
- const INDEX_VERSION = 1;
7
- const DEFAULT_CONTEXT_LINES = 2;
8
- const DEFAULT_TOP_K = 1;
9
- const MAX_TOP_K = 10;
10
- const BROAD_SCAN_MAX_FILE_BYTES = 1024 * 1024;
11
- const QUERY_EXCERPT_MAX_BYTES = 8_192;
12
- const LINE_PREVIEW_MAX_BYTES = 2_048;
13
- const TRUNCATION_SUFFIX = " … [truncated; query index stores bounded preview only]";
14
- const STOPWORDS = new Set([
15
- "a",
16
- "an",
17
- "and",
18
- "are",
19
- "as",
20
- "at",
21
- "be",
22
- "by",
23
- "for",
24
- "from",
25
- "in",
26
- "is",
27
- "it",
28
- "of",
29
- "on",
30
- "or",
31
- "that",
32
- "the",
33
- "this",
34
- "to",
35
- "with",
36
- ]);
37
- const SKIP_DIRS = new Set([
38
- ".git",
39
- "node_modules",
40
- "dist",
41
- "build",
42
- "out",
43
- ".next",
44
- ".nuxt",
45
- "coverage",
46
- "target",
47
- "graphify-out",
48
- ".cache",
49
- ".tmp",
50
- "tmp",
51
- "temp",
52
- "logs",
53
- "generated",
54
- ]);
55
- const BROAD_SKIP_FILE_EXTENSIONS = new Set([
56
- ".7z",
57
- ".avi",
58
- ".bin",
59
- ".bmp",
60
- ".br",
61
- ".class",
62
- ".db",
63
- ".dll",
64
- ".dylib",
65
- ".eot",
66
- ".exe",
67
- ".gif",
68
- ".gz",
69
- ".heic",
70
- ".icns",
71
- ".ico",
72
- ".jar",
73
- ".jpeg",
74
- ".jpg",
75
- ".mov",
76
- ".mp3",
77
- ".mp4",
78
- ".otf",
79
- ".parquet",
80
- ".pdf",
81
- ".png",
82
- ".pyc",
83
- ".rar",
84
- ".so",
85
- ".sqlite",
86
- ".sqlite3",
87
- ".tar",
88
- ".tgz",
89
- ".ttf",
90
- ".wasm",
91
- ".webm",
92
- ".webp",
93
- ".woff",
94
- ".woff2",
95
- ".zip",
96
- ".zst",
97
- ]);
98
- export function defaultExperimentalIndexCacheRoot() {
99
- const xdgCache = process.env.XDG_CACHE_HOME;
100
- return resolve(xdgCache && xdgCache.trim() ? xdgCache : join(homedir(), ".cache"), "freeflow-router", "experimental-index");
101
- }
102
- export async function experimentalIndexCachePath(options) {
103
- const root = await realpath(resolve(options.root));
104
- const cacheRoot = resolve(options.cacheRoot ?? defaultExperimentalIndexCacheRoot());
105
- return join(cacheRoot, `${hash(JSON.stringify({ root, generatedPathGlobs: options.generatedPathGlobs ?? [] })).slice(0, 24)}.json`);
106
- }
107
- export async function buildOrLoadExperimentalRepoIndex(options) {
108
- const startedAt = performance.now();
109
- const root = await realpath(resolve(options.root));
110
- const cacheOptions = { root };
111
- if (options.cacheRoot !== undefined) {
112
- cacheOptions.cacheRoot = options.cacheRoot;
113
- }
114
- if (options.generatedPathGlobs !== undefined) {
115
- cacheOptions.generatedPathGlobs = options.generatedPathGlobs;
116
- }
117
- const cachePath = await experimentalIndexCachePath(cacheOptions);
118
- const scannedFiles = await scanRepoTextFiles(root, options.generatedPathGlobs ?? []);
119
- const cachedIndex = await readCachedIndex(cachePath, root);
120
- if (cachedIndex && manifestMatches(cachedIndex, scannedFiles)) {
121
- return {
122
- mode: "warm-loaded",
123
- index: cachedIndex,
124
- cachePath,
125
- buildMs: performance.now() - startedAt,
126
- };
127
- }
128
- const index = buildIndexFromScannedFiles(root, cachePath, scannedFiles);
129
- await writeIndex(cachePath, index);
130
- return {
131
- mode: cachedIndex ? "stale-refreshed" : "cold-built",
132
- index,
133
- cachePath,
134
- buildMs: performance.now() - startedAt,
135
- ...(cachedIndex ? { refreshReason: staleReason(cachedIndex, scannedFiles) } : {}),
136
- };
137
- }
138
- export function queryExperimentalRepoIndex(index, query, options = {}) {
139
- const requestedTopK = options.topK ?? DEFAULT_TOP_K;
140
- const topK = Number.isFinite(requestedTopK)
141
- ? Math.min(MAX_TOP_K, Math.max(1, Math.floor(requestedTopK)))
142
- : DEFAULT_TOP_K;
143
- const queryTokens = uniqueTokens(tokenize(query));
144
- if (queryTokens.length === 0) {
145
- return [];
146
- }
147
- const normalizedQueryPhrase = normalizeTokenSequence(query);
148
- const stats = {
149
- averageLength: index.averageChunkTokens || 1,
150
- documentFrequency: new Map(Object.entries(index.tokenDocumentFrequency)),
151
- chunkCount: index.chunks.length,
152
- };
153
- const scored = [];
154
- for (const chunk of index.chunks) {
155
- const candidate = scoreIndexedChunk(index, chunk, queryTokens, normalizedQueryPhrase, stats);
156
- if (candidate) {
157
- scored.push(candidate);
158
- }
159
- }
160
- scored.sort((a, b) => b.score - a.score);
161
- const selected = [];
162
- const seen = new Set();
163
- for (const candidate of scored) {
164
- if (seen.has(candidate.path)) {
165
- continue;
166
- }
167
- seen.add(candidate.path);
168
- selected.push(candidate);
169
- if (selected.length >= topK) {
170
- break;
171
- }
172
- }
173
- return selected;
174
- }
175
- async function readCachedIndex(cachePath, root) {
176
- try {
177
- const parsed = JSON.parse(await readFile(cachePath, "utf8"));
178
- if (parsed.version !== INDEX_VERSION || parsed.root !== root || !parsed.files || !Array.isArray(parsed.chunks)) {
179
- return null;
180
- }
181
- return parsed;
182
- }
183
- catch {
184
- return null;
185
- }
186
- }
187
- async function writeIndex(cachePath, index) {
188
- await mkdir(dirname(cachePath), { recursive: true });
189
- await writeFile(cachePath, `${JSON.stringify(index, null, 2)}\n`, "utf8");
190
- }
191
- function manifestMatches(index, scannedFiles) {
192
- const indexedPaths = Object.keys(index.files).sort();
193
- const scannedPaths = scannedFiles.map((file) => file.path).sort();
194
- if (indexedPaths.length !== scannedPaths.length) {
195
- return false;
196
- }
197
- for (let indexPath = 0; indexPath < scannedPaths.length; indexPath += 1) {
198
- if (indexedPaths[indexPath] !== scannedPaths[indexPath]) {
199
- return false;
200
- }
201
- }
202
- return scannedFiles.every((file) => index.files[file.path]?.hashSha256 === file.hashSha256);
203
- }
204
- function staleReason(index, scannedFiles) {
205
- const indexedPaths = new Set(Object.keys(index.files));
206
- const scannedPaths = new Set(scannedFiles.map((file) => file.path));
207
- const added = [...scannedPaths].filter((path) => !indexedPaths.has(path));
208
- const removed = [...indexedPaths].filter((path) => !scannedPaths.has(path));
209
- const changed = scannedFiles
210
- .filter((file) => indexedPaths.has(file.path) && index.files[file.path]?.hashSha256 !== file.hashSha256)
211
- .map((file) => file.path);
212
- const parts = [];
213
- if (added.length) {
214
- parts.push(`${added.length} added`);
215
- }
216
- if (removed.length) {
217
- parts.push(`${removed.length} removed`);
218
- }
219
- if (changed.length) {
220
- parts.push(`${changed.length} changed`);
221
- }
222
- return parts.length ? parts.join(", ") : "cache metadata changed";
223
- }
224
- function buildIndexFromScannedFiles(root, cachePath, scannedFiles) {
225
- const chunks = [];
226
- const files = {};
227
- for (const file of scannedFiles) {
228
- const fileChunks = candidateChunksForFile(file);
229
- const chunkIds = [];
230
- for (const chunk of fileChunks) {
231
- const tokens = tokenize(chunk.text);
232
- const indexedChunk = {
233
- id: chunks.length,
234
- path: file.path,
235
- startLine: chunk.range.start,
236
- endLine: chunk.range.end,
237
- kind: chunk.kind,
238
- text: chunk.text,
239
- tokens,
240
- tokenCounts: Object.fromEntries(tokenCountMap(tokens)),
241
- };
242
- if (chunk.heading !== undefined) {
243
- indexedChunk.heading = chunk.heading;
244
- }
245
- chunks.push(indexedChunk);
246
- chunkIds.push(indexedChunk.id);
247
- }
248
- files[file.path] = {
249
- path: file.path,
250
- hashSha256: file.hashSha256,
251
- sizeBytes: file.sizeBytes,
252
- lineCount: file.lines.length,
253
- chunkIds,
254
- };
255
- }
256
- const tokenDocumentFrequency = {};
257
- let totalTokens = 0;
258
- for (const chunk of chunks) {
259
- totalTokens += Math.max(1, chunk.tokens.length);
260
- for (const token of uniqueTokens(chunk.tokens)) {
261
- tokenDocumentFrequency[token] = (tokenDocumentFrequency[token] ?? 0) + 1;
262
- }
263
- }
264
- return {
265
- version: INDEX_VERSION,
266
- root,
267
- builtAt: new Date().toISOString(),
268
- files,
269
- chunks,
270
- tokenDocumentFrequency,
271
- averageChunkTokens: chunks.length ? totalTokens / chunks.length : 1,
272
- cachePath,
273
- };
274
- }
275
- async function scanRepoTextFiles(root, generatedPathGlobs = []) {
276
- const files = [];
277
- const visitedDirectories = new Set();
278
- await collectTextFiles(root, root, files, visitedDirectories, generatedPathGlobs);
279
- return files.sort((a, b) => a.path.localeCompare(b.path));
280
- }
281
- async function collectTextFiles(root, currentPath, files, visitedDirectories, generatedPathGlobs = []) {
282
- let currentRealPath;
283
- try {
284
- currentRealPath = await realpath(currentPath);
285
- }
286
- catch {
287
- return;
288
- }
289
- if (!isPathInsideRoot(root, currentRealPath)) {
290
- return;
291
- }
292
- let currentStat;
293
- try {
294
- currentStat = await stat(currentRealPath);
295
- }
296
- catch {
297
- return;
298
- }
299
- const relativePath = normalizeRelativePath(relative(root, currentRealPath));
300
- if (currentStat.isDirectory()) {
301
- if (visitedDirectories.has(currentRealPath)) {
302
- return;
303
- }
304
- visitedDirectories.add(currentRealPath);
305
- if (relativePath !== "" && (shouldSkipBroadDirectory(currentRealPath) || matchesGeneratedPathHint(relativePath, generatedPathGlobs))) {
306
- return;
307
- }
308
- const entries = await readdir(currentRealPath, { withFileTypes: true });
309
- for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
310
- await collectTextFiles(root, resolve(currentRealPath, entry.name), files, visitedDirectories, generatedPathGlobs);
311
- }
312
- return;
313
- }
314
- if (!currentStat.isFile()) {
315
- return;
316
- }
317
- if (shouldSkipBroadFile(relativePath, currentStat.size) || matchesGeneratedPathHint(relativePath, generatedPathGlobs)) {
318
- return;
319
- }
320
- const text = await readFile(currentRealPath, "utf8");
321
- if (text.includes("\0")) {
322
- return;
323
- }
324
- files.push({
325
- path: relativePath,
326
- absolutePath: currentRealPath,
327
- text,
328
- lines: splitLines(text),
329
- hashSha256: hash(text),
330
- sizeBytes: byteLength(text),
331
- });
332
- }
333
- function candidateChunksForFile(file) {
334
- const chunks = [...markdownSectionChunks(file), ...lineWindowChunks(file)];
335
- return chunks.length ? chunks : lineWindowChunks(file);
336
- }
337
- function markdownSectionChunks(file) {
338
- const headingIndexes = file.lines
339
- .map((line, index) => ({ line, index }))
340
- .filter(({ line }) => line.trimStart().startsWith("#"));
341
- if (!headingIndexes.length) {
342
- return [];
343
- }
344
- return headingIndexes.map(({ line, index }, headingOrdinal) => {
345
- const nextHeading = headingIndexes[headingOrdinal + 1]?.index ?? file.lines.length;
346
- const range = { start: index + 1, end: Math.max(index + 1, nextHeading) };
347
- return {
348
- range,
349
- text: file.lines.slice(range.start - 1, range.end).join("\n"),
350
- heading: line,
351
- kind: "section",
352
- };
353
- });
354
- }
355
- function lineWindowChunks(file) {
356
- return file.lines.map((_, lineIndex) => {
357
- const start = Math.max(0, lineIndex - DEFAULT_CONTEXT_LINES);
358
- const end = Math.min(file.lines.length - 1, lineIndex + DEFAULT_CONTEXT_LINES);
359
- return {
360
- range: { start: start + 1, end: end + 1 },
361
- text: file.lines.slice(start, end + 1).join("\n"),
362
- kind: "window",
363
- };
364
- });
365
- }
366
- function scoreIndexedChunk(index, chunk, queryTokens, normalizedQueryPhrase, stats) {
367
- const tokenCounts = new Map(Object.entries(chunk.tokenCounts));
368
- const matchingTokens = queryTokens.filter((token) => (tokenCounts.get(token) ?? 0) > 0);
369
- const pathScore = scoreText(chunk.path, queryTokens);
370
- if (!matchingTokens.length && pathScore <= 0) {
371
- return null;
372
- }
373
- const exactPhrase = hasExactNormalizedPhrase(chunk.text, normalizedQueryPhrase);
374
- const chunkLength = Math.max(1, chunk.tokens.length);
375
- const score = (exactPhrase ? 100_000 : 0) +
376
- bm25Score(queryTokens, tokenCounts, chunkLength, stats) * 10 +
377
- coverageRatio(matchingTokens, queryTokens) * 25 +
378
- headingCoverageBoost(chunk.heading ?? "", queryTokens) +
379
- identifierBoost(chunk.text, queryTokens) +
380
- pathScore -
381
- Math.log1p(chunkLength) * 10;
382
- const file = index.files[chunk.path];
383
- if (!file) {
384
- return null;
385
- }
386
- const lines = `${chunk.startLine}-${chunk.endLine}`;
387
- const excerpt = boundedExcerpt(chunk.text);
388
- return {
389
- path: chunk.path,
390
- lines,
391
- excerpt,
392
- score,
393
- reason: exactPhrase
394
- ? `matched exact normalized query phrase in indexed ${chunk.kind} chunk`
395
- : `BM25-style indexed ${chunk.kind} chunk with ${matchingTokens.length}/${queryTokens.length} query-token coverage`,
396
- chunkKind: chunk.kind,
397
- hashSha256: file.hashSha256,
398
- contextBytes: byteLength(excerpt),
399
- };
400
- }
401
- function bm25Score(queryTokens, tokenCounts, chunkLength, stats) {
402
- const k1 = 1.2;
403
- const b = 0.75;
404
- return queryTokens.reduce((score, token) => {
405
- const termFrequency = tokenCounts.get(token) ?? 0;
406
- if (termFrequency <= 0) {
407
- return score;
408
- }
409
- const documentFrequency = stats.documentFrequency.get(token) ?? 0;
410
- const idf = Math.log(1 + (stats.chunkCount - documentFrequency + 0.5) / (documentFrequency + 0.5));
411
- const normalizedLength = k1 * (1 - b + b * (chunkLength / Math.max(1, stats.averageLength)));
412
- const saturatedFrequency = (termFrequency * (k1 + 1)) / (termFrequency + normalizedLength);
413
- return score + idf * saturatedFrequency;
414
- }, 0);
415
- }
416
- function coverageRatio(matchingTokens, queryTokens) {
417
- return queryTokens.length ? matchingTokens.length / queryTokens.length : 0;
418
- }
419
- function headingCoverageBoost(heading, queryTokens) {
420
- const headingTokens = new Set(tokenize(heading));
421
- return queryTokens.filter((token) => headingTokens.has(token)).length * 4;
422
- }
423
- function identifierBoost(text, queryTokens) {
424
- const identifiers = Array.from(text.matchAll(/`([^`]+)`/g), (match) => tokenize(match[1] ?? "")).flat();
425
- if (!identifiers.length) {
426
- return 0;
427
- }
428
- const identifierSet = new Set(identifiers);
429
- return queryTokens.filter((token) => identifierSet.has(token)).length * 6;
430
- }
431
- function scoreText(text, tokens) {
432
- const lower = text.toLowerCase();
433
- return tokens.reduce((score, token) => score + countOccurrences(lower, token), 0);
434
- }
435
- function countOccurrences(text, token) {
436
- let count = 0;
437
- let index = text.indexOf(token);
438
- while (index !== -1) {
439
- count += 1;
440
- index = text.indexOf(token, index + token.length);
441
- }
442
- return count;
443
- }
444
- function normalizeTokenSequence(text) {
445
- const tokens = tokenize(text);
446
- return tokens.length >= 2 ? tokens.join(" ") : "";
447
- }
448
- function hasExactNormalizedPhrase(text, normalizedQueryPhrase) {
449
- return normalizedQueryPhrase !== "" && normalizeTokenSequence(text).includes(normalizedQueryPhrase);
450
- }
451
- function tokenize(query) {
452
- return query
453
- .toLowerCase()
454
- .split(/[^a-z0-9_./-]+/)
455
- .map((token) => token.trim())
456
- .filter((token) => token.length >= 2 && !STOPWORDS.has(token));
457
- }
458
- function tokenCountMap(tokens) {
459
- const counts = new Map();
460
- for (const token of tokens) {
461
- counts.set(token, (counts.get(token) ?? 0) + 1);
462
- }
463
- return counts;
464
- }
465
- function uniqueTokens(tokens) {
466
- return Array.from(new Set(tokens));
467
- }
468
- function boundedExcerpt(text) {
469
- const previewedLines = splitLines(text).map((line) => truncateToUtf8Bytes(line, LINE_PREVIEW_MAX_BYTES));
470
- return truncateToUtf8Bytes(previewedLines.join("\n"), QUERY_EXCERPT_MAX_BYTES);
471
- }
472
- function shouldSkipBroadDirectory(path) {
473
- const name = path.split(/[\\/]+/).at(-1) ?? path;
474
- return SKIP_DIRS.has(name);
475
- }
476
- function matchesGeneratedPathHint(path, hints) {
477
- if (hints.length === 0) {
478
- return false;
479
- }
480
- const normalizedPath = normalizeRelativePath(path);
481
- return hints.some((hint) => matchesSimpleGlob(normalizedPath, hint));
482
- }
483
- function matchesSimpleGlob(path, pattern) {
484
- if (!pattern) {
485
- return false;
486
- }
487
- const normalizedPattern = normalizeRelativePath(pattern);
488
- if (normalizedPattern.endsWith("/**")) {
489
- const prefix = normalizedPattern.slice(0, -3);
490
- return path === prefix || path.startsWith(`${prefix}/`);
491
- }
492
- const escaped = normalizedPattern
493
- .replace(/[.+^${}()|[\]\\]/g, "\\$&")
494
- .replace(/\*\*/g, ".*")
495
- .replace(/\*/g, "[^/]*");
496
- return new RegExp(`^${escaped}$`).test(path);
497
- }
498
- function shouldSkipBroadFile(path, size) {
499
- const name = path.split("/").at(-1)?.toLowerCase() ?? path.toLowerCase();
500
- if (isLockfile(name)) {
501
- return false;
502
- }
503
- if (hasBroadSkippedFileExtension(name)) {
504
- return true;
505
- }
506
- if (size > BROAD_SCAN_MAX_FILE_BYTES) {
507
- return true;
508
- }
509
- if (name.endsWith(".min.js") || name.endsWith(".min.css") || name.endsWith(".map")) {
510
- return true;
511
- }
512
- if (name.includes(".bundle.") || name.endsWith(".log")) {
513
- return true;
514
- }
515
- if ((name.endsWith(".html") || name.endsWith(".json")) && size > 64_000) {
516
- return true;
517
- }
518
- return false;
519
- }
520
- function hasBroadSkippedFileExtension(name) {
521
- for (const extension of BROAD_SKIP_FILE_EXTENSIONS) {
522
- if (name.endsWith(extension)) {
523
- return true;
524
- }
525
- }
526
- return false;
527
- }
528
- function isLockfile(name) {
529
- return (name === "package-lock.json" ||
530
- name === "npm-shrinkwrap.json" ||
531
- name === "pnpm-lock.yaml" ||
532
- name === "yarn.lock" ||
533
- name === "bun.lockb");
534
- }
535
- function truncateToUtf8Bytes(text, maxBytes) {
536
- if (byteLength(text) <= maxBytes) {
537
- return text;
538
- }
539
- const suffixBytes = byteLength(TRUNCATION_SUFFIX);
540
- const contentBytes = Math.max(0, maxBytes - suffixBytes);
541
- let truncated = Buffer.from(text, "utf8").subarray(0, contentBytes).toString("utf8");
542
- while (byteLength(truncated) > contentBytes) {
543
- truncated = truncated.slice(0, -1);
544
- }
545
- return `${truncated}${TRUNCATION_SUFFIX}`;
546
- }
547
- function splitLines(text) {
548
- return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n");
549
- }
550
- function byteLength(text) {
551
- return Buffer.byteLength(text, "utf8");
552
- }
553
- function isPathInsideRoot(root, absolutePath) {
554
- const relativePath = relative(root, absolutePath);
555
- return relativePath === "" || (!relativePath.startsWith("..") && !relativePath.startsWith("/") && !/^[A-Za-z]:/.test(relativePath));
556
- }
557
- function normalizeRelativePath(path) {
558
- return path.split(/[\\/]+/).filter(Boolean).join("/");
559
- }
560
- function hash(value) {
561
- return createHash("sha256").update(value).digest("hex");
562
- }
@@ -1,84 +0,0 @@
1
- import { type ExperimentalIndexLoadMode } from "./experiments/local-index.js";
2
- export interface RunIndexBenchmarksOptions {
3
- iterations?: number;
4
- generatedAt?: string;
5
- }
6
- export interface IndexBenchmarkReport {
7
- generatedAt: string;
8
- iterations: number;
9
- summary: IndexBenchmarkSummary;
10
- fixtures: IndexBenchmarkFixtureResult[];
11
- }
12
- export interface IndexBenchmarkSummary {
13
- fixtures: number;
14
- modeResults: number;
15
- scannerDefault: boolean;
16
- indexAdopted: boolean;
17
- scanner: IndexModeSummary;
18
- index: IndexModeSummary;
19
- generatedFalsePositiveCount: number;
20
- coldBuildMs: LatencySummary;
21
- warmQueryMs: LatencySummary;
22
- staleRefreshMs: LatencySummary;
23
- }
24
- export interface IndexModeSummary {
25
- passed: number;
26
- failed: number;
27
- pathCorrect: number;
28
- spanCorrect: number;
29
- excerptComplete: number;
30
- totalRawBytes: number;
31
- totalContextBytes: number;
32
- weightedContextReductionPercent: number;
33
- }
34
- export interface LatencySummary {
35
- p50: number;
36
- p95: number;
37
- }
38
- export interface IndexBenchmarkFixtureResult {
39
- id: string;
40
- title: string;
41
- expected: IndexBenchmarkExpected;
42
- results: IndexBenchmarkModeResult[];
43
- }
44
- export interface IndexBenchmarkExpected {
45
- path: string;
46
- lines?: string;
47
- requiredExcerpt: string[];
48
- }
49
- export interface IndexBenchmarkModeResult {
50
- mode: IndexBenchmarkMode;
51
- toolPathUsed: string;
52
- rawBytes: number;
53
- contextBytes: number;
54
- contextReductionPercent: number;
55
- latencyMs: LatencySummary;
56
- buildMs?: number;
57
- queryMs?: number;
58
- indexMode?: ExperimentalIndexLoadMode;
59
- actualPath?: string;
60
- actualLines?: string;
61
- excerpt: string;
62
- correctness: IndexCorrectnessResult;
63
- notes: string[];
64
- }
65
- export interface IndexCorrectnessResult {
66
- passed: boolean;
67
- pathCorrect: boolean;
68
- spanCorrect: boolean;
69
- excerptComplete: boolean;
70
- generatedFalsePositive: boolean;
71
- }
72
- type IndexBenchmarkMode = "scanner-default" | "index-cold" | "index-warm" | "index-stale-refresh";
73
- export declare function runIndexBenchmarks(options?: RunIndexBenchmarksOptions): Promise<IndexBenchmarkReport>;
74
- export declare function renderIndexBenchmarkReport(report: IndexBenchmarkReport): string;
75
- export declare function writeIndexBenchmarkReport(report: IndexBenchmarkReport, reportPath: string): Promise<void>;
76
- export declare function writeIndexBenchmarkJsonReport(report: IndexBenchmarkReport, reportPath: string): Promise<void>;
77
- export interface WriteIndexBenchmarkReportsOptions {
78
- jsonReportPath?: string | false;
79
- }
80
- export declare function writeIndexBenchmarkReports(report: IndexBenchmarkReport, markdownReportPath: string, options?: WriteIndexBenchmarkReportsOptions): Promise<{
81
- markdown: string;
82
- json?: string;
83
- }>;
84
- export {};