@orchestrator-claude/cli 1.7.2 → 1.7.3
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/templates/base/.orchestrator/patterns/legacy/README.md +360 -0
- package/dist/templates/base/.orchestrator/patterns/legacy/php/laravel.patterns.json +396 -0
- package/dist/templates/base/.orchestrator/templates/legacy/README.md +296 -0
- package/dist/templates/base/.orchestrator/templates/legacy/analysis-report.md.hbs +342 -0
- package/dist/templates/base/.orchestrator/templates/legacy/api-spec.yaml.hbs +263 -0
- package/dist/templates/base/.orchestrator/templates/legacy/business-rules.md.hbs +449 -0
- package/dist/templates/base/.orchestrator/templates/legacy/database-schema.md.hbs +356 -0
- package/dist/templates/base/.orchestrator/templates/legacy/dead-code-report.md.hbs +330 -0
- package/dist/templates/base/.orchestrator/templates/legacy/discovery-report.md.hbs +267 -0
- package/dist/templates/base/.orchestrator/templates/legacy/final-report.md.hbs +451 -0
- package/dist/templates/base/.orchestrator/templates/legacy/inventory.json.schema +346 -0
- package/dist/templates/base/.orchestrator/templates/legacy/migration-roadmap.md.hbs +571 -0
- package/dist/templates/base/.orchestrator/templates/legacy/tech-debt.md.hbs +412 -0
- package/dist/templates/base/claude/agents/api-extractor.md +665 -0
- package/dist/templates/base/claude/agents/business-rule-miner.md +734 -0
- package/dist/templates/base/claude/agents/code-archaeologist.md +715 -0
- package/dist/templates/base/claude/agents/legacy-discoverer.md +578 -0
- package/dist/templates/base/claude/agents/legacy-synthesizer.md +1097 -0
- package/dist/templates/base/claude/agents/schema-extractor.md +767 -0
- package/dist/templates/workflows/README.md +137 -0
- package/dist/templates/workflows/bug-fix.json +73 -0
- package/dist/templates/workflows/feature-development.json +87 -0
- package/dist/templates/workflows/legacy-analysis.json +288 -0
- package/dist/templates/workflows/refactoring.json +73 -0
- package/package.json +1 -1
- package/templates/base/.orchestrator/patterns/legacy/README.md +360 -0
- package/templates/base/.orchestrator/patterns/legacy/php/laravel.patterns.json +396 -0
- package/templates/base/.orchestrator/templates/legacy/README.md +296 -0
- package/templates/base/.orchestrator/templates/legacy/analysis-report.md.hbs +342 -0
- package/templates/base/.orchestrator/templates/legacy/api-spec.yaml.hbs +263 -0
- package/templates/base/.orchestrator/templates/legacy/business-rules.md.hbs +449 -0
- package/templates/base/.orchestrator/templates/legacy/database-schema.md.hbs +356 -0
- package/templates/base/.orchestrator/templates/legacy/dead-code-report.md.hbs +330 -0
- package/templates/base/.orchestrator/templates/legacy/discovery-report.md.hbs +267 -0
- package/templates/base/.orchestrator/templates/legacy/final-report.md.hbs +451 -0
- package/templates/base/.orchestrator/templates/legacy/inventory.json.schema +346 -0
- package/templates/base/.orchestrator/templates/legacy/migration-roadmap.md.hbs +571 -0
- package/templates/base/.orchestrator/templates/legacy/tech-debt.md.hbs +412 -0
- package/templates/base/claude/agents/api-extractor.md +665 -0
- package/templates/base/claude/agents/business-rule-miner.md +734 -0
- package/templates/base/claude/agents/code-archaeologist.md +715 -0
- package/templates/base/claude/agents/legacy-discoverer.md +578 -0
- package/templates/base/claude/agents/legacy-synthesizer.md +1097 -0
- package/templates/base/claude/agents/schema-extractor.md +767 -0
- package/templates/workflows/README.md +137 -0
- package/templates/workflows/bug-fix.json +73 -0
- package/templates/workflows/feature-development.json +87 -0
- package/templates/workflows/legacy-analysis.json +288 -0
- package/templates/workflows/refactoring.json +73 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# Legacy Analysis Pattern Sets
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0
|
|
4
|
+
**Created:** 2026-01-23
|
|
5
|
+
**RFC:** RFC-004-LEGACY-ANALYSIS-WORKFLOW.md
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Purpose
|
|
10
|
+
|
|
11
|
+
Pattern sets provide deterministic, regex-based detection for legacy codebases. Each pattern set targets a specific language/framework combination and defines how to identify and catalog code assets.
|
|
12
|
+
|
|
13
|
+
**Design Philosophy:** ~80% deterministic (patterns) + ~20% heuristic (LLM fallback)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Pattern Set Schema
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"id": "language-framework",
|
|
22
|
+
"stack": {
|
|
23
|
+
"language": "php",
|
|
24
|
+
"framework": "laravel",
|
|
25
|
+
"versions": ["8.x", "9.x", "10.x", "11.x"]
|
|
26
|
+
},
|
|
27
|
+
"detection": {
|
|
28
|
+
"indicators": [
|
|
29
|
+
{
|
|
30
|
+
"type": "file | directory | content",
|
|
31
|
+
"path": "relative/path",
|
|
32
|
+
"contains": "optional-string-match",
|
|
33
|
+
"confidence": 0.0-1.0
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"minConfidence": 0.8
|
|
37
|
+
},
|
|
38
|
+
"patterns": {
|
|
39
|
+
"asset-type": {
|
|
40
|
+
"files": ["glob-pattern"],
|
|
41
|
+
"regex": ["regex-pattern"],
|
|
42
|
+
"extractors": {
|
|
43
|
+
"name": "capture-group-index",
|
|
44
|
+
"metadata": "optional-additional-data"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Detection System
|
|
54
|
+
|
|
55
|
+
### Confidence Scoring
|
|
56
|
+
|
|
57
|
+
Detection indicators are weighted by confidence scores:
|
|
58
|
+
|
|
59
|
+
| Confidence | Meaning | Example |
|
|
60
|
+
|------------|---------|---------|
|
|
61
|
+
| 0.95-1.0 | Definitive indicator | `composer.json` contains `laravel/framework` |
|
|
62
|
+
| 0.80-0.94 | Strong indicator | `artisan` file exists at root |
|
|
63
|
+
| 0.60-0.79 | Moderate indicator | `app/Http/Controllers` directory exists |
|
|
64
|
+
| 0.40-0.59 | Weak indicator | `.php` files present |
|
|
65
|
+
| 0.0-0.39 | Very weak | Generic directory structure |
|
|
66
|
+
|
|
67
|
+
**Total confidence** = sum of matched indicators' confidence scores (capped at 1.0)
|
|
68
|
+
|
|
69
|
+
**Threshold**: Stack is detected if total confidence >= `minConfidence` (default: 0.8)
|
|
70
|
+
|
|
71
|
+
### Fallback Behavior
|
|
72
|
+
|
|
73
|
+
If no pattern set reaches `minConfidence`:
|
|
74
|
+
1. Use heuristic LLM-based detection
|
|
75
|
+
2. Analyze file extensions, directory structure, imports
|
|
76
|
+
3. Generate generic inventory with lower precision
|
|
77
|
+
4. Warn user about reduced accuracy
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Pattern Types
|
|
82
|
+
|
|
83
|
+
### 1. File Indicators
|
|
84
|
+
|
|
85
|
+
Detect specific files at known locations:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"type": "file",
|
|
90
|
+
"path": "artisan",
|
|
91
|
+
"confidence": 0.9
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### 2. Content Indicators
|
|
96
|
+
|
|
97
|
+
Check file content for specific strings:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"type": "file",
|
|
102
|
+
"path": "package.json",
|
|
103
|
+
"contains": "\"express\":",
|
|
104
|
+
"confidence": 0.85
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### 3. Directory Indicators
|
|
109
|
+
|
|
110
|
+
Detect characteristic directory structures:
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"type": "directory",
|
|
115
|
+
"path": "app/Models",
|
|
116
|
+
"confidence": 0.7
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Asset Pattern Definitions
|
|
123
|
+
|
|
124
|
+
Each pattern defines how to find and extract a specific type of code asset.
|
|
125
|
+
|
|
126
|
+
### Pattern Structure
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"routes": {
|
|
131
|
+
"files": ["routes/*.php", "config/routes.ts"],
|
|
132
|
+
"regex": [
|
|
133
|
+
"Route::(get|post|put|delete)\\(['\"]([^'\"]+)['\"]",
|
|
134
|
+
"app\\.(get|post|put|delete)\\(['\"]([^'\"]+)['\"]\\"
|
|
135
|
+
],
|
|
136
|
+
"extractors": {
|
|
137
|
+
"method": 1,
|
|
138
|
+
"path": 2
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Common Asset Types
|
|
145
|
+
|
|
146
|
+
| Asset Type | Description | Typical Locations |
|
|
147
|
+
|------------|-------------|-------------------|
|
|
148
|
+
| `routes` | HTTP route definitions | `routes/*.php`, `config/routes.ts` |
|
|
149
|
+
| `controllers` | Controller classes | `app/Http/Controllers/**/*.php` |
|
|
150
|
+
| `models` | Data models / entities | `app/Models/**/*.php` |
|
|
151
|
+
| `migrations` | Database migrations | `database/migrations/*.php` |
|
|
152
|
+
| `middleware` | Request middleware | `app/Http/Middleware/*.php` |
|
|
153
|
+
| `services` | Service classes | `app/Services/**/*.php` |
|
|
154
|
+
| `repositories` | Repository pattern classes | `app/Repositories/**/*.php` |
|
|
155
|
+
| `tests` | Test files | `tests/**/*.php` |
|
|
156
|
+
| `validations` | Form validators / requests | `app/Http/Requests/**/*.php` |
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## Regex Guidelines
|
|
161
|
+
|
|
162
|
+
### DO
|
|
163
|
+
- Use named capture groups when extracting data
|
|
164
|
+
- Escape special characters properly
|
|
165
|
+
- Test regex against real codebase samples
|
|
166
|
+
- Prefer precision over recall (false positives expensive)
|
|
167
|
+
|
|
168
|
+
### DON'T
|
|
169
|
+
- Use overly greedy patterns (.*?)
|
|
170
|
+
- Match across multiple lines without multiline flag
|
|
171
|
+
- Assume consistent formatting (handle spaces/tabs)
|
|
172
|
+
- Forget to escape regex metacharacters
|
|
173
|
+
|
|
174
|
+
### Examples
|
|
175
|
+
|
|
176
|
+
**Good:**
|
|
177
|
+
```regex
|
|
178
|
+
Route::(get|post|put|delete|patch)\s*\(\s*['"]([^'"]+)['"]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Bad:**
|
|
182
|
+
```regex
|
|
183
|
+
Route.*\(.*\)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Adding a New Pattern Set
|
|
189
|
+
|
|
190
|
+
### 1. Choose Directory Structure
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
.orchestrator/patterns/legacy/
|
|
194
|
+
├── php/
|
|
195
|
+
│ ├── laravel.patterns.json
|
|
196
|
+
│ └── symfony.patterns.json
|
|
197
|
+
├── node/
|
|
198
|
+
│ ├── express.patterns.json
|
|
199
|
+
│ └── nestjs.patterns.json
|
|
200
|
+
└── python/
|
|
201
|
+
├── django.patterns.json
|
|
202
|
+
└── flask.patterns.json
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 2. Define Detection Indicators
|
|
206
|
+
|
|
207
|
+
Start with high-confidence indicators:
|
|
208
|
+
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"detection": {
|
|
212
|
+
"indicators": [
|
|
213
|
+
{
|
|
214
|
+
"type": "file",
|
|
215
|
+
"path": "manage.py",
|
|
216
|
+
"confidence": 0.95,
|
|
217
|
+
"description": "Django management script"
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"type": "file",
|
|
221
|
+
"path": "requirements.txt",
|
|
222
|
+
"contains": "Django",
|
|
223
|
+
"confidence": 0.90
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
"minConfidence": 0.85
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### 3. Define Asset Patterns
|
|
232
|
+
|
|
233
|
+
For each asset type, specify:
|
|
234
|
+
- File glob patterns to search
|
|
235
|
+
- Regex patterns to match
|
|
236
|
+
- Capture groups to extract data
|
|
237
|
+
|
|
238
|
+
```json
|
|
239
|
+
{
|
|
240
|
+
"patterns": {
|
|
241
|
+
"views": {
|
|
242
|
+
"files": ["app/views.py", "*/views.py"],
|
|
243
|
+
"regex": [
|
|
244
|
+
"def\\s+(\\w+)\\(request",
|
|
245
|
+
"@api_view\\(['\"]([^'\"]+)['\"]\\)"
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 4. Test Against Real Codebase
|
|
253
|
+
|
|
254
|
+
Run legacy-discoverer agent against sample codebase:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Expected output:
|
|
258
|
+
Stack Detected: Python / Django
|
|
259
|
+
Confidence: 0.95
|
|
260
|
+
Assets Found: 45 routes, 23 models, 67 views
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 5. Iterate and Refine
|
|
264
|
+
|
|
265
|
+
- Check false positives (assets detected incorrectly)
|
|
266
|
+
- Check false negatives (assets missed)
|
|
267
|
+
- Adjust regex patterns and confidence scores
|
|
268
|
+
- Target: >= 90% accuracy
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
## Supported Stacks (v1.0)
|
|
273
|
+
|
|
274
|
+
| Language | Framework | Pattern File | Status |
|
|
275
|
+
|----------|-----------|--------------|--------|
|
|
276
|
+
| PHP | Laravel | `php/laravel.patterns.json` | ✅ Implemented |
|
|
277
|
+
| PHP | Symfony | `php/symfony.patterns.json` | 🔜 Planned |
|
|
278
|
+
| Node | Express | `node/express.patterns.json` | 🔜 Planned |
|
|
279
|
+
| Node | NestJS | `node/nestjs.patterns.json` | 🔜 Planned |
|
|
280
|
+
| Python | Django | `python/django.patterns.json` | 🔜 Planned |
|
|
281
|
+
| Python | Flask | `python/flask.patterns.json` | 🔜 Planned |
|
|
282
|
+
| Java | Spring | `java/spring.patterns.json` | 🔜 Planned |
|
|
283
|
+
|
|
284
|
+
**Roadmap:** Add 2-3 new stacks per release based on user demand.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## Validation
|
|
289
|
+
|
|
290
|
+
Pattern sets are validated on load against JSON schema:
|
|
291
|
+
|
|
292
|
+
### Required Fields
|
|
293
|
+
- `id` (string)
|
|
294
|
+
- `stack.language` (string)
|
|
295
|
+
- `stack.framework` (string)
|
|
296
|
+
- `detection.indicators` (array, min 1)
|
|
297
|
+
- `detection.minConfidence` (number, 0.0-1.0)
|
|
298
|
+
- `patterns` (object, min 1 asset type)
|
|
299
|
+
|
|
300
|
+
### Optional Fields
|
|
301
|
+
- `stack.versions` (array of strings)
|
|
302
|
+
- `patterns.*.extractors` (object)
|
|
303
|
+
- `metadata` (object)
|
|
304
|
+
|
|
305
|
+
### Validation Errors
|
|
306
|
+
|
|
307
|
+
Common errors and fixes:
|
|
308
|
+
|
|
309
|
+
| Error | Cause | Fix |
|
|
310
|
+
|-------|-------|-----|
|
|
311
|
+
| Invalid regex | Unescaped special chars | Escape `(`, `)`, `[`, `]`, etc. |
|
|
312
|
+
| Confidence out of range | Score < 0 or > 1.0 | Set 0.0 <= confidence <= 1.0 |
|
|
313
|
+
| No patterns defined | Empty `patterns` object | Add at least one asset type |
|
|
314
|
+
| Duplicate ID | Multiple pattern sets with same ID | Use unique IDs |
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Performance Considerations
|
|
319
|
+
|
|
320
|
+
### Pattern Execution
|
|
321
|
+
|
|
322
|
+
- Patterns run sequentially per asset type
|
|
323
|
+
- Glob patterns executed first (filesystem scan)
|
|
324
|
+
- Regex applied only to matched files
|
|
325
|
+
- Results cached per codebase
|
|
326
|
+
|
|
327
|
+
### Optimization Tips
|
|
328
|
+
|
|
329
|
+
1. **Use specific globs**: `routes/*.php` better than `**/*.php`
|
|
330
|
+
2. **Order regex by frequency**: Most common patterns first
|
|
331
|
+
3. **Limit file scanning**: Exclude `node_modules/`, `vendor/`
|
|
332
|
+
4. **Cache results**: Store inventory.json for reuse
|
|
333
|
+
|
|
334
|
+
### Token Budget
|
|
335
|
+
|
|
336
|
+
Pattern-based detection uses minimal tokens (~1-5k per codebase) compared to LLM-based heuristic detection (~50-100k).
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## References
|
|
341
|
+
|
|
342
|
+
- [RFC-004 Legacy Analysis Workflow](../../../project-guidelines/rfcs/RFC-004-LEGACY-ANALYSIS-WORKFLOW.md)
|
|
343
|
+
- [Legacy Discoverer Agent](.claude/agents/legacy-discoverer.md)
|
|
344
|
+
- [Pattern Set Examples](./examples/)
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## Directory Contents
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
patterns/legacy/
|
|
352
|
+
├── README.md # This file
|
|
353
|
+
└── php/
|
|
354
|
+
└── laravel.patterns.json # Laravel pattern set (v1.0)
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
**Maintained by:** Orchestrator System
|
|
360
|
+
**Last Updated:** 2026-01-23
|