Skip to content

Conversation

@whizzzkid
Copy link
Contributor

Attempts to fix #259

whizzzkid and others added 8 commits January 28, 2026 09:16
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
Simplify the startup command by removing the ssh-add -l check,
which is unnecessary for launching claude.

Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
Refactor the scope project to be a library-first tool with a thin CLI
wrapper, enabling programmatic usage from other Rust programs.

Changes:
- Add UserInteraction trait for abstracting user prompts (AutoApprove, DenyAll)
- Add ProgressReporter trait for abstracting progress display (NoOpProgress)
- Create CLI-independent options types (AnalyzeOptions, DoctorRunOptions, ConfigLoadOptions)
- Create cli module with InquireInteraction for terminal usage
- Refactor shared/analyze to use UserInteraction trait instead of inquire directly
- Add explicit exports in lib.rs for library consumers
- Rename crate from dev-scope to dx-scope
- Add comprehensive library usage documentation

New modules:
- src/internal/prompts.rs - UserInteraction trait and implementations
- src/internal/progress.rs - ProgressReporter trait and implementations
- src/cli/mod.rs - CLI-specific InquireInteraction
- src/analyze/options.rs - AnalyzeOptions, AnalyzeInput
- src/doctor/options.rs - DoctorRunOptions
- src/shared/config/options.rs - ConfigLoadOptions

BREAKING CHANGE: Crate renamed from dev-scope to dx-scope. Update imports
from `use dev_scope::` to `use dx_scope::`.

Co-Authored-By: Claude (global.anthropic.claude-opus-4-5-20251101-v1:0) <noreply@anthropic.com>
Add library-first API functions that can be used without CLI dependencies:

- doctor::run() - Run health checks programmatically with DoctorRunOptions
- doctor::list() - List available doctor checks
- analyze::process_input() - Analyze various input sources for known errors
- analyze::process_text() - Convenience function for string analysis

The new API returns structured results instead of printing to console,
allowing library users to format output as needed.

Additional changes:
- Make cli module private (pub(crate)) - only InquireInteraction is re-exported
- Add examples/simple-doctor and examples/simple-analyze demonstrating library usage
- Add integration tests for new API functions in tests/lib_api.rs

This enables dx-scope to be used as a library in other Rust projects
without depending on CLI-specific code or forcing console output.

Breaking change: cli module is no longer publicly accessible from lib.rs

BREAKING CHANGE: The cli module is now private and cannot be imported directly.
Use the re-exported InquireInteraction type at the crate root instead.
Reduce scope binary from 231 lines to 110 lines (52% reduction) by
extracting command routing and utility functions to a dedicated
cli module within the binary.

Changes:
- Create src/bin/cli/commands.rs with all routing and formatting logic
- Move handle_command, exec_sub_command, show_config, print_commands,
  and print_version functions from binary to cli module
- Binary now only handles: arg parsing, logging setup, config loading,
  command delegation, and exit

The binary is now a thin wrapper that delegates to the cli module,
making it easier to maintain and understand. This follows the
library-first architecture principle where binaries should be minimal.
Update Cargo.toml and build.rs for crates.io compatibility:

- Change edition from 2024 to 2021 (2024 edition is not yet stable)
- Update build.rs to gracefully handle missing .git directory
  - Provides default values for VERGEN_GIT_* env vars when not in git repo
  - Allows building from crates.io source tarballs that lack .git

These changes ensure the crate can be published to and built from crates.io
where the .git directory is not available.

Note: Wildcard dependencies remain as-is per maintainer preference.
Add deprecation warning to the prelude module to guide users toward
explicit imports from the crate root or specific modules.

The prelude pattern made it unclear what was actually being imported.
With the new library-first design, users should import specific types:

Before (deprecated):
  use dx_scope::prelude::*;

After (recommended):
  use dx_scope::{DoctorRunOptions, AnalyzeOptions, FoundConfig};
  use dx_scope::doctor;
  use dx_scope::analyze;

The prelude remains available for backward compatibility and internal
use, but external users are encouraged to use explicit imports for
better code clarity and IDE support.
Fix compilation errors after switching to Rust 2021 edition:

- Replace let chain syntax with nested if-let (Rust 2024 feature)
- Update examples to use FoundConfig::empty() instead of ConfigOptions
- Remove dependency on CLI types (ConfigOptions) from library examples

Examples now demonstrate pure library usage without CLI dependencies.
The library compiles successfully on Rust 2021 edition.
@whizzzkid whizzzkid changed the base branch from main to feat/dev-container January 28, 2026 11:12
@whizzzkid whizzzkid changed the title feat(devcontainer): ✨ Devcontainer with Claude-Code Support. feat(lib): ✨ Scope as Lib Jan 28, 2026
Add #[allow(dead_code)] to make_prompt_fn which is kept for potential
future use but currently unused. This eliminates the only warning
when building the library.

Library now compiles with zero warnings.
Replace ConfigOptions::default() with FoundConfig::empty() in doctests
for doctor and analyze API modules. ConfigOptions is a CLI-specific type
that doesn't have a Default implementation, while FoundConfig is the
proper library API for programmatic usage.

Fixes 2 doctest compilation errors:
- src/doctor/api.rs line 18
- src/analyze/api.rs line 21

Doctest results: 13 passed (up from 10), 3 failed due to linker OOM
(environment limitation, not code issue).
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
* feat/dev-container:
  fix(claude): rename
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
* feat/dev-container:
  fix: default to mise to manage envs.
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
* feat/dev-container:
  fix: claude broke over npx.
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
Base automatically changed from feat/dev-container to main January 29, 2026 19:55
* main:
  feat(devcontainer): ✨ Devcontainer with Claude-Code Support. (#264)
  ci: Use Gusto self-hosted runners for release workflow (#267)
  Replace cargo-dist with simplified release workflow (#263)

Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
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.

Exposing a library crate

2 participants