@compilr-dev/cli 0.5.11 → 0.5.12

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,225 +1,14 @@
1
1
  /**
2
- * Delegation Tracker (Phase 3d-beta - Coordinator Mode)
2
+ * Delegation Tracker - CLI Singleton Wrapper
3
3
  *
4
- * Tracks active delegations from the coordinator to background specialists.
5
- * Maintains a completion event queue so the coordinator can be notified
6
- * when specialists finish their work.
7
- *
8
- * Pattern follows PendingRequestsManager (singleton, event-based).
4
+ * The DelegationTracker class lives in @compilr-dev/sdk.
5
+ * This file provides CLI-specific singleton access.
9
6
  */
10
- import { EventEmitter } from 'events';
11
- import { randomUUID } from 'crypto';
12
- // =============================================================================
13
- // Tracker Class
14
- // =============================================================================
15
- export class DelegationTracker extends EventEmitter {
16
- delegations = new Map();
17
- completionQueue = [];
18
- /**
19
- * Create a new delegation.
20
- */
21
- create(options) {
22
- const delegation = {
23
- id: `del_${randomUUID().slice(0, 8)}`,
24
- coordinatorId: options.coordinatorId,
25
- targetAgentId: options.targetAgentId,
26
- task: options.task,
27
- expectedOutput: options.expectedOutput,
28
- todoIndex: options.todoIndex,
29
- status: 'pending',
30
- createdAt: new Date(),
31
- };
32
- this.delegations.set(delegation.id, delegation);
33
- this.emit('delegation-created', delegation);
34
- this.emit('count-changed', this.getStats());
35
- return delegation;
36
- }
37
- /**
38
- * Update a delegation's status.
39
- */
40
- updateStatus(id, status) {
41
- const delegation = this.delegations.get(id);
42
- if (!delegation)
43
- return;
44
- delegation.status = status;
45
- this.emit('count-changed', this.getStats());
46
- }
47
- /**
48
- * Mark a delegation as completed with a result.
49
- */
50
- complete(id, result) {
51
- const delegation = this.delegations.get(id);
52
- if (!delegation)
53
- return;
54
- delegation.status = 'completed';
55
- delegation.result = result;
56
- delegation.completedAt = new Date();
57
- const event = {
58
- delegationId: id,
59
- agentId: delegation.targetAgentId,
60
- status: 'completed',
61
- result,
62
- timestamp: new Date(),
63
- };
64
- this.completionQueue.push(event);
65
- this.emit('delegation-completed', event);
66
- this.emit('count-changed', this.getStats());
67
- }
68
- /**
69
- * Mark a delegation as failed.
70
- */
71
- fail(id, error) {
72
- const delegation = this.delegations.get(id);
73
- if (!delegation)
74
- return;
75
- const result = {
76
- success: false,
77
- summary: `Failed: ${error}`,
78
- artifactIds: [],
79
- error,
80
- };
81
- delegation.status = 'failed';
82
- delegation.result = result;
83
- delegation.completedAt = new Date();
84
- const event = {
85
- delegationId: id,
86
- agentId: delegation.targetAgentId,
87
- status: 'failed',
88
- result,
89
- timestamp: new Date(),
90
- };
91
- this.completionQueue.push(event);
92
- this.emit('delegation-failed', event);
93
- this.emit('count-changed', this.getStats());
94
- }
95
- /**
96
- * Mark a delegation as cancelled.
97
- */
98
- cancel(id) {
99
- const delegation = this.delegations.get(id);
100
- if (!delegation)
101
- return;
102
- delegation.status = 'cancelled';
103
- delegation.completedAt = new Date();
104
- this.emit('count-changed', this.getStats());
105
- }
106
- /**
107
- * Cancel all active delegations for a specific agent.
108
- */
109
- cancelAllForAgent(agentId) {
110
- const active = this.getByAgent(agentId).filter(d => d.status === 'pending' || d.status === 'running');
111
- for (const delegation of active) {
112
- this.cancel(delegation.id);
113
- }
114
- return active.length;
115
- }
116
- // ===========================================================================
117
- // Query
118
- // ===========================================================================
119
- /**
120
- * Get a delegation by ID.
121
- */
122
- get(id) {
123
- return this.delegations.get(id);
124
- }
125
- /**
126
- * Get all delegations targeting a specific agent.
127
- */
128
- getByAgent(agentId) {
129
- return Array.from(this.delegations.values())
130
- .filter(d => d.targetAgentId === agentId);
131
- }
132
- /**
133
- * Get all active (pending or running) delegations.
134
- */
135
- getActive() {
136
- return Array.from(this.delegations.values())
137
- .filter(d => d.status === 'pending' || d.status === 'running');
138
- }
139
- /**
140
- * Get all delegations.
141
- */
142
- getAll() {
143
- return Array.from(this.delegations.values())
144
- .sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
145
- }
146
- // ===========================================================================
147
- // Completion Events
148
- // ===========================================================================
149
- /**
150
- * Check if there are pending completion events.
151
- */
152
- hasCompletionEvents() {
153
- return this.completionQueue.length > 0;
154
- }
155
- /**
156
- * Drain all completion events (removes them from queue).
157
- */
158
- drainCompletionEvents() {
159
- const events = [...this.completionQueue];
160
- this.completionQueue.length = 0;
161
- return events;
162
- }
163
- /**
164
- * Peek at completion events without removing them.
165
- */
166
- peekCompletionEvents() {
167
- return [...this.completionQueue];
168
- }
169
- // ===========================================================================
170
- // Stats
171
- // ===========================================================================
172
- /**
173
- * Get delegation statistics.
174
- */
175
- getStats() {
176
- let pending = 0;
177
- let running = 0;
178
- let completed = 0;
179
- let failed = 0;
180
- let cancelled = 0;
181
- for (const d of this.delegations.values()) {
182
- switch (d.status) {
183
- case 'pending':
184
- pending++;
185
- break;
186
- case 'running':
187
- running++;
188
- break;
189
- case 'completed':
190
- completed++;
191
- break;
192
- case 'failed':
193
- failed++;
194
- break;
195
- case 'cancelled':
196
- cancelled++;
197
- break;
198
- }
199
- }
200
- return {
201
- total: this.delegations.size,
202
- pending,
203
- running,
204
- completed,
205
- failed,
206
- cancelled,
207
- };
208
- }
209
- // ===========================================================================
210
- // Cleanup
211
- // ===========================================================================
212
- /**
213
- * Clear all delegations and completion events.
214
- */
215
- clear() {
216
- this.delegations.clear();
217
- this.completionQueue.length = 0;
218
- this.emit('count-changed', this.getStats());
219
- }
220
- }
7
+ // Re-export everything from SDK
8
+ export { DelegationTracker, } from '@compilr-dev/sdk';
9
+ import { DelegationTracker } from '@compilr-dev/sdk';
221
10
  // =============================================================================
222
- // Singleton Instance
11
+ // CLI Singleton
223
12
  // =============================================================================
224
13
  let instance = null;
225
14
  /**
@@ -1,24 +1,20 @@
1
1
  /**
2
2
  * Multi-Agent Module
3
3
  *
4
- * Provides multi-agent team functionality:
5
- * - AgentTeam: Orchestrates multiple persistent agents
6
- * - TeamAgent: Wrapper for individual team agents
7
- * - Checkpointing: Persistence for team state
8
- * - SharedContextManager: Shared context across agents
9
- * - ArtifactStore: Storage for team artifacts
4
+ * Re-exports team orchestration from @compilr-dev/sdk plus
5
+ * CLI-specific implementations (checkpointer, session registry, etc.)
10
6
  */
11
- export type { MascotExpression, AgentRole, RoleMetadata, TeamAgentConfig, SerializedTeamAgent, TeamMetadata, SerializedTeam, TeamEventType, TeamEvent, TeamEventHandler, } from './types.js';
12
- export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from './types.js';
13
- export { TeamAgent } from './team-agent.js';
14
- export { AgentTeam, type AgentTeamConfig } from './team.js';
7
+ export type { MascotExpression, AgentRole, RoleMetadata, TeamAgentConfig, SerializedTeamAgent, TeamMetadata, SerializedTeam, TeamEventType, TeamEvent, TeamEventHandler, BackgroundSessionInfo, } from '@compilr-dev/sdk';
8
+ export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from '@compilr-dev/sdk';
9
+ export { TeamAgent, AgentTeam } from '@compilr-dev/sdk';
10
+ export type { AgentTeamConfig } from '@compilr-dev/sdk';
11
+ export { SharedContextManager, type SharedContext, type SharedProjectInfo, type SharedTeamInfo, type TeamRosterEntry, type TeamActivity, type TeamActivityType, type SharedDecision, type TokenBudget, type SerializedSharedContext, } from '@compilr-dev/sdk';
12
+ export { ArtifactStore, type Artifact, type TeamArtifactType as ArtifactType, type TeamArtifactSummary as ArtifactSummary, type CreateArtifactOptions, type UpdateArtifactOptions, } from '@compilr-dev/sdk';
13
+ export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, type ParsedMention, type ParsedInput, } from '@compilr-dev/sdk';
14
+ export { ContextResolver, buildContextMap, type ResolvedMention, type ResolutionSource, type ResolveOptions, } from '@compilr-dev/sdk';
15
+ export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity } from '@compilr-dev/sdk';
16
+ export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from '@compilr-dev/sdk';
17
+ export { suggestOwner, suggestOwners, matchesAgentExpertise } from '@compilr-dev/sdk';
18
+ export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from '@compilr-dev/sdk';
15
19
  export { TeamCheckpointer, getTeamCheckpointer, getSessionsPath } from './checkpointer.js';
16
- export { SharedContextManager, type SharedContext, type SharedProjectInfo, type SharedTeamInfo, type TeamRosterEntry, type TeamActivity, type TeamActivityType, type SharedDecision, type TokenBudget, type SerializedSharedContext, } from './shared-context.js';
17
- export { ArtifactStore, type Artifact, type ArtifactType, type ArtifactSummary, type CreateArtifactOptions, type UpdateArtifactOptions, } from './artifacts.js';
18
- export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, type ParsedMention, type ParsedInput, } from './mention-parser.js';
19
- export { ContextResolver, buildContextMap, type ResolvedMention, type ResolutionSource, type ResolveOptions, } from './context-resolver.js';
20
- export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity, } from './activity.js';
21
- export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from './agent-selection.js';
22
- export { suggestOwner, suggestOwners, matchesAgentExpertise, } from './task-suggestion.js';
23
- export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from './task-assignment.js';
24
20
  export { PendingRequestsManager, getPendingRequestsManager, resetPendingRequestsManager, type PendingRequest, type PendingRequestResponse, type PendingRequestType, type EnqueueOptions, type PendingRequestsEvents, } from './pending-requests.js';
@@ -1,30 +1,29 @@
1
1
  /**
2
2
  * Multi-Agent Module
3
3
  *
4
- * Provides multi-agent team functionality:
5
- * - AgentTeam: Orchestrates multiple persistent agents
6
- * - TeamAgent: Wrapper for individual team agents
7
- * - Checkpointing: Persistence for team state
8
- * - SharedContextManager: Shared context across agents
9
- * - ArtifactStore: Storage for team artifacts
4
+ * Re-exports team orchestration from @compilr-dev/sdk plus
5
+ * CLI-specific implementations (checkpointer, session registry, etc.)
10
6
  */
11
- export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from './types.js';
7
+ export { ROLE_METADATA, ROLE_EXPERTISE, PREDEFINED_ROLE_IDS } from '@compilr-dev/sdk';
12
8
  // Classes
13
- export { TeamAgent } from './team-agent.js';
14
- export { AgentTeam } from './team.js';
9
+ export { TeamAgent, AgentTeam } from '@compilr-dev/sdk';
10
+ // Shared Context
11
+ export { SharedContextManager, } from '@compilr-dev/sdk';
12
+ // Artifacts
13
+ export { ArtifactStore, } from '@compilr-dev/sdk';
14
+ // Mention References
15
+ export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, } from '@compilr-dev/sdk';
16
+ export { ContextResolver, buildContextMap, } from '@compilr-dev/sdk';
17
+ // Activity Recording
18
+ export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity } from '@compilr-dev/sdk';
19
+ // Agent Selection
20
+ export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from '@compilr-dev/sdk';
21
+ // Task Ownership
22
+ export { suggestOwner, suggestOwners, matchesAgentExpertise } from '@compilr-dev/sdk';
23
+ export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from '@compilr-dev/sdk';
24
+ // =============================================================================
25
+ // CLI-only modules (filesystem, SQLite, terminal-specific)
26
+ // =============================================================================
15
27
  export { TeamCheckpointer, getTeamCheckpointer, getSessionsPath } from './checkpointer.js';
16
- // Phase 2: Shared Context
17
- export { SharedContextManager, } from './shared-context.js';
18
- export { ArtifactStore, } from './artifacts.js';
19
- // Phase 2c: Mention References
20
- export { parseInputForMentions, getReferencedAgents, hasReferences, buildMessageWithContext, } from './mention-parser.js';
21
- export { ContextResolver, buildContextMap, } from './context-resolver.js';
22
- // Phase 2c: Activity Recording
23
- export { setActiveSharedContext, getActiveSharedContext, recordTeamActivity, } from './activity.js';
24
- // Phase 3: Agent Selection (for delegation)
25
- export { findAgentForRole, findAgentById, getAvailableSpecialists, getSpecialistsSummary, hasSpecialists, } from './agent-selection.js';
26
- // Task Ownership: Suggestion and Assignment
27
- export { suggestOwner, suggestOwners, matchesAgentExpertise, } from './task-suggestion.js';
28
- export { wouldCreateLoop, recordAssignment, getAssignmentHistory, clearAssignmentHistory, clearAllAssignmentHistory, canReassign, } from './task-assignment.js';
29
- // Phase 3b: Background Agents - Pending Requests
28
+ // Background Agents - Pending Requests
30
29
  export { PendingRequestsManager, getPendingRequestsManager, resetPendingRequestsManager, } from './pending-requests.js';
package/dist/repl-v2.js CHANGED
@@ -2746,7 +2746,7 @@ export class ReplV2 {
2746
2746
  formatCompletionMessage(events) {
2747
2747
  const lines = ['[DELEGATION COMPLETIONS]', ''];
2748
2748
  for (const event of events) {
2749
- const delegation = getDelegationTracker().get(event.delegationId);
2749
+ const delegation = getDelegationTracker().getDelegation(event.delegationId);
2750
2750
  const agentLabel = this.team?.get(event.agentId)?.displayName ?? event.agentId;
2751
2751
  const status = event.status === 'completed' ? 'COMPLETED' : 'FAILED';
2752
2752
  lines.push(`## $${event.agentId} (${agentLabel}) — ${status}`);
@@ -78,7 +78,7 @@ export const delegationStatusTool = defineTool({
78
78
  const tracker = await Promise.resolve(getDelegationTracker());
79
79
  // Single delegation lookup
80
80
  if (input.delegation_id) {
81
- const delegation = tracker.get(input.delegation_id);
81
+ const delegation = tracker.getDelegation(input.delegation_id);
82
82
  if (!delegation) {
83
83
  return {
84
84
  success: false,
@@ -32,4 +32,4 @@ export declare const allPlatformTools: import("@compilr-dev/sdk").Tool<never>[];
32
32
  * - 3 model tools (app_model_get, app_model_update, app_model_validate)
33
33
  * - 2 factory tools (factory_scaffold, factory_list_toolkits)
34
34
  */
35
- export declare const allFactoryTools: import("@compilr-dev/sdk").Tool<never>[];
35
+ export declare const allFactoryTools: import("@compilr-dev/agents").Tool<never>[];
@@ -20,7 +20,7 @@ import { createFactoryTools } from '@compilr-dev/factory';
20
20
  import { projectRepository, workItemRepository, documentRepository, planRepository, } from '../db/repositories/index.js';
21
21
  import { getCurrentProject, setCurrentProject } from './project-db.js';
22
22
  import { awardFirstProject, awardWorkItemCompletion } from '../games/coins.js';
23
- import { getActiveSharedContext } from '../multi-agent/activity.js';
23
+ import { getActiveSharedContext } from '@compilr-dev/sdk';
24
24
  import { getGlobalAnchorManager, getAnchorManager, } from '../anchors/index.js';
25
25
  import { getTeamCheckpointer, recordTeamActivity } from '../multi-agent/index.js';
26
26
  import { getGlobalEpisodeStore } from '../episodes/index.js';
@@ -196,7 +196,7 @@ const artifactService = {
196
196
  });
197
197
  if (!updated)
198
198
  throw new Error(`Failed to update artifact "${input.name}"`);
199
- store.save();
199
+ getTeamCheckpointer().saveArtifactStore(currentProject?.id ?? null, store);
200
200
  recordTeamActivity(agentId, 'artifact_updated', `updated artifact "${updated.name}"`);
201
201
  const artifact = {
202
202
  id: updated.id,
@@ -219,7 +219,7 @@ const artifactService = {
219
219
  content: input.content,
220
220
  summary: input.summary,
221
221
  });
222
- store.save();
222
+ getTeamCheckpointer().saveArtifactStore(currentProject?.id ?? null, store);
223
223
  recordTeamActivity(agentId, 'artifact_created', `created artifact "${created.name}"`);
224
224
  const artifact = {
225
225
  id: created.id,
@@ -284,7 +284,7 @@ const artifactService = {
284
284
  const deleted = store.delete(artifact.id);
285
285
  if (!deleted)
286
286
  return Promise.resolve(null);
287
- store.save();
287
+ getTeamCheckpointer().saveArtifactStore(currentProject?.id ?? null, store);
288
288
  const result = {
289
289
  id: artifact.id,
290
290
  name: artifact.name,
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { BaseOverlayV2 } from '../../base/index.js';
10
10
  import type { RenderContext, OverlayAction, KeyEvent } from '../index.js';
11
- import type { BackgroundSessionInfo } from '../../../multi-agent/types.js';
11
+ import type { BackgroundSessionInfo } from '@compilr-dev/sdk';
12
12
  export type BackgroundOverlayResult = {
13
13
  type: 'closed';
14
14
  } | {
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { BaseOverlayV2 } from '../../base/index.js';
11
11
  import type { RenderContext, OverlayAction, KeyEvent } from '../types.js';
12
- import { type CustomAgentDefinition, type ToolConfig, type ToolProfile } from '../../../multi-agent/custom-agents.js';
12
+ import { type CustomAgentDefinition, type TeamToolConfig as ToolConfig, type ToolProfile } from '@compilr-dev/sdk';
13
13
  import { type ModelTier } from '../../../models/index.js';
14
14
  interface FormField {
15
15
  id: string;
@@ -8,10 +8,7 @@
8
8
  * Step 4: Model Tier (select fast/balanced/powerful)
9
9
  */
10
10
  import { BaseOverlayV2, renderBorder, wrapText } from '../../base/index.js';
11
- import { validateAgentId, isAgentIdTaken, } from '../../../multi-agent/custom-agents.js';
12
- import { PREDEFINED_ROLE_IDS } from '../../../multi-agent/types.js';
13
- import { TOOL_GROUPS, PROFILE_INFO, getGroupsByTier, createDefaultToolConfig, getToolsForProfile, } from '../../../multi-agent/tool-config.js';
14
- import { getDefinedSkillNames, checkSkillCompatibility, getSkillsByCategory, } from '../../../multi-agent/skill-requirements.js';
11
+ import { validateAgentId, isAgentIdTaken, PREDEFINED_ROLE_IDS, TOOL_GROUPS, PROFILE_INFO, getGroupsByTier, createDefaultToolConfig, getToolsForProfile, getDefinedSkillNames, checkSkillCompatibility, getSkillsByCategory, } from '@compilr-dev/sdk';
15
12
  import { MODEL_TIERS, TIER_INFO } from '../../../models/index.js';
16
13
  // Profile list for selection
17
14
  const PROFILE_LIST = [
@@ -105,7 +105,7 @@ export class DelegationsOverlayV2 extends BaseOverlayV2 {
105
105
  const lines = [];
106
106
  const innerWidth = context.width - 4;
107
107
  const tracker = getDelegationTracker();
108
- const d = this.state.detailId ? tracker.get(this.state.detailId) : undefined;
108
+ const d = this.state.detailId ? tracker.getDelegation(this.state.detailId) : undefined;
109
109
  lines.push(...this.renderHeader(this.state.detailId ?? 'Delegation'));
110
110
  if (!d) {
111
111
  lines.push(s.error(' Delegation not found.'));
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import { TabbedListOverlayV2, BaseScreen } from '../../base/index.js';
13
13
  import type { AgentTeam, AgentRole } from '../../../multi-agent/index.js';
14
- import { type ToolProfile } from '../../../multi-agent/tool-config.js';
14
+ import { type ToolProfile } from '@compilr-dev/sdk';
15
15
  import { type ModelTier } from '../../../models/index.js';
16
16
  interface TeamMemberItem {
17
17
  id: string;
@@ -12,7 +12,7 @@
12
12
  import * as terminal from '../../terminal.js';
13
13
  import { TabbedListOverlayV2, BaseScreen, stay, popScreen, closeOverlay, isEscape, isCtrlC, isEnter, isClose, extractPrintable, renderBorder, wrapText, renderProgressBar, formatTokens, } from '../../base/index.js';
14
14
  import { ROLE_METADATA } from '../../../multi-agent/index.js';
15
- import { PROFILE_INFO } from '../../../multi-agent/tool-config.js';
15
+ import { PROFILE_INFO } from '@compilr-dev/sdk';
16
16
  import { TIER_INFO, getModelForTier } from '../../../models/index.js';
17
17
  import { getSettings } from '../../../settings/index.js';
18
18
  import { getRoleTierDefault, setRoleTierDefault } from '../../../settings/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/cli",
3
- "version": "0.5.11",
3
+ "version": "0.5.12",
4
4
  "description": "AI-powered coding assistant CLI using @compilr-dev/agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -58,7 +58,7 @@
58
58
  "@compilr-dev/agents-coding": "^1.0.4",
59
59
  "@compilr-dev/editor-core": "^0.0.2",
60
60
  "@compilr-dev/factory": "^0.1.12",
61
- "@compilr-dev/sdk": "^0.1.28",
61
+ "@compilr-dev/sdk": "^0.2.0",
62
62
  "@compilr-dev/ui-core": "^0.0.1",
63
63
  "@modelcontextprotocol/sdk": "^1.23.0",
64
64
  "better-sqlite3": "^12.5.0",