specsoloist 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. specsoloist-0.2.0/.claude/settings.local.json +26 -0
  2. specsoloist-0.2.0/.github/workflows/ci.yaml +29 -0
  3. specsoloist-0.2.0/.github/workflows/docs.yaml +36 -0
  4. specsoloist-0.2.0/.gitignore +45 -0
  5. specsoloist-0.2.0/AGENTS.md +44 -0
  6. specsoloist-0.2.0/CLAUDE.md +56 -0
  7. specsoloist-0.2.0/LICENSE +21 -0
  8. specsoloist-0.2.0/PKG-INFO +143 -0
  9. specsoloist-0.2.0/README.md +113 -0
  10. specsoloist-0.2.0/ROADMAP.md +44 -0
  11. specsoloist-0.2.0/demo.py +110 -0
  12. specsoloist-0.2.0/docs/concepts/self_healing.md +10 -0
  13. specsoloist-0.2.0/docs/concepts/spec_as_source.md +22 -0
  14. specsoloist-0.2.0/docs/examples/math_demo.md +10 -0
  15. specsoloist-0.2.0/docs/examples/ml_demo.md +20 -0
  16. specsoloist-0.2.0/docs/examples/ts_demo.md +10 -0
  17. specsoloist-0.2.0/docs/getting_started.md +44 -0
  18. specsoloist-0.2.0/docs/guide/workflow.md +56 -0
  19. specsoloist-0.2.0/docs/index.md +17 -0
  20. specsoloist-0.2.0/docs/reference/cli.md +20 -0
  21. specsoloist-0.2.0/docs/reference/template.md +26 -0
  22. specsoloist-0.2.0/examples/ml_demo/README.md +35 -0
  23. specsoloist-0.2.0/examples/ml_demo/requirements.txt +2 -0
  24. specsoloist-0.2.0/examples/ml_demo/src/data.spec.md +44 -0
  25. specsoloist-0.2.0/examples/ml_demo/src/model.spec.md +44 -0
  26. specsoloist-0.2.0/examples/ml_demo/train.py +64 -0
  27. specsoloist-0.2.0/examples/ts_demo/src/ts_demo.spec.md +43 -0
  28. specsoloist-0.2.0/examples/user_project/README.md +46 -0
  29. specsoloist-0.2.0/examples/user_project/src/types.spec.md +59 -0
  30. specsoloist-0.2.0/examples/user_project/src/user_service.spec.md +64 -0
  31. specsoloist-0.2.0/examples/user_project/src/validation.spec.md +76 -0
  32. specsoloist-0.2.0/mkdocs.yml +54 -0
  33. specsoloist-0.2.0/pyproject.toml +50 -0
  34. specsoloist-0.2.0/self_hosting/specular_core.spec.md +309 -0
  35. specsoloist-0.2.0/src/math_demo.spec.md +46 -0
  36. specsoloist-0.2.0/src/specsoloist/__init__.py +15 -0
  37. specsoloist-0.2.0/src/specsoloist/cli.py +301 -0
  38. specsoloist-0.2.0/src/specsoloist/compiler.py +261 -0
  39. specsoloist-0.2.0/src/specsoloist/config.py +129 -0
  40. specsoloist-0.2.0/src/specsoloist/core.py +562 -0
  41. specsoloist-0.2.0/src/specsoloist/manifest.py +199 -0
  42. specsoloist-0.2.0/src/specsoloist/parser.py +281 -0
  43. specsoloist-0.2.0/src/specsoloist/providers/__init__.py +9 -0
  44. specsoloist-0.2.0/src/specsoloist/providers/anthropic.py +113 -0
  45. specsoloist-0.2.0/src/specsoloist/providers/base.py +37 -0
  46. specsoloist-0.2.0/src/specsoloist/providers/gemini.py +94 -0
  47. specsoloist-0.2.0/src/specsoloist/resolver.py +304 -0
  48. specsoloist-0.2.0/src/specsoloist/runner.py +151 -0
  49. specsoloist-0.2.0/src/specsoloist/server.py +88 -0
  50. specsoloist-0.2.0/src/specsoloist/templates/__init__.py +1 -0
  51. specsoloist-0.2.0/src/specsoloist/templates/global_context.md +16 -0
  52. specsoloist-0.2.0/src/specsoloist/templates/spec_template.md +43 -0
  53. specsoloist-0.2.0/src/specsoloist/ui.py +70 -0
  54. specsoloist-0.2.0/tests/test_core.py +137 -0
  55. specsoloist-0.2.0/tests/test_manifest.py +194 -0
  56. specsoloist-0.2.0/tests/test_parser.py +72 -0
  57. specsoloist-0.2.0/tests/test_resolver.py +237 -0
  58. specsoloist-0.2.0/uv.lock +1432 -0
@@ -0,0 +1,26 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(git -C /home/toby/_code/specular log --oneline -15)",
5
+ "Bash(uv run pytest:*)",
6
+ "Bash(uv run ruff:*)",
7
+ "Bash(git -C /home/toby/_code/specular status)",
8
+ "Bash(git -C /home/toby/_code/specular log --oneline -5)",
9
+ "Bash(git -C /home/toby/_code/specular add -A)",
10
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\nrefactor: extract modules and add LLM provider abstraction \\(Phase 1.5\\)\n\n- Extract parser.py: spec parsing, validation, frontmatter handling\n- Extract runner.py: test execution and build file management\n- Extract compiler.py: prompt construction and LLM code generation\n- Extract config.py: SpecularConfig with env-based loading\n- Add providers/: LLMProvider protocol with Gemini and Anthropic implementations\n- Refactor SpecularCore as thin orchestrator delegating to modules\n- Update tests to use mock provider injection pattern\n\nThis lays the foundation for Phase 2''s multi-spec architecture.\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
11
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\ndocs: update specs and roadmap for Phase 1.5 completion\n\n- Update self_hosting/specular_core.spec.md \\(The Quine\\) to reflect\n modular architecture with all new components documented\n- Update README with multi-provider support and configuration examples\n- Update ROADMAP: add Phase 1.5 as completed, split Phase 2 into 2a/2b\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
12
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\nrefactor: clean up technical debt before Phase 2a\n\n- Move create_spec and template loading to SpecParser \\(fixes internal access smell\\)\n- Use pyyaml for proper frontmatter parsing \\(prepares for dependency syntax\\)\n- Add model override to LLMProvider.generate\\(\\) \\(makes model param actually work\\)\n- Make get_spec_path public \\(was _get_spec_path\\)\n- Add load_global_context to SpecParser\n- Make max_tokens configurable in AnthropicProvider\n- Update tests for new provider interface\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
13
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\nfeat: implement Phase 2a multi-spec architecture\n\n- Add dependency syntax in frontmatter \\(YAML list of name/from pairs\\)\n- Create DependencyResolver with topological sort for build order\n- Add CircularDependencyError and MissingDependencyError\n- Support type: typedef specs with specialized compile_typedef\\(\\)\n- Add compile_project\\(\\) for multi-spec builds in dependency order\n- Add get_build_order\\(\\) and get_dependency_graph\\(\\) for introspection\n- Add run_all_tests\\(\\) for project-wide test execution\n- Add get_affected_specs\\(\\) for incremental build support\n- Include import context in compilation prompts\n- Add examples/user_project demonstrating multi-spec dependencies\n- Add comprehensive resolver tests \\(circular deps, diamond pattern, etc.\\)\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
14
+ "Bash(git -C /home/toby/_code/specular diff --stat)",
15
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\nfeat: implement Phase 2b build optimization\n\n- Add manifest.py with BuildManifest and IncrementalBuilder for tracking\n spec file hashes and build metadata \\(.specular-manifest.json\\)\n- Add incremental build support to compile_project\\(\\) - only recompiles\n specs when content, dependencies, or dependency outputs change\n- Add parallel compilation using ThreadPoolExecutor - specs at the same\n dependency level compile concurrently\n- Add get_parallel_build_order\\(\\) to DependencyResolver returning specs\n grouped into parallelizable levels\n- Add specs_skipped to BuildResult for incremental build reporting\n- Update The Quine spec with Phase 2b features \\(FR-21 through FR-25\\)\n- Add comprehensive manifest tests \\(11 tests\\)\n- Add parallel build order tests \\(2 tests\\)\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
16
+ "Bash(uv run:*)",
17
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\nfeat: add human-friendly CLI\n\n- Add cli.py with commands: list, create, validate, compile, test, fix, build\n- Build command supports --incremental and --parallel flags\n- Change entry point: `specular` now runs CLI, `specular-mcp` runs MCP server\n- Fix demo.py to use parser.get_spec_path\\(\\) \\(was broken after refactor\\)\n- Update README with CLI-focused quick start and reference\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
18
+ "Bash(git -C /home/toby/_code/specular commit -m \"$\\(cat <<''EOF''\nchore: add PyPI metadata and MIT license\n\n- Add author, license, keywords, classifiers to pyproject.toml\n- Add project URLs \\(homepage, repository, issues\\)\n- Add LICENSE file \\(MIT\\)\n- Fix GitHub URL placeholder in README\n\n🤖 Generated with [Claude Code]\\(https://claude.com/claude-code\\)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n\\)\")",
19
+ "Bash(uv build:*)",
20
+ "Bash(unzip:*)",
21
+ "Bash(git -C /home/toby/_code/specular commit -m \"docs: update README with pip install instructions\")",
22
+ "Bash(git -C /home/toby/_code/specular commit -m \"docs: update ROADMAP and add CLAUDE.md for future sessions\")",
23
+ "Bash(git -C /home/toby/_code/specular log --oneline origin/main..HEAD)"
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v5
18
+
19
+ - name: Set up Python
20
+ run: uv python install 3.10
21
+
22
+ - name: Install dependencies
23
+ run: uv sync --all-extras --dev
24
+
25
+ - name: Run Tests
26
+ run: uv run pytest tests/
27
+
28
+ - name: Lint (Ruff)
29
+ run: uv run ruff check src/
@@ -0,0 +1,36 @@
1
+ name: Deploy Documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ paths:
8
+ - "docs/**"
9
+ - "mkdocs.yml"
10
+ - ".github/workflows/docs.yaml"
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ jobs:
16
+ deploy:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Configure Git Credentials
22
+ run: |
23
+ git config user.name github-actions[bot]
24
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
25
+
26
+ - name: Set up Python
27
+ uses: actions/setup-python@v5
28
+ with:
29
+ python-version: 3.x
30
+
31
+ - name: Install dependencies
32
+ run: |
33
+ pip install mkdocs-material
34
+
35
+ - name: Deploy to GitHub Pages
36
+ run: mkdocs gh-deploy --force
@@ -0,0 +1,45 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # Environments
26
+ .venv/
27
+ env/
28
+ venv/
29
+ ENV/
30
+ env.bak/
31
+ venv.bak/
32
+
33
+ # Project Specific
34
+ test_env/
35
+ test_env_pytest/
36
+ .specular/
37
+
38
+ # IDEs
39
+ .vscode/
40
+ .idea/
41
+
42
+ # Byte-compiled / optimized / DLL files
43
+ __pycache__/
44
+ *.py[cod]
45
+ *$py.class
@@ -0,0 +1,44 @@
1
+ # Specular for Agents
2
+
3
+ Specular is designed to be **Agent-Native**. It provides a set of high-level tools via the **Model Context Protocol (MCP)** that allow an AI Agent to act as a Software Architect.
4
+
5
+ ## The Role of the Agent
6
+ When using Specular, the Agent's role shifts from "Writing Code" to **"Defining Behavior"**.
7
+ * **The Agent (Architect)**: Writes `*.spec.md` files.
8
+ * **Specular (Builder)**: Compiles specs to code, writes tests, runs them, and fixes low-level bugs.
9
+
10
+ ## MCP Toolset
11
+
12
+ ### 1. `create_spec(name, description, type)`
13
+ Initializes a new component specification.
14
+ * *Usage*: "Create a user authentication component."
15
+
16
+ ### 2. `compile_spec(name)`
17
+ Compiles the Markdown spec into source code (e.g., Python).
18
+ * *Usage*: "Build the auth component."
19
+
20
+ ### 3. `compile_tests(name)`
21
+ Generates a test suite based on the `Test Scenarios` and `Design Contract` in the spec.
22
+ * *Usage*: "Generate tests for auth."
23
+
24
+ ### 4. `run_tests(name)`
25
+ Executes the test suite and returns the results.
26
+ * *Usage*: "Verify the auth component."
27
+
28
+ ### 5. `attempt_fix(name)`
29
+ Triggers the **Self-Healing Loop**. If tests fail, Specular analyzes the logs and automatically patches the Code or the Test file.
30
+ * *Usage*: "The tests failed. Fix it."
31
+
32
+ ## Example System Prompt for an Architect Agent
33
+
34
+ If you are configuring a custom agent to use Specular, use this system prompt:
35
+
36
+ > You are a Lead Software Architect. Your goal is to build robust software using the **Specular Framework**.
37
+ >
38
+ > **Rules:**
39
+ > 1. **Never write source code** (Python/JS) directly. Always create or edit `*.spec.md` files.
40
+ > 2. **Be Rigorous**: When editing specs, clearly define **Functional Requirements (FRs)** and **Design Contracts**.
41
+ > 3. **Iterate**:
42
+ > - Create Spec -> `compile_spec` -> `compile_tests` -> `run_tests`.
43
+ > - If tests fail, use `attempt_fix` first.
44
+ > - If that fails, read the spec and refine the requirements.
@@ -0,0 +1,56 @@
1
+ # Claude Context for Specular
2
+
3
+ ## What is Specular?
4
+
5
+ Specular is a "Spec-as-Source" AI coding framework. Users write rigorous Markdown specifications (SRS-style), and Specular uses LLMs to compile them into executable Python code with tests.
6
+
7
+ **Key insight**: Code is a build artifact. Specs are source of truth.
8
+
9
+ ## Architecture
10
+
11
+ ```
12
+ src/specular/
13
+ ├── core.py # SpecularCore - thin orchestrator
14
+ ├── parser.py # Spec parsing, validation, frontmatter
15
+ ├── compiler.py # Prompt construction, LLM code generation
16
+ ├── runner.py # Test execution, build file management
17
+ ├── resolver.py # Dependency resolution, topological sort
18
+ ├── manifest.py # Build caching, incremental builds
19
+ ├── config.py # SpecularConfig, env-based loading
20
+ ├── cli.py # Human-friendly CLI
21
+ ├── server.py # MCP server for AI agents
22
+ ├── providers/ # LLM backends (Gemini, Anthropic)
23
+ └── templates/ # Spec template, global context
24
+ ```
25
+
26
+ ## Key Commands
27
+
28
+ ```bash
29
+ uv run pytest tests/ # Run tests (25 tests)
30
+ uv run ruff check src/ # Lint
31
+ uv run specular --help # CLI help
32
+ uv run specular-mcp # Start MCP server
33
+ ```
34
+
35
+ ## Self-Hosting Spec ("The Quine")
36
+
37
+ `self_hosting/specular_core.spec.md` is Specular's own specification - it describes itself. Keep this updated when making architectural changes.
38
+
39
+ ## Current State (v0.1.0)
40
+
41
+ - Phases 1, 1.5, 2a, 2b, 2c complete
42
+ - Published to PyPI as `specular-ai`
43
+ - CLI and MCP server both functional
44
+ - Supports Gemini and Anthropic providers
45
+
46
+ ## What's Next (Phase 3)
47
+
48
+ See ROADMAP.md. Main items:
49
+ - CLI polish (spinners, colors)
50
+ - Multi-language support (TypeScript, Go)
51
+ - Documentation site
52
+ - Better error messages
53
+
54
+ ## Testing Changes
55
+
56
+ Always run `uv run pytest tests/ && uv run ruff check src/` before committing.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Toby Lightheart
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,143 @@
1
+ Metadata-Version: 2.4
2
+ Name: specsoloist
3
+ Version: 0.2.0
4
+ Summary: Spec-as-Source Framework: AI-driven development where specifications are the source of truth.
5
+ Project-URL: Homepage, https://github.com/symbolfarm/specsoloist
6
+ Project-URL: Repository, https://github.com/symbolfarm/specsoloist
7
+ Project-URL: Issues, https://github.com/symbolfarm/specsoloist/issues
8
+ Author-email: Toby Lightheart <code@symbolfarm.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,code-generation,llm,mcp,specifications
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Code Generators
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: mcp>=0.1.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: rich>=13.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: mkdocs-material>=9.0.0; extra == 'dev'
26
+ Requires-Dist: mkdocs>=1.5.0; extra == 'dev'
27
+ Requires-Dist: pytest>=7.0; extra == 'dev'
28
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
29
+ Description-Content-Type: text/markdown
30
+
31
+ # SpecSoloist
32
+
33
+ **SpecSoloist** is a "Spec-as-Source" AI coding framework. It treats rigorous, SRS-style specifications as the source of truth and uses LLMs to compile them into executable code.
34
+
35
+ ## Why SpecSoloist?
36
+
37
+ Code is often messy, poorly documented, and prone to drift from original requirements. SpecSoloist flips the script:
38
+
39
+ 1. **Write Specs**: You write high-level, human-readable specifications (Markdown).
40
+ 2. **Compile to Code**: SpecSoloist uses LLMs (Gemini/Claude) to implement the spec.
41
+ 3. **Self-Healing**: If tests fail, SpecSoloist analyzes the failure and patches the code or tests automatically.
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install specsoloist
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ 1. Clone the repository (or create a new folder):
52
+ ```bash
53
+ git clone https://github.com/symbolfarm/specsoloist.git
54
+ cd specsoloist
55
+ ```
56
+
57
+ 2. Set your API Key (Gemini or Anthropic):
58
+ ```bash
59
+ export GEMINI_API_KEY="your_key_here"
60
+ # or
61
+ export ANTHROPIC_API_KEY="your_key_here"
62
+ ```
63
+
64
+ 3. Create a new specification:
65
+ ```bash
66
+ sp create calculator "A simple calculator with add and multiply"
67
+ ```
68
+ This creates `src/calculator.spec.md`.
69
+
70
+ 4. Compile it to code:
71
+ ```bash
72
+ sp compile calculator
73
+ ```
74
+ This generates `build/calculator.py` and `build/test_calculator.py`.
75
+
76
+ 5. Run the tests:
77
+ ```bash
78
+ sp test calculator
79
+ ```
80
+
81
+ 6. (Optional) If tests fail, try auto-fix:
82
+ ```bash
83
+ sp fix calculator
84
+ ```
85
+
86
+ ## The Workflow
87
+
88
+ SpecSoloist isn't just a code generator; it's an architecture tool.
89
+
90
+ * **Edit Spec** -> `sp compile` -> `sp test`.
91
+ * **Failure?** -> `sp fix` (Let the AI patch the code).
92
+ * **Architecture Change?** -> Edit `src/*.spec.md`.
93
+
94
+ ## CLI Reference
95
+
96
+ | Command | Description |
97
+ | :--- | :--- |
98
+ | `sp list` | List all specs in `src/` |
99
+ | `sp create <name> <desc>` | Create a new spec from template |
100
+ | `sp validate <name>` | Check spec structure |
101
+ | `sp compile <name>` | Compile spec to code + tests |
102
+ | `sp test <name>` | Run tests for a spec |
103
+ | `sp fix <name>` | Auto-fix failing tests |
104
+ | `sp build` | Compile all specs in dependency order |
105
+
106
+ ## Configuration
107
+
108
+ You can configure SpecSoloist via environment variables or a `.env` file:
109
+
110
+ ```bash
111
+ export SPECSOLOIST_LLM_PROVIDER="gemini" # or "anthropic"
112
+ export SPEC_LLM_MODEL="gemini-2.0-flash" # optional
113
+ ```
114
+
115
+ For Anthropic:
116
+
117
+ ```bash
118
+ export SPECSOLOIST_LLM_PROVIDER="anthropic"
119
+ export ANTHROPIC_API_KEY="your_key_here"
120
+ export SPECSOLOIST_LLM_MODEL="claude-sonnet-4-20250514" # optional
121
+ ```
122
+
123
+ ## Agent Integration (MCP)
124
+
125
+ SpecSoloist can run as an MCP server for Claude Desktop or other AI agents:
126
+
127
+ Add to your `claude_desktop_config.json`:
128
+
129
+ ```json
130
+ {
131
+ "mcpServers": {
132
+ "specsoloist": {
133
+ "command": "uv",
134
+ "args": ["run", "specsoloist-mcp"],
135
+ "env": {
136
+ "GEMINI_API_KEY": "..."
137
+ }
138
+ }
139
+ }
140
+ }
141
+ ```
142
+
143
+ Or use the CLI: `sp mcp`
@@ -0,0 +1,113 @@
1
+ # SpecSoloist
2
+
3
+ **SpecSoloist** is a "Spec-as-Source" AI coding framework. It treats rigorous, SRS-style specifications as the source of truth and uses LLMs to compile them into executable code.
4
+
5
+ ## Why SpecSoloist?
6
+
7
+ Code is often messy, poorly documented, and prone to drift from original requirements. SpecSoloist flips the script:
8
+
9
+ 1. **Write Specs**: You write high-level, human-readable specifications (Markdown).
10
+ 2. **Compile to Code**: SpecSoloist uses LLMs (Gemini/Claude) to implement the spec.
11
+ 3. **Self-Healing**: If tests fail, SpecSoloist analyzes the failure and patches the code or tests automatically.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install specsoloist
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ 1. Clone the repository (or create a new folder):
22
+ ```bash
23
+ git clone https://github.com/symbolfarm/specsoloist.git
24
+ cd specsoloist
25
+ ```
26
+
27
+ 2. Set your API Key (Gemini or Anthropic):
28
+ ```bash
29
+ export GEMINI_API_KEY="your_key_here"
30
+ # or
31
+ export ANTHROPIC_API_KEY="your_key_here"
32
+ ```
33
+
34
+ 3. Create a new specification:
35
+ ```bash
36
+ sp create calculator "A simple calculator with add and multiply"
37
+ ```
38
+ This creates `src/calculator.spec.md`.
39
+
40
+ 4. Compile it to code:
41
+ ```bash
42
+ sp compile calculator
43
+ ```
44
+ This generates `build/calculator.py` and `build/test_calculator.py`.
45
+
46
+ 5. Run the tests:
47
+ ```bash
48
+ sp test calculator
49
+ ```
50
+
51
+ 6. (Optional) If tests fail, try auto-fix:
52
+ ```bash
53
+ sp fix calculator
54
+ ```
55
+
56
+ ## The Workflow
57
+
58
+ SpecSoloist isn't just a code generator; it's an architecture tool.
59
+
60
+ * **Edit Spec** -> `sp compile` -> `sp test`.
61
+ * **Failure?** -> `sp fix` (Let the AI patch the code).
62
+ * **Architecture Change?** -> Edit `src/*.spec.md`.
63
+
64
+ ## CLI Reference
65
+
66
+ | Command | Description |
67
+ | :--- | :--- |
68
+ | `sp list` | List all specs in `src/` |
69
+ | `sp create <name> <desc>` | Create a new spec from template |
70
+ | `sp validate <name>` | Check spec structure |
71
+ | `sp compile <name>` | Compile spec to code + tests |
72
+ | `sp test <name>` | Run tests for a spec |
73
+ | `sp fix <name>` | Auto-fix failing tests |
74
+ | `sp build` | Compile all specs in dependency order |
75
+
76
+ ## Configuration
77
+
78
+ You can configure SpecSoloist via environment variables or a `.env` file:
79
+
80
+ ```bash
81
+ export SPECSOLOIST_LLM_PROVIDER="gemini" # or "anthropic"
82
+ export SPEC_LLM_MODEL="gemini-2.0-flash" # optional
83
+ ```
84
+
85
+ For Anthropic:
86
+
87
+ ```bash
88
+ export SPECSOLOIST_LLM_PROVIDER="anthropic"
89
+ export ANTHROPIC_API_KEY="your_key_here"
90
+ export SPECSOLOIST_LLM_MODEL="claude-sonnet-4-20250514" # optional
91
+ ```
92
+
93
+ ## Agent Integration (MCP)
94
+
95
+ SpecSoloist can run as an MCP server for Claude Desktop or other AI agents:
96
+
97
+ Add to your `claude_desktop_config.json`:
98
+
99
+ ```json
100
+ {
101
+ "mcpServers": {
102
+ "specsoloist": {
103
+ "command": "uv",
104
+ "args": ["run", "specsoloist-mcp"],
105
+ "env": {
106
+ "GEMINI_API_KEY": "..."
107
+ }
108
+ }
109
+ }
110
+ }
111
+ ```
112
+
113
+ Or use the CLI: `sp mcp`
@@ -0,0 +1,44 @@
1
+ # Specular Roadmap
2
+
3
+ ## Phase 1: Core Framework & Self-Healing (Completed)
4
+ - [x] **Spec-as-Source**: Define components using rigorous SRS-style Markdown.
5
+ - [x] **LLM Compilation**: Compile specs to Python code using Google Gemini.
6
+ - [x] **Test Generation**: Automatically generate `pytest` suites from spec scenarios.
7
+ - [x] **Integrated Runner**: Run tests in isolated environments.
8
+ - [x] **Agentic Self-Healing**: `attempt_fix` loop that analyzes failures and patches code/tests.
9
+ - [x] **MCP Server**: Expose all tools via the Model Context Protocol.
10
+
11
+ ## Phase 1.5: Foundation Hardening (Completed)
12
+ - [x] **Code Separation**: Extract specialized modules (parser, compiler, runner, config).
13
+ - [x] **LLM Provider Abstraction**: `LLMProvider` protocol with Gemini and Anthropic implementations.
14
+ - [x] **Configuration System**: `SpecularConfig` with environment-based loading.
15
+ - [x] **Thin Orchestrator**: Refactor `SpecularCore` to delegate to specialized modules.
16
+ - [x] **Updated Self-Hosting Spec**: The Quine updated to reflect new architecture.
17
+
18
+ ## Phase 2a: Multi-Spec Architecture (Completed)
19
+ - [x] **Dependency Syntax**: YAML frontmatter syntax for declaring spec dependencies.
20
+ - [x] **Dependency Graph**: `DependencyResolver` with topological sort for build order.
21
+ - [x] **Type Specs**: Support `type: typedef` specs with specialized compilation.
22
+ - [x] **Multi-Spec Builds**: `compile_project()` compiles all specs in dependency order.
23
+ - [x] **Affected Specs**: Track which specs need rebuilding when a dependency changes.
24
+
25
+ ## Phase 2b: Build Optimization (Completed)
26
+ - [x] **Incremental Builds**: Only recompile specs that have changed.
27
+ - [x] **Build Caching**: Track file hashes and build manifest (`.specular-manifest.json`).
28
+ - [x] **Parallel Compilation**: Compile independent specs concurrently using `ThreadPoolExecutor`.
29
+
30
+ ## Phase 2c: Release Prep (Completed)
31
+ - [x] **Human CLI**: `specular` command with list, create, compile, test, fix, build commands.
32
+ - [x] **PyPI Publication**: Released `specular-ai` v0.1.0 to PyPI.
33
+
34
+ ## Phase 3: Polish (Completed)
35
+ - [x] **CLI Polish**: Rich terminal output (spinners, tables, colored panels).
36
+ - [x] **Multi-Language Support**: Config-driven runner with TypeScript support (via `tsx` and `node:test`).
37
+ - [x] **Documentation Site**: MkDocs Material site with "Leaves-Up" workflow guide.
38
+ - [x] **Error Handling**: Friendly messages for circular dependencies and missing API keys.
39
+
40
+ ## Phase 4: Developer Experience (Future)
41
+ - [ ] **Sandboxed Execution**: Run generated code in Docker containers for safety.
42
+ - [ ] **VS Code Extension**: Live preview of generated code/tests while editing specs.
43
+ - [ ] **Visual Spec Editor**: A GUI for defining Functional Requirements and Contracts.
44
+
@@ -0,0 +1,110 @@
1
+ import os
2
+ import sys
3
+ from specsoloist.core import SpecSoloistCore
4
+
5
+ def main():
6
+ # Ensure API Key is present
7
+ if "GEMINI_API_KEY" not in os.environ:
8
+ print("ERROR: GEMINI_API_KEY environment variable not found.")
9
+ print("Please run: export GEMINI_API_KEY='your_key_here'")
10
+ sys.exit(1)
11
+
12
+ print("--- SpecSoloist Demo: End-to-End Flow ---")
13
+
14
+ # Initialize Core
15
+ core = SpecSoloistCore(".")
16
+
17
+ spec_name = "math_demo"
18
+
19
+ # 1. Create a spec from template
20
+ try:
21
+ core.create_spec(spec_name, "A robust factorial and prime check library.")
22
+ except FileExistsError:
23
+ print(f"Spec {spec_name} already exists, proceeding to overwrite with demo content.")
24
+
25
+ # 2. Overwrite with a high-quality definition to ensure LLM success
26
+ spec_path = core.parser.get_spec_path(spec_name)
27
+ demo_spec_content = """---
28
+ name: math_demo
29
+ type: module
30
+ language_target: python
31
+ status: draft
32
+ ---
33
+
34
+ # 1. Overview
35
+ A library for mathematical operations including factorial calculation and primality testing.
36
+
37
+ # 2. Interface Specification
38
+
39
+ ## 2.1 Inputs
40
+ ### `factorial(n: int) -> int`
41
+ * `n`: The non-negative integer to calculate the factorial of.
42
+
43
+ ### `is_prime(n: int) -> bool`
44
+ * `n`: The integer to check for primality.
45
+
46
+ ## 2.2 Outputs
47
+ * `factorial`: Returns the factorial as an integer.
48
+ * `is_prime`: Returns True if n is prime, False otherwise.
49
+
50
+ # 3. Functional Requirements (Behavior)
51
+ * **FR-01**: `factorial` shall return 1 for input 0.
52
+ * **FR-02**: `factorial` shall return the product of all positive integers less than or equal to n.
53
+ * **FR-03**: `is_prime` shall return False for numbers less than or equal to 1.
54
+ * **FR-04**: `is_prime` shall return True for 2 and 3.
55
+ * **FR-05**: `is_prime` shall use an efficient primality test (e.g., trial division up to sqrt(n)).
56
+
57
+ # 4. Non-Functional Requirements (Constraints)
58
+ * **NFR-Purity**: Both functions must be pure.
59
+ * **NFR-Robustness**: `factorial` should raise a ValueError for negative inputs.
60
+
61
+ # 5. Design Contract
62
+ * **Pre-condition**: `factorial` input `n >= 0`.
63
+ * **Post-condition**: `is_prime` output is always boolean.
64
+
65
+ # 6. Test Scenarios
66
+ | Scenario | Input | Expected Output |
67
+ |----------|-------|-----------------|
68
+ | Factorial 0 | `factorial(0)` | `1` |
69
+ | Factorial 5 | `factorial(5)` | `120` |
70
+ | Prime 7 | `is_prime(7)` | `True` |
71
+ | Not Prime 10 | `is_prime(10)` | `False` |
72
+ | Negative Factorial | `factorial(-1)` | `ValueError` |
73
+ """.strip()
74
+ with open(spec_path, 'w') as f:
75
+ f.write(demo_spec_content)
76
+ print(f"1. Spec created/updated at: {spec_path}")
77
+
78
+ # 3. Compile Code
79
+ print(f"2. Compiling {spec_name} to code...")
80
+ print(core.compile_spec(spec_name))
81
+
82
+ # 4. Compile Tests
83
+ print(f"3. Compiling {spec_name} to tests...")
84
+ print(core.compile_tests(spec_name))
85
+
86
+ # 5. Run Tests
87
+ print("4. Running tests...")
88
+ result = core.run_tests(spec_name)
89
+
90
+ if result["success"]:
91
+ print("\nSUCCESS: All tests passed!")
92
+ else:
93
+ print("\nFAILURE: Tests failed.")
94
+ print("--- Test Output ---")
95
+ print(result["output"][:500] + "...") # Print snippet
96
+
97
+ print("\n5. Attempting Auto-Fix (Self-Correction)...")
98
+ fix_msg = core.attempt_fix(spec_name)
99
+ print(fix_msg)
100
+
101
+ print("6. Rerunning tests after fix...")
102
+ result_retry = core.run_tests(spec_name)
103
+ if result_retry["success"]:
104
+ print("\nSUCCESS: Auto-fix worked! All tests passed.")
105
+ else:
106
+ print("\nFAILURE: Auto-fix failed to resolve the issue.")
107
+ print(result_retry["output"])
108
+
109
+ if __name__ == "__main__":
110
+ main()