跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
浏览器与自动化

capability

Creates or modifies a capability class in domain/capabilities/ and its corresponding Has* interface in domain/tools/contracts.ts. Use when adding a new tool runtime behavior (agents, skills, commands, rules, mcp, hooks, settings, plugins), changing the constructor params of an existing capability class, or wiring a new capability into an existing AiTool definition. Do NOT use for AI tool definitions — use `tool` instead. Do NOT use for domain value objects or discriminant unions — use `domain-model` instead. Do NOT use for pure string transforms — use `format` instead.

ai-driven-dev · 已有 AI 审核记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add ai-driven-dev/framework --skill capability

技能说明


name: capability description: > Creates or modifies a capability class in domain/capabilities/ and its corresponding Has* interface in domain/tools/contracts.ts. Use when adding a new tool runtime behavior (agents, skills, commands, rules, mcp, hooks, settings, plugins), changing the constructor params of an existing capability class, or wiring a new capability into an existing AiTool definition. Do NOT use for AI tool definitions — use tool instead. Do NOT use for domain value objects or discriminant unions — use domain-model instead. Do NOT use for pure string transforms — use format instead.

Capability

Builds a capability class that encapsulates one tool runtime behavior and its corresponding Has* interface in domain/tools/contracts.ts. Each capability class is instantiated in exactly one AiTool<C> file; the Has* interface declares the typed field in the C parameter.

Available actions

#ActionRoleInput
01define-has-interfaceDeclare the Has* interface in domain/tools/contracts.tscapability name + field type
02write-capability-classWrite the capability class in domain/capabilities/Has* interface from 01
03wire-into-toolAdd the capability to an AiTool definitioncapability class from 02
04testWrite unit tests covering constructor params and public APIcompleted capability from 02

Default flow

01 → 02 → 03 → 04

Skip 01 when the Has* interface already exists in contracts.ts and only the class needs updating. Skip 03 when the new capability is not yet needed by any existing tool (e.g. adding it speculatively).

Transversal rules

  • Has* interface lives in domain/tools/contracts.ts; the field type is the capability class.
  • Capability class file lives in domain/capabilities/<kebab-name>-capability.ts; one class per file.
  • Capability class name ends in Capability (e.g. WidgetsCapability).
  • Constructor accepts a single params object; no positional arguments.
  • All public fields are readonly; no setters.
  • Throw CapabilityConfigError (from domain/errors.ts) on invalid constructor params.
  • Capability presence guard uses the in operator: "widgets" in tool.capabilities — never instanceof.
  • Named export only; no default export.
  • No any types.
  • .js extensions on all relative imports.

References

  • references/capability-conventions.md — class shape, constructor params object, CapabilityConfigError, readonly fields
  • references/has-interface.md — Has* interface placement, naming, and capability-presence guard

Invariant rules

  • references/capability-conventions.md — authoritative capability class rules