Index of every page on this site: llms.txt
All skills
oahc09 avatar

/cocosair-agent-session

@ed38648
by oahc09oahc09/cocosairjs3 stars
2
Run it yourself

Inspect live scenes and frames with devtools; read runtime diagnostics. Use for scoped session writes, pixel probes or duplicate requestId INVALID_ARGUMENT errors.

  • 9 files
  • 34.7 KB
  • MIT
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/oahc09/cocosairjs/cocosair-agent-session

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencescommon-mistakes.md

≈963 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Derived from the cocosair-agent-session skill and its canonical docs/source pointers; reorganized on 2026-10-11. Source annotations below identify repository inputs, not files guaranteed to ship to npm consumers.

Common Mistakes

[HIGH] Blindly retrying a write with the same requestId

Wrong:

// a create/add failed to reach the page; assuming dispatch is an idempotent replay:
await session.dispatch({ requestId: 'a2', action: 'setTransform', targetId: id, params: { space: 'local', position: [0, 0, 0] } });
// ...network hiccup, then retry the SAME requestId expecting the original result
await session.dispatch({ requestId: 'a2', action: 'setTransform', targetId: id, params: { space: 'local', position: [5, 5, 5] } });

Correct:

const first = await session.dispatch({ requestId: 'a2', action: 'setTransform', targetId: id, params: { space: 'local', position: [0, 0, 0] } });
if (!first.ok && first.error.code !== 'INVALID_ARGUMENT') {
    const retry = await session.dispatch({ requestId: 'a2-retry', action: 'setTransform', targetId: id, params: { space: 'local', position: [0, 0, 0] } });
}

A duplicate requestId within the 60s retention window (or while still running) returns ok: false with INVALID_ARGUMENT, not the original result (tools/debug/agent-session.ts:673-678); use a fresh requestId and inspect ok before retrying.

[HIGH] Treating the devtools session as a default-runtime API in app code

Wrong:

// shipped application code, not under a dev server:
import { createAgentSession, inspectScene } from 'cocosair';
const session = createAgentSession({ app });   // these names are not on the cocosair export

Correct:

// runtime app code only publishes the binding:
window.__airApp = app;
// a dev-only tool attaches the session through the dev server route:
const { createAgentSession } = await import('/__debug/agent-session.js');
const session = createAgentSession({ app, writableScenes: [app.getScene()] });

createAgentSession, inspectScene, dispatch and the probes live in tools/debug/agent-session.ts and are not on the runtime bundle export; the automation example loads them only via the dev server's /__debug/ route (examples/automation/main.ts:50, tools/dev/dev-server.cjs:337).

[MEDIUM] Confusing the runtime diagnostics channel with the devtools error ring buffer

Wrong:

const errs = app.diagnostics.getRuntimeErrors();   // no such method on AirDiagnostics
const snap = session.getRuntimeErrors().snapshot;  // Collector returns { errors, dropped }, not a snapshot field

Correct:

const runtime = app.diagnostics ? app.diagnostics.snapshot() : [];   // bounded 80-entry runtime channel
const devtools = session.getRuntimeErrors();                          // { errors, dropped } ring, default cap 200

AirDiagnostics exposes snapshot/onMessage/clear/destroy only (src/air/diagnostics.ts:16-20), while getRuntimeErrors is the devtools Collector.list returning { errors, dropped } (tools/debug/agent-session.ts:306-313, :647).

[MEDIUM] Reading raw canvas pixels with a screenshot-style origin

Wrong:

// measuring a top-left rectangle directly against gl.readPixels output
measurePixelRegions({ width, height, data }, [{ x: 0, y: 0, w: 40, h: 40 }], { origin: 'top-left' });

Correct:

// screenshot pixels are top-left; readPixels rows are bottom-left, so use the canvas helper
measureCanvasRegions(canvas, [{ x: 0, y: 0, w: 40, h: 40 }], { distance: 30 });

measurePixelRegions defaults to a top-left origin for screenshot bytes, but measureCanvasRegions forces bottom-left because gl.readPixels rows are inverted, and lit is RGB distance from each region's modal background with a distance of 30 (tools/debug/pixel-regions.mjs:5, :11, :47-54).

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at ed38648. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
layer
subsystem
All 1 allowed tools
Read Bash
Other metadata
compatibility
Cocos AIR source checkout or installed cocosair.js package. Browser rendering requires WebGL 2; source tooling requires Node.js >=18. Use the host-provided tools and user-authorized workspace.
when_to_use
[
  "inspect the running scene or node",
  "apply a scoped change through an agent session",
  "capture a frame after drawing",
  "read runtime errors and diagnostics",
  "duplicate requestId is rejected"
]
owns
[
  "agent-session",
  "scene-inspection",
  "scoped-writes",
  "frame-capture",
  "pixel-probes",
  "runtime-diagnostics"
]
not_for
[
  "app startup or shutdown -> cocosair-application",
  "verification gates and release evidence -> cocosair-verification",
  "scene-tree implementation -> cocosair-scene-graph"
]
metadata
{
  "author": "oahc09@gmail.com",
  "version": "1.0.0",
  "last-updated": "2026-10-13",
  "description_zh": "使用开发工具观察运行时、按明确范围写入、捕获画面和读取诊断。用于实时应用检查或受控自动化,工具不属于默认运行时包。"
}

README badge

README badge for oahc09/cocosairjs/cocosair-agent-session