Skip to content

Rust SDK is not pretty #141

@markovejnovic

Description

@markovejnovic
✻ Cooked for 17s
 ▐▛███▜▌   Claude Code v2.1.169
▝▜█████▛▘  Opus 4.8 (1M context) with high effort · Claude Max
  ▘▘ ▝▝    ~/Desktop/harmont-cli

  Feature of the week: /loop — run a prompt or slash command on a recurring interval

   Fable 5 is now available with the latest version of Claude Code! Run "claude update" to update to v2.1.170+
 ⚠ 7 setup issues: MCP · /doctor

 ▎ Opus 4.8 is here! Now defaults to high effort · /effort xhigh for your hardest tasks

❯ /clear                                                                                                                                                                                                                                                                                 

❯ with the rust sdk, how do we pass custom flags to clippy, test and build                                                                                                                                                                                                               

⏺ Caveman mode. Find Rust SDK pipeline API first.

⏺ Bash(fd -t d -i rust | head -50)
  ⎿  examples/rust/

  Searched for 1 pattern (ctrl+o to expand)

⏺ Bash(ls -R examples/rust/ | head -60; echo ---; fd -t d -i 'rust' crates/ ; echo ---; grep -rl "rust" crates/hm-dsl-engine/ -i --include=*.py --include=*.ts | head)
  ⎿  Cargo.toml
     README.md
     src
     … +15 lines (ctrl+o to expand)

⏺ Caveman. "Rust SDK" = Rust toolchain in DSL. Read source.
  Read 2 files (ctrl+o to expand)

⏺ Two APIs. Custom flags differ.

  hm.rust.project() — has flags=

  test, clippy, fmt take flags: tuple[str, ...]. Appended to the cargo command.

  import harmont as hm
  proj = hm.rust.project()

  proj.test(flags=("--no-fail-fast", "--", "--nocapture"))
  proj.test(packages=("hm-exec",), flags=("--release",))
  proj.clippy(flags=("--no-deps",))   # → cargo clippy --workspace --tests --locked --no-deps -- -D warnings
  proj.fmt(flags=("--all",))

  Flag insert point (_rust.py:103-132):
  - test → cargo test {scope} --locked{flags}
  - clippy → cargo clippy --workspace --tests --locked{flags} -- -D warnings
  - fmt → cargo fmt --check{flags}
  
  Note clippy flags land before -- -D warnings. Lint-level flags (-W, -A) go after --, so those NOT reachable via flags=. Drop to .sh() for that.

  hm.rust.toolchain() — NO flags=

  build/test/clippy/fmt/doc hardcode cargo string. No flags param. Pass-through **kw go to .sh() (label/cache/etc), not cargo. For custom flags here, use raw .sh():

  tc = hm.rust.toolchain()
  tc.installed.sh(
      ". $HOME/.cargo/env && cd . && cargo build --release --features foo",
      label=":rust: build",
  )

  Summary: want custom cargo flags → use project() + flags=. Want full control (build flags, post--- clippy lints) → raw .sh() off .installed or .warmup.

✻ Cooked for 26s

❯ can we pass packages= to the project?                                                                                                                                                                                                                                                  

⏺ Only test().

  RustProject.test(packages=(...)) exists (_rust.py:103-116) → -p {pkg} per package, else --workspace.

  clippy() and fmt() — NO packages= param. clippy hardcodes --workspace, fmt has no scope.

  Want clippy on one package → use flags=:
  proj.clippy(flags=("-p", "hm-exec"))
  → cargo clippy --workspace --tests --locked -p hm-exec -- -D warnings

  Problem: --workspace still there. Conflicts/overrides. Cargo lets -p narrow but --workspace already set in template = both flags present. May not scope as wanted. Cleaner → raw .sh() off proj.warmup:

  proj.warmup.sh(
      proj.toolchain._wrap("cargo clippy -p hm-exec --tests --locked -- -D warnings"),
      label=":rust: clippy hm-exec",
  )

  _wrap is private (noqa: SLF001 in source), but it's just . $HOME/.cargo/env && cd {path} && {cargo}.

✻ Churned for 8s

❯ one of our users is using project.build(flags=("-p", "datachannel_socket_native_peer")) and that's failing                                                                                                                                                                             

⏺ RustProject has no build method. Look at _rust.py:103-132 — RustProject only has test, clippy, fmt. build lives on RustToolchain (_rust.py:62), and that one takes no flags=/packages= either.

  So proj.build(...) → AttributeError: 'RustProject' object has no attribute 'build'.

  Two fixes:

  Want build as a CI step sharing the warmup → raw .sh() off proj.warmup:
  proj.warmup.sh(
      proj.toolchain._wrap("cargo build -p datachannel_socket_native_peer --locked"),
      label=":rust: build",
  )

  Or via toolchain (no warmup sharing, no flags param either):
  tc = hm.rust.toolchain()
  tc.installed.sh(
      tc._wrap("cargo build -p datachannel_socket_native_peer"),
      label=":rust: build",
  )   

  Real gap: RustProject has no build, and RustToolchain.build rejects flags=/packages=. If users want project.build(flags=...), that's a missing feature. Want me to add build() to RustProject (mirror test() with flags=/packages=)?

✻ Brewed for 7s

We should fix RustProject to have a build command and so on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions