@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.
Files changed (40) hide show
  1. package/.agents/ralph/PROMPT_build.md +126 -0
  2. package/.agents/ralph/agents.sh +15 -0
  3. package/.agents/ralph/config.sh +25 -0
  4. package/.agents/ralph/log-activity.sh +15 -0
  5. package/.agents/ralph/loop.sh +1001 -0
  6. package/.agents/ralph/references/CONTEXT_ENGINEERING.md +126 -0
  7. package/.agents/ralph/references/GUARDRAILS.md +174 -0
  8. package/AGENTS.md +20 -0
  9. package/README.md +266 -0
  10. package/bin/ralph +766 -0
  11. package/diagram.svg +55 -0
  12. package/examples/commands.md +46 -0
  13. package/package.json +39 -0
  14. package/ralph.webp +0 -0
  15. package/skills/commit/SKILL.md +219 -0
  16. package/skills/commit/references/commit_examples.md +292 -0
  17. package/skills/dev-browser/SKILL.md +211 -0
  18. package/skills/dev-browser/bun.lock +443 -0
  19. package/skills/dev-browser/package-lock.json +2988 -0
  20. package/skills/dev-browser/package.json +31 -0
  21. package/skills/dev-browser/references/scraping.md +155 -0
  22. package/skills/dev-browser/scripts/start-relay.ts +32 -0
  23. package/skills/dev-browser/scripts/start-server.ts +117 -0
  24. package/skills/dev-browser/server.sh +24 -0
  25. package/skills/dev-browser/src/client.ts +474 -0
  26. package/skills/dev-browser/src/index.ts +287 -0
  27. package/skills/dev-browser/src/relay.ts +731 -0
  28. package/skills/dev-browser/src/snapshot/__tests__/snapshot.test.ts +223 -0
  29. package/skills/dev-browser/src/snapshot/browser-script.ts +877 -0
  30. package/skills/dev-browser/src/snapshot/index.ts +14 -0
  31. package/skills/dev-browser/src/snapshot/inject.ts +13 -0
  32. package/skills/dev-browser/src/types.ts +34 -0
  33. package/skills/dev-browser/tsconfig.json +36 -0
  34. package/skills/dev-browser/vitest.config.ts +12 -0
  35. package/skills/prd/SKILL.md +235 -0
  36. package/tests/agent-loops.mjs +79 -0
  37. package/tests/agent-ping.mjs +39 -0
  38. package/tests/audit.md +56 -0
  39. package/tests/cli-smoke.mjs +47 -0
  40. package/tests/real-agents.mjs +127 -0
@@ -0,0 +1,126 @@
1
+ # Build
2
+
3
+ You are an autonomous coding agent. Your task is to complete the work for exactly one story and record the outcome.
4
+
5
+ ## Paths
6
+ - PRD: {{PRD_PATH}}
7
+ - AGENTS (optional): {{AGENTS_PATH}}
8
+ - Progress Log: {{PROGRESS_PATH}}
9
+ - Guardrails: {{GUARDRAILS_PATH}}
10
+ - Guardrails Reference: {{GUARDRAILS_REF}}
11
+ - Context Reference: {{CONTEXT_REF}}
12
+ - Errors Log: {{ERRORS_LOG_PATH}}
13
+ - Activity Log: {{ACTIVITY_LOG_PATH}}
14
+ - Activity Logger: {{ACTIVITY_CMD}}
15
+ - No-commit: {{NO_COMMIT}}
16
+ - Repo Root: {{REPO_ROOT}}
17
+ - Run ID: {{RUN_ID}}
18
+ - Iteration: {{ITERATION}}
19
+ - Run Log: {{RUN_LOG_PATH}}
20
+ - Run Summary: {{RUN_META_PATH}}
21
+
22
+ ## Global Quality Gates (apply to every story)
23
+ {{QUALITY_GATES}}
24
+
25
+ ## Selected Story (Do not change scope)
26
+ ID: {{STORY_ID}}
27
+ Title: {{STORY_TITLE}}
28
+
29
+ Story details:
30
+ {{STORY_BLOCK}}
31
+
32
+ If the story details are empty or missing, STOP and report that the PRD story format could not be parsed.
33
+
34
+ ## Rules (Non-Negotiable)
35
+ - Implement **only** the work required to complete the selected story.
36
+ - Complete all tasks associated with this story (and only this story).
37
+ - Do NOT ask the user questions.
38
+ - Do NOT change unrelated code.
39
+ - Do NOT assume something is unimplemented — confirm by reading code.
40
+ - Implement completely; no placeholders or stubs.
41
+ - If No-commit is true, do NOT commit or push changes.
42
+ - Do NOT edit the PRD JSON (status is handled by the loop).
43
+ - All changes made during the run must be committed (including updates to progress/logs).
44
+ - Before committing, perform a final **security**, **performance**, and **regression** review of your changes.
45
+
46
+ ## Your Task (Do this in order)
47
+ 1. Read {{GUARDRAILS_PATH}} before any code changes.
48
+ 2. Read {{ERRORS_LOG_PATH}} for repeated failures to avoid.
49
+ 3. Read {{PRD_PATH}} for global context (do not edit).
50
+ 4. Fully audit and read all necessary files to understand the task end-to-end before implementing. Do not assume missing functionality.
51
+ 5. If {{AGENTS_PATH}} exists, follow its build/test instructions.
52
+ 6. Implement only the tasks that belong to {{STORY_ID}}.
53
+ 7. Run verification commands listed in the story, the global quality gates, and in {{AGENTS_PATH}} (if required).
54
+ 8. If the project has a build or dev workflow, run what applies:
55
+ - Build step (e.g., `npm run build`) if defined.
56
+ - Dev server (e.g., `npm run dev`, `wrangler dev`) if it is the normal validation path.
57
+ - Confirm no runtime/build errors in the console.
58
+ 9. Perform a brief audit before committing:
59
+ - **Security:** check for obvious vulnerabilities or unsafe handling introduced by your changes.
60
+ - **Performance:** check for avoidable regressions (extra queries, heavy loops, unnecessary re-renders).
61
+ - **Regression:** verify existing behavior that could be impacted still works.
62
+ 10. If No-commit is false, commit changes using the `$commit` skill.
63
+ - Stage everything: `git add -A`
64
+ - Confirm a clean working tree after commit: `git status --porcelain` should be empty.
65
+ - After committing, capture the commit hash and subject using:
66
+ `git show -s --format="%h %s" HEAD`.
67
+ 11. Append a progress entry to {{PROGRESS_PATH}} with run/commit/test details (format below).
68
+ If No-commit is true, skip committing and note it in the progress entry.
69
+
70
+ ## Progress Entry Format (Append Only)
71
+ ```
72
+ ## [Date/Time] - {{STORY_ID}}: {{STORY_TITLE}}
73
+ Thread: [codex exec session id if available, otherwise leave blank]
74
+ Run: {{RUN_ID}} (iteration {{ITERATION}})
75
+ Run log: {{RUN_LOG_PATH}}
76
+ Run summary: {{RUN_META_PATH}}
77
+ - Guardrails reviewed: yes
78
+ - No-commit run: {{NO_COMMIT}}
79
+ - Commit: <hash> <subject> (or `none` + reason)
80
+ - Post-commit status: `clean` or list remaining files
81
+ - Verification:
82
+ - Command: <exact command> -> PASS/FAIL
83
+ - Command: <exact command> -> PASS/FAIL
84
+ - Files changed:
85
+ - <file path>
86
+ - <file path>
87
+ - What was implemented
88
+ - **Learnings for future iterations:**
89
+ - Patterns discovered
90
+ - Gotchas encountered
91
+ - Useful context
92
+ ---
93
+ ```
94
+
95
+ ## Completion Signal
96
+ Only output the completion signal when the **selected story** is fully complete and verified.
97
+ When the selected story is complete, output:
98
+ <promise>COMPLETE</promise>
99
+
100
+ Otherwise, end normally without the signal.
101
+
102
+ ## Additional Guardrails
103
+ - When authoring documentation, capture the why (tests + implementation intent).
104
+ - If you learn how to run/build/test the project, update {{AGENTS_PATH}} briefly (operational only).
105
+ - Keep AGENTS operational only; progress notes belong in {{PROGRESS_PATH}}.
106
+ - If you hit repeated errors, log them in {{ERRORS_LOG_PATH}} and add a Sign to {{GUARDRAILS_PATH}} using {{GUARDRAILS_REF}} as the template.
107
+
108
+ ## Activity Logging (Required)
109
+ Log major actions to {{ACTIVITY_LOG_PATH}} using the helper:
110
+ ```
111
+ {{ACTIVITY_CMD}} "message"
112
+ ```
113
+ Log at least:
114
+ - Start of work on the story
115
+ - After major code changes
116
+ - After tests/verification
117
+ - After updating progress log
118
+
119
+ ## Browser Testing (Required for Frontend Stories)
120
+ If the selected story changes UI, you MUST verify it in the browser:
121
+ 1. Load the `dev-browser` skill.
122
+ 2. Navigate to the relevant page.
123
+ 3. Verify the UI changes work as expected.
124
+ 4. Take a screenshot if helpful for the progress log.
125
+
126
+ A frontend story is NOT complete until browser verification passes.
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env bash
2
+ # Default agent command templates (used by loop.sh and CLI).
3
+
4
+ AGENT_CODEX_CMD="codex exec --yolo --skip-git-repo-check -"
5
+ AGENT_CODEX_INTERACTIVE_CMD="codex --yolo {prompt}"
6
+ AGENT_CLAUDE_CMD="claude -p --dangerously-skip-permissions \"\$(cat {prompt})\""
7
+ AGENT_CLAUDE_INTERACTIVE_CMD="claude --dangerously-skip-permissions {prompt}"
8
+ AGENT_DROID_CMD="droid exec --skip-permissions-unsafe -f {prompt}"
9
+ AGENT_DROID_INTERACTIVE_CMD="droid --skip-permissions-unsafe {prompt}"
10
+ AGENT_OPENCODE_CMD="opencode run \"\$(cat {prompt})\""
11
+ AGENT_OPENCODE_INTERACTIVE_CMD="opencode --prompt {prompt}"
12
+ # Uncomment to use server mode (faster, avoids cold boot):
13
+ # AGENT_OPENCODE_CMD="opencode run --attach http://localhost:4096 \"\$(cat {prompt})\""
14
+ # AGENT_OPENCODE_INTERACTIVE_CMD="opencode --prompt {prompt} --attach http://localhost:4096"
15
+ DEFAULT_AGENT="${DEFAULT_AGENT:-codex}"
@@ -0,0 +1,25 @@
1
+ # Optional Ralph config overrides.
2
+ # All paths are relative to repo root unless absolute.
3
+ # Uncomment and edit as needed.
4
+
5
+ # PRD_PATH=".agents/tasks/prd.json"
6
+ # PROGRESS_PATH=".ralph/progress.md"
7
+ # GUARDRAILS_PATH=".ralph/guardrails.md"
8
+ # ERRORS_LOG_PATH=".ralph/errors.log"
9
+ # ACTIVITY_LOG_PATH=".ralph/activity.log"
10
+ # TMP_DIR=".ralph/.tmp"
11
+ # RUNS_DIR=".ralph/runs"
12
+ # GUARDRAILS_REF=".agents/ralph/references/GUARDRAILS.md"
13
+ # CONTEXT_REF=".agents/ralph/references/CONTEXT_ENGINEERING.md"
14
+ # ACTIVITY_CMD=".agents/ralph/log-activity.sh"
15
+ # AGENT_CMD defaults are defined in agents.sh. Override here if needed.
16
+ # AGENT_CMD="codex exec --yolo --skip-git-repo-check -"
17
+ # PRD_AGENT_CMD defaults are defined in agents.sh (interactive).
18
+ # PRD_AGENT_CMD="codex --yolo --skip-git-repo-check {prompt}"
19
+ # AGENT_CMD="claude -p --dangerously-skip-permissions \"\$(cat {prompt})\""
20
+ # AGENT_CMD="droid exec --skip-permissions-unsafe -f {prompt}"
21
+ # AGENTS_PATH="AGENTS.md"
22
+ # PROMPT_BUILD=".agents/ralph/PROMPT_build.md"
23
+ # NO_COMMIT=false
24
+ # MAX_ITERATIONS=25
25
+ # STALE_SECONDS=0
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ ROOT_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"
6
+ ACTIVITY_LOG="$ROOT_DIR/.ralph/activity.log"
7
+
8
+ if [ $# -lt 1 ]; then
9
+ echo "Usage: $0 \"message\""
10
+ exit 1
11
+ fi
12
+
13
+ mkdir -p "$(dirname "$ACTIVITY_LOG")"
14
+ TS=$(date '+%Y-%m-%d %H:%M:%S')
15
+ echo "[$TS] $*" >> "$ACTIVITY_LOG"