跳到正文
DEV Community· Duck duck builder·· 6 小時前AI 評分54

pinflow 以手繪標記與 Kane CLI 打通 AI 編碼智能體驗證閉環

Closing the AI Coding Agent Loop with Hand-Drawn Pins and Kane CLI

AI 導讀

作者 Harry 開發 pinflow,讓用戶以手繪標記和簡短備註建立 Kane CLI 瀏覽器測試,並透過 PostToolUse hook 將失敗軌跡回傳編碼智能體,供每次修改後重新驗證。

正文

Hi there,

I’m Harry. I built this little UI check tool for myself, and for you, as my entry for #KaneCLIHackday with TestMu AI.

The rules are simple: pin, check, fix and ship. Flow every UI bug from a quick pin to a passing check. That’s why it’s called pinflow: pin + flow.

I dislike writing long test scripts for every visual bug, so you don’t have to. When something looks broken on screen, drop a pin and leave a short note. When you save, Kane CLI checks it in a real browser for you.

One more rule, on purpose: if a check fails, the trace flows back to your coding agent on its own. Same after every edit. It nudges you to ship what actually works on screen, not what you assumed was fine.

  1. Live Demo: https://harrymove-ctrl.github.io/pinflow/
  2. GitHub Repository (MIT): https://github.com/harrymove-ctrl/pinflow
  3. 60s Demo Video on X: https://x.com/harry_phan06/status/2123407982851674246

The bug that unit tests kept missing

When iterating on dense dashboards and automation editors with coding agents, isolated unit tests in jsdom pass easily while real 390x844 mobile viewports ship broken.

In my own workflow dashboards, four real regressions kept slipping through:

  1. A sticky 9.5rem side rail squeezed the content column on 390px phones (532px scrollWidth inside a 364px container, causing +168px of horizontal overflow).
  2. Right-side outcome badges (+$0.48, VETO 2, VETO 0) clipped straight past the viewport edge.
  3. Entry markers on the 30D Macro candlestick strip piled on top of each other (6 colliding SVG circles).
  4. Protected safety gates could accidentally be deleted during flow edits, or internal strategy formulas leaked to guest roles.

How pinflow works inside /studio

pinflow (React, TypeScript, Vite, Tailwind) is organized into four practical views you can try immediately in the live browser build:

  1. Automation Flow Canvas (/studio?tab=canvas): A monochrome dotted canvas with 1:1 pointer card dragging, live SVG connector routing, undo and redo snapshots, role visibility lenses (L0 Guest redacts internal formulas, L1 Follower, L3 Operator), and an immutable safety-gate delete refusal guard.
  2. 390px Mobile Observatory (/studio?tab=mobile): Reproduces the real 9.5rem sticky-rail squeeze side by side against the stacked full-width fix with green (#10b981) and red (#ef4444) 30D Macro candlesticks and five unclipped filter pills (30D, All (3), XAUUSD (2), EURUSD (2), Safe BE (2)).
  3. Hand-Drawn Agentation Compiler (press A): Click any element on the canvas or 390px frame to sketch a curved ink arrow and short note. pinflow compiles that note directly into a plain-English .testmuai/tests/*_test.md Kane CLI test file plus a structured JSON handoff payload.
  4. Closed-Loop Verifier & Candidate Reward Arena (/studio?tab=loop): Runs real browser checks, compares Candidate A (buggy, scored 24/100) against Candidate B (fixed, scored 100/100), and records structured DOM telemetry.

Plain-English Kane CLI specs compiled from visual pins

Instead of hand-maintaining brittle CSS selector chains, every pin compiles into a readable TestMu AI Kane CLI Markdown spec committed directly under .testmuai/tests/. Here is .testmuai/tests/mobile_390_overflow_test.md straight from the repo:

mode: testing
tags: [pinflow, mobile-390, closed-loop]
variables:
  app_url:
    value: "http://127.0.0.1:4173"

# Mobile 390px Layout & 30D Macro Strip Verification

## Step 1: Open Fixed 390px Mobile Observatory
Open {{app_url}}/studio?tab=mobile&mode=fixed.
Set viewport to 390x844 mobile portrait.

## Step 2: Verify Zero Horizontal Overflow
Inspect `[data-testid="mobile-390-viewport"]`.
Verify scrollWidth equals clientWidth (0px horizontal overflow) and the dual-account summary bar is visible at the top.

## Step 3: Verify Outcome Badges and Filter Strip Are Unclipped
Inspect all `[data-testid="mobile-outcome-badge"]` pills (`+$0.48`, `VETO 2`, `VETO 0`) and all 5 filter controls (`30D`, `All (3)`, `XAUUSD (2)`, `EURUSD (2)`, `Safe BE (2)`) inside `[data-testid="mobile-filter-strip"]`.
Verify every badge and filter chip fits completely inside the 390px container with zero right-edge clipping.

## Step 4: Verify 30D Macro Strip Has Zero Colliding Markers
Inspect `[data-testid="macro-30d-chart"]`.
Verify every SVG circle marker has `data-marker-colliding="false"`, bullish/bearish candlesticks render in `#10b981` green and `#ef4444` red, and axis labels (`21 Oct`, `05 Nov`, `19 Nov`) remain legible.

The repository ships with three committed specs covering mobile overflow, safety-gate delete refusal (safety_gate_refusal_test.md), and hand-drawn pin compilation (agentation_compile_test.md).

Closing the loop automatically with a PostToolUse hook

Running a browser check once is helpful, but wiring its failure output straight back into the coding agent is what stops regressions from shipping.

In .claude/settings.json, pinflow attaches scripts/agent-post-edit-hook.mjs to PostToolUse on every Edit or Write:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "node scripts/agent-post-edit-hook.mjs"
          }
        ]
      }
    ]
  }
}

When scripts/kane-loop.mjs runs real browser checks (emitting TestMu AI --agent NDJSON, or invoking kane-cli testmd run <spec> --agent directly with --engine kane), any failure writes the exact DOM geometry measurements to .testmuai/last-failure-handoff.md and .testmuai/last-failure-handoff.json. The hook then prints the failure trace to stderr and exits with code 2:

if (exitCode !== 0) {
  const handoff = fs.existsSync(HANDOFF_MD)
    ? fs.readFileSync(HANDOFF_MD, "utf8")
    : "Browser verification failed. Inspect Kane CLI NDJSON output above.";
  process.stderr.write(`\n[pinflow closed-loop hook] Verification blocked commit:\n${handoff}\n`);
  process.exit(2);
}

Because the hook exits with code 2, the coding agent does not stop on a broken layout. It reads the exact overflow pixels and clipped badge count, patches the stacked layout, and re-runs verification until Round 2 returns exit 0.

Measured Round 1 vs Round 2 verification

Check (390x844 real Chromium) Round 1 (Candidate A, Buggy) Round 2 (Candidate B, Fixed)
Container width vs scrollWidth 532px inside 364px (+168px overflow) 364px inside 364px (0px overflow)
Right-side outcome badges clipped 3 clipped (+$0.48, VETO 2, VETO 0) 0 clipped
30D Macro filter chips clipped Overflowed container 0 clipped (all 5 visible)
Colliding 30D chart entry markers 6 overlapping circles 0 overlaps
Safety-gate delete refusal & L0 redaction Verified intact Verified intact
Candidate Reward Arena score 24 / 100 (Rejected, exit 1) 100 / 100 (Promoted, exit 0)

Try it locally in 3 commands

You can explore the UI right now at https://harrymove-ctrl.github.io/pinflow/ (which ships with bundled verified run evidence) or run the full closed loop on your machine:

git clone https://github.com/harrymove-ctrl/pinflow.git
cd pinflow
pnpm install
pnpm run kane:loop

To run the committed Markdown test specs directly through TestMu AI Kane CLI:

npm install -g @testmuai/kane-cli
kane-cli login
pnpm build && pnpm preview --host 127.0.0.1 --port 4173 &
kane-cli testmd run .testmuai/tests/mobile_390_overflow_test.md --agent
kane-cli testmd run .testmuai/tests/safety_gate_refusal_test.md --agent
kane-cli testmd run .testmuai/tests/agentation_compile_test.md --agent

That’s all. I hope you like it, and I’d love to hear how you are wiring real browser verification into your own coding-agent loops for #KaneCLIHackday!

來源:DEV Community · dev.to