Safety notes
Verified with notes
Command rewriting and output compaction for RTK-heavy workflows.
Command rewriting and output compaction for RTK-heavy workflows.
Static scan findings
This is a first-pass static screen, not a formal audit. It flags patterns worth reading before install.
MEDIUM · token_access
README.md
Multi-stage pipeline to reduce token consumption:├── command-rewriter.ts # Command tokenization and rewrite logic
MEDIUM · token_access
package.json
"token-optimization",
MEDIUM · spawn_shell
CHANGELOG.md
- Inline command flag detection for `bash`, `powershell`, and `cmd` shells
MEDIUM · token_access
CHANGELOG.md
- Improved command tokenization so `sed` scripts, shell separators, redirects, and background operators do not break later rewrites.
MEDIUM · spawn_shell
src/types-shims.d.ts
exec(
MEDIUM · spawn_shell
src/index.ts
const result = await pi.exec("rtk", ["--version"], { timeout: 5000 });
MEDIUM · token_access
src/output-compactor-test.ts
"[rtk] /!\\ No hook installed — run `rtk init -g` for automatic token savings\n\n4 files changed\n",content: [{ type: "text", text: "[rtk] /!\\ No hook installed — run `rtk init -g` for automatic token savings\n" }],"⚠️ Hook outdated — run `rtk init -g` to update\n\nSaved 42 tokens\n",
MEDIUM · token_access
src/config-modal.ts
description: "Compact bash/read/grep tool results to reduce token usage",description: "Condense git command output for lower token usage",description: "Bash rewrite + tool output compaction for lower token usage",
MEDIUM · token_access
src/additional-coverage-test.ts
stripRtkHookWarnings("No hook installed — run `rtk init -g` for automatic token savings\n\nready\n", null),"?? bun.lock[rtk] /!\\ No hook installed — run `rtk init -g` for automatic token savings\n",stripRtkHookWarnings("[rtk] /!\\ No hook installed — run `rtk init -g` for automatic token savings\n\n", "rtk git status"),
MEDIUM · spawn_shell
src/rtk-rewrite-provider.ts
const result = await pi.exec("rtk", ["rewrite", command], { timeout: timeoutMs });
Package scripts captured
package.json
{
"build": "npx --yes -p typescript@5.7.3 tsc -p tsconfig.json --noCheck",
"lint": "npm run build",
"typecheck": "npx --yes -p typescript@5.7.3 tsc -p tsconfig.json",
"test": "bun ./src/output-compactor-test.ts && bun ./src/command-rewriter-test.ts && bun ./src/runtime-guard-test.ts && bun ./src/additional-coverage-test.ts && bun ./src/config-modal-test.ts && bun ./src/index-test.ts",
"check": "npm run lint && npm run typecheck && npm run test",
"build:check": "bunx esbuild ./index.ts --bundle --platform=node --format=esm --outfile=./.pi-rtk-optimizer-check.mjs --external:@mariozechner/pi-coding-agent --external:@mariozechner/pi-tui && bun -e \"import { unlinkSync } from 'node:fs'; unlinkSync('./.pi-rtk-optimizer-check.mjs');\""
}