@mind-fold/open-flow 0.1.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/README.md +176 -0
- package/bin/open-flow.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +32 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/init.d.ts +8 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +202 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/configurators/claude.d.ts +2 -0
- package/dist/configurators/claude.d.ts.map +1 -0
- package/dist/configurators/claude.js +16 -0
- package/dist/configurators/claude.js.map +1 -0
- package/dist/configurators/cursor.d.ts +2 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +16 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/templates.d.ts +9 -0
- package/dist/configurators/templates.d.ts.map +1 -0
- package/dist/configurators/templates.js +97 -0
- package/dist/configurators/templates.js.map +1 -0
- package/dist/configurators/workflow.d.ts +2 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +739 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
export async function createWorkflowStructure(cwd) {
|
|
4
|
+
const workflowDir = path.join(cwd, 'workflow');
|
|
5
|
+
// Create directories
|
|
6
|
+
const dirs = [
|
|
7
|
+
'workflow',
|
|
8
|
+
'workflow/scripts',
|
|
9
|
+
'workflow/agent-progress',
|
|
10
|
+
'workflow/structure',
|
|
11
|
+
'workflow/structure/frontend',
|
|
12
|
+
'workflow/structure/backend',
|
|
13
|
+
];
|
|
14
|
+
for (const dir of dirs) {
|
|
15
|
+
fs.mkdirSync(path.join(cwd, dir), { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
// Create scripts
|
|
18
|
+
await createScripts(cwd);
|
|
19
|
+
// Create agent-progress index
|
|
20
|
+
await createAgentProgressIndex(cwd);
|
|
21
|
+
// Create structure templates
|
|
22
|
+
await createStructureTemplates(cwd);
|
|
23
|
+
// Create feature.json
|
|
24
|
+
await createFeatureJson(cwd);
|
|
25
|
+
// Create flow.md
|
|
26
|
+
await createFlowMd(cwd);
|
|
27
|
+
// Create .gitignore for workflow
|
|
28
|
+
await createWorkflowGitignore(cwd);
|
|
29
|
+
}
|
|
30
|
+
async function createScripts(cwd) {
|
|
31
|
+
const initDeveloperScript = `#!/bin/bash
|
|
32
|
+
|
|
33
|
+
# Initialize developer identity for open-flow
|
|
34
|
+
# Usage: ./workflow/scripts/init-developer.sh <developer-name>
|
|
35
|
+
|
|
36
|
+
SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
37
|
+
WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
|
|
38
|
+
|
|
39
|
+
if [ -z "$1" ]; then
|
|
40
|
+
echo "Usage: $0 <developer-name>"
|
|
41
|
+
echo "Example: $0 john-doe"
|
|
42
|
+
exit 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
DEVELOPER_NAME="$1"
|
|
46
|
+
DEVELOPER_FILE="$WORKFLOW_DIR/.developer"
|
|
47
|
+
PROGRESS_DIR="$WORKFLOW_DIR/agent-progress/$DEVELOPER_NAME"
|
|
48
|
+
|
|
49
|
+
# Check if already initialized
|
|
50
|
+
if [ -f "$DEVELOPER_FILE" ]; then
|
|
51
|
+
CURRENT=$(cat "$DEVELOPER_FILE" | grep "name:" | cut -d' ' -f2)
|
|
52
|
+
echo "Already initialized as: $CURRENT"
|
|
53
|
+
read -p "Override with $DEVELOPER_NAME? (y/N) " -n 1 -r
|
|
54
|
+
echo
|
|
55
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
56
|
+
exit 0
|
|
57
|
+
fi
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
# Create developer identity file
|
|
61
|
+
cat > "$DEVELOPER_FILE" << EOF
|
|
62
|
+
# Developer Identity (gitignored)
|
|
63
|
+
# Created by open-flow
|
|
64
|
+
|
|
65
|
+
name: $DEVELOPER_NAME
|
|
66
|
+
created: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
67
|
+
EOF
|
|
68
|
+
|
|
69
|
+
# Create progress directory
|
|
70
|
+
mkdir -p "$PROGRESS_DIR"
|
|
71
|
+
|
|
72
|
+
# Create personal index
|
|
73
|
+
cat > "$PROGRESS_DIR/index.md" << EOF
|
|
74
|
+
# Agent Progress - $DEVELOPER_NAME
|
|
75
|
+
|
|
76
|
+
> Personal progress tracking for $DEVELOPER_NAME
|
|
77
|
+
|
|
78
|
+
## Current Status
|
|
79
|
+
|
|
80
|
+
- **Active File**: \\\`progress-1.md\\\`
|
|
81
|
+
- **Total Sessions**: 0
|
|
82
|
+
- **Last Active**: $(date +%Y-%m-%d)
|
|
83
|
+
|
|
84
|
+
## Active Documents
|
|
85
|
+
|
|
86
|
+
| File | Lines | Status |
|
|
87
|
+
|------|-------|--------|
|
|
88
|
+
| \\\`progress-1.md\\\` | ~0 | Active |
|
|
89
|
+
|
|
90
|
+
## Session History (Recent)
|
|
91
|
+
|
|
92
|
+
| Session | Date | Title | Commit |
|
|
93
|
+
|---------|------|-------|--------|
|
|
94
|
+
| - | - | - | - |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Notes
|
|
99
|
+
|
|
100
|
+
- Each progress file has max 2000 lines
|
|
101
|
+
- When exceeded, create new file and archive old one
|
|
102
|
+
- Update this index when creating new files
|
|
103
|
+
EOF
|
|
104
|
+
|
|
105
|
+
# Create initial progress file
|
|
106
|
+
cat > "$PROGRESS_DIR/progress-1.md" << EOF
|
|
107
|
+
# Progress Record - $DEVELOPER_NAME
|
|
108
|
+
|
|
109
|
+
> Session-by-session work log
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Session 1 - $(date +%Y-%m-%d)
|
|
114
|
+
|
|
115
|
+
### Summary
|
|
116
|
+
Initial setup
|
|
117
|
+
|
|
118
|
+
### Main Changes
|
|
119
|
+
- Initialized developer identity
|
|
120
|
+
|
|
121
|
+
### Git Commits
|
|
122
|
+
- N/A (initial setup)
|
|
123
|
+
|
|
124
|
+
### Next Steps
|
|
125
|
+
- Start first development task
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
EOF
|
|
129
|
+
|
|
130
|
+
echo "✅ Developer identity initialized: $DEVELOPER_NAME"
|
|
131
|
+
echo " Progress directory: $PROGRESS_DIR"
|
|
132
|
+
`;
|
|
133
|
+
const getDeveloperScript = `#!/bin/bash
|
|
134
|
+
|
|
135
|
+
# Get current developer identity
|
|
136
|
+
# Usage: ./workflow/scripts/get-developer.sh
|
|
137
|
+
|
|
138
|
+
SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
139
|
+
WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
|
|
140
|
+
DEVELOPER_FILE="$WORKFLOW_DIR/.developer"
|
|
141
|
+
|
|
142
|
+
if [ ! -f "$DEVELOPER_FILE" ]; then
|
|
143
|
+
echo "Not initialized. Run: ./workflow/scripts/init-developer.sh <your-name>" >&2
|
|
144
|
+
exit 1
|
|
145
|
+
fi
|
|
146
|
+
|
|
147
|
+
cat "$DEVELOPER_FILE" | grep "name:" | cut -d' ' -f2
|
|
148
|
+
`;
|
|
149
|
+
fs.writeFileSync(path.join(cwd, 'workflow/scripts/init-developer.sh'), initDeveloperScript);
|
|
150
|
+
fs.writeFileSync(path.join(cwd, 'workflow/scripts/get-developer.sh'), getDeveloperScript);
|
|
151
|
+
// Make scripts executable
|
|
152
|
+
fs.chmodSync(path.join(cwd, 'workflow/scripts/init-developer.sh'), '755');
|
|
153
|
+
fs.chmodSync(path.join(cwd, 'workflow/scripts/get-developer.sh'), '755');
|
|
154
|
+
}
|
|
155
|
+
async function createAgentProgressIndex(cwd) {
|
|
156
|
+
const content = `# Agent Progress
|
|
157
|
+
|
|
158
|
+
> Multi-developer progress tracking system
|
|
159
|
+
|
|
160
|
+
## Overview
|
|
161
|
+
|
|
162
|
+
Each developer (human or AI agent) has their own progress directory under \`agent-progress/\`.
|
|
163
|
+
|
|
164
|
+
## Structure
|
|
165
|
+
|
|
166
|
+
\`\`\`
|
|
167
|
+
agent-progress/
|
|
168
|
+
├── index.md # This file
|
|
169
|
+
└── {developer}/ # Per-developer directory
|
|
170
|
+
├── index.md # Personal index
|
|
171
|
+
└── progress-N.md # Progress files (sequential: 1, 2, 3...)
|
|
172
|
+
\`\`\`
|
|
173
|
+
|
|
174
|
+
## Active Developers
|
|
175
|
+
|
|
176
|
+
| Developer | Active File | Last Active |
|
|
177
|
+
|-----------|-------------|-------------|
|
|
178
|
+
| - | - | - |
|
|
179
|
+
|
|
180
|
+
## Session Template
|
|
181
|
+
|
|
182
|
+
When recording a session, use this format:
|
|
183
|
+
|
|
184
|
+
\`\`\`markdown
|
|
185
|
+
## Session N - YYYY-MM-DD
|
|
186
|
+
|
|
187
|
+
### Summary
|
|
188
|
+
One-line description of what was done
|
|
189
|
+
|
|
190
|
+
### Main Changes
|
|
191
|
+
- File1: Description of changes
|
|
192
|
+
- File2: Description of changes
|
|
193
|
+
|
|
194
|
+
### Git Commits
|
|
195
|
+
- \`abc1234\` - commit message
|
|
196
|
+
|
|
197
|
+
### Testing
|
|
198
|
+
- [x] pnpm lint passed
|
|
199
|
+
- [x] pnpm type-check passed
|
|
200
|
+
- [x] Manual testing passed
|
|
201
|
+
|
|
202
|
+
### Related Features
|
|
203
|
+
- feature-id from feature.json
|
|
204
|
+
|
|
205
|
+
### Next Steps
|
|
206
|
+
- What to do next
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
\`\`\`
|
|
210
|
+
|
|
211
|
+
## Rules
|
|
212
|
+
|
|
213
|
+
1. **Max 2000 lines per progress file** - Create new file when exceeded
|
|
214
|
+
2. **Include commit hashes** - For traceability
|
|
215
|
+
3. **Update personal index** - After each session
|
|
216
|
+
4. **Sequential numbering** - progress-1.md, progress-2.md, etc.
|
|
217
|
+
`;
|
|
218
|
+
fs.writeFileSync(path.join(cwd, 'workflow/agent-progress/index.md'), content);
|
|
219
|
+
}
|
|
220
|
+
async function createStructureTemplates(cwd) {
|
|
221
|
+
// Frontend index.md
|
|
222
|
+
const frontendIndex = `# Frontend Development Guidelines Index
|
|
223
|
+
|
|
224
|
+
> **Full documentation**: See \`./doc.md\` for detailed guidelines
|
|
225
|
+
|
|
226
|
+
This index helps you quickly locate the guidelines you need based on your task type.
|
|
227
|
+
|
|
228
|
+
## Quick Navigation
|
|
229
|
+
|
|
230
|
+
| Task | Section | Line Range |
|
|
231
|
+
|------|---------|------------|
|
|
232
|
+
| **New feature module** | Directory Structure | L5-30 |
|
|
233
|
+
| **Write Query Hook** | Hook Guidelines > Query | L50-100 |
|
|
234
|
+
| **Write Mutation Hook** | Hook Guidelines > Mutation | L100-150 |
|
|
235
|
+
| **API calls** | API Guidelines | L150-250 |
|
|
236
|
+
| **State management** | State Guidelines | L250-350 |
|
|
237
|
+
| **Write component** | Component Guidelines | L350-500 |
|
|
238
|
+
| **Performance optimization** | Performance Guidelines | L500-600 |
|
|
239
|
+
| **Code quality check** | Quality Guidelines | L600-700 |
|
|
240
|
+
|
|
241
|
+
## Core Rules
|
|
242
|
+
|
|
243
|
+
| Rule | Location |
|
|
244
|
+
|------|----------|
|
|
245
|
+
| Import types from backend | L50-60 |
|
|
246
|
+
| Use semantic HTML | L400-420 |
|
|
247
|
+
| Use Next.js Image | L420-440 |
|
|
248
|
+
| No non-null assertions | L600-620 |
|
|
249
|
+
|
|
250
|
+
## Reference Files
|
|
251
|
+
|
|
252
|
+
| Feature | Reference File |
|
|
253
|
+
|---------|----------------|
|
|
254
|
+
| Query Hook | (add your example file path) |
|
|
255
|
+
| Mutation Hook | (add your example file path) |
|
|
256
|
+
| Component | (add your example file path) |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
Fill in the line numbers and reference files based on your project's doc.md content.
|
|
261
|
+
`;
|
|
262
|
+
const frontendDoc = `# Frontend Development Guidelines
|
|
263
|
+
|
|
264
|
+
> Complete guidelines for frontend development
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
## 1. Directory Structure (L5-30)
|
|
269
|
+
|
|
270
|
+
\`\`\`
|
|
271
|
+
modules/
|
|
272
|
+
├── {feature}/
|
|
273
|
+
│ ├── components/ # UI components
|
|
274
|
+
│ ├── hooks/ # Custom hooks
|
|
275
|
+
│ ├── context/ # React context
|
|
276
|
+
│ └── types.ts # Type definitions
|
|
277
|
+
\`\`\`
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 2. Type Safety (L30-50)
|
|
282
|
+
|
|
283
|
+
### Import Types from Backend
|
|
284
|
+
|
|
285
|
+
Always import types from the API package instead of redefining them:
|
|
286
|
+
|
|
287
|
+
\`\`\`typescript
|
|
288
|
+
// ✅ Good
|
|
289
|
+
import type { User } from '@/packages/api';
|
|
290
|
+
|
|
291
|
+
// ❌ Bad - don't redefine
|
|
292
|
+
interface User {
|
|
293
|
+
id: string;
|
|
294
|
+
name: string;
|
|
295
|
+
}
|
|
296
|
+
\`\`\`
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 3. Hook Guidelines (L50-150)
|
|
301
|
+
|
|
302
|
+
### Query Hook (L50-100)
|
|
303
|
+
|
|
304
|
+
\`\`\`typescript
|
|
305
|
+
// Template for query hooks
|
|
306
|
+
export function useExample() {
|
|
307
|
+
return useQuery({
|
|
308
|
+
queryKey: ['example'],
|
|
309
|
+
queryFn: async () => {
|
|
310
|
+
// API call
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
\`\`\`
|
|
315
|
+
|
|
316
|
+
### Mutation Hook (L100-150)
|
|
317
|
+
|
|
318
|
+
\`\`\`typescript
|
|
319
|
+
// Template for mutation hooks
|
|
320
|
+
export function useUpdateExample() {
|
|
321
|
+
const queryClient = useQueryClient();
|
|
322
|
+
|
|
323
|
+
return useMutation({
|
|
324
|
+
mutationFn: async (data) => {
|
|
325
|
+
// API call
|
|
326
|
+
},
|
|
327
|
+
onSuccess: () => {
|
|
328
|
+
queryClient.invalidateQueries({ queryKey: ['example'] });
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
\`\`\`
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 4. API Guidelines (L150-250)
|
|
337
|
+
|
|
338
|
+
(Add your project-specific API guidelines here)
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## 5. State Management (L250-350)
|
|
343
|
+
|
|
344
|
+
(Add your project-specific state management guidelines here)
|
|
345
|
+
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
## 6. Component Guidelines (L350-500)
|
|
349
|
+
|
|
350
|
+
### Semantic HTML
|
|
351
|
+
|
|
352
|
+
Use proper HTML elements:
|
|
353
|
+
|
|
354
|
+
\`\`\`tsx
|
|
355
|
+
// ✅ Good
|
|
356
|
+
<button onClick={handleClick}>Click me</button>
|
|
357
|
+
|
|
358
|
+
// ❌ Bad
|
|
359
|
+
<div role="button" onClick={handleClick}>Click me</div>
|
|
360
|
+
\`\`\`
|
|
361
|
+
|
|
362
|
+
### Image Optimization
|
|
363
|
+
|
|
364
|
+
Use Next.js Image component:
|
|
365
|
+
|
|
366
|
+
\`\`\`tsx
|
|
367
|
+
// ✅ Good
|
|
368
|
+
import Image from 'next/image';
|
|
369
|
+
<Image src="/logo.png" alt="Logo" width={100} height={100} />
|
|
370
|
+
|
|
371
|
+
// ❌ Bad
|
|
372
|
+
<img src="/logo.png" alt="Logo" />
|
|
373
|
+
\`\`\`
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 7. Performance Guidelines (L500-600)
|
|
378
|
+
|
|
379
|
+
(Add your project-specific performance guidelines here)
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 8. Quality Guidelines (L600-700)
|
|
384
|
+
|
|
385
|
+
### Before Every Commit
|
|
386
|
+
|
|
387
|
+
- [ ] \`pnpm lint\` - 0 errors
|
|
388
|
+
- [ ] \`pnpm type-check\` - No type errors
|
|
389
|
+
- [ ] Manual testing passes
|
|
390
|
+
|
|
391
|
+
### Forbidden Patterns
|
|
392
|
+
|
|
393
|
+
- No non-null assertions (\`!\`)
|
|
394
|
+
- No \`any\` type
|
|
395
|
+
- No unused imports/variables
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
**Note**: Update line numbers in index.md when you modify this document.
|
|
400
|
+
`;
|
|
401
|
+
// Backend index.md
|
|
402
|
+
const backendIndex = `# Backend Development Guidelines Index
|
|
403
|
+
|
|
404
|
+
> **Full documentation**: See \`./doc.md\` for detailed guidelines
|
|
405
|
+
|
|
406
|
+
This index helps you quickly locate the guidelines you need based on your task type.
|
|
407
|
+
|
|
408
|
+
## Quick Navigation
|
|
409
|
+
|
|
410
|
+
| Task | Section | Line Range |
|
|
411
|
+
|------|---------|------------|
|
|
412
|
+
| **New API module** | Directory Structure | L5-30 |
|
|
413
|
+
| **Type safety** | Type Safety | L30-100 |
|
|
414
|
+
| **Database operations** | Database Guidelines | L100-200 |
|
|
415
|
+
| **Error handling** | Error Handling | L200-250 |
|
|
416
|
+
| **Logging** | Logging Guidelines | L250-300 |
|
|
417
|
+
| **AI/Prompt** | AI Guidelines | L300-400 |
|
|
418
|
+
| **Code quality** | Quality Guidelines | L400-500 |
|
|
419
|
+
|
|
420
|
+
## Core Rules
|
|
421
|
+
|
|
422
|
+
| Rule | Location |
|
|
423
|
+
|------|----------|
|
|
424
|
+
| No non-null assertions | L40-60 |
|
|
425
|
+
| All inputs/outputs need Zod Schema | L60-80 |
|
|
426
|
+
| Use structured logging | L250-270 |
|
|
427
|
+
| No await in loops | L120-140 |
|
|
428
|
+
|
|
429
|
+
## Reference Files
|
|
430
|
+
|
|
431
|
+
| Feature | Reference File |
|
|
432
|
+
|---------|----------------|
|
|
433
|
+
| API Route | (add your example file path) |
|
|
434
|
+
| Database Query | (add your example file path) |
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
Fill in the line numbers and reference files based on your project's doc.md content.
|
|
439
|
+
`;
|
|
440
|
+
const backendDoc = `# Backend Development Guidelines
|
|
441
|
+
|
|
442
|
+
> Complete guidelines for backend development
|
|
443
|
+
|
|
444
|
+
---
|
|
445
|
+
|
|
446
|
+
## 1. Directory Structure (L5-30)
|
|
447
|
+
|
|
448
|
+
\`\`\`
|
|
449
|
+
packages/api/modules/
|
|
450
|
+
├── {module}/
|
|
451
|
+
│ ├── router.ts # Route definitions
|
|
452
|
+
│ ├── procedures/ # Business logic
|
|
453
|
+
│ ├── types.ts # Type definitions
|
|
454
|
+
│ └── api/ # API documentation
|
|
455
|
+
│ └── *.md
|
|
456
|
+
\`\`\`
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
## 2. Type Safety (L30-100)
|
|
461
|
+
|
|
462
|
+
### No Non-Null Assertions (L40-60)
|
|
463
|
+
|
|
464
|
+
\`\`\`typescript
|
|
465
|
+
// ✅ Good - use local variable
|
|
466
|
+
const user = await getUser(id);
|
|
467
|
+
if (!user) {
|
|
468
|
+
throw new Error('User not found');
|
|
469
|
+
}
|
|
470
|
+
const userName = user.name; // Safe access
|
|
471
|
+
|
|
472
|
+
// ❌ Bad - non-null assertion
|
|
473
|
+
const userName = user!.name;
|
|
474
|
+
\`\`\`
|
|
475
|
+
|
|
476
|
+
### Zod Schema (L60-80)
|
|
477
|
+
|
|
478
|
+
\`\`\`typescript
|
|
479
|
+
// All inputs and outputs need Zod schemas
|
|
480
|
+
const inputSchema = z.object({
|
|
481
|
+
id: z.string(),
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
const outputSchema = z.object({
|
|
485
|
+
success: z.boolean(),
|
|
486
|
+
data: z.object({...}),
|
|
487
|
+
});
|
|
488
|
+
\`\`\`
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## 3. Database Guidelines (L100-200)
|
|
493
|
+
|
|
494
|
+
### No Await in Loops (L120-140)
|
|
495
|
+
|
|
496
|
+
\`\`\`typescript
|
|
497
|
+
// ✅ Good - parallel execution
|
|
498
|
+
const results = await Promise.all(
|
|
499
|
+
ids.map(id => db.query.users.findFirst({ where: eq(users.id, id) }))
|
|
500
|
+
);
|
|
501
|
+
|
|
502
|
+
// ❌ Bad - sequential execution
|
|
503
|
+
for (const id of ids) {
|
|
504
|
+
await db.query.users.findFirst({ where: eq(users.id, id) });
|
|
505
|
+
}
|
|
506
|
+
\`\`\`
|
|
507
|
+
|
|
508
|
+
### Batch Operations (L140-160)
|
|
509
|
+
|
|
510
|
+
\`\`\`typescript
|
|
511
|
+
// Use batch insert with conflict handling
|
|
512
|
+
await db.insert(users).values(data).onConflictDoUpdate({
|
|
513
|
+
target: users.id,
|
|
514
|
+
set: { updatedAt: new Date() },
|
|
515
|
+
});
|
|
516
|
+
\`\`\`
|
|
517
|
+
|
|
518
|
+
---
|
|
519
|
+
|
|
520
|
+
## 4. Error Handling (L200-250)
|
|
521
|
+
|
|
522
|
+
(Add your project-specific error handling guidelines here)
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 5. Logging Guidelines (L250-300)
|
|
527
|
+
|
|
528
|
+
### Use Structured Logging
|
|
529
|
+
|
|
530
|
+
\`\`\`typescript
|
|
531
|
+
// ✅ Good
|
|
532
|
+
logger.info('User created', { userId: user.id, email: user.email });
|
|
533
|
+
|
|
534
|
+
// ❌ Bad
|
|
535
|
+
console.log('User created: ' + user.id);
|
|
536
|
+
\`\`\`
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## 6. AI Guidelines (L300-400)
|
|
541
|
+
|
|
542
|
+
(Add your project-specific AI/prompt guidelines here)
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## 7. Quality Guidelines (L400-500)
|
|
547
|
+
|
|
548
|
+
### Before Every Commit
|
|
549
|
+
|
|
550
|
+
- [ ] \`pnpm lint\` - 0 errors
|
|
551
|
+
- [ ] \`pnpm type-check\` - No type errors
|
|
552
|
+
- [ ] API documentation updated
|
|
553
|
+
|
|
554
|
+
### Forbidden Patterns
|
|
555
|
+
|
|
556
|
+
- No non-null assertions (\`!\`)
|
|
557
|
+
- No \`console.log\` (use logger)
|
|
558
|
+
- No await in loops
|
|
559
|
+
|
|
560
|
+
---
|
|
561
|
+
|
|
562
|
+
**Note**: Update line numbers in index.md when you modify this document.
|
|
563
|
+
`;
|
|
564
|
+
fs.writeFileSync(path.join(cwd, 'workflow/structure/frontend/index.md'), frontendIndex);
|
|
565
|
+
fs.writeFileSync(path.join(cwd, 'workflow/structure/frontend/doc.md'), frontendDoc);
|
|
566
|
+
fs.writeFileSync(path.join(cwd, 'workflow/structure/backend/index.md'), backendIndex);
|
|
567
|
+
fs.writeFileSync(path.join(cwd, 'workflow/structure/backend/doc.md'), backendDoc);
|
|
568
|
+
}
|
|
569
|
+
async function createFeatureJson(cwd) {
|
|
570
|
+
const content = {
|
|
571
|
+
project: 'My Project',
|
|
572
|
+
lastUpdated: new Date().toISOString().split('T')[0],
|
|
573
|
+
version: '1.0.0',
|
|
574
|
+
categories: {
|
|
575
|
+
example: {
|
|
576
|
+
name: 'Example Category',
|
|
577
|
+
features: [
|
|
578
|
+
{
|
|
579
|
+
id: 'example-001',
|
|
580
|
+
name: 'Example Feature',
|
|
581
|
+
description: 'An example feature to demonstrate the structure',
|
|
582
|
+
status: 'planned',
|
|
583
|
+
priority: 'medium',
|
|
584
|
+
},
|
|
585
|
+
],
|
|
586
|
+
},
|
|
587
|
+
},
|
|
588
|
+
statistics: {
|
|
589
|
+
totalFeatures: 1,
|
|
590
|
+
completed: 0,
|
|
591
|
+
inProgress: 0,
|
|
592
|
+
planned: 1,
|
|
593
|
+
blocked: 0,
|
|
594
|
+
completionRate: '0%',
|
|
595
|
+
},
|
|
596
|
+
notes: [
|
|
597
|
+
'Feature ID format: category-XXX (e.g., auth-001, ui-002)',
|
|
598
|
+
'Status: completed | in-progress | planned | blocked',
|
|
599
|
+
'Priority: high | medium | low',
|
|
600
|
+
'When completed, add completedAt (YYYY-MM-DD) and commit (hash)',
|
|
601
|
+
'When blocked, add blockedReason field',
|
|
602
|
+
'Update statistics after changing feature status',
|
|
603
|
+
],
|
|
604
|
+
};
|
|
605
|
+
fs.writeFileSync(path.join(cwd, 'workflow/feature.json'), JSON.stringify(content, null, 2));
|
|
606
|
+
}
|
|
607
|
+
async function createFlowMd(cwd) {
|
|
608
|
+
const content = `# Development Workflow
|
|
609
|
+
|
|
610
|
+
> Based on [Effective Harnesses for Long-Running Agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents)
|
|
611
|
+
|
|
612
|
+
---
|
|
613
|
+
|
|
614
|
+
## Core Principles
|
|
615
|
+
|
|
616
|
+
1. **Read Before Write** - Understand context before starting
|
|
617
|
+
2. **Follow Standards** - Read \`workflow/structure/\` guidelines before coding
|
|
618
|
+
3. **Incremental Development** - Complete one feature at a time
|
|
619
|
+
4. **Record Promptly** - Update tracking files after completion
|
|
620
|
+
5. **Document Limits** - Max 2000 lines per agent-progress document
|
|
621
|
+
|
|
622
|
+
---
|
|
623
|
+
|
|
624
|
+
## Session Start Process
|
|
625
|
+
|
|
626
|
+
### Step 1: Read Work Context
|
|
627
|
+
|
|
628
|
+
\`\`\`bash
|
|
629
|
+
# 0. Check your developer identity
|
|
630
|
+
./workflow/scripts/get-developer.sh
|
|
631
|
+
|
|
632
|
+
# 1. Check recent work progress (your own directory)
|
|
633
|
+
DEVELOPER=$(./workflow/scripts/get-developer.sh)
|
|
634
|
+
cat workflow/agent-progress/$DEVELOPER/index.md
|
|
635
|
+
|
|
636
|
+
# 2. Check feature status
|
|
637
|
+
cat workflow/feature.json
|
|
638
|
+
|
|
639
|
+
# 3. Check Git history
|
|
640
|
+
git status
|
|
641
|
+
git log --oneline -20
|
|
642
|
+
\`\`\`
|
|
643
|
+
|
|
644
|
+
### Step 2: Read Development Guidelines
|
|
645
|
+
|
|
646
|
+
Based on your task (frontend/backend), read the corresponding guidelines:
|
|
647
|
+
|
|
648
|
+
\`\`\`bash
|
|
649
|
+
# Frontend
|
|
650
|
+
cat workflow/structure/frontend/index.md
|
|
651
|
+
|
|
652
|
+
# Backend
|
|
653
|
+
cat workflow/structure/backend/index.md
|
|
654
|
+
\`\`\`
|
|
655
|
+
|
|
656
|
+
### Step 3: Select Feature to Develop
|
|
657
|
+
|
|
658
|
+
Based on \`workflow/feature.json\`:
|
|
659
|
+
- Prioritize \`in-progress\` status features
|
|
660
|
+
- Then select \`planned\` with \`priority: high\`
|
|
661
|
+
- Only select one feature at a time
|
|
662
|
+
|
|
663
|
+
---
|
|
664
|
+
|
|
665
|
+
## Development Process
|
|
666
|
+
|
|
667
|
+
\`\`\`
|
|
668
|
+
1. Update feature.json
|
|
669
|
+
└─> Change selected feature status to "in-progress"
|
|
670
|
+
|
|
671
|
+
2. Write code according to guidelines
|
|
672
|
+
└─> Follow workflow/structure/ guidelines
|
|
673
|
+
|
|
674
|
+
3. Self-test
|
|
675
|
+
└─> pnpm lint (must pass)
|
|
676
|
+
└─> pnpm type-check (must pass)
|
|
677
|
+
└─> Manual feature testing
|
|
678
|
+
|
|
679
|
+
4. Commit code (human responsibility)
|
|
680
|
+
└─> git add <files>
|
|
681
|
+
└─> git commit -m "type(scope): description"
|
|
682
|
+
|
|
683
|
+
5. Update tracking files
|
|
684
|
+
└─> agent-progress: Record session work
|
|
685
|
+
└─> feature.json: Update feature status
|
|
686
|
+
\`\`\`
|
|
687
|
+
|
|
688
|
+
---
|
|
689
|
+
|
|
690
|
+
## Session End
|
|
691
|
+
|
|
692
|
+
### Checklist
|
|
693
|
+
|
|
694
|
+
1. ✅ All code committed
|
|
695
|
+
2. ✅ \`workflow/agent-progress/{developer}/progress-N.md\` updated
|
|
696
|
+
3. ✅ \`workflow/feature.json\` status updated
|
|
697
|
+
4. ✅ No lint/type-check errors
|
|
698
|
+
|
|
699
|
+
---
|
|
700
|
+
|
|
701
|
+
## Best Practices
|
|
702
|
+
|
|
703
|
+
### DO
|
|
704
|
+
- Read guidelines before coding
|
|
705
|
+
- Update agent-progress after each session
|
|
706
|
+
- Include commit hashes in progress records
|
|
707
|
+
- Run lint and type-check before finishing
|
|
708
|
+
|
|
709
|
+
### DON'T
|
|
710
|
+
- Skip reading guidelines (CRITICAL VIOLATION)
|
|
711
|
+
- Let agent-progress exceed 2000 lines
|
|
712
|
+
- Commit code with lint/type-check errors
|
|
713
|
+
- Execute \`git commit\` as AI - human reviews and commits
|
|
714
|
+
|
|
715
|
+
---
|
|
716
|
+
|
|
717
|
+
## Common Commands
|
|
718
|
+
|
|
719
|
+
\`\`\`bash
|
|
720
|
+
# Development
|
|
721
|
+
pnpm dev # Start dev server
|
|
722
|
+
pnpm build # Production build
|
|
723
|
+
pnpm lint # Lint check
|
|
724
|
+
pnpm type-check # Type check
|
|
725
|
+
|
|
726
|
+
# Git
|
|
727
|
+
git log --oneline -20 # Recent commits
|
|
728
|
+
git status # Working directory status
|
|
729
|
+
\`\`\`
|
|
730
|
+
`;
|
|
731
|
+
fs.writeFileSync(path.join(cwd, 'workflow/flow.md'), content);
|
|
732
|
+
}
|
|
733
|
+
async function createWorkflowGitignore(cwd) {
|
|
734
|
+
const content = `# Developer identity (local only)
|
|
735
|
+
.developer
|
|
736
|
+
`;
|
|
737
|
+
fs.writeFileSync(path.join(cwd, 'workflow/.gitignore'), content);
|
|
738
|
+
}
|
|
739
|
+
//# sourceMappingURL=workflow.js.map
|