Skip to content

feat(genkit-tools/cli): Add docs discovery tools to the CLI#4453

Draft
ssbushi wants to merge 2 commits intosb/mcpDocsImprovementsfrom
sb/cliDocs
Draft

feat(genkit-tools/cli): Add docs discovery tools to the CLI#4453
ssbushi wants to merge 2 commits intosb/mcpDocsImprovementsfrom
sb/cliDocs

Conversation

@ssbushi
Copy link
Contributor

@ssbushi ssbushi commented Feb 5, 2026

Checklist (if applicable):

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ssbushi, I'm Gemini Code Assist1! 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 Genkit CLI by providing direct, integrated access to its documentation. Users can now effortlessly list, read, and search through Genkit's documentation directly from their command line. This functionality is underpinned by a newly established, centralized utility layer for documentation handling, which also incorporates an efficient caching strategy to optimize the retrieval of documentation bundles.

Highlights

  • New CLI Commands for Documentation: Introduced three new CLI commands: 'docs:list' to enumerate available documentation, 'docs:read' to display specific document content, and 'docs:search' to find documentation based on keywords.
  • Centralized Documentation Utilities: Refactored documentation loading and searching logic into a new utility file (genkit-tools/cli/src/utils/docs.ts), making these functions reusable across the CLI.
  • Documentation Bundle Caching: Implemented a caching mechanism for the downloaded documentation bundle with a 1-week Time To Live (TTL), reducing redundant downloads and improving performance.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • genkit-tools/cli/src/cli.ts
    • Added imports for the new documentation-related commands (docsList, docsRead, docsSearch).
    • Registered the new documentation commands to the main CLI program, making them accessible to users.
  • genkit-tools/cli/src/commands/docs.ts
    • New file created to define the implementation of the docs:list, docs:read, and docs:search CLI commands.
  • genkit-tools/cli/src/mcp/docs.ts
    • Removed the previously embedded logic for downloading and parsing the documentation bundle.
    • Removed the custom search implementation, delegating to the new searchDocs utility.
    • Updated to utilize the new loadDocs and searchDocs utility functions for documentation access.
  • genkit-tools/cli/src/utils/docs.ts
    • New file created to centralize documentation-related utility functions.
    • Contains DOCS_URL and DOCS_BUNDLE_FILE_PATH definitions.
    • Includes maybeDownloadDocsBundle function with a 1-week TTL for caching the documentation bundle.
    • Defines the Doc interface for documentation structure.
    • Provides loadDocs for asynchronously loading the documentation bundle.
    • Implements searchDocs for keyword-based documentation search, including scoring and filtering.
Activity
  • The pull request introduces new features to the Genkit CLI.
  • New files were added to encapsulate the logic for documentation discovery tools and shared utilities.
  • Existing core CLI files were modified to integrate these new commands.
  • An existing file (genkit-tools/cli/src/mcp/docs.ts) was refactored to leverage the new shared documentation utilities, improving modularity and reducing code duplication.
  • The author has indicated that manual testing is pending as per the provided checklist.
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 👍 and 👎 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.

Footnotes

  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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new CLI commands (docs:list, docs:search, docs:read) for discovering and reading Genkit documentation. This is achieved by adding a new docs.ts command file and refactoring existing documentation-related logic from mcp/docs.ts into a new shared utility file utils/docs.ts. The refactoring is well-done and improves code reuse. My feedback includes suggestions to improve type safety in error handling and to enhance the readability of the search scoring logic by replacing magic numbers with named constants.

Comment on lines +49 to +51
} catch (e: any) {
logger.error(`Failed to load documentation: ${e.message}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For improved type safety, it's a best practice to catch errors as unknown and then check their type before accessing properties like message. This avoids potential runtime errors if a non-Error object is thrown.

Suggested change
} catch (e: any) {
logger.error(`Failed to load documentation: ${e.message}`);
}
} catch (e: unknown) {
logger.error(`Failed to load documentation: ${e instanceof Error ? e.message : String(e)}`);
}

Comment on lines +83 to +85
} catch (e: any) {
logger.error(`Failed to load documentation: ${e.message}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For improved type safety, it's a best practice to catch errors as unknown and then check their type before accessing properties like message. This avoids potential runtime errors if a non-Error object is thrown.

Suggested change
} catch (e: any) {
logger.error(`Failed to load documentation: ${e.message}`);
}
} catch (e: unknown) {
logger.error(`Failed to load documentation: ${e instanceof Error ? e.message : String(e)}`);
}

Comment on lines +104 to +106
} catch (e: any) {
logger.error(`Failed to load documentation: ${e.message}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For improved type safety, it's a best practice to catch errors as unknown and then check their type before accessing properties like message. This avoids potential runtime errors if a non-Error object is thrown.

Suggested change
} catch (e: any) {
logger.error(`Failed to load documentation: ${e.message}`);
}
} catch (e: unknown) {
logger.error(`Failed to load documentation: ${e instanceof Error ? e.message : String(e)}`);
}

Comment on lines +99 to +104
terms.forEach((term) => {
if (title.includes(term)) score += 10;
if (desc.includes(term)) score += 5;
if (headers.includes(term)) score += 3;
if (file.includes(term)) score += 5;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The scoring logic uses magic numbers (10, 5, 3, 5), which can make the code harder to understand and maintain. It's better to extract these values into named constants to improve readability and make it easier to adjust the scoring in the future.

      const TITLE_SCORE = 10;
      const DESC_SCORE = 5;
      const HEADERS_SCORE = 3;
      const FILE_PATH_SCORE = 5;

      terms.forEach((term) => {
        if (title.includes(term)) score += TITLE_SCORE;
        if (desc.includes(term)) score += DESC_SCORE;
        if (headers.includes(term)) score += HEADERS_SCORE;
        if (file.includes(term)) score += FILE_PATH_SCORE;
      });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant