Integrate InnoClaw CLI runtime support#98
Merged
Conversation
Contributor
There was a problem hiding this comment.
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, JSONbatch, 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 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 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 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) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Contracts:
Validation:
Follow-ups: