@robhowley/pi-structured-return 1.6.0 → 1.6.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 +76 -83
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# pi-structured-return
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A [Pi](https://pi.dev/) extension that adds a `structured_return` tool alongside `bash`, returning compact parsed results with full logs — 60–95% fewer tokens without losing signal.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This Pi package adds a `structured_return` tool alongside `bash`. A bundled skill teaches the model when to reach for it — test suites, linters, build tools, data pipelines — anywhere verbose output burns tokens. It captures full logs, applies a parser, and returns a compact structured result. The full output stays on disk.
|
|
5
|
+
A failing test run, before and after:
|
|
8
6
|
|
|
9
7
|
**Raw pytest output (262 tokens):**
|
|
10
8
|
```
|
|
@@ -46,7 +44,17 @@ pytest test_math.py --junitxml=.tmp/report.xml → cwd: project
|
|
|
46
44
|
test_math.py:8 ZeroDivisionError: division by zero
|
|
47
45
|
```
|
|
48
46
|
|
|
49
|
-
262 → 56 tokens
|
|
47
|
+
262 → 56 tokens on a 3-test example. Real test suites are much larger — the reduction scales with them, saving thousands of tokens per run.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pi install npm:@robhowley/pi-structured-return
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Design
|
|
56
|
+
|
|
57
|
+
`structured_return` is a separate tool, not a wrapper around `bash`. Intercepting `bash` to silently rewrite commands would override a primitive the model and platform both rely on. Pi's philosophy is to extend rather than obfuscate: features are built on top of the platform, not hidden inside it. A dedicated tool honors that. It adds to the available surface, keeps `bash` honest, and leaves the choice explicit. The skill guides the model toward it; nothing is hijacked to get there.
|
|
50
58
|
|
|
51
59
|
## Token reduction
|
|
52
60
|
|
|
@@ -56,55 +64,66 @@ Measured with `cl100k_base` (tiktoken). All benchmarks use tiny fixtures — red
|
|
|
56
64
|
|
|
57
65
|
Benchmark: 3 tests — 1 passing, 1 assertion failure, 1 unexpected error.
|
|
58
66
|
|
|
59
|
-
|
|
|
67
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
68
|
+
|---|---|---|---|---|
|
|
69
|
+
| `mvn test` | 1063 | 86 | **92%** | build lifecycle noise with surefire stack traces per failure |
|
|
70
|
+
| `node --test` | 629 | 64 | **90%** | strips full stack traces, assertion internals, timing; preserves expected/actual |
|
|
71
|
+
| `npx ava` | 483 | 56 | **88%** | source snippets, diffs, full stack traces stripped; expected/actual preserved |
|
|
72
|
+
| `go test` | 394 | 48 | **88%** | stack traces, goroutine frames, panic recovery noise stripped; file:line + expected/actual preserved |
|
|
73
|
+
| `dotnet test` | 487 | 107 | **78%** | build header and VSTest output with per-failure stack traces |
|
|
74
|
+
| `npx vitest` | 348 | 75 | **78%** | source diff with inline arrows and ANSI color codes per failure |
|
|
75
|
+
| `python -m unittest` | 231 | 52 | **78%** | full tracebacks with source annotations; expected/actual from AssertionError |
|
|
76
|
+
| `cargo test` | 285 | 68 | **76%** | cargo progress + test binary output with panic traces per failure |
|
|
77
|
+
| `pytest` | 289 | 71 | **75%** | verbose output with source snippets and summary footer |
|
|
78
|
+
| `rspec` | 212 | 55 | **74%** | default output with backtrace |
|
|
79
|
+
| `gradle test` | 263 | 81 | **69%** | gradle console output with build lifecycle noise |
|
|
80
|
+
| `npx mocha` | 180 | 55 | **69%** | stack traces + assertion diff formatting; expected/actual preserved |
|
|
81
|
+
| `npx jest` | 309 | 99 | **68%** | source annotations with deep jest-circus stack traces per failure |
|
|
82
|
+
| `ruby` (minitest) | 168 | 59 | **65%** | default output with backtrace |
|
|
83
|
+
|
|
84
|
+
### Build tools and compilers
|
|
85
|
+
|
|
86
|
+
Benchmark: 1 file, 1–2 errors. Reduction scales with error count since raw output includes source snippets, caret indicators, and annotations per error.
|
|
87
|
+
|
|
88
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
60
89
|
|---|---|---|---|---|
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| `junit-xml` (pytest) | 289 | 71 | **75%** | verbose output with source snippets and summary footer |
|
|
71
|
-
| `rspec-json` | 212 | 55 | **74%** | default output with backtrace |
|
|
72
|
-
| `junit-xml` (gradle) | 263 | 81 | **69%** | gradle console output with build lifecycle noise |
|
|
73
|
-
| `mocha-json` | 180 | 55 | **69%** | stack traces + assertion diff formatting; expected/actual preserved |
|
|
74
|
-
| `junit-xml` (jest) | 309 | 99 | **68%** | source annotations with deep jest-circus stack traces per failure |
|
|
75
|
-
| `minitest-text` | 168 | 59 | **65%** | default output with backtrace |
|
|
76
|
-
|
|
77
|
-
### Linters, type checkers, and build tools
|
|
90
|
+
| `dotnet build` | 383 | 53 | **86%** | strips restore/timing noise, deduplicates repeated error lines, absolute paths relativized |
|
|
91
|
+
| `npx jsonlint` | 148 | 28 | **81%** | strips stack trace, source pointer line; preserves line number and expecting message |
|
|
92
|
+
| `tidy` | 233 | 51 | **78%** | strips remediation advice, accessibility tips, reformatted HTML output, Info lines |
|
|
93
|
+
| `cargo build` | 225 | 77 | **66%** | rustc error annotations with code spans and help text per error |
|
|
94
|
+
| `swiftc` | 161 | 58 | **64%** | source annotations with backtick markers deduplicated |
|
|
95
|
+
| `gcc` / `clang` | 109 | 77 | **29%** | strips source snippets, caret indicators, line numbers from gutter |
|
|
96
|
+
| `javac` | 79 | 66 | **16%** | strips source snippets, caret indicators; folds symbol/location into message |
|
|
97
|
+
|
|
98
|
+
### Linters and type checkers
|
|
78
99
|
|
|
79
100
|
Benchmark: 1 file, 1–2 violations. Reduction is a conservative lower bound — scales with file and error count since raw output repeats paths, source snippets, and annotations per violation.
|
|
80
101
|
|
|
81
|
-
|
|
|
102
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
82
103
|
|---|---|---|---|---|
|
|
83
|
-
| `
|
|
84
|
-
| `
|
|
85
|
-
| `
|
|
86
|
-
| `
|
|
87
|
-
| `
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
93
|
-
| `
|
|
94
|
-
| `
|
|
95
|
-
| `
|
|
96
|
-
| `
|
|
97
|
-
| `
|
|
98
|
-
| `
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
|
103
|
-
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `mypy-json` | 75 | 72 | **4%** | mypy text is already compact; notes folded into parent errors |
|
|
107
|
-
| `black-text` | 155 | 31 | **80%** | strips diff hunks, emoji, timestamps; lists files needing reformatting |
|
|
104
|
+
| `isort --check` | 143 | 29 | **80%** | strips diff hunks, absolute paths, timestamps; lists files with unsorted imports |
|
|
105
|
+
| `black --check` | 155 | 31 | **80%** | strips diff hunks, emoji, timestamps; lists files needing reformatting |
|
|
106
|
+
| `ruff check` | 107 | 52 | **51%** | source context + help text per error |
|
|
107
|
+
| `shellcheck` | 224 | 117 | **48%** | strips source snippets, carets, suggestions, wiki URLs |
|
|
108
|
+
| `npx htmlhint` | 174 | 92 | **47%** | strips ANSI codes, source evidence, rule descriptions, URLs |
|
|
109
|
+
| `vale` | 141 | 79 | **44%** | strips ANSI codes, Action/Span metadata, column-aligned formatting |
|
|
110
|
+
| `markdownlint` | 199 | 117 | **41%** | strips context quotes, URLs, fix info, error ranges |
|
|
111
|
+
| `pyright` | 100 | 59 | **41%** | strips version, timing, absolute paths; detail lines collapsed |
|
|
112
|
+
| `rubocop` | 149 | 90 | **40%** | strips source snippets, caret indicators, summary line |
|
|
113
|
+
| `tsc` | 107 | 72 | **33%** | vs `--pretty true` default; source snippets and underlines stripped |
|
|
114
|
+
| `stylelint` | 70 | 51 | **27%** | strips summary footer and fix hint |
|
|
115
|
+
| `pylint` | 141 | 120 | **15%** | strips header, score line, separator; scales with error count |
|
|
116
|
+
| `prettier --check` | 38 | 33 | **13%** | strips preamble, [warn] prefixes, footer hint; scales with file count |
|
|
117
|
+
| `hadolint` | 178 | 156 | **12%** | strips ANSI color codes and level labels; measured vs colored output |
|
|
118
|
+
| `eslint` | 64 | 59 | **8%** | already compact formatter |
|
|
119
|
+
| `mypy` | 75 | 72 | **4%** | mypy text is already compact; notes folded into parent errors |
|
|
120
|
+
|
|
121
|
+
### Security and audit
|
|
122
|
+
|
|
123
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
124
|
+
|---|---|---|---|---|
|
|
125
|
+
| `bandit` | 402 | 99 | **75%** | strips source snippets, CWE URLs, run metrics, confidence labels |
|
|
126
|
+
| `npm audit` | 158 | 50 | **68%** | strips advisory URLs, fix instructions, CVSS vectors; advisory titles joined per package |
|
|
108
127
|
|
|
109
128
|
### Pipeline tools
|
|
110
129
|
|
|
@@ -112,12 +131,12 @@ dbt output is the noisiest tool in this repo relative to useful signal. Every ru
|
|
|
112
131
|
|
|
113
132
|
The numbers below use 3–4 model toy examples; real projects run hundreds of models where the noise scales linearly and reduction compounds.
|
|
114
133
|
|
|
115
|
-
|
|
|
134
|
+
| Tool | Raw | Structured | Reduction | Notes |
|
|
116
135
|
|---|---|---|---|---|
|
|
117
|
-
| `dbt
|
|
118
|
-
| `dbt
|
|
119
|
-
| `dbt
|
|
120
|
-
| `dbt
|
|
136
|
+
| `dbt run` (success) | 428 | 20 | **95%** | version, adapter, concurrency, per-model start/finish — all noise on success |
|
|
137
|
+
| `dbt run` (failure) | 618 | 198 | **68%** | error messages, model paths, compiled code paths preserved |
|
|
138
|
+
| `dbt test` | 720 | 274 | **62%** | unit test diff tables preserved verbatim; preamble stripped |
|
|
139
|
+
| `dbt compile` | 775 | 683 | **12%** | compiled SQL is the signal and returned verbatim |
|
|
121
140
|
|
|
122
141
|
At 12 models, run failures hit 85% reduction. An 18-model DAG success: 1,645 → 20 tokens (99%).
|
|
123
142
|
|
|
@@ -131,33 +150,10 @@ Evaluated for structured parsing but raw output is already compact enough that a
|
|
|
131
150
|
| `flake8` | 75 | `file:line:col: CODE message` | no JSON without a plugin; text is already one line per violation |
|
|
132
151
|
| `yamllint` | 72 | `file:line:col level message (rule)` | filename printed once; one line per issue |
|
|
133
152
|
| `golangci-lint` | 59 | `file:line:col: message (linter)` | text output already minimal; JSON includes massive linter report |
|
|
134
|
-
| `go vet` | ~60 | `file:line:col: message` | same format as go build |
|
|
153
|
+
| `go vet` | ~60 | `file:line:col: message` | same format as `go build` |
|
|
135
154
|
| `vulture` | 58 | `file:line: message (confidence%)` | single line per finding |
|
|
136
155
|
| `pydocstyle` | 48 | `file:line context + CODE: message` | two lines per issue; structured format would repeat file paths |
|
|
137
156
|
|
|
138
|
-
## Built-in parsers
|
|
139
|
-
|
|
140
|
-
**Test runners:** `junit-xml` (pytest, Gradle, Maven, Jest, Go, .NET — anything that emits JUnit XML), `vitest-json`, `rspec-json`, `minitest-text`, `cargo-test`, `go-test-json`, `mocha-json`, `ava-text`, `unittest-text`, `node-test-text`
|
|
141
|
-
|
|
142
|
-
**Linters & type checkers:** `ruff-json`, `eslint-json`, `mypy-json`, `pyright-json`, `tsc-text`, `pylint-json`, `shellcheck-json`, `rubocop-json`, `swiftc-text`, `hadolint-json`, `stylelint-json`, `black-text`, `markdownlint-json`, `prettier-text`, `vale-json`, `tidy-text`, `jsonlint-text`, `isort-text`, `htmlhint-json`
|
|
143
|
-
|
|
144
|
-
**Build tools:** `cargo-build`, `javac-text`, `dotnet-build-text`, `clang-text`
|
|
145
|
-
|
|
146
|
-
**Security & audit:** `bandit-json`, `npm-audit-json`
|
|
147
|
-
|
|
148
|
-
**Pipeline tools:** `dbt-json` (run, test, compile)
|
|
149
|
-
|
|
150
|
-
Run `/sr-parsers` in a pi session to see all registered parsers with their match rules.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
## Installation
|
|
154
|
-
|
|
155
|
-
Install the skill and extension:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
pi install npm:@robhowley/pi-structured-return
|
|
159
|
-
```
|
|
160
|
-
|
|
161
157
|
## How it works
|
|
162
158
|
|
|
163
159
|
1. The agent runs commands through `structured_return` when it would reduce noise and token usage.
|
|
@@ -166,6 +162,8 @@ pi install npm:@robhowley/pi-structured-return
|
|
|
166
162
|
4. The agent receives the structured result in context — signal only, no noise.
|
|
167
163
|
5. The full log is always available on disk for both the agent and humans to inspect.
|
|
168
164
|
|
|
165
|
+
Run `/sr-parsers` in a pi session to see all registered parsers with their match rules.
|
|
166
|
+
|
|
169
167
|
## Extending with project-local parsers
|
|
170
168
|
|
|
171
169
|
Built-in parsers cover common tools. For everything else — internal CLIs, custom test runners, proprietary lint tools — add a `.pi/structured-return.json` to your project root.
|
|
@@ -245,8 +243,3 @@ Every parser returns the same shape. The model always knows where to look.
|
|
|
245
243
|
| `artifact` | `string?` | Path to the saved report file, if one was written |
|
|
246
244
|
| `logPath` | `string` | Path to full stdout+stderr log |
|
|
247
245
|
| `rawTail` | `string?` | Last 200 lines of log, included on fallback when no parser matched |
|
|
248
|
-
|
|
249
|
-
## Design
|
|
250
|
-
|
|
251
|
-
`structured_return` is a separate tool, not a wrapper around `bash`. Intercepting `bash` to silently rewrite commands would override a primitive the model and platform both rely on. Pi's philosophy is to extend rather than obfuscate: features are built on top of the platform, not hidden inside it. A dedicated tool honors that. It adds to the available surface, keeps `bash` honest, and leaves the choice explicit. The skill guides the model toward it; nothing is hijacked to get there.
|
|
252
|
-
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robhowley/pi-structured-return",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.6.1",
|
|
4
|
+
"description": "Turn noisy CLI output into compact structured results (fewer tokens), full logs preserved.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
"url": "https://github.com/robhowley/pi-structured-return/issues"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
|
-
"pi-package"
|
|
15
|
+
"pi-package",
|
|
16
|
+
"pi-coding-agent",
|
|
17
|
+
"pi",
|
|
18
|
+
"pi-extension",
|
|
19
|
+
"token-reduction",
|
|
20
|
+
"structured-output"
|
|
16
21
|
],
|
|
17
22
|
"files": [
|
|
18
23
|
"extensions",
|