Elffuss BraidHub

kikocis/continue public

chore: foramt
Changesete1e7a7d5fb5561e71a38e76102a0d392f18c4eb77125cb9e63e4c62ba013086a
AuthorNate <sestinj@gmail.com> · 2025-08-23 11:28 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-23 11:28 -07:00
Parents58306607ad94

Browse the files at this changeset

7 files changed

modified extensions/cli/src/args.prompt.test.ts +33 −5
@@ -22,13 +22,28 @@
2222 });
2323
2424 it("should parse multiple prompts from multiple --prompt flags", () => {
25- process.argv = ["node", "script.js", "--prompt", "prompt1", "--prompt", "prompt2"];
25+ process.argv = [
26+ "node",
27+ "script.js",
28+ "--prompt",
29+ "prompt1",
30+ "--prompt",
31+ "prompt2",
32+ ];
2633 const result = parseArgs();
2734 expect(result.prompts).toEqual(["prompt1", "prompt2"]);
2835 });
2936
3037 it("should handle mixed flags including --prompt", () => {
31- process.argv = ["node", "script.js", "--config", "myconfig", "--prompt", "myprompt", "--resume"];
38+ process.argv = [
39+ "node",
40+ "script.js",
41+ "--config",
42+ "myconfig",
43+ "--prompt",
44+ "myprompt",
45+ "--resume",
46+ ];
3247 const result = parseArgs();
3348 expect(result.configPath).toBe("myconfig");
3449 expect(result.prompts).toEqual(["myprompt"]);
@@ -36,14 +51,27 @@
3651 });
3752
3853 it("should not include --prompt value in non-flag arguments", () => {
39- process.argv = ["node", "script.js", "--prompt", "prompt-value", "actual-prompt"];
54+ process.argv = [
55+ "node",
56+ "script.js",
57+ "--prompt",
58+ "prompt-value",
59+ "actual-prompt",
60+ ];
4061 const result = parseArgs();
4162 expect(result.prompts).toEqual(["prompt-value"]);
4263 expect(result.prompt).toBe("actual-prompt");
4364 });
4465
4566 it("should handle both --rule and --prompt flags", () => {
46- process.argv = ["node", "script.js", "--rule", "my-rule", "--prompt", "my-prompt"];
67+ process.argv = [
68+ "node",
69+ "script.js",
70+ "--rule",
71+ "my-rule",
72+ "--prompt",
73+ "my-prompt",
74+ ];
4775 const result = parseArgs();
4876 expect(result.rules).toEqual(["my-rule"]);
4977 expect(result.prompts).toEqual(["my-prompt"]);
@@ -53,4 +81,4 @@
5381 const result = await processPromptOrRule("This is a direct prompt");
5482 expect(result).toBe("This is a direct prompt");
5583 });
56-});
No newline at the end of the file
84+});
modified extensions/cli/src/args.test.ts +18 −6
@@ -269,7 +269,9 @@
269269 statusText: "Not Found",
270270 } as Response);
271271
272- await expect(processPromptOrRule("continuedev/nonexistent-rule")).rejects.toThrow(
272+ await expect(
273+ processPromptOrRule("continuedev/nonexistent-rule"),
274+ ).rejects.toThrow(
273275 'Failed to load rule from hub "continuedev/nonexistent-rule": HTTP 404: Not Found',
274276 );
275277 });
@@ -277,7 +279,9 @@
277279 it("should handle network errors when loading from hub", async () => {
278280 mockFetch.mockRejectedValue(new Error("Network error"));
279281
280- await expect(processPromptOrRule("continuedev/sentry-nextjs")).rejects.toThrow(
282+ await expect(
283+ processPromptOrRule("continuedev/sentry-nextjs"),
284+ ).rejects.toThrow(
281285 'Failed to load rule from hub "continuedev/sentry-nextjs": Network error',
282286 );
283287 });
@@ -285,7 +289,9 @@
285289 it("should handle invalid slug format", async () => {
286290 // "invalid-slug" doesn't contain "/" so it's treated as direct content, not a hub slug
287291 // Let's test with a slug that has wrong format but contains "/"
288- await expect(processPromptOrRule("invalid/slug/too/many/parts")).rejects.toThrow(
292+ await expect(
293+ processPromptOrRule("invalid/slug/too/many/parts"),
294+ ).rejects.toThrow(
289295 'Invalid hub slug format. Expected "owner/package", got: invalid/slug/too/many/parts',
290296 );
291297 });
@@ -300,7 +306,9 @@
300306 arrayBuffer: () => Promise.resolve(zipBuffer),
301307 } as Response);
302308
303- await expect(processPromptOrRule("continuedev/empty-rule")).rejects.toThrow(
309+ await expect(
310+ processPromptOrRule("continuedev/empty-rule"),
311+ ).rejects.toThrow(
304312 'Failed to load rule from hub "continuedev/empty-rule": No rule content found in downloaded zip file',
305313 );
306314 });
@@ -316,7 +324,9 @@
316324 arrayBuffer: () => Promise.resolve(zipBuffer),
317325 } as Response);
318326
319- await expect(processPromptOrRule("continuedev/directory-only")).rejects.toThrow(
327+ await expect(
328+ processPromptOrRule("continuedev/directory-only"),
329+ ).rejects.toThrow(
320330 'Failed to load rule from hub "continuedev/directory-only": No rule content found in downloaded zip file',
321331 );
322332 });
@@ -373,7 +383,9 @@
373383 arrayBuffer: () => Promise.resolve(invalidZipBuffer),
374384 } as Response);
375385
376- await expect(processPromptOrRule("continuedev/corrupted-zip")).rejects.toThrow(
386+ await expect(
387+ processPromptOrRule("continuedev/corrupted-zip"),
388+ ).rejects.toThrow(
377389 'Failed to load rule from hub "continuedev/corrupted-zip"',
378390 );
379391 });
modified extensions/cli/src/args.ts +12 −14
@@ -90,20 +90,12 @@
9090 */
9191 export async function processPromptOrRule(spec: string): Promise<string> {
9292 // If it looks like a hub slug (contains / but doesn't start with . or /)
93- if (
94- spec.includes("/") &&
95- !spec.startsWith(".") &&
96- !spec.startsWith("/")
97- ) {
93+ if (spec.includes("/") && !spec.startsWith(".") && !spec.startsWith("/")) {
9894 return await loadRuleFromHub(spec);
9995 }
10096
10197 // If it looks like a file path (contains . or / or ends with common file extensions)
102- if (
103- spec.includes(".") ||
104- spec.includes("/") ||
105- spec.includes("\\")
106- ) {
98+ if (spec.includes(".") || spec.includes("/") || spec.includes("\\")) {
10799 return loadRuleFromFile(spec);
108100 }
109101
@@ -186,20 +178,26 @@
186178 if (promptIndex + 1 >= args.length) {
187179 throw new Error("--prompt flag requires a value");
188180 }
189-
181+
190182 const promptValue = args[promptIndex + 1];
191-
183+
192184 // Check if the next argument is actually another flag
193185 if (promptValue.startsWith("--")) {
194186 throw new Error("--prompt flag requires a value, found flag instead");
195187 }
196-
188+
197189 result.prompts.push(promptValue);
198190 }
199191 }
200192
201193 // Find the last argument that's not a flag or a flag value
202- const flagsWithValues = ["--config", "--org", "--rule", "--prompt", "--format"];
194+ const flagsWithValues = [
195+ "--config",
196+ "--org",
197+ "--rule",
198+ "--prompt",
199+ "--format",
200+ ];
203201 const nonFlagArgs = args.filter((arg, index) => {
204202 // Skip flags (starting with --)
205203 if (arg.startsWith("--") || arg === "-p") return false;
modified extensions/cli/src/commands/chat.ts +7 −2
@@ -397,8 +397,13 @@
397397 }
398398
399399 // Handle additional prompts from --prompt flags
400- const { processAndCombinePrompts } = await import("../util/promptProcessor.js");
401- const initialUserInput = await processAndCombinePrompts(options.prompt, prompt);
400+ const { processAndCombinePrompts } = await import(
401+ "../util/promptProcessor.js"
402+ );
403+ const initialUserInput = await processAndCombinePrompts(
404+ options.prompt,
405+ prompt,
406+ );
402407
403408 let isFirstMessage = true;
404409 while (true) {
modified extensions/cli/src/ui/hooks/useChat.ts +13 −5
@@ -164,16 +164,24 @@
164164 useEffect(() => {
165165 // Only handle initial prompt after chat history is initialized
166166 // This prevents race conditions where the prompt runs before system message is loaded
167- if ((initialPrompt || (additionalPrompts && additionalPrompts.length > 0)) && isChatHistoryInitialized) {
167+ if (
168+ (initialPrompt || (additionalPrompts && additionalPrompts.length > 0)) &&
169+ isChatHistoryInitialized
170+ ) {
168171 const processPrompts = async () => {
169- const { processAndCombinePrompts } = await import("../../util/promptProcessor.js");
170- const finalMessage = await processAndCombinePrompts(additionalPrompts, initialPrompt);
171-
172+ const { processAndCombinePrompts } = await import(
173+ "../../util/promptProcessor.js"
174+ );
175+ const finalMessage = await processAndCombinePrompts(
176+ additionalPrompts,
177+ initialPrompt,
178+ );
179+
172180 if (finalMessage) {
173181 await handleUserMessage(finalMessage);
174182 }
175183 };
176-
184+
177185 processPrompts().catch(console.error);
178186 }
179187 }, [initialPrompt, additionalPrompts, isChatHistoryInitialized]);
modified extensions/cli/src/util/promptProcessor.test.ts +6 −7
@@ -82,11 +82,7 @@
8282 .mockRejectedValueOnce(new Error("processing failed"))
8383 .mockResolvedValueOnce("success2");
8484
85- const result = await processAndCombinePrompts([
86- "good1",
87- "bad",
88- "good2",
89- ]);
85+ const result = await processAndCombinePrompts(["good1", "bad", "good2"]);
9086
9187 expect(mockProcessPromptOrRule).toHaveBeenCalledTimes(3);
9288 expect(result).toBe("success1\n\nsuccess2");
@@ -98,7 +94,10 @@
9894 .mockRejectedValueOnce(new Error("fail1"))
9995 .mockRejectedValueOnce(new Error("fail2"));
10096
101- const result = await processAndCombinePrompts(["bad1", "bad2"], "initial");
97+ const result = await processAndCombinePrompts(
98+ ["bad1", "bad2"],
99+ "initial",
100+ );
102101
103102 expect(result).toBe("initial");
104103 });
@@ -125,4 +124,4 @@
125124 );
126125 });
127126 });
128-});
No newline at the end of the file
127+});
modified extensions/cli/src/util/promptProcessor.ts +2 −4
@@ -22,9 +22,7 @@
2222 const processed = await processPromptOrRule(promptSpec);
2323 processedPrompts.push(processed);
2424 } catch (error: any) {
25- logger.warn(
26- `Failed to process prompt "${promptSpec}": ${error.message}`,
27- );
25+ logger.warn(`Failed to process prompt "${promptSpec}": ${error.message}`);
2826 }
2927 }
3028
@@ -36,4 +34,4 @@
3634 return initialPrompt
3735 ? `${combinedPrompts}\n\n${initialPrompt}`
3836 : combinedPrompts;
39-}
No newline at the end of the file
37+}