@wrongstack/cli 1.1.2 → 1.1.5

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.
Files changed (117) hide show
  1. package/dist/{acp-HCGUTFNE.js → acp-NKUEYJDZ.js} +14 -5
  2. package/dist/acp-leader/acp-leader-confirm.d.ts +20 -0
  3. package/dist/acp-leader/acp-leader-context.d.ts +29 -0
  4. package/dist/acp-leader/acp-leader-fleet.d.ts +26 -0
  5. package/dist/acp-leader/acp-leader-host-binding.d.ts +17 -0
  6. package/dist/acp-leader/acp-leader-host.d.ts +82 -0
  7. package/dist/acp-leader/acp-leader-picker.d.ts +24 -0
  8. package/dist/acp-leader/acp-leader-provider.d.ts +85 -0
  9. package/dist/acp-leader/acp-leader-resume.d.ts +10 -0
  10. package/dist/acp-leader/acp-leader-stream.d.ts +83 -0
  11. package/dist/{auth-ANOVZVHE.js → auth-2ZG5DBHS.js} +62 -66
  12. package/dist/auth-menu/index.d.ts +1 -2
  13. package/dist/boot/dispatch-webui.d.ts +16 -0
  14. package/dist/boot/launch-menu-arrow.d.ts +20 -0
  15. package/dist/boot/launch-menu-types.d.ts +36 -0
  16. package/dist/boot/launch-menu.d.ts +1 -57
  17. package/dist/boot/tui-session-resume-rollback.d.ts +31 -0
  18. package/dist/{boot-auto-thin-7D4OVEWA.js → boot-auto-thin-N2CIGTXE.js} +3 -3
  19. package/dist/{chunk-TZPKOS5G.js → chunk-2XQ6SRKG.js} +2 -2
  20. package/dist/chunk-3LEIFO5D.js +65 -0
  21. package/dist/chunk-5SGMUDP5.js +752 -0
  22. package/dist/{chunk-3EXRPTAU.js → chunk-5TQ65PXQ.js} +17 -17
  23. package/dist/{chunk-GRAGMA4B.js → chunk-7BM4LGKQ.js} +18 -18
  24. package/dist/{chunk-VAQXOZKP.js → chunk-AJM4EFCM.js} +139 -136
  25. package/dist/{chunk-C2BBH4S4.js → chunk-E3MJFAFR.js} +2 -2
  26. package/dist/{chunk-5TRZZHMN.js → chunk-JCZ2D3VV.js} +4 -65
  27. package/dist/{chunk-AWRZWPJ3.js → chunk-JFYQGMMM.js} +99 -75
  28. package/dist/{chunk-BIGSVBPI.js → chunk-KNYIEQAY.js} +64 -61
  29. package/dist/chunk-LUEO5HLZ.js +50 -0
  30. package/dist/chunk-LYWOV4OX.js +252 -0
  31. package/dist/chunk-M7FNHCE3.js +2070 -0
  32. package/dist/{chunk-75OLD563.js → chunk-M7PSENGF.js} +3 -1
  33. package/dist/{chunk-NMXQFQ26.js → chunk-MEBXWI7U.js} +5 -5
  34. package/dist/{chunk-RAWHRRUJ.js → chunk-MKMM5RIW.js} +209 -201
  35. package/dist/{chunk-3R3OADC5.js → chunk-P7MEEUGT.js} +281 -252
  36. package/dist/chunk-QLYPIJ7X.js +258 -0
  37. package/dist/chunk-RN5CFAVQ.js +292 -0
  38. package/dist/{chunk-WDXNBYGD.js → chunk-TDP7CZGE.js} +6 -1
  39. package/dist/{chunk-6VPWQ4TG.js → chunk-UROB7MK5.js} +2 -1
  40. package/dist/chunk-VEESMPTX.js +254 -0
  41. package/dist/{chunk-IJLIAPCW.js → chunk-VPSAKGLK.js} +47 -47
  42. package/dist/{cli-context-YIT4FEDM.js → cli-context-CQYGIWOU.js} +254 -237
  43. package/dist/{cli-main-JIADJ5OL.js → cli-main-VRUJNUBX.js} +2081 -1594
  44. package/dist/cli-main-boot.d.ts +1 -1
  45. package/dist/config-doctor-known-keys.d.ts +33 -0
  46. package/dist/config-doctor.d.ts +2 -47
  47. package/dist/config-history-support.d.ts +36 -0
  48. package/dist/config-history.d.ts +1 -1
  49. package/dist/{config-transfer-Y7XJMJRN.js → config-transfer-B4GOZTFC.js} +2 -2
  50. package/dist/{execution-BAP566QC.js → execution-IV72RUSM.js} +5354 -5258
  51. package/dist/execution-tui.d.ts +30 -0
  52. package/dist/fleet/acp-live-steer.d.ts +28 -0
  53. package/dist/fleet/acp-permission-bridge.d.ts +49 -0
  54. package/dist/fleet/acp-quota-hold.d.ts +3 -0
  55. package/dist/fleet/acp-quota-reading.d.ts +3 -0
  56. package/dist/fleet/acp-turn-reminders.d.ts +15 -0
  57. package/dist/fleet/acp-wrongstack-bridge.d.ts +50 -0
  58. package/dist/fleet/host-acp.d.ts +23 -2
  59. package/dist/fleet/wrongforge-client.d.ts +116 -0
  60. package/dist/fleet/wrongforge-gateway.d.ts +20 -0
  61. package/dist/fleet/wrongforge-info.d.ts +32 -0
  62. package/dist/fleet/wrongforge-quota.d.ts +10 -0
  63. package/dist/fleet/wrongforge-runner.d.ts +37 -0
  64. package/dist/fleet/wrongforge-runtime.d.ts +10 -0
  65. package/dist/{hq-JD5AZVMG.js → hq-54PQYR5O.js} +311 -307
  66. package/dist/hq-server/sweeps.d.ts +28 -0
  67. package/dist/{hq-server-BI23EPM7.js → hq-server-YK7FBLL6.js} +3 -3
  68. package/dist/index.js +8 -5
  69. package/dist/mcp-22CFBX4H.js +236 -0
  70. package/dist/mcp-serve-project.d.ts +18 -0
  71. package/dist/mcp-serve.d.ts +0 -63
  72. package/dist/{modeldiag-HDIKG37X.js → modeldiag-5PBB777J.js} +4 -4
  73. package/dist/{per-subcommand-help-D6J4ZXW2.js → per-subcommand-help-MQGERD4E.js} +2 -2
  74. package/dist/plugin-llm-command.d.ts +9 -0
  75. package/dist/{plugin-usage-TYF5HY4K.js → plugin-usage-UWKYMNQU.js} +3 -3
  76. package/dist/{plugins-XGAXDLPT.js → plugins-VP7JQH47.js} +4 -4
  77. package/dist/{sdd-runtime-6MFUXWJK.js → sdd-runtime-HIJ4Z5TF.js} +2 -2
  78. package/dist/services/sdd/state.d.ts +2 -0
  79. package/dist/session-event-wiring-types.d.ts +62 -0
  80. package/dist/session-event-wiring.d.ts +2 -52
  81. package/dist/{sessions-config-SJVQXCIE.js → sessions-config-7MK742OW.js} +2 -2
  82. package/dist/short-circuit-flags-AGHURHMQ.js +11 -0
  83. package/dist/slash-commands/command-context-fleet.d.ts +187 -0
  84. package/dist/slash-commands/command-context-sdd-goal.d.ts +102 -0
  85. package/dist/slash-commands/command-context.d.ts +3 -282
  86. package/dist/slash-commands/project-switch-interactive.d.ts +11 -0
  87. package/dist/slash-commands/setmodel-helpers.d.ts +36 -0
  88. package/dist/subcommands/handlers/hq-token.d.ts +3 -0
  89. package/dist/subcommands/handlers/hq.d.ts +0 -21
  90. package/dist/subcommands/handlers/per-subcommand-help-operations.d.ts +8 -0
  91. package/dist/subcommands/handlers/tools-cli-args.d.ts +57 -0
  92. package/dist/subcommands/handlers/tools-cli.d.ts +5 -0
  93. package/dist/subcommands/handlers/tools-serve.d.ts +4 -0
  94. package/dist/{subcommands-VTMIZQBP.js → subcommands-OCJNO57E.js} +2 -2
  95. package/dist/tool-gateway-http.d.ts +30 -0
  96. package/dist/tool-gateway.d.ts +185 -0
  97. package/dist/tools-cli-44MLIUQO.js +509 -0
  98. package/dist/tools-serve-TRCET2M7.js +102 -0
  99. package/dist/{tools-skills-55QVTMSK.js → tools-skills-WDTMCE46.js} +7 -2
  100. package/dist/tuneup-runtime-checks.d.ts +7 -0
  101. package/dist/tuneup-types.d.ts +118 -0
  102. package/dist/tuneup.d.ts +3 -122
  103. package/dist/{typesafe-YBEADNAH.js → typesafe-QLSMFU7J.js} +1 -1
  104. package/dist/{version-help-RBZC5GZZ.js → version-help-X6CC4CFY.js} +2 -2
  105. package/dist/{webui-server-HIUY3RHD.js → webui-server-V2R5WQUK.js} +79 -3
  106. package/dist/wiring/provider-runtime-setup.d.ts +3 -1
  107. package/dist/wiring/session-runtime.d.ts +1 -1
  108. package/dist/wrongforge-gateway-UOFBK56J.js +92 -0
  109. package/dist/wrongforge-leader/wrongforge-leader-gateway.d.ts +9 -0
  110. package/dist/wrongforge-leader/wrongforge-leader-picker.d.ts +12 -0
  111. package/dist/wrongforge-leader/wrongforge-leader-provider.d.ts +49 -0
  112. package/package.json +34 -30
  113. package/dist/auth-menu/anthropic-oauth.d.ts +0 -43
  114. package/dist/chunk-XT3NAHRX.js +0 -337
  115. package/dist/chunk-ZNNFEKDZ.js +0 -319
  116. package/dist/mcp-2XWBJEQN.js +0 -464
  117. package/dist/short-circuit-flags-CPCT5MWB.js +0 -11
@@ -0,0 +1,254 @@
1
+
2
+ // src/fleet/wrongforge-client.ts
3
+ import { readFileSync } from "node:fs";
4
+ import { homedir } from "node:os";
5
+ import path from "node:path";
6
+ import { toErrorMessage } from "@wrongstack/core/utils";
7
+ var WRONGFORGE_AGENT_ID = "wrongforge";
8
+ var DEFAULT_URL = "http://127.0.0.1:8787";
9
+ var MIN_KEY_LENGTH = 16;
10
+ var POLL_WAIT_MS = 25e3;
11
+ var POLL_LIMIT = 1e3;
12
+ var MAX_POLL_FAILURES = 6;
13
+ var WRONGFORGE_READ_SIDE_TOOLS = [
14
+ "read",
15
+ "ls",
16
+ "glob",
17
+ "grep",
18
+ "web_fetch",
19
+ "todo_read",
20
+ "todo_write",
21
+ "report_progress"
22
+ ];
23
+ var WfHttpError = class extends Error {
24
+ constructor(status, code, message) {
25
+ super(message);
26
+ this.status = status;
27
+ this.code = code;
28
+ }
29
+ status;
30
+ code;
31
+ };
32
+ var WfAborted = class extends Error {
33
+ constructor() {
34
+ super("cancelled by the delegating agent");
35
+ }
36
+ };
37
+ function resolveWrongForgeEndpoint(env = process.env) {
38
+ const url = (env["WRONGFORGE_URL"]?.trim() || DEFAULT_URL).replace(/\/+$/, "");
39
+ let apiKey = env["WRONGFORGE_API_KEY"]?.trim() || env["AGENT_API_KEY"]?.trim();
40
+ if (!apiKey) {
41
+ const home = env["WRONGFORGE_HOME"]?.trim() || path.join(homedir(), ".wrongforge");
42
+ try {
43
+ apiKey = readFileSync(path.join(home, "api-key"), "utf8").replace(/^\uFEFF/, "").trim();
44
+ } catch {
45
+ return void 0;
46
+ }
47
+ }
48
+ return apiKey && apiKey.length >= MIN_KEY_LENGTH ? { url, apiKey } : void 0;
49
+ }
50
+ var safeWfId = (s) => s.replace(/[^A-Za-z0-9._-]/g, "-").slice(0, 80);
51
+ function wrongForgeCall(ep, doFetch = fetch) {
52
+ return async (method, route, body, signal) => {
53
+ let res;
54
+ try {
55
+ res = await doFetch(`${ep.url}${route}`, {
56
+ method,
57
+ headers: {
58
+ authorization: `Bearer ${ep.apiKey}`,
59
+ ...body !== void 0 ? { "content-type": "application/json" } : {}
60
+ },
61
+ ...body !== void 0 ? { body: JSON.stringify(body) } : {},
62
+ ...signal ? { signal } : {}
63
+ });
64
+ } catch (err) {
65
+ if (signal?.aborted) throw new WfAborted();
66
+ throw new WfHttpError(
67
+ 0,
68
+ "unreachable",
69
+ `WrongForge is not reachable at ${ep.url} (${toErrorMessage(err)}); is \`npm run serve\` running?`
70
+ );
71
+ }
72
+ const text = await res.text();
73
+ let parsed;
74
+ try {
75
+ parsed = text ? JSON.parse(text) : {};
76
+ } catch {
77
+ parsed = {};
78
+ }
79
+ if (!res.ok) {
80
+ const e = parsed.error;
81
+ throw new WfHttpError(
82
+ res.status,
83
+ e?.code ?? `http_${res.status}`,
84
+ e?.message ?? text.slice(0, 300)
85
+ );
86
+ }
87
+ return parsed;
88
+ };
89
+ }
90
+ async function* followTask(call, taskId, signal, opts = {}) {
91
+ let after = 0;
92
+ let failures = 0;
93
+ for (; ; ) {
94
+ if (signal.aborted) throw new WfAborted();
95
+ let page;
96
+ try {
97
+ page = await call(
98
+ "GET",
99
+ `/v1/tasks/${encodeURIComponent(taskId)}/events?after=${after}&limit=${POLL_LIMIT}&wait_ms=${POLL_WAIT_MS}`,
100
+ void 0,
101
+ signal
102
+ );
103
+ failures = 0;
104
+ } catch (err) {
105
+ if (signal.aborted || err instanceof WfAborted) throw new WfAborted();
106
+ if (++failures >= MAX_POLL_FAILURES) throw err;
107
+ await sleep(opts.retryDelayMs ?? 2e3, signal);
108
+ continue;
109
+ }
110
+ for (const ev of page.events) yield ev;
111
+ if (page.status) opts.onPoll?.(page.status);
112
+ after = page.next_after;
113
+ if (page.terminal && page.events.length < POLL_LIMIT) return;
114
+ }
115
+ }
116
+ async function terminalTaskRecord(call, taskId, signal, opts = {}) {
117
+ let failures = 0;
118
+ for (; ; ) {
119
+ try {
120
+ return (await call(
121
+ "GET",
122
+ `/v1/tasks/${encodeURIComponent(taskId)}`,
123
+ void 0,
124
+ signal
125
+ )).task;
126
+ } catch (err) {
127
+ if (signal.aborted || err instanceof WfAborted) throw new WfAborted();
128
+ if (++failures >= MAX_POLL_FAILURES) throw err;
129
+ await sleep(opts.retryDelayMs ?? 2e3, signal);
130
+ }
131
+ }
132
+ }
133
+ function cancelTask(call, taskId, reason) {
134
+ void call("POST", `/v1/tasks/${encodeURIComponent(taskId)}/cancel`, { reason }).catch(
135
+ () => void 0
136
+ );
137
+ }
138
+ function chooseModel(requested, agentName, info) {
139
+ const id = requested?.trim();
140
+ if (!id || id === WRONGFORGE_AGENT_ID || id === agentName) return {};
141
+ if (info && info.models.length > 0) {
142
+ if (info.models.includes(id)) return { id };
143
+ return {
144
+ error: `WrongForge does not serve model "${id}"; it serves ${info.models.join(", ")}${info.defaultModel ? ` (default ${info.defaultModel})` : ""}`
145
+ };
146
+ }
147
+ return /^claude-[a-z0-9.-]+$/i.test(id) ? { id } : {};
148
+ }
149
+ function toProgress(ev) {
150
+ const d = ev.data;
151
+ const str = (v) => typeof v === "string" ? v : "";
152
+ const rec = (v) => v === void 0 ? void 0 : v && typeof v === "object" && !Array.isArray(v) ? v : { value: v };
153
+ switch (ev.type) {
154
+ case "task.started":
155
+ return [
156
+ {
157
+ type: "thought",
158
+ text: `[started] WrongForge \xB7 ${str(d["model"]) || "default model"} \xB7 ${str(d["workdir"])}
159
+ `
160
+ }
161
+ ];
162
+ case "task.queued":
163
+ return str(d["waiting_for"]) ? [
164
+ {
165
+ type: "thought",
166
+ text: `[queued] WrongForge is busy (waiting for ${str(d["waiting_for"])})
167
+ `
168
+ }
169
+ ] : [];
170
+ case "agent.text":
171
+ return str(d["text"]) ? [{ type: "message", text: str(d["text"]) }] : [];
172
+ case "agent.report":
173
+ return str(d["message"]) ? [{ type: "thought", text: `[progress] ${str(d["message"])}
174
+ ` }] : [];
175
+ case "tool.started":
176
+ return [
177
+ {
178
+ type: "tool_call",
179
+ toolCall: {
180
+ toolCallId: str(d["tool_call_id"]),
181
+ title: str(d["name"]),
182
+ status: "in_progress",
183
+ rawInput: rec(d["input"])
184
+ }
185
+ }
186
+ ];
187
+ case "tool.finished":
188
+ case "tool.failed": {
189
+ const failed = ev.type === "tool.failed" || d["ok"] === false;
190
+ return [
191
+ {
192
+ type: "tool_call_update",
193
+ toolCall: {
194
+ toolCallId: str(d["tool_call_id"]),
195
+ title: str(d["name"]),
196
+ status: failed ? "failed" : "completed",
197
+ rawOutput: ev.type === "tool.failed" ? { error: d["error"] } : rec(d["output"])
198
+ }
199
+ }
200
+ ];
201
+ }
202
+ case "agent.todos": {
203
+ const todos = Array.isArray(d["todos"]) ? d["todos"] : [];
204
+ return [
205
+ {
206
+ type: "plan",
207
+ entries: todos.map((t) => ({
208
+ content: str(t["content"]),
209
+ priority: "medium",
210
+ status: t["status"] === "completed" || t["status"] === "in_progress" ? t["status"] : "pending"
211
+ }))
212
+ }
213
+ ];
214
+ }
215
+ default:
216
+ return [];
217
+ }
218
+ }
219
+ function wfTokens(usage) {
220
+ return {
221
+ input: usage?.input_tokens ?? 0,
222
+ output: usage?.output_tokens ?? 0,
223
+ cacheRead: usage?.cache_read_tokens ?? 0,
224
+ cacheWrite: usage?.cache_write_tokens ?? 0
225
+ };
226
+ }
227
+ function sleep(ms, signal) {
228
+ return new Promise((resolve) => {
229
+ const t = setTimeout(done, ms);
230
+ function done() {
231
+ clearTimeout(t);
232
+ signal.removeEventListener("abort", done);
233
+ resolve();
234
+ }
235
+ signal.addEventListener("abort", done, { once: true });
236
+ });
237
+ }
238
+
239
+ export {
240
+ WRONGFORGE_AGENT_ID,
241
+ WRONGFORGE_READ_SIDE_TOOLS,
242
+ WfHttpError,
243
+ WfAborted,
244
+ resolveWrongForgeEndpoint,
245
+ safeWfId,
246
+ wrongForgeCall,
247
+ followTask,
248
+ terminalTaskRecord,
249
+ cancelTask,
250
+ chooseModel,
251
+ toProgress,
252
+ wfTokens
253
+ };
254
+ //# sourceMappingURL=chunk-VEESMPTX.js.map
@@ -32,52 +32,6 @@ function clearSuggestions() {
32
32
  sharedAutoSuggestions = [];
33
33
  }
34
34
 
35
- // src/tui-thinking-word.ts
36
- var DEFAULT_TUI_THINKING_WORD = "thinking";
37
- var MAX_TUI_THINKING_WORD_LENGTH = 16;
38
- function normalizeTuiThinkingWord(value) {
39
- if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
40
- const word = value.trim();
41
- if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
42
- return DEFAULT_TUI_THINKING_WORD;
43
- }
44
- if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
45
- return word;
46
- }
47
-
48
- // src/services/run-git.ts
49
- import { spawn } from "node:child_process";
50
- import { toErrorMessage } from "@wrongstack/core/utils";
51
- async function runGit(args, cwd, env) {
52
- try {
53
- return await new Promise((resolve, reject) => {
54
- const child = spawn("git", args, {
55
- cwd,
56
- ...env ? { env: { ...process.env, ...env } } : {},
57
- stdio: ["ignore", "pipe", "pipe"],
58
- signal: AbortSignal.timeout(3e4),
59
- windowsHide: true
60
- });
61
- let stdout = "";
62
- let stderr = "";
63
- child.stdout?.setEncoding("utf8");
64
- child.stderr?.setEncoding("utf8");
65
- child.stdout?.on("data", (d) => {
66
- stdout += d;
67
- });
68
- child.stderr?.on("data", (d) => {
69
- stderr += d;
70
- });
71
- child.on("error", (err) => {
72
- reject(new Error(`Failed to run git: ${err.message}`));
73
- });
74
- child.on("close", (code) => resolve({ stdout, stderr, code: code ?? 1 }));
75
- });
76
- } catch (err) {
77
- throw new Error(toErrorMessage(err));
78
- }
79
- }
80
-
81
35
  // src/hq-fleet-control.ts
82
36
  import {
83
37
  areSubagentsAllowedForSession,
@@ -141,6 +95,52 @@ function createHqFleetControl(getDirector, defaultSessionId, scope) {
141
95
  };
142
96
  }
143
97
 
98
+ // src/tui-thinking-word.ts
99
+ var DEFAULT_TUI_THINKING_WORD = "thinking";
100
+ var MAX_TUI_THINKING_WORD_LENGTH = 16;
101
+ function normalizeTuiThinkingWord(value) {
102
+ if (typeof value !== "string") return DEFAULT_TUI_THINKING_WORD;
103
+ const word = value.trim();
104
+ if (word.length === 0 || word.length > MAX_TUI_THINKING_WORD_LENGTH) {
105
+ return DEFAULT_TUI_THINKING_WORD;
106
+ }
107
+ if (!/^[\p{L}\p{N}_-]+$/u.test(word)) return DEFAULT_TUI_THINKING_WORD;
108
+ return word;
109
+ }
110
+
111
+ // src/services/run-git.ts
112
+ import { spawn } from "node:child_process";
113
+ import { toErrorMessage } from "@wrongstack/core/utils";
114
+ async function runGit(args, cwd, env) {
115
+ try {
116
+ return await new Promise((resolve, reject) => {
117
+ const child = spawn("git", args, {
118
+ cwd,
119
+ ...env ? { env: { ...process.env, ...env } } : {},
120
+ stdio: ["ignore", "pipe", "pipe"],
121
+ signal: AbortSignal.timeout(3e4),
122
+ windowsHide: true
123
+ });
124
+ let stdout = "";
125
+ let stderr = "";
126
+ child.stdout?.setEncoding("utf8");
127
+ child.stderr?.setEncoding("utf8");
128
+ child.stdout?.on("data", (d) => {
129
+ stdout += d;
130
+ });
131
+ child.stderr?.on("data", (d) => {
132
+ stderr += d;
133
+ });
134
+ child.on("error", (err) => {
135
+ reject(new Error(`Failed to run git: ${err.message}`));
136
+ });
137
+ child.on("close", (code) => resolve({ stdout, stderr, code: code ?? 1 }));
138
+ });
139
+ } catch (err) {
140
+ throw new Error(toErrorMessage(err));
141
+ }
142
+ }
143
+
144
144
  export {
145
145
  resolveExecutionMode,
146
146
  setSuggestions,
@@ -156,4 +156,4 @@ export {
156
156
  spawnHqAgent,
157
157
  createHqFleetControl
158
158
  };
159
- //# sourceMappingURL=chunk-IJLIAPCW.js.map
159
+ //# sourceMappingURL=chunk-VPSAKGLK.js.map