The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Teach coding agents Harness Compute, and install that skill on harness start
Timb0a1599ac40a
diff --git a/cli/build-bundle.mjs b/cli/build-bundle.mjsindex 515a83370..744fa272d 100644--- a/cli/build-bundle.mjs+++ b/cli/build-bundle.mjs@@ -10,7 +10,7 @@* `require` via the banner so ws's try/catch fallback works without them.*/import * as esbuild from 'esbuild'-import { readFileSync, copyFileSync, rmSync } from 'fs'+import { readFileSync, copyFileSync, rmSync, mkdirSync } from 'fs'const version =process.env.ADAPTER_VERSION ||@@ -43,4 +43,11 @@ await esbuild.build({})copyFileSync('hook/notify.mjs', 'dist/notify.mjs')-console.log(`✓ Bundled dist/cli.js (v${version}) + dist/notify.mjs`)++// harnessComputeSkill.ts reads this doc at runtime, as a SIBLING `skills/` dir next to cli.js —+// same layout notify.mjs uses, and the same "the doc is the source, install just ships it" split+// the source file documents.+mkdirSync('dist/skills', { recursive: true })+copyFileSync('../docs/skills/harness-compute.md', 'dist/skills/harness-compute.md')++console.log(`✓ Bundled dist/cli.js (v${version}) + dist/notify.mjs + dist/skills/`)diff --git a/cli/src/cli.ts b/cli/src/cli.tsindex 9c70b3525..500474878 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -37,6 +37,7 @@ import { DeviceLink } from './device/deviceLink.js'import { DeviceFleet } from './device/deviceFleet.js'import { registry, projectDisplayName, type RegisteredSession } from './lib/registry.js'import { installAmpPlugin, installCodexHooks, installCommandCodeHooks, installCursorHooks, installDevinHooks, installGrokHooks, installAgyHooks, installCopilotHooks, installHermesHooks, installKiloPlugin, installOpencodePlugin, installPiExtension, installSessionHooks } from './lib/hooks.js'+import { installOpencodeHarnessComputeSkill } from './lib/harnessComputeSkill.js'import { PID_FILE, daemonPort, isAlive, readPid } from './lib/daemonState.js'import {BIND_WAIT_MS, connectFailure, defaultLaunchDeps, removePidFileIf, waitForBind, waitForReady,@@ -3224,6 +3225,7 @@ async function runForeground(session: AuthSession): Promise<void> {installCodexHooks(hookPort)installCursorHooks(hookPort)installOpencodePlugin(hookPort)+ installOpencodeHarnessComputeSkill()installKiloPlugin(hookPort)installPiExtension(hookPort)// A self-update refreshes plugin files here; running engine processes pick them up according to eachdiff --git a/cli/src/config/env.ts b/cli/src/config/env.tsindex 70345e960..521528b99 100644--- a/cli/src/config/env.ts+++ b/cli/src/config/env.ts@@ -168,6 +168,12 @@ const envSchema = z.object({OPENCODE_PLUGIN_DIR: z.string().default(join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'opencode', 'plugin')),+ // OpenCode skills dir (honors XDG_CONFIG_HOME) — where the adapter drops the Harness Compute+ // skill, so any opencode session can help start/use a local model without being told what the+ // underlying CLI it shells out to is called.+ OPENCODE_SKILL_DIR: z+ .string()+ .default(join(process.env.XDG_CONFIG_HOME || join(homedir(), '.config'), 'opencode', 'skills')),// Kilo state root — the SQLite store lives at <KILO_DATA_DIR>/kilo.db. Kilo is an opencode fork and// keeps the same layout, but NOT the same overrides: measured on 7.4.20 via `kilo debug paths`, it// honours XDG_DATA_HOME and ignores both `KILO_DATA_DIR` and `OPENCODE_DATA_DIR`. So this variablediff --git a/cli/src/lib/harnessComputeSkill.ts b/cli/src/lib/harnessComputeSkill.tsnew file mode 100644index 000000000..29ea75850--- /dev/null+++ b/cli/src/lib/harnessComputeSkill.ts@@ -0,0 +1,71 @@+/**+ * Idempotently install the Harness Compute opencode skill into+ * ~/.config/opencode/skills/harness-compute/SKILL.md, so any opencode session — including one+ * running inside a Harness swarm pane — can help the user start or use a local model without+ * ever being told what the underlying CLI it shells out to is called.+ *+ * The skill's own prose is not duplicated here: it lives in `docs/skills/harness-compute.md`,+ * one file for every agent — it tells the agent to add a custom provider to itself, which every+ * coding agent knows how to do, rather than carrying a page per agent's config format. This just adds the frontmatter opencode's skill loader requires.+ */+import { readFileSync, writeFileSync, mkdirSync, existsSync, renameSync } from 'fs'+import { join, dirname } from 'path'+import { fileURLToPath } from 'url'+import { env } from '../config/env.js'++const cliDir = dirname(fileURLToPath(import.meta.url))++// Same dual-path pattern hooks.ts uses for notify.mjs (import.meta.url is the REAL executing+// file at runtime):+// - packaged/bundled: cli.js at ~/.harness/cli/cli.js → the docs ship as a SIBLING `skills/` dir+// (build-bundle.mjs copies them there, same as it copies notify.mjs).+// - dev/per-file: hooks live at <appRoot>/cli/src/lib/ → the docs are three levels up, at+// <appRoot>/docs/skills/.+function skillSourcePath(name: string): string {+ const packaged = join(cliDir, 'skills', name)+ const dev = join(cliDir, '..', '..', '..', 'docs', 'skills', name)+ return [packaged, dev].find(existsSync) ?? dev+}++const SKILL_PATH = join(env.OPENCODE_SKILL_DIR, 'harness-compute', 'SKILL.md')++const FRONTMATTER = `---+name: harness-compute+description: Run AI models on the user's own machines under their Harness account and chat with them from this agent. Use when the user asks to start or serve a local model, run a model on this machine, add a custom provider for those models, or check what their machines are currently serving.+license: MIT+compatibility: opencode+metadata:+ source: autonomous-harness (docs/skills/harness-compute.md)+---++`++/** Idempotently drop the assembled Harness Compute skill into ~/.config/opencode/skills/. */+export function installOpencodeHarnessComputeSkill(): void {+ let core: string+ try {+ core = readFileSync(skillSourcePath('harness-compute.md'), 'utf-8')+ } catch (err) {+ // Best-effort, same posture as every other engine install in hooks.ts: a missing or unreadable+ // source must never fail `harness start`, only skip this one skill.+ console.error('[hooks] failed to read Harness Compute skill sources:', err)+ return+ }+ const source = FRONTMATTER + core.trimEnd() + '\n'+ try {+ if (existsSync(SKILL_PATH) && readFileSync(SKILL_PATH, 'utf-8') === source) {+ console.log('[hooks] Harness Compute opencode skill already installed')+ return+ }+ } catch { /* unreadable — rewrite it */ }+ try {+ mkdirSync(dirname(SKILL_PATH), { recursive: true })+ const tmp = `${SKILL_PATH}.${process.pid}.tmp`+ writeFileSync(tmp, source)+ renameSync(tmp, SKILL_PATH)+ console.log(`[hooks] installed Harness Compute opencode skill → ${SKILL_PATH}`)+ console.log('[hooks] (a NEW opencode session picks this up automatically)')+ } catch (err) {+ console.error('[hooks] failed to write Harness Compute opencode skill:', err)+ }+}diff --git a/docs/skills/harness-compute.md b/docs/skills/harness-compute.mdnew file mode 100644index 000000000..2d557fbae--- /dev/null+++ b/docs/skills/harness-compute.md@@ -0,0 +1,264 @@+# HOW TO OPERATE HARNESS COMPUTE++Harness Compute is models running on the user's own machines, under their Harness account,+reachable by any coding agent Harness drives. This file is the same for every agent — Claude+Code, Codex, Cursor, opencode — because they all read the same state through the same `grid`+commands. The one thing that differs per agent, how it registers a custom provider, is the+agent's own business; section 2 only hands it what to register.++The user does exactly one thing by hand: `harness login`, browser and SSO. That already signs+them into Harness Compute — there is no second sign-in, no second credential, nothing else to set+up first. Everything below, you do for them in conversation. Don't ask them to run something you+can run yourself, and don't ask them for a base URL, an API key, or a model list — all three are+discoverable from the commands here.++Three things the user asks for:++ 1. Start a local model on this machine, so it joins Harness Compute+ 2. Add it to this agent as a custom provider, so they can chat with it here+ 3. Show what Harness Compute is doing right now++Read the section for what was asked. Don't do the others unprompted.+++## Ground rules — apply everywhere, in every agent++**Talk the way Harness talks.** Short, declarative sentences. State what's true and what happens+next — don't hedge, don't soften a "no" into a maybe, don't open with "I'd be happy to" or close+with an exclamation point. Say the concrete consequence instead of a vague reassurance: not "this+should be more efficient" but name what it actually saves or costs. Second person, never third —+you're talking to the user, not describing them to someone else. When something isn't set up, say+so plainly and stop, the same way you'd report a failed build — that's not a lesser answer than+success, it's the accurate one.++**Never say the plumbing's name — and never hand the user a command either.** The commands below+shell out to a CLI called `grid` — that part cannot change, it's the real binary. But the user+never hears that word from you, and never gets a command to type or a flag to remember: not in+chat, not in a file you write for them, not in a report, not as "you can stop it with X" or+"pass --Y if you want Z." Call the whole feature **Harness Compute**, every time. Every action+this file describes is something you do when the user tells you what they want in plain words —+never something you tell them to do themselves in a terminal. If a command's own output prints+its internal name (it will), summarize what it means instead of repeating the raw line back.++**No network name, ever, anywhere you'd have to say it out loud.** Harness Compute is one thing+per account — the user doesn't pick it, name it, or switch between several. Commands that need to+know which one discover it themselves (`grid info --json`, `grid ls --json`); you never surface+the raw name or ask the user to choose one. If a lookup comes back empty, stop and say so in+plain words: "Harness Compute isn't set up on your account yet." Don't invent a name or create+one — that's provisioned automatically at sign-in, and a guessed name can collide with someone+else's account on the same shared service.++**If a command fails because the user isn't signed in**, stop and tell them to run+`harness login`. That's the only command in this whole feature that's ever theirs to run by hand.++**Ask through a tool, not through prose.** Every point in this file that says "ask" means: use+whatever structured, interactive way your own agent has of putting a question to the user — real+selectable options, a real blocking prompt — not a sentence ending in a question mark inside a+normal reply. A written question in prose is not a stop: nothing forces the turn to end there,+and the user gets a paragraph to parse instead of choices to pick. An interactive prompt is what+actually blocks until an answer comes back, and it's what turns "coding, chat, vision, or+fastest" or "go ahead?" into something the user picks rather than types out by hand. Use it for+the intent question, the model shortlist, and every yes/go-ahead confirmation before a slow step+— never substitute freeform text for any of these. If your agent has no such mechanism, the+fallback is to end your entire turn on the question and nothing else — never on a question+followed by the command that answers it.+++## 1. Start a local model on this machine++Goal: this computer serves a model that becomes available to Harness Compute, so any agent it+is added to as a custom provider (section 2) can chat with it. Five steps, in order.++**Steps 3 and 4 are a real stop, not a narrated one.** Each downloads or compiles something+multi-gigabyte-to-multi-minute on the user's machine. Ask a direct question ("this will build+llama.cpp from source, which takes a while on this hardware — go ahead?" / "this pulls 19.2 GB —+go ahead?") and end your turn there. Do not start the command in the same turn as the question,+and do not treat "here's what I'm about to do" as itself the ask — it isn't, and saying it while+the command is already running is not asking. Wait for an actual reply before running `grid+engine install` or `grid pull`. The one exception is `grid engine install` when `grid engine+status` already shows the engine installed — that's a no-op, not a step, so it never needs+confirmation.++**Step 1 — two questions, through a tool, before naming any model.** Skip either one the user+already answered in the same breath.++ "What's it for?"+ - Coding+ - Chat and writing+ - Reading images+ - Just something fast++ "How much context do you want?"+ - 32K+ - 64K+ - 128K+ - As much as fits++Suggest a default on the second based on the first — coding wants 128K (an agent burns context as+a session grows), chat is fine at 32K. Both answers are what step 4 filters on.++**Step 2 — know this machine's hardware before recommending anything.**++ grid device-info++Read `Usable ... for models` (or `usable_bytes` under `--json`) — that's the real ceiling for+what this machine can load, already adjusted for the OS/GPU's own reserve on Apple Silicon. Do+this **before** step 4's catalog, not after: a recommendation needs both halves — what step 1+asked, and what this machine can actually run. Never guess or assume a machine's specs — always+read this command's output.++**Step 3 — the engine, once per machine.** Skip straight to step 4 if `grid engine status` already+shows it installed — no question needed for a no-op. Otherwise, ask first, **through a tool**, in+its own turn:++ grid engine install llama.cpp --from-source++`--from-source` builds it (Metal on macOS, CUDA on Linux NVIDIA) and takes a while; without the+flag it downloads a prebuilt release, which is faster. Present both as the question's options,+recommend `--from-source` as the default, and stop — the command runs only after the answer comes+back, never in the message that asks.++**Step 4 — the weights.**++ grid catalog --json # sized for THIS machine; the table isn't+ grid pull unsloth/Qwen3.8-27B-GGUF:Qwen3.8-27B-UD-Q4_K_XL.gguf++The JSON has what the pick is made from: `runnable`, `task`, `params_b`, and a `fit` block+computed for this machine — `fit.version` (the quant that fits), `fit.size`, `fit.ctx` (the+context it can serve with), `fit.est_tok_s`. Keep entries that are `runnable`, whose `fit.ctx`+covers the context asked in step 1, and that suit the purpose (`task` for images; `fit.est_tok_s`+for "fast"). Offer 2–3, through a tool, each with size, context and speed. Pull `fit.version`'s+`pull_spec` unless the user named a quant. The download runs in the next turn, after the answer.++**Step 5 — join.**++ grid join --serve Qwen3.8-27B-UD-Q4_K_XL.gguf \+ --advertise-as Qwen3.8-27B \+ --name this-machines-display-name \+ --max-concurrency 2 \+ --ctx-size 128000++What each flag means, because two of them are easy to confuse:++ - `--serve` is the **file** step 4 saved, exactly as saved.+ - `--advertise-as` is the **model name the user picks** in whichever agent they connect. Without+ it, the raw filename shows up instead, which nobody wants to type.+ - `--name` is **this machine's** display name. A different thing from `--advertise-as`: one+ names the model, the other names the computer.+ - `--max-concurrency` is how many requests this box takes at once. Keep it low (2) on a shared+ machine; higher on a dedicated GPU box.+ - `--ctx-size` is the context the user asked for in step 1 ("as much as fits" = that file's+ `fit.ctx`), never above its `fit.max_ctx`. Always pass it: left off, the engine takes a 16K+ default, and an agent's own prompt is bigger than that.++Ask before picking values not given — steps 1 and 2 already established intent and hardware, so+there's no excuse to guess here.++This returns as soon as the model is up; it keeps serving in the background. **Prove it answers+before saying it's ready** — the join's exit code and `grid stats` only show it is listed:++ grid chat -m Qwen3.8-27B "say ok"++The `-m` is the `--advertise-as` name. A reply means the whole path works. No reply, or an error+about context size, means it is not ready — fix it (see "When something fails") before telling+the user anything succeeded.++Once the chat check passes, say it's ready, then ask through a tool: "Add it to this agent as a+custom provider now, so you can pick the model here?" — section 2 on a yes, nothing on a no.+Never as a side effect of starting a model.++**To stop it, don't name the command — offer to do it.** Say something like "tell me when you+want it stopped and I'll turn it off," never "stop it with `grid leave`." The user asking you to+stop it is itself the trigger: run `grid leave` yourself right then (`--all` if this box is+serving more than one model), and confirm in plain words that it's stopped. The command is+something you run, never something you hand the user to type.+++## 2. Add it to this agent as a custom provider++**Add a custom provider** to the agent the user is in — opencode, Claude Code, Codex, whichever —+the way that agent itself adds one; every coding agent has its own flow for a custom+OpenAI-compatible provider, and it knows its own config better than this file does. This file+only supplies the values to put in:++ eval "$(grid info --env)" && curl -s -H "Authorization: Bearer $OPENAI_API_KEY" \+ "$OPENAI_BASE_URL/models"++One invocation, never split: each shell command is its own process, so an export in one dies+before the next. That gives the three inputs:++ - **Base URL** — `$OPENAI_BASE_URL`, exactly as printed. It already ends in the versioned path;+ don't append `/v1` or trim it — the client adds `/chat/completions` itself.+ - **API key** — `$OPENAI_API_KEY`, as a literal. It goes in the agent's **global** config, never+ a project file that lands in a repo. Never write it anywhere else, and never echo it back to+ the user in chat.+ - **Models** — the `/models` list. Skip any entry whose `owned_by` is a router (`Auto` and+ friends); everything else is a real model, keyed by its exact `id`, case included.+ `context_window`, when present, is the model's context limit; when absent, leave the limit+ out rather than inventing one.++Name the provider whatever the agent's flow asks for, so the user recognises it in the picker.++Don't make it the agent's default model; leave whatever default was there. The agent needs a+restart to load a new provider — say so, then which models are now available and how the agent+picks one. Don't claim it's usable until after the restart.++If the agent later answers `Unauthorized` and nothing else changed, the key went stale (a+sign-in mints a new one): redo this section, which rewrites it.+++## 3. Show what's running++None of these need env vars or setup. Read-only, safe to run any time.++ grid stats --verbose # uptime, memory, and a card per machine+ grid usage --by member # who used it+ grid usage --by model # which models did the work+ grid usage --by engine # which machines did the work++`grid stats` without `--verbose` is just the summary block. Every one takes `--json` for+computing on the output rather than displaying it.++Two things to get right when summarizing:++ - **A `0` and a `—` are different answers.** `0` means measured and idle; `—` means nothing+ measured it at all. Don't collapse them, and don't report a `—` as zero.+ - **`input` excludes cached tokens.** `input`, `cached` and `output` are three non-overlapping+ figures that add up to the total. Don't add input and cached together.++Pick the split that answers what was actually asked, rather than dumping all four commands.+++## When something fails++Say what failed and stop — don't paper over it or retry blindly. Translate every message: never+repeat a raw line that names the underlying CLI.++ - **"Not signed in"** → the user's to fix: `harness login`.+ - **"isn't up"** → Harness Compute is stopped for this account. Say so; ask before restarting+ it.+ - **404 on a model** → wrong id, or nothing is currently serving it. `grid stats --verbose`+ shows what each machine actually has loaded.+ - **`exceeds the available context size`** (an agent may show it as a garbled "expected array+ `choices`") → the model was served with too small a window, usually `--ctx-size` left off.+ Stop it and join again with the context the user asked for; then redo section 2 so the+ agent's context limit matches. The model is fine; only its window was too small.+++---++*Maintainer note (not shown to the end user, ever): this is the whole skill, for every agent, for+the feature described in `docs/plans/2026-09-14-004-harness-grid-plan.md`. It deliberately drops the+generic `grid` product's multi-network `grid use`/`grid start <name>`/member-management surface+(present in `autonomous-grid/docs/opencode.txt`, sections D/E) because Harness auto-provisions+one private network per account at `harness login` and never exposes selection or naming to the+user (Change 2/2b of that plan). If that backend auto-provisioning (Change 7) isn't live yet on+the account this runs against, `grid info --json`/`grid ls --json` will simply come back empty —+this file tells the agent to stop and say so rather than inventing a network name, since names+are globally unique and a guessed one can collide with another user's account.++There is deliberately no per-agent page and no fixed provider name: section 2 says "add a custom+provider" and hands over the base URL, key and model list, because every coding agent already+knows how to add a custom OpenAI-compatible provider to itself — better than a page here could,+and without drifting when its config format changes. The words "add a custom provider" are the+hook those agents' own skills recognise; keep them, and don't decorate them.*