@plainconceptsplatform/workflows 0.4.5 → 0.4.7

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.
@@ -77,9 +77,12 @@ async function preserveConsumerWorkerEnv(repositoryPath, files) {
77
77
  }
78
78
  function mergeWorkerEnv(packageContent, consumerContent) {
79
79
  const consumerEnv = workerEnvValues(consumerContent);
80
- if (consumerEnv.size === 0)
81
- return packageContent;
82
- return packageContent.replace(/^ ([A-Z][A-Z0-9_]*): .+$/gm, (line, key) => consumerEnv.has(key) ? ` ${key}: ${consumerEnv.get(key)}` : line);
80
+ let result = packageContent.replace(/^ ([A-Z][A-Z0-9_]*): .+$/gm, (line, key) => consumerEnv.has(key) ? ` ${key}: ${consumerEnv.get(key)}` : line);
81
+ const endpoint = engineEndpoint(consumerContent);
82
+ if (endpoint !== undefined) {
83
+ result = result.replace(/^ OPENAI_BASE_URL: .+$/m, ` OPENAI_BASE_URL: ${endpoint}`);
84
+ }
85
+ return result;
83
86
  }
84
87
  function workerEnvValues(content) {
85
88
  const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---/m.exec(content)?.[1];
@@ -94,6 +97,9 @@ function workerEnvValues(content) {
94
97
  }
95
98
  return values;
96
99
  }
100
+ function engineEndpoint(content) {
101
+ return /^ OPENAI_BASE_URL: (.+)$/m.exec(content)?.[1];
102
+ }
97
103
  function transformOpencodeFiles(files, inspection) {
98
104
  const result = new Map(files);
99
105
  for (const [key, content] of result) {
@@ -154,15 +160,22 @@ async function preCommitHookUpdate(repositoryPath) {
154
160
  const target = ".husky/pre-commit";
155
161
  const hookPath = join(repositoryPath, target);
156
162
  const compileLine = "node scripts/compile-agent-workflows.mjs";
163
+ const stageLine = "git add -- .github/workflows/*.lock.yml";
164
+ const actionLockLine = "[ ! -f .github/actions/actions-lock.json ] || git add -- .github/actions/actions-lock.json";
165
+ const managedLines = `${compileLine}\n${stageLine}\n${actionLockLine}\n`;
157
166
  if (!await exists(hookPath)) {
158
- return { target, content: `${compileLine}\n` };
167
+ return { target, content: managedLines };
159
168
  }
160
169
  const content = await readFile(hookPath, "utf8");
161
- if (content.includes("compile-agent-workflows"))
162
- return { target, content };
170
+ if (content.includes("compile-agent-workflows")) {
171
+ if (content.includes(stageLine))
172
+ return { target, content };
173
+ const suffix = content.endsWith("\n") || content === "" ? "" : "\n";
174
+ return { target, content: `${content}${suffix}${stageLine}\n${actionLockLine}\n` };
175
+ }
163
176
  return { target, content: content.endsWith("\n") || content === ""
164
- ? `${content}${compileLine}\n`
165
- : `${content}\n${compileLine}\n` };
177
+ ? `${content}${managedLines}`
178
+ : `${content}\n${managedLines}` };
166
179
  }
167
180
  export async function runCompileIfAvailable(repositoryPath) {
168
181
  const script = join(repositoryPath, "scripts", "compile-agent-workflows.mjs");
@@ -253,14 +253,20 @@ describe("catalog installation", () => {
253
253
  const repositoryPath = await createDirectory({});
254
254
  await ensurePreCommitHook(repositoryPath);
255
255
  await expect(readFile(join(repositoryPath, ".husky", "pre-commit"), "utf8"))
256
- .resolves.toBe("node scripts/compile-agent-workflows.mjs\n");
256
+ .resolves.toBe("node scripts/compile-agent-workflows.mjs\ngit add -- .github/workflows/*.lock.yml\n[ ! -f .github/actions/actions-lock.json ] || git add -- .github/actions/actions-lock.json\n");
257
257
  });
258
258
  it("keeps existing pre-commit commands and appends the compiler once", async () => {
259
259
  const repositoryPath = await createDirectory({ ".husky/pre-commit": "pnpm lint\n" });
260
260
  await ensurePreCommitHook(repositoryPath);
261
261
  await ensurePreCommitHook(repositoryPath);
262
262
  await expect(readFile(join(repositoryPath, ".husky", "pre-commit"), "utf8"))
263
- .resolves.toBe("pnpm lint\nnode scripts/compile-agent-workflows.mjs\n");
263
+ .resolves.toBe("pnpm lint\nnode scripts/compile-agent-workflows.mjs\ngit add -- .github/workflows/*.lock.yml\n[ ! -f .github/actions/actions-lock.json ] || git add -- .github/actions/actions-lock.json\n");
264
+ });
265
+ it("upgrades an existing compiler hook to stage generated locks", async () => {
266
+ const repositoryPath = await createDirectory({ ".husky/pre-commit": "node scripts/compile-agent-workflows.mjs\n" });
267
+ await ensurePreCommitHook(repositoryPath);
268
+ await expect(readFile(join(repositoryPath, ".husky", "pre-commit"), "utf8"))
269
+ .resolves.toContain("git add -- .github/workflows/*.lock.yml");
264
270
  });
265
271
  it("leaves consumer files untouched when staged workflow compilation fails", async () => {
266
272
  const sourcePath = await createDirectory({
@@ -289,15 +295,15 @@ describe("catalog installation", () => {
289
295
  it("preserves consumer-specific worker environment values during a forced update", async () => {
290
296
  const sourcePath = await createDirectory({
291
297
  "actions/check/action.yml": "name: Check\n",
292
- "workflows/agent-check.md": "---\nenv:\n VERIFY_COMMANDS: \"package verify\"\n REPO_RULES: \"package rules\"\n OPENAI_BASE_URL: https://forge.plainconcepts.com/v1\n---\n",
298
+ "workflows/agent-check.md": "---\nenv:\n VERIFY_COMMANDS: \"package verify\"\n REPO_RULES: \"package rules\"\n---\nengine:\n env:\n OPENAI_BASE_URL: https://forge.plainconcepts.com/v1\n",
293
299
  "scripts/compile-agent-workflows.mjs": "compile\n",
294
300
  "templates/opencode/opencode.ci.json": "{}\n",
295
301
  });
296
302
  const repositoryPath = await createDirectory({
297
- ".github/workflows/agent-check.md": "---\nenv:\n VERIFY_COMMANDS: \"consumer verify\"\n REPO_RULES: \"consumer rules\"\n OPENAI_BASE_URL: https://consumer.example/v1\n---\n",
303
+ ".github/workflows/agent-check.md": "---\nenv:\n VERIFY_COMMANDS: \"consumer verify\"\n REPO_RULES: \"consumer rules\"\n---\nengine:\n env:\n OPENAI_BASE_URL: https://consumer.example/v1\n",
298
304
  });
299
305
  await installCatalog(repositoryPath, { force: true, sourcePath });
300
- await expect(readFile(join(repositoryPath, ".github/workflows/agent-check.md"), "utf8")).resolves.toContain(" REPO_RULES: \"consumer rules\"\n OPENAI_BASE_URL: https://consumer.example/v1\n");
306
+ await expect(readFile(join(repositoryPath, ".github/workflows/agent-check.md"), "utf8")).resolves.toContain(" REPO_RULES: \"consumer rules\"\n---\nengine:\n env:\n OPENAI_BASE_URL: https://consumer.example/v1\n");
301
307
  });
302
308
  it("applies staged generated locks with managed sources", async () => {
303
309
  const sourcePath = await createDirectory({
@@ -37,7 +37,8 @@ for (const file of readdirSync(workflowDirectory)) {
37
37
  const patched = content
38
38
  .replaceAll("opencode run --print-logs --log-level DEBUG", "opencode run --log-level ERROR")
39
39
  .replaceAll("opencode run --print-logs --log-level ERROR", "opencode run --log-level ERROR")
40
- .replaceAll("--log-level DEBUG", "--log-level ERROR");
40
+ .replaceAll("--log-level DEBUG", "--log-level ERROR")
41
+ .replace(/GH_AW_INFO_MODEL_COSTS: '[^']*'/g, "GH_AW_INFO_MODEL_COSTS: '{\"providers\":{}}'");
41
42
 
42
43
  if (patched !== content) writeFileSync(path, patched);
43
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plainconceptsplatform/workflows",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
4
4
  "description": "Install and update Platform GitHub agentic workflows.",
5
5
  "keywords": [
6
6
  "github-actions",