Skip to content
Merged
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
22 changes: 16 additions & 6 deletions ansible/ansible-compact/filter.lf
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ansible/ansible-compact/lowfat.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
157 changes: 79 additions & 78 deletions aws/aws-compact/filter.lf
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion aws/aws-compact/lowfat.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
Loading