poe-code 3.0.103 → 3.0.104

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
@@ -13344,12 +13344,56 @@ var init_pipeline2 = __esm({
13344
13344
  }
13345
13345
  });
13346
13346
 
13347
+ // packages/ralph/src/frontmatter/frontmatter.ts
13348
+ import { stringify, parse as parse6 } from "yaml";
13349
+ function parseFrontmatter(content) {
13350
+ const defaults = { status: "pending", iteration: 0 };
13351
+ if (!content.startsWith(`${FENCE}
13352
+ `)) {
13353
+ return { data: defaults, body: content };
13354
+ }
13355
+ const closingIndex = content.indexOf(`
13356
+ ${FENCE}
13357
+ `, FENCE.length);
13358
+ if (closingIndex === -1) {
13359
+ return { data: defaults, body: content };
13360
+ }
13361
+ const yamlBlock = content.slice(FENCE.length + 1, closingIndex);
13362
+ const body = content.slice(closingIndex + FENCE.length + 2);
13363
+ const parsed = parse6(yamlBlock);
13364
+ return {
13365
+ data: {
13366
+ status: isValidStatus(parsed?.status) ? parsed.status : defaults.status,
13367
+ iteration: typeof parsed?.iteration === "number" ? parsed.iteration : defaults.iteration
13368
+ },
13369
+ body
13370
+ };
13371
+ }
13372
+ function writeFrontmatter(data, body) {
13373
+ const yaml = stringify(data).trimEnd();
13374
+ return `${FENCE}
13375
+ ${yaml}
13376
+ ${FENCE}
13377
+ ${body}`;
13378
+ }
13379
+ function isValidStatus(value) {
13380
+ return typeof value === "string" && ["pending", "in_progress", "completed", "overbake_abort", "cancelled"].includes(
13381
+ value
13382
+ );
13383
+ }
13384
+ var FENCE;
13385
+ var init_frontmatter = __esm({
13386
+ "packages/ralph/src/frontmatter/frontmatter.ts"() {
13387
+ "use strict";
13388
+ FENCE = "---";
13389
+ }
13390
+ });
13391
+
13347
13392
  // packages/ralph/src/discovery/discovery.ts
13348
13393
  import path17 from "node:path";
13349
13394
  import * as fsPromises6 from "node:fs/promises";
13350
13395
  function createDefaultFs4() {
13351
13396
  return {
13352
- readFile: fsPromises6.readFile,
13353
13397
  readdir: fsPromises6.readdir,
13354
13398
  stat: async (filePath) => {
13355
13399
  const stat8 = await fsPromises6.stat(filePath);
@@ -13472,10 +13516,31 @@ async function runRalph(options) {
13472
13516
  options.cwd,
13473
13517
  options.homeDir
13474
13518
  );
13475
- const prompt = await fs3.readFile(absoluteDocPath, "utf8");
13519
+ const rawContent = await fs3.readFile(absoluteDocPath, "utf8");
13520
+ const { body: prompt } = parseFrontmatter(rawContent);
13476
13521
  const detector = new OverbakingDetector(threshold);
13477
13522
  const startTime = Date.now();
13478
13523
  let iterationsCompleted = 0;
13524
+ await updateFrontmatter(fs3, absoluteDocPath, prompt, "in_progress", 0);
13525
+ async function finalize2(stopReason) {
13526
+ const status = stopReasonToStatus(stopReason);
13527
+ await updateFrontmatter(
13528
+ fs3,
13529
+ absoluteDocPath,
13530
+ prompt,
13531
+ status,
13532
+ iterationsCompleted
13533
+ );
13534
+ if (stopReason === "max_iterations" && iterationsCompleted > 0) {
13535
+ await archivePlan2(fs3, absoluteDocPath);
13536
+ }
13537
+ return {
13538
+ stopReason,
13539
+ docPath: options.docPath,
13540
+ iterationsCompleted,
13541
+ totalDurationMs: Date.now() - startTime
13542
+ };
13543
+ }
13479
13544
  try {
13480
13545
  for (let iteration = 1; iteration <= options.maxIterations; iteration += 1) {
13481
13546
  assertNotAborted5(options.signal);
@@ -13492,17 +13557,19 @@ async function runRalph(options) {
13492
13557
  });
13493
13558
  } catch (error2) {
13494
13559
  if (isAbortError2(error2)) {
13495
- return {
13496
- stopReason: "cancelled",
13497
- docPath: options.docPath,
13498
- iterationsCompleted,
13499
- totalDurationMs: Date.now() - startTime
13500
- };
13560
+ return finalize2("cancelled");
13501
13561
  }
13502
13562
  throw error2;
13503
13563
  }
13504
13564
  const success2 = result.exitCode === 0;
13505
13565
  iterationsCompleted += 1;
13566
+ await updateFrontmatter(
13567
+ fs3,
13568
+ absoluteDocPath,
13569
+ prompt,
13570
+ "in_progress",
13571
+ iterationsCompleted
13572
+ );
13506
13573
  options.onIterationComplete?.(
13507
13574
  iteration,
13508
13575
  Date.now() - iterationStart,
@@ -13521,35 +13588,21 @@ async function runRalph(options) {
13521
13588
  threshold
13522
13589
  }) : "abort";
13523
13590
  if (action === "abort") {
13524
- return {
13525
- stopReason: "overbake_abort",
13526
- docPath: options.docPath,
13527
- iterationsCompleted,
13528
- totalDurationMs: Date.now() - startTime
13529
- };
13591
+ return finalize2("overbake_abort");
13530
13592
  }
13531
13593
  }
13532
13594
  } catch (error2) {
13533
13595
  if (isAbortError2(error2)) {
13534
- return {
13535
- stopReason: "cancelled",
13536
- docPath: options.docPath,
13537
- iterationsCompleted,
13538
- totalDurationMs: Date.now() - startTime
13539
- };
13596
+ return finalize2("cancelled");
13540
13597
  }
13541
13598
  throw error2;
13542
13599
  }
13543
- return {
13544
- stopReason: "max_iterations",
13545
- docPath: options.docPath,
13546
- iterationsCompleted,
13547
- totalDurationMs: Date.now() - startTime
13548
- };
13600
+ return finalize2("max_iterations");
13549
13601
  }
13550
13602
  function createDefaultFs5() {
13551
13603
  return {
13552
13604
  readFile: fsPromises7.readFile,
13605
+ writeFile: (filePath, content) => fsPromises7.writeFile(filePath, content, "utf8"),
13553
13606
  readdir: fsPromises7.readdir,
13554
13607
  stat: async (filePath) => {
13555
13608
  const stat8 = await fsPromises7.stat(filePath);
@@ -13557,7 +13610,11 @@ function createDefaultFs5() {
13557
13610
  isFile: () => stat8.isFile(),
13558
13611
  mtimeMs: stat8.mtimeMs
13559
13612
  };
13560
- }
13613
+ },
13614
+ mkdir: async (filePath, options) => {
13615
+ await fsPromises7.mkdir(filePath, options);
13616
+ },
13617
+ rename: fsPromises7.rename
13561
13618
  };
13562
13619
  }
13563
13620
  function resolveAbsoluteDocPath(docPath, cwd, homeDir) {
@@ -13580,10 +13637,33 @@ function createAbortError4() {
13580
13637
  function isAbortError2(error2) {
13581
13638
  return error2 instanceof Error && error2.name === "AbortError";
13582
13639
  }
13640
+ async function updateFrontmatter(fs3, absoluteDocPath, body, status, iteration) {
13641
+ const content = writeFrontmatter({ status, iteration }, body);
13642
+ await fs3.writeFile(absoluteDocPath, content);
13643
+ }
13644
+ async function archivePlan2(fs3, absoluteDocPath) {
13645
+ const dir = path18.dirname(absoluteDocPath);
13646
+ const archiveDir = path18.join(dir, "archive");
13647
+ const archivePath = path18.join(archiveDir, path18.basename(absoluteDocPath));
13648
+ await fs3.mkdir(archiveDir, { recursive: true });
13649
+ await fs3.rename(absoluteDocPath, archivePath);
13650
+ }
13651
+ function stopReasonToStatus(stopReason) {
13652
+ switch (stopReason) {
13653
+ case "completed":
13654
+ case "max_iterations":
13655
+ return "completed";
13656
+ case "overbake_abort":
13657
+ return "overbake_abort";
13658
+ case "cancelled":
13659
+ return "cancelled";
13660
+ }
13661
+ }
13583
13662
  var init_ralph = __esm({
13584
13663
  "packages/ralph/src/run/ralph.ts"() {
13585
13664
  "use strict";
13586
13665
  init_detector();
13666
+ init_frontmatter();
13587
13667
  }
13588
13668
  });
13589
13669
 
@@ -13591,6 +13671,7 @@ var init_ralph = __esm({
13591
13671
  var init_src12 = __esm({
13592
13672
  "packages/ralph/src/index.ts"() {
13593
13673
  "use strict";
13674
+ init_frontmatter();
13594
13675
  init_discovery2();
13595
13676
  init_detector();
13596
13677
  init_ralph();
@@ -21676,7 +21757,7 @@ var init_errors4 = __esm({
21676
21757
  });
21677
21758
 
21678
21759
  // node_modules/zod/v4/core/parse.js
21679
- var _parse, parse6, _parseAsync, parseAsync, _safeParse, safeParse, _safeParseAsync, safeParseAsync, _encode, _decode, _encodeAsync, _decodeAsync, _safeEncode, _safeDecode, _safeEncodeAsync, _safeDecodeAsync;
21760
+ var _parse, parse7, _parseAsync, parseAsync, _safeParse, safeParse, _safeParseAsync, safeParseAsync, _encode, _decode, _encodeAsync, _decodeAsync, _safeEncode, _safeDecode, _safeEncodeAsync, _safeDecodeAsync;
21680
21761
  var init_parse = __esm({
21681
21762
  "node_modules/zod/v4/core/parse.js"() {
21682
21763
  init_core();
@@ -21695,7 +21776,7 @@ var init_parse = __esm({
21695
21776
  }
21696
21777
  return result.value;
21697
21778
  };
21698
- parse6 = /* @__PURE__ */ _parse($ZodRealError);
21779
+ parse7 = /* @__PURE__ */ _parse($ZodRealError);
21699
21780
  _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
21700
21781
  const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
21701
21782
  let result = schema._zod.run({ value, issues: [] }, ctx);
@@ -24414,10 +24495,10 @@ var init_schemas = __esm({
24414
24495
  throw new Error("implement() must be called with a function");
24415
24496
  }
24416
24497
  return function(...args) {
24417
- const parsedArgs = inst._def.input ? parse6(inst._def.input, args) : args;
24498
+ const parsedArgs = inst._def.input ? parse7(inst._def.input, args) : args;
24418
24499
  const result = Reflect.apply(func, this, parsedArgs);
24419
24500
  if (inst._def.output) {
24420
- return parse6(inst._def.output, result);
24501
+ return parse7(inst._def.output, result);
24421
24502
  }
24422
24503
  return result;
24423
24504
  };
@@ -26973,12 +27054,12 @@ var init_errors5 = __esm({
26973
27054
  });
26974
27055
 
26975
27056
  // node_modules/zod/v4/classic/parse.js
26976
- var parse7, parseAsync2, safeParse2, safeParseAsync2, encode2, decode2, encodeAsync2, decodeAsync2, safeEncode2, safeDecode2, safeEncodeAsync2, safeDecodeAsync2;
27057
+ var parse8, parseAsync2, safeParse2, safeParseAsync2, encode2, decode2, encodeAsync2, decodeAsync2, safeEncode2, safeDecode2, safeEncodeAsync2, safeDecodeAsync2;
26977
27058
  var init_parse3 = __esm({
26978
27059
  "node_modules/zod/v4/classic/parse.js"() {
26979
27060
  init_core2();
26980
27061
  init_errors5();
26981
- parse7 = /* @__PURE__ */ _parse(ZodRealError);
27062
+ parse8 = /* @__PURE__ */ _parse(ZodRealError);
26982
27063
  parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
26983
27064
  safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
26984
27065
  safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
@@ -27654,7 +27735,7 @@ var init_schemas3 = __esm({
27654
27735
  reg.add(inst, meta3);
27655
27736
  return inst;
27656
27737
  });
27657
- inst.parse = (data, params) => parse7(inst, data, params, { callee: inst.parse });
27738
+ inst.parse = (data, params) => parse8(inst, data, params, { callee: inst.parse });
27658
27739
  inst.safeParse = (data, params) => safeParse2(inst, data, params);
27659
27740
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
27660
27741
  inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
@@ -30505,10 +30586,10 @@ var require_code = __commonJS({
30505
30586
  function interpolate2(x) {
30506
30587
  return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify2(Array.isArray(x) ? x.join(",") : x);
30507
30588
  }
30508
- function stringify(x) {
30589
+ function stringify2(x) {
30509
30590
  return new _Code(safeStringify2(x));
30510
30591
  }
30511
- exports.stringify = stringify;
30592
+ exports.stringify = stringify2;
30512
30593
  function safeStringify2(x) {
30513
30594
  return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
30514
30595
  }
@@ -33923,24 +34004,24 @@ var require_fast_uri = __commonJS({
33923
34004
  function normalize(uri, options) {
33924
34005
  if (typeof uri === "string") {
33925
34006
  uri = /** @type {T} */
33926
- serialize3(parse8(uri, options), options);
34007
+ serialize3(parse9(uri, options), options);
33927
34008
  } else if (typeof uri === "object") {
33928
34009
  uri = /** @type {T} */
33929
- parse8(serialize3(uri, options), options);
34010
+ parse9(serialize3(uri, options), options);
33930
34011
  }
33931
34012
  return uri;
33932
34013
  }
33933
34014
  function resolve(baseURI, relativeURI, options) {
33934
34015
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
33935
- const resolved = resolveComponent(parse8(baseURI, schemelessOptions), parse8(relativeURI, schemelessOptions), schemelessOptions, true);
34016
+ const resolved = resolveComponent(parse9(baseURI, schemelessOptions), parse9(relativeURI, schemelessOptions), schemelessOptions, true);
33936
34017
  schemelessOptions.skipEscape = true;
33937
34018
  return serialize3(resolved, schemelessOptions);
33938
34019
  }
33939
34020
  function resolveComponent(base, relative, options, skipNormalization) {
33940
34021
  const target = {};
33941
34022
  if (!skipNormalization) {
33942
- base = parse8(serialize3(base, options), options);
33943
- relative = parse8(serialize3(relative, options), options);
34023
+ base = parse9(serialize3(base, options), options);
34024
+ relative = parse9(serialize3(relative, options), options);
33944
34025
  }
33945
34026
  options = options || {};
33946
34027
  if (!options.tolerant && relative.scheme) {
@@ -33992,13 +34073,13 @@ var require_fast_uri = __commonJS({
33992
34073
  function equal(uriA, uriB, options) {
33993
34074
  if (typeof uriA === "string") {
33994
34075
  uriA = unescape(uriA);
33995
- uriA = serialize3(normalizeComponentEncoding(parse8(uriA, options), true), { ...options, skipEscape: true });
34076
+ uriA = serialize3(normalizeComponentEncoding(parse9(uriA, options), true), { ...options, skipEscape: true });
33996
34077
  } else if (typeof uriA === "object") {
33997
34078
  uriA = serialize3(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
33998
34079
  }
33999
34080
  if (typeof uriB === "string") {
34000
34081
  uriB = unescape(uriB);
34001
- uriB = serialize3(normalizeComponentEncoding(parse8(uriB, options), true), { ...options, skipEscape: true });
34082
+ uriB = serialize3(normalizeComponentEncoding(parse9(uriB, options), true), { ...options, skipEscape: true });
34002
34083
  } else if (typeof uriB === "object") {
34003
34084
  uriB = serialize3(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
34004
34085
  }
@@ -34067,7 +34148,7 @@ var require_fast_uri = __commonJS({
34067
34148
  return uriTokens.join("");
34068
34149
  }
34069
34150
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
34070
- function parse8(uri, opts) {
34151
+ function parse9(uri, opts) {
34071
34152
  const options = Object.assign({}, opts);
34072
34153
  const parsed = {
34073
34154
  scheme: void 0,
@@ -34161,7 +34242,7 @@ var require_fast_uri = __commonJS({
34161
34242
  resolveComponent,
34162
34243
  equal,
34163
34244
  serialize: serialize3,
34164
- parse: parse8
34245
+ parse: parse9
34165
34246
  };
34166
34247
  module.exports = fastUri;
34167
34248
  module.exports.default = fastUri;
@@ -38042,7 +38123,7 @@ var init_configs3 = __esm({
38042
38123
  });
38043
38124
 
38044
38125
  // packages/agent-skill-config/src/templates.ts
38045
- import { readFile as readFile7 } from "node:fs/promises";
38126
+ import { readFile as readFile6 } from "node:fs/promises";
38046
38127
  async function getTemplates() {
38047
38128
  if (templatesCache) {
38048
38129
  return templatesCache;
@@ -38051,7 +38132,7 @@ async function getTemplates() {
38051
38132
  "./templates/poe-generate.md",
38052
38133
  import.meta.url
38053
38134
  );
38054
- const poeGenerateTemplate = await readFile7(poeGenerateTemplateUrl, "utf8");
38135
+ const poeGenerateTemplate = await readFile6(poeGenerateTemplateUrl, "utf8");
38055
38136
  templatesCache = {
38056
38137
  "poe-generate.md": poeGenerateTemplate
38057
38138
  };
@@ -39018,7 +39099,7 @@ var init_models = __esm({
39018
39099
 
39019
39100
  // src/cli/commands/pipeline.ts
39020
39101
  import path26 from "node:path";
39021
- import { readFile as readFile8, stat as stat7 } from "node:fs/promises";
39102
+ import { readFile as readFile7, stat as stat7 } from "node:fs/promises";
39022
39103
  import { fileURLToPath as fileURLToPath4 } from "node:url";
39023
39104
  function formatDuration(ms) {
39024
39105
  const totalSeconds = Math.round(ms / 1e3);
@@ -39072,8 +39153,8 @@ async function loadPipelineTemplates() {
39072
39153
  continue;
39073
39154
  }
39074
39155
  const [skillPlan, steps] = await Promise.all([
39075
- readFile8(path26.join(templateRoot, "SKILL_plan.md"), "utf8"),
39076
- readFile8(path26.join(templateRoot, "steps.yaml.hbs"), "utf8")
39156
+ readFile7(path26.join(templateRoot, "SKILL_plan.md"), "utf8"),
39157
+ readFile7(path26.join(templateRoot, "steps.yaml.hbs"), "utf8")
39077
39158
  ]);
39078
39159
  pipelineTemplatesCache = { skillPlan, steps };
39079
39160
  return pipelineTemplatesCache;
@@ -39637,7 +39718,7 @@ var init_package = __esm({
39637
39718
  "package.json"() {
39638
39719
  package_default = {
39639
39720
  name: "poe-code",
39640
- version: "3.0.103",
39721
+ version: "3.0.104",
39641
39722
  description: "CLI tool to configure Poe API for developer workflows.",
39642
39723
  type: "module",
39643
39724
  main: "./dist/index.js",