@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.
- package/README.md +149 -187
- package/dist/cli/commands/convention.d.ts +1 -1
- package/dist/cli/commands/convention.d.ts.map +1 -1
- package/dist/cli/commands/convention.js +174 -31
- package/dist/cli/commands/convention.js.map +1 -1
- package/dist/cli/commands/docs.d.ts.map +1 -1
- package/dist/cli/commands/docs.js +9 -2
- package/dist/cli/commands/docs.js.map +1 -1
- package/dist/cli/commands/export.d.ts.map +1 -1
- package/dist/cli/commands/export.js +6 -1
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/start.d.ts +2 -0
- package/dist/cli/commands/start.d.ts.map +1 -0
- package/dist/cli/commands/start.js +172 -0
- package/dist/cli/commands/start.js.map +1 -0
- package/dist/cli/index.js +9 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/config/ConfigManager.d.ts +18 -0
- package/dist/config/ConfigManager.d.ts.map +1 -1
- package/dist/config/ConfigManager.js +55 -2
- package/dist/config/ConfigManager.js.map +1 -1
- package/dist/config/ConventionSchema.d.ts +59 -0
- package/dist/config/ConventionSchema.d.ts.map +1 -1
- package/dist/config/ConventionSchema.js +11 -0
- package/dist/config/ConventionSchema.js.map +1 -1
- package/dist/config/defaults.d.ts +60 -2
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +136 -20
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/types.d.ts +71 -0
- package/dist/config/types.d.ts.map +1 -1
- package/dist/core/analyzer/AstAnalyzer.d.ts +11 -2
- package/dist/core/analyzer/AstAnalyzer.d.ts.map +1 -1
- package/dist/core/analyzer/AstAnalyzer.js +21 -5
- package/dist/core/analyzer/AstAnalyzer.js.map +1 -1
- package/dist/core/analyzer/ConventionDetector.d.ts +12 -1
- package/dist/core/analyzer/ConventionDetector.d.ts.map +1 -1
- package/dist/core/analyzer/ConventionDetector.js +120 -20
- package/dist/core/analyzer/ConventionDetector.js.map +1 -1
- package/dist/core/analyzer/ConventionMlResolver.d.ts +4 -0
- package/dist/core/analyzer/ConventionMlResolver.d.ts.map +1 -0
- package/dist/core/analyzer/ConventionMlResolver.js +17 -0
- package/dist/core/analyzer/ConventionMlResolver.js.map +1 -0
- package/dist/core/analyzer/PatternAggregator.d.ts +11 -2
- package/dist/core/analyzer/PatternAggregator.d.ts.map +1 -1
- package/dist/core/analyzer/PatternAggregator.js +87 -15
- package/dist/core/analyzer/PatternAggregator.js.map +1 -1
- package/dist/core/analyzer/SemanticCoherencePhase.d.ts +10 -0
- package/dist/core/analyzer/SemanticCoherencePhase.d.ts.map +1 -0
- package/dist/core/analyzer/SemanticCoherencePhase.js +191 -0
- package/dist/core/analyzer/SemanticCoherencePhase.js.map +1 -0
- package/dist/core/analyzer/SemanticCoherenceService.d.ts +11 -0
- package/dist/core/analyzer/SemanticCoherenceService.d.ts.map +1 -0
- package/dist/core/analyzer/SemanticCoherenceService.js +56 -0
- package/dist/core/analyzer/SemanticCoherenceService.js.map +1 -0
- package/dist/core/analyzer/visitors/ComponentVisitor.d.ts.map +1 -1
- package/dist/core/analyzer/visitors/ComponentVisitor.js +2 -2
- package/dist/core/analyzer/visitors/ComponentVisitor.js.map +1 -1
- package/dist/core/analyzer/visitors/ErrorHandlingVisitor.d.ts.map +1 -1
- package/dist/core/analyzer/visitors/ErrorHandlingVisitor.js +2 -2
- package/dist/core/analyzer/visitors/ErrorHandlingVisitor.js.map +1 -1
- package/dist/core/analyzer/visitors/ImportVisitor.d.ts +5 -0
- package/dist/core/analyzer/visitors/ImportVisitor.d.ts.map +1 -1
- package/dist/core/analyzer/visitors/ImportVisitor.js +8 -3
- package/dist/core/analyzer/visitors/ImportVisitor.js.map +1 -1
- package/dist/core/analyzer/visitors/NamingVisitor.d.ts +20 -2
- package/dist/core/analyzer/visitors/NamingVisitor.d.ts.map +1 -1
- package/dist/core/analyzer/visitors/NamingVisitor.js +464 -25
- package/dist/core/analyzer/visitors/NamingVisitor.js.map +1 -1
- package/dist/core/analyzer/visitors/SchemaVisitor.d.ts +7 -0
- package/dist/core/analyzer/visitors/SchemaVisitor.d.ts.map +1 -0
- package/dist/core/analyzer/visitors/SchemaVisitor.js +50 -0
- package/dist/core/analyzer/visitors/SchemaVisitor.js.map +1 -0
- package/dist/core/analyzer/visitors/StructureVisitor.d.ts +4 -1
- package/dist/core/analyzer/visitors/StructureVisitor.d.ts.map +1 -1
- package/dist/core/analyzer/visitors/StructureVisitor.js +38 -4
- package/dist/core/analyzer/visitors/StructureVisitor.js.map +1 -1
- package/dist/core/analyzer/visitors/types.d.ts +4 -0
- package/dist/core/analyzer/visitors/types.d.ts.map +1 -1
- package/dist/core/classifier/CodeBertEmbedder.d.ts +9 -0
- package/dist/core/classifier/CodeBertEmbedder.d.ts.map +1 -0
- package/dist/core/classifier/CodeBertEmbedder.js +33 -0
- package/dist/core/classifier/CodeBertEmbedder.js.map +1 -0
- package/dist/core/classifier/ConfidenceGate.d.ts +2 -0
- package/dist/core/classifier/ConfidenceGate.d.ts.map +1 -1
- package/dist/core/classifier/ConfidenceGate.js +6 -2
- package/dist/core/classifier/ConfidenceGate.js.map +1 -1
- package/dist/core/exporter/FreshnessChecker.d.ts +5 -1
- package/dist/core/exporter/FreshnessChecker.d.ts.map +1 -1
- package/dist/core/exporter/FreshnessChecker.js +5 -10
- package/dist/core/exporter/FreshnessChecker.js.map +1 -1
- package/dist/core/generator/DocGenerator.d.ts +6 -1
- package/dist/core/generator/DocGenerator.d.ts.map +1 -1
- package/dist/core/generator/DocGenerator.js +34 -7
- package/dist/core/generator/DocGenerator.js.map +1 -1
- package/dist/core/generator/StalenessTracker.d.ts +7 -1
- package/dist/core/generator/StalenessTracker.d.ts.map +1 -1
- package/dist/core/generator/StalenessTracker.js +12 -12
- package/dist/core/generator/StalenessTracker.js.map +1 -1
- package/dist/core/generator/documents/ArchitectureGenerator.d.ts +1 -0
- package/dist/core/generator/documents/ArchitectureGenerator.d.ts.map +1 -1
- package/dist/core/generator/documents/ArchitectureGenerator.js +34 -16
- package/dist/core/generator/documents/ArchitectureGenerator.js.map +1 -1
- package/dist/core/generator/documents/ContributingGenerator.d.ts.map +1 -1
- package/dist/core/generator/documents/ContributingGenerator.js +10 -9
- package/dist/core/generator/documents/ContributingGenerator.js.map +1 -1
- package/dist/core/generator/documents/ConventionsGenerator.d.ts.map +1 -1
- package/dist/core/generator/documents/ConventionsGenerator.js +22 -8
- package/dist/core/generator/documents/ConventionsGenerator.js.map +1 -1
- package/dist/core/generator/documents/OnboardingGenerator.d.ts.map +1 -1
- package/dist/core/generator/documents/OnboardingGenerator.js +25 -27
- package/dist/core/generator/documents/OnboardingGenerator.js.map +1 -1
- package/dist/core/generator/documents/ReadmeGenerator.d.ts +4 -3
- package/dist/core/generator/documents/ReadmeGenerator.d.ts.map +1 -1
- package/dist/core/generator/documents/ReadmeGenerator.js +149 -140
- package/dist/core/generator/documents/ReadmeGenerator.js.map +1 -1
- package/dist/core/generator/documents/promptHelpers.d.ts +1 -1
- package/dist/core/generator/documents/promptHelpers.d.ts.map +1 -1
- package/dist/core/generator/documents/promptHelpers.js +1 -1
- package/dist/core/generator/documents/promptHelpers.js.map +1 -1
- package/dist/core/generator/documents/types.d.ts +4 -1
- package/dist/core/generator/documents/types.d.ts.map +1 -1
- package/dist/core/generator/facts/FactExtractor.d.ts +5 -0
- package/dist/core/generator/facts/FactExtractor.d.ts.map +1 -0
- package/dist/core/generator/facts/FactExtractor.js +90 -0
- package/dist/core/generator/facts/FactExtractor.js.map +1 -0
- package/dist/core/generator/facts/types.d.ts +18 -0
- package/dist/core/generator/facts/types.d.ts.map +1 -0
- package/dist/core/generator/facts/types.js +2 -0
- package/dist/core/generator/facts/types.js.map +1 -0
- package/dist/core/generator/mlPipelineBuilder.d.ts +8 -0
- package/dist/core/generator/mlPipelineBuilder.d.ts.map +1 -0
- package/dist/core/generator/mlPipelineBuilder.js +117 -0
- package/dist/core/generator/mlPipelineBuilder.js.map +1 -0
- package/dist/core/scorer/ComplianceScorer.d.ts +5 -1
- package/dist/core/scorer/ComplianceScorer.d.ts.map +1 -1
- package/dist/core/scorer/ComplianceScorer.js +47 -23
- package/dist/core/scorer/ComplianceScorer.js.map +1 -1
- package/dist/core/scorer/ViolationDetector.d.ts +19 -2
- package/dist/core/scorer/ViolationDetector.d.ts.map +1 -1
- package/dist/core/scorer/ViolationDetector.js +169 -53
- package/dist/core/scorer/ViolationDetector.js.map +1 -1
- package/dist/models/ModelManager.d.ts +5 -1
- package/dist/models/ModelManager.d.ts.map +1 -1
- package/dist/models/ModelManager.js +19 -5
- package/dist/models/ModelManager.js.map +1 -1
- package/dist/models/ModelRegistry.d.ts +1 -1
- package/dist/models/ModelRegistry.d.ts.map +1 -1
- package/dist/models/ModelRegistry.js +28 -0
- package/dist/models/ModelRegistry.js.map +1 -1
- package/dist/storage/CustomRuleStore.d.ts +9 -0
- package/dist/storage/CustomRuleStore.d.ts.map +1 -0
- package/dist/storage/CustomRuleStore.js +22 -0
- package/dist/storage/CustomRuleStore.js.map +1 -0
- package/dist/storage/ScoreStore.d.ts +2 -5
- package/dist/storage/ScoreStore.d.ts.map +1 -1
- package/dist/storage/ScoreStore.js +23 -71
- package/dist/storage/ScoreStore.js.map +1 -1
- package/package.json +4 -3
- package/dist/core/classifier/DriftClassifier.d.ts +0 -17
- package/dist/core/classifier/DriftClassifier.d.ts.map +0 -1
- package/dist/core/classifier/DriftClassifier.js +0 -293
- package/dist/core/classifier/DriftClassifier.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,58 +1,65 @@
|
|
|
1
1
|
# CodePlug
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> The source of truth for codebase understanding & governance.
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
##
|
|
11
|
+
## Key Descriptions
|
|
10
12
|
|
|
11
|
-
|
|
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
|
-
##
|
|
17
|
+
## Key Features
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
codeplug convention init
|
|
29
|
+
### Feature Matrix
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
53
|
+
### Global Install
|
|
47
54
|
|
|
48
55
|
```bash
|
|
49
56
|
npm install -g @dinyangetoh/codeplug-cli
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
### Local
|
|
59
|
+
### Local Development
|
|
53
60
|
|
|
54
61
|
```bash
|
|
55
|
-
git clone <
|
|
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
|
-
##
|
|
65
|
-
|
|
66
|
-
### Convention Detection
|
|
71
|
+
## Quick Start
|
|
67
72
|
|
|
68
73
|
```bash
|
|
69
|
-
#
|
|
74
|
+
# Initialize and detect conventions in your project
|
|
75
|
+
cd your-project
|
|
70
76
|
codeplug convention init
|
|
71
77
|
|
|
72
|
-
#
|
|
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
|
-
#
|
|
83
|
-
codeplug
|
|
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
|
-
|
|
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
|
-
|
|
103
|
-
codeplug convention score --trend
|
|
104
|
-
```
|
|
87
|
+
## Usage
|
|
105
88
|
|
|
106
|
-
###
|
|
89
|
+
### Interactive Wizard
|
|
107
90
|
|
|
108
|
-
|
|
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
|
-
|
|
113
|
-
|
|
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
|
-
###
|
|
100
|
+
### Common Commands
|
|
117
101
|
|
|
118
102
|
```bash
|
|
119
|
-
#
|
|
120
|
-
codeplug
|
|
103
|
+
# Audit changes from the last 7 days
|
|
104
|
+
codeplug convention audit --since 7d
|
|
121
105
|
|
|
122
|
-
#
|
|
123
|
-
codeplug
|
|
106
|
+
# CI mode — exits non-zero if score is below threshold
|
|
107
|
+
codeplug convention audit --ci
|
|
124
108
|
|
|
125
|
-
#
|
|
109
|
+
# Generate docs for a junior audience in concise style
|
|
126
110
|
codeplug docs generate --audience junior --style concise
|
|
127
111
|
|
|
128
|
-
#
|
|
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
|
|
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
|
|
170
|
-
|
|
171
|
-
### LLM Provider
|
|
123
|
+
CodePlug stores project-level settings in `.codeplug/config.json`.
|
|
172
124
|
|
|
173
|
-
|
|
125
|
+
### LLM Providers
|
|
174
126
|
|
|
175
|
-
|
|
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
|
-
|
|
129
|
+
- **Local:** Ollama (default)
|
|
130
|
+
- **Cloud:** OpenAI, Anthropic, Gemini, OpenRouter, Groq, DeepSeek, Grok
|
|
182
131
|
|
|
183
132
|
```bash
|
|
184
|
-
codeplug config set llm.
|
|
185
|
-
codeplug config set llm.
|
|
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
|
|
137
|
+
### Model Tiers
|
|
190
138
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
196
|
-
codeplug config set
|
|
144
|
+
```bash
|
|
145
|
+
codeplug config set model.tier lite
|
|
197
146
|
```
|
|
198
147
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## Supported LLM Providers
|
|
148
|
+
### Custom Rules
|
|
204
149
|
|
|
205
|
-
|
|
150
|
+
Define regex-based rules in `.codeplug/rules.json` to extend or override detected conventions:
|
|
206
151
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
##
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
##
|
|
209
|
+
## Conventions
|
|
236
210
|
|
|
237
|
-
|
|
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
|
-
|
|
245
|
-
npm run typecheck
|
|
213
|
+
### Naming
|
|
246
214
|
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
251
|
-
npm run test:watch
|
|
224
|
+
> **Note:** Kebab-case filenames are not used anywhere in this project.
|
|
252
225
|
|
|
253
|
-
|
|
254
|
-
npm run coverage
|
|
226
|
+
### API & Async Patterns
|
|
255
227
|
|
|
256
|
-
|
|
257
|
-
npm run lint
|
|
228
|
+
- All I/O operations use `async/await`; callbacks and raw Promise chains are avoided.
|
|
258
229
|
|
|
259
|
-
|
|
260
|
-
npm run lint:fix
|
|
230
|
+
### Testing
|
|
261
231
|
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
##
|
|
238
|
+
## Development
|
|
269
239
|
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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 {
|
|
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,
|
|
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"}
|