@wingsbutterfly/dsh-rtk 0.1.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 +52 -0
- package/LICENSE +21 -0
- package/README.md +214 -0
- package/README.zh.md +211 -0
- package/THIRD_PARTY_NOTICES.md +51 -0
- package/docs/assets/how-it-works.svg +47 -0
- package/docs/verification.md +279 -0
- package/lib/command.d.ts +41 -0
- package/lib/command.d.ts.map +1 -0
- package/lib/command.js +137 -0
- package/lib/command.js.map +1 -0
- package/lib/compact/build.d.ts +15 -0
- package/lib/compact/build.d.ts.map +1 -0
- package/lib/compact/build.js +140 -0
- package/lib/compact/build.js.map +1 -0
- package/lib/compact/detect.d.ts +22 -0
- package/lib/compact/detect.d.ts.map +1 -0
- package/lib/compact/detect.js +54 -0
- package/lib/compact/detect.js.map +1 -0
- package/lib/compact/dsh-result.d.ts +49 -0
- package/lib/compact/dsh-result.d.ts.map +1 -0
- package/lib/compact/dsh-result.js +84 -0
- package/lib/compact/dsh-result.js.map +1 -0
- package/lib/compact/git.d.ts +21 -0
- package/lib/compact/git.d.ts.map +1 -0
- package/lib/compact/git.js +197 -0
- package/lib/compact/git.js.map +1 -0
- package/lib/compact/index.d.ts +39 -0
- package/lib/compact/index.d.ts.map +1 -0
- package/lib/compact/index.js +236 -0
- package/lib/compact/index.js.map +1 -0
- package/lib/compact/linter.d.ts +12 -0
- package/lib/compact/linter.d.ts.map +1 -0
- package/lib/compact/linter.js +118 -0
- package/lib/compact/linter.js.map +1 -0
- package/lib/compact/search.d.ts +16 -0
- package/lib/compact/search.d.ts.map +1 -0
- package/lib/compact/search.js +67 -0
- package/lib/compact/search.js.map +1 -0
- package/lib/compact/source.d.ts +22 -0
- package/lib/compact/source.d.ts.map +1 -0
- package/lib/compact/source.js +224 -0
- package/lib/compact/source.js.map +1 -0
- package/lib/compact/test-output.d.ts +12 -0
- package/lib/compact/test-output.d.ts.map +1 -0
- package/lib/compact/test-output.js +168 -0
- package/lib/compact/test-output.js.map +1 -0
- package/lib/compact/text.d.ts +22 -0
- package/lib/compact/text.d.ts.map +1 -0
- package/lib/compact/text.js +87 -0
- package/lib/compact/text.js.map +1 -0
- package/lib/config.d.ts +243 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +183 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +46 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +405 -0
- package/lib/index.js.map +1 -0
- package/lib/metrics.d.ts +35 -0
- package/lib/metrics.d.ts.map +1 -0
- package/lib/metrics.js +51 -0
- package/lib/metrics.js.map +1 -0
- package/lib/rtk-executable.d.ts +51 -0
- package/lib/rtk-executable.d.ts.map +1 -0
- package/lib/rtk-executable.js +75 -0
- package/lib/rtk-executable.js.map +1 -0
- package/lib/rtk-rewrite.d.ts +88 -0
- package/lib/rtk-rewrite.d.ts.map +1 -0
- package/lib/rtk-rewrite.js +150 -0
- package/lib/rtk-rewrite.js.map +1 -0
- package/lib/runtime-guard.d.ts +31 -0
- package/lib/runtime-guard.d.ts.map +1 -0
- package/lib/runtime-guard.js +32 -0
- package/lib/runtime-guard.js.map +1 -0
- package/package.json +82 -0
- package/scripts/link-dsh.mjs +135 -0
- package/src/command.ts +174 -0
- package/src/compact/build.ts +154 -0
- package/src/compact/detect.ts +54 -0
- package/src/compact/dsh-result.ts +99 -0
- package/src/compact/git.ts +209 -0
- package/src/compact/index.ts +284 -0
- package/src/compact/linter.ts +126 -0
- package/src/compact/search.ts +73 -0
- package/src/compact/source.ts +244 -0
- package/src/compact/test-output.ts +184 -0
- package/src/compact/text.ts +86 -0
- package/src/config.ts +263 -0
- package/src/index.ts +431 -0
- package/src/metrics.ts +84 -0
- package/src/rtk-executable.ts +117 -0
- package/src/rtk-rewrite.ts +179 -0
- package/src/runtime-guard.ts +44 -0
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
/**
|
|
3
|
+
* How bash commands are handled.
|
|
4
|
+
*
|
|
5
|
+
* - `rewrite` — a command with an RTK equivalent is replaced before it runs.
|
|
6
|
+
* - `suggest` — the command runs unchanged; the rewrite is only reported.
|
|
7
|
+
*/
|
|
8
|
+
export type RtkMode = 'rewrite' | 'suggest';
|
|
9
|
+
/** Source-code filtering strength applied to `read` output. */
|
|
10
|
+
export type SourceCodeFilteringLevel = 'none' | 'minimal' | 'aggressive';
|
|
11
|
+
/** Line-based truncation for `read` output. */
|
|
12
|
+
export interface SmartTruncateConfig {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
maxLines: number;
|
|
15
|
+
}
|
|
16
|
+
/** Final character-budget enforcement applied to every compacted text. */
|
|
17
|
+
export interface TruncateConfig {
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
maxChars: number;
|
|
20
|
+
}
|
|
21
|
+
/** Lossy compaction for `read` output; off by default so code reads stay exact. */
|
|
22
|
+
export interface ReadCompactionConfig {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** The output-compaction pipeline's switches. */
|
|
26
|
+
export interface OutputCompactionConfig {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
stripAnsi: boolean;
|
|
29
|
+
readCompaction: ReadCompactionConfig;
|
|
30
|
+
sourceCodeFilteringEnabled: boolean;
|
|
31
|
+
preserveExactSkillReads: boolean;
|
|
32
|
+
sourceCodeFiltering: SourceCodeFilteringLevel;
|
|
33
|
+
aggregateTestOutput: boolean;
|
|
34
|
+
filterBuildOutput: boolean;
|
|
35
|
+
compactGitOutput: boolean;
|
|
36
|
+
aggregateLinterOutput: boolean;
|
|
37
|
+
groupSearchOutput: boolean;
|
|
38
|
+
trackSavings: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Yield oversized results to the harness's own spill policy when it is
|
|
41
|
+
* mounted, instead of hard-truncating them first.
|
|
42
|
+
*/
|
|
43
|
+
deferToHarnessSpill: boolean;
|
|
44
|
+
smartTruncate: SmartTruncateConfig;
|
|
45
|
+
truncate: TruncateConfig;
|
|
46
|
+
}
|
|
47
|
+
/** The plugin's fully-resolved configuration. */
|
|
48
|
+
export interface RtkConfig {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
mode: RtkMode;
|
|
51
|
+
guardWhenRtkMissing: boolean;
|
|
52
|
+
showRewriteNotifications: boolean;
|
|
53
|
+
/** Whether a session is told once that rewriting is off because rtk is absent. */
|
|
54
|
+
notifyWhenRtkMissing: boolean;
|
|
55
|
+
/** Executable used for both `--version` probes and `rtk rewrite`. */
|
|
56
|
+
rtkExecutable: string;
|
|
57
|
+
/** Deadline for one `rtk rewrite` call. */
|
|
58
|
+
rewriteTimeoutMs: number;
|
|
59
|
+
/** Tools whose results pass through the compaction pipeline. */
|
|
60
|
+
compactedTools: string[];
|
|
61
|
+
outputCompaction: OutputCompactionConfig;
|
|
62
|
+
}
|
|
63
|
+
/** Defaults for every field; also the fallback when a layer omits one. */
|
|
64
|
+
export declare const DEFAULT_CONFIG: RtkConfig;
|
|
65
|
+
/** Bounds published in the configuration catalog and enforced during normalization. */
|
|
66
|
+
export declare const BOUNDS: {
|
|
67
|
+
readonly maxLines: {
|
|
68
|
+
readonly min: 40;
|
|
69
|
+
readonly max: 4000;
|
|
70
|
+
};
|
|
71
|
+
readonly maxChars: {
|
|
72
|
+
readonly min: 1000;
|
|
73
|
+
readonly max: 200000;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The composition-facing configuration schema.
|
|
78
|
+
*
|
|
79
|
+
* Exported as both a value (the schemastery schema the loader validates and
|
|
80
|
+
* fills defaults with) and, through declaration merging, the resolved type.
|
|
81
|
+
* No explicit annotation is attached: `z.object` already infers the pair, and
|
|
82
|
+
* a hand-written one would have to restate every nested field.
|
|
83
|
+
*/
|
|
84
|
+
export declare const Config: z<Schemastery.ObjectS<{
|
|
85
|
+
enabled: z<boolean, boolean>;
|
|
86
|
+
mode: z<"rewrite" | "suggest", "rewrite" | "suggest">;
|
|
87
|
+
guardWhenRtkMissing: z<boolean, boolean>;
|
|
88
|
+
showRewriteNotifications: z<boolean, boolean>;
|
|
89
|
+
notifyWhenRtkMissing: z<boolean, boolean>;
|
|
90
|
+
rtkExecutable: z<string, string>;
|
|
91
|
+
rewriteTimeoutMs: z<number, number>;
|
|
92
|
+
compactedTools: z<string[], string[]>;
|
|
93
|
+
outputCompaction: z<Schemastery.ObjectS<{
|
|
94
|
+
enabled: z<boolean, boolean>;
|
|
95
|
+
stripAnsi: z<boolean, boolean>;
|
|
96
|
+
readCompaction: z<Schemastery.ObjectS<{
|
|
97
|
+
enabled: z<boolean, boolean>;
|
|
98
|
+
}>, Schemastery.ObjectT<{
|
|
99
|
+
enabled: z<boolean, boolean>;
|
|
100
|
+
}>>;
|
|
101
|
+
sourceCodeFilteringEnabled: z<boolean, boolean>;
|
|
102
|
+
preserveExactSkillReads: z<boolean, boolean>;
|
|
103
|
+
sourceCodeFiltering: z<"none" | "minimal" | "aggressive", "none" | "minimal" | "aggressive">;
|
|
104
|
+
aggregateTestOutput: z<boolean, boolean>;
|
|
105
|
+
filterBuildOutput: z<boolean, boolean>;
|
|
106
|
+
compactGitOutput: z<boolean, boolean>;
|
|
107
|
+
aggregateLinterOutput: z<boolean, boolean>;
|
|
108
|
+
groupSearchOutput: z<boolean, boolean>;
|
|
109
|
+
trackSavings: z<boolean, boolean>;
|
|
110
|
+
deferToHarnessSpill: z<boolean, boolean>;
|
|
111
|
+
smartTruncate: z<Schemastery.ObjectS<{
|
|
112
|
+
enabled: z<boolean, boolean>;
|
|
113
|
+
maxLines: z<number, number>;
|
|
114
|
+
}>, Schemastery.ObjectT<{
|
|
115
|
+
enabled: z<boolean, boolean>;
|
|
116
|
+
maxLines: z<number, number>;
|
|
117
|
+
}>>;
|
|
118
|
+
truncate: z<Schemastery.ObjectS<{
|
|
119
|
+
enabled: z<boolean, boolean>;
|
|
120
|
+
maxChars: z<number, number>;
|
|
121
|
+
}>, Schemastery.ObjectT<{
|
|
122
|
+
enabled: z<boolean, boolean>;
|
|
123
|
+
maxChars: z<number, number>;
|
|
124
|
+
}>>;
|
|
125
|
+
}>, Schemastery.ObjectT<{
|
|
126
|
+
enabled: z<boolean, boolean>;
|
|
127
|
+
stripAnsi: z<boolean, boolean>;
|
|
128
|
+
readCompaction: z<Schemastery.ObjectS<{
|
|
129
|
+
enabled: z<boolean, boolean>;
|
|
130
|
+
}>, Schemastery.ObjectT<{
|
|
131
|
+
enabled: z<boolean, boolean>;
|
|
132
|
+
}>>;
|
|
133
|
+
sourceCodeFilteringEnabled: z<boolean, boolean>;
|
|
134
|
+
preserveExactSkillReads: z<boolean, boolean>;
|
|
135
|
+
sourceCodeFiltering: z<"none" | "minimal" | "aggressive", "none" | "minimal" | "aggressive">;
|
|
136
|
+
aggregateTestOutput: z<boolean, boolean>;
|
|
137
|
+
filterBuildOutput: z<boolean, boolean>;
|
|
138
|
+
compactGitOutput: z<boolean, boolean>;
|
|
139
|
+
aggregateLinterOutput: z<boolean, boolean>;
|
|
140
|
+
groupSearchOutput: z<boolean, boolean>;
|
|
141
|
+
trackSavings: z<boolean, boolean>;
|
|
142
|
+
deferToHarnessSpill: z<boolean, boolean>;
|
|
143
|
+
smartTruncate: z<Schemastery.ObjectS<{
|
|
144
|
+
enabled: z<boolean, boolean>;
|
|
145
|
+
maxLines: z<number, number>;
|
|
146
|
+
}>, Schemastery.ObjectT<{
|
|
147
|
+
enabled: z<boolean, boolean>;
|
|
148
|
+
maxLines: z<number, number>;
|
|
149
|
+
}>>;
|
|
150
|
+
truncate: z<Schemastery.ObjectS<{
|
|
151
|
+
enabled: z<boolean, boolean>;
|
|
152
|
+
maxChars: z<number, number>;
|
|
153
|
+
}>, Schemastery.ObjectT<{
|
|
154
|
+
enabled: z<boolean, boolean>;
|
|
155
|
+
maxChars: z<number, number>;
|
|
156
|
+
}>>;
|
|
157
|
+
}>>;
|
|
158
|
+
}>, Schemastery.ObjectT<{
|
|
159
|
+
enabled: z<boolean, boolean>;
|
|
160
|
+
mode: z<"rewrite" | "suggest", "rewrite" | "suggest">;
|
|
161
|
+
guardWhenRtkMissing: z<boolean, boolean>;
|
|
162
|
+
showRewriteNotifications: z<boolean, boolean>;
|
|
163
|
+
notifyWhenRtkMissing: z<boolean, boolean>;
|
|
164
|
+
rtkExecutable: z<string, string>;
|
|
165
|
+
rewriteTimeoutMs: z<number, number>;
|
|
166
|
+
compactedTools: z<string[], string[]>;
|
|
167
|
+
outputCompaction: z<Schemastery.ObjectS<{
|
|
168
|
+
enabled: z<boolean, boolean>;
|
|
169
|
+
stripAnsi: z<boolean, boolean>;
|
|
170
|
+
readCompaction: z<Schemastery.ObjectS<{
|
|
171
|
+
enabled: z<boolean, boolean>;
|
|
172
|
+
}>, Schemastery.ObjectT<{
|
|
173
|
+
enabled: z<boolean, boolean>;
|
|
174
|
+
}>>;
|
|
175
|
+
sourceCodeFilteringEnabled: z<boolean, boolean>;
|
|
176
|
+
preserveExactSkillReads: z<boolean, boolean>;
|
|
177
|
+
sourceCodeFiltering: z<"none" | "minimal" | "aggressive", "none" | "minimal" | "aggressive">;
|
|
178
|
+
aggregateTestOutput: z<boolean, boolean>;
|
|
179
|
+
filterBuildOutput: z<boolean, boolean>;
|
|
180
|
+
compactGitOutput: z<boolean, boolean>;
|
|
181
|
+
aggregateLinterOutput: z<boolean, boolean>;
|
|
182
|
+
groupSearchOutput: z<boolean, boolean>;
|
|
183
|
+
trackSavings: z<boolean, boolean>;
|
|
184
|
+
deferToHarnessSpill: z<boolean, boolean>;
|
|
185
|
+
smartTruncate: z<Schemastery.ObjectS<{
|
|
186
|
+
enabled: z<boolean, boolean>;
|
|
187
|
+
maxLines: z<number, number>;
|
|
188
|
+
}>, Schemastery.ObjectT<{
|
|
189
|
+
enabled: z<boolean, boolean>;
|
|
190
|
+
maxLines: z<number, number>;
|
|
191
|
+
}>>;
|
|
192
|
+
truncate: z<Schemastery.ObjectS<{
|
|
193
|
+
enabled: z<boolean, boolean>;
|
|
194
|
+
maxChars: z<number, number>;
|
|
195
|
+
}>, Schemastery.ObjectT<{
|
|
196
|
+
enabled: z<boolean, boolean>;
|
|
197
|
+
maxChars: z<number, number>;
|
|
198
|
+
}>>;
|
|
199
|
+
}>, Schemastery.ObjectT<{
|
|
200
|
+
enabled: z<boolean, boolean>;
|
|
201
|
+
stripAnsi: z<boolean, boolean>;
|
|
202
|
+
readCompaction: z<Schemastery.ObjectS<{
|
|
203
|
+
enabled: z<boolean, boolean>;
|
|
204
|
+
}>, Schemastery.ObjectT<{
|
|
205
|
+
enabled: z<boolean, boolean>;
|
|
206
|
+
}>>;
|
|
207
|
+
sourceCodeFilteringEnabled: z<boolean, boolean>;
|
|
208
|
+
preserveExactSkillReads: z<boolean, boolean>;
|
|
209
|
+
sourceCodeFiltering: z<"none" | "minimal" | "aggressive", "none" | "minimal" | "aggressive">;
|
|
210
|
+
aggregateTestOutput: z<boolean, boolean>;
|
|
211
|
+
filterBuildOutput: z<boolean, boolean>;
|
|
212
|
+
compactGitOutput: z<boolean, boolean>;
|
|
213
|
+
aggregateLinterOutput: z<boolean, boolean>;
|
|
214
|
+
groupSearchOutput: z<boolean, boolean>;
|
|
215
|
+
trackSavings: z<boolean, boolean>;
|
|
216
|
+
deferToHarnessSpill: z<boolean, boolean>;
|
|
217
|
+
smartTruncate: z<Schemastery.ObjectS<{
|
|
218
|
+
enabled: z<boolean, boolean>;
|
|
219
|
+
maxLines: z<number, number>;
|
|
220
|
+
}>, Schemastery.ObjectT<{
|
|
221
|
+
enabled: z<boolean, boolean>;
|
|
222
|
+
maxLines: z<number, number>;
|
|
223
|
+
}>>;
|
|
224
|
+
truncate: z<Schemastery.ObjectS<{
|
|
225
|
+
enabled: z<boolean, boolean>;
|
|
226
|
+
maxChars: z<number, number>;
|
|
227
|
+
}>, Schemastery.ObjectT<{
|
|
228
|
+
enabled: z<boolean, boolean>;
|
|
229
|
+
maxChars: z<number, number>;
|
|
230
|
+
}>>;
|
|
231
|
+
}>>;
|
|
232
|
+
}>>;
|
|
233
|
+
/**
|
|
234
|
+
* Normalize arbitrary configuration into a complete {@link RtkConfig}.
|
|
235
|
+
*
|
|
236
|
+
* The loader already validates the composition's `config:` block, but this
|
|
237
|
+
* entry is also reachable from tests, from `apply()` called directly, and from
|
|
238
|
+
* a runtime patch, so every field is re-derived rather than trusted. Numbers
|
|
239
|
+
* are clamped to {@link BOUNDS} so a hand-edited value cannot disable the
|
|
240
|
+
* pipeline's safeguards by accident.
|
|
241
|
+
*/
|
|
242
|
+
export declare function normalizeConfig(raw: unknown): RtkConfig;
|
|
243
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAE3C,+DAA+D;AAC/D,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,CAAA;AAExE,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,0EAA0E;AAC1E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,iDAAiD;AACjD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,cAAc,EAAE,oBAAoB,CAAA;IACpC,0BAA0B,EAAE,OAAO,CAAA;IACnC,uBAAuB,EAAE,OAAO,CAAA;IAChC,mBAAmB,EAAE,wBAAwB,CAAA;IAC7C,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/** Defaults for every field; also the fallback when a layer omits one. */
|
|
3
|
+
export const DEFAULT_CONFIG = {
|
|
4
|
+
enabled: true,
|
|
5
|
+
mode: 'rewrite',
|
|
6
|
+
guardWhenRtkMissing: true,
|
|
7
|
+
// Deliberately off, unlike pi-rtk-optimizer's equivalent flag. There the
|
|
8
|
+
// notice is a TUI toast; here it is appended to the tool result, so it would
|
|
9
|
+
// sit in the model's context on every rewritten call. The saving is the
|
|
10
|
+
// point of the plugin, and `/rtk stats` already reports what happened.
|
|
11
|
+
showRewriteNotifications: false,
|
|
12
|
+
// On: a missing binary is the one condition that silently costs the user the
|
|
13
|
+
// whole feature. The notice is emitted once per session, so its cost is
|
|
14
|
+
// bounded even though it is on by default.
|
|
15
|
+
notifyWhenRtkMissing: true,
|
|
16
|
+
rtkExecutable: 'rtk',
|
|
17
|
+
rewriteTimeoutMs: 3000,
|
|
18
|
+
compactedTools: ['bash', 'read', 'grep'],
|
|
19
|
+
outputCompaction: {
|
|
20
|
+
enabled: true,
|
|
21
|
+
stripAnsi: true,
|
|
22
|
+
readCompaction: { enabled: false },
|
|
23
|
+
sourceCodeFilteringEnabled: false,
|
|
24
|
+
preserveExactSkillReads: false,
|
|
25
|
+
sourceCodeFiltering: 'none',
|
|
26
|
+
aggregateTestOutput: true,
|
|
27
|
+
filterBuildOutput: true,
|
|
28
|
+
compactGitOutput: true,
|
|
29
|
+
aggregateLinterOutput: true,
|
|
30
|
+
groupSearchOutput: true,
|
|
31
|
+
trackSavings: true,
|
|
32
|
+
// The harness spill policy truncates recoverably (full output on disk,
|
|
33
|
+
// head/tail preview inline); this plugin's hard truncation does not. It
|
|
34
|
+
// also runs first, so at 12 000 characters it fires far below spill's
|
|
35
|
+
// threshold and spill never sees a large result. Deferring is the default;
|
|
36
|
+
// `false` keeps this plugin's own bound even when spill is mounted.
|
|
37
|
+
deferToHarnessSpill: true,
|
|
38
|
+
smartTruncate: { enabled: false, maxLines: 220 },
|
|
39
|
+
truncate: { enabled: true, maxChars: 12000 },
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
const SOURCE_CODE_FILTERING_LEVELS = ['none', 'minimal', 'aggressive'];
|
|
43
|
+
/** Bounds published in the configuration catalog and enforced during normalization. */
|
|
44
|
+
export const BOUNDS = {
|
|
45
|
+
maxLines: { min: 40, max: 4000 },
|
|
46
|
+
maxChars: { min: 1000, max: 200000 },
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* The composition-facing configuration schema.
|
|
50
|
+
*
|
|
51
|
+
* Exported as both a value (the schemastery schema the loader validates and
|
|
52
|
+
* fills defaults with) and, through declaration merging, the resolved type.
|
|
53
|
+
* No explicit annotation is attached: `z.object` already infers the pair, and
|
|
54
|
+
* a hand-written one would have to restate every nested field.
|
|
55
|
+
*/
|
|
56
|
+
export const Config = z.object({
|
|
57
|
+
enabled: z.boolean().default(DEFAULT_CONFIG.enabled).description('Master switch for command rewriting and output compaction.'),
|
|
58
|
+
mode: z
|
|
59
|
+
.union([z.const('rewrite'), z.const('suggest')])
|
|
60
|
+
.default(DEFAULT_CONFIG.mode)
|
|
61
|
+
.description('`rewrite` replaces a supported command; `suggest` only reports the equivalent.'),
|
|
62
|
+
guardWhenRtkMissing: z
|
|
63
|
+
.boolean()
|
|
64
|
+
.default(DEFAULT_CONFIG.guardWhenRtkMissing)
|
|
65
|
+
.description('Run the original command unchanged when the rtk executable is unavailable.'),
|
|
66
|
+
showRewriteNotifications: z
|
|
67
|
+
.boolean()
|
|
68
|
+
.default(DEFAULT_CONFIG.showRewriteNotifications)
|
|
69
|
+
.description('Record rewrite decisions so they are visible in the session log.'),
|
|
70
|
+
notifyWhenRtkMissing: z
|
|
71
|
+
.boolean()
|
|
72
|
+
.default(DEFAULT_CONFIG.notifyWhenRtkMissing)
|
|
73
|
+
.description('Tell each session once that command rewriting is off because rtk is not installed.'),
|
|
74
|
+
rtkExecutable: z.string().default(DEFAULT_CONFIG.rtkExecutable).description('Executable name or path for rtk.'),
|
|
75
|
+
rewriteTimeoutMs: z.natural().default(DEFAULT_CONFIG.rewriteTimeoutMs).description('Deadline in milliseconds for one `rtk rewrite` call.'),
|
|
76
|
+
compactedTools: z
|
|
77
|
+
.array(z.string())
|
|
78
|
+
.default([...DEFAULT_CONFIG.compactedTools])
|
|
79
|
+
.description('Tool names whose text results pass through the compaction pipeline.'),
|
|
80
|
+
outputCompaction: z
|
|
81
|
+
.object({
|
|
82
|
+
enabled: z.boolean().default(true),
|
|
83
|
+
stripAnsi: z.boolean().default(true),
|
|
84
|
+
readCompaction: z.object({ enabled: z.boolean().default(false) }),
|
|
85
|
+
sourceCodeFilteringEnabled: z.boolean().default(false),
|
|
86
|
+
preserveExactSkillReads: z.boolean().default(false),
|
|
87
|
+
sourceCodeFiltering: z
|
|
88
|
+
.union([z.const('none'), z.const('minimal'), z.const('aggressive')])
|
|
89
|
+
.default(DEFAULT_CONFIG.outputCompaction.sourceCodeFiltering),
|
|
90
|
+
aggregateTestOutput: z.boolean().default(true),
|
|
91
|
+
filterBuildOutput: z.boolean().default(true),
|
|
92
|
+
compactGitOutput: z.boolean().default(true),
|
|
93
|
+
aggregateLinterOutput: z.boolean().default(true),
|
|
94
|
+
groupSearchOutput: z.boolean().default(true),
|
|
95
|
+
trackSavings: z.boolean().default(true),
|
|
96
|
+
deferToHarnessSpill: z.boolean().default(true),
|
|
97
|
+
smartTruncate: z.object({
|
|
98
|
+
enabled: z.boolean().default(false),
|
|
99
|
+
maxLines: z.natural().default(DEFAULT_CONFIG.outputCompaction.smartTruncate.maxLines),
|
|
100
|
+
}),
|
|
101
|
+
truncate: z.object({
|
|
102
|
+
enabled: z.boolean().default(true),
|
|
103
|
+
maxChars: z.natural().default(DEFAULT_CONFIG.outputCompaction.truncate.maxChars),
|
|
104
|
+
}),
|
|
105
|
+
})
|
|
106
|
+
.default(DEFAULT_CONFIG.outputCompaction),
|
|
107
|
+
});
|
|
108
|
+
function asRecord(value) {
|
|
109
|
+
return typeof value === 'object' && value !== null ? value : {};
|
|
110
|
+
}
|
|
111
|
+
function pickBoolean(value, fallback) {
|
|
112
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
113
|
+
}
|
|
114
|
+
function pickNumber(value, fallback, min, max) {
|
|
115
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
116
|
+
return fallback;
|
|
117
|
+
return Math.min(max, Math.max(min, Math.floor(value)));
|
|
118
|
+
}
|
|
119
|
+
function pickString(value, fallback) {
|
|
120
|
+
return typeof value === 'string' && value.trim() ? value : fallback;
|
|
121
|
+
}
|
|
122
|
+
function pickStringList(value, fallback) {
|
|
123
|
+
if (!Array.isArray(value))
|
|
124
|
+
return [...fallback];
|
|
125
|
+
const names = value.filter((entry) => typeof entry === 'string' && entry.trim().length > 0);
|
|
126
|
+
return names.length > 0 ? names : [...fallback];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Normalize arbitrary configuration into a complete {@link RtkConfig}.
|
|
130
|
+
*
|
|
131
|
+
* The loader already validates the composition's `config:` block, but this
|
|
132
|
+
* entry is also reachable from tests, from `apply()` called directly, and from
|
|
133
|
+
* a runtime patch, so every field is re-derived rather than trusted. Numbers
|
|
134
|
+
* are clamped to {@link BOUNDS} so a hand-edited value cannot disable the
|
|
135
|
+
* pipeline's safeguards by accident.
|
|
136
|
+
*/
|
|
137
|
+
export function normalizeConfig(raw) {
|
|
138
|
+
const root = asRecord(raw);
|
|
139
|
+
const compaction = asRecord(root.outputCompaction);
|
|
140
|
+
const readCompaction = asRecord(compaction.readCompaction);
|
|
141
|
+
const smartTruncate = asRecord(compaction.smartTruncate);
|
|
142
|
+
const truncate = asRecord(compaction.truncate);
|
|
143
|
+
const mode = root.mode === 'suggest' ? 'suggest' : 'rewrite';
|
|
144
|
+
const filtering = SOURCE_CODE_FILTERING_LEVELS.includes(compaction.sourceCodeFiltering)
|
|
145
|
+
? compaction.sourceCodeFiltering
|
|
146
|
+
: DEFAULT_CONFIG.outputCompaction.sourceCodeFiltering;
|
|
147
|
+
return {
|
|
148
|
+
enabled: pickBoolean(root.enabled, DEFAULT_CONFIG.enabled),
|
|
149
|
+
mode,
|
|
150
|
+
guardWhenRtkMissing: pickBoolean(root.guardWhenRtkMissing, DEFAULT_CONFIG.guardWhenRtkMissing),
|
|
151
|
+
showRewriteNotifications: pickBoolean(root.showRewriteNotifications, DEFAULT_CONFIG.showRewriteNotifications),
|
|
152
|
+
notifyWhenRtkMissing: pickBoolean(root.notifyWhenRtkMissing, DEFAULT_CONFIG.notifyWhenRtkMissing),
|
|
153
|
+
rtkExecutable: pickString(root.rtkExecutable, DEFAULT_CONFIG.rtkExecutable),
|
|
154
|
+
rewriteTimeoutMs: pickNumber(root.rewriteTimeoutMs, DEFAULT_CONFIG.rewriteTimeoutMs, 100, 60000),
|
|
155
|
+
compactedTools: pickStringList(root.compactedTools, DEFAULT_CONFIG.compactedTools),
|
|
156
|
+
outputCompaction: {
|
|
157
|
+
enabled: pickBoolean(compaction.enabled, DEFAULT_CONFIG.outputCompaction.enabled),
|
|
158
|
+
stripAnsi: pickBoolean(compaction.stripAnsi, DEFAULT_CONFIG.outputCompaction.stripAnsi),
|
|
159
|
+
readCompaction: {
|
|
160
|
+
enabled: pickBoolean(readCompaction.enabled, DEFAULT_CONFIG.outputCompaction.readCompaction.enabled),
|
|
161
|
+
},
|
|
162
|
+
sourceCodeFilteringEnabled: pickBoolean(compaction.sourceCodeFilteringEnabled, DEFAULT_CONFIG.outputCompaction.sourceCodeFilteringEnabled),
|
|
163
|
+
preserveExactSkillReads: pickBoolean(compaction.preserveExactSkillReads, DEFAULT_CONFIG.outputCompaction.preserveExactSkillReads),
|
|
164
|
+
sourceCodeFiltering: filtering,
|
|
165
|
+
aggregateTestOutput: pickBoolean(compaction.aggregateTestOutput, DEFAULT_CONFIG.outputCompaction.aggregateTestOutput),
|
|
166
|
+
filterBuildOutput: pickBoolean(compaction.filterBuildOutput, DEFAULT_CONFIG.outputCompaction.filterBuildOutput),
|
|
167
|
+
compactGitOutput: pickBoolean(compaction.compactGitOutput, DEFAULT_CONFIG.outputCompaction.compactGitOutput),
|
|
168
|
+
aggregateLinterOutput: pickBoolean(compaction.aggregateLinterOutput, DEFAULT_CONFIG.outputCompaction.aggregateLinterOutput),
|
|
169
|
+
groupSearchOutput: pickBoolean(compaction.groupSearchOutput, DEFAULT_CONFIG.outputCompaction.groupSearchOutput),
|
|
170
|
+
trackSavings: pickBoolean(compaction.trackSavings, DEFAULT_CONFIG.outputCompaction.trackSavings),
|
|
171
|
+
deferToHarnessSpill: pickBoolean(compaction.deferToHarnessSpill, DEFAULT_CONFIG.outputCompaction.deferToHarnessSpill),
|
|
172
|
+
smartTruncate: {
|
|
173
|
+
enabled: pickBoolean(smartTruncate.enabled, DEFAULT_CONFIG.outputCompaction.smartTruncate.enabled),
|
|
174
|
+
maxLines: pickNumber(smartTruncate.maxLines, DEFAULT_CONFIG.outputCompaction.smartTruncate.maxLines, BOUNDS.maxLines.min, BOUNDS.maxLines.max),
|
|
175
|
+
},
|
|
176
|
+
truncate: {
|
|
177
|
+
enabled: pickBoolean(truncate.enabled, DEFAULT_CONFIG.outputCompaction.truncate.enabled),
|
|
178
|
+
maxChars: pickNumber(truncate.maxChars, DEFAULT_CONFIG.outputCompaction.truncate.maxChars, BOUNDS.maxChars.min, BOUNDS.maxChars.max),
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAsExC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,cAAc,GAAc;IACvC,OAAO,EAAE,IAAI;IACb,IAAI,EAAE,SAAS;IACf,mBAAmB,EAAE,IAAI;IACzB,yEAAyE;IACzE,6EAA6E;IAC7E,wEAAwE;IACxE,uEAAuE;IACvE,wBAAwB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-ai/cordis';
|
|
2
|
+
import { Config, type RtkConfig } from './config.js';
|
|
3
|
+
import { READ_COMPACTION_BANNER_PREFIX } from './compact/index.js';
|
|
4
|
+
/** Cordis plugin name used by loader diagnostics. */
|
|
5
|
+
export declare const name = "rtk";
|
|
6
|
+
/**
|
|
7
|
+
* The tool runtime is a hard dependency: both halves of this plugin are
|
|
8
|
+
* `tools/*` listeners, and without the registry there is nothing to rewrite or
|
|
9
|
+
* compact.
|
|
10
|
+
*
|
|
11
|
+
* `settings` is declared too, and not because the plugin cannot run without it
|
|
12
|
+
* — it can, entirely from the composition's `config:` block. It is declared
|
|
13
|
+
* because the provider registers *asynchronously*: it reads the settings
|
|
14
|
+
* document first, so a plain `ctx.get('settings')` during `apply` can find
|
|
15
|
+
* nothing and the namespace silently never registers. Observed exactly that in
|
|
16
|
+
* production (`/rtk` reported "settings service unavailable" while a sibling
|
|
17
|
+
* `ctx.get('spillStore')` succeeded). Declaring it makes Cordis park this
|
|
18
|
+
* plugin until the provider appears, then activate it.
|
|
19
|
+
*
|
|
20
|
+
* `commands` and `systemPrompt` stay optional `ctx.get` lookups: they are
|
|
21
|
+
* registered early enough to be present, and a composition without them should
|
|
22
|
+
* still get the optimization.
|
|
23
|
+
*/
|
|
24
|
+
export declare const inject: string[];
|
|
25
|
+
export { Config };
|
|
26
|
+
/**
|
|
27
|
+
* Register RTK command rewriting and tool-output compaction.
|
|
28
|
+
*
|
|
29
|
+
* Both halves hang off the tool pipeline rather than wrapping a tool:
|
|
30
|
+
*
|
|
31
|
+
* - **Rewriting** rides `tools/execute`. The harness deliberately keeps
|
|
32
|
+
* `tools/pre-execute` from mutating arguments (they are logged and presented
|
|
33
|
+
* before dispatch), so the around-dispatch stage is the only seam where the
|
|
34
|
+
* command that actually runs can differ from the one that was recorded. The
|
|
35
|
+
* replacement is scoped to the call: the original arguments are restored as
|
|
36
|
+
* soon as dispatch returns, so later pipeline stages and the session log see
|
|
37
|
+
* what the model asked for.
|
|
38
|
+
* - **Compaction** rides `tools/post-execute`, which is the stage that may
|
|
39
|
+
* replace result content.
|
|
40
|
+
*
|
|
41
|
+
* @param ctx - the agent-scoped context this row was mounted into.
|
|
42
|
+
* @param rawConfig - the row's `config:` block, already schema-validated.
|
|
43
|
+
*/
|
|
44
|
+
export declare function apply(ctx: Context, rawConfig: RtkConfig): void;
|
|
45
|
+
export { READ_COMPACTION_BANNER_PREFIX };
|
|
46
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD,OAAO,EAAE,MAAM,EAAmB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAA;AACrE,OAAO,EAAE,6BAA6B,EAAqB,MAAM,oBAAoB,CAAA;AAQrF,qDAAqD;AACrD,eAAO,MAAM,IAAI,QAAQ,CAAA;AAEzB;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,MAAM,UAAwB,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,CAAA;AAwCjB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CA4S9D;AA8BD,OAAO,EAAE,6BAA6B,EAAE,CAAA"}
|