@miller-tech/uap 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +888 -0
- package/dist/analyzers/index.d.ts +3 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +684 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/benchmarks/agents/naive-agent.d.ts +60 -0
- package/dist/benchmarks/agents/naive-agent.d.ts.map +1 -0
- package/dist/benchmarks/agents/naive-agent.js +144 -0
- package/dist/benchmarks/agents/naive-agent.js.map +1 -0
- package/dist/benchmarks/agents/uap-agent.d.ts +167 -0
- package/dist/benchmarks/agents/uap-agent.d.ts.map +1 -0
- package/dist/benchmarks/agents/uap-agent.js +437 -0
- package/dist/benchmarks/agents/uap-agent.js.map +1 -0
- package/dist/benchmarks/benchmark.d.ts +328 -0
- package/dist/benchmarks/benchmark.d.ts.map +1 -0
- package/dist/benchmarks/benchmark.js +112 -0
- package/dist/benchmarks/benchmark.js.map +1 -0
- package/dist/benchmarks/execution-verifier.d.ts +41 -0
- package/dist/benchmarks/execution-verifier.d.ts.map +1 -0
- package/dist/benchmarks/execution-verifier.js +340 -0
- package/dist/benchmarks/execution-verifier.js.map +1 -0
- package/dist/benchmarks/hierarchical-prompting.d.ts +37 -0
- package/dist/benchmarks/hierarchical-prompting.d.ts.map +1 -0
- package/dist/benchmarks/hierarchical-prompting.js +246 -0
- package/dist/benchmarks/hierarchical-prompting.js.map +1 -0
- package/dist/benchmarks/improved-benchmark.d.ts +89 -0
- package/dist/benchmarks/improved-benchmark.d.ts.map +1 -0
- package/dist/benchmarks/improved-benchmark.js +585 -0
- package/dist/benchmarks/improved-benchmark.js.map +1 -0
- package/dist/benchmarks/index.d.ts +11 -0
- package/dist/benchmarks/index.d.ts.map +1 -0
- package/dist/benchmarks/index.js +11 -0
- package/dist/benchmarks/index.js.map +1 -0
- package/dist/benchmarks/model-integration.d.ts +111 -0
- package/dist/benchmarks/model-integration.d.ts.map +1 -0
- package/dist/benchmarks/model-integration.js +904 -0
- package/dist/benchmarks/model-integration.js.map +1 -0
- package/dist/benchmarks/multi-turn-agent.d.ts +44 -0
- package/dist/benchmarks/multi-turn-agent.d.ts.map +1 -0
- package/dist/benchmarks/multi-turn-agent.js +254 -0
- package/dist/benchmarks/multi-turn-agent.js.map +1 -0
- package/dist/benchmarks/multi-turn-loop.d.ts +57 -0
- package/dist/benchmarks/multi-turn-loop.d.ts.map +1 -0
- package/dist/benchmarks/multi-turn-loop.js +167 -0
- package/dist/benchmarks/multi-turn-loop.js.map +1 -0
- package/dist/benchmarks/tasks.d.ts +19 -0
- package/dist/benchmarks/tasks.d.ts.map +1 -0
- package/dist/benchmarks/tasks.js +435 -0
- package/dist/benchmarks/tasks.js.map +1 -0
- package/dist/bin/cli.d.ts +3 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +546 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/bin/llama-server-optimize.d.ts +18 -0
- package/dist/bin/llama-server-optimize.d.ts.map +1 -0
- package/dist/bin/llama-server-optimize.js +708 -0
- package/dist/bin/llama-server-optimize.js.map +1 -0
- package/dist/bin/policy.d.ts +3 -0
- package/dist/bin/policy.d.ts.map +1 -0
- package/dist/bin/policy.js +143 -0
- package/dist/bin/policy.js.map +1 -0
- package/dist/bin/tool-calls.d.ts +3 -0
- package/dist/bin/tool-calls.d.ts.map +1 -0
- package/dist/bin/tool-calls.js +4 -0
- package/dist/bin/tool-calls.js.map +1 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/web-browser.d.ts +30 -0
- package/dist/browser/web-browser.d.ts.map +1 -0
- package/dist/browser/web-browser.js +93 -0
- package/dist/browser/web-browser.js.map +1 -0
- package/dist/cli/agent.d.ts +20 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +474 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/analyze.d.ts +7 -0
- package/dist/cli/analyze.d.ts.map +1 -0
- package/dist/cli/analyze.js +103 -0
- package/dist/cli/analyze.js.map +1 -0
- package/dist/cli/completion-gates.d.ts +51 -0
- package/dist/cli/completion-gates.d.ts.map +1 -0
- package/dist/cli/completion-gates.js +201 -0
- package/dist/cli/completion-gates.js.map +1 -0
- package/dist/cli/compliance.d.ts +8 -0
- package/dist/cli/compliance.d.ts.map +1 -0
- package/dist/cli/compliance.js +509 -0
- package/dist/cli/compliance.js.map +1 -0
- package/dist/cli/coord.d.ts +7 -0
- package/dist/cli/coord.d.ts.map +1 -0
- package/dist/cli/coord.js +138 -0
- package/dist/cli/coord.js.map +1 -0
- package/dist/cli/dashboard.d.ts +21 -0
- package/dist/cli/dashboard.d.ts.map +1 -0
- package/dist/cli/dashboard.js +1508 -0
- package/dist/cli/dashboard.js.map +1 -0
- package/dist/cli/deploy.d.ts +19 -0
- package/dist/cli/deploy.d.ts.map +1 -0
- package/dist/cli/deploy.js +387 -0
- package/dist/cli/deploy.js.map +1 -0
- package/dist/cli/droids.d.ts +9 -0
- package/dist/cli/droids.d.ts.map +1 -0
- package/dist/cli/droids.js +227 -0
- package/dist/cli/droids.js.map +1 -0
- package/dist/cli/generate.d.ts +17 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +432 -0
- package/dist/cli/generate.js.map +1 -0
- package/dist/cli/hooks.d.ts +9 -0
- package/dist/cli/hooks.d.ts.map +1 -0
- package/dist/cli/hooks.js +464 -0
- package/dist/cli/hooks.js.map +1 -0
- package/dist/cli/init.d.ts +12 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +364 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/mcp-router.d.ts +16 -0
- package/dist/cli/mcp-router.d.ts.map +1 -0
- package/dist/cli/mcp-router.js +143 -0
- package/dist/cli/mcp-router.js.map +1 -0
- package/dist/cli/memory.d.ts +24 -0
- package/dist/cli/memory.d.ts.map +1 -0
- package/dist/cli/memory.js +885 -0
- package/dist/cli/memory.js.map +1 -0
- package/dist/cli/model.d.ts +15 -0
- package/dist/cli/model.d.ts.map +1 -0
- package/dist/cli/model.js +290 -0
- package/dist/cli/model.js.map +1 -0
- package/dist/cli/patterns.d.ts +26 -0
- package/dist/cli/patterns.d.ts.map +1 -0
- package/dist/cli/patterns.js +862 -0
- package/dist/cli/patterns.js.map +1 -0
- package/dist/cli/rtk-validation.d.ts +9 -0
- package/dist/cli/rtk-validation.d.ts.map +1 -0
- package/dist/cli/rtk-validation.js +9 -0
- package/dist/cli/rtk-validation.js.map +1 -0
- package/dist/cli/rtk.d.ts +34 -0
- package/dist/cli/rtk.d.ts.map +1 -0
- package/dist/cli/rtk.js +401 -0
- package/dist/cli/rtk.js.map +1 -0
- package/dist/cli/schema-diff.d.ts +7 -0
- package/dist/cli/schema-diff.d.ts.map +1 -0
- package/dist/cli/schema-diff.js +11 -0
- package/dist/cli/schema-diff.js.map +1 -0
- package/dist/cli/setup-mcp-router.d.ts +8 -0
- package/dist/cli/setup-mcp-router.d.ts.map +1 -0
- package/dist/cli/setup-mcp-router.js +163 -0
- package/dist/cli/setup-mcp-router.js.map +1 -0
- package/dist/cli/setup-wizard.d.ts +2 -0
- package/dist/cli/setup-wizard.d.ts.map +1 -0
- package/dist/cli/setup-wizard.js +806 -0
- package/dist/cli/setup-wizard.js.map +1 -0
- package/dist/cli/setup.d.ts +15 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +154 -0
- package/dist/cli/setup.js.map +1 -0
- package/dist/cli/sync.d.ts +8 -0
- package/dist/cli/sync.d.ts.map +1 -0
- package/dist/cli/sync.js +395 -0
- package/dist/cli/sync.js.map +1 -0
- package/dist/cli/task.d.ts +33 -0
- package/dist/cli/task.d.ts.map +1 -0
- package/dist/cli/task.js +672 -0
- package/dist/cli/task.js.map +1 -0
- package/dist/cli/tool-calls.d.ts +20 -0
- package/dist/cli/tool-calls.d.ts.map +1 -0
- package/dist/cli/tool-calls.js +605 -0
- package/dist/cli/tool-calls.js.map +1 -0
- package/dist/cli/uap.d.ts +10 -0
- package/dist/cli/uap.d.ts.map +1 -0
- package/dist/cli/uap.js +398 -0
- package/dist/cli/uap.js.map +1 -0
- package/dist/cli/update.d.ts +10 -0
- package/dist/cli/update.d.ts.map +1 -0
- package/dist/cli/update.js +300 -0
- package/dist/cli/update.js.map +1 -0
- package/dist/cli/visualize.d.ts +77 -0
- package/dist/cli/visualize.d.ts.map +1 -0
- package/dist/cli/visualize.js +287 -0
- package/dist/cli/visualize.js.map +1 -0
- package/dist/cli/worktree.d.ts +9 -0
- package/dist/cli/worktree.d.ts.map +1 -0
- package/dist/cli/worktree.js +213 -0
- package/dist/cli/worktree.js.map +1 -0
- package/dist/coordination/adaptive-patterns.d.ts +65 -0
- package/dist/coordination/adaptive-patterns.d.ts.map +1 -0
- package/dist/coordination/adaptive-patterns.js +108 -0
- package/dist/coordination/adaptive-patterns.js.map +1 -0
- package/dist/coordination/auto-agent.d.ts +82 -0
- package/dist/coordination/auto-agent.d.ts.map +1 -0
- package/dist/coordination/auto-agent.js +145 -0
- package/dist/coordination/auto-agent.js.map +1 -0
- package/dist/coordination/capability-router.d.ts +79 -0
- package/dist/coordination/capability-router.d.ts.map +1 -0
- package/dist/coordination/capability-router.js +334 -0
- package/dist/coordination/capability-router.js.map +1 -0
- package/dist/coordination/database.d.ts +13 -0
- package/dist/coordination/database.d.ts.map +1 -0
- package/dist/coordination/database.js +136 -0
- package/dist/coordination/database.js.map +1 -0
- package/dist/coordination/deploy-batcher.d.ts +122 -0
- package/dist/coordination/deploy-batcher.d.ts.map +1 -0
- package/dist/coordination/deploy-batcher.js +718 -0
- package/dist/coordination/deploy-batcher.js.map +1 -0
- package/dist/coordination/droid-validator.d.ts +59 -0
- package/dist/coordination/droid-validator.d.ts.map +1 -0
- package/dist/coordination/droid-validator.js +142 -0
- package/dist/coordination/droid-validator.js.map +1 -0
- package/dist/coordination/index.d.ts +10 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +10 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/pattern-router.d.ts +50 -0
- package/dist/coordination/pattern-router.d.ts.map +1 -0
- package/dist/coordination/pattern-router.js +118 -0
- package/dist/coordination/pattern-router.js.map +1 -0
- package/dist/coordination/service.d.ts +81 -0
- package/dist/coordination/service.d.ts.map +1 -0
- package/dist/coordination/service.js +619 -0
- package/dist/coordination/service.js.map +1 -0
- package/dist/coordination/worktree-enforcer.d.ts +22 -0
- package/dist/coordination/worktree-enforcer.d.ts.map +1 -0
- package/dist/coordination/worktree-enforcer.js +71 -0
- package/dist/coordination/worktree-enforcer.js.map +1 -0
- package/dist/generators/claude-md.d.ts +3 -0
- package/dist/generators/claude-md.d.ts.map +1 -0
- package/dist/generators/claude-md.js +1020 -0
- package/dist/generators/claude-md.js.map +1 -0
- package/dist/generators/template-loader.d.ts +105 -0
- package/dist/generators/template-loader.d.ts.map +1 -0
- package/dist/generators/template-loader.js +291 -0
- package/dist/generators/template-loader.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-router/config/parser.d.ts +9 -0
- package/dist/mcp-router/config/parser.d.ts.map +1 -0
- package/dist/mcp-router/config/parser.js +174 -0
- package/dist/mcp-router/config/parser.js.map +1 -0
- package/dist/mcp-router/executor/client.d.ts +31 -0
- package/dist/mcp-router/executor/client.d.ts.map +1 -0
- package/dist/mcp-router/executor/client.js +189 -0
- package/dist/mcp-router/executor/client.js.map +1 -0
- package/dist/mcp-router/index.d.ts +22 -0
- package/dist/mcp-router/index.d.ts.map +1 -0
- package/dist/mcp-router/index.js +18 -0
- package/dist/mcp-router/index.js.map +1 -0
- package/dist/mcp-router/output-compressor.d.ts +26 -0
- package/dist/mcp-router/output-compressor.d.ts.map +1 -0
- package/dist/mcp-router/output-compressor.js +236 -0
- package/dist/mcp-router/output-compressor.js.map +1 -0
- package/dist/mcp-router/search/fuzzy.d.ts +26 -0
- package/dist/mcp-router/search/fuzzy.d.ts.map +1 -0
- package/dist/mcp-router/search/fuzzy.js +94 -0
- package/dist/mcp-router/search/fuzzy.js.map +1 -0
- package/dist/mcp-router/server.d.ts +50 -0
- package/dist/mcp-router/server.d.ts.map +1 -0
- package/dist/mcp-router/server.js +229 -0
- package/dist/mcp-router/server.js.map +1 -0
- package/dist/mcp-router/session-stats.d.ts +37 -0
- package/dist/mcp-router/session-stats.d.ts.map +1 -0
- package/dist/mcp-router/session-stats.js +56 -0
- package/dist/mcp-router/session-stats.js.map +1 -0
- package/dist/mcp-router/tools/discover.d.ts +37 -0
- package/dist/mcp-router/tools/discover.d.ts.map +1 -0
- package/dist/mcp-router/tools/discover.js +65 -0
- package/dist/mcp-router/tools/discover.js.map +1 -0
- package/dist/mcp-router/tools/execute.d.ts +43 -0
- package/dist/mcp-router/tools/execute.d.ts.map +1 -0
- package/dist/mcp-router/tools/execute.js +144 -0
- package/dist/mcp-router/tools/execute.js.map +1 -0
- package/dist/mcp-router/types.d.ts +62 -0
- package/dist/mcp-router/types.d.ts.map +1 -0
- package/dist/mcp-router/types.js +6 -0
- package/dist/mcp-router/types.js.map +1 -0
- package/dist/memory/adaptive-context.d.ts +149 -0
- package/dist/memory/adaptive-context.d.ts.map +1 -0
- package/dist/memory/adaptive-context.js +1095 -0
- package/dist/memory/adaptive-context.js.map +1 -0
- package/dist/memory/agent-scoped-memory.d.ts +67 -0
- package/dist/memory/agent-scoped-memory.d.ts.map +1 -0
- package/dist/memory/agent-scoped-memory.js +126 -0
- package/dist/memory/agent-scoped-memory.js.map +1 -0
- package/dist/memory/ambiguity-detector.d.ts +54 -0
- package/dist/memory/ambiguity-detector.d.ts.map +1 -0
- package/dist/memory/ambiguity-detector.js +401 -0
- package/dist/memory/ambiguity-detector.js.map +1 -0
- package/dist/memory/backends/base.d.ts +18 -0
- package/dist/memory/backends/base.d.ts.map +1 -0
- package/dist/memory/backends/base.js +2 -0
- package/dist/memory/backends/base.js.map +1 -0
- package/dist/memory/backends/factory.d.ts +4 -0
- package/dist/memory/backends/factory.d.ts.map +1 -0
- package/dist/memory/backends/factory.js +53 -0
- package/dist/memory/backends/factory.js.map +1 -0
- package/dist/memory/backends/github.d.ts +27 -0
- package/dist/memory/backends/github.d.ts.map +1 -0
- package/dist/memory/backends/github.js +134 -0
- package/dist/memory/backends/github.js.map +1 -0
- package/dist/memory/backends/qdrant-cloud.d.ts +32 -0
- package/dist/memory/backends/qdrant-cloud.d.ts.map +1 -0
- package/dist/memory/backends/qdrant-cloud.js +167 -0
- package/dist/memory/backends/qdrant-cloud.js.map +1 -0
- package/dist/memory/context-compressor.d.ts +116 -0
- package/dist/memory/context-compressor.d.ts.map +1 -0
- package/dist/memory/context-compressor.js +430 -0
- package/dist/memory/context-compressor.js.map +1 -0
- package/dist/memory/context-pruner.d.ts +55 -0
- package/dist/memory/context-pruner.d.ts.map +1 -0
- package/dist/memory/context-pruner.js +85 -0
- package/dist/memory/context-pruner.js.map +1 -0
- package/dist/memory/correction-propagator.d.ts +44 -0
- package/dist/memory/correction-propagator.d.ts.map +1 -0
- package/dist/memory/correction-propagator.js +156 -0
- package/dist/memory/correction-propagator.js.map +1 -0
- package/dist/memory/daily-log.d.ts +67 -0
- package/dist/memory/daily-log.d.ts.map +1 -0
- package/dist/memory/daily-log.js +143 -0
- package/dist/memory/daily-log.js.map +1 -0
- package/dist/memory/dynamic-retrieval.d.ts +112 -0
- package/dist/memory/dynamic-retrieval.d.ts.map +1 -0
- package/dist/memory/dynamic-retrieval.js +908 -0
- package/dist/memory/dynamic-retrieval.js.map +1 -0
- package/dist/memory/embeddings.d.ts +172 -0
- package/dist/memory/embeddings.d.ts.map +1 -0
- package/dist/memory/embeddings.js +780 -0
- package/dist/memory/embeddings.js.map +1 -0
- package/dist/memory/generic-uap-patterns.d.ts +7 -0
- package/dist/memory/generic-uap-patterns.d.ts.map +1 -0
- package/dist/memory/generic-uap-patterns.js +43 -0
- package/dist/memory/generic-uap-patterns.js.map +1 -0
- package/dist/memory/hierarchical-memory.d.ts +141 -0
- package/dist/memory/hierarchical-memory.d.ts.map +1 -0
- package/dist/memory/hierarchical-memory.js +485 -0
- package/dist/memory/hierarchical-memory.js.map +1 -0
- package/dist/memory/knowledge-graph.d.ts +98 -0
- package/dist/memory/knowledge-graph.d.ts.map +1 -0
- package/dist/memory/knowledge-graph.js +275 -0
- package/dist/memory/knowledge-graph.js.map +1 -0
- package/dist/memory/memory-consolidator.d.ts +124 -0
- package/dist/memory/memory-consolidator.d.ts.map +1 -0
- package/dist/memory/memory-consolidator.js +514 -0
- package/dist/memory/memory-consolidator.js.map +1 -0
- package/dist/memory/memory-maintenance.d.ts +39 -0
- package/dist/memory/memory-maintenance.d.ts.map +1 -0
- package/dist/memory/memory-maintenance.js +336 -0
- package/dist/memory/memory-maintenance.js.map +1 -0
- package/dist/memory/model-router.d.ts +105 -0
- package/dist/memory/model-router.d.ts.map +1 -0
- package/dist/memory/model-router.js +474 -0
- package/dist/memory/model-router.js.map +1 -0
- package/dist/memory/multi-view-memory.d.ts +134 -0
- package/dist/memory/multi-view-memory.d.ts.map +1 -0
- package/dist/memory/multi-view-memory.js +430 -0
- package/dist/memory/multi-view-memory.js.map +1 -0
- package/dist/memory/predictive-memory.d.ts +79 -0
- package/dist/memory/predictive-memory.d.ts.map +1 -0
- package/dist/memory/predictive-memory.js +294 -0
- package/dist/memory/predictive-memory.js.map +1 -0
- package/dist/memory/prepopulate.d.ts +76 -0
- package/dist/memory/prepopulate.d.ts.map +1 -0
- package/dist/memory/prepopulate.js +832 -0
- package/dist/memory/prepopulate.js.map +1 -0
- package/dist/memory/semantic-compression.d.ts +77 -0
- package/dist/memory/semantic-compression.d.ts.map +1 -0
- package/dist/memory/semantic-compression.js +359 -0
- package/dist/memory/semantic-compression.js.map +1 -0
- package/dist/memory/serverless-qdrant.d.ts +102 -0
- package/dist/memory/serverless-qdrant.d.ts.map +1 -0
- package/dist/memory/serverless-qdrant.js +369 -0
- package/dist/memory/serverless-qdrant.js.map +1 -0
- package/dist/memory/short-term/factory.d.ts +26 -0
- package/dist/memory/short-term/factory.d.ts.map +1 -0
- package/dist/memory/short-term/factory.js +28 -0
- package/dist/memory/short-term/factory.js.map +1 -0
- package/dist/memory/short-term/indexeddb.d.ts +25 -0
- package/dist/memory/short-term/indexeddb.d.ts.map +1 -0
- package/dist/memory/short-term/indexeddb.js +64 -0
- package/dist/memory/short-term/indexeddb.js.map +1 -0
- package/dist/memory/short-term/schema.d.ts +6 -0
- package/dist/memory/short-term/schema.d.ts.map +1 -0
- package/dist/memory/short-term/schema.js +141 -0
- package/dist/memory/short-term/schema.js.map +1 -0
- package/dist/memory/short-term/sqlite.d.ts +64 -0
- package/dist/memory/short-term/sqlite.d.ts.map +1 -0
- package/dist/memory/short-term/sqlite.js +274 -0
- package/dist/memory/short-term/sqlite.js.map +1 -0
- package/dist/memory/speculative-cache.d.ts +111 -0
- package/dist/memory/speculative-cache.d.ts.map +1 -0
- package/dist/memory/speculative-cache.js +457 -0
- package/dist/memory/speculative-cache.js.map +1 -0
- package/dist/memory/task-classifier.d.ts +40 -0
- package/dist/memory/task-classifier.d.ts.map +1 -0
- package/dist/memory/task-classifier.js +342 -0
- package/dist/memory/task-classifier.js.map +1 -0
- package/dist/memory/terminal-bench-knowledge.d.ts +48 -0
- package/dist/memory/terminal-bench-knowledge.d.ts.map +1 -0
- package/dist/memory/terminal-bench-knowledge.js +622 -0
- package/dist/memory/terminal-bench-knowledge.js.map +1 -0
- package/dist/memory/write-gate.d.ts +39 -0
- package/dist/memory/write-gate.d.ts.map +1 -0
- package/dist/memory/write-gate.js +190 -0
- package/dist/memory/write-gate.js.map +1 -0
- package/dist/models/api-client.d.ts +46 -0
- package/dist/models/api-client.d.ts.map +1 -0
- package/dist/models/api-client.js +182 -0
- package/dist/models/api-client.js.map +1 -0
- package/dist/models/execution-profiles.d.ts +64 -0
- package/dist/models/execution-profiles.d.ts.map +1 -0
- package/dist/models/execution-profiles.js +403 -0
- package/dist/models/execution-profiles.js.map +1 -0
- package/dist/models/executor.d.ts +130 -0
- package/dist/models/executor.d.ts.map +1 -0
- package/dist/models/executor.js +382 -0
- package/dist/models/executor.js.map +1 -0
- package/dist/models/index.d.ts +19 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +23 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/plan-validator.d.ts +37 -0
- package/dist/models/plan-validator.d.ts.map +1 -0
- package/dist/models/plan-validator.js +179 -0
- package/dist/models/plan-validator.js.map +1 -0
- package/dist/models/planner.d.ts +73 -0
- package/dist/models/planner.d.ts.map +1 -0
- package/dist/models/planner.js +375 -0
- package/dist/models/planner.js.map +1 -0
- package/dist/models/router.d.ts +96 -0
- package/dist/models/router.d.ts.map +1 -0
- package/dist/models/router.js +523 -0
- package/dist/models/router.js.map +1 -0
- package/dist/models/types.d.ts +370 -0
- package/dist/models/types.d.ts.map +1 -0
- package/dist/models/types.js +232 -0
- package/dist/models/types.js.map +1 -0
- package/dist/models/unified-router.d.ts +152 -0
- package/dist/models/unified-router.d.ts.map +1 -0
- package/dist/models/unified-router.js +313 -0
- package/dist/models/unified-router.js.map +1 -0
- package/dist/policies/convert-policy-to-claude.d.ts +3 -0
- package/dist/policies/convert-policy-to-claude.d.ts.map +1 -0
- package/dist/policies/convert-policy-to-claude.js +87 -0
- package/dist/policies/convert-policy-to-claude.js.map +1 -0
- package/dist/policies/database-manager.d.ts +27 -0
- package/dist/policies/database-manager.d.ts.map +1 -0
- package/dist/policies/database-manager.js +198 -0
- package/dist/policies/database-manager.js.map +1 -0
- package/dist/policies/enforced-tool-router.d.ts +53 -0
- package/dist/policies/enforced-tool-router.d.ts.map +1 -0
- package/dist/policies/enforced-tool-router.js +80 -0
- package/dist/policies/enforced-tool-router.js.map +1 -0
- package/dist/policies/index.d.ts +10 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +8 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/policy-gate.d.ts +59 -0
- package/dist/policies/policy-gate.d.ts.map +1 -0
- package/dist/policies/policy-gate.js +171 -0
- package/dist/policies/policy-gate.js.map +1 -0
- package/dist/policies/policy-memory.d.ts +18 -0
- package/dist/policies/policy-memory.d.ts.map +1 -0
- package/dist/policies/policy-memory.js +126 -0
- package/dist/policies/policy-memory.js.map +1 -0
- package/dist/policies/policy-tools.d.ts +11 -0
- package/dist/policies/policy-tools.d.ts.map +1 -0
- package/dist/policies/policy-tools.js +66 -0
- package/dist/policies/policy-tools.js.map +1 -0
- package/dist/policies/schemas/policy.d.ts +69 -0
- package/dist/policies/schemas/policy.d.ts.map +1 -0
- package/dist/policies/schemas/policy.js +31 -0
- package/dist/policies/schemas/policy.js.map +1 -0
- package/dist/tasks/coordination.d.ts +83 -0
- package/dist/tasks/coordination.d.ts.map +1 -0
- package/dist/tasks/coordination.js +291 -0
- package/dist/tasks/coordination.js.map +1 -0
- package/dist/tasks/database.d.ts +19 -0
- package/dist/tasks/database.d.ts.map +1 -0
- package/dist/tasks/database.js +149 -0
- package/dist/tasks/database.js.map +1 -0
- package/dist/tasks/decoder-gate.d.ts +64 -0
- package/dist/tasks/decoder-gate.d.ts.map +1 -0
- package/dist/tasks/decoder-gate.js +268 -0
- package/dist/tasks/decoder-gate.js.map +1 -0
- package/dist/tasks/index.d.ts +6 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +6 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/tasks/service.d.ts +40 -0
- package/dist/tasks/service.d.ts.map +1 -0
- package/dist/tasks/service.js +671 -0
- package/dist/tasks/service.js.map +1 -0
- package/dist/tasks/types.d.ts +238 -0
- package/dist/tasks/types.d.ts.map +1 -0
- package/dist/tasks/types.js +74 -0
- package/dist/tasks/types.js.map +1 -0
- package/dist/telemetry/index.d.ts +2 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/session-telemetry.d.ts +56 -0
- package/dist/telemetry/session-telemetry.d.ts.map +1 -0
- package/dist/telemetry/session-telemetry.js +807 -0
- package/dist/telemetry/session-telemetry.js.map +1 -0
- package/dist/types/analysis.d.ts +82 -0
- package/dist/types/analysis.d.ts.map +1 -0
- package/dist/types/analysis.js +2 -0
- package/dist/types/analysis.js.map +1 -0
- package/dist/types/config.d.ts +3324 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +418 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/coordination.d.ts +240 -0
- package/dist/types/coordination.d.ts.map +1 -0
- package/dist/types/coordination.js +43 -0
- package/dist/types/coordination.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/uap-droids-strict.d.ts +59 -0
- package/dist/uap-droids-strict.d.ts.map +1 -0
- package/dist/uap-droids-strict.js +200 -0
- package/dist/uap-droids-strict.js.map +1 -0
- package/dist/utils/config-manager.d.ts +30 -0
- package/dist/utils/config-manager.d.ts.map +1 -0
- package/dist/utils/config-manager.js +41 -0
- package/dist/utils/config-manager.js.map +1 -0
- package/dist/utils/fetch-with-retry.d.ts +5 -0
- package/dist/utils/fetch-with-retry.d.ts.map +1 -0
- package/dist/utils/fetch-with-retry.js +61 -0
- package/dist/utils/fetch-with-retry.js.map +1 -0
- package/dist/utils/merge-claude-md.d.ts +28 -0
- package/dist/utils/merge-claude-md.d.ts.map +1 -0
- package/dist/utils/merge-claude-md.js +342 -0
- package/dist/utils/merge-claude-md.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +58 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +100 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/string-similarity.d.ts +37 -0
- package/dist/utils/string-similarity.d.ts.map +1 -0
- package/dist/utils/string-similarity.js +114 -0
- package/dist/utils/string-similarity.js.map +1 -0
- package/dist/utils/validate-json.d.ts +51 -0
- package/dist/utils/validate-json.d.ts.map +1 -0
- package/dist/utils/validate-json.js +94 -0
- package/dist/utils/validate-json.js.map +1 -0
- package/docs/INDEX.md +66 -0
- package/docs/architecture/MULTI_MODEL.md +224 -0
- package/docs/architecture/SYSTEM_ANALYSIS.md +1117 -0
- package/docs/architecture/UAP_COMPLIANCE.md +217 -0
- package/docs/architecture/UAP_PROTOCOL.md +339 -0
- package/docs/architecture/UAP_STRICT_DROIDS.md +172 -0
- package/docs/archive/BALLS_MODE_SELF_ANALYSIS.md +260 -0
- package/docs/archive/FAILING_TASKS_SOLUTION_PLAN.md +668 -0
- package/docs/archive/JINJA2-SYSTEM-MESSAGE-FIX.md +209 -0
- package/docs/archive/NPM-PUBLISH-V0.9.1.md +240 -0
- package/docs/archive/OPTIMIZATION_OPTIONS.md +334 -0
- package/docs/archive/SETUP_IMPROVEMENTS.md +213 -0
- package/docs/archive/UAP_GENERIC_OPTIMIZATION_PLAN.md +270 -0
- package/docs/archive/UAP_V103_PATTERN_DESIGN.md +315 -0
- package/docs/archive/UAP_V104_COMPLIANCE_DESIGN.md +223 -0
- package/docs/archive/changelog/2026-03-10_uap-100-compliance.md +77 -0
- package/docs/archive/changelog/2026-03-10_uap-full-system-verification.md +109 -0
- package/docs/benchmarks/ACCURACY_ANALYSIS.md +471 -0
- package/docs/benchmarks/TOKEN_OPTIMIZATION.md +572 -0
- package/docs/benchmarks/VALIDATION_PLAN.md +568 -0
- package/docs/benchmarks/VALIDATION_RESULTS.md +161 -0
- package/docs/deployment/DEPLOYMENT.md +895 -0
- package/docs/deployment/DEPLOYMENT_STRATEGIES.md +518 -0
- package/docs/deployment/DEPLOY_BATCHER_ANALYSIS.md +856 -0
- package/docs/deployment/DEPLOY_BATCHING.md +273 -0
- package/docs/deployment/DEPLOY_BUCKETING_ANALYSIS.md +420 -0
- package/docs/deployment/QWEN35_LLAMA_CPP.md +265 -0
- package/docs/getting-started/INTEGRATION.md +449 -0
- package/docs/getting-started/OVERVIEW.md +344 -0
- package/docs/getting-started/SETUP.md +203 -0
- package/docs/integrations/MCP_ROUTER_SETUP.md +445 -0
- package/docs/integrations/RTK_INTEGRATION.md +468 -0
- package/docs/operations/TROUBLESHOOTING.md +660 -0
- package/docs/reference/API_REFERENCE.md +903 -0
- package/docs/reference/FEATURES.md +472 -0
- package/docs/reference/HARNESS-MATRIX.md +318 -0
- package/docs/reference/UAP_CLI_REFERENCE.md +600 -0
- package/docs/research/BEHAVIORAL_PATTERNS.md +228 -0
- package/docs/research/DOMAIN_STRATEGIES.md +316 -0
- package/docs/research/MEMORY_SYSTEMS_COMPARISON.md +812 -0
- package/docs/research/PATTERN_ANALYSIS_2026-01-18.md +436 -0
- package/docs/research/PERFORMANCE_ANALYSIS_2026-01-18.md +209 -0
- package/docs/research/PERFORMANCE_TEST_PLAN.md +383 -0
- package/docs/research/TERMINAL_BENCH_LEARNINGS.md +217 -0
- package/package.json +113 -0
- package/scripts/README.md +161 -0
- package/templates/CLAUDE.template.md +10 -0
- package/templates/CLAUDE_ARCHITECTURE.template.md +103 -0
- package/templates/CLAUDE_CODING.template.md +127 -0
- package/templates/CLAUDE_DROIDS.template.md +109 -0
- package/templates/CLAUDE_MEMORY.template.md +131 -0
- package/templates/CLAUDE_WORKFLOWS.template.md +139 -0
- package/templates/PROJECT.template.md +209 -0
- package/templates/SCHEMA.md +57 -0
- package/templates/archive/CLAUDE.template.root-v6.md +534 -0
- package/templates/archive/CLAUDE.template.v6.md +534 -0
- package/templates/hooks/forgecode/pre-compact.sh +68 -0
- package/templates/hooks/forgecode/session-start.sh +169 -0
- package/templates/hooks/forgecode.plugin.sh +128 -0
- package/templates/hooks/pre-compact.sh +74 -0
- package/templates/hooks/session-start.sh +366 -0
- package/tools/agents/README.md +224 -0
- package/tools/agents/UAP/README.md +386 -0
- package/tools/agents/UAP/__init__.py +9 -0
- package/tools/agents/UAP/cli.py +901 -0
- package/tools/agents/UAP/compliance_verify.sh +108 -0
- package/tools/agents/UAP/full_verification.sh +126 -0
- package/tools/agents/UAP/version.py +32 -0
- package/tools/agents/benchmarks/benchmark_memory_systems.py +730 -0
- package/tools/agents/benchmarks/results/benchmark_20260106_064817.json +170 -0
- package/tools/agents/benchmarks/results/benchmark_20260106_064817.md +51 -0
- package/tools/agents/config/chat_template.jinja +77 -0
- package/tools/agents/config/tool-call-schema.json +19 -0
- package/tools/agents/config/tool-call.gbnf +58 -0
- package/tools/agents/docker/Dockerfile.python +52 -0
- package/tools/agents/docker/Dockerfile.ubuntu +55 -0
- package/tools/agents/docker-compose.qdrant.yml +24 -0
- package/tools/agents/install-opencode-local.sh.j2 +135 -0
- package/tools/agents/migrations/apply.py +256 -0
- package/tools/agents/opencode_uap_agent.py +1505 -0
- package/tools/agents/plugin/README.md +91 -0
- package/tools/agents/plugin/index.ts +46 -0
- package/tools/agents/plugin/pre-compact.sh +68 -0
- package/tools/agents/plugin/session-start.sh +175 -0
- package/tools/agents/plugin/uap-commands.ts +45 -0
- package/tools/agents/plugin/uap-droids.ts +54 -0
- package/tools/agents/plugin/uap-patterns.ts +54 -0
- package/tools/agents/plugin/uap-skills.ts +52 -0
- package/tools/agents/plugins/uap-enforce.ts +314 -0
- package/tools/agents/scripts/__pycache__/tool_call_wrapper.cpython-313.pyc +0 -0
- package/tools/agents/scripts/chat_template_verifier.py +343 -0
- package/tools/agents/scripts/fix-qwen-template.js +38 -0
- package/tools/agents/scripts/fix_qwen_chat_template.py +316 -0
- package/tools/agents/scripts/generate_lora_training_data.py +412 -0
- package/tools/agents/scripts/init_qdrant.py +151 -0
- package/tools/agents/scripts/memory_migration.py +560 -0
- package/tools/agents/scripts/migrate_memory_to_qdrant.py +110 -0
- package/tools/agents/scripts/prepare_lora.sh +512 -0
- package/tools/agents/scripts/query_memory.py +200 -0
- package/tools/agents/scripts/qwen-tool-call-test.js +38 -0
- package/tools/agents/scripts/qwen-tool-call-wrapper.js +38 -0
- package/tools/agents/scripts/qwen_tool_call_test.py +464 -0
- package/tools/agents/scripts/qwen_tool_call_wrapper.py +686 -0
- package/tools/agents/scripts/start-services.sh +96 -0
- package/tools/agents/scripts/tool-choice-proxy.cjs +296 -0
- package/tools/agents/scripts/tool_call_test.py +656 -0
- package/tools/agents/scripts/tool_call_wrapper.py +799 -0
- package/tools/agents/tests/test_uap_compliance.py +257 -0
- package/tools/agents/uap_agent.py +122 -0
- package/tools/agents/uap_agent_install.sh +12 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import { createHash, randomBytes } from 'crypto';
|
|
2
|
+
import { TaskDatabase, getDefaultTaskDbPath } from './database.js';
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
4
|
+
import { dirname } from 'path';
|
|
5
|
+
export class TaskService {
|
|
6
|
+
db;
|
|
7
|
+
jsonlPath;
|
|
8
|
+
agentId;
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
const dbPath = config.dbPath || getDefaultTaskDbPath();
|
|
11
|
+
this.db = TaskDatabase.getInstance(dbPath).getDatabase();
|
|
12
|
+
this.jsonlPath = config.jsonlPath || './.uap/tasks/tasks.jsonl';
|
|
13
|
+
this.agentId = config.agentId;
|
|
14
|
+
}
|
|
15
|
+
// ==================== ID Generation ====================
|
|
16
|
+
generateId() {
|
|
17
|
+
const bytes = randomBytes(4);
|
|
18
|
+
const hash = createHash('md5').update(bytes).digest('hex').slice(0, 4);
|
|
19
|
+
return `uap-${hash}`;
|
|
20
|
+
}
|
|
21
|
+
// ==================== CRUD Operations ====================
|
|
22
|
+
create(input) {
|
|
23
|
+
const id = this.generateId();
|
|
24
|
+
const now = new Date().toISOString();
|
|
25
|
+
const task = {
|
|
26
|
+
id,
|
|
27
|
+
title: input.title,
|
|
28
|
+
description: input.description,
|
|
29
|
+
type: input.type || 'task',
|
|
30
|
+
status: 'open',
|
|
31
|
+
priority: (input.priority ?? 2),
|
|
32
|
+
assignee: input.assignee,
|
|
33
|
+
labels: input.labels || [],
|
|
34
|
+
notes: input.notes,
|
|
35
|
+
parentId: input.parentId,
|
|
36
|
+
dueDate: input.dueDate,
|
|
37
|
+
createdAt: now,
|
|
38
|
+
updatedAt: now,
|
|
39
|
+
};
|
|
40
|
+
const stmt = this.db.prepare(`
|
|
41
|
+
INSERT INTO tasks (id, title, description, type, status, priority, assignee, labels, notes, parent_id, due_date, created_at, updated_at)
|
|
42
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
43
|
+
`);
|
|
44
|
+
stmt.run(task.id, task.title, task.description || null, task.type, task.status, task.priority, task.assignee || null, JSON.stringify(task.labels), task.notes || null, task.parentId || null, task.dueDate || null, task.createdAt, task.updatedAt);
|
|
45
|
+
// Record activity
|
|
46
|
+
this.recordActivity(id, 'created', `Created task: ${task.title}`);
|
|
47
|
+
// Record history
|
|
48
|
+
this.recordHistory(id, 'created', null, task.title);
|
|
49
|
+
return task;
|
|
50
|
+
}
|
|
51
|
+
get(id) {
|
|
52
|
+
const stmt = this.db.prepare(`
|
|
53
|
+
SELECT id, title, description, type, status, priority, assignee,
|
|
54
|
+
worktree_branch as worktreeBranch, labels, notes, parent_id as parentId,
|
|
55
|
+
due_date as dueDate, created_at as createdAt, updated_at as updatedAt,
|
|
56
|
+
closed_at as closedAt, closed_reason as closedReason
|
|
57
|
+
FROM tasks WHERE id = ?
|
|
58
|
+
`);
|
|
59
|
+
const row = stmt.get(id);
|
|
60
|
+
if (!row)
|
|
61
|
+
return null;
|
|
62
|
+
return {
|
|
63
|
+
...row,
|
|
64
|
+
labels: row.labels ? JSON.parse(row.labels) : [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
getWithRelations(id) {
|
|
68
|
+
const task = this.get(id);
|
|
69
|
+
if (!task)
|
|
70
|
+
return null;
|
|
71
|
+
const deps = this.getDependencies(id);
|
|
72
|
+
const blockedBy = deps
|
|
73
|
+
.filter((d) => d.fromTask === id && d.depType === 'blocks')
|
|
74
|
+
.map((d) => d.toTask);
|
|
75
|
+
const blocks = deps
|
|
76
|
+
.filter((d) => d.toTask === id && d.depType === 'blocks')
|
|
77
|
+
.map((d) => d.fromTask);
|
|
78
|
+
const relatedTo = deps
|
|
79
|
+
.filter((d) => d.depType === 'related')
|
|
80
|
+
.map((d) => (d.fromTask === id ? d.toTask : d.fromTask));
|
|
81
|
+
const children = this.getChildren(id).map((t) => t.id);
|
|
82
|
+
const parent = task.parentId ? this.get(task.parentId) || undefined : undefined;
|
|
83
|
+
// Check if blocked (has unresolved blocking dependencies)
|
|
84
|
+
const unresolvedBlockers = blockedBy.filter((blockerId) => {
|
|
85
|
+
const blocker = this.get(blockerId);
|
|
86
|
+
return blocker && blocker.status !== 'done' && blocker.status !== 'wont_do';
|
|
87
|
+
});
|
|
88
|
+
const isBlocked = unresolvedBlockers.length > 0;
|
|
89
|
+
const isReady = task.status === 'open' && !isBlocked;
|
|
90
|
+
return {
|
|
91
|
+
...task,
|
|
92
|
+
blockedBy,
|
|
93
|
+
blocks,
|
|
94
|
+
relatedTo,
|
|
95
|
+
children,
|
|
96
|
+
parent,
|
|
97
|
+
isBlocked,
|
|
98
|
+
isReady,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
update(id, input) {
|
|
102
|
+
const existing = this.get(id);
|
|
103
|
+
if (!existing)
|
|
104
|
+
return null;
|
|
105
|
+
const now = new Date().toISOString();
|
|
106
|
+
const updates = [];
|
|
107
|
+
const params = [];
|
|
108
|
+
// Track changes for history
|
|
109
|
+
const changes = [];
|
|
110
|
+
if (input.title !== undefined && input.title !== existing.title) {
|
|
111
|
+
updates.push('title = ?');
|
|
112
|
+
params.push(input.title);
|
|
113
|
+
changes.push({ field: 'title', oldValue: existing.title, newValue: input.title });
|
|
114
|
+
}
|
|
115
|
+
if (input.description !== undefined && input.description !== existing.description) {
|
|
116
|
+
updates.push('description = ?');
|
|
117
|
+
params.push(input.description || null);
|
|
118
|
+
changes.push({
|
|
119
|
+
field: 'description',
|
|
120
|
+
oldValue: existing.description || null,
|
|
121
|
+
newValue: input.description || null,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (input.type !== undefined && input.type !== existing.type) {
|
|
125
|
+
updates.push('type = ?');
|
|
126
|
+
params.push(input.type);
|
|
127
|
+
changes.push({ field: 'type', oldValue: existing.type, newValue: input.type });
|
|
128
|
+
}
|
|
129
|
+
if (input.status !== undefined && input.status !== existing.status) {
|
|
130
|
+
updates.push('status = ?');
|
|
131
|
+
params.push(input.status);
|
|
132
|
+
changes.push({ field: 'status', oldValue: existing.status, newValue: input.status });
|
|
133
|
+
// Set closed_at if closing
|
|
134
|
+
if (input.status === 'done' || input.status === 'wont_do') {
|
|
135
|
+
updates.push('closed_at = ?');
|
|
136
|
+
params.push(now);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (input.priority !== undefined && input.priority !== existing.priority) {
|
|
140
|
+
updates.push('priority = ?');
|
|
141
|
+
params.push(input.priority);
|
|
142
|
+
changes.push({
|
|
143
|
+
field: 'priority',
|
|
144
|
+
oldValue: String(existing.priority),
|
|
145
|
+
newValue: String(input.priority),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
if (input.assignee !== undefined && input.assignee !== existing.assignee) {
|
|
149
|
+
updates.push('assignee = ?');
|
|
150
|
+
params.push(input.assignee || null);
|
|
151
|
+
changes.push({
|
|
152
|
+
field: 'assignee',
|
|
153
|
+
oldValue: existing.assignee || null,
|
|
154
|
+
newValue: input.assignee || null,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (input.worktreeBranch !== undefined && input.worktreeBranch !== existing.worktreeBranch) {
|
|
158
|
+
updates.push('worktree_branch = ?');
|
|
159
|
+
params.push(input.worktreeBranch || null);
|
|
160
|
+
changes.push({
|
|
161
|
+
field: 'worktreeBranch',
|
|
162
|
+
oldValue: existing.worktreeBranch || null,
|
|
163
|
+
newValue: input.worktreeBranch || null,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (input.labels !== undefined) {
|
|
167
|
+
const newLabels = JSON.stringify(input.labels);
|
|
168
|
+
const oldLabels = JSON.stringify(existing.labels);
|
|
169
|
+
if (newLabels !== oldLabels) {
|
|
170
|
+
updates.push('labels = ?');
|
|
171
|
+
params.push(newLabels);
|
|
172
|
+
changes.push({ field: 'labels', oldValue: oldLabels, newValue: newLabels });
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (input.notes !== undefined && input.notes !== existing.notes) {
|
|
176
|
+
updates.push('notes = ?');
|
|
177
|
+
params.push(input.notes || null);
|
|
178
|
+
changes.push({
|
|
179
|
+
field: 'notes',
|
|
180
|
+
oldValue: existing.notes || null,
|
|
181
|
+
newValue: input.notes || null,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
if (input.dueDate !== undefined && input.dueDate !== existing.dueDate) {
|
|
185
|
+
updates.push('due_date = ?');
|
|
186
|
+
params.push(input.dueDate || null);
|
|
187
|
+
changes.push({
|
|
188
|
+
field: 'dueDate',
|
|
189
|
+
oldValue: existing.dueDate || null,
|
|
190
|
+
newValue: input.dueDate || null,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (updates.length === 0) {
|
|
194
|
+
return existing;
|
|
195
|
+
}
|
|
196
|
+
updates.push('updated_at = ?');
|
|
197
|
+
params.push(now);
|
|
198
|
+
params.push(id);
|
|
199
|
+
const stmt = this.db.prepare(`
|
|
200
|
+
UPDATE tasks SET ${updates.join(', ')} WHERE id = ?
|
|
201
|
+
`);
|
|
202
|
+
stmt.run(...params);
|
|
203
|
+
// Record history for each change
|
|
204
|
+
for (const change of changes) {
|
|
205
|
+
this.recordHistory(id, change.field, change.oldValue, change.newValue);
|
|
206
|
+
}
|
|
207
|
+
// Record activity
|
|
208
|
+
this.recordActivity(id, 'updated', `Updated: ${changes.map((c) => c.field).join(', ')}`);
|
|
209
|
+
return this.get(id);
|
|
210
|
+
}
|
|
211
|
+
close(id, reason) {
|
|
212
|
+
const task = this.get(id);
|
|
213
|
+
if (!task)
|
|
214
|
+
return null;
|
|
215
|
+
const now = new Date().toISOString();
|
|
216
|
+
const stmt = this.db.prepare(`
|
|
217
|
+
UPDATE tasks SET status = 'done', closed_at = ?, closed_reason = ?, updated_at = ?
|
|
218
|
+
WHERE id = ?
|
|
219
|
+
`);
|
|
220
|
+
stmt.run(now, reason || null, now, id);
|
|
221
|
+
this.recordHistory(id, 'status', task.status, 'done');
|
|
222
|
+
this.recordActivity(id, 'closed', reason || 'Task completed');
|
|
223
|
+
return this.get(id);
|
|
224
|
+
}
|
|
225
|
+
delete(id) {
|
|
226
|
+
// Delete dependencies first
|
|
227
|
+
this.db.prepare('DELETE FROM task_dependencies WHERE from_task = ? OR to_task = ?').run(id, id);
|
|
228
|
+
// Delete history
|
|
229
|
+
this.db.prepare('DELETE FROM task_history WHERE task_id = ?').run(id);
|
|
230
|
+
// Delete activity
|
|
231
|
+
this.db.prepare('DELETE FROM task_activity WHERE task_id = ?').run(id);
|
|
232
|
+
// Delete task
|
|
233
|
+
const result = this.db.prepare('DELETE FROM tasks WHERE id = ?').run(id);
|
|
234
|
+
return result.changes > 0;
|
|
235
|
+
}
|
|
236
|
+
// ==================== Query Operations ====================
|
|
237
|
+
hasDueDateColumn() {
|
|
238
|
+
try {
|
|
239
|
+
const columns = this.db.pragma('table_info(tasks)');
|
|
240
|
+
return columns.some((c) => c.name === 'due_date');
|
|
241
|
+
}
|
|
242
|
+
catch {
|
|
243
|
+
return false;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
list(filter = {}) {
|
|
247
|
+
const hasDueDate = this.hasDueDateColumn();
|
|
248
|
+
let sql = `
|
|
249
|
+
SELECT id, title, description, type, status, priority, assignee,
|
|
250
|
+
worktree_branch as worktreeBranch, labels, notes, parent_id as parentId,
|
|
251
|
+
${hasDueDate ? 'due_date as dueDate,' : 'NULL as dueDate,'}
|
|
252
|
+
created_at as createdAt, updated_at as updatedAt,
|
|
253
|
+
closed_at as closedAt, closed_reason as closedReason
|
|
254
|
+
FROM tasks WHERE 1=1
|
|
255
|
+
`;
|
|
256
|
+
const params = [];
|
|
257
|
+
if (filter.status) {
|
|
258
|
+
const statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
259
|
+
sql += ` AND status IN (${statuses.map(() => '?').join(',')})`;
|
|
260
|
+
params.push(...statuses);
|
|
261
|
+
}
|
|
262
|
+
if (filter.type) {
|
|
263
|
+
const types = Array.isArray(filter.type) ? filter.type : [filter.type];
|
|
264
|
+
sql += ` AND type IN (${types.map(() => '?').join(',')})`;
|
|
265
|
+
params.push(...types);
|
|
266
|
+
}
|
|
267
|
+
if (filter.priority !== undefined) {
|
|
268
|
+
const priorities = Array.isArray(filter.priority) ? filter.priority : [filter.priority];
|
|
269
|
+
sql += ` AND priority IN (${priorities.map(() => '?').join(',')})`;
|
|
270
|
+
params.push(...priorities);
|
|
271
|
+
}
|
|
272
|
+
if (filter.assignee) {
|
|
273
|
+
sql += ' AND assignee = ?';
|
|
274
|
+
params.push(filter.assignee);
|
|
275
|
+
}
|
|
276
|
+
if (filter.parentId) {
|
|
277
|
+
sql += ' AND parent_id = ?';
|
|
278
|
+
params.push(filter.parentId);
|
|
279
|
+
}
|
|
280
|
+
if (filter.labels && filter.labels.length > 0) {
|
|
281
|
+
// Match any of the specified labels
|
|
282
|
+
const labelConditions = filter.labels.map(() => 'labels LIKE ?');
|
|
283
|
+
sql += ` AND (${labelConditions.join(' OR ')})`;
|
|
284
|
+
params.push(...filter.labels.map((l) => `%"${l}"%`));
|
|
285
|
+
}
|
|
286
|
+
if (filter.search) {
|
|
287
|
+
sql += ' AND (title LIKE ? OR description LIKE ?)';
|
|
288
|
+
const searchPattern = `%${filter.search}%`;
|
|
289
|
+
params.push(searchPattern, searchPattern);
|
|
290
|
+
}
|
|
291
|
+
if (filter.overdue && hasDueDate) {
|
|
292
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
293
|
+
sql += ' AND due_date IS NOT NULL AND due_date < ? AND status NOT IN (?, ?)';
|
|
294
|
+
params.push(today, 'done', 'wont_do');
|
|
295
|
+
}
|
|
296
|
+
sql += ' ORDER BY priority ASC, created_at DESC';
|
|
297
|
+
const stmt = this.db.prepare(sql);
|
|
298
|
+
const rows = stmt.all(...params);
|
|
299
|
+
let tasks = rows.map((row) => ({
|
|
300
|
+
...row,
|
|
301
|
+
labels: row.labels ? JSON.parse(row.labels) : [],
|
|
302
|
+
}));
|
|
303
|
+
// Post-filter for blocked/ready (requires dependency check)
|
|
304
|
+
if (filter.isBlocked !== undefined || filter.isReady !== undefined) {
|
|
305
|
+
tasks = tasks.filter((task) => {
|
|
306
|
+
const withRelations = this.getWithRelations(task.id);
|
|
307
|
+
if (!withRelations)
|
|
308
|
+
return false;
|
|
309
|
+
if (filter.isBlocked !== undefined && withRelations.isBlocked !== filter.isBlocked) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
if (filter.isReady !== undefined && withRelations.isReady !== filter.isReady) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
return true;
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return tasks;
|
|
319
|
+
}
|
|
320
|
+
ready() {
|
|
321
|
+
const openTasks = this.list({ status: 'open' });
|
|
322
|
+
return openTasks
|
|
323
|
+
.map((t) => this.getWithRelations(t.id))
|
|
324
|
+
.filter((t) => t !== null && t.isReady);
|
|
325
|
+
}
|
|
326
|
+
blocked() {
|
|
327
|
+
const tasks = this.list({ status: ['open', 'in_progress'] });
|
|
328
|
+
return tasks
|
|
329
|
+
.map((t) => this.getWithRelations(t.id))
|
|
330
|
+
.filter((t) => t !== null && t.isBlocked);
|
|
331
|
+
}
|
|
332
|
+
getChildren(parentId) {
|
|
333
|
+
return this.list({ parentId });
|
|
334
|
+
}
|
|
335
|
+
// ==================== Dependencies ====================
|
|
336
|
+
addDependency(fromTask, toTask, depType = 'blocks') {
|
|
337
|
+
// Validate both tasks exist
|
|
338
|
+
if (!this.get(fromTask) || !this.get(toTask)) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
// Prevent self-dependency
|
|
342
|
+
if (fromTask === toTask) {
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
// Check for cycles (for blocking dependencies)
|
|
346
|
+
if (depType === 'blocks' && this.wouldCreateCycle(fromTask, toTask)) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
const now = new Date().toISOString();
|
|
350
|
+
try {
|
|
351
|
+
const stmt = this.db.prepare(`
|
|
352
|
+
INSERT INTO task_dependencies (from_task, to_task, dep_type, created_at)
|
|
353
|
+
VALUES (?, ?, ?, ?)
|
|
354
|
+
`);
|
|
355
|
+
const result = stmt.run(fromTask, toTask, depType, now);
|
|
356
|
+
return {
|
|
357
|
+
id: result.lastInsertRowid,
|
|
358
|
+
fromTask,
|
|
359
|
+
toTask,
|
|
360
|
+
depType,
|
|
361
|
+
createdAt: now,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
catch {
|
|
365
|
+
// Duplicate dependency
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
removeDependency(fromTask, toTask) {
|
|
370
|
+
const result = this.db
|
|
371
|
+
.prepare(`
|
|
372
|
+
DELETE FROM task_dependencies WHERE from_task = ? AND to_task = ?
|
|
373
|
+
`)
|
|
374
|
+
.run(fromTask, toTask);
|
|
375
|
+
return result.changes > 0;
|
|
376
|
+
}
|
|
377
|
+
getDependencies(taskId) {
|
|
378
|
+
const stmt = this.db.prepare(`
|
|
379
|
+
SELECT id, from_task as fromTask, to_task as toTask, dep_type as depType, created_at as createdAt
|
|
380
|
+
FROM task_dependencies
|
|
381
|
+
WHERE from_task = ? OR to_task = ?
|
|
382
|
+
`);
|
|
383
|
+
return stmt.all(taskId, taskId);
|
|
384
|
+
}
|
|
385
|
+
getBlockers(taskId) {
|
|
386
|
+
const stmt = this.db.prepare(`
|
|
387
|
+
SELECT t.* FROM tasks t
|
|
388
|
+
JOIN task_dependencies d ON t.id = d.to_task
|
|
389
|
+
WHERE d.from_task = ? AND d.dep_type = 'blocks'
|
|
390
|
+
`);
|
|
391
|
+
const rows = stmt.all(taskId);
|
|
392
|
+
return rows.map((row) => ({
|
|
393
|
+
...row,
|
|
394
|
+
labels: row.labels ? JSON.parse(row.labels) : [],
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
wouldCreateCycle(fromTask, toTask) {
|
|
398
|
+
// BFS to check if toTask can reach fromTask
|
|
399
|
+
const visited = new Set();
|
|
400
|
+
const queue = [toTask];
|
|
401
|
+
while (queue.length > 0) {
|
|
402
|
+
const current = queue.shift();
|
|
403
|
+
if (current === fromTask) {
|
|
404
|
+
return true; // Cycle detected
|
|
405
|
+
}
|
|
406
|
+
if (visited.has(current)) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
visited.add(current);
|
|
410
|
+
// Get tasks that current blocks
|
|
411
|
+
const stmt = this.db.prepare(`
|
|
412
|
+
SELECT to_task FROM task_dependencies
|
|
413
|
+
WHERE from_task = ? AND dep_type = 'blocks'
|
|
414
|
+
`);
|
|
415
|
+
const deps = stmt.all(current);
|
|
416
|
+
queue.push(...deps.map((d) => d.to_task));
|
|
417
|
+
}
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
// ==================== History & Activity ====================
|
|
421
|
+
recordHistory(taskId, field, oldValue, newValue) {
|
|
422
|
+
const stmt = this.db.prepare(`
|
|
423
|
+
INSERT INTO task_history (task_id, field, old_value, new_value, changed_by, changed_at)
|
|
424
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
425
|
+
`);
|
|
426
|
+
stmt.run(taskId, field, oldValue, newValue, this.agentId || null, new Date().toISOString());
|
|
427
|
+
}
|
|
428
|
+
recordActivity(taskId, activity, details) {
|
|
429
|
+
if (!this.agentId)
|
|
430
|
+
return;
|
|
431
|
+
const stmt = this.db.prepare(`
|
|
432
|
+
INSERT INTO task_activity (task_id, agent_id, activity, details, timestamp)
|
|
433
|
+
VALUES (?, ?, ?, ?, ?)
|
|
434
|
+
`);
|
|
435
|
+
stmt.run(taskId, this.agentId, activity, details || null, new Date().toISOString());
|
|
436
|
+
}
|
|
437
|
+
getHistory(taskId) {
|
|
438
|
+
const stmt = this.db.prepare(`
|
|
439
|
+
SELECT id, task_id as taskId, field, old_value as oldValue, new_value as newValue,
|
|
440
|
+
changed_by as changedBy, changed_at as changedAt
|
|
441
|
+
FROM task_history
|
|
442
|
+
WHERE task_id = ?
|
|
443
|
+
ORDER BY changed_at DESC
|
|
444
|
+
`);
|
|
445
|
+
return stmt.all(taskId);
|
|
446
|
+
}
|
|
447
|
+
getActivity(taskId) {
|
|
448
|
+
const stmt = this.db.prepare(`
|
|
449
|
+
SELECT id, task_id as taskId, agent_id as agentId, activity, details, timestamp
|
|
450
|
+
FROM task_activity
|
|
451
|
+
WHERE task_id = ?
|
|
452
|
+
ORDER BY timestamp DESC
|
|
453
|
+
`);
|
|
454
|
+
return stmt.all(taskId);
|
|
455
|
+
}
|
|
456
|
+
// ==================== Statistics ====================
|
|
457
|
+
getStats() {
|
|
458
|
+
const total = this.db.prepare('SELECT COUNT(*) as count FROM tasks').get().count;
|
|
459
|
+
const byStatus = {
|
|
460
|
+
open: 0,
|
|
461
|
+
in_progress: 0,
|
|
462
|
+
blocked: 0,
|
|
463
|
+
done: 0,
|
|
464
|
+
wont_do: 0,
|
|
465
|
+
};
|
|
466
|
+
const statusRows = this.db
|
|
467
|
+
.prepare('SELECT status, COUNT(*) as count FROM tasks GROUP BY status')
|
|
468
|
+
.all();
|
|
469
|
+
for (const row of statusRows) {
|
|
470
|
+
byStatus[row.status] = row.count;
|
|
471
|
+
}
|
|
472
|
+
const byType = {
|
|
473
|
+
task: 0,
|
|
474
|
+
bug: 0,
|
|
475
|
+
feature: 0,
|
|
476
|
+
epic: 0,
|
|
477
|
+
chore: 0,
|
|
478
|
+
story: 0,
|
|
479
|
+
};
|
|
480
|
+
const typeRows = this.db
|
|
481
|
+
.prepare('SELECT type, COUNT(*) as count FROM tasks GROUP BY type')
|
|
482
|
+
.all();
|
|
483
|
+
for (const row of typeRows) {
|
|
484
|
+
byType[row.type] = row.count;
|
|
485
|
+
}
|
|
486
|
+
const byPriority = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 };
|
|
487
|
+
const priorityRows = this.db
|
|
488
|
+
.prepare('SELECT priority, COUNT(*) as count FROM tasks GROUP BY priority')
|
|
489
|
+
.all();
|
|
490
|
+
for (const row of priorityRows) {
|
|
491
|
+
byPriority[row.priority] = row.count;
|
|
492
|
+
}
|
|
493
|
+
const blocked = this.blocked().length;
|
|
494
|
+
const ready = this.ready().length;
|
|
495
|
+
const today = new Date().toISOString().slice(0, 10);
|
|
496
|
+
let overdue = 0;
|
|
497
|
+
try {
|
|
498
|
+
overdue = this.db
|
|
499
|
+
.prepare(`SELECT COUNT(*) as count FROM tasks WHERE due_date IS NOT NULL AND due_date < ? AND status NOT IN ('done', 'wont_do')`)
|
|
500
|
+
.get(today).count;
|
|
501
|
+
}
|
|
502
|
+
catch {
|
|
503
|
+
// due_date column may not exist in older databases; degrade gracefully
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
total,
|
|
507
|
+
byStatus,
|
|
508
|
+
byType,
|
|
509
|
+
byPriority,
|
|
510
|
+
blocked,
|
|
511
|
+
ready,
|
|
512
|
+
overdue,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
// ==================== JSONL Sync ====================
|
|
516
|
+
exportToJSONL() {
|
|
517
|
+
const tasks = this.list({});
|
|
518
|
+
const lines = [];
|
|
519
|
+
for (const task of tasks) {
|
|
520
|
+
const deps = this.getDependencies(task.id)
|
|
521
|
+
.filter((d) => d.fromTask === task.id)
|
|
522
|
+
.map((d) => ({ toTask: d.toTask, depType: d.depType }));
|
|
523
|
+
const jsonl = {
|
|
524
|
+
id: task.id,
|
|
525
|
+
title: task.title,
|
|
526
|
+
description: task.description,
|
|
527
|
+
type: task.type,
|
|
528
|
+
status: task.status,
|
|
529
|
+
priority: task.priority,
|
|
530
|
+
assignee: task.assignee,
|
|
531
|
+
worktreeBranch: task.worktreeBranch,
|
|
532
|
+
labels: task.labels,
|
|
533
|
+
notes: task.notes,
|
|
534
|
+
parentId: task.parentId,
|
|
535
|
+
dueDate: task.dueDate,
|
|
536
|
+
createdAt: task.createdAt,
|
|
537
|
+
updatedAt: task.updatedAt,
|
|
538
|
+
closedAt: task.closedAt,
|
|
539
|
+
closedReason: task.closedReason,
|
|
540
|
+
dependencies: deps,
|
|
541
|
+
};
|
|
542
|
+
lines.push(JSON.stringify(jsonl));
|
|
543
|
+
}
|
|
544
|
+
return lines.join('\n');
|
|
545
|
+
}
|
|
546
|
+
saveToJSONL() {
|
|
547
|
+
const dir = dirname(this.jsonlPath);
|
|
548
|
+
if (!existsSync(dir)) {
|
|
549
|
+
mkdirSync(dir, { recursive: true });
|
|
550
|
+
}
|
|
551
|
+
const content = this.exportToJSONL();
|
|
552
|
+
writeFileSync(this.jsonlPath, content);
|
|
553
|
+
}
|
|
554
|
+
importFromJSONL() {
|
|
555
|
+
if (!existsSync(this.jsonlPath)) {
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
558
|
+
const content = readFileSync(this.jsonlPath, 'utf-8');
|
|
559
|
+
const lines = content.split('\n').filter((l) => l.trim());
|
|
560
|
+
let imported = 0;
|
|
561
|
+
for (const line of lines) {
|
|
562
|
+
try {
|
|
563
|
+
const data = JSON.parse(line);
|
|
564
|
+
// Check if task exists
|
|
565
|
+
const existing = this.get(data.id);
|
|
566
|
+
if (existing) {
|
|
567
|
+
// Update if JSONL is newer
|
|
568
|
+
if (data.updatedAt > existing.updatedAt) {
|
|
569
|
+
this.db
|
|
570
|
+
.prepare(`
|
|
571
|
+
UPDATE tasks SET title = ?, description = ?, type = ?, status = ?, priority = ?,
|
|
572
|
+
assignee = ?, worktree_branch = ?, labels = ?, notes = ?, parent_id = ?,
|
|
573
|
+
due_date = ?, updated_at = ?, closed_at = ?, closed_reason = ?
|
|
574
|
+
WHERE id = ?
|
|
575
|
+
`)
|
|
576
|
+
.run(data.title, data.description || null, data.type, data.status, data.priority, data.assignee || null, data.worktreeBranch || null, JSON.stringify(data.labels), data.notes || null, data.parentId || null, data.dueDate || null, data.updatedAt, data.closedAt || null, data.closedReason || null, data.id);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
// Insert new task
|
|
581
|
+
this.db
|
|
582
|
+
.prepare(`
|
|
583
|
+
INSERT INTO tasks (id, title, description, type, status, priority, assignee,
|
|
584
|
+
worktree_branch, labels, notes, parent_id, due_date, created_at, updated_at, closed_at, closed_reason)
|
|
585
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
586
|
+
`)
|
|
587
|
+
.run(data.id, data.title, data.description || null, data.type, data.status, data.priority, data.assignee || null, data.worktreeBranch || null, JSON.stringify(data.labels), data.notes || null, data.parentId || null, data.dueDate || null, data.createdAt, data.updatedAt, data.closedAt || null, data.closedReason || null);
|
|
588
|
+
imported++;
|
|
589
|
+
}
|
|
590
|
+
// Sync dependencies
|
|
591
|
+
for (const dep of data.dependencies || []) {
|
|
592
|
+
this.addDependency(data.id, dep.toTask, dep.depType);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
catch {
|
|
596
|
+
// Skip invalid lines
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return imported;
|
|
600
|
+
}
|
|
601
|
+
// ==================== Compaction ====================
|
|
602
|
+
compact(olderThanDays = 90) {
|
|
603
|
+
const cutoff = new Date(Date.now() - olderThanDays * 86400000).toISOString();
|
|
604
|
+
// Find old closed tasks
|
|
605
|
+
const stmt = this.db.prepare(`
|
|
606
|
+
SELECT id, title, type, labels, closed_at as closedAt
|
|
607
|
+
FROM tasks
|
|
608
|
+
WHERE status IN ('done', 'wont_do') AND closed_at < ?
|
|
609
|
+
ORDER BY closed_at ASC
|
|
610
|
+
`);
|
|
611
|
+
const oldTasks = stmt.all(cutoff);
|
|
612
|
+
if (oldTasks.length === 0) {
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
// Group by quarter
|
|
616
|
+
const quarters = new Map();
|
|
617
|
+
for (const task of oldTasks) {
|
|
618
|
+
const date = new Date(task.closedAt);
|
|
619
|
+
const quarter = `${date.getFullYear()}-Q${Math.floor(date.getMonth() / 3) + 1}`;
|
|
620
|
+
const existing = quarters.get(quarter) || [];
|
|
621
|
+
existing.push(task);
|
|
622
|
+
quarters.set(quarter, existing);
|
|
623
|
+
}
|
|
624
|
+
// Create summaries
|
|
625
|
+
const summaries = [];
|
|
626
|
+
for (const [period, tasks] of quarters) {
|
|
627
|
+
const allLabels = new Set();
|
|
628
|
+
for (const task of tasks) {
|
|
629
|
+
const labels = task.labels ? JSON.parse(task.labels) : [];
|
|
630
|
+
labels.forEach((l) => allLabels.add(l));
|
|
631
|
+
}
|
|
632
|
+
const summary = `Completed ${tasks.length} tasks: ${tasks
|
|
633
|
+
.slice(0, 5)
|
|
634
|
+
.map((t) => t.title)
|
|
635
|
+
.join(', ')}${tasks.length > 5 ? '...' : ''}`;
|
|
636
|
+
const insertStmt = this.db.prepare(`
|
|
637
|
+
INSERT INTO task_summaries (original_ids, summary, labels, closed_period, created_at)
|
|
638
|
+
VALUES (?, ?, ?, ?, ?)
|
|
639
|
+
`);
|
|
640
|
+
const result = insertStmt.run(JSON.stringify(tasks.map((t) => t.id)), summary, JSON.stringify([...allLabels]), period, new Date().toISOString());
|
|
641
|
+
summaries.push({
|
|
642
|
+
id: result.lastInsertRowid,
|
|
643
|
+
originalIds: tasks.map((t) => t.id),
|
|
644
|
+
summary,
|
|
645
|
+
labels: [...allLabels],
|
|
646
|
+
closedPeriod: period,
|
|
647
|
+
createdAt: new Date().toISOString(),
|
|
648
|
+
});
|
|
649
|
+
// Delete compacted tasks
|
|
650
|
+
const ids = tasks.map((t) => t.id);
|
|
651
|
+
this.db
|
|
652
|
+
.prepare(`DELETE FROM tasks WHERE id IN (${ids.map(() => '?').join(',')})`)
|
|
653
|
+
.run(...ids);
|
|
654
|
+
}
|
|
655
|
+
return summaries[0] || null;
|
|
656
|
+
}
|
|
657
|
+
getSummaries() {
|
|
658
|
+
const stmt = this.db.prepare(`
|
|
659
|
+
SELECT id, original_ids as originalIds, summary, labels, closed_period as closedPeriod, created_at as createdAt
|
|
660
|
+
FROM task_summaries
|
|
661
|
+
ORDER BY closed_period DESC
|
|
662
|
+
`);
|
|
663
|
+
const rows = stmt.all();
|
|
664
|
+
return rows.map((row) => ({
|
|
665
|
+
...row,
|
|
666
|
+
originalIds: JSON.parse(row.originalIds),
|
|
667
|
+
labels: row.labels ? JSON.parse(row.labels) : [],
|
|
668
|
+
}));
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
//# sourceMappingURL=service.js.map
|