@cleocode/contracts 2026.5.62 → 2026.5.64

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 (36) hide show
  1. package/dist/__tests__/llm-config-schema.test.d.ts +20 -0
  2. package/dist/__tests__/llm-config-schema.test.d.ts.map +1 -0
  3. package/dist/__tests__/llm-config-schema.test.js +121 -0
  4. package/dist/__tests__/llm-config-schema.test.js.map +1 -0
  5. package/dist/config.d.ts +95 -5
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/index.d.ts +6 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/operations/llm.d.ts +380 -0
  11. package/dist/operations/llm.d.ts.map +1 -1
  12. package/dist/project-context.d.ts +69 -0
  13. package/dist/project-context.d.ts.map +1 -0
  14. package/dist/project-context.js +14 -0
  15. package/dist/project-context.js.map +1 -0
  16. package/dist/release/channel.d.ts +20 -0
  17. package/dist/release/channel.d.ts.map +1 -0
  18. package/dist/release/channel.js +12 -0
  19. package/dist/release/channel.js.map +1 -0
  20. package/dist/release/github-pr.d.ts +79 -0
  21. package/dist/release/github-pr.d.ts.map +1 -0
  22. package/dist/release/github-pr.js +12 -0
  23. package/dist/release/github-pr.js.map +1 -0
  24. package/dist/release/version-bump.d.ts +73 -0
  25. package/dist/release/version-bump.d.ts.map +1 -0
  26. package/dist/release/version-bump.js +12 -0
  27. package/dist/release/version-bump.js.map +1 -0
  28. package/package.json +2 -2
  29. package/src/__tests__/llm-config-schema.test.ts +135 -0
  30. package/src/config.ts +100 -5
  31. package/src/index.ts +67 -0
  32. package/src/operations/llm.ts +437 -0
  33. package/src/project-context.ts +106 -0
  34. package/src/release/channel.ts +21 -0
  35. package/src/release/github-pr.ts +89 -0
  36. package/src/release/version-bump.ts +79 -0
@@ -56,6 +56,15 @@ export interface ModelConfig {
56
56
  cachePolicy?: PromptCachePolicy | null;
57
57
  /** Fallback model config used on final retry attempt. */
58
58
  fallback?: Omit<ModelConfig, 'fallback'> | null;
59
+ /**
60
+ * Extra HTTP headers to attach to the provider client (merged into the SDK's
61
+ * `defaultHeaders`). Populated from `authHeaders(cred)` when a credential is
62
+ * resolved with `authType: 'oauth'` so the provider client uses the
63
+ * `Authorization: Bearer …` scheme instead of `x-api-key`.
64
+ *
65
+ * @task T-LLM-CRED-CENTRALIZATION Phase 1
66
+ */
67
+ extraHeaders?: Record<string, string> | null;
59
68
  }
60
69
 
61
70
  /** Parameters for a single LLM call. */
@@ -113,3 +122,431 @@ export interface LLMCallResult<T = string> {
113
122
  thinkingBlocks: Array<Record<string, unknown>>;
114
123
  reasoningDetails: Array<Record<string, unknown>>;
115
124
  }
125
+
126
+ // ============================================================================
127
+ // Credential resolution wire types (T-LLM-CRED-CENTRALIZATION Phase 1/2)
128
+ //
129
+ // These mirror the runtime types declared in `@cleocode/core/llm/credentials.ts`
130
+ // but live here so packages outside `core` (CLI, harness, studio) can speak
131
+ // the same wire vocabulary without taking a dependency on core internals.
132
+ // The runtime module re-exports compatible aliases so existing imports keep
133
+ // working.
134
+ // ============================================================================
135
+
136
+ /**
137
+ * Which credential-resolution tier produced a {@link CredentialResultWire}.
138
+ *
139
+ * Mirrors `CredentialSource` in `@cleocode/core/llm/credentials.ts`. The set is
140
+ * append-only; new tiers (e.g. `aws-sdk`, `gcp-sdk` in Phase 3) extend this
141
+ * union.
142
+ *
143
+ * @task T-LLM-CRED-CENTRALIZATION Phase 1
144
+ * @task T9255
145
+ */
146
+ export type CredentialSourceWire =
147
+ | 'explicit'
148
+ | 'env'
149
+ | 'cred-file'
150
+ | 'claude-creds'
151
+ | 'global-config'
152
+ | 'project-config';
153
+
154
+ /**
155
+ * Authentication scheme used when sending the credential to the provider.
156
+ *
157
+ * - `api_key` — provider-issued long-lived key sent as `x-api-key` (Anthropic)
158
+ * or `Authorization: Bearer …` (OpenAI, Gemini, Moonshot).
159
+ * - `oauth` — short-lived OAuth bearer token sent as `Authorization: Bearer …`
160
+ * with the matching beta header.
161
+ *
162
+ * @task T-LLM-CRED-CENTRALIZATION Phase 1
163
+ * @task T9255
164
+ */
165
+ export type AuthTypeWire = 'api_key' | 'oauth';
166
+
167
+ /**
168
+ * Resolved credential as returned by `resolveCredentials()` /
169
+ * `resolveLLMForRole()`. Mirrors `CredentialResult` in core. Compatible by
170
+ * structural typing.
171
+ *
172
+ * @task T-LLM-CRED-CENTRALIZATION Phase 1
173
+ * @task T9255
174
+ */
175
+ export interface CredentialResultWire {
176
+ /** Provider transport this credential is for. */
177
+ provider: ModelTransport;
178
+ /** API key or OAuth bearer token. `null` only when no credential was found. */
179
+ apiKey: string | null;
180
+ /** Which tier produced this credential. `undefined` when `apiKey` is `null`. */
181
+ source: CredentialSourceWire | undefined;
182
+ /** Scheme used to present the credential to the provider. */
183
+ authType: AuthTypeWire;
184
+ }
185
+
186
+ // ============================================================================
187
+ // Role-based LLM resolution wire types (T9255 — Phase 2 T-llm-1)
188
+ // ============================================================================
189
+
190
+ /**
191
+ * Which configuration tier produced a {@link ResolvedLLM}.
192
+ *
193
+ * Resolution chain order:
194
+ * 1. `role` — `config.llm.roles[role]` (explicit override)
195
+ * 2. `default` — `config.llm.default` (canonical default)
196
+ * 3. `daemon-legacy` — `config.llm.daemon` (deprecated alias)
197
+ * 4. `implicit-fallback` — hard-coded fallback inside the resolver
198
+ *
199
+ * Useful for `cleo llm whoami` diagnostics and for migration tooling that
200
+ * needs to identify call-sites still on the legacy `daemon` block.
201
+ *
202
+ * @task T9255
203
+ */
204
+ export type ResolutionSource = 'role' | 'default' | 'daemon-legacy' | 'implicit-fallback';
205
+
206
+ /**
207
+ * Result envelope returned by `resolveLLMForRole(role)`.
208
+ *
209
+ * Carries the fully-wired SDK client plus the {@link CredentialResultWire}
210
+ * so raw-fetch callers (sleep-consolidation, observer-reflector, hygiene-scan)
211
+ * can call `authHeaders(credential)` themselves when bypassing the SDK
212
+ * client (e.g. to call the Anthropic Messages REST API directly).
213
+ *
214
+ * `client` is `null` only when `credential.apiKey` is also `null` — in which
215
+ * case the caller MUST fall back to its graceful-degradation path
216
+ * (`return null` / skip / log warn).
217
+ *
218
+ * `client` is typed as `unknown` here because the concrete SDK classes
219
+ * (Anthropic, OpenAI, GoogleGenerativeAI) are not referenced from contracts
220
+ * to preserve its zero-dependency footprint. Consumers MUST narrow via the
221
+ * typed helpers in `@cleocode/core/llm/role-resolver` (e.g.
222
+ * `resolveAnthropicForRole`) rather than casting with `as unknown as X`.
223
+ *
224
+ * @task T9255
225
+ */
226
+ export interface ResolvedLLM {
227
+ /** LLM provider transport that was resolved. */
228
+ provider: ModelTransport;
229
+ /** Full model identifier. */
230
+ model: string;
231
+ /**
232
+ * Fully-wired SDK client constructed via `clientForModelConfig`. `null`
233
+ * when no credential is available. Typed as `unknown` — consumers MUST
234
+ * narrow via a provider-specific helper (e.g. `resolveAnthropicForRole`
235
+ * in `@cleocode/core/llm/role-resolver`), NEVER via an `as unknown as X`
236
+ * cast.
237
+ */
238
+ client: unknown;
239
+ /**
240
+ * Resolved credential. `null` when no tier produced a token. Callers
241
+ * MUST handle this case.
242
+ */
243
+ credential: CredentialResultWire | null;
244
+ /** Which config path produced this resolution. */
245
+ source: ResolutionSource;
246
+ /** When `roles[role].credentialLabel` was set, the label that was used. */
247
+ credentialLabel?: string;
248
+ }
249
+
250
+ /**
251
+ * Options accepted by `resolveLLMForRole()`.
252
+ *
253
+ * @task T9255
254
+ */
255
+ export interface ResolveLLMForRoleOptions {
256
+ /**
257
+ * Absolute path to the project root. Forwarded to `loadConfig()` and to
258
+ * `resolveCredentials({ projectRoot })` for tier-5 project-config lookup.
259
+ * Defaults to `process.cwd()`.
260
+ */
261
+ projectRoot?: string;
262
+ }
263
+
264
+ // ============================================================================
265
+ // `cleo llm` CLI / dispatch operation contracts (T9258 — Phase 2 T-llm-4)
266
+ //
267
+ // Wire types backing the `cleo llm` CLI subcommands and the `llm` dispatch
268
+ // domain. Provider-redacted views of `StoredCredential` (defined in
269
+ // `@cleocode/core/llm/credentials-store`) plus the dispatch param/result
270
+ // shapes for add / list / remove / use / profile / test / whoami.
271
+ //
272
+ // Tokens are NEVER returned in raw form by these envelopes — `tokenPreview`
273
+ // surfaces only the last 4 characters so the wire vocabulary is safe for
274
+ // JSON output, logs, and remote dispatch consumers.
275
+ // ============================================================================
276
+
277
+ /**
278
+ * Storage-level authentication scheme as persisted in the credentials store.
279
+ *
280
+ * Wider than the wire-level {@link AuthTypeWire}: includes `'aws_sdk'` for
281
+ * Bedrock / Vertex entries where the AWS SDK supplies the credential
282
+ * out-of-band. The runtime resolver narrows `'aws_sdk' → 'api_key'` for
283
+ * wire-level use until Phase 3 widens {@link AuthTypeWire}.
284
+ *
285
+ * Mirrors `StoredAuthType` in `@cleocode/core/llm/credentials-store`.
286
+ *
287
+ * @task T9258
288
+ */
289
+ export type StoredAuthTypeWire = 'api_key' | 'oauth' | 'aws_sdk';
290
+
291
+ /**
292
+ * Strategy used by the credentials-store picker.
293
+ *
294
+ * Mirrors `CredentialsStoreStrategy` in
295
+ * `@cleocode/core/llm/credentials-store`. Held here so callers outside
296
+ * `core` can render UI without taking a dependency on the storage module.
297
+ *
298
+ * @task T9258
299
+ */
300
+ export type CredentialsStoreStrategyWire = 'priorityWithFallback' | 'roundRobin' | 'priorityOnly';
301
+
302
+ /**
303
+ * Token-redacted view of a single stored credential.
304
+ *
305
+ * `tokenPreview` is the last 4 characters of `accessToken` prefixed by
306
+ * `'…'` (e.g. `'…aB7q'`). The full token is NEVER returned by any
307
+ * `cleo llm` operation — callers that need the live token must resolve it
308
+ * through `resolveLLMForRole()`.
309
+ *
310
+ * @task T9258
311
+ */
312
+ export interface LlmStoredCredentialView {
313
+ /** LLM transport this credential is for. */
314
+ provider: ModelTransport;
315
+ /** Human-readable identifier, unique within `provider`. */
316
+ label: string;
317
+ /** Storage-level auth scheme. */
318
+ authType: StoredAuthTypeWire;
319
+ /** Redacted token preview — last 4 chars, prefixed by `'…'`. */
320
+ tokenPreview: string;
321
+ /** Whether the entry carried a non-empty refresh token. */
322
+ hasRefreshToken: boolean;
323
+ /** Unix epoch ms; `null` means "never expires". */
324
+ expiresAt: number | null;
325
+ /** Lower wins. */
326
+ priority: number;
327
+ /** Free-form provenance label (`claude-code`, `cli-input`, etc.). */
328
+ source: string | undefined;
329
+ /** Optional override for provider base URL. */
330
+ baseUrl: string | null;
331
+ /** When `true`, the picker skips this entry. */
332
+ disabled: boolean;
333
+ }
334
+
335
+ /**
336
+ * Parameters for `llm.add` (mutate).
337
+ *
338
+ * Mirrors the `cleo llm add <provider> --api-key <k>` CLI surface. When
339
+ * `authType` is omitted, the dispatcher auto-detects from the token
340
+ * prefix: tokens beginning with `sk-ant-oat-` are stored as `'oauth'`,
341
+ * everything else as `'api_key'`.
342
+ *
343
+ * @task T9258
344
+ */
345
+ export interface LlmAddParams {
346
+ /** Target provider transport. */
347
+ provider: ModelTransport;
348
+ /** API key or OAuth bearer token to persist. */
349
+ apiKey: string;
350
+ /** Human-readable label, unique within `provider`. Defaults to `'default'`. */
351
+ label?: string;
352
+ /** Optional override for the provider base URL. */
353
+ baseUrl?: string;
354
+ /** Optional explicit auth type override (skips prefix auto-detect). */
355
+ authType?: StoredAuthTypeWire;
356
+ /** Optional priority override (lower wins). */
357
+ priority?: number;
358
+ }
359
+
360
+ /**
361
+ * Result envelope for `llm.add`.
362
+ *
363
+ * @task T9258
364
+ */
365
+ export interface LlmAddResult {
366
+ /** Token-redacted view of the newly stored entry. */
367
+ credential: LlmStoredCredentialView;
368
+ /** Detected auth type (`'oauth'` for `sk-ant-oat-*`, else `'api_key'`). */
369
+ detectedAuthType: StoredAuthTypeWire;
370
+ }
371
+
372
+ /**
373
+ * Parameters for `llm.list` (query).
374
+ *
375
+ * @task T9258
376
+ */
377
+ export interface LlmListParams {
378
+ /** Optional provider filter — when set, only entries for that provider. */
379
+ provider?: ModelTransport;
380
+ }
381
+
382
+ /**
383
+ * Result envelope for `llm.list`.
384
+ *
385
+ * @task T9258
386
+ */
387
+ export interface LlmListResult {
388
+ /** Token-redacted credentials, in store order (priority asc). */
389
+ credentials: LlmStoredCredentialView[];
390
+ }
391
+
392
+ /**
393
+ * Parameters for `llm.remove` (mutate).
394
+ *
395
+ * @task T9258
396
+ */
397
+ export interface LlmRemoveParams {
398
+ /** Target provider transport. */
399
+ provider: ModelTransport;
400
+ /** Label of the credential to remove. */
401
+ label: string;
402
+ }
403
+
404
+ /**
405
+ * Result envelope for `llm.remove`.
406
+ *
407
+ * @task T9258
408
+ */
409
+ export interface LlmRemoveResult {
410
+ /** `true` when a matching entry was deleted. */
411
+ removed: boolean;
412
+ /** Echo of the targeted `(provider, label)` pair. */
413
+ provider: ModelTransport;
414
+ /** Echo of the targeted label. */
415
+ label: string;
416
+ }
417
+
418
+ /**
419
+ * Parameters for `llm.use` (mutate) — set `llm.default.{provider,model}`.
420
+ *
421
+ * @task T9258
422
+ */
423
+ export interface LlmUseParams {
424
+ /** Provider transport to mark as the default. */
425
+ provider: ModelTransport;
426
+ /** Optional default model identifier. When omitted, `default.model` is left untouched. */
427
+ model?: string;
428
+ }
429
+
430
+ /**
431
+ * Result envelope for `llm.use`.
432
+ *
433
+ * @task T9258
434
+ */
435
+ export interface LlmUseResult {
436
+ /** Provider written to `llm.default.provider`. */
437
+ provider: ModelTransport;
438
+ /** Model written to `llm.default.model` — `null` when not provided. */
439
+ model: string | null;
440
+ /** Config scope the write landed in (`'global'` for `cleo llm use`). */
441
+ scope: 'project' | 'global';
442
+ }
443
+
444
+ /**
445
+ * Parameters for `llm.profile` (mutate) — set `llm.roles[role]`.
446
+ *
447
+ * @task T9258
448
+ */
449
+ export interface LlmProfileParams {
450
+ /** Logical role name. */
451
+ role: string;
452
+ /** Provider transport for this role. */
453
+ provider: ModelTransport;
454
+ /** Optional model identifier for this role. */
455
+ model?: string;
456
+ /** Optional credential label to pin this role to a specific store entry. */
457
+ credentialLabel?: string;
458
+ }
459
+
460
+ /**
461
+ * Result envelope for `llm.profile`.
462
+ *
463
+ * @task T9258
464
+ */
465
+ export interface LlmProfileResult {
466
+ /** Role name written to `llm.roles[role]`. */
467
+ role: string;
468
+ /** Provider written for the role. */
469
+ provider: ModelTransport;
470
+ /** Model written for the role (or `null` when not supplied). */
471
+ model: string | null;
472
+ /** Credential label written for the role (or `null` when not supplied). */
473
+ credentialLabel: string | null;
474
+ /** Config scope the write landed in. */
475
+ scope: 'project' | 'global';
476
+ }
477
+
478
+ /**
479
+ * Parameters for `llm.test` (query).
480
+ *
481
+ * @task T9258
482
+ */
483
+ export interface LlmTestParams {
484
+ /** Provider transport to test. */
485
+ provider: ModelTransport;
486
+ /** Optional credential label to pin the test to a specific store entry. */
487
+ label?: string;
488
+ /** Optional model override. Defaults to the provider's implicit fallback. */
489
+ model?: string;
490
+ }
491
+
492
+ /**
493
+ * Result envelope for `llm.test`. Tokens are NEVER included.
494
+ *
495
+ * @task T9258
496
+ */
497
+ export interface LlmTestResult {
498
+ /** Provider transport that was probed. */
499
+ provider: ModelTransport;
500
+ /** Model identifier used for the probe. */
501
+ model: string;
502
+ /** End-to-end round-trip latency in ms. */
503
+ latencyMs: number;
504
+ /** Provider response identifier (e.g. Anthropic `msg_…`). `null` when unavailable. */
505
+ providerResponseId: string | null;
506
+ /** Redacted credential preview (last 4 chars) — confirms which entry was used. */
507
+ credentialPreview: string;
508
+ /** Resolution tier that produced the credential (`env`, `cred-file`, etc.). */
509
+ credentialSource: CredentialSourceWire;
510
+ }
511
+
512
+ /**
513
+ * Single `whoami` row — one entry per `RoleName`.
514
+ *
515
+ * @task T9258
516
+ */
517
+ export interface LlmWhoamiEntry {
518
+ /** Role name (`'extraction' | 'consolidation' | ...`). */
519
+ role: string;
520
+ /** Provider that would be picked for this role. */
521
+ provider: ModelTransport;
522
+ /** Model that would be used. */
523
+ model: string;
524
+ /** Which config tier produced the resolution. */
525
+ source: ResolutionSource;
526
+ /** Credential label, when the role pinned a specific store entry. */
527
+ credentialLabel: string | undefined;
528
+ /** Resolution tier of the eventual credential, when one was reachable. */
529
+ credentialSource: CredentialSourceWire | undefined;
530
+ /** Whether a usable credential exists for this role. */
531
+ hasCredential: boolean;
532
+ }
533
+
534
+ /**
535
+ * Parameters for `llm.whoami` (query). Reserved for future filters.
536
+ *
537
+ * @task T9258
538
+ */
539
+ export interface LlmWhoamiParams {
540
+ /** Optional role filter — when set, only that role is resolved. */
541
+ role?: string;
542
+ }
543
+
544
+ /**
545
+ * Result envelope for `llm.whoami`.
546
+ *
547
+ * @task T9258
548
+ */
549
+ export interface LlmWhoamiResult {
550
+ /** One entry per role resolved (filtered by `params.role` when set). */
551
+ entries: LlmWhoamiEntry[];
552
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Project context — canonical ecosystem detection types.
3
+ *
4
+ * Defines the shape of `.cleo/project-context.json` and the smaller hint
5
+ * envelope consumed by release-flow / spawn-engine / codebase-map analyzers.
6
+ *
7
+ * Type-only: the detector implementation lives in `@cleocode/core/store/
8
+ * project-detect.ts`. Centralising the types here lets any package (release,
9
+ * studio, agents, …) reason about ecosystem signals without importing core.
10
+ *
11
+ * @adr ADR-013
12
+ */
13
+
14
+ /** Detected project ecosystem. Matches the writer in `detectProjectType`. */
15
+ export type ProjectType =
16
+ | 'node'
17
+ | 'python'
18
+ | 'rust'
19
+ | 'go'
20
+ | 'ruby'
21
+ | 'java'
22
+ | 'dotnet'
23
+ | 'bash'
24
+ | 'elixir'
25
+ | 'php'
26
+ | 'deno'
27
+ | 'bun'
28
+ | 'unknown';
29
+
30
+ /** Detected test framework. */
31
+ export type TestFramework =
32
+ | 'jest'
33
+ | 'vitest'
34
+ | 'mocha'
35
+ | 'pytest'
36
+ | 'bats'
37
+ | 'cargo'
38
+ | 'go'
39
+ | 'rspec'
40
+ | 'junit'
41
+ | 'playwright'
42
+ | 'cypress'
43
+ | 'ava'
44
+ | 'uvu'
45
+ | 'tap'
46
+ | 'node:test'
47
+ | 'deno'
48
+ | 'bun'
49
+ | 'custom'
50
+ | 'unknown';
51
+
52
+ /** File-naming convention detected from source files. */
53
+ export type FileNamingConvention = 'kebab-case' | 'snake_case' | 'camelCase' | 'PascalCase';
54
+
55
+ /** Module import style. */
56
+ export type ImportStyle = 'esm' | 'commonjs' | 'mixed';
57
+
58
+ /** Schema-compliant project context for LLM agent consumption. */
59
+ export interface ProjectContext {
60
+ schemaVersion: string;
61
+ detectedAt: string;
62
+ projectTypes: ProjectType[];
63
+ primaryType?: ProjectType;
64
+ monorepo: boolean;
65
+ testing?: {
66
+ framework?: TestFramework;
67
+ command?: string;
68
+ testFilePatterns?: string[];
69
+ directories?: {
70
+ unit?: string;
71
+ integration?: string;
72
+ };
73
+ };
74
+ build?: {
75
+ command?: string;
76
+ outputDir?: string;
77
+ };
78
+ directories?: {
79
+ source?: string;
80
+ tests?: string;
81
+ docs?: string;
82
+ };
83
+ conventions?: {
84
+ fileNaming?: FileNamingConvention;
85
+ importStyle?: ImportStyle;
86
+ typeSystem?: string;
87
+ };
88
+ llmHints?: {
89
+ preferredTestStyle?: string;
90
+ typeSystem?: string;
91
+ commonPatterns?: string[];
92
+ avoidPatterns?: string[];
93
+ };
94
+ }
95
+
96
+ /**
97
+ * Narrow subset of {@link ProjectContext} consumed by the release engine's
98
+ * workspace discovery and other ecosystem-aware flows. Avoid passing the
99
+ * full {@link ProjectContext} when only the three discriminating fields are
100
+ * needed.
101
+ */
102
+ export interface EcosystemHint {
103
+ primaryType?: ProjectType;
104
+ projectTypes?: ProjectType[];
105
+ monorepo?: boolean;
106
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Release channel contracts — types describing the npm dist-tag channel
3
+ * model used by the release pipeline.
4
+ *
5
+ * The implementation (branch→channel resolution, version validation) lives
6
+ * in `@cleocode/core/release/channel.ts`. The types live here so consumers
7
+ * can describe / validate the same shapes without depending on core.
8
+ *
9
+ * @adr ADR-063
10
+ */
11
+
12
+ /** npm dist-tag channel for a release. */
13
+ export type ReleaseChannel = 'latest' | 'beta' | 'alpha';
14
+
15
+ /** Result of validating a version string against a channel's expectations. */
16
+ export interface ChannelValidationResult {
17
+ valid: boolean;
18
+ expected?: string;
19
+ actual?: string;
20
+ message: string;
21
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * GitHub PR contracts — types describing the PR-creation surface used by
3
+ * the release pipeline.
4
+ *
5
+ * The implementation lives in `@cleocode/core/release/github-pr.ts`. The
6
+ * types live here so consumers (CLI, studio, downstream tools) can describe
7
+ * / validate the same shapes without depending on core.
8
+ *
9
+ * @adr ADR-063
10
+ */
11
+
12
+ import type { ReleaseChannel } from './channel.js';
13
+
14
+ /** Outcome of `detectBranchProtection`. */
15
+ export interface BranchProtectionResult {
16
+ protected: boolean;
17
+ detectionMethod: 'gh-api' | 'push-dry-run' | 'unknown';
18
+ error?: string;
19
+ }
20
+
21
+ /** Input to `createPullRequest`. */
22
+ export interface PRCreateOptions {
23
+ base: string;
24
+ head: string;
25
+ title: string;
26
+ body: string;
27
+ /**
28
+ * Requested PR labels. Non-existent ones are filtered or auto-created by
29
+ * the resolver; the engine never passes a bare list to `gh pr create`.
30
+ */
31
+ labels?: string[];
32
+ version: string;
33
+ epicId?: string;
34
+ projectRoot?: string;
35
+ }
36
+
37
+ /** How a PR-create attempt resolved. */
38
+ export type PRMode = 'created' | 'manual' | 'skipped';
39
+
40
+ /** Outcome of `createPullRequest`. */
41
+ export interface PRResult {
42
+ mode: PRMode;
43
+ prUrl?: string;
44
+ prNumber?: number;
45
+ instructions?: string;
46
+ error?: string;
47
+ }
48
+
49
+ /** Parsed `owner/repo` pair extracted from a git remote URL. */
50
+ export interface RepoIdentity {
51
+ owner: string;
52
+ repo: string;
53
+ }
54
+
55
+ /**
56
+ * Names of the labels CLEO knows how to auto-create when they are missing
57
+ * on a repo. Includes the universal `release` flag plus one label per npm
58
+ * dist-tag channel.
59
+ */
60
+ export type CleoKnownLabel = 'release' | ReleaseChannel;
61
+
62
+ /** Color + description used when CLEO auto-creates one of its known labels. */
63
+ export interface LabelDefinition {
64
+ color: string;
65
+ description: string;
66
+ }
67
+
68
+ /** Static palette of CLEO-known labels keyed by label name. */
69
+ export type CleoLabelPalette = Readonly<Record<CleoKnownLabel, LabelDefinition>>;
70
+
71
+ /** Outcome of {@link ensureCleoLabelsExist}. */
72
+ export interface LabelEnsureResult {
73
+ /** Labels that exist on the repo after this call (pre-existed or auto-created). */
74
+ ensured: string[];
75
+ /** Labels that this call created. */
76
+ created: string[];
77
+ /** Labels that could not be ensured (unknown to CLEO, or `gh label create` failed). */
78
+ missing: string[];
79
+ }
80
+
81
+ /** Outcome of {@link resolvePRLabels} — what to actually pass to `gh pr create`. */
82
+ export interface PRLabelResolution {
83
+ /** Labels safe to pass to `gh pr create`. */
84
+ labels: string[];
85
+ /** Labels auto-created during resolution. */
86
+ created: string[];
87
+ /** Labels dropped because they could not be ensured. */
88
+ missing: string[];
89
+ }