-
Notifications
You must be signed in to change notification settings - Fork 1
Reorganize Rust code with modular utilities (matching JS pattern) #152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adding CLAUDE.md with task information for AI processing. This file will be removed when the task is complete. Issue: #151
Apply similar modular architecture from PR #150 to the Rust codebase: - Extract trace.rs (152 lines) - Logging and tracing utilities - Extract ansi.rs (194 lines) - ANSI escape code handling - Extract quote.rs (161 lines) - Shell quoting utilities - Update utils.rs (230 lines) - Re-exports and command utilities - Update lib.rs (514 lines) - New module declarations and exports All modules are well under the 1500-line limit. The structure now mirrors the JavaScript modular organization for consistency. Fixes #151 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This reverts commit 4e5d577.
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Does our Rust version support full features set of JavaScript version of library? If not, please ensure all tests are supported and all logic implements the same features. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-10T01:05:04.697Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
Added two new modules to bring Rust closer to JS feature parity: 1. events.rs - Event emitter for ProcessRunner events - StreamEmitter with on(), once(), off(), emit() - EventType enum (Stdout, Stderr, Exit, etc.) - EventData variants for different event payloads - 8 integration tests 2. state.rs - Global state management - ShellSettings with enable/disable/set methods - GlobalState for tracking active runners - Virtual commands enable/disable - Signal handler state tracking - 13 integration tests Total tests: 298 passing (up from 267) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Feature Parity Analysis CompleteIn response to the request to ensure Rust supports the full feature set of the JavaScript library, I've completed a comprehensive analysis and added new modules to improve feature parity. Summary of Changes
Test Coverage
Feature Parity Status
The Rust library now covers the core feature set of the JavaScript version. The remaining features (pipeline and async iteration) are documented as future work items. Work session completed |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Can we use something like $! macro in Rust? Also I want all features to be implemented in this pull request fully, and all test logic should be moved to separate test files, please don't mix tests and logic. In all files, previous or new. |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-10T14:19:12.673Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
This commit adds feature parity with JavaScript implementation: - cmd! macro: Similar to JS $ tagged template literal, provides ergonomic shell command execution with safe value interpolation - Pipeline: Builder pattern for chaining commands with stdout->stdin - StreamingRunner: Async streaming with OutputChunk for real-time output - AsyncIterator trait and IntoStream for async iteration support Tests are organized in separate test files following user feedback. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Implementation CompleteI've addressed the feedback with the following changes: 1.
|
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
Now working session is ended, feel free to review and add any feedback on the solution draft. |
|
Add also |
|
🤖 AI Work Session Started Starting automated work session at 2026-01-10T14:42:34.141Z The PR has been converted to draft mode while work is in progress. This comment marks the beginning of an AI work session. Please wait working session to finish, and provide your feedback. |
- Add s! and cs! macros as aliases to cmd! - Update documentation to use s! and sh! as primary examples - Add comprehensive tests for new macro aliases - All 9 macro tests passing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
✅ Added Macro AliasesI've added the Changes Made
Available Macros (All Aliases)
Example DocumentationThe module documentation now shows: use command_stream::s;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Simple command
let result = s!("echo hello world").await?;
// With interpolation
let name = "John Doe";
let result = s!("echo Hello, {}", name).await?;
Ok(())
}All tests pass and changes have been pushed to the PR branch. |
Summary
This PR addresses issue #151 by applying similar modular architecture changes from PR #150 to the Rust codebase, and adds full feature parity with the JavaScript version.
✅ Completed Work - Full Feature Parity
1. Extracted Utility Modules (~507 lines total)
Created standalone modules matching the JavaScript pattern:
trace.rs(152 lines) - Trace/logging utilitiesansi.rs(194 lines) - ANSI escape code handling utilitiesquote.rs(161 lines) - Shell quoting utilities2. Feature Parity Modules (~1,880 lines total)
Added new modules to match JavaScript functionality:
events.rs(186 lines) - Event emitter for ProcessRunner eventsStreamEmitterwithon(),once(),off(),emit()methodsEventTypeenum (Stdout, Stderr, Exit, Data, etc.)EventDatavariants for different event payloadsstate.rs(230 lines) - Global state managementShellSettingswith bash-like options (errexit, verbose, xtrace, pipefail, nounset)GlobalStatefor tracking active process runnersmacros.rs(~130 lines) - NEWcmd!macro for ergonomic command execution$tagged template literalpipeline.rs(~280 lines) - NEW Pipeline execution supportPipelinebuilder for chaining commandsPipelineExttrait for.pipe()methodstream.rs(~430 lines) - NEW Async streaming supportStreamingRunnerfor real-time output streamingOutputStreamwithOutputChunkenumAsyncIteratortrait andIntoStreamextension3. Module Structure Comparison
$.trace.mjstrace.rs$.ansi.mjsansi.rs$.quote.mjsquote.rs$.stream-emitter.mjsevents.rs$.state.mjsstate.rs$.result.mjs+ utilsutils.rs$tagged templatemacros.rs$.process-runner-pipeline.mjspipeline.rs$.stream-utils.mjsstream.rs4. All Files Under 1500 Lines ✅
All Rust source files remain well under the 1500-line limit:
shell_parser.rsat 565 linesTest Results
Feature Parity Analysis
$\cmd``)cmd!macroUsage Examples
Using
cmd!macro (similar to JavaScript$tagged template):Using Pipeline:
Using StreamingRunner:
Architecture Notes
The modular architecture now fully mirrors the JavaScript implementation:
This PR was created to address issue #151
Fixes #151
🤖 Generated with Claude Code