dsh-github-copilot 0.4.0-alpha.129 → 0.4.0-alpha.132
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/AGENTS.md +3 -1
- package/CHANGELOG.md +17 -0
- package/README.md +37 -45
- package/README.zh.md +33 -40
- package/deployment-baseline.json +16 -1
- package/docs/images/copilot-accounts-credits.png +0 -0
- package/docs/images/copilot-accounts.png +0 -0
- package/docs/images/copilot-current-provenance.json +36 -0
- package/docs/images/copilot-model-preferences.png +0 -0
- package/docs/images/copilot-search-routing.png +0 -0
- package/docs/model-compatibility-acceptance.md +2 -0
- package/docs/official-first-020-rc2.md +1 -0
- package/docs/plugin-diagnostics.md +64 -0
- package/docs/session-search-routing.md +1 -1
- package/docs/single-route-migration.md +5 -4
- package/lib/client.js +1 -1
- package/lib/diagnostics-analysis-io.js +78 -0
- package/lib/diagnostics-analysis.js +425 -0
- package/lib/diagnostics-types-FVf6zjob.js +182 -0
- package/lib/index.js +10 -2
- package/lib/manual-compaction-recovery.js +2 -1
- package/lib/request-budget-DLY_aRq0.js +87 -0
- package/lib/types/account-model-catalog.d.ts +7 -0
- package/lib/types/diagnostics-analysis-io.d.ts +23 -0
- package/lib/types/diagnostics-analysis.d.ts +295 -0
- package/lib/types/preview-provider.d.ts +1 -0
- package/package.json +3 -1
- package/scripts/analyze-diagnostics.mjs +91 -0
- package/lib/request-budget-Cui2hCi1.js +0 -268
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DiagnosticsSnapshot, DiagnosticsView } from './diagnostics-types.ts';
|
|
3
|
+
export declare const DiagnosticsAnalysisReportSchema: z.ZodObject<{
|
|
4
|
+
reportVersion: z.ZodLiteral<1>;
|
|
5
|
+
coverageVersion: z.ZodLiteral<1>;
|
|
6
|
+
interpretation: z.ZodLiteral<"descriptive-observations-only">;
|
|
7
|
+
source: z.ZodEnum<{
|
|
8
|
+
"reviewed-view": "reviewed-view";
|
|
9
|
+
"persisted-snapshot": "persisted-snapshot";
|
|
10
|
+
}>;
|
|
11
|
+
observedAt: z.ZodNumber;
|
|
12
|
+
snapshotAt: z.ZodNumber;
|
|
13
|
+
ageMs: z.ZodNullable<z.ZodNumber>;
|
|
14
|
+
epoch: z.ZodNumber;
|
|
15
|
+
coverageComplete: z.ZodLiteral<false>;
|
|
16
|
+
effectivenessVerified: z.ZodLiteral<false>;
|
|
17
|
+
gaps: z.ZodArray<z.ZodEnum<{
|
|
18
|
+
"clock-discontinuity": "clock-discontinuity";
|
|
19
|
+
"persisted-only": "persisted-only";
|
|
20
|
+
"live-enabled-state-unknown": "live-enabled-state-unknown";
|
|
21
|
+
"live-pending-state-unknown": "live-pending-state-unknown";
|
|
22
|
+
"unflushed-tail-unknown": "unflushed-tail-unknown";
|
|
23
|
+
"stored-pending-is-not-live": "stored-pending-is-not-live";
|
|
24
|
+
"no-retained-operation-observations": "no-retained-operation-observations";
|
|
25
|
+
"account-switch-not-observed": "account-switch-not-observed";
|
|
26
|
+
"compaction-not-observed": "compaction-not-observed";
|
|
27
|
+
"stale-snapshot": "stale-snapshot";
|
|
28
|
+
"expired-in-stored-snapshot": "expired-in-stored-snapshot";
|
|
29
|
+
"host-dropped": "host-dropped";
|
|
30
|
+
"client-dropped": "client-dropped";
|
|
31
|
+
"client-unconfirmed": "client-unconfirmed";
|
|
32
|
+
"retention-or-capacity-eviction": "retention-or-capacity-eviction";
|
|
33
|
+
"collector-saturated": "collector-saturated";
|
|
34
|
+
"interrupted-observations": "interrupted-observations";
|
|
35
|
+
"recorded-pause": "recorded-pause";
|
|
36
|
+
"unpersisted-observations": "unpersisted-observations";
|
|
37
|
+
"collection-paused": "collection-paused";
|
|
38
|
+
"storage-not-ready": "storage-not-ready";
|
|
39
|
+
"analysis-count-overflow": "analysis-count-overflow";
|
|
40
|
+
"no-cross-layer-correlation": "no-cross-layer-correlation";
|
|
41
|
+
"no-unique-impact": "no-unique-impact";
|
|
42
|
+
"hour-boundary-censoring": "hour-boundary-censoring";
|
|
43
|
+
"no-collection-coverage-clock": "no-collection-coverage-clock";
|
|
44
|
+
"no-calibrated-alert-thresholds": "no-calibrated-alert-thresholds";
|
|
45
|
+
"no-baseline-trend": "no-baseline-trend";
|
|
46
|
+
"no-root-cause-proof": "no-root-cause-proof";
|
|
47
|
+
}>>;
|
|
48
|
+
collection: z.ZodObject<{
|
|
49
|
+
enabled: z.ZodNullable<z.ZodBoolean>;
|
|
50
|
+
state: z.ZodNullable<z.ZodEnum<{
|
|
51
|
+
error: "error";
|
|
52
|
+
ready: "ready";
|
|
53
|
+
unavailable: "unavailable";
|
|
54
|
+
loading: "loading";
|
|
55
|
+
}>>;
|
|
56
|
+
diagnostic: z.ZodNullable<z.ZodEnum<{
|
|
57
|
+
none: "none";
|
|
58
|
+
"storage-unavailable": "storage-unavailable";
|
|
59
|
+
"storage-invalid": "storage-invalid";
|
|
60
|
+
"storage-write-failed": "storage-write-failed";
|
|
61
|
+
"profile-unavailable": "profile-unavailable";
|
|
62
|
+
"settings-unavailable": "settings-unavailable";
|
|
63
|
+
"settings-conflict": "settings-conflict";
|
|
64
|
+
"client-report-failed": "client-report-failed";
|
|
65
|
+
"client-report-revoked": "client-report-revoked";
|
|
66
|
+
closed: "closed";
|
|
67
|
+
}>>;
|
|
68
|
+
dirty: z.ZodNullable<z.ZodBoolean>;
|
|
69
|
+
persistedAt: z.ZodNullable<z.ZodNumber>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
counters: z.ZodObject<{
|
|
72
|
+
dropped: z.ZodNumber;
|
|
73
|
+
clientDropped: z.ZodNumber;
|
|
74
|
+
clientUnconfirmed: z.ZodNumber;
|
|
75
|
+
evicted: z.ZodNumber;
|
|
76
|
+
saturated: z.ZodNumber;
|
|
77
|
+
interrupted: z.ZodNumber;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
populations: z.ZodArray<z.ZodObject<{
|
|
80
|
+
version: z.ZodString;
|
|
81
|
+
layer: z.ZodEnum<{
|
|
82
|
+
client: "client";
|
|
83
|
+
host: "host";
|
|
84
|
+
}>;
|
|
85
|
+
operation: z.ZodEnum<{
|
|
86
|
+
compaction: "compaction";
|
|
87
|
+
"account-global-switch": "account-global-switch";
|
|
88
|
+
"account-session-select": "account-session-select";
|
|
89
|
+
"account-session-inherit": "account-session-inherit";
|
|
90
|
+
"identity-read": "identity-read";
|
|
91
|
+
"identity-flight": "identity-flight";
|
|
92
|
+
"compaction-summary": "compaction-summary";
|
|
93
|
+
collection: "collection";
|
|
94
|
+
}>;
|
|
95
|
+
successMeaning: z.ZodEnum<{
|
|
96
|
+
"owner-terminal-observation-only": "owner-terminal-observation-only";
|
|
97
|
+
"matching-checkpoint-and-end-observed": "matching-checkpoint-and-end-observed";
|
|
98
|
+
"summary-call-fulfilled-not-checkpoint-commit": "summary-call-fulfilled-not-checkpoint-commit";
|
|
99
|
+
}>;
|
|
100
|
+
firstHour: z.ZodNumber;
|
|
101
|
+
lastHour: z.ZodNumber;
|
|
102
|
+
started: z.ZodObject<{
|
|
103
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
104
|
+
overflow: z.ZodBoolean;
|
|
105
|
+
}, z.core.$strict>;
|
|
106
|
+
terminalObservations: z.ZodObject<{
|
|
107
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
108
|
+
overflow: z.ZodBoolean;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
outcomes: z.ZodObject<{
|
|
111
|
+
success: z.ZodObject<{
|
|
112
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
113
|
+
overflow: z.ZodBoolean;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
'no-op': z.ZodObject<{
|
|
116
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
117
|
+
overflow: z.ZodBoolean;
|
|
118
|
+
}, z.core.$strict>;
|
|
119
|
+
cancelled: z.ZodObject<{
|
|
120
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
121
|
+
overflow: z.ZodBoolean;
|
|
122
|
+
}, z.core.$strict>;
|
|
123
|
+
'policy-rejected': z.ZodObject<{
|
|
124
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
125
|
+
overflow: z.ZodBoolean;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
revoked: z.ZodObject<{
|
|
128
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
129
|
+
overflow: z.ZodBoolean;
|
|
130
|
+
}, z.core.$strict>;
|
|
131
|
+
'environment-fault': z.ZodObject<{
|
|
132
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
133
|
+
overflow: z.ZodBoolean;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
failed: z.ZodObject<{
|
|
136
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
137
|
+
overflow: z.ZodBoolean;
|
|
138
|
+
}, z.core.$strict>;
|
|
139
|
+
unknown: z.ZodObject<{
|
|
140
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
141
|
+
overflow: z.ZodBoolean;
|
|
142
|
+
}, z.core.$strict>;
|
|
143
|
+
interrupted: z.ZodObject<{
|
|
144
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
145
|
+
overflow: z.ZodBoolean;
|
|
146
|
+
}, z.core.$strict>;
|
|
147
|
+
}, z.core.$strict>;
|
|
148
|
+
terminalLatency: z.ZodArray<z.ZodObject<{
|
|
149
|
+
lowerMs: z.ZodNumber;
|
|
150
|
+
upperExclusiveMs: z.ZodNullable<z.ZodNumber>;
|
|
151
|
+
count: z.ZodObject<{
|
|
152
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
153
|
+
overflow: z.ZodBoolean;
|
|
154
|
+
}, z.core.$strict>;
|
|
155
|
+
}, z.core.$strict>>;
|
|
156
|
+
stageAgeObservations: z.ZodArray<z.ZodObject<{
|
|
157
|
+
lowerMs: z.ZodNumber;
|
|
158
|
+
upperExclusiveMs: z.ZodNullable<z.ZodNumber>;
|
|
159
|
+
count: z.ZodObject<{
|
|
160
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
161
|
+
overflow: z.ZodBoolean;
|
|
162
|
+
}, z.core.$strict>;
|
|
163
|
+
}, z.core.$strict>>;
|
|
164
|
+
pendingSamples: z.ZodObject<{
|
|
165
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
166
|
+
overflow: z.ZodBoolean;
|
|
167
|
+
}, z.core.$strict>;
|
|
168
|
+
pendingSampleAges: z.ZodArray<z.ZodObject<{
|
|
169
|
+
lowerMs: z.ZodNumber;
|
|
170
|
+
upperExclusiveMs: z.ZodNullable<z.ZodNumber>;
|
|
171
|
+
count: z.ZodObject<{
|
|
172
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
173
|
+
overflow: z.ZodBoolean;
|
|
174
|
+
}, z.core.$strict>;
|
|
175
|
+
}, z.core.$strict>>;
|
|
176
|
+
stageObservations: z.ZodObject<{
|
|
177
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
178
|
+
overflow: z.ZodBoolean;
|
|
179
|
+
}, z.core.$strict>;
|
|
180
|
+
startsMinusTerminals: z.ZodNull;
|
|
181
|
+
exactOperationFailureRate: z.ZodNull;
|
|
182
|
+
}, z.core.$strict>>;
|
|
183
|
+
pendingAtSnapshot: z.ZodArray<z.ZodObject<{
|
|
184
|
+
version: z.ZodString;
|
|
185
|
+
operation: z.ZodEnum<{
|
|
186
|
+
compaction: "compaction";
|
|
187
|
+
"account-global-switch": "account-global-switch";
|
|
188
|
+
"account-session-select": "account-session-select";
|
|
189
|
+
"account-session-inherit": "account-session-inherit";
|
|
190
|
+
"identity-read": "identity-read";
|
|
191
|
+
"identity-flight": "identity-flight";
|
|
192
|
+
"compaction-summary": "compaction-summary";
|
|
193
|
+
collection: "collection";
|
|
194
|
+
}>;
|
|
195
|
+
stage: z.ZodEnum<{
|
|
196
|
+
ended: "ended";
|
|
197
|
+
admitted: "admitted";
|
|
198
|
+
"rpc-invoked": "rpc-invoked";
|
|
199
|
+
"host-received": "host-received";
|
|
200
|
+
"identity-validation": "identity-validation";
|
|
201
|
+
"model-validation": "model-validation";
|
|
202
|
+
cas: "cas";
|
|
203
|
+
readback: "readback";
|
|
204
|
+
"response-received": "response-received";
|
|
205
|
+
decoded: "decoded";
|
|
206
|
+
"client-settled": "client-settled";
|
|
207
|
+
"summary-attempt": "summary-attempt";
|
|
208
|
+
"checkpoint-committed": "checkpoint-committed";
|
|
209
|
+
"cache-hit": "cache-hit";
|
|
210
|
+
"joined-flight": "joined-flight";
|
|
211
|
+
cooldown: "cooldown";
|
|
212
|
+
dispatched: "dispatched";
|
|
213
|
+
}>;
|
|
214
|
+
bucket: z.ZodNumber;
|
|
215
|
+
count: z.ZodNumber;
|
|
216
|
+
}, z.core.$strict>>;
|
|
217
|
+
investigationCandidates: z.ZodArray<z.ZodObject<{
|
|
218
|
+
fingerprint: z.ZodString;
|
|
219
|
+
category: z.ZodEnum<{
|
|
220
|
+
"recorded-failure": "recorded-failure";
|
|
221
|
+
"unknown-outcome": "unknown-outcome";
|
|
222
|
+
}>;
|
|
223
|
+
layer: z.ZodEnum<{
|
|
224
|
+
client: "client";
|
|
225
|
+
host: "host";
|
|
226
|
+
}>;
|
|
227
|
+
operation: z.ZodEnum<{
|
|
228
|
+
compaction: "compaction";
|
|
229
|
+
"account-global-switch": "account-global-switch";
|
|
230
|
+
"account-session-select": "account-session-select";
|
|
231
|
+
"account-session-inherit": "account-session-inherit";
|
|
232
|
+
"identity-read": "identity-read";
|
|
233
|
+
"identity-flight": "identity-flight";
|
|
234
|
+
"compaction-summary": "compaction-summary";
|
|
235
|
+
collection: "collection";
|
|
236
|
+
}>;
|
|
237
|
+
metric: z.ZodEnum<{
|
|
238
|
+
unknown: "unknown";
|
|
239
|
+
"environment-fault": "environment-fault";
|
|
240
|
+
failed: "failed";
|
|
241
|
+
}>;
|
|
242
|
+
reason: z.ZodEnum<{
|
|
243
|
+
none: "none";
|
|
244
|
+
COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
245
|
+
COPILOT_ACCOUNTS_CHANGED: "COPILOT_ACCOUNTS_CHANGED";
|
|
246
|
+
COPILOT_ACCOUNTS_BUSY: "COPILOT_ACCOUNTS_BUSY";
|
|
247
|
+
COPILOT_ACCOUNTS_CONFLICT: "COPILOT_ACCOUNTS_CONFLICT";
|
|
248
|
+
COPILOT_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
249
|
+
COPILOT_ACCOUNTS_MODELS_FAILED: "COPILOT_ACCOUNTS_MODELS_FAILED";
|
|
250
|
+
COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE: "COPILOT_ACCOUNTS_IDENTITY_UNAVAILABLE";
|
|
251
|
+
COPILOT_ACCOUNTS_IDENTITY_INVALID: "COPILOT_ACCOUNTS_IDENTITY_INVALID";
|
|
252
|
+
COPILOT_ACCOUNTS_IDENTITY_TIMEOUT: "COPILOT_ACCOUNTS_IDENTITY_TIMEOUT";
|
|
253
|
+
COPILOT_ACCOUNTS_IDENTITY_TLS: "COPILOT_ACCOUNTS_IDENTITY_TLS";
|
|
254
|
+
COPILOT_ACCOUNTS_IDENTITY_NETWORK: "COPILOT_ACCOUNTS_IDENTITY_NETWORK";
|
|
255
|
+
COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED: "COPILOT_ACCOUNTS_IDENTITY_AUTH_REJECTED";
|
|
256
|
+
COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED: "COPILOT_ACCOUNTS_IDENTITY_RATE_LIMITED";
|
|
257
|
+
COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR: "COPILOT_ACCOUNTS_IDENTITY_HTTP_ERROR";
|
|
258
|
+
unknown: "unknown";
|
|
259
|
+
"rpc-unavailable": "rpc-unavailable";
|
|
260
|
+
"decode-invalid": "decode-invalid";
|
|
261
|
+
COPILOT_SESSION_ACCOUNTS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_UNAVAILABLE";
|
|
262
|
+
COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE: "COPILOT_SESSION_ACCOUNTS_SETTINGS_UNAVAILABLE";
|
|
263
|
+
COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN: "COPILOT_SESSION_ACCOUNTS_COMMIT_UNCERTAIN";
|
|
264
|
+
COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH: "COPILOT_RESPONSES_REPLAY_SCOPE_MISMATCH";
|
|
265
|
+
CONTEXT_WINDOW_EXCEEDED: "CONTEXT_WINDOW_EXCEEDED";
|
|
266
|
+
COPILOT_MANUAL_RECOVERY_FIXED_PREFIX: "COPILOT_MANUAL_RECOVERY_FIXED_PREFIX";
|
|
267
|
+
COPILOT_MANUAL_RECOVERY_INDIVISIBLE: "COPILOT_MANUAL_RECOVERY_INDIVISIBLE";
|
|
268
|
+
COPILOT_MANUAL_RECOVERY_CALL_LIMIT: "COPILOT_MANUAL_RECOVERY_CALL_LIMIT";
|
|
269
|
+
COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY: "COPILOT_MANUAL_RECOVERY_EMPTY_SUMMARY";
|
|
270
|
+
COPILOT_MANUAL_RECOVERY_UNBALANCED: "COPILOT_MANUAL_RECOVERY_UNBALANCED";
|
|
271
|
+
}>;
|
|
272
|
+
versions: z.ZodArray<z.ZodString>;
|
|
273
|
+
firstHour: z.ZodNumber;
|
|
274
|
+
lastHour: z.ZodNumber;
|
|
275
|
+
observations: z.ZodObject<{
|
|
276
|
+
value: z.ZodNullable<z.ZodNumber>;
|
|
277
|
+
overflow: z.ZodBoolean;
|
|
278
|
+
}, z.core.$strict>;
|
|
279
|
+
regressionProven: z.ZodLiteral<false>;
|
|
280
|
+
persistentFaultProven: z.ZodLiteral<false>;
|
|
281
|
+
rootCause: z.ZodLiteral<"unknown">;
|
|
282
|
+
}, z.core.$strict>>;
|
|
283
|
+
}, z.core.$strict>;
|
|
284
|
+
export type DiagnosticsAnalysisReport = z.infer<typeof DiagnosticsAnalysisReportSchema>;
|
|
285
|
+
export type DiagnosticsAnalysisSource = 'reviewed-view' | 'persisted-snapshot';
|
|
286
|
+
export declare function diagnosticsUnitName(profileName: string): string;
|
|
287
|
+
export declare function parseReviewedView(text: string): DiagnosticsView;
|
|
288
|
+
export declare function parsePersistedUnit(text: string, expectedUnit: string): DiagnosticsSnapshot;
|
|
289
|
+
export declare function analyzeSnapshot(input: unknown, options: {
|
|
290
|
+
source: DiagnosticsAnalysisSource;
|
|
291
|
+
observedAt: number;
|
|
292
|
+
view?: DiagnosticsView;
|
|
293
|
+
}): DiagnosticsAnalysisReport;
|
|
294
|
+
export declare function analyzeReviewedView(view: DiagnosticsView, observedAt: number): DiagnosticsAnalysisReport;
|
|
295
|
+
//# sourceMappingURL=diagnostics-analysis.d.ts.map
|
|
@@ -56,6 +56,7 @@ export type AccountPiModel = Model<AccountModelApi> & {
|
|
|
56
56
|
readonly unmappedReasoningEfforts: readonly string[];
|
|
57
57
|
readonly minThinkingBudget?: number;
|
|
58
58
|
readonly maxThinkingBudget?: number;
|
|
59
|
+
readonly temperatureCompatibility: AccountModelDescriptor['sampling']['temperature'];
|
|
59
60
|
};
|
|
60
61
|
export declare function copilotPublicHeaders(): Readonly<Record<string, string>>;
|
|
61
62
|
/** Materialize advertised capabilities only; model names and the local static catalog never select the API. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-github-copilot",
|
|
3
3
|
"description": "DSH companion for GitHub Copilot sign-in, account-aware model profiles, tool compatibility, and provider-hosted search.",
|
|
4
|
-
"version": "0.4.0-alpha.
|
|
4
|
+
"version": "0.4.0-alpha.132",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"docs/evidence-driven-iteration.md",
|
|
77
77
|
"docs/plugin-diagnostics.md",
|
|
78
78
|
"docs/auto-iteration-review.json",
|
|
79
|
+
"scripts/analyze-diagnostics.mjs",
|
|
79
80
|
"scripts/iteration-review.mjs",
|
|
80
81
|
"docs/image-input-compatibility.md",
|
|
81
82
|
"output/auto-model-mockup/index.html",
|
|
@@ -231,6 +232,7 @@
|
|
|
231
232
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
232
233
|
"typecheck:tests": "tsc -p tsconfig.tests.json",
|
|
233
234
|
"test:scripts": "node --test \"tests/scripts/*.test.mjs\"",
|
|
235
|
+
"diagnostics:analyze": "node scripts/analyze-diagnostics.mjs",
|
|
234
236
|
"agent:describe": "node scripts/agent.mjs describe --json",
|
|
235
237
|
"agent:doctor": "node scripts/agent.mjs doctor --json",
|
|
236
238
|
"agent:plan": "node scripts/agent.mjs plan",
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { open } from 'node:fs/promises'
|
|
2
|
+
import { basename, isAbsolute, parse, resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import {
|
|
5
|
+
analyzeReviewedView, analyzeSnapshot, diagnosticsUnitName, parsePersistedUnit, parseReviewedView,
|
|
6
|
+
} from '../lib/diagnostics-analysis.js'
|
|
7
|
+
import { readBoundedDiagnosticsFile } from '../lib/diagnostics-analysis-io.js'
|
|
8
|
+
|
|
9
|
+
const usage = 'Usage: node scripts/analyze-diagnostics.mjs --input <absolute-file> --mode persisted-unit --profile-name <name> --output <new-local-file>\n'
|
|
10
|
+
+ ' or: node scripts/analyze-diagnostics.mjs --input <absolute-file> --mode reviewed-view --output <new-local-file>'
|
|
11
|
+
const supportedErrors = new Set([
|
|
12
|
+
'INVALID_PROFILE', 'INVALID_UNIT', 'INVALID_SNAPSHOT', 'DUPLICATE_AGGREGATE',
|
|
13
|
+
'INVALID_OPTIONS', 'INVALID_VIEW', 'INVALID_ARGUMENTS', 'INPUT_LIMIT', 'INVALID_JSON', 'INVALID_PATH',
|
|
14
|
+
'SYMLINK_REJECTED', 'NOT_REGULAR_FILE', 'FILE_CHANGED', 'FILE_READ_FAILED', 'INVALID_UTF8',
|
|
15
|
+
'INVALID_REPORT', 'OUTPUT_UNAVAILABLE',
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
function parseArguments(args) {
|
|
19
|
+
const values = new Map()
|
|
20
|
+
for (let index = 0; index < args.length; index += 2) {
|
|
21
|
+
const key = args[index]
|
|
22
|
+
const value = args[index + 1]
|
|
23
|
+
if (!['--input', '--mode', '--profile-name', '--output'].includes(key)
|
|
24
|
+
|| !value || value.startsWith('--') || values.has(key)) {
|
|
25
|
+
throw new Error('COPILOT_DIAGNOSTICS_ANALYSIS_INVALID_ARGUMENTS')
|
|
26
|
+
}
|
|
27
|
+
values.set(key, value)
|
|
28
|
+
}
|
|
29
|
+
const mode = values.get('--mode')
|
|
30
|
+
if (!values.has('--input') || !values.has('--output')
|
|
31
|
+
|| !['persisted-unit', 'reviewed-view'].includes(mode)
|
|
32
|
+
|| (mode === 'persisted-unit') !== values.has('--profile-name')) {
|
|
33
|
+
throw new Error('COPILOT_DIAGNOSTICS_ANALYSIS_INVALID_ARGUMENTS')
|
|
34
|
+
}
|
|
35
|
+
const input = values.get('--input')
|
|
36
|
+
const output = values.get('--output')
|
|
37
|
+
if (!isAbsolute(input) || !isAbsolute(output))
|
|
38
|
+
throw new Error('COPILOT_DIAGNOSTICS_ANALYSIS_INVALID_PATH')
|
|
39
|
+
const inputPath = resolve(input)
|
|
40
|
+
const outputPath = resolve(output)
|
|
41
|
+
const comparable = value => process.platform === 'win32' ? value.toLowerCase() : value
|
|
42
|
+
if (comparable(inputPath) === comparable(outputPath)
|
|
43
|
+
|| (process.platform === 'win32' && parse(outputPath).root.startsWith('\\\\'))) {
|
|
44
|
+
throw new Error('COPILOT_DIAGNOSTICS_ANALYSIS_INVALID_PATH')
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
inputPath, outputPath, mode,
|
|
48
|
+
profileName: values.get('--profile-name'),
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function errorCode(error) {
|
|
53
|
+
const prefix = 'COPILOT_DIAGNOSTICS_ANALYSIS_'
|
|
54
|
+
if (error instanceof Error && error.message.startsWith(prefix)) {
|
|
55
|
+
const candidate = error.message.slice(prefix.length)
|
|
56
|
+
if (supportedErrors.has(candidate)) return candidate
|
|
57
|
+
}
|
|
58
|
+
return 'ANALYSIS_FAILED'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main(args) {
|
|
62
|
+
if (args.length === 1 && args[0] === '--help') {
|
|
63
|
+
process.stdout.write(`${usage}\n`)
|
|
64
|
+
return
|
|
65
|
+
}
|
|
66
|
+
const options = parseArguments(args)
|
|
67
|
+
const text = await readBoundedDiagnosticsFile(options.inputPath)
|
|
68
|
+
const observedAt = Date.now()
|
|
69
|
+
let report
|
|
70
|
+
if (options.mode === 'persisted-unit') {
|
|
71
|
+
const unitName = diagnosticsUnitName(options.profileName)
|
|
72
|
+
if (basename(options.inputPath) !== `${unitName}.json`)
|
|
73
|
+
throw new Error('COPILOT_DIAGNOSTICS_ANALYSIS_INVALID_UNIT')
|
|
74
|
+
const snapshot = parsePersistedUnit(text, unitName)
|
|
75
|
+
report = analyzeSnapshot(snapshot, { source: 'persisted-snapshot', observedAt })
|
|
76
|
+
} else {
|
|
77
|
+
report = analyzeReviewedView(parseReviewedView(text), observedAt)
|
|
78
|
+
}
|
|
79
|
+
let handle
|
|
80
|
+
try { handle = await open(options.outputPath, 'wx') } catch {
|
|
81
|
+
throw new Error('COPILOT_DIAGNOSTICS_ANALYSIS_OUTPUT_UNAVAILABLE')
|
|
82
|
+
}
|
|
83
|
+
try { await handle.writeFile(`${JSON.stringify(report, null, 2)}\n`, 'utf8') } finally { await handle.close() }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (process.argv[1] !== undefined && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
87
|
+
main(process.argv.slice(2)).catch(error => {
|
|
88
|
+
process.stderr.write(`COPILOT_DIAGNOSTICS_ANALYSIS_${errorCode(error)}\n`)
|
|
89
|
+
process.exitCode = 1
|
|
90
|
+
})
|
|
91
|
+
}
|