Skip to content

feat(shortcuts): Add GitHub issue listing to SCM shortcuts - #282

Merged
edenreich merged 8 commits into
mainfrom
claude/issue-280-20251128-1846
Nov 28, 2025
Merged

edenreich merged 8 commits into
mainfrom
claude/issue-280-20251128-1846

Conversation

@edenreich

@edenreich edenreich commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Summary

Implements /scm issues and /scm issues <number> shortcuts to provide deterministic GitHub issue fetching without using LLM tokens.

Changes

  • Add executeListIssues() to list all repository issues via gh CLI
  • Add executeShowIssue() to fetch specific issue details with comments
  • Return structured JSON data for LLM consumption
  • Add comprehensive test coverage for new functionality
  • Update README.md with SCM shortcuts documentation

Testing

All tests pass:

  • Unit tests for CanExecute() logic
  • Tests for formatting functions
  • Integration with existing SCM shortcut tests

Closes #280

Implement `/scm issues` and `/scm issues <number>` shortcuts to provide
deterministic GitHub issue fetching without using LLM tokens.

Changes:
- Add executeListIssues() to list all repository issues via gh CLI
- Add executeShowIssue() to fetch specific issue details with comments
- Return structured JSON data for LLM consumption
- Add comprehensive test coverage for new functionality
- Update README.md with SCM shortcuts documentation

The shortcuts use GitHub CLI (gh) to fetch issue data directly,
providing context for the LLM without consuming tokens on API calls.

Fixes #280

Co-authored-by: Eden Reich <[email protected]>
@edenreich

Copy link
Copy Markdown
Contributor Author

@claude I thought we can simply create a .infer/shortcuts/scm.yaml when running infer init ? can't we do this? I think it's simpler and it allows the user then to modify those shortcuts or at least it gives them the idea how to add their own shortcuts!

It's a better approach than using code for this simple task.

@claude

claude Bot commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


Analysis Complete ✅

Todo List

  • Read the current PR changes to understand the implementation
  • Check if YAML-based shortcuts already exist in the codebase
  • Review the infer init command implementation
  • Examine the shortcuts system architecture
  • Provide feedback on code-based vs YAML-based approach
  • Discuss trade-offs and recommendations

Analysis

You're absolutely right! The codebase already has a YAML-based custom shortcuts system that would be perfect for SCM shortcuts. Let me explain why your suggestion makes excellent sense:

Current State

  1. Custom Shortcuts System Exists: The codebase already has internal/shortcuts/custom.go which:

    • Loads YAML files from .infer/shortcuts/ directory
    • Supports multiple YAML files (e.g., custom-*.yaml)
    • Each YAML can define multiple shortcuts with name, description, command, args, and working_dir
  2. Current PR Implementation: Your PR implements /scm issues and /scm issues <number> as hardcoded Go code in internal/shortcuts/scm.go

  3. infer init Command: Currently only creates:

    • .infer/config.yaml (or ~/.infer/config.yaml)
    • .infer/.gitignore
    • Does NOT create any example shortcuts

Why YAML-Based Approach is Better

✅ Advantages of YAML Configuration

  1. Consistency: Uses the existing custom shortcuts infrastructure that's already documented in README.md
  2. User Discoverability: Users can see example shortcuts and understand the pattern
  3. Modifiability: Users can easily customize commands (e.g., change JSON format, add filters, modify limit)
  4. Educational: Shows users how to create their own shortcuts
  5. Simplicity: No Go code needed for simple command execution
  6. Maintenance: Easier to update - just edit YAML instead of recompiling

❌ Disadvantages of Current Go Implementation

  1. Hardcoded Logic: Cannot be customized without rebuilding the binary
  2. Complexity: ~100+ lines of Go code for what could be a 10-line YAML file
  3. Pattern Inconsistency: Creates a different pattern from user-defined shortcuts
  4. Limited Reusability: Users can't learn from this to create their own gh shortcuts

Recommended Approach

I recommend refactoring this PR to:

  1. Create .infer/shortcuts/ directory during infer init
  2. Add example YAML file (e.g., .infer/shortcuts/scm.yaml) with:
shortcuts:
  - name: "scm-issues"
    description: "List all GitHub issues for the repository"
    command: "gh"
    args: ["issue", "list", "--json", "number,title,state,author,labels,createdAt,updatedAt", "--limit", "20"]
  
  - name: "scm-issue"
    description: "Show details for a specific GitHub issue (usage: /scm-issue <number>)"
    command: "gh"
    args: ["issue", "view"]
    # Additional args passed by user will be appended (e.g., the issue number)
  1. Keep /scm pr create in Go code since it requires:
    • LLM interaction for generating PR plan
    • Complex git operations
    • State management with GeneratePRPlan()

Implementation Notes

The current custom shortcut system in custom.go already handles:

  • ✅ Command execution via exec.CommandContext
  • ✅ Combined output capture
  • ✅ Error handling
  • ✅ Working directory support
  • ✅ Argument passing (user args are appended to config args)

However, there's one limitation: The current implementation doesn't support placeholder-based argument insertion (e.g., /scm-issue 123 needs to append 123 to args). Looking at line 62 in custom.go:

cmdArgs := append(c.config.Args, args...)

This appends user args to the end, which works perfectly for gh issue view <number> since the issue number comes last!

Next Steps

Would you like me to:

  1. Refactor this PR to use YAML-based shortcuts for /scm issues commands?
  2. Update infer init to create .infer/shortcuts/scm.yaml with these examples?
  3. Keep only the /scm pr create logic in Go code?
  4. Update README.md accordingly?

This would result in a simpler, more maintainable, and more educational implementation! 🎯


Branch |

@edenreich

Copy link
Copy Markdown
Contributor Author

@claude I think we can think of shortcuts that create a snippets, not only execute binaries - then we can migrate also the /scm create. But for right now please just migrate the /scm-issue and /scm-issues

@claude

claude Bot commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Claude finished @edenreich's task —— View job


Migration Complete ✅

Todo List

  • Read current PR changes to understand implementation
  • Review infer init command structure
  • Review custom shortcuts system
  • Create .infer/shortcuts/scm.yaml template
  • Update cmd/init.go to create shortcuts directory and file
  • Remove issue-related code from internal/shortcuts/scm.go
  • Update tests in internal/shortcuts/scm_test.go
  • Update README.md documentation
  • Build and verify changes compile
  • Commit and push changes

Summary

Successfully migrated /scm-issue and /scm-issues shortcuts from Go code to YAML-based configuration! 🎉

What Changed

✅ Created YAML-based shortcuts:

  • New file: .infer/shortcuts/scm.yaml with /scm-issues and /scm-issue shortcuts
  • Users can now customize these shortcuts (change limits, filters, JSON fields, etc.)
  • Provides a clear example for users to create their own GitHub CLI shortcuts

✅ Updated infer init command:

  • Now creates .infer/shortcuts/ directory automatically
  • Generates scm.yaml with example GitHub issue shortcuts
  • Shows users how to add custom shortcuts in the initialization output

✅ Simplified Go code:

  • Removed ~110 lines of Go code from internal/shortcuts/scm.go
  • Removed executeListIssues(), executeShowIssue(), formatting functions
  • Kept only /scm pr create as built-in (requires LLM for PR plan generation)
  • Updated tests to match simplified implementation

✅ Enhanced documentation:

  • Updated README.md with clear sections for built-in vs YAML-based shortcuts
  • Added customization examples showing how to modify the YAML
  • Documented the benefits of the YAML approach

Benefits of This Approach

  1. User Empowerment: Users can easily customize shortcuts without rebuilding the binary
  2. Educational: Provides concrete examples of how to create custom shortcuts
  3. Simpler Codebase: Less hardcoded logic, easier to maintain
  4. Consistency: Uses the existing custom shortcuts infrastructure
  5. Flexibility: Users can add filters, change output format, or create new GitHub CLI shortcuts

Testing

  • ✅ All tests pass (go test ./internal/shortcuts -v)
  • ✅ Binary compiles successfully
  • ✅ YAML structure matches existing custom shortcuts format

Branch |

edenreich and others added 7 commits November 28, 2025 21:08
- Move /scm-issues and /scm-issue from Go code to YAML-based shortcuts
- Update infer init to create .infer/shortcuts/scm.yaml with example shortcuts
- Remove executeListIssues, executeShowIssue, and related formatting functions
- Update tests to reflect simplified SCM shortcut implementation
- Update README.md to document YAML-based approach with customization examples
- Keep /scm pr create as built-in shortcut (requires LLM interaction)

Benefits of YAML approach:
- Users can easily customize shortcuts (change filters, limits, format)
- Provides educational examples for creating custom shortcuts
- Simpler codebase with less hardcoded logic
- Consistent with existing custom shortcuts infrastructure

Co-authored-by: Eden Reich <[email protected]>
@edenreich
edenreich merged commit 80aaebc into main Nov 28, 2025
@edenreich
edenreich deleted the claude/issue-280-20251128-1846 branch November 28, 2025 21:03
inference-gateway-releaser Bot pushed a commit that referenced this pull request Nov 28, 2025
## [0.70.0](v0.69.19...v0.70.0) (2025-11-28)

### 🚀 Features

* **shortcuts:** Add GitHub issue listing to SCM shortcuts ([#282](#282)) ([80aaebc](80aaebc)), closes [#280](#280)

### 📚 Documentation

* Add docs about /init-github-action shortcut ([18e89e3](18e89e3))
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.70.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Make it simple to fetch github issues deterministically

1 participant