@pasko70/pibo 1.9.13 → 1.10.1
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/README.md +183 -183
- package/context/codex-base-prompt.md +148 -148
- package/context/compute-worker.md +23 -23
- package/context/pibo-compaction-prompt.md +100 -100
- package/context/pibo-native-tooling.md +18 -18
- package/context/pibo-system-prompt.md +77 -77
- package/dist/apps/chat/agent-profiles.js +2 -2
- package/dist/apps/chat/agent-store.js +263 -250
- package/dist/apps/chat/chat-request-normalizers.js +17 -0
- package/dist/apps/chat/data/chat-data-mappers.js +2 -0
- package/dist/apps/chat/data/project-service.js +168 -168
- package/dist/apps/chat/data/read-state-service.js +18 -18
- package/dist/apps/chat/data/session-query-service.js +25 -25
- package/dist/apps/chat/data/timeline-query-service.js +19 -19
- package/dist/apps/chat/loop-api.js +181 -0
- package/dist/apps/chat/static-assets.js +854 -854
- package/dist/apps/chat/web-app.js +36 -16
- package/dist/apps/chat/workflow-manual-trigger-runtime.js +149 -46
- package/dist/apps/chat/workflow-persistence.js +255 -255
- package/dist/apps/chat-ui/assets/{dist-BZ2eTC4f.js → dist-3Sts0Afa.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BHa-kcGl.js → dist-4NlLjLs7.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-yCYNNb5d.js → dist-BA6mhAec.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D811wJeV.js → dist-BPl-fzRB.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-Dq4GxJi3.js → dist-BPnn9e2B.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CzE6k3F3.js → dist-BpfBSMzK.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CnVsqwSG.js → dist-Cvx5M97R.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-WyXdYl-w.js → dist-DnXWNQRm.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BNMu92bb.js → dist-hU-2oAb6.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BCB6zezO.js → dist-r31x5Fcc.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-HqTN67dc.js → dist-uF6UXzI7.js} +1 -1
- package/dist/apps/chat-ui/assets/index-CaTGYBOS.js +173 -0
- package/dist/apps/chat-ui/assets/{index-C0x9nEcf.css → index-al8DeEjA.css} +1 -1
- package/dist/apps/chat-ui/index.html +18 -18
- package/dist/apps/chat-ui/manifest.webmanifest +25 -25
- package/dist/apps/chat-ui/sw.js +47 -47
- package/dist/apps/chat-vscode-web/assets/index-CK4SMZuu.js +41 -0
- package/dist/apps/chat-vscode-web/index.html +13 -13
- package/dist/apps/cli-ui/cliSessionsCommand.js +23 -23
- package/dist/apps/context-files-ui/index.html +11 -11
- package/dist/cli-session/localSessionSource.js +34 -12
- package/dist/cli.js +61 -44
- package/dist/compute/cli.js +54 -54
- package/dist/compute/resource-health.js +35 -2
- package/dist/core/events.js +6 -1
- package/dist/core/routed-session.js +97 -5
- package/dist/core/runtime.js +6 -1
- package/dist/core/session-router.js +27 -8
- package/dist/cron/cli.js +15 -15
- package/dist/cron/store.js +49 -49
- package/dist/data/cli.js +23 -23
- package/dist/data/event-log.js +23 -23
- package/dist/data/ingest-service.js +3 -1
- package/dist/data/message-store.js +27 -27
- package/dist/data/navigation-store.js +9 -9
- package/dist/data/observation-store.js +4 -4
- package/dist/data/payload-store.js +17 -17
- package/dist/data/schema.js +433 -433
- package/dist/data/session-store.js +4 -4
- package/dist/data/telemetry-queries.js +54 -54
- package/dist/data/telemetry.js +197 -197
- package/dist/debug/events.js +12 -12
- package/dist/debug/failures.js +6 -6
- package/dist/debug/index.js +231 -227
- package/dist/debug/messages.js +6 -6
- package/dist/debug/pty.js +124 -124
- package/dist/debug/session.js +29 -29
- package/dist/debug/tools.js +5 -5
- package/dist/debug/trace.js +42 -7
- package/dist/debug/web-snapshot-browser-scripts.js +294 -294
- package/dist/debug/web-streaming-browser-library.js +925 -925
- package/dist/debug/web-streaming-browser-scripts.js +232 -232
- package/dist/debug/web-streaming-provider-telemetry.js +4 -4
- package/dist/debug/web.js +93 -93
- package/dist/gateway/cli.js +19 -19
- package/dist/gateway/server.js +4 -2
- package/dist/gateway/web.js +2 -2
- package/dist/index.js +1 -0
- package/dist/loops/accounting.js +19 -0
- package/dist/loops/channel.js +8 -0
- package/dist/loops/cli.js +224 -0
- package/dist/loops/plugin.js +16 -0
- package/dist/loops/prompts.js +86 -0
- package/dist/loops/service.js +446 -0
- package/dist/loops/stopping.js +170 -0
- package/dist/loops/store.js +642 -0
- package/dist/loops/templates.js +232 -0
- package/dist/loops/tools.js +184 -0
- package/dist/loops/types.js +1 -0
- package/dist/mcp/config-command.js +53 -53
- package/dist/mcp/index.js +21 -21
- package/dist/mcp/registry.js +11 -11
- package/dist/pi-packages/cli.js +11 -11
- package/dist/plugins/builtin.js +8 -0
- package/dist/plugins/context-files-store.js +110 -110
- package/dist/plugins/context-files.js +4 -4
- package/dist/plugins/registry.js +23 -12
- package/dist/ralph/cli.js +18 -18
- package/dist/ralph/templates.js +140 -140
- package/dist/reliability/store.js +256 -229
- package/dist/runs/lifecycle.js +59 -0
- package/dist/runs/registry.js +47 -1
- package/dist/runs/tools.js +31 -13
- package/dist/session-ui/terminalRows.js +66 -2
- package/dist/sessions/pibo-data-store.js +16 -16
- package/dist/sessions/sqlite-store.js +53 -53
- package/dist/setup/cli.js +58 -58
- package/dist/shared/trace-async-agent-runs.js +4 -4
- package/dist/shared/trace-event-projection.js +59 -19
- package/dist/shared/trace-nodes.js +5 -0
- package/dist/shared/trace-page-merge.js +15 -0
- package/dist/shared/trace-run-notifications.js +3 -1
- package/dist/signals/projector.js +6 -2
- package/dist/tools/agent-browser-wrapper.js +80 -80
- package/dist/tools/browser-pool.js +50 -0
- package/dist/tools/browser-use-cdp.js +12 -12
- package/dist/tools/browser-use-leases.js +12 -8
- package/dist/tools/browser-use-wrapper.js +762 -762
- package/dist/tools/guides.js +596 -538
- package/dist/tools/index.js +123 -99
- package/dist/tools/registry.js +21 -3
- package/dist/tools/runtime/node-worker-source.js +205 -205
- package/dist/tools/runtime/python-worker-source.js +177 -177
- package/dist/vscode/cli.js +9 -9
- package/dist/web-annotations/cdp.js +900 -900
- package/dist/web-annotations/store.js +96 -96
- package/docs/README.md +23 -23
- package/docs/ops/install-developer-host.md +112 -112
- package/docs/ops/install-user-host.md +96 -96
- package/docs/ops/upgrade-user-to-developer-host.md +69 -69
- package/docs/ops/vscode-extension-release.md +160 -160
- package/package.json +99 -95
- package/skills/builtin/graphify/SKILL.md +52 -52
- package/skills/builtin/loop/SKILL.md +78 -0
- package/skills/builtin/pi-agent-harness/SKILL.md +319 -319
- package/skills/builtin/pi-agent-harness/agents/openai.yaml +4 -4
- package/skills/builtin/pibo-docker-system/SKILL.md +170 -170
- package/skills/builtin/pibo-spec-writing/SKILL.md +330 -330
- package/skills/builtin/prd/SKILL.md +143 -143
- package/skills/builtin/ralph-loop/SKILL.md +361 -359
- package/skills/builtin/ralph-prd-json/SKILL.md +123 -123
- package/skills/builtin/skill-creator/LICENSE.txt +201 -201
- package/skills/builtin/skill-creator/SKILL.md +513 -513
- package/skills/builtin/skill-creator/agents/analyzer.md +274 -274
- package/skills/builtin/skill-creator/agents/comparator.md +202 -202
- package/skills/builtin/skill-creator/agents/grader.md +223 -223
- package/skills/builtin/skill-creator/assets/eval_review.html +146 -146
- package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -471
- package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -1325
- package/skills/builtin/skill-creator/references/schemas.md +430 -430
- package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -401
- package/skills/builtin/skill-creator/scripts/generate_report.py +326 -326
- package/skills/builtin/skill-creator/scripts/improve_description.py +247 -247
- package/skills/builtin/skill-creator/scripts/package_skill.py +136 -136
- package/skills/builtin/skill-creator/scripts/quick_validate.py +102 -102
- package/skills/builtin/skill-creator/scripts/run_eval.py +310 -310
- package/skills/builtin/skill-creator/scripts/run_loop.py +328 -328
- package/skills/builtin/skill-creator/scripts/utils.py +47 -47
- package/skills/builtin/web-annotations/SKILL.md +93 -93
- package/src/mcp/LICENSE.mcp-cli +21 -21
- package/dist/apps/chat-ui/assets/index-DwHJfmiF.js +0 -173
- package/dist/apps/chat-vscode-web/assets/index-BAMxIaI_.js +0 -41
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.9.13.vsix +0 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
const promiseCompletePolicy = {
|
|
2
|
+
mode: 'any',
|
|
3
|
+
conditions: [{ id: 'promise-complete', type: 'pibo.loop.promise-complete' }],
|
|
4
|
+
};
|
|
5
|
+
const goalStatusPolicy = {
|
|
6
|
+
mode: 'any',
|
|
7
|
+
conditions: [{ id: 'goal-status', type: 'pibo.loop.goal-status' }],
|
|
8
|
+
};
|
|
9
|
+
const singleRunPolicy = {
|
|
10
|
+
mode: 'any',
|
|
11
|
+
conditions: [{ id: 'max-iterations', type: 'pibo.loop.max-iterations' }],
|
|
12
|
+
};
|
|
13
|
+
function markdown(strings) {
|
|
14
|
+
return String.raw(strings).replaceAll('\\`', '`');
|
|
15
|
+
}
|
|
16
|
+
export const BUILT_IN_LOOP_JOB_TEMPLATES = [
|
|
17
|
+
{
|
|
18
|
+
id: 'goal-objective',
|
|
19
|
+
name: 'Goal objective',
|
|
20
|
+
description: 'Default same-session goal loop: keep pursuing the full objective across turns until completion is proven or another stop condition is satisfied.',
|
|
21
|
+
category: 'general',
|
|
22
|
+
job: {
|
|
23
|
+
mode: 'goal',
|
|
24
|
+
name: 'Goal loop',
|
|
25
|
+
description: 'Long-running objective continued in one Pibo Session.',
|
|
26
|
+
prompt: markdown `# Objective
|
|
27
|
+
|
|
28
|
+
<Describe the complete requested end state.>
|
|
29
|
+
|
|
30
|
+
# Success criteria
|
|
31
|
+
|
|
32
|
+
- <Observable completion criterion>
|
|
33
|
+
- <Required verification>
|
|
34
|
+
- <Behavior that must not regress>
|
|
35
|
+
|
|
36
|
+
# Constraints
|
|
37
|
+
|
|
38
|
+
- <Scope, safety, or approval boundary>`,
|
|
39
|
+
stopPolicy: goalStatusPolicy,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'prd-single-story-standard',
|
|
44
|
+
name: 'PRD single story standard',
|
|
45
|
+
description: 'Legacy Ralph loop: pick the highest-priority failing PRD user story, implement exactly one story, test, commit, update progress, then stop or continue on the next run.',
|
|
46
|
+
category: 'prd',
|
|
47
|
+
job: {
|
|
48
|
+
mode: 'ralph',
|
|
49
|
+
name: 'Ralph PRD single story',
|
|
50
|
+
description: 'One PRD user story per Loop iteration.',
|
|
51
|
+
prompt: markdown `# Ralph Auftrag: <Project / Change Name>
|
|
52
|
+
|
|
53
|
+
## Worktree
|
|
54
|
+
|
|
55
|
+
Work from the host worktree, not from a container copy:
|
|
56
|
+
|
|
57
|
+
\`\`\`bash
|
|
58
|
+
cd <host-worktree>
|
|
59
|
+
\`\`\`
|
|
60
|
+
|
|
61
|
+
Branch: \`<branch-name>\`
|
|
62
|
+
Base: \`<base-branch-or-commit>\`
|
|
63
|
+
PRDs: \`<path-to-prds>/prd_*.json\`
|
|
64
|
+
Progress log: \`<path-to-prds>/progress.txt\`
|
|
65
|
+
|
|
66
|
+
If a container is required for build, gateway, or browser checks, use it only for running commands. Edit files and run git commands in the host worktree. Do not edit \`/app\` inside a container.
|
|
67
|
+
|
|
68
|
+
## Ralph Agent Instructions
|
|
69
|
+
|
|
70
|
+
You are an autonomous coding agent working on a software project.
|
|
71
|
+
|
|
72
|
+
### Your Task
|
|
73
|
+
|
|
74
|
+
1. Work from the host worktree above.
|
|
75
|
+
2. Read all PRD JSON files matching \`<path-to-prds>/prd_*.json\`.
|
|
76
|
+
3. Read the progress log. If it does not exist, create it.
|
|
77
|
+
4. Read the \`## Codebase Patterns\` section at the top of the progress log if present.
|
|
78
|
+
5. Pick the highest-priority user story where \`passes: false\`.
|
|
79
|
+
6. Implement that single user story only.
|
|
80
|
+
7. Run quality checks:
|
|
81
|
+
- Always run \`npm run typecheck\`.
|
|
82
|
+
- Run relevant tests for touched areas.
|
|
83
|
+
- For UI stories, run browser verification in the configured dev container/browser environment.
|
|
84
|
+
8. If checks pass, update the PRD JSON to set \`passes: true\` for the completed story.
|
|
85
|
+
9. Commit all changes from the host worktree with message:
|
|
86
|
+
\`feat: [Story ID] - [Story Title]\`
|
|
87
|
+
10. Append your progress to the progress log.
|
|
88
|
+
|
|
89
|
+
### Progress Report Format
|
|
90
|
+
|
|
91
|
+
Append to the progress log. Never replace; always append.
|
|
92
|
+
|
|
93
|
+
\`\`\`md
|
|
94
|
+
## [Date/Time] - [Story ID]
|
|
95
|
+
- What was implemented
|
|
96
|
+
- Files changed
|
|
97
|
+
- Quality checks run
|
|
98
|
+
- Browser verification, if UI changed
|
|
99
|
+
- **Learnings for future iterations:**
|
|
100
|
+
- Patterns discovered
|
|
101
|
+
- Gotchas encountered
|
|
102
|
+
- Useful context
|
|
103
|
+
---
|
|
104
|
+
\`\`\`
|
|
105
|
+
|
|
106
|
+
### Consolidate Patterns
|
|
107
|
+
|
|
108
|
+
If you discover a reusable pattern, add it to the \`## Codebase Patterns\` section at the top of the progress log. Only add general reusable patterns, not story-specific notes.
|
|
109
|
+
|
|
110
|
+
## Quality Requirements
|
|
111
|
+
|
|
112
|
+
- All commits must pass quality checks.
|
|
113
|
+
- Do not commit broken code.
|
|
114
|
+
- Keep changes focused and minimal.
|
|
115
|
+
- Follow existing code patterns.
|
|
116
|
+
- For UI stories, browser verification is mandatory.
|
|
117
|
+
|
|
118
|
+
## Stop Condition
|
|
119
|
+
|
|
120
|
+
After completing one user story, check whether all stories in all PRD JSON files have \`passes: true\`.
|
|
121
|
+
|
|
122
|
+
If all stories are complete and passing, reply with the XML completion marker on its own line. Compose it from the opening tag \`<promise>\`, the word \`COMPLETE\`, and the closing tag \`</promise>\`.
|
|
123
|
+
|
|
124
|
+
Do not quote, negate, explain, or mention that literal marker unless all stories are complete and you intend to stop the job. If any story remains with \`passes: false\`, end normally so another iteration can pick up the next story and say only that the completion marker was omitted.`,
|
|
125
|
+
stopPolicy: promiseCompletePolicy,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'prd-batch-stories',
|
|
130
|
+
name: 'PRD batch stories',
|
|
131
|
+
description: 'Batch loop: implement several failing PRD user stories in priority order in one Loop run, committing after each completed story.',
|
|
132
|
+
category: 'prd',
|
|
133
|
+
job: {
|
|
134
|
+
mode: 'ralph',
|
|
135
|
+
name: 'Ralph PRD batch',
|
|
136
|
+
description: 'Multiple PRD user stories per Loop run.',
|
|
137
|
+
prompt: markdown `# Ralph Auftrag: <Project / Change Name> Batch
|
|
138
|
+
|
|
139
|
+
## Worktree
|
|
140
|
+
|
|
141
|
+
Work from the host worktree:
|
|
142
|
+
|
|
143
|
+
\`\`\`bash
|
|
144
|
+
cd <host-worktree>
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
PRDs: \`<path-to-prds>/prd_*.json\`
|
|
148
|
+
Progress log: \`<path-to-prds>/progress.txt\`
|
|
149
|
+
Batch limit: \`<max-stories-this-run>\`
|
|
150
|
+
|
|
151
|
+
## Task
|
|
152
|
+
|
|
153
|
+
1. Read the PRD JSON files and progress log.
|
|
154
|
+
2. Work through failing user stories in priority order.
|
|
155
|
+
3. Complete up to \`<max-stories-this-run>\` stories in this run.
|
|
156
|
+
4. Keep each story isolated:
|
|
157
|
+
- implement one story;
|
|
158
|
+
- run relevant checks;
|
|
159
|
+
- set that story's \`passes\` to \`true\` only after checks pass;
|
|
160
|
+
- commit with \`feat: [Story ID] - [Story Title]\`;
|
|
161
|
+
- append a progress-log entry.
|
|
162
|
+
5. Stop early if a story is blocked, ambiguous, or tests fail. Do not continue with later stories after a failed story.
|
|
163
|
+
|
|
164
|
+
## Quality Requirements
|
|
165
|
+
|
|
166
|
+
- Always run \`npm run typecheck\` before each story commit unless the repository has a documented narrower check for this batch.
|
|
167
|
+
- Run relevant tests for touched areas.
|
|
168
|
+
- Browser verification is mandatory for UI changes.
|
|
169
|
+
- Keep changes focused; do not bundle unrelated refactors.
|
|
170
|
+
|
|
171
|
+
## Stop Condition
|
|
172
|
+
|
|
173
|
+
If all stories in all PRD JSON files are complete and passing, reply with the XML completion marker on its own line. Compose it from the opening tag \`<promise>\`, the word \`COMPLETE\`, and the closing tag \`</promise>\`.
|
|
174
|
+
|
|
175
|
+
Do not quote, negate, explain, or mention that literal marker unless all stories are complete and you intend to stop the job. Otherwise report the stories completed and the next remaining failing story, and say only that the completion marker was omitted.`,
|
|
176
|
+
stopPolicy: promiseCompletePolicy,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 'single-run-objective',
|
|
181
|
+
name: 'Single-run objective',
|
|
182
|
+
description: 'Non-PRD template for one focused objective with explicit done criteria. Stops after one completed run attempt by max-iterations.',
|
|
183
|
+
category: 'general',
|
|
184
|
+
job: {
|
|
185
|
+
mode: 'ralph',
|
|
186
|
+
name: 'Ralph single-run objective',
|
|
187
|
+
description: 'One focused non-PRD objective.',
|
|
188
|
+
maxIterations: 1,
|
|
189
|
+
stopPolicy: singleRunPolicy,
|
|
190
|
+
prompt: markdown `# Ralph Auftrag: <Objective>
|
|
191
|
+
|
|
192
|
+
## Worktree
|
|
193
|
+
|
|
194
|
+
\`\`\`bash
|
|
195
|
+
cd <host-worktree>
|
|
196
|
+
\`\`\`
|
|
197
|
+
|
|
198
|
+
Branch: \`<branch-name>\`
|
|
199
|
+
|
|
200
|
+
## Objective
|
|
201
|
+
|
|
202
|
+
<Describe the concrete outcome.>
|
|
203
|
+
|
|
204
|
+
## Done Criteria
|
|
205
|
+
|
|
206
|
+
- <Pass/fail criterion 1>
|
|
207
|
+
- <Pass/fail criterion 2>
|
|
208
|
+
- <Required verification command or manual check>
|
|
209
|
+
|
|
210
|
+
## Instructions
|
|
211
|
+
|
|
212
|
+
1. Inspect the relevant code and docs before editing.
|
|
213
|
+
2. State assumptions in code comments or docs only when they matter for maintainers.
|
|
214
|
+
3. Implement the smallest focused change that satisfies the done criteria.
|
|
215
|
+
4. Run \`npm run typecheck\` and relevant tests.
|
|
216
|
+
5. Commit with a concise message if checks pass.
|
|
217
|
+
6. End with a short report listing files changed and verification run.
|
|
218
|
+
|
|
219
|
+
This is not a PRD loop. Do not edit PRD JSON progress unless the objective explicitly asks for it.`,
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
];
|
|
223
|
+
export function listLoopJobTemplates() {
|
|
224
|
+
return BUILT_IN_LOOP_JOB_TEMPLATES.map((template) => cloneTemplate(template));
|
|
225
|
+
}
|
|
226
|
+
export function getLoopJobTemplate(id) {
|
|
227
|
+
const template = BUILT_IN_LOOP_JOB_TEMPLATES.find((item) => item.id === id);
|
|
228
|
+
return template ? cloneTemplate(template) : undefined;
|
|
229
|
+
}
|
|
230
|
+
function cloneTemplate(template) {
|
|
231
|
+
return JSON.parse(JSON.stringify(template));
|
|
232
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { StringEnum, Type } from '@earendil-works/pi-ai';
|
|
2
|
+
import { defineTool } from '@earendil-works/pi-coding-agent';
|
|
3
|
+
import { goalActiveTimeSeconds, goalCanStartNextTurn, goalElapsedWallClockSeconds, goalRemainingTokens } from './accounting.js';
|
|
4
|
+
import { createDefaultPiboLoopStore } from './store.js';
|
|
5
|
+
export const PIBO_GOAL_TOOL_NAMES = ['get_goal', 'create_goal', 'update_goal'];
|
|
6
|
+
let configuredStorePath;
|
|
7
|
+
export function configurePiboGoalToolStorePath(path) {
|
|
8
|
+
configuredStorePath = path;
|
|
9
|
+
}
|
|
10
|
+
function toolResult(value, isError = false) {
|
|
11
|
+
return {
|
|
12
|
+
content: [{ type: 'text', text: JSON.stringify(value, null, 2) }],
|
|
13
|
+
details: value,
|
|
14
|
+
...(isError ? { isError: true } : {}),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function errorResult(error) {
|
|
18
|
+
return toolResult({ ok: false, error: error instanceof Error ? error.message : String(error) }, true);
|
|
19
|
+
}
|
|
20
|
+
function requireSessionContext(context) {
|
|
21
|
+
const piboSessionId = context.piboSessionId?.trim();
|
|
22
|
+
if (!piboSessionId)
|
|
23
|
+
throw new Error('Goal tools require the current Pibo Session ID');
|
|
24
|
+
return {
|
|
25
|
+
piboSessionId,
|
|
26
|
+
piboRoomId: context.piboRoomId?.trim() || undefined,
|
|
27
|
+
profileName: context.profileName?.trim() || 'base',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function positiveInteger(value, field) {
|
|
31
|
+
if (value === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
if (!Number.isInteger(value) || value < 1)
|
|
34
|
+
throw new Error(`${field} must be a positive integer`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
function nonNegativeInteger(value, field) {
|
|
38
|
+
if (value === undefined)
|
|
39
|
+
return undefined;
|
|
40
|
+
if (!Number.isInteger(value) || value < 0)
|
|
41
|
+
throw new Error(`${field} must be a non-negative integer`);
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
function goalPayload(job) {
|
|
45
|
+
const tokenBudget = job.tokenBudget;
|
|
46
|
+
return {
|
|
47
|
+
goalId: job.id,
|
|
48
|
+
objective: job.prompt,
|
|
49
|
+
status: effectiveGoalStatus(job),
|
|
50
|
+
budgetType: tokenBudget === undefined ? 'unbounded' : 'soft',
|
|
51
|
+
tokenBudget: tokenBudget ?? null,
|
|
52
|
+
tokenReserve: job.tokenReserve ?? 0,
|
|
53
|
+
tokensUsed: job.state.tokensUsed ?? 0,
|
|
54
|
+
remainingTokens: goalRemainingTokens(job) ?? null,
|
|
55
|
+
canStartNextTurn: goalCanStartNextTurn(job),
|
|
56
|
+
activeAgentTimeSeconds: goalActiveTimeSeconds(job),
|
|
57
|
+
elapsedWallClockSeconds: goalElapsedWallClockSeconds(job),
|
|
58
|
+
goalStartedAt: job.state.goalStartedAt ?? null,
|
|
59
|
+
goalEndedAt: job.state.goalEndedAt ?? null,
|
|
60
|
+
wallClockIncludesPausedTime: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function effectiveGoalStatus(job) {
|
|
64
|
+
return job.state.goalStatus ?? (job.enabled ? 'active' : 'paused');
|
|
65
|
+
}
|
|
66
|
+
async function withStore(options, action) {
|
|
67
|
+
if (options.store)
|
|
68
|
+
return await action(options.store);
|
|
69
|
+
const store = createDefaultPiboLoopStore({ path: configuredStorePath });
|
|
70
|
+
try {
|
|
71
|
+
return await action(store);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
store.close();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function createGetGoalTool(context, options) {
|
|
78
|
+
return defineTool({
|
|
79
|
+
name: 'get_goal',
|
|
80
|
+
label: 'Get Goal',
|
|
81
|
+
description: 'Get the current goal for this Pibo Session, including soft-budget risk, per-turn reserve, active agent time, and wall-clock elapsed time.',
|
|
82
|
+
promptSnippet: 'Use get_goal when you need the authoritative persisted status or accounting for the current Pibo Session goal.',
|
|
83
|
+
parameters: Type.Object({}),
|
|
84
|
+
async execute() {
|
|
85
|
+
try {
|
|
86
|
+
const { piboSessionId } = requireSessionContext(context);
|
|
87
|
+
return await withStore(options, (store) => {
|
|
88
|
+
const job = store.getLatestGoalForSession(piboSessionId);
|
|
89
|
+
return toolResult({ ok: true, goal: job ? goalPayload(job) : null });
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return errorResult(error);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function createCreateGoalTool(context, options) {
|
|
99
|
+
return defineTool({
|
|
100
|
+
name: 'create_goal',
|
|
101
|
+
label: 'Create Goal',
|
|
102
|
+
description: 'Create an active persisted Goal Loop for this Pibo Session only when explicitly requested. Fails while this session already has an unfinished goal.',
|
|
103
|
+
promptSnippet: 'Call create_goal only when the user or system explicitly requests a persistent goal. Do not infer a goal from an ordinary task.',
|
|
104
|
+
parameters: Type.Object({
|
|
105
|
+
objective: Type.String({ description: 'Concrete objective to pursue across automatic continuations.' }),
|
|
106
|
+
token_budget: Type.Optional(Type.Number({ description: 'Optional soft token budget. Usage arrives after each model response, so the final turn can overshoot.' })),
|
|
107
|
+
token_reserve: Type.Optional(Type.Number({ description: 'Optional non-negative minimum remaining tokens required before Pibo starts another turn.' })),
|
|
108
|
+
}),
|
|
109
|
+
async execute(_toolCallId, params) {
|
|
110
|
+
try {
|
|
111
|
+
const session = requireSessionContext(context);
|
|
112
|
+
const objective = params.objective?.trim();
|
|
113
|
+
if (!objective)
|
|
114
|
+
throw new Error('objective is required');
|
|
115
|
+
const tokenBudget = positiveInteger(params.token_budget, 'token_budget');
|
|
116
|
+
const tokenReserve = nonNegativeInteger(params.token_reserve, 'token_reserve');
|
|
117
|
+
return await withStore(options, (store) => {
|
|
118
|
+
const existing = store.getLatestGoalForSession(session.piboSessionId);
|
|
119
|
+
if (existing && effectiveGoalStatus(existing) !== 'complete') {
|
|
120
|
+
throw new Error('cannot create a new goal because this Pibo Session has an unfinished goal; complete the existing goal first');
|
|
121
|
+
}
|
|
122
|
+
const job = store.createJob({
|
|
123
|
+
mode: 'goal',
|
|
124
|
+
enabled: true,
|
|
125
|
+
target: session.piboRoomId ? { kind: 'room', roomId: session.piboRoomId } : { kind: 'default-chat' },
|
|
126
|
+
profile: session.profileName,
|
|
127
|
+
prompt: objective,
|
|
128
|
+
tokenBudget,
|
|
129
|
+
tokenReserve,
|
|
130
|
+
initialPiboSessionId: session.piboSessionId,
|
|
131
|
+
});
|
|
132
|
+
return toolResult({ ok: true, goal: goalPayload(job) });
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
return errorResult(error);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function createUpdateGoalTool(context, options) {
|
|
142
|
+
return defineTool({
|
|
143
|
+
name: 'update_goal',
|
|
144
|
+
label: 'Update Goal',
|
|
145
|
+
description: 'Mark the current goal complete or genuinely blocked. Complete requires verified achievement. Blocked requires the same impasse for at least three consecutive goal turns.',
|
|
146
|
+
promptSnippet: 'Use update_goal only with status complete after a requirement-by-requirement completion audit, or blocked after the strict repeated-blocker audit.',
|
|
147
|
+
parameters: Type.Object({
|
|
148
|
+
status: StringEnum(['complete', 'blocked'], { description: 'Terminal status for the current goal.' }),
|
|
149
|
+
}),
|
|
150
|
+
async execute(_toolCallId, params) {
|
|
151
|
+
try {
|
|
152
|
+
const { piboSessionId } = requireSessionContext(context);
|
|
153
|
+
if (params.status !== 'complete' && params.status !== 'blocked')
|
|
154
|
+
throw new Error('status must be complete or blocked');
|
|
155
|
+
const status = params.status;
|
|
156
|
+
return await withStore(options, (store) => {
|
|
157
|
+
const existing = store.getLatestGoalForSession(piboSessionId);
|
|
158
|
+
if (!existing)
|
|
159
|
+
throw new Error('cannot update goal because this Pibo Session has no goal');
|
|
160
|
+
const job = store.updateGoalStatus(existing.id, status);
|
|
161
|
+
if (!job)
|
|
162
|
+
throw new Error('goal no longer exists');
|
|
163
|
+
return toolResult({
|
|
164
|
+
ok: true,
|
|
165
|
+
goal: goalPayload(job),
|
|
166
|
+
...(status === 'complete' && job.tokenBudget !== undefined
|
|
167
|
+
? { completionBudgetReport: `${job.state.tokensUsed ?? 0}/${job.tokenBudget} reported tokens consumed against a soft budget before the current model turn finishes` }
|
|
168
|
+
: {}),
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
return errorResult(error);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
export function createPiboGoalToolDefinitions(context, options = {}) {
|
|
179
|
+
return [
|
|
180
|
+
createGetGoalTool(context, options),
|
|
181
|
+
createCreateGoalTool(context, options),
|
|
182
|
+
createUpdateGoalTool(context, options),
|
|
183
|
+
];
|
|
184
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,65 +14,65 @@ const EXAMPLE_CONFIG = {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
export function printConfigHelp() {
|
|
17
|
-
console.log(`
|
|
18
|
-
MCP server configuration
|
|
19
|
-
|
|
20
|
-
Commands:
|
|
21
|
-
pibo mcp config init Create mcp_servers.json if missing
|
|
22
|
-
pibo mcp config path Print the config path that will be used
|
|
23
|
-
pibo mcp config paths Show config path lookup order
|
|
24
|
-
pibo mcp config show Print the current config JSON
|
|
25
|
-
pibo mcp config add <name> <json> Add or replace one server
|
|
26
|
-
pibo mcp config describe <name> "<text>" Add or update an agent-facing description
|
|
27
|
-
pibo mcp config remove <name> Remove one server
|
|
28
|
-
pibo mcp config schema Show server JSON schema and examples
|
|
29
|
-
pibo mcp config help Show this help
|
|
17
|
+
console.log(`
|
|
18
|
+
MCP server configuration
|
|
19
|
+
|
|
20
|
+
Commands:
|
|
21
|
+
pibo mcp config init Create mcp_servers.json if missing
|
|
22
|
+
pibo mcp config path Print the config path that will be used
|
|
23
|
+
pibo mcp config paths Show config path lookup order
|
|
24
|
+
pibo mcp config show Print the current config JSON
|
|
25
|
+
pibo mcp config add <name> <json> Add or replace one server
|
|
26
|
+
pibo mcp config describe <name> "<text>" Add or update an agent-facing description
|
|
27
|
+
pibo mcp config remove <name> Remove one server
|
|
28
|
+
pibo mcp config schema Show server JSON schema and examples
|
|
29
|
+
pibo mcp config help Show this help
|
|
30
30
|
`);
|
|
31
31
|
}
|
|
32
32
|
export function printConfigPaths() {
|
|
33
|
-
console.log(`
|
|
34
|
-
MCP config lookup order:
|
|
35
|
-
1. -c/--config <path>
|
|
36
|
-
2. MCP_CONFIG_PATH
|
|
37
|
-
3. ./mcp_servers.json
|
|
38
|
-
4. ~/.mcp_servers.json
|
|
39
|
-
5. ~/.config/mcp/mcp_servers.json
|
|
33
|
+
console.log(`
|
|
34
|
+
MCP config lookup order:
|
|
35
|
+
1. -c/--config <path>
|
|
36
|
+
2. MCP_CONFIG_PATH
|
|
37
|
+
3. ./mcp_servers.json
|
|
38
|
+
4. ~/.mcp_servers.json
|
|
39
|
+
5. ~/.config/mcp/mcp_servers.json
|
|
40
40
|
`);
|
|
41
41
|
}
|
|
42
42
|
export function printConfigSchema() {
|
|
43
|
-
console.log(`
|
|
44
|
-
Server schema:
|
|
45
|
-
Stdio server:
|
|
46
|
-
{
|
|
47
|
-
"command": "npx",
|
|
48
|
-
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
|
|
49
|
-
"env": { "TOKEN": "\${TOKEN}" },
|
|
50
|
-
"cwd": ".",
|
|
51
|
-
"allowedTools": ["read_*"],
|
|
52
|
-
"disabledTools": ["write_*"],
|
|
53
|
-
"pibo": {
|
|
54
|
-
"description": "Access project files through the configured filesystem MCP server.",
|
|
55
|
-
"descriptionSource": "user"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
HTTP server:
|
|
60
|
-
{
|
|
61
|
-
"url": "https://example.com/mcp",
|
|
62
|
-
"headers": { "Authorization": "Bearer \${TOKEN}" },
|
|
63
|
-
"allowedTools": ["search_*"],
|
|
64
|
-
"disabledTools": ["dangerous_*"]
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Full example:
|
|
68
|
-
${JSON.stringify(EXAMPLE_CONFIG, null, 2)}
|
|
69
|
-
|
|
70
|
-
Examples:
|
|
71
|
-
pibo mcp config init
|
|
72
|
-
pibo mcp config add filesystem '{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","."]}'
|
|
73
|
-
pibo mcp config add deepwiki '{"url":"https://mcp.deepwiki.com/mcp"}'
|
|
74
|
-
pibo mcp config describe filesystem "Access project files through the configured filesystem MCP server."
|
|
75
|
-
pibo mcp config remove filesystem
|
|
43
|
+
console.log(`
|
|
44
|
+
Server schema:
|
|
45
|
+
Stdio server:
|
|
46
|
+
{
|
|
47
|
+
"command": "npx",
|
|
48
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
|
|
49
|
+
"env": { "TOKEN": "\${TOKEN}" },
|
|
50
|
+
"cwd": ".",
|
|
51
|
+
"allowedTools": ["read_*"],
|
|
52
|
+
"disabledTools": ["write_*"],
|
|
53
|
+
"pibo": {
|
|
54
|
+
"description": "Access project files through the configured filesystem MCP server.",
|
|
55
|
+
"descriptionSource": "user"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
HTTP server:
|
|
60
|
+
{
|
|
61
|
+
"url": "https://example.com/mcp",
|
|
62
|
+
"headers": { "Authorization": "Bearer \${TOKEN}" },
|
|
63
|
+
"allowedTools": ["search_*"],
|
|
64
|
+
"disabledTools": ["dangerous_*"]
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Full example:
|
|
68
|
+
${JSON.stringify(EXAMPLE_CONFIG, null, 2)}
|
|
69
|
+
|
|
70
|
+
Examples:
|
|
71
|
+
pibo mcp config init
|
|
72
|
+
pibo mcp config add filesystem '{"command":"npx","args":["-y","@modelcontextprotocol/server-filesystem","."]}'
|
|
73
|
+
pibo mcp config add deepwiki '{"url":"https://mcp.deepwiki.com/mcp"}'
|
|
74
|
+
pibo mcp config describe filesystem "Access project files through the configured filesystem MCP server."
|
|
75
|
+
pibo mcp config remove filesystem
|
|
76
76
|
`);
|
|
77
77
|
}
|
|
78
78
|
async function readRawConfig(path) {
|
package/dist/mcp/index.js
CHANGED
|
@@ -314,27 +314,27 @@ function parseArgs(args) {
|
|
|
314
314
|
* Print help message
|
|
315
315
|
*/
|
|
316
316
|
function printHelp() {
|
|
317
|
-
console.log(`
|
|
318
|
-
pibo mcp (mcp-cli v${VERSION}) - A lightweight CLI for MCP servers
|
|
319
|
-
|
|
320
|
-
Commands:
|
|
321
|
-
pibo mcp List configured servers and tools
|
|
322
|
-
pibo mcp info <server> Show server tools
|
|
323
|
-
pibo mcp info <server> <tool> Show one tool schema
|
|
324
|
-
pibo mcp grep <pattern> Search tool names
|
|
325
|
-
pibo mcp call <server> <tool> [json] Call one tool
|
|
326
|
-
pibo mcp config Discover config commands
|
|
327
|
-
pibo mcp registry Discover curated server presets
|
|
328
|
-
|
|
329
|
-
Options:
|
|
330
|
-
-v, --version Show version number
|
|
331
|
-
-d, --with-descriptions Show full tool descriptions (default: first 100 chars)
|
|
332
|
-
-c, --config <path> Path to mcp_servers.json config file
|
|
333
|
-
--no-setup Skip registry setup commands during install
|
|
334
|
-
|
|
335
|
-
Next:
|
|
336
|
-
pibo mcp config help
|
|
337
|
-
pibo mcp registry help
|
|
317
|
+
console.log(`
|
|
318
|
+
pibo mcp (mcp-cli v${VERSION}) - A lightweight CLI for MCP servers
|
|
319
|
+
|
|
320
|
+
Commands:
|
|
321
|
+
pibo mcp List configured servers and tools
|
|
322
|
+
pibo mcp info <server> Show server tools
|
|
323
|
+
pibo mcp info <server> <tool> Show one tool schema
|
|
324
|
+
pibo mcp grep <pattern> Search tool names
|
|
325
|
+
pibo mcp call <server> <tool> [json] Call one tool
|
|
326
|
+
pibo mcp config Discover config commands
|
|
327
|
+
pibo mcp registry Discover curated server presets
|
|
328
|
+
|
|
329
|
+
Options:
|
|
330
|
+
-v, --version Show version number
|
|
331
|
+
-d, --with-descriptions Show full tool descriptions (default: first 100 chars)
|
|
332
|
+
-c, --config <path> Path to mcp_servers.json config file
|
|
333
|
+
--no-setup Skip registry setup commands during install
|
|
334
|
+
|
|
335
|
+
Next:
|
|
336
|
+
pibo mcp config help
|
|
337
|
+
pibo mcp registry help
|
|
338
338
|
`);
|
|
339
339
|
}
|
|
340
340
|
/**
|
package/dist/mcp/registry.js
CHANGED
|
@@ -17,17 +17,17 @@ function buildServerConfig(entry) {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
function printRegistryHelp() {
|
|
20
|
-
console.log(`
|
|
21
|
-
MCP server registry
|
|
22
|
-
|
|
23
|
-
Commands:
|
|
24
|
-
pibo mcp registry list List built-in MCP server presets
|
|
25
|
-
pibo mcp registry show <name> Show one preset
|
|
26
|
-
pibo mcp registry doctor <name> Check runtime prerequisites
|
|
27
|
-
pibo mcp registry install <name> Install setup deps and add preset to mcp_servers.json
|
|
28
|
-
pibo mcp registry install <name> --no-setup Only add preset to mcp_servers.json
|
|
29
|
-
pibo mcp registry remove <name> Remove config and local runtime
|
|
30
|
-
pibo mcp registry help Show this help
|
|
20
|
+
console.log(`
|
|
21
|
+
MCP server registry
|
|
22
|
+
|
|
23
|
+
Commands:
|
|
24
|
+
pibo mcp registry list List built-in MCP server presets
|
|
25
|
+
pibo mcp registry show <name> Show one preset
|
|
26
|
+
pibo mcp registry doctor <name> Check runtime prerequisites
|
|
27
|
+
pibo mcp registry install <name> Install setup deps and add preset to mcp_servers.json
|
|
28
|
+
pibo mcp registry install <name> --no-setup Only add preset to mcp_servers.json
|
|
29
|
+
pibo mcp registry remove <name> Remove config and local runtime
|
|
30
|
+
pibo mcp registry help Show this help
|
|
31
31
|
`);
|
|
32
32
|
}
|
|
33
33
|
function printEntry(entry) {
|
package/dist/pi-packages/cli.js
CHANGED
|
@@ -77,16 +77,16 @@ export async function runPiPackagesCli(argv = process.argv) {
|
|
|
77
77
|
await program.parseAsync(argv);
|
|
78
78
|
}
|
|
79
79
|
function printPiPackagesDiscovery() {
|
|
80
|
-
console.log(`pibo pi-packages - registered Pi Coding Agent packages
|
|
81
|
-
|
|
82
|
-
Commands:
|
|
83
|
-
list List registered packages
|
|
84
|
-
add <source> Register a pi.dev URL or local path
|
|
85
|
-
inspect <name-or-id> Show package metadata
|
|
86
|
-
remove <name-or-id> Remove a registration
|
|
87
|
-
doctor Check package sources
|
|
88
|
-
|
|
89
|
-
Next:
|
|
90
|
-
pibo pi-packages list
|
|
80
|
+
console.log(`pibo pi-packages - registered Pi Coding Agent packages
|
|
81
|
+
|
|
82
|
+
Commands:
|
|
83
|
+
list List registered packages
|
|
84
|
+
add <source> Register a pi.dev URL or local path
|
|
85
|
+
inspect <name-or-id> Show package metadata
|
|
86
|
+
remove <name-or-id> Remove a registration
|
|
87
|
+
doctor Check package sources
|
|
88
|
+
|
|
89
|
+
Next:
|
|
90
|
+
pibo pi-packages list
|
|
91
91
|
`);
|
|
92
92
|
}
|