animedex.policy.lint
Docstring lint for backend commands and MCP tools.
The lint enforces plans/02 §4 on a Click command tree: every
@cli.command(...) / @mcp.tool(...) callable must have a
docstring containing:
a
Backend:line that names the upstream;a
Rate limit:line stating the documented cap;a block delimited by
--- LLM Agent Guidance ---and--- End ---for the agent’s policy text.
The helpers below operate on Click command objects so the lint can
also drive the auto-extracted Agents Reference page in the docs
build (plans/02 §4 and the animedex --agent-guide aggregator).
check_command_docstring
- animedex.policy.lint.check_command_docstring(command: Command) List[str][source]
Validate one Click command’s docstring against the policy template.
- Parameters:
command (click.Command) – A Click
click.Command(the decorated callable, not a group).- Returns:
List of human-readable problem descriptions; empty when the docstring is well-formed.
- Return type:
lint_group
- animedex.policy.lint.lint_group(group: Group) List[Dict[str, Any]][source]
Walk a Click group recursively and collect every problem.
- Parameters:
group (click.Group) – A Click
click.Group(e.g. the top-levelanimedexgroup).- Returns:
List of
{"command": "<name path>", "problems": [...]}dicts. Empty when every nested command is well-formed.- Return type:
extract_agent_guidance
- animedex.policy.lint.extract_agent_guidance(command: Command) str | None[source]
Extract the
--- LLM Agent Guidance ---block.Returns
Nonewhen the block is absent (the command never declared one). RaisesApiErrorwithreason="malformed-guidance"when the begin marker is present but the end marker is missing - silent skip would let a typo’d docstring quietly disappear from the--agent-guidelisting, which does not runcheck_command_docstring()first.- Parameters:
command (click.Command) – A Click
click.Command.- Returns:
Text between the begin and end delimiters, stripped, or
Nonewhen the block is absent.- Return type:
str or None
- Raises:
ApiError – When the begin marker is present without a matching end marker (
reason="malformed-guidance").
collect_agent_guidance
- animedex.policy.lint.collect_agent_guidance(group: Group) List[Dict[str, str]][source]
Walk a Click group and return every command’s guidance block.
- Parameters:
group (click.Group) – A Click
click.Group.- Returns:
List of
{"command": "<name path>", "guidance": "..."}dicts, in tree-walk order, for every command that has a guidance block.- Return type: