AGENT SKILL

contract-change

Change a Cloudhal domain contract (JSON Schema in packages/core-contracts) and regenerate TypeScript and Rust types without drift. Use when adding or changing a node type, field, enum value or shared definition.

License 许可
Apache-2.0
最近更新
2026-11-15
Stars
★ 1
Forks
0

01 前言 Front Matter

name
contract-change
license
Apache-2.0
metadata
{ "cloudhal.area": "area:graph", "cloudhal.kind": "repo-skill" }
description
Change a Cloudhal domain contract (JSON Schema in packages/core-contracts) and regenerate TypeScript and Rust types without drift. Use when adding or changing a node type, field, enum value or shared definition.

03 SKILL.md 正文

Contract change

Contracts are JSON Schema 2020-12 files in packages/core-contracts/schemas/. Both src/generated/*.ts and crates/cloudhal-schema/src/generated/*.rs are produced from them and committed; CI rejects drift.

Steps

  1. Decide the version impact. Adding an optional field is non-breaking. Removing/renaming a field, changing a type, or adding a required field is breaking → bump SchemaVersion enum in common.schema.json only with an accepted RFC (write-rfc), and keep the old version's fixtures.
  2. Edit the schema. Shared shapes go in common.schema.json#/$defs; root-specific helpers in that root's $defs. Stay inside the generator-safe subset:
    • unions: oneOf + inline object variants + a one-value enum discriminator, "kind": {"type":"string","enum":["one"]} unless the domain says otherwise (field definitions use type, ADR-0043), listed in required
    • no default, $dynamicRef, unevaluatedProperties, dependentSchemas, if/then
    • cross-file refs only common.schema.json#/$defs/X or <root>.schema.json (top level)
    • additionalProperties: false on objects; maps use additionalProperties: {schema}
    • string patterns must be valid in both JS and the Rust regress crate (ECMAScript syntax; avoid lookbehind)
  3. Add fixtures. At least one fixtures/valid/<schema>/*.json exercising the new shape and one fixtures/invalid/<schema>/*.json as {"reason": "...", "data": {...}}.
  4. Regenerate and test.
    pnpm gen
    pnpm check && cargo test --workspace && cargo clippy --workspace --all-targets -- -D warnings
    
    If Rust round-trip fails, the usual causes are default (serde skips defaults) or a union shape typify turned into untagged. Fix the schema, not the generated code.
  5. Check the generated diff reads as intended (git diff packages/core-contracts/src/generated crates/cloudhal-schema/src/generated). Unexpected renames mean a title changed.
  6. Commit schema + fixtures + generated files together; add a changeset for @cloudhal/core-contracts; reference the RFC/ADR in the commit body.

References

04 同仓库更多 Skills

cloudhal-dev
cloudhal-dev/cloudhal

stale-review

Review a few published articles that have not been updated for a long time, make small safe fixes in drafts, and leave them as one proposed release for a person to schedule - never publishing anything. Built for a weekly scheduled agent task (begin_run, then end_run) that does not read visitor text. Use for a periodic content review or when asked which old articles need attention.

★ 1
cloudhal-dev
cloudhal-dev/cloudhal

site-design

Design or redesign Cloudhal pages that look modern and follow the site's own design rules (DESIGN.md). Use when asked to build, design, restyle or improve a page, a landing page or a home page, or to write the site's design rules.

★ 1
cloudhal-dev
cloudhal-dev/cloudhal

site-bootstrap

Set up a new Cloudhal site's first pages and navigation from a short brief. Use when a site is empty or the user asks to "set up", "scaffold" or "bootstrap" a site.

★ 1
cloudhal-dev
cloudhal-dev/cloudhal

safe-edit

Make a reviewable change to an existing page or article - snapshot first, edit, preview, report the diff. Use for any edit request on existing content, including re-filing an article under other categories or tags.

★ 1
cloudhal-dev
cloudhal-dev/cloudhal

rollback

Restore a site to an earlier snapshot after confirming the target with the user. Use when something published is wrong and the user asks to revert, undo or roll back.

★ 1
cloudhal-dev
cloudhal-dev/cloudhal

publish-article

Check a draft article, file it under the site's categories and tags, produce a preview and submit it for publication now or at a set time, optionally under an embargo or with an expiry. Use when the user asks to publish, release, schedule or go live with an article.

★ 1