@wrongstack/cli 1.0.17 → 1.0.24
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/{acp-INCNOH42.js → acp-AJWSKWE5.js} +18 -7
- package/dist/arg-parser.d.ts +1 -0
- package/dist/{auth-YXK3EDUL.js → auth-GRBZ7Y3D.js} +61 -15
- package/dist/auth-menu/direct.d.ts +1 -0
- package/dist/auth-menu/local.d.ts +2 -0
- package/dist/auth-menu/oauth-menu.d.ts +3 -1
- package/dist/auth-menu/panel-service.d.ts +20 -0
- package/dist/{bench-YBU6BVQP.js → bench-N5K7Z5O3.js} +2 -2
- package/dist/boot/config-backup-recovery.d.ts +2 -1
- package/dist/boot/dispatch-webui.d.ts +11 -0
- package/dist/boot/short-circuit-desktop.d.ts +1 -0
- package/dist/boot/tui-project-picker-callback.d.ts +1 -1
- package/dist/boot/tui-settings-adapter.d.ts +15 -2
- package/dist/{boot-auto-thin-MANHOYHE.js → boot-auto-thin-6Q56FY3F.js} +3 -2
- package/dist/{chunk-6WRKAACA.js → chunk-2BKFWIER.js} +4 -2
- package/dist/{chunk-JY52HWL6.js → chunk-2EBVTYJR.js} +2 -2
- package/dist/chunk-3OCUS3VN.js +46 -0
- package/dist/chunk-424ORSE7.js +56 -0
- package/dist/{chunk-KEPABQYT.js → chunk-5SEYGOCH.js} +8 -82
- package/dist/chunk-BBHWW6LR.js +549 -0
- package/dist/{chunk-CJTBLTS4.js → chunk-BLD5DSVA.js} +4 -3
- package/dist/{chunk-K5PAL6KR.js → chunk-DRM7PSW7.js} +75 -29
- package/dist/{chunk-XJ7K67PP.js → chunk-JF2MULWF.js} +17 -10
- package/dist/{chunk-SIS37L3W.js → chunk-L2RVEQWO.js} +211 -193
- package/dist/{chunk-RDHFXOJM.js → chunk-LFMVHT3R.js} +106 -57
- package/dist/chunk-LUMETJFO.js +171 -0
- package/dist/{chunk-C3Z4N6A6.js → chunk-MHEBWVXL.js} +6 -2
- package/dist/{chunk-VGER3HYZ.js → chunk-PGKJ2OQP.js} +5 -5
- package/dist/{chunk-672UXYL3.js → chunk-QBBF7GIK.js} +2 -2
- package/dist/{chunk-DE7BZDNK.js → chunk-QFPQXKCG.js} +11 -3
- package/dist/chunk-R4QGL6GB.js +10 -0
- package/dist/chunk-S4FFHDJG.js +93 -0
- package/dist/chunk-SFBFYIOW.js +271 -0
- package/dist/{chunk-JX6KL7OF.js → chunk-SKPDE62W.js} +4 -3
- package/dist/{chunk-RMQNCHGO.js → chunk-U46QR4WR.js} +5 -9
- package/dist/{chunk-B4JLSXZB.js → chunk-WSTVGC2C.js} +73 -45
- package/dist/chunk-YBUCXXYZ.js +36 -0
- package/dist/{chunk-2VMJ3E5Z.js → chunk-YTEOAWOJ.js} +6 -2
- package/dist/{chunk-GPPRNAKW.js → chunk-ZMX5HRLI.js} +2 -2
- package/dist/{chunk-YLQEGYV4.js → chunk-ZZRSG7VK.js} +14 -4
- package/dist/{cli-context-4PTWEK52.js → cli-context-34Q5IJRA.js} +121 -89
- package/dist/cli-entry-point.d.ts +2 -0
- package/dist/{cli-main-DQ2GBY7M.js → cli-main-AELJDBGU.js} +1471 -1293
- package/dist/config-doctor.d.ts +10 -2
- package/dist/{config-transfer-2YF3CRTN.js → config-transfer-RUWLDCNK.js} +34 -13
- package/dist/{diag-doctor-ANPRUYFM.js → diag-doctor-WIFJH3XH.js} +2 -2
- package/dist/execute-deps.d.ts +2 -1
- package/dist/{execution-A6WJLSOC.js → execution-PYC5FCS4.js} +303 -256
- package/dist/{hq-NU75W3SE.js → hq-JTUTFI4L.js} +274 -258
- package/dist/hq-command-controller.d.ts +1 -1
- package/dist/hq-server/project-root.d.ts +35 -1
- package/dist/{hq-server-M2JWVW4D.js → hq-server-PC7GZMPT.js} +2 -2
- package/dist/{hq-service-L5INQFM4.js → hq-service-NW56MUP2.js} +11 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -12
- package/dist/kanban-supervisor-67ECABTD.js +7 -0
- package/dist/live-settings-input.d.ts +7 -0
- package/dist/{mailbox-serve-3GFOK2I7.js → mailbox-serve-WDOCH6KR.js} +3 -3
- package/dist/{mcp-DC5WSBOO.js → mcp-LBS45HWZ.js} +4 -4
- package/dist/modeldiag-36OGAL5C.js +828 -0
- package/dist/{per-subcommand-help-DHTYU524.js → per-subcommand-help-XE77MTGJ.js} +3 -3
- package/dist/permission-prompt-mirror.d.ts +1 -1
- package/dist/permission-prompt.d.ts +2 -2
- package/dist/plugin-config.d.ts +12 -0
- package/dist/plugin-management-types.d.ts +31 -0
- package/dist/plugin-management.d.ts +2 -30
- package/dist/plugin-package-install.d.ts +3 -0
- package/dist/{plugin-usage-M6KET4OZ.js → plugin-usage-S5LVGMBW.js} +6 -5
- package/dist/{plugins-WJLW6ULV.js → plugins-RHBIVLI7.js} +4 -3
- package/dist/provider-config-utils.d.ts +1 -6
- package/dist/{providers-models-LFNZ5WI7.js → providers-models-2CFG46RD.js} +41 -31
- package/dist/release-asset-download.d.ts +3 -0
- package/dist/services/dispatch-classifier.d.ts +39 -5
- package/dist/{sessions-config-UL45XKX7.js → sessions-config-IQUH2GXT.js} +13 -5
- package/dist/settings-menu.d.ts +2 -0
- package/dist/short-circuit-flags-SDT53OML.js +10 -0
- package/dist/{simpleui-dist-CXSIDAXZ.js → simpleui-dist-7BQISSEP.js} +7 -3
- package/dist/skill-suggest-L2EVWB6R.js +290 -0
- package/dist/slash-commands/effort.d.ts +1 -1
- package/dist/slash-commands/fallback.d.ts +1 -1
- package/dist/slash-commands/gitid.d.ts +1 -1
- package/dist/slash-commands/jev.d.ts +4 -0
- package/dist/slash-commands/openai-quota.d.ts +15 -0
- package/dist/slash-commands/sdd-task-mutations.d.ts +4 -0
- package/dist/slash-commands/settings-keys.d.ts +2 -0
- package/dist/slash-commands/settings-reset.d.ts +6 -0
- package/dist/standalone-update-MW47J3AK.js +164 -0
- package/dist/standalone-update.d.ts +19 -0
- package/dist/subcommands/handlers/hq-alerts.d.ts +3 -0
- package/dist/subcommands/handlers/hq-audit.d.ts +46 -0
- package/dist/subcommands/handlers/hq-data-dir.d.ts +13 -0
- package/dist/subcommands/handlers/skill-suggest.d.ts +21 -0
- package/dist/subcommands/handlers/typesafe-brain-replay.d.ts +26 -0
- package/dist/subcommands/handlers/typesafe-judgment-check.d.ts +3 -0
- package/dist/subcommands/handlers/typesafe-topic-replay.d.ts +19 -0
- package/dist/subcommands/handlers/typesafe-triage-replay.d.ts +18 -0
- package/dist/subcommands/handlers/typesafe.d.ts +23 -0
- package/dist/{subcommands-ERDDIJ3L.js → subcommands-ZTSIN7LG.js} +2 -2
- package/dist/typesafe-HVEVPA6R.js +316 -0
- package/dist/typesafe-brain-replay-C5276FVR.js +222 -0
- package/dist/typesafe-judgment-check-GGYYV5UF.js +29 -0
- package/dist/typesafe-topic-replay-4W73BOLV.js +218 -0
- package/dist/typesafe-triage-replay-FGAW7QM7.js +215 -0
- package/dist/{update-5DPB4YD4.js → update-7XIOEXTD.js} +4 -3
- package/dist/{update-check-BS3DHTSI.js → update-check-2POMBHFB.js} +3 -2
- package/dist/update-check.d.ts +1 -1
- package/dist/version-help-WZ623NWM.js +10 -0
- package/dist/version.d.ts +3 -2
- package/dist/webui-client-observability.d.ts +7 -0
- package/dist/{webui-server-MRPGTTKL.js → webui-server-L2SICPTB.js} +158 -94
- package/dist/webui-server-options.d.ts +11 -0
- package/dist/webui-server.d.ts +15 -1
- package/dist/wiring/domain-glossary.d.ts +5 -4
- package/dist/wiring/plugins.d.ts +1 -1
- package/dist/wiring/provider-persisters.d.ts +24 -0
- package/dist/wiring/provider-runtime.d.ts +9 -1
- package/dist/wiring/runtime-dispatch-state.d.ts +3 -1
- package/package.json +28 -28
- package/dist/chunk-DR2OXU46.js +0 -174
- package/dist/chunk-JACOMTIH.js +0 -275
- package/dist/chunk-M4W3QLQW.js +0 -54
- package/dist/chunk-XJXDOF63.js +0 -28
- package/dist/modeldiag-CJSFHZ3J.js +0 -1356
- package/dist/short-circuit-flags-SJQBJ33I.js +0 -10
- package/dist/version-help-WXI42PZ3.js +0 -10
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderForId
|
|
3
|
+
} from "./chunk-BBHWW6LR.js";
|
|
4
|
+
|
|
5
|
+
// src/subcommands/handlers/typesafe-topic-replay.ts
|
|
6
|
+
import { readdir, readFile } from "node:fs/promises";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { promisify } from "node:util";
|
|
9
|
+
import { gunzip } from "node:zlib";
|
|
10
|
+
import { TopicShiftAdvisor } from "@wrongstack/core/execution";
|
|
11
|
+
import { resolveTypeSafeAccount } from "@wrongstack/core/typesafe";
|
|
12
|
+
import { color } from "@wrongstack/core/utils";
|
|
13
|
+
var gunzipAsync = promisify(gunzip);
|
|
14
|
+
function textOf(content) {
|
|
15
|
+
if (typeof content === "string") return content;
|
|
16
|
+
if (!Array.isArray(content)) return "";
|
|
17
|
+
return content.filter((b) => b?.type === "text").map((b) => b.text).join("\n");
|
|
18
|
+
}
|
|
19
|
+
async function sessionFiles(root) {
|
|
20
|
+
const out = [];
|
|
21
|
+
let days;
|
|
22
|
+
try {
|
|
23
|
+
days = await readdir(root);
|
|
24
|
+
} catch {
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
for (const day of days.sort()) {
|
|
28
|
+
let entries;
|
|
29
|
+
try {
|
|
30
|
+
entries = await readdir(path.join(root, day));
|
|
31
|
+
} catch {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
for (const name of entries.sort()) {
|
|
35
|
+
if (/^sess_[^.]+\.jsonl(\.gz)?$/.test(name)) out.push(path.join(root, day, name));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
async function promptPoints(file) {
|
|
41
|
+
const buf = await readFile(file);
|
|
42
|
+
const raw = file.endsWith(".gz") ? (await gunzipAsync(buf)).toString("utf8") : buf.toString("utf8");
|
|
43
|
+
const messages = [];
|
|
44
|
+
const points = [];
|
|
45
|
+
let contextTokens;
|
|
46
|
+
let previousPrompt = "";
|
|
47
|
+
for (const line of raw.split("\n")) {
|
|
48
|
+
if (!line.trim()) continue;
|
|
49
|
+
let e;
|
|
50
|
+
try {
|
|
51
|
+
e = JSON.parse(line);
|
|
52
|
+
} catch {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (e["type"] === "llm_request" && typeof e["estimatedInputTokens"] === "number") {
|
|
56
|
+
contextTokens = e["estimatedInputTokens"];
|
|
57
|
+
} else if (e["type"] === "user_input") {
|
|
58
|
+
const prompt = textOf(e["content"]).trim();
|
|
59
|
+
if (prompt) {
|
|
60
|
+
points.push({
|
|
61
|
+
session: path.basename(file).replace(/\.jsonl(\.gz)?$/, ""),
|
|
62
|
+
prompt,
|
|
63
|
+
previousPrompt,
|
|
64
|
+
messages: [...messages],
|
|
65
|
+
contextTokens
|
|
66
|
+
});
|
|
67
|
+
previousPrompt = prompt;
|
|
68
|
+
}
|
|
69
|
+
} else if (e["type"] === "message_appended") {
|
|
70
|
+
const m = e["message"];
|
|
71
|
+
if (m && (m.role === "user" || m.role === "assistant")) {
|
|
72
|
+
const text = textOf(m.content).trim();
|
|
73
|
+
if (text) messages.push({ role: m.role, content: text });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return points;
|
|
78
|
+
}
|
|
79
|
+
async function replayTopicShift(deps, write) {
|
|
80
|
+
const flags = deps.flags ?? {};
|
|
81
|
+
const json = flags["json"] === true;
|
|
82
|
+
const account = resolveTypeSafeAccount({ config: deps.config, restGate: null });
|
|
83
|
+
if (account.status !== "ready") {
|
|
84
|
+
write(`${color.red("\u2717")} ${account.reason}. Run \`wstack typesafe login\`.`);
|
|
85
|
+
return 2;
|
|
86
|
+
}
|
|
87
|
+
const limit = Math.max(1, Number(flags["limit"]) || 40);
|
|
88
|
+
const maxContext = Math.max(1, Number(flags["max-context"]) || 2e5);
|
|
89
|
+
const sessionsRoot = typeof flags["sessions"] === "string" ? path.resolve(flags["sessions"]) : path.join(deps.paths.projectDir, "sessions");
|
|
90
|
+
const providerId = typeof flags["provider"] === "string" ? flags["provider"] : deps.config.provider;
|
|
91
|
+
const model = typeof flags["model"] === "string" ? flags["model"] : deps.config.model;
|
|
92
|
+
const provider = flags["no-llm"] === true ? void 0 : createProviderForId(providerId, deps.config);
|
|
93
|
+
const judge = { client: account.client, model: account.model, feature: "topicShift" };
|
|
94
|
+
const reached = [];
|
|
95
|
+
let scanned = 0;
|
|
96
|
+
const files = await sessionFiles(sessionsRoot);
|
|
97
|
+
for (const file of files.reverse()) {
|
|
98
|
+
if (reached.length >= limit) break;
|
|
99
|
+
let points;
|
|
100
|
+
try {
|
|
101
|
+
points = await promptPoints(file);
|
|
102
|
+
} catch {
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
for (const point of points) {
|
|
106
|
+
if (reached.length >= limit) break;
|
|
107
|
+
scanned++;
|
|
108
|
+
let gate = false;
|
|
109
|
+
let jevNoul;
|
|
110
|
+
let jevError;
|
|
111
|
+
const jevAdvisor = new TopicShiftAdvisor({
|
|
112
|
+
getJudge: () => judge,
|
|
113
|
+
onDiagnostic: (d) => {
|
|
114
|
+
if (d.stage === "gate") gate = true;
|
|
115
|
+
if (d.stage === "system-one") {
|
|
116
|
+
jevNoul = d.noul;
|
|
117
|
+
jevError = d.error;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
await jevAdvisor.advise({
|
|
122
|
+
prompt: point.prompt,
|
|
123
|
+
messages: point.messages,
|
|
124
|
+
contextTokens: point.contextTokens,
|
|
125
|
+
maxContext
|
|
126
|
+
});
|
|
127
|
+
if (!gate) continue;
|
|
128
|
+
const c = { ...point, jevNoul, jevError };
|
|
129
|
+
if (provider?.complete) {
|
|
130
|
+
let failure;
|
|
131
|
+
const llmAdvisor = new TopicShiftAdvisor({
|
|
132
|
+
onDiagnostic: (d) => {
|
|
133
|
+
if (d.stage === "model" && !d.parsed) {
|
|
134
|
+
failure = d.error ?? (d.text?.trim() ? "unparseable reply" : "empty reply");
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const advice = await llmAdvisor.advise({
|
|
139
|
+
prompt: point.prompt,
|
|
140
|
+
messages: point.messages,
|
|
141
|
+
provider,
|
|
142
|
+
model,
|
|
143
|
+
contextTokens: point.contextTokens,
|
|
144
|
+
maxContext
|
|
145
|
+
});
|
|
146
|
+
if (advice.source === "model") {
|
|
147
|
+
c.llm = advice.suggestNewContext ? "new" : "same";
|
|
148
|
+
c.llmConfidence = advice.confidence;
|
|
149
|
+
} else {
|
|
150
|
+
c.llmFailure = failure ?? `no model answer (${advice.source})`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
reached.push(c);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const bucket = (n) => n === void 0 ? "none" : n >= 0.8 ? "new" : n <= 0.3 ? "same" : "unsure";
|
|
157
|
+
if (json) {
|
|
158
|
+
write(
|
|
159
|
+
JSON.stringify(
|
|
160
|
+
{
|
|
161
|
+
sessionsRoot,
|
|
162
|
+
scanned,
|
|
163
|
+
llm: provider ? `${providerId}/${model}` : null,
|
|
164
|
+
cases: reached.map((c) => ({
|
|
165
|
+
session: c.session,
|
|
166
|
+
previousPrompt: c.previousPrompt.slice(0, 200),
|
|
167
|
+
prompt: c.prompt.slice(0, 300),
|
|
168
|
+
jev: c.jevNoul === void 0 ? null : Number(c.jevNoul.toFixed(3)),
|
|
169
|
+
jevBucket: bucket(c.jevNoul),
|
|
170
|
+
jevError: c.jevError,
|
|
171
|
+
llm: c.llm ?? null,
|
|
172
|
+
llmConfidence: c.llmConfidence,
|
|
173
|
+
llmFailure: c.llmFailure
|
|
174
|
+
}))
|
|
175
|
+
},
|
|
176
|
+
null,
|
|
177
|
+
2
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
const pct = (a, b) => b === 0 ? "\u2014" : `${Math.round(a / b * 100)}%`;
|
|
183
|
+
const count = (b) => reached.filter((c) => bucket(c.jevNoul) === b).length;
|
|
184
|
+
write(
|
|
185
|
+
color.dim(
|
|
186
|
+
`${scanned} prompt(s) scanned in ${files.length} session file(s); ${reached.length} passed the local gate and reached a classifier`
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
write(color.bold("Jev"));
|
|
190
|
+
write(
|
|
191
|
+
` new ${count("new")} same ${count("same")} unsure\u2192provider ${count("unsure")} no answer ${count("none")}`
|
|
192
|
+
);
|
|
193
|
+
if (provider) {
|
|
194
|
+
const answered = reached.filter((c) => c.llm);
|
|
195
|
+
write(color.bold(`Provider classifier (${providerId}/${model}, production request shape)`));
|
|
196
|
+
write(
|
|
197
|
+
` answered ${answered.length}/${reached.length} new ${answered.filter((c) => c.llm === "new").length} same ${answered.filter((c) => c.llm === "same").length}`
|
|
198
|
+
);
|
|
199
|
+
const failures = /* @__PURE__ */ new Map();
|
|
200
|
+
for (const c of reached) {
|
|
201
|
+
if (c.llmFailure) failures.set(c.llmFailure, (failures.get(c.llmFailure) ?? 0) + 1);
|
|
202
|
+
}
|
|
203
|
+
for (const [reason, n] of failures) write(color.amber(` ${n}\xD7 ${reason.slice(0, 100)}`));
|
|
204
|
+
const both = reached.filter((c) => c.llm && ["new", "same"].includes(bucket(c.jevNoul)));
|
|
205
|
+
write(
|
|
206
|
+
` agreement where Jev is decisive: ${pct(
|
|
207
|
+
both.filter((c) => bucket(c.jevNoul) === c.llm).length,
|
|
208
|
+
both.length
|
|
209
|
+
)} of ${both.length}`
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
write(color.dim(`model ${account.model}`));
|
|
213
|
+
return 0;
|
|
214
|
+
}
|
|
215
|
+
export {
|
|
216
|
+
replayTopicShift
|
|
217
|
+
};
|
|
218
|
+
//# sourceMappingURL=typesafe-topic-replay-4W73BOLV.js.map
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createProviderForId
|
|
3
|
+
} from "./chunk-BBHWW6LR.js";
|
|
4
|
+
|
|
5
|
+
// src/subcommands/handlers/typesafe-triage-replay.ts
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { resolveTypeSafeAccount } from "@wrongstack/core/typesafe";
|
|
8
|
+
import { color } from "@wrongstack/core/utils";
|
|
9
|
+
import { loadRuntimeDatabaseSync } from "@wrongstack/persistence";
|
|
10
|
+
import {
|
|
11
|
+
computeValueScore,
|
|
12
|
+
evaluateMemory,
|
|
13
|
+
preFilterBatch,
|
|
14
|
+
probeMemoryValue
|
|
15
|
+
} from "@wrongstack/sage";
|
|
16
|
+
var SYSTEM_ONE_MIN_CONFIDENCE = 0.55;
|
|
17
|
+
var SYSTEM_ONE_MIN_PROBABILITY = 0.5;
|
|
18
|
+
async function loadMemories(dbPath) {
|
|
19
|
+
const Database = loadRuntimeDatabaseSync();
|
|
20
|
+
const db = new Database(dbPath, { readOnly: true });
|
|
21
|
+
try {
|
|
22
|
+
const rows = db.prepare("SELECT data FROM memories WHERE status IN ('active', 'stale')").all();
|
|
23
|
+
const out = [];
|
|
24
|
+
for (const row of rows) {
|
|
25
|
+
try {
|
|
26
|
+
out.push(JSON.parse(row.data));
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return out;
|
|
31
|
+
} finally {
|
|
32
|
+
db.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function actionFor(memory, score) {
|
|
36
|
+
const vs = computeValueScore(memory);
|
|
37
|
+
const result = await evaluateMemory(memory, vs, async () => `${score} | calibration`);
|
|
38
|
+
return result.action === "keep_llm_override" ? "keep" : result.action;
|
|
39
|
+
}
|
|
40
|
+
async function replayMemoryTriage(deps, write) {
|
|
41
|
+
const flags = deps.flags ?? {};
|
|
42
|
+
const account = resolveTypeSafeAccount({ config: deps.config, restGate: null });
|
|
43
|
+
if (account.status !== "ready") {
|
|
44
|
+
write(`${color.red("\u2717")} ${account.reason}. Run \`wstack typesafe login\`.`);
|
|
45
|
+
return 2;
|
|
46
|
+
}
|
|
47
|
+
const limit = Math.max(1, Number(flags["limit"]) || 40);
|
|
48
|
+
const useLlm = flags["no-llm"] !== true;
|
|
49
|
+
const storageDir = deps.config.Sage?.storage?.directory;
|
|
50
|
+
const dbPath = path.resolve(
|
|
51
|
+
deps.projectRoot,
|
|
52
|
+
storageDir && typeof storageDir === "string" ? storageDir : path.join(".wrongstack", "memories"),
|
|
53
|
+
"sage.db"
|
|
54
|
+
);
|
|
55
|
+
let memories;
|
|
56
|
+
try {
|
|
57
|
+
memories = await loadMemories(dbPath);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
write(`${color.red("\u2717")} cannot open ${dbPath}: ${err.message}`);
|
|
60
|
+
return 2;
|
|
61
|
+
}
|
|
62
|
+
const { uncertain } = preFilterBatch(memories);
|
|
63
|
+
const gray = uncertain.map((memory) => ({ memory, vs: computeValueScore(memory) })).filter((x) => x.vs.band === "gray");
|
|
64
|
+
const step = Math.max(1, gray.length / limit);
|
|
65
|
+
const cases = [];
|
|
66
|
+
for (let i = 0; i < gray.length && cases.length < limit; i += step) {
|
|
67
|
+
const pick = gray[Math.floor(i)];
|
|
68
|
+
if (pick) cases.push({ memory: pick.memory, vsTotal: pick.vs.total });
|
|
69
|
+
}
|
|
70
|
+
if (flags["json"] !== true)
|
|
71
|
+
write(
|
|
72
|
+
color.dim(
|
|
73
|
+
`${memories.length} memories, ${gray.length} in the gray zone; replaying ${cases.length}` + (useLlm ? " with the LLM reference" : " (Jev only)")
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
if (cases.length === 0) return 0;
|
|
77
|
+
let callLlm;
|
|
78
|
+
let llmLabel = "";
|
|
79
|
+
if (useLlm) {
|
|
80
|
+
const providerId = typeof flags["provider"] === "string" ? flags["provider"] : deps.config.provider;
|
|
81
|
+
const model = typeof flags["model"] === "string" ? flags["model"] : deps.config.model;
|
|
82
|
+
const provider = createProviderForId(
|
|
83
|
+
providerId,
|
|
84
|
+
deps.config
|
|
85
|
+
);
|
|
86
|
+
if (!provider?.complete) {
|
|
87
|
+
write(
|
|
88
|
+
color.amber(
|
|
89
|
+
`! cannot build provider "${providerId}" here; use --provider/--model or --no-llm.`
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
return 2;
|
|
93
|
+
}
|
|
94
|
+
llmLabel = `${providerId}/${model}`;
|
|
95
|
+
callLlm = async (system, user) => {
|
|
96
|
+
const response = await provider.complete(
|
|
97
|
+
{
|
|
98
|
+
model,
|
|
99
|
+
system: [{ type: "text", text: system }],
|
|
100
|
+
messages: [{ role: "user", content: user }],
|
|
101
|
+
// 60 is what `/memory triage` sends; --llm-max-tokens shows whether
|
|
102
|
+
// a reasoning model needs more room to produce any answer at all.
|
|
103
|
+
maxTokens: Math.max(16, Number(flags["llm-max-tokens"]) || 60),
|
|
104
|
+
temperature: 0.1
|
|
105
|
+
},
|
|
106
|
+
{ signal: AbortSignal.timeout(6e4) }
|
|
107
|
+
);
|
|
108
|
+
return response.content.filter((b) => b.type === "text").map((b) => b.text).join("").trim();
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const judge = { client: account.client, model: account.model, feature: "memoryTriage" };
|
|
112
|
+
const CONCURRENCY = 6;
|
|
113
|
+
for (let i = 0; i < cases.length; i += CONCURRENCY) {
|
|
114
|
+
await Promise.all(
|
|
115
|
+
cases.slice(i, i + CONCURRENCY).map(async (c) => {
|
|
116
|
+
try {
|
|
117
|
+
c.jev = await probeMemoryValue(judge, c.memory);
|
|
118
|
+
if (c.jev) c.jevAction = await actionFor(c.memory, c.jev.score);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
c.error = `jev: ${err instanceof Error ? err.message : String(err)}`;
|
|
121
|
+
}
|
|
122
|
+
if (!callLlm) return;
|
|
123
|
+
try {
|
|
124
|
+
const r = await evaluateMemory(c.memory, computeValueScore(c.memory), callLlm);
|
|
125
|
+
if (r.evaluation.ok) {
|
|
126
|
+
c.llmScore = r.evaluation.score;
|
|
127
|
+
c.llmAction = r.action === "keep_llm_override" ? "keep" : r.action;
|
|
128
|
+
} else {
|
|
129
|
+
c.error = `llm: ${r.evaluation.error ?? "no score"}`;
|
|
130
|
+
}
|
|
131
|
+
} catch (err) {
|
|
132
|
+
c.error = `llm: ${err instanceof Error ? err.message : String(err)}`;
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
const judged = cases.filter((c) => c.jev);
|
|
138
|
+
const both = judged.filter((c) => c.llmScore !== void 0);
|
|
139
|
+
const settles = (c, minConfidence) => !!c.jev && c.jev.confidence >= minConfidence && c.jev.probability >= SYSTEM_ONE_MIN_PROBABILITY;
|
|
140
|
+
const pct = (a, b) => b === 0 ? "\u2014" : `${Math.round(a / b * 100)}%`;
|
|
141
|
+
if (flags["json"] === true) {
|
|
142
|
+
write(
|
|
143
|
+
JSON.stringify(
|
|
144
|
+
{
|
|
145
|
+
db: dbPath,
|
|
146
|
+
llm: llmLabel || null,
|
|
147
|
+
model: judged[0]?.jev?.model,
|
|
148
|
+
cases: cases.map((c) => ({
|
|
149
|
+
id: c.memory.id,
|
|
150
|
+
text: c.memory.text.slice(0, 160),
|
|
151
|
+
phase2: c.vsTotal,
|
|
152
|
+
jev: c.jev ? {
|
|
153
|
+
score: c.jev.score,
|
|
154
|
+
p: Number(c.jev.probability.toFixed(3)),
|
|
155
|
+
confidence: Number(c.jev.confidence.toFixed(3)),
|
|
156
|
+
action: c.jevAction
|
|
157
|
+
} : null,
|
|
158
|
+
llm: c.llmScore !== void 0 ? { score: c.llmScore, action: c.llmAction } : null,
|
|
159
|
+
error: c.error
|
|
160
|
+
}))
|
|
161
|
+
},
|
|
162
|
+
null,
|
|
163
|
+
2
|
|
164
|
+
)
|
|
165
|
+
);
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
write("");
|
|
169
|
+
write(color.bold("Jev rating distribution"));
|
|
170
|
+
const dist = [1, 2, 3, 4, 5].map((s) => judged.filter((c) => c.jev.score === s).length);
|
|
171
|
+
write(` 1:${dist[0]} 2:${dist[1]} 3:${dist[2]} 4:${dist[3]} 5:${dist[4]}`);
|
|
172
|
+
if (both.length > 0) {
|
|
173
|
+
write(color.bold(`Jev vs LLM (${llmLabel}), n=${both.length}`));
|
|
174
|
+
write(
|
|
175
|
+
` rating exact ${pct(both.filter((c) => c.jev.score === c.llmScore).length, both.length)}`
|
|
176
|
+
);
|
|
177
|
+
write(
|
|
178
|
+
` rating \xB11 ${pct(both.filter((c) => Math.abs(c.jev.score - c.llmScore) <= 1).length, both.length)}`
|
|
179
|
+
);
|
|
180
|
+
write(
|
|
181
|
+
` same action ${pct(both.filter((c) => c.jevAction === c.llmAction).length, both.length)}`
|
|
182
|
+
);
|
|
183
|
+
write(" matrix (rows Jev 1-5, cols LLM 1-5)");
|
|
184
|
+
for (let j = 1; j <= 5; j++) {
|
|
185
|
+
const row = [1, 2, 3, 4, 5].map(
|
|
186
|
+
(l) => both.filter((c) => c.jev.score === j && c.llmScore === l).length
|
|
187
|
+
);
|
|
188
|
+
write(` ${j}: ${row.map((n) => String(n).padStart(3)).join("")}`);
|
|
189
|
+
}
|
|
190
|
+
write("");
|
|
191
|
+
write(color.bold("Sweep (confidence threshold, p \u2265 0.5): settles / same action"));
|
|
192
|
+
for (const t of [0.3, 0.4, 0.5, 0.55, 0.6, 0.7, 0.8]) {
|
|
193
|
+
const s = both.filter((c) => settles(c, t));
|
|
194
|
+
write(
|
|
195
|
+
` conf \u2265 ${t.toFixed(2)}${t === SYSTEM_ONE_MIN_CONFIDENCE ? " (current)" : " "} ${pct(s.length, both.length).padStart(4)} ${pct(
|
|
196
|
+
s.filter((c) => c.jevAction === c.llmAction).length,
|
|
197
|
+
s.length
|
|
198
|
+
)}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
const s = judged.filter((c) => settles(c, SYSTEM_ONE_MIN_CONFIDENCE));
|
|
203
|
+
write(` settles at current thresholds: ${pct(s.length, judged.length)}`);
|
|
204
|
+
}
|
|
205
|
+
const errors = cases.filter((c) => c.error);
|
|
206
|
+
if (errors.length > 0) {
|
|
207
|
+
write(color.amber(`${errors.length} case(s) with errors, e.g. ${errors[0]?.error}`));
|
|
208
|
+
}
|
|
209
|
+
write(color.dim(`model ${judged[0]?.jev?.model ?? account.model}`));
|
|
210
|
+
return 0;
|
|
211
|
+
}
|
|
212
|
+
export {
|
|
213
|
+
replayMemoryTriage
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=typesafe-triage-replay-FGAW7QM7.js.map
|
|
@@ -3,13 +3,14 @@ import {
|
|
|
3
3
|
detectUpdatePackageName,
|
|
4
4
|
runUpdateCommand,
|
|
5
5
|
updateCmd
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-QFPQXKCG.js";
|
|
7
7
|
import "./chunk-U3SS4NRH.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-ZZRSG7VK.js";
|
|
9
|
+
import "./chunk-YBUCXXYZ.js";
|
|
9
10
|
export {
|
|
10
11
|
detectUpdatePackageManager,
|
|
11
12
|
detectUpdatePackageName,
|
|
12
13
|
runUpdateCommand,
|
|
13
14
|
updateCmd
|
|
14
15
|
};
|
|
15
|
-
//# sourceMappingURL=update-
|
|
16
|
+
//# sourceMappingURL=update-7XIOEXTD.js.map
|
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
fetchLatestFromNpm,
|
|
6
6
|
getUpdateNotification,
|
|
7
7
|
isNewer
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZZRSG7VK.js";
|
|
9
|
+
import "./chunk-YBUCXXYZ.js";
|
|
9
10
|
export {
|
|
10
11
|
cachePath,
|
|
11
12
|
checkForUpdate,
|
|
@@ -14,4 +15,4 @@ export {
|
|
|
14
15
|
getUpdateNotification,
|
|
15
16
|
isNewer
|
|
16
17
|
};
|
|
17
|
-
//# sourceMappingURL=update-check-
|
|
18
|
+
//# sourceMappingURL=update-check-2POMBHFB.js.map
|
package/dist/update-check.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ type HomeDirFn = () => string;
|
|
|
8
8
|
export type UpdatePackageName = 'wrongstack' | '@wrongstack/cli';
|
|
9
9
|
/** Cache file path — homeFn is injectable for testing */
|
|
10
10
|
export declare function cachePath(homeFn?: HomeDirFn): string;
|
|
11
|
-
/** Read the current CLI version from package.json */
|
|
11
|
+
/** Read the current CLI version from package.json (or the binary's build stamp). */
|
|
12
12
|
export declare function currentVersion(): string;
|
|
13
13
|
/** SemVer comparison — returns true if a > b. Invalid versions are never considered newer. */
|
|
14
14
|
export declare function isNewer(a: string, b: string): boolean;
|
package/dist/version.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const CLI_VERSION: string;
|
|
2
|
-
declare
|
|
3
|
-
|
|
2
|
+
export declare const API_VERSION: string;
|
|
3
|
+
/** Build target of the standalone executable; undefined in an npm install. */
|
|
4
|
+
export declare const STANDALONE_TARGET: string | undefined;
|
|
4
5
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type SessionAgentRegistry, startWebUILiveStatusLogger } from '@wrongstack/webui-server';
|
|
2
|
+
import type { WebSocket } from 'ws';
|
|
3
|
+
import type { ConnectedClient } from './webui-server/connection-handler.js';
|
|
4
|
+
import type { CliWebUIOptions } from './webui-server-options.js';
|
|
5
|
+
export declare function createEmbeddedClientRegistration(opts: CliWebUIOptions, clients: Map<WebSocket, ConnectedClient>, abortControllers: Map<string, AbortController>, getSessionAgents: () => SessionAgentRegistry | undefined): import("./webui-server/client-registration.js").WebuiClientRegistration;
|
|
6
|
+
export declare function startEmbeddedLiveStatusLogger(opts: CliWebUIOptions, clients: Map<WebSocket, ConnectedClient>, abortControllers: Map<string, AbortController>, getSessionAgents: () => SessionAgentRegistry | undefined, terminalLogView: Parameters<typeof startWebUILiveStatusLogger>[0]['dashboard']): () => void;
|
|
7
|
+
//# sourceMappingURL=webui-client-observability.d.ts.map
|