JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat(skills): add skvm-general and skvm-jit skill definitions
wangxiaolong1000a8391a970c9
diff --git a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-general/SKILL.md b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-general/SKILL.mdnew file mode 100644index 0000000000..d00f061a45--- /dev/null+++ b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-general/SKILL.md@@ -0,0 +1,144 @@+---+name: skvm-general+description: Drive the skvm CLI on behalf of a user to profile models, AOT-compile skills, run skill-assisted tasks, run benchmarks, and manage compiled proposals. Trigger when the user asks to "profile", "aot-compile", "bench", "run a single ad-hoc task with a skill", or asks about skvm proposals. Do NOT trigger for `jit-optimize` or when the user wants to optimize/improve a skill — use the sibling `skvm-jit` skill instead.+---++# SkVM General Usage++You are driving `skvm`, a CLI that AOT-compiles and runs LLM agent skills across heterogeneous models. Use this skill when the user wants to *use* skvm — profile a model, AOT-compile a skill, run a task with a skill, run a benchmark, or manage optimization proposals. Do **not** invent flags — every example below uses the real flag set from the installed `skvm` binary.++## Step 1: Prerequisite self-check++Split the check in two — the binary must always be present, but the API key is only required for commands that call an LLM.++**Always required** — skvm is on PATH:++```bash+skvm --help >/dev/null 2>&1 || { echo "skvm not installed — tell the user to run: curl -fsSL https://skillvm.ai/install.sh | sh"; exit 1; }+```++**Required only before LLM-calling commands** — `profile` (without `--list`), `aot-compile`, `pipeline`, `run`, `bench`, `jit-optimize`. Local filesystem commands (`profile --list`, `proposals list|show|reject`, `logs`, `clean-jit`) do **not** need the API key — run them even if the key is unset.++```bash+# Before running profile/aot-compile/run/bench/jit-optimize:+test -n "${OPENROUTER_API_KEY:-}" || { echo "OPENROUTER_API_KEY is not set — ask the user for their key"; exit 1; }+```++If a required prerequisite is missing, **stop** and tell the user what is missing. Do not install anything yourself.++## Step 2: Profile a model++A profile (TCP — Target Capability Profile) records what an LLM can do across 26 primitive capabilities. It is the input for AOT compilation and is cached so subsequent compile calls reuse it.++```bash+skvm profile --model=<id> # profile one model+skvm profile --model=<id1>,<id2> --concurrency=4 # profile several in parallel+skvm profile --model=<id> --adapter=opencode # non-default adapter+skvm profile --model=<id> --force # ignore cache, re-run+skvm profile --list # list cached profiles+```++Notes:+- Default adapter is `bare-agent`. Other valid adapters: `opencode`, `openclaw`, `hermes`, `jiuwenclaw`.+- Cache lives at `$SKVM_PROFILES_DIR` (default `.skvm/profiles/`).+- Profiling is expensive — confirm with the user before running on several models, and prefer `--concurrency` over sequential runs.++## Step 3: AOT-compile a skill++AOT compilation rewrites a skill's `SKILL.md` (and optionally bundle files) so it fits a specific target model's capability profile. The three-pass AOT compiler runs by default.++```bash+skvm aot-compile --skill=<path> --model=<id> # all three passes+skvm aot-compile --skill=<path> --model=<id> --pass=1,2,3 # explicit+skvm aot-compile --skill=<path> --model=<id> --pass=1 # only pass 1 (SCR + gap analysis)+skvm aot-compile --skill=<path> --model=<id> --dry-run # no write+skvm pipeline --skill=<path> --model=<id> # profile-if-needed → aot-compile+```++Pass semantics:+- `--pass=1` — SCR extraction, gap analysis, capability substitution/compensation+- `--pass=2` — dependency manifest + env-binding script generation+- `--pass=3` — workflow decomposition + DAG parallelism extraction++Compiled variants land under the proposals tree (`proposals/aot-compile/...`). Multiple passes can be combined in any subset: `--pass=1,3` runs passes 1 and 3, skipping 2.++## Step 4: Run a single task with a skill++For ad-hoc debugging of one skill on one task:++```bash+skvm run --task=<path/to/task.json> --model=<id> # no skill+skvm run --task=<path> --model=<id> --skill=<path/to/SKILL.md> # with skill+skvm run --task=<path> --model=<id> --adapter=opencode --verbose # explicit adapter + debug+```++Use this to reproduce a single failing task or validate a skill edit. Do **not** use it for benchmarking — use `skvm bench` instead.++## Step 5: Bench a skill++Benchmarking runs a skill across many tasks and condition variants. It can get expensive fast — always confirm with the user before running across many models or tasks, and use `--concurrency` for parallelism.++```bash+skvm bench --model=<id> # all conditions, all tasks+skvm bench --model=<id> --conditions=original,aot-compiled # baseline + compiled+skvm bench --model=<id> --conditions=jit-optimized # use latest jit-optimize best round+skvm bench --model=<id> --conditions=jit-boost --jit-runs=5 # 5 warmup runs for solidification+skvm bench --model=<id1>,<id2> --concurrency=4 # multi-model in parallel+skvm bench --model=<id> --tasks=task_01,task_02 --runs-per-task=3 # specific tasks, 3 reps each+skvm bench --model=<id> --async-judge # defer LLM-judge to post-run batch+skvm bench --resume=latest # resume an interrupted session+skvm bench --list-sessions # list past sessions+```++Valid `--conditions` strings:+- `no-skill` — run the task with no skill injected (baseline floor)+- `original` — the skill as-written (baseline ceiling)+- `aot-compiled` — full 3-pass AOT compiled variant+- `aot-compiled-p1`, `-p2`, `-p3`, `-p12`, `-p13`, `-p23` — single or partial AOT passes+- `jit-optimized` — the latest best-round variant from `skvm jit-optimize` proposals+- `jit-boost` — code-solidification runtime optimization++Bench logs land at `.skvm/log/bench/<sessionId>/`.++## Step 6: Manage jit-optimize proposals++Proposals are the artifact produced by `skvm jit-optimize` (and by the sibling `skvm-jit` skill). Each proposal contains the original skill in `round-0/`, one or more improved rounds in `round-N/`, and metadata recording which round the engine considered best.++```bash+skvm proposals list # all proposals+skvm proposals list --status=pending # only pending (not yet accepted/rejected)+skvm proposals list --skill=<name> --target-model=<id> # filter by skill + target model+skvm proposals show <id> # print metadata and per-round summary+skvm proposals accept <id> # deploy the engine-recommended best round+skvm proposals accept <id> --round=2 # override: deploy round 2 instead+skvm proposals accept <id> --target=<dir> # deploy to a non-default skill dir+skvm proposals reject <id> # mark as rejected (no deploy)+skvm proposals cancel <id> # stop a detached run still in phase=running+```++Proposal id format: `<harness>/<safe-target-model>/<skill-name>/<timestamp>`, where `<safe-target-model>` is the slugified target model id (forward slashes in the CLI id become `--`). When the user gives you an id like `bare-agent/openrouter--anthropic--claude-sonnet-4.6/calendar/20260401T120000Z`, pass it verbatim — do not reformat it.++Detached runs (`skvm jit-optimize --detach`) write an extra `run-status.json` inside the proposal directory that tracks execution phase (`running` / `done` / `failed`), separate from `meta.json.status`. `skvm proposals show` renders this header and tails the last 20 lines of `run.log` for running / failed detached runs. If the user wants to stop a detached optimization mid-run, use `cancel`; sync runs (no `--detach`) do not need `cancel`, they block until complete.++**Critical rule**: only run `skvm proposals accept` when the user has **explicitly** asked to deploy. If the user just says "check the proposals", run `list` and `show` and stop there. Accepting without confirmation overwrites the skill files in place.++## Step 7: Environment variables++| Variable | Required | Purpose |+|----------|----------|---------|+| `OPENROUTER_API_KEY` | yes | OpenRouter key used by bare-agent, profiler, compiler (when routed through OpenRouter), and jit-optimize optimizer |+| `ANTHROPIC_API_KEY` | optional | Enables the Anthropic SDK backend for the compiler and judge |+| `SKVM_DATA_DIR` | optional | Override the input dataset root (default: `./skvm-data` submodule) |+| `SKVM_CACHE` | optional | Override the runtime cache root (default: `~/.skvm`) |+| `SKVM_PROPOSALS_DIR` | optional | Override the proposals storage root (default: `~/.skvm/proposals/`) |++`OPENROUTER_API_KEY` is only required for commands that actually call an LLM. Local-only commands (`proposals list/show/reject`, `profile --list`, `logs`, `clean-jit`) run without it.++## Rules++- **Never run `bench` or `profile` across many models without explicit user confirmation** — they can cost tens of dollars per run. Always quote an expected model count back to the user before starting.+- **Never run `skvm proposals accept` unless the user explicitly asked to deploy.**+- **Prefer `--concurrency=<n>` over sequential loops** for multi-model work.+- **Do not invent flags.** If the user asks for something you don't see in this skill, run `skvm <command> --help` to check before guessing.+- **Do not install anything.** If `skvm` is missing, tell the user to run the installer; if `OPENROUTER_API_KEY` is missing, ask them for it.+- **Surface skvm's stderr progress lines** (e.g. `Installing bundled opencode…`, `Downloading profile…`) as normal output — they are not errors.diff --git a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-jit/SKILL.md b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-jit/SKILL.mdnew file mode 100644index 0000000000..31be30b342--- /dev/null+++ b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-jit/SKILL.md@@ -0,0 +1,142 @@+---+name: skvm-jit+description: Trigger `skvm jit-optimize` with post-task evidence so it generates a reviewable optimization proposal for a skill. Use after finishing a task that was driven by any skill (not just SkVM-compiled ones) when the outcome was a failure, was partial, or the skill's instructions clearly caused confusion or an unnecessary detour. Clean successful runs usually do not need an optimization pass. For general skvm usage (profile/aot-compile/bench/proposals), use the sibling `skvm-general` skill instead.+---++# SkVM JIT Optimize Trigger++When you finish a task that was driven by a skill, and the skill's own instructions appear to have caused problems, collect a short structured record of what happened and invoke `skvm jit-optimize`. The optimizer reads that evidence, proposes improvements to the skill's files, and stores them as a **proposal** you can inspect with `skvm proposals show <id>`.++This skill is not a human review workflow. Its job is to turn task evidence into a concrete optimization run.++This works for **any** skill the host harness can load — it does not need to have been produced by SkVM's compiler. `jit-optimize` only needs the skill folder on disk; it does not require SkVM-specific artifacts.++## When to trigger++Run this skill **only** when both of the following hold:++1. The task you just completed was driven by a skill that the harness loaded from disk (not an ad-hoc user instruction).+2. At least one of the following is true:+ - the task **failed** or ended **partial**, and a clearer skill would plausibly have avoided it+ - you observed a concrete problem in the skill's instructions: ambiguity, a missing step, an incorrect claim, a confusing ordering, or an unnecessary detour the skill forced you into++Do **not** run this skill when:++- the task succeeded and the skill read cleanly — silent passes are fine, the optimizer does not need "nothing to report" submissions+- the failure was purely user-side (typo in the prompt, missing credentials, network failure) and no change to the skill would have helped+- the task did not use a skill at all, or used only a trivial one-shot instruction+- you are running inside `skvm bench` or any other SkVM-orchestrated flow — bench owns its own optimization loop, do not double-submit++## Step 1: Locate the skill directory++The skill directory contains a `SKILL.md` file. You need the absolute path to pass as `--skill=<dir>` in Step 3.++Each agent harness installs skills in well-known locations. Read `adapter-skill-paths.md` (sibling file in this skill's directory) and look up the section matching the harness you are currently running inside — it lists the search order for Claude Code, opencode, openclaw, hermes, jiuwenclaw, and bare-agent. Probe the listed paths in order and pick the first one that contains a `SKILL.md` for the skill name you are looking for.++If none of the listed paths contains the skill, or the reference file marks your harness as "confirm with user", ask the user for the path — do not guess.++## Step 2: Prepare optimizer input++Pick **one** of the two formats below. Save it anywhere (e.g. a temp file); you'll pass its path as `--logs=<path>` in Step 3.++### Format A — Simple optimization report (preferred for one-off observations)++Save as `report.json`:++```json+{+ "task": "<what the user asked, one or two sentences>",+ "outcome": "pass" | "fail" | "partial",+ "issues": [+ "short description of each problem you hit",+ "another problem"+ ],+ "skill_feedback": "concrete suggestion for how the SKILL.md could be clearer or more correct"+}+```++Keep `issues` focused on things the **skill's instructions** could prevent or clarify. Do not include issues that were purely user-side (typos in the prompt, missing credentials, network failures).++The JSON key is still named `skill_feedback` because that is the current report schema consumed by `jit-optimize`; treat it as an optimization hint for the engine, not as human-directed feedback.++When `outcome` is `fail` or `partial`, the optimizer treats the issues and `skill_feedback` as failure reasons attached to a synthetic "agent-reported" criterion. When `outcome` is `pass`, the report still enters the optimizer but with no failures, letting it notice what worked well.++### Format B — Conversation log (preferred when the full turn-by-turn trace is informative)++Save as `conv-log.jsonl`, one JSON object per line:++```jsonl+{"type":"request","ts":"<iso8601>","text":"<user prompt>"}+{"type":"response","ts":"<iso8601>","text":"<your reply or summary of the step>"}+{"type":"tool","ts":"<iso8601>","text":"<tool call summary>","toolCalls":[...]}+```++Only include entries that matter for diagnosing the skill's quality. Redact secrets.++## Step 3: Run jit-optimize++```bash+skvm jit-optimize --detach \+ --skill=<skill-directory> \+ --task-source=log \+ --logs=<path-to-report.json-or-conv-log.jsonl> \+ --target-model=<id-the-task-ran-on> \+ --optimizer-model=openrouter/z-ai/glm-5.1+```++`--detach` is what lets this skill stay snappy. Without it the optimizer runs in-process and blocks the agent for the full optimization pass (often a minute or more); with it the CLI returns in well under a second after spawning a background worker. Always pass it from this skill.++Required parameters:++- `--skill` — path to the skill directory (the one containing `SKILL.md`)+- `--task-source=log` — tells jit-optimize to analyze a conversation log without rerunning anything. **This is the only task source valid from this post-task optimization flow** — `real` and `synthetic` sources rerun tasks against a live model, which a post-hoc report cannot do.+- `--logs` — path to the report file you wrote in Step 2+- `--target-model=<id>` — **required for every `skvm jit-optimize` invocation, including `--task-source=log`**. In log mode the target model is not used for execution — it is the *storage key* that decides which folder under `proposals/<harness>/<target-model>/<skill>/` the proposal lands in, so proposals stay grouped by the model the skill is tuned for. Use the prefixed model id of the model that just ran the task — **that is you**, the agent reading this skill. Every id must carry a `<provider>/` prefix that matches a route in the user's `providers.routes`; read your own model id out of your system prompt / harness environment and prepend the right provider (Claude Code exposes it as the "exact model ID", e.g. map `claude-opus-4-6` → `anthropic/claude-opus-4.6` when Anthropic-routed, or `openrouter/anthropic/claude-opus-4.6` when OR-routed; opencode/openclaw/hermes similarly). If you genuinely cannot determine your own model id or provider, ask the user once and stop — do not substitute a placeholder.+- `--optimizer-model=<id>` — the LLM that drives the optimizer agent. Every id must carry a `<provider>/` prefix; `openrouter/z-ai/glm-5.1` is a good cheap default (needs `OPENROUTER_API_KEY`).++Optional:++- `--target-adapter=<name>` — purely informational in log mode (default: `bare-agent`). Set it if the log came from a non-default adapter (e.g., openClaw, Hermes, jiuwenclaw) so the proposal is filed under the right harness folder.+- `--failures=<path,...>` — structured failure-reasons JSON, one path per corresponding entry in `--logs`. Pass only when you already have a cleaner per-criterion breakdown than the report file itself; the count must match `--logs`. Skip it for single-report cases.++**What NOT to pass in log mode** (the CLI will error if you do):++- `--tasks`, `--test-tasks` — these belong to `--task-source=real`+- `--synthetic-count`, `--synthetic-test-count` — these belong to `--task-source=synthetic`+- `--runs-per-task`, `--convergence`, `--baseline` — the log mode does not rerun the task, so there is no loop to configure++With `--detach`, the CLI returns in well under a second. Stdout ends with a block like:++```+Proposal: <harness>/<safeTargetModel>/<skill>/<timestamp>+Proposal dir: <absolute-path>+Detached; watch with 'skvm proposals show <id>'+```++The optimization continues in a background worker process; its progress is recorded in `<proposal-dir>/run-status.json` (`phase: queued | running | done | failed`) and detailed log output goes to `<proposal-dir>/run.log`. Both are surfaced when the user runs `skvm proposals show <id>`.++**Capture the id from the line starting with `Proposal: ` only** — everything after `Proposal: ` up to the newline is the id. Do not parse `Proposal dir:` or the `Detached; watch with` line. Note the middle segment is `safeTargetModel` (derived from `--target-model`), not the optimizer model.++If `skvm jit-optimize` exits **non-zero** with no `Proposal:` line, the worker failed before it could allocate a proposal id. Read the stderr message and stop — do not retry blindly. The most common cause is `another optimization is in progress for <skill>`, which means a prior detach for the same skill+model is still running.++## Step 4: Report the proposal id++Print one line with the proposal id you captured:++> Triggered `skvm jit-optimize` for `<skill>`. Review with `skvm proposals show <id>`; accept with `skvm proposals accept <id>`.++Do **not** accept or deploy the proposal yourself unless the user explicitly asks you to. If the user asks you to deploy, run `skvm proposals accept <id>` and report the deployed file list.++## Rules++- Never include sensitive data (API keys, private file contents) in the report.+- Never edit the skill directory directly. Proposals are stored under `$SKVM_PROPOSALS_DIR` (default `~/.skvm/proposals/`); only `skvm proposals accept` writes back into the skill.+- If `skvm` is not on PATH, report it to the user and stop — do not install anything. If `skvm jit-optimize` fails with "opencode not found", tell the user to re-run the skvm installer (`curl -fsSL https://skillvm.ai/install.sh | sh` or `npm i -g @ipads-skvm/skvm`) rather than installing opencode yourself. skvm bundles its own private opencode copy and manages it through the installer.+- One report per task. Don't batch multiple unrelated tasks into a single report.+- `OPENROUTER_API_KEY` must be set in the environment for the optimizer to run. If it is missing, the background worker will fail and `skvm proposals show <id>` will display `run: FAILED` with the reason. The parent CLI cannot detect this in advance because the API key is only used inside the detached worker.++## Reference: what happens on the skvm side++`skvm jit-optimize --detach` validates the flags, then forks a background worker that does all the heavy work (creating the proposal directory, acquiring a per-skill lock, running the optimizer agent, snapshotting rounds). Once the worker has the lock and a proposal id, it tells the parent over an IPC channel; the parent prints `Proposal: <id>` and exits. The worker keeps running independently and writes its phase to `<proposal>/run-status.json` (`queued → running → done | failed`) so `skvm proposals show <id>` can report progress at any time.++The optimizer agent reads your report, inspects the skill folder, diagnoses a root cause, and edits files in a temp workspace (SKILL.md and/or bundle files). The edited folder is snapshotted as `round-1/` inside the proposal. `round-0/` is a copy of the original skill. The user can later diff the two with `skvm proposals show <id>` or reject the proposal if the root cause looks wrong. Proposals are keyed by `(harness, target-model, skill-name)`, which is why `--target-model` is required even in log mode and why concurrent detached runs for the same triple are rejected with a clean error rather than left to clobber each other.diff --git a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-jit/adapter-skill-paths.md b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-jit/adapter-skill-paths.mdnew file mode 100644index 0000000000..678d7ce4b4--- /dev/null+++ b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/skills/skvm-jit/adapter-skill-paths.md@@ -0,0 +1,56 @@+# Default skill directory paths per harness++When `skvm-jit` needs to pass `--skill=<dir>` to `skvm jit-optimize`, it must+resolve the on-disk directory that holds the skill's `SKILL.md`. The agent+should already know which harness it is running inside; look up the matching+section below and probe the listed paths in order. If none contain a+`SKILL.md` for the skill name you are looking for, ask the user — do not+guess.++This file is loaded on demand from Step 1 of the parent `SKILL.md`. It is not+a skill itself.++## Claude Code++1. Project-scoped: `./.claude/skills/<name>/`+2. User-scoped: `~/.claude/skills/<name>/`+3. Plugin-provided: `~/.claude/plugins/<plugin>/skills/<name>/`++Source of truth: Claude Code skill-loader documentation. The first match wins+in the order above.++## opencode++1. Project-scoped: `./.opencode/skills/<name>/`+2. User-scoped: *(confirm with user — not derivable from the adapter code)*++The `.opencode/skills/<name>/` layout is what `src/adapters/opencode.ts`+writes in discover mode, so it is the path opencode's own loader reads from.++## openclaw++1. User-scoped: *(confirm with user — the adapter writes to a workspace-+ local `skills/<name>/` directory under `/tmp/skvm-openclaw/<agentId>/`,+ which is a bench artifact, not the harness's persistent skill root)*++## hermes++1. User-scoped: `~/.hermes/skills/<name>/`++Source of truth: `src/adapters/hermes.ts` line 249 — `hermesHome/skills/<name>`.+Hermes has no documented project-scoped location.++## jiuwenclaw++Not supported. jiuwenclaw runs in inject-only mode: skill content is prepended+to the prompt and has no persistent on-disk copy. `skvm-jit` cannot submit+feedback for a jiuwenclaw run because there is no `--skill=<dir>` to pass.+Tell the user and stop.++## bare-agent++Not applicable for runtime feedback. `bare-agent` is SkVM's own minimal+harness and only runs inside `skvm bench`; it is not a production harness an+end-user task would run under. If you find yourself here, you are almost+certainly running inside a bench and should not be triggering `skvm-jit`+yourself — the bench orchestrator owns that flow.