Skip to content

refactor(ai): move Ask AI domain logic out of the provider adapter - #666

Open
Reversean wants to merge 1 commit into
masterfrom
refactor/ai-service-layering
Open

refactor(ai): move Ask AI domain logic out of the provider adapter#666
Reversean wants to merge 1 commit into
masterfrom
refactor/ai-service-layering

Conversation

@Reversean

@Reversean Reversean commented Jul 29, 2026

Copy link
Copy Markdown
Member

src/integrations/ holds adapters to external services, but the Ask AI prompt assembly, the model instruction and the event serialisation live inside the Vercel adapter without importing anything from the provider. Replacing the provider drags the domain with it, and anything applied around the model call can only be reused by importing from another adapter's internals.

The domain modules move to src/services/askAi/ and VercelAIApi is reduced to a transport:

complete({ system, prompt }: CompletionParams): Promise<string>

instructions/cto.ts and inputs/eventSolving.ts move unchanged. The service is renamed AIServiceAskAiService to match the package, so its caller src/resolvers/event.js changes with it.

No behaviour change: generateSuggestion keeps its signature.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the “Ask AI” feature by moving prompt/instruction assembly out of the Vercel AI integration adapter and into a dedicated domain area under src/services/askAi/, leaving src/integrations/vercel-ai/ as a thin transport layer.

Changes:

  • Moved Ask AI domain prompt/instruction modules into src/services/askAi/ and updated AIService.generateSuggestion to assemble { system, prompt } there.
  • Simplified the Vercel adapter API to complete({ system, prompt }): Promise<string> and added unit coverage for it.
  • Added unit tests to validate AIService.generateSuggestion orchestration and the Vercel transport behavior; bumped package version.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/services/ai.ts Moves orchestration into AIService and calls the adapter via complete({ system, prompt }).
src/integrations/vercel-ai/index.ts Refactors the adapter to a transport-style complete method that forwards to generateText.
src/services/askAi/instructions/cto.ts Adds the CTO system instruction in the new domain location.
src/services/askAi/inputs/eventSolving.ts Adds event prompt serialization in the new domain location.
test/services/askAi.test.ts Adds unit tests asserting AIService.generateSuggestion calls the transport with the assembled system/prompt.
test/integrations/vercel-ai.test.ts Adds unit tests asserting adapter forwards to generateText and returns text.
package.json Bumps version to 1.5.10.
Comments suppressed due to low confidence (1)

src/integrations/vercel-ai/index.ts:39

  • Continuation of the indentation issue: this docblock/method body is indented differently from the surrounding codebase (2-space blocks). Reformatting here will keep the file consistent and avoid noisy diffs from auto-formatting.
     * Send a system/prompt pair to the model and return the generated text
     *
     * @param {CompletionParams} params - system instruction and prompt to complete
     * @returns {Promise<string>} text generated by the model
     * @todo add defence against invalid prompt injection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/services/askAi.test.ts Outdated
Comment thread src/integrations/vercel-ai/index.ts Outdated
@Reversean
Reversean force-pushed the refactor/ai-service-layering branch from 6a67733 to 9ba6bdd Compare August 16, 2026 15:02
Base automatically changed from chore/bump-types-node to master August 17, 2026 18:41
The Ask AI prompt assembly, the model instruction and the event serialisation live in src/integrations/vercel-ai/ although none of them import anything from the provider. Replacing the provider drags the domain with it, and anything applied around the model call can only be reused by importing from another adapter's internals.

Move those modules to src/services/askAi/ and reduce VercelAIApi to a transport taking a system/prompt pair. The service moves with them and is renamed to AskAiService, which is why src/resolvers/event.js changes too.
@Reversean
Reversean force-pushed the refactor/ai-service-layering branch from 9ba6bdd to e9f6570 Compare August 17, 2026 18:41
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.

4 participants