Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 18, 2025

Replaces placeholder JSDoc descriptions with AI-generated contextual descriptions using OpenAI. Merged with main branch to include support for JSX, TSX, and Vue Single File Components.

Changes

New AIService class (src/ai-service.ts)

  • Integrates OpenAI API for description generation
  • Falls back to placeholder text on API failure or when disabled
  • Configurable model selection (default: gpt-3.5-turbo)

CLI enhancements (src/cli.ts)

  • --ai flag to enable AI generation
  • --api-key <key> for API key (or use OPENAI_API_KEY env var)
  • --model <model> for model selection

Refactored generation pipeline (src/index.ts)

  • Async processing to support AI API calls
  • String-based insertion instead of TypeScript transformer (more reliable with comments)
  • Recursive AST traversal for both function declarations and arrow functions
  • Multi-format file support: JavaScript (.js), TypeScript (.ts), JSX (.jsx), TSX (.tsx), and Vue (.vue)
  • Vue SFC handling with template, script, and style section preservation
  • Fixed regex patterns to properly handle closing tags with attributes (security fix)

Usage

# Without AI (unchanged behavior)
jsdoc-builder example.ts

# With AI
export OPENAI_API_KEY=sk-...
jsdoc-builder example.ts --ai

# Works with JSX, TSX, and Vue files
jsdoc-builder component.jsx
jsdoc-builder component.vue --ai

Before:

/**
 * @description Press Your { Function calculateDiscount } Description
 * @param {number} price
 * @param {number} discount
 * @returns {number}
 */
function calculateDiscount(price: number, discount: number): number {
  return price - (price * discount / 100);
}

After (with --ai):

/**
 * @description Calculates the discounted price by subtracting the percentage discount from the original price
 * @param {number} price
 * @param {number} discount
 * @returns {number}
 */
function calculateDiscount(price: number, discount: number): number {
  return price - (price * discount / 100);
}

Merge & Security

  • Merged with main branch to include JSX, TSX, and Vue file support
  • Resolved all merge conflicts
  • Fixed regex security vulnerabilities (CodeQL scan passes with 0 alerts)

Backward compatible—works identically without --ai flag.

Original prompt

This section details on the original issue you should resolve

<issue_title>When users create JSDOC with commands, I want to make it flexible by utilizing ai.</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 18, 2025 04:23
Co-authored-by: klmhyeonwoo <19422885+klmhyeonwoo@users.noreply.github.com>
Co-authored-by: klmhyeonwoo <19422885+klmhyeonwoo@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement AI-driven flexibility for JSDOC commands Add AI-powered JSDoc description generation with OpenAI Nov 18, 2025
Copilot AI requested a review from klmhyeonwoo November 18, 2025 04:28
@klmhyeonwoo klmhyeonwoo marked this pull request as ready for review November 18, 2025 04:34
@klmhyeonwoo
Copy link
Owner

@copilot plz fix conflicts branch

…SDoc generation

Co-authored-by: klmhyeonwoo <19422885+klmhyeonwoo@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot plz fix conflicts branch

Fixed merge conflicts with main branch. The branch now includes both AI-powered JSDoc generation and support for JSX, TSX, and Vue files. All conflicts resolved and tested successfully. (commit 794157c)

Co-authored-by: klmhyeonwoo <19422885+klmhyeonwoo@users.noreply.github.com>
Copilot AI changed the title Add AI-powered JSDoc description generation with OpenAI Add AI-powered JSDoc description generation with OpenAI and multi-format support Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When users create JSDOC with commands, I want to make it flexible by utilizing ai.

2 participants