@compilr-dev/cli 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -12
- package/dist/agent.d.ts +74 -1
- package/dist/agent.js +259 -76
- package/dist/anchors/index.d.ts +9 -0
- package/dist/anchors/index.js +9 -0
- package/dist/anchors/project-anchors.d.ts +79 -0
- package/dist/anchors/project-anchors.js +202 -0
- package/dist/commands/handler-types.d.ts +68 -0
- package/dist/commands/handler-types.js +8 -0
- package/dist/commands/handlers/agent-commands.d.ts +13 -0
- package/dist/commands/handlers/agent-commands.js +305 -0
- package/dist/commands/handlers/design-commands.d.ts +15 -0
- package/dist/commands/handlers/design-commands.js +334 -0
- package/dist/commands/handlers/index.d.ts +20 -0
- package/dist/commands/handlers/index.js +43 -0
- package/dist/commands/handlers/overlay-commands.d.ts +21 -0
- package/dist/commands/handlers/overlay-commands.js +287 -0
- package/dist/commands/handlers/project-commands.d.ts +11 -0
- package/dist/commands/handlers/project-commands.js +167 -0
- package/dist/commands/handlers/simple-commands.d.ts +19 -0
- package/dist/commands/handlers/simple-commands.js +144 -0
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/registry.d.ts +50 -0
- package/dist/commands/registry.js +75 -0
- package/dist/commands-v2/handlers/context.d.ts +13 -0
- package/dist/commands-v2/handlers/context.js +348 -0
- package/dist/commands-v2/handlers/core.d.ts +13 -0
- package/dist/commands-v2/handlers/core.js +165 -0
- package/dist/commands-v2/handlers/debug.d.ts +11 -0
- package/dist/commands-v2/handlers/debug.js +159 -0
- package/dist/commands-v2/handlers/index.d.ts +12 -0
- package/dist/commands-v2/handlers/index.js +24 -0
- package/dist/commands-v2/handlers/project.d.ts +22 -0
- package/dist/commands-v2/handlers/project.js +814 -0
- package/dist/commands-v2/handlers/settings.d.ts +15 -0
- package/dist/commands-v2/handlers/settings.js +235 -0
- package/dist/commands-v2/index.d.ts +13 -0
- package/dist/commands-v2/index.js +15 -0
- package/dist/commands-v2/registry.d.ts +37 -0
- package/dist/commands-v2/registry.js +80 -0
- package/dist/commands-v2/types.d.ts +75 -0
- package/dist/commands-v2/types.js +7 -0
- package/dist/commands.js +110 -7
- package/dist/index.js +288 -29
- package/dist/input-handlers/index.d.ts +7 -0
- package/dist/input-handlers/index.js +7 -0
- package/dist/input-handlers/memory-handler.d.ts +26 -0
- package/dist/input-handlers/memory-handler.js +68 -0
- package/dist/repl-helpers.d.ts +63 -0
- package/dist/repl-helpers.js +318 -0
- package/dist/repl-v2.d.ts +155 -0
- package/dist/repl-v2.js +774 -0
- package/dist/repl.d.ts +32 -4
- package/dist/repl.js +250 -977
- package/dist/settings/index.d.ts +23 -0
- package/dist/settings/index.js +48 -0
- package/dist/settings/paths.d.ts +110 -0
- package/dist/settings/paths.js +264 -0
- package/dist/templates/compilr-md.js +7 -4
- package/dist/templates/index.js +3 -4
- package/dist/themes/colors.js +3 -1
- package/dist/themes/registry.d.ts +5 -36
- package/dist/themes/registry.js +11 -95
- package/dist/themes/types.d.ts +3 -38
- package/dist/themes/types.js +2 -2
- package/dist/tools/anchor-tools.d.ts +31 -0
- package/dist/tools/anchor-tools.js +255 -0
- package/dist/tools/backlog-wrappers.d.ts +54 -0
- package/dist/tools/backlog-wrappers.js +338 -0
- package/dist/tools/backlog.js +1 -1
- package/dist/tools/db-tools.d.ts +65 -0
- package/dist/tools/db-tools.js +19 -0
- package/dist/tools/document-db.d.ts +43 -0
- package/dist/tools/document-db.js +220 -0
- package/dist/tools/project-db.d.ts +102 -0
- package/dist/tools/project-db.js +370 -0
- package/dist/tools/workitem-db.d.ts +103 -0
- package/dist/tools/workitem-db.js +549 -0
- package/dist/tools.js +13 -3
- package/dist/ui/agents-overlay-v2.d.ts +43 -0
- package/dist/ui/agents-overlay-v2.js +809 -0
- package/dist/ui/agents-overlay.d.ts +5 -5
- package/dist/ui/agents-overlay.js +782 -420
- package/dist/ui/anchors-overlay.d.ts +12 -0
- package/dist/ui/anchors-overlay.js +775 -0
- package/dist/ui/arch-type-overlay.d.ts +1 -6
- package/dist/ui/arch-type-overlay.js +175 -203
- package/dist/ui/ask-user-overlay-v2.d.ts +26 -0
- package/dist/ui/ask-user-overlay-v2.js +555 -0
- package/dist/ui/ask-user-overlay.d.ts +2 -2
- package/dist/ui/ask-user-overlay.js +443 -535
- package/dist/ui/ask-user-simple-overlay-v2.d.ts +25 -0
- package/dist/ui/ask-user-simple-overlay-v2.js +215 -0
- package/dist/ui/ask-user-simple-overlay.d.ts +2 -2
- package/dist/ui/ask-user-simple-overlay.js +182 -209
- package/dist/ui/backlog-overlay.d.ts +16 -1
- package/dist/ui/backlog-overlay.js +525 -659
- package/dist/ui/base/index.d.ts +26 -0
- package/dist/ui/base/index.js +33 -0
- package/dist/ui/base/inline-overlay-utils.d.ts +217 -0
- package/dist/ui/base/inline-overlay-utils.js +320 -0
- package/dist/ui/base/inline-overlay.d.ts +159 -0
- package/dist/ui/base/inline-overlay.js +257 -0
- package/dist/ui/base/key-utils.d.ts +15 -0
- package/dist/ui/base/key-utils.js +30 -0
- package/dist/ui/base/overlay-base-v2.d.ts +193 -0
- package/dist/ui/base/overlay-base-v2.js +246 -0
- package/dist/ui/base/overlay-base.d.ts +156 -0
- package/dist/ui/base/overlay-base.js +238 -0
- package/dist/ui/base/overlay-lifecycle.d.ts +65 -0
- package/dist/ui/base/overlay-lifecycle.js +159 -0
- package/dist/ui/base/overlay-types.d.ts +185 -0
- package/dist/ui/base/overlay-types.js +7 -0
- package/dist/ui/base/render-utils.d.ts +8 -0
- package/dist/ui/base/render-utils.js +11 -0
- package/dist/ui/base/screen-stack.d.ts +148 -0
- package/dist/ui/base/screen-stack.js +184 -0
- package/dist/ui/base/tabbed-list-overlay-v2.d.ts +103 -0
- package/dist/ui/base/tabbed-list-overlay-v2.js +317 -0
- package/dist/ui/base/tabbed-list-overlay.d.ts +153 -0
- package/dist/ui/base/tabbed-list-overlay.js +369 -0
- package/dist/ui/commands-overlay-v2.d.ts +33 -0
- package/dist/ui/commands-overlay-v2.js +441 -0
- package/dist/ui/commands-overlay.d.ts +7 -2
- package/dist/ui/commands-overlay.js +384 -355
- package/dist/ui/config-overlay.d.ts +5 -4
- package/dist/ui/config-overlay.js +243 -513
- package/dist/ui/conversation.d.ts +75 -4
- package/dist/ui/conversation.js +374 -161
- package/dist/ui/docs-overlay.d.ts +17 -0
- package/dist/ui/docs-overlay.js +303 -0
- package/dist/ui/ephemeral.d.ts +1 -1
- package/dist/ui/ephemeral.js +1 -1
- package/dist/ui/features/index.d.ts +34 -0
- package/dist/ui/features/index.js +34 -0
- package/dist/ui/features/input-feature.d.ts +85 -0
- package/dist/ui/features/input-feature.js +238 -0
- package/dist/ui/features/list-feature.d.ts +155 -0
- package/dist/ui/features/list-feature.js +244 -0
- package/dist/ui/features/pagination-feature.d.ts +154 -0
- package/dist/ui/features/pagination-feature.js +238 -0
- package/dist/ui/features/search-feature.d.ts +148 -0
- package/dist/ui/features/search-feature.js +185 -0
- package/dist/ui/features/tab-feature.d.ts +194 -0
- package/dist/ui/features/tab-feature.js +307 -0
- package/dist/ui/footer-v2.d.ts +222 -0
- package/dist/ui/footer-v2.js +1349 -0
- package/dist/ui/footer.d.ts +107 -0
- package/dist/ui/footer.js +359 -67
- package/dist/ui/guardrail-overlay.d.ts +29 -0
- package/dist/ui/guardrail-overlay.js +145 -0
- package/dist/ui/help-overlay-v2.d.ts +34 -0
- package/dist/ui/help-overlay-v2.js +309 -0
- package/dist/ui/help-overlay.d.ts +16 -0
- package/dist/ui/help-overlay.js +316 -0
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -3
- package/dist/ui/init-overlay-v2.d.ts +34 -0
- package/dist/ui/init-overlay-v2.js +600 -0
- package/dist/ui/init-overlay.d.ts +12 -2
- package/dist/ui/init-overlay.js +349 -270
- package/dist/ui/input-prompt-v2.d.ts +1 -0
- package/dist/ui/input-prompt-v2.js +14 -6
- package/dist/ui/input-prompt.d.ts +116 -33
- package/dist/ui/input-prompt.js +536 -337
- package/dist/ui/iteration-limit-overlay-v2.d.ts +21 -0
- package/dist/ui/iteration-limit-overlay-v2.js +114 -0
- package/dist/ui/iteration-limit-overlay.d.ts +2 -2
- package/dist/ui/iteration-limit-overlay.js +92 -128
- package/dist/ui/keys-overlay-v2.d.ts +41 -0
- package/dist/ui/keys-overlay-v2.js +248 -0
- package/dist/ui/keys-overlay.d.ts +1 -0
- package/dist/ui/keys-overlay.js +203 -141
- package/dist/ui/line-utils.d.ts +88 -0
- package/dist/ui/line-utils.js +150 -0
- package/dist/ui/live-region.d.ts +161 -0
- package/dist/ui/live-region.js +387 -0
- package/dist/ui/mascot/expressions.d.ts +32 -0
- package/dist/ui/mascot/expressions.js +213 -0
- package/dist/ui/mascot/index.d.ts +8 -0
- package/dist/ui/mascot/index.js +8 -0
- package/dist/ui/mascot/renderer.d.ts +19 -0
- package/dist/ui/mascot/renderer.js +97 -0
- package/dist/ui/mascot-overlay-v2.d.ts +41 -0
- package/dist/ui/mascot-overlay-v2.js +138 -0
- package/dist/ui/mascot-overlay.d.ts +21 -0
- package/dist/ui/mascot-overlay.js +146 -0
- package/dist/ui/model-overlay-v2.d.ts +49 -0
- package/dist/ui/model-overlay-v2.js +118 -0
- package/dist/ui/model-overlay.d.ts +27 -0
- package/dist/ui/model-overlay.js +221 -0
- package/dist/ui/model-warning-overlay.js +3 -5
- package/dist/ui/new-overlay.d.ts +34 -0
- package/dist/ui/new-overlay.js +604 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.d.ts +45 -0
- package/dist/ui/overlay/impl/agents-overlay-v2.js +825 -0
- package/dist/ui/overlay/impl/anchors-overlay-v2.d.ts +47 -0
- package/dist/ui/overlay/impl/anchors-overlay-v2.js +783 -0
- package/dist/ui/overlay/impl/arch-type-overlay-v2.d.ts +37 -0
- package/dist/ui/overlay/impl/arch-type-overlay-v2.js +240 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.d.ts +72 -0
- package/dist/ui/overlay/impl/ask-user-overlay-v2.js +584 -0
- package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.d.ts +46 -0
- package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.js +204 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/backlog-overlay-v2.js +642 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.d.ts +33 -0
- package/dist/ui/overlay/impl/commands-overlay-v2.js +441 -0
- package/dist/ui/overlay/impl/config-overlay-v2.d.ts +100 -0
- package/dist/ui/overlay/impl/config-overlay-v2.js +654 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.d.ts +55 -0
- package/dist/ui/overlay/impl/dashboard-overlay-v2.js +359 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.d.ts +45 -0
- package/dist/ui/overlay/impl/docs-overlay-v2.js +114 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/document-detail-overlay-v2.js +1071 -0
- package/dist/ui/overlay/impl/guardrail-overlay-v2.d.ts +43 -0
- package/dist/ui/overlay/impl/guardrail-overlay-v2.js +114 -0
- package/dist/ui/overlay/impl/help-overlay-v2.d.ts +34 -0
- package/dist/ui/overlay/impl/help-overlay-v2.js +309 -0
- package/dist/ui/overlay/impl/init-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/init-overlay-v2.js +593 -0
- package/dist/ui/overlay/impl/init-setup-overlay-v2.d.ts +25 -0
- package/dist/ui/overlay/impl/init-setup-overlay-v2.js +97 -0
- package/dist/ui/overlay/impl/iteration-limit-overlay-v2.d.ts +35 -0
- package/dist/ui/overlay/impl/iteration-limit-overlay-v2.js +105 -0
- package/dist/ui/overlay/impl/keys-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/keys-overlay-v2.js +248 -0
- package/dist/ui/overlay/impl/mascot-overlay-v2.d.ts +41 -0
- package/dist/ui/overlay/impl/mascot-overlay-v2.js +138 -0
- package/dist/ui/overlay/impl/model-overlay-v2.d.ts +49 -0
- package/dist/ui/overlay/impl/model-overlay-v2.js +118 -0
- package/dist/ui/overlay/impl/model-warning-overlay-v2.d.ts +46 -0
- package/dist/ui/overlay/impl/model-warning-overlay-v2.js +132 -0
- package/dist/ui/overlay/impl/new-overlay-v2.d.ts +77 -0
- package/dist/ui/overlay/impl/new-overlay-v2.js +593 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/permission-overlay-v2.js +380 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.d.ts +36 -0
- package/dist/ui/overlay/impl/projects-overlay-v2.js +499 -0
- package/dist/ui/overlay/impl/theme-overlay-v2.d.ts +42 -0
- package/dist/ui/overlay/impl/theme-overlay-v2.js +135 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.d.ts +47 -0
- package/dist/ui/overlay/impl/tools-overlay-v2.js +218 -0
- package/dist/ui/overlay/impl/tutorial-overlay-v2.d.ts +31 -0
- package/dist/ui/overlay/impl/tutorial-overlay-v2.js +1035 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +80 -0
- package/dist/ui/overlay/impl/workflow-overlay-v2.js +637 -0
- package/dist/ui/overlay/index.d.ts +33 -0
- package/dist/ui/overlay/index.js +35 -0
- package/dist/ui/overlay/key-utils.d.ts +6 -0
- package/dist/ui/overlay/key-utils.js +6 -0
- package/dist/ui/overlay/overlay-types.d.ts +128 -0
- package/dist/ui/overlay/overlay-types.js +22 -0
- package/dist/ui/overlay/types.d.ts +135 -0
- package/dist/ui/overlay/types.js +22 -0
- package/dist/ui/overlays/help-overlay-v2.d.ts +28 -0
- package/dist/ui/overlays/help-overlay-v2.js +198 -0
- package/dist/ui/overlays/index.d.ts +11 -0
- package/dist/ui/overlays/index.js +11 -0
- package/dist/ui/overlays.d.ts +0 -4
- package/dist/ui/overlays.js +0 -444
- package/dist/ui/permission-overlay-v2.d.ts +36 -0
- package/dist/ui/permission-overlay-v2.js +380 -0
- package/dist/ui/permission-overlay.d.ts +1 -1
- package/dist/ui/permission-overlay.js +186 -298
- package/dist/ui/projects-overlay.d.ts +19 -0
- package/dist/ui/projects-overlay.js +484 -0
- package/dist/ui/providers/types.d.ts +178 -0
- package/dist/ui/providers/types.js +9 -0
- package/dist/ui/render-modes.d.ts +36 -0
- package/dist/ui/render-modes.js +44 -0
- package/dist/ui/startup-menu.d.ts +36 -0
- package/dist/ui/startup-menu.js +236 -0
- package/dist/ui/subagent-renderer.d.ts +117 -0
- package/dist/ui/subagent-renderer.js +334 -0
- package/dist/ui/terminal-codes.d.ts +94 -0
- package/dist/ui/terminal-codes.js +124 -0
- package/dist/ui/terminal-renderer.d.ts +221 -0
- package/dist/ui/terminal-renderer.js +751 -0
- package/dist/ui/terminal-ui.d.ts +463 -0
- package/dist/ui/terminal-ui.js +2296 -0
- package/dist/ui/terminal.d.ts +20 -0
- package/dist/ui/terminal.js +72 -0
- package/dist/ui/theme-overlay-v2.d.ts +42 -0
- package/dist/ui/theme-overlay-v2.js +135 -0
- package/dist/ui/theme-overlay.d.ts +24 -0
- package/dist/ui/theme-overlay.js +127 -0
- package/dist/ui/todo-zone.js +53 -25
- package/dist/ui/tool-formatters.d.ts +16 -0
- package/dist/ui/tool-formatters.js +516 -0
- package/dist/ui/tools-overlay-v2.d.ts +47 -0
- package/dist/ui/tools-overlay-v2.js +218 -0
- package/dist/ui/tools-overlay.d.ts +10 -2
- package/dist/ui/tools-overlay.js +172 -220
- package/dist/ui/tutorial-overlay-v2.d.ts +31 -0
- package/dist/ui/tutorial-overlay-v2.js +1035 -0
- package/dist/ui/tutorial-overlay.d.ts +1 -0
- package/dist/ui/tutorial-overlay.js +400 -302
- package/dist/ui/workflow-overlay.d.ts +22 -0
- package/dist/ui/workflow-overlay.js +636 -0
- package/dist/utils/debug-log.d.ts +28 -0
- package/dist/utils/debug-log.js +57 -0
- package/dist/utils/model-tiers.js +1 -1
- package/dist/utils/path-safety.d.ts +56 -0
- package/dist/utils/path-safety.js +239 -0
- package/dist/workflow/guided-mode-injector.d.ts +42 -0
- package/dist/workflow/guided-mode-injector.js +191 -0
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +8 -0
- package/dist/workflow/step-criteria.d.ts +62 -0
- package/dist/workflow/step-criteria.js +150 -0
- package/dist/workflow/step-tracker.d.ts +92 -0
- package/dist/workflow/step-tracker.js +141 -0
- package/package.json +12 -5
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL Helper Functions
|
|
3
|
+
*
|
|
4
|
+
* Standalone utility functions extracted from repl.ts to reduce file size
|
|
5
|
+
* and improve maintainability. These functions support the REPL but don't
|
|
6
|
+
* depend on REPL instance state.
|
|
7
|
+
*/
|
|
8
|
+
import { builtinSkills } from '@compilr-dev/agents';
|
|
9
|
+
import { codingSkills } from '@compilr-dev/agents-coding';
|
|
10
|
+
import * as fs from 'fs';
|
|
11
|
+
import * as path from 'path';
|
|
12
|
+
import { findBacklogPath, parseBacklogItems } from './tools/backlog.js';
|
|
13
|
+
import { loadCompilrConfig } from './utils/project-status.js';
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Tool Intent Detection
|
|
16
|
+
// =============================================================================
|
|
17
|
+
/**
|
|
18
|
+
* Keyword patterns for tool selection based on user input.
|
|
19
|
+
* Maps tool names to keywords that suggest the tool should be used.
|
|
20
|
+
*/
|
|
21
|
+
export const TOOL_KEYWORDS = {
|
|
22
|
+
read_file: ['read', 'show', 'display', 'look at', 'view', 'what is in', 'content of'],
|
|
23
|
+
write_file: ['write', 'create', 'save', 'make a file'],
|
|
24
|
+
edit: ['edit', 'modify', 'change', 'update', 'fix', 'replace'],
|
|
25
|
+
bash: ['run', 'execute', 'command', 'shell', 'npm', 'git', 'pip', 'ls', 'pwd', 'mkdir', 'build', 'install'],
|
|
26
|
+
grep: ['search', 'find', 'grep', 'look for', 'where is', 'occurrences'],
|
|
27
|
+
glob: ['list files', 'find files', 'what files', 'show files', 'directory', 'pattern'],
|
|
28
|
+
todo_write: ['todo', 'task list', 'plan', 'steps'],
|
|
29
|
+
todo_read: ['todo', 'task list', 'plan', 'steps'],
|
|
30
|
+
// Database-backed workitem tools replace file-based backlog tools
|
|
31
|
+
workitem_query: ['backlog', 'requirements', 'features', 'bugs', 'items', 'work items'],
|
|
32
|
+
workitem_add: ['backlog', 'requirements', 'features', 'bugs', 'add item', 'add feature', 'add work item'],
|
|
33
|
+
workitem_update: ['update item', 'change status', 'complete item'],
|
|
34
|
+
git_status: ['git status', 'changes', 'modified', 'staged'],
|
|
35
|
+
git_diff: ['git diff', 'differences', 'what changed'],
|
|
36
|
+
git_log: ['git log', 'history', 'commits'],
|
|
37
|
+
git_commit: ['commit', 'save changes'],
|
|
38
|
+
git_branch: ['branch', 'branches'],
|
|
39
|
+
detect_project: ['project type', 'what kind of project', 'framework'],
|
|
40
|
+
find_project_root: ['project root', 'root directory'],
|
|
41
|
+
run_tests: ['test', 'tests', 'run tests', 'check tests'],
|
|
42
|
+
run_lint: ['lint', 'linting', 'check code', 'style'],
|
|
43
|
+
// Task tool for sub-agent delegation
|
|
44
|
+
task: [
|
|
45
|
+
'explore', 'investigate', 'analyze', 'review code', 'code review',
|
|
46
|
+
'security audit', 'refactor', 'help me find', 'search the codebase',
|
|
47
|
+
'look through', 'scan for', 'debug', 'figure out', 'understand',
|
|
48
|
+
'complex', 'multi-step', 'delegate', 'sub-agent', 'agent',
|
|
49
|
+
],
|
|
50
|
+
// User interaction tools
|
|
51
|
+
ask_user: ['ask', 'question', 'choice', 'select', 'options'],
|
|
52
|
+
ask_user_simple: ['confirm', 'yes or no', 'simple question'],
|
|
53
|
+
suggest: ['suggest', 'recommendation', 'next step'],
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Select relevant tool names based on user input intent.
|
|
57
|
+
* Returns all tools if input is short or a question.
|
|
58
|
+
*/
|
|
59
|
+
export function selectToolNamesByIntent(input, allToolNames) {
|
|
60
|
+
const lower = input.toLowerCase();
|
|
61
|
+
// If input is very short or a question, use all tools
|
|
62
|
+
if (input.length < 10 || input.includes('?')) {
|
|
63
|
+
return allToolNames;
|
|
64
|
+
}
|
|
65
|
+
const selected = new Set();
|
|
66
|
+
// Add tools based on keyword matches
|
|
67
|
+
for (const [tool, keywords] of Object.entries(TOOL_KEYWORDS)) {
|
|
68
|
+
if (keywords.some((kw) => lower.includes(kw)) && allToolNames.includes(tool)) {
|
|
69
|
+
selected.add(tool);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// If nothing matched from keywords, use all tools
|
|
73
|
+
// (Check BEFORE adding always-included tools)
|
|
74
|
+
if (selected.size === 0) {
|
|
75
|
+
return allToolNames;
|
|
76
|
+
}
|
|
77
|
+
// Always include todo tools (they're used implicitly for task tracking)
|
|
78
|
+
if (allToolNames.includes('todo_write'))
|
|
79
|
+
selected.add('todo_write');
|
|
80
|
+
if (allToolNames.includes('todo_read'))
|
|
81
|
+
selected.add('todo_read');
|
|
82
|
+
// Always include suggest tool (for next action suggestions)
|
|
83
|
+
if (allToolNames.includes('suggest'))
|
|
84
|
+
selected.add('suggest');
|
|
85
|
+
return Array.from(selected);
|
|
86
|
+
}
|
|
87
|
+
// =============================================================================
|
|
88
|
+
// Build Command Types and Constants
|
|
89
|
+
// =============================================================================
|
|
90
|
+
/**
|
|
91
|
+
* Priority order for sorting backlog items (most important first).
|
|
92
|
+
*/
|
|
93
|
+
export const PRIORITY_ORDER = ['critical', 'high', 'medium', 'low'];
|
|
94
|
+
/**
|
|
95
|
+
* Detect if we're in a compilr project (has .compilr folder or -docs sibling).
|
|
96
|
+
* Returns project path from config.json if available.
|
|
97
|
+
*/
|
|
98
|
+
export function detectCompilrProject() {
|
|
99
|
+
const cwd = process.cwd();
|
|
100
|
+
// First try to load config and get paths from there
|
|
101
|
+
const config = loadCompilrConfig(cwd);
|
|
102
|
+
if (config) {
|
|
103
|
+
return {
|
|
104
|
+
found: true,
|
|
105
|
+
backlogPath: findBacklogPath(cwd),
|
|
106
|
+
projectPath: config.paths.project || null,
|
|
107
|
+
docsPath: config.paths.docs,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Check for .compilr folder in current directory
|
|
111
|
+
const compilrDir = path.join(cwd, '.compilr');
|
|
112
|
+
if (fs.existsSync(compilrDir)) {
|
|
113
|
+
const backlogPath = path.join(compilrDir, 'backlog.md');
|
|
114
|
+
return {
|
|
115
|
+
found: true,
|
|
116
|
+
backlogPath: fs.existsSync(backlogPath) ? backlogPath : null,
|
|
117
|
+
projectPath: cwd,
|
|
118
|
+
docsPath: null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
// Check for -docs sibling folder (two-repo pattern)
|
|
122
|
+
const parentDir = path.dirname(cwd);
|
|
123
|
+
const projectName = path.basename(cwd);
|
|
124
|
+
const docsDir = path.join(parentDir, `${projectName}-docs`);
|
|
125
|
+
const docsBacklogPath = path.join(docsDir, '01-planning', 'backlog.md');
|
|
126
|
+
if (fs.existsSync(docsBacklogPath)) {
|
|
127
|
+
return {
|
|
128
|
+
found: true,
|
|
129
|
+
backlogPath: docsBacklogPath,
|
|
130
|
+
projectPath: cwd,
|
|
131
|
+
docsPath: docsDir,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// Check if we're in the docs repo itself
|
|
135
|
+
const inDocsBacklog = path.join(cwd, '01-planning', 'backlog.md');
|
|
136
|
+
if (fs.existsSync(inDocsBacklog)) {
|
|
137
|
+
// We're in -docs folder, try to find sibling code folder
|
|
138
|
+
const baseName = projectName.replace(/-docs$/, '');
|
|
139
|
+
const codeDir = path.join(parentDir, baseName);
|
|
140
|
+
return {
|
|
141
|
+
found: true,
|
|
142
|
+
backlogPath: inDocsBacklog,
|
|
143
|
+
projectPath: fs.existsSync(codeDir) ? codeDir : null,
|
|
144
|
+
docsPath: cwd,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Check for project subfolders (running from parent folder after /new)
|
|
148
|
+
try {
|
|
149
|
+
const entries = fs.readdirSync(cwd, { withFileTypes: true });
|
|
150
|
+
for (const entry of entries) {
|
|
151
|
+
if (!entry.isDirectory())
|
|
152
|
+
continue;
|
|
153
|
+
// Check for .compilr in subfolder (single-repo pattern)
|
|
154
|
+
const subCompilrDir = path.join(cwd, entry.name, '.compilr');
|
|
155
|
+
if (fs.existsSync(subCompilrDir)) {
|
|
156
|
+
const backlogPath = path.join(subCompilrDir, 'backlog.md');
|
|
157
|
+
return {
|
|
158
|
+
found: true,
|
|
159
|
+
backlogPath: fs.existsSync(backlogPath) ? backlogPath : null,
|
|
160
|
+
projectPath: path.join(cwd, entry.name),
|
|
161
|
+
docsPath: null,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// Check for -docs subfolder (two-repo pattern)
|
|
165
|
+
if (entry.name.endsWith('-docs')) {
|
|
166
|
+
const docsBacklog = path.join(cwd, entry.name, '01-planning', 'backlog.md');
|
|
167
|
+
if (fs.existsSync(docsBacklog)) {
|
|
168
|
+
const baseName = entry.name.replace(/-docs$/, '');
|
|
169
|
+
const codeDir = path.join(cwd, baseName);
|
|
170
|
+
return {
|
|
171
|
+
found: true,
|
|
172
|
+
backlogPath: docsBacklog,
|
|
173
|
+
projectPath: fs.existsSync(codeDir) ? codeDir : null,
|
|
174
|
+
docsPath: path.join(cwd, entry.name),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// Ignore read errors
|
|
182
|
+
}
|
|
183
|
+
return { found: false, backlogPath: null, projectPath: null, docsPath: null };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Check if backlog has any items using the shared parser.
|
|
187
|
+
*/
|
|
188
|
+
export function hasBacklogItems(backlogPath) {
|
|
189
|
+
if (!backlogPath || !fs.existsSync(backlogPath)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const content = fs.readFileSync(backlogPath, 'utf-8');
|
|
194
|
+
const items = parseBacklogItems(content);
|
|
195
|
+
return items.length > 0;
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get skill prompt by name from builtinSkills or codingSkills.
|
|
203
|
+
*/
|
|
204
|
+
export function getSkillPrompt(name) {
|
|
205
|
+
const skill = builtinSkills.find((s) => s.name === name)
|
|
206
|
+
?? codingSkills.find((s) => s.name === name);
|
|
207
|
+
return skill?.prompt ?? null;
|
|
208
|
+
}
|
|
209
|
+
// =============================================================================
|
|
210
|
+
// Build Command Helpers
|
|
211
|
+
// =============================================================================
|
|
212
|
+
/**
|
|
213
|
+
* Select the best backlog item to build.
|
|
214
|
+
* If requestedId is provided, finds that specific item.
|
|
215
|
+
* Otherwise, auto-picks the highest priority 📋 item.
|
|
216
|
+
*/
|
|
217
|
+
export function selectBuildItem(items, requestedId) {
|
|
218
|
+
// If specific ID requested, find it
|
|
219
|
+
if (requestedId && requestedId.toLowerCase() !== 'scaffold') {
|
|
220
|
+
const searchId = requestedId.toUpperCase();
|
|
221
|
+
const item = items.find(i => i.id === searchId);
|
|
222
|
+
if (!item)
|
|
223
|
+
return null;
|
|
224
|
+
if (item.status !== '📋') {
|
|
225
|
+
// Item exists but not in planned status
|
|
226
|
+
return null; // Handler will show appropriate message
|
|
227
|
+
}
|
|
228
|
+
return item;
|
|
229
|
+
}
|
|
230
|
+
// Filter to only 📋 (planned) items
|
|
231
|
+
const planned = items.filter(i => i.status === '📋');
|
|
232
|
+
if (planned.length === 0)
|
|
233
|
+
return null;
|
|
234
|
+
// Sort by priority, then by ID
|
|
235
|
+
planned.sort((a, b) => {
|
|
236
|
+
const prioA = PRIORITY_ORDER.indexOf(a.priority.toLowerCase());
|
|
237
|
+
const prioB = PRIORITY_ORDER.indexOf(b.priority.toLowerCase());
|
|
238
|
+
if (prioA !== prioB)
|
|
239
|
+
return prioA - prioB;
|
|
240
|
+
return a.id.localeCompare(b.id); // REQ-001 before REQ-002
|
|
241
|
+
});
|
|
242
|
+
return planned[0];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Find dependency IDs mentioned in item title/description.
|
|
246
|
+
* Looks for patterns like "depends on REQ-001", "blocked by BUG-002", etc.
|
|
247
|
+
*/
|
|
248
|
+
export function findDependencies(item) {
|
|
249
|
+
const text = `${item.title} ${item.description}`;
|
|
250
|
+
const patterns = [
|
|
251
|
+
/depends\s+on\s+([A-Z]+-\d+)/gi,
|
|
252
|
+
/blocked\s+by\s+([A-Z]+-\d+)/gi,
|
|
253
|
+
/requires\s+([A-Z]+-\d+)/gi,
|
|
254
|
+
/after\s+([A-Z]+-\d+)/gi,
|
|
255
|
+
/needs\s+([A-Z]+-\d+)/gi,
|
|
256
|
+
];
|
|
257
|
+
const deps = [];
|
|
258
|
+
for (const pattern of patterns) {
|
|
259
|
+
const matches = text.matchAll(pattern);
|
|
260
|
+
for (const match of matches) {
|
|
261
|
+
deps.push(match[1].toUpperCase());
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return [...new Set(deps)];
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Get list of dependencies that are not yet completed.
|
|
268
|
+
*/
|
|
269
|
+
export function getUnmetDependencies(item, allItems) {
|
|
270
|
+
const depIds = findDependencies(item);
|
|
271
|
+
return allItems.filter(i => depIds.includes(i.id) && i.status !== '✅');
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Check if the project has a code foundation (src/, package.json, etc.)
|
|
275
|
+
*/
|
|
276
|
+
export function hasProjectFoundation() {
|
|
277
|
+
const cwd = process.cwd();
|
|
278
|
+
const indicators = [
|
|
279
|
+
'src',
|
|
280
|
+
'lib',
|
|
281
|
+
'app',
|
|
282
|
+
'package.json',
|
|
283
|
+
'requirements.txt',
|
|
284
|
+
'Cargo.toml',
|
|
285
|
+
'go.mod',
|
|
286
|
+
'pom.xml',
|
|
287
|
+
'build.gradle',
|
|
288
|
+
'setup.py',
|
|
289
|
+
'pyproject.toml',
|
|
290
|
+
];
|
|
291
|
+
for (const indicator of indicators) {
|
|
292
|
+
const fullPath = path.join(cwd, indicator);
|
|
293
|
+
if (fs.existsSync(fullPath)) {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Also check in project subfolders (for two-repo pattern)
|
|
298
|
+
try {
|
|
299
|
+
const entries = fs.readdirSync(cwd, { withFileTypes: true });
|
|
300
|
+
for (const entry of entries) {
|
|
301
|
+
if (!entry.isDirectory())
|
|
302
|
+
continue;
|
|
303
|
+
// Skip docs folder and hidden folders
|
|
304
|
+
if (entry.name.endsWith('-docs') || entry.name.startsWith('.'))
|
|
305
|
+
continue;
|
|
306
|
+
for (const indicator of indicators) {
|
|
307
|
+
const subPath = path.join(cwd, entry.name, indicator);
|
|
308
|
+
if (fs.existsSync(subPath)) {
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
// Ignore read errors
|
|
316
|
+
}
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REPL V2 - New Terminal UI based REPL
|
|
3
|
+
*
|
|
4
|
+
* Uses TerminalUI with:
|
|
5
|
+
* - Persistent footer (todo list + input prompt)
|
|
6
|
+
* - Overlay system for commands
|
|
7
|
+
* - Real agent integration (or simulation mode for testing)
|
|
8
|
+
*
|
|
9
|
+
* Can be run standalone: npx tsx src/repl-v2.ts
|
|
10
|
+
* Or imported and used with a real agent from index.ts
|
|
11
|
+
*/
|
|
12
|
+
import type { Agent } from '@compilr-dev/agents';
|
|
13
|
+
import { type PermissionResult, type PermissionOverlayV2Options } from './ui/overlay/impl/permission-overlay-v2.js';
|
|
14
|
+
import { type AskUserSimpleOptionsV2, type AskUserSimpleResultV2 } from './ui/overlay/impl/ask-user-simple-overlay-v2.js';
|
|
15
|
+
import { type GuardrailConfirmOptionsV2, type GuardrailConfirmResultV2 } from './ui/overlay/impl/guardrail-overlay-v2.js';
|
|
16
|
+
import { type AskUserOptionsV2, type AskUserResultV2 } from './ui/overlay/impl/ask-user-overlay-v2.js';
|
|
17
|
+
import { type IterationLimitOptionsV2, type IterationLimitResultV2 } from './ui/overlay/impl/iteration-limit-overlay-v2.js';
|
|
18
|
+
export interface ReplV2Options {
|
|
19
|
+
/** Agent instance (optional - uses simulation if not provided) */
|
|
20
|
+
agent?: Agent;
|
|
21
|
+
/** Current model ID */
|
|
22
|
+
model?: string;
|
|
23
|
+
/** Current provider */
|
|
24
|
+
provider?: string;
|
|
25
|
+
/** CLI version */
|
|
26
|
+
version?: string;
|
|
27
|
+
/** Initial project name */
|
|
28
|
+
projectName?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Callback invoked when TerminalUI is ready.
|
|
31
|
+
* Allows index.ts to set up permission overlay callback.
|
|
32
|
+
*/
|
|
33
|
+
onUIReady?: (showPermissionOverlay: (options: PermissionOverlayV2Options) => Promise<PermissionResult | null>) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Callback invoked when text buffer flush function is ready.
|
|
36
|
+
* Allows index.ts to flush accumulated agent text before showing overlays.
|
|
37
|
+
*/
|
|
38
|
+
onTextBufferReady?: (flushTextBuffer: () => void) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Callback invoked when ask_user_simple overlay is ready.
|
|
41
|
+
* Allows index.ts to use V2 overlay for agent questions.
|
|
42
|
+
*/
|
|
43
|
+
onAskUserSimpleReady?: (showOverlay: (options: AskUserSimpleOptionsV2) => Promise<AskUserSimpleResultV2>) => void;
|
|
44
|
+
/**
|
|
45
|
+
* Callback invoked when guardrail overlay is ready.
|
|
46
|
+
* Allows index.ts to use V2 overlay for guardrail confirmations.
|
|
47
|
+
*/
|
|
48
|
+
onGuardrailReady?: (showOverlay: (options: GuardrailConfirmOptionsV2) => Promise<GuardrailConfirmResultV2>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Callback invoked when ask_user overlay is ready.
|
|
51
|
+
* Allows index.ts to use V2 overlay for multi-question forms.
|
|
52
|
+
*/
|
|
53
|
+
onAskUserReady?: (showOverlay: (options: AskUserOptionsV2) => Promise<AskUserResultV2>) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Callback invoked when iteration_limit overlay is ready.
|
|
56
|
+
* Allows index.ts to use V2 overlay for iteration limit prompts.
|
|
57
|
+
*/
|
|
58
|
+
onIterationLimitReady?: (showOverlay: (options: IterationLimitOptionsV2) => Promise<IterationLimitResultV2>) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Callback invoked when agent finishes processing.
|
|
61
|
+
* Allows index.ts to apply deferred actions like suggestions.
|
|
62
|
+
*/
|
|
63
|
+
onAgentFinish?: () => void;
|
|
64
|
+
/**
|
|
65
|
+
* Callback invoked when suggestion setter is ready.
|
|
66
|
+
* Allows index.ts to set suggestions on the V2 UI.
|
|
67
|
+
*/
|
|
68
|
+
onSuggestionReady?: (setSuggestion: (action: string | null) => void) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Callback invoked when subagent tracking is ready.
|
|
71
|
+
* Allows index.ts to forward subagent events to LiveRegion for live rendering.
|
|
72
|
+
* Now uses toolUseId for direct correlation (no more FIFO queue matching).
|
|
73
|
+
*/
|
|
74
|
+
onSubagentReady?: (callbacks: {
|
|
75
|
+
onStart: (toolUseId: string, agentType: string, description: string) => void;
|
|
76
|
+
onToolUse: (toolUseId: string, toolName: string, summary?: string) => void;
|
|
77
|
+
onEnd: (toolUseId: string, success: boolean, tokenCount: number, error?: string) => void;
|
|
78
|
+
}) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Function to clear subagent tracking state in agent.ts between runs.
|
|
81
|
+
* Called at the start of each agent run to prevent stale data.
|
|
82
|
+
*/
|
|
83
|
+
clearSubagentTracking?: () => void;
|
|
84
|
+
}
|
|
85
|
+
export declare class ReplV2 {
|
|
86
|
+
private readonly agent?;
|
|
87
|
+
private readonly model;
|
|
88
|
+
private readonly provider;
|
|
89
|
+
private readonly version;
|
|
90
|
+
private readonly projectName;
|
|
91
|
+
private currentSession;
|
|
92
|
+
private ui;
|
|
93
|
+
private readonly onUIReady?;
|
|
94
|
+
private readonly onTextBufferReady?;
|
|
95
|
+
private readonly onAskUserSimpleReady?;
|
|
96
|
+
private readonly onGuardrailReady?;
|
|
97
|
+
private readonly onAskUserReady?;
|
|
98
|
+
private readonly onIterationLimitReady?;
|
|
99
|
+
private readonly onAgentFinish?;
|
|
100
|
+
private readonly onSuggestionReady?;
|
|
101
|
+
private readonly onSubagentReady?;
|
|
102
|
+
private readonly clearSubagentTracking?;
|
|
103
|
+
private readonly startTime;
|
|
104
|
+
private sessionInputTokens;
|
|
105
|
+
private sessionOutputTokens;
|
|
106
|
+
private sessionRequests;
|
|
107
|
+
private textAccumulator;
|
|
108
|
+
constructor(options?: ReplV2Options);
|
|
109
|
+
/**
|
|
110
|
+
* Flush accumulated agent text to the UI.
|
|
111
|
+
* Called externally (e.g., before showing permission overlay) to ensure
|
|
112
|
+
* agent's "I'll do X" message appears before the overlay.
|
|
113
|
+
*/
|
|
114
|
+
private flushTextBuffer;
|
|
115
|
+
/**
|
|
116
|
+
* Start the REPL.
|
|
117
|
+
*/
|
|
118
|
+
start(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Stop the REPL.
|
|
121
|
+
*/
|
|
122
|
+
stop(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Print just the logo to the scrolling area.
|
|
125
|
+
* Used for dashboard mode where hints are not needed.
|
|
126
|
+
*/
|
|
127
|
+
private printLogo;
|
|
128
|
+
/**
|
|
129
|
+
* Print full welcome message for REPL mode.
|
|
130
|
+
*/
|
|
131
|
+
private printWelcome;
|
|
132
|
+
private createCommandContext;
|
|
133
|
+
private handleCommand;
|
|
134
|
+
/**
|
|
135
|
+
* Process queued agent messages.
|
|
136
|
+
* Commands can queue messages to invoke the agent programmatically.
|
|
137
|
+
*/
|
|
138
|
+
private processAgentMessageQueue;
|
|
139
|
+
private processInput;
|
|
140
|
+
/**
|
|
141
|
+
* Handle memory note input ("# note") - V2 compatible version
|
|
142
|
+
*/
|
|
143
|
+
private handleMemoryInputV2;
|
|
144
|
+
private processQueue;
|
|
145
|
+
private runAgentReal;
|
|
146
|
+
private formatToolParams;
|
|
147
|
+
/**
|
|
148
|
+
* Extract content and summary from tool result.
|
|
149
|
+
* Delegates to tool-formatters module.
|
|
150
|
+
*/
|
|
151
|
+
private extractToolResult;
|
|
152
|
+
private runAgentSimulation;
|
|
153
|
+
private sleep;
|
|
154
|
+
private cancelSession;
|
|
155
|
+
}
|