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 (#211)
* 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>
* fix: address review feedback on CompilerExtension
- Add validation loop to OneESCompiler (bug: Lean/ADO warnings were
silently dropped for target: 1es agents)
- Add debug_assert on display_name in wrap_prompt_append to guard
against future extension names with shell/YAML metacharacters
- Document why CacheMemoryExtension.config is #[allow(dead_code)]
(options consumed at Stage 2, not compile time)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* feat: add ExtensionPhase ordering policy (runtimes before tools)
Extensions now declare their phase via phase() -> ExtensionPhase.
collect_extensions() sorts by phase using stable sort, guaranteeing
runtimes install before tools — critical when a tool depends on a
runtime (e.g., uv requires Python to be installed first).
Phases: Runtime (0) → Tool (1).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: harden wrap_prompt_append and document validate() limitations
- Replace debug_assert! with anyhow::ensure! in wrap_prompt_append so
unsafe display_name characters are rejected in release builds too.
Function now returns Result<String>.
- Add doc comment to validate() explaining that inferred_org is not
available at validation time — org-dependent checks belong in
mcpg_servers() which receives the fully populated CompileContext.
- Add test for unsafe display_name rejection.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
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