Skip to content

Integrate InnoClaw CLI runtime support#98

Merged
zjowowen merged 12 commits into
mainfrom
feature/pr-95-cli-merge
Jun 26, 2026
Merged

Integrate InnoClaw CLI runtime support#98
zjowowen merged 12 commits into
mainfrom
feature/pr-95-cli-merge

Conversation

@zjowowen

Copy link
Copy Markdown
Collaborator

Summary:

  • Integrates PR Add InnoClaw CLI headless run support #95 on top of the current main branch and current AUTH_MODE=disabled auth model.
  • Adds CLI runtime commands, browser-to-CLI session handoff, workspace helpers, batch mode support, and safer dev-start readiness checks.
  • Fixes merge-risk issues found during review: explicit CLI handoff confirmation, safe redirects, atomic CLI session writes, batch mode validation, server probe validation, standalone tsc compatibility, and API docs field drift.

Contracts:

  • Uses AUTH_MODE=disabled for no-auth development startup; does not reintroduce DISABLE_AUTH or HEADLESS_ADMIN_ID.
  • /api/auth/cli-session remains unavailable when auth is disabled.
  • Workspace API and CLI use folderPath.

Validation:

  • npx tsc --noEmit: passed
  • npm run lint: passed with existing deep-research warnings
  • npm test: 67 files / 391 tests passed
  • NEXT_TELEMETRY_DISABLED=1 npm run build: passed with existing Turbopack NFT warnings
  • sphinx-build -b html docs docs/_build/html/en -W --keep-going: passed
  • sphinx-build -b html docs docs/_build/html/zh -D language=zh_CN -W --keep-going: passed
  • AUTH_MODE=disabled npm run dev -- --port 3001 smoke: /api/auth/me, CLI doctor, CLI auth status, and CLI workspace list passed without login

Follow-ups:

Copilot AI review requested due to automatic review settings June 18, 2026 06:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Integrates first-class local CLI runtime support into InnoClaw, including browser-to-CLI session handoff, local runtime probing/auto-start, workspace helpers, and batch execution—while aligning docs and tests with the updated contracts (notably AUTH_MODE=disabled and folderPath).

Changes:

  • Added CLI runtime implementation (interactive REPL, one-shot run, JSON batch, auth/session management, server readiness checks).
  • Added browser-to-CLI session handoff plumbing (UI + shared helpers + /api/auth/cli-session).
  • Improved workspace-root handling (no silent FIFO truncation; configurable cap) and expanded test coverage.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/lib/innoclaw-cli/session-client.test.ts Tests CLI session persistence, permissions, and browser-launch error handling.
src/lib/innoclaw-cli/server-client.test.ts Tests server readiness probing and dev-start.sh behaviors via stubs.
src/lib/innoclaw-cli/model-client.test.ts Tests CLI /model parsing and settings read/write via API.
src/lib/innoclaw-cli/http.test.ts Tests localhost → 127.0.0.1 retry behavior for CLI HTTP client.
src/lib/innoclaw-cli/batch-client.test.ts Tests batch mode validation and persisted results content.
src/lib/files/filesystem.ts Updates workspace root registration behavior; adds WORKSPACE_ROOTS_MAX_ENTRIES cap handling.
src/lib/files/filesystem.test.ts Adds tests for expanded workspace root allowlist behavior and cap enforcement.
src/lib/auth/cli-handoff.ts Implements safe redirect handling + CLI handoff param parsing + handoff execution helper.
src/lib/auth/cli-handoff.test.ts Tests loopback validation, redirect safety, payload shape, and route rejection when auth disabled.
src/app/register/page.tsx Preserves CLI handoff params across auth pages; adds explicit “Complete CLI sign-in” flow.
src/app/register/page.test.tsx Tests explicit action requirement before completing authenticated CLI handoff.
src/app/login/page.tsx Adds safe next redirect handling and explicit CLI handoff confirmation UI.
src/app/login/page.test.tsx Tests explicit action requirement before completing authenticated CLI handoff.
src/app/api/auth/cli-session/route.ts Adds endpoint to mint a dedicated CLI session from an authenticated browser session (403 when auth disabled).
README.md Documents optional CLI usage and headless/no-auth local run mode.
plugins/innoclaw-cli/src/workspace-client.mjs Ensures/creates workspaces using folderPath and derived names.
plugins/innoclaw-cli/src/session-client.mjs Implements CLI session storage, browser handoff callback server, and auth/session management.
plugins/innoclaw-cli/src/server-client.mjs Adds server probe logic and optional local auto-start via dev-start.sh.
plugins/innoclaw-cli/src/runtime.mjs Defines CLI runtime constants and base URL normalization/candidates.
plugins/innoclaw-cli/src/repl.mjs Adds interactive REPL renderer + commands + streaming tool/message display.
plugins/innoclaw-cli/src/model-client.mjs Adds model settings read/write + /model command parsing.
plugins/innoclaw-cli/src/http.mjs Adds robust API client with JSON/text handling and local retry candidates.
plugins/innoclaw-cli/src/batch-client.mjs Implements JSON batch runner with concurrency, logging, and results persistence.
plugins/innoclaw-cli/src/agent-client.mjs Implements streaming agent invocation and message/tool helpers for CLI.
plugins/innoclaw-cli/skills/innoclaw-cli/SKILL.md Documents CLI usage patterns and login/headless flows.
plugins/innoclaw-cli/scripts/innoclaw-cli.mjs Expands CLI entrypoint to support interactive/run/batch/auth + shared flags.
plugins/innoclaw-cli/README.md Documents CLI feature set and interactive login flow.
docs/usage/api-reference.md Updates API reference for auth endpoints, CLI session handoff, and field names (folderPath, git clone fields).
dev-start.sh Tightens readiness checks/port ownership handling; adds auth-probe based “server responding” logic.

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

Comment thread dev-start.sh
Comment on lines +17 to +19
local body_file meta status content_type node_status
body_file=$(mktemp) || return 1
meta=$(curl --noproxy "*" -sS -o "$body_file" -w "%{http_code}\n%{content_type}" "http://127.0.0.1:$PORT/api/auth/me" 2>/dev/null) || {
Comment thread dev-start.sh
Comment on lines +23 to +32
status=$(printf '%s\n' "$meta" | sed -n '1p')
content_type=$(printf '%s\n' "$meta" | sed -n '2p')

case "${content_type,,}" in
*application/json*) ;;
*)
rm -f "$body_file"
return 1
;;
esac
Comment thread dev-start.sh
Comment on lines +64 to +73
pid_workdir() {
readlink "/proc/$1/cwd" 2>/dev/null
}

is_repo_dev_process() {
local pid=$1
local cwd=$(pid_workdir "$pid")
local cmdline=$(ps -p "$pid" -o args= 2>/dev/null)
[ "$cwd" = "$PWD" ] && echo "$cmdline" | grep -qE "(npm run dev|next dev|node.*next)"
}
Comment on lines +26 to +35
return {
id: typeof entry.id === "string" && entry.id.trim() ? entry.id.trim() : `item-${index + 1}`,
prompt: prompt.trim(),
mode: typeof mode === "string" ? mode : null,
skill: typeof entry.skill === "string" ? entry.skill : null,
cwd: entry.cwd || entry.workspace || null,
provider: typeof entry.provider === "string" ? entry.provider : null,
model: typeof entry.model === "string" ? entry.model : null,
params: entry.params && typeof entry.params === "object" ? entry.params : null,
};
Comment on lines +16 to +19
function getWorkspaceRootsMaxEntries(): number {
const raw = Number.parseInt(process.env.WORKSPACE_ROOTS_MAX_ENTRIES || "64", 10);
return Number.isFinite(raw) && raw > 0 ? raw : 64;
}
Comment on lines +187 to +190
const { execFile } = await vi.importActual<typeof import("node:child_process")>("node:child_process");
const bashPath = "C:\\Program Files\\Git\\bin\\bash.exe";

return new Promise<{ stdout: string; stderr: string; code: number | null }>((resolve) => {
@zjowowen zjowowen merged commit 1398254 into main Jun 26, 2026
4 checks passed
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.

2 participants