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: consolidate first-class tools — colocate compile-time and runtime code per tool (#290)
* Initial plan
* refactor: consolidate first-class tools and runtimes into colocated modules
Move compile-time (CompilerExtension) and runtime (Stage 3) code for
each tool/runtime into a single directory:
- tools/cache_memory/ — extension.rs + execute.rs
- tools/azure_devops/ — extension.rs
- runtimes/lean/ — extension.rs + mod.rs (config/helpers)
Infrastructure extensions (GitHub, SafeOutputs) remain in
compile/extensions/ as they are always-on and not user-configured.
compile/extensions/mod.rs re-exports tool/runtime extensions from
their new colocated homes.
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/3cae398b-84f6-450a-8e39-31f2c20687f3
Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
* docs: update AGENTS.md with new directory structure and colocation methodology
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/3cae398b-84f6-450a-8e39-31f2c20687f3
Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
* fix: remove unused MCPG_PORT re-export from compile/mod.rs
MCPG_PORT is only used within the compile module (onees.rs,
standalone.rs import via super::common). The pub re-export was
generating an unused_imports warning.
Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/cf879e88-1dcc-48b9-94d4-3d0df7bbaba4
Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
@@ -1481,13 +1492,24 @@ When extending the compiler:
1481
1492
3. **New front matter fields**: Add fields to `FrontMatter` in `src/compile/types.rs`
1482
1493
4. **New template markers**: Handle replacements in the target-specific compiler (e.g., `standalone.rs` or `onees.rs`)
1483
1494
5. **New safe-output tools**: Add to `src/safeoutputs/` — implement `ToolResult`, `Executor`, register in `mod.rs`, `mcp.rs`, `execute.rs`
1484
-
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()`
1485
-
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()`
1495
+
6. **New first-class tools**: Create `src/tools/<name>/` with `mod.rs` and `extension.rs` (CompilerExtension impl). Add `execute.rs` if the tool has Stage 3 runtime logic. Extend `ToolsConfig` in `types.rs`, add collection in `collect_extensions()`
1496
+
7. **New runtimes**: Create `src/runtimes/<name>/` with `mod.rs` (config types) and `extension.rs` (CompilerExtension impl). Extend `RuntimesConfig` in `types.rs`, add collection in `collect_extensions()`
1486
1497
8. **Validation**: Add compile-time validation for safe outputs and permissions
1487
1498
1499
+
#### Code Organization Principles
1500
+
1501
+
The codebase follows a **colocation** principle for tools and runtimes:
1502
+
1503
+
- **Tools** (`tools:` front matter) live in `src/tools/<name>/` — one directory per tool, containing both compile-time (`extension.rs`) and runtime (`execute.rs`) code. This means you can look at a single directory to understand everything a tool does.
1504
+
- **Runtimes** (`runtimes:` front matter) live in `src/runtimes/<name>/` — one directory per runtime, with config types in `mod.rs` and the `CompilerExtension` impl in `extension.rs`.
1505
+
- **Infrastructure extensions** (GitHub MCP, SafeOutputs MCP) that are always-on and not user-configured stay in `src/compile/extensions/`. These are internal plumbing, not user-facing tools.
1506
+
- **Safe outputs** (`safe-outputs:` front matter) stay in `src/safeoutputs/` — they follow a different lifecycle (Stage 1 NDJSON → Stage 3 execution) and are not `CompilerExtension` implementations.
1507
+
1508
+
The `src/compile/extensions/mod.rs` file owns the `CompilerExtension` trait, the `Extension` enum, and `collect_extensions()`. It re-exports tool/runtime extension types from their colocated homes so the rest of the compiler can import them from a single path.
1509
+
1488
1510
#### `CompilerExtension` Trait
1489
1511
1490
-
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:
1512
+
Runtimes and first-party tools declare their compilation requirements via the `CompilerExtension` trait (`src/compile/extensions/mod.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.
1526
+
To add a new runtime or tool: (1) create a directory under `src/tools/` or `src/runtimes/`, (2) implement `CompilerExtension` in `extension.rs`, (3) add a variant to the `Extension` enum and a collection check in `collect_extensions()` in `src/compile/extensions/mod.rs`.
0 commit comments