New authoring tooling and a fix for the doc-regeneration defect it exposed. Added: - src/kaizen_agentic/agent_docs.py — render + idempotent upsert of the CLAUDE.md "## Installed Agents" section (shared by installer and CLI) - `kaizen-agentic docs generate [--check]` — idempotent doc refresh / CI gate - `kaizen-agentic create-agent` — scaffold a schema-valid agent - Frontmatter schema validation in `kaizen-agentic validate` (required name/description/category, known category, valid memory/model) - tests: test_agent_docs, test_validate_schema, test_create_agent Fixed: - _update_documentation regex duplicated the Installed Agents block on every run (stopped at the first ### subheading) — now idempotent - declared frontmatter `category` is authoritative (heuristic is fallback) - list_installed_agents reads the frontmatter name, not the filename - renamed agent-project-management.md -> agent-project-assistant.md to satisfy the agent-<name>.md convention (eliminates a name/filename collision that caused install/update to write a divergent duplicate) - test_cli_error_handling no longer installs into the repo root (uses tmp) Version 1.4.0; CHANGELOG, CLI cheat sheet, agency-framework, TODO updated. Workplan KAIZEN-WP-0007 closed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
5.3 KiB
id, type, title, domain, repo, status, owner, topic_slug, state_hub_workstream_id, depends_on, created, updated, tasks
| id | type | title | domain | repo | status | owner | topic_slug | state_hub_workstream_id | depends_on | created | updated | tasks | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| KAIZEN-WP-0007 | workplan | Agent Authoring & Doc Generation (v1.4.0) | custodian | kaizen-agentic | done | kaizen-agentic | custodian | a8bc88a4-0ee3-44c6-aff5-9d7f54a316f5 |
|
2026-06-18 | 2026-06-18 |
|
KAIZEN-WP-0007 — Agent Authoring & Doc Generation
Status: done Owner: kaizen-agentic Repo: kaizen-agentic Target version: 1.4.0 Depends on: WP-0006 (scheduled agent execution)
Goal
Close the WP-0005/WP-0006 deferrals — agent selection/authoring, template schema enforcement, and doc generation — and fix the doc-generation defect they exposed. After this workplan, authoring a new agent and keeping project docs in sync is a first-class, idempotent, validated CLI flow.
Background
AgentInstaller._update_documentation() regenerates the ## Installed Agents
block in a project's CLAUDE.md, but its regex
(## Installed Agents.*?(?=##|\Z)) is non-greedy and the (?=##) lookahead
matches ### Category subheadings inside the section — so each run leaves the
old category lists and footer in place and appends a fresh copy. The block
duplicates and grows unbounded (reported to state-hub; the corrupting write is
ours). validate only checks dependencies and file existence — it does not
enforce the agent frontmatter schema — and there is no scaffolding command for
new agents.
Tasks
T01 — Fix idempotent doc regeneration
- Anchor the replace to a top-level heading:
(?=\n## (?!#)|\Z). - Add a regression test that runs regeneration twice and asserts exactly one
## Installed Agents, one footer, one block per category. - Clean the existing baseline duplication in this repo's
CLAUDE.md.
T02 — Reusable agent-docs module + docs generate
- Extract the "Installed Agents" rendering into a pure function
(
render_installed_agents_section) and an idempotentupsert_installed_agents_section(content, section). _update_documentationreuses them (no behavioral fork).- New
kaizen-agentic docs generate [--target PATH] [--check]refreshes the section for installed agents;--checkexits non-zero if it would change (CI-friendly).
T03 — Enforce agent frontmatter schema in validate
- Add
validate_frontmatter_schema()to the registry: requiredname,description,category;category∈AgentCategory;memory∈ {enabled,disabled} when present;modela non-empty string when present. - Surface schema errors in
kaizen-agentic validatealongside dependency errors, with actionable messages.
T04 — create-agent scaffold
kaizen-agentic create-agent <name> [--category] [--description] [--memory] [--target] [--force]writes a schema-validagents/agent-<name>.mdwith frontmatter + section skeleton.- Missing
--category/--descriptionfall back to interactive prompts. - Refuses invalid category; refuses overwrite without
--force; output passes T03 validation.
T05 — Tests
tests/test_agent_docs.py— idempotency,docs generate --check.tests/test_validate_schema.py— schema pass/fail cases.tests/test_create_agent.py— scaffold + round-trips through registry.
T06 — Docs
docs/CLI_CHEAT_SHEET.md—docs generate,create-agent, schema validate.docs/agency-framework.md— authoring + doc-sync note.CHANGELOG.md[Unreleased];TODO.mdpointer.
Definition of Done
- Doc regeneration is idempotent (N runs == 1 run); baseline cleaned.
kaizen-agentic validatefails on malformed agent frontmatter with clear errors.kaizen-agentic create-agentproduces an agent that passesvalidate.kaizen-agentic docs generate --checkis green on a synced repo.- Full test suite +
make release-checkgreen.
Out of Scope
- Multi-file agent packages / protocol scaffolding (separate workplan).
- Publishing generated docs to external knowledge bases (info-tech-canon).
- Changing the agent frontmatter schema itself (only enforcing the current one).
Notes
- Boundary: the doc-regeneration trigger (a state-hub routine invoking the installer mid-session) is tracked separately in the state-hub inbox; this workplan fixes the write so the trigger becomes harmless/idempotent.
create-agentwrites toagents/; remembermake agents-sync-packagebefore release so packageddata/agents/parity holds (existing release-check gate).