@h-rig/contracts 0.0.6-alpha.154 → 0.0.6-alpha.156

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 (40) hide show
  1. package/dist/index.cjs +407 -91
  2. package/dist/index.mjs +407 -91
  3. package/dist/src/browser.d.ts +50 -0
  4. package/dist/src/browser.js +6 -0
  5. package/dist/src/config.d.ts +4 -0
  6. package/dist/src/config.js +6 -14
  7. package/dist/src/control-plane-types.d.ts +283 -0
  8. package/dist/src/control-plane-types.js +29 -0
  9. package/dist/src/doctor.d.ts +27 -0
  10. package/dist/src/doctor.js +14 -0
  11. package/dist/src/github.d.ts +103 -0
  12. package/dist/src/github.js +6 -0
  13. package/dist/src/help-catalog.js +1 -1
  14. package/dist/src/index.d.ts +11 -0
  15. package/dist/src/index.js +407 -91
  16. package/dist/src/isolation.d.ts +21 -0
  17. package/dist/src/isolation.js +6 -0
  18. package/dist/src/kernel.d.ts +3 -35
  19. package/dist/src/kernel.js +0 -15
  20. package/dist/src/lifecycle-capabilities.d.ts +29 -0
  21. package/dist/src/lifecycle-capabilities.js +8 -0
  22. package/dist/src/managed-repos.d.ts +73 -0
  23. package/dist/src/managed-repos.js +6 -0
  24. package/dist/src/memory.d.ts +151 -0
  25. package/dist/src/memory.js +8 -0
  26. package/dist/src/panel-protocol.d.ts +17 -0
  27. package/dist/src/panel-protocol.js +10 -0
  28. package/dist/src/plugin-hooks.js +6 -14
  29. package/dist/src/plugin.d.ts +13 -0
  30. package/dist/src/plugin.js +7 -14
  31. package/dist/src/provider-instructions.d.ts +19 -0
  32. package/dist/src/provider-instructions.js +6 -0
  33. package/dist/src/run-journal.d.ts +1 -1
  34. package/dist/src/run-record.d.ts +11 -0
  35. package/dist/src/run-record.js +16 -0
  36. package/dist/src/supervisor-journal.d.ts +0 -1
  37. package/dist/src/supervisor-journal.js +0 -74
  38. package/dist/src/task-graph-primitives.d.ts +68 -0
  39. package/dist/src/task-graph-primitives.js +319 -0
  40. package/package.json +1 -1
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Pure browser-contract types.
3
+ *
4
+ * These types are the neutral home for the browser-required task contract so
5
+ * that the dumb runtime substrate (isolation provisioning, task info, rig-agent,
6
+ * rig-browser-tool) and the @rig/browser-plugin that owns the resolution logic
7
+ * can both reference them without a substrate->plugin import cycle. They carry
8
+ * no behaviour and import nothing — exactly like `memory.ts` /
9
+ * `lifecycle-capabilities.ts`.
10
+ *
11
+ * The plugin registers its executable `BrowserContractService` impl under
12
+ * {@link BROWSER_CONTRACT_SERVICE_CAPABILITY_ID} on `contributes.capabilities[].run`;
13
+ * the runtime resolves it by id from `pluginHost.listExecutableCapabilities()`
14
+ * via the typed port in `@rig/runtime/control-plane/browser-contract-port`.
15
+ */
16
+ /** Capability id the browser plugin registers its `BrowserContractService` factory under. */
17
+ export declare const BROWSER_CONTRACT_SERVICE_CAPABILITY_ID = "browser.contract";
18
+ /** Author-facing browser config attached to a task entry (rig.config / task source). */
19
+ export type TaskBrowserConfig = {
20
+ required?: boolean;
21
+ preset?: string;
22
+ profile?: string;
23
+ attach_url?: string;
24
+ state_dir?: string;
25
+ dev_command?: string;
26
+ launch_command?: string;
27
+ check_command?: string;
28
+ e2e_command?: string;
29
+ mode?: string;
30
+ };
31
+ /** Resolved, runtime-effective browser contract persisted into the runtime context. */
32
+ export type RuntimeBrowserContext = {
33
+ required: boolean;
34
+ preset: string;
35
+ mode: string;
36
+ stateDir: string;
37
+ defaultProfile: string;
38
+ effectiveProfile: string;
39
+ defaultAttachUrl: string;
40
+ effectiveAttachUrl: string;
41
+ devCommand?: string;
42
+ launchCommand?: string;
43
+ checkCommand?: string;
44
+ e2eCommand?: string;
45
+ launchHelper: string;
46
+ checkHelper: string;
47
+ attachInfoHelper: string;
48
+ e2eHelper: string;
49
+ resetProfileHelper: string;
50
+ };
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ // packages/contracts/src/browser.ts
3
+ var BROWSER_CONTRACT_SERVICE_CAPABILITY_ID = "browser.contract";
4
+ export {
5
+ BROWSER_CONTRACT_SERVICE_CAPABILITY_ID
6
+ };
@@ -388,6 +388,10 @@ export declare const RigConfig: Schema.Struct<{
388
388
  readonly description: Schema.optional<Schema.String>;
389
389
  readonly priority: Schema.optional<Schema.Number>;
390
390
  }>>>;
391
+ readonly sessionExtensions: Schema.optional<Schema.$Array<Schema.Struct<{
392
+ readonly id: Schema.String;
393
+ readonly description: Schema.optional<Schema.String>;
394
+ }>>>;
391
395
  }>>;
392
396
  }>>;
393
397
  readonly taskSource: Schema.Struct<{
@@ -170,19 +170,6 @@ var CapabilityReplacementSpec = Schema3.Union([
170
170
  CapabilityReplacement,
171
171
  TrimmedNonEmptyString
172
172
  ]);
173
- var PluginMeta = Schema3.Struct({
174
- id: TrimmedNonEmptyString,
175
- version: TrimmedNonEmptyString,
176
- provides: Schema3.Array(CapabilityTag),
177
- requires: Schema3.optional(Schema3.Array(CapabilityTag)),
178
- replaces: Schema3.optional(Schema3.Array(CapabilityReplacementSpec))
179
- });
180
- var LoadedPluginDescriptor = Schema3.Struct({
181
- meta: PluginMeta,
182
- provides: Schema3.Array(CapabilityTag),
183
- contributes: Schema3.Unknown,
184
- runtime: Schema3.Unknown
185
- });
186
173
  var KernelReplacementGrant = Schema3.Struct({
187
174
  pluginId: TrimmedNonEmptyString,
188
175
  grantedBy: Schema3.optional(TrimmedNonEmptyString),
@@ -327,6 +314,10 @@ var BlockerClassifierRegistration = Schema4.Struct({
327
314
  description: Schema4.optional(Schema4.String),
328
315
  priority: Schema4.optional(Schema4.Number)
329
316
  });
317
+ var SessionExtensionRegistration = Schema4.Struct({
318
+ id: Schema4.String,
319
+ description: Schema4.optional(Schema4.String)
320
+ });
330
321
  var PluginContributes = Schema4.Struct({
331
322
  validators: Schema4.optional(Schema4.Array(ValidatorRegistration)),
332
323
  hooks: Schema4.optional(Schema4.Array(HookRegistration)),
@@ -340,7 +331,8 @@ var PluginContributes = Schema4.Struct({
340
331
  stageMutations: Schema4.optional(Schema4.Array(StageMutation)),
341
332
  capabilities: Schema4.optional(Schema4.Array(ProductCapabilityRegistration)),
342
333
  panels: Schema4.optional(Schema4.Array(PanelRegistration)),
343
- blockerClassifiers: Schema4.optional(Schema4.Array(BlockerClassifierRegistration))
334
+ blockerClassifiers: Schema4.optional(Schema4.Array(BlockerClassifierRegistration)),
335
+ sessionExtensions: Schema4.optional(Schema4.Array(SessionExtensionRegistration))
344
336
  });
345
337
  var RigPlugin = Schema4.Struct({
346
338
  name: Schema4.String,
@@ -0,0 +1,283 @@
1
+ /**
2
+ * Control-plane shared types.
3
+ *
4
+ * These types previously lived inside the runtime native PR/merge/verify
5
+ * lifecycle modules (pr-automation.ts, pr-review-gate.ts, verifier.ts) and
6
+ * were imported across module boundaries, creating mutual coupling. They are
7
+ * hoisted here — the bottom contracts layer — so the lifecycle plugins
8
+ * (@rig/pr-review-plugin, @rig/bundle-default-lifecycle) and the dumb runtime
9
+ * substrate (git-ops, task-ops) all reference one canonical definition without
10
+ * importing each other.
11
+ */
12
+ export type GitHubCommandResult = {
13
+ readonly exitCode: number;
14
+ readonly stdout?: string;
15
+ readonly stderr?: string;
16
+ };
17
+ export type GitHubCommandRunner = (args: readonly string[], options?: {
18
+ readonly cwd?: string;
19
+ }) => Promise<GitHubCommandResult>;
20
+ export type GitCommandRunner = (args: readonly string[], options?: {
21
+ readonly cwd?: string;
22
+ }) => Promise<GitHubCommandResult>;
23
+ export type RigAutomationConfig = {
24
+ readonly automation?: {
25
+ readonly maxValidationAttempts?: number;
26
+ readonly maxPrFixIterations?: number;
27
+ };
28
+ readonly pr?: {
29
+ readonly mode?: "auto" | "ask" | "off";
30
+ readonly watchChecks?: boolean;
31
+ readonly autoFixChecks?: boolean;
32
+ readonly autoFixReview?: boolean;
33
+ readonly pendingTimeoutMs?: number;
34
+ readonly pendingPollMs?: number;
35
+ };
36
+ readonly merge?: {
37
+ readonly mode?: "auto" | "off" | "pr-ready";
38
+ readonly method?: "repo-default" | "squash" | "merge" | "rebase";
39
+ readonly deleteBranch?: "repo-default" | boolean;
40
+ readonly allowedFailures?: readonly string[];
41
+ readonly bypass?: boolean;
42
+ };
43
+ readonly review?: {
44
+ readonly mode?: "off" | "advisory" | "required";
45
+ readonly provider?: "greptile" | "github";
46
+ };
47
+ };
48
+ export type PrAutomationResult = {
49
+ readonly status: "skipped" | "opened" | "merged" | "needs_attention";
50
+ readonly prUrl?: string;
51
+ readonly iterations: number;
52
+ readonly actionableFeedback: readonly string[];
53
+ readonly merged?: boolean;
54
+ };
55
+ export type PrAutomationLifecycle = {
56
+ readonly onPrOpened?: (input: {
57
+ readonly prUrl: string;
58
+ }) => Promise<void> | void;
59
+ readonly onReviewCiStarted?: (input: {
60
+ readonly prUrl: string;
61
+ readonly iteration: number;
62
+ }) => Promise<void> | void;
63
+ readonly onFeedback?: (input: {
64
+ readonly prUrl: string;
65
+ readonly iteration: number;
66
+ readonly feedback: readonly string[];
67
+ }) => Promise<void> | void;
68
+ readonly onMergeStarted?: (input: {
69
+ readonly prUrl: string;
70
+ }) => Promise<void> | void;
71
+ readonly onMerged?: (input: {
72
+ readonly prUrl: string;
73
+ }) => Promise<void> | void;
74
+ };
75
+ export type GithubUser = {
76
+ readonly login?: string | null;
77
+ } | null;
78
+ export type GithubPullRequestReview = {
79
+ readonly id?: string | null;
80
+ readonly state?: string | null;
81
+ readonly body?: string | null;
82
+ readonly commit_id?: string | null;
83
+ readonly html_url?: string | null;
84
+ readonly author?: GithubUser;
85
+ };
86
+ export type GithubReviewThreadComment = {
87
+ readonly author?: GithubUser;
88
+ readonly body?: string | null;
89
+ readonly path?: string | null;
90
+ readonly url?: string | null;
91
+ readonly createdAt?: string | null;
92
+ };
93
+ export type GithubReviewThread = {
94
+ readonly id?: string | null;
95
+ readonly isResolved?: boolean | null;
96
+ readonly isOutdated?: boolean | null;
97
+ readonly comments?: {
98
+ readonly nodes?: readonly GithubReviewThreadComment[] | null;
99
+ readonly pageInfo?: {
100
+ readonly hasNextPage?: boolean | null;
101
+ readonly endCursor?: string | null;
102
+ } | null;
103
+ } | null;
104
+ };
105
+ export type GithubReviewComment = {
106
+ readonly id?: number | string | null;
107
+ readonly user?: GithubUser;
108
+ readonly author?: GithubUser;
109
+ readonly body?: string | null;
110
+ readonly path?: string | null;
111
+ readonly html_url?: string | null;
112
+ readonly url?: string | null;
113
+ readonly commit_id?: string | null;
114
+ readonly original_commit_id?: string | null;
115
+ };
116
+ export type GithubIssueComment = {
117
+ readonly id?: number | string | null;
118
+ readonly user?: GithubUser;
119
+ readonly author?: GithubUser;
120
+ readonly body?: string | null;
121
+ readonly html_url?: string | null;
122
+ readonly url?: string | null;
123
+ readonly created_at?: string | null;
124
+ };
125
+ export type PrCheckSummary = {
126
+ readonly name: string;
127
+ readonly status?: string | null;
128
+ readonly state?: string | null;
129
+ readonly conclusion?: string | null;
130
+ readonly detailsUrl?: string | null;
131
+ };
132
+ export type GithubStatusCheckRollupItem = PrCheckSummary & {
133
+ readonly __typename?: string | null;
134
+ readonly context?: string | null;
135
+ readonly detailsUrl?: string | null;
136
+ readonly link?: string | null;
137
+ readonly headSha?: string | null;
138
+ readonly head_sha?: string | null;
139
+ readonly output?: {
140
+ readonly title?: string | null;
141
+ readonly summary?: string | null;
142
+ readonly text?: string | null;
143
+ } | null;
144
+ readonly app?: {
145
+ readonly slug?: string | null;
146
+ readonly name?: string | null;
147
+ readonly owner?: GithubUser;
148
+ } | null;
149
+ };
150
+ export type GreptileScore = {
151
+ readonly value: number;
152
+ readonly scale: number;
153
+ readonly raw: string;
154
+ };
155
+ export type GreptileSignalSource = "api" | "github-review" | "github-check" | "changed-file-comment" | "issue-comment" | "review-thread" | "pr-body" | "pr-title";
156
+ export type GreptileSignalVerdict = "approved" | "rejected" | "skipped" | "pending" | "failed" | "completed";
157
+ export type GreptileSignalEvidence = {
158
+ readonly source: GreptileSignalSource;
159
+ readonly trusted: boolean;
160
+ readonly authorLogin?: string | null;
161
+ readonly reviewedSha?: string | null;
162
+ readonly current: boolean | null;
163
+ readonly stale: boolean;
164
+ readonly score?: GreptileScore | null;
165
+ readonly scores?: readonly GreptileScore[];
166
+ readonly explicitApproval?: boolean;
167
+ readonly verdict?: GreptileSignalVerdict | null;
168
+ readonly blocker?: boolean;
169
+ readonly actionable?: boolean;
170
+ readonly bodyExcerpt?: string;
171
+ };
172
+ export type GreptileApiSignalInput = {
173
+ readonly id?: string | null;
174
+ readonly body?: string | null;
175
+ readonly reviewedSha?: string | null;
176
+ readonly status?: string | null;
177
+ };
178
+ export type GreptileEvidence = {
179
+ readonly source: "api" | "github-review" | "github-check" | "github-comment" | "pr-body" | "combined" | "missing";
180
+ readonly currentHeadSha: string;
181
+ readonly reviewedSha?: string | null;
182
+ readonly fresh: boolean;
183
+ readonly completed: boolean;
184
+ readonly approved: boolean;
185
+ readonly score?: GreptileScore | null;
186
+ readonly explicitApproval?: boolean;
187
+ readonly blockers: readonly string[];
188
+ readonly unresolvedComments: readonly string[];
189
+ readonly rawBodies: readonly string[];
190
+ readonly signals: readonly GreptileSignalEvidence[];
191
+ readonly mapping: "score-5-of-5" | "explicit-approved" | "unproven" | "missing" | "stale";
192
+ };
193
+ export type PrReviewEvidence = {
194
+ readonly prUrl: string;
195
+ readonly prNumber: number;
196
+ readonly repoName: string;
197
+ readonly title: string;
198
+ readonly body: string;
199
+ readonly bodyEditorLogin?: string | null;
200
+ readonly bodyLastEditedAt?: string | null;
201
+ readonly headCommittedDate?: string | null;
202
+ readonly headSha: string;
203
+ readonly headRefName?: string | null;
204
+ readonly baseRefName?: string | null;
205
+ readonly state?: string | null;
206
+ readonly isDraft?: boolean | null;
207
+ readonly mergeable?: string | null;
208
+ readonly mergeStateStatus?: string | null;
209
+ readonly reviewDecision?: string | null;
210
+ readonly reviews: readonly GithubPullRequestReview[];
211
+ readonly reviewThreads: readonly GithubReviewThread[];
212
+ readonly changedFileReviewComments: readonly GithubReviewComment[];
213
+ readonly relevantIssueComments: readonly GithubIssueComment[];
214
+ readonly statusCheckRollup: readonly GithubStatusCheckRollupItem[];
215
+ readonly checkFailures: readonly string[];
216
+ readonly pendingChecks: readonly string[];
217
+ readonly readErrors: readonly string[];
218
+ readonly greptile: GreptileEvidence;
219
+ };
220
+ export type PrReviewCycleArtifacts = {
221
+ readonly root: string;
222
+ readonly prTitlePath: string;
223
+ readonly prBodyPath: string;
224
+ readonly prCommentsPath: string;
225
+ readonly reviewThreadsPath: string;
226
+ readonly reviewCommentsPath: string;
227
+ readonly checkRollupPath: string;
228
+ readonly greptileEvidencePath: string;
229
+ readonly mergeGateResultPath: string;
230
+ readonly steeringPromptPath: string;
231
+ readonly finalMergeGateResultPath?: string;
232
+ };
233
+ export type StrictPrMergeGateReasonCode = "read_error" | "missing_head_sha" | "ci_failed" | "check_pending" | "review_decision_blocking" | "review_thread_unresolved" | "greptile_missing" | "greptile_stale" | "greptile_pending" | "greptile_api_status_unknown" | "greptile_not_current_head" | "greptile_score_not_5" | "greptile_score_missing" | "greptile_mapping_unproven" | "greptile_blocker_text" | "greptile_unresolved_comment";
234
+ export type StrictPrMergeGateReason = {
235
+ readonly code: StrictPrMergeGateReasonCode;
236
+ readonly reasonClass: "pending" | "reject";
237
+ readonly surface: "github" | "ci" | "review" | "greptile";
238
+ readonly suggestedAction: "wait" | "fix" | "ask_greptile" | "needs_attention";
239
+ readonly message: string;
240
+ readonly headSha?: string | null;
241
+ readonly reviewedSha?: string | null;
242
+ };
243
+ export type StrictPrMergeGateResult = {
244
+ readonly approved: boolean;
245
+ readonly pending: boolean;
246
+ readonly reasons: readonly string[];
247
+ readonly reasonDetails: readonly StrictPrMergeGateReason[];
248
+ readonly warnings: readonly string[];
249
+ readonly actionableFeedback: readonly string[];
250
+ readonly evidence: PrReviewEvidence;
251
+ readonly artifacts?: PrReviewCycleArtifacts;
252
+ readonly steeringPrompt: string;
253
+ };
254
+ export type StrictPrGreptileApiFetch = (input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => ReturnType<typeof fetch>;
255
+ export type StrictPrGreptileApiOptions = {
256
+ readonly enabled?: boolean;
257
+ readonly env?: Record<string, string | undefined>;
258
+ readonly fetch?: StrictPrGreptileApiFetch;
259
+ };
260
+ export type StrictPrMergeGateInput = {
261
+ readonly projectRoot: string;
262
+ readonly prUrl: string;
263
+ readonly taskId: string;
264
+ readonly runId: string;
265
+ readonly cycle: number;
266
+ readonly command: GitHubCommandRunner;
267
+ readonly artifactRoot?: string | null;
268
+ readonly allowedFailures?: readonly string[];
269
+ readonly apiSignals?: readonly GreptileApiSignalInput[];
270
+ readonly greptileApi?: StrictPrGreptileApiOptions;
271
+ readonly final?: boolean;
272
+ readonly requireGreptile?: boolean;
273
+ };
274
+ export type VerifyOutcome = {
275
+ approved: boolean;
276
+ localReasons: string[];
277
+ aiReasons: string[];
278
+ aiWarnings: string[];
279
+ aiVerdict: "APPROVE" | "REJECT" | "SKIP";
280
+ reviewFeedbackPath: string;
281
+ reviewStatePath: string;
282
+ };
283
+ export declare function strictMergeHeadShaFromGate(result: StrictPrMergeGateResult, prUrl: string, requireGreptile?: boolean): string;
@@ -0,0 +1,29 @@
1
+ // @bun
2
+ // packages/contracts/src/control-plane-types.ts
3
+ function strictMergeHeadShaFromGate(result, prUrl, requireGreptile = true) {
4
+ if (!result.approved) {
5
+ throw new Error(`Refusing to merge ${prUrl}: strict merge gate is not approved.`);
6
+ }
7
+ if (result.evidence.prUrl !== prUrl) {
8
+ throw new Error(`Refusing to merge ${prUrl}: strict merge gate evidence belongs to ${result.evidence.prUrl}.`);
9
+ }
10
+ const headSha = result.evidence.headSha?.trim();
11
+ if (!headSha) {
12
+ throw new Error(`Refusing to merge ${prUrl}: strict merge gate did not provide a current head SHA.`);
13
+ }
14
+ if (!/^[0-9a-f]{40}$/i.test(headSha)) {
15
+ throw new Error(`Refusing to merge ${prUrl}: strict merge gate head is not a raw 40-character commit SHA.`);
16
+ }
17
+ if (requireGreptile) {
18
+ if (!result.evidence.greptile.fresh || result.evidence.greptile.currentHeadSha !== headSha) {
19
+ throw new Error(`Refusing to merge ${prUrl}: strict merge gate approval is not tied to head ${headSha}.`);
20
+ }
21
+ if (result.evidence.greptile.mapping !== "score-5-of-5" && result.evidence.greptile.mapping !== "explicit-approved") {
22
+ throw new Error(`Refusing to merge ${prUrl}: strict merge gate mapping is ${result.evidence.greptile.mapping}.`);
23
+ }
24
+ }
25
+ return headSha;
26
+ }
27
+ export {
28
+ strictMergeHeadShaFromGate
29
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * doctor.ts — pure diagnostic vocabulary for the doctor product domain.
3
+ *
4
+ * The diagnostic implementation (toolchain probes, rig.config loadability,
5
+ * GitHub auth/permission checks, Pi/run/relay discovery, remediation copy)
6
+ * lives in @rig/doctor-plugin and is resolved by substrate consumers (CLI
7
+ * surface, rig-extension) through the typed port in
8
+ * `@rig/runtime/control-plane/doctor-service-port` under
9
+ * {@link DOCTOR_RUNNER_CAPABILITY_ID}. This file holds ONLY the pure types and
10
+ * pure helpers shared by producer and consumers — no IO, no plugin imports.
11
+ */
12
+ /** The capability id the doctor plugin registers its runner under. */
13
+ export declare const DOCTOR_RUNNER_CAPABILITY_ID = "doctor.runner";
14
+ export type DoctorStatus = "pass" | "warn" | "fail";
15
+ export type DoctorLevel = "ok" | "warn" | "fail";
16
+ export type DoctorCheck = {
17
+ readonly id?: string;
18
+ readonly label: string;
19
+ readonly status?: DoctorStatus;
20
+ readonly level?: DoctorLevel;
21
+ readonly detail?: string;
22
+ readonly remediation?: string;
23
+ };
24
+ /** Normalize the legacy `level` field to the canonical `status`. */
25
+ export declare function doctorLevelToStatus(level: DoctorLevel): DoctorStatus;
26
+ /** Count checks that resolve to a `fail` status (across status/level shapes). */
27
+ export declare function countDoctorFailures(checks: readonly DoctorCheck[]): number;
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ // packages/contracts/src/doctor.ts
3
+ var DOCTOR_RUNNER_CAPABILITY_ID = "doctor.runner";
4
+ function doctorLevelToStatus(level) {
5
+ return level === "ok" ? "pass" : level;
6
+ }
7
+ function countDoctorFailures(checks) {
8
+ return checks.filter((entry) => (entry.status ?? doctorLevelToStatus(entry.level ?? "warn")) === "fail").length;
9
+ }
10
+ export {
11
+ doctorLevelToStatus,
12
+ countDoctorFailures,
13
+ DOCTOR_RUNNER_CAPABILITY_ID
14
+ };
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Pure GitHub-provider contract types.
3
+ *
4
+ * This is the neutral home for the GitHub SCM-provider data model so that the
5
+ * @rig/github-provider-plugin (which owns the implementation), the
6
+ * @rig/task-sources-plugin (which consumes the credential-provider abstraction),
7
+ * and any future dumb runtime substrate can all reference the same vocabulary
8
+ * without a substrate->plugin import cycle. These types carry no behaviour and
9
+ * import nothing — exactly like `memory.ts` / `lifecycle-capabilities.ts`.
10
+ *
11
+ * The plugin registers its executable GitHub-provider service under
12
+ * {@link GITHUB_PROVIDER_CAPABILITY_ID} on `contributes.capabilities[].run`; a
13
+ * dumb substrate consumer would resolve it by id from a plugin host built from
14
+ * the project's rig.config via a typed port — the same seam shape proven by
15
+ * the memory/lifecycle capability ports. (Today the only substrate-facing
16
+ * GitHub primitive — reading a token from an env-pointed state file — stays in
17
+ * @rig/runtime/control-plane/github/token-env as a dumb reader; the policy that
18
+ * produces that token lives in this plugin.)
19
+ */
20
+ /** Capability id the GitHub-provider plugin registers its service factory under. */
21
+ export declare const GITHUB_PROVIDER_CAPABILITY_ID = "github.provider";
22
+ export type GitHubCredentialPurpose = "selected-repo" | "admin-fallback";
23
+ export type GitHubCredentialSource = "signed-in-user" | "host-admin-fallback";
24
+ export type GitHubCredentialProviderOptions = {
25
+ /**
26
+ * Session-scoped tokens keyed as:
27
+ * `user:<userId>|repo:<owner>/<repo>|workspace:<workspaceId>`.
28
+ * This intentionally models the app/session auth boundary; host tokens are
29
+ * not used for normal selected-repo operations.
30
+ */
31
+ sessionTokens?: Readonly<Record<string, string>>;
32
+ hostToken?: string | null;
33
+ };
34
+ export type ResolveGitHubTokenInput = {
35
+ owner: string;
36
+ repo: string;
37
+ workspaceId: string;
38
+ userId?: string;
39
+ purpose: GitHubCredentialPurpose;
40
+ };
41
+ export type ResolvedGitHubToken = {
42
+ token: string;
43
+ source: GitHubCredentialSource;
44
+ };
45
+ export interface GitHubCredentialProvider {
46
+ resolveGitHubToken(input: ResolveGitHubTokenInput): Promise<ResolvedGitHubToken>;
47
+ }
48
+ /** Options the state-file-backed credential provider accepts. */
49
+ export type GitHubStateCredentialProviderOptions = {
50
+ stateFile?: string;
51
+ stateDir?: string;
52
+ };
53
+ export type GitHubAuthStatus = {
54
+ readonly signedIn: boolean;
55
+ readonly login: string | null;
56
+ readonly userId: string | null;
57
+ readonly scopes: readonly string[];
58
+ readonly selectedRepo: string | null;
59
+ readonly oauthConfigured: boolean;
60
+ readonly tokenSource: "oauth-device" | "manual-token" | "env" | null;
61
+ };
62
+ export type GitHubUserInfo = {
63
+ readonly login: string;
64
+ readonly id: string;
65
+ readonly scopes?: readonly string[];
66
+ };
67
+ export type GitHubRepositoryProbe = {
68
+ readonly ok: boolean;
69
+ readonly owner: string;
70
+ readonly repo: string;
71
+ readonly status: number;
72
+ readonly authenticated: boolean;
73
+ readonly authenticationRequired: boolean;
74
+ readonly fullName: string | null;
75
+ readonly private: boolean | null;
76
+ readonly message: string;
77
+ readonly scopes: readonly string[];
78
+ };
79
+ export interface GitHubProjectSummary {
80
+ id: string;
81
+ number: number;
82
+ title: string;
83
+ url?: string;
84
+ }
85
+ export interface GitHubProjectStatusField {
86
+ id: string;
87
+ name: string;
88
+ options: Array<{
89
+ id: string;
90
+ name: string;
91
+ }>;
92
+ }
93
+ /**
94
+ * The executable surface the GitHub-provider capability `run()` returns. Kept
95
+ * intentionally narrow to the substrate-relevant seam (token resolution); the
96
+ * plugin's full API (OAuth device flow, Projects sync, issue analysis) is
97
+ * imported directly by above-runtime consumers and is not part of this port.
98
+ */
99
+ export interface GitHubProviderService {
100
+ createCredentialProvider(options?: GitHubCredentialProviderOptions): GitHubCredentialProvider;
101
+ }
102
+ /** The capability `run` shape the plugin registers: a zero-arg service factory. */
103
+ export type GitHubProviderServiceRun = () => GitHubProviderService;
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ // packages/contracts/src/github.ts
3
+ var GITHUB_PROVIDER_CAPABILITY_ID = "github.provider";
4
+ export {
5
+ GITHUB_PROVIDER_CAPABILITY_ID
6
+ };
@@ -313,7 +313,7 @@ var PRIMARY_GROUPS = [
313
313
  name: "graph",
314
314
  summary: "Workspace dependency graph.",
315
315
  usage: ["rig graph [--json|--dot]"],
316
- commands: [{ command: "[--json|--dot]", description: "Build the dependency graph through @rig/client and print summary, JSON, or DOT.", primary: true }],
316
+ commands: [{ command: "[--json|--dot]", description: "Build the workspace dependency graph and print summary, JSON, or DOT.", primary: true }],
317
317
  examples: ["rig graph", "rig graph --json", "rig graph --dot"]
318
318
  },
319
319
  {
@@ -44,3 +44,14 @@ export * from "./supervisor-journal";
44
44
  export * from "./planning";
45
45
  export * from "./drift";
46
46
  export * from "./rollups";
47
+ export * from "./panel-protocol";
48
+ export * from "./control-plane-types";
49
+ export * from "./lifecycle-capabilities";
50
+ export * from "./browser";
51
+ export * from "./memory";
52
+ export * from "./provider-instructions";
53
+ export * from "./isolation";
54
+ export * from "./managed-repos";
55
+ export * from "./task-graph-primitives";
56
+ export * from "./github";
57
+ export * from "./doctor";