poe-code 3.0.339 → 3.0.341

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 (27) hide show
  1. package/dist/index.js +153 -27
  2. package/dist/index.js.map +3 -3
  3. package/dist/metafile.json +1 -1
  4. package/dist/workflow-templates/fix-vulnerabilities.ejected.yml +4 -3
  5. package/dist/workflow-templates/github-issue-comment-created.ejected.yml +8 -6
  6. package/dist/workflow-templates/github-issue-opened.ejected.yml +8 -6
  7. package/dist/workflow-templates/github-pull-request-comment-created.ejected.yml +8 -6
  8. package/dist/workflow-templates/github-pull-request-opened.ejected.yml +8 -6
  9. package/dist/workflow-templates/github-pull-request-synchronized.ejected.yml +8 -6
  10. package/dist/workflow-templates/update-dependencies.ejected.yml +4 -3
  11. package/dist/workflow-templates/update-documentation.ejected.yml +4 -3
  12. package/package.json +1 -1
  13. package/packages/github-workflows/dist/commands.js +4 -2
  14. package/packages/github-workflows/dist/discover.d.ts +1 -0
  15. package/packages/github-workflows/dist/discover.js +33 -4
  16. package/packages/github-workflows/dist/exec/trufflehog-pr-scan.js +26 -6
  17. package/packages/github-workflows/dist/preflight.js +1 -1
  18. package/packages/github-workflows/dist/workflow-templates/fix-vulnerabilities.ejected.yml +4 -3
  19. package/packages/github-workflows/dist/workflow-templates/github-issue-comment-created.ejected.yml +8 -6
  20. package/packages/github-workflows/dist/workflow-templates/github-issue-opened.ejected.yml +8 -6
  21. package/packages/github-workflows/dist/workflow-templates/github-pull-request-comment-created.ejected.yml +8 -6
  22. package/packages/github-workflows/dist/workflow-templates/github-pull-request-opened.ejected.yml +8 -6
  23. package/packages/github-workflows/dist/workflow-templates/github-pull-request-synchronized.ejected.yml +8 -6
  24. package/packages/github-workflows/dist/workflow-templates/update-dependencies.ejected.yml +4 -3
  25. package/packages/github-workflows/dist/workflow-templates/update-documentation.ejected.yml +4 -3
  26. package/packages/plan-browser/dist/actions.js +54 -8
  27. package/packages/plan-browser/dist/discovery.js +31 -5
package/dist/index.js CHANGED
@@ -71012,8 +71012,13 @@ function resolveAbsoluteDirectory4(dir, cwd, homeDir) {
71012
71012
  }
71013
71013
  return path89.isAbsolute(dir) ? dir : path89.resolve(cwd, dir);
71014
71014
  }
71015
- function isMarkdownFile2(name) {
71016
- return name.toLowerCase().endsWith(".md");
71015
+ function isSupportedPlanFile(name) {
71016
+ const lowerName = name.toLowerCase();
71017
+ return lowerName.endsWith(".md") || lowerName.endsWith(".yaml") || lowerName.endsWith(".yml");
71018
+ }
71019
+ function isYamlPlanFile(name) {
71020
+ const lowerName = name.toLowerCase();
71021
+ return lowerName.endsWith(".yaml") || lowerName.endsWith(".yml");
71017
71022
  }
71018
71023
  function getPlanTypeLabel(kind) {
71019
71024
  switch (kind) {
@@ -71061,6 +71066,10 @@ function toPlanKind(value, filePath) {
71061
71066
  throw new Error(`${filePath}: unsupported frontmatter kind ${JSON.stringify(value)}`);
71062
71067
  }
71063
71068
  function classifyPlanKind(content, filePath) {
71069
+ if (isYamlPlanFile(filePath)) {
71070
+ parsePlan(content);
71071
+ return "pipeline";
71072
+ }
71064
71073
  const { data } = splitFrontmatter2(content, filePath);
71065
71074
  if (data === void 0) {
71066
71075
  return "plan";
@@ -71096,15 +71105,31 @@ async function discoverSharedPlans(options) {
71096
71105
  }
71097
71106
  const plans = [];
71098
71107
  for (const name of entries) {
71099
- if (!isMarkdownFile2(name)) {
71108
+ if (!isSupportedPlanFile(name)) {
71100
71109
  continue;
71101
71110
  }
71102
71111
  const absolutePath = path89.join(absoluteDir, name);
71103
- const canonicalPath = await options.fs.realpath(absolutePath);
71112
+ const canonicalPath = await options.fs.realpath(absolutePath).catch((error3) => {
71113
+ if (isNotFound3(error3)) {
71114
+ return void 0;
71115
+ }
71116
+ throw error3;
71117
+ });
71118
+ if (canonicalPath === void 0) {
71119
+ continue;
71120
+ }
71104
71121
  if (canonicalPath !== path89.resolve(absolutePath)) {
71105
71122
  throw new Error(`Plan file must not be a symbolic link: ${path89.join(displayDir, name)}`);
71106
71123
  }
71107
- const stat33 = await options.fs.stat(absolutePath);
71124
+ const stat33 = await options.fs.stat(absolutePath).catch((error3) => {
71125
+ if (isNotFound3(error3)) {
71126
+ return void 0;
71127
+ }
71128
+ throw error3;
71129
+ });
71130
+ if (stat33 === void 0) {
71131
+ continue;
71132
+ }
71108
71133
  if (!stat33.isFile()) {
71109
71134
  continue;
71110
71135
  }
@@ -71148,6 +71173,7 @@ async function discoverAllPlans(options) {
71148
71173
  var init_discovery4 = __esm({
71149
71174
  "packages/plan-browser/src/discovery.ts"() {
71150
71175
  "use strict";
71176
+ init_src31();
71151
71177
  init_src9();
71152
71178
  init_error_codes15();
71153
71179
  init_format();
@@ -71158,7 +71184,7 @@ var init_discovery4 = __esm({
71158
71184
  import path90 from "node:path";
71159
71185
  import { spawnSync as nodeSpawnSync2 } from "node:child_process";
71160
71186
  function resolveEditor2(env = process.env) {
71161
- const editor = getOwnEnvValue2(env, "EDITOR")?.trim() || getOwnEnvValue2(env, "VISUAL")?.trim() || "vi";
71187
+ const editor = getOwnEnvValue2(env, "VISUAL")?.trim() || getOwnEnvValue2(env, "EDITOR")?.trim() || "vi";
71162
71188
  return editor.length > 0 ? editor : "vi";
71163
71189
  }
71164
71190
  function editFile(absolutePath, options = {}) {
@@ -71217,12 +71243,59 @@ function getOwnEnvValue2(env, key2) {
71217
71243
  function hasErrorCode3(error3, code) {
71218
71244
  return hasOwnErrorCode19(error3, code);
71219
71245
  }
71246
+ function isCommandWhitespace(character) {
71247
+ return character === " " || character === " " || character === "\n" || character === "\r";
71248
+ }
71220
71249
  function parseEditorCommand(command) {
71221
- const parts = command.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) ?? [];
71222
- return parts.map((part) => {
71223
- const quote = part[0];
71224
- return (quote === '"' || quote === "'") && part.at(-1) === quote ? part.slice(1, -1) : part;
71225
- });
71250
+ const parts = [];
71251
+ let current = "";
71252
+ let quote;
71253
+ let escaping = false;
71254
+ let hasToken = false;
71255
+ for (const character of command) {
71256
+ if (escaping) {
71257
+ current += character;
71258
+ escaping = false;
71259
+ hasToken = true;
71260
+ continue;
71261
+ }
71262
+ if (character === "\\") {
71263
+ escaping = true;
71264
+ hasToken = true;
71265
+ continue;
71266
+ }
71267
+ if (quote !== void 0) {
71268
+ if (character === quote) {
71269
+ quote = void 0;
71270
+ } else {
71271
+ current += character;
71272
+ hasToken = true;
71273
+ }
71274
+ continue;
71275
+ }
71276
+ if (character === "'" || character === '"') {
71277
+ quote = character;
71278
+ hasToken = true;
71279
+ continue;
71280
+ }
71281
+ if (isCommandWhitespace(character)) {
71282
+ if (hasToken) {
71283
+ parts.push(current);
71284
+ current = "";
71285
+ hasToken = false;
71286
+ }
71287
+ continue;
71288
+ }
71289
+ current += character;
71290
+ hasToken = true;
71291
+ }
71292
+ if (escaping) {
71293
+ current += "\\";
71294
+ }
71295
+ if (hasToken) {
71296
+ parts.push(current);
71297
+ }
71298
+ return parts;
71226
71299
  }
71227
71300
  async function deletePlan(entry, fs29) {
71228
71301
  await fs29.unlink(entry.absolutePath);
@@ -79518,7 +79591,7 @@ async function readAutomation(dir, fileName, baseName, baseDirs) {
79518
79591
  path: baseDir
79519
79592
  })),
79520
79593
  {
79521
- source: "defaults",
79594
+ source: DEFAULTS_SOURCE,
79522
79595
  data: {
79523
79596
  agent: "codex"
79524
79597
  }
@@ -79529,11 +79602,23 @@ async function readAutomation(dir, fileName, baseName, baseDirs) {
79529
79602
  }
79530
79603
  );
79531
79604
  const name = stripPrefix(fileName.slice(0, -3));
79532
- return {
79605
+ const automation = {
79533
79606
  name,
79534
79607
  prompt: readPrompt(getOwnEntry32(resolved.data, "prompt"), fileName),
79535
79608
  ...readAutomationFields(resolved.data, fileName)
79536
79609
  };
79610
+ Object.defineProperty(automation, AGENT_SOURCE_PROPERTY, {
79611
+ configurable: true,
79612
+ enumerable: false,
79613
+ value: resolved.sources.agent
79614
+ });
79615
+ return automation;
79616
+ }
79617
+ function usesDefaultAgent(automation) {
79618
+ return getInternalAgentSource(automation) === DEFAULTS_SOURCE;
79619
+ }
79620
+ function getInternalAgentSource(automation) {
79621
+ return automation[AGENT_SOURCE_PROPERTY];
79537
79622
  }
79538
79623
  function readPrompt(value, fileName) {
79539
79624
  if (typeof value === "string") {
@@ -79546,8 +79631,8 @@ function readPrompt(value, fileName) {
79546
79631
  }
79547
79632
  function readAutomationFields(frontmatter, fileName) {
79548
79633
  const label = readOptionalString3(getOwnEntry32(frontmatter, "label"), "label", fileName);
79549
- const source = readOptionalString3(getOwnEntry32(frontmatter, "source"), "source", fileName);
79550
- const agent3 = readOptionalString3(getOwnEntry32(frontmatter, "agent"), "agent", fileName);
79634
+ const source = readOptionalNonBlankString(getOwnEntry32(frontmatter, "source"), "source", fileName);
79635
+ const agent3 = readOptionalNonBlankString(getOwnEntry32(frontmatter, "agent"), "agent", fileName);
79551
79636
  const mcp = readOptionalMcp(getOwnEntry32(frontmatter, "mcp"), fileName);
79552
79637
  const allow = readOptionalStringArray2(getOwnEntry32(frontmatter, "allow"), "allow", fileName);
79553
79638
  const prefix = readOptionalPrefix(getOwnEntry32(frontmatter, "prefix"), fileName);
@@ -79569,6 +79654,20 @@ function readOptionalString3(value, field, fileName) {
79569
79654
  }
79570
79655
  return value;
79571
79656
  }
79657
+ function readOptionalNonBlankString(value, field, fileName) {
79658
+ if (value === void 0) {
79659
+ return void 0;
79660
+ }
79661
+ if (typeof value !== "string") {
79662
+ throw new Error(`Automation "${fileName}" has invalid "${field}" frontmatter. Expected a string.`);
79663
+ }
79664
+ if (value.trim().length === 0) {
79665
+ throw new Error(
79666
+ `Automation "${fileName}" has invalid "${field}" frontmatter. Expected a non-empty string.`
79667
+ );
79668
+ }
79669
+ return value;
79670
+ }
79572
79671
  function readOptionalPrefix(value, fileName) {
79573
79672
  if (value === void 0) {
79574
79673
  return void 0;
@@ -79642,6 +79741,11 @@ function readOptionalMcp(value, fileName) {
79642
79741
  `Automation "${fileName}" has invalid "mcp.${serverName}.command" frontmatter. Expected a string.`
79643
79742
  );
79644
79743
  }
79744
+ if (command.trim().length === 0) {
79745
+ throw new Error(
79746
+ `Automation "${fileName}" has invalid "mcp.${serverName}.command" frontmatter. Expected a non-empty string.`
79747
+ );
79748
+ }
79645
79749
  const args = getOwnEntry32(serverValue, "args");
79646
79750
  if (args !== void 0 && (!Array.isArray(args) || args.some((item) => typeof item !== "string"))) {
79647
79751
  throw new Error(
@@ -79688,12 +79792,14 @@ function isStringRecord(value) {
79688
79792
  function stripPrefix(name) {
79689
79793
  return name.startsWith(POE_CODE_PREFIX) ? name.slice(POE_CODE_PREFIX.length) : name;
79690
79794
  }
79691
- var VALID_AUTHOR_ASSOCIATIONS, POE_CODE_PREFIX;
79795
+ var DEFAULTS_SOURCE, AGENT_SOURCE_PROPERTY, VALID_AUTHOR_ASSOCIATIONS, POE_CODE_PREFIX;
79692
79796
  var init_discover2 = __esm({
79693
79797
  "packages/github-workflows/src/discover.ts"() {
79694
79798
  "use strict";
79695
79799
  init_src5();
79696
79800
  init_errors6();
79801
+ DEFAULTS_SOURCE = "defaults";
79802
+ AGENT_SOURCE_PROPERTY = "__poeCodeAgentSource";
79697
79803
  VALID_AUTHOR_ASSOCIATIONS = /* @__PURE__ */ new Set([
79698
79804
  "COLLABORATOR",
79699
79805
  "CONTRIBUTOR",
@@ -79821,6 +79927,7 @@ function uniqueTruffleHogFindings(findings) {
79821
79927
  return [...unique4.values()];
79822
79928
  }
79823
79929
  function renderTruffleHogFindingsTable(findings, options) {
79930
+ assertPositiveInteger(options.maxFindings, "maxFindings");
79824
79931
  const uniqueFindings = uniqueTruffleHogFindings(findings);
79825
79932
  const rows = [
79826
79933
  "| Detector | Location | Verification |",
@@ -79895,7 +80002,7 @@ async function scanForSecrets(env, cwd, runner, fs29) {
79895
80002
  async function reportAdvisoryResult(env, runner, fs29) {
79896
80003
  const githubToken = requireEnv(env, "GH_TOKEN");
79897
80004
  const headSha = requireEnv(env, "HEAD_SHA");
79898
- const maxFindings = numberEnv(env, "MAX_FINDINGS");
80005
+ const maxFindings = positiveDecimalIntegerEnv(env, "MAX_FINDINGS");
79899
80006
  const prNumber = requireEnv(env, "PR_NUMBER");
79900
80007
  const repository = requireEnv(env, "REPOSITORY");
79901
80008
  const resultsFile = env.get("TRUFFLEHOG_RESULTS_FILE") ?? DEFAULT_RESULTS_FILE;
@@ -80076,12 +80183,31 @@ function requireEnv(env, name) {
80076
80183
  }
80077
80184
  return value;
80078
80185
  }
80079
- function numberEnv(env, name) {
80080
- const value = Number(requireEnv(env, name));
80081
- if (!Number.isFinite(value)) {
80082
- throw new UserError(`${name} must be a number.`);
80186
+ function positiveDecimalIntegerEnv(env, name) {
80187
+ const parsed = parsePositiveDecimalInteger(requireEnv(env, name));
80188
+ if (parsed === void 0) {
80189
+ throw new UserError(`${name} must be a positive integer.`);
80190
+ }
80191
+ return parsed;
80192
+ }
80193
+ function parsePositiveDecimalInteger(value) {
80194
+ let parsed = 0;
80195
+ for (const char of value) {
80196
+ const digit = char.charCodeAt(0) - "0".charCodeAt(0);
80197
+ if (digit < 0 || digit > 9) {
80198
+ return void 0;
80199
+ }
80200
+ parsed = parsed * 10 + digit;
80201
+ if (!Number.isSafeInteger(parsed)) {
80202
+ return void 0;
80203
+ }
80204
+ }
80205
+ return parsed > 0 ? parsed : void 0;
80206
+ }
80207
+ function assertPositiveInteger(value, label) {
80208
+ if (!Number.isInteger(value) || value <= 0) {
80209
+ throw new Error(`${label} must be a positive integer.`);
80083
80210
  }
80084
- return value;
80085
80211
  }
80086
80212
  function parseJsonObject(value) {
80087
80213
  try {
@@ -80156,7 +80282,7 @@ function runPreflightChecks(context) {
80156
80282
  }
80157
80283
  function checkRequiredEnvVar(env, key2) {
80158
80284
  const value = env.get(key2);
80159
- if (value === void 0 || value === "") {
80285
+ if (value === void 0 || value.trim() === "") {
80160
80286
  throw new UserError(`Missing required environment variable: ${key2}`);
80161
80287
  }
80162
80288
  }
@@ -80973,7 +81099,7 @@ var init_commands2 = __esm({
80973
81099
  await discoverAutomations(await resolveBuiltInPromptsDir(), ...projectPromptDirs(cwd))
80974
81100
  );
80975
81101
  const automation = await loadNamedAutomation(name, cwd);
80976
- const agent3 = automation.agent ?? params.agent ?? "codex";
81102
+ const agent3 = params.agent !== void 0 && usesDefaultAgent(automation) ? params.agent : automation.agent ?? params.agent ?? "codex";
80977
81103
  const variables = await loadVariables(await resolveBuiltInAssetsDir(), projectGitHubWorkflowsDir(cwd));
80978
81104
  const sharedTemplateContext = { ...variables, ...buildTemplateContext5(env) };
80979
81105
  if (automation.source === void 0) {
@@ -85752,7 +85878,7 @@ async function* runMatrix(opts) {
85752
85878
  const source = await openSource(opts.sourceDir);
85753
85879
  const evalIds = opts.evalIds ?? await listEvals(source);
85754
85880
  const repeats = opts.repeats ?? defaultRepeats;
85755
- assertPositiveInteger("repeats", repeats);
85881
+ assertPositiveInteger2("repeats", repeats);
85756
85882
  const matrixDir = path135.join(opts.outDir ?? "runs", matrixId);
85757
85883
  await ensureRunArtifactDirectory(source.rootDir, matrixDir);
85758
85884
  for (const evalId of evalIds) {
@@ -85902,7 +86028,7 @@ function assertNonEmpty(name, values) {
85902
86028
  throw new Error(`Eval matrix ${name} must be a non-empty array`);
85903
86029
  }
85904
86030
  }
85905
- function assertPositiveInteger(name, value) {
86031
+ function assertPositiveInteger2(name, value) {
85906
86032
  if (!Number.isInteger(value) || value < 1) {
85907
86033
  throw new Error(`Eval matrix ${name} must be a positive integer`);
85908
86034
  }
@@ -138162,7 +138288,7 @@ var init_package2 = __esm({
138162
138288
  "package.json"() {
138163
138289
  package_default2 = {
138164
138290
  name: "poe-code",
138165
- version: "3.0.339",
138291
+ version: "3.0.341",
138166
138292
  description: "CLI tool to configure Poe API for developer workflows.",
138167
138293
  type: "module",
138168
138294
  main: "./dist/index.js",