pal-mcp-server icon indicating copy to clipboard operation
pal-mcp-server copied to clipboard

feat: Add code generator role to CLink

Open JulianPscheid opened this issue 1 month ago • 6 comments

Summary

Adds a new codegen role to CLink, enabling structured code generation through CLI subagents. Complements existing default, planner, and codereviewer roles.

Changes

  • New: systemprompts/clink/default_codegen.txt - CLI-optimized code generation prompt
  • Updated: All CLI configs (gemini.json, claude.json, codex.json) with codegen role
  • Updated: docs/tools/clink.md - documentation with usage examples
  • Updated: tests/test_clink_tool.py - 2 new tests for codegen role

Features

  • Structured code output using <GENERATED-CODE> format
  • Complete implementations with <NEWFILE> and <UPDATED_EXISTING_FILE> tags
  • CLI-optimized with terminal tool usage guidance
  • Cross-CLI support (Gemini, Claude, Codex)
  • Auto-discovered by registry (no code changes needed)

Usage Examples

# Generate new module via Gemini
clink with gemini codegen to create a REST API with authentication

# Major refactoring via Claude
clink codegen with claude to refactor auth system to OAuth2

# Complex feature via Codex
clink with codex codegen to implement payment processing with Stripe

Testing

✅ All tests pass (7/7 in tests/test_clink_tool.py)

  • test_codegen_role_available - verifies role exists for all CLIs
  • test_clink_codegen_role_structured_output - tests structured format ✅ Registry correctly discovers codegen role ✅ Role appears in tool schema enum ✅ All configs validated

Backward Compatibility

✅ No breaking changes ✅ Existing roles unaffected ✅ No code changes (leverages dynamic discovery)

Technical Details

The codegen role is designed for substantial code generation tasks:

  • Creating new features from scratch with multiple files
  • Major refactoring across large sections of code
  • Implementing new modules, components, or subsystems
  • Large-scale updates affecting substantial portions of the codebase

The structured format ensures:

  • Complete, working code without placeholders
  • Step-by-step instructions for implementation
  • Proper file path references for new/modified files
  • Summary conclusion with testing recommendations

The implementation follows CLink's existing architecture:

  1. Role configuration in JSON files points to system prompt
  2. Registry dynamically discovers all roles
  3. Tool schema automatically includes new role in enum
  4. No hardcoded validation or role lists to update

JulianPscheid avatar Nov 11 '25 21:11 JulianPscheid

Summary of Changes

Hello @JulianPscheid, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the CLink tool by introducing a dedicated codegen role. This new capability allows for structured and comprehensive code generation, targeting substantial implementation tasks such as creating new features, refactoring large codebases, or developing new modules. The integration ensures seamless operation across various CLI clients and provides a standardized output format for generated code, streamlining automated development workflows.

Highlights

  • New codegen Role: Introduced a new codegen role to CLink, enabling structured code generation through CLI subagents. This role complements existing default, planner, and codereviewer roles.
  • Configuration Updates: All CLI client configurations (gemini.json, claude.json, codex.json) have been updated to include the new codegen role, pointing to a dedicated system prompt.
  • Documentation and Usage Examples: The docs/tools/clink.md file has been updated to include detailed documentation, usage examples, and a description of the codegen role's capabilities and structured output format.
  • Structured Code Output: The codegen role is designed to produce complete, working code using a structured format with specific tags like <GENERATED-CODE>, <NEWFILE>, <UPDATED_EXISTING_FILE>, and <SUMMARY>, ensuring clarity and ease of integration.
  • New Test Cases: Two new tests, test_codegen_role_available and test_clink_codegen_role_structured_output, have been added to tests/test_clink_tool.py to verify the availability and correct structured output handling of the codegen role across different CLI clients.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Nov 11 '25 21:11 gemini-code-assist[bot]

Thanks for the review, @gemini-code-assist! I've addressed your feedback:

Standardized command examples - Updated both examples to use the consistent clink with <cli> <role> format:

  • Complex Feature Implementation: Now uses clink with codex codegen
  • Major Refactoring: Changed from clink codegen with claude to clink with claude codegen
  • Removed quotes for clarity

All examples in the documentation now follow the same consistent pattern. The changes have been pushed to the PR.

JulianPscheid avatar Nov 11 '25 21:11 JulianPscheid

Thanks for the update, @JulianPscheid! I appreciate you addressing the feedback regarding the standardization of command examples in the documentation. It's great to hear that all examples now follow the consistent clink with <cli> <role> format and that the quotes have been removed for clarity. I'll re-evaluate the pull request with these changes.

gemini-code-assist[bot] avatar Nov 11 '25 21:11 gemini-code-assist[bot]

@codex review

guidedways avatar Nov 18 '25 06:11 guidedways

Codex Review: Didn't find any major issues. :rocket:

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codex what about

  - [P1] Preserve code when summary present — tools/clink.py:333-368
    The new codegen role mandates <SUMMARY> blocks on every response, but _apply_output_limit still treats the presence of a <SUMMARY> as permission to drop the rest of the payload whenever the content exceeds MAX_RESPONSE_CHARS. For substantial codegen tasks (the very use cases described in docs/tools/clink.md—REST APIs, refactors, multi-file modules)
  the <GENERATED-CODE> block will often be >20 kB, so the tool will now return only the short summary and discard 100 % of the generated code whenever the limit is hit. Before this change, large outputs at least returned a truncated excerpt of the code; after this PR any sizeable codegen request that follows the structured prompt becomes unusable.
  _apply_output_limit needs to skip the summary shortcut (or stream the file) when <GENERATED-CODE> is present, otherwise the new role can’t deliver code for the very scenarios it enables.

guidedways avatar Nov 18 '25 07:11 guidedways