@growthagent/ci 0.8.0 → 0.9.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.
Files changed (2) hide show
  1. package/dist/cli.js +15 -35
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  // src/cli.ts
4
4
  import { execFileSync, spawnSync as spawnSync2 } from "node:child_process";
5
- import { cpSync, existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
6
- import path7 from "node:path";
7
- import { fileURLToPath as fileURLToPath2 } from "node:url";
5
+ import { cpSync, existsSync as existsSync3, mkdirSync, readFileSync, writeFileSync as writeFileSync2 } from "node:fs";
6
+ import path6 from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
8
 
9
9
  // ../github/src/app.ts
10
10
  import { createSign } from "node:crypto";
@@ -53,30 +53,10 @@ import path3 from "node:path";
53
53
  import { promisify } from "node:util";
54
54
  var run = promisify(execFile);
55
55
 
56
- // ../github/src/actions.ts
57
- import { readFileSync } from "node:fs";
58
- import path4 from "node:path";
59
- import { fileURLToPath } from "node:url";
60
- var HERE = path4.dirname(fileURLToPath(import.meta.url));
61
- function read(name) {
62
- for (const candidate of [
63
- path4.join(HERE, "..", "..", "..", "action", name, "action.yml"),
64
- path4.join(HERE, "..", "action", name, "action.yml")
65
- ]) {
66
- try {
67
- return readFileSync(candidate, "utf8");
68
- } catch {
69
- }
70
- }
71
- throw new Error(`could not find the ${name} action definition`);
72
- }
73
- var IMPLEMENT_ACTION = read("implement");
74
- var APPLY_ACTION = read("apply");
75
-
76
56
  // src/lockfiles.ts
77
57
  import { spawnSync } from "node:child_process";
78
58
  import { existsSync as existsSync2, rmSync as rmSync2 } from "node:fs";
79
- import path5 from "node:path";
59
+ import path4 from "node:path";
80
60
  var LOCKFILES = [
81
61
  "pnpm-lock.yaml",
82
62
  "package-lock.json",
@@ -89,12 +69,12 @@ function discardLockfileChanges(cwd = process.cwd()) {
89
69
  const git = (args) => spawnSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
90
70
  const touched = [];
91
71
  for (const lockfile of LOCKFILES) {
92
- if (!existsSync2(path5.join(cwd, lockfile))) continue;
72
+ if (!existsSync2(path4.join(cwd, lockfile))) continue;
93
73
  const tracked = git(["ls-files", "--error-unmatch", "--", lockfile]).status === 0;
94
74
  if (tracked) {
95
75
  git(["restore", "--staged", "--worktree", "--", lockfile]);
96
76
  } else {
97
- rmSync2(path5.join(cwd, lockfile), { force: true });
77
+ rmSync2(path4.join(cwd, lockfile), { force: true });
98
78
  }
99
79
  touched.push(lockfile);
100
80
  }
@@ -340,11 +320,11 @@ function validatePatch(patch, limits = DEFAULT_PATCH_LIMITS) {
340
320
  // src/provider-config.ts
341
321
  import { mkdtempSync as mkdtempSync2, writeFileSync } from "node:fs";
342
322
  import { tmpdir as tmpdir3 } from "node:os";
343
- import path6 from "node:path";
323
+ import path5 from "node:path";
344
324
  var RUN_TOKEN_ENV = "GX_RUN_TOKEN";
345
325
  function writeGoogleProviderConfig(model) {
346
326
  const gateway = (process.env.GX_GATEWAY_URL ?? "").replace(/\/$/, "");
347
- const dir = mkdtempSync2(path6.join(tmpdir3(), "growth-agent-pi-"));
327
+ const dir = mkdtempSync2(path5.join(tmpdir3(), "growth-agent-pi-"));
348
328
  const config = {
349
329
  providers: {
350
330
  "growthagent-google": {
@@ -355,7 +335,7 @@ function writeGoogleProviderConfig(model) {
355
335
  }
356
336
  }
357
337
  };
358
- writeFileSync(path6.join(dir, "models.json"), JSON.stringify(config, null, 2));
338
+ writeFileSync(path5.join(dir, "models.json"), JSON.stringify(config, null, 2));
359
339
  return dir;
360
340
  }
361
341
 
@@ -464,11 +444,11 @@ function buildPrompt(fields, briefing) {
464
444
  }
465
445
 
466
446
  // src/cli.ts
467
- var HERE2 = path7.dirname(fileURLToPath2(import.meta.url));
447
+ var HERE = path6.dirname(fileURLToPath(import.meta.url));
468
448
  var PATCH_FILE = "growth-agent.patch";
469
449
  function assetsDir() {
470
- const packaged = path7.join(HERE2, "assets", "skills");
471
- return existsSync3(packaged) ? packaged : path7.join(HERE2, "..", "assets", "skills");
450
+ const packaged = path6.join(HERE, "assets", "skills");
451
+ return existsSync3(packaged) ? packaged : path6.join(HERE, "..", "assets", "skills");
472
452
  }
473
453
  function sh(cmd, args, opts = {}) {
474
454
  const r = spawnSync2(cmd, args, { encoding: "utf8", stdio: ["inherit", "pipe", "inherit"] });
@@ -485,7 +465,7 @@ function required(name) {
485
465
  function readIssue() {
486
466
  const eventPath = process.env.GITHUB_EVENT_PATH;
487
467
  if (eventPath) {
488
- const event = JSON.parse(readFileSync2(eventPath, "utf8"));
468
+ const event = JSON.parse(readFileSync(eventPath, "utf8"));
489
469
  if (event.issue) {
490
470
  return {
491
471
  number: event.issue.number,
@@ -595,7 +575,7 @@ async function implement() {
595
575
  console.log(
596
576
  meta.kind === "instrumentation" ? `\u25B8 instrumentation request #${issue.number}` : `\u25B8 change request #${issue.number} \u2014 flag ${meta.flagKey} on ${meta.surface}`
597
577
  );
598
- const skillsDir = path7.resolve(process.cwd(), ".pi", "skills");
578
+ const skillsDir = path6.resolve(process.cwd(), ".pi", "skills");
599
579
  mkdirSync(skillsDir, { recursive: true });
600
580
  cpSync(assetsDir(), skillsDir, { recursive: true });
601
581
  const prompt = buildPrompt(meta, extractBriefing(issue.body));
@@ -697,7 +677,7 @@ function apply() {
697
677
  console.error(`No ${PATCH_FILE} was produced by the implementer job.`);
698
678
  return 1;
699
679
  }
700
- const patch = readFileSync2(PATCH_FILE, "utf8");
680
+ const patch = readFileSync(PATCH_FILE, "utf8");
701
681
  const verdict = validatePatch(patch);
702
682
  if (!verdict.ok) {
703
683
  console.error(`Refusing to apply the patch: ${verdict.reason}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growthagent/ci",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {