@wrongstack/cli 0.313.0 → 0.313.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.
|
@@ -5203,7 +5203,7 @@ async function runCliExecution(params) {
|
|
|
5203
5203
|
governanceHandle,
|
|
5204
5204
|
setConfig
|
|
5205
5205
|
} = params;
|
|
5206
|
-
const { execute } = await import("./execution-
|
|
5206
|
+
const { execute } = await import("./execution-L4CXQEND.js");
|
|
5207
5207
|
return execute(
|
|
5208
5208
|
toExecuteDeps({
|
|
5209
5209
|
core: {
|
|
@@ -23858,7 +23858,57 @@ var THEME_META = {
|
|
|
23858
23858
|
},
|
|
23859
23859
|
aura: { name: "Aura Dark", desc: "Vivid purple and spring green on near-black violet" },
|
|
23860
23860
|
"dark-plus": { name: "VS Code Dark+", desc: "VS Code's default \u2014 familiar blue/orange/teal" },
|
|
23861
|
-
monochrome: { name: "Monochrome", desc: "Pure grayscale \u2014 no hue, only luminance" }
|
|
23861
|
+
monochrome: { name: "Monochrome", desc: "Pure grayscale \u2014 no hue, only luminance" },
|
|
23862
|
+
matrix: { name: "Matrix Green", desc: "Phosphor green CRT terminal \u2014 digital rain aesthetic" },
|
|
23863
|
+
amber: { name: "Amber CRT", desc: "Warm phosphor CRT terminal \u2014 glowing vintage amber" },
|
|
23864
|
+
"cyber-noir": {
|
|
23865
|
+
name: "Cyber Noir",
|
|
23866
|
+
desc: "Stark white and slate on jet black \u2014 minimalist high contrast"
|
|
23867
|
+
},
|
|
23868
|
+
"cobalt-mono": {
|
|
23869
|
+
name: "Cobalt Monochrome",
|
|
23870
|
+
desc: "Luminous cyan on deep abyss blue \u2014 oceanic blueprint"
|
|
23871
|
+
},
|
|
23872
|
+
"blood-moon": {
|
|
23873
|
+
name: "Blood Moon",
|
|
23874
|
+
desc: "Crimson & scarlet on obsidian \u2014 brooding dark mode"
|
|
23875
|
+
},
|
|
23876
|
+
cobalt2: {
|
|
23877
|
+
name: "Cobalt2",
|
|
23878
|
+
desc: "Wes Bos' signature theme \u2014 deep navy with golden yellow & cyan"
|
|
23879
|
+
},
|
|
23880
|
+
"shades-of-purple": {
|
|
23881
|
+
name: "Shades of Purple",
|
|
23882
|
+
desc: "Ahmad Awais' bold purple palette with neon yellow & magenta"
|
|
23883
|
+
},
|
|
23884
|
+
"flexoki-dark": {
|
|
23885
|
+
name: "Flexoki Dark",
|
|
23886
|
+
desc: "Steph Ango's inky warm paper palette \u2014 natural earthy accents"
|
|
23887
|
+
},
|
|
23888
|
+
laserwave: {
|
|
23889
|
+
name: "LaserWave",
|
|
23890
|
+
desc: "80s retrowave \u2014 neon flamingo and turquoise on violet"
|
|
23891
|
+
},
|
|
23892
|
+
andromeda: {
|
|
23893
|
+
name: "Andromeda",
|
|
23894
|
+
desc: "Deep interstellar dark with vibrant neon teal and pink"
|
|
23895
|
+
},
|
|
23896
|
+
"github-dark-dimmed": {
|
|
23897
|
+
name: "GitHub Dark Dimmed",
|
|
23898
|
+
desc: "GitHub's softer slate dark theme \u2014 gentle blues and pastels"
|
|
23899
|
+
},
|
|
23900
|
+
snazzy: {
|
|
23901
|
+
name: "Hyper Snazzy",
|
|
23902
|
+
desc: "Sindre Sorhus' elegant saturated terminal palette"
|
|
23903
|
+
},
|
|
23904
|
+
"tokyo-night-moon": {
|
|
23905
|
+
name: "Tokyo Night Moon",
|
|
23906
|
+
desc: "Tokyo Night on balanced deep indigo \u2014 vibrant accents"
|
|
23907
|
+
},
|
|
23908
|
+
"gruvbox-dark-hard": {
|
|
23909
|
+
name: "Gruvbox Dark Hard",
|
|
23910
|
+
desc: "Maximum contrast Gruvbox on deep pitch charcoal"
|
|
23911
|
+
}
|
|
23862
23912
|
};
|
|
23863
23913
|
var THEME_OPTIONS = THEME_PRESET_IDS.map((id) => ({ id, ...THEME_META[id] }));
|
|
23864
23914
|
function presetHelpLines(perLine = 4) {
|
|
@@ -26553,6 +26603,59 @@ function parseFlags2(args) {
|
|
|
26553
26603
|
);
|
|
26554
26604
|
}
|
|
26555
26605
|
|
|
26606
|
+
// src/slash-commands/sidebar.ts
|
|
26607
|
+
import { color as color57 } from "@wrongstack/core/utils";
|
|
26608
|
+
function buildSidebarCommand(opts) {
|
|
26609
|
+
return {
|
|
26610
|
+
name: "sidebar",
|
|
26611
|
+
category: "Config",
|
|
26612
|
+
description: "Toggle or configure the TUI right sidebar visibility.",
|
|
26613
|
+
help: [
|
|
26614
|
+
"Usage:",
|
|
26615
|
+
" /sidebar Toggle the right sidebar on/off",
|
|
26616
|
+
" /sidebar on Show the right sidebar",
|
|
26617
|
+
" /sidebar off Hide the right sidebar (chat uses full terminal width)",
|
|
26618
|
+
" /sidebar status Show current sidebar visibility"
|
|
26619
|
+
].join("\n"),
|
|
26620
|
+
async run(args) {
|
|
26621
|
+
const { cmd } = parseSubcommand(args);
|
|
26622
|
+
const sub = cmd.toLowerCase();
|
|
26623
|
+
if (sub === "help" || sub === "--help") {
|
|
26624
|
+
return { message: this.help ?? "" };
|
|
26625
|
+
}
|
|
26626
|
+
if (!opts.configStore) {
|
|
26627
|
+
return { message: `${color57.red("Error")} config store not available.` };
|
|
26628
|
+
}
|
|
26629
|
+
const current = opts.configStore.get().autonomy?.showSidebar ?? true;
|
|
26630
|
+
let next;
|
|
26631
|
+
if (!sub || sub === "toggle") {
|
|
26632
|
+
next = !current;
|
|
26633
|
+
} else if (sub === "on" || sub === "true" || sub === "1" || sub === "show") {
|
|
26634
|
+
next = true;
|
|
26635
|
+
} else if (sub === "off" || sub === "false" || sub === "0" || sub === "hide") {
|
|
26636
|
+
next = false;
|
|
26637
|
+
} else if (sub === "status") {
|
|
26638
|
+
return {
|
|
26639
|
+
message: `Right sidebar is currently ${current ? color57.green("on") : color57.yellow("off")}.`
|
|
26640
|
+
};
|
|
26641
|
+
} else {
|
|
26642
|
+
return {
|
|
26643
|
+
message: `Unknown argument "${sub}". Use \`/sidebar on\`, \`/sidebar off\`, or \`/sidebar\`.`
|
|
26644
|
+
};
|
|
26645
|
+
}
|
|
26646
|
+
opts.configStore.update({
|
|
26647
|
+
autonomy: {
|
|
26648
|
+
...opts.configStore.get().autonomy ?? {},
|
|
26649
|
+
showSidebar: next
|
|
26650
|
+
}
|
|
26651
|
+
});
|
|
26652
|
+
return {
|
|
26653
|
+
message: `Right sidebar is now ${next ? color57.green("on") : color57.yellow("off")}.`
|
|
26654
|
+
};
|
|
26655
|
+
}
|
|
26656
|
+
};
|
|
26657
|
+
}
|
|
26658
|
+
|
|
26556
26659
|
// src/slash-commands/spawn-agents.ts
|
|
26557
26660
|
import { toErrorMessage as toErrorMessage24 } from "@wrongstack/core/utils";
|
|
26558
26661
|
function buildSpawnCommand(opts) {
|
|
@@ -26760,7 +26863,7 @@ function buildStatuslineCommand(deps) {
|
|
|
26760
26863
|
}
|
|
26761
26864
|
|
|
26762
26865
|
// src/slash-commands/supervisor.ts
|
|
26763
|
-
import { color as
|
|
26866
|
+
import { color as color58 } from "@wrongstack/core/utils";
|
|
26764
26867
|
function fmtAge4(at) {
|
|
26765
26868
|
const s = Math.max(0, Math.round((Date.now() - at) / 1e3));
|
|
26766
26869
|
if (s < 60) return `${s}s ago`;
|
|
@@ -26796,13 +26899,13 @@ function buildSupervisorCommand(opts) {
|
|
|
26796
26899
|
}
|
|
26797
26900
|
if (sub === "on") {
|
|
26798
26901
|
supervisor.start();
|
|
26799
|
-
const msg2 = `Fleet supervisor ${
|
|
26902
|
+
const msg2 = `Fleet supervisor ${color58.green("armed")} \u2014 evaluating every ${Math.round(supervisor.configSnapshot().intervalMs / 1e3)}s.`;
|
|
26800
26903
|
opts.renderer.write(msg2);
|
|
26801
26904
|
return { message: msg2 };
|
|
26802
26905
|
}
|
|
26803
26906
|
if (sub === "off") {
|
|
26804
26907
|
supervisor.stop();
|
|
26805
|
-
const msg2 = `Fleet supervisor ${
|
|
26908
|
+
const msg2 = `Fleet supervisor ${color58.yellow("disarmed")} \u2014 no further automatic interventions this session.`;
|
|
26806
26909
|
opts.renderer.write(msg2);
|
|
26807
26910
|
return { message: msg2 };
|
|
26808
26911
|
}
|
|
@@ -26815,10 +26918,10 @@ function buildSupervisorCommand(opts) {
|
|
|
26815
26918
|
return { message: msg3 };
|
|
26816
26919
|
}
|
|
26817
26920
|
const lines2 = entries.map((e) => {
|
|
26818
|
-
const who = e.subagentId ? ` ${
|
|
26921
|
+
const who = e.subagentId ? ` ${color58.cyan(e.subagentId)}` : "";
|
|
26819
26922
|
const task = e.taskId ? ` task=${e.taskId.slice(0, 8)}` : "";
|
|
26820
|
-
const outcome = e.outcome === "approved" ?
|
|
26821
|
-
return `${
|
|
26923
|
+
const outcome = e.outcome === "approved" ? color58.green(e.outcome) : e.outcome === "denied" || e.outcome === "error" ? color58.red(e.outcome) : color58.yellow(e.outcome);
|
|
26924
|
+
return `${color58.dim(fmtAge4(e.at))} ${e.kind}${who}${task} \u2192 ${e.proposedAction} [${outcome}] ${color58.dim(e.detail)}`;
|
|
26822
26925
|
});
|
|
26823
26926
|
const msg2 = lines2.join("\n");
|
|
26824
26927
|
opts.renderer.write(msg2);
|
|
@@ -26828,12 +26931,12 @@ function buildSupervisorCommand(opts) {
|
|
|
26828
26931
|
const history = supervisor.history();
|
|
26829
26932
|
const last = history[history.length - 1];
|
|
26830
26933
|
const lines = [
|
|
26831
|
-
`Fleet supervisor: ${supervisor.isRunning() ?
|
|
26934
|
+
`Fleet supervisor: ${supervisor.isRunning() ? color58.green("armed") : color58.yellow("disarmed")}`,
|
|
26832
26935
|
` interval ${Math.round(cfg.intervalMs / 1e3)}s \xB7 cooldown ${Math.round(cfg.cooldownMs / 1e3)}s \xB7 max ${cfg.maxInterventionsPerSubagent} interventions/agent`,
|
|
26833
26936
|
` signals: starvation>${Math.round(cfg.pinnedWaitMs / 1e3)}s \xB7 overload\u2265${cfg.overloadPinnedThreshold} pinned \xB7 backlog>${cfg.backlogFactor}\xD7workers \xB7 stuck>${Math.round(cfg.stuckMs / 1e3)}s \xB7 failstreak\u2265${cfg.failureStreak}`,
|
|
26834
26937
|
` actions: retarget \u2713 \xB7 spawn ${cfg.allowSpawn ? "\u2713" : "\u2717"} \xB7 steer \u2713 \xB7 terminate ${cfg.allowTerminate ? "\u2713" : "\u2717 (config fleet.supervisor.allowTerminate)"}`,
|
|
26835
26938
|
` activity: ${history.length} engagement(s)${last ? ` \u2014 last: ${last.kind} \u2192 ${last.proposedAction} [${last.outcome}] ${fmtAge4(last.at)}` : ""}`,
|
|
26836
|
-
|
|
26939
|
+
color58.dim(" decisions are gated by the Brain \u2014 see /brain (risk ceiling applies)")
|
|
26837
26940
|
];
|
|
26838
26941
|
const msg = lines.join("\n");
|
|
26839
26942
|
opts.renderer.write(msg);
|
|
@@ -27262,7 +27365,7 @@ ${formatTaskProgress(file.tasks)}`;
|
|
|
27262
27365
|
// src/slash-commands/techstack.ts
|
|
27263
27366
|
import * as fs16 from "node:fs/promises";
|
|
27264
27367
|
import * as path19 from "node:path";
|
|
27265
|
-
import { color as
|
|
27368
|
+
import { color as color59, toErrorMessage as toErrorMessage25 } from "@wrongstack/core/utils";
|
|
27266
27369
|
async function discoverPackageFiles(projectRoot) {
|
|
27267
27370
|
const files = [];
|
|
27268
27371
|
const rootPkg = path19.join(projectRoot, "package.json");
|
|
@@ -27412,10 +27515,10 @@ function buildTechStackCommand(opts) {
|
|
|
27412
27515
|
" 1. Reads every package.json in the project",
|
|
27413
27516
|
" 2. Looks up latest versions on the npm registry",
|
|
27414
27517
|
" 3. Flags outdated, dead, or obsolete packages",
|
|
27415
|
-
` 4. Writes a ${
|
|
27518
|
+
` 4. Writes a ${color59.cyan("techstack.md")} (or .json) report to the project root`,
|
|
27416
27519
|
"",
|
|
27417
27520
|
"Uses the `tech-stack` skill for version verification rules.",
|
|
27418
|
-
`Hooked into ${
|
|
27521
|
+
`Hooked into ${color59.cyan("/init")} \u2014 runs automatically on first project setup.`
|
|
27419
27522
|
].join("\n"),
|
|
27420
27523
|
async run(args, _ctx) {
|
|
27421
27524
|
const trimmed = args.trim().toLowerCase();
|
|
@@ -27499,12 +27602,12 @@ function buildTechStackCommand(opts) {
|
|
|
27499
27602
|
try {
|
|
27500
27603
|
packageFiles = await discoverPackageFiles(opts.projectRoot);
|
|
27501
27604
|
if (packageFiles.length === 0) {
|
|
27502
|
-
discoveryNote =
|
|
27605
|
+
discoveryNote = color59.amber(
|
|
27503
27606
|
"\u26A0 No package.json files found. This does not look like a Node.js project."
|
|
27504
27607
|
);
|
|
27505
27608
|
}
|
|
27506
27609
|
} catch (err) {
|
|
27507
|
-
discoveryNote =
|
|
27610
|
+
discoveryNote = color59.red(`Could not scan for package files: ${toErrorMessage25(err)}`);
|
|
27508
27611
|
}
|
|
27509
27612
|
const task = buildTechStackTask({
|
|
27510
27613
|
projectRoot: opts.projectRoot,
|
|
@@ -27527,11 +27630,11 @@ function buildTechStackCommand(opts) {
|
|
|
27527
27630
|
};
|
|
27528
27631
|
}
|
|
27529
27632
|
const header = isInit ? "Tech Stack Init Audit" : "Tech Stack Audit";
|
|
27530
|
-
const label = `${
|
|
27633
|
+
const label = `${color59.cyan("\u{1F50D}")} ${color59.bold(header)} ${color59.dim(`(${packageFiles.length} package files)`)}`;
|
|
27531
27634
|
opts.renderer.write(label);
|
|
27532
27635
|
if (discoveryNote) opts.renderer.write(discoveryNote);
|
|
27533
27636
|
opts.renderer.write(
|
|
27534
|
-
|
|
27637
|
+
color59.dim(
|
|
27535
27638
|
`Spawning tech-stack subagent \u2192 writes ${outputFormat === "json" ? "techstack.json" : "techstack.md"} when done.`
|
|
27536
27639
|
)
|
|
27537
27640
|
);
|
|
@@ -27553,10 +27656,10 @@ function buildTechStackCommand(opts) {
|
|
|
27553
27656
|
}
|
|
27554
27657
|
|
|
27555
27658
|
// src/slash-commands/telegram-settings.ts
|
|
27556
|
-
import { color as
|
|
27659
|
+
import { color as color61, toErrorMessage as toErrorMessage26 } from "@wrongstack/core/utils";
|
|
27557
27660
|
|
|
27558
27661
|
// src/slash-commands/telegram-setup.ts
|
|
27559
|
-
import { color as
|
|
27662
|
+
import { color as color60 } from "@wrongstack/core/utils";
|
|
27560
27663
|
|
|
27561
27664
|
// src/slash-commands/telegram-pairing.ts
|
|
27562
27665
|
var DISCOVERY_LIMIT = 25;
|
|
@@ -27672,31 +27775,31 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27672
27775
|
if (BOT_TOKEN_RE.test(first)) {
|
|
27673
27776
|
return {
|
|
27674
27777
|
message: [
|
|
27675
|
-
`${
|
|
27676
|
-
`Run ${
|
|
27778
|
+
`${color60.red("\u2717")} Bot tokens are no longer accepted as slash-command arguments.`,
|
|
27779
|
+
`Run ${color60.cyan("/telegram-setup [chatId]")} and enter it at the masked prompt.`
|
|
27677
27780
|
].join("\n")
|
|
27678
27781
|
};
|
|
27679
27782
|
}
|
|
27680
27783
|
if (parts.length > 1) {
|
|
27681
|
-
return { message: `${
|
|
27784
|
+
return { message: `${color60.amber("Usage:")} /telegram-setup [chatId]` };
|
|
27682
27785
|
}
|
|
27683
27786
|
if (!opts.readSecret || !opts.vault || !opts.paths?.globalConfig) {
|
|
27684
27787
|
return {
|
|
27685
|
-
message: `${
|
|
27788
|
+
message: `${color60.red("\u2717")} Secure Telegram setup is unavailable in this session.`
|
|
27686
27789
|
};
|
|
27687
27790
|
}
|
|
27688
27791
|
let botToken;
|
|
27689
27792
|
try {
|
|
27690
|
-
botToken = (await opts.readSecret(`Telegram bot token ${
|
|
27793
|
+
botToken = (await opts.readSecret(`Telegram bot token ${color60.dim("(hidden, paste OK)")}: `)).trim();
|
|
27691
27794
|
} catch {
|
|
27692
|
-
return { message:
|
|
27795
|
+
return { message: color60.dim("Telegram setup cancelled.") };
|
|
27693
27796
|
}
|
|
27694
|
-
if (!botToken) return { message:
|
|
27797
|
+
if (!botToken) return { message: color60.dim("Telegram setup cancelled.") };
|
|
27695
27798
|
if (!BOT_TOKEN_RE.test(botToken)) {
|
|
27696
27799
|
return {
|
|
27697
27800
|
message: [
|
|
27698
|
-
`${
|
|
27699
|
-
`Expected: ${
|
|
27801
|
+
`${color60.red("\u2717")} Invalid token format.`,
|
|
27802
|
+
`Expected: ${color60.dim("123456789:ABCdefGHIjkl...")}`,
|
|
27700
27803
|
"",
|
|
27701
27804
|
"Get a valid token from @BotFather on Telegram."
|
|
27702
27805
|
].join("\n")
|
|
@@ -27711,7 +27814,7 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27711
27814
|
} catch {
|
|
27712
27815
|
return {
|
|
27713
27816
|
message: [
|
|
27714
|
-
`${
|
|
27817
|
+
`${color60.red("\u2717")} Could not reach Telegram API.`,
|
|
27715
27818
|
"",
|
|
27716
27819
|
"Check your network connection and try again."
|
|
27717
27820
|
].join("\n")
|
|
@@ -27720,7 +27823,7 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27720
27823
|
if (!botInfo.ok || !botInfo.result) {
|
|
27721
27824
|
return {
|
|
27722
27825
|
message: [
|
|
27723
|
-
`${
|
|
27826
|
+
`${color60.red("\u2717")} Invalid bot token.`,
|
|
27724
27827
|
"",
|
|
27725
27828
|
"Get a valid token from @BotFather on Telegram."
|
|
27726
27829
|
].join("\n")
|
|
@@ -27730,13 +27833,13 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27730
27833
|
const classifiedChatId = chatId ? classifyTelegramChatId(chatId) : void 0;
|
|
27731
27834
|
if (classifiedChatId?.kind === "invalid") {
|
|
27732
27835
|
return {
|
|
27733
|
-
message: `${
|
|
27836
|
+
message: `${color60.red("\u2717")} Invalid Telegram chat ID. Expected a positive private chat ID.`
|
|
27734
27837
|
};
|
|
27735
27838
|
}
|
|
27736
27839
|
if (classifiedChatId?.kind === "group") {
|
|
27737
27840
|
return {
|
|
27738
27841
|
message: [
|
|
27739
|
-
`${
|
|
27842
|
+
`${color60.amber("\u26A0")} Shared group, supergroup, and channel IDs cannot be paired by manual ID.`,
|
|
27740
27843
|
"Run /telegram-setup without a chat ID and select a discovered private identity.",
|
|
27741
27844
|
"No configuration was changed."
|
|
27742
27845
|
].join("\n")
|
|
@@ -27750,7 +27853,7 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27750
27853
|
} catch {
|
|
27751
27854
|
return {
|
|
27752
27855
|
message: [
|
|
27753
|
-
`${
|
|
27856
|
+
`${color60.red("\u2717")} Could not discover recent Telegram chats.`,
|
|
27754
27857
|
"Message the bot once, then run /telegram-setup again.",
|
|
27755
27858
|
"No configuration was changed."
|
|
27756
27859
|
].join("\n")
|
|
@@ -27759,7 +27862,7 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27759
27862
|
if (candidates.length === 0) {
|
|
27760
27863
|
return {
|
|
27761
27864
|
message: [
|
|
27762
|
-
`${
|
|
27865
|
+
`${color60.amber("No recent chats found.")}`,
|
|
27763
27866
|
"Message the bot from the private account you want to pair, then run setup again.",
|
|
27764
27867
|
"No configuration was changed."
|
|
27765
27868
|
].join("\n")
|
|
@@ -27767,31 +27870,31 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27767
27870
|
}
|
|
27768
27871
|
opts.renderer.write(
|
|
27769
27872
|
[
|
|
27770
|
-
|
|
27873
|
+
color60.bold("Recent Telegram identities"),
|
|
27771
27874
|
formatTelegramPairingCandidates(candidates),
|
|
27772
27875
|
"",
|
|
27773
|
-
|
|
27876
|
+
color60.dim("Choose a private candidate number, or press Enter to cancel.")
|
|
27774
27877
|
].join("\n")
|
|
27775
27878
|
);
|
|
27776
27879
|
let choiceInput;
|
|
27777
27880
|
try {
|
|
27778
27881
|
choiceInput = opts.readText ? await opts.readText("Pair candidate \u203A ") : await opts.reader.readLine("Pair candidate \u203A ");
|
|
27779
27882
|
} catch {
|
|
27780
|
-
return { message:
|
|
27883
|
+
return { message: color60.dim("Telegram setup cancelled. No configuration was changed.") };
|
|
27781
27884
|
}
|
|
27782
27885
|
const choice = parseTelegramPairingChoice(choiceInput, candidates);
|
|
27783
27886
|
if (choice.kind === "cancel") {
|
|
27784
|
-
return { message:
|
|
27887
|
+
return { message: color60.dim("Telegram setup cancelled. No configuration was changed.") };
|
|
27785
27888
|
}
|
|
27786
27889
|
if (choice.kind === "invalid") {
|
|
27787
27890
|
return {
|
|
27788
|
-
message: `${
|
|
27891
|
+
message: `${color60.red("\u2717")} Invalid pairing choice. No configuration was changed.`
|
|
27789
27892
|
};
|
|
27790
27893
|
}
|
|
27791
27894
|
if (!choice.candidate.eligible) {
|
|
27792
27895
|
return {
|
|
27793
27896
|
message: [
|
|
27794
|
-
`${
|
|
27897
|
+
`${color60.amber("\u26A0")} Shared, group, or ambiguous identities are not paired automatically.`,
|
|
27795
27898
|
"Use a private chat where chat_id and user_id identify the same account.",
|
|
27796
27899
|
"No configuration was changed."
|
|
27797
27900
|
].join("\n")
|
|
@@ -27833,7 +27936,7 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27833
27936
|
} catch {
|
|
27834
27937
|
return {
|
|
27835
27938
|
message: [
|
|
27836
|
-
`${
|
|
27939
|
+
`${color60.red("\u2717")} Failed to save Telegram configuration.`,
|
|
27837
27940
|
"The token was not printed. Check the config path and vault, then try again."
|
|
27838
27941
|
].join("\n")
|
|
27839
27942
|
};
|
|
@@ -27841,15 +27944,15 @@ function buildTelegramSetupCommand(opts) {
|
|
|
27841
27944
|
const bot = botInfo.result;
|
|
27842
27945
|
return {
|
|
27843
27946
|
message: [
|
|
27844
|
-
`${
|
|
27947
|
+
`${color60.green("\u2713")} Telegram configured successfully.`,
|
|
27845
27948
|
"",
|
|
27846
|
-
`Bot: ${
|
|
27949
|
+
`Bot: ${color60.bold(`@${bot.username ?? bot.first_name}`)}`,
|
|
27847
27950
|
...pairedCandidate ? [
|
|
27848
|
-
`Paired private chat: ${
|
|
27849
|
-
`Paired user: ${
|
|
27850
|
-
] : chatId ? [`Default chat: ${
|
|
27951
|
+
`Paired private chat: ${color60.green(String(pairedCandidate.chatId))}`,
|
|
27952
|
+
`Paired user: ${color60.green(String(pairedCandidate.userId))}`
|
|
27953
|
+
] : chatId ? [`Default chat: ${color60.green(chatId)}`] : [],
|
|
27851
27954
|
"",
|
|
27852
|
-
`${
|
|
27955
|
+
`${color60.amber("\u26A0")} Restart WrongStack for the plugin to load the new token.`
|
|
27853
27956
|
].join("\n")
|
|
27854
27957
|
};
|
|
27855
27958
|
}
|
|
@@ -27883,15 +27986,15 @@ function buildTelegramSettingsCommand(opts) {
|
|
|
27883
27986
|
const chat = tg.notifyChatId !== void 0 && tg.notifyChatId !== null ? String(tg.notifyChatId) : "not set";
|
|
27884
27987
|
const hasToken = typeof tg.botToken === "string" && tg.botToken.length > 0;
|
|
27885
27988
|
return [
|
|
27886
|
-
`${
|
|
27989
|
+
`${color61.bold("Telegram")} ${color61.dim("\u2014 Notification Settings")}`,
|
|
27887
27990
|
"",
|
|
27888
|
-
` session end: ${sessionEnd ?
|
|
27889
|
-
` delegate done: ${delegate ?
|
|
27890
|
-
` long tool: ${
|
|
27891
|
-
` poll interval: ${
|
|
27892
|
-
` notify chat: ${
|
|
27991
|
+
` session end: ${sessionEnd ? color61.cyan("on") : color61.dim("off")} ${color61.dim("change: /telegram-settings session-end on|off")}`,
|
|
27992
|
+
` delegate done: ${delegate ? color61.cyan("on") : color61.dim("off")} ${color61.dim("change: /telegram-settings delegate on|off")}`,
|
|
27993
|
+
` long tool: ${color61.cyan(longTool)} ${color61.dim("change: /telegram-settings long-tool <ms|off>")}`,
|
|
27994
|
+
` poll interval: ${color61.cyan(poll)} ${color61.dim("change: /telegram-settings poll <seconds>")}`,
|
|
27995
|
+
` notify chat: ${color61.cyan(chat)} ${color61.dim("change: /telegram-settings chat <chatId>")}`,
|
|
27893
27996
|
"",
|
|
27894
|
-
hasToken ?
|
|
27997
|
+
hasToken ? color61.dim(" Bot token configured. Changes apply immediately.") : `${color61.amber("\u26A0")} No bot token configured. Run: /telegram-setup <botToken> [chatId]`
|
|
27895
27998
|
].join("\n");
|
|
27896
27999
|
}
|
|
27897
28000
|
return {
|
|
@@ -27907,7 +28010,7 @@ function buildTelegramSettingsCommand(opts) {
|
|
|
27907
28010
|
return { message: HELP2 };
|
|
27908
28011
|
}
|
|
27909
28012
|
if (!opts.configStore || !opts.paths?.globalConfig || !opts.vault) {
|
|
27910
|
-
return { message: `${
|
|
28013
|
+
return { message: `${color61.red("Error")} secure config persistence not available.` };
|
|
27911
28014
|
}
|
|
27912
28015
|
if (!sub) {
|
|
27913
28016
|
return { message: currentView() };
|
|
@@ -27921,7 +28024,7 @@ function buildTelegramSettingsCommand(opts) {
|
|
|
27921
28024
|
if (sub === "all") {
|
|
27922
28025
|
const raw = (rest[0] ?? "").toLowerCase();
|
|
27923
28026
|
if (!["on", "off"].includes(raw)) {
|
|
27924
|
-
return { message: `${
|
|
28027
|
+
return { message: `${color61.amber("Usage:")} /telegram-settings all on|off` };
|
|
27925
28028
|
}
|
|
27926
28029
|
const on = raw === "on";
|
|
27927
28030
|
await persistTelegramConfig(persistDeps, (tg) => {
|
|
@@ -27929,40 +28032,40 @@ function buildTelegramSettingsCommand(opts) {
|
|
|
27929
28032
|
tg.notifyOnDelegate = on;
|
|
27930
28033
|
});
|
|
27931
28034
|
return {
|
|
27932
|
-
message: `${
|
|
28035
|
+
message: `${color61.green("\u2713")} all event notifications \u2192 ${on ? color61.cyan("on") : color61.dim("off")} ${color61.dim("(session-end, delegate)")}`
|
|
27933
28036
|
};
|
|
27934
28037
|
}
|
|
27935
28038
|
if (sub === "session-end") {
|
|
27936
28039
|
const raw = (rest[0] ?? "").toLowerCase();
|
|
27937
28040
|
if (!["on", "off"].includes(raw)) {
|
|
27938
|
-
return { message: `${
|
|
28041
|
+
return { message: `${color61.amber("Usage:")} /telegram-settings session-end on|off` };
|
|
27939
28042
|
}
|
|
27940
28043
|
const on = raw === "on";
|
|
27941
28044
|
await persistTelegramConfig(persistDeps, (tg) => {
|
|
27942
28045
|
tg.notifyOnSessionEnd = on;
|
|
27943
28046
|
});
|
|
27944
28047
|
return {
|
|
27945
|
-
message: `${
|
|
28048
|
+
message: `${color61.green("\u2713")} session-end \u2192 ${on ? color61.cyan("on") : color61.dim("off")}`
|
|
27946
28049
|
};
|
|
27947
28050
|
}
|
|
27948
28051
|
if (sub === "delegate") {
|
|
27949
28052
|
const raw = (rest[0] ?? "").toLowerCase();
|
|
27950
28053
|
if (!["on", "off"].includes(raw)) {
|
|
27951
|
-
return { message: `${
|
|
28054
|
+
return { message: `${color61.amber("Usage:")} /telegram-settings delegate on|off` };
|
|
27952
28055
|
}
|
|
27953
28056
|
const on = raw === "on";
|
|
27954
28057
|
await persistTelegramConfig(persistDeps, (tg) => {
|
|
27955
28058
|
tg.notifyOnDelegate = on;
|
|
27956
28059
|
});
|
|
27957
28060
|
return {
|
|
27958
|
-
message: `${
|
|
28061
|
+
message: `${color61.green("\u2713")} delegate \u2192 ${on ? color61.cyan("on") : color61.dim("off")}`
|
|
27959
28062
|
};
|
|
27960
28063
|
}
|
|
27961
28064
|
if (sub === "long-tool") {
|
|
27962
28065
|
const raw = rest[0];
|
|
27963
28066
|
if (raw === void 0) {
|
|
27964
28067
|
return {
|
|
27965
|
-
message: `${
|
|
28068
|
+
message: `${color61.amber("Usage:")} /telegram-settings long-tool <ms|off> ${color61.dim("(0 or off disables)")}`
|
|
27966
28069
|
};
|
|
27967
28070
|
}
|
|
27968
28071
|
if (raw === "off") {
|
|
@@ -27970,57 +28073,57 @@ function buildTelegramSettingsCommand(opts) {
|
|
|
27970
28073
|
tg.longToolThresholdMs = 0;
|
|
27971
28074
|
});
|
|
27972
28075
|
return {
|
|
27973
|
-
message: `${
|
|
28076
|
+
message: `${color61.green("\u2713")} long-tool \u2192 ${color61.dim("off")}`
|
|
27974
28077
|
};
|
|
27975
28078
|
}
|
|
27976
28079
|
const ms = Number.parseInt(raw, 10);
|
|
27977
28080
|
if (Number.isNaN(ms) || ms < 0) {
|
|
27978
28081
|
return {
|
|
27979
|
-
message: `${
|
|
28082
|
+
message: `${color61.red("Invalid number")}: "${raw}". Enter milliseconds, e.g. /telegram-settings long-tool 15000`
|
|
27980
28083
|
};
|
|
27981
28084
|
}
|
|
27982
28085
|
await persistTelegramConfig(persistDeps, (tg) => {
|
|
27983
28086
|
tg.longToolThresholdMs = ms;
|
|
27984
28087
|
});
|
|
27985
28088
|
return {
|
|
27986
|
-
message: `${
|
|
28089
|
+
message: `${color61.green("\u2713")} long-tool \u2192 ${color61.cyan(`${ms}ms`)}`
|
|
27987
28090
|
};
|
|
27988
28091
|
}
|
|
27989
28092
|
if (sub === "poll") {
|
|
27990
28093
|
const raw = rest[0];
|
|
27991
28094
|
if (raw === void 0) {
|
|
27992
28095
|
return {
|
|
27993
|
-
message: `${
|
|
28096
|
+
message: `${color61.amber("Usage:")} /telegram-settings poll <seconds> ${color61.dim("(1\u201360)")}`
|
|
27994
28097
|
};
|
|
27995
28098
|
}
|
|
27996
28099
|
const sec = Number.parseInt(raw, 10);
|
|
27997
28100
|
if (Number.isNaN(sec) || sec < 1 || sec > 60) {
|
|
27998
28101
|
return {
|
|
27999
|
-
message: `${
|
|
28102
|
+
message: `${color61.red("Invalid value")}: "${raw}". Enter seconds between 1 and 60.`
|
|
28000
28103
|
};
|
|
28001
28104
|
}
|
|
28002
28105
|
await persistTelegramConfig(persistDeps, (tg) => {
|
|
28003
28106
|
tg.pollIntervalSec = sec;
|
|
28004
28107
|
});
|
|
28005
28108
|
return {
|
|
28006
|
-
message: `${
|
|
28109
|
+
message: `${color61.green("\u2713")} poll \u2192 ${color61.cyan(`${sec}s`)}`
|
|
28007
28110
|
};
|
|
28008
28111
|
}
|
|
28009
28112
|
if (sub === "chat") {
|
|
28010
28113
|
const raw = rest[0];
|
|
28011
28114
|
if (!raw) {
|
|
28012
|
-
return { message: `${
|
|
28115
|
+
return { message: `${color61.amber("Usage:")} /telegram-settings chat <chatId>` };
|
|
28013
28116
|
}
|
|
28014
28117
|
const classification = classifyTelegramChatId(raw);
|
|
28015
28118
|
if (classification.kind === "invalid") {
|
|
28016
|
-
return { message: `${
|
|
28119
|
+
return { message: `${color61.red("Invalid chat ID")}: expected a non-zero integer.` };
|
|
28017
28120
|
}
|
|
28018
28121
|
const current = opts.configStore.get();
|
|
28019
28122
|
const allowGroupChats = current.extensions?.telegram?.allowGroupChats === true;
|
|
28020
28123
|
if (classification.kind === "group" && !allowGroupChats) {
|
|
28021
28124
|
return {
|
|
28022
28125
|
message: [
|
|
28023
|
-
`${
|
|
28126
|
+
`${color61.amber("\u26A0")} Group, supergroup, and channel targets require explicit allowGroupChats=true.`,
|
|
28024
28127
|
"No configuration was changed."
|
|
28025
28128
|
].join("\n")
|
|
28026
28129
|
};
|
|
@@ -28043,15 +28146,15 @@ function buildTelegramSettingsCommand(opts) {
|
|
|
28043
28146
|
}
|
|
28044
28147
|
});
|
|
28045
28148
|
return {
|
|
28046
|
-
message: `${
|
|
28149
|
+
message: `${color61.green("\u2713")} notify chat \u2192 ${color61.cyan(raw)}`
|
|
28047
28150
|
};
|
|
28048
28151
|
}
|
|
28049
28152
|
return {
|
|
28050
|
-
message: `${
|
|
28153
|
+
message: `${color61.red("Unknown setting")} "${sub}". ${unknownSubcommand(sub, ["session-end", "delegate", "long-tool", "poll", "chat", "all"], "telegram-settings")}`
|
|
28051
28154
|
};
|
|
28052
28155
|
} catch (err) {
|
|
28053
28156
|
return {
|
|
28054
|
-
message: `${
|
|
28157
|
+
message: `${color61.red("Settings error")}: ${toErrorMessage26(err)}`
|
|
28055
28158
|
};
|
|
28056
28159
|
}
|
|
28057
28160
|
}
|
|
@@ -28199,7 +28302,7 @@ function buildTodosCommand(opts) {
|
|
|
28199
28302
|
// src/slash-commands/tool.ts
|
|
28200
28303
|
import { noOpVault as noOpVault11 } from "@wrongstack/core/security";
|
|
28201
28304
|
import {
|
|
28202
|
-
color as
|
|
28305
|
+
color as color62,
|
|
28203
28306
|
getToolDescriptionMode,
|
|
28204
28307
|
getToolResultRenderMode,
|
|
28205
28308
|
normalizeToolDescriptionMode,
|
|
@@ -28213,11 +28316,11 @@ function fit(text, width) {
|
|
|
28213
28316
|
}
|
|
28214
28317
|
function formatDescriptionMode(mode) {
|
|
28215
28318
|
const raw = `desc:${mode}`;
|
|
28216
|
-
return mode === "simple" ?
|
|
28319
|
+
return mode === "simple" ? color62.amber(raw) : color62.cyan(raw);
|
|
28217
28320
|
}
|
|
28218
28321
|
function formatResultRenderMode(mode) {
|
|
28219
28322
|
const raw = `result:${mode}`;
|
|
28220
|
-
return mode === "simple" ?
|
|
28323
|
+
return mode === "simple" ? color62.amber(raw) : color62.cyan(raw);
|
|
28221
28324
|
}
|
|
28222
28325
|
function buildToolCommand(opts) {
|
|
28223
28326
|
const help = [
|
|
@@ -28323,38 +28426,38 @@ function buildToolCommand(opts) {
|
|
|
28323
28426
|
const resultSimple = Object.entries(configured.resultRenderMode ?? {}).filter(([, mode]) => normalizeToolResultRenderMode(mode) === "simple").map(([name]) => name).sort();
|
|
28324
28427
|
const disabled = opts.toolRegistry.listDisabled();
|
|
28325
28428
|
const lines = [
|
|
28326
|
-
`${
|
|
28429
|
+
`${color62.bold("Tool modes")} ${color62.dim("(default: extend on both axes)")}`,
|
|
28327
28430
|
"",
|
|
28328
|
-
`${formatDescriptionMode("simple")}: ${descSimple.length > 0 ? descSimple.map((n) =>
|
|
28329
|
-
`${formatResultRenderMode("simple")}: ${resultSimple.length > 0 ? resultSimple.map((n) =>
|
|
28431
|
+
`${formatDescriptionMode("simple")}: ${descSimple.length > 0 ? descSimple.map((n) => color62.cyan(n)).join(", ") : color62.dim("none")}`,
|
|
28432
|
+
`${formatResultRenderMode("simple")}: ${resultSimple.length > 0 ? resultSimple.map((n) => color62.cyan(n)).join(", ") : color62.dim("none")}`,
|
|
28330
28433
|
""
|
|
28331
28434
|
];
|
|
28332
28435
|
if (disabled.length > 0) {
|
|
28333
28436
|
lines.push(
|
|
28334
|
-
`${
|
|
28437
|
+
`${color62.bold("Disabled tools")}`,
|
|
28335
28438
|
"",
|
|
28336
|
-
` ${
|
|
28439
|
+
` ${color62.red("disabled")}: ${disabled.map(({ tool }) => color62.dim(tool.name)).join(", ")}`,
|
|
28337
28440
|
""
|
|
28338
28441
|
);
|
|
28339
28442
|
}
|
|
28340
28443
|
lines.push(
|
|
28341
|
-
|
|
28444
|
+
color62.dim(
|
|
28342
28445
|
" /tool <name> desc simple \xB7 /tool <name> result simple \xB7 /tool list \xB7 /tool disable|enable <name>"
|
|
28343
28446
|
)
|
|
28344
28447
|
);
|
|
28345
28448
|
return lines.join("\n");
|
|
28346
28449
|
}
|
|
28347
28450
|
function formatList() {
|
|
28348
|
-
const header = ` ${
|
|
28451
|
+
const header = ` ${color62.dim(fit("tool", 28))} ${color62.dim(fit("owner", 28))} ${color62.dim(fit("status", 10))} ${color62.dim(fit("desc", 14))} ` + color62.dim("result");
|
|
28349
28452
|
const rows = opts.toolRegistry.listWithOwner().map(({ tool }) => {
|
|
28350
28453
|
const descMode = getToolDescriptionMode(opts.toolRegistry, tool.name);
|
|
28351
28454
|
const resultMode = getToolResultRenderMode(opts.toolRegistry, tool.name);
|
|
28352
28455
|
const owner = opts.toolRegistry.ownerOf(tool.name) ?? "core";
|
|
28353
|
-
const status = opts.toolRegistry.isDisabled(tool.name) ?
|
|
28354
|
-
return ` ${fit(tool.name, 28)} ${
|
|
28456
|
+
const status = opts.toolRegistry.isDisabled(tool.name) ? color62.red("disabled") : color62.green("active");
|
|
28457
|
+
return ` ${fit(tool.name, 28)} ${color62.dim(fit(`[${owner}]`, 28))} ${fit(status, 10)} ${fit(formatDescriptionMode(descMode), 14)} ` + formatResultRenderMode(resultMode);
|
|
28355
28458
|
});
|
|
28356
28459
|
return [
|
|
28357
|
-
`${
|
|
28460
|
+
`${color62.bold("Tool modes")} ${color62.dim("(default: extend on both axes)")}`,
|
|
28358
28461
|
"",
|
|
28359
28462
|
header,
|
|
28360
28463
|
...rows
|
|
@@ -28365,55 +28468,55 @@ function buildToolCommand(opts) {
|
|
|
28365
28468
|
const tool = reg.get(name);
|
|
28366
28469
|
if (!tool) {
|
|
28367
28470
|
if (reg.isDisabled(name)) {
|
|
28368
|
-
return `${
|
|
28471
|
+
return `${color62.amber(name)} is disabled. Use ${color62.dim(`/tool enable ${name}`)} to restore.`;
|
|
28369
28472
|
}
|
|
28370
|
-
return `${
|
|
28473
|
+
return `${color62.red("Unknown tool")}: ${name}. Use ${color62.dim("/tools")} to list registered tools.`;
|
|
28371
28474
|
}
|
|
28372
28475
|
const descMode = getToolDescriptionMode(reg, name);
|
|
28373
28476
|
const resultMode = getToolResultRenderMode(reg, name);
|
|
28374
|
-
const status = reg.isDisabled(name) ?
|
|
28477
|
+
const status = reg.isDisabled(name) ? color62.red("disabled") : color62.green("active");
|
|
28375
28478
|
return [
|
|
28376
|
-
`${
|
|
28479
|
+
`${color62.bold(name)} ${status}`,
|
|
28377
28480
|
`description mode: ${formatDescriptionMode(descMode)}`,
|
|
28378
28481
|
`result mode: ${formatResultRenderMode(resultMode)}`,
|
|
28379
28482
|
"",
|
|
28380
|
-
|
|
28483
|
+
color62.dim(tool.description)
|
|
28381
28484
|
].join("\n");
|
|
28382
28485
|
}
|
|
28383
28486
|
async function cmdEnable(name) {
|
|
28384
28487
|
const reg = opts.toolRegistry;
|
|
28385
28488
|
if (!reg.isDisabled(name)) {
|
|
28386
|
-
return `${
|
|
28489
|
+
return `${color62.amber(name)} is not disabled.`;
|
|
28387
28490
|
}
|
|
28388
28491
|
const ok = reg.enable(name);
|
|
28389
|
-
if (!ok) return `${
|
|
28492
|
+
if (!ok) return `${color62.red("Could not enable")}: ${name}.`;
|
|
28390
28493
|
const disabled = currentDisabledSet();
|
|
28391
28494
|
disabled.delete(name);
|
|
28392
28495
|
await persistDisabled(Array.from(disabled));
|
|
28393
|
-
return `${
|
|
28496
|
+
return `${color62.green("\u2713")} ${color62.cyan(name)} re-enabled \u2014 will appear in next provider request.`;
|
|
28394
28497
|
}
|
|
28395
28498
|
async function cmdEnableAll() {
|
|
28396
28499
|
const reg = opts.toolRegistry;
|
|
28397
28500
|
const count = reg.enableAll();
|
|
28398
|
-
if (count === 0) return `${
|
|
28501
|
+
if (count === 0) return `${color62.amber("No disabled tools to re-enable.")}`;
|
|
28399
28502
|
await persistDisabled([]);
|
|
28400
|
-
return `${
|
|
28503
|
+
return `${color62.green("\u2713")} All ${count} disabled tool(s) re-enabled.`;
|
|
28401
28504
|
}
|
|
28402
28505
|
async function cmdDisable(name) {
|
|
28403
28506
|
const reg = opts.toolRegistry;
|
|
28404
28507
|
const tool = reg.get(name);
|
|
28405
28508
|
if (!tool) {
|
|
28406
28509
|
if (reg.isDisabled(name)) {
|
|
28407
|
-
return `${
|
|
28510
|
+
return `${color62.amber(name)} is already disabled.`;
|
|
28408
28511
|
}
|
|
28409
|
-
return `${
|
|
28512
|
+
return `${color62.red("Unknown tool")}: ${name}. Use ${color62.dim("/tools")} to list registered tools.`;
|
|
28410
28513
|
}
|
|
28411
28514
|
const ok = reg.disable(name);
|
|
28412
|
-
if (!ok) return `${
|
|
28515
|
+
if (!ok) return `${color62.red("Could not disable")}: ${name}.`;
|
|
28413
28516
|
const disabled = currentDisabledSet();
|
|
28414
28517
|
disabled.add(name);
|
|
28415
28518
|
await persistDisabled(Array.from(disabled));
|
|
28416
|
-
return `${
|
|
28519
|
+
return `${color62.green("\u2713")} ${color62.cyan(name)} disabled \u2014 removed from system prompt and tool registry.`;
|
|
28417
28520
|
}
|
|
28418
28521
|
function applyDescMode(name, mode) {
|
|
28419
28522
|
opts.toolRegistry.setDescriptionMode?.(name, mode);
|
|
@@ -28429,7 +28532,7 @@ function buildToolCommand(opts) {
|
|
|
28429
28532
|
help,
|
|
28430
28533
|
async run(args) {
|
|
28431
28534
|
if (!opts.configStore) {
|
|
28432
|
-
return { message: `${
|
|
28535
|
+
return { message: `${color62.red("Error")} config store not available.` };
|
|
28433
28536
|
}
|
|
28434
28537
|
const parts = args.trim().split(/\s+/).filter(Boolean);
|
|
28435
28538
|
const sub = (parts[0] ?? "").toLowerCase();
|
|
@@ -28440,7 +28543,7 @@ function buildToolCommand(opts) {
|
|
|
28440
28543
|
try {
|
|
28441
28544
|
return { message: await cmdEnableAll() };
|
|
28442
28545
|
} catch (err) {
|
|
28443
|
-
return { message: `${
|
|
28546
|
+
return { message: `${color62.red("Error")}: ${toErrorMessage27(err)}` };
|
|
28444
28547
|
}
|
|
28445
28548
|
}
|
|
28446
28549
|
const name = parts[0] ?? "";
|
|
@@ -28448,43 +28551,43 @@ function buildToolCommand(opts) {
|
|
|
28448
28551
|
if (sub === "disable") {
|
|
28449
28552
|
const targets = parts.slice(1);
|
|
28450
28553
|
if (targets.length === 0)
|
|
28451
|
-
return { message: `${
|
|
28554
|
+
return { message: `${color62.amber("Usage:")} /tool disable <name> [name...]` };
|
|
28452
28555
|
try {
|
|
28453
28556
|
const results = [];
|
|
28454
28557
|
for (const t of targets) results.push(await cmdDisable(t));
|
|
28455
28558
|
return { message: results.join("\n") };
|
|
28456
28559
|
} catch (err) {
|
|
28457
|
-
return { message: `${
|
|
28560
|
+
return { message: `${color62.red("Error")}: ${toErrorMessage27(err)}` };
|
|
28458
28561
|
}
|
|
28459
28562
|
}
|
|
28460
28563
|
if (sub === "enable") {
|
|
28461
28564
|
const targets = parts.slice(1);
|
|
28462
28565
|
if (targets.length === 0)
|
|
28463
|
-
return { message: `${
|
|
28566
|
+
return { message: `${color62.amber("Usage:")} /tool enable <name> [name...]` };
|
|
28464
28567
|
try {
|
|
28465
28568
|
const results = [];
|
|
28466
28569
|
for (const t of targets) results.push(await cmdEnable(t));
|
|
28467
28570
|
return { message: results.join("\n") };
|
|
28468
28571
|
} catch (err) {
|
|
28469
|
-
return { message: `${
|
|
28572
|
+
return { message: `${color62.red("Error")}: ${toErrorMessage27(err)}` };
|
|
28470
28573
|
}
|
|
28471
28574
|
}
|
|
28472
28575
|
const action = parts[1]?.toLowerCase();
|
|
28473
28576
|
if (action === "disable" || action === "enable") {
|
|
28474
28577
|
if (parts.length > 2) {
|
|
28475
28578
|
return {
|
|
28476
|
-
message: `${
|
|
28579
|
+
message: `${color62.amber("Usage:")} /tool ${name} ${action}`
|
|
28477
28580
|
};
|
|
28478
28581
|
}
|
|
28479
28582
|
try {
|
|
28480
28583
|
return { message: action === "disable" ? await cmdDisable(name) : await cmdEnable(name) };
|
|
28481
28584
|
} catch (err) {
|
|
28482
|
-
return { message: `${
|
|
28585
|
+
return { message: `${color62.red("Error")}: ${toErrorMessage27(err)}` };
|
|
28483
28586
|
}
|
|
28484
28587
|
}
|
|
28485
28588
|
if (!opts.toolRegistry.get(name) && !opts.toolRegistry.isDisabled(name)) {
|
|
28486
28589
|
return {
|
|
28487
|
-
message: `${
|
|
28590
|
+
message: `${color62.red("Unknown tool")}: ${name}. Use ${color62.dim("/tools")} to list registered tools.`
|
|
28488
28591
|
};
|
|
28489
28592
|
}
|
|
28490
28593
|
if (parts.length === 1) return { message: formatOne(name) };
|
|
@@ -28493,53 +28596,53 @@ function buildToolCommand(opts) {
|
|
|
28493
28596
|
const rawMode = parts[2];
|
|
28494
28597
|
if (!rawMode) {
|
|
28495
28598
|
return {
|
|
28496
|
-
message: `${
|
|
28599
|
+
message: `${color62.amber("Usage:")} /tool ${name} ${axis} simple|extend`
|
|
28497
28600
|
};
|
|
28498
28601
|
}
|
|
28499
28602
|
const mode2 = normalizeToolDescriptionMode(rawMode);
|
|
28500
28603
|
if (!mode2) {
|
|
28501
28604
|
return {
|
|
28502
|
-
message: `${
|
|
28605
|
+
message: `${color62.amber("Usage:")} /tool ${name} ${axis} simple|extend`
|
|
28503
28606
|
};
|
|
28504
28607
|
}
|
|
28505
28608
|
try {
|
|
28506
28609
|
if (axis === "desc") {
|
|
28507
28610
|
const persisted2 = await persistModeForAxis(name, "desc", mode2);
|
|
28508
28611
|
applyDescMode(name, mode2);
|
|
28509
|
-
const persistence2 = persisted2 ?
|
|
28612
|
+
const persistence2 = persisted2 ? color62.dim("saved") : color62.dim("runtime only; config paths unavailable");
|
|
28510
28613
|
return {
|
|
28511
|
-
message: `${
|
|
28614
|
+
message: `${color62.green("\u2713")} ${color62.cyan(name)} ${formatDescriptionMode(mode2)} ${persistence2}`
|
|
28512
28615
|
};
|
|
28513
28616
|
}
|
|
28514
28617
|
const persisted = await persistModeForAxis(name, "result", mode2);
|
|
28515
28618
|
applyResultMode(name, mode2);
|
|
28516
|
-
const persistence = persisted ?
|
|
28619
|
+
const persistence = persisted ? color62.dim("saved") : color62.dim("runtime only; config paths unavailable");
|
|
28517
28620
|
return {
|
|
28518
|
-
message: `${
|
|
28621
|
+
message: `${color62.green("\u2713")} ${color62.cyan(name)} ${formatResultRenderMode(mode2)} ${persistence}`
|
|
28519
28622
|
};
|
|
28520
28623
|
} catch (err) {
|
|
28521
28624
|
return {
|
|
28522
|
-
message: `${
|
|
28625
|
+
message: `${color62.red("Could not save tool setting")}: ${toErrorMessage27(err)}`
|
|
28523
28626
|
};
|
|
28524
28627
|
}
|
|
28525
28628
|
}
|
|
28526
28629
|
const mode = normalizeToolDescriptionMode(axis);
|
|
28527
28630
|
if (!mode) {
|
|
28528
28631
|
return {
|
|
28529
|
-
message: `${
|
|
28632
|
+
message: `${color62.amber("Usage:")} /tool ${name} [desc|result] simple|extend`
|
|
28530
28633
|
};
|
|
28531
28634
|
}
|
|
28532
28635
|
try {
|
|
28533
28636
|
const persisted = await persistModeBoth(name, mode);
|
|
28534
28637
|
applyDescMode(name, mode);
|
|
28535
28638
|
applyResultMode(name, mode);
|
|
28536
|
-
const persistence = persisted ?
|
|
28639
|
+
const persistence = persisted ? color62.dim("saved (both axes)") : color62.dim("runtime only; config paths unavailable");
|
|
28537
28640
|
return {
|
|
28538
|
-
message: `${
|
|
28641
|
+
message: `${color62.green("\u2713")} ${color62.cyan(name)} ${formatDescriptionMode(mode)} + ${formatResultRenderMode(mode)} ${persistence}`
|
|
28539
28642
|
};
|
|
28540
28643
|
} catch (err) {
|
|
28541
28644
|
return {
|
|
28542
|
-
message: `${
|
|
28645
|
+
message: `${color62.red("Could not save tool setting")}: ${toErrorMessage27(err)}`
|
|
28543
28646
|
};
|
|
28544
28647
|
}
|
|
28545
28648
|
}
|
|
@@ -28547,14 +28650,14 @@ function buildToolCommand(opts) {
|
|
|
28547
28650
|
}
|
|
28548
28651
|
|
|
28549
28652
|
// src/slash-commands/tools.ts
|
|
28550
|
-
import { color as
|
|
28653
|
+
import { color as color63, getToolDescriptionMode as getToolDescriptionMode2 } from "@wrongstack/core/utils";
|
|
28551
28654
|
function fit2(text, width) {
|
|
28552
28655
|
if (text.length <= width) return text.padEnd(width);
|
|
28553
28656
|
return `${text.slice(0, Math.max(0, width - 3))}...`;
|
|
28554
28657
|
}
|
|
28555
28658
|
function formatDescriptionMode2(mode) {
|
|
28556
28659
|
const raw = `desc:${mode}`;
|
|
28557
|
-
return mode === "simple" ?
|
|
28660
|
+
return mode === "simple" ? color63.amber(raw) : color63.dim(raw);
|
|
28558
28661
|
}
|
|
28559
28662
|
function buildToolsCommand(opts) {
|
|
28560
28663
|
return {
|
|
@@ -28575,21 +28678,21 @@ function buildToolsCommand(opts) {
|
|
|
28575
28678
|
if (opened) return { message: "" };
|
|
28576
28679
|
}
|
|
28577
28680
|
if (filter && all.length === 0) {
|
|
28578
|
-
const msg2 = `${
|
|
28681
|
+
const msg2 = `${color63.bold("Tools")} \u2014 no tool name or owner matched "${filter}".`;
|
|
28579
28682
|
opts.renderer.write(msg2);
|
|
28580
28683
|
return { message: msg2 };
|
|
28581
28684
|
}
|
|
28582
|
-
const header = ` ${
|
|
28685
|
+
const header = ` ${color63.dim(fit2("tool", 28))} ${color63.dim(fit2("owner", 28))} ${color63.dim(fit2("rw", 4))} ${color63.dim(fit2("perm", 8))} ${color63.dim(fit2("status", 10))} ` + color63.dim("description");
|
|
28583
28686
|
const lines = all.map(({ tool, owner }) => {
|
|
28584
28687
|
const mode = getToolDescriptionMode2(reg, tool.name);
|
|
28585
|
-
const rw = tool.mutating ?
|
|
28586
|
-
const status = reg.isDisabled(tool.name) ?
|
|
28587
|
-
return ` ${fit2(tool.name, 28)} ${
|
|
28688
|
+
const rw = tool.mutating ? color63.yellow(fit2("mut", 4)) : color63.cyan(fit2("ro", 4));
|
|
28689
|
+
const status = reg.isDisabled(tool.name) ? color63.red("disabled") : color63.green("active");
|
|
28690
|
+
return ` ${fit2(tool.name, 28)} ${color63.dim(fit2(`[${owner}]`, 28))} ${rw} ${color63.dim(fit2(tool.permission, 8))} ${fit2(status, 10)} ` + formatDescriptionMode2(mode);
|
|
28588
28691
|
});
|
|
28589
28692
|
const extra = disabled.length > 0 ? `
|
|
28590
|
-
${
|
|
28591
|
-
const filterNote = filter ?
|
|
28592
|
-
const msg = `${
|
|
28693
|
+
${color63.dim(`${disabled.length} tool(s) disabled. Use /tool enable <name> or /tool enable-all to restore.`)}` : "";
|
|
28694
|
+
const filterNote = filter ? color63.dim(` matching "${filter}" (${all.length} of ${allTools.length})`) : "";
|
|
28695
|
+
const msg = `${color63.bold("Tools")}${filterNote} (${all.length} shown, ${disabled.length} disabled) ${color63.dim("description detail via /tool <name> simple|extend")}:
|
|
28593
28696
|
${header}
|
|
28594
28697
|
${lines.join("\n")}${extra}
|
|
28595
28698
|
`;
|
|
@@ -28603,7 +28706,7 @@ ${lines.join("\n")}${extra}
|
|
|
28603
28706
|
import * as fs17 from "node:fs/promises";
|
|
28604
28707
|
import * as os3 from "node:os";
|
|
28605
28708
|
import * as path20 from "node:path";
|
|
28606
|
-
import { atomicWrite as atomicWrite10, color as
|
|
28709
|
+
import { atomicWrite as atomicWrite10, color as color64 } from "@wrongstack/core/utils";
|
|
28607
28710
|
|
|
28608
28711
|
// src/tuneup.ts
|
|
28609
28712
|
var DEFAULT_EAGER_MAX_CHARS = 24e3;
|
|
@@ -29081,17 +29184,17 @@ function buildTuneupCommand(opts) {
|
|
|
29081
29184
|
const parsed = parseArgs(args);
|
|
29082
29185
|
if (parsed.mode === "help") return { message: help };
|
|
29083
29186
|
if (parsed.mode === "usage") {
|
|
29084
|
-
return { message: `${
|
|
29187
|
+
return { message: `${color64.amber("Usage:")} /tuneup [fix [--power] [--pick] | deep]` };
|
|
29085
29188
|
}
|
|
29086
29189
|
if (!opts.paths) {
|
|
29087
|
-
return { message: `${
|
|
29190
|
+
return { message: `${color64.red("Error")} config paths not available.` };
|
|
29088
29191
|
}
|
|
29089
29192
|
const input = await gatherInput(opts, parsed.power);
|
|
29090
29193
|
const report = runTuneup(input);
|
|
29091
|
-
const lines = [`${
|
|
29194
|
+
const lines = [`${color64.bold("WrongStack")} ${color64.dim("\u2014 Tune-up")}`];
|
|
29092
29195
|
renderFindings(lines, report.findings);
|
|
29093
29196
|
if (parsed.mode === "deep") {
|
|
29094
|
-
lines.push("",
|
|
29197
|
+
lines.push("", color64.dim(" \u2192 asking the agent for a project-specific optimization plan\u2026"));
|
|
29095
29198
|
return { message: lines.join("\n"), runText: buildDeepPrompt(report) };
|
|
29096
29199
|
}
|
|
29097
29200
|
if (parsed.mode === "report") {
|
|
@@ -29113,18 +29216,18 @@ function buildTuneupCommand(opts) {
|
|
|
29113
29216
|
const applied = await applyActions(actions, opts);
|
|
29114
29217
|
lines.push("");
|
|
29115
29218
|
if (applied.messages.length === 0) {
|
|
29116
|
-
lines.push(
|
|
29219
|
+
lines.push(color64.dim(" no deterministic fixes to apply"));
|
|
29117
29220
|
} else {
|
|
29118
|
-
for (const m of applied.messages) lines.push(` ${
|
|
29221
|
+
for (const m of applied.messages) lines.push(` ${color64.green("\u2713")} ${m}`);
|
|
29119
29222
|
if (applied.changed) {
|
|
29120
29223
|
lines.push(
|
|
29121
|
-
` ${
|
|
29224
|
+
` ${color64.green("\u2713")} written ${color64.dim("(backup: config.json.last + timestamped .bak)")}`
|
|
29122
29225
|
);
|
|
29123
29226
|
}
|
|
29124
29227
|
}
|
|
29125
29228
|
const runText = report.agentHandoff || void 0;
|
|
29126
29229
|
if (runText) {
|
|
29127
|
-
lines.push("",
|
|
29230
|
+
lines.push("", color64.dim(" \u2192 handing instruction-file cleanups to the agent\u2026"));
|
|
29128
29231
|
}
|
|
29129
29232
|
return { message: lines.join("\n"), ...runText ? { runText } : {} };
|
|
29130
29233
|
}
|
|
@@ -29285,7 +29388,7 @@ async function applyActions(actions, opts) {
|
|
|
29285
29388
|
parsed = JSON.parse(raw);
|
|
29286
29389
|
} catch {
|
|
29287
29390
|
return {
|
|
29288
|
-
messages: [`${
|
|
29391
|
+
messages: [`${color64.red("\u2717")} global config is not valid JSON \u2014 run /doctor fix first`],
|
|
29289
29392
|
changed: false
|
|
29290
29393
|
};
|
|
29291
29394
|
}
|
|
@@ -29394,26 +29497,26 @@ var CATEGORY_ORDER = [
|
|
|
29394
29497
|
function severityIcon(severity) {
|
|
29395
29498
|
switch (severity) {
|
|
29396
29499
|
case "error":
|
|
29397
|
-
return
|
|
29500
|
+
return color64.red("\u2717");
|
|
29398
29501
|
case "warning":
|
|
29399
|
-
return
|
|
29502
|
+
return color64.amber("!");
|
|
29400
29503
|
case "ok":
|
|
29401
|
-
return
|
|
29504
|
+
return color64.green("\u2713");
|
|
29402
29505
|
default:
|
|
29403
|
-
return
|
|
29506
|
+
return color64.cyan("\xB7");
|
|
29404
29507
|
}
|
|
29405
29508
|
}
|
|
29406
29509
|
function renderFindings(lines, findings) {
|
|
29407
29510
|
for (const category of CATEGORY_ORDER) {
|
|
29408
29511
|
const group = findings.filter((f) => f.category === category);
|
|
29409
29512
|
if (group.length === 0) continue;
|
|
29410
|
-
lines.push("",
|
|
29513
|
+
lines.push("", color64.bold(CATEGORY_LABELS[category]));
|
|
29411
29514
|
for (const f of group) {
|
|
29412
29515
|
lines.push(` ${severityIcon(f.severity)} ${f.problem}`);
|
|
29413
29516
|
if (f.suggestion) {
|
|
29414
|
-
for (const s of f.suggestion.split("\n")) lines.push(
|
|
29517
|
+
for (const s of f.suggestion.split("\n")) lines.push(color64.dim(` ${s}`));
|
|
29415
29518
|
}
|
|
29416
|
-
if (f.fix) lines.push(
|
|
29519
|
+
if (f.fix) lines.push(color64.dim(` \u2192 fixable: ${f.fix}`));
|
|
29417
29520
|
}
|
|
29418
29521
|
}
|
|
29419
29522
|
}
|
|
@@ -29422,20 +29525,20 @@ function summaryLine(findings, fixable, handoffs, power) {
|
|
|
29422
29525
|
(f) => f.severity === "warning" || f.severity === "error"
|
|
29423
29526
|
).length;
|
|
29424
29527
|
if (warnings === 0 && fixable === 0 && handoffs === 0) {
|
|
29425
|
-
return `${
|
|
29528
|
+
return `${color64.green("\u2713")} everything looks healthy`;
|
|
29426
29529
|
}
|
|
29427
29530
|
const parts = [];
|
|
29428
29531
|
if (warnings > 0) parts.push(`${warnings} warning(s)`);
|
|
29429
29532
|
if (fixable > 0) parts.push(`${fixable} auto-fixable`);
|
|
29430
29533
|
if (handoffs > 0) parts.push(`${handoffs} for the agent`);
|
|
29431
29534
|
const cmd = power ? "/tuneup fix --power" : "/tuneup fix";
|
|
29432
|
-
return `${parts.join(", ")} ${
|
|
29535
|
+
return `${parts.join(", ")} ${color64.dim(`\u2014 run ${cmd}`)}`;
|
|
29433
29536
|
}
|
|
29434
29537
|
|
|
29435
29538
|
// src/slash-commands/working-dir.ts
|
|
29436
29539
|
import * as fs18 from "node:fs/promises";
|
|
29437
29540
|
import * as path21 from "node:path";
|
|
29438
|
-
import { color as
|
|
29541
|
+
import { color as color65, toErrorMessage as toErrorMessage28 } from "@wrongstack/core/utils";
|
|
29439
29542
|
function buildWorkingDirCommand(_opts) {
|
|
29440
29543
|
return {
|
|
29441
29544
|
name: "working_dir",
|
|
@@ -29454,16 +29557,16 @@ function buildWorkingDirCommand(_opts) {
|
|
|
29454
29557
|
].join("\n"),
|
|
29455
29558
|
async run(args, ctx) {
|
|
29456
29559
|
if (!ctx) {
|
|
29457
|
-
return { message:
|
|
29560
|
+
return { message: color65.yellow("No active context. Start a session first.") };
|
|
29458
29561
|
}
|
|
29459
29562
|
const trimmed = args.trim();
|
|
29460
29563
|
if (!trimmed) {
|
|
29461
29564
|
const rel2 = path21.relative(ctx.projectRoot, ctx.workingDir) || ".";
|
|
29462
29565
|
return {
|
|
29463
29566
|
message: [
|
|
29464
|
-
`Working directory: ${
|
|
29465
|
-
|
|
29466
|
-
|
|
29567
|
+
`Working directory: ${color65.bold(ctx.workingDir)}`,
|
|
29568
|
+
color65.dim(` (relative to root: ${rel2})`),
|
|
29569
|
+
color65.dim(` Project root: ${ctx.projectRoot}`)
|
|
29467
29570
|
].join("\n")
|
|
29468
29571
|
};
|
|
29469
29572
|
}
|
|
@@ -29472,7 +29575,7 @@ function buildWorkingDirCommand(_opts) {
|
|
|
29472
29575
|
const rel = path21.relative(root, resolved);
|
|
29473
29576
|
if (rel.startsWith("..") || path21.isAbsolute(rel)) {
|
|
29474
29577
|
return {
|
|
29475
|
-
message:
|
|
29578
|
+
message: color65.red(
|
|
29476
29579
|
`Directory "${trimmed}" is outside the project root.
|
|
29477
29580
|
Resolved: ${resolved}
|
|
29478
29581
|
Root: ${root}`
|
|
@@ -29482,25 +29585,25 @@ function buildWorkingDirCommand(_opts) {
|
|
|
29482
29585
|
try {
|
|
29483
29586
|
const stat5 = await fs18.stat(resolved);
|
|
29484
29587
|
if (!stat5.isDirectory()) {
|
|
29485
|
-
return { message:
|
|
29588
|
+
return { message: color65.red(`Not a directory: ${resolved}`) };
|
|
29486
29589
|
}
|
|
29487
29590
|
} catch {
|
|
29488
|
-
return { message:
|
|
29591
|
+
return { message: color65.red(`Directory does not exist: ${resolved}`) };
|
|
29489
29592
|
}
|
|
29490
29593
|
const previous = ctx.workingDir;
|
|
29491
29594
|
try {
|
|
29492
29595
|
ctx.setWorkingDir(resolved);
|
|
29493
29596
|
} catch (err) {
|
|
29494
29597
|
return {
|
|
29495
|
-
message:
|
|
29598
|
+
message: color65.red(toErrorMessage28(err))
|
|
29496
29599
|
};
|
|
29497
29600
|
}
|
|
29498
29601
|
const prevRel = path21.relative(ctx.projectRoot, previous) || ".";
|
|
29499
29602
|
const newRel = path21.relative(ctx.projectRoot, resolved) || ".";
|
|
29500
29603
|
return {
|
|
29501
29604
|
message: [
|
|
29502
|
-
|
|
29503
|
-
|
|
29605
|
+
color65.green(` \u2713 ${prevRel} \u2192 ${color65.bold(newRel)}`),
|
|
29606
|
+
color65.dim(` ${resolved}`)
|
|
29504
29607
|
].join("\n")
|
|
29505
29608
|
};
|
|
29506
29609
|
}
|
|
@@ -29569,7 +29672,7 @@ function buildWorktreeCommand(opts) {
|
|
|
29569
29672
|
}
|
|
29570
29673
|
|
|
29571
29674
|
// src/slash-commands/yolo.ts
|
|
29572
|
-
import { color as
|
|
29675
|
+
import { color as color66 } from "@wrongstack/core/utils";
|
|
29573
29676
|
function buildYoloCommand(opts) {
|
|
29574
29677
|
return {
|
|
29575
29678
|
name: "yolo",
|
|
@@ -29593,7 +29696,7 @@ function buildYoloCommand(opts) {
|
|
|
29593
29696
|
}
|
|
29594
29697
|
if (!arg) {
|
|
29595
29698
|
const current = opts.onYolo();
|
|
29596
|
-
const status = current ? `${
|
|
29699
|
+
const status = current ? `${color66.yellow("ON")} ${color66.dim("(auto-approving tool calls)")}` : `${color66.green("OFF")} ${color66.dim("(permission prompts active)")}`;
|
|
29597
29700
|
const msg2 = `YOLO mode: ${status}`;
|
|
29598
29701
|
opts.renderer.write(msg2);
|
|
29599
29702
|
return { message: msg2 };
|
|
@@ -29608,11 +29711,11 @@ function buildYoloCommand(opts) {
|
|
|
29608
29711
|
} else if (arg === "destructive") {
|
|
29609
29712
|
const currentMode = opts.onYolo();
|
|
29610
29713
|
if (!currentMode) {
|
|
29611
|
-
const msg3 = `${
|
|
29714
|
+
const msg3 = `${color66.amber("YOLO is OFF.")} Destructive-gate flags are deprecated; prompts are active because YOLO is off.`;
|
|
29612
29715
|
opts.renderer.writeWarning(msg3);
|
|
29613
29716
|
return { message: msg3 };
|
|
29614
29717
|
}
|
|
29615
|
-
const msg2 = `${
|
|
29718
|
+
const msg2 = `${color66.amber("Destructive gate:")} ${color66.dim("deprecated \u2014 YOLO auto-approves all non-denied tool calls.")}`;
|
|
29616
29719
|
opts.renderer.writeWarning(msg2);
|
|
29617
29720
|
return { message: msg2 };
|
|
29618
29721
|
} else {
|
|
@@ -29621,7 +29724,7 @@ function buildYoloCommand(opts) {
|
|
|
29621
29724
|
return { message: msg2 };
|
|
29622
29725
|
}
|
|
29623
29726
|
opts.onYolo(newState);
|
|
29624
|
-
const label = newState ? `${
|
|
29727
|
+
const label = newState ? `${color66.yellow("ENABLED")} \u2014 tool calls will be auto-approved unless explicitly denied` : `${color66.green("DISABLED")} \u2014 permission prompts are active`;
|
|
29625
29728
|
const msg = `YOLO mode: ${label}`;
|
|
29626
29729
|
opts.renderer.write(msg);
|
|
29627
29730
|
return { message: msg };
|
|
@@ -29695,6 +29798,7 @@ function buildBuiltinSlashCommands(opts) {
|
|
|
29695
29798
|
buildFixCommand(opts),
|
|
29696
29799
|
buildWorktreeCommand(opts),
|
|
29697
29800
|
buildSettingsCommand(opts),
|
|
29801
|
+
buildSidebarCommand(opts),
|
|
29698
29802
|
buildHqCommand(opts),
|
|
29699
29803
|
buildTelegramSetupCommand(opts),
|
|
29700
29804
|
buildTelegramSettingsCommand(opts),
|
|
@@ -32228,11 +32332,19 @@ function setupProviderRuntime(deps) {
|
|
|
32228
32332
|
}
|
|
32229
32333
|
const switchProviderAndModel = async (providerId, modelId) => context.runModelTransition(async () => {
|
|
32230
32334
|
try {
|
|
32335
|
+
statusTracker?.unblock(providerId, modelId);
|
|
32231
32336
|
const nextProvider = await buildProviderForModel(providerId, modelId);
|
|
32232
32337
|
configStore.update({ provider: providerId, model: modelId });
|
|
32233
32338
|
sync(patchConfig(cfg, { provider: providerId, model: modelId }));
|
|
32339
|
+
const from = context.provider ? { providerId: context.provider.id, model: context.model } : void 0;
|
|
32234
32340
|
context.provider = nextProvider;
|
|
32235
32341
|
context.model = modelId;
|
|
32342
|
+
events?.emit("provider.model_switched", {
|
|
32343
|
+
sessionId: context.session?.id,
|
|
32344
|
+
from,
|
|
32345
|
+
to: { providerId, model: modelId },
|
|
32346
|
+
timestamp: Date.now()
|
|
32347
|
+
});
|
|
32236
32348
|
await Promise.all([
|
|
32237
32349
|
refreshMaxContextFor(providerId, modelId),
|
|
32238
32350
|
refreshActiveReasoningConfig(providerId, modelId)
|
|
@@ -32783,6 +32895,7 @@ async function setupSession(params) {
|
|
|
32783
32895
|
let restoredEvents = [];
|
|
32784
32896
|
let resumedModel;
|
|
32785
32897
|
let resumedProvider;
|
|
32898
|
+
let resumedUsage;
|
|
32786
32899
|
if (resumeId) {
|
|
32787
32900
|
let claimHandle;
|
|
32788
32901
|
try {
|
|
@@ -32802,6 +32915,10 @@ async function setupSession(params) {
|
|
|
32802
32915
|
restoredEvents = resumed.data.events ?? [];
|
|
32803
32916
|
resumedModel = resumed.data.metadata.model;
|
|
32804
32917
|
resumedProvider = resumed.data.metadata.provider;
|
|
32918
|
+
resumedUsage = resumed.data.usage;
|
|
32919
|
+
if (resumed.data.usage) {
|
|
32920
|
+
tokenCounter.account(resumed.data.usage, resumedModel, resumedProvider);
|
|
32921
|
+
}
|
|
32805
32922
|
renderer.writeInfo(
|
|
32806
32923
|
`Resumed session ${resumed.data.metadata.id} \u2014 ${restoredMessages.length} messages, ${restoredToolCalls.length} tool executions, ${resumed.data.usage.input + resumed.data.usage.output} tokens used previously.`
|
|
32807
32924
|
);
|
|
@@ -32844,6 +32961,9 @@ async function setupSession(params) {
|
|
|
32844
32961
|
agentName: "Leader Agent",
|
|
32845
32962
|
traceId
|
|
32846
32963
|
});
|
|
32964
|
+
if (typeof resumedUsage?.input === "number" && resumedUsage.input > 0) {
|
|
32965
|
+
context.lastRequestTokens = resumedUsage.input;
|
|
32966
|
+
}
|
|
32847
32967
|
context.meta["packageTrackerOpts"] = {
|
|
32848
32968
|
storageDir: wpaths.projectDir,
|
|
32849
32969
|
projectRoot
|
|
@@ -33513,7 +33633,7 @@ function wireSessionEvents(deps) {
|
|
|
33513
33633
|
}
|
|
33514
33634
|
|
|
33515
33635
|
// src/session-stats.ts
|
|
33516
|
-
import { color as
|
|
33636
|
+
import { color as color67 } from "@wrongstack/core/utils";
|
|
33517
33637
|
var SESSION_STATS_MAX_PATHS = 1e4;
|
|
33518
33638
|
function addBoundedPath(set, path34) {
|
|
33519
33639
|
if (set.has(path34)) return;
|
|
@@ -33604,13 +33724,13 @@ var SessionStats = class {
|
|
|
33604
33724
|
const elapsedSec = ((Date.now() - this.startedAt) / 1e3).toFixed(1);
|
|
33605
33725
|
const lines = [];
|
|
33606
33726
|
lines.push("");
|
|
33607
|
-
lines.push(
|
|
33608
|
-
lines.push(
|
|
33727
|
+
lines.push(color67.bold("Session report"));
|
|
33728
|
+
lines.push(color67.dim("\u2500".repeat(40)));
|
|
33609
33729
|
lines.push(` Elapsed: ${elapsedSec}s`);
|
|
33610
33730
|
lines.push(` Iterations: ${this.iterations}`);
|
|
33611
33731
|
lines.push(` API requests: ${this.apiRequests}`);
|
|
33612
33732
|
if (this.errors > 0) {
|
|
33613
|
-
lines.push(` Errors: ${
|
|
33733
|
+
lines.push(` Errors: ${color67.yellow(String(this.errors))}`);
|
|
33614
33734
|
}
|
|
33615
33735
|
lines.push("");
|
|
33616
33736
|
lines.push(
|
|
@@ -33620,48 +33740,48 @@ var SessionStats = class {
|
|
|
33620
33740
|
if (cache.readTokens > 0 || cache.writeTokens > 0) {
|
|
33621
33741
|
const pct2 = (cache.hitRatio * 100).toFixed(1);
|
|
33622
33742
|
lines.push(
|
|
33623
|
-
` Prompt cache: ${pct2}% hit ${
|
|
33743
|
+
` Prompt cache: ${pct2}% hit ${color67.dim(`(${fmtTok(cache.readTokens)} read / ${fmtTok(cache.writeTokens)} write)`)}`
|
|
33624
33744
|
);
|
|
33625
33745
|
}
|
|
33626
33746
|
if (cost.total > 0) {
|
|
33627
33747
|
lines.push(
|
|
33628
|
-
` Cost: $${cost.total.toFixed(4)}${
|
|
33748
|
+
` Cost: $${cost.total.toFixed(4)}${color67.dim(` (in $${cost.input.toFixed(4)} / out $${cost.output.toFixed(4)})`)}`
|
|
33629
33749
|
);
|
|
33630
33750
|
} else {
|
|
33631
|
-
lines.push(` Cost: ${
|
|
33751
|
+
lines.push(` Cost: ${color67.dim("$0 (no pricing on this plan)")}`);
|
|
33632
33752
|
}
|
|
33633
33753
|
if (this.toolStats.size > 0) {
|
|
33634
33754
|
lines.push("");
|
|
33635
|
-
lines.push(` ${
|
|
33755
|
+
lines.push(` ${color67.bold("Tool calls")}`);
|
|
33636
33756
|
const sorted = [...this.toolStats.entries()].sort(
|
|
33637
33757
|
(a, b) => b[1].ok + b[1].fail - (a[1].ok + a[1].fail)
|
|
33638
33758
|
);
|
|
33639
33759
|
for (const [name, s] of sorted) {
|
|
33640
33760
|
const total = s.ok + s.fail;
|
|
33641
|
-
const failPart = s.fail > 0 ?
|
|
33761
|
+
const failPart = s.fail > 0 ? color67.yellow(` (${s.fail} failed)`) : "";
|
|
33642
33762
|
const avgMs = total > 0 ? Math.round(s.totalMs / total) : 0;
|
|
33643
33763
|
lines.push(
|
|
33644
|
-
` ${name.padEnd(12)} ${String(total).padStart(3)}\xD7 ${
|
|
33764
|
+
` ${name.padEnd(12)} ${String(total).padStart(3)}\xD7 ${color67.dim(`avg ${avgMs}ms`)}${failPart}`
|
|
33645
33765
|
);
|
|
33646
33766
|
}
|
|
33647
33767
|
}
|
|
33648
33768
|
const fileActivity = this.readPaths.size > 0 || this.editedPaths.size > 0 || this.writtenPaths.size > 0 || this.bytesWritten > 0;
|
|
33649
33769
|
if (fileActivity) {
|
|
33650
33770
|
lines.push("");
|
|
33651
|
-
lines.push(` ${
|
|
33771
|
+
lines.push(` ${color67.bold("Files")}`);
|
|
33652
33772
|
if (this.readPaths.size > 0)
|
|
33653
33773
|
lines.push(
|
|
33654
|
-
` read: ${this.readPaths.size} ${
|
|
33774
|
+
` read: ${this.readPaths.size} ${color67.dim(samplePaths(this.readPaths))}`
|
|
33655
33775
|
);
|
|
33656
33776
|
if (this.editedPaths.size > 0)
|
|
33657
33777
|
lines.push(
|
|
33658
|
-
` edited: ${this.editedPaths.size} ${
|
|
33778
|
+
` edited: ${this.editedPaths.size} ${color67.dim(samplePaths(this.editedPaths))}`
|
|
33659
33779
|
);
|
|
33660
33780
|
if (this.writtenPaths.size > 0) {
|
|
33661
33781
|
const bytes = this.bytesWritten;
|
|
33662
33782
|
const byteStr = bytes > 1024 ? `${(bytes / 1024).toFixed(1)}KB` : `${bytes}B`;
|
|
33663
33783
|
lines.push(
|
|
33664
|
-
` written: ${this.writtenPaths.size} (${byteStr}) ${
|
|
33784
|
+
` written: ${this.writtenPaths.size} (${byteStr}) ${color67.dim(samplePaths(this.writtenPaths))}`
|
|
33665
33785
|
);
|
|
33666
33786
|
}
|
|
33667
33787
|
}
|
|
@@ -34109,6 +34229,7 @@ async function runInteractive(cliCtx) {
|
|
|
34109
34229
|
logger,
|
|
34110
34230
|
teardownHandlers
|
|
34111
34231
|
});
|
|
34232
|
+
container.override(TOKENS13.ProviderModelStatusTracker, () => statusTracker);
|
|
34112
34233
|
bootstrapWrongProxy(config.tools?.wrongProxy);
|
|
34113
34234
|
await awaitFirstWrongProxyProbe();
|
|
34114
34235
|
const { buildProviderForId: buildProviderForId2, buildProviderForModel, switchProviderAndModel } = setupProviderRuntime({
|
|
@@ -34545,4 +34666,4 @@ export {
|
|
|
34545
34666
|
CLI_VERSION,
|
|
34546
34667
|
runInteractive
|
|
34547
34668
|
};
|
|
34548
|
-
//# sourceMappingURL=cli-main-
|
|
34669
|
+
//# sourceMappingURL=cli-main-UOQ2ICUO.js.map
|