Skip to content

Conversation

@sestinj
Copy link
Contributor

@sestinj sestinj commented Aug 22, 2025

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

    • --prompt option (repeatable) with help text and parsing.
    • Unified processor (processPromptOrRule) to load from file path, Hub slug, or string.
    • New promptProcessor combines multiple --prompt values with any inline prompt; used in TUI and headless chat.
    • Tests for arg parsing and prompt processing; E2E help updated.
  • Dependencies

    • Added @types/node ^24.3.0 (dev).

@sestinj sestinj requested a review from a team as a code owner August 22, 2025 23:52
@sestinj sestinj requested review from Patrick-Erichsen and removed request for a team August 22, 2025 23:52
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 22, 2025
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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);
Copy link
Contributor

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(() =&gt; {
     // Only handle initial prompt after chat history is initialized
     // This prevents race conditions where the prompt runs before system message is loaded
-    if (initialPrompt &amp;&amp; isChatHistoryInitialized) {
-      handleUserMessage(initialPrompt);
+    if ((initialPrompt || (additionalPrompts &amp;&amp; additionalPrompts.length &gt; 0)) &amp;&amp; isChatHistoryInitialized) {
+      const processPrompts = async () =&gt; {
+        const { processAndCombinePrompts } = await import(&quot;../../util/promptProcessor.js&quot;);
+        const finalMessage = await processAndCombinePrompts(additionalPrompts, initialPrompt);
</file context>

result.prompts = [];
for (const promptIndex of promptIndices) {
if (promptIndex + 1 < args.length) {
result.prompts.push(args[promptIndex + 1]);
Copy link
Contributor

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 &lt; args.length; i++) {
+    if (args[i] === &quot;--prompt&quot;) {
+      promptIndices.push(i);
+    }
</file context>

import { Minimatch } from "minimatch";

import { processRule } from "./args.js";
import { processPromptOrRule } from "./args.js";
Copy link
Contributor

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 &#39;processRule&#39; function name</comment>

<file context>
@@ -5,7 +5,7 @@ import * as path from &quot;path&quot;;
 import pkg from &quot;ignore-walk&quot;;
 import { Minimatch } from &quot;minimatch&quot;;
 
-import { processRule } from &quot;./args.js&quot;;
+import { processPromptOrRule } from &quot;./args.js&quot;;
 import { serviceContainer } from &quot;./services/ServiceContainer.js&quot;;
 import { ConfigServiceState, SERVICE_NAMES } from &quot;./services/types.js&quot;;
</file context>


import { parseArgs, processPrompt } from "./args.js";

describe("args --prompt flag", () => {
Copy link
Contributor

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 &quot;vitest&quot;;
+
+import { parseArgs, processPrompt } from &quot;./args.js&quot;;
+
+describe(&quot;args --prompt flag&quot;, () =&gt; {
+  beforeEach(() =&gt; {
+    // Reset process.argv for each test
</file context>

configPath?: string;
organizationSlug?: string;
additionalRules?: string[];
additionalPrompts?: string[];
Copy link
Contributor

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[];
Copy link
Contributor

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>

@sestinj sestinj merged commit 5f78236 into main Aug 23, 2025
55 checks passed
@sestinj sestinj deleted the nate-1 branch August 23, 2025 18:43
@github-project-automation github-project-automation bot moved this from Todo to Done in Issues and PRs Aug 23, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2025
@github-actions github-actions bot added the tier 2 Important feature that adds new capabilities to the platform or improves critical user journeys label Aug 23, 2025
@sestinj
Copy link
Contributor Author

sestinj commented Aug 24, 2025

🎉 This PR is included in version 1.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sestinj
Copy link
Contributor Author

sestinj commented Aug 25, 2025

🎉 This PR is included in version 1.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

released size:L This PR changes 100-499 lines, ignoring generated files. tier 2 Important feature that adds new capabilities to the platform or improves critical user journeys

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants