@nuasite/cli 0.0.32 → 0.0.34

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 (2) hide show
  1. package/dist/index.js +15 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2451,23 +2451,32 @@ var updateAgentsSummary = async (pages, redirects) => {
2451
2451
  const jsonlRecords = createJsonlRecords(pages, redirects);
2452
2452
  const summaryBody = jsonlRecords.join(`
2453
2453
  `);
2454
- const summaryBlock = `${SUMMARY_START}
2455
-
2456
- ${summaryBody}${summaryBody ? `
2457
- ` : ""}
2454
+ const summaryBlock = summaryBody ? `${SUMMARY_START}
2455
+ ${summaryBody}
2456
+ ${SUMMARY_END}
2457
+ ` : `${SUMMARY_START}
2458
2458
  ${SUMMARY_END}
2459
2459
  `;
2460
2460
  const agentsContent = await fs.readFile(AGENTS_PATH, "utf8").catch(() => "");
2461
2461
  if (agentsContent.includes(SUMMARY_START) && agentsContent.includes(SUMMARY_END)) {
2462
2462
  const startIndex = agentsContent.indexOf(SUMMARY_START);
2463
- const endIndex = agentsContent.indexOf(SUMMARY_END) + SUMMARY_END.length;
2463
+ const summaryEndIndex = agentsContent.indexOf(SUMMARY_END, startIndex);
2464
+ if (summaryEndIndex === -1) {
2465
+ const recovered = `${agentsContent.slice(0, startIndex)}${summaryBlock}`;
2466
+ await fs.writeFile(AGENTS_PATH, recovered, "utf8");
2467
+ return;
2468
+ }
2469
+ let endIndex = summaryEndIndex + SUMMARY_END.length;
2470
+ while (endIndex < agentsContent.length && (agentsContent[endIndex] === `
2471
+ ` || agentsContent[endIndex] === "\r")) {
2472
+ endIndex += 1;
2473
+ }
2464
2474
  const updated = `${agentsContent.slice(0, startIndex)}${summaryBlock}${agentsContent.slice(endIndex)}`;
2465
2475
  await fs.writeFile(AGENTS_PATH, updated, "utf8");
2466
2476
  return;
2467
2477
  }
2468
2478
  const prefix = agentsContent.trimEnd();
2469
2479
  const separator = prefix.length === 0 ? "" : `
2470
-
2471
2480
  `;
2472
2481
  await fs.writeFile(AGENTS_PATH, `${prefix}${separator}${summaryBlock}`, "utf8");
2473
2482
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuasite/cli",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,7 +23,7 @@
23
23
  "prepack": "bun run ../../scripts/workspace-deps/resolve-deps.ts"
24
24
  },
25
25
  "dependencies": {
26
- "@nuasite/agent-summary": "0.0.32",
26
+ "@nuasite/agent-summary": "0.0.34",
27
27
  "astro": "5.15.1",
28
28
  "stacktracey": "2.1.8"
29
29
  },