Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
],
"PostToolUse": [
{
"matcher": "Bash|Agent|WebFetch|WebSearch|Grep|Glob|mcp__.*",
"matcher": "Bash|PowerShell|Agent|WebFetch|WebSearch|Grep|Glob|mcp__.*",
"hooks": [
{
"type": "command",
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ Format loosely follows [Keep a Changelog](https://keepachangelog.com/).

### Added
- **Antigravity `PreToolUse` command-wrapping hook.** On Unix, `npx chisle --only antigravity` now copies the runner/compressor into `.agents/chisle-hooks/` and merges a `PreToolUse` `run_command` hook into `.agents/hooks.json` (preserving sibling hooks on both install and uninstall). Wraps commands when Antigravity CLI `toolPermission` is `always-proceed` (or `CHISLE_COMPRESS_WRAP=1`), skips programs guarded by `permissions.deny`/`permissions.ask` in `~/.gemini/antigravity-cli/settings.json`, and routes compression stats to `~/.gemini/config` via `--state-dir`.

- **Claude Code compresses `PowerShell` tool output.** `PowerShell` is Claude Code's shell tool on Windows. `powershell` was already on the Copilot and Pi allowlists, but it was missing from Claude Code's and from both PostToolUse matchers, so the hook never started for it. It joins `SAFE_TOOLS`, the plugin manifest matcher and the standalone installer's matcher. A test now fails if an allowlisted tool is missing from a matcher.
### Fixed
- **Command filters leave other commands' output alone.** A compound call with a segment they don't recognise that prints (`git status && cat m.py`) is no longer filtered, so that command's blank lines, diff headers and `ok N` lines reach the agent unchanged. `cd`, `export`, plain assignments, `true` and `:` don't count.

### Docs
- The config file's Windows path, `%APPDATA%\chisle\config.json`, in `INSTALL.md`, `docs/usage.md` and `docs/install-windows.md`.

## [3.14.2] - 2026-11-19

Patch: the star prompt reports star and follow separately, and the site shows each agent's logo.
Expand Down
5 changes: 5 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ Pi: start a session. Footer shows `[CHISLE]`; `/chisle off`, `stop chisle`, or `

Pi's default compression allowlist includes `bash`, `powershell`, `grep`, `find`, `ls`, and MCP tools. Add extension tools explicitly with `CHISLE_COMPRESS_TOOLS`. `read`, `edit`, and `write` are always untouched because exact output may feed later edits.

Claude Code's default compression allowlist is `Bash`, `PowerShell` (its shell tool on Windows), `Agent`, `WebFetch`, `WebSearch`, `Grep`, `Glob`, and MCP tools. `Read`, `Edit`, and `Write` are always untouched, for the same reason.

## Status badge

Pi's extension configures its footer badge automatically. Claude Code's standalone fallback configures the bundled statusline when no existing statusline is present. Manual Claude setup:
Expand Down Expand Up @@ -245,6 +247,9 @@ export CHISLE_DEFAULT_MODE=off
{ "defaultMode": "off" }
```

On Windows the file is `%APPDATA%\chisle\config.json`. `XDG_CONFIG_HOME`, when set,
wins on every platform: `$XDG_CONFIG_HOME/chisle/config.json`.

At the end of a first install or update in an interactive terminal, the installer asks
whether to star the repo and follow @JayPokale on GitHub (`[y]es / [n]o / [L]ater`),
leading with the tokens Chisle has saved you when its ledger has any. Only a `y` does
Expand Down
2 changes: 1 addition & 1 deletion bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ function installClaudeHooks(ctx) {
}
SETTINGS.addCommandHook(settings, 'PostToolUse',
{ command: `"${node}" "${compress}"`, marker: 'chisle-compress-output', timeout: 10,
matcher: 'Bash|Agent|WebFetch|WebSearch|Grep|Glob|mcp__.*', statusMessage: 'Compressing tool output...' });
matcher: 'Bash|PowerShell|Agent|WebFetch|WebSearch|Grep|Glob|mcp__.*', statusMessage: 'Compressing tool output...' });

const psHost = IS_WIN && hasCmd('pwsh') ? 'pwsh' : (IS_WIN ? 'powershell' : null);
const slCmd = IS_WIN
Expand Down
13 changes: 13 additions & 0 deletions docs/install-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ On Windows the flag lives at:
The symlink-safety checks in `chisle-config.js` fall back to a home-directory
containment check on Windows (where `process.getuid` is unavailable).

## Config file

On Windows `config.json` lives at `%APPDATA%\chisle\config.json`, not
`~/.config/chisle/`. If `XDG_CONFIG_HOME` is set, it is
`%XDG_CONFIG_HOME%\chisle\config.json` instead.

## Tool-output compression

Claude Code runs shell commands on Windows through its `PowerShell` tool. That
tool is on the compression allowlist alongside `Bash`, and the same switches
apply (`CHISLE_COMPRESS=0`, `CHISLE_COMPRESS_MAX_CHARS`, ...). The `PreToolUse`
wrapper that filters failed test and build runs is not available on Windows.

## Troubleshooting

- **Badge not showing** → confirm `chisle-statusline.ps1` runs: `powershell -File hooks\chisle-statusline.ps1`
Expand Down
1 change: 1 addition & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export CHISLE_DEFAULT_MODE=off

# config file (persists across shells)
~/.config/chisle/config.json → { "defaultMode": "off" }
# Windows: %APPDATA%\chisle\config.json
```

Resolution: env var → config file → `on`. Valid: `off`, `on`.
Expand Down
4 changes: 3 additions & 1 deletion hooks/chisle-compress-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ const THRESHOLDS = { maxChars: 8000, headLines: 60, tailLines: 40 };

// Tools whose output is safe to elide. Read/Edit/Write are absent on purpose:
// their output feeds exact-match edits. mcp__* are read-only info tools.
const SAFE_TOOLS = ['Bash', 'Agent', 'WebFetch', 'WebSearch', 'Grep', 'Glob'];
// PowerShell is Claude Code's shell tool on Windows; its result has Bash's
// shape ({ stdout, stderr, interrupted, ... }).
const SAFE_TOOLS = ['Bash', 'PowerShell', 'Agent', 'WebFetch', 'WebSearch', 'Grep', 'Glob'];

// The correctness invariant, enforced rather than merely defaulted: these tools'
// output feeds later exact-match edits, so eliding it makes the model edit text
Expand Down
2 changes: 1 addition & 1 deletion site/public/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Key measured results (same model and prompts, only the injected ruleset differs;
- Tool output is 67.5% of session content across 171 real Claude Code transcripts; the compressor trims eligible outputs ~46%. On OpenCode a 30 KB log cut fresh input tokens 87%.
- Quality: 156/156 on auto-graded maths and coding problems (bare model 156/156).

Safety/correctness: the compressor runs behind an allowlist (Claude Code: Bash, Agent, WebFetch, WebSearch, Grep, Glob, mcp__*; Pi: bash, powershell, grep, find, ls, mcp__*; Copilot CLI: bash, powershell, grep, glob, web_fetch, web_search, task; MCP proxy: any tool not named like read/view/file/edit/write/patch) and never modifies Read/Edit/Write results, whose exact bytes feed later edits. Deterministic, zero dependencies, zero network calls, zero LLM calls. One mode, no intensity levels. Kill switches: CHISLE_COMPRESS=0, "stop chisle", /chisle off, npx chisle --uninstall.
Safety/correctness: the compressor runs behind an allowlist (Claude Code: Bash, PowerShell, Agent, WebFetch, WebSearch, Grep, Glob, mcp__*; Pi: bash, powershell, grep, find, ls, mcp__*; Copilot CLI: bash, powershell, grep, glob, web_fetch, web_search, task; MCP proxy: any tool not named like read/view/file/edit/write/patch) and never modifies Read/Edit/Write results, whose exact bytes feed later edits. Deterministic, zero dependencies, zero network calls, zero LLM calls. One mode, no intensity levels. Kill switches: CHISLE_COMPRESS=0, "stop chisle", /chisle off, npx chisle --uninstall.

Install: `npx chisle` (npm, auto-detects all 13 agents; `npx chisle mcp wrap` adds MCP output compression to Cursor, Windsurf, Cline, Kiro, Gemini, Qwen Code and Copilot CLI), `claude plugin marketplace add JayPokale/Chisle` then `claude plugin install chisle@chisle` (Claude Code plugin), or `pi install npm:chisle` (Pi package). Requires Node >= 18. MIT license.

Expand Down
10 changes: 5 additions & 5 deletions site/src/components/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ export default function Terminal() {

<Reveal delay={0.15}>
<p className="mt-4 text-xs text-dim">
Deterministic: no LLM calls, no network, no dependencies. Allowlist: Bash, Agent,
WebFetch, WebSearch, Grep, Glob, mcp__*. Never Read/Edit/Write. Claude Code sends a
failed command to PostToolUseFailure, which no hook can rewrite, so since 3.14 test,
build and install commands run through a small wrapper that filters them before they
exit (in bypass-permissions mode).
Deterministic: no LLM calls, no network, no dependencies. Allowlist: Bash, PowerShell,
Agent, WebFetch, WebSearch, Grep, Glob, mcp__*. Never Read/Edit/Write. Claude Code
sends a failed command to PostToolUseFailure, which no hook can rewrite, so since 3.14
test, build and install commands run through a small wrapper that filters them before
they exit (in bypass-permissions mode).
</p>
</Reveal>
</section>
Expand Down
89 changes: 88 additions & 1 deletion tests/test_compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { test } = require('node:test');
const assert = require('node:assert/strict');

const {
extractText, rebuildResponse, scrub, compress, transform, limitsFor, toolAllowed, processPayload, THRESHOLDS,
extractText, rebuildResponse, scrub, compress, transform, limitsFor, toolAllowed, processPayload, THRESHOLDS, SAFE_TOOLS,
} = require('../hooks/chisle-compress-output');

const FULL = THRESHOLDS;
Expand Down Expand Up @@ -413,3 +413,90 @@ test('the exclusion is case-insensitive and survives an empty override', () => {
if (saved !== undefined) process.env.CHISLE_COMPRESS_TOOLS = saved;
}
});

// ── Claude Code's PowerShell tool ────────────────────────────────────────────
// On Windows, Claude Code runs shell commands through a tool named `PowerShell`.
// Captured live from a PostToolUse payload (Claude Code 2.1.329, PowerShell 7.7):
// tool_response is { stdout, stderr, interrupted, isImage }, lines end in CRLF,
// and PowerShell's own error records arrive inline in stdout, not in stderr.
// Past 30,000 chars the harness truncates stdout itself and adds
// persistedOutputPath / persistedOutputSize.

const psRows = (n) => Array.from({ length: n }, (_, i) => `row ${i + 1} ${'x'.repeat(58)}`).join('\r\n');
const psResponse = (stdout, extra) => ({ stdout, stderr: '', interrupted: false, isImage: false, ...extra });
const psPayload = (stdout, extra) => ({
tool_name: 'PowerShell',
tool_input: { command: "1..300 | ForEach-Object { 'row ' + $_ + ' ' + ('x' * 58) }" },
tool_response: psResponse(stdout, extra),
});

function withEnv(name, value, fn) {
const saved = process.env[name];
process.env[name] = value;
try { return fn(); }
finally {
if (saved === undefined) delete process.env[name];
else process.env[name] = saved;
}
}

test('PowerShell is on the allowlist; Read/Edit/Write stay off it', () => {
assert.equal(toolAllowed('PowerShell'), true);
assert.ok(SAFE_TOOLS.includes('PowerShell'));
withEnv('CHISLE_COMPRESS_TOOLS', 'PowerShell,Read,Edit,Write', () => {
assert.equal(toolAllowed('PowerShell'), true);
for (const t of ['Read', 'Edit', 'Write']) assert.equal(toolAllowed(t), false, `${t} must stay excluded`);
});
});

test('a big PowerShell result is elided and rebuilt in the tool\'s own shape', () => {
withSpillDir(() => {
const payload = psPayload(psRows(300));
const out = processPayload(payload, 'on');
assert.ok(out && out.includes('[chisle: elided 200 lines'), 'PowerShell output was not elided');
assert.ok(out.startsWith('row 1 ') && out.includes('row 300 '), 'head or tail missing');
assert.ok(!out.includes('row 150 '), 'middle was not elided');
// Claude Code checks the replacement against the tool's output schema, so
// every field it sent must come back.
assert.deepEqual(rebuildResponse(payload.tool_response, out),
{ stdout: out, stderr: '', interrupted: false, isImage: false });
});
});

test('a rebuilt PowerShell result keeps the persisted-output fields', () => {
const res = psResponse('x'.repeat(30000), {
persistedOutputPath: 'C:\\Users\\me\\.claude\\projects\\p\\session\\tool-results\\abc123.txt',
persistedOutputSize: 71892,
});
const rebuilt = rebuildResponse(res, 'trimmed');
assert.equal(rebuilt.stdout, 'trimmed');
assert.equal(rebuilt.persistedOutputPath, res.persistedOutputPath);
assert.equal(rebuilt.persistedOutputSize, 71892);
});

test('PowerShell obeys the mode flag and every switch', () => {
withSpillDir(() => {
const payload = psPayload(psRows(300));
assert.ok(processPayload(payload, 'on'), 'baseline: this payload must compress');
assert.equal(processPayload(payload, 'off'), null);
assert.equal(processPayload(payload, null), null);
withEnv('CHISLE_COMPRESS', '0', () => assert.equal(processPayload(payload, 'on'), null));
withEnv('CHISLE_COMPRESS_TOOLS', 'Bash', () => assert.equal(processPayload(payload, 'on'), null));
withEnv('CHISLE_COMPRESS_MAX_CHARS', '1000000', () => {
const out = processPayload(payload, 'on');
assert.ok(out == null || !out.includes('[chisle: elided'), 'elided below the raised threshold');
});
});
});

test('the Claude Code hook matcher reaches every allowlisted tool, never Read/Edit/Write', () => {
// An allowlisted tool the matcher misses is never compressed: the hook does
// not fire for it. That is how PowerShell was covered for Copilot and Pi but
// not for Claude Code.
const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '.claude-plugin', 'plugin.json'), 'utf8'));
const matcher = manifest.hooks.PostToolUse[0].matcher;
const reaches = (tool) => new RegExp(`^(?:${matcher})$`).test(tool);
for (const tool of SAFE_TOOLS) assert.ok(reaches(tool), `${tool} is allowlisted but the hook never fires for it`);
assert.ok(reaches('mcp__server__tool'));
for (const tool of ['Read', 'Edit', 'Write', 'NotebookEdit']) assert.ok(!reaches(tool), `${tool} must not reach the compressor`);
});
23 changes: 23 additions & 0 deletions tests/test_installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -772,3 +772,26 @@ test('REGRESSION: --update upgrades an installed Claude plugin via plugin update
fs.rmSync(cfg, { recursive: true, force: true });
fs.rmSync(binDir, { recursive: true, force: true });
});

// The standalone wiring carries its own copy of the PostToolUse matcher. It has
// to stay equal to the plugin manifest's, or a tool is compressed under one
// install path and silently skipped under the other.
test('standalone Claude hooks register the same PostToolUse matcher as the plugin manifest', () => {
const cfg = fs.mkdtempSync(path.join(os.tmpdir(), 'chisle-cfg-'));
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'chisle-home-'));
const emptyBin = fs.mkdtempSync(path.join(os.tmpdir(), 'chisle-nopath-'));
// Empty PATH: no `claude` CLI, so the installer takes the standalone path.
const env = { HOME: home, USERPROFILE: home, XDG_CONFIG_HOME: path.join(home, 'xdg'), PATH: emptyBin };
try {
runCLI(['--only', 'claude', '--config-dir', cfg], { env });
const settings = JSON.parse(fs.readFileSync(path.join(cfg, 'settings.json'), 'utf8'));
const entry = ((settings.hooks && settings.hooks.PostToolUse) || [])
.find(e => e.hooks.some(h => h.command.includes('chisle-compress-output')));
assert.ok(entry, 'compressor hook not wired');
const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '.claude-plugin', 'plugin.json'), 'utf8'));
assert.equal(entry.matcher, manifest.hooks.PostToolUse[0].matcher);
assert.match(entry.matcher, /(?:^|\|)PowerShell(?:\||$)/);
} finally {
for (const d of [cfg, home, emptyBin]) fs.rmSync(d, { recursive: true, force: true });
}
});