From 2b478ce2b67d8d334181d6282b13b0c08f6daa1c Mon Sep 17 00:00:00 2001 From: Parfii-bot Date: Tue, 21 Apr 2026 14:07:28 +0800 Subject: [PATCH] feat(new-agent): final-name confirmation with kei- default + override Wizard's Phase 3 previously computed a deterministic `-specialist` name and wrote it directly. Now: - Phase 3 composition step states the PROPOSED default: `kei--specialist` (matches the KeiSeiKit kit-prefix convention introduced in commit 3039ada). - NEW Phase 3.5: one AskUserQuestion call with three options: 1. `kei--specialist` (default, kit convention) 2. `-specialist` (user namespace, no kei- prefix) 3. Specify custom name (free-text with strict validation: regex ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$, length 3-40, no --, no leading/trailing dash; no auto -specialist suffix) - Resolved value stored as FINAL_NAME and threaded through Phase 4 (manifest Write path), Phase 5 (--validate + --in-place assemble args), and Phase 6 (report block + git-commit example). - Phase 2 prompt updated to reflect the confirmation step. - Invalid custom-name input re-asks instead of falling through (constructive- only rule). Touches only skills/new-agent/SKILL.md. The installed ~/.claude/skills/new-agent/ copy will be refreshed on the next `./install.sh` run. Co-Authored-By: Claude Opus 4.7 (1M context) --- skills/new-agent/SKILL.md | 66 +++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/skills/new-agent/SKILL.md b/skills/new-agent/SKILL.md index a401390..3a9dc18 100644 --- a/skills/new-agent/SKILL.md +++ b/skills/new-agent/SKILL.md @@ -129,7 +129,7 @@ Store as `Q5`, `Q6`, `Q7`. Ask the user to reply in one message with all four fields. Use this exact prompt: > Now give me four lines: -> 1. Project slug (lowercase, `[a-z0-9-]{3,30}`, e.g. `myapp` — final agent name will be `-specialist`) +> 1. Project slug (lowercase, `[a-z0-9-]{3,30}`, e.g. `myapp` — proposed agent name will be `kei--specialist` unless you override in Phase 3.5) > 2. One-line description (shown to the orchestrator) > 3. Project path (e.g. `~/Projects/MyApp/`) > 4. 3-5 domain gotchas / constraints (one per line; these become the forbidden-domain list) @@ -139,7 +139,7 @@ Validate the slug: - Invalid → report the regex failure and re-ask that single line; do not fall through. Build: -- `name = "-specialist"` +- Default proposed `name = "kei--specialist"` — matches the KeiSeiKit kit-prefix convention. The user confirms or overrides in Phase 3.5 below; the value written to the manifest is the one picked there. - `memory_project = "-project.md"` - `project_claudemd = "/CLAUDE.md"` (preserve the `~/` prefix if the user gave it — the assembler does not expand tildes; manifests across the fleet keep `~/` literals) @@ -266,6 +266,43 @@ inherits: --- +## Phase 3.5 — Final name confirmation (AskUserQuestion, ONE call) + +Before writing the manifest, give the user one explicit chance to confirm or override the agent name. Send this `AskUserQuestion`. Substitute the literal slug from Phase 2 into every option label so the user sees, for example, `kei-myapp-specialist` (NOT the literal `kei--specialist` placeholder). + +```json +{ + "questions": [ + { + "question": "Use proposed agent name?", + "header": "Name", + "multiSelect": false, + "options": [ + {"label": "kei--specialist", "description": "Proposed default — matches KeiSeiKit kit-prefix convention"}, + {"label": "-specialist", "description": "Without kei- prefix (user-namespace, won't collide with kit names)"}, + {"label": "Specify custom name", "description": "Enter arbitrary name as one free-text line (must match [a-z0-9-]{3,40})"} + ] + } + ] +} +``` + +Resolve the final name as follows: + +- **`kei--specialist`** — use as-is. +- **`-specialist`** — use as-is. +- **Specify custom name** — follow up with ONE free-text prompt: `Enter the agent name (lowercase [a-z0-9-], 3-40 chars, no double-dash, no leading/trailing dash).` + Validate strictly: + - Regex: `^[a-z0-9]([a-z0-9-]*[a-z0-9])?$` (forbids leading/trailing `-`). + - Length: 3-40 chars. + - No `--` anywhere. + - Invalid → report the failing check and re-ask the same question; do NOT fall through to a default. + - No `-specialist` suffix is auto-appended. Whatever the user types IS the final name. + +Store the resolved value as `FINAL_NAME`. All subsequent phases use `FINAL_NAME` in place of `-specialist` when writing the manifest, running the assembler, and reporting. + +--- + ## Phase 4 — Fill the template + write the manifest 1. Read `~/.claude/agents/_templates/specialist.toml.template` via the Read tool. @@ -288,7 +325,10 @@ inherits: trigger = "anti-pattern / Constructor Pattern sweep on diffs >200 LOC" ``` 5. Write the filled manifest to - `~/.claude/agents/_manifests/-specialist.toml` via the Write tool. + `~/.claude/agents/_manifests/.toml` via the Write tool. + (The `name = "..."` field inside the manifest MUST also equal `FINAL_NAME` — + the assembler uses this as the single source of truth for both the generated + `.md` filename and the frontmatter `name:` value.) CRITICAL invariants (re-check before Write): - All top-level keys appear BEFORE any `[[handoff]]`. @@ -305,7 +345,7 @@ CRITICAL invariants (re-check before Write): Run validate first, assemble only on success: ```bash -~/.claude/agents/_assembler/target/release/assemble --validate ~/.claude/agents/_manifests/-specialist.toml +~/.claude/agents/_assembler/target/release/assemble --validate ~/.claude/agents/_manifests/.toml ``` If validate FAILS: @@ -319,24 +359,24 @@ If validate FAILS: If validate PASSES: ```bash -~/.claude/agents/_assembler/target/release/assemble --in-place ~/.claude/agents/_manifests/-specialist.toml +~/.claude/agents/_assembler/target/release/assemble --in-place ~/.claude/agents/_manifests/.toml ``` -This writes `~/.claude/agents/-specialist.md` (the generated agent file). +This writes `~/.claude/agents/.md` (the generated agent file). --- ## Phase 6 — Report -Show a concise block to the user: +Show a concise block to the user. `` is the name resolved in Phase 3.5 (default `kei--specialist`, or the user's override). ``` -Agent generated: -specialist +Agent generated: Blocks: baseline, evidence-grading, memory-protocol, rule-pre-dev-gate, , , Handoffs: kei-code-implementer, kei-critic, kei-validator, - Manifest: ~/.claude/agents/_manifests/-specialist.toml - Generated: ~/.claude/agents/-specialist.md + Manifest: ~/.claude/agents/_manifests/.toml + Generated: ~/.claude/agents/.md Memory: ~/.claude/memory/-project.md (not yet created — adjust path if your memory layout differs) Edit the MANIFEST, not the .md — the no-hand-edit-agents hook will block direct .md edits. @@ -357,9 +397,9 @@ touch ~/.claude/memory/-project.md # 3. Commit the new agent cd ~/.claude && git add \ - agents/_manifests/-specialist.toml \ - agents/-specialist.md \ - && git commit -m "feat: new agent -specialist" + agents/_manifests/.toml \ + agents/.md \ + && git commit -m "feat: new agent " ``` Ask the user: "Run the three commands now? (yes / edit first / skip)"