Skip to content

[Feature Request] Context-aware AI Feature Enhancement #152

@cabana8471-arch

Description

@cabana8471-arch

Feature Request: Context-aware AI Feature Enhancement

Problem

The "Enhance with AI" functionality in the Kanban board is a pure text transformation tool that operates completely blind to the project context.

When enhancing a feature description, the AI receives ONLY:

  • The feature description text
  • The enhancement mode (Improve Clarity, Add Technical Details, Simplify, Add Acceptance Criteria)
  • Pre-defined few-shot examples

The AI does NOT receive:

  • Project structure or existing code
  • app_spec.txt content (project overview, technology stack, core capabilities)
  • Other features in the project (potential duplicates)
  • Feature dependencies
  • What has already been implemented

Current Behavior

// Current enhance endpoint - no project context
const response = await client.messages.create({
  model: selectedModel,
  system: systemPrompt,        // Generic enhancement instructions
  messages: [{
    role: "user",
    content: userPrompt        // Only feature text + few-shot examples
  }]
});

Example problem scenario:

  1. User has project with authentication already implemented
  2. User adds feature "Add user authentication"
  3. User clicks "Enhance with AI" → "Add Technical Details"
  4. AI suggests JWT, sessions, OAuth implementation details
  5. AI has NO IDEA the project already has auth using BetterAuth

Expected Behavior

AI enhancement should be context-aware:

  1. Read and understand app_spec.txt
  2. Consider the technology stack when suggesting technical details
  3. Check for similar existing features (warn about duplicates)
  4. Provide suggestions aligned with project architecture
  5. Reference actual project dependencies and patterns

Suggested Implementation

Phase 1: Basic Context (Low effort, high impact)

Pass app_spec.txt overview and technology stack to the enhancement prompt:

// In apps/server/src/routes/enhance-prompt/routes/enhance.ts

const appSpecPath = path.join(projectPath, '.automaker', 'app_spec.txt');
const appSpec = await parseAppSpec(appSpecPath);

const context = {
  projectName: appSpec.projectName,
  overview: appSpec.overview,
  techStack: appSpec.technologyStack,
  coreCapabilities: appSpec.coreCapabilities.slice(0, 10)
};

// Add to system prompt
const contextualSystemPrompt = `
${systemPrompt}

PROJECT CONTEXT:
- Name: ${context.projectName}
- Overview: ${context.overview}
- Tech Stack: ${context.techStack.join(', ')}

Consider this context when enhancing the feature description.
`;

Phase 2: Feature Awareness

Include existing features to detect potential duplicates:

const existingFeatures = await loadFeatures(projectPath);
const featureTitles = existingFeatures.map(f => f.title);

// Add to prompt
const featureContext = `
EXISTING FEATURES (check for duplicates/conflicts):
${featureTitles.slice(0, 30).join('\n')}
`;

Phase 3: Relevance Validation

Add a validation step that warns users if a feature:

  • Might be a duplicate of an existing feature
  • Conflicts with implemented features
  • Doesn't align with project scope
  • Uses technologies not in the stack
// New endpoint or enhancement mode
POST /api/features/validate
{
  "featureDescription": "...",
  "projectPath": "..."
}

// Returns
{
  "isRelevant": true,
  "duplicateWarning": "Similar to feature 'user-auth'",
  "techStackAlignment": ["Uses React - aligned", "Mentions Vue - not in stack"],
  "suggestions": ["Consider using BetterAuth (already in project)"]
}

Files to Modify

File Changes
apps/server/src/routes/enhance-prompt/routes/enhance.ts Add project context loading
apps/server/src/lib/enhancement-prompts.ts Update prompts to use context
apps/server/src/lib/app-spec-parser.ts Create parser for app_spec.txt (new file)
apps/app/src/components/views/board-view/dialogs/add-feature-dialog.tsx Pass projectPath to enhance
apps/app/src/components/views/board-view/dialogs/edit-feature-dialog.tsx Pass projectPath to enhance

Code References

Current enhance endpoint (no context):

  • apps/server/src/routes/enhance-prompt/routes/enhance.ts:96-124

Enhancement prompts (generic):

  • apps/server/src/lib/enhancement-prompts.ts:30-146

Frontend enhance call:

  • apps/app/src/components/views/board-view/dialogs/add-feature-dialog.tsx:178-203

API Changes

Current:

POST /api/enhance-prompt
{
  "originalText": "Add user login",
  "enhancementMode": "technical",
  "model": "sonnet"
}

Proposed:

POST /api/enhance-prompt
{
  "originalText": "Add user login",
  "enhancementMode": "technical",
  "model": "sonnet",
  "projectPath": "/path/to/project"  // NEW - enables context
}

Acceptance Criteria

  • Enhance endpoint accepts optional projectPath parameter
  • When projectPath provided, app_spec.txt is read and parsed
  • Technology stack is included in enhancement prompt context
  • Project overview is included in enhancement prompt context
  • Existing feature titles are optionally included (for duplicate detection)
  • Enhanced descriptions reference actual project technologies
  • Backward compatible - works without projectPath (current behavior)

Impact

  • User Experience: AI suggestions will be relevant to actual project
  • Quality: Reduced duplicate features and conflicting suggestions
  • Trust: Users will trust AI more when it shows project awareness

Labels

enhancement, ai, feature-management, high-priority

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementImprovements to existing functionality or UI.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions