File tree Expand file tree Collapse file tree 7 files changed +31
-23
lines changed
src/services/ghost/strategies Expand file tree Collapse file tree 7 files changed +31
-23
lines changed Original file line number Diff line number Diff line change @@ -24,11 +24,14 @@ export class AutoTriggerStrategy extends BasePromptStrategy {
2424 /**
2525 * System instructions for auto-trigger
2626 */
27- protected getSpecificSystemInstructions ( ) : string {
28- return `Task: Subtle Auto-Completion
27+ getSystemInstructions ( ) : string {
28+ return (
29+ this . getBaseSystemInstructions ( ) +
30+ `Task: Subtle Auto-Completion
2931Provide non-intrusive completions after a typing pause. Be conservative and helpful.
3032
3133`
34+ )
3235 }
3336
3437 /**
Original file line number Diff line number Diff line change @@ -24,16 +24,6 @@ export abstract class BasePromptStrategy implements PromptStrategy {
2424 */
2525 abstract canHandle ( context : GhostSuggestionContext ) : boolean
2626
27- /**
28- * Generates system instructions for the AI model
29- */
30- getSystemInstructions ( ) : string {
31- const baseInstructions = this . getBaseSystemInstructions ( )
32- const specificInstructions = this . getSpecificSystemInstructions ( )
33-
34- return `${ baseInstructions } ${ specificInstructions } `
35- }
36-
3727 /**
3828 * Gets the base system instructions that apply to all strategies
3929 */
@@ -82,7 +72,7 @@ EXAMPLE:
8272 * Gets strategy-specific system instructions
8373 * Must be implemented by each strategy
8474 */
85- protected abstract getSpecificSystemInstructions ( ) : string
75+ abstract getSystemInstructions ( ) : string
8676
8777 /**
8878 * Generates the user prompt with context
Original file line number Diff line number Diff line change @@ -30,8 +30,10 @@ export class CommentDrivenStrategy extends BasePromptStrategy {
3030 return isComment && ! context . userInput // User input takes precedence
3131 }
3232
33- protected getSpecificSystemInstructions ( ) : string {
34- return `You are an expert code generation assistant that implements code based on comments.
33+ getSystemInstructions ( ) : string {
34+ return (
35+ this . getBaseSystemInstructions ( ) +
36+ `You are an expert code generation assistant that implements code based on comments.
3537
3638## Core Responsibilities:
37391. Read and understand the comment's intent
@@ -63,6 +65,7 @@ export class CommentDrivenStrategy extends BasePromptStrategy {
6365- Do not add explanatory comments unless necessary for complex logic
6466- Ensure the code is production-ready
6567- When using search/replace format, include ALL existing code to preserve it`
68+ )
6669 }
6770
6871 getUserPrompt ( context : GhostSuggestionContext ) : string {
Original file line number Diff line number Diff line change @@ -25,8 +25,10 @@ export class InlineCompletionStrategy extends BasePromptStrategy {
2525 return hasContentBefore && ! context . userInput && ! context . range . isEmpty === false && isNotAtEnd
2626 }
2727
28- protected getSpecificSystemInstructions ( ) : string {
29- return `You are an expert code completion assistant specializing in inline completions.
28+ getSystemInstructions ( ) : string {
29+ return (
30+ this . getBaseSystemInstructions ( ) +
31+ `You are an expert code completion assistant specializing in inline completions.
3032
3133## Core Responsibilities:
32341. Complete partial statements and expressions
@@ -63,6 +65,7 @@ export class InlineCompletionStrategy extends BasePromptStrategy {
6365- Complete just enough to finish the current expression
6466- Ensure syntactic correctness
6567- Match the existing code style`
68+ )
6669 }
6770
6871 getUserPrompt ( context : GhostSuggestionContext ) : string {
Original file line number Diff line number Diff line change @@ -25,8 +25,10 @@ export class NewLineCompletionStrategy extends BasePromptStrategy {
2525 /**
2626 * System instructions for new line completion
2727 */
28- protected getSpecificSystemInstructions ( ) : string {
29- return `Task: Proactive Code Completion for New Lines
28+ getSystemInstructions ( ) : string {
29+ return (
30+ this . getBaseSystemInstructions ( ) +
31+ `Task: Proactive Code Completion for New Lines
3032The user has created a new line. Suggest the most logical next code based on context.
3133
3234Completion Guidelines:
@@ -59,6 +61,7 @@ Important:
5961- Respect existing code patterns and comments
6062- Maintain consistent style
6163- Consider the most likely next step`
64+ )
6265 }
6366
6467 /**
Original file line number Diff line number Diff line change @@ -17,8 +17,10 @@ export class SelectionRefactorStrategy extends BasePromptStrategy {
1717 return ! ! ( context . range && ! context . range . isEmpty && ! context . userInput )
1818 }
1919
20- protected getSpecificSystemInstructions ( ) : string {
21- return `You are an expert code refactoring assistant. Your task is to improve selected code while maintaining its functionality.
20+ getSystemInstructions ( ) : string {
21+ return (
22+ this . getBaseSystemInstructions ( ) +
23+ `You are an expert code refactoring assistant. Your task is to improve selected code while maintaining its functionality.
2224
2325## Core Responsibilities:
24261. Analyze the selected code for improvement opportunities
@@ -44,6 +46,7 @@ export class SelectionRefactorStrategy extends BasePromptStrategy {
4446- Do not include explanations outside the code
4547
4648Remember: The goal is to improve the code quality while keeping the exact same behavior.`
49+ )
4750 }
4851
4952 getUserPrompt ( context : GhostSuggestionContext ) : string {
Original file line number Diff line number Diff line change @@ -22,8 +22,10 @@ export class UserRequestStrategy extends BasePromptStrategy {
2222 /**
2323 * System instructions specific to user requests
2424 */
25- protected getSpecificSystemInstructions ( ) : string {
26- return `Task: Execute User's Explicit Request
25+ getSystemInstructions ( ) : string {
26+ return (
27+ this . getBaseSystemInstructions ( ) +
28+ `Task: Execute User's Explicit Request
2729You are responding to a direct user instruction. Your primary goal is to fulfill their specific request accurately.
2830
2931Priority Order:
@@ -48,6 +50,7 @@ Common Request Patterns:
4850- "add comments" → add JSDoc or inline comments
4951- "extract function" → move selected code to a new function
5052- "fix" → resolve errors, warnings, or obvious issues`
53+ )
5154 }
5255
5356 /**
You can’t perform that action at this time.
0 commit comments