Skip to content

feat(core): plugin-registered init steps for agnos init#10

Merged
rgdevme merged 4 commits into
mainfrom
claude/recursing-mendel-a1cf37
May 19, 2026
Merged

feat(core): plugin-registered init steps for agnos init#10
rgdevme merged 4 commits into
mainfrom
claude/recursing-mendel-a1cf37

Conversation

@rgdevme
Copy link
Copy Markdown
Owner

@rgdevme rgdevme commented May 19, 2026

Summary

  • Adds a top-level initSteps?: InitStep[] field on DomainPlugin so each installed domain contributes its own interactive setup prompts to agnos init. Steps declare { id, type, message, default, callback }; the runner orchestrates them in domain-priority order (rules → mcp → skills → docs).
  • Adds agnos init --only=<ids> to scope a re-run to specific domains (skips the agents picker + skills.sh lock migration). Per-domain agnos <domain> init is auto-synthesized from the plugin's initSteps when no explicit cli.init exists.
  • Extracts setRulesSource(target, opts) (with noDispatch?) so the same write/move/dispatch logic powers both the CLI prompt path and the rules-domain callback.

Built-in domain steps

  • rules: source text step, default reads current agnos.json#rules.source (or ./AGENTS.md)
  • skills: skillsDir text step — now actually persists agnos.json#paths.skillsDir, dropping the key when set to default to keep agnos.json clean
  • docs: 6 steps — route, index, content (bool), docRules, injectIndex, injectRules — with dynamic defaults pulling from current agnos.json#docs
  • mcp: opts out — no initSteps, no synthesized mcp init

Public API additions

  • InitStep discriminated union (text | boolean | select) — default accepts a literal or (ctx) => value for dynamic defaults
  • runDomainInitSteps(plugin, ctx, opts) and runAllDomainInitSteps(registry, ctx, opts, onlyIds?) exported from @luxia/core
  • setRulesSource(target, opts) and SetRulesSourceOptions exported from @luxia/core

Test plan

  • pnpm -r build — all 8 packages build clean
  • pnpm -r typecheck — passes
  • pnpm -r test — 160 tests pass (core: 115, skills: 8, docs: 37)
  • pnpm -r lint — no new warnings introduced
  • Manual: agnos init walks rules → skills → docs prompts in order, then picks agents
  • Manual: agnos init -y writes defaults without prompting
  • Manual: agnos init --only=docs runs only docs prompts, skips agents picker
  • Manual: agnos rules init / agnos skill init / agnos docs init each prompt their domain's steps
  • Manual: agnos mcp init errors with "unknown subcommand"

rgdevme added 4 commits May 19, 2026 15:13
Add a top-level `initSteps` array on `DomainPlugin` so each installed
domain can contribute its own interactive setup prompts to `agnos init`.
Each step declares `{ id, type, message, default, callback }` and the
runner orchestrates them in domain-priority order. `agnos <domain> init`
synthesizes the same flow when the plugin doesn't declare `cli.init`.

- rules: prompts for `rules.source` (default reads current value)
- skills: prompts for `paths.skillsDir` and now persists the value
- docs: prompts for route / index / content / docRules / inject flags
- mcp: opts out — no init step and no synthesized init command

Adds `agnos init --only=<ids>` to scope a re-run to specific domains
(skips the agents picker + skills.sh lock migration). Extracts a
`setRulesSource` helper from `runRules` so the same write/move/dispatch
logic powers both the CLI prompt and the rules-domain callback.
Core was importing `@luxia/domain-rules/template` directly and listed
`@luxia/domain-rules` in its runtime dependencies, while domain-rules
already peer-depends on core. Turbo refuses to compute a task graph
with a cycle, so `pnpm typecheck` failed in CI on every PR after the
template-templates refactor (bc3880e) landed.

Replace the direct subpath import with an optional
`getStarterContent?(): string | Promise<string>` hook on `DomainPlugin`.
Core's `ensureStarterRules` / `setRulesSource` now accept a content
provider and fall back to a minimal inline template. The rules-domain
plugin exposes `readDefaultRulesTemplate` via the new hook, and
`agnos rules <path>` (core CLI) looks it up via `loadPlugins` instead
of importing the plugin's package directly.

`@luxia/domain-rules` is removed from core's dependencies.
`runInject` now short-circuits when either `agnos.json#rules.source` is
unset (no rules domain installed / no rules managed by agnos) or when
the configured rules file is missing on disk. Previously it threw when
unset and silently wrote into a fresh file when the path existed in
config but not on disk — both surprising when docs is enabled without
rules.

The docs `injectIndex` / `injectRules` init steps now skip prompting
entirely when no managed rules file exists, via a new optional
`when?(ctx): boolean | Promise<boolean>` predicate on `InitStep`. If
rules.source is missing or the file isn't on disk, the prompts don't
appear and stored values are effectively a no-op downstream.
@rgdevme rgdevme merged commit ad83173 into main May 19, 2026
1 check passed
@rgdevme rgdevme deleted the claude/recursing-mendel-a1cf37 branch May 19, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant