@mind-fold/open-flow 0.1.9 → 0.1.11

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.
Files changed (107) hide show
  1. package/README.md +1 -0
  2. package/dist/configurators/templates.d.ts.map +1 -1
  3. package/dist/configurators/templates.js +14 -837
  4. package/dist/configurators/templates.js.map +1 -1
  5. package/dist/configurators/workflow.d.ts.map +1 -1
  6. package/dist/configurators/workflow.js +24 -1547
  7. package/dist/configurators/workflow.js.map +1 -1
  8. package/dist/templates/commands/before-backend-dev.txt +10 -0
  9. package/dist/templates/commands/before-frontend-dev.txt +10 -0
  10. package/dist/templates/commands/check-backend.txt +9 -0
  11. package/dist/templates/commands/check-frontend.txt +9 -0
  12. package/dist/templates/commands/create-command.txt +155 -0
  13. package/dist/templates/commands/generate-backend-structure.txt +341 -0
  14. package/dist/templates/commands/generate-frontend-structure.txt +297 -0
  15. package/dist/templates/commands/index.d.ts +18 -0
  16. package/dist/templates/commands/index.d.ts.map +1 -0
  17. package/dist/templates/commands/index.js +19 -0
  18. package/dist/templates/commands/index.js.map +1 -0
  19. package/dist/templates/commands/init-agent.txt +11 -0
  20. package/dist/templates/commands/onboard-developer.txt +34 -0
  21. package/dist/templates/commands/record-agent-flow.txt +64 -0
  22. package/dist/templates/commands/record-question.txt +38 -0
  23. package/dist/templates/commands/update-backend-structure.txt +16 -0
  24. package/dist/templates/commands/update-frontend-structure.txt +16 -0
  25. package/dist/templates/extract.d.ts +20 -0
  26. package/dist/templates/extract.d.ts.map +1 -0
  27. package/dist/templates/extract.js +34 -0
  28. package/dist/templates/extract.js.map +1 -0
  29. package/dist/templates/markdown/agent-progress-index.d.ts +2 -0
  30. package/dist/templates/markdown/agent-progress-index.d.ts.map +1 -0
  31. package/dist/templates/markdown/agent-progress-index.js +5 -0
  32. package/dist/templates/markdown/agent-progress-index.js.map +1 -0
  33. package/dist/templates/markdown/agent-progress-index.md.txt +124 -0
  34. package/dist/templates/markdown/backend-doc.d.ts +2 -0
  35. package/dist/templates/markdown/backend-doc.d.ts.map +1 -0
  36. package/dist/templates/markdown/backend-doc.js +5 -0
  37. package/dist/templates/markdown/backend-doc.js.map +1 -0
  38. package/dist/templates/markdown/backend-doc.md.txt +154 -0
  39. package/dist/templates/markdown/backend-index.d.ts +2 -0
  40. package/dist/templates/markdown/backend-index.d.ts.map +1 -0
  41. package/dist/templates/markdown/backend-index.js +5 -0
  42. package/dist/templates/markdown/backend-index.js.map +1 -0
  43. package/dist/templates/markdown/backend-index.md.txt +45 -0
  44. package/dist/templates/markdown/flow.d.ts +2 -0
  45. package/dist/templates/markdown/flow.d.ts.map +1 -0
  46. package/dist/templates/markdown/flow.js +5 -0
  47. package/dist/templates/markdown/flow.js.map +1 -0
  48. package/dist/templates/markdown/flow.md.txt +342 -0
  49. package/dist/templates/markdown/frontend-doc.d.ts +2 -0
  50. package/dist/templates/markdown/frontend-doc.d.ts.map +1 -0
  51. package/dist/templates/markdown/frontend-doc.js +5 -0
  52. package/dist/templates/markdown/frontend-doc.js.map +1 -0
  53. package/dist/templates/markdown/frontend-doc.md.txt +175 -0
  54. package/dist/templates/markdown/frontend-index.d.ts +2 -0
  55. package/dist/templates/markdown/frontend-index.d.ts.map +1 -0
  56. package/dist/templates/markdown/frontend-index.js +5 -0
  57. package/dist/templates/markdown/frontend-index.js.map +1 -0
  58. package/dist/templates/markdown/frontend-index.md.txt +46 -0
  59. package/dist/templates/markdown/gitignore.d.ts +2 -0
  60. package/dist/templates/markdown/gitignore.d.ts.map +1 -0
  61. package/dist/templates/markdown/gitignore.js +5 -0
  62. package/dist/templates/markdown/gitignore.js.map +1 -0
  63. package/dist/templates/markdown/gitignore.txt +3 -0
  64. package/dist/templates/markdown/index.d.ts +12 -0
  65. package/dist/templates/markdown/index.d.ts.map +1 -0
  66. package/dist/templates/markdown/index.js +13 -0
  67. package/dist/templates/markdown/index.js.map +1 -0
  68. package/dist/templates/scripts/add-session.d.ts +2 -0
  69. package/dist/templates/scripts/add-session.d.ts.map +1 -0
  70. package/dist/templates/scripts/add-session.js +5 -0
  71. package/dist/templates/scripts/add-session.js.map +1 -0
  72. package/dist/templates/scripts/add-session.sh.txt +257 -0
  73. package/dist/templates/scripts/extract-md-headings.d.ts +2 -0
  74. package/dist/templates/scripts/extract-md-headings.d.ts.map +1 -0
  75. package/dist/templates/scripts/extract-md-headings.js +5 -0
  76. package/dist/templates/scripts/extract-md-headings.js.map +1 -0
  77. package/dist/templates/scripts/extract-md-headings.sh.txt +260 -0
  78. package/dist/templates/scripts/feature.d.ts +2 -0
  79. package/dist/templates/scripts/feature.d.ts.map +1 -0
  80. package/dist/templates/scripts/feature.js +5 -0
  81. package/dist/templates/scripts/feature.js.map +1 -0
  82. package/dist/templates/scripts/feature.sh.txt +243 -0
  83. package/dist/templates/scripts/get-context.d.ts +2 -0
  84. package/dist/templates/scripts/get-context.d.ts.map +1 -0
  85. package/dist/templates/scripts/get-context.js +5 -0
  86. package/dist/templates/scripts/get-context.js.map +1 -0
  87. package/dist/templates/scripts/get-context.sh.txt +243 -0
  88. package/dist/templates/scripts/get-developer.d.ts +2 -0
  89. package/dist/templates/scripts/get-developer.d.ts.map +1 -0
  90. package/dist/templates/scripts/get-developer.js +5 -0
  91. package/dist/templates/scripts/get-developer.js.map +1 -0
  92. package/dist/templates/scripts/get-developer.sh.txt +16 -0
  93. package/dist/templates/scripts/index.d.ts +12 -0
  94. package/dist/templates/scripts/index.d.ts.map +1 -0
  95. package/dist/templates/scripts/index.js +13 -0
  96. package/dist/templates/scripts/index.js.map +1 -0
  97. package/dist/templates/scripts/init-developer.d.ts +2 -0
  98. package/dist/templates/scripts/init-developer.d.ts.map +1 -0
  99. package/dist/templates/scripts/init-developer.js +5 -0
  100. package/dist/templates/scripts/init-developer.js.map +1 -0
  101. package/dist/templates/scripts/init-developer.sh.txt +114 -0
  102. package/dist/templates/scripts/update-index.d.ts +2 -0
  103. package/dist/templates/scripts/update-index.d.ts.map +1 -0
  104. package/dist/templates/scripts/update-index.js +5 -0
  105. package/dist/templates/scripts/update-index.js.map +1 -0
  106. package/dist/templates/scripts/update-index.sh.txt +244 -0
  107. package/package.json +3 -2
@@ -1,5 +1,9 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
+ // Import script templates
4
+ import { initDeveloperScript, getDeveloperScript, extractMdHeadingsScript, featureScript, getContextScript, updateIndexScript, addSessionScript, } from "../templates/scripts/index.js";
5
+ // Import markdown templates
6
+ import { agentProgressIndexContent, frontendIndexContent, frontendDocContent, backendIndexContent, backendDocContent, flowMdContent, workflowGitignoreContent, } from "../templates/markdown/index.js";
3
7
  export async function createWorkflowStructure(cwd) {
4
8
  // Create directories
5
9
  const dirs = [
@@ -19,1567 +23,40 @@ export async function createWorkflowStructure(cwd) {
19
23
  await createAgentProgressIndex(cwd);
20
24
  // Create structure templates
21
25
  await createStructureTemplates(cwd);
22
- // Create feature.json
23
- await createFeatureJson(cwd);
24
26
  // Create flow.md
25
27
  await createFlowMd(cwd);
26
- // Create onboarding-guide.md
27
- await createOnboardingGuide(cwd);
28
28
  // Create .gitignore for workflow
29
29
  await createWorkflowGitignore(cwd);
30
30
  }
31
31
  async function createScripts(cwd) {
32
- const initDeveloperScript = `#!/bin/bash
33
-
34
- # Initialize developer identity for open-flow
35
- # Usage: ./workflow/scripts/init-developer.sh <developer-name>
36
-
37
- SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
38
- WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
39
-
40
- if [ -z "$1" ]; then
41
- echo "Usage: $0 <developer-name>"
42
- echo "Example: $0 john-doe"
43
- exit 1
44
- fi
45
-
46
- DEVELOPER_NAME="$1"
47
- DEVELOPER_FILE="$WORKFLOW_DIR/.developer"
48
- PROGRESS_DIR="$WORKFLOW_DIR/agent-progress/$DEVELOPER_NAME"
49
-
50
- # Check if already initialized
51
- if [ -f "$DEVELOPER_FILE" ]; then
52
- CURRENT=$(cat "$DEVELOPER_FILE" | grep "name:" | cut -d' ' -f2)
53
- echo "Already initialized as: $CURRENT"
54
- read -p "Override with $DEVELOPER_NAME? (y/N) " -n 1 -r
55
- echo
56
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
57
- exit 0
58
- fi
59
- fi
60
-
61
- # Create developer identity file
62
- cat > "$DEVELOPER_FILE" << EOF
63
- # Developer Identity (gitignored)
64
- # Created by open-flow
65
-
66
- name: $DEVELOPER_NAME
67
- created: $(date -u +"%Y-%m-%dT%H:%M:%SZ")
68
- EOF
69
-
70
- # Create progress directory
71
- mkdir -p "$PROGRESS_DIR"
72
-
73
- # Create personal index
74
- cat > "$PROGRESS_DIR/index.md" << EOF
75
- # Agent Progress - $DEVELOPER_NAME
76
-
77
- > Personal progress tracking for $DEVELOPER_NAME
78
-
79
- ## Current Status
80
-
81
- - **Active File**: \\\`progress-1.md\\\`
82
- - **Total Sessions**: 0
83
- - **Last Active**: $(date +%Y-%m-%d)
84
-
85
- ## Active Documents
86
-
87
- | File | Lines | Status |
88
- |------|-------|--------|
89
- | \\\`progress-1.md\\\` | ~0 | Active |
90
-
91
- ## Session History (Recent)
92
-
93
- | Session | Date | Title | Commit |
94
- |---------|------|-------|--------|
95
- | - | - | - | - |
96
-
97
- ---
98
-
99
- ## Notes
100
-
101
- - Each progress file has max 2000 lines
102
- - When exceeded, create new file and archive old one
103
- - Update this index when creating new files
104
- EOF
105
-
106
- # Create initial progress file
107
- cat > "$PROGRESS_DIR/progress-1.md" << EOF
108
- # Progress Record - $DEVELOPER_NAME
109
-
110
- > Session-by-session work log
111
-
112
- ---
113
-
114
- ## Session 1 - $(date +%Y-%m-%d)
115
-
116
- ### Summary
117
- Initial setup
118
-
119
- ### Main Changes
120
- - Initialized developer identity
121
-
122
- ### Git Commits
123
- - N/A (initial setup)
124
-
125
- ### Next Steps
126
- - Start first development task
127
-
128
- ---
129
- EOF
130
-
131
- echo "✅ Developer identity initialized: $DEVELOPER_NAME"
132
- echo " Progress directory: $PROGRESS_DIR"
133
- `;
134
- const getDeveloperScript = `#!/bin/bash
135
-
136
- # Get current developer identity
137
- # Usage: ./workflow/scripts/get-developer.sh
138
-
139
- SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
140
- WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
141
- DEVELOPER_FILE="$WORKFLOW_DIR/.developer"
142
-
143
- if [ ! -f "$DEVELOPER_FILE" ]; then
144
- echo "Not initialized. Run: ./workflow/scripts/init-developer.sh <your-name>" >&2
145
- exit 1
146
- fi
147
-
148
- cat "$DEVELOPER_FILE" | grep "name:" | cut -d' ' -f2
149
- `;
150
- fs.writeFileSync(path.join(cwd, "workflow/scripts/init-developer.sh"), initDeveloperScript);
151
- fs.writeFileSync(path.join(cwd, "workflow/scripts/get-developer.sh"), getDeveloperScript);
152
- // Make scripts executable
153
- fs.chmodSync(path.join(cwd, "workflow/scripts/init-developer.sh"), "755");
154
- fs.chmodSync(path.join(cwd, "workflow/scripts/get-developer.sh"), "755");
155
- // Create extract-md-headings.sh script
156
- const extractMdHeadingsScript = `#!/bin/zsh
157
-
158
- # ============================================
159
- # Markdown Heading Line Number Extraction Tool
160
- # ============================================
161
- #
162
- # Purpose: Auto-extract headings and line numbers from markdown files
163
- # Used to quickly update line number references in index.md
164
- #
165
- # Usage:
166
- # ./extract-md-headings.sh <markdown-file> [options]
167
- #
168
- # Options:
169
- # -l, --level <1-6> Only extract specific heading levels (default: 1,2)
170
- # -f, --format <type> Output format: table(default), list, csv, json
171
- # -r, --range Show line number ranges (current heading to next)
172
- # -h, --help Show help
173
- #
174
- # Examples:
175
- # # Extract all # and ## level headings
176
- # ./extract-md-headings.sh doc.md
177
- #
178
- # # Only extract ## level headings
179
- # ./extract-md-headings.sh doc.md -l 2
180
- #
181
- # # Output as CSV format
182
- # ./extract-md-headings.sh doc.md -f csv
183
- #
184
- # # Show line number ranges
185
- # ./extract-md-headings.sh doc.md -r
186
- #
187
- # ============================================
188
-
189
- # Color definitions
190
- RED='\\033[0;31m'
191
- GREEN='\\033[0;32m'
192
- YELLOW='\\033[1;33m'
193
- BLUE='\\033[0;34m'
194
- CYAN='\\033[0;36m'
195
- NC='\\033[0m' # No Color
196
-
197
- # Default parameters
198
- LEVELS="1,2"
199
- FORMAT="table"
200
- SHOW_RANGE=false
201
-
202
- # Show help
203
- show_help() {
204
- echo "📚 Markdown Heading Line Number Extraction Tool"
205
- echo ""
206
- echo "Purpose: Auto-extract headings and line numbers from markdown files"
207
- echo ""
208
- echo "Usage:"
209
- echo " $0 <markdown-file> [options]"
210
- echo ""
211
- echo "Options:"
212
- echo " -l, --level <1-6> Only extract specific heading levels (default: 1,2)"
213
- echo " Can be single number or comma-separated list: 1,2,3"
214
- echo " -f, --format <type> Output format:"
215
- echo " - table Table format (default)"
216
- echo " - list List format"
217
- echo " - csv CSV format"
218
- echo " - json JSON format"
219
- echo " -r, --range Show line number ranges (current to next same/higher level)"
220
- echo " -h, --help Show this help"
221
- echo ""
222
- echo "Examples:"
223
- echo " # Extract all # and ## level headings"
224
- echo " $0 doc.md"
225
- echo ""
226
- echo " # Only extract ## level headings"
227
- echo " $0 doc.md -l 2"
228
- echo ""
229
- echo " # Extract # ## ### three levels"
230
- echo " $0 doc.md -l 1,2,3"
231
- echo ""
232
- echo " # Output as CSV format"
233
- echo " $0 doc.md -f csv"
234
- echo ""
235
- echo " # Show line number ranges (for Read tool)"
236
- echo " $0 doc.md -r"
237
- echo ""
238
- exit 0
239
- }
240
-
241
- # Parse command line arguments
242
- POSITIONAL_ARGS=()
243
- while [[ $# -gt 0 ]]; do
244
- case $1 in
245
- -l|--level)
246
- LEVELS="$2"
247
- shift 2
248
- ;;
249
- -f|--format)
250
- FORMAT="$2"
251
- shift 2
252
- ;;
253
- -r|--range)
254
- SHOW_RANGE=true
255
- shift
256
- ;;
257
- -h|--help)
258
- show_help
259
- ;;
260
- *)
261
- POSITIONAL_ARGS+=("$1")
262
- shift
263
- ;;
264
- esac
265
- done
266
-
267
- # Restore positional args
268
- set -- "\${POSITIONAL_ARGS[@]}"
269
-
270
- # Check file argument
271
- if [[ $# -eq 0 ]]; then
272
- echo -e "\${RED}Error: Please provide markdown file path\${NC}"
273
- echo "Use -h or --help to see help"
274
- exit 1
275
- fi
276
-
277
- MD_FILE="$1"
278
-
279
- # Check if file exists
280
- if [[ ! -f "$MD_FILE" ]]; then
281
- echo -e "\${RED}Error: File not found: $MD_FILE\${NC}"
282
- exit 1
283
- fi
284
-
285
- # Check if file is markdown
286
- if [[ ! "$MD_FILE" =~ \\.(md|markdown)$ ]]; then
287
- echo -e "\${YELLOW}Warning: File may not be markdown format: $MD_FILE\${NC}"
288
- fi
289
-
290
- # Build awk script to extract headings
291
- AWK_SCRIPT='
292
- BEGIN {
293
- split(levels, level_array, ",")
294
- for (i in level_array) {
295
- allowed_levels[level_array[i]] = 1
296
- }
297
- }
298
- /^#{1,6} / {
299
- # Calculate heading level
300
- match($0, /^#+/)
301
- level = RLENGTH
302
-
303
- # Check if this is a level we want
304
- if (level in allowed_levels) {
305
- # Extract heading text (remove leading # and space)
306
- title = substr($0, level + 2)
307
- # Remove trailing # symbols (some markdown styles)
308
- gsub(/ #+$/, "", title)
309
-
310
- # Save heading info (use @@@ as delimiter)
311
- headings[++count] = level "@@@" NR "@@@" title
312
- }
313
- }
314
- END {
315
- for (i = 1; i <= count; i++) {
316
- split(headings[i], parts, "@@@")
317
- level = parts[1]
318
- line = parts[2]
319
- title = parts[3]
320
-
321
- # Calculate end line (previous line of next same/higher level heading)
322
- end_line = total_lines
323
- for (j = i + 1; j <= count; j++) {
324
- split(headings[j], next_parts, "@@@")
325
- next_level = next_parts[1]
326
- next_line = next_parts[2]
327
- if (next_level <= level) {
328
- end_line = next_line - 1
329
- break
330
- }
331
- }
332
-
333
- printf "%d|%d|%d|%s\\n", level, line, end_line, title
32
+ const scripts = [
33
+ { name: "init-developer.sh", content: initDeveloperScript },
34
+ { name: "get-developer.sh", content: getDeveloperScript },
35
+ { name: "extract-md-headings.sh", content: extractMdHeadingsScript },
36
+ { name: "feature.sh", content: featureScript },
37
+ { name: "get-context.sh", content: getContextScript },
38
+ { name: "update-index.sh", content: updateIndexScript },
39
+ { name: "add-session.sh", content: addSessionScript },
40
+ ];
41
+ for (const script of scripts) {
42
+ const scriptPath = path.join(cwd, "workflow/scripts", script.name);
43
+ fs.writeFileSync(scriptPath, script.content);
44
+ fs.chmodSync(scriptPath, "755");
334
45
  }
335
46
  }
336
- '
337
-
338
- # Get total lines
339
- TOTAL_LINES=$(wc -l < "$MD_FILE" | tr -d ' ')
340
-
341
- # Extract headings
342
- HEADINGS=$(awk -v levels="$LEVELS" -v total_lines="$TOTAL_LINES" "$AWK_SCRIPT" "$MD_FILE")
343
-
344
- # Check if headings found
345
- if [[ -z "$HEADINGS" ]]; then
346
- echo -e "\${YELLOW}No matching headings found\${NC}"
347
- exit 0
348
- fi
349
-
350
- # Output based on format
351
- case $FORMAT in
352
- table)
353
- echo -e "\${GREEN}📋 Heading List\${NC}"
354
- echo -e "\${CYAN}File: $MD_FILE\${NC}"
355
- echo ""
356
- printf "%-8s %-12s %-12s %s\\n" "Level" "Line" "Range" "Title"
357
- printf "%-8s %-12s %-12s %s\\n" "----" "----" "----" "----"
358
- echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
359
- indent=$(printf '%*s' $((level * 2)) '')
360
- if [[ "$SHOW_RANGE" == true ]]; then
361
- range="L\${line}-\${end_line}"
362
- else
363
- range="L\${line}"
364
- fi
365
- printf "%-8s %-12s %-12s %s%s\\n" "$level" "$line" "$range" "$indent" "$title"
366
- done
367
- ;;
368
-
369
- list)
370
- echo -e "\${GREEN}📋 Heading List\${NC}"
371
- echo -e "\${CYAN}File: $MD_FILE\${NC}"
372
- echo ""
373
- echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
374
- indent=$(printf '%*s' $((level * 2)) '')
375
- if [[ "$SHOW_RANGE" == true ]]; then
376
- echo "L\${line}-\${end_line}: \${indent}$title"
377
- else
378
- echo "L\${line}: \${indent}$title"
379
- fi
380
- done
381
- ;;
382
-
383
- csv)
384
- echo "Level,LineStart,LineEnd,Title"
385
- echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
386
- # CSV needs to escape commas and quotes in title
387
- escaped_title=$(echo "$title" | sed 's/"/""/g')
388
- echo "$level,$line,$end_line,\\"$escaped_title\\""
389
- done
390
- ;;
391
-
392
- json)
393
- echo "["
394
- first=true
395
- echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
396
- if [[ "$first" != true ]]; then
397
- echo ","
398
- fi
399
- first=false
400
- # JSON needs to escape quotes and backslashes
401
- escaped_title=$(echo "$title" | sed 's/\\\\/\\\\\\\\/g' | sed 's/"/\\\\"/g')
402
- printf ' {"level": %d, "lineStart": %d, "lineEnd": %d, "title": "%s"}' \\
403
- "$level" "$line" "$end_line" "$escaped_title"
404
- done
405
- echo ""
406
- echo "]"
407
- ;;
408
-
409
- *)
410
- echo -e "\${RED}Error: Unknown output format: $FORMAT\${NC}"
411
- echo "Supported formats: table, list, csv, json"
412
- exit 1
413
- ;;
414
- esac
415
- `;
416
- fs.writeFileSync(path.join(cwd, "workflow/scripts/extract-md-headings.sh"), extractMdHeadingsScript);
417
- fs.chmodSync(path.join(cwd, "workflow/scripts/extract-md-headings.sh"), "755");
418
- }
419
47
  async function createAgentProgressIndex(cwd) {
420
- const content = `# Agent Progress
421
-
422
- > Multi-developer progress tracking system
423
-
424
- ## Overview
425
-
426
- Each developer (human or AI agent) has their own progress directory under \`agent-progress/\`.
427
-
428
- ## Structure
429
-
430
- \`\`\`
431
- agent-progress/
432
- ├── index.md # This file
433
- └── {developer}/ # Per-developer directory
434
- ├── index.md # Personal index
435
- └── progress-N.md # Progress files (sequential: 1, 2, 3...)
436
- \`\`\`
437
-
438
- ## Active Developers
439
-
440
- | Developer | Active File | Last Active |
441
- |-----------|-------------|-------------|
442
- | - | - | - |
443
-
444
- ## Session Template
445
-
446
- When recording a session, use this format:
447
-
448
- \`\`\`markdown
449
- ## Session N - YYYY-MM-DD
450
-
451
- ### Summary
452
- One-line description of what was done
453
-
454
- ### Main Changes
455
- - File1: Description of changes
456
- - File2: Description of changes
457
-
458
- ### Git Commits
459
- - \`abc1234\` - commit message
460
-
461
- ### Testing
462
- - [x] pnpm lint passed
463
- - [x] pnpm type-check passed
464
- - [x] Manual testing passed
465
-
466
- ### Related Features
467
- - feature-id from feature.json
468
-
469
- ### Next Steps
470
- - What to do next
471
-
472
- ---
473
- \`\`\`
474
-
475
- ## Rules
476
-
477
- 1. **Max 2000 lines per progress file** - Create new file when exceeded
478
- 2. **Include commit hashes** - For traceability
479
- 3. **Update personal index** - After each session
480
- 4. **Sequential numbering** - progress-1.md, progress-2.md, etc.
481
- `;
482
- fs.writeFileSync(path.join(cwd, "workflow/agent-progress/index.md"), content);
48
+ fs.writeFileSync(path.join(cwd, "workflow/agent-progress/index.md"), agentProgressIndexContent);
483
49
  }
484
50
  async function createStructureTemplates(cwd) {
485
- // Frontend index.md
486
- const frontendIndex = `# Frontend Development Guidelines Index
487
-
488
- > **Full documentation**: See \`./doc.md\` for detailed guidelines
489
-
490
- This index helps you quickly locate the guidelines you need based on your task type.
491
-
492
- ## Quick Navigation
493
-
494
- | Task | Section | Section ID |
495
- |------|---------|------------|
496
- | **New feature module** | Directory Structure | \`directory-structure\` |
497
- | **Write Query Hook** | Hook Guidelines > Query | \`query-hook\` |
498
- | **Write Mutation Hook** | Hook Guidelines > Mutation | \`mutation-hook\` |
499
- | **API calls** | API Guidelines | \`api-guidelines\` |
500
- | **State management** | State Guidelines | \`state-management\` |
501
- | **Write component** | Component Guidelines | \`component-guidelines\` |
502
- | **Performance optimization** | Performance Guidelines | \`performance-guidelines\` |
503
- | **Code quality check** | Quality Guidelines | \`quality-guidelines\` |
504
-
505
- ## How to Read Sections
506
-
507
- \`\`\`bash
508
- # Extract a specific section by ID
509
- sed -n '/@@@section:query-hook/,/@@@\\/section:query-hook/p' doc.md
510
- \`\`\`
511
-
512
- ## Core Rules
513
-
514
- | Rule | Section ID |
515
- |------|------------|
516
- | Import types from backend | \`type-safety\` |
517
- | Use semantic HTML | \`semantic-html\` |
518
- | Use Next.js Image | \`image-optimization\` |
519
- | No non-null assertions | \`quality-guidelines\` |
520
-
521
- ## Reference Files
522
-
523
- | Feature | Reference File |
524
- |---------|----------------|
525
- | Query Hook | (add your example file path) |
526
- | Mutation Hook | (add your example file path) |
527
- | Component | (add your example file path) |
528
-
529
- ---
530
-
531
- **Language**: All documentation must be written in **English**.
532
- `;
533
- const frontendDoc = `# Frontend Development Guidelines
534
-
535
- > Complete guidelines for frontend development
536
-
537
- ---
538
-
539
- @@@section:directory-structure
540
- ## 1. Directory Structure
541
-
542
- \`\`\`
543
- modules/
544
- ├── {feature}/
545
- │ ├── components/ # UI components
546
- │ ├── hooks/ # Custom hooks
547
- │ ├── context/ # React context
548
- │ └── types.ts # Type definitions
549
- \`\`\`
550
-
551
- @@@/section:directory-structure
552
-
553
- ---
554
-
555
- @@@section:type-safety
556
- ## 2. Type Safety
557
-
558
- ### Import Types from Backend
559
-
560
- Always import types from the API package instead of redefining them:
561
-
562
- \`\`\`typescript
563
- // ✅ Good
564
- import type { User } from '@/packages/api';
565
-
566
- // ❌ Bad - don't redefine
567
- interface User {
568
- id: string;
569
- name: string;
570
- }
571
- \`\`\`
572
-
573
- @@@/section:type-safety
574
-
575
- ---
576
-
577
- @@@section:hook-guidelines
578
- ## 3. Hook Guidelines
579
-
580
- @@@section:query-hook
581
- ### Query Hook
582
-
583
- \`\`\`typescript
584
- // Template for query hooks
585
- export function useExample() {
586
- return useQuery({
587
- queryKey: ['example'],
588
- queryFn: async () => {
589
- // API call
590
- },
591
- });
592
- }
593
- \`\`\`
594
-
595
- @@@/section:query-hook
596
-
597
- @@@section:mutation-hook
598
- ### Mutation Hook
599
-
600
- \`\`\`typescript
601
- // Template for mutation hooks
602
- export function useUpdateExample() {
603
- const queryClient = useQueryClient();
604
-
605
- return useMutation({
606
- mutationFn: async (data) => {
607
- // API call
608
- },
609
- onSuccess: () => {
610
- queryClient.invalidateQueries({ queryKey: ['example'] });
611
- },
612
- });
613
- }
614
- \`\`\`
615
-
616
- @@@/section:mutation-hook
617
-
618
- @@@/section:hook-guidelines
619
-
620
- ---
621
-
622
- @@@section:api-guidelines
623
- ## 4. API Guidelines
624
-
625
- (Add your project-specific API guidelines here)
626
-
627
- @@@/section:api-guidelines
628
-
629
- ---
630
-
631
- @@@section:state-management
632
- ## 5. State Management
633
-
634
- (Add your project-specific state management guidelines here)
635
-
636
- @@@/section:state-management
637
-
638
- ---
639
-
640
- @@@section:component-guidelines
641
- ## 6. Component Guidelines
642
-
643
- @@@section:semantic-html
644
- ### Semantic HTML
645
-
646
- Use proper HTML elements:
647
-
648
- \`\`\`tsx
649
- // ✅ Good
650
- <button onClick={handleClick}>Click me</button>
651
-
652
- // ❌ Bad
653
- <div role="button" onClick={handleClick}>Click me</div>
654
- \`\`\`
655
-
656
- @@@/section:semantic-html
657
-
658
- @@@section:image-optimization
659
- ### Image Optimization
660
-
661
- Use Next.js Image component:
662
-
663
- \`\`\`tsx
664
- // ✅ Good
665
- import Image from 'next/image';
666
- <Image src="/logo.png" alt="Logo" width={100} height={100} />
667
-
668
- // ❌ Bad
669
- <img src="/logo.png" alt="Logo" />
670
- \`\`\`
671
-
672
- @@@/section:image-optimization
673
-
674
- @@@/section:component-guidelines
675
-
676
- ---
677
-
678
- @@@section:performance-guidelines
679
- ## 7. Performance Guidelines
680
-
681
- (Add your project-specific performance guidelines here)
682
-
683
- @@@/section:performance-guidelines
684
-
685
- ---
686
-
687
- @@@section:quality-guidelines
688
- ## 8. Quality Guidelines
689
-
690
- ### Before Every Commit
691
-
692
- - [ ] \`pnpm lint\` - 0 errors
693
- - [ ] \`pnpm type-check\` - No type errors
694
- - [ ] Manual testing passes
695
-
696
- ### Forbidden Patterns
697
-
698
- - No non-null assertions (\`!\`)
699
- - No \`any\` type
700
- - No unused imports/variables
701
-
702
- @@@/section:quality-guidelines
703
-
704
- ---
705
-
706
- **Language**: All documentation must be written in **English**.
707
- `;
708
- // Backend index.md
709
- const backendIndex = `# Backend Development Guidelines Index
710
-
711
- > **Full documentation**: See \`./doc.md\` for detailed guidelines
712
-
713
- This index helps you quickly locate the guidelines you need based on your task type.
714
-
715
- ## Quick Navigation
716
-
717
- | Task | Section | Section ID |
718
- |------|---------|------------|
719
- | **New API module** | Directory Structure | \`directory-structure\` |
720
- | **Type safety** | Type Safety | \`type-safety\` |
721
- | **Database operations** | Database Guidelines | \`database-guidelines\` |
722
- | **Error handling** | Error Handling | \`error-handling\` |
723
- | **Logging** | Logging Guidelines | \`logging-guidelines\` |
724
- | **AI/Prompt** | AI Guidelines | \`ai-guidelines\` |
725
- | **Code quality** | Quality Guidelines | \`quality-guidelines\` |
726
-
727
- ## How to Read Sections
728
-
729
- \`\`\`bash
730
- # Extract a specific section by ID
731
- sed -n '/@@@section:database-guidelines/,/@@@\\/section:database-guidelines/p' doc.md
732
- \`\`\`
733
-
734
- ## Core Rules
735
-
736
- | Rule | Section ID |
737
- |------|------------|
738
- | No non-null assertions | \`non-null-assertion\` |
739
- | All inputs/outputs need Zod Schema | \`zod-schema\` |
740
- | Use structured logging | \`logging-guidelines\` |
741
- | No await in loops | \`no-await-in-loops\` |
742
-
743
- ## Reference Files
744
-
745
- | Feature | Reference File |
746
- |---------|----------------|
747
- | API Route | (add your example file path) |
748
- | Database Query | (add your example file path) |
749
-
750
- ---
751
-
752
- **Language**: All documentation must be written in **English**.
753
- `;
754
- const backendDoc = `# Backend Development Guidelines
755
-
756
- > Complete guidelines for backend development
757
-
758
- ---
759
-
760
- @@@section:directory-structure
761
- ## 1. Directory Structure
762
-
763
- \`\`\`
764
- packages/api/modules/
765
- ├── {module}/
766
- │ ├── router.ts # Route definitions
767
- │ ├── procedures/ # Business logic
768
- │ ├── types.ts # Type definitions
769
- │ └── api/ # API documentation
770
- │ └── *.md
771
- \`\`\`
772
-
773
- @@@/section:directory-structure
774
-
775
- ---
776
-
777
- @@@section:type-safety
778
- ## 2. Type Safety
779
-
780
- @@@section:non-null-assertion
781
- ### No Non-Null Assertions
782
-
783
- \`\`\`typescript
784
- // ✅ Good - use local variable
785
- const user = await getUser(id);
786
- if (!user) {
787
- throw new Error('User not found');
788
- }
789
- const userName = user.name; // Safe access
790
-
791
- // ❌ Bad - non-null assertion
792
- const userName = user!.name;
793
- \`\`\`
794
-
795
- @@@/section:non-null-assertion
796
-
797
- @@@section:zod-schema
798
- ### Zod Schema
799
-
800
- \`\`\`typescript
801
- // All inputs and outputs need Zod schemas
802
- const inputSchema = z.object({
803
- id: z.string(),
804
- });
805
-
806
- const outputSchema = z.object({
807
- success: z.boolean(),
808
- data: z.object({...}),
809
- });
810
- \`\`\`
811
-
812
- @@@/section:zod-schema
813
-
814
- @@@/section:type-safety
815
-
816
- ---
817
-
818
- @@@section:database-guidelines
819
- ## 3. Database Guidelines
820
-
821
- @@@section:no-await-in-loops
822
- ### No Await in Loops
823
-
824
- \`\`\`typescript
825
- // ✅ Good - parallel execution
826
- const results = await Promise.all(
827
- ids.map(id => db.query.users.findFirst({ where: eq(users.id, id) }))
828
- );
829
-
830
- // ❌ Bad - sequential execution
831
- for (const id of ids) {
832
- await db.query.users.findFirst({ where: eq(users.id, id) });
833
- }
834
- \`\`\`
835
-
836
- @@@/section:no-await-in-loops
837
-
838
- ### Batch Operations
839
-
840
- \`\`\`typescript
841
- // Use batch insert with conflict handling
842
- await db.insert(users).values(data).onConflictDoUpdate({
843
- target: users.id,
844
- set: { updatedAt: new Date() },
845
- });
846
- \`\`\`
847
-
848
- @@@/section:database-guidelines
849
-
850
- ---
851
-
852
- @@@section:error-handling
853
- ## 4. Error Handling
854
-
855
- (Add your project-specific error handling guidelines here)
856
-
857
- @@@/section:error-handling
858
-
859
- ---
860
-
861
- @@@section:logging-guidelines
862
- ## 5. Logging Guidelines
863
-
864
- ### Use Structured Logging
865
-
866
- \`\`\`typescript
867
- // ✅ Good
868
- logger.info('User created', { userId: user.id, email: user.email });
869
-
870
- // ❌ Bad
871
- console.log('User created: ' + user.id);
872
- \`\`\`
873
-
874
- @@@/section:logging-guidelines
875
-
876
- ---
877
-
878
- @@@section:ai-guidelines
879
- ## 6. AI Guidelines
880
-
881
- (Add your project-specific AI/prompt guidelines here)
882
-
883
- @@@/section:ai-guidelines
884
-
885
- ---
886
-
887
- @@@section:quality-guidelines
888
- ## 7. Quality Guidelines
889
-
890
- ### Before Every Commit
891
-
892
- - [ ] \`pnpm lint\` - 0 errors
893
- - [ ] \`pnpm type-check\` - No type errors
894
- - [ ] API documentation updated
895
-
896
- ### Forbidden Patterns
897
-
898
- - No non-null assertions (\`!\`)
899
- - No \`console.log\` (use logger)
900
- - No await in loops
901
-
902
- @@@/section:quality-guidelines
903
-
904
- ---
905
-
906
- **Language**: All documentation must be written in **English**.
907
- `;
908
- fs.writeFileSync(path.join(cwd, "workflow/structure/frontend/index.md"), frontendIndex);
909
- fs.writeFileSync(path.join(cwd, "workflow/structure/frontend/doc.md"), frontendDoc);
910
- fs.writeFileSync(path.join(cwd, "workflow/structure/backend/index.md"), backendIndex);
911
- fs.writeFileSync(path.join(cwd, "workflow/structure/backend/doc.md"), backendDoc);
912
- }
913
- async function createFeatureJson(cwd) {
914
- const content = {
915
- project: "My Project",
916
- lastUpdated: new Date().toISOString().split("T")[0],
917
- version: "1.0.0",
918
- categories: {
919
- example: {
920
- name: "Example Category",
921
- features: [
922
- {
923
- id: "example-001",
924
- name: "Example Feature",
925
- description: "An example feature to demonstrate the structure",
926
- status: "planned",
927
- priority: "medium",
928
- },
929
- ],
930
- },
931
- },
932
- statistics: {
933
- totalFeatures: 1,
934
- completed: 0,
935
- inProgress: 0,
936
- planned: 1,
937
- blocked: 0,
938
- completionRate: "0%",
939
- },
940
- notes: [
941
- "Feature ID format: category-XXX (e.g., auth-001, ui-002)",
942
- "Status: completed | in-progress | planned | blocked",
943
- "Priority: high | medium | low",
944
- "When completed, add completedAt (YYYY-MM-DD) and commit (hash)",
945
- "When blocked, add blockedReason field",
946
- "Update statistics after changing feature status",
947
- ],
948
- };
949
- fs.writeFileSync(path.join(cwd, "workflow/feature.json"), JSON.stringify(content, null, 2));
51
+ fs.writeFileSync(path.join(cwd, "workflow/structure/frontend/index.md"), frontendIndexContent);
52
+ fs.writeFileSync(path.join(cwd, "workflow/structure/frontend/doc.md"), frontendDocContent);
53
+ fs.writeFileSync(path.join(cwd, "workflow/structure/backend/index.md"), backendIndexContent);
54
+ fs.writeFileSync(path.join(cwd, "workflow/structure/backend/doc.md"), backendDocContent);
950
55
  }
951
56
  async function createFlowMd(cwd) {
952
- const content = `# Development Workflow
953
-
954
- > Based on [Effective Harnesses for Long-Running Agents](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents)
955
-
956
- ---
957
-
958
- ## Table of Contents
959
-
960
- 1. [Workflow Overview](#workflow-overview)
961
- 2. [Session Start Process](#session-start-process)
962
- 3. [Development Process](#development-process)
963
- 4. [Session End](#session-end)
964
- 5. [File Descriptions](#file-descriptions)
965
- 6. [Best Practices](#best-practices)
966
-
967
- ---
968
-
969
- ## Workflow Overview
970
-
971
- ### Core Principles
972
-
973
- 1. **Read Before Write** - Understand context before starting
974
- 2. **Follow Standards** - ⚠️ **MUST read \`workflow/structure/\` guidelines (index → doc) before coding**
975
- 3. **Incremental Development** - Complete one feature at a time
976
- 4. **Record Promptly** - Update tracking files immediately after completion
977
- 5. **Document Limits** - ⚠️ **Max 2000 lines per agent-progress document**
978
-
979
- ### File System
980
-
981
- \`\`\`
982
- workflow/
983
- ├── .developer # Developer identity (gitignored)
984
- ├── scripts/
985
- │ ├── init-developer.sh # Initialize developer identity
986
- │ └── get-developer.sh # Get current developer name
987
- ├── agent-progress/ # AI Agent work progress records
988
- │ ├── index.md # Progress index + Session template
989
- │ └── {developer}/ # Per-developer directories
990
- │ ├── index.md # Personal index
991
- │ └── progress-N.md # Progress files (sequential numbering)
992
- ├── structure/ # ⚠️ MUST READ before coding
993
- │ ├── frontend/
994
- │ │ ├── index.md # Frontend guidelines index (read first)
995
- │ │ └── doc.md # Frontend guidelines detailed doc (read specific sections)
996
- │ └── backend/
997
- │ ├── index.md # Backend guidelines index (read first)
998
- │ └── doc.md # Backend guidelines detailed doc (read specific sections)
999
- ├── feature.json # Feature tracking list (single file, no limit)
1000
- └── flow.md # This document
1001
- \`\`\`
1002
-
1003
- ---
1004
-
1005
- ## Session Start Process
1006
-
1007
- ### Step 1: Read Work Context
1008
-
1009
- Read the following files in order to quickly establish context:
1010
-
1011
- \`\`\`bash
1012
- # 0. Check your developer identity
1013
- ./workflow/scripts/get-developer.sh
1014
-
1015
- # 1. Check recent work progress (your own directory)
1016
- DEVELOPER=$(./workflow/scripts/get-developer.sh)
1017
- cat workflow/agent-progress/$DEVELOPER/index.md
1018
-
1019
- # 2. Check feature status
1020
- cat workflow/feature.json
1021
-
1022
- # 3. Check Git history (use git command directly)
1023
- git status
1024
- git log --oneline -20
1025
- \`\`\`
1026
-
1027
- ### Step 2: Read Development Guidelines Index ⚠️ REQUIRED
1028
-
1029
- **⚠️ CRITICAL: MUST read guidelines before writing any code**
1030
-
1031
- Based on what you'll develop (frontend/backend), read the corresponding guidelines **index document**:
1032
-
1033
- **Frontend Development**:
1034
- \`\`\`bash
1035
- cat workflow/structure/frontend/index.md
1036
- \`\`\`
1037
- - Find corresponding chapters based on task type (e.g., "New Query Hook", "Write Component")
1038
- - Note down chapter names and **section IDs** (e.g., \`query-hook\`)
1039
- - This is **mandatory**, not optional
1040
-
1041
- **Backend Development**:
1042
- \`\`\`bash
1043
- cat workflow/structure/backend/index.md
1044
- \`\`\`
1045
- - Find corresponding chapters based on scenario (e.g., "New API Module", "Write Batch Tasks")
1046
- - Note down chapter names and **section IDs** (e.g., \`database-guidelines\`)
1047
- - This is **mandatory**, not optional
1048
-
1049
- ### Step 3: Read Specific Guidelines ⚠️ REQUIRED
1050
-
1051
- **⚠️ CRITICAL: Read detailed guidelines for your specific task**
1052
-
1053
- Based on section IDs found in index, extract specific sections:
1054
-
1055
- **Frontend**:
1056
- \`\`\`bash
1057
- # Extract specific section by ID
1058
- sed -n '/@@@section:query-hook/,/@@@\\/section:query-hook/p' workflow/structure/frontend/doc.md
1059
- \`\`\`
1060
- - **MUST read** the sections relevant to your task
1061
- - Do NOT skip this step
1062
-
1063
- **Backend**:
1064
- \`\`\`bash
1065
- # Extract specific section by ID
1066
- sed -n '/@@@section:database-guidelines/,/@@@\\/section:database-guidelines/p' workflow/structure/backend/doc.md
1067
- \`\`\`
1068
- - **MUST read** the sections relevant to your task
1069
- - Do NOT skip this step
1070
-
1071
- ### Step 4: Select Feature to Develop
1072
-
1073
- Based on \`workflow/feature.json\`:
1074
- - Prioritize \`in-progress\` status features
1075
- - Then select \`planned\` with \`priority: high\`
1076
- - Only select one feature at a time
1077
-
1078
- ---
1079
-
1080
- ## Development Process
1081
-
1082
- ### Feature Development Flow
1083
-
1084
- \`\`\`
1085
- 1. Update feature.json
1086
- └─> Change selected feature status to "in-progress"
1087
-
1088
- 2. Write code according to guidelines
1089
- └─> Strictly follow workflow/structure/ development guidelines
1090
- └─> Frontend: Type safety, Hook standards, Component standards, Performance
1091
- └─> Backend: Directory structure, Type safety, Database operations, Logging
1092
-
1093
- 3. Self-test
1094
- └─> pnpm lint (must pass)
1095
- └─> pnpm type-check (must pass)
1096
- └─> Manual feature testing
1097
-
1098
- 4. Commit code
1099
- └─> git add <files>
1100
- └─> git commit -m "type(scope): description"
1101
- Format: feat/fix/docs/refactor/test/chore
1102
-
1103
- 5. Update tracking files
1104
- └─> agent-progress: Record this session's work (include commit hashes)
1105
- └─> feature.json: Update feature status to "completed"
1106
- \`\`\`
1107
-
1108
- ### Code Quality Checklist
1109
-
1110
- **Must pass before commit**:
1111
- - ✅ \`pnpm lint\` - 0 errors
1112
- - ✅ \`pnpm type-check\` - No type errors
1113
- - ✅ Manual feature testing passes
1114
-
1115
- **Frontend-specific checks**:
1116
- - ✅ Use semantic HTML (\`<button>\` not \`<div role="button">\`)
1117
- - ✅ Use Next.js \`<Image>\` instead of \`<img>\`
1118
- - ✅ Import types from backend, don't redefine
1119
- - ✅ Avoid non-null assertions \`!\`
1120
-
1121
- **Backend-specific checks**:
1122
- - ✅ Strictly avoid non-null assertion \`!\`, use local variable extraction
1123
- - ✅ All API inputs/outputs have Zod Schema
1124
- - ✅ Use structured logging (\`logger\`), forbidden \`console.log\`
1125
- - ✅ Database operations avoid \`await\` in loops
1126
- - ✅ Update corresponding API documentation
1127
-
1128
- ---
1129
-
1130
- ## Session End
1131
-
1132
- ### Pre-end Checklist
1133
-
1134
- 1. ✅ All code committed, commit message follows convention
1135
- 2. ✅ \`workflow/agent-progress/{developer}/progress-N.md\` updated
1136
- 3. ✅ \`workflow/feature.json\` status updated
1137
- 4. ✅ No lint/type-check errors
1138
- 5. ✅ Working directory clean (or WIP noted)
1139
-
1140
- ### Update Tracking Files
1141
-
1142
- **agent-progress update**:
1143
- - Write to your own directory: \`workflow/agent-progress/{developer}/\`
1144
- - Include commit hashes in your session record
1145
- - See template in \`workflow/agent-progress/index.md\`
1146
-
1147
- **feature.json update**:
1148
- \`\`\`json
1149
- {
1150
- "id": "feature-xxx",
1151
- "status": "completed",
1152
- "completedAt": "2025-11-28",
1153
- "commit": "abc1234"
1154
- }
1155
- \`\`\`
1156
-
1157
- Also update \`statistics\` field completion rate.
1158
-
1159
- ---
1160
-
1161
- ## File Descriptions
1162
-
1163
- ### 1. agent-progress/ - Agent Work Progress
1164
-
1165
- **Purpose**: Record each AI Agent session's work content
1166
-
1167
- **Structure** (Multi-developer support):
1168
- \`\`\`
1169
- agent-progress/
1170
- ├── index.md # Main index (Active Developers table)
1171
- └── {developer}/ # Per-developer directory
1172
- ├── index.md # Personal index
1173
- └── progress-N.md # Progress files (sequential: 1, 2, 3...)
1174
- \`\`\`
1175
-
1176
- **When to update**:
1177
- - ✅ End of each session
1178
- - ✅ Complete important feature
1179
- - ✅ Fix important bug
1180
-
1181
- **How to update**:
1182
- 1. Get your developer name: \`./workflow/scripts/get-developer.sh\`
1183
- 2. Open your personal index: \`workflow/agent-progress/{developer}/index.md\`
1184
- 3. Add new session record to your active progress file
1185
- 4. ⚠️ **IMPORTANT: If file exceeds 2000 lines:**
1186
- - Create new file \`progress-{N+1}.md\`
1187
- - Update your personal index.md
1188
- - **Do NOT continue adding to a file over 2000 lines**
1189
-
1190
- **Record content**:
1191
- - Summary: One-line description
1192
- - Main changes: Files and change descriptions
1193
- - Git commits: Commit hash and message (use \`git log\` to get)
1194
- - Related features: ID in feature.json
1195
- - Next steps: What to do next
1196
-
1197
- ### 2. feature.json - Feature Tracking
1198
-
1199
- **Purpose**: Structured record of all feature completion status
1200
-
1201
- **When to update**:
1202
- - ✅ Start developing new feature (planned → in-progress)
1203
- - ✅ Complete feature (in-progress → completed)
1204
- - ✅ Feature blocked (any status → blocked)
1205
- - ✅ Add new planned feature (add planned)
1206
-
1207
- **How to update**:
1208
- 1. Modify corresponding feature's \`status\` field
1209
- 2. If completed, add \`completedAt\` and \`commit\` fields
1210
- 3. If blocked, add \`blockedReason\` field
1211
- 4. Recalculate \`statistics\` section values
1212
- 5. Update \`lastUpdated\` field to current date
1213
-
1214
- **Status flow**:
1215
- \`\`\`
1216
- planned → in-progress → completed
1217
- ↓ ↓ ↓
1218
- blocked ← blocked ← blocked
1219
- \`\`\`
1220
-
1221
- ---
1222
-
1223
- ## Best Practices
1224
-
1225
- ### ✅ DO - Should Do
1226
-
1227
- 1. **Before session start**:
1228
- - Check your identity: \`./workflow/scripts/get-developer.sh\`
1229
- - Read your agent-progress and feature.json
1230
- - Check recent git log: \`git log --oneline -20\`
1231
- - ⚠️ **MUST read** \`workflow/structure/[frontend|backend]/index.md\`
1232
- - ⚠️ **MUST read** specific sections in doc.md based on task
1233
-
1234
- 2. **During development**:
1235
- - ⚠️ **Strictly follow** \`workflow/structure/\` frontend/backend guidelines
1236
- - Develop only one feature at a time
1237
- - Run lint and type-check before finishing
1238
-
1239
- 3. **After development complete** (⚠️ AI should not commit, human is responsible):
1240
- - AI reminds human to test
1241
- - Human commits after testing passes
1242
- - After human commits, use \`/record-agent-flow\` to record progress
1243
- - Update feature.json status
1244
-
1245
- ### ❌ DON'T - Should Not Do
1246
-
1247
- 1. ⚠️ **Don't** skip reading \`workflow/structure/\` guidelines (CRITICAL VIOLATION)
1248
- 2. ⚠️ **Don't** let agent-progress single file exceed 2000 lines
1249
- 3. **Don't** skip reading context files
1250
- 4. **Don't** develop multiple unrelated features simultaneously
1251
- 5. **Don't** commit code with lint/type-check errors
1252
- 6. **Don't** forget to update tracking files
1253
- 7. ⚠️ **Don't** execute \`git commit\` - AI should not commit code
1254
- - Only allowed: \`git log\`, \`git status\`, \`git diff\`
1255
- - Human is responsible for testing and committing
1256
- 8. **Don't** write \`workflow/structure/\` docs in Chinese - **English only**
1257
-
1258
- ---
1259
-
1260
- ## Error Recovery
1261
-
1262
- ### Lint/Type Errors
1263
-
1264
- \`\`\`bash
1265
- # Auto-fix formatting issues
1266
- pnpm format
1267
-
1268
- # Auto-fix safe lint issues
1269
- pnpm biome check --write --unsafe .
1270
-
1271
- # Check remaining issues
1272
- pnpm lint
1273
- \`\`\`
1274
-
1275
- ### Git Issues
1276
-
1277
- \`\`\`bash
1278
- # Undo last commit (keep changes)
1279
- git reset --soft HEAD~1
1280
-
1281
- # Discard uncommitted changes
1282
- git checkout -- <file>
1283
-
1284
- # View changes
1285
- git diff
1286
- git status
1287
- \`\`\`
1288
-
1289
- ---
1290
-
1291
- ## Quick Reference
1292
-
1293
- ### Must-read Before Development
1294
-
1295
- | Task Type | Must-read Document | Section ID |
1296
- |---------|---------|------|
1297
- | New Frontend Query Hook | \`frontend/doc.md\` | \`query-hook\` |
1298
- | New Frontend Mutation Hook | \`frontend/doc.md\` | \`mutation-hook\` |
1299
- | New Frontend Component | \`frontend/doc.md\` | \`component-guidelines\` |
1300
- | New Backend API | \`backend/doc.md\` | \`directory-structure\`, \`type-safety\` |
1301
- | Database Batch Operations | \`backend/doc.md\` | \`database-guidelines\` |
1302
-
1303
- ### Commit Convention
1304
-
1305
- \`\`\`bash
1306
- git commit -m "type(scope): description"
1307
- \`\`\`
1308
-
1309
- **Type**: feat, fix, docs, refactor, test, chore
1310
- **Scope**: Module name (e.g., mail, auth, api)
1311
- **Description**: Brief description
1312
-
1313
- ### Common Commands
1314
-
1315
- \`\`\`bash
1316
- # Development
1317
- pnpm dev # Start dev server
1318
- pnpm build # Production build
1319
- pnpm lint # Lint check
1320
- pnpm format # Format code
1321
- pnpm type-check # Type check
1322
-
1323
- # Git
1324
- git log --oneline -20 # Recent 20 commits
1325
- git diff main...HEAD # Diff with main
1326
- git status # Working directory status
1327
- \`\`\`
1328
-
1329
- ---
1330
-
1331
- ## Summary
1332
-
1333
- Following this workflow ensures:
1334
- - ✅ Continuity across multiple sessions
1335
- - ✅ Consistent code quality
1336
- - ✅ Trackable progress
1337
- - ✅ Easy recovery and rollback
1338
- - ✅ Transparent team collaboration
1339
-
1340
- **Core Philosophy**: Read before write, follow standards, record promptly, develop incrementally
1341
- `;
1342
- fs.writeFileSync(path.join(cwd, "workflow/flow.md"), content);
1343
- }
1344
- async function createOnboardingGuide(cwd) {
1345
- const content = `# AI Onboarding Guide for New Developers
1346
-
1347
- > **Purpose**: Help AI understand the workflow system, then guide first-time developers
1348
-
1349
- ---
1350
-
1351
- ## Part 1: AI Self-Learning (Read This First)
1352
-
1353
- ### 1.1 What is This Workflow?
1354
-
1355
- This is a **multi-developer collaboration workflow system** based on [Anthropic Best Practices](https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents).
1356
-
1357
- **Core Problem**: AI Agents have no persistent memory, each session is independent. Without handling:
1358
- - New sessions don't know what was done before
1359
- - May re-develop completed features
1360
- - Code style may be inconsistent
1361
-
1362
- **Solution**: Use file system to simulate "persistent memory"
1363
-
1364
- \`\`\`
1365
- workflow/
1366
- ├── agent-progress/ # Progress records (simulated memory)
1367
- │ └── {developer}/ # Each developer has own directory
1368
- │ ├── index.md # Session history table
1369
- │ └── progress-N.md # Detailed records
1370
- ├── structure/ # Development guidelines
1371
- │ ├── frontend/ # Frontend guidelines
1372
- │ └── backend/ # Backend guidelines
1373
- ├── feature.json # Feature tracking
1374
- ├── flow.md # Workflow specification
1375
- └── .developer # Local identity file (gitignore)
1376
- \`\`\`
1377
-
1378
- ### 1.2 Key Design Principles
1379
-
1380
- | Principle | Description |
1381
- |-----------|-------------|
1382
- | **Multi-developer Isolation** | Each developer/Agent has own directory, avoid conflicts |
1383
- | **AI Doesn't Commit Code** | AI only develops, human tests and commits |
1384
- | **Sequential Numbering** | Progress files use \`progress-1.md\`, \`progress-2.md\` (not dates) |
1385
- | **2000 Line Limit** | Create new file when single file exceeds 2000 lines |
1386
-
1387
- ### 1.3 Daily Workflow
1388
-
1389
- \`\`\`
1390
- ┌─────────────────────────────────────────────────────────┐
1391
- │ │
1392
- │ /init-agent → AI reads context │
1393
- │ ↓ │
1394
- │ AI develops code → Follow workflow/structure/ │
1395
- │ ↓ │
1396
- │ /check-frontend → Check frontend standards (opt) │
1397
- │ /check-backend → Check backend standards (opt) │
1398
- │ ↓ │
1399
- │ pnpm lint → Check code quality │
1400
- │ ↓ │
1401
- │ 👤 Human tests → AI doesn't commit itself │
1402
- │ ↓ │
1403
- │ 👤 Human git commit → Commit after test passes │
1404
- │ ↓ │
1405
- │ /record-agent-flow → Record progress (with hash) │
1406
- │ │
1407
- └─────────────────────────────────────────────────────────┘
1408
- \`\`\`
1409
-
1410
- ### 1.4 Available Slash Commands
1411
-
1412
- | Command | Purpose | When to Use |
1413
- |---------|---------|-------------|
1414
- | \`/init-agent\` | Initialize AI session, read project context | Every time starting work |
1415
- | \`/onboard-developer\` | Guide new developer through initialization | First-time users |
1416
- | \`/check-frontend\` | Check if frontend code follows standards | After frontend code is done |
1417
- | \`/check-backend\` | Check if backend code follows standards | After backend code is done |
1418
- | \`/record-agent-flow\` | Record progress to agent-progress | After human commits code |
1419
- | \`/generate-frontend-structure\` | Auto-generate frontend guidelines | Setting up project standards |
1420
- | \`/generate-backend-structure\` | Auto-generate backend guidelines | Setting up project standards |
1421
- | \`/before-frontend-dev\` | Read frontend guidelines before development | Before writing frontend code |
1422
- | \`/before-backend-dev\` | Read backend guidelines before development | Before writing backend code |
1423
- | \`/update-frontend-structure\` | Update frontend guidelines with new patterns | When new patterns are found |
1424
- | \`/update-backend-structure\` | Update backend guidelines with new patterns | When new patterns are found |
1425
-
1426
- ### 1.5 AI Permission Boundaries
1427
-
1428
- | Can Do ✅ | Cannot Do ❌ |
1429
- |----------|-------------|
1430
- | \`git log\` view history | \`git commit\` commit code |
1431
- | \`git status\` view status | \`git push\` push code |
1432
- | \`git diff\` view changes | \`git add\` stage files |
1433
- | Write code | Commit without human testing |
1434
-
1435
- ### 1.6 Related Document Locations
1436
-
1437
- | Document | Purpose | When to Read |
1438
- |----------|---------|--------------|
1439
- | \`init-agent.md\` | Complete initialization guide | Start of each session |
1440
- | \`workflow/flow.md\` | Workflow specification | Need to understand process details |
1441
- | \`workflow/structure/\` | Coding standards | Before writing code |
1442
-
1443
- ---
1444
-
1445
- ## Part 2: Identifying New Developers
1446
-
1447
- When the following occurs, developer may be first-time user:
1448
-
1449
- ### 2.1 Auto Detection
1450
-
1451
- \`\`\`bash
1452
- # Run this command, if error returned, it's a new developer
1453
- ./workflow/scripts/get-developer.sh
1454
-
1455
- # Error output:
1456
- # ERROR: Developer not initialized. Run: ./workflow/scripts/init-developer.sh
1457
- \`\`\`
1458
-
1459
- ### 2.2 Proactive Inquiry
1460
-
1461
- Developer may say:
1462
- - "How do I use this workflow?"
1463
- - "I'm new, how do I start?"
1464
- - "First time using, what do I need to do?"
1465
- - "Do I need to initialize something?"
1466
-
1467
- ---
1468
-
1469
- ## Part 3: Guiding New Developers
1470
-
1471
- > When you confirm developer needs guidance, follow these steps
1472
-
1473
- ### Step 1: Explain Concept (30 seconds)
1474
-
1475
- **AI should say**:
1476
-
1477
- > This project uses a multi-developer workflow system. Simply put:
1478
- >
1479
- > - Each developer has their own progress directory
1480
- > - AI helps write code, but **you test and commit**
1481
- > - This ensures code quality, prevents AI from committing problematic code
1482
- >
1483
- > Now let me help you initialize your developer identity.
1484
-
1485
- ### Step 2: Choose Name
1486
-
1487
- **AI should ask**:
1488
-
1489
- > Please tell me your developer name:
1490
- > - Use your name, like \`john-doe\`
1491
- > - Only letters, numbers, hyphens, underscores allowed
1492
-
1493
- ### Step 3: Run Initialization
1494
-
1495
- \`\`\`bash
1496
- ./workflow/scripts/init-developer.sh <developer-name>
1497
- \`\`\`
1498
-
1499
- **AI should explain**:
1500
-
1501
- > The script created:
1502
- > 1. Your identity file (stored locally, not committed to git)
1503
- > 2. Your progress directory
1504
-
1505
- ### Step 4: Verify Success
1506
-
1507
- \`\`\`bash
1508
- ./workflow/scripts/get-developer.sh
1509
- # Should output developer's name
1510
- \`\`\`
1511
-
1512
- ### Step 5: Explain Daily Process and Common Commands
1513
-
1514
- **AI should say**:
1515
-
1516
- > Initialization complete! Future workflow:
1517
- >
1518
- > 1. Every time starting work, run \`/init-agent\`
1519
- > 2. AI helps write code
1520
- > 3. After code is done, use \`/check-frontend\` or \`/check-backend\` to check standards
1521
- > 4. You test the code
1522
- > 5. After test passes, **you do git commit**
1523
- > 6. After commit, run \`/record-agent-flow\` to record progress
1524
- >
1525
- > **Remember**: AI won't execute git commit, that's your responsibility.
1526
-
1527
- ---
1528
-
1529
- ## Part 4: Quick Guide Template
1530
-
1531
- If developer is in a hurry, use this simplified version:
1532
-
1533
- **AI says**:
1534
-
1535
- > Quick start:
1536
- >
1537
- > \`\`\`bash
1538
- > # Initialize (only once)
1539
- > ./workflow/scripts/init-developer.sh your-name
1540
- > \`\`\`
1541
- >
1542
- > Then develop normally:
1543
- > - AI won't commit, you commit
1544
- > - After commit use \`/record-agent-flow\` to record
1545
- >
1546
- > Detailed docs: \`workflow/flow.md\`
1547
-
1548
- ---
1549
-
1550
- ## Part 5: FAQ
1551
-
1552
- ### Q: Why can't AI commit code itself?
1553
-
1554
- > To ensure code quality. Humans can review and test before commit, preventing problematic code from entering codebase.
1555
-
1556
- ### Q: Do I need to initialize every time?
1557
-
1558
- > No, only once. Identity info is stored locally, not committed to git.
1559
-
1560
- ### Q: Will multi-person collaboration conflict?
1561
-
1562
- > No. Each developer has their own directory, only updates their own files.
1563
-
1564
- ---
1565
-
1566
- ## Part 6: Onboarding Completion Checklist
1567
-
1568
- Confirm all completed:
1569
-
1570
- - [ ] AI understands workflow (Part 1)
1571
- - [ ] Identified developer needs guidance
1572
- - [ ] Developer chose name
1573
- - [ ] \`init-developer.sh\` ran successfully
1574
- - [ ] \`get-developer.sh\` returns correct name
1575
- - [ ] Developer understands AI won't commit
1576
- `;
1577
- fs.writeFileSync(path.join(cwd, "workflow/onboarding-guide.md"), content);
57
+ fs.writeFileSync(path.join(cwd, "workflow/flow.md"), flowMdContent);
1578
58
  }
1579
59
  async function createWorkflowGitignore(cwd) {
1580
- const content = `# Developer identity (local only)
1581
- .developer
1582
- `;
1583
- fs.writeFileSync(path.join(cwd, "workflow/.gitignore"), content);
60
+ fs.writeFileSync(path.join(cwd, "workflow/.gitignore"), workflowGitignoreContent);
1584
61
  }
1585
62
  //# sourceMappingURL=workflow.js.map