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

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 (151) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +194 -209
  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 +16 -0
  24. package/dist/commands/migrate.d.ts.map +1 -0
  25. package/dist/commands/migrate.js +118 -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 +198 -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 +96 -88
  65. package/sources/skills/mvt-bug-detect/business.md +101 -0
  66. package/sources/skills/mvt-bug-detect/manifest.yaml +84 -0
  67. package/sources/skills/mvt-check-context/business.md +89 -42
  68. package/sources/skills/mvt-check-context/manifest.yaml +63 -74
  69. package/sources/skills/mvt-cleanup/business.md +80 -31
  70. package/sources/skills/mvt-cleanup/manifest.yaml +85 -93
  71. package/sources/skills/mvt-config/business.md +94 -26
  72. package/sources/skills/mvt-config/manifest.yaml +96 -108
  73. package/sources/skills/mvt-create-skill/business.md +231 -111
  74. package/sources/skills/mvt-create-skill/manifest.yaml +91 -79
  75. package/sources/skills/mvt-design/business.md +116 -34
  76. package/sources/skills/mvt-design/manifest.yaml +96 -105
  77. package/sources/skills/mvt-fix/business.md +132 -28
  78. package/sources/skills/mvt-fix/manifest.yaml +85 -86
  79. package/sources/skills/mvt-help/business.md +74 -70
  80. package/sources/skills/mvt-help/manifest.yaml +67 -61
  81. package/sources/skills/mvt-implement/business.md +91 -32
  82. package/sources/skills/mvt-implement/manifest.yaml +80 -96
  83. package/sources/skills/mvt-init/business.md +164 -49
  84. package/sources/skills/mvt-init/manifest.yaml +101 -93
  85. package/sources/skills/mvt-manage-context/business.md +175 -0
  86. package/sources/skills/mvt-manage-context/manifest.yaml +123 -0
  87. package/sources/skills/mvt-plan-dev/business.md +75 -0
  88. package/sources/skills/mvt-plan-dev/manifest.yaml +91 -0
  89. package/sources/skills/mvt-quick-dev/business.md +99 -0
  90. package/sources/skills/mvt-quick-dev/manifest.yaml +69 -0
  91. package/sources/skills/mvt-refactor/business.md +104 -33
  92. package/sources/skills/mvt-refactor/manifest.yaml +86 -101
  93. package/sources/skills/mvt-resume/business.md +137 -0
  94. package/sources/skills/mvt-resume/manifest.yaml +71 -0
  95. package/sources/skills/mvt-review/business.md +112 -49
  96. package/sources/skills/mvt-review/manifest.yaml +87 -106
  97. package/sources/skills/mvt-status/business.md +71 -24
  98. package/sources/skills/mvt-status/manifest.yaml +66 -74
  99. package/sources/skills/mvt-sync-context/business.md +150 -25
  100. package/sources/skills/mvt-sync-context/manifest.yaml +96 -84
  101. package/sources/skills/mvt-template/business.md +96 -49
  102. package/sources/skills/mvt-template/manifest.yaml +63 -71
  103. package/sources/skills/mvt-test/business.md +104 -36
  104. package/sources/skills/mvt-test/manifest.yaml +102 -111
  105. package/sources/skills/mvt-update-plan/business.md +72 -0
  106. package/sources/skills/mvt-update-plan/manifest.yaml +132 -0
  107. package/sources/templates/analyze-output/body.md +15 -38
  108. package/sources/templates/analyze-output/manifest.yaml +11 -11
  109. package/sources/templates/design-output/body.md +17 -50
  110. package/sources/templates/design-output/manifest.yaml +11 -11
  111. package/sources/templates/implement-output/body.md +11 -32
  112. package/sources/templates/implement-output/manifest.yaml +11 -11
  113. package/sources/templates/project-context/body.md +13 -0
  114. package/sources/templates/project-context/manifest.yaml +12 -0
  115. package/sources/templates/review-output/body.md +11 -45
  116. package/sources/templates/review-output/manifest.yaml +11 -11
  117. package/sources/templates/test-output/body.md +7 -31
  118. package/sources/templates/test-output/manifest.yaml +11 -11
  119. package/dist/fs/protection.d.ts +0 -15
  120. package/dist/fs/protection.d.ts.map +0 -1
  121. package/dist/fs/protection.js +0 -16
  122. package/dist/fs/protection.js.map +0 -1
  123. package/sources/knowledge/core/review-principles.md +0 -51
  124. package/sources/knowledge/patterns/clean-architecture/manifest.yaml +0 -66
  125. package/sources/knowledge/patterns/clean-architecture/review-checklist.md +0 -230
  126. package/sources/knowledge/patterns/ddd/manifest.yaml +0 -83
  127. package/sources/knowledge/patterns/ddd/review-checklist.md +0 -226
  128. package/sources/knowledge/patterns/ddd/tactical-patterns.md +0 -12
  129. package/sources/knowledge/patterns/frontend-react/manifest.yaml +0 -44
  130. package/sources/knowledge/patterns/frontend-react/review-checklist.md +0 -78
  131. package/sources/knowledge/patterns/manifest.yaml +0 -113
  132. package/sources/skills/mvt-add-context/business.md +0 -47
  133. package/sources/skills/mvt-add-context/manifest.yaml +0 -83
  134. package/sources/templates/analyze-code-output/body.md +0 -44
  135. package/sources/templates/analyze-code-output/manifest.yaml +0 -11
  136. package/sources/templates/cleanup-output/body.md +0 -9
  137. package/sources/templates/cleanup-output/manifest.yaml +0 -11
  138. package/sources/templates/config-output/body.md +0 -11
  139. package/sources/templates/config-output/manifest.yaml +0 -11
  140. package/sources/templates/context-check-output/body.md +0 -32
  141. package/sources/templates/context-check-output/manifest.yaml +0 -11
  142. package/sources/templates/fix-output/body.md +0 -30
  143. package/sources/templates/fix-output/manifest.yaml +0 -11
  144. package/sources/templates/init-output/body.md +0 -34
  145. package/sources/templates/init-output/manifest.yaml +0 -11
  146. package/sources/templates/refactor-output/body.md +0 -32
  147. package/sources/templates/refactor-output/manifest.yaml +0 -11
  148. package/sources/templates/status-output/body.md +0 -36
  149. package/sources/templates/status-output/manifest.yaml +0 -11
  150. package/sources/templates/sync-context-output/body.md +0 -16
  151. package/sources/templates/sync-context-output/manifest.yaml +0 -11
@@ -0,0 +1,99 @@
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Load Inputs
4
+ - **Required**:
5
+ - User's change description (free text or file path).
6
+ - **Fallback**: if no project context exists (no `project-context.md`), proceed as "context-light" (skip layer compliance checks).
7
+
8
+ ### Step 2: Classify Complexity
9
+ - **What**: determine the change tier based on scope signals in the user's description.
10
+ - **How**: apply the classification table below. Walk signals top-to-bottom; the first match wins.
11
+
12
+ | Tier | Criteria | Behavior |
13
+ |------|----------|----------|
14
+ | **Trivial** | 1 file, no new concepts, no interface change, ≤10 lines affected | Implement directly, conversation-only |
15
+ | **Simple** | 1-3 files, no new module, no interface break, existing patterns sufficient | Implement after showing plan, conversation-only |
16
+ | **Complex** | >3 files, new module, interface break, new dependency, or ambiguous scope | STOP -- recommend `/mvt-analyze` or `/mvt-design` |
17
+
18
+ Scope signals (heuristic):
19
+
20
+ | Signal | Suggests |
21
+ |--------|----------|
22
+ | Mentions specific file/symbol | Trivial/Simple |
23
+ | "add a field/property/column" | Simple |
24
+ | "change label/text/color" | Trivial |
25
+ | "new API/endpoint/module" | Complex |
26
+ | "refactor/redesign/migrate" | Complex |
27
+ | "integration with X" | Complex |
28
+ | Affects >1 module (per `project-context.md`) | Complex |
29
+ | Introduces new dependency | Complex |
30
+
31
+ - **Branches**:
32
+
33
+ | Condition | Action |
34
+ |-----------|--------|
35
+ | Classified as Trivial or Simple | Proceed to Step 3 |
36
+ | Classified as Complex | STOP; recommend `/mvt-analyze` or `/mvt-design` |
37
+ | Ambiguous (could be Simple or Complex) | Ask user to confirm scope before proceeding |
38
+
39
+ ### Step 3: Locate Target
40
+ - **What**: resolve the exact file(s) and symbol(s) to change.
41
+ - **How**:
42
+ 1. Parse the change description for file paths, class/function/variable names, or module references.
43
+ 2. Resolve each reference using Glob/Grep against the project tree.
44
+ 3. Verify each target: exists on disk (for modifications) or parent path exists (for new files).
45
+ 4. If a target cannot be uniquely resolved, ask the user for clarification before continuing.
46
+ 5. Cross-reference `project-context.md` layer rules (if available) -- flag any change that would violate layer constraints.
47
+ - **Output of this step**: a target list (`path | action | one-line intent`).
48
+
49
+ ### Step 4: Plan the Change
50
+ - **What**: produce an ordered file list before writing any code.
51
+ - **How**:
52
+ 1. For each target from Step 3, decide: `create | modify | delete`, and write a one-line intent.
53
+ 2. Topologically order by dependency if multiple files are involved.
54
+ - **Branches**:
55
+
56
+ | Condition | Action |
57
+ |-----------|--------|
58
+ | Trivial tier | Proceed silently (change is small and reversible) |
59
+ | Simple tier | Show the plan to the user as a preview; wait for confirmation before proceeding |
60
+ | Plan exceeds 3 files | Escalate to Complex -- STOP, recommend standard workflow |
61
+ | Plan introduces an unplanned module | Escalate to Complex -- STOP, recommend standard workflow |
62
+
63
+ ### Step 5: Implement
64
+ - **What**: write/modify the planned files.
65
+ - **How**:
66
+ 1. Apply changes one file at a time, in the order determined by Step 4.
67
+ 2. Follow `coding-standards.md` if available; match surrounding code style otherwise.
68
+ 3. Respect module/layer rules from `project-context.md`. Forbidden imports must NOT appear.
69
+ 4. Add error handling at system boundaries only (HTTP, DB, external API, file IO, message bus). Do NOT add try/catch around internal calls.
70
+ 5. Inline comments only for non-obvious algorithmic choices or deliberate workarounds with a reason.
71
+ 6. Do NOT introduce abstractions, helpers, or feature flags beyond what the task requires.
72
+
73
+ ### Step 6: Quick Verify
74
+ - **What**: light-weight verification before reporting completion.
75
+ - **How**:
76
+ 1. If a type-checker is configured for the project (`tsc`, `mypy`, `cargo check`, etc.), run it on changed files only. Surface failures.
77
+ 2. If existing tests cover the changed code, suggest the test command but do not auto-run unless user explicitly approved.
78
+ 3. For frontend/UI changes, note that user should verify in browser; do NOT claim "tested" based on type-check alone.
79
+
80
+ ### Step 7: Summarize in Conversation
81
+ - **What**: present the result without writing any artifact file.
82
+ - **How**: output a brief summary containing:
83
+ - Files touched: `path | action`
84
+ - Verification status: type-check result, test suggestion
85
+ - **No artifact is written. No document is generated.** This is a conversation-only skill.
86
+
87
+ ### Step 8: (session update handled by shared section)
88
+
89
+ ## Edge Cases & Errors
90
+
91
+ | Case | Handling |
92
+ |------|----------|
93
+ | Change description is vague ("improve performance") | STOP -- ask for specifics; cannot classify without concrete scope |
94
+ | Target file doesn't exist | Ask whether it is a new file or a wrong path; do not silently create |
95
+ | Implementation reveals the change is actually Complex | STOP -- revert partial changes, recommend `/mvt-analyze` |
96
+ | Active change is in the middle of `/mvt-implement` | Warn about potential conflicts; ask user to confirm before proceeding |
97
+ | No `active_change` and change is Simple | Proceed without creating an `active_change`; conversation-only result |
98
+ | Change touches a file also being modified in an active plan | Surface the conflict; user must resolve outside this skill |
99
+ | User wants to save progress notes | Direct them to the standard workflow (`/mvt-analyze` -> `/mvt-design` -> `/mvt-implement`) which produces artifacts |
@@ -0,0 +1,69 @@
1
+ name: mvt-quick-dev
2
+ output: .claude/skills/mvt-quick-dev/SKILL.md
3
+
4
+ frontmatter:
5
+ name: mvt-quick-dev
6
+ description: "Quickly implement simple, well-scoped changes without the full analyze-design-implement workflow. This skill should be used when the change is small (1-3 files), architecturally neutral, and clearly specified — such as adding a field, fixing a label, adjusting config, or making a targeted enhancement."
7
+
8
+ sections:
9
+ - type: inline
10
+ content: |
11
+ # MVT Quick Dev
12
+
13
+ ## Purpose
14
+
15
+ Implement simple, well-scoped changes quickly, bypassing the full workflow. For changes that are small (1-3 files), architecturally neutral, and clearly specified. Produces no artifacts — results are conversation-only.
16
+
17
+ - type: shared
18
+ source: sections/role-header.md
19
+ params:
20
+ role: Developer
21
+ role_desc: "an Implementation Specialist"
22
+ decision_rules:
23
+ - rule: "Change is Trivial (1 file, ≤10 lines) -> Implement directly, conversation-only"
24
+ - rule: "Change is Simple (1-3 files, no module break) -> Implement, show plan first, conversation-only"
25
+ - rule: "Change is Complex -> STOP, recommend /mvt-analyze or /mvt-design"
26
+ - rule: "Ambiguous scope -> Ask user to confirm before proceeding"
27
+ - rule: "Implementation reveals unexpected complexity -> Revert and escalate"
28
+ - rule: "Existing tests cover changed code -> Suggest running them"
29
+ boundaries:
30
+ - scope: "analyze complex requirements"
31
+ skill: "/mvt-analyze"
32
+ - scope: "design architecture"
33
+ skill: "/mvt-design"
34
+ - scope: "review code"
35
+ skill: "/mvt-review"
36
+
37
+ - type: shared
38
+ source: sections/activation-load-context.md
39
+ params:
40
+ extended_context:
41
+ - ".ai-agents/knowledge/project/_generated/project-context.md -- Module/layer map (optional)"
42
+ - ".ai-agents/knowledge/principle/coding-standards.md -- Coding standards (optional)"
43
+ - "Target source files (load based on change description)"
44
+
45
+ - type: shared
46
+ source: sections/activation-load-config.md
47
+
48
+ - type: shared
49
+ source: sections/output-language-constraint.md
50
+
51
+ - type: inline
52
+ content: |
53
+ ### Shortcut Operation Rules
54
+ - Can execute at any time without checking workflow prerequisites
55
+ - Do NOT update `progress` (this is a shortcut operation, not a workflow phase)
56
+ - Do NOT create an `active_change` if one doesn't already exist
57
+ - Do NOT write any artifact or document — results are conversation-only
58
+ - Do NOT interact with plan.yaml in any way — this skill is plan-independent
59
+
60
+ - type: file
61
+ source: ./business.md
62
+
63
+ - type: shared
64
+ source: sections/session-update.md
65
+
66
+ - type: shared
67
+ source: sections/footer-next-steps.md
68
+ params:
69
+ current_skill: mvt-quick-dev
@@ -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 |
@@ -1,101 +1,86 @@
1
- name: mvt-refactor
2
- output: .claude/skills/mvt-refactor/SKILL.md
3
-
4
- frontmatter:
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."
7
-
8
- sections:
9
- - type: inline
10
- content: |
11
- # MVT Refactor
12
-
13
- ## Purpose
14
-
15
- Refactor existing code while preserving observable behavior. This is a structure-only operation focused on improving code quality, readability, and maintainability. This is a shortcut operation that can run at any time.
16
-
17
- - type: shared
18
- source: sections/role-header.md
19
- params:
20
- role: Developer
21
- role_desc: "an Implementation Specialist"
22
- decision_rules:
23
- - rule: "Refactoring target specified -> Analyze and plan the refactoring"
24
- - rule: "No target specified -> Ask user what to refactor"
25
- - rule: "Risk level is High -> Warn user and require explicit confirmation"
26
- - rule: "Tests exist for target code -> Recommend running them after refactoring"
27
- - rule: "No tests exist -> Describe how to verify behavior is unchanged"
28
- - rule: "Change requires new module not in design -> Flag for Architect"
29
- boundaries:
30
- - scope: "re-analyze requirements"
31
- skill: "/mvt-analyze"
32
- - scope: "evaluate architecture"
33
- skill: "/mvt-design"
34
- - scope: "review own code"
35
- skill: "/mvt-review"
36
-
37
- - type: inline
38
- content: |
39
- ### Constraints
40
- - Do NOT change observable behavior -- refactoring is structure-only
41
- - Do NOT introduce new features during refactoring
42
- - Do NOT modify unrelated code outside the refactoring scope
43
-
44
- ## Refactoring Types
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 |
54
-
55
- - type: shared
56
- source: sections/activation-load-context.md
57
- params:
58
- 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
- - "Related source files to be refactored"
62
-
63
- - type: shared
64
- source: sections/activation-load-config.md
65
-
66
- - type: inline
67
- content: |
68
- ### Step 3: Pre-flight Checks
69
- - No blocking checks required (shortcut operation).
70
-
71
- ### Shortcut Operation Rules
72
- - 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
-
79
- - type: file
80
- source: ./business.md
81
-
82
- - type: inline
83
- content: |
84
- ## Output Format
85
-
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.
93
-
94
- - type: shared
95
- source: sections/footer-next-steps.md
96
- 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"
1
+ name: mvt-refactor
2
+ output: .claude/skills/mvt-refactor/SKILL.md
3
+
4
+ frontmatter:
5
+ name: mvt-refactor
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
+
8
+ sections:
9
+ - type: inline
10
+ content: |
11
+ # MVT Refactor
12
+
13
+ ## Purpose
14
+
15
+ Refactor existing code while preserving observable behavior. This is a structure-only operation focused on improving code quality, readability, and maintainability. This is a shortcut operation that can run at any time.
16
+
17
+ - type: shared
18
+ source: sections/role-header.md
19
+ params:
20
+ role: Developer
21
+ role_desc: "an Implementation Specialist"
22
+ decision_rules:
23
+ - rule: "Refactoring target specified -> Analyze and plan the refactoring"
24
+ - rule: "No target specified -> Prompt user for refactoring target"
25
+ - rule: "Risk level is High -> Warn user and require explicit confirmation"
26
+ - rule: "Tests exist for target code -> Recommend running them after refactoring"
27
+ - rule: "No tests exist -> Describe how to verify behavior is unchanged"
28
+ - rule: "Change requires new module not in design -> Flag for Architect"
29
+ boundaries:
30
+ - scope: "re-analyze requirements"
31
+ skill: "/mvt-analyze"
32
+ - scope: "evaluate architecture"
33
+ skill: "/mvt-design"
34
+ - scope: "review own code"
35
+ skill: "/mvt-review"
36
+
37
+ - type: inline
38
+ content: |
39
+ ### Constraints
40
+ - Do NOT change observable behavior -- refactoring is structure-only
41
+ - Do NOT introduce new features during refactoring
42
+ - Do NOT modify unrelated code outside the refactoring scope
43
+
44
+ ## Refactoring Types
45
+
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 |
55
+
56
+ - type: shared
57
+ source: sections/activation-load-context.md
58
+ params:
59
+ extended_context:
60
+ - "Related source files to be refactored"
61
+
62
+ - type: shared
63
+ source: sections/activation-load-config.md
64
+
65
+ - type: shared
66
+ source: sections/output-language-constraint.md
67
+
68
+ - type: inline
69
+ content: |
70
+ ### Step 3: Pre-flight Checks
71
+ - No blocking checks required (shortcut operation).
72
+
73
+ ### Shortcut Operation Rules
74
+ - Can execute at any time without checking workflow prerequisites
75
+
76
+ - type: file
77
+ source: ./business.md
78
+
79
+
80
+ - type: shared
81
+ source: sections/session-update.md
82
+
83
+ - type: shared
84
+ source: sections/footer-next-steps.md
85
+ params:
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."