@vinaes/succ 1.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +87 -0
- package/README.md +588 -0
- package/agents/succ-checkpoint-manager.md +51 -0
- package/agents/succ-code-reviewer.md +181 -0
- package/agents/succ-context-optimizer.md +83 -0
- package/agents/succ-debug.md +224 -0
- package/agents/succ-decision-auditor.md +74 -0
- package/agents/succ-deep-search.md +41 -0
- package/agents/succ-diff-reviewer.md +123 -0
- package/agents/succ-explore.md +83 -0
- package/agents/succ-general.md +109 -0
- package/agents/succ-knowledge-indexer.md +45 -0
- package/agents/succ-knowledge-mapper.md +61 -0
- package/agents/succ-memory-curator.md +43 -0
- package/agents/succ-memory-health-monitor.md +55 -0
- package/agents/succ-pattern-detective.md +62 -0
- package/agents/succ-plan.md +172 -0
- package/agents/succ-quality-improvement-coach.md +63 -0
- package/agents/succ-readiness-improver.md +62 -0
- package/agents/succ-session-handoff-orchestrator.md +54 -0
- package/agents/succ-session-reviewer.md +46 -0
- package/agents/succ-style-tracker.md +73 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +749 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/agents-md.d.ts +16 -0
- package/dist/commands/agents-md.d.ts.map +1 -0
- package/dist/commands/agents-md.js +33 -0
- package/dist/commands/agents-md.js.map +1 -0
- package/dist/commands/analyze-agents.d.ts +20 -0
- package/dist/commands/analyze-agents.d.ts.map +1 -0
- package/dist/commands/analyze-agents.js +305 -0
- package/dist/commands/analyze-agents.js.map +1 -0
- package/dist/commands/analyze-helpers.d.ts +22 -0
- package/dist/commands/analyze-helpers.d.ts.map +1 -0
- package/dist/commands/analyze-helpers.js +38 -0
- package/dist/commands/analyze-helpers.js.map +1 -0
- package/dist/commands/analyze-profile.d.ts +53 -0
- package/dist/commands/analyze-profile.d.ts.map +1 -0
- package/dist/commands/analyze-profile.js +638 -0
- package/dist/commands/analyze-profile.js.map +1 -0
- package/dist/commands/analyze-recursive.d.ts +20 -0
- package/dist/commands/analyze-recursive.d.ts.map +1 -0
- package/dist/commands/analyze-recursive.js +326 -0
- package/dist/commands/analyze-recursive.js.map +1 -0
- package/dist/commands/analyze-utils.d.ts +83 -0
- package/dist/commands/analyze-utils.d.ts.map +1 -0
- package/dist/commands/analyze-utils.js +541 -0
- package/dist/commands/analyze-utils.js.map +1 -0
- package/dist/commands/analyze.d.ts +15 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +265 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/backfill.d.ts +22 -0
- package/dist/commands/backfill.d.ts.map +1 -0
- package/dist/commands/backfill.js +62 -0
- package/dist/commands/backfill.js.map +1 -0
- package/dist/commands/benchmark-quality.d.ts +18 -0
- package/dist/commands/benchmark-quality.d.ts.map +1 -0
- package/dist/commands/benchmark-quality.js +316 -0
- package/dist/commands/benchmark-quality.js.map +1 -0
- package/dist/commands/benchmark-sqlite-vec.d.ts +12 -0
- package/dist/commands/benchmark-sqlite-vec.d.ts.map +1 -0
- package/dist/commands/benchmark-sqlite-vec.js +281 -0
- package/dist/commands/benchmark-sqlite-vec.js.map +1 -0
- package/dist/commands/benchmark.d.ts +57 -0
- package/dist/commands/benchmark.d.ts.map +1 -0
- package/dist/commands/benchmark.js +682 -0
- package/dist/commands/benchmark.js.map +1 -0
- package/dist/commands/chat.d.ts +14 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +84 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/checkpoint.d.ts +27 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +181 -0
- package/dist/commands/checkpoint.js.map +1 -0
- package/dist/commands/clear.d.ts +9 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +31 -0
- package/dist/commands/clear.js.map +1 -0
- package/dist/commands/config.d.ts +26 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +247 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/consolidate.d.ts +21 -0
- package/dist/commands/consolidate.d.ts.map +1 -0
- package/dist/commands/consolidate.js +117 -0
- package/dist/commands/consolidate.js.map +1 -0
- package/dist/commands/daemon.d.ts +48 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +218 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/embedding.d.ts +26 -0
- package/dist/commands/embedding.d.ts.map +1 -0
- package/dist/commands/embedding.js +168 -0
- package/dist/commands/embedding.js.map +1 -0
- package/dist/commands/graph.d.ts +20 -0
- package/dist/commands/graph.d.ts.map +1 -0
- package/dist/commands/graph.js +128 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/index-code.d.ts +23 -0
- package/dist/commands/index-code.d.ts.map +1 -0
- package/dist/commands/index-code.js +218 -0
- package/dist/commands/index-code.js.map +1 -0
- package/dist/commands/index.d.ts +23 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +217 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init-templates.d.ts +21 -0
- package/dist/commands/init-templates.d.ts.map +1 -0
- package/dist/commands/init-templates.js +487 -0
- package/dist/commands/init-templates.js.map +1 -0
- package/dist/commands/init.d.ts +10 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +865 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/memories.d.ts +47 -0
- package/dist/commands/memories.d.ts.map +1 -0
- package/dist/commands/memories.js +597 -0
- package/dist/commands/memories.js.map +1 -0
- package/dist/commands/migrate.d.ts +19 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +154 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/prd.d.ts +46 -0
- package/dist/commands/prd.d.ts.map +1 -0
- package/dist/commands/prd.js +378 -0
- package/dist/commands/prd.js.map +1 -0
- package/dist/commands/precompute-context.d.ts +11 -0
- package/dist/commands/precompute-context.d.ts.map +1 -0
- package/dist/commands/precompute-context.js +12 -0
- package/dist/commands/precompute-context.js.map +1 -0
- package/dist/commands/progress.d.ts +16 -0
- package/dist/commands/progress.d.ts.map +1 -0
- package/dist/commands/progress.js +38 -0
- package/dist/commands/progress.js.map +1 -0
- package/dist/commands/reindex.d.ts +17 -0
- package/dist/commands/reindex.d.ts.map +1 -0
- package/dist/commands/reindex.js +83 -0
- package/dist/commands/reindex.js.map +1 -0
- package/dist/commands/retention.d.ts +19 -0
- package/dist/commands/retention.d.ts.map +1 -0
- package/dist/commands/retention.js +162 -0
- package/dist/commands/retention.js.map +1 -0
- package/dist/commands/score.d.ts +10 -0
- package/dist/commands/score.d.ts.map +1 -0
- package/dist/commands/score.js +28 -0
- package/dist/commands/score.js.map +1 -0
- package/dist/commands/search.d.ts +7 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +89 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/session-summary.d.ts +15 -0
- package/dist/commands/session-summary.d.ts.map +1 -0
- package/dist/commands/session-summary.js +16 -0
- package/dist/commands/session-summary.js.map +1 -0
- package/dist/commands/setup.d.ts +6 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +222 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/soul.d.ts +9 -0
- package/dist/commands/soul.d.ts.map +1 -0
- package/dist/commands/soul.js +256 -0
- package/dist/commands/soul.js.map +1 -0
- package/dist/commands/stats.d.ts +18 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +138 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +145 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/train-bpe.d.ts +8 -0
- package/dist/commands/train-bpe.d.ts.map +1 -0
- package/dist/commands/train-bpe.js +35 -0
- package/dist/commands/train-bpe.js.map +1 -0
- package/dist/commands/watch.d.ts +22 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +171 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/daemon/analyzer.d.ts +54 -0
- package/dist/daemon/analyzer.d.ts.map +1 -0
- package/dist/daemon/analyzer.js +362 -0
- package/dist/daemon/analyzer.js.map +1 -0
- package/dist/daemon/client.d.ts +87 -0
- package/dist/daemon/client.d.ts.map +1 -0
- package/dist/daemon/client.js +356 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/index.d.ts +12 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +12 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/service.d.ts +51 -0
- package/dist/daemon/service.d.ts.map +1 -0
- package/dist/daemon/service.js +1203 -0
- package/dist/daemon/service.js.map +1 -0
- package/dist/daemon/session-processor.d.ts +85 -0
- package/dist/daemon/session-processor.d.ts.map +1 -0
- package/dist/daemon/session-processor.js +571 -0
- package/dist/daemon/session-processor.js.map +1 -0
- package/dist/daemon/sessions.d.ts +62 -0
- package/dist/daemon/sessions.d.ts.map +1 -0
- package/dist/daemon/sessions.js +192 -0
- package/dist/daemon/sessions.js.map +1 -0
- package/dist/daemon/watcher.d.ts +52 -0
- package/dist/daemon/watcher.d.ts.map +1 -0
- package/dist/daemon/watcher.js +363 -0
- package/dist/daemon/watcher.js.map +1 -0
- package/dist/lib/agents-md-generator.d.ts +33 -0
- package/dist/lib/agents-md-generator.d.ts.map +1 -0
- package/dist/lib/agents-md-generator.js +156 -0
- package/dist/lib/agents-md-generator.js.map +1 -0
- package/dist/lib/ai-readiness.d.ts +132 -0
- package/dist/lib/ai-readiness.d.ts.map +1 -0
- package/dist/lib/ai-readiness.js +702 -0
- package/dist/lib/ai-readiness.js.map +1 -0
- package/dist/lib/analyze-state.d.ts +34 -0
- package/dist/lib/analyze-state.d.ts.map +1 -0
- package/dist/lib/analyze-state.js +106 -0
- package/dist/lib/analyze-state.js.map +1 -0
- package/dist/lib/benchmark.d.ts +250 -0
- package/dist/lib/benchmark.d.ts.map +1 -0
- package/dist/lib/benchmark.js +778 -0
- package/dist/lib/benchmark.js.map +1 -0
- package/dist/lib/bm25.d.ts +114 -0
- package/dist/lib/bm25.d.ts.map +1 -0
- package/dist/lib/bm25.js +727 -0
- package/dist/lib/bm25.js.map +1 -0
- package/dist/lib/bpe.d.ts +70 -0
- package/dist/lib/bpe.d.ts.map +1 -0
- package/dist/lib/bpe.js +270 -0
- package/dist/lib/bpe.js.map +1 -0
- package/dist/lib/checkpoint.d.ts +124 -0
- package/dist/lib/checkpoint.d.ts.map +1 -0
- package/dist/lib/checkpoint.js +321 -0
- package/dist/lib/checkpoint.js.map +1 -0
- package/dist/lib/chunker.d.ts +47 -0
- package/dist/lib/chunker.d.ts.map +1 -0
- package/dist/lib/chunker.js +358 -0
- package/dist/lib/chunker.js.map +1 -0
- package/dist/lib/claude-ws-transport.d.ts +76 -0
- package/dist/lib/claude-ws-transport.d.ts.map +1 -0
- package/dist/lib/claude-ws-transport.js +487 -0
- package/dist/lib/claude-ws-transport.js.map +1 -0
- package/dist/lib/compact-briefing.d.ts +22 -0
- package/dist/lib/compact-briefing.d.ts.map +1 -0
- package/dist/lib/compact-briefing.js +180 -0
- package/dist/lib/compact-briefing.js.map +1 -0
- package/dist/lib/config-defaults.d.ts +41 -0
- package/dist/lib/config-defaults.d.ts.map +1 -0
- package/dist/lib/config-defaults.js +99 -0
- package/dist/lib/config-defaults.js.map +1 -0
- package/dist/lib/config-display.d.ts +16 -0
- package/dist/lib/config-display.d.ts.map +1 -0
- package/dist/lib/config-display.js +408 -0
- package/dist/lib/config-display.js.map +1 -0
- package/dist/lib/config-types.d.ts +601 -0
- package/dist/lib/config-types.d.ts.map +1 -0
- package/dist/lib/config-types.js +7 -0
- package/dist/lib/config-types.js.map +1 -0
- package/dist/lib/config-validation.d.ts +19 -0
- package/dist/lib/config-validation.d.ts.map +1 -0
- package/dist/lib/config-validation.js +136 -0
- package/dist/lib/config-validation.js.map +1 -0
- package/dist/lib/config.d.ts +143 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +689 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/consolidate.d.ts +115 -0
- package/dist/lib/consolidate.d.ts.map +1 -0
- package/dist/lib/consolidate.js +600 -0
- package/dist/lib/consolidate.js.map +1 -0
- package/dist/lib/db/bm25-indexes.d.ts +58 -0
- package/dist/lib/db/bm25-indexes.d.ts.map +1 -0
- package/dist/lib/db/bm25-indexes.js +333 -0
- package/dist/lib/db/bm25-indexes.js.map +1 -0
- package/dist/lib/db/bpe.d.ts +18 -0
- package/dist/lib/db/bpe.d.ts.map +1 -0
- package/dist/lib/db/bpe.js +44 -0
- package/dist/lib/db/bpe.js.map +1 -0
- package/dist/lib/db/connection.d.ts +47 -0
- package/dist/lib/db/connection.d.ts.map +1 -0
- package/dist/lib/db/connection.js +114 -0
- package/dist/lib/db/connection.js.map +1 -0
- package/dist/lib/db/documents.d.ts +58 -0
- package/dist/lib/db/documents.d.ts.map +1 -0
- package/dist/lib/db/documents.js +374 -0
- package/dist/lib/db/documents.js.map +1 -0
- package/dist/lib/db/file-hash.d.ts +26 -0
- package/dist/lib/db/file-hash.d.ts.map +1 -0
- package/dist/lib/db/file-hash.js +56 -0
- package/dist/lib/db/file-hash.js.map +1 -0
- package/dist/lib/db/global-memories.d.ts +62 -0
- package/dist/lib/db/global-memories.d.ts.map +1 -0
- package/dist/lib/db/global-memories.js +173 -0
- package/dist/lib/db/global-memories.js.map +1 -0
- package/dist/lib/db/graph.d.ts +163 -0
- package/dist/lib/db/graph.d.ts.map +1 -0
- package/dist/lib/db/graph.js +488 -0
- package/dist/lib/db/graph.js.map +1 -0
- package/dist/lib/db/helpers.d.ts +13 -0
- package/dist/lib/db/helpers.d.ts.map +1 -0
- package/dist/lib/db/helpers.js +21 -0
- package/dist/lib/db/helpers.js.map +1 -0
- package/dist/lib/db/hybrid-search.d.ts +64 -0
- package/dist/lib/db/hybrid-search.d.ts.map +1 -0
- package/dist/lib/db/hybrid-search.js +549 -0
- package/dist/lib/db/hybrid-search.js.map +1 -0
- package/dist/lib/db/index.d.ts +23 -0
- package/dist/lib/db/index.d.ts.map +1 -0
- package/dist/lib/db/index.js +23 -0
- package/dist/lib/db/index.js.map +1 -0
- package/dist/lib/db/memories.d.ts +174 -0
- package/dist/lib/db/memories.d.ts.map +1 -0
- package/dist/lib/db/memories.js +866 -0
- package/dist/lib/db/memories.js.map +1 -0
- package/dist/lib/db/retention.d.ts +64 -0
- package/dist/lib/db/retention.d.ts.map +1 -0
- package/dist/lib/db/retention.js +115 -0
- package/dist/lib/db/retention.js.map +1 -0
- package/dist/lib/db/schema.d.ts +29 -0
- package/dist/lib/db/schema.d.ts.map +1 -0
- package/dist/lib/db/schema.js +832 -0
- package/dist/lib/db/schema.js.map +1 -0
- package/dist/lib/db/skills.d.ts +65 -0
- package/dist/lib/db/skills.d.ts.map +1 -0
- package/dist/lib/db/skills.js +119 -0
- package/dist/lib/db/skills.js.map +1 -0
- package/dist/lib/db/token-frequency.d.ts +34 -0
- package/dist/lib/db/token-frequency.d.ts.map +1 -0
- package/dist/lib/db/token-frequency.js +92 -0
- package/dist/lib/db/token-frequency.js.map +1 -0
- package/dist/lib/db/token-stats.d.ts +43 -0
- package/dist/lib/db/token-stats.d.ts.map +1 -0
- package/dist/lib/db/token-stats.js +59 -0
- package/dist/lib/db/token-stats.js.map +1 -0
- package/dist/lib/db/types.d.ts +57 -0
- package/dist/lib/db/types.d.ts.map +1 -0
- package/dist/lib/db/types.js +5 -0
- package/dist/lib/db/types.js.map +1 -0
- package/dist/lib/db/web-search-history.d.ts +22 -0
- package/dist/lib/db/web-search-history.d.ts.map +1 -0
- package/dist/lib/db/web-search-history.js +107 -0
- package/dist/lib/db/web-search-history.js.map +1 -0
- package/dist/lib/debug/state.d.ts +17 -0
- package/dist/lib/debug/state.d.ts.map +1 -0
- package/dist/lib/debug/state.js +131 -0
- package/dist/lib/debug/state.js.map +1 -0
- package/dist/lib/debug/types.d.ts +74 -0
- package/dist/lib/debug/types.d.ts.map +1 -0
- package/dist/lib/debug/types.js +85 -0
- package/dist/lib/debug/types.js.map +1 -0
- package/dist/lib/embedding-pool.d.ts +37 -0
- package/dist/lib/embedding-pool.d.ts.map +1 -0
- package/dist/lib/embedding-pool.js +159 -0
- package/dist/lib/embedding-pool.js.map +1 -0
- package/dist/lib/embedding-worker.d.ts +7 -0
- package/dist/lib/embedding-worker.d.ts.map +1 -0
- package/dist/lib/embedding-worker.js +49 -0
- package/dist/lib/embedding-worker.js.map +1 -0
- package/dist/lib/embeddings.d.ts +54 -0
- package/dist/lib/embeddings.d.ts.map +1 -0
- package/dist/lib/embeddings.js +437 -0
- package/dist/lib/embeddings.js.map +1 -0
- package/dist/lib/errors.d.ts +40 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +66 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/fault-logger.d.ts +35 -0
- package/dist/lib/fault-logger.d.ts.map +1 -0
- package/dist/lib/fault-logger.js +182 -0
- package/dist/lib/fault-logger.js.map +1 -0
- package/dist/lib/graph/centrality.d.ts +34 -0
- package/dist/lib/graph/centrality.d.ts.map +1 -0
- package/dist/lib/graph/centrality.js +76 -0
- package/dist/lib/graph/centrality.js.map +1 -0
- package/dist/lib/graph/cleanup.d.ts +36 -0
- package/dist/lib/graph/cleanup.d.ts.map +1 -0
- package/dist/lib/graph/cleanup.js +96 -0
- package/dist/lib/graph/cleanup.js.map +1 -0
- package/dist/lib/graph/community-detection.d.ts +61 -0
- package/dist/lib/graph/community-detection.d.ts.map +1 -0
- package/dist/lib/graph/community-detection.js +218 -0
- package/dist/lib/graph/community-detection.js.map +1 -0
- package/dist/lib/graph/contextual-proximity.d.ts +41 -0
- package/dist/lib/graph/contextual-proximity.d.ts.map +1 -0
- package/dist/lib/graph/contextual-proximity.js +125 -0
- package/dist/lib/graph/contextual-proximity.js.map +1 -0
- package/dist/lib/graph/llm-relations.d.ts +54 -0
- package/dist/lib/graph/llm-relations.d.ts.map +1 -0
- package/dist/lib/graph/llm-relations.js +265 -0
- package/dist/lib/graph/llm-relations.js.map +1 -0
- package/dist/lib/graph-export.d.ts +13 -0
- package/dist/lib/graph-export.d.ts.map +1 -0
- package/dist/lib/graph-export.js +637 -0
- package/dist/lib/graph-export.js.map +1 -0
- package/dist/lib/graph-scheduler.d.ts +7 -0
- package/dist/lib/graph-scheduler.d.ts.map +1 -0
- package/dist/lib/graph-scheduler.js +21 -0
- package/dist/lib/graph-scheduler.js.map +1 -0
- package/dist/lib/indexer.d.ts +36 -0
- package/dist/lib/indexer.d.ts.map +1 -0
- package/dist/lib/indexer.js +226 -0
- package/dist/lib/indexer.js.map +1 -0
- package/dist/lib/learning-delta.d.ts +35 -0
- package/dist/lib/learning-delta.d.ts.map +1 -0
- package/dist/lib/learning-delta.js +53 -0
- package/dist/lib/learning-delta.js.map +1 -0
- package/dist/lib/llm.d.ts +118 -0
- package/dist/lib/llm.d.ts.map +1 -0
- package/dist/lib/llm.js +439 -0
- package/dist/lib/llm.js.map +1 -0
- package/dist/lib/lock.d.ts +27 -0
- package/dist/lib/lock.d.ts.map +1 -0
- package/dist/lib/lock.js +143 -0
- package/dist/lib/lock.js.map +1 -0
- package/dist/lib/md-fetch.d.ts +61 -0
- package/dist/lib/md-fetch.d.ts.map +1 -0
- package/dist/lib/md-fetch.js +141 -0
- package/dist/lib/md-fetch.js.map +1 -0
- package/dist/lib/mmr.d.ts +29 -0
- package/dist/lib/mmr.d.ts.map +1 -0
- package/dist/lib/mmr.js +89 -0
- package/dist/lib/mmr.js.map +1 -0
- package/dist/lib/onboarding/ai-chat.d.ts +11 -0
- package/dist/lib/onboarding/ai-chat.d.ts.map +1 -0
- package/dist/lib/onboarding/ai-chat.js +85 -0
- package/dist/lib/onboarding/ai-chat.js.map +1 -0
- package/dist/lib/onboarding/index.d.ts +7 -0
- package/dist/lib/onboarding/index.d.ts.map +1 -0
- package/dist/lib/onboarding/index.js +7 -0
- package/dist/lib/onboarding/index.js.map +1 -0
- package/dist/lib/onboarding/wizard.d.ts +11 -0
- package/dist/lib/onboarding/wizard.d.ts.map +1 -0
- package/dist/lib/onboarding/wizard.js +104 -0
- package/dist/lib/onboarding/wizard.js.map +1 -0
- package/dist/lib/ort-provider.d.ts +27 -0
- package/dist/lib/ort-provider.d.ts.map +1 -0
- package/dist/lib/ort-provider.js +83 -0
- package/dist/lib/ort-provider.js.map +1 -0
- package/dist/lib/ort-session.d.ts +32 -0
- package/dist/lib/ort-session.d.ts.map +1 -0
- package/dist/lib/ort-session.js +227 -0
- package/dist/lib/ort-session.js.map +1 -0
- package/dist/lib/patterns.d.ts +43 -0
- package/dist/lib/patterns.d.ts.map +1 -0
- package/dist/lib/patterns.js +395 -0
- package/dist/lib/patterns.js.map +1 -0
- package/dist/lib/prd/codebase-context.d.ts +27 -0
- package/dist/lib/prd/codebase-context.d.ts.map +1 -0
- package/dist/lib/prd/codebase-context.js +420 -0
- package/dist/lib/prd/codebase-context.js.map +1 -0
- package/dist/lib/prd/context.d.ts +24 -0
- package/dist/lib/prd/context.d.ts.map +1 -0
- package/dist/lib/prd/context.js +68 -0
- package/dist/lib/prd/context.js.map +1 -0
- package/dist/lib/prd/executor.d.ts +52 -0
- package/dist/lib/prd/executor.d.ts.map +1 -0
- package/dist/lib/prd/executor.js +154 -0
- package/dist/lib/prd/executor.js.map +1 -0
- package/dist/lib/prd/export.d.ts +40 -0
- package/dist/lib/prd/export.d.ts.map +1 -0
- package/dist/lib/prd/export.js +511 -0
- package/dist/lib/prd/export.js.map +1 -0
- package/dist/lib/prd/gates.d.ts +30 -0
- package/dist/lib/prd/gates.d.ts.map +1 -0
- package/dist/lib/prd/gates.js +100 -0
- package/dist/lib/prd/gates.js.map +1 -0
- package/dist/lib/prd/generate.d.ts +56 -0
- package/dist/lib/prd/generate.d.ts.map +1 -0
- package/dist/lib/prd/generate.js +357 -0
- package/dist/lib/prd/generate.js.map +1 -0
- package/dist/lib/prd/parse.d.ts +21 -0
- package/dist/lib/prd/parse.d.ts.map +1 -0
- package/dist/lib/prd/parse.js +270 -0
- package/dist/lib/prd/parse.js.map +1 -0
- package/dist/lib/prd/prompt-builder.d.ts +18 -0
- package/dist/lib/prd/prompt-builder.d.ts.map +1 -0
- package/dist/lib/prd/prompt-builder.js +61 -0
- package/dist/lib/prd/prompt-builder.js.map +1 -0
- package/dist/lib/prd/runner.d.ts +54 -0
- package/dist/lib/prd/runner.d.ts.map +1 -0
- package/dist/lib/prd/runner.js +563 -0
- package/dist/lib/prd/runner.js.map +1 -0
- package/dist/lib/prd/scheduler.d.ts +27 -0
- package/dist/lib/prd/scheduler.d.ts.map +1 -0
- package/dist/lib/prd/scheduler.js +113 -0
- package/dist/lib/prd/scheduler.js.map +1 -0
- package/dist/lib/prd/state.d.ts +77 -0
- package/dist/lib/prd/state.d.ts.map +1 -0
- package/dist/lib/prd/state.js +253 -0
- package/dist/lib/prd/state.js.map +1 -0
- package/dist/lib/prd/team-runner.d.ts +48 -0
- package/dist/lib/prd/team-runner.d.ts.map +1 -0
- package/dist/lib/prd/team-runner.js +261 -0
- package/dist/lib/prd/team-runner.js.map +1 -0
- package/dist/lib/prd/types.d.ts +169 -0
- package/dist/lib/prd/types.d.ts.map +1 -0
- package/dist/lib/prd/types.js +143 -0
- package/dist/lib/prd/types.js.map +1 -0
- package/dist/lib/prd/worktree.d.ts +54 -0
- package/dist/lib/prd/worktree.d.ts.map +1 -0
- package/dist/lib/prd/worktree.js +255 -0
- package/dist/lib/prd/worktree.js.map +1 -0
- package/dist/lib/precompute-context.d.ts +48 -0
- package/dist/lib/precompute-context.d.ts.map +1 -0
- package/dist/lib/precompute-context.js +265 -0
- package/dist/lib/precompute-context.js.map +1 -0
- package/dist/lib/pricing.d.ts +60 -0
- package/dist/lib/pricing.d.ts.map +1 -0
- package/dist/lib/pricing.js +258 -0
- package/dist/lib/pricing.js.map +1 -0
- package/dist/lib/process-registry.d.ts +30 -0
- package/dist/lib/process-registry.d.ts.map +1 -0
- package/dist/lib/process-registry.js +92 -0
- package/dist/lib/process-registry.js.map +1 -0
- package/dist/lib/progress-log.d.ts +44 -0
- package/dist/lib/progress-log.d.ts.map +1 -0
- package/dist/lib/progress-log.js +58 -0
- package/dist/lib/progress-log.js.map +1 -0
- package/dist/lib/public-api.d.ts +56 -0
- package/dist/lib/public-api.d.ts.map +1 -0
- package/dist/lib/public-api.js +63 -0
- package/dist/lib/public-api.js.map +1 -0
- package/dist/lib/quality.d.ts +66 -0
- package/dist/lib/quality.d.ts.map +1 -0
- package/dist/lib/quality.js +486 -0
- package/dist/lib/quality.js.map +1 -0
- package/dist/lib/query-expansion.d.ts +16 -0
- package/dist/lib/query-expansion.d.ts.map +1 -0
- package/dist/lib/query-expansion.js +53 -0
- package/dist/lib/query-expansion.js.map +1 -0
- package/dist/lib/readiness.d.ts +35 -0
- package/dist/lib/readiness.d.ts.map +1 -0
- package/dist/lib/readiness.js +142 -0
- package/dist/lib/readiness.js.map +1 -0
- package/dist/lib/reference-embeddings.d.ts +39 -0
- package/dist/lib/reference-embeddings.d.ts.map +1 -0
- package/dist/lib/reference-embeddings.js +95 -0
- package/dist/lib/reference-embeddings.js.map +1 -0
- package/dist/lib/reflection-synthesizer.d.ts +27 -0
- package/dist/lib/reflection-synthesizer.d.ts.map +1 -0
- package/dist/lib/reflection-synthesizer.js +149 -0
- package/dist/lib/reflection-synthesizer.js.map +1 -0
- package/dist/lib/retention.d.ts +105 -0
- package/dist/lib/retention.d.ts.map +1 -0
- package/dist/lib/retention.js +246 -0
- package/dist/lib/retention.js.map +1 -0
- package/dist/lib/sensitive-filter.d.ts +34 -0
- package/dist/lib/sensitive-filter.d.ts.map +1 -0
- package/dist/lib/sensitive-filter.js +344 -0
- package/dist/lib/sensitive-filter.js.map +1 -0
- package/dist/lib/session-observations.d.ts +59 -0
- package/dist/lib/session-observations.d.ts.map +1 -0
- package/dist/lib/session-observations.js +128 -0
- package/dist/lib/session-observations.js.map +1 -0
- package/dist/lib/session-summary.d.ts +65 -0
- package/dist/lib/session-summary.d.ts.map +1 -0
- package/dist/lib/session-summary.js +344 -0
- package/dist/lib/session-summary.js.map +1 -0
- package/dist/lib/similarity-worker.d.ts +7 -0
- package/dist/lib/similarity-worker.d.ts.map +1 -0
- package/dist/lib/similarity-worker.js +36 -0
- package/dist/lib/similarity-worker.js.map +1 -0
- package/dist/lib/skills.d.ts +78 -0
- package/dist/lib/skills.d.ts.map +1 -0
- package/dist/lib/skills.js +439 -0
- package/dist/lib/skills.js.map +1 -0
- package/dist/lib/skyll-client.d.ts +59 -0
- package/dist/lib/skyll-client.d.ts.map +1 -0
- package/dist/lib/skyll-client.js +257 -0
- package/dist/lib/skyll-client.js.map +1 -0
- package/dist/lib/storage/backends/interface.d.ts +383 -0
- package/dist/lib/storage/backends/interface.d.ts.map +1 -0
- package/dist/lib/storage/backends/interface.js +12 -0
- package/dist/lib/storage/backends/interface.js.map +1 -0
- package/dist/lib/storage/backends/postgresql.d.ts +454 -0
- package/dist/lib/storage/backends/postgresql.d.ts.map +1 -0
- package/dist/lib/storage/backends/postgresql.js +2528 -0
- package/dist/lib/storage/backends/postgresql.js.map +1 -0
- package/dist/lib/storage/benchmark.d.ts +16 -0
- package/dist/lib/storage/benchmark.d.ts.map +1 -0
- package/dist/lib/storage/benchmark.js +219 -0
- package/dist/lib/storage/benchmark.js.map +1 -0
- package/dist/lib/storage/dispatcher-export.d.ts +108 -0
- package/dist/lib/storage/dispatcher-export.d.ts.map +1 -0
- package/dist/lib/storage/dispatcher-export.js +593 -0
- package/dist/lib/storage/dispatcher-export.js.map +1 -0
- package/dist/lib/storage/dispatcher.d.ts +468 -0
- package/dist/lib/storage/dispatcher.d.ts.map +1 -0
- package/dist/lib/storage/dispatcher.js +1926 -0
- package/dist/lib/storage/dispatcher.js.map +1 -0
- package/dist/lib/storage/index.d.ts +481 -0
- package/dist/lib/storage/index.d.ts.map +1 -0
- package/dist/lib/storage/index.js +727 -0
- package/dist/lib/storage/index.js.map +1 -0
- package/dist/lib/storage/migration/export-import.d.ts +133 -0
- package/dist/lib/storage/migration/export-import.d.ts.map +1 -0
- package/dist/lib/storage/migration/export-import.js +264 -0
- package/dist/lib/storage/migration/export-import.js.map +1 -0
- package/dist/lib/storage/types.d.ts +313 -0
- package/dist/lib/storage/types.d.ts.map +1 -0
- package/dist/lib/storage/types.js +30 -0
- package/dist/lib/storage/types.js.map +1 -0
- package/dist/lib/storage/vector/interface.d.ts +89 -0
- package/dist/lib/storage/vector/interface.d.ts.map +1 -0
- package/dist/lib/storage/vector/interface.js +10 -0
- package/dist/lib/storage/vector/interface.js.map +1 -0
- package/dist/lib/storage/vector/qdrant.d.ts +221 -0
- package/dist/lib/storage/vector/qdrant.d.ts.map +1 -0
- package/dist/lib/storage/vector/qdrant.js +880 -0
- package/dist/lib/storage/vector/qdrant.js.map +1 -0
- package/dist/lib/supersession.d.ts +26 -0
- package/dist/lib/supersession.d.ts.map +1 -0
- package/dist/lib/supersession.js +97 -0
- package/dist/lib/supersession.js.map +1 -0
- package/dist/lib/temporal.d.ts +140 -0
- package/dist/lib/temporal.d.ts.map +1 -0
- package/dist/lib/temporal.js +303 -0
- package/dist/lib/temporal.js.map +1 -0
- package/dist/lib/token-budget.d.ts +79 -0
- package/dist/lib/token-budget.d.ts.map +1 -0
- package/dist/lib/token-budget.js +146 -0
- package/dist/lib/token-budget.js.map +1 -0
- package/dist/lib/token-counter.d.ts +27 -0
- package/dist/lib/token-counter.d.ts.map +1 -0
- package/dist/lib/token-counter.js +52 -0
- package/dist/lib/token-counter.js.map +1 -0
- package/dist/lib/tree-sitter/chunker-ts.d.ts +24 -0
- package/dist/lib/tree-sitter/chunker-ts.d.ts.map +1 -0
- package/dist/lib/tree-sitter/chunker-ts.js +206 -0
- package/dist/lib/tree-sitter/chunker-ts.js.map +1 -0
- package/dist/lib/tree-sitter/extractor.d.ts +43 -0
- package/dist/lib/tree-sitter/extractor.d.ts.map +1 -0
- package/dist/lib/tree-sitter/extractor.js +297 -0
- package/dist/lib/tree-sitter/extractor.js.map +1 -0
- package/dist/lib/tree-sitter/index.d.ts +13 -0
- package/dist/lib/tree-sitter/index.d.ts.map +1 -0
- package/dist/lib/tree-sitter/index.js +14 -0
- package/dist/lib/tree-sitter/index.js.map +1 -0
- package/dist/lib/tree-sitter/parser.d.ts +70 -0
- package/dist/lib/tree-sitter/parser.d.ts.map +1 -0
- package/dist/lib/tree-sitter/parser.js +354 -0
- package/dist/lib/tree-sitter/parser.js.map +1 -0
- package/dist/lib/tree-sitter/public.d.ts +28 -0
- package/dist/lib/tree-sitter/public.d.ts.map +1 -0
- package/dist/lib/tree-sitter/public.js +50 -0
- package/dist/lib/tree-sitter/public.js.map +1 -0
- package/dist/lib/tree-sitter/queries.d.ts +28 -0
- package/dist/lib/tree-sitter/queries.d.ts.map +1 -0
- package/dist/lib/tree-sitter/queries.js +383 -0
- package/dist/lib/tree-sitter/queries.js.map +1 -0
- package/dist/lib/tree-sitter/types.d.ts +69 -0
- package/dist/lib/tree-sitter/types.d.ts.map +1 -0
- package/dist/lib/tree-sitter/types.js +131 -0
- package/dist/lib/tree-sitter/types.js.map +1 -0
- package/dist/lib/working-memory-pipeline.d.ts +118 -0
- package/dist/lib/working-memory-pipeline.d.ts.map +1 -0
- package/dist/lib/working-memory-pipeline.js +344 -0
- package/dist/lib/working-memory-pipeline.js.map +1 -0
- package/dist/mcp/helpers.d.ts +44 -0
- package/dist/mcp/helpers.d.ts.map +1 -0
- package/dist/mcp/helpers.js +244 -0
- package/dist/mcp/helpers.js.map +1 -0
- package/dist/mcp/index.d.ts +10 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +15 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/resources.d.ts +12 -0
- package/dist/mcp/resources.d.ts.map +1 -0
- package/dist/mcp/resources.js +136 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +22 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +131 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools/config.d.ts +10 -0
- package/dist/mcp/tools/config.d.ts.map +1 -0
- package/dist/mcp/tools/config.js +236 -0
- package/dist/mcp/tools/config.js.map +1 -0
- package/dist/mcp/tools/dead-end.d.ts +9 -0
- package/dist/mcp/tools/dead-end.d.ts.map +1 -0
- package/dist/mcp/tools/dead-end.js +137 -0
- package/dist/mcp/tools/dead-end.js.map +1 -0
- package/dist/mcp/tools/debug.d.ts +9 -0
- package/dist/mcp/tools/debug.d.ts.map +1 -0
- package/dist/mcp/tools/debug.js +387 -0
- package/dist/mcp/tools/debug.js.map +1 -0
- package/dist/mcp/tools/graph.d.ts +9 -0
- package/dist/mcp/tools/graph.d.ts.map +1 -0
- package/dist/mcp/tools/graph.js +337 -0
- package/dist/mcp/tools/graph.js.map +1 -0
- package/dist/mcp/tools/indexing.d.ts +12 -0
- package/dist/mcp/tools/indexing.d.ts.map +1 -0
- package/dist/mcp/tools/indexing.js +289 -0
- package/dist/mcp/tools/indexing.js.map +1 -0
- package/dist/mcp/tools/memory.d.ts +14 -0
- package/dist/mcp/tools/memory.d.ts.map +1 -0
- package/dist/mcp/tools/memory.js +1170 -0
- package/dist/mcp/tools/memory.js.map +1 -0
- package/dist/mcp/tools/prd.d.ts +12 -0
- package/dist/mcp/tools/prd.d.ts.map +1 -0
- package/dist/mcp/tools/prd.js +276 -0
- package/dist/mcp/tools/prd.js.map +1 -0
- package/dist/mcp/tools/search.d.ts +9 -0
- package/dist/mcp/tools/search.d.ts.map +1 -0
- package/dist/mcp/tools/search.js +279 -0
- package/dist/mcp/tools/search.js.map +1 -0
- package/dist/mcp/tools/status.d.ts +10 -0
- package/dist/mcp/tools/status.d.ts.map +1 -0
- package/dist/mcp/tools/status.js +296 -0
- package/dist/mcp/tools/status.js.map +1 -0
- package/dist/mcp/tools/web-fetch.d.ts +10 -0
- package/dist/mcp/tools/web-fetch.d.ts.map +1 -0
- package/dist/mcp/tools/web-fetch.js +107 -0
- package/dist/mcp/tools/web-fetch.js.map +1 -0
- package/dist/mcp/tools/web-search.d.ts +14 -0
- package/dist/mcp/tools/web-search.d.ts.map +1 -0
- package/dist/mcp/tools/web-search.js +427 -0
- package/dist/mcp/tools/web-search.js.map +1 -0
- package/dist/mcp/types.d.ts +16 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +5 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp-server.d.ts +9 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +9 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/prompts/analyze.d.ts +21 -0
- package/dist/prompts/analyze.d.ts.map +1 -0
- package/dist/prompts/analyze.js +27 -0
- package/dist/prompts/analyze.js.map +1 -0
- package/dist/prompts/briefing.d.ts +27 -0
- package/dist/prompts/briefing.d.ts.map +1 -0
- package/dist/prompts/briefing.js +123 -0
- package/dist/prompts/briefing.js.map +1 -0
- package/dist/prompts/chat.d.ts +8 -0
- package/dist/prompts/chat.d.ts.map +1 -0
- package/dist/prompts/chat.js +39 -0
- package/dist/prompts/chat.js.map +1 -0
- package/dist/prompts/daemon.d.ts +16 -0
- package/dist/prompts/daemon.d.ts.map +1 -0
- package/dist/prompts/daemon.js +46 -0
- package/dist/prompts/daemon.js.map +1 -0
- package/dist/prompts/extraction.d.ts +13 -0
- package/dist/prompts/extraction.d.ts.map +1 -0
- package/dist/prompts/extraction.js +93 -0
- package/dist/prompts/extraction.js.map +1 -0
- package/dist/prompts/index.d.ts +17 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +27 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/memory.d.ts +11 -0
- package/dist/prompts/memory.d.ts.map +1 -0
- package/dist/prompts/memory.js +23 -0
- package/dist/prompts/memory.js.map +1 -0
- package/dist/prompts/onboarding.d.ts +16 -0
- package/dist/prompts/onboarding.d.ts.map +1 -0
- package/dist/prompts/onboarding.js +183 -0
- package/dist/prompts/onboarding.js.map +1 -0
- package/dist/prompts/prd.d.ts +12 -0
- package/dist/prompts/prd.d.ts.map +1 -0
- package/dist/prompts/prd.js +211 -0
- package/dist/prompts/prd.js.map +1 -0
- package/dist/prompts/quality.d.ts +11 -0
- package/dist/prompts/quality.d.ts.map +1 -0
- package/dist/prompts/quality.js +11 -0
- package/dist/prompts/quality.js.map +1 -0
- package/dist/prompts/skills.d.ts +16 -0
- package/dist/prompts/skills.d.ts.map +1 -0
- package/dist/prompts/skills.js +30 -0
- package/dist/prompts/skills.js.map +1 -0
- package/hooks/succ-post-tool.cjs +227 -0
- package/hooks/succ-pre-tool.cjs +312 -0
- package/hooks/succ-session-end.cjs +85 -0
- package/hooks/succ-session-start.cjs +618 -0
- package/hooks/succ-stop-reflection.cjs +87 -0
- package/hooks/succ-user-prompt.cjs +220 -0
- package/package.json +128 -0
package/dist/lib/bm25.js
ADDED
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BM25 + Hybrid Search
|
|
3
|
+
*
|
|
4
|
+
* Two modes:
|
|
5
|
+
* - Code search: exact tokenizer for identifiers (camelCase, snake_case)
|
|
6
|
+
* - Docs search: stemming for natural language
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - RRF (Reciprocal Rank Fusion) for combining results
|
|
10
|
+
* - k1=1.3, b=0.75 - optimal BM25 parameters
|
|
11
|
+
* - Exact match boost for identifier searches
|
|
12
|
+
*/
|
|
13
|
+
// BM25 parameters (tuned for code/docs)
|
|
14
|
+
const K1 = 1.3; // Term frequency saturation (1.2-1.5 optimal)
|
|
15
|
+
const B = 0.75; // Length normalization
|
|
16
|
+
const RRF_K = 60; // RRF constant (standard value)
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Tokenizers
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Code-aware tokenizer
|
|
22
|
+
* Handles all common naming conventions:
|
|
23
|
+
* - camelCase: getUserName -> get, user, name
|
|
24
|
+
* - PascalCase: GetUserName -> get, user, name
|
|
25
|
+
* - snake_case: get_user_name -> get, user, name
|
|
26
|
+
* - SCREAMING_SNAKE: GET_USER_NAME -> get, user, name
|
|
27
|
+
* - kebab-case: get-user-name -> get, user, name
|
|
28
|
+
* - dot.case: get.user.name -> get, user, name
|
|
29
|
+
* - path/case: src/utils/helper -> src, utils, helper
|
|
30
|
+
* - Train-Case: Get-User-Name -> get, user, name
|
|
31
|
+
* - colon::case: std::vector -> std, vector
|
|
32
|
+
* - number suffixes: user2, v3 -> user, 2, v, 3
|
|
33
|
+
*
|
|
34
|
+
* Preserves original identifiers for exact match
|
|
35
|
+
*/
|
|
36
|
+
export function tokenizeCode(text) {
|
|
37
|
+
// 1. Split camelCase/PascalCase: useGlobalHooks -> use Global Hooks
|
|
38
|
+
let processed = text.replace(/([a-z])([A-Z])/g, '$1 $2');
|
|
39
|
+
// Handle acronyms: HTMLParser -> HTML Parser
|
|
40
|
+
processed = processed.replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2');
|
|
41
|
+
// 2. Split on common separators: _ - . / \ : @
|
|
42
|
+
processed = processed.replace(/[_\-./\\:@]+/g, ' ');
|
|
43
|
+
// 3. Split numbers from letters: user2 -> user 2, v3 -> v 3
|
|
44
|
+
processed = processed.replace(/([a-zA-Z])(\d)/g, '$1 $2');
|
|
45
|
+
processed = processed.replace(/(\d)([a-zA-Z])/g, '$1 $2');
|
|
46
|
+
// 4. Keep alphanumeric, remove rest
|
|
47
|
+
processed = processed.replace(/[^a-zA-Z0-9\s]/g, ' ');
|
|
48
|
+
// 5. Lowercase and split
|
|
49
|
+
const words = processed
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.split(/\s+/)
|
|
52
|
+
.filter((t) => t.length > 0);
|
|
53
|
+
// 6. Add original tokens for exact match (important for searching useGlobalHooks)
|
|
54
|
+
// Split on non-identifier chars but keep underscores (valid in most languages)
|
|
55
|
+
const originalTokens = text
|
|
56
|
+
.split(/[^a-zA-Z0-9_]+/)
|
|
57
|
+
.filter((t) => t.length > 1)
|
|
58
|
+
.map((t) => t.toLowerCase());
|
|
59
|
+
// Combine: split tokens + original identifiers
|
|
60
|
+
return [...new Set([...words, ...originalTokens])];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Enrich BM25 tokens with AST-derived identifiers.
|
|
64
|
+
* AST identifiers are boosted by repeating them (doubles their TF score).
|
|
65
|
+
* Symbol names are tokenized through the same pipeline for consistency.
|
|
66
|
+
*/
|
|
67
|
+
export function tokenizeCodeWithAST(text, astIdentifiers, symbolName) {
|
|
68
|
+
const baseTokens = tokenizeCode(text);
|
|
69
|
+
// Tokenize and boost AST identifiers
|
|
70
|
+
const astTokens = [];
|
|
71
|
+
for (const id of astIdentifiers) {
|
|
72
|
+
// Apply same tokenization as code tokens
|
|
73
|
+
const subTokens = tokenizeCode(id);
|
|
74
|
+
astTokens.push(...subTokens);
|
|
75
|
+
// Also keep the original identifier for exact match
|
|
76
|
+
if (id.length > 1)
|
|
77
|
+
astTokens.push(id.toLowerCase());
|
|
78
|
+
}
|
|
79
|
+
// Symbol name gets extra boost (3x: once from content, twice here)
|
|
80
|
+
if (symbolName) {
|
|
81
|
+
const nameTokens = tokenizeCode(symbolName);
|
|
82
|
+
astTokens.push(...nameTokens, ...nameTokens);
|
|
83
|
+
}
|
|
84
|
+
// Intentionally no dedup — repeated AST tokens boost their TF score in BM25
|
|
85
|
+
return [...baseTokens, ...astTokens];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Porter Stemmer (simplified)
|
|
89
|
+
* Handles common English suffixes
|
|
90
|
+
*/
|
|
91
|
+
function stem(word) {
|
|
92
|
+
if (word.length < 3)
|
|
93
|
+
return word;
|
|
94
|
+
let w = word.toLowerCase();
|
|
95
|
+
// Step 1a: plurals
|
|
96
|
+
if (w.endsWith('sses'))
|
|
97
|
+
w = w.slice(0, -2);
|
|
98
|
+
else if (w.endsWith('ies'))
|
|
99
|
+
w = w.slice(0, -2) + 'y';
|
|
100
|
+
else if (w.endsWith('ss')) {
|
|
101
|
+
/* keep */
|
|
102
|
+
}
|
|
103
|
+
else if (w.endsWith('s'))
|
|
104
|
+
w = w.slice(0, -1);
|
|
105
|
+
// Step 1b: -ed, -ing
|
|
106
|
+
if (w.endsWith('eed')) {
|
|
107
|
+
if (w.length > 4)
|
|
108
|
+
w = w.slice(0, -1);
|
|
109
|
+
}
|
|
110
|
+
else if (w.endsWith('ed')) {
|
|
111
|
+
const base = w.slice(0, -2);
|
|
112
|
+
if (/[aeiou]/.test(base))
|
|
113
|
+
w = base;
|
|
114
|
+
}
|
|
115
|
+
else if (w.endsWith('ing')) {
|
|
116
|
+
const base = w.slice(0, -3);
|
|
117
|
+
if (/[aeiou]/.test(base))
|
|
118
|
+
w = base;
|
|
119
|
+
}
|
|
120
|
+
// Step 2: common suffixes
|
|
121
|
+
const suffixes = [
|
|
122
|
+
['ational', 'ate'],
|
|
123
|
+
['tional', 'tion'],
|
|
124
|
+
['ization', 'ize'],
|
|
125
|
+
['ation', 'ate'],
|
|
126
|
+
['fulness', 'ful'],
|
|
127
|
+
['ousness', 'ous'],
|
|
128
|
+
['iveness', 'ive'],
|
|
129
|
+
['ement', 'e'],
|
|
130
|
+
['ment', ''],
|
|
131
|
+
['ness', ''],
|
|
132
|
+
['able', ''],
|
|
133
|
+
['ible', ''],
|
|
134
|
+
['ful', ''],
|
|
135
|
+
['less', ''],
|
|
136
|
+
['ive', ''],
|
|
137
|
+
['ize', ''],
|
|
138
|
+
['ise', ''],
|
|
139
|
+
['ly', ''],
|
|
140
|
+
['er', ''],
|
|
141
|
+
['or', ''],
|
|
142
|
+
];
|
|
143
|
+
for (const [suffix, replacement] of suffixes) {
|
|
144
|
+
if (w.endsWith(suffix) && w.length - suffix.length >= 2) {
|
|
145
|
+
w = w.slice(0, -suffix.length) + replacement;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return w;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Docs tokenizer with stemming
|
|
153
|
+
* For natural language in markdown files
|
|
154
|
+
*/
|
|
155
|
+
export function tokenizeDocs(text) {
|
|
156
|
+
// Remove markdown syntax
|
|
157
|
+
let processed = text
|
|
158
|
+
.replace(/```[\s\S]*?```/g, ' ') // code blocks
|
|
159
|
+
.replace(/`[^`]+`/g, ' ') // inline code
|
|
160
|
+
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // links -> text
|
|
161
|
+
.replace(/[#*_~>|]/g, ' ') // markdown chars
|
|
162
|
+
.replace(/\n/g, ' ');
|
|
163
|
+
// Keep alphanumeric
|
|
164
|
+
processed = processed.replace(/[^a-zA-Z0-9\s]/g, ' ');
|
|
165
|
+
// Lowercase, split, filter short words, stem
|
|
166
|
+
const words = processed
|
|
167
|
+
.toLowerCase()
|
|
168
|
+
.split(/\s+/)
|
|
169
|
+
.filter((t) => t.length > 2)
|
|
170
|
+
.map(stem);
|
|
171
|
+
// Also keep original words (without stemming) for exact matches
|
|
172
|
+
const original = processed
|
|
173
|
+
.toLowerCase()
|
|
174
|
+
.split(/\s+/)
|
|
175
|
+
.filter((t) => t.length > 2);
|
|
176
|
+
return [...new Set([...words, ...original])];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Build BM25 index from documents.
|
|
180
|
+
* For code documents with AST metadata, uses tokenizeCodeWithAST for TF boost.
|
|
181
|
+
*/
|
|
182
|
+
export function buildIndex(docs, tokenizer = 'code') {
|
|
183
|
+
const invertedIndex = new Map();
|
|
184
|
+
const docLengths = new Map();
|
|
185
|
+
const rawContent = new Map();
|
|
186
|
+
let totalLength = 0;
|
|
187
|
+
// Only store rawContent for code indexes (used for exact match boost).
|
|
188
|
+
// Docs/memories indexes never use rawContent — saves ~2x memory and serialization size.
|
|
189
|
+
const storeRawContent = tokenizer === 'code';
|
|
190
|
+
for (const doc of docs) {
|
|
191
|
+
// Use AST-enriched tokenizer when metadata is available (code search)
|
|
192
|
+
let tokens;
|
|
193
|
+
if (tokenizer === 'code' && (doc.symbolName || doc.signature)) {
|
|
194
|
+
const sigTokens = doc.signature ? tokenizeCode(doc.signature) : [];
|
|
195
|
+
tokens = tokenizeCodeWithAST(doc.content, sigTokens, doc.symbolName);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const tokenizeFn = tokenizer === 'code' ? tokenizeCode : tokenizeDocs;
|
|
199
|
+
tokens = tokenizeFn(doc.content);
|
|
200
|
+
}
|
|
201
|
+
docLengths.set(doc.id, tokens.length);
|
|
202
|
+
if (storeRawContent)
|
|
203
|
+
rawContent.set(doc.id, doc.content.toLowerCase());
|
|
204
|
+
totalLength += tokens.length;
|
|
205
|
+
const termFreq = new Map();
|
|
206
|
+
for (const token of tokens) {
|
|
207
|
+
termFreq.set(token, (termFreq.get(token) || 0) + 1);
|
|
208
|
+
}
|
|
209
|
+
for (const [term, freq] of termFreq) {
|
|
210
|
+
if (!invertedIndex.has(term)) {
|
|
211
|
+
invertedIndex.set(term, new Map());
|
|
212
|
+
}
|
|
213
|
+
invertedIndex.get(term).set(doc.id, freq);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
invertedIndex,
|
|
218
|
+
docLengths,
|
|
219
|
+
avgDocLength: docs.length > 0 ? totalLength / docs.length : 0,
|
|
220
|
+
totalDocs: docs.length,
|
|
221
|
+
rawContent,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Add single document to existing index.
|
|
226
|
+
* For code documents with AST metadata, uses tokenizeCodeWithAST for TF boost.
|
|
227
|
+
*/
|
|
228
|
+
export function addToIndex(index, doc, tokenizer = 'code') {
|
|
229
|
+
// Use AST-enriched tokenizer when metadata is available
|
|
230
|
+
let tokens;
|
|
231
|
+
if (tokenizer === 'code' && (doc.symbolName || doc.signature)) {
|
|
232
|
+
const sigTokens = doc.signature ? tokenizeCode(doc.signature) : [];
|
|
233
|
+
tokens = tokenizeCodeWithAST(doc.content, sigTokens, doc.symbolName);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
const tokenizeFn = tokenizer === 'code' ? tokenizeCode : tokenizeDocs;
|
|
237
|
+
tokens = tokenizeFn(doc.content);
|
|
238
|
+
}
|
|
239
|
+
// Update avg doc length
|
|
240
|
+
const oldTotal = index.avgDocLength * index.totalDocs;
|
|
241
|
+
index.totalDocs += 1;
|
|
242
|
+
index.avgDocLength = (oldTotal + tokens.length) / index.totalDocs;
|
|
243
|
+
index.docLengths.set(doc.id, tokens.length);
|
|
244
|
+
// Only store rawContent for code indexes (exact match boost)
|
|
245
|
+
if (tokenizer === 'code')
|
|
246
|
+
index.rawContent.set(doc.id, doc.content.toLowerCase());
|
|
247
|
+
const termFreq = new Map();
|
|
248
|
+
for (const token of tokens) {
|
|
249
|
+
termFreq.set(token, (termFreq.get(token) || 0) + 1);
|
|
250
|
+
}
|
|
251
|
+
for (const [term, freq] of termFreq) {
|
|
252
|
+
if (!index.invertedIndex.has(term)) {
|
|
253
|
+
index.invertedIndex.set(term, new Map());
|
|
254
|
+
}
|
|
255
|
+
index.invertedIndex.get(term).set(doc.id, freq);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Remove document from index
|
|
260
|
+
*/
|
|
261
|
+
export function removeFromIndex(index, docId) {
|
|
262
|
+
const docLength = index.docLengths.get(docId);
|
|
263
|
+
if (docLength === undefined)
|
|
264
|
+
return;
|
|
265
|
+
// Update avg doc length
|
|
266
|
+
const oldTotal = index.avgDocLength * index.totalDocs;
|
|
267
|
+
index.totalDocs -= 1;
|
|
268
|
+
index.avgDocLength = index.totalDocs > 0 ? (oldTotal - docLength) / index.totalDocs : 0;
|
|
269
|
+
index.docLengths.delete(docId);
|
|
270
|
+
index.rawContent.delete(docId);
|
|
271
|
+
// Remove from inverted index
|
|
272
|
+
for (const [, docsMap] of index.invertedIndex) {
|
|
273
|
+
docsMap.delete(docId);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// ============================================================================
|
|
277
|
+
// Search
|
|
278
|
+
// ============================================================================
|
|
279
|
+
/**
|
|
280
|
+
* IDF with smoothing
|
|
281
|
+
*/
|
|
282
|
+
function idf(term, index) {
|
|
283
|
+
const docsWithTerm = index.invertedIndex.get(term)?.size || 0;
|
|
284
|
+
if (docsWithTerm === 0)
|
|
285
|
+
return 0;
|
|
286
|
+
return Math.log((index.totalDocs - docsWithTerm + 0.5) / (docsWithTerm + 0.5) + 1);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Check if query looks like an identifier (for exact match boost)
|
|
290
|
+
*/
|
|
291
|
+
function isIdentifierLike(query) {
|
|
292
|
+
return (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(query.trim()) && query.trim().length > 2 && !query.includes(' '));
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* BM25 search with exact match boost
|
|
296
|
+
*/
|
|
297
|
+
export function search(query, index, tokenizer = 'code', limit = 10) {
|
|
298
|
+
const tokenizeFn = tokenizer === 'code' ? tokenizeCode : tokenizeDocs;
|
|
299
|
+
const queryTokens = tokenizeFn(query);
|
|
300
|
+
const scores = new Map();
|
|
301
|
+
const queryLower = query.toLowerCase().trim();
|
|
302
|
+
const isIdentifier = isIdentifierLike(query);
|
|
303
|
+
// BM25 scoring
|
|
304
|
+
for (const token of queryTokens) {
|
|
305
|
+
const termIdf = idf(token, index);
|
|
306
|
+
const docsWithTerm = index.invertedIndex.get(token);
|
|
307
|
+
if (!docsWithTerm)
|
|
308
|
+
continue;
|
|
309
|
+
for (const [docId, termFreq] of docsWithTerm) {
|
|
310
|
+
const docLength = index.docLengths.get(docId) || 0;
|
|
311
|
+
const numerator = termFreq * (K1 + 1);
|
|
312
|
+
const denominator = termFreq + K1 * (1 - B + B * (docLength / index.avgDocLength));
|
|
313
|
+
const termScore = termIdf * (numerator / denominator);
|
|
314
|
+
scores.set(docId, (scores.get(docId) || 0) + termScore);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Exact match boost (critical for identifier search)
|
|
318
|
+
if (isIdentifier && tokenizer === 'code') {
|
|
319
|
+
for (const [docId, content] of index.rawContent) {
|
|
320
|
+
if (content.includes(queryLower)) {
|
|
321
|
+
const currentScore = scores.get(docId) || 0;
|
|
322
|
+
// Boost: 2x for contains, 3x for word boundary match
|
|
323
|
+
const wordBoundary = new RegExp(`\\b${escapeRegex(queryLower)}\\b`);
|
|
324
|
+
const boost = wordBoundary.test(content) ? 3.0 : 2.0;
|
|
325
|
+
scores.set(docId, currentScore * boost + 5); // +5 base boost
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return Array.from(scores.entries())
|
|
330
|
+
.map(([docId, score]) => ({ docId, score }))
|
|
331
|
+
.sort((a, b) => b.score - a.score)
|
|
332
|
+
.slice(0, limit);
|
|
333
|
+
}
|
|
334
|
+
function escapeRegex(str) {
|
|
335
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
336
|
+
}
|
|
337
|
+
// ============================================================================
|
|
338
|
+
// Hybrid Search (RRF)
|
|
339
|
+
// ============================================================================
|
|
340
|
+
/**
|
|
341
|
+
* Reciprocal Rank Fusion - combines BM25 and vector search results
|
|
342
|
+
* Formula: RRF(d) = Σ 1/(k + rank(d))
|
|
343
|
+
*
|
|
344
|
+
* @param bm25Results - Results from BM25 search
|
|
345
|
+
* @param vectorResults - Results from vector search
|
|
346
|
+
* @param alpha - Weight: 0 = pure BM25, 1 = pure vector, 0.5 = equal
|
|
347
|
+
* @param limit - Max results to return
|
|
348
|
+
*/
|
|
349
|
+
export function reciprocalRankFusion(bm25Results, vectorResults, alpha = 0.5, limit = 10) {
|
|
350
|
+
const combined = new Map();
|
|
351
|
+
// BM25 contribution (weighted by 1-alpha)
|
|
352
|
+
bm25Results.forEach((r, rank) => {
|
|
353
|
+
const rrfScore = (1 - alpha) / (RRF_K + rank + 1);
|
|
354
|
+
combined.set(r.docId, (combined.get(r.docId) || 0) + rrfScore);
|
|
355
|
+
});
|
|
356
|
+
// Vector contribution (weighted by alpha)
|
|
357
|
+
vectorResults.forEach((r, rank) => {
|
|
358
|
+
const rrfScore = alpha / (RRF_K + rank + 1);
|
|
359
|
+
combined.set(r.docId, (combined.get(r.docId) || 0) + rrfScore);
|
|
360
|
+
});
|
|
361
|
+
return Array.from(combined.entries())
|
|
362
|
+
.map(([docId, score]) => ({ docId, score }))
|
|
363
|
+
.sort((a, b) => b.score - a.score)
|
|
364
|
+
.slice(0, limit);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Serialize index for storage in SQLite
|
|
368
|
+
*/
|
|
369
|
+
export function serializeIndex(index) {
|
|
370
|
+
const data = {
|
|
371
|
+
invertedIndex: Array.from(index.invertedIndex.entries()).map(([term, docs]) => [
|
|
372
|
+
term,
|
|
373
|
+
Array.from(docs.entries()),
|
|
374
|
+
]),
|
|
375
|
+
docLengths: Array.from(index.docLengths.entries()),
|
|
376
|
+
rawContent: Array.from(index.rawContent.entries()),
|
|
377
|
+
avgDocLength: index.avgDocLength,
|
|
378
|
+
totalDocs: index.totalDocs,
|
|
379
|
+
};
|
|
380
|
+
return JSON.stringify(data);
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Deserialize index from SQLite
|
|
384
|
+
*/
|
|
385
|
+
export function deserializeIndex(data) {
|
|
386
|
+
const p = JSON.parse(data);
|
|
387
|
+
return {
|
|
388
|
+
invertedIndex: new Map(p.invertedIndex.map(([t, d]) => [t, new Map(d)])),
|
|
389
|
+
docLengths: new Map(p.docLengths),
|
|
390
|
+
rawContent: new Map(p.rawContent),
|
|
391
|
+
avgDocLength: p.avgDocLength,
|
|
392
|
+
totalDocs: p.totalDocs,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Create empty index
|
|
397
|
+
*/
|
|
398
|
+
export function createEmptyIndex() {
|
|
399
|
+
return {
|
|
400
|
+
invertedIndex: new Map(),
|
|
401
|
+
docLengths: new Map(),
|
|
402
|
+
rawContent: new Map(),
|
|
403
|
+
avgDocLength: 0,
|
|
404
|
+
totalDocs: 0,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
// ============================================================================
|
|
408
|
+
// Ronin-style Word Segmentation (for flatcase identifiers)
|
|
409
|
+
// ============================================================================
|
|
410
|
+
/**
|
|
411
|
+
* Base dictionary of common programming terms.
|
|
412
|
+
* Used as fallback when token frequencies are low.
|
|
413
|
+
* Frequencies are approximate based on typical codebases.
|
|
414
|
+
*/
|
|
415
|
+
const BASE_CODE_DICTIONARY = {
|
|
416
|
+
// Actions
|
|
417
|
+
get: 500,
|
|
418
|
+
set: 400,
|
|
419
|
+
add: 300,
|
|
420
|
+
remove: 250,
|
|
421
|
+
delete: 200,
|
|
422
|
+
create: 200,
|
|
423
|
+
update: 200,
|
|
424
|
+
find: 150,
|
|
425
|
+
fetch: 150,
|
|
426
|
+
load: 150,
|
|
427
|
+
save: 150,
|
|
428
|
+
read: 150,
|
|
429
|
+
write: 150,
|
|
430
|
+
parse: 100,
|
|
431
|
+
init: 100,
|
|
432
|
+
start: 100,
|
|
433
|
+
stop: 100,
|
|
434
|
+
run: 100,
|
|
435
|
+
execute: 80,
|
|
436
|
+
handle: 100,
|
|
437
|
+
process: 100,
|
|
438
|
+
check: 100,
|
|
439
|
+
validate: 80,
|
|
440
|
+
format: 80,
|
|
441
|
+
convert: 80,
|
|
442
|
+
transform: 80,
|
|
443
|
+
build: 100,
|
|
444
|
+
render: 100,
|
|
445
|
+
display: 80,
|
|
446
|
+
show: 80,
|
|
447
|
+
hide: 80,
|
|
448
|
+
open: 80,
|
|
449
|
+
close: 80,
|
|
450
|
+
connect: 80,
|
|
451
|
+
send: 80,
|
|
452
|
+
receive: 60,
|
|
453
|
+
emit: 60,
|
|
454
|
+
listen: 60,
|
|
455
|
+
subscribe: 60,
|
|
456
|
+
publish: 60,
|
|
457
|
+
// Nouns
|
|
458
|
+
user: 200,
|
|
459
|
+
name: 200,
|
|
460
|
+
data: 300,
|
|
461
|
+
file: 300,
|
|
462
|
+
path: 300,
|
|
463
|
+
config: 200,
|
|
464
|
+
error: 250,
|
|
465
|
+
request: 200,
|
|
466
|
+
response: 200,
|
|
467
|
+
result: 150,
|
|
468
|
+
value: 250,
|
|
469
|
+
key: 200,
|
|
470
|
+
index: 200,
|
|
471
|
+
list: 150,
|
|
472
|
+
array: 150,
|
|
473
|
+
map: 150,
|
|
474
|
+
object: 200,
|
|
475
|
+
string: 300,
|
|
476
|
+
number: 200,
|
|
477
|
+
type: 200,
|
|
478
|
+
id: 300,
|
|
479
|
+
code: 150,
|
|
480
|
+
text: 150,
|
|
481
|
+
content: 200,
|
|
482
|
+
message: 150,
|
|
483
|
+
event: 150,
|
|
484
|
+
state: 150,
|
|
485
|
+
status: 100,
|
|
486
|
+
context: 100,
|
|
487
|
+
options: 100,
|
|
488
|
+
params: 100,
|
|
489
|
+
args: 100,
|
|
490
|
+
callback: 100,
|
|
491
|
+
handler: 150,
|
|
492
|
+
listener: 100,
|
|
493
|
+
component: 150,
|
|
494
|
+
element: 100,
|
|
495
|
+
node: 100,
|
|
496
|
+
item: 150,
|
|
497
|
+
entry: 100,
|
|
498
|
+
record: 100,
|
|
499
|
+
row: 100,
|
|
500
|
+
column: 80,
|
|
501
|
+
field: 100,
|
|
502
|
+
token: 100,
|
|
503
|
+
buffer: 80,
|
|
504
|
+
stream: 80,
|
|
505
|
+
chunk: 80,
|
|
506
|
+
batch: 80,
|
|
507
|
+
queue: 80,
|
|
508
|
+
stack: 80,
|
|
509
|
+
cache: 100,
|
|
510
|
+
store: 100,
|
|
511
|
+
db: 150,
|
|
512
|
+
database: 100,
|
|
513
|
+
table: 100,
|
|
514
|
+
query: 150,
|
|
515
|
+
url: 150,
|
|
516
|
+
uri: 80,
|
|
517
|
+
api: 150,
|
|
518
|
+
http: 100,
|
|
519
|
+
json: 150,
|
|
520
|
+
xml: 80,
|
|
521
|
+
html: 100,
|
|
522
|
+
css: 80,
|
|
523
|
+
server: 100,
|
|
524
|
+
client: 100,
|
|
525
|
+
socket: 80,
|
|
526
|
+
port: 80,
|
|
527
|
+
host: 80,
|
|
528
|
+
endpoint: 80,
|
|
529
|
+
// Modifiers
|
|
530
|
+
async: 200,
|
|
531
|
+
sync: 80,
|
|
532
|
+
local: 100,
|
|
533
|
+
global: 100,
|
|
534
|
+
public: 80,
|
|
535
|
+
private: 80,
|
|
536
|
+
static: 80,
|
|
537
|
+
final: 60,
|
|
538
|
+
default: 150,
|
|
539
|
+
custom: 80,
|
|
540
|
+
new: 150,
|
|
541
|
+
old: 80,
|
|
542
|
+
first: 100,
|
|
543
|
+
last: 100,
|
|
544
|
+
next: 100,
|
|
545
|
+
prev: 80,
|
|
546
|
+
current: 100,
|
|
547
|
+
all: 150,
|
|
548
|
+
single: 80,
|
|
549
|
+
multi: 80,
|
|
550
|
+
max: 100,
|
|
551
|
+
min: 100,
|
|
552
|
+
total: 100,
|
|
553
|
+
count: 150,
|
|
554
|
+
is: 200,
|
|
555
|
+
has: 150,
|
|
556
|
+
can: 100,
|
|
557
|
+
should: 80,
|
|
558
|
+
will: 80,
|
|
559
|
+
did: 60,
|
|
560
|
+
// Common suffixes/prefixes as words
|
|
561
|
+
by: 150,
|
|
562
|
+
to: 200,
|
|
563
|
+
from: 200,
|
|
564
|
+
with: 200,
|
|
565
|
+
for: 250,
|
|
566
|
+
of: 200,
|
|
567
|
+
on: 150,
|
|
568
|
+
in: 150,
|
|
569
|
+
at: 100,
|
|
570
|
+
or: 100,
|
|
571
|
+
and: 150,
|
|
572
|
+
not: 100,
|
|
573
|
+
if: 250,
|
|
574
|
+
else: 150,
|
|
575
|
+
then: 80,
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
* Check if a word looks like flatcase (all lowercase, no separators)
|
|
579
|
+
*/
|
|
580
|
+
export function isFlatcase(word) {
|
|
581
|
+
// Must be lowercase, only letters, length > 3 (to avoid false positives)
|
|
582
|
+
return /^[a-z]{4,}$/.test(word);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Ronin-style DP segmentation for flatcase identifiers.
|
|
586
|
+
* Uses token frequencies from indexed code to find optimal split.
|
|
587
|
+
*
|
|
588
|
+
* Algorithm (based on Peter Norvig's word segmentation):
|
|
589
|
+
* - For each position, try all possible splits
|
|
590
|
+
* - Score = sum of log(frequency) for each token
|
|
591
|
+
* - Prefer longer tokens (reward = log(freq) * sqrt(length))
|
|
592
|
+
* - Use DP to find globally optimal segmentation
|
|
593
|
+
*
|
|
594
|
+
* @param word - The flatcase word to segment (e.g., "getusername")
|
|
595
|
+
* @param getFrequency - Function to get token frequency from DB
|
|
596
|
+
* @param totalTokens - Total token count for probability calculation
|
|
597
|
+
* @param minTokenLength - Minimum token length (default: 2)
|
|
598
|
+
* @returns Array of tokens (e.g., ["get", "user", "name"])
|
|
599
|
+
*/
|
|
600
|
+
// LRU cache for segmentation results (DP is expensive per token)
|
|
601
|
+
const segmentationCache = new Map();
|
|
602
|
+
const SEGMENTATION_CACHE_MAX = 2000;
|
|
603
|
+
export function segmentFlatcase(word, getFrequency, totalTokens, minTokenLength = 2) {
|
|
604
|
+
const n = word.length;
|
|
605
|
+
if (n <= minTokenLength)
|
|
606
|
+
return [word];
|
|
607
|
+
// Check cache (keyed on word + totalTokens to detect corpus changes)
|
|
608
|
+
const cacheKey = `${word}:${totalTokens}`;
|
|
609
|
+
const cached = segmentationCache.get(cacheKey);
|
|
610
|
+
if (cached)
|
|
611
|
+
return cached;
|
|
612
|
+
// DP arrays
|
|
613
|
+
// bestScore[i] = best score for segmenting word[0:i]
|
|
614
|
+
// bestSplit[i] = position of last split for word[0:i]
|
|
615
|
+
const bestScore = new Array(n + 1).fill(-Infinity);
|
|
616
|
+
const bestSplit = new Array(n + 1).fill(0);
|
|
617
|
+
bestScore[0] = 0;
|
|
618
|
+
// Small constant for unknown tokens (prevents -Infinity)
|
|
619
|
+
const unknownScore = Math.log10(0.1 / Math.max(totalTokens, 1));
|
|
620
|
+
for (let i = 1; i <= n; i++) {
|
|
621
|
+
// Try all possible last tokens ending at position i
|
|
622
|
+
for (let j = Math.max(0, i - 15); j < i; j++) {
|
|
623
|
+
// Max token length 15
|
|
624
|
+
const tokenLen = i - j;
|
|
625
|
+
if (tokenLen < minTokenLength)
|
|
626
|
+
continue;
|
|
627
|
+
const token = word.slice(j, i);
|
|
628
|
+
let freq = getFrequency(token);
|
|
629
|
+
// Fallback to base dictionary if token not found in indexed code
|
|
630
|
+
// Scale base dictionary frequencies to match indexed corpus
|
|
631
|
+
if (freq === 0 && BASE_CODE_DICTIONARY[token]) {
|
|
632
|
+
// Scale: if total is 34000 and base dict max is 500, scale by ~68
|
|
633
|
+
const scaleFactor = Math.max(1, totalTokens / 5000);
|
|
634
|
+
freq = BASE_CODE_DICTIONARY[token] * scaleFactor;
|
|
635
|
+
}
|
|
636
|
+
// Score: log probability with length bonus
|
|
637
|
+
// But penalize long flatcase tokens that look like compounds
|
|
638
|
+
let tokenScore;
|
|
639
|
+
if (freq > 0) {
|
|
640
|
+
// Known token: log(freq/total) + length bonus
|
|
641
|
+
const prob = freq / Math.max(totalTokens, 1);
|
|
642
|
+
tokenScore = Math.log10(prob);
|
|
643
|
+
// Length bonus only for tokens <= 8 chars
|
|
644
|
+
// Longer flatcase tokens are likely compounds and should be split
|
|
645
|
+
if (tokenLen <= 8) {
|
|
646
|
+
tokenScore += Math.sqrt(tokenLen) * 0.5;
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
// Penalize long flatcase tokens to encourage splitting
|
|
650
|
+
tokenScore -= (tokenLen - 8) * 0.3;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
// Unknown token: penalize, but less for longer tokens
|
|
655
|
+
tokenScore = unknownScore - (15 - tokenLen) * 0.1;
|
|
656
|
+
}
|
|
657
|
+
const totalScore = bestScore[j] + tokenScore;
|
|
658
|
+
if (totalScore > bestScore[i]) {
|
|
659
|
+
bestScore[i] = totalScore;
|
|
660
|
+
bestSplit[i] = j;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
// Backtrack to find the optimal segmentation
|
|
665
|
+
const tokens = [];
|
|
666
|
+
let pos = n;
|
|
667
|
+
while (pos > 0) {
|
|
668
|
+
const splitPos = bestSplit[pos];
|
|
669
|
+
tokens.unshift(word.slice(splitPos, pos));
|
|
670
|
+
pos = splitPos;
|
|
671
|
+
}
|
|
672
|
+
// Cache result (LRU eviction)
|
|
673
|
+
if (segmentationCache.size >= SEGMENTATION_CACHE_MAX) {
|
|
674
|
+
const firstKey = segmentationCache.keys().next().value;
|
|
675
|
+
if (firstKey)
|
|
676
|
+
segmentationCache.delete(firstKey);
|
|
677
|
+
}
|
|
678
|
+
segmentationCache.set(cacheKey, tokens);
|
|
679
|
+
return tokens;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Enhanced tokenizeCode that handles flatcase using Ronin-style segmentation.
|
|
683
|
+
* This version accepts a frequency lookup function for dynamic segmentation.
|
|
684
|
+
*
|
|
685
|
+
* @param text - The text to tokenize
|
|
686
|
+
* @param getFrequency - Optional function to get token frequency (for flatcase segmentation)
|
|
687
|
+
* @param totalTokens - Optional total token count
|
|
688
|
+
*/
|
|
689
|
+
export function tokenizeCodeWithSegmentation(text, getFrequency, totalTokens) {
|
|
690
|
+
// First, apply standard tokenization rules
|
|
691
|
+
const standardTokens = tokenizeCode(text);
|
|
692
|
+
// If no frequency function provided, return standard tokens
|
|
693
|
+
if (!getFrequency || !totalTokens || totalTokens === 0) {
|
|
694
|
+
return standardTokens;
|
|
695
|
+
}
|
|
696
|
+
// Process each token - if it looks like flatcase, try to segment it
|
|
697
|
+
const result = [];
|
|
698
|
+
const seen = new Set();
|
|
699
|
+
for (const token of standardTokens) {
|
|
700
|
+
if (seen.has(token))
|
|
701
|
+
continue;
|
|
702
|
+
seen.add(token);
|
|
703
|
+
if (isFlatcase(token) && token.length >= 6) {
|
|
704
|
+
// Try to segment flatcase
|
|
705
|
+
const segments = segmentFlatcase(token, getFrequency, totalTokens);
|
|
706
|
+
// Only use segmentation if it found meaningful splits
|
|
707
|
+
if (segments.length > 1 && segments.every((s) => s.length >= 2)) {
|
|
708
|
+
for (const seg of segments) {
|
|
709
|
+
if (!seen.has(seg)) {
|
|
710
|
+
result.push(seg);
|
|
711
|
+
seen.add(seg);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
// Also keep original for exact match
|
|
715
|
+
result.push(token);
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
result.push(token);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
result.push(token);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return result;
|
|
726
|
+
}
|
|
727
|
+
//# sourceMappingURL=bm25.js.map
|