ai-nexus 1.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.
Files changed (53) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +308 -0
  3. package/bin/ai-rules.cjs +120 -0
  4. package/config/agents/code-standards.md +81 -0
  5. package/config/agents/review-checklist.md +70 -0
  6. package/config/agents/security-rules.md +51 -0
  7. package/config/codex/AGENTS.md +69 -0
  8. package/config/commands/commit.md +34 -0
  9. package/config/commands/review.md +36 -0
  10. package/config/contexts/dev.md +20 -0
  11. package/config/hooks/README.md +110 -0
  12. package/config/hooks/semantic-router.cjs +236 -0
  13. package/config/rules/code-thresholds.md +12 -0
  14. package/config/rules/commit.md +49 -0
  15. package/config/rules/development-workflow.md +19 -0
  16. package/config/rules/essential.md +19 -0
  17. package/config/rules/pr.md +54 -0
  18. package/config/rules/security.md +19 -0
  19. package/config/settings.json +15 -0
  20. package/config/skills/react.md +42 -0
  21. package/config/skills/review.md +42 -0
  22. package/config/templates/basic/CLAUDE.md +23 -0
  23. package/config/templates/node-express/CLAUDE.md +75 -0
  24. package/config/templates/react-nextjs/CLAUDE.md +59 -0
  25. package/dist/commands/add.d.ts +5 -0
  26. package/dist/commands/add.js +69 -0
  27. package/dist/commands/doctor.d.ts +1 -0
  28. package/dist/commands/doctor.js +212 -0
  29. package/dist/commands/init-interactive.d.ts +1 -0
  30. package/dist/commands/init-interactive.js +397 -0
  31. package/dist/commands/init.d.ts +7 -0
  32. package/dist/commands/init.js +160 -0
  33. package/dist/commands/list.d.ts +1 -0
  34. package/dist/commands/list.js +63 -0
  35. package/dist/commands/remove.d.ts +1 -0
  36. package/dist/commands/remove.js +59 -0
  37. package/dist/commands/test.d.ts +5 -0
  38. package/dist/commands/test.js +94 -0
  39. package/dist/commands/uninstall.d.ts +6 -0
  40. package/dist/commands/uninstall.js +87 -0
  41. package/dist/commands/update.d.ts +6 -0
  42. package/dist/commands/update.js +163 -0
  43. package/dist/index.d.ts +11 -0
  44. package/dist/index.js +11 -0
  45. package/dist/utils/config-scanner.d.ts +20 -0
  46. package/dist/utils/config-scanner.js +112 -0
  47. package/dist/utils/files.d.ts +20 -0
  48. package/dist/utils/files.js +77 -0
  49. package/dist/utils/git.d.ts +15 -0
  50. package/dist/utils/git.js +58 -0
  51. package/dist/utils/semantic-router.d.ts +26 -0
  52. package/dist/utils/semantic-router.js +316 -0
  53. package/package.json +63 -0
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: Review Checklist
3
+ description: Code review checklist for quality, security, testing, and performance
4
+ keywords: [리뷰, review, 검토, 레뷰, checklist, code quality, security, testing, performance, documentation]
5
+ ---
6
+
7
+ # Review Checklist
8
+
9
+ ## Code Quality
10
+
11
+ ### Size Limits
12
+ - [ ] File size ≤ 300 LOC
13
+ - [ ] Function size ≤ 50 LOC
14
+ - [ ] Parameters ≤ 5
15
+ - [ ] Cyclomatic complexity ≤ 10
16
+ - [ ] Split/refactor if limits exceeded
17
+
18
+ ### Clean Code
19
+ - [ ] Intention-revealing names used
20
+ - [ ] Each function does one thing
21
+ - [ ] Side effects isolated to boundary layers
22
+ - [ ] Guard clauses preferred
23
+ - [ ] Constants symbolized (no hardcoding)
24
+ - [ ] Code structured as Input → Processing → Return
25
+
26
+ ## Functionality Review
27
+
28
+ - [ ] Correctly implements requirements
29
+ - [ ] Edge cases handled
30
+ - [ ] Error handling is appropriate
31
+ - [ ] No unintended side effects
32
+
33
+ ## Security Review
34
+
35
+ - [ ] No secrets in code
36
+ - [ ] Inputs validated and sanitized
37
+ - [ ] No SQL injection vulnerabilities
38
+ - [ ] No XSS vulnerabilities
39
+ - [ ] Authentication/authorization applied
40
+ - [ ] See [security-rules.md](./security-rules.md) for full checklist
41
+
42
+ ## Testing Review
43
+
44
+ - [ ] New code has tests
45
+ - [ ] Bug fixes have regression tests
46
+ - [ ] Tests are deterministic
47
+ - [ ] E2E has success and failure paths
48
+ - [ ] See [testing-rules.md](./testing-rules.md) for full checklist
49
+
50
+ ## Performance Review
51
+
52
+ - [ ] No obvious performance issues
53
+ - [ ] Database queries optimized
54
+ - [ ] No N+1 query problems
55
+ - [ ] Appropriate caching considered
56
+
57
+ ## Documentation Review
58
+
59
+ - [ ] Complex logic is documented
60
+ - [ ] API changes documented
61
+ - [ ] README updated if needed
62
+ - [ ] Breaking changes noted
63
+
64
+ ## Reviewer Actions
65
+
66
+ 1. **Read**: Understand the context and purpose
67
+ 2. **Verify**: Check against requirements
68
+ 3. **Test**: Run tests locally if needed
69
+ 4. **Comment**: Provide constructive feedback
70
+ 5. **Approve/Request Changes**: Make clear decision
@@ -0,0 +1,51 @@
1
+ ---
2
+ name: Security Rules
3
+ description: Secrets management, vulnerability prevention, authentication and authorization rules
4
+ keywords: [보안, security, 시큐리티, vulnerability, secrets, API keys, SQL injection, XSS, CSRF, authentication, authorization]
5
+ ---
6
+
7
+ # Security Rules
8
+
9
+ ## ABSOLUTE Rules (NEVER Violate)
10
+
11
+ ### NEVER
12
+
13
+ - Leave secrets (passwords/API keys/tokens) in code/logs/tickets/environment variables/.env files.
14
+ - Log sensitive data (PII/credit cards/SSN) in logs.
15
+ - Leave SQL injection, XSS, CSRF vulnerabilities.
16
+ - Commit secrets, API keys, tokens, or sensitive information.
17
+
18
+ ### ALWAYS
19
+
20
+ - Validate, normalize, and encode all inputs; use parameterized queries.
21
+ - Use HTTPS/TLS and apply principle of least privilege.
22
+ - Apply authentication/authorization to all endpoints.
23
+ - Set security headers (CSP, HSTS, X-Frame-Options).
24
+ - Regularly scan and update dependency vulnerabilities.
25
+
26
+ ## Security Violation Protocol
27
+
28
+ **Stop work immediately and request review upon security violations.**
29
+
30
+ ## Pre-commit Security Checklist
31
+
32
+ - [ ] No secrets (passwords/API keys/tokens) in code
33
+ - [ ] No sensitive data (PII/credit cards/SSN) in logs
34
+ - [ ] No SQL injection vulnerabilities
35
+ - [ ] No XSS vulnerabilities
36
+ - [ ] No CSRF vulnerabilities
37
+ - [ ] All inputs validated and sanitized
38
+ - [ ] Parameterized queries used for database operations
39
+ - [ ] Authentication/authorization applied to endpoints
40
+ - [ ] Development debug code removed
41
+ - [ ] Console logs cleaned up
42
+
43
+ ## Common Vulnerability Prevention
44
+
45
+ | Vulnerability | Prevention |
46
+ |--------------|------------|
47
+ | SQL Injection | Use parameterized queries, ORMs |
48
+ | XSS | Encode output, use CSP headers |
49
+ | CSRF | Use CSRF tokens, SameSite cookies |
50
+ | Auth Bypass | Validate on server, check permissions |
51
+ | Data Exposure | Minimize data, encrypt at rest/transit |
@@ -0,0 +1,69 @@
1
+ # AI 에이전트 가이드
2
+
3
+ 이 파일은 OpenAI Codex CLI가 자동으로 읽습니다.
4
+
5
+ ## 필수 규칙
6
+
7
+ ### 1. 먼저 읽기
8
+ 변경하기 전에 관련 파일을 먼저 읽는다. 코드를 이해하지 않고 수정하지 않는다.
9
+
10
+ ### 2. 작게 유지
11
+ - 작업, 커밋, PR의 범위를 최소화
12
+ - 한 번에 하나의 문제만 해결
13
+ - 300줄 이상의 변경은 분할
14
+
15
+ ### 3. 가정 기록
16
+ - Issue, PR, 코드 주석에 가정 사항 명시
17
+ - "왜" 이 결정을 했는지 기록
18
+
19
+ ### 4. 입력 검증
20
+ - 모든 외부 입력을 검증
21
+ - 출력을 적절히 인코딩/이스케이프
22
+
23
+ ### 5. 조기 추상화 금지
24
+ - 필요할 때까지 추상화하지 않음
25
+ - 3번 반복되기 전까지는 중복 허용
26
+
27
+ ### 6. 대안 비교
28
+ - 최소 2개 이상의 접근 방식 검토
29
+ - 가장 단순한 해결책 선택
30
+
31
+ ## 코드 임계값
32
+
33
+ | 항목 | 제한 |
34
+ |------|------|
35
+ | 파일 크기 | ≤ 300 LOC |
36
+ | 함수 길이 | ≤ 50 LOC |
37
+ | 파라미터 수 | ≤ 5개 |
38
+ | 순환 복잡도 | ≤ 10 |
39
+
40
+ ## 커밋 컨벤션
41
+
42
+ 형식: `<type>: [<ticket>] <subject>`
43
+
44
+ 타입:
45
+ - feat: 새로운 기능
46
+ - fix: 버그 수정
47
+ - refactor: 코드 개선
48
+ - style: 포맷팅
49
+ - docs: 문서
50
+ - test: 테스트
51
+ - chore: 기타
52
+
53
+ 규칙:
54
+ - 제목 50자 이내, 영어
55
+ - 이모지 사용 금지
56
+ - AI 표기 금지
57
+ - 자동 커밋 금지
58
+
59
+ ## 보안 규칙
60
+
61
+ ### 절대 금지
62
+ - 코드/로그에 비밀값 하드코딩
63
+ - SQL Injection, XSS, CSRF 취약점
64
+
65
+ ### 항상 실행
66
+ - 입력 검증
67
+ - 파라미터화된 쿼리
68
+ - 인증/인가 검사
69
+ - HTTPS 사용
@@ -0,0 +1,34 @@
1
+ ---
2
+ description: Git commit command - creates conventional commits
3
+ ---
4
+
5
+ # /commit
6
+
7
+ Create a git commit following conventional commit format.
8
+
9
+ ## Format
10
+
11
+ ```
12
+ <type>(<scope>): <subject>
13
+
14
+ <body>
15
+
16
+ <footer>
17
+ ```
18
+
19
+ ## Types
20
+
21
+ - `feat`: New feature
22
+ - `fix`: Bug fix
23
+ - `docs`: Documentation
24
+ - `style`: Formatting
25
+ - `refactor`: Code refactoring
26
+ - `test`: Tests
27
+ - `chore`: Maintenance
28
+
29
+ ## Rules
30
+
31
+ 1. Subject line ≤ 50 characters
32
+ 2. Body wrapped at 72 characters
33
+ 3. Use imperative mood ("add" not "added")
34
+ 4. Reference issues in footer
@@ -0,0 +1,36 @@
1
+ ---
2
+ description: Code review command - review diff, check security, performance, style, tests
3
+ ---
4
+
5
+ # Code Review Command
6
+
7
+ Review the code changes following these guidelines:
8
+
9
+ 1. **Read the diff carefully**
10
+ 2. **Check against review checklist**
11
+ 3. **Provide specific, actionable feedback**
12
+
13
+ ## Focus Areas
14
+
15
+ - Security vulnerabilities
16
+ - Performance issues
17
+ - Code style consistency
18
+ - Test coverage
19
+ - Documentation
20
+
21
+ ## Output Format
22
+
23
+ ```markdown
24
+ ## Summary
25
+ Brief overview of the changes
26
+
27
+ ## Issues Found
28
+ - [ ] Issue 1: Description + suggestion
29
+ - [ ] Issue 2: Description + suggestion
30
+
31
+ ## Good Patterns
32
+ - Pattern 1: Why it's good
33
+
34
+ ## Suggestions
35
+ - Optional improvements
36
+ ```
@@ -0,0 +1,20 @@
1
+ # Development Context
2
+
3
+ Mode: Active development
4
+ Focus: Implementation, coding, building features
5
+
6
+ ## Behavior
7
+ - Write code first, explain after
8
+ - Prefer working solutions over perfect solutions
9
+ - Run tests after changes
10
+ - Keep commits atomic
11
+
12
+ ## Priorities
13
+ 1. Get it working
14
+ 2. Get it right
15
+ 3. Get it clean
16
+
17
+ ## Tools to favor
18
+ - Edit, Write for code changes
19
+ - Bash for running tests/builds
20
+ - Grep, Glob for finding code
@@ -0,0 +1,110 @@
1
+ # Semantic Router Hook
2
+
3
+ The semantic router hook analyzes keywords in prompts to **dynamically activate only the necessary rules**.
4
+
5
+ ## How It Works
6
+
7
+ ```
8
+ 1. User enters a prompt
9
+ "Write a commit message"
10
+
11
+ 2. UserPromptSubmit hook executes
12
+
13
+ 3. Keyword analysis ("commit" detected)
14
+
15
+ 4. Dynamic rule file swap
16
+ - .claude/rules/commit.md ← activated
17
+ - .claude/rules/security.md → rules-inactive/ (deactivated)
18
+
19
+ 5. Claude Code loads only necessary rules
20
+
21
+ 6. Token savings!
22
+ ```
23
+
24
+ ## Installation
25
+
26
+ ### 1. Auto-install with ai-rules
27
+
28
+ ```bash
29
+ npx ai-rules init
30
+ # or
31
+ npx ai-rules install
32
+
33
+ # → Select hooks option
34
+ ```
35
+
36
+ ### 2. Manual Installation
37
+
38
+ ```bash
39
+ # Project installation
40
+ mkdir -p .claude/hooks
41
+ cp config/hooks/semantic-router.cjs .claude/hooks/
42
+
43
+ # Or global installation
44
+ mkdir -p ~/.claude/hooks
45
+ cp config/hooks/semantic-router.cjs ~/.claude/hooks/
46
+ ```
47
+
48
+ ### 3. Register in Claude Code settings.json
49
+
50
+ Add to `.claude/settings.json` or `~/.claude/settings.json`:
51
+
52
+ ```json
53
+ {
54
+ "hooks": {
55
+ "UserPromptSubmit": [
56
+ {
57
+ "matcher": "",
58
+ "hooks": [
59
+ {
60
+ "type": "command",
61
+ "command": "node .claude/hooks/semantic-router.cjs"
62
+ }
63
+ ]
64
+ }
65
+ ]
66
+ }
67
+ }
68
+ ```
69
+
70
+ ## Directory Structure
71
+
72
+ ```
73
+ ~/.ai-rules/config/ ← Original rules (all)
74
+ ~/.claude/rules/ ← Active rules (only needed)
75
+ ~/.claude/rules-inactive/ ← Inactive rules
76
+ ```
77
+
78
+ ## Keyword Mapping
79
+
80
+ | Keyword | Activated Rules |
81
+ |---------|-----------------|
82
+ | commit | rules/commit.md, commands/commit.md |
83
+ | pr, pull request, merge | rules/pr.md |
84
+ | security | rules/security.md, agents/security-rules.md |
85
+ | review | commands/review.md, skills/review.md |
86
+ | react, next, nextjs | skills/react.md |
87
+ | code | agents/code-standards.md |
88
+
89
+ ## Always Active Rules
90
+
91
+ - `rules/essential.md` - Always active (cannot be deactivated)
92
+
93
+ ## Environment Variables
94
+
95
+ ```bash
96
+ # Enable semantic router (default: true)
97
+ SEMANTIC_ROUTER_ENABLED=true
98
+
99
+ # API keys for AI-based routing (optional)
100
+ OPENAI_API_KEY=sk-xxx
101
+ ANTHROPIC_API_KEY=sk-ant-xxx
102
+ ```
103
+
104
+ ## Token Savings
105
+
106
+ | Method | Rules Loaded | Estimated Tokens |
107
+ |--------|--------------|------------------|
108
+ | Load all | All rules (15) | ~5000 tokens |
109
+ | Semantic Router | Only needed (2-3) | ~800 tokens |
110
+ | **Savings** | | **~84%** |
@@ -0,0 +1,236 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const https = require('https');
4
+
5
+ // Configuration - Use home directory's .claude
6
+ const os = require('os');
7
+ const RULES_DIR = path.join(os.homedir(), '.claude/rules');
8
+ const INACTIVE_DIR = path.join(os.homedir(), '.claude/rules-inactive');
9
+ const SEMANTIC_ROUTER_ENABLED = process.env.SEMANTIC_ROUTER_ENABLED !== 'false'; // Default to true unless explicitly disabled
10
+
11
+ // Map file names to keywords for fallback and management identification
12
+ const KEYWORD_MAP = {
13
+ 'testing.md': ['test', 'spec', 'jest', 'vitest', 'unit', 'e2e'],
14
+ 'typescript.md': ['ts', 'typescript', 'interface', 'type'],
15
+ 'react.md': ['react', 'component', 'jsx', 'tsx', 'hook'],
16
+ 'node.md': ['node', 'express', 'server', 'api'],
17
+ 'git.md': ['git', 'commit', 'merge', 'branch', 'rebase'],
18
+ 'security.md': ['security', 'auth', 'token', 'secret', 'password'],
19
+ 'performance.md': ['perf', 'performance', 'optimize', 'speed', 'memory'],
20
+ 'commit.md': ['commit', 'git', 'message', 'convention'],
21
+ };
22
+
23
+ const ALWAYS_ACTIVE = ['essential.md', 'security.md']; // Files that are always kept active
24
+
25
+ // Helper: Ensure directories exist
26
+ function ensureDirs() {
27
+ if (!fs.existsSync(RULES_DIR)) fs.mkdirSync(RULES_DIR, { recursive: true });
28
+ if (!fs.existsSync(INACTIVE_DIR)) fs.mkdirSync(INACTIVE_DIR, { recursive: true });
29
+ }
30
+
31
+ // Helper: Call Claude API for semantic analysis
32
+ async function analyzeWithClaude(prompt, availableFiles) {
33
+ const apiKey = process.env.ANTHROPIC_API_KEY;
34
+ if (!apiKey) return null;
35
+
36
+ const systemPrompt = `
37
+ You are a semantic router for a coding assistant. Your job is to select the most relevant rule files for a given user prompt.
38
+ Available files: ${availableFiles.join(', ')}
39
+ Return ONLY a JSON array of filenames that should be active. Do not include any explanation.
40
+ Example: ["react.md", "typescript.md"]
41
+ `;
42
+
43
+ const data = JSON.stringify({
44
+ model: 'claude-3-haiku-20240307',
45
+ max_tokens: 100,
46
+ system: systemPrompt,
47
+ messages: [{ role: 'user', content: prompt }]
48
+ });
49
+
50
+ const options = {
51
+ hostname: 'api.anthropic.com',
52
+ path: '/v1/messages',
53
+ method: 'POST',
54
+ headers: {
55
+ 'Content-Type': 'application/json',
56
+ 'x-api-key': apiKey,
57
+ 'anthropic-version': '2023-06-01'
58
+ }
59
+ };
60
+
61
+ return new Promise((resolve) => {
62
+ const req = https.request(options, (res) => {
63
+ let body = '';
64
+ res.on('data', (chunk) => body += chunk);
65
+ res.on('end', () => {
66
+ try {
67
+ const response = JSON.parse(body);
68
+ const content = response.content?.[0]?.text;
69
+ if (content) {
70
+ const files = JSON.parse(content);
71
+ resolve(files);
72
+ } else {
73
+ resolve(null);
74
+ }
75
+ } catch (e) {
76
+ resolve(null);
77
+ }
78
+ });
79
+ });
80
+ req.on('error', (e) => {
81
+ resolve(null);
82
+ });
83
+ req.write(data);
84
+ req.end();
85
+ });
86
+ }
87
+
88
+ // Helper: Call OpenAI API for semantic analysis
89
+ async function analyzeWithOpenAI(prompt, availableFiles) {
90
+ const apiKey = process.env.OPENAI_API_KEY;
91
+ if (!apiKey) return null;
92
+
93
+ const systemPrompt = `
94
+ You are a semantic router for a coding assistant. Your job is to select the most relevant rule files for a given user prompt.
95
+ Available files: ${availableFiles.join(', ')}
96
+ Return ONLY a JSON array of filenames that should be active. Do not include any explanation.
97
+ Example: ["react.md", "typescript.md"]
98
+ `;
99
+
100
+ const data = JSON.stringify({
101
+ model: 'gpt-4o-mini',
102
+ messages: [
103
+ { role: 'system', content: systemPrompt },
104
+ { role: 'user', content: prompt }
105
+ ],
106
+ temperature: 0,
107
+ response_format: { type: 'json_object' }
108
+ });
109
+
110
+ const options = {
111
+ hostname: 'api.openai.com',
112
+ path: '/v1/chat/completions',
113
+ method: 'POST',
114
+ headers: {
115
+ 'Content-Type': 'application/json',
116
+ 'Authorization': `Bearer ${apiKey}`
117
+ }
118
+ };
119
+
120
+ return new Promise((resolve) => {
121
+ const req = https.request(options, (res) => {
122
+ let body = '';
123
+ res.on('data', (chunk) => body += chunk);
124
+ res.on('end', () => {
125
+ try {
126
+ const response = JSON.parse(body);
127
+ const content = response.choices?.[0]?.message?.content;
128
+ if (content) {
129
+ // OpenAI JSON mode might return { "files": [...] } or just [...]
130
+ const parsed = JSON.parse(content);
131
+ const files = Array.isArray(parsed) ? parsed : (parsed.files || []);
132
+ resolve(files);
133
+ } else {
134
+ resolve(null);
135
+ }
136
+ } catch (e) {
137
+ resolve(null);
138
+ }
139
+ });
140
+ });
141
+ req.on('error', (e) => {
142
+ resolve(null);
143
+ });
144
+ req.write(data);
145
+ req.end();
146
+ });
147
+ }
148
+
149
+ // Helper: Keyword fallback
150
+ function selectByKeywords(prompt) {
151
+ const selected = [];
152
+ const lowerPrompt = prompt.toLowerCase();
153
+ for (const [file, keywords] of Object.entries(KEYWORD_MAP)) {
154
+ if (keywords.some(k => lowerPrompt.includes(k))) {
155
+ selected.push(file);
156
+ }
157
+ }
158
+ return selected;
159
+ }
160
+
161
+ // Main Router Logic
162
+ async function route(userPrompt) {
163
+ try {
164
+ ensureDirs();
165
+
166
+ // 1. Identify all managed files (active + inactive)
167
+ let activeFiles = [];
168
+ try { activeFiles = fs.readdirSync(RULES_DIR).filter(f => f.endsWith('.md')); } catch(e) {}
169
+ let inactiveFiles = [];
170
+ try { inactiveFiles = fs.readdirSync(INACTIVE_DIR).filter(f => f.endsWith('.md')); } catch(e) {}
171
+
172
+ // Managed files are those in KEYWORD_MAP
173
+ const allManagedFiles = Object.keys(KEYWORD_MAP);
174
+
175
+ // 2. Determine desired active files
176
+ let desiredFiles = [...ALWAYS_ACTIVE];
177
+
178
+ // Try AI routing if enabled
179
+ const available = [...new Set([...activeFiles, ...inactiveFiles, ...allManagedFiles])];
180
+
181
+ let aiSelected = null;
182
+ if (SEMANTIC_ROUTER_ENABLED) {
183
+ // Try OpenAI first
184
+ aiSelected = await analyzeWithOpenAI(userPrompt, available);
185
+
186
+ // If OpenAI fails or key is missing, try Claude
187
+ if (!aiSelected) {
188
+ aiSelected = await analyzeWithClaude(userPrompt, available);
189
+ }
190
+ }
191
+
192
+ if (aiSelected) {
193
+ desiredFiles.push(...aiSelected);
194
+ } else {
195
+ // Fallback to keywords
196
+ desiredFiles.push(...selectByKeywords(userPrompt));
197
+ }
198
+
199
+ // Deduplicate
200
+ desiredFiles = [...new Set(desiredFiles)];
201
+
202
+ // 3. Execution: Swap files
203
+ // Move unwanted managed files to inactive
204
+ for (const file of activeFiles) {
205
+ if (KEYWORD_MAP[file] && !desiredFiles.includes(file) && !ALWAYS_ACTIVE.includes(file)) {
206
+ const src = path.join(RULES_DIR, file);
207
+ const dest = path.join(INACTIVE_DIR, file);
208
+ if (fs.existsSync(src)) {
209
+ fs.renameSync(src, dest);
210
+ console.log(`[Router] Deactivated: ${file}`);
211
+ }
212
+ }
213
+ }
214
+
215
+ // Move wanted files to active
216
+ for (const file of desiredFiles) {
217
+ if (allManagedFiles.includes(file)) {
218
+ const inactivePath = path.join(INACTIVE_DIR, file);
219
+ const activePath = path.join(RULES_DIR, file);
220
+ if (fs.existsSync(inactivePath)) {
221
+ fs.renameSync(inactivePath, activePath);
222
+ console.log(`[Router] Activated: ${file}`);
223
+ }
224
+ }
225
+ }
226
+
227
+ } catch (error) {
228
+ console.error('[Semantic Router] Error:', error);
229
+ }
230
+ }
231
+
232
+ // Hook Entry Point
233
+ const userPrompt = process.argv[2];
234
+ if (userPrompt) {
235
+ route(userPrompt);
236
+ }
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Code size limits - file 300 LOC, function 50 LOC, parameters 5, complexity 10
3
+ ---
4
+
5
+ # Code Thresholds
6
+
7
+ ## Threshold Limits
8
+
9
+ * **File Length:** ≤ 300 LOC
10
+ * **Function Length:** ≤ 50 LOC
11
+ * **Parameters:** ≤ 5
12
+ * **Cyclomatic Complexity:** ≤ 10
@@ -0,0 +1,49 @@
1
+ ---
2
+ description: Git commit message format, types, and security checks for commits
3
+ ---
4
+
5
+ # Commit Convention
6
+
7
+ ## Format
8
+
9
+ ```
10
+ <type>: [<ticket>] <subject>
11
+
12
+ <body>
13
+ - Specific changes
14
+ - Key logic explanation
15
+ ```
16
+
17
+ ## Types
18
+
19
+ - feat: New feature
20
+ - fix: Bug fix
21
+ - refactor: Code improvement (no functionality change)
22
+ - style: Formatting (no logic change)
23
+ - docs: Documentation
24
+ - test: Tests
25
+ - chore: Build scripts, package manager, etc.
26
+
27
+ ## Rules
28
+
29
+ - Title under 50 chars, in English
30
+ - Body explains changes and reasons
31
+ - NO emojis
32
+ - NO AI attribution markers (Co-Authored-By, Generated with, etc.)
33
+ - NO auto-commit without user request
34
+
35
+ ## Security Check
36
+
37
+ - NEVER: Commit secrets (passwords/API keys/tokens)
38
+ - NEVER: Commit sensitive data (PII/credit cards)
39
+ - Stop immediately if secrets found
40
+
41
+ ## Example
42
+
43
+ ```
44
+ feat: [PP-1234] Add user authentication
45
+
46
+ - Implement JWT token validation
47
+ - Add login/logout endpoints
48
+ - Add refresh token rotation
49
+ ```