@sylphx/flow 1.5.4 → 1.6.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/CHANGELOG.md +14 -0
- package/assets/rules/code-standards.md +23 -24
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @sylphx/flow
|
|
2
2
|
|
|
3
|
+
## 1.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4a025d0: Refactor code standards to pragmatic functional programming. Replace dogmatic FP rules with flexible, pragmatic approach following MEP principles.
|
|
8
|
+
|
|
9
|
+
**Key Changes:**
|
|
10
|
+
|
|
11
|
+
- Programming Patterns: Merge 4 rules into "Pragmatic FP" (-58% tokens). Business logic pure, local mutations acceptable, composition default but inheritance when natural.
|
|
12
|
+
- Error Handling: Support both Result types and explicit exceptions (previously forced Result/Either).
|
|
13
|
+
- Anti-Patterns: Remove neverthrow enforcement, allow try/catch as valid option.
|
|
14
|
+
|
|
15
|
+
**Philosophy Shift:** From "pure FP always" to "pragmatic: use best tool for the job". More MEP-compliant (prompt not teach), more flexible, preserves all core values.
|
|
16
|
+
|
|
3
17
|
## 1.5.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -40,31 +40,22 @@ description: Technical standards for Coder and Reviewer agents
|
|
|
40
40
|
|
|
41
41
|
## Programming Patterns
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
**Pure functions default**: No mutations, no global state, no I/O. Side effects isolated with comment.
|
|
43
|
+
<!-- P1 --> **Pragmatic FP**:
|
|
44
|
+
- Business logic pure. Local mutations acceptable.
|
|
45
|
+
- I/O explicit (comment when impure)
|
|
46
|
+
- Composition default, inheritance when natural (1 level max)
|
|
47
|
+
- Declarative when clearer, imperative when simpler
|
|
50
48
|
|
|
51
49
|
<example>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
function validateConfig(config) { return ... }
|
|
50
|
+
✅ users.filter(u => u.active)
|
|
51
|
+
✅ for (const user of users) process(user)
|
|
52
|
+
✅ class UserRepo extends BaseRepo {}
|
|
53
|
+
❌ let shared = {}; fn() { shared.x = 1 }
|
|
57
54
|
</example>
|
|
58
55
|
|
|
59
|
-
**
|
|
60
|
-
|
|
61
|
-
**Declarative over imperative**:
|
|
62
|
-
<example>
|
|
63
|
-
✅ const active = users.filter(u => u.isActive)
|
|
64
|
-
❌ const active = []; for (let i = 0; i < users.length; i++) { ... }
|
|
65
|
-
</example>
|
|
56
|
+
**Named args (3+ params)**: `update({ id, email, role })`
|
|
66
57
|
|
|
67
|
-
**Event-driven when appropriate**: Decouple
|
|
58
|
+
**Event-driven when appropriate**: Decouple via events/messages
|
|
68
59
|
|
|
69
60
|
---
|
|
70
61
|
|
|
@@ -138,7 +129,13 @@ function validateConfig(config) { return ... }
|
|
|
138
129
|
❌ const data = await fetchUser(id) // let it bubble unhandled
|
|
139
130
|
</example>
|
|
140
131
|
|
|
141
|
-
**Expected Failures**:
|
|
132
|
+
**Expected Failures**: Result types or explicit exceptions. Never throw for control flow.
|
|
133
|
+
|
|
134
|
+
<example>
|
|
135
|
+
✅ return Result.err(error)
|
|
136
|
+
✅ throw new DomainError(msg)
|
|
137
|
+
❌ throw "error" // control flow
|
|
138
|
+
</example>
|
|
142
139
|
|
|
143
140
|
**Logging**: Include context (user id, request id). Actionable messages. Appropriate severity. Never mask failures.
|
|
144
141
|
|
|
@@ -201,9 +198,11 @@ Before ANY feature: research best practices + search codebase + check package re
|
|
|
201
198
|
</instruction>
|
|
202
199
|
|
|
203
200
|
<example>
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
✅ import { Result } from 'neverthrow'
|
|
202
|
+
✅ try/catch with typed errors
|
|
203
|
+
✅ import { z } from 'zod'
|
|
204
|
+
✅ import { format } from 'date-fns'
|
|
205
|
+
❌ Custom Result/validation/date implementations
|
|
207
206
|
</example>
|
|
208
207
|
|
|
209
208
|
**Premature Abstraction**:
|