@levironexe/architect 0.1.0

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 (210) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CONTRIBUTING.md +55 -0
  3. package/README.md +341 -0
  4. package/dist/analyzers/ast-parser.d.ts +3 -0
  5. package/dist/analyzers/ast-parser.js +305 -0
  6. package/dist/analyzers/ast-parser.js.map +1 -0
  7. package/dist/analyzers/dependency-graph.d.ts +2 -0
  8. package/dist/analyzers/dependency-graph.js +67 -0
  9. package/dist/analyzers/dependency-graph.js.map +1 -0
  10. package/dist/analyzers/duplication.d.ts +2 -0
  11. package/dist/analyzers/duplication.js +56 -0
  12. package/dist/analyzers/duplication.js.map +1 -0
  13. package/dist/analyzers/file-walker.d.ts +3 -0
  14. package/dist/analyzers/file-walker.js +80 -0
  15. package/dist/analyzers/file-walker.js.map +1 -0
  16. package/dist/cli/context-runner.d.ts +1 -0
  17. package/dist/cli/context-runner.js +16 -0
  18. package/dist/cli/context-runner.js.map +1 -0
  19. package/dist/cli/index.d.ts +24 -0
  20. package/dist/cli/index.js +217 -0
  21. package/dist/cli/index.js.map +1 -0
  22. package/dist/cli/init-runner.d.ts +25 -0
  23. package/dist/cli/init-runner.js +152 -0
  24. package/dist/cli/init-runner.js.map +1 -0
  25. package/dist/cli/scan-runner.d.ts +8 -0
  26. package/dist/cli/scan-runner.js +133 -0
  27. package/dist/cli/scan-runner.js.map +1 -0
  28. package/dist/formatters/plan-json.d.ts +2 -0
  29. package/dist/formatters/plan-json.js +4 -0
  30. package/dist/formatters/plan-json.js.map +1 -0
  31. package/dist/formatters/plan-markdown.d.ts +2 -0
  32. package/dist/formatters/plan-markdown.js +42 -0
  33. package/dist/formatters/plan-markdown.js.map +1 -0
  34. package/dist/formatters/plan-prompt.d.ts +4 -0
  35. package/dist/formatters/plan-prompt.js +5 -0
  36. package/dist/formatters/plan-prompt.js.map +1 -0
  37. package/dist/formatters/plan-terminal.d.ts +5 -0
  38. package/dist/formatters/plan-terminal.js +62 -0
  39. package/dist/formatters/plan-terminal.js.map +1 -0
  40. package/dist/generators/blueprint-renderer.d.ts +3 -0
  41. package/dist/generators/blueprint-renderer.js +27 -0
  42. package/dist/generators/blueprint-renderer.js.map +1 -0
  43. package/dist/generators/claudeWriter.d.ts +3 -0
  44. package/dist/generators/claudeWriter.js +9 -0
  45. package/dist/generators/claudeWriter.js.map +1 -0
  46. package/dist/generators/copilotWriter.d.ts +3 -0
  47. package/dist/generators/copilotWriter.js +11 -0
  48. package/dist/generators/copilotWriter.js.map +1 -0
  49. package/dist/generators/cursorWriter.d.ts +3 -0
  50. package/dist/generators/cursorWriter.js +14 -0
  51. package/dist/generators/cursorWriter.js.map +1 -0
  52. package/dist/generators/genericWriter.d.ts +3 -0
  53. package/dist/generators/genericWriter.js +9 -0
  54. package/dist/generators/genericWriter.js.map +1 -0
  55. package/dist/generators/template-context.d.ts +18 -0
  56. package/dist/generators/template-context.js +126 -0
  57. package/dist/generators/template-context.js.map +1 -0
  58. package/dist/generators/templateRenderer.d.ts +2 -0
  59. package/dist/generators/templateRenderer.js +19 -0
  60. package/dist/generators/templateRenderer.js.map +1 -0
  61. package/dist/generators/windsurfWriter.d.ts +3 -0
  62. package/dist/generators/windsurfWriter.js +14 -0
  63. package/dist/generators/windsurfWriter.js.map +1 -0
  64. package/dist/generators/writer-types.d.ts +11 -0
  65. package/dist/generators/writer-types.js +40 -0
  66. package/dist/generators/writer-types.js.map +1 -0
  67. package/dist/llm/claude-provider.d.ts +8 -0
  68. package/dist/llm/claude-provider.js +22 -0
  69. package/dist/llm/claude-provider.js.map +1 -0
  70. package/dist/llm/concern-classifier.d.ts +15 -0
  71. package/dist/llm/concern-classifier.js +61 -0
  72. package/dist/llm/concern-classifier.js.map +1 -0
  73. package/dist/llm/config.d.ts +11 -0
  74. package/dist/llm/config.js +120 -0
  75. package/dist/llm/config.js.map +1 -0
  76. package/dist/llm/ollama-provider.d.ts +8 -0
  77. package/dist/llm/ollama-provider.js +27 -0
  78. package/dist/llm/ollama-provider.js.map +1 -0
  79. package/dist/llm/openai-provider.d.ts +8 -0
  80. package/dist/llm/openai-provider.js +19 -0
  81. package/dist/llm/openai-provider.js.map +1 -0
  82. package/dist/llm/prompt-builder.d.ts +12 -0
  83. package/dist/llm/prompt-builder.js +132 -0
  84. package/dist/llm/prompt-builder.js.map +1 -0
  85. package/dist/llm/provider.d.ts +17 -0
  86. package/dist/llm/provider.js +2 -0
  87. package/dist/llm/provider.js.map +1 -0
  88. package/dist/llm/response-parser.d.ts +6 -0
  89. package/dist/llm/response-parser.js +128 -0
  90. package/dist/llm/response-parser.js.map +1 -0
  91. package/dist/planner/plan-generator.d.ts +7 -0
  92. package/dist/planner/plan-generator.js +275 -0
  93. package/dist/planner/plan-generator.js.map +1 -0
  94. package/dist/planner/plan-prompt-builder.d.ts +9 -0
  95. package/dist/planner/plan-prompt-builder.js +92 -0
  96. package/dist/planner/plan-prompt-builder.js.map +1 -0
  97. package/dist/planner/plan-response-parser.d.ts +7 -0
  98. package/dist/planner/plan-response-parser.js +21 -0
  99. package/dist/planner/plan-response-parser.js.map +1 -0
  100. package/dist/planner/plan-validator.d.ts +3 -0
  101. package/dist/planner/plan-validator.js +49 -0
  102. package/dist/planner/plan-validator.js.map +1 -0
  103. package/dist/reporters/scan-json.d.ts +13 -0
  104. package/dist/reporters/scan-json.js +26 -0
  105. package/dist/reporters/scan-json.js.map +1 -0
  106. package/dist/reporters/terminal.d.ts +6 -0
  107. package/dist/reporters/terminal.js +224 -0
  108. package/dist/reporters/terminal.js.map +1 -0
  109. package/dist/scoring/consistency-score.d.ts +3 -0
  110. package/dist/scoring/consistency-score.js +23 -0
  111. package/dist/scoring/consistency-score.js.map +1 -0
  112. package/dist/scoring/duplication-score.d.ts +3 -0
  113. package/dist/scoring/duplication-score.js +16 -0
  114. package/dist/scoring/duplication-score.js.map +1 -0
  115. package/dist/scoring/health-score.d.ts +4 -0
  116. package/dist/scoring/health-score.js +20 -0
  117. package/dist/scoring/health-score.js.map +1 -0
  118. package/dist/scoring/issue-builder.d.ts +4 -0
  119. package/dist/scoring/issue-builder.js +62 -0
  120. package/dist/scoring/issue-builder.js.map +1 -0
  121. package/dist/scoring/modularity-score.d.ts +3 -0
  122. package/dist/scoring/modularity-score.js +56 -0
  123. package/dist/scoring/modularity-score.js.map +1 -0
  124. package/dist/scoring/pattern-analysis.d.ts +3 -0
  125. package/dist/scoring/pattern-analysis.js +74 -0
  126. package/dist/scoring/pattern-analysis.js.map +1 -0
  127. package/dist/scoring/separation-score.d.ts +3 -0
  128. package/dist/scoring/separation-score.js +35 -0
  129. package/dist/scoring/separation-score.js.map +1 -0
  130. package/dist/skills/detector.d.ts +4 -0
  131. package/dist/skills/detector.js +104 -0
  132. package/dist/skills/detector.js.map +1 -0
  133. package/dist/skills/lister.d.ts +9 -0
  134. package/dist/skills/lister.js +35 -0
  135. package/dist/skills/lister.js.map +1 -0
  136. package/dist/skills/loader.d.ts +6 -0
  137. package/dist/skills/loader.js +76 -0
  138. package/dist/skills/loader.js.map +1 -0
  139. package/dist/skills/structure-check.d.ts +2 -0
  140. package/dist/skills/structure-check.js +37 -0
  141. package/dist/skills/structure-check.js.map +1 -0
  142. package/dist/skills/validator.d.ts +6 -0
  143. package/dist/skills/validator.js +229 -0
  144. package/dist/skills/validator.js.map +1 -0
  145. package/dist/types/analysis.d.ts +130 -0
  146. package/dist/types/analysis.js +41 -0
  147. package/dist/types/analysis.js.map +1 -0
  148. package/dist/types/concern.d.ts +48 -0
  149. package/dist/types/concern.js +16 -0
  150. package/dist/types/concern.js.map +1 -0
  151. package/dist/types/generation.d.ts +32 -0
  152. package/dist/types/generation.js +2 -0
  153. package/dist/types/generation.js.map +1 -0
  154. package/dist/types/issue.d.ts +12 -0
  155. package/dist/types/issue.js +2 -0
  156. package/dist/types/issue.js.map +1 -0
  157. package/dist/types/pattern.d.ts +15 -0
  158. package/dist/types/pattern.js +2 -0
  159. package/dist/types/pattern.js.map +1 -0
  160. package/dist/types/plan.d.ts +56 -0
  161. package/dist/types/plan.js +2 -0
  162. package/dist/types/plan.js.map +1 -0
  163. package/dist/types/scan-output.d.ts +84 -0
  164. package/dist/types/scan-output.js +2 -0
  165. package/dist/types/scan-output.js.map +1 -0
  166. package/dist/types/scoring.d.ts +15 -0
  167. package/dist/types/scoring.js +2 -0
  168. package/dist/types/scoring.js.map +1 -0
  169. package/dist/types/skill.d.ts +97 -0
  170. package/dist/types/skill.js +2 -0
  171. package/dist/types/skill.js.map +1 -0
  172. package/dist/utils/agent-detector.d.ts +2 -0
  173. package/dist/utils/agent-detector.js +22 -0
  174. package/dist/utils/agent-detector.js.map +1 -0
  175. package/dist/utils/interactive.d.ts +6 -0
  176. package/dist/utils/interactive.js +15 -0
  177. package/dist/utils/interactive.js.map +1 -0
  178. package/dist/utils/path.d.ts +5 -0
  179. package/dist/utils/path.js +31 -0
  180. package/dist/utils/path.js.map +1 -0
  181. package/dist/utils/progress.d.ts +17 -0
  182. package/dist/utils/progress.js +48 -0
  183. package/dist/utils/progress.js.map +1 -0
  184. package/dist/utils/thresholds.d.ts +6 -0
  185. package/dist/utils/thresholds.js +48 -0
  186. package/dist/utils/thresholds.js.map +1 -0
  187. package/package.json +63 -0
  188. package/skills/meta/general-js.skill.yaml +131 -0
  189. package/skills/patterns/clerk-auth.skill.yaml +349 -0
  190. package/skills/patterns/docker-deploy.skill.yaml +214 -0
  191. package/skills/patterns/drizzle.skill.yaml +277 -0
  192. package/skills/patterns/mongoose.skill.yaml +290 -0
  193. package/skills/patterns/nextauth.skill.yaml +308 -0
  194. package/skills/patterns/playwright-e2e.skill.yaml +265 -0
  195. package/skills/patterns/prisma.skill.yaml +255 -0
  196. package/skills/patterns/s3-storage.skill.yaml +235 -0
  197. package/skills/patterns/selenium-e2e.skill.yaml +276 -0
  198. package/skills/patterns/supabase-auth.skill.yaml +298 -0
  199. package/skills/patterns/supabase.skill.yaml +304 -0
  200. package/skills/patterns/vercel-deploy.skill.yaml +219 -0
  201. package/skills/patterns/vitest-testing.skill.yaml +262 -0
  202. package/skills/stacks/express-api.skill.yaml +155 -0
  203. package/skills/stacks/fastify-api.skill.yaml +119 -0
  204. package/skills/stacks/hono-api.skill.yaml +130 -0
  205. package/skills/stacks/nestjs.skill.yaml +135 -0
  206. package/skills/stacks/nextjs-app-router.skill.yaml +176 -0
  207. package/skills/stacks/react-spa.skill.yaml +153 -0
  208. package/skills/stacks/vue-nuxt.skill.yaml +115 -0
  209. package/templates/architect-plan.md +139 -0
  210. package/templates/architect-refactor.md +119 -0
@@ -0,0 +1,139 @@
1
+ ---
2
+ name: architect-plan
3
+ description: >
4
+ Analyzes a codebase's architecture and generates a phased refactoring roadmap saved to
5
+ .architect/plan.md. Use this skill whenever the user wants to plan a refactor, understand
6
+ their codebase structure, clean up architectural problems, generate a migration plan, or
7
+ prepare for a major restructuring. Trigger even if the user just says "analyze my architecture",
8
+ "how should I organize this project", or "make a plan to clean this up".
9
+ metadata:
10
+ version: "1.0"
11
+ author-email: "nguyenphuoc4805@gmail.com"
12
+ last-updated: "2026-05-11"
13
+ ---
14
+
15
+ # architect-plan
16
+
17
+ You are helping a developer understand and improve the architecture of their codebase. Your job
18
+ is to produce a concrete, ordered refactoring roadmap — not advice, not observations, but a
19
+ specific plan saved to `.architect/plan.md` that the developer (or `/architect-refactor`) can
20
+ execute step by step.
21
+
22
+ ## Context already loaded for you
23
+
24
+ The following static analysis and blueprint data has been pre-computed by `architect init`. Read
25
+ it carefully before touching any source files — it tells you where the biggest problems are and
26
+ what the target architecture looks like.
27
+
28
+ **Stack**: {{skill.name}}
29
+
30
+ **Largest files by line count** (likely candidates for extraction):
31
+ {{analysis.largestFiles}}
32
+
33
+ **Hub files** (imported by many others — high-impact, higher risk to touch):
34
+ {{analysis.hubFiles}}
35
+
36
+ **Code duplication**: {{analysis.duplicationPercent}} of lines are duplicated
37
+
38
+ **Missing required directories** (the blueprint expects these but they don't exist yet):
39
+ {{analysis.missingDirs}}
40
+
41
+ **Target directory structure** (what the codebase should look like):
42
+ {{skill.structure.required}}
43
+
44
+ **How data should flow through this architecture**:
45
+ {{skill.separation.data_flow}}
46
+
47
+ If any of the above blocks are empty, proceed without them — the live codebase is your primary source.
48
+
49
+ ## Step-by-step instructions
50
+
51
+ ### 1. Read the codebase
52
+
53
+ Open and read:
54
+ - `package.json` (or equivalent manifest) to confirm the tech stack and dependencies
55
+ - The 3 largest source files from the list above (or the largest files you can find if the list
56
+ is empty) — understand what they do and what concerns they mix
57
+
58
+ ### 2. Confirm the detected stack
59
+
60
+ Based on what you read, confirm or correct the detected stack (`{{skill.name}}`). If the stack
61
+ looks wrong, call:
62
+ ```
63
+ architect context --techstack <correct-id>
64
+ ```
65
+ Otherwise call:
66
+ ```
67
+ architect context --techstack {{skill.name}}
68
+ ```
69
+
70
+ If `architect` is not found globally, fall back to:
71
+ ```
72
+ npx @levironexe/architect context --techstack {{skill.name}}
73
+ ```
74
+
75
+ Read the output — it gives you the full architectural blueprint: required directories, separation
76
+ rules, anti-patterns to avoid.
77
+
78
+ ### 3. Compare current vs target structure
79
+
80
+ Walk through the blueprint's required directories. For each one, note:
81
+ - ✓ Exists and looks right
82
+ - ⚠ Exists but contains the wrong concerns
83
+ - ✗ Missing entirely
84
+
85
+ Cross-reference with the "Missing required directories" list above.
86
+
87
+ ### 4. Identify the problems
88
+
89
+ Based on what you've read, identify the concrete structural problems:
90
+ - Which files are doing too many things (mixed concerns)?
91
+ - What code lives in the wrong place relative to the blueprint?
92
+ - Where is duplication concentrated?
93
+ - Which hub files are risky to touch?
94
+
95
+ ### 5. Write `.architect/plan.md`
96
+
97
+ Create or overwrite `.architect/plan.md` with a phased refactoring roadmap. Use this exact format:
98
+
99
+ ```markdown
100
+ # Refactoring Plan: <project name>
101
+ Generated: <today's date>
102
+ Stack: <detected stack id>
103
+
104
+ ## Phase 1: <name — most impactful, lowest risk first>
105
+ **Goal**: <what structural problem this phase solves>
106
+ **Risk**: low | medium | high
107
+
108
+ ### Steps
109
+ - [ ] Step 1.1: <verb> `<source>` → `<target>`
110
+ - What: <exactly what code is being moved or created>
111
+ - Why: <which separation rule or blueprint requirement this satisfies>
112
+ - Imports to update: <list files that import from source, or "none">
113
+
114
+ - [ ] Step 1.2: ...
115
+
116
+ ## Phase 2: ...
117
+ ```
118
+
119
+ **Ordering rules**:
120
+ - Put the highest-impact changes first (files that are mixed the most, missing dirs that block
121
+ other changes)
122
+ - Within the same impact level, put lower-risk changes first (creating new files before moving
123
+ existing ones; moving to new dirs before changing existing files)
124
+ - Do not put hub files in Phase 1 unless unavoidable — moving a hub breaks many things at once
125
+ - Each phase should be independently executable: completing it leaves the project in a valid,
126
+ runnable state
127
+
128
+ **Minimum**: at least 1 phase with at least 1 step. If the project already follows the
129
+ blueprint well, write a single phase with steps for minor cleanup and note "Structure largely
130
+ follows the {{skill.name}} blueprint."
131
+
132
+ ### 6. Report to the developer
133
+
134
+ After writing the plan, summarize in the chat:
135
+ - How many phases and total steps
136
+ - The single biggest structural problem you found
137
+ - Which phase to start with and why
138
+
139
+ Do not ask for confirmation before writing the plan — just do it and report when done.
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: architect-refactor
3
+ description: >
4
+ Executes a refactoring plan phase by phase, moving files, updating imports, and pausing
5
+ between phases for developer confirmation. Use this skill whenever the user wants to execute
6
+ a refactor, apply an architect plan, move files per their architecture blueprint, or says
7
+ "do the refactor", "execute phase 1", "start refactoring". Trigger even if the user just
8
+ says "let's do it" after a planning session, or "go ahead with the plan".
9
+ metadata:
10
+ version: "1.0"
11
+ author-email: "nguyenphuoc4805@gmail.com"
12
+ last-updated: "2026-05-11"
13
+ ---
14
+
15
+ # architect-refactor
16
+
17
+ You are executing a developer's refactoring plan one phase at a time. The goal is safe,
18
+ incremental restructuring — the developer controls the pace, you do the work precisely and
19
+ explain everything before you touch a file.
20
+
21
+ ## Before you do anything: check for the plan
22
+
23
+ Look for `.architect/plan.md` in the project root.
24
+
25
+ If it does not exist, stop immediately and output:
26
+
27
+ ```
28
+ ❌ No refactoring plan found.
29
+
30
+ Run `/architect-plan` first to generate a plan, then invoke `/architect-refactor` to execute it.
31
+ ```
32
+
33
+ Do not modify any files if the plan is missing.
34
+
35
+ ## Architectural constraints you must follow
36
+
37
+ The following rules come from the **{{skill.name}}** architecture blueprint. Treat them as
38
+ hard constraints — they are not suggestions. Every file move you make must end up satisfying
39
+ these rules.
40
+
41
+ {{skill.separation.rules}}
42
+
43
+ If the above block is empty, use your best judgment based on the stack and the plan itself.
44
+
45
+ ## Anti-patterns to avoid
46
+
47
+ After each step, verify you have not introduced any of the following:
48
+
49
+ {{skill.anti_patterns}}
50
+
51
+ If the above block is empty, at minimum: do not put business logic in route handlers, do not
52
+ hardcode secrets, do not create circular imports.
53
+
54
+ ## How to execute the plan
55
+
56
+ ### 1. Read the plan
57
+
58
+ Read `.architect/plan.md` in full. Identify which phase comes next — look for the first phase
59
+ that still has unchecked steps (`- [ ]`). If all steps in a phase are already checked (`- [x]`),
60
+ skip to the next phase. This lets you resume after a previous partial run.
61
+
62
+ ### 2. Execute the current phase, step by step
63
+
64
+ For each unchecked step in the current phase:
65
+
66
+ **Before touching the file**, state in the chat:
67
+ > "Step N.M: Moving `<source>` → `<target>`. Reason: <why from the plan>. Updating imports in: <files>."
68
+
69
+ Then:
70
+ 1. Create the target directory if it doesn't exist
71
+ 2. Move or create the file as specified
72
+ 3. Update all imports listed in the step's "Imports to update" field
73
+ 4. Verify the project still makes sense (no obviously broken imports left behind)
74
+ 5. Mark the step as done in `.architect/plan.md` by changing `- [ ]` to `- [x]`
75
+
76
+ If a step would create a circular dependency, skip it, explain why in the chat, and continue
77
+ with the next step.
78
+
79
+ ### 3. After completing all steps in the phase, pause
80
+
81
+ Output exactly this (replacing the placeholders):
82
+
83
+ ```
84
+ ✅ Phase N complete: <phase name>
85
+
86
+ Steps executed:
87
+ - [x] Step N.1: <description>
88
+ - [x] Step N.2: <description>
89
+ ...
90
+
91
+ Proceed to Phase N+1 (<next phase name>)? **yes / no**
92
+ ```
93
+
94
+ Then stop. Wait for the developer to respond before touching Phase N+1.
95
+
96
+ If there is no next phase, output:
97
+
98
+ ```
99
+ ✅ All phases complete.
100
+
101
+ The refactoring is done. Run `architect scan .` to measure the improvement in your health score.
102
+ ```
103
+
104
+ ### 4. On developer confirmation
105
+
106
+ If the developer says yes (or "continue", "proceed", "go ahead"), execute the next phase
107
+ following the same step-by-step process.
108
+
109
+ If the developer says no (or "stop", "wait", "pause"), stop and confirm:
110
+ > "Paused after Phase N. The plan in `.architect/plan.md` is up to date — all completed steps
111
+ > are checked. Run `/architect-refactor` again when you're ready to continue."
112
+
113
+ ## Important: what NOT to do
114
+
115
+ - Do not skip the pre-flight plan check — refactoring without a plan risks breaking the codebase
116
+ - Do not execute more than one phase per invocation unless the developer explicitly asks for all phases
117
+ - Do not modify files outside the scope of the current step
118
+ - Do not change business logic while moving files — the goal is structural change only
119
+ - Do not proceed to Phase N+1 automatically — always wait for the developer's yes/no