opencode-completion-gate 2.0.0 → 2.1.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.1.0](https://github.com/PauloDevelo/opencode-completion-gate/compare/v2.0.1...v2.1.0) (2026-11-19)
4
+
5
+
6
+ ### Features
7
+
8
+ * **config:** accept one command per platform for run ([#16](https://github.com/PauloDevelo/opencode-completion-gate/issues/16)) ([17299e9](https://github.com/PauloDevelo/opencode-completion-gate/commit/17299e9984b9c75beb387eea182aff05c842e240))
9
+
10
+ ## [2.0.1](https://github.com/PauloDevelo/opencode-completion-gate/compare/v2.0.0...v2.0.1) (2026-11-18)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * keep polling PR policies while CI is still running ([#14](https://github.com/PauloDevelo/opencode-completion-gate/issues/14)) ([40713c4](https://github.com/PauloDevelo/opencode-completion-gate/commit/40713c4be72744ce71df1b3094f68bbb532c4fbe))
16
+
3
17
  ## [2.0.0](https://github.com/PauloDevelo/opencode-completion-gate/compare/v1.3.1...v2.0.0) (2026-10-15)
4
18
 
5
19
 
package/README.md CHANGED
@@ -24,6 +24,8 @@ Add the plugin to your OpenCode configuration (V2):
24
24
  ```
25
25
 
26
26
  > Requires OpenCode V2 (`@opencode/plugin` ≥ 2.0). For OpenCode V1, use `opencode-completion-gate@1.x` and the `plugin` field.
27
+ >
28
+ > Restart OpenCode after changing the `plugins` array: plugins are loaded at startup, so a running session keeps the previous plugin set. The addition only takes effect after the restart.
27
29
 
28
30
  ## Quick start
29
31
 
package/dist/index.js CHANGED
@@ -123,6 +123,29 @@ function fail(name, evidence) {
123
123
  function positiveInt(v, fallback) {
124
124
  return typeof v === "number" && Number.isFinite(v) && v > 0 ? Math.floor(v) : fallback;
125
125
  }
126
+ function resolvePlatformCommand(run, nameOf) {
127
+ if (typeof run === "string") {
128
+ const command2 = run.trim();
129
+ if (!command2) return null;
130
+ return { run, name: nameOf(command2.split(/\s+/)[0]) };
131
+ }
132
+ if (!run || typeof run !== "object" || Array.isArray(run)) return null;
133
+ const pair = run;
134
+ const unknownKeys = Object.keys(pair).filter((key) => key !== "windows" && key !== "linux");
135
+ if (unknownKeys.length > 0) {
136
+ logDiag(`gate config: run carries unknown platform key(s): ${unknownKeys.join(", ")}`);
137
+ return null;
138
+ }
139
+ const platform = process.platform === "win32" ? "windows" : "linux";
140
+ const command = pair[platform];
141
+ if (typeof command !== "string" || !command.trim()) {
142
+ logDiag(
143
+ `gate config: run has no "${platform}" command for this host (${process.platform}); the whole config is skipped`
144
+ );
145
+ return null;
146
+ }
147
+ return { run: command, name: nameOf(command.trim().split(/\s+/)[0]) };
148
+ }
126
149
  function validateGateConfig(raw) {
127
150
  if (!raw || typeof raw !== "object") return null;
128
151
  const obj = raw;
@@ -133,15 +156,17 @@ function validateGateConfig(raw) {
133
156
  if (!a || typeof a !== "object") return null;
134
157
  const nameOf = (fb) => typeof a.name === "string" && a.name.trim() ? a.name : fb;
135
158
  switch (a.type) {
136
- case "command":
137
- if (typeof a.run !== "string" || !a.run.trim()) return null;
159
+ case "command": {
160
+ const resolved = resolvePlatformCommand(a.run, nameOf);
161
+ if (!resolved) return null;
138
162
  assertions.push({
139
163
  type: "command",
140
- name: nameOf(a.run.split(/\s+/)[0]),
141
- run: a.run,
164
+ name: resolved.name,
165
+ run: resolved.run,
142
166
  timeoutSeconds: positiveInt(a.timeoutSeconds, 300)
143
167
  });
144
168
  break;
169
+ }
145
170
  case "ado-pr":
146
171
  assertions.push({
147
172
  type: "ado-pr",
@@ -399,12 +424,13 @@ function requiredPoliciesGreen(policyListJson, opts = {}) {
399
424
  if (bad.length > 0) {
400
425
  const names = bad.map((e) => `${e.configuration?.type?.displayName ?? "policy"}: ${String(e.status ?? "?")}`).join("; ");
401
426
  const skipped = ignored.length > 0 ? ` (${ignored.length} human policy(ies) ignored)` : "";
402
- const hasTerminalAutomatedFailure = bad.some(
403
- (e) => !isHumanReviewPolicy(e) && !IN_PROGRESS_POLICY_STATUSES.has(String(e.status ?? "").toLowerCase())
427
+ const stillSettling = bad.some(
428
+ (e) => IN_PROGRESS_POLICY_STATUSES.has(String(e.status ?? "").toLowerCase())
404
429
  );
430
+ const onlyHumanRemaining = bad.every(isHumanReviewPolicy);
405
431
  return {
406
432
  green: false,
407
- retryable: !hasTerminalAutomatedFailure,
433
+ retryable: stillSettling || onlyHumanRemaining,
408
434
  detail: `PR policies not green \u2014 ${names}${skipped}`
409
435
  };
410
436
  }
package/dist/plugin.js CHANGED
@@ -123,6 +123,29 @@ function fail(name, evidence) {
123
123
  function positiveInt(v, fallback) {
124
124
  return typeof v === "number" && Number.isFinite(v) && v > 0 ? Math.floor(v) : fallback;
125
125
  }
126
+ function resolvePlatformCommand(run, nameOf) {
127
+ if (typeof run === "string") {
128
+ const command2 = run.trim();
129
+ if (!command2) return null;
130
+ return { run, name: nameOf(command2.split(/\s+/)[0]) };
131
+ }
132
+ if (!run || typeof run !== "object" || Array.isArray(run)) return null;
133
+ const pair = run;
134
+ const unknownKeys = Object.keys(pair).filter((key) => key !== "windows" && key !== "linux");
135
+ if (unknownKeys.length > 0) {
136
+ logDiag(`gate config: run carries unknown platform key(s): ${unknownKeys.join(", ")}`);
137
+ return null;
138
+ }
139
+ const platform = process.platform === "win32" ? "windows" : "linux";
140
+ const command = pair[platform];
141
+ if (typeof command !== "string" || !command.trim()) {
142
+ logDiag(
143
+ `gate config: run has no "${platform}" command for this host (${process.platform}); the whole config is skipped`
144
+ );
145
+ return null;
146
+ }
147
+ return { run: command, name: nameOf(command.trim().split(/\s+/)[0]) };
148
+ }
126
149
  function validateGateConfig(raw) {
127
150
  if (!raw || typeof raw !== "object") return null;
128
151
  const obj = raw;
@@ -133,15 +156,17 @@ function validateGateConfig(raw) {
133
156
  if (!a || typeof a !== "object") return null;
134
157
  const nameOf = (fb) => typeof a.name === "string" && a.name.trim() ? a.name : fb;
135
158
  switch (a.type) {
136
- case "command":
137
- if (typeof a.run !== "string" || !a.run.trim()) return null;
159
+ case "command": {
160
+ const resolved = resolvePlatformCommand(a.run, nameOf);
161
+ if (!resolved) return null;
138
162
  assertions.push({
139
163
  type: "command",
140
- name: nameOf(a.run.split(/\s+/)[0]),
141
- run: a.run,
164
+ name: resolved.name,
165
+ run: resolved.run,
142
166
  timeoutSeconds: positiveInt(a.timeoutSeconds, 300)
143
167
  });
144
168
  break;
169
+ }
145
170
  case "ado-pr":
146
171
  assertions.push({
147
172
  type: "ado-pr",
@@ -395,12 +420,13 @@ function requiredPoliciesGreen(policyListJson, opts = {}) {
395
420
  if (bad.length > 0) {
396
421
  const names = bad.map((e) => `${e.configuration?.type?.displayName ?? "policy"}: ${String(e.status ?? "?")}`).join("; ");
397
422
  const skipped = ignored.length > 0 ? ` (${ignored.length} human policy(ies) ignored)` : "";
398
- const hasTerminalAutomatedFailure = bad.some(
399
- (e) => !isHumanReviewPolicy(e) && !IN_PROGRESS_POLICY_STATUSES.has(String(e.status ?? "").toLowerCase())
423
+ const stillSettling = bad.some(
424
+ (e) => IN_PROGRESS_POLICY_STATUSES.has(String(e.status ?? "").toLowerCase())
400
425
  );
426
+ const onlyHumanRemaining = bad.every(isHumanReviewPolicy);
401
427
  return {
402
428
  green: false,
403
- retryable: !hasTerminalAutomatedFailure,
429
+ retryable: stillSettling || onlyHumanRemaining,
404
430
  detail: `PR policies not green \u2014 ${names}${skipped}`
405
431
  };
406
432
  }
package/dist/types.d.ts CHANGED
@@ -4,6 +4,20 @@ export interface CommandAssertion {
4
4
  run: string;
5
5
  timeoutSeconds: number;
6
6
  }
7
+ /**
8
+ * The `run` field of a command assertion may be a single string (the original
9
+ * shape, still valid) or one command per platform. The config layer resolves it
10
+ * to a single string before anything reaches the runner, so `CommandAssertion.run`
11
+ * stays a string at runtime.
12
+ *
13
+ * Both keys are optional so the JSON can be authored incrementally, but a config
14
+ * that does not carry a command for the platform it is being read on is
15
+ * rejected rather than run against the other platform's shell.
16
+ */
17
+ export interface PlatformCommand {
18
+ windows?: string;
19
+ linux?: string;
20
+ }
7
21
  export interface AdoPrAssertion {
8
22
  type: 'ado-pr';
9
23
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-completion-gate",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "OpenCode plugin: per-session quality gate that blocks declaring done until configured assertions pass",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.js",