SuperAPI AI Directory

edu-solid-geometry

Agents & models

View repository

Updated 10-15 23:59

About this skill

Solid geometry problem solving → interactive webpage

What this skill produces

A single-page HTML file that can be opened directly in a browser: on the left, the problem statement/answer/step-by-step explanation (formulas use MathJax); on the right is the 3D model corresponding to the problem (Three.js, rotatable and zoomable, highlighting key elements step by step and switching cameras). The form is consistent with template/lesson.html .

Dependencies (important)

The computation core lib/geometry_kernel.py depends on sympy. Before running the script, first confirm there is one that can import sympy python3: run python3 -c "import sympy"。

Handling when libraries are missing (important): if import reports an error (the same applies to sympy or any library used later),first ask the user whether to install, and only after getting consent help install it (python3 -m pip install <库名>), or switch to an interpreter that already has the library installed;do not install directly without asking. In the commands below, python3 all refer to this interpreter that can run the dependencies successfully.

Workflow

Step 1: Obtain the problem spec (unify the three entry points)

Organize the problem into a structured spec (format see references/problem-schema.md): geometry type and dimensions, known constructed points/conditions, the requested type and object,language。

  • Text problem: extract directly.
  • Image: extract by visual reading, andecho the recognized problem back to the user for confirmation(problem statement/geometry/dimensions/requested/language) before continuing.
  • Random problem generation: choose the geometry and problem type, use the kernel to solve with random parameters, and redraw if the answer is not neat.

Output language follows the prompt language: English prompt → English webpage, Chinese → Chinese. Record in the spec language。

Step 2: Use the kernel for exact computation (do not do mental math)

According to references/conventions.md 's coordinate system conventions and solution recipes, call lib/geometry_kernel.py: obtain exact coordinates, key vectors, normal vectors, the final answer, and the intermediate quantities to display at each step (all as LaTeX strings). Use kernel.to_three(points, scale) to obtain the three.js coordinates of the vertices.

You can first run the kernel on the command line to verify the answer, for example:

python3 lib/geometry_kernel.py    # 内置样例自检

Step 3: Assemble the lesson data and inject it into the template

📍 Output location (important): the finished HTML must always be written tothe user's current working directory (Path.cwd()), unless the user explicitly specifies a path. Neverwrite it into the skill's own directory (skills/edu-solid-geometry/output/ etc.)—that is the skill's internal development sample directory. Temporary build scripts should also be placed in cwd or a temporary directory (such as /tmp), and can be deleted after use.

Write atemporary build script, import kernel, bodies, generate, assemble the lesson / steps / model data (schema see references/problem-schema.md), then call generate.render_html(data, out) to inject the template and produce the HTML. out Use an absolute path under cwd:

from pathlib import Path
out = Path.cwd() / "solution-<题目简述>.html"   # 落在用户当前目录,而非技能目录
generate.render_html(data, out)
  • steps[*].content all numerical values indirectly reference the kernel's computation results, and the model is only responsible for organizing the explanatory text (written in the target language).
  • model.points use the results of kernel.to_three(...) ;model.spheres/edges use the topology of lib/bodies.py (quad_pyramid / tri_pyramid / cuboid / cube / prism); for rare geometric bodies, edges can be written by hand.
  • Each step is paired with highlight(the absolute set of elements visible in that step) and cameraPos。
  • When the problem statement gives segment lengths: add a measure element for the corresponding edge (label uses LaTeX, e.g. 2\sqrt{2}), and put it into the highlightof the "set up coordinate system / list known conditions" step, marking the length at the point in the 3D figure (see problem-schema).
  • For English output, fill in the lesson.ui English copy and set lesson.language="en"。

Examples that can be referenced directly:scripts/generate.py the build_data()(regular square pyramid · line-plane angle), build_cube_data()(cube · line-plane angle), andbuild_box_volume_data()(cuboid · volume) are all complete templates; just modify them accordingly.

generate.py can directly produce registered problems;when no path is passed, it defaults to writing to the current working directory (cwd), or you can explicitly give a filename under cwd (using the scripts/generate.pyin the skill directory, with output landing in cwd):

python3 <技能目录>/scripts/generate.py cube ./cube.html
python3 <技能目录>/scripts/generate.py box  ./box.html

Random problem generation:generate.py random <seed> [输出.html], internally using kernel.is_clean(...) to check that the answer is clean and redraw if it is not:

python3 <技能目录>/scripts/generate.py random 7 ./random.html   # 不给路径则默认 ./random.html(cwd)

When extending random problem types, continue using "random parameters → solve → redraw if is_clean fails".

Step 4: Self-check (corresponding to the correctness scheme)

  • kernel answer == answer card answerValue == the final value shown in the last step (generate.py already has assertion examples).
  • 3D vertex coordinates come from kernel.to_three(same source as the solution).
  • Start a local static server (servingthe directory where the output file is located, i.e. cwd) and use preview to check: no console errors, formulas render correctly, step-by-step highlighting/camera match expectations. (When developing inside the skill repository, you can use the .claude/launch.json of geom-preview; when running elsewhere, start a temporary static server for cwd.)

⚠️ You must close any ports/services you opened: stop the local service immediately once the preview check is finished,never leave behind a process occupying a port。

  • If opened with the preview tool: preview_stopimmediately after checking (pass the corresponding serverId).
  • If started directly with http.server: after use, kill it, or check lsof -nP -iTCP:<port> -sTCP:LISTEN to confirm it has been released.
  • Before delivery, confirm the port has been released, then tell the user the result. Opening without closing = self-check not completed.

Step 5: Delivery

The finished product is written tothe user's current working directory (cwd), named like solution-<题目简述>.html, tell the user the path (under cwd), and it can be opened directly in a browser. Before delivery, confirm:(1) the finished product is in cwd, not in the skill directory;(2) no local service/port opened by this preview is left over.

Extension

  • Add a problem type: in geometry_kernel.py add a solving function (see the conventions recipe table), in generate.py add a build_*。
  • Add a geometric body: in geometry_kernel.py add a coordinate construction function, in bodies.py add edge topology.

Contents

  • template/lesson.html — Data-Driven Template (Generic 3D Renderer + Data Island __LESSON_DATA__)
  • lib/geometry_kernel.py — sympy Exact Computation Core
  • lib/bodies.py — Geometric Solid Edge Topology Library
  • scripts/generate.py — Injection Template + Example Construction Functions
  • references/problem-schema.md — Data Format
  • references/conventions.md — Coordinate System Conventions, Solution Recipes, Self-Check