claude-code-workflow 6.2.1 → 6.2.2
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 +10 -0
- package/.claude/agents/action-planning-agent.md +857 -0
- package/.claude/agents/cli-execution-agent.md +267 -0
- package/.claude/agents/cli-explore-agent.md +182 -0
- package/.claude/agents/cli-lite-planning-agent.md +446 -0
- package/.claude/agents/cli-planning-agent.md +558 -0
- package/.claude/agents/code-developer.md +311 -0
- package/.claude/agents/conceptual-planning-agent.md +308 -0
- package/.claude/agents/context-search-agent.md +581 -0
- package/.claude/agents/doc-generator.md +330 -0
- package/.claude/agents/memory-bridge.md +94 -0
- package/.claude/agents/test-context-search-agent.md +400 -0
- package/.claude/agents/test-fix-agent.md +344 -0
- package/.claude/agents/ui-design-agent.md +593 -0
- package/.claude/agents/universal-executor.md +131 -0
- package/.claude/commands/clean.md +516 -0
- package/.claude/commands/cli/cli-init.md +440 -0
- package/.claude/commands/enhance-prompt.md +93 -0
- package/.claude/commands/memory/code-map-memory.md +687 -0
- package/.claude/commands/memory/compact.md +383 -0
- package/.claude/commands/memory/docs-full-cli.md +471 -0
- package/.claude/commands/memory/docs-related-cli.md +386 -0
- package/.claude/commands/memory/docs.md +615 -0
- package/.claude/commands/memory/load-skill-memory.md +182 -0
- package/.claude/commands/memory/load.md +240 -0
- package/.claude/commands/memory/skill-memory.md +525 -0
- package/.claude/commands/memory/style-skill-memory.md +396 -0
- package/.claude/commands/memory/tech-research-rules.md +310 -0
- package/.claude/commands/memory/update-full.md +332 -0
- package/.claude/commands/memory/update-related.md +332 -0
- package/.claude/commands/memory/workflow-skill-memory.md +517 -0
- package/.claude/commands/task/breakdown.md +204 -0
- package/.claude/commands/task/create.md +152 -0
- package/.claude/commands/task/execute.md +270 -0
- package/.claude/commands/task/replan.md +437 -0
- package/.claude/commands/version.md +254 -0
- package/.claude/commands/workflow/action-plan-verify.md +447 -0
- package/.claude/commands/workflow/brainstorm/api-designer.md +587 -0
- package/.claude/commands/workflow/brainstorm/artifacts.md +453 -0
- package/.claude/commands/workflow/brainstorm/auto-parallel.md +443 -0
- package/.claude/commands/workflow/brainstorm/data-architect.md +220 -0
- package/.claude/commands/workflow/brainstorm/product-manager.md +200 -0
- package/.claude/commands/workflow/brainstorm/product-owner.md +200 -0
- package/.claude/commands/workflow/brainstorm/scrum-master.md +200 -0
- package/.claude/commands/workflow/brainstorm/subject-matter-expert.md +200 -0
- package/.claude/commands/workflow/brainstorm/synthesis.md +398 -0
- package/.claude/commands/workflow/brainstorm/system-architect.md +389 -0
- package/.claude/commands/workflow/brainstorm/ui-designer.md +221 -0
- package/.claude/commands/workflow/brainstorm/ux-expert.md +221 -0
- package/.claude/commands/workflow/debug.md +321 -0
- package/.claude/commands/workflow/execute.md +475 -0
- package/.claude/commands/workflow/init.md +165 -0
- package/.claude/commands/workflow/lite-execute.md +792 -0
- package/.claude/commands/workflow/lite-fix.md +623 -0
- package/.claude/commands/workflow/lite-plan.md +610 -0
- package/.claude/commands/workflow/plan.md +551 -0
- package/.claude/commands/workflow/replan.md +515 -0
- package/.claude/commands/workflow/review-fix.md +606 -0
- package/.claude/commands/workflow/review-module-cycle.md +767 -0
- package/.claude/commands/workflow/review-session-cycle.md +778 -0
- package/.claude/commands/workflow/review.md +297 -0
- package/.claude/commands/workflow/session/complete.md +153 -0
- package/.claude/commands/workflow/session/list.md +96 -0
- package/.claude/commands/workflow/session/resume.md +61 -0
- package/.claude/commands/workflow/session/start.md +200 -0
- package/.claude/commands/workflow/tdd-plan.md +460 -0
- package/.claude/commands/workflow/tdd-verify.md +400 -0
- package/.claude/commands/workflow/test-cycle-execute.md +500 -0
- package/.claude/commands/workflow/test-fix-gen.md +699 -0
- package/.claude/commands/workflow/test-gen.md +529 -0
- package/.claude/commands/workflow/tools/conflict-resolution.md +766 -0
- package/.claude/commands/workflow/tools/context-gather.md +436 -0
- package/.claude/commands/workflow/tools/task-generate-agent.md +490 -0
- package/.claude/commands/workflow/tools/task-generate-tdd.md +526 -0
- package/.claude/commands/workflow/tools/tdd-coverage-analysis.md +309 -0
- package/.claude/commands/workflow/tools/test-concept-enhanced.md +164 -0
- package/.claude/commands/workflow/tools/test-context-gather.md +236 -0
- package/.claude/commands/workflow/tools/test-task-generate.md +257 -0
- package/.claude/commands/workflow/ui-design/animation-extract.md +1150 -0
- package/.claude/commands/workflow/ui-design/codify-style.md +652 -0
- package/.claude/commands/workflow/ui-design/design-sync.md +454 -0
- package/.claude/commands/workflow/ui-design/explore-auto.md +678 -0
- package/.claude/commands/workflow/ui-design/generate.md +504 -0
- package/.claude/commands/workflow/ui-design/imitate-auto.md +745 -0
- package/.claude/commands/workflow/ui-design/import-from-code.md +540 -0
- package/.claude/commands/workflow/ui-design/layout-extract.md +788 -0
- package/.claude/commands/workflow/ui-design/reference-page-generator.md +356 -0
- package/.claude/commands/workflow/ui-design/style-extract.md +773 -0
- package/.claude/skills/command-guide/SKILL.md +388 -0
- package/.claude/skills/command-guide/UPDATE-GUIDELINE.md +592 -0
- package/.claude/skills/command-guide/guides/cli-tools-guide.md +410 -0
- package/.claude/skills/command-guide/guides/examples.md +537 -0
- package/.claude/skills/command-guide/guides/getting-started.md +242 -0
- package/.claude/skills/command-guide/guides/implementation-details.md +1010 -0
- package/.claude/skills/command-guide/guides/index-structure.md +326 -0
- package/.claude/skills/command-guide/guides/troubleshooting.md +92 -0
- package/.claude/skills/command-guide/guides/ui-design-workflow-guide.md +316 -0
- package/.claude/skills/command-guide/guides/workflow-patterns.md +662 -0
- package/.claude/skills/command-guide/index/all-commands.json +772 -0
- package/.claude/skills/command-guide/index/by-category.json +800 -0
- package/.claude/skills/command-guide/index/by-use-case.json +786 -0
- package/.claude/skills/command-guide/index/command-relationships.json +307 -0
- package/.claude/skills/command-guide/index/essential-commands.json +112 -0
- package/.claude/skills/command-guide/reference/agents/action-planning-agent.md +857 -0
- package/.claude/skills/command-guide/reference/agents/cli-execution-agent.md +267 -0
- package/.claude/skills/command-guide/reference/agents/cli-explore-agent.md +182 -0
- package/.claude/skills/command-guide/reference/agents/cli-lite-planning-agent.md +446 -0
- package/.claude/skills/command-guide/reference/agents/cli-planning-agent.md +558 -0
- package/.claude/skills/command-guide/reference/agents/code-developer.md +311 -0
- package/.claude/skills/command-guide/reference/agents/conceptual-planning-agent.md +308 -0
- package/.claude/skills/command-guide/reference/agents/context-search-agent.md +581 -0
- package/.claude/skills/command-guide/reference/agents/doc-generator.md +330 -0
- package/.claude/skills/command-guide/reference/agents/memory-bridge.md +94 -0
- package/.claude/skills/command-guide/reference/agents/test-context-search-agent.md +400 -0
- package/.claude/skills/command-guide/reference/agents/test-fix-agent.md +344 -0
- package/.claude/skills/command-guide/reference/agents/ui-design-agent.md +593 -0
- package/.claude/skills/command-guide/reference/agents/universal-executor.md +131 -0
- package/.claude/skills/command-guide/reference/commands/cli/cli-init.md +440 -0
- package/.claude/skills/command-guide/reference/commands/enhance-prompt.md +93 -0
- package/.claude/skills/command-guide/reference/commands/memory/code-map-memory.md +687 -0
- package/.claude/skills/command-guide/reference/commands/memory/docs-full-cli.md +471 -0
- package/.claude/skills/command-guide/reference/commands/memory/docs-related-cli.md +386 -0
- package/.claude/skills/command-guide/reference/commands/memory/docs.md +616 -0
- package/.claude/skills/command-guide/reference/commands/memory/load-skill-memory.md +182 -0
- package/.claude/skills/command-guide/reference/commands/memory/load.md +240 -0
- package/.claude/skills/command-guide/reference/commands/memory/skill-memory.md +525 -0
- package/.claude/skills/command-guide/reference/commands/memory/style-skill-memory.md +396 -0
- package/.claude/skills/command-guide/reference/commands/memory/tech-research.md +314 -0
- package/.claude/skills/command-guide/reference/commands/memory/update-full.md +332 -0
- package/.claude/skills/command-guide/reference/commands/memory/update-related.md +332 -0
- package/.claude/skills/command-guide/reference/commands/memory/workflow-skill-memory.md +517 -0
- package/.claude/skills/command-guide/reference/commands/task/breakdown.md +204 -0
- package/.claude/skills/command-guide/reference/commands/task/create.md +152 -0
- package/.claude/skills/command-guide/reference/commands/task/execute.md +270 -0
- package/.claude/skills/command-guide/reference/commands/task/replan.md +437 -0
- package/.claude/skills/command-guide/reference/commands/version.md +254 -0
- package/.claude/skills/command-guide/reference/commands/workflow/action-plan-verify.md +447 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/api-designer.md +585 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/artifacts.md +452 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/auto-parallel.md +443 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/data-architect.md +220 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/product-manager.md +200 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/product-owner.md +200 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/scrum-master.md +200 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/subject-matter-expert.md +200 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/synthesis.md +398 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/system-architect.md +387 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/ui-designer.md +221 -0
- package/.claude/skills/command-guide/reference/commands/workflow/brainstorm/ux-expert.md +221 -0
- package/.claude/skills/command-guide/reference/commands/workflow/execute.md +465 -0
- package/.claude/skills/command-guide/reference/commands/workflow/init.md +164 -0
- package/.claude/skills/command-guide/reference/commands/workflow/lite-execute.md +748 -0
- package/.claude/skills/command-guide/reference/commands/workflow/lite-fix.md +664 -0
- package/.claude/skills/command-guide/reference/commands/workflow/lite-plan.md +645 -0
- package/.claude/skills/command-guide/reference/commands/workflow/plan.md +551 -0
- package/.claude/skills/command-guide/reference/commands/workflow/replan.md +515 -0
- package/.claude/skills/command-guide/reference/commands/workflow/review-fix.md +606 -0
- package/.claude/skills/command-guide/reference/commands/workflow/review-module-cycle.md +765 -0
- package/.claude/skills/command-guide/reference/commands/workflow/review-session-cycle.md +776 -0
- package/.claude/skills/command-guide/reference/commands/workflow/review.md +298 -0
- package/.claude/skills/command-guide/reference/commands/workflow/session/complete.md +547 -0
- package/.claude/skills/command-guide/reference/commands/workflow/session/list.md +114 -0
- package/.claude/skills/command-guide/reference/commands/workflow/session/resume.md +77 -0
- package/.claude/skills/command-guide/reference/commands/workflow/session/start.md +257 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tdd-plan.md +460 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tdd-verify.md +400 -0
- package/.claude/skills/command-guide/reference/commands/workflow/test-cycle-execute.md +498 -0
- package/.claude/skills/command-guide/reference/commands/workflow/test-fix-gen.md +699 -0
- package/.claude/skills/command-guide/reference/commands/workflow/test-gen.md +529 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/conflict-resolution.md +766 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/context-gather.md +434 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-agent.md +487 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/task-generate-tdd.md +525 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/tdd-coverage-analysis.md +309 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-concept-enhanced.md +163 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-context-gather.md +235 -0
- package/.claude/skills/command-guide/reference/commands/workflow/tools/test-task-generate.md +256 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/animation-extract.md +1150 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/codify-style.md +652 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/design-sync.md +454 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/explore-auto.md +678 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/generate.md +504 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/imitate-auto.md +745 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/import-from-code.md +537 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/layout-extract.md +788 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/reference-page-generator.md +356 -0
- package/.claude/skills/command-guide/reference/commands/workflow/ui-design/style-extract.md +773 -0
- package/.claude/skills/command-guide/scripts/analyze_commands.py +502 -0
- package/.claude/skills/command-guide/scripts/update-index.sh +130 -0
- package/.claude/skills/command-guide/templates/issue-bug.md +104 -0
- package/.claude/skills/command-guide/templates/issue-diagnosis.md +275 -0
- package/.claude/skills/command-guide/templates/issue-feature.md +97 -0
- package/.claude/skills/command-guide/templates/issue-question.md +141 -0
- package/.claude/skills/prompt-enhancer/SKILL.md +124 -0
- package/.claude/workflows/_template-compare-matrix.html +692 -0
- package/.claude/workflows/chinese-response.md +38 -0
- package/.claude/workflows/cli-templates/fix-plan-template.json +75 -0
- package/.claude/workflows/cli-templates/fix-progress-template.json +48 -0
- package/.claude/workflows/cli-templates/memory/style-skill-memory/skill-md-template.md +299 -0
- package/.claude/workflows/cli-templates/planning-roles/data-architect.md +120 -0
- package/.claude/workflows/cli-templates/planning-roles/product-manager.md +119 -0
- package/.claude/workflows/cli-templates/planning-roles/product-owner.md +261 -0
- package/.claude/workflows/cli-templates/planning-roles/scrum-master.md +186 -0
- package/.claude/workflows/cli-templates/planning-roles/subject-matter-expert.md +281 -0
- package/.claude/workflows/cli-templates/planning-roles/synthesis-role.md +414 -0
- package/.claude/workflows/cli-templates/planning-roles/system-architect.md +106 -0
- package/.claude/workflows/cli-templates/planning-roles/test-strategist.md +124 -0
- package/.claude/workflows/cli-templates/planning-roles/ui-designer.md +379 -0
- package/.claude/workflows/cli-templates/planning-roles/ux-expert.md +240 -0
- package/.claude/workflows/cli-templates/prompts/analysis/01-diagnose-bug-root-cause.txt +127 -0
- package/.claude/workflows/cli-templates/prompts/analysis/01-trace-code-execution.txt +115 -0
- package/.claude/workflows/cli-templates/prompts/analysis/02-analyze-code-patterns.txt +37 -0
- package/.claude/workflows/cli-templates/prompts/analysis/02-analyze-technical-document.txt +33 -0
- package/.claude/workflows/cli-templates/prompts/analysis/02-review-architecture.txt +29 -0
- package/.claude/workflows/cli-templates/prompts/analysis/02-review-code-quality.txt +28 -0
- package/.claude/workflows/cli-templates/prompts/analysis/03-analyze-performance.txt +29 -0
- package/.claude/workflows/cli-templates/prompts/analysis/03-assess-security-risks.txt +29 -0
- package/.claude/workflows/cli-templates/prompts/analysis/03-review-quality-standards.txt +29 -0
- package/.claude/workflows/cli-templates/prompts/development/02-generate-tests.txt +70 -0
- package/.claude/workflows/cli-templates/prompts/development/02-implement-component-ui.txt +55 -0
- package/.claude/workflows/cli-templates/prompts/development/02-implement-feature.txt +58 -0
- package/.claude/workflows/cli-templates/prompts/development/02-refactor-codebase.txt +55 -0
- package/.claude/workflows/cli-templates/prompts/development/03-debug-runtime-issues.txt +55 -0
- package/.claude/workflows/cli-templates/prompts/documentation/api.txt +15 -0
- package/.claude/workflows/cli-templates/prompts/documentation/folder-navigation.txt +27 -0
- package/.claude/workflows/cli-templates/prompts/documentation/module-readme.txt +49 -0
- package/.claude/workflows/cli-templates/prompts/documentation/project-architecture.txt +41 -0
- package/.claude/workflows/cli-templates/prompts/documentation/project-examples.txt +35 -0
- package/.claude/workflows/cli-templates/prompts/documentation/project-readme.txt +35 -0
- package/.claude/workflows/cli-templates/prompts/memory/02-document-module-structure.txt +165 -0
- package/.claude/workflows/cli-templates/prompts/planning/01-plan-architecture-design.txt +109 -0
- package/.claude/workflows/cli-templates/prompts/planning/02-breakdown-task-steps.txt +30 -0
- package/.claude/workflows/cli-templates/prompts/planning/02-design-component-spec.txt +28 -0
- package/.claude/workflows/cli-templates/prompts/planning/03-evaluate-concept-feasibility.txt +127 -0
- package/.claude/workflows/cli-templates/prompts/planning/03-plan-migration-strategy.txt +30 -0
- package/.claude/workflows/cli-templates/prompts/rules/rule-api.txt +122 -0
- package/.claude/workflows/cli-templates/prompts/rules/rule-components.txt +122 -0
- package/.claude/workflows/cli-templates/prompts/rules/rule-config.txt +89 -0
- package/.claude/workflows/cli-templates/prompts/rules/rule-core.txt +60 -0
- package/.claude/workflows/cli-templates/prompts/rules/rule-patterns.txt +70 -0
- package/.claude/workflows/cli-templates/prompts/rules/rule-testing.txt +81 -0
- package/.claude/workflows/cli-templates/prompts/rules/tech-rules-agent-prompt.txt +89 -0
- package/.claude/workflows/cli-templates/prompts/tech/tech-module-format.txt +359 -0
- package/.claude/workflows/cli-templates/prompts/tech/tech-skill-index.txt +185 -0
- package/.claude/workflows/cli-templates/prompts/test/test-concept-analysis.txt +179 -0
- package/.claude/workflows/cli-templates/prompts/universal/00-universal-creative-style.txt +95 -0
- package/.claude/workflows/cli-templates/prompts/universal/00-universal-rigorous-style.txt +92 -0
- package/.claude/workflows/cli-templates/prompts/verification/codex-technical.txt +28 -0
- package/.claude/workflows/cli-templates/prompts/verification/cross-validation.txt +28 -0
- package/.claude/workflows/cli-templates/prompts/verification/gemini-strategic.txt +27 -0
- package/.claude/workflows/cli-templates/prompts/workflow/analysis-results-structure.txt +224 -0
- package/.claude/workflows/cli-templates/prompts/workflow/codex-feasibility-validation.txt +176 -0
- package/.claude/workflows/cli-templates/prompts/workflow/gemini-solution-design.txt +131 -0
- package/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt +286 -0
- package/.claude/workflows/cli-templates/prompts/workflow/skill-aggregation.txt +172 -0
- package/.claude/workflows/cli-templates/prompts/workflow/skill-conflict-patterns.txt +94 -0
- package/.claude/workflows/cli-templates/prompts/workflow/skill-index.txt +224 -0
- package/.claude/workflows/cli-templates/prompts/workflow/skill-lessons-learned.txt +94 -0
- package/.claude/workflows/cli-templates/prompts/workflow/skill-sessions-timeline.txt +53 -0
- package/.claude/workflows/cli-templates/prompts/workflow/task-json-agent-mode.txt +123 -0
- package/.claude/workflows/cli-templates/prompts/workflow/task-json-cli-mode.txt +182 -0
- package/.claude/workflows/cli-templates/protocols/analysis-protocol.md +112 -0
- package/.claude/workflows/cli-templates/protocols/write-protocol.md +201 -0
- package/.claude/workflows/cli-templates/schemas/conflict-resolution-schema.json +137 -0
- package/.claude/workflows/cli-templates/schemas/debug-log-json-schema.json +127 -0
- package/.claude/workflows/cli-templates/schemas/diagnosis-json-schema.json +234 -0
- package/.claude/workflows/cli-templates/schemas/explore-json-schema.json +124 -0
- package/.claude/workflows/cli-templates/schemas/fix-plan-json-schema.json +298 -0
- package/.claude/workflows/cli-templates/schemas/plan-json-schema.json +244 -0
- package/.claude/workflows/cli-templates/schemas/project-json-schema.json +221 -0
- package/.claude/workflows/cli-templates/schemas/review-deep-dive-results-schema.json +82 -0
- package/.claude/workflows/cli-templates/schemas/review-dimension-results-schema.json +51 -0
- package/.claude/workflows/cli-templates/tech-stacks/go-dev.md +91 -0
- package/.claude/workflows/cli-templates/tech-stacks/java-dev.md +107 -0
- package/.claude/workflows/cli-templates/tech-stacks/javascript-dev.md +58 -0
- package/.claude/workflows/cli-templates/tech-stacks/python-dev.md +79 -0
- package/.claude/workflows/cli-templates/tech-stacks/react-dev.md +103 -0
- package/.claude/workflows/cli-templates/tech-stacks/typescript-dev.md +83 -0
- package/.claude/workflows/cli-templates/ui-design/systems/animation-tokens.json +247 -0
- package/.claude/workflows/cli-templates/ui-design/systems/design-tokens.json +342 -0
- package/.claude/workflows/cli-templates/ui-design/systems/layout-templates.json +145 -0
- package/.claude/workflows/cli-tools-usage.md +526 -0
- package/.claude/workflows/coding-philosophy.md +70 -0
- package/.claude/workflows/context-tools.md +84 -0
- package/.claude/workflows/file-modification.md +64 -0
- package/.claude/workflows/review-directory-specification.md +336 -0
- package/.claude/workflows/task-core.md +214 -0
- package/.claude/workflows/tool-strategy.md +216 -0
- package/.claude/workflows/windows-platform.md +16 -0
- package/.claude/workflows/workflow-architecture.md +942 -0
- package/.codex/AGENTS.md +63 -0
- package/.codex/prompts/debug.md +318 -0
- package/.codex/prompts/execute.md +273 -0
- package/.codex/prompts/lite-execute.md +164 -0
- package/.codex/prompts/lite-plan.md +469 -0
- package/.codex/prompts.zip +0 -0
- package/.gemini/GEMINI.md +25 -0
- package/.qwen/QWEN.md +25 -0
- package/LICENSE +21 -0
- package/README.md +294 -145
- package/ccw/README.md +145 -0
- package/ccw/package.json +65 -0
- package/codex-lens/pyproject.toml +48 -0
- package/codex-lens/src/codexlens/.workflow/.cli-history/history.db +0 -0
- package/codex-lens/src/codexlens/__init__.py +28 -0
- package/codex-lens/src/codexlens/__main__.py +14 -0
- package/codex-lens/src/codexlens/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/__main__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/config.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/entities.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/__pycache__/errors.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/cli/__init__.py +27 -0
- package/codex-lens/src/codexlens/cli/__pycache__/__init__.cpython-313.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-313.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-313.pyc +0 -0
- package/codex-lens/src/codexlens/cli/commands.py +1931 -0
- package/codex-lens/src/codexlens/cli/embedding_manager.py +620 -0
- package/codex-lens/src/codexlens/cli/model_manager.py +289 -0
- package/codex-lens/src/codexlens/cli/output.py +124 -0
- package/codex-lens/src/codexlens/config.py +201 -0
- package/codex-lens/src/codexlens/entities.py +121 -0
- package/codex-lens/src/codexlens/errors.py +55 -0
- package/codex-lens/src/codexlens/indexing/README.md +77 -0
- package/codex-lens/src/codexlens/indexing/__init__.py +4 -0
- package/codex-lens/src/codexlens/indexing/__pycache__/__init__.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/symbol_extractor.py +243 -0
- package/codex-lens/src/codexlens/parsers/__init__.py +8 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/encoding.cpython-313.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-313.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/__pycache__/treesitter_parser.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/parsers/encoding.py +202 -0
- package/codex-lens/src/codexlens/parsers/factory.py +256 -0
- package/codex-lens/src/codexlens/parsers/tokenizer.py +98 -0
- package/codex-lens/src/codexlens/parsers/treesitter_parser.py +335 -0
- package/codex-lens/src/codexlens/search/__init__.py +15 -0
- package/codex-lens/src/codexlens/search/__pycache__/__init__.cpython-313.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__/hybrid_search.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/query_parser.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/__pycache__/ranking.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/search/chain_search.py +647 -0
- package/codex-lens/src/codexlens/search/enrichment.py +150 -0
- package/codex-lens/src/codexlens/search/hybrid_search.py +313 -0
- package/codex-lens/src/codexlens/search/query_parser.py +242 -0
- package/codex-lens/src/codexlens/search/ranking.py +274 -0
- package/codex-lens/src/codexlens/semantic/__init__.py +39 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/ann_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/chunker.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/code_extractor.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/embedder.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/graph_analyzer.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/semantic/__pycache__/llm_enhancer.cpython-313.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 +414 -0
- package/codex-lens/src/codexlens/semantic/chunker.py +448 -0
- package/codex-lens/src/codexlens/semantic/code_extractor.py +274 -0
- package/codex-lens/src/codexlens/semantic/embedder.py +185 -0
- package/codex-lens/src/codexlens/semantic/vector_store.py +955 -0
- package/codex-lens/src/codexlens/storage/__init__.py +29 -0
- package/codex-lens/src/codexlens/storage/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/dir_index.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/file_cache.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/index_tree.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/migration_manager.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/path_mapper.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/__pycache__/registry.cpython-313.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-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/dir_index.py +1850 -0
- package/codex-lens/src/codexlens/storage/file_cache.py +32 -0
- package/codex-lens/src/codexlens/storage/index_tree.py +776 -0
- package/codex-lens/src/codexlens/storage/migration_manager.py +154 -0
- package/codex-lens/src/codexlens/storage/migrations/__init__.py +1 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/__init__.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_001_normalize_keywords.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_002_add_token_metadata.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_003_code_relationships.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_004_dual_fts.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/__pycache__/migration_005_cleanup_unused_fields.cpython-313.pyc +0 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_001_normalize_keywords.py +123 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_002_add_token_metadata.py +48 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_004_dual_fts.py +232 -0
- package/codex-lens/src/codexlens/storage/migrations/migration_005_cleanup_unused_fields.py +196 -0
- package/codex-lens/src/codexlens/storage/path_mapper.py +274 -0
- package/codex-lens/src/codexlens/storage/registry.py +670 -0
- package/codex-lens/src/codexlens/storage/sqlite_store.py +576 -0
- package/codex-lens/src/codexlens/storage/sqlite_utils.py +64 -0
- package/package.json +37 -32
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -219
- package/dist/cli.js.map +0 -1
- package/dist/commands/cli.d.ts +0 -32
- package/dist/commands/cli.d.ts.map +0 -1
- package/dist/commands/cli.js +0 -619
- package/dist/commands/cli.js.map +0 -1
- package/dist/commands/core-memory.d.ts +0 -32
- package/dist/commands/core-memory.d.ts.map +0 -1
- package/dist/commands/core-memory.js +0 -640
- package/dist/commands/core-memory.js.map +0 -1
- package/dist/commands/hook.d.ts +0 -16
- package/dist/commands/hook.d.ts.map +0 -1
- package/dist/commands/hook.js +0 -276
- package/dist/commands/hook.js.map +0 -1
- package/dist/commands/install.d.ts +0 -12
- package/dist/commands/install.d.ts.map +0 -1
- package/dist/commands/install.js +0 -443
- package/dist/commands/install.js.map +0 -1
- package/dist/commands/list.d.ts +0 -5
- package/dist/commands/list.d.ts.map +0 -1
- package/dist/commands/list.js +0 -32
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -57
- package/dist/commands/memory.d.ts.map +0 -1
- package/dist/commands/memory.js +0 -890
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/serve.d.ts +0 -12
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -63
- package/dist/commands/serve.js.map +0 -1
- package/dist/commands/session-path-resolver.d.ts +0 -45
- package/dist/commands/session-path-resolver.d.ts.map +0 -1
- package/dist/commands/session-path-resolver.js +0 -302
- package/dist/commands/session-path-resolver.js.map +0 -1
- package/dist/commands/session.d.ts +0 -12
- package/dist/commands/session.d.ts.map +0 -1
- package/dist/commands/session.js +0 -954
- package/dist/commands/session.js.map +0 -1
- package/dist/commands/stop.d.ts +0 -11
- package/dist/commands/stop.d.ts.map +0 -1
- package/dist/commands/stop.js +0 -96
- package/dist/commands/stop.js.map +0 -1
- package/dist/commands/tool.d.ts +0 -29
- package/dist/commands/tool.d.ts.map +0 -1
- package/dist/commands/tool.js +0 -173
- package/dist/commands/tool.js.map +0 -1
- package/dist/commands/uninstall.d.ts +0 -9
- package/dist/commands/uninstall.d.ts.map +0 -1
- package/dist/commands/uninstall.js +0 -239
- package/dist/commands/uninstall.js.map +0 -1
- package/dist/commands/upgrade.d.ts +0 -10
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/upgrade.js +0 -288
- package/dist/commands/upgrade.js.map +0 -1
- package/dist/commands/view.d.ts +0 -14
- package/dist/commands/view.d.ts.map +0 -1
- package/dist/commands/view.js +0 -100
- package/dist/commands/view.js.map +0 -1
- package/dist/config/storage-paths.d.ts +0 -184
- package/dist/config/storage-paths.d.ts.map +0 -1
- package/dist/config/storage-paths.js +0 -536
- package/dist/config/storage-paths.js.map +0 -1
- package/dist/core/cache-manager.d.ts +0 -80
- package/dist/core/cache-manager.d.ts.map +0 -1
- package/dist/core/cache-manager.js +0 -260
- package/dist/core/cache-manager.js.map +0 -1
- package/dist/core/claude-freshness.d.ts +0 -53
- package/dist/core/claude-freshness.d.ts.map +0 -1
- package/dist/core/claude-freshness.js +0 -232
- package/dist/core/claude-freshness.js.map +0 -1
- package/dist/core/core-memory-store.d.ts +0 -320
- package/dist/core/core-memory-store.d.ts.map +0 -1
- package/dist/core/core-memory-store.js +0 -1177
- package/dist/core/core-memory-store.js.map +0 -1
- package/dist/core/dashboard-generator-patch.d.ts +0 -2
- package/dist/core/dashboard-generator-patch.d.ts.map +0 -1
- package/dist/core/dashboard-generator-patch.js +0 -48
- package/dist/core/dashboard-generator-patch.js.map +0 -1
- package/dist/core/dashboard-generator.d.ts +0 -8
- package/dist/core/dashboard-generator.d.ts.map +0 -1
- package/dist/core/dashboard-generator.js +0 -695
- package/dist/core/dashboard-generator.js.map +0 -1
- package/dist/core/data-aggregator.d.ts +0 -145
- package/dist/core/data-aggregator.d.ts.map +0 -1
- package/dist/core/data-aggregator.js +0 -416
- package/dist/core/data-aggregator.js.map +0 -1
- package/dist/core/history-importer.d.ts +0 -102
- package/dist/core/history-importer.d.ts.map +0 -1
- package/dist/core/history-importer.js +0 -493
- package/dist/core/history-importer.js.map +0 -1
- package/dist/core/lite-scanner-complete.d.ts +0 -81
- package/dist/core/lite-scanner-complete.d.ts.map +0 -1
- package/dist/core/lite-scanner-complete.js +0 -368
- package/dist/core/lite-scanner-complete.js.map +0 -1
- package/dist/core/lite-scanner.d.ts +0 -81
- package/dist/core/lite-scanner.d.ts.map +0 -1
- package/dist/core/lite-scanner.js +0 -368
- package/dist/core/lite-scanner.js.map +0 -1
- package/dist/core/manifest.d.ts +0 -88
- package/dist/core/manifest.d.ts.map +0 -1
- package/dist/core/manifest.js +0 -214
- package/dist/core/manifest.js.map +0 -1
- package/dist/core/memory-embedder-bridge.d.ts +0 -83
- package/dist/core/memory-embedder-bridge.d.ts.map +0 -1
- package/dist/core/memory-embedder-bridge.js +0 -181
- package/dist/core/memory-embedder-bridge.js.map +0 -1
- package/dist/core/memory-store.d.ts +0 -249
- package/dist/core/memory-store.d.ts.map +0 -1
- package/dist/core/memory-store.js +0 -781
- package/dist/core/memory-store.js.map +0 -1
- package/dist/core/routes/ccw-routes.d.ts +0 -20
- package/dist/core/routes/ccw-routes.d.ts.map +0 -1
- package/dist/core/routes/ccw-routes.js +0 -70
- package/dist/core/routes/ccw-routes.js.map +0 -1
- package/dist/core/routes/claude-routes.d.ts +0 -19
- package/dist/core/routes/claude-routes.d.ts.map +0 -1
- package/dist/core/routes/claude-routes.js +0 -1017
- package/dist/core/routes/claude-routes.js.map +0 -1
- package/dist/core/routes/cli-routes.d.ts +0 -20
- package/dist/core/routes/cli-routes.d.ts.map +0 -1
- package/dist/core/routes/cli-routes.js +0 -468
- package/dist/core/routes/cli-routes.js.map +0 -1
- package/dist/core/routes/codexlens-routes.d.ts +0 -20
- package/dist/core/routes/codexlens-routes.d.ts.map +0 -1
- package/dist/core/routes/codexlens-routes.js +0 -754
- package/dist/core/routes/codexlens-routes.js.map +0 -1
- package/dist/core/routes/core-memory-routes.d.ts +0 -21
- package/dist/core/routes/core-memory-routes.d.ts.map +0 -1
- package/dist/core/routes/core-memory-routes.js +0 -520
- package/dist/core/routes/core-memory-routes.js.map +0 -1
- package/dist/core/routes/files-routes.d.ts +0 -20
- package/dist/core/routes/files-routes.d.ts.map +0 -1
- package/dist/core/routes/files-routes.js +0 -374
- package/dist/core/routes/files-routes.js.map +0 -1
- package/dist/core/routes/graph-routes.d.ts +0 -20
- package/dist/core/routes/graph-routes.d.ts.map +0 -1
- package/dist/core/routes/graph-routes.js +0 -517
- package/dist/core/routes/graph-routes.js.map +0 -1
- package/dist/core/routes/help-routes.d.ts +0 -20
- package/dist/core/routes/help-routes.d.ts.map +0 -1
- package/dist/core/routes/help-routes.js +0 -250
- package/dist/core/routes/help-routes.js.map +0 -1
- package/dist/core/routes/hooks-routes.d.ts +0 -21
- package/dist/core/routes/hooks-routes.d.ts.map +0 -1
- package/dist/core/routes/hooks-routes.js +0 -346
- package/dist/core/routes/hooks-routes.js.map +0 -1
- package/dist/core/routes/mcp-routes.d.ts +0 -20
- package/dist/core/routes/mcp-routes.d.ts.map +0 -1
- package/dist/core/routes/mcp-routes.js +0 -1129
- package/dist/core/routes/mcp-routes.js.map +0 -1
- package/dist/core/routes/mcp-templates-db.d.ts +0 -54
- package/dist/core/routes/mcp-templates-db.d.ts.map +0 -1
- package/dist/core/routes/mcp-templates-db.js +0 -226
- package/dist/core/routes/mcp-templates-db.js.map +0 -1
- package/dist/core/routes/memory-routes.d.ts +0 -21
- package/dist/core/routes/memory-routes.d.ts.map +0 -1
- package/dist/core/routes/memory-routes.js +0 -1095
- package/dist/core/routes/memory-routes.js.map +0 -1
- package/dist/core/routes/rules-routes.d.ts +0 -20
- package/dist/core/routes/rules-routes.d.ts.map +0 -1
- package/dist/core/routes/rules-routes.js +0 -442
- package/dist/core/routes/rules-routes.js.map +0 -1
- package/dist/core/routes/session-routes.d.ts +0 -20
- package/dist/core/routes/session-routes.d.ts.map +0 -1
- package/dist/core/routes/session-routes.js +0 -423
- package/dist/core/routes/session-routes.js.map +0 -1
- package/dist/core/routes/skills-routes.d.ts +0 -20
- package/dist/core/routes/skills-routes.d.ts.map +0 -1
- package/dist/core/routes/skills-routes.js +0 -533
- package/dist/core/routes/skills-routes.js.map +0 -1
- package/dist/core/routes/status-routes.d.ts +0 -20
- package/dist/core/routes/status-routes.d.ts.map +0 -1
- package/dist/core/routes/status-routes.js +0 -38
- package/dist/core/routes/status-routes.js.map +0 -1
- package/dist/core/routes/system-routes.d.ts +0 -22
- package/dist/core/routes/system-routes.d.ts.map +0 -1
- package/dist/core/routes/system-routes.js +0 -354
- package/dist/core/routes/system-routes.js.map +0 -1
- package/dist/core/server.d.ts +0 -17
- package/dist/core/server.d.ts.map +0 -1
- package/dist/core/server.js +0 -386
- package/dist/core/server.js.map +0 -1
- package/dist/core/session-clustering-service.d.ts +0 -153
- package/dist/core/session-clustering-service.d.ts.map +0 -1
- package/dist/core/session-clustering-service.js +0 -1065
- package/dist/core/session-clustering-service.js.map +0 -1
- package/dist/core/session-scanner.d.ts +0 -32
- package/dist/core/session-scanner.d.ts.map +0 -1
- package/dist/core/session-scanner.js +0 -253
- package/dist/core/session-scanner.js.map +0 -1
- package/dist/core/websocket.d.ts +0 -23
- package/dist/core/websocket.d.ts.map +0 -1
- package/dist/core/websocket.js +0 -168
- package/dist/core/websocket.js.map +0 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/mcp-server/index.d.ts +0 -7
- package/dist/mcp-server/index.d.ts.map +0 -1
- package/dist/mcp-server/index.js +0 -157
- package/dist/mcp-server/index.js.map +0 -1
- package/dist/tools/classify-folders.d.ts +0 -26
- package/dist/tools/classify-folders.d.ts.map +0 -1
- package/dist/tools/classify-folders.js +0 -201
- package/dist/tools/classify-folders.js.map +0 -1
- package/dist/tools/cli-config-manager.d.ts +0 -62
- package/dist/tools/cli-config-manager.d.ts.map +0 -1
- package/dist/tools/cli-config-manager.js +0 -221
- package/dist/tools/cli-config-manager.js.map +0 -1
- package/dist/tools/cli-executor.d.ts +0 -373
- package/dist/tools/cli-executor.d.ts.map +0 -1
- package/dist/tools/cli-executor.js +0 -1625
- package/dist/tools/cli-executor.js.map +0 -1
- package/dist/tools/cli-history-store.d.ts +0 -330
- package/dist/tools/cli-history-store.d.ts.map +0 -1
- package/dist/tools/cli-history-store.js +0 -916
- package/dist/tools/cli-history-store.js.map +0 -1
- package/dist/tools/codex-lens.d.ts +0 -118
- package/dist/tools/codex-lens.d.ts.map +0 -1
- package/dist/tools/codex-lens.js +0 -962
- package/dist/tools/codex-lens.js.map +0 -1
- package/dist/tools/convert-tokens-to-css.d.ts +0 -14
- package/dist/tools/convert-tokens-to-css.d.ts.map +0 -1
- package/dist/tools/convert-tokens-to-css.js +0 -244
- package/dist/tools/convert-tokens-to-css.js.map +0 -1
- package/dist/tools/core-memory.d.ts +0 -66
- package/dist/tools/core-memory.d.ts.map +0 -1
- package/dist/tools/core-memory.js +0 -324
- package/dist/tools/core-memory.js.map +0 -1
- package/dist/tools/detect-changed-modules.d.ts +0 -24
- package/dist/tools/detect-changed-modules.d.ts.map +0 -1
- package/dist/tools/detect-changed-modules.js +0 -277
- package/dist/tools/detect-changed-modules.js.map +0 -1
- package/dist/tools/discover-design-files.d.ts +0 -36
- package/dist/tools/discover-design-files.d.ts.map +0 -1
- package/dist/tools/discover-design-files.js +0 -147
- package/dist/tools/discover-design-files.js.map +0 -1
- package/dist/tools/edit-file.d.ts +0 -28
- package/dist/tools/edit-file.d.ts.map +0 -1
- package/dist/tools/edit-file.js +0 -479
- package/dist/tools/edit-file.js.map +0 -1
- package/dist/tools/generate-module-docs.d.ts +0 -22
- package/dist/tools/generate-module-docs.d.ts.map +0 -1
- package/dist/tools/generate-module-docs.js +0 -379
- package/dist/tools/generate-module-docs.js.map +0 -1
- package/dist/tools/get-modules-by-depth.d.ts +0 -15
- package/dist/tools/get-modules-by-depth.d.ts.map +0 -1
- package/dist/tools/get-modules-by-depth.js +0 -296
- package/dist/tools/get-modules-by-depth.js.map +0 -1
- package/dist/tools/index.d.ts +0 -55
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -304
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/native-session-discovery.d.ts +0 -97
- package/dist/tools/native-session-discovery.d.ts.map +0 -1
- package/dist/tools/native-session-discovery.js +0 -700
- package/dist/tools/native-session-discovery.js.map +0 -1
- package/dist/tools/notifier.d.ts +0 -50
- package/dist/tools/notifier.d.ts.map +0 -1
- package/dist/tools/notifier.js +0 -90
- package/dist/tools/notifier.js.map +0 -1
- package/dist/tools/read-file.d.ts +0 -32
- package/dist/tools/read-file.d.ts.map +0 -1
- package/dist/tools/read-file.js +0 -329
- package/dist/tools/read-file.js.map +0 -1
- package/dist/tools/resume-strategy.d.ts +0 -48
- package/dist/tools/resume-strategy.d.ts.map +0 -1
- package/dist/tools/resume-strategy.js +0 -248
- package/dist/tools/resume-strategy.js.map +0 -1
- package/dist/tools/session-content-parser.d.ts +0 -58
- package/dist/tools/session-content-parser.d.ts.map +0 -1
- package/dist/tools/session-content-parser.js +0 -420
- package/dist/tools/session-content-parser.js.map +0 -1
- package/dist/tools/session-manager.d.ts +0 -9
- package/dist/tools/session-manager.d.ts.map +0 -1
- package/dist/tools/session-manager.js +0 -834
- package/dist/tools/session-manager.js.map +0 -1
- package/dist/tools/smart-context.d.ts +0 -35
- package/dist/tools/smart-context.d.ts.map +0 -1
- package/dist/tools/smart-context.js +0 -182
- package/dist/tools/smart-context.js.map +0 -1
- package/dist/tools/smart-search.d.ts +0 -105
- package/dist/tools/smart-search.d.ts.map +0 -1
- package/dist/tools/smart-search.js +0 -1753
- package/dist/tools/smart-search.js.map +0 -1
- package/dist/tools/storage-manager.d.ts +0 -114
- package/dist/tools/storage-manager.d.ts.map +0 -1
- package/dist/tools/storage-manager.js +0 -392
- package/dist/tools/storage-manager.js.map +0 -1
- package/dist/tools/ui-generate-preview.d.ts +0 -39
- package/dist/tools/ui-generate-preview.d.ts.map +0 -1
- package/dist/tools/ui-generate-preview.js +0 -300
- package/dist/tools/ui-generate-preview.js.map +0 -1
- package/dist/tools/ui-instantiate-prototypes.d.ts +0 -75
- package/dist/tools/ui-instantiate-prototypes.d.ts.map +0 -1
- package/dist/tools/ui-instantiate-prototypes.js +0 -256
- package/dist/tools/ui-instantiate-prototypes.js.map +0 -1
- package/dist/tools/update-module-claude.d.ts +0 -80
- package/dist/tools/update-module-claude.d.ts.map +0 -1
- package/dist/tools/update-module-claude.js +0 -351
- package/dist/tools/update-module-claude.js.map +0 -1
- package/dist/tools/write-file.d.ts +0 -19
- package/dist/tools/write-file.d.ts.map +0 -1
- package/dist/tools/write-file.js +0 -193
- package/dist/tools/write-file.js.map +0 -1
- package/dist/types/config.d.ts +0 -11
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -2
- package/dist/types/config.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +0 -1
- package/dist/types/session.d.ts +0 -20
- package/dist/types/session.d.ts.map +0 -1
- package/dist/types/session.js +0 -2
- package/dist/types/session.js.map +0 -1
- package/dist/types/tool.d.ts +0 -36
- package/dist/types/tool.d.ts.map +0 -1
- package/dist/types/tool.js +0 -11
- package/dist/types/tool.js.map +0 -1
- package/dist/utils/browser-launcher.d.ts +0 -13
- package/dist/utils/browser-launcher.d.ts.map +0 -1
- package/dist/utils/browser-launcher.js +0 -60
- package/dist/utils/browser-launcher.js.map +0 -1
- package/dist/utils/file-utils.d.ts +0 -25
- package/dist/utils/file-utils.d.ts.map +0 -1
- package/dist/utils/file-utils.js +0 -48
- package/dist/utils/file-utils.js.map +0 -1
- package/dist/utils/path-resolver.d.ts +0 -80
- package/dist/utils/path-resolver.d.ts.map +0 -1
- package/dist/utils/path-resolver.js +0 -260
- package/dist/utils/path-resolver.js.map +0 -1
- package/dist/utils/path-validator.d.ts +0 -49
- package/dist/utils/path-validator.d.ts.map +0 -1
- package/dist/utils/path-validator.js +0 -123
- package/dist/utils/path-validator.js.map +0 -1
- package/dist/utils/ui.d.ts +0 -62
- package/dist/utils/ui.d.ts.map +0 -1
- package/dist/utils/ui.js +0 -129
- package/dist/utils/ui.js.map +0 -1
- /package/{bin → ccw/bin}/ccw-mcp.js +0 -0
- /package/{bin → ccw/bin}/ccw.js +0 -0
- /package/{src → ccw/src}/.workflow/.cli-history/history.db +0 -0
- /package/{src → ccw/src}/.workflow/.cli-history/history.db-shm +0 -0
- /package/{src → ccw/src}/.workflow/.cli-history/history.db-wal +0 -0
- /package/{src → ccw/src}/cli.ts +0 -0
- /package/{src → ccw/src}/commands/cli.ts +0 -0
- /package/{src → ccw/src}/commands/core-memory.ts +0 -0
- /package/{src → ccw/src}/commands/hook.ts +0 -0
- /package/{src → ccw/src}/commands/install.ts +0 -0
- /package/{src → ccw/src}/commands/list.ts +0 -0
- /package/{src → ccw/src}/commands/memory.ts +0 -0
- /package/{src → ccw/src}/commands/serve.ts +0 -0
- /package/{src → ccw/src}/commands/session-path-resolver.ts +0 -0
- /package/{src → ccw/src}/commands/session.ts +0 -0
- /package/{src → ccw/src}/commands/stop.ts +0 -0
- /package/{src → ccw/src}/commands/tool.ts +0 -0
- /package/{src → ccw/src}/commands/uninstall.ts +0 -0
- /package/{src → ccw/src}/commands/upgrade.ts +0 -0
- /package/{src → ccw/src}/commands/view.ts +0 -0
- /package/{src → ccw/src}/config/storage-paths.ts +0 -0
- /package/{src → ccw/src}/core/cache-manager.ts +0 -0
- /package/{src → ccw/src}/core/claude-freshness.ts +0 -0
- /package/{src → ccw/src}/core/core-memory-store.ts +0 -0
- /package/{src → ccw/src}/core/dashboard-generator-patch.ts +0 -0
- /package/{src → ccw/src}/core/dashboard-generator.ts +0 -0
- /package/{src → ccw/src}/core/data-aggregator.ts +0 -0
- /package/{src → ccw/src}/core/history-importer.ts +0 -0
- /package/{src → ccw/src}/core/lite-scanner-complete.ts +0 -0
- /package/{src → ccw/src}/core/lite-scanner.ts +0 -0
- /package/{src → ccw/src}/core/manifest.ts +0 -0
- /package/{src → ccw/src}/core/memory-embedder-bridge.ts +0 -0
- /package/{src → ccw/src}/core/memory-store.ts +0 -0
- /package/{src → ccw/src}/core/routes/ccw-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/claude-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/cli-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/codexlens-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/core-memory-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/files-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/graph-routes.md +0 -0
- /package/{src → ccw/src}/core/routes/graph-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/help-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/hooks-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/mcp-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/mcp-routes.ts.backup +0 -0
- /package/{src → ccw/src}/core/routes/mcp-templates-db.ts +0 -0
- /package/{src → ccw/src}/core/routes/memory-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/rules-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/session-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/skills-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/status-routes.ts +0 -0
- /package/{src → ccw/src}/core/routes/system-routes.ts +0 -0
- /package/{src → ccw/src}/core/server.ts +0 -0
- /package/{src → ccw/src}/core/session-clustering-service.ts +0 -0
- /package/{src → ccw/src}/core/session-scanner.ts +0 -0
- /package/{src → ccw/src}/core/websocket.ts +0 -0
- /package/{src → ccw/src}/index.ts +0 -0
- /package/{src → ccw/src}/mcp-server/index.ts +0 -0
- /package/{src → ccw/src}/templates/assets/css/github-dark.min.css +0 -0
- /package/{src → ccw/src}/templates/assets/css/github.min.css +0 -0
- /package/{src → ccw/src}/templates/assets/js/cytoscape.min.js +0 -0
- /package/{src → ccw/src}/templates/assets/js/d3.min.js +0 -0
- /package/{src → ccw/src}/templates/assets/js/highlight.min.js +0 -0
- /package/{src → ccw/src}/templates/assets/js/lucide.min.js +0 -0
- /package/{src → ccw/src}/templates/assets/js/marked.min.js +0 -0
- /package/{src → ccw/src}/templates/assets/js/tailwind.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/01-base.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/02-session.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/03-tasks.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/04-lite-tasks.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/05-context.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/06-cards.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/07-managers.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/08-review.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/09-explorer.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/10-cli-status.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/11-cli-history.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/12-cli-legacy.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/13-cli-ccw.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/14-cli-modals.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/15-cli-endpoints.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/16-cli-session.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/17-cli-conversation.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/18-cli-settings.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/19-cli-native-session.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/20-cli-taskqueue.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/21-cli-toolmgmt.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/22-cli-semantic.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/23-memory.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/24-prompt-history.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/25-skills-rules.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/26-claude-manager.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/27-graph-explorer.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/28-mcp-manager.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/29-help.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-css/30-core-memory.css +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/api.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/_conflict_tab.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/_exp_helpers.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/_review_tab.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/carousel.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/cli-history.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/cli-status.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/flowchart.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/global-notifications.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/hook-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/index-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/mcp-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/modals.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/navigation.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/notifications.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/sidebar.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/storage-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/tabs-context.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/tabs-other.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/task-drawer-core.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/task-drawer-renderers.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/task-queue-sidebar.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/theme.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/components/version-check.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/help-i18n.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/i18n.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/main.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/state.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/utils.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/claude-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/cli-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/codexlens-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/core-memory-clusters.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/core-memory.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/explorer.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/fix-session.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/graph-explorer.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/help.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/history.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/home.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/hook-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/lite-tasks.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/mcp-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/mcp-manager.js.backup +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/mcp-manager.js.new +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/memory.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/project-overview.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/prompt-history.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/review-session.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/rules-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/session-detail.js +0 -0
- /package/{src → ccw/src}/templates/dashboard-js/views/skills-manager.js +0 -0
- /package/{src → ccw/src}/templates/dashboard.html +0 -0
- /package/{src → ccw/src}/templates/hooks-config-example.json +0 -0
- /package/{src → ccw/src}/templates/review-cycle-dashboard.html +0 -0
- /package/{src → ccw/src}/templates/workflow-dashboard.html +0 -0
- /package/{src → ccw/src}/tools/classify-folders.ts +0 -0
- /package/{src → ccw/src}/tools/cli-config-manager.ts +0 -0
- /package/{src → ccw/src}/tools/cli-executor.ts +0 -0
- /package/{src → ccw/src}/tools/cli-history-store.ts +0 -0
- /package/{src → ccw/src}/tools/codex-lens.ts +0 -0
- /package/{src → ccw/src}/tools/convert-tokens-to-css.ts +0 -0
- /package/{src → ccw/src}/tools/core-memory.ts +0 -0
- /package/{src → ccw/src}/tools/detect-changed-modules.ts +0 -0
- /package/{src → ccw/src}/tools/discover-design-files.ts +0 -0
- /package/{src → ccw/src}/tools/edit-file.ts +0 -0
- /package/{src → ccw/src}/tools/generate-module-docs.ts +0 -0
- /package/{src → ccw/src}/tools/get-modules-by-depth.ts +0 -0
- /package/{src → ccw/src}/tools/index.ts +0 -0
- /package/{src → ccw/src}/tools/native-session-discovery.ts +0 -0
- /package/{src → ccw/src}/tools/notifier.ts +0 -0
- /package/{src → ccw/src}/tools/read-file.ts +0 -0
- /package/{src → ccw/src}/tools/resume-strategy.ts +0 -0
- /package/{src → ccw/src}/tools/session-content-parser.ts +0 -0
- /package/{src → ccw/src}/tools/session-manager.ts +0 -0
- /package/{src → ccw/src}/tools/smart-context.ts +0 -0
- /package/{src → ccw/src}/tools/smart-search.ts +0 -0
- /package/{src → ccw/src}/tools/smart-search.ts.backup +0 -0
- /package/{src → ccw/src}/tools/storage-manager.ts +0 -0
- /package/{src → ccw/src}/tools/ui-generate-preview.js +0 -0
- /package/{src → ccw/src}/tools/ui-instantiate-prototypes.js +0 -0
- /package/{src → ccw/src}/tools/update-module-claude.js +0 -0
- /package/{src → ccw/src}/tools/write-file.ts +0 -0
- /package/{src → ccw/src}/types/config.ts +0 -0
- /package/{src → ccw/src}/types/index.ts +0 -0
- /package/{src → ccw/src}/types/session.ts +0 -0
- /package/{src → ccw/src}/types/tool.ts +0 -0
- /package/{src → ccw/src}/utils/browser-launcher.ts +0 -0
- /package/{src → ccw/src}/utils/file-utils.ts +0 -0
- /package/{src → ccw/src}/utils/path-resolver.ts +0 -0
- /package/{src → ccw/src}/utils/path-validator.ts +0 -0
- /package/{src → ccw/src}/utils/ui.ts +0 -0
|
@@ -1,1095 +0,0 @@
|
|
|
1
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, unlinkSync } from 'fs';
|
|
2
|
-
import { join, isAbsolute, extname } from 'path';
|
|
3
|
-
import { homedir } from 'os';
|
|
4
|
-
import { getMemoryStore } from '../memory-store.js';
|
|
5
|
-
import { executeCliTool } from '../../tools/cli-executor.js';
|
|
6
|
-
/**
|
|
7
|
-
* Derive prompt intent from text
|
|
8
|
-
*/
|
|
9
|
-
function derivePromptIntent(text) {
|
|
10
|
-
const lower = text.toLowerCase();
|
|
11
|
-
// Implementation/coding patterns
|
|
12
|
-
if (/实现|implement|create|add|build|write|develop|make/.test(lower))
|
|
13
|
-
return 'implement';
|
|
14
|
-
if (/修复|fix|bug|error|issue|problem|解决/.test(lower))
|
|
15
|
-
return 'fix';
|
|
16
|
-
if (/重构|refactor|optimize|improve|clean/.test(lower))
|
|
17
|
-
return 'refactor';
|
|
18
|
-
if (/测试|test|spec|coverage/.test(lower))
|
|
19
|
-
return 'test';
|
|
20
|
-
// Analysis patterns
|
|
21
|
-
if (/分析|analyze|review|check|examine|audit/.test(lower))
|
|
22
|
-
return 'analyze';
|
|
23
|
-
if (/解释|explain|what|how|why|understand/.test(lower))
|
|
24
|
-
return 'explain';
|
|
25
|
-
if (/搜索|search|find|look|where|locate/.test(lower))
|
|
26
|
-
return 'search';
|
|
27
|
-
// Documentation patterns
|
|
28
|
-
if (/文档|document|readme|comment|注释/.test(lower))
|
|
29
|
-
return 'document';
|
|
30
|
-
// Planning patterns
|
|
31
|
-
if (/计划|plan|design|architect|strategy/.test(lower))
|
|
32
|
-
return 'plan';
|
|
33
|
-
// Configuration patterns
|
|
34
|
-
if (/配置|config|setup|install|设置/.test(lower))
|
|
35
|
-
return 'configure';
|
|
36
|
-
// Default
|
|
37
|
-
return 'general';
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Calculate prompt quality score (0-100)
|
|
41
|
-
*/
|
|
42
|
-
function calculateQualityScore(text) {
|
|
43
|
-
let score = 50; // Base score
|
|
44
|
-
// Length factors
|
|
45
|
-
const length = text.length;
|
|
46
|
-
if (length > 50 && length < 500)
|
|
47
|
-
score += 15;
|
|
48
|
-
else if (length >= 500 && length < 1000)
|
|
49
|
-
score += 10;
|
|
50
|
-
else if (length < 20)
|
|
51
|
-
score -= 20;
|
|
52
|
-
// Specificity indicators
|
|
53
|
-
if (/file|path|function|class|method|variable/i.test(text))
|
|
54
|
-
score += 10;
|
|
55
|
-
if (/src\/|\.ts|\.js|\.py|\.go/i.test(text))
|
|
56
|
-
score += 10;
|
|
57
|
-
// Context indicators
|
|
58
|
-
if (/when|after|before|because|since/i.test(text))
|
|
59
|
-
score += 5;
|
|
60
|
-
// Action clarity
|
|
61
|
-
if (/please|要|请|帮|help/i.test(text))
|
|
62
|
-
score += 5;
|
|
63
|
-
// Structure indicators
|
|
64
|
-
if (/\d+\.|•|-\s/.test(text))
|
|
65
|
-
score += 10; // Lists
|
|
66
|
-
// Cap at 100
|
|
67
|
-
return Math.min(100, Math.max(0, score));
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Handle Memory API routes
|
|
71
|
-
* @returns true if route was handled, false otherwise
|
|
72
|
-
*/
|
|
73
|
-
export async function handleMemoryRoutes(ctx) {
|
|
74
|
-
const { pathname, url, req, res, initialPath, handlePostRequest, broadcastToClients } = ctx;
|
|
75
|
-
// API: Memory Module - Track entity access
|
|
76
|
-
if (pathname === '/api/memory/track' && req.method === 'POST') {
|
|
77
|
-
handlePostRequest(req, res, async (body) => {
|
|
78
|
-
const { type, action, value, sessionId, metadata, path: projectPath } = body;
|
|
79
|
-
if (!type || !action || !value) {
|
|
80
|
-
return { error: 'type, action, and value are required', status: 400 };
|
|
81
|
-
}
|
|
82
|
-
const basePath = projectPath || initialPath;
|
|
83
|
-
try {
|
|
84
|
-
const memoryStore = getMemoryStore(basePath);
|
|
85
|
-
const now = new Date().toISOString();
|
|
86
|
-
// Normalize the value
|
|
87
|
-
const normalizedValue = value.toLowerCase().trim();
|
|
88
|
-
// Upsert entity
|
|
89
|
-
const entityId = memoryStore.upsertEntity({
|
|
90
|
-
type,
|
|
91
|
-
value,
|
|
92
|
-
normalized_value: normalizedValue,
|
|
93
|
-
first_seen_at: now,
|
|
94
|
-
last_seen_at: now,
|
|
95
|
-
metadata: metadata ? JSON.stringify(metadata) : undefined
|
|
96
|
-
});
|
|
97
|
-
// Log access
|
|
98
|
-
memoryStore.logAccess({
|
|
99
|
-
entity_id: entityId,
|
|
100
|
-
action,
|
|
101
|
-
session_id: sessionId,
|
|
102
|
-
timestamp: now,
|
|
103
|
-
context_summary: metadata?.context
|
|
104
|
-
});
|
|
105
|
-
// Update stats
|
|
106
|
-
memoryStore.updateStats(entityId, action);
|
|
107
|
-
// Calculate new heat score
|
|
108
|
-
const heatScore = memoryStore.calculateHeatScore(entityId);
|
|
109
|
-
const stats = memoryStore.getStats(entityId);
|
|
110
|
-
// Broadcast MEMORY_UPDATED event via WebSocket
|
|
111
|
-
broadcastToClients({
|
|
112
|
-
type: 'MEMORY_UPDATED',
|
|
113
|
-
payload: {
|
|
114
|
-
entity: { id: entityId, type, value },
|
|
115
|
-
stats: {
|
|
116
|
-
read_count: stats?.read_count || 0,
|
|
117
|
-
write_count: stats?.write_count || 0,
|
|
118
|
-
mention_count: stats?.mention_count || 0,
|
|
119
|
-
heat_score: heatScore
|
|
120
|
-
},
|
|
121
|
-
timestamp: now
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
return {
|
|
125
|
-
success: true,
|
|
126
|
-
entity_id: entityId,
|
|
127
|
-
heat_score: heatScore
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
return { error: error.message, status: 500 };
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
// API: Memory Module - Get native Claude history from ~/.claude/history.jsonl
|
|
137
|
-
if (pathname === '/api/memory/native-history') {
|
|
138
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
139
|
-
const limit = parseInt(url.searchParams.get('limit') || '100', 10);
|
|
140
|
-
const historyFile = join(homedir(), '.claude', 'history.jsonl');
|
|
141
|
-
try {
|
|
142
|
-
if (!existsSync(historyFile)) {
|
|
143
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
144
|
-
res.end(JSON.stringify({ prompts: [], total: 0, message: 'No history file found' }));
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
const content = readFileSync(historyFile, 'utf8');
|
|
148
|
-
const lines = content.trim().split('\n').filter(line => line.trim());
|
|
149
|
-
const allPrompts = [];
|
|
150
|
-
for (const line of lines) {
|
|
151
|
-
try {
|
|
152
|
-
const entry = JSON.parse(line);
|
|
153
|
-
// Filter by project if specified
|
|
154
|
-
if (projectPath && entry.project) {
|
|
155
|
-
const normalizedProject = entry.project.replace(/\\/g, '/').toLowerCase();
|
|
156
|
-
const normalizedPath = projectPath.replace(/\\/g, '/').toLowerCase();
|
|
157
|
-
if (!normalizedProject.includes(normalizedPath) && !normalizedPath.includes(normalizedProject)) {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
allPrompts.push({
|
|
162
|
-
id: `${entry.sessionId}-${entry.timestamp}`,
|
|
163
|
-
text: entry.display || '',
|
|
164
|
-
timestamp: new Date(entry.timestamp).toISOString(),
|
|
165
|
-
project: entry.project || '',
|
|
166
|
-
session_id: entry.sessionId || '',
|
|
167
|
-
pasted_contents: entry.pastedContents || {},
|
|
168
|
-
// Derive intent from content keywords
|
|
169
|
-
intent: derivePromptIntent(entry.display || ''),
|
|
170
|
-
quality_score: calculateQualityScore(entry.display || '')
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (parseError) {
|
|
174
|
-
// Skip malformed lines
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
// Sort by timestamp descending
|
|
178
|
-
allPrompts.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
179
|
-
// Apply limit
|
|
180
|
-
const prompts = allPrompts.slice(0, limit);
|
|
181
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
182
|
-
res.end(JSON.stringify({ prompts, total: allPrompts.length }));
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
186
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
// API: Memory Module - Get prompt history
|
|
191
|
-
if (pathname === '/api/memory/prompts') {
|
|
192
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
193
|
-
const limit = parseInt(url.searchParams.get('limit') || '50', 10);
|
|
194
|
-
const search = url.searchParams.get('search') || null;
|
|
195
|
-
const recursive = url.searchParams.get('recursive') !== 'false';
|
|
196
|
-
try {
|
|
197
|
-
let prompts;
|
|
198
|
-
// Recursive mode: aggregate prompts from parent and child projects
|
|
199
|
-
if (recursive && !search) {
|
|
200
|
-
const { getAggregatedPrompts } = await import('../memory-store.js');
|
|
201
|
-
prompts = await getAggregatedPrompts(projectPath, limit);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
// Non-recursive mode or search mode: query only current project
|
|
205
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
206
|
-
if (search) {
|
|
207
|
-
prompts = memoryStore.searchPrompts(search, limit);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
// Get all recent prompts (we'll need to add this method to MemoryStore)
|
|
211
|
-
const stmt = memoryStore['db'].prepare(`
|
|
212
|
-
SELECT * FROM prompt_history
|
|
213
|
-
ORDER BY timestamp DESC
|
|
214
|
-
LIMIT ?
|
|
215
|
-
`);
|
|
216
|
-
prompts = stmt.all(limit);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
220
|
-
res.end(JSON.stringify({ prompts }));
|
|
221
|
-
}
|
|
222
|
-
catch (error) {
|
|
223
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
224
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
225
|
-
}
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
// API: Memory Module - Get insights (from prompt_patterns)
|
|
229
|
-
if (pathname === '/api/memory/insights' && req.method === 'GET') {
|
|
230
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
231
|
-
const limitParam = url.searchParams.get('limit');
|
|
232
|
-
const tool = url.searchParams.get('tool') || undefined;
|
|
233
|
-
// Check if this is a request for insights history (has limit or tool param)
|
|
234
|
-
if (limitParam || tool) {
|
|
235
|
-
const limit = parseInt(limitParam || '20', 10);
|
|
236
|
-
try {
|
|
237
|
-
const storeModule = await import('../../tools/cli-history-store.js');
|
|
238
|
-
const store = storeModule.getHistoryStore(projectPath);
|
|
239
|
-
const insights = store.getInsights({ limit, tool });
|
|
240
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
241
|
-
res.end(JSON.stringify({ success: true, insights }));
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
245
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
}
|
|
249
|
-
// Default: Get prompt pattern insights
|
|
250
|
-
try {
|
|
251
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
252
|
-
// Get total prompt count
|
|
253
|
-
const countStmt = memoryStore['db'].prepare(`SELECT COUNT(*) as count FROM prompt_history`);
|
|
254
|
-
const { count: totalPrompts } = countStmt.get();
|
|
255
|
-
// Get top intent
|
|
256
|
-
const topIntentStmt = memoryStore['db'].prepare(`
|
|
257
|
-
SELECT intent_label, COUNT(*) as count
|
|
258
|
-
FROM prompt_history
|
|
259
|
-
WHERE intent_label IS NOT NULL
|
|
260
|
-
GROUP BY intent_label
|
|
261
|
-
ORDER BY count DESC
|
|
262
|
-
LIMIT 1
|
|
263
|
-
`);
|
|
264
|
-
const topIntentRow = topIntentStmt.get();
|
|
265
|
-
// Get average prompt length
|
|
266
|
-
const avgLengthStmt = memoryStore['db'].prepare(`
|
|
267
|
-
SELECT AVG(LENGTH(prompt_text)) as avg_length
|
|
268
|
-
FROM prompt_history
|
|
269
|
-
WHERE prompt_text IS NOT NULL
|
|
270
|
-
`);
|
|
271
|
-
const { avg_length: avgLength } = avgLengthStmt.get();
|
|
272
|
-
// Get prompt patterns
|
|
273
|
-
const patternsStmt = memoryStore['db'].prepare(`
|
|
274
|
-
SELECT * FROM prompt_patterns
|
|
275
|
-
ORDER BY frequency DESC
|
|
276
|
-
LIMIT 10
|
|
277
|
-
`);
|
|
278
|
-
const patterns = patternsStmt.all();
|
|
279
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
280
|
-
res.end(JSON.stringify({
|
|
281
|
-
stats: {
|
|
282
|
-
totalPrompts,
|
|
283
|
-
topIntent: topIntentRow?.intent_label || 'unknown',
|
|
284
|
-
avgLength: Math.round(avgLength || 0)
|
|
285
|
-
},
|
|
286
|
-
patterns: patterns.map((p) => ({
|
|
287
|
-
type: p.pattern_type,
|
|
288
|
-
description: `Pattern detected in prompts`,
|
|
289
|
-
occurrences: p.frequency,
|
|
290
|
-
suggestion: `Consider using more specific prompts for ${p.pattern_type}`
|
|
291
|
-
}))
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
catch (error) {
|
|
295
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
296
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
297
|
-
}
|
|
298
|
-
return true;
|
|
299
|
-
}
|
|
300
|
-
// API: Memory Module - Trigger async CLI-based insights analysis
|
|
301
|
-
if (pathname === '/api/memory/insights/analyze' && req.method === 'POST') {
|
|
302
|
-
handlePostRequest(req, res, async (body) => {
|
|
303
|
-
const projectPath = body.path || initialPath;
|
|
304
|
-
const tool = body.tool || 'gemini'; // gemini, qwen, codex, claude
|
|
305
|
-
const prompts = body.prompts || [];
|
|
306
|
-
const lang = body.lang || 'en'; // Language preference
|
|
307
|
-
if (prompts.length === 0) {
|
|
308
|
-
return { error: 'No prompts provided for analysis', status: 400 };
|
|
309
|
-
}
|
|
310
|
-
// Prepare prompt summary for CLI analysis
|
|
311
|
-
const promptSummary = prompts.slice(0, 20).map((p, i) => {
|
|
312
|
-
return `${i + 1}. [${p.intent || 'unknown'}] ${(p.text || '').substring(0, 100)}...`;
|
|
313
|
-
}).join('\n');
|
|
314
|
-
const langInstruction = lang === 'zh'
|
|
315
|
-
? '请用中文回复。所有 description、suggestion、title 字段必须使用中文。'
|
|
316
|
-
: 'Respond in English. All description, suggestion, title fields must be in English.';
|
|
317
|
-
const analysisPrompt = `
|
|
318
|
-
PURPOSE: Analyze prompt patterns and provide optimization suggestions
|
|
319
|
-
TASK:
|
|
320
|
-
• Review the following prompt history summary
|
|
321
|
-
• Identify common patterns (vague requests, repetitive queries, incomplete context)
|
|
322
|
-
• Suggest specific improvements for prompt quality
|
|
323
|
-
• Detect areas where prompts could be more effective
|
|
324
|
-
MODE: analysis
|
|
325
|
-
CONTEXT: ${prompts.length} prompts from project: ${projectPath}
|
|
326
|
-
EXPECTED: JSON with patterns array and suggestions array
|
|
327
|
-
LANGUAGE: ${langInstruction}
|
|
328
|
-
|
|
329
|
-
PROMPT HISTORY:
|
|
330
|
-
${promptSummary}
|
|
331
|
-
|
|
332
|
-
Return ONLY valid JSON in this exact format (no markdown, no code blocks, just pure JSON):
|
|
333
|
-
{
|
|
334
|
-
"patterns": [
|
|
335
|
-
{"type": "pattern_type", "description": "description", "occurrences": count, "severity": "low|medium|high", "suggestion": "how to improve"}
|
|
336
|
-
],
|
|
337
|
-
"suggestions": [
|
|
338
|
-
{"title": "title", "description": "description", "example": "example prompt"}
|
|
339
|
-
]
|
|
340
|
-
}`;
|
|
341
|
-
try {
|
|
342
|
-
// Queue CLI execution
|
|
343
|
-
const result = await executeCliTool({
|
|
344
|
-
tool,
|
|
345
|
-
prompt: analysisPrompt,
|
|
346
|
-
mode: 'analysis',
|
|
347
|
-
timeout: 120000,
|
|
348
|
-
cd: projectPath,
|
|
349
|
-
category: 'insight'
|
|
350
|
-
});
|
|
351
|
-
// Try to parse JSON from response
|
|
352
|
-
let insights = { patterns: [], suggestions: [] };
|
|
353
|
-
if (result.stdout) {
|
|
354
|
-
let outputText = result.stdout;
|
|
355
|
-
// Strip markdown code blocks if present
|
|
356
|
-
const codeBlockMatch = outputText.match(/```(?:json)?\s*([\s\S]*?)```/);
|
|
357
|
-
if (codeBlockMatch) {
|
|
358
|
-
outputText = codeBlockMatch[1].trim();
|
|
359
|
-
}
|
|
360
|
-
// Find JSON object in the response
|
|
361
|
-
const jsonMatch = outputText.match(/\{[\s\S]*\}/);
|
|
362
|
-
if (jsonMatch) {
|
|
363
|
-
try {
|
|
364
|
-
insights = JSON.parse(jsonMatch[0]);
|
|
365
|
-
// Ensure arrays exist
|
|
366
|
-
if (!Array.isArray(insights.patterns))
|
|
367
|
-
insights.patterns = [];
|
|
368
|
-
if (!Array.isArray(insights.suggestions))
|
|
369
|
-
insights.suggestions = [];
|
|
370
|
-
}
|
|
371
|
-
catch (e) {
|
|
372
|
-
console.error('[insights/analyze] JSON parse error:', e);
|
|
373
|
-
// Return raw output if JSON parse fails
|
|
374
|
-
insights = {
|
|
375
|
-
patterns: [{ type: 'raw_analysis', description: result.stdout.substring(0, 500), occurrences: 1, severity: 'low', suggestion: '' }],
|
|
376
|
-
suggestions: []
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
// No JSON found, wrap raw output
|
|
382
|
-
insights = {
|
|
383
|
-
patterns: [{ type: 'raw_analysis', description: result.stdout.substring(0, 500), occurrences: 1, severity: 'low', suggestion: '' }],
|
|
384
|
-
suggestions: []
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
// Save insight to database
|
|
389
|
-
try {
|
|
390
|
-
const storeModule = await import('../../tools/cli-history-store.js');
|
|
391
|
-
const store = storeModule.getHistoryStore(projectPath);
|
|
392
|
-
const insightId = `insight-${Date.now()}`;
|
|
393
|
-
store.saveInsight({
|
|
394
|
-
id: insightId,
|
|
395
|
-
tool,
|
|
396
|
-
promptCount: prompts.length,
|
|
397
|
-
patterns: insights.patterns,
|
|
398
|
-
suggestions: insights.suggestions,
|
|
399
|
-
rawOutput: result.stdout || '',
|
|
400
|
-
executionId: result.execution?.id,
|
|
401
|
-
lang
|
|
402
|
-
});
|
|
403
|
-
console.log('[Insights] Saved insight:', insightId);
|
|
404
|
-
}
|
|
405
|
-
catch (saveErr) {
|
|
406
|
-
console.warn('[Insights] Failed to save insight:', saveErr.message);
|
|
407
|
-
}
|
|
408
|
-
return {
|
|
409
|
-
success: true,
|
|
410
|
-
insights,
|
|
411
|
-
tool,
|
|
412
|
-
executionId: result.execution.id
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
catch (error) {
|
|
416
|
-
return { error: error.message, status: 500 };
|
|
417
|
-
}
|
|
418
|
-
});
|
|
419
|
-
return true;
|
|
420
|
-
}
|
|
421
|
-
// API: Get single insight detail
|
|
422
|
-
if (pathname.startsWith('/api/memory/insights/') && req.method === 'GET') {
|
|
423
|
-
const insightId = pathname.replace('/api/memory/insights/', '');
|
|
424
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
425
|
-
if (!insightId || insightId === 'analyze') {
|
|
426
|
-
// Skip - handled by other routes
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
try {
|
|
430
|
-
const storeModule = await import('../../tools/cli-history-store.js');
|
|
431
|
-
const store = storeModule.getHistoryStore(projectPath);
|
|
432
|
-
const insight = store.getInsight(insightId);
|
|
433
|
-
if (insight) {
|
|
434
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
435
|
-
res.end(JSON.stringify({ success: true, insight }));
|
|
436
|
-
}
|
|
437
|
-
else {
|
|
438
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
439
|
-
res.end(JSON.stringify({ error: 'Insight not found' }));
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
catch (error) {
|
|
443
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
444
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
445
|
-
}
|
|
446
|
-
return true;
|
|
447
|
-
}
|
|
448
|
-
// API: Delete insight
|
|
449
|
-
if (pathname.startsWith('/api/memory/insights/') && req.method === 'DELETE') {
|
|
450
|
-
const insightId = pathname.replace('/api/memory/insights/', '');
|
|
451
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
452
|
-
try {
|
|
453
|
-
const storeModule = await import('../../tools/cli-history-store.js');
|
|
454
|
-
const store = storeModule.getHistoryStore(projectPath);
|
|
455
|
-
const deleted = store.deleteInsight(insightId);
|
|
456
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
457
|
-
res.end(JSON.stringify({ success: deleted }));
|
|
458
|
-
}
|
|
459
|
-
catch (error) {
|
|
460
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
461
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
462
|
-
}
|
|
463
|
-
return true;
|
|
464
|
-
}
|
|
465
|
-
// API: Memory Module - Get hotspot statistics
|
|
466
|
-
if (pathname === '/api/memory/stats') {
|
|
467
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
468
|
-
const filter = url.searchParams.get('filter') || 'all'; // today, week, all
|
|
469
|
-
const limit = parseInt(url.searchParams.get('limit') || '10', 10);
|
|
470
|
-
const recursive = url.searchParams.get('recursive') !== 'false';
|
|
471
|
-
try {
|
|
472
|
-
// If requesting aggregated stats, use the aggregated function
|
|
473
|
-
if (url.searchParams.has('aggregated') || recursive) {
|
|
474
|
-
const { getAggregatedStats } = await import('../memory-store.js');
|
|
475
|
-
const aggregatedStats = await getAggregatedStats(projectPath);
|
|
476
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
477
|
-
res.end(JSON.stringify({
|
|
478
|
-
stats: aggregatedStats,
|
|
479
|
-
aggregated: true
|
|
480
|
-
}));
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
// Original hotspot statistics (non-recursive)
|
|
484
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
485
|
-
const hotEntities = memoryStore.getHotEntities(limit * 4);
|
|
486
|
-
// Filter by time if needed
|
|
487
|
-
let filtered = hotEntities;
|
|
488
|
-
if (filter === 'today') {
|
|
489
|
-
const today = new Date();
|
|
490
|
-
today.setHours(0, 0, 0, 0);
|
|
491
|
-
filtered = hotEntities.filter((e) => new Date(e.last_seen_at) >= today);
|
|
492
|
-
}
|
|
493
|
-
else if (filter === 'week') {
|
|
494
|
-
const weekAgo = new Date();
|
|
495
|
-
weekAgo.setDate(weekAgo.getDate() - 7);
|
|
496
|
-
filtered = hotEntities.filter((e) => new Date(e.last_seen_at) >= weekAgo);
|
|
497
|
-
}
|
|
498
|
-
// Separate into mostRead, mostEdited, and mostMentioned
|
|
499
|
-
const fileEntities = filtered.filter((e) => e.type === 'file');
|
|
500
|
-
const topicEntities = filtered.filter((e) => e.type === 'topic');
|
|
501
|
-
const mostRead = fileEntities
|
|
502
|
-
.filter((e) => e.stats.read_count > 0)
|
|
503
|
-
.sort((a, b) => b.stats.read_count - a.stats.read_count)
|
|
504
|
-
.slice(0, limit)
|
|
505
|
-
.map((e) => ({
|
|
506
|
-
path: e.value,
|
|
507
|
-
file: e.value.split(/[/\\]/).pop(),
|
|
508
|
-
heat: e.stats.read_count,
|
|
509
|
-
count: e.stats.read_count,
|
|
510
|
-
lastSeen: e.last_seen_at
|
|
511
|
-
}));
|
|
512
|
-
const mostEdited = fileEntities
|
|
513
|
-
.filter((e) => e.stats.write_count > 0)
|
|
514
|
-
.sort((a, b) => b.stats.write_count - a.stats.write_count)
|
|
515
|
-
.slice(0, limit)
|
|
516
|
-
.map((e) => ({
|
|
517
|
-
path: e.value,
|
|
518
|
-
file: e.value.split(/[/\\]/).pop(),
|
|
519
|
-
heat: e.stats.write_count,
|
|
520
|
-
count: e.stats.write_count,
|
|
521
|
-
lastSeen: e.last_seen_at
|
|
522
|
-
}));
|
|
523
|
-
const mostMentioned = topicEntities
|
|
524
|
-
.filter((e) => e.stats.mention_count > 0)
|
|
525
|
-
.sort((a, b) => b.stats.mention_count - a.stats.mention_count)
|
|
526
|
-
.slice(0, limit)
|
|
527
|
-
.map((e) => ({
|
|
528
|
-
topic: e.value,
|
|
529
|
-
preview: e.value.substring(0, 100) + (e.value.length > 100 ? '...' : ''),
|
|
530
|
-
heat: e.stats.mention_count,
|
|
531
|
-
count: e.stats.mention_count,
|
|
532
|
-
lastSeen: e.last_seen_at
|
|
533
|
-
}));
|
|
534
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
535
|
-
res.end(JSON.stringify({ stats: { mostRead, mostEdited, mostMentioned } }));
|
|
536
|
-
}
|
|
537
|
-
catch (error) {
|
|
538
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
539
|
-
res.end(JSON.stringify({ stats: { mostRead: [], mostEdited: [], mostMentioned: [] } }));
|
|
540
|
-
}
|
|
541
|
-
return true;
|
|
542
|
-
}
|
|
543
|
-
// API: Memory Module - Get memory graph (file associations with modules and components)
|
|
544
|
-
if (pathname === '/api/memory/graph') {
|
|
545
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
546
|
-
try {
|
|
547
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
548
|
-
const hotEntities = memoryStore.getHotEntities(100);
|
|
549
|
-
// Build file nodes from entities
|
|
550
|
-
const fileEntities = hotEntities.filter((e) => e.type === 'file');
|
|
551
|
-
const fileNodes = fileEntities.map((e) => {
|
|
552
|
-
const fileName = e.value.split(/[/\\]/).pop() || '';
|
|
553
|
-
// Detect component type based on file name patterns
|
|
554
|
-
const isComponent = /\.(tsx|jsx|vue|svelte)$/.test(fileName) ||
|
|
555
|
-
/^[A-Z][a-zA-Z]+\.(ts|js)$/.test(fileName) ||
|
|
556
|
-
fileName.includes('.component.') ||
|
|
557
|
-
fileName.includes('.controller.');
|
|
558
|
-
return {
|
|
559
|
-
id: e.value,
|
|
560
|
-
name: fileName,
|
|
561
|
-
path: e.value,
|
|
562
|
-
type: isComponent ? 'component' : 'file',
|
|
563
|
-
heat: Math.min(25, 8 + e.stats.heat_score / 10)
|
|
564
|
-
};
|
|
565
|
-
});
|
|
566
|
-
// Extract unique modules (directories) from file paths
|
|
567
|
-
const moduleMap = new Map();
|
|
568
|
-
for (const file of fileEntities) {
|
|
569
|
-
const parts = file.value.split(/[/\\]/);
|
|
570
|
-
// Get parent directory as module (skip if root level)
|
|
571
|
-
if (parts.length > 1) {
|
|
572
|
-
const modulePath = parts.slice(0, -1).join('/');
|
|
573
|
-
const moduleName = parts[parts.length - 2] || modulePath;
|
|
574
|
-
// Skip common non-module directories
|
|
575
|
-
if (['node_modules', '.git', 'dist', 'build', '.next', '.nuxt'].includes(moduleName))
|
|
576
|
-
continue;
|
|
577
|
-
if (!moduleMap.has(modulePath)) {
|
|
578
|
-
moduleMap.set(modulePath, { heat: 0, files: [] });
|
|
579
|
-
}
|
|
580
|
-
const mod = moduleMap.get(modulePath);
|
|
581
|
-
mod.heat += file.stats.heat_score / 20;
|
|
582
|
-
mod.files.push(file.value);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
// Create module nodes (limit to top modules by heat)
|
|
586
|
-
const moduleNodes = Array.from(moduleMap.entries())
|
|
587
|
-
.sort((a, b) => b[1].heat - a[1].heat)
|
|
588
|
-
.slice(0, 15)
|
|
589
|
-
.map(([modulePath, data]) => ({
|
|
590
|
-
id: modulePath,
|
|
591
|
-
name: modulePath.split(/[/\\]/).pop() || modulePath,
|
|
592
|
-
path: modulePath,
|
|
593
|
-
type: 'module',
|
|
594
|
-
heat: Math.min(20, 12 + data.heat / 5),
|
|
595
|
-
fileCount: data.files.length
|
|
596
|
-
}));
|
|
597
|
-
// Combine all nodes
|
|
598
|
-
const nodes = [...fileNodes, ...moduleNodes];
|
|
599
|
-
const nodeIds = new Set(nodes.map(n => n.id));
|
|
600
|
-
// Build edges from associations
|
|
601
|
-
const edges = [];
|
|
602
|
-
const edgeSet = new Set(); // Prevent duplicate edges
|
|
603
|
-
// Add file-to-file associations
|
|
604
|
-
for (const entity of hotEntities) {
|
|
605
|
-
if (!entity.id || entity.type !== 'file')
|
|
606
|
-
continue;
|
|
607
|
-
const associations = memoryStore.getAssociations(entity.id, 10);
|
|
608
|
-
for (const assoc of associations) {
|
|
609
|
-
if (assoc.target && nodeIds.has(assoc.target.value)) {
|
|
610
|
-
const edgeKey = [entity.value, assoc.target.value].sort().join('|');
|
|
611
|
-
if (!edgeSet.has(edgeKey)) {
|
|
612
|
-
edgeSet.add(edgeKey);
|
|
613
|
-
edges.push({
|
|
614
|
-
source: entity.value,
|
|
615
|
-
target: assoc.target.value,
|
|
616
|
-
weight: assoc.weight
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
// Add file-to-module edges (files belong to their parent modules)
|
|
623
|
-
for (const [modulePath, data] of moduleMap.entries()) {
|
|
624
|
-
if (!nodeIds.has(modulePath))
|
|
625
|
-
continue;
|
|
626
|
-
for (const filePath of data.files) {
|
|
627
|
-
if (nodeIds.has(filePath)) {
|
|
628
|
-
const edgeKey = [modulePath, filePath].sort().join('|');
|
|
629
|
-
if (!edgeSet.has(edgeKey)) {
|
|
630
|
-
edgeSet.add(edgeKey);
|
|
631
|
-
edges.push({
|
|
632
|
-
source: modulePath,
|
|
633
|
-
target: filePath,
|
|
634
|
-
weight: 2 // Lower weight for structural relationships
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
641
|
-
res.end(JSON.stringify({ graph: { nodes, edges } }));
|
|
642
|
-
}
|
|
643
|
-
catch (error) {
|
|
644
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
645
|
-
res.end(JSON.stringify({ graph: { nodes: [], edges: [] } }));
|
|
646
|
-
}
|
|
647
|
-
return true;
|
|
648
|
-
}
|
|
649
|
-
// API: Memory Module - Get recent context activities
|
|
650
|
-
if (pathname === '/api/memory/recent') {
|
|
651
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
652
|
-
const limit = parseInt(url.searchParams.get('limit') || '20', 10);
|
|
653
|
-
try {
|
|
654
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
655
|
-
// Get recent access logs with entity info - filter to file type only
|
|
656
|
-
const db = memoryStore.db;
|
|
657
|
-
const recentLogs = db.prepare(`
|
|
658
|
-
SELECT a.*, e.type, e.value
|
|
659
|
-
FROM access_logs a
|
|
660
|
-
JOIN entities e ON a.entity_id = e.id
|
|
661
|
-
WHERE e.type = 'file'
|
|
662
|
-
ORDER BY a.timestamp DESC
|
|
663
|
-
LIMIT ?
|
|
664
|
-
`).all(limit * 2); // Fetch more to account for filtering
|
|
665
|
-
// Filter out invalid entries (JSON strings, error messages, etc.)
|
|
666
|
-
const validLogs = recentLogs.filter((log) => {
|
|
667
|
-
const value = log.value || '';
|
|
668
|
-
// Skip if value looks like JSON or contains error-like patterns
|
|
669
|
-
if (value.includes('"status"') || value.includes('"content"') ||
|
|
670
|
-
value.includes('"activeForm"') || value.startsWith('{') ||
|
|
671
|
-
value.startsWith('[') || value.includes('graph 400')) {
|
|
672
|
-
return false;
|
|
673
|
-
}
|
|
674
|
-
// Must have a file extension or look like a valid path
|
|
675
|
-
const hasExtension = /\.[a-zA-Z0-9]{1,10}$/.test(value);
|
|
676
|
-
const looksLikePath = value.includes('/') || value.includes('\\');
|
|
677
|
-
return hasExtension || looksLikePath;
|
|
678
|
-
}).slice(0, limit);
|
|
679
|
-
const recent = validLogs.map((log) => ({
|
|
680
|
-
type: log.action, // read, write, mention
|
|
681
|
-
timestamp: log.timestamp,
|
|
682
|
-
prompt: log.context_summary || '',
|
|
683
|
-
files: [log.value],
|
|
684
|
-
description: `${log.action}: ${log.value.split(/[/\\]/).pop()}`
|
|
685
|
-
}));
|
|
686
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
687
|
-
res.end(JSON.stringify({ recent }));
|
|
688
|
-
}
|
|
689
|
-
catch (error) {
|
|
690
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
691
|
-
res.end(JSON.stringify({ recent: [] }));
|
|
692
|
-
}
|
|
693
|
-
return true;
|
|
694
|
-
}
|
|
695
|
-
// API: Active Memory - Get status
|
|
696
|
-
if (pathname === '/api/memory/active/status') {
|
|
697
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
698
|
-
if (!projectPath) {
|
|
699
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
700
|
-
res.end(JSON.stringify({ enabled: false, status: null, config: { interval: 'manual', tool: 'gemini' } }));
|
|
701
|
-
return true;
|
|
702
|
-
}
|
|
703
|
-
try {
|
|
704
|
-
const rulesDir = join(projectPath, '.claude', 'rules');
|
|
705
|
-
const configPath = join(rulesDir, 'active_memory.md');
|
|
706
|
-
const configJsonPath = join(projectPath, '.claude', 'active_memory_config.json');
|
|
707
|
-
const enabled = existsSync(configPath);
|
|
708
|
-
let lastSync = null;
|
|
709
|
-
let fileCount = 0;
|
|
710
|
-
let config = { interval: 'manual', tool: 'gemini' };
|
|
711
|
-
if (enabled) {
|
|
712
|
-
const stats = statSync(configPath);
|
|
713
|
-
lastSync = stats.mtime.toISOString();
|
|
714
|
-
const content = readFileSync(configPath, 'utf-8');
|
|
715
|
-
// Count file sections
|
|
716
|
-
fileCount = (content.match(/^## /gm) || []).length;
|
|
717
|
-
}
|
|
718
|
-
// Load config if exists
|
|
719
|
-
if (existsSync(configJsonPath)) {
|
|
720
|
-
try {
|
|
721
|
-
config = JSON.parse(readFileSync(configJsonPath, 'utf-8'));
|
|
722
|
-
}
|
|
723
|
-
catch (e) { /* ignore parse errors */ }
|
|
724
|
-
}
|
|
725
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
726
|
-
res.end(JSON.stringify({
|
|
727
|
-
enabled,
|
|
728
|
-
status: enabled ? { lastSync, fileCount } : null,
|
|
729
|
-
config
|
|
730
|
-
}));
|
|
731
|
-
}
|
|
732
|
-
catch (error) {
|
|
733
|
-
console.error('Active Memory status error:', error);
|
|
734
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
735
|
-
res.end(JSON.stringify({ enabled: false, status: null, config: { interval: 'manual', tool: 'gemini' } }));
|
|
736
|
-
}
|
|
737
|
-
return true;
|
|
738
|
-
}
|
|
739
|
-
// API: Active Memory - Toggle
|
|
740
|
-
if (pathname === '/api/memory/active/toggle' && req.method === 'POST') {
|
|
741
|
-
let body = '';
|
|
742
|
-
req.on('data', (chunk) => { body += chunk.toString(); });
|
|
743
|
-
req.on('end', async () => {
|
|
744
|
-
try {
|
|
745
|
-
const { enabled, config } = JSON.parse(body || '{}');
|
|
746
|
-
const projectPath = initialPath;
|
|
747
|
-
if (!projectPath) {
|
|
748
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
749
|
-
res.end(JSON.stringify({ error: 'No project path configured' }));
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
const claudeDir = join(projectPath, '.claude');
|
|
753
|
-
const rulesDir = join(claudeDir, 'rules');
|
|
754
|
-
const configPath = join(rulesDir, 'active_memory.md');
|
|
755
|
-
const configJsonPath = join(claudeDir, 'active_memory_config.json');
|
|
756
|
-
if (enabled) {
|
|
757
|
-
// Enable: Create directories and initial file
|
|
758
|
-
if (!existsSync(claudeDir)) {
|
|
759
|
-
mkdirSync(claudeDir, { recursive: true });
|
|
760
|
-
}
|
|
761
|
-
if (!existsSync(rulesDir)) {
|
|
762
|
-
mkdirSync(rulesDir, { recursive: true });
|
|
763
|
-
}
|
|
764
|
-
// Save config
|
|
765
|
-
if (config) {
|
|
766
|
-
writeFileSync(configJsonPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
767
|
-
}
|
|
768
|
-
// Create initial active_memory.md with header
|
|
769
|
-
const initialContent = `# Active Memory - Project Context
|
|
770
|
-
|
|
771
|
-
> Auto-generated understanding of frequently accessed files.
|
|
772
|
-
> Last updated: ${new Date().toISOString()}
|
|
773
|
-
|
|
774
|
-
---
|
|
775
|
-
|
|
776
|
-
*No files analyzed yet. Click "Sync Now" to analyze hot files.*
|
|
777
|
-
`;
|
|
778
|
-
writeFileSync(configPath, initialContent, 'utf-8');
|
|
779
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
780
|
-
res.end(JSON.stringify({ enabled: true, message: 'Active Memory enabled' }));
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
783
|
-
// Disable: Remove the files
|
|
784
|
-
if (existsSync(configPath)) {
|
|
785
|
-
unlinkSync(configPath);
|
|
786
|
-
}
|
|
787
|
-
if (existsSync(configJsonPath)) {
|
|
788
|
-
unlinkSync(configJsonPath);
|
|
789
|
-
}
|
|
790
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
791
|
-
res.end(JSON.stringify({ enabled: false, message: 'Active Memory disabled' }));
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
catch (error) {
|
|
795
|
-
console.error('Active Memory toggle error:', error);
|
|
796
|
-
if (!res.headersSent) {
|
|
797
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
798
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
return true;
|
|
803
|
-
}
|
|
804
|
-
// API: Active Memory - Update Config
|
|
805
|
-
if (pathname === '/api/memory/active/config' && req.method === 'POST') {
|
|
806
|
-
let body = '';
|
|
807
|
-
req.on('data', (chunk) => { body += chunk.toString(); });
|
|
808
|
-
req.on('end', async () => {
|
|
809
|
-
try {
|
|
810
|
-
const { config } = JSON.parse(body || '{}');
|
|
811
|
-
const projectPath = initialPath;
|
|
812
|
-
const claudeDir = join(projectPath, '.claude');
|
|
813
|
-
const configJsonPath = join(claudeDir, 'active_memory_config.json');
|
|
814
|
-
if (!existsSync(claudeDir)) {
|
|
815
|
-
mkdirSync(claudeDir, { recursive: true });
|
|
816
|
-
}
|
|
817
|
-
writeFileSync(configJsonPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
818
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
819
|
-
res.end(JSON.stringify({ success: true, config }));
|
|
820
|
-
}
|
|
821
|
-
catch (error) {
|
|
822
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
823
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
824
|
-
}
|
|
825
|
-
});
|
|
826
|
-
return true;
|
|
827
|
-
}
|
|
828
|
-
// API: Active Memory - Sync (analyze hot files using CLI and update active_memory.md)
|
|
829
|
-
if (pathname === '/api/memory/active/sync' && req.method === 'POST') {
|
|
830
|
-
let body = '';
|
|
831
|
-
req.on('data', (chunk) => { body += chunk.toString(); });
|
|
832
|
-
req.on('end', async () => {
|
|
833
|
-
try {
|
|
834
|
-
const { tool = 'gemini' } = JSON.parse(body || '{}');
|
|
835
|
-
const projectPath = initialPath;
|
|
836
|
-
if (!projectPath) {
|
|
837
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
838
|
-
res.end(JSON.stringify({ error: 'No project path configured' }));
|
|
839
|
-
return;
|
|
840
|
-
}
|
|
841
|
-
const claudeDir = join(projectPath, '.claude');
|
|
842
|
-
const rulesDir = join(claudeDir, 'rules');
|
|
843
|
-
const configPath = join(rulesDir, 'active_memory.md');
|
|
844
|
-
// Get hot files from memory store - with fallback
|
|
845
|
-
let hotFiles = [];
|
|
846
|
-
try {
|
|
847
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
848
|
-
const hotEntities = memoryStore.getHotEntities(20);
|
|
849
|
-
hotFiles = hotEntities
|
|
850
|
-
.filter((e) => e.type === 'file')
|
|
851
|
-
.slice(0, 10);
|
|
852
|
-
}
|
|
853
|
-
catch (memErr) {
|
|
854
|
-
console.warn('[Active Memory] Memory store error, using empty list:', memErr.message);
|
|
855
|
-
}
|
|
856
|
-
// Build file list for CLI analysis
|
|
857
|
-
const filePaths = hotFiles.map((f) => {
|
|
858
|
-
const filePath = f.value;
|
|
859
|
-
return isAbsolute(filePath) ? filePath : join(projectPath, filePath);
|
|
860
|
-
}).filter((p) => existsSync(p));
|
|
861
|
-
// Build the active_memory.md content header
|
|
862
|
-
let content = `# Active Memory - Project Context
|
|
863
|
-
|
|
864
|
-
> Auto-generated understanding of frequently accessed files using ${tool.toUpperCase()}.
|
|
865
|
-
> Last updated: ${new Date().toISOString()}
|
|
866
|
-
> Files analyzed: ${hotFiles.length}
|
|
867
|
-
> CLI Tool: ${tool}
|
|
868
|
-
|
|
869
|
-
---
|
|
870
|
-
|
|
871
|
-
`;
|
|
872
|
-
// Use CCW CLI tool to analyze files
|
|
873
|
-
let cliOutput = '';
|
|
874
|
-
// Build CLI prompt
|
|
875
|
-
const cliPrompt = `PURPOSE: Analyze the following hot files and provide a concise understanding of each.
|
|
876
|
-
TASK: For each file, describe its purpose, key exports, dependencies, and how it relates to other files.
|
|
877
|
-
MODE: analysis
|
|
878
|
-
CONTEXT: ${filePaths.map((p) => '@' + p).join(' ')}
|
|
879
|
-
EXPECTED: Markdown format with ## headings for each file, bullet points for key information.
|
|
880
|
-
RULES: Be concise. Focus on practical understanding. Include function signatures for key exports.`;
|
|
881
|
-
// Try to execute CLI using CCW's built-in executor
|
|
882
|
-
try {
|
|
883
|
-
const syncId = `active-memory-${Date.now()}`;
|
|
884
|
-
const result = await executeCliTool({
|
|
885
|
-
tool: tool === 'qwen' ? 'qwen' : 'gemini',
|
|
886
|
-
prompt: cliPrompt,
|
|
887
|
-
mode: 'analysis',
|
|
888
|
-
format: 'plain',
|
|
889
|
-
cd: projectPath,
|
|
890
|
-
timeout: 120000,
|
|
891
|
-
stream: false,
|
|
892
|
-
category: 'internal',
|
|
893
|
-
id: syncId
|
|
894
|
-
});
|
|
895
|
-
if (result.success && result.execution?.output) {
|
|
896
|
-
// Extract stdout from output object with proper serialization
|
|
897
|
-
const output = result.execution.output;
|
|
898
|
-
if (typeof output === 'string') {
|
|
899
|
-
cliOutput = output;
|
|
900
|
-
}
|
|
901
|
-
else if (output && typeof output === 'object') {
|
|
902
|
-
// Handle object output - extract stdout or serialize the object
|
|
903
|
-
if (output.stdout && typeof output.stdout === 'string') {
|
|
904
|
-
cliOutput = output.stdout;
|
|
905
|
-
}
|
|
906
|
-
else if (output.stderr && typeof output.stderr === 'string') {
|
|
907
|
-
cliOutput = output.stderr;
|
|
908
|
-
}
|
|
909
|
-
else {
|
|
910
|
-
// Last resort: serialize the entire object as JSON
|
|
911
|
-
cliOutput = JSON.stringify(output, null, 2);
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
else {
|
|
915
|
-
cliOutput = '';
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
// Add CLI output to content (only if not empty)
|
|
919
|
-
if (cliOutput && cliOutput.trim()) {
|
|
920
|
-
content += cliOutput + '\n\n---\n\n';
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
catch (cliErr) {
|
|
924
|
-
// Fallback to basic analysis if CLI fails
|
|
925
|
-
console.warn('[Active Memory] CLI analysis failed, using basic analysis:', cliErr.message);
|
|
926
|
-
// Basic analysis fallback
|
|
927
|
-
for (const file of hotFiles) {
|
|
928
|
-
const fileName = file.value.split(/[/\\]/).pop() || file.value;
|
|
929
|
-
const filePath = file.value;
|
|
930
|
-
const heat = file.stats?.heat_score || 0;
|
|
931
|
-
const readCount = file.stats?.read_count || 0;
|
|
932
|
-
const writeCount = file.stats?.write_count || 0;
|
|
933
|
-
content += `## ${fileName}
|
|
934
|
-
|
|
935
|
-
- **Path**: \`${filePath}\`
|
|
936
|
-
- **Heat Score**: ${heat}
|
|
937
|
-
- **Access**: ${readCount} reads, ${writeCount} writes
|
|
938
|
-
- **Last Seen**: ${file.last_seen_at || 'Unknown'}
|
|
939
|
-
|
|
940
|
-
`;
|
|
941
|
-
// Try to read file and generate summary
|
|
942
|
-
try {
|
|
943
|
-
const fullPath = isAbsolute(filePath) ? filePath : join(projectPath, filePath);
|
|
944
|
-
if (existsSync(fullPath)) {
|
|
945
|
-
const stat = statSync(fullPath);
|
|
946
|
-
const ext = extname(fullPath).toLowerCase();
|
|
947
|
-
content += `- **Size**: ${(stat.size / 1024).toFixed(1)} KB\n`;
|
|
948
|
-
content += `- **Type**: ${ext || 'unknown'}\n`;
|
|
949
|
-
const textExts = ['.ts', '.js', '.tsx', '.jsx', '.md', '.json', '.css', '.html', '.vue', '.svelte', '.py', '.go', '.rs'];
|
|
950
|
-
if (textExts.includes(ext) && stat.size < 100000) {
|
|
951
|
-
const fileContent = readFileSync(fullPath, 'utf-8');
|
|
952
|
-
const lines = fileContent.split('\n').slice(0, 30);
|
|
953
|
-
const exports = lines.filter(l => l.includes('export ') || l.includes('function ') ||
|
|
954
|
-
l.includes('class ') || l.includes('interface ')).slice(0, 8);
|
|
955
|
-
if (exports.length > 0) {
|
|
956
|
-
content += `\n**Key Exports**:\n\`\`\`\n${exports.join('\n')}\n\`\`\`\n`;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
catch (fileErr) {
|
|
962
|
-
// Skip file analysis errors
|
|
963
|
-
}
|
|
964
|
-
content += '\n---\n\n';
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
// Ensure directories exist
|
|
968
|
-
if (!existsSync(claudeDir)) {
|
|
969
|
-
mkdirSync(claudeDir, { recursive: true });
|
|
970
|
-
}
|
|
971
|
-
if (!existsSync(rulesDir)) {
|
|
972
|
-
mkdirSync(rulesDir, { recursive: true });
|
|
973
|
-
}
|
|
974
|
-
// Write the file
|
|
975
|
-
writeFileSync(configPath, content, 'utf-8');
|
|
976
|
-
// Broadcast Active Memory sync completion event
|
|
977
|
-
broadcastToClients({
|
|
978
|
-
type: 'ACTIVE_MEMORY_SYNCED',
|
|
979
|
-
payload: {
|
|
980
|
-
filesAnalyzed: hotFiles.length,
|
|
981
|
-
path: configPath,
|
|
982
|
-
tool,
|
|
983
|
-
usedCli: cliOutput.length > 0,
|
|
984
|
-
timestamp: new Date().toISOString()
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
988
|
-
res.end(JSON.stringify({
|
|
989
|
-
success: true,
|
|
990
|
-
filesAnalyzed: hotFiles.length,
|
|
991
|
-
path: configPath,
|
|
992
|
-
usedCli: cliOutput.length > 0
|
|
993
|
-
}));
|
|
994
|
-
}
|
|
995
|
-
catch (error) {
|
|
996
|
-
console.error('[Active Memory] Sync error:', error);
|
|
997
|
-
if (!res.headersSent) {
|
|
998
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
999
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
return true;
|
|
1004
|
-
}
|
|
1005
|
-
// API: Memory Module - Get conversations index
|
|
1006
|
-
if (pathname === '/api/memory/conversations') {
|
|
1007
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
1008
|
-
const project = url.searchParams.get('project') || null;
|
|
1009
|
-
const limit = parseInt(url.searchParams.get('limit') || '20', 10);
|
|
1010
|
-
try {
|
|
1011
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
1012
|
-
let conversations;
|
|
1013
|
-
if (project) {
|
|
1014
|
-
const stmt = memoryStore['db'].prepare(`
|
|
1015
|
-
SELECT * FROM conversations
|
|
1016
|
-
WHERE project_name = ?
|
|
1017
|
-
ORDER BY updated_at DESC
|
|
1018
|
-
LIMIT ?
|
|
1019
|
-
`);
|
|
1020
|
-
conversations = stmt.all(project, limit);
|
|
1021
|
-
}
|
|
1022
|
-
else {
|
|
1023
|
-
conversations = memoryStore.getConversations(limit);
|
|
1024
|
-
}
|
|
1025
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1026
|
-
res.end(JSON.stringify({ conversations }));
|
|
1027
|
-
}
|
|
1028
|
-
catch (error) {
|
|
1029
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1030
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
1031
|
-
}
|
|
1032
|
-
return true;
|
|
1033
|
-
}
|
|
1034
|
-
// API: Memory Module - Replay conversation
|
|
1035
|
-
if (pathname.startsWith('/api/memory/replay/')) {
|
|
1036
|
-
const conversationId = pathname.replace('/api/memory/replay/', '');
|
|
1037
|
-
const projectPath = url.searchParams.get('path') || initialPath;
|
|
1038
|
-
if (!conversationId) {
|
|
1039
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
1040
|
-
res.end(JSON.stringify({ error: 'Conversation ID is required' }));
|
|
1041
|
-
return true;
|
|
1042
|
-
}
|
|
1043
|
-
try {
|
|
1044
|
-
const memoryStore = getMemoryStore(projectPath);
|
|
1045
|
-
const conversation = memoryStore.getConversation(conversationId);
|
|
1046
|
-
if (!conversation) {
|
|
1047
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
1048
|
-
res.end(JSON.stringify({ error: 'Conversation not found' }));
|
|
1049
|
-
return true;
|
|
1050
|
-
}
|
|
1051
|
-
const messages = memoryStore.getMessages(conversationId);
|
|
1052
|
-
// Enhance messages with tool calls
|
|
1053
|
-
const messagesWithTools = [];
|
|
1054
|
-
for (const message of messages) {
|
|
1055
|
-
const toolCalls = message.id ? memoryStore.getToolCalls(message.id) : [];
|
|
1056
|
-
messagesWithTools.push({
|
|
1057
|
-
...message,
|
|
1058
|
-
tool_calls: toolCalls
|
|
1059
|
-
});
|
|
1060
|
-
}
|
|
1061
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
1062
|
-
res.end(JSON.stringify({
|
|
1063
|
-
conversation,
|
|
1064
|
-
messages: messagesWithTools
|
|
1065
|
-
}));
|
|
1066
|
-
}
|
|
1067
|
-
catch (error) {
|
|
1068
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
1069
|
-
res.end(JSON.stringify({ error: error.message }));
|
|
1070
|
-
}
|
|
1071
|
-
return true;
|
|
1072
|
-
}
|
|
1073
|
-
// API: Memory Module - Import history (async task)
|
|
1074
|
-
if (pathname === '/api/memory/import' && req.method === 'POST') {
|
|
1075
|
-
handlePostRequest(req, res, async (body) => {
|
|
1076
|
-
const { source = 'all', project, path: projectPath } = body;
|
|
1077
|
-
const basePath = projectPath || initialPath;
|
|
1078
|
-
// Generate task ID for async operation
|
|
1079
|
-
const taskId = `import-${Date.now()}`;
|
|
1080
|
-
// TODO: Implement actual history import using HistoryImporter
|
|
1081
|
-
// For now, return a placeholder response
|
|
1082
|
-
console.log(`[Memory] Import task ${taskId} started: source=${source}, project=${project}`);
|
|
1083
|
-
return {
|
|
1084
|
-
success: true,
|
|
1085
|
-
taskId,
|
|
1086
|
-
message: 'Import task started (not yet implemented)',
|
|
1087
|
-
source,
|
|
1088
|
-
project
|
|
1089
|
-
};
|
|
1090
|
-
});
|
|
1091
|
-
return true;
|
|
1092
|
-
}
|
|
1093
|
-
return false;
|
|
1094
|
-
}
|
|
1095
|
-
//# sourceMappingURL=memory-routes.js.map
|