Skip to content

Latest commit

 

History

History
105 lines (74 loc) · 4.17 KB

File metadata and controls

105 lines (74 loc) · 4.17 KB

Description

Adds starforge complete, an intelligent offline completion assistant for Soroban contracts. It suggests context-aware code completions, generates accurate boilerplate, fills in function stubs, suggests imports, and infers types. The engine is rule-based and dependency-free (std-only), so it runs instantly with no network access or model download.

Closes #508

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Changes Made

  • Add src/utils/completion.rs — std-only completion engine: source analysis, context-aware suggestions, boilerplate generation, function-stub completion, import inference, and type inference.
  • Add src/commands/complete.rsstarforge complete CLI with suggest, boilerplate, stub, imports, and infer subcommands (human + --json output).
  • Register the new modules and wire the Complete command into src/main.rs, src/commands/mod.rs, and src/utils/mod.rs.
  • Add tests/completion_assistant_integration.rs — CLI integration tests.
  • Incidental build fix: remove stray match-arm lines left inside enum Commands, wire the previously-unregistered Migrate variant into both dispatch matches, and drop a duplicate pub mod simulate;master did not compile without these.

Testing

How has this been tested?

The std-only engine and the stub-splicing logic were compiled and run standalone with rustc --test (the full crate could not be built in the dev sandbox — see Additional Context). CLI behaviour is covered by integration tests that shell out to the built binary.

Reproduce:

cargo test --lib completion
cargo test --test completion_assistant_integration
  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Coverage

Describe what scenarios have been tested:

  • Happy path: boilerplate generation for each kind, suggestions on a partial contract, import/type inference, stub --write applying generated bodies.
  • Edge cases: empty file (scaffold suggestion), imported-but-unused symbols, un-annotated let bindings incl. mut, brace balance/indentation preserved when splicing stub bodies.
  • Error handling: missing file returns a non-zero exit; unknown boilerplate kind is rejected with the list of valid kinds.

Code Quality Checklist

  • My code follows the style guidelines of this project (cargo fmt)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (cargo clippy -- -D warnings)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The CI checks pass (format, clippy, tests)

cargo fmt, cargo clippy, and the full test suite could not be run locally (offline sandbox); please confirm these in CI.

Breaking Changes

  • This PR introduces breaking changes

None — this adds a new, self-contained command and does not alter existing behaviour.

Documentation

  • README.md updated
  • DEVELOPER_GUIDE.md updated (if applicable)
  • API_REFERENCE.md updated (if applicable)
  • No documentation changes needed

Module- and command-level rustdoc is included; usage is discoverable via starforge complete --help.

Screenshots (if applicable)

N/A — CLI feature.

Additional Context

The full crate could not be compiled in the development sandbox: the crates.io registry was unreachable and tokio's transitive dependencies were not cached. Logic was therefore validated by compiling the std-only portions standalone with rustc --test (23 engine unit tests pass; stub-splicing verified). The thin CLI layer follows existing command patterns (migrate.rs, gas.rs, lint.rs). Please run the checks below in CI.


Note: Make sure all tests pass locally before submitting:

cargo test
cargo fmt --all
cargo clippy -- -D warnings