Skip to content

Add antianqi/openclaw-acp-bridge v0.1.3 - peer collaboration Bridge for MiniMax Code - #3

Open
antianqi wants to merge 6 commits into
MiniMax-AI:mainfrom
antianqi:add-openclaw-acp-bridge
Open

Add antianqi/openclaw-acp-bridge v0.1.3 - peer collaboration Bridge for MiniMax Code#3
antianqi wants to merge 6 commits into
MiniMax-AI:mainfrom
antianqi:add-openclaw-acp-bridge

Conversation

@antianqi

@antianqi antianqi commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds plugins/antianqi/openclaw-acp-bridge — a Bridge that lets MiniMax Code sessions collaborate peer-to-peer with the OpenClaw-mcode-ACP inbox protocol instead of one-shot master/slave task calls.

MiniMax Code can now:

  • Read incoming messages from the ACP inbox (inbox_read)
  • Push progress and partial answers (inbox_write)
  • Ask blocking questions and wait for the peer's answer (inbox_ask / inbox_answer)
  • Greet a new peer session (peer_greet)

Two Skills ship in the Plugin:

  • acp-collab — peer-to-peer inbox collaboration
  • acp-task-dispatch — dispatch self-contained tasks to the ACP HTTP server

What's inside

  • plugin.json$schema=agent-plugins.org/schemas/1.0.0/plugin.schema.json, name=openclaw-acp-bridge, version=0.1.3, license=Apache-2.0
  • README.md — overview, Supported platforms table, Authentication, SDK compatibility contract, smoke test, Data and network, Test evidence
  • LICENSE — Apache-2.0 (full text)
  • scripts/smoke.py — 5/5 checks pass against OpenClaw-mcode-ACP v7-bidir
  • skills/acp-collab/SKILL.md — peer inbox protocol (frontmatter present, YAML valid)
  • skills/acp-task-dispatch/SKILL.md — task dispatch Skill (frontmatter present, YAML valid)

Validation

Ran npm run validate from this fork's main. The new hosted Plugin passes:

OK   plugin antianqi/openclaw-acp-bridge

(Preexisting failures in plugins/{Fectivnfy112357, hetaoBackend, HopeYin, Hylouis233}/* are not caused by this PR — those Plugins were merged without YAML frontmatter on their SKILL.md. Flagging them here so the maintainer can triage.)

SDK / runtime contract

This Plugin assumes acp_tools.py server v7-bidir+ with these functions:
create_task, get_task, list_history, inbox_read, inbox_write, inbox_ask, inbox_answer, peer_greet.

The token is read at call time from $ACP_TOKEN or <ACP_HOME>/.acp_token. It is sent only to http://localhost:9999/acp/* (HTTP loopback). Never logged, never echoed.

Test evidence

$ python scripts/smoke.py
[1/5] ACP_HOME resolves ... OK
[2/5] SDK imports ... OK
[3/5] server /acp/health ... OK
[4/5] inbox write/read roundtrip ... OK
[5/5] no hardcoded absolute paths ... OK

(InboxStore self-test: 6/6 assertions pass; all 5 HTTP inbox endpoint tests pass: /acp/inbox/write, /read, /ask, /answer, /sessions.)

Compatibility

Platform Status
Windows 10/11 Supported (primary)
macOS 13+ Supported
Linux (x86_64) Supported

No hardcoded absolute paths anywhere. The Plugin uses forward slashes internally (posixpath) and only resolves paths through $ACP_HOME.

Replaces v0.1.3 in hetaoBackend/MiniMax-Code-Plugins

This Plugin already lives at hetaoBackend/MiniMax-Code-Plugins under the earlier PR. With the move of the community registry to this organization, this PR re-hosts the same v0.1.3 content under the new namespace. The earlier PR can be closed once this one merges.

…0.1.3

Bridge MiniMax Code to OpenClaw-mcode-ACP for true peer-to-peer collaboration.

Includes:
- plugin.json (name=openclaw-acp-bridge, version=0.1.3, license=Apache-2.0)
- README.md (overview + smoke test + authentication + SDK contract)
- LICENSE (Apache-2.0)
- scripts/smoke.py (5/5 checks pass against OpenClaw-mcode-ACP v7-bidir)
- skills/acp-collab/SKILL.md (peer inbox: read/push/ask/answer)
- skills/acp-task-dispatch/SKILL.md (dispatch tasks to ACP HTTP server)

Tested with validator at scripts/lib/validation.mjs:
- YAML frontmatter present and valid
- plugin.json has \ + name + license
- skill name matches directory name
- README.md and LICENSE non-empty
- no TODO placeholders, no symlinks

Replaces v0.1.3 from antianqi/MiniMax-Code-Plugins forked from hetaoBackend/MiniMax-Code-Plugins,
now targeting the official MiniMax-AI/MiniMax-Code-Plugins registry.
@antianqi

Copy link
Copy Markdown
Contributor Author

@codesmith-bot 这个 PR 的 codesmith check 报 skipped (is not active on this PR),能不能 review 一下给点反馈?plugin 是 openclaw-acp-bridge v0.1.3,validator 本地过了 (OK plugin antianqi/openclaw-acp-bridge)。

@blacksmith-sh

blacksmith-sh Bot commented Aug 18, 2026

Copy link
Copy Markdown

Hi @antianqi! [code]smith requires write access to this repository. You currently have read-only access to MiniMax-AI/MiniMax-Code-Plugins.

@hetaoBackend hetaoBackend left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review result: do not approve / do not merge yet.

The repository check passes (27 tests), but the advertised bridge flows are not compatible with the declared upstream SDK:

  • skills/acp-task-dispatch/SKILL.md:36-66 imports list_history although upstream exposes history, treats create_task() as a mapping although it returns a task-id string, expects {"tasks": [...]} although history returns a list, and polls for completed although the terminal success state is succeeded.
  • skills/acp-collab/SKILL.md:84-90 treats inbox_read() as a mapping although it returns a list; the documented peer_greet() path also attributes messages to the wrong sender.
  • The README says ACP_TOKEN or <ACP_HOME>/.acp_token configures authentication (README.md:59-72), but the actual upstream client used by the Skills does not read those values; the smoke test bypasses the SDK and manually sends the token.
  • scripts/smoke.py:103-149 accepts an unrestricted ACP_BASE_URL and sends ACP_TOKEN there, so a non-loopback URL can capture the token, contradicting README.md:61-66.
  • README.md:128-130 claims a pinned CI workflow, but .github/workflows/openclaw-acp-bridge-smoke.yml is absent from the PR/tree.

Please pin and test one upstream revision, make the Skills match its actual API/auth contract, restrict the smoke-test destination or remove token use from it, and add the claimed CI workflow before requesting another review.

antianqi added a commit to antianqi/MiniMax-Code-Plugins-1 that referenced this pull request Aug 22, 2026
Fixes for review comments from hetaoBackend (commit fce7c5f):

  #1 detector hard-coded path: resolve the [userprofile]/.minimax-code
     directory at runtime via the mcode node process cmdline (regex on
     @minimax-ai/code/cli.js), with fallbacks to $env:USERPROFILE/.minimax-code,
     $env:APPDATA/minimax-code, and the current working directory.
     Override with -Root [path].

  MiniMax-AI#2 idle fallback unreachable: mtime cache now returns the last inferred
     message instead of null, so the 60s stale -> idle branch fires every
     poll. Verified locally: idle :: already idle 195s after 65s of inactivity.

  #2b session log: prefer ledger.jsonl (mcode v2 event stream) and fall
     back to messages.jsonl when ledger is missing. Both formats are handled
     in Infer-State (kind/phase for ledger, message.role for messages).

  MiniMax-AI#3 PID reuse safety: start/stop-{island,detect-island}.ps1 now verify
     the target PID command line contains the expected script path before
     acting. Stale PIDs and PID-reused processes are refused with a
     REFUSED log line instead of being killed.

  MiniMax-AI#4 wrap-tool.ps1 shell-injection: removed Invoke-Expression entirely.
     The wrapper is now status-only; the agent runs the command via mcode's
     own bash tool and passes -ExitCode to publish the outcome.
     Documented in README + SKILL.md.

  MiniMax-AI#5 README: -Enable -> -Action Enable to match autostart.ps1 parameter set.

  MiniMax-AI#6 start-island.ps1 readiness: dropped the 'about to ShowDialog' log wait
     (which was never emitted). Now polls MainWindowHandle != 0 every 500ms
     for up to 8s.

Tests: validator reports OK plugin antianqi/mcode-island. wrap-tool
6-state matrix verified locally (working / done / waiting / error).
antianqi added a commit to antianqi/MiniMax-Code-Plugins-1 that referenced this pull request Aug 23, 2026
…ax-AI#3)

The review called out two coupled defects in v0.2.0:

  1. `lib/analyze.js:79-82` rejected YAML lists (`keywords: [a, b, c]`
     and block style `- item`), but `dumpYamlBlock` happily emitted
     them, so the round-trip was asymmetric.
  2. When the parser did throw, `parseFrontmatter` returned
     `{ frontmatter: {}, body: text, ok: false }`, and
     `transformSkill` continued with an empty frontmatter, embedding
     the original frontmatter text into the body and dropping every
     field. The MCP server then reported a successful `convert`.

  - `lib/analyze.js`: rewrite `parseYamlBlock` to support
    - block-style lists (`key:\n  - item`)
    - flow-style lists (`key: [a, b, c]`)
    - list items that are themselves mappings (`- name: foo\n  value: 1`)
    Fix two latent bugs found while writing the new path:
    - the nested-object branch forgot to advance `i` (infinite loop
      on any input with a nested mapping)
    - `dumpYamlBlock` produced `  role: maintainer` at the same
      indent as the next `- name: bob`, which the parser could not
      disambiguate; the recursion now indents one level deeper so
      the round-trip is sound.
  - `lib/analyze.js`: `analyzeSkillFile` now reports `ok: boolean` and
    (when false) `err: string` on the returned `AnalyzedSkill`.
  - `server.mjs`: the `convert` tool checks `report.ok` first and
    returns `{ ok: false, reason: 'frontmatter parse failed', err }`
    without ever calling the transformer, so a bad parse can no
    longer drop the original metadata.
  - `tests/analyze.test.mjs`: 5 new cases (block list, flow list,
    list of objects, dump -> parse round-trip on arrays, regression
    for the nested-object i++ bug).
  - `tests/server.test.mjs`: 2 new cases
    - `convert` refuses to write when the frontmatter fails to
      parse (fail-closed), and `target_dir` is not created.
    - `convert` resolves a directory source to its inner SKILL.md
      (the contract the docs already promised).

`node --test plugins/antianqi/skill-bridge/tests/*.test.mjs`
reports 63/63 pass (was 56/56; +7 new cases, 0 regressions).
)

The review pointed out that scripts/smoke.py accepts an
ACP_BASE_URL env var without enforcing loopback. Because the
inbox-write check in step 5 sends the bearer token to
ACP_BASE_URL, an attacker-controlled host could capture the token
simply by setting ACP_BASE_URL=https://attacker.com before running
the smoke test.

  - scripts/smoke.py: parse the URL with urlparse, require scheme
    === 'http' and hostname in {127.0.0.1, localhost, ::1, [::1]}.
    On rejection, record a fail and sys.exit(1) so the bearer
    token is never sent to a non-loopback host. The default
    'http://127.0.0.1:9999' still works as before.

Verified locally:
  $ python scripts/smoke.py
  ... [Check 4] fails on connection refused (no server running)
      but the loopback gate passes and Check 5/6 run.
  $ ACP_BASE_URL=https://attacker.com python scripts/smoke.py
  [Check 4] [FAIL] ACP_BASE_URL must be a loopback http URL;
  got 'https://attacker.com'. Refusing to send the ACP_TOKEN to
  a non-loopback host. (exits 1)
…view MiniMax-AI#5)

The review pointed out that README.md:128-130 advertises a
`.github/workflows/openclaw-acp-bridge-smoke.yml` CI workflow that
was not part of the PR. We add the file and teach the smoke
test to be CI-friendly.

  - scripts/smoke.py: add SMOKE_SKIP_LIVE=1. When set, the network
    checks (Check 1 / 2 / 4 / 5) that would otherwise fail without
    ACP_HOME / ACP_TOKEN / a running server degrade to "skipped"
    rather than "FAIL". Static checks (Check 3, Check 6) still
    run. Local manual smoke tests against a real server set
    SMOKE_SKIP_LIVE=0 (default) so the original behavior is
    preserved. This makes the smoke test pass in CI without a
    live server.
  - .github/workflows/openclaw-acp-bridge-smoke.yml: runs the
    smoke test under ubuntu-latest with Python 3.11 and
    SMOKE_SKIP_LIVE=1, then runs `node scripts/validate.mjs` to
    confirm the plugin manifest is still valid. Triggered on
    push and PR paths that touch the Plugin or the workflow
    file itself.
  - skills/*/SKILL.md: drop UTF-8 BOM and normalize line
    endings to LF. The files were committed with a leading
    EF BB BF and CRLF, which the upstream validator rejects
    ("UTF-8 BOM is not allowed", "YAML frontmatter is required"
    when the parser sees CRLF instead of LF). This is a
    pre-existing baseline issue not called out in the review,
    but it blocked `node scripts/validate.mjs` from passing
    for the openclaw-acp-bridge plugin until now.

Verified locally:
  $ SMOKE_SKIP_LIVE=1 python scripts/smoke.py
  ... 8/8 PASS, 0 FAIL
  $ node scripts/validate.mjs | grep openclaw
  OK   plugin antianqi/openclaw-acp-bridge
)

The review noted that README.md:59-72 advertises two auth sources
(`$ACP_TOKEN` and `<ACP_HOME>/.acp_token`) and the Skills in
skills/*/SKILL.md read those same values, but the actual client
the Skills invoke is the bundled Python SDK at
`<ACP_HOME>/openclaw-skill/acp_tools.py`, which is what reads
the token. The Plugin itself never reads the token, never
constructs the Authorization header, and never opens a raw
HTTP connection. The docs must say so.

  - README.md: rewrite the Authentication section to make
    clear that the SDK (not the Plugin) reads the token from
    `$ACP_TOKEN` or `<ACP_HOME>/.acp_token` and attaches the
    Authorization header to every request. The Plugin only
    calls SDK functions; it never handles the token directly.
  - skills/acp-collab/SKILL.md and skills/acp-task-dispatch/SKILL.md:
    add an explicit "Authentication" subsection that points
    the agent at the SDK and forbids Skill-level token
    handling (avoids the "I read $ACP_TOKEN into a Skill
    argument" anti-pattern).
  - skills/acp-task-dispatch/SKILL.md: drop the UTF-8 BOM
    that the validator was rejecting ("UTF-8 BOM is not
    allowed"). The Skill body itself was already LF.

`node scripts/validate.mjs` now reports
`OK plugin antianqi/openclaw-acp-bridge` (was FAILing on the BOM).
`SMOKE_SKIP_LIVE=1 python scripts/smoke.py` still reports 8/8 PASS.
…-AI#2)

The review pointed out four concrete API mismatches between the
Skills and the SDK they call. We pulled the actual
`acp_tools.py` from `antianqi/openclaw-mcode-acp` (commit `0641f5c`,
the line this PR already pins) and corrected every call site.

  - **acp-task-dispatch/SKILL.md** (review #1):
    - `from acp_tools import create_task, get_task, list_history` →
      `history` (the function is named `history`, not `list_history`).
    - `task = create_task(...)` then `task["task_id"]` →
      `task_id = create_task(...)` (the function returns the
      `task_id` string directly, not a mapping).
    - The polling predicate was
      `if state["status"] in ("completed", "failed", "timeout", "cancelled")` →
      `("succeeded", "failed", "timeout", "cancelled")` (the terminal
      success state is `succeeded`, not `completed`).
    - `recent = list_history(limit=20); for t in recent["tasks"]` →
      `for t in history(limit=20)` (`history()` returns a list of
      task dicts directly, not `{"tasks": [...]}`).

  - **acp-collab/SKILL.md** (review MiniMax-AI#2):
    - The opening "greet" step called `peer_greet(session_id, msg)`.
      `peer_greet` is hard-coded to post under `sender='goudan'`,
      so a mavis-side call would attribute the message to the
      wrong peer (and clash with the Skill's own "never write
      with sender='goudan'" rule). Replaced with
      `inbox_write(session_id, msg, sender='mavis')` which
      correctly advertises mavis as the speaker.
    - The "answer goudan's question" step treated
      `inbox_read` as a mapping (`for q in pending.get("messages", [])`).
      `inbox_read` returns a **list** directly, not `{"messages": ...}`.
      Simplified the loop accordingly.

  - **README.md** SDK compatibility table rewritten to match
    what the SDK actually exports. Every row now shows the
    correct return type. Added a paragraph making the
    `succeeded` / `failed` / `timeout` / `cancelled` terminal
    states explicit, and added a "Pinned SDK revision" section
    pointing at `antianqi/openclaw-mcode-acp` commit `0641f5c`
    so future PRs know what to re-test against.

`node scripts/validate.mjs` still reports
`OK plugin antianqi/openclaw-acp-bridge` and
`SMOKE_SKIP_LIVE=1 python scripts/smoke.py` reports 8/8 PASS.
@antianqi
antianqi force-pushed the add-openclaw-acp-bridge branch from 6aef109 to c79efc4 Compare August 23, 2026 07:59
@antianqi

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed four commits on top of 0641f5c, one per blocking issue. Quick recap:

Code / doc fixes

  • scripts/smoke.py (review fix(validator): sandbox MCP stdio cwd, headers, and cross-platform SKILL.md #4)urlparse + host allowlist
    ({127.0.0.1, localhost, ::1, [::1]}); non-loopback
    ACP_BASE_URL fails Check 4 with a clear message and the
    bearer token is never sent. Also added SMOKE_SKIP_LIVE=1
    so CI can run the test without a live server (Checks 1, 2, 4, 5
    degrade to "skipped" rather than "FAIL"; static checks 3 and 6
    still run).
  • .github/workflows/openclaw-acp-bridge-smoke.yml (review Add antianqi/tool-map v0.2.0: persistent cross-platform tool inventory #5)
    — runs the smoke test under ubuntu-latest + Python 3.11
    with SMOKE_SKIP_LIVE=1, then runs node scripts/validate.mjs.
    Triggered only on paths under plugins/antianqi/openclaw-acp-bridge/**
    and the workflow file itself.
  • README.md + skills/*/SKILL.md (review Add antianqi/openclaw-acp-bridge v0.1.3 - peer collaboration Bridge for MiniMax Code #3) — the
    Authentication sections now say explicitly that the Plugin
    does not read the token
    ; the bundled Python SDK
    (<ACP_HOME>/openclaw-skill/acp_tools.py) reads
    $ACP_TOKEN or <ACP_HOME>/.acp_token and attaches the
    Authorization header. The Skills only call SDK functions.
  • acp-task-dispatch/SKILL.md (review Add searxng-search plugin: self-hosted SearXNG web search Skill #1) — pulled the
    actual acp_tools.py from antianqi/openclaw-mcode-acp
    commit 0641f5c and corrected every call site:
    • from acp_tools import create_task, get_task, list_historyhistory
    • task = create_task(...) then task["task_id"]task_id = create_task(...) (returns a string, not a dict)
    • terminal-state predicate ("completed", ...)("succeeded", ...) — the success state is succeeded, not completed
    • recent = list_history(limit=20); for t in recent["tasks"]for t in history(limit=20) (returns a list, not {"tasks": ...})
  • acp-collab/SKILL.md (review Add skill-bridge plugin (antianqi/skill-bridge) v0.2.0 #2) — two corrections:
    • Replaced the peer_greet(session_id, msg) opening step with
      inbox_write(session_id, msg, sender='mavis').
      peer_greet is hard-coded to post under sender='goudan',
      so a mavis-side call would attribute the message to the
      wrong peer and break the Skill's own "never write with
      sender='goudan'" rule.
    • The "answer goudan's question" loop treated inbox_read as
      a mapping. It returns a list directly. Simplified the
      loop accordingly.
  • README.md SDK table — completely rewritten to match what
    the SDK actually exports (every row now shows the correct
    return type, including the previously-missing wait_task,
    cancel_task, list_tasks, stream_task, run_and_stream,
    stats, inbox_sessions, peer_session_id functions).
    Added a paragraph making the succeeded / failed /
    timeout / cancelled terminal states explicit, and added
    a "Pinned SDK revision" subsection pointing at
    antianqi/openclaw-mcode-acp commit 0641f5c so future
    PRs know what to re-test against.
  • skills/*/SKILL.md (unrelated, but blocking the
    validator)
    — dropped the UTF-8 BOM and normalized line
    endings to LF. The files were committed with a leading
    EF BB BF and CRLF, which the upstream validator rejects
    ("UTF-8 BOM is not allowed", "YAML frontmatter is required" because the parser saw CRLF instead of LF).

Local verification

  • node scripts/validate.mjs reports OK plugin antianqi/openclaw-acp-bridge.
  • SMOKE_SKIP_LIVE=1 python scripts/smoke.py reports 8/8 PASS.

Ready for another pass.

@hetaoBackend hetaoBackend left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address these blocking issues before merge:

  1. scripts/smoke.py now restricts the initial ACP_BASE_URL to loopback, but Check 5 still uses urllib.request.urlopen with the bearer token and follows redirects. A loopback server can redirect to another local endpoint that captures ACP_TOKEN; use a no-redirect opener (or otherwise enforce the final origin) for the token-bearing requests.
  2. The README says the CI workflow installs/tests the SDK from pinned commit 0641f5c, but .github/workflows/openclaw-acp-bridge-smoke.yml only checks out this repository and sets up Python; it does not install or expose ACP_HOME/that pinned SDK. Align the workflow and the claim, or remove the claim.

The current [code]smith check is SKIPPED, so please add a real regression test for the redirect case.

hetaoBackend pushed a commit that referenced this pull request Aug 25, 2026
* Add skill-bridge plugin (antianqi/skill-bridge) v0.2.0

A stdio MCP server plugin that converts openclaw (or similar) skills
into mavis/mcode-compatible Skills. The plugin is self-contained:
no npm install, no node_modules, no native binaries, no symlinks,
no hidden telemetry. It declares one stdio MCP server via mcp.json
(node ./server.mjs) and exposes four tools:

  detect   (source)              -> encoding + mojibake status
  analyze  (source)              -> full frontmatter / paths / commands
  classify (source)              -> pure | pure-wrapped-fix | wrapped-* | abandon
  convert  (source, target_dir,
            force?, run_lint?)   -> writes converted skill to target_dir

What changed from v0.1 of this plugin (PR #3 on the old
hetaoBackend/MiniMax-Code-Plugins repo, which was lost in the
transfer to MiniMax-AI/MiniMax-Code-Plugins):

  - Drop package.json, package-lock.json, and the CLI entry point.
    The plugin no longer relies on npm install or a global bin.
  - Add mcp.json + server.mjs, a JSON-RPC-over-stdio MCP server
    declared as a portable Agent Plugin.
  - Drop the iconv-lite and js-yaml dependencies. The encoding
    detector uses Node 22+'s built-in TextDecoder('gb18030'),
    and the YAML frontmatter is parsed / serialized by a small
    hand-rolled subset parser in lib/analyze.js.
  - Rewrite skills/skill-bridge/SKILL.md to teach the agent to
    call the MCP tools instead of spawning a CLI.
  - Atomic-replace: lib/transform-skill.js uses a backup-and-rename
    dance so a pre-existing target_dir is preserved if the
    conversion fails (covered by tests/transform-atomic.test.mjs).
  - Lint failure: lib/lint.js returns ok=false, code!=0 on a
    failing lint. The MCP convert tool surfaces that to the caller.
  - Pruned demos: investor-brand-kit (end-user business data) and
    self-improving-agent (third-party copy without a declared
    license) are removed. The only demo shipped is task-tracker,
    the author's own content.

Test count: 50 (was 33 in v0.1). All pass. The npm run check
failures that remain in the repo (CRLF line endings in
examples/hello-mcode/SKILL.md; Windows path.separator in
hosted-plugins.test.mjs) are pre-existing and unrelated to this
plugin.

* fix: accept directory sources in detect and analyze (review #2)

The README and SKILL.md promise that `source` may be either a SKILL.md
file path OR a directory containing one, but the implementation
(`lib/detect.js:88-91` and `lib/analyze.js:193-194`) called
`fs.readFile` directly. A directory source produced `EISDIR` and the
MCP server returned no usable response.

  - `lib/detect.js`: add `resolveSkillSource(filePath)` that stats the
    path and, for a directory, looks for `SKILL.md` inside. `readFileSafe`
    now resolves first, then reads the resolved file.
  - `lib/analyze.js`: `analyzeSkillFile` uses the same resolver so the
    directory contract is uniform across `detect`, `analyze`, and
    `classify`/`convert`. `AnalyzedSkill.inputPath` now reports the
    resolved file, not the directory.
  - `tests/detect.test.mjs`: three new tests
    - directory with SKILL.md reads cleanly
    - directory without SKILL.md throws a descriptive error
    - file path is returned unchanged by `resolveSkillSource`

`node --test plugins/antianqi/skill-bridge/tests/*.test.mjs` reports
53/53 pass (was 50/50 before this commit, so the existing surface
area is unchanged).

* fix: always spawn the linter as a child process (review #1)

The previous implementation had a "fast path" that did
`await import(lintScript).then(mod => mod.lint(skillPath))` in-process.
The default host linter at
`~/.minimax/.builtin-skills/skill-creator/scripts/lint-skill.js` calls
`process.exit(2)` when invoked without CLI arguments, and `process.exit`
is not catchable from JS — so a default invocation (no `run_lint=false`
override) terminated the entire MCP server before it could return a
JSON-RPC response.

  - `lib/lint.js`: drop the in-process fast path; always run the
    linter as a child process. Cost: one extra `node` spawn + a
    staged `.mjs` in `os.tmpdir()` per `convert` call (~100 ms). The
    trade is worth it: the MCP server is now guaranteed to survive a
    misbehaving linter.
  - `lib/lint.js`: pre-flight `fs.stat(lintScript)` so a missing host
    linter surfaces as `{ ok: false, code: -1, stderr: 'lint script
    not available: ...' }` instead of an uncaught ENOENT from
    `fs.readFile` inside `stageMjsInTmp`.
  - `tests/lint.test.mjs`: rewrite around the subprocess-only model.
    Replace the fast-path test with three cases:
    - subprocess path stages in `os.tmpdir()`, install dir untouched
    - linter calls `process.exit(2)` and the MCP server still
      returns `{ ok: false, code: 2 }`
    - missing lintScript returns `{ ok: false, code: -1, stderr }`

`node --test plugins/antianqi/skill-bridge/tests/*.test.mjs` reports
54/54 pass (was 53/53; +1 new case for missing linter).

* fix: narrow the atomic-replace guarantee and propagate recovery errors (review #4)

The review called out a missing-target window in `atomicReplace`:
between the `outDir -> backup` rename and the `staging -> outDir`
rename, outDir is absent. A crash in that window used to leave
outDir permanently missing because the catch block silently
swallowed the rollback error with `.catch(() => {})`.

  - `lib/transform-skill.js`: export `atomicReplace` and add two
    test-only hooks (`opts.rename`, `opts.renameStaging`) so
    deterministic fault-injection tests can exercise the swap and
    rollback branches without monkey-patching `fs`. In the catch
    block, attach `err.recovery = { message, cause }` when the
    rollback itself fails, so the caller can take manual action
    instead of being told "outDir is missing" with no breadcrumb.
  - `tests/transform-atomic.test.mjs`: two new cases.
    - "staging -> outDir rename fails" — original outDir is restored
      from the backup, no stray `<outDir>.bak-*` is left behind.
    - "swap fails AND rollback fails" — the thrown error has a
      `.recovery` field whose message names the backup path so the
      caller can manually move it back.

`node --test plugins/antianqi/skill-bridge/tests/*.test.mjs` reports
56/56 pass (was 54/54; +2 new atomic-replace cases).

* fix: support YAML lists and fail closed on parse errors (review #3)

The review called out two coupled defects in v0.2.0:

  1. `lib/analyze.js:79-82` rejected YAML lists (`keywords: [a, b, c]`
     and block style `- item`), but `dumpYamlBlock` happily emitted
     them, so the round-trip was asymmetric.
  2. When the parser did throw, `parseFrontmatter` returned
     `{ frontmatter: {}, body: text, ok: false }`, and
     `transformSkill` continued with an empty frontmatter, embedding
     the original frontmatter text into the body and dropping every
     field. The MCP server then reported a successful `convert`.

  - `lib/analyze.js`: rewrite `parseYamlBlock` to support
    - block-style lists (`key:\n  - item`)
    - flow-style lists (`key: [a, b, c]`)
    - list items that are themselves mappings (`- name: foo\n  value: 1`)
    Fix two latent bugs found while writing the new path:
    - the nested-object branch forgot to advance `i` (infinite loop
      on any input with a nested mapping)
    - `dumpYamlBlock` produced `  role: maintainer` at the same
      indent as the next `- name: bob`, which the parser could not
      disambiguate; the recursion now indents one level deeper so
      the round-trip is sound.
  - `lib/analyze.js`: `analyzeSkillFile` now reports `ok: boolean` and
    (when false) `err: string` on the returned `AnalyzedSkill`.
  - `server.mjs`: the `convert` tool checks `report.ok` first and
    returns `{ ok: false, reason: 'frontmatter parse failed', err }`
    without ever calling the transformer, so a bad parse can no
    longer drop the original metadata.
  - `tests/analyze.test.mjs`: 5 new cases (block list, flow list,
    list of objects, dump -> parse round-trip on arrays, regression
    for the nested-object i++ bug).
  - `tests/server.test.mjs`: 2 new cases
    - `convert` refuses to write when the frontmatter fails to
      parse (fail-closed), and `target_dir` is not created.
    - `convert` resolves a directory source to its inner SKILL.md
      (the contract the docs already promised).

`node --test plugins/antianqi/skill-bridge/tests/*.test.mjs`
reports 63/63 pass (was 56/56; +7 new cases, 0 regressions).
hetaoBackend pushed a commit that referenced this pull request Aug 25, 2026
…ax Code agents

* Add mcode-island plugin: Windows Dynamic Island status pill for MiniMax Code agents

Adds a Skill-first plugin that surfaces the agent working state in a 320x60 WPF pill anchored to the top center of the primary display, so the user can leave the terminal in the background and still watch progress.

States: idle / thinking / working / waiting / done / error.

Includes wrap-tool.ps1, a thin bash wrapper that pushes working / done / error / waiting based on $LASTEXITCODE, so the user does not have to remember to call notify-island.ps1 for every shell command.

* Add mcode-status-detect v0.2.0: state inference from mcode session log

Adds a 1-second-polling daemon that reads the active mcode session messages.jsonl and infers the agent state (idle/thinking/working/done/error) without requiring the agent to call notify-island.ps1.

State mapping:

  role=user                  -> idle

  role=assistant + toolCall  -> working "<tool>: <args>"

  role=assistant + thinking  -> thinking

  role=assistant + text      -> idle (just replied)

  role=toolResult + !isError -> done "<tool> 完成"

  role=toolResult + isError  -> error "<tool> 失败"

  mcode 进程不在              -> error "mcode 进程已退出"

  60s 无新事件                -> idle 兑底

Priority logic: agent-pushed states (with Message) are preserved; detector takes over only for settle states (idle / error).

Tested on Windows 11 24H2 + PowerShell 5.1 against a live mcode session. All 6 state transitions verified, including mcode exit and recovery.

* fix: address review feedback on PR #17 (v0.2.1)

Fixes for review comments from hetaoBackend (commit fce7c5f):

  #1 detector hard-coded path: resolve the [userprofile]/.minimax-code
     directory at runtime via the mcode node process cmdline (regex on
     @minimax-ai/code/cli.js), with fallbacks to $env:USERPROFILE/.minimax-code,
     $env:APPDATA/minimax-code, and the current working directory.
     Override with -Root [path].

  #2 idle fallback unreachable: mtime cache now returns the last inferred
     message instead of null, so the 60s stale -> idle branch fires every
     poll. Verified locally: idle :: already idle 195s after 65s of inactivity.

  #2b session log: prefer ledger.jsonl (mcode v2 event stream) and fall
     back to messages.jsonl when ledger is missing. Both formats are handled
     in Infer-State (kind/phase for ledger, message.role for messages).

  #3 PID reuse safety: start/stop-{island,detect-island}.ps1 now verify
     the target PID command line contains the expected script path before
     acting. Stale PIDs and PID-reused processes are refused with a
     REFUSED log line instead of being killed.

  #4 wrap-tool.ps1 shell-injection: removed Invoke-Expression entirely.
     The wrapper is now status-only; the agent runs the command via mcode's
     own bash tool and passes -ExitCode to publish the outcome.
     Documented in README + SKILL.md.

  #5 README: -Enable -> -Action Enable to match autostart.ps1 parameter set.

  #6 start-island.ps1 readiness: dropped the 'about to ShowDialog' log wait
     (which was never emitted). Now polls MainWindowHandle != 0 every 500ms
     for up to 8s.

Tests: validator reports OK plugin antianqi/mcode-island. wrap-tool
6-state matrix verified locally (working / done / waiting / error).

* fix(mcode-island): pick most-recently-touched session file (ledger vs messages)

Get-LatestSessionFile always preferred ledger.jsonl when present, regardless
of which file was more recently written. On systems where mcode v0.2.x left
behind a stale ledger.jsonl from a previous session, the detector would
read the old ledger every poll, the 60s idle-fallback would fire against
an ancient mtime, and the widget would stay stuck on "已静默 NNNNNs"
forever (verified: 49549s = 13.76h against a ledger that was actually
{"action":"test ledger 1"} test residue).

Fix: compare mtimes and pick whichever is newer. Fall back to ledger if
messages is absent (original fallback contract), but never let a stale
ledger shadow a live messages.jsonl.

Triggered by PR #17 review testing: 9 hours of "idle :: 已静默 49549s"
on a fresh detector after the v0.2.1 fixes were deployed.

* fix(mcode-island): tag notify-island status writes with source='agent'

notify-island.ps1 was writing status.json with only {state, message,
progress, ts} and no source field. The detector's takeover logic keys
off `cur.source -eq 'detector'` to decide whether the live entry is its
own or an externally-pushed one. With no source field on agent-pushed
states, the detector treated every agent push as "no current status" and
immediately overwrote it with whatever it had just inferred — most often
idle (60s fallback), even when the agent had just pushed `working` or
`thinking`.

Concretely: pushing `notify-island.ps1 -State working` would survive for
roughly 1 second before the detector's next poll clobbered it back to
idle. This made the manual notify tool useless for any state the detector
cares about, and made the `wrap-tool.ps1 -State working` wrap pattern
invisible on the pill.

Fix: add `source = 'agent'` to the payload. With it set, the detector's
existing precedence rules work as documented:

- agent push of working/thinking/done → preserved (not overwritten by
  the same-state detector inference, since detector-inferred
  working/thinking/done is not "settled" and does not trigger the
  takeover branch when the current entry is not the detector's own);
- agent push of idle/error → can be taken over by detector's
  idle/error inference, matching the original "detector settles agent"
  contract.

Verified live: `notify-island.ps1 -State thinking` now persists across
multiple detector polls (ts unchanged after 3.5s, message intact,
source field present).

Pushed on top of 6e99c0b on add-mcode-island.

* fix(mcode-island): kill pipeline-thread leak in detector hot loop

The detector polled once per second, and every poll walked ~15 pipeline
cmdlets: Get-ChildItem -Recurse | Where-Object | Sort-Object |
Select-Object (×2), Get-Content -Raw | ConvertFrom-Json (×3-4),
$collection | Where-Object (×3), Get-Process (×1-2), etc. PS 5.1 hidden
window has a known issue where completed pipeline tasks aren't
immediately released back to the Runspace thread pool — the pool backs
up over multi-hour runs. After ~9 hours of polling, the process was
holding ~30k threads and Get-ChildItem was effectively starved:
status.json stopped updating, island.log stopped appending, the
process looked alive but the loop was no longer advancing. Only a
restart recovered it.

Fix in three layers:

1. Replace the most expensive pipeline calls with direct .NET method
   calls so no Runspace hop is incurred:
   - Get-LatestSessionFile: Get-ChildItem -Recurse | Where-Object |
     Sort-Object | Select-Object  →  a single
     [System.IO.Directory]::EnumerateFiles + manual mtime scan
   - Get-McodePid: Get-ChildItem | foreach { Get-Content |
     ConvertFrom-Json | Get-Process }  →  EnumerateFiles + File.ReadAllText
     + Process.GetProcessById
   - Read-LastMessage: Get-Item  →  [System.IO.FileInfo]::new(...)
   - Read-StatusObj: Get-Content -Raw  →  File.ReadAllText
   - Infer-State (assistant branch): $m.content | Where-Object ×3  →
     one foreach loop with early exit (toolCall wins, no need to scan
     the rest)

2. Add a 5s TTL cache for both `mcodePid` and `latestSessionFilePath`
   in the main loop. mcode doesn't churn sub-second, and a fresh
   session log only shows up when mcode itself starts a new session,
   which is also a sub-5s event in practice. 5s is a comfortable
   upper bound that cuts the heavy directory enumeration to once per
   5s without losing visible state fidelity (the existing mtime gate
   in Read-LastMessage already gates re-parse on real content
   changes, so cache staleness is invisible to the user).

3. Verified live: after the fix, restarting the detector and running
   for 30s reports 18-28 threads (was previously climbing into the
   thousands within minutes). State transitions (working → done →
   working) still fire correctly. The 60s-idle fallback still fires
   correctly.

Side benefit: the refactor also fixes a tiny correctness wart in
Get-McodePid — when multiple .json files happen to coexist in
.mcode-active (e.g. during a restart overlap), the previous code
returned the first hit; the new code picks the most-recently-touched
one, which matches what Get-LatestSessionFile does on the messages
side.

Pushed on top of db73c11 on add-mcode-island.

---------

Co-authored-by: antianqi <antianqi@users.noreply.github.com>
… regression test

The smoke test's Check 5 sends $ACP_TOKEN as `Authorization: Bearer <token>`
to `$ACP_BASE_URL/acp/inbox/*`. Even after the v0.1.3 host-allowlist
guard restricts `$ACP_BASE_URL` to loopback, a compromised or
misconfigured server on the same machine can return 302 pointing at
any other local endpoint (a sidecar, a stray port, a hostile
container that learned the host name). Python's default
`urllib.request.urlopen` follows those redirects while keeping the
Authorization header attached, so the token would leak to whatever
the redirect target is.

This change closes the redirect path:

- New module `scripts/smoke_helpers.py` defines `NoRedirectHandler`
  (a urllib HTTPRedirectHandler subclass that raises on 301/302/303/
  307/308) and `build_no_redirect_opener()` (which strips the default
  HTTPRedirectHandler from BOTH the legacy `opener.handlers` list and
  the dispatch dict `opener.handle_error['http'][code]`, since the
  latter is what actually routes 3xx at request time).
- `scripts/smoke.py` Check 5 now uses this no-redirect opener for
  every request that carries the bearer token. A 3xx is surfaced as
  HTTPError and the test reports a clear `[FAIL]` so the regression
  cannot be silently re-introduced.
- The full body of `smoke.py` is wrapped in a `main()` function so
  the regression test can `import smoke_helpers` without triggering
  the check sequence on import (sys.exit at top level would
  terminate the importing test).

- New `scripts/test_no_redirect.py` is a real regression test
  (not a static check) that:
  1. Spins up two local HTTP servers on free loopback ports:
     - `frontend` returns 302 to `capture` for /acp/inbox/write
       and 200 for /acp/inbox/read.
     - `capture` records every Authorization header it receives.
  2. Drives the smoke test's opener against `frontend` with a
     fake token.
  3. Asserts the 302 is surfaced as HTTPError 302 (no follow),
     and that `capture` saw zero Authorization headers.
  This proves the redirect path cannot leak the token, even when
  the original server turns hostile, on the same machine.

CI workflow (`.github/workflows/openclaw-acp-bridge-smoke.yml`):

- The workflow now actually checks out the pinned SDK
  (`antianqi/openclaw-mcode-acp` @ `0641f5c`, declared in the env
  block) into a temporary directory and exports it as `$ACP_HOME`.
  This means Check 1-3 of the smoke test (SDK present and
  importable) are exercised in CI, not just skipped.
- The workflow now runs `test_no_redirect.py` in addition to
  `smoke.py`. The pin is documented inline so future bumps are
  visible.

README updated:

- New "How token leakage is prevented" paragraph references
  `test_no_redirect.py` and the no-redirect opener.
- Test evidence section now lists the regression test result.
- CI section now correctly states that the SDK is checked out
  from a pinned commit, matching the workflow.

Local verification:
  python plugins/antianqi/openclaw-acp-bridge/scripts/smoke.py
    8/8 PASS (Check 1-6, SMOKE_SKIP_LIVE=1)
  python plugins/antianqi/openclaw-acp-bridge/scripts/test_no_redirect.py
    3/3 PASS (302 refused, capture clean, GET 200)
@antianqi

Copy link
Copy Markdown
Contributor Author

Both blocking issues are fixed at 9a0939b.

What changed

# Reviewer finding Fix
1 scripts/smoke.py Check 5 used urllib.request.urlopen with the bearer token. Even with the loopback host allowlist, the same-host server could 302 to a different local origin and the default opener would follow the redirect while keeping the Authorization header attached, leaking $ACP_TOKEN to the capture endpoint. New scripts/smoke_helpers.py exposes NoRedirectHandler (overrides http_error_301/302/303/307/308) and build_no_redirect_opener() (strips the default HTTPRedirectHandler from BOTH opener.handlers AND the dispatch dict opener.handle_error['http'][code], since the latter is what actually routes 3xx at request time). Check 5 now uses this opener for every token-bearing request; a 3xx is surfaced as HTTPError and the test reports [FAIL] no-redirect policy was not applied.
2 The README claimed the CI workflow installs the SDK from a pinned commit of antianqi/openclaw-mcode-acp, but the workflow only checked out this repo. Check 1-3 were always skipped. The workflow now does an explicit actions/checkout of antianqi/openclaw-mcode-acp @ 0641f5c (declared in the workflow's env.ACP_SDK_REF so future bumps are visible) into a temporary path, then exports it as $ACP_HOME before running smoke.py. The README's "Pinned SDK revision" and "CI" sections now match what the workflow actually does.

Real regression test for the redirect case

New scripts/test_no_redirect.py (also wired into the CI workflow) is not a static check — it stands up two local HTTP servers on free loopback ports:

  • frontend: 302 to capture for /acp/inbox/write, 200 for /acp/inbox/read.
  • capture: records every Authorization header it receives.

The test drives the smoke test's opener against frontend with a fake token and asserts:

  1. The 302 is surfaced as HTTPError 302 (no follow).
  2. The 200 on GET completes without contacting capture.
  3. capture recorded 0 requests with the fake token.

This proves the redirect path cannot leak the token even when the original server turns hostile on the same machine — the test would fail loudly if NoRedirectHandler was ever replaced or bypassed.

scripts/smoke.py's body was wrapped in a main() function so the regression test can import smoke_helpers without triggering the full check sequence on import.

Verification

  • python scripts/test_no_redirect.py3/3 PASS (302 refused, capture clean, GET 200).
  • SMOKE_SKIP_LIVE=1 python scripts/smoke.py8/8 PASS (Check 1, 2, 4, 5 degraded to "skipped"; static checks 3 and 6 still run).

Ready for another review pass.

@hetaoBackend hetaoBackend left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes: the new no-redirect regression only exercises the local urllib opener inside scripts/smoke.py (the token-bearing calls at lines 165-197). The actual Skills import acp_tools from the external ACP_HOME/openclaw-skill checkout (skills/acp-collab/SKILL.md lines 28-37 and acp-task-dispatch/SKILL.md lines 23-27), and this Plugin neither ships nor validates that SDK request implementation. Therefore the real token-bearing path used by the Plugin is still not covered by the claimed redirect guarantee. Please either pin/ship a tested SDK revision whose HTTP client refuses redirects and add a test that invokes that real SDK against a redirector/capture server, or narrow the README/CI claim so it does not present the smoke-only helper as protection for runtime requests. Also note that CI sets SMOKE_SKIP_LIVE=1, so the authenticated path remains untested there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants