forked from DreamLab-AI/origin-logseq-AR
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathassemble-blobs.sh
More file actions
executable file
·371 lines (322 loc) · 14.6 KB
/
assemble-blobs.sh
File metadata and controls
executable file
·371 lines (322 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
#!/bin/bash
# VisionFlow Codebase Blob Assembler
# Assembles client and server code into concatenated text files
# for 1M token context window audit
#
# Output: /tmp/visionflow-blobs/
# - server-blob.txt (~560K tokens)
# - client-blob.txt (~306K tokens)
# - spec-blob.txt (~83K tokens)
# - manifest.json (metadata index)
set -uo pipefail
PROJECT="/home/devuser/workspace/project"
OUTPUT="/tmp/visionflow-blobs"
mkdir -p "$OUTPUT"
# ============================================================
# UTILITY: Add file with metadata header
# ============================================================
add_file() {
local blob_file="$1"
local src_file="$2"
local category="${3:-source}"
if [ ! -f "$src_file" ]; then
return
fi
local rel_path="${src_file#$PROJECT/}"
local lines=$(wc -l < "$src_file")
echo "" >> "$blob_file"
echo "// ================================================================" >> "$blob_file"
echo "// FILE: $rel_path" >> "$blob_file"
echo "// LINES: $lines | CATEGORY: $category" >> "$blob_file"
echo "// ================================================================" >> "$blob_file"
cat "$src_file" >> "$blob_file"
echo "" >> "$blob_file"
}
# ============================================================
# UTILITY: Strip #[cfg(test)] blocks from Rust files
# ============================================================
add_rust_file_no_tests() {
local blob_file="$1"
local src_file="$2"
local category="${3:-source}"
if [ ! -f "$src_file" ]; then
return
fi
local rel_path="${src_file#$PROJECT/}"
# Strip cfg(test) modules using awk
local content
content=$(awk '
BEGIN { skip=0; brace_count=0 }
/^#\[cfg\(test\)\]/ { skip=1; next }
skip==1 && /\{/ { brace_count++; next }
skip==1 && /\}/ { brace_count--; if(brace_count<=0) { skip=0; brace_count=0 }; next }
skip==1 { next }
{ print }
' "$src_file")
local lines=$(echo "$content" | wc -l)
echo "" >> "$blob_file"
echo "// ================================================================" >> "$blob_file"
echo "// FILE: $rel_path" >> "$blob_file"
echo "// LINES: $lines | CATEGORY: $category (tests stripped)" >> "$blob_file"
echo "// ================================================================" >> "$blob_file"
echo "$content" >> "$blob_file"
echo "" >> "$blob_file"
}
# ============================================================
# SERVER BLOB
# ============================================================
echo "=== Assembling Server Blob ==="
SERVER_BLOB="$OUTPUT/server-blob.txt"
cat > "$SERVER_BLOB" << 'HEADER'
================================================================================
VISIONFLOW SERVER CODEBASE (Rust/Actix-web)
================================================================================
Architecture: Actix-web + Actor system + CQRS + Hexagonal + GPU (CUDA)
Database: Neo4j graph database
Auth: Nostr NIP-98 + session tokens
Physics: GPU-accelerated force-directed layout with CUDA kernels
Features: OWL ontology reasoning, semantic analysis, graph algorithms,
community detection, anomaly detection, pathfinding, stress majorization
Total files: ~427 Rust source files
================================================================================
HEADER
# 1. Entry point and app state
echo " [1/12] Entry points..."
add_rust_file_no_tests "$SERVER_BLOB" "$PROJECT/src/main.rs" "entry"
add_rust_file_no_tests "$SERVER_BLOB" "$PROJECT/src/lib.rs" "entry"
add_rust_file_no_tests "$SERVER_BLOB" "$PROJECT/src/app_state.rs" "entry"
add_rust_file_no_tests "$SERVER_BLOB" "$PROJECT/src/openapi.rs" "entry"
# 2. Models
echo " [2/12] Models..."
find "$PROJECT/src/models/" -name "*.rs" -type f 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "model"
done
# 3. Ports (interfaces)
echo " [3/12] Ports..."
find "$PROJECT/src/ports/" -name "*.rs" -type f 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "port"
done
# 4. Errors
echo " [4/12] Errors..."
find "$PROJECT/src/errors/" -name "*.rs" -type f 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "error"
done
# 5. Adapters (excluding test files)
echo " [5/12] Adapters..."
find "$PROJECT/src/adapters/" -name "*.rs" -type f ! -path "*/tests/*" 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "adapter"
done
# 6. CQRS layer
echo " [6/12] CQRS..."
find "$PROJECT/src/cqrs/" -name "*.rs" -type f 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "cqrs"
done
# 7. Application services
echo " [7/12] Application..."
find "$PROJECT/src/application/" -name "*.rs" -type f ! -path "*/tests/*" 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "application"
done
# 8. Services
echo " [8/12] Services..."
find "$PROJECT/src/services/" -name "*.rs" -type f ! -name "*stub*" 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "service"
done
# 9. Actors
echo " [9/12] Actors..."
find "$PROJECT/src/actors/" -name "*.rs" -type f 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "actor"
done
# 10. Handlers
echo " [10/12] Handlers..."
find "$PROJECT/src/handlers/" -name "*.rs" -type f ! -path "*/tests/*" 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "handler"
done
# 11. GPU + Physics
echo " [11/12] GPU & Physics..."
find "$PROJECT/src/gpu/" -name "*.rs" -type f 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "gpu"
done
find "$PROJECT/src/physics/" -name "*.rs" -type f ! -name "*integration_test*" 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "physics"
done
# 12. Infrastructure (config, middleware, utils, events, constraints, types, etc)
echo " [12/12] Infrastructure..."
for dir in config middleware utils events constraints types inference ontology telemetry protocols settings validation; do
find "$PROJECT/src/$dir/" -name "*.rs" -type f ! -path "*/tests/*" ! -name "*test*" 2>/dev/null | sort | while read f; do
add_rust_file_no_tests "$SERVER_BLOB" "$f" "$dir"
done 2>/dev/null || true
done
# Add Cargo.toml for dependency context
echo "" >> "$SERVER_BLOB"
echo "// ================================================================" >> "$SERVER_BLOB"
echo "// FILE: Cargo.toml" >> "$SERVER_BLOB"
echo "// CATEGORY: build-config" >> "$SERVER_BLOB"
echo "// ================================================================" >> "$SERVER_BLOB"
cat "$PROJECT/Cargo.toml" >> "$SERVER_BLOB"
SERVER_LINES=$(wc -l < "$SERVER_BLOB")
echo " Server blob: $SERVER_LINES lines"
# ============================================================
# CLIENT BLOB
# ============================================================
echo ""
echo "=== Assembling Client Blob ==="
CLIENT_BLOB="$OUTPUT/client-blob.txt"
cat > "$CLIENT_BLOB" << 'HEADER'
================================================================================
VISIONFLOW CLIENT CODEBASE (TypeScript/React/Three.js)
================================================================================
Framework: React 19 + Three.js/R3F + Zustand + TailwindCSS 4
3D: @react-three/fiber + @react-three/drei + @react-three/xr
WASM: scene-effects crate (Rust compiled to WebAssembly)
State: Zustand stores with Immer
UI: Radix UI primitives + Lucide icons + Framer Motion
WebSocket: Binary protocol for real-time position updates
Features: 3D graph visualization, XR/VR mode, voice commands,
AI integrations (RAGFlow, Perplexity, OpenAI, Kokoro TTS, Whisper STT)
================================================================================
HEADER
# Client files by feature area (excluding tests)
echo " [1/7] Core app files..."
find "$PROJECT/client/src" -maxdepth 1 \( -name "*.ts" -o -name "*.tsx" \) 2>/dev/null | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "core"
done
echo " [2/7] Features (graph, settings, etc)..."
find "$PROJECT/client/src/features/" \( -name "*.ts" -o -name "*.tsx" \) 2>/dev/null | grep -v "__tests__" | grep -v ".test." | grep -v ".spec." | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "feature"
done
echo " [3/7] Components..."
find "$PROJECT/client/src/components/" \( -name "*.ts" -o -name "*.tsx" \) 2>/dev/null | grep -v "__tests__" | grep -v ".test." | grep -v ".spec." | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "component"
done
echo " [4/7] Hooks & Store..."
find "$PROJECT/client/src/hooks/" "$PROJECT/client/src/store/" \( -name "*.ts" -o -name "*.tsx" \) 2>/dev/null | grep -v "__tests__" | grep -v ".test." | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "hook-store"
done
echo " [5/7] Services & API..."
find "$PROJECT/client/src/services/" "$PROJECT/client/src/api/" -name "*.ts" 2>/dev/null | grep -v "__tests__" | grep -v ".test." | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "service"
done
echo " [6/7] Types, Utils, Config, Settings..."
for dir in types utils config settings; do
if [ -d "$PROJECT/client/src/$dir/" ]; then
find "$PROJECT/client/src/$dir/" -name "*.ts" 2>/dev/null | grep -v "__tests__" | grep -v ".test." | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "types-utils"
done
fi
done
echo " [7/7] Workers, WASM bridge..."
find "$PROJECT/client/src/workers/" "$PROJECT/client/src/wasm/" -name "*.ts" 2>/dev/null | grep -v ".test." | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "worker-wasm"
done
# WASM Rust crate
echo "" >> "$CLIENT_BLOB"
echo "// ================================================================" >> "$CLIENT_BLOB"
echo "// WASM SCENE EFFECTS CRATE (Rust -> WebAssembly)" >> "$CLIENT_BLOB"
echo "// ================================================================" >> "$CLIENT_BLOB"
find "$PROJECT/client/crates/" -name "*.rs" 2>/dev/null | sort | while read f; do
add_file "$CLIENT_BLOB" "$f" "wasm-rust"
done
# Package.json for dependency context
echo "" >> "$CLIENT_BLOB"
echo "// ================================================================" >> "$CLIENT_BLOB"
echo "// FILE: client/package.json" >> "$CLIENT_BLOB"
echo "// CATEGORY: build-config" >> "$CLIENT_BLOB"
echo "// ================================================================" >> "$CLIENT_BLOB"
cat "$PROJECT/client/package.json" >> "$CLIENT_BLOB"
CLIENT_LINES=$(wc -l < "$CLIENT_BLOB")
echo " Client blob: $CLIENT_LINES lines"
# ============================================================
# SPEC BLOB (Diagrams + Dense Overview)
# ============================================================
echo ""
echo "=== Assembling Spec Blob ==="
SPEC_BLOB="$OUTPUT/spec-blob.txt"
cat > "$SPEC_BLOB" << 'HEADER'
================================================================================
VISIONFLOW FUNCTIONAL SPECIFICATION & ARCHITECTURE DIAGRAMS
================================================================================
Contains: Dense system overview, Mermaid architecture diagrams,
data flow diagrams, component diagrams, API reference
All diagrams are Mermaid notation (diagrams-as-code)
================================================================================
HEADER
# Dense overview first (most valuable single doc)
echo " [1/4] Dense overview..."
add_file "$SPEC_BLOB" "$PROJECT/docs/denseOverview.md" "spec"
# Architecture overview
echo " [2/4] Architecture docs..."
add_file "$SPEC_BLOB" "$PROJECT/docs/architecture.md" "spec"
add_file "$SPEC_BLOB" "$PROJECT/docs/api-reference.md" "spec"
# Dedicated diagram files (high-density architecture diagrams)
echo " [3/4] Architecture diagrams..."
find "$PROJECT/docs/diagrams/" -name "*.md" -type f 2>/dev/null | sort | while read f; do
add_file "$SPEC_BLOB" "$f" "diagram"
done
# Key architecture explanation docs
echo " [4/4] Architecture explanations..."
for f in \
"$PROJECT/docs/explanation/system-overview.md" \
"$PROJECT/docs/explanation/architecture/data-flow.md" \
"$PROJECT/docs/explanation/architecture/system-architecture.md" \
"$PROJECT/docs/explanation/architecture/server/overview.md" \
"$PROJECT/docs/explanation/architecture/client/overview.md" \
"$PROJECT/docs/explanation/architecture/components/websocket-protocol.md" \
"$PROJECT/docs/explanation/architecture/gpu/communication-flow.md" \
"$PROJECT/docs/explanation/architecture/event-driven-architecture.md" \
"$PROJECT/docs/explanation/architecture/pipeline-sequence-diagrams.md" \
"$PROJECT/docs/explanation/concepts/architecture/core/server.md" \
"$PROJECT/docs/explanation/concepts/architecture/core/client.md" \
"$PROJECT/docs/explanation/concepts/actor-model.md" \
"$PROJECT/docs/explanation/concepts/physics-engine.md" \
"$PROJECT/docs/explanation/concepts/hexagonal-architecture.md" \
"$PROJECT/docs/reference/protocols/binary-websocket.md" \
"$PROJECT/docs/reference/api/websocket-endpoints.md" \
"$PROJECT/docs/reference/database/ontology-schema-v2.md" \
"$PROJECT/docs/reference/database/schemas.md" \
; do
add_file "$SPEC_BLOB" "$f" "architecture-doc" 2>/dev/null || true
done
SPEC_LINES=$(wc -l < "$SPEC_BLOB")
echo " Spec blob: $SPEC_LINES lines"
# ============================================================
# MANIFEST
# ============================================================
echo ""
echo "=== Generating Manifest ==="
cat > "$OUTPUT/manifest.json" << EOF
{
"project": "VisionFlow AI Multi-Agent Knowledge Graph Visualisation",
"generated": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"blobs": {
"server-blob.txt": {
"lines": $SERVER_LINES,
"estimated_tokens": $(echo "$SERVER_LINES * 3.5 / 1" | bc),
"language": "Rust",
"framework": "Actix-web + CUDA",
"contents": "All server source code (tests stripped), Cargo.toml"
},
"client-blob.txt": {
"lines": $CLIENT_LINES,
"estimated_tokens": $(echo "$CLIENT_LINES * 3.5 / 1" | bc),
"language": "TypeScript/TSX",
"framework": "React 19 + Three.js + R3F",
"contents": "All client source code (tests excluded), WASM crate, package.json"
},
"spec-blob.txt": {
"lines": $SPEC_LINES,
"estimated_tokens": $(echo "$SPEC_LINES * 2.5 / 1" | bc),
"language": "Markdown + Mermaid",
"contents": "Dense overview, architecture diagrams, API reference, key docs"
}
},
"total_estimated_tokens": $(echo "($SERVER_LINES * 3.5 + $CLIENT_LINES * 3.5 + $SPEC_LINES * 2.5) / 1" | bc),
"target_context_window": 1000000
}
EOF
echo ""
echo "=== DONE ==="
echo "Files in $OUTPUT/:"
ls -lh "$OUTPUT/"
echo ""
echo "Token estimates:"
cat "$OUTPUT/manifest.json" | python3 -m json.tool 2>/dev/null || cat "$OUTPUT/manifest.json"