autoworkflow 1.1.0 → 2.0.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.
- package/.claude/commands/analyze.md +77 -0
- package/.claude/commands/audit.md +220 -0
- package/.claude/commands/build.md +159 -0
- package/.claude/commands/commit.md +165 -0
- package/.claude/commands/fix.md +119 -0
- package/.claude/commands/plan.md +101 -0
- package/.claude/commands/suggest.md +195 -0
- package/.claude/commands/verify.md +113 -0
- package/.claude/settings.json +129 -0
- package/.claude/settings.local.json +9 -0
- package/.prettierrc +11 -0
- package/.vscode/extensions.json +27 -0
- package/.vscode/settings.json +69 -0
- package/.vscode/tasks.json +161 -0
- package/CLAUDE.md +344 -0
- package/README.md +180 -195
- package/eslint.config.example.js +83 -0
- package/hooks/commit-msg +137 -0
- package/hooks/pre-commit +152 -0
- package/instructions/AI_RULES.md +284 -0
- package/instructions/BLUEPRINT.md +170 -0
- package/instructions/CLAUDE.md +472 -0
- package/package.json +45 -45
- package/scripts/autoworkflow.sh +324 -0
- package/scripts/check-ui-enforcement.sh +177 -0
- package/scripts/ensure-no-errors.sh +116 -0
- package/scripts/run-verification.sh +112 -0
- package/scripts/setup.sh +201 -0
- package/system/gates.md +390 -0
- package/system/loops.md +348 -0
- package/system/router.md +415 -0
- package/system/triggers.md +369 -0
- package/tsconfig.example.json +52 -0
- package/bin/cli.js +0 -299
- package/lib/index.js +0 -9
- package/lib/install.js +0 -600
package/README.md
CHANGED
|
@@ -1,250 +1,235 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AutoWorkflow - System Prompt Layer for Claude Code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Claude is the enforcement engine.** No scripts, no git hooks - just instructions that Claude follows.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
A system prompt architecture that controls Claude Code's behavior through triggers, loops, gates, and routing. When you use Claude Code in VS Code with this project, Claude will automatically follow a structured workflow for all coding tasks.
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
---
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
npm install autoworkflow --save-dev
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
**That's it.** Enforcement is now active on all commits.
|
|
15
|
-
|
|
16
|
-
## What Happens
|
|
9
|
+
## How It Works
|
|
17
10
|
|
|
18
11
|
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
│
|
|
29
|
-
│
|
|
30
|
-
│
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
12
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
13
|
+
│ CLAUDE.md (Entry Point) │
|
|
14
|
+
│ Loaded automatically by Claude Code │
|
|
15
|
+
└───────────────────────────┬─────────────────────────────────┘
|
|
16
|
+
│
|
|
17
|
+
▼
|
|
18
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
19
|
+
│ system/ (Control Layer) │
|
|
20
|
+
│ │
|
|
21
|
+
│ triggers.md │ loops.md │ gates.md │ router.md │
|
|
22
|
+
│ WHEN to act │ HOW to │ WHAT │ WHERE to │
|
|
23
|
+
│ │ repeat │ blocks │ route │
|
|
24
|
+
└───────────────────────────┬─────────────────────────────────┘
|
|
25
|
+
│
|
|
26
|
+
▼
|
|
27
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
28
|
+
│ instructions/ (Content Layer) │
|
|
29
|
+
│ │
|
|
30
|
+
│ CLAUDE.md │ AI_RULES.md │ BLUEPRINT.md │
|
|
31
|
+
│ Workflow │ Standards │ Project spec │
|
|
32
|
+
└─────────────────────────────────────────────────────────────┘
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## Default Checks
|
|
40
|
-
|
|
41
|
-
| Check | Blocking | Auto-Fix |
|
|
42
|
-
| ---------------------- | -------- | -------- |
|
|
43
|
-
| No TODO/FIXME comments | ✅ | - |
|
|
44
|
-
| No console.log | ✅ | - |
|
|
45
|
-
| TypeScript errors | ✅ | - |
|
|
46
|
-
| ESLint errors | ✅ | ✅ |
|
|
47
|
-
| Circular dependencies | ✅ | - |
|
|
48
|
-
| Commit message format | ✅ | - |
|
|
35
|
+
---
|
|
49
36
|
|
|
50
|
-
##
|
|
37
|
+
## Quick Start
|
|
51
38
|
|
|
52
|
-
|
|
39
|
+
1. **Copy this structure** into your project:
|
|
40
|
+
```
|
|
41
|
+
your-project/
|
|
42
|
+
├── CLAUDE.md # Entry point
|
|
43
|
+
├── system/ # Control layer
|
|
44
|
+
│ ├── triggers.md
|
|
45
|
+
│ ├── loops.md
|
|
46
|
+
│ ├── gates.md
|
|
47
|
+
│ └── router.md
|
|
48
|
+
├── instructions/ # Content layer
|
|
49
|
+
│ ├── CLAUDE.md
|
|
50
|
+
│ ├── AI_RULES.md
|
|
51
|
+
│ └── BLUEPRINT.md
|
|
52
|
+
├── .claude/ # Claude Code integration
|
|
53
|
+
│ ├── settings.json
|
|
54
|
+
│ └── commands/
|
|
55
|
+
└── .vscode/ # VS Code integration
|
|
56
|
+
├── settings.json
|
|
57
|
+
├── tasks.json
|
|
58
|
+
└── extensions.json
|
|
59
|
+
```
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
2. **Customize the instructions**:
|
|
62
|
+
- Edit `instructions/AI_RULES.md` with your coding standards
|
|
63
|
+
- Edit `instructions/BLUEPRINT.md` with your project spec
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
2. If ESLint fails, auto-fixes and retries (up to 5 attempts)
|
|
58
|
-
3. Blocks commit if any blocking check fails
|
|
59
|
-
4. Allows commit if all checks pass
|
|
65
|
+
3. **Use Claude Code** - Claude will automatically follow the workflow!
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
---
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
## The Workflow
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
# ✅ Valid
|
|
67
|
-
git commit -m "feat: add user authentication"
|
|
68
|
-
git commit -m "fix(api): resolve timeout issue"
|
|
69
|
-
git commit -m "docs: update installation guide"
|
|
71
|
+
When you ask Claude to do something, it follows this workflow:
|
|
70
72
|
|
|
71
|
-
# ❌ Invalid (blocked)
|
|
72
|
-
git commit -m "fixed stuff"
|
|
73
|
-
git commit -m "WIP"
|
|
74
73
|
```
|
|
75
|
-
|
|
76
|
-
## Configuration
|
|
77
|
-
|
|
78
|
-
Edit `enforce.config.json` in your project root:
|
|
79
|
-
|
|
80
|
-
```json
|
|
81
|
-
{
|
|
82
|
-
"rules": {
|
|
83
|
-
"no-todo-comments": {
|
|
84
|
-
"enabled": true,
|
|
85
|
-
"blocking": true,
|
|
86
|
-
"patterns": ["TODO", "FIXME", "XXX", "HACK"]
|
|
87
|
-
},
|
|
88
|
-
"no-console-logs": {
|
|
89
|
-
"enabled": true,
|
|
90
|
-
"blocking": true
|
|
91
|
-
},
|
|
92
|
-
"typescript": {
|
|
93
|
-
"enabled": true,
|
|
94
|
-
"blocking": true,
|
|
95
|
-
"command": "npx tsc --noEmit"
|
|
96
|
-
},
|
|
97
|
-
"eslint": {
|
|
98
|
-
"enabled": true,
|
|
99
|
-
"blocking": true,
|
|
100
|
-
"autoFix": true,
|
|
101
|
-
"command": "npx eslint . --max-warnings 0",
|
|
102
|
-
"fixCommand": "npx eslint . --fix"
|
|
103
|
-
},
|
|
104
|
-
"circular-deps": {
|
|
105
|
-
"enabled": true,
|
|
106
|
-
"blocking": true,
|
|
107
|
-
"paths": ["src/"]
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
"fixLoop": {
|
|
111
|
-
"enabled": true,
|
|
112
|
-
"maxAttempts": 5,
|
|
113
|
-
"autoFixRules": ["eslint"]
|
|
114
|
-
},
|
|
115
|
-
"commitMessage": {
|
|
116
|
-
"enabled": true,
|
|
117
|
-
"pattern": "^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\\(.+\\))?: .{1,72}$"
|
|
118
|
-
}
|
|
119
|
-
}
|
|
74
|
+
ANALYZE → PLAN → CONFIRM → IMPLEMENT → VERIFY → AUDIT → COMMIT
|
|
120
75
|
```
|
|
121
76
|
|
|
122
|
-
|
|
77
|
+
| Phase | What Claude Does |
|
|
78
|
+
|-------|------------------|
|
|
79
|
+
| **ANALYZE** | Reads relevant files, understands context |
|
|
80
|
+
| **PLAN** | Designs approach, shows suggestions |
|
|
81
|
+
| **CONFIRM** | Waits for your approval |
|
|
82
|
+
| **IMPLEMENT** | Makes changes (only after approval) |
|
|
83
|
+
| **VERIFY** | Runs `npm run verify` (typecheck + lint) |
|
|
84
|
+
| **AUDIT** | Checks for orphan features, circular deps |
|
|
85
|
+
| **COMMIT** | Creates conventional commit (after approval) |
|
|
123
86
|
|
|
124
|
-
|
|
125
|
-
| ------------ | ------- | -------------------------------------- |
|
|
126
|
-
| `enabled` | boolean | Enable/disable the rule |
|
|
127
|
-
| `blocking` | boolean | If true, fails the commit on violation |
|
|
128
|
-
| `autoFix` | boolean | Enable auto-fix for this rule |
|
|
129
|
-
| `command` | string | Custom check command |
|
|
130
|
-
| `fixCommand` | string | Custom fix command |
|
|
87
|
+
---
|
|
131
88
|
|
|
132
|
-
|
|
89
|
+
## Blocking Gates
|
|
133
90
|
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
"rules": {
|
|
137
|
-
"no-console-logs": { "enabled": false }
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
```
|
|
91
|
+
Claude will STOP and cannot proceed if:
|
|
141
92
|
|
|
142
|
-
|
|
93
|
+
| Gate | Blocks If |
|
|
94
|
+
|------|-----------|
|
|
95
|
+
| `plan_approval_gate` | You haven't approved the plan |
|
|
96
|
+
| `verify_gate` | TypeScript or ESLint errors exist |
|
|
97
|
+
| `audit_gate` | Orphan features or circular dependencies |
|
|
98
|
+
| `pre_commit_gate` | TODO/FIXME, console.log, bad commit format |
|
|
143
99
|
|
|
144
|
-
|
|
145
|
-
{
|
|
146
|
-
"rules": {
|
|
147
|
-
"circular-deps": { "enabled": true, "blocking": false }
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
```
|
|
100
|
+
---
|
|
151
101
|
|
|
152
|
-
##
|
|
102
|
+
## Available Commands
|
|
153
103
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
104
|
+
| Command | Purpose |
|
|
105
|
+
|---------|---------|
|
|
106
|
+
| `/analyze [task]` | Analyze codebase for a task |
|
|
107
|
+
| `/plan [task]` | Create implementation plan |
|
|
108
|
+
| `/build [feature]` | Full workflow for features |
|
|
109
|
+
| `/verify` | Run TypeScript + ESLint |
|
|
110
|
+
| `/fix` | Fix verification errors |
|
|
111
|
+
| `/audit` | Run UI + cycle audits |
|
|
112
|
+
| `/suggest [task]` | Generate suggestions |
|
|
113
|
+
| `/commit [msg]` | Pre-commit check + commit |
|
|
157
114
|
|
|
158
|
-
|
|
159
|
-
npx autoworkflow list
|
|
115
|
+
---
|
|
160
116
|
|
|
161
|
-
|
|
162
|
-
npx autoworkflow commit-msg .git/COMMIT_EDITMSG
|
|
117
|
+
## Hard Rules
|
|
163
118
|
|
|
164
|
-
|
|
165
|
-
npx autoworkflow --help
|
|
166
|
-
```
|
|
119
|
+
Claude enforces these automatically:
|
|
167
120
|
|
|
168
|
-
|
|
121
|
+
- **No orphan features** - Backend MUST have corresponding UI
|
|
122
|
+
- **No TODO/FIXME** - Complete the work, don't leave placeholders
|
|
123
|
+
- **No console.log** - No debug logs in production code
|
|
124
|
+
- **No circular deps** - Clean architecture required
|
|
125
|
+
- **Conventional commits** - `type(scope): description` format
|
|
169
126
|
|
|
170
|
-
|
|
127
|
+
---
|
|
171
128
|
|
|
172
|
-
|
|
173
|
-
[1/5] ESLint... ❌
|
|
174
|
-
src/app.ts: 'unused' is defined but never used
|
|
129
|
+
## File Structure
|
|
175
130
|
|
|
176
|
-
🔧 Attempting auto-fix...
|
|
177
|
-
✅ Fixed: ESLint
|
|
178
|
-
|
|
179
|
-
🔄 Fix Loop - Attempt 2/5
|
|
180
|
-
|
|
181
|
-
[1/5] ESLint... ✅
|
|
182
|
-
|
|
183
|
-
✅ ALL CHECKS PASSED
|
|
184
131
|
```
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
132
|
+
@autoworkflow/
|
|
133
|
+
├── CLAUDE.md # Entry point (Claude reads this first)
|
|
134
|
+
│
|
|
135
|
+
├── system/ # Control Layer
|
|
136
|
+
│ ├── triggers.md # Event → Action mappings
|
|
137
|
+
│ ├── loops.md # Verify/fix cycle definitions
|
|
138
|
+
│ ├── gates.md # Blocking checkpoints
|
|
139
|
+
│ └── router.md # Task type routing
|
|
140
|
+
│
|
|
141
|
+
├── instructions/ # Content Layer
|
|
142
|
+
│ ├── CLAUDE.md # Workflow steps
|
|
143
|
+
│ ├── AI_RULES.md # Coding standards
|
|
144
|
+
│ └── BLUEPRINT.md # Project specification
|
|
145
|
+
│
|
|
146
|
+
├── .claude/ # Claude Code Integration
|
|
147
|
+
│ ├── settings.json # Settings + hard rules
|
|
148
|
+
│ └── commands/ # Slash command definitions
|
|
149
|
+
│ ├── analyze.md
|
|
150
|
+
│ ├── plan.md
|
|
151
|
+
│ ├── build.md
|
|
152
|
+
│ ├── verify.md
|
|
153
|
+
│ ├── fix.md
|
|
154
|
+
│ ├── audit.md
|
|
155
|
+
│ ├── suggest.md
|
|
156
|
+
│ └── commit.md
|
|
157
|
+
│
|
|
158
|
+
└── .vscode/ # VS Code Integration
|
|
159
|
+
├── settings.json # Editor settings
|
|
160
|
+
├── tasks.json # Runnable tasks
|
|
161
|
+
└── extensions.json # Recommended extensions
|
|
190
162
|
```
|
|
191
163
|
|
|
192
|
-
|
|
164
|
+
---
|
|
193
165
|
|
|
194
|
-
##
|
|
166
|
+
## Why This Approach?
|
|
195
167
|
|
|
196
|
-
|
|
197
|
-
- Git
|
|
168
|
+
### Traditional Enforcement
|
|
169
|
+
- Git hooks run scripts
|
|
170
|
+
- Scripts check code
|
|
171
|
+
- Blocks commit on failure
|
|
198
172
|
|
|
199
|
-
###
|
|
173
|
+
### AutoWorkflow (This Approach)
|
|
174
|
+
- Claude reads instructions
|
|
175
|
+
- Claude follows the workflow
|
|
176
|
+
- Claude enforces rules as it works
|
|
200
177
|
|
|
201
|
-
|
|
202
|
-
-
|
|
178
|
+
**Benefits:**
|
|
179
|
+
- No runtime code to maintain
|
|
180
|
+
- Works in any project (just copy files)
|
|
181
|
+
- Claude explains what's happening
|
|
182
|
+
- Flexible - Claude can adapt to context
|
|
183
|
+
- Suggestions improve code quality proactively
|
|
203
184
|
|
|
204
|
-
|
|
185
|
+
---
|
|
205
186
|
|
|
206
|
-
|
|
187
|
+
## Customization
|
|
207
188
|
|
|
208
|
-
|
|
189
|
+
### Adding Your Coding Standards
|
|
190
|
+
Edit `instructions/AI_RULES.md`:
|
|
191
|
+
```markdown
|
|
192
|
+
## ALWAYS
|
|
193
|
+
- Use TypeScript strict mode
|
|
194
|
+
- Handle all error cases
|
|
195
|
+
- Add loading states for async
|
|
209
196
|
|
|
210
|
-
|
|
211
|
-
-
|
|
212
|
-
-
|
|
213
|
-
-
|
|
214
|
-
|
|
197
|
+
## NEVER
|
|
198
|
+
- Use `any` type
|
|
199
|
+
- Leave console.logs
|
|
200
|
+
- Skip error handling
|
|
201
|
+
```
|
|
215
202
|
|
|
216
|
-
###
|
|
203
|
+
### Adding Your Project Spec
|
|
204
|
+
Edit `instructions/BLUEPRINT.md`:
|
|
205
|
+
```markdown
|
|
206
|
+
## Features
|
|
207
|
+
- [ ] User authentication
|
|
208
|
+
- [ ] Dashboard page
|
|
209
|
+
- [ ] Settings panel
|
|
217
210
|
|
|
218
|
-
|
|
211
|
+
## Data Model
|
|
212
|
+
User: id, email, name, role
|
|
213
|
+
```
|
|
219
214
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
| Autoworkflow: Run Checks | Run all enforcement checks |
|
|
223
|
-
| Autoworkflow: TypeScript Check | TypeScript only |
|
|
224
|
-
| Autoworkflow: ESLint Fix | Fix all ESLint issues |
|
|
225
|
-
| Autoworkflow: List Rules | Show rule status |
|
|
226
|
-
| Dev Server | Start npm run dev |
|
|
227
|
-
| Quick Commit | Stage all + commit with prompt |
|
|
215
|
+
### Adjusting Gates
|
|
216
|
+
Edit `system/gates.md` to change what blocks progress.
|
|
228
217
|
|
|
229
|
-
|
|
218
|
+
### Adjusting Loops
|
|
219
|
+
Edit `system/loops.md` to change retry behavior.
|
|
230
220
|
|
|
231
|
-
|
|
221
|
+
---
|
|
232
222
|
|
|
233
|
-
|
|
234
|
-
- Show 3-tier suggestions (Required/Recommended/Optional)
|
|
235
|
-
- Ask for confirmation before implementing
|
|
236
|
-
- Use conventional commit messages
|
|
237
|
-
- Respect all enforcement rules
|
|
223
|
+
## Requirements
|
|
238
224
|
|
|
239
|
-
|
|
225
|
+
- VS Code with Claude Code extension
|
|
226
|
+
- That's it! No npm install needed for the workflow itself.
|
|
240
227
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
rm -rf .vscode # Only if you want to remove VSCode settings
|
|
247
|
-
```
|
|
228
|
+
If you want the verification commands (`npm run verify`, etc.) to work, you'll need:
|
|
229
|
+
- Node.js 18+
|
|
230
|
+
- TypeScript, ESLint, etc. in your project
|
|
231
|
+
|
|
232
|
+
---
|
|
248
233
|
|
|
249
234
|
## License
|
|
250
235
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* eslint.config.example.js
|
|
3
|
+
* AutoWorkflow ESLint Configuration
|
|
4
|
+
*
|
|
5
|
+
* This is a reference configuration that enforces the rules
|
|
6
|
+
* defined in CLAUDE.md and instructions/AI_RULES.md
|
|
7
|
+
*
|
|
8
|
+
* Copy to your project as: eslint.config.js
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import js from '@eslint/js'
|
|
12
|
+
import globals from 'globals'
|
|
13
|
+
import reactHooks from 'eslint-plugin-react-hooks'
|
|
14
|
+
import reactRefresh from 'eslint-plugin-react-refresh'
|
|
15
|
+
import tseslint from 'typescript-eslint'
|
|
16
|
+
|
|
17
|
+
export default tseslint.config(
|
|
18
|
+
{ ignores: ['dist', 'node_modules', 'coverage'] },
|
|
19
|
+
{
|
|
20
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
21
|
+
files: ['**/*.{ts,tsx}'],
|
|
22
|
+
languageOptions: {
|
|
23
|
+
ecmaVersion: 2020,
|
|
24
|
+
globals: globals.browser,
|
|
25
|
+
},
|
|
26
|
+
plugins: {
|
|
27
|
+
'react-hooks': reactHooks,
|
|
28
|
+
'react-refresh': reactRefresh,
|
|
29
|
+
},
|
|
30
|
+
rules: {
|
|
31
|
+
// ─────────────────────────────────────────────────────────────
|
|
32
|
+
// React Rules
|
|
33
|
+
// ─────────────────────────────────────────────────────────────
|
|
34
|
+
...reactHooks.configs.recommended.rules,
|
|
35
|
+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
|
36
|
+
|
|
37
|
+
// ─────────────────────────────────────────────────────────────
|
|
38
|
+
// TypeScript Rules (from AI_RULES.md)
|
|
39
|
+
// ─────────────────────────────────────────────────────────────
|
|
40
|
+
'@typescript-eslint/no-unused-vars': 'error',
|
|
41
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
42
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
43
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
44
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
45
|
+
'error',
|
|
46
|
+
{ prefer: 'type-imports' },
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
// ─────────────────────────────────────────────────────────────
|
|
50
|
+
// Console Rules (BLOCKING - from CLAUDE.md)
|
|
51
|
+
// ─────────────────────────────────────────────────────────────
|
|
52
|
+
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
53
|
+
|
|
54
|
+
// ─────────────────────────────────────────────────────────────
|
|
55
|
+
// Code Quality Rules (from AI_RULES.md)
|
|
56
|
+
// ─────────────────────────────────────────────────────────────
|
|
57
|
+
'max-lines': ['warn', { max: 300, skipBlankLines: true, skipComments: true }],
|
|
58
|
+
'max-lines-per-function': ['warn', { max: 75, skipBlankLines: true, skipComments: true }],
|
|
59
|
+
complexity: ['warn', 15],
|
|
60
|
+
'no-nested-ternary': 'error',
|
|
61
|
+
eqeqeq: ['error', 'always'],
|
|
62
|
+
|
|
63
|
+
// ─────────────────────────────────────────────────────────────
|
|
64
|
+
// Best Practices
|
|
65
|
+
// ─────────────────────────────────────────────────────────────
|
|
66
|
+
'prefer-const': 'error',
|
|
67
|
+
'no-var': 'error',
|
|
68
|
+
'object-shorthand': 'error',
|
|
69
|
+
'prefer-template': 'error',
|
|
70
|
+
'prefer-arrow-callback': 'error',
|
|
71
|
+
'no-duplicate-imports': 'error',
|
|
72
|
+
|
|
73
|
+
// ─────────────────────────────────────────────────────────────
|
|
74
|
+
// Accessibility Rules (optional but recommended)
|
|
75
|
+
// ─────────────────────────────────────────────────────────────
|
|
76
|
+
// Note: Install eslint-plugin-jsx-a11y for these
|
|
77
|
+
// 'jsx-a11y/alt-text': 'error',
|
|
78
|
+
// 'jsx-a11y/anchor-has-content': 'error',
|
|
79
|
+
// 'jsx-a11y/aria-props': 'error',
|
|
80
|
+
// 'jsx-a11y/click-events-have-key-events': 'warn',
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
)
|
package/hooks/commit-msg
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# commit-msg
|
|
3
|
+
# Git commit-msg hook that enforces conventional commit format
|
|
4
|
+
# Install: cp hooks/commit-msg .git/hooks/commit-msg && chmod +x .git/hooks/commit-msg
|
|
5
|
+
|
|
6
|
+
# Colors
|
|
7
|
+
RED='\033[0;31m'
|
|
8
|
+
GREEN='\033[0;32m'
|
|
9
|
+
YELLOW='\033[1;33m'
|
|
10
|
+
NC='\033[0m'
|
|
11
|
+
|
|
12
|
+
COMMIT_MSG_FILE=$1
|
|
13
|
+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE")
|
|
14
|
+
|
|
15
|
+
# Skip merge commits
|
|
16
|
+
if echo "$COMMIT_MSG" | grep -qE "^Merge"; then
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Skip revert commits
|
|
21
|
+
if echo "$COMMIT_MSG" | grep -qE "^Revert"; then
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
echo ""
|
|
26
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
27
|
+
echo "🔍 COMMIT MESSAGE VALIDATION"
|
|
28
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
29
|
+
echo ""
|
|
30
|
+
|
|
31
|
+
# ─────────────────────────────────────────────────────────────
|
|
32
|
+
# Conventional Commit Format
|
|
33
|
+
# ─────────────────────────────────────────────────────────────
|
|
34
|
+
# type(scope): description
|
|
35
|
+
#
|
|
36
|
+
# Valid types:
|
|
37
|
+
# feat - New feature
|
|
38
|
+
# fix - Bug fix
|
|
39
|
+
# docs - Documentation only
|
|
40
|
+
# style - Formatting, no code change
|
|
41
|
+
# refactor - Code change, no feature/fix
|
|
42
|
+
# perf - Performance improvement
|
|
43
|
+
# test - Adding tests
|
|
44
|
+
# build - Build system changes
|
|
45
|
+
# ci - CI/CD changes
|
|
46
|
+
# chore - Maintenance
|
|
47
|
+
# revert - Revert commit
|
|
48
|
+
|
|
49
|
+
VALID_TYPES="feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert"
|
|
50
|
+
|
|
51
|
+
# Pattern: type(scope): description
|
|
52
|
+
# - type is required
|
|
53
|
+
# - scope is optional (in parentheses)
|
|
54
|
+
# - colon and space are required
|
|
55
|
+
# - description is required
|
|
56
|
+
|
|
57
|
+
PATTERN="^($VALID_TYPES)(\([a-z0-9_-]+\))?: .+"
|
|
58
|
+
|
|
59
|
+
# Get first line (subject)
|
|
60
|
+
SUBJECT=$(echo "$COMMIT_MSG" | head -1)
|
|
61
|
+
|
|
62
|
+
echo "Message: \"$SUBJECT\""
|
|
63
|
+
echo ""
|
|
64
|
+
|
|
65
|
+
# ─────────────────────────────────────────────────────────────
|
|
66
|
+
# Validation
|
|
67
|
+
# ─────────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
VALID=1
|
|
70
|
+
ERRORS=""
|
|
71
|
+
|
|
72
|
+
# Check 1: Matches conventional format
|
|
73
|
+
if ! echo "$SUBJECT" | grep -qE "$PATTERN"; then
|
|
74
|
+
VALID=0
|
|
75
|
+
ERRORS="${ERRORS} ❌ Does not match format: type(scope): description\n"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
# Check 2: Subject length (max 72 characters)
|
|
79
|
+
SUBJECT_LENGTH=${#SUBJECT}
|
|
80
|
+
if [ $SUBJECT_LENGTH -gt 72 ]; then
|
|
81
|
+
VALID=0
|
|
82
|
+
ERRORS="${ERRORS} ❌ Subject too long: ${SUBJECT_LENGTH}/72 characters\n"
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
# Check 3: Subject doesn't end with period
|
|
86
|
+
if echo "$SUBJECT" | grep -qE "\.$"; then
|
|
87
|
+
VALID=0
|
|
88
|
+
ERRORS="${ERRORS} ❌ Subject should not end with a period\n"
|
|
89
|
+
fi
|
|
90
|
+
|
|
91
|
+
# Check 4: Subject starts with lowercase (after type)
|
|
92
|
+
if echo "$SUBJECT" | grep -qE "^[a-z]+(\([a-z0-9_-]+\))?: [A-Z]"; then
|
|
93
|
+
ERRORS="${ERRORS} ⚠️ Description should start with lowercase (optional)\n"
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
# ─────────────────────────────────────────────────────────────
|
|
97
|
+
# Result
|
|
98
|
+
# ─────────────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
if [ $VALID -eq 0 ]; then
|
|
101
|
+
echo -e "${RED}╔══════════════════════════════════════════════════════════════╗${NC}"
|
|
102
|
+
echo -e "${RED}║ ⛔ INVALID COMMIT MESSAGE ⛔ ║${NC}"
|
|
103
|
+
echo -e "${RED}╚══════════════════════════════════════════════════════════════╝${NC}"
|
|
104
|
+
echo ""
|
|
105
|
+
echo "Issues found:"
|
|
106
|
+
echo -e "$ERRORS"
|
|
107
|
+
echo ""
|
|
108
|
+
echo "Expected format:"
|
|
109
|
+
echo -e " ${YELLOW}type(scope): description${NC}"
|
|
110
|
+
echo ""
|
|
111
|
+
echo "Valid types:"
|
|
112
|
+
echo " feat New feature"
|
|
113
|
+
echo " fix Bug fix"
|
|
114
|
+
echo " docs Documentation"
|
|
115
|
+
echo " style Formatting"
|
|
116
|
+
echo " refactor Code restructure"
|
|
117
|
+
echo " perf Performance"
|
|
118
|
+
echo " test Tests"
|
|
119
|
+
echo " build Build system"
|
|
120
|
+
echo " ci CI/CD"
|
|
121
|
+
echo " chore Maintenance"
|
|
122
|
+
echo " revert Revert"
|
|
123
|
+
echo ""
|
|
124
|
+
echo "Examples:"
|
|
125
|
+
echo " feat(auth): add login page"
|
|
126
|
+
echo " fix(api): handle null response"
|
|
127
|
+
echo " refactor(utils): extract date helpers"
|
|
128
|
+
echo " docs: update README"
|
|
129
|
+
echo ""
|
|
130
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
131
|
+
exit 1
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
echo -e "${GREEN}✅ Commit message is valid${NC}"
|
|
135
|
+
echo ""
|
|
136
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
137
|
+
exit 0
|