poe-code 3.0.341 → 3.0.343

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/dist/index.js CHANGED
@@ -73219,10 +73219,14 @@ function validateStateDefinitions(value) {
73219
73219
  throw new Error("Workflow config requires at least one state.");
73220
73220
  }
73221
73221
  for (const [name, definition] of entries) {
73222
+ const stateName = String(name);
73223
+ if (stateName.trim().length === 0) {
73224
+ throw new Error("State names must not be empty.");
73225
+ }
73222
73226
  if (!isRecord28(definition)) {
73223
- throw new Error(`State "${String(name)}" must be an object.`);
73227
+ throw new Error(`State "${stateName}" must be an object.`);
73224
73228
  }
73225
- validateStateDefinition(String(name), definition);
73229
+ validateStateDefinition(stateName, definition);
73226
73230
  }
73227
73231
  }
73228
73232
  async function validateDispatch(cfg, taskList) {
@@ -73294,6 +73298,9 @@ function validateStateDefinition(name, definition) {
73294
73298
  if (prompt !== void 0 && typeof prompt !== "string") {
73295
73299
  throw new Error(`State "${name}" prompt must be a string.`);
73296
73300
  }
73301
+ if (typeof prompt === "string" && prompt.trim().length === 0) {
73302
+ throw new Error(`State "${name}" prompt must not be empty.`);
73303
+ }
73297
73304
  if (terminal !== void 0 && typeof terminal !== "boolean") {
73298
73305
  throw new Error(`State "${name}" terminal must be a boolean.`);
73299
73306
  }
@@ -73410,13 +73417,13 @@ function resolveConfig2(raw, cwd) {
73410
73417
  },
73411
73418
  workspace: {
73412
73419
  root: resolvePathValue(
73413
- readString8(getOwnEntry30(workspace, "root")) ?? path96.join(os13.tmpdir(), "poe-code-maestro"),
73420
+ readString8(getOwnEntry30(workspace, "root"), "workspace.root") ?? path96.join(os13.tmpdir(), "poe-code-maestro"),
73414
73421
  cwd
73415
73422
  )
73416
73423
  },
73417
73424
  agent: {
73418
- service: readString8(getOwnEntry30(agent3, "service")) ?? "codex",
73419
- list: readString8(resolveStringValue(getOwnEntry30(agent3, "list"))),
73425
+ service: readString8(getOwnEntry30(agent3, "service"), "agent.service") ?? "codex",
73426
+ list: readString8(resolveStringValue(getOwnEntry30(agent3, "list")), "agent.list"),
73420
73427
  maxConcurrentAgents: readPositiveInteger(
73421
73428
  getOwnEntry30(agent3, "max_concurrent_agents"),
73422
73429
  1,
@@ -73532,25 +73539,34 @@ function expandHome5(value) {
73532
73539
  }
73533
73540
  return value;
73534
73541
  }
73535
- function readString8(value) {
73536
- if (typeof value !== "string") {
73542
+ function readString8(value, field) {
73543
+ if (value === void 0) {
73537
73544
  return void 0;
73538
73545
  }
73546
+ if (typeof value !== "string") {
73547
+ throw new Error(`Expected "${field}" to be a string.`);
73548
+ }
73539
73549
  const trimmed = value.trim();
73540
73550
  return trimmed.length > 0 ? value : void 0;
73541
73551
  }
73542
- function readNumber3(value, fallback) {
73543
- return typeof value === "number" && Number.isFinite(value) ? value : fallback;
73552
+ function readNumber3(value, fallback, field) {
73553
+ if (value === void 0) {
73554
+ return fallback;
73555
+ }
73556
+ if (typeof value !== "number" || !Number.isFinite(value)) {
73557
+ throw new Error(`Expected "${field}" to be a number.`);
73558
+ }
73559
+ return value;
73544
73560
  }
73545
73561
  function readPositiveInteger(value, fallback, field) {
73546
- const numberValue2 = readNumber3(value, fallback);
73562
+ const numberValue2 = readNumber3(value, fallback, field);
73547
73563
  if (!Number.isInteger(numberValue2) || numberValue2 <= 0) {
73548
73564
  throw new Error(`Expected "${field}" to be a positive integer.`);
73549
73565
  }
73550
73566
  return numberValue2;
73551
73567
  }
73552
73568
  function readNonNegativeInteger(value, fallback, field) {
73553
- const numberValue2 = readNumber3(value, fallback);
73569
+ const numberValue2 = readNumber3(value, fallback, field);
73554
73570
  if (!Number.isInteger(numberValue2) || numberValue2 < 0) {
73555
73571
  throw new Error(`Expected "${field}" to be a non-negative integer.`);
73556
73572
  }
@@ -74542,7 +74558,22 @@ function resolveWorkflowPath2(name, cwd) {
74542
74558
  return path99.resolve(cwd, filename);
74543
74559
  }
74544
74560
  function isValidWorkflowName(name) {
74545
- return name.length > 0 && !name.includes("/") && !name.includes("\\");
74561
+ if (name.length === 0 || name.trim() !== name || name === "." || name === "..") {
74562
+ return false;
74563
+ }
74564
+ for (const character of name) {
74565
+ if (!isWorkflowNameCharacter(character)) {
74566
+ return false;
74567
+ }
74568
+ }
74569
+ return true;
74570
+ }
74571
+ function isWorkflowNameCharacter(character) {
74572
+ const code = character.charCodeAt(0);
74573
+ const isUppercase = code >= 65 && code <= 90;
74574
+ const isLowercase = code >= 97 && code <= 122;
74575
+ const isDigit5 = code >= 48 && code <= 57;
74576
+ return isUppercase || isLowercase || isDigit5 || character === "_" || character === "-";
74546
74577
  }
74547
74578
  var init_workflow_path = __esm({
74548
74579
  "packages/maestro/src/workflow-path.ts"() {
@@ -91895,11 +91926,16 @@ function buildOpenSourceAction(options) {
91895
91926
  id: "open-source",
91896
91927
  key: "o",
91897
91928
  label: "Open in $EDITOR",
91898
- predicate: (ctx) => getTask(options.taskByRowId(), ctx.row.id).sourcePath != null,
91929
+ predicate: (ctx) => getSourcePath(getTask(options.taskByRowId(), ctx.row.id)) !== null,
91899
91930
  handler: async (ctx) => {
91900
91931
  const task = getTask(options.taskByRowId(), ctx.row.id);
91932
+ const sourcePath = getSourcePath(task);
91933
+ if (sourcePath === null) {
91934
+ ctx.toast("No source file available.", "info");
91935
+ return;
91936
+ }
91901
91937
  await ctx.suspendAnd(async () => {
91902
- editFile(task.sourcePath, { env: options.variables });
91938
+ editFile(sourcePath, { env: options.variables });
91903
91939
  });
91904
91940
  await ctx.refresh();
91905
91941
  ctx.toast(`Edited ${task.qualifiedId}`, "info");
@@ -91931,13 +91967,24 @@ function getIssueUrl(task) {
91931
91967
  if (typeof url !== "string") {
91932
91968
  return null;
91933
91969
  }
91970
+ const trimmedUrl = url.trim();
91971
+ if (trimmedUrl.length === 0) {
91972
+ return null;
91973
+ }
91934
91974
  try {
91935
- const parsedUrl = new URL(url);
91936
- return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:" ? url : null;
91975
+ const parsedUrl = new URL(trimmedUrl);
91976
+ return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:" ? trimmedUrl : null;
91937
91977
  } catch {
91938
91978
  return null;
91939
91979
  }
91940
91980
  }
91981
+ function getSourcePath(task) {
91982
+ const sourcePath = task.sourcePath;
91983
+ if (typeof sourcePath !== "string" || sourcePath.trim().length === 0) {
91984
+ return null;
91985
+ }
91986
+ return sourcePath;
91987
+ }
91941
91988
  function getTask(taskByRowId, rowId) {
91942
91989
  const task = taskByRowId.get(rowId);
91943
91990
  if (task === void 0) {
@@ -92033,6 +92080,7 @@ async function renderTaskDetailMarkdown(task, taskList) {
92033
92080
  const eventsMarkdown = await renderEventsMarkdown(task, taskList);
92034
92081
  const description = task.description.length > 0 ? task.description : "_No description._";
92035
92082
  const metadata = stringify7(task.metadata).trimEnd();
92083
+ const metadataFence = buildBacktickFence(metadata);
92036
92084
  return [
92037
92085
  `# ${task.name}`,
92038
92086
  "",
@@ -92042,9 +92090,9 @@ async function renderTaskDetailMarkdown(task, taskList) {
92042
92090
  "",
92043
92091
  "## Metadata",
92044
92092
  "",
92045
- "```yaml",
92093
+ `${metadataFence}yaml`,
92046
92094
  metadata,
92047
- "```",
92095
+ metadataFence,
92048
92096
  "",
92049
92097
  "## Next",
92050
92098
  "",
@@ -92059,9 +92107,42 @@ async function renderEventsMarkdown(task, taskList) {
92059
92107
  }
92060
92108
  return events.map((event) => `- ${event}`).join("\n");
92061
92109
  } catch (err) {
92062
- return `_Could not load events: ${err.message}_`;
92110
+ return `_Could not load events: ${formatThrownValue(err)}_`;
92063
92111
  }
92064
92112
  }
92113
+ function buildBacktickFence(content) {
92114
+ return "`".repeat(Math.max(3, longestCharacterRun(content, "`") + 1));
92115
+ }
92116
+ function longestCharacterRun(content, expected) {
92117
+ let longest = 0;
92118
+ let current = 0;
92119
+ for (const character of content) {
92120
+ if (character === expected) {
92121
+ current += 1;
92122
+ longest = Math.max(longest, current);
92123
+ } else {
92124
+ current = 0;
92125
+ }
92126
+ }
92127
+ return longest;
92128
+ }
92129
+ function formatThrownValue(value) {
92130
+ if (value instanceof Error && value.message.length > 0) {
92131
+ return value.message;
92132
+ }
92133
+ if (typeof value === "string" && value.length > 0) {
92134
+ return value;
92135
+ }
92136
+ try {
92137
+ const json = JSON.stringify(value);
92138
+ if (json !== void 0 && json.length > 0) {
92139
+ return json;
92140
+ }
92141
+ } catch {
92142
+ }
92143
+ const text5 = String(value);
92144
+ return text5.length > 0 ? text5 : "unknown error";
92145
+ }
92065
92146
  function toTaskMap(tasks) {
92066
92147
  const taskByRowId = /* @__PURE__ */ new Map();
92067
92148
  for (const task of tasks) {
@@ -92111,9 +92192,7 @@ var init_explorer_config2 = __esm({
92111
92192
  STATE_ORDER_INDEX = new Map(
92112
92193
  STATE_ORDER.map((state, index) => [state, index])
92113
92194
  );
92114
- STATE_TONES = new Map(
92115
- KNOWN_STATES.map(({ state, tone }) => [state, tone])
92116
- );
92195
+ STATE_TONES = new Map(KNOWN_STATES.map(({ state, tone }) => [state, tone]));
92117
92196
  }
92118
92197
  });
92119
92198
 
@@ -138288,7 +138367,7 @@ var init_package2 = __esm({
138288
138367
  "package.json"() {
138289
138368
  package_default2 = {
138290
138369
  name: "poe-code",
138291
- version: "3.0.341",
138370
+ version: "3.0.343",
138292
138371
  description: "CLI tool to configure Poe API for developer workflows.",
138293
138372
  type: "module",
138294
138373
  main: "./dist/index.js",