Skip to content

feat(commands): add /commit command - #819

Merged
will-lamerton merged 2 commits into
Nano-Collective:mainfrom
DeepamJha:feature/commit-message-generator
Aug 13, 2026
Merged

will-lamerton merged 2 commits into
Nano-Collective:mainfrom
DeepamJha:feature/commit-message-generator

Conversation

@DeepamJha

Copy link
Copy Markdown
Contributor

Closes #757

Description

Adds a new /commit slash command that generates a Conventional Commit
message from the currently staged Git diff.

The implementation follows the approach discussed in #757:

  • Checks for staged changes before making an LLM request.
  • Reads the staged diff using git diff --cached.
  • Reuses the active conversation LLM client (metadata.client) instead of
    creating a new client.
  • Uses a dedicated system prompt to generate only a Conventional Commit
    message.
  • Returns the generated message without automatically executing
    git commit.
  • Handles missing staged changes, empty model responses, and LLM errors
    using the existing message factory.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Changeset

  • Added a changeset (pnpm changeset) describing this feature for the changelog.

Testing

Automated Tests

  • Added commit.spec.tsx
  • pnpm build
  • pnpm test
  • pnpm test:lint

Manual Testing

  • Tested with OpenRouter

Verified that:

  • /commit warns when no changes are staged.
  • /commit generates a Conventional Commit message from the staged diff.
  • Model errors are surfaced through the existing error message flow.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Documentation updated (if needed)
  • No breaking changes
  • Appropriate logging added using structured logging (see CONTRIBUTING.md#logging)

(No additional logging was required for this command.)

@will-lamerton

Copy link
Copy Markdown
Member

Hey @DeepamJha - thanks for this - the design is right to reuse metadata.client, guarding on staged changes before spending a request, and not auto-running git commit are all the calls I'd have made.

One blocker before this can merge: source/commands/commit.spec.tsx is a copy of copy.spec.tsx. It imports commitCommand but every assertion still references copyCommand, and it stubs clipboardy, which /commit never touches. Running it on your branch gives 7 tests failed / ReferenceError: copyCommand is not defined. It slips past test:types because tsconfig.json excludes *.spec.ts(x), and biome doesn't flag it either - only pnpm test:ava catches it. So the command currently has no coverage. Could you swap it for a spec that stubs execGit/hasStagedChanges and a fake client.chat, covering no-staged-changes, missing client, empty response, and thrown error?

Three smaller things worth fixing in the same pass:

  • The staged diff is sent unbounded, so a staged lockfile can blow the context window. @/tools/git/utils already exports truncateDiff(diff, maxLines) - git-diff.tsx uses it at 500 lines.
  • Add /commit to the command table in docs/features/commands.md (it lists /copy around line 33).
  • Pass --no-ext-diff --no-color so a user's diff.external or textconv config can't change what the model sees.

Nice-to-haves, happy for them to be follow-ups: no streaming callbacks means the UI sits silent on a slow local model, and calling client.chat() directly bypasses onApiCallComplete, so /usage won't count these requests.

@DeepamJha
DeepamJha force-pushed the feature/commit-message-generator branch from 4aaa155 to 4b3445a Compare August 10, 2026 08:13
@DeepamJha

Copy link
Copy Markdown
Contributor Author

Thanks @will-lamerton! I've addressed the review feedback:

Reworked commit.spec.tsx to cover the requested cases with mocked Git dependencies and client.chat.
Added truncateDiff(..., 500) for staged diffs.
Added --no-ext-diff --no-color.
Added /commit to the command documentation.

All local tests/checks are passing, and the updated commit has been pushed.

@akramcodez akramcodez left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I reviewed the updates and verified the requested changes locally. The remaining CI failures are unrelated and also occur on main. Everything looks good from my side.

@will-lamerton

Copy link
Copy Markdown
Member

Love this. Nice job @DeepamJha! Merging :)

@will-lamerton
will-lamerton merged commit 0753374 into Nano-Collective:main Aug 13, 2026
10 of 11 checks passed
AryanNandanwar pushed a commit to AryanNandanwar/nanocoder that referenced this pull request Aug 13, 2026
* feat: add commit command for generating conventional commit messages from staged changes

* fix: address commit command review feedback
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.

[Feature] nanocoder commit (Auto-Commit Message Generator)

3 participants