@compilr-dev/cli 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/dist/index.js CHANGED
@@ -100,20 +100,24 @@ Options:
100
100
  --version, -v Show version number
101
101
  --help, -h Show this help
102
102
 
103
- Environment Variables:
104
- ANTHROPIC_API_KEY Required for Claude provider
105
- OPENAI_API_KEY Required for OpenAI provider
106
- GOOGLE_AI_API_KEY Required for Gemini provider
103
+ API Keys:
104
+ Run /init inside the REPL to set up API keys (encrypted local storage).
105
+ Alternatively, set environment variables:
106
+ ANTHROPIC_API_KEY Claude provider
107
+ OPENAI_API_KEY OpenAI provider
108
+ GOOGLE_AI_API_KEY Gemini provider
109
+
110
+ Other Environment Variables:
107
111
  NO_COLOR Disable ANSI colors
108
112
  COMPILR_NO_UPDATE_CHECK Skip the npm registry update check at startup
109
113
  CI Auto-skips the update check
110
114
 
111
115
  Examples:
112
- compilr
113
- compilr --model claude-sonnet-4-6
116
+ compilr Start with auto-detected provider
117
+ compilr --model claude-sonnet-4-6 Use a specific model
114
118
  compilr --provider gemini --model gemini-2.0-flash
115
- compilr --minimal --show-filtering
116
- compilr --update
119
+ compilr --minimal --show-filtering Minimal tools with analysis
120
+ compilr --update Check for updates
117
121
  `);
118
122
  }
119
123
  // =============================================================================
@@ -1,16 +1,7 @@
1
1
  /**
2
2
  * Delegation Status Tool - Coordinator Mode
3
3
  *
4
- * Read-only tool for the coordinator to query delegation progress.
5
- * Queries the DelegationTracker singleton and returns formatted status.
4
+ * Thin wrapper over SDK's createDelegationStatusTool factory.
6
5
  */
7
- interface DelegationStatusInput {
8
- /** Specific delegation ID (e.g., "del_abc12345") */
9
- delegation_id?: string;
10
- /** Filter by target agent (e.g., "dev") */
11
- agent_id?: string;
12
- /** Filter by status: active (pending+running), completed, failed, all. Default: active */
13
- status?: 'active' | 'completed' | 'failed' | 'all';
14
- }
15
- export declare const delegationStatusTool: import("@compilr-dev/sdk").Tool<DelegationStatusInput>;
16
- export {};
6
+ import type { Tool } from '@compilr-dev/agents';
7
+ export declare const delegationStatusTool: Tool<any>;
@@ -1,128 +1,9 @@
1
1
  /**
2
2
  * Delegation Status Tool - Coordinator Mode
3
3
  *
4
- * Read-only tool for the coordinator to query delegation progress.
5
- * Queries the DelegationTracker singleton and returns formatted status.
4
+ * Thin wrapper over SDK's createDelegationStatusTool factory.
6
5
  */
7
- import { defineTool } from '@compilr-dev/sdk';
6
+ import { createDelegationStatusTool } from '@compilr-dev/sdk';
8
7
  import { getDelegationTracker } from '../multi-agent/delegation-tracker.js';
9
- // =============================================================================
10
- // Helpers
11
- // =============================================================================
12
- function formatDuration(from, to) {
13
- const endTime = to ?? new Date();
14
- const ms = endTime.getTime() - from.getTime();
15
- const seconds = Math.floor(ms / 1000);
16
- const minutes = Math.floor(seconds / 60);
17
- const hours = Math.floor(minutes / 60);
18
- if (hours > 0) {
19
- return `${String(hours)}h ${String(minutes % 60)}m`;
20
- }
21
- else if (minutes > 0) {
22
- return `${String(minutes)}m ${String(seconds % 60)}s`;
23
- }
24
- else {
25
- return `${String(seconds)}s`;
26
- }
27
- }
28
- function formatDelegation(d) {
29
- const entry = {
30
- id: d.id,
31
- targetAgent: d.targetAgentId,
32
- task: d.task.length > 100 ? d.task.slice(0, 100) + '...' : d.task,
33
- status: d.status,
34
- duration: formatDuration(d.createdAt, d.completedAt),
35
- };
36
- if (d.todoIndex !== undefined) {
37
- entry.todoIndex = d.todoIndex;
38
- }
39
- if (d.result) {
40
- entry.result = {
41
- success: d.result.success,
42
- summary: d.result.summary,
43
- artifactIds: d.result.artifactIds,
44
- ...(d.result.error ? { error: d.result.error } : {}),
45
- };
46
- }
47
- return entry;
48
- }
49
- // =============================================================================
50
- // Tool Definition
51
- // =============================================================================
52
- export const delegationStatusTool = defineTool({
53
- name: 'delegation_status',
54
- description: 'Query the status of tasks delegated via delegate_background. ' +
55
- 'Returns active delegations by default (pending and running). ' +
56
- 'Use delegation_id for a specific delegation, agent_id to filter by agent, ' +
57
- 'or status to see completed/failed/all delegations. ' +
58
- 'Note: Only tracks delegate_background calls, not foreground delegate.',
59
- inputSchema: {
60
- type: 'object',
61
- properties: {
62
- delegation_id: {
63
- type: 'string',
64
- description: 'Specific delegation ID (e.g., "del_abc12345")',
65
- },
66
- agent_id: {
67
- type: 'string',
68
- description: 'Filter by target agent (e.g., "dev", "arch")',
69
- },
70
- status: {
71
- type: 'string',
72
- enum: ['active', 'completed', 'failed', 'all'],
73
- description: 'Filter by status. Default: "active" (pending + running)',
74
- },
75
- },
76
- },
77
- execute: async (input) => {
78
- const tracker = await Promise.resolve(getDelegationTracker());
79
- // Single delegation lookup
80
- if (input.delegation_id) {
81
- const delegation = tracker.getDelegation(input.delegation_id);
82
- if (!delegation) {
83
- return {
84
- success: false,
85
- error: `Delegation ${input.delegation_id} not found`,
86
- };
87
- }
88
- return {
89
- success: true,
90
- result: {
91
- delegations: [formatDelegation(delegation)],
92
- stats: tracker.getStats(),
93
- },
94
- };
95
- }
96
- // Get all delegations then filter
97
- let delegations;
98
- if (input.agent_id) {
99
- delegations = tracker.getByAgent(input.agent_id);
100
- }
101
- else {
102
- delegations = tracker.getAll();
103
- }
104
- // Apply status filter
105
- const filter = input.status ?? 'active';
106
- if (filter !== 'all') {
107
- delegations = delegations.filter((d) => {
108
- switch (filter) {
109
- case 'active':
110
- return d.status === 'pending' || d.status === 'running';
111
- case 'completed':
112
- return d.status === 'completed';
113
- case 'failed':
114
- return d.status === 'failed';
115
- default:
116
- return true;
117
- }
118
- });
119
- }
120
- return {
121
- success: true,
122
- result: {
123
- delegations: delegations.map(formatDelegation),
124
- stats: tracker.getStats(),
125
- },
126
- };
127
- },
128
- });
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ export const delegationStatusTool = createDelegationStatusTool(getDelegationTracker());
@@ -1,25 +1,17 @@
1
1
  /**
2
2
  * Handoff Tool - Multi-Agent Task Handoff
3
3
  *
4
- * Allows any agent to hand off the current task to another agent.
5
- * Available to all agents (specialists and coordinator).
6
- *
7
- * Flow:
8
- * 1. Agent calls handoff(agentId, task, reason?)
9
- * 2. CLI shows approval prompt (unless auto-approve is enabled)
10
- * 3. If approved: auto-switch to target agent, inject task
11
- * 4. If denied: return "User declined" to current agent
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.
12
9
  *
13
- * One-hop rule: If this agent was itself handed a task, it cannot
14
- * re-hand it off (except back to the coordinator/default).
10
+ * The handler (registered by delegation-handlers.ts) manages team validation,
11
+ * one-hop enforcement, user approval, and agent switching.
15
12
  */
16
- interface HandoffInput {
17
- /** Target agent ID (e.g., 'arch', 'dev', 'qa', 'default') */
13
+ export declare const handoffTool: import("@compilr-dev/sdk").Tool<{
18
14
  agentId: string;
19
- /** Task description for the target agent */
20
15
  task: string;
21
- /** Optional reason for handoff (shown to user for context) */
22
16
  reason?: string;
23
- }
24
- export declare const handoffTool: import("@compilr-dev/sdk").Tool<HandoffInput>;
25
- export {};
17
+ }>;
@@ -1,23 +1,17 @@
1
1
  /**
2
2
  * Handoff Tool - Multi-Agent Task Handoff
3
3
  *
4
- * Allows any agent to hand off the current task to another agent.
5
- * Available to all agents (specialists and coordinator).
6
- *
7
- * Flow:
8
- * 1. Agent calls handoff(agentId, task, reason?)
9
- * 2. CLI shows approval prompt (unless auto-approve is enabled)
10
- * 3. If approved: auto-switch to target agent, inject task
11
- * 4. If denied: return "User declined" to current agent
12
- *
13
- * One-hop rule: If this agent was itself handed a task, it cannot
14
- * re-hand it off (except back to the coordinator/default).
4
+ * Uses SDK's createHandoffTool factory with CLI-specific handler.
5
+ * Exported as a static tool that lazily resolves dependencies.
15
6
  */
16
7
  import { defineTool } from '@compilr-dev/sdk';
17
8
  import { getHandoffHandler } from '../shared-handlers.js';
18
- // =============================================================================
19
- // Tool Definition
20
- // =============================================================================
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
+ */
21
15
  export const handoffTool = defineTool({
22
16
  name: 'handoff',
23
17
  description: 'Hand off the current task to another team agent. ' +
@@ -43,50 +37,36 @@ export const handoffTool = defineTool({
43
37
  required: ['agentId', 'task'],
44
38
  },
45
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
+ }
46
53
  try {
47
- // Validate input
48
- if (!input.agentId || input.agentId.trim().length === 0) {
49
- return {
50
- success: false,
51
- error: 'Agent ID is required',
52
- };
53
- }
54
- if (!input.task || input.task.trim().length === 0) {
55
- return {
56
- success: false,
57
- error: 'Task description is required',
58
- };
59
- }
60
- // Get the handoff handler from shared-handlers
61
- const handoffHandler = getHandoffHandler();
62
- if (!handoffHandler) {
63
- return {
64
- success: false,
65
- error: 'Handoff handler not initialized. ' +
66
- 'This tool requires multi-agent mode with a team.',
67
- };
68
- }
69
- // Execute handoff (shows approval prompt, switches if approved)
70
54
  const result = await handoffHandler({
71
55
  agentId: input.agentId.trim(),
72
56
  task: input.task.trim(),
73
57
  reason: input.reason?.trim(),
74
58
  });
75
59
  if (result.error) {
76
- return {
77
- success: false,
78
- error: result.error,
79
- };
60
+ return { success: false, error: result.error };
80
61
  }
81
- const output = {
82
- handedOff: result.success,
83
- message: result.declined
84
- ? 'User declined the handoff. Continue handling the task yourself.'
85
- : `Task handed off to $${input.agentId}. They will handle it from here.`,
86
- };
87
62
  return {
88
63
  success: true,
89
- result: output,
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
+ },
90
70
  };
91
71
  }
92
72
  catch (err) {
@@ -148,7 +148,7 @@ export function getApiKey(provider) {
148
148
  const envVarMap = {
149
149
  anthropic: 'ANTHROPIC_API_KEY',
150
150
  openai: 'OPENAI_API_KEY',
151
- google: 'GOOGLE_API_KEY',
151
+ google: 'GOOGLE_AI_API_KEY',
152
152
  ollama: '', // No key needed
153
153
  together: 'TOGETHER_API_KEY',
154
154
  groq: 'GROQ_API_KEY',
@@ -239,7 +239,7 @@ export function isKeyFromEnv(provider) {
239
239
  const envVarMap = {
240
240
  anthropic: 'ANTHROPIC_API_KEY',
241
241
  openai: 'OPENAI_API_KEY',
242
- google: 'GOOGLE_API_KEY',
242
+ google: 'GOOGLE_AI_API_KEY',
243
243
  ollama: '',
244
244
  together: 'TOGETHER_API_KEY',
245
245
  groq: 'GROQ_API_KEY',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/cli",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "AI-powered coding assistant CLI using @compilr-dev/agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -60,9 +60,10 @@
60
60
  "@compilr-dev/editor-core": "^0.0.2",
61
61
  "@compilr-dev/factory": "^0.1.30",
62
62
  "@compilr-dev/logger": "^0.1.0",
63
- "@compilr-dev/sdk": "^0.10.6",
63
+ "@compilr-dev/sdk": "^0.10.8",
64
64
  "@compilr-dev/ui-core": "^0.0.1",
65
65
  "@modelcontextprotocol/sdk": "^1.23.0",
66
+ "ansi-escapes": "^7.3.0",
66
67
  "better-sqlite3": "^12.5.0",
67
68
  "chalk": "^5.6.2",
68
69
  "cli-highlight": "^2.1.11",
@@ -71,6 +72,7 @@
71
72
  "js-tiktoken": "^1.0.21",
72
73
  "marked": "^18.0.3",
73
74
  "picocolors": "^1.1.1",
75
+ "supports-hyperlinks": "^3.2.0",
74
76
  "uuid": "^14.0.0"
75
77
  },
76
78
  "overrides": {