-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: --prompt flag #7358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: --prompt flag #7358
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 issues found across 17 files
React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| const finalMessage = await processAndCombinePrompts(additionalPrompts, initialPrompt); | ||
|
|
||
| if (finalMessage) { | ||
| handleUserMessage(finalMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unhandled promise rejection: handleUserMessage not awaited inside async function
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/hooks/useChat.ts at line 173:
<comment>Unhandled promise rejection: handleUserMessage not awaited inside async function</comment>
<file context>
@@ -163,10 +164,19 @@ export function useChat({
useEffect(() => {
// Only handle initial prompt after chat history is initialized
// This prevents race conditions where the prompt runs before system message is loaded
- if (initialPrompt && isChatHistoryInitialized) {
- handleUserMessage(initialPrompt);
+ if ((initialPrompt || (additionalPrompts && additionalPrompts.length > 0)) && isChatHistoryInitialized) {
+ const processPrompts = async () => {
+ const { processAndCombinePrompts } = await import("../../util/promptProcessor.js");
+ const finalMessage = await processAndCombinePrompts(additionalPrompts, initialPrompt);
</file context>
extensions/cli/src/args.ts
Outdated
| result.prompts = []; | ||
| for (const promptIndex of promptIndices) { | ||
| if (promptIndex + 1 < args.length) { | ||
| result.prompts.push(args[promptIndex + 1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prompt parsing incorrectly captures flag names as prompt values when no value is provided
Prompt for AI agents
Address the following comment on extensions/cli/src/args.ts at line 187:
<comment>Prompt parsing incorrectly captures flag names as prompt values when no value is provided</comment>
<file context>
@@ -170,8 +172,25 @@ export function parseArgs(): CommandLineArgs {
}
}
+ // Get prompts from --prompt flags (can be specified multiple times)
+ const promptIndices: number[] = [];
+ for (let i = 0; i < args.length; i++) {
+ if (args[i] === "--prompt") {
+ promptIndices.push(i);
+ }
</file context>
| import { Minimatch } from "minimatch"; | ||
|
|
||
| import { processRule } from "./args.js"; | ||
| import { processPromptOrRule } from "./args.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incomplete function rename may break existing tests and mocks that still reference the old 'processRule' function name
Prompt for AI agents
Address the following comment on extensions/cli/src/systemMessage.ts at line 8:
<comment>Incomplete function rename may break existing tests and mocks that still reference the old 'processRule' function name</comment>
<file context>
@@ -5,7 +5,7 @@ import * as path from "path";
import pkg from "ignore-walk";
import { Minimatch } from "minimatch";
-import { processRule } from "./args.js";
+import { processPromptOrRule } from "./args.js";
import { serviceContainer } from "./services/ServiceContainer.js";
import { ConfigServiceState, SERVICE_NAMES } from "./services/types.js";
</file context>
|
|
||
| import { parseArgs, processPrompt } from "./args.js"; | ||
|
|
||
| describe("args --prompt flag", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing afterAll hook to restore original process.argv could affect other test suites
Prompt for AI agents
Address the following comment on extensions/cli/src/args.prompt.test.ts at line 5:
<comment>Missing afterAll hook to restore original process.argv could affect other test suites</comment>
<file context>
@@ -0,0 +1,49 @@
+import { describe, it, expect, beforeEach } from "vitest";
+
+import { parseArgs, processPrompt } from "./args.js";
+
+describe("args --prompt flag", () => {
+ beforeEach(() => {
+ // Reset process.argv for each test
</file context>
| configPath?: string; | ||
| organizationSlug?: string; | ||
| additionalRules?: string[]; | ||
| additionalPrompts?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: React Re-renders
Array prop in useEffect dependency may cause excessive re-renders if not properly memoized
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/index.ts at line 18:
<comment>Array prop in useEffect dependency may cause excessive re-renders if not properly memoized</comment>
<file context>
@@ -15,6 +15,7 @@ interface StartTUIChatOptions {
configPath?: string;
organizationSlug?: string;
additionalRules?: string[];
+ additionalPrompts?: string[];
toolPermissionOverrides?: {
allow?: string[];
</file context>
| initialPrompt?: string; | ||
| resume?: boolean; | ||
| additionalRules?: string[]; | ||
| additionalPrompts?: string[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule violated: React Re-renders
Adding additionalPrompts to interface without preventing re-renders from array reference changes
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/AppRoot.tsx at line 12:
<comment>Adding additionalPrompts to interface without preventing re-renders from array reference changes</comment>
<file context>
@@ -9,6 +9,7 @@ interface AppRootProps {
initialPrompt?: string;
resume?: boolean;
additionalRules?: string[];
+ additionalPrompts?: string[];
}
</file context>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
|
🎉 This PR is included in version 1.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.10.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
--prompt flag to pass a prompt from the hub
Summary by cubic
Adds a repeatable --prompt flag to the CLI to preload one or more prompts from files, Hub slugs, or raw strings, combined into the initial user message in both TUI and headless modes.
New Features
Dependencies