@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,33 +1,104 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Analyze Current Code
4
- - Read target files
5
- - Understand current behavior
6
- - Classify refactoring type from the types table
7
- - Identify refactoring opportunities
8
-
9
- ### Step 2: Risk Assessment
10
- - Assess risk level based on refactoring type
11
- - Identify all callers/dependents of the target code
12
- - Estimate impact scope (files and modules affected)
13
- - Check for existing tests covering the target code
14
-
15
- ### Step 3: Plan Refactoring
16
- - Define refactoring goals
17
- - Identify incremental steps
18
- - Ensure behavior preservation strategy
19
-
20
- ### Step 4: Execute Refactoring
21
- - Apply changes incrementally
22
- - Verify behavior at each step
23
-
24
- ### Step 5: Verify Behavior Preservation
25
- - If tests exist -> Suggest running them
26
- - If no tests -> Describe how to verify behavior is unchanged
27
- - Confirm no regressions in dependent code
28
-
29
- ### Step 6: Update Workspace
30
- 1. Update `.ai-agents/workspace/session.yaml`:
31
- - Set `session.last_command: "/mvt-refactor"`
32
- - Append one-line summary to `recent_actions` (keep max 3)
33
- - Do NOT update `progress` (shortcut operation)
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Load Inputs
4
+ - **Required**:
5
+ - User-specified target (file path, symbol name, module, or "the code I just wrote").
6
+ - **Recommended**:
7
+ - Existing tests covering the target (search by file path, by symbol name, and by sibling test files).
8
+ - `git status` / `git diff` -- to know what is already modified before refactoring.
9
+ - **Fallback**: if no target was specified, ask the user. Do not refactor speculatively.
10
+
11
+ ### Step 2: Locate and Understand Target
12
+ - **What**: produce a precise list of files and line ranges that constitute the refactoring target, plus a one-paragraph statement of what the code currently does.
13
+ - **How**:
14
+ 1. Resolve the target: glob/grep for the named symbol or path.
15
+ 2. List every caller / dependent: grep for the symbol's exported name across the project (and across packages if it is exported beyond the module).
16
+ 3. State the current behavior in plain language; include any non-obvious side effects or invariants you can see in the code.
17
+ - **Output of this step**: a target table (`file | range | role`) and a "current behavior" paragraph; both are shown to user before continuing.
18
+
19
+ ### Step 3: Classify Refactoring Type
20
+ - **What**: pick the smallest type that covers the requested change. Use the Refactoring Types table above for risk levels.
21
+ - **How**: assign one primary type per refactoring task. Multiple types in one run are allowed but each must be tracked separately in the artifact.
22
+ - If the request requires `Change Interface/API` AND the symbol is exported beyond the project (public API, library entry point, IPC boundary): STOP -- this is no longer a refactoring task; recommend `/mvt-design`.
23
+
24
+ ### Step 4: Risk Assessment
25
+ - **What**: assign a final risk score and decide whether explicit confirmation is needed.
26
+ - **How**: combine refactoring type and impact factors.
27
+
28
+ | Factor | +risk |
29
+ |--------|-------|
30
+ | Touches > 10 files | +1 |
31
+ | Touches a public/exported symbol | +1 |
32
+ | No existing tests on the target | +1 |
33
+ | Target is in a critical path (auth, payments, persistence boundary, public API) | +1 |
34
+ | User has uncommitted changes overlapping the target | +1 |
35
+
36
+ - Final risk = type's base level + factors:
37
+ - Low + 0..1 -> proceed silently in Step 7.
38
+ - Medium OR Low + 2 -> require explicit confirmation in Step 6.
39
+ - High OR (Medium + 2) -> require explicit confirmation AND a behavior-preservation strategy from Step 5.
40
+
41
+ ### Step 5: Choose Behavior-Preservation Strategy
42
+ - **What**: pick a verification path BEFORE editing.
43
+ - **How**: choose the row that matches your test reality.
44
+
45
+ | Test reality | Strategy |
46
+ |--------------|----------|
47
+ | Comprehensive tests cover the target | Run them once before changes (capture baseline), once after each step, and once at the end |
48
+ | Some tests exist, gaps known | Do the refactor in incremental steps; after each step, run available tests; for gaps, add a single characterization test BEFORE refactoring (capture current behavior, even if quirky) |
49
+ | No tests exist | Choose ONE: (a) write a minimal characterization test first, OR (b) for Low-risk refactors only, use mechanical refactoring (rename, extract) where the editor / language tooling guarantees behavior. Never attempt High-risk refactors with zero tests |
50
+
51
+ - Document the chosen strategy in the artifact regardless of risk level.
52
+
53
+ ### Step 6: Confirm with User (when required)
54
+ - **Trigger**: per the Step 4 thresholds, or any High-risk type.
55
+ - **Format**: present a single screen with:
56
+ - Target summary (Step 2's table, condensed to file count + symbol).
57
+ - Refactoring type and risk level.
58
+ - Number of callers and a list of the top 5 affected files.
59
+ - Behavior-preservation strategy (Step 5).
60
+ - One yes/no prompt: `Proceed with this refactor? (y / n / show-plan)`.
61
+
62
+ ### Step 7: Plan and Execute Incrementally
63
+ - **What**: apply the change in the smallest reversible steps.
64
+ - **How**:
65
+ 1. Break the refactor into ordered sub-steps (e.g., Rename: 1) update declaration, 2) update callers, 3) update tests, 4) update docs).
66
+ 2. After each sub-step:
67
+ - Compile / type-check the affected files.
68
+ - If a test command was identified in Step 5, run it (or surface it for user to run if running tests is not allowed in this environment).
69
+ - On failure: revert the sub-step, surface the cause, do NOT continue.
70
+ 3. Do not interleave behavior changes (bug fixes, feature toggles) with the refactor. If you spot one, note it for follow-up; do not silently include it.
71
+ 4. Do not modify code outside the planned target unless required for compilation/type correctness; record any such "incidental" edits.
72
+
73
+ ### Step 8: Verify Behavior Preservation
74
+ - **What**: prove (within the chosen strategy) that observable behavior is unchanged.
75
+ - **How**:
76
+ - With tests: all pre-existing tests pass; new characterization tests pass; assert pass count is unchanged or increased.
77
+ - Without tests: list the call sites you visually verified, plus the manual behavior checks you recommend the user run.
78
+ - If anything regresses: revert the most recent sub-step, surface the regression, return to Step 7. Do not declare success.
79
+
80
+ ### Step 9: Write Refactor Notes
81
+ - **Path**: `.ai-agents/workspace/artifacts/{change-id}/refactor-notes.md` if `active_change` exists; otherwise inline summary in conversation only (shortcut mode).
82
+ - **Required content**:
83
+ - `Target` -- file/symbol list, current-behavior paragraph.
84
+ - `Refactoring Type` and final risk level.
85
+ - `Behavior-Preservation Strategy` -- chosen row + tests touched / written.
86
+ - `Steps Applied` -- ordered sub-steps with one-line outcome each.
87
+ - `Incidental Edits` -- any unplanned files touched, with reason.
88
+ - `Verification Result` -- tests run, pass/fail counts; or manual checks recommended.
89
+ - `Follow-ups` -- deferred behavior changes spotted during refactoring.
90
+
91
+ ### Step 10: (session update handled by shared section)
92
+
93
+ ## Edge Cases & Errors
94
+
95
+ | Case | Handling |
96
+ |------|----------|
97
+ | Target spans multiple repos / submodules | STOP -- out of scope; recommend a coordinated change rather than a single refactor |
98
+ | Refactor uncovers a real bug | Pause refactor, document the bug, recommend `/mvt-fix` -- do NOT fix during the refactor |
99
+ | Refactor target is dead code | Confirm with user before deleting; offer alternative of marking deprecated first |
100
+ | Symbol is referenced via reflection / dynamic dispatch / string lookup | Increase risk by +2; require strategy 5(a) (characterization test) before proceeding |
101
+ | User has uncommitted changes overlapping the target | Show diff, recommend committing/stashing first, ask for explicit confirmation if user wants to proceed anyway |
102
+ | Type/test failures persist after revert | Surface a clear summary; suggest user re-run the original test baseline to detect a pre-existing failure unrelated to the refactor |
103
+ | User aborts at Step 6 | Do not modify any file; report "no changes" |
104
+ | Active change is mid-implementation (not yet `done`) | Warn that refactoring during implementation can confuse review/test phases; require explicit confirmation |
@@ -3,7 +3,7 @@ output: .claude/skills/mvt-refactor/SKILL.md
3
3
 
4
4
  frontmatter:
5
5
  name: mvt-refactor
6
- description: "Refactor existing code while preserving behavior. Supports extract, rename, move, decompose, and other refactoring types. Use when user wants to improve code structure without changing functionality."
6
+ description: "Refactor existing code while preserving behavior. This skill should be used when user wants to improve code structure, rename symbols, extract methods or classes, or reorganize code without changing functionality."
7
7
 
8
8
  sections:
9
9
  - type: inline
@@ -21,7 +21,7 @@ sections:
21
21
  role_desc: "an Implementation Specialist"
22
22
  decision_rules:
23
23
  - rule: "Refactoring target specified -> Analyze and plan the refactoring"
24
- - rule: "No target specified -> Ask user what to refactor"
24
+ - rule: "No target specified -> Prompt user for refactoring target"
25
25
  - rule: "Risk level is High -> Warn user and require explicit confirmation"
26
26
  - rule: "Tests exist for target code -> Recommend running them after refactoring"
27
27
  - rule: "No tests exist -> Describe how to verify behavior is unchanged"
@@ -43,26 +43,28 @@ sections:
43
43
 
44
44
  ## Refactoring Types
45
45
 
46
- | Type | Description | Risk Level |
47
- |------|-------------|------------|
48
- | Extract Method/Class | Pull logic into new method or class | Low |
49
- | Rename | Rename symbols for clarity | Low |
50
- | Move | Relocate code to appropriate module/layer | Medium |
51
- | Decompose Conditional | Simplify complex if/switch logic | Medium |
52
- | Replace Inheritance with Composition | Change class hierarchy | High |
53
- | Change Interface/API | Modify public contracts | High |
46
+ | Type | Risk Level | Examples |
47
+ |------|------------|----------|
48
+ | Rename | Low | Variable, function, file rename |
49
+ | Extract Method/Class | Low | Pull repeated logic into a helper |
50
+ | Inline | Low | Eliminate a thin wrapper |
51
+ | Move | Medium | Relocate code to appropriate module/layer |
52
+ | Decompose Conditional | Medium | Simplify complex if/switch logic |
53
+ | Replace Inheritance with Composition | High | Class-hierarchy redesign |
54
+ | Change Interface/API | High | Modify public contracts |
54
55
 
55
56
  - type: shared
56
57
  source: sections/activation-load-context.md
57
58
  params:
58
59
  extended_context:
59
- - ".ai-agents/knowledge/patterns/{pattern.active}/ -- Active architecture pattern knowledge"
60
- - ".ai-agents/knowledge/principle/coding-standards.md -- Project coding standards"
61
60
  - "Related source files to be refactored"
62
61
 
63
62
  - type: shared
64
63
  source: sections/activation-load-config.md
65
64
 
65
+ - type: shared
66
+ source: sections/output-language-constraint.md
67
+
66
68
  - type: inline
67
69
  content: |
68
70
  ### Step 3: Pre-flight Checks
@@ -70,32 +72,15 @@ sections:
70
72
 
71
73
  ### Shortcut Operation Rules
72
74
  - Can execute at any time without checking workflow prerequisites
73
- - Do NOT update `progress` in `session.yaml` after completion
74
- - Only update `session.last_command` and `recent_actions`
75
-
76
- ### Step 4: Execute
77
- Proceed to Execution Flow below.
78
75
 
79
76
  - type: file
80
77
  source: ./business.md
81
78
 
82
- - type: inline
83
- content: |
84
- ## Output Format
85
79
 
86
- Read and use the output template from: `.ai-agents/skills/_templates/refactor-output.md`
87
-
88
- If a custom version exists at `.ai-agents/skills/_templates/custom/refactor-output.md`, use the custom version instead.
89
-
90
- Fill the template placeholders with the refactoring results.
91
-
92
- Every response MUST end with a Suggested Next Steps section.
80
+ - type: shared
81
+ source: sections/session-update.md
93
82
 
94
83
  - type: shared
95
84
  source: sections/footer-next-steps.md
96
85
  params:
97
- next_primary: mvt-review
98
- next_primary_desc: "Verify refactoring changes"
99
- next_alternatives:
100
- - skill: mvt-test
101
- when: "Run tests to confirm behavior preservation"
86
+ current_skill: mvt-refactor
@@ -0,0 +1,137 @@
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Read Session State
4
+
5
+ Extract from the already-loaded session context:
6
+ - `active_change` -- the current change-id (if any), its phase, plan_path, has_plan
7
+ - `recent_changes` -- list of changes with active plans
8
+ - `skill_history` -- last 10 entries (skill name, timestamp, status, change_id)
9
+ - `recent_actions` -- last 5 entries (what was done, when, outcome)
10
+ - `last_command` and `last_skill` -- most recent invocation
11
+
12
+ If session.yaml is missing or empty, jump to Step 6 with the "no session" branch.
13
+
14
+ ### Step 1.5: Discover Pending Plans
15
+
16
+ Scan for in-progress plans using two sources:
17
+
18
+ 1. **Index path**: For each entry in `recent_changes[]`, read its `plan_path` if the file exists.
19
+ 2. **Fallback scan**: Glob `.ai-agents/workspace/artifacts/*/plan.yaml`, read any files not already covered by (1).
20
+
21
+ For each found plan.yaml, read and filter:
22
+ - Include only plans where `plan.status == "in_progress"`.
23
+ - Capture: `change_id`, `title`, task progress (`done_count / total_count`), `updated_at`.
24
+ - Sort candidates by `updated_at` descending.
25
+
26
+ ### Step 1.6: Select Target Change
27
+
28
+ | Candidates | Behavior |
29
+ |------------|----------|
30
+ | 0 | Skip to Step 2 — use legacy `active_change` / `skill_history` flow (no plan context). |
31
+ | 1 | Auto-select. Print: "Found one active plan: **{title}** ({progress}). Resuming." |
32
+ | ≥2 | **Pause and prompt**. Display candidate table and wait for user input. |
33
+
34
+ **Candidate table format** (≥2 candidates):
35
+
36
+ ```
37
+ Found {N} active plans. Select which to resume:
38
+
39
+ | # | change-id | title | progress | last_updated |
40
+ |---|-----------|-------|----------|--------------|
41
+ | 1 | {id} | {t} | {d}/{n} | {relative} |
42
+ | ...
43
+
44
+ Enter a number, a change-id, or "none" to skip plan context:
45
+ ```
46
+
47
+ **Explicit argument override**: If the user invoked `/mvt-resume {change-id}`, use that change-id directly — skip the table, locate and load its plan.yaml (error if not found or not in_progress).
48
+
49
+ After selection, set `selected_change_id` for use in subsequent steps. If "none" or 0 candidates, `selected_change_id = null`.
50
+
51
+ ### Step 2: Inspect Recent Artifacts
52
+
53
+ If `selected_change_id` is set:
54
+ - List files under `.ai-agents/workspace/artifacts/{selected_change_id}/`, sorted by mtime descending
55
+ - Exclude `plan.yaml` from the artifact list (it gets its own section)
56
+ - Take the top 5
57
+
58
+ Else if `active_change.id` is set (no-plan fallback):
59
+ - List files under `.ai-agents/workspace/artifacts/{active_change.id}/`, sorted by mtime descending
60
+ - Take the top 5
61
+
62
+ Otherwise:
63
+ - List all files under `.ai-agents/workspace/artifacts/` (recursive), sorted by mtime descending
64
+ - Take the top 5
65
+
66
+ For each artifact, capture: file path, mtime, size (in tokens estimate = chars / 4), and the change-id it belongs to.
67
+
68
+ ### Step 3: Determine Resume Point
69
+
70
+ **Plan-aware path** (when `selected_change_id` has a valid plan.yaml):
71
+
72
+ Read the plan's `current_task`. The resume point = that task. Next-step recommendation = the task's `skill_hint` (or infer from task title if skill_hint is absent).
73
+
74
+ Also filter `skill_history` to entries matching `change_id == selected_change_id` (entries with empty change_id are excluded from this filtered view).
75
+
76
+ **Legacy path** (no plan):
77
+
78
+ Pick the **resume point** by precedence:
79
+
80
+ | Condition | Resume point | Phase label |
81
+ |-----------|--------------|-------------|
82
+ | `active_change` is set with non-empty `phase` | `{active_change.phase}` | from session |
83
+ | `active_change` is set without phase | inferred from last skill in history | inferred |
84
+ | `skill_history[0]` exists | last skill | last skill |
85
+ | Nothing | `none` | new project |
86
+
87
+ Map skill -> next-step recommendation:
88
+
89
+ | Last skill | Suggested next |
90
+ |-----------|----------------|
91
+ | mvt-init | mvt-analyze-code (if has code) or mvt-analyze (if requirements available) |
92
+ | mvt-analyze | mvt-design |
93
+ | mvt-analyze-code | mvt-analyze (if requirements pending) or mvt-design |
94
+ | mvt-design | mvt-plan-dev (if change is large) or mvt-implement |
95
+ | mvt-implement | mvt-review |
96
+ | mvt-review | mvt-fix (if findings) or mvt-test |
97
+ | mvt-fix | mvt-review (re-review) or mvt-test |
98
+ | mvt-test | mvt-cleanup or next change |
99
+ | mvt-cleanup | new change via mvt-analyze |
100
+ | (other) | mvt-status |
101
+
102
+ ### Step 4: Load Plan Progress (plan-aware path only)
103
+
104
+ If `selected_change_id` has a plan, generate the **Plan Progress** section:
105
+
106
+ - Read all tasks from plan.yaml.
107
+ - Build a compact status table: `| # | id | title | status | skill_hint |`
108
+ - Highlight `current_task` row (prefix with `>>` or bold).
109
+ - Count summary: `Done: {d}, In Progress: {ip}, Pending: {p}, Blocked: {b}, Skipped: {s}`
110
+
111
+ And the **Current Task Detail** section:
112
+
113
+ - `title`
114
+ - `acceptance` criteria (bulleted list)
115
+ - `depends_on` with status of each dependency (all should be `done`)
116
+ - `notes` (if non-empty)
117
+ - `skill_hint` -> recommendation
118
+
119
+ ### Step 5: Generate Resume Report
120
+
121
+ Render via the `resume-output.md` template. Sections to fill:
122
+
123
+ 1. **Active Task** -- name, change-id, phase, started_at (from active_change or selected plan)
124
+ 2. **Plan Progress** -- (only when plan exists) task table + counts + current task detail
125
+ 3. **Recent Skill History** -- last 5 entries from skill_history (filtered to selected change if applicable)
126
+ 4. **Recent Artifacts** -- the top 5 artifacts collected in Step 2 (path, mtime, size)
127
+ 5. **Resume Point** -- a one-paragraph natural-language summary of "where we are"
128
+ 6. **Recommended Next Step** -- the mapped next skill from Step 3, with justification
129
+
130
+ ### Step 6: Edge Cases
131
+
132
+ - **No session**: report "No session found. Run `/mvt-init` to start a project."
133
+ - **No active_change AND no history AND no plans**: report "No active task. Suggested entry points: `/mvt-init`, `/mvt-analyze`, `/mvt-status`."
134
+ - **active_change set but referenced artifacts missing**: warn "Artifact directory `{path}` not found -- task state may be stale. Verify with `/mvt-status` or run `/mvt-cleanup`."
135
+ - **Last skill ended in failure** (skill_history entry status=failed): surface the failure summary first, suggest retry of that skill rather than advancing.
136
+ - **Plan exists but plan.yaml is invalid** (parse error or schema violation): warn "plan.yaml is corrupted or invalid. Run `/mvt-plan-dev` to regenerate, or `/mvt-status` to inspect."
137
+ - **Stale task warning**: If plan's `current_task` has status `in_progress` but the plan's `updated_at` is more than 5 days old, append a notice: "Current task has been in_progress for {N} days without updates. Consider running `/mvt-update-plan` to refresh status."
@@ -0,0 +1,71 @@
1
+ name: mvt-resume
2
+ output: .claude/skills/mvt-resume/SKILL.md
3
+
4
+ frontmatter:
5
+ name: mvt-resume
6
+ description: "Resume an in-progress development task in a new conversation. Reads session.yaml (active_change, skill_history, recent_actions) and recent artifacts to reconstruct context. Does not read git state."
7
+
8
+ sections:
9
+ - type: inline
10
+ content: |
11
+ # MVT Resume
12
+
13
+ ## Purpose
14
+
15
+ Reconstruct an in-progress development task in a fresh conversation by replaying state from `session.yaml`, recent artifacts, and plan.yaml (if one exists). When multiple plans are in-flight, prompt the user to select which change to resume. Use this skill at the start of a new conversation to pick up exactly where the last session left off.
16
+
17
+ ## Arguments
18
+
19
+ | Argument | Required | Description |
20
+ |----------|----------|-------------|
21
+ | `{change-id}` | No | Directly resume a specific change (skips candidate selection). Error if not found or not in_progress. |
22
+
23
+ - type: shared
24
+ source: sections/role-header.md
25
+ params:
26
+ role: Conductor
27
+ role_desc: "a Workflow Coordinator"
28
+ decision_rules:
29
+ - rule: "Multiple in_progress plans found -> Pause and display candidate table, wait for user selection"
30
+ - rule: "Exactly one in_progress plan found -> Auto-select it and proceed"
31
+ - rule: "No plans found BUT active_change is set -> Fall back to legacy skill_history-based resume"
32
+ - rule: "active_change is empty AND skill_history is empty AND no plans -> Recommend `/mvt-init` or `/mvt-status`"
33
+ - rule: "Plan exists and has current_task -> Use current_task's skill_hint as next-step recommendation"
34
+ - rule: "Plan's current_task has been in_progress for >5 days -> Surface stale warning"
35
+ - rule: "Last skill failed or was interrupted -> Surface the failure context, suggest retry"
36
+ boundaries:
37
+ - scope: "read git state (branch, diff, commits)"
38
+ skill: "(Out of scope -- this skill is session-state only)"
39
+ - scope: "modify any files"
40
+ skill: "(Read-only)"
41
+ - scope: "run analyses or tests"
42
+ skill: "(Use the recommended next skill)"
43
+
44
+ - type: shared
45
+ source: sections/activation-load-context.md
46
+
47
+ - type: shared
48
+ source: sections/activation-load-config.md
49
+
50
+ - type: shared
51
+ source: sections/output-language-constraint.md
52
+
53
+ - type: shared
54
+ source: sections/activation-preflight.md
55
+ params:
56
+ checks:
57
+ - order: "1"
58
+ field: "session.initialized_at"
59
+ level: "WARN"
60
+ message: "Session not initialized. Run `/mvt-init` first."
61
+
62
+ - type: file
63
+ source: ./business.md
64
+
65
+ - type: shared
66
+ source: sections/session-update.md
67
+
68
+ - type: shared
69
+ source: sections/footer-next-steps.md
70
+ params:
71
+ current_skill: mvt-resume
@@ -1,49 +1,112 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Identify Review Target
4
- - Latest implementation files from current change
5
- - Files specified by user
6
- - Files in current change artifacts
7
-
8
- ### Step 2: Load Context
9
- - Read target files
10
- - Read project-context for architecture expectations
11
- - Load review checklist for active pattern (if available)
12
-
13
- ### Step 3: Analyze Code
14
- - Check architecture compliance (layer assignments, dependencies)
15
- - Check code quality (functions small/focused, naming, duplication)
16
- - Check error handling
17
- - Check edge cases
18
- - Check readability
19
- - If `--aspect` specified -> Focus on that aspect
20
-
21
- ### Step 4: Categorize Issues
22
- Classify each finding by severity:
23
-
24
- | Level | Description | Action Required |
25
- |-------|-------------|-----------------|
26
- | **Critical** | Bugs, security issues, breaks functionality | Must fix before merge |
27
- | **Warning** | Code quality issues, potential bugs | Should fix |
28
- | **Suggestion** | Improvements, best practices | Nice to have |
29
-
30
- ### Step 5: Update Workspace
31
- 1. Update `.ai-agents/workspace/session.yaml`:
32
- - Set `progress.review: done`
33
- - Set `session.last_command: "/mvt-review"`
34
- - Append one-line summary to `recent_actions` (keep max 3)
35
- 2. Write artifact: `.ai-agents/workspace/artifacts/{change-id}/review.md`
36
-
37
- ## Review Checklist
38
-
39
- ### Architecture Compliance
40
- - [ ] Follows established architecture pattern
41
- - [ ] Correct layer assignment
42
- - [ ] Proper dependency direction
43
- - [ ] Module boundaries respected
44
-
45
- ### Code Quality
46
- - [ ] Functions are small and focused
47
- - [ ] Naming is clear and consistent
48
- - [ ] No code duplication
49
- - [ ] Proper error handling
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Load Inputs
4
+ - **Required**:
5
+ - The set of files to review (see Step 2 for resolution).
6
+ - **Fallback**:
7
+ - If `design.md`/`implementation.md` are missing, downgrade to "code-only review": skip the design-compliance checks (Step 4 row group A) and note the limitation in the artifact.
8
+ - If `project-context.md` is missing, skip layer-compliance checks and note the limitation.
9
+
10
+ ### Step 2: Resolve Review Target
11
+ - **What**: produce a definitive file list to review.
12
+ - **How**: pick the FIRST source that yields a non-empty list.
13
+
14
+ | Source | Condition |
15
+ |--------|-----------|
16
+ | User-provided file paths | User passed paths/globs as arguments |
17
+ | `--aspect` filter | User specified an aspect; intersect aspect-relevant files with the active change's `Change Tracking` |
18
+ | `implementation.md` -> `Files Touched` | Active change has implementation artifact |
19
+ | `git diff --name-only main...HEAD` | Inside a feature branch |
20
+ | `git diff --name-only HEAD~1` | Last-commit fallback |
21
+
22
+ - If the resolved list is empty, STOP and ask the user to specify the target.
23
+ - If the list exceeds ~30 files, ask the user to scope down OR confirm a high-level (per-module) review depth.
24
+
25
+ ### Step 3: Determine Review Depth
26
+ - **Default**: full review across all axes (Step 4).
27
+ - `--aspect <name>`: narrow to a single axis. Supported aspects: `architecture`, `quality`, `errors`, `edge-cases`, `security`, `naming`, `tests`. Other aspects -> ask user to clarify.
28
+ - For files >300 lines, do a structural pass first (interfaces, exports, key paths) before line-level review; do not attempt line-by-line on huge files.
29
+
30
+ ### Step 4: Run Review Checks
31
+ - **What**: produce findings, each tagged with severity, location, and a concrete remedy.
32
+ - **How**: walk the checklist below. Skip any group whose inputs were missing per Step 1 fallback notes.
33
+
34
+ **Group A -- Design / Layer Compliance** (requires design.md OR project-context.md)
35
+ - Each file is in the module/layer assigned by design or project-context.
36
+ - Dependency direction respects layer rules (no upward imports, no forbidden cross-module reaches).
37
+ - Public interfaces match `Key Interfaces` from design.
38
+ - Implementation `Deviations from Design` are documented; undocumented deviations are findings.
39
+
40
+ **Group B -- Code Quality**
41
+ - Functions are small and focused; flag functions > ~50 lines or with > ~3 nested control levels.
42
+ - Naming is clear, consistent with `naming-conventions.md`, and matches surrounding code.
43
+ - No duplication: same logic appearing >= 3 times warrants extraction.
44
+ - No premature abstraction: a single-use helper / interface / wrapper is a finding.
45
+ - No dead code, unused imports, commented-out blocks left behind.
46
+
47
+ **Group C -- Error Handling**
48
+ - Error handling appears only at system boundaries (HTTP, DB, external API, file IO, queue).
49
+ - Interior try/catch must have an explicit reason in a one-line comment, otherwise findable.
50
+ - No swallowed errors (catch without rethrow / log / explicit recovery).
51
+ - Error types are specific where the language supports it (no bare `catch Exception` without rethrow).
52
+
53
+ **Group D -- Edge Cases**
54
+ - Boundary inputs handled: empty / null / max length / negative / zero / unicode.
55
+ - Concurrency: shared state, async ordering, idempotency where required by design.
56
+ - Resource lifecycle: opened resources are closed on all paths.
57
+ - Off-by-one: loop bounds, slice indices, pagination cursors.
58
+
59
+ **Group E -- Tests** (if test files are in scope)
60
+ - Each business rule from `project-context.md` has at least one test case.
61
+ - Tests assert behavior, not implementation details.
62
+ - No `skip` / `only` / commented-out tests left in.
63
+ - Test names describe the scenario, not the function name.
64
+
65
+ **Group F -- Security** (if user requirements mention auth/data sensitivity OR `--aspect security`)
66
+ - No secrets in code or test fixtures.
67
+ - Input validation at every external boundary.
68
+ - Auth/authz checks present on every protected endpoint or operation.
69
+ - SQL/NoSQL/HTML rendered through parameterized / escaped APIs.
70
+
71
+ ### Step 5: Categorize and De-duplicate Findings
72
+ - **Severity**: assign each finding using the table below.
73
+
74
+ | Level | Definition | Examples |
75
+ |-------|------------|----------|
76
+ | **Critical** | Bug, security flaw, broken contract, data loss risk, layer violation that breaks isolation | Swallowed exception in payment path; missing auth on protected endpoint; forbidden cross-layer import |
77
+ | **Warning** | Likely problem or significant quality issue: not a bug today, but high-risk or maintainability hazard | Function 200 lines; duplicated logic 3x; missing tests for a documented business rule |
78
+ | **Suggestion** | Improvement, polish, taste preference | Variable name could be clearer; could split a small helper; minor docstring gap |
79
+
80
+ - Merge duplicate findings (same root cause appearing in multiple files) into one entry with a list of locations.
81
+ - Each finding must include: file, line range, severity, observation, recommendation.
82
+
83
+ ### Step 6: Write Artifact
84
+ - **Path**: `.ai-agents/workspace/artifacts/{active_change.id}/review.md` if `active_change` exists; else `.ai-agents/workspace/artifacts/_ad-hoc-review-{YYYY-MM-DD-HHMM}/review.md`.
85
+ - **Template**: `.ai-agents/skills/_templates/review-output.md` (custom override at `_templates/custom/...` takes precedence).
86
+ - **Required content** (mapped to template headings):
87
+ - `Review Scope` -- file list, depth, aspect filter, fallbacks applied (e.g., "design.md missing -> Group A skipped").
88
+ - `Summary` -- counts per severity + one-paragraph overall verdict (Approve / Approve with comments / Request changes / Block).
89
+ - `Critical Findings` -- one entry per finding.
90
+ - `Warnings`.
91
+ - `Suggestions`.
92
+ - `Skipped Checks` -- groups skipped because inputs were missing, with reason.
93
+ - `Recommended Next Skill` -- e.g., `/mvt-fix` for Critical, `/mvt-test` if Group E gaps, `/mvt-refactor` if Group B is dominant.
94
+
95
+ ### Step 7: Verdict Rule
96
+ - Critical > 0 -> verdict is `Request changes`. Suggest `/mvt-fix`.
97
+ - Critical = 0, Warnings > 5 -> verdict is `Approve with comments`.
98
+ - Critical = 0, Warnings <= 5, Suggestions only -> verdict is `Approve`.
99
+ - Code-only review (design.md missing) -> verdict cannot be higher than `Approve with comments` (call it out explicitly).
100
+
101
+ ### Step 8: (session update handled by shared section)
102
+
103
+ ## Edge Cases & Errors
104
+
105
+ | Case | Handling |
106
+ |------|----------|
107
+ | Review target is generated code (build output, lockfile, vendored dep) | Skip with a one-line note in artifact; do not flag findings |
108
+ | All Group A inputs missing | Run as code-only review; cap verdict at `Approve with comments` |
109
+ | User asked for review but there are zero changes | STOP, report "no diff to review", do not write artifact |
110
+ | Findings in the same file conflict (e.g., quality says "extract", architecture says "do not introduce a new module") | Defer to architecture; record the tension in `Suggestions` |
111
+ | Implementation explicitly documents a deviation from design (in `Deviations from Design`) | Treat as accepted -- flag only if the deviation is itself problematic |
112
+ | Reviewer finds bugs requiring discussion before fix | Mark Critical, but do NOT auto-invoke `/mvt-fix`; leave the call to the user |