codenib.agent.skills
¶
Declarative skill definitions for CodeNib agents.
Built-in skills are loaded from sub-packages via SkillLoader.
User code can still define additional skills with the @skill decorator.
Modules:
| Name | Description |
|---|---|
bm25_search |
|
code_to_query |
|
codenib_context |
|
context |
Typed skill-context layer. |
core |
Core data structures for skill definitions. |
crossencoder_rerank |
|
embedding_search |
|
find_callees |
|
find_callers |
|
hybrid_search |
|
llm_rerank |
|
loader |
Skill package loader. |
registry |
Skill registry and |
trace |
|
typecheck |
Type parsing, runtime arg coercion, and skill-dataflow type checking. |
Classes:
| Name | Description |
|---|---|
Cost |
Relative cost hint for the policy engine. |
SkillInputSpec |
Type specification for a single skill input. |
SkillMetadata |
Pure-data descriptor for a registered skill. |
SkillOutputSpec |
Type specification for skill output. |
SkillType |
Execution characteristic of a skill. |
SkillLoader |
Load skill packages from a directory into the |
SkillRegistry |
Global catalogue of skill metadata. |
Functions:
| Name | Description |
|---|---|
skill |
Register a function as a skill. |
Cost
¶
Bases: str, Enum
Relative cost hint for the policy engine.
SkillInputSpec
dataclass
¶
SkillInputSpec(
name: str,
type_hint: str,
required: bool = True,
default: Any = None,
description: str = "",
enum: list[str] | None = None,
is_line_number: bool = False,
)
Type specification for a single skill input.
SkillMetadata
dataclass
¶
SkillMetadata(
skill_id: str,
skill_type: SkillType,
inputs: list[SkillInputSpec] = list(),
outputs: SkillOutputSpec = (lambda: SkillOutputSpec(type_hint="Any"))(),
executor_fn: Callable[..., Any] | None = None,
async_capable: bool = False,
cacheable: bool = True,
cost: Cost = MEDIUM,
dependencies: list[str] = list(),
resources: list[str] = list(),
operator: str | None = None,
defaults: dict[str, Any] = dict(),
index_requirements: list[Any] = list(),
skill_doc: str = "",
description: str = "",
)
Pure-data descriptor for a registered skill.
The executor_fn is the only non-serializable field — the Rust compiler
will never touch it; the Python scheduler calls it at execution time.
Methods:
| Name | Description |
|---|---|
to_dict |
JSON-friendly dict (excludes |
to_dict
¶
JSON-friendly dict (excludes executor_fn).
Source code in codenib/agent/skills/core.py
SkillOutputSpec
dataclass
¶
Type specification for skill output.
SkillType
¶
Bases: str, Enum
Execution characteristic of a skill.
SkillLoader
¶
Load skill packages from a directory into the SkillRegistry.
Each skill package is a subdirectory containing:
config.yaml— skill metadata and default parametersskill.md— agent-readable description (optional)executor.py—create_executor(context) -> Callablefactory
Methods:
| Name | Description |
|---|---|
load_all |
Scan skills_dir for subdirectories containing |
load_skill |
Load a single skill package from skill_dir. |
load_all
¶
load_all(
skills_dir: str,
contexts: dict[str, Any] | None = None,
*,
registry: SkillRegistry | None = None
) -> list[SkillMetadata]
Scan skills_dir for subdirectories containing config.yaml
and load each as a skill package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skills_dir
|
str
|
Path to the skills directory. |
required |
contexts
|
dict[str, Any] | None
|
Mapping of context-type names to context objects
(e.g. |
None
|
registry
|
SkillRegistry | None
|
Registry to populate; defaults to the singleton. |
None
|
Returns:
| Type | Description |
|---|---|
list[SkillMetadata]
|
List of loaded |
Source code in codenib/agent/skills/loader.py
load_skill
¶
load_skill(
skill_dir: str, contexts: dict[str, Any] | None = None
) -> SkillMetadata | None
Load a single skill package from skill_dir.
Returns None if the directory lacks a config.yaml.
Source code in codenib/agent/skills/loader.py
SkillRegistry
¶
skill
¶
skill(
skill_id: str,
skill_type: SkillType,
inputs: list[SkillInputSpec] | None = None,
outputs: SkillOutputSpec | None = None,
*,
dependencies: list[str] | None = None,
resources: list[str] | None = None,
cost: Cost = MEDIUM,
operator: str | None = None,
async_capable: bool = False,
cacheable: bool = True,
defaults: dict[str, Any] | None = None,
index_requirements: list[Any] | None = None,
skill_doc: str = "",
description: str = ""
) -> Callable[[Callable[..., Any]], Callable[..., Any]]
Register a function as a skill.
Usage::
@skill(
skill_id="embedding_search",
skill_type=SkillType.RETRIEVAL,
inputs=[SkillInputSpec(name="query", type_hint="str")],
outputs=SkillOutputSpec(type_hint="List[QueriedNode]"),
operator="faiss.retrieve",
cost=Cost.HIGH,
)
def embedding_search(query: str, top_k: int = 10) -> List[QueriedNode]:
...
The decorator only stores metadata — the function body is the execution logic invoked by the scheduler.