@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
package/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+
3
+ All notable changes to Architect CLI are recorded here.
4
+
5
+ ## Unreleased
6
+
7
+ ### Added
8
+
9
+ - Interactive scan target prompting for human terminal sessions.
10
+ - Configurable scan thresholds for LOC and complexity findings.
11
+ - Explicit scan provider selection, including metrics-only mode.
12
+ - Human-only progress feedback for long-running analysis.
13
+ - Public documentation, contribution guide, issue templates, and CI workflow.
14
+
15
+ ### Changed
16
+
17
+ - Expected scan errors now include clearer next actions.
18
+ - README now documents installation, command reference, scoring, providers, and example output.
19
+
20
+ ### Fixed
21
+
22
+ - Machine-readable scan output remains free of prompts, spinners, and ANSI styling.
23
+
24
+ ### Security
25
+
26
+ - Provider guidance avoids printing secret values and recommends environment-based configuration.
27
+
28
+ ## 0.1.0
29
+
30
+ ### Added
31
+
32
+ - Initial CLI scanning, dependency, duplication, skill detection, scoring, JSON output, and refactoring plan generation.
@@ -0,0 +1,55 @@
1
+ # Contributing
2
+
3
+ Thanks for helping make Architect sharper.
4
+
5
+ ## Local Setup
6
+
7
+ ```bash
8
+ cd architect-cli
9
+ npm install
10
+ npm run build
11
+ ```
12
+
13
+ ## Validation Commands
14
+
15
+ Run these before opening a pull request:
16
+
17
+ ```bash
18
+ npm run build
19
+ npm run lint
20
+ npm test
21
+ npm audit --audit-level=high
22
+ ```
23
+
24
+ ## Coding Expectations
25
+
26
+ - Keep TypeScript strict and avoid `any` unless the reason is documented inline.
27
+ - Keep source files under 300 LOC and functions under 50 LOC.
28
+ - Keep CLI behavior read-only; do not modify scanned user projects.
29
+ - Write primary command output to stdout and warnings/errors to stderr.
30
+ - Preserve `--json` as parseable machine-readable output with no spinner text or ANSI styling.
31
+ - Add tests before implementing new scan, scoring, planning, or reporting behavior.
32
+
33
+ ## Tests
34
+
35
+ Use focused tests while developing:
36
+
37
+ ```bash
38
+ npm test -- tests/unit/cli/scan-ux.test.ts
39
+ npm test -- tests/unit/utils/thresholds.test.ts
40
+ ```
41
+
42
+ Then run the full suite before submitting.
43
+
44
+ ## Pull Requests
45
+
46
+ Pull requests should include:
47
+
48
+ - A clear description of the behavior change.
49
+ - Tests or documentation updates for user-facing behavior.
50
+ - Notes for any constitution limit exceptions.
51
+ - Confirmation that build, lint, tests, and audit passed.
52
+
53
+ ## Issues
54
+
55
+ Use the bug report or feature request templates. Remove secrets from command output before pasting logs.
package/README.md ADDED
@@ -0,0 +1,341 @@
1
+ <div align="center">
2
+ <h1>🏛️ Architect</h1>
3
+ <h3><em>Fix vibe-coded projects without breaking them.</em></h3>
4
+ </div>
5
+
6
+ <p align="center">
7
+ <strong>A CLI tool that scans your JavaScript or TypeScript codebase, detects its architecture pattern, and installs agent skills that guide your coding agent through a safe, phased refactoring.</strong>
8
+ </p>
9
+
10
+ <p align="center">
11
+ <a href="https://github.com/Levironexe/architect-cli/releases/latest"><img src="https://img.shields.io/github/v/release/Levironexe/architect-cli" alt="Latest Release"/></a>
12
+ <a href="https://www.npmjs.com/package/@levironexe/architect"><img src="https://img.shields.io/npm/v/@levironexe/architect" alt="npm version"/></a>
13
+ <a href="https://github.com/Levironexe/architect-cli/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Levironexe/architect-cli" alt="License"/></a>
14
+ <img src="https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen" alt="Node.js 20+"/>
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## Table of Contents
20
+
21
+ - [🤔 What problem does it solve?](#-what-problem-does-it-solve)
22
+ - [⚡ Quick Start](#-quick-start)
23
+ - [🔄 How It Works](#-how-it-works)
24
+ - [🤖 Supported Agents](#-supported-agents)
25
+ - [🗂️ Built-in Architecture Skills](#️-built-in-architecture-skills)
26
+ - [🔧 Command Reference](#-command-reference)
27
+ - [📋 The Refactoring Skills](#-the-refactoring-skills)
28
+ - [🛠️ How to Contribute a Skill](#️-how-to-contribute-a-skill)
29
+ - [🔧 Prerequisites](#-prerequisites)
30
+ - [📄 License](#-license)
31
+
32
+ ---
33
+
34
+ ## 🤔 What problem does it solve?
35
+
36
+ Vibe coding is fast. Cleanup is hard.
37
+
38
+ When you ship quickly with an AI agent — or inherit a fast-moving codebase — you often end up with:
39
+
40
+ - **God files** — one 800-line `index.ts` doing routing, DB queries, and business logic at once
41
+ - **Wrong structure** — everything in the root, no `services/`, no `controllers/`, no separation
42
+ - **Risky refactors** — you know something needs to move, but you don't know what it will break
43
+
44
+ **Architect** solves this in three steps:
45
+
46
+ 1. **Scan** — static analysis tells you exactly what's wrong (file sizes, complexity, duplication, dependency risks)
47
+ 2. **Plan** — your coding agent reads the analysis, loads the architecture blueprint for your stack, and writes a safe, phased refactoring plan
48
+ 3. **Execute** — the agent executes the plan one phase at a time, explaining every move and pausing for your approval before proceeding
49
+
50
+ No LLM API keys. No cloud. Architect is a local CLI that hands off to the agent already open in your editor.
51
+
52
+ ---
53
+
54
+ ## ⚡ Quick Start
55
+
56
+ ### 1. Install the CLI
57
+
58
+ ```bash
59
+ npm install -g @levironexe/architect
60
+ ```
61
+
62
+ ### 2. Initialize your project
63
+
64
+ ```bash
65
+ cd your-project
66
+ architect init .
67
+ ```
68
+
69
+ This scans your project, detects your stack (Express, Next.js, React SPA, etc.), and installs two skills into your coding agent's config directory.
70
+
71
+ ### 3. Open your agent and plan the refactor
72
+
73
+ In Claude Code (or any supported agent), run:
74
+
75
+ ```
76
+ /architect-plan
77
+ ```
78
+
79
+ The agent reads the analysis, fetches the architecture blueprint for your stack, and writes a phased refactoring roadmap to `.architect/plan.md`.
80
+
81
+ ### 4. Execute the plan
82
+
83
+ ```
84
+ /architect-refactor
85
+ ```
86
+
87
+ The agent executes Phase 1, announces every file move before touching anything, updates all imports, and pauses:
88
+
89
+ ```
90
+ ✅ Phase 1 complete: Extract service layer
91
+
92
+ Proceed to Phase 2 (Add controllers)? yes / no
93
+ ```
94
+
95
+ You control the pace. The agent does the work.
96
+
97
+ ---
98
+
99
+ ## 🔄 How It Works
100
+
101
+ ```
102
+ architect init .
103
+
104
+
105
+ Scan project ← file sizes, complexity, imports, duplication
106
+
107
+
108
+ Detect stack ← express-api / next-app / react-spa / general-js
109
+
110
+
111
+ Install agent skills ← /architect-plan and /architect-refactor
112
+
113
+
114
+ /architect-plan ← agent loads analysis + blueprint → writes .architect/plan.md
115
+
116
+
117
+ /architect-refactor ← agent executes plan phase by phase, pauses between phases
118
+ ```
119
+
120
+ ### What `architect init` does under the hood
121
+
122
+ 1. Walks your source tree (skipping `node_modules/`, `.git/`, `dist/`)
123
+ 2. Parses every `.js`, `.jsx`, `.ts`, `.tsx` file with Babel
124
+ 3. Computes: lines of code, cyclomatic complexity, import/export graph, duplication %, hub files
125
+ 4. Detects your stack from `package.json` dependencies and source patterns
126
+ 5. Embeds the analysis results into two SKILL.md files and writes them into your agent's config directory (e.g., `.claude/skills/architect-plan/SKILL.md`)
127
+
128
+ When your agent runs `/architect-plan`, it reads those pre-computed numbers — so it knows where the problems are before it opens a single file.
129
+
130
+ ---
131
+
132
+ ## 🤖 Supported Agents
133
+
134
+ | Agent | Status | Skills installed to |
135
+ |-------|--------|---------------------|
136
+ | **Claude Code** | ✅ Supported | `.claude/skills/` |
137
+ | **GitHub Copilot** | ✅ Supported | `.github/copilot-instructions.md` |
138
+ | **Cursor** | ✅ Supported | `.cursor/rules/` |
139
+ | **Windsurf** | ✅ Supported | `.windsurf/rules/` |
140
+ | **Generic** | ✅ Supported | `.architect/skills/` (plain Markdown) |
141
+
142
+ Architect auto-detects which agent is installed in your project. Override with `--integration <agent>`.
143
+
144
+ ---
145
+
146
+ ## 🗂️ Built-in Architecture Skills
147
+
148
+ Each skill defines what an ideal project structure looks like for a given stack — required directories, separation rules, and anti-patterns. Architect uses the skill to generate your plan and constrain your refactor.
149
+
150
+ | Skill ID | Stack | Detects via |
151
+ |----------|-------|-------------|
152
+ | `express-api` | Express.js REST API | `express` in `package.json` |
153
+ | `next-app` | Next.js App Router | `next` in `package.json` |
154
+ | `react-spa` | React Single Page App | `react` + no `next` |
155
+ | `general-js` | General JS/TS | Fallback for any JS/TS project |
156
+
157
+ Check active skills in your current directory:
158
+
159
+ ```bash
160
+ architect skill list
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 🔧 Command Reference
166
+
167
+ ### `architect init <directory>`
168
+
169
+ Scans the project, detects the stack, and installs agent skill files.
170
+
171
+ ```bash
172
+ architect init . # auto-detect everything
173
+ architect init . --skill express-api # override stack detection
174
+ architect init . --integration claude # override agent detection
175
+ architect init . --update # overwrite existing skill files
176
+ ```
177
+
178
+ **Edge cases handled:**
179
+ - **Empty directory** → `No source files found. Point architect at a JS/TS project root.`
180
+ - **No `package.json`** → warns and continues with file-pattern detection
181
+ - **Unrecognized stack** → `Could not detect stack. Override with --skill <id>.`
182
+ - **Large project (>500 files)** → shows progress spinner during scan
183
+
184
+ ---
185
+
186
+ ### `architect scan [directory]`
187
+
188
+ Analyzes your project and reports structural health metrics — without writing any files.
189
+
190
+ ```bash
191
+ architect scan .
192
+ architect scan . --json # machine-readable JSON
193
+ architect scan . --verbose # detailed diagnostics per file
194
+ architect scan . --no-color # for CI environments
195
+ architect scan . --threshold "loc=400,complexity=20" # custom thresholds
196
+ ```
197
+
198
+ **Output includes:**
199
+ - Total files, lines of code, average complexity
200
+ - Files over the LOC threshold (default: 300 lines)
201
+ - Functions over the complexity threshold (default: 15)
202
+ - Hub files (imported by many — risky to touch)
203
+ - Code duplication percentage
204
+
205
+ ---
206
+
207
+ ### `architect context --techstack <id>`
208
+
209
+ Fetches and prints the full architecture blueprint for a stack. Called automatically by `/architect-plan`.
210
+
211
+ ```bash
212
+ architect context --techstack express-api
213
+ architect context --techstack next-app react-spa # multiple stacks
214
+ ```
215
+
216
+ ---
217
+
218
+ ### `architect skill list`
219
+
220
+ Lists all available skills. Skills installed in the current directory's agent config are marked `[active]`.
221
+
222
+ ```bash
223
+ architect skill list
224
+ ```
225
+
226
+ Example output:
227
+
228
+ ```
229
+ Available skills:
230
+
231
+ express-api [active] Express.js REST API
232
+ next-app Next.js App Router
233
+ react-spa React Single Page Application
234
+ general-js General JavaScript/TypeScript
235
+ ```
236
+
237
+ ---
238
+
239
+ ## 📋 The Refactoring Skills
240
+
241
+ After `architect init .`, your agent has two new skills:
242
+
243
+ ### `/architect-plan`
244
+
245
+ The agent will:
246
+
247
+ 1. Read `package.json` and the 3 largest source files to understand current structure
248
+ 2. Call `npx @levironexe/architect context --techstack <detected>` to load the full blueprint
249
+ 3. Compare current vs target directory structure
250
+ 4. Write `.architect/plan.md` — a phased roadmap where each step specifies:
251
+ - **What**: which file moves where
252
+ - **Why**: which separation rule this satisfies
253
+ - **Imports to update**: every file that needs to be patched after the move
254
+
255
+ **Pass criteria** (what a good plan looks like):
256
+ - ≥ 2 phases for a messy project, ≤ 1 phase for a clean one
257
+ - Phase 1 targets the biggest structural problem first (lowest risk, highest impact)
258
+ - Every step has `What`, `Why`, and `Imports to update` fields
259
+ - Agent asks zero clarifying questions — it just makes the plan
260
+
261
+ ---
262
+
263
+ ### `/architect-refactor`
264
+
265
+ The agent will:
266
+
267
+ 1. Check for `.architect/plan.md` — if missing, prints `❌ No refactoring plan found. Run /architect-plan first.` and stops
268
+ 2. Find the first phase with unchecked steps (supports resuming mid-plan)
269
+ 3. For each step, announce intent before touching any file: `"Step 1.2: Moving src/server.ts → src/app.ts. Reason: …"`
270
+ 4. Execute the move, update all listed imports, mark the step `[x]` in the plan
271
+ 5. After the last step in the phase, output the phase-gate message and **stop**:
272
+
273
+ ```
274
+ ✅ Phase 1 complete: Extract service layer
275
+
276
+ Proceed to Phase 2 (Add controllers)? yes / no
277
+ ```
278
+
279
+ **Hard constraints the agent follows:**
280
+ - Never touches business logic — structural moves only
281
+ - Never proceeds to the next phase automatically
282
+ - Never modifies files outside the current step's scope
283
+
284
+ ---
285
+
286
+ ## 🛠️ How to Contribute a Skill
287
+
288
+ Skills are YAML files (with a Markdown body for the blueprint) that live in `skills/stacks/` or `skills/meta/`.
289
+
290
+ **To add a new skill:**
291
+
292
+ 1. Create `skills/stacks/<your-skill-id>.skill.yaml` following the schema:
293
+
294
+ ```yaml
295
+ schema_version: "2.0.0"
296
+ id: your-skill-id
297
+ name: "Human Readable Name"
298
+ version: "1.0.0"
299
+ description: "What this architecture pattern looks like."
300
+ category: stack # stack | meta
301
+ language: javascript
302
+ frameworks:
303
+ - your-framework
304
+ detection:
305
+ dependencies:
306
+ any:
307
+ - framework-package-name
308
+ structure:
309
+ required_dirs:
310
+ - path: src/your-dir
311
+ purpose: "What belongs here."
312
+ separation:
313
+ rules:
314
+ - rule_text: "Business logic MUST NOT live in route handlers."
315
+ example: "// good: call service from route\nrouter.get('/', (req, res) => userService.getAll())"
316
+ anti_patterns:
317
+ - name: God File
318
+ description: "Everything in one file."
319
+ bad_example: "// 600-line server.js with routes + DB + auth"
320
+ good_example: "// separate files per concern"
321
+ ```
322
+
323
+ 2. Add a detection fixture under `tests/fixtures/<your-skill-id>/` — a minimal project that should match your skill
324
+ 3. Run `npm test` — your skill must be detected and not conflict with existing ones
325
+ 4. Open a pull request with the skill file and fixture
326
+
327
+ See existing skills in `skills/stacks/` for complete examples.
328
+
329
+ ---
330
+
331
+ ## 🔧 Prerequisites
332
+
333
+ - **Node.js 20+** (LTS recommended)
334
+ - A supported AI coding agent (Claude Code, Cursor, GitHub Copilot, or Windsurf)
335
+ - A JavaScript or TypeScript project to analyze
336
+
337
+ ---
338
+
339
+ ## 📄 License
340
+
341
+ MIT — see [LICENSE](./LICENSE) for full terms.
@@ -0,0 +1,3 @@
1
+ import { type FileAnalysis } from '../types/analysis.js';
2
+ import type { ScanThresholds } from '../types/scan-output.js';
3
+ export declare function analyzeFile(filePath: string, rootDirectory: string, thresholds?: ScanThresholds): Promise<FileAnalysis>;