Skip to content

Commit 3ad33a9

Browse files
authored
Feat/module schema (#35)
* feat(build, validate): Add verbose output option for commands - Implemented verbose logging for the build and validate commands. - Updated handleBuild and handleValidate functions to accept verbose option. - Enhanced user feedback during file validation and persona building processes. * refactor(build, validate): Move validation functions to persona-service - Moved validatePersona and validatePersonaFile functions to a new persona-service module for better organization. - Updated imports in build and validate commands to reflect the new structure. - Improved separation of concerns by isolating persona validation logic. * test(error-handler): Add unit tests for handleError function - Verify error handling with provided spinner - Ensure console logging when no spinner is present - Handle non-Error objects gracefully - Confirm no logging for non-Error instances * test(build): Add unit tests for handleBuild function * test(create-module): Add unit tests for handleCreateModule function - Mock file system and ora dependencies - Test successful module creation - Handle existing module file scenario - Validate default layer usage for recognized subjects - Ensure exit on missing layer for foundation tier - Check for invalid layer values - Handle file system errors during creation * test(create-persona): Add unit tests for handleCreatePersona function * test(module-service): Add unit tests for module validation functions - Implement tests for validateFrontmatter, validateModuleSchema, validateModuleFile, and scanModules functions. - Ensure coverage for valid and invalid scenarios, including required fields and error handling. * test(persona-service): Add unit tests for persona validation * test(validate): Add unit tests for handleValidate function - Implement tests for validating module and persona files - Handle scenarios for no files found and unsupported file types - Mock dependencies for consistent test results * test(validate): Add unit tests for module validation * refactor(module-service): Simplify module validation logic and improve structure - Consolidate module validation into a single function - Remove redundant parsing functions - Enhance error handling for module content validation - Update tests to reflect changes in validation logic * refactor(build): Enhance module validation and output assembly * chore(instructions): add layer null to various module files * refactor(instructions): Remove 'layer: null' from execution/persona-builder modules * refactor(instructions): Remove 'layer: null' from various modules * chore(instructions): update various modules to include 'layer: null' * refactor(instructions): add tier to modules
1 parent 97e43cb commit 3ad33a9

File tree

191 files changed

+2845
-415
lines changed

Some content is hidden

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

191 files changed

+2845
-415
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
tier: execution
3+
name: 'Foundation Layer Rules'
4+
description: "The rule that Foundation modules must be ordered by their 'layer' metadata, from lowest to highest."
5+
tags:
6+
- foundation
7+
- layer
8+
- validation
9+
- ordering
10+
layer: null
11+
---
12+
13+
# Foundation Layer Rules
14+
15+
## Primary Directive
16+
17+
Within the block of `Foundation` modules in a persona, you MUST validate that the modules are ordered by their `layer` property in ascending order.
18+
19+
## Process
20+
21+
1. **Isolate Foundation Block:** Identify all consecutive `Foundation` modules in the persona's list.
22+
2. **Track Maximum Layer:** Initialize a `max_layer_seen` variable to -1.
23+
3. **Iterate and Compare:** For each `Foundation` module in the block:
24+
a. Read its `layer` value from its metadata.
25+
b. If the module's `layer` is LESS THAN `max_layer_seen`, you MUST flag it as a Foundational Layer Violation.
26+
c. Otherwise, update `max_layer_seen` to the current module's `layer` if it is higher.
27+
28+
## Constraints
29+
30+
- This rule only applies to modules within the `Foundation` tier.
31+
- It is valid for modules to have the same layer number (e.g., two `layer: 1` modules in a row). The violation only occurs when a lower layer appears after a higher one.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
tier: execution
3+
name: 'Four-Tier Philosophy'
4+
description: 'The mandatory hierarchical order for persona module tiers: Foundation -> Principle -> Technology -> Execution.'
5+
tags:
6+
- architecture
7+
- validation
8+
- ordering
9+
- tiers
10+
layer: null
11+
---
12+
13+
# Four-Tier Philosophy
14+
15+
## Primary Directive
16+
17+
You MUST validate that the modules in a given persona file follow the strict hierarchical order: `Foundation` modules first, followed by `Principle`, then `Technology`, and finally `Execution`.
18+
19+
## Process
20+
21+
1. **Scan and Categorize:** Ingest the ordered list of module IDs. For each ID, determine its tier from its path.
22+
2. **Track Tier State:** Iterate through the list, keeping track of the current tier. The allowed state transitions are:
23+
- `Foundation` -> `Principle`
24+
- `Principle` -> `Technology`
25+
- `Technology` -> `Execution`
26+
3. **Detect Violations:** If you encounter a module from a tier that violates the allowed state transition (e.g., a `Technology` module appearing after an `Execution` module), you MUST flag it as a Tier Order Violation.
27+
28+
## Constraints
29+
30+
- A persona is not required to contain modules from all four tiers.
31+
- It is valid for a tier to be skipped (e.g., `Foundation` -> `Technology`). The order of the present tiers must be respected.
32+
- Multiple modules from the same tier can appear consecutively. The violation only occurs when a lower tier appears after a higher tier.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
tier: execution
3+
name: 'Machine-Centric Language'
4+
description: 'A style guide for using imperative, unambiguous, and direct language suitable for programming an AI.'
5+
tags:
6+
- language
7+
- style guide
8+
- imperative
9+
- unambiguous
10+
- prompt engineering
11+
- clarity
12+
layer: null
13+
---
14+
15+
# Machine-Centric Language
16+
17+
## Primary Directive
18+
19+
All generated module content MUST be written in imperative, unambiguous, and machine-interpretable language. The module is a configuration file, not a tutorial.
20+
21+
## Process
22+
23+
1. **Use Modal Verbs of Obligation:** All directives MUST use words like "MUST," "WILL," "SHALL."
24+
- _Correct:_ "You MUST validate the input."
25+
- _Incorrect:_ "You should validate the input."
26+
2. **Use Active Voice:** The AI is the subject performing the action.
27+
- _Correct:_ "You WILL analyze the data."
28+
- _Incorrect:_ "The data will be analyzed."
29+
3. **Be Specific and Quantifiable:** Replace vague terms with precise instructions.
30+
- _Correct:_ "If cyclomatic complexity is greater than 10, you MUST refactor."
31+
- _Incorrect:_ "If the code is too complex, you should refactor."
32+
4. **Define All Terms:** Do not assume the AI will infer the correct meaning of a specialized term within the context of the module.
33+
- _Correct:_ "Apply the '5 Whys' technique, where you recursively ask 'Why?' to trace a symptom to its root cause."
34+
- _Incorrect:_ "Do a root cause analysis."
35+
36+
## Constraints
37+
38+
- Do NOT use conversational filler, rhetorical questions, or explanatory prose.
39+
- Do NOT use hedging language (e.g., "maybe," "perhaps," "it seems like").
40+
- Do NOT use analogies or metaphors to explain a concept; instead, define the process algorithmically.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
tier: execution
3+
name: 'Module Structure Standard'
4+
description: 'The mandatory three-section format for all instruction modules.'
5+
tags:
6+
- format
7+
- template
8+
- structure
9+
- standard
10+
- directive
11+
- process
12+
- constraints
13+
layer: null
14+
---
15+
16+
# Module Structure Standard
17+
18+
## Primary Directive
19+
20+
All generated instruction module content MUST strictly adhere to the following three-section format, using Markdown H2 level (`##`) for each heading.
21+
22+
## Process
23+
24+
1. **`## Primary Directive` Section:** This section MUST contain a single, concise, imperative sentence that defines the module's core, non-negotiable command.
25+
2. **`## Process` Section:** This section MUST contain an ordered, step-by-step list (`1.`, `2.`, `3.`) that defines the algorithm or workflow the AI must follow to comply with the Primary Directive.
26+
3. **`## Constraints` Section:** This section MUST contain a bulleted list (`-`) of negative constraints, anti-patterns, or explicit boundaries. It defines what the AI MUST NOT do.
27+
28+
## Constraints
29+
30+
- Do not add any additional top-level `##` headings beyond the three specified.
31+
- Do not omit any of the three required sections.
32+
- You MUST use the exact heading names: `Primary Directive`, `Process`, and `Constraints`.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
tier: execution
3+
name: 'Instruction Module Validation Rules'
4+
description: 'A set of strict validation rules to ensure that every instruction module is high-quality, well-structured, and machine-interpretable.'
5+
tags:
6+
- persona-builder
7+
- validation
8+
- quality
9+
- meta
10+
layer: null
11+
---
12+
13+
# Instruction Module Validation Rules
14+
15+
## Primary Directive
16+
17+
All instruction modules MUST pass a systematic validation process to ensure they are well-formed, clear, and adhere to the established standard before being integrated into a persona.
18+
19+
## Process
20+
21+
1. **Validate Frontmatter:**
22+
- Confirm the presence of `name`, `description`, and `layer`.
23+
- The `name` MUST be descriptive and use Title Case.
24+
- The `description` MUST be a single, concise sentence explaining the module's purpose.
25+
- The `layer` MUST be an integer or `null`.
26+
2. **Validate Structure:**
27+
- The module MUST contain exactly three H2 headings: `## Primary Directive`, `## Process`, and `## Constraints`.
28+
- The content under `Process` MUST be a numbered list (`1.`, `2.`, etc.).
29+
- The content under `Constraints` MUST be a bulleted list (`-`).
30+
3. **Validate Content:**
31+
- **Primary Directive:** It MUST be a single, imperative sentence. It MUST contain a modal verb of obligation (e.g., "MUST," "MUST NOT").
32+
- **Process:** Each step MUST describe an action. The steps should be logical and sequential.
33+
- **Constraints:** Each item MUST clearly define a boundary or a negative command, typically starting with "Do NOT," "MUST NOT," or similar phrasing.
34+
4. **Validate Language:**
35+
- The language MUST be clear, direct, and unambiguous, intended for machine interpretation.
36+
- The module MUST adhere to the principles defined in `Clean Code Principles` metaphorically (e.g., single responsibility, clarity).
37+
- The module MUST NOT contain placeholder text like "[Add details here]".
38+
39+
## Constraints
40+
41+
- A module that fails any validation check MUST NOT be used or integrated.
42+
- Validation is not optional; it is a required step in the module authoring workflow.
43+
- The rules defined in this module apply to all other instruction modules, including this one.

instructions-modules/execution/playbook/audit-documentation/1-verify-and-comment.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2+
tier: execution
23
name: 'Playbook: Verify and Comment Documentation'
34
description: 'A step-by-step process for auditing documentation against a codebase.'
5+
layer: null
46
---
57

68
### Execution Playbook: Audit and Correct Documentation

instructions-modules/execution/playbook/audit-documentation/verify-and-comment.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
2+
tier: execution
23
name: 'Playbook: Verify and Comment Documentation'
34
description: 'A step-by-step process for auditing documentation against a codebase.'
5+
layer: null
46
---
57

68
## Primary Directive

instructions-modules/execution/playbook/debug-issue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
2+
tier: execution
23
name: 'Debug an Issue'
34
description: 'A systematic playbook for debugging, leveraging foundational modules like root-cause-analysis and causal-reasoning.'
45
tags:
56
- execution
67
- playbook
78
- debugging
89
- root-cause-analysis
10+
layer: null
911
---
1012

1113
# Playbook: Debug an Issue

instructions-modules/execution/playbook/design-microservices-architecture.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
2+
tier: execution
23
name: 'Design Microservices Architecture'
34
description: 'A playbook for designing a system based on the microservices architectural style.'
45
tags:
56
- architecture
67
- microservices
78
- playbook
89
- design
10+
layer: null
911
---
1012

1113
# Design Microservices Architecture

instructions-modules/execution/playbook/document-a-function.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
2+
tier: execution
23
name: 'Document a Function'
34
description: 'A playbook for writing comprehensive documentation for a given function, including its parameters, return value, and potential errors.'
45
tags:
56
- execution
67
- playbook
78
- documentation
89
- functions
10+
layer: null
911
---
1012

1113
# Playbook: Document a Function

0 commit comments

Comments
 (0)