AGENT SKILL

constructs

Use when maintaining the generated construct index at plugin/skills/effected-packages/references/constructs/ — regenerating it after a package's exports change, authoring intent annotations for new value-kind exports, or repairing a construct-index.bats failure (drift, stale annotation, missing intent). The index is generated; never hand-edit it.

License 许可
MIT
最近更新
2026-11-14
Stars
★ 8
Forks
2

01 前言 Front Matter

name
constructs
description
Use when maintaining the generated construct index at plugin/skills/effected-packages/references/constructs/ — regenerating it after a package's exports change, authoring intent annotations for new value-kind exports, or repairing a construct-index.bats failure (drift, stale annotation, missing intent). The index is generated; never hand-edit it.

03 SKILL.md 正文

Maintaining the construct index

The construct index (effected#188) is one generated markdown table per kit package under plugin/skills/effected-packages/references/constructs/, rendered by plugin/scripts/generate-constructs.mts from each package's build-emitted doc model (packages/<dir>/dist/prod/npm/meta/<dir>.api.json) joined with plugin/scripts/construct-annotations.json. The generated files are never hand-edited — every change flows through the annotations file or the source itself, then regeneration.

plugin/__test__/construct-index.bats enforces three things: the committed files match a fresh regeneration, no annotation names a construct that no longer exists, and every value-kind export (Class / Variable / Function / Enum) carries an intent annotation. Interfaces and type aliases ride on their TSDoc summary; annotating them is optional.

The loop

  1. pnpm build --filter @effected/<pkg> for each package you changed — the doc models must postdate the source. A missing model fails the generator with exit 2 and a build first: message; a model older than any file in its package's src/ fails with exit 3 and a stale doc model: message naming the package, both timestamps and the rebuild command.
  2. node plugin/scripts/generate-constructs.mts check --require-intent --only <pkg,...> — lists stale annotations and unannotated value constructs for those packages (drop --only to check the whole kit; every model must then be fresh).
  3. Author what it lists in plugin/scripts/construct-annotations.json (shape below). Read the construct's source first — never write intent keywords from the name alone.
  4. node plugin/scripts/generate-constructs.mts generate --only <pkg,...> — rewrites only those packages' committed tables, leaving every other table byte-identical. Name every package whose table the change touches, including the other side of an implements link. A bare generate reads every package's model, so a stale local build of an unrelated package would otherwise rewrite its rows (effected#839).
  5. pnpm build --filter @effected/ai-plugins — copies the regenerated tables into both committed builds under plugin/builds/. The pre-push gate blocks a push whose builds lag the source.
  6. bats plugin/__test__/construct-index.bats — must be green before commit.

Annotations file shape

{
 "<packageDir>": {
  "<ConstructName>": "intent keywords as a plain string",
  "<OtherName>": {
   "intent": "intent keywords",
   "implements": "<packageDir>.<ContractName>"
  }
 }
}

implements is single-sided: annotate only the implementing construct; the generator inverts the link so the contract's row says "implemented by …" and the implementation's row says "implements …" — both packages' files update from one entry.

Writing intent keywords

The intent column is what an agent greps when it knows the goal but not the name — that failure mode is the whole reason the index exists (four real misses documented in #188). Rules:

  • Write the words a consumer would search: verbs plus objects. "validate NTIA minimum elements, check SBOM compliance" — not "NTIA report class".
  • Never restate the construct's name; the name is already in the row.
  • Aim for 3–12 words, hard cap 14, lowercase, comma-separated phrases. Terse beats complete.
  • Emphasis-active tokens — anything containing * or _ (env-var patterns like GITHUB_*, snake_case names) — must be wrapped in code spans. The pre-commit markdown fixer rewrites bare emphasis-like sequences, and an un-spanned token breaks the committed-equals-regenerated fixed point.
  • A schema-plus-class merged row gets ONE annotation covering both faces.
  • If two constructs are a contract/implementation pair across packages, the implementing side carries implements — check for the kit's known splits (commands/workspaces, npm/workspaces, sbom/github-actions).
  • A construct whose TSDoc summary already contains the searchable verbs still needs an annotation if it is value-kind — the check does not parse prose.

Repairing a red construct-index.bats

  • "has drifted" — someone changed exports or annotations without regenerating: run step 4 for the drifted packages and commit the result. Never hand-edit the tables. If it goes red AGAIN after that regeneration+commit, the markdown fixer mutated a cell at commit time — code-span the offending emphasis-active token in the annotation (rule above) and regenerate once more. Never loop on plain regeneration; that never converges against a fixer that keeps rewriting the same token.
  • "stale annotation" — the export was renamed or removed: move or delete the annotation entry, regenerate.
  • "dangling implements" — an implements target names a package or construct that does not exist: fix or drop the implements field. check validates every implements target, not just staleness of the annotated name itself.
  • "missing intent annotation" — a new value-kind export landed: author it (rules above), regenerate.
  • "build first" (exit 2) — the doc models are missing: pnpm build, then rerun.
  • "stale doc model" (exit 3) — a package's src/ is newer than its model: run the pnpm build --filter … command the message prints, then rerun. If the same package is still stale after that build, turbo replayed a cache hit onto an unchanged model (the source was touched without changing — a branch switch or rebase): rebuild it with --force.

04 同仓库更多 Skills

spencerbeggs
spencerbeggs/effected

testing-actions

Use when writing or reviewing tests for @effected/github-actions, @effected/github, @effected/sbom or @effected/commands — stubbing the GitHub API, writing a service's layerTest or makeTest double, testing the pre/main/post lifecycle through Action.run, or debugging why a test hits the real network or hangs.

★ 8
spencerbeggs
spencerbeggs/effected

supply-chain-attestation

Use when generating a CycloneDX SBOM, checking NTIA minimum elements, building an in-toto statement or a SLSA provenance predicate, signing into a Sigstore DSSE bundle, or uploading an attestation to GitHub.

★ 8
spencerbeggs
spencerbeggs/effected

structuring-an-action

Use when laying out a new GitHub Action repository on the @effected suite, deciding where a piece of code belongs (an entry point, a step, a shared service, a shim), or reviewing an existing action's file structure against the canonical shape.

★ 8
spencerbeggs
spencerbeggs/effected

running-commands-and-tools

Use when running a subprocess in Effect v4, spawning a command, capturing stdout/stderr/exit code, checking whether a CLI tool is installed or which copy to run, running a package-manager script through the project's launcher, detaching a background process, or redacting a secret from argv or captured output.

★ 8
spencerbeggs
spencerbeggs/effected

release-and-publish

Use when publishing a package to npm, reading the npm registry from Effect v4, checking whether a version is already published, cutting a release tag or GitHub release from an action, applying a release-age gate, or deriving tracking tags for GitHub Actions distribution.

★ 8
spencerbeggs
spencerbeggs/effected

hardening-a-parser-port

Use when porting or writing a recursive-descent parser, lexer, or tree-walker over untrusted text in the @effected monorepo — the class of hardening the cloud reviewer scans for on every migration. Covers stack-overflow depth guards (on EVERY recursion surface, which a facade has N of — not two), numeric bound guards that must reject NaN and non-integers, code-point range checks scoped to formats with wide escapes, prototype-pollution, control-character rejection, and the invariant that malformed input must fail through the typed error channel, never as an unhandled defect.

★ 8