@a-company/paradigm 1.5.0
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.
- package/README.md +142 -0
- package/dist/accept-orchestration-CWZNCGZX.js +188 -0
- package/dist/agents-suggest-35LIQKDH.js +83 -0
- package/dist/aggregate-W7Q6VIM2.js +88 -0
- package/dist/auto-IU7VN55K.js +470 -0
- package/dist/beacon-B47XSTL7.js +251 -0
- package/dist/chunk-2M6OSOIG.js +1302 -0
- package/dist/chunk-4NCFWYGG.js +110 -0
- package/dist/chunk-5C4SGQKH.js +705 -0
- package/dist/chunk-5GOA7WYD.js +1095 -0
- package/dist/chunk-5JGJACDU.js +37 -0
- package/dist/chunk-6QC3YGB6.js +114 -0
- package/dist/chunk-753RICFF.js +325 -0
- package/dist/chunk-AD2LSCHB.js +1595 -0
- package/dist/chunk-CHSHON3O.js +669 -0
- package/dist/chunk-ELLR7WP6.js +3175 -0
- package/dist/chunk-ILOWBJRC.js +12 -0
- package/dist/chunk-IRKUEJVW.js +405 -0
- package/dist/chunk-MC7XC7XQ.js +533 -0
- package/dist/chunk-MO4EEYFW.js +38 -0
- package/dist/chunk-MQWH7PFI.js +13366 -0
- package/dist/chunk-N6PJAPDE.js +364 -0
- package/dist/chunk-PBHIFAL4.js +259 -0
- package/dist/chunk-PMXRGPRQ.js +305 -0
- package/dist/chunk-PW2EXJQT.js +689 -0
- package/dist/chunk-TAP5N3HH.js +245 -0
- package/dist/chunk-THFVK5AE.js +148 -0
- package/dist/chunk-UM54F7G5.js +1533 -0
- package/dist/chunk-UUZ2DMG5.js +185 -0
- package/dist/chunk-WS5KM7OL.js +780 -0
- package/dist/chunk-YDNKXH4Z.js +2316 -0
- package/dist/chunk-YO6DVTL7.js +99 -0
- package/dist/claude-SUYNN72C.js +362 -0
- package/dist/claude-cli-OF43XAO3.js +276 -0
- package/dist/claude-code-PW6SKD2M.js +126 -0
- package/dist/claude-code-teams-JLZ5IXB6.js +199 -0
- package/dist/constellation-K3CIQCHI.js +225 -0
- package/dist/cost-AEK6R7HK.js +174 -0
- package/dist/cost-KYXIQ62X.js +93 -0
- package/dist/cursor-cli-IHJMPRCW.js +269 -0
- package/dist/cursorrules-KI5QWHIX.js +84 -0
- package/dist/diff-AJJ5H6HV.js +125 -0
- package/dist/dist-7MPIRMTZ-IOQOREMZ.js +10866 -0
- package/dist/dist-NHJQVVUW.js +68 -0
- package/dist/dist-ZEMSQV74.js +20 -0
- package/dist/doctor-6Y6L6HEB.js +11 -0
- package/dist/echo-VYZW3OTT.js +248 -0
- package/dist/export-R4FJ5NOH.js +38 -0
- package/dist/history-EVO3L6SC.js +277 -0
- package/dist/hooks-MBWE4ILT.js +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +568 -0
- package/dist/lint-HXKTWRNO.js +316 -0
- package/dist/manual-Y3QOXWYA.js +204 -0
- package/dist/mcp.js +14745 -0
- package/dist/orchestrate-4ZH5GUQH.js +323 -0
- package/dist/probe-OYCP4JYG.js +151 -0
- package/dist/promote-Z52ZJTJU.js +181 -0
- package/dist/providers-4PGPZEWP.js +104 -0
- package/dist/remember-6VZ74B7E.js +77 -0
- package/dist/ripple-SBQOSTZD.js +215 -0
- package/dist/sentinel-LCFD56OJ.js +43 -0
- package/dist/server-F5ITNK6T.js +9846 -0
- package/dist/server-T6WIFYRQ.js +16076 -0
- package/dist/setup-DF4F3ICN.js +25 -0
- package/dist/setup-JHBPZAG7.js +296 -0
- package/dist/shift-HKIAP4ZN.js +226 -0
- package/dist/snapshot-GTVPRYZG.js +62 -0
- package/dist/spawn-BJRQA2NR.js +196 -0
- package/dist/summary-H6J6N6PJ.js +140 -0
- package/dist/switch-6EANJ7O6.js +232 -0
- package/dist/sync-BEOCW7TZ.js +11 -0
- package/dist/team-NWP2KJAB.js +32 -0
- package/dist/test-MA5TWJQV.js +934 -0
- package/dist/thread-JCJVRUQR.js +258 -0
- package/dist/triage-ETVXXFMV.js +1880 -0
- package/dist/tutorial-L5Q3ZDHK.js +666 -0
- package/dist/university-R2WDQLSI.js +40 -0
- package/dist/upgrade-5B3YGGC6.js +550 -0
- package/dist/validate-F3YHBCRZ.js +39 -0
- package/dist/validate-QEEY6KFS.js +64 -0
- package/dist/watch-4LT4O6K7.js +123 -0
- package/dist/watch-6IIWPWDN.js +111 -0
- package/dist/wisdom-LRM4FFCH.js +319 -0
- package/package.json +68 -0
- package/templates/paradigm/config.yaml +175 -0
- package/templates/paradigm/docs/commands.md +727 -0
- package/templates/paradigm/docs/decisions/000-template.md +47 -0
- package/templates/paradigm/docs/decisions/README.md +26 -0
- package/templates/paradigm/docs/error-patterns.md +215 -0
- package/templates/paradigm/docs/patterns.md +358 -0
- package/templates/paradigm/docs/queries.md +200 -0
- package/templates/paradigm/docs/troubleshooting.md +477 -0
- package/templates/paradigm/echoes.yaml +25 -0
- package/templates/paradigm/prompts/add-feature.md +152 -0
- package/templates/paradigm/prompts/add-gate.md +117 -0
- package/templates/paradigm/prompts/debug-auth.md +174 -0
- package/templates/paradigm/prompts/implement-ftux.md +722 -0
- package/templates/paradigm/prompts/implement-sandbox.md +651 -0
- package/templates/paradigm/prompts/read-docs.md +84 -0
- package/templates/paradigm/prompts/refactor.md +106 -0
- package/templates/paradigm/prompts/run-e2e-tests.md +340 -0
- package/templates/paradigm/prompts/trace-flow.md +202 -0
- package/templates/paradigm/prompts/validate-portals.md +279 -0
- package/templates/paradigm/specs/context-tracking.md +200 -0
- package/templates/paradigm/specs/context.md +461 -0
- package/templates/paradigm/specs/disciplines.md +413 -0
- package/templates/paradigm/specs/history.md +339 -0
- package/templates/paradigm/specs/logger.md +303 -0
- package/templates/paradigm/specs/navigator.md +236 -0
- package/templates/paradigm/specs/purpose.md +265 -0
- package/templates/paradigm/specs/scan.md +177 -0
- package/templates/paradigm/specs/symbols.md +451 -0
- package/templates/paradigm/specs/wisdom.md +294 -0
|
@@ -0,0 +1,1533 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
BackgroundOrchestrator
|
|
4
|
+
} from "./chunk-AD2LSCHB.js";
|
|
5
|
+
import {
|
|
6
|
+
AGENT_MODEL_RECOMMENDATIONS,
|
|
7
|
+
addActivity,
|
|
8
|
+
agentsConfigured,
|
|
9
|
+
clearCurrentAgent,
|
|
10
|
+
generateDefaultManifest,
|
|
11
|
+
getAgentsPath,
|
|
12
|
+
getParadigmDir,
|
|
13
|
+
getPendingHandoffs,
|
|
14
|
+
listHandoffs,
|
|
15
|
+
loadAgentsManifest,
|
|
16
|
+
loadTeamState,
|
|
17
|
+
saveAgentsManifest,
|
|
18
|
+
saveHandoff,
|
|
19
|
+
saveTeamState,
|
|
20
|
+
setCurrentAgent
|
|
21
|
+
} from "./chunk-PMXRGPRQ.js";
|
|
22
|
+
|
|
23
|
+
// src/commands/team/index.ts
|
|
24
|
+
import * as fs2 from "fs";
|
|
25
|
+
import * as path3 from "path";
|
|
26
|
+
import chalk2 from "chalk";
|
|
27
|
+
|
|
28
|
+
// src/commands/team/configure-models.ts
|
|
29
|
+
import prompts from "prompts";
|
|
30
|
+
import chalk from "chalk";
|
|
31
|
+
|
|
32
|
+
// src/core/model-discovery.ts
|
|
33
|
+
import { exec } from "child_process";
|
|
34
|
+
import { promisify } from "util";
|
|
35
|
+
import * as fs from "fs";
|
|
36
|
+
import * as path from "path";
|
|
37
|
+
var execAsync = promisify(exec);
|
|
38
|
+
var MANIFEST_URL = "https://raw.githubusercontent.com/ascend42/a-paradigm/main/models.json";
|
|
39
|
+
var MANIFEST_CACHE_TTL = 7 * 24 * 60 * 60 * 1e3;
|
|
40
|
+
var ModelDiscovery = class {
|
|
41
|
+
cacheFile;
|
|
42
|
+
manifestCacheFile;
|
|
43
|
+
cacheTTL = 24 * 60 * 60 * 1e3;
|
|
44
|
+
// 24 hours
|
|
45
|
+
constructor(_rootDir) {
|
|
46
|
+
this.cacheFile = path.join(_rootDir, ".paradigm", "model-cache.json");
|
|
47
|
+
this.manifestCacheFile = path.join(_rootDir, ".paradigm", "model-manifest-cache.json");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Fetch the remote model manifest (cached for 7 days).
|
|
51
|
+
* Returns null on any failure — callers fall back to hardcoded presets.
|
|
52
|
+
*/
|
|
53
|
+
async fetchManifest() {
|
|
54
|
+
try {
|
|
55
|
+
if (fs.existsSync(this.manifestCacheFile)) {
|
|
56
|
+
const raw = fs.readFileSync(this.manifestCacheFile, "utf8");
|
|
57
|
+
const cached = JSON.parse(raw);
|
|
58
|
+
const age = Date.now() - new Date(cached._fetchedAt).getTime();
|
|
59
|
+
if (age < MANIFEST_CACHE_TTL) {
|
|
60
|
+
return cached;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timeout = setTimeout(() => controller.abort(), 5e3);
|
|
68
|
+
const response = await fetch(MANIFEST_URL, { signal: controller.signal });
|
|
69
|
+
clearTimeout(timeout);
|
|
70
|
+
if (!response.ok) return null;
|
|
71
|
+
const manifest = await response.json();
|
|
72
|
+
try {
|
|
73
|
+
const dir = path.dirname(this.manifestCacheFile);
|
|
74
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
75
|
+
fs.writeFileSync(this.manifestCacheFile, JSON.stringify({ ...manifest, _fetchedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
76
|
+
} catch {
|
|
77
|
+
}
|
|
78
|
+
return manifest;
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get models for a provider from the remote manifest.
|
|
85
|
+
* Returns null if manifest unavailable or provider not found.
|
|
86
|
+
*/
|
|
87
|
+
async getManifestModels(provider) {
|
|
88
|
+
const manifest = await this.fetchManifest();
|
|
89
|
+
if (!manifest?.providers?.[provider]) return null;
|
|
90
|
+
return manifest.providers[provider];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Get environment-specific models from the remote manifest.
|
|
94
|
+
* Returns null if manifest unavailable or environment not found.
|
|
95
|
+
*/
|
|
96
|
+
async getManifestEnvironment(env) {
|
|
97
|
+
const manifest = await this.fetchManifest();
|
|
98
|
+
if (!manifest?.environments?.[env]) return null;
|
|
99
|
+
const envConfig = manifest.environments[env];
|
|
100
|
+
if (envConfig.models) {
|
|
101
|
+
return envConfig.models;
|
|
102
|
+
}
|
|
103
|
+
if (envConfig.include) {
|
|
104
|
+
const models = [];
|
|
105
|
+
for (const providerName of envConfig.include) {
|
|
106
|
+
const providerModels = manifest.providers?.[providerName];
|
|
107
|
+
if (providerModels) {
|
|
108
|
+
models.push(...providerModels);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return models.length > 0 ? models : null;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Discover available models
|
|
117
|
+
*/
|
|
118
|
+
async discover() {
|
|
119
|
+
const cached = this.loadCache();
|
|
120
|
+
if (cached) return cached;
|
|
121
|
+
const env = this.detectEnvironment();
|
|
122
|
+
let result;
|
|
123
|
+
switch (env) {
|
|
124
|
+
case "cursor":
|
|
125
|
+
result = await this.discoverCursorModels();
|
|
126
|
+
break;
|
|
127
|
+
case "claude-code":
|
|
128
|
+
result = this.getClaudeCodeModels();
|
|
129
|
+
break;
|
|
130
|
+
case "vscode":
|
|
131
|
+
result = await this.getVSCodeModels();
|
|
132
|
+
break;
|
|
133
|
+
case "multi-provider":
|
|
134
|
+
result = await this.discoverMultiProviderModels();
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
result = this.getFallbackModels();
|
|
138
|
+
}
|
|
139
|
+
this.saveCache(result);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Detect the current environment
|
|
144
|
+
*/
|
|
145
|
+
detectEnvironment() {
|
|
146
|
+
if (process.env.CLAUDE_CODE === "1" || process.env.TERM_PROGRAM === "claude") {
|
|
147
|
+
return "claude-code";
|
|
148
|
+
}
|
|
149
|
+
if (process.env.TERM_PROGRAM === "cursor" || process.env.CURSOR_SESSION || process.env.CURSOR_TRACE_ID || // Cursor sets VSCODE_* vars but with cursor in the path
|
|
150
|
+
process.env.VSCODE_CWD && process.env.VSCODE_CWD.toLowerCase().includes("cursor") || process.env.VSCODE_NLS_CONFIG && process.env.VSCODE_NLS_CONFIG.toLowerCase().includes("cursor") || // Check if running in Cursor's integrated terminal
|
|
151
|
+
process.env.TERM_PROGRAM === "vscode" && process.env.VSCODE_GIT_ASKPASS_NODE?.toLowerCase().includes("cursor")) {
|
|
152
|
+
return "cursor";
|
|
153
|
+
}
|
|
154
|
+
if (process.env.TERM_PROGRAM === "vscode" || process.env.VSCODE_PID) {
|
|
155
|
+
return "vscode";
|
|
156
|
+
}
|
|
157
|
+
const providers = this.getAvailableProviders();
|
|
158
|
+
if (providers.length > 0) {
|
|
159
|
+
return "multi-provider";
|
|
160
|
+
}
|
|
161
|
+
return "fallback";
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get list of providers with configured API keys
|
|
165
|
+
*/
|
|
166
|
+
getAvailableProviders() {
|
|
167
|
+
const providers = [];
|
|
168
|
+
if (process.env.ANTHROPIC_API_KEY) providers.push("anthropic");
|
|
169
|
+
if (process.env.OPENAI_API_KEY) providers.push("openai");
|
|
170
|
+
if (process.env.GOOGLE_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY) providers.push("google");
|
|
171
|
+
if (process.env.XAI_API_KEY) providers.push("xai");
|
|
172
|
+
if (process.env.MISTRAL_API_KEY) providers.push("mistral");
|
|
173
|
+
if (process.env.DEEPSEEK_API_KEY) providers.push("deepseek");
|
|
174
|
+
if (process.env.COHERE_API_KEY) providers.push("cohere");
|
|
175
|
+
if (process.env.OPENROUTER_API_KEY) providers.push("openrouter");
|
|
176
|
+
return providers;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Discover models from all available providers
|
|
180
|
+
*/
|
|
181
|
+
async discoverMultiProviderModels() {
|
|
182
|
+
const providers = this.getAvailableProviders();
|
|
183
|
+
const allModels = [];
|
|
184
|
+
const discoveries = await Promise.allSettled(
|
|
185
|
+
providers.map((provider) => this.discoverProviderModels(provider))
|
|
186
|
+
);
|
|
187
|
+
for (const result of discoveries) {
|
|
188
|
+
if (result.status === "fulfilled" && result.value) {
|
|
189
|
+
allModels.push(...result.value.models);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (allModels.length === 0) {
|
|
193
|
+
return this.getFallbackModels();
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
source: "multi-provider",
|
|
197
|
+
models: allModels,
|
|
198
|
+
cached: false,
|
|
199
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Discover models for a specific provider
|
|
204
|
+
*/
|
|
205
|
+
async discoverProviderModels(provider) {
|
|
206
|
+
switch (provider) {
|
|
207
|
+
case "anthropic":
|
|
208
|
+
return this.discoverAnthropicModels();
|
|
209
|
+
case "openai":
|
|
210
|
+
return this.discoverOpenAIModels();
|
|
211
|
+
case "google":
|
|
212
|
+
return this.discoverGoogleModels();
|
|
213
|
+
case "xai":
|
|
214
|
+
return this.discoverXAIModels();
|
|
215
|
+
case "openrouter":
|
|
216
|
+
return this.discoverOpenRouterModels();
|
|
217
|
+
default:
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Discover Anthropic models via API
|
|
223
|
+
*/
|
|
224
|
+
async discoverAnthropicModels() {
|
|
225
|
+
try {
|
|
226
|
+
const response = await fetch("https://api.anthropic.com/v1/models", {
|
|
227
|
+
headers: {
|
|
228
|
+
"x-api-key": process.env.ANTHROPIC_API_KEY,
|
|
229
|
+
"anthropic-version": "2023-06-01"
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
if (!response.ok) {
|
|
233
|
+
return await this.getAnthropicPresets();
|
|
234
|
+
}
|
|
235
|
+
const data = await response.json();
|
|
236
|
+
if (!data.data || data.data.length === 0) {
|
|
237
|
+
return await this.getAnthropicPresets();
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
source: "anthropic-api",
|
|
241
|
+
models: data.data.map((m) => ({
|
|
242
|
+
id: m.id,
|
|
243
|
+
name: m.display_name || this.formatModelName(m.id),
|
|
244
|
+
provider: "anthropic",
|
|
245
|
+
family: this.extractFamily(m.id, "claude")
|
|
246
|
+
})),
|
|
247
|
+
cached: false,
|
|
248
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
249
|
+
};
|
|
250
|
+
} catch {
|
|
251
|
+
return await this.getAnthropicPresets();
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Discover OpenAI models via API
|
|
256
|
+
*/
|
|
257
|
+
async discoverOpenAIModels() {
|
|
258
|
+
try {
|
|
259
|
+
const response = await fetch("https://api.openai.com/v1/models", {
|
|
260
|
+
headers: { "Authorization": `Bearer ${process.env.OPENAI_API_KEY}` }
|
|
261
|
+
});
|
|
262
|
+
if (!response.ok) {
|
|
263
|
+
return await this.getOpenAIPresets();
|
|
264
|
+
}
|
|
265
|
+
const data = await response.json();
|
|
266
|
+
if (!data.data) {
|
|
267
|
+
return await this.getOpenAIPresets();
|
|
268
|
+
}
|
|
269
|
+
const chatModels = data.data.filter(
|
|
270
|
+
(m) => m.id.includes("gpt-4") || m.id.includes("o1") || m.id.includes("o3") || m.id.includes("o4")
|
|
271
|
+
);
|
|
272
|
+
return {
|
|
273
|
+
source: "openai",
|
|
274
|
+
models: chatModels.map((m) => ({
|
|
275
|
+
id: m.id,
|
|
276
|
+
name: this.formatModelName(m.id),
|
|
277
|
+
provider: "openai",
|
|
278
|
+
family: this.extractFamily(m.id, "gpt")
|
|
279
|
+
})),
|
|
280
|
+
cached: false,
|
|
281
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
282
|
+
};
|
|
283
|
+
} catch {
|
|
284
|
+
return await this.getOpenAIPresets();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Discover Google models via API
|
|
289
|
+
*/
|
|
290
|
+
async discoverGoogleModels() {
|
|
291
|
+
try {
|
|
292
|
+
const apiKey = process.env.GOOGLE_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY;
|
|
293
|
+
const response = await fetch(
|
|
294
|
+
`https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`
|
|
295
|
+
);
|
|
296
|
+
if (!response.ok) {
|
|
297
|
+
return await this.getGooglePresets();
|
|
298
|
+
}
|
|
299
|
+
const data = await response.json();
|
|
300
|
+
if (!data.models) {
|
|
301
|
+
return await this.getGooglePresets();
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
source: "google",
|
|
305
|
+
models: data.models.filter((m) => m.name.includes("gemini")).map((m) => ({
|
|
306
|
+
id: m.name.replace("models/", ""),
|
|
307
|
+
name: m.displayName || this.formatModelName(m.name),
|
|
308
|
+
provider: "google",
|
|
309
|
+
family: "gemini"
|
|
310
|
+
})),
|
|
311
|
+
cached: false,
|
|
312
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
313
|
+
};
|
|
314
|
+
} catch {
|
|
315
|
+
return await this.getGooglePresets();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Discover xAI/Grok models via API
|
|
320
|
+
*/
|
|
321
|
+
async discoverXAIModels() {
|
|
322
|
+
try {
|
|
323
|
+
const response = await fetch("https://api.x.ai/v1/models", {
|
|
324
|
+
headers: { "Authorization": `Bearer ${process.env.XAI_API_KEY}` }
|
|
325
|
+
});
|
|
326
|
+
if (!response.ok) {
|
|
327
|
+
return await this.getXAIPresets();
|
|
328
|
+
}
|
|
329
|
+
const data = await response.json();
|
|
330
|
+
if (!data.data) {
|
|
331
|
+
return await this.getXAIPresets();
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
source: "xai",
|
|
335
|
+
models: data.data.map((m) => ({
|
|
336
|
+
id: m.id,
|
|
337
|
+
name: m.id.includes("grok") ? `Grok ${m.id.split("-").pop()}` : m.id,
|
|
338
|
+
provider: "xai",
|
|
339
|
+
family: "grok"
|
|
340
|
+
})),
|
|
341
|
+
cached: false,
|
|
342
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
343
|
+
};
|
|
344
|
+
} catch {
|
|
345
|
+
return await this.getXAIPresets();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Discover OpenRouter models via API
|
|
350
|
+
*/
|
|
351
|
+
async discoverOpenRouterModels() {
|
|
352
|
+
try {
|
|
353
|
+
const response = await fetch("https://openrouter.ai/api/v1/models", {
|
|
354
|
+
headers: { "Authorization": `Bearer ${process.env.OPENROUTER_API_KEY}` }
|
|
355
|
+
});
|
|
356
|
+
if (!response.ok) {
|
|
357
|
+
return { source: "openrouter", models: [], cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
358
|
+
}
|
|
359
|
+
const data = await response.json();
|
|
360
|
+
if (!data.data) {
|
|
361
|
+
return { source: "openrouter", models: [], cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
source: "openrouter",
|
|
365
|
+
models: data.data.slice(0, 30).map((m) => ({
|
|
366
|
+
id: m.id,
|
|
367
|
+
name: m.name || m.id,
|
|
368
|
+
provider: m.id.split("/")[0] || "openrouter"
|
|
369
|
+
})),
|
|
370
|
+
cached: false,
|
|
371
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
372
|
+
};
|
|
373
|
+
} catch {
|
|
374
|
+
return { source: "openrouter", models: [], cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Discover Cursor models
|
|
379
|
+
*/
|
|
380
|
+
async discoverCursorModels() {
|
|
381
|
+
try {
|
|
382
|
+
const { stdout } = await execAsync("cursor agent models --json", { timeout: 5e3 });
|
|
383
|
+
const models = JSON.parse(stdout);
|
|
384
|
+
return {
|
|
385
|
+
source: "cursor",
|
|
386
|
+
models: models.map((m) => this.normalizeModel(m)),
|
|
387
|
+
cached: false,
|
|
388
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
389
|
+
};
|
|
390
|
+
} catch {
|
|
391
|
+
const manifest = await this.getManifestEnvironment("cursor");
|
|
392
|
+
return {
|
|
393
|
+
source: manifest ? "cursor-manifest" : "cursor",
|
|
394
|
+
models: manifest || this.getCursorPresets(),
|
|
395
|
+
cached: false,
|
|
396
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Get Claude Code models (fixed list)
|
|
402
|
+
*/
|
|
403
|
+
getClaudeCodeModels() {
|
|
404
|
+
return {
|
|
405
|
+
source: "claude-code",
|
|
406
|
+
models: [
|
|
407
|
+
{ id: "opus", name: "Claude Opus", provider: "anthropic", family: "claude" },
|
|
408
|
+
{ id: "sonnet", name: "Claude Sonnet", provider: "anthropic", family: "claude" },
|
|
409
|
+
{ id: "haiku", name: "Claude Haiku", provider: "anthropic", family: "claude" }
|
|
410
|
+
],
|
|
411
|
+
cached: false,
|
|
412
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Get VSCode/Copilot models
|
|
417
|
+
*/
|
|
418
|
+
async getVSCodeModels() {
|
|
419
|
+
const manifest = await this.getManifestEnvironment("vscode");
|
|
420
|
+
if (manifest) {
|
|
421
|
+
return { source: "vscode-manifest", models: manifest, cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
source: "vscode",
|
|
425
|
+
models: [
|
|
426
|
+
{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai", family: "gpt-4.1" },
|
|
427
|
+
{ id: "gpt-4.1-mini", name: "GPT-4.1 Mini", provider: "openai", family: "gpt-4.1" },
|
|
428
|
+
{ id: "gpt-4.1-nano", name: "GPT-4.1 Nano", provider: "openai", family: "gpt-4.1" },
|
|
429
|
+
{ id: "o3", name: "OpenAI o3", provider: "openai", family: "o3" },
|
|
430
|
+
{ id: "o4-mini", name: "OpenAI o4 Mini", provider: "openai", family: "o4" },
|
|
431
|
+
{ id: "claude-sonnet-4-5-20250929", name: "Claude Sonnet 4.5", provider: "anthropic", family: "claude-4" }
|
|
432
|
+
],
|
|
433
|
+
cached: false,
|
|
434
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Get comprehensive preset models for Cursor
|
|
439
|
+
*/
|
|
440
|
+
getCursorPresets() {
|
|
441
|
+
return [
|
|
442
|
+
// Anthropic Claude models
|
|
443
|
+
{ id: "claude-opus-4-6", name: "Claude Opus 4.6", provider: "anthropic", family: "claude-4" },
|
|
444
|
+
{ id: "claude-sonnet-4-5-20250929", name: "Claude Sonnet 4.5", provider: "anthropic", family: "claude-4" },
|
|
445
|
+
{ id: "claude-haiku-4-5-20251001", name: "Claude Haiku 4.5", provider: "anthropic", family: "claude-4" },
|
|
446
|
+
// OpenAI GPT models
|
|
447
|
+
{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai", family: "gpt-4.1" },
|
|
448
|
+
{ id: "gpt-4.1-mini", name: "GPT-4.1 Mini", provider: "openai", family: "gpt-4.1" },
|
|
449
|
+
{ id: "gpt-4.1-nano", name: "GPT-4.1 Nano", provider: "openai", family: "gpt-4.1" },
|
|
450
|
+
{ id: "o3", name: "OpenAI o3", provider: "openai", family: "o3" },
|
|
451
|
+
{ id: "o4-mini", name: "OpenAI o4 Mini", provider: "openai", family: "o4" },
|
|
452
|
+
{ id: "o3-mini", name: "OpenAI o3 Mini", provider: "openai", family: "o3" },
|
|
453
|
+
// Google Gemini models
|
|
454
|
+
{ id: "gemini-2.5-pro", name: "Gemini 2.5 Pro", provider: "google", family: "gemini-2.5" },
|
|
455
|
+
{ id: "gemini-2.5-flash", name: "Gemini 2.5 Flash", provider: "google", family: "gemini-2.5" },
|
|
456
|
+
{ id: "gemini-2.0-flash", name: "Gemini 2.0 Flash", provider: "google", family: "gemini-2" },
|
|
457
|
+
// xAI Grok models
|
|
458
|
+
{ id: "grok-3", name: "Grok 3", provider: "xai", family: "grok" },
|
|
459
|
+
{ id: "grok-3-mini", name: "Grok 3 Mini", provider: "xai", family: "grok" },
|
|
460
|
+
// Meta Llama models
|
|
461
|
+
{ id: "llama-4-scout", name: "Llama 4 Scout", provider: "meta", family: "llama-4" },
|
|
462
|
+
{ id: "llama-4-maverick", name: "Llama 4 Maverick", provider: "meta", family: "llama-4" },
|
|
463
|
+
// Mistral models
|
|
464
|
+
{ id: "mistral-large", name: "Mistral Large", provider: "mistral", family: "mistral" },
|
|
465
|
+
{ id: "codestral", name: "Codestral", provider: "mistral", family: "codestral" },
|
|
466
|
+
// DeepSeek models
|
|
467
|
+
{ id: "deepseek-r1", name: "DeepSeek R1", provider: "deepseek", family: "deepseek" },
|
|
468
|
+
{ id: "deepseek-v3", name: "DeepSeek V3", provider: "deepseek", family: "deepseek" },
|
|
469
|
+
// Cohere models
|
|
470
|
+
{ id: "command-r-plus", name: "Command R+", provider: "cohere", family: "command" },
|
|
471
|
+
{ id: "command-r", name: "Command R", provider: "cohere", family: "command" }
|
|
472
|
+
];
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Get Anthropic preset models (manifest → hardcoded)
|
|
476
|
+
*/
|
|
477
|
+
async getAnthropicPresets() {
|
|
478
|
+
const manifest = await this.getManifestModels("anthropic");
|
|
479
|
+
if (manifest) {
|
|
480
|
+
return { source: "anthropic-manifest", models: manifest, cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
481
|
+
}
|
|
482
|
+
return {
|
|
483
|
+
source: "anthropic-api",
|
|
484
|
+
models: [
|
|
485
|
+
{ id: "claude-opus-4-6", name: "Claude Opus 4.6", provider: "anthropic", family: "claude-4" },
|
|
486
|
+
{ id: "claude-sonnet-4-5-20250929", name: "Claude Sonnet 4.5", provider: "anthropic", family: "claude-4" },
|
|
487
|
+
{ id: "claude-haiku-4-5-20251001", name: "Claude Haiku 4.5", provider: "anthropic", family: "claude-4" }
|
|
488
|
+
],
|
|
489
|
+
cached: false,
|
|
490
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Get OpenAI preset models (manifest → hardcoded)
|
|
495
|
+
*/
|
|
496
|
+
async getOpenAIPresets() {
|
|
497
|
+
const manifest = await this.getManifestModels("openai");
|
|
498
|
+
if (manifest) {
|
|
499
|
+
return { source: "openai-manifest", models: manifest, cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
source: "openai",
|
|
503
|
+
models: [
|
|
504
|
+
{ id: "gpt-4.1", name: "GPT-4.1", provider: "openai", family: "gpt-4.1" },
|
|
505
|
+
{ id: "gpt-4.1-mini", name: "GPT-4.1 Mini", provider: "openai", family: "gpt-4.1" },
|
|
506
|
+
{ id: "gpt-4.1-nano", name: "GPT-4.1 Nano", provider: "openai", family: "gpt-4.1" },
|
|
507
|
+
{ id: "o3", name: "OpenAI o3", provider: "openai", family: "o3" },
|
|
508
|
+
{ id: "o4-mini", name: "OpenAI o4 Mini", provider: "openai", family: "o4" },
|
|
509
|
+
{ id: "o3-mini", name: "OpenAI o3 Mini", provider: "openai", family: "o3" }
|
|
510
|
+
],
|
|
511
|
+
cached: false,
|
|
512
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* Get Google preset models (manifest → hardcoded)
|
|
517
|
+
*/
|
|
518
|
+
async getGooglePresets() {
|
|
519
|
+
const manifest = await this.getManifestModels("google");
|
|
520
|
+
if (manifest) {
|
|
521
|
+
return { source: "google-manifest", models: manifest, cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
source: "google",
|
|
525
|
+
models: [
|
|
526
|
+
{ id: "gemini-2.5-pro", name: "Gemini 2.5 Pro", provider: "google", family: "gemini-2.5" },
|
|
527
|
+
{ id: "gemini-2.5-flash", name: "Gemini 2.5 Flash", provider: "google", family: "gemini-2.5" },
|
|
528
|
+
{ id: "gemini-2.0-flash", name: "Gemini 2.0 Flash", provider: "google", family: "gemini-2" }
|
|
529
|
+
],
|
|
530
|
+
cached: false,
|
|
531
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Get xAI preset models (manifest → hardcoded)
|
|
536
|
+
*/
|
|
537
|
+
async getXAIPresets() {
|
|
538
|
+
const manifest = await this.getManifestModels("xai");
|
|
539
|
+
if (manifest) {
|
|
540
|
+
return { source: "xai-manifest", models: manifest, cached: false, timestamp: (/* @__PURE__ */ new Date()).toISOString() };
|
|
541
|
+
}
|
|
542
|
+
return {
|
|
543
|
+
source: "xai",
|
|
544
|
+
models: [
|
|
545
|
+
{ id: "grok-3", name: "Grok 3", provider: "xai", family: "grok" },
|
|
546
|
+
{ id: "grok-3-mini", name: "Grok 3 Mini", provider: "xai", family: "grok" }
|
|
547
|
+
],
|
|
548
|
+
cached: false,
|
|
549
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Get fallback models (basic Claude models)
|
|
554
|
+
*/
|
|
555
|
+
getFallbackModels() {
|
|
556
|
+
return {
|
|
557
|
+
source: "fallback",
|
|
558
|
+
models: [
|
|
559
|
+
{ id: "opus", name: "Claude Opus", provider: "anthropic", family: "claude" },
|
|
560
|
+
{ id: "sonnet", name: "Claude Sonnet", provider: "anthropic", family: "claude" },
|
|
561
|
+
{ id: "haiku", name: "Claude Haiku", provider: "anthropic", family: "claude" }
|
|
562
|
+
],
|
|
563
|
+
cached: false,
|
|
564
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Normalize a model from external source
|
|
569
|
+
*/
|
|
570
|
+
normalizeModel(model) {
|
|
571
|
+
return {
|
|
572
|
+
id: model.id,
|
|
573
|
+
name: model.name || this.formatModelName(model.id),
|
|
574
|
+
provider: model.provider || "unknown",
|
|
575
|
+
family: model.family,
|
|
576
|
+
capabilities: model.capabilities
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Format a model ID into a human-readable name
|
|
581
|
+
*/
|
|
582
|
+
formatModelName(id) {
|
|
583
|
+
return id.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).replace(/(\d)([a-z])/gi, "$1 $2");
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Extract model family from ID
|
|
587
|
+
*/
|
|
588
|
+
extractFamily(id, defaultFamily) {
|
|
589
|
+
const patterns = [
|
|
590
|
+
[/claude-4|claude-opus-4|claude-sonnet-4|claude-haiku-4/i, "claude-4"],
|
|
591
|
+
[/claude-3\.5|claude-3-5/i, "claude-3.5"],
|
|
592
|
+
[/claude-3/i, "claude-3"],
|
|
593
|
+
[/gpt-4\.1/i, "gpt-4.1"],
|
|
594
|
+
[/gpt-4o/i, "gpt-4o"],
|
|
595
|
+
[/gpt-4/i, "gpt-4"],
|
|
596
|
+
[/o4/i, "o4"],
|
|
597
|
+
[/o3/i, "o3"],
|
|
598
|
+
[/o1/i, "o1"],
|
|
599
|
+
[/gemini-2\.5/i, "gemini-2.5"],
|
|
600
|
+
[/gemini-2/i, "gemini-2"],
|
|
601
|
+
[/gemini-1\.5/i, "gemini-1.5"],
|
|
602
|
+
[/grok/i, "grok"],
|
|
603
|
+
[/llama-4/i, "llama-4"],
|
|
604
|
+
[/llama/i, "llama"],
|
|
605
|
+
[/mistral/i, "mistral"]
|
|
606
|
+
];
|
|
607
|
+
for (const [pattern, family] of patterns) {
|
|
608
|
+
if (pattern.test(id)) {
|
|
609
|
+
return family;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return defaultFamily;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Load cached models
|
|
616
|
+
*/
|
|
617
|
+
loadCache() {
|
|
618
|
+
try {
|
|
619
|
+
if (!fs.existsSync(this.cacheFile)) {
|
|
620
|
+
return null;
|
|
621
|
+
}
|
|
622
|
+
const content = fs.readFileSync(this.cacheFile, "utf8");
|
|
623
|
+
const cached = JSON.parse(content);
|
|
624
|
+
const cacheTime = new Date(cached.timestamp).getTime();
|
|
625
|
+
if (Date.now() - cacheTime > this.cacheTTL) {
|
|
626
|
+
return null;
|
|
627
|
+
}
|
|
628
|
+
return { ...cached, cached: true };
|
|
629
|
+
} catch {
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Save models to cache
|
|
635
|
+
*/
|
|
636
|
+
saveCache(result) {
|
|
637
|
+
try {
|
|
638
|
+
const dir = path.dirname(this.cacheFile);
|
|
639
|
+
if (!fs.existsSync(dir)) {
|
|
640
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
641
|
+
}
|
|
642
|
+
fs.writeFileSync(this.cacheFile, JSON.stringify(result, null, 2));
|
|
643
|
+
} catch {
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Clear the cache
|
|
648
|
+
*/
|
|
649
|
+
clearCache() {
|
|
650
|
+
try {
|
|
651
|
+
if (fs.existsSync(this.cacheFile)) {
|
|
652
|
+
fs.unlinkSync(this.cacheFile);
|
|
653
|
+
}
|
|
654
|
+
} catch {
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Get models grouped by tier (high/medium/low)
|
|
659
|
+
*/
|
|
660
|
+
groupByTier(models) {
|
|
661
|
+
const high = [];
|
|
662
|
+
const medium = [];
|
|
663
|
+
const low = [];
|
|
664
|
+
const miniPattern = /\bmini\b/i;
|
|
665
|
+
const flashPattern = /\bflash\b/i;
|
|
666
|
+
const smallPattern = /\bsmall\b/i;
|
|
667
|
+
for (const model of models) {
|
|
668
|
+
const name = model.name.toLowerCase();
|
|
669
|
+
const id = model.id.toLowerCase();
|
|
670
|
+
const combined = `${name} ${id}`;
|
|
671
|
+
const isLowTier = name.includes("haiku") || miniPattern.test(combined) || name.includes("nano") || flashPattern.test(combined) && !name.includes("flash-thinking") || smallPattern.test(combined) || name.includes("scout") || name.includes("instant");
|
|
672
|
+
const isHighTier = name.includes("opus") || name.includes("gpt-4") && !miniPattern.test(combined) && !name.includes("nano") || id.includes("gpt-4.1") && !miniPattern.test(combined) && !id.includes("nano") || (id === "o3" || id.includes("o3") && !miniPattern.test(combined)) || (id === "o1" || id.includes("o1") && !miniPattern.test(combined) && !id.includes("o1-")) || // Pro models (Gemini Pro, etc.) but not mini variants
|
|
673
|
+
id.includes("-pro") && !miniPattern.test(combined) || id.includes("grok-3") && !miniPattern.test(combined) || id.includes("grok-2") && !miniPattern.test(combined) || name.includes("large") || name.includes("maverick") || name.includes("command r+") || id.includes("deepseek-r1") || id.includes("deepseek-v3");
|
|
674
|
+
if (isLowTier) {
|
|
675
|
+
low.push(model);
|
|
676
|
+
} else if (isHighTier) {
|
|
677
|
+
high.push(model);
|
|
678
|
+
} else {
|
|
679
|
+
medium.push(model);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return { high, medium, low };
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
// src/commands/team/configure-models.ts
|
|
687
|
+
import * as path2 from "path";
|
|
688
|
+
function shouldPromptForModels() {
|
|
689
|
+
if (process.env.CLAUDE_CODE === "1" || process.env.TERM_PROGRAM === "claude") {
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
if (process.env.TERM_PROGRAM === "cursor" || process.env.CURSOR_SESSION || process.env.CURSOR_TRACE_ID || process.env.VSCODE_CWD && process.env.VSCODE_CWD.toLowerCase().includes("cursor") || process.env.VSCODE_NLS_CONFIG && process.env.VSCODE_NLS_CONFIG.toLowerCase().includes("cursor") || process.env.TERM_PROGRAM === "vscode" && process.env.VSCODE_GIT_ASKPASS_NODE?.toLowerCase().includes("cursor")) {
|
|
693
|
+
return true;
|
|
694
|
+
}
|
|
695
|
+
if (process.stdin.isTTY) {
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
return false;
|
|
699
|
+
}
|
|
700
|
+
async function promptForAgentModels(rootDir) {
|
|
701
|
+
const discovery = new ModelDiscovery(rootDir);
|
|
702
|
+
const result = await discovery.discover();
|
|
703
|
+
console.log(chalk.cyan("\n Configure Agent Models\n"));
|
|
704
|
+
console.log(chalk.gray(` Environment: ${result.source}`));
|
|
705
|
+
console.log(chalk.gray(` Available: ${result.models.length} models
|
|
706
|
+
`));
|
|
707
|
+
const models = {};
|
|
708
|
+
const tiers = discovery.groupByTier(result.models);
|
|
709
|
+
const buildChoices = (agent) => {
|
|
710
|
+
const rec = AGENT_MODEL_RECOMMENDATIONS[agent];
|
|
711
|
+
const recommended = rec.tier === "high" ? tiers.high : rec.tier === "medium" ? tiers.medium : tiers.low;
|
|
712
|
+
const choices = [];
|
|
713
|
+
for (const model of recommended) {
|
|
714
|
+
const isFirst = choices.length === 0;
|
|
715
|
+
choices.push({
|
|
716
|
+
title: isFirst ? `${model.name} (recommended)` : model.name,
|
|
717
|
+
value: model.id,
|
|
718
|
+
description: `${model.provider} - ${rec.tier} tier`
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
const otherHigh = tiers.high.filter((m) => !recommended.includes(m));
|
|
722
|
+
const otherMedium = tiers.medium.filter((m) => !recommended.includes(m));
|
|
723
|
+
const otherLow = tiers.low.filter((m) => !recommended.includes(m));
|
|
724
|
+
for (const model of otherHigh) {
|
|
725
|
+
choices.push({
|
|
726
|
+
title: model.name,
|
|
727
|
+
value: model.id,
|
|
728
|
+
description: `${model.provider} - high tier`
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
for (const model of otherMedium) {
|
|
732
|
+
choices.push({
|
|
733
|
+
title: model.name,
|
|
734
|
+
value: model.id,
|
|
735
|
+
description: `${model.provider} - medium tier`
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
for (const model of otherLow) {
|
|
739
|
+
choices.push({
|
|
740
|
+
title: model.name,
|
|
741
|
+
value: model.id,
|
|
742
|
+
description: `${model.provider} - low tier`
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
return choices;
|
|
746
|
+
};
|
|
747
|
+
for (const agent of ["architect", "builder", "tester", "reviewer", "security"]) {
|
|
748
|
+
const rec = AGENT_MODEL_RECOMMENDATIONS[agent];
|
|
749
|
+
const label = agent.charAt(0).toUpperCase() + agent.slice(1);
|
|
750
|
+
const choices = buildChoices(agent);
|
|
751
|
+
const response = await prompts({
|
|
752
|
+
type: "select",
|
|
753
|
+
name: "model",
|
|
754
|
+
message: `${label} (${rec.description})`,
|
|
755
|
+
choices,
|
|
756
|
+
initial: 0
|
|
757
|
+
}, {
|
|
758
|
+
onCancel: () => {
|
|
759
|
+
console.log(chalk.yellow("\n Cancelled. Using defaults.\n"));
|
|
760
|
+
process.exit(0);
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
models[agent] = { id: response.model };
|
|
764
|
+
console.log(chalk.green(` \u2713 ${label}: ${response.model}
|
|
765
|
+
`));
|
|
766
|
+
}
|
|
767
|
+
return models;
|
|
768
|
+
}
|
|
769
|
+
async function teamModelsCommand(targetPath, options) {
|
|
770
|
+
const rootDir = targetPath ? path2.resolve(targetPath) : process.cwd();
|
|
771
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
772
|
+
const discovery = new ModelDiscovery(rootDir);
|
|
773
|
+
if (options.refresh) {
|
|
774
|
+
discovery.clearCache();
|
|
775
|
+
}
|
|
776
|
+
const available = await discovery.discover();
|
|
777
|
+
if (options.json) {
|
|
778
|
+
const agentModels = {};
|
|
779
|
+
if (manifest?.agents) {
|
|
780
|
+
for (const [name, agent] of Object.entries(manifest.agents)) {
|
|
781
|
+
agentModels[name] = agent.defaultModel || "default";
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
console.log(JSON.stringify({
|
|
785
|
+
environment: available.source,
|
|
786
|
+
cached: available.cached,
|
|
787
|
+
agents: agentModels,
|
|
788
|
+
available: available.models
|
|
789
|
+
}, null, 2));
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
console.log(chalk.cyan("\n Agent Model Configuration\n"));
|
|
793
|
+
console.log(chalk.gray(` Environment: ${available.source}${available.cached ? " (cached)" : ""}`));
|
|
794
|
+
console.log(chalk.gray(` Available models: ${available.models.length}
|
|
795
|
+
`));
|
|
796
|
+
console.log(" Current assignments:");
|
|
797
|
+
console.log(chalk.gray(" \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
|
|
798
|
+
console.log(chalk.gray(" \u2502 Agent \u2502 Model \u2502"));
|
|
799
|
+
console.log(chalk.gray(" \u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"));
|
|
800
|
+
if (manifest?.agents) {
|
|
801
|
+
for (const [name, agent] of Object.entries(manifest.agents)) {
|
|
802
|
+
const model = agent.defaultModel || "default";
|
|
803
|
+
const paddedName = name.padEnd(11);
|
|
804
|
+
const paddedModel = model.padEnd(21);
|
|
805
|
+
console.log(chalk.gray(" \u2502 ") + chalk.white(paddedName) + chalk.gray(" \u2502 ") + chalk.yellow(paddedModel) + chalk.gray(" \u2502"));
|
|
806
|
+
}
|
|
807
|
+
} else {
|
|
808
|
+
console.log(chalk.gray(" \u2502 (no agents configured) \u2502"));
|
|
809
|
+
}
|
|
810
|
+
console.log(chalk.gray(" \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n"));
|
|
811
|
+
const tiers = discovery.groupByTier(available.models);
|
|
812
|
+
console.log(chalk.cyan(" Available models by tier:\n"));
|
|
813
|
+
if (tiers.high.length > 0) {
|
|
814
|
+
console.log(chalk.yellow(" High (complex reasoning):"));
|
|
815
|
+
for (const m of tiers.high.slice(0, 5)) {
|
|
816
|
+
console.log(chalk.gray(` - ${m.name} (${m.provider})`));
|
|
817
|
+
}
|
|
818
|
+
if (tiers.high.length > 5) {
|
|
819
|
+
console.log(chalk.gray(` ... and ${tiers.high.length - 5} more`));
|
|
820
|
+
}
|
|
821
|
+
console.log();
|
|
822
|
+
}
|
|
823
|
+
if (tiers.medium.length > 0) {
|
|
824
|
+
console.log(chalk.blue(" Medium (balanced):"));
|
|
825
|
+
for (const m of tiers.medium.slice(0, 5)) {
|
|
826
|
+
console.log(chalk.gray(` - ${m.name} (${m.provider})`));
|
|
827
|
+
}
|
|
828
|
+
if (tiers.medium.length > 5) {
|
|
829
|
+
console.log(chalk.gray(` ... and ${tiers.medium.length - 5} more`));
|
|
830
|
+
}
|
|
831
|
+
console.log();
|
|
832
|
+
}
|
|
833
|
+
if (tiers.low.length > 0) {
|
|
834
|
+
console.log(chalk.green(" Low (fast & cheap):"));
|
|
835
|
+
for (const m of tiers.low.slice(0, 5)) {
|
|
836
|
+
console.log(chalk.gray(` - ${m.name} (${m.provider})`));
|
|
837
|
+
}
|
|
838
|
+
if (tiers.low.length > 5) {
|
|
839
|
+
console.log(chalk.gray(` ... and ${tiers.low.length - 5} more`));
|
|
840
|
+
}
|
|
841
|
+
console.log();
|
|
842
|
+
}
|
|
843
|
+
if (process.stdin.isTTY && !options.json) {
|
|
844
|
+
console.log(chalk.gray(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
845
|
+
const { action } = await prompts({
|
|
846
|
+
type: "select",
|
|
847
|
+
name: "action",
|
|
848
|
+
message: "What would you like to do?",
|
|
849
|
+
choices: [
|
|
850
|
+
{ title: "Reconfigure all models", value: "all" },
|
|
851
|
+
{ title: "Exit", value: "exit" }
|
|
852
|
+
],
|
|
853
|
+
initial: 1
|
|
854
|
+
});
|
|
855
|
+
if (action === "all" && manifest) {
|
|
856
|
+
const models = await promptForAgentModels(rootDir);
|
|
857
|
+
for (const [agentName, config] of Object.entries(models)) {
|
|
858
|
+
if (manifest.agents[agentName]) {
|
|
859
|
+
manifest.agents[agentName].defaultModel = mapToSimpleModel(config.id);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
saveAgentsManifest(rootDir, manifest);
|
|
863
|
+
console.log(chalk.green("\n \u2713 Model configuration updated.\n"));
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
function mapToSimpleModel(modelId) {
|
|
868
|
+
const id = modelId.toLowerCase();
|
|
869
|
+
if (id.includes("opus") || id.includes("gpt-4") && !id.includes("mini") && !id.includes("nano") || (id === "o3" || id.includes("o3") && !id.includes("mini")) || id.includes("o1") && !id.includes("mini") || id.includes("-pro") && !id.includes("mini") || id.includes("large") || id.includes("maverick") || id.includes("deepseek-r1") || id.includes("grok-3") && !id.includes("mini") || id.includes("grok-2") && !id.includes("mini")) {
|
|
870
|
+
return "opus";
|
|
871
|
+
}
|
|
872
|
+
if (id.includes("haiku") || id.includes("mini") || id.includes("nano") || id.includes("flash") || id.includes("scout") || id.includes("small")) {
|
|
873
|
+
return "haiku";
|
|
874
|
+
}
|
|
875
|
+
return "sonnet";
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// src/commands/team/index.ts
|
|
879
|
+
async function teamInitCommand(targetPath, options) {
|
|
880
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
881
|
+
const projectName = path3.basename(rootDir);
|
|
882
|
+
const agentsPath = getAgentsPath(rootDir);
|
|
883
|
+
if (!options.json) {
|
|
884
|
+
console.log(chalk2.blue("\n Initialize Paradigm Team\n"));
|
|
885
|
+
}
|
|
886
|
+
if (agentsConfigured(rootDir) && !options.force) {
|
|
887
|
+
if (options.json) {
|
|
888
|
+
console.log(JSON.stringify({ error: "Team already configured", path: agentsPath }));
|
|
889
|
+
} else {
|
|
890
|
+
console.log(chalk2.yellow(` Team already configured at ${agentsPath}`));
|
|
891
|
+
console.log(chalk2.gray(" Use --force to reinitialize.\n"));
|
|
892
|
+
}
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
let modelOverrides;
|
|
896
|
+
const shouldConfigure = options.configureModels || shouldPromptForModels() && options.noConfigureModels !== true;
|
|
897
|
+
if (shouldConfigure && !options.json) {
|
|
898
|
+
try {
|
|
899
|
+
modelOverrides = await promptForAgentModels(rootDir);
|
|
900
|
+
} catch {
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const manifest = generateDefaultManifest(projectName, modelOverrides);
|
|
904
|
+
saveAgentsManifest(rootDir, manifest);
|
|
905
|
+
const state = {
|
|
906
|
+
current: null,
|
|
907
|
+
queue: [],
|
|
908
|
+
recent: [],
|
|
909
|
+
blocked: []
|
|
910
|
+
};
|
|
911
|
+
saveTeamState(rootDir, state);
|
|
912
|
+
if (options.json) {
|
|
913
|
+
const agentModels = {};
|
|
914
|
+
for (const [name, agent] of Object.entries(manifest.agents)) {
|
|
915
|
+
agentModels[name] = agent.defaultModel || "default";
|
|
916
|
+
}
|
|
917
|
+
console.log(JSON.stringify({
|
|
918
|
+
success: true,
|
|
919
|
+
path: agentsPath,
|
|
920
|
+
agents: Object.keys(manifest.agents),
|
|
921
|
+
models: agentModels
|
|
922
|
+
}));
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
console.log(chalk2.green(" \u2713 Team configuration created\n"));
|
|
926
|
+
console.log(chalk2.gray(` ${agentsPath}
|
|
927
|
+
`));
|
|
928
|
+
console.log(chalk2.cyan(" Available agents:"));
|
|
929
|
+
for (const [name, agent] of Object.entries(manifest.agents)) {
|
|
930
|
+
const model = agent.defaultModel || "default";
|
|
931
|
+
console.log(` ${chalk2.yellow(name.padEnd(12))} ${chalk2.gray(`(${model})`)} ${agent.role.split("\n")[0]}`);
|
|
932
|
+
}
|
|
933
|
+
console.log(chalk2.cyan("\n Next steps:"));
|
|
934
|
+
console.log(chalk2.gray(" 1. Review .paradigm/agents.yaml and customize roles"));
|
|
935
|
+
console.log(chalk2.gray(" 2. Run `paradigm team models` to reconfigure models"));
|
|
936
|
+
console.log(chalk2.gray(" 3. Run `paradigm team status` to see team state"));
|
|
937
|
+
console.log(chalk2.gray(" 4. Use `paradigm team handoff --to <agent>` to hand off work\n"));
|
|
938
|
+
}
|
|
939
|
+
async function teamStatusCommand(targetPath, options) {
|
|
940
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
941
|
+
if (options.id) {
|
|
942
|
+
return showOrchestrationStatus(rootDir, options.id, options);
|
|
943
|
+
}
|
|
944
|
+
if (options.running) {
|
|
945
|
+
return showRunningOrchestrations(rootDir, options);
|
|
946
|
+
}
|
|
947
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
948
|
+
if (!manifest) {
|
|
949
|
+
if (options.json) {
|
|
950
|
+
console.log(JSON.stringify({ error: "Team not configured" }));
|
|
951
|
+
} else {
|
|
952
|
+
console.log(chalk2.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));
|
|
953
|
+
}
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const state = loadTeamState(rootDir);
|
|
957
|
+
const pending = getPendingHandoffs(rootDir);
|
|
958
|
+
const bgOrchestrator = new BackgroundOrchestrator(rootDir);
|
|
959
|
+
const running = bgOrchestrator.getRunning();
|
|
960
|
+
if (options.json) {
|
|
961
|
+
console.log(JSON.stringify({
|
|
962
|
+
team: manifest.team,
|
|
963
|
+
agents: Object.keys(manifest.agents),
|
|
964
|
+
current: state.current,
|
|
965
|
+
queue: state.queue,
|
|
966
|
+
pending_handoffs: pending.length,
|
|
967
|
+
running_orchestrations: running.length,
|
|
968
|
+
recent: state.recent.slice(0, 5)
|
|
969
|
+
}, null, 2));
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
console.log(chalk2.blue("\n\u{1F465} Paradigm Team Status\n"));
|
|
973
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
974
|
+
console.log(chalk2.white(`Team: ${manifest.team.name}`));
|
|
975
|
+
console.log(chalk2.gray(`Agents: ${Object.keys(manifest.agents).join(", ")}`));
|
|
976
|
+
console.log();
|
|
977
|
+
if (running.length > 0) {
|
|
978
|
+
console.log(chalk2.cyan("Running Orchestrations:"));
|
|
979
|
+
for (const orch of running) {
|
|
980
|
+
const elapsed = orch.started ? Math.floor((Date.now() - new Date(orch.started).getTime()) / 6e4) : 0;
|
|
981
|
+
console.log(` ${chalk2.yellow("\u25B6")} ${orch.id}`);
|
|
982
|
+
console.log(chalk2.gray(` ${orch.task.slice(0, 40)}${orch.task.length > 40 ? "..." : ""}`));
|
|
983
|
+
console.log(chalk2.gray(` Running for ${elapsed}m | Mode: ${orch.mode}`));
|
|
984
|
+
}
|
|
985
|
+
console.log(chalk2.gray(`
|
|
986
|
+
Use --running to see details, or \`tail -f <output_file>\` for logs`));
|
|
987
|
+
console.log();
|
|
988
|
+
}
|
|
989
|
+
if (state.current) {
|
|
990
|
+
const elapsed = Date.now() - new Date(state.current.started).getTime();
|
|
991
|
+
const mins = Math.floor(elapsed / 6e4);
|
|
992
|
+
console.log(chalk2.cyan("Current Agent:"));
|
|
993
|
+
console.log(` ${chalk2.yellow(state.current.agent.toUpperCase())} - ${state.current.task}`);
|
|
994
|
+
console.log(chalk2.gray(` Started ${mins}m ago`));
|
|
995
|
+
if (state.current.symbols_touched.length > 0) {
|
|
996
|
+
console.log(chalk2.gray(` Touched: ${state.current.symbols_touched.join(", ")}`));
|
|
997
|
+
}
|
|
998
|
+
console.log();
|
|
999
|
+
} else {
|
|
1000
|
+
console.log(chalk2.cyan("Current Agent:"));
|
|
1001
|
+
console.log(chalk2.gray(" No active agent"));
|
|
1002
|
+
console.log();
|
|
1003
|
+
}
|
|
1004
|
+
if (pending.length > 0) {
|
|
1005
|
+
console.log(chalk2.cyan("Pending Handoffs:"));
|
|
1006
|
+
for (const h of pending) {
|
|
1007
|
+
console.log(` ${chalk2.yellow(h.from)} \u2192 ${chalk2.green(h.to)}: ${h.context.summary.substring(0, 50)}...`);
|
|
1008
|
+
}
|
|
1009
|
+
console.log(chalk2.gray(`
|
|
1010
|
+
Run \`paradigm team accept\` to accept a handoff`));
|
|
1011
|
+
console.log();
|
|
1012
|
+
}
|
|
1013
|
+
if (state.queue.length > 0) {
|
|
1014
|
+
console.log(chalk2.cyan("Queue:"));
|
|
1015
|
+
for (const q of state.queue) {
|
|
1016
|
+
console.log(` ${chalk2.yellow(q.agent)} waiting for ${q.waiting_for}: ${q.task}`);
|
|
1017
|
+
}
|
|
1018
|
+
console.log();
|
|
1019
|
+
}
|
|
1020
|
+
if (state.blocked.length > 0) {
|
|
1021
|
+
console.log(chalk2.red("Blocked:"));
|
|
1022
|
+
for (const b of state.blocked) {
|
|
1023
|
+
console.log(` ${chalk2.yellow(b.agent)}: ${b.reason}`);
|
|
1024
|
+
}
|
|
1025
|
+
console.log();
|
|
1026
|
+
}
|
|
1027
|
+
if (state.recent.length > 0) {
|
|
1028
|
+
console.log(chalk2.cyan("Recent Activity:"));
|
|
1029
|
+
for (const a of state.recent.slice(0, 5)) {
|
|
1030
|
+
const time = new Date(a.timestamp).toLocaleTimeString();
|
|
1031
|
+
const status = a.result === "success" ? chalk2.green("\u2713") : a.result === "failed" ? chalk2.red("\u2717") : a.result === "blocked" ? chalk2.yellow("\u2298") : chalk2.gray("\u25CB");
|
|
1032
|
+
const handoff = a.handed_to ? ` \u2192 ${a.handed_to}` : "";
|
|
1033
|
+
console.log(` ${status} ${time} ${chalk2.gray(a.agent)}: ${a.task}${handoff}`);
|
|
1034
|
+
}
|
|
1035
|
+
console.log();
|
|
1036
|
+
}
|
|
1037
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
1038
|
+
console.log(chalk2.gray("Commands: team status | team status --running | team diff <id> | team accept <id>"));
|
|
1039
|
+
console.log();
|
|
1040
|
+
}
|
|
1041
|
+
async function showRunningOrchestrations(rootDir, options) {
|
|
1042
|
+
const bgOrchestrator = new BackgroundOrchestrator(rootDir);
|
|
1043
|
+
const running = bgOrchestrator.listOrchestrations({ status: ["running", "pending"] });
|
|
1044
|
+
const completed = bgOrchestrator.listOrchestrations({ status: "completed", limit: 5 });
|
|
1045
|
+
if (options.json) {
|
|
1046
|
+
console.log(JSON.stringify({
|
|
1047
|
+
running,
|
|
1048
|
+
recently_completed: completed
|
|
1049
|
+
}, null, 2));
|
|
1050
|
+
return;
|
|
1051
|
+
}
|
|
1052
|
+
console.log(chalk2.blue("\n\u{1F504} Running Orchestrations\n"));
|
|
1053
|
+
console.log(chalk2.gray("\u2500".repeat(60)));
|
|
1054
|
+
if (running.length === 0) {
|
|
1055
|
+
console.log(chalk2.gray(" No orchestrations currently running."));
|
|
1056
|
+
console.log();
|
|
1057
|
+
} else {
|
|
1058
|
+
for (const orch of running) {
|
|
1059
|
+
const elapsed = orch.started ? Math.floor((Date.now() - new Date(orch.started).getTime()) / 6e4) : 0;
|
|
1060
|
+
const statusIcon = orch.status === "running" ? chalk2.yellow("\u25B6") : chalk2.gray("\u25CB");
|
|
1061
|
+
console.log(` ${statusIcon} ${chalk2.cyan(orch.id)}`);
|
|
1062
|
+
console.log(chalk2.white(` Task: ${orch.task.slice(0, 50)}${orch.task.length > 50 ? "..." : ""}`));
|
|
1063
|
+
console.log(chalk2.gray(` Status: ${orch.status} | Mode: ${orch.mode} | Duration: ${elapsed}m`));
|
|
1064
|
+
console.log(chalk2.gray(` Output: ${orch.outputFile}`));
|
|
1065
|
+
console.log();
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
if (completed.length > 0) {
|
|
1069
|
+
console.log(chalk2.cyan("Recently Completed:"));
|
|
1070
|
+
for (const orch of completed) {
|
|
1071
|
+
const statusIcon = orch.status === "completed" ? chalk2.green("\u2713") : orch.status === "failed" ? chalk2.red("\u2717") : orch.status === "accepted" ? chalk2.green("\u2713\u2713") : chalk2.gray("\u25CB");
|
|
1072
|
+
console.log(` ${statusIcon} ${orch.id} - ${orch.task.slice(0, 40)}${orch.task.length > 40 ? "..." : ""}`);
|
|
1073
|
+
}
|
|
1074
|
+
console.log();
|
|
1075
|
+
}
|
|
1076
|
+
console.log(chalk2.gray("\u2500".repeat(60)));
|
|
1077
|
+
console.log(chalk2.gray("Commands: team status <id> | team diff <id> | team accept <id>"));
|
|
1078
|
+
console.log();
|
|
1079
|
+
}
|
|
1080
|
+
async function showOrchestrationStatus(rootDir, id, options) {
|
|
1081
|
+
const bgOrchestrator = new BackgroundOrchestrator(rootDir);
|
|
1082
|
+
const orch = bgOrchestrator.getOrchestration(id);
|
|
1083
|
+
if (!orch) {
|
|
1084
|
+
if (options.json) {
|
|
1085
|
+
console.log(JSON.stringify({ error: "Orchestration not found", id }));
|
|
1086
|
+
} else {
|
|
1087
|
+
console.log(chalk2.red(`
|
|
1088
|
+
Orchestration not found: ${id}
|
|
1089
|
+
`));
|
|
1090
|
+
}
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
if (options.json) {
|
|
1094
|
+
console.log(JSON.stringify(orch, null, 2));
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
const statusIcon = orch.status === "running" ? chalk2.yellow("\u25B6") : orch.status === "completed" ? chalk2.green("\u2713") : orch.status === "failed" ? chalk2.red("\u2717") : orch.status === "accepted" ? chalk2.green("\u2713\u2713") : orch.status === "rejected" ? chalk2.red("\u2717\u2717") : chalk2.gray("\u25CB");
|
|
1098
|
+
console.log();
|
|
1099
|
+
console.log(chalk2.blue("\u2501".repeat(60)));
|
|
1100
|
+
console.log(chalk2.blue(` Orchestration: ${orch.id}`));
|
|
1101
|
+
console.log(chalk2.blue("\u2501".repeat(60)));
|
|
1102
|
+
console.log();
|
|
1103
|
+
console.log(` Status: ${statusIcon} ${orch.status}`);
|
|
1104
|
+
console.log(chalk2.gray(` Task: ${orch.task}`));
|
|
1105
|
+
console.log(chalk2.gray(` Mode: ${orch.mode}`));
|
|
1106
|
+
console.log(chalk2.gray(` Created: ${orch.created}`));
|
|
1107
|
+
if (orch.started) {
|
|
1108
|
+
console.log(chalk2.gray(` Started: ${orch.started}`));
|
|
1109
|
+
}
|
|
1110
|
+
if (orch.completed) {
|
|
1111
|
+
console.log(chalk2.gray(` Completed: ${orch.completed}`));
|
|
1112
|
+
}
|
|
1113
|
+
console.log();
|
|
1114
|
+
if (orch.parallelBuilderStats) {
|
|
1115
|
+
console.log(chalk2.cyan(" Parallel Builders:"));
|
|
1116
|
+
console.log(chalk2.gray(` Used file plan: ${orch.parallelBuilderStats.usedFilePlan ? "Yes" : "No"}`));
|
|
1117
|
+
console.log(chalk2.gray(` Sub-phases: ${orch.parallelBuilderStats.totalSubPhases}`));
|
|
1118
|
+
console.log(chalk2.gray(` Parallel builders: ${orch.parallelBuilderStats.totalParallelBuilders}`));
|
|
1119
|
+
console.log(chalk2.gray(` Files created: ${orch.parallelBuilderStats.filesCreated}`));
|
|
1120
|
+
console.log();
|
|
1121
|
+
}
|
|
1122
|
+
if (orch.artifacts.length > 0) {
|
|
1123
|
+
console.log(chalk2.cyan(" Artifacts:"));
|
|
1124
|
+
for (const artifact of orch.artifacts) {
|
|
1125
|
+
const icon = artifact.action === "created" ? chalk2.green("+") : artifact.action === "modified" ? chalk2.yellow("~") : chalk2.red("-");
|
|
1126
|
+
console.log(` ${icon} ${artifact.path}`);
|
|
1127
|
+
}
|
|
1128
|
+
console.log();
|
|
1129
|
+
}
|
|
1130
|
+
if (orch.result) {
|
|
1131
|
+
console.log(chalk2.cyan(" Result:"));
|
|
1132
|
+
console.log(chalk2.gray(` Agents spawned: ${orch.result.agentsSpawned}`));
|
|
1133
|
+
console.log(chalk2.gray(` Total tokens: ${orch.result.totalTokens.total}`));
|
|
1134
|
+
console.log(chalk2.gray(` Total cost: $${orch.result.totalCost.toFixed(4)}`));
|
|
1135
|
+
console.log(chalk2.gray(` Duration: ${(orch.result.duration_ms / 1e3).toFixed(1)}s`));
|
|
1136
|
+
console.log();
|
|
1137
|
+
}
|
|
1138
|
+
if (orch.error) {
|
|
1139
|
+
console.log(chalk2.red(` Error: ${orch.error}`));
|
|
1140
|
+
console.log();
|
|
1141
|
+
}
|
|
1142
|
+
console.log(chalk2.gray(` Output file: ${orch.outputFile}`));
|
|
1143
|
+
console.log();
|
|
1144
|
+
if (orch.status === "completed") {
|
|
1145
|
+
console.log(chalk2.cyan(" Actions:"));
|
|
1146
|
+
console.log(chalk2.gray(` paradigm team diff ${orch.id} # View changes`));
|
|
1147
|
+
console.log(chalk2.gray(` paradigm team accept ${orch.id} # Accept changes`));
|
|
1148
|
+
console.log(chalk2.gray(` paradigm team reject ${orch.id} # Reject changes`));
|
|
1149
|
+
console.log();
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
async function teamHandoffCommand(targetPath, options) {
|
|
1153
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
1154
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
1155
|
+
if (!manifest) {
|
|
1156
|
+
if (options.json) {
|
|
1157
|
+
console.log(JSON.stringify({ error: "Team not configured" }));
|
|
1158
|
+
} else {
|
|
1159
|
+
console.log(chalk2.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));
|
|
1160
|
+
}
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
const state = loadTeamState(rootDir);
|
|
1164
|
+
if (!manifest.agents[options.to]) {
|
|
1165
|
+
if (options.json) {
|
|
1166
|
+
console.log(JSON.stringify({
|
|
1167
|
+
error: "Unknown agent",
|
|
1168
|
+
agent: options.to,
|
|
1169
|
+
available: Object.keys(manifest.agents)
|
|
1170
|
+
}));
|
|
1171
|
+
} else {
|
|
1172
|
+
console.log(chalk2.red(`
|
|
1173
|
+
Unknown agent: ${options.to}`));
|
|
1174
|
+
console.log(chalk2.gray(`Available agents: ${Object.keys(manifest.agents).join(", ")}
|
|
1175
|
+
`));
|
|
1176
|
+
}
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
const fromAgent = state.current?.agent || manifest.team.default_agent;
|
|
1180
|
+
const handoffId = `${Date.now()}-${fromAgent}-${options.to}`;
|
|
1181
|
+
const handoff = {
|
|
1182
|
+
id: handoffId,
|
|
1183
|
+
from: fromAgent,
|
|
1184
|
+
to: options.to,
|
|
1185
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1186
|
+
status: "pending",
|
|
1187
|
+
completed: {
|
|
1188
|
+
symbols: state.current?.symbols_touched || [],
|
|
1189
|
+
artifacts: []
|
|
1190
|
+
},
|
|
1191
|
+
context: {
|
|
1192
|
+
summary: options.summary || `Task handed off from ${fromAgent} to ${options.to}`,
|
|
1193
|
+
key_symbols: [],
|
|
1194
|
+
warnings: []
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
saveHandoff(rootDir, handoff);
|
|
1198
|
+
addActivity(rootDir, {
|
|
1199
|
+
agent: fromAgent,
|
|
1200
|
+
task: state.current?.task || "Unknown task",
|
|
1201
|
+
result: "success",
|
|
1202
|
+
handed_to: options.to
|
|
1203
|
+
});
|
|
1204
|
+
clearCurrentAgent(rootDir);
|
|
1205
|
+
if (options.json) {
|
|
1206
|
+
console.log(JSON.stringify({
|
|
1207
|
+
success: true,
|
|
1208
|
+
handoff_id: handoffId,
|
|
1209
|
+
from: fromAgent,
|
|
1210
|
+
to: options.to
|
|
1211
|
+
}));
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
console.log(chalk2.blue("\n\u270B Handoff Created\n"));
|
|
1215
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
1216
|
+
console.log(` From: ${chalk2.yellow(fromAgent)}`);
|
|
1217
|
+
console.log(` To: ${chalk2.green(options.to)}`);
|
|
1218
|
+
console.log(` ID: ${chalk2.gray(handoffId)}`);
|
|
1219
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
1220
|
+
const targetAgent = manifest.agents[options.to];
|
|
1221
|
+
console.log(chalk2.cyan("\nTarget agent role:"));
|
|
1222
|
+
for (const line of targetAgent.role.split("\n")) {
|
|
1223
|
+
console.log(chalk2.gray(` ${line}`));
|
|
1224
|
+
}
|
|
1225
|
+
console.log(chalk2.cyan("\nNext steps:"));
|
|
1226
|
+
console.log(chalk2.gray(` 1. The ${options.to} agent will see this handoff`));
|
|
1227
|
+
console.log(chalk2.gray(` 2. Run \`paradigm team accept\` as ${options.to} to accept`));
|
|
1228
|
+
console.log();
|
|
1229
|
+
}
|
|
1230
|
+
async function teamAcceptCommand(handoffId, targetPath, options) {
|
|
1231
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
1232
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
1233
|
+
if (!manifest) {
|
|
1234
|
+
if (options.json) {
|
|
1235
|
+
console.log(JSON.stringify({ error: "Team not configured" }));
|
|
1236
|
+
} else {
|
|
1237
|
+
console.log(chalk2.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));
|
|
1238
|
+
}
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
const pending = getPendingHandoffs(rootDir);
|
|
1242
|
+
if (pending.length === 0) {
|
|
1243
|
+
if (options.json) {
|
|
1244
|
+
console.log(JSON.stringify({ error: "No pending handoffs" }));
|
|
1245
|
+
} else {
|
|
1246
|
+
console.log(chalk2.yellow("\nNo pending handoffs to accept.\n"));
|
|
1247
|
+
}
|
|
1248
|
+
return;
|
|
1249
|
+
}
|
|
1250
|
+
let handoff;
|
|
1251
|
+
if (handoffId) {
|
|
1252
|
+
handoff = pending.find((h) => h.id === handoffId);
|
|
1253
|
+
if (!handoff) {
|
|
1254
|
+
if (options.json) {
|
|
1255
|
+
console.log(JSON.stringify({ error: "Handoff not found", id: handoffId }));
|
|
1256
|
+
} else {
|
|
1257
|
+
console.log(chalk2.red(`
|
|
1258
|
+
Handoff not found: ${handoffId}
|
|
1259
|
+
`));
|
|
1260
|
+
}
|
|
1261
|
+
return;
|
|
1262
|
+
}
|
|
1263
|
+
} else {
|
|
1264
|
+
handoff = pending[0];
|
|
1265
|
+
}
|
|
1266
|
+
handoff.status = "accepted";
|
|
1267
|
+
handoff.accepted_at = (/* @__PURE__ */ new Date()).toISOString();
|
|
1268
|
+
handoff.acceptance_note = options.note;
|
|
1269
|
+
saveHandoff(rootDir, handoff);
|
|
1270
|
+
setCurrentAgent(rootDir, handoff.to, `Accepted from ${handoff.from}: ${handoff.context.summary}`);
|
|
1271
|
+
if (options.json) {
|
|
1272
|
+
console.log(JSON.stringify({
|
|
1273
|
+
success: true,
|
|
1274
|
+
handoff_id: handoff.id,
|
|
1275
|
+
agent: handoff.to,
|
|
1276
|
+
from: handoff.from,
|
|
1277
|
+
context: handoff.context
|
|
1278
|
+
}));
|
|
1279
|
+
return;
|
|
1280
|
+
}
|
|
1281
|
+
console.log(chalk2.blue("\n\u2713 Handoff Accepted\n"));
|
|
1282
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
1283
|
+
console.log(` You are now: ${chalk2.green(handoff.to.toUpperCase())}`);
|
|
1284
|
+
console.log(` From: ${chalk2.yellow(handoff.from)}`);
|
|
1285
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
1286
|
+
console.log(chalk2.cyan("\nContext from previous agent:"));
|
|
1287
|
+
console.log(chalk2.white(` ${handoff.context.summary}`));
|
|
1288
|
+
if (handoff.completed.symbols.length > 0) {
|
|
1289
|
+
console.log(chalk2.cyan("\nSymbols touched:"));
|
|
1290
|
+
for (const sym of handoff.completed.symbols) {
|
|
1291
|
+
console.log(chalk2.gray(` \u2022 ${sym}`));
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
if (handoff.context.warnings.length > 0) {
|
|
1295
|
+
console.log(chalk2.yellow("\nWarnings:"));
|
|
1296
|
+
for (const warn of handoff.context.warnings) {
|
|
1297
|
+
console.log(chalk2.yellow(` \u26A0 ${warn}`));
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
const agent = manifest.agents[handoff.to];
|
|
1301
|
+
console.log(chalk2.cyan("\nYour role:"));
|
|
1302
|
+
for (const line of agent.role.split("\n")) {
|
|
1303
|
+
console.log(chalk2.gray(` ${line}`));
|
|
1304
|
+
}
|
|
1305
|
+
console.log();
|
|
1306
|
+
}
|
|
1307
|
+
async function teamCheckCommand(targetPath, options) {
|
|
1308
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
1309
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
1310
|
+
if (!manifest) {
|
|
1311
|
+
if (options.json) {
|
|
1312
|
+
console.log(JSON.stringify({ error: "Team not configured" }));
|
|
1313
|
+
} else {
|
|
1314
|
+
console.log(chalk2.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));
|
|
1315
|
+
}
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
const state = loadTeamState(rootDir);
|
|
1319
|
+
const pending = getPendingHandoffs(rootDir);
|
|
1320
|
+
const issues = [];
|
|
1321
|
+
for (const h of pending) {
|
|
1322
|
+
const age = Date.now() - new Date(h.timestamp).getTime();
|
|
1323
|
+
const hours = Math.floor(age / 36e5);
|
|
1324
|
+
if (hours > 24) {
|
|
1325
|
+
issues.push({
|
|
1326
|
+
type: "stale_handoff",
|
|
1327
|
+
message: `Handoff from ${h.from} to ${h.to} pending for ${hours}h`,
|
|
1328
|
+
severity: "warning"
|
|
1329
|
+
});
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
for (const b of state.blocked) {
|
|
1333
|
+
issues.push({
|
|
1334
|
+
type: "blocked_agent",
|
|
1335
|
+
message: `${b.agent} blocked: ${b.reason}`,
|
|
1336
|
+
severity: "error"
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1339
|
+
if (state.current) {
|
|
1340
|
+
const elapsed = Date.now() - new Date(state.current.started).getTime();
|
|
1341
|
+
const hours = Math.floor(elapsed / 36e5);
|
|
1342
|
+
if (hours > 8) {
|
|
1343
|
+
issues.push({
|
|
1344
|
+
type: "long_task",
|
|
1345
|
+
message: `Current task running for ${hours}h - consider handing off`,
|
|
1346
|
+
severity: "warning"
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
for (const [name, agent] of Object.entries(manifest.agents)) {
|
|
1351
|
+
for (const target of agent.handoff_to) {
|
|
1352
|
+
if (!manifest.agents[target]) {
|
|
1353
|
+
issues.push({
|
|
1354
|
+
type: "invalid_handoff",
|
|
1355
|
+
message: `${name} can handoff to unknown agent: ${target}`,
|
|
1356
|
+
severity: "error"
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
if (options.json) {
|
|
1362
|
+
console.log(JSON.stringify({
|
|
1363
|
+
issues,
|
|
1364
|
+
current: state.current,
|
|
1365
|
+
pending_count: pending.length
|
|
1366
|
+
}, null, 2));
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1369
|
+
console.log(chalk2.blue("\n\u{1F50D} Team Health Check\n"));
|
|
1370
|
+
console.log(chalk2.gray("\u2500".repeat(50)));
|
|
1371
|
+
if (issues.length === 0) {
|
|
1372
|
+
console.log(chalk2.green("\u2713 No issues found\n"));
|
|
1373
|
+
} else {
|
|
1374
|
+
console.log(chalk2.yellow(`Found ${issues.length} issue(s):
|
|
1375
|
+
`));
|
|
1376
|
+
for (const issue of issues) {
|
|
1377
|
+
const icon = issue.severity === "error" ? chalk2.red("\u2717") : chalk2.yellow("\u26A0");
|
|
1378
|
+
console.log(` ${icon} ${issue.message}`);
|
|
1379
|
+
}
|
|
1380
|
+
console.log();
|
|
1381
|
+
}
|
|
1382
|
+
console.log(chalk2.cyan("Status:"));
|
|
1383
|
+
console.log(` Current agent: ${state.current ? chalk2.green(state.current.agent) : chalk2.gray("none")}`);
|
|
1384
|
+
console.log(` Pending handoffs: ${pending.length}`);
|
|
1385
|
+
console.log(` Blocked agents: ${state.blocked.length}`);
|
|
1386
|
+
console.log();
|
|
1387
|
+
}
|
|
1388
|
+
async function teamHistoryCommand(targetPath, options) {
|
|
1389
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
1390
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
1391
|
+
if (!manifest) {
|
|
1392
|
+
if (options.json) {
|
|
1393
|
+
console.log(JSON.stringify({ error: "Team not configured" }));
|
|
1394
|
+
} else {
|
|
1395
|
+
console.log(chalk2.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));
|
|
1396
|
+
}
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
const state = loadTeamState(rootDir);
|
|
1400
|
+
const handoffs = listHandoffs(rootDir);
|
|
1401
|
+
const limit = options.limit || 50;
|
|
1402
|
+
const timeline = [];
|
|
1403
|
+
for (const activity of state.recent) {
|
|
1404
|
+
timeline.push({
|
|
1405
|
+
timestamp: activity.timestamp,
|
|
1406
|
+
type: "activity",
|
|
1407
|
+
agent: activity.agent,
|
|
1408
|
+
description: activity.task,
|
|
1409
|
+
details: {
|
|
1410
|
+
result: activity.result,
|
|
1411
|
+
handed_to: activity.handed_to,
|
|
1412
|
+
artifacts: activity.artifacts
|
|
1413
|
+
}
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
for (const handoff of handoffs) {
|
|
1417
|
+
timeline.push({
|
|
1418
|
+
timestamp: handoff.timestamp,
|
|
1419
|
+
type: "handoff",
|
|
1420
|
+
agent: handoff.from,
|
|
1421
|
+
description: `Handoff to ${handoff.to}: ${handoff.context.summary}`,
|
|
1422
|
+
details: {
|
|
1423
|
+
to: handoff.to,
|
|
1424
|
+
status: handoff.status,
|
|
1425
|
+
symbols: handoff.completed.symbols
|
|
1426
|
+
}
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
timeline.sort((a, b) => new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime());
|
|
1430
|
+
const limited = timeline.slice(0, limit);
|
|
1431
|
+
if (options.json) {
|
|
1432
|
+
console.log(JSON.stringify({
|
|
1433
|
+
total: timeline.length,
|
|
1434
|
+
showing: limited.length,
|
|
1435
|
+
timeline: limited
|
|
1436
|
+
}, null, 2));
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
console.log(chalk2.blue("\n\u{1F4DC} Team History\n"));
|
|
1440
|
+
console.log(chalk2.gray("\u2500".repeat(60)));
|
|
1441
|
+
if (limited.length === 0) {
|
|
1442
|
+
console.log(chalk2.gray("No activity recorded yet.\n"));
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
for (const entry of limited) {
|
|
1446
|
+
const time = new Date(entry.timestamp).toLocaleString();
|
|
1447
|
+
const icon = entry.type === "handoff" ? "\u270B" : entry.details?.result === "success" ? "\u2713" : entry.details?.result === "failed" ? "\u2717" : "\u25CB";
|
|
1448
|
+
const color = entry.type === "handoff" ? chalk2.cyan : entry.details?.result === "success" ? chalk2.green : entry.details?.result === "failed" ? chalk2.red : chalk2.gray;
|
|
1449
|
+
console.log(`${color(icon)} ${chalk2.gray(time)}`);
|
|
1450
|
+
console.log(` ${chalk2.yellow(entry.agent)}: ${entry.description}`);
|
|
1451
|
+
if (entry.details?.handed_to) {
|
|
1452
|
+
console.log(chalk2.gray(` \u2192 handed to ${entry.details.handed_to}`));
|
|
1453
|
+
}
|
|
1454
|
+
if (entry.details?.symbols && entry.details.symbols.length > 0) {
|
|
1455
|
+
console.log(chalk2.gray(` symbols: ${entry.details.symbols.join(", ")}`));
|
|
1456
|
+
}
|
|
1457
|
+
console.log();
|
|
1458
|
+
}
|
|
1459
|
+
if (timeline.length > limit) {
|
|
1460
|
+
console.log(chalk2.gray(`Showing ${limit} of ${timeline.length} entries. Use --limit to see more.
|
|
1461
|
+
`));
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
async function teamResetCommand(targetPath, options) {
|
|
1465
|
+
const rootDir = targetPath ? path3.resolve(targetPath) : process.cwd();
|
|
1466
|
+
const manifest = loadAgentsManifest(rootDir);
|
|
1467
|
+
if (!manifest) {
|
|
1468
|
+
if (options.json) {
|
|
1469
|
+
console.log(JSON.stringify({ error: "Team not configured" }));
|
|
1470
|
+
} else {
|
|
1471
|
+
console.log(chalk2.yellow("\nTeam not configured. Run `paradigm team init` first.\n"));
|
|
1472
|
+
}
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
const state = loadTeamState(rootDir);
|
|
1476
|
+
const pending = getPendingHandoffs(rootDir);
|
|
1477
|
+
if (!options.force && (state.current || pending.length > 0)) {
|
|
1478
|
+
if (options.json) {
|
|
1479
|
+
console.log(JSON.stringify({
|
|
1480
|
+
error: "Has pending work",
|
|
1481
|
+
current: state.current,
|
|
1482
|
+
pending_handoffs: pending.length
|
|
1483
|
+
}));
|
|
1484
|
+
} else {
|
|
1485
|
+
console.log(chalk2.yellow("\n\u26A0 Cannot reset - there is pending work:\n"));
|
|
1486
|
+
if (state.current) {
|
|
1487
|
+
console.log(` Current: ${state.current.agent} working on "${state.current.task}"`);
|
|
1488
|
+
}
|
|
1489
|
+
if (pending.length > 0) {
|
|
1490
|
+
console.log(` Pending handoffs: ${pending.length}`);
|
|
1491
|
+
}
|
|
1492
|
+
console.log(chalk2.gray("\nUse --force to reset anyway.\n"));
|
|
1493
|
+
}
|
|
1494
|
+
return;
|
|
1495
|
+
}
|
|
1496
|
+
const newState = {
|
|
1497
|
+
current: null,
|
|
1498
|
+
queue: [],
|
|
1499
|
+
recent: [],
|
|
1500
|
+
blocked: []
|
|
1501
|
+
};
|
|
1502
|
+
saveTeamState(rootDir, newState);
|
|
1503
|
+
const handoffsDir = path3.join(getParadigmDir(rootDir), "handoffs");
|
|
1504
|
+
if (options.force && fs2.existsSync(handoffsDir)) {
|
|
1505
|
+
const files = fs2.readdirSync(handoffsDir);
|
|
1506
|
+
for (const file of files) {
|
|
1507
|
+
fs2.unlinkSync(path3.join(handoffsDir, file));
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
if (options.json) {
|
|
1511
|
+
console.log(JSON.stringify({ success: true, cleared_handoffs: options.force }));
|
|
1512
|
+
return;
|
|
1513
|
+
}
|
|
1514
|
+
console.log(chalk2.green("\n\u2713 Team state reset\n"));
|
|
1515
|
+
console.log(chalk2.gray(" Current agent: cleared"));
|
|
1516
|
+
console.log(chalk2.gray(" Activity log: cleared"));
|
|
1517
|
+
console.log(chalk2.gray(" Queue: cleared"));
|
|
1518
|
+
if (options.force) {
|
|
1519
|
+
console.log(chalk2.gray(" Handoff files: deleted"));
|
|
1520
|
+
}
|
|
1521
|
+
console.log(chalk2.gray("\nReady for fresh start. Run `paradigm team status` to verify.\n"));
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
export {
|
|
1525
|
+
teamModelsCommand,
|
|
1526
|
+
teamInitCommand,
|
|
1527
|
+
teamStatusCommand,
|
|
1528
|
+
teamHandoffCommand,
|
|
1529
|
+
teamAcceptCommand,
|
|
1530
|
+
teamCheckCommand,
|
|
1531
|
+
teamHistoryCommand,
|
|
1532
|
+
teamResetCommand
|
|
1533
|
+
};
|