@bytesbrains/pi-review-gate 1.1.2 → 1.1.3

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Review Gate for Pi
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/pi-review-gate)](https://www.npmjs.com/package/pi-review-gate)
4
- [![license](https://img.shields.io/npm/l/pi-review-gate)](./LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/@bytesbrains/pi-review-gate)](https://www.npmjs.com/package/@bytesbrains/pi-review-gate)
4
+ [![license](https://img.shields.io/npm/l/@bytesbrains/pi-review-gate)](./LICENSE)
5
5
 
6
6
  > CI-level merge guardian for AI agents — required reviewers, breaking change detection, stale PR cleanup, and review automation. **Agents don't `git merge` — CI merges only after all gates pass.**
7
7
 
@@ -15,7 +15,7 @@ Core enforcement runs in Gitea Actions — agents **cannot bypass** these gates.
15
15
  ## Install
16
16
 
17
17
  ```bash
18
- pi install npm:pi-review-gate
18
+ pi install npm:@bytesbrains/pi-review-gate
19
19
  ```
20
20
 
21
21
  ## Tools
@@ -76,7 +76,7 @@ breakingChangePatterns: export interface,export type,export function,export clas
76
76
  ## Workflow
77
77
 
78
78
  ```
79
- contrib_submit() from pi-contrib-gate
79
+ contrib_submit() from @bytesbrains/pi-contrib-gate
80
80
 
81
81
 
82
82
  PR opened on Gitea
@@ -120,12 +120,12 @@ Every CI run diffs against the base branch and scans for:
120
120
 
121
121
  If detected, CI adds a `⚠️ breaking-change` label and requires human review.
122
122
 
123
- ## Integration with pi-contrib-gate
123
+ ## Integration with @bytesbrains/pi-contrib-gate
124
124
 
125
125
  The two gates work together:
126
126
 
127
127
  ```
128
- pi-contrib-gate pi-review-gate
128
+ pi-contrib-gate @bytesbrains/pi-review-gate
129
129
  │ │
130
130
  │ contrib_start_work │
131
131
  │ contrib_propose │
@@ -141,8 +141,8 @@ pi-contrib-gate pi-review-gate
141
141
  Install both for full agent governance:
142
142
 
143
143
  ```bash
144
- pi install npm:pi-contrib-gate
145
- pi install npm:pi-review-gate
144
+ pi install npm:@bytesbrains/pi-contrib-gate
145
+ pi install npm:@bytesbrains/pi-review-gate
146
146
  ```
147
147
 
148
148
  ## License
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytesbrains/pi-review-gate",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "CI-level merge guardian for AI agents \u2014 required reviewers, breaking change detection, stale PR cleanup, and review automation.",
5
5
  "keywords": [
6
6
  "pi-package",
package/src/config.ts CHANGED
@@ -37,10 +37,12 @@ export function loadConfig(cwd: string): ReviewConfig {
37
37
  reviewers[key.replace("requiredReviewers.", "")] = (val as string).split(",").map(s => s.trim()).filter(Boolean);
38
38
  }
39
39
  }
40
+ const minDiverseReviews = parseInt(result["minDiverseReviews"] as string);
41
+ const staleDays = parseInt(result["staleDays"] as string);
40
42
  return {
41
- minDiverseReviews: parseInt(result["minDiverseReviews"] as string) || DEFAULT_CONFIG.minDiverseReviews,
43
+ minDiverseReviews: isNaN(minDiverseReviews) ? DEFAULT_CONFIG.minDiverseReviews : minDiverseReviews,
42
44
  requiredReviewers: reviewers,
43
- staleDays: parseInt(result["staleDays"] as string) || DEFAULT_CONFIG.staleDays,
45
+ staleDays: isNaN(staleDays) ? DEFAULT_CONFIG.staleDays : staleDays,
44
46
  protectedPaths: (result["protectedPaths"] as string)?.split(",").map(s => s.trim()).filter(Boolean) || DEFAULT_CONFIG.protectedPaths,
45
47
  breakingChangePatterns: (result["breakingChangePatterns"] as string)?.split(",").map(s => s.trim()).filter(Boolean) || DEFAULT_CONFIG.breakingChangePatterns,
46
48
  };
package/src/helpers.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import * as cp from "node:child_process";
2
2
 
3
+ // ⚠️ SYNC-MARKER: exec(), resolveGitea(), giteaApi() are duplicated across packages.
4
+ // If changing behavior here, update all copies in: ci-gate, contrib-gate, review-gate, project-gate
3
5
  export function exec(cmd: string, cwd?: string): { ok: boolean; stdout: string; stderr: string } {
4
6
  try {
5
7
  const r = cp.execSync(cmd, { cwd, encoding: "utf-8", timeout: 30000 });
@@ -23,7 +25,7 @@ export function resolveGitea(cwd: string): { repo: string; token: string } {
23
25
  return { repo, token };
24
26
  }
25
27
 
26
- export async function giteaApi(path: string, method: string, body: Record<string, unknown> | null, opts: { repo: string; token?: string }, _cwd: string): Promise<{ ok: boolean; data: unknown; error?: string }> {
28
+ export async function giteaApi(path: string, method: string, body: Record<string, unknown> | null, opts: { repo: string; token?: string }, _cwd: string): Promise<{ ok: boolean; data: unknown; error?: string; statusCode?: number }> {
27
29
  const base = `http://127.0.0.1:3001/api/v1/repos/${opts.repo}`;
28
30
  const url = `${base}${path}`;
29
31
  const headers: Record<string, string> = { "Content-Type": "application/json", "Accept": "application/json" };
@@ -36,8 +38,9 @@ export async function giteaApi(path: string, method: string, body: Record<string
36
38
  body: body ? JSON.stringify(body) : undefined,
37
39
  });
38
40
  const text = await res.text();
39
- if (!res.ok) return { ok: false, data: null, error: text || `HTTP ${res.status}` };
40
- try { return { ok: true, data: JSON.parse(text) }; } catch { return { ok: true, data: text }; }
41
+ const statusCode = res.status;
42
+ if (!res.ok) return { ok: false, data: null, statusCode, error: `Gitea API error: HTTP ${statusCode} ${method} ${path}` };
43
+ try { return { ok: true, data: JSON.parse(text), statusCode }; } catch { return { ok: true, data: text, statusCode }; }
41
44
  } catch (e: any) {
42
45
  return { ok: false, data: null, error: e.message || "Network error" };
43
46
  }