@canivel/ralph 0.2.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/.agents/ralph/PROMPT_build.md +126 -0
- package/.agents/ralph/agents.sh +15 -0
- package/.agents/ralph/config.sh +25 -0
- package/.agents/ralph/log-activity.sh +15 -0
- package/.agents/ralph/loop.sh +1001 -0
- package/.agents/ralph/references/CONTEXT_ENGINEERING.md +126 -0
- package/.agents/ralph/references/GUARDRAILS.md +174 -0
- package/AGENTS.md +20 -0
- package/README.md +266 -0
- package/bin/ralph +766 -0
- package/diagram.svg +55 -0
- package/examples/commands.md +46 -0
- package/package.json +39 -0
- package/ralph.webp +0 -0
- package/skills/commit/SKILL.md +219 -0
- package/skills/commit/references/commit_examples.md +292 -0
- package/skills/dev-browser/SKILL.md +211 -0
- package/skills/dev-browser/bun.lock +443 -0
- package/skills/dev-browser/package-lock.json +2988 -0
- package/skills/dev-browser/package.json +31 -0
- package/skills/dev-browser/references/scraping.md +155 -0
- package/skills/dev-browser/scripts/start-relay.ts +32 -0
- package/skills/dev-browser/scripts/start-server.ts +117 -0
- package/skills/dev-browser/server.sh +24 -0
- package/skills/dev-browser/src/client.ts +474 -0
- package/skills/dev-browser/src/index.ts +287 -0
- package/skills/dev-browser/src/relay.ts +731 -0
- package/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -0
- package/skills/dev-browser/src/snapshot/browser-script.ts +877 -0
- package/skills/dev-browser/src/snapshot/index.ts +14 -0
- package/skills/dev-browser/src/snapshot/inject.ts +13 -0
- package/skills/dev-browser/src/types.ts +34 -0
- package/skills/dev-browser/tsconfig.json +36 -0
- package/skills/dev-browser/vitest.config.ts +12 -0
- package/skills/prd/SKILL.md +235 -0
- package/tests/agent-loops.mjs +79 -0
- package/tests/agent-ping.mjs +39 -0
- package/tests/audit.md +56 -0
- package/tests/cli-smoke.mjs +47 -0
- package/tests/real-agents.mjs +127 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, existsSync, rmSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const cliPath = path.join(repoRoot, "bin", "ralph");
|
|
9
|
+
|
|
10
|
+
function run(cmd, args, options = {}) {
|
|
11
|
+
const result = spawnSync(cmd, args, { stdio: "inherit", ...options });
|
|
12
|
+
if (result.status !== 0) {
|
|
13
|
+
throw new Error(`Command failed: ${cmd} ${args.join(" ")}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function setupTempProject() {
|
|
18
|
+
const base = mkdtempSync(path.join(tmpdir(), "ralph-real-"));
|
|
19
|
+
mkdirSync(path.join(base, ".agents", "tasks"), { recursive: true });
|
|
20
|
+
mkdirSync(path.join(base, ".ralph"), { recursive: true });
|
|
21
|
+
|
|
22
|
+
const prd = {
|
|
23
|
+
version: 1,
|
|
24
|
+
project: "Real Agent Smoke Test",
|
|
25
|
+
qualityGates: [],
|
|
26
|
+
stories: [
|
|
27
|
+
{
|
|
28
|
+
id: "US-001",
|
|
29
|
+
title: "Create baseline file",
|
|
30
|
+
status: "open",
|
|
31
|
+
dependsOn: [],
|
|
32
|
+
description:
|
|
33
|
+
"As a user, I want a baseline file so the repo has an artifact.",
|
|
34
|
+
acceptanceCriteria: [
|
|
35
|
+
"File \"docs/US-001.txt\" exists with the exact text \"US-001 complete\"",
|
|
36
|
+
"Example: open docs/US-001.txt -> \"US-001 complete\"",
|
|
37
|
+
"Negative case: missing file -> failure",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "US-002",
|
|
42
|
+
title: "Add second artifact",
|
|
43
|
+
status: "open",
|
|
44
|
+
dependsOn: ["US-001"],
|
|
45
|
+
description:
|
|
46
|
+
"As a user, I want a second artifact to verify multi-story iteration.",
|
|
47
|
+
acceptanceCriteria: [
|
|
48
|
+
"File \"docs/US-002.txt\" exists with the exact text \"US-002 complete\"",
|
|
49
|
+
"Example: open docs/US-002.txt -> \"US-002 complete\"",
|
|
50
|
+
"Negative case: missing file -> failure",
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
writeFileSync(
|
|
57
|
+
path.join(base, ".agents", "tasks", "prd.json"),
|
|
58
|
+
`${JSON.stringify(prd, null, 2)}\n`,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const agents = `# AGENTS\n\n## Validation\n- For this repo, verify changes with shell checks only.\n- Use commands like: test -f <file>, grep -q \"text\" <file>\n- Do NOT run package manager tests.\n`;
|
|
62
|
+
|
|
63
|
+
writeFileSync(path.join(base, "AGENTS.md"), agents);
|
|
64
|
+
|
|
65
|
+
run("git", ["init"], { cwd: base });
|
|
66
|
+
run("git", ["config", "user.email", "ralph@example.com"], { cwd: base });
|
|
67
|
+
run("git", ["config", "user.name", "ralph"], { cwd: base });
|
|
68
|
+
|
|
69
|
+
return base;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function assertAllStoriesComplete(prdPath) {
|
|
73
|
+
const prd = JSON.parse(readFileSync(prdPath, "utf-8"));
|
|
74
|
+
const stories = Array.isArray(prd.stories) ? prd.stories : [];
|
|
75
|
+
const remaining = stories.filter(
|
|
76
|
+
(story) => String(story.status || "open").toLowerCase() !== "done",
|
|
77
|
+
);
|
|
78
|
+
if (remaining.length > 0) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
`Some stories remain incomplete: ${remaining.map((s) => s.id).join(", ")}`,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function assertCommitted(cwd) {
|
|
86
|
+
const result = spawnSync("git", ["rev-list", "--count", "HEAD"], { cwd, encoding: "utf-8" });
|
|
87
|
+
if (result.status !== 0) {
|
|
88
|
+
throw new Error("Failed to read git history.");
|
|
89
|
+
}
|
|
90
|
+
const count = Number(result.stdout.trim() || "0");
|
|
91
|
+
if (count < 1) {
|
|
92
|
+
throw new Error("Expected at least one commit, found none.");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function runForAgent(agent) {
|
|
97
|
+
console.log(`\n=== Real agent test: ${agent} ===`);
|
|
98
|
+
const projectRoot = setupTempProject();
|
|
99
|
+
const env = { ...process.env };
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
run(process.execPath, [cliPath, "build", "2", `--agent=${agent}`], {
|
|
103
|
+
cwd: projectRoot,
|
|
104
|
+
env,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const prdPath = path.join(projectRoot, ".agents", "tasks", "prd.json");
|
|
108
|
+
assertAllStoriesComplete(prdPath);
|
|
109
|
+
assertCommitted(projectRoot);
|
|
110
|
+
|
|
111
|
+
const progressPath = path.join(projectRoot, ".ralph", "progress.md");
|
|
112
|
+
if (!existsSync(progressPath)) {
|
|
113
|
+
throw new Error("Progress log not created.");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.log(`Agent ${agent} passed.`);
|
|
117
|
+
} finally {
|
|
118
|
+
rmSync(projectRoot, { recursive: true, force: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const agents = ["codex", "claude", "droid"];
|
|
123
|
+
for (const agent of agents) {
|
|
124
|
+
runForAgent(agent);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
console.log("Real agent integration tests passed.");
|