@h-rig/contracts 0.0.6-alpha.157 → 0.0.6-alpha.159

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 (126) hide show
  1. package/dist/index.cjs +2340 -6832
  2. package/dist/index.mjs +2116 -6608
  3. package/dist/src/agent-roles.d.ts +8 -0
  4. package/dist/src/browser.d.ts +34 -4
  5. package/dist/src/browser.js +8 -1
  6. package/dist/src/capability-id.d.ts +22 -0
  7. package/dist/src/capability-id.js +8 -0
  8. package/dist/src/cli-output.d.ts +24 -0
  9. package/dist/src/cli-runner.d.ts +43 -0
  10. package/dist/src/cli-runner.js +13 -0
  11. package/dist/src/collab-session-viewer.d.ts +36 -0
  12. package/dist/src/collab-session-viewer.js +13 -0
  13. package/dist/src/config.d.ts +11 -0
  14. package/dist/src/config.js +279 -1098
  15. package/dist/src/control-plane-types.d.ts +41 -1
  16. package/dist/src/control-plane-types.js +9 -25
  17. package/dist/src/dependency-preflight.d.ts +43 -0
  18. package/dist/src/dependency-preflight.js +13 -0
  19. package/dist/src/doctor.d.ts +67 -4
  20. package/dist/src/doctor.js +8 -9
  21. package/dist/src/errors.d.ts +13 -0
  22. package/dist/src/errors.js +17 -0
  23. package/dist/src/github.d.ts +43 -0
  24. package/dist/src/github.js +12 -1
  25. package/dist/src/graph.d.ts +37 -0
  26. package/dist/src/graph.js +13 -0
  27. package/dist/src/guard.d.ts +111 -0
  28. package/dist/src/guard.js +6 -0
  29. package/dist/src/harness-events.d.ts +8 -0
  30. package/dist/src/harness-events.js +1 -0
  31. package/dist/src/help-catalog.d.ts +17 -10
  32. package/dist/src/help-catalog.js +9 -651
  33. package/dist/src/host.d.ts +41 -0
  34. package/dist/src/host.js +13 -0
  35. package/dist/src/identity.d.ts +44 -0
  36. package/dist/src/identity.js +1 -0
  37. package/dist/src/index.d.ts +27 -7
  38. package/dist/src/index.js +2116 -6608
  39. package/dist/src/isolation.d.ts +207 -15
  40. package/dist/src/isolation.js +8 -1
  41. package/dist/src/kernel.d.ts +11 -0
  42. package/dist/src/kernel.js +7 -0
  43. package/dist/src/layout.d.ts +49 -0
  44. package/dist/src/layout.js +10 -0
  45. package/dist/src/lifecycle-capabilities.d.ts +99 -0
  46. package/dist/src/lifecycle-capabilities.js +18 -1
  47. package/dist/src/managed-repos.d.ts +79 -16
  48. package/dist/src/managed-repos.js +12 -1
  49. package/dist/src/memory.d.ts +52 -4
  50. package/dist/src/memory.js +8 -1
  51. package/dist/src/notify.d.ts +46 -0
  52. package/dist/src/notify.js +13 -0
  53. package/dist/src/orchestration.d.ts +0 -3652
  54. package/dist/src/orchestration.js +28 -964
  55. package/dist/src/plugin-hooks.js +22 -3
  56. package/dist/src/plugin.d.ts +47 -0
  57. package/dist/src/plugin.js +24 -3
  58. package/dist/src/prompt.d.ts +29 -0
  59. package/dist/src/prompt.js +13 -0
  60. package/dist/src/provider-instructions.d.ts +26 -4
  61. package/dist/src/provider-instructions.js +8 -1
  62. package/dist/src/provider.js +1 -824
  63. package/dist/src/remote.d.ts +0 -8
  64. package/dist/src/remote.js +229 -1075
  65. package/dist/src/run-discovery.d.ts +79 -0
  66. package/dist/src/run-discovery.js +13 -0
  67. package/dist/src/run-dispatch.d.ts +34 -0
  68. package/dist/src/run-dispatch.js +13 -0
  69. package/dist/src/run-identity.d.ts +47 -0
  70. package/dist/src/run-identity.js +13 -0
  71. package/dist/src/run-journal.d.ts +0 -236
  72. package/dist/src/run-journal.js +249 -1321
  73. package/dist/src/run-read-model.d.ts +234 -0
  74. package/dist/src/run-read-model.js +13 -0
  75. package/dist/src/run-record.d.ts +0 -11
  76. package/dist/src/run-record.js +0 -16
  77. package/dist/src/run-registry-backbone.d.ts +56 -0
  78. package/dist/src/run-registry-backbone.js +13 -0
  79. package/dist/src/run-session-journal.d.ts +1 -25
  80. package/dist/src/run-session-journal.js +0 -1731
  81. package/dist/src/run-status.d.ts +0 -2
  82. package/dist/src/run-status.js +0 -11
  83. package/dist/src/run-timeline.d.ts +0 -3
  84. package/dist/src/run-timeline.js +0 -1498
  85. package/dist/src/runtime-task-context.d.ts +82 -0
  86. package/dist/src/runtime-task-context.js +1 -0
  87. package/dist/src/runtime.js +66 -904
  88. package/dist/src/session-asset-materializer.d.ts +35 -0
  89. package/dist/src/session-asset-materializer.js +13 -0
  90. package/dist/src/setup.d.ts +47 -0
  91. package/dist/src/setup.js +13 -0
  92. package/dist/src/supervisor-journal.js +117 -955
  93. package/dist/src/task-data.d.ts +239 -0
  94. package/dist/src/task-data.js +13 -0
  95. package/dist/src/task-graph-primitives.d.ts +0 -21
  96. package/dist/src/task-graph-primitives.js +0 -318
  97. package/dist/src/task-source.d.ts +65 -0
  98. package/dist/src/task-source.js +12 -0
  99. package/dist/src/task-state-metadata.d.ts +21 -0
  100. package/dist/src/task-state-metadata.js +1 -0
  101. package/dist/src/tool-materializer.d.ts +36 -0
  102. package/dist/src/tool-materializer.js +13 -0
  103. package/dist/src/tool-registry.d.ts +3 -0
  104. package/dist/src/tool-registry.js +58 -0
  105. package/dist/src/toolchain-sources.d.ts +54 -0
  106. package/dist/src/toolchain-sources.js +17 -0
  107. package/dist/src/workflow-journal.d.ts +0 -32
  108. package/dist/src/workflow-journal.js +0 -371
  109. package/dist/src/workspace-config.d.ts +18 -0
  110. package/dist/src/workspace-config.js +13 -0
  111. package/dist/src/workspace.js +73 -911
  112. package/package.json +1 -1
  113. package/dist/src/engine.d.ts +0 -2789
  114. package/dist/src/engine.js +0 -2392
  115. package/dist/src/ipc.d.ts +0 -248
  116. package/dist/src/providerRuntime.d.ts +0 -3949
  117. package/dist/src/providerRuntime.js +0 -1633
  118. package/dist/src/rig.d.ts +0 -783
  119. package/dist/src/rig.js +0 -2537
  120. package/dist/src/server.d.ts +0 -106
  121. package/dist/src/server.js +0 -1056
  122. package/dist/src/serviceFabric.d.ts +0 -62
  123. package/dist/src/serviceFabric.js +0 -1069
  124. package/dist/src/ws.d.ts +0 -747
  125. package/dist/src/ws.js +0 -3126
  126. /package/dist/src/{ipc.js → agent-roles.js} +0 -0
@@ -9,6 +9,7 @@
9
9
  * substrate (git-ops, task-ops) all reference one canonical definition without
10
10
  * importing each other.
11
11
  */
12
+ import type { CapabilityId } from "./capability-id";
12
13
  export type GitHubCommandResult = {
13
14
  readonly exitCode: number;
14
15
  readonly stdout?: string;
@@ -280,4 +281,43 @@ export type VerifyOutcome = {
280
281
  reviewFeedbackPath: string;
281
282
  reviewStatePath: string;
282
283
  };
283
- export declare function strictMergeHeadShaFromGate(result: StrictPrMergeGateResult, prUrl: string, requireGreptile?: boolean): string;
284
+ /** Capability id the pr-review plugin registers its merge-head-SHA resolver under. */
285
+ export declare const PR_MERGE_GATE_CAPABILITY_ID = "rig.mergeGate.resolveHeadSha";
286
+ /** Pure input to the merge-head-SHA resolver: the gate result + target PR. */
287
+ export type ResolveMergeHeadShaInput = {
288
+ readonly result: StrictPrMergeGateResult;
289
+ readonly prUrl: string;
290
+ /** Defaults to true at the impl; gate enforces Greptile freshness when set. */
291
+ readonly requireGreptile?: boolean;
292
+ };
293
+ /**
294
+ * The cohesive merge-gate seam the default lifecycle bundle depends on. Owned +
295
+ * provided by `@rig/pr-review-plugin` under {@link PR_MERGE_GATE_CAPABILITY_ID};
296
+ * `@rig/bundle-default-lifecycle` resolves it off the host instead of importing
297
+ * `@rig/pr-review-plugin`. Surfaces exactly the merge-gate operations the bundle
298
+ * uses (gate run + head-SHA resolution + the evidence-collection/evaluation
299
+ * primitives the verifier composes). Types only here — VOCAB, no behaviour.
300
+ */
301
+ export interface PrMergeGateService {
302
+ /**
303
+ * Given an approved gate result + PR url, return the raw 40-char head SHA it
304
+ * is safe to merge (throws when not approved / not tied to head). Pure.
305
+ */
306
+ resolveHeadSha(input: ResolveMergeHeadShaInput): string;
307
+ /** Run the full strict merge gate (collect evidence + evaluate + artifacts). */
308
+ runGate(input: StrictPrMergeGateInput): Promise<StrictPrMergeGateResult>;
309
+ /** Collect the PR review evidence the gate evaluates (IO). */
310
+ collectEvidence(input: StrictPrMergeGateInput): Promise<PrReviewEvidence>;
311
+ /** Evaluate already-collected evidence into a gate decision (pure). */
312
+ evaluateGate(evidence: PrReviewEvidence, requireGreptile?: boolean): Omit<StrictPrMergeGateResult, "artifacts" | "steeringPrompt">;
313
+ /** Parse a Greptile review score from a review body (pure). */
314
+ parseGreptileScore(input: string): GreptileScore | null;
315
+ /** Strip HTML to plain text (pure). */
316
+ stripHtml(input: string): string;
317
+ }
318
+ /**
319
+ * Typed capability id, phantom-typed with {@link PrMergeGateService} so
320
+ * `defineCapability(PR_MERGE_GATE)` resolves with no cast leaking to callers.
321
+ * String value is {@link PR_MERGE_GATE_CAPABILITY_ID}.
322
+ */
323
+ export declare const PR_MERGE_GATE: CapabilityId<PrMergeGateService>;
@@ -1,29 +1,13 @@
1
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;
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
26
5
  }
6
+
7
+ // packages/contracts/src/control-plane-types.ts
8
+ var PR_MERGE_GATE_CAPABILITY_ID = "rig.mergeGate.resolveHeadSha";
9
+ var PR_MERGE_GATE = makeCapabilityId(PR_MERGE_GATE_CAPABILITY_ID);
27
10
  export {
28
- strictMergeHeadShaFromGate
11
+ PR_MERGE_GATE_CAPABILITY_ID,
12
+ PR_MERGE_GATE
29
13
  };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The `workspace.dependency-preflight` capability seam.
3
+ *
4
+ * Pure capability VOCAB (no impl). The init/setup plugin (@rig/init-plugin)
5
+ * PROVIDES the concrete service — it mutates `package.json` to pin the project's
6
+ * `@rig/*` config deps and runs the package manager's install — and the CLI seed
7
+ * (`packages/cli/bin/rig.ts`) RESOLVES it by id off a plugin host built from the
8
+ * embedded standard plugins, invoking it only on the rig.config.ts power-path
9
+ * fallback (a code config present that the project-binary build did not handle).
10
+ *
11
+ * The heavy install/mutate impl therefore lives in the setup plugin, NOT in a
12
+ * CLI seed module on the hot path: the seed neither imports nor bundles it
13
+ * eagerly — it is reached purely through this typed seam.
14
+ */
15
+ import type { CapabilityId } from "./capability-id";
16
+ /** Inputs the CLI seed hands the preflight. The CLI owns version detection (it
17
+ * reads its OWN installed version), so it passes the resolved values in rather
18
+ * than the floor library reaching back into CLI-specific version resolution. */
19
+ export type RigConfigDependencyPreflightInput = {
20
+ /** Project root whose `package.json` / config deps are reconciled. */
21
+ readonly projectRoot: string;
22
+ /** The CLI's own resolved installed version (drives the `@rig/*` dep pin). */
23
+ readonly installedCliVersion: string;
24
+ /** Whether {@link installedCliVersion} is a published (non source/dev) version;
25
+ * when false the deps pin to `latest`. */
26
+ readonly isInstalledCliVersionPublished: boolean;
27
+ };
28
+ /** Outcome of a dependency preflight pass. */
29
+ export type RigConfigDependencyPreflightResult = {
30
+ readonly rewroteManifest: boolean;
31
+ readonly ranInstall: boolean;
32
+ readonly command: string | null;
33
+ readonly version: string;
34
+ };
35
+ /** The dependency-preflight service the setup plugin provides and the CLI seed
36
+ * resolves by id off a host. */
37
+ export interface RigConfigDependencyPreflightService {
38
+ ensureInstalled(input: RigConfigDependencyPreflightInput): RigConfigDependencyPreflightResult;
39
+ }
40
+ /** The capability id string the setup plugin provides and the CLI seed resolves. */
41
+ export declare const DEPENDENCY_PREFLIGHT_CAPABILITY_ID = "workspace.dependency-preflight";
42
+ /** The typed capability id, phantom-typed with {@link RigConfigDependencyPreflightService}. */
43
+ export declare const DEPENDENCY_PREFLIGHT_CAPABILITY: CapabilityId<RigConfigDependencyPreflightService>;
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/dependency-preflight.ts
8
+ var DEPENDENCY_PREFLIGHT_CAPABILITY_ID = "workspace.dependency-preflight";
9
+ var DEPENDENCY_PREFLIGHT_CAPABILITY = makeCapabilityId(DEPENDENCY_PREFLIGHT_CAPABILITY_ID);
10
+ export {
11
+ DEPENDENCY_PREFLIGHT_CAPABILITY_ID,
12
+ DEPENDENCY_PREFLIGHT_CAPABILITY
13
+ };
@@ -9,6 +9,7 @@
9
9
  * {@link DOCTOR_RUNNER_CAPABILITY_ID}. This file holds ONLY the pure types and
10
10
  * pure helpers shared by producer and consumers — no IO, no plugin imports.
11
11
  */
12
+ import type { CapabilityId } from "./capability-id";
12
13
  /** The capability id the doctor plugin registers its runner under. */
13
14
  export declare const DOCTOR_RUNNER_CAPABILITY_ID = "doctor.runner";
14
15
  export type DoctorStatus = "pass" | "warn" | "fail";
@@ -21,7 +22,69 @@ export type DoctorCheck = {
21
22
  readonly detail?: string;
22
23
  readonly remediation?: string;
23
24
  };
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;
25
+ /**
26
+ * Structural mirror of the runtime's `RigIdentityContext` (in
27
+ * `@rig/runtime/control-plane/identity`). The diagnostic runner reads the
28
+ * GitHub/session identity off this context; the field references a runtime
29
+ * shape, so — exactly like memory's `MemoryCommandEventSink` — it is typed here
30
+ * as a minimal contracts-owned interface carrying only the structure the runner
31
+ * needs. The runtime's `RigIdentityContext` is structurally identical and so
32
+ * flows in/out without a cast, keeping the contract free of any runtime import.
33
+ */
34
+ export interface DoctorIdentityContext {
35
+ readonly sessionManager: {
36
+ getCwd(): string;
37
+ getSessionId(): string;
38
+ getBranch(): readonly {
39
+ type: string;
40
+ customType?: string;
41
+ data?: unknown;
42
+ }[];
43
+ };
44
+ readonly modelRegistry?: {
45
+ readonly authStorage?: {
46
+ getOAuthAccountIdentity?: (provider: string, sessionId?: string) => unknown;
47
+ };
48
+ };
49
+ }
50
+ /**
51
+ * Options the substrate passes through to the diagnostic runner. The function
52
+ * fields are typed loosely (the consumers only read `.length`/labels); the
53
+ * plugin impl supplies concrete client-backed defaults. Keeping these signatures
54
+ * free of @rig/client types keeps the contract (and runtime) decoupled from
55
+ * client.
56
+ */
57
+ export type RunDoctorChecksOptions = {
58
+ readonly projectRoot: string;
59
+ readonly requestJson?: (pathname: string, init?: RequestInit) => Promise<unknown>;
60
+ readonly piChecks?: () => Promise<readonly {
61
+ ok: boolean;
62
+ label: string;
63
+ detail?: string;
64
+ hint?: string;
65
+ }[]>;
66
+ readonly which?: (binary: string) => string | null;
67
+ readonly bunVersion?: string;
68
+ readonly loadConfig?: (projectRoot: string) => Promise<unknown>;
69
+ readonly onProgress?: (label: string) => void;
70
+ readonly identityContext?: DoctorIdentityContext;
71
+ readonly listRuns?: (projectRoot: string) => Promise<readonly unknown[]>;
72
+ readonly listPlacements?: (projectRoot: string) => readonly unknown[];
73
+ };
74
+ /**
75
+ * The cohesive diagnostic operation the substrate depends on. This is pure
76
+ * capability VOCAB: `@rig/doctor-plugin` provides a concrete impl (statically
77
+ * checked against this interface via `DoctorCap.provide`), and the substrate
78
+ * only ever sees this contract — resolved by id off a plugin host with no
79
+ * `as unknown as` at any call site.
80
+ */
81
+ export interface DoctorService {
82
+ runDoctorChecks(options: RunDoctorChecksOptions): Promise<DoctorCheck[]>;
83
+ }
84
+ /**
85
+ * The typed capability id the doctor plugin provides and consumers require.
86
+ * Phantom-typed with {@link DoctorService} so `DoctorCap.require(host)` returns
87
+ * a `DoctorService` with no cast leaking to callers. Its string value is
88
+ * {@link DOCTOR_RUNNER_CAPABILITY_ID}, so it indexes the same host entry.
89
+ */
90
+ export declare const DOCTOR: CapabilityId<DoctorService>;
@@ -1,14 +1,13 @@
1
1
  // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
2
7
  // packages/contracts/src/doctor.ts
3
8
  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
- }
9
+ var DOCTOR = makeCapabilityId(DOCTOR_RUNNER_CAPABILITY_ID);
10
10
  export {
11
- doctorLevelToStatus,
12
- countDoctorFailures,
13
- DOCTOR_RUNNER_CAPABILITY_ID
11
+ DOCTOR_RUNNER_CAPABILITY_ID,
12
+ DOCTOR
14
13
  };
@@ -0,0 +1,13 @@
1
+ export declare class CliError extends Error {
2
+ readonly exitCode: number;
3
+ /**
4
+ * Optional remediation hint. Rendered on its own `Next: <hint>` line (and
5
+ * carried in the `--json` error payload) so a failure can name the next
6
+ * command to run. Pure vocab — the exec machinery (now in @rig/guard-plugin)
7
+ * throws this with a hint without importing a CLI-seed error class.
8
+ */
9
+ readonly hint?: string;
10
+ constructor(message: string, exitCode?: number, options?: {
11
+ readonly hint?: string;
12
+ });
13
+ }
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ // packages/contracts/src/errors.ts
3
+ class CliError extends Error {
4
+ exitCode;
5
+ hint;
6
+ constructor(message, exitCode = 1, options = {}) {
7
+ super(message);
8
+ this.name = "CliError";
9
+ this.exitCode = exitCode;
10
+ if (options.hint?.trim()) {
11
+ this.hint = options.hint.trim();
12
+ }
13
+ }
14
+ }
15
+ export {
16
+ CliError
17
+ };
@@ -17,6 +17,7 @@
17
17
  * @rig/runtime/control-plane/github/token-env as a dumb reader; the policy that
18
18
  * produces that token lives in this plugin.)
19
19
  */
20
+ import type { CapabilityId } from "./capability-id";
20
21
  /** Capability id the GitHub-provider plugin registers its service factory under. */
21
22
  export declare const GITHUB_PROVIDER_CAPABILITY_ID = "github.provider";
22
23
  export type GitHubCredentialPurpose = "selected-repo" | "admin-fallback";
@@ -101,3 +102,45 @@ export interface GitHubProviderService {
101
102
  }
102
103
  /** The capability `run` shape the plugin registers: a zero-arg service factory. */
103
104
  export type GitHubProviderServiceRun = () => GitHubProviderService;
105
+ /**
106
+ * Typed capability id, phantom-typed with {@link GitHubProviderService} so
107
+ * consumers (task-sources/doctor/init) resolve it off the host with no cast.
108
+ * String value is {@link GITHUB_PROVIDER_CAPABILITY_ID}.
109
+ */
110
+ export declare const GITHUB_PROVIDER: CapabilityId<GitHubProviderService>;
111
+ /** Capability id the issue-triage provider registers its runner under. */
112
+ export declare const ISSUE_TRIAGE_CAPABILITY_ID = "cap:issue-triage";
113
+ /** Pure input to a triage pass: which project + an optional reason label. */
114
+ export type IssueTriageInput = {
115
+ readonly projectRoot: string;
116
+ readonly reason?: string;
117
+ };
118
+ /**
119
+ * Pure summary of a triage pass. Contracts-owned mirror of the plugin's
120
+ * `IssueAnalysisTriageRunResult` so substrate consumers read the outcome
121
+ * without importing the plugin. Structurally compatible with the impl result.
122
+ */
123
+ export type IssueTriageResult = {
124
+ readonly ok: true;
125
+ readonly enabled: boolean;
126
+ readonly reason: string;
127
+ readonly sourceId: string | null;
128
+ readonly sourceKind: string | null;
129
+ readonly analyzedIssues: number;
130
+ readonly metadataPatches: number;
131
+ readonly labelsAdded: number;
132
+ readonly labelsRemoved: number;
133
+ readonly generatedIssues: number;
134
+ readonly writeBackRefreshes: number;
135
+ readonly refreshedIssueCount: number | null;
136
+ readonly skippedReason?: "no-config" | "disabled";
137
+ };
138
+ /** The cohesive triage operation the CLI surface depends on. Async (does IO). */
139
+ export interface IssueTriageService {
140
+ runTriage(input: IssueTriageInput): Promise<IssueTriageResult>;
141
+ }
142
+ /**
143
+ * Typed capability id, phantom-typed with {@link IssueTriageService}. String
144
+ * value is {@link ISSUE_TRIAGE_CAPABILITY_ID}.
145
+ */
146
+ export declare const ISSUE_TRIAGE: CapabilityId<IssueTriageService>;
@@ -1,6 +1,17 @@
1
1
  // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
2
7
  // packages/contracts/src/github.ts
3
8
  var GITHUB_PROVIDER_CAPABILITY_ID = "github.provider";
9
+ var GITHUB_PROVIDER = makeCapabilityId(GITHUB_PROVIDER_CAPABILITY_ID);
10
+ var ISSUE_TRIAGE_CAPABILITY_ID = "cap:issue-triage";
11
+ var ISSUE_TRIAGE = makeCapabilityId(ISSUE_TRIAGE_CAPABILITY_ID);
4
12
  export {
5
- GITHUB_PROVIDER_CAPABILITY_ID
13
+ ISSUE_TRIAGE_CAPABILITY_ID,
14
+ ISSUE_TRIAGE,
15
+ GITHUB_PROVIDER_CAPABILITY_ID,
16
+ GITHUB_PROVIDER
6
17
  };
@@ -1,4 +1,5 @@
1
1
  import { Schema } from "effect";
2
+ import type { CapabilityId } from "./capability-id";
2
3
  export declare const TaskStatus: Schema.Literals<readonly ["draft", "open", "ready", "queued", "running", "in_progress", "under_review", "blocked", "unknown", "completed", "failed", "cancelled", "closed"]>;
3
4
  export type TaskStatus = typeof TaskStatus.Type;
4
5
  export declare const GraphSummary: Schema.Struct<{
@@ -321,3 +322,39 @@ export declare const DependencyGraphModel: Schema.Struct<{
321
322
  readonly generatedAt: Schema.String;
322
323
  }>;
323
324
  export type DependencyGraphModel = typeof DependencyGraphModel.Type;
325
+ /** Capability id the dependency-graph plugin registers its project-graph builder under. */
326
+ export declare const GRAPH_PROJECT_CAPABILITY_ID = "rig.graph.project";
327
+ /** Pure input to the project-graph builder: which workspace to analyze. */
328
+ export type GraphProjectInput = {
329
+ readonly projectRoot: string;
330
+ };
331
+ /** The cohesive project-graph operation the substrate depends on. Async (does IO). */
332
+ export interface GraphProjectService {
333
+ buildProjectGraph(input: GraphProjectInput): Promise<DependencyGraphModel>;
334
+ }
335
+ /** Typed capability id; string value is {@link GRAPH_PROJECT_CAPABILITY_ID}. */
336
+ export declare const GRAPH_PROJECT: CapabilityId<GraphProjectService>;
337
+ /** Capability id the dependency-graph plugin registers its task selector under. */
338
+ export declare const TASK_SELECTION_CAPABILITY_ID = "cap:task-selection";
339
+ /** Pure filters narrowing which tasks are eligible for selection. */
340
+ export type TaskSelectionFilters = {
341
+ readonly assignee?: string;
342
+ readonly state?: "open" | "closed";
343
+ readonly search?: string;
344
+ };
345
+ /** Pure input to task selection: which workspace + optional filters. */
346
+ export type TaskSelectionInput = {
347
+ readonly projectRoot: string;
348
+ readonly filters?: TaskSelectionFilters;
349
+ };
350
+ /** Pure result of task selection: the next ready task + the ready set it came from. */
351
+ export type TaskSelectionResult = {
352
+ readonly selected: TaskSummary | null;
353
+ readonly ready: readonly TaskSummary[];
354
+ };
355
+ /** The cohesive task-selection operation the CLI surface depends on. Async (does IO). */
356
+ export interface TaskSelectionService {
357
+ selectNextReadyTask(input: TaskSelectionInput): Promise<TaskSelectionResult>;
358
+ }
359
+ /** Typed capability id; string value is {@link TASK_SELECTION_CAPABILITY_ID}. */
360
+ export declare const TASK_SELECTION: CapabilityId<TaskSelectionService>;
package/dist/src/graph.js CHANGED
@@ -39,6 +39,11 @@ var ApprovalRequestId = makeEntityId("ApprovalRequestId");
39
39
  var CheckpointRef = makeEntityId("CheckpointRef");
40
40
  var RemoteEndpointId = makeEntityId("RemoteEndpointId");
41
41
 
42
+ // packages/contracts/src/capability-id.ts
43
+ function makeCapabilityId(id) {
44
+ return id;
45
+ }
46
+
42
47
  // packages/contracts/src/graph.ts
43
48
  var TaskStatus = Schema2.Literals([
44
49
  "draft",
@@ -196,6 +201,10 @@ var DependencyGraphModel = Schema2.Struct({
196
201
  degraded: Schema2.Boolean,
197
202
  generatedAt: IsoDateTime
198
203
  });
204
+ var GRAPH_PROJECT_CAPABILITY_ID = "rig.graph.project";
205
+ var GRAPH_PROJECT = makeCapabilityId(GRAPH_PROJECT_CAPABILITY_ID);
206
+ var TASK_SELECTION_CAPABILITY_ID = "cap:task-selection";
207
+ var TASK_SELECTION = makeCapabilityId(TASK_SELECTION_CAPABILITY_ID);
199
208
  export {
200
209
  TaskSummary,
201
210
  TaskStatus,
@@ -204,8 +213,12 @@ export {
204
213
  TaskGraphLayout,
205
214
  TaskGraphLane,
206
215
  TaskGraphEdge,
216
+ TASK_SELECTION_CAPABILITY_ID,
217
+ TASK_SELECTION,
207
218
  QueueEntry,
208
219
  GraphSummary,
220
+ GRAPH_PROJECT_CAPABILITY_ID,
221
+ GRAPH_PROJECT,
209
222
  DependencyNode,
210
223
  DependencyGraphModel,
211
224
  DependencyEdgeType,
@@ -0,0 +1,111 @@
1
+ import type { PolicyMode } from "./policy";
2
+ export declare const POLICY_VERSION: 1;
3
+ export type PolicyVersion = typeof POLICY_VERSION;
4
+ export type { PolicyMode };
5
+ export type RuleCategory = "command" | "content" | "import" | "test-integrity";
6
+ export type RuleAction = "block" | "warn";
7
+ export type RuleAppliesTo = "test-files";
8
+ export type RuleMatch = {
9
+ pattern?: string;
10
+ regex?: string;
11
+ };
12
+ export type RuleUnless = {
13
+ regex?: string;
14
+ task_in?: string[];
15
+ };
16
+ export type PolicyRule = {
17
+ id: string;
18
+ category: RuleCategory;
19
+ description?: string;
20
+ match: RuleMatch;
21
+ unless?: RuleUnless;
22
+ action: RuleAction;
23
+ applies_to?: RuleAppliesTo;
24
+ compiledRegex?: RegExp;
25
+ compiledUnlessRegex?: RegExp;
26
+ };
27
+ export type ScopeConfig = {
28
+ fail_closed: boolean;
29
+ harness_paths_exempt: boolean;
30
+ runtime_paths_exempt: boolean;
31
+ };
32
+ export type SandboxConfig = {
33
+ mode: PolicyMode;
34
+ network: boolean;
35
+ read_deny: string[];
36
+ write_allow_from_runtime: boolean;
37
+ };
38
+ export type IsolationConfig = {
39
+ default_mode: "worktree";
40
+ repo_symlink_fallback: boolean;
41
+ strict_provisioning: boolean;
42
+ fail_closed_on_provision_error: boolean;
43
+ };
44
+ export type CompletionConfig = {
45
+ derive_checks_from_scope: boolean;
46
+ checks: string[];
47
+ typescript_config_probe: string[];
48
+ eslint_config_probe: string[];
49
+ };
50
+ export type RuntimeImageDeps = {
51
+ monorepo_install: boolean;
52
+ hp_next_install: boolean;
53
+ };
54
+ export type RuntimeImageConfig = {
55
+ deps: RuntimeImageDeps;
56
+ plugins_require_binaries: boolean;
57
+ };
58
+ export type RuntimeSnapshotConfig = {
59
+ enabled: boolean;
60
+ };
61
+ export type PolicyConfig = {
62
+ version: PolicyVersion;
63
+ mode: PolicyMode;
64
+ scope: ScopeConfig;
65
+ rules: PolicyRule[];
66
+ sandbox: SandboxConfig;
67
+ isolation: IsolationConfig;
68
+ completion: CompletionConfig;
69
+ runtime_image?: RuntimeImageConfig;
70
+ runtime_snapshot?: RuntimeSnapshotConfig;
71
+ };
72
+ export type ToolCallEvaluation = {
73
+ type: "tool-call";
74
+ tool_name: string;
75
+ tool_input: Record<string, unknown>;
76
+ };
77
+ export type CommandEvaluation = {
78
+ type: "command";
79
+ command: string;
80
+ };
81
+ export type ContentWriteEvaluation = {
82
+ type: "content-write";
83
+ file_path: string;
84
+ content: string;
85
+ };
86
+ export type FileAccessEvaluation = {
87
+ type: "file-access";
88
+ file_path: string;
89
+ access: "read" | "write";
90
+ };
91
+ export type GuardEvaluation = ToolCallEvaluation | CommandEvaluation | ContentWriteEvaluation | FileAccessEvaluation;
92
+ export type GuardContext = {
93
+ projectRoot: string;
94
+ monorepoRoot?: string;
95
+ taskId?: string;
96
+ taskScopes?: string[];
97
+ taskWorkspace?: string;
98
+ evaluation: GuardEvaluation;
99
+ };
100
+ export type MatchedRule = {
101
+ id: string;
102
+ category: RuleCategory;
103
+ description?: string;
104
+ reason: string;
105
+ };
106
+ export type GuardDecision = {
107
+ allowed: boolean;
108
+ matchedRules: MatchedRule[];
109
+ action: "allow" | "block" | "warn";
110
+ failClosed: boolean;
111
+ };
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ // packages/contracts/src/guard.ts
3
+ var POLICY_VERSION = 1;
4
+ export {
5
+ POLICY_VERSION
6
+ };
@@ -0,0 +1,8 @@
1
+ export type HarnessEventType = "runtime.init" | "command.received" | "policy.decision" | "command.started" | "command.finished" | "command.failed" | "plugin.loaded" | "plugin.error" | "validator.started" | "validator.finished" | "queue.started" | "queue.task.started" | "queue.task.finished" | "queue.finished" | "memory.command.requested" | "memory.command.applied" | "memory.command.failed";
2
+ export type HarnessEvent<TPayload = Record<string, unknown>> = {
3
+ id: string;
4
+ runId: string;
5
+ timestamp: string;
6
+ type: HarnessEventType;
7
+ payload: TPayload;
8
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -1,3 +1,4 @@
1
+ import type { CapabilityId } from "./capability-id";
1
2
  export type HelpCommand = {
2
3
  command: string;
3
4
  description: string;
@@ -21,14 +22,20 @@ export type TopLevelSection = {
21
22
  subtitle: string;
22
23
  commands: HelpCommand[];
23
24
  };
24
- /** Catalog DATA for the app's help view the view builds its own layout
25
- * from these; the render* functions below remain for plain/script output. */
26
- export declare function helpCatalog(): {
27
- sections: readonly TopLevelSection[];
28
- groups: readonly HelpGroup[];
25
+ /** The full help catalog payload: top-level sections + command groups. */
26
+ export type HelpCatalog = {
27
+ readonly sections: readonly TopLevelSection[];
28
+ readonly groups: readonly HelpGroup[];
29
+ /** Compatibility/internal commands shown only from advanced help. */
30
+ readonly advancedCommands?: readonly HelpCommand[];
31
+ /** Group names shown under advanced help; omitted means every group is shown. */
32
+ readonly advancedGroupNames?: readonly string[];
29
33
  };
30
- export declare const TOP_LEVEL_SECTIONS: TopLevelSection[];
31
- export declare const PRIMARY_GROUPS: HelpGroup[];
32
- export declare const ADVANCED_GROUPS: HelpGroup[];
33
- export declare const ADVANCED_COMMANDS: HelpCommand[];
34
- export declare const ALL_GROUPS: HelpGroup[];
34
+ /** Capability id the CLI-surface plugin registers its help-catalog provider under. */
35
+ export declare const HELP_CATALOG_CAPABILITY_ID = "rig.help.catalog";
36
+ /** The cohesive help-catalog operation the cockpit depends on. Pure (data only). */
37
+ export interface HelpCatalogService {
38
+ helpCatalog(): HelpCatalog;
39
+ }
40
+ /** Typed capability id; string value is {@link HELP_CATALOG_CAPABILITY_ID}. */
41
+ export declare const HELP_CATALOG: CapabilityId<HelpCatalogService>;