Skip to content

feat: one-shot CLI mode with subcommands (agent, websearch, web-fetch, list)#87

Merged
huberp merged 2 commits intomainfrom
copilot/add-oneshot-cli-mode
Mar 28, 2026
Merged

feat: one-shot CLI mode with subcommands (agent, websearch, web-fetch, list)#87
huberp merged 2 commits intomainfrom
copilot/add-oneshot-cli-mode

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 28, 2026

agentloop had no non-interactive invocation mode — every entry point dropped into a readline REPL, making it unusable in scripts, Makefiles, or CI pipelines.

New: src/start-oneshot.ts

Scriptable entry point that parses a subcommand, runs one operation, prints to stdout, and exits.

# Run the agent loop once
npm run oneshot -- agent -u "What files are in src/?"
npm run oneshot -- agent -s "You are terse." -u "Summarise README" --json
npm run oneshot -- agent --profile coder --stream -u "Refactor src/config.ts"

# Invoke tools directly (no LLM involved)
npm run oneshot -- websearch -q "LangChain tool calling" -n 3 --json
npm run oneshot -- web-fetch -u "https://example.com"

# Discover capabilities
npm run oneshot -- list tools
npm run oneshot -- list agentprofiles
Subcommand Key flags
agent -u (required), -s system override, -p profile, --stream, --json
websearch -q (required), -n max results, --json
web-fetch -u (required), --json
list tools | agentprofiles

Uses Node.js built-in util.parseArgs — no new dependencies. Unknown subcommands print help and exit 1.

Changes to src/index.ts

  • Exported ensureInitialized() — allows external entry points to load the tool registry before direct tool invocation (no LLM call needed for websearch/web-fetch/list).
  • Exported agentProfileRegistry.
  • Added AgentRunOptions interface with systemPromptOverride?: string; threaded through executeWithTools and executeWithToolsStream as an optional third parameter (fully backward-compatible). When set, replaces the auto-generated system prompt for that invocation.

Other

  • package.json: added "oneshot": "npx tsx src/start-oneshot.ts" script.
  • README.md: added "One-Shot CLI Mode" section with examples and flag tables.
  • 22 new unit tests covering argument parsing for all subcommands and AgentRunOptions propagation.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • duckduckgo.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node /home/REDACTED/work/agentloop/agentloop/node_modules/jest-worker/build/processChild.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

Copilot AI linked an issue Mar 28, 2026 that may be closed by this pull request
11 tasks
Copilot AI changed the title [WIP] Add one-shot CLI mode with subcommands to agentloop feat: one-shot CLI mode with subcommands (agent, websearch, web-fetch, list) Mar 28, 2026
Copilot AI requested a review from huberp March 28, 2026 10:26
@huberp huberp marked this pull request as ready for review March 28, 2026 10:39
@huberp huberp merged commit 062d714 into main Mar 28, 2026
2 checks passed
@huberp huberp deleted the copilot/add-oneshot-cli-mode branch March 28, 2026 10:39
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.

feat: one-shot CLI mode with subcommands (agent, websearch, …)

2 participants