You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: unify runtime/tool requirements via CompilerExtension trait
Introduce a CompilerExtension trait that runtimes and first-party tools
implement to declare their compilation requirements (network hosts,
bash commands, prompt supplements, prepare steps, MCPG entries).
Previously, each runtime/tool required scattered special-case code
across standalone.rs, common.rs, and other files. Now:
- LeanExtension: declares hosts, bash cmds, install steps, prompt
- AzureDevOpsExtension: declares hosts, MCPG entry, validation
- CacheMemoryExtension: declares download steps, prompt supplement
The compiler collects all enabled extensions via collect_extensions()
and iterates over them generically -- no more bespoke if-blocks.
Adding a new runtime or tool is now a 2-step process:
1. Implement CompilerExtension
2. Add to collect_extensions()
MCPG types (McpgServerConfig, McpgConfig, etc.) moved from
standalone.rs to extensions.rs for shared access.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: AGENTS.md
+21-3Lines changed: 21 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1447,9 +1447,27 @@ When extending the compiler:
1447
1447
3. **New front matter fields**: Add fields to `FrontMatter` in `src/compile/types.rs`
1448
1448
4. **New template markers**: Handle replacements in the target-specific compiler (e.g., `standalone.rs` or `onees.rs`)
1449
1449
5. **New safe-output tools**: Add to `src/safeoutputs/` — implement `ToolResult`, `Executor`, register in `mod.rs`, `mcp.rs`, `execute.rs`
1450
-
6. **New first-class tools**: Add to `src/tools/` — extend `ToolsConfig` in `types.rs`, wire in compilers
1451
-
7. **New runtimes**: Add to `src/runtimes/` — extend `RuntimesConfig` in `types.rs`, wire in compilers
1452
-
7. **Validation**: Add compile-time validation for safe outputs and permissions
1450
+
6. **New first-class tools**: Add to `src/tools/` — extend `ToolsConfig` in `types.rs`, implement `CompilerExtension` trait in `src/compile/extensions.rs`, add collection in `collect_extensions()`
1451
+
7. **New runtimes**: Add to `src/runtimes/` — extend `RuntimesConfig` in `types.rs`, implement `CompilerExtension` trait in `src/compile/extensions.rs`, add collection in `collect_extensions()`
1452
+
8. **Validation**: Add compile-time validation for safe outputs and permissions
1453
+
1454
+
#### `CompilerExtension` Trait
1455
+
1456
+
Runtimes and first-party tools declare their compilation requirements via the `CompilerExtension` trait (`src/compile/extensions.rs`). Instead of scattering special-case `if` blocks across the compiler, each runtime/tool implements this trait and the compiler collects requirements generically:
To add a new runtime or tool: (1) create a struct implementing `CompilerExtension`, (2) add a collection check in `collect_extensions()`. No other files need modification.
0 commit comments