Skip to content

Conversation

@ryoppippi
Copy link
Member

@ryoppippi ryoppippi commented Dec 10, 2025

Summary

  • Add @clack/prompts to the pnpm workspace dev catalog
  • Add new interactive-cli.ts example demonstrating dynamic tool discovery and execution

Features

  • Interactive credential input with environment variable fallback
  • Dynamic tool discovery via fetchTools()
  • Interactive tool selection menu with descriptions
  • Spinner feedback during async operations
  • Verbose fetch logging when running with Bun (BUN_CONFIG_VERBOSE_FETCH=curl)

Test plan

  • Run npx tsx examples/interactive-cli.ts and verify interactive prompts work
  • Test with environment variables set (STACKONE_API_KEY, STACKONE_ACCOUNT_ID)
  • Test manual credential entry flow
  • Verify tool selection and execution works correctly

Summary by cubic

Add an interactive CLI demo to discover and run StackOne tools. Improves developer experience with prompts, env fallback, and a menu to select tools.

  • New Features

    • Interactive credential input with environment variable fallback
    • Dynamic tool discovery via fetchTools() and selection by description
    • Spinner feedback during async operations
    • Optional verbose fetch logging when running with Bun
  • Dependencies

    • Added @clack/prompts ^0.11.0 to the dev catalog and examples package

Written for commit e54cf99. Summary will update automatically on new commits.

Add @clack/prompts ^0.11.0 to the pnpm workspace catalog for building
interactive CLI tools with beautiful prompts, spinners, and user input
handling.
Add a new example demonstrating how to build an interactive CLI tool
for dynamically discovering and executing StackOne tools.

Features:
- Interactive credential input with environment variable fallback
- Dynamic tool discovery via fetchTools()
- Interactive tool selection menu with descriptions
- Spinner feedback during async operations

This provides a user-friendly way to explore and test StackOne tools
without hardcoding credentials or tool names.
@ryoppippi ryoppippi requested a review from a team as a code owner December 10, 2025 16:01
Copilot AI review requested due to automatic review settings December 10, 2025 16:01
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@203

commit: e54cf99

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.

1 issue found across 5 files

Prompt for AI agents (all 1 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="examples/interactive-cli.ts">

<violation number="1" location="examples/interactive-cli.ts:23">
P2: Rule violated: **Flag Security Vulnerabilities**

Verbose fetch logging is enabled unconditionally, which may expose API credentials in console output. HTTP request logging typically includes Authorization headers containing the API key. Consider making this opt-in via a command-line flag or environment variable check rather than enabling it by default.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

import { StackOneToolSet } from '@stackone/ai';

// Enable verbose fetch logging when running with Bun
process.env.BUN_CONFIG_VERBOSE_FETCH = 'curl';
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Rule violated: Flag Security Vulnerabilities

Verbose fetch logging is enabled unconditionally, which may expose API credentials in console output. HTTP request logging typically includes Authorization headers containing the API key. Consider making this opt-in via a command-line flag or environment variable check rather than enabling it by default.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At examples/interactive-cli.ts, line 23:

<comment>Verbose fetch logging is enabled unconditionally, which may expose API credentials in console output. HTTP request logging typically includes Authorization headers containing the API key. Consider making this opt-in via a command-line flag or environment variable check rather than enabling it by default.</comment>

<file context>
@@ -0,0 +1,160 @@
+import { StackOneToolSet } from &#39;@stackone/ai&#39;;
+
+// Enable verbose fetch logging when running with Bun
+process.env.BUN_CONFIG_VERBOSE_FETCH = &#39;curl&#39;;
+
+clack.intro(&#39;Welcome to StackOne AI Tool Tester&#39;);
</file context>
Fix with Cubic

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an interactive CLI example that demonstrates dynamic tool discovery and execution using the @clack/prompts library. The example provides a user-friendly way to explore StackOne tools through interactive prompts and real-time feedback.

Key Changes:

  • Added @clack/prompts library to the development catalog for creating interactive CLI experiences
  • Created new interactive-cli.ts example with credential prompts, tool selection menu, and execution feedback
  • Updated documentation to include the new interactive CLI example in the examples overview

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Adds @clack/prompts ^0.11.0 to the dev catalog for interactive CLI functionality
pnpm-lock.yaml Resolves @clack/prompts and its dependencies (@clack/core, sisteransi, picocolors)
examples/package.json Adds @clack/prompts as a dev dependency to the examples package
examples/interactive-cli.ts New interactive CLI demo with credential input, tool discovery, selection menu, and execution with spinner feedback
examples/README.md Documents the new interactive CLI example with usage instructions and marks it as production ready
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

* Features:
* - Interactive credential input with environment variable fallback
* - Dynamic tool discovery and selection
* - Spinner feedback during async operations
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The file header documentation lists features but omits "Verbose fetch logging when running with Bun" which is mentioned in the PR description and implemented on line 23. For completeness, consider adding this feature to the documentation comment, or clarify that it's an internal implementation detail not intended as a user-facing feature.

Suggested change
* - Spinner feedback during async operations
* - Spinner feedback during async operations
* - Verbose fetch logging enabled when running with Bun

Copilot uses AI. Check for mistakes.

spinner.message('Fetching available tools...');
const tools = await toolset.fetchTools();
const allTools = tools.toArray();
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If allTools is empty (no tools available), the clack.select call will fail or display an empty list, which could confuse users. Consider adding a check after fetching tools to handle this case gracefully:

if (allTools.length === 0) {
  clack.log.error('No tools available. Please check your API key and account ID.');
  process.exit(1);
}
Suggested change
const allTools = tools.toArray();
const allTools = tools.toArray();
if (allTools.length === 0) {
spinner.stop('No tools found');
clack.log.error('No tools available. Please check your API key and account ID.');
process.exit(1);
}

Copilot uses AI. Check for mistakes.
Comment on lines +147 to +149
const result = await selectedTool.execute({
query: { limit: 5 },
});
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding { query: { limit: 5 } } as execution parameters may not work for all tools. Different tools have different parameter requirements. Some tools may not accept a query parameter or limit field, which could cause execution failures. Consider either:

  1. Prompting the user for parameters based on the selected tool's schema
  2. Using empty parameters {} for a more generic approach
  3. Adding error handling that explains parameter mismatches
Suggested change
const result = await selectedTool.execute({
query: { limit: 5 },
});
const result = await selectedTool.execute({});

Copilot uses AI. Check for mistakes.
@ryoppippi ryoppippi merged commit c5c6990 into main Dec 10, 2025
20 checks passed
@ryoppippi ryoppippi deleted the feat/interactive-cli-example branch December 10, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants