refactor: extract lib/ foundation layer and decompose src/#38
Merged
Conversation
…ator pipeline Extract 5 shared core modules from duplicated implementations: - frontmatter-parser: unified parsing replacing 2 separate implementations - agent-names: table-driven name conversion replacing 4 scattered functions - feature-blocks: configurable strict/lenient stripping replacing 2 copies - markdown-state: session state serialization replacing 3 local functions - file-utils: safe read utilities replacing 8+ try-catch patterns Decompose generate.js (807->148 lines) into focused modules: - file-writer, manifest-expander, stale-pruner, payload-builder - registry-scanner, entry-point-expander Replace hardcoded allowlists with build-time auto-discovered registries: - agent-registry.json scanned from src/agents/*.md - resource-registry.json scanned from skills/templates/references - hook-registry.json scanned from src/hooks/logic/*-logic.js Decompose inject-frontmatter.js (291 lines) into 3 composable transforms: - parse-frontmatter, extract-examples, rebuild-frontmatter Adding a new agent now requires only creating src/agents/<name>.md. Generated output is byte-identical (zero drift). 567 tests pass.
Consolidate atomic-write, file-utils, and writeIfChanged into a single I/O module at src/lib/io with zero intra-project dependencies. Exports: atomicWriteSync, readFileSafe, readJsonSafe, writeIfChanged, ensureDir. Contract tests cover atomicity, fallback semantics, change detection, and idempotent directory creation.
Consolidate three frontmatter boundary detection implementations and two YAML escaping implementations into one authoritative module. Exports: parse, parseFrontmatterOnly, extractValue, escapeYaml, splitAtBoundary, parseValue, parseDoubleQuotedValue. 270 tests including parity validation against all 22 agent files.
Extract 15+ inline validation patterns from MCP handlers and session state into composable assert functions that throw typed ValidationErrors. Validators: assertNonEmptyArray, assertSessionId, assertAllowlisted, assertRelativePath, assertContainedIn. All throw ValidationError from lib/errors with descriptive messages and structured details payloads.
… frontmatter guards
…ders (codex review fixes)
# Conflicts: # claude/src/mcp/handlers/session-state-tools.js # plugins/maestro/src/mcp/handlers/session-state-tools.js # src/mcp/handlers/session-state-tools.js
josstei
pushed a commit
that referenced
this pull request
Apr 14, 2026
Comprehensive analysis of the Qwen adapter contract mismatch, fabricated PR description claims, binary artifacts, and fork divergence from the #38 refactor. https://claude.ai/code/session_01RrDPZpKY1X3o6jX5HXKPEZ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lib/foundation layer: Extracted reusable primitives intosrc/lib/— errors, validation, naming, I/O, frontmatter parsing, and generic discovery framework — each with strict contracts and comprehensive testslib/modules instead of ad-hoc implementations; removed deprecated modules (agent-names.js,atomic-write.js,file-utils.js,session-id-validator.js)generation-session.js,tool-outcome.js, and registry builder helpers; simplifiedregistry-scanner.jsby ~30%scripts/check-layer-boundaries.jsto preventlib/from importing higher layers; integrated into justfileChanges
src/lib/errorsMaestroError,ValidationError,IOError,DiscoveryError)src/lib/validationsrc/lib/namingsrc/lib/iosrc/lib/frontmattersrc/lib/discoverysrc/coresrc/mcpsrc/transformssrc/hookssrc/generatorscriptstestsTest plan
npm test— all existing and new unit/integration tests passnode scripts/check-layer-boundaries.js— no lib/ → higher-layer importsjust generate+ diff