Skip to content

Latest commit

ย 

History

History
1377 lines (1170 loc) ยท 35.7 KB

File metadata and controls

1377 lines (1170 loc) ยท 35.7 KB

SVP (Semantic Voxel Protocol) ้กน็›ฎ่ฎพ่ฎก็จฟ

ๅฎŒๆ•ดๅทฅ็จ‹ๆžถๆž„ไธŽๅฎž็ŽฐๆŒ‡ๅ—


๐Ÿ“‹ ็›ฎๅฝ•

  1. ้กน็›ฎๆฆ‚่ฟฐ
  2. ๅทฅ็จ‹ๅˆ’ๅˆ†
  3. ๆ ธๅฟƒๆžถๆž„
  4. Package่ฎพ่ฎก
  5. ๅฎž็Žฐ็ป†่Š‚
  6. ไฝฟ็”จๆต็จ‹
  7. MCP็”Ÿๆ€้›†ๆˆ
  8. Adapter่ฎพ่ฎก
  9. ๅผ€ๅ‘่ทฏ็บฟๅ›พ
  10. ้™„ๅฝ•

้กน็›ฎๆฆ‚่ฟฐ

้กน็›ฎๅ็งฐ

SVP (Semantic Voxel Protocol) - ่ฏญไน‰ไฝ“็ด ๅ่ฎฎ

ๆ ธๅฟƒๅฎšไฝ

AI-Humanๅไฝœ็ผ–็จ‹็š„"ๆ™บ่ƒฝไธŠไธ‹ๆ–‡็ฝ‘ๅ…ณ"๏ผŒ้€š่ฟ‡่ฏญไน‰ไฝ“็ด +LODๆŠ€ๆœฏ๏ผŒไธบAIๆไพ›็ป“ๆž„ๅŒ–็š„ไปฃ็ ่ฎค็Ÿฅ็ฉบ้—ดใ€‚

่ฎพ่ฎกๅ“ฒๅญฆ

Code โ†’ Voxel Space โ†’ AI Understanding
ๅŽŸๅง‹ไปฃ็  โ”€โ”€โ–ถ ่ฏญไน‰ไฝ“็ด ็ฉบ้—ด โ”€โ”€โ–ถ AIๅฏ็†่งฃ็š„็ป“ๆž„ๅŒ–ไธŠไธ‹ๆ–‡

ๅทฅ็จ‹ๅˆ’ๅˆ†

Monorepo็ป“ๆž„

svp/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ core/                    # @semanticvoxelprotocol/core
โ”‚   โ”‚   โ””โ”€โ”€ ๆ ธๅฟƒๅผ•ๆ“Ž๏ผˆไฝ“็ด ๅŒ–ใ€LODใ€ไธŠไธ‹ๆ–‡็ฎก็†๏ผ‰
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ sdk/                     # @semanticvoxelprotocol/sdk
โ”‚   โ”‚   โ””โ”€โ”€ TypeScript SDK๏ผˆๅผ€ๅ‘่€…ไฝฟ็”จ๏ผ‰
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ mcp-server/              # @semanticvoxelprotocol/mcp-server
โ”‚   โ”‚   โ””โ”€โ”€ MCPๅ่ฎฎ้€‚้…๏ผˆClaude/Cursor้›†ๆˆ๏ผ‰
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ cli/                     # @semanticvoxelprotocol/cli
โ”‚   โ”‚   โ””โ”€โ”€ ๅ‘ฝไปค่กŒๅทฅๅ…ท
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ vscode-extension/        # VS Codeๆ‰ฉๅฑ•
โ”‚   โ”‚   โ””โ”€โ”€ IDEๆ’ไปถ
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ adapters/
โ”‚   โ”‚   โ”œโ”€โ”€ lsp-adapter/         # LSPๅ่ฎฎ้€‚้…
โ”‚   โ”‚   โ”œโ”€โ”€ git-adapter/         # Git้›†ๆˆ
โ”‚   โ”‚   โ””โ”€โ”€ tree-sitter-adapter/ # ่ฏญๆณ•่งฃๆž
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ shared/                  # @semanticvoxelprotocol/shared
โ”‚       โ””โ”€โ”€ ๅ…ฑไบซ็ฑปๅž‹ๅ’Œๅทฅๅ…ท
โ”‚
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ playground/              # ๅผ€ๅ‘ๆต‹่ฏ•็Žฏๅขƒ
โ”‚
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ specification/           # ๅ่ฎฎ่ง„่Œƒ
โ”‚   โ””โ”€โ”€ api-reference/           # APIๆ–‡ๆกฃ
โ”‚
โ””โ”€โ”€ examples/
    โ”œโ”€โ”€ basic-usage/             # ๅŸบ็ก€็”จๆณ•็คบไพ‹
    โ””โ”€โ”€ mcp-integration/         # MCP้›†ๆˆ็คบไพ‹

Packageไพ่ต–ๅ…ณ็ณป

                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  vscode-ext     โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚      cli        โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                             โ”‚
              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
              โ”‚              โ”‚              โ”‚
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚   mcp-server    โ”‚    โ”‚    โ”‚   playground      โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ”‚             โ”‚
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚              sdk               โ”‚
     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                     โ”‚
     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
     โ”‚               โ”‚               โ”‚
โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”
โ”‚  core   โ”‚   โ”‚   shared    โ”‚   โ”‚adapters โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

ๆ ธๅฟƒๆžถๆž„

ๅˆ†ๅฑ‚ๆžถๆž„

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Application Layer                           โ”‚
โ”‚         CLI โ”‚ VS Code Ext โ”‚ MCP Server โ”‚ Web UI                โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                        SDK Layer                                 โ”‚
โ”‚              VoxelClient โ”‚ ContextAPI โ”‚ QueryAPI               โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                       Core Engine Layer                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚  โ”‚ Ingestion   โ”‚  โ”‚ Voxelizationโ”‚  โ”‚    LOD      โ”‚             โ”‚
โ”‚  โ”‚   Engine    โ”‚  โ”‚   Engine    โ”‚  โ”‚   Manager   โ”‚             โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ”‚
โ”‚  โ”‚  Context    โ”‚  โ”‚   Query     โ”‚  โ”‚    Sync     โ”‚             โ”‚
โ”‚  โ”‚ Aggregator  โ”‚  โ”‚   Engine    โ”‚  โ”‚   Manager   โ”‚             โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                      Adapter Layer                               โ”‚
โ”‚    LSP Adapter โ”‚ Git Adapter โ”‚ Tree-sitter โ”‚ File System       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                       Data Layer                                 โ”‚
โ”‚    Octree Index โ”‚ Vector DB โ”‚ Semantic Cache โ”‚ File Storage    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

ๆ ธๅฟƒ็ป„ไปถ่ฏฆ่งฃ

1. Ingestion Engine๏ผˆๆ‘„ๅ–ๅผ•ๆ“Ž๏ผ‰

// packages/core/src/ingestion/engine.ts

interface IngestionConfig {
  source: {
    rootPath: string;
    include: string[];
    exclude: string[];
    gitIntegration: boolean;
  };
  context: {
    configFiles: string[];
    designDocs: string[];
    envVars: string[];
    screenshots: string[];
  };
  watch: {
    enabled: boolean;
    debounceMs: number;
  };
}

class IngestionEngine {
  constructor(private config: IngestionConfig) {}
  
  // ๆ‰ซๆๆบ็ ๆ–‡ไปถ
  async scanSource(): Promise<SourceFile[]> {
    // ไฝฟ็”จglobๆ‰ซๆๆ–‡ไปถ
    // ๆŽ’้™คnode_modules็ญ‰
  }
  
  // ๅŠ ่ฝฝๅค–้ƒจไธŠไธ‹ๆ–‡
  async loadExternalContext(): Promise<ExternalContext> {
    // ่ฏปๅ–.svp/config.yaml
    // ๅŠ ่ฝฝ่ฎพ่ฎกๆ–‡ๆกฃ
    // ่งฃๆž็Žฏๅขƒๅ˜้‡
  }
  
  // ็›‘ๅฌๆ–‡ไปถๅ˜ๅŒ–
  watchChanges(callback: (event: FileEvent) => void): void {
    // ไฝฟ็”จchokidar็›‘ๅฌ
    // ้˜ฒๆŠ–ๅค„็†
  }
}

2. Voxelization Engine๏ผˆไฝ“็ด ๅŒ–ๅผ•ๆ“Ž๏ผ‰

// packages/core/src/voxelization/engine.ts

interface SemanticVoxel {
  id: string;
  position: { x: number; y: number; z: number };
  nodeType: ASTNodeType;
  semanticRole: SemanticRole;
  dataType?: string;
  scopeLevel: number;
  parent?: VoxelRef;
  children: VoxelRef[];
  references: VoxelRef[];
  sourceLocation: SourceLocation;
  codeSnippet: string;
  visual: VisualProperties;
}

class VoxelizationEngine {
  constructor(
    private parser: TreeSitterAdapter,
    private lspAdapter: LSPAdapter
  ) {}
  
  // ๅฐ†AST่ฝฌๆขไธบ่ฏญไน‰ไฝ“็ด 
  async voxelize(ast: ASTNode[]): Promise<SemanticVoxel[]> {
    // ้ๅކAST่Š‚็‚น
    // ไธบๆฏไธช่Š‚็‚นๅˆ›ๅปบไฝ“็ด 
    // ่ฎก็ฎ—็ฉบ้—ดๅๆ ‡
  }
  
  // ๆž„ๅปบๅ…ซๅ‰ๆ ‘็ดขๅผ•
  buildOctree(voxels: SemanticVoxel[]): OctreeIndex {
    // ไฝฟ็”จ็จ€็–ๅ…ซๅ‰ๆ ‘
    // ๆ”ฏๆŒๅฟซ้€Ÿ็ฉบ้—ดๆŸฅ่ฏข
  }
  
  // ๅปบ็ซ‹ๅ…ณ็ณปๅ›พ่ฐฑ
  buildRelationGraph(voxels: SemanticVoxel[]): RelationGraph {
    // ่ฐƒ็”จๅ…ณ็ณป
    // ๆ•ฐๆฎๆตๅ…ณ็ณป
    // ็ปงๆ‰ฟๅ…ณ็ณป
  }
}

3. LOD Manager๏ผˆLOD็ฎก็†ๅ™จ๏ผ‰

// packages/core/src/lod/manager.ts

enum LODLevel {
  ARCHITECTURE = 5,   // ๆžถๆž„ๆ„ๅ›พ
  MODULE = 4,         // ๆจกๅ—ๅฅ‘็บฆ
  ALGORITHM = 3,      // ็ฎ—ๆณ•้€ป่พ‘
  IMPLEMENTATION = 2, // ๅฎž็Žฐ็ป†่Š‚
  SYNTAX = 1          // ่ฏญๆณ•็ป“ๆž„
}

interface LODProfile {
  level: LODLevel;
  includeProperties: string[];
  excludeProperties: string[];
  renderMode: 'voxel' | 'cluster' | 'graph';
}

class LODManager {
  // ้ข„่ฎก็ฎ—ๆฏไธชไฝ“็ด ็š„LOD็บงๅˆซ
  precomputeLODs(voxel: SemanticVoxel): Map<LODLevel, LODVoxel> {
    // LOD-5: ๅชไฟ็•™ๆŽฅๅฃๅฎšไน‰
    // LOD-4: ไฟ็•™ๅ‡ฝๆ•ฐ็ญพๅๅ’Œๅ…ณ้”ฎๆณจ้‡Š
    // LOD-3: ไฟ็•™ๆŽงๅˆถๆต็ป“ๆž„
    // LOD-2: ไฟ็•™ๅฎŒๆ•ดๅฎž็Žฐ
    // LOD-1: ไฟ็•™่ฏญๆณ•็ป†่Š‚
  }
  
  // ๆ นๆฎไธŠไธ‹ๆ–‡้€‰ๆ‹ฉLOD
  selectLOD(context: TaskContext): LODLevel {
    // taskType: navigation/debugging/refactoring
    // userExpertise: novice/intermediate/expert
    // timeConstraint: quick/normal/deep
  }
  
  // LODๅนณๆป‘่ฟ‡ๆธก
  async transitionLOD(
    from: LODLevel,
    to: LODLevel,
    focusVoxel?: VoxelRef
  ): Promise<TransitionResult> {
    // ๅŠจ็”ป่ฟ‡ๆธก
    // ไฟๆŒไธŠไธ‹ๆ–‡่ฟž็ปญๆ€ง
  }
}

4. Context Aggregator๏ผˆไธŠไธ‹ๆ–‡่šๅˆๅ™จ๏ผ‰

// packages/core/src/context/aggregator.ts

interface ContextSnapshot {
  codeContext: {
    voxels: SemanticVoxel[];
    relations: RelationEdge[];
    lod: LODLevel;
  };
  externalContext: {
    designDocs: DesignDoc[];
    envVars: EnvVar[];
    screenshots: Screenshot[];
  };
  meta: {
    projectName: string;
    language: string;
    totalFiles: number;
    totalVoxels: number;
    coverage: number;
    tokenUsage: TokenUsage;
  };
}

class ContextAggregator {
  constructor(
    private voxelEngine: VoxelizationEngine,
    private lodManager: LODManager,
    private queryEngine: QueryEngine
  ) {}
  
  // ๅˆ†ๆžไปปๅŠกๆ„ๅ›พ
  analyzeIntent(query: string): TaskIntent {
    // ๅ…ณ้”ฎ่ฏๆๅ–
    // ๅฎžไฝ“่ฏ†ๅˆซ
    // ไปปๅŠกๅˆ†็ฑป
  }
  
  // ็ป„่ฃ…ไธŠไธ‹ๆ–‡
  async buildContext(
    query: string,
    maxTokens: number
  ): Promise<ContextSnapshot> {
    // 1. ๅˆ†ๆžๆ„ๅ›พ
    // 2. ๆœ็ดข็›ธๅ…ณไฝ“็ด 
    // 3. ้€‰ๆ‹ฉLOD
    // 4. ๅŠ ่ฝฝๅค–้ƒจไธŠไธ‹ๆ–‡
    // 5. ็ฎก็†Token้ข„็ฎ—
  }
  
  // Token้ข„็ฎ—็ฎก็†
  manageTokenBudget(
    context: ContextSnapshot,
    maxTokens: number
  ): TrimmedContext {
    // ไผ˜ๅ…ˆ็บงๆŽ’ๅบ
    // ่ฃๅ‰ชไฝŽไผ˜ๅ…ˆ็บงๅ†…ๅฎน
    // ็กฎไฟๆ ธๅฟƒไธŠไธ‹ๆ–‡ไฟ็•™
  }
}

5. Query Engine๏ผˆๆŸฅ่ฏขๅผ•ๆ“Ž๏ผ‰

// packages/core/src/query/engine.ts

interface QueryOptions {
  keywords?: string[];
  semanticType?: string;
  lod?: LODLevel;
  boundingBox?: BoundingBox;
  limit?: number;
}

class QueryEngine {
  constructor(private octreeIndex: OctreeIndex) {}
  
  // ่ฏญไน‰ๆœ็ดข
  async semanticSearch(query: string): Promise<VoxelRef[]> {
    // ๅ‘้‡ๅŒ–ๆŸฅ่ฏข
    // ็›ธไผผๅบฆ่ฎก็ฎ—
    // ่ฟ”ๅ›ž็›ธๅ…ณไฝ“็ด 
  }
  
  // ็ฉบ้—ดๆŸฅ่ฏข
  async spatialQuery(
    center: Position,
    radius: number
  ): Promise<VoxelRef[]> {
    // ๅ…ซๅ‰ๆ ‘่Œƒๅ›ดๆŸฅ่ฏข
  }
  
  // ๅ…ณ็ณปๆŸฅ่ฏข
  async relationQuery(
    voxelId: string,
    relationType: RelationType
  ): Promise<VoxelRef[]> {
    // ่ฐƒ็”จๅ›พ้ๅކ
    // ๆ•ฐๆฎๆต่ฟฝ่ธช
  }
}

Package่ฎพ่ฎก

1. @semanticvoxelprotocol/core

package.json

{
  "name": "@semanticvoxelprotocol/core",
  "version": "0.1.0",
  "description": "SVPๆ ธๅฟƒๅผ•ๆ“Ž",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "scripts": {
    "build": "tsc",
    "test": "jest",
    "lint": "eslint src/**/*.ts"
  },
  "dependencies": {
    "@semanticvoxelprotocol/shared": "workspace:*",
    "tree-sitter": "^0.21.0",
    "chokidar": "^3.6.0",
    "yaml": "^2.4.0"
  },
  "devDependencies": {
    "typescript": "^5.4.0",
    "@types/node": "^20.11.0"
  }
}

็›ฎๅฝ•็ป“ๆž„

core/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts                    # ๅ…ฅๅฃ
โ”‚   โ”œโ”€โ”€ ingestion/
โ”‚   โ”‚   โ”œโ”€โ”€ engine.ts
โ”‚   โ”‚   โ”œโ”€โ”€ scanner.ts
โ”‚   โ”‚   โ””โ”€โ”€ watcher.ts
โ”‚   โ”œโ”€โ”€ voxelization/
โ”‚   โ”‚   โ”œโ”€โ”€ engine.ts
โ”‚   โ”‚   โ”œโ”€โ”€ coordinate.ts
โ”‚   โ”‚   โ””โ”€โ”€ properties.ts
โ”‚   โ”œโ”€โ”€ lod/
โ”‚   โ”‚   โ”œโ”€โ”€ manager.ts
โ”‚   โ”‚   โ”œโ”€โ”€ profiles.ts
โ”‚   โ”‚   โ””โ”€โ”€ transition.ts
โ”‚   โ”œโ”€โ”€ context/
โ”‚   โ”‚   โ”œโ”€โ”€ aggregator.ts
โ”‚   โ”‚   โ”œโ”€โ”€ intent.ts
โ”‚   โ”‚   โ””โ”€โ”€ budget.ts
โ”‚   โ”œโ”€โ”€ query/
โ”‚   โ”‚   โ”œโ”€โ”€ engine.ts
โ”‚   โ”‚   โ”œโ”€โ”€ semantic.ts
โ”‚   โ”‚   โ””โ”€โ”€ spatial.ts
โ”‚   โ”œโ”€โ”€ storage/
โ”‚   โ”‚   โ”œโ”€โ”€ octree.ts
โ”‚   โ”‚   โ”œโ”€โ”€ cache.ts
โ”‚   โ”‚   โ””โ”€โ”€ persistence.ts
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ logger.ts
โ”‚       โ””โ”€โ”€ errors.ts
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ *.test.ts
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ tsconfig.json

2. @semanticvoxelprotocol/sdk

package.json

{
  "name": "@semanticvoxelprotocol/sdk",
  "version": "0.1.0",
  "description": "SVP TypeScript SDK",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "scripts": {
    "build": "tsc",
    "test": "jest"
  },
  "dependencies": {
    "@semanticvoxelprotocol/core": "workspace:*",
    "@semanticvoxelprotocol/shared": "workspace:*",
    "axios": "^1.6.0",
    "ws": "^8.16.0"
  }
}

ๆ ธๅฟƒAPI

// packages/sdk/src/client.ts

export class SVPClient {
  constructor(options: SVPClientOptions) {
    // ๅˆๅง‹ๅŒ–่ฟžๆŽฅ
  }
  
  // ่Žทๅ–ไธŠไธ‹ๆ–‡ๅฟซ็…ง
  async getContext(query: string): Promise<ContextSnapshot> {
    // ่ฐƒ็”จๆ ธๅฟƒๅผ•ๆ“Ž
  }
  
  // ๆŸฅ่ฏขไฝ“็ด 
  async queryVoxels(options: QueryOptions): Promise<SemanticVoxel[]> {
    // ็ฉบ้—ด/่ฏญไน‰ๆŸฅ่ฏข
  }
  
  // ๅˆ‡ๆขLOD
  async switchLOD(level: LODLevel): Promise<void> {
    // LODๅˆ‡ๆข
  }
  
  // ็›‘ๅฌๅ˜ๅŒ–
  onChange(callback: (event: ChangeEvent) => void): void {
    // WebSocketๅฎžๆ—ถๅŒๆญฅ
  }
}

3. @semanticvoxelprotocol/mcp-server

package.json

{
  "name": "@semanticvoxelprotocol/mcp-server",
  "version": "0.1.0",
  "description": "SVP MCP Server",
  "bin": {
    "svp-mcp": "dist/server.js"
  },
  "scripts": {
    "build": "tsc",
    "start": "node dist/server.js"
  },
  "dependencies": {
    "@semanticvoxelprotocol/core": "workspace:*",
    "@modelcontextprotocol/sdk": "^0.5.0"
  }
}

MCP Serverๅฎž็Žฐ

// packages/mcp-server/src/server.ts

import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';

class SVP_MCPServer {
  private server: Server;
  private core: SVPCore;
  
  constructor() {
    this.server = new Server({
      name: 'svp-mcp-server',
      version: '0.1.0'
    }, {
      capabilities: {
        resources: {},
        tools: {}
      }
    });
    
    this.setupHandlers();
  }
  
  private setupHandlers() {
    // Resources: ๆšด้œฒไฝ“็ด ๅœฐๅ›พ
    this.server.setRequestHandler(ListResourcesRequestSchema, async () => {
      return {
        resources: [
          {
            uri: 'svp://project/voxels',
            name: 'Project Voxel Map',
            mimeType: 'application/vnd.svp.voxel+json'
          },
          {
            uri: 'svp://project/context',
            name: 'Current Context',
            mimeType: 'application/vnd.svp.context+json'
          }
        ]
      };
    });
    
    // Tools: ๆไพ›LODๅˆ‡ๆขใ€ๆŸฅ่ฏข็ญ‰ๅŠŸ่ƒฝ
    this.server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          {
            name: 'switch_lod',
            description: 'Switch to a different LOD level',
            inputSchema: {
              type: 'object',
              properties: {
                level: {
                  type: 'number',
                  enum: [1, 2, 3, 4, 5],
                  description: 'LOD level'
                }
              },
              required: ['level']
            }
          },
          {
            name: 'query_voxels',
            description: 'Query voxels by semantic criteria',
            inputSchema: {
              type: 'object',
              properties: {
                keywords: {
                  type: 'array',
                  items: { type: 'string' }
                },
                semanticType: { type: 'string' },
                lod: { type: 'number' }
              }
            }
          },
          {
            name: 'get_context',
            description: 'Get context snapshot for a query',
            inputSchema: {
              type: 'object',
              properties: {
                query: { type: 'string' },
                maxTokens: { type: 'number' }
              },
              required: ['query']
            }
          }
        ]
      };
    });
  }
  
  async run() {
    const transport = new StdioServerTransport();
    await this.server.connect(transport);
  }
}

// ๅฏๅŠจๆœๅŠกๅ™จ
const server = new SVP_MCPServer();
server.run();

4. @semanticvoxelprotocol/cli

package.json

{
  "name": "@semanticvoxelprotocol/cli",
  "version": "0.1.0",
  "description": "SVP CLIๅทฅๅ…ท",
  "bin": {
    "svp": "dist/cli.js"
  },
  "scripts": {
    "build": "tsc"
  },
  "dependencies": {
    "@semanticvoxelprotocol/core": "workspace:*",
    "commander": "^12.0.0",
    "chalk": "^5.3.0",
    "ora": "^8.0.0"
  }
}

CLIๅฎž็Žฐ

// packages/cli/src/cli.ts

import { Command } from 'commander';
import chalk from 'chalk';

const program = new Command();

program
  .name('svp')
  .description('Semantic Voxel Protocol CLI')
  .version('0.1.0');

// svp init
program
  .command('init')
  .description('Initialize SVP for current project')
  .option('-l, --language <lang>', 'Project language', 'typescript')
  .action(async (options) => {
    console.log(chalk.blue('Initializing SVP...'));
    // ๅˆ›ๅปบ.svp/็›ฎๅฝ•
    // ็”Ÿๆˆ้ป˜่ฎค้…็ฝฎ
    // ้ฆ–ๆฌกไฝ“็ด ๅŒ–
  });

// svp voxelize
program
  .command('voxelize')
  .description('Voxelize the codebase')
  .option('-w, --watch', 'Watch for changes')
  .action(async (options) => {
    console.log(chalk.blue('Voxelizing...'));
    // ๆ‰ซๆๆบ็ 
    // ็”Ÿๆˆไฝ“็ด 
    // ๆž„ๅปบ็ดขๅผ•
  });

// svp serve
program
  .command('serve')
  .description('Start SVP service')
  .option('-p, --port <port>', 'Port number', '8080')
  .action(async (options) => {
    console.log(chalk.blue(`Starting SVP service on port ${options.port}...`));
    // ๅฏๅŠจHTTP/gRPCๆœๅŠก
    // ๆ”ฏๆŒๅคšๅฎขๆˆท็ซฏ่ฟžๆŽฅ
  });

// svp query
program
  .command('query <query>')
  .description('Query the voxel space')
  .option('-l, --lod <level>', 'LOD level', '4')
  .action(async (query, options) => {
    // ๆ‰ง่กŒๆŸฅ่ฏข
    // ๆ˜พ็คบ็ป“ๆžœ
  });

program.parse();

ๅฎž็Žฐ็ป†่Š‚

1. ็ฑปๅž‹ๅฎšไน‰๏ผˆsharedๅŒ…๏ผ‰

// packages/shared/src/types.ts

// ๆ ธๅฟƒไฝ“็ด ็ฑปๅž‹
export interface SemanticVoxel {
  id: string;
  position: Vector3;
  nodeType: ASTNodeType;
  semanticRole: SemanticRole;
  dataType?: string;
  scopeLevel: number;
  parent?: VoxelRef;
  children: VoxelRef[];
  references: VoxelRef[];
  sourceLocation: SourceLocation;
  codeSnippet: string;
  visual: VisualProperties;
  lodProfiles: Map<LODLevel, LODVoxel>;
}

// LOD็บงๅˆซ
export enum LODLevel {
  SYNTAX = 1,
  IMPLEMENTATION = 2,
  ALGORITHM = 3,
  MODULE = 4,
  ARCHITECTURE = 5
}

// ไธŠไธ‹ๆ–‡ๅฟซ็…ง
export interface ContextSnapshot {
  codeContext: {
    voxels: SemanticVoxel[];
    relations: RelationEdge[];
    lod: LODLevel;
  };
  externalContext: {
    designDocs: DesignDoc[];
    envVars: EnvVar[];
    screenshots: Screenshot[];
  };
  meta: ContextMeta;
}

// ๆŸฅ่ฏข้€‰้กน
export interface QueryOptions {
  keywords?: string[];
  semanticType?: ASTNodeType;
  lod?: LODLevel;
  boundingBox?: BoundingBox;
  limit?: number;
}

// ไปปๅŠกไธŠไธ‹ๆ–‡
export interface TaskContext {
  taskType: TaskType;
  userExpertise: UserExpertise;
  timeConstraint: TimeConstraint;
  focusArea?: VoxelRef[];
  history: NavigationPath[];
}

2. ๅ…ซๅ‰ๆ ‘ๅฎž็Žฐ

// packages/core/src/storage/octree.ts

export class OctreeNode {
  voxels: SemanticVoxel[] = [];
  children: OctreeNode[] | null = null;
  
  constructor(
    public bounds: BoundingBox,
    public depth: number,
    public maxDepth: number = 8
  ) {}
  
  insert(voxel: SemanticVoxel): void {
    if (this.depth === this.maxDepth) {
      this.voxels.push(voxel);
      return;
    }
    
    if (!this.children) {
      this.subdivide();
    }
    
    const childIndex = this.getChildIndex(voxel.position);
    this.children![childIndex].insert(voxel);
  }
  
  queryRange(range: BoundingBox): SemanticVoxel[] {
    if (!this.intersects(range)) {
      return [];
    }
    
    let results = this.voxels.filter(v => range.contains(v.position));
    
    if (this.children) {
      for (const child of this.children) {
        results = results.concat(child.queryRange(range));
      }
    }
    
    return results;
  }
  
  private subdivide(): void {
    // ๅˆ›ๅปบ8ไธชๅญ่Š‚็‚น
  }
  
  private getChildIndex(position: Vector3): number {
    // ่ฎก็ฎ—ๅญ่Š‚็‚น็ดขๅผ•
  }
  
  private intersects(range: BoundingBox): boolean {
    // AABB็›ธไบคๆต‹่ฏ•
  }
}

ไฝฟ็”จๆต็จ‹

ๅฎ‰่ฃ…

# ๅ…จๅฑ€ๅฎ‰่ฃ…CLI
npm install -g @semanticvoxelprotocol/cli

# ๆˆ–่€…ๆœฌๅœฐๅฎ‰่ฃ…
npm install --save-dev @semanticvoxelprotocol/cli

# ๅฎ‰่ฃ…SDK๏ผˆ็”จไบŽ็จ‹ๅบๅŒ–่ฎฟ้—ฎ๏ผ‰
npm install @semanticvoxelprotocol/sdk

ๅˆๅง‹ๅŒ–้กน็›ฎ

# ่ฟ›ๅ…ฅ้กน็›ฎ็›ฎๅฝ•
cd my-project

# ๅˆๅง‹ๅŒ–SVP
svp init

# ไบคไบ’ๅผ้…็ฝฎ
# ? Project language: TypeScript
# ? Include git history: Yes
# ? LOD default level: 4 (Module Contract)
# ? Token budget: 8000

# ็”Ÿๆˆ้…็ฝฎๆ–‡ไปถ
# .svp/config.yaml

้…็ฝฎๆ–‡ไปถ็คบไพ‹

# .svp/config.yaml
project:
  name: "my-project"
  language: "typescript"
  description: "A task management application"

source:
  root: "./src"
  include:
    - "src/**/*"
    - "lib/**/*"
  exclude:
    - "node_modules"
    - "dist"
    - "**/*.test.ts"
    - "**/*.spec.ts"
  git:
    enabled: true
    maxHistoryDepth: 100

context:
  designDocs:
    - path: "docs/architecture.md"
      description: "System architecture"
    - path: "docs/api-design.md"
      description: "API design document"
  
  envVars:
    - path: ".env.example"
      description: "Environment template"
  
  screenshots:
    - path: "assets/architecture.png"
      description: "Architecture diagram"
      relatedTo: ["src/core", "src/api"]

lod:
  defaultLevel: 4
  overrides:
    - path: "src/core/**"
      level: 2
    - path: "src/utils/**"
      level: 5

exposure:
  virtualFolders:
    "/core":
      physicalPaths: ["src/core/**"]
      description: "Core business logic"
    "/api":
      physicalPaths: ["src/api/**"]
      description: "API endpoints"
  
  restrictedPaths:
    - "src/secrets/**"
    - ".env.production"
  
  tokenBudget:
    default: 8000
    max: 32000

sync:
  reverseSync:
    enabled: true
    highlightActiveVoxels: true
    showArchitectureUpdates: true
  
  realtime:
    enabled: true
    debounceMs: 500

ๅฏๅŠจๆœๅŠก

# ๅฏๅŠจๆœฌๅœฐๆœๅŠก
svp serve

# ้€‰้กน
svp serve --port 8080 --watch

# ่พ“ๅ‡บ
# โœ“ Loaded configuration from .svp/config.yaml
# โœ“ Indexed 1,247 files
# โœ“ Generated 45,832 voxels
# โœ“ Built octree index (depth: 8)
# โœ“ SVP service running on http://localhost:8080

ไฝฟ็”จSDK

import { SVPClient } from '@semanticvoxelprotocol/sdk';

const client = new SVPClient({
  endpoint: 'http://localhost:8080',
  project: 'my-project'
});

// ่Žทๅ–ไธŠไธ‹ๆ–‡
const context = await client.getContext({
  query: 'ๅฎž็Žฐ็”จๆˆท็™ปๅฝ•ๅŠŸ่ƒฝ',
  maxTokens: 8000
});

console.log(context.codeContext.voxels);
console.log(context.externalContext.designDocs);

// ๆŸฅ่ฏขไฝ“็ด 
const voxels = await client.queryVoxels({
  keywords: ['auth', 'login'],
  semanticType: 'function',
  lod: 4
});

// ๅˆ‡ๆขLOD
await client.switchLOD(LODLevel.IMPLEMENTATION);

// ็›‘ๅฌๅ˜ๅŒ–
client.onChange((event) => {
  console.log('Code changed:', event.file);
  console.log('Affected voxels:', event.voxels);
});

MCP้›†ๆˆ

// claude_desktop_config.json
{
  "mcpServers": {
    "semantic-voxel": {
      "command": "npx",
      "args": ["-y", "@semanticvoxelprotocol/mcp-server"],
      "env": {
        "SVP_PROJECT_PATH": "/path/to/your/project"
      }
    }
  }
}

็ŽฐๅœจClaudeๅฏไปฅ๏ผš

  • ่‡ชๅŠจ่Žทๅ–้กน็›ฎไธŠไธ‹ๆ–‡
  • ๅฏผ่ˆช่ฏญไน‰ไฝ“็ด ็ฉบ้—ด
  • ๅŠจๆ€ๅˆ‡ๆขLOD็บงๅˆซ

MCP็”Ÿๆ€้›†ๆˆ

็”Ÿๆ€็ณป็ปŸๅฎšไฝ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    AI็ผ–็จ‹ๅ่ฎฎ็”Ÿๆ€                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  A2A (Agent-to-Agent)                                       โ”‚
โ”‚  - Agent้—ดๅไฝœ้€šไฟก                                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  MCP (Model Context Protocol)                               โ”‚
โ”‚  - ๅทฅๅ…ท่ฐƒ็”จใ€่ต„ๆบ่ฎฟ้—ฎ                                        โ”‚
โ”‚  - SVPไฝœไธบMCP Serverๆšด้œฒไฝ“็ด ๆœๅŠก                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ˜… SVP (Semantic Voxel Protocol)                           โ”‚
โ”‚  โ˜… ไปฃ็ ่ฏญไน‰่กจ็คบใ€LOD็ฎก็†                                    โ”‚
โ”‚  โ˜… ๅ…ฑไบซ่ฎค็Ÿฅ็ฉบ้—ด                                             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  LSP (Language Server Protocol)                             โ”‚
โ”‚  - ่ฏญๆณ•ๅˆ†ๆžใ€็ฌฆๅท่งฃๆž                                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

SVP MCP Server่ƒฝๅŠ›

// Resources๏ผˆ่ต„ๆบ๏ผ‰
{
  'svp://{project}/voxels': 'ไฝ“็ด ๅœฐๅ›พ',
  'svp://{project}/context': 'ๅฝ“ๅ‰ไธŠไธ‹ๆ–‡',
  'svp://{project}/architecture': 'ๆžถๆž„่ง†ๅ›พ',
  'svp://{project}/relations': 'ๅ…ณ็ณปๅ›พ่ฐฑ'
}

// Tools๏ผˆๅทฅๅ…ท๏ผ‰
{
  'switch_lod': 'ๅˆ‡ๆขLOD็บงๅˆซ',
  'query_voxels': 'ๆŸฅ่ฏขไฝ“็ด ',
  'get_context': '่Žทๅ–ไธŠไธ‹ๆ–‡ๅฟซ็…ง',
  'navigate_relation': 'ๅฏผ่ˆชๅ…ณ็ณปๅ›พ่ฐฑ',
  'highlight_voxel': '้ซ˜ไบฎไฝ“็ด '
}

// Prompts๏ผˆๆ็คบๆจกๆฟ๏ผ‰
{
  'code_review': 'ไปฃ็ ๅฎกๆŸฅๆจกๆฟ',
  'refactoring': '้‡ๆž„ๅปบ่ฎฎๆจกๆฟ',
  'architecture_review': 'ๆžถๆž„ๅฎกๆŸฅๆจกๆฟ'
}

ไธŽๅ…ถไป–MCP Serverๅไฝœ

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      MCP็”Ÿๆ€็ณป็ปŸ                             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                             โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚   โ”‚  Filesystem โ”‚      โ”‚    GitHub   โ”‚      โ”‚  Database  โ”‚ โ”‚
โ”‚   โ”‚   Server    โ”‚      โ”‚   Server    โ”‚      โ”‚   Server   โ”‚ โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚          โ”‚                    โ”‚                   โ”‚        โ”‚
โ”‚          โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ”‚                               โ”‚                            โ”‚
โ”‚                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                   โ”‚
โ”‚                      โ”‚   MCP Host      โ”‚                   โ”‚
โ”‚                      โ”‚ (Claude/Cursor) โ”‚                   โ”‚
โ”‚                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚
โ”‚                               โ”‚                            โ”‚
โ”‚                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                   โ”‚
โ”‚                      โ”‚   SVP Server    โ”‚                   โ”‚
โ”‚                      โ”‚  (ไปฃ็ ่ฏญไน‰ๆœๅŠก)  โ”‚                   โ”‚
โ”‚                      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                   โ”‚
โ”‚                                                             โ”‚
โ”‚   Claude: "ๆˆ‘้œ€่ฆไฟฎๆ”น็”จๆˆท่ฎค่ฏๆจกๅ—"                          โ”‚
โ”‚   โ†“                                                         โ”‚
โ”‚   SVP Server: ๆไพ›็›ธๅ…ณไฝ“็ด ๏ผˆLOD-4ๆจกๅ—่ง†ๅ›พ๏ผ‰                  โ”‚
โ”‚   โ†“                                                         โ”‚
โ”‚   Filesystem Server: ่ฏปๅ–/ๅ†™ๅ…ฅๆ–‡ไปถ                          โ”‚
โ”‚   โ†“                                                         โ”‚
โ”‚   GitHub Server: ๅˆ›ๅปบPR                                     โ”‚
โ”‚                                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Adapter่ฎพ่ฎก

1. LSP Adapter

// packages/adapters/lsp-adapter/src/index.ts

export class LSPAdapter {
  private connection: Connection;
  
  constructor(private serverPath: string) {}
  
  async initialize(): Promise<void> {
    // ๅฏๅŠจLSPๆœๅŠกๅ™จ
    // ๅปบ็ซ‹่ฟžๆŽฅ
  }
  
  // ่Žทๅ–็ฌฆๅทไฟกๆฏ
  async getSymbols(filePath: string): Promise<SymbolInformation[]> {
    const response = await this.connection.sendRequest(
      'textDocument/documentSymbol',
      { textDocument: { uri: filePath } }
    );
    return response;
  }
  
  // ่Žทๅ–็ฑปๅž‹ๅฎšไน‰
  async getTypeDefinition(
    filePath: string,
    position: Position
  ): Promise<Location[]> {
    const response = await this.connection.sendRequest(
      'textDocument/typeDefinition',
      {
        textDocument: { uri: filePath },
        position
      }
    );
    return response;
  }
  
  // ่Žทๅ–ๅผ•็”จ
  async getReferences(
    filePath: string,
    position: Position
  ): Promise<Location[]> {
    const response = await this.connection.sendRequest(
      'textDocument/references',
      {
        textDocument: { uri: filePath },
        position,
        context: { includeDeclaration: true }
      }
    );
    return response;
  }
}

2. Git Adapter

// packages/adapters/git-adapter/src/index.ts

export class GitAdapter {
  constructor(private repoPath: string) {}
  
  // ่Žทๅ–ๆ–‡ไปถๅކๅฒ
  async getFileHistory(filePath: string): Promise<Commit[]> {
    const result = await execAsync(
      `git log --follow --format="%H|%an|%ad|%s" -- "${filePath}"`,
      { cwd: this.repoPath }
    );
    return this.parseLog(result.stdout);
  }
  
  // ่Žทๅ–ๅ˜ๆ›ด่ฎฐๅฝ•
  async getChanges(filePath: string): Promise<Change[]> {
    const result = await execAsync(
      `git log -p -- "${filePath}"`,
      { cwd: this.repoPath }
    );
    return this.parseDiff(result.stdout);
  }
  
  // ่Žทๅ–ไฝœ่€…ไฟกๆฏ
  async getAuthors(filePath: string): Promise<Author[]> {
    const result = await execAsync(
      `git log --format="%an" -- "${filePath}" | sort | uniq -c | sort -rn`,
      { cwd: this.repoPath }
    );
    return this.parseAuthors(result.stdout);
  }
}

3. Tree-sitter Adapter

// packages/adapters/tree-sitter-adapter/src/index.ts

import Parser from 'tree-sitter';
import TypeScript from 'tree-sitter-typescript';

export class TreeSitterAdapter {
  private parser: Parser;
  private languageMap: Map<string, Parser.Language>;
  
  constructor() {
    this.parser = new Parser();
    this.languageMap = new Map([
      ['typescript', TypeScript.typescript],
      ['tsx', TypeScript.tsx],
      ['javascript', TypeScript.javascript]
    ]);
  }
  
  parse(code: string, language: string): Parser.Tree {
    const lang = this.languageMap.get(language);
    if (!lang) {
      throw new Error(`Unsupported language: ${language}`);
    }
    this.parser.setLanguage(lang);
    return this.parser.parse(code);
  }
  
  // ๆๅ–ๅ‡ฝๆ•ฐๅฎšไน‰
  extractFunctions(tree: Parser.Tree): FunctionNode[] {
    const query = new Parser.Query(
      this.parser.getLanguage(),
      `
      (function_declaration
        name: (identifier) @name
        parameters: (formal_parameters) @params
        body: (statement_block) @body) @function
      
      (arrow_function
        parameters: (formal_parameters) @params
        body: (_) @body) @function
      `
    );
    
    const matches = query.matches(tree.rootNode);
    return matches.map(match => this.parseFunctionNode(match));
  }
  
  // ๆๅ–็ฑปๅฎšไน‰
  extractClasses(tree: Parser.Tree): ClassNode[] {
    // ็ฑปไผผๅฎž็Žฐ
  }
}

ๅผ€ๅ‘่ทฏ็บฟๅ›พ

Phase 1: Foundation (Month 1-2)

  • ้กน็›ฎ่„šๆ‰‹ๆžถๆญๅปบ
  • CoreๅŒ…ๅŸบ็ก€ๅฎž็Žฐ
    • Ingestion Engine
    • Voxelization Engine
    • LOD Manager
    • Context Aggregator
  • SharedๅŒ…็ฑปๅž‹ๅฎšไน‰
  • CLIๅŸบ็ก€ๅ‘ฝไปค
  • SDKๅŸบ็ก€API
  • ๅ•ๅ…ƒๆต‹่ฏ•่ฆ†็›–

Phase 2: Integration (Month 3-4)

  • MCP Serverๅฎž็Žฐ
  • LSP Adapter
  • Git Adapter
  • Tree-sitter Adapter
  • VS Code Extension MVP
  • ๆ–‡ๆกฃ็ฝ‘็ซ™

Phase 3: Ecosystem (Month 5-6)

  • ๅคš่ฏญ่จ€ๆ”ฏๆŒ๏ผˆPython, Go, Rust๏ผ‰
  • JetBrains Plugin
  • Web UI
  • ๆ€ง่ƒฝไผ˜ๅŒ–
  • ็คพๅŒบ็คบไพ‹

Phase 4: Standardization (Month 7+)

  • ๅ่ฎฎ่ง„่ŒƒๅฎŒๅ–„
  • W3C/Linux Foundationๆไบค
  • ไผไธš็บงๅŠŸ่ƒฝ
  • Cloud Service

้™„ๅฝ•

A. ๆŠ€ๆœฏๆ ˆ

ๅฑ‚็บง ๆŠ€ๆœฏ
่ฏญ่จ€ TypeScript 5.4+
่ฟ่กŒๆ—ถ Node.js 20+
ๆž„ๅปบ tsc + esbuild
ๆต‹่ฏ• Jest
ๅŒ…็ฎก็† pnpm workspaces
ไปฃ็ ่ดจ้‡ ESLint + Prettier

B. ็›ฎๅฝ•็ป“ๆž„่ง„่Œƒ

packages/{name}/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ index.ts          # ๅ…ฅๅฃๆ–‡ไปถ
โ”‚   โ”œโ”€โ”€ {feature}/        # ๅŠŸ่ƒฝๆจกๅ—
โ”‚   โ”‚   โ”œโ”€โ”€ index.ts
โ”‚   โ”‚   โ””โ”€โ”€ *.ts
โ”‚   โ””โ”€โ”€ utils/            # ๅทฅๅ…ทๅ‡ฝๆ•ฐ
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ *.test.ts
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ””โ”€โ”€ README.md

C. ๅ‘ฝๅ่ง„่Œƒ

  • Package: @semanticvoxelprotocol/{name}
  • Class: PascalCase
  • Interface: PascalCase
  • Function: camelCase
  • Constant: UPPER_SNAKE_CASE
  • Type: PascalCase

D. ็‰ˆๆœฌ็ญ–็•ฅ

  • ้ตๅพชSemVer
  • Alpha: 0.x.x-alpha.x
  • Beta: 0.x.x-beta.x
  • RC: 0.x.x-rc.x
  • Stable: 1.x.x