@compilr-dev/cli 0.8.7 → 0.8.9

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 (40) hide show
  1. package/dist/agent.js +7 -3
  2. package/dist/commands-v2/handlers/settings.js +22 -3
  3. package/dist/commands-v2/types.d.ts +10 -0
  4. package/dist/compilr-diff-companion.vsix +0 -0
  5. package/dist/index.js +68 -1
  6. package/dist/models/model-registry.js +1 -0
  7. package/dist/models/providers.js +1 -0
  8. package/dist/repl-v2.d.ts +19 -1
  9. package/dist/repl-v2.js +37 -0
  10. package/dist/settings/index.d.ts +1 -1
  11. package/dist/ui/overlay/impl/model-overlay-v2.js +33 -20
  12. package/dist/ui/overlay-manager.js +10 -2
  13. package/dist/utils/credentials.d.ts +1 -1
  14. package/dist/utils/credentials.js +1 -0
  15. package/dist/utils/model-tiers.js +14 -9
  16. package/package.json +3 -3
  17. package/dist/episodes/recorder.d.ts +0 -51
  18. package/dist/episodes/recorder.js +0 -195
  19. package/dist/episodes/significant-work.d.ts +0 -21
  20. package/dist/episodes/significant-work.js +0 -56
  21. package/dist/episodes/store.d.ts +0 -38
  22. package/dist/episodes/store.js +0 -199
  23. package/dist/episodes/types.d.ts +0 -35
  24. package/dist/episodes/types.js +0 -6
  25. package/dist/episodes/work-at-risk.d.ts +0 -12
  26. package/dist/episodes/work-at-risk.js +0 -38
  27. package/dist/episodes/work-summary-anchor.d.ts +0 -23
  28. package/dist/episodes/work-summary-anchor.js +0 -73
  29. package/dist/tools/consult.d.ts +0 -14
  30. package/dist/tools/consult.js +0 -73
  31. package/dist/tools/delegate-background.d.ts +0 -27
  32. package/dist/tools/delegate-background.js +0 -115
  33. package/dist/tools/delegate.d.ts +0 -28
  34. package/dist/tools/delegate.js +0 -113
  35. package/dist/tools/handoff.d.ts +0 -17
  36. package/dist/tools/handoff.js +0 -79
  37. package/dist/tools/meta-tools.d.ts +0 -31
  38. package/dist/tools/meta-tools.js +0 -78
  39. package/dist/ui/overlay/impl/skill-editor-overlay.d.ts +0 -56
  40. package/dist/ui/overlay/impl/skill-editor-overlay.js +0 -493
@@ -1,73 +0,0 @@
1
- /**
2
- * Work Summary Anchor
3
- *
4
- * Manages an auto-generated anchor that summarizes work done in the current session.
5
- * Updated automatically after each episode batch is flushed.
6
- */
7
- const ANCHOR_TAG = 'episode-work-summary';
8
- /**
9
- * Build the anchor content string from the store's work summary.
10
- * Returns null when there are no episodes to summarize.
11
- */
12
- export function buildWorkSummaryContent(summary) {
13
- if (summary.episodeCount === 0)
14
- return null;
15
- const lines = ['[Session Work Summary]'];
16
- lines.push(`Episodes: ${String(summary.episodeCount)}, Effort: ${summary.totalEffort}, Time: ${formatMs(summary.timeSpentMs)}`);
17
- if (summary.agentBreakdown.length > 0) {
18
- const agents = summary.agentBreakdown
19
- .map(a => `${a.agentId}(${String(a.episodeCount)})`)
20
- .join(', ');
21
- lines.push(`Agents: ${agents}`);
22
- }
23
- if (summary.topFiles.length > 0) {
24
- const files = summary.topFiles.slice(0, 5)
25
- .map(f => f.path.split('/').pop() ?? f.path)
26
- .join(', ');
27
- lines.push(`Top files: ${files}`);
28
- }
29
- if (summary.uncommittedWork.length > 0) {
30
- lines.push(`Uncommitted: ${String(summary.uncommittedWork.length)} episode(s)`);
31
- }
32
- return lines.join('\n');
33
- }
34
- /**
35
- * Update the work summary anchor for a project.
36
- * Removes existing anchor (if any) and adds updated one.
37
- */
38
- export function updateWorkSummaryAnchor(config) {
39
- const { store, projectId, getAnchorManager: getManager } = config;
40
- const manager = getManager(projectId);
41
- const summary = store.getWorkSummary();
42
- const content = buildWorkSummaryContent(summary);
43
- // Remove existing work summary anchor
44
- const existing = manager.getAll().find((a) => a.tags?.includes(ANCHOR_TAG));
45
- if (existing)
46
- manager.remove(existing.id);
47
- // Add new anchor if there's content
48
- if (content) {
49
- manager.add({
50
- content,
51
- priority: 'info',
52
- scope: 'persistent',
53
- tags: [ANCHOR_TAG],
54
- projectId,
55
- });
56
- }
57
- }
58
- /**
59
- * Format milliseconds to a human-readable string (e.g., "2h 15m", "45s").
60
- */
61
- function formatMs(ms) {
62
- if (ms < 1000)
63
- return `${String(ms)}ms`;
64
- const totalSeconds = Math.floor(ms / 1000);
65
- if (totalSeconds < 60)
66
- return `${String(totalSeconds)}s`;
67
- const minutes = Math.floor(totalSeconds / 60);
68
- if (minutes < 60)
69
- return `${String(minutes)}m`;
70
- const hours = Math.floor(minutes / 60);
71
- const remainingMinutes = minutes % 60;
72
- return remainingMinutes > 0 ? `${String(hours)}h ${String(remainingMinutes)}m` : `${String(hours)}h`;
73
- }
@@ -1,14 +0,0 @@
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
- }>;
@@ -1,73 +0,0 @@
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,27 +0,0 @@
1
- /**
2
- * Delegate Background Tool - Coordinator Mode
3
- *
4
- * Allows the coordinator to delegate tasks to specialists running in background.
5
- * Unlike the foreground `delegate` tool (which switches the active agent),
6
- * this tool keeps the coordinator in the foreground while the specialist
7
- * works independently in the background.
8
- *
9
- * Flow:
10
- * 1. Coordinator calls delegate_background(agentId, task)
11
- * 2. DelegationTracker registers the delegation
12
- * 3. Specialist starts as background agent (or queued if busy)
13
- * 4. Coordinator continues working
14
- * 5. On completion, coordinator is notified via completion events (Phase 2)
15
- */
16
- interface DelegateBackgroundInput {
17
- /** Target specialist agent ID (e.g., 'arch', 'dev', 'qa') */
18
- agentId: string;
19
- /** Detailed task description for the specialist */
20
- task: string;
21
- /** Optional todo index to associate with this delegation */
22
- todoIndex?: number;
23
- /** What the specialist should produce (e.g., "architecture document") */
24
- expectedOutput?: string;
25
- }
26
- export declare const delegateBackgroundTool: import("@compilr-dev/sdk").Tool<DelegateBackgroundInput>;
27
- export {};
@@ -1,115 +0,0 @@
1
- /**
2
- * Delegate Background Tool - Coordinator Mode
3
- *
4
- * Allows the coordinator to delegate tasks to specialists running in background.
5
- * Unlike the foreground `delegate` tool (which switches the active agent),
6
- * this tool keeps the coordinator in the foreground while the specialist
7
- * works independently in the background.
8
- *
9
- * Flow:
10
- * 1. Coordinator calls delegate_background(agentId, task)
11
- * 2. DelegationTracker registers the delegation
12
- * 3. Specialist starts as background agent (or queued if busy)
13
- * 4. Coordinator continues working
14
- * 5. On completion, coordinator is notified via completion events (Phase 2)
15
- */
16
- import { defineTool } from '@compilr-dev/sdk';
17
- import { getDelegateBackgroundHandler } from '../shared-handlers.js';
18
- // =============================================================================
19
- // Tool Definition
20
- // =============================================================================
21
- export const delegateBackgroundTool = defineTool({
22
- name: 'delegate_background',
23
- description: 'Delegate a task to a specialist running in background. ' +
24
- 'The specialist executes independently while you continue working. ' +
25
- 'You will be notified when the specialist completes. ' +
26
- 'Use delegation_status to check progress. ' +
27
- 'Prefer this over delegate — it keeps you in control and tracks status. ' +
28
- 'Only available to the coordinator.',
29
- inputSchema: {
30
- type: 'object',
31
- properties: {
32
- agentId: {
33
- type: 'string',
34
- description: 'Target specialist agent ID (e.g., "arch", "dev", "qa")',
35
- },
36
- task: {
37
- type: 'string',
38
- description: 'Detailed task description for the specialist',
39
- },
40
- todoIndex: {
41
- type: 'number',
42
- description: 'Optional todo index to associate with this delegation',
43
- },
44
- expectedOutput: {
45
- type: 'string',
46
- description: 'What the specialist should produce (e.g., "architecture document", "implementation")',
47
- },
48
- },
49
- required: ['agentId', 'task'],
50
- },
51
- execute: async (input) => {
52
- try {
53
- // Validate input
54
- if (!input.agentId || input.agentId.trim().length === 0) {
55
- return {
56
- success: false,
57
- error: 'Agent ID is required',
58
- };
59
- }
60
- if (!input.task || input.task.trim().length === 0) {
61
- return {
62
- success: false,
63
- error: 'Task description is required',
64
- };
65
- }
66
- // Prevent self-delegation
67
- if (input.agentId.trim() === 'default') {
68
- return {
69
- success: false,
70
- error: 'Cannot delegate to yourself (the coordinator). Delegate to a specialist agent.',
71
- };
72
- }
73
- // Get the delegate background handler from shared-handlers
74
- const handler = getDelegateBackgroundHandler();
75
- if (!handler) {
76
- return {
77
- success: false,
78
- error: 'Delegate background handler not initialized. ' +
79
- 'This tool requires multi-agent mode with coordinator role.',
80
- };
81
- }
82
- // Execute background delegation
83
- const result = await handler({
84
- agentId: input.agentId.trim(),
85
- task: input.task.trim(),
86
- todoIndex: input.todoIndex,
87
- expectedOutput: input.expectedOutput?.trim(),
88
- });
89
- if (result.error) {
90
- return {
91
- success: false,
92
- error: result.error,
93
- };
94
- }
95
- const output = {
96
- delegated: true,
97
- delegationId: result.delegationId,
98
- status: result.status,
99
- message: result.status === 'queued'
100
- ? `Task queued for $${input.agentId} (currently busy). It will start when they're free.`
101
- : `Task delegated to $${input.agentId} running in background. You'll be notified on completion.`,
102
- };
103
- return {
104
- success: true,
105
- result: output,
106
- };
107
- }
108
- catch (err) {
109
- return {
110
- success: false,
111
- error: `Background delegation failed: ${err instanceof Error ? err.message : String(err)}`,
112
- };
113
- }
114
- },
115
- });
@@ -1,28 +0,0 @@
1
- /**
2
- * Delegate Tool - Multi-Agent Task Delegation (sync, persistent)
3
- *
4
- * Allows the coordinator to delegate tasks to specialist agents.
5
- * Only available to the coordinator (default agent).
6
- *
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`.
18
- */
19
- interface DelegateInput {
20
- /** Target agent ID (e.g., 'arch', 'dev', 'qa') */
21
- agentId: string;
22
- /** Task description for the specialist */
23
- task: string;
24
- /** Optional reason for delegation (shown to user for context) */
25
- reason?: string;
26
- }
27
- export declare const delegateTool: import("@compilr-dev/sdk").Tool<DelegateInput>;
28
- export {};
@@ -1,113 +0,0 @@
1
- /**
2
- * Delegate Tool - Multi-Agent Task Delegation (sync, persistent)
3
- *
4
- * Allows the coordinator to delegate tasks to specialist agents.
5
- * Only available to the coordinator (default agent).
6
- *
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`.
18
- */
19
- import { defineTool } from '@compilr-dev/sdk';
20
- import { getDelegateHandler } from '../shared-handlers.js';
21
- // =============================================================================
22
- // Tool Definition
23
- // =============================================================================
24
- export const delegateTool = defineTool({
25
- name: 'delegate',
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). ' +
32
- 'Only available to the coordinator.',
33
- inputSchema: {
34
- type: 'object',
35
- properties: {
36
- agentId: {
37
- type: 'string',
38
- description: 'Target agent ID (e.g., "arch", "dev", "qa")',
39
- },
40
- task: {
41
- type: 'string',
42
- description: 'Task description for the specialist - be specific and clear',
43
- },
44
- reason: {
45
- type: 'string',
46
- description: 'Why this specialist is suited for the task (shown to user)',
47
- },
48
- },
49
- required: ['agentId', 'task'],
50
- },
51
- execute: async (input) => {
52
- try {
53
- // Validate input
54
- if (!input.agentId || input.agentId.trim().length === 0) {
55
- return {
56
- success: false,
57
- error: 'Agent ID is required',
58
- };
59
- }
60
- if (!input.task || input.task.trim().length === 0) {
61
- return {
62
- success: false,
63
- error: 'Task description is required',
64
- };
65
- }
66
- // Get the delegate handler from shared-handlers
67
- const delegateHandler = getDelegateHandler();
68
- if (!delegateHandler) {
69
- return {
70
- success: false,
71
- error: 'Delegate handler not initialized. ' +
72
- 'This tool requires multi-agent mode with coordinator role.',
73
- };
74
- }
75
- // Execute delegation: show approval prompt, run specialist inline,
76
- // capture response.
77
- const result = await delegateHandler({
78
- agentId: input.agentId.trim(),
79
- task: input.task.trim(),
80
- reason: input.reason?.trim(),
81
- });
82
- if (result.error) {
83
- return {
84
- success: false,
85
- error: result.error,
86
- };
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.
99
- const output = {
100
- delegated: true,
101
- agent: result.agentId ?? input.agentId,
102
- response: result.response,
103
- };
104
- return { success: true, result: output };
105
- }
106
- catch (err) {
107
- return {
108
- success: false,
109
- error: `Delegation failed: ${err instanceof Error ? err.message : String(err)}`,
110
- };
111
- }
112
- },
113
- });
@@ -1,17 +0,0 @@
1
- /**
2
- * Handoff Tool - Multi-Agent Task Handoff
3
- *
4
- * Uses SDK's createHandoffTool factory with CLI-specific handler.
5
- * Exported as a static tool that lazily resolves dependencies.
6
- */
7
- /**
8
- * Handoff tool — delegates to the CLI's handoff handler.
9
- *
10
- * The handler (registered by delegation-handlers.ts) manages team validation,
11
- * one-hop enforcement, user approval, and agent switching.
12
- */
13
- export declare const handoffTool: import("@compilr-dev/sdk").Tool<{
14
- agentId: string;
15
- task: string;
16
- reason?: string;
17
- }>;
@@ -1,79 +0,0 @@
1
- /**
2
- * Handoff Tool - Multi-Agent Task Handoff
3
- *
4
- * Uses SDK's createHandoffTool factory with CLI-specific handler.
5
- * Exported as a static tool that lazily resolves dependencies.
6
- */
7
- import { defineTool } from '@compilr-dev/sdk';
8
- import { getHandoffHandler } from '../shared-handlers.js';
9
- /**
10
- * Handoff tool — delegates to the CLI's handoff handler.
11
- *
12
- * The handler (registered by delegation-handlers.ts) manages team validation,
13
- * one-hop enforcement, user approval, and agent switching.
14
- */
15
- export const handoffTool = defineTool({
16
- name: 'handoff',
17
- description: 'Hand off the current task to another team agent. ' +
18
- 'Use this when a task is outside your expertise or would benefit from another specialist. ' +
19
- 'The user will be asked to approve the handoff before switching. ' +
20
- 'Example: hand off architecture questions to $arch, implementation to $dev, testing to $qa.',
21
- inputSchema: {
22
- type: 'object',
23
- properties: {
24
- agentId: {
25
- type: 'string',
26
- description: 'Target agent ID (e.g., "arch", "dev", "qa", "default")',
27
- },
28
- task: {
29
- type: 'string',
30
- description: 'Task description for the target agent - be specific and clear',
31
- },
32
- reason: {
33
- type: 'string',
34
- description: 'Why this agent is better suited for the task (shown to user)',
35
- },
36
- },
37
- required: ['agentId', 'task'],
38
- },
39
- execute: async (input) => {
40
- if (!input.agentId || input.agentId.trim().length === 0) {
41
- return { success: false, error: 'Agent ID is required' };
42
- }
43
- if (!input.task || input.task.trim().length === 0) {
44
- return { success: false, error: 'Task description is required' };
45
- }
46
- const handoffHandler = getHandoffHandler();
47
- if (!handoffHandler) {
48
- return {
49
- success: false,
50
- error: 'Handoff handler not initialized. This tool requires multi-agent mode with a team.',
51
- };
52
- }
53
- try {
54
- const result = await handoffHandler({
55
- agentId: input.agentId.trim(),
56
- task: input.task.trim(),
57
- reason: input.reason?.trim(),
58
- });
59
- if (result.error) {
60
- return { success: false, error: result.error };
61
- }
62
- return {
63
- success: true,
64
- result: {
65
- handedOff: !result.declined,
66
- message: result.declined
67
- ? 'User declined the handoff. Continue handling the task yourself.'
68
- : `Task handed off to $${input.agentId}. They will handle it from here.`,
69
- },
70
- };
71
- }
72
- catch (err) {
73
- return {
74
- success: false,
75
- error: `Handoff failed: ${err instanceof Error ? err.message : String(err)}`,
76
- };
77
- }
78
- },
79
- });
@@ -1,31 +0,0 @@
1
- /**
2
- * Meta-Tools for Dynamic Tool Loading
3
- *
4
- * Thin singleton wrapper over @compilr-dev/sdk's MetaToolsRegistry.
5
- * Provides the same module-level API used by the CLI while delegating
6
- * all logic to the SDK's class-based implementation.
7
- *
8
- * Instead of declaring all 49 tools (~15K tokens), we declare:
9
- * 1. A small set of "direct" tools (always available)
10
- * 2. A get_tool_info meta-tool (always available)
11
- * 3. A tool index in the system prompt
12
- * 4. A transparent fallback handler that routes calls to the registry
13
- */
14
- import { type Tool, type ToolExecutionResult } from '@compilr-dev/sdk';
15
- export declare function setMetaToolFilter(filter: string[] | null | undefined): void;
16
- export declare function getMetaToolFilter(): Set<string> | null;
17
- export declare function initializeMetaToolRegistry(tools: Tool[]): void;
18
- export declare function getRegisteredMetaTools(): Tool[];
19
- export declare function getMetaToolCount(): number;
20
- export declare function generateToolIndex(): string;
21
- export declare const listToolsTool: Tool<object>;
22
- export declare const getToolInfoTool: Tool<object>;
23
- export declare const useToolTool: Tool<object>;
24
- export declare const metaTools: Tool<object>[];
25
- export declare function createMetaToolFallback(): (name: string, input: Record<string, unknown>) => Promise<ToolExecutionResult | null>;
26
- /**
27
- * Generate a filtered tool index showing only tools in the given set.
28
- * Sets the registry filter, generates the index, then restores the previous filter.
29
- */
30
- export declare function generateFilteredToolIndex(activeToolNames: string[]): string;
31
- export declare const META_TOOLS_SYSTEM_PROMPT_PREFIX = "\n## Tool Index (Specialized Tools)\n\nThese tools are called **exactly like direct tools** \u2014 just use the tool name with parameters. No special syntax or wrapper needed. The system routes them automatically.\n\n**IMPORTANT \u2014 These are CLI system tools, NOT your project's backend. Never use localhost/curl to access them.**\n\n**Parameter Rules:**\n- For **zero-parameter calls**: call the tool directly (e.g., `workitem_query()`, `git_status()`).\n- For **calls WITH parameters**: you MUST call `get_tool_info(\"tool_name\")` first to get parameter details. The signatures below are summaries only \u2014 do NOT guess parameter structure from them.\n- After a failed tool call, always call `get_tool_info()` before retrying.\n\n";
@@ -1,78 +0,0 @@
1
- /**
2
- * Meta-Tools for Dynamic Tool Loading
3
- *
4
- * Thin singleton wrapper over @compilr-dev/sdk's MetaToolsRegistry.
5
- * Provides the same module-level API used by the CLI while delegating
6
- * all logic to the SDK's class-based implementation.
7
- *
8
- * Instead of declaring all 49 tools (~15K tokens), we declare:
9
- * 1. A small set of "direct" tools (always available)
10
- * 2. A get_tool_info meta-tool (always available)
11
- * 3. A tool index in the system prompt
12
- * 4. A transparent fallback handler that routes calls to the registry
13
- */
14
- import { MetaToolsRegistry, createMetaTools, META_TOOLS_SYSTEM_PROMPT_PREFIX as SDK_META_TOOLS_SYSTEM_PROMPT_PREFIX, } from '@compilr-dev/sdk';
15
- import { getCapabilityManager } from '../multi-agent/capability-loader.js';
16
- // Singleton registry for the CLI process
17
- const registry = new MetaToolsRegistry();
18
- /**
19
- * Auto-load callback shared by both use_tool and createFallback paths.
20
- * When a tool is blocked by the capability filter, this loads the pack
21
- * and updates the filter so the tool executes in the same turn.
22
- */
23
- function onFilteredTool(toolName) {
24
- const manager = getCapabilityManager();
25
- if (!manager)
26
- return false;
27
- const packId = manager.findPackForTool(toolName);
28
- if (!packId || manager.isLoaded(packId))
29
- return false;
30
- if (manager.getTier(packId) !== 'loadable')
31
- return false;
32
- manager.load(packId, 'auto-load');
33
- // Minimal filter rebuild — next BeforeLLM turn does the full rebuild with orphans
34
- registry.setFilter(manager.getActiveToolNames());
35
- return true;
36
- }
37
- const metaToolSet = createMetaTools(registry, { onFilteredTool });
38
- // =============================================================================
39
- // Module-level API (same signatures as before)
40
- // =============================================================================
41
- export function setMetaToolFilter(filter) {
42
- registry.setFilter(filter);
43
- }
44
- export function getMetaToolFilter() {
45
- return registry.getFilter();
46
- }
47
- export function initializeMetaToolRegistry(tools) {
48
- registry.initialize(tools);
49
- }
50
- export function getRegisteredMetaTools() {
51
- return registry.getRegisteredTools();
52
- }
53
- export function getMetaToolCount() {
54
- return registry.getToolCount();
55
- }
56
- export function generateToolIndex() {
57
- return registry.generateToolIndex();
58
- }
59
- // Re-export tool instances
60
- export const listToolsTool = metaToolSet.listToolsTool;
61
- export const getToolInfoTool = metaToolSet.getToolInfoTool;
62
- export const useToolTool = metaToolSet.useToolTool;
63
- export const metaTools = [listToolsTool, getToolInfoTool, useToolTool];
64
- export function createMetaToolFallback() {
65
- return metaToolSet.createFallback({ onFilteredTool });
66
- }
67
- /**
68
- * Generate a filtered tool index showing only tools in the given set.
69
- * Sets the registry filter, generates the index, then restores the previous filter.
70
- */
71
- export function generateFilteredToolIndex(activeToolNames) {
72
- const previousFilter = registry.getFilter();
73
- registry.setFilter(activeToolNames);
74
- const index = registry.generateToolIndex();
75
- registry.setFilter(previousFilter ? [...previousFilter] : null);
76
- return index;
77
- }
78
- export const META_TOOLS_SYSTEM_PROMPT_PREFIX = SDK_META_TOOLS_SYSTEM_PROMPT_PREFIX;