debabble 0.1.0 → 0.1.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.
- package/README.md +5 -5
- package/package.json +1 -1
- package/src/cli.mjs +1 -1
- package/src/hook.mjs +6 -6
package/README.md
CHANGED
|
@@ -63,9 +63,9 @@ It rewrites only when all of these hold; otherwise it prints nothing and the com
|
|
|
63
63
|
It starts with a program, not a shell builtin or keyword (`cd`, `time`, `export`, `source`, `exec`, …).
|
|
64
64
|
- Its first words match an entry in the list file, and it is not already a `debabble` line.
|
|
65
65
|
- `DEBABBLE` is not `off`, and the call is not `run_in_background`.
|
|
66
|
-
- `
|
|
67
|
-
(read from
|
|
68
|
-
A list without
|
|
66
|
+
- `debabble` is on `PATH`, at or past its version in `requires`
|
|
67
|
+
(read from its `package.json`, else from `debabble --version` within 1 second).
|
|
68
|
+
A list without that pin never rewrites.
|
|
69
69
|
- An allow rule in your user settings (`~/.claude/settings.json`, or `$CLAUDE_CONFIG_DIR/settings.json`),
|
|
70
70
|
the project's `.claude/settings.json` or a `.claude/settings.local.json` (in the project folder, the repo root,
|
|
71
71
|
or a worktree's main checkout) matches the rewritten line (for example `Bash(debabble -- pnpm test:*)`),
|
|
@@ -95,7 +95,7 @@ It rewrites only when all of these hold; otherwise it prints nothing and the com
|
|
|
95
95
|
On Linux, argv is read from `/proc/<pid>/cmdline`; a claude that rewrites its process title would hide `--settings` (untested on Linux).
|
|
96
96
|
|
|
97
97
|
**The built-in default list is a no-op.** Its `requires` is empty, so `debabble hook claude` without
|
|
98
|
-
`--list` never rewrites anything. Pass `--list <file>` with
|
|
98
|
+
`--list` never rewrites anything. Pass `--list <file>` with a `debabble` pin to turn the hook on.
|
|
99
99
|
Without `--list` the hook reads the shipped default under your own list file (see [Manage the wrap list](#manage-the-wrap-list)).
|
|
100
100
|
`--list <file>` reads that one file and skips the layering.
|
|
101
101
|
|
|
@@ -106,7 +106,7 @@ List file:
|
|
|
106
106
|
|
|
107
107
|
```json
|
|
108
108
|
{
|
|
109
|
-
"requires": { "
|
|
109
|
+
"requires": { "debabble": "0.1.0" },
|
|
110
110
|
"wrap": [
|
|
111
111
|
{ "match": "pnpm test", "show": "verdict" },
|
|
112
112
|
{ "match": "gh run view", "show": "excerpt" }
|
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
// `✓ <label> · 41.2s · log: <path>` (with `· 1 warning: "…"` and `· 1 error-like line: "…"` before the path when the log holds any), or for a red run
|
|
18
18
|
// `✗ <label> · exit 1 · 38.9s`, the excerpt indented two spaces, and a last line `log: <path>`. A timeout or kill is one line ending ` · log: <path>`.
|
|
19
19
|
// `--show excerpt` is for log readers (`gh run view --log`): green prints `✓ … · N failure lines of M` and those lines, red as above.
|
|
20
|
-
// `--` is required so a
|
|
20
|
+
// `--` is required so a tool that reads the line can find the command without knowing debabble's flags.
|
|
21
21
|
|
|
22
22
|
import { writeSync } from "node:fs";
|
|
23
23
|
import { constants } from "node:os";
|
package/src/hook.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Run: Claude Code pipes the hook JSON on stdin; settings entry: `{"type":"command","command":"debabble hook claude","timeout":5}` under PreToolUse, matcher `Bash`.
|
|
4
4
|
// When: every Bash call in a project that wires it.
|
|
5
5
|
// Env: DEBABBLE=off (no rewrite); CLAUDE_PROJECT_DIR (where project settings are read; else the hook JSON's `cwd`); HOME; CLAUDE_CONFIG_DIR (the user
|
|
6
|
-
// settings folder, else ~/.claude); PATH (where `
|
|
6
|
+
// settings folder, else ~/.claude); PATH (where `debabble` is looked up); any RULE_ENV variable set (no rewrite).
|
|
7
7
|
// Writes: nothing but stdout: either nothing (no rewrite) or one JSON line with `updatedInput`. Never a `permissionDecision`.
|
|
8
8
|
// Exit: 0 always (a usage error prints one line on stderr). Any other error prints nothing, so Claude Code runs the original command (costs tokens, never safety).
|
|
9
9
|
// Used by: bin/debabble.mjs; tested by test/hook.test.mjs.
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
// and it starts with a program, not a shell builtin or keyword (`cd`, `time`, `export`, `source`, `exec`, …);
|
|
19
19
|
// - its words start with a list entry's `match` words, and it is not already a debabble line;
|
|
20
20
|
// - DEBABBLE is not `off`; the call is not `run_in_background`;
|
|
21
|
-
// - `
|
|
21
|
+
// - `debabble` is on PATH (version from its package.json, else `--version`), at or past its pin in the list's `requires` (a missing pin counts as not met);
|
|
22
22
|
// - an allow rule in the user or project settings matches the rewritten line (the mirror), and no deny or ask rule matches either line;
|
|
23
23
|
// - every place Claude Code may take a deny or ask rule from is one the hook reads (blindSpot, ancestorBlindSpot): Claude Code checks its rules against the rewritten
|
|
24
24
|
// line only, so a deny the hook cannot see (`Bash(git push:*)` in an MDM profile or `--settings`) would not match `debabble -- git push …`.
|
|
25
|
-
// The rewrite is the prefix plus the exact original bytes, so the line
|
|
25
|
+
// The rewrite is the prefix plus the exact original bytes, so the line any other PreToolUse hook judged is the line that runs inside the wrapper.
|
|
26
26
|
|
|
27
27
|
import { execFileSync } from "node:child_process";
|
|
28
28
|
import { readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
@@ -32,8 +32,8 @@ import { NOT_PROGRAMS, readLayered } from "./list.mjs";
|
|
|
32
32
|
|
|
33
33
|
export { NOT_PROGRAMS };
|
|
34
34
|
|
|
35
|
-
// The
|
|
36
|
-
export const REQUIRED = {
|
|
35
|
+
// The program whose version gates a rewrite, and its npm package (to find its package.json from the bin on PATH).
|
|
36
|
+
export const REQUIRED = { debabble: "debabble" };
|
|
37
37
|
const PACKAGE_DEPTH = 6;
|
|
38
38
|
// The fallback `<bin> --version` (only when no package.json is found, as behind a pnpm, Volta or asdf shim) gives up after this long: no version, no rewrite.
|
|
39
39
|
const VERSION_TIMEOUT_MS = 1000;
|
|
@@ -197,7 +197,7 @@ export const compareVersions = (a, b) => {
|
|
|
197
197
|
const isDebabble = (word) => word === "debabble" || word.endsWith("/debabble");
|
|
198
198
|
|
|
199
199
|
// The pure core: the rewritten command, or null for no rewrite.
|
|
200
|
-
// facts: { background, versions: {
|
|
200
|
+
// facts: { background, versions: { debabble }, rules: { allow, deny, ask } (rule contents of `Bash(…)` entries), blind (a reason, or null) }.
|
|
201
201
|
export const decide = (line, list, env, facts) => {
|
|
202
202
|
if (env.DEBABBLE === "off" || facts.background !== false || facts.blind !== null) return null;
|
|
203
203
|
const words = readLine(line);
|