@h-rig/core 0.0.6-alpha.64 → 0.0.6-alpha.66

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.
@@ -2,6 +2,13 @@
2
2
  // packages/core/src/define-config.ts
3
3
  import { Schema } from "effect";
4
4
  import { RigConfig } from "@rig/contracts";
5
+ function normalizeWorkspaceConfig(raw) {
6
+ const workspace = raw && typeof raw === "object" && !Array.isArray(raw) ? { ...raw } : { mainRepo: "." };
7
+ workspace.checkout = workspace.checkout ?? workspace.isolation ?? "worktree";
8
+ workspace.isolation = workspace.isolation ?? workspace.checkout;
9
+ workspace.sandbox = workspace.sandbox ?? "enforce";
10
+ return workspace;
11
+ }
5
12
  function applyConfigDefaults(raw) {
6
13
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
7
14
  return raw;
@@ -9,7 +16,7 @@ function applyConfigDefaults(raw) {
9
16
  return {
10
17
  ...record,
11
18
  plugins: Array.isArray(record.plugins) ? record.plugins : [],
12
- workspace: record.workspace && typeof record.workspace === "object" && !Array.isArray(record.workspace) ? record.workspace : { mainRepo: ".", isolation: "worktree" }
19
+ workspace: normalizeWorkspaceConfig(record.workspace)
13
20
  };
14
21
  }
15
22
  function defineConfig(cfg) {
@@ -43,6 +43,23 @@ function definePlugin(meta, runtime) {
43
43
  }
44
44
  }
45
45
  }
46
+ const declaredHooks = new Map((validated.contributes?.hooks ?? []).map((h) => [h.id, h]));
47
+ for (const hookId of Object.keys(runtime.hooks ?? {})) {
48
+ const metadata = declaredHooks.get(hookId);
49
+ if (!metadata) {
50
+ throw new Error(`definePlugin(${validated.name}): typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
51
+ }
52
+ if (metadata.command) {
53
+ throw new Error(`definePlugin(${validated.name}): hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
54
+ }
55
+ }
56
+ if (runtime.hooks) {
57
+ for (const h of declaredHooks.values()) {
58
+ if (!runtime.hooks[h.id] && !h.command) {
59
+ throw new Error(`definePlugin(${validated.name}): hook metadata "${h.id}" has no implementation (typed function or command)`);
60
+ }
61
+ }
62
+ }
46
63
  return { ...validated, __runtime: runtime };
47
64
  }
48
65
  export {
@@ -149,7 +149,7 @@ function mapLegacySessionStatusToRunStatus(status) {
149
149
  case "error":
150
150
  return "failed";
151
151
  case "stopped":
152
- return "cancelled";
152
+ return "stopped";
153
153
  default:
154
154
  return "created";
155
155
  }
@@ -185,12 +185,15 @@ function mapTaskStatusFromRunStatus(status, fallback) {
185
185
  case "paused":
186
186
  return "in_progress";
187
187
  case "reviewing":
188
+ case "closing-out":
188
189
  return "under_review";
190
+ case "needs-attention":
191
+ return "blocked";
189
192
  case "completed":
190
193
  return "completed";
191
194
  case "failed":
192
195
  return "ready";
193
- case "cancelled":
196
+ case "stopped":
194
197
  return "cancelled";
195
198
  }
196
199
  }
@@ -1040,7 +1043,7 @@ function applyEngineEvent(snapshot, event) {
1040
1043
  ...base,
1041
1044
  runs: patchById(base.runs, payload.runId, (run) => ({
1042
1045
  ...run,
1043
- status: "cancelled",
1046
+ status: "stopped",
1044
1047
  updatedAt: payload.createdAt,
1045
1048
  completedAt: payload.createdAt
1046
1049
  }))
package/dist/src/index.js CHANGED
@@ -43,11 +43,35 @@ function definePlugin(meta, runtime) {
43
43
  }
44
44
  }
45
45
  }
46
+ const declaredHooks = new Map((validated.contributes?.hooks ?? []).map((h) => [h.id, h]));
47
+ for (const hookId of Object.keys(runtime.hooks ?? {})) {
48
+ const metadata = declaredHooks.get(hookId);
49
+ if (!metadata) {
50
+ throw new Error(`definePlugin(${validated.name}): typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
51
+ }
52
+ if (metadata.command) {
53
+ throw new Error(`definePlugin(${validated.name}): hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
54
+ }
55
+ }
56
+ if (runtime.hooks) {
57
+ for (const h of declaredHooks.values()) {
58
+ if (!runtime.hooks[h.id] && !h.command) {
59
+ throw new Error(`definePlugin(${validated.name}): hook metadata "${h.id}" has no implementation (typed function or command)`);
60
+ }
61
+ }
62
+ }
46
63
  return { ...validated, __runtime: runtime };
47
64
  }
48
65
  // packages/core/src/define-config.ts
49
66
  import { Schema as Schema2 } from "effect";
50
67
  import { RigConfig } from "@rig/contracts";
68
+ function normalizeWorkspaceConfig(raw) {
69
+ const workspace = raw && typeof raw === "object" && !Array.isArray(raw) ? { ...raw } : { mainRepo: "." };
70
+ workspace.checkout = workspace.checkout ?? workspace.isolation ?? "worktree";
71
+ workspace.isolation = workspace.isolation ?? workspace.checkout;
72
+ workspace.sandbox = workspace.sandbox ?? "enforce";
73
+ return workspace;
74
+ }
51
75
  function applyConfigDefaults(raw) {
52
76
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
53
77
  return raw;
@@ -55,7 +79,7 @@ function applyConfigDefaults(raw) {
55
79
  return {
56
80
  ...record,
57
81
  plugins: Array.isArray(record.plugins) ? record.plugins : [],
58
- workspace: record.workspace && typeof record.workspace === "object" && !Array.isArray(record.workspace) ? record.workspace : { mainRepo: ".", isolation: "worktree" }
82
+ workspace: normalizeWorkspaceConfig(record.workspace)
59
83
  };
60
84
  }
61
85
  function defineConfig(cfg) {
@@ -134,6 +158,24 @@ function assertRuntimeMatchesMetadata(plugin) {
134
158
  }
135
159
  }
136
160
  }
161
+ const declaredHooks = new Map((plugin.contributes?.hooks ?? []).map((hook) => [hook.id, hook]));
162
+ const runtimeHooks = plugin.__runtime?.hooks;
163
+ for (const hookId of Object.keys(runtimeHooks ?? {})) {
164
+ const metadata = declaredHooks.get(hookId);
165
+ if (!metadata) {
166
+ throw new Error(`plugin "${plugin.name}" typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
167
+ }
168
+ if (metadata.command) {
169
+ throw new Error(`plugin "${plugin.name}" hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
170
+ }
171
+ }
172
+ if (runtimeHooks) {
173
+ for (const hook of declaredHooks.values()) {
174
+ if (!runtimeHooks[hook.id] && !hook.command) {
175
+ throw new Error(`plugin "${plugin.name}" hook metadata "${hook.id}" has no implementation (typed function or command)`);
176
+ }
177
+ }
178
+ }
137
179
  }
138
180
  function createPluginHost(plugins) {
139
181
  assertUniquePluginNames(plugins);
@@ -432,7 +474,7 @@ function mapLegacySessionStatusToRunStatus(status) {
432
474
  case "error":
433
475
  return "failed";
434
476
  case "stopped":
435
- return "cancelled";
477
+ return "stopped";
436
478
  default:
437
479
  return "created";
438
480
  }
@@ -468,12 +510,15 @@ function mapTaskStatusFromRunStatus(status, fallback) {
468
510
  case "paused":
469
511
  return "in_progress";
470
512
  case "reviewing":
513
+ case "closing-out":
471
514
  return "under_review";
515
+ case "needs-attention":
516
+ return "blocked";
472
517
  case "completed":
473
518
  return "completed";
474
519
  case "failed":
475
520
  return "ready";
476
- case "cancelled":
521
+ case "stopped":
477
522
  return "cancelled";
478
523
  }
479
524
  }
@@ -1323,7 +1368,7 @@ function applyEngineEvent(snapshot, event) {
1323
1368
  ...base,
1324
1369
  runs: patchById(base.runs, payload.runId, (run) => ({
1325
1370
  ...run,
1326
- status: "cancelled",
1371
+ status: "stopped",
1327
1372
  updatedAt: payload.createdAt,
1328
1373
  completedAt: payload.createdAt
1329
1374
  }))
@@ -10,6 +10,13 @@ import { RigConfig as RigConfig2 } from "@rig/contracts";
10
10
  // packages/core/src/define-config.ts
11
11
  import { Schema } from "effect";
12
12
  import { RigConfig } from "@rig/contracts";
13
+ function normalizeWorkspaceConfig(raw) {
14
+ const workspace = raw && typeof raw === "object" && !Array.isArray(raw) ? { ...raw } : { mainRepo: "." };
15
+ workspace.checkout = workspace.checkout ?? workspace.isolation ?? "worktree";
16
+ workspace.isolation = workspace.isolation ?? workspace.checkout;
17
+ workspace.sandbox = workspace.sandbox ?? "enforce";
18
+ return workspace;
19
+ }
13
20
  function applyConfigDefaults(raw) {
14
21
  if (!raw || typeof raw !== "object" || Array.isArray(raw))
15
22
  return raw;
@@ -17,7 +24,7 @@ function applyConfigDefaults(raw) {
17
24
  return {
18
25
  ...record,
19
26
  plugins: Array.isArray(record.plugins) ? record.plugins : [],
20
- workspace: record.workspace && typeof record.workspace === "object" && !Array.isArray(record.workspace) ? record.workspace : { mainRepo: ".", isolation: "worktree" }
27
+ workspace: normalizeWorkspaceConfig(record.workspace)
21
28
  };
22
29
  }
23
30
 
@@ -58,6 +58,24 @@ function assertRuntimeMatchesMetadata(plugin) {
58
58
  }
59
59
  }
60
60
  }
61
+ const declaredHooks = new Map((plugin.contributes?.hooks ?? []).map((hook) => [hook.id, hook]));
62
+ const runtimeHooks = plugin.__runtime?.hooks;
63
+ for (const hookId of Object.keys(runtimeHooks ?? {})) {
64
+ const metadata = declaredHooks.get(hookId);
65
+ if (!metadata) {
66
+ throw new Error(`plugin "${plugin.name}" typed hook "${hookId}" has no matching metadata entry in contributes.hooks`);
67
+ }
68
+ if (metadata.command) {
69
+ throw new Error(`plugin "${plugin.name}" hook "${hookId}" has both a typed implementation and a command string \u2014 pick one`);
70
+ }
71
+ }
72
+ if (runtimeHooks) {
73
+ for (const hook of declaredHooks.values()) {
74
+ if (!runtimeHooks[hook.id] && !hook.command) {
75
+ throw new Error(`plugin "${plugin.name}" hook metadata "${hook.id}" has no implementation (typed function or command)`);
76
+ }
77
+ }
78
+ }
61
79
  }
62
80
  function createPluginHost(plugins) {
63
81
  assertUniquePluginNames(plugins);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@h-rig/core",
3
- "version": "0.0.6-alpha.64",
3
+ "version": "0.0.6-alpha.66",
4
4
  "type": "module",
5
5
  "description": "Rig package",
6
6
  "license": "UNLICENSED",
@@ -31,7 +31,7 @@
31
31
  "main": "./dist/src/index.js",
32
32
  "module": "./dist/src/index.js",
33
33
  "dependencies": {
34
- "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.64",
34
+ "@rig/contracts": "npm:@h-rig/contracts@0.0.6-alpha.66",
35
35
  "effect": "4.0.0-beta.78"
36
36
  }
37
37
  }