Skip to content

refactor: Phases 6-7 — shared library modules + verb-first CLI#830

Merged
aRustyDev merged 20 commits into
mainfrom
pr/1-phases-6-7
Mar 28, 2026
Merged

refactor: Phases 6-7 — shared library modules + verb-first CLI#830
aRustyDev merged 20 commits into
mainfrom
pr/1-phases-6-7

Conversation

@aRustyDev
Copy link
Copy Markdown
Owner

Summary

  • Phase 6: Extract shared library modules — component type registry (9→12 types), file-io.ts (Result-wrapped I/O), config.ts (TOML config with precedence)
  • Phase 7: Verb-first command decomposition — extract catalog.ts (1324 lines), create 8 verb command modules (add, remove, list, search, info, init, lint, update), backward-compat aliases
  • Follow-ups: Fix lint delegation, add process.exit(EXIT.OK), disambiguate Component interface, add EntityType↔ComponentType bridge, decompose plugin.ts, add valibot config validation

Test plan

  • bun test --cwd packages/cli — zero regressions from baseline
  • Verb-first commands resolve: agents add skill, agents search mcp-server
  • Backward-compat aliases work: agents skill add shows deprecation warning

🤖 Generated with Claude Code

aRustyDev and others added 20 commits March 24, 2026 03:24
Pre-restructure snapshot for regression tracking.
92 failures categorized: hash API (26), skill lifecycle (12),
catalog/search (11), plugin ops (9), git ops (9), other (25).
Success criterion: zero regressions, not zero failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove: build/ (7 .gitkeep files across claude, claude-code, cortex, gemini, vscode, zed)
Add: build/ to .gitignore to prevent re-tracking

Note: crew/, polecats/, witness/, mayor/, refinery/, models/ were already absent
from this repo (never tracked or previously removed). models/ was already gitignored.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Atomic commit: directory rename + all references updated.
- .pre-commit-config.yaml (34 patterns)
- .claude/devrag.json (7 patterns)
- .claude-plugin/marketplace.json (6 plugin sources)
- .github/pre-commit/cspell.json, biome.json
- .github/workflows/plugin-validation.yml
- justfile (38 references + 5 module paths)
- CLAUDE.md, README.md
- ~10 catalog path hardcodes in skill.ts
- 38 TypeScript source files (lib/ + commands/)
- 29 TypeScript test files (test expectations)
- 6 rule markdown files
- 10 plugin JSON config files (sources, schemas, hooks)
- 99 content markdown files (commands, plugins, agents)
- 31 plan/docs markdown files
- entityIdFromPath test expectations updated (context_ -> content_)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Phase 4: Root workspace configuration
- Create root package.json with Bun workspaces: ["packages/*"]
- Move bun.lock to root
- Update 24 cli/ → packages/cli/ refs in justfile
- Update .claude/settings.json hooks paths
- Resolve 3 merge conflicts from parallel Phase 2/3 cherry-picks
  (catalog.ts, taxonomy.ts, skill.ts: use Phase 2 depth + Phase 3 rename)
- bun install from root works, tests pass

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…(ai-c8x)

- Add picomatch dependency (was missing from package.json)
- Clean up orphaned worktrees
- Update CLAUDE.md paths: cli/ → packages/cli/src/, .scripts/ → packages/cli/src/
- Update memory files
- Fix settings.local.json stale cli/ refs

Verification results:
- Tests: 1550 pass / 81 fail (improved from 1580/92 baseline — no regressions)
- CLI: bun run packages/cli/src/bin/agents.ts works
- Stale paths: 0 components/, 0 .scripts/, minimal cli/ in non-critical files
- Workspace: bun install from root resolves all deps

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Expand COMPONENT_TYPES from 9 to 12 entries with kebab-case naming:
- Remove: claude_md (not a component type)
- Rename: mcp_server → mcp-server, output_style → output-style
- Add placeholders: persona, lsp, mcp-client, mcp-tool

Add ComponentTypeMetadata interface and COMPONENT_TYPE_META registry
with discovery patterns, provider mappings, and placeholder flags.
Add helper functions: getComponentMeta, getActiveTypes, parseComponentType.

Update all 20 source/test files across providers, commands, registry,
KG system, SQL, and Python embedding CLI. Zero new test failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…omponentType

Revert coverage-analysis.sql and semantic-search.sql to use KG underscore
format (mcp_server) instead of CLI hyphen format (mcp-server). Update
README.md entity types column to use CLI ComponentType format. Fix test
description strings and add clarifying comment to schema.sql.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
C1+C2: Revert EntityType (KG/database layer) back to underscore format
(output_style, mcp_server) — distinct from ComponentType's kebab-case.
Fix embed.py ENTITY_PATTERNS keys and guess_entity_type return values.
Fix kg.ts and kg-commands.test.ts to match underscore EntityType keys.

I1: Replace hardcoded type arrays in component.ts with getActiveTypes()
and parseComponentType(), enabling flexible user input (underscore,
mixed case) and auto-including all non-placeholder types.

I2: Mark hook as placeholder: true (no providers yet) for consistency.

Test results: 1547 pass / 100 fail / 5 errors (baseline +1 pass).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract two reusable library modules for the CLI package:

- file-io.ts: Unified file I/O with Result error handling (read, write,
  copy, remove, directory ops, existence checks, symlink re-exports)
- config.ts: TOML-based layered configuration with precedence chain
  (defaults -> user config -> project config -> env vars)

Adds smol-toml dependency and 57 new tests (zero regressions).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…, parse warnings

- Deep copy DEFAULT_CONFIG in loadConfig to prevent shared nested references
- Add camelCase<->snake_case key transformation for TOML files (snake_case
  in TOML, camelCase in TypeScript)
- Warn on console.error when config file parsing fails instead of silently
  swallowing errors
- Remove dead withFileTypes parameter from listDirectory signature
- Update config tests for snake_case TOML convention with new coverage

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…g97)

- Reconcile component types: 9→12 (rename mcp_server→mcp-server,
  output_style→output-style, add persona/lsp/mcp-client/mcp-tool
  placeholders, remove claude_md from ComponentType)
- Add ComponentTypeMetadata registry with discovery patterns, providers
- Add helper functions: getComponentMeta, getActiveTypes, parseComponentType
- Create file-io.ts: unified Result-wrapped file I/O operations
- Create config.ts: TOML-based layered CLI config with precedence chain
- 59 new tests, zero regressions (1606 pass / 100 fail baseline)

Closes: ai-miw, ai-geo, ai-g97

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the entire catalog subcommand tree (9 commands: analyze, summary,
forks, cleanup, errors, scrub, stale, backfill, discover) to a dedicated
commands/catalog.ts module. The catalog is a named exception to the
verb-first grammar and is now accessible as both `agents catalog <sub>`
(top-level) and `agents skill catalog <sub>` (backward-compat lazy import).

- skill.ts: 2193 → 893 lines, catalog-only imports removed
- catalog.ts: 1324 lines, self-contained with own constants
- agents.ts: top-level catalog route added
- Zero test regressions (1606 pass / 100 fail / 5 errors — baseline)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Create add, remove, list, search, info, init, lint, update command
modules under packages/cli/src/commands/. Each accepts component type
as first positional arg and routes through ComponentManager. Includes
51 structural tests verifying command definitions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… verb code

Add 8 verb-first commands (add, remove, list, search, info, init, lint,
update) as top-level lazy imports in agents.ts. Remove the corresponding
subcommand definitions and verb-only imports from skill.ts, reducing it
from 893 to 508 lines. Update skill-cli-wiring and verb-commands tests
to reflect the new structure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Old noun-first commands (e.g. "agents skill add foo") now proxy to the
new verb-first modules with a deprecation warning on stderr. This
preserves backward compatibility during the verb-first migration.

- Add compat.ts helper: nounAlias() and deprecatedCommand() factories
- Wire 9 aliases into skill.ts: add, init, list, search, info, update,
  remove, find, outdated
- Each alias injects the component type and delegates to the verb module
- find/outdated use deprecatedCommand for skill-specific lib functions
- Update skill-cli-wiring test to expect aliases instead of undefined
- Add 15 structural tests for the compat aliases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Extract catalog.ts (1324 lines) from skill.ts as standalone command
- Create 8 verb-first command modules: add, remove, list, search,
  info, init, lint, update — all route through ComponentManager
- Wire verb modules into agents.ts as top-level commands
- Reduce skill.ts from 2193 to 621 lines
- Add backward-compat aliases via compat.ts factory — old noun-first
  commands (agents skill add) still work with deprecation warnings
- 63 new tests, zero regressions

CLI grammar now supports:
  agents add skill foo          (verb-first, preferred)
  agents skill add foo          (noun-first, deprecated)
  agents catalog analyze        (pipeline exception)

Closes: ai-nhj, ai-9ld, ai-t23, ai-7ch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- lint.ts: delegate to CClint for skill type instead of stub
- All verb modules: add process.exit(EXIT.OK) on success paths
- remove.ts: drop --yes flag (ComponentProvider.remove lacks support)
- update.ts: require explicit type arg instead of defaulting to skill
- compat.ts: replace `as typeof args` with `as any` + explanatory comment
- catalog.ts: replace all inline require() with ES imports

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- lint.ts: delegate to CClint for skill type instead of stub
- All verb modules: add process.exit(EXIT.OK) on success paths
- remove.ts: remove unused --yes flag (prompts not yet implemented)
- update.ts: require explicit type instead of defaulting to skill
- compat.ts: document type assertion rationale
- catalog.ts: replace 15 require() calls with ES imports

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedsmol-toml@​1.6.110010010090100
Addedplaywright@​1.58.210010010099100

View full report

@aRustyDev aRustyDev merged commit 786857e into main Mar 28, 2026
4 checks passed
@aRustyDev aRustyDev deleted the pr/1-phases-6-7 branch March 28, 2026 02:31
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