@uoyo/mvtt 2.0.0-beta.1 → 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 (46) hide show
  1. package/README.md +194 -193
  2. package/dist/commands/migrate.d.ts +0 -2
  3. package/dist/commands/migrate.d.ts.map +1 -1
  4. package/dist/commands/migrate.js +0 -45
  5. package/dist/commands/migrate.js.map +1 -1
  6. package/package.json +1 -1
  7. package/registry.yaml +6 -0
  8. package/sources/sections/output-language-constraint.md +11 -11
  9. package/sources/sections/session-update.md +47 -47
  10. package/sources/skills/mvt-analyze/business.md +7 -7
  11. package/sources/skills/mvt-analyze-code/manifest.yaml +96 -96
  12. package/sources/skills/mvt-bug-detect/business.md +101 -0
  13. package/sources/skills/mvt-bug-detect/manifest.yaml +84 -0
  14. package/sources/skills/mvt-check-context/manifest.yaml +63 -63
  15. package/sources/skills/mvt-config/manifest.yaml +96 -96
  16. package/sources/skills/mvt-create-skill/business.md +81 -74
  17. package/sources/skills/mvt-create-skill/manifest.yaml +91 -95
  18. package/sources/skills/mvt-design/manifest.yaml +96 -96
  19. package/sources/skills/mvt-fix/business.md +37 -8
  20. package/sources/skills/mvt-fix/manifest.yaml +85 -72
  21. package/sources/skills/mvt-help/manifest.yaml +67 -67
  22. package/sources/skills/mvt-implement/manifest.yaml +80 -80
  23. package/sources/skills/mvt-init/manifest.yaml +101 -101
  24. package/sources/skills/mvt-manage-context/business.md +175 -175
  25. package/sources/skills/mvt-manage-context/manifest.yaml +123 -123
  26. package/sources/skills/mvt-plan-dev/manifest.yaml +91 -91
  27. package/sources/skills/mvt-quick-dev/manifest.yaml +69 -69
  28. package/sources/skills/mvt-refactor/manifest.yaml +86 -86
  29. package/sources/skills/mvt-resume/manifest.yaml +71 -71
  30. package/sources/skills/mvt-review/manifest.yaml +87 -87
  31. package/sources/skills/mvt-status/manifest.yaml +66 -66
  32. package/sources/skills/mvt-sync-context/business.md +150 -150
  33. package/sources/skills/mvt-sync-context/manifest.yaml +96 -96
  34. package/sources/skills/mvt-template/manifest.yaml +63 -63
  35. package/sources/skills/mvt-test/manifest.yaml +102 -102
  36. package/sources/skills/mvt-update-plan/business.md +72 -72
  37. package/sources/skills/mvt-update-plan/manifest.yaml +132 -132
  38. package/sources/templates/analyze-output/body.md +15 -15
  39. package/sources/templates/design-output/body.md +17 -17
  40. package/sources/templates/implement-output/body.md +11 -11
  41. package/sources/templates/review-output/body.md +11 -11
  42. package/sources/templates/test-output/body.md +7 -7
  43. package/dist/fs/protection.d.ts +0 -15
  44. package/dist/fs/protection.d.ts.map +0 -1
  45. package/dist/fs/protection.js +0 -16
  46. package/dist/fs/protection.js.map +0 -1
@@ -1,87 +1,87 @@
1
- name: mvt-review
2
- output: .claude/skills/mvt-review/SKILL.md
3
-
4
- frontmatter:
5
- name: mvt-review
6
- description: "Perform code review for quality, standards compliance, and best practices. This skill should be used when user wants code reviewed, quality checked, or to identify issues before merging."
7
-
8
- sections:
9
- - type: inline
10
- content: |
11
- # MVT Review
12
-
13
- ## Purpose
14
-
15
- Review code for quality, standards compliance, and best practices. Identify issues by severity, suggest improvements, and ensure architecture compliance.
16
-
17
- - type: shared
18
- source: sections/role-header.md
19
- params:
20
- role: Reviewer
21
- role_desc: "a Code Quality Guardian"
22
- decision_rules:
23
- - rule: "Critical issue found (security, data loss, crash) -> Mark as CRITICAL, require fix before merge"
24
- - rule: "Layer violation found -> Flag for Architect, suggest `/mvt-design`"
25
- - rule: "Minor style issue -> Note as suggestion, don't block"
26
- - rule: "Subjective preference -> Mark as \"non-blocking\" optional improvement"
27
- - rule: "Good code pattern found -> Highlight positively"
28
- - rule: "Bug found -> Document with reproduction steps, suggest `/mvt-fix`"
29
- - rule: "Insufficient test coverage -> Recommend specific scenarios, suggest `/mvt-test`"
30
- boundaries:
31
- - scope: "fix code directly"
32
- skill: "/mvt-fix"
33
- - scope: "make architecture decisions"
34
- skill: "/mvt-design"
35
- - scope: "modify source code"
36
- skill: "(This is a read-only review)"
37
-
38
- - type: inline
39
- content: |
40
- ## Aspect Options
41
-
42
- | Aspect | Focus Areas |
43
- |--------|-------------|
44
- | `architecture` | Layer compliance, module boundaries, dependency direction |
45
- | `security` | Input validation, injection prevention, authentication |
46
- | `performance` | N+1 queries, memory leaks, caching |
47
- | `style` | Naming conventions, formatting, documentation |
48
-
49
- Usage: `/mvt-review` or `/mvt-review --aspect {type}`
50
-
51
- - type: shared
52
- source: sections/activation-load-config.md
53
-
54
- - type: shared
55
- source: sections/output-language-constraint.md
56
-
57
- - type: shared
58
- source: sections/activation-preflight.md
59
- params:
60
- checks:
61
- - order: "1"
62
- field: "session.initialized_at"
63
- level: "WARN"
64
- message: "Session not initialized. Run `/mvt-init` first."
65
- - order: "2"
66
- field: "no code to review"
67
- level: "WARN"
68
- message: "No code to review. Run `/mvt-implement` first or specify files."
69
-
70
- - type: file
71
- source: ./business.md
72
-
73
- - type: inline
74
- content: |
75
- ## Artifact Structure
76
- Read the document structure template from: `.ai-agents/skills/_templates/review-output.md`
77
- If a custom version exists at `.ai-agents/skills/_templates/custom/review-output.md`, use the custom version instead.
78
- The template defines section headings only. Generate content for each section based on review results.
79
- Write the artifact to: `.ai-agents/workspace/artifacts/{change-id}/review.md`
80
-
81
- - type: shared
82
- source: sections/session-update.md
83
-
84
- - type: shared
85
- source: sections/footer-next-steps.md
86
- params:
87
- current_skill: mvt-review
1
+ name: mvt-review
2
+ output: .claude/skills/mvt-review/SKILL.md
3
+
4
+ frontmatter:
5
+ name: mvt-review
6
+ description: "Perform code review for quality, standards compliance, and best practices. This skill should be used when user wants code reviewed, quality checked, or to identify issues before merging."
7
+
8
+ sections:
9
+ - type: inline
10
+ content: |
11
+ # MVT Review
12
+
13
+ ## Purpose
14
+
15
+ Review code for quality, standards compliance, and best practices. Identify issues by severity, suggest improvements, and ensure architecture compliance.
16
+
17
+ - type: shared
18
+ source: sections/role-header.md
19
+ params:
20
+ role: Reviewer
21
+ role_desc: "a Code Quality Guardian"
22
+ decision_rules:
23
+ - rule: "Critical issue found (security, data loss, crash) -> Mark as CRITICAL, require fix before merge"
24
+ - rule: "Layer violation found -> Flag for Architect, suggest `/mvt-design`"
25
+ - rule: "Minor style issue -> Note as suggestion, don't block"
26
+ - rule: "Subjective preference -> Mark as \"non-blocking\" optional improvement"
27
+ - rule: "Good code pattern found -> Highlight positively"
28
+ - rule: "Bug found -> Document with reproduction steps, suggest `/mvt-fix`"
29
+ - rule: "Insufficient test coverage -> Recommend specific scenarios, suggest `/mvt-test`"
30
+ boundaries:
31
+ - scope: "fix code directly"
32
+ skill: "/mvt-fix"
33
+ - scope: "make architecture decisions"
34
+ skill: "/mvt-design"
35
+ - scope: "modify source code"
36
+ skill: "(This is a read-only review)"
37
+
38
+ - type: inline
39
+ content: |
40
+ ## Aspect Options
41
+
42
+ | Aspect | Focus Areas |
43
+ |--------|-------------|
44
+ | `architecture` | Layer compliance, module boundaries, dependency direction |
45
+ | `security` | Input validation, injection prevention, authentication |
46
+ | `performance` | N+1 queries, memory leaks, caching |
47
+ | `style` | Naming conventions, formatting, documentation |
48
+
49
+ Usage: `/mvt-review` or `/mvt-review --aspect {type}`
50
+
51
+ - type: shared
52
+ source: sections/activation-load-config.md
53
+
54
+ - type: shared
55
+ source: sections/output-language-constraint.md
56
+
57
+ - type: shared
58
+ source: sections/activation-preflight.md
59
+ params:
60
+ checks:
61
+ - order: "1"
62
+ field: "session.initialized_at"
63
+ level: "WARN"
64
+ message: "Session not initialized. Run `/mvt-init` first."
65
+ - order: "2"
66
+ field: "no code to review"
67
+ level: "WARN"
68
+ message: "No code to review. Run `/mvt-implement` first or specify files."
69
+
70
+ - type: file
71
+ source: ./business.md
72
+
73
+ - type: inline
74
+ content: |
75
+ ## Artifact Structure
76
+ Read the document structure template from: `.ai-agents/skills/_templates/review-output.md`
77
+ If a custom version exists at `.ai-agents/skills/_templates/custom/review-output.md`, use the custom version instead.
78
+ The template defines section headings only. Generate content for each section based on review results.
79
+ Write the artifact to: `.ai-agents/workspace/artifacts/{change-id}/review.md`
80
+
81
+ - type: shared
82
+ source: sections/session-update.md
83
+
84
+ - type: shared
85
+ source: sections/footer-next-steps.md
86
+ params:
87
+ current_skill: mvt-review
@@ -1,66 +1,66 @@
1
- name: mvt-status
2
- output: .claude/skills/mvt-status/SKILL.md
3
-
4
- frontmatter:
5
- name: mvt-status
6
- description: "Display current project and workflow status including skill history, active changes, and session state. This skill should be used when user wants to check project status, review workflow progress, or see where they are in the development cycle."
7
-
8
- sections:
9
- - type: inline
10
- content: |
11
- # MVT Status
12
-
13
- ## Purpose
14
-
15
- Display comprehensive project and workflow status, showing project list, semantic context availability, skill history, active changes, and current session state.
16
-
17
- - type: shared
18
- source: sections/role-header.md
19
- params:
20
- role: Conductor
21
- role_desc: "a Workflow Coordinator"
22
- decision_rules:
23
- - rule: "If project not initialized -> Warn and suggest `/mvt-init`"
24
- - rule: "If no active change -> Show project info only, suggest starting a workflow"
25
- - rule: "If workflow in progress -> Highlight recent skill history and next recommended step"
26
- - rule: "If project-context.md missing -> Suggest `/mvt-analyze-code` to generate semantic context"
27
- - rule: "If one or more plans exist -> Show Changes Overview table with progress for all plans"
28
- - rule: "If an in_progress plan has a current_task -> Suggest the matching skill_hint as next step"
29
- boundaries:
30
- - scope: "analyze requirements"
31
- skill: "/mvt-analyze"
32
- - scope: "design architecture"
33
- skill: "/mvt-design"
34
- - scope: "write implementation code"
35
- skill: "/mvt-implement"
36
-
37
- - type: shared
38
- source: sections/activation-load-context.md
39
-
40
- - type: shared
41
- source: sections/activation-load-config.md
42
-
43
- - type: shared
44
- source: sections/output-language-constraint.md
45
-
46
- - type: shared
47
- source: sections/activation-preflight.md
48
- params:
49
- checks:
50
- - order: "1"
51
- field: "session.initialized_at"
52
- level: "WARN"
53
- message: "Session not initialized. Run `/mvt-init` first."
54
-
55
- - type: file
56
- source: ./business.md
57
-
58
- - type: shared
59
- source: sections/session-update.md
60
- params:
61
- read_only: true
62
-
63
- - type: shared
64
- source: sections/footer-next-steps.md
65
- params:
66
- current_skill: mvt-status
1
+ name: mvt-status
2
+ output: .claude/skills/mvt-status/SKILL.md
3
+
4
+ frontmatter:
5
+ name: mvt-status
6
+ description: "Display current project and workflow status including skill history, active changes, and session state. This skill should be used when user wants to check project status, review workflow progress, or see where they are in the development cycle."
7
+
8
+ sections:
9
+ - type: inline
10
+ content: |
11
+ # MVT Status
12
+
13
+ ## Purpose
14
+
15
+ Display comprehensive project and workflow status, showing project list, semantic context availability, skill history, active changes, and current session state.
16
+
17
+ - type: shared
18
+ source: sections/role-header.md
19
+ params:
20
+ role: Conductor
21
+ role_desc: "a Workflow Coordinator"
22
+ decision_rules:
23
+ - rule: "If project not initialized -> Warn and suggest `/mvt-init`"
24
+ - rule: "If no active change -> Show project info only, suggest starting a workflow"
25
+ - rule: "If workflow in progress -> Highlight recent skill history and next recommended step"
26
+ - rule: "If project-context.md missing -> Suggest `/mvt-analyze-code` to generate semantic context"
27
+ - rule: "If one or more plans exist -> Show Changes Overview table with progress for all plans"
28
+ - rule: "If an in_progress plan has a current_task -> Suggest the matching skill_hint as next step"
29
+ boundaries:
30
+ - scope: "analyze requirements"
31
+ skill: "/mvt-analyze"
32
+ - scope: "design architecture"
33
+ skill: "/mvt-design"
34
+ - scope: "write implementation code"
35
+ skill: "/mvt-implement"
36
+
37
+ - type: shared
38
+ source: sections/activation-load-context.md
39
+
40
+ - type: shared
41
+ source: sections/activation-load-config.md
42
+
43
+ - type: shared
44
+ source: sections/output-language-constraint.md
45
+
46
+ - type: shared
47
+ source: sections/activation-preflight.md
48
+ params:
49
+ checks:
50
+ - order: "1"
51
+ field: "session.initialized_at"
52
+ level: "WARN"
53
+ message: "Session not initialized. Run `/mvt-init` first."
54
+
55
+ - type: file
56
+ source: ./business.md
57
+
58
+ - type: shared
59
+ source: sections/session-update.md
60
+ params:
61
+ read_only: true
62
+
63
+ - type: shared
64
+ source: sections/footer-next-steps.md
65
+ params:
66
+ current_skill: mvt-status
@@ -1,150 +1,150 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Identify Completed Changes
4
- - **What**: produce a candidate list of change-ids whose artifacts will be aggregated.
5
- - **How**:
6
- 1. Read `session.yaml`. Collect `recent_changes[]` entries with `status: completed`.
7
- 2. For each candidate, verify `.ai-agents/workspace/artifacts/{change-id}/` exists AND contains at least one of `analysis.md` or `design.md`. Drop entries with only `plan.yaml`.
8
- 3. (Fallback) If `recent_changes[]` is empty, scan `.ai-agents/workspace/artifacts/*/` directly; offer those with `analysis.md` or `design.md`, marked `unindexed`.
9
- 4. Exclude any change-id whose directory contains an `_archive/` subfolder (already archived).
10
- 5. Exclude `active_change.id` (work in flight).
11
-
12
- - **Present** the list:
13
-
14
- | # | change-id | title | status | analysis.md | design.md | implementation.md |
15
- |---|-----------|-------|--------|-------------|-----------|-------------------|
16
-
17
- - **Always print before user confirmation**:
18
- > Run `/mvt-sync-context` BEFORE `/mvt-cleanup`. Once cleanup archives a change-id, this skill will skip it.
19
-
20
- - **Prompt**: "Select changes to aggregate. Indices (e.g. 1,3,5), `a` for all, `n` to cancel."
21
-
22
- - Cancel / empty selection -> stop with "no changes applied".
23
-
24
- ### Step 2: Read Current Project Context (Adaptive Structure Discovery)
25
-
26
- This step establishes the **target structure** that aggregated content must fit into. The structure is NOT assumed -- it is derived from the current document.
27
-
28
- 1. Read `.ai-agents/knowledge/project/_generated/project-context.md`.
29
- - Already required by preflight; if discovered missing here, STOP and recommend `/mvt-analyze-code`.
30
- 2. Parse the current `.md` into a section map:
31
- - Each top-level `##` heading -> one section anchor.
32
- - Record: section title (verbatim), byte range, and a 1-line semantic summary derived from the section's content (e.g., "lists domain terms with definitions" or "describes module dependencies").
33
- - The summary is what enables matching in Step 3 -- section titles may be in any language and may not match conventional names (Terms / Modules / etc.).
34
- 3. If the document has zero `##` sections (single block) -> STOP. Recommend `/mvt-analyze-code` to establish a sectioned baseline first.
35
- 4. Read `.ai-agents/workspace/project-context.yaml`. Record current `projects[].source_paths`, `modules`, and `tech_stack` for diff comparison in Step 4d.
36
-
37
- ### Step 3: Extract and Classify Artifact Content
38
-
39
- - **What**: from each selected change-id, extract atomic knowledge items and classify them against the section map from Step 2.
40
- - **How**:
41
- 1. For each selected change-id, read available artifacts (`analysis.md`, `design.md`, `implementation.md`).
42
- 2. Extract atomic items. Typical sources:
43
- - `analysis.md` -> domain terms, actors, business rules, constraints
44
- - `design.md` -> modules, layers, dependency rules, key interfaces, ADRs
45
- - `implementation.md` -> files added/changed (informs `.yaml` source_paths), realized vs deviated design points
46
- 3. For each item, match to a section from the Step 2 map:
47
- - Match by semantic similarity to **section title + 1-line summary**, not by exact string.
48
- - Confidence levels:
49
- - **mapped**: exactly one section matches with high confidence
50
- - **ambiguous**: 2+ sections plausibly match
51
- - **orphan**: no section matches; propose a new section name
52
- 4. For each item, also detect change type relative to current section content:
53
- - `new` -- target section does not contain this entity
54
- - `modify` -- target section mentions the entity but artifact provides a different value
55
- - `redundant` -- already present, no change (will be filtered out, not shown to user)
56
-
57
- ### Step 4: Render the Update Plan (Four Tables)
58
-
59
- #### 4a. Section-mapped items
60
- | # | change-id | item | type | target section | classification |
61
- |---|-----------|------|------|----------------|----------------|
62
-
63
- #### 4b. Conflicts requiring resolution (every `modify` item)
64
- | # | item | section | current value | proposed value (from {change-id}) |
65
- |---|------|---------|---------------|-----------------------------------|
66
-
67
- #### 4c. Ambiguous and orphan items
68
- | # | item | reason | candidate sections (or proposed new section) |
69
- |---|------|--------|----------------------------------------------|
70
-
71
- #### 4d. Implied yaml changes
72
- | # | yaml field | current | proposed |
73
- |---|------------|---------|----------|
74
-
75
- ### Step 5: User Confirmation (Per-Table)
76
-
77
- - **4a**: default = accept all. User input: indices to drop, or `e <n>` to edit a single item's target section.
78
- - **4b**: **explicit per-row decision required**. Format `<index>:<keep|replace|edit>`. Example: `1:replace,2:keep,3:edit`. No default.
79
- - **4c**: per row, user picks an existing section, types a new section name, or `skip`.
80
- - **4d**: default = accept; user can drop indices.
81
-
82
- Then ask: **"Run optional read-only code verification before applying? (y/n)"**
83
-
84
- ### Step 6: (Optional) Read-only Code Verification
85
-
86
- This step catches artifacts claiming entities never actually delivered. It is **read-only** -- it never writes anything to `.md` or `.yaml`.
87
-
88
- If user opts in:
89
- 1. For each accepted item naming a code entity (module path, file, class, function), search the codebase under registered `source_paths`:
90
- - Module path -> directory exists?
91
- - File -> file exists?
92
- - Symbol -> grep within source_paths
93
- 2. Classify findings:
94
-
95
- | Finding | Action |
96
- |---------|--------|
97
- | Artifact item matches code | Mark `verified`; keep in apply list |
98
- | Artifact item NOT found in code | Flag `unverified`; ask user: drop or proceed (likely reverted / un-merged) |
99
- | Code contains module / file / symbol that NO artifact item references | **Do NOT add to apply list.** Print: `Code-only entity detected: {path}. Run /mvt-analyze-code for ground-truth rebuild.` |
100
-
101
- 3. Re-render the apply list with `verified` / `unverified` markers; final confirmation.
102
-
103
- If user skips verification: proceed directly to Step 7 with Step 5 selections.
104
-
105
- ### Step 7: Apply Updates (Merge Mode)
106
-
107
- - **Pre-write**:
108
- 1. Backup: `project-context.md` -> `project-context.md.bak`; `project-context.yaml` -> `project-context.yaml.bak`. Overwrite any prior `.bak`.
109
- 2. Backup write failure -> STOP, do not modify originals.
110
-
111
- - **Update `project-context.md`** (merge, never rewrite):
112
- 1. Each `new` item: append to target section, matching the section's existing style (bullet vs paragraph).
113
- 2. Each `modify` item with `replace`: replace the matching line in place. Smallest possible diff.
114
- 3. Each `orphan` item with new-section choice: append a new `##` section at end of file.
115
- 4. **Never delete** any existing line. **Never reorder** existing sections.
116
-
117
- - **Update `project-context.yaml`** (structured merge):
118
- 1. Apply accepted entries from Table 4d.
119
- 2. Add new `source_paths` to matching project entry; add new modules to `modules[]`.
120
- 3. **Never delete** an existing yaml entry in this skill.
121
-
122
- - **Atomicity**: temp + rename per file. If `.md` write succeeds but `.yaml` fails (or vice versa) -> restore the failed one from `.bak`, keep the other; report partial success.
123
-
124
- ### Step 8: Report
125
-
126
- 1. **Applied summary** -- counts: items added / modified / skipped / orphaned-into-new-section
127
- 2. **Files changed** -- paths + byte deltas
128
- 3. **Backup paths** -- so user can manually revert
129
- 4. **Out-of-scope reminder** (always print):
130
- > This skill processes additions and modifications only. Module deletions, renames, and large refactors are NOT detected here. Run `/mvt-analyze-code` periodically to rebuild from ground truth.
131
- 5. **Suggested next**:
132
- - Aggregated >= 1 change -> "Run `/mvt-cleanup` to archive these completed changes."
133
- - Verification flagged code-only entities -> "Run `/mvt-analyze-code` to capture missing entities."
134
-
135
- ### Step 9: (session update handled by shared section)
136
- - Refresh `session.last_synced_at` to current ISO timestamp.
137
-
138
- ## Edge Cases & Errors
139
-
140
- | Case | Handling |
141
- |------|----------|
142
- | `project-context.md` does not exist | Caught at preflight; recommend `/mvt-analyze-code` |
143
- | `.md` has zero `##` sections | STOP at Step 2; recommend `/mvt-analyze-code` |
144
- | Selected change-id has only `plan.yaml` | Filtered in Step 1; will not appear |
145
- | `modify` with `replace` but the existing line cannot be located deterministically | Fall back to append + flag as duplicate-needs-manual-edit; do NOT silently overwrite the wrong line |
146
- | `.md.bak` already exists | Overwrite (only the most recent backup matters) |
147
- | User aborts at Step 5 | Do not write; report "no changes applied" |
148
- | Step 6 verification finds zero matches for everything | Strong warning; require explicit confirm before proceeding (artifacts likely describe planned, not delivered, work) |
149
- | Two artifacts contradict each other (design says layer A, implementation says layer B) | Surface in Table 4b as cross-artifact conflict; user picks |
150
- | change-id was archived between Step 1 and Step 7 | Skip with note; do not error the run |
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Identify Completed Changes
4
+ - **What**: produce a candidate list of change-ids whose artifacts will be aggregated.
5
+ - **How**:
6
+ 1. Read `session.yaml`. Collect `recent_changes[]` entries with `status: completed`.
7
+ 2. For each candidate, verify `.ai-agents/workspace/artifacts/{change-id}/` exists AND contains at least one of `analysis.md` or `design.md`. Drop entries with only `plan.yaml`.
8
+ 3. (Fallback) If `recent_changes[]` is empty, scan `.ai-agents/workspace/artifacts/*/` directly; offer those with `analysis.md` or `design.md`, marked `unindexed`.
9
+ 4. Exclude any change-id whose directory contains an `_archive/` subfolder (already archived).
10
+ 5. Exclude `active_change.id` (work in flight).
11
+
12
+ - **Present** the list:
13
+
14
+ | # | change-id | title | status | analysis.md | design.md | implementation.md |
15
+ |---|-----------|-------|--------|-------------|-----------|-------------------|
16
+
17
+ - **Always print before user confirmation**:
18
+ > Run `/mvt-sync-context` BEFORE `/mvt-cleanup`. Once cleanup archives a change-id, this skill will skip it.
19
+
20
+ - **Prompt**: "Select changes to aggregate. Indices (e.g. 1,3,5), `a` for all, `n` to cancel."
21
+
22
+ - Cancel / empty selection -> stop with "no changes applied".
23
+
24
+ ### Step 2: Read Current Project Context (Adaptive Structure Discovery)
25
+
26
+ This step establishes the **target structure** that aggregated content must fit into. The structure is NOT assumed -- it is derived from the current document.
27
+
28
+ 1. Read `.ai-agents/knowledge/project/_generated/project-context.md`.
29
+ - Already required by preflight; if discovered missing here, STOP and recommend `/mvt-analyze-code`.
30
+ 2. Parse the current `.md` into a section map:
31
+ - Each top-level `##` heading -> one section anchor.
32
+ - Record: section title (verbatim), byte range, and a 1-line semantic summary derived from the section's content (e.g., "lists domain terms with definitions" or "describes module dependencies").
33
+ - The summary is what enables matching in Step 3 -- section titles may be in any language and may not match conventional names (Terms / Modules / etc.).
34
+ 3. If the document has zero `##` sections (single block) -> STOP. Recommend `/mvt-analyze-code` to establish a sectioned baseline first.
35
+ 4. Read `.ai-agents/workspace/project-context.yaml`. Record current `projects[].source_paths`, `modules`, and `tech_stack` for diff comparison in Step 4d.
36
+
37
+ ### Step 3: Extract and Classify Artifact Content
38
+
39
+ - **What**: from each selected change-id, extract atomic knowledge items and classify them against the section map from Step 2.
40
+ - **How**:
41
+ 1. For each selected change-id, read available artifacts (`analysis.md`, `design.md`, `implementation.md`).
42
+ 2. Extract atomic items. Typical sources:
43
+ - `analysis.md` -> domain terms, actors, business rules, constraints
44
+ - `design.md` -> modules, layers, dependency rules, key interfaces, ADRs
45
+ - `implementation.md` -> files added/changed (informs `.yaml` source_paths), realized vs deviated design points
46
+ 3. For each item, match to a section from the Step 2 map:
47
+ - Match by semantic similarity to **section title + 1-line summary**, not by exact string.
48
+ - Confidence levels:
49
+ - **mapped**: exactly one section matches with high confidence
50
+ - **ambiguous**: 2+ sections plausibly match
51
+ - **orphan**: no section matches; propose a new section name
52
+ 4. For each item, also detect change type relative to current section content:
53
+ - `new` -- target section does not contain this entity
54
+ - `modify` -- target section mentions the entity but artifact provides a different value
55
+ - `redundant` -- already present, no change (will be filtered out, not shown to user)
56
+
57
+ ### Step 4: Render the Update Plan (Four Tables)
58
+
59
+ #### 4a. Section-mapped items
60
+ | # | change-id | item | type | target section | classification |
61
+ |---|-----------|------|------|----------------|----------------|
62
+
63
+ #### 4b. Conflicts requiring resolution (every `modify` item)
64
+ | # | item | section | current value | proposed value (from {change-id}) |
65
+ |---|------|---------|---------------|-----------------------------------|
66
+
67
+ #### 4c. Ambiguous and orphan items
68
+ | # | item | reason | candidate sections (or proposed new section) |
69
+ |---|------|--------|----------------------------------------------|
70
+
71
+ #### 4d. Implied yaml changes
72
+ | # | yaml field | current | proposed |
73
+ |---|------------|---------|----------|
74
+
75
+ ### Step 5: User Confirmation (Per-Table)
76
+
77
+ - **4a**: default = accept all. User input: indices to drop, or `e <n>` to edit a single item's target section.
78
+ - **4b**: **explicit per-row decision required**. Format `<index>:<keep|replace|edit>`. Example: `1:replace,2:keep,3:edit`. No default.
79
+ - **4c**: per row, user picks an existing section, types a new section name, or `skip`.
80
+ - **4d**: default = accept; user can drop indices.
81
+
82
+ Then ask: **"Run optional read-only code verification before applying? (y/n)"**
83
+
84
+ ### Step 6: (Optional) Read-only Code Verification
85
+
86
+ This step catches artifacts claiming entities never actually delivered. It is **read-only** -- it never writes anything to `.md` or `.yaml`.
87
+
88
+ If user opts in:
89
+ 1. For each accepted item naming a code entity (module path, file, class, function), search the codebase under registered `source_paths`:
90
+ - Module path -> directory exists?
91
+ - File -> file exists?
92
+ - Symbol -> grep within source_paths
93
+ 2. Classify findings:
94
+
95
+ | Finding | Action |
96
+ |---------|--------|
97
+ | Artifact item matches code | Mark `verified`; keep in apply list |
98
+ | Artifact item NOT found in code | Flag `unverified`; ask user: drop or proceed (likely reverted / un-merged) |
99
+ | Code contains module / file / symbol that NO artifact item references | **Do NOT add to apply list.** Print: `Code-only entity detected: {path}. Run /mvt-analyze-code for ground-truth rebuild.` |
100
+
101
+ 3. Re-render the apply list with `verified` / `unverified` markers; final confirmation.
102
+
103
+ If user skips verification: proceed directly to Step 7 with Step 5 selections.
104
+
105
+ ### Step 7: Apply Updates (Merge Mode)
106
+
107
+ - **Pre-write**:
108
+ 1. Backup: `project-context.md` -> `project-context.md.bak`; `project-context.yaml` -> `project-context.yaml.bak`. Overwrite any prior `.bak`.
109
+ 2. Backup write failure -> STOP, do not modify originals.
110
+
111
+ - **Update `project-context.md`** (merge, never rewrite):
112
+ 1. Each `new` item: append to target section, matching the section's existing style (bullet vs paragraph).
113
+ 2. Each `modify` item with `replace`: replace the matching line in place. Smallest possible diff.
114
+ 3. Each `orphan` item with new-section choice: append a new `##` section at end of file.
115
+ 4. **Never delete** any existing line. **Never reorder** existing sections.
116
+
117
+ - **Update `project-context.yaml`** (structured merge):
118
+ 1. Apply accepted entries from Table 4d.
119
+ 2. Add new `source_paths` to matching project entry; add new modules to `modules[]`.
120
+ 3. **Never delete** an existing yaml entry in this skill.
121
+
122
+ - **Atomicity**: temp + rename per file. If `.md` write succeeds but `.yaml` fails (or vice versa) -> restore the failed one from `.bak`, keep the other; report partial success.
123
+
124
+ ### Step 8: Report
125
+
126
+ 1. **Applied summary** -- counts: items added / modified / skipped / orphaned-into-new-section
127
+ 2. **Files changed** -- paths + byte deltas
128
+ 3. **Backup paths** -- so user can manually revert
129
+ 4. **Out-of-scope reminder** (always print):
130
+ > This skill processes additions and modifications only. Module deletions, renames, and large refactors are NOT detected here. Run `/mvt-analyze-code` periodically to rebuild from ground truth.
131
+ 5. **Suggested next**:
132
+ - Aggregated >= 1 change -> "Run `/mvt-cleanup` to archive these completed changes."
133
+ - Verification flagged code-only entities -> "Run `/mvt-analyze-code` to capture missing entities."
134
+
135
+ ### Step 9: (session update handled by shared section)
136
+ - Refresh `session.last_synced_at` to current ISO timestamp.
137
+
138
+ ## Edge Cases & Errors
139
+
140
+ | Case | Handling |
141
+ |------|----------|
142
+ | `project-context.md` does not exist | Caught at preflight; recommend `/mvt-analyze-code` |
143
+ | `.md` has zero `##` sections | STOP at Step 2; recommend `/mvt-analyze-code` |
144
+ | Selected change-id has only `plan.yaml` | Filtered in Step 1; will not appear |
145
+ | `modify` with `replace` but the existing line cannot be located deterministically | Fall back to append + flag as duplicate-needs-manual-edit; do NOT silently overwrite the wrong line |
146
+ | `.md.bak` already exists | Overwrite (only the most recent backup matters) |
147
+ | User aborts at Step 5 | Do not write; report "no changes applied" |
148
+ | Step 6 verification finds zero matches for everything | Strong warning; require explicit confirm before proceeding (artifacts likely describe planned, not delivered, work) |
149
+ | Two artifacts contradict each other (design says layer A, implementation says layer B) | Surface in Table 4b as cross-artifact conflict; user picks |
150
+ | change-id was archived between Step 1 and Step 7 | Skip with note; do not error the run |