SPARC 框架是一套全面的方法,旨在指导可靠、可扩展应用程序的开发。SPARC 的全称是 Specification, Pseudo Code, Architecture, and Reuse (规范、伪代码、架构和重用)。
SPARC 框架是一套全面的方法,旨在指导可靠、可扩展应用程序的开发。SPARC 的全称是 Specification, Pseudo Code, Architecture, and Reuse (规范、伪代码、架构和重用)。
SPARC 2.0, agentic code analysis and generation, is an intelligent coding agent framework built to automate and streamline software development. It combines secure execution environments, version control, and Model Context Protocol (MCP) capabilities into a unified system where specialized agents collaborate to understand, modify, and manage code.
These agents analyze patterns, suggest improvements, implement changes, and validate solutions, all while maintaining a detailed history that allows for easy rollbacks when needed.
npm install -g @agentics.org/sparc2
By bridging the gap between human developers and AI assistants, SPARC 2.0 enhances productivity across the entire development lifecycle, from initial code review to final deployment.
A defining feature of SPARC is its ability to track code changes over time, functioning like a perfect memory of your code's evolution. It uses a unified diff system to capture precisely what changed between versions rather than storing entire files, dramatically reducing storage needs and speeding up operations. By default, the system tracks changes at the file level for optimal performance, yet it can zoom in to function-level tracking when more granular detail is required. This efficient diff tracking ensures smooth performance whether you are working on a small project or a massive enterprise codebase.
Essentially, SPARC acts as an advanced version control enhancer that integrates with Git and GitHub while leveraging artificial intelligence to manage updates automatically. Its understanding of temporal relationships between code modifications allows it to orchestrate complex workflows that support simultaneous contributions from both human developers and AI agents. SPARC adapts its processing pace to match developers' speed, ensuring seamless, conflict-free collaboration.
At the heart of SPARC lies its vector store, a specialized database that transforms code and text into abstract patterns. Instead of merely memorizing exact words, it captures the underlying meaning of the code, similar to understanding cooking techniques rather than just listing ingredients. This approach enables the system to locate similar code snippets despite differences in variable names or styles, creating a smart library of your development history.
Another key element is its integrated code interpreter built using E2B—a language-agnostic execution environment that builds, runs, and modifies code without relying on a traditional IDE. It creates secure, isolated sandboxes for execution across languages such as Python, JavaScript, TypeScript, Go, Rust, and more.
SPARC 2.0 employs a ReACT (Reason + Act) strategy to semantically understand code. It first reasons about what the code means and then takes appropriate actions. This combination of efficient diff tracking and intelligent reasoning enables rapid processing of large codebases without sacrificing deep comprehension of the code's purpose and structure.
At its core, SPARC 2.0 uses advanced diff tracking to compare previous and updated versions of code:
SPARC 2.0 supports multiple processing modes:
SPARC 2.0 is ideal for:
# Install globally
npm install -g @agentics.org/sparc2
# Or install locally in your project
npm install --save-dev @agentics.org/sparc2# Clone the repository
git clone https://github.com/agentics-org/sparc2.git
cd sparc2
# Install dependencies
deno cache --reload src/cli/cli.tsA comprehensive command-line interface for the SPARC2 project that integrates the E2B code interpreter and agent framework implementations.
If you installed via npm:
# The CLI is available as the 'sparc2' command
sparc2 --help
# You can also use the 'sparc' command for direct execution
sparc --helpIf you cloned the repository:
# Create an alias for easier use
alias sparc2="deno run --allow-read --allow-write --allow-env --allow-net --allow-run /path/to/sparc2/src/cli/cli.ts"
# Or use the provided script
./sparc --helpSPARC2 CLI provides the following commands:
SPARC2 uses TOML configuration files:
config/sparc2-config.toml: General configurationconfig/agent-config.toml: Agent-specific configurationYou can also set the configuration path using the environment variable:
export SPARC2_CONFIG_PATH=/path/to/your/config.tomlCreate a .env file in your project root (you can copy from .env.example) or set these environment variables:
# Required
- `OPENAI_API_KEY`: Your OpenAI API key
- `E2B_API_KEY`: Your E2B API key
# Optional
- `OPENROUTER_API_KEY`: Your OpenRouter API key (optional)
- `SPARC2_CONFIG_PATH`: Custom path to your config file
- `NPM_TOKEN`: Your NPM token (only needed when publishing to npm)
- `MCP_SECRET_KEY`: Secret key for MCP server authenticationSPARC2 includes a Model Context Protocol (MCP) server that allows AI agents to interact with your codebase. The MCP server provides a standardized interface for tools and resources discovery, enabling seamless integration with AI assistants.
SPARC2 provides two different ways to use the Model Context Protocol (MCP):
The api command starts an HTTP server that implements the MCP protocol over HTTP:
# Using the sparc command
./sparc api --port 3001
# Or with npm installation
sparc2 api --port 3001Options:
--port, -p: Port to run the API server on (default: 3001)--model: Model to use for the agent--mode: Execution mode (automatic, semi, manual, custom, interactive)--diff-mode: Diff mode (file, function)--processing: Processing mode (sequential, parallel, concurrent, swarm)--config, -c: Path to the agent configuration fileThis is useful for integrations that communicate with SPARC2 over HTTP.
The mcp command starts a server that implements the MCP protocol over standard input/output (stdio):
# Using the sparc command
./sparc mcp
# Or with npm installation
sparc2 mcpOptions:
--model: Model to use for the agent--mode: Execution mode (automatic, semi, manual, custom, interactive)--diff-mode: Diff mode (file, function)--processing: Processing mode (sequential, parallel, concurrent, swarm)--config, -c: Path to the agent configuration fileThis is useful for integrations with tools like VS Code extensions that communicate with SPARC2 over stdio.
To use SPARC2 with VS Code extensions that support the Model Context Protocol (MCP), you'll need to configure the extension's settings. Here's an example configuration for the Claude extension:
…The MCP server wrapper automatically detects the Deno executable in various common installation locations, making it portable across different systems.
The MCP server exposes the following endpoints:
The SPARC2 MCP server provides the following tools:
Analyzes
暂无开放 Issues,或尚未同步最近议题。