How spyglassmc/spyglass works
• Core Engine: Represent the “core” package that includes the primary logic for parsing, processing, and transforming data (e.g., classes found in packages/core for nodes, parsers, processors, services, and symbol handling). This is the heart of the tool that performs language analysis.
• Language Server: Include the “language-server” package. This component acts as a bridge between the core engine and the VS Code (or other editors) using the Language Server Protocol (LSP). It translates editor events into commands that the core package processes.
• VS Code Extension: Add the “vscode-extension” package, which integrates Spyglass within the VS Code environment. Although it uses CommonJS modules (with the necessary file extension overrides), its main role is to present the IntelliSense features to end users and communicate with the language server.
• Additional Utilities and Tools: Optionally, include packages like “discord-bot”, “web-api-server”, “locales”, and “playground”. Although these may not be central to the IntelliSense experience, they provide external services (e.g., bot interactions, API services, localization, and demo environments) and are part of the overall ecosystem.
• Deployment and Build Infrastructure: Represent the “ansible” directory and various scripts. This shows how deployment, CI/CD (with GitHub workflows), testing, and building are orchestrated for all components.
• Developer Tools and Testing: While not part of the runtime architecture per se, tools for linting, testing (with Mocha and snapshot tests), and build pipeline management should be noted as external utilities that ensure the reliability of the project.
Relationships and data flows
• For language-specific features, link the core engine to the various domain packages (e.g., java-edition, mcfunction, nbt, mcdoc) to reflect that the core delegates certain tasks (parsing, binding, formatting, linting) to these specialized modules.
• Utilities and deployment scripts in a separate section linked to the overall monorepo by showing how they influence build and deployment processes (CI/CD workflows, Ansible roles for deployment).
Design principles and technologies
• Modular monorepo design: Many packages grouped under “packages” share a common toolchain (TypeScript, ESLint, Prettier) and are built altogether using npm scripts.
• Use of ES modules across the board, with an explicit override for the vscode-extension package (using CommonJS where necessary due to VS Code limitations).
• Separation of concerns – the language analysis and processing core is separate from the UI integration (VS Code extension) and the server part (language server), which helps maintain a clear modular architecture.