mirror of
https://github.com/alphaXiv/OpenResearch.git
synced 2026-11-11 09:59:34 +08:00
A draft that opens with `!` is a shell command, as in Claude Code: the
composer turns amber with a Bash chip, Enter (or the Run button) runs it
in the session's worktree through POST /api/chat/sessions/{id}/shell,
and the exchange lands on the transcript as a user-side card. Commands
run since the last real message are folded into the next turn's prompt
as untrusted context. Output is capped, the process group is killed on
timeout, and a backgrounded child cannot hold the request open.
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
21 lines
720 B
JavaScript
21 lines
720 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { bashCommand, withoutBashPrefix } from "../src/bashCommand.ts";
|
|
|
|
test("a leading ! turns the draft into a shell command", () => {
|
|
assert.equal(bashCommand("!ls -la"), "ls -la");
|
|
assert.equal(bashCommand("! git status "), "git status");
|
|
assert.equal(bashCommand("!"), "");
|
|
});
|
|
|
|
test("only the first character counts", () => {
|
|
assert.equal(bashCommand("ls !"), null);
|
|
assert.equal(bashCommand(" !ls"), null);
|
|
assert.equal(bashCommand(""), null);
|
|
});
|
|
|
|
test("leaving the mode keeps whatever was typed after the prefix", () => {
|
|
assert.equal(withoutBashPrefix("!ls"), "ls");
|
|
assert.equal(withoutBashPrefix("plain"), "plain");
|
|
});
|