@robhowley/pi-structured-return 1.8.0 → 1.10.0
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 +84 -73
- package/extensions/structured-return/config/project-config.ts +10 -0
- package/extensions/structured-return/config/registry.ts +306 -0
- package/extensions/structured-return/examples/.pi/machine-readable.json +18 -0
- package/extensions/structured-return/examples/.pi/parsers/foo-cli.ts +25 -0
- package/extensions/structured-return/{src/index.ts → index.ts} +94 -69
- package/extensions/structured-return/{src/parsers → parsers}/ava-text.ts +23 -15
- package/extensions/structured-return/{src/parsers → parsers}/bandit-json.ts +17 -15
- package/extensions/structured-return/{src/parsers → parsers}/black-text.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/cargo-build.ts +19 -14
- package/extensions/structured-return/{src/parsers → parsers}/cargo-test.ts +20 -19
- package/extensions/structured-return/parsers/checkstyle-xml.ts +183 -0
- package/extensions/structured-return/{src/parsers → parsers}/clang-text.ts +15 -13
- package/extensions/structured-return/{src/parsers → parsers}/dbt-json.ts +28 -23
- package/extensions/structured-return/{src/parsers → parsers}/dotnet-build-text.ts +10 -8
- package/extensions/structured-return/{src/parsers → parsers}/eslint-json.ts +15 -9
- package/extensions/structured-return/{src/parsers → parsers}/go-test-json.ts +23 -21
- package/extensions/structured-return/{src/parsers → parsers}/hadolint-json.ts +18 -12
- package/extensions/structured-return/{src/parsers → parsers}/htmlhint-json.ts +15 -13
- package/extensions/structured-return/{src/parsers → parsers}/isort-text.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/javac-text.ts +14 -12
- package/extensions/structured-return/{src/parsers → parsers}/jsonlint-text.ts +16 -14
- package/extensions/structured-return/{src/parsers → parsers}/junit-xml.ts +149 -50
- package/extensions/structured-return/{src/parsers → parsers}/markdownlint-json.ts +19 -17
- package/extensions/structured-return/{src/parsers → parsers}/minitest-text.ts +24 -15
- package/extensions/structured-return/{src/parsers → parsers}/mocha-json.ts +17 -10
- package/extensions/structured-return/{src/parsers → parsers}/mypy-json.ts +16 -16
- package/extensions/structured-return/{src/parsers → parsers}/node-test-text.ts +17 -14
- package/extensions/structured-return/{src/parsers → parsers}/npm-audit-json.ts +19 -16
- package/extensions/structured-return/{src/parsers → parsers}/prettier-text.ts +21 -17
- package/extensions/structured-return/{src/parsers → parsers}/pylint-json.ts +17 -17
- package/extensions/structured-return/{src/parsers → parsers}/pyright-json.ts +20 -18
- package/extensions/structured-return/{src/parsers → parsers}/rspec-json.ts +14 -14
- package/extensions/structured-return/{src/parsers → parsers}/rubocop-json.ts +22 -11
- package/extensions/structured-return/{src/parsers → parsers}/ruff-json.ts +7 -7
- package/extensions/structured-return/{src/parsers → parsers}/shellcheck-json.ts +14 -14
- package/extensions/structured-return/{src/parsers → parsers}/stylelint-json.ts +21 -13
- package/extensions/structured-return/{src/parsers → parsers}/swiftc-text.ts +16 -10
- package/extensions/structured-return/parsers/tail-fallback.ts +20 -0
- package/extensions/structured-return/{src/parsers → parsers}/tidy-text.ts +13 -13
- package/extensions/structured-return/{src/parsers → parsers}/tsc-text.ts +11 -11
- package/extensions/structured-return/{src/parsers → parsers}/unittest-text.ts +24 -14
- package/extensions/structured-return/{src/parsers → parsers}/utils.ts +9 -6
- package/extensions/structured-return/{src/parsers → parsers}/vale-json.ts +18 -18
- package/extensions/structured-return/{src/parsers → parsers}/vitest-json.ts +14 -14
- package/extensions/structured-return/{src/storage → storage}/log-store.ts +5 -5
- package/extensions/structured-return/{src/storage → storage}/session-stats.ts +11 -11
- package/extensions/structured-return/{src/types.ts → types.ts} +4 -2
- package/package.json +27 -43
- package/skills/structured-return/SKILL.md +62 -1
- package/LICENSE +0 -21
- package/extensions/structured-return/src/config/project-config.ts +0 -10
- package/extensions/structured-return/src/config/registry.test.ts +0 -171
- package/extensions/structured-return/src/config/registry.ts +0 -282
- package/extensions/structured-return/src/index.test.ts +0 -220
- package/extensions/structured-return/src/parsers/ava-text.test.ts +0 -116
- package/extensions/structured-return/src/parsers/bandit-json.test.ts +0 -90
- package/extensions/structured-return/src/parsers/black-text.test.ts +0 -67
- package/extensions/structured-return/src/parsers/cargo-build.test.ts +0 -170
- package/extensions/structured-return/src/parsers/cargo-test.test.ts +0 -191
- package/extensions/structured-return/src/parsers/clang-text.test.ts +0 -61
- package/extensions/structured-return/src/parsers/dbt-json.test.ts +0 -172
- package/extensions/structured-return/src/parsers/dotnet-build-text.test.ts +0 -85
- package/extensions/structured-return/src/parsers/eslint-json.test.ts +0 -60
- package/extensions/structured-return/src/parsers/go-test-json.test.ts +0 -119
- package/extensions/structured-return/src/parsers/hadolint-json.test.ts +0 -73
- package/extensions/structured-return/src/parsers/htmlhint-json.test.ts +0 -72
- package/extensions/structured-return/src/parsers/isort-text.test.ts +0 -58
- package/extensions/structured-return/src/parsers/javac-text.test.ts +0 -75
- package/extensions/structured-return/src/parsers/jsonlint-text.test.ts +0 -52
- package/extensions/structured-return/src/parsers/junit-xml.test.ts +0 -410
- package/extensions/structured-return/src/parsers/markdownlint-json.test.ts +0 -76
- package/extensions/structured-return/src/parsers/minitest-text.test.ts +0 -110
- package/extensions/structured-return/src/parsers/mocha-json.test.ts +0 -108
- package/extensions/structured-return/src/parsers/mypy-json.test.ts +0 -101
- package/extensions/structured-return/src/parsers/node-test-text.test.ts +0 -117
- package/extensions/structured-return/src/parsers/npm-audit-json.test.ts +0 -83
- package/extensions/structured-return/src/parsers/prettier-text.test.ts +0 -76
- package/extensions/structured-return/src/parsers/pylint-json.test.ts +0 -120
- package/extensions/structured-return/src/parsers/pyright-json.test.ts +0 -112
- package/extensions/structured-return/src/parsers/rspec-json.test.ts +0 -126
- package/extensions/structured-return/src/parsers/rubocop-json.test.ts +0 -118
- package/extensions/structured-return/src/parsers/ruff-json.test.ts +0 -57
- package/extensions/structured-return/src/parsers/shellcheck-json.test.ts +0 -110
- package/extensions/structured-return/src/parsers/stylelint-json.test.ts +0 -120
- package/extensions/structured-return/src/parsers/swiftc-text.test.ts +0 -73
- package/extensions/structured-return/src/parsers/tail-fallback.test.ts +0 -41
- package/extensions/structured-return/src/parsers/tail-fallback.ts +0 -20
- package/extensions/structured-return/src/parsers/tidy-text.test.ts +0 -74
- package/extensions/structured-return/src/parsers/tsc-text.test.ts +0 -81
- package/extensions/structured-return/src/parsers/unittest-text.test.ts +0 -126
- package/extensions/structured-return/src/parsers/vale-json.test.ts +0 -84
- package/extensions/structured-return/src/parsers/vitest-json.test.ts +0 -118
- package/extensions/structured-return/src/storage/session-stats.test.ts +0 -156
- package/extensions/structured-return/tsconfig.json +0 -11
- package/extensions/structured-return/vitest.config.ts +0 -9
- /package/extensions/structured-return/{src/ui → ui}/widget.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fs from
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Safely read a file, returning empty string if it doesn't exist.
|
|
@@ -6,9 +6,9 @@ import fs from "node:fs";
|
|
|
6
6
|
*/
|
|
7
7
|
export function safeReadFile(filePath: string): string {
|
|
8
8
|
try {
|
|
9
|
-
return fs.readFileSync(filePath,
|
|
9
|
+
return fs.readFileSync(filePath, 'utf8');
|
|
10
10
|
} catch (err: unknown) {
|
|
11
|
-
if (err instanceof Error &&
|
|
11
|
+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') return '';
|
|
12
12
|
throw err;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -21,9 +21,12 @@ export function safeReadFile(filePath: string): string {
|
|
|
21
21
|
* at functionName (file.ts:10:5)
|
|
22
22
|
* at file.ts:10:5
|
|
23
23
|
*/
|
|
24
|
-
export function extractJsStackLocation(stack: string | undefined): {
|
|
24
|
+
export function extractJsStackLocation(stack: string | undefined): {
|
|
25
|
+
file?: string;
|
|
26
|
+
line?: number;
|
|
27
|
+
} {
|
|
25
28
|
if (!stack) return {};
|
|
26
|
-
for (const line of stack.split(
|
|
29
|
+
for (const line of stack.split('\n')) {
|
|
27
30
|
// "at name (file:line:col)"
|
|
28
31
|
const withParens = line.match(/at\s+\S+\s+\(([^)]+\.(?:[jt]sx?|mjs|cjs)):(\d+):\d+\)/);
|
|
29
32
|
if (withParens && isUserFrame(withParens[1])) {
|
|
@@ -39,5 +42,5 @@ export function extractJsStackLocation(stack: string | undefined): { file?: stri
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
function isUserFrame(filePath: string): boolean {
|
|
42
|
-
return !filePath.includes(
|
|
45
|
+
return !filePath.includes('node_modules') && !filePath.includes('node:');
|
|
43
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule, ParsedFailure } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule, ParsedFailure } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface ValeAlert {
|
|
6
6
|
Line: number;
|
|
@@ -10,14 +10,14 @@ interface ValeAlert {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const parser: ParserModule = {
|
|
13
|
-
id:
|
|
13
|
+
id: 'vale-json',
|
|
14
14
|
async parse(ctx) {
|
|
15
15
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
16
16
|
if (!stdout) {
|
|
17
17
|
return {
|
|
18
|
-
tool:
|
|
19
|
-
status:
|
|
20
|
-
summary:
|
|
18
|
+
tool: 'vale',
|
|
19
|
+
status: 'pass',
|
|
20
|
+
summary: 'no prose issues',
|
|
21
21
|
failures: [],
|
|
22
22
|
logPath: ctx.logPath,
|
|
23
23
|
};
|
|
@@ -28,9 +28,9 @@ const parser: ParserModule = {
|
|
|
28
28
|
output = JSON.parse(stdout);
|
|
29
29
|
} catch {
|
|
30
30
|
return {
|
|
31
|
-
tool:
|
|
32
|
-
status:
|
|
33
|
-
summary:
|
|
31
|
+
tool: 'vale',
|
|
32
|
+
status: 'error',
|
|
33
|
+
summary: 'failed to parse vale JSON output',
|
|
34
34
|
logPath: ctx.logPath,
|
|
35
35
|
};
|
|
36
36
|
}
|
|
@@ -55,22 +55,22 @@ const parser: ParserModule = {
|
|
|
55
55
|
|
|
56
56
|
if (failures.length === 0) {
|
|
57
57
|
return {
|
|
58
|
-
tool:
|
|
59
|
-
status:
|
|
60
|
-
summary:
|
|
58
|
+
tool: 'vale',
|
|
59
|
+
status: 'pass',
|
|
60
|
+
summary: 'no prose issues',
|
|
61
61
|
failures: [],
|
|
62
62
|
logPath: ctx.logPath,
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
const parts = [
|
|
66
|
+
const parts = ['error', 'warning', 'suggestion']
|
|
67
67
|
.filter((s) => bySeverity[s])
|
|
68
|
-
.map((s) => `${bySeverity[s]} ${s}${bySeverity[s] !== 1 ?
|
|
68
|
+
.map((s) => `${bySeverity[s]} ${s}${bySeverity[s] !== 1 ? 's' : ''}`);
|
|
69
69
|
|
|
70
70
|
return {
|
|
71
|
-
tool:
|
|
72
|
-
status: bySeverity[
|
|
73
|
-
summary: parts.join(
|
|
71
|
+
tool: 'vale',
|
|
72
|
+
status: bySeverity['error'] ? 'fail' : 'pass',
|
|
73
|
+
summary: parts.join(', '),
|
|
74
74
|
failures,
|
|
75
75
|
logPath: ctx.logPath,
|
|
76
76
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import type { ParserModule } from
|
|
3
|
-
import { safeReadFile } from
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import type { ParserModule } from '../types';
|
|
3
|
+
import { safeReadFile } from './utils';
|
|
4
4
|
|
|
5
5
|
interface VitestAssertionResult {
|
|
6
6
|
fullName: string;
|
|
7
|
-
status:
|
|
7
|
+
status: 'passed' | 'failed';
|
|
8
8
|
failureMessages: string[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
interface VitestTestResult {
|
|
12
12
|
name: string;
|
|
13
|
-
status:
|
|
13
|
+
status: 'passed' | 'failed';
|
|
14
14
|
assertionResults: VitestAssertionResult[];
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -21,35 +21,35 @@ interface VitestReport {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const parser: ParserModule = {
|
|
24
|
-
id:
|
|
24
|
+
id: 'vitest-json',
|
|
25
25
|
async parse(ctx) {
|
|
26
26
|
const stdout = safeReadFile(ctx.stdoutPath).trim();
|
|
27
27
|
const report = stdout ? (JSON.parse(stdout) as VitestReport) : null;
|
|
28
28
|
if (!report) {
|
|
29
29
|
return {
|
|
30
|
-
tool:
|
|
31
|
-
status:
|
|
32
|
-
summary:
|
|
30
|
+
tool: 'vitest',
|
|
31
|
+
status: 'error',
|
|
32
|
+
summary: 'no output',
|
|
33
33
|
logPath: ctx.logPath,
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const failures = report.testResults.flatMap((suite) =>
|
|
38
38
|
suite.assertionResults
|
|
39
|
-
.filter((t) => t.status ===
|
|
39
|
+
.filter((t) => t.status === 'failed')
|
|
40
40
|
.map((t) => ({
|
|
41
41
|
id: t.fullName,
|
|
42
42
|
file: path.relative(ctx.cwd, suite.name),
|
|
43
|
-
message: t.failureMessages[0]?.split(
|
|
44
|
-
}))
|
|
43
|
+
message: t.failureMessages[0]?.split('\n')[0] ?? 'test failed',
|
|
44
|
+
})),
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
const failed = report.numFailedTests;
|
|
48
48
|
const passed = report.numPassedTests;
|
|
49
49
|
|
|
50
50
|
return {
|
|
51
|
-
tool:
|
|
52
|
-
status: failed > 0 ?
|
|
51
|
+
tool: 'vitest',
|
|
52
|
+
status: failed > 0 ? 'fail' : 'pass',
|
|
53
53
|
summary: failed > 0 ? `${failed} failed, ${passed} passed` : `${passed} passed`,
|
|
54
54
|
failures,
|
|
55
55
|
logPath: ctx.logPath,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
export function ensureRunDir(cwd: string): string {
|
|
5
|
-
const dir = path.join(cwd,
|
|
5
|
+
const dir = path.join(cwd, '.pi', 'structured-returns');
|
|
6
6
|
fs.mkdirSync(dir, { recursive: true });
|
|
7
7
|
return dir;
|
|
8
8
|
}
|
|
@@ -11,13 +11,13 @@ export function writeRunArtifacts(
|
|
|
11
11
|
dir: string,
|
|
12
12
|
runId: string,
|
|
13
13
|
stdout: string,
|
|
14
|
-
stderr: string
|
|
14
|
+
stderr: string,
|
|
15
15
|
): { stdoutPath: string; stderrPath: string; logPath: string } {
|
|
16
16
|
const stdoutPath = path.join(dir, `${runId}.stdout.log`);
|
|
17
17
|
const stderrPath = path.join(dir, `${runId}.stderr.log`);
|
|
18
18
|
const logPath = path.join(dir, `${runId}.combined.log`);
|
|
19
19
|
fs.writeFileSync(stdoutPath, stdout);
|
|
20
20
|
fs.writeFileSync(stderrPath, stderr);
|
|
21
|
-
fs.writeFileSync(logPath, [stdout, stderr].filter(Boolean).join(
|
|
21
|
+
fs.writeFileSync(logPath, [stdout, stderr].filter(Boolean).join('\n'));
|
|
22
22
|
return { stdoutPath, stderrPath, logPath };
|
|
23
23
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import os from
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import os from 'node:os';
|
|
4
4
|
|
|
5
|
-
const FILE_PREFIX =
|
|
6
|
-
const FILE_SUFFIX =
|
|
5
|
+
const FILE_PREFIX = 'structured-return-stats.';
|
|
6
|
+
const FILE_SUFFIX = '.jsonl';
|
|
7
7
|
const MAX_FILE_BYTES = 3 * 1024 * 1024; // 3MB
|
|
8
8
|
|
|
9
9
|
function statsDir(): string {
|
|
10
|
-
return path.join(os.homedir(),
|
|
10
|
+
return path.join(os.homedir(), '.pi');
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export type StatsEntry = {
|
|
@@ -27,7 +27,7 @@ export type AggregatedStats = {
|
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
function statsFileName(index: number): string {
|
|
30
|
-
return `${FILE_PREFIX}${String(index).padStart(3,
|
|
30
|
+
return `${FILE_PREFIX}${String(index).padStart(3, '0')}${FILE_SUFFIX}`;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function statsFilePath(index: number): string {
|
|
@@ -69,7 +69,7 @@ export function appendRun(entry: StatsEntry): void {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
const line = JSON.stringify(entry) +
|
|
72
|
+
const line = JSON.stringify(entry) + '\n';
|
|
73
73
|
fs.appendFileSync(filePath, line);
|
|
74
74
|
}
|
|
75
75
|
|
|
@@ -79,8 +79,8 @@ export function readLifetimeStats(opts: { cwd?: string } = {}): AggregatedStats
|
|
|
79
79
|
const totals: AggregatedStats = { runs: 0, rawBytes: 0, parsedBytes: 0 };
|
|
80
80
|
|
|
81
81
|
for (const file of files) {
|
|
82
|
-
const content = fs.readFileSync(file,
|
|
83
|
-
for (const line of content.split(
|
|
82
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
83
|
+
for (const line of content.split('\n')) {
|
|
84
84
|
if (!line.trim()) continue;
|
|
85
85
|
try {
|
|
86
86
|
const entry: StatsEntry = JSON.parse(line);
|
|
@@ -113,7 +113,7 @@ export function estimateTokens(bytes: number): string {
|
|
|
113
113
|
|
|
114
114
|
export function formatStatsBlock(label: string, stats: AggregatedStats): string[] {
|
|
115
115
|
const saved = stats.rawBytes - stats.parsedBytes;
|
|
116
|
-
const pct = stats.rawBytes > 0 ? ((saved / stats.rawBytes) * 100).toFixed(1) :
|
|
116
|
+
const pct = stats.rawBytes > 0 ? ((saved / stats.rawBytes) * 100).toFixed(1) : '0.0';
|
|
117
117
|
return [
|
|
118
118
|
`${label}:`,
|
|
119
119
|
` runs: ${stats.runs}`,
|
|
@@ -2,14 +2,16 @@ export type ParsedFailure = {
|
|
|
2
2
|
id: string;
|
|
3
3
|
file?: string;
|
|
4
4
|
line?: number;
|
|
5
|
+
column?: number;
|
|
5
6
|
message?: string;
|
|
6
7
|
rule?: string;
|
|
8
|
+
severity?: 'error' | 'warning' | 'info';
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export type ParsedResult = {
|
|
10
12
|
tool: string;
|
|
11
13
|
exitCode: number;
|
|
12
|
-
status:
|
|
14
|
+
status: 'pass' | 'fail' | 'error';
|
|
13
15
|
summary: string;
|
|
14
16
|
cwd?: string;
|
|
15
17
|
failures?: ParsedFailure[];
|
|
@@ -36,7 +38,7 @@ export type RunContext = {
|
|
|
36
38
|
|
|
37
39
|
export type ParserModule = {
|
|
38
40
|
id: string;
|
|
39
|
-
parse: (ctx: RunContext) => Promise<Omit<ParsedResult,
|
|
41
|
+
parse: (ctx: RunContext) => Promise<Omit<ParsedResult, 'exitCode'>>;
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
export type ParserRegistration = {
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robhowley/pi-structured-return",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Turn noisy CLI output into compact structured results (fewer tokens), full logs preserved.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"extensions",
|
|
8
|
+
"skills",
|
|
9
|
+
"README.md",
|
|
10
|
+
"../LICENSE"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|
|
15
16
|
"pi-package",
|
|
@@ -19,50 +20,33 @@
|
|
|
19
20
|
"token-reduction",
|
|
20
21
|
"structured-output"
|
|
21
22
|
],
|
|
22
|
-
"files": [
|
|
23
|
-
"extensions",
|
|
24
|
-
"skills",
|
|
25
|
-
"LICENSE",
|
|
26
|
-
"README.md"
|
|
27
|
-
],
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
30
|
-
},
|
|
31
|
-
"lint-staged": {
|
|
32
|
-
"extensions/structured-return/src/**/*.ts": [
|
|
33
|
-
"eslint --fix",
|
|
34
|
-
"prettier --write"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
23
|
"pi": {
|
|
38
24
|
"extensions": [
|
|
39
|
-
"./extensions/structured-return
|
|
40
|
-
],
|
|
41
|
-
"skills": [
|
|
42
|
-
"./skills/structured-return"
|
|
25
|
+
"./extensions/structured-return"
|
|
43
26
|
]
|
|
44
27
|
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/robhowley/pi-userland.git",
|
|
31
|
+
"directory": "packages/pi-structured-return"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/robhowley/pi-userland/tree/main/packages/pi-structured-return",
|
|
45
34
|
"scripts": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"prepare": "node -e \"if (process.env.CI || process.env.GITHUB_ACTIONS) process.exit(0)\" || husky"
|
|
35
|
+
"lint": "eslint extensions/",
|
|
36
|
+
"format:check": "prettier --check extensions/",
|
|
37
|
+
"format:write": "prettier --write extensions/",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"test": "vitest run __tests__"
|
|
52
40
|
},
|
|
53
41
|
"dependencies": {
|
|
54
42
|
"fast-xml-parser": "^5.4.1",
|
|
55
43
|
"glob": "^11.0.0"
|
|
56
44
|
},
|
|
57
|
-
"
|
|
45
|
+
"peerDependencies": {
|
|
58
46
|
"@mariozechner/pi-coding-agent": "*",
|
|
59
|
-
"@
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"prettier": "^3.4.0",
|
|
64
|
-
"typescript": "^5.7.0",
|
|
65
|
-
"typescript-eslint": "^8.0.0",
|
|
66
|
-
"vitest": "^4.1.0"
|
|
47
|
+
"@mariozechner/pi-tui": "*"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^22.15.17"
|
|
67
51
|
}
|
|
68
52
|
}
|
|
@@ -25,119 +25,155 @@ Prefer better output at the source.
|
|
|
25
25
|
## Examples
|
|
26
26
|
|
|
27
27
|
### pytest
|
|
28
|
+
|
|
28
29
|
- `structured_return({ command: "pytest [any pytest args] --junitxml=.tmp/report.xml", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — `--junitxml` is built into pytest, no extra dependencies needed; scope, filters, markers, etc. go in `[any pytest args]`
|
|
29
30
|
|
|
30
31
|
### ruff check
|
|
32
|
+
|
|
31
33
|
- `structured_return({ command: "ruff check [any ruff args] --output-format=json", parseAs: "ruff-json" })` — scope, selects, ignores, etc. go in `[any ruff args]`
|
|
32
34
|
|
|
33
35
|
### mypy
|
|
36
|
+
|
|
34
37
|
- `structured_return({ command: "mypy [any mypy args] --output json", parseAs: "mypy-json" })` — `--output json` is built into mypy (1.0+); outputs NDJSON to stderr with file, line, column, message, error code, and severity; notes are folded into their parent error's message
|
|
35
38
|
|
|
36
39
|
### htmlhint
|
|
40
|
+
|
|
37
41
|
- `structured_return({ command: "npx htmlhint --format json [any htmlhint args]", parseAs: "htmlhint-json" })` — `--format json` outputs structured array; strips ANSI codes, source evidence, rule descriptions, and URLs
|
|
38
42
|
|
|
39
43
|
### isort
|
|
44
|
+
|
|
40
45
|
- `structured_return({ command: "isort --check --diff [any isort args]", parseAs: "isort-text" })` — parses `--check` output; strips diff hunks, absolute paths, timestamps; lists files with unsorted imports
|
|
41
46
|
|
|
42
47
|
### npm audit
|
|
48
|
+
|
|
43
49
|
- `structured_return({ command: "npm audit --json", parseAs: "npm-audit-json" })` — `--json` is built into npm; strips advisory URLs, CVSS vectors, fix instructions; advisory titles joined per package; severity breakdown in summary
|
|
44
50
|
|
|
45
51
|
### jsonlint
|
|
52
|
+
|
|
46
53
|
- `structured_return({ command: "npx jsonlint [file]", parseAs: "jsonlint-text" })` — strips stack trace and source pointer; extracts line number and "Expecting X, got Y" message
|
|
47
54
|
|
|
48
55
|
### tidy (HTML Tidy)
|
|
56
|
+
|
|
49
57
|
- `structured_return({ command: "tidy -errors [any tidy args]", parseAs: "tidy-text" })` — parses `line N column N - Warning/Error: message` from stderr; strips remediation advice, accessibility tips, reformatted HTML output, and Info lines
|
|
50
58
|
|
|
51
59
|
### vale
|
|
60
|
+
|
|
52
61
|
- `structured_return({ command: "vale --output JSON [any vale args]", parseAs: "vale-json" })` — `--output JSON` is built into vale; strips ANSI codes, Action/Span metadata, column-aligned formatting; severity breakdown in summary
|
|
53
62
|
|
|
54
63
|
### prettier
|
|
64
|
+
|
|
55
65
|
- `structured_return({ command: "prettier --check [any prettier args]", parseAs: "prettier-text" })` — parses `--check` output; strips "Checking formatting..." preamble, [warn] prefixes, and "Run Prettier with --write to fix" footer
|
|
56
66
|
|
|
57
67
|
### markdownlint
|
|
68
|
+
|
|
58
69
|
- `structured_return({ command: "markdownlint --json [any markdownlint args]", parseAs: "markdownlint-json" })` — `--json` outputs structured array; strips context quotes, rule info URLs, fix info, and error ranges; error details folded into description
|
|
59
70
|
|
|
60
71
|
### black
|
|
72
|
+
|
|
61
73
|
- `structured_return({ command: "black --check [any black args]", parseAs: "black-text" })` — parses `--check` output; strips diff hunks, emoji banners, timestamps; lists files needing reformatting; also handles `--check --diff` mode
|
|
62
74
|
|
|
63
75
|
### bandit
|
|
76
|
+
|
|
64
77
|
- `structured_return({ command: "bandit -f json [any bandit args]", parseAs: "bandit-json" })` — `-f json` is built into bandit; strips source snippets, CWE URLs, run metrics, and confidence labels; severity breakdown in summary
|
|
65
78
|
|
|
66
79
|
### gcc / clang
|
|
80
|
+
|
|
67
81
|
- `structured_return({ command: "gcc -c [any gcc args]", parseAs: "clang-text" })` — works with gcc, g++, clang, clang++; parses `file:line:col: error: message` from stderr; source snippets and caret indicators stripped; warning flags preserved as rule
|
|
68
82
|
|
|
69
83
|
### dotnet build
|
|
84
|
+
|
|
70
85
|
- `structured_return({ command: "dotnet build [any dotnet args]", parseAs: "dotnet-build-text" })` — parses MSBuild `file(line,col): error CODE: message` format; strips restore/timing noise; deduplicates the inline+summary error repetition; absolute paths relativized
|
|
71
86
|
|
|
72
87
|
### javac
|
|
88
|
+
|
|
73
89
|
- `structured_return({ command: "javac [any javac args]", parseAs: "javac-text" })` — parses `file:line: error: message` from stderr; source snippets and caret indicators stripped; `cannot find symbol` errors fold the symbol continuation line into the message
|
|
74
90
|
|
|
75
91
|
### pyright
|
|
92
|
+
|
|
76
93
|
- `structured_return({ command: "pyright --outputjson [any pyright args]", parseAs: "pyright-json" })` — `--outputjson` is built into pyright; JSON output includes file, line, message, and rule code; multi-line detail messages collapsed; warnings excluded from failures
|
|
77
94
|
|
|
78
95
|
### tsc
|
|
96
|
+
|
|
79
97
|
- `structured_return({ command: "tsc --noEmit --pretty false [any tsc args]", parseAs: "tsc-text" })` — `--pretty false` suppresses source snippets and ANSI codes; parser extracts file, line, TS error code, and message from the compact `file(line,col): error TSXXXX: message` format
|
|
80
98
|
|
|
81
99
|
### pylint
|
|
100
|
+
|
|
82
101
|
- `structured_return({ command: "pylint [any pylint args] --output-format=json", parseAs: "pylint-json" })` — `--output-format=json` is built into pylint; rule includes both message-id and symbol name (e.g. `W0612(unused-variable)`)
|
|
83
102
|
|
|
84
103
|
### shellcheck
|
|
104
|
+
|
|
85
105
|
- `structured_return({ command: "shellcheck [any shellcheck args] --format=json", parseAs: "shellcheck-json" })` — `--format=json` is built into shellcheck; strips source snippets, caret indicators, "Did you mean" suggestions, and wiki URLs
|
|
86
106
|
|
|
87
107
|
### rubocop
|
|
108
|
+
|
|
88
109
|
- `structured_return({ command: "rubocop [any rubocop args] --format json", parseAs: "rubocop-json" })` — `--format json` is built into rubocop; cop name prefix stripped from messages; source snippets and caret indicators removed
|
|
89
110
|
|
|
90
111
|
### swiftc
|
|
112
|
+
|
|
91
113
|
- `structured_return({ command: "swiftc -typecheck [any swiftc args]", parseAs: "swiftc-text" })` — parses `file:line:col: error: message` from stderr; source annotations and duplicate error lines deduplicated; warnings filtered out
|
|
92
114
|
|
|
93
115
|
### hadolint
|
|
116
|
+
|
|
94
117
|
- `structured_return({ command: "hadolint [any hadolint args] --format json", parseAs: "hadolint-json" })` — `--format json` is built into hadolint; strips ANSI color codes and level labels from text output
|
|
95
118
|
|
|
96
119
|
### stylelint
|
|
120
|
+
|
|
97
121
|
- `structured_return({ command: "stylelint [any stylelint args] --formatter json", parseAs: "stylelint-json" })` — `--formatter json` is built into stylelint; rule name suffix stripped from message text; requires a `.stylelintrc` config
|
|
98
122
|
|
|
99
123
|
### node --test
|
|
124
|
+
|
|
100
125
|
- `structured_return({ command: "node --test [any node test args]", parseAs: "node-test-text" })` — parses the default spec reporter output; strips full stack traces, assertion error internals, timing data; preserves expected/actual values from assertion failures
|
|
101
126
|
|
|
102
127
|
### ava
|
|
128
|
+
|
|
103
129
|
- `structured_return({ command: "npx ava [any ava args] --no-color", parseAs: "ava-text" })` — parses default text output from stderr; assertion failures extract expected/actual from diff lines and file:line; runtime errors extract message and file:line from stack trace
|
|
104
130
|
|
|
105
131
|
### mocha
|
|
132
|
+
|
|
106
133
|
- `structured_return({ command: "mocha [any mocha args] --reporter json", parseAs: "mocha-json" })` — `--reporter json` is built into mocha; assertion failures surface explicit expected/actual values; runtime errors surface message and file:line from stack trace
|
|
107
134
|
|
|
108
135
|
### Python unittest
|
|
136
|
+
|
|
109
137
|
- `structured_return({ command: "python3 -m unittest [any unittest args]", parseAs: "unittest-text" })` — no special flags needed; parses the default verbose traceback output from stderr; assertion messages extracted from `AssertionError` lines; file:line from traceback frames
|
|
110
138
|
|
|
111
139
|
### go test
|
|
140
|
+
|
|
112
141
|
- `structured_return({ command: "go test -json [any go test args]", parseAs: "go-test-json" })` — `-json` is built into `go test`; NDJSON output; assertion failures extract file:line and message from `t.Error`/`t.Errorf` output; panics extract message and user-code file:line from stack trace; 97% reduction vs raw NDJSON
|
|
113
142
|
|
|
114
143
|
### vitest
|
|
144
|
+
|
|
115
145
|
- `structured_return({ command: "vitest run [any vitest args] --reporter=json", parseAs: "vitest-json" })` — file paths, filters, etc. go in `[any vitest args]`
|
|
116
146
|
|
|
117
147
|
### eslint
|
|
148
|
+
|
|
118
149
|
- `structured_return({ command: "eslint [any eslint args] -f json", parseAs: "eslint-json" })` — paths, configs, rules, etc. go in `[any eslint args]`
|
|
119
150
|
|
|
120
151
|
### rspec
|
|
152
|
+
|
|
121
153
|
- `structured_return({ command: "bundle exec rspec [any rspec args] --format json", parseAs: "rspec-json" })` — `--format json` is required; without it output is not parseable
|
|
122
154
|
|
|
123
155
|
### minitest
|
|
156
|
+
|
|
124
157
|
- `structured_return({ command: "ruby [any minitest args]", parseAs: "minitest-text" })` — no format flags needed; works with plain ruby invocation
|
|
125
158
|
|
|
126
159
|
### dbt (run, test, compile)
|
|
160
|
+
|
|
127
161
|
- `structured_return({ command: "dbt run [any dbt args] --log-format json", parseAs: "dbt-json" })` — `--log-format json` required; model selectors, flags, etc. go in `[any dbt args]`
|
|
128
162
|
- `structured_return({ command: "dbt test [any dbt args] --log-format json", parseAs: "dbt-json" })` — same parser handles run and test; unit test diffs preserved verbatim
|
|
129
163
|
- `structured_return({ command: "dbt compile [any dbt args] --log-format json", parseAs: "dbt-json" })` — returns compiled SQL; preamble stripped
|
|
130
164
|
|
|
131
165
|
### cargo build
|
|
166
|
+
|
|
132
167
|
- `structured_return({ command: "cargo build --message-format=json", parseAs: "cargo-build" })` — `--message-format=json` is built into cargo; errors include file, line, error code (E0308 etc.), and primary span label (expected X, found Y); warnings are filtered out
|
|
133
168
|
|
|
134
169
|
### cargo test
|
|
170
|
+
|
|
135
171
|
- `structured_return({ command: "cargo test", parseAs: "cargo-test" })` — no extra flags needed; assertion failures surface left/right values and file:line; panics surface the message and file:line; if compilation fails, the summary says so and tells the model to run `cargo build --message-format=json` for structured errors
|
|
136
172
|
- `structured_return({ command: "cargo test [filter]", parseAs: "cargo-test" })` — filter by test name substring, module path, or `--test integration_test_name`
|
|
137
173
|
|
|
138
174
|
### junit-xml
|
|
139
175
|
|
|
140
|
-
JUnit XML is the de facto standard output format across the JVM ecosystem and many others — Maven, Gradle, pytest (`--junitxml`), Go (`go-junit-report`), .NET (`--logger trx` with conversion), Jest (`jest-junit`), and more. If a tool can emit JUnit XML, `junit-xml` covers it without a custom parser.
|
|
176
|
+
JUnit XML is the de facto standard output format across the JVM ecosystem and many others — Maven, Gradle, pytest (`--junitxml`), Playwright (`--reporter=junit`), PHPUnit/Pest (`--log-junit`), Go (`go-junit-report`), .NET (`--logger trx` with conversion), Jest (`jest-junit`), and more. If a tool can emit JUnit XML, `junit-xml` covers it without a custom parser.
|
|
141
177
|
|
|
142
178
|
`artifactPaths` supports glob patterns — the parser aggregates results across all matching files. Use globs for tools that write one XML per test class (Gradle, Maven/Surefire). Use a single path for tools that write one consolidated file (pytest, Jest, etc.).
|
|
143
179
|
|
|
@@ -171,6 +207,24 @@ Jest requires the `jest-junit` reporter (`npm install --save-dev jest-junit`). P
|
|
|
171
207
|
|
|
172
208
|
- `structured_return({ command: "jest [any jest args] --reporters=jest-junit", parseAs: "junit-xml", artifactPaths: [".tmp/junit.xml"] })` — set `JEST_JUNIT_OUTPUT_FILE=.tmp/junit.xml` or configure `outputFile` in `jest-junit` config; file paths, `--testPathPattern`, etc. go in `[any jest args]`
|
|
173
209
|
|
|
210
|
+
#### Playwright
|
|
211
|
+
|
|
212
|
+
Playwright has a built-in JUnit reporter. Set the output file inline so `junit-xml` has a concrete artifact to parse.
|
|
213
|
+
|
|
214
|
+
- `structured_return({ command: "PLAYWRIGHT_JUNIT_OUTPUT_FILE=.tmp/report.xml playwright test [any playwright args] --reporter=junit", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — built-in JUnit reporter; file paths, `--grep`, project names, and shard flags go in `[any playwright args]`
|
|
215
|
+
|
|
216
|
+
#### PHPUnit
|
|
217
|
+
|
|
218
|
+
PHPUnit writes JUnit XML directly via `--log-junit`.
|
|
219
|
+
|
|
220
|
+
- `structured_return({ command: "vendor/bin/phpunit [any phpunit args] --log-junit .tmp/report.xml", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — built-in JUnit logging; test paths, `--filter`, and suite selection flags go in `[any phpunit args]`
|
|
221
|
+
|
|
222
|
+
#### Pest
|
|
223
|
+
|
|
224
|
+
Pest supports the same JUnit XML logging flag as PHPUnit.
|
|
225
|
+
|
|
226
|
+
- `structured_return({ command: "vendor/bin/pest [any pest args] --log-junit .tmp/report.xml", parseAs: "junit-xml", artifactPaths: [".tmp/report.xml"] })` — built-in JUnit logging; file paths, `--filter`, and parallelization flags go in `[any pest args]`
|
|
227
|
+
|
|
174
228
|
#### Swift / XCTest (Swift Package Manager)
|
|
175
229
|
|
|
176
230
|
`swift test` has native JUnit XML output via `--xunit-output` (Swift 5.7+). Use this for all SPM projects — no third-party reporter needed.
|
|
@@ -184,6 +238,13 @@ Jest requires the `jest-junit` reporter (`npm install --save-dev jest-junit`). P
|
|
|
184
238
|
|
|
185
239
|
- `structured_return({ command: "xcodebuild test -scheme [scheme] -destination '[destination]' 2>&1 | xcbeautify --report junit --output .tmp", parseAs: "junit-xml", artifactPaths: [".tmp/report.junit.xml"] })` — xcbeautify writes `report.junit.xml` into the `--output` directory; run `xcodebuild -showdestinations -scheme [scheme]` first to find the correct `[destination]` string for the project
|
|
186
240
|
|
|
241
|
+
### checkstyle
|
|
242
|
+
|
|
243
|
+
Checkstyle is the standard Java linter — `checkstyle-xml` parses its XML output. Supports both Checkstyle and ktlint (which emits compatible XML).
|
|
244
|
+
|
|
245
|
+
- `structured_return({ command: "checkstyle -c [config.xml] -f xml [files]", parseAs: "checkstyle-xml" })` — Checkstyle native; scope goes in `[files]`
|
|
246
|
+
- `structured_return({ command: "ktlint [files] --reporter=checkstyle", parseAs: "checkstyle-xml" })` — ktlint with built-in checkstyle reporter
|
|
247
|
+
|
|
187
248
|
## Already compact — use `bash` directly
|
|
188
249
|
|
|
189
250
|
These tools were evaluated for structured parsing but their output is already compact enough that a parser adds no token reduction. Use `bash` instead of `structured_return`.
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Rob Howley
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import type { ParserConfigFile, ParserRegistration } from "../types";
|
|
4
|
-
|
|
5
|
-
export function loadProjectConfig(cwd: string): ParserRegistration[] {
|
|
6
|
-
const configPath = path.join(cwd, ".pi", "structured-return.json");
|
|
7
|
-
if (!fs.existsSync(configPath)) return [];
|
|
8
|
-
const data = JSON.parse(fs.readFileSync(configPath, "utf8")) as ParserConfigFile;
|
|
9
|
-
return Array.isArray(data.parsers) ? data.parsers : [];
|
|
10
|
-
}
|