Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 209 additions & 13 deletions core/codegen/src/cli_gen.rs

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions core/codegen/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ impl ToolDef {
enable_step_mode: false,
mock_spec_call: None,
enable_mode: false,
available_profiles: vec![],
},
entrypoints: vec![],
custom_import: None,
Expand Down Expand Up @@ -293,6 +294,15 @@ impl ToolDef {
self
}

/// Set available profiles for `--profile` enum flag (C20/RT59).
///
/// When non-empty, the generated CLI accepts `--profile <name>` to select
/// which interface bindings are active at runtime.
pub fn available_profiles(mut self, profiles: Vec<String>) -> Self {
self.meta.available_profiles = profiles;
self
}

/// Add a subcommand for multi-func dispatch (RT63).
pub fn subcommand(mut self, subcmd: SubcommandDef) -> Self {
self.subcommands.push(subcmd);
Expand Down
26 changes: 26 additions & 0 deletions core/daglang/daglang-driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ pub struct CompileOutput {
/// Keys are both qualified (`module.name`) and unqualified (`name`).
/// Values are the constant expressions from `data` items.
pub data_values: HashMap<String, serde_json::Value>,
/// Available profile names extracted from `profile` declarations (C20/RT59).
///
/// When non-empty, the CLI generator can produce a `--profile` enum flag
/// that validates against these names. Profile selection determines which
/// interface bindings are active at runtime.
pub available_profiles: Vec<String>,
}

impl CompileOutput {
Expand Down Expand Up @@ -413,6 +419,7 @@ pub fn compile_from_module_graph_with_options(
let inferred_entrypoints = daglang_lower::infer_entrypoints(&lowered);
let dsl_type_registry = extract_dsl_type_registry(&typed);
let data_values = daglang_lower::build_data_values(&typed);
let available_profiles = collect_available_profiles(&typed);

let receipt = compute_receipt(&lowered, &emitted, &emit_manifest_path, &source_paths);

Expand All @@ -427,6 +434,7 @@ pub fn compile_from_module_graph_with_options(
dsl_type_registry,
receipt,
data_values,
available_profiles,
})
}

Expand Down Expand Up @@ -463,6 +471,24 @@ fn collect_pipeline_params(typed: &TypedProject) -> Vec<PipelineParam> {
params
}

/// Extract available profile names from the typed project (C20/RT59).
///
/// Walks all modules looking for `profile` declarations and collects
/// their names. These names become valid values for the `--profile` CLI flag.
fn collect_available_profiles(typed: &TypedProject) -> Vec<String> {
let mut profiles = Vec::new();
for module in &typed.modules {
for item in &module.ast.items {
if let Item::ProfileDef(def) = &item.node {
profiles.push(def.name.clone());
}
}
}
profiles.sort();
profiles.dedup();
profiles
}

/// Extract a `TypeRegistry` from DSL-defined sum and product types.
///
/// Walks all modules in the `TypedProject` and registers:
Expand Down
Loading
Loading