feat(new-agent): final-name confirmation with kei- default + override

Wizard's Phase 3 previously computed a deterministic `<slug>-specialist`
name and wrote it directly. Now:

- Phase 3 composition step states the PROPOSED default: `kei-<slug>-specialist`
  (matches the KeiSeiKit kit-prefix convention introduced in commit 3039ada).
- NEW Phase 3.5: one AskUserQuestion call with three options:
  1. `kei-<slug>-specialist` (default, kit convention)
  2. `<slug>-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) <noreply@anthropic.com>
This commit is contained in:
Parfii-bot 2026-04-21 14:07:28 +08:00
parent fc0763870f
commit 2b478ce2b6

View file

@ -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 `<slug>-specialist`)
> 1. Project slug (lowercase, `[a-z0-9-]{3,30}`, e.g. `myapp`proposed agent name will be `kei-<slug>-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 = "<slug>-specialist"`
- Default proposed `name = "kei-<slug>-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 = "<slug>-project.md"`
- `project_claudemd = "<project-path>/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-<slug>-specialist` placeholder).
```json
{
"questions": [
{
"question": "Use proposed agent name?",
"header": "Name",
"multiSelect": false,
"options": [
{"label": "kei-<slug>-specialist", "description": "Proposed default — matches KeiSeiKit kit-prefix convention"},
{"label": "<slug>-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-<slug>-specialist`** — use as-is.
- **`<slug>-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 `<slug>-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/<slug>-specialist.toml` via the Write tool.
`~/.claude/agents/_manifests/<FINAL_NAME>.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/<slug>-specialist.toml
~/.claude/agents/_assembler/target/release/assemble --validate ~/.claude/agents/_manifests/<FINAL_NAME>.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/<slug>-specialist.toml
~/.claude/agents/_assembler/target/release/assemble --in-place ~/.claude/agents/_manifests/<FINAL_NAME>.toml
```
This writes `~/.claude/agents/<slug>-specialist.md` (the generated agent file).
This writes `~/.claude/agents/<FINAL_NAME>.md` (the generated agent file).
---
## Phase 6 — Report
Show a concise block to the user:
Show a concise block to the user. `<FINAL_NAME>` is the name resolved in Phase 3.5 (default `kei-<slug>-specialist`, or the user's override).
```
Agent generated: <slug>-specialist
Agent generated: <FINAL_NAME>
Blocks: baseline, evidence-grading, memory-protocol, rule-pre-dev-gate,
<stack>, <deploy or >, <domain blocks>
Handoffs: kei-code-implementer, kei-critic, kei-validator, <conditional ones>
Manifest: ~/.claude/agents/_manifests/<slug>-specialist.toml
Generated: ~/.claude/agents/<slug>-specialist.md
Manifest: ~/.claude/agents/_manifests/<FINAL_NAME>.toml
Generated: ~/.claude/agents/<FINAL_NAME>.md
Memory: ~/.claude/memory/<slug>-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/<slug>-project.md
# 3. Commit the new agent
cd ~/.claude && git add \
agents/_manifests/<slug>-specialist.toml \
agents/<slug>-specialist.md \
&& git commit -m "feat: new agent <slug>-specialist"
agents/_manifests/<FINAL_NAME>.toml \
agents/<FINAL_NAME>.md \
&& git commit -m "feat: new agent <FINAL_NAME>"
```
Ask the user: "Run the three commands now? (yes / edit first / skip)"