specialist-agent 2.9.0 → 2.10.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/.opencode/INSTALL.md +74 -79
- package/.opencode/opencode.json +141 -0
- package/agents/architect.md +23 -14
- package/cli/architectures.mjs +713 -0
- package/cli/detect-architecture.mjs +752 -0
- package/cli/generate-architecture.mjs +1096 -0
- package/cli/index.mjs +371 -14
- package/cli/recommend-architecture.mjs +870 -0
- package/hooks/native/auto-dispatch.mjs +8 -2
- package/hooks/native/security-config.json +3 -0
- package/hooks/native/security-guard.mjs +41 -4
- package/package.json +1 -1
- package/skills/migrate-architecture/SKILL.md +242 -0
|
@@ -57,7 +57,7 @@ const INTENT_MAP = {
|
|
|
57
57
|
scout: { phrases: ['analyze project', 'project analysis', 'quick scan'], keywords: ['analyze', 'scan', 'overview', 'analysis'], weight: 1 },
|
|
58
58
|
explorer: { phrases: ['explore codebase', 'understand code', 'how does this work'], keywords: ['explore', 'understand', 'codebase', 'how does'], weight: 1 },
|
|
59
59
|
memory: { phrases: ['remember this', 'save decision', 'recall decision', 'session memory'], keywords: ['remember', 'recall', 'memory', 'decision log'], weight: 1.5 },
|
|
60
|
-
architect: { phrases: ['architecture migration', 'monolith to microservices', 'system redesign', 'clean architecture', 'hexagonal architecture', 'migrate architecture'], keywords: ['architecture', 'hexagonal', 'ddd', 'cqrs', 'modular monolith', 'bounded context', 'strangler fig'], weight: 1.5 },
|
|
60
|
+
architect: { phrases: ['architecture migration', 'monolith to microservices', 'system redesign', 'clean architecture', 'hexagonal architecture', 'migrate architecture', 'detect architecture', 'change architecture', 'improve architecture', 'modular monolith', 'domain driven design', 'feature sliced design', 'ports and adapters'], keywords: ['architecture', 'hexagonal', 'ddd', 'cqrs', 'modular monolith', 'bounded context', 'strangler fig', 'modular', 'fsd', 'clean arch', 'ports adapters'], weight: 1.5 },
|
|
61
61
|
ripple: { phrases: ['impact analysis', 'cascading effects', 'what will break', 'change impact'], keywords: ['impact', 'ripple', 'cascade', 'breaking change', 'downstream'], weight: 1.5 },
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -187,7 +187,13 @@ async function main() {
|
|
|
187
187
|
|
|
188
188
|
if (match) {
|
|
189
189
|
const output = {
|
|
190
|
-
additionalContext: `Specialist Agent suggests: @${match.agent}
|
|
190
|
+
additionalContext: `Specialist Agent suggests: @${match.agent} — ${match.description}. Mention @${match.agent} in your prompt to activate it. Agents provide domain expertise, structured workflows, and verification — always prefer them over generic prompts.`,
|
|
191
|
+
};
|
|
192
|
+
process.stdout.write(JSON.stringify(output));
|
|
193
|
+
} else {
|
|
194
|
+
// Reinforce agent usage even when no specific match is found
|
|
195
|
+
const output = {
|
|
196
|
+
additionalContext: 'Tip: Specialist Agent has 27+ agents for this project. Use @builder to create, @reviewer to review, @doctor to debug, @planner to plan, @tdd for test-driven development. Agents deliver better results than generic prompts.',
|
|
191
197
|
};
|
|
192
198
|
process.stdout.write(JSON.stringify(output));
|
|
193
199
|
}
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"pipe-to-shell": { "enabled": true, "severity": "HIGH" },
|
|
14
14
|
"chmod-777": { "enabled": true, "severity": "HIGH" },
|
|
15
15
|
"env-file-read": { "enabled": true, "severity": "MEDIUM" },
|
|
16
|
+
"ssh-key-access": { "enabled": true, "severity": "MEDIUM" },
|
|
17
|
+
"aws-credentials": { "enabled": true, "severity": "MEDIUM" },
|
|
18
|
+
"cloud-credentials": { "enabled": true, "severity": "MEDIUM" },
|
|
16
19
|
"env-file-write": { "enabled": true, "severity": "MEDIUM" },
|
|
17
20
|
"inline-secrets": { "enabled": true, "severity": "MEDIUM" }
|
|
18
21
|
},
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { readFileSync } from 'fs';
|
|
16
|
-
import { join, dirname, resolve
|
|
16
|
+
import { join, dirname, resolve } from 'path';
|
|
17
17
|
import { fileURLToPath } from 'url';
|
|
18
18
|
|
|
19
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -129,18 +129,55 @@ const RULES = [
|
|
|
129
129
|
id: 'env-file-read',
|
|
130
130
|
severity: 'MEDIUM',
|
|
131
131
|
test: (cmd) => {
|
|
132
|
+
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type)\b/;
|
|
132
133
|
// Block reading .env files (but allow .env.example, .env.sample, .env.template)
|
|
133
|
-
if (
|
|
134
|
+
if (readCmds.test(cmd) && /\.env\b/.test(cmd)) {
|
|
134
135
|
if (/\.env\.(example|sample|template|test|development)/.test(cmd)) return false;
|
|
135
|
-
if (/\.env\.local/.test(cmd)) return true; // .env.local has secrets
|
|
136
136
|
return true;
|
|
137
137
|
}
|
|
138
138
|
// Block reading private keys
|
|
139
|
-
if (
|
|
139
|
+
if (readCmds.test(cmd) && /\.(pem|key|p12|pfx)\b/.test(cmd)) return true;
|
|
140
140
|
return false;
|
|
141
141
|
},
|
|
142
142
|
message: 'BLOCKED [MEDIUM]: Reading sensitive file (.env or private key) via shell.\nUse the Read tool instead, which provides better access control.\nAllowed: .env.example, .env.sample, .env.template'
|
|
143
143
|
},
|
|
144
|
+
{
|
|
145
|
+
id: 'ssh-key-access',
|
|
146
|
+
severity: 'MEDIUM',
|
|
147
|
+
test: (cmd) => {
|
|
148
|
+
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type|cp|scp)\b/;
|
|
149
|
+
if (!readCmds.test(cmd)) return false;
|
|
150
|
+
return /[~\/]\.ssh\/(id_|authorized_keys|known_hosts|config)/.test(cmd);
|
|
151
|
+
},
|
|
152
|
+
message: 'BLOCKED [MEDIUM]: Accessing SSH keys or config via shell.\nSSH keys are sensitive credentials that should never be read or copied by AI agents.\nIf you need to configure SSH, do it manually in your terminal.'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: 'aws-credentials',
|
|
156
|
+
severity: 'MEDIUM',
|
|
157
|
+
test: (cmd) => {
|
|
158
|
+
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type|cp)\b/;
|
|
159
|
+
if (!readCmds.test(cmd)) return false;
|
|
160
|
+
return /[~\/]\.aws\/(credentials|config)/.test(cmd);
|
|
161
|
+
},
|
|
162
|
+
message: 'BLOCKED [MEDIUM]: Accessing AWS credentials via shell.\nAWS credentials contain secret access keys. Use environment variables ($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY) or IAM roles instead.'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: 'cloud-credentials',
|
|
166
|
+
severity: 'MEDIUM',
|
|
167
|
+
test: (cmd) => {
|
|
168
|
+
const readCmds = /\b(cat|less|more|head|tail|sed|awk|grep|bat|type|cp)\b/;
|
|
169
|
+
if (!readCmds.test(cmd)) return false;
|
|
170
|
+
return /application_default_credentials\.json/.test(cmd) ||
|
|
171
|
+
/service[_-]account[_-]?key.*\.json/.test(cmd) ||
|
|
172
|
+
/[~\/]\.azure\/(credentials|config|accessTokens)/.test(cmd) ||
|
|
173
|
+
/[~\/]\.kube\/config/.test(cmd) ||
|
|
174
|
+
/[~\/]\.docker\/config\.json/.test(cmd) ||
|
|
175
|
+
/[~\/]\.npmrc/.test(cmd) ||
|
|
176
|
+
/[~\/]\.netrc/.test(cmd) ||
|
|
177
|
+
/[~\/]\.pgpass/.test(cmd);
|
|
178
|
+
},
|
|
179
|
+
message: 'BLOCKED [MEDIUM]: Accessing cloud/service credentials via shell.\nThese files contain sensitive tokens and secrets. Use environment variables or secret managers instead.'
|
|
180
|
+
},
|
|
144
181
|
{
|
|
145
182
|
id: 'env-file-write',
|
|
146
183
|
severity: 'MEDIUM',
|
package/package.json
CHANGED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migrate-architecture
|
|
3
|
+
description: "Use when transforming a project's architecture pattern - e.g., Flat to Modular, MVC to Clean Architecture, Monolith to Modular Monolith."
|
|
4
|
+
user-invocable: true
|
|
5
|
+
argument-hint: "[current-architecture] to [target-architecture] [variant: full|lite] [scope: file|module|project]"
|
|
6
|
+
allowed-tools: Read, Write, Edit, Bash, Glob, Grep
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# /migrate-architecture - Architecture Pattern Migration
|
|
10
|
+
|
|
11
|
+
Migrate a project's architecture from one pattern to another while preserving all functionality.
|
|
12
|
+
|
|
13
|
+
**Arguments:** $ARGUMENTS (e.g., "flat to modular full project", "mvc to clean lite src/modules/auth")
|
|
14
|
+
|
|
15
|
+
## Supported Architecture Patterns
|
|
16
|
+
|
|
17
|
+
### Frontend
|
|
18
|
+
|
|
19
|
+
| Pattern | Description |
|
|
20
|
+
|---------|-------------|
|
|
21
|
+
| Flat / Component-Driven | Single components/ dir, minimal structure |
|
|
22
|
+
| Modular (Feature-Based) | Vertical slicing by feature with services/adapters/types |
|
|
23
|
+
| Feature-Sliced Design (FSD) | Strict layered: app > pages > features > entities > shared |
|
|
24
|
+
| Atomic Design | Components by granularity: atoms > molecules > organisms |
|
|
25
|
+
| Clean Architecture | Domain > Use Cases > Adapters > Frameworks |
|
|
26
|
+
| Hexagonal (Ports & Adapters) | Core with ports, infrastructure in adapters |
|
|
27
|
+
|
|
28
|
+
### Backend / Fullstack
|
|
29
|
+
|
|
30
|
+
| Pattern | Description |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| MVC / Layered | Horizontal: controllers, services, repositories |
|
|
33
|
+
| Modular Monolith | Single deployment, strict module boundaries |
|
|
34
|
+
| Clean Architecture | Concentric layers, dependency rule inward |
|
|
35
|
+
| Hexagonal | Ports & Adapters, domain isolated |
|
|
36
|
+
| DDD | Bounded contexts, aggregates, domain events |
|
|
37
|
+
| CQRS | Separate command/query paths |
|
|
38
|
+
| Event-Driven | Async communication via events |
|
|
39
|
+
| Microservices | Independent services, own databases |
|
|
40
|
+
|
|
41
|
+
### Variants
|
|
42
|
+
|
|
43
|
+
| Variant | Description |
|
|
44
|
+
|---------|-------------|
|
|
45
|
+
| **Full** | Complete implementation with all layers and patterns |
|
|
46
|
+
| **Lite (Simplified)** | Fewer layers, same principles. For smaller teams |
|
|
47
|
+
|
|
48
|
+
## Workflow
|
|
49
|
+
|
|
50
|
+
### Phase 1: Assessment
|
|
51
|
+
|
|
52
|
+
1. **Read** `docs/ARCHITECTURE.md` if it exists
|
|
53
|
+
2. **Scan** the project structure:
|
|
54
|
+
- List all directories under `src/` (or root if no `src/`)
|
|
55
|
+
- Identify current architecture pattern by matching directory names
|
|
56
|
+
- Count modules/features/components
|
|
57
|
+
- Check for barrel exports (index.ts)
|
|
58
|
+
- Check import patterns between directories
|
|
59
|
+
3. **Identify** the current architecture pattern and confidence level
|
|
60
|
+
4. **Report** findings:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
── Architecture Assessment ──
|
|
64
|
+
Current: [detected pattern] (confidence: high/medium/low)
|
|
65
|
+
Target: [requested pattern] ([variant])
|
|
66
|
+
Scope: [project | specific module/path]
|
|
67
|
+
Estimated files to move: X
|
|
68
|
+
Estimated files to create: X
|
|
69
|
+
Risk: low/medium/high
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
5. **Ask** for confirmation before proceeding
|
|
73
|
+
|
|
74
|
+
### Phase 2: Planning
|
|
75
|
+
|
|
76
|
+
1. **Generate** the target directory structure based on:
|
|
77
|
+
- Target architecture pattern
|
|
78
|
+
- Detected framework (React, Vue, Next.js, etc.)
|
|
79
|
+
- Chosen variant (Full or Lite)
|
|
80
|
+
2. **Map** existing files to their new locations:
|
|
81
|
+
- Components → appropriate layer/module
|
|
82
|
+
- Services → service layer or domain layer
|
|
83
|
+
- Types → types layer
|
|
84
|
+
- Tests → co-located __tests__/
|
|
85
|
+
- Utils/Helpers → shared/
|
|
86
|
+
3. **Identify** new files to create:
|
|
87
|
+
- Barrel exports (index.ts) per module
|
|
88
|
+
- Adapter layer (if Full variant)
|
|
89
|
+
- Type separation (.types.ts + .contracts.ts for Full)
|
|
90
|
+
4. **Create** migration plan with ordered steps:
|
|
91
|
+
- Phase 2a: Create target directory structure
|
|
92
|
+
- Phase 2b: Move files (least coupled first)
|
|
93
|
+
- Phase 2c: Create new files (barrel exports, adapters)
|
|
94
|
+
- Phase 2d: Update imports
|
|
95
|
+
- Phase 2e: Validate
|
|
96
|
+
|
|
97
|
+
### Phase 3: Execution
|
|
98
|
+
|
|
99
|
+
Execute the migration plan step by step:
|
|
100
|
+
|
|
101
|
+
1. **Create** target directory structure (mkdir -p)
|
|
102
|
+
2. **Move** files one module at a time:
|
|
103
|
+
- Start with the LEAST coupled module
|
|
104
|
+
- Move component files
|
|
105
|
+
- Move service files
|
|
106
|
+
- Move type files
|
|
107
|
+
- Move test files
|
|
108
|
+
3. **Create** new architectural files:
|
|
109
|
+
- Barrel exports (index.ts) for each module
|
|
110
|
+
- Adapter files (if migrating to Modular Full, Clean, or Hexagonal)
|
|
111
|
+
- Type separation files (.types.ts + .contracts.ts)
|
|
112
|
+
4. **Update** all import paths:
|
|
113
|
+
- Use Grep to find all imports referencing moved files
|
|
114
|
+
- Update each import to the new path
|
|
115
|
+
- Use barrel exports where possible
|
|
116
|
+
5. **Generate** or update `docs/ARCHITECTURE.md` for the target pattern
|
|
117
|
+
|
|
118
|
+
### Phase 4: Validation
|
|
119
|
+
|
|
120
|
+
1. **Check** directory structure matches target pattern
|
|
121
|
+
2. **Verify** no broken imports:
|
|
122
|
+
```bash
|
|
123
|
+
npx tsc --noEmit 2>&1 | head -50
|
|
124
|
+
```
|
|
125
|
+
3. **Validate** import rules:
|
|
126
|
+
- Modules don't import from each other (Modular)
|
|
127
|
+
- Dependencies point inward (Clean/Hexagonal)
|
|
128
|
+
- FSD layers import top-down only
|
|
129
|
+
4. **Run** tests if they exist:
|
|
130
|
+
```bash
|
|
131
|
+
npm test 2>&1 | tail -20
|
|
132
|
+
```
|
|
133
|
+
5. **Report** results:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
── Architecture Migration Complete ──
|
|
137
|
+
From: [source pattern]
|
|
138
|
+
To: [target pattern] ([variant])
|
|
139
|
+
|
|
140
|
+
Files moved: X
|
|
141
|
+
Files created: X
|
|
142
|
+
Imports updated: X
|
|
143
|
+
Barrel exports created: X
|
|
144
|
+
|
|
145
|
+
Validation:
|
|
146
|
+
TypeScript: ✓ compiles
|
|
147
|
+
Import rules: ✓ no violations
|
|
148
|
+
Tests: ✓ passing (or N/A)
|
|
149
|
+
|
|
150
|
+
docs/ARCHITECTURE.md: ✓ generated
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Migration Strategies by Pattern
|
|
154
|
+
|
|
155
|
+
### Flat → Modular
|
|
156
|
+
|
|
157
|
+
1. Group components by domain/feature
|
|
158
|
+
2. Create `modules/[feature]/components/` for each group
|
|
159
|
+
3. Move related services, types into module
|
|
160
|
+
4. Create index.ts for each module
|
|
161
|
+
5. Move shared components to `shared/components/`
|
|
162
|
+
|
|
163
|
+
### MVC → Modular
|
|
164
|
+
|
|
165
|
+
1. For each controller+service pair, create a module
|
|
166
|
+
2. Move controller logic to module's hooks/composables
|
|
167
|
+
3. Move models to module's types/
|
|
168
|
+
4. Create service layer in each module
|
|
169
|
+
5. Move shared middleware to shared/
|
|
170
|
+
|
|
171
|
+
### MVC → Clean Architecture
|
|
172
|
+
|
|
173
|
+
1. Extract domain entities (pure business objects, no framework deps)
|
|
174
|
+
2. Create use-case classes for each business operation
|
|
175
|
+
3. Define port interfaces for external dependencies
|
|
176
|
+
4. Move database/HTTP code to infrastructure/ as adapter implementations
|
|
177
|
+
5. Wire use cases to ports in the composition root
|
|
178
|
+
|
|
179
|
+
### Modular → Clean Architecture
|
|
180
|
+
|
|
181
|
+
1. For each module, add domain/ and application/ sub-layers
|
|
182
|
+
2. Extract entities from services into domain/entities/
|
|
183
|
+
3. Create use-cases from service methods
|
|
184
|
+
4. Define port interfaces for external deps
|
|
185
|
+
5. Move HTTP/DB code to infrastructure/
|
|
186
|
+
|
|
187
|
+
### Modular → Hexagonal
|
|
188
|
+
|
|
189
|
+
1. Create core/ with domain/ and ports/
|
|
190
|
+
2. Extract entities to core/domain/
|
|
191
|
+
3. Define driving ports (use case interfaces) in core/ports/in/
|
|
192
|
+
4. Define driven ports (repository interfaces) in core/ports/out/
|
|
193
|
+
5. Move components to adapters/in/web/
|
|
194
|
+
6. Move HTTP/DB to adapters/out/
|
|
195
|
+
|
|
196
|
+
### Modular → Feature-Sliced Design
|
|
197
|
+
|
|
198
|
+
1. Map modules to FSD layers:
|
|
199
|
+
- Shared components → shared/ui/
|
|
200
|
+
- Feature-specific → features/[feature]/
|
|
201
|
+
- Business entities → entities/[entity]/
|
|
202
|
+
- Page compositions → pages/
|
|
203
|
+
2. Enforce top-down import rules
|
|
204
|
+
3. Split cross-cutting features into widgets/
|
|
205
|
+
|
|
206
|
+
### Modular → DDD
|
|
207
|
+
|
|
208
|
+
1. Identify bounded contexts from modules
|
|
209
|
+
2. Add aggregates/ with aggregate roots
|
|
210
|
+
3. Extract value objects from entity properties
|
|
211
|
+
4. Create domain events for state changes
|
|
212
|
+
5. Add command/query handlers in application layer
|
|
213
|
+
|
|
214
|
+
### Any → Modular Monolith
|
|
215
|
+
|
|
216
|
+
1. Start with Modular structure
|
|
217
|
+
2. Add domain/application/infrastructure layers per module
|
|
218
|
+
3. Enforce module boundaries with barrel exports
|
|
219
|
+
4. Validate no cross-module internal imports
|
|
220
|
+
5. Each module = potential future microservice
|
|
221
|
+
|
|
222
|
+
## Anti-Patterns to Avoid
|
|
223
|
+
|
|
224
|
+
| Mistake | Correct Approach |
|
|
225
|
+
|---------|-----------------|
|
|
226
|
+
| Moving files without updating imports | Use TypeScript compiler to verify after each move |
|
|
227
|
+
| Creating empty architectural layers | Only create layers with actual content |
|
|
228
|
+
| Migrating everything at once | One module at a time, least coupled first |
|
|
229
|
+
| Skipping barrel exports | Always create index.ts - it enforces boundaries |
|
|
230
|
+
| Copying patterns blindly | Adapt to the project's actual needs (Full vs Lite) |
|
|
231
|
+
| Ignoring existing tests | Move tests alongside their source files |
|
|
232
|
+
|
|
233
|
+
## Rules
|
|
234
|
+
|
|
235
|
+
1. ALWAYS assess before migrating - understand current state first
|
|
236
|
+
2. NEVER migrate without user confirmation
|
|
237
|
+
3. ONE module at a time - never parallel moves
|
|
238
|
+
4. VALIDATE after each module migration (TypeScript + imports)
|
|
239
|
+
5. PRESERVE all existing tests (move them, don't delete)
|
|
240
|
+
6. CREATE docs/ARCHITECTURE.md for the target pattern
|
|
241
|
+
7. USE the appropriate variant (Full for established teams, Lite for small teams)
|
|
242
|
+
8. If TypeScript errors appear, FIX them before continuing
|