poe-code 3.0.341 → 3.0.342

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
@@ -91895,11 +91895,16 @@ function buildOpenSourceAction(options) {
91895
91895
  id: "open-source",
91896
91896
  key: "o",
91897
91897
  label: "Open in $EDITOR",
91898
- predicate: (ctx) => getTask(options.taskByRowId(), ctx.row.id).sourcePath != null,
91898
+ predicate: (ctx) => getSourcePath(getTask(options.taskByRowId(), ctx.row.id)) !== null,
91899
91899
  handler: async (ctx) => {
91900
91900
  const task = getTask(options.taskByRowId(), ctx.row.id);
91901
+ const sourcePath = getSourcePath(task);
91902
+ if (sourcePath === null) {
91903
+ ctx.toast("No source file available.", "info");
91904
+ return;
91905
+ }
91901
91906
  await ctx.suspendAnd(async () => {
91902
- editFile(task.sourcePath, { env: options.variables });
91907
+ editFile(sourcePath, { env: options.variables });
91903
91908
  });
91904
91909
  await ctx.refresh();
91905
91910
  ctx.toast(`Edited ${task.qualifiedId}`, "info");
@@ -91931,13 +91936,24 @@ function getIssueUrl(task) {
91931
91936
  if (typeof url !== "string") {
91932
91937
  return null;
91933
91938
  }
91939
+ const trimmedUrl = url.trim();
91940
+ if (trimmedUrl.length === 0) {
91941
+ return null;
91942
+ }
91934
91943
  try {
91935
- const parsedUrl = new URL(url);
91936
- return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:" ? url : null;
91944
+ const parsedUrl = new URL(trimmedUrl);
91945
+ return parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:" ? trimmedUrl : null;
91937
91946
  } catch {
91938
91947
  return null;
91939
91948
  }
91940
91949
  }
91950
+ function getSourcePath(task) {
91951
+ const sourcePath = task.sourcePath;
91952
+ if (typeof sourcePath !== "string" || sourcePath.trim().length === 0) {
91953
+ return null;
91954
+ }
91955
+ return sourcePath;
91956
+ }
91941
91957
  function getTask(taskByRowId, rowId) {
91942
91958
  const task = taskByRowId.get(rowId);
91943
91959
  if (task === void 0) {
@@ -92033,6 +92049,7 @@ async function renderTaskDetailMarkdown(task, taskList) {
92033
92049
  const eventsMarkdown = await renderEventsMarkdown(task, taskList);
92034
92050
  const description = task.description.length > 0 ? task.description : "_No description._";
92035
92051
  const metadata = stringify7(task.metadata).trimEnd();
92052
+ const metadataFence = buildBacktickFence(metadata);
92036
92053
  return [
92037
92054
  `# ${task.name}`,
92038
92055
  "",
@@ -92042,9 +92059,9 @@ async function renderTaskDetailMarkdown(task, taskList) {
92042
92059
  "",
92043
92060
  "## Metadata",
92044
92061
  "",
92045
- "```yaml",
92062
+ `${metadataFence}yaml`,
92046
92063
  metadata,
92047
- "```",
92064
+ metadataFence,
92048
92065
  "",
92049
92066
  "## Next",
92050
92067
  "",
@@ -92059,9 +92076,42 @@ async function renderEventsMarkdown(task, taskList) {
92059
92076
  }
92060
92077
  return events.map((event) => `- ${event}`).join("\n");
92061
92078
  } catch (err) {
92062
- return `_Could not load events: ${err.message}_`;
92079
+ return `_Could not load events: ${formatThrownValue(err)}_`;
92063
92080
  }
92064
92081
  }
92082
+ function buildBacktickFence(content) {
92083
+ return "`".repeat(Math.max(3, longestCharacterRun(content, "`") + 1));
92084
+ }
92085
+ function longestCharacterRun(content, expected) {
92086
+ let longest = 0;
92087
+ let current = 0;
92088
+ for (const character of content) {
92089
+ if (character === expected) {
92090
+ current += 1;
92091
+ longest = Math.max(longest, current);
92092
+ } else {
92093
+ current = 0;
92094
+ }
92095
+ }
92096
+ return longest;
92097
+ }
92098
+ function formatThrownValue(value) {
92099
+ if (value instanceof Error && value.message.length > 0) {
92100
+ return value.message;
92101
+ }
92102
+ if (typeof value === "string" && value.length > 0) {
92103
+ return value;
92104
+ }
92105
+ try {
92106
+ const json = JSON.stringify(value);
92107
+ if (json !== void 0 && json.length > 0) {
92108
+ return json;
92109
+ }
92110
+ } catch {
92111
+ }
92112
+ const text5 = String(value);
92113
+ return text5.length > 0 ? text5 : "unknown error";
92114
+ }
92065
92115
  function toTaskMap(tasks) {
92066
92116
  const taskByRowId = /* @__PURE__ */ new Map();
92067
92117
  for (const task of tasks) {
@@ -92111,9 +92161,7 @@ var init_explorer_config2 = __esm({
92111
92161
  STATE_ORDER_INDEX = new Map(
92112
92162
  STATE_ORDER.map((state, index) => [state, index])
92113
92163
  );
92114
- STATE_TONES = new Map(
92115
- KNOWN_STATES.map(({ state, tone }) => [state, tone])
92116
- );
92164
+ STATE_TONES = new Map(KNOWN_STATES.map(({ state, tone }) => [state, tone]));
92117
92165
  }
92118
92166
  });
92119
92167
 
@@ -138288,7 +138336,7 @@ var init_package2 = __esm({
138288
138336
  "package.json"() {
138289
138337
  package_default2 = {
138290
138338
  name: "poe-code",
138291
- version: "3.0.341",
138339
+ version: "3.0.342",
138292
138340
  description: "CLI tool to configure Poe API for developer workflows.",
138293
138341
  type: "module",
138294
138342
  main: "./dist/index.js",