@sylphx/flow 1.4.6 → 1.4.7

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.
@@ -0,0 +1,485 @@
1
+ ---
2
+ name: Workspace Documentation
3
+ description: .sylphx/ shared workspace - auto-create, maintain SSOT, verify on every read
4
+ ---
5
+
6
+ # WORKSPACE DOCUMENTATION
7
+
8
+ ## On First Task
9
+
10
+ **Check:** `.sylphx/` exists?
11
+
12
+ **No → Create structure:**
13
+ ```bash
14
+ mkdir -p .sylphx/decisions
15
+ ```
16
+
17
+ Create files with templates below. Populate with project-specific content.
18
+
19
+ **Yes → Verify:**
20
+ - Read all files
21
+ - Check accuracy vs actual code
22
+ - Update or delete outdated sections
23
+
24
+ ---
25
+
26
+ ## Structure & Templates
27
+
28
+ ### .sylphx/context.md
29
+
30
+ **Create when:** First task, or when missing
31
+ **Update when:** Project scope/purpose/constraints change
32
+
33
+ ```markdown
34
+ # Project Context
35
+
36
+ ## What
37
+ [1-2 sentence description of what this project is]
38
+
39
+ ## Why
40
+ [Problem being solved, user need addressed]
41
+
42
+ ## Who
43
+ [Target users, primary use cases]
44
+
45
+ ## Status
46
+ [Development phase: Alpha/Beta/Stable, current version]
47
+
48
+ ## Key Constraints
49
+ - [Non-negotiable requirement 1]
50
+ - [Non-negotiable requirement 2]
51
+ - [Critical limitation or boundary]
52
+
53
+ ## Source of Truth References
54
+ <!-- VERIFY: These files exist -->
55
+ - Tech stack: `package.json`
56
+ - Configuration: [list config files]
57
+ - Build/Scripts: `package.json` scripts
58
+ ```
59
+
60
+ **Verify:** Referenced files exist. If not, update or remove reference.
61
+
62
+ ---
63
+
64
+ ### .sylphx/architecture.md
65
+
66
+ **Create when:** First task, or when missing
67
+ **Update when:** Architecture changes, patterns adopted, major refactoring
68
+
69
+ ```markdown
70
+ # Architecture
71
+
72
+ ## System Overview
73
+ [1-2 paragraph high-level description]
74
+
75
+ ## Key Components
76
+ <!-- VERIFY: Paths exist -->
77
+ - **Component A** (`src/path/`): [Purpose, responsibility]
78
+ - **Component B** (`src/path/`): [Purpose, responsibility]
79
+
80
+ ## Design Patterns
81
+
82
+ ### Pattern: [Name]
83
+ **Why chosen:** [Rationale - problem it solves]
84
+ **Where used:** `src/path/to/implementation.ts`
85
+ **Trade-off:** [What gained vs what lost]
86
+
87
+ ## Data Flow
88
+ [Macro-level: input → processing → output]
89
+ See `src/[entry-point].ts` for implementation.
90
+
91
+ ## Boundaries
92
+ **In scope:** [What this project does]
93
+ **Out of scope:** [What it explicitly doesn't do]
94
+ ```
95
+
96
+ **Verify:** All paths exist. Patterns still used. Trade-offs still accurate.
97
+
98
+ ---
99
+
100
+ ### .sylphx/glossary.md
101
+
102
+ **Create when:** First task, or when missing
103
+ **Update when:** New project-specific term introduced
104
+
105
+ ```markdown
106
+ # Glossary
107
+
108
+ ## [Term]
109
+ **Definition:** [Clear, concise definition]
110
+ **Usage:** `src/path/where/used.ts`
111
+ **Context:** [When/why this term matters]
112
+
113
+ ---
114
+
115
+ [Only project-specific terms. No general programming concepts.]
116
+ ```
117
+
118
+ **Verify:** Terms still used. Usage references exist.
119
+
120
+ ---
121
+
122
+ ### .sylphx/decisions/README.md
123
+
124
+ **Create when:** First ADR created
125
+ **Update when:** New ADR added
126
+
127
+ ```markdown
128
+ # Architecture Decision Records
129
+
130
+ ## Active Decisions
131
+ - [ADR-001: Title](./001-title.md) ✅ Accepted
132
+ - [ADR-002: Title](./002-title.md) ✅ Accepted
133
+
134
+ ## Superseded
135
+ - [ADR-XXX: Old Title](./xxx-old.md) 🔄 Superseded by ADR-YYY
136
+
137
+ ## Status Legend
138
+ - ✅ Accepted - Currently in effect
139
+ - ⏸️ Proposed - Under consideration
140
+ - ❌ Rejected - Not adopted
141
+ - 🔄 Superseded - Replaced by newer ADR
142
+ ```
143
+
144
+ ---
145
+
146
+ ### .sylphx/decisions/NNN-title.md
147
+
148
+ **Create when:** Making architectural decision
149
+ **Update when:** Decision status changes or is superseded
150
+
151
+ ```markdown
152
+ # NNN. [Title - Verb + Object, e.g., "Use Bun as Package Manager"]
153
+
154
+ **Status:** ✅ Accepted
155
+ **Date:** YYYY-MM-DD
156
+ **Deciders:** [Who made decision, or "Project maintainers"]
157
+
158
+ ## Context
159
+ [Situation/problem requiring a decision. 1-2 sentences.]
160
+
161
+ ## Decision
162
+ [What was decided. 1 sentence.]
163
+
164
+ ## Rationale
165
+ [Why this decision over alternatives. Key benefits. 2-3 bullet points.]
166
+
167
+ ## Consequences
168
+ **Positive:**
169
+ - [Benefit 1]
170
+ - [Benefit 2]
171
+
172
+ **Negative:**
173
+ - [Drawback 1]
174
+ - [Drawback 2]
175
+
176
+ ## References
177
+ <!-- VERIFY: Links exist -->
178
+ - Implementation: `src/path/to/code.ts`
179
+ - Related PR: #123 (if applicable)
180
+ - Supersedes: ADR-XXX (if applicable)
181
+ ```
182
+
183
+ **Keep <200 words total.**
184
+
185
+ ---
186
+
187
+ ## SSOT Discipline
188
+
189
+ **Never duplicate. Always reference.**
190
+
191
+ ### ❌ Bad (Duplication - Will Drift)
192
+
193
+ ```markdown
194
+ Dependencies:
195
+ - react 19.2.0
196
+ - zod 4.1.12
197
+
198
+ Linting rules:
199
+ - no-unused-vars
200
+ - prefer-const
201
+ ```
202
+
203
+ ### ✅ Good (Reference - SSOT Maintained)
204
+
205
+ ```markdown
206
+ <!-- VERIFY: package.json exists -->
207
+ Dependencies: See `package.json`
208
+
209
+ <!-- VERIFY: biome.json exists -->
210
+ Linting: Biome (config in `biome.json`)
211
+
212
+ ## Why Biome
213
+ - Decision: ADR-003
214
+ - Benefit: Single tool for format + lint
215
+ - Trade-off: Smaller ecosystem than ESLint
216
+ ```
217
+
218
+ **Format for references:**
219
+ ```markdown
220
+ <!-- VERIFY: path/to/file.ts -->
221
+ [Description]. See `path/to/file.ts`.
222
+ ```
223
+
224
+ Verification marker reminds: when file changes, check if doc needs update.
225
+
226
+ ---
227
+
228
+ ## Maintenance Triggers
229
+
230
+ ### On Every Task Start
231
+
232
+ ```
233
+ 1. Check .sylphx/ exists
234
+ - No → Create with templates
235
+ - Yes → Continue to verify
236
+
237
+ 2. Read all .sylphx/ files
238
+
239
+ 3. Verify accuracy:
240
+ - Check <!-- VERIFY: --> markers
241
+ - Confirm files exist
242
+ - Check if still accurate vs code
243
+
244
+ 4. Update or delete:
245
+ - Wrong → Fix immediately
246
+ - Outdated → Update or delete
247
+ - Missing context → Add
248
+
249
+ 5. Note gaps for later update
250
+ ```
251
+
252
+ ### During Task Execution
253
+
254
+ **Triggers to update:**
255
+
256
+ - **New understanding** → Update context.md or architecture.md
257
+ - **Architectural decision made** → Create ADR in decisions/
258
+ - **New project-specific term** → Add to glossary.md
259
+ - **Pattern adopted** → Document in architecture.md with WHY
260
+ - **Constraint discovered** → Add to context.md
261
+ - **Found outdated info** → Delete or update immediately
262
+
263
+ ### Before Commit
264
+
265
+ ```
266
+ 1. Updated understanding? → Update .sylphx/
267
+ 2. Made architectural change? → Create/update ADR
268
+ 3. Deprecated approach? → Mark superseded or delete
269
+ 4. Verify: No contradictions between .sylphx/ and code
270
+ 5. Verify: All <!-- VERIFY: --> markers still valid
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Content Rules
276
+
277
+ ### ✅ Include (Macro-Level WHY)
278
+
279
+ - Project purpose and context
280
+ - Architectural decisions (WHY chosen)
281
+ - System boundaries (in/out of scope)
282
+ - Key patterns (WHY used, trade-offs)
283
+ - Project-specific terminology
284
+ - Non-obvious constraints
285
+
286
+ ### ❌ Exclude (Belongs Elsewhere)
287
+
288
+ - API documentation → JSDoc in code
289
+ - Implementation details → Code comments
290
+ - Configuration values → Config files
291
+ - Dependency versions → package.json
292
+ - Code examples → Actual code or tests
293
+ - How-to guides → Code comments
294
+ - Step-by-step processes → Code itself
295
+
296
+ **Principle:** If it's in code or config, don't duplicate it here.
297
+
298
+ ---
299
+
300
+ ## Red Flags (Delete Immediately)
301
+
302
+ Scan for these on every read:
303
+
304
+ - ❌ "We plan to..." / "In the future..." (speculation)
305
+ - ❌ "Currently using..." (implies might change - use present tense or delete)
306
+ - ❌ Contradicts actual code
307
+ - ❌ References non-existent files
308
+ - ❌ Duplicates package.json / config
309
+ - ❌ Explains HOW instead of WHY
310
+ - ❌ Generic advice (not project-specific)
311
+
312
+ **When found:** Delete entire section immediately.
313
+
314
+ ---
315
+
316
+ ## Cleanup Protocol
317
+
318
+ **Monthly or after major changes:**
319
+
320
+ ```bash
321
+ # 1. Check all referenced files exist
322
+ cd .sylphx
323
+ grep -r "src/" . | grep -o 'src/[^`)]*' | sort -u > /tmp/refs.txt
324
+ # Verify each file in refs.txt exists
325
+
326
+ # 2. Check package.json references
327
+ grep -r "package.json" .
328
+ # Verify info isn't duplicated
329
+
330
+ # 3. Check verification markers
331
+ grep -r "<!-- VERIFY:" .
332
+ # Check each marked file exists and content accurate
333
+
334
+ # 4. Read all files
335
+ # Delete outdated sections
336
+ # Update inaccurate content
337
+ # Remove speculation
338
+ ```
339
+
340
+ ---
341
+
342
+ ## Decision Flow: Create ADR?
343
+
344
+ **Create ADR when:**
345
+ - Choosing between 2+ significant alternatives
346
+ - Decision has long-term impact
347
+ - Future developers will ask "why did they do this?"
348
+ - Non-obvious trade-offs involved
349
+
350
+ **Don't create ADR for:**
351
+ - Obvious choices (use standard tool)
352
+ - Temporary decisions (will change soon)
353
+ - Implementation details (belongs in code comments)
354
+ - Trivial choices (naming, formatting)
355
+
356
+ **Quick test:** Will this decision matter in 6 months? Yes → ADR. No → Skip.
357
+
358
+ ---
359
+
360
+ ## Verification Commands
361
+
362
+ **Check links valid:**
363
+ ```bash
364
+ cd .sylphx
365
+ # Extract all file references
366
+ grep -roh '`[^`]*\.[a-z]*`' . | tr -d '`' | sort -u | while read f; do
367
+ [ -f "../$f" ] || echo "MISSING: $f"
368
+ done
369
+ ```
370
+
371
+ **Check for duplication:**
372
+ ```bash
373
+ # If package.json mentioned without "See package.json"
374
+ grep -r "dependencies" .sylphx/ | grep -v "See \`package.json\`"
375
+ # Should be empty or references only
376
+ ```
377
+
378
+ ---
379
+
380
+ ## Examples
381
+
382
+ ### Good context.md (Real Project)
383
+
384
+ ```markdown
385
+ # Project Context
386
+
387
+ ## What
388
+ AI-powered CLI for autonomous development workflows with agent orchestration.
389
+
390
+ ## Why
391
+ Enable developers to delegate complex multi-step tasks to AI that can plan, execute, verify autonomously while maintaining quality.
392
+
393
+ ## Who
394
+ Developers using Claude/AI for coding assistance.
395
+
396
+ ## Status
397
+ Active development - v1.2.0
398
+ Focus: Agent prompt optimization
399
+
400
+ ## Key Constraints
401
+ - No breaking changes without major version
402
+ - Research mandatory before implementation
403
+ - All modules need .test.ts and .bench.ts
404
+ - Clean commits only (no TODOs, debug code)
405
+
406
+ ## Source of Truth
407
+ <!-- VERIFY: packages/flow/package.json -->
408
+ - Dependencies: `packages/flow/package.json`
409
+ - Build: `package.json` scripts (root + packages/flow)
410
+ - TypeScript: `packages/flow/tsconfig.json`
411
+ ```
412
+
413
+ ### Good architecture.md
414
+
415
+ ```markdown
416
+ # Architecture
417
+
418
+ ## System Overview
419
+ CLI loads agent prompts from markdown, composes with rules/output-styles, orchestrates multi-agent workflows.
420
+
421
+ ## Key Components
422
+ <!-- VERIFY: Paths exist -->
423
+ - **Agent Loader** (`src/core/agent-loader.ts`): Parses markdown prompts
424
+ - **Agent Manager** (`src/core/agent-manager.ts`): Orchestration
425
+
426
+ ## Design Patterns
427
+
428
+ ### Pattern: Markdown-as-Config
429
+ **Why:** Human-readable, version-controlled, easy iteration
430
+ **Where:** `assets/**/*.md` with frontmatter
431
+ **Trade-off:** Parsing overhead vs flexibility (chose flexibility)
432
+
433
+ ### Pattern: Minimal Effective Prompting
434
+ **Why:** Trust LLM, reduce tokens 40%, increase clarity
435
+ **Where:** All prompts (v1.2.0 refactor)
436
+ **Trade-off:** Less explicit teaching vs more effective triggering
437
+ **Decision:** ADR-002
438
+ ```
439
+
440
+ ### Good ADR
441
+
442
+ ```markdown
443
+ # 002. Minimal Effective Prompt Philosophy
444
+
445
+ **Status:** ✅ Accepted
446
+ **Date:** 2024-11-15
447
+
448
+ ## Context
449
+ Agent prompts were verbose with step-by-step teaching, reducing effectiveness and increasing cost.
450
+
451
+ ## Decision
452
+ Adopt MEP: Trust LLM, WHAT+WHEN not HOW+WHY, mixed formats, condensed.
453
+
454
+ ## Rationale
455
+ - 40% token reduction
456
+ - Better LLM performance (less noise)
457
+ - Easier maintenance
458
+
459
+ ## Consequences
460
+ **Positive:** Lower cost, better results, cleaner prompts
461
+ **Negative:** Less explicit for human readers
462
+
463
+ ## References
464
+ <!-- VERIFY: commit exists -->
465
+ - Implementation: All `assets/**/*.md` files
466
+ - Refactor: commit c7795c0f
467
+ ```
468
+
469
+ ---
470
+
471
+ ## Summary
472
+
473
+ **Agent behavior:**
474
+ 1. **First task:** Check .sylphx/ exists → Create if missing → Populate with templates
475
+ 2. **Every task start:** Read .sylphx/ → Verify accuracy → Update/delete as needed
476
+ 3. **During work:** New understanding → Update immediately
477
+ 4. **Before commit:** Verify .sylphx/ matches reality → No contradictions
478
+
479
+ **Content:**
480
+ - **Include:** WHY (context, decisions, rationale)
481
+ - **Exclude:** HOW (implementation → code)
482
+ - **Reference:** Link to SSOT, never duplicate
483
+ - **Maintain:** Verify on read, update on learn, delete when wrong
484
+
485
+ **Prime Directive: Outdated docs worse than no docs. When in doubt, delete.**
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: cleanup
3
+ description: Clean technical debt, refactor, optimize, and simplify codebase
4
+ agent: coder
5
+ ---
6
+
7
+ # Cleanup & Refactor
8
+
9
+ Scan codebase for technical debt and code smells. Clean, refactor, optimize.
10
+
11
+ ## Scope
12
+
13
+ **Code Smells:**
14
+ - Functions >20 lines → extract
15
+ - Duplication (3+ occurrences) → DRY
16
+ - Complexity (>3 nesting levels) → flatten
17
+ - Unused code/imports/variables → remove
18
+ - Commented code → delete
19
+ - Magic numbers → named constants
20
+ - Poor naming → clarify
21
+
22
+ **Technical Debt:**
23
+ - TODOs/FIXMEs → implement or delete
24
+ - Deprecated APIs → upgrade
25
+ - Outdated patterns → modernize
26
+ - Performance bottlenecks → optimize
27
+ - Memory leaks → fix
28
+ - Lint warnings → resolve
29
+
30
+ **Optimization:**
31
+ - Algorithm complexity → reduce
32
+ - N+1 queries → batch
33
+ - Unnecessary re-renders → memoize
34
+ - Large bundles → code split
35
+ - Unused dependencies → remove
36
+
37
+ ## Execution
38
+
39
+ 1. **Scan** entire codebase systematically
40
+ 2. **Prioritize** by impact (critical → major → minor)
41
+ 3. **Clean** incrementally with atomic commits
42
+ 4. **Test** after every change
43
+ 5. **Report** what was cleaned and impact
44
+
45
+ ## Commit Strategy
46
+
47
+ One commit per logical cleanup:
48
+ - `refactor(auth): extract validateToken function`
49
+ - `perf(db): batch user queries to fix N+1`
50
+ - `chore: remove unused imports and commented code`
51
+
52
+ ## Exit Criteria
53
+
54
+ - [ ] No code smells remain
55
+ - [ ] All tests pass
56
+ - [ ] Lint clean
57
+ - [ ] Performance improved (measure before/after)
58
+ - [ ] Technical debt reduced measurably
59
+
60
+ Report: Lines removed, complexity reduced, performance gains.
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: improve
3
+ description: Proactively discover and implement improvements
4
+ agent: coder
5
+ ---
6
+
7
+ # Proactive Improvement
8
+
9
+ Analyze project comprehensively. Discover improvement opportunities. Prioritize and execute.
10
+
11
+ ## Discovery Areas
12
+
13
+ **Code Quality:**
14
+ - Code complexity hotspots
15
+ - Duplication patterns
16
+ - Test coverage gaps
17
+ - Error handling weaknesses
18
+ - Type safety improvements
19
+ - Naming inconsistencies
20
+
21
+ **Architecture:**
22
+ - Tight coupling
23
+ - Missing abstractions
24
+ - Scalability bottlenecks
25
+ - State management issues
26
+ - API design improvements
27
+ - Module organization
28
+
29
+ **Performance:**
30
+ - Slow algorithms (profiling data)
31
+ - Database query inefficiencies
32
+ - Bundle size optimization
33
+ - Memory usage patterns
34
+ - Network request optimization
35
+ - Caching opportunities
36
+
37
+ **Security:**
38
+ - Vulnerability scan (dependencies)
39
+ - Input validation gaps
40
+ - Authentication/authorization weaknesses
41
+ - Sensitive data exposure
42
+ - OWASP top 10 check
43
+ - Security best practices
44
+
45
+ **Developer Experience:**
46
+ - Development setup complexity
47
+ - Build time optimization
48
+ - Testing speed
49
+ - Debugging capabilities
50
+ - Error messages clarity
51
+ - Documentation gaps
52
+
53
+ **Maintenance:**
54
+ - Outdated dependencies
55
+ - Deprecated API usage
56
+ - Missing tests
57
+ - Incomplete documentation
58
+ - Configuration complexity
59
+ - Technical debt accumulation
60
+
61
+ **Features:**
62
+ - Missing functionality (user feedback)
63
+ - Integration opportunities
64
+ - Automation potential
65
+ - Monitoring/observability
66
+ - Error recovery
67
+ - User experience improvements
68
+
69
+ ## Analysis Process
70
+
71
+ 1. **Scan** codebase comprehensively
72
+ 2. **Profile** performance bottlenecks
73
+ 3. **Check** security vulnerabilities
74
+ 4. **Review** dependencies for updates
75
+ 5. **Analyze** test coverage
76
+ 6. **Assess** documentation completeness
77
+ 7. **Evaluate** architectural patterns
78
+ 8. **Identify** missing features
79
+
80
+ ## Prioritization Matrix
81
+
82
+ **Impact vs Effort:**
83
+ - **High Impact + Low Effort** → Do first
84
+ - **High Impact + High Effort** → Plan carefully
85
+ - **Low Impact + Low Effort** → Quick wins
86
+ - **Low Impact + High Effort** → Skip or defer
87
+
88
+ **Categories:**
89
+ - **Critical:** Security, data loss, crashes
90
+ - **High:** Performance degradation, poor UX
91
+ - **Medium:** Code quality, maintainability
92
+ - **Low:** Nice-to-haves, polish
93
+
94
+ ## Execution Plan
95
+
96
+ For each improvement:
97
+ 1. **Describe** what and why
98
+ 2. **Estimate** effort (small/medium/large)
99
+ 3. **Assess** impact (low/medium/high)
100
+ 4. **Prioritize** using matrix
101
+ 5. **Create** implementation plan
102
+
103
+ Then execute top priorities:
104
+ - Start with high-impact, low-effort
105
+ - Make atomic commits
106
+ - Test thoroughly
107
+ - Document changes
108
+
109
+ ## Output Format
110
+
111
+ ```markdown
112
+ ## Improvement Opportunities
113
+
114
+ ### Critical (Do Now)
115
+ 1. [Security] Update vulnerable dependency X (CVE-XXXX)
116
+ - Impact: High (prevents exploit)
117
+ - Effort: Low (5 min)
118
+ - Action: `npm update X`
119
+
120
+ ### High Priority
121
+ 1. [Performance] Optimize user query (N+1 problem)
122
+ - Impact: High (10x speedup)
123
+ - Effort: Medium (2 hrs)
124
+ - Action: Batch queries with JOIN
125
+
126
+ ### Quick Wins
127
+ 1. [DX] Add pre-commit hooks
128
+ - Impact: Medium (catch errors early)
129
+ - Effort: Low (30 min)
130
+ - Action: Setup husky + lint-staged
131
+
132
+ ### Planned Improvements
133
+ 1. [Feature] Add caching layer
134
+ - Impact: High (reduce server load)
135
+ - Effort: High (1 week)
136
+ - Action: Design cache strategy, implement Redis
137
+
138
+ ## Execution Plan
139
+ 1. Fix security vulnerability (now)
140
+ 2. Optimize query performance (today)
141
+ 3. Add pre-commit hooks (today)
142
+ 4. Plan caching implementation (next sprint)
143
+ ```
144
+
145
+ ## Exit Criteria
146
+
147
+ - [ ] Comprehensive analysis completed
148
+ - [ ] Opportunities prioritized
149
+ - [ ] High-priority improvements implemented
150
+ - [ ] Tests pass
151
+ - [ ] Impact measured
152
+ - [ ] Documentation updated
153
+
154
+ Report: Improvements discovered, implemented, impact metrics.