Skip to content

feat(cli): Add feature flags for modular CLI builds#93

Merged
CSRessel merged 7 commits into
devfrom
feature/release-feature-flags
Dec 11, 2025
Merged

feat(cli): Add feature flags for modular CLI builds#93
CSRessel merged 7 commits into
devfrom
feature/release-feature-flags

Conversation

@CSRessel
Copy link
Copy Markdown
Collaborator

Summary

🤖 Generated with Nori

  • Implemented Cargo feature flags to make the CLI binary modular with default = [] (minimal) and full (complete) configurations
  • Made 6 dependencies optional: codex-app-server, codex-chatgpt, codex-cloud-tasks, codex-login, codex-mcp-server, codex-responses-api-proxy, codex-rmcp-client
  • Added #[cfg(feature = "...")] guards throughout main.rs for conditional compilation
  • Achieves 22% release binary size reduction (46MB → 36MB) for minimal builds

Test Plan

  • cargo build -p codex-cli (minimal) compiles successfully
  • cargo build -p codex-cli --features full compiles successfully
  • cargo test --all --features full passes
  • cargo clippy --all --features full passes
  • MCP integration tests correctly skipped without mcp-server feature

Share Nori with your team: https://www.npmjs.com/package/nori-ai

Implement Cargo feature flags to make the CLI binary modular:
- default = [] (minimal: TUI + exec + ACP only)
- full = all features for complete functionality
- Individual features: app-server, cloud-tasks, login, mcp-server, chatgpt, responses-api-proxy

This reduces release binary size from 46MB to 36MB (22% reduction) for
minimal builds by excluding optional HTTP-based functionality.

Key changes:
- Made 6 dependencies optional with dep: prefix
- Added #[cfg(feature = "...")] guards to main.rs imports, enum variants, and match arms
- Added required-features to MCP integration tests
- Updated docs.md with feature flag documentation
🤖 Generated with [Nori](https://nori.ai)

Co-Authored-By: Nori <contact@tilework.tech>
@CSRessel
Copy link
Copy Markdown
Collaborator Author

CSRessel commented Dec 10, 2025

Feature Flags Implementation Complete

This update completes the feature flags implementation as specified in FEATURE_PLAN.md.

New Additions

Nori Update System (codex-rs/tui/src/nori/):

  • update_action.rs - Defines UpdateAction enum with NpmGlobalLatest and Manual variants
  • updates.rs - Checks tilework-tech/nori-cli GitHub releases for updates
  • update_prompt.rs - Nori-branded update prompt UI

CLI Feature Propagation (codex-rs/cli/Cargo.toml):

  • Features now propagate from CLI to TUI: login, feedback, backend-client, upstream-updates

Slash Command Visibility:

  • /logout is hidden when login feature is disabled
  • /feedback is hidden when feedback feature is disabled

Build Modes

Mode Command Features
Minimal (Nori default) cargo build -p codex-cli ACP-only, Nori updates
Full (OpenAI compat) cargo build -p codex-cli --features full All OpenAI functionality

Test Results

All tests pass:

  • cargo test -p codex-tui --no-default-features
  • cargo test -p codex-tui --features full
  • cargo test -p codex-cli --no-default-features
  • cargo test -p codex-cli --features full
  • cargo clippy
  • cargo fmt

🤖 Generated with Nori

CSRessel and others added 2 commits December 10, 2025 14:29
Add conditional compilation throughout TUI crate to enable modular
builds:

- Define feature flags in Cargo.toml: full, login, feedback, backend-client, upstream-updates
- Make codex-login, codex-feedback, codex-backend-client optional dependencies
- Gate onboarding auth flow with #[cfg(feature = "login")]
- Gate feedback popups and events with #[cfg(feature = "feedback")]
- Gate BackendClient usage with #[cfg(feature = "backend-client")]
- Hide /logout and /feedback slash commands when features disabled
- Add nori/feedback.rs to redirect feedback to GitHub Discussions
- Add nori/update_action.rs and nori/updates.rs for Nori update system
- Gate feedback-related tests with #[cfg(feature = "feedback")]
- Create FEATURE_PLAN.md documenting the implementation plan

This enables the Nori CLI fork to default to ACP-only mode without
OpenAI-specific functionality, while allowing full-featured builds
via --features full.
- Add Nori-specific update modules (update_action.rs, updates.rs, update_prompt.rs)
- Gate slash command visibility based on features (login, feedback)
- Add CLI feature propagation to TUI crate
- Update documentation for feature flags architecture
- Remove unnecessary dead code workaround in updates.rs
- Add documentation for get_update_action() design decision

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CSRessel CSRessel force-pushed the feature/release-feature-flags branch from d7b6dfd to 0fddda2 Compare December 10, 2025 19:30
Add missing re-export of nori::updates as crate::updates when
upstream-updates feature is disabled. This fixes a release build error
where app.rs calls crate::updates::get_upgrade_version() but the module
wasn't available in the Nori configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add `oss-providers` feature flag to gate codex-ollama and codex-lmstudio
  - CLI, TUI, and common crates now support `oss-providers` feature
  - OSS provider functions return stubs when feature disabled
- Improve feedback_compat.rs stub for API compatibility
  - Match anyhow::Result<()> return type for upload_feedback
  - Add proper tests with feature-gated assertions
  - Add placeholder comments for future Nori feedback integration
- Include `oss-providers` in `full` feature bundle
- Update documentation in docs.md files

This continues the feature flags work to enable minimal binary builds
by making OSS provider dependencies optional.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@CSRessel
Copy link
Copy Markdown
Collaborator Author

Update: Gate OSS providers and improve feedback stub

This commit adds the following improvements:

OSS Providers Feature Flag

  • Added oss-providers feature flag to gate codex-ollama and codex-lmstudio dependencies
  • Feature propagates through CLI → TUI → codex-common
  • When disabled, OSS provider functions return stubs (None for model lookup, error for model info)
  • Added to full feature bundle for complete builds

Feedback Stub Improvements

  • Fixed API compatibility: upload_feedback now returns anyhow::Result<()> to match real implementation
  • Added proper feature-gated test assertions (not tautological)
  • Added placeholder comments linking to https://github.com/tilework-tech/nori-cli/issues for future Nori feedback integration

Files Changed

  • codex-rs/common/Cargo.toml - Made ollama/lmstudio optional
  • codex-rs/common/src/oss.rs - Conditional compilation for OSS functions
  • codex-rs/tui/Cargo.toml - Added oss-providers feature
  • codex-rs/tui/src/feedback_compat.rs - Improved stub with proper API
  • codex-rs/cli/Cargo.toml - Added oss-providers to full bundle
  • Various docs.md files updated

Testing

  • ✅ Compiles with --no-default-features
  • ✅ Compiles with --features feedback
  • ✅ Compiles with --features oss-providers
  • ✅ All TUI tests pass (513 tests with feedback feature)
  • ✅ All codex-common tests pass (22 tests)

@CSRessel CSRessel merged commit a48cafb into dev Dec 11, 2025
1 of 3 checks passed
@CSRessel CSRessel deleted the feature/release-feature-flags branch December 11, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant