@mossbear/protocol 0.1.0-alpha.115 → 0.1.0-alpha.116

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.
Files changed (45) hide show
  1. package/dist/bundles.d.ts +662 -0
  2. package/dist/bundles.d.ts.map +1 -0
  3. package/dist/bundles.js +454 -0
  4. package/dist/bundles.js.map +1 -0
  5. package/dist/bundles.test.d.ts +2 -0
  6. package/dist/bundles.test.d.ts.map +1 -0
  7. package/dist/bundles.test.js +61 -0
  8. package/dist/bundles.test.js.map +1 -0
  9. package/dist/guideHistory.d.ts +643 -0
  10. package/dist/guideHistory.d.ts.map +1 -0
  11. package/dist/guideHistory.js +343 -0
  12. package/dist/guideHistory.js.map +1 -0
  13. package/dist/guideHistory.test.d.ts +2 -0
  14. package/dist/guideHistory.test.d.ts.map +1 -0
  15. package/dist/guideHistory.test.js +35 -0
  16. package/dist/guideHistory.test.js.map +1 -0
  17. package/dist/guideImport.d.ts +398 -0
  18. package/dist/guideImport.d.ts.map +1 -0
  19. package/dist/guideImport.js +350 -0
  20. package/dist/guideImport.js.map +1 -0
  21. package/dist/guideImport.test.d.ts +2 -0
  22. package/dist/guideImport.test.d.ts.map +1 -0
  23. package/dist/guideImport.test.js +62 -0
  24. package/dist/guideImport.test.js.map +1 -0
  25. package/dist/guideSnapshot.d.ts +105 -0
  26. package/dist/guideSnapshot.d.ts.map +1 -0
  27. package/dist/guideSnapshot.js +101 -0
  28. package/dist/guideSnapshot.js.map +1 -0
  29. package/dist/guideSnapshot.test.d.ts +2 -0
  30. package/dist/guideSnapshot.test.d.ts.map +1 -0
  31. package/dist/guideSnapshot.test.js +49 -0
  32. package/dist/guideSnapshot.test.js.map +1 -0
  33. package/dist/pairing.d.ts +1 -1
  34. package/dist/schemas.d.ts +14 -2042
  35. package/dist/schemas.d.ts.map +1 -1
  36. package/dist/schemas.js +13 -1358
  37. package/dist/schemas.js.map +1 -1
  38. package/dist/types.d.ts +4 -27
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/types.js.map +1 -1
  41. package/dist/wirePrimitives.d.ts +87 -0
  42. package/dist/wirePrimitives.d.ts.map +1 -1
  43. package/dist/wirePrimitives.js +121 -0
  44. package/dist/wirePrimitives.js.map +1 -1
  45. package/package.json +1 -1
@@ -0,0 +1,398 @@
1
+ /** Raw guide import and unlink wire contracts. */
2
+ import * as v from 'valibot';
3
+ export declare const GuideFileFormatSchema: v.PicklistSchema<["agents-md", "agents-dir", "claude-md", "claude-rules", "cursorrules", "cursor-rules", "skill-md"], undefined>;
4
+ /** Max member files a single skill-md payload may carry. */
5
+ export declare const MAX_SKILL_MEMBER_FILES = 64;
6
+ export declare const SkillMemberPathSchema: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>, v.CheckAction<string, "path must not shadow the skill’s own SKILL.md">]>;
7
+ export declare const RawSkillMemberFileSchema: v.ObjectSchema<{
8
+ readonly path: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>, v.CheckAction<string, "path must not shadow the skill’s own SKILL.md">]>;
9
+ readonly rawContent: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "rawContent must be at most 524288 bytes">]>;
10
+ readonly lastModified: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
11
+ readonly content_hash: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
12
+ /**
13
+ * Whether the file is executable (`100755` in git), so delivery writes it
14
+ * `0o755` or `0o644`. A boolean rather than a mode because git records only
15
+ * those two for a blob, and a numeric mode would be a channel for bits
16
+ * nothing here should set. **Absent is not `false`**: a CLI that predates the
17
+ * field sends none, and the server then keeps whatever it already holds.
18
+ */
19
+ readonly executable: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
20
+ }, undefined>;
21
+ /** Max skipped-member paths a skill-md payload may report alongside `members`. */
22
+ export declare const MAX_SKILL_SKIPPED_MEMBER_PATHS = 256;
23
+ export declare const RawGuideFilePayloadSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
24
+ readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>;
25
+ readonly root: v.OptionalSchema<v.PicklistSchema<["project", "global"], undefined>, undefined>;
26
+ readonly format: v.PicklistSchema<["agents-md", "agents-dir", "claude-md", "claude-rules", "cursorrules", "cursor-rules", "skill-md"], undefined>;
27
+ readonly rawContent: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "rawContent must be at most 524288 bytes">]>;
28
+ readonly lastModified: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
29
+ readonly content_hash: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
30
+ readonly members: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
31
+ readonly path: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>, v.CheckAction<string, "path must not shadow the skill’s own SKILL.md">]>;
32
+ readonly rawContent: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "rawContent must be at most 524288 bytes">]>;
33
+ readonly lastModified: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
34
+ readonly content_hash: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, undefined>]>;
35
+ /**
36
+ * Whether the file is executable (`100755` in git), so delivery writes it
37
+ * `0o755` or `0o644`. A boolean rather than a mode because git records only
38
+ * those two for a blob, and a numeric mode would be a channel for bits
39
+ * nothing here should set. **Absent is not `false`**: a CLI that predates the
40
+ * field sends none, and the server then keeps whatever it already holds.
41
+ */
42
+ readonly executable: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
43
+ }, undefined>, undefined>, v.MaxLengthAction<{
44
+ path: string;
45
+ rawContent: string;
46
+ lastModified: number;
47
+ content_hash: string;
48
+ executable?: boolean | undefined;
49
+ }[], 64, undefined>]>, undefined>;
50
+ /**
51
+ * The body-item version this machine last agreed with the server about for
52
+ * this `(scope, root, path)` — the machine-local baseline
53
+ * (`guide-versioned-identity-plan.md` → slice 2b-B, D10 in
54
+ * `context-bundle-authoring-plan.md`).
55
+ *
56
+ * It is the *client* half of the reconcile precondition, and it exists to
57
+ * answer a question the server cannot: whether the bytes on this disk were
58
+ * edited **from** the version the server currently holds, or from an older
59
+ * one. The server-only guard shipped in 2b-A can see that a dashboard edit
60
+ * exists, never that this machine has already seen it — so a guide the
61
+ * dashboard edited and the user then re-synced to disk forks forever.
62
+ *
63
+ * **Optional, and its absence is not an error.** A CLI predating the
64
+ * baseline store, a fresh machine, or a deleted `~/.mossbear/state/` sends
65
+ * none, and the payload falls back to the server-only guard exactly as it
66
+ * behaves today. Absence therefore degrades to "decline and fork", never to
67
+ * an overwrite; a *stale* value degrades to a reported conflict.
68
+ */
69
+ readonly expectedVersion: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>, undefined>;
70
+ readonly skippedMemberPaths: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>]>, undefined>, v.MaxLengthAction<string[], 256, undefined>]>, undefined>;
71
+ }, undefined>, v.CheckAction<{
72
+ path: string;
73
+ root?: "project" | "global" | undefined;
74
+ format: "agents-md" | "agents-dir" | "claude-md" | "claude-rules" | "cursorrules" | "cursor-rules" | "skill-md";
75
+ rawContent: string;
76
+ lastModified: number;
77
+ content_hash: string;
78
+ members?: {
79
+ path: string;
80
+ rawContent: string;
81
+ lastModified: number;
82
+ content_hash: string;
83
+ executable?: boolean | undefined;
84
+ }[] | undefined;
85
+ expectedVersion?: number | undefined;
86
+ skippedMemberPaths?: string[] | undefined;
87
+ }, "members are only supported on skill-md payloads">, v.CheckAction<{
88
+ path: string;
89
+ root?: "project" | "global" | undefined;
90
+ format: "agents-md" | "agents-dir" | "claude-md" | "claude-rules" | "cursorrules" | "cursor-rules" | "skill-md";
91
+ rawContent: string;
92
+ lastModified: number;
93
+ content_hash: string;
94
+ members?: {
95
+ path: string;
96
+ rawContent: string;
97
+ lastModified: number;
98
+ content_hash: string;
99
+ executable?: boolean | undefined;
100
+ }[] | undefined;
101
+ expectedVersion?: number | undefined;
102
+ skippedMemberPaths?: string[] | undefined;
103
+ }, "skippedMemberPaths requires members">, v.CheckAction<{
104
+ path: string;
105
+ root?: "project" | "global" | undefined;
106
+ format: "agents-md" | "agents-dir" | "claude-md" | "claude-rules" | "cursorrules" | "cursor-rules" | "skill-md";
107
+ rawContent: string;
108
+ lastModified: number;
109
+ content_hash: string;
110
+ members?: {
111
+ path: string;
112
+ rawContent: string;
113
+ lastModified: number;
114
+ content_hash: string;
115
+ executable?: boolean | undefined;
116
+ }[] | undefined;
117
+ expectedVersion?: number | undefined;
118
+ skippedMemberPaths?: string[] | undefined;
119
+ }, "member paths must be unique (case-insensitive)">]>;
120
+ /** Max number of rules accepted in a single `POST /api/rules/import` request. */
121
+ export declare const MAX_RULES_IMPORT_BATCH = 100;
122
+ export declare const RulesImportRequestSchema: v.ObjectSchema<{
123
+ readonly rules: v.SchemaWithPipe<readonly [v.ArraySchema<v.UnknownSchema, undefined>, v.MaxLengthAction<unknown[], 100, undefined>]>;
124
+ /**
125
+ * Which checkout these files came from — the same opaque digest the hook and
126
+ * the rule manifest already carry (`packages/cli/src/repo-id.ts`,
127
+ * `RuleManifestSchema.repoId`). Envelope-level, not per-file: every file in
128
+ * one import comes from one repo, and the per-file payload stays lean (the
129
+ * "Import endpoint payload" resolved decision).
130
+ *
131
+ * It is what lets the server reconcile an edited file back onto the guide it
132
+ * already created instead of inserting a second one. `origin` alone cannot:
133
+ * it is `file:{format}:{path}` with no repo component, so two checkouts
134
+ * sharing `.agents/code-style.md` would collide.
135
+ *
136
+ * **Optional, and its absence is not an error.** A CLI predating this field
137
+ * sends none, and the server falls back to the content-hash dedupe it always
138
+ * used. Never send a repo id derived anywhere but `repoIdFromRoot` — the
139
+ * digest is keyed by a machine-local secret precisely so the server never
140
+ * learns a path.
141
+ *
142
+ * Shaped by the canonical `RepoIdSchema` (shared with run logs and manifests)
143
+ * rather than a looser local check: a row storing anything but
144
+ * a real digest could never match one, so a malformed identity has to be
145
+ * rejected at the boundary instead of persisted as a permanent orphan.
146
+ */
147
+ readonly repoId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "repoId must be repo_ followed by 32 hex chars">]>, undefined>;
148
+ /**
149
+ * The repo's **portable** identity — `project.id` from the committed
150
+ * `<repo>/.mossbear/config.json` (`guide-write-side-identity` slice 1, shipped in
151
+ * #540). This is what makes `(scope, path)` reconciliation portable, and it is
152
+ * the field `unified-item-sync` slice 2 exists to put on the wire.
153
+ *
154
+ * **Why `repoId` is not enough, even though it is already here.**
155
+ * `repoIdFromRoot` is an HMAC keyed by a machine-local secret
156
+ * (`packages/cli/src/repo-id.ts`), so the same checkout on two machines — or
157
+ * one teammate's clone versus another's — produces two different digests. A
158
+ * guide reconciled on it therefore forks the moment anyone else edits the
159
+ * file, which is the one-way trip this item is closing. `projectId` is
160
+ * declared in a committed file, so every clone agrees on it.
161
+ *
162
+ * **Optional, and its absence is not an error.** A CLI predating this field
163
+ * sends none and the server falls back to `repoId` scoping, which is exactly
164
+ * the behaviour those clients already have. A repo that has never run
165
+ * `mossbear init` also has no declaration, and must keep importing.
166
+ *
167
+ * Deliberately looser than `RepoIdSchema`: a generated id is
168
+ * `proj_`+hex, but a *declared* one is whatever a human committed —
169
+ * `readRepoProjectId` accepts any non-empty trimmed string
170
+ * (`packages/cli/src/artifacts/repo-config.ts`), and rejecting those here would
171
+ * break a shipped contract. Constrained only as far as it must be to serve as
172
+ * a storage key: no whitespace, no path separators, no control characters,
173
+ * bounded length.
174
+ */
175
+ readonly projectId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, "projectId must contain only letters, digits, underscore, dot or hyphen">]>, undefined>;
176
+ /**
177
+ * The workspace this repo declares its project-scoped guidance belongs to —
178
+ * `workspace.id` from the committed `<repo>/.mossbear/config.json`
179
+ * (`workspace-declaration` slice 1).
180
+ *
181
+ * **What it changes: which of the caller's workspaces a project path resolves
182
+ * in.** Import identity is already scoped by workspace *membership* rather
183
+ * than authorship, so a caller in several workspaces has several candidate
184
+ * rows at one `(project, root, path)` and the resolver picked between them by
185
+ * row age. The declaration is the narrower lookup that removes the guess, and
186
+ * it is committed so every clone of the repo narrows the same way.
187
+ *
188
+ * **Membership stays the boundary; this only narrows inside it.** The
189
+ * declaration cannot widen what a caller may reach: a workspace they are not a
190
+ * member of is refused by name rather than resolved, and never quietly
191
+ * replaced by their personal one — falling back would recreate the fork the
192
+ * declaration exists to close.
193
+ *
194
+ * **Envelope-level, and never sent on a global batch.** It is the *repo's*
195
+ * declaration, so it travels with the same batch that carries `repoId` and
196
+ * `projectId`; a `root: 'global'` file belongs to no checkout and to no
197
+ * project, and by the same rule to no repo-declared workspace.
198
+ *
199
+ * **Optional, and its absence is not an error.** A CLI predating this field
200
+ * sends none, and a repo that has never declared one has none to send; both
201
+ * keep the resolution they have today.
202
+ */
203
+ readonly workspaceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 128, undefined>, v.RegexAction<string, "workspaceId must contain only letters, digits, underscore, dot or hyphen">]>, undefined>;
204
+ }, undefined>;
205
+ /**
206
+ * What the server did with one payload, reported per file so the CLI can update
207
+ * its machine-local baseline (`guide-versioned-identity-plan.md` → slice 2b-B).
208
+ *
209
+ * The distinction that matters is not "did something change" but **do disk and
210
+ * server now agree**: `imported`, `updated` and `skipped` all mean they do, and
211
+ * only those license recording a new baseline. `conflict` means the disk bytes
212
+ * did *not* land — recording the server's version for one would hand the next
213
+ * import a matching `expectedVersion` and turn a refused overwrite into an
214
+ * automatic one on the following run, which is the failure this whole precondition
215
+ * exists to prevent.
216
+ */
217
+ export declare const GuideImportOutcomeSchema: v.PicklistSchema<["imported", "updated", "skipped", "conflict"], undefined>;
218
+ /**
219
+ * Per-payload import outcome, addressed by the same `(root, path)` pair the
220
+ * server reconciles on so the CLI can key its baseline identically without
221
+ * re-deriving anything.
222
+ *
223
+ * `version` is the body item's version **as the server holds it after this
224
+ * request** — the value a later import should send as `expectedVersion` once
225
+ * disk and server agree. It is reported for a `conflict` too, deliberately: the
226
+ * conflict report needs it to offer explicit resolution, and reporting it is not
227
+ * the same as recording it.
228
+ *
229
+ * Entries are omitted for a payload the server could not address at all (no
230
+ * `root`, or a pre-R0 row): there is no identity to key a baseline on, and
231
+ * inventing one would let a later import claim a precondition it never observed.
232
+ */
233
+ export declare const GuideImportResultSchema: v.ObjectSchema<{
234
+ /** Canonical guide identity for review links; absent on older servers. */
235
+ readonly guideId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>;
236
+ readonly root: v.PicklistSchema<["project", "global"], undefined>;
237
+ readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>;
238
+ readonly outcome: v.PicklistSchema<["imported", "updated", "skipped", "conflict"], undefined>;
239
+ readonly version: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
240
+ }, undefined>;
241
+ export type GuideImportResult = v.InferOutput<typeof GuideImportResultSchema>;
242
+ /** Max alias sets one import response reports as divergent. */
243
+ export declare const MAX_GUIDE_IMPORT_DIVERGENCES = 64;
244
+ /**
245
+ * An alias set the server found in one import but **did not** collapse, because
246
+ * the files do not hold the same rules
247
+ * (`alias-instruction-file-identity-plan.md` → second addendum,
248
+ * 2026-09-03).
249
+ *
250
+ * Reporting rather than refusing is the whole point. An identical
251
+ * `AGENTS.md`/`.cursorrules` pair becomes one guide; a divergent one imports as
252
+ * two guides exactly as it does today, and this names the paths so the user can
253
+ * see the drift the product would otherwise have kept silent. Nothing about the
254
+ * import fails, and nothing the user does today stops working.
255
+ *
256
+ * `paths` carries every path in the set this request saw, in the order the
257
+ * server ranks them — so the first is the one that would have kept the body had
258
+ * they matched.
259
+ */
260
+ export declare const GuideImportDivergenceSchema: v.ObjectSchema<{
261
+ readonly root: v.PicklistSchema<["project", "global"], undefined>;
262
+ readonly paths: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>, undefined>, v.MinLengthAction<string[], 2, undefined>]>;
263
+ }, undefined>;
264
+ export type GuideImportDivergence = v.InferOutput<typeof GuideImportDivergenceSchema>;
265
+ /**
266
+ * An alias pair one import left as **two guides**, because a guide was already
267
+ * stored at the incoming file's alias partner path and the pair could not be
268
+ * collapsed onto it (`skill-alias-collapse-managed-file-plan.md` →
269
+ * *Reporting*).
270
+ *
271
+ * Distinct from {@link GuideImportDivergenceSchema}, which says the files
272
+ * differ. This one says only that the fork happened — the reasons are several
273
+ * (the bodies differ, the skill directories around them could not be proven to
274
+ * match, the partner path already answers to a second guide) and the import
275
+ * cannot always tell them apart, so it names the pair and leaves the reading to
276
+ * whoever wrote the files. Reported only when a guide was *created* at the
277
+ * incoming path, so a repo re-importing a pair that forked long ago stays
278
+ * quiet.
279
+ *
280
+ * `paths` is the incoming file first, then the partner already stored.
281
+ */
282
+ export declare const GuideImportAliasForkSchema: v.ObjectSchema<{
283
+ readonly root: v.PicklistSchema<["project", "global"], undefined>;
284
+ readonly paths: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>, undefined>, v.MinLengthAction<string[], 2, undefined>]>;
285
+ }, undefined>;
286
+ export type GuideImportAliasFork = v.InferOutput<typeof GuideImportAliasForkSchema>;
287
+ /**
288
+ * One guide to stop delivering, addressed the way the **import** route already
289
+ * resolves an existing guide: `(root, path)` plus the envelope's checkout and
290
+ * project identity.
291
+ *
292
+ * **Deliberately not `origin`.** `file:{format}:{path}` is not unique — every
293
+ * repo has an `AGENTS.md`, so an origin-keyed request disables the matching
294
+ * guide in every repo in the workspace. That is the defect that sank the first
295
+ * implementation of this verb. `(root, path)` scoped by `repoId`/`projectId`
296
+ * is the key the import route reconciles on, so unlink addresses exactly the
297
+ * row link created and no other.
298
+ */
299
+ export declare const RawGuideUnlinkSchema: v.ObjectSchema<{
300
+ readonly root: v.PicklistSchema<["project", "global"], undefined>;
301
+ /**
302
+ * The canonical guide-path validator, not a fresh `v.string()`: it already
303
+ * rejects absolute paths, control characters and `..` traversal, and a second
304
+ * hand-rolled constraint here would be a place for the two to disagree.
305
+ */
306
+ readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>;
307
+ }, undefined>;
308
+ export type RawGuideUnlink = v.InferOutput<typeof RawGuideUnlinkSchema>;
309
+ /** Max guides accepted in a single `POST /api/rules/unlink` request. */
310
+ export declare const MAX_RULE_UNLINK_BATCH = 500;
311
+ export declare const RuleUnlinkRequestSchema: v.ObjectSchema<{
312
+ readonly unlinks: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
313
+ readonly root: v.PicklistSchema<["project", "global"], undefined>;
314
+ /**
315
+ * The canonical guide-path validator, not a fresh `v.string()`: it already
316
+ * rejects absolute paths, control characters and `..` traversal, and a second
317
+ * hand-rolled constraint here would be a place for the two to disagree.
318
+ */
319
+ readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>;
320
+ }, undefined>, undefined>, v.MaxLengthAction<{
321
+ root: "project" | "global";
322
+ path: string;
323
+ }[], 500, undefined>]>;
324
+ /** Same envelope identity the import route carries, and for the same reason. */
325
+ readonly repoId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
326
+ readonly projectId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
327
+ }, undefined>;
328
+ export type RuleUnlinkRequest = v.InferOutput<typeof RuleUnlinkRequestSchema>;
329
+ /**
330
+ * `unlinked` counts guides removed from the default bundle; `skipped` counts
331
+ * requested paths that resolved to nothing, or were already out of it.
332
+ *
333
+ * `stillDelivered` names guides that remain in *other* bundles the caller can
334
+ * reach — including a teammate's, since a bundle shared into a workspace they
335
+ * belong to keeps arriving whoever owns it. Unlink is the exact inverse of what
336
+ * link does — it removes the default-bundle membership link created — so a
337
+ * guide someone deliberately added to a curated bundle stays there, and saying
338
+ * so is the difference between a true report and a reassuring one.
339
+ *
340
+ * `released` names the requested paths whose guide is now in **no** bundle the
341
+ * caller can reach, so nothing delivers it any more. It exists because the
342
+ * caller holds a fact the server does not: the local placement record that
343
+ * marks a path as managed by a bundle. A path taken out of every bundle and
344
+ * still recorded as bundle-managed is two answers to one question, and only the
345
+ * server can tell which paths genuinely stopped being delivered. Note this is
346
+ * not on its own enough to make a re-link restore delivery — the import route
347
+ * enrols only the guide rows its insert creates — so a caller acting on this
348
+ * should not report the path as re-adoptable.
349
+ *
350
+ * Optional with an empty default, so a client on this version still parses a
351
+ * response from a deployment that predates the field.
352
+ */
353
+ export declare const RuleUnlinkResponseSchema: v.ObjectSchema<{
354
+ readonly unlinked: v.NumberSchema<undefined>;
355
+ readonly skipped: v.NumberSchema<undefined>;
356
+ readonly stillDelivered: v.ArraySchema<v.StringSchema<undefined>, undefined>;
357
+ readonly released: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
358
+ readonly root: v.PicklistSchema<["project", "global"], undefined>;
359
+ /**
360
+ * The canonical guide-path validator, not a fresh `v.string()`: it already
361
+ * rejects absolute paths, control characters and `..` traversal, and a second
362
+ * hand-rolled constraint here would be a place for the two to disagree.
363
+ */
364
+ readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 512, undefined>, v.CheckAction<string, "path must use forward slashes">, v.CheckAction<string, "path must be relative">, v.CheckAction<string, "path must not contain control characters">, v.CheckAction<string, "path must not contain empty, \".\" or \"..\" segments">]>;
365
+ }, undefined>, undefined>, readonly []>;
366
+ }, undefined>;
367
+ export type RuleUnlinkResponse = v.InferOutput<typeof RuleUnlinkResponseSchema>;
368
+ export declare function parseRuleUnlinkRequest(data: unknown): {
369
+ unlinks: {
370
+ root: "project" | "global";
371
+ path: string;
372
+ }[];
373
+ repoId?: string | undefined;
374
+ projectId?: string | undefined;
375
+ };
376
+ export declare function parseRawGuideFilePayload(data: unknown): {
377
+ path: string;
378
+ root?: "project" | "global" | undefined;
379
+ format: "agents-md" | "agents-dir" | "claude-md" | "claude-rules" | "cursorrules" | "cursor-rules" | "skill-md";
380
+ rawContent: string;
381
+ lastModified: number;
382
+ content_hash: string;
383
+ members?: {
384
+ path: string;
385
+ rawContent: string;
386
+ lastModified: number;
387
+ content_hash: string;
388
+ executable?: boolean | undefined;
389
+ }[] | undefined;
390
+ expectedVersion?: number | undefined;
391
+ skippedMemberPaths?: string[] | undefined;
392
+ };
393
+ /** Supported raw guide file format. */
394
+ export type GuideFileFormat = v.InferOutput<typeof GuideFileFormatSchema>;
395
+ export type RawGuideFilePayload = v.InferOutput<typeof RawGuideFilePayloadSchema>;
396
+ export type RawSkillMemberFile = v.InferOutput<typeof RawSkillMemberFileSchema>;
397
+ export type RulesImportRequest = v.InferOutput<typeof RulesImportRequestSchema>;
398
+ //#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