Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix:/statusline set jq -r 不用加文件参数

openJiuwen-bot55a27522f533
diff --git a/jiuwenswarm/channels/tui/frontend/src/app-state.ts b/jiuwenswarm/channels/tui/frontend/src/app-state.ts
index 8b802dfc54..c06794878f 100644
--- a/jiuwenswarm/channels/tui/frontend/src/app-state.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/app-state.ts
@@ -1764,11 +1764,9 @@ export class CliPiAppState {
try {
if (isWindows) {
- // On Windows, sh.exe from MSYS2/Git Bash can't read stdin in $(cat)
- // inside sh -c. Solution: write JSON to a temp file and:
- // 1. Replace $(cat) (no args) with $(cat "filepath") for inline commands
- // 2. Export JIUWENSWARM_SL_FILE so script files can use it too:
- // input=$(cat "$JIUWENSWARM_SL_FILE")
+ // On Windows: pipe stdin (like POSIX) so `jq -r '.field'` works directly.
+ // Also write a temp file and export JIUWENSWARM_SL_FILE as a fallback for
+ // `$(cat "$JIUWENSWARM_SL_FILE")` style commands (sh -c can't $(cat) stdin).
const tmpFile = join(tmpdir(), "jiuwenswarm-sl.json");
writeFileSync(tmpFile, jsonInput, "utf8");
const msysPath = tmpFile
@@ -1791,6 +1789,9 @@ export class CliPiAppState {
}
},
);
+ // Pipe stdin so commands that read stdin directly (jq, python, etc.) work
+ // on Windows the same way they do on POSIX — aligning with Claude Code behavior.
+ child.stdin?.end(jsonInput);
} else {
// On POSIX, stdin piping works correctly in sh -c.
const child = execFile(
diff --git a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/statusline.ts b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/statusline.ts
index 17c34f0b81..079d8a2d00 100644
--- a/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/statusline.ts
+++ b/jiuwenswarm/channels/tui/frontend/src/core/commands/builtins/statusline.ts
@@ -19,8 +19,24 @@ function showCurrentConfig(ctx: CommandContext): void {
ctx.addItem(makeItem(ctx.sessionId, "info", `StatusLine\n ${lines.join("\n ")}`, "m"));
}
+function stripOuterQuotes(s: string): string {
+ const trimmed = s.trim();
+ if (trimmed.length < 2) return trimmed;
+ const first = trimmed[0];
+ const last = trimmed[trimmed.length - 1];
+ if ((first === "'" && last === "'") || (first === '"' && last === '"')) {
+ return trimmed.slice(1, -1);
+ }
+ return trimmed;
+}
+
+/** Unescape JSON-style backslash sequences so users can type `\"` to mean `"`, aligning with Claude Code's JSON config behavior. */
+function unescapeCommand(s: string): string {
+ return s.replace(/\\(["\\])/g, "$1");
+}
+
function setConfig(ctx: CommandContext, args: string): void {
- const command = args.trim().replace(/^['"]|['"]$/g, "");
+ const command = unescapeCommand(stripOuterQuotes(args));
if (!command) {
ctx.addItem(makeItem(ctx.sessionId, "error", "usage: /statusline set <command>", "m"));
return;