@robhowley/pi-structured-return 1.9.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 +2 -1
- 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 +61 -43
- 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 +7 -0
- 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 -627
- 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,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
|
}
|
|
@@ -238,6 +238,13 @@ Pest supports the same JUnit XML logging flag as PHPUnit.
|
|
|
238
238
|
|
|
239
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
|
|
240
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
|
+
|
|
241
248
|
## Already compact — use `bash` directly
|
|
242
249
|
|
|
243
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
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { resolveParser } from "./registry";
|
|
3
|
-
|
|
4
|
-
/** Resolve a parser from argv with no explicit parseAs or project registrations. */
|
|
5
|
-
async function detect(argv: string[]) {
|
|
6
|
-
const parser = await resolveParser({ cwd: "/project", argv, registrations: [] });
|
|
7
|
-
return parser.id;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
describe("resolveParser priority", () => {
|
|
11
|
-
it("explicit parseAs wins over auto-detect", async () => {
|
|
12
|
-
// argv would auto-detect as ruff-json, but parseAs overrides
|
|
13
|
-
const parser = await resolveParser({
|
|
14
|
-
cwd: "/project",
|
|
15
|
-
parseAs: "eslint-json",
|
|
16
|
-
argv: ["ruff", "check", "--output-format=json"],
|
|
17
|
-
registrations: [],
|
|
18
|
-
});
|
|
19
|
-
expect(parser.id).toBe("eslint-json");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("project registration wins over auto-detect", async () => {
|
|
23
|
-
const parser = await resolveParser({
|
|
24
|
-
cwd: "/project",
|
|
25
|
-
argv: ["ruff", "check", "--output-format=json"],
|
|
26
|
-
registrations: [{ id: "custom", match: { argvIncludes: ["ruff"] }, parseAs: "eslint-json" }],
|
|
27
|
-
});
|
|
28
|
-
expect(parser.id).toBe("eslint-json");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("falls back to tail-fallback when nothing matches", async () => {
|
|
32
|
-
const parser = await resolveParser({ cwd: "/project", argv: ["unknown-tool"], registrations: [] });
|
|
33
|
-
expect(parser.id).toBe("tail-fallback");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe("AUTO_DETECT", () => {
|
|
38
|
-
describe("hasFlag correctness — no false positives from bare value tokens", () => {
|
|
39
|
-
it("eslint -f json matches", async () => {
|
|
40
|
-
expect(await detect(["eslint", "src/", "-f", "json"])).toBe("eslint-json");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("eslint without -f json does not match", async () => {
|
|
44
|
-
expect(await detect(["eslint", "src/"])).toBe("tail-fallback");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("ruff --output-format=json (joined) matches", async () => {
|
|
48
|
-
expect(await detect(["ruff", "check", "--output-format=json"])).toBe("ruff-json");
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("ruff --output-format json (split) matches", async () => {
|
|
52
|
-
expect(await detect(["ruff", "check", "--output-format", "json"])).toBe("ruff-json");
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("ruff without --output-format does not match", async () => {
|
|
56
|
-
expect(await detect(["ruff", "check"])).toBe("tail-fallback");
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("mocha --reporter=json matches", async () => {
|
|
60
|
-
expect(await detect(["mocha", "--reporter=json"])).toBe("mocha-json");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("mocha --reporter json (split) matches", async () => {
|
|
64
|
-
expect(await detect(["mocha", "--reporter", "json"])).toBe("mocha-json");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("mocha with json in path does NOT false-positive", async () => {
|
|
68
|
-
expect(await detect(["mocha", "test/json/"])).toBe("tail-fallback");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("rubocop --format=json matches", async () => {
|
|
72
|
-
expect(await detect(["rubocop", "--format=json"])).toBe("rubocop-json");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("rubocop --format progress does NOT false-positive", async () => {
|
|
76
|
-
expect(await detect(["rubocop", "--format", "progress"])).toBe("tail-fallback");
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("hadolint --format json (split) matches", async () => {
|
|
80
|
-
expect(await detect(["hadolint", "--format", "json", "Dockerfile"])).toBe("hadolint-json");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("hadolint without --format does NOT match", async () => {
|
|
84
|
-
expect(await detect(["hadolint", "Dockerfile"])).toBe("tail-fallback");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("tsc --pretty false (split) matches", async () => {
|
|
88
|
-
expect(await detect(["tsc", "--pretty", "false"])).toBe("tsc-text");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("tsc --pretty=false (joined) matches", async () => {
|
|
92
|
-
expect(await detect(["tsc", "--pretty=false"])).toBe("tsc-text");
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it("tsc without --pretty does NOT match", async () => {
|
|
96
|
-
expect(await detect(["tsc"])).toBe("tail-fallback");
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("mypy --output=json matches", async () => {
|
|
100
|
-
expect(await detect(["mypy", "--output=json", "src/"])).toBe("mypy-json");
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("mypy --output html does NOT false-positive", async () => {
|
|
104
|
-
expect(await detect(["mypy", "--output", "html", "src/"])).toBe("tail-fallback");
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("pylint --output-format=json matches", async () => {
|
|
108
|
-
expect(await detect(["pylint", "--output-format=json", "src/"])).toBe("pylint-json");
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it("shellcheck --format=json matches", async () => {
|
|
112
|
-
expect(await detect(["shellcheck", "--format=json", "script.sh"])).toBe("shellcheck-json");
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("stylelint --formatter=json matches", async () => {
|
|
116
|
-
expect(await detect(["stylelint", "--formatter=json", "src/"])).toBe("stylelint-json");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("dbt run --log-format=json matches", async () => {
|
|
120
|
-
expect(await detect(["dbt", "run", "--log-format=json"])).toBe("dbt-json");
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it("dbt run --log-format json (split) matches", async () => {
|
|
124
|
-
expect(await detect(["dbt", "run", "--log-format", "json"])).toBe("dbt-json");
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("dbt run without --log-format does NOT match", async () => {
|
|
128
|
-
expect(await detect(["dbt", "run"])).toBe("tail-fallback");
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe("remaining flag-based detectors", () => {
|
|
133
|
-
it("rspec --format=json matches", async () => {
|
|
134
|
-
expect(await detect(["rspec", "--format=json"])).toBe("rspec-json");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("cargo build --message-format=json matches", async () => {
|
|
138
|
-
expect(await detect(["cargo", "build", "--message-format=json"])).toBe("cargo-build");
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it("pytest --junitxml matches junit-xml", async () => {
|
|
142
|
-
expect(await detect(["pytest", "--junitxml=report.xml"])).toBe("junit-xml");
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe("non-flag-based detectors still work", () => {
|
|
147
|
-
it("cargo test matches", async () => {
|
|
148
|
-
expect(await detect(["cargo", "test"])).toBe("cargo-test");
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("go test -json matches", async () => {
|
|
152
|
-
expect(await detect(["go", "test", "-json", "./..."])).toBe("go-test-json");
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("ava matches", async () => {
|
|
156
|
-
expect(await detect(["ava"])).toBe("ava-text");
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
it("swiftc -typecheck matches", async () => {
|
|
160
|
-
expect(await detect(["swiftc", "-typecheck", "main.swift"])).toBe("swiftc-text");
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("python3 -m unittest matches", async () => {
|
|
164
|
-
expect(await detect(["python3", "-m", "unittest"])).toBe("unittest-text");
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("vitest --reporter=json matches", async () => {
|
|
168
|
-
expect(await detect(["vitest", "run", "--reporter=json"])).toBe("vitest-json");
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
});
|