Skip to content

Conversation

@Shironex
Copy link
Collaborator

@Shironex Shironex commented Dec 23, 2025

  • Improve AI suggestions by appending the project app specification file, completed features, and the current project backlog to minimize duplicate tasks.

Resolve

Summary by CodeRabbit

  • New Features
    • Suggestions now incorporate existing implemented features and backlog context so recommendations reflect current project state.
  • Bug Fixes
    • Fixed duplicate feature suggestions by using project context and backlog to avoid recommending already-planned or implemented items.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Reads implemented features from .automaker/app_spec.txt and existing backlog features, assembles that context, and injects it into the suggestions prompt so generated feature suggestions avoid duplicating implemented or backlog items.

Changes

Cohort / File(s) Summary
Suggestion generator with context
apps/server/src/routes/suggestions/generate-suggestions.ts
Added helpers to extract <implemented_features> from app_spec.txt and to load existing backlog features; refactored generateSuggestions to call loadExistingContext(projectPath) and embed "ALREADY IMPLEMENTED FEATURES" and "EXISTING FEATURES IN BACKLOG" blocks into the AI prompt, and conditionally append an instruction to avoid duplicates; added debug logging for missing/unreadable resources.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Server
  participant FS as Filesystem
  participant Backlog as FeatureLoader
  participant AI as AI Service

  Client->>Server: request generateSuggestions(projectPath, type)
  Server->>FS: read .automaker/app_spec.txt (getAppSpecPath, secureFs)
  alt app_spec exists
    FS-->>Server: app_spec content
    Server->>Server: extractImplementedFeatures(content)
  else missing/unreadable
    FS-->>Server: error / empty
  end
  Server->>Backlog: load features from .automaker/features/...
  Backlog-->>Server: list of backlog features
  Server->>Server: assemble existingContext (implemented + backlog)
  Server->>AI: send prompt + existingContext -> request suggestions
  AI-->>Server: suggestions
  Server-->>Client: filtered/annotated suggestions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰🌿 I nibble specs beneath the moon,
I fetch the backlog, hum a tune,
I stitch the context, soft and bright,
So suggestions hop in wrong-free light,
New ideas bounded, tidy and white.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title "feat: improve ai suggestions" is vague and generic, failing to convey the specific implementation detail about preventing duplicate suggestions by incorporating app context. Consider a more specific title like "feat: prevent duplicate AI suggestions by including app_spec and backlog context" to clearly communicate the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully addresses all core coding requirements from issue #154: reads app_spec.txt for implemented features [#154], loads existing backlog features [#154], integrates context into the prompt [#154], and maintains backward compatibility when app_spec.txt is missing [#154].
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the context incorporation feature from issue #154; no unrelated modifications are present in the generate-suggestions.ts file.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/improve-ai-suggestions

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Shironex, 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 refines the AI suggestion mechanism by integrating crucial project context directly into the AI's prompt. By feeding the AI information about already implemented features from the app_spec.txt and existing tasks in the project backlog, the system aims to generate more relevant and unique suggestions, thereby minimizing the proposal of duplicate or already completed work.

Highlights

  • Enhanced AI Suggestion Context: The AI suggestion generation process has been improved by providing more comprehensive context to the AI model, aiming to reduce redundant suggestions.
  • Integration of Implemented Features: The system now reads the project's app_spec.txt file to identify and inform the AI about features that have already been implemented, preventing their re-suggestion.
  • Inclusion of Project Backlog: The current project backlog is now loaded and appended to the AI prompt, ensuring the AI is aware of features that are already planned or in progress.
  • Duplicate Task Minimization: A specific instruction has been added to the AI prompt, explicitly telling the model to avoid suggesting features that are either already implemented or present in the backlog.

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

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.

@Shironex Shironex self-assigned this Dec 23, 2025
@Shironex Shironex added the Enhancement Improvements to existing functionality or UI. label Dec 23, 2025
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 enhances the AI suggestion feature by incorporating existing context from the project's specification file and backlog. This is a valuable improvement to prevent duplicate task suggestions. The implementation is well-structured into new helper functions. My review includes a few suggestions to refactor parts of the new code to use more modern, declarative JavaScript/TypeScript constructs, which will improve readability and maintainability.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)

18-39: Consider using a proper XML parser instead of regex.

Parsing XML with regex is fragile and may fail with comments, CDATA sections, nested structures, or other XML edge cases. Consider using a library like fast-xml-parser or the built-in DOMParser for more robust parsing.

🔎 Example using fast-xml-parser
+import { XMLParser } from 'fast-xml-parser';
+
 /**
  * Extract implemented features from app_spec.txt XML content
  */
 function extractImplementedFeatures(specContent: string): string[] {
-  const features: string[] = [];
-
-  // Match <implemented_features>...</implemented_features> section
-  const implementedMatch = specContent.match(
-    /<implemented_features>([\s\S]*?)<\/implemented_features>/
-  );
-
-  if (implementedMatch) {
-    const implementedSection = implementedMatch[1];
-
-    // Extract feature names from <name>...</name> tags
-    const nameRegex = /<name>(.*?)<\/name>/g;
-    let match;
-
-    while ((match = nameRegex.exec(implementedSection)) !== null) {
-      features.push(match[1].trim());
-    }
+  try {
+    const parser = new XMLParser();
+    const parsed = parser.parse(specContent);
+    
+    const implementedFeatures = parsed?.implemented_features;
+    if (!implementedFeatures) return [];
+    
+    // Handle both single feature and array of features
+    const featuresArray = Array.isArray(implementedFeatures) 
+      ? implementedFeatures 
+      : [implementedFeatures];
+    
+    return featuresArray
+      .map(f => f?.name)
+      .filter(name => typeof name === 'string')
+      .map(name => name.trim());
+  } catch (error) {
+    return [];
   }
-
-  return features;
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d50b15e and dbc21c8.

📒 Files selected for processing (1)
  • apps/server/src/routes/suggestions/generate-suggestions.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)

132-148: Good integration of existing context into the prompt.

The context loading and conditional instruction logic correctly avoids suggesting duplicates when existing features are present. The empty string check on line 138 properly handles the case when no context is available.

@Shironex Shironex added the Do Not Merge Use this label if something should not be merged. label Dec 23, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)

22-43: Consider using [\s\S]*? in the name regex for consistency.

The outer regex correctly uses [\s\S]*? to match content including newlines, but the inner regex on line 34 uses .*? which doesn't match newlines by default in JavaScript. While feature names spanning multiple lines are unlikely, using /<name>([\s\S]*?)<\/name>/g would be more consistent and handle edge cases better.

Note: XML entities (e.g., &lt;, &amp;) and CDATA sections are not decoded/handled by this regex-based approach. This should be fine for the "controlled XML structure" mentioned in the comment, but if feature names start containing special characters that require entity encoding, consider migrating to a proper XML parser as noted in the comments.

🔎 Suggested enhancement
-    const nameRegex = /<name>(.*?)<\/name>/g;
+    const nameRegex = /<name>([\s\S]*?)<\/name>/g;
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbc21c8 and e07fba1.

📒 Files selected for processing (1)
  • apps/server/src/routes/suggestions/generate-suggestions.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/server/src/routes/suggestions/generate-suggestions.ts (1)
apps/server/src/services/feature-loader.ts (1)
  • FeatureLoader (22-384)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (2)
apps/server/src/routes/suggestions/generate-suggestions.ts (2)

48-93: Excellent error handling and backward compatibility.

The function gracefully handles missing files and read errors with appropriate debug logging, meeting the acceptance criteria for backward compatibility. The implementation correctly:

  • Uses map().join() for cleaner string building (lines 62, 79-85) ✓
  • Fixes the previous null/undefined issue on line 82 with optional chaining and a fallback to 'Untitled'
  • Returns an empty string when both context sources are unavailable, allowing the caller to proceed without context

137-143: Clean integration of existing context into the prompt.

The implementation correctly:

  • Awaits the async loadExistingContext call
  • Conditionally includes the duplicate-prevention instruction only when context is present
  • Handles the empty-context case gracefully (empty string is falsy, so the ternary on line 143 correctly produces an empty string)

This achieves the PR objective of providing implemented features and backlog context to the AI to minimize duplicate suggestions.

@Shironex Shironex added Ready-To-Merge A feature or bug has been improved/fixed and a final review is requested before merging. and removed Do Not Merge Use this label if something should not be merged. labels Dec 24, 2025
@webdevcody webdevcody merged commit 91eeda3 into main Dec 24, 2025
7 checks passed
@webdevcody webdevcody deleted the feat/improve-ai-suggestions branch December 24, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Improvements to existing functionality or UI. Ready-To-Merge A feature or bug has been improved/fixed and a final review is requested before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Reques] AI Suggestions should check app_spec.txt to avoid duplicates

3 participants