@xn-intenton-z2a/agentic-lib 7.4.53 → 7.4.55
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/bin/agentic-lib.js
CHANGED
|
@@ -848,7 +848,7 @@ async function initPurge(seedsDir, missionName, initTimestamp) {
|
|
|
848
848
|
// Copy mission seed file as MISSION.md (with random/generate support)
|
|
849
849
|
const missionsDir = resolve(seedsDir, "missions");
|
|
850
850
|
let resolvedMission = missionName;
|
|
851
|
-
let missionType = missionName; // "random"
|
|
851
|
+
let missionType = missionName; // "random" or the specific seed name
|
|
852
852
|
|
|
853
853
|
if (missionName === "random") {
|
|
854
854
|
// W11: Pick a random mission from available seeds
|
|
@@ -861,62 +861,20 @@ async function initPurge(seedsDir, missionName, initTimestamp) {
|
|
|
861
861
|
}
|
|
862
862
|
resolvedMission = available[Math.floor(Math.random() * available.length)];
|
|
863
863
|
console.log(` RANDOM: selected mission "${resolvedMission}" from ${available.length} available`);
|
|
864
|
-
} else if (missionName === "generate") {
|
|
865
|
-
// W12: Generate a mission using LLM
|
|
866
|
-
console.log(" GENERATE: Creating LLM-generated mission...");
|
|
867
|
-
try {
|
|
868
|
-
const { runCopilotSession } = await import("../src/copilot/copilot-session.js");
|
|
869
|
-
const available = existsSync(missionsDir)
|
|
870
|
-
? readdirSync(missionsDir).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, ""))
|
|
871
|
-
: [];
|
|
872
|
-
const sampleMission = existsSync(resolve(missionsDir, "7-kyu-understand-fizz-buzz.md"))
|
|
873
|
-
? readFileSync(resolve(missionsDir, "7-kyu-understand-fizz-buzz.md"), "utf8")
|
|
874
|
-
: "";
|
|
875
|
-
const prompt = [
|
|
876
|
-
"Generate a novel JavaScript library mission for an autonomous coding pipeline.",
|
|
877
|
-
"The mission should follow this exact structure (use the example as a template):",
|
|
878
|
-
"",
|
|
879
|
-
sampleMission,
|
|
880
|
-
"",
|
|
881
|
-
"Requirements:",
|
|
882
|
-
"- Be distinct from all existing missions: " + available.join(", "),
|
|
883
|
-
"- Difficulty should be between 8-kyu (trivial) and 2-kyu (expert)",
|
|
884
|
-
"- Include 5-10 acceptance criteria as markdown checkboxes (- [ ] ...)",
|
|
885
|
-
"- The library must be implementable in a single src/lib/main.js file",
|
|
886
|
-
"- Include edge cases and error handling in the requirements",
|
|
887
|
-
"",
|
|
888
|
-
"Write the mission to MISSION.md using the write_file tool.",
|
|
889
|
-
].join("\n");
|
|
890
|
-
await runCopilotSession({
|
|
891
|
-
workspacePath: target,
|
|
892
|
-
model,
|
|
893
|
-
userPrompt: prompt,
|
|
894
|
-
timeoutMs: 120000,
|
|
895
|
-
writablePaths: [resolve(target, "MISSION.md")],
|
|
896
|
-
});
|
|
897
|
-
resolvedMission = "generated";
|
|
898
|
-
console.log(" GENERATE: Mission written to MISSION.md");
|
|
899
|
-
} catch (err) {
|
|
900
|
-
console.error(` GENERATE: LLM generation failed (${err.message}), falling back to fizz-buzz`);
|
|
901
|
-
resolvedMission = "7-kyu-understand-fizz-buzz";
|
|
902
|
-
missionType = "generate-fallback";
|
|
903
|
-
}
|
|
904
864
|
}
|
|
905
865
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
console.error(`Available missions: ${available.join(", ")}`);
|
|
917
|
-
}
|
|
918
|
-
process.exit(1);
|
|
866
|
+
const selectedMissionFile = resolve(missionsDir, `${resolvedMission}.md`);
|
|
867
|
+
if (existsSync(selectedMissionFile)) {
|
|
868
|
+
initCopyFile(selectedMissionFile, resolve(target, "MISSION.md"), `MISSION: missions/${resolvedMission}.md → MISSION.md`);
|
|
869
|
+
} else {
|
|
870
|
+
const available = existsSync(missionsDir)
|
|
871
|
+
? readdirSync(missionsDir).filter((f) => f.endsWith(".md")).map((f) => f.replace(/\.md$/, ""))
|
|
872
|
+
: [];
|
|
873
|
+
console.error(`\nERROR: Unknown mission "${resolvedMission}".`);
|
|
874
|
+
if (available.length > 0) {
|
|
875
|
+
console.error(`Available missions: ${available.join(", ")}`);
|
|
919
876
|
}
|
|
877
|
+
process.exit(1);
|
|
920
878
|
}
|
|
921
879
|
|
|
922
880
|
// W17: Generate structured acceptance criteria in TOML
|
package/package.json
CHANGED
|
@@ -97,12 +97,16 @@ async function run() {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
// C1: Read persistent state from agentic-lib-state.toml
|
|
100
|
-
|
|
100
|
+
readState("."); // warm up / validate
|
|
101
101
|
|
|
102
102
|
const startTime = Date.now();
|
|
103
103
|
const result = await handler(context);
|
|
104
104
|
const durationMs = Date.now() - startTime;
|
|
105
105
|
|
|
106
|
+
// W3 fix: Re-read state after task — handlers like direct.js may have
|
|
107
|
+
// written mission-complete or other status updates to disk during execution.
|
|
108
|
+
const state = readState(".");
|
|
109
|
+
|
|
106
110
|
// Set outputs
|
|
107
111
|
core.setOutput("result", result.outcome || "completed");
|
|
108
112
|
for (const [key, field] of [["pr-number", "prNumber"], ["tokens-used", "tokensUsed"], ["model", "model"], ["action", "action"], ["action-arg", "actionArg"], ["narrative", "narrative"], ["report-content", "reportContent"]]) {
|