@mind-fold/open-flow 0.1.10 → 0.1.12

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 (120) hide show
  1. package/dist/cli/index.js +2 -0
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/commands/init.d.ts +2 -0
  4. package/dist/commands/init.d.ts.map +1 -1
  5. package/dist/commands/init.js +25 -40
  6. package/dist/commands/init.js.map +1 -1
  7. package/dist/configurators/claude.js +6 -6
  8. package/dist/configurators/claude.js.map +1 -1
  9. package/dist/configurators/cursor.js +6 -6
  10. package/dist/configurators/cursor.js.map +1 -1
  11. package/dist/configurators/templates.d.ts.map +1 -1
  12. package/dist/configurators/templates.js +14 -995
  13. package/dist/configurators/templates.js.map +1 -1
  14. package/dist/configurators/workflow.d.ts.map +1 -1
  15. package/dist/configurators/workflow.js +25 -1549
  16. package/dist/configurators/workflow.js.map +1 -1
  17. package/dist/templates/commands/before-backend-dev.txt +10 -0
  18. package/dist/templates/commands/before-frontend-dev.txt +10 -0
  19. package/dist/templates/commands/check-backend.txt +9 -0
  20. package/dist/templates/commands/check-frontend.txt +9 -0
  21. package/dist/templates/commands/create-command.txt +155 -0
  22. package/dist/templates/commands/generate-backend-structure.txt +341 -0
  23. package/dist/templates/commands/generate-frontend-structure.txt +297 -0
  24. package/dist/templates/commands/index.d.ts +18 -0
  25. package/dist/templates/commands/index.d.ts.map +1 -0
  26. package/dist/templates/commands/index.js +19 -0
  27. package/dist/templates/commands/index.js.map +1 -0
  28. package/dist/templates/commands/init-agent.txt +11 -0
  29. package/dist/templates/commands/onboard-developer.txt +34 -0
  30. package/dist/templates/commands/record-agent-flow.txt +64 -0
  31. package/dist/templates/commands/record-question.txt +38 -0
  32. package/dist/templates/commands/update-backend-structure.txt +16 -0
  33. package/dist/templates/commands/update-frontend-structure.txt +16 -0
  34. package/dist/templates/extract.d.ts +20 -0
  35. package/dist/templates/extract.d.ts.map +1 -0
  36. package/dist/templates/extract.js +34 -0
  37. package/dist/templates/extract.js.map +1 -0
  38. package/dist/templates/markdown/agent-progress-index.d.ts +2 -0
  39. package/dist/templates/markdown/agent-progress-index.d.ts.map +1 -0
  40. package/dist/templates/markdown/agent-progress-index.js +5 -0
  41. package/dist/templates/markdown/agent-progress-index.js.map +1 -0
  42. package/dist/templates/markdown/agent-progress-index.md.txt +124 -0
  43. package/dist/templates/markdown/backend-doc.d.ts +2 -0
  44. package/dist/templates/markdown/backend-doc.d.ts.map +1 -0
  45. package/dist/templates/markdown/backend-doc.js +5 -0
  46. package/dist/templates/markdown/backend-doc.js.map +1 -0
  47. package/dist/templates/markdown/backend-doc.md.txt +154 -0
  48. package/dist/templates/markdown/backend-index.d.ts +2 -0
  49. package/dist/templates/markdown/backend-index.d.ts.map +1 -0
  50. package/dist/templates/markdown/backend-index.js +5 -0
  51. package/dist/templates/markdown/backend-index.js.map +1 -0
  52. package/dist/templates/markdown/backend-index.md.txt +45 -0
  53. package/dist/templates/markdown/flow.d.ts +2 -0
  54. package/dist/templates/markdown/flow.d.ts.map +1 -0
  55. package/dist/templates/markdown/flow.js +5 -0
  56. package/dist/templates/markdown/flow.js.map +1 -0
  57. package/dist/templates/markdown/flow.md.txt +342 -0
  58. package/dist/templates/markdown/frontend-doc.d.ts +2 -0
  59. package/dist/templates/markdown/frontend-doc.d.ts.map +1 -0
  60. package/dist/templates/markdown/frontend-doc.js +5 -0
  61. package/dist/templates/markdown/frontend-doc.js.map +1 -0
  62. package/dist/templates/markdown/frontend-doc.md.txt +175 -0
  63. package/dist/templates/markdown/frontend-index.d.ts +2 -0
  64. package/dist/templates/markdown/frontend-index.d.ts.map +1 -0
  65. package/dist/templates/markdown/frontend-index.js +5 -0
  66. package/dist/templates/markdown/frontend-index.js.map +1 -0
  67. package/dist/templates/markdown/frontend-index.md.txt +46 -0
  68. package/dist/templates/markdown/gitignore.d.ts +2 -0
  69. package/dist/templates/markdown/gitignore.d.ts.map +1 -0
  70. package/dist/templates/markdown/gitignore.js +5 -0
  71. package/dist/templates/markdown/gitignore.js.map +1 -0
  72. package/dist/templates/markdown/gitignore.txt +3 -0
  73. package/dist/templates/markdown/index.d.ts +12 -0
  74. package/dist/templates/markdown/index.d.ts.map +1 -0
  75. package/dist/templates/markdown/index.js +13 -0
  76. package/dist/templates/markdown/index.js.map +1 -0
  77. package/dist/templates/scripts/add-session.d.ts +2 -0
  78. package/dist/templates/scripts/add-session.d.ts.map +1 -0
  79. package/dist/templates/scripts/add-session.js +5 -0
  80. package/dist/templates/scripts/add-session.js.map +1 -0
  81. package/dist/templates/scripts/add-session.sh.txt +257 -0
  82. package/dist/templates/scripts/extract-md-headings.d.ts +2 -0
  83. package/dist/templates/scripts/extract-md-headings.d.ts.map +1 -0
  84. package/dist/templates/scripts/extract-md-headings.js +5 -0
  85. package/dist/templates/scripts/extract-md-headings.js.map +1 -0
  86. package/dist/templates/scripts/extract-md-headings.sh.txt +260 -0
  87. package/dist/templates/scripts/feature.d.ts +2 -0
  88. package/dist/templates/scripts/feature.d.ts.map +1 -0
  89. package/dist/templates/scripts/feature.js +5 -0
  90. package/dist/templates/scripts/feature.js.map +1 -0
  91. package/dist/templates/scripts/feature.sh.txt +243 -0
  92. package/dist/templates/scripts/get-context.d.ts +2 -0
  93. package/dist/templates/scripts/get-context.d.ts.map +1 -0
  94. package/dist/templates/scripts/get-context.js +5 -0
  95. package/dist/templates/scripts/get-context.js.map +1 -0
  96. package/dist/templates/scripts/get-context.sh.txt +243 -0
  97. package/dist/templates/scripts/get-developer.d.ts +2 -0
  98. package/dist/templates/scripts/get-developer.d.ts.map +1 -0
  99. package/dist/templates/scripts/get-developer.js +5 -0
  100. package/dist/templates/scripts/get-developer.js.map +1 -0
  101. package/dist/templates/scripts/get-developer.sh.txt +16 -0
  102. package/dist/templates/scripts/index.d.ts +12 -0
  103. package/dist/templates/scripts/index.d.ts.map +1 -0
  104. package/dist/templates/scripts/index.js +13 -0
  105. package/dist/templates/scripts/index.js.map +1 -0
  106. package/dist/templates/scripts/init-developer.d.ts +2 -0
  107. package/dist/templates/scripts/init-developer.d.ts.map +1 -0
  108. package/dist/templates/scripts/init-developer.js +5 -0
  109. package/dist/templates/scripts/init-developer.js.map +1 -0
  110. package/dist/templates/scripts/init-developer.sh.txt +114 -0
  111. package/dist/templates/scripts/update-index.d.ts +2 -0
  112. package/dist/templates/scripts/update-index.d.ts.map +1 -0
  113. package/dist/templates/scripts/update-index.js +5 -0
  114. package/dist/templates/scripts/update-index.js.map +1 -0
  115. package/dist/templates/scripts/update-index.sh.txt +244 -0
  116. package/dist/utils/file-writer.d.ts +21 -0
  117. package/dist/utils/file-writer.d.ts.map +1 -0
  118. package/dist/utils/file-writer.js +93 -0
  119. package/dist/utils/file-writer.js.map +1 -0
  120. package/package.json +3 -2
@@ -0,0 +1,114 @@
1
+ #!/bin/bash
2
+
3
+ # Initialize developer identity for open-flow
4
+ # Usage: ./workflow/scripts/init-developer.sh <developer-name>
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
+ WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
8
+
9
+ if [ -z "$1" ]; then
10
+ echo "Usage: $0 <developer-name>"
11
+ echo "Example: $0 john-doe"
12
+ exit 1
13
+ fi
14
+
15
+ DEVELOPER_NAME="$1"
16
+ DEVELOPER_FILE="$WORKFLOW_DIR/.developer"
17
+ PROGRESS_DIR="$WORKFLOW_DIR/agent-progress/$DEVELOPER_NAME"
18
+ FEATURES_DIR="$PROGRESS_DIR/features"
19
+
20
+ # Check if already initialized
21
+ if [ -f "$DEVELOPER_FILE" ]; then
22
+ CURRENT=$(grep "^name=" "$DEVELOPER_FILE" | cut -d= -f2)
23
+ echo "Already initialized as: $CURRENT"
24
+ read -p "Override with $DEVELOPER_NAME? (y/N) " -n 1 -r
25
+ echo
26
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
27
+ exit 0
28
+ fi
29
+ fi
30
+
31
+ # Create developer identity file (using name= format for parsing)
32
+ cat > "$DEVELOPER_FILE" << EOF
33
+ # Developer Identity (gitignored)
34
+ # Created by open-flow
35
+
36
+ name=$DEVELOPER_NAME
37
+ created=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
38
+ EOF
39
+
40
+ # Create progress directory and features directory
41
+ mkdir -p "$PROGRESS_DIR"
42
+ mkdir -p "$FEATURES_DIR"
43
+ mkdir -p "$FEATURES_DIR/archive"
44
+
45
+ # Create personal index with auto-update markers
46
+ cat > "$PROGRESS_DIR/index.md" << EOF
47
+ # Agent Progress - $DEVELOPER_NAME
48
+
49
+ > Personal progress tracking for $DEVELOPER_NAME
50
+
51
+ ## Current Status
52
+
53
+ <!-- @@@auto:current-status -->
54
+ - **Active File**: \`progress-1.md\`
55
+ - **Total Sessions**: 0
56
+ - **Last Active**: $(date +%Y-%m-%d)
57
+ <!-- @@@/auto:current-status -->
58
+
59
+ ## Active Documents
60
+
61
+ <!-- @@@auto:active-documents -->
62
+ | File | Lines | Status |
63
+ |------|-------|--------|
64
+ | \`progress-1.md\` | ~0 | Active |
65
+ <!-- @@@/auto:active-documents -->
66
+
67
+ ## Session History (Recent)
68
+
69
+ <!-- @@@auto:session-history -->
70
+
71
+ | Session | Date | Title | Commit |
72
+ |---------|------|-------|--------|
73
+ | - | - | - | - |
74
+
75
+ <!-- @@@/auto:session-history -->
76
+
77
+ ---
78
+
79
+ ## Notes
80
+
81
+ - Each progress file has max 2000 lines
82
+ - When exceeded, create new file and archive old one
83
+ - Update this index when creating new files
84
+ EOF
85
+
86
+ # Create initial progress file
87
+ cat > "$PROGRESS_DIR/progress-1.md" << EOF
88
+ # Progress Record - $DEVELOPER_NAME
89
+
90
+ > Session-by-session work log
91
+
92
+ ---
93
+
94
+ ## Session 1 - $(date +%Y-%m-%d)
95
+
96
+ ### Summary
97
+ Initial setup
98
+
99
+ ### Main Changes
100
+ - Initialized developer identity
101
+
102
+ ### Git Commits
103
+ - N/A (initial setup)
104
+
105
+ ### Next Steps
106
+ - Start first development task
107
+
108
+ ---
109
+ EOF
110
+
111
+ echo "✅ Developer identity initialized: $DEVELOPER_NAME"
112
+ echo " Progress directory: $PROGRESS_DIR"
113
+ echo " Features directory: $FEATURES_DIR"
114
+
@@ -0,0 +1,2 @@
1
+ export declare const updateIndexScript: string;
2
+ //# sourceMappingURL=update-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-index.d.ts","sourceRoot":"","sources":["../../../src/templates/scripts/update-index.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,QAAyC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ const templatePath = path.join(__dirname, "update-index.sh.txt");
4
+ export const updateIndexScript = fs.readFileSync(templatePath, "utf-8");
5
+ //# sourceMappingURL=update-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-index.js","sourceRoot":"","sources":["../../../src/templates/scripts/update-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,244 @@
1
+ #!/bin/bash
2
+ # Update index.md automatically
3
+ # Usage: ./workflow/scripts/update-index.sh add-session --title "Title" [--commit "hash1,hash2"]
4
+
5
+ set -e
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
9
+ PROJECT_ROOT="$(dirname "$WORKFLOW_DIR")"
10
+
11
+ get_developer() {
12
+ local dev_file="$WORKFLOW_DIR/.developer"
13
+ if [[ -f "$dev_file" ]]; then
14
+ grep "^name=" "$dev_file" | cut -d= -f2
15
+ else
16
+ echo ""
17
+ fi
18
+ }
19
+
20
+ DEVELOPER=$(get_developer)
21
+ if [[ -z "$DEVELOPER" ]]; then
22
+ echo "Error: Developer not initialized. Run ./workflow/scripts/init-developer.sh <name>" >&2
23
+ exit 1
24
+ fi
25
+
26
+ DEV_DIR="$WORKFLOW_DIR/agent-progress/$DEVELOPER"
27
+ INDEX_FILE="$DEV_DIR/index.md"
28
+
29
+ if [[ ! -f "$INDEX_FILE" ]]; then
30
+ echo "Error: Index file not found: $INDEX_FILE" >&2
31
+ exit 1
32
+ fi
33
+
34
+ TODAY=$(date +%Y-%m-%d)
35
+
36
+ get_active_progress_info() {
37
+ local latest_file=""
38
+ local latest_num=0
39
+
40
+ for f in "$DEV_DIR"/progress-*.md; do
41
+ if [[ -f "$f" ]]; then
42
+ local num=$(basename "$f" | sed 's/progress-\([0-9]*\)\.md/\1/')
43
+ if [[ "$num" -gt "$latest_num" ]]; then
44
+ latest_num=$num
45
+ latest_file="$f"
46
+ fi
47
+ fi
48
+ done
49
+
50
+ if [[ -n "$latest_file" ]]; then
51
+ local lines=$(wc -l < "$latest_file" | tr -d ' ')
52
+ echo "progress-$latest_num.md:$lines"
53
+ else
54
+ echo "progress-1.md:0"
55
+ fi
56
+ }
57
+
58
+ get_current_session() {
59
+ local line=$(grep "Total Sessions" "$INDEX_FILE" 2>/dev/null | head -1)
60
+ echo "$line" | sed 's/.*: //' | tr -d ' '
61
+ }
62
+
63
+ count_progress_files() {
64
+ local result=""
65
+ local active_info=$(get_active_progress_info)
66
+ local active_file=$(echo "$active_info" | cut -d: -f1)
67
+
68
+ for f in $(ls -v "$DEV_DIR"/progress-*.md 2>/dev/null | sort -t- -k2 -n -r); do
69
+ if [[ -f "$f" ]]; then
70
+ local filename=$(basename "$f")
71
+ local lines=$(wc -l < "$f" | tr -d ' ')
72
+
73
+ local status="Archived"
74
+ if [[ "$filename" == "$active_file" ]]; then
75
+ status="Active"
76
+ fi
77
+
78
+ result="${result}| \`$filename\` | ~$lines | $status |
79
+ "
80
+ fi
81
+ done
82
+ echo "$result" | sed '/^$/d'
83
+ }
84
+
85
+ add_session() {
86
+ local title=""
87
+ local commit="-"
88
+
89
+ while [[ $# -gt 0 ]]; do
90
+ case $1 in
91
+ --title)
92
+ title="$2"
93
+ shift 2
94
+ ;;
95
+ --commit)
96
+ local commits="$2"
97
+ if [[ -n "$commits" ]]; then
98
+ commit=$(echo "$commits" | sed 's/,/, /g' | sed 's/\([a-f0-9]\{7,\}\)/`\1`/g')
99
+ fi
100
+ shift 2
101
+ ;;
102
+ *)
103
+ shift
104
+ ;;
105
+ esac
106
+ done
107
+
108
+ if [[ -z "$title" ]]; then
109
+ echo "Error: --title is required" >&2
110
+ echo "Usage: $0 add-session --title \"Session Title\" [--commit \"hash1,hash2\"]" >&2
111
+ exit 1
112
+ fi
113
+
114
+ local current_session=$(get_current_session)
115
+ local new_session=$((current_session + 1))
116
+
117
+ local progress_info=$(get_active_progress_info)
118
+ local active_file=$(echo "$progress_info" | cut -d: -f1)
119
+
120
+ local files_table=$(count_progress_files)
121
+
122
+ echo "Updating index.md for session $new_session..."
123
+ echo " Title: $title"
124
+ echo " Commit: $commit"
125
+ echo " Active File: $active_file"
126
+ echo ""
127
+
128
+ if ! grep -q "@@@auto:current-status" "$INDEX_FILE"; then
129
+ echo "Error: Markers not found in index.md. Please ensure markers exist." >&2
130
+ exit 1
131
+ fi
132
+
133
+ local tmp_file=$(mktemp)
134
+
135
+ local in_current_status=false
136
+ local in_active_documents=false
137
+ local in_session_history=false
138
+ local header_written=false
139
+
140
+ while IFS= read -r line || [[ -n "$line" ]]; do
141
+ if [[ "$line" == *"@@@auto:current-status"* ]]; then
142
+ echo "$line" >> "$tmp_file"
143
+ in_current_status=true
144
+ echo "- **Active File**: \`$active_file\`" >> "$tmp_file"
145
+ echo "- **Total Sessions**: $new_session" >> "$tmp_file"
146
+ echo "- **Last Active**: $TODAY" >> "$tmp_file"
147
+ continue
148
+ fi
149
+
150
+ if [[ "$line" == *"@@@/auto:current-status"* ]]; then
151
+ in_current_status=false
152
+ echo "$line" >> "$tmp_file"
153
+ continue
154
+ fi
155
+
156
+ if [[ "$line" == *"@@@auto:active-documents"* ]]; then
157
+ echo "$line" >> "$tmp_file"
158
+ in_active_documents=true
159
+ echo "| File | Lines | Status |" >> "$tmp_file"
160
+ echo "|------|-------|--------|" >> "$tmp_file"
161
+ echo "$files_table" >> "$tmp_file"
162
+ continue
163
+ fi
164
+
165
+ if [[ "$line" == *"@@@/auto:active-documents"* ]]; then
166
+ in_active_documents=false
167
+ echo "$line" >> "$tmp_file"
168
+ continue
169
+ fi
170
+
171
+ if [[ "$line" == *"@@@auto:session-history"* ]]; then
172
+ echo "$line" >> "$tmp_file"
173
+ in_session_history=true
174
+ header_written=false
175
+ continue
176
+ fi
177
+
178
+ if [[ "$line" == *"@@@/auto:session-history"* ]]; then
179
+ in_session_history=false
180
+ echo "$line" >> "$tmp_file"
181
+ continue
182
+ fi
183
+
184
+ if $in_current_status; then
185
+ continue
186
+ fi
187
+
188
+ if $in_active_documents; then
189
+ continue
190
+ fi
191
+
192
+ if $in_session_history; then
193
+ echo "$line" >> "$tmp_file"
194
+ if [[ "$line" == "|---"* ]] && ! $header_written; then
195
+ echo "| $new_session | $TODAY | $title | $commit |" >> "$tmp_file"
196
+ header_written=true
197
+ fi
198
+ continue
199
+ fi
200
+
201
+ echo "$line" >> "$tmp_file"
202
+ done < "$INDEX_FILE"
203
+
204
+ mv "$tmp_file" "$INDEX_FILE"
205
+
206
+ echo "✅ Updated index.md successfully!"
207
+ echo ""
208
+ echo "Changes:"
209
+ echo " - Total Sessions: $current_session → $new_session"
210
+ echo " - Last Active: $TODAY"
211
+ echo " - New session row added to history"
212
+ }
213
+
214
+ show_help() {
215
+ echo "Usage: $0 <command> [options]"
216
+ echo ""
217
+ echo "Commands:"
218
+ echo " add-session Add a new session to index.md"
219
+ echo " help Show this help message"
220
+ echo ""
221
+ echo "Options for add-session:"
222
+ echo " --title TEXT Session title (required)"
223
+ echo " --commit HASHES Comma-separated commit hashes (optional)"
224
+ echo ""
225
+ echo "Examples:"
226
+ echo " $0 add-session --title \"Fix login bug\" --commit \"abc1234\""
227
+ echo " $0 add-session --title \"Add feature\" --commit \"abc1234,def5678\""
228
+ }
229
+
230
+ case "${1:-help}" in
231
+ add-session)
232
+ shift
233
+ add_session "$@"
234
+ ;;
235
+ help|--help|-h)
236
+ show_help
237
+ ;;
238
+ *)
239
+ echo "Unknown command: $1" >&2
240
+ show_help
241
+ exit 1
242
+ ;;
243
+ esac
244
+
@@ -0,0 +1,21 @@
1
+ export type WriteMode = "ask" | "force" | "skip";
2
+ export interface WriteOptions {
3
+ mode: WriteMode;
4
+ }
5
+ export declare function setWriteMode(mode: WriteMode): void;
6
+ export declare function getWriteMode(): WriteMode;
7
+ /**
8
+ * Write file with conflict handling
9
+ * - If file doesn't exist: write directly
10
+ * - If file exists and mode is 'force': overwrite
11
+ * - If file exists and mode is 'skip': skip
12
+ * - If file exists and mode is 'ask': prompt user
13
+ */
14
+ export declare function writeFile(filePath: string, content: string, options?: {
15
+ executable?: boolean;
16
+ }): Promise<boolean>;
17
+ /**
18
+ * Ensure directory exists
19
+ */
20
+ export declare function ensureDir(dirPath: string): void;
21
+ //# sourceMappingURL=file-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-writer.d.ts","sourceRoot":"","sources":["../../src/utils/file-writer.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,SAAS,CAAC;CAChB;AAKD,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAElD;AAED,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,OAAO,CAAC,OAAO,CAAC,CA4ElB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/C"}
@@ -0,0 +1,93 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import chalk from "chalk";
4
+ import inquirer from "inquirer";
5
+ // Global write mode (set from CLI options)
6
+ let globalWriteMode = "ask";
7
+ export function setWriteMode(mode) {
8
+ globalWriteMode = mode;
9
+ }
10
+ export function getWriteMode() {
11
+ return globalWriteMode;
12
+ }
13
+ /**
14
+ * Write file with conflict handling
15
+ * - If file doesn't exist: write directly
16
+ * - If file exists and mode is 'force': overwrite
17
+ * - If file exists and mode is 'skip': skip
18
+ * - If file exists and mode is 'ask': prompt user
19
+ */
20
+ export async function writeFile(filePath, content, options) {
21
+ const exists = fs.existsSync(filePath);
22
+ const fileName = path.basename(filePath);
23
+ if (!exists) {
24
+ // File doesn't exist, write directly
25
+ fs.writeFileSync(filePath, content);
26
+ if (options?.executable) {
27
+ fs.chmodSync(filePath, "755");
28
+ }
29
+ return true;
30
+ }
31
+ // File exists, handle based on mode
32
+ const mode = globalWriteMode;
33
+ if (mode === "force") {
34
+ fs.writeFileSync(filePath, content);
35
+ if (options?.executable) {
36
+ fs.chmodSync(filePath, "755");
37
+ }
38
+ console.log(chalk.yellow(` ↻ Overwritten: ${fileName}`));
39
+ return true;
40
+ }
41
+ if (mode === "skip") {
42
+ console.log(chalk.gray(` ○ Skipped: ${fileName} (already exists)`));
43
+ return false;
44
+ }
45
+ // mode === 'ask': Interactive prompt
46
+ const { action } = await inquirer.prompt([
47
+ {
48
+ type: "list",
49
+ name: "action",
50
+ message: `File "${fileName}" already exists. What would you like to do?`,
51
+ choices: [
52
+ { name: "Skip (keep existing)", value: "skip" },
53
+ { name: "Overwrite", value: "overwrite" },
54
+ { name: "Skip all remaining conflicts", value: "skip-all" },
55
+ { name: "Overwrite all remaining conflicts", value: "overwrite-all" },
56
+ ],
57
+ },
58
+ ]);
59
+ if (action === "skip") {
60
+ console.log(chalk.gray(` ○ Skipped: ${fileName}`));
61
+ return false;
62
+ }
63
+ if (action === "overwrite") {
64
+ fs.writeFileSync(filePath, content);
65
+ if (options?.executable) {
66
+ fs.chmodSync(filePath, "755");
67
+ }
68
+ console.log(chalk.yellow(` ↻ Overwritten: ${fileName}`));
69
+ return true;
70
+ }
71
+ if (action === "skip-all") {
72
+ globalWriteMode = "skip";
73
+ console.log(chalk.gray(` ○ Skipped: ${fileName}`));
74
+ return false;
75
+ }
76
+ if (action === "overwrite-all") {
77
+ globalWriteMode = "force";
78
+ fs.writeFileSync(filePath, content);
79
+ if (options?.executable) {
80
+ fs.chmodSync(filePath, "755");
81
+ }
82
+ console.log(chalk.yellow(` ↻ Overwritten: ${fileName}`));
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+ /**
88
+ * Ensure directory exists
89
+ */
90
+ export function ensureDir(dirPath) {
91
+ fs.mkdirSync(dirPath, { recursive: true });
92
+ }
93
+ //# sourceMappingURL=file-writer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-writer.js","sourceRoot":"","sources":["../../src/utils/file-writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAQhC,2CAA2C;AAC3C,IAAI,eAAe,GAAc,KAAK,CAAC;AAEvC,MAAM,UAAU,YAAY,CAAC,IAAe;IAC3C,eAAe,GAAG,IAAI,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,YAAY;IAC3B,OAAO,eAAe,CAAC;AACxB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC9B,QAAgB,EAChB,O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AAK,CAAC,MAAM,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,OAAe;IACxC,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mind-fold/open-flow",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "AI-assisted development workflow initializer for Cursor, Claude Code and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,7 +13,8 @@
13
13
  "access": "public"
14
14
  },
15
15
  "scripts": {
16
- "build": "tsc",
16
+ "build": "tsc && npm run copy-templates",
17
+ "copy-templates": "cp -r src/templates/commands/*.txt dist/templates/commands/ && cp -r src/templates/scripts/*.txt dist/templates/scripts/ && cp -r src/templates/markdown/*.txt dist/templates/markdown/",
17
18
  "dev": "tsc --watch",
18
19
  "start": "node ./dist/cli/index.js",
19
20
  "prepublishOnly": "npm run build"