pi-soly 0.7.0 → 0.8.0

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
@@ -78,7 +78,7 @@ State lives in `.soly/` — portable, git-friendly, human-readable.
78
78
 
79
79
  ### 🎤 Multi-Question Picker
80
80
 
81
- Claude Code-style `ask_pro` for the LLM. Single-select, multi-select, recommended ⭐, free-text Other.
81
+ Multi-question picker `ask_pro` for the LLM. Tabbed UI: single-select, multi-select, recommended ⭐, free-text Other.
82
82
 
83
83
  ```ts
84
84
  ask_pro({
package/agents-install.ts CHANGED
@@ -35,9 +35,12 @@ const SHIPPED_SKILLS = [
35
35
 
36
36
  /** Where pi looks for user agents. Respects HOME/USERPROFILE for
37
37
  * testability (otherwise we'd always write to the real user home). */
38
- function userAgentsDir(): string {
38
+ function userAgentsDirs(): string[] {
39
39
  const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
40
- return path.join(home, ".pi", "agent", "agents");
40
+ return [
41
+ path.join(home, ".agents"), // vendor-neutral (preferred)
42
+ path.join(home, ".pi", "agent", "agents"), // pi's native
43
+ ];
41
44
  }
42
45
 
43
46
  /** Where pi looks for user skills. */
@@ -87,20 +90,27 @@ function copyDirIfMissing(from: string, to: string): "installed" | "skipped" | "
87
90
  }
88
91
  }
89
92
 
90
- /** Install shipped soly agents to `~/.pi/agent/agents/`. Idempotent. */
93
+ /** Install shipped soly agents to `~/.agents/` (vendor-neutral,
94
+ * preferred). Legacy `~/.pi/agent/agents/` copies are left alone —
95
+ * `discoverUserAgents` reads both, so old installs still work. */
91
96
  export function installSolyAgents(extensionRoot: string): InstallResult {
92
97
  const result: InstallResult = { installed: [], skipped: [], errors: [] };
93
98
  const src = shippedAgentsDir(extensionRoot);
94
- const dst = userAgentsDir();
95
99
 
96
100
  if (!fs.existsSync(src)) return result; // dev mode no-op
97
101
 
98
- try {
99
- fs.mkdirSync(dst, { recursive: true });
100
- } catch (err) {
101
- result.errors.push(`mkdir ${dst}: ${(err as Error).message}`);
102
- return result;
102
+ // Try vendor-neutral first, then fall back to pi's native dir.
103
+ let dst: string | null = null;
104
+ for (const candidate of userAgentsDirs()) {
105
+ try {
106
+ fs.mkdirSync(candidate, { recursive: true });
107
+ dst = candidate;
108
+ break;
109
+ } catch (err) {
110
+ result.errors.push(`mkdir ${candidate}: ${(err as Error).message}`);
111
+ }
103
112
  }
113
+ if (!dst) return result;
104
114
 
105
115
  for (const name of SHIPPED_AGENTS) {
106
116
  const from = path.join(src, name);
@@ -145,20 +155,18 @@ export function installSolyAssets(extensionRoot: string): {
145
155
  };
146
156
  }
147
157
 
148
- /** Check which shipped soly agents are present in the user dir. Used by doctor. */
158
+ /** Check which shipped soly agents are present across all user agent
159
+ * homes. A file counts as "installed" if it's in ANY of the dirs. */
149
160
  export function checkSolyAgentsInstalled(extensionRoot: string): {
150
161
  installed: string[];
151
162
  missing: string[];
152
163
  } {
153
- const dst = userAgentsDir();
154
164
  const installed: string[] = [];
155
165
  const missing: string[] = [];
156
166
  for (const name of SHIPPED_AGENTS) {
157
- if (fs.existsSync(path.join(dst, name))) {
158
- installed.push(name);
159
- } else {
160
- missing.push(name);
161
- }
167
+ const present = userAgentsDirs().some((dir) => fs.existsSync(path.join(dir, name)));
168
+ if (present) installed.push(name);
169
+ else missing.push(name);
162
170
  }
163
171
  return { installed, missing };
164
172
  }
package/ask/README.md CHANGED
@@ -1,8 +1,7 @@
1
- # pi-ask — Claude Code-style multi-question picker for pi
1
+ # pi-ask — multi-question picker for pi
2
2
 
3
3
  A small pi-coding-agent extension that registers one tool (`ask_pro`) for
4
- showing a **tabbed, multi-question picker** in pi's TUI. Inspired by Claude
5
- Code's `AskUserQuestion`.
4
+ showing a **tabbed, multi-question picker** in pi's TUI.
6
5
 
7
6
  ## Features
8
7
 
@@ -88,10 +87,10 @@ Result:
88
87
  | `Enter` | **Single-select:** confirm + advance (or submit on last). **Multi-select:** advance to next question (or submit on last + all answered). Does NOT toggle. |
89
88
  | `Esc` | Cancel (returns `{cancelled: true}`) |
90
89
 
91
- Multi-select follows the Claude Code convention: **Space toggles, Enter
92
- advances/submits**. Single-select uses Enter as the universal action key
93
- (toggle/pick + advance). When you're on the last question and all
94
- questions are answered, the footer shows `⏎ submit` in accent color.
90
+ Multi-select: **Space toggles, Enter advances/submits**. Single-select
91
+ uses Enter as the universal action key (toggle/pick + advance). When
92
+ you're on the last question and all questions are answered, the footer
93
+ shows `⏎ submit` in accent color.
95
94
 
96
95
  ## Limits
97
96
 
@@ -101,30 +100,15 @@ questions are answered, the footer shows `⏎ submit` in accent color.
101
100
  - At most 1 `recommended: true` per question
102
101
  - TUI and RPC modes only (`hasUI: true`); print mode returns an error
103
102
 
104
- ## Setup
105
-
106
- Drop the directory in `~/.pi/agent/extensions/`:
107
-
108
- ```bash
109
- ls ~/.pi/agent/extensions/pi-ask/
110
- # index.ts picker.ts tests/ package.json tsconfig.json README.md
111
- ```
112
-
113
- pi auto-discovers and loads it on next start. The `ask_pro` tool is then
114
- available to the LLM. No config required.
115
-
116
103
  ## Development
117
104
 
118
105
  ```bash
119
- cd ~/.pi/agent/extensions/pi-ask
106
+ cd packages/pi-soly/ask
120
107
  bun test # runs tests/picker.test.ts
121
108
  bun run typecheck # tsc --noEmit
122
109
  ```
123
110
 
124
- CI: not configured (this is a single-file TUI component, low risk).
125
- Add `.github/workflows/ci.yml` if you want green-tick PRs.
126
-
127
- ## Why a separate extension?
111
+ ## Why a separate module?
128
112
 
129
113
  The picker is **generic** — any pi extension (soly, your own tool, etc.) can
130
114
  use `ask_pro` to drive multi-question Q&A without re-implementing the TUI.
package/ask/index.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // =============================================================================
4
4
  //
5
5
  // Registers one LLM tool: `ask_pro`. Lets the LLM ask the user a list of
6
- // questions at once via a Claude Code-style tabbed picker (tabs, numbered
6
+ // questions at once via a tabbed picker (tabs, numbered
7
7
  // options, ⭐ recommended answer, optional multi-select). All answers
8
8
  // returned in a single call.
9
9
  //
@@ -39,7 +39,7 @@ export default function piAskExtension(pi: ExtensionAPI) {
39
39
  name: "ask_pro",
40
40
  label: "pi-ask ask_pro",
41
41
  description:
42
- "Ask the user multiple questions at once via a Claude Code-style tabbed picker. Each question is a tab at the top. Options are numbered (1-N instant-pick), the recommended answer is marked ⭐. Supports single-select (default, auto-advance on pick) and multi-select (Enter toggles, last question shows Submit). All answers returned in one call. Use for progressive Q&A flows like `soly discuss`.",
42
+ "Ask the user multiple questions at once via a tabbed picker. Each question is a tab at the top. Options are numbered (1-N instant-pick), the recommended answer is marked ⭐. Supports single-select (default, auto-advance on pick) and multi-select (Enter toggles, last question shows Submit). All answers returned in one call. Use for progressive Q&A flows like `soly discuss`.",
43
43
  parameters: Type.Object({
44
44
  questions: Type.Array(
45
45
  Type.Object({
package/ask/picker.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // =============================================================================
2
- // picker.ts — Claude Code-style multi-question picker TUI component
2
+ // picker.ts — multi-question picker TUI component
3
3
  // =============================================================================
4
4
  //
5
5
  // Renders a tabbed multi-question flow inside pi's TUI. One `ask_pro` tool
@@ -493,7 +493,7 @@ export class AskProComponent extends Container {
493
493
  return;
494
494
  }
495
495
 
496
- // Space — toggle in multi-select (Claude Code convention).
496
+ // Space — toggle in multi-select.
497
497
  // On "Other…", opens the input dialog (or toggles existing custom string).
498
498
  // In single-select, Space is a no-op (Enter is the action key there).
499
499
  if (keyData === KEY_SPACE) {
@@ -247,7 +247,7 @@ describe("AskProComponent — multi-select", () => {
247
247
  expect(picker.getAnswers().get(0)).toEqual([0]); // multi preserved
248
248
  });
249
249
 
250
- test("Space toggles current selection in multi-select (Claude Code style)", () => {
250
+ test("Space toggles current selection in multi-select", () => {
251
251
  const { picker } = setup(multiQuestions);
252
252
  picker.handleInput("j"); // selectedIndex = 1 (Tokens)
253
253
  picker.handleInput(" "); // Space toggles
package/integrations.ts CHANGED
@@ -29,7 +29,7 @@ export const KNOWN_INTEGRATIONS: KnownIntegration[] = [
29
29
  {
30
30
  tool: "ask_pro",
31
31
  extension: "pi-ask",
32
- summary: "Multi-question tabbed picker (Claude Code style).",
32
+ summary: "Multi-question tabbed picker.",
33
33
  whenToUse:
34
34
  "Use instead of `soly_ask_user` for `soly discuss` flows when you have multiple related questions. PREFERRED in `soly discuss` when available.",
35
35
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-soly",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Project management framework for pi-coding-agent. Workflows, planning, multi-question picker, agent switcher, live task list — one npm install, zero config.",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -43,6 +43,11 @@ The **soly** extension adds project-management workflow to [pi-coding-agent](htt
43
43
 
44
44
  ```
45
45
  <project-root>/
46
+ ├── AGENTS.md # vendor-neutral agent context (loaded by pi)
47
+ ├── agents.md # same as AGENTS.md, lowercase accepted
48
+ ├── .agents/ # project-level agent definitions
49
+ │ ├── project-reviewer.md
50
+ │ └── data-scientist.md
46
51
  ├── .soly/
47
52
  │ ├── ROADMAP.md # phase table
48
53
  │ ├── STATE.md # current position + decisions log
@@ -274,8 +279,26 @@ Intent docs are 0-point — written BEFORE any plan, by humans. They define the
274
279
 
275
280
  1. `soly init` (or manually create `.soly/`, `docs/`, `rules/`)
276
281
  2. Write 1-3 intent docs in `.soly/docs/`
277
- 3. Create `ROADMAP.md` with phase table
278
- 4. `/plan 1` to start phase 1
282
+ 3. Optionally write `AGENTS.md` (or `agents.md`) at project root with project conventions
283
+ 4. Create `ROADMAP.md` with phase table
284
+ 5. `/plan 1` to start phase 1
285
+
286
+ ### Add project-specific agents
287
+
288
+ Drop a markdown file in `.agents/<name>.md` (project) or `~/.agents/<name>.md` (user):
289
+
290
+ ```markdown
291
+ ---
292
+ name: data-scientist
293
+ description: Reads CSVs, runs pandas, plots results
294
+ thinking: medium
295
+ tools: read, bash
296
+ ---
297
+
298
+ You are a data scientist. ...
299
+ ```
300
+
301
+ Both `~/.agents/` and `~/.pi/agent/agents/` are read (vendor-neutral preferred). `Ctrl+Tab` to see them in the cycle.
279
302
 
280
303
  ### Add a feature to an existing phase
281
304
 
package/switch/core.ts CHANGED
@@ -65,29 +65,55 @@ export function isValidAgentName(name: string): boolean {
65
65
  }
66
66
 
67
67
  /** Discover agent `.md` files in user dir. */
68
- export function discoverUserAgents(userDir: string = path.join(os.homedir(), ".pi", "agent", "agents")): string[] {
69
- if (!fs.existsSync(userDir)) return [];
70
- const names: string[] = [];
71
- for (const file of fs.readdirSync(userDir)) {
72
- if (!file.endsWith(".md")) continue;
68
+ /** User agent home directories, in priority order. First existing one
69
+ * wins for new agent creation; all are read and merged in the cycle.
70
+ * Honors $HOME / $USERPROFILE so tests can redirect to a tmp dir. */
71
+ export function userAgentDirs(): string[] {
72
+ const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
73
+ return [
74
+ path.join(home, ".agents"), // vendor-neutral (preferred)
75
+ path.join(home, ".pi", "agent", "agents"), // pi's native
76
+ ];
77
+ }
78
+
79
+ /** Read all user agent names from every registered home dir. Dedupes,
80
+ * first-occurrence wins. */
81
+ export function discoverUserAgents(): string[] {
82
+ const seen = new Set<string>();
83
+ const out: string[] = [];
84
+ for (const dir of userAgentDirs()) {
85
+ if (!fs.existsSync(dir)) continue;
86
+ let entries: string[];
73
87
  try {
74
- const raw = fs.readFileSync(path.join(userDir, file), "utf-8");
75
- const m = raw.match(/^---\n([\s\S]*?)\n---/);
76
- if (!m) continue;
77
- const fm = m[1] ?? "";
78
- const nameMatch = fm.match(/^name:\s*(.+)$/m);
79
- if (nameMatch) {
80
- const n = (nameMatch[1] ?? "").trim();
81
- if (isValidAgentName(n)) names.push(n);
82
- }
83
- } catch { /* skip */ }
88
+ entries = fs.readdirSync(dir);
89
+ } catch {
90
+ continue;
91
+ }
92
+ for (const file of entries) {
93
+ if (!file.endsWith(".md")) continue;
94
+ try {
95
+ const raw = fs.readFileSync(path.join(dir, file), "utf-8");
96
+ const m = raw.match(/^---\n([\s\S]*?)\n---/);
97
+ if (!m) continue;
98
+ const fm = m[1] ?? "";
99
+ const nameMatch = fm.match(/^name:\s*(.+)$/m);
100
+ if (nameMatch) {
101
+ const n = (nameMatch[1] ?? "").trim();
102
+ if (isValidAgentName(n) && !seen.has(n)) {
103
+ seen.add(n);
104
+ out.push(n);
105
+ }
106
+ }
107
+ } catch { /* skip unreadable */ }
108
+ }
84
109
  }
85
- return names;
110
+ return out;
86
111
  }
87
112
 
88
113
  /** Build the full cycle of available agents. Built-ins first, then
89
- * user-discovered. Dedupes while preserving first-occurrence order. */
90
- export function availableAgents(userDir?: string): string[] {
114
+ * user-discovered (from all user agent home dirs). Dedupes while
115
+ * preserving first-occurrence order. */
116
+ export function availableAgents(): string[] {
91
117
  const out: string[] = [];
92
118
  const seen = new Set<string>();
93
119
  const push = (n: string) => {
@@ -97,7 +123,7 @@ export function availableAgents(userDir?: string): string[] {
97
123
  }
98
124
  };
99
125
  for (const a of BUILTIN_AGENTS) push(a);
100
- for (const a of discoverUserAgents(userDir)) push(a);
126
+ for (const a of discoverUserAgents()) push(a);
101
127
  return out;
102
128
  }
103
129
 
@@ -139,8 +165,8 @@ export function formatAgentSwitchNotify(prev: string, next: string): string {
139
165
  }
140
166
 
141
167
  /** Group agents: built-ins + user-defined. */
142
- export function groupedAvailableAgents(userDir?: string): Array<{ header: string; agents: string[] }> {
143
- const all = availableAgents(userDir);
168
+ export function groupedAvailableAgents(): Array<{ header: string; agents: string[] }> {
169
+ const all = availableAgents();
144
170
  const groups: Array<{ header: string; agents: string[] }> = [];
145
171
  const builtin = all.filter((a) => BUILTIN_AGENTS.includes(a));
146
172
  if (builtin.length > 0) groups.push({ header: "built-in", agents: builtin });
package/switch/index.ts CHANGED
@@ -231,20 +231,50 @@ function createAgent(
231
231
  ui.notify(`pi-switch: invalid name "${name}". Use letters/digits/dashes/underscores, ≤64 chars.`, "error");
232
232
  return;
233
233
  }
234
- const userDir = path.join(os.homedir(), ".pi", "agent", "agents");
235
- fs.mkdirSync(userDir, { recursive: true });
236
- const file = path.join(userDir, `${name}.md`);
234
+ // Write to ~/.agents/ (vendor-neutral) first; fall back to ~/.pi/agent/agents/
235
+ // (pi's native) if .agents/ doesn't exist or is unwritable.
236
+ const home = os.homedir();
237
+ const candidates = [
238
+ path.join(home, ".agents"),
239
+ path.join(home, ".pi", "agent", "agents"),
240
+ ];
241
+ const targetDir = candidates.find((d) => {
242
+ try {
243
+ if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
244
+ // Probe write permission
245
+ const probe = path.join(d, ".pi-switch-write-probe");
246
+ fs.writeFileSync(probe, "");
247
+ fs.unlinkSync(probe);
248
+ return true;
249
+ } catch {
250
+ return false;
251
+ }
252
+ });
253
+ if (!targetDir) {
254
+ ui.notify(`pi-switch: could not find a writable agents dir (tried ${candidates.join(", ")}).`, "error");
255
+ return;
256
+ }
257
+ const file = path.join(targetDir, `${name}.md`);
237
258
  if (fs.existsSync(file)) {
238
259
  ui.notify(`pi-switch: ${file} already exists. edit it directly.`, "warning");
239
260
  return;
240
261
  }
241
262
  void ui.input(`description for "${name}":`, "one-liner that shows in the picker")?.then((desc) => {
242
263
  const description = desc?.trim() || `custom agent (${name})`;
243
- fs.writeFileSync(file, agentTemplate(name, description), "utf-8");
244
- ui.notify(
245
- `pi-switch: created ${file}\n → next Ctrl+Tab to see it in the cycle\n → edit the system prompt to specialize`,
246
- "info",
247
- );
264
+ try {
265
+ // Atomic write: tmp + rename. Avoids partial files and the
266
+ // race where two parallel createAgent calls would clobber each
267
+ // other's write after both pass the existsSync check.
268
+ const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
269
+ fs.writeFileSync(tmp, agentTemplate(name, description), "utf-8");
270
+ fs.renameSync(tmp, file);
271
+ ui.notify(
272
+ `pi-switch: created ${file}\n → next Ctrl+Tab to see it in the cycle\n → edit the system prompt to specialize`,
273
+ "info",
274
+ );
275
+ } catch (err) {
276
+ ui.notify(`pi-switch: failed to write ${file}: ${(err as Error).message}`, "error");
277
+ }
248
278
  });
249
279
  }
250
280
 
@@ -123,11 +123,22 @@ describe("groupedAvailableAgents", () => {
123
123
  expect(groups[0]?.header).toBe("built-in");
124
124
  });
125
125
  test("includes user group when present", () => {
126
- const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "pis-grp-"));
127
- fs.writeFileSync(path.join(tmp, "my.md"), "---\nname: my-helper\n---\n# body\n");
128
- const groups = groupedAvailableAgents(tmp);
126
+ // Use HOME override so the new ~.agents/ scan picks up our fixture
127
+ const home = process.env.HOME || process.env.USERPROFILE || os.homedir();
128
+ const prevHome = process.env.HOME;
129
+ const prevUserProfile = process.env.USERPROFILE;
130
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "pis-home-"));
131
+ process.env.HOME = tmp;
132
+ process.env.USERPROFILE = tmp;
133
+ const agentsDir = path.join(tmp, ".agents");
134
+ fs.mkdirSync(agentsDir, { recursive: true });
135
+ fs.writeFileSync(path.join(agentsDir, "my.md"), "---\nname: my-helper\n---\n# body\n");
136
+ const groups = groupedAvailableAgents();
129
137
  const userGroup = groups.find((g) => g.header === "user-defined");
130
138
  expect(userGroup?.agents).toContain("my-helper");
139
+ // restore
140
+ process.env.HOME = prevHome ?? home;
141
+ process.env.USERPROFILE = prevUserProfile ?? home;
131
142
  fs.rmSync(tmp, { recursive: true, force: true });
132
143
  });
133
144
  });
@@ -309,18 +309,21 @@ When the subagent completes, synthesize the result. Do not re-execute its work.`
309
309
  planNumber: isPlanLevel ? (target.plan ?? undefined) : undefined,
310
310
  });
311
311
 
312
- // For plan-level: also pull out the must_haves summary for inline cache.
313
- const planFile = isPlanLevel
314
- ? path.join(phase.dir, `${phase.slug}-${String(target.plan).padStart(2, "0")}-${phase.slug.split("-").slice(1).join("-") || "plan"}-PLAN.md`)
315
- : null;
316
- // Fall back to findPlanFile if the conventional name didn't match.
317
- let planFileResolved = planFile;
318
- if (isPlanLevel && planFile && !fs.existsSync(planFile)) {
312
+ // For plan-level: find the PLAN.md. We always use the directory scan
313
+ // (the conventional name would require knowing the slug suffix, which
314
+ // is fragile and changed over time). Pattern: NN-MM-slug-PLAN.md.
315
+ let planFileResolved: string | null = null;
316
+ if (isPlanLevel && phase.dir) {
319
317
  const padded = String(target.plan).padStart(2, "0");
320
- const candidates = fs.readdirSync(phase.dir).filter((f) =>
321
- new RegExp(`^\\d+-${padded}-.+-PLAN\\.md$`).test(f),
322
- );
323
- if (candidates.length > 0) planFileResolved = path.join(phase.dir, candidates[0]!);
318
+ let entries: string[];
319
+ try {
320
+ entries = fs.readdirSync(phase.dir);
321
+ } catch {
322
+ entries = [];
323
+ }
324
+ const re = new RegExp(`^\\d{2,}-${padded}-.+-PLAN\\.md$`);
325
+ const match = entries.find((f) => re.test(f));
326
+ if (match) planFileResolved = path.join(phase.dir, match);
324
327
  }
325
328
  const inlineSummary = isPlanLevel ? inlinePlanSummary(planFileResolved) : "_(phase-level exec — iterate all PLAN.md files; each iteration has its own bundle)_";
326
329
 
@@ -124,13 +124,22 @@ export function showDoctor(_cmd: unknown, state: SolyState, ui: InspectUI, confi
124
124
  if (fs.existsSync(phasesDir)) {
125
125
  let totalPlans = 0;
126
126
  let badPlans = 0;
127
+ // Tight match: "NN-something-PLAN.md" — phase number prefix, then
128
+ // slug, then -PLAN.md. Avoids matching "old-PLAN-PLAN.md" or
129
+ // "PLAN.md" without a phase prefix.
130
+ const planRe = /^\d{2,}-.+-PLAN\.md$/;
127
131
  for (const p of fs.readdirSync(phasesDir, { withFileTypes: true })) {
128
132
  if (!p.isDirectory() || p.name.startsWith(".")) continue;
129
133
  for (const f of fs.readdirSync(path.join(phasesDir, p.name))) {
130
- if (/-PLAN\.md$/.test(f)) {
134
+ if (planRe.test(f)) {
131
135
  totalPlans++;
132
- const raw = fs.readFileSync(path.join(phasesDir, p.name, f), "utf-8");
133
- if (!raw.startsWith("---\n") && !raw.startsWith("---\r\n")) badPlans++;
136
+ try {
137
+ const raw = fs.readFileSync(path.join(phasesDir, p.name, f), "utf-8");
138
+ if (!raw.startsWith("---\n") && !raw.startsWith("---\r\n")) badPlans++;
139
+ } catch {
140
+ // Unreadable plan: count as bad so user notices
141
+ badPlans++;
142
+ }
134
143
  }
135
144
  }
136
145
  }
@@ -284,6 +284,15 @@ When the subagent returns, summarize what was refined. Do not execute — planni
284
284
  const featureReadme = path.join(featureDir, "README.md");
285
285
  try {
286
286
  fs.mkdirSync(path.join(featureDir, "tasks"), { recursive: true });
287
+ } catch (e) {
288
+ return {
289
+ handled: true,
290
+ transformedText:
291
+ `soly plan: could not create .soly/features/${target.feature}/tasks/ (${(e as Error).message}). ` +
292
+ `Create it manually: \`mkdir -p .soly/features/${target.feature}/tasks/\``,
293
+ };
294
+ }
295
+ try {
287
296
  if (!fs.existsSync(featureReadme)) {
288
297
  fs.writeFileSync(
289
298
  featureReadme,
@@ -295,8 +304,8 @@ When the subagent returns, summarize what was refined. Do not execute — planni
295
304
  return {
296
305
  handled: true,
297
306
  transformedText:
298
- `soly plan: could not auto-create .soly/features/${target.feature}/ (${(e as Error).message}). ` +
299
- `Create it manually: \`mkdir -p .soly/features/${target.feature}/tasks/\``,
307
+ `soly plan: created .soly/features/${target.feature}/tasks/ but failed to write README.md (${(e as Error).message}). ` +
308
+ `Continue manually: \`touch .soly/features/${target.feature}/README.md\``,
300
309
  };
301
310
  }
302
311
  // Re-read state so the planner sees the new feature