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
- 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
- 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.rs—starforge completeCLI withsuggest,boilerplate,stub,imports, andinfersubcommands (human +--jsonoutput). - Register the new modules and wire the
Completecommand intosrc/main.rs,src/commands/mod.rs, andsrc/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-unregisteredMigratevariant into both dispatch matches, and drop a duplicatepub mod simulate;—masterdid not compile without these.
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
Describe what scenarios have been tested:
- Happy path: boilerplate generation for each kind, suggestions on a partial contract, import/type inference, stub
--writeapplying generated bodies. - Edge cases: empty file (scaffold suggestion), imported-but-unused symbols, un-annotated
letbindings 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.
- 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.
- This PR introduces breaking changes
None — this adds a new, self-contained command and does not alter existing behaviour.
- 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.
N/A — CLI feature.
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