prjct-cli 0.11.5 → 0.12.1
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/CHANGELOG.md +58 -0
- package/README.md +81 -25
- package/bin/dev.js +1 -1
- package/bin/generate-views.js +209 -0
- package/bin/migrate-to-json.js +742 -0
- package/bin/prjct +5 -5
- package/bin/serve.js +226 -50
- package/core/__tests__/agentic/{memory-system.test.js → memory-system.test.ts} +12 -23
- package/core/__tests__/agentic/{plan-mode.test.js → plan-mode.test.ts} +26 -24
- package/core/__tests__/agentic/{prompt-builder.test.js → prompt-builder.test.ts} +3 -8
- package/core/__tests__/utils/{date-helper.test.js → date-helper.test.ts} +19 -30
- package/core/__tests__/utils/{output.test.js → output.test.ts} +12 -24
- package/core/agentic/agent-router.ts +137 -0
- package/core/agentic/chain-of-thought.ts +228 -0
- package/core/agentic/command-executor/command-executor.ts +384 -0
- package/core/agentic/command-executor/index.ts +16 -0
- package/core/agentic/command-executor/status-signal.ts +38 -0
- package/core/agentic/command-executor/types.ts +79 -0
- package/core/agentic/command-executor.ts +8 -0
- package/core/agentic/{context-builder.js → context-builder.ts} +92 -81
- package/core/agentic/context-filter.ts +365 -0
- package/core/agentic/ground-truth/index.ts +76 -0
- package/core/agentic/ground-truth/types.ts +33 -0
- package/core/agentic/ground-truth/utils.ts +48 -0
- package/core/agentic/ground-truth/verifiers/analyze.ts +54 -0
- package/core/agentic/ground-truth/verifiers/done.ts +75 -0
- package/core/agentic/ground-truth/verifiers/feature.ts +70 -0
- package/core/agentic/ground-truth/verifiers/index.ts +37 -0
- package/core/agentic/ground-truth/verifiers/init.ts +52 -0
- package/core/agentic/ground-truth/verifiers/now.ts +57 -0
- package/core/agentic/ground-truth/verifiers/ship.ts +85 -0
- package/core/agentic/ground-truth/verifiers/spec.ts +45 -0
- package/core/agentic/ground-truth/verifiers/sync.ts +47 -0
- package/core/agentic/ground-truth/verifiers.ts +6 -0
- package/core/agentic/ground-truth.ts +8 -0
- package/core/agentic/loop-detector/error-analysis.ts +97 -0
- package/core/agentic/loop-detector/hallucination.ts +71 -0
- package/core/agentic/loop-detector/index.ts +41 -0
- package/core/agentic/loop-detector/loop-detector.ts +222 -0
- package/core/agentic/loop-detector/types.ts +66 -0
- package/core/agentic/loop-detector.ts +8 -0
- package/core/agentic/memory-system/history.ts +53 -0
- package/core/agentic/memory-system/index.ts +192 -0
- package/core/agentic/memory-system/patterns.ts +156 -0
- package/core/agentic/memory-system/semantic-memories.ts +277 -0
- package/core/agentic/memory-system/session.ts +21 -0
- package/core/agentic/memory-system/types.ts +159 -0
- package/core/agentic/memory-system.ts +8 -0
- package/core/agentic/parallel-tools.ts +165 -0
- package/core/agentic/plan-mode/approval.ts +57 -0
- package/core/agentic/plan-mode/constants.ts +44 -0
- package/core/agentic/plan-mode/index.ts +28 -0
- package/core/agentic/plan-mode/plan-mode.ts +406 -0
- package/core/agentic/plan-mode/types.ts +193 -0
- package/core/agentic/plan-mode.ts +8 -0
- package/core/agentic/prompt-builder.ts +566 -0
- package/core/agentic/response-templates.ts +164 -0
- package/core/agentic/semantic-compression.ts +273 -0
- package/core/agentic/services.ts +206 -0
- package/core/agentic/smart-context.ts +476 -0
- package/core/agentic/{template-loader.js → template-loader.ts} +27 -16
- package/core/agentic/think-blocks.ts +202 -0
- package/core/agentic/tool-registry.ts +119 -0
- package/core/agentic/validation-rules.ts +313 -0
- package/core/agents/index.ts +28 -0
- package/core/agents/performance.ts +444 -0
- package/core/agents/types.ts +126 -0
- package/core/bus/{index.js → index.ts} +57 -61
- package/core/command-registry/categories.ts +23 -0
- package/core/command-registry/commands.ts +15 -0
- package/core/command-registry/core-commands.ts +319 -0
- package/core/command-registry/index.ts +158 -0
- package/core/command-registry/optional-commands.ts +119 -0
- package/core/command-registry/setup-commands.ts +53 -0
- package/core/command-registry/types.ts +59 -0
- package/core/command-registry.ts +9 -0
- package/core/commands/analysis.ts +298 -0
- package/core/commands/analytics.ts +288 -0
- package/core/commands/base.ts +273 -0
- package/core/commands/index.ts +211 -0
- package/core/commands/maintenance.ts +226 -0
- package/core/commands/planning.ts +311 -0
- package/core/commands/setup.ts +309 -0
- package/core/commands/shipping.ts +188 -0
- package/core/commands/types.ts +183 -0
- package/core/commands/workflow.ts +226 -0
- package/core/commands.ts +11 -0
- package/core/constants/formats.ts +187 -0
- package/core/constants/index.ts +7 -0
- package/core/{context-sync.js → context-sync.ts} +59 -26
- package/core/data/agents-manager.ts +76 -0
- package/core/data/analysis-manager.ts +83 -0
- package/core/data/base-manager.ts +156 -0
- package/core/data/ideas-manager.ts +81 -0
- package/core/data/index.ts +32 -0
- package/core/data/outcomes-manager.ts +96 -0
- package/core/data/project-manager.ts +75 -0
- package/core/data/roadmap-manager.ts +118 -0
- package/core/data/shipped-manager.ts +65 -0
- package/core/data/state-manager.ts +214 -0
- package/core/domain/{agent-generator.js → agent-generator.ts} +77 -57
- package/core/domain/{agent-loader.js → agent-loader.ts} +65 -56
- package/core/domain/{agent-matcher.js → agent-matcher.ts} +51 -24
- package/core/domain/{agent-validator.js → agent-validator.ts} +70 -37
- package/core/domain/{analyzer.js → analyzer.ts} +91 -85
- package/core/domain/{architect-session.js → architect-session.ts} +49 -34
- package/core/domain/{architecture-generator.js → architecture-generator.ts} +25 -13
- package/core/domain/{context-estimator.js → context-estimator.ts} +57 -36
- package/core/domain/{product-standards.js → product-standards.ts} +40 -26
- package/core/domain/{smart-cache.js → smart-cache.ts} +39 -30
- package/core/domain/{snapshot-manager.js → snapshot-manager.ts} +103 -100
- package/core/domain/{task-analyzer.js → task-analyzer.ts} +82 -43
- package/core/domain/task-stack/index.ts +19 -0
- package/core/domain/task-stack/parser.ts +86 -0
- package/core/domain/task-stack/storage.ts +123 -0
- package/core/domain/task-stack/task-stack.ts +340 -0
- package/core/domain/task-stack/types.ts +51 -0
- package/core/domain/task-stack.ts +8 -0
- package/core/{index.js → index.ts} +61 -18
- package/core/infrastructure/{agent-detector.js → agent-detector.ts} +55 -19
- package/core/infrastructure/agents/{claude-agent.js → claude-agent.ts} +61 -21
- package/core/infrastructure/{author-detector.js → author-detector.ts} +42 -49
- package/core/infrastructure/{capability-installer.js → capability-installer.ts} +51 -27
- package/core/infrastructure/{command-installer.js → command-installer/command-installer.ts} +43 -144
- package/core/infrastructure/command-installer/global-config.ts +106 -0
- package/core/infrastructure/command-installer/index.ts +25 -0
- package/core/infrastructure/command-installer/types.ts +41 -0
- package/core/infrastructure/command-installer.ts +8 -0
- package/core/infrastructure/{config-manager.js → config-manager.ts} +60 -80
- package/core/infrastructure/{editors-config.js → editors-config.ts} +33 -31
- package/core/infrastructure/legacy-installer-detector/cleanup.ts +216 -0
- package/core/infrastructure/legacy-installer-detector/detection.ts +95 -0
- package/core/infrastructure/legacy-installer-detector/index.ts +171 -0
- package/core/infrastructure/legacy-installer-detector/migration.ts +87 -0
- package/core/infrastructure/legacy-installer-detector/types.ts +42 -0
- package/core/infrastructure/legacy-installer-detector.ts +7 -0
- package/core/infrastructure/migrator/file-operations.ts +125 -0
- package/core/infrastructure/migrator/index.ts +288 -0
- package/core/infrastructure/migrator/project-scanner.ts +89 -0
- package/core/infrastructure/migrator/reports.ts +117 -0
- package/core/infrastructure/migrator/types.ts +124 -0
- package/core/infrastructure/migrator/validation.ts +94 -0
- package/core/infrastructure/migrator/version-migration.ts +117 -0
- package/core/infrastructure/migrator.ts +10 -0
- package/core/infrastructure/{path-manager.js → path-manager.ts} +51 -91
- package/core/infrastructure/session-manager/index.ts +23 -0
- package/core/infrastructure/session-manager/migration.ts +88 -0
- package/core/infrastructure/session-manager/session-manager.ts +307 -0
- package/core/infrastructure/session-manager/types.ts +45 -0
- package/core/infrastructure/session-manager.ts +8 -0
- package/core/infrastructure/{setup.js → setup.ts} +29 -21
- package/core/infrastructure/{update-checker.js → update-checker.ts} +40 -18
- package/core/outcomes/analyzer.ts +333 -0
- package/core/outcomes/index.ts +34 -0
- package/core/outcomes/recorder.ts +194 -0
- package/core/outcomes/types.ts +145 -0
- package/core/plugin/{hooks.js → hooks.ts} +56 -58
- package/core/plugin/{index.js → index.ts} +19 -8
- package/core/plugin/{loader.js → loader.ts} +87 -69
- package/core/plugin/{registry.js → registry.ts} +49 -45
- package/core/plugins/{webhook.js → webhook.ts} +43 -27
- package/core/schemas/agents.ts +27 -0
- package/core/schemas/analysis.ts +41 -0
- package/core/schemas/ideas.ts +83 -0
- package/core/schemas/index.ts +73 -0
- package/core/schemas/outcomes.ts +22 -0
- package/core/schemas/project.ts +26 -0
- package/core/schemas/roadmap.ts +90 -0
- package/core/schemas/shipped.ts +82 -0
- package/core/schemas/state.ts +107 -0
- package/core/session/index.ts +17 -0
- package/core/session/{metrics.js → metrics.ts} +64 -46
- package/core/session/{index.js → session-manager.ts} +51 -117
- package/core/session/types.ts +29 -0
- package/core/session/utils.ts +57 -0
- package/core/state/index.ts +25 -0
- package/core/state/manager.ts +376 -0
- package/core/state/types.ts +185 -0
- package/core/tsconfig.json +22 -0
- package/core/types/index.ts +506 -0
- package/core/utils/{animations.js → animations.ts} +74 -28
- package/core/utils/{branding.js → branding.ts} +29 -4
- package/core/utils/{date-helper.js → date-helper.ts} +31 -74
- package/core/utils/file-helper.ts +262 -0
- package/core/utils/{jsonl-helper.js → jsonl-helper.ts} +71 -107
- package/core/utils/{logger.js → logger.ts} +24 -12
- package/core/utils/{output.js → output.ts} +25 -13
- package/core/utils/{project-capabilities.js → project-capabilities.ts} +31 -18
- package/core/utils/{session-helper.js → session-helper.ts} +79 -66
- package/core/utils/{version.js → version.ts} +23 -31
- package/core/view-generator.ts +536 -0
- package/package.json +23 -17
- package/packages/shared/.turbo/turbo-build.log +14 -0
- package/packages/shared/dist/index.d.ts +8 -613
- package/packages/shared/dist/index.d.ts.map +1 -0
- package/packages/shared/dist/index.js +4110 -118
- package/packages/shared/dist/schemas.d.ts +408 -0
- package/packages/shared/dist/schemas.d.ts.map +1 -0
- package/packages/shared/dist/types.d.ts +144 -0
- package/packages/shared/dist/types.d.ts.map +1 -0
- package/packages/shared/dist/unified.d.ts +139 -0
- package/packages/shared/dist/unified.d.ts.map +1 -0
- package/packages/shared/dist/utils.d.ts +60 -0
- package/packages/shared/dist/utils.d.ts.map +1 -0
- package/packages/shared/package.json +4 -4
- package/packages/shared/src/index.ts +1 -0
- package/packages/shared/src/unified.ts +174 -0
- package/packages/web/app/api/claude/sessions/route.ts +1 -1
- package/packages/web/app/api/claude/status/route.ts +1 -1
- package/packages/web/app/api/migrate/route.ts +46 -0
- package/packages/web/app/api/projects/[id]/route.ts +1 -1
- package/packages/web/app/api/projects/[id]/stats/route.ts +30 -2
- package/packages/web/app/api/projects/[id]/status/route.ts +1 -1
- package/packages/web/app/api/projects/route.ts +1 -1
- package/packages/web/app/api/settings/route.ts +97 -0
- package/packages/web/app/api/v2/projects/[id]/unified/route.ts +57 -0
- package/packages/web/app/globals.css +38 -0
- package/packages/web/app/layout.tsx +10 -2
- package/packages/web/app/page.tsx +9 -224
- package/packages/web/app/project/[id]/page.tsx +191 -63
- package/packages/web/app/project/[id]/stats/loading.tsx +43 -0
- package/packages/web/app/project/[id]/stats/page.tsx +204 -163
- package/packages/web/app/settings/page.tsx +222 -2
- package/packages/web/components/ActivityTimeline/ActivityTimeline.constants.ts +2 -0
- package/packages/web/components/ActivityTimeline/ActivityTimeline.tsx +50 -0
- package/packages/web/components/ActivityTimeline/ActivityTimeline.types.ts +8 -0
- package/packages/web/components/ActivityTimeline/hooks/index.ts +2 -0
- package/packages/web/components/ActivityTimeline/hooks/useExpandable.ts +9 -0
- package/packages/web/components/ActivityTimeline/hooks/useGroupedEvents.ts +23 -0
- package/packages/web/components/ActivityTimeline/index.ts +2 -0
- package/packages/web/components/AgentsCard/AgentsCard.tsx +63 -0
- package/packages/web/components/AgentsCard/AgentsCard.types.ts +13 -0
- package/packages/web/components/AgentsCard/index.ts +2 -0
- package/packages/web/components/AppSidebar/AppSidebar.tsx +190 -0
- package/packages/web/components/AppSidebar/index.ts +1 -0
- package/packages/web/components/BackLink/BackLink.tsx +18 -0
- package/packages/web/components/BackLink/BackLink.types.ts +5 -0
- package/packages/web/components/BackLink/index.ts +2 -0
- package/packages/web/components/BentoCard/BentoCard.constants.ts +16 -0
- package/packages/web/components/BentoCard/BentoCard.tsx +47 -0
- package/packages/web/components/BentoCard/BentoCard.types.ts +15 -0
- package/packages/web/components/BentoCard/index.ts +2 -0
- package/packages/web/components/BentoCardSkeleton/BentoCardSkeleton.constants.ts +9 -0
- package/packages/web/components/BentoCardSkeleton/BentoCardSkeleton.tsx +18 -0
- package/packages/web/components/BentoCardSkeleton/BentoCardSkeleton.types.ts +5 -0
- package/packages/web/components/BentoCardSkeleton/index.ts +2 -0
- package/packages/web/components/{stats → BentoGrid}/BentoGrid.tsx +4 -8
- package/packages/web/components/BentoGrid/BentoGrid.types.ts +4 -0
- package/packages/web/components/BentoGrid/index.ts +2 -0
- package/packages/web/components/CommandButton/index.ts +1 -0
- package/packages/web/components/ConnectionStatus/index.ts +1 -0
- package/packages/web/components/DashboardContent/DashboardContent.tsx +254 -0
- package/packages/web/components/DashboardContent/index.ts +1 -0
- package/packages/web/components/DateGroup/DateGroup.tsx +18 -0
- package/packages/web/components/DateGroup/DateGroup.types.ts +6 -0
- package/packages/web/components/DateGroup/DateGroup.utils.ts +11 -0
- package/packages/web/components/DateGroup/index.ts +2 -0
- package/packages/web/components/{stats → EmptyState}/EmptyState.tsx +1 -10
- package/packages/web/components/EmptyState/EmptyState.types.ts +10 -0
- package/packages/web/components/EmptyState/index.ts +2 -0
- package/packages/web/components/EventRow/EventRow.constants.ts +10 -0
- package/packages/web/components/EventRow/EventRow.tsx +49 -0
- package/packages/web/components/EventRow/EventRow.types.ts +7 -0
- package/packages/web/components/EventRow/EventRow.utils.ts +49 -0
- package/packages/web/components/EventRow/index.ts +2 -0
- package/packages/web/components/ExpandButton/ExpandButton.tsx +18 -0
- package/packages/web/components/ExpandButton/ExpandButton.types.ts +6 -0
- package/packages/web/components/ExpandButton/index.ts +2 -0
- package/packages/web/components/HealthGradientBackground/HealthGradientBackground.tsx +14 -0
- package/packages/web/components/HealthGradientBackground/HealthGradientBackground.types.ts +5 -0
- package/packages/web/components/HealthGradientBackground/HealthGradientBackground.utils.ts +13 -0
- package/packages/web/components/HealthGradientBackground/index.ts +2 -0
- package/packages/web/components/HeroSection/HeroSection.tsx +55 -0
- package/packages/web/components/HeroSection/HeroSection.types.ts +14 -0
- package/packages/web/components/HeroSection/HeroSection.utils.ts +7 -0
- package/packages/web/components/HeroSection/hooks/index.ts +2 -0
- package/packages/web/components/HeroSection/hooks/useCountUp.ts +45 -0
- package/packages/web/components/HeroSection/hooks/useWeeklyActivity.ts +18 -0
- package/packages/web/components/HeroSection/index.ts +2 -0
- package/packages/web/components/{stats → IdeasCard}/IdeasCard.tsx +3 -14
- package/packages/web/components/IdeasCard/IdeasCard.types.ts +9 -0
- package/packages/web/components/IdeasCard/index.ts +2 -0
- package/packages/web/components/InsightMessage/InsightMessage.tsx +9 -0
- package/packages/web/components/InsightMessage/InsightMessage.types.ts +3 -0
- package/packages/web/components/InsightMessage/index.ts +2 -0
- package/packages/web/components/Logo/index.ts +1 -0
- package/packages/web/components/MarkdownContent/index.ts +1 -0
- package/packages/web/components/NowCard/NowCard.tsx +93 -0
- package/packages/web/components/NowCard/NowCard.types.ts +15 -0
- package/packages/web/components/NowCard/index.ts +2 -0
- package/packages/web/components/ProgressRing/ProgressRing.constants.ts +20 -0
- package/packages/web/components/{stats → ProgressRing}/ProgressRing.tsx +4 -27
- package/packages/web/components/ProgressRing/ProgressRing.types.ts +11 -0
- package/packages/web/components/ProgressRing/index.ts +2 -0
- package/packages/web/components/ProjectAvatar/index.ts +1 -0
- package/packages/web/components/Providers/index.ts +1 -0
- package/packages/web/components/QueueCard/QueueCard.tsx +72 -0
- package/packages/web/components/QueueCard/QueueCard.types.ts +11 -0
- package/packages/web/components/QueueCard/QueueCard.utils.ts +12 -0
- package/packages/web/components/QueueCard/index.ts +2 -0
- package/packages/web/components/{stats → RoadmapCard}/RoadmapCard.tsx +3 -23
- package/packages/web/components/RoadmapCard/RoadmapCard.types.ts +15 -0
- package/packages/web/components/RoadmapCard/index.ts +2 -0
- package/packages/web/components/{stats → ShipsCard}/ShipsCard.tsx +4 -22
- package/packages/web/components/ShipsCard/ShipsCard.types.ts +12 -0
- package/packages/web/components/ShipsCard/ShipsCard.utils.ts +4 -0
- package/packages/web/components/ShipsCard/index.ts +2 -0
- package/packages/web/components/{stats → SparklineChart}/SparklineChart.tsx +1 -7
- package/packages/web/components/SparklineChart/SparklineChart.types.ts +6 -0
- package/packages/web/components/SparklineChart/index.ts +2 -0
- package/packages/web/components/StreakCard/StreakCard.constants.ts +2 -0
- package/packages/web/components/{stats → StreakCard}/StreakCard.tsx +5 -11
- package/packages/web/components/StreakCard/StreakCard.types.ts +4 -0
- package/packages/web/components/StreakCard/index.ts +2 -0
- package/packages/web/components/TasksCounter/TasksCounter.tsx +14 -0
- package/packages/web/components/TasksCounter/TasksCounter.types.ts +3 -0
- package/packages/web/components/TasksCounter/index.ts +2 -0
- package/packages/web/components/TechStackBadges/index.ts +1 -0
- package/packages/web/components/{TerminalTab.tsx → TerminalTabs/TerminalTab.tsx} +11 -0
- package/packages/web/components/{TerminalTabs.tsx → TerminalTabs/TerminalTabs.tsx} +29 -28
- package/packages/web/components/TerminalTabs/index.ts +1 -0
- package/packages/web/components/VelocityBadge/VelocityBadge.tsx +27 -0
- package/packages/web/components/VelocityBadge/VelocityBadge.types.ts +3 -0
- package/packages/web/components/VelocityBadge/index.ts +2 -0
- package/packages/web/components/VelocityCard/VelocityCard.tsx +71 -0
- package/packages/web/components/VelocityCard/VelocityCard.types.ts +7 -0
- package/packages/web/components/VelocityCard/index.ts +2 -0
- package/packages/web/components/WeeklySparkline/WeeklySparkline.tsx +13 -0
- package/packages/web/components/WeeklySparkline/WeeklySparkline.types.ts +3 -0
- package/packages/web/components/WeeklySparkline/index.ts +2 -0
- package/packages/web/components/ui/input.tsx +21 -0
- package/packages/web/context/TerminalTabsContext.tsx +46 -1
- package/packages/web/hooks/useClaudeTerminal.ts +71 -21
- package/packages/web/hooks/useProjectStats.ts +55 -0
- package/packages/web/hooks/useProjects.ts +6 -6
- package/packages/web/lib/actions/projects.ts +15 -0
- package/packages/web/lib/json-loader.ts +630 -0
- package/packages/web/lib/services/index.ts +9 -0
- package/packages/web/lib/services/migration.server.ts +600 -0
- package/packages/web/lib/services/projects.server.ts +52 -0
- package/packages/web/lib/services/stats.server.ts +264 -0
- package/packages/web/lib/unified-loader.ts +396 -0
- package/packages/web/package.json +10 -7
- package/packages/web/server.ts +58 -8
- package/templates/commands/done.md +76 -32
- package/templates/commands/feature.md +121 -47
- package/templates/commands/idea.md +81 -8
- package/templates/commands/now.md +41 -17
- package/templates/commands/ship.md +64 -25
- package/templates/commands/sync.md +28 -3
- package/core/agentic/agent-router.js +0 -140
- package/core/agentic/chain-of-thought.js +0 -578
- package/core/agentic/command-executor.js +0 -417
- package/core/agentic/context-filter.js +0 -354
- package/core/agentic/ground-truth.js +0 -591
- package/core/agentic/loop-detector.js +0 -406
- package/core/agentic/memory-system.js +0 -845
- package/core/agentic/parallel-tools.js +0 -366
- package/core/agentic/plan-mode.js +0 -572
- package/core/agentic/prompt-builder.js +0 -352
- package/core/agentic/response-templates.js +0 -290
- package/core/agentic/semantic-compression.js +0 -517
- package/core/agentic/think-blocks.js +0 -657
- package/core/agentic/tool-registry.js +0 -184
- package/core/agentic/validation-rules.js +0 -380
- package/core/command-registry.js +0 -698
- package/core/commands.js +0 -2237
- package/core/domain/task-stack.js +0 -497
- package/core/infrastructure/legacy-installer-detector.js +0 -546
- package/core/infrastructure/migrator.js +0 -796
- package/core/infrastructure/session-manager.js +0 -390
- package/core/utils/file-helper.js +0 -329
- package/packages/web/app/api/projects/[id]/delete/route.ts +0 -21
- package/packages/web/app/api/stats/route.ts +0 -38
- package/packages/web/components/AppSidebar.tsx +0 -113
- package/packages/web/components/stats/ActivityTimeline.tsx +0 -201
- package/packages/web/components/stats/AgentsCard.tsx +0 -56
- package/packages/web/components/stats/BentoCard.tsx +0 -88
- package/packages/web/components/stats/HeroSection.tsx +0 -172
- package/packages/web/components/stats/NowCard.tsx +0 -71
- package/packages/web/components/stats/QueueCard.tsx +0 -58
- package/packages/web/components/stats/VelocityCard.tsx +0 -60
- package/packages/web/components/stats/index.ts +0 -17
- package/packages/web/hooks/useStats.ts +0 -28
- /package/packages/web/components/{CommandButton.tsx → CommandButton/CommandButton.tsx} +0 -0
- /package/packages/web/components/{ConnectionStatus.tsx → ConnectionStatus/ConnectionStatus.tsx} +0 -0
- /package/packages/web/components/{Logo.tsx → Logo/Logo.tsx} +0 -0
- /package/packages/web/components/{MarkdownContent.tsx → MarkdownContent/MarkdownContent.tsx} +0 -0
- /package/packages/web/components/{ProjectAvatar.tsx → ProjectAvatar/ProjectAvatar.tsx} +0 -0
- /package/packages/web/components/{providers.tsx → Providers/Providers.tsx} +0 -0
- /package/packages/web/components/{TechStackBadges.tsx → TechStackBadges/TechStackBadges.tsx} +0 -0
|
@@ -1,657 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Think Blocks - Devin Pattern Implementation
|
|
3
|
-
*
|
|
4
|
-
* P3.1: Advanced reasoning layer that triggers <think> blocks
|
|
5
|
-
* in specific situations to prevent hallucination and improve decisions.
|
|
6
|
-
*
|
|
7
|
-
* WHEN TO THINK (Devin's rules):
|
|
8
|
-
* 1. Before critical git/GitHub decisions (branch, PR, merge)
|
|
9
|
-
* 2. When transitioning from exploration to editing
|
|
10
|
-
* 3. Before reporting task completion to user
|
|
11
|
-
* 4. When there's no clear next step
|
|
12
|
-
* 5. When encountering unexpected difficulties
|
|
13
|
-
* 6. When tests/CI fail unexpectedly
|
|
14
|
-
*
|
|
15
|
-
* Source: Devin AI system prompt
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const fs = require('fs').promises
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Think trigger types and their conditions
|
|
22
|
-
*/
|
|
23
|
-
const THINK_TRIGGERS = {
|
|
24
|
-
// Git/GitHub critical decisions
|
|
25
|
-
GIT_DECISION: {
|
|
26
|
-
id: 'git_decision',
|
|
27
|
-
description: 'Before critical git operations',
|
|
28
|
-
commands: ['ship', 'git'],
|
|
29
|
-
conditions: ['has_uncommitted', 'branch_decision', 'merge_conflict'],
|
|
30
|
-
priority: 1
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
// Transitioning from exploration to action
|
|
34
|
-
EXPLORE_TO_EDIT: {
|
|
35
|
-
id: 'explore_to_edit',
|
|
36
|
-
description: 'Transitioning from reading to editing',
|
|
37
|
-
commands: ['feature', 'spec', 'design'],
|
|
38
|
-
conditions: ['first_edit', 'complex_change'],
|
|
39
|
-
priority: 2
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
// Before reporting completion
|
|
43
|
-
REPORT_COMPLETE: {
|
|
44
|
-
id: 'report_complete',
|
|
45
|
-
description: 'Before marking task as done',
|
|
46
|
-
commands: ['done', 'ship'],
|
|
47
|
-
conditions: ['task_complete', 'feature_ship'],
|
|
48
|
-
priority: 1
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
// Unclear next step
|
|
52
|
-
UNCLEAR_NEXT: {
|
|
53
|
-
id: 'unclear_next',
|
|
54
|
-
description: 'No clear next action',
|
|
55
|
-
commands: ['next', 'help', 'suggest'],
|
|
56
|
-
conditions: ['empty_queue', 'ambiguous_state'],
|
|
57
|
-
priority: 3
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
// Unexpected difficulties
|
|
61
|
-
UNEXPECTED_ERROR: {
|
|
62
|
-
id: 'unexpected_error',
|
|
63
|
-
description: 'Something went wrong unexpectedly',
|
|
64
|
-
commands: ['*'],
|
|
65
|
-
conditions: ['test_fail', 'ci_fail', 'repeated_error'],
|
|
66
|
-
priority: 1
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
// Complex feature analysis
|
|
70
|
-
COMPLEX_ANALYSIS: {
|
|
71
|
-
id: 'complex_analysis',
|
|
72
|
-
description: 'Analyzing complex feature or system',
|
|
73
|
-
commands: ['analyze', 'spec', 'feature'],
|
|
74
|
-
conditions: ['multi_file', 'architecture_change'],
|
|
75
|
-
priority: 2
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Think block generator
|
|
81
|
-
*/
|
|
82
|
-
class ThinkBlocks {
|
|
83
|
-
constructor() {
|
|
84
|
-
this.triggers = THINK_TRIGGERS
|
|
85
|
-
this.thinkHistory = []
|
|
86
|
-
this.maxHistory = 50
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Detect if current context requires a think block
|
|
91
|
-
* @param {string} commandName - Command being executed
|
|
92
|
-
* @param {Object} context - Execution context
|
|
93
|
-
* @param {Object} state - Current state
|
|
94
|
-
* @returns {Object|null} Think trigger if applicable
|
|
95
|
-
*/
|
|
96
|
-
detectTrigger(commandName, context, state) {
|
|
97
|
-
const applicableTriggers = []
|
|
98
|
-
|
|
99
|
-
for (const [, trigger] of Object.entries(this.triggers)) {
|
|
100
|
-
// Check if command matches
|
|
101
|
-
const commandMatches =
|
|
102
|
-
trigger.commands.includes('*') ||
|
|
103
|
-
trigger.commands.includes(commandName)
|
|
104
|
-
|
|
105
|
-
if (!commandMatches) continue
|
|
106
|
-
|
|
107
|
-
// Check conditions
|
|
108
|
-
const conditionsMet = this._checkConditions(trigger.conditions, context, state)
|
|
109
|
-
|
|
110
|
-
if (conditionsMet.length > 0) {
|
|
111
|
-
applicableTriggers.push({
|
|
112
|
-
...trigger,
|
|
113
|
-
metConditions: conditionsMet
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Return highest priority trigger
|
|
119
|
-
if (applicableTriggers.length === 0) return null
|
|
120
|
-
|
|
121
|
-
applicableTriggers.sort((a, b) => a.priority - b.priority)
|
|
122
|
-
return applicableTriggers[0]
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Check which conditions are met
|
|
127
|
-
* @private
|
|
128
|
-
*/
|
|
129
|
-
_checkConditions(conditions, context, state) {
|
|
130
|
-
const met = []
|
|
131
|
-
|
|
132
|
-
for (const condition of conditions) {
|
|
133
|
-
const checker = this._getConditionChecker(condition)
|
|
134
|
-
if (checker && checker(context, state)) {
|
|
135
|
-
met.push(condition)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return met
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Get condition checker function
|
|
144
|
-
* @private
|
|
145
|
-
*/
|
|
146
|
-
_getConditionChecker(condition) {
|
|
147
|
-
const checkers = {
|
|
148
|
-
// Git conditions
|
|
149
|
-
has_uncommitted: (ctx) => ctx.groundTruth?.actual?.hasUncommittedChanges,
|
|
150
|
-
branch_decision: (ctx) => ctx.params?.branch || ctx.needsBranch,
|
|
151
|
-
merge_conflict: (ctx) => ctx.groundTruth?.actual?.hasMergeConflict,
|
|
152
|
-
|
|
153
|
-
// State conditions
|
|
154
|
-
task_complete: (ctx, state) => state.now && state.now.trim() !== '',
|
|
155
|
-
feature_ship: (ctx) => ctx.params?.feature || ctx.params?.description,
|
|
156
|
-
empty_queue: (ctx, state) => !state.next || state.next.trim() === '',
|
|
157
|
-
ambiguous_state: (ctx, state) => !state.now && !state.next,
|
|
158
|
-
|
|
159
|
-
// Complexity conditions
|
|
160
|
-
first_edit: (ctx) => ctx.isFirstEdit,
|
|
161
|
-
complex_change: (ctx) => ctx.params?.complex || ctx.filesAffected > 5,
|
|
162
|
-
multi_file: (ctx) => ctx.filesAffected > 3,
|
|
163
|
-
architecture_change: (ctx, state) => {
|
|
164
|
-
const desc = ctx.params?.description?.toLowerCase() || ''
|
|
165
|
-
return desc.includes('refactor') ||
|
|
166
|
-
desc.includes('architecture') ||
|
|
167
|
-
desc.includes('migrate')
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
// Error conditions
|
|
171
|
-
test_fail: (ctx) => ctx.groundTruth?.actual?.testsFailed,
|
|
172
|
-
ci_fail: (ctx) => ctx.groundTruth?.actual?.ciFailed,
|
|
173
|
-
repeated_error: (ctx) => ctx.errorCount > 2
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return checkers[condition]
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Generate a think block for the given trigger
|
|
181
|
-
* @param {Object} trigger - The triggered think condition
|
|
182
|
-
* @param {string} commandName - Command being executed
|
|
183
|
-
* @param {Object} context - Execution context
|
|
184
|
-
* @param {Object} state - Current state
|
|
185
|
-
* @returns {Object} Think block content
|
|
186
|
-
*/
|
|
187
|
-
async generate(trigger, commandName, context, state) {
|
|
188
|
-
const thinkBlock = {
|
|
189
|
-
id: `think_${Date.now()}`,
|
|
190
|
-
trigger: trigger.id,
|
|
191
|
-
command: commandName,
|
|
192
|
-
timestamp: new Date().toISOString(),
|
|
193
|
-
questions: [],
|
|
194
|
-
observations: [],
|
|
195
|
-
conclusions: [],
|
|
196
|
-
plan: [],
|
|
197
|
-
confidence: 0
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Generate questions based on trigger type
|
|
201
|
-
const generator = this._getThinkGenerator(trigger.id)
|
|
202
|
-
if (generator) {
|
|
203
|
-
const content = await generator.call(this, context, state, trigger)
|
|
204
|
-
Object.assign(thinkBlock, content)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// Calculate confidence
|
|
208
|
-
thinkBlock.confidence = this._calculateConfidence(thinkBlock)
|
|
209
|
-
|
|
210
|
-
// Add to history
|
|
211
|
-
this._addToHistory(thinkBlock)
|
|
212
|
-
|
|
213
|
-
return thinkBlock
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Get think generator for trigger type
|
|
218
|
-
* @private
|
|
219
|
-
*/
|
|
220
|
-
_getThinkGenerator(triggerId) {
|
|
221
|
-
const generators = {
|
|
222
|
-
git_decision: this._thinkGitDecision,
|
|
223
|
-
explore_to_edit: this._thinkExploreToEdit,
|
|
224
|
-
report_complete: this._thinkReportComplete,
|
|
225
|
-
unclear_next: this._thinkUnclearNext,
|
|
226
|
-
unexpected_error: this._thinkUnexpectedError,
|
|
227
|
-
complex_analysis: this._thinkComplexAnalysis
|
|
228
|
-
}
|
|
229
|
-
return generators[triggerId]
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Think: Git Decision
|
|
234
|
-
* @private
|
|
235
|
-
*/
|
|
236
|
-
async _thinkGitDecision(context, state, trigger) {
|
|
237
|
-
const questions = [
|
|
238
|
-
'What git operation am I about to perform?',
|
|
239
|
-
'Are there uncommitted changes that should be included?',
|
|
240
|
-
'What branch should this go on?',
|
|
241
|
-
'Should I create a PR or commit directly?'
|
|
242
|
-
]
|
|
243
|
-
|
|
244
|
-
const observations = []
|
|
245
|
-
const conclusions = []
|
|
246
|
-
const plan = []
|
|
247
|
-
|
|
248
|
-
// Check uncommitted changes
|
|
249
|
-
if (context.groundTruth?.actual?.hasUncommittedChanges) {
|
|
250
|
-
observations.push(`Found ${context.groundTruth.actual.uncommittedFiles} uncommitted files`)
|
|
251
|
-
conclusions.push('Should commit changes before proceeding')
|
|
252
|
-
plan.push('Stage relevant changes')
|
|
253
|
-
plan.push('Create commit with prjct footer')
|
|
254
|
-
} else {
|
|
255
|
-
observations.push('No uncommitted changes')
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Check branch
|
|
259
|
-
if (context.groundTruth?.actual?.currentBranch) {
|
|
260
|
-
observations.push(`Current branch: ${context.groundTruth.actual.currentBranch}`)
|
|
261
|
-
if (context.groundTruth.actual.currentBranch === 'main') {
|
|
262
|
-
conclusions.push('On main branch - consider feature branch for safety')
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// Version check
|
|
267
|
-
if (context.groundTruth?.actual?.currentVersion) {
|
|
268
|
-
observations.push(`Current version: ${context.groundTruth.actual.currentVersion}`)
|
|
269
|
-
if (trigger.metConditions.includes('feature_ship')) {
|
|
270
|
-
conclusions.push('May need version bump')
|
|
271
|
-
plan.push('Check if version bump needed')
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
plan.push('Execute git operation')
|
|
276
|
-
plan.push('Verify success')
|
|
277
|
-
|
|
278
|
-
return { questions, observations, conclusions, plan }
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Think: Explore to Edit transition
|
|
283
|
-
* @private
|
|
284
|
-
*/
|
|
285
|
-
async _thinkExploreToEdit(context, state, trigger) {
|
|
286
|
-
const questions = [
|
|
287
|
-
'What have I learned from exploring the codebase?',
|
|
288
|
-
'Am I confident about the changes needed?',
|
|
289
|
-
'What files will be affected?',
|
|
290
|
-
'Are there any risks or edge cases?'
|
|
291
|
-
]
|
|
292
|
-
|
|
293
|
-
const observations = []
|
|
294
|
-
const conclusions = []
|
|
295
|
-
const plan = []
|
|
296
|
-
|
|
297
|
-
// Feature analysis
|
|
298
|
-
const featureDesc = context.params?.description || context.params?.feature
|
|
299
|
-
if (featureDesc) {
|
|
300
|
-
observations.push(`Feature: "${featureDesc}"`)
|
|
301
|
-
|
|
302
|
-
// Complexity assessment
|
|
303
|
-
const complexKeywords = ['auth', 'payment', 'database', 'refactor', 'migrate', 'security']
|
|
304
|
-
const isComplex = complexKeywords.some(kw => featureDesc.toLowerCase().includes(kw))
|
|
305
|
-
|
|
306
|
-
if (isComplex) {
|
|
307
|
-
conclusions.push('This is a complex feature - proceed carefully')
|
|
308
|
-
plan.push('Create spec document first')
|
|
309
|
-
plan.push('Break into small tasks (20-30 min each)')
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// Files affected
|
|
314
|
-
if (context.filesAffected) {
|
|
315
|
-
observations.push(`Estimated files affected: ${context.filesAffected}`)
|
|
316
|
-
if (context.filesAffected > 5) {
|
|
317
|
-
conclusions.push('Multiple files affected - consider incremental approach')
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
plan.push('Document design decision')
|
|
322
|
-
plan.push('Start with smallest change first')
|
|
323
|
-
plan.push('Test after each change')
|
|
324
|
-
|
|
325
|
-
return { questions, observations, conclusions, plan }
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Think: Report Complete
|
|
330
|
-
* @private
|
|
331
|
-
*/
|
|
332
|
-
async _thinkReportComplete(context, state, trigger) {
|
|
333
|
-
const questions = [
|
|
334
|
-
'Is the task actually complete?',
|
|
335
|
-
'Have all acceptance criteria been met?',
|
|
336
|
-
'Are there any tests I should run?',
|
|
337
|
-
'Is the code ready for review?'
|
|
338
|
-
]
|
|
339
|
-
|
|
340
|
-
const observations = []
|
|
341
|
-
const conclusions = []
|
|
342
|
-
const plan = []
|
|
343
|
-
|
|
344
|
-
// Check current task
|
|
345
|
-
if (state.now) {
|
|
346
|
-
const taskName = this._extractTaskName(state.now)
|
|
347
|
-
observations.push(`Current task: "${taskName}"`)
|
|
348
|
-
|
|
349
|
-
// Check for started time
|
|
350
|
-
const startMatch = state.now.match(/Started:\s*(.+)/i)
|
|
351
|
-
if (startMatch) {
|
|
352
|
-
const duration = this._calculateDuration(startMatch[1])
|
|
353
|
-
observations.push(`Duration: ${duration}`)
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
// Ground truth verification
|
|
358
|
-
if (context.groundTruth?.verified === false) {
|
|
359
|
-
conclusions.push('Ground truth verification found issues')
|
|
360
|
-
context.groundTruth.warnings?.forEach(w => {
|
|
361
|
-
conclusions.push(`Warning: ${w}`)
|
|
362
|
-
})
|
|
363
|
-
} else {
|
|
364
|
-
conclusions.push('Ground truth verification passed')
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// Check for tests
|
|
368
|
-
if (context.groundTruth?.actual?.hasTestScript) {
|
|
369
|
-
observations.push('Project has tests')
|
|
370
|
-
plan.push('Run tests to verify')
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
plan.push('Mark task complete')
|
|
374
|
-
plan.push('Update metrics')
|
|
375
|
-
plan.push('Suggest next task')
|
|
376
|
-
|
|
377
|
-
return { questions, observations, conclusions, plan }
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Think: Unclear Next Step
|
|
382
|
-
* @private
|
|
383
|
-
*/
|
|
384
|
-
async _thinkUnclearNext(context, state, trigger) {
|
|
385
|
-
const questions = [
|
|
386
|
-
'What is the current project state?',
|
|
387
|
-
'What was the last completed task?',
|
|
388
|
-
'Are there any pending items in the queue?',
|
|
389
|
-
'What should the user focus on?'
|
|
390
|
-
]
|
|
391
|
-
|
|
392
|
-
const observations = []
|
|
393
|
-
const conclusions = []
|
|
394
|
-
const plan = []
|
|
395
|
-
|
|
396
|
-
// Check queue
|
|
397
|
-
if (!state.next || state.next.trim() === '') {
|
|
398
|
-
observations.push('Queue is empty')
|
|
399
|
-
conclusions.push('User needs to add tasks or features')
|
|
400
|
-
plan.push('Suggest /p:feature or /p:idea')
|
|
401
|
-
} else {
|
|
402
|
-
const taskCount = (state.next.match(/- \[ \]/g) || []).length
|
|
403
|
-
observations.push(`Queue has ${taskCount} pending tasks`)
|
|
404
|
-
plan.push('Show top priority task')
|
|
405
|
-
plan.push('Suggest starting with /p:now')
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// Check roadmap
|
|
409
|
-
if (state.roadmap && state.roadmap.trim() !== '') {
|
|
410
|
-
observations.push('Roadmap exists')
|
|
411
|
-
plan.push('Check roadmap for planned features')
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// Check ideas
|
|
415
|
-
if (state.ideas && state.ideas.trim() !== '') {
|
|
416
|
-
observations.push('Ideas backlog exists')
|
|
417
|
-
plan.push('Review ideas for inspiration')
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return { questions, observations, conclusions, plan }
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Think: Unexpected Error
|
|
425
|
-
* @private
|
|
426
|
-
*/
|
|
427
|
-
async _thinkUnexpectedError(context, state, trigger) {
|
|
428
|
-
const questions = [
|
|
429
|
-
'What error occurred?',
|
|
430
|
-
'Is this a known issue?',
|
|
431
|
-
'Have I seen this pattern before?',
|
|
432
|
-
'What are the possible solutions?'
|
|
433
|
-
]
|
|
434
|
-
|
|
435
|
-
const observations = []
|
|
436
|
-
const conclusions = []
|
|
437
|
-
const plan = []
|
|
438
|
-
|
|
439
|
-
// Error analysis
|
|
440
|
-
if (context.lastError) {
|
|
441
|
-
observations.push(`Error: ${context.lastError.message || context.lastError}`)
|
|
442
|
-
|
|
443
|
-
// Pattern matching
|
|
444
|
-
const errorPatterns = {
|
|
445
|
-
permission: /permission|EACCES|denied/i,
|
|
446
|
-
not_found: /not found|ENOENT|missing/i,
|
|
447
|
-
syntax: /syntax|parse|unexpected/i,
|
|
448
|
-
network: /network|ECONNREFUSED|timeout/i,
|
|
449
|
-
git: /git|merge|conflict/i
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
for (const [type, pattern] of Object.entries(errorPatterns)) {
|
|
453
|
-
if (pattern.test(context.lastError.message || context.lastError)) {
|
|
454
|
-
conclusions.push(`Error type: ${type}`)
|
|
455
|
-
break
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Error count
|
|
461
|
-
if (context.errorCount > 2) {
|
|
462
|
-
conclusions.push(`Repeated error (${context.errorCount} times) - may need different approach`)
|
|
463
|
-
plan.push('Consider alternative approach')
|
|
464
|
-
plan.push('Ask user for help if stuck')
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
plan.push('Analyze error details')
|
|
468
|
-
plan.push('Try recovery action')
|
|
469
|
-
plan.push('Report to user if unresolvable')
|
|
470
|
-
|
|
471
|
-
return { questions, observations, conclusions, plan }
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Think: Complex Analysis
|
|
476
|
-
* @private
|
|
477
|
-
*/
|
|
478
|
-
async _thinkComplexAnalysis(context, state, trigger) {
|
|
479
|
-
const questions = [
|
|
480
|
-
'What is the scope of this analysis?',
|
|
481
|
-
'What components are involved?',
|
|
482
|
-
'Are there dependencies between components?',
|
|
483
|
-
'What is the best order to proceed?'
|
|
484
|
-
]
|
|
485
|
-
|
|
486
|
-
const observations = []
|
|
487
|
-
const conclusions = []
|
|
488
|
-
const plan = []
|
|
489
|
-
|
|
490
|
-
const desc = context.params?.description || context.params?.feature || ''
|
|
491
|
-
|
|
492
|
-
// Scope assessment
|
|
493
|
-
if (desc.includes('refactor')) {
|
|
494
|
-
observations.push('This is a refactoring task')
|
|
495
|
-
conclusions.push('Need to understand existing code first')
|
|
496
|
-
plan.push('Map current architecture')
|
|
497
|
-
plan.push('Identify affected components')
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
if (desc.includes('migrate')) {
|
|
501
|
-
observations.push('This is a migration task')
|
|
502
|
-
conclusions.push('Need migration strategy with rollback plan')
|
|
503
|
-
plan.push('Document current state')
|
|
504
|
-
plan.push('Plan incremental migration')
|
|
505
|
-
plan.push('Create rollback strategy')
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if (desc.includes('architecture')) {
|
|
509
|
-
observations.push('This involves architecture changes')
|
|
510
|
-
conclusions.push('High-impact change - needs careful planning')
|
|
511
|
-
plan.push('Create architecture diagram')
|
|
512
|
-
plan.push('Get user approval before proceeding')
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
// Default plan additions
|
|
516
|
-
plan.push('Break into small incremental changes')
|
|
517
|
-
plan.push('Test after each change')
|
|
518
|
-
plan.push('Document decisions')
|
|
519
|
-
|
|
520
|
-
return { questions, observations, conclusions, plan }
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Format think block for output
|
|
525
|
-
* @param {Object} thinkBlock - Generated think block
|
|
526
|
-
* @param {boolean} verbose - Whether to show full output
|
|
527
|
-
* @returns {string}
|
|
528
|
-
*/
|
|
529
|
-
format(thinkBlock, verbose = false) {
|
|
530
|
-
if (!thinkBlock) return ''
|
|
531
|
-
|
|
532
|
-
const lines = ['<think>']
|
|
533
|
-
|
|
534
|
-
// Questions (only in verbose)
|
|
535
|
-
if (verbose && thinkBlock.questions.length > 0) {
|
|
536
|
-
lines.push('QUESTIONS:')
|
|
537
|
-
thinkBlock.questions.forEach(q => lines.push(` ? ${q}`))
|
|
538
|
-
lines.push('')
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// Observations
|
|
542
|
-
if (thinkBlock.observations.length > 0) {
|
|
543
|
-
lines.push('OBSERVATIONS:')
|
|
544
|
-
thinkBlock.observations.forEach(o => lines.push(` • ${o}`))
|
|
545
|
-
lines.push('')
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
// Conclusions
|
|
549
|
-
if (thinkBlock.conclusions.length > 0) {
|
|
550
|
-
lines.push('CONCLUSIONS:')
|
|
551
|
-
thinkBlock.conclusions.forEach(c => lines.push(` → ${c}`))
|
|
552
|
-
lines.push('')
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// Plan
|
|
556
|
-
if (thinkBlock.plan.length > 0) {
|
|
557
|
-
lines.push('PLAN:')
|
|
558
|
-
thinkBlock.plan.forEach((p, i) => lines.push(` ${i + 1}. ${p}`))
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
lines.push('</think>')
|
|
562
|
-
lines.push(`Confidence: ${Math.round(thinkBlock.confidence * 100)}%`)
|
|
563
|
-
|
|
564
|
-
return lines.join('\n')
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* Format compact version for prompts
|
|
569
|
-
* @param {Object} thinkBlock
|
|
570
|
-
* @returns {string}
|
|
571
|
-
*/
|
|
572
|
-
formatCompact(thinkBlock) {
|
|
573
|
-
if (!thinkBlock) return ''
|
|
574
|
-
|
|
575
|
-
const parts = []
|
|
576
|
-
|
|
577
|
-
if (thinkBlock.conclusions.length > 0) {
|
|
578
|
-
parts.push(`Conclusions: ${thinkBlock.conclusions.join('; ')}`)
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if (thinkBlock.plan.length > 0) {
|
|
582
|
-
parts.push(`Plan: ${thinkBlock.plan.slice(0, 3).join(' → ')}`)
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
return `<think>${parts.join(' | ')}</think>`
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// Helper methods
|
|
589
|
-
|
|
590
|
-
_extractTaskName(nowContent) {
|
|
591
|
-
if (!nowContent) return ''
|
|
592
|
-
const lines = nowContent.split('\n')
|
|
593
|
-
for (const line of lines) {
|
|
594
|
-
if (line.startsWith('**') || line.startsWith('# ')) {
|
|
595
|
-
return line.replace(/[*#]/g, '').trim()
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
return nowContent.substring(0, 50).trim()
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
_calculateDuration(startTime) {
|
|
602
|
-
try {
|
|
603
|
-
const start = new Date(startTime)
|
|
604
|
-
const now = new Date()
|
|
605
|
-
const ms = now - start
|
|
606
|
-
const hours = Math.floor(ms / (1000 * 60 * 60))
|
|
607
|
-
const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60))
|
|
608
|
-
return hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`
|
|
609
|
-
} catch {
|
|
610
|
-
return 'unknown'
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
_calculateConfidence(thinkBlock) {
|
|
615
|
-
let score = 0.5 // Base confidence
|
|
616
|
-
|
|
617
|
-
// More observations = more confidence
|
|
618
|
-
score += Math.min(thinkBlock.observations.length * 0.1, 0.3)
|
|
619
|
-
|
|
620
|
-
// Clear conclusions = more confidence
|
|
621
|
-
score += Math.min(thinkBlock.conclusions.length * 0.1, 0.2)
|
|
622
|
-
|
|
623
|
-
// Having a plan = more confidence
|
|
624
|
-
if (thinkBlock.plan.length > 0) score += 0.1
|
|
625
|
-
|
|
626
|
-
return Math.min(score, 1.0)
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
_addToHistory(thinkBlock) {
|
|
630
|
-
this.thinkHistory.unshift(thinkBlock)
|
|
631
|
-
if (this.thinkHistory.length > this.maxHistory) {
|
|
632
|
-
this.thinkHistory.pop()
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/**
|
|
637
|
-
* Get recent think history
|
|
638
|
-
* @param {number} limit
|
|
639
|
-
* @returns {Array}
|
|
640
|
-
*/
|
|
641
|
-
getHistory(limit = 10) {
|
|
642
|
-
return this.thinkHistory.slice(0, limit)
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
/**
|
|
646
|
-
* Check if we should think based on command and context
|
|
647
|
-
* @param {string} commandName
|
|
648
|
-
* @param {Object} context
|
|
649
|
-
* @param {Object} state
|
|
650
|
-
* @returns {boolean}
|
|
651
|
-
*/
|
|
652
|
-
shouldThink(commandName, context, state) {
|
|
653
|
-
return this.detectTrigger(commandName, context, state) !== null
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
module.exports = new ThinkBlocks()
|