ultimate-pi 0.1.6 → 0.1.7

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
- description: Full harness bootstrap — obsidian wiki scaffold, CLI tools install, pi extension packages, and verification. Run once per project.
3
- argument-hint: "[--skip-wiki] [--skip-tools] [--force] [--wiki-path <path>]"
2
+ description: Full harness bootstrap — obsidian wiki scaffold, optional self-hosted firecrawl (Docker), CLI tools install, pi extension packages, and verification. Run once per project.
3
+ argument-hint: "[--skip-wiki] [--skip-tools] [--skip-firecrawl-self] [--force] [--wiki-path <path>]"
4
4
  ---
5
5
 
6
6
  # harness-setup — Full Harness Bootstrap
@@ -110,12 +110,140 @@ Run the `/wiki` prompt flow using the user-confirmed `$WIKI_PATH`:
110
110
  ├── meta/ # dashboards, lint reports
111
111
  └── components/ # reusable sub-modules
112
112
  ```
113
- 4. Create `$WIKI_PATH/../.vault-meta/` with vault metadata (at project root level, not inside wiki).
114
- 5. Create vault `AGENTS.md` in project root with mode, purpose, conventions, operations.
113
+ 4. Create `$WIKI_PATH/.vault-meta/` with vault metadata (inside the wiki vault).
114
+ 5. Create vault `AGENTS.md` inside `$WIKI_PATH/` with mode, purpose, conventions, operations.
115
115
  6. Initialize wiki git tracking if not already present.
116
116
  7. Write initial `$WIKI_PATH/hot.md` with setup timestamp.
117
117
  8. **Save resolved path** to `.pi/settings.json` (merge `"wiki_path": "<relative-path>"` into settings) for future sessions.
118
118
 
119
+ ## Step 1.5 — Optional Self-Hosted Firecrawl
120
+
121
+ Ask: "Use self-hosted Firecrawl (local Docker) or cloud (api.firecrawl.dev)? [cloud/self]"
122
+ Default: **cloud**.
123
+
124
+ If user chooses **self**:
125
+
126
+ ### 1.5.1 — Docker Engine Install
127
+
128
+ Check if Docker is already available:
129
+ ```bash
130
+ if ! command -v docker &>/dev/null; then
131
+ # Detect OS and install Docker Engine
132
+ if [ -f /etc/os-release ]; then
133
+ . /etc/os-release
134
+ case "$ID" in
135
+ ubuntu|debian)
136
+ curl -fsSL https://get.docker.com | sh
137
+ ;;
138
+ fedora|rhel|centos)
139
+ curl -fsSL https://get.docker.com | sh
140
+ ;;
141
+ arch)
142
+ pacman -S --noconfirm docker
143
+ ;;
144
+ *)
145
+ echo "Unsupported distro: $ID. Install Docker manually: https://docs.docker.com/engine/install/"
146
+ ;;
147
+ esac
148
+ elif command -v brew &>/dev/null; then
149
+ # macOS — install Docker Desktop via brew
150
+ brew install --cask docker
151
+ else
152
+ echo "Cannot detect OS. Install Docker manually: https://docs.docker.com/engine/install/"
153
+ fi
154
+
155
+ # Enable and start Docker
156
+ sudo systemctl enable --now docker 2>/dev/null || true
157
+
158
+ # Add current user to docker group (no sudo needed)
159
+ sudo usermod -aG docker $USER 2>/dev/null || true
160
+ newgrp docker 2>/dev/null || echo "Docker group added. Restart terminal or run: newgrp docker"
161
+ fi
162
+ ```
163
+
164
+ Verify:
165
+ ```bash
166
+ docker --version
167
+ docker compose version
168
+ ```
169
+
170
+ Block if Docker install fails. Show manual install link.
171
+
172
+ ### 1.5.2 — Set Up Self-Hosted Firecrawl Files
173
+
174
+ The `firecrawl/` directory in the project root contains all self-hosted config:
175
+
176
+ ```
177
+ firecrawl/
178
+ ├── docker-compose.yaml # Multi-service compose (API, Playwright, Redis, RabbitMQ, Postgres, SearXNG)
179
+ ├── README.md # Self-hosted usage docs
180
+ ├── .env.template # Environment variables template
181
+ └── searxng/
182
+ ├── searxng.env # SearXNG-specific env
183
+ └── settings.yml # SearXNG engine config
184
+ ```
185
+
186
+ Create `.env` from template if missing:
187
+ ```bash
188
+ if [ ! -f firecrawl/.env ]; then
189
+ if [ -f firecrawl/.env.template ]; then
190
+ cp firecrawl/.env.template firecrawl/.env
191
+ echo "Created firecrawl/.env from template."
192
+ else
193
+ cat > firecrawl/.env << 'EOF'
194
+ # Firecrawl Self-Hosted Configuration
195
+ PORT=3002
196
+ INTERNAL_PORT=3002
197
+ REDIS_URL=redis://redis:6379
198
+ POSTGRES_USER=postgres
199
+ POSTGRES_PASSWORD=postgres
200
+ POSTGRES_DB=postgres
201
+ USE_DB_AUTHENTICATION=false
202
+ NUM_WORKERS_PER_QUEUE=8
203
+ CRAWL_CONCURRENT_REQUESTS=10
204
+ MAX_CONCURRENT_JOBS=5
205
+ BROWSER_POOL_SIZE=5
206
+ BULL_AUTH_KEY=changeme
207
+ SEARXNG_EXTERNAL_PORT=8080
208
+ # Optional AI: uncomment and set
209
+ # OPENAI_API_KEY=
210
+ # OPENAI_BASE_URL=
211
+ # MODEL_NAME=
212
+ # OLLAMA_BASE_URL=
213
+ EOF
214
+ echo "Created firecrawl/.env with defaults."
215
+ fi
216
+ fi
217
+ ```
218
+
219
+ ### 1.5.3 — Start Services
220
+
221
+ ```bash
222
+ docker compose -f firecrawl/docker-compose.yaml up -d
223
+ ```
224
+
225
+ Wait for health:
226
+ ```bash
227
+ echo "Waiting for services to be healthy..."
228
+ for i in $(seq 1 30); do
229
+ if curl -sf http://localhost:3002/v1/health &>/dev/null; then
230
+ echo "✓ Firecrawl API is healthy"
231
+ break
232
+ fi
233
+ sleep 2
234
+ done
235
+ ```
236
+
237
+ ### 1.5.4 — Verify Self-Hosted Instance
238
+
239
+ ```bash
240
+ curl -sf http://localhost:3002/v1/health && echo "✓ Self-hosted Firecrawl running on :3002" || echo "✗ Firecrawl not healthy yet — check: docker compose -f firecrawl/docker-compose.yaml logs"
241
+ docker compose -f firecrawl/docker-compose.yaml ps
242
+ ```
243
+
244
+ If user chose **cloud**, skip all 1.5.x steps. Just note:
245
+ > "Using cloud Firecrawl. Ensure `FIRECRAWL_API_KEY` is set. Run `firecrawl login` in Step 2.1."
246
+
119
247
  ## Step 2 — Install Global CLI Packages
120
248
 
121
249
  Check each package first. Install only if missing unless `--force` flag.
@@ -133,7 +261,18 @@ Verify:
133
261
  firecrawl --status
134
262
  ```
135
263
 
136
- If not authenticated, offer browser login or API key:
264
+ **If self-hosted mode (Step 1.5 was chosen):** skip cloud auth. Point CLI at local instance:
265
+ ```bash
266
+ export FIRECRAWL_API_URL=http://localhost:3002
267
+ export FIRECRAWL_API_KEY=""
268
+ ```
269
+ Add to shell profile for persistence:
270
+ ```bash
271
+ echo 'export FIRECRAWL_API_URL=http://localhost:3002' >> ~/.bashrc 2>/dev/null
272
+ echo 'export FIRECRAWL_API_KEY=""' >> ~/.bashrc 2>/dev/null
273
+ ```
274
+
275
+ **If cloud mode:** authenticate if not already:
137
276
  ```bash
138
277
  firecrawl login --browser
139
278
  # OR
@@ -324,7 +463,7 @@ Ensure `.gitignore` contains:
324
463
 
325
464
  ### 4.2 — Vault AGENTS.md
326
465
 
327
- If not already created by Step 1, create a minimal `AGENTS.md` in project root:
466
+ If not already created by Step 1, create a minimal `AGENTS.md` inside `$WIKI_PATH/`:
328
467
 
329
468
  ```markdown
330
469
  # ultimate-pi: Agentic Harness Wiki
@@ -337,7 +476,6 @@ Wiki vault path: `$WIKI_PATH`
337
476
 
338
477
  ## Structure
339
478
 
340
- `$WIKI_PATH/`
341
479
  ├── index.md → master catalog
342
480
  ├── log.md → chronological operations
343
481
  ├── hot.md → recent context cache
@@ -348,21 +486,22 @@ Wiki vault path: `$WIKI_PATH`
348
486
  ├── entities/ → tools, platforms, people
349
487
  ├── questions/ → filed research answers
350
488
  ├── consensus/ → debate verdicts
351
- └── flows/ → pipeline diagrams
489
+ ├── flows/ → pipeline diagrams
490
+ └── .vault-meta/ → vault metadata
352
491
 
353
492
  ## Conventions
354
493
 
355
494
  - YAML frontmatter required: type, status, created, updated, tags
356
495
  - Wikilinks: [[Page Name]] format
357
496
  - .raw/ is immutable source storage
358
- - $WIKI_PATH/index.md updated on every ingest
359
- - $WIKI_PATH/log.md is append-only, newest at top
497
+ - index.md updated on every ingest
498
+ - log.md is append-only, newest at top
360
499
 
361
500
  ## Cross-Project Reference
362
501
 
363
502
  Other projects can reference this vault:
364
- 1. Read $WIKI_PATH/hot.md (~500 tokens)
365
- 2. Read $WIKI_PATH/index.md if needed
503
+ 1. Read hot.md (~500 tokens)
504
+ 2. Read index.md if needed
366
505
  3. Drill into specific topics as needed
367
506
 
368
507
  ## Path Resolution
@@ -461,13 +600,16 @@ Output summary table:
461
600
 
462
601
  | .gitignore | ✓/✗ | 6 entries added |
463
602
  | wiki_path in settings | ✓/✗ | Persisted to .pi/settings.json |
603
+ | Firecrawl mode | self/cloud | Self-hosted on :3002 / Cloud (api.firecrawl.dev) |
604
+ | Docker Engine | ✓/✗/N/A | Installed / Not needed (cloud mode) |
464
605
 
465
606
  Next steps:
466
607
  1. If tools missing: re-run with `--force` or install individually
467
608
  2. If wiki not scaffolded: run `/wiki` prompt
468
609
  3. If gh not authenticated: `gh auth login`
469
- 4. First harness run: `/harness "your task description"`
470
- 5. To change wiki path later: update `VAULT_WIKI_PATH` env var or `.pi/settings.json` → `wiki_path` field
610
+ 4. If self-hosted Firecrawl unhealthy: `docker compose -f firecrawl/docker-compose.yaml logs`
611
+ 5. First harness run: `/harness "your task description"`
612
+ 6. To change wiki path later: update `VAULT_WIKI_PATH` env var or `.pi/settings.json` → `wiki_path` field
471
613
 
472
614
  ## Guard Rails
473
615
 
@@ -475,11 +617,13 @@ Next steps:
475
617
  - **Wiki path must be writable**: Check `test -w "$(dirname "$WIKI_PATH")"` before scaffold. Block if not writable.
476
618
  - **Wiki path outside project**: Allowed (e.g., `~/vaults/my-project`). Cross-project vault sharing is supported.
477
619
  - **Node.js >= 18 required**: Some pi packages use modern Node APIs.
620
+ - **Docker required for self-hosted**: Step 1.5 needs Docker Engine + Compose. Block if install fails.
621
+ - **Sufficient RAM for self-hosted**: Firecrawl stack needs ~8GB+ free (API: 8G, Playwright: 4G, others).
478
622
  - **Idempotent**: All checks skip if already installed. `--force` overrides.
479
623
  - **No destructive actions**: Creates files only if missing. Never overwrites existing wiki content.
480
624
  - **Wiki safety**: Scaffold only creates structure, never modifies existing wiki content.
481
625
  - **Partial success**: If some tools fail, report which and continue. User can fix individually.
482
- - **Rate limits**: ctx7 login is optional. firecrawl auth is required for web operations.
626
+ - **Rate limits**: ctx7 login is optional. firecrawl auth is required for cloud; none needed for self-hosted.
483
627
  - **Settings persistence**: The resolved `wiki_path` is saved to `.pi/settings.json` so future sessions auto-detect it.
484
628
 
485
629
  ## Error Handling
@@ -498,6 +642,10 @@ Next steps:
498
642
  | biome.json missing | Create minimal config. |
499
643
  | settings.json not writable | Warn. Wiki path won't persist across sessions. |
500
644
  | No internet | Block for tool installs. Continue for wiki-only steps if `--skip-tools`. |
645
+ | Docker not running | Start: `sudo systemctl start docker`. Block if cannot start. |
646
+ | Docker install fails | Show manual link: https://docs.docker.com/engine/install/. Block Step 1.5, continue rest. |
647
+ | Port 3002 already in use | Warn. User must free port or change `PORT` in `firecrawl/.env`. |
648
+ | Self-hosted health check timeout | Show logs: `docker compose -f firecrawl/docker-compose.yaml logs`. Continue — may need more time. |
501
649
 
502
650
  ## Flags
503
651
 
@@ -505,5 +653,6 @@ Next steps:
505
653
  |------|--------|
506
654
  | `--skip-wiki` | Skip Step 1 (wiki scaffold). Use when wiki already exists. |
507
655
  | `--skip-tools` | Skip Step 2 (CLI tool installs). Use when tools already set up. |
656
+ | `--skip-firecrawl-self` | Skip Step 1.5 (self-hosted Firecrawl). Always use cloud. |
508
657
  | `--force` | Reinstall all tools even if already present. Overwrite existing files. |
509
658
  | `--wiki-path <path>` | Override wiki vault path. Absolute or relative to project root. Bypasses env var and settings. |
package/.pi/settings.json CHANGED
@@ -8,9 +8,9 @@
8
8
  "packages": [
9
9
  "..",
10
10
  "npm:@posthog/pi",
11
- "npm:pi-lean-ctx",
11
+ "npm:context-mode",
12
12
  "npm:@tintinweb/pi-subagents",
13
13
  "npm:@yeliu84/pi-model-router",
14
- "npm:pi-smart-voice-notify"
14
+ "npm:@sting8k/pi-vcc"
15
15
  ]
16
16
  }
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ ## [v0.1.7] — 2026-05-07
6
+
7
+ ### ✨ Features
8
+
9
+ - add /release prompt for version bump and CI/CD publish
10
+ - integrate pi-vcc for deterministic auto-compaction
11
+ - replace pi-lean-ctx with context-mode
12
+ - add soundboard extension, update settings and firecrawl env template
13
+
14
+ ### 🔧 Chores
15
+
16
+ - bump to 0.1.7, move vault AGENTS.md and .vault-meta under VAULT_WIKI_PATH
package/CONTRIBUTING.md CHANGED
@@ -113,4 +113,4 @@ Configurable via env vars (set before launching pi):
113
113
 
114
114
  `wiki`, `wiki-save`, `wiki-query`, `wiki-ingest`, `wiki-lint`, `wiki-fold`, `autoresearch`, `canvas`, `obsidian-markdown`, `obsidian-bases`
115
115
 
116
- > `lean-ctx` is installed as a separate pi package (`pi-lean-ctx`) — not bundled as a skill.
116
+ > `context-mode` is installed as a separate pi package (`npm:context-mode`) — not bundled as a skill.
@@ -1,58 +1,62 @@
1
- # ===== Required ENVS ======
1
+ # Firecrawl Self-Hosted Configuration Template
2
+ # Copy to .env and adjust values as needed.
3
+
4
+ # === API Service ===
2
5
  PORT=3002
6
+ INTERNAL_PORT=3002
3
7
  HOST=0.0.0.0
4
- USE_DB_AUTHENTICATION=false
8
+ ENV=local
5
9
 
6
- # ===== Optional ENVS ======
7
- # OpenAI API key for AI features (JSON formatting, /extract API)
8
- # OPENAI_API_KEY=
10
+ # === Redis ===
11
+ REDIS_URL=redis://redis:6379
9
12
 
10
- # Experimental: Use Ollama
11
- # OLLAMA_BASE_URL=http://localhost:11434/api
12
- # MODEL_NAME=deepseek-r1:7b
13
- # MODEL_EMBEDDING_NAME=nomic-embed-text
13
+ # === PostgreSQL (NUQ) ===
14
+ POSTGRES_USER=postgres
15
+ POSTGRES_PASSWORD=postgres
16
+ POSTGRES_DB=postgres
17
+ POSTGRES_HOST=nuq-postgres
18
+ POSTGRES_PORT=5432
19
+ USE_DB_AUTHENTICATION=false
14
20
 
15
- # Experimental: Use any OpenAI-compatible API
16
- # OPENAI_BASE_URL=https://example.com/v1
21
+ # === Queue / Workers ===
22
+ NUM_WORKERS_PER_QUEUE=8
23
+ CRAWL_CONCURRENT_REQUESTS=10
24
+ MAX_CONCURRENT_JOBS=5
25
+ BROWSER_POOL_SIZE=5
26
+ BULL_AUTH_KEY=changeme
27
+ TEST_API_KEY=
28
+
29
+ # === Playwright Browser Service ===
30
+ PLAYWRIGHT_MICROSERVICE_URL=http://playwright-service:3000/scrape
31
+ BLOCK_MEDIA=false
32
+ ALLOW_LOCAL_WEBHOOKS=true
33
+ MAX_CONCURRENT_PAGES=10
34
+
35
+ # === AI / LLM (optional) ===
17
36
  # OPENAI_API_KEY=
37
+ # OPENAI_BASE_URL=
38
+ # MODEL_NAME=
39
+ # MODEL_EMBEDDING_NAME=
40
+ # OLLAMA_BASE_URL=
18
41
 
19
- # ===== Proxy =====
20
- # PROXY_SERVER can be a full URL (e.g. http://0.1.2.3:1234) or just an IP:port combo
21
- # PROXY_SERVER=
22
- # PROXY_USERNAME=
23
- # PROXY_PASSWORD=
24
-
25
- # ===== /search API =====
26
- # SearXNG instance running alongside Firecrawl in docker-compose
27
- SEARXNG_ENDPOINT=http://searxng:8080
28
- # SEARXNG_ENGINES=
29
- # SEARXNG_CATEGORIES=
30
-
31
- # ===== Authentication / Admin =====
32
- # Supabase not configured (self-hosted doesn't support it yet)
42
+ # === Integrations ===
43
+ # AUTUMN_SECRET_KEY=
44
+ # SLACK_WEBHOOK_URL=
33
45
  # SUPABASE_ANON_TOKEN=
34
46
  # SUPABASE_URL=
35
47
  # SUPABASE_SERVICE_TOKEN=
48
+ # SELF_HOSTED_WEBHOOK_URL=
36
49
 
37
- # Change this for security in production
38
- BULL_AUTH_KEY=CHANGEME
39
-
40
- # ===== PostgreSQL =====
41
- POSTGRES_USER=firecrawl
42
- POSTGRES_PASSWORD=firecrawl_password
43
- POSTGRES_DB=postgres
44
-
45
- # ===== Optional: Telemetry / Logging =====
46
- # POSTHOG_API_KEY=
47
- # POSTHOG_HOST=
48
- # SLACK_WEBHOOK_URL=
49
-
50
- # ===== Optional: Local webhooks =====
51
- # ALLOW_LOCAL_WEBHOOKS=true
50
+ # === Proxy (optional) ===
51
+ # PROXY_SERVER=
52
+ # PROXY_USERNAME=
53
+ # PROXY_PASSWORD=
52
54
 
53
- # ===== Auto-configured by docker-compose (do not change) =====
54
- # REDIS_URL=redis://redis:6379
55
- # PLAYWRIGHT_MICROSERVICE_URL=http://playwright-service:3000/scrape
55
+ # === Logging ===
56
+ LOGGING_LEVEL=info
56
57
 
57
- # ===== Optional: Block media (images, video, etc.) during scrape =====
58
- # BLOCK_MEDIA=true
58
+ # === SearXNG ===
59
+ SEARXNG_ENDPOINT=http://searxng:8080
60
+ SEARXNG_ENGINES=google,bing,duckduckgo
61
+ SEARXNG_CATEGORIES=general,science,technology
62
+ SEARXNG_EXTERNAL_PORT=8080
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ultimate-pi",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Ultimate AI coding harness for pi.dev — extensible skills, Obsidian wiki knowledge layer, compressed context, deterministic output",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -14,7 +14,7 @@
14
14
  "agent-skills",
15
15
  "cursor-sdk",
16
16
  "firecrawl",
17
- "lean-ctx",
17
+ "context-mode",
18
18
  "vcc"
19
19
  ],
20
20
  "license": "MIT",
@@ -54,7 +54,6 @@
54
54
  "dependencies": {
55
55
  "@cursor/sdk": "^1.0.12",
56
56
  "@sting8k/pi-vcc": "^0.3.12",
57
- "asciify-image": "^0.1.10",
58
- "pi-smart-voice-notify": "^0.4.0"
57
+ "asciify-image": "^0.1.10"
59
58
  }
60
59
  }
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  type: concept
3
- status: developing
3
+ status: active
4
4
  created: 2026-05-05
5
+ updated: 2026-05-07
5
6
  tags:
6
7
  - pi-agent
7
8
  - vcc
@@ -11,6 +12,7 @@ related:
11
12
  - "[[pi-vcc-github-repo]]"
12
13
  - "[[context-continuity]]"
13
14
  - "[[structured-compaction]]"
15
+ - "[[adr-027]]"
14
16
  ---
15
17
 
16
18
  # VCC Conversation Compaction for Pi
@@ -0,0 +1,59 @@
1
+ ---
2
+ type: decision
3
+ title: "Replace pi-lean-ctx with context-mode"
4
+ created: 2026-05-07
5
+ updated: 2026-05-07
6
+ tags:
7
+ - decision
8
+ - context-optimization
9
+ - migration
10
+ status: accepted
11
+ related:
12
+ - "[[context-mode]]"
13
+ - "[[lean-ctx]]"
14
+ - "[[agentic-harness-context-enforcement]]"
15
+
16
+ ---
17
+ # Replace pi-lean-ctx with context-mode
18
+
19
+ ## Context
20
+
21
+ ultimate-pi uses `pi-lean-ctx@3.5.1` for context compression via AST parsing, shell pattern compression, and smart read modes. User requested migration to `context-mode` (11K+ GitHub stars, 48K npm downloads/month) as the primary context optimization layer.
22
+
23
+ context-mode uses intercept-and-sandbox architecture: raw tool output never enters the agent's context window. Instead, output is indexed into SQLite FTS5 with BM25 ranking, and the agent queries on demand. Claims 98-99.5% token reduction. Has native Pi Coding Agent extension support with session_start, tool_call, tool_result, and session_before_compact hooks.
24
+
25
+ ## Alternatives Considered
26
+
27
+ 1. **Keep pi-lean-ctx** — mature, 48 MCP tools, agent governance (profiles, budgets, SLOs), Apache 2.0. Less community adoption (924 stars vs 11K).
28
+ 2. **Run both simultaneously** — wiki research notes they solve complementary halves (lean-ctx: compress input, context-mode: sandbox output). However, potential tool conflicts, complexity, and user explicitly requested removal.
29
+ 3. **Replace with context-mode** — stronger community validation, native Pi extension, FTS5 sandbox, "Think in Code" paradigm, session continuity.
30
+
31
+ ## Chosen
32
+
33
+ Replace pi-lean-ctx with context-mode (`npm:context-mode@^1.0.111`).
34
+
35
+ ## Changes Made
36
+
37
+ - `.pi/settings.json`: replaced `"npm:pi-lean-ctx"` with `"npm:context-mode"`
38
+ - `.pi/npm/package.json`: replaced `"pi-lean-ctx": "^3.5.1"` with `"context-mode": "^1.0.111"`
39
+ - `package.json`: replaced `"lean-ctx"` keyword with `"context-mode"`
40
+ - `.pi/extensions/ck-enforce.ts`: **deleted** (lean-ctx-specific grep override, no longer needed)
41
+ - `CONTRIBUTING.md`: updated lean-ctx reference to context-mode
42
+
43
+ ## Tradeoffs
44
+
45
+ | Gained | Lost |
46
+ |--------|------|
47
+ | 11K+ GitHub stars, larger community | 48 MCP tools reduced to 11 |
48
+ | FTS5 sandbox (output never enters context) | AST-based compression (tree-sitter, 18 languages) |
49
+ | Native Pi extension with full hook lifecycle | 90+ shell pattern compression |
50
+ | "Think in Code" paradigm enforcement | Smart read modes (full/map/signatures) |
51
+ | Session continuity (26 events) | Agent governance (profiles, budgets, SLOs) |
52
+
53
+ ## Consequences
54
+
55
+ - Need to ensure context-mode's `ctx_search` and `ctx_execute` tools are integrated into the search policy
56
+ - ck-enforce.ts was blocking conceptual grep searches and steering to `ck --hybrid` — this enforcement is lost; SYSTEM.md grep policy still applies but relies on agent compliance
57
+ - context-mode uses ELv2 license (vs Apache 2.0) — acceptable for internal use
58
+ - `npm install` in `.pi/npm/` installed 42 new packages, removed pi-lean-ctx
59
+ - Wiki pages referencing `[[lean-ctx]]` should be updated to reference `[[context-mode]]` where appropriate
@@ -0,0 +1,94 @@
1
+ ---
2
+ type: decision
3
+ title: "ADR-027: pi-vcc Overrides Built-in Auto-Compaction"
4
+ status: accepted
5
+ priority: 1
6
+ date: "2026-05-07"
7
+ tags: [adr, compaction, pi-vcc, vcc, context]
8
+ sources:
9
+ - "[[pi-vcc-github-repo]]"
10
+ - "[[vcc-conversation-compaction-for-pi]]"
11
+ - "https://github.com/sting8k/pi-vcc/issues/3"
12
+ related:
13
+ - "[[adr-012]]"
14
+ - "[[adr-015]]"
15
+ created: 2026-05-07
16
+ updated: 2026-05-07
17
+ ---
18
+
19
+ # ADR-027: pi-vcc Overrides Built-in Auto-Compaction
20
+
21
+ ## Context
22
+
23
+ Pi's default compaction uses LLM-generated summaries. This is:
24
+ - **Non-deterministic** — can hallucinate or lose context
25
+ - **Expensive** — burns tokens on every compaction
26
+ - **Slow** — waits for LLM call (seconds vs milliseconds)
27
+ - **Destructive** — pre-compaction history is permanently lost
28
+
29
+ [pi-vcc](https://github.com/sting8k/pi-vcc) is an algorithmic compaction extension inspired by lllyasviel's VCC. It provides:
30
+ - **Deterministic** — same input = same output, no LLM
31
+ - **Zero cost** — no API calls, algorithmic extraction
32
+ - **Fast** — 30-470ms per compaction
33
+ - **99% token reduction** on long sessions
34
+ - **Lossless recall** — `vcc_recall` reads raw session JSONL
35
+
36
+ ### Problem: Model Stops After Auto-Compaction
37
+
38
+ GitHub issue [sting8k/pi-vcc#3](https://github.com/sting8k/pi-vcc/issues/3): when `overrideDefaultCompaction: true`, the AI model stops generating after auto-compaction. The maintainer confirmed it is "by design for now."
39
+
40
+ **Root cause**: pi-vcc's `buildOwnCut` keeps the last user message and everything after it as the "kept tail." When that tail contains a completed turn (user message + assistant's finished response), the LLM sees a complete conversation after session reload and has no signal to continue working.
41
+
42
+ ## Decision
43
+
44
+ ### 1. Project-level pi-vcc activation (not global)
45
+
46
+ pi-vcc is registered as a **project-level package** in `.pi/settings.json`, not in `~/.pi/agent/settings.json`. The config lives at `.pi/pi-vcc-config.json`, referenced via `PI_VCC_CONFIG_PATH` in `.env`.
47
+
48
+ This keeps the VCC override scoped to this project only. Other projects use pi's default LLM compaction.
49
+
50
+ ### 2. Enable `overrideDefaultCompaction: true`
51
+
52
+ All compaction paths (auto-threshold, `/compact`, `/pi-vcc`) route through pi-vcc's algorithmic compactor.
53
+
54
+ ### 3. Fix "model stops" with continuation directive
55
+
56
+ For auto-compactions (not manual `/pi-vcc`), append `[Continue]` section to the summary:
57
+
58
+ ```
59
+ [Continue]
60
+ Continue working on the current task. The user's request is not yet complete. Use vcc_recall if you need context from earlier in the session.
61
+ ```
62
+
63
+ This is patched in `node_modules/@sting8k/pi-vcc/src/hooks/before-compact.ts`, applied only when `isPiVcc === false` (auto-compact or `/compact`).
64
+
65
+ ## Alternatives Considered
66
+
67
+ | Option | Pros | Cons |
68
+ |--------|------|------|
69
+ | **Keep default LLM compaction** | No risk of model stopping | Expensive, non-deterministic, slow |
70
+ | **`overrideDefaultCompaction: false` (manual only)** | Safer, model never stops unexpectedly | User must run `/pi-vcc` manually; auto-compaction still burns LLM tokens |
71
+ | **Fork pi-vcc repo** | Clean patch management | Overhead of maintaining fork, slow to upstream updates |
72
+ | **Patch node_modules directly** (chosen) | Zero overhead, immediate fix | Patch lost on `npm update`; requires re-apply |
73
+ | **Send synthetic "continue" message post-compaction** | Clean separation of concerns | Requires new `session_compact` handler; more invasive |
74
+ | **Append continuation to summary** (chosen) | Simplest fix; minimal code change | Slightly longer summary text |
75
+
76
+ ## Consequences
77
+
78
+ ### Positive
79
+ - **99% context reduction** on auto-compaction (vs ~70-80% with LLM)
80
+ - **Zero compaction cost** — no LLM calls, saves tokens
81
+ - **30-470ms latency** vs 2-10s LLM wait
82
+ - **Deterministic output** — same session = same summary
83
+ - **Lossless recall** via `vcc_recall` — pre-compaction history searchable
84
+ - **Model continues working** after auto-compaction via continuation directive
85
+
86
+ ### Negative
87
+ - Patch in node_modules is fragile — `npm update` removes it
88
+ - Continuation directive may prompt unnecessary continuation if task IS actually complete (minor risk)
89
+ - VCC config is project-scoped only — other projects don't benefit
90
+
91
+ ### Mitigations
92
+ - Document the patch location so it can be re-applied after npm updates
93
+ - Consider upstreaming the fix to pi-vcc repo
94
+ - Continuation directive only fires on auto-compaction, not `/pi-vcc`
package/vault/wiki/log.md CHANGED
@@ -8,7 +8,11 @@ tags: [meta, log, operations]
8
8
 
9
9
  # Wiki Operations Log
10
10
 
11
- ## [2026-05-05] wiki-autoresearch | pi-vcc (ecosystem expansion + SOTA update)
11
+ ## [2026-05-07] replace | pi-lean-ctx context-mode
12
+ - **Decision**: [[2026-05-07-replace-lean-ctx-with-context-mode]]
13
+ - **Changes**: replaced `npm:pi-lean-ctx` with `npm:context-mode` in `.pi/settings.json`; replaced `pi-lean-ctx` devDependency with `context-mode` in `.pi/npm/package.json`; deleted `.pi/extensions/ck-enforce.ts` (lean-ctx-specific grep override); updated `package.json` keyword and `CONTRIBUTING.md`
14
+ - **Tradeoff**: gained FTS5 sandbox + 11K+ community + native Pi hooks; lost AST compression (tree-sitter 18 langs), 90+ shell pattern compression, smart read modes, agent governance (profiles/budgets/SLOs), 48 MCP tools → 11
15
+ - **Risk**: `ck-enforce.ts` was blocking conceptual grep and steering to `ck --hybrid` — now relies on SYSTEM.md policy compliance alone
12
16
  - Rounds: 2 (broad search across 4 angles + targeted gap fill on 3 new extensions + 2 SOTA developments)
13
17
  - Searches: 8 | Sources found: 5 new (pi-rtk-optimizer, pi-omni-compact, pi-context-prune, Anthropic Compaction API, Context Folding paper)
14
18
  - Pages created: [[pi-rtk-optimizer-github-repo]], [[pi-omni-compact-github-repo]], [[pi-context-prune-github-repo]], [[anthropic-compaction-api]], [[context-folding-paper]] (sources), [[context-folding]] (concept)