codeforge-dev 1.7.0 → 1.8.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/.devcontainer/.env +4 -6
- package/.devcontainer/.env.example +29 -0
- package/.devcontainer/.gitignore +8 -0
- package/.devcontainer/.secrets.example +12 -0
- package/.devcontainer/CHANGELOG.md +130 -0
- package/.devcontainer/CLAUDE.md +56 -19
- package/.devcontainer/README.md +111 -56
- package/.devcontainer/config/{main-system-prompt.md → defaults/main-system-prompt.md} +72 -0
- package/.devcontainer/config/file-manifest.json +20 -0
- package/.devcontainer/devcontainer.json +20 -0
- package/.devcontainer/docs/configuration-reference.md +90 -0
- package/.devcontainer/docs/keybindings.md +100 -0
- package/.devcontainer/docs/optional-features.md +129 -0
- package/.devcontainer/docs/plugins.md +154 -0
- package/.devcontainer/docs/troubleshooting.md +128 -0
- package/.devcontainer/features/agent-browser/install.sh +6 -0
- package/.devcontainer/features/ast-grep/install.sh +6 -0
- package/.devcontainer/features/biome/README.md +27 -0
- package/.devcontainer/features/biome/install.sh +6 -0
- package/.devcontainer/features/ccburn/install.sh +6 -0
- package/.devcontainer/features/ccstatusline/devcontainer-feature.json +5 -0
- package/.devcontainer/features/ccstatusline/install.sh +7 -0
- package/.devcontainer/features/ccusage/install.sh +6 -0
- package/.devcontainer/features/claude-monitor/install.sh +6 -0
- package/.devcontainer/features/dprint/README.md +30 -0
- package/.devcontainer/features/dprint/devcontainer-feature.json +18 -0
- package/.devcontainer/features/dprint/install.sh +131 -0
- package/.devcontainer/features/hadolint/README.md +35 -0
- package/.devcontainer/features/hadolint/devcontainer-feature.json +13 -0
- package/.devcontainer/features/hadolint/install.sh +86 -0
- package/.devcontainer/features/lsp-servers/devcontainer-feature.json +5 -0
- package/.devcontainer/features/lsp-servers/install.sh +7 -0
- package/.devcontainer/features/mcp-qdrant/devcontainer-feature.json +5 -0
- package/.devcontainer/features/mcp-qdrant/install.sh +13 -6
- package/.devcontainer/features/mcp-reasoner/devcontainer-feature.json +5 -0
- package/.devcontainer/features/mcp-reasoner/install.sh +8 -1
- package/.devcontainer/features/notify-hook/devcontainer-feature.json +5 -0
- package/.devcontainer/features/notify-hook/install.sh +7 -0
- package/.devcontainer/features/ruff/README.md +26 -0
- package/.devcontainer/features/ruff/devcontainer-feature.json +21 -0
- package/.devcontainer/features/ruff/install.sh +74 -0
- package/.devcontainer/features/shellcheck/README.md +38 -0
- package/.devcontainer/features/shellcheck/devcontainer-feature.json +13 -0
- package/.devcontainer/features/shellcheck/install.sh +24 -0
- package/.devcontainer/features/shfmt/README.md +37 -0
- package/.devcontainer/features/shfmt/devcontainer-feature.json +13 -0
- package/.devcontainer/features/shfmt/install.sh +85 -0
- package/.devcontainer/features/splitrail/devcontainer-feature.json +5 -0
- package/.devcontainer/features/splitrail/install.sh +7 -0
- package/.devcontainer/features/tmux/install.sh +8 -0
- package/.devcontainer/features/tree-sitter/install.sh +6 -0
- package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +3 -10
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/.claude-plugin/plugin.json +1 -1
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/__pycache__/format-on-stop.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/format-on-stop.py +114 -9
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/.claude-plugin/plugin.json +1 -1
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/hooks/hooks.json +4 -5
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/__pycache__/lint-file.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/lint-file.py +478 -76
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/.claude-plugin/plugin.json +1 -1
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/AGENT-REDIRECTION.md +226 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/architect.md +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/bash-exec.md +4 -4
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/claude-guide.md +14 -23
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/debug-logs.md +2 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/dependency-analyst.md +2 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/doc-writer.md +13 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/explorer.md +2 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/generalist.md +10 -1
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/migrator.md +6 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/refactorer.md +4 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/spec-writer.md +36 -23
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/statusline-config.md +3 -3
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/agents/test-writer.md +3 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/hooks/hooks.json +39 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/advisory-test-runner.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/collect-edited-files.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/commit-reminder.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/git-state-injector.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/redirect-builtin-agents.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/ticket-linker.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/__pycache__/todo-harvester.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/advisory-test-runner.py +174 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/collect-edited-files.py +8 -6
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/commit-reminder.py +90 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/git-state-injector.py +114 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/skill-suggester.py +61 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/ticket-linker.py +137 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/scripts/todo-harvester.py +130 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/SKILL.md +224 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/references/error-handling.md +166 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/api-design/references/rest-conventions.md +215 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns/SKILL.md +211 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/ast-grep-patterns/references/language-patterns.md +327 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/SKILL.md +134 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/references/ecosystem-commands.md +264 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/dependency-management/references/license-compliance.md +80 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/SKILL.md +153 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/references/api-doc-templates.md +221 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/documentation-patterns/references/docstring-formats.md +296 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/SKILL.md +150 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/references/javascript-migrations.md +179 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/migration-patterns/references/python-migrations.md +141 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/code-directive/skills/specification-writing/SKILL.md +32 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/__pycache__/block-dangerous.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/hooks/hooks.json +1 -1
- package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/__pycache__/guard-protected.cpython-314.pyc +0 -0
- package/.devcontainer/scripts/check-setup.sh +72 -0
- package/.devcontainer/scripts/setup-aliases.sh +43 -3
- package/.devcontainer/scripts/setup-auth.sh +74 -0
- package/.devcontainer/scripts/setup-config.sh +112 -22
- package/.devcontainer/scripts/setup-update-claude.sh +8 -0
- package/.devcontainer/scripts/setup.sh +46 -13
- package/README.md +23 -190
- package/package.json +1 -1
- package/setup.js +245 -71
- package/.devcontainer/features/claude-code/README.md +0 -498
- package/.devcontainer/features/claude-code/config/settings.json +0 -72
- package/.devcontainer/features/claude-code/config/system-prompt.md +0 -118
- package/.devcontainer/features/claude-code/config/world-building-sp.md +0 -1432
- package/.devcontainer/features/claude-code/devcontainer-feature.json +0 -42
- package/.devcontainer/features/claude-code/install.sh +0 -466
- package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/.claude-plugin/plugin.json +0 -7
- package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/hooks/hooks.json +0 -17
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/.claude-plugin/plugin.json +0 -6
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/config/planning-instructions.md +0 -14
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/functional-conjuring-map.md +0 -989
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/hooks/hooks.json +0 -33
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/__pycache__/post-enhance-task.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhance-planning.py +0 -71
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-plan.sh +0 -68
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-task.sh +0 -120
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-plan.py +0 -133
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-task.py +0 -253
- /package/.devcontainer/config/{keybindings.json → defaults/keybindings.json} +0 -0
- /package/.devcontainer/config/{settings.json → defaults/settings.json} +0 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Docstring Format Reference
|
|
2
|
+
|
|
3
|
+
Complete templates for inline documentation across languages. Detect the project's existing style before adding new docstrings.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Python
|
|
8
|
+
|
|
9
|
+
### Google-Style (Recommended Default)
|
|
10
|
+
|
|
11
|
+
Detection pattern: `Grep: "Args:"` or `Grep: "Returns:"` in `.py` files.
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
def process_payment(amount: float, currency: str, customer_id: str) -> PaymentResult:
|
|
15
|
+
"""Process a payment for the given customer.
|
|
16
|
+
|
|
17
|
+
Validates the amount, charges the customer's default payment method,
|
|
18
|
+
and records the transaction in the payment ledger.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
amount: Payment amount in the smallest currency unit (e.g., cents).
|
|
22
|
+
Must be positive.
|
|
23
|
+
currency: ISO 4217 currency code (e.g., "usd", "eur").
|
|
24
|
+
customer_id: The unique customer identifier from the auth system.
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
PaymentResult with transaction ID, status, and timestamp.
|
|
28
|
+
|
|
29
|
+
Raises:
|
|
30
|
+
InvalidAmountError: If amount is negative or zero.
|
|
31
|
+
CustomerNotFoundError: If customer_id doesn't match any customer.
|
|
32
|
+
PaymentGatewayError: If the external payment provider is unreachable.
|
|
33
|
+
|
|
34
|
+
Example:
|
|
35
|
+
>>> result = process_payment(1500, "usd", "cust_abc123")
|
|
36
|
+
>>> result.status
|
|
37
|
+
'completed'
|
|
38
|
+
"""
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### NumPy-Style
|
|
42
|
+
|
|
43
|
+
Detection pattern: `Grep: "Parameters\n----------"` (multiline) or `Grep: "----------"` in docstrings.
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
def interpolate(x, y, method="linear"):
|
|
47
|
+
"""Interpolate data points using the specified method.
|
|
48
|
+
|
|
49
|
+
Parameters
|
|
50
|
+
----------
|
|
51
|
+
x : array_like
|
|
52
|
+
The x-coordinates of the data points.
|
|
53
|
+
y : array_like
|
|
54
|
+
The y-coordinates of the data points. Must have the same length as `x`.
|
|
55
|
+
method : str, optional
|
|
56
|
+
Interpolation method. One of 'linear', 'cubic', 'nearest'.
|
|
57
|
+
Default is 'linear'.
|
|
58
|
+
|
|
59
|
+
Returns
|
|
60
|
+
-------
|
|
61
|
+
callable
|
|
62
|
+
An interpolation function that accepts x values and returns
|
|
63
|
+
interpolated y values.
|
|
64
|
+
|
|
65
|
+
Raises
|
|
66
|
+
------
|
|
67
|
+
ValueError
|
|
68
|
+
If `x` and `y` have different lengths.
|
|
69
|
+
|
|
70
|
+
Examples
|
|
71
|
+
--------
|
|
72
|
+
>>> f = interpolate([0, 1, 2], [0, 1, 4], method='cubic')
|
|
73
|
+
>>> f(1.5)
|
|
74
|
+
2.25
|
|
75
|
+
"""
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Sphinx / reStructuredText
|
|
79
|
+
|
|
80
|
+
Detection pattern: `Grep: ":param "` or `Grep: ":type "` in `.py` files.
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
def connect(host, port, timeout=30):
|
|
84
|
+
"""Connect to the remote server.
|
|
85
|
+
|
|
86
|
+
Establishes a TCP connection with configurable timeout.
|
|
87
|
+
|
|
88
|
+
:param host: Server hostname or IP address.
|
|
89
|
+
:type host: str
|
|
90
|
+
:param port: Server port number (1-65535).
|
|
91
|
+
:type port: int
|
|
92
|
+
:param timeout: Connection timeout in seconds. Defaults to 30.
|
|
93
|
+
:type timeout: int
|
|
94
|
+
:returns: Active connection handle.
|
|
95
|
+
:rtype: Connection
|
|
96
|
+
:raises ConnectionError: If the server is unreachable.
|
|
97
|
+
:raises ValueError: If port is out of valid range.
|
|
98
|
+
"""
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Module and Class Docstrings
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
"""Payment processing module.
|
|
105
|
+
|
|
106
|
+
Handles payment creation, validation, and gateway communication.
|
|
107
|
+
Supports Stripe and PayPal providers via the adapter pattern.
|
|
108
|
+
|
|
109
|
+
See `src/payments/adapters/` for provider implementations.
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class PaymentProcessor:
|
|
114
|
+
"""Orchestrates payment workflows across multiple providers.
|
|
115
|
+
|
|
116
|
+
Manages provider selection, retry logic, and transaction recording.
|
|
117
|
+
Uses the strategy pattern to delegate provider-specific logic.
|
|
118
|
+
|
|
119
|
+
Attributes:
|
|
120
|
+
default_provider: Name of the fallback payment provider.
|
|
121
|
+
max_retries: Maximum retry attempts for failed transactions.
|
|
122
|
+
"""
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## TypeScript / JavaScript
|
|
128
|
+
|
|
129
|
+
### JSDoc
|
|
130
|
+
|
|
131
|
+
Detection pattern: `Grep: "@param "` or `Grep: "@returns"` in `.ts` or `.js` files.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
/**
|
|
135
|
+
* Process a payment for the given customer.
|
|
136
|
+
*
|
|
137
|
+
* Validates the amount, charges the customer's default payment method,
|
|
138
|
+
* and records the transaction.
|
|
139
|
+
*
|
|
140
|
+
* @param amount - Payment amount in cents (must be positive)
|
|
141
|
+
* @param currency - ISO 4217 currency code (e.g., "usd", "eur")
|
|
142
|
+
* @param customerId - The unique customer identifier
|
|
143
|
+
* @returns Payment result with transaction ID and status
|
|
144
|
+
* @throws {InvalidAmountError} If amount is negative or zero
|
|
145
|
+
* @throws {CustomerNotFoundError} If customerId doesn't match any customer
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const result = await processPayment(1500, "usd", "cust_abc123");
|
|
150
|
+
* console.log(result.status); // "completed"
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async function processPayment(
|
|
154
|
+
amount: number,
|
|
155
|
+
currency: string,
|
|
156
|
+
customerId: string
|
|
157
|
+
): Promise<PaymentResult> {
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### TSDoc
|
|
161
|
+
|
|
162
|
+
TSDoc is a stricter subset of JSDoc used by TypeScript-focused projects.
|
|
163
|
+
|
|
164
|
+
Key differences from JSDoc:
|
|
165
|
+
- Uses `{@link ClassName}` for references (not `{@see}`)
|
|
166
|
+
- `@param name -` format (with dash separator)
|
|
167
|
+
- `@throws` without type braces (types are in TypeScript)
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
/**
|
|
171
|
+
* Fetches user data from the API.
|
|
172
|
+
*
|
|
173
|
+
* @param userId - The user's unique identifier
|
|
174
|
+
* @param options - Request configuration
|
|
175
|
+
* @returns The user object, or `undefined` if not found
|
|
176
|
+
*
|
|
177
|
+
* @remarks
|
|
178
|
+
* This method caches results for 5 minutes. Use {@link invalidateCache}
|
|
179
|
+
* to force a fresh fetch.
|
|
180
|
+
*/
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Module / File Headers
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
/**
|
|
187
|
+
* @module payments
|
|
188
|
+
*
|
|
189
|
+
* Payment processing module handling Stripe and PayPal integrations.
|
|
190
|
+
* Entry point: {@link PaymentProcessor.process}
|
|
191
|
+
*/
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Go (godoc)
|
|
197
|
+
|
|
198
|
+
Detection pattern: Comments starting with the function/type name: `Grep: "^// [A-Z]"` before `func` or `type` declarations.
|
|
199
|
+
|
|
200
|
+
```go
|
|
201
|
+
// ProcessPayment charges the customer's default payment method.
|
|
202
|
+
// Amount is in the smallest currency unit (e.g., cents for USD).
|
|
203
|
+
// Currency must be a valid ISO 4217 code.
|
|
204
|
+
//
|
|
205
|
+
// Returns the transaction result or an error if the charge fails.
|
|
206
|
+
// Possible errors: ErrInvalidAmount, ErrCustomerNotFound, ErrGatewayUnavailable.
|
|
207
|
+
func ProcessPayment(amount int64, currency string, customerID string) (*PaymentResult, error) {
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Package Comments
|
|
211
|
+
|
|
212
|
+
```go
|
|
213
|
+
// Package payments provides payment processing across multiple providers.
|
|
214
|
+
//
|
|
215
|
+
// It supports Stripe and PayPal via pluggable adapters. Use NewProcessor
|
|
216
|
+
// to create a processor with the desired provider configuration.
|
|
217
|
+
//
|
|
218
|
+
// Example:
|
|
219
|
+
//
|
|
220
|
+
// p := payments.NewProcessor(payments.WithStripe(apiKey))
|
|
221
|
+
// result, err := p.Process(ctx, 1500, "usd", "cust_123")
|
|
222
|
+
package payments
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### godoc Conventions
|
|
226
|
+
|
|
227
|
+
- First sentence starts with the name being documented: "ProcessPayment charges..."
|
|
228
|
+
- Use complete sentences with proper punctuation.
|
|
229
|
+
- Code examples use tab-indented blocks (no triple backticks).
|
|
230
|
+
- Document exported (capitalized) identifiers only.
|
|
231
|
+
|
|
232
|
+
---
|
|
233
|
+
|
|
234
|
+
## Rust (rustdoc)
|
|
235
|
+
|
|
236
|
+
Detection pattern: `Grep: "/// "` or `Grep: "//! "` in `.rs` files.
|
|
237
|
+
|
|
238
|
+
```rust
|
|
239
|
+
/// Process a payment for the given customer.
|
|
240
|
+
///
|
|
241
|
+
/// Validates the amount, charges the customer's default payment method,
|
|
242
|
+
/// and records the transaction in the payment ledger.
|
|
243
|
+
///
|
|
244
|
+
/// # Arguments
|
|
245
|
+
///
|
|
246
|
+
/// * `amount` - Payment amount in cents (must be positive)
|
|
247
|
+
/// * `currency` - ISO 4217 currency code (e.g., "usd", "eur")
|
|
248
|
+
/// * `customer_id` - The unique customer identifier
|
|
249
|
+
///
|
|
250
|
+
/// # Returns
|
|
251
|
+
///
|
|
252
|
+
/// A `PaymentResult` with transaction ID, status, and timestamp.
|
|
253
|
+
///
|
|
254
|
+
/// # Errors
|
|
255
|
+
///
|
|
256
|
+
/// Returns `PaymentError::InvalidAmount` if the amount is zero or negative.
|
|
257
|
+
/// Returns `PaymentError::CustomerNotFound` if the customer ID is invalid.
|
|
258
|
+
///
|
|
259
|
+
/// # Examples
|
|
260
|
+
///
|
|
261
|
+
/// ```
|
|
262
|
+
/// let result = process_payment(1500, "usd", "cust_abc123")?;
|
|
263
|
+
/// assert_eq!(result.status, PaymentStatus::Completed);
|
|
264
|
+
/// ```
|
|
265
|
+
///
|
|
266
|
+
/// # Panics
|
|
267
|
+
///
|
|
268
|
+
/// Panics if the payment gateway client is not initialized. Call
|
|
269
|
+
/// `init_gateway()` before using this function.
|
|
270
|
+
pub fn process_payment(amount: u64, currency: &str, customer_id: &str) -> Result<PaymentResult, PaymentError> {
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Module Documentation
|
|
274
|
+
|
|
275
|
+
```rust
|
|
276
|
+
//! Payment processing module.
|
|
277
|
+
//!
|
|
278
|
+
//! Handles payment creation, validation, and gateway communication.
|
|
279
|
+
//! Supports Stripe and PayPal providers via the adapter pattern.
|
|
280
|
+
//!
|
|
281
|
+
//! # Overview
|
|
282
|
+
//!
|
|
283
|
+
//! Use [`PaymentProcessor::new`] to create a processor, then call
|
|
284
|
+
//! [`PaymentProcessor::process`] to execute a payment.
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Sections Convention
|
|
288
|
+
|
|
289
|
+
| Section | When to Use |
|
|
290
|
+
|---------|------------|
|
|
291
|
+
| `# Arguments` | All public functions with parameters |
|
|
292
|
+
| `# Returns` | Functions that return non-unit types |
|
|
293
|
+
| `# Errors` | Functions that return `Result` |
|
|
294
|
+
| `# Panics` | Functions that can panic |
|
|
295
|
+
| `# Safety` | Unsafe functions — document invariants |
|
|
296
|
+
| `# Examples` | Always for public API |
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: migration-patterns
|
|
3
|
+
description: >-
|
|
4
|
+
This skill should be used when the user asks to "migrate from X to Y",
|
|
5
|
+
"upgrade to version N", "bump Python version", "upgrade pydantic",
|
|
6
|
+
"migrate express to fastify", "framework migration", "version upgrade",
|
|
7
|
+
"modernize the codebase", or discusses code migration, framework upgrades,
|
|
8
|
+
API version bumps, or dependency migration strategies.
|
|
9
|
+
version: 0.1.0
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Migration Patterns
|
|
13
|
+
|
|
14
|
+
## Mental Model
|
|
15
|
+
|
|
16
|
+
Migrations are a sequence of **small, verifiable, rollback-safe transformations**. Each step must independently compile, pass tests, and leave the system in a valid state. The moment you batch changes or skip verification, you create a state that is harder to debug than the original problem.
|
|
17
|
+
|
|
18
|
+
**Key principles:**
|
|
19
|
+
- **One thing at a time.** Each migration step changes one category of code (imports, API calls, configuration, types). Mixing categories makes failures hard to isolate.
|
|
20
|
+
- **Verify after every step.** Build → Test → Lint after each transformation. A broken intermediate state that goes undetected compounds into an undebuggable mess.
|
|
21
|
+
- **Rollback is always an option.** Git checkpoints after each successful step. If step N fails, you can revert to step N-1 cleanly.
|
|
22
|
+
- **Import mapping first.** Most framework migrations change import paths. Map all imports before modifying call sites — this gives you a complete inventory of affected code.
|
|
23
|
+
- **Official guides are the source of truth.** Always fetch and read the official migration guide before planning. Community blog posts may be outdated or incomplete.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Migration Planning Framework
|
|
28
|
+
|
|
29
|
+
Follow this sequence for every migration:
|
|
30
|
+
|
|
31
|
+
### 1. Assess Current State
|
|
32
|
+
|
|
33
|
+
- Read manifest files to identify current version and all dependencies.
|
|
34
|
+
- Use `Glob` and `Grep` to inventory usage of the APIs being migrated.
|
|
35
|
+
- Count occurrences of each deprecated pattern to estimate effort.
|
|
36
|
+
|
|
37
|
+
### 2. Read Official Guides
|
|
38
|
+
|
|
39
|
+
- Use `WebFetch` to pull the official migration guide, changelog, and breaking changes list.
|
|
40
|
+
- Note every breaking change that applies to the project.
|
|
41
|
+
- Identify changes with no direct replacement — these need special handling.
|
|
42
|
+
|
|
43
|
+
### 3. Inventory Affected Files
|
|
44
|
+
|
|
45
|
+
- Map every file that uses a deprecated API or pattern.
|
|
46
|
+
- Group files by change type (imports, API calls, configuration, types).
|
|
47
|
+
- Count total changes per group to estimate per-step effort.
|
|
48
|
+
|
|
49
|
+
### 4. Order Steps
|
|
50
|
+
|
|
51
|
+
Sequence changes so each step is independently buildable:
|
|
52
|
+
|
|
53
|
+
1. **Configuration** — Manifest files, build configs, tool configs
|
|
54
|
+
2. **Core utilities and shared modules** — Changes here propagate to dependents
|
|
55
|
+
3. **Business logic** — Module by module, starting with lowest dependency count
|
|
56
|
+
4. **Route handlers / controllers** — Often the most numerous changes
|
|
57
|
+
5. **Tests** — Updated last to match migrated source
|
|
58
|
+
|
|
59
|
+
### 5. Risk Assessment
|
|
60
|
+
|
|
61
|
+
Flag high-risk changes:
|
|
62
|
+
- Behavioral changes (same API, different default behavior)
|
|
63
|
+
- Removed APIs with no direct replacement
|
|
64
|
+
- Database schema changes
|
|
65
|
+
- Serialization format changes (affects stored data)
|
|
66
|
+
|
|
67
|
+
### 6. Present Plan
|
|
68
|
+
|
|
69
|
+
Output numbered steps with:
|
|
70
|
+
- File count per step
|
|
71
|
+
- Risk level (low / medium / high)
|
|
72
|
+
- Verification command
|
|
73
|
+
- Rollback command
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Step Verification Protocol
|
|
78
|
+
|
|
79
|
+
After each migration step, run these checks in order:
|
|
80
|
+
|
|
81
|
+
| Check | Command Examples | Purpose |
|
|
82
|
+
|-------|-----------------|---------|
|
|
83
|
+
| **Syntax** | `python -m py_compile`, `npx tsc --noEmit`, `node --check` | Code parses correctly |
|
|
84
|
+
| **Build** | `npm run build`, `cargo build`, `go build ./...` | Project compiles |
|
|
85
|
+
| **Tests** | `pytest`, `npm test`, `cargo test`, `go test ./...` | Behavior preserved |
|
|
86
|
+
| **Lint** | `ruff check`, `npm run lint`, `cargo clippy` | Style and correctness |
|
|
87
|
+
|
|
88
|
+
If any check fails:
|
|
89
|
+
1. Identify which change in this step caused the failure.
|
|
90
|
+
2. Fix within the current step — do not proceed to the next.
|
|
91
|
+
3. If the fix is unclear, report the failure with full error output.
|
|
92
|
+
4. Never fix forward by making changes intended for later steps.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Rollback Strategy
|
|
97
|
+
|
|
98
|
+
- **Before starting**: Verify the user has committed or stashed current work.
|
|
99
|
+
- **After each step**: Suggest a commit checkpoint: "Step N complete — recommend committing now."
|
|
100
|
+
- **On failure**: Provide exact `git checkout -- <files>` commands to revert to the last good state.
|
|
101
|
+
- **Database migrations**: Always plan the down-migration alongside the up-migration.
|
|
102
|
+
- **Feature flags**: For gradual migrations, consider feature flags to run old and new code paths in parallel.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Import-First Strategy
|
|
107
|
+
|
|
108
|
+
Most framework migrations change import paths. Map imports before modifying call sites:
|
|
109
|
+
|
|
110
|
+
1. **Inventory**: `Grep` for all imports from the old framework/library.
|
|
111
|
+
2. **Map**: Create a mapping of old import → new import.
|
|
112
|
+
3. **Transform**: Change all imports in a single step.
|
|
113
|
+
4. **Verify**: Build and test after import changes (some imports may have side effects).
|
|
114
|
+
5. **Proceed**: With imports correct, modify call sites knowing the right modules are loaded.
|
|
115
|
+
|
|
116
|
+
This approach gives you a complete inventory of affected code before making any behavioral changes.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Common Pitfalls
|
|
121
|
+
|
|
122
|
+
| Pitfall | Why It Fails | Prevention |
|
|
123
|
+
|---------|-------------|------------|
|
|
124
|
+
| Batching all changes | One failure breaks everything; can't isolate cause | One category per step |
|
|
125
|
+
| Skipping verification | Errors compound silently | Build + test after every step |
|
|
126
|
+
| Fixing forward | New changes mask existing failures | Fix in current step or revert |
|
|
127
|
+
| Ignoring transitive deps | A dependency may not support the target version | Check compatibility first |
|
|
128
|
+
| Mixing migration with refactoring | Two concerns, double the failure modes | Migrate first, refactor later |
|
|
129
|
+
| Not reading the migration guide | Miss non-obvious behavioral changes | Official guide before planning |
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Ambiguity Policy
|
|
134
|
+
|
|
135
|
+
| Ambiguity | Default |
|
|
136
|
+
|-----------|---------|
|
|
137
|
+
| **Verification depth** | Full suite: build + test + lint after every step |
|
|
138
|
+
| **Step granularity** | One file category per step (imports, then API calls, then config) |
|
|
139
|
+
| **Unknown migration path** | Fetch docs, analyze both APIs, present mapping for review |
|
|
140
|
+
| **Partial migration requested** | Warn about inconsistency; verify the module's own tests pass |
|
|
141
|
+
| **Target version not specified** | Migrate to the latest stable release |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Reference Files
|
|
146
|
+
|
|
147
|
+
| File | Contents |
|
|
148
|
+
|------|----------|
|
|
149
|
+
| [Python Migrations](references/python-migrations.md) | Python version upgrades (3.8→3.12), Pydantic v1→v2 API mapping, Django and SQLAlchemy migration patterns |
|
|
150
|
+
| [JavaScript Migrations](references/javascript-migrations.md) | Express→Fastify mapping, React upgrade patterns, TypeScript version upgrades, CommonJS→ESM migration |
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# JavaScript / TypeScript Migration Patterns
|
|
2
|
+
|
|
3
|
+
## Express → Fastify
|
|
4
|
+
|
|
5
|
+
### Route Mapping
|
|
6
|
+
|
|
7
|
+
| Express | Fastify | Notes |
|
|
8
|
+
|---------|---------|-------|
|
|
9
|
+
| `app.get('/path', handler)` | `fastify.get('/path', handler)` | Similar signature |
|
|
10
|
+
| `app.post('/path', handler)` | `fastify.post('/path', handler)` | Similar signature |
|
|
11
|
+
| `app.use(middleware)` | `fastify.register(plugin)` | Middleware → plugin model |
|
|
12
|
+
| `app.use('/prefix', router)` | `fastify.register(plugin, { prefix: '/prefix' })` | Router → registered plugin |
|
|
13
|
+
|
|
14
|
+
### Request / Response API
|
|
15
|
+
|
|
16
|
+
| Express | Fastify | Notes |
|
|
17
|
+
|---------|---------|-------|
|
|
18
|
+
| `req.body` | `request.body` | Same concept, different naming convention |
|
|
19
|
+
| `req.params.id` | `request.params.id` | Same |
|
|
20
|
+
| `req.query.page` | `request.query.page` | Same |
|
|
21
|
+
| `req.headers` | `request.headers` | Same |
|
|
22
|
+
| `res.status(200).json(data)` | `reply.code(200).send(data)` | `status` → `code`, `json` → `send` |
|
|
23
|
+
| `res.send('text')` | `reply.send('text')` | Same |
|
|
24
|
+
| `res.redirect('/url')` | `reply.redirect('/url')` | Same |
|
|
25
|
+
| `res.set('header', 'value')` | `reply.header('header', 'value')` | `set` → `header` |
|
|
26
|
+
|
|
27
|
+
### Middleware → Plugin Conversion
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
// Express middleware
|
|
31
|
+
app.use((req, res, next) => {
|
|
32
|
+
req.startTime = Date.now();
|
|
33
|
+
next();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Fastify equivalent (using hooks)
|
|
37
|
+
fastify.addHook('onRequest', async (request, reply) => {
|
|
38
|
+
request.startTime = Date.now();
|
|
39
|
+
});
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Error Handling
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
// Express error handler
|
|
46
|
+
app.use((err, req, res, next) => {
|
|
47
|
+
res.status(err.status || 500).json({ error: err.message });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Fastify error handler
|
|
51
|
+
fastify.setErrorHandler((error, request, reply) => {
|
|
52
|
+
reply.code(error.statusCode || 500).send({ error: error.message });
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Migration Steps
|
|
57
|
+
|
|
58
|
+
1. Install Fastify: `npm install fastify`
|
|
59
|
+
2. Create Fastify app instance to replace Express app
|
|
60
|
+
3. Convert middleware to Fastify plugins/hooks
|
|
61
|
+
4. Convert route handlers (update request/response API calls)
|
|
62
|
+
5. Convert error handling
|
|
63
|
+
6. Update tests to use `fastify.inject()` instead of `supertest`
|
|
64
|
+
7. Remove Express: `npm uninstall express`
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## React Version Upgrades
|
|
69
|
+
|
|
70
|
+
### React 17 → 18
|
|
71
|
+
|
|
72
|
+
| Change | Action |
|
|
73
|
+
|--------|--------|
|
|
74
|
+
| `ReactDOM.render()` | Replace with `createRoot().render()` |
|
|
75
|
+
| `ReactDOM.hydrate()` | Replace with `hydrateRoot()` |
|
|
76
|
+
| Automatic batching | No code change — now batches all state updates by default |
|
|
77
|
+
| `useId()` hook | New — use for accessible server/client IDs |
|
|
78
|
+
| Strict Mode double-rendering | Now also double-invokes effects in dev mode |
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
// React 17
|
|
82
|
+
import ReactDOM from 'react-dom';
|
|
83
|
+
ReactDOM.render(<App />, document.getElementById('root'));
|
|
84
|
+
|
|
85
|
+
// React 18
|
|
86
|
+
import { createRoot } from 'react-dom/client';
|
|
87
|
+
const root = createRoot(document.getElementById('root'));
|
|
88
|
+
root.render(<App />);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### React 18 → 19
|
|
92
|
+
|
|
93
|
+
| Change | Action |
|
|
94
|
+
|--------|--------|
|
|
95
|
+
| `forwardRef` | No longer needed — `ref` is a regular prop |
|
|
96
|
+
| `React.lazy` | Now supports server components |
|
|
97
|
+
| Context | `<Context>` replaces `<Context.Provider>` |
|
|
98
|
+
| `use()` hook | New — reads resources (promises, context) during render |
|
|
99
|
+
| `ref` callbacks | Now support cleanup functions (return from callback) |
|
|
100
|
+
| Metadata tags | `<title>`, `<meta>`, `<link>` in components hoist to `<head>` |
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## TypeScript Version Upgrades
|
|
105
|
+
|
|
106
|
+
### Key Changes by Version
|
|
107
|
+
|
|
108
|
+
| Version | Notable Changes |
|
|
109
|
+
|---------|----------------|
|
|
110
|
+
| 4.7 → 4.8 | Stricter type narrowing in `in` operator |
|
|
111
|
+
| 4.8 → 4.9 | `satisfies` operator |
|
|
112
|
+
| 4.9 → 5.0 | Decorators (TC39 standard), `bundler` module resolution |
|
|
113
|
+
| 5.0 → 5.1 | Easier implicit returns for `undefined`, linked cursors |
|
|
114
|
+
| 5.1 → 5.2 | `using` declarations (explicit resource management) |
|
|
115
|
+
| 5.2 → 5.3 | Import attributes, narrowing in `switch(true)` |
|
|
116
|
+
| 5.3 → 5.4 | `NoInfer<T>` utility type, improved narrowing in closures |
|
|
117
|
+
| 5.4 → 5.5 | Inferred type predicates, regex syntax checking |
|
|
118
|
+
|
|
119
|
+
### tsconfig Changes
|
|
120
|
+
|
|
121
|
+
| Old Option | New Option | Version |
|
|
122
|
+
|-----------|-----------|---------|
|
|
123
|
+
| `moduleResolution: "node"` | `moduleResolution: "bundler"` | 5.0+ (for bundled apps) |
|
|
124
|
+
| `target: "es2020"` | `target: "es2022"` | 5.0+ (enables native decorators) |
|
|
125
|
+
| `importsNotUsedAsValues` | `verbatimModuleSyntax` | 5.0 (consolidates 3 flags into 1) |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## CommonJS → ESM Migration
|
|
130
|
+
|
|
131
|
+
### Step-by-Step
|
|
132
|
+
|
|
133
|
+
1. **Update `package.json`**: Add `"type": "module"`
|
|
134
|
+
2. **Rename if needed**: `.js` files become ESM by default; use `.cjs` for files that must stay CommonJS
|
|
135
|
+
3. **Convert imports**:
|
|
136
|
+
|
|
137
|
+
| CommonJS | ESM |
|
|
138
|
+
|----------|-----|
|
|
139
|
+
| `const x = require('pkg')` | `import x from 'pkg'` |
|
|
140
|
+
| `const { a, b } = require('pkg')` | `import { a, b } from 'pkg'` |
|
|
141
|
+
| `module.exports = x` | `export default x` |
|
|
142
|
+
| `module.exports = { a, b }` | `export { a, b }` |
|
|
143
|
+
| `exports.a = x` | `export const a = x` |
|
|
144
|
+
|
|
145
|
+
4. **Fix path imports**: ESM requires file extensions in relative imports: `import x from './utils.js'` (not `'./utils'`)
|
|
146
|
+
5. **Replace `__dirname` / `__filename`**:
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
// CommonJS
|
|
150
|
+
const dir = __dirname;
|
|
151
|
+
const file = __filename;
|
|
152
|
+
|
|
153
|
+
// ESM
|
|
154
|
+
import { fileURLToPath } from 'url';
|
|
155
|
+
import { dirname } from 'path';
|
|
156
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
157
|
+
const __dirname = dirname(__filename);
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
6. **Replace `require.resolve`**:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
// CommonJS
|
|
164
|
+
const resolved = require.resolve('pkg');
|
|
165
|
+
|
|
166
|
+
// ESM
|
|
167
|
+
import { createRequire } from 'module';
|
|
168
|
+
const require = createRequire(import.meta.url);
|
|
169
|
+
const resolved = require.resolve('pkg');
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
7. **Update tooling configs**: Jest, ESLint, and other tools may need config changes for ESM support.
|
|
173
|
+
|
|
174
|
+
### Common Gotchas
|
|
175
|
+
|
|
176
|
+
- JSON imports require import assertions: `import data from './data.json' with { type: 'json' }`
|
|
177
|
+
- Dynamic imports (`import()`) return a module namespace object with a `.default` property
|
|
178
|
+
- Top-level `await` is available in ESM (not in CommonJS)
|
|
179
|
+
- Some packages only export CommonJS — use `import pkg from 'pkg'` (default import) or dynamic `import()`
|