ralph-cli-sandboxed 0.2.3 → 0.2.4
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/commands/run.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
-
import { readFileSync, writeFileSync, unlinkSync } from "fs";
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, unlinkSync } from "fs";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
import { checkFilesExist, loadConfig, loadPrompt, getPaths, getCliConfig, requireContainer } from "../utils/config.js";
|
|
5
5
|
import { resolvePromptVariables } from "../templates/prompts.js";
|
|
@@ -29,6 +29,48 @@ function createFilteredPrd(prdPath, baseDir, category) {
|
|
|
29
29
|
hasIncomplete: filteredItems.length > 0
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Syncs passes flags from prd-tasks.json back to prd.json.
|
|
34
|
+
* If the LLM marked any item as passes: true in prd-tasks.json,
|
|
35
|
+
* find the matching item in prd.json and update it.
|
|
36
|
+
* Returns the number of items synced.
|
|
37
|
+
*/
|
|
38
|
+
function syncPassesFromTasks(tasksPath, prdPath) {
|
|
39
|
+
// Check if tasks file exists
|
|
40
|
+
if (!existsSync(tasksPath)) {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const tasksContent = readFileSync(tasksPath, "utf-8");
|
|
45
|
+
const tasks = JSON.parse(tasksContent);
|
|
46
|
+
const prdContent = readFileSync(prdPath, "utf-8");
|
|
47
|
+
const prd = JSON.parse(prdContent);
|
|
48
|
+
let synced = 0;
|
|
49
|
+
// Find tasks that were marked as passing
|
|
50
|
+
for (const task of tasks) {
|
|
51
|
+
if (task.passes === true) {
|
|
52
|
+
// Find matching item in prd by description
|
|
53
|
+
const match = prd.find(item => item.description === task.description ||
|
|
54
|
+
item.description.includes(task.description) ||
|
|
55
|
+
task.description.includes(item.description));
|
|
56
|
+
if (match && !match.passes) {
|
|
57
|
+
match.passes = true;
|
|
58
|
+
synced++;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Write back if any items were synced
|
|
63
|
+
if (synced > 0) {
|
|
64
|
+
writeFileSync(prdPath, JSON.stringify(prd, null, 2) + "\n");
|
|
65
|
+
console.log(`\x1b[32mSynced ${synced} completed item(s) from prd-tasks.json to prd.json\x1b[0m`);
|
|
66
|
+
}
|
|
67
|
+
return synced;
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Ignore errors - the validation step will handle any issues
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
32
74
|
async function runIteration(prompt, paths, sandboxed, filteredPrdPath, cliConfig, debug, model) {
|
|
33
75
|
return new Promise((resolve, reject) => {
|
|
34
76
|
let output = "";
|
|
@@ -342,6 +384,9 @@ export async function run(args) {
|
|
|
342
384
|
}
|
|
343
385
|
}
|
|
344
386
|
const { exitCode, output } = await runIteration(prompt, paths, sandboxed, filteredPrdPath, cliConfig, debug, model);
|
|
387
|
+
// Sync any completed items from prd-tasks.json back to prd.json
|
|
388
|
+
// This catches cases where the LLM updated prd-tasks.json instead of prd.json
|
|
389
|
+
syncPassesFromTasks(filteredPrdPath, paths.prd);
|
|
345
390
|
// Clean up temp file after each iteration
|
|
346
391
|
try {
|
|
347
392
|
unlinkSync(filteredPrdPath);
|
|
@@ -98,8 +98,8 @@
|
|
|
98
98
|
"description": "Sourcegraph's AMP coding agent",
|
|
99
99
|
"command": "amp",
|
|
100
100
|
"defaultArgs": [],
|
|
101
|
-
"yoloArgs": ["--
|
|
102
|
-
"promptArgs": [],
|
|
101
|
+
"yoloArgs": ["--dangerously-allow-all"],
|
|
102
|
+
"promptArgs": ["-x"],
|
|
103
103
|
"docker": {
|
|
104
104
|
"install": "# Install AMP CLI (as node user)\nRUN su - node -c 'curl -fsSL https://ampcode.com/install.sh | bash' \\\n && echo 'export PATH=\"$HOME/.amp/bin:$PATH\"' >> /home/node/.zshrc",
|
|
105
105
|
"note": "Check 'amp --help' for available flags"
|