Skip to content

Feat/ai contract completion assistance - #593

Merged
Nanle-code merged 3 commits into
Nanle-code:masterfrom
Power70:feat/ai-contract-completion-assistance
Jul 23, 2026
Merged

Feat/ai contract completion assistance#593
Nanle-code merged 3 commits into
Nanle-code:masterfrom
Power70:feat/ai-contract-completion-assistance

Conversation

@Power70

@Power70 Power70 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

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.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
  • 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

@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

@Power70 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Nanle-code
Nanle-code merged commit 5559a80 into Nanle-code:master Jul 23, 2026
1 of 10 checks passed
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.

AI Contract Completion Assistant

2 participants