@@ -12,52 +12,52 @@ import {
12
12
const TEST_CONTEXT_SIZE = 20 ;
13
13
14
14
describe ( "Watch mode trigger pattern matching" , ( ) => {
15
- it ( "should detect double-slash (JS-style) AI triggers" , ( ) => {
15
+ it ( "should detect double-slash (JS-style) CODEX triggers" , ( ) => {
16
16
const content = `
17
17
function testFunction() {
18
18
// This is a normal comment
19
- // Fix this bug, AI!
19
+ // CODEX: Fix this bug
20
20
return 1 + 1;
21
21
}
22
22
` ;
23
23
24
24
const matches = findAllTriggers ( content ) ;
25
25
26
26
expect ( matches . length ) . toBe ( 1 ) ;
27
- expect ( matches [ 0 ] ! [ 0 ] ) . toContain ( "Fix this bug, AI! " ) ;
27
+ expect ( matches [ 0 ] ! [ 0 ] ) . toContain ( "// CODEX: Fix this bug" ) ;
28
28
expect ( matches [ 0 ] ! [ 1 ] ) . toBe ( "Fix this bug" ) ;
29
29
} ) ;
30
30
31
- it ( "should detect hash (Python/Ruby-style) AI triggers " , ( ) => {
31
+ it ( "should detect CODEX triggers with different indentation " , ( ) => {
32
32
const content = `
33
33
def test_function():
34
34
# This is a normal comment
35
- # What does this function do, AI?
35
+ // CODEX: What does this function do
36
36
return 1 + 1
37
37
` ;
38
38
39
39
const matches = findAllTriggers ( content ) ;
40
40
41
41
expect ( matches . length ) . toBe ( 1 ) ;
42
- expect ( matches [ 0 ] ! [ 0 ] ) . toContain ( "# What does this function do, AI? " ) ;
42
+ expect ( matches [ 0 ] ! [ 0 ] ) . toContain ( "// CODEX: What does this function do" ) ;
43
43
expect ( matches [ 0 ] ! [ 1 ] ) . toBe ( "What does this function do" ) ;
44
44
} ) ;
45
45
46
46
47
- it ( "should detect multiple AI triggers in a single file" , ( ) => {
47
+ it ( "should detect multiple CODEX triggers in a single file" , ( ) => {
48
48
const content = `
49
49
function testFunction() {
50
- // Fix this bug, AI!
50
+ // CODEX: Fix this bug
51
51
return 1 + 1;
52
52
}
53
53
54
54
function anotherFunction() {
55
- # What does this function do, AI?
55
+ // CODEX: What does this function do
56
56
return 2 + 2;
57
57
}
58
58
59
59
function thirdFunction() {
60
- -- Optimize this algorithm, AI!
60
+ // CODEX: Optimize this algorithm
61
61
return 3 + 3;
62
62
}
63
63
` ;
@@ -70,24 +70,24 @@ describe("Watch mode trigger pattern matching", () => {
70
70
expect ( matches [ 2 ] ! [ 1 ] ) . toBe ( "Optimize this algorithm" ) ;
71
71
} ) ;
72
72
73
- it ( "should handle AI! pattern with question mark " , ( ) => {
73
+ it ( "should handle CODEX pattern with question" , ( ) => {
74
74
const content = `
75
75
function testFunction() {
76
- // What's going on here, AI ?
76
+ // CODEX: What's going on here?
77
77
return 1 + 1;
78
78
}
79
79
` ;
80
80
81
81
const matches = findAllTriggers ( content ) ;
82
82
83
83
expect ( matches . length ) . toBe ( 1 ) ;
84
- expect ( matches [ 0 ] ! [ 1 ] ) . toBe ( "What's going on here" ) ;
84
+ expect ( matches [ 0 ] ! [ 1 ] ) . toBe ( "What's going on here? " ) ;
85
85
} ) ;
86
86
87
- it ( "should handle AI! pattern with exclamation mark " , ( ) => {
87
+ it ( "should handle CODEX pattern with imperative " , ( ) => {
88
88
const content = `
89
89
function testFunction() {
90
- // Fix this, AI!
90
+ // CODEX: Fix this
91
91
return 1 + 1;
92
92
}
93
93
` ;
@@ -98,12 +98,12 @@ describe("Watch mode trigger pattern matching", () => {
98
98
expect ( matches [ 0 ] ! [ 1 ] ) . toBe ( "Fix this" ) ;
99
99
} ) ;
100
100
101
- it ( "should ignore non-AI comments" , ( ) => {
101
+ it ( "should ignore non-CODEX comments" , ( ) => {
102
102
const content = `
103
103
function testFunction() {
104
104
// This is a normal comment
105
- // AI is an interesting topic
106
- // This uses an AI model
105
+ // CODEX is a great tool
106
+ // This uses a CODEX model
107
107
return 1 + 1;
108
108
}
109
109
` ;
@@ -113,19 +113,18 @@ describe("Watch mode trigger pattern matching", () => {
113
113
expect ( matches . length ) . toBe ( 0 ) ;
114
114
} ) ;
115
115
116
- it ( "should detect SQL-style (--) AI triggers " , ( ) => {
116
+ it ( "should not detect SQL-style (--) comments with the new pattern " , ( ) => {
117
117
const content = `
118
118
SELECT * FROM users
119
119
-- This is a normal comment
120
- -- Optimize this query, AI!
120
+ -- CODEX: Optimize this query
121
121
WHERE age > 18;
122
122
` ;
123
123
124
124
const matches = findAllTriggers ( content ) ;
125
125
126
- expect ( matches . length ) . toBe ( 1 ) ;
127
- expect ( matches [ 0 ] ! [ 0 ] ) . toContain ( "-- Optimize this query, AI!" ) ;
128
- expect ( matches [ 0 ] ! [ 1 ] ) . toBe ( "Optimize this query" ) ;
126
+ // Should not match because the pattern only looks for // CODEX:
127
+ expect ( matches . length ) . toBe ( 0 ) ;
129
128
} ) ;
130
129
131
130
@@ -163,7 +162,7 @@ describe("Watch mode trigger pattern matching", () => {
163
162
} ) ;
164
163
} ) ;
165
164
166
- describe ( "Context extraction around AI triggers" , ( ) => {
165
+ describe ( "Context extraction around CODEX triggers" , ( ) => {
167
166
it ( "should extract the correct context around a trigger in the middle of the file" , ( ) => {
168
167
const content = `// File header
169
168
import { useState } from 'react';
@@ -173,7 +172,7 @@ function Counter() {
173
172
// State initialization
174
173
const [count, setCount] = useState(0);
175
174
176
- // Fix this increment function, AI!
175
+ // CODEX: Fix this increment function
177
176
const increment = () => {
178
177
setCount(count); // Bug: doesn't increment
179
178
};
@@ -206,7 +205,7 @@ export default Counter;`;
206
205
207
206
// Should include appropriate context around the trigger (the entire file in this case)
208
207
// Use includes instead of exact equality to handle whitespace differences
209
- expect ( context ) . toContain ( "// Fix this increment function, AI! " ) ;
208
+ expect ( context ) . toContain ( "// CODEX: Fix this increment function" ) ;
210
209
211
210
// Should extract the instruction correctly
212
211
expect ( instruction ) . toBe ( "Fix this increment function" ) ;
@@ -217,7 +216,7 @@ export default Counter;`;
217
216
const fileLines = Array . from ( { length : 100 } , ( _ , i ) => `// Line ${ i + 1 } ` ) ;
218
217
219
218
// Insert the trigger at line 50
220
- fileLines [ 49 ] = "// Optimize this code, AI! " ;
219
+ fileLines [ 49 ] = "// CODEX: Optimize this code" ;
221
220
222
221
const content = fileLines . join ( "\n" ) ;
223
222
const matches = findAllTriggers ( content ) ;
@@ -234,14 +233,14 @@ export default Counter;`;
234
233
expect ( contextLines . length ) . toBeGreaterThanOrEqual ( 41 ) ; // At least the trigger line + 20 before + 20 after
235
234
236
235
// Should include the trigger line
237
- expect ( context ) . toContain ( "// Optimize this code, AI! " ) ;
236
+ expect ( context ) . toContain ( "// CODEX: Optimize this code" ) ;
238
237
239
238
// Should extract the instruction correctly
240
239
expect ( instruction ) . toBe ( "Optimize this code" ) ;
241
240
} ) ;
242
241
243
242
it ( "should handle triggers at the beginning of the file" , ( ) => {
244
- const content = `// Explain this code, AI!
243
+ const content = `// CODEX: Explain this code
245
244
function complexFunction() {
246
245
return [1, 2, 3].map(x => x * 2).reduce((a, b) => a + b, 0);
247
246
}` ;
@@ -265,7 +264,7 @@ function complexFunction() {
265
264
const content = `function complexFunction() {
266
265
return [1, 2, 3].map(x => x * 2).reduce((a, b) => a + b, 0);
267
266
}
268
- // Explain this code, AI! ` ;
267
+ // CODEX: Explain this code` ;
269
268
270
269
const matches = findAllTriggers ( content ) ;
271
270
0 commit comments