ó
    |¤jB®  ã                  óÊ  • % S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	J
r
Jr  \" 5       rS0S jrSSS	S
.rS\S'   S1S jrS2S jrS3S jrS3S jrS2S jrSrSrSrSrSr\\\\S.rSSKrSSKrS4S5S jjrS6S7S jjrS8S9S jjrS2S jr S:S jr!S;S jr"S2S jr#S:S  jr$S<S! jr%S:S" jr&S:S# jr'S;S$ jr(S:S% jr)S:S& jr*S;S' jr+S:S( jr,S;S) jr-S2S* jr.S=S+ jr/S>S, jr0S2S- jr1S2S. jr2S?S/ jr3g)@aÒ  Developer / extension commands.

`/dev` provides two kinds of capabilities:

1. **Runtime operations** (take effect immediately and persist to the
   workspace config)
   - `model list`              list selectable models for all providers
   - `model add <p> <m>`       register a new model for a provider
     (persisted to the workspace's custom_models)
   - `model remove  <p> <m>`   remove a custom model

2. **Extension guides** (print Markdown steps showing which files to
   edit and what code to add)
   - `provider`                add an LLM Provider
   - `platform`                add a cloud Platform capability
   - `tool`                    add a local tool
   - `skill`                   add a preset Skill
é    )Úannotations)ÚConsole)ÚMarkdown)ÚPROVIDER_MODELSÚConfigÚnormalize_model_nameÚregister_custom_modelc            
     óÄ   • / SQn [         R                  " 5        H3  u  pU R                  SU SSR                  S U 5       5       S35        M5     SR                  U 5      $ )z4Render PROVIDER_MODELS as a markdown table snapshot.)z## Available ModelsÚ z| Provider | Model |z	|---|---|z| `z` | ú, c              3  ó.   #   • U  H  nS U S 3v •  M     g7f)Ú`N© )Ú.0Úms     Ú C:\Users\johnn\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\dashscope/acli/dev.pyÚ	<genexpr>Ú!_format_models.<locals>.<genexpr>.   s   é € Ð.HÂ¸A°°1°#°Q­xÂùó   ‚z |Ú
)r   ÚitemsÚappendÚjoin)ÚlinesÚprovÚmodelss      r   Ú_format_modelsr   *   sV   € âL€EÜ'×-Ò-Ö/‰ˆØ�‰�s˜4˜&  T§Y¡YÑ.HÁÓ.HÓ%HÐ$IÈÐLÖMñ 0à�9‰9�UÓÐó    ÚtongyiÚ	anthropicÚopenai)ÚqwenÚclaudeÚgptzdict[str, str]Ú_MODEL_PROVIDER_HINTSc                ó¤   • U R                  5       n[        [        R                  5       S S9 H  u  p#UR	                  U5      (       d  M  Us  $    g)ziInfer a built-in provider from a model name prefix.

Returns None if the prefix is unknown or ambiguous.
c                ó    • [        U S   5      * $ )Nr   )Úlen©Úxs    r   Ú<lambda>Ú,_infer_provider_from_model.<locals>.<lambda>D   s   € ”s˜1˜Q™4“y‘jr   ©ÚkeyN)ÚlowerÚsortedr%   r   Ú
startswith)ÚmodelÚmodel_lowerÚprefixÚproviders       r   Ú_infer_provider_from_modelr6   <   sM   € ð
 —+‘+“-€KÜ"Ü×#Ñ#Ó%Ù ôÑˆð ×!Ñ! &×)Ó)ØŠOñð r   c                ó6  • [        U S/ 5      =(       d    /  H  nSU;  a  M  UR                  SS5      u  p#UR                  5       UR                  5       p2U(       a  U(       a
  U[        ;  a  MX  U[        U   ;  d  Mg  [        U   R	                  U5        M�     g)z–Merge config.custom_models into the in-process PROVIDER_MODELS dict.

Format of each entry: `provider:model`. Unknown providers are skipped
silently.
Úcustom_modelsÚ:é   N)ÚgetattrÚsplitÚstripr   r   )ÚconfigÚentryr   r2   s       r   Ú_apply_custom_modelsr@   K   s~   € ô ˜ °"Ó5×;¸Ò;ˆØ�eÓÙØ—k‘k # qÓ)‰ˆØ—j‘j“l E§K¡K£MˆeÞž5 D´Ó$?ÙØœ¨Ñ-Õ-Ü˜DÑ!×(Ñ(¨Ö/ò <r   c                óD  • U[         ;  aU  [        R                  SU S35        [        R                  SSR                  [         R                  " 5       5       S35        g [        U5      nX2R                  5       :w  a  [        R                  SU S35        U[         U    Vs1 s H  oDR                  5       iM     sn;   a  [        R                  SU S	U S
35        g [        XU5        [        R                  SU S	U S35        [        R                  S5        g s  snf )Nz[red]Unknown provider: ú[/red]z[dim]Available: r   ú[/dim]z[dim]Model name normalized to z) (API model IDs are case-sensitive)[/dim]z[dim]Ú/z already exists[/dim]u   [green]âœ“ Registered ú[/green]z"[dim]Switch to it: /provider[/dim])	r   ÚconsoleÚprintr   Úkeysr   r=   r/   r	   )r>   r5   r2   Ú
normalizedr   s        r   Ú
_model_addrJ   \   sÿ   € Ø”Ó&Ü�‰Ð/°¨z¸Ð@ÔAÜ�‰Ø˜tŸy™y¬×)=Ò)=Ó)?Ó@ÐAÀÐHô	
ð 	Ü% eÓ,€JØ—[‘[“]Ó"Ü�‰Ø,¨Z¨Lð 97ð 8ô	
ð ¬¸Ò)BÓCÒ)B A—g‘g–iÑ)BÑCÓCÜ�‰˜˜h˜Z q¨¨Ð4IÐJÔKØÜ˜&¨JÔ7Ü‡M�MÐ*¨8¨*°A°j°\ÀÐJÔKÜ‡M�MÐ6Õ7ùò Ds   Â#Dc                óx  • [        U5      nU SU 3nX0R                  =(       d    / ;  a  [        R                  SU S35        g U R                  R	                  U5        U[
        ;   a%  U[
        U   ;   a  [
        U   R	                  U5        U R                  5         [        R                  SU SU S35        g )Nr9   z[yellow]z= is not a custom model (built-ins cannot be removed)[/yellow]u   [yellow]âœ— Removed rD   ú	[/yellow])r   r8   rF   rG   Úremover   Úsave_workspace)r>   r5   r2   r?   s       r   Ú_model_removerO   q   s´   € ô ! Ó'€EØˆj˜˜%˜Ð!€EØ×)Ñ)×/¨RÓ0Ü�‰Ø�u�gð 5ð 6ô	
ð 	Ø
×Ñ×Ñ Ô&Ø”?Ó" u´ÀÑ0IÓ'IÜ˜Ñ!×(Ñ(¨Ô/Ø
×ÑÔÜ‡M�MÐ(¨¨
°!°E°7¸)ÐDÕEr   c                ó   • [         R                  [        [        5       5      5        U R                  (       aG  [         R                  5         [         R                  SSR                  U R                  5       S35        g g )Nz[dim]Workspace custom: r   rC   )rF   rG   r   r   r8   r   )r>   s    r   Ú_model_listrQ   ƒ   sU   € Ü‡M�M”(œ>Ó+Ó,Ô-Ø××Ü�‰ŒÜ�‰Ø% d§i¡i°×0DÑ0DÓ&EÐ%FÀfÐMõ	
ð r   uX	  ## Add an LLM Provider

> Wire a new LLM into acli's chat / stream / tool-call loop.
> In most scenarios **no code is needed** â€” just fill in a TOML block.

acli ships 3 protocol implementations and 3 built-in providers
(tongyi / anthropic / openai), which need no TOML at all. Every other
provider is configured via `custom-extensions.toml`:

| Protocol    | Implementation      | Use case                        |
|-------------|---------------------|---------------------------------|
| `openai`    | `OpenAIProvider`    | OpenAI-compatible endpoints     |
|             |                     | (any vendor, or local Ollamaâ€¦)  |
| `anthropic` | `AnthropicProvider` | Anthropic Messages API (Claude  |
|             |                     | / proxied endpoints)            |
| `dashscope` | `TongyiProvider`    | DashScope OpenAI-compat         |
|             |                     | endpoint (Qwen)                 |

**Steps** (Layer-1, recommended)

1. Run `/dev provider add` and fill in name / base_url / api_key /
   model / protocol interactively
2. Or manually add a block to `~/.acli/custom-extensions.toml`
   (global) or `./.acli/custom-extensions.toml` (workspace):

```toml
# Any OpenAI-compatible endpoint
[[providers]]
name = "my-llm"
base_url = "https://llm.example.com/v1"
api_key_env = "MY_LLM_API_KEY"
default_model = "my-model"
models = ["my-model", "my-model-lite"]
protocol = "openai"

# Access Qwen via an Anthropic-protocol proxy
[[providers]]
name = "bailian-anthropic"
base_url = "https://example.com/apps/anthropic"
api_key_env = "DASHSCOPE_API_KEY"
default_model = "qwen3.7-max"
protocol = "anthropic"

# Local Ollama, no auth
[[providers]]
name = "ollama"
base_url = "http://localhost:11434/v1"
default_model = "llama3"
protocol = "openai"
auth = false
```

**Steps** (Layer-2, only when the protocol is not in the table above)

Only needed when the new LLM speaks a non-standard protocol (not
OpenAI/Anthropic/DashScope compatible): implement the full
`LLMProvider` protocol in `src/acli/providers/<name>.py` (`chat` /
`stream_chat` + tool-call passthrough, see `providers/base.py`), then
add an `if proto == "<name>"` branch to `_create_provider` in
`providers/__init__.py`.

**Verify**

```
acli> /provider   # interactively switch Provider / write API Key
                  # (auth=false providers don't need one)
acli> hello       # trigger a chat
```
uð  ## Add a Platform Capability

> Platform = cloud SDK wrapper layer. One Platform can expose multiple
> capabilities (e.g. bailian â†’ memory + mcp).

**Steps**

1. Create a package under `src/acli/platforms/<vendor>/` with a client
   class implementing one of the Protocols in `platforms/base.py`
   (`MemoryProvider` / `KBProvider` / `SearchProvider` /
   `ContextProvider` / `DataProvider` / `PromptProvider`)
   - For a brand-new capability category, first add a new Protocol +
     dataclass to `platforms/base.py`
2. Add a `get_<cap>_provider(config)` factory in
   `src/acli/platforms/__init__.py`; return `None` when credentials
   are missing
3. Add a line to `CAPABILITY_CATALOG` in `src/acli/cli.py`:
   ```python
   {"key": "<vendor>.<cap>", "name": "...", "platform": "<vendor>",
   "cap": "<cap>", "requires": ["..."]}
   ```
4. Add a branch in `register_platform_tools()` in
   `src/acli/tools/platform.py` that wraps the client into tools and
   registers them with `registry` when the capability is enabled
5. If you need a `/<cap>` subcommand, add `_handle_<cap>_command` in
   `cli.py` and mount it in the `_handle_slash_command` + `_run_loop`
   routing (remember the `_require_capability` gate)
6. To be synced by `/update`, register a `_sync_<vendor>` in `cli.py`
   `_get_update_targets()`

**Verify**

```
acli> /capability enable <vendor>.<cap>
acli> /update <vendor>
acli> /<cap> list                # via its own subcommand
acli> look up ... for me         # LLM picks the new tool itself
```
up  ## Add a Local Tool

> Local tool = a capability the LLM can call directly in the agent
> loop, with no cloud dependency.

**Steps**

1. Write a plain `async`/sync function in `src/acli/tools/<name>.py`
   with the `@tool(...)` decorator:
   ```python
   from dashscope.acli.tools.registry import PermissionLevel, tool

   @tool(
       name="my_tool",
       description="one line telling the LLM what it does and when",
       permission=PermissionLevel.AUTO,  # AUTO / CONFIRM / DANGEROUS
   )
   def my_tool(path: str, limit: int = 10) -> str:
       ...
   ```
   - The parameter schema is auto-derived from type annotations by
     `_build_parameters_schema` (`str/int/float/bool/list/dict` +
     `Optional`)
   - Return a string as the tool result fed back to the LLM
2. Add `import acli.tools.<name>` at the top of `src/acli/cli.py` to
   trigger registration (see filesystem/shell for the pattern)
3. Write a good description â€” it is the ONLY signal the LLM has for
   deciding whether to call your tool; spell out **when to call / when
   not to call / inputs & outputs**

**Permission levels**

- `AUTO`      read ops / idempotent queries, run directly
- `CONFIRM`   reversible writes (write file, upload), confirm each time
- `DANGEROUS` irreversible (delete, `rm -rf`), double warning

**Verify**

```
acli> use my_tool to process X     # does the LLM pick it on its own?
```
a  ## Add a Skill

> Skill = preset Prompt template. `/skill <name> <args...>` replaces
> hand-typing a prompt; may optionally depend on an MCP service.

**Steps**

1. Register in `src/acli/skills/<name>.py`:
   ```python
   from dashscope.acli.skills.base import Skill, register

   register(Skill(
       name="my-skill",
       description="one line on what this Skill does",
       mcp_service="",  # MCP service name if required; auto-connects
       prompt_template="please... {arg1} ... {arg2}",  # placeholders
       arguments=["arg1", "arg2"],  # last greedily eats the rest
   ))
   ```
2. Append your module name to the `from acli.skills import ...` line
   in `src/acli/skills/__init__.py` to trigger the registration side
   effect
3. Call it: `/skill my-skill val1 val2`; with no args it prints usage

**Depending on an MCP service**

- With a name like `mcp_service="time"` filled in, `/skill` tries to
  auto-connect first; to make it visible under `/mcp services`, add a
  description to `KNOWN_MCP_SERVICES` in `skills/base.py`
u‹	  ## /dev â€” developer / extension guide

**Runtime (takes effect immediately)**
- `dev model list`                        list models per provider
- `dev model add <p> <m>`                 register a new model for a
  provider (persisted to workspace)
- `dev model remove  <p> <m>`             remove a custom model

**Layer-1 extensions: config as program** (written to
`custom-extensions.toml`, no code changes needed)
- `dev provider add`                      interactively register an
  extension LLM Provider (OpenAI compatible)
- `dev provider list` / `remove <name>`   view / delete
- `dev capability add`                    write a capability scaffold
  template for editing
- `dev capability list` / `remove <key>`  view / delete
- `dev skill add`                         interactively add a custom
  Skill (Prompt template)
- `dev skill list` / `remove <name>`      view / delete
- `dev tool add`                          interactively add a Shell
  tool (wrap a command as an LLM tool)
- `dev tool list` / `remove <name>`       view / delete

**Debug / test**
- `dev debug tools`                       list all registered tools
  (name, permission, description)
- `dev debug schema <name>`               show a tool's parameter
  JSON Schema
- `dev debug call <name> {"arg":"val"}`   invoke a tool manually (no
  LLM)
- `dev debug prompt`                      show the current full system
  prompt
- `dev test provider <name>`              test provider connectivity
  (sends hello)
- `dev reload`                            hot-reload
  custom-extensions.toml (no restart)
- `dev log`                               show tool registration
  stats

**Extension guides** (print steps + files + code snippets; Layer-2,
real Python modules)
- `dev provider`                          add an LLM Provider (write
  Python)
- `dev platform`                          add a cloud Platform
  capability
- `dev tool`                              add a local tool (write
  Python)
- `dev skill`                             add a preset Skill (write
  Python)

**Plugin directory**
- `.acli/plugins/*.py` files auto-load at startup (can register
  tools/skills)

> Most new LLMs speak an OpenAI-compatible protocol â€” Layer-1
> (`dev provider add`) gets you connected in 30 seconds; custom Skills
> use `dev skill add`, Shell tools use `dev tool add`, no code needed;
> for unusual protocols or complex local tools, follow the Layer-2
> guides.
)r5   ÚplatformÚtoolÚskillNc                óØ   • U(       a  SU S3OSnU(       a+  [         R                   " SU  U S35      R                  5       nO[        SU  U S35      R                  5       nU=(       d    U$ )zzSmall input wrapper. Returns default when user just hits enter.
secret=True suppresses echo (for ENC fallback paths only).z [Ú]r   ú  ú: )Úgetpassr=   Úinput)ÚlabelÚdefaultÚsecretÚhintÚvals        r   Ú_promptr`   œ  sf   € ö &ˆR�ˆy˜‰?¨2€DÞÜ�oŠo  5 '¨$¨¨rÐ2Ó3×9Ñ9Ó;‰ä�b˜˜ ˜v RÐ(Ó)×/Ñ/Ó1ˆØ�>�'Ðr   c                óô   • SSK JnJn  [        R	                  5         [        R	                  SU S35        [        R	                  SU 35        [        S5      R                  5       =(       d    SnUS:X  a  U$ U$ )	z?Ask the user whether to write to global or workspace toml file.r   )ÚGLOBAL_EXTENSIONS_FILEÚWORKSPACE_EXTENSIONS_FILEz  [1] Global: z'  [dim](shared across workspaces)[/dim]z  [2] Current workspace: z  Write to [1]: Ú1Ú2)Údashscope.acli.extensionsrb   rc   rF   rG   rZ   r=   )Údefault_globalrb   rc   Úraws       r   Ú_choose_targetri   §  su   € ÷ô
 ‡M�M„OÜ‡M�MØ
Ð/Ð0ð 10ð 	1ôô ‡M�MÐ-Ð.GÐ-HÐIÔJÜ
Ð"Ó
#×
)Ñ
)Ó
+×
2¨s€CØ(+¨s«
Ð$ÐNÐ8NÐNr   c                óh   • SSK Jn  U" [        5      nSSKJn  U" U5        U b  SSKJn  U" U 5        gg)a‹  Re-apply extensions after a /dev write so the change is visible
without restart. Mutates PROVIDER_MODELS in place, refreshes the
extensions.current() singleton, AND folds new/removed extension caps
into cli.CAPABILITY_CATALOG so /capability enable can find them
without a restart. When config is given, enabled extension caps are
re-registered so their HTTP-tool closures rebind to the new toml.r   )Úapply_extensions)Úsync_extensions_into_catalogN)Ú"refresh_extension_capability_tools)rf   rk   r   Údashscope.acli.clirl   Údashscope.acli.tools.platformrm   )r>   rk   Úextrl   rm   s        r   Ú_hot_reloadrq   ¸  s6   € õ ;á
œ?Ó
+€Cå?á  Ô%ØÑõ	
ñ 	+¨6Õ2ð r   c                ó|  • SSK JnJnJnJn  [
        R                  S5        [        S5      nU(       d  [
        R                  S5        gU" 5       R                   Vs/ s H  ofR                  U:X  d  M  UPM     nnU(       d
  U[        ;   a  [
        R                  SU S35        g[        S	5      nU(       d  [
        R                  S
5        g[        S5      n	[        S5      n
U
R                  S5       Vs/ s H)  o»R                  5       (       d  M  UR                  5       PM+     nn[        S5      R                  5       =(       d    SnUR                  5       nUS;  a  [
        R                  S5        g[        S5      R                  5       R                  5       =(       d    SnUS:g  n[
        R                  5         SnSnU(       aü  [
        R                  S5        [
        R                  S5        [
        R                  S5        [        S5      R                  5       =(       d    SnUS:X  a0  [        SSS9nU(       d  [
        R                  S5        gU" U5      nOe[        S 5      nU(       d  [
        R                  S!5        g[        R                   R#                  U5      (       d  [
        R                  S"U S#35        [%        5       nU" UUUUU	UUUS$9nU" UU5        ['        5         [
        R                  S%U S&U S'35        [
        R                  S(U S)U	=(       d    S* S+35        gs  snf s  snf ),z>Interactive flow that ends with a [[providers]] block in toml.r   )ÚCustomProviderÚappend_providerÚencrypt_for_tomlÚload_extensionsz
[bold]Add Provider[/bold]zProvider name (e.g. dashscope)ú[dim]Cancelled[/dim]Nú[red]Name conflict: z- already exists (built-in or extension)[/red]zEAPI base URL (e.g. https://dashscope.aliyuncs.com/compatible-mode/v1)z%[red]base_url must not be empty[/red]zDefault model (e.g. qwen-max)z(Other models (comma-separated, optional)Ú,z.Protocol (openai/anthropic/dashscope) [openai]r!   )r!   r    Ú	dashscopez:[red]Protocol must be openai / anthropic / dashscope[/red]zRequires API Key? (y/n) [y]ÚyÚnr   z[bold]API Key source[/bold]:z1  [1] Env var (recommended; toml stores the name)zH  [2] Encrypted into toml (XOR + machine fingerprint, this machine only)z  Choose [1]: rd   re   z(API key (hidden input, stored encrypted)T)r]   z[red]Empty key, cancelled[/red]z"Env var name (e.g. MY_LLM_API_KEY)z)[red]Env var name must not be empty[/red]z[yellow]Note: zt is not exported, so it won't work in this session; export it and restart, or it will apply on next launch.[/yellow])ÚnameÚbase_urlÚapi_key_envÚapi_key_encÚdefault_modelr   ÚprotocolÚauthu   
[green]âœ“ Provider ú written to rE   z$[dim]Ready now: /provider switch to rD   z<model>rC   )rf   rs   rt   ru   rv   rF   rG   r`   Ú	providersr}   r   r<   r=   r/   rZ   ÚosÚenvironÚgetri   rq   )r>   rs   rt   ru   rv   r}   ÚpÚexistingr~   r�   Ú
models_rawr   r   Úprotocol_rawr‚   Úauth_choiceÚ
needs_authr   r€   Úchoicer]   Útargets                         r   Ú_provider_addr‘   Î  sß  € ÷ó ô ‡M�MÐ/Ô0ÜÐ3Ó4€DÞÜ�‰Ð,Ô-ØÙ*Ó,×6Ò6ÓIÒ6�a¿&¹&ÀD¹.—Ñ6€HÐIÞ�4œ?Ó*Ü�‰Ø" 4 &ð ),ð -ô	
ð 	Üð	Có€Hö Ü�‰Ð=Ô>ØÜÐ;Ó<€MÜÐCÓD€JØ!+×!1Ñ!1°#Ô!6ÓDÒ!6˜A¿'¹'¿)‹iˆa�g‰gŽiÑ!6€FÐDäÐ@ÓA×GÑGÓI÷ 	Øð ð ×!Ñ!Ó#€HØÐ;Ó;Ü�‰ØHô	
ð 	äÐ7Ó8×>Ñ>Ó@×FÑFÓH×OÈC€KØ Ñ#€Jô ‡M�M„OØ€KØ€KÞÜ�‰Ð4Ô5Ü�‰ÐIÔJÜ�‰ð!ô	
ô Ð'Ó(×.Ñ.Ó0×7°CˆØ�S‹=ÜØ:ØñˆFö Ü—‘Ð?Ô@ØÙ*¨6Ó2‰Kä!Ð"FÓGˆKÞÜ—‘ÐIÔJØÜ—:‘:—>‘> +×.Ñ.Ü—‘Ø$ [ Mð 2Ið Jôô Ó€FÙØØØØØ#ØØØñ		€Añ �F˜AÔÜ„MÜ‡M�MÐ*¨4¨&°¸V¸HÀHÐMÔNÜ‡M�MØ
.Øˆ&��-×, 9Ð-¨Vð	5õùò] Jùò  Es   ÁL4Á4L4Ã8L9ÄL9c                 óâ  • SSK Jn   U " 5       nUR                  (       d  [        R	                  S5        g [        R	                  S5        UR                   H–  nUR
                  (       a  SUR
                   3OUR                  (       a  SOSn[        R	                  SUR                   S	UR                   S
UR                   SUR                  5        SU SUR                   S35        M˜     g )Nr   ©ÚcurrentzC[dim]No extension providers registered; use /dev provider add[/dim]z![bold]Extension providers:[/bold]zenv=zENC(machine-local)Ú?õ     â€¢ [cyan]u   [/cyan] â†’ z [dim](default=z, protocol=z, auth=z	, source=ú)[/dim])rf   r”   r…   rF   rG   r   r€   r}   r~   r�   Úresolved_protocolÚsource)r”   rp   r‰   rƒ   s       r   Ú_provider_listrš   0  sÔ   € Ý1á
‹)€CØ�=�=Ü�‰ð*ô	
ð 	Ü‡M�MÐ5Ô6Ø�]Œ]ˆð �}�}ð �1—=‘=�/Ñ"ð �}�}ñ &àð 	ô 	�‰Ø˜1Ÿ6™6˜( ,¨q¯z©z¨lð ;ØŸ_™_Ð-ð .Ø×+Ñ+Ó-Ð.ð /Ø�6˜ 1§8¡8 *¨Gð5ö	
ò r   c                óà   • SSK JnJnJn  SnX!4 H0  nU" XP5      (       d  M  [        R                  SU  SU S35        SnM2     U(       d  [        R                  SU  S	35        g [        5         g )
Nr   )rb   rc   Úremove_providerFu   [yellow]âœ— Removed provider ú from rL   Tz#[dim]Extension provider not found: rC   )rf   rb   rc   rœ   rF   rG   rq   )r}   rb   rc   rœ   Úremovedr�   s         r   Ú_provider_removerŸ   K  st   € ÷ñ ð €GØ,ÓEˆÙ˜6×(Ó(Ü�M‰MØ/°¨v°V¸F¸8À9ÐMôð ŠGñ Fö Ü�‰Ð;¸D¸6ÀÐHÔIØÜ…Mr   c                ó  ^• SSK JnJn  [        R	                  S5        [        R	                  S5        [        S5      mT(       a  ST;  a  [        R	                  S5        g[        U4S	 jU" 5       R                   5       5      (       a  [        R	                  S
T S35        g[        S5      n[        5       nU" UTU5        [        U 5        [        R	                  SU S35        [        R	                  SU ST 35        g)u�   Scaffold a [[capabilities]] block in toml the user then edits in their
editor â€” tool definitions are too complex for a smooth one-shot prompt.r   )Úappend_capability_scaffoldrv   z.
[bold]Add Capability (HTTP tool group)[/bold]zB[dim](writes a toml template; fill in fields in your editor)[/dim]z3Capability key (vendor.feature, e.g. dashscope.web)Ú.z/[red]key must be in vendor.feature format[/red]Nc              3  ó@   >#   • U  H  oR                   T:H  v •  M     g 7f©Nr-   )r   Úcr.   s     €r   r   Ú"_capability_add.<locals>.<genexpr>o  s   øé € Ð
@Ò!?˜A�5‰5�CŽ<Ò!?ùó   ƒz[red]ú already exists[/red]z(Display name (optional, defaults to key)u    
[green]âœ“ Template written to rE   z[yellow]Next:[/yellow] open z� in your editor and fill in the [[capabilities.tools]] section with the real endpoint/params/body_template, then:
  acli> /capability enable )
rf   r¡   rv   rF   rG   r`   ÚanyÚcapabilitiesri   rq   )r>   r¡   rv   Údisplayr�   r.   s        @r   Ú_capability_addr¬   _  sà   ø€ ÷ô
 ‡M�MÐCÔDÜ‡M�MØLôô ÐGÓ
H€CÞ�#˜S“.Ü�‰ÐGÔHØÜ
Ô
@¡Ó!2×!?Ò!?Ó
@×@Ñ@Ü�‰˜˜c˜UÐ"7Ð8Ô9ØÜÐ@ÓA€GÜÓ€FÙ˜v s¨GÔ4Ü�ÔÜ‡M�MÐ5°f°X¸XÐFÔGÜ‡M�MØ
& v hð /&ð '* Uð	,õr   c                 óè  • SSK Jn   U " 5       nUR                  (       d  [        R	                  S5        g [        R	                  S5        UR                   H™  n[        R	                  SUR
                   SUR                   S[        UR                  5       S35        UR                   H@  n[        R	                  S	UR                   S
UR                   SUR                   S35        MB     M›     g )Nr   r“   zH[dim]No extension capabilities registered; use /dev capability add[/dim]z$[bold]Extension capabilities:[/bold]r–   u   [/cyan] â€” z [dim](z tools)[/dim]u         [dim]Â· u    â†’ Ú rC   )rf   r”   rª   rF   rG   r.   r«   r(   Útoolsr}   Úhttp_methodÚendpoint)r”   rp   r¥   Úts       r   Ú_capability_listr³     sÂ   € Ý1á
‹)€CØ××Ü�‰ð,ô	
ð 	Ü‡M�MÐ8Ô9Ø×ÔˆÜ�‰Ø˜1Ÿ5™5˜' ¨a¯i©i¨[ð 9Ü˜Ÿ™“\�N -ð1ô	
ð —”ˆAÜ�M‰MØ  §¡ ¨¨a¯m©m¨_¸A¸a¿j¹j¸\ÈÐPöó ò r   c                óâ   • SSK JnJnJn  SnX24 H0  nU" X`5      (       d  M  [        R                  SU  SU S35        SnM2     U(       d  [        R                  SU  S	35        g [        U5        g )
Nr   )rb   rc   Úremove_capabilityFu   [yellow]âœ— Removed capability r�   rL   Tz%[dim]Extension capability not found: rC   )rf   rb   rc   rµ   rF   rG   rq   )r.   r>   rb   rc   rµ   rž   r�   s          r   Ú_capability_remover¶   •  sw   € ÷ñ ð €GØ,ÓEˆÙ˜V×)Ó)Ü�M‰MØ1°#°°f¸V¸HÀIÐNôð ŠGñ Fö Ü�‰Ð=¸c¸UÀ&ÐIÔJØÜ�Õr   c            
     ó€  ^• SSK Jn JnJn  SSKJnJnJn  [        R                  S5        [        S5      mT(       d  [        R                  S5        g U" 5       nTU;   d$  [        U4S jUR                   5       5      (       a  [        R                  ST S	35        g [        S
5      n[        S5      nU(       d  [        R                  S5        g [        S5      n	U	(       aF  U	R                  S5       V
s/ s H)  oªR                  5       (       d  M  U
R                  5       PM+     sn
O/ n[        S5      n[        5       nU " TUUUUS9nU" XÞ5        U" U" TUUUUS95        [!        5         [        R                  ST SU S35        [        R                  ST SSR#                  S U 5       5       S35        g s  sn
f )Nr   )ÚCustomSkillÚappend_skillrv   )ÚBUILTIN_SKILLSÚSkillÚregisterz)
[bold]Add Skill (Prompt template)[/bold]zSkill name (e.g. code-review)rw   c              3  ó@   >#   • U  H  oR                   T:H  v •  M     g 7fr¤   ©r}   )r   Úsr}   s     €r   r   Ú_skill_add.<locals>.<genexpr>º  s   øé € Ð$Mº_¸§V¡V¨t¦^º_ùr§   rx   r¨   z'Description (one line on what it's for)z(Prompt template (use {arg} placeholders)z%[red]Template must not be empty[/red]z5Arguments (comma-separated, e.g. city,lang; optional)ry   zRequired MCP service (optional))r}   ÚdescriptionÚprompt_templateÚ	argumentsÚmcp_service)r}   rÁ   rÄ   rÂ   rÃ   u   
[green]âœ“ Skill r„   rE   z[dim]Ready now: /skill r®   c              3  ó.   #   • U  H  nS U S3v •  M     g7f©Ú<Ú>Nr   ©r   Úas     r   r   rÀ   á  s   é € Ð0¢i �a˜�s˜!•H¢iùr   rC   )rf   r¸   r¹   rv   Údashscope.acli.skills.baserº   r»   r¼   rF   rG   r`   r©   Úskillsr<   r=   ri   rq   r   )r¸   r¹   rv   rº   r»   r¼   rŠ   rÁ   rÂ   Úargs_rawrÊ   rÃ   rÄ   r�   r¿   r}   s                  @r   Ú
_skill_addrÎ   ¬  s�  ø€ ÷ñ ÷
 KÑJä‡M�MÐ>Ô?ÜÐ2Ó3€DÞÜ�‰Ð,Ô-ØÙÓ €HØˆ~Ó¤Ô$M¸X¿_º_Ó$M×!MÑ!MÜ�‰Ð,¨T¨FÐ2GÐHÔIØÜÐCÓD€KÜÐHÓI€OÞÜ�‰Ð=Ô>ØÜÐNÓO€Hö ð %ŸN™N¨3Ô/Ó=Ò/�q·7±7·9‹ˆ�‰ŽÑ/Ò=àð ô
 Ð;Ó<€KäÓ€FÙØØØ'ØØñ	€Añ �ÔáÙØØ#Ø#Ø+Øñ	
ôô „MÜ‡M�MÐ'¨ v¨\¸&¸ÀÐJÔKÜ‡M�MØ
! $  qØ�8‰8Ñ0¡iÓ0Ó0Ð
1°ð	9õùò7 	>s   Ã6F;ÄF;c                 ó^  • SSK Jn   U " 5       nUR                  (       d  [        R	                  S5        g [        R	                  S5        UR                   HÔ  nSR                  S UR                   5       5      nUR                  (       a  SUR                   S3OS	n[        R	                  S
UR                   SU U 35        [        R	                  SUR                   35        [        R	                  SUR                  S S  [        UR                  5      S:”  a  SOS	 S35        MÖ     g )Nr   r“   z:[dim]No custom skills registered; use /dev skill add[/dim]z[bold]Custom skills:[/bold]r®   c              3  ó.   #   • U  H  nS U S3v •  M     g7frÆ   r   rÉ   s     r   r   Ú_skill_list.<locals>.<genexpr>ð  s   é € Ð6ª+ Q˜!˜A˜3˜a�ª+ùr   z [MCP: rV   r   r–   z[/cyan] ú    z    [dim]Template: é<   z...rC   )rf   r”   rÌ   rF   rG   r   rÃ   rÄ   r}   rÁ   rÂ   r(   )r”   rp   r¿   ÚargsÚmcps        r   Ú_skill_listrÖ   å  sï   € Ý1á
‹)€CØ�:�:Ü�‰ØHô	
ð 	Ü‡M�MÐ/Ô0Ø�ZŒZˆØ�x‰xÑ6¨!¯+ª+Ó6Ó6ˆØ,-¯M¯M�˜Ÿ™� aÑ(¸rˆÜ�‰˜ Q§V¡V H¨H°T°F¸3¸%Ð@ÔAÜ�‰˜˜QŸ]™]˜OÐ,Ô-Ü�‰Ø! !×"3Ñ"3°C°RÐ"8Ð!9Ü˜A×-Ñ-Ó.°Ó3‰u¸Ð<¸FðDö	
ò r   c                óà   • SSK JnJnJn  SnX!4 H0  nU" XP5      (       d  M  [        R                  SU  SU S35        SnM2     U(       d  [        R                  SU  S	35        g [        5         g )
Nr   )rb   rc   Úremove_skillFu   [yellow]âœ— Removed skill r�   rL   Tz[dim]Custom skill not found: rC   )rf   rb   rc   rØ   rF   rG   rq   )r}   rb   rc   rØ   rž   r�   s         r   Ú_skill_removerÙ   ú  st   € ÷ñ ð €GØ,ÓEˆÙ˜×%Ó%Ü�M‰MØ,¨T¨F°&¸¸À	ÐJôð ŠGñ Fö Ü�‰Ð5°d°V¸6ÐBÔCØÜ…Mr   c            	     ó®  ^• SSK Jn JnJn  [        R                  S5        [        R                  S5        [        S5      mT(       d  [        R                  S5        g U" 5       n[        U4S jUR                   5       5      (       a  [        R                  ST S	35        g [        S
5      n[        S5      nU(       d  [        R                  S5        g SS K	nUR                  SU5      n/ nU(       a_  [        R                  SSR                  U5       S35        U H1  n	[        SU	 S35      n
UR                  U	SSU
=(       d    U	S.5        M3     [        R                  S5        [        R                  S5        [        R                  S5        [        R                  S5        [        S5      R                  5       =(       d    SnSSSS.nUR                  US5      n[!        5       nU " TUUUUS 9nU" Xï5        [#        5         [        R                  S!T S"U S#35        [        R                  S$T S%SR                  S& U 5       5       S'35        g )(Nr   )ÚCustomShellToolÚappend_shell_toolrv   z
[bold]Add Shell Tool[/bold]z:[dim](wraps a shell command as an LLM-callable tool)[/dim]zTool name (e.g. check_port)rw   c              3  ó@   >#   • U  H  oR                   T:H  v •  M     g 7fr¤   r¾   )r   r²   r}   s     €r   r   Ú_tool_add.<locals>.<genexpr>!  s   øé € Ð
8Ò#7˜a�6‰6�TŽ>Ò#7ùr§   rx   r¨   z+Description (tells the LLM when to call it)zACommand template (use {{arg}} placeholders, e.g. curl -s {{url}})z-[red]Command template must not be empty[/red]z\{\{(\w+)\}\}z[dim]Detected params: r   rC   z  Description of param z (optional)ÚstringT)r}   ÚtypeÚrequiredrÁ   z
[bold]Permission level[/bold]:u/     [1] auto      â€” run without asking the useru8     [2] confirm   â€” confirm before running (recommended)u'     [3] dangerous â€” double confirmationz  Choose [2]: re   ÚautoÚconfirmÚ	dangerous)rd   re   Ú3)r}   rÁ   Úcommand_templateÚparamsÚ
permissionu   
[green]âœ“ Shell tool r„   rE   z[dim]LLM can call directly: Ú(c              3  ó$   #   • U  H  ov •  M     g 7fr¤   r   )r   Úpns     r   r   rÞ   S  s   é € Ð5ª 2œBªùs   ‚r—   )rf   rÛ   rÜ   rv   rF   rG   r`   r©   Úshell_toolsÚreÚfindallr   r   rZ   r=   rˆ   ri   rq   )rÛ   rÜ   rv   rŠ   rÁ   ræ   rí   Úparam_namesrç   rë   ÚdescÚperm_choiceÚperm_maprè   r�   r²   r}   s                   @r   Ú	_tool_addró     s  ø€ ÷ñ ô ‡M�MÐ1Ô2Ü‡M�MØDôô Ð0Ó1€DÞÜ�‰Ð,Ô-ØÙÓ €HÜ
Ô
8 8×#7Ò#7Ó
8×8Ñ8Ü�‰Ð,¨T¨FÐ2GÐHÔIØÜÐGÓH€KÜØKóÐö Ü�‰ÐEÔFØó à—*‘*Ð-Ð/?Ó@€KØ€FÞÜ�‰Ð.¨t¯y©y¸Ó/EÐ.FÀfÐMÔNÛˆBÜÐ4°R°D¸ÐDÓEˆDØ�M‰MàØ$Ø $Ø#'§:¨2ñ	öñ ô ‡M�MÐ4Ô5Ü‡M�MÐCÔDÜ‡M�MÐLÔMÜ‡M�MÐ;Ô<ÜÐ(Ó)×/Ñ/Ó1×8°S€KØ )°+Ñ>€HØ—‘˜k¨9Ó5€JäÓ€FÙØØØ)ØØñ	€Añ �fÔ Ü„MÜ‡M�MÐ,¨T¨F°,¸v¸hÀhÐOÔPÜ‡M�MØ
&Øˆ&��$—)‘)Ñ5©Ó5Ó5Ð6°gð	?õr   c                 ó¦  • SSK Jn   U " 5       nUR                  (       d  [        R	                  S5        g [        R	                  S5        UR                   Hx  n[        R	                  SUR
                   SUR                   S35        [        R	                  SUR                   35        [        R	                  S	UR                   S
35        Mz     g )Nr   r“   z>[dim]No custom shell tools registered; use /dev tool add[/dim]z [bold]Custom shell tools:[/bold]r–   ú	[/cyan] [rV   rÒ   z    [dim]Command: rC   )	rf   r”   rì   rF   rG   r}   rè   rÁ   ræ   )r”   rp   r²   s      r   Ú
_tool_liströ   W  s›   € Ý1á
‹)€CØ�?�?Ü�‰ð&ô	
ð 	Ü‡M�MÐ4Ô5Ø�_Œ_ˆÜ�‰˜ Q§V¡V H¨I°a·l±l°^À1ÐEÔFÜ�‰˜˜QŸ]™]˜OÐ,Ô-Ü�‰Ð*¨1×+=Ñ+=Ð*>¸fÐEÖFò r   c                óà   • SSK JnJnJn  SnX!4 H0  nU" XP5      (       d  M  [        R                  SU  SU S35        SnM2     U(       d  [        R                  SU  S	35        g [        5         g )
Nr   )rb   rc   Úremove_shell_toolFu   [yellow]âœ— Removed shell tool r�   rL   Tz"[dim]Custom shell tool not found: rC   )rf   rb   rc   rø   rF   rG   rq   )r}   rb   rc   rø   rž   r�   s         r   Ú_tool_removerù   h  st   € ÷ñ ð €GØ,ÓEˆÙ˜V×*Ó*Ü�M‰MØ1°$°°v¸f¸XÀYÐOôð ŠGñ Fö Ü�‰Ð:¸4¸&ÀÐGÔHØÜ…Mr   c                 óh  • SSK Jn   U R                  5       nU(       d  [        R	                  S5        g [        R	                  S[        U5       S35        [        US S9 HN  n[        R	                  SUR                  S	 S
UR                  R                  S SUR                  S S  35        MP     g )Nr   ©Úregistryz[dim]No tools registered[/dim]z[bold]Registered tools (z	):[/bold]c                ó   • U R                   $ r¤   r¾   r)   s    r   r+   Ú_debug_tools.<locals>.<lambda>‡  s   € ¨¯ªr   r-   z  [cyan]Ú30srõ   Ú8sz]  é2   )Údashscope.acli.tools.registryrü   Ú
list_toolsrF   rG   r(   r0   r}   rè   ÚvaluerÁ   )rü   r¯   r²   s      r   Ú_debug_toolsr    s™   € Ý6à×ÑÓ!€EÞÜ�‰Ð6Ô7ØÜ‡M�MÐ,¬S°«Z¨L¸	ÐBÔCÜ�EÑ/Ô0ˆÜ�‰Ø�q—v‘v˜c�lð #Ø—‘×"Ñ" 2Ð& c¨!¯-©-¸¸Ð*<Ð)=ð?ö	
ò 1r   c                óº  • SS K nSSKJn  UR                  U 5      nU(       d  [        R                  SU  S35        g [        R                  SUR                   SUR                  R                   S35        [        R                  SUR                   35        [        R                  S	5        [        R                  UR                  UR                  S
SS95        g )Nr   rû   ú
[red]Tool ú does not exist[/red]z[bold]z	[/bold] [rV   rW   z%
[bold]Parameters JSON Schema:[/bold]Fé   )Úensure_asciiÚindent)Újsonr  rü   rˆ   rF   rG   r}   rè   r  rÁ   ÚdumpsÚ
parameters)r}   Ú_jsonrü   rS   s       r   Ú_debug_schemar  Ž  s¢   € Ûå6à�<‰<˜Ó€DÞÜ�‰˜
 4 &Ð(=Ð>Ô?ØÜ‡M�M�F˜4Ÿ9™9˜+ Y¨t¯©×/DÑ/DÐ.EÀQÐGÔHÜ‡M�M�B�t×'Ñ'Ð(Ð)Ô*Ü‡M�MÐ:Ô;Ü‡M�M�%—+‘+˜dŸo™o¸EÈ!�+ÐLÕMr   c                ó|  • SSK Jn  SSKJn  SSKJn  UnU" [        5       5      nU(       a  USU-   -  nU" U 5      nU(       a  XF-  nU R                  (       a.  US-  n[        U R                  S5       H  u  pxXG SU S	3-  nM     [        R                  S
[        U5       S35        [        R                  U5        g )Nr   )ÚSYSTEM_PROMPT)Úskills_summary_for_llm)Údisabled_capabilities_hintz

Available Skill templates:
z

## Long-term user directives
r:   z. r   z[bold]Current system prompt (z chars):[/bold]
)Údashscope.acli.agentr  Údashscope.acli.skillsr  ro   r  ÚsetÚuser_directivesÚ	enumeraterF   rG   r(   )	r>   r  r  r  ÚpromptrÌ   ÚdisabledÚiÚrs	            r   Ú_debug_promptr  �  s²   € Ý2Ý<ÝHà€FÙ#¤C£EÓ*€FÞØÐ4°vÑ=Ñ=ˆÙ)¨&Ó1€HÞØÑˆØ××ØÐ6Ñ6ˆÜ˜f×4Ñ4°aÖ8‰DˆAØ˜˜2˜a˜S �mÑ#ŠFñ 9ô ‡M�MØ
'¬¨F« }Ð4EÐFôô ‡M�M�&Õr   c              ƒ  óN  #   • SS K nSSKJn  [        U 5      S:  a  [        R                  S5        g U S   nUR                  U5      nU(       d  [        R                  SU S35        g [        U 5      S:”  a  SR                  U SS  5      OS	n UR                  U5      n[        R                  SU SU S35         SS K
nUR                  UR                  5      (       a  UR                  " S0 UD6I S h  v•N n	OUR                  " S0 UD6n	[        R                  SU	 35        g ! UR                   a#  n[        R                  S
U S35         S nAg S nAff = f Nf! [         a9  n[        R                  S[        U5      R                   SU S35         S nAg S nAff = f7f)Nr   rû   é   z<[dim]Usage: /dev debug call <tool_name> {"arg": "val"}[/dim]é   r  r  r®   z{}z [red]Failed to parse args JSON: rB   z[dim]Calling ré   z
)...[/dim]z[green]Result:[/green]
z[red]Call failed: rX   r   )r  r  rü   r(   rF   rG   rˆ   r   ÚloadsÚJSONDecodeErrorÚasyncioÚiscoroutinefunctionÚfuncÚ	Exceptionrà   Ú__name__)
Ú	cmd_partsr  rü   r}   rS   Úargs_strÚkwargsÚer$  Úresults
             r   Ú_debug_callr.  ´  sy  é € Ûå6ä
ˆ9ƒ~˜ÓÜ�‰ØJô	
ð 	Ø�Q‰<€DØ�<‰<˜Ó€DÞÜ�‰˜
 4 &Ð(=Ð>Ô?ØÜ*-¨i«.¸1Ó*<ˆs�x‰x˜	 ! "˜Ô&À$€HðØ—‘˜XÓ&ˆô ‡M�M�M $  q¨¨°
Ð;Ô<ð	JÛà×&Ñ& t§y¡y×1Ñ1ØŸ9š9Ñ. vÑ.×.‰Fà—Y’YÑ( Ñ(ˆFÜ�‰Ð0°°Ð9Õ:øð × Ñ ó Ü�‰Ð8¸¸¸6ÐBÔCÜûðúñ /øô ó JÜ�‰Ð*¬4°«7×+;Ñ+;Ð*<¸B¸q¸cÀÐH×IÑIûðJüsl   ‚BF%ÂD' Â F%Â=9E Ã6EÃ7/E Ä&F%Ä'EÄ7EÅF%ÅEÅF%ÅE Å
F"Å)/FÆF%ÆF"Æ"F%c           
   ƒ  ó4  #   • SS K nSSKJn  SSKJnJn  [        R                  SU  S35         U" U 5      nUbI  [        R                  " U S/5      S   =(       d&    UR                  =(       d    UR                  5       S   nO[        R                  " U S/5      S   nUR                  U5      nXl        Xxl        SUl        SUl        U" U5      n	U	(       a  U	S   OS n
U
(       a  U
R                   OSnU
(       a  U
R                  OUnU(       d  [        R                  SU  S35        g U(       dR  Ub5  UR"                  =(       d    S	n[        R                  SU  S
U  SU S35        g [        R                  SU  S35        g U" U
5      nSSS.SSS./nUR%                  U/ S9I S h  v•N n[        R                  SU  S35        [        R                  SUR&                  S S  35        UR(                  (       aP  [        R                  SUR(                  R                  SS5       SUR(                  R                  SS5       35        g g  N¤! [*         a<  n[        R                  SU  S[-        U5      R.                   SU S35         S nAg S nAff = f7f) Nr   )Úfind_provider)Ú_create_providerÚbuild_profiles_from_configz[dim]Testing provider z	...[/dim]r   u	   [red]âœ— z has no model configured[/red]z(none)z1 has no API Key configured[/red]
  [dim]Checked: z)_api_key in ~/.acli/config.toml, env var z/, encrypted key in custom-extensions.toml[/dim]z  has no API Key configured[/red]ÚsystemzReply with OK)ÚroleÚcontentÚuserÚhello)r¯   u   [green]âœ“ z is reachable[/green]z  Response: éd   z  Token: input=Úinput_tokensr•   z	, output=Úoutput_tokensz connection failed: rX   rB   )Úcopyrf   r0  Údashscope.acli.providersr1  r2  rF   rG   r   rˆ   r�   Úresolved_modelsr5   r2   r~   r‚   Úapi_keyr   Úchatr5  Úusager'  rà   r(  )r}   r>   Ú_copyr0  r1  r2  rp   r2   ÚprobeÚprofilesÚprofiler>  Úenv_hintr5   ÚmessagesÚrespr,  s                    r   Ú_test_providerrH  Ö  s‚  é € Ûå7÷ô
 ‡M�MÐ*¨4¨&°	Ð:Ô;ð;
Ù˜DÓ!ˆØ‰?Ü#×'Ò'¨¨r¨dÓ3°AÑ6÷ Ø×!Ñ!×= S×%8Ñ%8Ó%:¸1Ñ%=ñ ô $×'Ò'¨¨r¨dÓ3°AÑ6ˆEð —
‘
˜6Ó"ˆØŒØŒØˆŒØˆŒÙ-¨eÓ4ˆÞ!)�(˜1’+¨tˆÞ%,�'—/’/°"ˆÞ!(�—’¨eˆæÜ�M‰M˜I d VÐ+IÐJÔKØÞØ‰ØŸ?™?×6¨h�Ü—‘Ø ˜vð &'Ø'+ fð -4Ø4<°:ð >DðEôð ô —‘Ø ˜vÐ%EÐFôð á# GÓ,ˆà¨/Ñ:Ø¨Ñ0ð
ˆð —]‘] 8°2�]Ð6×6ˆÜ�‰˜ D 6Ð)>Ð?Ô@Ü�‰˜ T§\¡\°$°3Ð%7Ð$8Ð9Ô:Ø�:�:Ü�M‰MØ! $§*¡*§.¡.°ÀÓ"EÐ!Fð GØŸ*™*Ÿ.™.¨¸#Ó>Ð?ðAõð ñ 7øô ó 
Ü�‰Ø˜�vÐ1Ü�A‹w×ÑÐ   1 # Vð-÷	
ñ 	
ûð
üsf   ‚,J¯C:I Ä)JÄ*>I Å(JÅ)I ÆJÆ%I Æ(IÆ)B"I ÉJÉI É
JÉ2JÊJÊJÊJc                ó8  • [        U 5        [        R                  S5        SSKJn  U" 5       n[        R                  S[        UR                  5       S[        UR                  5       S[        UR                  5       S[        UR                  5       35        g)	z4Re-apply extensions from toml files without restart.u&   [green]âœ“ Extensions reloaded[/green]r   r“   z  providers: z, capabilities: z
, skills: z, shell_tools: N)
rq   rF   rG   rf   r”   r(   r…   rª   rÌ   rì   )r>   r”   rp   s      r   Ú_dev_reloadrJ    s}   € ä�ÔÜ‡M�MÐ:Ô;Ý1á
‹)€CÜ‡M�MØ
œ˜CŸM™MÓ*Ð+ð ,Ü˜S×-Ñ-Ó.Ð/ð 0Ü�s—z‘z“?Ð# ?´3°s·±Ó3GÐ2Hð	Jõr   c           	     óX  • SSK Jn  [        R                  S5        [        R                  SU R                   35        [        R                  SU R
                   35        [        R                  S5        UR                  5       n0 nU HB  nUR                  UR                  R                  / 5      R                  UR                  5        MD     [        UR                  5       5       H*  u  pV[        R                  SU S[        U5       S	35        M,     [        R                  S
5        g)z-Show recent API call log from executor stats.r   rû   z![bold]Recent API call log:[/bold]z  Provider: z	  Model: z$
[bold]Registered tool stats:[/bold]z  [z] z toolsz/
[dim]For detailed token stats use /stats[/dim]N)r  rü   rF   rG   r5   r2   r  Ú
setdefaultrè   r  r   r}   r0   r   r(   )r>   rü   r¯   Úby_permr²   ÚpermÚnamess          r   Ú_dev_logrP  ,  s×   € å6ä‡M�MÐ5Ô6Ü‡M�M�L §¡Ð 1Ð2Ô3Ü‡M�M�I˜fŸl™l˜^Ð,Ô-Ü‡M�MÐ9Ô:Ø×ÑÓ!€EØ€GÛˆØ×Ñ˜1Ÿ<™<×-Ñ-¨rÓ2×9Ñ9¸!¿&¹&ÖAñ ä˜gŸm™m›oÖ.‰ˆÜ�‰˜˜D˜6 ¤C¨£J <¨vÐ6Ö7ñ /ä‡M�MÐDÕEr   c                ó¾
  • U R                  5       R                  5       n[        U5      S::  a#  [        R	                  [        [        5      5        g US   nUS:X  Ga(  [        U5      S:”  a  US   OSnUS:X  a  [        U5        g US:X  a¼  [        U5      S:¼  a  [        XS   US   5        g [        U5      S:X  at  US   n[        U5      nUcT  [        R	                  S	U S
35        [        R	                  SSR                  [        R                  5       5       S35        g [        XU5        g [        R	                  S5         g US;   a"  [        U5      S:¼  a  [        XS   US   5        g [        R	                  S5        g US:X  aq  [        U5      S:¼  ab  US   nUS:X  a  [        U5        g US:X  a  [        5         g US;   a  [        U5      S:¼  a  [!        US   5        g [        R	                  S5        g US:X  ar  [        U5      S:¼  ac  US   nUS:X  a  [#        U5        g US:X  a  [%        5         g US;   a  [        U5      S:¼  a  ['        US   U5        g [        R	                  S5        g US:X  ap  [        U5      S:¼  aa  US   nUS:X  a  [)        5         g US:X  a  [+        5         g US;   a  [        U5      S:¼  a  [-        US   5        g [        R	                  S5        g US:X  ap  [        U5      S:¼  aa  US   nUS:X  a  [/        5         g US:X  a  [1        5         g US;   a  [        U5      S:¼  a  [3        US   5        g [        R	                  S5        g US:X  a©  [        U5      S:”  a  US   OSnUS:X  a  [5        5         g US:X  a  [        U5      S:¼  a  [7        US   5        g US:X  a0  SS Kn UR;                  5       nUR=                  [?        U5      5        g US:X  a  [E        U5        g [        R	                  S5        g US:X  ab  [        U5      S:¼  a=  US   S:X  a4  SS Kn UR;                  5       nUR=                  [G        US   U5      5        g [        R	                  S 5        g US!:X  a  [I        U5        g US":X  a  [K        U5        g U[L        ;   a&  [        R	                  [        [L        U   5      5        g [        R	                  S#U S$35        [        R	                  [        [        5      5        g ! [@         a    URC                  [?        U5      5         g f = f! [@         a!    URC                  [G        US   U5      5         g f = f)%Nr:   r2   r	  ÚlistÚaddé   r!  r   z,[red]Cannot infer provider from model name 'z>'; use the full syntax: /dev model add <provider> <name>[/red]z[dim]Recognized prefixes: r   rC   u-  [dim]Usage:
  /dev model list                       â€” list available models
  /dev model add <provider> <name>      â€” register a new model
  /dev model add <name>                 â€” shorthand; infer provider from name prefix
  /dev model remove <provider> <name>   â€” remove a custom model[/dim])rM   Úrmr5   uØ   [dim]Usage:
  /dev provider add            â€” interactively add an extension provider
  /dev provider list           â€” list extension providers
  /dev provider remove <name>  â€” delete an extension provider[/dim]Ú
capabilityuà   [dim]Usage:
  /dev capability add            â€” write a capability scaffold template
  /dev capability list           â€” list extension capabilities
  /dev capability remove <key>   â€” delete an extension capability[/dim]rT   u»   [dim]Usage:
  /dev skill add            â€” interactively add a custom Skill
  /dev skill list           â€” list custom Skills
  /dev skill remove <name>  â€” delete a custom Skill[/dim]rS   uÀ   [dim]Usage:
  /dev tool add            â€” interactively add a Shell tool
  /dev tool list           â€” list custom Shell tools
  /dev tool remove <name>  â€” delete a custom Shell tool[/dim]Údebugr¯   ÚschemaÚcallr   r  uÿ   [dim]Usage:
  /dev debug tools           â€” list all registered tools
  /dev debug schema <name>   â€” show a tool's JSON Schema
  /dev debug call <name> {}  â€” invoke a tool manually
  /dev debug prompt          â€” show the current system prompt[/dim]ÚtestuM   [dim]Usage:
  /dev test provider <name>  â€” test provider connectivity[/dim]ÚreloadÚlogz[red]Unknown /dev subcommand: rB   )'r=   r<   r(   rF   rG   r   Ú_GUIDE_INDEXrQ   rJ   r6   r   r%   rH   rO   r‘   rš   rŸ   r¬   r³   r¶   rÎ   rÖ   rÙ   ró   rö   rù   r  r  r$  Úget_running_loopÚcreate_taskr.  ÚRuntimeErrorÚrunr  rH  rJ  rP  Ú_GUIDES)	Úcmdr>   ÚpartsÚsubÚactionr2   r5   r$  Úloops	            r   Úhandle_dev_commandrh  @  su  € Ø�I‰I‹K×ÑÓ€EÜ
ˆ5ƒz�QƒÜ�‰”hœ|Ó,Ô-Øà
�‰(€Cà
ˆg„~Ü  ›Z¨!›^��q’°ˆØ�VÓÜ˜Ôð\ 	ð[ �u‹_Ü�5‹z˜Q‹Ü˜6¨¡8¨U°1©XÔ6ðV 	ôU �U“˜q“à˜a™�Ü5°eÓ<�ØÑ#Ü—M‘MðØ!˜7ð #AðBôô
 —M‘MØ4ØŸ9™9Ô%:×%?Ñ%?Ó%AÓBÐCÀ6ðKôð Ü˜6¨UÔ3ð6 	ô3 —‘ð6õ
ð2 	ð Ð'Ó'¬C°«J¸!«OÜ˜&¨¡(¨E°!©HÔ5ð 	ô �M‰Mð2ô
ð 	ð ˆjÓœS ›Z¨1›_Ø�q‘ˆØ�U‹?Ü˜&Ô!ð 	ð �vÓÜÔð 	ð Ð'Ó'¬C°«J¸!«OÜ˜U 1™XÔ&ð 	ô �M‰Mð9ôð 	à
ˆlÓœs 5›z¨Q›Ø�q‘ˆØ�U‹?Ü˜FÔ#ð 	ð �vÓÜÔð 	ð Ð'Ó'¬C°«J¸!«OÜ˜u Q™x¨Ô0ð 	ô �M‰Mð;ôð 	à
ˆgƒ~œ#˜e›*¨›/Ø�q‘ˆØ�U‹?ÜŒLð 	ð �vÓÜŒMð 	ð Ð'Ó'¬C°«J¸!«OÜ˜% ™(Ô#ð 	ô �M‰MðNôð 	à
ˆfƒ}œ˜U› q›Ø�q‘ˆØ�U‹?ÜŒKð 	ð �vÓÜŒLð 	ð Ð'Ó'¬C°«J¸!«OÜ˜˜q™Ô"ð 	ô �M‰Mð7ôð 	à
ˆgƒ~Ü  ›Z¨!›^��q’°ˆØ�WÓÜŒNð8 	ð7 �xÓ¤C¨£J°!£OÜ˜% ™(Ô#ð4 	ð3 �vÓÛð	5Ø×/Ñ/Ó1�ð × Ñ ¤¨UÓ!3Ô4ð 	ð �xÓÜ˜&Ô!ð 	ô �M‰Mð;ôð 	à
ˆfƒ}Üˆu‹:˜‹?˜u Q™x¨:Ó5Ûð	CØ×/Ñ/Ó1�ð × Ñ ¤°°a±¸&Ó!AÔBð 	ô �M‰Mð7ôð
 	à
ˆhƒÜ�FÔØà
ˆeƒ|Ü�ÔØà
Œgƒ~Ü�‰”hœw s™|Ó,Ô-Øä‡M�MÐ2°3°%°vÐ>Ô?Ü‡M�M”(œ<Ó(Õ)øôs  ó 0ð —‘œK¨Ó.Õ/ð" 	ð)0ûô8  ó >ð —‘œN¨5°©8°VÓ<Õ=ð 	ð>ús$   Î<T Ð2T1 Ô$T.Ô-T.Ô1(UÕU)ÚreturnÚstr)r2   rj  ri  z
str | None)r>   r   ri  ÚNone)r>   r   r5   rj  r2   rj  ri  rk  )r   F)r[   rj  r\   rj  r]   Úboolri  rj  )T)rg   rl  r¤   )r>   zConfig | Noneri  rk  )ri  rk  )r}   rj  ri  rk  )r.   rj  r>   r   ri  rk  )r)  z	list[str]ri  rk  )r}   rj  r>   r   ri  rk  )rc  rj  r>   r   ri  rk  )4Ú__doc__Ú
__future__r   Úrich.consoler   Úrich.markdownr   Údashscope.acli.configr   r   r   r	   rF   r   r%   Ú__annotations__r6   r@   rJ   rO   rQ   Ú_GUIDE_PROVIDERÚ_GUIDE_PLATFORMÚ_GUIDE_TOOLÚ_GUIDE_SKILLr]  rb  rY   r†   r`   ri   rq   r‘   rš   rŸ   r¬   r³   r¶   rÎ   rÖ   rÙ   ró   rö   rù   r  r  r  r.  rH  rJ  rP  rh  r   r   r   Ú<module>rw     s)  ðòõ, #å  Ý "÷ó ñ ‹)€ôð ØØñ)Ð �~ó ôô0ô"8ô*Fô$
ðE€ðP'€ðT*€ðZ€ðB<€ð@  ØØØñ	€ó Û 	ööOö"3ô,_ôD
ô6ô(ô@ô,ô.6ôr
ô*ô.CôLGô"ô.
ôNôô.JôDE
ôPôFõ(N*r   