From ed7608fc04a9f9770f48732a0c214432ccab71d3 Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Sun, 7 Jun 2026 14:55:19 +0800 Subject: [PATCH] feat(codegen): scaffold ai-feature-gated pipeline module --- crates/op-codegen/Cargo.toml | 12 ++++++++++++ crates/op-codegen/src/ai/assets.rs | 1 + crates/op-codegen/src/ai/bundle.rs | 1 + crates/op-codegen/src/ai/mod.rs | 13 +++++++++++++ crates/op-codegen/src/ai/parse.rs | 1 + crates/op-codegen/src/ai/pipeline.rs | 1 + crates/op-codegen/src/ai/prompts.rs | 1 + crates/op-codegen/src/ai/types.rs | 1 + crates/op-codegen/src/lib.rs | 6 ++++++ 9 files changed, 37 insertions(+) create mode 100644 crates/op-codegen/src/ai/assets.rs create mode 100644 crates/op-codegen/src/ai/bundle.rs create mode 100644 crates/op-codegen/src/ai/mod.rs create mode 100644 crates/op-codegen/src/ai/parse.rs create mode 100644 crates/op-codegen/src/ai/pipeline.rs create mode 100644 crates/op-codegen/src/ai/prompts.rs create mode 100644 crates/op-codegen/src/ai/types.rs diff --git a/crates/op-codegen/Cargo.toml b/crates/op-codegen/Cargo.toml index 930da3489..3f9f5c15e 100644 --- a/crates/op-codegen/Cargo.toml +++ b/crates/op-codegen/Cargo.toml @@ -13,3 +13,15 @@ path = "src/lib.rs" [dependencies] jian-ops-schema = { path = "../../vendor/jian/crates/jian-ops-schema" } op-editor-core = { path = "../op-editor-core" } + +# AI pipeline deps — optional, pulled in only by the `ai` feature so +# non-AI consumers (and the deterministic generators) stay lean. op-ai +# is dependency-free + wasm-clean; op-codegen does NOT depend on +# op-ai-skills (skill corpus is expanded at the transport edge). +op-ai = { path = "../op-ai", optional = true } +serde = { workspace = true, features = ["derive"], optional = true } +serde_json = { workspace = true, optional = true } + +[features] +# Gates the AI code-generation pipeline (src/ai/). Off by default. +ai = ["dep:op-ai", "dep:serde", "dep:serde_json"] diff --git a/crates/op-codegen/src/ai/assets.rs b/crates/op-codegen/src/ai/assets.rs new file mode 100644 index 000000000..2b21d827c --- /dev/null +++ b/crates/op-codegen/src/ai/assets.rs @@ -0,0 +1 @@ +// Implemented in later tasks of this plan. diff --git a/crates/op-codegen/src/ai/bundle.rs b/crates/op-codegen/src/ai/bundle.rs new file mode 100644 index 000000000..2b21d827c --- /dev/null +++ b/crates/op-codegen/src/ai/bundle.rs @@ -0,0 +1 @@ +// Implemented in later tasks of this plan. diff --git a/crates/op-codegen/src/ai/mod.rs b/crates/op-codegen/src/ai/mod.rs new file mode 100644 index 000000000..476a072ca --- /dev/null +++ b/crates/op-codegen/src/ai/mod.rs @@ -0,0 +1,13 @@ +//! AI-driven code-generation pipeline. A pull-based, transport-agnostic +//! state machine: it emits `PendingRequest`s (skill names + user message +//! + params) and consumes streamed text deltas via `on_delta`/ +//! `on_complete`/`on_error`, advancing through planning → chunk → +//! assembly. Hosts supply the streaming transport; the pipeline owns the +//! logic. Ported from the TS `code-generation-pipeline.ts`. + +pub mod assets; +pub mod bundle; +pub mod parse; +pub mod pipeline; +pub mod prompts; +pub mod types; diff --git a/crates/op-codegen/src/ai/parse.rs b/crates/op-codegen/src/ai/parse.rs new file mode 100644 index 000000000..2b21d827c --- /dev/null +++ b/crates/op-codegen/src/ai/parse.rs @@ -0,0 +1 @@ +// Implemented in later tasks of this plan. diff --git a/crates/op-codegen/src/ai/pipeline.rs b/crates/op-codegen/src/ai/pipeline.rs new file mode 100644 index 000000000..2b21d827c --- /dev/null +++ b/crates/op-codegen/src/ai/pipeline.rs @@ -0,0 +1 @@ +// Implemented in later tasks of this plan. diff --git a/crates/op-codegen/src/ai/prompts.rs b/crates/op-codegen/src/ai/prompts.rs new file mode 100644 index 000000000..2b21d827c --- /dev/null +++ b/crates/op-codegen/src/ai/prompts.rs @@ -0,0 +1 @@ +// Implemented in later tasks of this plan. diff --git a/crates/op-codegen/src/ai/types.rs b/crates/op-codegen/src/ai/types.rs new file mode 100644 index 000000000..2b21d827c --- /dev/null +++ b/crates/op-codegen/src/ai/types.rs @@ -0,0 +1 @@ +// Implemented in later tasks of this plan. diff --git a/crates/op-codegen/src/lib.rs b/crates/op-codegen/src/lib.rs index 8d63b2e59..cbc55f583 100644 --- a/crates/op-codegen/src/lib.rs +++ b/crates/op-codegen/src/lib.rs @@ -12,6 +12,12 @@ //! node-accessor helpers, and the test suite; per-framework markup //! generators live in the sibling `codegen_targets` module. +/// AI-driven code-generation pipeline (planning → chunk → assembly). +/// Gated behind the `ai` feature so the deterministic generators stay +/// dependency-light. +#[cfg(feature = "ai")] +pub mod ai; + mod codegen_targets; pub use crate::codegen_targets::{