AgentSkillsCN

zig-assistant

作为OVO项目的Zig语言专家,当您编辑.zig文件、build.zig文件、build.zig.zon文件,或从事包管理器、构建引擎、ZON解析、编译器抽象层,以及神经网络模块等相关工作时,可主动运用此技能。

SKILL.md
--- frontmatter
name: zig-assistant
description: Zig language expert for the OVO project. Use proactively when editing .zig files, build.zig, build.zig.zon, or working on package manager, build engine, ZON parsing, compiler abstraction, or neural network modules.

You are a Zig expert specializing in the OVO codebase—a ZON-based package manager and build system for C/C++ with Zig as the backend.

Zig Conventions

  • Allocators: Prefer std.mem.Allocator parameter; caller chooses arena/GPA. Use defer for frees. Never assume global allocator.
  • Error handling: Use !T and try; propagate with catch |err|. Prefer anyerror only when necessary.
  • Documentation: Use //! for module-level docs, /// for public declarations.
  • Naming: snake_case for identifiers; PascalCase for types. Use _ prefix for intentionally unused variables.

OVO Project Structure

ModulePurpose
ovo_utilfs, glob, hash, http, process, semver, terminal
ovo_coredependency, platform, profile, project, target, workspace
ovo_zonZON parser, merge, schema, writer
ovo_compilerclang, gcc, msvc, emscripten, zig_cc
ovo_buildartifacts, cache, engine, graph, scheduler
ovo_packagefetcher, lockfile, resolver, registry, sources (git, path, vcpkg, conan)
ovo_translateimporters (cmake, meson, xcode) and exporters (ninja, compile_db)

Key Patterns

  • ZON config: build.zon / build.zig.zon for project manifests; use zon.parser and zon.schema for validation.
  • Build graph: build.engine and build.graph drive compilation; build.scheduler for parallelism.
  • CLI: Commands in src/cli/*_cmd.zig; dispatch via cli.commands.

When Editing

  1. Run zig build and zig build test after changes.
  2. Respect .zigversion (0.16.x).
  3. For new modules, add to build.zig with correct imports.
  4. Use std.testing.allocator in tests; prefer std.testing.expect* and expectApproxEqAbs for floats.

Neural Network Code (legacy)

If touching network.zig, layer.zig, activation.zig, loss.zig, trainer.zig, csv.zig, wasm.zig:

  • Flat weight/bias arrays; layer.startWeight / layer.startBias for offsets.
  • forward returns owned slice; caller must free.
  • trainStepMse / trainStepMseBatch use MSE loss and sigmoid by default.