claude-code-workflow 6.3.18 → 6.3.20
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/.claude/CLAUDE.md +8 -5
- package/.claude/agents/action-planning-agent.md +26 -2
- package/.claude/agents/code-developer.md +132 -43
- package/.claude/agents/debug-explore-agent.md +434 -0
- package/.claude/agents/issue-plan-agent.md +31 -2
- package/.claude/agents/test-fix-agent.md +14 -0
- package/.claude/commands/issue/discover.md +41 -0
- package/.claude/commands/issue/execute.md +200 -19
- package/.claude/commands/issue/new.md +93 -3
- package/.claude/commands/issue/plan.md +9 -3
- package/.claude/commands/issue/queue.md +94 -39
- package/.claude/commands/memory/swagger-docs.md +773 -0
- package/.claude/commands/workflow/brainstorm/auto-parallel.md +21 -21
- package/.claude/commands/workflow/execute.md +54 -34
- package/.claude/commands/workflow/lite-execute.md +48 -164
- package/.claude/commands/workflow/lite-fix.md +4 -4
- package/.claude/commands/workflow/lite-plan.md +5 -5
- package/.claude/commands/workflow/plan.md +27 -27
- package/.claude/commands/workflow/review.md +42 -17
- package/.claude/commands/workflow/tdd-plan.md +25 -25
- package/.claude/commands/workflow/test-fix-gen.md +10 -10
- package/.claude/commands/workflow/test-gen.md +14 -14
- package/.claude/commands/workflow/ui-design/explore-auto.md +21 -21
- package/.claude/commands/workflow/ui-design/imitate-auto.md +24 -24
- package/.claude/skills/_shared/SKILL-DESIGN-SPEC.md +693 -0
- package/.claude/skills/ccw/SKILL.md +462 -0
- package/.claude/skills/ccw/index/command-capabilities.json +127 -0
- package/.claude/skills/ccw/index/intent-rules.json +136 -0
- package/.claude/skills/ccw/index/workflow-chains.json +451 -0
- package/.claude/skills/ccw/phases/actions/bugfix.md +218 -0
- package/.claude/skills/ccw/phases/actions/coupled.md +194 -0
- package/.claude/skills/ccw/phases/actions/docs.md +93 -0
- package/.claude/skills/ccw/phases/actions/full.md +154 -0
- package/.claude/skills/ccw/phases/actions/issue.md +201 -0
- package/.claude/skills/ccw/phases/actions/rapid.md +104 -0
- package/.claude/skills/ccw/phases/actions/review-fix.md +84 -0
- package/.claude/skills/ccw/phases/actions/tdd.md +66 -0
- package/.claude/skills/ccw/phases/actions/ui.md +79 -0
- package/.claude/skills/ccw/phases/orchestrator.md +435 -0
- package/.claude/skills/ccw/specs/intent-classification.md +336 -0
- package/.claude/skills/ccw-help/SKILL.md +177 -0
- package/.claude/skills/ccw-help/index/all-agents.json +82 -0
- package/.claude/skills/{command-guide → ccw-help}/index/all-commands.json +183 -73
- package/.claude/skills/{command-guide → ccw-help}/index/by-category.json +187 -73
- package/.claude/skills/{command-guide → ccw-help}/index/by-use-case.json +295 -185
- package/.claude/skills/{command-guide → ccw-help}/index/command-relationships.json +19 -166
- package/.claude/skills/{command-guide → ccw-help}/index/essential-commands.json +10 -10
- package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -0
- package/.claude/skills/code-reviewer/README.md +340 -0
- package/.claude/skills/code-reviewer/SKILL.md +308 -0
- package/.claude/skills/code-reviewer/phases/01-code-discovery.md +246 -0
- package/.claude/skills/code-reviewer/phases/02-security-analysis.md +442 -0
- package/.claude/skills/code-reviewer/phases/03-best-practices-review.md +36 -0
- package/.claude/skills/code-reviewer/phases/04-report-generation.md +278 -0
- package/.claude/skills/code-reviewer/specs/best-practices-requirements.md +346 -0
- package/.claude/skills/code-reviewer/specs/quality-standards.md +252 -0
- package/.claude/skills/code-reviewer/specs/security-requirements.md +243 -0
- package/.claude/skills/code-reviewer/templates/best-practice-finding.md +234 -0
- package/.claude/skills/code-reviewer/templates/report-template.md +316 -0
- package/.claude/skills/code-reviewer/templates/security-finding.md +161 -0
- package/.claude/skills/skill-generator/SKILL.md +187 -0
- package/.claude/skills/skill-generator/phases/01-requirements-discovery.md +239 -0
- package/.claude/skills/skill-generator/phases/02-structure-generation.md +207 -0
- package/.claude/skills/skill-generator/phases/03-phase-generation.md +802 -0
- package/.claude/skills/skill-generator/phases/04-specs-templates.md +328 -0
- package/.claude/skills/skill-generator/phases/05-validation.md +334 -0
- package/.claude/skills/skill-generator/specs/cli-integration.md +448 -0
- package/.claude/skills/skill-generator/specs/execution-modes.md +396 -0
- package/.claude/skills/skill-generator/specs/scripting-integration.md +265 -0
- package/.claude/skills/skill-generator/specs/skill-requirements.md +466 -0
- package/.claude/skills/skill-generator/templates/autonomous-action.md +517 -0
- package/.claude/skills/skill-generator/templates/autonomous-orchestrator.md +276 -0
- package/.claude/skills/skill-generator/templates/code-analysis-action.md +503 -0
- package/.claude/skills/skill-generator/templates/llm-action.md +355 -0
- package/.claude/skills/skill-generator/templates/script-bash.md +277 -0
- package/.claude/skills/skill-generator/templates/script-python.md +198 -0
- package/.claude/skills/skill-generator/templates/sequential-phase.md +441 -0
- package/.claude/skills/skill-generator/templates/skill-md.md +156 -0
- package/.claude/workflows/chinese-response.md +15 -28
- package/.claude/workflows/cli-templates/prompts/documentation/swagger-api.txt +266 -0
- package/.claude/workflows/cli-tools-usage.md +221 -177
- package/.claude/workflows/windows-platform.md +13 -10
- package/.codex/prompts/issue-execute.md +310 -82
- package/.codex/prompts/issue-queue.md +22 -0
- package/.codex/prompts/lite-execute.md +36 -11
- package/README.md +309 -305
- package/ccw/README.md +10 -4
- package/ccw/dist/cli.d.ts.map +1 -1
- package/ccw/dist/cli.js +4 -1
- package/ccw/dist/cli.js.map +1 -1
- package/ccw/dist/commands/cli.d.ts.map +1 -1
- package/ccw/dist/commands/cli.js +131 -34
- package/ccw/dist/commands/cli.js.map +1 -1
- package/ccw/dist/commands/issue.d.ts +152 -0
- package/ccw/dist/commands/issue.d.ts.map +1 -1
- package/ccw/dist/commands/issue.js +550 -85
- package/ccw/dist/commands/issue.js.map +1 -1
- package/ccw/dist/commands/serve.d.ts +1 -0
- package/ccw/dist/commands/serve.d.ts.map +1 -1
- package/ccw/dist/commands/serve.js +12 -5
- package/ccw/dist/commands/serve.js.map +1 -1
- package/ccw/dist/commands/stop.d.ts.map +1 -1
- package/ccw/dist/commands/stop.js +29 -5
- package/ccw/dist/commands/stop.js.map +1 -1
- package/ccw/dist/commands/tool.d.ts.map +1 -1
- package/ccw/dist/commands/tool.js +19 -2
- package/ccw/dist/commands/tool.js.map +1 -1
- package/ccw/dist/commands/view.d.ts +1 -0
- package/ccw/dist/commands/view.d.ts.map +1 -1
- package/ccw/dist/commands/view.js +10 -3
- package/ccw/dist/commands/view.js.map +1 -1
- package/ccw/dist/config/cli-settings-manager.d.ts +86 -0
- package/ccw/dist/config/cli-settings-manager.d.ts.map +1 -0
- package/ccw/dist/config/cli-settings-manager.js +392 -0
- package/ccw/dist/config/cli-settings-manager.js.map +1 -0
- package/ccw/dist/config/litellm-api-config-manager.d.ts +71 -5
- package/ccw/dist/config/litellm-api-config-manager.d.ts.map +1 -1
- package/ccw/dist/config/litellm-api-config-manager.js +290 -20
- package/ccw/dist/config/litellm-api-config-manager.js.map +1 -1
- package/ccw/dist/core/auth/csrf-manager.d.ts +18 -0
- package/ccw/dist/core/auth/csrf-manager.d.ts.map +1 -0
- package/ccw/dist/core/auth/csrf-manager.js +80 -0
- package/ccw/dist/core/auth/csrf-manager.js.map +1 -0
- package/ccw/dist/core/auth/csrf-middleware.d.ts +8 -0
- package/ccw/dist/core/auth/csrf-middleware.d.ts.map +1 -0
- package/ccw/dist/core/auth/csrf-middleware.js +141 -0
- package/ccw/dist/core/auth/csrf-middleware.js.map +1 -0
- package/ccw/dist/core/auth/middleware.d.ts +15 -0
- package/ccw/dist/core/auth/middleware.d.ts.map +1 -0
- package/ccw/dist/core/auth/middleware.js +76 -0
- package/ccw/dist/core/auth/middleware.js.map +1 -0
- package/ccw/dist/core/auth/token-manager.d.ts +41 -0
- package/ccw/dist/core/auth/token-manager.d.ts.map +1 -0
- package/ccw/dist/core/auth/token-manager.js +171 -0
- package/ccw/dist/core/auth/token-manager.js.map +1 -0
- package/ccw/dist/core/cache-manager.d.ts +6 -6
- package/ccw/dist/core/cache-manager.d.ts.map +1 -1
- package/ccw/dist/core/cache-manager.js +70 -48
- package/ccw/dist/core/cache-manager.js.map +1 -1
- package/ccw/dist/core/claude-freshness.d.ts.map +1 -1
- package/ccw/dist/core/claude-freshness.js +23 -3
- package/ccw/dist/core/claude-freshness.js.map +1 -1
- package/ccw/dist/core/core-memory-store.d.ts.map +1 -1
- package/ccw/dist/core/core-memory-store.js +2 -1
- package/ccw/dist/core/core-memory-store.js.map +1 -1
- package/ccw/dist/core/cors.d.ts +3 -0
- package/ccw/dist/core/cors.d.ts.map +1 -0
- package/ccw/dist/core/cors.js +10 -0
- package/ccw/dist/core/cors.js.map +1 -0
- package/ccw/dist/core/dashboard-generator-patch.js +0 -1
- package/ccw/dist/core/dashboard-generator-patch.js.map +1 -1
- package/ccw/dist/core/dashboard-generator.d.ts.map +1 -1
- package/ccw/dist/core/dashboard-generator.js +417 -416
- package/ccw/dist/core/dashboard-generator.js.map +1 -1
- package/ccw/dist/core/data-aggregator.js +2 -2
- package/ccw/dist/core/data-aggregator.js.map +1 -1
- package/ccw/dist/core/lite-scanner.d.ts +1 -1
- package/ccw/dist/core/lite-scanner.d.ts.map +1 -1
- package/ccw/dist/core/lite-scanner.js +130 -127
- package/ccw/dist/core/lite-scanner.js.map +1 -1
- package/ccw/dist/core/routes/auth-routes.d.ts +12 -0
- package/ccw/dist/core/routes/auth-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/auth-routes.js +80 -0
- package/ccw/dist/core/routes/auth-routes.js.map +1 -0
- package/ccw/dist/core/routes/ccw-routes.d.ts +1 -14
- package/ccw/dist/core/routes/ccw-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/ccw-routes.js +9 -4
- package/ccw/dist/core/routes/ccw-routes.js.map +1 -1
- package/ccw/dist/core/routes/claude-routes.d.ts +1 -14
- package/ccw/dist/core/routes/claude-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/claude-routes.js +98 -39
- package/ccw/dist/core/routes/claude-routes.js.map +1 -1
- package/ccw/dist/core/routes/cli-routes.d.ts +14 -12
- package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/cli-routes.js +122 -43
- package/ccw/dist/core/routes/cli-routes.js.map +1 -1
- package/ccw/dist/core/routes/cli-settings-routes.d.ts +11 -0
- package/ccw/dist/core/routes/cli-settings-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/cli-settings-routes.js +204 -0
- package/ccw/dist/core/routes/cli-settings-routes.js.map +1 -0
- package/ccw/dist/core/routes/codexlens/config-handlers.d.ts +6 -0
- package/ccw/dist/core/routes/codexlens/config-handlers.d.ts.map +1 -0
- package/ccw/dist/core/routes/codexlens/config-handlers.js +1195 -0
- package/ccw/dist/core/routes/codexlens/config-handlers.js.map +1 -0
- package/ccw/dist/core/routes/codexlens/index-handlers.d.ts +10 -0
- package/ccw/dist/core/routes/codexlens/index-handlers.d.ts.map +1 -0
- package/ccw/dist/core/routes/codexlens/index-handlers.js +322 -0
- package/ccw/dist/core/routes/codexlens/index-handlers.js.map +1 -0
- package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts +6 -0
- package/ccw/dist/core/routes/codexlens/semantic-handlers.d.ts.map +1 -0
- package/ccw/dist/core/routes/codexlens/semantic-handlers.js +865 -0
- package/ccw/dist/core/routes/codexlens/semantic-handlers.js.map +1 -0
- package/ccw/dist/core/routes/codexlens/utils.d.ts +23 -0
- package/ccw/dist/core/routes/codexlens/utils.d.ts.map +1 -0
- package/ccw/dist/core/routes/codexlens/utils.js +85 -0
- package/ccw/dist/core/routes/codexlens/utils.js.map +1 -0
- package/ccw/dist/core/routes/codexlens/watcher-handlers.d.ts +13 -0
- package/ccw/dist/core/routes/codexlens/watcher-handlers.d.ts.map +1 -0
- package/ccw/dist/core/routes/codexlens/watcher-handlers.js +235 -0
- package/ccw/dist/core/routes/codexlens/watcher-handlers.js.map +1 -0
- package/ccw/dist/core/routes/codexlens-routes.d.ts +2 -11
- package/ccw/dist/core/routes/codexlens-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/codexlens-routes.js +10 -981
- package/ccw/dist/core/routes/codexlens-routes.js.map +1 -1
- package/ccw/dist/core/routes/discovery-routes.d.ts +1 -35
- package/ccw/dist/core/routes/discovery-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/discovery-routes.js +25 -0
- package/ccw/dist/core/routes/discovery-routes.js.map +1 -1
- package/ccw/dist/core/routes/files-routes.d.ts +1 -14
- package/ccw/dist/core/routes/files-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/files-routes.js +57 -14
- package/ccw/dist/core/routes/files-routes.js.map +1 -1
- package/ccw/dist/core/routes/graph-routes.d.ts +1 -14
- package/ccw/dist/core/routes/graph-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/graph-routes.js +36 -37
- package/ccw/dist/core/routes/graph-routes.js.map +1 -1
- package/ccw/dist/core/routes/help-routes.d.ts +1 -14
- package/ccw/dist/core/routes/help-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/help-routes.js +5 -0
- package/ccw/dist/core/routes/help-routes.js.map +1 -1
- package/ccw/dist/core/routes/hooks-routes.d.ts +4 -14
- package/ccw/dist/core/routes/hooks-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/hooks-routes.js +43 -21
- package/ccw/dist/core/routes/hooks-routes.js.map +1 -1
- package/ccw/dist/core/routes/issue-routes.d.ts +1 -34
- package/ccw/dist/core/routes/issue-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/issue-routes.js +24 -0
- package/ccw/dist/core/routes/issue-routes.js.map +1 -1
- package/ccw/dist/core/routes/litellm-api-routes.d.ts +1 -14
- package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/litellm-api-routes.js +513 -48
- package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
- package/ccw/dist/core/routes/litellm-routes.d.ts +1 -14
- package/ccw/dist/core/routes/litellm-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/litellm-routes.js +28 -11
- package/ccw/dist/core/routes/litellm-routes.js.map +1 -1
- package/ccw/dist/core/routes/mcp-routes.d.ts +1 -14
- package/ccw/dist/core/routes/mcp-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/mcp-routes.js +99 -30
- package/ccw/dist/core/routes/mcp-routes.js.map +1 -1
- package/ccw/dist/core/routes/mcp-templates-db.d.ts.map +1 -1
- package/ccw/dist/core/routes/mcp-templates-db.js +30 -31
- package/ccw/dist/core/routes/mcp-templates-db.js.map +1 -1
- package/ccw/dist/core/routes/memory-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/memory-routes.js +74 -24
- package/ccw/dist/core/routes/memory-routes.js.map +1 -1
- package/ccw/dist/core/routes/nav-status-routes.d.ts +3 -0
- package/ccw/dist/core/routes/nav-status-routes.d.ts.map +1 -0
- package/ccw/dist/core/routes/nav-status-routes.js +217 -0
- package/ccw/dist/core/routes/nav-status-routes.js.map +1 -0
- package/ccw/dist/core/routes/rules-routes.d.ts +1 -14
- package/ccw/dist/core/routes/rules-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/rules-routes.js +481 -58
- package/ccw/dist/core/routes/rules-routes.js.map +1 -1
- package/ccw/dist/core/routes/session-routes.d.ts +1 -14
- package/ccw/dist/core/routes/session-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/session-routes.js +15 -3
- package/ccw/dist/core/routes/session-routes.js.map +1 -1
- package/ccw/dist/core/routes/skills-routes.d.ts +1 -14
- package/ccw/dist/core/routes/skills-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/skills-routes.js +394 -112
- package/ccw/dist/core/routes/skills-routes.js.map +1 -1
- package/ccw/dist/core/routes/status-routes.d.ts +1 -14
- package/ccw/dist/core/routes/status-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/status-routes.js +4 -0
- package/ccw/dist/core/routes/status-routes.js.map +1 -1
- package/ccw/dist/core/routes/system-routes.d.ts +4 -10
- package/ccw/dist/core/routes/system-routes.d.ts.map +1 -1
- package/ccw/dist/core/routes/system-routes.js +6 -4
- package/ccw/dist/core/routes/system-routes.js.map +1 -1
- package/ccw/dist/core/routes/types.d.ts +19 -0
- package/ccw/dist/core/routes/types.d.ts.map +1 -0
- package/ccw/dist/core/routes/types.js +2 -0
- package/ccw/dist/core/routes/types.js.map +1 -0
- package/ccw/dist/core/server.d.ts.map +1 -1
- package/ccw/dist/core/server.js +206 -29
- package/ccw/dist/core/server.js.map +1 -1
- package/ccw/dist/core/services/api-key-tester.d.ts +42 -0
- package/ccw/dist/core/services/api-key-tester.d.ts.map +1 -0
- package/ccw/dist/core/services/api-key-tester.js +126 -0
- package/ccw/dist/core/services/api-key-tester.js.map +1 -0
- package/ccw/dist/core/services/health-check-service.d.ts +88 -0
- package/ccw/dist/core/services/health-check-service.d.ts.map +1 -0
- package/ccw/dist/core/services/health-check-service.js +293 -0
- package/ccw/dist/core/services/health-check-service.js.map +1 -0
- package/ccw/dist/core/websocket.d.ts +9 -7
- package/ccw/dist/core/websocket.d.ts.map +1 -1
- package/ccw/dist/core/websocket.js +9 -4
- package/ccw/dist/core/websocket.js.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.d.ts +152 -28
- package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
- package/ccw/dist/tools/claude-cli-tools.js +490 -100
- package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
- package/ccw/dist/tools/cli-config-manager.d.ts +24 -8
- package/ccw/dist/tools/cli-config-manager.d.ts.map +1 -1
- package/ccw/dist/tools/cli-config-manager.js +76 -156
- package/ccw/dist/tools/cli-config-manager.js.map +1 -1
- package/ccw/dist/tools/cli-executor-core.d.ts +85 -0
- package/ccw/dist/tools/cli-executor-core.d.ts.map +1 -0
- package/ccw/dist/tools/cli-executor-core.js +1310 -0
- package/ccw/dist/tools/cli-executor-core.js.map +1 -0
- package/ccw/dist/tools/cli-executor-state.d.ts +241 -0
- package/ccw/dist/tools/cli-executor-state.d.ts.map +1 -0
- package/ccw/dist/tools/cli-executor-state.js +392 -0
- package/ccw/dist/tools/cli-executor-state.js.map +1 -0
- package/ccw/dist/tools/cli-executor-utils.d.ts +36 -0
- package/ccw/dist/tools/cli-executor-utils.d.ts.map +1 -0
- package/ccw/dist/tools/cli-executor-utils.js +298 -0
- package/ccw/dist/tools/cli-executor-utils.js.map +1 -0
- package/ccw/dist/tools/cli-executor.d.ts +3 -377
- package/ccw/dist/tools/cli-executor.d.ts.map +1 -1
- package/ccw/dist/tools/cli-executor.js +3 -1884
- package/ccw/dist/tools/cli-executor.js.map +1 -1
- package/ccw/dist/tools/cli-history-store.d.ts +2 -0
- package/ccw/dist/tools/cli-history-store.d.ts.map +1 -1
- package/ccw/dist/tools/cli-history-store.js.map +1 -1
- package/ccw/dist/tools/cli-output-converter.d.ts +192 -0
- package/ccw/dist/tools/cli-output-converter.d.ts.map +1 -0
- package/ccw/dist/tools/cli-output-converter.js +1047 -0
- package/ccw/dist/tools/cli-output-converter.js.map +1 -0
- package/ccw/dist/tools/cli-prompt-builder.d.ts +113 -0
- package/ccw/dist/tools/cli-prompt-builder.d.ts.map +1 -0
- package/ccw/dist/tools/cli-prompt-builder.js +363 -0
- package/ccw/dist/tools/cli-prompt-builder.js.map +1 -0
- package/ccw/dist/tools/codex-lens.d.ts +15 -1
- package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
- package/ccw/dist/tools/codex-lens.js +289 -55
- package/ccw/dist/tools/codex-lens.js.map +1 -1
- package/ccw/dist/tools/detect-changed-modules.d.ts.map +1 -1
- package/ccw/dist/tools/detect-changed-modules.js +22 -4
- package/ccw/dist/tools/detect-changed-modules.js.map +1 -1
- package/ccw/dist/tools/index.d.ts.map +1 -1
- package/ccw/dist/tools/index.js +2 -0
- package/ccw/dist/tools/index.js.map +1 -1
- package/ccw/dist/tools/litellm-client.d.ts.map +1 -1
- package/ccw/dist/tools/litellm-client.js +10 -4
- package/ccw/dist/tools/litellm-client.js.map +1 -1
- package/ccw/dist/tools/litellm-executor.d.ts +2 -4
- package/ccw/dist/tools/litellm-executor.d.ts.map +1 -1
- package/ccw/dist/tools/litellm-executor.js +39 -8
- package/ccw/dist/tools/litellm-executor.js.map +1 -1
- package/ccw/dist/tools/native-session-discovery.d.ts +2 -0
- package/ccw/dist/tools/native-session-discovery.d.ts.map +1 -1
- package/ccw/dist/tools/native-session-discovery.js +197 -1
- package/ccw/dist/tools/native-session-discovery.js.map +1 -1
- package/ccw/dist/tools/session-manager.d.ts.map +1 -1
- package/ccw/dist/tools/session-manager.js +79 -0
- package/ccw/dist/tools/session-manager.js.map +1 -1
- package/ccw/dist/tools/skill-context-loader.d.ts +15 -0
- package/ccw/dist/tools/skill-context-loader.d.ts.map +1 -0
- package/ccw/dist/tools/skill-context-loader.js +198 -0
- package/ccw/dist/tools/skill-context-loader.js.map +1 -0
- package/ccw/dist/tools/smart-search.d.ts +8 -3
- package/ccw/dist/tools/smart-search.d.ts.map +1 -1
- package/ccw/dist/tools/smart-search.js +378 -75
- package/ccw/dist/tools/smart-search.js.map +1 -1
- package/ccw/dist/types/cli-settings.d.ts +86 -0
- package/ccw/dist/types/cli-settings.d.ts.map +1 -0
- package/ccw/dist/types/cli-settings.js +54 -0
- package/ccw/dist/types/cli-settings.js.map +1 -0
- package/ccw/dist/types/litellm-api-config.d.ts +40 -1
- package/ccw/dist/types/litellm-api-config.d.ts.map +1 -1
- package/ccw/dist/utils/exec-constants.d.ts +25 -0
- package/ccw/dist/utils/exec-constants.d.ts.map +1 -0
- package/ccw/dist/utils/exec-constants.js +25 -0
- package/ccw/dist/utils/exec-constants.js.map +1 -0
- package/ccw/dist/utils/path-resolver.d.ts +1 -0
- package/ccw/dist/utils/path-resolver.d.ts.map +1 -1
- package/ccw/dist/utils/path-resolver.js +48 -3
- package/ccw/dist/utils/path-resolver.js.map +1 -1
- package/ccw/dist/utils/path-validator.d.ts.map +1 -1
- package/ccw/dist/utils/path-validator.js +25 -6
- package/ccw/dist/utils/path-validator.js.map +1 -1
- package/ccw/dist/utils/python-utils.d.ts.map +1 -1
- package/ccw/dist/utils/python-utils.js +27 -7
- package/ccw/dist/utils/python-utils.js.map +1 -1
- package/ccw/dist/utils/shell-escape.d.ts +8 -0
- package/ccw/dist/utils/shell-escape.d.ts.map +1 -0
- package/ccw/dist/utils/shell-escape.js +24 -0
- package/ccw/dist/utils/shell-escape.js.map +1 -0
- package/ccw/dist/utils/uv-manager.d.ts +167 -0
- package/ccw/dist/utils/uv-manager.d.ts.map +1 -0
- package/ccw/dist/utils/uv-manager.js +644 -0
- package/ccw/dist/utils/uv-manager.js.map +1 -0
- package/ccw/src/cli.ts +4 -1
- package/ccw/src/commands/cli.ts +132 -34
- package/ccw/src/commands/issue.ts +605 -91
- package/ccw/src/commands/serve.ts +15 -5
- package/ccw/src/commands/stop.ts +32 -5
- package/ccw/src/commands/tool.ts +17 -2
- package/ccw/src/commands/view.ts +13 -3
- package/ccw/src/config/cli-settings-manager.ts +460 -0
- package/ccw/src/config/litellm-api-config-manager.ts +392 -57
- package/ccw/src/core/auth/csrf-manager.ts +104 -0
- package/ccw/src/core/auth/csrf-middleware.ts +159 -0
- package/ccw/src/core/auth/middleware.ts +94 -0
- package/ccw/src/core/auth/token-manager.ts +219 -0
- package/ccw/src/core/cache-manager.ts +64 -52
- package/ccw/src/core/claude-freshness.ts +26 -6
- package/ccw/src/core/core-memory-store.ts +2 -1
- package/ccw/src/core/cors.ts +10 -0
- package/ccw/src/core/dashboard-generator-patch.ts +47 -48
- package/ccw/src/core/dashboard-generator.ts +797 -744
- package/ccw/src/core/data-aggregator.ts +667 -667
- package/ccw/src/core/lite-scanner.ts +156 -140
- package/ccw/src/core/routes/auth-routes.ts +98 -0
- package/ccw/src/core/routes/ccw-routes.ts +10 -20
- package/ccw/src/core/routes/claude-routes.ts +101 -51
- package/ccw/src/core/routes/cli-routes.ts +152 -55
- package/ccw/src/core/routes/cli-settings-routes.ts +232 -0
- package/ccw/src/core/routes/codexlens/README.md +37 -0
- package/ccw/src/core/routes/codexlens/config-handlers.ts +1269 -0
- package/ccw/src/core/routes/codexlens/index-handlers.ts +354 -0
- package/ccw/src/core/routes/codexlens/semantic-handlers.ts +931 -0
- package/ccw/src/core/routes/codexlens/utils.ts +96 -0
- package/ccw/src/core/routes/codexlens/watcher-handlers.ts +265 -0
- package/ccw/src/core/routes/codexlens-routes.ts +11 -1044
- package/ccw/src/core/routes/discovery-routes.ts +1 -12
- package/ccw/src/core/routes/files-routes.ts +112 -40
- package/ccw/src/core/routes/graph-routes.ts +39 -46
- package/ccw/src/core/routes/help-routes.ts +2 -12
- package/ccw/src/core/routes/hooks-routes.ts +83 -44
- package/ccw/src/core/routes/issue-routes.ts +1 -12
- package/ccw/src/core/routes/litellm-api-routes.ts +574 -60
- package/ccw/src/core/routes/litellm-routes.ts +35 -27
- package/ccw/src/core/routes/mcp-routes.ts +157 -60
- package/ccw/src/core/routes/mcp-routes.ts.backup +549 -550
- package/ccw/src/core/routes/mcp-templates-db.ts +267 -268
- package/ccw/src/core/routes/memory-routes.ts +76 -22
- package/ccw/src/core/routes/nav-status-routes.ts +231 -0
- package/ccw/src/core/routes/rules-routes.ts +600 -81
- package/ccw/src/core/routes/session-routes.ts +28 -22
- package/ccw/src/core/routes/skills-routes.ts +452 -132
- package/ccw/src/core/routes/status-routes.ts +1 -12
- package/ccw/src/core/routes/system-routes.ts +15 -22
- package/ccw/src/core/routes/types.ts +25 -0
- package/ccw/src/core/server.ts +657 -468
- package/ccw/src/core/services/api-key-tester.ts +160 -0
- package/ccw/src/core/services/health-check-service.ts +366 -0
- package/ccw/src/core/websocket.ts +20 -12
- package/ccw/src/templates/dashboard-css/01-base.css +109 -0
- package/ccw/src/templates/dashboard-css/10-cli-status.css +202 -0
- package/ccw/src/templates/dashboard-css/21-cli-toolmgmt.css +308 -0
- package/ccw/src/templates/dashboard-css/30-core-memory.css +20 -0
- package/ccw/src/templates/dashboard-css/31-api-settings.css +751 -14
- package/ccw/src/templates/dashboard-css/33-cli-stream-viewer.css +230 -2
- package/ccw/src/templates/dashboard-js/api.js +5 -0
- package/ccw/src/templates/dashboard-js/components/cli-status.js +279 -107
- package/ccw/src/templates/dashboard-js/components/cli-stream-viewer.js +262 -20
- package/ccw/src/templates/dashboard-js/components/hook-manager.js +105 -5
- package/ccw/src/templates/dashboard-js/components/mcp-manager.js +317 -0
- package/ccw/src/templates/dashboard-js/components/navigation.js +45 -0
- package/ccw/src/templates/dashboard-js/components/notifications.js +128 -0
- package/ccw/src/templates/dashboard-js/i18n.js +4448 -3983
- package/ccw/src/templates/dashboard-js/main.js +71 -0
- package/ccw/src/templates/dashboard-js/services.js +289 -0
- package/ccw/src/templates/dashboard-js/views/api-settings.js +5613 -3361
- package/ccw/src/templates/dashboard-js/views/claude-manager.js +1 -7
- package/ccw/src/templates/dashboard-js/views/cli-manager.js +581 -87
- package/ccw/src/templates/dashboard-js/views/codexlens-manager.js +6101 -1965
- package/ccw/src/templates/dashboard-js/views/core-memory.js +129 -20
- package/ccw/src/templates/dashboard-js/views/hook-manager.js +17 -3
- package/ccw/src/templates/dashboard-js/views/mcp-manager.js +63 -0
- package/ccw/src/templates/dashboard-js/views/project-overview.js +182 -37
- package/ccw/src/templates/dashboard-js/views/rules-manager.js +26 -3
- package/ccw/src/templates/dashboard-js/views/skills-manager.js +2 -42
- package/ccw/src/templates/dashboard.html +6 -0
- package/ccw/src/tools/README.md +29 -0
- package/ccw/src/tools/claude-cli-tools.ts +640 -125
- package/ccw/src/tools/cli-config-manager.ts +102 -172
- package/ccw/src/tools/cli-executor-core.ts +1533 -0
- package/ccw/src/tools/cli-executor-state.ts +560 -0
- package/ccw/src/tools/cli-executor-utils.ts +349 -0
- package/ccw/src/tools/cli-executor.ts +3 -2309
- package/ccw/src/tools/cli-history-store.ts +2 -0
- package/ccw/src/tools/cli-output-converter.ts +1237 -0
- package/ccw/src/tools/cli-prompt-builder.ts +487 -0
- package/ccw/src/tools/codex-lens.ts +324 -59
- package/ccw/src/tools/detect-changed-modules.ts +24 -6
- package/ccw/src/tools/index.ts +2 -0
- package/ccw/src/tools/litellm-client.ts +10 -4
- package/ccw/src/tools/litellm-executor.ts +146 -114
- package/ccw/src/tools/native-session-discovery.ts +209 -1
- package/ccw/src/tools/session-manager.ts +88 -0
- package/ccw/src/tools/skill-context-loader.ts +213 -0
- package/ccw/src/tools/smart-search.ts +427 -76
- package/ccw/src/types/cli-settings.ts +137 -0
- package/ccw/src/types/litellm-api-config.ts +55 -1
- package/ccw/src/utils/exec-constants.ts +24 -0
- package/ccw/src/utils/path-resolver.ts +49 -3
- package/ccw/src/utils/path-validator.ts +28 -6
- package/ccw/src/utils/python-utils.ts +140 -121
- package/ccw/src/utils/shell-escape.ts +30 -0
- package/ccw/src/utils/uv-manager.ts +796 -0
- package/ccw-litellm/src/ccw_litellm/__pycache__/__init__.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/__pycache__/__init__.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/__init__.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/__init__.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_embedder.cpython-313.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/__pycache__/litellm_llm.cpython-313.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +270 -251
- package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +33 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/__init__.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/__init__.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/loader.cpython-313.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/__pycache__/models.cpython-313.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/config/loader.py +343 -316
- package/ccw-litellm/src/ccw_litellm/config/models.py +162 -130
- package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/__init__.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/__init__.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/embedder.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/embedder.cpython-312.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/llm.cpython-310.pyc +0 -0
- package/ccw-litellm/src/ccw_litellm/interfaces/__pycache__/llm.cpython-312.pyc +0 -0
- package/codex-lens/pyproject.toml +43 -0
- package/codex-lens/src/codexlens/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/__main__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/__main__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/config.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/config.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/entities.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/entities.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/entities.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/env_config.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/env_config.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/env_config.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/errors.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/errors.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/commands.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/embedding_manager.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/model_manager.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/output.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__pycache__/output.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/cli/commands.py +4416 -2295
- package/codex-lens/src/codexlens/cli/embedding_manager.py +777 -15
- package/codex-lens/src/codexlens/cli/model_manager.py +676 -0
- package/codex-lens/src/codexlens/config.py +356 -12
- package/codex-lens/src/codexlens/entities.py +4 -1
- package/codex-lens/src/codexlens/env_config.py +304 -0
- package/codex-lens/src/codexlens/indexing/__init__.py +23 -1
- package/codex-lens/src/codexlens/indexing/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/indexing/__pycache__/embedding.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/indexing/__pycache__/symbol_extractor.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/indexing/embedding.py +582 -0
- package/codex-lens/src/codexlens/indexing/symbol_extractor.py +62 -28
- package/codex-lens/src/codexlens/parsers/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/factory.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/factory.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/factory.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/tokenizer.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/tokenizer.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/factory.py +139 -10
- package/codex-lens/src/codexlens/parsers/treesitter_parser.py +487 -13
- package/codex-lens/src/codexlens/search/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/binary_searcher.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/chain_search.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/enrichment.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/graph_expander.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/hybrid_search.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/binary_searcher.py +277 -0
- package/codex-lens/src/codexlens/search/chain_search.py +1652 -8
- package/codex-lens/src/codexlens/search/enrichment.py +21 -0
- package/codex-lens/src/codexlens/search/graph_expander.py +264 -0
- package/codex-lens/src/codexlens/search/hybrid_search.py +772 -37
- package/codex-lens/src/codexlens/search/ranking.py +397 -8
- package/codex-lens/src/codexlens/semantic/SPLADE_IMPLEMENTATION.md +225 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/base.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/base.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/embedder.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/embedder.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/factory.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/gpu_support.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/litellm_embedder.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/reranker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/splade_encoder.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/splade_encoder.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/splade_encoder.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/vector_store.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/ann_index.py +654 -0
- package/codex-lens/src/codexlens/semantic/chunker.py +328 -23
- package/codex-lens/src/codexlens/semantic/factory.py +63 -3
- package/codex-lens/src/codexlens/semantic/gpu_support.py +19 -2
- package/codex-lens/src/codexlens/semantic/litellm_embedder.py +144 -144
- package/codex-lens/src/codexlens/semantic/reranker/__init__.py +25 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/api_reranker.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/api_reranker.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/api_reranker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/base.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/base.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/base.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/factory.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/factory.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/factory.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/fastembed_reranker.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/fastembed_reranker.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/fastembed_reranker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/legacy.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/legacy.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/legacy.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/litellm_reranker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/onnx_reranker.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/onnx_reranker.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/__pycache__/onnx_reranker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/reranker/api_reranker.py +403 -0
- package/codex-lens/src/codexlens/semantic/reranker/base.py +46 -0
- package/codex-lens/src/codexlens/semantic/reranker/factory.py +159 -0
- package/codex-lens/src/codexlens/semantic/reranker/fastembed_reranker.py +257 -0
- package/codex-lens/src/codexlens/semantic/reranker/legacy.py +91 -0
- package/codex-lens/src/codexlens/semantic/reranker/litellm_reranker.py +214 -0
- package/codex-lens/src/codexlens/semantic/reranker/onnx_reranker.py +268 -0
- package/codex-lens/src/codexlens/semantic/splade_encoder.py +567 -0
- package/codex-lens/src/codexlens/semantic/vector_store.py +472 -352
- package/codex-lens/src/codexlens/storage/__init__.py +3 -0
- package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/global_index.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/global_index.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/merkle_tree.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/path_mapper.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/path_mapper.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/splade_index.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/splade_index.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/splade_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/sqlite_store.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/sqlite_store.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/sqlite_store.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/sqlite_utils.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/sqlite_utils.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/vector_meta_store.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/vector_meta_store.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/vector_meta_store.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/dir_index.py +310 -12
- package/codex-lens/src/codexlens/storage/index_tree.py +240 -25
- package/codex-lens/src/codexlens/storage/merkle_tree.py +136 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_006_enhance_relationships.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_007_add_graph_neighbors.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_007_add_graph_neighbors.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_007_add_graph_neighbors.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_008_add_merkle_hashes.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_009_add_splade.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_010_add_multi_vector_chunks.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_006_enhance_relationships.py +37 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_007_add_graph_neighbors.py +47 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_008_add_merkle_hashes.py +81 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_009_add_splade.py +103 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_010_add_multi_vector_chunks.py +162 -0
- package/codex-lens/src/codexlens/storage/splade_index.py +578 -0
- package/codex-lens/src/codexlens/storage/sqlite_store.py +508 -184
- package/codex-lens/src/codexlens/storage/vector_meta_store.py +415 -0
- package/codex-lens/src/codexlens/watcher/__init__.py +17 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/__init__.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/__init__.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/events.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/events.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/events.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/file_watcher.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/file_watcher.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/file_watcher.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/incremental_indexer.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/incremental_indexer.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/incremental_indexer.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/manager.cpython-310.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/manager.cpython-312.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/__pycache__/manager.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/watcher/events.py +82 -0
- package/codex-lens/src/codexlens/watcher/file_watcher.py +347 -0
- package/codex-lens/src/codexlens/watcher/incremental_indexer.py +369 -0
- package/codex-lens/src/codexlens/watcher/manager.py +255 -0
- package/package.json +4 -1
- package/.claude/commands/workflow/docs/analyze.md +0 -1467
- package/.claude/commands/workflow/docs/copyright.md +0 -1265
- package/.claude/skills/command-guide/SKILL.md +0 -388
- package/.claude/skills/command-guide/UPDATE-GUIDELINE.md +0 -592
- package/.claude/skills/command-guide/guides/cli-tools-guide.md +0 -410
- package/.claude/skills/command-guide/guides/examples.md +0 -537
- package/.claude/skills/command-guide/guides/getting-started.md +0 -242
- package/.claude/skills/command-guide/guides/implementation-details.md +0 -1010
- package/.claude/skills/command-guide/guides/index-structure.md +0 -326
- package/.claude/skills/command-guide/guides/troubleshooting.md +0 -92
- package/.claude/skills/command-guide/guides/ui-design-workflow-guide.md +0 -316
- package/.claude/skills/command-guide/guides/workflow-patterns.md +0 -662
- package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +0 -855
- package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +0 -267
- package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +0 -182
- package/.claude/skills/command-guide/reference/agents/cli-lite-planning-agent.md +0 -446
- package/.claude/skills/command-guide/reference/agents/cli-planning-agent.md +0 -558
- package/.claude/skills/command-guide/reference/agents/code-developer.md +0 -311
- package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +0 -308
- package/.claude/skills/command-guide/reference/agents/context-search-agent.md +0 -581
- package/.claude/skills/command-guide/reference/agents/doc-generator.md +0 -330
- package/.claude/skills/command-guide/reference/agents/memory-bridge.md +0 -94
- package/.claude/skills/command-guide/reference/agents/test-context-search-agent.md +0 -400
- package/.claude/skills/command-guide/reference/agents/test-fix-agent.md +0 -344
- package/.claude/skills/command-guide/reference/agents/ui-design-agent.md +0 -593
- package/.claude/skills/command-guide/reference/agents/universal-executor.md +0 -131
- package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +0 -440
- package/.claude/skills/command-guide/reference/commands/enhance-prompt.md +0 -93
- package/.claude/skills/command-guide/reference/commands/memory/code-map-memory.md +0 -687
- package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +0 -471
- package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +0 -386
- package/.claude/skills/command-guide/reference/commands/memory/docs.md +0 -616
- package/.claude/skills/command-guide/reference/commands/memory/load-skill-memory.md +0 -182
- package/.claude/skills/command-guide/reference/commands/memory/load.md +0 -240
- package/.claude/skills/command-guide/reference/commands/memory/skill-memory.md +0 -525
- package/.claude/skills/command-guide/reference/commands/memory/style-skill-memory.md +0 -396
- package/.claude/skills/command-guide/reference/commands/memory/tech-research.md +0 -314
- package/.claude/skills/command-guide/reference/commands/memory/update-full.md +0 -332
- package/.claude/skills/command-guide/reference/commands/memory/update-related.md +0 -332
- package/.claude/skills/command-guide/reference/commands/memory/workflow-skill-memory.md +0 -517
- package/.claude/skills/command-guide/reference/commands/task/breakdown.md +0 -204
- package/.claude/skills/command-guide/reference/commands/task/create.md +0 -152
- package/.claude/skills/command-guide/reference/commands/task/execute.md +0 -270
- package/.claude/skills/command-guide/reference/commands/task/replan.md +0 -437
- package/.claude/skills/command-guide/reference/commands/version.md +0 -254
- package/.claude/skills/command-guide/reference/commands/workflow/action-plan-verify.md +0 -447
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/api-designer.md +0 -585
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +0 -452
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +0 -443
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/data-architect.md +0 -220
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/product-manager.md +0 -200
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/product-owner.md +0 -200
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/scrum-master.md +0 -200
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/subject-matter-expert.md +0 -200
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +0 -398
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/system-architect.md +0 -387
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/ui-designer.md +0 -221
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/ux-expert.md +0 -221
- package/.claude/skills/command-guide/reference/commands/workflow/execute.md +0 -465
- package/.claude/skills/command-guide/reference/commands/workflow/init.md +0 -164
- package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +0 -748
- package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +0 -664
- package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +0 -645
- package/.claude/skills/command-guide/reference/commands/workflow/plan.md +0 -551
- package/.claude/skills/command-guide/reference/commands/workflow/replan.md +0 -515
- package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +0 -606
- package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +0 -765
- package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +0 -776
- package/.claude/skills/command-guide/reference/commands/workflow/review.md +0 -298
- package/.claude/skills/command-guide/reference/commands/workflow/session/complete.md +0 -547
- package/.claude/skills/command-guide/reference/commands/workflow/session/list.md +0 -114
- package/.claude/skills/command-guide/reference/commands/workflow/session/resume.md +0 -77
- package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +0 -257
- package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +0 -460
- package/.claude/skills/command-guide/reference/commands/workflow/tdd-verify.md +0 -400
- package/.claude/skills/command-guide/reference/commands/workflow/test-cycle-execute.md +0 -498
- package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +0 -699
- package/.claude/skills/command-guide/reference/commands/workflow/test-gen.md +0 -529
- package/.claude/skills/command-guide/reference/commands/workflow/tools/conflict-resolution.md +0 -766
- package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +0 -433
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +0 -487
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +0 -518
- package/.claude/skills/command-guide/reference/commands/workflow/tools/tdd-coverage-analysis.md +0 -309
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-concept-enhanced.md +0 -163
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-context-gather.md +0 -232
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +0 -254
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/animation-extract.md +0 -1150
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/codify-style.md +0 -652
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/design-sync.md +0 -454
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/explore-auto.md +0 -678
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +0 -504
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/imitate-auto.md +0 -745
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +0 -537
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/layout-extract.md +0 -788
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/reference-page-generator.md +0 -356
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/style-extract.md +0 -773
- package/.claude/skills/command-guide/scripts/analyze_commands.py +0 -502
- package/.claude/skills/command-guide/scripts/update-index.sh +0 -130
- package/.claude/skills/command-guide/templates/issue-bug.md +0 -104
- package/.claude/skills/command-guide/templates/issue-diagnosis.md +0 -275
- package/.claude/skills/command-guide/templates/issue-feature.md +0 -97
- package/.claude/skills/command-guide/templates/issue-question.md +0 -141
|
@@ -2,68 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import json
|
|
6
|
-
import logging
|
|
7
|
-
import sqlite3
|
|
8
|
-
import threading
|
|
9
|
-
import time
|
|
10
|
-
from dataclasses import asdict
|
|
11
|
-
from pathlib import Path
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
import sqlite3
|
|
8
|
+
import threading
|
|
9
|
+
import time
|
|
10
|
+
from dataclasses import asdict
|
|
11
|
+
from pathlib import Path
|
|
12
12
|
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
|
13
13
|
|
|
14
|
-
from codexlens.entities import IndexedFile, SearchResult, Symbol
|
|
15
|
-
from codexlens.errors import StorageError
|
|
16
|
-
|
|
17
|
-
logger = logging.getLogger(__name__)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class SQLiteStore:
|
|
21
|
-
"""SQLiteStore providing FTS5 search and symbol lookup.
|
|
22
|
-
|
|
23
|
-
Implements thread-local connection pooling for improved performance.
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
# Maximum number of connections to keep in pool to prevent memory leaks
|
|
27
|
-
MAX_POOL_SIZE = 32
|
|
28
|
-
# Idle timeout in seconds (10 minutes)
|
|
29
|
-
IDLE_TIMEOUT = 600
|
|
30
|
-
# Periodic cleanup interval in seconds (5 minutes)
|
|
31
|
-
CLEANUP_INTERVAL = 300
|
|
32
|
-
|
|
33
|
-
def __init__(self, db_path: str | Path) -> None:
|
|
34
|
-
self.db_path = Path(db_path)
|
|
35
|
-
self._lock = threading.RLock()
|
|
36
|
-
self._local = threading.local()
|
|
37
|
-
self._pool_lock = threading.Lock()
|
|
38
|
-
# Pool stores (connection, last_access_time) tuples
|
|
39
|
-
self._pool: Dict[int, Tuple[sqlite3.Connection, float]] = {}
|
|
40
|
-
self._pool_generation = 0
|
|
41
|
-
self._cleanup_timer: threading.Timer | None = None
|
|
42
|
-
self._cleanup_stop_event = threading.Event()
|
|
43
|
-
self._start_cleanup_timer()
|
|
14
|
+
from codexlens.entities import IndexedFile, SearchResult, Symbol
|
|
15
|
+
from codexlens.errors import StorageError
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SQLiteStore:
|
|
21
|
+
"""SQLiteStore providing FTS5 search and symbol lookup.
|
|
22
|
+
|
|
23
|
+
Implements thread-local connection pooling for improved performance.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
# Maximum number of connections to keep in pool to prevent memory leaks
|
|
27
|
+
MAX_POOL_SIZE = 32
|
|
28
|
+
# Idle timeout in seconds (10 minutes)
|
|
29
|
+
IDLE_TIMEOUT = 600
|
|
30
|
+
# Periodic cleanup interval in seconds (5 minutes)
|
|
31
|
+
CLEANUP_INTERVAL = 300
|
|
32
|
+
|
|
33
|
+
def __init__(self, db_path: str | Path) -> None:
|
|
34
|
+
self.db_path = Path(db_path)
|
|
35
|
+
self._lock = threading.RLock()
|
|
36
|
+
self._local = threading.local()
|
|
37
|
+
self._pool_lock = threading.Lock()
|
|
38
|
+
# Pool stores (connection, last_access_time) tuples
|
|
39
|
+
self._pool: Dict[int, Tuple[sqlite3.Connection, float]] = {}
|
|
40
|
+
self._pool_generation = 0
|
|
41
|
+
self._cleanup_timer: threading.Timer | None = None
|
|
42
|
+
self._cleanup_stop_event = threading.Event()
|
|
43
|
+
self._start_cleanup_timer()
|
|
44
44
|
|
|
45
45
|
def _get_connection(self) -> sqlite3.Connection:
|
|
46
46
|
"""Get or create a thread-local database connection."""
|
|
47
47
|
thread_id = threading.get_ident()
|
|
48
48
|
current_time = time.time()
|
|
49
49
|
|
|
50
|
-
if getattr(self._local, "generation", None) == self._pool_generation:
|
|
51
|
-
conn = getattr(self._local, "conn", None)
|
|
52
|
-
if conn is not None:
|
|
53
|
-
with self._pool_lock:
|
|
54
|
-
pool_entry = self._pool.get(thread_id)
|
|
55
|
-
if pool_entry is not None:
|
|
56
|
-
pooled_conn, _ = pool_entry
|
|
57
|
-
self._pool[thread_id] = (pooled_conn, current_time)
|
|
58
|
-
self._local.conn = pooled_conn
|
|
59
|
-
return pooled_conn
|
|
60
|
-
|
|
61
|
-
# Thread-local connection is stale (e.g., cleaned up by timer).
|
|
62
|
-
self._local.conn = None
|
|
63
|
-
|
|
64
|
-
with self._pool_lock:
|
|
65
|
-
pool_entry = self._pool.get(thread_id)
|
|
66
|
-
if pool_entry is not None:
|
|
50
|
+
if getattr(self._local, "generation", None) == self._pool_generation:
|
|
51
|
+
conn = getattr(self._local, "conn", None)
|
|
52
|
+
if conn is not None:
|
|
53
|
+
with self._pool_lock:
|
|
54
|
+
pool_entry = self._pool.get(thread_id)
|
|
55
|
+
if pool_entry is not None:
|
|
56
|
+
pooled_conn, _ = pool_entry
|
|
57
|
+
self._pool[thread_id] = (pooled_conn, current_time)
|
|
58
|
+
self._local.conn = pooled_conn
|
|
59
|
+
return pooled_conn
|
|
60
|
+
|
|
61
|
+
# Thread-local connection is stale (e.g., cleaned up by timer).
|
|
62
|
+
self._local.conn = None
|
|
63
|
+
|
|
64
|
+
with self._pool_lock:
|
|
65
|
+
pool_entry = self._pool.get(thread_id)
|
|
66
|
+
if pool_entry is not None:
|
|
67
67
|
conn, _ = pool_entry
|
|
68
68
|
# Update last access time
|
|
69
69
|
self._pool[thread_id] = (conn, current_time)
|
|
@@ -85,91 +85,91 @@ class SQLiteStore:
|
|
|
85
85
|
self._local.generation = self._pool_generation
|
|
86
86
|
return conn
|
|
87
87
|
|
|
88
|
-
def _cleanup_stale_connections(self) -> None:
|
|
89
|
-
"""Remove connections for threads that no longer exist or have been idle too long."""
|
|
90
|
-
current_time = time.time()
|
|
91
|
-
# Get list of active thread IDs
|
|
92
|
-
active_threads = {t.ident for t in threading.enumerate() if t.ident is not None}
|
|
93
|
-
|
|
94
|
-
# Find connections to remove: dead threads or idle timeout exceeded
|
|
95
|
-
stale_ids: list[tuple[int, str]] = []
|
|
96
|
-
for tid, (conn, last_access) in list(self._pool.items()):
|
|
97
|
-
try:
|
|
98
|
-
is_dead_thread = tid not in active_threads
|
|
99
|
-
is_idle = (current_time - last_access) > self.IDLE_TIMEOUT
|
|
100
|
-
|
|
101
|
-
is_invalid_connection = False
|
|
102
|
-
if not is_dead_thread and not is_idle:
|
|
103
|
-
try:
|
|
104
|
-
conn.execute("SELECT 1").fetchone()
|
|
105
|
-
except sqlite3.ProgrammingError:
|
|
106
|
-
is_invalid_connection = True
|
|
107
|
-
except sqlite3.Error:
|
|
108
|
-
is_invalid_connection = True
|
|
109
|
-
|
|
110
|
-
if is_invalid_connection:
|
|
111
|
-
stale_ids.append((tid, "invalid_connection"))
|
|
112
|
-
elif is_dead_thread:
|
|
113
|
-
stale_ids.append((tid, "dead_thread"))
|
|
114
|
-
elif is_idle:
|
|
115
|
-
stale_ids.append((tid, "idle_timeout"))
|
|
116
|
-
except Exception:
|
|
117
|
-
# Never break cleanup for a single bad entry.
|
|
118
|
-
continue
|
|
119
|
-
|
|
120
|
-
# Close and remove stale connections
|
|
121
|
-
for tid, reason in stale_ids:
|
|
122
|
-
try:
|
|
123
|
-
conn, _ = self._pool[tid]
|
|
124
|
-
conn.close()
|
|
125
|
-
except Exception:
|
|
126
|
-
pass
|
|
127
|
-
del self._pool[tid]
|
|
128
|
-
logger.debug("Cleaned SQLiteStore connection for thread_id=%s (%s)", tid, reason)
|
|
129
|
-
|
|
130
|
-
def _start_cleanup_timer(self) -> None:
|
|
131
|
-
if self.CLEANUP_INTERVAL <= 0:
|
|
132
|
-
return
|
|
133
|
-
|
|
134
|
-
self._cleanup_stop_event.clear()
|
|
135
|
-
|
|
136
|
-
def tick() -> None:
|
|
137
|
-
if self._cleanup_stop_event.is_set():
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
try:
|
|
141
|
-
with self._pool_lock:
|
|
142
|
-
self._cleanup_stale_connections()
|
|
143
|
-
finally:
|
|
144
|
-
with self._pool_lock:
|
|
145
|
-
if self._cleanup_stop_event.is_set():
|
|
146
|
-
self._cleanup_timer = None
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
self._cleanup_timer = threading.Timer(self.CLEANUP_INTERVAL, tick)
|
|
150
|
-
self._cleanup_timer.daemon = True
|
|
151
|
-
self._cleanup_timer.start()
|
|
152
|
-
|
|
153
|
-
self._cleanup_timer = threading.Timer(self.CLEANUP_INTERVAL, tick)
|
|
154
|
-
self._cleanup_timer.daemon = True
|
|
155
|
-
self._cleanup_timer.start()
|
|
156
|
-
|
|
157
|
-
def _stop_cleanup_timer(self) -> None:
|
|
158
|
-
self._cleanup_stop_event.set()
|
|
159
|
-
with self._pool_lock:
|
|
160
|
-
if self._cleanup_timer is not None:
|
|
161
|
-
self._cleanup_timer.cancel()
|
|
162
|
-
self._cleanup_timer = None
|
|
163
|
-
|
|
164
|
-
def close(self) -> None:
|
|
165
|
-
"""Close all pooled connections."""
|
|
166
|
-
with self._lock:
|
|
167
|
-
self._stop_cleanup_timer()
|
|
168
|
-
with self._pool_lock:
|
|
169
|
-
for conn, _ in self._pool.values():
|
|
170
|
-
conn.close()
|
|
171
|
-
self._pool.clear()
|
|
172
|
-
self._pool_generation += 1
|
|
88
|
+
def _cleanup_stale_connections(self) -> None:
|
|
89
|
+
"""Remove connections for threads that no longer exist or have been idle too long."""
|
|
90
|
+
current_time = time.time()
|
|
91
|
+
# Get list of active thread IDs
|
|
92
|
+
active_threads = {t.ident for t in threading.enumerate() if t.ident is not None}
|
|
93
|
+
|
|
94
|
+
# Find connections to remove: dead threads or idle timeout exceeded
|
|
95
|
+
stale_ids: list[tuple[int, str]] = []
|
|
96
|
+
for tid, (conn, last_access) in list(self._pool.items()):
|
|
97
|
+
try:
|
|
98
|
+
is_dead_thread = tid not in active_threads
|
|
99
|
+
is_idle = (current_time - last_access) > self.IDLE_TIMEOUT
|
|
100
|
+
|
|
101
|
+
is_invalid_connection = False
|
|
102
|
+
if not is_dead_thread and not is_idle:
|
|
103
|
+
try:
|
|
104
|
+
conn.execute("SELECT 1").fetchone()
|
|
105
|
+
except sqlite3.ProgrammingError:
|
|
106
|
+
is_invalid_connection = True
|
|
107
|
+
except sqlite3.Error:
|
|
108
|
+
is_invalid_connection = True
|
|
109
|
+
|
|
110
|
+
if is_invalid_connection:
|
|
111
|
+
stale_ids.append((tid, "invalid_connection"))
|
|
112
|
+
elif is_dead_thread:
|
|
113
|
+
stale_ids.append((tid, "dead_thread"))
|
|
114
|
+
elif is_idle:
|
|
115
|
+
stale_ids.append((tid, "idle_timeout"))
|
|
116
|
+
except Exception:
|
|
117
|
+
# Never break cleanup for a single bad entry.
|
|
118
|
+
continue
|
|
119
|
+
|
|
120
|
+
# Close and remove stale connections
|
|
121
|
+
for tid, reason in stale_ids:
|
|
122
|
+
try:
|
|
123
|
+
conn, _ = self._pool[tid]
|
|
124
|
+
conn.close()
|
|
125
|
+
except Exception:
|
|
126
|
+
pass
|
|
127
|
+
del self._pool[tid]
|
|
128
|
+
logger.debug("Cleaned SQLiteStore connection for thread_id=%s (%s)", tid, reason)
|
|
129
|
+
|
|
130
|
+
def _start_cleanup_timer(self) -> None:
|
|
131
|
+
if self.CLEANUP_INTERVAL <= 0:
|
|
132
|
+
return
|
|
133
|
+
|
|
134
|
+
self._cleanup_stop_event.clear()
|
|
135
|
+
|
|
136
|
+
def tick() -> None:
|
|
137
|
+
if self._cleanup_stop_event.is_set():
|
|
138
|
+
return
|
|
139
|
+
|
|
140
|
+
try:
|
|
141
|
+
with self._pool_lock:
|
|
142
|
+
self._cleanup_stale_connections()
|
|
143
|
+
finally:
|
|
144
|
+
with self._pool_lock:
|
|
145
|
+
if self._cleanup_stop_event.is_set():
|
|
146
|
+
self._cleanup_timer = None
|
|
147
|
+
return
|
|
148
|
+
|
|
149
|
+
self._cleanup_timer = threading.Timer(self.CLEANUP_INTERVAL, tick)
|
|
150
|
+
self._cleanup_timer.daemon = True
|
|
151
|
+
self._cleanup_timer.start()
|
|
152
|
+
|
|
153
|
+
self._cleanup_timer = threading.Timer(self.CLEANUP_INTERVAL, tick)
|
|
154
|
+
self._cleanup_timer.daemon = True
|
|
155
|
+
self._cleanup_timer.start()
|
|
156
|
+
|
|
157
|
+
def _stop_cleanup_timer(self) -> None:
|
|
158
|
+
self._cleanup_stop_event.set()
|
|
159
|
+
with self._pool_lock:
|
|
160
|
+
if self._cleanup_timer is not None:
|
|
161
|
+
self._cleanup_timer.cancel()
|
|
162
|
+
self._cleanup_timer = None
|
|
163
|
+
|
|
164
|
+
def close(self) -> None:
|
|
165
|
+
"""Close all pooled connections."""
|
|
166
|
+
with self._lock:
|
|
167
|
+
self._stop_cleanup_timer()
|
|
168
|
+
with self._pool_lock:
|
|
169
|
+
for conn, _ in self._pool.values():
|
|
170
|
+
conn.close()
|
|
171
|
+
self._pool.clear()
|
|
172
|
+
self._pool_generation += 1
|
|
173
173
|
|
|
174
174
|
if hasattr(self._local, "conn"):
|
|
175
175
|
self._local.conn = None
|
|
@@ -329,20 +329,20 @@ class SQLiteStore:
|
|
|
329
329
|
],
|
|
330
330
|
)
|
|
331
331
|
|
|
332
|
-
conn.commit()
|
|
333
|
-
except Exception as exc:
|
|
334
|
-
try:
|
|
335
|
-
conn.rollback()
|
|
336
|
-
except Exception as rollback_exc:
|
|
337
|
-
logger.error(
|
|
338
|
-
"Rollback failed after add_files() error (%s): %s", exc, rollback_exc
|
|
339
|
-
)
|
|
340
|
-
raise exc.with_traceback(exc.__traceback__) from rollback_exc
|
|
341
|
-
raise
|
|
342
|
-
|
|
343
|
-
def remove_file(self, path: str | Path) -> bool:
|
|
344
|
-
"""Remove a file from the index."""
|
|
345
|
-
with self._lock:
|
|
332
|
+
conn.commit()
|
|
333
|
+
except Exception as exc:
|
|
334
|
+
try:
|
|
335
|
+
conn.rollback()
|
|
336
|
+
except Exception as rollback_exc:
|
|
337
|
+
logger.error(
|
|
338
|
+
"Rollback failed after add_files() error (%s): %s", exc, rollback_exc
|
|
339
|
+
)
|
|
340
|
+
raise exc.with_traceback(exc.__traceback__) from rollback_exc
|
|
341
|
+
raise
|
|
342
|
+
|
|
343
|
+
def remove_file(self, path: str | Path) -> bool:
|
|
344
|
+
"""Remove a file from the index."""
|
|
345
|
+
with self._lock:
|
|
346
346
|
conn = self._get_connection()
|
|
347
347
|
resolved_path = str(Path(path).resolve())
|
|
348
348
|
|
|
@@ -539,6 +539,27 @@ class SQLiteStore:
|
|
|
539
539
|
)
|
|
540
540
|
conn.execute("CREATE INDEX IF NOT EXISTS idx_rel_target ON code_relationships(target_qualified_name)")
|
|
541
541
|
conn.execute("CREATE INDEX IF NOT EXISTS idx_rel_source ON code_relationships(source_symbol_id)")
|
|
542
|
+
# Chunks table for multi-vector storage (cascade retrieval architecture)
|
|
543
|
+
# - embedding: Original embedding for backward compatibility
|
|
544
|
+
# - embedding_binary: 256-dim binary vector for coarse ranking
|
|
545
|
+
# - embedding_dense: 2048-dim dense vector for fine ranking
|
|
546
|
+
conn.execute(
|
|
547
|
+
"""
|
|
548
|
+
CREATE TABLE IF NOT EXISTS chunks (
|
|
549
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
550
|
+
file_path TEXT NOT NULL,
|
|
551
|
+
content TEXT NOT NULL,
|
|
552
|
+
embedding BLOB,
|
|
553
|
+
embedding_binary BLOB,
|
|
554
|
+
embedding_dense BLOB,
|
|
555
|
+
metadata TEXT,
|
|
556
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
557
|
+
)
|
|
558
|
+
"""
|
|
559
|
+
)
|
|
560
|
+
conn.execute("CREATE INDEX IF NOT EXISTS idx_chunks_file_path ON chunks(file_path)")
|
|
561
|
+
# Run migration for existing databases
|
|
562
|
+
self._migrate_chunks_table(conn)
|
|
542
563
|
conn.commit()
|
|
543
564
|
except sqlite3.DatabaseError as exc:
|
|
544
565
|
raise StorageError(f"Failed to initialize database schema: {exc}") from exc
|
|
@@ -612,10 +633,10 @@ class SQLiteStore:
|
|
|
612
633
|
"""
|
|
613
634
|
)
|
|
614
635
|
|
|
615
|
-
def _migrate_fts_to_external(self, conn: sqlite3.Connection) -> None:
|
|
616
|
-
"""Migrate legacy files_fts (with duplicated content) to external content."""
|
|
617
|
-
try:
|
|
618
|
-
conn.execute("BEGIN")
|
|
636
|
+
def _migrate_fts_to_external(self, conn: sqlite3.Connection) -> None:
|
|
637
|
+
"""Migrate legacy files_fts (with duplicated content) to external content."""
|
|
638
|
+
try:
|
|
639
|
+
conn.execute("BEGIN")
|
|
619
640
|
conn.execute("DROP TRIGGER IF EXISTS files_ai")
|
|
620
641
|
conn.execute("DROP TRIGGER IF EXISTS files_ad")
|
|
621
642
|
conn.execute("DROP TRIGGER IF EXISTS files_au")
|
|
@@ -623,30 +644,333 @@ class SQLiteStore:
|
|
|
623
644
|
conn.execute("ALTER TABLE files_fts RENAME TO files_fts_legacy")
|
|
624
645
|
self._create_external_fts(conn)
|
|
625
646
|
conn.execute("INSERT INTO files_fts(files_fts) VALUES('rebuild')")
|
|
626
|
-
conn.execute("DROP TABLE files_fts_legacy")
|
|
627
|
-
conn.commit()
|
|
628
|
-
except sqlite3.DatabaseError as exc:
|
|
629
|
-
try:
|
|
630
|
-
conn.rollback()
|
|
631
|
-
except Exception as rollback_exc:
|
|
632
|
-
logger.error(
|
|
633
|
-
"Rollback failed during FTS schema migration (%s): %s", exc, rollback_exc
|
|
634
|
-
)
|
|
635
|
-
raise exc.with_traceback(exc.__traceback__) from rollback_exc
|
|
636
|
-
|
|
637
|
-
try:
|
|
638
|
-
conn.execute("DROP TABLE IF EXISTS files_fts")
|
|
639
|
-
except Exception:
|
|
640
|
-
pass
|
|
641
|
-
|
|
642
|
-
try:
|
|
643
|
-
conn.execute("ALTER TABLE files_fts_legacy RENAME TO files_fts")
|
|
644
|
-
conn.commit()
|
|
645
|
-
except Exception:
|
|
646
|
-
pass
|
|
647
|
-
raise
|
|
648
|
-
|
|
649
|
-
try:
|
|
650
|
-
conn.execute("VACUUM")
|
|
651
|
-
except sqlite3.DatabaseError:
|
|
652
|
-
pass
|
|
647
|
+
conn.execute("DROP TABLE files_fts_legacy")
|
|
648
|
+
conn.commit()
|
|
649
|
+
except sqlite3.DatabaseError as exc:
|
|
650
|
+
try:
|
|
651
|
+
conn.rollback()
|
|
652
|
+
except Exception as rollback_exc:
|
|
653
|
+
logger.error(
|
|
654
|
+
"Rollback failed during FTS schema migration (%s): %s", exc, rollback_exc
|
|
655
|
+
)
|
|
656
|
+
raise exc.with_traceback(exc.__traceback__) from rollback_exc
|
|
657
|
+
|
|
658
|
+
try:
|
|
659
|
+
conn.execute("DROP TABLE IF EXISTS files_fts")
|
|
660
|
+
except Exception:
|
|
661
|
+
pass
|
|
662
|
+
|
|
663
|
+
try:
|
|
664
|
+
conn.execute("ALTER TABLE files_fts_legacy RENAME TO files_fts")
|
|
665
|
+
conn.commit()
|
|
666
|
+
except Exception:
|
|
667
|
+
pass
|
|
668
|
+
raise
|
|
669
|
+
|
|
670
|
+
try:
|
|
671
|
+
conn.execute("VACUUM")
|
|
672
|
+
except sqlite3.DatabaseError:
|
|
673
|
+
pass
|
|
674
|
+
|
|
675
|
+
def _migrate_chunks_table(self, conn: sqlite3.Connection) -> None:
|
|
676
|
+
"""Migrate existing chunks table to add multi-vector columns if needed.
|
|
677
|
+
|
|
678
|
+
This handles upgrading existing databases that may have the chunks table
|
|
679
|
+
without the embedding_binary and embedding_dense columns.
|
|
680
|
+
"""
|
|
681
|
+
# Check if chunks table exists
|
|
682
|
+
table_exists = conn.execute(
|
|
683
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='chunks'"
|
|
684
|
+
).fetchone()
|
|
685
|
+
|
|
686
|
+
if not table_exists:
|
|
687
|
+
# Table doesn't exist yet, nothing to migrate
|
|
688
|
+
return
|
|
689
|
+
|
|
690
|
+
# Check existing columns
|
|
691
|
+
cursor = conn.execute("PRAGMA table_info(chunks)")
|
|
692
|
+
columns = {row[1] for row in cursor.fetchall()}
|
|
693
|
+
|
|
694
|
+
# Add embedding_binary column if missing
|
|
695
|
+
if "embedding_binary" not in columns:
|
|
696
|
+
logger.info("Migrating chunks table: adding embedding_binary column")
|
|
697
|
+
conn.execute(
|
|
698
|
+
"ALTER TABLE chunks ADD COLUMN embedding_binary BLOB"
|
|
699
|
+
)
|
|
700
|
+
|
|
701
|
+
# Add embedding_dense column if missing
|
|
702
|
+
if "embedding_dense" not in columns:
|
|
703
|
+
logger.info("Migrating chunks table: adding embedding_dense column")
|
|
704
|
+
conn.execute(
|
|
705
|
+
"ALTER TABLE chunks ADD COLUMN embedding_dense BLOB"
|
|
706
|
+
)
|
|
707
|
+
|
|
708
|
+
def add_chunks(
|
|
709
|
+
self,
|
|
710
|
+
file_path: str,
|
|
711
|
+
chunks_data: List[Dict[str, Any]],
|
|
712
|
+
*,
|
|
713
|
+
embedding: Optional[List[List[float]]] = None,
|
|
714
|
+
embedding_binary: Optional[List[bytes]] = None,
|
|
715
|
+
embedding_dense: Optional[List[bytes]] = None,
|
|
716
|
+
) -> List[int]:
|
|
717
|
+
"""Add multiple chunks with multi-vector embeddings support.
|
|
718
|
+
|
|
719
|
+
This method supports the cascade retrieval architecture with three embedding types:
|
|
720
|
+
- embedding: Original dense embedding for backward compatibility
|
|
721
|
+
- embedding_binary: 256-dim binary vector for fast coarse ranking
|
|
722
|
+
- embedding_dense: 2048-dim dense vector for precise fine ranking
|
|
723
|
+
|
|
724
|
+
Args:
|
|
725
|
+
file_path: Path to the source file for all chunks.
|
|
726
|
+
chunks_data: List of dicts with 'content' and optional 'metadata' keys.
|
|
727
|
+
embedding: Optional list of dense embeddings (one per chunk).
|
|
728
|
+
embedding_binary: Optional list of binary embeddings as bytes (one per chunk).
|
|
729
|
+
embedding_dense: Optional list of dense embeddings as bytes (one per chunk).
|
|
730
|
+
|
|
731
|
+
Returns:
|
|
732
|
+
List of inserted chunk IDs.
|
|
733
|
+
|
|
734
|
+
Raises:
|
|
735
|
+
ValueError: If embedding list lengths don't match chunks_data length.
|
|
736
|
+
StorageError: If database operation fails.
|
|
737
|
+
"""
|
|
738
|
+
if not chunks_data:
|
|
739
|
+
return []
|
|
740
|
+
|
|
741
|
+
n_chunks = len(chunks_data)
|
|
742
|
+
|
|
743
|
+
# Validate embedding lengths
|
|
744
|
+
if embedding is not None and len(embedding) != n_chunks:
|
|
745
|
+
raise ValueError(
|
|
746
|
+
f"embedding length ({len(embedding)}) != chunks_data length ({n_chunks})"
|
|
747
|
+
)
|
|
748
|
+
if embedding_binary is not None and len(embedding_binary) != n_chunks:
|
|
749
|
+
raise ValueError(
|
|
750
|
+
f"embedding_binary length ({len(embedding_binary)}) != chunks_data length ({n_chunks})"
|
|
751
|
+
)
|
|
752
|
+
if embedding_dense is not None and len(embedding_dense) != n_chunks:
|
|
753
|
+
raise ValueError(
|
|
754
|
+
f"embedding_dense length ({len(embedding_dense)}) != chunks_data length ({n_chunks})"
|
|
755
|
+
)
|
|
756
|
+
|
|
757
|
+
# Prepare batch data
|
|
758
|
+
batch_data = []
|
|
759
|
+
for i, chunk in enumerate(chunks_data):
|
|
760
|
+
content = chunk.get("content", "")
|
|
761
|
+
metadata = chunk.get("metadata")
|
|
762
|
+
metadata_json = json.dumps(metadata) if metadata else None
|
|
763
|
+
|
|
764
|
+
# Convert embeddings to bytes if needed
|
|
765
|
+
emb_blob = None
|
|
766
|
+
if embedding is not None:
|
|
767
|
+
import struct
|
|
768
|
+
emb_blob = struct.pack(f"{len(embedding[i])}f", *embedding[i])
|
|
769
|
+
|
|
770
|
+
emb_binary_blob = embedding_binary[i] if embedding_binary is not None else None
|
|
771
|
+
emb_dense_blob = embedding_dense[i] if embedding_dense is not None else None
|
|
772
|
+
|
|
773
|
+
batch_data.append((
|
|
774
|
+
file_path, content, emb_blob, emb_binary_blob, emb_dense_blob, metadata_json
|
|
775
|
+
))
|
|
776
|
+
|
|
777
|
+
with self._lock:
|
|
778
|
+
conn = self._get_connection()
|
|
779
|
+
try:
|
|
780
|
+
# Get starting ID before insert
|
|
781
|
+
row = conn.execute("SELECT MAX(id) FROM chunks").fetchone()
|
|
782
|
+
start_id = (row[0] or 0) + 1
|
|
783
|
+
|
|
784
|
+
conn.executemany(
|
|
785
|
+
"""
|
|
786
|
+
INSERT INTO chunks (
|
|
787
|
+
file_path, content, embedding, embedding_binary,
|
|
788
|
+
embedding_dense, metadata
|
|
789
|
+
)
|
|
790
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
791
|
+
""",
|
|
792
|
+
batch_data
|
|
793
|
+
)
|
|
794
|
+
conn.commit()
|
|
795
|
+
|
|
796
|
+
# Calculate inserted IDs
|
|
797
|
+
return list(range(start_id, start_id + n_chunks))
|
|
798
|
+
|
|
799
|
+
except sqlite3.DatabaseError as exc:
|
|
800
|
+
raise StorageError(
|
|
801
|
+
f"Failed to add chunks: {exc}",
|
|
802
|
+
db_path=str(self.db_path),
|
|
803
|
+
operation="add_chunks",
|
|
804
|
+
) from exc
|
|
805
|
+
|
|
806
|
+
def get_binary_embeddings(
|
|
807
|
+
self, chunk_ids: List[int]
|
|
808
|
+
) -> Dict[int, Optional[bytes]]:
|
|
809
|
+
"""Get binary embeddings for specified chunk IDs.
|
|
810
|
+
|
|
811
|
+
Used for coarse ranking in cascade retrieval architecture.
|
|
812
|
+
Binary embeddings (256-dim) enable fast approximate similarity search.
|
|
813
|
+
|
|
814
|
+
Args:
|
|
815
|
+
chunk_ids: List of chunk IDs to retrieve embeddings for.
|
|
816
|
+
|
|
817
|
+
Returns:
|
|
818
|
+
Dictionary mapping chunk_id to embedding_binary bytes (or None if not set).
|
|
819
|
+
|
|
820
|
+
Raises:
|
|
821
|
+
StorageError: If database query fails.
|
|
822
|
+
"""
|
|
823
|
+
if not chunk_ids:
|
|
824
|
+
return {}
|
|
825
|
+
|
|
826
|
+
with self._lock:
|
|
827
|
+
conn = self._get_connection()
|
|
828
|
+
try:
|
|
829
|
+
placeholders = ",".join("?" * len(chunk_ids))
|
|
830
|
+
rows = conn.execute(
|
|
831
|
+
f"SELECT id, embedding_binary FROM chunks WHERE id IN ({placeholders})",
|
|
832
|
+
chunk_ids
|
|
833
|
+
).fetchall()
|
|
834
|
+
|
|
835
|
+
return {row["id"]: row["embedding_binary"] for row in rows}
|
|
836
|
+
|
|
837
|
+
except sqlite3.DatabaseError as exc:
|
|
838
|
+
raise StorageError(
|
|
839
|
+
f"Failed to get binary embeddings: {exc}",
|
|
840
|
+
db_path=str(self.db_path),
|
|
841
|
+
operation="get_binary_embeddings",
|
|
842
|
+
) from exc
|
|
843
|
+
|
|
844
|
+
def get_dense_embeddings(
|
|
845
|
+
self, chunk_ids: List[int]
|
|
846
|
+
) -> Dict[int, Optional[bytes]]:
|
|
847
|
+
"""Get dense embeddings for specified chunk IDs.
|
|
848
|
+
|
|
849
|
+
Used for fine ranking in cascade retrieval architecture.
|
|
850
|
+
Dense embeddings (2048-dim) provide high-precision similarity scoring.
|
|
851
|
+
|
|
852
|
+
Args:
|
|
853
|
+
chunk_ids: List of chunk IDs to retrieve embeddings for.
|
|
854
|
+
|
|
855
|
+
Returns:
|
|
856
|
+
Dictionary mapping chunk_id to embedding_dense bytes (or None if not set).
|
|
857
|
+
|
|
858
|
+
Raises:
|
|
859
|
+
StorageError: If database query fails.
|
|
860
|
+
"""
|
|
861
|
+
if not chunk_ids:
|
|
862
|
+
return {}
|
|
863
|
+
|
|
864
|
+
with self._lock:
|
|
865
|
+
conn = self._get_connection()
|
|
866
|
+
try:
|
|
867
|
+
placeholders = ",".join("?" * len(chunk_ids))
|
|
868
|
+
rows = conn.execute(
|
|
869
|
+
f"SELECT id, embedding_dense FROM chunks WHERE id IN ({placeholders})",
|
|
870
|
+
chunk_ids
|
|
871
|
+
).fetchall()
|
|
872
|
+
|
|
873
|
+
return {row["id"]: row["embedding_dense"] for row in rows}
|
|
874
|
+
|
|
875
|
+
except sqlite3.DatabaseError as exc:
|
|
876
|
+
raise StorageError(
|
|
877
|
+
f"Failed to get dense embeddings: {exc}",
|
|
878
|
+
db_path=str(self.db_path),
|
|
879
|
+
operation="get_dense_embeddings",
|
|
880
|
+
) from exc
|
|
881
|
+
|
|
882
|
+
def get_chunks_by_ids(
|
|
883
|
+
self, chunk_ids: List[int]
|
|
884
|
+
) -> List[Dict[str, Any]]:
|
|
885
|
+
"""Get chunk data for specified IDs.
|
|
886
|
+
|
|
887
|
+
Args:
|
|
888
|
+
chunk_ids: List of chunk IDs to retrieve.
|
|
889
|
+
|
|
890
|
+
Returns:
|
|
891
|
+
List of chunk dictionaries with id, file_path, content, metadata.
|
|
892
|
+
|
|
893
|
+
Raises:
|
|
894
|
+
StorageError: If database query fails.
|
|
895
|
+
"""
|
|
896
|
+
if not chunk_ids:
|
|
897
|
+
return []
|
|
898
|
+
|
|
899
|
+
with self._lock:
|
|
900
|
+
conn = self._get_connection()
|
|
901
|
+
try:
|
|
902
|
+
placeholders = ",".join("?" * len(chunk_ids))
|
|
903
|
+
rows = conn.execute(
|
|
904
|
+
f"""
|
|
905
|
+
SELECT id, file_path, content, metadata, created_at
|
|
906
|
+
FROM chunks
|
|
907
|
+
WHERE id IN ({placeholders})
|
|
908
|
+
""",
|
|
909
|
+
chunk_ids
|
|
910
|
+
).fetchall()
|
|
911
|
+
|
|
912
|
+
results = []
|
|
913
|
+
for row in rows:
|
|
914
|
+
metadata = None
|
|
915
|
+
if row["metadata"]:
|
|
916
|
+
try:
|
|
917
|
+
metadata = json.loads(row["metadata"])
|
|
918
|
+
except json.JSONDecodeError:
|
|
919
|
+
pass
|
|
920
|
+
|
|
921
|
+
results.append({
|
|
922
|
+
"id": row["id"],
|
|
923
|
+
"file_path": row["file_path"],
|
|
924
|
+
"content": row["content"],
|
|
925
|
+
"metadata": metadata,
|
|
926
|
+
"created_at": row["created_at"],
|
|
927
|
+
})
|
|
928
|
+
|
|
929
|
+
return results
|
|
930
|
+
|
|
931
|
+
except sqlite3.DatabaseError as exc:
|
|
932
|
+
raise StorageError(
|
|
933
|
+
f"Failed to get chunks: {exc}",
|
|
934
|
+
db_path=str(self.db_path),
|
|
935
|
+
operation="get_chunks_by_ids",
|
|
936
|
+
) from exc
|
|
937
|
+
|
|
938
|
+
def delete_chunks_by_file(self, file_path: str) -> int:
|
|
939
|
+
"""Delete all chunks for a given file path.
|
|
940
|
+
|
|
941
|
+
Args:
|
|
942
|
+
file_path: Path to the source file.
|
|
943
|
+
|
|
944
|
+
Returns:
|
|
945
|
+
Number of deleted chunks.
|
|
946
|
+
|
|
947
|
+
Raises:
|
|
948
|
+
StorageError: If database operation fails.
|
|
949
|
+
"""
|
|
950
|
+
with self._lock:
|
|
951
|
+
conn = self._get_connection()
|
|
952
|
+
try:
|
|
953
|
+
cursor = conn.execute(
|
|
954
|
+
"DELETE FROM chunks WHERE file_path = ?",
|
|
955
|
+
(file_path,)
|
|
956
|
+
)
|
|
957
|
+
conn.commit()
|
|
958
|
+
return cursor.rowcount
|
|
959
|
+
|
|
960
|
+
except sqlite3.DatabaseError as exc:
|
|
961
|
+
raise StorageError(
|
|
962
|
+
f"Failed to delete chunks: {exc}",
|
|
963
|
+
db_path=str(self.db_path),
|
|
964
|
+
operation="delete_chunks_by_file",
|
|
965
|
+
) from exc
|
|
966
|
+
|
|
967
|
+
def count_chunks(self) -> int:
|
|
968
|
+
"""Count total chunks in store.
|
|
969
|
+
|
|
970
|
+
Returns:
|
|
971
|
+
Total number of chunks.
|
|
972
|
+
"""
|
|
973
|
+
with self._lock:
|
|
974
|
+
conn = self._get_connection()
|
|
975
|
+
row = conn.execute("SELECT COUNT(*) AS c FROM chunks").fetchone()
|
|
976
|
+
return int(row["c"]) if row else 0
|