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

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 (80) hide show
  1. package/README.md +1 -11
  2. package/dist/build/section-loader.d.ts.map +1 -1
  3. package/dist/build/section-loader.js +18 -8
  4. package/dist/build/section-loader.js.map +1 -1
  5. package/dist/fs/materialize.d.ts.map +1 -1
  6. package/dist/fs/materialize.js +12 -4
  7. package/dist/fs/materialize.js.map +1 -1
  8. package/dist/fs/registry-merge.d.ts +19 -0
  9. package/dist/fs/registry-merge.d.ts.map +1 -0
  10. package/dist/fs/registry-merge.js +177 -0
  11. package/dist/fs/registry-merge.js.map +1 -0
  12. package/dist/scripts/plan-update.cjs +7563 -0
  13. package/dist/scripts/session-update.cjs +7568 -0
  14. package/install-manifest.yaml +8 -2
  15. package/package.json +3 -2
  16. package/sources/defaults/config.yaml +7 -7
  17. package/sources/defaults/session.yaml +9 -16
  18. package/sources/scripts/plan-update.js +353 -0
  19. package/sources/scripts/session-update.js +351 -0
  20. package/sources/sections/activation-load-context.md +4 -0
  21. package/sources/sections/footer-next-steps.md +1 -1
  22. package/sources/sections/output-format-constraint.md +14 -0
  23. package/sources/sections/project-context-profile.md +29 -0
  24. package/sources/sections/session-update.md +100 -32
  25. package/sources/skills/mvt-analyze/manifest.yaml +4 -0
  26. package/sources/skills/mvt-analyze-code/manifest.yaml +24 -4
  27. package/sources/skills/mvt-bug-detect/business.md +99 -101
  28. package/sources/skills/mvt-bug-detect/manifest.yaml +84 -84
  29. package/sources/skills/mvt-check-context/business.md +3 -5
  30. package/sources/skills/mvt-check-context/manifest.yaml +15 -8
  31. package/sources/skills/mvt-cleanup/business.md +49 -23
  32. package/sources/skills/mvt-cleanup/manifest.yaml +18 -10
  33. package/sources/skills/mvt-config/business.md +1 -2
  34. package/sources/skills/mvt-config/manifest.yaml +11 -4
  35. package/sources/skills/mvt-create-skill/business.md +6 -5
  36. package/sources/skills/mvt-create-skill/manifest.yaml +30 -11
  37. package/sources/skills/mvt-design/business.md +3 -6
  38. package/sources/skills/mvt-design/manifest.yaml +17 -1
  39. package/sources/skills/mvt-fix/business.md +2 -1
  40. package/sources/skills/mvt-fix/manifest.yaml +9 -3
  41. package/sources/skills/mvt-help/business.md +2 -4
  42. package/sources/skills/mvt-help/manifest.yaml +13 -5
  43. package/sources/skills/mvt-implement/business.md +10 -7
  44. package/sources/skills/mvt-implement/manifest.yaml +16 -0
  45. package/sources/skills/mvt-init/business.md +2 -2
  46. package/sources/skills/mvt-init/manifest.yaml +4 -0
  47. package/sources/skills/mvt-manage-context/business.md +11 -0
  48. package/sources/skills/mvt-manage-context/manifest.yaml +20 -3
  49. package/sources/skills/mvt-plan-dev/business.md +101 -20
  50. package/sources/skills/mvt-plan-dev/manifest.yaml +21 -19
  51. package/sources/skills/mvt-quick-dev/business.md +2 -1
  52. package/sources/skills/mvt-quick-dev/manifest.yaml +24 -6
  53. package/sources/skills/mvt-refactor/business.md +2 -1
  54. package/sources/skills/mvt-refactor/manifest.yaml +24 -3
  55. package/sources/skills/mvt-resume/business.md +28 -68
  56. package/sources/skills/mvt-resume/manifest.yaml +17 -7
  57. package/sources/skills/mvt-review/business.md +3 -3
  58. package/sources/skills/mvt-review/manifest.yaml +25 -1
  59. package/sources/skills/mvt-status/business.md +14 -18
  60. package/sources/skills/mvt-status/manifest.yaml +11 -3
  61. package/sources/skills/mvt-sync-context/business.md +69 -35
  62. package/sources/skills/mvt-sync-context/manifest.yaml +9 -0
  63. package/sources/skills/mvt-template/business.md +0 -2
  64. package/sources/skills/mvt-template/manifest.yaml +13 -8
  65. package/sources/skills/mvt-test/business.md +3 -3
  66. package/sources/skills/mvt-test/manifest.yaml +17 -1
  67. package/sources/skills/mvt-update-plan/business.md +41 -28
  68. package/sources/skills/mvt-update-plan/manifest.yaml +14 -19
  69. package/dist/build/plan-validator.d.ts +0 -26
  70. package/dist/build/plan-validator.d.ts.map +0 -1
  71. package/dist/build/plan-validator.js +0 -225
  72. package/dist/build/plan-validator.js.map +0 -1
  73. package/dist/commands/build.d.ts +0 -5
  74. package/dist/commands/build.d.ts.map +0 -1
  75. package/dist/commands/build.js +0 -46
  76. package/dist/commands/build.js.map +0 -1
  77. package/dist/commands/migrate.d.ts +0 -16
  78. package/dist/commands/migrate.d.ts.map +0 -1
  79. package/dist/commands/migrate.js +0 -118
  80. package/dist/commands/migrate.js.map +0 -1
@@ -1,101 +1,99 @@
1
- ## Execution Flow
2
-
3
- ### Step 1: Receive & Complete Input
4
- - Read the user-provided bug description (free text, possibly with stack trace, error message, or reproduction steps).
5
- - Assess input completeness using the table below:
6
-
7
- | Input Situation | Action |
8
- |-----------------|--------|
9
- | No input provided | Present a structured template and wait. Template fields: **Error message**, **Reproduction steps**, **Expected behavior**, **Actual behavior**, **Environment** |
10
- | Only error message | Ask: trigger conditions, runtime environment, recent changes |
11
- | Only behavioral description (no error) | Ask: any error message available, whether it reproduces reliably, affected scope |
12
- | Stack trace present | Sufficient — proceed to Step 2 |
13
- | Reproduction steps + error message | Sufficient — proceed to Step 2 |
14
-
15
- - When asking for clarification, be specific. Do NOT ask "can you provide more details?" — instead, name the exact missing dimension (e.g., "What error message do you see when this happens?").
16
-
17
- ### Step 2: Signal Extraction & Localization
18
- - Extract concrete signals from the bug description: error message text, stack trace frames, file paths, function/class names, input data.
19
- - For each signal, locate matching code (Grep / Glob).
20
- - Build a candidate file list with one-line justification per file.
21
- - Read recent git state (`git diff HEAD`, `git log -n 10 --oneline`) to surface recent changes that may correlate with the issue.
22
-
23
- ### Step 3: Reproduction Verification
24
-
25
- | Condition | Action |
26
- |-----------|--------|
27
- | Reproduction steps provided → successfully reproduced | Mark as `Verified`, capture observed vs expected behavior |
28
- | Reproduction steps provided → cannot reproduce | Mark as `Unverified`, continue with static analysis only |
29
- | No reproduction steps, but signals are concrete (stack trace + paths) | Continue with static analysis, mark as `Static-only` |
30
- | No reproduction steps, signals are vague | STOP — ask user for: minimal reproduction, exact error, environment, last-known-good version |
31
-
32
- ### Step 4: Root Cause Analysis
33
- - Generate 1-5 candidate root cause hypotheses based on the dominant signal:
34
-
35
- | Dominant Signal | Hypothesis Sources |
36
- |-----------------|--------------------|
37
- | Stack trace | Top frame in user code, recently changed code in any frame, null/undefined origin, type mismatch at boundary |
38
- | Error message | Exact-string search in repo, typed exception class hierarchy, library docs for that error |
39
- | Recent git diff | Files changed in last N commits intersecting with localized files, commit messages mentioning related modules |
40
- | Behavioral description (no error) | Module boundary mismatches, off-by-one / null-handling, async/race, state leakage, configuration drift |
41
-
42
- - Each hypothesis must be written as: `<claim> -- evidence: <pointer> -- check: <how to verify>`.
43
- - Verify hypotheses from cheapest check to most expensive. Eliminate hypotheses that fail their checks.
44
- - If ALL hypotheses are eliminated — STOP, surface findings, request more info from user. Do NOT fabricate new hypotheses silently.
45
-
46
- ### Step 5: Impact Assessment & Classification
47
-
48
- **Bug Confirmation Status:**
49
-
50
- | Status | Meaning |
51
- |--------|---------|
52
- | Confirmed | Root cause verified, bug definitely exists |
53
- | Likely | Evidence is strong but cannot fully rule out other possibilities |
54
- | NotABug | Actual behavior matches expected behavior / business rules — not a bug |
55
- | Inconclusive | Insufficient evidence, requires human judgment |
56
-
57
- **Severity:**
58
-
59
- | Level | Definition |
60
- |-------|------------|
61
- | Critical | Data loss, security vulnerability, core functionality broken |
62
- | High | Major feature broken but temporary workaround exists |
63
- | Medium | Minor feature broken or usability issue |
64
- | Low | Edge case issue, no significant impact on main flow |
65
-
66
- **Impact Scope:**
67
- - List affected modules/files with one-line description each.
68
- - List affected user scenarios / business flows.
69
- - Search for similar patterns elsewhere in the codebase (same root cause may exist in other locations).
70
-
71
- ### Step 6: Present Diagnosis
72
- - Output the diagnosis in conversation using this format:
73
-
74
- ```
75
- Bug Detection Result
76
- ─────────────────────
77
- Status: <Confirmed | Likely | NotABug | Inconclusive>
78
- Severity: <Critical | High | Medium | Low>
79
- Root Cause: <one paragraph>
80
- Confidence: <reasoning for the status judgment>
81
- Impact: <affected modules and scenarios>
82
- Affected: <file list with line ranges>
83
- Similar: <other locations that may have the same root cause>
84
- ─────────────────────
85
- ```
86
-
87
- - For `NotABug`: explain why the current behavior is expected, and suggest `/mvt-analyze` if the requirement itself needs revision.
88
- - For `Inconclusive`: summarize what was found and what remains unknown, so the user or `/mvt-fix` can act with full awareness.
89
-
90
- ### Step 7: (session update handled by shared section)
91
-
92
- ## Edge Cases & Errors
93
-
94
- | Case | Handling |
95
- |------|----------|
96
- | Bug is intermittent / racy | Mark reproduction as "flaky", state confidence level explicitly, suggest adding instrumentation rather than speculative analysis |
97
- | Root cause is in a third-party dependency | Document the upstream issue, note that local workaround would be the only fix option |
98
- | Bug description describes expected behavior (NotABug) | Explain clearly with evidence from code/business rules, do NOT proceed to suggest fixes |
99
- | Multiple independent bugs described in one input | Analyze each separately, present multiple diagnosis blocks |
100
- | User provides a URL or external reference | Note it but do NOT fetch external resources; work only with local code and the description text |
101
- | `active_change` is missing | Run without change context (shortcut mode); omit change-id references in output |
1
+ ## Execution Flow
2
+
3
+ ### Step 1: Receive & Complete Input
4
+ - Read the user-provided bug description (free text, possibly with stack trace, error message, or reproduction steps).
5
+ - Assess input completeness using the table below:
6
+
7
+ | Input Situation | Action |
8
+ |-----------------|--------|
9
+ | No input provided | Present a structured template and wait. Template fields: **Error message**, **Reproduction steps**, **Expected behavior**, **Actual behavior**, **Environment** |
10
+ | Only error message | Ask: trigger conditions, runtime environment, recent changes |
11
+ | Only behavioral description (no error) | Ask: any error message available, whether it reproduces reliably, affected scope |
12
+ | Stack trace present | Sufficient — proceed to Step 2 |
13
+ | Reproduction steps + error message | Sufficient — proceed to Step 2 |
14
+
15
+ - When asking for clarification, be specific. Do NOT ask "can you provide more details?" — instead, name the exact missing dimension (e.g., "What error message do you see when this happens?").
16
+
17
+ ### Step 2: Signal Extraction & Localization
18
+ - Extract concrete signals from the bug description: error message text, stack trace frames, file paths, function/class names, input data.
19
+ - For each signal, locate matching code (Grep / Glob).
20
+ - Build a candidate file list with one-line justification per file.
21
+ - Read recent git state (`git diff HEAD`, `git log -n 10 --oneline`) to surface recent changes that may correlate with the issue.
22
+
23
+ ### Step 3: Reproduction Verification
24
+
25
+ | Condition | Action |
26
+ |-----------|--------|
27
+ | Reproduction steps provided → successfully reproduced | Mark as `Verified`, capture observed vs expected behavior |
28
+ | Reproduction steps provided → cannot reproduce | Mark as `Unverified`, continue with static analysis only |
29
+ | No reproduction steps, but signals are concrete (stack trace + paths) | Continue with static analysis, mark as `Static-only` |
30
+ | No reproduction steps, signals are vague | STOP — ask user for: minimal reproduction, exact error, environment, last-known-good version |
31
+
32
+ ### Step 4: Root Cause Analysis
33
+ - Generate 1-5 candidate root cause hypotheses based on the dominant signal:
34
+
35
+ | Dominant Signal | Hypothesis Sources |
36
+ |-----------------|--------------------|
37
+ | Stack trace | Top frame in user code, recently changed code in any frame, null/undefined origin, type mismatch at boundary |
38
+ | Error message | Exact-string search in repo, typed exception class hierarchy, library docs for that error |
39
+ | Recent git diff | Files changed in last N commits intersecting with localized files, commit messages mentioning related modules |
40
+ | Behavioral description (no error) | Module boundary mismatches, off-by-one / null-handling, async/race, state leakage, configuration drift |
41
+
42
+ - Each hypothesis must be written as: `<claim> -- evidence: <pointer> -- check: <how to verify>`.
43
+ - Verify hypotheses from cheapest check to most expensive. Eliminate hypotheses that fail their checks.
44
+ - If ALL hypotheses are eliminated — STOP, surface findings, request more info from user. Do NOT fabricate new hypotheses silently.
45
+
46
+ ### Step 5: Impact Assessment & Classification
47
+
48
+ **Bug Confirmation Status:**
49
+
50
+ | Status | Meaning |
51
+ |--------|---------|
52
+ | Confirmed | Root cause verified, bug definitely exists |
53
+ | Likely | Evidence is strong but cannot fully rule out other possibilities |
54
+ | NotABug | Actual behavior matches expected behavior / business rules — not a bug |
55
+ | Inconclusive | Insufficient evidence, requires human judgment |
56
+
57
+ **Severity:**
58
+
59
+ | Level | Definition |
60
+ |-------|------------|
61
+ | Critical | Data loss, security vulnerability, core functionality broken |
62
+ | High | Major feature broken but temporary workaround exists |
63
+ | Medium | Minor feature broken or usability issue |
64
+ | Low | Edge case issue, no significant impact on main flow |
65
+
66
+ **Impact Scope:**
67
+ - List affected modules/files with one-line description each.
68
+ - List affected user scenarios / business flows.
69
+ - Search for similar patterns elsewhere in the codebase (same root cause may exist in other locations).
70
+
71
+ ### Step 6: Present Diagnosis
72
+ - Output the diagnosis in conversation using this format:
73
+
74
+ ```
75
+ Bug Detection Result
76
+ ─────────────────────
77
+ Status: <Confirmed | Likely | NotABug | Inconclusive>
78
+ Severity: <Critical | High | Medium | Low>
79
+ Root Cause: <one paragraph>
80
+ Confidence: <reasoning for the status judgment>
81
+ Impact: <affected modules and scenarios>
82
+ Affected: <file list with line ranges>
83
+ Similar: <other locations that may have the same root cause>
84
+ ─────────────────────
85
+ ```
86
+
87
+ - For `NotABug`: explain why the current behavior is expected, and suggest `/mvt-analyze` if the requirement itself needs revision.
88
+ - For `Inconclusive`: summarize what was found and what remains unknown, so the user or `/mvt-fix` can act with full awareness.
89
+
90
+ ## Edge Cases & Errors
91
+
92
+ | Case | Handling |
93
+ |------|----------|
94
+ | Bug is intermittent / racy | Mark reproduction as "flaky", state confidence level explicitly, suggest adding instrumentation rather than speculative analysis |
95
+ | Root cause is in a third-party dependency | Document the upstream issue, note that local workaround would be the only fix option |
96
+ | Bug description describes expected behavior (NotABug) | Explain clearly with evidence from code/business rules, do NOT proceed to suggest fixes |
97
+ | Multiple independent bugs described in one input | Analyze each separately, present multiple diagnosis blocks |
98
+ | User provides a URL or external reference | Note it but do NOT fetch external resources; work only with local code and the description text |
99
+ | `active_change` is missing | Run without change context (shortcut mode); omit change-id references in output |
@@ -1,84 +1,84 @@
1
- name: mvt-bug-detect
2
- output: .claude/skills/mvt-bug-detect/SKILL.md
3
-
4
- frontmatter:
5
- name: mvt-bug-detect
6
- description: "Analyze and detect bugs by investigating root cause, assessing severity and impact scope. Produces a structured diagnosis in conversation without applying fixes. This skill should be used when user suspects a bug, wants to understand a problem before fixing, or needs impact analysis."
7
-
8
- sections:
9
- - type: inline
10
- content: |
11
- # MVT Bug Detect
12
-
13
- ## Purpose
14
-
15
- Investigate suspected bugs: confirm whether the bug exists, identify root cause, assess severity and impact scope, and produce a structured diagnosis. This skill does NOT apply fixes — it provides analysis to help the user understand the problem and decide on next steps.
16
-
17
- - type: shared
18
- source: sections/role-header.md
19
- params:
20
- role: Analyst
21
- role_desc: "a Bug Investigation Specialist"
22
- decision_rules:
23
- - rule: "Bug description provided -> Analyze and investigate"
24
- - rule: "Input too vague -> Prompt for specific details with structured template"
25
- - rule: "No input -> Provide input template and wait"
26
- - rule: "Root cause confirmed -> Assess impact and produce diagnosis"
27
- - rule: "Multiple possible causes -> List hypotheses with evidence, verify each"
28
- - rule: "Bug does not exist (expected behavior) -> Report clearly, suggest /mvt-analyze if requirement gap"
29
- - rule: "Evidence insufficient -> Report findings, request more info, do NOT fabricate hypotheses"
30
- boundaries:
31
- - scope: "apply fixes"
32
- skill: "/mvt-fix"
33
- - scope: "design architecture"
34
- skill: "/mvt-design"
35
- - scope: "review code quality"
36
- skill: "/mvt-review"
37
-
38
- - type: shared
39
- source: sections/activation-load-context.md
40
- params:
41
- extended_context:
42
- - "Related source files (load based on bug description signals)"
43
-
44
- - type: shared
45
- source: sections/activation-load-config.md
46
-
47
- - type: shared
48
- source: sections/output-language-constraint.md
49
-
50
- - type: inline
51
- content: |
52
- ### Shortcut Operation Rules
53
- - Can execute at any time without checking workflow prerequisites
54
- - Do NOT update `progress` (this is a shortcut operation, not a workflow phase)
55
- - Do NOT write any artifact — diagnosis is presented in conversation only
56
- - Do NOT modify any source code — this skill is read-only analysis
57
-
58
- - type: file
59
- source: ./business.md
60
-
61
- - type: shared
62
- source: sections/session-update.md
63
-
64
- - type: shared
65
- source: sections/footer-next-steps.md
66
- params:
67
- current_skill: mvt-bug-detect
68
- conditional_suggestions:
69
- conditions:
70
- - condition: "bug confirmed, fix is straightforward"
71
- primary: "mvt-fix"
72
- primary_desc: "Fix this bug"
73
- - condition: "bug confirmed, fix requires architecture change"
74
- primary: "mvt-design"
75
- primary_desc: "Design architectural solution first"
76
- alternatives:
77
- - skill: "mvt-fix"
78
- desc: "Apply a minimal workaround"
79
- - condition: "not a bug (expected behavior)"
80
- primary: "mvt-analyze"
81
- primary_desc: "Re-analyze the underlying requirement"
82
- - condition: "inconclusive, needs deeper code understanding"
83
- primary: "mvt-analyze-code"
84
- primary_desc: "Deep-dive into the codebase"
1
+ name: mvt-bug-detect
2
+ output: .claude/skills/mvt-bug-detect/SKILL.md
3
+
4
+ frontmatter:
5
+ name: mvt-bug-detect
6
+ description: "Analyze and detect bugs by investigating root cause, assessing severity and impact scope. Produces a structured diagnosis in conversation without applying fixes. This skill should be used when user suspects a bug, wants to understand a problem before fixing, or needs impact analysis."
7
+
8
+ sections:
9
+ - type: inline
10
+ content: |
11
+ # MVT Bug Detect
12
+
13
+ ## Purpose
14
+
15
+ Investigate suspected bugs: confirm whether the bug exists, identify root cause, assess severity and impact scope, and produce a structured diagnosis. This skill does NOT apply fixes — it provides analysis to help the user understand the problem and decide on next steps.
16
+
17
+ - type: shared
18
+ source: sections/role-header.md
19
+ params:
20
+ role: Analyst
21
+ role_desc: "a Bug Investigation Specialist"
22
+ decision_rules:
23
+ - rule: "Bug description provided -> Analyze and investigate"
24
+ - rule: "Input too vague -> Prompt for specific details with structured template"
25
+ - rule: "No input -> Provide input template and wait"
26
+ - rule: "Root cause confirmed -> Assess impact and produce diagnosis"
27
+ - rule: "Multiple possible causes -> List hypotheses with evidence, verify each"
28
+ - rule: "Bug does not exist (expected behavior) -> Report clearly, suggest /mvt-analyze if requirement gap"
29
+ - rule: "Evidence insufficient -> Report findings, request more info, do NOT fabricate hypotheses"
30
+ boundaries:
31
+ - scope: "apply fixes"
32
+ skill: "/mvt-fix"
33
+ - scope: "design architecture"
34
+ skill: "/mvt-design"
35
+ - scope: "review code quality"
36
+ skill: "/mvt-review"
37
+
38
+ - type: shared
39
+ source: sections/activation-load-context.md
40
+ params:
41
+ extended_context:
42
+ - "Related source files (load based on bug description signals)"
43
+
44
+ - type: shared
45
+ source: sections/activation-load-config.md
46
+
47
+ - type: inline
48
+ content: |
49
+ ## Operation Mode: Shortcut
50
+
51
+ This skill operates as a shortcut — it can execute at any time without checking workflow prerequisites.
52
+ - Do NOT update `active_change` fields (this is a shortcut operation, not a workflow phase).
53
+ - Do NOT write any artifact diagnosis is presented in conversation only.
54
+ - Do NOT modify any source code this skill is read-only analysis.
55
+
56
+ - type: file
57
+ source: ./business.md
58
+
59
+ - type: shared
60
+ source: sections/session-update.md
61
+ params:
62
+ current_skill: mvt-bug-detect
63
+
64
+ - type: shared
65
+ source: sections/footer-next-steps.md
66
+ params:
67
+ current_skill: mvt-bug-detect
68
+ conditional_suggestions:
69
+ conditions:
70
+ - condition: "bug confirmed, fix is straightforward"
71
+ primary: "mvt-fix"
72
+ primary_desc: "Fix this bug"
73
+ - condition: "bug confirmed, fix requires architecture change"
74
+ primary: "mvt-design"
75
+ primary_desc: "Design architectural solution first"
76
+ alternatives:
77
+ - skill: "mvt-fix"
78
+ desc: "Apply a minimal workaround"
79
+ - condition: "not a bug (expected behavior)"
80
+ primary: "mvt-analyze"
81
+ primary_desc: "Re-analyze the underlying requirement"
82
+ - condition: "inconclusive, needs deeper code understanding"
83
+ primary: "mvt-analyze-code"
84
+ primary_desc: "Deep-dive into the codebase"
@@ -13,7 +13,7 @@ This skill measures only files the **user** can reduce or relocate. Framework-fi
13
13
  - Semantic context: `.ai-agents/knowledge/project/_generated/project-context.md`.
14
14
  - Shared knowledge: every entry in `registry.yaml > knowledge.shared`. For the `core` entry, scan only files marked as user-origin per `core/manifest.yaml` (or whose path begins with `user/`); skip files under `core/_framework/`.
15
15
  - Per-skill knowledge: every entry in `registry.yaml > skills.*.knowledge`, grouped by skill.
16
- - Artifacts: all files under `.ai-agents/workspace/artifacts/` recursively.
16
+ - Artifacts: all files under `.ai-agents/workspace/artifacts/` recursively. **Exclude the `_archived/` subdirectory** — it contains completed changes archived by `/mvt-cleanup` and should not count toward the active workspace token budget.
17
17
 
18
18
  **Out of scope (do NOT scan):**
19
19
  - `.claude/skills/mvt-*/SKILL.md` -- framework-shipped, not user-editable.
@@ -51,7 +51,7 @@ This skill measures only files the **user** can reduce or relocate. Framework-fi
51
51
  |---------|------------------|-----------------|
52
52
  | `project-context.md` is `oversized` | "project-context.md is {N} tokens. Regenerate with leaner sections." | `/mvt-analyze-code` |
53
53
  | `project-context.md` is `borderline` AND last `/mvt-analyze-code` ran > 30 days ago | "project-context.md is {N} tokens and may be stale. Consider regenerating." | `/mvt-analyze-code` |
54
- | Total artifacts tokens > artifacts threshold OR > 3 completed changes still in `artifacts/` | "Workspace has {N} tokens of historical artifacts. Archive completed changes." | `/mvt-cleanup` |
54
+ | Total artifacts tokens > artifacts threshold OR > 3 completed changes still in `artifacts/` (excluding `_archived/`) | "Workspace has {N} tokens of historical artifacts. Archive completed changes." | `/mvt-cleanup` |
55
55
  | A specific change-id directory is `oversized` | "artifacts/{id} alone is {N} tokens. Summarize this change." | `/mvt-cleanup` |
56
56
  | Shared Knowledge total is `oversized` | "Shared knowledge totals {N} tokens (loaded by every skill). Move skill-specific entries to per-skill." | `/mvt-manage-context move` |
57
57
  | A single Shared Knowledge file is `oversized` | "{path} is {N} tokens. Split or move to per-skill." | `/mvt-manage-context move` |
@@ -74,8 +74,6 @@ This skill measures only files the **user** can reduce or relocate. Framework-fi
74
74
  6. **Excluded Scope Note** -- one paragraph reminding the user that framework files (`_framework/`, `mvt-*/SKILL.md`, `config.yaml`, `session.yaml`, `registry.yaml`) were not measured here.
75
75
  - The report is conversation output; this skill does NOT write any artifact.
76
76
 
77
- ### Step 7: (session update handled by shared section)
78
-
79
77
  ## Edge Cases & Errors
80
78
 
81
79
  | Case | Handling |
@@ -83,7 +81,7 @@ This skill measures only files the **user** can reduce or relocate. Framework-fi
83
81
  | `registry.yaml` references a knowledge id whose source path is empty / missing | Include in Step 5 recommendations; do NOT count missing files toward token totals |
84
82
  | `core/manifest.yaml` cannot be parsed | Treat the whole `core/` tree as in-scope (over-counts); add a note in the report |
85
83
  | Workspace has zero artifacts | Skip the artifacts category in Step 6; do not error |
86
- | Workspace exceeds the artifacts threshold AND the user just ran `/mvt-cleanup` (within last hour per `skill_history`) | Surface but downgrade to a one-line note ("recently cleaned -- remaining {N} tokens are likely active work") |
84
+ | Workspace exceeds the artifacts threshold AND the user just ran `/mvt-cleanup` (within last hour per `history`) | Surface but downgrade to a one-line note ("recently cleaned -- remaining {N} tokens are likely active work") |
87
85
  | User passes a path argument | This skill ignores arguments; print a one-line note and run as normal (do not narrow scope to a single file -- that is `/mvt-status` territory) |
88
86
  | Token estimate disagrees with model's actual consumption | This is expected; the `chars/4` heuristic is an approximation. State this caveat in the Summary line |
89
87
  | Two skills declare the same knowledge id | Count the file once for storage but report it under both skills in the Per-Skill table; flag the duplication in Step 5 |
@@ -20,10 +20,9 @@ sections:
20
20
  role: Conductor
21
21
  role_desc: "a Workflow Coordinator"
22
22
  decision_rules:
23
- - rule: "Total tokens < 5,000 -> Report as \"Good\""
24
- - rule: "Total tokens 5,000-15,000 -> Report as \"Moderate\""
25
- - rule: "Total tokens 15,000-30,000 -> Report as \"High\", suggest optimizations"
26
- - rule: "Total tokens > 30,000 -> Report as \"Overloaded\", strongly recommend cleanup"
23
+ - rule: "Total tokens <= 12,000 -> Report as \"Healthy\""
24
+ - rule: "Total tokens 12,001-25,000 -> Report as \"Borderline\", suggest optimizations"
25
+ - rule: "Total tokens > 25,000 -> Report as \"Oversized\", strongly recommend cleanup"
27
26
  boundaries:
28
27
  - scope: "modify any files"
29
28
  skill: "(Only analyze and recommend)"
@@ -41,12 +40,9 @@ sections:
41
40
  - type: shared
42
41
  source: sections/activation-load-config.md
43
42
 
44
- - type: shared
45
- source: sections/output-language-constraint.md
46
-
47
43
  - type: inline
48
44
  content: |
49
- ### Step 3: Pre-flight Checks
45
+ ### Step 4: Pre-flight Checks
50
46
  - No blocking checks required.
51
47
 
52
48
  - type: file
@@ -61,3 +57,14 @@ sections:
61
57
  source: sections/footer-next-steps.md
62
58
  params:
63
59
  current_skill: mvt-check-context
60
+ conditional_suggestions:
61
+ conditions:
62
+ - condition: "context oversized or borderline"
63
+ primary: mvt-cleanup
64
+ primary_desc: "Archive old artifacts to reduce context"
65
+ alternatives:
66
+ - skill: mvt-manage-context
67
+ desc: "Move per-skill knowledge to reduce shared load"
68
+ - condition: "context healthy"
69
+ primary: mvt-status
70
+ primary_desc: "Check overall project status"
@@ -3,33 +3,42 @@
3
3
  ### Step 1: Load Inputs
4
4
  - **Fallback**: if `session.yaml` is missing, refuse to clean -- without state we can't tell what is in-progress vs completed; recommend `/mvt-init` and stop.
5
5
 
6
- ### Step 2: Inventory Artifacts
6
+ ### Step 2: Pre-Archive Sync Check
7
+
8
+ For each `changes[]` entry with `status: done`:
9
+ 1. Compare `session.last_synced_at` with the change's `updated_at`.
10
+ 2. If `last_synced_at` is empty OR `last_synced_at` < `updated_at`, mark the change as **⚠️ unsynced**.
11
+ 3. Collect all unsynced change-ids into a warning list for display in Step 6.
12
+
13
+ This check ensures `/mvt-sync-context` has processed a change's knowledge before cleanup archives it. Once archived, the original artifact files (`analysis.md`, `design.md`, `implementation.md`) are no longer accessible to sync-context.
14
+
15
+ ### Step 3: Inventory Artifacts
7
16
  - **What**: produce a per-change-id inventory with size and last-modified data.
8
17
  - **How**:
9
- 1. Walk `.ai-agents/workspace/artifacts/` and group files by their parent change-id directory.
18
+ 1. Walk `.ai-agents/workspace/artifacts/` and group files by their parent change-id directory. **Exclude the `_archived/` subdirectory** from the walk — it contains previously archived changes and is not subject to re-inventory.
10
19
  2. For each file: characters, estimated tokens (`chars / 4`), last-modified (mtime).
11
20
  3. For each change-id directory, sum tokens and file count.
12
21
  4. Mark each change-id as `active | in-recent-changes | unindexed | legacy-pattern`:
13
22
  - `active` if it matches `session.active_change.id`.
14
- - `in-recent-changes` if it appears in `session.recent_changes[]` (any status).
23
+ - `in-recent-changes` if it appears in `session.changes[]` (any status).
15
24
  - `unindexed` if neither condition holds and it sits under `artifacts/`.
16
25
  - `legacy-pattern` if the directory is `knowledge/patterns/` or matches other legacy markers.
17
26
 
18
- ### Step 3: Apply Cleanup Rules
27
+ ### Step 4: Apply Cleanup Rules
19
28
  - **What**: compute Cleanup Candidates from the inventory.
20
- - **How**: run the rules table (defined in the shared section above) plus the additions below. A single change-id may match multiple rows; collect all proposed actions.
29
+ - **How**: run the rules table below. A single change-id may match multiple rows; collect all proposed actions.
21
30
 
22
31
  | Source | Rule | Proposed action |
23
32
  |--------|------|-----------------|
24
- | `recent_changes[]` entry with `status: completed` AND any task in plan is older than the active change's start | Summarize: collapse multi-file artifacts into a single `summary.md`, keep the plan.yaml verbatim, archive the rest under `artifacts/{id}/_archive/` |
33
+ | `changes[]` entry with `status: done` AND any task in plan is older than the active change's start | Summarize: generate a `summary.md` from the change's artifacts, then move the **entire** `artifacts/{id}/` directory (including `summary.md`) to `artifacts/_archived/{id}/` |
25
34
  | Change-id directory marked `unindexed` | List for user review (do NOT auto-archive -- could be in-flight work the user just hasn't registered) |
26
- | `skill_history` entries beyond the most recent 10 | Collapse into a single summary entry inside session.yaml (rule from Cleanup Rules table) |
35
+ | `history` entries beyond the most recent N (from `config.yaml > preferences.history_limits.history`, default 20) | Truncate via `session-update.cjs --truncate-history <N>` |
27
36
  | Directory `knowledge/patterns/` exists | Flag for deletion (legacy pattern data; no replacement) |
28
37
  | Empty change-id directories (zero files inside) | Propose deletion of the directory itself |
29
38
 
30
39
  - For each candidate, compute: `current size (tokens)` -> `projected size (tokens)`, expected savings.
31
40
 
32
- ### Step 4: Present Cleanup Plan
41
+ ### Step 5: Present Cleanup Plan
33
42
  - Render the plan as a table:
34
43
 
35
44
  | Item | Category | Current Size | Action | Result |
@@ -40,41 +49,58 @@
40
49
  - Below the table, list any items marked `review-only` (unindexed) with a one-line note: user must decide manually.
41
50
  - If `--dry-run` is set, STOP here. Print "(dry run -- no changes applied)" and exit cleanly.
42
51
 
43
- ### Step 5: Confirm Before Destructive Steps
52
+ ### Step 6: Confirm Before Destructive Steps
44
53
  - **Always require confirmation** if the plan includes any of:
45
54
  - File deletion (legacy patterns, empty dirs).
46
55
  - `summarize` action (collapses multi-file content).
47
- - `archive` action (moves files into `_archive/`).
48
- - Confirmation format: a single prompt `Apply cleanup plan? (y / n / show-details)`. `show-details` prints the per-file actions, then re-asks.
56
+ - `archive` action (moves entire change-id directory into `artifacts/_archived/`).
57
+ - If the Step 2 warning list is non-empty, prepend it to the confirmation prompt:
58
+ > ⚠️ The following changes have NOT been synced by `/mvt-sync-context`. Archiving them will permanently lose their knowledge for aggregation:
59
+ > - {change-id}: {title}
60
+ > Options: `y` = archive anyway, `n` = cancel, `sync-first` = abort and run `/mvt-sync-context` first, `show-details` = per-file breakdown.
61
+ - If no unsynced warnings, use the standard prompt: `Apply cleanup plan? (y / n / show-details)`. `show-details` prints the per-file actions, then re-asks.
62
+ - User chooses `sync-first` → stop cleanup, print "Run `/mvt-sync-context` first, then re-run `/mvt-cleanup`." and exit.
49
63
  - Do NOT silently delete. Do NOT skip confirmation when `--dry-run` is absent.
50
64
 
51
- ### Step 6: Execute the Plan
65
+ ### Step 7: Execute the Plan
52
66
  - **What**: apply the confirmed actions.
53
67
  - **How**:
54
- 1. **Summarize action**: read the full set of files in the change-id directory; produce a `summary.md` with: title, change-id, status, key decisions (list each ADR/decision title), final outcomes, list of original files. Then move originals to `_archive/`.
55
- 2. **Archive action**: move files into `_archive/` under the same change-id directory, preserving relative paths.
68
+ 1. **Summarize action**: read the full set of files in the change-id directory; produce a `summary.md` with: title, change-id, status, key decisions (list each ADR/decision title), final outcomes, list of original files. Write `summary.md` into the change-id directory, then move the **entire** `artifacts/{id}/` directory to `artifacts/_archived/{id}/` (summary.md travels with it).
69
+ 2. **Archive action** (no summarize): move the **entire** `artifacts/{id}/` directory to `artifacts/_archived/{id}/`. No internal path restructuring needed.
56
70
  3. **Delete action**: remove only the items explicitly marked for deletion in the confirmed plan; never recurse beyond what was listed.
57
- 4. **Stale skill_history collapse**: rewrite `session.yaml`'s `skill_history` keeping the most recent 10 detailed entries plus one rolled-up entry summarizing the older ones (count + earliest/latest date).
71
+ 4. **Stale history truncation**: call `session-update.cjs --truncate-history <N>` where N is from `config.yaml > preferences.history_limits.history` (default 20).
58
72
  5. All file mutations atomic where possible (write-temp + rename, copy-then-delete for moves).
59
73
  6. If any single action fails, STOP further actions; report what completed, what failed, and leave a recoverable state (do not partially overwrite a file with truncated content).
60
74
 
61
- ### Step 7: Report Result
62
- - Print the actually-applied actions (may differ from the plan if Step 6 stopped early).
75
+ ### Step 8: Report Result
76
+ - Print the actually-applied actions (may differ from the plan if Step 7 stopped early).
63
77
  - Show new totals: files cleaned, tokens saved.
64
78
  - Recommend `/mvt-check-context` to validate the post-cleanup state if savings exceed ~5k tokens.
65
79
 
66
- ### Step 8: (session update handled by shared section)
67
- - This skill mutates `session.skill_history` directly in Step 6 (collapse). The standard `skill_history` append from the shared section still applies; the collapse runs BEFORE the append so the new entry is preserved at full detail.
80
+ ### Step 9: Session Update Parameter Selection
81
+
82
+ Based on the actual cleanup actions performed, choose the appropriate session-update parameter combination:
83
+
84
+ | Actual cleanup action | session-update parameters |
85
+ |----------------------|---------------------------|
86
+ | Closed `active_change` (all plan tasks completed) | `--close-change --truncate-history <N>` |
87
+ | Only truncated history / archived old changes (active_change still in progress) | `--truncate-history <N>` (**do NOT** pass `--close-change`) |
88
+ | `--dry-run` mode (no modifications made) | **Do NOT call** session-update script; only record history |
89
+
90
+ N is read from `config.yaml > preferences.history_limits.history` (default 20).
91
+
92
+ ### Step 10: State Update
93
+ Apply the State Update rules defined in the **State Update** section below.
68
94
 
69
95
  ## Edge Cases & Errors
70
96
 
71
97
  | Case | Handling |
72
98
  |------|----------|
73
99
  | `active_change.id` directory matches a "stale completed" rule | Skip cleanup of the active change; never archive in-progress work |
74
- | `--dry-run` set | Stop after Step 4; do not request confirmation; do not modify any file |
100
+ | `--dry-run` set | Stop after Step 5; do not request confirmation; do not modify any file |
75
101
  | Plan would archive ALL artifacts (workspace becomes empty) | Require an extra confirmation: `This will archive every artifact. Continue? (y/n)` |
76
- | User aborts at Step 5 confirmation | Report "no changes applied" |
77
- | `_archive/` already exists with content from a prior run | Preserve existing `_archive/` content; new archives are added alongside |
102
+ | User aborts at Step 6 confirmation | Report "no changes applied" |
103
+ | `artifacts/_archived/{id}/` already exists from a prior run | Preserve existing content; merge or skip with a note — do not overwrite |
78
104
  | File targeted for action no longer exists (concurrent removal) | Skip with a note; do not error out the whole run |
79
105
  | Unindexed change-id directory contains only `plan.yaml` | List as review-only; suggest user runs `/mvt-update-plan` or registers it via `/mvt-plan-dev` instead of cleaning |
80
- | `session.yaml.bak` present from a previous failed run | Overwrite during Step 6 collapse (only the most recent backup is useful) |
106
+ | `session.yaml.bak` present from a previous failed run | Overwrite during Step 7 collapse (only the most recent backup is useful) |
@@ -54,6 +54,9 @@ sections:
54
54
  - type: shared
55
55
  source: sections/output-language-constraint.md
56
56
 
57
+ - type: shared
58
+ source: sections/output-format-constraint.md
59
+
57
60
  - type: shared
58
61
  source: sections/activation-preflight.md
59
62
  params:
@@ -63,23 +66,28 @@ sections:
63
66
  level: "REQUIRED"
64
67
  message: "Project must be initialized (session.yaml exists)"
65
68
 
66
- - type: inline
67
- content: |
68
- ## Cleanup Rules
69
-
70
- | Category | Rule | Action |
71
- |----------|------|--------|
72
- | Completed changes | Change with `status: completed` older than current task | Summarize -> archive |
73
- | Orphaned artifacts | Files in `artifacts/` not referenced by any active change | List for user review |
74
- | Stale session data | Session history entries older than 5 phases ago | Summarize into single entry |
75
-
76
69
  - type: file
77
70
  source: ./business.md
78
71
 
79
72
  - type: shared
80
73
  source: sections/session-update.md
74
+ params:
75
+ current_skill: mvt-cleanup
76
+ truncate_history: true
77
+ close_change: true
81
78
 
82
79
  - type: shared
83
80
  source: sections/footer-next-steps.md
84
81
  params:
85
82
  current_skill: mvt-cleanup
83
+ conditional_suggestions:
84
+ conditions:
85
+ - condition: "cleanup freed significant tokens"
86
+ primary: mvt-check-context
87
+ primary_desc: "Validate post-cleanup context health"
88
+ - condition: "active change still in progress"
89
+ primary: mvt-resume
90
+ primary_desc: "Resume work on the active change"
91
+ - condition: "no active changes remain"
92
+ primary: mvt-analyze
93
+ primary_desc: "Start a new feature"