@pasko70/pibo 1.4.0 → 1.4.2

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 (129) 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-store.js +82 -82
  8. package/dist/apps/chat/data/project-service.js +166 -166
  9. package/dist/apps/chat/data/read-state-service.js +18 -18
  10. package/dist/apps/chat/data/timeline-query-service.js +8 -8
  11. package/dist/apps/chat/model-catalog.js +5 -1
  12. package/dist/apps/chat/static-assets.js +853 -853
  13. package/dist/apps/chat/workflow-persistence.js +255 -255
  14. package/dist/apps/chat-ui/assets/{dist-7YaJd19a.js → dist-B2BEpL7n.js} +1 -1
  15. package/dist/apps/chat-ui/assets/{dist-CiYeO8nN.js → dist-BAGS_xkV.js} +1 -1
  16. package/dist/apps/chat-ui/assets/{dist-BIvPnn_C.js → dist-BAXNalar.js} +1 -1
  17. package/dist/apps/chat-ui/assets/{dist-CjSI6y5z.js → dist-BwUvs6Ph.js} +1 -1
  18. package/dist/apps/chat-ui/assets/{dist-Ubstha8t.js → dist-C0zsJ8II.js} +1 -1
  19. package/dist/apps/chat-ui/assets/{dist-KXCMNKIL.js → dist-C3PnEkhb.js} +1 -1
  20. package/dist/apps/chat-ui/assets/{dist-CVQU42Fn.js → dist-CYPL-B2Z.js} +1 -1
  21. package/dist/apps/chat-ui/assets/{dist-BbNE72h8.js → dist-CiDSXgtg.js} +1 -1
  22. package/dist/apps/chat-ui/assets/{dist-D7TCkoFT.js → dist-DnACFKyO.js} +1 -1
  23. package/dist/apps/chat-ui/assets/{dist-ChSZNqKE.js → dist-ZB1-ui2y.js} +1 -1
  24. package/dist/apps/chat-ui/assets/{dist-8Noo5eCN.js → dist-vKlxFkTa.js} +1 -1
  25. package/dist/apps/chat-ui/assets/{index-CmxtUVG1.js → index-0x7tuTNX.js} +3 -3
  26. package/dist/apps/chat-ui/assets/{index-C25VYnyb.css → index-B-qaya1G.css} +1 -1
  27. package/dist/apps/chat-ui/index.html +18 -18
  28. package/dist/apps/chat-ui/manifest.webmanifest +25 -25
  29. package/dist/apps/chat-ui/sw.js +41 -41
  30. package/dist/apps/chat-vscode-web/index.html +12 -12
  31. package/dist/apps/cli-ui/cliSessionsCommand.js +23 -23
  32. package/dist/apps/context-files-ui/index.html +11 -11
  33. package/dist/apps/vscode-artifacts/latest.vsix +0 -0
  34. package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.4.2.vsix +0 -0
  35. package/dist/bin/pibo.js +0 -0
  36. package/dist/bin/rg.js +0 -0
  37. package/dist/cli.js +35 -35
  38. package/dist/compute/cli.js +54 -54
  39. package/dist/core/runtime.js +2 -0
  40. package/dist/core/session-router.js +1 -0
  41. package/dist/cron/cli.js +15 -15
  42. package/dist/cron/store.js +49 -49
  43. package/dist/data/cli.js +23 -23
  44. package/dist/data/event-log.js +23 -23
  45. package/dist/data/message-store.js +20 -20
  46. package/dist/data/navigation-store.js +9 -9
  47. package/dist/data/observation-store.js +4 -4
  48. package/dist/data/payload-store.js +17 -17
  49. package/dist/data/schema.js +429 -429
  50. package/dist/data/session-store.js +4 -4
  51. package/dist/data/telemetry-queries.js +54 -54
  52. package/dist/data/telemetry.js +156 -156
  53. package/dist/debug/events.js +12 -12
  54. package/dist/debug/failures.js +6 -6
  55. package/dist/debug/index.js +207 -207
  56. package/dist/debug/messages.js +6 -6
  57. package/dist/debug/pty.js +124 -124
  58. package/dist/debug/session.js +29 -29
  59. package/dist/debug/tools.js +5 -5
  60. package/dist/debug/web-snapshot-browser-scripts.js +294 -294
  61. package/dist/debug/web-streaming-browser-library.js +925 -925
  62. package/dist/debug/web-streaming-browser-scripts.js +232 -232
  63. package/dist/debug/web-streaming-provider-telemetry.js +4 -4
  64. package/dist/debug/web.js +93 -93
  65. package/dist/gateway/cli.js +19 -19
  66. package/dist/mcp/config-command.js +53 -53
  67. package/dist/mcp/index.js +21 -21
  68. package/dist/mcp/registry.js +11 -11
  69. package/dist/pi-packages/cli.js +11 -11
  70. package/dist/plugins/context-files-store.js +110 -110
  71. package/dist/plugins/context-files.js +4 -4
  72. package/dist/providers/glm.js +59 -0
  73. package/dist/ralph/cli.js +18 -18
  74. package/dist/ralph/templates.js +140 -140
  75. package/dist/reliability/store.js +226 -226
  76. package/dist/sessions/pibo-data-store.js +16 -16
  77. package/dist/sessions/sqlite-store.js +53 -53
  78. package/dist/setup/cli.js +58 -58
  79. package/dist/tools/agent-browser-wrapper.js +80 -80
  80. package/dist/tools/browser-use-cdp.js +12 -12
  81. package/dist/tools/browser-use-wrapper.js +762 -762
  82. package/dist/tools/guides.js +455 -455
  83. package/dist/tools/index.js +99 -99
  84. package/dist/tools/runtime/node-worker-source.js +205 -205
  85. package/dist/tools/runtime/python-worker-source.js +177 -177
  86. package/dist/vscode/cli.js +9 -9
  87. package/dist/web-annotations/cdp.js +900 -900
  88. package/dist/web-annotations/store.js +96 -96
  89. package/docs/README.md +23 -23
  90. package/docs/ops/install-developer-host.md +112 -112
  91. package/docs/ops/install-user-host.md +96 -96
  92. package/docs/ops/upgrade-user-to-developer-host.md +69 -69
  93. package/docs/ops/vscode-extension-release.md +160 -160
  94. package/package.json +1 -1
  95. package/skills/builtin/pi-agent-harness/SKILL.md +319 -319
  96. package/skills/builtin/pi-agent-harness/agents/openai.yaml +4 -4
  97. package/skills/builtin/pibo-docker-system/SKILL.md +170 -170
  98. package/skills/builtin/pibo-spec-writing/SKILL.md +330 -330
  99. package/skills/builtin/prd/SKILL.md +143 -143
  100. package/skills/builtin/ralph-loop/SKILL.md +359 -359
  101. package/skills/builtin/ralph-prd-json/SKILL.md +123 -123
  102. package/skills/builtin/skill-creator/LICENSE.txt +201 -201
  103. package/skills/builtin/skill-creator/SKILL.md +513 -513
  104. package/skills/builtin/skill-creator/agents/analyzer.md +274 -274
  105. package/skills/builtin/skill-creator/agents/comparator.md +202 -202
  106. package/skills/builtin/skill-creator/agents/grader.md +223 -223
  107. package/skills/builtin/skill-creator/assets/eval_review.html +146 -146
  108. package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -471
  109. package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -1325
  110. package/skills/builtin/skill-creator/references/schemas.md +430 -430
  111. package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -401
  112. package/skills/builtin/skill-creator/scripts/generate_report.py +326 -326
  113. package/skills/builtin/skill-creator/scripts/improve_description.py +247 -247
  114. package/skills/builtin/skill-creator/scripts/package_skill.py +136 -136
  115. package/skills/builtin/skill-creator/scripts/quick_validate.py +102 -102
  116. package/skills/builtin/skill-creator/scripts/run_eval.py +310 -310
  117. package/skills/builtin/skill-creator/scripts/run_loop.py +328 -328
  118. package/skills/builtin/skill-creator/scripts/utils.py +47 -47
  119. package/skills/builtin/web-annotations/SKILL.md +93 -93
  120. package/src/mcp/LICENSE.mcp-cli +21 -21
  121. package/dist/apps/vscode-artifacts/pibo-vscode-1.3.0.vsix +0 -0
  122. package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.3.3.vsix +0 -0
  123. package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.3.4.vsix +0 -0
  124. package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.3.5.vsix +0 -0
  125. package/dist/core/shared-app.js +0 -17
  126. package/dist/data/final-app-space-cutover-migration.js +0 -728
  127. package/dist/data/shared-app-migration.js +0 -757
  128. package/dist/session-ui/ownerViewModel.js +0 -27
  129. package/dist/shared-app.js +0 -4
@@ -1,359 +1,359 @@
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 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
+ ```