@mind-fold/open-flow 0.1.10 → 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.
- package/dist/configurators/templates.d.ts.map +1 -1
- package/dist/configurators/templates.js +14 -995
- package/dist/configurators/templates.js.map +1 -1
- package/dist/configurators/workflow.d.ts.map +1 -1
- package/dist/configurators/workflow.js +24 -1547
- package/dist/configurators/workflow.js.map +1 -1
- package/dist/templates/commands/before-backend-dev.txt +10 -0
- package/dist/templates/commands/before-frontend-dev.txt +10 -0
- package/dist/templates/commands/check-backend.txt +9 -0
- package/dist/templates/commands/check-frontend.txt +9 -0
- package/dist/templates/commands/create-command.txt +155 -0
- package/dist/templates/commands/generate-backend-structure.txt +341 -0
- package/dist/templates/commands/generate-frontend-structure.txt +297 -0
- package/dist/templates/commands/index.d.ts +18 -0
- package/dist/templates/commands/index.d.ts.map +1 -0
- package/dist/templates/commands/index.js +19 -0
- package/dist/templates/commands/index.js.map +1 -0
- package/dist/templates/commands/init-agent.txt +11 -0
- package/dist/templates/commands/onboard-developer.txt +34 -0
- package/dist/templates/commands/record-agent-flow.txt +64 -0
- package/dist/templates/commands/record-question.txt +38 -0
- package/dist/templates/commands/update-backend-structure.txt +16 -0
- package/dist/templates/commands/update-frontend-structure.txt +16 -0
- package/dist/templates/extract.d.ts +20 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +34 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/markdown/agent-progress-index.d.ts +2 -0
- package/dist/templates/markdown/agent-progress-index.d.ts.map +1 -0
- package/dist/templates/markdown/agent-progress-index.js +5 -0
- package/dist/templates/markdown/agent-progress-index.js.map +1 -0
- package/dist/templates/markdown/agent-progress-index.md.txt +124 -0
- package/dist/templates/markdown/backend-doc.d.ts +2 -0
- package/dist/templates/markdown/backend-doc.d.ts.map +1 -0
- package/dist/templates/markdown/backend-doc.js +5 -0
- package/dist/templates/markdown/backend-doc.js.map +1 -0
- package/dist/templates/markdown/backend-doc.md.txt +154 -0
- package/dist/templates/markdown/backend-index.d.ts +2 -0
- package/dist/templates/markdown/backend-index.d.ts.map +1 -0
- package/dist/templates/markdown/backend-index.js +5 -0
- package/dist/templates/markdown/backend-index.js.map +1 -0
- package/dist/templates/markdown/backend-index.md.txt +45 -0
- package/dist/templates/markdown/flow.d.ts +2 -0
- package/dist/templates/markdown/flow.d.ts.map +1 -0
- package/dist/templates/markdown/flow.js +5 -0
- package/dist/templates/markdown/flow.js.map +1 -0
- package/dist/templates/markdown/flow.md.txt +342 -0
- package/dist/templates/markdown/frontend-doc.d.ts +2 -0
- package/dist/templates/markdown/frontend-doc.d.ts.map +1 -0
- package/dist/templates/markdown/frontend-doc.js +5 -0
- package/dist/templates/markdown/frontend-doc.js.map +1 -0
- package/dist/templates/markdown/frontend-doc.md.txt +175 -0
- package/dist/templates/markdown/frontend-index.d.ts +2 -0
- package/dist/templates/markdown/frontend-index.d.ts.map +1 -0
- package/dist/templates/markdown/frontend-index.js +5 -0
- package/dist/templates/markdown/frontend-index.js.map +1 -0
- package/dist/templates/markdown/frontend-index.md.txt +46 -0
- package/dist/templates/markdown/gitignore.d.ts +2 -0
- package/dist/templates/markdown/gitignore.d.ts.map +1 -0
- package/dist/templates/markdown/gitignore.js +5 -0
- package/dist/templates/markdown/gitignore.js.map +1 -0
- package/dist/templates/markdown/gitignore.txt +3 -0
- package/dist/templates/markdown/index.d.ts +12 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +13 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/scripts/add-session.d.ts +2 -0
- package/dist/templates/scripts/add-session.d.ts.map +1 -0
- package/dist/templates/scripts/add-session.js +5 -0
- package/dist/templates/scripts/add-session.js.map +1 -0
- package/dist/templates/scripts/add-session.sh.txt +257 -0
- package/dist/templates/scripts/extract-md-headings.d.ts +2 -0
- package/dist/templates/scripts/extract-md-headings.d.ts.map +1 -0
- package/dist/templates/scripts/extract-md-headings.js +5 -0
- package/dist/templates/scripts/extract-md-headings.js.map +1 -0
- package/dist/templates/scripts/extract-md-headings.sh.txt +260 -0
- package/dist/templates/scripts/feature.d.ts +2 -0
- package/dist/templates/scripts/feature.d.ts.map +1 -0
- package/dist/templates/scripts/feature.js +5 -0
- package/dist/templates/scripts/feature.js.map +1 -0
- package/dist/templates/scripts/feature.sh.txt +243 -0
- package/dist/templates/scripts/get-context.d.ts +2 -0
- package/dist/templates/scripts/get-context.d.ts.map +1 -0
- package/dist/templates/scripts/get-context.js +5 -0
- package/dist/templates/scripts/get-context.js.map +1 -0
- package/dist/templates/scripts/get-context.sh.txt +243 -0
- package/dist/templates/scripts/get-developer.d.ts +2 -0
- package/dist/templates/scripts/get-developer.d.ts.map +1 -0
- package/dist/templates/scripts/get-developer.js +5 -0
- package/dist/templates/scripts/get-developer.js.map +1 -0
- package/dist/templates/scripts/get-developer.sh.txt +16 -0
- package/dist/templates/scripts/index.d.ts +12 -0
- package/dist/templates/scripts/index.d.ts.map +1 -0
- package/dist/templates/scripts/index.js +13 -0
- package/dist/templates/scripts/index.js.map +1 -0
- package/dist/templates/scripts/init-developer.d.ts +2 -0
- package/dist/templates/scripts/init-developer.d.ts.map +1 -0
- package/dist/templates/scripts/init-developer.js +5 -0
- package/dist/templates/scripts/init-developer.js.map +1 -0
- package/dist/templates/scripts/init-developer.sh.txt +114 -0
- package/dist/templates/scripts/update-index.d.ts +2 -0
- package/dist/templates/scripts/update-index.d.ts.map +1 -0
- package/dist/templates/scripts/update-index.js +5 -0
- package/dist/templates/scripts/update-index.js.map +1 -0
- package/dist/templates/scripts/update-index.sh.txt +244 -0
- package/package.json +3 -2
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Add a new session to progress file and update index.md
|
|
3
|
+
# Usage:
|
|
4
|
+
# ./workflow/scripts/add-session.sh --title "Title" --commit "hash" --summary "Summary"
|
|
5
|
+
# echo "content" | ./workflow/scripts/add-session.sh --title "Title" --commit "hash"
|
|
6
|
+
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
WORKFLOW_DIR="$(dirname "$SCRIPT_DIR")"
|
|
11
|
+
PROJECT_ROOT="$(dirname "$WORKFLOW_DIR")"
|
|
12
|
+
|
|
13
|
+
MAX_LINES=2000
|
|
14
|
+
|
|
15
|
+
get_developer() {
|
|
16
|
+
local dev_file="$WORKFLOW_DIR/.developer"
|
|
17
|
+
if [[ -f "$dev_file" ]]; then
|
|
18
|
+
grep "^name=" "$dev_file" | cut -d= -f2
|
|
19
|
+
else
|
|
20
|
+
echo ""
|
|
21
|
+
fi
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
DEVELOPER=$(get_developer)
|
|
25
|
+
if [[ -z "$DEVELOPER" ]]; then
|
|
26
|
+
echo "Error: Developer not initialized. Run ./workflow/scripts/init-developer.sh <name>" >&2
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
DEV_DIR="$WORKFLOW_DIR/agent-progress/$DEVELOPER"
|
|
31
|
+
INDEX_FILE="$DEV_DIR/index.md"
|
|
32
|
+
TODAY=$(date +%Y-%m-%d)
|
|
33
|
+
|
|
34
|
+
get_latest_progress_info() {
|
|
35
|
+
local latest_file=""
|
|
36
|
+
local latest_num=0
|
|
37
|
+
|
|
38
|
+
for f in "$DEV_DIR"/progress-*.md; do
|
|
39
|
+
if [[ -f "$f" ]]; then
|
|
40
|
+
local num=$(basename "$f" | sed 's/progress-\([0-9]*\)\.md/\1/')
|
|
41
|
+
if [[ "$num" -gt "$latest_num" ]]; then
|
|
42
|
+
latest_num=$num
|
|
43
|
+
latest_file="$f"
|
|
44
|
+
fi
|
|
45
|
+
fi
|
|
46
|
+
done
|
|
47
|
+
|
|
48
|
+
if [[ -n "$latest_file" ]]; then
|
|
49
|
+
local lines=$(wc -l < "$latest_file" | tr -d ' ')
|
|
50
|
+
echo "$latest_file:$latest_num:$lines"
|
|
51
|
+
else
|
|
52
|
+
echo ":0:0"
|
|
53
|
+
fi
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get_current_session() {
|
|
57
|
+
local line=$(grep "Total Sessions" "$INDEX_FILE" 2>/dev/null | head -1)
|
|
58
|
+
echo "$line" | sed 's/.*: //' | tr -d ' '
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
create_new_progress_file() {
|
|
62
|
+
local num=$1
|
|
63
|
+
local prev_num=$((num - 1))
|
|
64
|
+
local new_file="$DEV_DIR/progress-$num.md"
|
|
65
|
+
|
|
66
|
+
cat > "$new_file" << EOF
|
|
67
|
+
# Agent Progress - $DEVELOPER (Part $num)
|
|
68
|
+
|
|
69
|
+
> Continuation from \`progress-$prev_num.md\` (archived at ~$MAX_LINES lines)
|
|
70
|
+
> Started: $TODAY
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
EOF
|
|
75
|
+
echo "$new_file"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
generate_session_content() {
|
|
79
|
+
local session_num=$1
|
|
80
|
+
local title=$2
|
|
81
|
+
local commit=$3
|
|
82
|
+
local summary=$4
|
|
83
|
+
local extra_content=$5
|
|
84
|
+
|
|
85
|
+
local commit_table=""
|
|
86
|
+
if [[ -n "$commit" && "$commit" != "-" ]]; then
|
|
87
|
+
commit_table="| Hash | Message |
|
|
88
|
+
|------|---------|"
|
|
89
|
+
IFS=',' read -ra COMMITS <<< "$commit"
|
|
90
|
+
for c in "${COMMITS[@]}"; do
|
|
91
|
+
c=$(echo "$c" | tr -d ' ')
|
|
92
|
+
commit_table="$commit_table
|
|
93
|
+
| \`$c\` | (see git log) |"
|
|
94
|
+
done
|
|
95
|
+
else
|
|
96
|
+
commit_table="(No commits - planning session)"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
cat << EOF
|
|
100
|
+
|
|
101
|
+
## Session $session_num: $title
|
|
102
|
+
|
|
103
|
+
**Date**: $TODAY
|
|
104
|
+
**Feature**: $title
|
|
105
|
+
|
|
106
|
+
### Summary
|
|
107
|
+
|
|
108
|
+
$summary
|
|
109
|
+
|
|
110
|
+
### Main Changes
|
|
111
|
+
|
|
112
|
+
$extra_content
|
|
113
|
+
|
|
114
|
+
### Git Commits
|
|
115
|
+
|
|
116
|
+
$commit_table
|
|
117
|
+
|
|
118
|
+
### Testing
|
|
119
|
+
|
|
120
|
+
- ✅ (Add test results)
|
|
121
|
+
|
|
122
|
+
### Status
|
|
123
|
+
|
|
124
|
+
✅ **Completed**
|
|
125
|
+
|
|
126
|
+
### Next Steps
|
|
127
|
+
|
|
128
|
+
- None - feature complete
|
|
129
|
+
EOF
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
add_session() {
|
|
133
|
+
local title=""
|
|
134
|
+
local commit="-"
|
|
135
|
+
local summary="(Add summary)"
|
|
136
|
+
local content_file=""
|
|
137
|
+
local extra_content="(Add details)"
|
|
138
|
+
|
|
139
|
+
while [[ $# -gt 0 ]]; do
|
|
140
|
+
case $1 in
|
|
141
|
+
--title)
|
|
142
|
+
title="$2"
|
|
143
|
+
shift 2
|
|
144
|
+
;;
|
|
145
|
+
--commit)
|
|
146
|
+
commit="$2"
|
|
147
|
+
shift 2
|
|
148
|
+
;;
|
|
149
|
+
--summary)
|
|
150
|
+
summary="$2"
|
|
151
|
+
shift 2
|
|
152
|
+
;;
|
|
153
|
+
--content-file)
|
|
154
|
+
content_file="$2"
|
|
155
|
+
shift 2
|
|
156
|
+
;;
|
|
157
|
+
*)
|
|
158
|
+
shift
|
|
159
|
+
;;
|
|
160
|
+
esac
|
|
161
|
+
done
|
|
162
|
+
|
|
163
|
+
if [[ -z "$title" ]]; then
|
|
164
|
+
echo "Error: --title is required" >&2
|
|
165
|
+
echo "Usage: $0 --title \"Session Title\" [--commit \"hash1,hash2\"] [--summary \"Brief summary\"]" >&2
|
|
166
|
+
exit 1
|
|
167
|
+
fi
|
|
168
|
+
|
|
169
|
+
if [[ -n "$content_file" && -f "$content_file" ]]; then
|
|
170
|
+
extra_content=$(cat "$content_file")
|
|
171
|
+
elif [[ ! -t 0 ]]; then
|
|
172
|
+
extra_content=$(cat)
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
local progress_info=$(get_latest_progress_info)
|
|
176
|
+
local current_file=$(echo "$progress_info" | cut -d: -f1)
|
|
177
|
+
local current_num=$(echo "$progress_info" | cut -d: -f2)
|
|
178
|
+
local current_lines=$(echo "$progress_info" | cut -d: -f3)
|
|
179
|
+
local current_session=$(get_current_session)
|
|
180
|
+
local new_session=$((current_session + 1))
|
|
181
|
+
|
|
182
|
+
local session_content=$(generate_session_content "$new_session" "$title" "$commit" "$summary" "$extra_content")
|
|
183
|
+
local content_lines=$(echo "$session_content" | wc -l | tr -d ' ')
|
|
184
|
+
|
|
185
|
+
echo "========================================" >&2
|
|
186
|
+
echo "ADD SESSION" >&2
|
|
187
|
+
echo "========================================" >&2
|
|
188
|
+
echo "" >&2
|
|
189
|
+
echo "Session: $new_session" >&2
|
|
190
|
+
echo "Title: $title" >&2
|
|
191
|
+
echo "Commit: $commit" >&2
|
|
192
|
+
echo "" >&2
|
|
193
|
+
echo "Current progress file: progress-$current_num.md" >&2
|
|
194
|
+
echo "Current lines: $current_lines" >&2
|
|
195
|
+
echo "New content lines: $content_lines" >&2
|
|
196
|
+
echo "Total after append: $((current_lines + content_lines))" >&2
|
|
197
|
+
echo "" >&2
|
|
198
|
+
|
|
199
|
+
local target_file="$current_file"
|
|
200
|
+
local target_num=$current_num
|
|
201
|
+
|
|
202
|
+
if [[ $((current_lines + content_lines)) -gt $MAX_LINES ]]; then
|
|
203
|
+
target_num=$((current_num + 1))
|
|
204
|
+
echo "⚠️ Exceeds $MAX_LINES lines, creating progress-$target_num.md" >&2
|
|
205
|
+
target_file=$(create_new_progress_file "$target_num")
|
|
206
|
+
echo "Created: $target_file" >&2
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
echo "$session_content" >> "$target_file"
|
|
210
|
+
echo "✅ Appended session to $(basename "$target_file")" >&2
|
|
211
|
+
|
|
212
|
+
echo "" >&2
|
|
213
|
+
echo "Updating index.md..." >&2
|
|
214
|
+
|
|
215
|
+
if [[ "$commit" == "-" ]]; then
|
|
216
|
+
"$SCRIPT_DIR/update-index.sh" add-session --title "$title"
|
|
217
|
+
else
|
|
218
|
+
"$SCRIPT_DIR/update-index.sh" add-session --title "$title" --commit "$commit"
|
|
219
|
+
fi
|
|
220
|
+
|
|
221
|
+
echo "" >&2
|
|
222
|
+
echo "========================================" >&2
|
|
223
|
+
echo "✅ Session $new_session added successfully!" >&2
|
|
224
|
+
echo "========================================" >&2
|
|
225
|
+
echo "" >&2
|
|
226
|
+
echo "Files updated:" >&2
|
|
227
|
+
echo " - $(basename "$target_file")" >&2
|
|
228
|
+
echo " - index.md" >&2
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
show_help() {
|
|
232
|
+
echo "Usage: $0 --title \"Title\" [options]"
|
|
233
|
+
echo ""
|
|
234
|
+
echo "Add a new session to progress file and update index.md automatically."
|
|
235
|
+
echo ""
|
|
236
|
+
echo "Options:"
|
|
237
|
+
echo " --title TEXT Session title (required)"
|
|
238
|
+
echo " --commit HASHES Comma-separated commit hashes (optional)"
|
|
239
|
+
echo " --summary TEXT Brief summary of the session (optional)"
|
|
240
|
+
echo " --content-file Path to file with detailed content (optional)"
|
|
241
|
+
echo ""
|
|
242
|
+
echo "You can also pipe content via stdin:"
|
|
243
|
+
echo " echo \"Details\" | $0 --title \"Title\" --commit \"abc123\""
|
|
244
|
+
echo ""
|
|
245
|
+
echo "Examples:"
|
|
246
|
+
echo " $0 --title \"Fix login bug\" --commit \"abc1234\" --summary \"Fixed auth issue\""
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
case "${1:-}" in
|
|
250
|
+
--help|-h|help)
|
|
251
|
+
show_help
|
|
252
|
+
;;
|
|
253
|
+
*)
|
|
254
|
+
add_session "$@"
|
|
255
|
+
;;
|
|
256
|
+
esac
|
|
257
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-md-headings.d.ts","sourceRoot":"","sources":["../../../src/templates/scripts/extract-md-headings.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB,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, "extract-md-headings.sh.txt");
|
|
4
|
+
export const extractMdHeadingsScript = fs.readFileSync(templatePath, "utf-8");
|
|
5
|
+
//# sourceMappingURL=extract-md-headings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-md-headings.js","sourceRoot":"","sources":["../../../src/templates/scripts/extract-md-headings.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,4BAA4B,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
|
|
3
|
+
# ============================================
|
|
4
|
+
# Markdown Heading Line Number Extraction Tool
|
|
5
|
+
# ============================================
|
|
6
|
+
#
|
|
7
|
+
# Purpose: Auto-extract headings and line numbers from markdown files
|
|
8
|
+
# Used to quickly update line number references in index.md
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# ./extract-md-headings.sh <markdown-file> [options]
|
|
12
|
+
#
|
|
13
|
+
# Options:
|
|
14
|
+
# -l, --level <1-6> Only extract specific heading levels (default: 1,2)
|
|
15
|
+
# -f, --format <type> Output format: table(default), list, csv, json
|
|
16
|
+
# -r, --range Show line number ranges (current heading to next)
|
|
17
|
+
# -h, --help Show help
|
|
18
|
+
#
|
|
19
|
+
# Examples:
|
|
20
|
+
# # Extract all # and ## level headings
|
|
21
|
+
# ./extract-md-headings.sh doc.md
|
|
22
|
+
#
|
|
23
|
+
# # Only extract ## level headings
|
|
24
|
+
# ./extract-md-headings.sh doc.md -l 2
|
|
25
|
+
#
|
|
26
|
+
# # Output as CSV format
|
|
27
|
+
# ./extract-md-headings.sh doc.md -f csv
|
|
28
|
+
#
|
|
29
|
+
# # Show line number ranges
|
|
30
|
+
# ./extract-md-headings.sh doc.md -r
|
|
31
|
+
#
|
|
32
|
+
# ============================================
|
|
33
|
+
|
|
34
|
+
# Color definitions
|
|
35
|
+
RED='\033[0;31m'
|
|
36
|
+
GREEN='\033[0;32m'
|
|
37
|
+
YELLOW='\033[1;33m'
|
|
38
|
+
BLUE='\033[0;34m'
|
|
39
|
+
CYAN='\033[0;36m'
|
|
40
|
+
NC='\033[0m' # No Color
|
|
41
|
+
|
|
42
|
+
# Default parameters
|
|
43
|
+
LEVELS="1,2"
|
|
44
|
+
FORMAT="table"
|
|
45
|
+
SHOW_RANGE=false
|
|
46
|
+
|
|
47
|
+
# Show help
|
|
48
|
+
show_help() {
|
|
49
|
+
echo "📚 Markdown Heading Line Number Extraction Tool"
|
|
50
|
+
echo ""
|
|
51
|
+
echo "Purpose: Auto-extract headings and line numbers from markdown files"
|
|
52
|
+
echo ""
|
|
53
|
+
echo "Usage:"
|
|
54
|
+
echo " $0 <markdown-file> [options]"
|
|
55
|
+
echo ""
|
|
56
|
+
echo "Options:"
|
|
57
|
+
echo " -l, --level <1-6> Only extract specific heading levels (default: 1,2)"
|
|
58
|
+
echo " Can be single number or comma-separated list: 1,2,3"
|
|
59
|
+
echo " -f, --format <type> Output format:"
|
|
60
|
+
echo " - table Table format (default)"
|
|
61
|
+
echo " - list List format"
|
|
62
|
+
echo " - csv CSV format"
|
|
63
|
+
echo " - json JSON format"
|
|
64
|
+
echo " -r, --range Show line number ranges (current to next same/higher level)"
|
|
65
|
+
echo " -h, --help Show this help"
|
|
66
|
+
echo ""
|
|
67
|
+
echo "Examples:"
|
|
68
|
+
echo " # Extract all # and ## level headings"
|
|
69
|
+
echo " $0 doc.md"
|
|
70
|
+
echo ""
|
|
71
|
+
echo " # Only extract ## level headings"
|
|
72
|
+
echo " $0 doc.md -l 2"
|
|
73
|
+
echo ""
|
|
74
|
+
echo " # Extract # ## ### three levels"
|
|
75
|
+
echo " $0 doc.md -l 1,2,3"
|
|
76
|
+
echo ""
|
|
77
|
+
echo " # Output as CSV format"
|
|
78
|
+
echo " $0 doc.md -f csv"
|
|
79
|
+
echo ""
|
|
80
|
+
echo " # Show line number ranges (for Read tool)"
|
|
81
|
+
echo " $0 doc.md -r"
|
|
82
|
+
echo ""
|
|
83
|
+
exit 0
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
# Parse command line arguments
|
|
87
|
+
POSITIONAL_ARGS=()
|
|
88
|
+
while [[ $# -gt 0 ]]; do
|
|
89
|
+
case $1 in
|
|
90
|
+
-l|--level)
|
|
91
|
+
LEVELS="$2"
|
|
92
|
+
shift 2
|
|
93
|
+
;;
|
|
94
|
+
-f|--format)
|
|
95
|
+
FORMAT="$2"
|
|
96
|
+
shift 2
|
|
97
|
+
;;
|
|
98
|
+
-r|--range)
|
|
99
|
+
SHOW_RANGE=true
|
|
100
|
+
shift
|
|
101
|
+
;;
|
|
102
|
+
-h|--help)
|
|
103
|
+
show_help
|
|
104
|
+
;;
|
|
105
|
+
*)
|
|
106
|
+
POSITIONAL_ARGS+=("$1")
|
|
107
|
+
shift
|
|
108
|
+
;;
|
|
109
|
+
esac
|
|
110
|
+
done
|
|
111
|
+
|
|
112
|
+
# Restore positional args
|
|
113
|
+
set -- "${POSITIONAL_ARGS[@]}"
|
|
114
|
+
|
|
115
|
+
# Check file argument
|
|
116
|
+
if [[ $# -eq 0 ]]; then
|
|
117
|
+
echo -e "${RED}Error: Please provide markdown file path${NC}"
|
|
118
|
+
echo "Use -h or --help to see help"
|
|
119
|
+
exit 1
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
MD_FILE="$1"
|
|
123
|
+
|
|
124
|
+
# Check if file exists
|
|
125
|
+
if [[ ! -f "$MD_FILE" ]]; then
|
|
126
|
+
echo -e "${RED}Error: File not found: $MD_FILE${NC}"
|
|
127
|
+
exit 1
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
# Check if file is markdown
|
|
131
|
+
if [[ ! "$MD_FILE" =~ \.(md|markdown)$ ]]; then
|
|
132
|
+
echo -e "${YELLOW}Warning: File may not be markdown format: $MD_FILE${NC}"
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# Build awk script to extract headings
|
|
136
|
+
AWK_SCRIPT='
|
|
137
|
+
BEGIN {
|
|
138
|
+
split(levels, level_array, ",")
|
|
139
|
+
for (i in level_array) {
|
|
140
|
+
allowed_levels[level_array[i]] = 1
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/^#{1,6} / {
|
|
144
|
+
# Calculate heading level
|
|
145
|
+
match($0, /^#+/)
|
|
146
|
+
level = RLENGTH
|
|
147
|
+
|
|
148
|
+
# Check if this is a level we want
|
|
149
|
+
if (level in allowed_levels) {
|
|
150
|
+
# Extract heading text (remove leading # and space)
|
|
151
|
+
title = substr($0, level + 2)
|
|
152
|
+
# Remove trailing # symbols (some markdown styles)
|
|
153
|
+
gsub(/ #+$/, "", title)
|
|
154
|
+
|
|
155
|
+
# Save heading info (use @@@ as delimiter)
|
|
156
|
+
headings[++count] = level "@@@" NR "@@@" title
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
END {
|
|
160
|
+
for (i = 1; i <= count; i++) {
|
|
161
|
+
split(headings[i], parts, "@@@")
|
|
162
|
+
level = parts[1]
|
|
163
|
+
line = parts[2]
|
|
164
|
+
title = parts[3]
|
|
165
|
+
|
|
166
|
+
# Calculate end line (previous line of next same/higher level heading)
|
|
167
|
+
end_line = total_lines
|
|
168
|
+
for (j = i + 1; j <= count; j++) {
|
|
169
|
+
split(headings[j], next_parts, "@@@")
|
|
170
|
+
next_level = next_parts[1]
|
|
171
|
+
next_line = next_parts[2]
|
|
172
|
+
if (next_level <= level) {
|
|
173
|
+
end_line = next_line - 1
|
|
174
|
+
break
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
printf "%d|%d|%d|%s\n", level, line, end_line, title
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
'
|
|
182
|
+
|
|
183
|
+
# Get total lines
|
|
184
|
+
TOTAL_LINES=$(wc -l < "$MD_FILE" | tr -d ' ')
|
|
185
|
+
|
|
186
|
+
# Extract headings
|
|
187
|
+
HEADINGS=$(awk -v levels="$LEVELS" -v total_lines="$TOTAL_LINES" "$AWK_SCRIPT" "$MD_FILE")
|
|
188
|
+
|
|
189
|
+
# Check if headings found
|
|
190
|
+
if [[ -z "$HEADINGS" ]]; then
|
|
191
|
+
echo -e "${YELLOW}No matching headings found${NC}"
|
|
192
|
+
exit 0
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# Output based on format
|
|
196
|
+
case $FORMAT in
|
|
197
|
+
table)
|
|
198
|
+
echo -e "${GREEN}📋 Heading List${NC}"
|
|
199
|
+
echo -e "${CYAN}File: $MD_FILE${NC}"
|
|
200
|
+
echo ""
|
|
201
|
+
printf "%-8s %-12s %-12s %s\n" "Level" "Line" "Range" "Title"
|
|
202
|
+
printf "%-8s %-12s %-12s %s\n" "----" "----" "----" "----"
|
|
203
|
+
echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
|
|
204
|
+
indent=$(printf '%*s' $((level * 2)) '')
|
|
205
|
+
if [[ "$SHOW_RANGE" == true ]]; then
|
|
206
|
+
range="L${line}-${end_line}"
|
|
207
|
+
else
|
|
208
|
+
range="L${line}"
|
|
209
|
+
fi
|
|
210
|
+
printf "%-8s %-12s %-12s %s%s\n" "$level" "$line" "$range" "$indent" "$title"
|
|
211
|
+
done
|
|
212
|
+
;;
|
|
213
|
+
|
|
214
|
+
list)
|
|
215
|
+
echo -e "${GREEN}📋 Heading List${NC}"
|
|
216
|
+
echo -e "${CYAN}File: $MD_FILE${NC}"
|
|
217
|
+
echo ""
|
|
218
|
+
echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
|
|
219
|
+
indent=$(printf '%*s' $((level * 2)) '')
|
|
220
|
+
if [[ "$SHOW_RANGE" == true ]]; then
|
|
221
|
+
echo "L${line}-${end_line}: ${indent}$title"
|
|
222
|
+
else
|
|
223
|
+
echo "L${line}: ${indent}$title"
|
|
224
|
+
fi
|
|
225
|
+
done
|
|
226
|
+
;;
|
|
227
|
+
|
|
228
|
+
csv)
|
|
229
|
+
echo "Level,LineStart,LineEnd,Title"
|
|
230
|
+
echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
|
|
231
|
+
# CSV needs to escape commas and quotes in title
|
|
232
|
+
escaped_title=$(echo "$title" | sed 's/"/""/g')
|
|
233
|
+
echo "$level,$line,$end_line,\"$escaped_title\""
|
|
234
|
+
done
|
|
235
|
+
;;
|
|
236
|
+
|
|
237
|
+
json)
|
|
238
|
+
echo "["
|
|
239
|
+
first=true
|
|
240
|
+
echo "$HEADINGS" | while IFS='|' read -r level line end_line title; do
|
|
241
|
+
if [[ "$first" != true ]]; then
|
|
242
|
+
echo ","
|
|
243
|
+
fi
|
|
244
|
+
first=false
|
|
245
|
+
# JSON needs to escape quotes and backslashes
|
|
246
|
+
escaped_title=$(echo "$title" | sed 's/\\/\\\\/g' | sed 's/"/\\"/g')
|
|
247
|
+
printf ' {"level": %d, "lineStart": %d, "lineEnd": %d, "title": "%s"}' \
|
|
248
|
+
"$level" "$line" "$end_line" "$escaped_title"
|
|
249
|
+
done
|
|
250
|
+
echo ""
|
|
251
|
+
echo "]"
|
|
252
|
+
;;
|
|
253
|
+
|
|
254
|
+
*)
|
|
255
|
+
echo -e "${RED}Error: Unknown output format: $FORMAT${NC}"
|
|
256
|
+
echo "Supported formats: table, list, csv, json"
|
|
257
|
+
exit 1
|
|
258
|
+
;;
|
|
259
|
+
esac
|
|
260
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../src/templates/scripts/feature.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,QAAyC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../src/templates/scripts/feature.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,gBAAgB,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC"}
|