spacecode 2.4.1 → 2.5.0
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 +4 -4
- package/dist/index.js.map +2 -2
- package/dist/repl.mjs +34 -20
- package/package.json +1 -1
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
|
|
5329
|
-
const
|
|
5330
|
-
const
|
|
5331
|
-
const
|
|
5332
|
-
|
|
5333
|
-
const
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
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
|
-
|
|
5346
|
-
|
|
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) {
|
|
@@ -5649,7 +5663,7 @@ __export(import_claude_exports, {
|
|
|
5649
5663
|
});
|
|
5650
5664
|
async function runImportClaude(deps) {
|
|
5651
5665
|
const flags = deps.argv.filter((a) => a !== "import-claude");
|
|
5652
|
-
const unknown = flags.filter((f) => !["--dry-run", "--overwrite", "--adapt", "--yes", "--restore-original"].includes(f));
|
|
5666
|
+
const unknown = flags.filter((f) => !["--dry-run", "--overwrite", "--adapt", "--no-adapt", "--yes", "--restore-original"].includes(f));
|
|
5653
5667
|
if (unknown.length > 0) {
|
|
5654
5668
|
deps.log(`Unknown option: ${unknown.join(" ")}
|
|
5655
5669
|
${USAGE}`);
|
|
@@ -5657,9 +5671,9 @@ ${USAGE}`);
|
|
|
5657
5671
|
}
|
|
5658
5672
|
const dryRun = flags.includes("--dry-run");
|
|
5659
5673
|
const overwrite = flags.includes("--overwrite");
|
|
5660
|
-
const adapt = flags.includes("--adapt");
|
|
5674
|
+
const adapt = !flags.includes("--no-adapt");
|
|
5661
5675
|
const restore = flags.includes("--restore-original");
|
|
5662
|
-
if (restore && (adapt || dryRun)) {
|
|
5676
|
+
if (restore && (flags.includes("--adapt") || dryRun)) {
|
|
5663
5677
|
deps.log(`--restore-original cannot be combined with --adapt or --dry-run
|
|
5664
5678
|
${USAGE}`);
|
|
5665
5679
|
return 2;
|
|
@@ -5745,7 +5759,7 @@ var init_import_claude = __esm({
|
|
|
5745
5759
|
init_api_key();
|
|
5746
5760
|
init_profile_runtime();
|
|
5747
5761
|
init_import_adapt();
|
|
5748
|
-
USAGE = "Usage: spacecode import-claude [--dry-run] [--overwrite] [--adapt [--yes]
|
|
5762
|
+
USAGE = "Usage: spacecode import-claude [--dry-run] [--overwrite] [--no-adapt] [--yes] [--restore-original]";
|
|
5749
5763
|
}
|
|
5750
5764
|
});
|
|
5751
5765
|
|