@mossbear/protocol 0.1.0-alpha.115 → 0.1.0-alpha.117
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/dist/bundles.d.ts +662 -0
- package/dist/bundles.d.ts.map +1 -0
- package/dist/bundles.js +454 -0
- package/dist/bundles.js.map +1 -0
- package/dist/bundles.test.d.ts +2 -0
- package/dist/bundles.test.d.ts.map +1 -0
- package/dist/bundles.test.js +61 -0
- package/dist/bundles.test.js.map +1 -0
- package/dist/guideHistory.d.ts +643 -0
- package/dist/guideHistory.d.ts.map +1 -0
- package/dist/guideHistory.js +343 -0
- package/dist/guideHistory.js.map +1 -0
- package/dist/guideHistory.test.d.ts +2 -0
- package/dist/guideHistory.test.d.ts.map +1 -0
- package/dist/guideHistory.test.js +35 -0
- package/dist/guideHistory.test.js.map +1 -0
- package/dist/guideImport.d.ts +398 -0
- package/dist/guideImport.d.ts.map +1 -0
- package/dist/guideImport.js +350 -0
- package/dist/guideImport.js.map +1 -0
- package/dist/guideImport.test.d.ts +2 -0
- package/dist/guideImport.test.d.ts.map +1 -0
- package/dist/guideImport.test.js +62 -0
- package/dist/guideImport.test.js.map +1 -0
- package/dist/guideSnapshot.d.ts +105 -0
- package/dist/guideSnapshot.d.ts.map +1 -0
- package/dist/guideSnapshot.js +101 -0
- package/dist/guideSnapshot.js.map +1 -0
- package/dist/guideSnapshot.test.d.ts +2 -0
- package/dist/guideSnapshot.test.d.ts.map +1 -0
- package/dist/guideSnapshot.test.js +49 -0
- package/dist/guideSnapshot.test.js.map +1 -0
- package/dist/pairing.d.ts +1 -1
- package/dist/schemas.d.ts +43 -2072
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +43 -1389
- package/dist/schemas.js.map +1 -1
- package/dist/search.d.ts +97 -0
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +14 -0
- package/dist/search.js.map +1 -1
- package/dist/search.test.js +22 -0
- package/dist/search.test.js.map +1 -1
- package/dist/sessionGrade.d.ts +12 -12
- package/dist/sessionGrade.d.ts.map +1 -1
- package/dist/sessionGrade.js +11 -11
- package/dist/sessionGrade.js.map +1 -1
- package/dist/types.d.ts +4 -27
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/whatSyncs.js +4 -4
- package/dist/whatSyncs.js.map +1 -1
- package/dist/wirePrimitives.d.ts +90 -3
- package/dist/wirePrimitives.d.ts.map +1 -1
- package/dist/wirePrimitives.js +124 -3
- package/dist/wirePrimitives.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/** Guide verdict history contracts, inferred types, and boundary parsers. */
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
import { GuideDiscoveryRootSchema, GuideHistoryUntrustedSchema, NonEmptyStringSchema, SafeRelativePosixPathSchema, } from './wirePrimitives.js';
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Guide verdict history (guide-history-for-agents)
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
/**
|
|
8
|
+
* The read an agent makes of a guide's own grading record, so the improvement
|
|
9
|
+
* loop the user already runs in-conversation ("what could be improved in this
|
|
10
|
+
* skill?") has the evidence Mossbear holds and the agent does not.
|
|
11
|
+
*
|
|
12
|
+
* **Evidence out, never instructions out.** Nothing in this contract carries a
|
|
13
|
+
* directive to change anything, and nothing on the server writes as a result of
|
|
14
|
+
* it. It is a read, and the decision stays in the user's conversation.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* How the agent names the guide.
|
|
18
|
+
*
|
|
19
|
+
* Either a repo-relative path exactly as the guide file declares it
|
|
20
|
+
* (`.claude/skills/reviewer/SKILL.md`, `AGENTS.md`), or the bare name of a
|
|
21
|
+
* skill (`reviewer`), which the server expands to the skill layouts it knows.
|
|
22
|
+
* Both resolve through the `(root, path)` identity import already reconciles
|
|
23
|
+
* on, rather than a second one invented here.
|
|
24
|
+
*
|
|
25
|
+
* Bounded and shape-checked at the boundary rather than at the query string: it
|
|
26
|
+
* reaches a SQL predicate, and an identifier is not free text.
|
|
27
|
+
*/
|
|
28
|
+
export const GuideHistoryIdentifierSchema = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(512), v.check((value) => !/[\u0000-\u001f\u007f]/.test(value), 'guide must not contain control characters'));
|
|
29
|
+
/**
|
|
30
|
+
* The request an agent sends.
|
|
31
|
+
*
|
|
32
|
+
* `root` is optional and is the disambiguator, not decoration: `.claude/skills`
|
|
33
|
+
* is scanned under **both** discovery roots
|
|
34
|
+
* (`packages/cli/src/guides/discover.ts`), so a project skill and its
|
|
35
|
+
* `~/.claude/skills` twin declare the same path string. When the identifier
|
|
36
|
+
* reaches guides under more than one root and no root was given, the server
|
|
37
|
+
* refuses and names both rather than picking one — answering a question about
|
|
38
|
+
* the wrong file's history is worse than not answering it.
|
|
39
|
+
*/
|
|
40
|
+
export const GuideHistoryRequestSchema = v.object({
|
|
41
|
+
guide: GuideHistoryIdentifierSchema,
|
|
42
|
+
root: v.optional(GuideDiscoveryRootSchema),
|
|
43
|
+
/**
|
|
44
|
+
* Which repo's copy — **the axis import itself reconciles on**, and the one
|
|
45
|
+
* that actually resolves the common collision.
|
|
46
|
+
*
|
|
47
|
+
* `root` alone does not, and assuming it did was the first version's defect:
|
|
48
|
+
* import's resolution key is `(userId, repoId, root, path)` and two files at
|
|
49
|
+
* one path under different repos deliberately stay two rows. So any
|
|
50
|
+
* user with two repos has two guides at `(project, AGENTS.md)`, and a refusal
|
|
51
|
+
* telling them to pass `root` names the one field that cannot separate those.
|
|
52
|
+
*
|
|
53
|
+
* `projectId` is the portable identity a repo commits and every clone agrees
|
|
54
|
+
* on; `repoId` is the machine-local digest. Both are optional and both are
|
|
55
|
+
* what the caller already sends at import time, so an agent running inside a
|
|
56
|
+
* repo supplies them without being asked.
|
|
57
|
+
*/
|
|
58
|
+
projectId: v.optional(NonEmptyStringSchema),
|
|
59
|
+
repoId: v.optional(NonEmptyStringSchema),
|
|
60
|
+
/**
|
|
61
|
+
* The exact guide, when the caller has already been shown the candidates.
|
|
62
|
+
*
|
|
63
|
+
* The escape hatch that makes the refusal always satisfiable: two repos can
|
|
64
|
+
* be indistinguishable to a caller that knows neither id (a guide imported
|
|
65
|
+
* before repo identity was recorded carries neither), and an error whose
|
|
66
|
+
* remedy cannot be carried out is worse than no remedy at all. The 409 names
|
|
67
|
+
* this id for every candidate.
|
|
68
|
+
*/
|
|
69
|
+
guideId: v.optional(NonEmptyStringSchema),
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* One revision of a guide's wording: the body file and the version it stood at.
|
|
73
|
+
*
|
|
74
|
+
* The pair, never a bare version number — `guide_files.version` restarts at 1
|
|
75
|
+
* per row, so a number alone compares equal across two different files.
|
|
76
|
+
*/
|
|
77
|
+
export const GuideHistoryRevisionSchema = v.object({
|
|
78
|
+
bodyItemId: NonEmptyStringSchema,
|
|
79
|
+
version: v.pipe(v.number(), v.integer()),
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Which of three states the guide's record is in — a required field rather than
|
|
83
|
+
* something a reader infers from empty arrays.
|
|
84
|
+
*
|
|
85
|
+
* The distinction is the whole point of returning it: `unevaluated` means no
|
|
86
|
+
* graded session has ever produced a verdict, while `awaiting_current_revision`
|
|
87
|
+
* means the guide has a real record that is entirely about wording the user has
|
|
88
|
+
* since rewritten. Collapsing those two onto "no data" is exactly the claim the
|
|
89
|
+
* dashboard stopped making with its awaiting-current-revision check, and an
|
|
90
|
+
* agent reading an absence as a verdict is the same error one screen further
|
|
91
|
+
* out.
|
|
92
|
+
*/
|
|
93
|
+
export const GuideHistoryStateSchema = v.picklist([
|
|
94
|
+
'evaluated',
|
|
95
|
+
'awaiting_current_revision',
|
|
96
|
+
'unevaluated',
|
|
97
|
+
]);
|
|
98
|
+
/**
|
|
99
|
+
* The verdict window, scoped to the revision named beside it.
|
|
100
|
+
*
|
|
101
|
+
* Both denominators travel: `applicable` is the rate's own denominator
|
|
102
|
+
* (`aligned + misaligned`), `total` is the window's row count including the sessions
|
|
103
|
+
* that never engaged the guide. Rendering one as the other is the defect
|
|
104
|
+
* `alignment-rate-sample-disclosure` was filed for, and a payload carrying only
|
|
105
|
+
* one of them would hand an agent the same mistake.
|
|
106
|
+
*/
|
|
107
|
+
export const GuideHistoryWindowSchema = v.object({
|
|
108
|
+
/** Rows summarized, after the revision narrow. */
|
|
109
|
+
total: v.pipe(v.number(), v.integer()),
|
|
110
|
+
aligned: v.pipe(v.number(), v.integer()),
|
|
111
|
+
misaligned: v.pipe(v.number(), v.integer()),
|
|
112
|
+
/** In context, never engaged. Neither a pass nor a failure. */
|
|
113
|
+
notApplicable: v.pipe(v.number(), v.integer()),
|
|
114
|
+
/** `aligned + misaligned` — the rate's own denominator. */
|
|
115
|
+
applicable: v.pipe(v.number(), v.integer()),
|
|
116
|
+
/** `aligned / applicable`, or **null when no session engaged the guide**. */
|
|
117
|
+
alignmentRate: v.nullable(v.number()),
|
|
118
|
+
/** The rows hit the per-guide cap: a bounded window, never a lifetime total. */
|
|
119
|
+
isWindowed: v.boolean(),
|
|
120
|
+
/** The cap the rows were fetched under, so a reader can say what "windowed" means. */
|
|
121
|
+
windowSize: v.pipe(v.number(), v.integer()),
|
|
122
|
+
/**
|
|
123
|
+
* Verdicts fetched and then dropped by the revision narrow — about wording
|
|
124
|
+
* that is no longer current, or citing no revision at all. A **floor** rather
|
|
125
|
+
* than a total whenever `isWindowed`, because rows past the cap were never
|
|
126
|
+
* fetched.
|
|
127
|
+
*/
|
|
128
|
+
olderRevisionRows: v.pipe(v.number(), v.integer()),
|
|
129
|
+
/**
|
|
130
|
+
* `applicable` is too small for the percentage to mean anything — threshold
|
|
131
|
+
* `applicable < 3` (founder, 2026-08-22). Read the counts, not the rate.
|
|
132
|
+
*/
|
|
133
|
+
isLowConfidence: v.boolean(),
|
|
134
|
+
});
|
|
135
|
+
/**
|
|
136
|
+
* One side of a guide edit's before/after pair — the wording, and what the sessions
|
|
137
|
+
* that engaged it did.
|
|
138
|
+
*
|
|
139
|
+
* Structurally a window like `GuideHistoryWindow` and deliberately not that
|
|
140
|
+
* schema: these two sides are bounded **per revision** by a different
|
|
141
|
+
* server-side query, so `isSaturated` is
|
|
142
|
+
* the server's own measurement of its partition rather than the client-side
|
|
143
|
+
* `isWindowed` inference, and the span each side covers is part of what makes
|
|
144
|
+
* the pair readable.
|
|
145
|
+
*
|
|
146
|
+
* Both denominators travel here for the same reason they travel on the window:
|
|
147
|
+
* a delta between two undisclosed denominators is worse than no number at all.
|
|
148
|
+
*/
|
|
149
|
+
export const GuideHistoryChangeSideSchema = v.object({
|
|
150
|
+
/** The wording this side judges. */
|
|
151
|
+
revision: GuideHistoryRevisionSchema,
|
|
152
|
+
/** Rows in this side's window, including the sessions that never engaged it. */
|
|
153
|
+
total: v.pipe(v.number(), v.integer()),
|
|
154
|
+
aligned: v.pipe(v.number(), v.integer()),
|
|
155
|
+
misaligned: v.pipe(v.number(), v.integer()),
|
|
156
|
+
notApplicable: v.pipe(v.number(), v.integer()),
|
|
157
|
+
/** `aligned + misaligned` — this side's own denominator. */
|
|
158
|
+
applicable: v.pipe(v.number(), v.integer()),
|
|
159
|
+
/** `aligned / applicable`, or null when no session engaged this wording. */
|
|
160
|
+
alignmentRate: v.nullable(v.number()),
|
|
161
|
+
/** This side is below the sample floor, so read its counts and not its rate. */
|
|
162
|
+
isLowConfidence: v.boolean(),
|
|
163
|
+
/**
|
|
164
|
+
* This side is a bounded sample of its revision rather than the whole record.
|
|
165
|
+
* A saturated side beside an unsaturated one is two different kinds of
|
|
166
|
+
* number, and comparing them without saying so is the defect the flag exists
|
|
167
|
+
* to stop.
|
|
168
|
+
*/
|
|
169
|
+
isSaturated: v.boolean(),
|
|
170
|
+
/** The span this side covers, ISO. Both null on a side with no rows. */
|
|
171
|
+
newestAt: v.nullable(v.string()),
|
|
172
|
+
oldestAt: v.nullable(v.string()),
|
|
173
|
+
});
|
|
174
|
+
/**
|
|
175
|
+
* Which side is too thin for a delta to mean anything.
|
|
176
|
+
*
|
|
177
|
+
* Named rather than a boolean because the two take different sentences: too few
|
|
178
|
+
* sessions *since* the change is the ordinary state right after an edit, while too
|
|
179
|
+
* few *before* it means there was never a baseline to compare against.
|
|
180
|
+
*/
|
|
181
|
+
export const GuideHistoryChangeSuppressionSchema = v.picklist(['since', 'before', 'both']);
|
|
182
|
+
/**
|
|
183
|
+
* Which way the pair points, or null while the delta is withheld.
|
|
184
|
+
*
|
|
185
|
+
* A reading of a *set* of sessions, never a verdict on one — the vocabulary
|
|
186
|
+
* `aligned | misaligned | not_applicable` is untouched, and nothing derived
|
|
187
|
+
* here is written back to a row.
|
|
188
|
+
*/
|
|
189
|
+
export const GuideHistoryChangeDirectionSchema = v.picklist([
|
|
190
|
+
'improved',
|
|
191
|
+
'regressed',
|
|
192
|
+
'unchanged',
|
|
193
|
+
]);
|
|
194
|
+
/**
|
|
195
|
+
* The guide's last edit, read as two windows
|
|
196
|
+
* (`insight-to-proven-change` §A, surfaced by `guide-history-for-agents`
|
|
197
|
+
* deliverable 3).
|
|
198
|
+
*
|
|
199
|
+
* > Changed 12 Aug. Before: misaligned in 6 of 8 runs that engaged it.
|
|
200
|
+
* > Since: 0 of 11.
|
|
201
|
+
*
|
|
202
|
+
* **Null on the response is a state, not a missing field.** It means this guide
|
|
203
|
+
* has no earlier wording that produced evidence — a guide on its first
|
|
204
|
+
* revision, which is the normal state and not an error.
|
|
205
|
+
*
|
|
206
|
+
* **Paired, never merged**, and **never causal**: this states two windows and
|
|
207
|
+
* their denominators and stops. The model changed, the task mix changed and the
|
|
208
|
+
* codebase changed too, so "since" is the strongest word the evidence supports.
|
|
209
|
+
*/
|
|
210
|
+
export const GuideHistoryChangeSchema = v.object({
|
|
211
|
+
/** The revision that preceded the change. */
|
|
212
|
+
before: GuideHistoryChangeSideSchema,
|
|
213
|
+
/** The wording the guide stands at now. */
|
|
214
|
+
since: GuideHistoryChangeSideSchema,
|
|
215
|
+
/**
|
|
216
|
+
* `since` minus `before`, in `[-1, 1]`, or **null whenever the pair is
|
|
217
|
+
* suppressed** or either side never engaged the guide. Null is not zero: one
|
|
218
|
+
* says the evidence does not support a number, the other would be a claim.
|
|
219
|
+
*/
|
|
220
|
+
alignmentRateDelta: v.nullable(v.number()),
|
|
221
|
+
/**
|
|
222
|
+
* Which side is below the sample floor, or null when neither is and the delta
|
|
223
|
+
* stands. `'since'` is the ordinary post-edit state — *not enough runs since
|
|
224
|
+
* this change* — and is reported rather than omitted.
|
|
225
|
+
*/
|
|
226
|
+
suppressedBy: v.nullable(GuideHistoryChangeSuppressionSchema),
|
|
227
|
+
/** The delta's sign, or null while it is withheld. `unchanged` is exactly zero. */
|
|
228
|
+
direction: v.nullable(GuideHistoryChangeDirectionSchema),
|
|
229
|
+
/** Either side is a bounded sample, so neither is a lifetime total. */
|
|
230
|
+
isWindowed: v.boolean(),
|
|
231
|
+
/** The per-revision cap each side was bounded by, so "sample" has a size. */
|
|
232
|
+
windowSize: v.pipe(v.number(), v.integer()),
|
|
233
|
+
/**
|
|
234
|
+
* When the current wording was recorded, ISO — the boundary between the two
|
|
235
|
+
* windows, and null when no version row carries it.
|
|
236
|
+
*
|
|
237
|
+
* A date, never an attribution: it says when the window opened, not that the
|
|
238
|
+
* edit caused what happened inside it.
|
|
239
|
+
*/
|
|
240
|
+
changedAt: v.nullable(v.string()),
|
|
241
|
+
});
|
|
242
|
+
/** Findings returned per response, and the character bound on each reasoning. */
|
|
243
|
+
export const MAX_GUIDE_HISTORY_FINDINGS = 5;
|
|
244
|
+
export const MAX_GUIDE_HISTORY_REASONING_CHARS = 1200;
|
|
245
|
+
/**
|
|
246
|
+
* One recorded finding: a session that judged this guide misaligned, and why.
|
|
247
|
+
*
|
|
248
|
+
* `reasoning` arrives **already wrapped in the response's untrusted markers**
|
|
249
|
+
* rather than raw. It is model-authored text derived from a transcript, so the
|
|
250
|
+
* discipline the session grader applies to such text on the way in applies on the
|
|
251
|
+
* way out; wrapping it at the source is what makes the boundary
|
|
252
|
+
* unforgeable, since a consumer handed raw text plus separate markers can
|
|
253
|
+
* simply not use them.
|
|
254
|
+
*
|
|
255
|
+
* `isCurrentRevision` is not optional detail. A payload that scopes its *rate*
|
|
256
|
+
* to the current wording and then hands over reasoning about deleted sentences,
|
|
257
|
+
* unlabelled, reproduces inside one response the conflation
|
|
258
|
+
* `pattern-evidence-guide-revision` removed from the dashboard.
|
|
259
|
+
*/
|
|
260
|
+
export const GuideHistoryFindingSchema = v.object({
|
|
261
|
+
sessionId: NonEmptyStringSchema,
|
|
262
|
+
occurredAt: v.string(),
|
|
263
|
+
revision: v.nullable(GuideHistoryRevisionSchema),
|
|
264
|
+
isCurrentRevision: v.boolean(),
|
|
265
|
+
reasoning: v.string(),
|
|
266
|
+
});
|
|
267
|
+
/** The guide the identifier resolved to, echoed so the agent can check itself. */
|
|
268
|
+
export const GuideHistoryGuideSchema = v.object({
|
|
269
|
+
id: NonEmptyStringSchema,
|
|
270
|
+
title: v.string(),
|
|
271
|
+
path: v.nullable(SafeRelativePosixPathSchema),
|
|
272
|
+
root: v.nullable(GuideDiscoveryRootSchema),
|
|
273
|
+
});
|
|
274
|
+
/**
|
|
275
|
+
* The caller's newest stored failure-pattern analysis of the guide
|
|
276
|
+
* (`drafted-guide-suggestions` slice 7), served through artifact feedback.
|
|
277
|
+
*
|
|
278
|
+
* **The caller's own analysis only.** An analysis reads the caller's verdicts,
|
|
279
|
+
* so a workspace-mate's is never returned, the same rule the verdicts follow.
|
|
280
|
+
*
|
|
281
|
+
* **Staleness is derived on read**: the
|
|
282
|
+
* guide's wording changed since (`revision_changed`), or failures of the same
|
|
283
|
+
* wording arrived that it has not read (`new_failures`, with how many). A stale
|
|
284
|
+
* analysis is still what it found; it is reported, never withheld.
|
|
285
|
+
*
|
|
286
|
+
* `summary` arrives wrapped in the response's untrusted markers. It is
|
|
287
|
+
* model-authored text derived from session transcripts. On `no_pattern` it may
|
|
288
|
+
* be empty between them, because the dashboard supplies that sentence itself.
|
|
289
|
+
*/
|
|
290
|
+
export const GuideHistoryAnalysisSchema = v.object({
|
|
291
|
+
id: NonEmptyStringSchema,
|
|
292
|
+
/** When it was written, ISO. */
|
|
293
|
+
createdAt: v.string(),
|
|
294
|
+
outcome: v.picklist(['pattern', 'no_pattern']),
|
|
295
|
+
summary: v.string(),
|
|
296
|
+
/** Failed sessions the analysis read. */
|
|
297
|
+
sessionsAnalysed: v.pipe(v.number(), v.integer()),
|
|
298
|
+
/** Failed sessions it left out to stay within its prompt's cap. */
|
|
299
|
+
sessionsOmitted: v.pipe(v.number(), v.integer()),
|
|
300
|
+
stale: v.boolean(),
|
|
301
|
+
/** Why it is out of date, or null while it is current. */
|
|
302
|
+
staleReason: v.nullable(v.picklist(['revision_changed', 'new_failures'])),
|
|
303
|
+
/** Failures it has not read, when `staleReason` is `new_failures`; else null. */
|
|
304
|
+
newFailures: v.nullable(v.pipe(v.number(), v.integer())),
|
|
305
|
+
});
|
|
306
|
+
export const GuideHistoryResponseSchema = v.object({
|
|
307
|
+
guide: GuideHistoryGuideSchema,
|
|
308
|
+
/** The wording the window is about, or null when the guide has no revision identity. */
|
|
309
|
+
currentRevision: v.nullable(GuideHistoryRevisionSchema),
|
|
310
|
+
state: GuideHistoryStateSchema,
|
|
311
|
+
window: GuideHistoryWindowSchema,
|
|
312
|
+
/**
|
|
313
|
+
* The last edit's two windows, or **null when there is no earlier wording to
|
|
314
|
+
* compare against**.
|
|
315
|
+
*
|
|
316
|
+
* Present-and-null rather than omitted: a guide on its first revision has no
|
|
317
|
+
* delta, and that is an answer. An absent key would leave a reader unable to
|
|
318
|
+
* tell "no edit to measure" from "this server does not report deltas".
|
|
319
|
+
*/
|
|
320
|
+
change: v.nullable(GuideHistoryChangeSchema),
|
|
321
|
+
findings: v.array(GuideHistoryFindingSchema),
|
|
322
|
+
/**
|
|
323
|
+
* Misaligned rows in the window beyond the `MAX_GUIDE_HISTORY_FINDINGS`
|
|
324
|
+
* returned. Reported rather than silently truncated: a caller reading five
|
|
325
|
+
* findings has no other way to know it is reading five of forty.
|
|
326
|
+
*/
|
|
327
|
+
findingsOmitted: v.pipe(v.number(), v.integer()),
|
|
328
|
+
/**
|
|
329
|
+
* The caller's newest stored failure-pattern analysis of this guide, or
|
|
330
|
+
* **null when they have never asked for one**. Optional because a server
|
|
331
|
+
* that predates it sends no key; a reader must not take absence for "never
|
|
332
|
+
* analysed".
|
|
333
|
+
*/
|
|
334
|
+
analysis: v.optional(v.nullable(GuideHistoryAnalysisSchema)),
|
|
335
|
+
untrusted: GuideHistoryUntrustedSchema,
|
|
336
|
+
});
|
|
337
|
+
export function parseGuideHistoryRequest(data) {
|
|
338
|
+
return v.parse(GuideHistoryRequestSchema, data);
|
|
339
|
+
}
|
|
340
|
+
export function parseGuideHistoryResponse(data) {
|
|
341
|
+
return v.parse(GuideHistoryResponseSchema, data);
|
|
342
|
+
}
|
|
343
|
+
//# sourceMappingURL=guideHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guideHistory.js","sourceRoot":"","sources":["../src/guideHistory.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAE7E,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAA;AAE5B,8EAA8E;AAC9E,mDAAmD;AACnD,8EAA8E;AAE9E;;;;;;;;GAQG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,IAAI,CAChD,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,IAAI,EAAE,EACR,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EACd,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAChB,CAAC,CAAC,KAAK,CACL,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,uBAAuB,CAA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CACvC,CAAC,CAAA;AAIF,MAAM,UAAU,wBAAwB,CAAC,IAAa;IACpD,OAAO,CAAC,CAAC,KAAK,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,IAAa;IACrD,OAAO,CAAC,CAAC,KAAK,CAAC,0BAA0B,EAAE,IAAI,CAAC,CAAA;AAClD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guideHistory.test.d.ts","sourceRoot":"","sources":["../src/guideHistory.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
3
|
+
import * as history from './guideHistory.js';
|
|
4
|
+
import * as protocol from './index.js';
|
|
5
|
+
import * as schemas from './schemas.js';
|
|
6
|
+
import * as primitives from './wirePrimitives.js';
|
|
7
|
+
describe('guide-history contract extraction', () => {
|
|
8
|
+
it('preserves aggregate exports and shared schema identity', () => {
|
|
9
|
+
for (const [name, value] of Object.entries(history)) {
|
|
10
|
+
expect(Reflect.get(schemas, name), name).toBe(value);
|
|
11
|
+
expect(Reflect.get(protocol, name), name).toBe(value);
|
|
12
|
+
}
|
|
13
|
+
expect(history.GuideHistoryRequestSchema.entries.root.wrapped).toBe(primitives.GuideDiscoveryRootSchema);
|
|
14
|
+
expect(history.GuideHistoryGuideSchema.entries.path.wrapped).toBe(primitives.SafeRelativePosixPathSchema);
|
|
15
|
+
expect(history.GuideHistoryResponseSchema.entries.untrusted).toBe(primitives.GuideHistoryUntrustedSchema);
|
|
16
|
+
expect(schemas.ArtifactFeedbackResponseSchema.entries.grading.wrapped).toBe(history.GuideHistoryResponseSchema);
|
|
17
|
+
expect(schemas.SafeRelativePosixPathSchema).toBe(primitives.SafeRelativePosixPathSchema);
|
|
18
|
+
expect(schemas.GuideDiscoveryRootSchema).toBe(primitives.GuideDiscoveryRootSchema);
|
|
19
|
+
expect(schemas.PATH_ISSUE_MESSAGES).toBe(primitives.PATH_ISSUE_MESSAGES);
|
|
20
|
+
});
|
|
21
|
+
it('keeps inferred consumer types and optional request fields', () => {
|
|
22
|
+
expectTypeOf().toEqualTypeOf();
|
|
23
|
+
expectTypeOf().toEqualTypeOf();
|
|
24
|
+
expectTypeOf().toEqualTypeOf();
|
|
25
|
+
expectTypeOf(history.parseGuideHistoryRequest).returns.toEqualTypeOf();
|
|
26
|
+
expectTypeOf(history.parseGuideHistoryResponse).returns.toEqualTypeOf();
|
|
27
|
+
expect(protocol.parseGuideHistoryRequest({ guide: ' AGENTS.md ', ignored: true })).toEqual({
|
|
28
|
+
guide: 'AGENTS.md',
|
|
29
|
+
});
|
|
30
|
+
for (const field of ['root', 'projectId', 'repoId', 'guideId']) {
|
|
31
|
+
expect(() => history.parseGuideHistoryRequest({ guide: 'a', [field]: null })).toThrow(v.ValiError);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=guideHistory.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guideHistory.test.js","sourceRoot":"","sources":["../src/guideHistory.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE3D,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AAIjD,QAAQ,CAAC,mCAAmC,EAAE,GAAG,EAAE;IACjD,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAChE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAA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