@uoyo/mvtt 2.0.0-beta.0 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +131 -147
  3. package/dist/build/assembler.d.ts.map +1 -1
  4. package/dist/build/assembler.js +2 -0
  5. package/dist/build/assembler.js.map +1 -1
  6. package/dist/build/plan-validator.d.ts +26 -0
  7. package/dist/build/plan-validator.d.ts.map +1 -0
  8. package/dist/build/plan-validator.js +225 -0
  9. package/dist/build/plan-validator.js.map +1 -0
  10. package/dist/build/section-loader.d.ts.map +1 -1
  11. package/dist/build/section-loader.js +45 -9
  12. package/dist/build/section-loader.js.map +1 -1
  13. package/dist/cli.d.ts.map +1 -1
  14. package/dist/cli.js +2 -11
  15. package/dist/cli.js.map +1 -1
  16. package/dist/commands/doctor.d.ts.map +1 -1
  17. package/dist/commands/doctor.js +0 -1
  18. package/dist/commands/doctor.js.map +1 -1
  19. package/dist/commands/install.d.ts +1 -4
  20. package/dist/commands/install.d.ts.map +1 -1
  21. package/dist/commands/install.js +18 -14
  22. package/dist/commands/install.js.map +1 -1
  23. package/dist/commands/migrate.d.ts +18 -0
  24. package/dist/commands/migrate.d.ts.map +1 -0
  25. package/dist/commands/migrate.js +163 -0
  26. package/dist/commands/migrate.js.map +1 -0
  27. package/dist/commands/update.d.ts.map +1 -1
  28. package/dist/commands/update.js +35 -2
  29. package/dist/commands/update.js.map +1 -1
  30. package/dist/fs/core-manifest.d.ts +17 -0
  31. package/dist/fs/core-manifest.d.ts.map +1 -0
  32. package/dist/fs/core-manifest.js +76 -0
  33. package/dist/fs/core-manifest.js.map +1 -0
  34. package/dist/fs/install-manifest.d.ts +1 -2
  35. package/dist/fs/install-manifest.d.ts.map +1 -1
  36. package/dist/fs/install-manifest.js +1 -2
  37. package/dist/fs/install-manifest.js.map +1 -1
  38. package/dist/fs/materialize.d.ts.map +1 -1
  39. package/dist/fs/materialize.js +23 -3
  40. package/dist/fs/materialize.js.map +1 -1
  41. package/dist/types/core-manifest.d.ts +12 -0
  42. package/dist/types/core-manifest.d.ts.map +1 -0
  43. package/dist/types/core-manifest.js +2 -0
  44. package/dist/types/core-manifest.js.map +1 -0
  45. package/dist/types/registry.d.ts +13 -5
  46. package/dist/types/registry.d.ts.map +1 -1
  47. package/install-manifest.yaml +31 -27
  48. package/package.json +57 -57
  49. package/registry.yaml +192 -209
  50. package/sources/defaults/config.yaml +27 -30
  51. package/sources/defaults/project-context.yaml +15 -26
  52. package/sources/defaults/session.yaml +31 -23
  53. package/sources/knowledge/core/manifest.yaml +4 -45
  54. package/sources/sections/activation-load-config.md +11 -5
  55. package/sources/sections/activation-load-context.md +26 -11
  56. package/sources/sections/activation-preflight.md +14 -4
  57. package/sources/sections/footer-next-steps.md +35 -9
  58. package/sources/sections/output-language-constraint.md +11 -0
  59. package/sources/sections/role-header.md +13 -13
  60. package/sources/sections/session-update.md +47 -0
  61. package/sources/skills/mvt-analyze/business.md +69 -33
  62. package/sources/skills/mvt-analyze/manifest.yaml +90 -89
  63. package/sources/skills/mvt-analyze-code/business.md +82 -35
  64. package/sources/skills/mvt-analyze-code/manifest.yaml +34 -26
  65. package/sources/skills/mvt-check-context/business.md +89 -42
  66. package/sources/skills/mvt-check-context/manifest.yaml +10 -21
  67. package/sources/skills/mvt-cleanup/business.md +80 -31
  68. package/sources/skills/mvt-cleanup/manifest.yaml +85 -93
  69. package/sources/skills/mvt-config/business.md +94 -26
  70. package/sources/skills/mvt-config/manifest.yaml +15 -27
  71. package/sources/skills/mvt-create-skill/business.md +224 -111
  72. package/sources/skills/mvt-create-skill/manifest.yaml +31 -15
  73. package/sources/skills/mvt-design/business.md +116 -34
  74. package/sources/skills/mvt-design/manifest.yaml +22 -31
  75. package/sources/skills/mvt-fix/business.md +103 -28
  76. package/sources/skills/mvt-fix/manifest.yaml +8 -22
  77. package/sources/skills/mvt-help/business.md +74 -70
  78. package/sources/skills/mvt-help/manifest.yaml +16 -10
  79. package/sources/skills/mvt-implement/business.md +91 -32
  80. package/sources/skills/mvt-implement/manifest.yaml +17 -33
  81. package/sources/skills/mvt-init/business.md +164 -49
  82. package/sources/skills/mvt-init/manifest.yaml +36 -28
  83. package/sources/skills/mvt-manage-context/business.md +175 -0
  84. package/sources/skills/mvt-manage-context/manifest.yaml +123 -0
  85. package/sources/skills/mvt-plan-dev/business.md +75 -0
  86. package/sources/skills/mvt-plan-dev/manifest.yaml +91 -0
  87. package/sources/skills/mvt-quick-dev/business.md +99 -0
  88. package/sources/skills/mvt-quick-dev/manifest.yaml +69 -0
  89. package/sources/skills/mvt-refactor/business.md +104 -33
  90. package/sources/skills/mvt-refactor/manifest.yaml +17 -32
  91. package/sources/skills/mvt-resume/business.md +137 -0
  92. package/sources/skills/mvt-resume/manifest.yaml +71 -0
  93. package/sources/skills/mvt-review/business.md +112 -49
  94. package/sources/skills/mvt-review/manifest.yaml +15 -34
  95. package/sources/skills/mvt-status/business.md +71 -24
  96. package/sources/skills/mvt-status/manifest.yaml +18 -26
  97. package/sources/skills/mvt-sync-context/business.md +148 -23
  98. package/sources/skills/mvt-sync-context/manifest.yaml +51 -39
  99. package/sources/skills/mvt-template/business.md +96 -49
  100. package/sources/skills/mvt-template/manifest.yaml +13 -21
  101. package/sources/skills/mvt-test/business.md +104 -36
  102. package/sources/skills/mvt-test/manifest.yaml +14 -23
  103. package/sources/skills/mvt-update-plan/business.md +72 -0
  104. package/sources/skills/mvt-update-plan/manifest.yaml +132 -0
  105. package/sources/templates/analyze-output/body.md +8 -31
  106. package/sources/templates/analyze-output/manifest.yaml +11 -11
  107. package/sources/templates/design-output/body.md +17 -50
  108. package/sources/templates/design-output/manifest.yaml +11 -11
  109. package/sources/templates/implement-output/body.md +6 -27
  110. package/sources/templates/implement-output/manifest.yaml +11 -11
  111. package/sources/templates/project-context/body.md +13 -0
  112. package/sources/templates/project-context/manifest.yaml +12 -0
  113. package/sources/templates/review-output/body.md +6 -40
  114. package/sources/templates/review-output/manifest.yaml +11 -11
  115. package/sources/templates/test-output/body.md +4 -28
  116. package/sources/templates/test-output/manifest.yaml +11 -11
  117. package/sources/knowledge/core/review-principles.md +0 -51
  118. package/sources/knowledge/patterns/clean-architecture/manifest.yaml +0 -66
  119. package/sources/knowledge/patterns/clean-architecture/review-checklist.md +0 -230
  120. package/sources/knowledge/patterns/ddd/manifest.yaml +0 -83
  121. package/sources/knowledge/patterns/ddd/review-checklist.md +0 -226
  122. package/sources/knowledge/patterns/ddd/tactical-patterns.md +0 -12
  123. package/sources/knowledge/patterns/frontend-react/manifest.yaml +0 -44
  124. package/sources/knowledge/patterns/frontend-react/review-checklist.md +0 -78
  125. package/sources/knowledge/patterns/manifest.yaml +0 -113
  126. package/sources/skills/mvt-add-context/business.md +0 -47
  127. package/sources/skills/mvt-add-context/manifest.yaml +0 -83
  128. package/sources/templates/analyze-code-output/body.md +0 -44
  129. package/sources/templates/analyze-code-output/manifest.yaml +0 -11
  130. package/sources/templates/cleanup-output/body.md +0 -9
  131. package/sources/templates/cleanup-output/manifest.yaml +0 -11
  132. package/sources/templates/config-output/body.md +0 -11
  133. package/sources/templates/config-output/manifest.yaml +0 -11
  134. package/sources/templates/context-check-output/body.md +0 -32
  135. package/sources/templates/context-check-output/manifest.yaml +0 -11
  136. package/sources/templates/fix-output/body.md +0 -30
  137. package/sources/templates/fix-output/manifest.yaml +0 -11
  138. package/sources/templates/init-output/body.md +0 -34
  139. package/sources/templates/init-output/manifest.yaml +0 -11
  140. package/sources/templates/refactor-output/body.md +0 -32
  141. package/sources/templates/refactor-output/manifest.yaml +0 -11
  142. package/sources/templates/status-output/body.md +0 -36
  143. package/sources/templates/status-output/manifest.yaml +0 -11
  144. package/sources/templates/sync-context-output/body.md +0 -16
  145. package/sources/templates/sync-context-output/manifest.yaml +0 -11
@@ -1,35 +1,82 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Scan Codebase
4
- - Scan source directories (src/, lib/, app/, etc.)
5
- - Identify entry points
6
- - Map module/directory structure
7
-
8
- ### Step 2: Extract Entities
9
- - Find domain entities and models
10
- - Identify value objects
11
- - Map relationships between entities
12
-
13
- ### Step 3: Extract Services
14
- - Find service classes and modules
15
- - Identify API endpoints
16
- - Map dependency graph between services
17
-
18
- ### Step 4: Analyze Architecture
19
- - Detect architecture pattern (DDD, Clean Architecture, MVC, etc.)
20
- - Assess confidence level
21
- - Identify layer boundaries
22
-
23
- ### Step 5: Infer Requirements
24
- - Generate feature list from code functionality
25
- - Identify business rules from logic
26
- - Document inferred requirements with confidence levels
27
-
28
- ### Step 6: Update Workspace
29
- 1. Update `.ai-agents/workspace/project-context.yaml`:
30
- - Write detected architecture to `architecture` section
31
- - Write discovered modules, entities, services
32
- 2. Write artifact: `.ai-agents/workspace/artifacts/code-analysis/{timestamp}-analysis.md`
33
- 3. Update `.ai-agents/workspace/session.yaml`:
34
- - Set `session.last_command: "/mvt-analyze-code"`
35
- - Append one-line summary to `recent_actions` (keep max 3)
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Determine Analysis Target
4
+
5
+ Identify which project(s) to analyze:
6
+
7
+ | Variant | Target |
8
+ |---------|--------|
9
+ | `/mvt-analyze-code` | Analyze the first project in `project-context.yaml` (or the only one) |
10
+ | `/mvt-analyze-code --all` | Analyze all projects listed in `project-context.yaml` |
11
+ | `/mvt-analyze-code {name}` | Analyze the project matching the given name |
12
+
13
+ For each target project:
14
+ 1. Read its `path` from `project-context.yaml`
15
+ 2. Use `path` as the source directory for analysis
16
+
17
+ ### Step 2: Load Template
18
+
19
+ Determine the output template for project-context.md:
20
+
21
+ 1. Check `.ai-agents/skills/_templates/custom/project-context.md` -- if exists, use it
22
+ 2. Otherwise, use `.ai-agents/skills/_templates/project-context.md` (default)
23
+ 3. Read the template to understand the required section structure
24
+ 4. The template defines section headings only -- generate content freely for each section based on code analysis
25
+
26
+ ### Step 3: Scan Code Structure
27
+
28
+ For the target project directory:
29
+
30
+ - Map directory structure (one level below source root)
31
+ - Identify entry points (main files, index files, router files)
32
+ - Detect module boundaries (top-level directories under source root)
33
+
34
+ ### Step 4: Extract Modules and Entities
35
+
36
+ - Identify top-level modules and their responsibilities
37
+ - For each module, determine: path, responsibility, dependencies on other modules
38
+ - Identify domain entities (models, schemas, types, interfaces)
39
+ - Classify entities by type: domain model, value object, DTO, configuration
40
+
41
+ ### Step 5: Extract Core Terms
42
+
43
+ Scan code for domain-specific terminology:
44
+
45
+ - Class and interface names that represent domain concepts
46
+ - Abbreviations and their expansions
47
+ - Domain jargon used in comments and docstrings
48
+ - Present as a glossary table: | Term | Meaning |
49
+
50
+ ### Step 6: Extract Business Rules
51
+
52
+ Identify key business logic and constraints:
53
+
54
+ - Validation rules (assertions, guards, precondition checks)
55
+ - Computation rules (formulas, algorithms, calculation logic)
56
+ - State transition rules (workflow steps, status changes)
57
+ - Constraint rules (limits, quotas, access restrictions)
58
+
59
+ ### Step 7: Extract API Overview
60
+
61
+ Identify public interfaces:
62
+
63
+ - HTTP endpoints (routes, handlers) with method and path
64
+ - Public methods of service classes
65
+ - Event publishers and subscribers
66
+ - CLI commands (if applicable)
67
+
68
+ ### Step 8: Generate Output
69
+
70
+ 1. For each analyzed project, generate a section in the template format:
71
+ - Use `# Project: {name}` as the top-level heading
72
+ - Fill each template section with analysis results
73
+ - If a section has no relevant content, include the heading with "(No relevant content detected)"
74
+
75
+ 2. Write the output to `.ai-agents/knowledge/project/_generated/project-context.md`:
76
+ - If analyzing a single project, write that project's section
77
+ - If analyzing multiple projects (`--all`), write all sections separated by `---`
78
+ - If the file already exists, merge with existing content:
79
+ - Replace sections for re-analyzed projects
80
+ - Preserve sections for projects NOT in this analysis run
81
+
82
+ 3. Do NOT update `project-context.yaml` -- it is the lean index, managed by `/mvt-init` and `/mvt-sync-context` only
@@ -3,7 +3,7 @@ output: .claude/skills/mvt-analyze-code/SKILL.md
3
3
 
4
4
  frontmatter:
5
5
  name: mvt-analyze-code
6
- description: "Reverse-analyze existing code to generate context and infer requirements. Use when user wants to understand an existing codebase, generate documentation for legacy code, or onboard to a new project."
6
+ description: "Analyze existing code to generate project-context.md with terms, modules, layers, and business rules. This skill should be used when user wants to understand an existing codebase, generate documentation for legacy code, onboard to a new project, or extract requirements from source code."
7
7
 
8
8
  sections:
9
9
  - type: inline
@@ -12,18 +12,18 @@ sections:
12
12
 
13
13
  ## Purpose
14
14
 
15
- Reverse-analyze existing code to generate context, discover architecture, and infer requirements. Unlike `/mvt-analyze` which works from requirements documents, this skill works from source code. This is an independent operation that does not create a change-id.
15
+ Analyze existing code to generate the project-context.md file, which describes the project's terms, modules, layer structure, business rules, and API overview. This is an independent operation that does not create a change-id.
16
16
 
17
17
  - type: shared
18
18
  source: sections/role-header.md
19
19
  params:
20
20
  role: Analyst
21
- role_desc: "a Requirements Analysis Expert"
21
+ role_desc: "a Code Analysis Expert"
22
22
  decision_rules:
23
23
  - rule: "Source code exists -> Proceed with codebase scanning"
24
24
  - rule: "No source code found -> Warn user and suggest checking project path"
25
- - rule: "Ambiguous architecture -> Present detected pattern with confidence level"
26
- - rule: "Multiple frameworks detected -> List all and ask user to confirm primary"
25
+ - rule: "Multiple frameworks detected -> List all and prompt for primary confirmation"
26
+ - rule: "Custom template exists -> Use it instead of default template"
27
27
  boundaries:
28
28
  - scope: "make architecture decisions"
29
29
  skill: "/mvt-design"
@@ -32,15 +32,30 @@ sections:
32
32
  - scope: "write implementation code"
33
33
  skill: "/mvt-implement"
34
34
 
35
+ - type: inline
36
+ content: |
37
+ ## Variants
38
+
39
+ | Variant | Description |
40
+ |---------|-------------|
41
+ | `/mvt-analyze-code` | Analyze the first (or only) project |
42
+ | `/mvt-analyze-code --all` | Analyze all projects in the workspace |
43
+ | `/mvt-analyze-code {name}` | Analyze a specific project by name |
44
+
35
45
  - type: shared
36
46
  source: sections/activation-load-context.md
37
47
  params:
38
48
  extended_context:
39
49
  - "Scan project source directories for analysis"
50
+ - ".ai-agents/skills/_templates/project-context.md -- Default template for output structure"
51
+ - ".ai-agents/skills/_templates/custom/project-context.md -- Custom template (if exists)"
40
52
 
41
53
  - type: shared
42
54
  source: sections/activation-load-config.md
43
55
 
56
+ - type: shared
57
+ source: sections/output-language-constraint.md
58
+
44
59
  - type: shared
45
60
  source: sections/activation-preflight.md
46
61
  params:
@@ -48,41 +63,34 @@ sections:
48
63
  - order: "1"
49
64
  field: "session.initialized_at"
50
65
  level: "WARN"
51
- message: 'Session not initialized. Run `/mvt-init` first.'
66
+ message: "Session not initialized. Run `/mvt-init` first."
67
+ - order: "2"
68
+ field: "projects[] in project-context.yaml"
69
+ level: "WARN"
70
+ message: "No projects registered. Run `/mvt-init` first."
52
71
 
53
72
  - type: inline
54
73
  content: |
55
74
  ### Independent Operation Rules
56
75
  - This is an independent operation -- no workflow prerequisites required
57
76
  - Does NOT create a change-id
58
- - Artifacts stored under `.ai-agents/workspace/artifacts/code-analysis/` instead of a change-id directory
59
-
60
- ### Step 4: Execute
61
- Proceed to Execution Flow below.
77
+ - Output is written to `.ai-agents/knowledge/project/_generated/project-context.md`
62
78
 
63
79
  - type: file
64
80
  source: ./business.md
65
81
 
66
82
  - type: inline
67
83
  content: |
68
- ## Output Format
69
-
70
- Read and use the output template from: `.ai-agents/skills/_templates/analyze-code-output.md`
84
+ ## Artifact Structure
85
+ Read the document structure template from: `.ai-agents/skills/_templates/project-context.md`
86
+ If a custom version exists at `.ai-agents/skills/_templates/custom/project-context.md`, use the custom version instead.
87
+ The template defines section headings only. Generate content for each section based on code analysis results.
88
+ Write the artifact to: `.ai-agents/knowledge/project/_generated/project-context.md`
71
89
 
72
- If a custom version exists at `.ai-agents/skills/_templates/custom/analyze-code-output.md`, use the custom version instead.
73
-
74
- Fill the template placeholders with the analysis results.
75
-
76
- Every response MUST end with a Suggested Next Steps section.
90
+ - type: shared
91
+ source: sections/session-update.md
77
92
 
78
93
  - type: shared
79
94
  source: sections/footer-next-steps.md
80
95
  params:
81
- next_primary: mvt-analyze
82
- next_primary_desc: "Add requirements on top of discovered structure"
83
- next_alternatives:
84
- - skill: mvt-design
85
- when: "Design new features for existing architecture"
86
- always_show:
87
- - skill: mvt-status
88
- desc: "Check current project state"
96
+ current_skill: mvt-analyze-code
@@ -1,42 +1,89 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Scan Context Files
4
- Scan all files that MVTT may load during operation:
5
-
6
- **Core files** (always loaded):
7
- - `.ai-agents/workspace/session.yaml`
8
- - `.ai-agents/workspace/project-context.yaml`
9
- - `.ai-agents/config.yaml`
10
-
11
- **Knowledge files** (loaded per config):
12
- - `.ai-agents/knowledge/core/`
13
- - `.ai-agents/knowledge/patterns/{active}/`
14
- - `.ai-agents/knowledge/principle/`
15
- - `.ai-agents/knowledge/project/`
16
-
17
- **Artifact files**:
18
- - `.ai-agents/workspace/artifacts/` (all subdirectories)
19
-
20
- **Skill files**:
21
- - `.claude/skills/mvt-*/SKILL.md` (all skill definitions)
22
-
23
- ### Step 2: Estimate Token Consumption
24
- - Calculate approximate tokens for each file: `characters / 4`
25
- - Group by category:
26
- - Core (session + context + config)
27
- - Knowledge (knowledge/)
28
- - Artifacts (artifacts/)
29
- - Skills (skills/)
30
- - Sum totals per category and overall
31
-
32
- ### Step 3: Assess and Recommend
33
- - Determine health status based on total tokens
34
- - Identify Top 5 largest files
35
- - Generate optimization recommendations:
36
- - Oversized project-context.yaml -> Suggest trimming
37
- - Too many old artifacts -> Suggest `/mvt-cleanup`
38
- - Unused knowledge files -> Suggest removal or lazy_load
39
- - Redundant information -> Suggest consolidation
40
- - Each recommendation should be specific and actionable
41
-
42
- ### Step 4: Generate Report
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Load Inputs
4
+ - **Recommended**:
5
+ - `.ai-agents/knowledge/core/manifest.yaml` -- to filter `core/_framework/` (excluded) from `core/user/` (in-scope).
6
+ - **Fallback**: missing `core/manifest.yaml` -> treat all `core/*` files as user-origin (over-counts; flag in report).
7
+
8
+ ### Step 2: Determine In-Scope Files
9
+ This skill measures only files the **user** can reduce or relocate. Framework-fixed overhead is excluded.
10
+
11
+ **In scope (user-actionable):**
12
+ - Index: `.ai-agents/workspace/project-context.yaml`.
13
+ - Semantic context: `.ai-agents/knowledge/project/_generated/project-context.md`.
14
+ - Shared knowledge: every entry in `registry.yaml > knowledge.shared`. For the `core` entry, scan only files marked as user-origin per `core/manifest.yaml` (or whose path begins with `user/`); skip files under `core/_framework/`.
15
+ - Per-skill knowledge: every entry in `registry.yaml > skills.*.knowledge`, grouped by skill.
16
+ - Artifacts: all files under `.ai-agents/workspace/artifacts/` recursively.
17
+
18
+ **Out of scope (do NOT scan):**
19
+ - `.claude/skills/mvt-*/SKILL.md` -- framework-shipped, not user-editable.
20
+ - `.ai-agents/knowledge/core/_framework/**` -- framework-shipped.
21
+ - `.ai-agents/config.yaml`, `.ai-agents/workspace/session.yaml`, `.ai-agents/registry.yaml` -- small, required, and addressed via `/mvt-config` or `/mvt-manage-context`, not here.
22
+
23
+ ### Step 3: Estimate Token Consumption
24
+ - **What**: produce a per-file tokens estimate and per-category subtotals.
25
+ - **How**:
26
+ 1. For each in-scope file: tokens ~= `characters / 4`.
27
+ 2. Group by category: `Index`, `Semantic Context`, `Shared Knowledge`, `Per-Skill Knowledge`, `Artifacts`.
28
+ 3. For Shared Knowledge, compute total once -- this is per-skill overhead (loaded by every skill invocation).
29
+ 4. For Per-Skill Knowledge, compute totals per skill so users can see which skill is heaviest.
30
+ 5. Identify the Top 5 largest single files across the whole in-scope set.
31
+
32
+ ### Step 4: Apply Thresholds and Health Status
33
+ - **What**: assign each file/category a status of `healthy | borderline | oversized`.
34
+ - **How**: read thresholds from `.ai-agents/config.yaml > preferences.context_thresholds.*` if present; otherwise use the defaults below.
35
+
36
+ | Subject | healthy | borderline | oversized |
37
+ |---------|---------|------------|-----------|
38
+ | Total in-scope tokens | <= 12000 | 12001-25000 | > 25000 |
39
+ | Single file tokens | <= 3000 | 3001-6000 | > 6000 |
40
+ | `project-context.md` tokens | <= 4000 | 4001-8000 | > 8000 |
41
+ | Shared Knowledge total tokens | <= 6000 | 6001-12000 | > 12000 |
42
+ | Single change-id artifacts directory tokens | <= 3000 | 3001-8000 | > 8000 |
43
+
44
+ - Overall workspace status = the worst status across all subjects above.
45
+
46
+ ### Step 5: Generate Recommendations
47
+ - **What**: produce a list of specific, actionable recommendations. Each entry is `(trigger, message, suggested skill)`.
48
+ - **How**: walk the table; emit a recommendation for every row whose trigger fires.
49
+
50
+ | Trigger | Message template | Suggested skill |
51
+ |---------|------------------|-----------------|
52
+ | `project-context.md` is `oversized` | "project-context.md is {N} tokens. Regenerate with leaner sections." | `/mvt-analyze-code` |
53
+ | `project-context.md` is `borderline` AND last `/mvt-analyze-code` ran > 30 days ago | "project-context.md is {N} tokens and may be stale. Consider regenerating." | `/mvt-analyze-code` |
54
+ | Total artifacts tokens > artifacts threshold OR > 3 completed changes still in `artifacts/` | "Workspace has {N} tokens of historical artifacts. Archive completed changes." | `/mvt-cleanup` |
55
+ | A specific change-id directory is `oversized` | "artifacts/{id} alone is {N} tokens. Summarize this change." | `/mvt-cleanup` |
56
+ | Shared Knowledge total is `oversized` | "Shared knowledge totals {N} tokens (loaded by every skill). Move skill-specific entries to per-skill." | `/mvt-manage-context move` |
57
+ | A single Shared Knowledge file is `oversized` | "{path} is {N} tokens. Split or move to per-skill." | `/mvt-manage-context move` |
58
+ | Per-skill Knowledge entry exists in `registry.yaml` but its referenced files are missing | "{skill} declares knowledge `{id}` but `{path}` is missing." | `/mvt-manage-context remove` (or restore the file) |
59
+ | A knowledge file exists on disk but no `registry.yaml` entry references it | "{path} is unused (not loaded by any skill)." | `/mvt-manage-context remove` |
60
+ | Two knowledge entries reference identical content (same hash) | "{a} and {b} are duplicates. Consolidate." | manual edit |
61
+
62
+ - **Constraints on recommendations**:
63
+ - Never recommend changes to framework files (`_framework/`, `mvt-*/SKILL.md`).
64
+ - Never recommend deletion without an `/mvt-manage-context` or `/mvt-cleanup` command -- those skills own the actual mutation.
65
+ - If no triggers fire, return a single line: "Workspace context is healthy ({N} tokens total)."
66
+
67
+ ### Step 6: Generate Report
68
+ - Render the report in this order:
69
+ 1. **Summary** -- one line: total tokens + overall status.
70
+ 2. **Per-Category Breakdown** -- table: `category | files | tokens | status`.
71
+ 3. **Top 5 Largest Files** -- table: `path | tokens | category | status`.
72
+ 4. **Per-Skill Knowledge Cost** -- table: `skill | tokens` (sorted desc); include shared knowledge as a separate row labeled `(shared, loaded every time)`.
73
+ 5. **Recommendations** -- numbered list from Step 5; if empty, render the healthy line.
74
+ 6. **Excluded Scope Note** -- one paragraph reminding the user that framework files (`_framework/`, `mvt-*/SKILL.md`, `config.yaml`, `session.yaml`, `registry.yaml`) were not measured here.
75
+ - The report is conversation output; this skill does NOT write any artifact.
76
+
77
+ ### Step 7: (session update handled by shared section)
78
+
79
+ ## Edge Cases & Errors
80
+
81
+ | Case | Handling |
82
+ |------|----------|
83
+ | `registry.yaml` references a knowledge id whose source path is empty / missing | Include in Step 5 recommendations; do NOT count missing files toward token totals |
84
+ | `core/manifest.yaml` cannot be parsed | Treat the whole `core/` tree as in-scope (over-counts); add a note in the report |
85
+ | Workspace has zero artifacts | Skip the artifacts category in Step 6; do not error |
86
+ | Workspace exceeds the artifacts threshold AND the user just ran `/mvt-cleanup` (within last hour per `skill_history`) | Surface but downgrade to a one-line note ("recently cleaned -- remaining {N} tokens are likely active work") |
87
+ | User passes a path argument | This skill ignores arguments; print a one-line note and run as normal (do not narrow scope to a single file -- that is `/mvt-status` territory) |
88
+ | Token estimate disagrees with model's actual consumption | This is expected; the `chars/4` heuristic is an approximation. State this caveat in the Summary line |
89
+ | Two skills declare the same knowledge id | Count the file once for storage but report it under both skills in the Per-Skill table; flag the duplication in Step 5 |
@@ -3,7 +3,7 @@ output: .claude/skills/mvt-check-context/SKILL.md
3
3
 
4
4
  frontmatter:
5
5
  name: mvt-check-context
6
- description: "Analyze context token load and give optimization recommendations. Use when user wants to check how much context MVTT loads, identify large files, or optimize workspace size for better performance."
6
+ description: "Analyze context token load and provide optimization recommendations. This skill should be used when user wants to check how much context MVTT loads, identify large files, or optimize workspace size for better performance."
7
7
 
8
8
  sections:
9
9
  - type: inline
@@ -30,7 +30,7 @@ sections:
30
30
  - scope: "clean up artifacts"
31
31
  skill: "/mvt-cleanup"
32
32
  - scope: "modify context"
33
- skill: "/mvt-add-context"
33
+ skill: "/mvt-manage-context"
34
34
 
35
35
  - type: shared
36
36
  source: sections/activation-load-context.md
@@ -41,34 +41,23 @@ sections:
41
41
  - type: shared
42
42
  source: sections/activation-load-config.md
43
43
 
44
+ - type: shared
45
+ source: sections/output-language-constraint.md
46
+
44
47
  - type: inline
45
48
  content: |
46
49
  ### Step 3: Pre-flight Checks
47
50
  - No blocking checks required.
48
51
 
49
- ### Step 4: Execute
50
- Proceed to Execution Flow below.
51
-
52
52
  - type: file
53
53
  source: ./business.md
54
54
 
55
- - type: inline
56
- content: |
57
- ## Output Format
58
-
59
- Read and use the output template from: `.ai-agents/skills/_templates/context-check-output.md`
60
-
61
- If a custom version exists at `.ai-agents/skills/_templates/custom/context-check-output.md`, use the custom version instead.
62
-
63
- Fill the template with analysis results.
64
-
65
- Every response MUST end with a Suggested Next Steps section.
55
+ - type: shared
56
+ source: sections/session-update.md
57
+ params:
58
+ read_only: true
66
59
 
67
60
  - type: shared
68
61
  source: sections/footer-next-steps.md
69
62
  params:
70
- next_primary: mvt-cleanup
71
- next_primary_desc: "Clean up old artifacts to reduce context size"
72
- next_alternatives:
73
- - skill: mvt-add-context
74
- when: "Update project context if information is outdated"
63
+ current_skill: mvt-check-context
@@ -1,31 +1,80 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Scan Workspace State
4
- - Read all files under `.ai-agents/workspace/artifacts/{change-id}/`
5
- - Read `.ai-agents/workspace/session.yaml`
6
- - Count total artifact files
7
- - Estimate token footprint for each file (~characters / 4)
8
-
9
- ### Step 2: Identify Cleanup Candidates
10
- - Apply cleanup rules to identify candidates
11
- - Calculate current size and projected savings for each
12
-
13
- ### Step 3: Present Cleanup Plan
14
- Show user what will be cleaned:
15
-
16
- | Item | Current Size | Action | Result |
17
- |------|-------------|--------|--------|
18
- | {artifact} | ~{tokens} tokens | {action} | ~{reduced} tokens |
19
- | **Total** | **{total}** | | **{new_total} ({savings} saved)** |
20
-
21
- If `--dry-run` flag is set -> Stop here. Do not proceed.
22
-
23
- ### Step 4: Execute (after user confirmation)
24
- - Summarize identified artifacts (keep key decisions, remove details)
25
- - Update `session.yaml` to reflect cleanup
26
- - Output summary of actions taken
27
-
28
- ### Step 5: Update Workspace
29
- 1. Update `.ai-agents/workspace/session.yaml`:
30
- - Set `session.last_command: "/mvt-cleanup"`
31
- - Append one-line summary to `recent_actions` (keep max 3)
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Load Inputs
4
+ - **Fallback**: if `session.yaml` is missing, refuse to clean -- without state we can't tell what is in-progress vs completed; recommend `/mvt-init` and stop.
5
+
6
+ ### Step 2: Inventory Artifacts
7
+ - **What**: produce a per-change-id inventory with size and last-modified data.
8
+ - **How**:
9
+ 1. Walk `.ai-agents/workspace/artifacts/` and group files by their parent change-id directory.
10
+ 2. For each file: characters, estimated tokens (`chars / 4`), last-modified (mtime).
11
+ 3. For each change-id directory, sum tokens and file count.
12
+ 4. Mark each change-id as `active | in-recent-changes | unindexed | legacy-pattern`:
13
+ - `active` if it matches `session.active_change.id`.
14
+ - `in-recent-changes` if it appears in `session.recent_changes[]` (any status).
15
+ - `unindexed` if neither condition holds and it sits under `artifacts/`.
16
+ - `legacy-pattern` if the directory is `knowledge/patterns/` or matches other legacy markers.
17
+
18
+ ### Step 3: Apply Cleanup Rules
19
+ - **What**: compute Cleanup Candidates from the inventory.
20
+ - **How**: run the rules table (defined in the shared section above) plus the additions below. A single change-id may match multiple rows; collect all proposed actions.
21
+
22
+ | Source | Rule | Proposed action |
23
+ |--------|------|-----------------|
24
+ | `recent_changes[]` entry with `status: completed` AND any task in plan is older than the active change's start | Summarize: collapse multi-file artifacts into a single `summary.md`, keep the plan.yaml verbatim, archive the rest under `artifacts/{id}/_archive/` |
25
+ | Change-id directory marked `unindexed` | List for user review (do NOT auto-archive -- could be in-flight work the user just hasn't registered) |
26
+ | `skill_history` entries beyond the most recent 10 | Collapse into a single summary entry inside session.yaml (rule from Cleanup Rules table) |
27
+ | Directory `knowledge/patterns/` exists | Flag for deletion (legacy pattern data; no replacement) |
28
+ | Empty change-id directories (zero files inside) | Propose deletion of the directory itself |
29
+
30
+ - For each candidate, compute: `current size (tokens)` -> `projected size (tokens)`, expected savings.
31
+
32
+ ### Step 4: Present Cleanup Plan
33
+ - Render the plan as a table:
34
+
35
+ | Item | Category | Current Size | Action | Result |
36
+ |------|----------|-------------|--------|--------|
37
+ | {change-id or path} | {completed | unindexed | stale-history | legacy} | ~{tokens} | {summarize | archive | review-only | delete} | ~{reduced tokens} |
38
+ | **Total** | | **{total}** | | **{new_total} ({savings} saved)** |
39
+
40
+ - Below the table, list any items marked `review-only` (unindexed) with a one-line note: user must decide manually.
41
+ - If `--dry-run` is set, STOP here. Print "(dry run -- no changes applied)" and exit cleanly.
42
+
43
+ ### Step 5: Confirm Before Destructive Steps
44
+ - **Always require confirmation** if the plan includes any of:
45
+ - File deletion (legacy patterns, empty dirs).
46
+ - `summarize` action (collapses multi-file content).
47
+ - `archive` action (moves files into `_archive/`).
48
+ - Confirmation format: a single prompt `Apply cleanup plan? (y / n / show-details)`. `show-details` prints the per-file actions, then re-asks.
49
+ - Do NOT silently delete. Do NOT skip confirmation when `--dry-run` is absent.
50
+
51
+ ### Step 6: Execute the Plan
52
+ - **What**: apply the confirmed actions.
53
+ - **How**:
54
+ 1. **Summarize action**: read the full set of files in the change-id directory; produce a `summary.md` with: title, change-id, status, key decisions (list each ADR/decision title), final outcomes, list of original files. Then move originals to `_archive/`.
55
+ 2. **Archive action**: move files into `_archive/` under the same change-id directory, preserving relative paths.
56
+ 3. **Delete action**: remove only the items explicitly marked for deletion in the confirmed plan; never recurse beyond what was listed.
57
+ 4. **Stale skill_history collapse**: rewrite `session.yaml`'s `skill_history` keeping the most recent 10 detailed entries plus one rolled-up entry summarizing the older ones (count + earliest/latest date).
58
+ 5. All file mutations atomic where possible (write-temp + rename, copy-then-delete for moves).
59
+ 6. If any single action fails, STOP further actions; report what completed, what failed, and leave a recoverable state (do not partially overwrite a file with truncated content).
60
+
61
+ ### Step 7: Report Result
62
+ - Print the actually-applied actions (may differ from the plan if Step 6 stopped early).
63
+ - Show new totals: files cleaned, tokens saved.
64
+ - Recommend `/mvt-check-context` to validate the post-cleanup state if savings exceed ~5k tokens.
65
+
66
+ ### Step 8: (session update handled by shared section)
67
+ - This skill mutates `session.skill_history` directly in Step 6 (collapse). The standard `skill_history` append from the shared section still applies; the collapse runs BEFORE the append so the new entry is preserved at full detail.
68
+
69
+ ## Edge Cases & Errors
70
+
71
+ | Case | Handling |
72
+ |------|----------|
73
+ | `active_change.id` directory matches a "stale completed" rule | Skip cleanup of the active change; never archive in-progress work |
74
+ | `--dry-run` set | Stop after Step 4; do not request confirmation; do not modify any file |
75
+ | Plan would archive ALL artifacts (workspace becomes empty) | Require an extra confirmation: `This will archive every artifact. Continue? (y/n)` |
76
+ | User aborts at Step 5 confirmation | Report "no changes applied" |
77
+ | `_archive/` already exists with content from a prior run | Preserve existing `_archive/` content; new archives are added alongside |
78
+ | File targeted for action no longer exists (concurrent removal) | Skip with a note; do not error out the whole run |
79
+ | Unindexed change-id directory contains only `plan.yaml` | List as review-only; suggest user runs `/mvt-update-plan` or registers it via `/mvt-plan-dev` instead of cleaning |
80
+ | `session.yaml.bak` present from a previous failed run | Overwrite during Step 6 collapse (only the most recent backup is useful) |