poe-code 3.0.193 → 3.0.194

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.
@@ -609,8 +609,8 @@ function resourceNotFound(resource) {
609
609
  `Resource not found: ${resource}`
610
610
  );
611
611
  }
612
- function assertAbsolutePath(path29) {
613
- if (!isAbsolute(path29)) {
612
+ function assertAbsolutePath(path30) {
613
+ if (!isAbsolute(path30)) {
614
614
  throw invalidParams('"path" must be an absolute path');
615
615
  }
616
616
  }
@@ -16843,21 +16843,21 @@ async function* adaptClaude(lines) {
16843
16843
  if (blockType !== "tool_result") continue;
16844
16844
  const kind = toolKindsById.get(item.tool_use_id);
16845
16845
  toolKindsById.delete(item.tool_use_id);
16846
- let path29;
16846
+ let path30;
16847
16847
  if (typeof item.content === "string") {
16848
- path29 = item.content;
16848
+ path30 = item.content;
16849
16849
  } else {
16850
16850
  try {
16851
- path29 = JSON.stringify(item.content);
16851
+ path30 = JSON.stringify(item.content);
16852
16852
  } catch {
16853
- path29 = String(item.content);
16853
+ path30 = String(item.content);
16854
16854
  }
16855
16855
  }
16856
16856
  yield {
16857
16857
  event: "tool_complete",
16858
16858
  id: item.tool_use_id,
16859
16859
  kind,
16860
- path: path29
16860
+ path: path30
16861
16861
  };
16862
16862
  }
16863
16863
  }
@@ -16980,10 +16980,10 @@ async function* adaptCodex(lines) {
16980
16980
  const kindFromStart = toolKindById.get(item.id);
16981
16981
  const kind = kindFromStart ?? (itemType === "command_execution" ? "exec" : itemType === "file_edit" ? "edit" : "other");
16982
16982
  const titleFromEvent = isNonEmptyString(item.path) ? item.path : itemType === "mcp_tool_call" ? `${isNonEmptyString(item.server) ? item.server : "unknown"}.${isNonEmptyString(item.tool) ? item.tool : "unknown"}` : void 0;
16983
- const path29 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
16983
+ const path30 = titleFromEvent ?? toolTitleById.get(item.id) ?? "";
16984
16984
  toolTitleById.delete(item.id);
16985
16985
  toolKindById.delete(item.id);
16986
- yield { event: "tool_complete", id: item.id, kind, path: path29 };
16986
+ yield { event: "tool_complete", id: item.id, kind, path: path30 };
16987
16987
  }
16988
16988
  }
16989
16989
  }
@@ -17507,7 +17507,7 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
17507
17507
  }
17508
17508
  const id = readString(event.id);
17509
17509
  const kind = readString(event.kind);
17510
- const path29 = readString(event.path);
17510
+ const path30 = readString(event.path);
17511
17511
  let toolCall = id ? toolCallsById.get(id) : void 0;
17512
17512
  if (!toolCall) {
17513
17513
  toolCall = {};
@@ -17522,8 +17522,8 @@ function updateSessionFromEvent(ctx, event, toolCallsById) {
17522
17522
  if (kind) {
17523
17523
  toolCall.kind = kind;
17524
17524
  }
17525
- if (path29) {
17526
- toolCall.path = path29;
17525
+ if (path30) {
17526
+ toolCall.path = path30;
17527
17527
  }
17528
17528
  }
17529
17529
  var sessionCapture;
@@ -18183,11 +18183,11 @@ function stripBom(content) {
18183
18183
  function mergeLayers(layers) {
18184
18184
  return mergeObjectLayers(layers, []);
18185
18185
  }
18186
- function mergeObjectLayers(layers, path29) {
18186
+ function mergeObjectLayers(layers, path30) {
18187
18187
  const data = {};
18188
18188
  const sources = {};
18189
18189
  for (const key2 of collectKeys(layers)) {
18190
- const resolved = resolveKey(layers, key2, path29);
18190
+ const resolved = resolveKey(layers, key2, path30);
18191
18191
  if (resolved === void 0) {
18192
18192
  continue;
18193
18193
  }
@@ -18205,7 +18205,7 @@ function collectKeys(layers) {
18205
18205
  }
18206
18206
  return [...keys];
18207
18207
  }
18208
- function resolveKey(layers, key2, path29) {
18208
+ function resolveKey(layers, key2, path30) {
18209
18209
  let winningSource;
18210
18210
  let winningValue;
18211
18211
  const objectLayers = [];
@@ -18235,9 +18235,9 @@ function resolveKey(layers, key2, path29) {
18235
18235
  if (winningSource === void 0) {
18236
18236
  return void 0;
18237
18237
  }
18238
- const fullPath = buildPath(path29, key2);
18238
+ const fullPath = buildPath(path30, key2);
18239
18239
  if (isPlainObject(winningValue)) {
18240
- const merged = mergeObjectLayers(objectLayers, [...path29, key2]);
18240
+ const merged = mergeObjectLayers(objectLayers, [...path30, key2]);
18241
18241
  return {
18242
18242
  value: merged.data,
18243
18243
  sources: {
@@ -18262,8 +18262,8 @@ function isWinningCandidate(key2, value) {
18262
18262
  }
18263
18263
  return true;
18264
18264
  }
18265
- function buildPath(path29, key2) {
18266
- return [...path29, key2].join(".");
18265
+ function buildPath(path30, key2) {
18266
+ return [...path30, key2].join(".");
18267
18267
  }
18268
18268
  function isPlainObject(value) {
18269
18269
  if (value === null || Array.isArray(value) || typeof value !== "object") {
@@ -18858,16 +18858,16 @@ function getConfigFormat(pathOrFormat) {
18858
18858
  }
18859
18859
  return formatRegistry[formatName];
18860
18860
  }
18861
- function detectFormat2(path29) {
18862
- const ext = getExtension(path29);
18861
+ function detectFormat2(path30) {
18862
+ const ext = getExtension(path30);
18863
18863
  return extensionMap[ext];
18864
18864
  }
18865
- function getExtension(path29) {
18866
- const lastDot = path29.lastIndexOf(".");
18865
+ function getExtension(path30) {
18866
+ const lastDot = path30.lastIndexOf(".");
18867
18867
  if (lastDot === -1) {
18868
18868
  return "";
18869
18869
  }
18870
- return path29.slice(lastDot).toLowerCase();
18870
+ return path30.slice(lastDot).toLowerCase();
18871
18871
  }
18872
18872
 
18873
18873
  // packages/config-mutations/src/execution/path-utils.ts
@@ -19926,7 +19926,7 @@ function createInstallRunner(definition) {
19926
19926
  }
19927
19927
 
19928
19928
  // src/services/config.ts
19929
- import path28 from "node:path";
19929
+ import path29 from "node:path";
19930
19930
  init_src8();
19931
19931
 
19932
19932
  // packages/superintendent/src/document/parse.ts
@@ -20491,22 +20491,83 @@ function backoff(attempt, minTimeout, maxTimeout) {
20491
20491
  function hasErrorCode(error2, code) {
20492
20492
  return !!error2 && typeof error2 === "object" && "code" in error2 && error2.code === code;
20493
20493
  }
20494
+ function hasAnyErrorCode(error2, codes) {
20495
+ return codes.some((code) => hasErrorCode(error2, code));
20496
+ }
20497
+ function isPidRunning(pid) {
20498
+ try {
20499
+ process.kill(pid, 0);
20500
+ return true;
20501
+ } catch (error2) {
20502
+ return !hasErrorCode(error2, "ESRCH");
20503
+ }
20504
+ }
20494
20505
  function createDefaultFs() {
20495
20506
  return {
20496
- open: (path29, flags) => fsPromises5.open(path29, flags),
20507
+ open: (path30, flags) => fsPromises5.open(path30, flags),
20508
+ readFile: (path30, encoding) => fsPromises5.readFile(path30, encoding),
20497
20509
  stat: fsPromises5.stat,
20498
20510
  unlink: fsPromises5.unlink
20499
20511
  };
20500
20512
  }
20501
- async function removeLockFile(fs4, lockPath) {
20513
+ async function removeLockFile(fs4, lockPath, signal) {
20514
+ for (let attempt = 0; attempt <= 4; attempt += 1) {
20515
+ throwIfAborted(signal);
20516
+ try {
20517
+ await fs4.unlink(lockPath);
20518
+ return;
20519
+ } catch (error2) {
20520
+ if (hasErrorCode(error2, "ENOENT")) {
20521
+ return;
20522
+ }
20523
+ if (!hasAnyErrorCode(error2, ["EPERM", "EBUSY"]) || attempt === 4) {
20524
+ throw error2;
20525
+ }
20526
+ }
20527
+ await sleep(25 * 2 ** attempt, signal);
20528
+ }
20529
+ }
20530
+ function parseLockMetadata(content) {
20502
20531
  try {
20503
- await fs4.unlink(lockPath);
20532
+ const parsed = JSON.parse(content);
20533
+ if (!parsed || typeof parsed !== "object" || !("host" in parsed) || !("pid" in parsed)) {
20534
+ return void 0;
20535
+ }
20536
+ const { host, pid } = parsed;
20537
+ if (typeof host === "string" && typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0) {
20538
+ return {
20539
+ host,
20540
+ pid
20541
+ };
20542
+ }
20543
+ } catch (ignoredError) {
20544
+ void ignoredError;
20545
+ }
20546
+ return void 0;
20547
+ }
20548
+ async function readLockMetadata(fs4, lockPath) {
20549
+ if (!fs4.readFile) {
20550
+ return void 0;
20551
+ }
20552
+ try {
20553
+ return parseLockMetadata(await fs4.readFile(lockPath, "utf8"));
20504
20554
  } catch (error2) {
20505
- if (!hasErrorCode(error2, "ENOENT")) {
20506
- throw error2;
20555
+ if (hasErrorCode(error2, "ENOENT")) {
20556
+ return null;
20507
20557
  }
20558
+ return void 0;
20508
20559
  }
20509
20560
  }
20561
+ async function shouldReclaimLock(options) {
20562
+ const metadata = await readLockMetadata(options.fs, options.lockPath);
20563
+ if (metadata === null) {
20564
+ return "missing";
20565
+ }
20566
+ if (metadata?.host === os2.hostname()) {
20567
+ return !options.isPidRunning(metadata.pid);
20568
+ }
20569
+ return Date.now() - options.stat.mtimeMs > options.staleMs;
20570
+ }
20510
20571
  async function writeLockMetadata(handle) {
20511
20572
  try {
20512
20573
  await handle.writeFile(
@@ -20527,7 +20588,8 @@ async function acquireFileLock(filePath, options = {}) {
20527
20588
  const retries = options.retries ?? 20;
20528
20589
  const minTimeout = options.minTimeout ?? 25;
20529
20590
  const maxTimeout = options.maxTimeout ?? 250;
20530
- const staleMs = options.staleMs ?? 3e4;
20591
+ const staleMs = options.staleMs ?? 1e3;
20592
+ const pidIsRunning = options.isPidRunning ?? isPidRunning;
20531
20593
  const lockPath = `${filePath}.lock`;
20532
20594
  let attempt = 0;
20533
20595
  while (attempt <= retries) {
@@ -20541,7 +20603,7 @@ async function acquireFileLock(filePath, options = {}) {
20541
20603
  return;
20542
20604
  }
20543
20605
  released = true;
20544
- await removeLockFile(fs4, lockPath);
20606
+ await removeLockFile(fs4, lockPath, options.signal);
20545
20607
  };
20546
20608
  } catch (error2) {
20547
20609
  if (!hasErrorCode(error2, "EEXIST")) {
@@ -20557,8 +20619,18 @@ async function acquireFileLock(filePath, options = {}) {
20557
20619
  }
20558
20620
  throw statError;
20559
20621
  }
20560
- if (Date.now() - stat7.mtimeMs > staleMs) {
20561
- await removeLockFile(fs4, lockPath);
20622
+ const reclaimLock = await shouldReclaimLock({
20623
+ fs: fs4,
20624
+ isPidRunning: pidIsRunning,
20625
+ lockPath,
20626
+ staleMs,
20627
+ stat: stat7
20628
+ });
20629
+ if (reclaimLock === "missing") {
20630
+ continue;
20631
+ }
20632
+ if (reclaimLock) {
20633
+ await removeLockFile(fs4, lockPath, options.signal);
20562
20634
  continue;
20563
20635
  }
20564
20636
  if (attempt >= retries) {
@@ -21909,7 +21981,7 @@ async function withInjectedAgentRunner(options, operation) {
21909
21981
  }
21910
21982
 
21911
21983
  // packages/toolcraft/src/index.ts
21912
- import { fileURLToPath as fileURLToPath2 } from "node:url";
21984
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
21913
21985
 
21914
21986
  // packages/toolcraft/src/user-error.ts
21915
21987
  var UserError = class extends Error {
@@ -22064,6 +22136,11 @@ var S = {
22064
22136
  Json
22065
22137
  };
22066
22138
 
22139
+ // packages/toolcraft/src/package-metadata.ts
22140
+ import { existsSync, readFileSync as readFileSync2, statSync } from "node:fs";
22141
+ import path23 from "node:path";
22142
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
22143
+
22067
22144
  // packages/toolcraft/src/index.ts
22068
22145
  var commandConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.command.config");
22069
22146
  var groupConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.group.config");
@@ -22149,7 +22226,7 @@ function validateRenameMap(rename3) {
22149
22226
  function parseStackPath(candidate) {
22150
22227
  if (candidate.startsWith("file://")) {
22151
22228
  try {
22152
- return fileURLToPath2(candidate);
22229
+ return fileURLToPath3(candidate);
22153
22230
  } catch {
22154
22231
  return void 0;
22155
22232
  }
@@ -22478,14 +22555,14 @@ function hasCode2(error2, code) {
22478
22555
  }
22479
22556
 
22480
22557
  // packages/superintendent/src/commands/install.ts
22481
- import path25 from "node:path";
22482
- import { readFile as readFile4, stat as stat4, mkdir as mkdir4, writeFile as writeFile2, unlink as unlink3, readdir as readdir3, chmod as chmod2 } from "node:fs/promises";
22483
- import { fileURLToPath as fileURLToPath4 } from "node:url";
22558
+ import path26 from "node:path";
22559
+ import { readFile as readFile5, stat as stat4, mkdir as mkdir4, writeFile as writeFile2, unlink as unlink3, readdir as readdir3, chmod as chmod2 } from "node:fs/promises";
22560
+ import { fileURLToPath as fileURLToPath5 } from "node:url";
22484
22561
 
22485
22562
  // packages/agent-skill-config/src/configs.ts
22486
22563
  init_src5();
22487
22564
  import os3 from "node:os";
22488
- import path23 from "node:path";
22565
+ import path24 from "node:path";
22489
22566
  var agentSkillConfigs = {
22490
22567
  "claude-code": {
22491
22568
  globalSkillDir: "~/.claude/skills",
@@ -22518,9 +22595,9 @@ function resolveAgentSupport(input, registry = agentSkillConfigs) {
22518
22595
  }
22519
22596
 
22520
22597
  // packages/agent-skill-config/src/templates.ts
22521
- import { readFile as readFile3, stat as stat3 } from "node:fs/promises";
22522
- import path24 from "node:path";
22523
- import { fileURLToPath as fileURLToPath3 } from "node:url";
22598
+ import { readFile as readFile4, stat as stat3 } from "node:fs/promises";
22599
+ import path25 from "node:path";
22600
+ import { fileURLToPath as fileURLToPath4 } from "node:url";
22524
22601
 
22525
22602
  // packages/agent-skill-config/src/apply.ts
22526
22603
  var UnsupportedAgentError = class extends Error {
@@ -22578,7 +22655,7 @@ async function installSkill(agentId, skill, options) {
22578
22655
 
22579
22656
  // packages/superintendent/src/commands/install.ts
22580
22657
  var fs2 = {
22581
- readFile: (p, encoding) => readFile4(p, encoding),
22658
+ readFile: (p, encoding) => readFile5(p, encoding),
22582
22659
  writeFile: (p, content) => writeFile2(p, content),
22583
22660
  mkdir: (p, options) => mkdir4(p, options).then(() => void 0),
22584
22661
  unlink: (p) => unlink3(p),
@@ -22673,9 +22750,9 @@ async function resolvePlanDirectory(cwd, homeDir, env) {
22673
22750
  }
22674
22751
  function resolveAbsoluteDirectory(dir, cwd, homeDir) {
22675
22752
  if (dir.startsWith("~/")) {
22676
- return path25.join(homeDir, dir.slice(2));
22753
+ return path26.join(homeDir, dir.slice(2));
22677
22754
  }
22678
- return path25.isAbsolute(dir) ? dir : path25.resolve(cwd, dir);
22755
+ return path26.isAbsolute(dir) ? dir : path26.resolve(cwd, dir);
22679
22756
  }
22680
22757
  async function pathExists2(targetPath) {
22681
22758
  try {
@@ -22693,17 +22770,17 @@ async function loadSkillTemplate() {
22693
22770
  if (skillTemplateCache) {
22694
22771
  return skillTemplateCache;
22695
22772
  }
22696
- const packageRoot = await findPackageRoot(fileURLToPath4(import.meta.url));
22773
+ const packageRoot = await findPackageRoot(fileURLToPath5(import.meta.url));
22697
22774
  const templateRoots = [
22698
- path25.join(packageRoot, "src", "templates"),
22699
- path25.join(packageRoot, "dist", "templates")
22775
+ path26.join(packageRoot, "src", "templates"),
22776
+ path26.join(packageRoot, "dist", "templates")
22700
22777
  ];
22701
22778
  for (const templateRoot of templateRoots) {
22702
22779
  if (!await pathExists2(templateRoot)) {
22703
22780
  continue;
22704
22781
  }
22705
- skillTemplateCache = await readFile4(
22706
- path25.join(templateRoot, "SKILL_superintendent.md"),
22782
+ skillTemplateCache = await readFile5(
22783
+ path26.join(templateRoot, "SKILL_superintendent.md"),
22707
22784
  "utf8"
22708
22785
  );
22709
22786
  return skillTemplateCache;
@@ -22711,12 +22788,12 @@ async function loadSkillTemplate() {
22711
22788
  throw new Error("Unable to locate Superintendent skill template.");
22712
22789
  }
22713
22790
  async function findPackageRoot(entryFilePath) {
22714
- let currentPath = path25.dirname(entryFilePath);
22791
+ let currentPath = path26.dirname(entryFilePath);
22715
22792
  while (true) {
22716
- if (await pathExists2(path25.join(currentPath, "package.json"))) {
22793
+ if (await pathExists2(path26.join(currentPath, "package.json"))) {
22717
22794
  return currentPath;
22718
22795
  }
22719
- const parentPath = path25.dirname(currentPath);
22796
+ const parentPath = path26.dirname(currentPath);
22720
22797
  if (parentPath === currentPath) {
22721
22798
  throw new Error("Unable to locate package root for Superintendent templates.");
22722
22799
  }
@@ -22914,10 +22991,10 @@ function hasCode4(error2, code) {
22914
22991
  }
22915
22992
 
22916
22993
  // packages/superintendent/src/commands/plan-path.ts
22917
- import path26 from "node:path";
22918
- import { readFile as readFile5, writeFile as writeFile3, mkdir as mkdir5, unlink as unlink4, stat as stat5, readdir as readdir4 } from "node:fs/promises";
22994
+ import path27 from "node:path";
22995
+ import { readFile as readFile6, writeFile as writeFile3, mkdir as mkdir5, unlink as unlink4, stat as stat5, readdir as readdir4 } from "node:fs/promises";
22919
22996
  var fs3 = {
22920
- readFile: (p, encoding) => readFile5(p, encoding),
22997
+ readFile: (p, encoding) => readFile6(p, encoding),
22921
22998
  writeFile: (p, content) => writeFile3(p, content),
22922
22999
  mkdir: (p, options) => mkdir5(p, options).then(() => void 0),
22923
23000
  unlink: (p) => unlink4(p),
@@ -22949,13 +23026,13 @@ var planPathCommand = defineCommand({
22949
23026
  });
22950
23027
  function resolveAbsoluteDirectory2(dir, cwd, homeDir) {
22951
23028
  if (dir.startsWith("~/")) {
22952
- return path26.join(homeDir, dir.slice(2));
23029
+ return path27.join(homeDir, dir.slice(2));
22953
23030
  }
22954
- return path26.isAbsolute(dir) ? dir : path26.resolve(cwd, dir);
23031
+ return path27.isAbsolute(dir) ? dir : path27.resolve(cwd, dir);
22955
23032
  }
22956
23033
 
22957
23034
  // packages/superintendent/src/commands/run.ts
22958
- import path27 from "node:path";
23035
+ import path28 from "node:path";
22959
23036
  import * as fsPromises7 from "node:fs/promises";
22960
23037
  import { spawn as nodeSpawn, spawnSync as nodeSpawnSync } from "node:child_process";
22961
23038
  init_src7();
@@ -23466,7 +23543,7 @@ async function runSuperintendentCommand(options) {
23466
23543
  session.pauseRequested = true;
23467
23544
  }
23468
23545
  editPlan(session.dashboard, session.latestLogFile, env, options.openInEditor);
23469
- appendEvent("info", `Log opened: ${path27.basename(session.latestLogFile)}`);
23546
+ appendEvent("info", `Log opened: ${path28.basename(session.latestLogFile)}`);
23470
23547
  syncStats();
23471
23548
  }
23472
23549
  };
@@ -23615,13 +23692,13 @@ async function listPlanDirectoryDocs(fs4, planDirectory, cwd, homeDir) {
23615
23692
  }
23616
23693
  throw error2;
23617
23694
  }
23618
- return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) => path27.join(absoluteDir, entry)).sort((left, right) => left.localeCompare(right));
23695
+ return entries.filter((entry) => entry.toLowerCase().endsWith(".md")).map((entry) => path28.join(absoluteDir, entry)).sort((left, right) => left.localeCompare(right));
23619
23696
  }
23620
23697
  function resolveAbsolutePlanDirectory(dir, cwd, homeDir) {
23621
23698
  if (dir.startsWith("~/")) {
23622
- return path27.join(homeDir, dir.slice(2));
23699
+ return path28.join(homeDir, dir.slice(2));
23623
23700
  }
23624
- return path27.isAbsolute(dir) ? dir : path27.resolve(cwd, dir);
23701
+ return path28.isAbsolute(dir) ? dir : path28.resolve(cwd, dir);
23625
23702
  }
23626
23703
  function normalizeAgentSelection(value) {
23627
23704
  if (typeof value !== "string") {
@@ -23858,7 +23935,7 @@ function resolveEditor(env) {
23858
23935
  const parts = raw.split(/\s+/);
23859
23936
  const command = parts[0] ?? "vi";
23860
23937
  const args = parts.slice(1);
23861
- const binary = path27.basename(command);
23938
+ const binary = path28.basename(command);
23862
23939
  const mode = GUI_EDITOR_BINARIES.has(binary) ? "gui" : "tty";
23863
23940
  return { command, args, mode };
23864
23941
  }
@@ -23885,11 +23962,11 @@ function stripStopReason(result) {
23885
23962
  };
23886
23963
  }
23887
23964
  function displayPath(filePath, cwd, homeDir) {
23888
- if (filePath.startsWith(`${cwd}${path27.sep}`)) {
23889
- return path27.relative(cwd, filePath);
23965
+ if (filePath.startsWith(`${cwd}${path28.sep}`)) {
23966
+ return path28.relative(cwd, filePath);
23890
23967
  }
23891
- if (filePath.startsWith(`${homeDir}${path27.sep}`)) {
23892
- return `~/${path27.relative(homeDir, filePath)}`;
23968
+ if (filePath.startsWith(`${homeDir}${path28.sep}`)) {
23969
+ return `~/${path28.relative(homeDir, filePath)}`;
23893
23970
  }
23894
23971
  return filePath;
23895
23972
  }