src/: TypeScript backend + graph/layout core. Main entry points aresrc/server.ts(CLI + HTTP server) andsrc/index.ts(graph build APIs).src/routes/: Modular API route handlers (knowledge, notemd, markdown, render, settings, diagnostics, data). Routes are registered viaregisterAllRoutes()and dispatched before the server.ts inline chain.src/middleware/: HTTP middleware (CORS, auth, body-parser, request-trace).src/core/: Bridging logic (PathBridge.ts), graph data structures, path/layout engines.src/backend/: Graph construction pipeline, algorithms, workers.src/learning/: Knowledge learning platform.api.tsdefines 31 typed interfaces;KnowledgeLearningPlatform.tsimplements them.domains/contains 7 domain classes (KnowledgeIngestor,KnowledgeQuerier,ConversationManager,MasteryEngine,QualityEvaluator,TutorRouter,MemoryPolicyManager) with*Platforminterfaces for gradual extraction.src/notemd/: NoteMD LLM-powered Markdown processing.src/utils/: Runtime path resolution (RuntimePaths.ts), cross-platform detection (platform.ts).
src/frontend/: Static UI (HTML/CSS/vanilla JS + ES modules). Employs Web Workers (path_worker.js,simulationWorker.js) to offload rendering and physics. Uses Vite for ES module bundling (6 chunks: main, graph-app, graph-state, agent-workspace, path-mode, path-workbench, path-worker). Extracted ES modules:i18n.mjs,runtime_bridge.mjs,main.mjs,path_worker_bridge.mjs,workbench_state.mjs,graph_state.mjs. Legacy IIFE files (.js) coexist with ES module versions (.mjs).path_mode/: Godot 4.3 UI layer (Forward+ Vulkan renderer, GL Compatibility fallback for mobile).src-tauri/: Tauri v2 (Rust) desktop shell. Platform configs attauri.{linux,macos,windows,android}.conf.json; sidecar binaries atbin/.scripts/: Build helpers (~50 scripts: sidecar build, verification, benchmarking, docs).android/: Capacitor Android project (deprecated; Tauri Android is the active mobile path).dist/: Generated build output fromtsc,vite build, and asset bundling.docs/: Diataxis-framework bilingual docs (EN/ZH). Solutions indocs/solutions/, archive indocs/archive/.
This repo is TypeScript/Node-first integrated with Tauri/Godot. (CI uses Node.js 20).
npm install # install dependencies
npm run build # tsc + copy assets + bundle path_core.js
npm run build:vite # Vite frontend build (ES module bundling)
npm run build:with-vite # full build (tsc + vite)
npm start # dev server at http://localhost:3000
npm run dev:vite # Vite dev server (HMR, proxy to :3000)
npm test # jest (ts-jest) test runner
npm run tauri:dev # Tauri dev (runs build + sidecar build)
npm run tauri:build # Tauri production build + sidecar packaging
npm run build:sidecar # pkg -> src-tauri/bin/server-{target-triple}Mobile (Tauri Android, recommended):
npm run tauri:android:init # first-time setup
npm run tauri:android:dev # dev build
npm run tauri:android:build # release APK/AAB- Godot Bridge Separation: Keep heavy algorithmic and mathematical work (like topological sorts or domain learning) inside
src/core/PathEngine.ts. Godot (path_mode/) should only act as a pure render target parsing bridging websocket JSON (PathBridge.ts). - Memory Safety & Worker Threads: Never parse massive text strings recursively in UI threads. Favor passing references or ArrayBuffers to Web Workers (see
StatisticalAnalyzer&KeywordMatchingoptimizations mitigating Heap OOM errors). - TypeScript
strict: Enabled natively (tsconfig.json). Keep public APIs rigorously typed to prevent parsing failures at the IPC/WebSocket boundary. - Naming Pattern:
PascalCase.tswith matchingPascalCase.test.tsfor modules. Godot prefers standardsnake_casepatterns for GDScript.
- Canonical Mermaid authoring format is Obsidian fenced Markdown: a standalone line starting with ```mermaid and a standalone closing ```.
- This fenced format must remain render-compatible across Web reader, Tauri runtime, and Godot reader flows.
$$```mermaid(or any non-line-start Mermaid fence concatenation) is treated as malformed content and must be fixed at source data level.- Default remediation for
$$```mermaid: split into two lines ($$then```mermaid), or runnpm run fix:markdown:mermaid:fence -- Knowledge_Base/testconcept. - Reader runtime guardrail: on Markdown reader open, run lightweight self-check and auto-heal
$$```mermaidto$$+ newline +```mermaidbefore rendering. - Godot Mermaid runtime path must use renderer preference that allows fallback (
auto), so missing frontend bridge does not break diagram display. - Any interface/runtime change touching markdown parsing or Mermaid rendering must preserve this baseline and re-verify it on
Knowledge_Base/testconcept.
The GET /api/runtime-diagnostics endpoint exposes runtime metrics from all 7 domain classes under the domains key:
{
"domains": {
"ingest": { "ingestCount", "averageIngestLatencyMs", "stalenessQueryCount", ... },
"query": { "queryCount", "cacheHitRate", "latencyP95Ms", "fallbackCount", ... },
"conversation": { "turnCount", "averageResponseLatencyMs", "memoryOperations", ... },
"mastery": { "pathGenerationCount", "sessionExecutionCount", ... },
"quality": { "evaluationCount", "recentPassRate", "snapshotCount", ... },
"tutor": { "actionExecutionCount", "actionKindDistribution", ... },
"memory": { "policyApplicationCount", "policyLayerDistribution", ... }
}
}Route migration metrics (routeMigration.registryHitRate) and global route count (routeMigration.totalModularRoutes: 65) are also exposed.
- Framework: Jest with
ts-jestarrayed injest.config.js. - Tests are colocated under
src/**. Execute them withnpm test. - Add or update regression tests whenever PathEngine logic changes (especially affecting Domain/Diffusion permutations).
- Follow Conventional Commits:
feat: ...,fix: ...,docs: ...,refactor: .... Add Godot-specific scoping where necessary e.g.,fix(godot-ui): padding. - PRs must document: the root cause trace, verification tests run locally across both UI clients (web browser vs Tauri WebView vs Godot executable), and UI screenshots.
- Release tags
vX.Y.Zmust precisely matchpackage.json’s version.
- After creating/pushing any new release tag, update the matching bilingual release note source file in
docs/(for exampledocs/release_notes_v1.6.7.md) before considering the release finalized. - GitHub Release notes must not stay as placeholder text. Use the previous high-quality release page as the structure benchmark; until superseded, treat
v1.6.6as the canonical quality bar for tone, bilingual layout, and subsystem grouping. - Every release note must contain separated
## Englishand## 中文sections, a compare baseline, concrete highlights, and subsystem-oriented bullets that reflect the actual shipped delta rather than generic “release prep” wording. - When a version includes runtime, packaging, CI, docs, or governance changes, summarize each affected surface explicitly so the GitHub Release body can be published directly from the checked-in docs note with minimal or no manual rewriting.