@kody-ade/kody-engine-lite 0.1.1 → 0.1.3
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/bin/cli.js +38 -11
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -267,16 +267,17 @@ var init_config = __esm({
|
|
|
267
267
|
import * as fs3 from "fs";
|
|
268
268
|
import * as path3 from "path";
|
|
269
269
|
function readPromptFile(stageName) {
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
"..",
|
|
273
|
-
"prompts",
|
|
274
|
-
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
|
|
270
|
+
const scriptDir = new URL(".", import.meta.url).pathname;
|
|
271
|
+
const candidates = [
|
|
272
|
+
path3.resolve(scriptDir, "..", "prompts", `${stageName}.md`),
|
|
273
|
+
path3.resolve(scriptDir, "..", "..", "prompts", `${stageName}.md`)
|
|
274
|
+
];
|
|
275
|
+
for (const candidate of candidates) {
|
|
276
|
+
if (fs3.existsSync(candidate)) {
|
|
277
|
+
return fs3.readFileSync(candidate, "utf-8");
|
|
278
|
+
}
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
+
throw new Error(`Prompt file not found: tried ${candidates.join(", ")}`);
|
|
280
281
|
}
|
|
281
282
|
function injectTaskContext(prompt, taskId, taskDir) {
|
|
282
283
|
let context = `## Task Context
|
|
@@ -575,6 +576,21 @@ function gh(args2, options) {
|
|
|
575
576
|
stdio: options?.input ? ["pipe", "pipe", "pipe"] : ["inherit", "pipe", "pipe"]
|
|
576
577
|
}).trim();
|
|
577
578
|
}
|
|
579
|
+
function getIssue(issueNumber) {
|
|
580
|
+
try {
|
|
581
|
+
const output = gh([
|
|
582
|
+
"issue",
|
|
583
|
+
"view",
|
|
584
|
+
String(issueNumber),
|
|
585
|
+
"--json",
|
|
586
|
+
"body,title"
|
|
587
|
+
]);
|
|
588
|
+
return JSON.parse(output);
|
|
589
|
+
} catch (err) {
|
|
590
|
+
logger.error(` Failed to get issue #${issueNumber}: ${err}`);
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
578
594
|
function setLabel(issueNumber, label) {
|
|
579
595
|
try {
|
|
580
596
|
gh(["issue", "edit", String(issueNumber), "--add-label", label]);
|
|
@@ -1411,10 +1427,21 @@ async function main() {
|
|
|
1411
1427
|
if (input.task) {
|
|
1412
1428
|
fs6.writeFileSync(path5.join(taskDir, "task.md"), input.task);
|
|
1413
1429
|
}
|
|
1430
|
+
const taskMdPath = path5.join(taskDir, "task.md");
|
|
1431
|
+
if (!fs6.existsSync(taskMdPath) && input.issueNumber) {
|
|
1432
|
+
logger.info(`Fetching issue #${input.issueNumber} body as task...`);
|
|
1433
|
+
const issue = getIssue(input.issueNumber);
|
|
1434
|
+
if (issue) {
|
|
1435
|
+
const taskContent = `# ${issue.title}
|
|
1436
|
+
|
|
1437
|
+
${issue.body ?? ""}`;
|
|
1438
|
+
fs6.writeFileSync(taskMdPath, taskContent);
|
|
1439
|
+
logger.info(` Task loaded from issue #${input.issueNumber}: ${issue.title}`);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1414
1442
|
if (input.command === "run") {
|
|
1415
|
-
const taskMdPath = path5.join(taskDir, "task.md");
|
|
1416
1443
|
if (!fs6.existsSync(taskMdPath)) {
|
|
1417
|
-
console.error("No task.md found. Provide --task or ensure .tasks/<id>/task.md exists.");
|
|
1444
|
+
console.error("No task.md found. Provide --task, --issue-number, or ensure .tasks/<id>/task.md exists.");
|
|
1418
1445
|
process.exit(1);
|
|
1419
1446
|
}
|
|
1420
1447
|
}
|