@compilr-dev/cli 0.8.7 → 0.8.8

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.
@@ -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;
@@ -1,56 +0,0 @@
1
- /**
2
- * Skill Editor Overlay
3
- *
4
- * Fullscreen raw markdown editor for SKILL.md files.
5
- * Uses alternate screen buffer (same pattern as DocumentDetailOverlayV2).
6
- *
7
- * Features:
8
- * - Raw markdown editing with syntax highlighting
9
- * - Line numbers, cursor, scroll
10
- * - Ctrl+S saves to disk + validates + shows warnings
11
- * - Dirty check with save prompt on exit
12
- */
13
- import { BaseOverlayV2 } from '../../base/overlay-base-v2.js';
14
- import type { RenderContext, OverlayAction, KeyEvent } from '../types.js';
15
- interface SkillEditorState {
16
- rawLines: string[];
17
- cursorLine: number;
18
- cursorColumn: number;
19
- scrollOffset: number;
20
- isDirty: boolean;
21
- originalContent: string;
22
- showSavePrompt: boolean;
23
- statusMessage: string | null;
24
- statusType: 'success' | 'warning' | 'error' | null;
25
- }
26
- export interface SkillEditorResult {
27
- saved: boolean;
28
- }
29
- export declare class SkillEditorOverlay extends BaseOverlayV2<SkillEditorState, SkillEditorResult> {
30
- readonly type: "inline";
31
- readonly id = "skill-editor-overlay";
32
- readonly usesAlternateScreen = true;
33
- private readonly filePath;
34
- private readonly skillName;
35
- constructor(filePath: string, skillName: string, content: string);
36
- onMount(): void;
37
- onUnmount(): void;
38
- protected renderContent(context: RenderContext): string[];
39
- private renderCursorLine;
40
- private ensureCursorVisible;
41
- handleKey(key: KeyEvent): OverlayAction<SkillEditorResult>;
42
- private handleSavePrompt;
43
- private save;
44
- private currentLine;
45
- private moveCursorUp;
46
- private moveCursorDown;
47
- private moveCursorLeft;
48
- private moveCursorRight;
49
- private pageUp;
50
- private pageDown;
51
- private insertText;
52
- private insertNewline;
53
- private handleBackspace;
54
- private handleDelete;
55
- }
56
- export {};