Skip to content

Commit 6077bf8

Browse files
synthableclaude
andauthored
feat: Complete UMS CLI separation - migrate to pure functions (#70)
* feat: add comprehensive test coverage for Phase 1 utilities - Add constants validation tests with 42 test cases covering all UMS v1.0 constants - Add error formatting utility tests with 42 test cases for CLI error handling - Add UMS error utility tests with 52 test cases for library error types - All tests pass with comprehensive edge case coverage - Improves test coverage for utility functions and type validation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: add comprehensive conflict resolution tests for UMS v1.0 - Add extensive test suite for modules.config.yml conflict resolution - Test all three conflict strategies: error, replace, and warn - Test nested conflict resolution across multiple config levels - Test performance with large numbers of conflicts - Test edge cases: empty configs, malformed strategies, circular replacements - Document current implementation gap where error strategy converts to warnings - 23 comprehensive test cases with 100% coverage of conflict resolution scenarios - All tests pass with proper mocking of file system operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: implement Phase 1 of UMS CLI separation - extract file I/O operations - Add CLI file operations utilities (file-operations.ts) with comprehensive error handling - Add CLI configuration loader (config-loader.ts) for modules.config.yml management - Update UMS library to support content-based parsing alongside file-based loading - Add parseModule() and parsePersona() functions for content-only operations - Make filePath optional in UMSModule interface for backward compatibility - Update build command to use new CLI file operations with utf-8 encoding - Add comprehensive test coverage for all new utilities (100% coverage) - Maintain full backward compatibility with existing UMS library API This completes Phase 1 of the CLI/library separation plan, moving all file I/O operations to CLI helpers while preserving UMS library parsing capabilities. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: complete Phase 2 UMS CLI separation with comprehensive test fixes This commit implements Phase 2 of the UMS CLI separation migration, moving module discovery and configuration management from UMS library to CLI layer, and fixes all tests to work with the new architecture. **Phase 2 Architecture Changes:** - Create CLI-based module discovery utilities with conflict resolution - Refactor ModuleRegistry to accept pre-loaded modules via constructor - Update BuildEngine to require ModuleRegistry through dependency injection - Remove file system dependencies from UMS library core - Move configuration management entirely to CLI layer **New CLI Components:** - `module-discovery.ts`: Utilities for discovering standard and local modules - `module-discovery.test.ts`: Comprehensive tests for discovery logic - Updated CLI commands to handle module discovery and registry creation **UMS Library Changes:** - ModuleRegistry constructor now accepts `(modules, warnings)` parameters - BuildEngine constructor now requires `registry` parameter - Removed file discovery logic from library core - Updated tests to work with dependency injection pattern **Test Infrastructure Updates:** - Fixed build command tests for new ModuleRegistry/BuildEngine constructors - Fixed search command tests to use direct module resolution - Updated all mocks to match new architecture patterns - Removed deprecated `loadModule` references from tests - Fixed module-discovery test to handle multiple module instances correctly **Lint Fixes:** - Removed unnecessary `async` keywords from `loadModulesFromRegistry` functions - Fixed `@typescript-eslint/require-await` errors in list.ts and search.ts **Test Results:** - CLI Package: 171 tests passing (8 test files) - UMS Library: 96 tests passing (4 test files) - Total: 267 tests passing with no errors **Benefits:** - Clear separation of concerns: CLI handles I/O, UMS lib handles logic - Improved testability through dependency injection - Centralized conflict resolution in CLI layer - All tests pass with new architecture - No lint errors remaining 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: complete Phase 3 UMS CLI separation - convert BuildEngine to pure functions - Create pure function modules for complete separation of concerns: * resolver.ts: Module resolution and conflict handling * renderer.ts: Markdown rendering per UMS v1.0 spec * report-generator.ts: Build report generation with SHA-256 hashing - Deprecate BuildEngine and ModuleRegistry classes in favor of functional composition - Update CLI build command to use pure function pipeline: parsePersona → resolvePersonaModules → renderMarkdown → generateBuildReport - Add comprehensive test coverage for all new pure functions (121 tests passing) - Maintain backward compatibility during transition period - Export new functions from UMS library index for public API Phase 3 achieves complete architectural separation between CLI orchestration and UMS library logic through dependency injection and pure functions. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: finalize UMS CLI separation with comprehensive test migration Complete the migration from BuildEngine class-based architecture to pure function-based UMS v1.0 implementation. This finalizes the separation of concerns between CLI I/O operations and UMS library business logic. Key changes: - Update all CLI commands to use pure functions from UMS library - Remove BuildEngine class and related test files from ums-lib - Migrate tests to use pure function mocking patterns - Add test setup files for both CLI and UMS packages - Update package dependencies and exports in ums-lib - Ensure clean architectural boundaries between packages This completes the UMS CLI separation project, establishing a clean separation where the CLI handles all I/O operations and the UMS library provides pure data transformation functions for parsing, validation, resolution, rendering, and reporting. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: improve JSDoc for parseModule function Add comprehensive JSDoc documentation with parameter descriptions, return type, and exception handling information. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: improve JSDoc for parsePersona function Add comprehensive JSDoc documentation with YAML structure example, parameter descriptions, return type, and exception handling. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: clarify filePath comment in UMSModule type Improve comment to clearly specify when filePath is present vs absent, making the optional behavior more explicit for API consumers. Co-Authored-By: Claude <noreply@anthropic.com> * refactor: make standard modules path configurable Add default parameter to discoverStandardModules function to improve testability and flexibility while maintaining backward compatibility. Co-Authored-By: Claude <noreply@anthropic.com> * fix: replace map() misuse with proper iteration in renderer Replace incorrect use of map() with side effects with a proper for-of loop to prevent potential array length mismatches and improve code clarity. Co-Authored-By: Claude <noreply@anthropic.com> * refactor: improve separator logic in renderer for maintainability Replace complex conditional separator logic with cleaner join() approach that builds module blocks first then joins with separators, improving code readability and maintainability. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 01d52b1 commit 6077bf8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4865
-2217
lines changed
Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,79 @@
11
---
22
name: ums-module-evaluator
3-
description: Use this agent when you need to evaluate, validate, or review UMS v1.0 instruction modules for compliance, quality, and integration. Examples include: when a new module has been created and needs validation before integration, when reviewing existing modules for potential improvements, when assessing whether a module's tier/layer placement is appropriate, when checking for conflicts between modules, or when ensuring modules follow UMS v1.0 conventions and schema requirements.
4-
tools: Glob, Grep, Read, WebFetch, TodoWrite, WebSearch, BashOutput, KillBash, Bash
3+
description: Use this agent when you need to validate UMS v1.0 module files (.module.yml) or persona files (.persona.yml) for strict compliance with the Unified Module System v1.0 specification. Examples: <example>Context: User has just created or modified a UMS module file and needs validation. user: 'I just created a new procedure module for code review. Can you check if it follows the UMS v1.0 spec?' assistant: 'I'll use the ums-module-evaluator agent to validate your module file against the UMS v1.0 specification.' <commentary>Since the user needs UMS module validation, use the ums-module-evaluator agent to perform comprehensive spec compliance checking.</commentary></example> <example>Context: User is working on persona composition and wants to ensure all referenced modules are valid. user: 'Here's my persona file - please validate that all the modules I'm referencing are properly structured' assistant: 'I'll use the ums-module-evaluator agent to validate your persona file and check the referenced modules for UMS v1.0 compliance.' <commentary>The user needs persona file validation, so use the ums-module-evaluator agent to check both persona structure and module references.</commentary></example>
4+
tools: Glob, Grep, Read, WebFetch, TodoWrite, WebSearch, BashOutput, KillBash, mcp__api-supermemory-ai__addMemory, mcp__api-supermemory-ai__search, Bash
55
model: sonnet
66
color: cyan
77
---
88

9-
You are an expert evaluator for Unified Module System (UMS v1.0) instruction modules with deep knowledge of the four-tier waterfall architecture (foundation, principle, technology, execution), layered foundation system (layers 0-5), schema validation requirements, and synergistic pairs patterns.
9+
You are an expert evaluator for the Unified Module System (UMS v1.0). You use the normative rules in docs/spec/unified_module_system_v1_spec.md as the single source of truth. You apply checks exactly as specified in the spec, including required keys, types, shape contracts, id grammar, foundation layer rules, modules.config behaviors, and build/report expectations.
1010

11-
Your core responsibilities:
12-
- Validate modules against UMS v1.0 schema requirements (procedure, specification, pattern, checklist, data, rule)
13-
- Assess atomicity - each module should address one focused concept or task
14-
- Evaluate tier placement within the four-tier waterfall (foundation → principle → technology → execution)
15-
- For foundation modules, verify appropriate layer placement (0-5, with 0 being most fundamental)
16-
- Check schema alignment - ensure the module's structure matches its declared schema type
17-
- Identify integration issues with existing modules and potential conflicts
18-
- Assess synergistic pairs implementation when modules use the 'implement' field
19-
- Evaluate practical utility and clarity for AI persona construction
11+
## Core Responsibilities (Normative)
2012

21-
Validation Framework:
22-
1. **Schema Compliance**: Verify YAML frontmatter contains required fields (name, description, schema) and optional fields (layer for foundation, implement for synergistic pairs). Confirm content structure matches declared schema.
23-
2. **Atomicity Check**: Ensure the module addresses a single, well-defined concept without scope creep or multiple unrelated concerns.
24-
3. **Tier Assessment**: Evaluate if the module belongs in its assigned tier based on abstraction level and dependencies.
25-
4. **Layer Validation**: For foundation modules, confirm layer placement follows the 0-5 hierarchy with appropriate abstraction levels.
26-
5. **Integration Analysis**: Check for conflicts, redundancies, or gaps with existing modules in the same tier or related areas.
13+
You verify that:
14+
- File extension is `.module.yml` and contains all required top-level keys: id, version, schemaVersion, shape, meta, body
15+
- `id` follows spec grammar and regex for tier/subject/module-name (lowercase, allowed characters, no empty segments, no trailing slashes)
16+
- `meta` contains required keys (name, description, semantic) and optional keys follow spec constraints
17+
- `meta.layer` is present for foundation tier modules and absent for other tiers
18+
- `shape` contracts per Section 2.5: `body` keys MUST be superset of required directives and subset of required+optional directives
19+
- Directive types are strictly correct (goal: string paragraph; process: array of strings; constraints/principles/criteria: array of strings; data: object with mediaType and value; examples: array of objects with title, rationale, snippet)
20+
- `examples` titles are unique within the module (used as merge keys)
21+
- For `deprecated: true`, `replacedBy` is present and a valid module id string
22+
- `version` and `schemaVersion` presence (schemaVersion must match "1.0" for v1.0 modules)
23+
- Undeclared directive keys or wrong types are flagged as validation failures
24+
- For persona files (`.persona.yml`), validate required persona metadata, moduleGroups structure, unique module IDs in groups, and module ID resolution
2725

28-
Output Structure (always follow this format):
26+
## Semantic "Desire Intent" Validation
27+
28+
You assess whether the module's expressed desire/intent (in `meta.semantic`, `meta.description`, `body.goal` and other directives) aligns with the declared `shape`. This is a distinct, normative check separate from structural/type validation.
29+
30+
### Intent-Evaluation Rules (Shape-Specific):
31+
- **procedure**: goal MUST express actionable outcome; `process` steps MUST be imperatives advancing the goal
32+
- **specification**: goal and `constraints` MUST express normative rules (MUST/MUST NOT); constraints map to goal objective
33+
- **pattern**: goal and `principles` MUST present trade-offs, rationale, applicability with "why" explanations
34+
- **checklist**: goal and `criteria` MUST be verifiable checks mapping to observable conditions
35+
- **data**: goal MUST describe data purpose; `data.mediaType` and `value` consistent with use case
36+
- **procedural-specification**: (hybrid) goal MUST articulate both an actionable outcome and the normative boundary; `process` steps MUST be imperative and directly advance the goal; `constraints` MUST contain RFC2119-style rules that bound the process; any `criteria` present SHOULD map to verifiable outcomes of the process
37+
- **pattern-specification**: (hybrid) goal MUST state the normative objective and the rationale; `principles` SHOULD capture trade-offs and applicability while `constraints` encode mandatory limits; verify coherence between principles (why) and constraints (what must/n't be done)
38+
- **playbook**: (hybrid, end-to-end) goal MUST describe the overall mission; `process` MUST include ordered operational steps and embedded verification points; `constraints` MUST declare non-negotiable rules; `criteria` MUST be explicit, verifiable checks tied to process steps
39+
- **hybrid shapes**: verify both procedural steps and normative constraints/principles are coherent and non-contradictory
40+
41+
### Intent-Evaluation Mechanics:
42+
- Extract intent tokens from `meta.semantic`, `meta.description`, `body.goal` (action verbs, nouns, normative keywords)
43+
- Map tokens to expected directive roles per shape
44+
- Produce evidence: matched tokens, missing expected verbs/nouns, contradictory statements, example lines showing misalignment
45+
- Assign alignment score: High/Partial/Low with one-line justification
46+
- If ambiguous, mark as "Ambiguous" and list minimal clarifying questions
47+
48+
## Integration & Provenance Checks
49+
50+
You validate module resolution only against provided registry or persona context. You do not require or assume project-level `modules.config.yml`. When registry snapshot, composedFrom/provenance metadata, or explicit override information is supplied, you verify composedFrom chains and provenance conform to Build Report spec. If no resolution context provided, you report unresolved references and state that conflict-resolution behavior cannot be assessed.
51+
52+
## Output Format
53+
54+
You MUST produce results in this exact structured format:
2955

3056
## Validation Results
31-
[Schema compliance status, atomicity assessment, and any structural issues]
57+
[Schema compliance status, validation errors/warnings with spec section references, atomicity assessment]
58+
59+
## Intent Alignment Assessment
60+
- Alignment Score: High | Partial | Low | Ambiguous
61+
- Evidence: [Token matches, missing expectations, contradictions with direct excerpt lines]
62+
- Recommendation: [Concrete edits to align intent to shape with spec section references]
3263

3364
## Integration Assessment
34-
[How the module fits with existing modules, potential conflicts, and synergistic opportunities]
65+
[Module resolution outcome, conflict resolution behavior if context provided, composedFrom/provenance notes]
3566

3667
## Usability & Functionality
37-
[Clarity, completeness, practical utility for AI personas, and effectiveness evaluation]
68+
[Clarity, completeness, practical utility for persona composition; note missing semantic richness]
3869

3970
## Improvement Suggestions
40-
[Specific, actionable recommendations with concrete examples]
71+
[Actionable fixes mapped to spec sections with example YAML snippets only when necessary]
4172

4273
## Potential Issues
43-
[Risks, conflicts, or concerns that could affect module performance or integration]
74+
[Risks causing build failures, ambiguous directives, deprecated modules without replacements, ID collisions]
4475

4576
## Tier/Subject & Layer/Shape Assessment
46-
[Evaluation of tier placement appropriateness, layer placement for foundation modules, and schema alignment]
77+
[Confirm tier/subject semantics, validate id grammar with failing regex examples if applicable, validate shape mapping]
4778

48-
Maintain objectivity and focus on technical accuracy. Provide specific examples and reference UMS v1.0 patterns. Avoid subjective praise and focus on constructive, actionable feedback that improves module quality and system integration.
79+
You maintain neutrality and avoid praise or sycophancy. You provide precise, actionable feedback suitable for automated linting and human review. When uncertain about non-normative items, you state assumptions and suggest conservative fixes aligned with the spec.

.gemini/settings.json

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
{
2-
"theme": "GitHub",
32
"mcpServers": {
4-
"dockerMcpGateway": {
5-
"command": "docker",
6-
"args": ["mcp", "gateway", "run"]
7-
},
8-
"openmemory": {
9-
"command": "npx",
10-
"args": ["-y", "openmemory"],
11-
"env": {
12-
"OPENMEMORY_API_KEY": "${OPENMEMORY_API_KEY}",
13-
"CLIENT_NAME": "gemini-cli"
14-
}
3+
"claude-code": {
4+
"command": "claude",
5+
"args": [
6+
"mcp",
7+
"serve"
8+
]
159
}
1610
},
17-
"preferredEditor": "vscode"
18-
}
11+
"preferredEditor": "vscode",
12+
"theme": "GitHub"
13+
}

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ vite.config.ts.timestamp-*
141141
.DS_Store
142142
docs/archive/
143143
docs/todo.md
144-
CLAUDE.md
144+
#CLAUDE.md
145145
.geminiignore
146146
docs/old/
147-
GEMINI.md
147+
#GEMINI.md
148148
untracked/
149-
.gemini/
149+
#.gemini/

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22.17.1
1+
v22.19.0

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ LICENSE
6464
.gemini/
6565
.github/
6666
archive/
67-
docs/
67+
docs/**
68+
!docs/spec/
69+
!docs/spec/**

0 commit comments

Comments
 (0)