@compilr-dev/cli 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +108 -0
- package/README.md +237 -69
- package/dist/.tsbuildinfo.app +1 -0
- package/dist/.tsbuildinfo.data +1 -0
- package/dist/.tsbuildinfo.domain +1 -0
- package/dist/.tsbuildinfo.foundation +1 -0
- package/dist/agent.d.ts +61 -4
- package/dist/agent.js +241 -245
- package/dist/anchors/index.d.ts +1 -1
- package/dist/anchors/index.js +1 -1
- package/dist/anchors/project-anchors.d.ts +2 -2
- package/dist/anchors/project-anchors.js +1 -1
- package/dist/auth/api-client.d.ts +124 -0
- package/dist/auth/api-client.js +261 -0
- package/dist/auth/index.d.ts +172 -0
- package/dist/auth/index.js +545 -0
- package/dist/auth/storage.d.ts +52 -0
- package/dist/auth/storage.js +118 -0
- package/dist/changelog/index.d.ts +16 -0
- package/dist/changelog/index.js +24 -0
- package/dist/changelog/releases.d.ts +17 -0
- package/dist/changelog/releases.js +63 -0
- package/dist/commands-v2/handlers/auth.d.ts +10 -0
- package/dist/commands-v2/handlers/auth.js +118 -0
- package/dist/commands-v2/handlers/background.d.ts +14 -0
- package/dist/commands-v2/handlers/background.js +276 -0
- package/dist/commands-v2/handlers/context.js +286 -81
- package/dist/commands-v2/handlers/core.d.ts +1 -0
- package/dist/commands-v2/handlers/core.js +133 -8
- package/dist/commands-v2/handlers/debug.js +18 -0
- package/dist/commands-v2/handlers/delegations.d.ts +8 -0
- package/dist/commands-v2/handlers/delegations.js +29 -0
- package/dist/commands-v2/handlers/files.d.ts +8 -0
- package/dist/commands-v2/handlers/files.js +162 -0
- package/dist/commands-v2/handlers/filter.d.ts +9 -0
- package/dist/commands-v2/handlers/filter.js +130 -0
- package/dist/commands-v2/handlers/games.d.ts +7 -0
- package/dist/commands-v2/handlers/games.js +57 -0
- package/dist/commands-v2/handlers/index.d.ts +13 -0
- package/dist/commands-v2/handlers/index.js +39 -0
- package/dist/commands-v2/handlers/mcp.d.ts +8 -0
- package/dist/commands-v2/handlers/mcp.js +39 -0
- package/dist/commands-v2/handlers/notifications.d.ts +9 -0
- package/dist/commands-v2/handlers/notifications.js +34 -0
- package/dist/commands-v2/handlers/project.js +295 -31
- package/dist/commands-v2/handlers/reset.d.ts +11 -0
- package/dist/commands-v2/handlers/reset.js +118 -0
- package/dist/commands-v2/handlers/session.d.ts +161 -0
- package/dist/commands-v2/handlers/session.js +805 -0
- package/dist/commands-v2/handlers/settings.d.ts +2 -0
- package/dist/commands-v2/handlers/settings.js +217 -35
- package/dist/commands-v2/handlers/tasks.d.ts +5 -0
- package/dist/commands-v2/handlers/tasks.js +36 -0
- package/dist/commands-v2/handlers/team.d.ts +9 -0
- package/dist/commands-v2/handlers/team.js +549 -0
- package/dist/commands-v2/handlers/terminals.d.ts +9 -0
- package/dist/commands-v2/handlers/terminals.js +34 -0
- package/dist/commands-v2/index.d.ts +3 -2
- package/dist/commands-v2/index.js +4 -1
- package/dist/commands-v2/registry.d.ts +15 -0
- package/dist/commands-v2/registry.js +34 -0
- package/dist/commands-v2/types.d.ts +81 -3
- package/dist/commands.js +13 -0
- package/dist/compilr-diff-companion.vsix +0 -0
- package/dist/db/index.js +98 -4
- package/dist/db/repositories/document-repository.d.ts +2 -0
- package/dist/db/repositories/document-repository.js +6 -1
- package/dist/db/repositories/index.d.ts +2 -0
- package/dist/db/repositories/index.js +1 -0
- package/dist/db/repositories/plan-repository.d.ts +101 -0
- package/dist/db/repositories/plan-repository.js +275 -0
- package/dist/db/repositories/project-repository.d.ts +6 -0
- package/dist/db/repositories/project-repository.js +41 -0
- package/dist/db/repositories/work-item-repository.d.ts +15 -0
- package/dist/db/repositories/work-item-repository.js +69 -4
- package/dist/db/schema.d.ts +40 -3
- package/dist/db/schema.js +66 -3
- package/dist/episodes/index.d.ts +20 -0
- package/dist/episodes/index.js +27 -0
- package/dist/episodes/recorder.d.ts +51 -0
- package/dist/episodes/recorder.js +195 -0
- package/dist/episodes/significant-work.d.ts +21 -0
- package/dist/episodes/significant-work.js +56 -0
- package/dist/episodes/store.d.ts +38 -0
- package/dist/episodes/store.js +199 -0
- package/dist/episodes/types.d.ts +35 -0
- package/dist/episodes/types.js +6 -0
- package/dist/episodes/work-at-risk.d.ts +12 -0
- package/dist/episodes/work-at-risk.js +38 -0
- package/dist/episodes/work-summary-anchor.d.ts +23 -0
- package/dist/episodes/work-summary-anchor.js +73 -0
- package/dist/games/coins.d.ts +66 -0
- package/dist/games/coins.js +165 -0
- package/dist/games/game-base.d.ts +84 -0
- package/dist/games/game-base.js +204 -0
- package/dist/games/index.d.ts +16 -0
- package/dist/games/index.js +49 -0
- package/dist/games/scores.d.ts +69 -0
- package/dist/games/scores.js +191 -0
- package/dist/games/tetris/board.d.ts +59 -0
- package/dist/games/tetris/board.js +170 -0
- package/dist/games/tetris/index.d.ts +109 -0
- package/dist/games/tetris/index.js +610 -0
- package/dist/games/tetris/pieces.d.ts +44 -0
- package/dist/games/tetris/pieces.js +271 -0
- package/dist/games/tetris/renderer.d.ts +26 -0
- package/dist/games/tetris/renderer.js +77 -0
- package/dist/guide/guide-content.d.ts +23 -0
- package/dist/guide/guide-content.js +196 -0
- package/dist/guide/index.d.ts +8 -0
- package/dist/guide/index.js +7 -0
- package/dist/guide/shared-content.d.ts +37 -0
- package/dist/guide/shared-content.js +1272 -0
- package/dist/guide/tutorial-helpers.d.ts +57 -0
- package/dist/guide/tutorial-helpers.js +147 -0
- package/dist/handlers/ask-user-handlers.d.ts +32 -0
- package/dist/handlers/ask-user-handlers.js +104 -0
- package/dist/handlers/delegation-handlers.d.ts +34 -0
- package/dist/handlers/delegation-handlers.js +291 -0
- package/dist/handlers/permission-handler.d.ts +30 -0
- package/dist/handlers/permission-handler.js +205 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +448 -271
- package/dist/input-handlers/memory-handler.d.ts +1 -1
- package/dist/input-handlers/memory-handler.js +2 -1
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +12 -0
- package/dist/models/model-registry.d.ts +38 -0
- package/dist/models/model-registry.js +69 -0
- package/dist/models/model-tiers.d.ts +28 -0
- package/dist/models/model-tiers.js +71 -0
- package/dist/models/model-validation.d.ts +25 -0
- package/dist/models/model-validation.js +291 -0
- package/dist/models/ollama-models.d.ts +73 -0
- package/dist/models/ollama-models.js +178 -0
- package/dist/models/provider-types.d.ts +6 -0
- package/dist/models/provider-types.js +1 -0
- package/dist/models/providers.d.ts +35 -0
- package/dist/models/providers.js +58 -0
- package/dist/models/types.d.ts +4 -0
- package/dist/models/types.js +4 -0
- package/dist/multi-agent/activity.d.ts +21 -0
- package/dist/multi-agent/activity.js +34 -0
- package/dist/multi-agent/agent-selection.d.ts +55 -0
- package/dist/multi-agent/agent-selection.js +90 -0
- package/dist/multi-agent/artifacts.d.ts +197 -0
- package/dist/multi-agent/artifacts.js +379 -0
- package/dist/multi-agent/checkpointer.d.ts +138 -0
- package/dist/multi-agent/checkpointer.js +471 -0
- package/dist/multi-agent/collision-utils.d.ts +16 -0
- package/dist/multi-agent/collision-utils.js +28 -0
- package/dist/multi-agent/context-resolver.d.ts +97 -0
- package/dist/multi-agent/context-resolver.js +316 -0
- package/dist/multi-agent/custom-agents.d.ts +83 -0
- package/dist/multi-agent/custom-agents.js +227 -0
- package/dist/multi-agent/delegation-tracker.d.ts +157 -0
- package/dist/multi-agent/delegation-tracker.js +243 -0
- package/dist/multi-agent/file-lock-hook.d.ts +29 -0
- package/dist/multi-agent/file-lock-hook.js +97 -0
- package/dist/multi-agent/file-locks.d.ts +58 -0
- package/dist/multi-agent/file-locks.js +194 -0
- package/dist/multi-agent/index.d.ts +24 -0
- package/dist/multi-agent/index.js +30 -0
- package/dist/multi-agent/mention-parser.d.ts +64 -0
- package/dist/multi-agent/mention-parser.js +146 -0
- package/dist/multi-agent/notification-manager.d.ts +84 -0
- package/dist/multi-agent/notification-manager.js +224 -0
- package/dist/multi-agent/pending-requests.d.ts +122 -0
- package/dist/multi-agent/pending-requests.js +155 -0
- package/dist/multi-agent/session-registry.d.ts +139 -0
- package/dist/multi-agent/session-registry.js +514 -0
- package/dist/multi-agent/shared-context.d.ts +293 -0
- package/dist/multi-agent/shared-context.js +671 -0
- package/dist/multi-agent/skill-requirements.d.ts +66 -0
- package/dist/multi-agent/skill-requirements.js +178 -0
- package/dist/multi-agent/task-assignment.d.ts +69 -0
- package/dist/multi-agent/task-assignment.js +123 -0
- package/dist/multi-agent/task-suggestion.d.ts +31 -0
- package/dist/multi-agent/task-suggestion.js +72 -0
- package/dist/multi-agent/team-agent.d.ts +201 -0
- package/dist/multi-agent/team-agent.js +488 -0
- package/dist/multi-agent/team.d.ts +286 -0
- package/dist/multi-agent/team.js +610 -0
- package/dist/multi-agent/tool-config.d.ts +110 -0
- package/dist/multi-agent/tool-config.js +661 -0
- package/dist/multi-agent/types.d.ts +211 -0
- package/dist/multi-agent/types.js +617 -0
- package/dist/prompts/plan-mode-prompt.d.ts +11 -0
- package/dist/prompts/plan-mode-prompt.js +95 -0
- package/dist/repl-helpers.js +5 -2
- package/dist/repl-v2.d.ts +401 -2
- package/dist/repl-v2.js +2588 -65
- package/dist/session/index.d.ts +6 -0
- package/dist/session/index.js +6 -0
- package/dist/session/project-session-manager.d.ts +158 -0
- package/dist/session/project-session-manager.js +650 -0
- package/dist/settings/index.d.ts +133 -13
- package/dist/settings/index.js +329 -24
- package/dist/settings/mcp-config.d.ts +76 -0
- package/dist/settings/mcp-config.js +143 -0
- package/dist/settings/paths.d.ts +4 -0
- package/dist/settings/paths.js +6 -0
- package/dist/shared-handlers.d.ts +62 -0
- package/dist/shared-handlers.js +48 -0
- package/dist/system-prompt/builder.d.ts +5 -0
- package/dist/system-prompt/builder.js +4 -0
- package/dist/system-prompt/index.d.ts +18 -0
- package/dist/system-prompt/index.js +18 -0
- package/dist/system-prompt/modules.d.ts +5 -0
- package/dist/system-prompt/modules.js +4 -0
- package/dist/tabbed-menu.js +2 -1
- package/dist/templates/compilr-md-import.d.ts +16 -0
- package/dist/templates/compilr-md-import.js +241 -0
- package/dist/templates/compilr-md.js +10 -61
- package/dist/templates/config-json.d.ts +1 -25
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.js +34 -73
- package/dist/tool-names.d.ts +113 -0
- package/dist/tool-names.js +239 -0
- package/dist/tools/ask-user-simple.d.ts +1 -1
- package/dist/tools/ask-user-simple.js +2 -1
- package/dist/tools/ask-user.d.ts +1 -1
- package/dist/tools/ask-user.js +2 -1
- package/dist/tools/backlog.d.ts +2 -2
- package/dist/tools/backlog.js +1 -1
- package/dist/tools/db-tools.d.ts +13 -61
- package/dist/tools/db-tools.js +12 -13
- package/dist/tools/delegate-background.d.ts +27 -0
- package/dist/tools/delegate-background.js +115 -0
- package/dist/tools/delegate.d.ts +22 -0
- package/dist/tools/delegate.js +97 -0
- package/dist/tools/delegation-status.d.ts +16 -0
- package/dist/tools/delegation-status.js +128 -0
- package/dist/tools/guide-tool.d.ts +12 -0
- package/dist/tools/guide-tool.js +59 -0
- package/dist/tools/handoff.d.ts +25 -0
- package/dist/tools/handoff.js +99 -0
- package/dist/tools/meta-tools.d.ts +26 -0
- package/dist/tools/meta-tools.js +47 -0
- package/dist/tools/platform-adapter.d.ts +35 -0
- package/dist/tools/platform-adapter.js +404 -0
- package/dist/tools/project-db.d.ts +5 -73
- package/dist/tools/project-db.js +5 -336
- package/dist/tools.d.ts +67 -2
- package/dist/tools.js +240 -48
- package/dist/ui/autocomplete-controller.d.ts +42 -0
- package/dist/ui/autocomplete-controller.js +384 -0
- package/dist/ui/base/index.d.ts +1 -1
- package/dist/ui/base/index.js +1 -1
- package/dist/ui/base/overlay-base-v2.d.ts +10 -0
- package/dist/ui/base/overlay-base-v2.js +14 -0
- package/dist/ui/base/render-utils.d.ts +19 -0
- package/dist/ui/base/render-utils.js +25 -0
- package/dist/ui/base/tabbed-list-overlay-v2.d.ts +16 -1
- package/dist/ui/base/tabbed-list-overlay-v2.js +19 -1
- package/dist/ui/constants/labels.d.ts +14 -0
- package/dist/ui/constants/labels.js +52 -0
- package/dist/ui/conversation-store.d.ts +55 -0
- package/dist/ui/conversation-store.js +107 -0
- package/dist/ui/conversation.js +11 -13
- package/dist/ui/diff.d.ts +7 -1
- package/dist/ui/diff.js +85 -48
- package/dist/ui/ephemeral.js +3 -9
- package/dist/ui/file-autocomplete.d.ts +24 -0
- package/dist/ui/file-autocomplete.js +56 -0
- package/dist/ui/footer-renderer.d.ts +69 -0
- package/dist/ui/footer-renderer.js +431 -0
- package/dist/ui/footer.d.ts +74 -7
- package/dist/ui/footer.js +173 -16
- package/dist/ui/input-controller.d.ts +51 -0
- package/dist/ui/input-controller.js +176 -0
- package/dist/ui/input-prompt.d.ts +19 -0
- package/dist/ui/input-prompt.js +206 -14
- package/dist/ui/keyboard-handler.d.ts +57 -0
- package/dist/ui/keyboard-handler.js +557 -0
- package/dist/ui/live-region-facade.d.ts +42 -0
- package/dist/ui/live-region-facade.js +205 -0
- package/dist/ui/live-region.d.ts +0 -4
- package/dist/ui/live-region.js +6 -14
- package/dist/ui/mascot/renderer.d.ts +1 -1
- package/dist/ui/mascot/renderer.js +37 -2
- package/dist/ui/overlay/data/tutorial-content.d.ts +9 -0
- package/dist/ui/overlay/data/tutorial-content.js +9 -0
- package/dist/ui/overlay/data/tutorial-registry.d.ts +12 -0
- package/dist/ui/overlay/data/tutorial-registry.js +116 -0
- package/dist/ui/overlay/data/tutorial-types.d.ts +35 -0
- package/dist/ui/overlay/data/tutorial-types.js +6 -0
- package/dist/ui/overlay/data/tutorials/basics/first-conversation.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/basics/first-conversation.js +220 -0
- package/dist/ui/overlay/data/tutorials/basics/first-project.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/basics/first-project.js +284 -0
- package/dist/ui/overlay/data/tutorials/basics/navigation.d.ts +8 -0
- package/dist/ui/overlay/data/tutorials/basics/navigation.js +22 -0
- package/dist/ui/overlay/data/tutorials/basics/welcome.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/basics/welcome.js +174 -0
- package/dist/ui/overlay/data/tutorials/config/context-management.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/config/context-management.js +158 -0
- package/dist/ui/overlay/data/tutorials/config/mcp-servers.d.ts +8 -0
- package/dist/ui/overlay/data/tutorials/config/mcp-servers.js +155 -0
- package/dist/ui/overlay/data/tutorials/config/model-selection.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/config/model-selection.js +162 -0
- package/dist/ui/overlay/data/tutorials/config/permissions-safety.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/config/permissions-safety.js +163 -0
- package/dist/ui/overlay/data/tutorials/config/settings-config.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/config/settings-config.js +166 -0
- package/dist/ui/overlay/data/tutorials/planning/arch.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/arch.js +168 -0
- package/dist/ui/overlay/data/tutorials/planning/backlog.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/backlog.js +103 -0
- package/dist/ui/overlay/data/tutorials/planning/build.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/build.js +173 -0
- package/dist/ui/overlay/data/tutorials/planning/design.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/design.js +205 -0
- package/dist/ui/overlay/data/tutorials/planning/docs.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/docs.js +143 -0
- package/dist/ui/overlay/data/tutorials/planning/prd.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/prd.js +173 -0
- package/dist/ui/overlay/data/tutorials/planning/scaffold.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/scaffold.js +164 -0
- package/dist/ui/overlay/data/tutorials/planning/sketch.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/planning/sketch.js +58 -0
- package/dist/ui/overlay/data/tutorials/projects/anchors.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/projects/anchors.js +248 -0
- package/dist/ui/overlay/data/tutorials/projects/import-project.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/projects/import-project.js +172 -0
- package/dist/ui/overlay/data/tutorials/projects/managing-projects.d.ts +8 -0
- package/dist/ui/overlay/data/tutorials/projects/managing-projects.js +212 -0
- package/dist/ui/overlay/data/tutorials/projects/new-project.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/projects/new-project.js +251 -0
- package/dist/ui/overlay/data/tutorials/projects/session-management.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/projects/session-management.js +169 -0
- package/dist/ui/overlay/data/tutorials/teams/background-execution.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/teams/background-execution.js +171 -0
- package/dist/ui/overlay/data/tutorials/teams/multi-terminal.d.ts +8 -0
- package/dist/ui/overlay/data/tutorials/teams/multi-terminal.js +147 -0
- package/dist/ui/overlay/data/tutorials/teams/task-assignment.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/teams/task-assignment.js +204 -0
- package/dist/ui/overlay/data/tutorials/teams/team-overview.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/teams/team-overview.js +165 -0
- package/dist/ui/overlay/data/tutorials/teams/working-with-agents.d.ts +7 -0
- package/dist/ui/overlay/data/tutorials/teams/working-with-agents.js +172 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.js +6 -17
- package/dist/ui/overlay/impl/anchors-overlay-v2.js +30 -64
- package/dist/ui/overlay/impl/artifact-detail-overlay-v2.d.ts +43 -0
- package/dist/ui/overlay/impl/artifact-detail-overlay-v2.js +232 -0
- package/dist/ui/overlay/impl/artifact-overlay-v2.d.ts +40 -0
- package/dist/ui/overlay/impl/artifact-overlay-v2.js +115 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.js +2 -5
- package/dist/ui/overlay/impl/background-overlay-v2.d.ts +40 -0
- package/dist/ui/overlay/impl/background-overlay-v2.js +147 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.d.ts +4 -1
- package/dist/ui/overlay/impl/backlog-overlay-v2.js +55 -16
- package/dist/ui/overlay/impl/changelog-overlay-v2.d.ts +44 -0
- package/dist/ui/overlay/impl/changelog-overlay-v2.js +165 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.js +4 -6
- package/dist/ui/overlay/impl/config-overlay-v2.d.ts +12 -1
- package/dist/ui/overlay/impl/config-overlay-v2.js +164 -100
- package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.d.ts +83 -0
- package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.js +711 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.d.ts +2 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.js +26 -3
- package/dist/ui/overlay/impl/delegations-overlay-v2.d.ts +28 -0
- package/dist/ui/overlay/impl/delegations-overlay-v2.js +279 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.js +12 -9
- package/dist/ui/overlay/impl/document-detail-overlay-v2.d.ts +7 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.js +119 -78
- package/dist/ui/overlay/impl/filter-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/filter-overlay-v2.js +110 -0
- package/dist/ui/overlay/impl/games-overlay-v2.d.ts +31 -0
- package/dist/ui/overlay/impl/games-overlay-v2.js +135 -0
- package/dist/ui/overlay/impl/help-overlay-v2.d.ts +26 -3
- package/dist/ui/overlay/impl/help-overlay-v2.js +20 -42
- package/dist/ui/overlay/impl/login-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/login-overlay-v2.js +277 -0
- package/dist/ui/overlay/impl/mcp-overlay-v2.d.ts +63 -0
- package/dist/ui/overlay/impl/mcp-overlay-v2.js +907 -0
- package/dist/ui/overlay/impl/model-overlay-v2.d.ts +57 -13
- package/dist/ui/overlay/impl/model-overlay-v2.js +1086 -61
- package/dist/ui/overlay/impl/new-overlay-v2.d.ts +37 -6
- package/dist/ui/overlay/impl/new-overlay-v2.js +715 -65
- package/dist/ui/overlay/impl/notifications-overlay-v2.d.ts +20 -0
- package/dist/ui/overlay/impl/notifications-overlay-v2.js +116 -0
- package/dist/ui/overlay/impl/onboarding-wizard-overlay-v2.d.ts +76 -0
- package/dist/ui/overlay/impl/onboarding-wizard-overlay-v2.js +728 -0
- package/dist/ui/overlay/impl/pending-overlay-v2.d.ts +51 -0
- package/dist/ui/overlay/impl/pending-overlay-v2.js +445 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.js +5 -5
- package/dist/ui/overlay/impl/permissions-overlay-v2.d.ts +85 -0
- package/dist/ui/overlay/impl/permissions-overlay-v2.js +820 -0
- package/dist/ui/overlay/impl/plan-approval-overlay-v2.d.ts +35 -0
- package/dist/ui/overlay/impl/plan-approval-overlay-v2.js +181 -0
- package/dist/ui/overlay/impl/project-edit-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/project-edit-overlay-v2.js +195 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.d.ts +1 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.js +278 -44
- package/dist/ui/overlay/impl/reset-overlay-v2.d.ts +39 -0
- package/dist/ui/overlay/impl/reset-overlay-v2.js +107 -0
- package/dist/ui/overlay/impl/resume-overlay-v2.d.ts +60 -0
- package/dist/ui/overlay/impl/resume-overlay-v2.js +414 -0
- package/dist/ui/overlay/impl/session-mode-overlay-v2.d.ts +43 -0
- package/dist/ui/overlay/impl/session-mode-overlay-v2.js +124 -0
- package/dist/ui/overlay/impl/tasks-overlay-v2.d.ts +28 -0
- package/dist/ui/overlay/impl/tasks-overlay-v2.js +283 -0
- package/dist/ui/overlay/impl/team-overlay-v2.d.ts +86 -0
- package/dist/ui/overlay/impl/team-overlay-v2.js +692 -0
- package/dist/ui/overlay/impl/terminals-overlay-v2.d.ts +26 -0
- package/dist/ui/overlay/impl/terminals-overlay-v2.js +217 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.js +3 -7
- package/dist/ui/overlay/impl/tutorial-overlay-v2.d.ts +30 -16
- package/dist/ui/overlay/impl/tutorial-overlay-v2.js +133 -956
- package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +1 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.js +10 -4
- package/dist/ui/overlay/index.d.ts +20 -1
- package/dist/ui/overlay/index.js +19 -0
- package/dist/ui/overlay/types.d.ts +5 -0
- package/dist/ui/overlay-manager.d.ts +43 -0
- package/dist/ui/overlay-manager.js +238 -0
- package/dist/ui/overlays.js +4 -16
- package/dist/ui/permission-overlay.js +6 -5
- package/dist/ui/status-bar-controller.d.ts +33 -0
- package/dist/ui/status-bar-controller.js +99 -0
- package/dist/ui/subagent-renderer.js +3 -19
- package/dist/ui/terminal-autocomplete-utils.d.ts +23 -0
- package/dist/ui/terminal-autocomplete-utils.js +83 -0
- package/dist/ui/terminal-line-builders.d.ts +17 -0
- package/dist/ui/terminal-line-builders.js +42 -0
- package/dist/ui/terminal-render-item.d.ts +16 -0
- package/dist/ui/terminal-render-item.js +267 -0
- package/dist/ui/terminal-renderer.d.ts +7 -8
- package/dist/ui/terminal-renderer.js +7 -8
- package/dist/ui/terminal-types.d.ts +179 -0
- package/dist/ui/terminal-types.js +34 -0
- package/dist/ui/terminal-ui.d.ts +144 -276
- package/dist/ui/terminal-ui.js +384 -1861
- package/dist/ui/todo-zone.d.ts +19 -1
- package/dist/ui/todo-zone.js +71 -13
- package/dist/ui/tool-formatters.js +696 -1
- package/dist/ui/turn-metrics.d.ts +56 -0
- package/dist/ui/turn-metrics.js +75 -0
- package/dist/ui/types.d.ts +28 -0
- package/dist/ui/types.js +1 -0
- package/dist/ui/vscode-diff-ipc.d.ts +102 -0
- package/dist/ui/vscode-diff-ipc.js +385 -0
- package/dist/utils/credentials.d.ts +24 -5
- package/dist/utils/credentials.js +123 -9
- package/dist/utils/format-tokens.d.ts +13 -0
- package/dist/utils/format-tokens.js +18 -0
- package/dist/utils/git-config.d.ts +26 -0
- package/dist/utils/git-config.js +54 -0
- package/dist/utils/message-utils.d.ts +61 -0
- package/dist/utils/message-utils.js +72 -0
- package/dist/utils/model-tiers.d.ts +8 -1
- package/dist/utils/model-tiers.js +38 -16
- package/dist/utils/open-browser.d.ts +5 -0
- package/dist/utils/open-browser.js +32 -0
- package/dist/utils/path-safety.js +3 -2
- package/dist/utils/project-detection.d.ts +58 -0
- package/dist/utils/project-detection.js +424 -0
- package/dist/utils/project-memory.js +2 -1
- package/dist/utils/project-status.d.ts +2 -2
- package/dist/utils/startup-perf.d.ts +18 -0
- package/dist/utils/startup-perf.js +60 -0
- package/dist/utils/token-tracker.d.ts +62 -0
- package/dist/utils/token-tracker.js +150 -0
- package/dist/utils/token-types.d.ts +23 -0
- package/dist/utils/token-types.js +18 -0
- package/dist/utils/types/config-types.d.ts +32 -0
- package/dist/utils/types/config-types.js +8 -0
- package/dist/utils/update-checker.d.ts +28 -0
- package/dist/utils/update-checker.js +106 -0
- package/dist/utils/version.d.ts +7 -0
- package/dist/utils/version.js +10 -0
- package/dist/utils/vscode-detect.d.ts +39 -0
- package/dist/utils/vscode-detect.js +137 -0
- package/package.json +27 -13
- package/dist/commands/handler-types.d.ts +0 -68
- package/dist/commands/handler-types.js +0 -8
- package/dist/commands/handlers/agent-commands.d.ts +0 -13
- package/dist/commands/handlers/agent-commands.js +0 -305
- package/dist/commands/handlers/design-commands.d.ts +0 -15
- package/dist/commands/handlers/design-commands.js +0 -334
- package/dist/commands/handlers/index.d.ts +0 -20
- package/dist/commands/handlers/index.js +0 -43
- package/dist/commands/handlers/overlay-commands.d.ts +0 -21
- package/dist/commands/handlers/overlay-commands.js +0 -287
- package/dist/commands/handlers/project-commands.d.ts +0 -11
- package/dist/commands/handlers/project-commands.js +0 -167
- package/dist/commands/handlers/simple-commands.d.ts +0 -19
- package/dist/commands/handlers/simple-commands.js +0 -144
- package/dist/commands/registry.d.ts +0 -50
- package/dist/commands/registry.js +0 -75
- package/dist/index.old.d.ts +0 -7
- package/dist/index.old.js +0 -1014
- package/dist/repl.d.ts +0 -149
- package/dist/repl.js +0 -1151
- package/dist/templates/claude-md.d.ts +0 -7
- package/dist/templates/claude-md.js +0 -189
- package/dist/test-autocomplete.d.ts +0 -7
- package/dist/test-autocomplete.js +0 -85
- package/dist/test-tabbed-menu.d.ts +0 -7
- package/dist/test-tabbed-menu.js +0 -25
- package/dist/tool-selector.d.ts +0 -71
- package/dist/tool-selector.js +0 -184
- package/dist/tools/anchor-tools.d.ts +0 -31
- package/dist/tools/anchor-tools.js +0 -255
- package/dist/tools/backlog-wrappers.d.ts +0 -54
- package/dist/tools/backlog-wrappers.js +0 -338
- package/dist/tools/document-db.d.ts +0 -43
- package/dist/tools/document-db.js +0 -220
- package/dist/tools/workitem-db.d.ts +0 -103
- package/dist/tools/workitem-db.js +0 -549
- package/dist/ui/agents-overlay-v2.d.ts +0 -43
- package/dist/ui/agents-overlay-v2.js +0 -809
- package/dist/ui/agents-overlay.d.ts +0 -12
- package/dist/ui/agents-overlay.js +0 -863
- package/dist/ui/anchors-overlay.d.ts +0 -12
- package/dist/ui/anchors-overlay.js +0 -775
- package/dist/ui/arch-type-overlay.d.ts +0 -15
- package/dist/ui/arch-type-overlay.js +0 -201
- package/dist/ui/ask-user-overlay-v2.d.ts +0 -26
- package/dist/ui/ask-user-overlay-v2.js +0 -555
- package/dist/ui/ask-user-simple-overlay-v2.d.ts +0 -25
- package/dist/ui/ask-user-simple-overlay-v2.js +0 -215
- package/dist/ui/backlog-overlay.d.ts +0 -32
- package/dist/ui/backlog-overlay.js +0 -652
- package/dist/ui/commands-overlay-v2.d.ts +0 -33
- package/dist/ui/commands-overlay-v2.js +0 -441
- package/dist/ui/commands-overlay.d.ts +0 -16
- package/dist/ui/commands-overlay.js +0 -439
- package/dist/ui/config-overlay.d.ts +0 -35
- package/dist/ui/config-overlay.js +0 -707
- package/dist/ui/docs-overlay.d.ts +0 -17
- package/dist/ui/docs-overlay.js +0 -303
- package/dist/ui/footer-v2.d.ts +0 -222
- package/dist/ui/footer-v2.js +0 -1349
- package/dist/ui/help-overlay-v2.d.ts +0 -34
- package/dist/ui/help-overlay-v2.js +0 -309
- package/dist/ui/help-overlay.d.ts +0 -16
- package/dist/ui/help-overlay.js +0 -316
- package/dist/ui/init-overlay-v2.d.ts +0 -34
- package/dist/ui/init-overlay-v2.js +0 -600
- package/dist/ui/init-overlay.d.ts +0 -34
- package/dist/ui/init-overlay.js +0 -604
- package/dist/ui/input-prompt-v2.d.ts +0 -180
- package/dist/ui/input-prompt-v2.js +0 -999
- package/dist/ui/iteration-limit-overlay-v2.d.ts +0 -21
- package/dist/ui/iteration-limit-overlay-v2.js +0 -114
- package/dist/ui/keys-overlay-v2.d.ts +0 -41
- package/dist/ui/keys-overlay-v2.js +0 -248
- package/dist/ui/mascot-overlay-v2.d.ts +0 -41
- package/dist/ui/mascot-overlay-v2.js +0 -138
- package/dist/ui/mascot-overlay.d.ts +0 -21
- package/dist/ui/mascot-overlay.js +0 -146
- package/dist/ui/model-overlay-v2.d.ts +0 -49
- package/dist/ui/model-overlay-v2.js +0 -118
- package/dist/ui/model-overlay.d.ts +0 -27
- package/dist/ui/model-overlay.js +0 -221
- package/dist/ui/model-warning-overlay.d.ts +0 -30
- package/dist/ui/model-warning-overlay.js +0 -169
- package/dist/ui/new-overlay.d.ts +0 -34
- package/dist/ui/new-overlay.js +0 -604
- package/dist/ui/overlay/impl/init-overlay-v2.d.ts +0 -77
- package/dist/ui/overlay/impl/init-overlay-v2.js +0 -593
- package/dist/ui/overlay/overlay-types.d.ts +0 -128
- package/dist/ui/overlay/overlay-types.js +0 -22
- package/dist/ui/overlays/help-overlay-v2.d.ts +0 -28
- package/dist/ui/overlays/help-overlay-v2.js +0 -198
- package/dist/ui/overlays/index.d.ts +0 -11
- package/dist/ui/overlays/index.js +0 -11
- package/dist/ui/permission-overlay-v2.d.ts +0 -36
- package/dist/ui/permission-overlay-v2.js +0 -380
- package/dist/ui/projects-overlay.d.ts +0 -19
- package/dist/ui/projects-overlay.js +0 -484
- package/dist/ui/theme-overlay-v2.d.ts +0 -42
- package/dist/ui/theme-overlay-v2.js +0 -135
- package/dist/ui/theme-overlay.d.ts +0 -24
- package/dist/ui/theme-overlay.js +0 -127
- package/dist/ui/tools-overlay-v2.d.ts +0 -47
- package/dist/ui/tools-overlay-v2.js +0 -218
- package/dist/ui/tools-overlay.d.ts +0 -34
- package/dist/ui/tools-overlay.js +0 -230
- package/dist/ui/tutorial-overlay-v2.d.ts +0 -31
- package/dist/ui/tutorial-overlay-v2.js +0 -1035
- package/dist/ui/tutorial-overlay.d.ts +0 -11
- package/dist/ui/tutorial-overlay.js +0 -1034
- package/dist/ui/workflow-overlay.d.ts +0 -22
- package/dist/ui/workflow-overlay.js +0 -636
package/dist/index.js
CHANGED
|
@@ -8,32 +8,48 @@ process.env.FORCE_COLOR = '3';
|
|
|
8
8
|
* AI-powered coding assistant CLI using @compilr-dev/agents.
|
|
9
9
|
* A terminal-based REPL for interacting with AI agents.
|
|
10
10
|
*/
|
|
11
|
+
import { perf, flushStartupPerf } from './utils/startup-perf.js';
|
|
12
|
+
perf('imports-start');
|
|
11
13
|
import { createAgent } from './agent.js';
|
|
14
|
+
import { getModelForTier } from './models/index.js';
|
|
12
15
|
import { ReplV2 } from './repl-v2.js';
|
|
13
|
-
import
|
|
14
|
-
import * as diff from './ui/diff.js';
|
|
15
|
-
import * as terminal from './ui/terminal.js';
|
|
16
|
+
import { AgentTeam, setActiveSharedContext } from './multi-agent/index.js';
|
|
16
17
|
import { getStyles } from './themes/index.js';
|
|
17
|
-
import { getDefaultProvider, getDefaultModel as getDefaultModelSetting, getProjectStartupMode, getLastProjectId } from './settings/index.js';
|
|
18
|
-
import {
|
|
18
|
+
import { getDefaultProvider, getDefaultModel as getDefaultModelSetting, getProjectStartupMode, getLastProjectId, isCheckUpdatesEnabled, getLastUpdateCheck, recordUpdateCheck, isFirstRunComplete, setSetting, getSetting } from './settings/index.js';
|
|
19
|
+
import { checkForUpdates, performUpdate } from './utils/update-checker.js';
|
|
19
20
|
import { showAskUserSimpleOverlay } from './ui/ask-user-simple-overlay.js';
|
|
20
|
-
import { showPermissionOverlay } from './ui/permission-overlay.js';
|
|
21
|
-
import { showIterationLimitOverlay } from './ui/iteration-limit-overlay.js';
|
|
22
|
-
import { showGuardrailOverlay } from './ui/guardrail-overlay.js';
|
|
23
21
|
import { showKeysOverlay } from './ui/keys-overlay.js';
|
|
24
22
|
import { projectRepository, workItemRepository } from './db/repositories/index.js';
|
|
25
23
|
import { setActiveProject } from './tools/project-db.js';
|
|
26
24
|
import { getFullGuidedPrompt, shouldInjectGuidedContext, } from './workflow/index.js';
|
|
27
25
|
import { hasApiKey, settingsProviderToCredentialKey } from './utils/credentials.js';
|
|
28
|
-
import { loadProjectMemory
|
|
26
|
+
import { loadProjectMemory } from './utils/project-memory.js';
|
|
29
27
|
import { getGlobalAnchorManager, getAnchorManager } from './anchors/index.js';
|
|
30
|
-
import {
|
|
31
|
-
import
|
|
32
|
-
|
|
28
|
+
import { getAuthManager } from './auth/index.js';
|
|
29
|
+
import { loadMCPConfig } from './settings/mcp-config.js';
|
|
30
|
+
import { isInVSCode } from './utils/vscode-detect.js';
|
|
31
|
+
import { cleanupStaleDiffs } from './ui/vscode-diff-ipc.js';
|
|
32
|
+
import { createPermissionHandler } from './handlers/permission-handler.js';
|
|
33
|
+
import { registerDelegationHandlers } from './handlers/delegation-handlers.js';
|
|
34
|
+
import { registerAskUserHandlers } from './handlers/ask-user-handlers.js';
|
|
35
|
+
import { EpisodeRecorder, FileEpisodeStore, setGlobalEpisodeStore } from './episodes/index.js';
|
|
36
|
+
import { updateWorkSummaryAnchor } from './episodes/work-summary-anchor.js';
|
|
37
|
+
import { getSessionsPath } from './settings/paths.js';
|
|
38
|
+
import * as path from 'path';
|
|
39
|
+
perf('imports-done');
|
|
40
|
+
const sharedState = {
|
|
41
|
+
mode: 'normal',
|
|
42
|
+
pendingSuggestion: null,
|
|
43
|
+
pendingDelegation: null,
|
|
44
|
+
vsDiffEnabled: false,
|
|
45
|
+
sessionPrefix: '',
|
|
46
|
+
vsDiffExtensionChecked: false,
|
|
47
|
+
};
|
|
33
48
|
// =============================================================================
|
|
34
49
|
// Version
|
|
35
50
|
// =============================================================================
|
|
36
|
-
|
|
51
|
+
import { VERSION } from './utils/version.js';
|
|
52
|
+
export { VERSION };
|
|
37
53
|
function parseArgs() {
|
|
38
54
|
const args = process.argv.slice(2);
|
|
39
55
|
const options = {};
|
|
@@ -51,6 +67,9 @@ function parseArgs() {
|
|
|
51
67
|
else if (arg === '--show-filtering') {
|
|
52
68
|
options.showFiltering = true;
|
|
53
69
|
}
|
|
70
|
+
else if (arg === '--update') {
|
|
71
|
+
options.update = true;
|
|
72
|
+
}
|
|
54
73
|
else if (arg === '--help' || arg === '-h') {
|
|
55
74
|
showHelp();
|
|
56
75
|
process.exit(0);
|
|
@@ -69,6 +88,7 @@ Options:
|
|
|
69
88
|
--model, -m <model> Model name (e.g., claude-3-5-haiku-20241022)
|
|
70
89
|
--minimal Use minimal tool set
|
|
71
90
|
--show-filtering Show tool filtering analysis
|
|
91
|
+
--update Check for and install updates
|
|
72
92
|
--help, -h Show this help
|
|
73
93
|
|
|
74
94
|
Environment Variables:
|
|
@@ -81,67 +101,236 @@ Examples:
|
|
|
81
101
|
npm run dev -- --model claude-3-5-haiku-20241022
|
|
82
102
|
npm run dev -- --provider gemini --model gemini-2.0-flash
|
|
83
103
|
npm run dev -- --minimal --show-filtering
|
|
104
|
+
npm run dev -- --update
|
|
84
105
|
`);
|
|
85
106
|
}
|
|
86
107
|
// =============================================================================
|
|
108
|
+
// MCP Initialization
|
|
109
|
+
// =============================================================================
|
|
110
|
+
/** MCPManager instance — stored at module level for /mcp command and cleanup */
|
|
111
|
+
let mcpManagerInstance = null;
|
|
112
|
+
async function createMCPManager(servers) {
|
|
113
|
+
// Dynamic import to avoid loading MCP code when not needed
|
|
114
|
+
perf('mcp-dynamic-import');
|
|
115
|
+
const { MCPManager } = await import('@compilr-dev/sdk');
|
|
116
|
+
perf('mcp-dynamic-import-done');
|
|
117
|
+
const manager = new MCPManager({ toolPrefix: 'mcp', autoConnect: true });
|
|
118
|
+
// Connect all servers in parallel — each addServer is independent
|
|
119
|
+
perf(`mcp-connect-${String(servers.length)}-servers`);
|
|
120
|
+
await Promise.allSettled(servers.map(server => manager.addServer(server)));
|
|
121
|
+
perf('mcp-connect-done');
|
|
122
|
+
return manager;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Initialize MCP servers and discover tools.
|
|
126
|
+
* Returns empty array if no servers configured or on error.
|
|
127
|
+
* Non-blocking: failures are silently ignored.
|
|
128
|
+
*/
|
|
129
|
+
async function initializeMCP(projectPath) {
|
|
130
|
+
const servers = loadMCPConfig(projectPath);
|
|
131
|
+
if (servers.length === 0) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const manager = await createMCPManager(servers);
|
|
136
|
+
mcpManagerInstance = manager;
|
|
137
|
+
perf('mcp-discover-tools');
|
|
138
|
+
const tools = await manager.discoverTools();
|
|
139
|
+
perf('mcp-discover-tools-done');
|
|
140
|
+
return tools;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
// MCP initialization failed — continue without MCP tools
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** Get the MCPManager instance (for /mcp command) */
|
|
148
|
+
export function getMCPManager() {
|
|
149
|
+
return mcpManagerInstance;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Get or lazily create an MCPManager instance.
|
|
153
|
+
* When no servers were configured at startup, mcpManagerInstance is null.
|
|
154
|
+
* This creates one on demand so the /mcp overlay can add servers at runtime.
|
|
155
|
+
*/
|
|
156
|
+
export async function ensureMCPManager() {
|
|
157
|
+
if (mcpManagerInstance)
|
|
158
|
+
return mcpManagerInstance;
|
|
159
|
+
const { MCPManager: MCPManagerClass } = await import('@compilr-dev/sdk');
|
|
160
|
+
mcpManagerInstance = new MCPManagerClass({ toolPrefix: 'mcp', autoConnect: true });
|
|
161
|
+
return mcpManagerInstance;
|
|
162
|
+
}
|
|
163
|
+
// =============================================================================
|
|
87
164
|
// Main Entry Point
|
|
88
165
|
// =============================================================================
|
|
89
166
|
async function main() {
|
|
167
|
+
perf('main-start');
|
|
90
168
|
const options = parseArgs();
|
|
169
|
+
const s = getStyles();
|
|
170
|
+
// ==========================================================================
|
|
171
|
+
// Handle --update flag: perform update and exit
|
|
172
|
+
// ==========================================================================
|
|
173
|
+
if (options.update) {
|
|
174
|
+
console.log('Checking for updates...');
|
|
175
|
+
const updateInfo = await checkForUpdates();
|
|
176
|
+
if (updateInfo.updateAvailable) {
|
|
177
|
+
console.log(s.primary(`Update available: v${updateInfo.currentVersion} → v${updateInfo.latestVersion}`));
|
|
178
|
+
console.log('Installing update...\n');
|
|
179
|
+
const result = await performUpdate();
|
|
180
|
+
console.log(result.success ? s.success(result.message) : s.error(result.message));
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
console.log(s.success(`You're on the latest version (v${updateInfo.currentVersion})`));
|
|
184
|
+
}
|
|
185
|
+
process.exit(0);
|
|
186
|
+
}
|
|
187
|
+
// ==========================================================================
|
|
188
|
+
// Update check (deferred to background — don't block startup)
|
|
189
|
+
// ==========================================================================
|
|
190
|
+
let updateAvailable = null;
|
|
191
|
+
// Fire update check in background (result used later if available before REPL starts)
|
|
192
|
+
let updateCheckPromise = null;
|
|
193
|
+
if (isCheckUpdatesEnabled()) {
|
|
194
|
+
const lastCheck = getLastUpdateCheck();
|
|
195
|
+
const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000;
|
|
196
|
+
if (!lastCheck || lastCheck < oneDayAgo) {
|
|
197
|
+
updateCheckPromise = checkForUpdates()
|
|
198
|
+
.then((updateInfo) => {
|
|
199
|
+
recordUpdateCheck();
|
|
200
|
+
if (updateInfo.updateAvailable) {
|
|
201
|
+
updateAvailable = {
|
|
202
|
+
current: updateInfo.currentVersion,
|
|
203
|
+
latest: updateInfo.latestVersion,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
.catch(() => {
|
|
208
|
+
// Silently ignore update check failures
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// ==========================================================================
|
|
213
|
+
// VS Code diff IPC: clean up stale files from previous sessions
|
|
214
|
+
// ==========================================================================
|
|
215
|
+
perf('stale-diff-cleanup');
|
|
216
|
+
cleanupStaleDiffs(300_000); // 5 minutes
|
|
217
|
+
// ==========================================================================
|
|
218
|
+
// Authentication check (mandatory — but fast with API tokens)
|
|
219
|
+
// ==========================================================================
|
|
220
|
+
perf('auth-start');
|
|
221
|
+
const auth = getAuthManager();
|
|
222
|
+
const isAuthenticated = await auth.isAuthenticated();
|
|
223
|
+
perf('auth-done');
|
|
224
|
+
const showLogin = !isAuthenticated;
|
|
225
|
+
// Auth status is used by REPL to skip login overlay
|
|
226
|
+
// (email displayed in welcome banner, not here)
|
|
91
227
|
// Resolve provider: CLI arg > settings > auto-detect
|
|
92
228
|
const settingsProvider = getDefaultProvider();
|
|
93
|
-
|
|
229
|
+
let provider = options.provider
|
|
94
230
|
?? (settingsProvider !== 'auto' ? settingsProvider : null)
|
|
95
231
|
?? detectProvider();
|
|
96
232
|
// Resolve model: CLI arg > settings > provider default
|
|
97
233
|
const settingsModel = getDefaultModelSetting();
|
|
98
|
-
|
|
234
|
+
let model = options.model ?? settingsModel ?? getDefaultModel(provider);
|
|
99
235
|
// Check if API key is available for selected provider (skip for ollama)
|
|
100
236
|
if (provider !== 'ollama') {
|
|
101
237
|
const credentialKey = settingsProviderToCredentialKey(provider === 'claude' ? 'claude' : provider);
|
|
102
238
|
if (!hasApiKey(credentialKey)) {
|
|
103
|
-
const s = getStyles();
|
|
104
239
|
console.log(s.warning('⚠ No API key found for ' + provider));
|
|
105
240
|
console.log(s.muted(' Use --provider ollama for local models without an API key.'));
|
|
106
241
|
console.log('');
|
|
107
|
-
//
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
242
|
+
// Ask user what they want to do
|
|
243
|
+
const choice = await showAskUserSimpleOverlay({
|
|
244
|
+
question: 'What would you like to do?',
|
|
245
|
+
options: [
|
|
246
|
+
`Set API key for ${provider}`,
|
|
247
|
+
'Switch to a different provider',
|
|
248
|
+
],
|
|
249
|
+
});
|
|
250
|
+
if (choice.skipped) {
|
|
112
251
|
console.log(s.error('No API key configured. Cannot start.'));
|
|
113
|
-
console.log(s.muted(' Set a key with /keys or use: export ANTHROPIC_API_KEY=sk-ant-...'));
|
|
114
|
-
console.log('');
|
|
115
252
|
process.exit(1);
|
|
116
253
|
}
|
|
117
|
-
|
|
118
|
-
|
|
254
|
+
if (choice.answer.includes('Switch')) {
|
|
255
|
+
// Let user pick a different provider
|
|
256
|
+
const providerChoice = await showAskUserSimpleOverlay({
|
|
257
|
+
question: 'Select a provider:',
|
|
258
|
+
options: [
|
|
259
|
+
'Claude (Anthropic)',
|
|
260
|
+
'OpenAI (GPT)',
|
|
261
|
+
'Gemini (Google)',
|
|
262
|
+
'Ollama (local, no key needed)',
|
|
263
|
+
],
|
|
264
|
+
});
|
|
265
|
+
if (providerChoice.skipped) {
|
|
266
|
+
console.log(s.error('No provider selected. Cannot start.'));
|
|
267
|
+
process.exit(1);
|
|
268
|
+
}
|
|
269
|
+
// Map choice to provider
|
|
270
|
+
let newProvider;
|
|
271
|
+
if (providerChoice.answer.includes('Claude')) {
|
|
272
|
+
newProvider = 'claude';
|
|
273
|
+
}
|
|
274
|
+
else if (providerChoice.answer.includes('OpenAI')) {
|
|
275
|
+
newProvider = 'openai';
|
|
276
|
+
}
|
|
277
|
+
else if (providerChoice.answer.includes('Gemini')) {
|
|
278
|
+
newProvider = 'gemini';
|
|
279
|
+
}
|
|
280
|
+
else if (providerChoice.answer.includes('Ollama')) {
|
|
281
|
+
newProvider = 'ollama';
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
newProvider = 'claude'; // Default fallback
|
|
285
|
+
}
|
|
286
|
+
// Update settings (provider AND model) and restart check
|
|
287
|
+
const newModel = getDefaultModel(newProvider);
|
|
288
|
+
setSetting('defaultProvider', newProvider);
|
|
289
|
+
setSetting('defaultModel', newModel);
|
|
290
|
+
provider = newProvider;
|
|
291
|
+
model = newModel;
|
|
292
|
+
console.log(s.success(`✓ Switched to ${newProvider} (${newModel})`));
|
|
293
|
+
console.log('');
|
|
294
|
+
// Re-check API key for new provider
|
|
295
|
+
if (newProvider !== 'ollama') {
|
|
296
|
+
const newCredKey = settingsProviderToCredentialKey(newProvider);
|
|
297
|
+
if (!hasApiKey(newCredKey)) {
|
|
298
|
+
console.log(s.warning(`⚠ No API key found for ${newProvider}`));
|
|
299
|
+
const result = await showKeysOverlay();
|
|
300
|
+
if (!result.changed || !hasApiKey(newCredKey)) {
|
|
301
|
+
console.log(s.error('No API key configured. Cannot start.'));
|
|
302
|
+
process.exit(1);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
// Show keys overlay to set API key
|
|
309
|
+
const result = await showKeysOverlay();
|
|
310
|
+
// Check again after overlay closes
|
|
311
|
+
if (!result.changed || !hasApiKey(credentialKey)) {
|
|
312
|
+
console.log('');
|
|
313
|
+
console.log(s.error('No API key configured. Cannot start.'));
|
|
314
|
+
console.log(s.muted(' Set a key with /keys or use: export ANTHROPIC_API_KEY=sk-ant-...'));
|
|
315
|
+
console.log('');
|
|
316
|
+
process.exit(1);
|
|
317
|
+
}
|
|
318
|
+
console.log(s.success('✓ API key configured'));
|
|
319
|
+
console.log('');
|
|
320
|
+
}
|
|
119
321
|
}
|
|
120
322
|
}
|
|
121
323
|
// Load project memory (COMPILR.md or CLAUDE.md)
|
|
324
|
+
perf('project-memory-start');
|
|
122
325
|
const projectMemory = loadProjectMemory();
|
|
123
326
|
let projectContext;
|
|
124
327
|
if (projectMemory.found && projectMemory.filePath) {
|
|
125
|
-
const s = getStyles();
|
|
126
|
-
const filename = projectMemory.filePath.split('/').pop() ?? 'COMPILR.md';
|
|
127
|
-
const sizeCategory = getSizeCategory(projectMemory.originalSize);
|
|
128
|
-
if (projectMemory.truncated) {
|
|
129
|
-
// Large file - was truncated
|
|
130
|
-
console.log(s.warning(`⚠ Loaded ${filename} (${formatBytes(projectMemory.originalSize)} → truncated to 100KB)`));
|
|
131
|
-
}
|
|
132
|
-
else if (sizeCategory === 'medium') {
|
|
133
|
-
// Medium file - loaded with note
|
|
134
|
-
console.log(s.muted(` Loaded ${filename} (${formatBytes(projectMemory.originalSize)}, ~${projectMemory.estimatedTokens.toLocaleString()} tokens)`));
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
// Small file - loaded silently (just a subtle note)
|
|
138
|
-
console.log(s.muted(` Loaded ${filename}`));
|
|
139
|
-
}
|
|
140
328
|
projectContext = projectMemory.content;
|
|
141
329
|
}
|
|
142
330
|
// ==========================================================================
|
|
143
331
|
// Load guided mode context from database (if project uses guided mode)
|
|
144
332
|
// ==========================================================================
|
|
333
|
+
perf('project-db-start');
|
|
145
334
|
let guidedModeContext;
|
|
146
335
|
// Determine which project to load based on projectStartup setting
|
|
147
336
|
const projectStartupMode = getProjectStartupMode();
|
|
@@ -193,6 +382,7 @@ async function main() {
|
|
|
193
382
|
// ==========================================================================
|
|
194
383
|
// Load persisted anchors (critical info that survives compaction)
|
|
195
384
|
// ==========================================================================
|
|
385
|
+
perf('anchors-start');
|
|
196
386
|
// Load global anchors (always)
|
|
197
387
|
const globalAnchors = getGlobalAnchorManager().getAll({ scope: 'persistent' });
|
|
198
388
|
// Load project-specific anchors (if in a tracked project)
|
|
@@ -220,223 +410,32 @@ async function main() {
|
|
|
220
410
|
// ==========================================================================
|
|
221
411
|
// Create handlers and agent BEFORE menu (so menu can access agent info)
|
|
222
412
|
// ==========================================================================
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
if (sharedState.showPermissionOverlayV2) {
|
|
231
|
-
// Flush any accumulated text BEFORE showing the permission overlay
|
|
232
|
-
// This ensures agent's "I'll help you..." text appears before the permission prompt
|
|
233
|
-
sharedState.flushTextBuffer?.();
|
|
234
|
-
// For edit operations, pre-render diff lines for the overlay
|
|
235
|
-
let diffLines;
|
|
236
|
-
if (request.toolName === 'edit') {
|
|
237
|
-
// DEBUG: Write to file to see field names (temporary)
|
|
238
|
-
fs.appendFileSync('/tmp/compilr-debug.log', `[${new Date().toISOString()}] edit request.input: ${JSON.stringify(request.input)}\n`);
|
|
239
|
-
const filePath = ((typeof request.input.filePath === 'string' ? request.input.filePath : null) ||
|
|
240
|
-
(typeof request.input.file_path === 'string' ? request.input.file_path : null) ||
|
|
241
|
-
(typeof request.input.path === 'string' ? request.input.path : null) || '');
|
|
242
|
-
const oldText = ((typeof request.input.oldString === 'string' ? request.input.oldString : null) ||
|
|
243
|
-
(typeof request.input.old_string === 'string' ? request.input.old_string : null) ||
|
|
244
|
-
(typeof request.input.old_text === 'string' ? request.input.old_text : null) || '');
|
|
245
|
-
const newText = ((typeof request.input.newString === 'string' ? request.input.newString : null) ||
|
|
246
|
-
(typeof request.input.new_string === 'string' ? request.input.new_string : null) ||
|
|
247
|
-
(typeof request.input.new_text === 'string' ? request.input.new_text : null) || '');
|
|
248
|
-
const replaceAll = Boolean(request.input.replaceAll);
|
|
249
|
-
// DEBUG: Log extracted values
|
|
250
|
-
fs.appendFileSync('/tmp/compilr-debug.log', ` filePath: "${filePath}", oldText len: ${String(oldText.length)}, newText len: ${String(newText.length)}, replaceAll: ${String(replaceAll)}\n`);
|
|
251
|
-
if (filePath && oldText && newText) {
|
|
252
|
-
const editDiff = diff.generateEditDiff(filePath, oldText, newText, replaceAll);
|
|
253
|
-
fs.appendFileSync('/tmp/compilr-debug.log', ` editDiff: ${editDiff ? `${String(editDiff.lines.length)} lines` : 'null'}\n`);
|
|
254
|
-
if (editDiff) {
|
|
255
|
-
const s = getStyles();
|
|
256
|
-
diffLines = [
|
|
257
|
-
s.warning('● ') + chalk.bold(`Edit(${filePath.split('/').pop() ?? 'unknown'})`),
|
|
258
|
-
diff.formatDiffHeader(filePath, editDiff.additions, editDiff.removals),
|
|
259
|
-
...editDiff.lines,
|
|
260
|
-
];
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
const result = await sharedState.showPermissionOverlayV2({
|
|
265
|
-
toolName: request.toolName,
|
|
266
|
-
args: request.input,
|
|
267
|
-
description: request.description,
|
|
268
|
-
diffLines,
|
|
269
|
-
});
|
|
270
|
-
// Handle result
|
|
271
|
-
if (result === 'allow-always') {
|
|
272
|
-
sharedState.grantSession?.(request.toolName);
|
|
273
|
-
sharedState.setMode?.('auto-accept');
|
|
274
|
-
}
|
|
275
|
-
// null result means cancelled, treat as deny
|
|
276
|
-
return result !== null && result !== 'deny';
|
|
277
|
-
}
|
|
278
|
-
// Legacy mode: show permission prompt with manual footer coordination
|
|
279
|
-
// Flush any accumulated text BEFORE showing the permission overlay
|
|
280
|
-
// This ensures agent's "I'll help you..." text appears before the permission prompt
|
|
281
|
-
sharedState.flushTextBuffer?.();
|
|
282
|
-
// Pause footer to prevent interference with the overlay
|
|
283
|
-
sharedState.pauseFooter?.();
|
|
284
|
-
// Set overlay active flag so REPL buffers any text output
|
|
285
|
-
setOverlayActive(true);
|
|
286
|
-
// For edit operations, show the diff BEFORE the permission prompt
|
|
287
|
-
if (request.toolName === 'edit') {
|
|
288
|
-
const filePath = ((typeof request.input.filePath === 'string' ? request.input.filePath : null) ||
|
|
289
|
-
(typeof request.input.file_path === 'string' ? request.input.file_path : null) ||
|
|
290
|
-
(typeof request.input.path === 'string' ? request.input.path : null) || '');
|
|
291
|
-
const oldText = ((typeof request.input.oldString === 'string' ? request.input.oldString : null) ||
|
|
292
|
-
(typeof request.input.old_string === 'string' ? request.input.old_string : null) ||
|
|
293
|
-
(typeof request.input.old_text === 'string' ? request.input.old_text : null) || '');
|
|
294
|
-
const newText = ((typeof request.input.newString === 'string' ? request.input.newString : null) ||
|
|
295
|
-
(typeof request.input.new_string === 'string' ? request.input.new_string : null) ||
|
|
296
|
-
(typeof request.input.new_text === 'string' ? request.input.new_text : null) || '');
|
|
297
|
-
const replaceAll = Boolean(request.input.replaceAll);
|
|
298
|
-
if (filePath && oldText && newText) {
|
|
299
|
-
const editDiff = diff.generateEditDiff(filePath, oldText, newText, replaceAll);
|
|
300
|
-
const s = getStyles();
|
|
301
|
-
terminal.writeLine('');
|
|
302
|
-
if (editDiff) {
|
|
303
|
-
terminal.writeLine(s.warning('● ') + chalk.bold(`Edit(${filePath.split('/').pop() ?? 'unknown'})`));
|
|
304
|
-
terminal.writeLine(diff.formatDiffHeader(filePath, editDiff.additions, editDiff.removals));
|
|
305
|
-
for (const line of editDiff.lines) {
|
|
306
|
-
terminal.writeLine(line);
|
|
307
|
-
}
|
|
308
|
-
terminal.writeLine('');
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
// Fallback: show simple edit info
|
|
312
|
-
terminal.writeLine(s.warning('● ') + chalk.bold(`Edit(${filePath.split('/').pop() ?? 'unknown'})`));
|
|
313
|
-
terminal.writeLine(` ${s.muted('⎿')} Will replace text in ${s.primary(filePath.split('/').pop() ?? filePath)}`);
|
|
314
|
-
terminal.writeLine(` ${chalk.bgRed.white(' - ')} ${s.muted(oldText.slice(0, 60))}${oldText.length > 60 ? '...' : ''}`);
|
|
315
|
-
terminal.writeLine(` ${chalk.bgGreen.black(' + ')} ${s.muted(newText.slice(0, 60))}${newText.length > 60 ? '...' : ''}`);
|
|
316
|
-
terminal.writeLine('');
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
try {
|
|
321
|
-
const result = await showPermissionOverlay({
|
|
322
|
-
toolName: request.toolName,
|
|
323
|
-
args: request.input,
|
|
324
|
-
description: request.description,
|
|
325
|
-
});
|
|
326
|
-
// If user chose 'allow-always', grant session permission and switch to auto-accept mode
|
|
327
|
-
if (result === 'allow-always') {
|
|
328
|
-
sharedState.grantSession?.(request.toolName);
|
|
329
|
-
// Switch to auto-accept mode so user can see and toggle back if needed
|
|
330
|
-
sharedState.setMode?.('auto-accept');
|
|
331
|
-
}
|
|
332
|
-
// Convert result to boolean (allow/allow-always = true, deny = false)
|
|
333
|
-
return result !== 'deny';
|
|
334
|
-
}
|
|
335
|
-
finally {
|
|
336
|
-
// Clear overlay active flag and resume footer
|
|
337
|
-
setOverlayActive(false);
|
|
338
|
-
sharedState.resumeFooter?.();
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
// Register ask_user handler that coordinates with footer
|
|
342
|
-
registerAskUserHandler(async (input) => {
|
|
343
|
-
// Wait for event loop to process any pending tool_end events
|
|
344
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
345
|
-
// Flush any accumulated text BEFORE showing the overlay
|
|
346
|
-
sharedState.flushTextBuffer?.();
|
|
347
|
-
// V2 mode: use TerminalUI overlay system
|
|
348
|
-
if (sharedState.showAskUserOverlayV2) {
|
|
349
|
-
return sharedState.showAskUserOverlayV2({
|
|
350
|
-
questions: input.questions,
|
|
351
|
-
context: input.context,
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
// Legacy mode: pause footer and use InlineOverlay
|
|
355
|
-
sharedState.pauseFooter?.();
|
|
356
|
-
setOverlayActive(true);
|
|
357
|
-
try {
|
|
358
|
-
// Show the overlay and get answers
|
|
359
|
-
const result = await showAskUserOverlay({
|
|
360
|
-
questions: input.questions,
|
|
361
|
-
context: input.context,
|
|
362
|
-
});
|
|
363
|
-
return result;
|
|
364
|
-
}
|
|
365
|
-
finally {
|
|
366
|
-
// Clear overlay active flag and resume footer
|
|
367
|
-
setOverlayActive(false);
|
|
368
|
-
sharedState.resumeFooter?.();
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
// Register ask_user_simple handler for smaller models (flat schema)
|
|
372
|
-
registerAskUserSimpleHandler(async (input) => {
|
|
373
|
-
// Wait for event loop to process any pending tool_end events
|
|
374
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
375
|
-
// Flush any accumulated text BEFORE showing the overlay
|
|
376
|
-
sharedState.flushTextBuffer?.();
|
|
377
|
-
// V2 mode: use TerminalUI overlay system
|
|
378
|
-
if (sharedState.showAskUserSimpleOverlayV2) {
|
|
379
|
-
return sharedState.showAskUserSimpleOverlayV2({
|
|
380
|
-
question: input.question,
|
|
381
|
-
options: input.options,
|
|
382
|
-
allowCustom: input.allowCustom,
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
// Legacy mode: pause footer and use InlineOverlay
|
|
386
|
-
sharedState.pauseFooter?.();
|
|
387
|
-
setOverlayActive(true);
|
|
388
|
-
try {
|
|
389
|
-
// Show the simple overlay and get answer
|
|
390
|
-
const result = await showAskUserSimpleOverlay({
|
|
391
|
-
question: input.question,
|
|
392
|
-
options: input.options,
|
|
393
|
-
allowCustom: input.allowCustom,
|
|
394
|
-
});
|
|
395
|
-
return result;
|
|
396
|
-
}
|
|
397
|
-
finally {
|
|
398
|
-
// Clear overlay active flag and resume footer
|
|
399
|
-
setOverlayActive(false);
|
|
400
|
-
sharedState.resumeFooter?.();
|
|
401
|
-
}
|
|
402
|
-
});
|
|
413
|
+
perf('handlers-start');
|
|
414
|
+
// Create permission handler that respects mode state and custom rules
|
|
415
|
+
const onPermissionRequest = createPermissionHandler(sharedState);
|
|
416
|
+
// Register ask_user and ask_user_simple handlers
|
|
417
|
+
registerAskUserHandlers(sharedState);
|
|
418
|
+
// Register delegate, delegate_background, and handoff handlers for multi-agent delegation
|
|
419
|
+
registerDelegationHandlers(sharedState);
|
|
403
420
|
// Create iteration limit handler that shows overlay
|
|
404
421
|
const onIterationLimitReached = async (context) => {
|
|
405
422
|
// Wait for event loop to process any pending tool_end events
|
|
406
423
|
await new Promise((resolve) => setImmediate(resolve));
|
|
407
424
|
// Flush any accumulated text BEFORE showing the overlay
|
|
408
425
|
sharedState.flushTextBuffer?.();
|
|
409
|
-
//
|
|
410
|
-
if (sharedState.showIterationLimitOverlayV2) {
|
|
411
|
-
|
|
412
|
-
iteration: context.iteration,
|
|
413
|
-
maxIterations: context.maxIterations,
|
|
414
|
-
toolCallCount: context.toolCallCount,
|
|
415
|
-
});
|
|
416
|
-
if (result.continue) {
|
|
417
|
-
return result.additionalIterations;
|
|
418
|
-
}
|
|
419
|
-
return false;
|
|
426
|
+
// Use TerminalUI overlay system
|
|
427
|
+
if (!sharedState.showIterationLimitOverlayV2) {
|
|
428
|
+
throw new Error('iteration_limit overlay not initialized');
|
|
420
429
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
toolCallCount: context.toolCallCount,
|
|
429
|
-
});
|
|
430
|
-
if (result.continue) {
|
|
431
|
-
return result.additionalIterations;
|
|
432
|
-
}
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
finally {
|
|
436
|
-
// Clear overlay active flag and resume footer
|
|
437
|
-
setOverlayActive(false);
|
|
438
|
-
sharedState.resumeFooter?.();
|
|
430
|
+
const result = await sharedState.showIterationLimitOverlayV2({
|
|
431
|
+
iteration: context.iteration,
|
|
432
|
+
maxIterations: context.maxIterations,
|
|
433
|
+
toolCallCount: context.toolCallCount,
|
|
434
|
+
});
|
|
435
|
+
if (result.continue) {
|
|
436
|
+
return result.additionalIterations;
|
|
439
437
|
}
|
|
438
|
+
return false;
|
|
440
439
|
};
|
|
441
440
|
// Create guardrail confirmation handler (for risky operations that need approval)
|
|
442
441
|
const onGuardrailTriggered = async (result, context) => {
|
|
@@ -452,35 +451,63 @@ async function main() {
|
|
|
452
451
|
matchedInput: result.match ?? context.inputString,
|
|
453
452
|
category: result.guardrail?.tags?.[0],
|
|
454
453
|
};
|
|
455
|
-
//
|
|
456
|
-
if (sharedState.showGuardrailOverlayV2) {
|
|
457
|
-
|
|
458
|
-
return overlayResult.approved;
|
|
459
|
-
}
|
|
460
|
-
// Legacy mode: pause footer and use InlineOverlay
|
|
461
|
-
sharedState.pauseFooter?.();
|
|
462
|
-
setOverlayActive(true);
|
|
463
|
-
try {
|
|
464
|
-
const overlayResult = await showGuardrailOverlay(overlayOptions);
|
|
465
|
-
return overlayResult.approved;
|
|
466
|
-
}
|
|
467
|
-
finally {
|
|
468
|
-
// Clear overlay active flag and resume footer
|
|
469
|
-
setOverlayActive(false);
|
|
470
|
-
sharedState.resumeFooter?.();
|
|
454
|
+
// Use TerminalUI overlay system
|
|
455
|
+
if (!sharedState.showGuardrailOverlayV2) {
|
|
456
|
+
throw new Error('guardrail overlay not initialized');
|
|
471
457
|
}
|
|
458
|
+
const overlayResult = await sharedState.showGuardrailOverlayV2(overlayOptions);
|
|
459
|
+
return overlayResult.approved;
|
|
460
|
+
};
|
|
461
|
+
// ==========================================================================
|
|
462
|
+
// MCP Server Initialization (deferred — connects in background after REPL starts)
|
|
463
|
+
// ==========================================================================
|
|
464
|
+
perf('mcp-init-fire');
|
|
465
|
+
// Check if there are MCP servers to connect — fire the promise but don't await yet
|
|
466
|
+
const mcpServerCount = loadMCPConfig(dbProject?.path).length;
|
|
467
|
+
const mcpInitPromise = mcpServerCount > 0 ? initializeMCP(dbProject?.path) : null;
|
|
468
|
+
// Mutable ref for MCP tools — read by team agent factory when creating new agents.
|
|
469
|
+
// Updated when background MCP init completes.
|
|
470
|
+
let mcpToolsRef = [];
|
|
471
|
+
// ==========================================================================
|
|
472
|
+
// Episode Recorder Setup (work history tracking)
|
|
473
|
+
// ==========================================================================
|
|
474
|
+
const createEpisodeRecorder = (agentId) => {
|
|
475
|
+
if (!dbProject)
|
|
476
|
+
return undefined;
|
|
477
|
+
const episodesPath = path.join(getSessionsPath(), `project-${String(dbProject.id)}`, 'episodes.json');
|
|
478
|
+
const store = new FileEpisodeStore({ filePath: episodesPath });
|
|
479
|
+
// Set global store for recall_work tool access
|
|
480
|
+
setGlobalEpisodeStore(store);
|
|
481
|
+
return new EpisodeRecorder({
|
|
482
|
+
store,
|
|
483
|
+
agentId,
|
|
484
|
+
terminalPrefix: sharedState.sessionPrefix || 'unknown',
|
|
485
|
+
sessionId: sharedState.sessionPrefix || 'unknown',
|
|
486
|
+
onBatchFlushed: () => {
|
|
487
|
+
updateWorkSummaryAnchor({
|
|
488
|
+
store,
|
|
489
|
+
projectId: String(dbProject.id),
|
|
490
|
+
getAnchorManager,
|
|
491
|
+
});
|
|
492
|
+
},
|
|
493
|
+
});
|
|
472
494
|
};
|
|
473
|
-
|
|
495
|
+
const defaultEpisodeRecorder = createEpisodeRecorder('default');
|
|
496
|
+
// Create agent with permission handler and suggestion callback (no MCP tools yet)
|
|
497
|
+
perf('create-agent-start');
|
|
474
498
|
const agent = createAgent({
|
|
475
499
|
provider,
|
|
476
500
|
model,
|
|
477
501
|
minimal: options.minimal,
|
|
502
|
+
quiet: true,
|
|
503
|
+
enableMetaTools: !options.minimal, // Use meta-tools for token optimization
|
|
478
504
|
onPermissionRequest,
|
|
479
505
|
onIterationLimitReached,
|
|
480
506
|
onSuggest: (event) => {
|
|
481
507
|
// Store suggestion to be applied after agent finishes
|
|
482
508
|
sharedState.pendingSuggestion = event.action;
|
|
483
509
|
},
|
|
510
|
+
projectName: dbProject?.displayName,
|
|
484
511
|
projectContext,
|
|
485
512
|
guidedModeContext,
|
|
486
513
|
// Anchors - library handles re-injection on every LLM call
|
|
@@ -505,19 +532,110 @@ async function main() {
|
|
|
505
532
|
onSubagentTrackingReady: (clearTracking) => {
|
|
506
533
|
sharedState.clearSubagentTracking = clearTracking;
|
|
507
534
|
},
|
|
535
|
+
// MCP tools injected later via agent.registerTools() when background init completes
|
|
536
|
+
// Episode recorder for work history tracking
|
|
537
|
+
episodeRecorder: defaultEpisodeRecorder,
|
|
508
538
|
});
|
|
539
|
+
perf('create-agent-done');
|
|
509
540
|
// Bind grantSession for the permission handler to use
|
|
510
541
|
sharedState.grantSession = (toolName) => {
|
|
511
542
|
agent.grantSessionPermission(toolName);
|
|
512
543
|
};
|
|
513
544
|
// ==========================================================================
|
|
545
|
+
// Create AgentTeam with the default agent (or restore from persistence)
|
|
546
|
+
// ==========================================================================
|
|
547
|
+
perf('team-setup-start');
|
|
548
|
+
// Define agent factory for creating team agents
|
|
549
|
+
const agentFactory = (_config, systemPromptAddition, useMinimalSystemPrompt, noTools, toolFilter, modelTier) => {
|
|
550
|
+
// Resolve model from tier if provided, otherwise use global model
|
|
551
|
+
const agentModel = modelTier ? getModelForTier(provider, modelTier) : model;
|
|
552
|
+
// Create new agent with same base options plus role-specific system prompt
|
|
553
|
+
return Promise.resolve(createAgent({
|
|
554
|
+
provider,
|
|
555
|
+
model: agentModel,
|
|
556
|
+
minimal: options.minimal,
|
|
557
|
+
enableMetaTools: !options.minimal && !noTools, // Disable meta-tools if noTools is set
|
|
558
|
+
onPermissionRequest,
|
|
559
|
+
onIterationLimitReached,
|
|
560
|
+
onSuggest: (event) => {
|
|
561
|
+
sharedState.pendingSuggestion = event.action;
|
|
562
|
+
},
|
|
563
|
+
projectName: dbProject?.displayName,
|
|
564
|
+
projectContext,
|
|
565
|
+
guidedModeContext,
|
|
566
|
+
enableAnchors: true,
|
|
567
|
+
persistedAnchors: persistedAnchors.length > 0 ? persistedAnchors : undefined,
|
|
568
|
+
enableGuardrails: true,
|
|
569
|
+
onGuardrailTriggered,
|
|
570
|
+
onSubagentStart: (toolUseId, agentType, description) => {
|
|
571
|
+
sharedState.onSubagentStart?.(toolUseId, agentType, description);
|
|
572
|
+
},
|
|
573
|
+
onSubagentEnd: (toolUseId, success, tokenCount, error) => {
|
|
574
|
+
sharedState.onSubagentEnd?.(toolUseId, success, tokenCount, error);
|
|
575
|
+
},
|
|
576
|
+
onSubagentToolUse: (toolUseId, toolName, summary) => {
|
|
577
|
+
sharedState.onSubagentToolUse?.(toolUseId, toolName, summary);
|
|
578
|
+
},
|
|
579
|
+
onSubagentTrackingReady: (clearTracking) => {
|
|
580
|
+
sharedState.clearSubagentTracking = clearTracking;
|
|
581
|
+
},
|
|
582
|
+
// Add role-specific system prompt
|
|
583
|
+
systemPromptAddition,
|
|
584
|
+
// Use minimal system prompt (skip all modules) - for testing role identity
|
|
585
|
+
useMinimalSystemPrompt,
|
|
586
|
+
// Skip all tool registration - for testing role identity without tool interference
|
|
587
|
+
noTools,
|
|
588
|
+
// Tool filter - limit which tools this agent can use
|
|
589
|
+
toolFilter,
|
|
590
|
+
// MCP tools from external servers (reads mutable ref — includes tools once MCP init completes)
|
|
591
|
+
mcpTools: mcpToolsRef.length > 0 ? mcpToolsRef : undefined,
|
|
592
|
+
// Suppress startup logs for team agents (avoid UI interference)
|
|
593
|
+
quiet: true,
|
|
594
|
+
// Episode recorder for work history tracking (team agents share project store)
|
|
595
|
+
episodeRecorder: createEpisodeRecorder('team-agent'),
|
|
596
|
+
}));
|
|
597
|
+
};
|
|
598
|
+
// Create fresh team — team restoration happens through session restore in ReplV2.
|
|
599
|
+
// This ensures team state is always bound to a session (no independent team loading).
|
|
600
|
+
const team = new AgentTeam({
|
|
601
|
+
name: 'Team',
|
|
602
|
+
agentFactory,
|
|
603
|
+
});
|
|
604
|
+
team.setDefaultAgent(agent);
|
|
605
|
+
// Set the active shared context for activity recording
|
|
606
|
+
setActiveSharedContext(team.sharedContext);
|
|
607
|
+
// Populate shared context with actual project info so agents know the project name
|
|
608
|
+
if (dbProject) {
|
|
609
|
+
team.sharedContext.setProject({
|
|
610
|
+
id: dbProject.id,
|
|
611
|
+
name: dbProject.displayName,
|
|
612
|
+
path: dbProject.path,
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
// ==========================================================================
|
|
514
616
|
// Create and run REPL
|
|
515
617
|
// ==========================================================================
|
|
618
|
+
perf('repl-setup-start');
|
|
619
|
+
// Store team reference in sharedState for delegate handler access
|
|
620
|
+
sharedState.team = team;
|
|
621
|
+
// Await background update check (ran in parallel with auth + project loading)
|
|
622
|
+
if (updateCheckPromise) {
|
|
623
|
+
perf('update-check-wait');
|
|
624
|
+
await updateCheckPromise;
|
|
625
|
+
perf('update-check-done');
|
|
626
|
+
}
|
|
627
|
+
// VS Code diff: set enabled state based on settings + environment
|
|
628
|
+
perf('vscode-detect');
|
|
629
|
+
sharedState.vsDiffEnabled = isInVSCode() && getSetting('vsDiffExtension');
|
|
630
|
+
perf('repl-v2-create');
|
|
516
631
|
const replV2 = new ReplV2({
|
|
517
632
|
agent,
|
|
633
|
+
team,
|
|
634
|
+
agentFactory,
|
|
518
635
|
model,
|
|
519
636
|
provider,
|
|
520
637
|
version: VERSION,
|
|
638
|
+
updateAvailable,
|
|
521
639
|
projectName: dbProject?.displayName ?? process.cwd().split('/').pop(),
|
|
522
640
|
// Set up V2 permission overlay callback when UI is ready
|
|
523
641
|
onUIReady: (showOverlay) => {
|
|
@@ -543,6 +661,16 @@ async function main() {
|
|
|
543
661
|
onIterationLimitReady: (showOverlay) => {
|
|
544
662
|
sharedState.showIterationLimitOverlayV2 = showOverlay;
|
|
545
663
|
},
|
|
664
|
+
// Set up delegate V2 overlay callback
|
|
665
|
+
onDelegateReady: (showOverlay) => {
|
|
666
|
+
sharedState.showDelegateOverlayV2 = showOverlay;
|
|
667
|
+
},
|
|
668
|
+
// Callback to handle pending delegation after agent finishes
|
|
669
|
+
onPendingDelegation: () => {
|
|
670
|
+
const pending = sharedState.pendingDelegation;
|
|
671
|
+
sharedState.pendingDelegation = null;
|
|
672
|
+
return pending ?? null;
|
|
673
|
+
},
|
|
546
674
|
// Set up subagent tracking callbacks for LiveRegion rendering
|
|
547
675
|
onSubagentReady: (callbacks) => {
|
|
548
676
|
sharedState.onSubagentStart = callbacks.onStart;
|
|
@@ -562,13 +690,62 @@ async function main() {
|
|
|
562
690
|
sharedState.pendingSuggestion = null;
|
|
563
691
|
}
|
|
564
692
|
},
|
|
693
|
+
// Phase 3b: Set up background agent tracking callbacks for permission routing
|
|
694
|
+
onBackgroundAgentReady: (callbacks) => {
|
|
695
|
+
sharedState.isBackgroundAgent = callbacks.isBackgroundAgent;
|
|
696
|
+
sharedState.getActiveBackgroundAgentId = callbacks.getActiveBackgroundAgentId;
|
|
697
|
+
sharedState.getBackgroundAgentInfo = callbacks.getBackgroundAgentInfo;
|
|
698
|
+
},
|
|
699
|
+
// Phase 3d-beta: Set up background delegation callback for coordinator mode
|
|
700
|
+
onBackgroundDelegationReady: (runDelegation) => {
|
|
701
|
+
sharedState.runBackgroundDelegation = runDelegation;
|
|
702
|
+
},
|
|
703
|
+
// Update sharedState.team when session restore replaces the team object
|
|
704
|
+
// (so delegation handlers see restored agents, not just 'default')
|
|
705
|
+
onTeamReplaced: (newTeam) => {
|
|
706
|
+
sharedState.team = newTeam;
|
|
707
|
+
},
|
|
708
|
+
// Set session prefix for VS Code diff IPC after session registration
|
|
709
|
+
onSessionRegistered: (sessionId) => {
|
|
710
|
+
sharedState.sessionPrefix = sessionId.slice(0, 8);
|
|
711
|
+
},
|
|
712
|
+
// Show onboarding wizard on first run
|
|
713
|
+
showOnboarding: !isFirstRunComplete(),
|
|
714
|
+
// Show login overlay if not authenticated
|
|
715
|
+
showLogin,
|
|
565
716
|
});
|
|
566
717
|
// Handle Ctrl+C gracefully
|
|
567
718
|
process.on('SIGINT', () => {
|
|
719
|
+
// Flush episode recorder before exit
|
|
720
|
+
defaultEpisodeRecorder?.flush();
|
|
568
721
|
replV2.stop();
|
|
722
|
+
// Clean up MCP servers (kill child processes)
|
|
723
|
+
void mcpManagerInstance?.disconnectAll();
|
|
569
724
|
process.exit(0);
|
|
570
725
|
});
|
|
726
|
+
perf('repl-v2-start');
|
|
571
727
|
replV2.start();
|
|
728
|
+
perf('startup-complete');
|
|
729
|
+
flushStartupPerf();
|
|
730
|
+
// Complete MCP initialization in background — inject tools once connected.
|
|
731
|
+
// Shows "mcp: connecting..." in footer status bar while loading.
|
|
732
|
+
// MCP timing details available in ~/.compilr-dev/startup-perf.log.
|
|
733
|
+
if (mcpInitPromise) {
|
|
734
|
+
replV2.setMCPLoading(true);
|
|
735
|
+
mcpInitPromise
|
|
736
|
+
.then((tools) => {
|
|
737
|
+
perf('mcp-background-done');
|
|
738
|
+
replV2.setMCPLoading(false, tools.length);
|
|
739
|
+
if (tools.length > 0) {
|
|
740
|
+
agent.registerTools(tools);
|
|
741
|
+
mcpToolsRef = tools;
|
|
742
|
+
}
|
|
743
|
+
})
|
|
744
|
+
.catch(() => {
|
|
745
|
+
// MCP failure is non-fatal — agent works without MCP tools
|
|
746
|
+
replV2.setMCPLoading(false);
|
|
747
|
+
});
|
|
748
|
+
}
|
|
572
749
|
// REPL V2 runs in event loop - the ReplV2 manages its own lifecycle
|
|
573
750
|
}
|
|
574
751
|
// =============================================================================
|
|
@@ -587,15 +764,15 @@ function detectProvider() {
|
|
|
587
764
|
function getDefaultModel(provider) {
|
|
588
765
|
switch (provider) {
|
|
589
766
|
case 'claude':
|
|
590
|
-
return 'claude-sonnet-4-
|
|
767
|
+
return 'claude-sonnet-4-5-20250929';
|
|
591
768
|
case 'openai':
|
|
592
|
-
return 'gpt-
|
|
769
|
+
return 'gpt-5-mini-2025-08-07';
|
|
593
770
|
case 'gemini':
|
|
594
|
-
return 'gemini-
|
|
771
|
+
return 'gemini-3-flash-preview';
|
|
595
772
|
case 'ollama':
|
|
596
|
-
return 'llama3.2';
|
|
773
|
+
return 'llama3.2:8b';
|
|
597
774
|
default:
|
|
598
|
-
return 'claude-sonnet-4-
|
|
775
|
+
return 'claude-sonnet-4-5-20250929';
|
|
599
776
|
}
|
|
600
777
|
}
|
|
601
778
|
// =============================================================================
|