[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7ATG0G2KHVKABCTHZ9X4585":3,"skill-same:01M7ATG0G2KHVKABCTHZ9X4585":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7ATG0G2KHVKABCTHZ9X4585","tny-tool-extensions",null,"Write, test and debug tny Python tool extensions (@tny.tool, tny.group, tny.proxy, folder modules, schemas). Use when asked to add a tool, command or MCP proxy to tny.","thehumanworks\u002Ftny","thehumanworks","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F178243268?v=4","01M7ATFN18HGD2MMZM8798C4T9","Tomas Roda","01M7ATFN1Y1WDK31RADZB53QSC",0,"MIT","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002Fskills\u002Ftny-tool-extensions\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: tny-tool-extensions\ndescription: Write, test and debug tny Python tool extensions (@tny.tool, tny.group, tny.proxy, folder modules, schemas). Use when asked to add a tool, command or MCP proxy to tny.\n---\n\n# Writing tny tool extensions\n\nA tool extension is a Python module of `@tny.tool` functions. Once the file is\nin an extension directory, each tool is callable everywhere with no restart\nand no registration step:\n\n- **CLI:** `tny MODULE [GROUP...] TOOL --flag value`, or `tny tool call NAME '{json}'`.\n- **Code mode:** `tools.MODULE.TOOL(arg=...)` or `tools.call(\"MODULE.TOOL\", json)`.\n- **MCP:** `tny mcp serve` serves the tools to other agents.\n\nFull reference: `docs\u002Fextensions.md` in the tny repository (ADR 0218).\n\n## Workflow\n\n1. **Pick the scope.**\n   - Project: `\u003Crepo>\u002F.tny\u002Fextensions\u002Ftools\u002F`, shared with the repo. This is the default.\n   - Global: `~\u002F.tny\u002Fextensions\u002Ftools\u002F`, for every workspace. Use it only when the user asks for a personal tool.\n2. **Pick the shape.** Use the table below.\n3. **Scaffold** with `tny tool new NAME [--folder] [--global]` or write the file directly. `NAME` must be a Python identifier that is not a tny command (`ask`, `tool`, `status`, ...).\n4. **Verify.** Run `tny tool check`, which must exit 0 and list your tools. Then call each tool once from the CLI. Then run `tny MODULE --help`.\n5. **Tell the user** the exact command to run, for example `tny jira projects list --status open`.\n\n| Need | Shape | Resulting names |\n| --- | --- | --- |\n| One action | `NAME.py` with one `@tny.tool` | `NAME` |\n| A few related actions | `NAME.py` with several tools | `NAME.a`, `NAME.b` |\n| Sub-commands in one file | `NAME.py` plus `tny.group(\"sub\")` | `NAME.sub.x` |\n| Many tools, shared helpers | `NAME\u002F__main__.py` plus submodules | `NAME.x`, `NAME.sub.y` |\n| Wrap an existing MCP server | `NAME.py` with `tny.proxy(...)` | `NAME.\u003Cremote tool>` |\n\n### Naming rules\n\n- The module (file or folder) name is the top-level name.\n- If a module has exactly one tool and no groups, that tool is called by the module name, whatever the function is called.\n- The tool name is the function name with leading and trailing `_` removed, or `name=`. Use `name=\"list\"` rather than shadowing the `list` builtin.\n- Names use letters, digits, `_` and `-`, start with a letter or `_`, and are at most 64 characters.\n- Files and folders starting with `_` or `.` are never loaded as extensions. Put shared code in `_client.py`.\n- Native tools (`read_file`, `terminal`, ...) and built-in commands always win over an extension with the same name. A project module shadows a global one with the same name, and `tny tool check` reports it.\n\n## Example 1: one tool\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fcall_advisor.py\nimport tny\n\n\n@tny.tool\ndef call_advisor(question: str, depth: int = 1) -> str:\n    \"\"\"Ask the advisor one question.\n\n    Args:\n        question: What to ask.\n        depth: How hard to think, 1 to 3.\n    \"\"\"\n    if not 1 \u003C= depth \u003C= 3:\n        raise tny.ToolError(\"depth must be 1, 2 or 3\")\n    return f\"advice on {question} (depth {depth})\"\n```\n\nCall it with `tny call_advisor \"why?\" --depth 2`, or as `tools.call_advisor(question=\"why?\")` in code mode.\n\n- The docstring's first paragraph is the description the model sees, and `Args:` describes each parameter. Google, NumPy and Sphinx styles all work.\n- A module docstring is the module's description in `tny --help` and `tny MODULE --help`. A group's description comes from `tny.group(\"name\", \"description\")` or from its submodule's docstring. Write one short first paragraph for each.\n- A parameter without a default is required, and the CLI also accepts it positionally.\n\n## Example 2: several tools in one file\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fdeploy.py\n\"\"\"Deployment helpers: deploy.status, deploy.start, deploy.wait.\"\"\"\n\nimport asyncio\nimport enum\nfrom typing import Literal\n\nimport tny\n\n\nclass Env(enum.Enum):\n    STAGING = \"staging\"\n    PROD = \"prod\"\n\n\n@tny.tool\ndef status(env: Env = Env.STAGING) -> dict[str, str]:\n    \"\"\"Current deployment status for an environment.\"\"\"\n    return {\"env\": env.value, \"state\": \"healthy\"}  # a dict is returned as JSON\n\n\n@tny.tool(timeout=900)  # seconds; the default limit is 300\ndef start(\n    ref: str, env: Env, strategy: Literal[\"rolling\", \"blue-green\"] = \"rolling\"\n) -> str:\n    \"\"\"Deploy a git ref.\n\n    Args:\n        ref: Branch, tag or commit to deploy.\n        env: Target environment.\n        strategy: How to roll it out.\n    \"\"\"\n    if env is Env.PROD and ref.startswith(\"wip\"):\n        raise tny.ToolError(\"refusing to deploy a wip ref to prod\")\n    return f\"deploying {ref} to {env.value} ({strategy})\"\n\n\n@tny.tool\nasync def wait(seconds: float = 0.1) -> str:\n    \"\"\"Wait for the rollout to settle.\"\"\"\n    await asyncio.sleep(seconds)  # async tools are run to completion\n    return \"settled\"\n```\n\n- Arguments are validated and converted before your function runs, so `env` arrives as an `Env` member. Bad input never reaches your code.\n- On the CLI, enums and `Literal` become choices: `tny deploy start v1.2 --env prod --strategy blue-green`.\n\n## Example 3: groups in one file\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fissues.py\nimport tny\n\nlabels = tny.group(\"labels\", \"Manage issue labels\")\n\n\n@tny.tool(name=\"list\")\ndef list_issues(state: str = \"open\", limit: int = 20) -> list[dict[str, object]]:\n    \"\"\"List issues.\"\"\"\n    return [{\"id\": 1, \"state\": state}][:limit]\n\n\n@labels.tool\ndef add(issue: int, label: str) -> str:\n    \"\"\"Add a label to an issue.\"\"\"\n    return f\"#{issue} +{label}\"\n\n\n@labels.tool(name=\"remove\")\ndef remove_label(issue: int, label: str) -> str:\n    \"\"\"Remove a label from an issue.\"\"\"\n    return f\"#{issue} -{label}\"\n```\n\nThis gives `issues.list`, `issues.labels.add` and `issues.labels.remove`, and the CLI runs `tny issues labels add 7 bug`. A group can nest further with `labels.group(\"colors\")`.\n\n## Example 4: a folder module\n\nUse a folder when the tools share a client, configuration or helpers. The entry point is `__main__.py`.\n\n- Submodules that `__main__.py` imports become groups named after the file.\n- Use relative imports.\n- Read secrets from the environment, never from the file.\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fjira\u002F__main__.py\n\"\"\"Jira tools.\"\"\"\n\nimport tny\n\nfrom . import projects  # noqa: F401  (registers jira.projects.*)\nfrom ._client import client\n\n\n@tny.tool\ndef whoami() -> str:\n    \"\"\"The signed-in Jira user.\"\"\"\n    return client().user\n```\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fjira\u002Fprojects.py\nimport tny\n\nfrom ._client import client\n\n\n@tny.tool(name=\"list\")\ndef list_projects(status: str = \"open\") -> list[str]:\n    \"\"\"List project keys.\"\"\"\n    return [p for p in client().projects if status == \"open\"]\n\n\n@tny.tool\ndef create(key: str, title: str = \"\") -> str:\n    \"\"\"Create a project.\"\"\"\n    return f\"created {key} {title}\".strip()\n```\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fjira\u002F_client.py\n\"\"\"Shared helper: the leading underscore keeps it out of the catalog.\"\"\"\n\nimport os\nfrom dataclasses import dataclass, field\n\n\n@dataclass\nclass Client:\n    user: str\n    projects: list[str] = field(default_factory=lambda: [\"TNY\", \"OPS\"])\n\n\ndef client() -> Client:\n    return Client(user=os.environ.get(\"JIRA_USER\", \"ada\"))\n```\n\nThis gives `jira.whoami`, `jira.projects.list` and `jira.projects.create`. To scaffold the same layout, run `tny tool new jira --folder`, which writes `__main__.py` and a sibling `notes.py`.\n\n## Example 5: schemas and descriptions\n\nSupported annotations:\n\n- `str`, `int`, `float`, `bool`, `None`\n- `list[...]`, `set[...]`, `tuple[...]`, `dict[str, ...]`\n- unions and `Optional`, `Literal`, `enum.Enum`\n- dataclasses, `TypedDict`, pydantic models\n- `datetime`, `date`, `uuid.UUID`, `pathlib.Path`\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fcatalog.py\nfrom dataclasses import dataclass\nfrom typing import Annotated, Any, TypedDict\n\nimport tny\n\n\n@dataclass\nclass Item:\n    sku: str\n    quantity: int = 1\n\n\nclass Filters(TypedDict, total=False):\n    color: str\n    max_price: float\n\n\n@tny.tool\ndef order(items: list[Item], note: str | None = None) -> dict[str, Any]:\n    \"\"\"Place an order. Items arrive as Item instances.\"\"\"\n    return {\n        \"skus\": [i.sku for i in items],\n        \"count\": sum(i.quantity for i in items),\n        \"note\": note,\n    }\n\n\n@tny.tool\ndef search(\n    query: Annotated[str, tny.Param(description=\"Free text\", examples=(\"red shoes\",))],\n    limit: Annotated[int, tny.Param(json_schema={\"minimum\": 1, \"maximum\": 50})] = 10,\n    filters: Filters | None = None,\n) -> list[str]:\n    \"\"\"Search the catalog.\"\"\"\n    return [f\"{query}:{n}\" for n in range(min(limit, 3))]\n\n\n@tny.tool(\n    name=\"raw\",\n    description=\"Echo the arguments back. The schema below replaces the inferred one.\",\n    input_schema={\n        \"type\": \"object\",\n        \"properties\": {\"payload\": {\"type\": \"object\"}},\n        \"required\": [\"payload\"],\n    },\n)\ndef raw_tool(**kwargs: Any) -> dict[str, Any]:\n    return kwargs  # **kwargs accepts arguments beyond the signature\n```\n\n- `tny.Param(description=, examples=, json_schema=, name=)` adds metadata to one parameter. `json_schema` merges keys such as `minimum` or `pattern` into it.\n- `@tny.tool(name=, description=, input_schema=, timeout=)` overrides the inferred values. An explicit `input_schema` is published as is, so validate inside the function.\n- When pydantic is importable it builds the schema and validates; otherwise a built-in mapper produces the same shape.\n- The tool host runs on your own `python3` (3.10 or newer; `TNY_PYTHON` picks another), so modern syntax (`X | None`, `list[int]`) is fine and your installed packages, including a virtual environment's, are importable.\n\n## Example 6: proxy an existing MCP server\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fgithub.py\n\"\"\"github.create_issue, github.search_code, ... from the GitHub MCP server.\"\"\"\n\nimport os\n\nimport tny\n\ntny.proxy(\n    [\"github-mcp-server\", \"stdio\"],  # a stdio server\n    env={\"GITHUB_TOKEN\": os.environ.get(\"GITHUB_TOKEN\", \"\")},\n    exclude=[\"delete_repository\"],  # or include=[...]\n    rename={\"search_code\": \"grep\"},  # remote name -> local name\n)\n```\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Flinear.py\n\"\"\"Mix a remote server (nested as linear.api.*) with local tools.\"\"\"\n\nimport os\n\nimport tny\n\ntny.proxy(\n    url=\"https:\u002F\u002Fmcp.linear.app\u002Fmcp\",  # Streamable HTTP\n    headers={\"Authorization\": f\"Bearer {os.environ.get('LINEAR_TOKEN', '')}\"},\n    name=\"api\",  # nest under linear.api\n    timeout=60,\n)\n\n\n@tny.tool\ndef triage_url(team: str) -> str:\n    \"\"\"Link to a team's triage view.\"\"\"\n    return f\"https:\u002F\u002Flinear.app\u002Fteam\u002F{team}\u002Ftriage\"\n```\n\n- Without `name=`, remote tools sit directly under the module, and a module may hold only one unnamed proxy. Name the others.\n- tny contacts the server when the catalog is rebuilt and on each call.\n- A server that fails shows up in `tny tool check` as a warning, and the rest of the catalog still loads.\n\n## Results and errors\n\n- A `str` return value is the result as is. Any other value is returned as JSON, and a `dict` is also MCP `structuredContent`.\n- With no return value, whatever the tool printed is the result. When a value is returned, printed text goes to stderr: on the terminal in the CLI, and in `~\u002F.tny\u002Flogs\u002Ftool-extensions.log` during agent turns.\n- `raise tny.ToolError(\"message\")` returns a clean error with that text. Any other exception returns `Type: message (file.py:line)`.\n- CLI exit codes are 0 for ok, 1 for a usage error, 2 for a tool error, and 130 when interrupted.\n\n## Verify before you finish\n\n```sh\ntny tool check                      # every module imports; lists tools, warnings, tracebacks\ntny tool list | grep jira           # the names you expect\ntny tool describe jira.projects.list\ntny --help                          # your module is listed under \"Extensions\"\ntny jira --help                     # its docstring, tools and groups\ntny jira projects --help            # one group's tools and sub-groups\ntny jira projects list --status open\necho '{\"status\":\"open\"}' | tny jira projects list -\ntny tool call jira.projects.create '{\"key\":\"TNY\"}' --json\n```\n\n- `tny tool check` exits 1 when any module fails to import, and prints the traceback. Fix that first.\n- The catalog is cached by file fingerprint, so editing a file is enough. There is nothing to reload.\n- To unit test, call the functions directly. The decorators return the original function, so `call_advisor(\"q\")` works in plain Python with tny's `python\u002F` directory or the `tny` package on `sys.path`.\n\n## Pitfalls\n\n- **Import time matters.** A module is imported whenever the catalog is rebuilt. Keep network calls and heavy setup inside the tool functions, not at module top level. `tny.proxy` is the exception: it only declares the server.\n- **Secrets.** Read them with `os.environ`. Never write tokens into the extension file; project extensions are committed.\n- **Keep the description short.** The model sees it; one plain sentence per tool works best.\n- **Trust.** Extensions run as the user with full access. Project extensions load by default. `--no-project-tools` or `TNY_TOOL_EXTENSIONS=global` limits loading to global ones, and `--no-tool-extensions` turns them all off.\n- **Permissions.** Calls use the `tool` category with the dotted name as a path, for example `{\"permission\":{\"tool\":{\"jira\u002F*\":\"allow\"}}}`. These rules only apply in `ask` or `auto` mode, since the default is yolo.\n- **Unavailable runtimes.** Extensions don't run on wasm, in `libtny` embeds or during prompt optimisation.\n- **Editor support.** For completions and type checking, install the `tny` Python package (`sdk\u002Fpython`) or add tny's `python\u002F` directory to the language server's extra paths. With Nix, `programs.tny.python.enable` and `programs.tny.neovim.enable` do this for you.\n","# Writing tny tool extensions\n\nA tool extension is a Python module of `@tny.tool` functions. Once the file is\nin an extension directory, each tool is callable everywhere with no restart\nand no registration step:\n\n- **CLI:** `tny MODULE [GROUP...] TOOL --flag value`, or `tny tool call NAME '{json}'`.\n- **Code mode:** `tools.MODULE.TOOL(arg=...)` or `tools.call(\"MODULE.TOOL\", json)`.\n- **MCP:** `tny mcp serve` serves the tools to other agents.\n\nFull reference: `docs\u002Fextensions.md` in the tny repository (ADR 0218).\n\n## Workflow\n\n1. **Pick the scope.**\n   - Project: `\u003Crepo>\u002F.tny\u002Fextensions\u002Ftools\u002F`, shared with the repo. This is the default.\n   - Global: `~\u002F.tny\u002Fextensions\u002Ftools\u002F`, for every workspace. Use it only when the user asks for a personal tool.\n2. **Pick the shape.** Use the table below.\n3. **Scaffold** with `tny tool new NAME [--folder] [--global]` or write the file directly. `NAME` must be a Python identifier that is not a tny command (`ask`, `tool`, `status`, ...).\n4. **Verify.** Run `tny tool check`, which must exit 0 and list your tools. Then call each tool once from the CLI. Then run `tny MODULE --help`.\n5. **Tell the user** the exact command to run, for example `tny jira projects list --status open`.\n\n| Need | Shape | Resulting names |\n| --- | --- | --- |\n| One action | `NAME.py` with one `@tny.tool` | `NAME` |\n| A few related actions | `NAME.py` with several tools | `NAME.a`, `NAME.b` |\n| Sub-commands in one file | `NAME.py` plus `tny.group(\"sub\")` | `NAME.sub.x` |\n| Many tools, shared helpers | `NAME\u002F__main__.py` plus submodules | `NAME.x`, `NAME.sub.y` |\n| Wrap an existing MCP server | `NAME.py` with `tny.proxy(...)` | `NAME.\u003Cremote tool>` |\n\n### Naming rules\n\n- The module (file or folder) name is the top-level name.\n- If a module has exactly one tool and no groups, that tool is called by the module name, whatever the function is called.\n- The tool name is the function name with leading and trailing `_` removed, or `name=`. Use `name=\"list\"` rather than shadowing the `list` builtin.\n- Names use letters, digits, `_` and `-`, start with a letter or `_`, and are at most 64 characters.\n- Files and folders starting with `_` or `.` are never loaded as extensions. Put shared code in `_client.py`.\n- Native tools (`read_file`, `terminal`, ...) and built-in commands always win over an extension with the same name. A project module shadows a global one with the same name, and `tny tool check` reports it.\n\n## Example 1: one tool\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fcall_advisor.py\nimport tny\n\n\n@tny.tool\ndef call_advisor(question: str, depth: int = 1) -> str:\n    \"\"\"Ask the advisor one question.\n\n    Args:\n        question: What to ask.\n        depth: How hard to think, 1 to 3.\n    \"\"\"\n    if not 1 \u003C= depth \u003C= 3:\n        raise tny.ToolError(\"depth must be 1, 2 or 3\")\n    return f\"advice on {question} (depth {depth})\"\n```\n\nCall it with `tny call_advisor \"why?\" --depth 2`, or as `tools.call_advisor(question=\"why?\")` in code mode.\n\n- The docstring's first paragraph is the description the model sees, and `Args:` describes each parameter. Google, NumPy and Sphinx styles all work.\n- A module docstring is the module's description in `tny --help` and `tny MODULE --help`. A group's description comes from `tny.group(\"name\", \"description\")` or from its submodule's docstring. Write one short first paragraph for each.\n- A parameter without a default is required, and the CLI also accepts it positionally.\n\n## Example 2: several tools in one file\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fdeploy.py\n\"\"\"Deployment helpers: deploy.status, deploy.start, deploy.wait.\"\"\"\n\nimport asyncio\nimport enum\nfrom typing import Literal\n\nimport tny\n\n\nclass Env(enum.Enum):\n    STAGING = \"staging\"\n    PROD = \"prod\"\n\n\n@tny.tool\ndef status(env: Env = Env.STAGING) -> dict[str, str]:\n    \"\"\"Current deployment status for an environment.\"\"\"\n    return {\"env\": env.value, \"state\": \"healthy\"}  # a dict is returned as JSON\n\n\n@tny.tool(timeout=900)  # seconds; the default limit is 300\ndef start(\n    ref: str, env: Env, strategy: Literal[\"rolling\", \"blue-green\"] = \"rolling\"\n) -> str:\n    \"\"\"Deploy a git ref.\n\n    Args:\n        ref: Branch, tag or commit to deploy.\n        env: Target environment.\n        strategy: How to roll it out.\n    \"\"\"\n    if env is Env.PROD and ref.startswith(\"wip\"):\n        raise tny.ToolError(\"refusing to deploy a wip ref to prod\")\n    return f\"deploying {ref} to {env.value} ({strategy})\"\n\n\n@tny.tool\nasync def wait(seconds: float = 0.1) -> str:\n    \"\"\"Wait for the rollout to settle.\"\"\"\n    await asyncio.sleep(seconds)  # async tools are run to completion\n    return \"settled\"\n```\n\n- Arguments are validated and converted before your function runs, so `env` arrives as an `Env` member. Bad input never reaches your code.\n- On the CLI, enums and `Literal` become choices: `tny deploy start v1.2 --env prod --strategy blue-green`.\n\n## Example 3: groups in one file\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fissues.py\nimport tny\n\nlabels = tny.group(\"labels\", \"Manage issue labels\")\n\n\n@tny.tool(name=\"list\")\ndef list_issues(state: str = \"open\", limit: int = 20) -> list[dict[str, object]]:\n    \"\"\"List issues.\"\"\"\n    return [{\"id\": 1, \"state\": state}][:limit]\n\n\n@labels.tool\ndef add(issue: int, label: str) -> str:\n    \"\"\"Add a label to an issue.\"\"\"\n    return f\"#{issue} +{label}\"\n\n\n@labels.tool(name=\"remove\")\ndef remove_label(issue: int, label: str) -> str:\n    \"\"\"Remove a label from an issue.\"\"\"\n    return f\"#{issue} -{label}\"\n```\n\nThis gives `issues.list`, `issues.labels.add` and `issues.labels.remove`, and the CLI runs `tny issues labels add 7 bug`. A group can nest further with `labels.group(\"colors\")`.\n\n## Example 4: a folder module\n\nUse a folder when the tools share a client, configuration or helpers. The entry point is `__main__.py`.\n\n- Submodules that `__main__.py` imports become groups named after the file.\n- Use relative imports.\n- Read secrets from the environment, never from the file.\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fjira\u002F__main__.py\n\"\"\"Jira tools.\"\"\"\n\nimport tny\n\nfrom . import projects  # noqa: F401  (registers jira.projects.*)\nfrom ._client import client\n\n\n@tny.tool\ndef whoami() -> str:\n    \"\"\"The signed-in Jira user.\"\"\"\n    return client().user\n```\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fjira\u002Fprojects.py\nimport tny\n\nfrom ._client import client\n\n\n@tny.tool(name=\"list\")\ndef list_projects(status: str = \"open\") -> list[str]:\n    \"\"\"List project keys.\"\"\"\n    return [p for p in client().projects if status == \"open\"]\n\n\n@tny.tool\ndef create(key: str, title: str = \"\") -> str:\n    \"\"\"Create a project.\"\"\"\n    return f\"created {key} {title}\".strip()\n```\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fjira\u002F_client.py\n\"\"\"Shared helper: the leading underscore keeps it out of the catalog.\"\"\"\n\nimport os\nfrom dataclasses import dataclass, field\n\n\n@dataclass\nclass Client:\n    user: str\n    projects: list[str] = field(default_factory=lambda: [\"TNY\", \"OPS\"])\n\n\ndef client() -> Client:\n    return Client(user=os.environ.get(\"JIRA_USER\", \"ada\"))\n```\n\nThis gives `jira.whoami`, `jira.projects.list` and `jira.projects.create`. To scaffold the same layout, run `tny tool new jira --folder`, which writes `__main__.py` and a sibling `notes.py`.\n\n## Example 5: schemas and descriptions\n\nSupported annotations:\n\n- `str`, `int`, `float`, `bool`, `None`\n- `list[...]`, `set[...]`, `tuple[...]`, `dict[str, ...]`\n- unions and `Optional`, `Literal`, `enum.Enum`\n- dataclasses, `TypedDict`, pydantic models\n- `datetime`, `date`, `uuid.UUID`, `pathlib.Path`\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fcatalog.py\nfrom dataclasses import dataclass\nfrom typing import Annotated, Any, TypedDict\n\nimport tny\n\n\n@dataclass\nclass Item:\n    sku: str\n    quantity: int = 1\n\n\nclass Filters(TypedDict, total=False):\n    color: str\n    max_price: float\n\n\n@tny.tool\ndef order(items: list[Item], note: str | None = None) -> dict[str, Any]:\n    \"\"\"Place an order. Items arrive as Item instances.\"\"\"\n    return {\n        \"skus\": [i.sku for i in items],\n        \"count\": sum(i.quantity for i in items),\n        \"note\": note,\n    }\n\n\n@tny.tool\ndef search(\n    query: Annotated[str, tny.Param(description=\"Free text\", examples=(\"red shoes\",))],\n    limit: Annotated[int, tny.Param(json_schema={\"minimum\": 1, \"maximum\": 50})] = 10,\n    filters: Filters | None = None,\n) -> list[str]:\n    \"\"\"Search the catalog.\"\"\"\n    return [f\"{query}:{n}\" for n in range(min(limit, 3))]\n\n\n@tny.tool(\n    name=\"raw\",\n    description=\"Echo the arguments back. The schema below replaces the inferred one.\",\n    input_schema={\n        \"type\": \"object\",\n        \"properties\": {\"payload\": {\"type\": \"object\"}},\n        \"required\": [\"payload\"],\n    },\n)\ndef raw_tool(**kwargs: Any) -> dict[str, Any]:\n    return kwargs  # **kwargs accepts arguments beyond the signature\n```\n\n- `tny.Param(description=, examples=, json_schema=, name=)` adds metadata to one parameter. `json_schema` merges keys such as `minimum` or `pattern` into it.\n- `@tny.tool(name=, description=, input_schema=, timeout=)` overrides the inferred values. An explicit `input_schema` is published as is, so validate inside the function.\n- When pydantic is importable it builds the schema and validates; otherwise a built-in mapper produces the same shape.\n- The tool host runs on your own `python3` (3.10 or newer; `TNY_PYTHON` picks another), so modern syntax (`X | None`, `list[int]`) is fine and your installed packages, including a virtual environment's, are importable.\n\n## Example 6: proxy an existing MCP server\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Fgithub.py\n\"\"\"github.create_issue, github.search_code, ... from the GitHub MCP server.\"\"\"\n\nimport os\n\nimport tny\n\ntny.proxy(\n    [\"github-mcp-server\", \"stdio\"],  # a stdio server\n    env={\"GITHUB_TOKEN\": os.environ.get(\"GITHUB_TOKEN\", \"\")},\n    exclude=[\"delete_repository\"],  # or include=[...]\n    rename={\"search_code\": \"grep\"},  # remote name -> local name\n)\n```\n\n```python\n# .tny\u002Fextensions\u002Ftools\u002Flinear.py\n\"\"\"Mix a remote server (nested as linear.api.*) with local tools.\"\"\"\n\nimport os\n\nimport tny\n\ntny.proxy(\n    url=\"https:\u002F\u002Fmcp.linear.app\u002Fmcp\",  # Streamable HTTP\n    headers={\"Authorization\": f\"Bearer {os.environ.get('LINEAR_TOKEN', '')}\"},\n    name=\"api\",  # nest under linear.api\n    timeout=60,\n)\n\n\n@tny.tool\ndef triage_url(team: str) -> str:\n    \"\"\"Link to a team's triage view.\"\"\"\n    return f\"https:\u002F\u002Flinear.app\u002Fteam\u002F{team}\u002Ftriage\"\n```\n\n- Without `name=`, remote tools sit directly under the module, and a module may hold only one unnamed proxy. Name the others.\n- tny contacts the server when the catalog is rebuilt and on each call.\n- A server that fails shows up in `tny tool check` as a warning, and the rest of the catalog still loads.\n\n## Results and errors\n\n- A `str` return value is the result as is. Any other value is returned as JSON, and a `dict` is also MCP `structuredContent`.\n- With no return value, whatever the tool printed is the result. When a value is returned, printed text goes to stderr: on the terminal in the CLI, and in `~\u002F.tny\u002Flogs\u002Ftool-extensions.log` during agent turns.\n- `raise tny.ToolError(\"message\")` returns a clean error with that text. Any other exception returns `Type: message (file.py:line)`.\n- CLI exit codes are 0 for ok, 1 for a usage error, 2 for a tool error, and 130 when interrupted.\n\n## Verify before you finish\n\n```sh\ntny tool check                      # every module imports; lists tools, warnings, tracebacks\ntny tool list | grep jira           # the names you expect\ntny tool describe jira.projects.list\ntny --help                          # your module is listed under \"Extensions\"\ntny jira --help                     # its docstring, tools and groups\ntny jira projects --help            # one group's tools and sub-groups\ntny jira projects list --status open\necho '{\"status\":\"open\"}' | tny jira projects list -\ntny tool call jira.projects.create '{\"key\":\"TNY\"}' --json\n```\n\n- `tny tool check` exits 1 when any module fails to import, and prints the traceback. Fix that first.\n- The catalog is cached by file fingerprint, so editing a file is enough. There is nothing to reload.\n- To unit test, call the functions directly. The decorators return the original function, so `call_advisor(\"q\")` works in plain Python with tny's `python\u002F` directory or the `tny` package on `sys.path`.\n\n## Pitfalls\n\n- **Import time matters.** A module is imported whenever the catalog is rebuilt. Keep network calls and heavy setup inside the tool functions, not at module top level. `tny.proxy` is the exception: it only declares the server.\n- **Secrets.** Read them with `os.environ`. Never write tokens into the extension file; project extensions are committed.\n- **Keep the description short.** The model sees it; one plain sentence per tool works best.\n- **Trust.** Extensions run as the user with full access. Project extensions load by default. `--no-project-tools` or `TNY_TOOL_EXTENSIONS=global` limits loading to global ones, and `--no-tool-extensions` turns them all off.\n- **Permissions.** Calls use the `tool` category with the dotted name as a path, for example `{\"permission\":{\"tool\":{\"jira\u002F*\":\"allow\"}}}`. These rules only apply in `ask` or `auto` mode, since the default is yolo.\n- **Unavailable runtimes.** Extensions don't run on wasm, in `libtny` embeds or during prompt optimisation.\n- **Editor support.** For completions and type checking, install the `tny` Python package (`sdk\u002Fpython`) or add tny's `python\u002F` directory to the language server's extra paths. With Nix, `programs.tny.python.enable` and `programs.tny.neovim.enable` do this for you.\n",{"name":5,"description":7},"main","f170ea8f9d04357df828f92f51cadb46dc37b054","skills\u002Ftny-tool-extensions","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny","https:\u002F\u002Fgithub.com\u002Fthehumanworks","Fluffy Pupster during the day; Agentic Doggo at night.","2026-11-14 22:10:19",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add thehumanworks\u002Ftny --skill tny-tool-extensions",{"tool":37,"command":38},"bunx","bunx skills add thehumanworks\u002Ftny --skill tny-tool-extensions",{"tool":40,"command":41},"pnpm","pnpm dlx skills add thehumanworks\u002Ftny --skill tny-tool-extensions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002Fskills\u002Ftny-tool-extensions\u002FSKILL.md",true,[],[46,53,60,67,74],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7ATG9M1W5Q5DVY6XH23YQSK","usr","Fixture whose name collides with a path component","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills-ws\u002Fskills\u002Fusr\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7ATG8CW7AYB97K6TTNE81AB","deploy","Ship the current branch to staging","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills-ws\u002Fskills\u002Fdeploy\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7ATG5D2V2817D8KN0WBJ8DX","deploy-prod","Promote staging to production","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002Ftests\u002Ffixtures\u002Fskills-ws\u002Fskills\u002Fdeploy-prod\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":19},"01M7ATFVQW36VB8KSWT0KNC0F0","tny-mutation-testing","Run and interpret tny's mutation-testing harness (tests\u002Fmutation\u002Fmutate.py) to verify that the test suite actually notices behavior changes. Use when asked to mutation-test a change, to \"test extensively\", or when adding code the unit suite might cover only nominally.","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftny-mutation-testing\u002FSKILL.md",[],[],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M7ATFR3936K9MTVYTHD47C48","tny-live-testing","Run tny against the user's real provider accounts (codex subscription, CURSOR_API_KEY) and drive the real TUI in a pty. Use for \"full integration\" or \"test against my accounts\" requests, and for verifying host process lifecycle (pre-warm, adoption, shutdown, orphans).","https:\u002F\u002Fgithub.com\u002Fthehumanworks\u002Ftny\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftny-live-testing\u002FSKILL.md",[],[]]