@pasko70/pibo 1.9.13 → 1.10.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 (139) hide show
  1. package/README.md +183 -183
  2. package/context/codex-base-prompt.md +148 -148
  3. package/context/compute-worker.md +23 -23
  4. package/context/pibo-compaction-prompt.md +100 -100
  5. package/context/pibo-native-tooling.md +18 -18
  6. package/context/pibo-system-prompt.md +77 -77
  7. package/dist/apps/chat/agent-profiles.js +2 -2
  8. package/dist/apps/chat/agent-store.js +263 -250
  9. package/dist/apps/chat/chat-request-normalizers.js +10 -0
  10. package/dist/apps/chat/data/project-service.js +168 -168
  11. package/dist/apps/chat/data/read-state-service.js +18 -18
  12. package/dist/apps/chat/data/session-query-service.js +25 -25
  13. package/dist/apps/chat/data/timeline-query-service.js +19 -19
  14. package/dist/apps/chat/loop-api.js +176 -0
  15. package/dist/apps/chat/static-assets.js +854 -854
  16. package/dist/apps/chat/web-app.js +6 -6
  17. package/dist/apps/chat/workflow-manual-trigger-runtime.js +149 -46
  18. package/dist/apps/chat/workflow-persistence.js +255 -255
  19. package/dist/apps/chat-ui/assets/{dist-yCYNNb5d.js → dist-BwKObYnX.js} +1 -1
  20. package/dist/apps/chat-ui/assets/{dist-BCB6zezO.js → dist-CKtT8YGm.js} +1 -1
  21. package/dist/apps/chat-ui/assets/{dist-CnVsqwSG.js → dist-CS7wdk0Z.js} +1 -1
  22. package/dist/apps/chat-ui/assets/{dist-HqTN67dc.js → dist-D-cxLQO1.js} +1 -1
  23. package/dist/apps/chat-ui/assets/{dist-BNMu92bb.js → dist-DUlaXAk7.js} +1 -1
  24. package/dist/apps/chat-ui/assets/{dist-CzE6k3F3.js → dist-DlATLa-U.js} +1 -1
  25. package/dist/apps/chat-ui/assets/{dist-Dq4GxJi3.js → dist-GdEM8UW1.js} +1 -1
  26. package/dist/apps/chat-ui/assets/{dist-BZ2eTC4f.js → dist-LHRs1Nhr.js} +1 -1
  27. package/dist/apps/chat-ui/assets/{dist-D811wJeV.js → dist-Y-AA2omI.js} +1 -1
  28. package/dist/apps/chat-ui/assets/{dist-WyXdYl-w.js → dist-nOLTkZrJ.js} +1 -1
  29. package/dist/apps/chat-ui/assets/{dist-BHa-kcGl.js → dist-wE9nop9V.js} +1 -1
  30. package/dist/apps/chat-ui/assets/{index-DwHJfmiF.js → index-8W_yMHQI.js} +6 -6
  31. package/dist/apps/chat-ui/index.html +17 -17
  32. package/dist/apps/chat-ui/manifest.webmanifest +25 -25
  33. package/dist/apps/chat-ui/sw.js +47 -47
  34. package/dist/apps/chat-vscode-web/index.html +12 -12
  35. package/dist/apps/cli-ui/cliSessionsCommand.js +23 -23
  36. package/dist/apps/context-files-ui/index.html +11 -11
  37. package/dist/cli.js +61 -44
  38. package/dist/compute/cli.js +54 -54
  39. package/dist/core/routed-session.js +30 -1
  40. package/dist/core/runtime.js +6 -1
  41. package/dist/core/session-router.js +4 -2
  42. package/dist/cron/cli.js +15 -15
  43. package/dist/cron/store.js +49 -49
  44. package/dist/data/cli.js +23 -23
  45. package/dist/data/event-log.js +23 -23
  46. package/dist/data/message-store.js +27 -27
  47. package/dist/data/navigation-store.js +9 -9
  48. package/dist/data/observation-store.js +4 -4
  49. package/dist/data/payload-store.js +17 -17
  50. package/dist/data/schema.js +433 -433
  51. package/dist/data/session-store.js +4 -4
  52. package/dist/data/telemetry-queries.js +54 -54
  53. package/dist/data/telemetry.js +197 -197
  54. package/dist/debug/events.js +12 -12
  55. package/dist/debug/failures.js +6 -6
  56. package/dist/debug/index.js +227 -227
  57. package/dist/debug/messages.js +6 -6
  58. package/dist/debug/pty.js +124 -124
  59. package/dist/debug/session.js +29 -29
  60. package/dist/debug/tools.js +5 -5
  61. package/dist/debug/web-snapshot-browser-scripts.js +294 -294
  62. package/dist/debug/web-streaming-browser-library.js +925 -925
  63. package/dist/debug/web-streaming-browser-scripts.js +232 -232
  64. package/dist/debug/web-streaming-provider-telemetry.js +4 -4
  65. package/dist/debug/web.js +93 -93
  66. package/dist/gateway/cli.js +19 -19
  67. package/dist/gateway/server.js +4 -2
  68. package/dist/gateway/web.js +2 -2
  69. package/dist/loops/channel.js +8 -0
  70. package/dist/loops/cli.js +208 -0
  71. package/dist/loops/plugin.js +16 -0
  72. package/dist/loops/prompts.js +83 -0
  73. package/dist/loops/service.js +357 -0
  74. package/dist/loops/stopping.js +170 -0
  75. package/dist/loops/store.js +531 -0
  76. package/dist/loops/templates.js +232 -0
  77. package/dist/loops/tools.js +167 -0
  78. package/dist/loops/types.js +1 -0
  79. package/dist/mcp/config-command.js +53 -53
  80. package/dist/mcp/index.js +21 -21
  81. package/dist/mcp/registry.js +11 -11
  82. package/dist/pi-packages/cli.js +11 -11
  83. package/dist/plugins/builtin.js +8 -0
  84. package/dist/plugins/context-files-store.js +110 -110
  85. package/dist/plugins/context-files.js +4 -4
  86. package/dist/plugins/registry.js +23 -12
  87. package/dist/ralph/cli.js +18 -18
  88. package/dist/ralph/templates.js +140 -140
  89. package/dist/reliability/store.js +226 -226
  90. package/dist/sessions/pibo-data-store.js +16 -16
  91. package/dist/sessions/sqlite-store.js +53 -53
  92. package/dist/setup/cli.js +58 -58
  93. package/dist/tools/agent-browser-wrapper.js +80 -80
  94. package/dist/tools/browser-use-cdp.js +12 -12
  95. package/dist/tools/browser-use-wrapper.js +762 -762
  96. package/dist/tools/guides.js +589 -538
  97. package/dist/tools/index.js +122 -99
  98. package/dist/tools/registry.js +21 -3
  99. package/dist/tools/runtime/node-worker-source.js +205 -205
  100. package/dist/tools/runtime/python-worker-source.js +177 -177
  101. package/dist/vscode/cli.js +9 -9
  102. package/dist/web-annotations/cdp.js +900 -900
  103. package/dist/web-annotations/store.js +96 -96
  104. package/docs/README.md +23 -23
  105. package/docs/ops/install-developer-host.md +112 -112
  106. package/docs/ops/install-user-host.md +96 -96
  107. package/docs/ops/upgrade-user-to-developer-host.md +69 -69
  108. package/docs/ops/vscode-extension-release.md +160 -160
  109. package/package.json +98 -95
  110. package/skills/builtin/graphify/SKILL.md +52 -52
  111. package/skills/builtin/loop/SKILL.md +69 -0
  112. package/skills/builtin/pi-agent-harness/SKILL.md +319 -319
  113. package/skills/builtin/pi-agent-harness/agents/openai.yaml +4 -4
  114. package/skills/builtin/pibo-docker-system/SKILL.md +170 -170
  115. package/skills/builtin/pibo-spec-writing/SKILL.md +330 -330
  116. package/skills/builtin/prd/SKILL.md +143 -143
  117. package/skills/builtin/ralph-loop/SKILL.md +361 -359
  118. package/skills/builtin/ralph-prd-json/SKILL.md +123 -123
  119. package/skills/builtin/skill-creator/LICENSE.txt +201 -201
  120. package/skills/builtin/skill-creator/SKILL.md +513 -513
  121. package/skills/builtin/skill-creator/agents/analyzer.md +274 -274
  122. package/skills/builtin/skill-creator/agents/comparator.md +202 -202
  123. package/skills/builtin/skill-creator/agents/grader.md +223 -223
  124. package/skills/builtin/skill-creator/assets/eval_review.html +146 -146
  125. package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -471
  126. package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -1325
  127. package/skills/builtin/skill-creator/references/schemas.md +430 -430
  128. package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -401
  129. package/skills/builtin/skill-creator/scripts/generate_report.py +326 -326
  130. package/skills/builtin/skill-creator/scripts/improve_description.py +247 -247
  131. package/skills/builtin/skill-creator/scripts/package_skill.py +136 -136
  132. package/skills/builtin/skill-creator/scripts/quick_validate.py +102 -102
  133. package/skills/builtin/skill-creator/scripts/run_eval.py +310 -310
  134. package/skills/builtin/skill-creator/scripts/run_loop.py +328 -328
  135. package/skills/builtin/skill-creator/scripts/utils.py +47 -47
  136. package/skills/builtin/web-annotations/SKILL.md +93 -93
  137. package/src/mcp/LICENSE.mcp-cli +21 -21
  138. package/dist/apps/vscode-artifacts/latest.vsix +0 -0
  139. package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.9.13.vsix +0 -0
@@ -1,359 +1,361 @@
1
- ---
2
- name: ralph-loop
3
- description: Plan, create, run, monitor, and review Ralph implementation loops with reusable Docker workers, git worktrees, PRD batches, stop policies, maxIterations, progress files, commits, and safe agent instructions. Use whenever the user wants to start a Ralph job, run an implementation loop, prepare autonomous PRD execution, monitor Ralph, debug Ralph job behavior, or capture the standard Ralph loop workflow.
4
- ---
5
-
6
- # Ralph Loop Workflow
7
-
8
- Use this skill to create and operate a Ralph implementation loop safely. Ralph runs repeated Pibo agent sessions against an objective, usually from PRD stories. The core pattern is:
9
-
10
- 1. Prepare a clean git worktree.
11
- 2. Reuse a dedicated Docker dev worker for runtime, builds, tests, gateway, and browser checks.
12
- 3. Create a Ralph job from a built-in template.
13
- 4. Give Ralph explicit operating instructions.
14
- 5. Start only after inspection.
15
- 6. Monitor with Ralph, debug session, events, trace, and git status.
16
- 7. Require progress updates and commits after completed stories or coherent story groups.
17
-
18
- For CLI details, first discover the current implementation:
19
-
20
- ```bash
21
- pibo tools guide ralph ralph
22
- pibo ralph templates --json
23
- pibo ralph conditions
24
- ```
25
-
26
- Do not duplicate the whole CLI guide in answers. Use it as the live source of truth.
27
-
28
- ## When to Use Which Skill
29
-
30
- - Use `ralph-loop` for job setup, Docker/worktree strategy, monitoring, stop conditions, and loop operations.
31
- - Use `ralph-prd-json` to convert Markdown PRDs/specs into Ralph `prd.json` story files.
32
- - Use `pibo-docker-system` when a Docker worker must be created, inspected, authenticated, or debugged.
33
- - Use `github-server-flow` when pushing branches or opening upstream PRs.
34
-
35
- ## Default Safety Rules
36
-
37
- Apply these unless the user says otherwise:
38
-
39
- - Reuse an existing Docker dev worker. Do not create or release workers without explicit approval.
40
- - Keep source edits and git commits in the host worktree.
41
- - Use the Docker worker only for runtime, builds, tests, dev gateway restarts, and browser/web verification.
42
- - Do not restart or modify host services such as `pibo-web.service` from the Ralph job.
43
- - Do not expose tokens or credentials in prompts, logs, commits, or reports.
44
- - Keep a progress file at the repo root, usually `IMPLEMENTATION_PROGRESS.md`.
45
- - Commit after each completed story or coherent story group.
46
- - Prefer starting the job stopped, inspect it, then start it.
47
- - Stop normally with `pibo ralph stop`; use `cancel` only when stuck or unsafe.
48
-
49
- ## Standard Topology
50
-
51
- Use a dedicated branch and worktree per Ralph loop:
52
-
53
- ```bash
54
- cd /root/code/pibo
55
- git fetch upstream main
56
- git switch main
57
- git merge --ff-only upstream/main
58
-
59
- git worktree add .worktrees/<loop-name> -b <branch-name>
60
- cd .worktrees/<loop-name>
61
- ```
62
-
63
- Typical names:
64
-
65
- - Worktree: `/root/code/pibo/.worktrees/<feature-or-loop-name>`
66
- - Branch: `<feature-or-loop-name>`
67
- - Docker worker: `pibo-dev-<feature-or-loop-name>`
68
- - Progress file: `<worktree>/IMPLEMENTATION_PROGRESS.md`
69
-
70
- If a Docker worker already exists, reuse it. A typical container command is:
71
-
72
- ```bash
73
- docker exec <worker-name> bash -lc 'cd /workspace && <command>'
74
- ```
75
-
76
- The container usually sees the worktree at `/workspace`. Git metadata may not work inside the container, so keep git operations on the host worktree.
77
-
78
- ## Progress File Template
79
-
80
- Create or update `IMPLEMENTATION_PROGRESS.md` in the worktree root:
81
-
82
- ```markdown
83
- # <Feature> Implementation Progress
84
-
85
- ## Ralph job setup
86
-
87
- - Created: <date>
88
- - Target scope: app-global
89
- - Target room: `<room-id>`
90
- - Profile: `pibo-agent`
91
- - Template: `<template-id>`
92
- - Worktree: `<absolute-host-worktree>`
93
- - Branch: `<branch>`
94
- - Docker dev worker: `<worker-name>`
95
- - Docker web port: `<port>`
96
- - Docker gateway port: `<port>`
97
- - Docker CDP port: `<port>`
98
-
99
- ## Scope
100
-
101
- Implement:
102
-
103
- `<paths to PRDs/specs/tasks>`
104
-
105
- ## Operating notes
106
-
107
- - Keep implementation work in the dedicated host worktree above.
108
- - Reuse the existing Docker dev worker for runtime, tests, builds, and gateway restarts.
109
- - Do not create or release Docker workers unless explicitly asked.
110
- - Do not restart or modify host services.
111
- - Run container commands as `docker exec <worker> bash -lc 'cd /workspace && <command>'`.
112
- - Git operations and commits must be done on the host worktree path.
113
- - Batch user stories sensibly. Stop the session when a coherent batch is complete.
114
- - Commit after each completed story or coherent story group.
115
- - Before starting new work, review recent commits in this worktree/branch.
116
-
117
- ## Progress log
118
-
119
- - <date>: Created worktree and validated Docker worker.
120
- ```
121
-
122
- ## Ralph Job Creation Flow
123
-
124
- Prefer this sequence:
125
-
126
- 1. Prepare or verify worktree, Docker worker, and progress file.
127
- 2. Inspect templates.
128
- 3. Create the job stopped.
129
- 4. Inspect the job JSON.
130
- 5. Start after confirmation.
131
-
132
- Example:
133
-
134
- ```bash
135
- ROOM_ID='<room-id>'
136
-
137
- pibo ralph templates --json
138
-
139
- pibo ralph add \
140
- --room "$ROOM_ID" \
141
- --profile pibo-agent \
142
- --template prd-batch-stories \
143
- --name "Implement <feature> PRD batch" \
144
- --prompt "$(cat /tmp/ralph-loop-prompt.txt)" \
145
- --json
146
-
147
- pibo ralph list --all --json
148
- pibo ralph start <job-id>
149
- ```
150
-
151
- Use `--start` only when the user explicitly wants immediate launch or the job has already been reviewed.
152
-
153
- ## Template Choice
154
-
155
- Use the built-in templates as source-of-truth presets:
156
-
157
- - `prd-single-story-standard`: one failing PRD story per run, useful for risky changes.
158
- - `prd-batch-stories`: multiple PRD stories in priority order, useful for a prepared batch with clear commits.
159
- - `single-run-objective`: one focused non-PRD task, stops after one completed run attempt.
160
-
161
- Explicit CLI options override template fields. Keep loaded fields editable when preparing jobs.
162
-
163
- ## Stop Conditions and maxIterations
164
-
165
- Ralph has two layers of stopping:
166
-
167
- - Semantic stop conditions, e.g. promise-complete or story completion.
168
- - `maxIterations` fallback.
169
-
170
- `maxIterations` should be treated as a hard fallback over **completed run attempts**, including:
171
-
172
- - `ok`
173
- - `error`
174
- - `cancelled`
175
-
176
- This prevents endless loops when runs repeatedly fail or get cancelled before satisfying a semantic stop condition.
177
-
178
- Use a high but bounded value for large PRD batches, such as `100`, and a small value for focused one-shot tasks, such as `1`. For PRD/story batches, a good rule of thumb is `maxIterations = 3 × total user stories`; adjust freely when the job is not PRD-based, the stop condition is different, or the risk profile calls for a smaller or larger fallback.
179
-
180
- ### Promise-complete Token Safety
181
-
182
- Ralph's promise-complete condition is a literal marker check on the final answer. Older deployments and some jobs may treat any mention as a match; even with stricter own-line matching, quoted examples are dangerous. If an agent writes the literal completion marker in a negative sentence, quote, explanation, or example, the loop can stop accidentally.
183
-
184
- When preparing prompts for jobs with a promise-complete condition:
185
-
186
- - Do not include the full literal completion marker contiguously in the prompt.
187
- - Describe it as the XML completion marker, or as the opening tag `<promise>`, the word `COMPLETE`, and the closing tag `</promise>`.
188
- - Instruct the agent not to quote, negate, explain, or mention the literal marker unless all completion criteria are satisfied and it intentionally wants to stop the job.
189
- - For incomplete work, instruct the agent to say "completion marker omitted" instead of writing the literal marker in any form.
190
- - When reviewing a stopped job with reason `promise-complete`, inspect the final answer for accidental mentions such as "not complete" statements before assuming the work is finished.
191
-
192
- ## Prompt Instructions Ralph Needs
193
-
194
- The job prompt is the most important part. It should be explicit about environment, scope, verification, commits, and forbidden actions.
195
-
196
- Include:
197
-
198
- - Exact host worktree path.
199
- - Exact branch name.
200
- - Exact Docker worker name and ports.
201
- - Exact PRD/spec paths to implement.
202
- - Progress file path.
203
- - Commit policy.
204
- - Test/build policy.
205
- - Real-path validation policy for user-facing work.
206
- - Safety restrictions.
207
- - What to do first.
208
- - When to stop the current session.
209
-
210
- ### Prompt Skeleton
211
-
212
- ```text
213
- Implement <feature/scope> using the dedicated Ralph loop environment.
214
-
215
- Environment:
216
- - Host worktree: <absolute-host-worktree>
217
- - Branch: <branch>
218
- - Docker dev worker: <worker-name>
219
- - Container workspace: /workspace
220
- - Web: http://127.0.0.1:<web-port>/apps/chat
221
- - Gateway: <gateway-port>
222
- - CDP: <cdp-port>
223
- - Progress file: <absolute-host-worktree>/IMPLEMENTATION_PROGRESS.md
224
-
225
- Scope:
226
- - Implement PRDs under: <path/glob>
227
- - Total workload: <optional story count>
228
-
229
- Operating rules:
230
- - Work in the host worktree. Use absolute paths or cd into the worktree before edits.
231
- - Use the Docker worker for runtime, tests, builds, dev gateway restarts, and browser checks.
232
- - Run container commands as: docker exec <worker> bash -lc 'cd /workspace && <command>'.
233
- - Do not create or release Docker workers.
234
- - Do not restart or modify host pibo-web.service.
235
- - Do not expose credentials.
236
- - Keep telemetry/privacy/product constraints from the PRDs.
237
- - If using promise-complete, never quote, negate, explain, or mention the literal completion marker unless all completion criteria are satisfied; for incomplete work, say "completion marker omitted".
238
- - Update IMPLEMENTATION_PROGRESS.md with decisions, completed stories, validation, commits, blockers, and next steps.
239
- - For each completed story, record concrete evidence: commands run, fake/demo/real path, browser/PTY/manual checks, and observed result.
240
- - Commit after every completed story or coherent story group.
241
-
242
- First actions:
243
- 1. cd <host-worktree>.
244
- 2. Run git status and recent git log.
245
- 3. Read IMPLEMENTATION_PROGRESS.md.
246
- 4. Read the PRD JSON files and related specs/tasks/decisions.
247
- 5. Select a coherent next story group.
248
- 6. State the selected group in the progress file.
249
-
250
- Completion rules for each story group:
251
- - Implement the smallest coherent slice.
252
- - Run focused tests first.
253
- - Run typecheck/build when appropriate.
254
- - For user-facing CLI, TUI, Web UI, gateway, runtime, auth, persistence, or agent-routing behavior, exercise the closest practical default path when feasible. Fake/demo/mocked checks are useful but should not be the only evidence for default-path behavior.
255
- - Commit from the host worktree with a clear message.
256
- - Update progress with validation, evidence tier, observed result, and commit hash.
257
- - Stop the session if the coherent batch is complete or if blocked.
258
- ```
259
-
260
- ## Validation Evidence Audit
261
-
262
- Use this audit lightly, not as a rigid ceremony. It exists to catch false confidence before a Ralph job marks user-facing work complete.
263
-
264
- Before the final story group is marked complete, or before emitting a completion marker, have Ralph list the top user-facing happy paths and the evidence for each. Classify each check as one of:
265
-
266
- - unit/fixture
267
- - fake/demo
268
- - integration-lite
269
- - real default path
270
- - browser/PTY/manual verified
271
- - not verified, with reason
272
-
273
- For user-facing CLI, TUI, Web UI, gateway, runtime, auth, persistence, or agent-routing features, demo/fake-only validation should trigger a pause or explicit risk note if the real default path is locally testable. Do not require heavyweight E2E tests for every helper or internal refactor; scale the audit to the risk and scope.
274
-
275
- ## Monitoring Checklist
276
-
277
- Use read-only checks unless the user asks for intervention:
278
-
279
- ```bash
280
- pibo ralph list --all --json
281
- pibo ralph runs --job <job-id> --json
282
- pibo debug session <pibo-session-id>
283
- pibo debug events <pibo-session-id> --limit 30
284
- pibo debug trace <pibo-session-id> --running-only --check
285
- ```
286
-
287
- Also inspect git state:
288
-
289
- ```bash
290
- cd <worktree>
291
- git status --short --branch
292
- git log --oneline --decorate -n 8
293
- tail -80 IMPLEMENTATION_PROGRESS.md
294
- ```
295
-
296
- Interpretation tips:
297
-
298
- - A running session with fresh events is healthy even if a trace wrapper reports `status: error`; compare session status, events, and Ralph run status before acting.
299
- - If the worktree has uncommitted changes for a long time, check whether Ralph is still actively editing/testing.
300
- - If a completed story is uncommitted, remind or intervene only with user approval unless the job instructions authorize commits.
301
-
302
- ## Review and Intervention Strategy
303
-
304
- Early review should be read-only:
305
-
306
- 1. Confirm job enabled/running state.
307
- 2. Confirm current run and session IDs.
308
- 3. Confirm session events are fresh.
309
- 4. Confirm worktree branch and changed files.
310
- 5. Confirm progress file is being updated.
311
- 6. Confirm Docker worker is reachable if runtime checks are expected.
312
- 7. Report concise status, risks, and whether to continue.
313
-
314
- Intervene only when:
315
-
316
- - The job is unsafe.
317
- - It touches forbidden host services.
318
- - It uses the wrong repo/worktree/branch.
319
- - It creates/release workers without approval.
320
- - It is stale and not making progress.
321
- - It repeatedly fails and `maxIterations` is being consumed.
322
-
323
- Prefer `pibo ralph stop` for graceful shutdown. Use `pibo ralph cancel` only for stuck or unsafe active runs.
324
-
325
- ## Sync and PR Strategy
326
-
327
- For host repo sync:
328
-
329
- ```bash
330
- cd /root/code/pibo
331
- git fetch upstream main
332
- git switch main
333
- git merge --ff-only upstream/main
334
- git switch developer
335
- git merge --ff-only main
336
- git push origin main developer
337
- ```
338
-
339
- For Ralph worktree branches:
340
-
341
- - Do not merge or rebase a running Ralph worktree without checking active edits.
342
- - Let Ralph finish and commit a coherent batch first.
343
- - Then sync intentionally, resolve conflicts, run tests, and push.
344
- - Open upstream PRs with the project helper when ready.
345
-
346
- ## Minimal User Report
347
-
348
- Keep reports short:
349
-
350
- ```text
351
- Ralph läuft gesund.
352
- - Job: <id>
353
- - Run: <id>, Status: running
354
- - Session: <id>, letzte Events frisch
355
- - Worktree: <branch>, aktuelle Änderungen: <files>
356
- - Progress: <last completed story/commit>
357
- - Risiko: <none/short note>
358
- Empfehlung: weiterlaufen lassen / stoppen / eingreifen.
359
- ```
1
+ ---
2
+ name: ralph-loop
3
+ description: Plan, create, run, monitor, and review legacy Ralph fresh-session implementation loops. Use when the user explicitly asks for Ralph compatibility, Ralph PRD batches, or a new Pibo Session per run; use the loop skill for standard persistent Goal Loops.
4
+ ---
5
+
6
+ # Ralph Loop Workflow
7
+
8
+ Use this skill to create and operate a legacy Ralph implementation loop safely. Ralph starts a fresh Pibo Session for each run. For new same-session persistent goals, use the `loop` skill and `pibo loop` instead.
9
+
10
+ Ralph runs repeated Pibo agent sessions against an objective, usually from PRD stories. The core pattern is:
11
+
12
+ 1. Prepare a clean git worktree.
13
+ 2. Reuse a dedicated Docker dev worker for runtime, builds, tests, gateway, and browser checks.
14
+ 3. Create a Ralph job from a built-in template.
15
+ 4. Give Ralph explicit operating instructions.
16
+ 5. Start only after inspection.
17
+ 6. Monitor with Ralph, debug session, events, trace, and git status.
18
+ 7. Require progress updates and commits after completed stories or coherent story groups.
19
+
20
+ For CLI details, first discover the current implementation:
21
+
22
+ ```bash
23
+ pibo tools guide ralph ralph
24
+ pibo ralph templates --json
25
+ pibo ralph conditions
26
+ ```
27
+
28
+ Do not duplicate the whole CLI guide in answers. Use it as the live source of truth.
29
+
30
+ ## When to Use Which Skill
31
+
32
+ - Use `ralph-loop` for job setup, Docker/worktree strategy, monitoring, stop conditions, and loop operations.
33
+ - Use `ralph-prd-json` to convert Markdown PRDs/specs into Ralph `prd.json` story files.
34
+ - Use `pibo-docker-system` when a Docker worker must be created, inspected, authenticated, or debugged.
35
+ - Use `github-server-flow` when pushing branches or opening upstream PRs.
36
+
37
+ ## Default Safety Rules
38
+
39
+ Apply these unless the user says otherwise:
40
+
41
+ - Reuse an existing Docker dev worker. Do not create or release workers without explicit approval.
42
+ - Keep source edits and git commits in the host worktree.
43
+ - Use the Docker worker only for runtime, builds, tests, dev gateway restarts, and browser/web verification.
44
+ - Do not restart or modify host services such as `pibo-web.service` from the Ralph job.
45
+ - Do not expose tokens or credentials in prompts, logs, commits, or reports.
46
+ - Keep a progress file at the repo root, usually `IMPLEMENTATION_PROGRESS.md`.
47
+ - Commit after each completed story or coherent story group.
48
+ - Prefer starting the job stopped, inspect it, then start it.
49
+ - Stop normally with `pibo ralph stop`; use `cancel` only when stuck or unsafe.
50
+
51
+ ## Standard Topology
52
+
53
+ Use a dedicated branch and worktree per Ralph loop:
54
+
55
+ ```bash
56
+ cd /root/code/pibo
57
+ git fetch upstream main
58
+ git switch main
59
+ git merge --ff-only upstream/main
60
+
61
+ git worktree add .worktrees/<loop-name> -b <branch-name>
62
+ cd .worktrees/<loop-name>
63
+ ```
64
+
65
+ Typical names:
66
+
67
+ - Worktree: `/root/code/pibo/.worktrees/<feature-or-loop-name>`
68
+ - Branch: `<feature-or-loop-name>`
69
+ - Docker worker: `pibo-dev-<feature-or-loop-name>`
70
+ - Progress file: `<worktree>/IMPLEMENTATION_PROGRESS.md`
71
+
72
+ If a Docker worker already exists, reuse it. A typical container command is:
73
+
74
+ ```bash
75
+ docker exec <worker-name> bash -lc 'cd /workspace && <command>'
76
+ ```
77
+
78
+ The container usually sees the worktree at `/workspace`. Git metadata may not work inside the container, so keep git operations on the host worktree.
79
+
80
+ ## Progress File Template
81
+
82
+ Create or update `IMPLEMENTATION_PROGRESS.md` in the worktree root:
83
+
84
+ ```markdown
85
+ # <Feature> Implementation Progress
86
+
87
+ ## Ralph job setup
88
+
89
+ - Created: <date>
90
+ - Target scope: app-global
91
+ - Target room: `<room-id>`
92
+ - Profile: `pibo-agent`
93
+ - Template: `<template-id>`
94
+ - Worktree: `<absolute-host-worktree>`
95
+ - Branch: `<branch>`
96
+ - Docker dev worker: `<worker-name>`
97
+ - Docker web port: `<port>`
98
+ - Docker gateway port: `<port>`
99
+ - Docker CDP port: `<port>`
100
+
101
+ ## Scope
102
+
103
+ Implement:
104
+
105
+ `<paths to PRDs/specs/tasks>`
106
+
107
+ ## Operating notes
108
+
109
+ - Keep implementation work in the dedicated host worktree above.
110
+ - Reuse the existing Docker dev worker for runtime, tests, builds, and gateway restarts.
111
+ - Do not create or release Docker workers unless explicitly asked.
112
+ - Do not restart or modify host services.
113
+ - Run container commands as `docker exec <worker> bash -lc 'cd /workspace && <command>'`.
114
+ - Git operations and commits must be done on the host worktree path.
115
+ - Batch user stories sensibly. Stop the session when a coherent batch is complete.
116
+ - Commit after each completed story or coherent story group.
117
+ - Before starting new work, review recent commits in this worktree/branch.
118
+
119
+ ## Progress log
120
+
121
+ - <date>: Created worktree and validated Docker worker.
122
+ ```
123
+
124
+ ## Ralph Job Creation Flow
125
+
126
+ Prefer this sequence:
127
+
128
+ 1. Prepare or verify worktree, Docker worker, and progress file.
129
+ 2. Inspect templates.
130
+ 3. Create the job stopped.
131
+ 4. Inspect the job JSON.
132
+ 5. Start after confirmation.
133
+
134
+ Example:
135
+
136
+ ```bash
137
+ ROOM_ID='<room-id>'
138
+
139
+ pibo ralph templates --json
140
+
141
+ pibo ralph add \
142
+ --room "$ROOM_ID" \
143
+ --profile pibo-agent \
144
+ --template prd-batch-stories \
145
+ --name "Implement <feature> PRD batch" \
146
+ --prompt "$(cat /tmp/ralph-loop-prompt.txt)" \
147
+ --json
148
+
149
+ pibo ralph list --all --json
150
+ pibo ralph start <job-id>
151
+ ```
152
+
153
+ Use `--start` only when the user explicitly wants immediate launch or the job has already been reviewed.
154
+
155
+ ## Template Choice
156
+
157
+ Use the built-in templates as source-of-truth presets:
158
+
159
+ - `prd-single-story-standard`: one failing PRD story per run, useful for risky changes.
160
+ - `prd-batch-stories`: multiple PRD stories in priority order, useful for a prepared batch with clear commits.
161
+ - `single-run-objective`: one focused non-PRD task, stops after one completed run attempt.
162
+
163
+ Explicit CLI options override template fields. Keep loaded fields editable when preparing jobs.
164
+
165
+ ## Stop Conditions and maxIterations
166
+
167
+ Ralph has two layers of stopping:
168
+
169
+ - Semantic stop conditions, e.g. promise-complete or story completion.
170
+ - `maxIterations` fallback.
171
+
172
+ `maxIterations` should be treated as a hard fallback over **completed run attempts**, including:
173
+
174
+ - `ok`
175
+ - `error`
176
+ - `cancelled`
177
+
178
+ This prevents endless loops when runs repeatedly fail or get cancelled before satisfying a semantic stop condition.
179
+
180
+ Use a high but bounded value for large PRD batches, such as `100`, and a small value for focused one-shot tasks, such as `1`. For PRD/story batches, a good rule of thumb is `maxIterations = 3 × total user stories`; adjust freely when the job is not PRD-based, the stop condition is different, or the risk profile calls for a smaller or larger fallback.
181
+
182
+ ### Promise-complete Token Safety
183
+
184
+ Ralph's promise-complete condition is a literal marker check on the final answer. Older deployments and some jobs may treat any mention as a match; even with stricter own-line matching, quoted examples are dangerous. If an agent writes the literal completion marker in a negative sentence, quote, explanation, or example, the loop can stop accidentally.
185
+
186
+ When preparing prompts for jobs with a promise-complete condition:
187
+
188
+ - Do not include the full literal completion marker contiguously in the prompt.
189
+ - Describe it as the XML completion marker, or as the opening tag `<promise>`, the word `COMPLETE`, and the closing tag `</promise>`.
190
+ - Instruct the agent not to quote, negate, explain, or mention the literal marker unless all completion criteria are satisfied and it intentionally wants to stop the job.
191
+ - For incomplete work, instruct the agent to say "completion marker omitted" instead of writing the literal marker in any form.
192
+ - When reviewing a stopped job with reason `promise-complete`, inspect the final answer for accidental mentions such as "not complete" statements before assuming the work is finished.
193
+
194
+ ## Prompt Instructions Ralph Needs
195
+
196
+ The job prompt is the most important part. It should be explicit about environment, scope, verification, commits, and forbidden actions.
197
+
198
+ Include:
199
+
200
+ - Exact host worktree path.
201
+ - Exact branch name.
202
+ - Exact Docker worker name and ports.
203
+ - Exact PRD/spec paths to implement.
204
+ - Progress file path.
205
+ - Commit policy.
206
+ - Test/build policy.
207
+ - Real-path validation policy for user-facing work.
208
+ - Safety restrictions.
209
+ - What to do first.
210
+ - When to stop the current session.
211
+
212
+ ### Prompt Skeleton
213
+
214
+ ```text
215
+ Implement <feature/scope> using the dedicated Ralph loop environment.
216
+
217
+ Environment:
218
+ - Host worktree: <absolute-host-worktree>
219
+ - Branch: <branch>
220
+ - Docker dev worker: <worker-name>
221
+ - Container workspace: /workspace
222
+ - Web: http://127.0.0.1:<web-port>/apps/chat
223
+ - Gateway: <gateway-port>
224
+ - CDP: <cdp-port>
225
+ - Progress file: <absolute-host-worktree>/IMPLEMENTATION_PROGRESS.md
226
+
227
+ Scope:
228
+ - Implement PRDs under: <path/glob>
229
+ - Total workload: <optional story count>
230
+
231
+ Operating rules:
232
+ - Work in the host worktree. Use absolute paths or cd into the worktree before edits.
233
+ - Use the Docker worker for runtime, tests, builds, dev gateway restarts, and browser checks.
234
+ - Run container commands as: docker exec <worker> bash -lc 'cd /workspace && <command>'.
235
+ - Do not create or release Docker workers.
236
+ - Do not restart or modify host pibo-web.service.
237
+ - Do not expose credentials.
238
+ - Keep telemetry/privacy/product constraints from the PRDs.
239
+ - If using promise-complete, never quote, negate, explain, or mention the literal completion marker unless all completion criteria are satisfied; for incomplete work, say "completion marker omitted".
240
+ - Update IMPLEMENTATION_PROGRESS.md with decisions, completed stories, validation, commits, blockers, and next steps.
241
+ - For each completed story, record concrete evidence: commands run, fake/demo/real path, browser/PTY/manual checks, and observed result.
242
+ - Commit after every completed story or coherent story group.
243
+
244
+ First actions:
245
+ 1. cd <host-worktree>.
246
+ 2. Run git status and recent git log.
247
+ 3. Read IMPLEMENTATION_PROGRESS.md.
248
+ 4. Read the PRD JSON files and related specs/tasks/decisions.
249
+ 5. Select a coherent next story group.
250
+ 6. State the selected group in the progress file.
251
+
252
+ Completion rules for each story group:
253
+ - Implement the smallest coherent slice.
254
+ - Run focused tests first.
255
+ - Run typecheck/build when appropriate.
256
+ - For user-facing CLI, TUI, Web UI, gateway, runtime, auth, persistence, or agent-routing behavior, exercise the closest practical default path when feasible. Fake/demo/mocked checks are useful but should not be the only evidence for default-path behavior.
257
+ - Commit from the host worktree with a clear message.
258
+ - Update progress with validation, evidence tier, observed result, and commit hash.
259
+ - Stop the session if the coherent batch is complete or if blocked.
260
+ ```
261
+
262
+ ## Validation Evidence Audit
263
+
264
+ Use this audit lightly, not as a rigid ceremony. It exists to catch false confidence before a Ralph job marks user-facing work complete.
265
+
266
+ Before the final story group is marked complete, or before emitting a completion marker, have Ralph list the top user-facing happy paths and the evidence for each. Classify each check as one of:
267
+
268
+ - unit/fixture
269
+ - fake/demo
270
+ - integration-lite
271
+ - real default path
272
+ - browser/PTY/manual verified
273
+ - not verified, with reason
274
+
275
+ For user-facing CLI, TUI, Web UI, gateway, runtime, auth, persistence, or agent-routing features, demo/fake-only validation should trigger a pause or explicit risk note if the real default path is locally testable. Do not require heavyweight E2E tests for every helper or internal refactor; scale the audit to the risk and scope.
276
+
277
+ ## Monitoring Checklist
278
+
279
+ Use read-only checks unless the user asks for intervention:
280
+
281
+ ```bash
282
+ pibo ralph list --all --json
283
+ pibo ralph runs --job <job-id> --json
284
+ pibo debug session <pibo-session-id>
285
+ pibo debug events <pibo-session-id> --limit 30
286
+ pibo debug trace <pibo-session-id> --running-only --check
287
+ ```
288
+
289
+ Also inspect git state:
290
+
291
+ ```bash
292
+ cd <worktree>
293
+ git status --short --branch
294
+ git log --oneline --decorate -n 8
295
+ tail -80 IMPLEMENTATION_PROGRESS.md
296
+ ```
297
+
298
+ Interpretation tips:
299
+
300
+ - A running session with fresh events is healthy even if a trace wrapper reports `status: error`; compare session status, events, and Ralph run status before acting.
301
+ - If the worktree has uncommitted changes for a long time, check whether Ralph is still actively editing/testing.
302
+ - If a completed story is uncommitted, remind or intervene only with user approval unless the job instructions authorize commits.
303
+
304
+ ## Review and Intervention Strategy
305
+
306
+ Early review should be read-only:
307
+
308
+ 1. Confirm job enabled/running state.
309
+ 2. Confirm current run and session IDs.
310
+ 3. Confirm session events are fresh.
311
+ 4. Confirm worktree branch and changed files.
312
+ 5. Confirm progress file is being updated.
313
+ 6. Confirm Docker worker is reachable if runtime checks are expected.
314
+ 7. Report concise status, risks, and whether to continue.
315
+
316
+ Intervene only when:
317
+
318
+ - The job is unsafe.
319
+ - It touches forbidden host services.
320
+ - It uses the wrong repo/worktree/branch.
321
+ - It creates/release workers without approval.
322
+ - It is stale and not making progress.
323
+ - It repeatedly fails and `maxIterations` is being consumed.
324
+
325
+ Prefer `pibo ralph stop` for graceful shutdown. Use `pibo ralph cancel` only for stuck or unsafe active runs.
326
+
327
+ ## Sync and PR Strategy
328
+
329
+ For host repo sync:
330
+
331
+ ```bash
332
+ cd /root/code/pibo
333
+ git fetch upstream main
334
+ git switch main
335
+ git merge --ff-only upstream/main
336
+ git switch developer
337
+ git merge --ff-only main
338
+ git push origin main developer
339
+ ```
340
+
341
+ For Ralph worktree branches:
342
+
343
+ - Do not merge or rebase a running Ralph worktree without checking active edits.
344
+ - Let Ralph finish and commit a coherent batch first.
345
+ - Then sync intentionally, resolve conflicts, run tests, and push.
346
+ - Open upstream PRs with the project helper when ready.
347
+
348
+ ## Minimal User Report
349
+
350
+ Keep reports short:
351
+
352
+ ```text
353
+ Ralph läuft gesund.
354
+ - Job: <id>
355
+ - Run: <id>, Status: running
356
+ - Session: <id>, letzte Events frisch
357
+ - Worktree: <branch>, aktuelle Änderungen: <files>
358
+ - Progress: <last completed story/commit>
359
+ - Risiko: <none/short note>
360
+ Empfehlung: weiterlaufen lassen / stoppen / eingreifen.
361
+ ```