@compilr-dev/cli 0.7.4 → 0.7.6

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.
Files changed (43) hide show
  1. package/dist/agent.d.ts +7 -2
  2. package/dist/agent.js +55 -39
  3. package/dist/commands-v2/handlers/project.js +65 -2
  4. package/dist/commands-v2/handlers/settings.js +18 -26
  5. package/dist/compilr-diff-companion.vsix +0 -0
  6. package/dist/db/schema.d.ts +1 -1
  7. package/dist/episodes/index.d.ts +13 -13
  8. package/dist/episodes/index.js +13 -14
  9. package/dist/guide/cli-guide-entries.js +54 -2
  10. package/dist/handlers/delegation-handlers.js +228 -50
  11. package/dist/handlers/interactive-flow-handlers.d.ts +26 -0
  12. package/dist/handlers/interactive-flow-handlers.js +61 -0
  13. package/dist/handlers/propose-alternatives-handlers.d.ts +36 -0
  14. package/dist/handlers/propose-alternatives-handlers.js +65 -0
  15. package/dist/index.js +13 -2
  16. package/dist/repl-v2.d.ts +66 -0
  17. package/dist/repl-v2.js +382 -53
  18. package/dist/shared-handlers.d.ts +57 -5
  19. package/dist/shared-handlers.js +50 -0
  20. package/dist/tools/consult.d.ts +14 -0
  21. package/dist/tools/consult.js +73 -0
  22. package/dist/tools/delegate.d.ts +12 -6
  23. package/dist/tools/delegate.js +35 -19
  24. package/dist/tools/interactive-flow.d.ts +13 -0
  25. package/dist/tools/interactive-flow.js +19 -0
  26. package/dist/tools/platform-adapter.d.ts +14 -2
  27. package/dist/tools/platform-adapter.js +16 -4
  28. package/dist/tools/propose-alternatives.d.ts +13 -0
  29. package/dist/tools/propose-alternatives.js +19 -0
  30. package/dist/tools.d.ts +22 -98
  31. package/dist/tools.js +27 -382
  32. package/dist/ui/markdown-renderer.js +26 -7
  33. package/dist/ui/overlay/data/tutorials/projects/new-project.js +56 -20
  34. package/dist/ui/overlay/impl/interactive-flow-overlay-v2.d.ts +79 -0
  35. package/dist/ui/overlay/impl/interactive-flow-overlay-v2.js +580 -0
  36. package/dist/ui/overlay/impl/new-overlay-v2.d.ts +32 -0
  37. package/dist/ui/overlay/impl/new-overlay-v2.js +305 -66
  38. package/dist/ui/overlay/impl/propose-alternatives-overlay-v2.d.ts +53 -0
  39. package/dist/ui/overlay/impl/propose-alternatives-overlay-v2.js +326 -0
  40. package/dist/ui/overlay/index.d.ts +2 -0
  41. package/dist/ui/overlay/index.js +2 -0
  42. package/dist/ui/tool-formatters.js +61 -3
  43. package/package.json +2 -2
@@ -5,8 +5,8 @@
5
5
  * accessible from tools but are set up at the application level.
6
6
  * This avoids circular imports between index.ts and tool modules.
7
7
  */
8
- import type { AskUserHandler, AskUserSimpleHandler } from '@compilr-dev/sdk';
9
- export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, } from '@compilr-dev/sdk';
8
+ import type { AskUserHandler, AskUserSimpleHandler, ProposeAlternativesHandler, InteractiveFlowHandler } from '@compilr-dev/sdk';
9
+ export type { AskUserQuestion, AskUserInput, AskUserResult, AskUserHandler, AskUserSimpleInput, AskUserSimpleResult, AskUserSimpleHandler, ProposeAlternativesInput, ProposeAlternativesResult, ProposeAlternativesHandler, Alternative, InteractiveFlowInput, InteractiveFlowResult, InteractiveFlowHandler, Flow, FlowNode, QuestionNode, InfoNode, BranchNode, SummaryNode, AnswerValue, AbortReason, NodeId, } from '@compilr-dev/sdk';
10
10
  /**
11
11
  * Register the ask_user handler. Called during app initialization.
12
12
  */
@@ -23,6 +23,24 @@ export declare function registerAskUserSimpleHandler(handler: AskUserSimpleHandl
23
23
  * Get the registered ask_user_simple handler. Called by the ask_user_simple tool.
24
24
  */
25
25
  export declare function getAskUserSimpleHandler(): AskUserSimpleHandler | undefined;
26
+ /**
27
+ * Register the propose_alternatives handler. Called during app initialization.
28
+ */
29
+ export declare function registerProposeAlternativesHandler(handler: ProposeAlternativesHandler): void;
30
+ /**
31
+ * Get the registered propose_alternatives handler. Called by the
32
+ * propose_alternatives tool.
33
+ */
34
+ export declare function getProposeAlternativesHandler(): ProposeAlternativesHandler | undefined;
35
+ /**
36
+ * Register the build_interactive_flow handler. Called during app initialization.
37
+ */
38
+ export declare function registerInteractiveFlowHandler(handler: InteractiveFlowHandler): void;
39
+ /**
40
+ * Get the registered build_interactive_flow handler. Called by the
41
+ * build_interactive_flow tool.
42
+ */
43
+ export declare function getInteractiveFlowHandler(): InteractiveFlowHandler | undefined;
26
44
  /**
27
45
  * Set overlay active state. Called when showing/hiding overlays.
28
46
  */
@@ -40,11 +58,20 @@ export interface DelegateInput {
40
58
  reason?: string;
41
59
  }
42
60
  export interface DelegateResult {
43
- /** True if delegation was approved and switch occurred */
61
+ /** True if delegation completed (approval granted + specialist ran) */
44
62
  success: boolean;
45
- /** True if user declined the delegation */
63
+ /** True if user declined the delegation via the approval overlay */
46
64
  declined: boolean;
47
- /** Error message if delegation failed */
65
+ /**
66
+ * Specialist's final response text. Populated when success=true. The
67
+ * coordinator's `delegate` tool surfaces this back to its LLM as the
68
+ * tool result body. See:
69
+ * project-docs/00-requirements/compilr-dev-sdk/multi-agent-tools-taxonomy-spec.md
70
+ */
71
+ response?: string;
72
+ /** Echo of the target agent id (helpful for the coordinator's LLM). */
73
+ agentId?: string;
74
+ /** Error message if delegation failed at the platform layer. */
48
75
  error?: string;
49
76
  }
50
77
  export type DelegateHandler = (input: DelegateInput) => Promise<DelegateResult>;
@@ -93,3 +120,28 @@ export declare function registerHandoffHandler(handler: HandoffHandler): void;
93
120
  * Get the registered handoff handler. Called by the handoff tool.
94
121
  */
95
122
  export declare function getHandoffHandler(): HandoffHandler | undefined;
123
+ export interface ConsultInput {
124
+ /** Target specialist agent ID */
125
+ agentId: string;
126
+ /** The focused question to ask */
127
+ question: string;
128
+ /** Optional supporting material the target needs to answer well */
129
+ context?: string;
130
+ }
131
+ export interface ConsultResult {
132
+ /** Final response text from the target agent. */
133
+ answer: string;
134
+ /** Echo of target agent ID (helpful for the borrower's LLM). */
135
+ agentId: string;
136
+ /** Error message if consult failed at the platform layer. */
137
+ error?: string;
138
+ }
139
+ export type ConsultHandler = (input: ConsultInput) => Promise<ConsultResult>;
140
+ /**
141
+ * Register the consult handler. Called during app initialization.
142
+ */
143
+ export declare function registerConsultHandler(handler: ConsultHandler): void;
144
+ /**
145
+ * Get the registered consult handler. Called by the consult tool.
146
+ */
147
+ export declare function getConsultHandler(): ConsultHandler | undefined;
@@ -35,6 +35,40 @@ export function getAskUserSimpleHandler() {
35
35
  return askUserSimpleHandler;
36
36
  }
37
37
  // =============================================================================
38
+ // Propose Alternatives Handler Registry
39
+ // =============================================================================
40
+ let proposeAlternativesHandler;
41
+ /**
42
+ * Register the propose_alternatives handler. Called during app initialization.
43
+ */
44
+ export function registerProposeAlternativesHandler(handler) {
45
+ proposeAlternativesHandler = handler;
46
+ }
47
+ /**
48
+ * Get the registered propose_alternatives handler. Called by the
49
+ * propose_alternatives tool.
50
+ */
51
+ export function getProposeAlternativesHandler() {
52
+ return proposeAlternativesHandler;
53
+ }
54
+ // =============================================================================
55
+ // Interactive Flow Handler Registry
56
+ // =============================================================================
57
+ let interactiveFlowHandler;
58
+ /**
59
+ * Register the build_interactive_flow handler. Called during app initialization.
60
+ */
61
+ export function registerInteractiveFlowHandler(handler) {
62
+ interactiveFlowHandler = handler;
63
+ }
64
+ /**
65
+ * Get the registered build_interactive_flow handler. Called by the
66
+ * build_interactive_flow tool.
67
+ */
68
+ export function getInteractiveFlowHandler() {
69
+ return interactiveFlowHandler;
70
+ }
71
+ // =============================================================================
38
72
  // Overlay State (for buffering output during overlays)
39
73
  // =============================================================================
40
74
  /**
@@ -103,3 +137,19 @@ export function registerHandoffHandler(handler) {
103
137
  export function getHandoffHandler() {
104
138
  return handoffHandler;
105
139
  }
140
+ // =============================================================================
141
+ // Consult Handler Registry
142
+ // =============================================================================
143
+ let consultHandler;
144
+ /**
145
+ * Register the consult handler. Called during app initialization.
146
+ */
147
+ export function registerConsultHandler(handler) {
148
+ consultHandler = handler;
149
+ }
150
+ /**
151
+ * Get the registered consult handler. Called by the consult tool.
152
+ */
153
+ export function getConsultHandler() {
154
+ return consultHandler;
155
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Consult Tool — Specialist-to-Specialist Sync Borrow
3
+ *
4
+ * The CLI surfaces the SDK's `consult` semantic via a thin wrapper around
5
+ * the registered consult handler (same pattern as handoff). The actual
6
+ * sub-run of the target agent lives in `handlers/delegation-handlers.ts`.
7
+ *
8
+ * Spec: project-docs/00-requirements/compilr-dev-sdk/consult-tool-spec.md
9
+ */
10
+ export declare const consultTool: import("@compilr-dev/sdk").Tool<{
11
+ agentId: string;
12
+ question: string;
13
+ context?: string;
14
+ }>;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Consult Tool — Specialist-to-Specialist Sync Borrow
3
+ *
4
+ * The CLI surfaces the SDK's `consult` semantic via a thin wrapper around
5
+ * the registered consult handler (same pattern as handoff). The actual
6
+ * sub-run of the target agent lives in `handlers/delegation-handlers.ts`.
7
+ *
8
+ * Spec: project-docs/00-requirements/compilr-dev-sdk/consult-tool-spec.md
9
+ */
10
+ import { defineTool } from '@compilr-dev/sdk';
11
+ import { getConsultHandler } from '../shared-handlers.js';
12
+ export const consultTool = defineTool({
13
+ name: 'consult',
14
+ description: 'Ask another specialist a focused question and continue the conversation yourself. ' +
15
+ 'Use this when you need a quick opinion or expertise input from a teammate without giving up the conversation. ' +
16
+ 'Unlike handoff, you keep ownership — the target answers and control returns to you. ' +
17
+ 'Example: $arch can consult $pm on scope, get an answer, and continue designing.',
18
+ inputSchema: {
19
+ type: 'object',
20
+ properties: {
21
+ agentId: {
22
+ type: 'string',
23
+ description: 'Target specialist agent ID to consult (e.g., "pm", "qa", "dev"). ' +
24
+ 'Cannot be yourself or "default" (use handoff to escalate to the coordinator).',
25
+ },
26
+ question: {
27
+ type: 'string',
28
+ description: 'The focused question you want answered — be specific.',
29
+ },
30
+ context: {
31
+ type: 'string',
32
+ description: 'Optional supporting material the target needs to answer well ' +
33
+ '(code snippet, design constraint, current state, etc.).',
34
+ },
35
+ },
36
+ required: ['agentId', 'question'],
37
+ },
38
+ execute: async (input) => {
39
+ if (!input.agentId || input.agentId.trim().length === 0) {
40
+ return { success: false, error: 'agentId is required' };
41
+ }
42
+ if (!input.question || input.question.trim().length === 0) {
43
+ return { success: false, error: 'question is required and cannot be empty' };
44
+ }
45
+ const handler = getConsultHandler();
46
+ if (!handler) {
47
+ return {
48
+ success: false,
49
+ error: 'Consult handler not initialized. This tool requires multi-agent mode with a team.',
50
+ };
51
+ }
52
+ try {
53
+ const result = await handler({
54
+ agentId: input.agentId.trim(),
55
+ question: input.question.trim(),
56
+ context: input.context?.trim() || undefined,
57
+ });
58
+ if (result.error) {
59
+ return { success: false, error: result.error };
60
+ }
61
+ return {
62
+ success: true,
63
+ result: { answer: result.answer, agentId: result.agentId },
64
+ };
65
+ }
66
+ catch (err) {
67
+ return {
68
+ success: false,
69
+ error: `Consult failed: ${err instanceof Error ? err.message : String(err)}`,
70
+ };
71
+ }
72
+ },
73
+ });
@@ -1,14 +1,20 @@
1
1
  /**
2
- * Delegate Tool - Multi-Agent Task Delegation
2
+ * Delegate Tool - Multi-Agent Task Delegation (sync, persistent)
3
3
  *
4
4
  * Allows the coordinator to delegate tasks to specialist agents.
5
5
  * Only available to the coordinator (default agent).
6
6
  *
7
- * Flow:
8
- * 1. Coordinator calls delegate(agentId, task, reason?)
9
- * 2. CLI shows approval prompt
10
- * 3. If approved: auto-switch to specialist, inject task
11
- * 4. If denied: return "User declined" to coordinator
7
+ * Behavior (per multi-agent-tools-taxonomy-spec.md §2):
8
+ * 1. Coordinator calls delegate(agentId, task, reason?)
9
+ * 2. CLI shows approval prompt
10
+ * 3. If approved: specialist runs the task INLINE in their persistent
11
+ * context; response is captured and returned to the coordinator
12
+ * 4. Coordinator stays in charge of the conversation — no permanent
13
+ * speaker switch
14
+ * 5. If declined: return "User declined" to coordinator (continues working)
15
+ *
16
+ * For sync-without-persistence use `consult`. For async + tracking use
17
+ * `delegate_background`. For permanent baton-pass use `handoff`.
12
18
  */
13
19
  interface DelegateInput {
14
20
  /** Target agent ID (e.g., 'arch', 'dev', 'qa') */
@@ -1,14 +1,20 @@
1
1
  /**
2
- * Delegate Tool - Multi-Agent Task Delegation
2
+ * Delegate Tool - Multi-Agent Task Delegation (sync, persistent)
3
3
  *
4
4
  * Allows the coordinator to delegate tasks to specialist agents.
5
5
  * Only available to the coordinator (default agent).
6
6
  *
7
- * Flow:
8
- * 1. Coordinator calls delegate(agentId, task, reason?)
9
- * 2. CLI shows approval prompt
10
- * 3. If approved: auto-switch to specialist, inject task
11
- * 4. If denied: return "User declined" to coordinator
7
+ * Behavior (per multi-agent-tools-taxonomy-spec.md §2):
8
+ * 1. Coordinator calls delegate(agentId, task, reason?)
9
+ * 2. CLI shows approval prompt
10
+ * 3. If approved: specialist runs the task INLINE in their persistent
11
+ * context; response is captured and returned to the coordinator
12
+ * 4. Coordinator stays in charge of the conversation — no permanent
13
+ * speaker switch
14
+ * 5. If declined: return "User declined" to coordinator (continues working)
15
+ *
16
+ * For sync-without-persistence use `consult`. For async + tracking use
17
+ * `delegate_background`. For permanent baton-pass use `handoff`.
12
18
  */
13
19
  import { defineTool } from '@compilr-dev/sdk';
14
20
  import { getDelegateHandler } from '../shared-handlers.js';
@@ -17,10 +23,12 @@ import { getDelegateHandler } from '../shared-handlers.js';
17
23
  // =============================================================================
18
24
  export const delegateTool = defineTool({
19
25
  name: 'delegate',
20
- description: 'Hand off the conversation to a specialist (foreground switch). ' +
21
- 'You stop working and the specialist takes over. No status tracking. ' +
22
- 'Use delegate_background instead if you want to continue working while ' +
23
- 'the specialist runs in the background (with delegation tracking). ' +
26
+ description: 'Delegate a task to a specialist and get their response back. ' +
27
+ 'The specialist runs the task in their persistent context (they remember the work). ' +
28
+ "You stay in charge control returns to you with the specialist's response. " +
29
+ 'Use consult if you just want a quick answer without persistence. ' +
30
+ 'Use delegate_background if you want the specialist to work in parallel while you continue. ' +
31
+ 'Use handoff to permanently pass the baton (you stop working). ' +
24
32
  'Only available to the coordinator.',
25
33
  inputSchema: {
26
34
  type: 'object',
@@ -64,7 +72,8 @@ export const delegateTool = defineTool({
64
72
  'This tool requires multi-agent mode with coordinator role.',
65
73
  };
66
74
  }
67
- // Execute delegation (shows approval prompt, switches if approved)
75
+ // Execute delegation: show approval prompt, run specialist inline,
76
+ // capture response.
68
77
  const result = await delegateHandler({
69
78
  agentId: input.agentId.trim(),
70
79
  task: input.task.trim(),
@@ -76,16 +85,23 @@ export const delegateTool = defineTool({
76
85
  error: result.error,
77
86
  };
78
87
  }
88
+ // User declined the approval prompt
89
+ if (result.declined) {
90
+ const output = {
91
+ delegated: false,
92
+ agent: input.agentId,
93
+ message: 'User declined the delegation. Continue handling the task yourself.',
94
+ };
95
+ return { success: true, result: output };
96
+ }
97
+ // Approved and specialist ran — surface the response so the coordinator's
98
+ // LLM sees it as the tool result body.
79
99
  const output = {
80
- delegated: result.success,
81
- message: result.declined
82
- ? 'User declined the delegation. Continue handling the task yourself.'
83
- : `Task delegated to $${input.agentId}. They will handle it from here.`,
84
- };
85
- return {
86
- success: true,
87
- result: output,
100
+ delegated: true,
101
+ agent: result.agentId ?? input.agentId,
102
+ response: result.response,
88
103
  };
104
+ return { success: true, result: output };
89
105
  }
90
106
  catch (err) {
91
107
  return {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Interactive Flow Tool — CLI wrapper around SDK factory.
3
+ *
4
+ * Uses getInteractiveFlowHandler() from shared-handlers.ts which
5
+ * coordinates with the terminal footer (pause/resume), routes background
6
+ * agent calls through the pending-requests manager, and shows the
7
+ * InteractiveFlowOverlayV2 for foreground calls.
8
+ *
9
+ * Spec: project-docs/00-requirements/compilr-dev-cli/interactive-flow-cli-spec.md
10
+ */
11
+ import { type InteractiveFlowInput } from '@compilr-dev/sdk';
12
+ export type { Flow, FlowNode, QuestionNode, InfoNode, BranchNode, SummaryNode, } from '@compilr-dev/sdk';
13
+ export declare const interactiveFlowTool: import("@compilr-dev/sdk").Tool<InteractiveFlowInput>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Interactive Flow Tool — CLI wrapper around SDK factory.
3
+ *
4
+ * Uses getInteractiveFlowHandler() from shared-handlers.ts which
5
+ * coordinates with the terminal footer (pause/resume), routes background
6
+ * agent calls through the pending-requests manager, and shows the
7
+ * InteractiveFlowOverlayV2 for foreground calls.
8
+ *
9
+ * Spec: project-docs/00-requirements/compilr-dev-cli/interactive-flow-cli-spec.md
10
+ */
11
+ import { createInteractiveFlowTool, } from '@compilr-dev/sdk';
12
+ import { getInteractiveFlowHandler } from '../shared-handlers.js';
13
+ export const interactiveFlowTool = createInteractiveFlowTool(async (input) => {
14
+ const handler = getInteractiveFlowHandler();
15
+ if (!handler) {
16
+ throw new Error('build_interactive_flow handler not initialized. This tool requires the CLI context.');
17
+ }
18
+ return handler(input);
19
+ });
@@ -18,8 +18,20 @@
18
18
  */
19
19
  export declare const allPlatformTools: import("@compilr-dev/sdk").Tool<never>[];
20
20
  /**
21
- * All 5 factory tools from @compilr-dev/factory:
22
- * - 3 model tools (app_model_get, app_model_update, app_model_validate)
21
+ * All 29 factory tools from @compilr-dev/factory (createAllFactoryTools):
22
+ * - 3 app model tools (app_model_get/update/validate)
23
+ * - 5 research model tools + research_scaffold
24
+ * - 4 business model tools + business_scaffold
25
+ * - 5 brand model tools + content_scaffold
26
+ * - 3 curriculum model tools
27
+ * - 3 book model tools + book_scaffold
23
28
  * - 2 factory tools (factory_scaffold, factory_list_toolkits)
29
+ *
30
+ * Pre-2026-06-04 the CLI imported the narrower `createFactoryTools` which
31
+ * only returned 5 tools (app model + factory infra). 24 non-software model
32
+ * + scaffold tools were silently missing — agents in research/business/
33
+ * brand/curriculum/book projects saw the tools advertised by capability
34
+ * pack `factory_models` and `factory_scaffold` but got "Tool not found"
35
+ * on call. Audit TODO-5 fix.
24
36
  */
25
37
  export declare const allFactoryTools: import('@compilr-dev/agents').Tool<never>[];
@@ -6,7 +6,7 @@
6
6
  * and delegates all 32 platform tool definitions to the SDK.
7
7
  */
8
8
  import { createPlatformTools, createSQLiteRepositories, ProjectAnchorStore, } from '@compilr-dev/sdk';
9
- import { createFactoryTools } from '@compilr-dev/factory';
9
+ import { createAllFactoryTools } from '@compilr-dev/factory';
10
10
  import { getDb } from '../db/index.js';
11
11
  import { getDataPath, getSessionsPath } from '../settings/paths.js';
12
12
  import { getPermissionMode } from '../settings/index.js';
@@ -280,11 +280,23 @@ export const allPlatformTools = createPlatformTools(config, {
280
280
  },
281
281
  });
282
282
  /**
283
- * All 5 factory tools from @compilr-dev/factory:
284
- * - 3 model tools (app_model_get, app_model_update, app_model_validate)
283
+ * All 29 factory tools from @compilr-dev/factory (createAllFactoryTools):
284
+ * - 3 app model tools (app_model_get/update/validate)
285
+ * - 5 research model tools + research_scaffold
286
+ * - 4 business model tools + business_scaffold
287
+ * - 5 brand model tools + content_scaffold
288
+ * - 3 curriculum model tools
289
+ * - 3 book model tools + book_scaffold
285
290
  * - 2 factory tools (factory_scaffold, factory_list_toolkits)
291
+ *
292
+ * Pre-2026-06-04 the CLI imported the narrower `createFactoryTools` which
293
+ * only returned 5 tools (app model + factory infra). 24 non-software model
294
+ * + scaffold tools were silently missing — agents in research/business/
295
+ * brand/curriculum/book projects saw the tools advertised by capability
296
+ * pack `factory_models` and `factory_scaffold` but got "Tool not found"
297
+ * on call. Audit TODO-5 fix.
286
298
  */
287
- export const allFactoryTools = createFactoryTools({
299
+ export const allFactoryTools = createAllFactoryTools({
288
300
  context,
289
301
  cwd: process.cwd(),
290
302
  });
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Propose Alternatives Tool — CLI wrapper around SDK factory.
3
+ *
4
+ * Uses getProposeAlternativesHandler() from shared-handlers.ts which
5
+ * coordinates with the terminal footer (pause/resume), routes background
6
+ * agent calls through the pending-requests manager, and shows the
7
+ * ProposeAlternativesOverlayV2 for foreground calls.
8
+ *
9
+ * Spec: project-docs/00-requirements/compilr-dev-cli/propose-alternatives-spec.md
10
+ */
11
+ import { type ProposeAlternativesInput } from '@compilr-dev/sdk';
12
+ export type { Alternative } from '@compilr-dev/sdk';
13
+ export declare const proposeAlternativesTool: import("@compilr-dev/sdk").Tool<ProposeAlternativesInput>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Propose Alternatives Tool — CLI wrapper around SDK factory.
3
+ *
4
+ * Uses getProposeAlternativesHandler() from shared-handlers.ts which
5
+ * coordinates with the terminal footer (pause/resume), routes background
6
+ * agent calls through the pending-requests manager, and shows the
7
+ * ProposeAlternativesOverlayV2 for foreground calls.
8
+ *
9
+ * Spec: project-docs/00-requirements/compilr-dev-cli/propose-alternatives-spec.md
10
+ */
11
+ import { createProposeAlternativesTool, } from '@compilr-dev/sdk';
12
+ import { getProposeAlternativesHandler } from '../shared-handlers.js';
13
+ export const proposeAlternativesTool = createProposeAlternativesTool(async (input) => {
14
+ const handler = getProposeAlternativesHandler();
15
+ if (!handler) {
16
+ throw new Error('propose_alternatives handler not initialized. This tool requires the CLI context.');
17
+ }
18
+ return handler(input);
19
+ });
package/dist/tools.d.ts CHANGED
@@ -1,105 +1,29 @@
1
1
  /**
2
- * Tool Registry Setup
2
+ * Tool Registry Helpers (slim).
3
3
  *
4
- * Configures all available tools from @compilr-dev/sdk
5
- * (which re-exports from @compilr-dev/agents and @compilr-dev/agents-coding).
4
+ * Pre-SDK migration this file owned the full HOT_TOOLS / WARM_TOOLS /
5
+ * DIRECT_TOOLS / META_REGISTRY_TOOLS arrays and a token-saving registry
6
+ * (~15K → ~2K per turn). That optimisation moved to the SDK as the
7
+ * capability-manager direct/meta tier split (`TOOL_GROUPS.<id>.tier`),
8
+ * and `createCompilrAgent({ capabilities: ... })` now handles tool
9
+ * registration end-to-end. See `src/agent.ts` and
10
+ * `@compilr-dev/sdk/src/capabilities/packs.ts`.
6
11
  *
7
- * ARCHITECTURE (Meta-Tools):
8
- * - DIRECT TOOLS: Always available, called by name (most common operations)
9
- * - META-REGISTRY TOOLS: Available via use_tool() (specialized operations)
12
+ * What remains here is the small surface CLI code outside agent.ts still
13
+ * touches:
14
+ * - `todoStore` alias for the SDK's `getDefaultTodoStore()` singleton,
15
+ * read by the footer renderer (see `repl-v2.ts`).
16
+ * - `TOOL_NAMES` / `ToolName` / `getAllToolNames` — re-exported from
17
+ * `./tool-names.js` for convenience.
10
18
  *
11
- * This reduces token overhead from ~15K to ~2K per request.
19
+ * Audit refs: TODO-4 (HOT/WARM cleanup), TODO-15 (deleted the parallel
20
+ * dead MetaToolsRegistry singleton + its setMetaToolFilter /
21
+ * getRegisteredMetaTools / isMetaToolSilent surface — the SDK's
22
+ * per-agent CapabilityManager already handles tool filtering at agent
23
+ * factory time, so the CLI re-exports here were always no-ops).
12
24
  *
13
- * SINGLE SOURCE OF TRUTH:
14
- * Tool names are defined in tool-names.ts (a dependency-free module).
15
- * This file re-exports them for convenience. Import from here or tool-names.ts.
25
+ * See `project-docs/00-requirements/compilr-dev-sdk/architecture-audit-cli-vs-desktop.md`.
16
26
  */
17
- export { TOOL_NAMES, type ToolName, DIRECT_TOOL_NAMES, HOT_TOOL_NAMES, WARM_TOOL_NAMES, META_TOOL_NAMES, META_REGISTRY_TOOL_NAMES, getAllToolNames, } from './tool-names.js';
18
- import { TodoStore, type Tool } from '@compilr-dev/sdk';
27
+ import { TodoStore } from '@compilr-dev/sdk';
28
+ export { TOOL_NAMES, type ToolName, getAllToolNames } from './tool-names.js';
19
29
  export declare const todoStore: TodoStore;
20
- import { setMetaToolFilter, getRegisteredMetaTools } from './tools/meta-tools.js';
21
- export { setMetaToolFilter, getRegisteredMetaTools };
22
- /**
23
- * Check if a tool in the meta-registry is marked as silent.
24
- * Used by the repl to suppress output for warm tools like todo_write/todo_read.
25
- */
26
- export declare function isMetaToolSilent(name: string): boolean;
27
- /**
28
- * Creates the tool registry with all available tools.
29
- * Returns tools as-is - the Agent.registerTools() method handles typing.
30
- *
31
- * @deprecated Use createDirectToolRegistry() + initializeMetaTools() instead
32
- */
33
- export declare function createToolRegistry(): unknown[];
34
- /**
35
- * Returns a minimal set of tools for basic testing.
36
- */
37
- export declare function createMinimalToolRegistry(): unknown[];
38
- /**
39
- * Get direct tools that are always available.
40
- * When hotOnly is true, returns only hot tools (7 tools, ~2.1K tokens).
41
- * When false/undefined, returns all direct tools (18 tools, ~5.4K tokens).
42
- */
43
- export declare function getDirectTools(hotOnly?: boolean): Tool[];
44
- /**
45
- * Get meta-tools for agent registration.
46
- * Only get_tool_info is kept as a direct tool — use_tool and list_tools
47
- * are no longer needed since the fallback handler routes calls transparently.
48
- */
49
- export declare function getMetaTools(): Tool[];
50
- /**
51
- * Create a fallback handler for the tool registry.
52
- * When the agent calls a tool not in the direct registry, this handler
53
- * checks the meta-registry and executes it transparently.
54
- *
55
- * Auto-loading of capability packs for filtered tools is handled by the
56
- * shared onFilteredTool callback in meta-tools.ts (covers both use_tool
57
- * and direct fallback paths).
58
- */
59
- export declare function createToolFallback(): (name: string, input: Record<string, unknown>) => Promise<import('@compilr-dev/sdk').ToolExecutionResult | null>;
60
- /**
61
- * Check if hot-tools mode is active.
62
- * When true, only hot tools are declared as direct schemas; warm tools are in meta-registry.
63
- */
64
- export declare function isHotToolsMode(): boolean;
65
- /**
66
- * Initialize the meta-tool registry with specialized tools.
67
- * When includeWarmTools is true, warm tools are also added to the meta-registry
68
- * (enabling hot-tools mode where only 7 core tools are declared directly).
69
- * Call this once at startup.
70
- */
71
- export declare function initializeMetaTools(includeWarmTools?: boolean): void;
72
- /**
73
- * Get the tool index for the system prompt.
74
- * This lists all meta-registry tools with their signatures.
75
- */
76
- export declare function getToolIndexForSystemPrompt(): string;
77
- /**
78
- * Get a filtered tool index for the system prompt.
79
- * Only includes tools whose names are in the given set.
80
- * Used by the capability-aware BeforeLLM hook.
81
- */
82
- export declare function getFilteredToolIndexForSystemPrompt(activeToolNames: string[]): string;
83
- /**
84
- * Get count of meta-registry tools.
85
- */
86
- export declare function getMetaToolsCount(): number;
87
- /**
88
- * Check if meta-tools mode is enabled.
89
- * Returns true if the meta-tool registry has been initialized.
90
- */
91
- export declare function isMetaToolsEnabled(): boolean;
92
- /**
93
- * Get tool statistics for debugging/display.
94
- */
95
- export declare function getToolStats(): {
96
- directTools: number;
97
- hotTools: number;
98
- warmTools: number;
99
- metaRegistryTools: number;
100
- totalTools: number;
101
- estimatedDirectTokens: number;
102
- estimatedMetaTokens: number;
103
- estimatedLegacyTokens: number;
104
- tokenSavings: number;
105
- };