SuperAPI AI Directory

lov-algo-viz-creator

Coding & development

View repository

Updated 10-19 11:40

About this skill

Algorithm Theater

Turn an algorithm, data structure, or information flow into an interactive diagram that can be opened directly by double-clicking and played back step by step (single-file HTML). Each frame corresponds to one visible state change, with Chinese narration, pseudocode highlighting, and playback controls, suitable for lectures, presentations, and self-study demonstrations.

The generated HTML does not depend on any external CDN or build tools; it works offline and demonstrates immediately on double-click.

Triggers

Activate when

  • "Make {algorithm} into a visualization / diagram / animation"
  • "Write a step-by-step demonstration for {data structure/flow}"
  • "Use visualization to explain {KMP / quicksort / Dijkstra / knapsack / climbing stairs …} clearly"
  • "Help me draw a presentation slide (algorithm-oriented)"
  • “build a step-by-step visualization for {algorithm}”
  • “make an interactive demo of {data structure / process}”
  • “create an algorithm explainer animation”

Do not activate when

  • If you only need a static schematic, architecture diagram, or relationship diagram (no step-by-step logic) → hand it to lov-bp-deck、 lov-diagram or frontend-design。
  • If you need brand-level long-form/article illustrations → hand it to document-illustrator / baoyu-article-illustrator。
  • To embed the visualization into an existing React application and require state management → this project's style: directly follow TraceDefinition write a TS module based on the data model, reuse the application's player, and do not use this Skill's single-file HTML output.

User Profile (cross-session)

Every generated Skill is connected to the shared user-profile/v1 contract in skill.yaml. Read the shared user, brand, workspace, preferences, and this Skill's skills.<skill_id> namespace at the start of every run. Keep the source portable: resolved personal values belong in the shared profile, never here.

When the user directly states a durable preference or brand fact, persist it through scripts/profile_store.py and report the saved profile path. Put Skill-specific values under records.<field>; use brand.<field> or user.<field> for shared values. Do not persist inferred secrets or credentials. See references/user-profile.md for the complete contract.

Skill Group Composition

Read references/skill-composition.md before deciding whether to invoke or extend any adjacent capability. The record distinguishes optional upstream and downstream handoffs from embedded Kit modules. Do not silently depend on a sibling Skill that is not shipped with this source.

Workflow (MANDATORY)

You MUST follow these steps in order.

Step 0: Resolve skill root, dependencies, and runtime context

  • Use SKILL_DIR if the environment provides it.
  • Otherwise infer the installed skill directory from the current skill context.
  • Verify every required local module, reference, script, and asset before work:
    • scripts/validate_viz.py(frame model validation)
    • scripts/build_viz.py(model → HTML)
    • assets/template.html(demonstration engine template)
    • references/step-model.md(frame model specification and examples)
  • If a required resource is missing, name its expected relative path and stop before producing a partial result.

When running scripts manually:

export SKILL_DIR="/path/to/lov-algo-viz-creator"

Resolve context.profile on every invocation. The precedence is current request, project context, Skill-specific profile records, shared preferences, shared brand/user profile, then safe defaults. A direct user statement about a durable preference or brand fact should be saved with scripts/profile_store.py record using --confirm, followed by a concise saved-path report.

Step 1: Understand the requested outcome

  • Determine the object to visualize: is it an algorithm, a data structure, or a business/information flow?
  • Determine the sample data and target audience (self-study / lecture / presentation).
  • Clarify the delivery location: by default, write to ./output/(according to the output specification); if the user specifies a path, respect the user.
  • If the algorithm has multiple implementations (recursive/iterative, different heuristics), first confirm which one to use; do not decide on your own and cause rework. For other technical details (layout, number of frames, wording), decide on your own according to the principles of this Skill.

Step 1.5: Analyze nearby Skills before implementation

  • Inspect related local and installed Skills by routing contract and concrete input/output, not by filename alone.
  • Record upstream, core, downstream, overlap, and not-composed decisions in references/skill-composition.md.
  • Keep sibling Skills optional and artifact-based. When stages require hard coupling for one outcome, create a self-contained Kit instead.

Step 2: Model the algorithm as step frames

This is the core of this Skill. First "translate" the algorithm into a frame sequence, then hand it to the engine for rendering.

Six principles of frame-by-frame modeling(see references/step-model.md):

  1. Minimal advance unit: each frame = one visible state change (one comparison, one swap, one visit, one relaxation, one push…). Fine-grained mechanical operations are merged into one frame; the target number of frames is 5–40.
  2. active vs settled:active is the element currently being operated on (1–3 per frame, focused); settled is the element that has been determined/completed/visited (monotonically accumulated, never changes back). The audience relies on these two groups of colors to read progress.
  3. Use valuesfor dynamic values: put "intermediate results" such as values filled into the DP table, shortest distances, and counts into values(the node layout is {节点id: 显示文本}, and the bars layout is an array snapshot).
  4. One-sentence narrative: each frame's note uses one Chinese sentence to clearly explain "what this step is doing + why", referencing specific values/characters ("B matches D, continue comparing the next position"), without piling up jargon or making empty statements.
  5. Pseudocode alignment:code Write 4–8 lines of human-language pseudocode,codeLine pointing to the current logical line, so the audience knows "which step this moment corresponds to".
  6. Opening and closing frames: the opening frame explains the input and starting point; the closing frame summarizes the result ("the topological order is ...").

Choose a layout:

  • sequence: array/sequence/string (KMP, binary search, Fibonacci, Z-array)
  • network: graph/tree/flow/dependency (BFS, Dijkstra, topological sort, Trie, architecture flow)
  • matrix: 2D DP table / distance matrix (knapsack, LCS, Floyd–Warshall)
  • bars: numerical sorting/comparison (bubble sort, quicksort, heap sort)

Produce in the following order:

  1. First write a model.json(full schema and examples in references/step-model.md), andactually run it oncedirectly on the algorithm, recording active/settled/values frame by frame; do not make up frames from imagination.
  2. Use scripts/validate_viz.py model.json to validate (errors must be zeroed out, warnings converge per --strict ).
  3. Use scripts/build_viz.py model.json -o output/xxx.html to generate standalone HTML.
  4. Open the generated file and do a "manual walkthrough": whether the narrative holds at every step, whether the frame order is correct, and whether the layout occludes anything.

Step 3: Validate the deliverable

  • Validation passed:validate_viz.py error=0。
  • HTML generated successfully:build_viz.py has an explicit output path; double-click to open.
  • Content walkthrough: every note sentence is accurate, codeLine is aligned, no occlusion, no emoji (use inline SVG icons).
  • Report: give the output file path, frame count, layout, and demo controls (space to play, ←/→ to step frame by frame).

Dependencies

  • python3(running validate_viz.py / build_viz.py)。
  • requires no npm, no build step, no external CDN.
  • The artifact is self-contained HTML and can be opened in a browser (modern Chrome/Safari/Edge/Firefox).