dsh-plugin-trim 0.0.0-stage → 0.2.4
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/LICENSE +21 -0
- package/README.md +108 -2
- package/client.js +1540 -0
- package/cordis.patch.yml +4 -0
- package/dist/index.d.ts +663 -0
- package/dist/index.js +4676 -0
- package/icon.png +0 -0
- package/package.json +102 -4
package/cordis.patch.yml
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
/** Deployment configuration for the trim plugin. */
|
|
4
|
+
export interface Config {
|
|
5
|
+
/** `advise` keeps every suggestion advisory; `auto-safe` only narrows the suggestion set. */
|
|
6
|
+
mode: 'advise' | 'auto-safe';
|
|
7
|
+
/** Extra package names or entry ids that must never be suggested for disable. */
|
|
8
|
+
protect: string[];
|
|
9
|
+
/** Packages the user explicitly pinned; never suggested for disable. */
|
|
10
|
+
pinned: string[];
|
|
11
|
+
/** Observe `tools/result` and keep a local tool-name usage ledger. */
|
|
12
|
+
trackUsage: boolean;
|
|
13
|
+
/** Usage retention window in days. */
|
|
14
|
+
usageRetentionDays: number;
|
|
15
|
+
/** Maximum retained slim-profile drafts and snapshots. */
|
|
16
|
+
maxDrafts: number;
|
|
17
|
+
/** Include cross-plugin prompt-section dedupe suggestions. */
|
|
18
|
+
enableDedupe: boolean;
|
|
19
|
+
/** Persist a short dedupe excerpt locally; off by default. */
|
|
20
|
+
persistExcerpts: boolean;
|
|
21
|
+
/** Non-CJK characters per token used for cost estimates. */
|
|
22
|
+
tokenRatio: number;
|
|
23
|
+
/** Extra tool name to owning package mapping. */
|
|
24
|
+
toolOwners: Record<string, string>;
|
|
25
|
+
/** Enable compatibility analysis. */
|
|
26
|
+
compatEnabled: boolean;
|
|
27
|
+
/** Scan other profiles under $DSH_HOME/profiles. */
|
|
28
|
+
compatScanAllProfiles: boolean;
|
|
29
|
+
/** Maximum profiles to scan. */
|
|
30
|
+
compatMaxProfiles: number;
|
|
31
|
+
/** Include info findings in the Markdown report (JSON always keeps them). */
|
|
32
|
+
compatIncludeInfo: boolean;
|
|
33
|
+
/** Maximum findings in one report. */
|
|
34
|
+
compatMaxFindings: number;
|
|
35
|
+
/** Parse pnpm-lock.yaml for duplicate package versions. */
|
|
36
|
+
compatReadLockfile: boolean;
|
|
37
|
+
/** Read workspace AGENTS.md/CLAUDE.md and compare with plugin prompt rules. */
|
|
38
|
+
compatReadWorkspace: boolean;
|
|
39
|
+
/** Report conflicts between official bundles' intentional row overrides. */
|
|
40
|
+
compatStrictOfficialOverrides: boolean;
|
|
41
|
+
/** In-memory compatibility report cache TTL. */
|
|
42
|
+
compatCacheTtlMs: number;
|
|
43
|
+
}
|
|
44
|
+
/** Schemastery configuration for the trim plugin. */
|
|
45
|
+
export declare const Config: z<Config>;
|
|
46
|
+
/** Installed plugin forms supported by DSH scaffolds. */
|
|
47
|
+
type PluginForm = 'pure' | 'bundle' | 'bundle-client';
|
|
48
|
+
/** Coarse task classification used by the trim scorer. */
|
|
49
|
+
type TaskTag = 'bugfix' | 'feature' | 'review' | 'docs' | 'release' | 'report' | 'research' | 'unknown';
|
|
50
|
+
/** Hard compatibility status derived from pluginManager/app-boot signals. */
|
|
51
|
+
type GuardStatus = 'ok' | 'warn' | 'incompatible' | 'protected' | 'unknown';
|
|
52
|
+
/** One explainable reason behind a suggestion. */
|
|
53
|
+
interface Evidence {
|
|
54
|
+
kind: 'task-match' | 'usage' | 'overlap' | 'cost' | 'guard' | 'user-pref' | 'context' | 'compat';
|
|
55
|
+
summary: string;
|
|
56
|
+
weight: number;
|
|
57
|
+
}
|
|
58
|
+
/** Detected task plus the evidence that produced it. */
|
|
59
|
+
interface TaskProfile {
|
|
60
|
+
tag: TaskTag;
|
|
61
|
+
confidence: number;
|
|
62
|
+
keywords: string[];
|
|
63
|
+
evidence: Evidence[];
|
|
64
|
+
source: 'explicit' | 'session' | 'goal' | 'heuristic' | 'unknown';
|
|
65
|
+
}
|
|
66
|
+
/** Usage aggregate for one plugin or tool owner. */
|
|
67
|
+
interface UsageStats {
|
|
68
|
+
calls: number;
|
|
69
|
+
successes: number;
|
|
70
|
+
lastUsedAt?: string;
|
|
71
|
+
sessionCalls: number;
|
|
72
|
+
}
|
|
73
|
+
/** A normalized bundle view used by scan/scoring. */
|
|
74
|
+
interface BundleProfile {
|
|
75
|
+
name: string;
|
|
76
|
+
version?: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
installed: boolean;
|
|
80
|
+
availability: string;
|
|
81
|
+
official: boolean;
|
|
82
|
+
optional: boolean;
|
|
83
|
+
removable: boolean;
|
|
84
|
+
readOnlyReason?: string;
|
|
85
|
+
guardStatus: GuardStatus;
|
|
86
|
+
rowModuleNames: string[];
|
|
87
|
+
contextTokens: number;
|
|
88
|
+
usage: UsageStats;
|
|
89
|
+
protected: boolean;
|
|
90
|
+
findings: CompatFinding[];
|
|
91
|
+
}
|
|
92
|
+
/** A normalized Loader entry view used by scan/scoring. */
|
|
93
|
+
interface PluginProfile {
|
|
94
|
+
entryId: string;
|
|
95
|
+
moduleName: string;
|
|
96
|
+
bundleName?: string;
|
|
97
|
+
enabled: boolean;
|
|
98
|
+
fiberPhase: string | null;
|
|
99
|
+
diagnostic?: string;
|
|
100
|
+
patchId?: string;
|
|
101
|
+
readOnlyReason?: string;
|
|
102
|
+
guardStatus: GuardStatus;
|
|
103
|
+
contextTokens: number;
|
|
104
|
+
usage: UsageStats;
|
|
105
|
+
protected: boolean;
|
|
106
|
+
findings: CompatFinding[];
|
|
107
|
+
}
|
|
108
|
+
/** A duplicate-context group found in assembled prompt sections. */
|
|
109
|
+
interface DedupeGroup {
|
|
110
|
+
fingerprint: string;
|
|
111
|
+
members: DedupeMember[];
|
|
112
|
+
authority: string;
|
|
113
|
+
conflict: boolean;
|
|
114
|
+
reason: string;
|
|
115
|
+
excerpt?: string;
|
|
116
|
+
}
|
|
117
|
+
interface DedupeMember {
|
|
118
|
+
section: string;
|
|
119
|
+
owner?: string;
|
|
120
|
+
textLength: number;
|
|
121
|
+
}
|
|
122
|
+
/** One suggestion item in a slim profile draft. */
|
|
123
|
+
interface SlimItem {
|
|
124
|
+
/** `bundle:<name>` or `entry:<entryId>` */
|
|
125
|
+
id: string;
|
|
126
|
+
kind: 'bundle' | 'entry';
|
|
127
|
+
name: string;
|
|
128
|
+
bundleName?: string;
|
|
129
|
+
action: 'keep' | 'enable' | 'suggest-disable' | 'disable-if-unused' | 'review';
|
|
130
|
+
risk: 'low' | 'medium' | 'high';
|
|
131
|
+
score: number;
|
|
132
|
+
evidence: Evidence[];
|
|
133
|
+
observedEnabled: boolean;
|
|
134
|
+
protected: boolean;
|
|
135
|
+
reason: string;
|
|
136
|
+
findings: CompatFinding[];
|
|
137
|
+
}
|
|
138
|
+
/** A local, reversible plugin-enablement plan. Not a DSH profile directory. */
|
|
139
|
+
interface SlimProfile {
|
|
140
|
+
schemaVersion: 1;
|
|
141
|
+
id: string;
|
|
142
|
+
createdAt: string;
|
|
143
|
+
task: TaskProfile;
|
|
144
|
+
mode: 'advise' | 'auto-safe';
|
|
145
|
+
items: SlimItem[];
|
|
146
|
+
dedupe: DedupeGroup[];
|
|
147
|
+
summary: {
|
|
148
|
+
keep: number;
|
|
149
|
+
enable: number;
|
|
150
|
+
disable: number;
|
|
151
|
+
review: number;
|
|
152
|
+
protected: number;
|
|
153
|
+
};
|
|
154
|
+
status: 'draft' | 'applied' | 'partial' | 'rolled-back';
|
|
155
|
+
}
|
|
156
|
+
interface ApplyItemResult {
|
|
157
|
+
id: string;
|
|
158
|
+
kind: 'bundle' | 'entry';
|
|
159
|
+
name: string;
|
|
160
|
+
status: 'applied' | 'applied-pending-restart' | 'skipped' | 'failed' | 'stale' | 'blocked-by-compat';
|
|
161
|
+
application?: string;
|
|
162
|
+
error?: string;
|
|
163
|
+
fixKind?: 'conflict' | 'workaround';
|
|
164
|
+
}
|
|
165
|
+
interface ApplyResult {
|
|
166
|
+
profileId: string;
|
|
167
|
+
token?: string;
|
|
168
|
+
items: ApplyItemResult[];
|
|
169
|
+
rolledBack?: boolean;
|
|
170
|
+
restartRequired?: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface RollbackItemResult {
|
|
173
|
+
id: string;
|
|
174
|
+
kind: 'bundle' | 'entry';
|
|
175
|
+
name: string;
|
|
176
|
+
status: 'restored' | 'already-restored' | 'skipped' | 'externally-changed' | 'failed';
|
|
177
|
+
error?: string;
|
|
178
|
+
}
|
|
179
|
+
interface RollbackResult {
|
|
180
|
+
token: string;
|
|
181
|
+
items: RollbackItemResult[];
|
|
182
|
+
}
|
|
183
|
+
/** Compatibility analysis domain. */
|
|
184
|
+
type CompatDomain = 'plugin-plugin' | 'plugin-runtime' | 'profile' | 'workspace';
|
|
185
|
+
/** Compatibility severity. */
|
|
186
|
+
type CompatSeverity = 'error' | 'warn' | 'info';
|
|
187
|
+
interface CompatEvidence {
|
|
188
|
+
source: 'manifest' | 'loader' | 'plugin-manager' | 'prompt' | 'profile-file' | 'lockfile' | 'runtime';
|
|
189
|
+
summary: string;
|
|
190
|
+
ref?: string;
|
|
191
|
+
}
|
|
192
|
+
interface CompatFix {
|
|
193
|
+
kind: 'disable' | 'enable' | 'update' | 'exemption' | 'reorder' | 'edit-patch' | 'rename' | 'none';
|
|
194
|
+
summary: string;
|
|
195
|
+
safe: boolean;
|
|
196
|
+
target?: string;
|
|
197
|
+
requiresConsent: boolean;
|
|
198
|
+
}
|
|
199
|
+
interface CompatFinding {
|
|
200
|
+
id: string;
|
|
201
|
+
domain: CompatDomain;
|
|
202
|
+
code: string;
|
|
203
|
+
severity: CompatSeverity;
|
|
204
|
+
title: string;
|
|
205
|
+
subjects: string[];
|
|
206
|
+
evidence: CompatEvidence[];
|
|
207
|
+
confidence: 'high' | 'medium' | 'low';
|
|
208
|
+
fix?: CompatFix;
|
|
209
|
+
autoApplicable: boolean;
|
|
210
|
+
}
|
|
211
|
+
interface ProfileCompatSummary {
|
|
212
|
+
name: string;
|
|
213
|
+
dir: string;
|
|
214
|
+
bundles: string[];
|
|
215
|
+
versions: Record<string, string | undefined>;
|
|
216
|
+
exemptions: Record<string, string[]>;
|
|
217
|
+
compatibilityWarnings: string[];
|
|
218
|
+
findings: CompatFinding[];
|
|
219
|
+
}
|
|
220
|
+
interface WorkspaceCompatSummary {
|
|
221
|
+
cwd: string;
|
|
222
|
+
instructionFiles: string[];
|
|
223
|
+
mcpEntries: string[];
|
|
224
|
+
findings: CompatFinding[];
|
|
225
|
+
}
|
|
226
|
+
interface CompatReport {
|
|
227
|
+
schemaVersion: 1;
|
|
228
|
+
generatedAt: string;
|
|
229
|
+
runtime: {
|
|
230
|
+
dshVersion: string;
|
|
231
|
+
nodeVersion: string;
|
|
232
|
+
platform: string;
|
|
233
|
+
arch: string;
|
|
234
|
+
};
|
|
235
|
+
profile: {
|
|
236
|
+
name: string;
|
|
237
|
+
dir: string;
|
|
238
|
+
bundles: string[];
|
|
239
|
+
};
|
|
240
|
+
findings: CompatFinding[];
|
|
241
|
+
summary: {
|
|
242
|
+
error: number;
|
|
243
|
+
warn: number;
|
|
244
|
+
info: number;
|
|
245
|
+
byDomain: Record<CompatDomain, number>;
|
|
246
|
+
};
|
|
247
|
+
profiles: ProfileCompatSummary[];
|
|
248
|
+
workspaces: WorkspaceCompatSummary[];
|
|
249
|
+
diagnostics: string[];
|
|
250
|
+
truncated?: boolean;
|
|
251
|
+
totalFindings?: number;
|
|
252
|
+
}
|
|
253
|
+
/** Minimal structural view of one plugin manifest. */
|
|
254
|
+
interface PluginManifest {
|
|
255
|
+
name?: string;
|
|
256
|
+
version?: string;
|
|
257
|
+
engines?: Record<string, unknown>;
|
|
258
|
+
peerDependencies?: Record<string, string>;
|
|
259
|
+
dependencies?: Record<string, string>;
|
|
260
|
+
dsh?: {
|
|
261
|
+
bundle?: {
|
|
262
|
+
patch?: string | string[];
|
|
263
|
+
platforms?: string[];
|
|
264
|
+
};
|
|
265
|
+
client?: unknown;
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
/** Minimal structural view of the plugin manager service. */
|
|
269
|
+
interface PluginManagerLike {
|
|
270
|
+
listPlugins(): Promise<PluginInfoLike[]>;
|
|
271
|
+
listBundles(): Promise<BundleInfoLike[]>;
|
|
272
|
+
listVersionExemptions(): {
|
|
273
|
+
exemptions: Record<string, string[]>;
|
|
274
|
+
warnings: string[];
|
|
275
|
+
};
|
|
276
|
+
setPluginEnabled?(id: string, enabled: boolean): Promise<ChangeResultLike>;
|
|
277
|
+
setBundleEnabled?(name: string, enabled: boolean): Promise<ChangeResultLike>;
|
|
278
|
+
}
|
|
279
|
+
/** Minimal structural view of a plugin-manager change result. */
|
|
280
|
+
interface ChangeResultLike {
|
|
281
|
+
changed: boolean;
|
|
282
|
+
application: 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
|
|
283
|
+
restartReason?: string;
|
|
284
|
+
error?: {
|
|
285
|
+
code?: string;
|
|
286
|
+
diagnostic?: string;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
interface PluginInfoLike {
|
|
290
|
+
entryId: string;
|
|
291
|
+
moduleName: string;
|
|
292
|
+
enabled: boolean;
|
|
293
|
+
fiberPhase: string | null;
|
|
294
|
+
diagnostic?: string;
|
|
295
|
+
patchId?: string;
|
|
296
|
+
readOnlyReason?: string;
|
|
297
|
+
}
|
|
298
|
+
interface BundleInfoLike {
|
|
299
|
+
name: string;
|
|
300
|
+
version?: string;
|
|
301
|
+
description?: string;
|
|
302
|
+
enabled: boolean;
|
|
303
|
+
installed: boolean;
|
|
304
|
+
availability: string;
|
|
305
|
+
official: boolean;
|
|
306
|
+
optional: boolean;
|
|
307
|
+
removable: boolean;
|
|
308
|
+
readOnlyReason?: string;
|
|
309
|
+
error?: {
|
|
310
|
+
code?: string;
|
|
311
|
+
diagnostic?: string;
|
|
312
|
+
incompatible?: Array<{
|
|
313
|
+
name: string;
|
|
314
|
+
version: string;
|
|
315
|
+
runtimeVersion: string;
|
|
316
|
+
requirements: Record<string, string>;
|
|
317
|
+
}>;
|
|
318
|
+
};
|
|
319
|
+
rows: Array<{
|
|
320
|
+
rowId: string;
|
|
321
|
+
moduleName: string;
|
|
322
|
+
entryId?: string;
|
|
323
|
+
}>;
|
|
324
|
+
overrides: string[];
|
|
325
|
+
}
|
|
326
|
+
/** Minimal structural view of the plugin inventory gateway. */
|
|
327
|
+
interface PluginInventoryLike {
|
|
328
|
+
list(): Promise<PluginInventorySnapshotLike>;
|
|
329
|
+
}
|
|
330
|
+
interface PluginInventorySnapshotLike {
|
|
331
|
+
managementAvailable?: boolean;
|
|
332
|
+
entries: Array<{
|
|
333
|
+
entryId: string;
|
|
334
|
+
moduleName: string;
|
|
335
|
+
enabled: boolean;
|
|
336
|
+
fiberPhase: string | null;
|
|
337
|
+
diagnostic?: string;
|
|
338
|
+
}>;
|
|
339
|
+
agentPresets?: Array<{
|
|
340
|
+
id: string;
|
|
341
|
+
name?: string;
|
|
342
|
+
isDefault: boolean;
|
|
343
|
+
broken?: string;
|
|
344
|
+
rows: Array<{
|
|
345
|
+
entryId: string | null;
|
|
346
|
+
moduleName: string;
|
|
347
|
+
enabled: boolean | 'conditional';
|
|
348
|
+
condition?: string;
|
|
349
|
+
fiberPhase: string | null;
|
|
350
|
+
}>;
|
|
351
|
+
}>;
|
|
352
|
+
}
|
|
353
|
+
/** Minimal structural view of one loader entry. */
|
|
354
|
+
interface LoaderEntryLike {
|
|
355
|
+
id: string;
|
|
356
|
+
options: {
|
|
357
|
+
id: string;
|
|
358
|
+
name: string;
|
|
359
|
+
config?: unknown;
|
|
360
|
+
group?: boolean | null;
|
|
361
|
+
disabled?: boolean | null;
|
|
362
|
+
inject?: unknown;
|
|
363
|
+
};
|
|
364
|
+
disabled: boolean;
|
|
365
|
+
fiber?: {
|
|
366
|
+
state?: number;
|
|
367
|
+
inject?: Record<string, unknown>;
|
|
368
|
+
provisions?: Iterable<{
|
|
369
|
+
name?: string;
|
|
370
|
+
}>;
|
|
371
|
+
};
|
|
372
|
+
moduleNamespace?: unknown;
|
|
373
|
+
}
|
|
374
|
+
/** Minimal structural view of the loader service. */
|
|
375
|
+
interface LoaderLike {
|
|
376
|
+
entries(): Iterable<LoaderEntryLike>;
|
|
377
|
+
}
|
|
378
|
+
/** A prompt assembly subset needed for overlap and cost attribution. */
|
|
379
|
+
interface PromptAssemblyLike {
|
|
380
|
+
sections: Array<{
|
|
381
|
+
name: string;
|
|
382
|
+
text: string;
|
|
383
|
+
}>;
|
|
384
|
+
contexts: Array<{
|
|
385
|
+
name: string;
|
|
386
|
+
text: string;
|
|
387
|
+
}>;
|
|
388
|
+
tools: Array<{
|
|
389
|
+
name: string;
|
|
390
|
+
description?: string;
|
|
391
|
+
parameters?: unknown;
|
|
392
|
+
}>;
|
|
393
|
+
}
|
|
394
|
+
/** A prompt adapter, separate from Cordis so tests can fake it. */
|
|
395
|
+
interface PromptAdapterLike {
|
|
396
|
+
assemble(agent?: unknown, toolSet?: unknown): Promise<PromptAssemblyLike | undefined>;
|
|
397
|
+
}
|
|
398
|
+
/** Runtime facts. */
|
|
399
|
+
interface CompatRuntimeInfo {
|
|
400
|
+
dshVersion: string;
|
|
401
|
+
nodeVersion: string;
|
|
402
|
+
platform: string;
|
|
403
|
+
arch: string;
|
|
404
|
+
}
|
|
405
|
+
/** One normalized loader/preset/MCP row. */
|
|
406
|
+
interface LoaderEntrySnapshot {
|
|
407
|
+
id: string;
|
|
408
|
+
parentId: string | null;
|
|
409
|
+
depth: number;
|
|
410
|
+
moduleName: string;
|
|
411
|
+
pluginName?: string;
|
|
412
|
+
enabled: boolean;
|
|
413
|
+
group: boolean;
|
|
414
|
+
fiberState: 'pending' | 'loading' | 'active' | 'failed' | 'unloading' | null;
|
|
415
|
+
diagnostic?: string;
|
|
416
|
+
provide: string[];
|
|
417
|
+
inject: string[];
|
|
418
|
+
config?: unknown;
|
|
419
|
+
source: 'loader' | 'preset' | 'mcp';
|
|
420
|
+
presetId?: string;
|
|
421
|
+
mcpServerName?: string;
|
|
422
|
+
}
|
|
423
|
+
/** One parsed patch-layer row. */
|
|
424
|
+
interface PatchLayerRow {
|
|
425
|
+
layer: string;
|
|
426
|
+
id: string;
|
|
427
|
+
name?: string;
|
|
428
|
+
disabled?: boolean | JsSentinel;
|
|
429
|
+
config?: unknown;
|
|
430
|
+
sourceFile: string;
|
|
431
|
+
}
|
|
432
|
+
interface JsSentinel {
|
|
433
|
+
__js: string;
|
|
434
|
+
}
|
|
435
|
+
/** Lockfile summary. */
|
|
436
|
+
interface LockfileSummary {
|
|
437
|
+
path: string;
|
|
438
|
+
packageVersions: Record<string, string[]>;
|
|
439
|
+
dshVersions: Record<string, string[]>;
|
|
440
|
+
parseError?: string;
|
|
441
|
+
}
|
|
442
|
+
/** One profile's raw facts. */
|
|
443
|
+
interface ProfileRaw {
|
|
444
|
+
name: string;
|
|
445
|
+
dir: string;
|
|
446
|
+
bundles: string[];
|
|
447
|
+
dependencies: Record<string, string>;
|
|
448
|
+
patchRows: PatchLayerRow[];
|
|
449
|
+
exemptions: Record<string, string[]>;
|
|
450
|
+
compatibilityWarnings: string[];
|
|
451
|
+
compatibilityRewritable: boolean;
|
|
452
|
+
manifestVersions: Record<string, string | undefined>;
|
|
453
|
+
}
|
|
454
|
+
/** Workspace facts. */
|
|
455
|
+
interface WorkspaceRaw {
|
|
456
|
+
cwd: string;
|
|
457
|
+
instructionFiles: string[];
|
|
458
|
+
instructions: Array<{
|
|
459
|
+
file: string;
|
|
460
|
+
text: string;
|
|
461
|
+
}>;
|
|
462
|
+
}
|
|
463
|
+
/** Configuration subset relevant to compatibility analysis. */
|
|
464
|
+
interface CompatConfigLike {
|
|
465
|
+
compatEnabled: boolean;
|
|
466
|
+
compatScanAllProfiles: boolean;
|
|
467
|
+
compatMaxProfiles: number;
|
|
468
|
+
compatIncludeInfo: boolean;
|
|
469
|
+
compatMaxFindings: number;
|
|
470
|
+
compatReadLockfile: boolean;
|
|
471
|
+
compatReadWorkspace: boolean;
|
|
472
|
+
compatStrictOfficialOverrides: boolean;
|
|
473
|
+
compatCacheTtlMs: number;
|
|
474
|
+
toolOwners: Record<string, string>;
|
|
475
|
+
}
|
|
476
|
+
/** Everything the compatibility rules need. */
|
|
477
|
+
interface CompatContext {
|
|
478
|
+
runtime: CompatRuntimeInfo;
|
|
479
|
+
config: CompatConfigLike;
|
|
480
|
+
profile: {
|
|
481
|
+
name: string;
|
|
482
|
+
dir: string;
|
|
483
|
+
bundles: string[];
|
|
484
|
+
dependencies: Record<string, string>;
|
|
485
|
+
patchRows: PatchLayerRow[];
|
|
486
|
+
exemptions: Record<string, string[]>;
|
|
487
|
+
compatibilityWarnings: string[];
|
|
488
|
+
compatibilityRewritable: boolean;
|
|
489
|
+
};
|
|
490
|
+
loaderEntries: LoaderEntrySnapshot[];
|
|
491
|
+
bundles: BundleInfoLike[];
|
|
492
|
+
entriesInfo: PluginInfoLike[];
|
|
493
|
+
inventory?: PluginInventorySnapshotLike;
|
|
494
|
+
manifests: Map<string, PluginManifest | undefined>;
|
|
495
|
+
lockfile?: LockfileSummary;
|
|
496
|
+
profiles: ProfileRaw[];
|
|
497
|
+
workspace: WorkspaceRaw;
|
|
498
|
+
prompt?: PromptAssemblyLike;
|
|
499
|
+
diagnostics: string[];
|
|
500
|
+
}
|
|
501
|
+
/** Result of one analysis plus the report. */
|
|
502
|
+
interface CompatAnalysisResult {
|
|
503
|
+
report: CompatReport;
|
|
504
|
+
findings: CompatFinding[];
|
|
505
|
+
context: CompatContext;
|
|
506
|
+
markdown: string;
|
|
507
|
+
reportPath?: string;
|
|
508
|
+
}
|
|
509
|
+
interface UsageLedgerOptions {
|
|
510
|
+
path?: string;
|
|
511
|
+
retentionDays?: number;
|
|
512
|
+
maxBytes?: number;
|
|
513
|
+
enabled?: boolean;
|
|
514
|
+
}
|
|
515
|
+
/** Append-only local usage ledger. Records tool names, success, and time only. */
|
|
516
|
+
declare class UsageLedger {
|
|
517
|
+
readonly path: string;
|
|
518
|
+
private readonly retentionDays;
|
|
519
|
+
private readonly maxBytes;
|
|
520
|
+
private readonly enabled;
|
|
521
|
+
private buffer;
|
|
522
|
+
private timer;
|
|
523
|
+
private flushPromise;
|
|
524
|
+
constructor(options?: UsageLedgerOptions);
|
|
525
|
+
record(toolName: string, ok: boolean): void;
|
|
526
|
+
flush(): Promise<void>;
|
|
527
|
+
dispose(): Promise<void>;
|
|
528
|
+
/** Aggregate retained lines by tool name. */
|
|
529
|
+
aggregate(): Promise<Map<string, UsageStats>>;
|
|
530
|
+
/** Add current-session tool calls to an aggregate without pretending to know success. */
|
|
531
|
+
addSessionUsage(aggregate: Map<string, UsageStats>, toolNames: readonly string[]): Map<string, UsageStats>;
|
|
532
|
+
private compactIfNeeded;
|
|
533
|
+
}
|
|
534
|
+
interface SectionCost {
|
|
535
|
+
name: string;
|
|
536
|
+
owner?: string;
|
|
537
|
+
tokens: number;
|
|
538
|
+
chars: number;
|
|
539
|
+
source: 'section' | 'context';
|
|
540
|
+
}
|
|
541
|
+
interface ToolCost {
|
|
542
|
+
name: string;
|
|
543
|
+
owner?: string;
|
|
544
|
+
tokens: number;
|
|
545
|
+
}
|
|
546
|
+
interface ScanResult {
|
|
547
|
+
managementAvailable: boolean;
|
|
548
|
+
compat: {
|
|
549
|
+
summary: CompatAnalysisResult['report']['summary'];
|
|
550
|
+
topFindings: CompatAnalysisResult['findings'];
|
|
551
|
+
reportPath?: string;
|
|
552
|
+
};
|
|
553
|
+
bundles: BundleProfile[];
|
|
554
|
+
entries: PluginProfile[];
|
|
555
|
+
context: {
|
|
556
|
+
totalTokens: number;
|
|
557
|
+
byOwner: Record<string, number>;
|
|
558
|
+
sections: SectionCost[];
|
|
559
|
+
tools: ToolCost[];
|
|
560
|
+
unattributedTokens: number;
|
|
561
|
+
};
|
|
562
|
+
presetModules: string[];
|
|
563
|
+
usage: {
|
|
564
|
+
byTool: Record<string, UsageStats>;
|
|
565
|
+
byOwner: Record<string, UsageStats>;
|
|
566
|
+
};
|
|
567
|
+
dedupe: DedupeGroup[];
|
|
568
|
+
diagnostics: string[];
|
|
569
|
+
}
|
|
570
|
+
interface ScanOptions {
|
|
571
|
+
config: Config;
|
|
572
|
+
compat: CompatAnalysisResult;
|
|
573
|
+
pluginManager?: PluginManagerLike;
|
|
574
|
+
inventory?: PluginInventorySnapshotLike;
|
|
575
|
+
usageLedger?: UsageLedger;
|
|
576
|
+
task?: TaskProfile;
|
|
577
|
+
sessionToolNames?: string[];
|
|
578
|
+
agent?: unknown;
|
|
579
|
+
}
|
|
580
|
+
/** Normalize plugin metadata, prompt costs, usage, and compat findings into one scan result. */
|
|
581
|
+
export declare function scanPlugins(options: ScanOptions): Promise<ScanResult>;
|
|
582
|
+
interface TaskInput {
|
|
583
|
+
explicit?: TaskTag;
|
|
584
|
+
goal?: string;
|
|
585
|
+
agent?: unknown;
|
|
586
|
+
messages?: Array<{
|
|
587
|
+
role: string;
|
|
588
|
+
content: unknown;
|
|
589
|
+
}>;
|
|
590
|
+
toolNames?: string[];
|
|
591
|
+
}
|
|
592
|
+
/** Detect the current task with explainable keyword/tool evidence. */
|
|
593
|
+
export declare function detectTask(input: TaskInput): TaskProfile;
|
|
594
|
+
interface DraftOptions {
|
|
595
|
+
includeReview?: boolean;
|
|
596
|
+
maxDisable?: number;
|
|
597
|
+
mode?: Config['mode'];
|
|
598
|
+
}
|
|
599
|
+
/** Build a local, reversible slim-profile draft. Does not change plugin state. */
|
|
600
|
+
export declare function buildSlimProfile(scan: ScanResult, task: TaskProfile, config: Config, options?: DraftOptions): SlimProfile;
|
|
601
|
+
interface ApplyOptions {
|
|
602
|
+
confirm: boolean;
|
|
603
|
+
items?: string[];
|
|
604
|
+
manager: PluginManagerLike;
|
|
605
|
+
maxDrafts: number;
|
|
606
|
+
findings?: readonly CompatFinding[];
|
|
607
|
+
profileName?: string;
|
|
608
|
+
}
|
|
609
|
+
/** Apply low-risk items from a saved draft, with a crash-safe snapshot and automatic rollback. */
|
|
610
|
+
export declare function applySlimProfile(profileId: string, options: ApplyOptions): Promise<ApplyResult>;
|
|
611
|
+
interface RollbackOptions {
|
|
612
|
+
token?: string;
|
|
613
|
+
manager: PluginManagerLike;
|
|
614
|
+
maxDrafts: number;
|
|
615
|
+
profileName?: string;
|
|
616
|
+
}
|
|
617
|
+
/** Restore a previous apply snapshot, skipping state changed outside trim. */
|
|
618
|
+
export declare function rollbackSlimProfile(options: RollbackOptions): Promise<RollbackResult>;
|
|
619
|
+
type CompatScope = 'current' | 'profiles' | 'all';
|
|
620
|
+
interface AnalyzeOptions {
|
|
621
|
+
scope?: CompatScope;
|
|
622
|
+
includeInfo?: boolean;
|
|
623
|
+
maxFindings?: number;
|
|
624
|
+
writeReport?: boolean;
|
|
625
|
+
force?: boolean;
|
|
626
|
+
agent?: unknown;
|
|
627
|
+
toolSet?: unknown;
|
|
628
|
+
}
|
|
629
|
+
/** Collect, analyze, render, and optionally persist a compatibility report. */
|
|
630
|
+
export declare function analyzeCompatibility(ctx: Context, config: CompatConfigLike, options?: AnalyzeOptions): Promise<CompatAnalysisResult>;
|
|
631
|
+
interface ReportOptions {
|
|
632
|
+
includeInfo: boolean;
|
|
633
|
+
maxFindings: number;
|
|
634
|
+
}
|
|
635
|
+
/** Run every compatibility rule against one collected context. */
|
|
636
|
+
export declare function runCompatibilityRules(context: CompatContext): Promise<CompatFinding[]>;
|
|
637
|
+
/** Build the serializable report. */
|
|
638
|
+
export declare function buildReport(context: CompatContext, findings: readonly CompatFinding[], options: ReportOptions): CompatReport;
|
|
639
|
+
/** Render a bounded Markdown matrix plus detailed findings. */
|
|
640
|
+
export declare function renderReport(report: CompatReport, options: ReportOptions): string;
|
|
641
|
+
interface CollectCompatOptions {
|
|
642
|
+
profileName: string;
|
|
643
|
+
profileDir: string;
|
|
644
|
+
dshHome: string;
|
|
645
|
+
cwd: string;
|
|
646
|
+
bundleNames?: readonly string[];
|
|
647
|
+
dependencies?: Record<string, string>;
|
|
648
|
+
loader?: LoaderLike;
|
|
649
|
+
pluginManager?: PluginManagerLike;
|
|
650
|
+
inventory?: PluginInventoryLike;
|
|
651
|
+
prompt?: PromptAdapterLike;
|
|
652
|
+
agent?: unknown;
|
|
653
|
+
toolSet?: unknown;
|
|
654
|
+
config: CompatConfigLike;
|
|
655
|
+
runtime?: Partial<CompatRuntimeInfo>;
|
|
656
|
+
}
|
|
657
|
+
/** Collect loader, plugin-manager, prompt, profile, lockfile, and workspace facts. */
|
|
658
|
+
export declare function collectCompatContext(options: CollectCompatOptions): Promise<CompatContext>;
|
|
659
|
+
export declare const name = "dsh-plugin-trim";
|
|
660
|
+
export declare const inject: string[];
|
|
661
|
+
/** Register trim tools and the local usage observer. */
|
|
662
|
+
export declare function apply(ctx: Context, config?: Partial<Config>): void;
|
|
663
|
+
export type { BundleInfoLike, ChangeResultLike, CompatAnalysisResult, CompatConfigLike, CompatContext, CompatRuntimeInfo, Config as TrimConfig, JsSentinel, LoaderEntryLike, LoaderEntrySnapshot, LoaderLike, LockfileSummary, PatchLayerRow, PluginForm, PluginInfoLike, PluginInventoryLike, PluginInventorySnapshotLike, PluginManagerLike, PluginManifest, ProfileRaw, PromptAdapterLike, PromptAssemblyLike, WorkspaceRaw };
|