pi-harness-runtime 1.1.166 → 1.1.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +272 -0
- package/CLAUDE.md +77 -0
- package/SECURITY.md +21 -0
- package/TODO-todo-bd-sync.md +124 -0
- package/auto-resume-fix-prompt.md +189 -0
- package/harness/reports/PROJECT_STATE.md +342 -0
- package/harness/reports/PROVIDER_USAGE_RESEARCH.md +115 -0
- package/harness/reports/SESSION_STATUS.md +107 -0
- package/harness/skills-plan/2026-07-12-herdr-moo-skills-adaptation-plan.md +278 -0
- package/harness/skills-plan/2026-07-12-minimax-prompt-step1-sync.md +345 -0
- package/harness/skills-plan/2026-07-12-public-skill-export-and-sync-design.md +504 -0
- package/harness/skills-plan/ACTION-PLAN.md +108 -0
- package/package.json +3 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/dist/extension.d.ts +2 -1
- package/packages/agent-policy/dist/extension.d.ts.map +1 -1
- package/packages/agent-policy/dist/extension.js +8 -3
- package/packages/agent-policy/dist/extension.js.map +1 -1
- package/packages/agent-policy/dist/policy-loader.d.ts.map +1 -1
- package/packages/agent-policy/dist/policy-loader.js +14 -2
- package/packages/agent-policy/dist/policy-loader.js.map +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/agent-policy/src/extension.ts +9 -3
- package/packages/agent-policy/src/policy-loader.ts +16 -2
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
# Agent Instructions
|
|
2
|
+
|
|
3
|
+
## Terminology: Two Task Tracking Systems (CRITICAL)
|
|
4
|
+
|
|
5
|
+
This project has **TWO separate task trackers** with different purposes:
|
|
6
|
+
|
|
7
|
+
| Term | Tool | Purpose |
|
|
8
|
+
|------|------|---------|
|
|
9
|
+
| **bd** / **beads** / **issues** | `bd create`, `bd list`, `bd close` | Issue tracker synced with GitHub issues |
|
|
10
|
+
| **todo** / **todos** / **task list** | `todo` tool (JSON-RPC) | Local task list for in-session tracking |
|
|
11
|
+
|
|
12
|
+
**When in doubt, ASK**: If a user mentions "tasks", "todos", or "track this" without specifying, ask:
|
|
13
|
+
|
|
14
|
+
> **"Did you mean bd (issue tracker) or todo (local task list)?"**
|
|
15
|
+
|
|
16
|
+
### When to use each:
|
|
17
|
+
- **bd (beads)**: Long-lived issues, bugs, feature requests, GitHub-synced items
|
|
18
|
+
- **todo (local task list)**: Short-lived session tasks, step-by-step workflows, immediate action items
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Pre-Commit/Build Checklist
|
|
23
|
+
|
|
24
|
+
**BEFORE any `git commit`, `git push`, or `bench build`:**
|
|
25
|
+
|
|
26
|
+
1. Run `bd ready` to check for pending tasks
|
|
27
|
+
2. Check if any todo-list items are marked as done → **mark them complete** with `bd close <id>`
|
|
28
|
+
3. Ensure all pending tasks are tracked in bd before committing
|
|
29
|
+
4. If todos exist, acknowledge them in response before proceeding
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Check pending todos before commit
|
|
33
|
+
bd ready
|
|
34
|
+
bd list --status pending
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Why**: Agent often builds/commits without checking todos. This causes incomplete tasks to be forgotten.
|
|
38
|
+
|
|
39
|
+
## Versioning Convention
|
|
40
|
+
|
|
41
|
+
**Only patch-level updates (`0.10.x`)** — no minor/major bumps until the app is fully functional.
|
|
42
|
+
|
|
43
|
+
When releasing:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
bun scripts/release-all.ts --release-as patch # default, use this
|
|
47
|
+
bun scripts/release-all.ts --release-as minor # only if explicitly requested
|
|
48
|
+
bun scripts/release-all.ts --release-as major # only if explicitly requested
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Release Tag Convention (CRITICAL)
|
|
52
|
+
|
|
53
|
+
**ALWAYS release a tag after ANY code change.** Use patch version bump (0.10.x → 0.10.x+1).
|
|
54
|
+
|
|
55
|
+
This repo uses tag-based GitHub Actions builds — no CI on push. Every code change should be tagged for release.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# After git push, immediately tag and push:
|
|
59
|
+
git tag v0.10.32 && git push origin v0.10.32
|
|
60
|
+
|
|
61
|
+
# Or use the release script:
|
|
62
|
+
bun scripts/release-all.ts --release-as patch
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Rule**: Every `git push` should be followed by a tag push. No code change should go unreleased.
|
|
66
|
+
|
|
67
|
+
## npm Publish Authentication
|
|
68
|
+
|
|
69
|
+
- **Normal release path: do NOT run local `npm publish`.** Push the code and release tag; GitHub Actions will sync/publish to npm.
|
|
70
|
+
- **GitHub Actions OIDC release path should not require `npm login`.**
|
|
71
|
+
- If a **local/manual npm publish fallback** is needed and `npm whoami` fails, ask the user to run:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm login
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
before retrying the publish.
|
|
78
|
+
- Do not assume a previous local npm login is still valid.
|
|
79
|
+
|
|
80
|
+
## Context-Mode Tool Priority
|
|
81
|
+
|
|
82
|
+
Use tools in this order (highest to lowest priority):
|
|
83
|
+
|
|
84
|
+
1. **`ctx_batch_execute`** — Multiple commands with queries in one call
|
|
85
|
+
2. **`ctx_execute`** — Single command or data derivation
|
|
86
|
+
3. **`ctx_execute_file`** — Read/analyze file before editing
|
|
87
|
+
4. **`ctx_search`** — Query indexed knowledge base
|
|
88
|
+
|
|
89
|
+
**File operations**: Always use `ctx_execute_file` to read/analyze files before editing.
|
|
90
|
+
|
|
91
|
+
## File Copy Rule (Mimic/Clone Between Folders)
|
|
92
|
+
|
|
93
|
+
**When asked to mimic, clone, or copy code/files from one folder to another:**
|
|
94
|
+
|
|
95
|
+
1. **USE `cp` or `sudo cp`** instead of writing files from scratch
|
|
96
|
+
2. **Do NOT write files from scratch** — copying is faster, more accurate, and preserves exact code
|
|
97
|
+
3. **Use `sudo cp` when permissions require it** (different owners, protected directories)
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# ✅ CORRECT - direct copy
|
|
101
|
+
cp /path/to/source/file.ts /path/to/dest/file.ts
|
|
102
|
+
|
|
103
|
+
# ✅ CORRECT - sudo for permission issues
|
|
104
|
+
sudo cp /path/to/source/file.ts /path/to/dest/file.ts
|
|
105
|
+
|
|
106
|
+
# ❌ WRONG - writing from scratch (loses fidelity, wastes time)
|
|
107
|
+
write /path/to/dest/file.ts
|
|
108
|
+
<content>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Why**: Copying preserves exact code including comments, formatting, and subtle details. Writing from scratch introduces drift and incompleteness.
|
|
112
|
+
|
|
113
|
+
## NPM Package Build Issues (Important!)
|
|
114
|
+
|
|
115
|
+
### Bug: Missing `dist/` Directories in Packages
|
|
116
|
+
|
|
117
|
+
**Problem**: When `packages/*/dist/` is gitignored and a package has `.js` imports but no compiled output, the published npm package will crash pi on load with:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
Cannot find module '../packages/notification/dist/notification-center.js'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**Root Cause**:
|
|
124
|
+
|
|
125
|
+
- The main build script (`bun run build`) only compiles packages with `tsconfig.json`
|
|
126
|
+
- If TypeScript is missing from `devDependencies`, `node_modules/.bin/tsc` doesn't exist
|
|
127
|
+
- The build loop silently ignores errors: `|| true`
|
|
128
|
+
- Packages get published WITHOUT their `dist/` directories
|
|
129
|
+
- Runtime imports from `dist/*.js` fail
|
|
130
|
+
|
|
131
|
+
**Solution**:
|
|
132
|
+
|
|
133
|
+
1. Ensure `typescript` is in `devDependencies` (so `tsc` is available)
|
|
134
|
+
2. Run `bun run build` locally BEFORE pushing
|
|
135
|
+
3. Verify `packages/*/dist/` contains compiled `.js` files
|
|
136
|
+
4. Commit the `dist/` output or ensure build succeeds in CI
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Check if dist exists before publishing
|
|
140
|
+
ls packages/notification/dist/
|
|
141
|
+
|
|
142
|
+
# If missing, build and check again
|
|
143
|
+
bun run build
|
|
144
|
+
ls packages/notification/dist/
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Prevention**: Add `typescript` to `devDependencies`:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
bun add -d typescript
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Icon Usage
|
|
154
|
+
|
|
155
|
+
**This is a Node.js CLI daemon — do NOT add React as a dependency for icons.**
|
|
156
|
+
|
|
157
|
+
### Default: ASCII (no extra deps, keeps bundle small)
|
|
158
|
+
|
|
159
|
+
ASCII is the default choice for regular cases — it keeps the bundle small and works everywhere.
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
// Stage indicators
|
|
163
|
+
[>>>] [==>] [###] [---] [OK!]
|
|
164
|
+
|
|
165
|
+
// Status icons
|
|
166
|
+
> write ✓ review ✗ blocked ~ retry
|
|
167
|
+
|
|
168
|
+
// Compact flags (preferred for status lines)
|
|
169
|
+
[P] [W] [R] [F] // plan/write/review/finish
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Never use emoji** — they render inconsistently across terminals and fonts, and CJK terminals display them at double width which breaks layout alignment.
|
|
173
|
+
|
|
174
|
+
### Nice/beautiful icons: Lucide (SVG, no React)
|
|
175
|
+
|
|
176
|
+
Use `lucide` only when you need polished SVG icons for display in a UI (not terminal output).
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
import { FileCode, CheckCircle, XCircle, AlertTriangle } from 'lucide';
|
|
180
|
+
|
|
181
|
+
// Render to SVG string (no React, no DOM)
|
|
182
|
+
const svg = FileCode({ size: 16, strokeWidth: 2 });
|
|
183
|
+
// svg is an HTML string like '<svg width="16" height="16" ...>...</svg>'
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Or use `lucide-static` for pre-built SVG strings — no runtime import:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
// No React, just static SVG strings
|
|
190
|
+
const icon = await readFile('./node_modules/lucide-static/icons/file-code.svg', 'utf8');
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Never use `react-icons`** — it pulls in React as a dependency.
|
|
194
|
+
|
|
195
|
+
## Todo List Rule (CRITICAL)
|
|
196
|
+
|
|
197
|
+
**When you identify 2+ tasks, issues, or jobs — add ALL of them to the task list immediately.**
|
|
198
|
+
|
|
199
|
+
Do NOT just list them in text. Use the `todo` tool to create tracked tasks:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Creating multiple tasks at once (use todo tool, NOT bd!)
|
|
203
|
+
todo create "Fix initialRemotionData not defined"
|
|
204
|
+
todo create "Fix dictionary.title undefined"
|
|
205
|
+
todo create "Replace Film icon with themed icon"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Rule**: If you write something like:
|
|
209
|
+
|
|
210
|
+
- "There are 3 issues: ..."
|
|
211
|
+
- "I found several problems: ..."
|
|
212
|
+
- "Let me fix these: 1) X 2) Y 3) Z"
|
|
213
|
+
- "Here are the tasks to do: ..."
|
|
214
|
+
|
|
215
|
+
**Then you MUST create Todo items for each one.** Single-issue fixes don't need tracking.
|
|
216
|
+
|
|
217
|
+
**Why**: Agents often identify issues verbally but forget to track them. This rule ensures nothing slips through.
|
|
218
|
+
|
|
219
|
+
**IMPORTANT**: The `todo` tool and `bd` commands are DIFFERENT systems. Use `todo` for local task tracking.
|
|
220
|
+
|
|
221
|
+
## Remote Server Commands (SSH)
|
|
222
|
+
|
|
223
|
+
**ALWAYS use detached SSH pattern to prevent long hangs.**
|
|
224
|
+
|
|
225
|
+
### Anti-Pattern (blocks SSH, hangs ~2000s)
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# WRONG - SSH blocks waiting for background process
|
|
229
|
+
ssh user@host "kill old; sleep 2; uvicorn ... &"
|
|
230
|
+
# SSH never returns because it waits for uvicorn
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Correct Pattern (fast exit, process stays on server)
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# CORRECT - SSH exits fast, process continues on server
|
|
237
|
+
ssh -o BatchMode=yes user@host \
|
|
238
|
+
"kill -9 917094 970065 2>/dev/null; sleep 1; \
|
|
239
|
+
cd /home/frappe/amos-saas/backend/services/api && \
|
|
240
|
+
nohup .venv/bin/uvicorn amos_api.main:app --host 0.0.0.0 --port 8100 \
|
|
241
|
+
> /tmp/uvicorn.log 2>&1 & \
|
|
242
|
+
echo 'UVICORN_STARTED'"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Key changes:**
|
|
246
|
+
|
|
247
|
+
- `nohup ... &` — detaches from SSH session
|
|
248
|
+
- `> /tmp/uvicorn.log 2>&1` — captures output to file
|
|
249
|
+
- `echo 'UVICORN_STARTED'` — SSH exits fast with confirmation
|
|
250
|
+
- `-o BatchMode=yes` — non-interactive, fails fast on auth issues
|
|
251
|
+
|
|
252
|
+
**Why this matters**: A bare `&` in SSH keeps the shell open. `nohup` + redirect + `echo` ensures SSH exits immediately while the process runs on the server.
|
|
253
|
+
|
|
254
|
+
**For long-running commands**, add a timeout guard:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
timeout 60s ssh -o BatchMode=yes user@host "long-command; echo DONE"
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Status files
|
|
261
|
+
|
|
262
|
+
The `.harness-status` file is consumed by the pi host, which adds its own UI. Keep daemon output plain ASCII:
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
# ✅ Good — plain ASCII with compact flags
|
|
266
|
+
[P] planning | MiniMax: 5h: 89% left
|
|
267
|
+
[W] coding | MiniMax: 5h: 89% left
|
|
268
|
+
|
|
269
|
+
# ❌ Bad — emoji in machine-readable files (CJK alignment issues)
|
|
270
|
+
🧭 planning | MiniMax: 5h: 89% left
|
|
271
|
+
✍️ coding | MiniMax: 5h: 89% left
|
|
272
|
+
```
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Project Instructions for AI Agents
|
|
2
|
+
|
|
3
|
+
This file provides instructions and context for AI coding agents working on this project.
|
|
4
|
+
|
|
5
|
+
<!-- BEGIN BEADS INTEGRATION v:1 profile:minimal hash:ca08a54f -->
|
|
6
|
+
## Beads Issue Tracker
|
|
7
|
+
|
|
8
|
+
This project uses **bd (beads)** for issue tracking. Run `bd prime` to see full workflow context and commands.
|
|
9
|
+
|
|
10
|
+
### Quick Reference
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
bd ready # Find available work
|
|
14
|
+
bd show <id> # View issue details
|
|
15
|
+
bd update <id> --claim # Claim work
|
|
16
|
+
bd close <id> # Complete work
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Rules
|
|
20
|
+
|
|
21
|
+
- Use `bd` for ALL task tracking — do NOT use TodoWrite, TaskCreate, or markdown TODO lists
|
|
22
|
+
- Run `bd prime` for detailed command reference and session close protocol
|
|
23
|
+
- Use `bd remember` for persistent knowledge — do NOT use MEMORY.md files
|
|
24
|
+
|
|
25
|
+
## Session Completion
|
|
26
|
+
|
|
27
|
+
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
|
|
28
|
+
|
|
29
|
+
**MANDATORY WORKFLOW:**
|
|
30
|
+
|
|
31
|
+
1. **File issues for remaining work** - Create issues for anything that needs follow-up
|
|
32
|
+
2. **Run quality gates** (if code changed) - Tests, linters, builds
|
|
33
|
+
3. **Update issue status** - Close finished work, update in-progress items
|
|
34
|
+
4. **PUSH TO REMOTE** - This is MANDATORY:
|
|
35
|
+
```bash
|
|
36
|
+
git pull --rebase
|
|
37
|
+
bd dolt push
|
|
38
|
+
git push
|
|
39
|
+
git status # MUST show "up to date with origin"
|
|
40
|
+
```
|
|
41
|
+
5. **Clean up** - Clear stashes, prune remote branches
|
|
42
|
+
6. **Verify** - All changes committed AND pushed
|
|
43
|
+
7. **Hand off** - Provide context for next session
|
|
44
|
+
|
|
45
|
+
**CRITICAL RULES:**
|
|
46
|
+
- Work is NOT complete until `git push` succeeds
|
|
47
|
+
- NEVER stop before pushing - that leaves work stranded locally
|
|
48
|
+
- NEVER say "ready to push when you are" - YOU must push
|
|
49
|
+
- If push fails, resolve and retry until it succeeds
|
|
50
|
+
<!-- END BEADS INTEGRATION -->
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Build & Test
|
|
54
|
+
|
|
55
|
+
_Add your build and test commands here_
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Example:
|
|
59
|
+
# npm install
|
|
60
|
+
# npm test
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Architecture Overview
|
|
64
|
+
|
|
65
|
+
_Add a brief overview of your project architecture_
|
|
66
|
+
|
|
67
|
+
## Conventions & Patterns
|
|
68
|
+
|
|
69
|
+
### Git Workflow
|
|
70
|
+
|
|
71
|
+
After running `git status`, **ALWAYS** run `git add --all` before asking about committing. Never assume changes are staged.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git status # inspect changes
|
|
75
|
+
git add --all # stage everything
|
|
76
|
+
git commit # then proceed
|
|
77
|
+
```
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Use this section to tell people about which versions of your project are
|
|
6
|
+
currently being supported with security updates.
|
|
7
|
+
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
| ------- | ------------------ |
|
|
10
|
+
| 5.1.x | :white_check_mark: |
|
|
11
|
+
| 5.0.x | :x: |
|
|
12
|
+
| 4.0.x | :white_check_mark: |
|
|
13
|
+
| < 4.0 | :x: |
|
|
14
|
+
|
|
15
|
+
## Reporting a Vulnerability
|
|
16
|
+
|
|
17
|
+
Use this section to tell people how to report a vulnerability.
|
|
18
|
+
|
|
19
|
+
Tell them where to go, how often they can expect to get an update on a
|
|
20
|
+
reported vulnerability, what to expect if the vulnerability is accepted or
|
|
21
|
+
declined, etc.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# TODO: Complete todo-bd-sync Implementation
|
|
2
|
+
|
|
3
|
+
## Status: Phase 1 & 2 Complete
|
|
4
|
+
|
|
5
|
+
### What was implemented
|
|
6
|
+
|
|
7
|
+
1. **Package structure** (`packages/todo-bd-sync/`)
|
|
8
|
+
- ✅ `src/types.ts` - Type definitions for TodoTask, BdIssue, IdMappingRegistry
|
|
9
|
+
- ✅ `src/detector.ts` - Dependency detection (rpiv-todo, bd CLI)
|
|
10
|
+
- ✅ `src/sync.ts` - Two-way sync logic (todo ↔ bd)
|
|
11
|
+
- ✅ `src/index.ts` - Main API with TodoBdSync class
|
|
12
|
+
- ✅ `src/extension.ts` - pi-coding-agent extension entry
|
|
13
|
+
- ✅ `src/todo-reminder.ts` - Auto-reminder for continuing todos
|
|
14
|
+
- ✅ `package.json` - Package manifest
|
|
15
|
+
|
|
16
|
+
2. **Integration into main extension**
|
|
17
|
+
- ✅ Added import and lazy initialization to `index.ts`
|
|
18
|
+
|
|
19
|
+
3. **Documentation**
|
|
20
|
+
- ✅ `docs/todo-bd-sync.md` - Full documentation with auto-reminder feature
|
|
21
|
+
- ✅ `README.md` - Added section and commands
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## New: Auto-Reminder Feature (Phase 2)
|
|
26
|
+
|
|
27
|
+
### Problem Fixed
|
|
28
|
+
|
|
29
|
+
- **Bug**: LLM completes tasks but stays silent about remaining todos
|
|
30
|
+
- **User had to manually ask**: "continue with todos" or "wrap up"
|
|
31
|
+
|
|
32
|
+
### Solution
|
|
33
|
+
|
|
34
|
+
The `todo-reminder.ts` module injects reminders when todos remain:
|
|
35
|
+
|
|
36
|
+
**Prerequisite**: Tasks must be created with `bd create` (not via `/todo` command).
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// After agent completes a task:
|
|
40
|
+
// Checks bd for remaining todos
|
|
41
|
+
// Injects message:
|
|
42
|
+
"Remaining todos detected:
|
|
43
|
+
[bd-a1b2] Review PR (pending)
|
|
44
|
+
|
|
45
|
+
Please continue with the next pending task or ask the user which to prioritize."
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### How It Works
|
|
49
|
+
|
|
50
|
+
1. Hooks into `agent_end` and `tool_execution_end`
|
|
51
|
+
2. Calls `bd ready --json` to check remaining todos
|
|
52
|
+
3. If pending tasks exist, sends reminder via `pi.sendUserMessage()`
|
|
53
|
+
4. 5-second cooldown to prevent spam
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Remaining Tasks
|
|
58
|
+
|
|
59
|
+
### P1: Test Basic Integration
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Restart pi and test
|
|
63
|
+
pi
|
|
64
|
+
|
|
65
|
+
# Check if todo-bd-sync is enabled
|
|
66
|
+
/bd-todo-status
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### P2: Test Auto-Reminder
|
|
70
|
+
|
|
71
|
+
1. Create a multi-step task via bd:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
bd create "Build API" -p 2
|
|
75
|
+
bd create "Add tests" --parent <parent-id>
|
|
76
|
+
bd create "Deploy" --parent <parent-id>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
2. Ask LLM to work on it:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
Build the API and manage tasks with bd
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
3. After completing a task, verify reminder is injected:
|
|
86
|
+
- Should see message about remaining todos
|
|
87
|
+
- LLM should offer to continue
|
|
88
|
+
|
|
89
|
+
### P3: Tune Reminder Behavior
|
|
90
|
+
|
|
91
|
+
- Adjust cooldown (currently 5 seconds)
|
|
92
|
+
- Customize reminder message template
|
|
93
|
+
- Test with various task counts
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Files Summary
|
|
98
|
+
|
|
99
|
+
| File | Purpose |
|
|
100
|
+
|------|---------|
|
|
101
|
+
| `src/types.ts` | Type definitions |
|
|
102
|
+
| `src/detector.ts` | Check dependencies |
|
|
103
|
+
| `src/sync.ts` | bd CLI integration |
|
|
104
|
+
| `src/todo-reminder.ts` | **NEW: Auto-reminder injection** |
|
|
105
|
+
| `src/index.ts` | Main API |
|
|
106
|
+
| `src/extension.ts` | Extension entry |
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Testing Plan
|
|
111
|
+
|
|
112
|
+
1. **Basic sync**: Create bd issue → verify sync
|
|
113
|
+
2. **Auto-reminder**: Multi-step task → verify reminder appears
|
|
114
|
+
3. **Integration**: Full workflow test
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Notes
|
|
119
|
+
|
|
120
|
+
- The implementation uses lazy imports to avoid breaking if dependencies are missing
|
|
121
|
+
- bd CLI must be installed for full functionality
|
|
122
|
+
- rpiv-todo is optional (fallback mode available)
|
|
123
|
+
- Auto-reminder does NOT modify the overlay (it works fine)
|
|
124
|
+
- Only injects context to prompt LLM to continue
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Auto-Resume Fix After Context Overflow Compaction
|
|
2
|
+
|
|
3
|
+
## Problem Statement
|
|
4
|
+
|
|
5
|
+
After context overflow compaction with `willRetry=false`, the agent does NOT automatically resume. The session pauses waiting for user input, even though context-mode has a resume snapshot that should be delivered.
|
|
6
|
+
|
|
7
|
+
## Root Cause Analysis
|
|
8
|
+
|
|
9
|
+
### The Compaction Flow
|
|
10
|
+
|
|
11
|
+
1. **Context overflow occurs** -> `_checkCompaction()` is called
|
|
12
|
+
2. **For overflow with `stopReason === "stop"`** (the common case):
|
|
13
|
+
- `willRetry = assistantMessage.stopReason !== "stop"` -> **FALSE**
|
|
14
|
+
- Calls `_runAutoCompaction("overflow", false)`
|
|
15
|
+
3. **Inside `_runAutoCompaction`** (line 1685):
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
return this.agent.hasQueuedMessages(); // <- Returns FALSE for overflow case!
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
4. **Result**: Session pauses waiting for user input
|
|
22
|
+
|
|
23
|
+
### Why Context-Mode Resume Wasn't Delivered
|
|
24
|
+
|
|
25
|
+
Context-mode builds resume snapshot in `session_before_compact` and stores it in DB:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
// From extension.js
|
|
29
|
+
pi.on("session_before_compact", () => {
|
|
30
|
+
const snapshot = buildResumeSnapshot(allEvents, { compactCount });
|
|
31
|
+
db.upsertResume(_sessionId, snapshot, allEvents.length);
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
But resume was only injected in `before_agent_start` via the `context` hook:
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
pi.on("before_agent_start", async (event, ctx) => {
|
|
39
|
+
const resume = db.getResume(_sessionId);
|
|
40
|
+
if (resume && !resume.consumed && resume.snapshot) {
|
|
41
|
+
parts.push(resume.snapshot);
|
|
42
|
+
db.markResumeConsumed(_sessionId);
|
|
43
|
+
}
|
|
44
|
+
// ...
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Problem**: `before_agent_start` only fires when a **new prompt is submitted**. After overflow compaction with `willRetry=false`, no prompt is submitted -> resume is never delivered.
|
|
49
|
+
|
|
50
|
+
## Solution Implemented: Post-Compaction Message Queue
|
|
51
|
+
|
|
52
|
+
Added a new extension API `queuePostCompactionMessage()` that allows extensions to queue messages that should be delivered after compaction completes, even when `willRetry=false`.
|
|
53
|
+
|
|
54
|
+
### Flow After Fix
|
|
55
|
+
|
|
56
|
+
1. `session_before_compact` -> Build resume snapshot in DB
|
|
57
|
+
2. `session_compact` -> Queue resume via `ctx.queuePostCompactionMessage()`
|
|
58
|
+
3. After compaction completes -> `drainPostCompactionMessages()` delivers queued messages
|
|
59
|
+
4. Agent continues and delivers resume automatically
|
|
60
|
+
|
|
61
|
+
## Files Changed
|
|
62
|
+
|
|
63
|
+
### 1. `pi-coding-agent/dist/core/extensions/types.d.ts`
|
|
64
|
+
|
|
65
|
+
Added new API to `ExtensionContext` and `ExtensionContextActions`:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// ExtensionContext
|
|
69
|
+
/**
|
|
70
|
+
* Queue a message to be delivered after compaction completes.
|
|
71
|
+
* When willRetry=false (e.g. overflow without context recovery), the agent
|
|
72
|
+
* will continue and deliver these queued messages before pausing for user input.
|
|
73
|
+
* Useful for resuming context-mode's snapshot after overflow compaction.
|
|
74
|
+
*/
|
|
75
|
+
queuePostCompactionMessage(message: { role: string; content: string }): void;
|
|
76
|
+
|
|
77
|
+
// ExtensionContextActions
|
|
78
|
+
queuePostCompactionMessage: (message: { role: string; content: string }) => void;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 2. `pi-coding-agent/dist/core/extensions/runner.js`
|
|
82
|
+
|
|
83
|
+
Added new methods to `ExtensionRunner`:
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// Instance variable
|
|
87
|
+
_postCompactionMessages = [];
|
|
88
|
+
|
|
89
|
+
// Method to queue messages (called from extension context)
|
|
90
|
+
queuePostCompactionMessageFn = (message) => {
|
|
91
|
+
this._postCompactionMessages.push(message);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// Method to get and clear messages (called by agent-session after compaction)
|
|
95
|
+
drainPostCompactionMessages() {
|
|
96
|
+
if (this.staleMessage) {
|
|
97
|
+
return []; // Don't drain if stale
|
|
98
|
+
}
|
|
99
|
+
const messages = this._postCompactionMessages;
|
|
100
|
+
this._postCompactionMessages = [];
|
|
101
|
+
return messages;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Check if runner is stale (without throwing)
|
|
105
|
+
isStale() {
|
|
106
|
+
return Boolean(this.staleMessage);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 3. `pi-coding-agent/dist/core/agent-session.js`
|
|
111
|
+
|
|
112
|
+
Modified `_runAutoCompaction()` to check for and deliver post-compaction messages:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
// After compaction completes (line 1682)
|
|
116
|
+
this._emit({ type: "compaction_end", reason, result, aborted: false, willRetry });
|
|
117
|
+
|
|
118
|
+
if (willRetry) {
|
|
119
|
+
// ... existing retry logic
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check for post-compaction messages from extensions
|
|
124
|
+
if (this._extensionRunner && !this._extensionRunner.isStale()) {
|
|
125
|
+
const postCompactionMessages = this._extensionRunner.drainPostCompactionMessages();
|
|
126
|
+
for (const msg of postCompactionMessages) {
|
|
127
|
+
await this.agent.followUp(msg.content);
|
|
128
|
+
}
|
|
129
|
+
if (postCompactionMessages.length > 0) {
|
|
130
|
+
return true; // Continue to deliver the queued messages
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Fall back to existing behavior
|
|
135
|
+
return this.agent.hasQueuedMessages();
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 4. `context-mode/build/adapters/pi/extension.js`
|
|
139
|
+
|
|
140
|
+
Modified `session_compact` handler to queue resume:
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
pi.on("session_compact", (event, ctx) => {
|
|
144
|
+
try {
|
|
145
|
+
if (!_sessionId)
|
|
146
|
+
return;
|
|
147
|
+
db.incrementCompactCount(_sessionId);
|
|
148
|
+
|
|
149
|
+
// Queue resume snapshot for post-compaction delivery when willRetry=false
|
|
150
|
+
if (!event.willRetry) {
|
|
151
|
+
const resume = db.getResume(_sessionId);
|
|
152
|
+
if (resume && !resume.consumed && resume.snapshot) {
|
|
153
|
+
ctx.queuePostCompactionMessage?.({
|
|
154
|
+
role: "user",
|
|
155
|
+
content: resume.snapshot,
|
|
156
|
+
});
|
|
157
|
+
db.markResumeConsumed(_sessionId);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
// best effort
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Testing
|
|
168
|
+
|
|
169
|
+
To verify the fix works:
|
|
170
|
+
|
|
171
|
+
1. **Trigger context overflow** with a long conversation
|
|
172
|
+
2. **Observe compaction happens automatically**
|
|
173
|
+
3. **Agent continues WITHOUT user input**
|
|
174
|
+
4. **Resume snapshot is delivered** and agent continues working
|
|
175
|
+
|
|
176
|
+
Check with:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
pi
|
|
180
|
+
# Run a long conversation that triggers overflow
|
|
181
|
+
# Verify agent continues automatically after compaction
|
|
182
|
+
/ctx-stats
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Backward Compatibility
|
|
186
|
+
|
|
187
|
+
- The new `queuePostCompactionMessage` API is optional (uses `?.` when calling)
|
|
188
|
+
- Extensions that don't use it continue to work unchanged
|
|
189
|
+
- Existing behavior for `willRetry=true` cases is preserved
|