Repository navigation
feat(cli): harness add/remove/list/serve + node ports - #72
Merged
Merged
Conversation
api.ts carries the Wave-2 pin (Store/StorePorts/FsPort/ExecPort/ SourceRef/JsonRpc*/BridgeMethod); sdk-bind.ts is the single file importing @any-harness/sdk — it casts through unknown so typecheck stays green while the W8 stub stands, and resolves each export lazily with a clear sdk-unavailable CliError. Core modules: hand-rolled flag parser (no arg lib), console-shim output with --json everywhere, minimal TOML-subset reader for [policy] + [[serve.caller]] (no parser dep), CliError exit codes, actor detection per trust.md 4.2, -y/interactive confirmation.
packages/cli owns the concrete StorePorts the sdk store runs on: FsPort over node:fs (atomic sibling-temp+rename writes per store-layout 7.1, recursive ops, symlink via the ln binary with copy as the caller's fallback — no symlinkSync on the island) and ExecPort over node:child_process (exec = one token + argv for git, run = shell form; non-zero exits are results, not throws).
Flag-driven command surface, no TUI: every mutating op takes -y (hand-rolled y/N on interactive TTY, confirmation-required otherwise); --json on every command; --skill-target shared|store on add (shared skills root default per store-layout 5.1); actor classification forwarded to store.install for the trust layer; audit reads audit.log JSONL through the fs port, tolerating partial lines (trust.md 6.1); verify raises trust-violation on integrity mismatch; doctor exits 1 on error findings.
NDJSON loop per transports 1: parse-error -32700, invalid-request -32600, notifications dispatched without reply, handler throws as -32603 without killing the loop. Per-request authz from [[serve.caller]] (deny wins, absent allow = full set, * wildcard, auto-granted negotiate/notify) with -32012 forbidden; stdio identity is the implicit owner caller. Trust-policy gate resolves exec.hooks/exec.mcp ask to exec.nonInteractive (deny default) with -32007 policy-denied — no interactive asks through a bridge session. Diagnostics on stderr only; stdout stays protocol-clean.
cli.ts is the harness bin (shebang, tsdown build to dist/cli.mjs, workspace dep on @any-harness/sdk). Global flags: --root, --json, --help, --version; store root resolves ANYHARNESS_STORE > ANYHARNESS_HOME/harness > ~/.agents/harness. Tests run entirely on a hand-rolled in-memory Store + memory FsPort under src/testing/ — no sdk import on the test path, so vitest stays green while packages/sdk is a stub. 55 tests cover the flag parser, TOML/policy/caller loading, all eight commands, caller authz + policy gate + NDJSON framing, and the real node ports on a tmpdir.
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
There was a problem hiding this comment.
Approved. Cursor Bugbot was not present on this PR after the initial check poll, so that automated-review signal was skipped; no applicable approval policy required human review. This is a non-blocking approval from the Cursor Approval Agent.
Sent by Cursor Approval Agent: Pull Request Router and Approver
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
Workstream W9 of the v2 build-out (
.agents/plans/2026-10-07-v2-foundation.md, Wave 2): implementspackages/cli— theharnessbinary — against the pinned@any-harness/sdksurface that W8 is building in parallel.Flag-driven only, per the scriptc-island constraints (AGENTS.md §7): every mutating op takes
-y, all output supports--json, git ops shell out to thegitbinary, symlinks go throughlnwith a copy fallback, logging is a console shim on stderr. No TUI/prompt/arg-parser/TOML/log deps.Changes
add <source> [--skill-target shared|store] [-y],remove <name> [-y],list [--all] [--kinds],enable/disable <name>,verify <name>(trust-violation on integrity mismatch),doctor(exit 1 on error findings),audit [--event|--actor|--extension|--limit](readsaudit.logJSONL via the fs port, tolerant of partial lines),serve [--transport stdio].src/ports/: node-sideStorePorts—FsPortovernode:fs(atomic sibling-temp+rename writes per store-layout §7.1,ln-based symlink with copy fallback) andExecPortovernode:child_process(one-token+argvexecfor git, shellrun; non-zero exits are results, not throws).src/serve/: stdio NDJSON loop →handleBridgeRequest(parse-error-32700, invalid-request-32600, notifications unanswered, handler throws as-32603); per-request caller authz from[[serve.caller]]inconfig.toml(deny wins,*wildcard, auto-grantedcapabilities.negotiate/events.notify,-32012 forbidden); exec-policy gate resolvingask→exec.nonInteractive(deny default) with-32007 policy-denied— no interactive asks through a bridge session.api.tscarries the pinned surface (Store/ports/SourceRef/JSON-RPC);sdk-bind.tsis the only file importing@any-harness/sdk— it casts throughunknownand resolves each export lazily, sotscis green against the current stub and commands fail cleanly withsdk-unavailableuntil W8 merges. Hand-rolled flag parser, minimal TOML-subset reader for[policy]/[[serve.caller]], actor detection per trust.md §4.2.@any-harness/sdkworkspace dep, tsdown build (dist/cli.mjs+ shebang bin),types: ["node"]in tsconfig.Store+ memoryFsPort(src/testing/) — no sdk import on the test path. Covers the flag parser, TOML/policy/caller loading, all commands' flag surfaces + confirmation discipline, authz/policy-gate/NDJSON framing, and the real node ports on a tmpdir.Test plan
mise exec -- pnpm -F @any-harness/cli test— 55/55 passmise exec -- pnpm -r typecheck— clean across all 5 packages (structural cast keeps the sdk-stub boundary compiling)mise exec -- pnpm -F @any-harness/cli build—dist/cli.mjs;--version/--helpwork, commands emit a cleansdk-unavailableJSON error until W8 landsNotes
FsPort/ExecPortmember-level shapes,Storereturn types (VerifyResult,DoctorReport), andInstallOptionsare my reading of the pin — W8's canonical definitions may need reconciling at merge;api.ts+sdk-bind.tsare the only drift points by construction.exec.nonInteractiveis NOT consulted for store mutations —-yis the only non-interactive attestation for add/remove; the policy key governs exec-classaskresolution only (trust.md §4.1 scope).harness serve --httpis out of scope (v0.1 ships stdio only);--transportrejects non-stdiovalues with a usage error.[[serve.caller]]authz is honored for the stdioownercaller when an explicitownerentry exists — an opt-in narrowing; default is the spec's full op set.Link to Devin session: https://app.devin.ai/sessions/be2e2d373dbf4e6a851935c31b794ba8
Open in Devin Desktop: https://app.devin.ai/desktop/session/be2e2d373dbf4e6a851935c31b794ba8?variant=devin
Requested by: @espetro