sequencer-integration
3
总安装量
3
周安装量
#61418
全站排名
安装命令
npx skills add https://github.com/kzkymur/sequencer --skill sequencer-integration
Agent 安装分布
gemini-cli
3
github-copilot
3
codex
3
kimi-cli
3
cursor
3
opencode
3
Skill 文档
Purpose
- Help an application developer and their coding agent integrate and use @kzkymur/sequencer effectively.
- Provide minimal, reliable steps with links to focused references.
When To Use
- Building animations, audio cues, game or UI events, or any timed workflow.
- Needing linear (serial) or overlapping (parallel) event execution with millisecond control.
Quick Workflow
- Choose Mode
- Queue (class
Sequencer): run fragments strictly in order. - Independent (class
IndependentSequencer): run fragments by start time; multiple can overlap.
- Define Fragments
- Queue:
new Fragment(name, durationMs, callback?). - Independent:
new IndependentFragment(name, durationMs, startMs, callback?). - Modular:
new CustomFragment(name, startMs)thenaddFragment(...)with independent/custom fragments; duration is computed; callback cannot be set directly.
- Initialize
- Queue:
const seq = new Sequencer(pitchMs, speed=1.0, loop=false, useUniversalWorker=false). - Independent:
const seq = new IndependentSequencer(pitchMs, speed=1.0, loop=false). - Pitch is the tick interval; smaller is smoother but costlier.
useUniversalWorker=trueimproves timer precision.
- Compose
push(fragment)to append.insert(index, fragment)for Queue only (throws on Independent).remove(fragment)by identity.
- Control
await seq.play(delayMs=0); throws if already playing or delay < 0.seq.stop(delayMs=0); throws if not playing or delay < 0.await seq.waitCompleted()to await natural end (must be playing).await seq.replay(delayMs=0); requires not playing; resets time to 0.
- Visualize (optional)
seq.renderToCanvas(ctx, { width?, height?, activeColor?, inactiveColor?, timeIndicatorColor? }).
Safety & Error Guards (agent-minded)
- Validate inputs before calling:
setPitch(p > 0),setSpeed(s > 0); non-positive or NaN throws.play/stop(delay >= 0); negative or NaN throws.insert(0..fragments.length); out-of-range throws.- Duplicates: pushing a fragment with an existing
idthrows.
- Independent mode:
insert(...)always throws (unsupported). - CustomFragment: cannot set callback; name must be non-empty; start must be ⥠0.
Handy Getters
getFragments()returns a copy of current fragments.getCurrentTime()current elapsed ms.getPitch(),setPitch(...).setSpeed(...),setLoopFlag(...),isLooping().
Open These References When Needed
references/quick-start.mdâ install + minimal setup.references/api.mdâ precise method signatures and invariants.references/patterns.mdâ common patterns (UI, audio, games, tasks).references/testing.mdâ unit/integration test scaffolds.references/troubleshooting.mdâ known errors and fixes.
Notes For Coding Agents
- Prefer creating fragments once and reusing via
.copy()when repeating patterns. - Await
waitCompleted()when callers expect completion before proceeding. - For canvas, ensure
totalDuration > 0before rendering to avoid divide-by-zero visuals. - For high precision timelines, set
useUniversalWorker=true(Queue mode) and avoid heavy work in callbacks.
References
- See the skill-creator guidance in
.agents/skills/skill-creator/for structure and progressive disclosure patterns.