@wrongstack/cli 0.84.1 → 0.89.1
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/dist/index.js +68 -18
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { color, writeErr, renderProgress, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, DefaultTaskStore, TaskTracker, renderTaskGraph, DefaultSecretScrubber, DefaultPathResolver, TOKENS, mergeCustomModelDefs, DefaultSystemPromptBuilder, makeAutonomyPromptContributor, ToolRegistry, createContextManagerTool, EventBus, resolveSessionLoggingConfig, createSessionEventBridge, HookRegistry, HookRunner, SlashCommandRegistry, BrainDecisionQueue, ObservableBrainArbiter, HumanEscalatingBrainArbiter, DefaultBrainArbiter, createDelegateTool, FLEET_ROSTER, createMcpControlTool, SpecVersioning, atomicWrite, DefaultLogger, DefaultModelsRegistry, isStdinTTY, writeOut, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, ProviderRegistry, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, RecoveryLock, DefaultAttachmentStore, QueueStore, Context, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, loadPlan, createDefaultPipelines, resolveContextWindowPolicy, resolveAuditLevel, AutoCompactionMiddleware, estimateRequestTokensCalibrated, Agent, loadPlugins, FleetManager, makeDirectorSessionFactory, Director, makeFleetEmitTool, makeFleetStatusTool, resolveModelMatrix, DEFAULT_SUBAGENT_BASELINE, AutoApprovePermissionPolicy, PhaseStore, AutoPhasePlanner, PhaseGraphBuilder, WorktreeManager, PhaseOrchestrator, makeLLMClassifier, ParallelEternalEngine, EternalAutonomyEngine, allServers as allServers$1, decryptConfigSecrets as decryptConfigSecrets$1, encryptConfigSecrets as encryptConfigSecrets$1, bootConfig as bootConfig$1, setOutputLineGuard, setRawMode, DefaultSessionReader, resolveWstackPaths, ToolAuditLog, DefaultSessionRewinder, DefaultSessionStore, DefaultPluginAPI, ProviderError, makeAgentSubagentRunner, NULL_FLEET_BUS, buildChildEnv, formatContextWindowModeList, repairToolUseAdjacency, getContextWindowMode, AGENTS_BY_PHASE, dispatchAgent, formatTodosList, SessionRecovery, loadGoal, goalFilePath, summarizeUsage, saveGoal, emptyGoal, buildGoalPreamble, formatGoal, pendingBtwCount, setBtwNote, MATRIX_PHASE_KEYS, AGENT_CATALOG, matrixKeyKind, onResize, ERROR_CODES, InputBuilder, FsError } from '@wrongstack/core';
|
|
2
|
+
import { color, writeErr, renderProgress, SpecStore, TaskGraphStore, analyzeCriticalPath, getTemplate, listTemplates, templateToMarkdown, SpecParser, renderSpecAnalysis, AISpecBuilder, DefaultTaskStore, TaskTracker, renderTaskGraph, DefaultSecretScrubber, DefaultPathResolver, TOKENS, mergeCustomModelDefs, DefaultSystemPromptBuilder, makeAutonomyPromptContributor, ToolRegistry, createContextManagerTool, EventBus, resolveSessionLoggingConfig, createSessionEventBridge, HookRegistry, HookRunner, SlashCommandRegistry, BrainDecisionQueue, ObservableBrainArbiter, HumanEscalatingBrainArbiter, DefaultBrainArbiter, createDelegateTool, FLEET_ROSTER, createMcpControlTool, SpecVersioning, atomicWrite, DefaultLogger, DefaultModelsRegistry, isStdinTTY, writeOut, runProviderWithRetry, ReplayLogStore, ReplayProviderRunner, ProviderRegistry, InMemoryMetricsSink, wireMetricsToEvents, DefaultHealthRegistry, startMetricsServer, DEFAULT_SESSION_PRUNE_DAYS, RecoveryLock, DefaultAttachmentStore, QueueStore, Context, loadTodosCheckpoint, attachTodosCheckpoint, loadDirectorState, loadPlan, createDefaultPipelines, resolveContextWindowPolicy, resolveAuditLevel, AutoCompactionMiddleware, estimateRequestTokensCalibrated, Agent, loadPlugins, FleetManager, makeDirectorSessionFactory, Director, makeFleetEmitTool, makeFleetStatusTool, resolveModelMatrix, DEFAULT_SUBAGENT_BASELINE, AutoApprovePermissionPolicy, PhaseStore, AutoPhasePlanner, PhaseGraphBuilder, WorktreeManager, PhaseOrchestrator, makeLLMClassifier, ParallelEternalEngine, EternalAutonomyEngine, allServers as allServers$1, decryptConfigSecrets as decryptConfigSecrets$1, encryptConfigSecrets as encryptConfigSecrets$1, bootConfig as bootConfig$1, setOutputLineGuard, setRawMode, DefaultSessionReader, resolveWstackPaths, ToolAuditLog, DefaultSessionRewinder, DefaultSessionStore, DefaultPluginAPI, ProviderError, makeAgentSubagentRunner, NULL_FLEET_BUS, buildChildEnv, formatContextWindowModeList, repairToolUseAdjacency, getContextWindowMode, AGENTS_BY_PHASE, dispatchAgent, formatTodosList, SessionRecovery, loadGoal, goalFilePath, summarizeUsage, saveGoal, emptyGoal, buildGoalPreamble, formatGoal, pendingBtwCount, setBtwNote, MATRIX_PHASE_KEYS, AGENT_CATALOG, matrixKeyKind, onResize, ERROR_CODES, InputBuilder, FsError } from '@wrongstack/core';
|
|
3
3
|
import * as path8 from 'path';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import * as fsp4 from 'fs/promises';
|
|
@@ -11,6 +11,7 @@ import * as crypto2 from 'crypto';
|
|
|
11
11
|
import { randomUUID } from 'crypto';
|
|
12
12
|
import { findFreePort, createHttpServer, openBrowser, registerInstance, unregisterInstance } from '@wrongstack/webui/server';
|
|
13
13
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
14
|
+
import { spawn } from 'child_process';
|
|
14
15
|
import { MCPRegistry, MCPServer, serveHttp, serveStdio } from '@wrongstack/mcp';
|
|
15
16
|
import { capabilitiesFor, buildProviderFactoriesFromRegistry, makeProviderFromConfig } from '@wrongstack/providers';
|
|
16
17
|
import { createDefaultContainer, routeImagesForModel, readClipboardImage } from '@wrongstack/runtime';
|
|
@@ -22,7 +23,6 @@ import { writeFileSync, existsSync, readFileSync } from 'fs';
|
|
|
22
23
|
import { WrongStackACPServer } from '@wrongstack/acp/agent';
|
|
23
24
|
import { ACP_AGENT_COMMANDS, makeACPSubagentRunner, makeACPSubagentRunnerWithStop } from '@wrongstack/acp';
|
|
24
25
|
import { ACP_AGENTS, SubagentBudget } from '@wrongstack/core/coordination';
|
|
25
|
-
import { spawn } from 'child_process';
|
|
26
26
|
import { allServers } from '@wrongstack/core/infrastructure';
|
|
27
27
|
import { ToolExecutor } from '@wrongstack/core/execution';
|
|
28
28
|
import { createToolVisionAdapters } from '@wrongstack/runtime/vision';
|
|
@@ -7431,9 +7431,9 @@ async function runProjectCheck(opts) {
|
|
|
7431
7431
|
}
|
|
7432
7432
|
if (answer2 === "y" || answer2 === "yes") {
|
|
7433
7433
|
try {
|
|
7434
|
-
const { spawn:
|
|
7434
|
+
const { spawn: spawn4 } = await import('child_process');
|
|
7435
7435
|
await new Promise((resolve5, reject) => {
|
|
7436
|
-
const child =
|
|
7436
|
+
const child = spawn4("git", ["init"], { cwd });
|
|
7437
7437
|
child.on("error", reject);
|
|
7438
7438
|
child.on("close", (code) => code === 0 ? resolve5() : reject(new Error(`git init failed with ${code}`)));
|
|
7439
7439
|
});
|
|
@@ -15201,8 +15201,20 @@ function expectDefined16(value) {
|
|
|
15201
15201
|
return value;
|
|
15202
15202
|
}
|
|
15203
15203
|
async function setupSession(params) {
|
|
15204
|
-
const {
|
|
15205
|
-
|
|
15204
|
+
const {
|
|
15205
|
+
config,
|
|
15206
|
+
wpaths,
|
|
15207
|
+
projectRoot,
|
|
15208
|
+
cwd,
|
|
15209
|
+
sessionStore,
|
|
15210
|
+
systemPrompt,
|
|
15211
|
+
provider,
|
|
15212
|
+
tokenCounter,
|
|
15213
|
+
renderer,
|
|
15214
|
+
flags,
|
|
15215
|
+
onRecovery
|
|
15216
|
+
} = params;
|
|
15217
|
+
sessionStore.prune(DEFAULT_SESSION_PRUNE_DAYS).then((count) => {
|
|
15206
15218
|
if (count > 0) renderer.writeInfo(`Pruned ${count} old session${count === 1 ? "" : "s"}.`);
|
|
15207
15219
|
}).catch(() => void 0);
|
|
15208
15220
|
let resumeId = typeof flags["resume"] === "string" ? flags["resume"] : void 0;
|
|
@@ -15228,20 +15240,38 @@ async function setupSession(params) {
|
|
|
15228
15240
|
const resumed = await sessionStore.resume(resumeId);
|
|
15229
15241
|
session = resumed.writer;
|
|
15230
15242
|
restoredMessages = resumed.data.messages;
|
|
15231
|
-
renderer.writeInfo(
|
|
15243
|
+
renderer.writeInfo(
|
|
15244
|
+
`Resumed session ${resumed.data.metadata.id} \u2014 ${restoredMessages.length} messages, ${resumed.data.usage.input + resumed.data.usage.output} tokens used previously.`
|
|
15245
|
+
);
|
|
15232
15246
|
} catch (err) {
|
|
15233
15247
|
renderer.writeError(`Resume failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
15234
15248
|
throw Object.assign(new Error("RESUME_FAILED"), { exitCode: 2 });
|
|
15235
15249
|
}
|
|
15236
15250
|
} else {
|
|
15237
|
-
session = await sessionStore.create({
|
|
15251
|
+
session = await sessionStore.create({
|
|
15252
|
+
id: "",
|
|
15253
|
+
title: "",
|
|
15254
|
+
model: config.model,
|
|
15255
|
+
provider: config.provider
|
|
15256
|
+
});
|
|
15238
15257
|
}
|
|
15239
15258
|
const sessionRef = { current: session };
|
|
15240
15259
|
await recoveryLock.write(session?.id).catch(() => void 0);
|
|
15241
|
-
const attachments = new DefaultAttachmentStore({
|
|
15260
|
+
const attachments = new DefaultAttachmentStore({
|
|
15261
|
+
spoolDir: path8.join(wpaths.projectSessions, session?.id, "attachments")
|
|
15262
|
+
});
|
|
15242
15263
|
const queueStore = new QueueStore({ dir: path8.join(wpaths.projectSessions, session?.id) });
|
|
15243
15264
|
const ctxSignal = new AbortController().signal;
|
|
15244
|
-
const context = new Context({
|
|
15265
|
+
const context = new Context({
|
|
15266
|
+
systemPrompt,
|
|
15267
|
+
provider,
|
|
15268
|
+
session: expectDefined16(session),
|
|
15269
|
+
signal: ctxSignal,
|
|
15270
|
+
tokenCounter,
|
|
15271
|
+
cwd,
|
|
15272
|
+
projectRoot,
|
|
15273
|
+
model: config.model
|
|
15274
|
+
});
|
|
15245
15275
|
if (restoredMessages.length > 0) context.state.replaceMessages(restoredMessages);
|
|
15246
15276
|
const todosCheckpointPath = path8.join(wpaths.projectSessions, `${session?.id}.todos.json`);
|
|
15247
15277
|
if (resumeId) {
|
|
@@ -15249,12 +15279,18 @@ async function setupSession(params) {
|
|
|
15249
15279
|
const restoredTodos = await loadTodosCheckpoint(todosCheckpointPath);
|
|
15250
15280
|
if (restoredTodos && restoredTodos.length > 0) {
|
|
15251
15281
|
context.state.replaceTodos(restoredTodos);
|
|
15252
|
-
renderer.writeInfo(
|
|
15282
|
+
renderer.writeInfo(
|
|
15283
|
+
`Restored ${restoredTodos.length} todo${restoredTodos.length === 1 ? "" : "s"} from previous run.`
|
|
15284
|
+
);
|
|
15253
15285
|
}
|
|
15254
15286
|
} catch {
|
|
15255
15287
|
}
|
|
15256
15288
|
}
|
|
15257
|
-
const detachTodosCheckpoint = attachTodosCheckpoint(
|
|
15289
|
+
const detachTodosCheckpoint = attachTodosCheckpoint(
|
|
15290
|
+
context.state,
|
|
15291
|
+
todosCheckpointPath,
|
|
15292
|
+
session?.id
|
|
15293
|
+
);
|
|
15258
15294
|
const planPath = path8.join(wpaths.projectSessions, `${session?.id}.plan.json`);
|
|
15259
15295
|
context.state.setMeta("plan.path", planPath);
|
|
15260
15296
|
let dirState;
|
|
@@ -15266,7 +15302,9 @@ async function setupSession(params) {
|
|
|
15266
15302
|
const tCounts = {};
|
|
15267
15303
|
for (const t of dirState.tasks) tCounts[t.status] = (tCounts[t.status] ?? 0) + 1;
|
|
15268
15304
|
const summary = Object.entries(tCounts).map(([k, v]) => `${v} ${k}`).join(", ");
|
|
15269
|
-
renderer.writeInfo(
|
|
15305
|
+
renderer.writeInfo(
|
|
15306
|
+
`Prior fleet state: ${dirState.subagents.length} subagent${dirState.subagents.length === 1 ? "" : "s"}, tasks ${summary || "(none)"}.`
|
|
15307
|
+
);
|
|
15270
15308
|
}
|
|
15271
15309
|
} catch {
|
|
15272
15310
|
}
|
|
@@ -15275,12 +15313,25 @@ async function setupSession(params) {
|
|
|
15275
15313
|
if (plan && plan.items.length > 0) {
|
|
15276
15314
|
const open = plan.items.filter((p) => p.status !== "done").length;
|
|
15277
15315
|
const done = plan.items.length - open;
|
|
15278
|
-
renderer.writeInfo(
|
|
15316
|
+
renderer.writeInfo(
|
|
15317
|
+
`Plan: ${plan.items.length} item${plan.items.length === 1 ? "" : "s"} (${open} open, ${done} done). Use /plan to review.`
|
|
15318
|
+
);
|
|
15279
15319
|
}
|
|
15280
15320
|
} catch {
|
|
15281
15321
|
}
|
|
15282
15322
|
}
|
|
15283
|
-
return {
|
|
15323
|
+
return {
|
|
15324
|
+
session: expectDefined16(session),
|
|
15325
|
+
sessionRef,
|
|
15326
|
+
context,
|
|
15327
|
+
restoredMessages,
|
|
15328
|
+
attachments,
|
|
15329
|
+
recoveryLock,
|
|
15330
|
+
queueStore,
|
|
15331
|
+
planPath,
|
|
15332
|
+
detachTodosCheckpoint,
|
|
15333
|
+
priorFleetState: dirState ?? void 0
|
|
15334
|
+
};
|
|
15284
15335
|
}
|
|
15285
15336
|
function resolveBundledSkillsDir2() {
|
|
15286
15337
|
try {
|
|
@@ -15661,7 +15712,7 @@ async function main(argv) {
|
|
|
15661
15712
|
renderer.writeInfo(`\u{1F91D} Delegating \u2192 ${e.target}: ${task}`);
|
|
15662
15713
|
});
|
|
15663
15714
|
events.on("delegate.completed", (e) => {
|
|
15664
|
-
const cost = e.costUsd && e.costUsd > 0 ? ` \xB7 $${e.costUsd.toFixed(
|
|
15715
|
+
const cost = e.costUsd && e.costUsd > 0 ? ` \xB7 $${e.costUsd.toFixed(4)}` : "";
|
|
15665
15716
|
renderer.writeInfo(`${e.ok ? "\u2705" : "\u274C"} ${e.summary}${cost}`);
|
|
15666
15717
|
});
|
|
15667
15718
|
}
|
|
@@ -16541,11 +16592,10 @@ Restart WrongStack to load or unload plugin code in this session.`;
|
|
|
16541
16592
|
void mcpRegistry.stopAll();
|
|
16542
16593
|
},
|
|
16543
16594
|
onBeforeExit: async () => {
|
|
16544
|
-
const { spawn: spawn3 } = await import('child_process');
|
|
16545
16595
|
const cwd2 = projectRoot;
|
|
16546
16596
|
const statusResult = await new Promise(
|
|
16547
16597
|
(resolve5, reject) => {
|
|
16548
|
-
const child =
|
|
16598
|
+
const child = spawn("git", ["status", "--porcelain"], {
|
|
16549
16599
|
cwd: cwd2,
|
|
16550
16600
|
stdio: ["ignore", "pipe", "pipe"]
|
|
16551
16601
|
});
|