feat(ultraplan-local): M1 — profile recommendation flow in ultrabrief

Adds the profile recommendation step to /ultrabrief-local Phase 4. The
brief stays universal (same questions, same template); the new step is
purely a processing-decision layer that records which profile downstream
commands should apply.

What lands:
- agents/profile-recommender.md — new sonnet agent that scores available
  profiles against the finalized brief (keyword + NFR-signal matching,
  axis bumps, hallucination gate that forbids inventing profile names).
  Emits a fenced JSON block with ranked entries.
- templates/ultrabrief-template.md — frontmatter gains
  recommended_profile, profile_match, profile_rationale (default values
  applied when only `default` is available — true at M1).
- commands/ultrabrief-local.md — Phase 4 gains Step 4h with explicit
  branches: short-circuit when only `default` exists; AskUserQuestion
  confirmation when top score ≥ 0.7; explicit fallback message when below
  threshold; manual selection sub-question on user override. Persists the
  three frontmatter fields to brief.md after user confirmation. JSON
  parser failure falls back to `default` with `profile_match: fallback`
  rather than blocking — silent fallback is the worst outcome, but a
  *visible* fallback is acceptable.
- scripts/profile-loader.mjs — adds selectRecommendation(ranked, opts) +
  RECOMMENDATION_THRESHOLD=0.7 export. Single source of truth for the
  threshold logic so the command spec and the helper agree.
- scripts/profile-loader.test.mjs — 10 new tests for selectRecommendation
  (default-only, empty/malformed input, above/below threshold, custom
  threshold, max-by-score, missing fields). Total now 36/36.
- README.md / CLAUDE.md / marketplace landing — docs reflect M0 + M1
  shipped, M2 + M3 still pending.

In practice nothing changes for users at M1 because only `default` is
available — Step 4h takes the short-circuit path and writes
`profile_match: default-only`. M2 ships the additional profiles that
make the recommender meaningful.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-04-30 14:21:54 +02:00
commit 7e2d9e151e
8 changed files with 609 additions and 15 deletions

View file

@ -90,6 +90,7 @@ Architect sits between `/ultraresearch-local` and `/ultraplan-local`. It matches
| research-scout | sonnet | External docs for unfamiliar tech (conditional, planning only) |
| convention-scanner | sonnet | Coding conventions: naming, style, error handling, test patterns |
| brief-reviewer | sonnet | Task brief quality (5 dimensions: completeness, consistency, testability, scope clarity, research plan validity) |
| profile-recommender | sonnet | Match finalized brief against available profiles; ranked JSON output with brief-anchored rationale (M1+) |
| plan-critic | sonnet | Adversarial plan review (9 dimensions) |
| scope-guardian | sonnet | Scope alignment (creep + gaps) |
| session-decomposer | sonnet | Splits plans into headless sessions with dependency graph |
@ -119,18 +120,30 @@ Architect sits between `/ultraresearch-local` and `/ultraplan-local`. It matches
**Security:** 4-layer defense-in-depth: plugin hooks (pre-bash-executor, pre-write-executor), prompt-level denylist (works in headless sessions), pre-execution plan scan (Phase 2.4), scoped `--allowedTools` replacing `--dangerously-skip-permissions`. Hard Rules 14-16 enforce verify command security, repo-boundary writes, and sensitive path protection.
**Profiles (M0 — foundation, no behaviour change):** Profiles describe
**Profiles (M0/M1 — foundation + recommendation):** Profiles describe
which exploration/review agents, catalog filter, and adversarial regime
ultraplan-local should use. They live as `profiles/*.yaml` and are loaded
by `scripts/profile-loader.mjs` (null-deps Node, limited-subset YAML
parser, agent cross-validation). M0 ships only `default.yaml`, which
captures today's hardcoded Phase 5/9 agent set verbatim — so existing
flows are unchanged. Phase 1 of `/ultraplan-local` now resolves a profile
in the order `--profile flag → brief frontmatter recommended_profile →
flows are unchanged. Phase 1 of `/ultraplan-local` resolves a profile in
the order `--profile flag → brief frontmatter recommended_profile →
default fallback` and reports `Profile: {name} (source: ...)` in the mode
banner. Future milestones: M1 wires recommendation into ultrabrief Phase
4; M2 ships more built-in profiles + replaces the hardcoded agent table;
M3 adds user-extensible profiles under `.claude/ultraplan-profiles/`.
banner.
M1 adds the recommendation flow: `/ultrabrief-local` Phase 4 gains
Step 4h, which spawns the new `profile-recommender` agent (sonnet,
single-shot, brief-anchored scoring) and writes
`recommended_profile`/`profile_match`/`profile_rationale` to the brief
frontmatter. The threshold is `RECOMMENDATION_THRESHOLD = 0.7` (exported
from the loader); below that, the orchestrator surfaces an explicit
fallback message and offers manual selection via AskUserQuestion. When
only `default` is available, Step 4h short-circuits without asking.
The brief itself stays universal — Step 4h does not change which
questions are asked, only which downstream profile applies. Future
milestones: M2 ships more built-in profiles + replaces the hardcoded
agent table; M3 adds user-extensible profiles under
`.claude/ultraplan-profiles/`.
**Pipeline:** `/ultrabrief-local` produces the task brief. `/ultraresearch-local --project <dir>` fills in `{dir}/research/`. `/ultra-cc-architect-local --project <dir>` *(optional, v2.2)* matches available Claude Code features against brief+research and writes `{dir}/architecture/`. `/ultraplan-local --project <dir>` reads brief + research (+ architecture note if present) to produce `{dir}/plan.md`. `/ultraexecute-local --project <dir>` executes and writes `{dir}/progress.json`. All artifacts live in one project directory.