@canivel/ralph 0.2.0 → 0.2.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/.agents/ralph/PROMPT_build.md +126 -126
- package/.agents/ralph/agents.sh +17 -15
- package/.agents/ralph/config.sh +25 -25
- package/.agents/ralph/log-activity.sh +15 -15
- package/.agents/ralph/loop.sh +1027 -1001
- package/.agents/ralph/references/CONTEXT_ENGINEERING.md +126 -126
- package/.agents/ralph/references/GUARDRAILS.md +174 -174
- package/AGENTS.md +20 -20
- package/README.md +270 -266
- package/bin/ralph +766 -765
- package/diagram.svg +55 -55
- package/examples/commands.md +46 -46
- package/package.json +39 -39
- package/skills/commit/SKILL.md +219 -219
- package/skills/commit/references/commit_examples.md +292 -292
- package/skills/dev-browser/SKILL.md +211 -211
- package/skills/dev-browser/bun.lock +443 -443
- package/skills/dev-browser/package-lock.json +2988 -2988
- package/skills/dev-browser/package.json +31 -31
- package/skills/dev-browser/references/scraping.md +155 -155
- package/skills/dev-browser/scripts/start-relay.ts +32 -32
- package/skills/dev-browser/scripts/start-server.ts +117 -117
- package/skills/dev-browser/server.sh +24 -24
- package/skills/dev-browser/src/client.ts +474 -474
- package/skills/dev-browser/src/index.ts +287 -287
- package/skills/dev-browser/src/relay.ts +731 -731
- package/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -223
- package/skills/dev-browser/src/snapshot/browser-script.ts +877 -877
- package/skills/dev-browser/src/snapshot/index.ts +14 -14
- package/skills/dev-browser/src/snapshot/inject.ts +13 -13
- package/skills/dev-browser/src/types.ts +34 -34
- package/skills/dev-browser/tsconfig.json +36 -36
- package/skills/dev-browser/vitest.config.ts +12 -12
- package/skills/prd/SKILL.md +235 -235
- package/tests/agent-loops.mjs +79 -79
- package/tests/agent-ping.mjs +39 -39
- package/tests/audit.md +56 -56
- package/tests/cli-smoke.mjs +47 -47
- package/tests/real-agents.mjs +127 -127
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
import { serve } from "@/index.js";
|
|
2
|
-
import { execSync } from "child_process";
|
|
3
|
-
import { mkdirSync, existsSync, readdirSync } from "fs";
|
|
4
|
-
import { join, dirname } from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
|
|
7
|
-
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const tmpDir = join(__dirname, "..", "tmp");
|
|
9
|
-
const profileDir = join(__dirname, "..", "profiles");
|
|
10
|
-
|
|
11
|
-
// Create tmp and profile directories if they don't exist
|
|
12
|
-
console.log("Creating tmp directory...");
|
|
13
|
-
mkdirSync(tmpDir, { recursive: true });
|
|
14
|
-
console.log("Creating profiles directory...");
|
|
15
|
-
mkdirSync(profileDir, { recursive: true });
|
|
16
|
-
|
|
17
|
-
// Install Playwright browsers if not already installed
|
|
18
|
-
console.log("Checking Playwright browser installation...");
|
|
19
|
-
|
|
20
|
-
function findPackageManager(): { name: string; command: string } | null {
|
|
21
|
-
const managers = [
|
|
22
|
-
{ name: "bun", command: "bunx playwright install chromium" },
|
|
23
|
-
{ name: "pnpm", command: "pnpm exec playwright install chromium" },
|
|
24
|
-
{ name: "npm", command: "npx playwright install chromium" },
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
for (const manager of managers) {
|
|
28
|
-
try {
|
|
29
|
-
execSync(`which ${manager.name}`, { stdio: "ignore" });
|
|
30
|
-
return manager;
|
|
31
|
-
} catch {
|
|
32
|
-
// Package manager not found, try next
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function isChromiumInstalled(): boolean {
|
|
39
|
-
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
40
|
-
const playwrightCacheDir = join(homeDir, ".cache", "ms-playwright");
|
|
41
|
-
|
|
42
|
-
if (!existsSync(playwrightCacheDir)) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Check for chromium directories (e.g., chromium-1148, chromium_headless_shell-1148)
|
|
47
|
-
try {
|
|
48
|
-
const entries = readdirSync(playwrightCacheDir);
|
|
49
|
-
return entries.some((entry) => entry.startsWith("chromium"));
|
|
50
|
-
} catch {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
try {
|
|
56
|
-
if (!isChromiumInstalled()) {
|
|
57
|
-
console.log("Playwright Chromium not found. Installing (this may take a minute)...");
|
|
58
|
-
|
|
59
|
-
const pm = findPackageManager();
|
|
60
|
-
if (!pm) {
|
|
61
|
-
throw new Error("No package manager found (tried bun, pnpm, npm)");
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
console.log(`Using ${pm.name} to install Playwright...`);
|
|
65
|
-
execSync(pm.command, { stdio: "inherit" });
|
|
66
|
-
console.log("Chromium installed successfully.");
|
|
67
|
-
} else {
|
|
68
|
-
console.log("Playwright Chromium already installed.");
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
console.error("Failed to install Playwright browsers:", error);
|
|
72
|
-
console.log("You may need to run: npx playwright install chromium");
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Check if server is already running
|
|
76
|
-
console.log("Checking for existing servers...");
|
|
77
|
-
try {
|
|
78
|
-
const res = await fetch("http://localhost:9222", {
|
|
79
|
-
signal: AbortSignal.timeout(1000),
|
|
80
|
-
});
|
|
81
|
-
if (res.ok) {
|
|
82
|
-
console.log("Server already running on port 9222");
|
|
83
|
-
process.exit(0);
|
|
84
|
-
}
|
|
85
|
-
} catch {
|
|
86
|
-
// Server not running, continue to start
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Clean up stale CDP port if HTTP server isn't running (crash recovery)
|
|
90
|
-
// This handles the case where Node crashed but Chrome is still running on 9223
|
|
91
|
-
try {
|
|
92
|
-
const pid = execSync("lsof -ti:9223", { encoding: "utf-8" }).trim();
|
|
93
|
-
if (pid) {
|
|
94
|
-
console.log(`Cleaning up stale Chrome process on CDP port 9223 (PID: ${pid})`);
|
|
95
|
-
execSync(`kill -9 ${pid}`);
|
|
96
|
-
}
|
|
97
|
-
} catch {
|
|
98
|
-
// No process on CDP port, which is expected
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
console.log("Starting dev browser server...");
|
|
102
|
-
const headless = process.env.HEADLESS === "true";
|
|
103
|
-
const server = await serve({
|
|
104
|
-
port: 9222,
|
|
105
|
-
headless,
|
|
106
|
-
profileDir,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
console.log(`Dev browser server started`);
|
|
110
|
-
console.log(` WebSocket: ${server.wsEndpoint}`);
|
|
111
|
-
console.log(` Tmp directory: ${tmpDir}`);
|
|
112
|
-
console.log(` Profile directory: ${profileDir}`);
|
|
113
|
-
console.log(`\nReady`);
|
|
114
|
-
console.log(`\nPress Ctrl+C to stop`);
|
|
115
|
-
|
|
116
|
-
// Keep the process running
|
|
117
|
-
await new Promise(() => {});
|
|
1
|
+
import { serve } from "@/index.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
import { mkdirSync, existsSync, readdirSync } from "fs";
|
|
4
|
+
import { join, dirname } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const tmpDir = join(__dirname, "..", "tmp");
|
|
9
|
+
const profileDir = join(__dirname, "..", "profiles");
|
|
10
|
+
|
|
11
|
+
// Create tmp and profile directories if they don't exist
|
|
12
|
+
console.log("Creating tmp directory...");
|
|
13
|
+
mkdirSync(tmpDir, { recursive: true });
|
|
14
|
+
console.log("Creating profiles directory...");
|
|
15
|
+
mkdirSync(profileDir, { recursive: true });
|
|
16
|
+
|
|
17
|
+
// Install Playwright browsers if not already installed
|
|
18
|
+
console.log("Checking Playwright browser installation...");
|
|
19
|
+
|
|
20
|
+
function findPackageManager(): { name: string; command: string } | null {
|
|
21
|
+
const managers = [
|
|
22
|
+
{ name: "bun", command: "bunx playwright install chromium" },
|
|
23
|
+
{ name: "pnpm", command: "pnpm exec playwright install chromium" },
|
|
24
|
+
{ name: "npm", command: "npx playwright install chromium" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
for (const manager of managers) {
|
|
28
|
+
try {
|
|
29
|
+
execSync(`which ${manager.name}`, { stdio: "ignore" });
|
|
30
|
+
return manager;
|
|
31
|
+
} catch {
|
|
32
|
+
// Package manager not found, try next
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isChromiumInstalled(): boolean {
|
|
39
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || "";
|
|
40
|
+
const playwrightCacheDir = join(homeDir, ".cache", "ms-playwright");
|
|
41
|
+
|
|
42
|
+
if (!existsSync(playwrightCacheDir)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check for chromium directories (e.g., chromium-1148, chromium_headless_shell-1148)
|
|
47
|
+
try {
|
|
48
|
+
const entries = readdirSync(playwrightCacheDir);
|
|
49
|
+
return entries.some((entry) => entry.startsWith("chromium"));
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
if (!isChromiumInstalled()) {
|
|
57
|
+
console.log("Playwright Chromium not found. Installing (this may take a minute)...");
|
|
58
|
+
|
|
59
|
+
const pm = findPackageManager();
|
|
60
|
+
if (!pm) {
|
|
61
|
+
throw new Error("No package manager found (tried bun, pnpm, npm)");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log(`Using ${pm.name} to install Playwright...`);
|
|
65
|
+
execSync(pm.command, { stdio: "inherit" });
|
|
66
|
+
console.log("Chromium installed successfully.");
|
|
67
|
+
} else {
|
|
68
|
+
console.log("Playwright Chromium already installed.");
|
|
69
|
+
}
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error("Failed to install Playwright browsers:", error);
|
|
72
|
+
console.log("You may need to run: npx playwright install chromium");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Check if server is already running
|
|
76
|
+
console.log("Checking for existing servers...");
|
|
77
|
+
try {
|
|
78
|
+
const res = await fetch("http://localhost:9222", {
|
|
79
|
+
signal: AbortSignal.timeout(1000),
|
|
80
|
+
});
|
|
81
|
+
if (res.ok) {
|
|
82
|
+
console.log("Server already running on port 9222");
|
|
83
|
+
process.exit(0);
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
// Server not running, continue to start
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Clean up stale CDP port if HTTP server isn't running (crash recovery)
|
|
90
|
+
// This handles the case where Node crashed but Chrome is still running on 9223
|
|
91
|
+
try {
|
|
92
|
+
const pid = execSync("lsof -ti:9223", { encoding: "utf-8" }).trim();
|
|
93
|
+
if (pid) {
|
|
94
|
+
console.log(`Cleaning up stale Chrome process on CDP port 9223 (PID: ${pid})`);
|
|
95
|
+
execSync(`kill -9 ${pid}`);
|
|
96
|
+
}
|
|
97
|
+
} catch {
|
|
98
|
+
// No process on CDP port, which is expected
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log("Starting dev browser server...");
|
|
102
|
+
const headless = process.env.HEADLESS === "true";
|
|
103
|
+
const server = await serve({
|
|
104
|
+
port: 9222,
|
|
105
|
+
headless,
|
|
106
|
+
profileDir,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
console.log(`Dev browser server started`);
|
|
110
|
+
console.log(` WebSocket: ${server.wsEndpoint}`);
|
|
111
|
+
console.log(` Tmp directory: ${tmpDir}`);
|
|
112
|
+
console.log(` Profile directory: ${profileDir}`);
|
|
113
|
+
console.log(`\nReady`);
|
|
114
|
+
console.log(`\nPress Ctrl+C to stop`);
|
|
115
|
+
|
|
116
|
+
// Keep the process running
|
|
117
|
+
await new Promise(() => {});
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Get the directory where this script is located
|
|
4
|
-
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
5
|
-
|
|
6
|
-
# Change to the script directory
|
|
7
|
-
cd "$SCRIPT_DIR"
|
|
8
|
-
|
|
9
|
-
# Parse command line arguments
|
|
10
|
-
HEADLESS=false
|
|
11
|
-
while [[ "$#" -gt 0 ]]; do
|
|
12
|
-
case $1 in
|
|
13
|
-
--headless) HEADLESS=true ;;
|
|
14
|
-
*) echo "Unknown parameter: $1"; exit 1 ;;
|
|
15
|
-
esac
|
|
16
|
-
shift
|
|
17
|
-
done
|
|
18
|
-
|
|
19
|
-
echo "Installing dependencies..."
|
|
20
|
-
npm install
|
|
21
|
-
|
|
22
|
-
echo "Starting dev-browser server..."
|
|
23
|
-
export HEADLESS=$HEADLESS
|
|
24
|
-
npx tsx scripts/start-server.ts
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Get the directory where this script is located
|
|
4
|
+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
5
|
+
|
|
6
|
+
# Change to the script directory
|
|
7
|
+
cd "$SCRIPT_DIR"
|
|
8
|
+
|
|
9
|
+
# Parse command line arguments
|
|
10
|
+
HEADLESS=false
|
|
11
|
+
while [[ "$#" -gt 0 ]]; do
|
|
12
|
+
case $1 in
|
|
13
|
+
--headless) HEADLESS=true ;;
|
|
14
|
+
*) echo "Unknown parameter: $1"; exit 1 ;;
|
|
15
|
+
esac
|
|
16
|
+
shift
|
|
17
|
+
done
|
|
18
|
+
|
|
19
|
+
echo "Installing dependencies..."
|
|
20
|
+
npm install
|
|
21
|
+
|
|
22
|
+
echo "Starting dev-browser server..."
|
|
23
|
+
export HEADLESS=$HEADLESS
|
|
24
|
+
npx tsx scripts/start-server.ts
|