@t3lnet/sceneforge 1.0.13 → 1.0.15
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/context/context-builder.ts +56 -0
- package/context/template-loader.ts +20 -2
- package/context/tests/context-builder.test.ts +15 -2
- package/dist/index.cjs +65 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +65 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- /package/dist/templates/{templates/base → base}/actions-reference.md +0 -0
- /package/dist/templates/{templates/base → base}/cli-reference.md +0 -0
- /package/dist/templates/{templates/base → base}/project-overview.md +0 -0
- /package/dist/templates/{templates/base → base}/selectors-guide.md +0 -0
- /package/dist/templates/{templates/base → base}/yaml-schema.md +0 -0
- /package/dist/templates/{templates/skills → skills}/balance-timing.md +0 -0
- /package/dist/templates/{templates/skills → skills}/debug-selector.md +0 -0
- /package/dist/templates/{templates/skills → skills}/generate-actions.md +0 -0
- /package/dist/templates/{templates/skills → skills}/optimize-demo.md +0 -0
- /package/dist/templates/{templates/skills → skills}/review-demo-yaml.md +0 -0
- /package/dist/templates/{templates/skills → skills}/write-step-script.md +0 -0
- /package/dist/templates/{templates/stages → stages}/stage1-actions.md +0 -0
- /package/dist/templates/{templates/stages → stages}/stage2-scripts.md +0 -0
- /package/dist/templates/{templates/stages → stages}/stage3-balancing.md +0 -0
- /package/dist/templates/{templates/stages → stages}/stage4-rebalancing.md +0 -0
package/dist/index.js
CHANGED
|
@@ -2387,13 +2387,27 @@ async function discoverDemos(demoDir) {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
|
|
2389
2389
|
// context/template-loader.ts
|
|
2390
|
+
import { existsSync } from "fs";
|
|
2390
2391
|
import * as fs5 from "fs/promises";
|
|
2391
2392
|
import * as path5 from "path";
|
|
2392
2393
|
import { fileURLToPath } from "url";
|
|
2393
2394
|
var __filename = fileURLToPath(import.meta.url);
|
|
2394
2395
|
var __dirname = path5.dirname(__filename);
|
|
2395
2396
|
function getTemplatesDir() {
|
|
2396
|
-
|
|
2397
|
+
const candidates = [
|
|
2398
|
+
// Standard dist layout: dist/templates/{base,stages,skills}
|
|
2399
|
+
path5.join(__dirname, "templates"),
|
|
2400
|
+
// Nested layout if templates were copied into an existing dist/templates
|
|
2401
|
+
path5.join(__dirname, "templates", "templates"),
|
|
2402
|
+
// Source layout when templates are shipped under context/templates
|
|
2403
|
+
path5.join(__dirname, "..", "context", "templates")
|
|
2404
|
+
];
|
|
2405
|
+
for (const candidate of candidates) {
|
|
2406
|
+
if (existsSync(path5.join(candidate, "base"))) {
|
|
2407
|
+
return candidate;
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
return candidates[0];
|
|
2397
2411
|
}
|
|
2398
2412
|
async function loadTemplate(category, name) {
|
|
2399
2413
|
const templatesDir = getTemplatesDir();
|
|
@@ -2420,7 +2434,9 @@ async function loadTemplatesByCategory(category) {
|
|
|
2420
2434
|
}
|
|
2421
2435
|
return templates;
|
|
2422
2436
|
} catch (error) {
|
|
2423
|
-
throw new Error(
|
|
2437
|
+
throw new Error(
|
|
2438
|
+
`Failed to load templates from ${category} in ${templatesDir}: ${error}`
|
|
2439
|
+
);
|
|
2424
2440
|
}
|
|
2425
2441
|
}
|
|
2426
2442
|
function interpolateVariables(content, variables) {
|
|
@@ -2610,6 +2626,33 @@ async function mergeWithExisting(filePath, newContent) {
|
|
|
2610
2626
|
throw error;
|
|
2611
2627
|
}
|
|
2612
2628
|
}
|
|
2629
|
+
async function writeSplitPointer(tool, stageNames, outputDir) {
|
|
2630
|
+
const config = getToolConfig(tool);
|
|
2631
|
+
const stageLines = stageNames.map((stage) => {
|
|
2632
|
+
const friendly = formatStageName(stage);
|
|
2633
|
+
const stageFile = `${config.splitFilePrefix}${getStageFileName(stage)}${config.fileExtension}`;
|
|
2634
|
+
const relativePath = path6.posix.join(config.splitDir, stageFile);
|
|
2635
|
+
return `- ${friendly}: ${relativePath}`;
|
|
2636
|
+
});
|
|
2637
|
+
const pointerBody = [
|
|
2638
|
+
"SceneForge context for this tool is split across the following stage files:",
|
|
2639
|
+
"",
|
|
2640
|
+
...stageLines,
|
|
2641
|
+
"",
|
|
2642
|
+
`Open the stage file that matches the work you're doing, or run "npx sceneforge context preview --target ${tool} --stage <stage>" to inspect a specific stage.`
|
|
2643
|
+
].join("\n");
|
|
2644
|
+
const formattedPointer = formatForTool(tool, pointerBody, {
|
|
2645
|
+
includeToolHeader: true
|
|
2646
|
+
});
|
|
2647
|
+
const combinedPath = path6.join(outputDir, config.combinedFile);
|
|
2648
|
+
await fs6.mkdir(path6.dirname(combinedPath), { recursive: true });
|
|
2649
|
+
const { content: finalContent, merged } = await mergeWithExisting(
|
|
2650
|
+
combinedPath,
|
|
2651
|
+
formattedPointer
|
|
2652
|
+
);
|
|
2653
|
+
await fs6.writeFile(combinedPath, finalContent, "utf-8");
|
|
2654
|
+
return { filePath: combinedPath, merged };
|
|
2655
|
+
}
|
|
2613
2656
|
async function buildContext(tool, stage, variables) {
|
|
2614
2657
|
const templates = [];
|
|
2615
2658
|
const baseTemplates = await loadTemplatesByCategory("base");
|
|
@@ -2670,6 +2713,7 @@ async function deployContext(options) {
|
|
|
2670
2713
|
});
|
|
2671
2714
|
}
|
|
2672
2715
|
} else {
|
|
2716
|
+
const deployedStages = [];
|
|
2673
2717
|
for (const stg of stages) {
|
|
2674
2718
|
try {
|
|
2675
2719
|
const content = await buildContext(tool, stg, variables);
|
|
@@ -2692,6 +2736,7 @@ async function deployContext(options) {
|
|
|
2692
2736
|
if (merged) {
|
|
2693
2737
|
console.log(` [merged] ${path6.relative(outputDir, absolutePath)}`);
|
|
2694
2738
|
}
|
|
2739
|
+
deployedStages.push(stg);
|
|
2695
2740
|
} catch (error) {
|
|
2696
2741
|
results.push({
|
|
2697
2742
|
tool,
|
|
@@ -2702,6 +2747,24 @@ async function deployContext(options) {
|
|
|
2702
2747
|
});
|
|
2703
2748
|
}
|
|
2704
2749
|
}
|
|
2750
|
+
if (deployedStages.length > 0) {
|
|
2751
|
+
const pointerResult = await writeSplitPointer(
|
|
2752
|
+
tool,
|
|
2753
|
+
deployedStages,
|
|
2754
|
+
outputDir
|
|
2755
|
+
);
|
|
2756
|
+
results.push({
|
|
2757
|
+
tool,
|
|
2758
|
+
filePath: pointerResult.filePath,
|
|
2759
|
+
created: true,
|
|
2760
|
+
skipped: false
|
|
2761
|
+
});
|
|
2762
|
+
if (pointerResult.merged) {
|
|
2763
|
+
console.log(
|
|
2764
|
+
` [merged] ${path6.relative(outputDir, pointerResult.filePath)}`
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2767
|
+
}
|
|
2705
2768
|
}
|
|
2706
2769
|
}
|
|
2707
2770
|
return results;
|