feat(AGE-46): Add web workspace and API adapter#38
Conversation
- Add web/ to pnpm-workspace.yaml as workspace package - Scaffold Next.js 14 + TypeScript app in web/ - Add /api/health endpoint returning version info - Implement APIAdapter in cli/adapters/api-adapter.ts - Collects wizard inputs from request body instead of prompts - Accumulates responses as structured JSON - Supports text, confirm, select, multiSelect field descriptors - Export APIAdapter from cli/adapters/index.ts Closes AGE-46
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds an HTTP-driven Runtime Adapter (APIExecAdapter + APIUIAdapter) with explicit input/response types and error classes, exposes a createAPIAdapter factory, and scaffolds a new Next.js "web" app with basic pages, health API, and workspace integration. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant APIUIAdapter
participant APIExecAdapter
participant ChildProcess
Client->>APIUIAdapter: request input or provide inputs object
alt Input present & valid
APIUIAdapter->>APIUIAdapter: validate input
APIUIAdapter-->>Client: return value
else Input missing or invalid
APIUIAdapter->>APIUIAdapter: append FieldDescriptor to response
APIUIAdapter-->>Client: throw APIAdapterNeedsInputError / APIAdapterValidationError
end
Client->>APIExecAdapter: capture(command, args)
APIExecAdapter->>ChildProcess: spawn/exec command
ChildProcess-->>APIExecAdapter: stdout/stderr/exitCode
APIExecAdapter-->>Client: return ExecResult / exit code
Client->>APIUIAdapter: spinner(message) / log actions
APIUIAdapter->>APIUIAdapter: append LogEntry(s) to APIResponse
APIUIAdapter-->>Client: return spinner controller or no-op
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@cli/adapters/api-adapter.ts`:
- Around line 62-80: The capture method currently builds a shell string and
calls execSync which allows command injection; replace execSync with
execFileSync from "child_process" and call execFileSync(command, args, { cwd,
encoding: "utf-8", stdio: ["pipe","pipe","pipe"] }) so arguments are passed
without a shell, and update the try/catch to handle the returned Buffer/string
and to cast errors to the ExecException shape to read stdout, stderr and status
(use these to populate the returned stdout, stderr and exitCode as before).
Ensure you remove the string join of command and args and keep the function name
capture unchanged.
- Around line 88-96: The commandExists function is vulnerable because it
interpolates the command into a shell string; update every commandExists
implementation (e.g., function commandExists in api-adapter.ts, cli-adapter.ts
and exec.ts) to avoid shell interpolation by invoking the platform check binary
without a shell or by scanning PATH programmatically; use spawnSync/execFileSync
with arguments as an array (e.g., call "which" on POSIX or "where" on Windows)
with shell: false and stdio ignored and return true when status === 0, or
replace the implementation entirely with a pure-Node PATH scan using fs and path
to locate executables.
🧹 Nitpick comments (1)
cli/adapters/api-adapter.ts (1)
244-254: Consider using underscore prefix for intentionally unused parameters.The
stopandmessagecallbacks have unused parameters which may trigger linter warnings. Prefixing with underscore is the TypeScript convention for intentionally unused parameters.✨ Suggested fix
spinner(message: string): SpinnerController { this.response.logs.push({ level: "info", message: `[spinner] ${message}`, timestamp: Date.now() }); return { - stop(msg?: string) { + stop(_msg?: string) { // No-op in API mode }, - message(_msg: string) { + message(_msg: string) { // No-op in API mode (already prefixed) }, }; }
Summary
Adds the foundational web workspace package and API adapter for the agent-army web deployment UI.
Changes
web/as workspace package/api/healthendpoint returning version info@agent-army/clifor shared typesTesting
tsc --noEmitpasses)Ticket
Closes AGE-46
Summary by CodeRabbit
New Features
Chores