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
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 abuild first:message; a model older than any file in its package'ssrc/fails with exit 3 and astale doc model:message naming the package, both timestamps and the rebuild command.node plugin/scripts/generate-constructs.mts check --require-intent --only <pkg,...>— lists stale annotations and unannotated value constructs for those packages (drop--onlyto check the whole kit; every model must then be fresh).- 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. 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 animplementslink. A baregeneratereads every package's model, so a stale local build of an unrelated package would otherwise rewrite its rows (effected#839).pnpm build --filter @effected/ai-plugins— copies the regenerated tables into both committed builds underplugin/builds/. The pre-push gate blocks a push whose builds lag the source.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 likeGITHUB_*,snake_casenames) — 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
implementstarget names a package or construct that does not exist: fix or drop theimplementsfield.checkvalidates everyimplementstarget, 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 thepnpm 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
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.
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.
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.
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.
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.
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.