pi-rtk-optimizer 0.3.2 → 0.4.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/CHANGELOG.md +83 -49
- package/README.md +292 -283
- package/config/config.example.json +36 -35
- package/package.json +60 -59
- package/src/additional-coverage-test.ts +197 -0
- package/src/boolean-format.ts +3 -0
- package/src/command-rewriter-test.ts +160 -0
- package/src/command-rewriter.ts +594 -349
- package/src/config-modal-test.ts +168 -0
- package/src/config-modal.ts +613 -600
- package/src/config-store.ts +224 -217
- package/src/index-test.ts +54 -0
- package/src/index.ts +320 -291
- package/src/output-compactor-test.ts +334 -120
- package/src/output-compactor.ts +418 -343
- package/src/record-utils.ts +6 -0
- package/src/rewrite-bypass.ts +332 -0
- package/src/rewrite-pipeline-safety.ts +154 -0
- package/src/rewrite-rules.ts +255 -248
- package/src/runtime-guard-test.ts +42 -0
- package/src/runtime-guard.ts +14 -0
- package/src/techniques/build.ts +155 -155
- package/src/techniques/git.ts +229 -229
- package/src/techniques/index.ts +8 -16
- package/src/techniques/linter.ts +151 -161
- package/src/techniques/path-utils.ts +67 -0
- package/src/techniques/search.ts +67 -76
- package/src/techniques/source.ts +253 -230
- package/src/techniques/test-output.ts +172 -172
- package/src/test-helpers.ts +10 -0
- package/src/types-shims.d.ts +189 -131
- package/src/types.ts +103 -114
- package/src/compat-commands.ts +0 -207
|
@@ -1,172 +1,172 @@
|
|
|
1
|
-
import { matchesCommandPatterns } from "./command-detection.js";
|
|
2
|
-
|
|
3
|
-
interface TestSummary {
|
|
4
|
-
passed: number;
|
|
5
|
-
failed: number;
|
|
6
|
-
skipped: number;
|
|
7
|
-
failures: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const TEST_COMMAND_PATTERNS = [
|
|
11
|
-
/^npm\s+test\b/,
|
|
12
|
-
/^pnpm\s+test\b/,
|
|
13
|
-
/^yarn\s+test\b/,
|
|
14
|
-
/^bun\s+test\b/,
|
|
15
|
-
/^cargo\s+test\b/,
|
|
16
|
-
/^go\s+test\b/,
|
|
17
|
-
/^pytest\b/,
|
|
18
|
-
/^python\s+-m\s+pytest\b/,
|
|
19
|
-
/^(?:pnpm\s+)?(?:npx\s+)?vitest\b/,
|
|
20
|
-
/^(?:npx\s+)?jest\b/,
|
|
21
|
-
/^mocha\b/,
|
|
22
|
-
/^ava\b/,
|
|
23
|
-
/^tap\b/,
|
|
24
|
-
] as const;
|
|
25
|
-
|
|
26
|
-
const TEST_RESULT_PATTERNS = [
|
|
27
|
-
/test result:\s*(\w+)\.\s*(\d+)\s*passed;\s*(\d+)\s*failed;/,
|
|
28
|
-
/(\d+)\s*passed(?:,\s*(\d+)\s*failed)?(?:,\s*(\d+)\s*skipped)?/i,
|
|
29
|
-
/(\d+)\s*pass(?:,\s*(\d+)\s*fail)?(?:,\s*(\d+)\s*skip)?/i,
|
|
30
|
-
/tests?:\s*(\d+)\s*passed(?:,\s*(\d+)\s*failed)?(?:,\s*(\d+)\s*skipped)?/i,
|
|
31
|
-
];
|
|
32
|
-
|
|
33
|
-
const FAILURE_START_PATTERNS = [
|
|
34
|
-
/^FAIL\s+/,
|
|
35
|
-
/^FAILED\s+/,
|
|
36
|
-
/^\s*●\s+/,
|
|
37
|
-
/^\s*✕\s+/,
|
|
38
|
-
/test\s+\w+\s+\.\.\.\s*FAILED/,
|
|
39
|
-
/thread\s+'\w+'\s+panicked/,
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
function isFailureStart(line: string): boolean {
|
|
43
|
-
return FAILURE_START_PATTERNS.some((pattern) => pattern.test(line));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function extractTestStats(output: string): Partial<TestSummary> {
|
|
47
|
-
for (const pattern of TEST_RESULT_PATTERNS) {
|
|
48
|
-
const match = output.match(pattern);
|
|
49
|
-
if (!match) {
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
passed: Number.parseInt(match[1] ?? "0", 10) || 0,
|
|
54
|
-
failed: Number.parseInt(match[2] ?? "0", 10) || 0,
|
|
55
|
-
skipped: Number.parseInt(match[3] ?? "0", 10) || 0,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function isTestCommand(command: string | undefined | null): boolean {
|
|
62
|
-
return matchesCommandPatterns(command, TEST_COMMAND_PATTERNS);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function aggregateTestOutput(output: string, command: string | undefined | null): string | null {
|
|
66
|
-
if (!isTestCommand(command)) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const lines = output.split("\n");
|
|
71
|
-
const summary: TestSummary = {
|
|
72
|
-
passed: 0,
|
|
73
|
-
failed: 0,
|
|
74
|
-
skipped: 0,
|
|
75
|
-
failures: [],
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const stats = extractTestStats(output);
|
|
79
|
-
summary.passed = stats.passed ?? 0;
|
|
80
|
-
summary.failed = stats.failed ?? 0;
|
|
81
|
-
summary.skipped = stats.skipped ?? 0;
|
|
82
|
-
|
|
83
|
-
if (summary.passed === 0 && summary.failed === 0) {
|
|
84
|
-
for (const line of lines) {
|
|
85
|
-
if (line.match(/\b(ok|PASS|✓|✔)\b/)) {
|
|
86
|
-
summary.passed++;
|
|
87
|
-
}
|
|
88
|
-
if (line.match(/\b(FAIL|fail|✗|✕)\b/)) {
|
|
89
|
-
summary.failed++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (summary.failed > 0) {
|
|
95
|
-
let inFailure = false;
|
|
96
|
-
let currentFailure: string[] = [];
|
|
97
|
-
let blankCount = 0;
|
|
98
|
-
|
|
99
|
-
for (const line of lines) {
|
|
100
|
-
if (isFailureStart(line)) {
|
|
101
|
-
if (inFailure && currentFailure.length > 0) {
|
|
102
|
-
summary.failures.push(currentFailure.join("\n"));
|
|
103
|
-
}
|
|
104
|
-
inFailure = true;
|
|
105
|
-
currentFailure = [line];
|
|
106
|
-
blankCount = 0;
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!inFailure) {
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (line.trim() === "") {
|
|
115
|
-
blankCount++;
|
|
116
|
-
if (blankCount >= 2 && currentFailure.length > 3) {
|
|
117
|
-
summary.failures.push(currentFailure.join("\n"));
|
|
118
|
-
inFailure = false;
|
|
119
|
-
currentFailure = [];
|
|
120
|
-
} else {
|
|
121
|
-
currentFailure.push(line);
|
|
122
|
-
}
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (line.match(/^\s/) || line.match(/^-/)) {
|
|
127
|
-
currentFailure.push(line);
|
|
128
|
-
blankCount = 0;
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
summary.failures.push(currentFailure.join("\n"));
|
|
133
|
-
inFailure = false;
|
|
134
|
-
currentFailure = [];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (inFailure && currentFailure.length > 0) {
|
|
138
|
-
summary.failures.push(currentFailure.join("\n"));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const result: string[] = ["
|
|
143
|
-
result.push(`
|
|
144
|
-
if (summary.failed > 0) {
|
|
145
|
-
result.push(`
|
|
146
|
-
}
|
|
147
|
-
if (summary.skipped > 0) {
|
|
148
|
-
result.push(`
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (summary.failed > 0 && summary.failures.length > 0) {
|
|
152
|
-
result.push("\n Failures:");
|
|
153
|
-
for (const failure of summary.failures.slice(0, 5)) {
|
|
154
|
-
const failureLines = failure.split("\n");
|
|
155
|
-
const firstLine = failureLines[0] ?? "";
|
|
156
|
-
result.push(`
|
|
157
|
-
for (const detailLine of failureLines.slice(1, 4)) {
|
|
158
|
-
if (detailLine.trim()) {
|
|
159
|
-
result.push(` ${detailLine.slice(0, 65)}${detailLine.length > 65 ? "..." : ""}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
if (failureLines.length > 4) {
|
|
163
|
-
result.push(` ... (${failureLines.length - 4} more lines)`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
if (summary.failures.length > 5) {
|
|
167
|
-
result.push(` ... and ${summary.failures.length - 5} more failures`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return result.join("\n");
|
|
172
|
-
}
|
|
1
|
+
import { matchesCommandPatterns } from "./command-detection.js";
|
|
2
|
+
|
|
3
|
+
interface TestSummary {
|
|
4
|
+
passed: number;
|
|
5
|
+
failed: number;
|
|
6
|
+
skipped: number;
|
|
7
|
+
failures: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const TEST_COMMAND_PATTERNS = [
|
|
11
|
+
/^npm\s+test\b/,
|
|
12
|
+
/^pnpm\s+test\b/,
|
|
13
|
+
/^yarn\s+test\b/,
|
|
14
|
+
/^bun\s+test\b/,
|
|
15
|
+
/^cargo\s+test\b/,
|
|
16
|
+
/^go\s+test\b/,
|
|
17
|
+
/^pytest\b/,
|
|
18
|
+
/^python\s+-m\s+pytest\b/,
|
|
19
|
+
/^(?:pnpm\s+)?(?:npx\s+)?vitest\b/,
|
|
20
|
+
/^(?:npx\s+)?jest\b/,
|
|
21
|
+
/^mocha\b/,
|
|
22
|
+
/^ava\b/,
|
|
23
|
+
/^tap\b/,
|
|
24
|
+
] as const;
|
|
25
|
+
|
|
26
|
+
const TEST_RESULT_PATTERNS = [
|
|
27
|
+
/test result:\s*(\w+)\.\s*(\d+)\s*passed;\s*(\d+)\s*failed;/,
|
|
28
|
+
/(\d+)\s*passed(?:,\s*(\d+)\s*failed)?(?:,\s*(\d+)\s*skipped)?/i,
|
|
29
|
+
/(\d+)\s*pass(?:,\s*(\d+)\s*fail)?(?:,\s*(\d+)\s*skip)?/i,
|
|
30
|
+
/tests?:\s*(\d+)\s*passed(?:,\s*(\d+)\s*failed)?(?:,\s*(\d+)\s*skipped)?/i,
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
const FAILURE_START_PATTERNS = [
|
|
34
|
+
/^FAIL\s+/,
|
|
35
|
+
/^FAILED\s+/,
|
|
36
|
+
/^\s*●\s+/,
|
|
37
|
+
/^\s*✕\s+/,
|
|
38
|
+
/test\s+\w+\s+\.\.\.\s*FAILED/,
|
|
39
|
+
/thread\s+'\w+'\s+panicked/,
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
function isFailureStart(line: string): boolean {
|
|
43
|
+
return FAILURE_START_PATTERNS.some((pattern) => pattern.test(line));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function extractTestStats(output: string): Partial<TestSummary> {
|
|
47
|
+
for (const pattern of TEST_RESULT_PATTERNS) {
|
|
48
|
+
const match = output.match(pattern);
|
|
49
|
+
if (!match) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
passed: Number.parseInt(match[1] ?? "0", 10) || 0,
|
|
54
|
+
failed: Number.parseInt(match[2] ?? "0", 10) || 0,
|
|
55
|
+
skipped: Number.parseInt(match[3] ?? "0", 10) || 0,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function isTestCommand(command: string | undefined | null): boolean {
|
|
62
|
+
return matchesCommandPatterns(command, TEST_COMMAND_PATTERNS);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function aggregateTestOutput(output: string, command: string | undefined | null): string | null {
|
|
66
|
+
if (!isTestCommand(command)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const lines = output.split("\n");
|
|
71
|
+
const summary: TestSummary = {
|
|
72
|
+
passed: 0,
|
|
73
|
+
failed: 0,
|
|
74
|
+
skipped: 0,
|
|
75
|
+
failures: [],
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const stats = extractTestStats(output);
|
|
79
|
+
summary.passed = stats.passed ?? 0;
|
|
80
|
+
summary.failed = stats.failed ?? 0;
|
|
81
|
+
summary.skipped = stats.skipped ?? 0;
|
|
82
|
+
|
|
83
|
+
if (summary.passed === 0 && summary.failed === 0) {
|
|
84
|
+
for (const line of lines) {
|
|
85
|
+
if (line.match(/\b(ok|PASS|✓|✔)\b/)) {
|
|
86
|
+
summary.passed++;
|
|
87
|
+
}
|
|
88
|
+
if (line.match(/\b(FAIL|fail|✗|✕)\b/)) {
|
|
89
|
+
summary.failed++;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (summary.failed > 0) {
|
|
95
|
+
let inFailure = false;
|
|
96
|
+
let currentFailure: string[] = [];
|
|
97
|
+
let blankCount = 0;
|
|
98
|
+
|
|
99
|
+
for (const line of lines) {
|
|
100
|
+
if (isFailureStart(line)) {
|
|
101
|
+
if (inFailure && currentFailure.length > 0) {
|
|
102
|
+
summary.failures.push(currentFailure.join("\n"));
|
|
103
|
+
}
|
|
104
|
+
inFailure = true;
|
|
105
|
+
currentFailure = [line];
|
|
106
|
+
blankCount = 0;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!inFailure) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (line.trim() === "") {
|
|
115
|
+
blankCount++;
|
|
116
|
+
if (blankCount >= 2 && currentFailure.length > 3) {
|
|
117
|
+
summary.failures.push(currentFailure.join("\n"));
|
|
118
|
+
inFailure = false;
|
|
119
|
+
currentFailure = [];
|
|
120
|
+
} else {
|
|
121
|
+
currentFailure.push(line);
|
|
122
|
+
}
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (line.match(/^\s/) || line.match(/^-/)) {
|
|
127
|
+
currentFailure.push(line);
|
|
128
|
+
blankCount = 0;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
summary.failures.push(currentFailure.join("\n"));
|
|
133
|
+
inFailure = false;
|
|
134
|
+
currentFailure = [];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (inFailure && currentFailure.length > 0) {
|
|
138
|
+
summary.failures.push(currentFailure.join("\n"));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const result: string[] = ["Test Results:"];
|
|
143
|
+
result.push(` PASS: ${summary.passed} passed`);
|
|
144
|
+
if (summary.failed > 0) {
|
|
145
|
+
result.push(` FAIL: ${summary.failed} failed`);
|
|
146
|
+
}
|
|
147
|
+
if (summary.skipped > 0) {
|
|
148
|
+
result.push(` SKIP: ${summary.skipped} skipped`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (summary.failed > 0 && summary.failures.length > 0) {
|
|
152
|
+
result.push("\n Failures:");
|
|
153
|
+
for (const failure of summary.failures.slice(0, 5)) {
|
|
154
|
+
const failureLines = failure.split("\n");
|
|
155
|
+
const firstLine = failureLines[0] ?? "";
|
|
156
|
+
result.push(` - ${firstLine.slice(0, 70)}${firstLine.length > 70 ? "..." : ""}`);
|
|
157
|
+
for (const detailLine of failureLines.slice(1, 4)) {
|
|
158
|
+
if (detailLine.trim()) {
|
|
159
|
+
result.push(` ${detailLine.slice(0, 65)}${detailLine.length > 65 ? "..." : ""}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (failureLines.length > 4) {
|
|
163
|
+
result.push(` ... (${failureLines.length - 4} more lines)`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (summary.failures.length > 5) {
|
|
167
|
+
result.push(` ... and ${summary.failures.length - 5} more failures`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return result.join("\n");
|
|
172
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DEFAULT_RTK_INTEGRATION_CONFIG, type RtkIntegrationConfig } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
export function runTest(name: string, testFn: () => void): void {
|
|
4
|
+
testFn();
|
|
5
|
+
console.log(`[PASS] ${name}`);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function cloneDefaultConfig(): RtkIntegrationConfig {
|
|
9
|
+
return structuredClone(DEFAULT_RTK_INTEGRATION_CONFIG);
|
|
10
|
+
}
|
package/src/types-shims.d.ts
CHANGED
|
@@ -1,131 +1,189 @@
|
|
|
1
|
-
declare module "@mariozechner/pi-tui" {
|
|
2
|
-
export interface SettingItem {
|
|
3
|
-
id: string;
|
|
4
|
-
label: string;
|
|
5
|
-
description: string;
|
|
6
|
-
currentValue: string;
|
|
7
|
-
values: string[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface AutocompleteItem {
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
export
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
1
|
+
declare module "@mariozechner/pi-tui" {
|
|
2
|
+
export interface SettingItem {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
currentValue: string;
|
|
7
|
+
values: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AutocompleteItem {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class Box {
|
|
17
|
+
constructor(...args: unknown[]);
|
|
18
|
+
addChild(child: unknown): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class Container {
|
|
22
|
+
constructor(...args: unknown[]);
|
|
23
|
+
addChild(child: unknown): void;
|
|
24
|
+
render(width: number): string[];
|
|
25
|
+
invalidate(): void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class SettingsList {
|
|
29
|
+
constructor(...args: unknown[]);
|
|
30
|
+
handleInput(data: string): void;
|
|
31
|
+
updateValue(id: string, value: string): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Spacer {
|
|
35
|
+
constructor(...args: unknown[]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class Text {
|
|
39
|
+
constructor(...args: unknown[]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function truncateToWidth(text: string, width: number, suffix?: string, pad?: boolean): string;
|
|
43
|
+
export function visibleWidth(text: string): number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare module "@mariozechner/pi-coding-agent" {
|
|
47
|
+
interface UiLike {
|
|
48
|
+
notify(message: string, level: "info" | "warning" | "error"): void;
|
|
49
|
+
custom<T>(
|
|
50
|
+
renderer: (
|
|
51
|
+
tui: { requestRender(): void },
|
|
52
|
+
theme: Theme,
|
|
53
|
+
keybindings: unknown,
|
|
54
|
+
done: () => void,
|
|
55
|
+
) => {
|
|
56
|
+
render(width: number): string[];
|
|
57
|
+
invalidate?(): void;
|
|
58
|
+
handleInput(data: string): void;
|
|
59
|
+
},
|
|
60
|
+
options?: Record<string, unknown>,
|
|
61
|
+
): Promise<T>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ExtensionContext {
|
|
65
|
+
hasUI: boolean;
|
|
66
|
+
cwd?: string;
|
|
67
|
+
ui: UiLike;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface ExtensionCommandContext extends ExtensionContext {}
|
|
71
|
+
|
|
72
|
+
export interface ToolResultEvent {
|
|
73
|
+
toolName: string;
|
|
74
|
+
input: Record<string, unknown>;
|
|
75
|
+
content: Array<Record<string, unknown>>;
|
|
76
|
+
details?: unknown;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface BashToolCallEvent {
|
|
80
|
+
toolName: "bash";
|
|
81
|
+
input: { command: string } & Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
85
|
+
|
|
86
|
+
export interface Theme {
|
|
87
|
+
fg(color: string, text: string): string;
|
|
88
|
+
bold(text: string): string;
|
|
89
|
+
getFgAnsi?(name: string): string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function getSettingsListTheme(): unknown;
|
|
93
|
+
|
|
94
|
+
export interface ExtensionAPI {
|
|
95
|
+
exec(
|
|
96
|
+
command: string,
|
|
97
|
+
args: string[],
|
|
98
|
+
options?: { timeout?: number },
|
|
99
|
+
): Promise<{ code: number; stdout: string; stderr: string }>;
|
|
100
|
+
|
|
101
|
+
on(
|
|
102
|
+
eventName: "tool_call",
|
|
103
|
+
handler: (
|
|
104
|
+
event: Record<string, unknown>,
|
|
105
|
+
ctx: ExtensionContext,
|
|
106
|
+
) => MaybePromise<Record<string, unknown> | void>,
|
|
107
|
+
): void;
|
|
108
|
+
|
|
109
|
+
on(
|
|
110
|
+
eventName: "tool_result",
|
|
111
|
+
handler: (
|
|
112
|
+
event: ToolResultEvent,
|
|
113
|
+
ctx: ExtensionContext,
|
|
114
|
+
) => MaybePromise<Record<string, unknown> | void>,
|
|
115
|
+
): void;
|
|
116
|
+
|
|
117
|
+
on(
|
|
118
|
+
eventName: "before_agent_start",
|
|
119
|
+
handler: (
|
|
120
|
+
event: { systemPrompt: string },
|
|
121
|
+
ctx: ExtensionContext,
|
|
122
|
+
) => MaybePromise<{ systemPrompt: string } | Record<string, unknown> | void>,
|
|
123
|
+
): void;
|
|
124
|
+
|
|
125
|
+
on(
|
|
126
|
+
eventName: string,
|
|
127
|
+
handler: (event: Record<string, unknown>, ctx: ExtensionContext) => MaybePromise<Record<string, unknown> | void>,
|
|
128
|
+
): void;
|
|
129
|
+
|
|
130
|
+
registerCommand(
|
|
131
|
+
name: string,
|
|
132
|
+
definition: {
|
|
133
|
+
description: string;
|
|
134
|
+
getArgumentCompletions?: (argumentPrefix: string) => Array<{ value: string; label: string; description?: string }> | null;
|
|
135
|
+
handler: (args: string, ctx: ExtensionCommandContext) => MaybePromise<void>;
|
|
136
|
+
},
|
|
137
|
+
): void;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function isToolCallEventType(
|
|
141
|
+
toolName: "bash",
|
|
142
|
+
event: Record<string, unknown>,
|
|
143
|
+
): event is BashToolCallEvent;
|
|
144
|
+
|
|
145
|
+
export function isToolCallEventType(
|
|
146
|
+
toolName: string,
|
|
147
|
+
event: Record<string, unknown>,
|
|
148
|
+
): boolean;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
declare module "node:assert/strict" {
|
|
153
|
+
const assert: {
|
|
154
|
+
equal(actual: unknown, expected: unknown, message?: string): void;
|
|
155
|
+
deepEqual(actual: unknown, expected: unknown, message?: string): void;
|
|
156
|
+
ok(value: unknown, message?: string): void;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export default assert;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
declare module "bun:test" {
|
|
163
|
+
export const mock: {
|
|
164
|
+
module(specifier: string, factory: () => Record<string, unknown>): void;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare const process: {
|
|
169
|
+
platform: string;
|
|
170
|
+
env: Record<string, string | undefined>;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
declare module "node:os" {
|
|
174
|
+
export function homedir(): string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare module "node:path" {
|
|
178
|
+
export function join(...segments: string[]): string;
|
|
179
|
+
export function dirname(path: string): string;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
declare module "node:fs" {
|
|
183
|
+
export function existsSync(path: string): boolean;
|
|
184
|
+
export function mkdirSync(path: string, options?: { recursive?: boolean }): void;
|
|
185
|
+
export function readFileSync(path: string, encoding: "utf-8"): string;
|
|
186
|
+
export function renameSync(oldPath: string, newPath: string): void;
|
|
187
|
+
export function unlinkSync(path: string): void;
|
|
188
|
+
export function writeFileSync(path: string, data: string, encoding: "utf-8"): void;
|
|
189
|
+
}
|