Skip to content

Commit 8a5bc07

Browse files
committed
Fix broken references in Continue
Signed-off-by: worksofliam <[email protected]>
1 parent 01bb812 commit 8a5bc07

File tree

2 files changed

+25
-66
lines changed

2 files changed

+25
-66
lines changed

src/aiProviders/continue/continueContextProvider.ts

Lines changed: 23 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from "../context";
1818
import { DB2_SELF_PROMPT, DB2_SYSTEM_PROMPT } from "../prompts";
1919
import Configuration from "../../configuration";
20+
import { getContextItems } from "../prompt";
2021

2122
export let isContinueActive = false;
2223

@@ -138,71 +139,33 @@ export class db2ContextProvider implements IContextProvider {
138139
): Promise<ContextItem[]> {
139140
const contextItems: ContextItem[] = [];
140141
if (canTalkToDb()) {
141-
const job: JobInfo = this.getCurrentJob();
142-
const schema = this.getDefaultSchema();
142+
const job = this.getCurrentJob();
143143
const fullInput = extras.fullInput;
144144

145-
// 1. SCHEMA Definiton (semantic)
146-
const useSchemaDef: boolean = Configuration.get<boolean>(`ai.useSchemaDefinition`);
147-
148-
if (useSchemaDef) {
149-
const schemaSemantic = await buildSchemaDefinition(schema);
150-
if (schemaSemantic) {
151-
contextItems.push({
152-
name: `SCHEMA Definition`,
153-
description: `${schema} definition`,
154-
content: JSON.stringify(schemaSemantic),
155-
});
156-
}
157-
}
158-
159-
try {
160-
switch (true) {
161-
case fullInput.includes(`*SELF`) || query?.includes(`*SELF`):
162-
// get current self code errors in job
163-
// build promt with error information
164-
// add to contextItems
165-
166-
if (job) {
167-
const selfCodes = await this.getSelfCodes(job);
168-
169-
let prompt = DB2_SELF_PROMPT.join(" ");
170-
prompt += JSON.stringify(selfCodes, null, 2);
171-
172-
contextItems.push({
173-
name: `${job.name}-self`,
174-
description: `SELF code errors for ${job.name}`,
175-
content: prompt,
176-
});
177-
}
178-
179-
break;
180-
default:
181-
// 2. TABLE References
182-
const tablesRefs = await getSqlContextItems(fullInput);
183-
for (const table of tablesRefs) {
184-
contextItems.push({
185-
name: `table definition for ${table.id}`,
186-
content: table.content,
187-
description: `${table.type} definition`,
188-
});
189-
}
190-
191-
break;
192-
}
193-
} catch (error) {
194-
vscode.window.showErrorMessage(
195-
`Failed to query Db2i database: ${error}`
196-
);
197-
throw new Error(`Failed to query Db2i database: ${error}`);
198-
} finally {
199-
// 3. DB2 Guidelines
145+
if (job && fullInput.includes(`*SELF`) || query?.includes(`*SELF`)) {
146+
// get current self code errors in job
147+
// build promt with error information
148+
// add to contextItems
149+
150+
const selfCodes = await this.getSelfCodes(job);
151+
152+
let prompt = DB2_SELF_PROMPT.join(" ");
153+
prompt += JSON.stringify(selfCodes, null, 2);
154+
200155
contextItems.push({
201-
name: `Db2i Guidelines`,
202-
content: DB2_SYSTEM_PROMPT,
203-
description: `Guidelines for Db2i Context provider`,
156+
name: `${job.name}-self`,
157+
description: `SELF code errors for ${job.name}`,
158+
content: prompt,
204159
});
205160
}
161+
162+
const newContextItems = await getContextItems(fullInput, {
163+
withDb2Prompt: true,
164+
})
165+
166+
contextItems.push(...newContextItems.context);
167+
168+
206169
} else {
207170
throw new Error(
208171
`Not connected to the database. Please check your configuration.`

src/aiProviders/continue/listTablesContextProvider.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,8 @@ class ListDb2iTables implements IContextProvider {
8383

8484
} else {
8585
const tablesRefs = await getSqlContextItems(extras.fullInput);
86-
for (const table of tablesRefs) {
87-
contextItems.push({
88-
name: `table definition for ${table.id}`,
89-
content: table.content,
90-
description: `${table.type} definition`,
91-
});
86+
for (const table of tablesRefs.items) {
87+
contextItems.push(table);
9288
}
9389
}
9490
return contextItems;

0 commit comments

Comments
 (0)