@leing2021/super-pi 0.23.0 → 0.23.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 CHANGED
@@ -10,22 +10,6 @@ pi install npm:@leing2021/super-pi
10
10
 
11
11
  ---
12
12
 
13
- ## Why Super Pi
14
-
15
- Using a bare AI agent to write code has three common failure modes:
16
-
17
- 1. **Builds before thinking** — you finish and realize it's not what you wanted
18
- 2. **Loses context on interruption** — close the terminal, lose the progress
19
- 3. **Repeats the same mistakes** — every session starts from zero
20
-
21
- Super Pi's answers:
22
-
23
- - **Forces clarity before action** — not a form to fill out, but an AI that interrogates you like a YC partner demanding specific evidence
24
- - **Auto-resume from checkpoints** — restart after interruption, skip completed work, continue from where you left off
25
- - **Auto-compounds experience** — every solved problem becomes a searchable knowledge card; next time, the agent finds and reuses it
26
-
27
- ---
28
-
29
13
  ## The Five-Step Loop
30
14
 
31
15
  ```
@@ -33,360 +17,109 @@ Super Pi's answers:
33
17
  think plan build review learn
34
18
  ```
35
19
 
36
- Each step has a dedicated skill + tool pair. Not just prompts — structured toolchains.
20
+ | Skill | Does | Core Tool |
21
+ |-------|------|-----------|
22
+ | **01-brainstorm** | YC-style interrogation, three modes (Startup/Builder/CE) | `brainstorm_dialog` |
23
+ | **02-plan** | RED→GREEN→REFACTOR, incremental updates, optional CEO Review | `plan_diff` |
24
+ | **03-work** | Parallel execution, checkpoint resume, strict TDD | `ce_subagent`, `ce_parallel_subagent` |
25
+ | **04-review** | Auto-assigned reviewers, structured findings, browser QA | `review_router` |
26
+ | **05-learn** | Pattern extraction → searchable knowledge cards | `pattern_extractor` |
27
+ | **06-next** | Next-step recommendation + full status report | `workflow_state` |
28
+ | **07-worktree** | Isolated git worktree development | `worktree_manager` |
29
+ | **08-help** | Phase 1 skill explainer and usage guide | — |
37
30
 
38
- ### New: Stage model routing
31
+ ### Model & Thinking Routing
39
32
 
40
- Configure once in `.pi/settings.json`:
33
+ Configure in `.pi/settings.json`:
41
34
 
42
35
  ```json
43
36
  {
44
37
  "modelStrategy": {
45
- "01-brainstorm": "claude-sonnet-4-20250514",
46
- "02-plan": "claude-opus-4-20250115",
47
- "03-work": "claude-sonnet-4-20250514",
48
- "04-review": "claude-sonnet-4-20250514",
49
- "05-learn": "claude-haiku-4-20250414",
50
- "default": "claude-sonnet-4-20250514"
38
+ "01-brainstorm": "anthropic/claude-sonnet-4-20250514",
39
+ "02-plan": "anthropic/claude-opus-4-20250115"
40
+ },
41
+ "thinkingStrategy": {
42
+ "01-brainstorm": "high",
43
+ "02-plan": "high",
44
+ "03-work": "medium"
51
45
  }
52
46
  }
53
47
  ```
54
48
 
55
- How it works:
56
- - Model switching is handled automatically by the ce-core extension `input` hook — no manual `/model` needed.
57
- - When you type `/skill:01-brainstorm` through `/skill:05-learn`, the extension reads `modelStrategy[stage]` (or `modelStrategy.default`) and switches before the skill runs.
58
- - Supported formats: full reference (`"anthropic/claude-opus-4-1"`) or bare model id (`"claude-opus-4-1"`, reuses current provider).
59
- - Every stage prints a `📊 Pipeline Status` block with `Current / Output / Next`.
60
- - A `Switched model for <stage>: <provider>/<model>` notification appears when the model changes.
61
-
62
- Quick example:
63
- 1. Run `/skill:01-brainstorm` — model auto-switches to the configured brainstorm model
64
- 2. Approve the design
65
- 3. Run `/skill:02-plan` — model auto-switches to the configured plan model
66
- 4. Continue through each stage — model switches automatically at each step
67
-
68
- ---
69
-
70
- ## What Each Step Does
71
-
72
- ### 01-brainstorm: Think First
73
-
74
- Not "describe your requirements." Three modes for three scenarios:
75
-
76
- | Mode | For | What it does |
77
- |------|-----|-------------|
78
- | **Startup Diagnostic** | Startup ideas, new products | Six YC-style forcing questions, pushed until you produce specific evidence (not "people are interested" — "who would freak out if this disappeared tomorrow?") |
79
- | **Builder Mode** | Side projects, hackathons | Only focused on building the coolest thing. If you accidentally mention revenue, it auto-upgrades to Startup Diagnostic |
80
- | **CE Brainstorm** | Adding features to existing projects | Multi-round dialog to clarify scope boundaries, generates a structured requirements doc |
81
-
82
- All three modes run a **premise challenge** (are your assumptions valid?) and **alternatives generation** (at least one minimal + one ideal approach) before you're allowed to move on.
83
-
84
- ### 02-plan: Plan Well
85
-
86
- Breaks requirements into implementation units, each following strict **RED → GREEN → REFACTOR** (no production code without a failing test first).
87
-
88
- **Incremental updates**: Requirements changed? `plan_diff` detects added/removed/modified units and patches the plan instead of rewriting it.
89
-
90
- **CEO Review (optional)**: After planning, you can request a CEO Review. It challenges your plan using Bezos reversible-decision frameworks, Munger inversion, Jobs subtraction, forces alternative approaches, and draws error maps. Like having a demanding CTO review your proposal for free.
91
-
92
- ### 03-work: Build Right
93
-
94
- **Parallel execution**: `task_splitter` uses a Union-Find algorithm to analyze file dependencies, feeds conflict-free units to `ce_parallel_subagent` for concurrent execution.
95
-
96
- **Checkpoint resume**: After each unit, a checkpoint is saved. Interrupted? Next startup auto-loads, skips completed work, continues from the breakpoint. Failed? `fail` records the error → `retry` suggests a recovery strategy (timeout? extend timeout. Permission issue? check permissions first. Code error? fix then retry).
97
-
98
- **Strict TDD**: Run failing test → write minimal implementation → test passes → refactor. Every step requires command output as evidence. No skipping.
99
-
100
- ### 04-review: Review Thoroughly
101
-
102
- **Structured code review**: `review_router` auto-assigns reviewer personas based on diff metadata (changed payment code? bring in the security reviewer). Review discipline is technical evaluation, not theater — every finding must cite specific code, YAGNI checks, no performative agreement.
103
-
104
- **Browser QA (optional)**: Uses `agent-browser` to open your app, click through pages, screenshot bugs, fix by severity, up to 3 auto-fix iterations. Can auto-generate regression tests. Like having a QA engineer run acceptance tests.
105
-
106
- ### 05-learn: Compound Learnings
107
-
108
- `pattern_extractor` scans existing artifacts, extracts and categorizes patterns. Turns "the pitfall we hit this time" into a YAML-tagged solution card in `docs/solutions/`.
109
-
110
- Two-level storage: project-specific → inside the project; cross-project → `~/.pi/agent/docs/solutions/` globally searchable.
111
-
112
- Next time `02-plan` or `04-review` runs, a grep-first search strategy automatically retrieves relevant past experience.
113
-
114
- ---
115
-
116
- ## Technical Architecture
117
-
118
- ### 8 Skills (workflow nodes)
119
-
120
- | Skill | One-liner | Core Tool |
121
- |-------|-----------|-----------|
122
- | `01-brainstorm` | Deep requirements mining in three modes | `brainstorm_dialog` |
123
- | `02-plan` | Break into units, TDD gates, incremental updates | `plan_diff` |
124
- | `03-work` | Parallel execution, checkpoint resume, error recovery | `session_checkpoint`, `task_splitter`, `ce_parallel_subagent` |
125
- | `04-review` | Persona-routed review + live browser testing | `review_router` |
126
- | `05-learn` | Pattern extraction → knowledge card compounding | `pattern_extractor` |
127
- | `06-next` | What to do next + full status report | `workflow_state`, `session_history` |
128
- | `07-worktree` | Git worktree isolated development | `worktree_manager` |
129
- | `08-help` | Usage guide | — |
130
-
131
-
132
- ### 14 Tools + 2 Helpers (underlying capabilities)
133
-
134
- | Tool | What it does |
135
- |------|-------------|
136
- | `task_splitter` | Union-Find algorithm analyzes file dependencies, auto-groups parallel-safe units |
137
- | `session_checkpoint` | JSON-persisted checkpoints with save/load/fail/retry operations |
138
- | `plan_diff` | Incremental plans: compare detects diffs, patch applies changes |
139
- | `ce_parallel_subagent` | `Promise.allSettled`-style CE parallel skill-based subagent execution with context slimming |
140
- | `review_router` | Auto-assign reviewer personas from diff metadata |
141
- | `pattern_extractor` | Extract and categorize patterns from artifacts |
142
- | `brainstorm_dialog` | Multi-round dialog state machine (start → refine × N → summarize) |
143
- | `session_history` | Cross-session execution history recording and querying |
144
- | `workflow_state` | Scan docs/ and .context/ to summarize workflow state |
145
- | `worktree_manager` | Full git worktree lifecycle management |
146
- | `artifact_helper` | Artifact path resolution and directory creation |
147
- | `ask_user_question` | Structured user prompts (choices / free input) |
148
- | `ce_subagent` | CE serial skill-based subagent chain with depth guard and context control |
149
- | `context_handoff` | Cross-stage context handoffs with evidence-first templates (save/load/latest/status) |
150
- | `subagent-depth-guard` | Helper: env-based recursion depth tracking (prevents runaway nesting) |
151
- | `async-mutex` | Helper: serializes `process.env` mutation for concurrency-safe child process spawning |
152
-
153
- ### Compatibility with pi-subagents
49
+ Model and thinking level switch automatically — no manual `/model` needed.
154
50
 
155
- super-pi's CE skill-router tools use a dedicated namespace to avoid runtime tool-name conflicts:
51
+ ### pi-subagents Compatibility
156
52
 
157
- - **CE tools**: `ce_subagent` and `ce_parallel_subagent` for CE pipeline skill execution
158
- - **Generic `subagent`**: reserved for third-party agent extensions like [pi-subagents](https://www.npmjs.com/package/pi-subagents)
159
-
160
- Both extensions can be installed simultaneously without tool collision. super-pi manages the CE pipeline (brainstorm → plan → work → review → learn); pi-subagents provides general-purpose multi-agent execution. No configuration needed — install both and each keeps its own tool namespace.
161
-
162
- ---
163
-
164
- ## Token Cost
165
-
166
- New conversation overhead: **~2,600 tokens** (1.3% of Claude Sonnet 4's 200K context).
167
-
168
- | Component | Tokens | When loaded |
169
- |-----------|--------|-------------|
170
- | 8 skill registrations | ~490 | Every conversation (fixed) |
171
- | 14 tool registrations | ~2,055 | Every conversation (fixed) |
172
- | Hooks & filters | 0 | Runtime interception, zero prompt cost |
173
- | Single skill trigger | ~1,000–4,000 | On-demand via `read` |
174
- | Rules minimal (2 files) | ~900 | Before plan/work |
175
- | Rules + language (7 files) | ~2,600 | Before work with specific language |
176
-
177
- | vs bare Pi | vs global rules injection | vs super-pi |
178
- |-----------|----------------------|------------|
179
- | No rules | All rules loaded upfront | Progressive on-demand |
180
- | No output filtering | No output filtering | Auto-compress (bash ~65–98%, read ~30–60%) |
181
- | No TDD gate | No TDD gate | Hard gate prevents rework |
182
- | 0 tokens | ~5,000–36,000 tokens | **~2,600 tokens** |
183
-
184
- Single `npm install` output filtered once pays for the entire overhead. Full evaluation → [`docs/token-cost-evaluation.md`](docs/token-cost-evaluation.md)
185
-
186
- ---
187
-
188
- ## Code Scale
189
-
190
- ~2800 lines of TypeScript implementing 14 registered tools + 2 helpers, 23 Markdown reference files + 79 rule files driving 8 skills, 175 tests covering all tool logic.
191
-
192
- Not a heavy framework. Each tool has a single responsibility, each skill works independently, and together they form a complete workflow.
53
+ CE skill tools use a dedicated namespace (`ce_subagent`, `ce_parallel_subagent`) to avoid conflicts with third-party extensions like [pi-subagents](https://www.npmjs.com/package/pi-subagents). Both can coexist without configuration.
193
54
 
194
55
  ---
195
56
 
196
57
  ## Quick Start
197
58
 
198
- ### New idea
199
-
200
59
  ```
201
60
  You: I want to build a tool that helps indie devs find users
202
61
 
203
- Auto-enters 01-brainstorm, YC-style interrogation
204
- Generates docs/brainstorms/2026-04-18-find-users-requirements.md
205
- Recommends next: 02-plan
62
+ → 01-brainstorm: YC-style interrogation → docs/brainstorms/requirements.md
63
+ 02-plan: RED→GREEN→REFACTOR units → docs/plans/plan.md
64
+ 03-work: parallel execution, checkpoint resume
65
+ → 04-review: structured findings, optional browser QA
66
+ → 05-learn: knowledge compounding
206
67
 
207
68
  You: continue
208
-
209
- → 02-plan breaks into units, optional CEO Review
210
- → Generates docs/plans/2026-04-18-find-users-plan.md
211
-
212
- You: continue
213
-
214
- → 03-work parallel execution, checkpoint resume
215
- → 04-review code review + optional browser QA
216
- → 05-learn knowledge compounding
69
+ → Next skill recommended automatically via /skill:06-next
217
70
  ```
218
71
 
219
- ### Adding a feature
220
-
72
+ **After interruption:**
221
73
  ```
222
- You: I want to add user authentication to the project
223
-
224
- → 01-brainstorm CE mode, multi-round dialog: OAuth2? JWT? MFA?
225
- → Requirements doc → 02-plan → 03-work → 04-review → 05-learn
226
- ```
227
-
228
- ### Resume after interruption
229
-
230
- ```
231
- You: /skill:03-work docs/plans/auth-plan.md
232
-
74
+ You: /skill:03-work docs/plans/plan.md
233
75
  → Auto-loads checkpoint, skips completed units, resumes from breakpoint
234
76
  ```
235
77
 
236
- ### Requirements changed
78
+ ---
237
79
 
238
- ```
239
- You: Requirements changed, need to add SSO support
80
+ ## Token Cost
240
81
 
241
- 02-plan uses plan_diff to detect changes, patches incrementally
242
- ```
82
+ New conversation overhead: **~2,600 tokens** (1.3% of 200K context).
243
83
 
244
- ### Check progress anytime
84
+ | Component | Tokens |
85
+ |-----------|--------|
86
+ | 8 skill registrations | ~490 |
87
+ | System prompt (skills) | ~1,400 |
88
+ | Skill inlining (per invocation) | ~500-800 |
245
89
 
246
- ```
247
- You: /skill:06-next
90
+ Progressive loading: only needed skills loaded on-demand.
248
91
 
249
- Scans all artifacts, shows progress + recommends next step
250
- ```
92
+ Full evaluation [`docs/token-cost-evaluation.md`](docs/token-cost-evaluation.md)
251
93
 
252
94
  ---
253
95
 
254
- ## Generated File Structure
96
+ ## Generated Structure
255
97
 
256
98
  ```
257
99
  your-project/
258
100
  ├── docs/
259
- │ ├── brainstorms/ # Requirements (01-brainstorm)
260
- │ ├── plans/ # Execution plans (02-plan)
261
- │ └── solutions/ # Knowledge cards (05-learn)
101
+ │ ├── brainstorms/ # Requirements
102
+ │ ├── plans/ # Execution plans
103
+ │ └── solutions/ # Knowledge cards
262
104
  └── .context/
263
105
  └── compound-engineering/
264
- ├── checkpoints/ # Breakpoint files (session_checkpoint)
265
- ├── dialogs/ # Dialog state (brainstorm_dialog)
266
- └── history/ # Execution history (session_history)
267
- ```
268
-
269
- **Recommendation: commit everything to git** — these files are the project's traceable memory.
270
-
271
- ### Progressive Rule Loading
272
-
273
- Built-in coding rules live under `rules/` in the package. Rules are loaded **progressively** by each skill — never all at once, only what the current task needs.
274
-
275
- **How it works:**
276
-
277
- ```
278
- system prompt (30 tokens: skill name + description)
279
- → skill SKILL.md (~200 tokens: loading decision tree)
280
- → specific rule files via read tool (on-demand, 900–2600 tokens)
106
+ ├── checkpoints/ # Breakpoint files
107
+ ├── dialogs/ # Dialog state
108
+ └── history/ # Execution history
281
109
  ```
282
110
 
283
- Three skills auto-trigger rule loading at their entry points:
284
-
285
- | Skill | Rules pre-loaded |
286
- |-------|-----------------|
287
- | `02-plan` | `common/` rules + language detection + matching language rules (e.g. `rules/typescript/`) |
288
- | `03-work` | `common/` rules + language detection + matching language rules + `web/` if frontend |
289
- | `04-review` | `common/code-review.md` + language detection + matching language rules + `web/` if frontend |
290
-
291
- Language detection uses file heuristics (see `skills/references/language-detection.md`): `tsconfig.json` → TypeScript, `Cargo.toml` → Rust, `go.mod` → Go, etc.
292
-
293
- **Rule precedence** (when layers overlap on the same topic):
294
-
295
- ```
296
- language-specific > web > common
297
- ```
298
-
299
- No rules are loaded when you brainstorm, check status, or do non-code tasks. Zero waste.
300
-
301
- #### Included rule layers
302
-
303
- | Layer | Files | When loaded |
304
- |-------|-------|------------|
305
- | `common/` | 11 files (includes `naming.md`) | Always (baseline for all tasks) |
306
- | `typescript/`, `python/`, `cpp/`, `csharp/`, `dart/`, `golang/`, `java/`, `kotlin/`, `perl/`, `php/`, `rust/`, `swift/` | 5 files each | When the task touches that language |
307
- | `web/` | 7 files (includes `design-quality.md`, `performance.md`) | When frontend/browser is relevant |
308
-
309
- #### Customizing rules for your project
310
-
311
- Two rule sources exist, with project-level taking priority:
312
-
313
- | Source | Location | Survives `pi update`? |
314
- |--------|----------|----------------------|
315
- | **Project-level** | `{your-project-root}/rules/` | ✅ Yes |
316
- | Package-level | Inside `node_modules/@leing2021/super-pi/rules/` | ❌ No |
317
-
318
- To customize, create a `rules/` directory in your project root. Skills check it first — if a file exists there, it overrides the package default for that topic.
319
-
320
- **Add a language** — create a new directory with the 5 standard topics:
321
-
322
- ```bash
323
- mkdir rules/elixir
324
- touch rules/elixir/{coding-style,testing,patterns,security,hooks}.md
325
- ```
326
-
327
- Each file should start with:
328
-
329
- ```markdown
330
- > This file extends [common/xxx.md](../common/xxx.md) with Elixir-specific content.
331
- ```
332
-
333
- **Remove unused languages** — just delete the directory:
334
-
335
- ```bash
336
- rm -rf rules/perl rules/cpp # don't need these? remove them
337
- ```
338
-
339
- **Tweak a rule** — edit the `.md` file directly:
340
-
341
- ```bash
342
- # Override testing conventions for your team
343
- vim rules/common/testing.md
344
-
345
- # Override for a specific language
346
- vim rules/typescript/testing.md
347
- ```
348
-
349
- **Add a new topic** — create a new `.md` in the appropriate layer:
350
-
351
- ```bash
352
- # Common topic
353
- vim rules/common/api-design.md
354
-
355
- # Language-specific override
356
- vim rules/python/api-design.md
357
- ```
358
-
359
- Skills will pick up any `.md` file in `rules/` — no configuration needed. If a language directory exists, it's available for loading. If it's gone, it's simply never loaded.
111
+ **Commit everything to git** these files are the project's traceable memory.
360
112
 
361
113
  ---
362
114
 
363
- ## Design Philosophy & Acknowledgements
364
-
365
- **80% planning and review, 20% execution.**
366
-
367
- The goal isn't making AI write code faster — it's making AI think before writing, review after writing, and compound learnings after reviewing. Speed comes from fewer rewrites, not from skipping steps.
368
-
369
- The following projects directly inspired this work:
115
+ ## Architecture
370
116
 
371
- - **[everything-claude-code](https://github.com/affaan-m/everything-claude-code)** (162K★) Parallel subagent orchestration, checkpoint resume, continuous learning
372
- - **[superpowers](https://github.com/obra/superpowers)** (161K★) Strict TDD gates, design checklists, review discipline
373
- - **[gstack](https://github.com/garrytan/gstack)** (78K★) → YC-style forcing questions, CEO Review frameworks, browser QA
374
- - **[compound-engineering-plugin](https://github.com/EveryInc/compound-engineering-plugin)** (14K★) Five-step loop, knowledge compounding backbone
117
+ - **8 skills** with dedicated tools
118
+ - **14 tools** + 2 helpers
119
+ - **~2800 lines** TypeScript, **175 tests**
120
+ - **Progressive rule loading** only what each task needs
375
121
 
376
- Not a fork. Not a wrapper. Methodologies extracted and rebuilt with Pi's native tool + skill system.
377
-
378
- ---
379
-
380
- ## Best Practices
381
-
382
- | Tip | Why |
383
- |-----|-----|
384
- | Start with 01-brainstorm | Whatever the scenario, thinking first never hurts |
385
- | Use 07-worktree for big features | Isolated dev, no impact on main branch |
386
- | Use CEO Review on plans | Like having a demanding CTO review for free |
387
- | Use browser QA for acceptance | Code review can't catch layout breaks and blank screens |
388
- | Don't panic on interruption | Next 03-work auto-resumes from checkpoint |
389
- | Use 06-next when lost | One glance shows where you are and what to do next |
122
+ Rules in `rules/` (11 common + language-specific). Project-level overrides take priority.
390
123
 
391
124
  ---
392
125
 
@@ -394,8 +127,6 @@ Not a fork. Not a wrapper. Methodologies extracted and rebuilt with Pi's native
394
127
 
395
128
  See [CHANGELOG.md](./CHANGELOG.md) for full version history.
396
129
 
397
- ---
398
-
399
130
  ## Repository
400
131
 
401
132
  - **GitHub**: https://github.com/leing2021/super-pi
@@ -406,4 +137,4 @@ See [CHANGELOG.md](./CHANGELOG.md) for full version history.
406
137
  ```bash
407
138
  bun test
408
139
  npm publish --dry-run
409
- ```
140
+ ```
@@ -31,15 +31,46 @@ const PIPELINE_STAGE_KEYS = new Set([
31
31
  "05-learn",
32
32
  ])
33
33
 
34
- interface ModelStrategySettings {
34
+ interface StrategySettings {
35
35
  modelStrategy?: Record<string, string>
36
+ thinkingStrategy?: Record<string, string>
36
37
  }
37
38
 
38
- async function readProjectSettings(cwd: string): Promise<ModelStrategySettings | null> {
39
- const settingsPath = path.join(cwd, ".pi", "settings.json")
39
+ /**
40
+ * Read settings from two locations:
41
+ * 1. Project-level: {cwd}/.pi/settings.json (highest priority)
42
+ * 2. Global-level: ~/.pi/agent/settings.json (fallback)
43
+ *
44
+ * Project-level takes precedence; global-level is used as fallback.
45
+ */
46
+ async function readSettings(cwd: string): Promise<StrategySettings | null> {
47
+ // Try project-level first
48
+ const projectPath = path.join(cwd, ".pi", "settings.json")
40
49
  try {
41
- const content = await readFile(settingsPath, "utf8")
42
- return JSON.parse(content) as ModelStrategySettings
50
+ const content = await readFile(projectPath, "utf8")
51
+ const projectSettings = JSON.parse(content) as StrategySettings
52
+ // If project has modelStrategy or thinkingStrategy, use it
53
+ if (projectSettings.modelStrategy || projectSettings.thinkingStrategy) {
54
+ return projectSettings
55
+ }
56
+ } catch {
57
+ // Project settings not found, continue to global
58
+ }
59
+
60
+ // Fallback to global-level
61
+ const globalPath = path.join(process.env.HOME || "~", ".pi", "agent", "settings.json")
62
+ try {
63
+ const content = await readFile(globalPath, "utf8")
64
+ return JSON.parse(content) as StrategySettings
65
+ } catch {
66
+ // Global settings not found either
67
+ }
68
+
69
+ // Try ~/.pi/settings.json as another fallback
70
+ const altGlobalPath = path.join(process.env.HOME || "~", ".pi", "settings.json")
71
+ try {
72
+ const content = await readFile(altGlobalPath, "utf8")
73
+ return JSON.parse(content) as StrategySettings
43
74
  } catch {
44
75
  return null
45
76
  }
@@ -319,47 +350,61 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
319
350
  return { action: "continue" as const }
320
351
  }
321
352
 
322
- const settings = await readProjectSettings(ctx.cwd)
353
+ const settings = await readSettings(ctx.cwd)
323
354
  const modelStrategy = settings?.modelStrategy
324
- if (!modelStrategy) {
325
- return { action: "continue" as const }
326
- }
327
-
328
- const targetModelRef = modelStrategy[stageKey] ?? modelStrategy.default
329
- if (!targetModelRef) {
330
- return { action: "continue" as const }
331
- }
332
-
333
- const parsed = parseModelRef(targetModelRef, ctx.model?.provider)
334
- if (!parsed) {
335
- if (ctx.hasUI) {
336
- ctx.ui.notify(`Invalid modelStrategy entry for ${stageKey}: ${targetModelRef}`, "warning")
337
- }
338
- return { action: "continue" as const }
339
- }
340
-
341
- if (ctx.model?.provider === parsed.provider && ctx.model?.id === parsed.id) {
342
- return { action: "continue" as const }
343
- }
344
-
345
- const model = ctx.modelRegistry.find(parsed.provider, parsed.id)
346
- if (!model) {
347
- if (ctx.hasUI) {
348
- ctx.ui.notify(`Configured model not found for ${stageKey}: ${targetModelRef}`, "warning")
355
+ const thinkingStrategy = settings?.thinkingStrategy
356
+
357
+ // Model switching
358
+ if (modelStrategy) {
359
+ const targetModelRef = modelStrategy[stageKey] ?? modelStrategy.default
360
+ if (targetModelRef) {
361
+ const parsed = parseModelRef(targetModelRef, ctx.model?.provider)
362
+ if (parsed) {
363
+ // Skip if already using the same model
364
+ if (ctx.model?.provider !== parsed.provider || ctx.model?.id !== parsed.id) {
365
+ const model = ctx.modelRegistry.find(parsed.provider, parsed.id)
366
+ if (model) {
367
+ const switched = await pi.setModel(model)
368
+ if (switched) {
369
+ if (ctx.hasUI) {
370
+ ctx.ui.notify(`Switched model for ${stageKey}: ${model.provider}/${model.id}`, "info")
371
+ }
372
+ } else {
373
+ if (ctx.hasUI) {
374
+ ctx.ui.notify(`No API key for ${stageKey}: ${model.provider}/${model.id}`, "warning")
375
+ }
376
+ }
377
+ } else if (ctx.hasUI) {
378
+ ctx.ui.notify(`Model not found for ${stageKey}: ${targetModelRef}`, "warning")
379
+ }
380
+ }
381
+ } else if (ctx.hasUI) {
382
+ ctx.ui.notify(`Invalid modelStrategy for ${stageKey}: ${targetModelRef}`, "warning")
383
+ }
349
384
  }
350
- return { action: "continue" as const }
351
385
  }
352
386
 
353
- const switched = await pi.setModel(model)
354
- if (switched) {
355
- if (ctx.hasUI) {
356
- ctx.ui.notify(`Switched model for ${stageKey}: ${model.provider}/${model.id}`, "info")
387
+ // Thinking level switching
388
+ if (thinkingStrategy) {
389
+ const targetThinking = thinkingStrategy[stageKey] ?? thinkingStrategy.default
390
+ if (targetThinking) {
391
+ const levelMap: Record<string, "low" | "medium" | "high"> = {
392
+ low: "low",
393
+ medium: "medium",
394
+ high: "high",
395
+ "0": "low",
396
+ "1": "medium",
397
+ "2": "high",
398
+ }
399
+ const normalized = levelMap[targetThinking.toLowerCase()] ?? "medium"
400
+ const currentLevel = ctx.getThinkingLevel?.() ?? "medium"
401
+ if (currentLevel !== normalized) {
402
+ ctx.setThinkingLevel?.(normalized)
403
+ if (ctx.hasUI) {
404
+ ctx.ui.notify(`Switched thinking level for ${stageKey}: ${normalized}`, "info")
405
+ }
406
+ }
357
407
  }
358
- return { action: "continue" as const }
359
- }
360
-
361
- if (ctx.hasUI) {
362
- ctx.ui.notify(`No API key available for configured model: ${model.provider}/${model.id}`, "warning")
363
408
  }
364
409
 
365
410
  return { action: "continue" as const }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",