From f83eef2f09b6c2a67d1d64cf58de0c97f58c729c Mon Sep 17 00:00:00 2001 From: zdk Date: Fri, 9 Oct 2026 11:51:38 +0700 Subject: [PATCH] feat: named rules for every plugin - failed commands handled by one rule per file, with per-subcommand rules where the failure view is not raw (go test, cargo test, npm audit) - single catch-all plugins become one flat rule per level - terraform: -json is truncated as JSON on every subcommand - bump converted plugins by one minor version --- README.md | 3 +- ansible/ansible-compact/filter.lf | 22 +++- ansible/ansible-compact/lowfat.toml | 2 +- aws/aws-compact/filter.lf | 157 +++++++++++------------ aws/aws-compact/lowfat.toml | 2 +- cargo/cargo-compact/filter.lf | 163 +++++++++++++----------- cargo/cargo-compact/lowfat.toml | 2 +- curl/curl-compact/filter.lf | 22 +++- curl/curl-compact/lowfat.toml | 2 +- git/git-compact/filter.lf | 110 ++++++++-------- git/git-compact/lowfat.toml | 2 +- go/go-compact/filter.lf | 113 ++++++++-------- go/go-compact/lowfat.toml | 2 +- helm/helm-compact/filter.lf | 76 +++++------ helm/helm-compact/lowfat.toml | 2 +- npm/npm-compact/filter.lf | 103 ++++++++------- npm/npm-compact/lowfat.toml | 2 +- psql/psql-compact/filter.lf | 22 +++- psql/psql-compact/lowfat.toml | 2 +- pytest/pytest-compact/filter.lf | 23 +++- pytest/pytest-compact/lowfat.toml | 2 +- terraform/terraform-compact/filter.lf | 151 ++++++++++++---------- terraform/terraform-compact/lowfat.toml | 2 +- 23 files changed, 537 insertions(+), 450 deletions(-) diff --git a/README.md b/README.md index c820c53..89c4427 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,8 @@ build|check: A named rule lists what it matches as fields. The first rule whose fields all hold runs, so shared policy is written once. Needs lowfat 0.9.0. -See [`kubectl-compact`](kubectl/kubectl-compact/filter.lf) for a full file. +Every plugin in this repo is written this way. See +[`kubectl-compact`](kubectl/kubectl-compact/filter.lf) for a full file. ``` rule failed: diff --git a/ansible/ansible-compact/filter.lf b/ansible/ansible-compact/filter.lf index dbd22cb..1910fdf 100644 --- a/ansible/ansible-compact/filter.lf +++ b/ansible/ansible-compact/filter.lf @@ -17,19 +17,29 @@ define strip-meta: drop /^\s*$/ drop /^\*+$/ -# ── default (only) ──────────────────────────────────────────────── -*: - if exit failed: +# ── failed commands ─────────────────────────────────────────────── +rule failed: + exit: failed + do: keep /^(PLAY |TASK |fatal:|FAILED|failed:|changed:|PLAY RECAP|\S+\s+:\s+ok=)/ head 300 - elif level ultra: + +# ── default (only) ──────────────────────────────────────────────── +rule ultra: + level: ultra + do: keep /^(PLAY \[|TASK \[|fatal:|failed:|changed:|PLAY RECAP|\S+\s+:\s+ok=)/ head 80 or "ansible-playbook: ok" - elif level lite: + +rule lite: + level: lite + do: drop-ok-status head 400 - else: + +rule default: + do: drop-ok-status strip-meta head 200 diff --git a/ansible/ansible-compact/lowfat.toml b/ansible/ansible-compact/lowfat.toml index 34a4cc3..ee70ab3 100644 --- a/ansible/ansible-compact/lowfat.toml +++ b/ansible/ansible-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "ansible-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact ansible/ansible-playbook output for LLM contexts" author = "zdk" commands = ["ansible-playbook", "ansible"] diff --git a/aws/aws-compact/filter.lf b/aws/aws-compact/filter.lf index a29e35d..22e7735 100644 --- a/aws/aws-compact/filter.lf +++ b/aws/aws-compact/filter.lf @@ -17,94 +17,95 @@ define strip-empty-collections: drop /^\s+"[A-Za-z]+": \{\},?$/ drop /^\s+"[A-Za-z]+": "",?$/ +# ── failed commands ─────────────────────────────────────────────── +# A failed command keeps its full error output. +rule failed: + exit: failed + do: raw + # ── ec2 / rds / lambda / ecs / eks / cloudformation (verbose JSON) ── -ec2|rds|lambda|ecs|eks|cloudformation|elbv2|elasticache: - if exit failed: - raw - elif level ultra: - strip-json-frame - strip-empty-collections - head 40 - elif level lite: - strip-empty-collections - head 500 - else: - strip-json-frame - strip-empty-collections - head 80 +rule ec2: + sub: ec2|rds|lambda|ecs|eks|cloudformation|elbv2|elasticache + do: + match level: + ultra: + strip-json-frame + strip-empty-collections + head 40 + lite: + strip-empty-collections + head 500 + else: + strip-json-frame + strip-empty-collections + head 80 # ── iam (huge with attached policies) ───────────────────────────── -iam: - if exit failed: - raw - elif level ultra: - keep /("(UserName|RoleName|PolicyName|Arn|CreateDate)":)/ - head 60 - elif level lite: - strip-empty-collections - head 500 - else: - strip-json-frame - strip-empty-collections - head 100 +rule iam: + sub: iam + do: + match level: + ultra: + keep /("(UserName|RoleName|PolicyName|Arn|CreateDate)":)/ + head 60 + lite: + strip-empty-collections + head 500 + else: + strip-json-frame + strip-empty-collections + head 100 # ── s3 (file listings) ──────────────────────────────────────────── -s3: - if exit failed: - raw - elif level ultra: - head 30 - elif level lite: - head 500 - else: - head 100 +rule s3: + sub: s3 + do: + match level: + ultra: head 30 + lite: head 500 + else: head 100 # ── logs (get-log-events: timestamps + messages) ────────────────── -logs: - if exit failed: - raw - elif level ultra: - head 40 - elif level lite: - head 500 - else: - head 100 +rule logs: + sub: logs + do: + match level: + ultra: head 40 + lite: head 500 + else: head 100 # ── dynamodb (type-annotated values inflate output) ─────────────── -dynamodb: - if exit failed: - raw - elif level ultra: - strip-json-frame - strip-empty-collections - head 40 - elif level lite: - strip-empty-collections - head 500 - else: - strip-json-frame - strip-empty-collections - head 100 +rule dynamodb: + sub: dynamodb + do: + match level: + ultra: + strip-json-frame + strip-empty-collections + head 40 + lite: + strip-empty-collections + head 500 + else: + strip-json-frame + strip-empty-collections + head 100 # ── sts / sqs / sns / ssm (smaller responses) ───────────────────── -sts|sqs|sns|ssm: - if exit failed: - raw - elif level ultra: - head 25 - elif level lite: - head 300 - else: - head 60 +rule sts: + sub: sts|sqs|sns|ssm + do: + match level: + ultra: head 25 + lite: head 300 + else: head 60 # ── default ─────────────────────────────────────────────────────── -*: - if exit failed: - raw - elif level ultra: - head 40 - elif level lite: - head 400 - else: - strip-empty-collections - head 80 +rule other: + do: + match level: + ultra: head 40 + lite: head 400 + else: + strip-empty-collections + head 80 diff --git a/aws/aws-compact/lowfat.toml b/aws/aws-compact/lowfat.toml index 3d0519b..d8771e6 100644 --- a/aws/aws-compact/lowfat.toml +++ b/aws/aws-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "aws-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact AWS CLI output for LLM contexts" author = "zdk" commands = ["aws"] diff --git a/cargo/cargo-compact/filter.lf b/cargo/cargo-compact/filter.lf index ea02c0e..ece7592 100644 --- a/cargo/cargo-compact/filter.lf +++ b/cargo/cargo-compact/filter.lf @@ -22,94 +22,107 @@ define strip-warn-meta: drop /^ --> / drop /^ = note:/ -# ── build / check ───────────────────────────────────────────────── -build|check: - if exit failed: - raw - elif level ultra: +# ── failed commands ─────────────────────────────────────────────── +rule test-failed: + sub: test + exit: failed + do: strip-compile - keep /(warning:|error|note: |help:)/ - head 40 - or "cargo $sub: ok" - elif level lite: + keep /(test result:|FAILED|failures:|---- |running |^test .+ \.\.\. (ok|FAILED|ignored)|panicked at|thread .+ panicked)/ head 250 - else: - strip-compile - head 80 + +# Every other failed command keeps its full error output. +rule failed: + exit: failed + do: raw + +# ── build / check ───────────────────────────────────────────────── +rule build: + sub: build|check + do: + match level: + ultra: + strip-compile + keep /(warning:|error|note: |help:)/ + head 40 + or "cargo $sub: ok" + lite: head 250 + else: + strip-compile + head 80 # ── clippy ──────────────────────────────────────────────────────── -clippy: - if exit failed: - raw - elif level ultra: - strip-compile - keep /(warning:|error|help:|^ = note:)/ - head 40 - or "cargo clippy: ok" - elif level lite: - head 300 - else: - strip-compile - head 100 +rule clippy: + sub: clippy + do: + match level: + ultra: + strip-compile + keep /(warning:|error|help:|^ = note:)/ + head 40 + or "cargo clippy: ok" + lite: head 300 + else: + strip-compile + head 100 # ── test ────────────────────────────────────────────────────────── -test: - if exit failed: - strip-compile - keep /(test result:|FAILED|failures:|---- |running |^test .+ \.\.\. (ok|FAILED|ignored)|panicked at|thread .+ panicked)/ - head 250 - elif level ultra: - keep /(test result:|FAILED|^test .+ \.\.\. (ok|FAILED))/ - head 40 - or "cargo test: ok" - elif level lite: - strip-compile - head 300 - else: - strip-compile - head 150 +rule test: + sub: test + do: + match level: + ultra: + keep /(test result:|FAILED|^test .+ \.\.\. (ok|FAILED))/ + head 40 + or "cargo test: ok" + lite: + strip-compile + head 300 + else: + strip-compile + head 150 # ── run / doc ───────────────────────────────────────────────────── -run|doc: - if exit failed: - raw - elif level ultra: - strip-compile - head 30 - elif level lite: - head 250 - else: - strip-compile - head 100 +rule run: + sub: run|doc + do: + match level: + ultra: + strip-compile + head 30 + lite: head 250 + else: + strip-compile + head 100 # ── update ──────────────────────────────────────────────────────── -update: - if exit failed: - raw - elif level ultra: - keep /(Updating |Adding |Removing |Locking|note:)/ - head 20 - or "cargo update: ok" - else: - head 60 +rule update: + sub: update + do: + match level: + ultra: + keep /(Updating |Adding |Removing |Locking|note:)/ + head 20 + or "cargo update: ok" + else: head 60 # ── fmt ─────────────────────────────────────────────────────────── -fmt: - if exit failed: raw - else: head 40 +rule fmt: + sub: fmt + do: head 40 # ── install / publish / bench ───────────────────────────────────── -install|publish|bench: - if exit failed: - raw - elif level ultra: - strip-compile - head 25 - else: - strip-compile - head 80 +rule install: + sub: install|publish|bench + do: + match level: + ultra: + strip-compile + head 25 + else: + strip-compile + head 80 # ── default ─────────────────────────────────────────────────────── -*: - if exit failed: raw - else: head 40 +rule other: + do: head 40 diff --git a/cargo/cargo-compact/lowfat.toml b/cargo/cargo-compact/lowfat.toml index dd3ed75..428c582 100644 --- a/cargo/cargo-compact/lowfat.toml +++ b/cargo/cargo-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "cargo-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact cargo output for LLM contexts" author = "zdk" commands = ["cargo"] diff --git a/curl/curl-compact/filter.lf b/curl/curl-compact/filter.lf index 8b7ed13..1c52221 100644 --- a/curl/curl-compact/filter.lf +++ b/curl/curl-compact/filter.lf @@ -20,19 +20,29 @@ define strip-progress: drop /^\s+% Total\s+% Received/ drop /^\s+Dload\s+Upload/ -# ── default (only) ──────────────────────────────────────────────── -*: - if exit failed: +# ── failed commands ─────────────────────────────────────────────── +rule failed: + exit: failed + do: strip-progress head 200 - elif level ultra: + +# ── default (only) ──────────────────────────────────────────────── +rule ultra: + level: ultra + do: strip-verbose strip-progress head 30 - elif level lite: + +rule lite: + level: lite + do: strip-progress head 300 - else: + +rule default: + do: strip-verbose strip-progress head 100 diff --git a/curl/curl-compact/lowfat.toml b/curl/curl-compact/lowfat.toml index ec913ce..ed8275a 100644 --- a/curl/curl-compact/lowfat.toml +++ b/curl/curl-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "curl-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact curl output for LLM contexts (strips verbose handshake + progress)" author = "zdk" commands = ["curl"] diff --git a/git/git-compact/filter.lf b/git/git-compact/filter.lf index 0d16b86..17f9713 100644 --- a/git/git-compact/filter.lf +++ b/git/git-compact/filter.lf @@ -17,11 +17,16 @@ define strip-hints: drop /^\s+\(use / drop /^\s+\(commit or discard / +# ── failed commands ─────────────────────────────────────────────── +# A failed command keeps its full error output. +rule failed: + exit: failed + do: raw + # ── status ──────────────────────────────────────────────────────── -status: - if exit failed: - raw - else: +rule status: + sub: status + do: match level: ultra: keep /^(On branch|Your branch|HEAD detached|nothing to commit| |modified:|new file:|deleted:|renamed:|Untracked files:|Changes (not staged|to be committed):)/ @@ -36,10 +41,9 @@ status: # ── log ─────────────────────────────────────────────────────────── # Date: lines are redundant with commit ordering; drop for an easy win on # unbounded `git log`. At ultra we keep only the metadata headers. -log: - if exit failed: - raw - else: +rule log: + sub: log + do: match level: ultra: keep /^(commit |Merge: |Author: )/ @@ -52,10 +56,9 @@ log: head 120 # ── diff / show ─────────────────────────────────────────────────── -diff|show: - if exit failed: - raw - else: +rule diff: + sub: diff|show + do: match level: ultra: keep /^(diff --git|@@|---|\+\+\+|\+[^+]|-[^-])/ @@ -66,56 +69,57 @@ diff|show: head 200 # ── push / pull / fetch / clone ─────────────────────────────────── -push|pull|fetch|clone: - if exit failed: - raw - elif level ultra: - strip-progress - keep /^(To |From | [0-9a-f]+\.\.[0-9a-f]+|Already up to date|Updating |Fast-forward| \d+ file|Branch |\* \[new)/ - head 10 - or-shell: printf 'git %s: ok' "$sub" - elif level lite: - strip-progress - head 60 - else: - strip-progress - head 25 +rule push: + sub: push|pull|fetch|clone + do: + match level: + ultra: + strip-progress + keep /^(To |From | [0-9a-f]+\.\.[0-9a-f]+|Already up to date|Updating |Fast-forward| \d+ file|Branch |\* \[new)/ + head 10 + or-shell: printf 'git %s: ok' "$sub" + lite: + strip-progress + head 60 + else: + strip-progress + head 25 # ── branch ──────────────────────────────────────────────────────── -branch: - if exit failed: - raw - else: +rule branch: + sub: branch + do: match level: ultra: head 25 lite: head 150 else: head 60 # ── add / reset / restore / stash / tag ────────────────────────── -add|reset|restore|stash|tag: - if exit failed: - raw - elif level ultra: - strip-hints - head 5 - or-shell: printf 'git %s: ok' "$sub" - else: - strip-hints - head 25 +rule add: + sub: add|reset|restore|stash|tag + do: + match level: + ultra: + strip-hints + head 5 + or-shell: printf 'git %s: ok' "$sub" + else: + strip-hints + head 25 # ── commit ──────────────────────────────────────────────────────── -commit: - if exit failed: - raw - elif level ultra: - keep /^\[/ - head 3 - or "git commit: ok" - else: - strip-hints - head 30 +rule commit: + sub: commit + do: + match level: + ultra: + keep /^\[/ + head 3 + or "git commit: ok" + else: + strip-hints + head 30 # ── default ─────────────────────────────────────────────────────── -*: - if exit failed: raw - else: head 40 +rule other: + do: head 40 diff --git a/git/git-compact/lowfat.toml b/git/git-compact/lowfat.toml index 22b7795..5da16f1 100644 --- a/git/git-compact/lowfat.toml +++ b/git/git-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "git-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact git output for LLM contexts" author = "zdk" commands = ["git", "g"] diff --git a/go/go-compact/filter.lf b/go/go-compact/filter.lf index 7a4ffe0..3744f64 100644 --- a/go/go-compact/filter.lf +++ b/go/go-compact/filter.lf @@ -2,69 +2,78 @@ # go-compact — compact go output for LLM contexts. # env: $sub $level $exit $args -# ── test ────────────────────────────────────────────────────────── -test: - if exit failed: +# ── failed commands ─────────────────────────────────────────────── +rule test-failed: + sub: test + exit: failed + do: keep /(^=== RUN|^--- FAIL|^--- PASS|^FAIL|^ok\b|^PASS\b|panic:|^\s+.+_test\.go:|Error:|--- SKIP)/ head 300 - elif level ultra: - keep /(^--- (FAIL|PASS)|^FAIL|^ok\b|^PASS\b)/ - head 50 - or "go test: ok" - elif level lite: - head 300 - else: - drop /^=== (RUN|PAUSE|CONT)/ - head 150 + +# Every other failed command keeps its full error output. +rule failed: + exit: failed + do: raw + +# ── test ────────────────────────────────────────────────────────── +rule test: + sub: test + do: + match level: + ultra: + keep /(^--- (FAIL|PASS)|^FAIL|^ok\b|^PASS\b)/ + head 50 + or "go test: ok" + lite: head 300 + else: + drop /^=== (RUN|PAUSE|CONT)/ + head 150 # ── build / vet ─────────────────────────────────────────────────── -build|vet: - if exit failed: - raw - elif level ultra: - head 30 - or "go $sub: ok" - else: - head 100 +rule build: + sub: build|vet + do: + match level: + ultra: + head 30 + or "go $sub: ok" + else: head 100 # ── mod ─────────────────────────────────────────────────────────── -mod: - if exit failed: - raw - elif level ultra: - head 30 - or "go mod: ok" - else: - head 100 +rule mod: + sub: mod + do: + match level: + ultra: + head 30 + or "go mod: ok" + else: head 100 # ── get / install ───────────────────────────────────────────────── -get|install: - if exit failed: - raw - elif level ultra: - keep /(go: (downloading|added|removed|upgraded)|Error)/ - head 25 - or "go $sub: ok" - else: - head 80 +rule get: + sub: get|install + do: + match level: + ultra: + keep /(go: (downloading|added|removed|upgraded)|Error)/ + head 25 + or "go $sub: ok" + else: head 80 # ── run ─────────────────────────────────────────────────────────── -run: - if exit failed: - raw - elif level ultra: - head 40 - elif level lite: - head 300 - else: - head 150 +rule run: + sub: run + do: + match level: + ultra: head 40 + lite: head 300 + else: head 150 # ── fmt ─────────────────────────────────────────────────────────── -fmt: - if exit failed: raw - else: head 40 +rule fmt: + sub: fmt + do: head 40 # ── default ─────────────────────────────────────────────────────── -*: - if exit failed: raw - else: head 40 +rule other: + do: head 40 diff --git a/go/go-compact/lowfat.toml b/go/go-compact/lowfat.toml index 2ae5a76..7a9b41e 100644 --- a/go/go-compact/lowfat.toml +++ b/go/go-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "go-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact go output for LLM contexts" author = "zdk" commands = ["go"] diff --git a/helm/helm-compact/filter.lf b/helm/helm-compact/filter.lf index d0e488f..9ff702e 100644 --- a/helm/helm-compact/filter.lf +++ b/helm/helm-compact/filter.lf @@ -8,11 +8,16 @@ # Every rule passes raw output straight through on a non-zero exit — # helm error blocks (failed release, hook failures) must reach the agent intact. +# ── failed commands ─────────────────────────────────────────────── +# A failed command keeps its full error output. +rule failed: + exit: failed + do: raw + # ── install / upgrade / status ──────────────────────────────────── -install|upgrade|status: - if exit failed: - raw - else: +rule install: + sub: install|upgrade|status + do: match level: ultra: keep /^(NAME:|LAST DEPLOYED:|STATUS:|REVISION:|NAMESPACE:|TEST SUITE:|Release ")/ @@ -24,20 +29,18 @@ install|upgrade|status: head 40 # ── list / ls ───────────────────────────────────────────────────── -list|ls: - if exit failed: - raw - else: +rule list: + sub: list|ls + do: match level: ultra: head 30 lite: head 200 else: head 80 # ── diff (helm-diff plugin) ─────────────────────────────────────── -diff: - if exit failed: - raw - else: +rule diff: + sub: diff + do: match level: ultra: keep /^(\+|-|@@|Plan: |default,)/ @@ -48,39 +51,36 @@ diff: head 200 # ── repo (add / update / list / remove) ─────────────────────────── -repo: - if exit failed: - raw - elif level ultra: - keep /(Update Complete|"[^"]+" has been added|"[^"]+" has been removed|"[^"]+" has been updated|^NAME\s|Error)/ - head 20 - elif level lite: - head 80 - else: - head 30 +rule repo: + sub: repo + do: + match level: + ultra: + keep /(Update Complete|"[^"]+" has been added|"[^"]+" has been removed|"[^"]+" has been updated|^NAME\s|Error)/ + head 20 + lite: head 80 + else: head 30 # ── search ──────────────────────────────────────────────────────── -search: - if exit failed: - raw - else: +rule search: + sub: search + do: match level: ultra: head 25 lite: head 200 else: head 80 # ── uninstall / rollback / history ──────────────────────────────── -uninstall|rollback|history: - if exit failed: - raw - elif level ultra: - keep /(uninstalled|Rollback was a success|^REVISION|Error|release "[^"]+" uninstalled)/ - head 12 - or-shell: printf 'helm %s: ok' "$sub" - else: - head 40 +rule uninstall: + sub: uninstall|rollback|history + do: + match level: + ultra: + keep /(uninstalled|Rollback was a success|^REVISION|Error|release "[^"]+" uninstalled)/ + head 12 + or-shell: printf 'helm %s: ok' "$sub" + else: head 40 # ── default ─────────────────────────────────────────────────────── -*: - if exit failed: raw - else: head 40 +rule other: + do: head 40 diff --git a/helm/helm-compact/lowfat.toml b/helm/helm-compact/lowfat.toml index bf167bc..f77da07 100644 --- a/helm/helm-compact/lowfat.toml +++ b/helm/helm-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "helm-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact helm output for LLM contexts" author = "zdk" commands = ["helm"] diff --git a/npm/npm-compact/filter.lf b/npm/npm-compact/filter.lf index 316e68e..976a249 100644 --- a/npm/npm-compact/filter.lf +++ b/npm/npm-compact/filter.lf @@ -7,48 +7,59 @@ define strip-deprecation: drop /^npm warn deprecated / drop /^npm WARN deprecated / +# ── failed commands ─────────────────────────────────────────────── +rule audit-failed: + sub: audit + exit: failed + do: + keep /(severity|vulnerabilities|^# npm|^to address|^npm audit|^[0-9]+ vulnerabilities)/ + head 200 + +# Every other failed command keeps its full error output. +rule failed: + exit: failed + do: raw + # ── install / i / ci ────────────────────────────────────────────── -install|i|ci: - if exit failed: - raw - elif level ultra: - keep /(added|removed|changed|audited|vulnerabilities|funding)/ - head 15 - or "npm $sub: ok" - elif level lite: - strip-deprecation - head 150 - else: - strip-deprecation - head 50 +rule install: + sub: install|i|ci + do: + match level: + ultra: + keep /(added|removed|changed|audited|vulnerabilities|funding)/ + head 15 + or "npm $sub: ok" + lite: + strip-deprecation + head 150 + else: + strip-deprecation + head 50 # ── list / ls ───────────────────────────────────────────────────── -list|ls: - if exit failed: - raw - else: +rule list: + sub: list|ls + do: match level: ultra: head 30 lite: head 250 else: head 100 # ── audit ───────────────────────────────────────────────────────── -audit: - if exit failed: - keep /(severity|vulnerabilities|^# npm|^to address|^npm audit|^[0-9]+ vulnerabilities)/ - head 200 - elif level ultra: - keep /(severity|vulnerabilities|^# npm|^to address|^[0-9]+ vulnerabilities)/ - head 30 - or "npm audit: ok" - else: - head 80 +rule audit: + sub: audit + do: + match level: + ultra: + keep /(severity|vulnerabilities|^# npm|^to address|^[0-9]+ vulnerabilities)/ + head 30 + or "npm audit: ok" + else: head 80 # ── outdated ────────────────────────────────────────────────────── -outdated: - if exit failed: - raw - else: +rule outdated: + sub: outdated + do: match level: ultra: head 30 lite: head 200 @@ -57,27 +68,25 @@ outdated: # ── run / test ──────────────────────────────────────────────────── # These pass through to user scripts; we cap by level but can't filter # semantically without knowing what the script does. -run|test: - if exit failed: - raw - else: +rule run: + sub: run|test + do: match level: ultra: head 60 lite: head 300 else: head 150 # ── update ──────────────────────────────────────────────────────── -update: - if exit failed: - raw - elif level ultra: - keep /(added|removed|changed|up to date)/ - head 15 - or "npm update: ok" - else: - head 60 +rule update: + sub: update + do: + match level: + ultra: + keep /(added|removed|changed|up to date)/ + head 15 + or "npm update: ok" + else: head 60 # ── default ─────────────────────────────────────────────────────── -*: - if exit failed: raw - else: head 40 +rule other: + do: head 40 diff --git a/npm/npm-compact/lowfat.toml b/npm/npm-compact/lowfat.toml index 7b03090..80d5256 100644 --- a/npm/npm-compact/lowfat.toml +++ b/npm/npm-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "npm-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact npm output for LLM contexts" author = "zdk" commands = ["npm"] diff --git a/psql/psql-compact/filter.lf b/psql/psql-compact/filter.lf index 78e467e..b9fbd60 100644 --- a/psql/psql-compact/filter.lf +++ b/psql/psql-compact/filter.lf @@ -15,19 +15,29 @@ define strip-notices: drop /^INFO: / drop /^DEBUG: / -# ── default (only) ──────────────────────────────────────────────── -*: - if exit failed: +# ── failed commands ─────────────────────────────────────────────── +rule failed: + exit: failed + do: strip-banner head 200 - elif level ultra: + +# ── default (only) ──────────────────────────────────────────────── +rule ultra: + level: ultra + do: strip-banner strip-notices head 40 - elif level lite: + +rule lite: + level: lite + do: strip-banner head 300 - else: + +rule default: + do: strip-banner strip-notices head 120 diff --git a/psql/psql-compact/lowfat.toml b/psql/psql-compact/lowfat.toml index b874da9..2de7882 100644 --- a/psql/psql-compact/lowfat.toml +++ b/psql/psql-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "psql-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact psql output for LLM contexts" author = "zdk" commands = ["psql"] diff --git a/pytest/pytest-compact/filter.lf b/pytest/pytest-compact/filter.lf index 7367c49..98f6e6f 100644 --- a/pytest/pytest-compact/filter.lf +++ b/pytest/pytest-compact/filter.lf @@ -4,18 +4,27 @@ # pytest has no subcommands (positional args are test paths/expressions), # so everything routes through the catch-all. -# ── default (only) ──────────────────────────────────────────────── -*: - if exit failed: +# ── failed commands ─────────────────────────────────────────────── +rule failed: + exit: failed + do: keep /(FAILED|ERROR|====|^E |^_+ .+_+$|^> |passed|failed|short test summary|collected )/ head 300 - elif level ultra: + +# ── default (only) ──────────────────────────────────────────────── +rule ultra: + level: ultra + do: keep /(passed|failed|skipped|PASSED|FAILED|====|short test summary|collected )/ head 40 or "pytest: ok" - elif level lite: - head 300 - else: + +rule lite: + level: lite + do: head 300 + +rule default: + do: drop /^platform .+ -- Python/ drop /^rootdir:/ drop /^plugins:/ diff --git a/pytest/pytest-compact/lowfat.toml b/pytest/pytest-compact/lowfat.toml index 3f76099..ffe7659 100644 --- a/pytest/pytest-compact/lowfat.toml +++ b/pytest/pytest-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "pytest-compact" -version = "0.1.1" +version = "0.2.0" description = "Compact pytest output for LLM contexts (failures-only at ultra)" author = "zdk" commands = ["pytest", "py.test"] diff --git a/terraform/terraform-compact/filter.lf b/terraform/terraform-compact/filter.lf index 7f74035..e603c5e 100644 --- a/terraform/terraform-compact/filter.lf +++ b/terraform/terraform-compact/filter.lf @@ -23,88 +23,99 @@ define strip-plan-banner: drop /^(Note: Objects have changed|Terraform (will perform|detected|used)|(plan\. )?Resource actions are indicated|Unless you have made|Saved the plan to:|To perform exactly these actions,| terraform apply )/ drop /^─+$/ +# ── failed commands ─────────────────────────────────────────────── +# A failed command keeps its full error output. +rule failed: + exit: failed + do: raw + +# `-json` on any subcommand. +rule json: + flag: -json + do: truncate-json + # ── plan ────────────────────────────────────────────────────────── -plan: - if exit failed: - raw - elif -json: - truncate-json - elif level ultra: - keep /^(Plan:|No changes\.|Error|Warning:)/ - head 5 - or "terraform plan: ok" - elif level lite: - strip-refresh - strip-plan-banner - head 120 - else: - strip-refresh - strip-plan-banner - head 60 +rule plan: + sub: plan + do: + match level: + ultra: + keep /^(Plan:|No changes\.|Error|Warning:)/ + head 5 + or "terraform plan: ok" + lite: + strip-refresh + strip-plan-banner + head 120 + else: + strip-refresh + strip-plan-banner + head 60 # ── apply / destroy ─────────────────────────────────────────────── -apply|destroy: - if exit failed: - raw - elif -json: - truncate-json - elif level ultra: - keep /^(Apply complete!|Destroy complete!|Error|Warning:)/ - head 5 - or-shell: printf 'terraform %s: ok' "$sub" - elif level lite: - strip-progress - head 100 - else: - strip-progress - head 50 +rule apply: + sub: apply|destroy + do: + match level: + ultra: + keep /^(Apply complete!|Destroy complete!|Error|Warning:)/ + head 5 + or-shell: printf 'terraform %s: ok' "$sub" + lite: + strip-progress + head 100 + else: + strip-progress + head 50 # ── init ────────────────────────────────────────────────────────── -init: - if exit failed: - raw - elif level ultra: - keep /(successfully initialized|Upgrading|Error|Warning:|^- (Installing|Using|Reusing|Finding))/ - head 10 - elif level lite: - keep /(Initializing|Successfully configured|^- (Installing|Installed|Using|Reusing|Finding|Downloading)|successfully initialized|Upgrading|Error|Warning:)/ - head 60 - else: - keep /(Initializing|Successfully configured|^- (Installing|Installed|Using|Reusing|Finding|Downloading)|successfully initialized|Upgrading|Error|Warning:)/ - head 30 +rule init: + sub: init + do: + match level: + ultra: + keep /(successfully initialized|Upgrading|Error|Warning:|^- (Installing|Using|Reusing|Finding))/ + head 10 + lite: + keep /(Initializing|Successfully configured|^- (Installing|Installed|Using|Reusing|Finding|Downloading)|successfully initialized|Upgrading|Error|Warning:)/ + head 60 + else: + keep /(Initializing|Successfully configured|^- (Installing|Installed|Using|Reusing|Finding|Downloading)|successfully initialized|Upgrading|Error|Warning:)/ + head 30 # ── validate ────────────────────────────────────────────────────── -validate: - if exit failed: raw - elif level ultra: - keep /(Success!|Error|Warning:)/ - head 10 - else: - head 40 +rule validate: + sub: validate + do: + match level: + ultra: + keep /(Success!|Error|Warning:)/ + head 10 + else: head 40 # ── fmt ─────────────────────────────────────────────────────────── -fmt: - if exit failed: raw - else: head 50 +rule fmt: + sub: fmt + do: head 50 # ── state (list / show) ────────────────────────────────────────── -state: - if exit failed: raw - elif -json: truncate-json - elif level ultra: head 30 - elif level lite: head 200 - else: head 80 +rule state: + sub: state + do: + match level: + ultra: head 30 + lite: head 200 + else: head 80 # ── output ─────────────────────────────────────────────────────── -output: - if exit failed: raw - elif -json: truncate-json - elif level ultra: head 40 - elif level lite: head 120 - else: head 80 +rule output: + sub: output + do: + match level: + ultra: head 40 + lite: head 120 + else: head 80 # ── default ────────────────────────────────────────────────────── -*: - if exit failed: raw - elif -json: truncate-json - else: head 30 +rule other: + do: head 30 diff --git a/terraform/terraform-compact/lowfat.toml b/terraform/terraform-compact/lowfat.toml index eb70c1c..2b915d5 100644 --- a/terraform/terraform-compact/lowfat.toml +++ b/terraform/terraform-compact/lowfat.toml @@ -1,6 +1,6 @@ [plugin] name = "terraform-compact" -version = "0.6.1" +version = "0.7.0" description = "Compact terraform/tf output for LLM contexts" author = "zdk" commands = ["terraform", "tf"]