spacecode 2.4.1 → 2.4.2

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/repl.mjs CHANGED
@@ -5325,28 +5325,41 @@ function applyPlan(input, decisions, maxCoreChars = MAX_CORE_CHARS) {
5325
5325
  }
5326
5326
  const missing = input.sections.filter((s) => !seen.has(s.slug)).map((s) => s.slug);
5327
5327
  if (missing.length > 0) throw new AdaptPlanError(`plan does not decide section(s): ${missing.join(", ")}`);
5328
- const kept = [];
5329
- const onDemand = [];
5330
- const dropped = [];
5331
- const index = [];
5332
- for (const d of decisions) {
5333
- const s = bySlug.get(d.slug);
5334
- if (d.decision === "keep") kept.push(s.text);
5335
- else if (d.decision === "on_demand") {
5336
- onDemand.push({ slug: s.slug, title: s.title, text: s.text });
5337
- index.push(`- ${s.slug}: ${s.title} \u2014 ${d.summary.trim().replace(/\s+/g, " ")}`);
5338
- } else dropped.push({ slug: s.slug, title: s.title, reason: d.reason.trim(), unsupported: s.unsupported });
5339
- }
5340
- const indexBlock = index.length > 0 ? `
5328
+ const keptSlugs = new Set(decisions.filter((d) => d.decision === "keep").map((d) => d.slug));
5329
+ const summaries = new Map(decisions.map((d) => [d.slug, d.summary?.trim().replace(/\s+/g, " ") ?? ""]));
5330
+ const demoted = [];
5331
+ const assemble = () => {
5332
+ const kept = [];
5333
+ const onDemand2 = [];
5334
+ const dropped2 = [];
5335
+ const index = [];
5336
+ for (const d of decisions) {
5337
+ const s = bySlug.get(d.slug);
5338
+ if (keptSlugs.has(d.slug)) kept.push(s.text);
5339
+ else if (d.decision === "drop") dropped2.push({ slug: s.slug, title: s.title, reason: d.reason.trim(), unsupported: s.unsupported });
5340
+ else {
5341
+ onDemand2.push({ slug: s.slug, title: s.title, text: s.text });
5342
+ index.push(`- ${s.slug}: ${s.title} \u2014 ${summaries.get(s.slug) || `read when working on: ${s.title}`}`);
5343
+ }
5344
+ }
5345
+ const indexBlock = index.length > 0 ? `
5341
5346
  ## More instructions (on demand)
5342
5347
  Use the instructions_read tool with a section name to read one before acting in that area:
5343
5348
  ${index.join("\n")}
5344
5349
  ` : "";
5345
- const core = input.preamble + kept.join("") + indexBlock;
5346
- if (core.length > maxCoreChars) throw new AdaptPlanError(`core is ${core.length} chars, over the ${maxCoreChars} budget: demote larger sections to on_demand`);
5350
+ return { core: input.preamble + kept.join("") + indexBlock, onDemand: onDemand2, dropped: dropped2 };
5351
+ };
5352
+ let { core, onDemand, dropped } = assemble();
5353
+ while (core.length > maxCoreChars && keptSlugs.size > 0) {
5354
+ const largest = [...keptSlugs].map((slug) => bySlug.get(slug)).sort((a, b2) => b2.chars - a.chars)[0];
5355
+ keptSlugs.delete(largest.slug);
5356
+ demoted.push({ slug: largest.slug, title: largest.title });
5357
+ ({ core, onDemand, dropped } = assemble());
5358
+ }
5359
+ if (core.length > maxCoreChars) throw new AdaptPlanError(`core is ${core.length} chars, over the ${maxCoreChars} budget even with every section on demand`);
5347
5360
  const translated = input.preamble + input.sections.map((s) => s.text).join("");
5348
5361
  const coverage = checkCoverage(translated, [core, ...onDemand.map((o) => o.text)], dropped.map((d) => bySlug.get(d.slug).text));
5349
- return { core, onDemand, dropped, coverage, coreChars: core.length };
5362
+ return { core, onDemand, dropped, coverage, coreChars: core.length, demoted };
5350
5363
  }
5351
5364
  var AdaptPlanError, MAX_CORE_CHARS;
5352
5365
  var init_adapt_plan = __esm({
@@ -5558,6 +5571,7 @@ async function sha12(text) {
5558
5571
  function formatAdaptReport(r, before, replaced) {
5559
5572
  const lines2 = [`Adapted instructions: ${before} chars -> core ${r.coreChars} chars + ${r.onDemand.length} on-demand section(s), ${r.dropped.length} dropped.`];
5560
5573
  for (const x2 of replaced) lines2.push(` tool name ${x2.from} -> ${x2.to} (${x2.count}x)`);
5574
+ for (const d of r.demoted) lines2.push(` demoted ${d.slug}: kept by the model but moved on demand to fit the core budget`);
5561
5575
  for (const o of r.onDemand) lines2.push(` on demand ${o.slug} (${o.text.length} chars)`);
5562
5576
  for (const d of r.dropped) lines2.push(` DROPPED ${d.slug}: ${d.reason}${d.unsupported.length ? ` [${d.unsupported.join("; ")}]` : ""}`);
5563
5577
  if (r.coverage.droppedRules.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spacecode",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "description": "SpaceCode - launch cloud dev environments with AI coding agents",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",