"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/
Python
fix: notebook_open updates name, tag list shows nested tags
hitoffda74879810
diff --git a/drawio/agent-harness/cli_anything/drawio/core/export.py b/drawio/agent-harness/cli_anything/drawio/core/export.pyindex c43392c25..1420a4c4d 100644--- a/drawio/agent-harness/cli_anything/drawio/core/export.py+++ b/drawio/agent-harness/cli_anything/drawio/core/export.py@@ -36,6 +36,7 @@ def render(session: Session, output_path: str,height: Optional[int] = None,transparent: bool = False,crop: bool = False,+ border: int = 0,overwrite: bool = False) -> dict:"""Export the current project to a file.@@ -99,6 +100,7 @@ def render(session: Session, output_path: str,height=height,transparent=transparent,crop=crop,+ border=border,overwrite=True, # We already checked above)result["action"] = "export"@@ -108,12 +110,12 @@ def render(session: Session, output_path: str,def render_or_save(session: Session, output_path: str,- fmt: str = "png", **kwargs) -> dict:+ fmt: str = "png", border: int = 0, **kwargs) -> dict:"""Export with fallback: if draw.io CLI is not available, save the .drawiofile and provide instructions for manual export."""try:- return render(session, output_path, fmt, **kwargs)+ return render(session, output_path, fmt, border=border, **kwargs)except RuntimeError as e:if "not installed" not in str(e):raisediff --git a/drawio/agent-harness/cli_anything/drawio/drawio_cli.py b/drawio/agent-harness/cli_anything/drawio/drawio_cli.pyindex 875a6fba1..65f1623d2 100644--- a/drawio/agent-harness/cli_anything/drawio/drawio_cli.py+++ b/drawio/agent-harness/cli_anything/drawio/drawio_cli.py@@ -521,10 +521,11 @@ def export():@click.option("--height", type=int, default=None, help="Output height (PNG)")@click.option("--transparent", is_flag=True, help="Transparent background (PNG)")@click.option("--crop", is_flag=True, help="Crop to content")[email protected]("--border", type=int, default=0, help="Border padding in pixels (PNG)")@click.option("--overwrite", is_flag=True, help="Overwrite existing file")@handle_errordef export_render(output_path, fmt, page_index, scale, width, height,- transparent, crop, overwrite):+ transparent, crop, border, overwrite):"""Export the diagram to a file."""session = get_session()result = export_mod.render_or_save(@@ -532,7 +533,7 @@ def export_render(output_path, fmt, page_index, scale, width, height,page_index=page_index, scale=scale,width=width, height=height,transparent=transparent, crop=crop,- overwrite=overwrite,+ border=border, overwrite=overwrite,)output(result, f"Exported to: {result.get('output', result.get('drawio_file', ''))}")diff --git a/siyuan/agent-harness/cli_anything/siyuan/siyuan_cli.py b/siyuan/agent-harness/cli_anything/siyuan/siyuan_cli.pyindex ac766721a..62c67803a 100644--- a/siyuan/agent-harness/cli_anything/siyuan/siyuan_cli.py+++ b/siyuan/agent-harness/cli_anything/siyuan/siyuan_cli.py@@ -435,9 +435,14 @@ def notebook_rename(ctx: SiYuanContext, notebook_id: str, name: str):def notebook_open(ctx: SiYuanContext, notebook_id: str):"""Open a notebook."""ctx.client.open_notebook(notebook_id)- ctx.session.update(current_notebook_id=notebook_id)+ name = notebook_id+ for nb in ctx.client.list_notebooks():+ if nb.get("id") == notebook_id:+ name = nb.get("name", notebook_id)+ break+ ctx.session.update(current_notebook_id=notebook_id, current_notebook_name=name)ctx.session.flush()- click.echo(f"Opened notebook: {notebook_id}")+ click.echo(f"Opened notebook: {name} ({notebook_id})")# ── Document commands ──────────────────────────────────────────────────@@ -707,13 +712,25 @@ def tag():"""Manage tags (标签)."""+def _print_tags(tags: list[dict], indent: int = 0) -> None:+ """Recursively print tags with hierarchical indentation."""+ pad = " " * indent+ for t in tags:+ if indent == 0:+ click.echo(f"{t.get('name', ''):<30} ({t.get('count', 0)})")+ else:+ click.echo(f"{pad}{t.get('name', ''):<{30 - 2 * indent}} ({t.get('count', 0)})")+ children = t.get("children")+ if children:+ _print_tags(children, indent + 1)++@tag.command("list")@click.pass_objdef tag_list(ctx: SiYuanContext):- """List all tags."""+ """List all tags (including nested tags)."""tags = ctx.client.get_tags()if ctx.json_output:click.echo(json.dumps(tags, ensure_ascii=False))else:- for t in tags:- click.echo(f"{t.get('name', ''):<30} ({t.get('count', 0)})")+ _print_tags(tags)