@dinyangetoh/codeplug-cli 0.1.3 → 0.1.5

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 (163) hide show
  1. package/README.md +149 -187
  2. package/dist/cli/commands/convention.d.ts +1 -1
  3. package/dist/cli/commands/convention.d.ts.map +1 -1
  4. package/dist/cli/commands/convention.js +174 -31
  5. package/dist/cli/commands/convention.js.map +1 -1
  6. package/dist/cli/commands/docs.d.ts.map +1 -1
  7. package/dist/cli/commands/docs.js +9 -2
  8. package/dist/cli/commands/docs.js.map +1 -1
  9. package/dist/cli/commands/export.d.ts.map +1 -1
  10. package/dist/cli/commands/export.js +6 -1
  11. package/dist/cli/commands/export.js.map +1 -1
  12. package/dist/cli/commands/start.d.ts +2 -0
  13. package/dist/cli/commands/start.d.ts.map +1 -0
  14. package/dist/cli/commands/start.js +172 -0
  15. package/dist/cli/commands/start.js.map +1 -0
  16. package/dist/cli/index.js +9 -2
  17. package/dist/cli/index.js.map +1 -1
  18. package/dist/config/ConfigManager.d.ts +18 -0
  19. package/dist/config/ConfigManager.d.ts.map +1 -1
  20. package/dist/config/ConfigManager.js +55 -2
  21. package/dist/config/ConfigManager.js.map +1 -1
  22. package/dist/config/ConventionSchema.d.ts +59 -0
  23. package/dist/config/ConventionSchema.d.ts.map +1 -1
  24. package/dist/config/ConventionSchema.js +11 -0
  25. package/dist/config/ConventionSchema.js.map +1 -1
  26. package/dist/config/defaults.d.ts +60 -2
  27. package/dist/config/defaults.d.ts.map +1 -1
  28. package/dist/config/defaults.js +136 -20
  29. package/dist/config/defaults.js.map +1 -1
  30. package/dist/config/types.d.ts +71 -0
  31. package/dist/config/types.d.ts.map +1 -1
  32. package/dist/core/analyzer/AstAnalyzer.d.ts +11 -2
  33. package/dist/core/analyzer/AstAnalyzer.d.ts.map +1 -1
  34. package/dist/core/analyzer/AstAnalyzer.js +21 -5
  35. package/dist/core/analyzer/AstAnalyzer.js.map +1 -1
  36. package/dist/core/analyzer/ConventionDetector.d.ts +12 -1
  37. package/dist/core/analyzer/ConventionDetector.d.ts.map +1 -1
  38. package/dist/core/analyzer/ConventionDetector.js +120 -20
  39. package/dist/core/analyzer/ConventionDetector.js.map +1 -1
  40. package/dist/core/analyzer/ConventionMlResolver.d.ts +4 -0
  41. package/dist/core/analyzer/ConventionMlResolver.d.ts.map +1 -0
  42. package/dist/core/analyzer/ConventionMlResolver.js +17 -0
  43. package/dist/core/analyzer/ConventionMlResolver.js.map +1 -0
  44. package/dist/core/analyzer/PatternAggregator.d.ts +11 -2
  45. package/dist/core/analyzer/PatternAggregator.d.ts.map +1 -1
  46. package/dist/core/analyzer/PatternAggregator.js +87 -15
  47. package/dist/core/analyzer/PatternAggregator.js.map +1 -1
  48. package/dist/core/analyzer/SemanticCoherencePhase.d.ts +10 -0
  49. package/dist/core/analyzer/SemanticCoherencePhase.d.ts.map +1 -0
  50. package/dist/core/analyzer/SemanticCoherencePhase.js +191 -0
  51. package/dist/core/analyzer/SemanticCoherencePhase.js.map +1 -0
  52. package/dist/core/analyzer/SemanticCoherenceService.d.ts +11 -0
  53. package/dist/core/analyzer/SemanticCoherenceService.d.ts.map +1 -0
  54. package/dist/core/analyzer/SemanticCoherenceService.js +56 -0
  55. package/dist/core/analyzer/SemanticCoherenceService.js.map +1 -0
  56. package/dist/core/analyzer/visitors/ComponentVisitor.d.ts.map +1 -1
  57. package/dist/core/analyzer/visitors/ComponentVisitor.js +2 -2
  58. package/dist/core/analyzer/visitors/ComponentVisitor.js.map +1 -1
  59. package/dist/core/analyzer/visitors/ErrorHandlingVisitor.d.ts.map +1 -1
  60. package/dist/core/analyzer/visitors/ErrorHandlingVisitor.js +2 -2
  61. package/dist/core/analyzer/visitors/ErrorHandlingVisitor.js.map +1 -1
  62. package/dist/core/analyzer/visitors/ImportVisitor.d.ts +5 -0
  63. package/dist/core/analyzer/visitors/ImportVisitor.d.ts.map +1 -1
  64. package/dist/core/analyzer/visitors/ImportVisitor.js +8 -3
  65. package/dist/core/analyzer/visitors/ImportVisitor.js.map +1 -1
  66. package/dist/core/analyzer/visitors/NamingVisitor.d.ts +20 -2
  67. package/dist/core/analyzer/visitors/NamingVisitor.d.ts.map +1 -1
  68. package/dist/core/analyzer/visitors/NamingVisitor.js +464 -25
  69. package/dist/core/analyzer/visitors/NamingVisitor.js.map +1 -1
  70. package/dist/core/analyzer/visitors/SchemaVisitor.d.ts +7 -0
  71. package/dist/core/analyzer/visitors/SchemaVisitor.d.ts.map +1 -0
  72. package/dist/core/analyzer/visitors/SchemaVisitor.js +50 -0
  73. package/dist/core/analyzer/visitors/SchemaVisitor.js.map +1 -0
  74. package/dist/core/analyzer/visitors/StructureVisitor.d.ts +4 -1
  75. package/dist/core/analyzer/visitors/StructureVisitor.d.ts.map +1 -1
  76. package/dist/core/analyzer/visitors/StructureVisitor.js +38 -4
  77. package/dist/core/analyzer/visitors/StructureVisitor.js.map +1 -1
  78. package/dist/core/analyzer/visitors/types.d.ts +4 -0
  79. package/dist/core/analyzer/visitors/types.d.ts.map +1 -1
  80. package/dist/core/classifier/CodeBertEmbedder.d.ts +9 -0
  81. package/dist/core/classifier/CodeBertEmbedder.d.ts.map +1 -0
  82. package/dist/core/classifier/CodeBertEmbedder.js +33 -0
  83. package/dist/core/classifier/CodeBertEmbedder.js.map +1 -0
  84. package/dist/core/classifier/ConfidenceGate.d.ts +2 -0
  85. package/dist/core/classifier/ConfidenceGate.d.ts.map +1 -1
  86. package/dist/core/classifier/ConfidenceGate.js +6 -2
  87. package/dist/core/classifier/ConfidenceGate.js.map +1 -1
  88. package/dist/core/exporter/FreshnessChecker.d.ts +5 -1
  89. package/dist/core/exporter/FreshnessChecker.d.ts.map +1 -1
  90. package/dist/core/exporter/FreshnessChecker.js +5 -10
  91. package/dist/core/exporter/FreshnessChecker.js.map +1 -1
  92. package/dist/core/generator/DocGenerator.d.ts +6 -1
  93. package/dist/core/generator/DocGenerator.d.ts.map +1 -1
  94. package/dist/core/generator/DocGenerator.js +34 -7
  95. package/dist/core/generator/DocGenerator.js.map +1 -1
  96. package/dist/core/generator/StalenessTracker.d.ts +7 -1
  97. package/dist/core/generator/StalenessTracker.d.ts.map +1 -1
  98. package/dist/core/generator/StalenessTracker.js +12 -12
  99. package/dist/core/generator/StalenessTracker.js.map +1 -1
  100. package/dist/core/generator/documents/ArchitectureGenerator.d.ts +1 -0
  101. package/dist/core/generator/documents/ArchitectureGenerator.d.ts.map +1 -1
  102. package/dist/core/generator/documents/ArchitectureGenerator.js +34 -16
  103. package/dist/core/generator/documents/ArchitectureGenerator.js.map +1 -1
  104. package/dist/core/generator/documents/ContributingGenerator.d.ts.map +1 -1
  105. package/dist/core/generator/documents/ContributingGenerator.js +10 -9
  106. package/dist/core/generator/documents/ContributingGenerator.js.map +1 -1
  107. package/dist/core/generator/documents/ConventionsGenerator.d.ts.map +1 -1
  108. package/dist/core/generator/documents/ConventionsGenerator.js +22 -8
  109. package/dist/core/generator/documents/ConventionsGenerator.js.map +1 -1
  110. package/dist/core/generator/documents/OnboardingGenerator.d.ts.map +1 -1
  111. package/dist/core/generator/documents/OnboardingGenerator.js +25 -27
  112. package/dist/core/generator/documents/OnboardingGenerator.js.map +1 -1
  113. package/dist/core/generator/documents/ReadmeGenerator.d.ts +4 -3
  114. package/dist/core/generator/documents/ReadmeGenerator.d.ts.map +1 -1
  115. package/dist/core/generator/documents/ReadmeGenerator.js +149 -140
  116. package/dist/core/generator/documents/ReadmeGenerator.js.map +1 -1
  117. package/dist/core/generator/documents/promptHelpers.d.ts +1 -1
  118. package/dist/core/generator/documents/promptHelpers.d.ts.map +1 -1
  119. package/dist/core/generator/documents/promptHelpers.js +1 -1
  120. package/dist/core/generator/documents/promptHelpers.js.map +1 -1
  121. package/dist/core/generator/documents/types.d.ts +4 -1
  122. package/dist/core/generator/documents/types.d.ts.map +1 -1
  123. package/dist/core/generator/facts/FactExtractor.d.ts +5 -0
  124. package/dist/core/generator/facts/FactExtractor.d.ts.map +1 -0
  125. package/dist/core/generator/facts/FactExtractor.js +90 -0
  126. package/dist/core/generator/facts/FactExtractor.js.map +1 -0
  127. package/dist/core/generator/facts/types.d.ts +18 -0
  128. package/dist/core/generator/facts/types.d.ts.map +1 -0
  129. package/dist/core/generator/facts/types.js +2 -0
  130. package/dist/core/generator/facts/types.js.map +1 -0
  131. package/dist/core/generator/mlPipelineBuilder.d.ts +8 -0
  132. package/dist/core/generator/mlPipelineBuilder.d.ts.map +1 -0
  133. package/dist/core/generator/mlPipelineBuilder.js +117 -0
  134. package/dist/core/generator/mlPipelineBuilder.js.map +1 -0
  135. package/dist/core/scorer/ComplianceScorer.d.ts +5 -1
  136. package/dist/core/scorer/ComplianceScorer.d.ts.map +1 -1
  137. package/dist/core/scorer/ComplianceScorer.js +47 -23
  138. package/dist/core/scorer/ComplianceScorer.js.map +1 -1
  139. package/dist/core/scorer/ViolationDetector.d.ts +19 -2
  140. package/dist/core/scorer/ViolationDetector.d.ts.map +1 -1
  141. package/dist/core/scorer/ViolationDetector.js +169 -53
  142. package/dist/core/scorer/ViolationDetector.js.map +1 -1
  143. package/dist/models/ModelManager.d.ts +5 -1
  144. package/dist/models/ModelManager.d.ts.map +1 -1
  145. package/dist/models/ModelManager.js +19 -5
  146. package/dist/models/ModelManager.js.map +1 -1
  147. package/dist/models/ModelRegistry.d.ts +1 -1
  148. package/dist/models/ModelRegistry.d.ts.map +1 -1
  149. package/dist/models/ModelRegistry.js +28 -0
  150. package/dist/models/ModelRegistry.js.map +1 -1
  151. package/dist/storage/CustomRuleStore.d.ts +9 -0
  152. package/dist/storage/CustomRuleStore.d.ts.map +1 -0
  153. package/dist/storage/CustomRuleStore.js +22 -0
  154. package/dist/storage/CustomRuleStore.js.map +1 -0
  155. package/dist/storage/ScoreStore.d.ts +2 -5
  156. package/dist/storage/ScoreStore.d.ts.map +1 -1
  157. package/dist/storage/ScoreStore.js +23 -71
  158. package/dist/storage/ScoreStore.js.map +1 -1
  159. package/package.json +4 -3
  160. package/dist/core/classifier/DriftClassifier.d.ts +0 -17
  161. package/dist/core/classifier/DriftClassifier.d.ts.map +0 -1
  162. package/dist/core/classifier/DriftClassifier.js +0 -293
  163. package/dist/core/classifier/DriftClassifier.js.map +0 -1
package/README.md CHANGED
@@ -1,58 +1,65 @@
1
1
  # CodePlug
2
2
 
3
- **The source of truth for codebase understanding and governance.**
3
+ > The source of truth for codebase understanding & governance.
4
4
 
5
- CodePlug is a local-first CLI tool that detects your codebase's coding conventions, enforces them with drift detection and compliance scoring, generates living documentation, and exports convention context for AI coding agents.
5
+ ## Overview
6
+
7
+ This document is the primary technical reference for **CodePlug** (`@dinyangetoh/codeplug-cli`), a professional-grade, local-first CLI tool designed to detect, enforce, and document coding conventions across TypeScript and JavaScript codebases. It covers installation, configuration, usage, and the underlying architecture to help developers integrate CodePlug into their workflows. CodePlug combines AST analysis with on-device ML inference to provide automated convention governance, living documentation generation, and structured AI agent context export — ensuring both human developers and AI assistants adhere to the same project standards.
6
8
 
7
9
  ---
8
10
 
9
- ## Features
11
+ ## Key Descriptions
10
12
 
11
- - **Convention Detection** -- AST analysis with on-device ML identifies naming patterns, folder structure, component styles, test organization, error handling, and import conventions across your TypeScript/JavaScript codebase.
12
- - **Drift & Compliance** -- Classifies git diffs against stored conventions, scores compliance with severity-weighted metrics, tracks trends over time, and auto-fixes what it can.
13
- - **Living Documentation** -- Generates and maintains README, ARCHITECTURE, CONVENTIONS, CONTRIBUTING, and ONBOARDING docs using ML summarization and optional LLM enhancement.
14
- - **AI Agent Export** -- Exports your conventions as `CLAUDE.md`, `.cursor/rules`, `.github/copilot-instructions.md`, structured JSON, and SARIF-format CI reports.
13
+ CodePlug acts as the **source of truth for codebase understanding**. It uses AST visitors and on-device ML models (via `@huggingface/transformers`, with no Python dependency) to identify patterns across naming, structure, components, and error handling. It generates "living documentation" and structured rule files for AI agents (Claude, Cursor, Copilot), and provides a compliance scoring engine to prevent architectural drift over time.
15
14
 
16
15
  ---
17
16
 
18
- ## Quick Start
17
+ ## Key Features
19
18
 
20
- ```bash
21
- # Install globally
22
- npm install -g @dinyangetoh/codeplug-cli
19
+ ### Convention Detection & Governance
20
+ - **Multi-Dimensional AST Analysis:** Six to seven specialized visitors identify naming patterns, component styles, test organization, error handling, and import conventions.
21
+ - **Drift & Compliance Scoring:** Classifies git diffs against stored conventions, scores compliance with severity-weighted metrics, and tracks trends via an internal `sql.js` time-series database.
22
+ - **Auto-Fix:** Supports automated renaming and provides guided remediation for complex violations.
23
23
 
24
- # Navigate to your project
25
- cd your-project
24
+ ### Documentation & AI Integration
25
+ - **Living Documentation:** Automatically maintains `ARCHITECTURE.md`, `CONVENTIONS.md`, and `ONBOARDING.md` using ML summarization pipelines (BART, BERT).
26
+ - **AI Agent Export:** Generates context files including `CLAUDE.md`, `.cursor/rules`, and `.github/copilot-instructions.md`.
27
+ - **CI/CD Ready:** Exports SARIF-format reports for integration with GitHub Actions and other CI pipelines.
26
28
 
27
- # Detect and confirm conventions
28
- codeplug convention init
29
+ ### Feature Matrix
29
30
 
30
- # Check compliance
31
- codeplug convention audit
32
- ```
31
+ | Category | Feature | Command | Notes |
32
+ |---|---|---|---|
33
+ | **CLI** | Interactive Wizard | `codeplug start` | Single entry point for all menus |
34
+ | **Audit** | Compliance Score | `codeplug convention score` | Severity-weighted, time-series tracking |
35
+ | **Docs** | ML Generation | `codeplug docs generate` | 5 core docs; optional LLM enhancement |
36
+ | **Export** | AI Context | `codeplug export --all` | Supports Claude, Cursor, Copilot, JSON |
37
+ | **Config** | Model Tiers | `codeplug config set` | Choose between `default` or `lite` models |
33
38
 
34
39
  ---
35
40
 
36
41
  ## Prerequisites
37
42
 
38
- - **Node.js 20+** (required)
39
- - **Git** (required for drift detection and history analysis)
40
- - **Ollama** (optional, for LLM-enhanced documentation -- any OpenAI-compatible provider works)
43
+ | Requirement | Version | Notes |
44
+ |---|---|---|
45
+ | **Node.js** | `>=20.0.0` | Required for native fetch and modern ESM support |
46
+ | **Git** | Any modern version | Required for drift detection and history analysis |
47
+ | **Ollama** | Optional | For local LLM-enhanced documentation; any OpenAI-compatible provider is also supported |
41
48
 
42
49
  ---
43
50
 
44
51
  ## Installation
45
52
 
46
- ### Global install
53
+ ### Global Install
47
54
 
48
55
  ```bash
49
56
  npm install -g @dinyangetoh/codeplug-cli
50
57
  ```
51
58
 
52
- ### Local development
59
+ ### Local Development
53
60
 
54
61
  ```bash
55
- git clone <repo-url>
62
+ git clone <repository-url>
56
63
  cd codeplug
57
64
  npm install
58
65
  npm run build
@@ -61,231 +68,186 @@ node dist/cli/index.js --help
61
68
 
62
69
  ---
63
70
 
64
- ## Usage
65
-
66
- ### Convention Detection
71
+ ## Quick Start
67
72
 
68
73
  ```bash
69
- # Detect and interactively confirm conventions
74
+ # Initialize and detect conventions in your project
75
+ cd your-project
70
76
  codeplug convention init
71
77
 
72
- # Re-run detection, overwrite existing conventions
73
- codeplug convention init --force
74
- ```
75
-
76
- ### Compliance Audit
77
-
78
- ```bash
79
- # Full compliance report
78
+ # Run a compliance audit
80
79
  codeplug convention audit
81
80
 
82
- # Audit only changes from the last 7 days
83
- codeplug convention audit --since 7d
84
-
85
- # CI mode -- exits non-zero if score drops below threshold
86
- codeplug convention audit --ci
81
+ # Launch the interactive wizard
82
+ codeplug start
87
83
  ```
88
84
 
89
- ### Drift Detection
90
-
91
- ```bash
92
- # Check recent commits for convention drift
93
- codeplug convention drift
94
- ```
95
-
96
- ### Compliance Score
97
-
98
- ```bash
99
- # Show current score
100
- codeplug convention score
85
+ ---
101
86
 
102
- # Show score history and trend chart
103
- codeplug convention score --trend
104
- ```
87
+ ## Usage
105
88
 
106
- ### Auto-Fix
89
+ ### Interactive Wizard
107
90
 
108
- ```bash
109
- # Apply all safe auto-fixes
110
- codeplug convention fix --auto
91
+ The `codeplug start` command provides a guided interface organized into four areas:
111
92
 
112
- # Fix a specific finding by ID
113
- codeplug convention fix --id naming-pascal-components
114
- ```
93
+ | Area | Description |
94
+ |---|---|
95
+ | **Config** | Manage LLM providers, API keys, and model tiers |
96
+ | **Convention** | Initialize detection, run audits, and apply auto-fixes |
97
+ | **Docs** | Generate and update stale documentation |
98
+ | **Export** | Refresh AI agent rule files |
115
99
 
116
- ### Documentation Generation
100
+ ### Common Commands
117
101
 
118
102
  ```bash
119
- # Generate all 5 documents
120
- codeplug docs generate
103
+ # Audit changes from the last 7 days
104
+ codeplug convention audit --since 7d
121
105
 
122
- # Generate a specific document
123
- codeplug docs generate --doc ARCHITECTURE
106
+ # CI mode exits non-zero if score is below threshold
107
+ codeplug convention audit --ci
124
108
 
125
- # Tune for audience and style
109
+ # Generate docs for a junior audience in concise style
126
110
  codeplug docs generate --audience junior --style concise
127
111
 
128
- # Check which docs are stale
129
- codeplug docs status
130
-
131
- # Regenerate only stale sections
132
- codeplug docs update
133
- ```
134
-
135
- ### Export for AI Agents
136
-
137
- ```bash
138
- # Export for a specific target
139
- codeplug export --target claude
112
+ # Export rules for Cursor
140
113
  codeplug export --target cursor
141
- codeplug export --target copilot
142
114
 
143
- # Export all targets at once
115
+ # Export all AI agent context files
144
116
  codeplug export --all
145
-
146
- # Check if exports are up to date
147
- codeplug export --check
148
- ```
149
-
150
- ### Configuration
151
-
152
- ```bash
153
- # View all settings
154
- codeplug config list
155
-
156
- # Get a specific value
157
- codeplug config get llm.provider
158
-
159
- # Set values
160
- codeplug config set llm.provider openai
161
- codeplug config set llm.model gpt-4o
162
- codeplug config set llm.apiKey sk-...
163
117
  ```
164
118
 
165
119
  ---
166
120
 
167
121
  ## Configuration
168
122
 
169
- CodePlug stores project-level configuration in `.codeplug/config.json`. The `config` command manages this file.
170
-
171
- ### LLM Provider
123
+ CodePlug stores project-level settings in `.codeplug/config.json`.
172
124
 
173
- The default provider is Ollama (local). Setting a provider auto-fills its base URL and default model:
125
+ ### LLM Providers
174
126
 
175
- ```bash
176
- codeplug config set llm.provider ollama # local, no API key needed
177
- codeplug config set llm.provider openai # sets baseUrl + model automatically
178
- codeplug config set llm.provider anthropic
179
- ```
127
+ Convention detection runs entirely on-device. Documentation prose generation can optionally be enhanced via a local or cloud LLM provider:
180
128
 
181
- You can also set individual fields for custom endpoints:
129
+ - **Local:** Ollama (default)
130
+ - **Cloud:** OpenAI, Anthropic, Gemini, OpenRouter, Groq, DeepSeek, Grok
182
131
 
183
132
  ```bash
184
- codeplug config set llm.baseUrl https://my-proxy.example.com/v1
185
- codeplug config set llm.model my-custom-model
186
- codeplug config set llm.apiKey my-key
133
+ codeplug config set llm.provider openai
134
+ codeplug config set llm.apiKey sk-...
187
135
  ```
188
136
 
189
- ### Model Tier
137
+ ### Model Tiers
190
138
 
191
- ```bash
192
- # Full-size models (default) -- best quality, ~1.1GB disk, 8GB+ RAM recommended
193
- codeplug config set models.tier default
139
+ | Tier | RAM | Disk | Use Case |
140
+ |---|---|---|---|
141
+ | **Default** | 8 GB+ | ~1.2 GB | Production quality, CI pipelines |
142
+ | **Lite** | 4 GB+ | ~450 MB | Constrained local hardware |
194
143
 
195
- # Lightweight models -- reduced quality, ~420MB disk, 4GB RAM minimum
196
- codeplug config set models.tier lite
144
+ ```bash
145
+ codeplug config set model.tier lite
197
146
  ```
198
147
 
199
- Switching to `lite` prints a warning about potential quality degradation.
200
-
201
- ---
202
-
203
- ## Supported LLM Providers
148
+ ### Custom Rules
204
149
 
205
- All providers work through a single unified client via the OpenAI SDK.
150
+ Define regex-based rules in `.codeplug/rules.json` to extend or override detected conventions:
206
151
 
207
- | Provider | Setup |
208
- |----------|-------|
209
- | Ollama | `codeplug config set llm.provider ollama` (default, no API key) |
210
- | OpenAI | `codeplug config set llm.provider openai` then set `llm.apiKey` |
211
- | Anthropic | `codeplug config set llm.provider anthropic` then set `llm.apiKey` |
212
- | Gemini | `codeplug config set llm.provider gemini` then set `llm.apiKey` |
213
- | OpenRouter | `codeplug config set llm.provider openrouter` then set `llm.apiKey` |
214
- | Groq | `codeplug config set llm.provider groq` then set `llm.apiKey` |
215
- | DeepSeek | `codeplug config set llm.provider deepseek` then set `llm.apiKey` |
216
- | Grok | `codeplug config set llm.provider grok` then set `llm.apiKey` |
152
+ ```json
153
+ [{
154
+ "id": "no-index-export",
155
+ "pattern": "export \\* from",
156
+ "scope": "content",
157
+ "message": "Prefer named exports",
158
+ "severity": "low"
159
+ }]
160
+ ```
217
161
 
218
162
  ---
219
163
 
220
- ## Model Tiers
221
-
222
- | | Default | Lite |
223
- |---|---------|------|
224
- | Target machine | 8GB+ RAM | 4GB+ RAM |
225
- | Disk usage | ~1.1GB | ~420MB |
226
- | Classification | CodeBERT-base (125M params) | CodeBERTa-small (84M params) |
227
- | Summarization | BART-large-CNN (406M params) | DistilBART (230M params) |
228
- | NER | BERT-base-NER (110M params) | DistilBERT-NER (66M params) |
229
- | When to use | Production quality, CI pipelines | Local development on constrained hardware |
230
-
231
- Models are downloaded on first use and cached in `~/.codeplug/models/`.
164
+ ## Project Structure & Architecture
165
+
166
+ ### Folder Structure
167
+
168
+ ```text
169
+ src/ # 66 source files
170
+ ├── cli/
171
+ │ └── commands/ # Command handlers (convention, docs, export)
172
+ ├── config/ # Zod schemas and provider presets
173
+ ├── core/
174
+ │ ├── analyzer/ # AST analysis — 6–7 specialized visitors
175
+ │ ├── classifier/ # Drift classification & confidence gating
176
+ │ ├── scorer/ # Compliance engine & violation detection
177
+ │ ├── generator/ # ML pipelines (BART, BERT) & LLM client
178
+ │ ├── exporter/ # Formatters (Claude, Cursor, SARIF)
179
+ │ └── git/ # Diff analysis & hook management
180
+ ├── models/ # Tier-aware ML model registry
181
+ ├── storage/ # sql.js (scores) and JSON stores
182
+ └── templates/ # Export templates for AI agents
183
+
184
+ tests/ # 18 test files
185
+ ├── unit/
186
+ │ ├── analyzer/
187
+ │ ├── config/
188
+ │ ├── exporter/
189
+ │ ├── generator/
190
+ │ ├── models/
191
+ │ └── scorer/
192
+ └── fixtures/
193
+ └── sample-react-app/
194
+ ```
195
+
196
+ ### Technical Stack
197
+
198
+ | Layer | Technology |
199
+ |---|---|
200
+ | **ML Inference** | `@huggingface/transformers` — Python-free, Node.js native |
201
+ | **Summarization** | BART (documentation prose) |
202
+ | **Embeddings** | BERT (pattern classification) |
203
+ | **Database** | `sql.js` (compliance time-series) |
204
+ | **Schema Validation** | Zod |
205
+ | **Test Runner** | Vitest |
232
206
 
233
207
  ---
234
208
 
235
- ## Development
209
+ ## Conventions
236
210
 
237
- ```bash
238
- # Install dependencies
239
- npm install
240
-
241
- # Build
242
- npm run build
211
+ These are the conventions CodePlug enforces and itself follows internally.
243
212
 
244
- # Type check without emitting
245
- npm run typecheck
213
+ ### Naming
246
214
 
247
- # Run tests
248
- npm test
215
+ | Target | Convention | Example |
216
+ |---|---|---|
217
+ | Class / service files | `PascalCase` | `ConfigManager.ts` |
218
+ | Utility files | `camelCase` | `formatDate.ts` |
219
+ | Class names | `PascalCase` | `class ConventionScorer` |
220
+ | Interface names | `PascalCase` | `interface RuleConfig` |
221
+ | Type aliases | `PascalCase` | `type SeverityLevel` |
222
+ | Factory functions | `camelCase` | `createAnalyzer()` |
249
223
 
250
- # Run tests in watch mode
251
- npm run test:watch
224
+ > **Note:** Kebab-case filenames are not used anywhere in this project.
252
225
 
253
- # Run with coverage
254
- npm run coverage
226
+ ### API & Async Patterns
255
227
 
256
- # Lint
257
- npm run lint
228
+ - All I/O operations use `async/await`; callbacks and raw Promise chains are avoided.
258
229
 
259
- # Lint with auto-fix
260
- npm run lint:fix
230
+ ### Testing
261
231
 
262
- # Watch build during development
263
- npm run dev
264
- ```
232
+ - Integration tests live in the root `tests/` directory.
233
+ - Unit tests are co-located in `__tests__/` subdirectories alongside source files.
234
+ - Test files follow the `.test.{ext}` naming convention.
265
235
 
266
236
  ---
267
237
 
268
- ## Project Structure
238
+ ## Development
269
239
 
270
- ```
271
- src/
272
- cli/commands/ Command handlers (convention, docs, export, config)
273
- config/ ConfigManager, Zod schemas, types, provider presets
274
- core/
275
- analyzer/ AST analysis engine + 6 visitors + PatternAggregator
276
- classifier/ Drift classification + confidence gating
277
- scorer/ Compliance scoring, violation detection, auto-fix, trends
278
- generator/ Doc generation, ML pipelines, LLM client, staleness tracking
279
- exporter/ Export engine + 5 formatters (Claude, Cursor, Copilot, JSON, CI)
280
- git/ Git integration + pre-commit hook management
281
- models/ ML model manager + tier-aware registry
282
- storage/ ConventionStore, ScoreStore (sql.js), ViolationStore
283
- templates/ Export templates (Claude, Cursor, Copilot)
284
- tests/ Unit tests, integration tests, fixture repos
240
+ ```bash
241
+ npm run build # Compile TypeScript
242
+ npm run dev # Watch mode for active development
243
+ npm run test # Run the full Vitest suite
244
+ npm run coverage # Generate test coverage report
245
+ npm run lint # Check code style
246
+ npm run typecheck # Verify TypeScript types
285
247
  ```
286
248
 
287
249
  ---
288
250
 
289
251
  ## License
290
252
 
291
- MIT
253
+ MIT
@@ -1,4 +1,4 @@
1
- import type { ConventionInitOptions, ConventionAuditOptions, ConventionScoreOptions, ConventionFixOptions } from '../../config/types.js';
1
+ import type { ConventionAuditOptions, ConventionFixOptions, ConventionInitOptions, ConventionScoreOptions } from "../../config/types.js";
2
2
  export declare function handleConventionInit(options: ConventionInitOptions): Promise<void>;
3
3
  export declare function handleConventionAudit(options: ConventionAuditOptions): Promise<void>;
4
4
  export declare function handleConventionDrift(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"convention.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/convention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAEzI,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BxF;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB1F;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAc3D;AAED,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe1F;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,CAYtF;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIxE"}
1
+ {"version":3,"file":"convention.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/convention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAuFf;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAsDf;AAID,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CA6H3D;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIxE"}