{"id":26304782,"url":"https://github.com/cablehead/xs-command-llm-anthropic","last_synced_at":"2026-02-11T17:03:19.085Z","repository":{"id":280554608,"uuid":"941741016","full_name":"cablehead/xs-command-llm-anthropic","owner":"cablehead","description":"nushell + anthropic + tool use + rich documents + cross.stream","archived":false,"fork":false,"pushed_at":"2025-03-14T18:45:23.000Z","size":51,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-29T16:52:02.719Z","etag":null,"topics":["agent","ai-assisted-development","anthropic","claude","cross-stream","event-sourcing","nushell","stream-driven-development","text-editor"],"latest_commit_sha":null,"homepage":"","language":"Nushell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cablehead.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-03-03T01:00:37.000Z","updated_at":"2025-09-18T16:46:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"b129d855-6119-4209-a8c2-fae9f5dce8d3","html_url":"https://github.com/cablehead/xs-command-llm-anthropic","commit_stats":null,"previous_names":["cablehead/xs-command-llm-anthropic"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cablehead/xs-command-llm-anthropic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fxs-command-llm-anthropic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fxs-command-llm-anthropic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fxs-command-llm-anthropic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fxs-command-llm-anthropic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cablehead","download_url":"https://codeload.github.com/cablehead/xs-command-llm-anthropic/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cablehead%2Fxs-command-llm-anthropic/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29338671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T16:14:43.024Z","status":"ssl_error","status_checked_at":"2026-02-11T16:14:15.258Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","ai-assisted-development","anthropic","claude","cross-stream","event-sourcing","nushell","stream-driven-development","text-editor"],"created_at":"2025-03-15T08:18:40.326Z","updated_at":"2026-02-11T17:03:19.058Z","avatar_url":"https://github.com/cablehead.png","language":"Nushell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xs-command-llm-anthropic\n\nA [cross.stream](https://github.com/cablehead/xs)\n[command](https://cablehead.github.io/xs/reference/commands/) and Nushell\nmodule for interacting with Anthropic's Claude AI models. This add-on leverages\ncross.stream's event-sourced architecture to provide persistent, stateful\nconversations with Claude that can be integrated into your terminal workflow.\n\n![image](https://github.com/user-attachments/assets/0e737663-f8cd-42cc-a666-a410226d9b52)\n\n\n## Requirements\n\n- [cross.stream](https://github.com/cablehead/xs)\n- [anthropic-text-editor](https://github.com/cablehead/anthropic-text-editor) (for the --with-tools option):\n  A micro-CLI to apply tool calls from Anthropic for their [text_editor_20250124](https://docs.anthropic.com/en/docs/agents-and-tools/computer-use)\n  built-in computer use tool\n\n## Onboarding\n\nQuick start with the `llm` module:\n\n1. **Load the module overlay**:\n\n```nushell\noverlay use -p ./llm\nhelp llm\n```\n\n2. **Initialize your API key and register the [cross.stream](https://github.com/cablehead/xs) [command](https://cablehead.github.io/xs/reference/commands/)**:\n\n```nushell\n$env.ANTHROPIC_API_KEY | llm init-store\n```\n\n3. **Make a test call**:\n\n```nushell\nllm call\n```\n\n```\nEnter prompt: hola\nText:\n¡Hola! ¿En qué puedo ayudarte hoy?\n```\n\nYou're ready to go!\n\n## Features\n\n- An interactive harness for processing [Claude's built-in `bash_20250124` and\n  `text_editor_20250124`\n  tools](https://docs.anthropic.com/en/docs/agents-and-tools/computer-use)\n- Rich documents, e.g. pdfs\n- Message caching: control which messages are cached using the `--cache` flag\n\n## To document\n\n- document how to run llm.call without registering it\n\n```\nlet c = source xs-command-llm.call-anthropic.nu ; do $c.process (\"hi\" | .append go)\n```\n\n- Working with the response\n\n```\n.head llm.response | .cas | from json\n```\n\nAdhoc request: translate the current clipboard to english\n\n```\n[\n    (bp)               # our current clipboard: but really you want to \"pin\" a\n                       # snippet of content\n    \"please translate to english\"  # tool selection\n]\n# we should be able to pipe a list of strings directly into llm.call\n| str join \"\\n\\n---\\n\\n\"\n| (.append\n    -c 03dg9w21nbjwon13m0iu6ek0a # the context which has llm.define and is generally considered adhoc\n    llm.call\n    )\n```\n\nUsing the cache flag with large documents or inputs:\n\n```\n# Load a large document and process it with caching enabled\nopen large_document.pdf | llm call --cache\nllm call \"Summarize the key points from the document\"\n\n# The document content is marked as ephemeral in Claude's context\n# This reduces token usage in subsequent exchanges\n# while still allowing Claude to reference the semantic content\n```\n\nView outstanding calls:\n\n```\n.cat | where topic in [\"llm.call\" \"llm.error\" \"llm.response\"] | reduce --fold {} {|frame acc|\n     if $frame.topic == \"llm.call\" {\n       return ($acc | insert $frame.id \"pending\")\n     }\n\n     $acc | upsert $frame.meta.frame_id ($frame | reject meta)\n\n   }\n```\n\n## Reference\n\n### Command Options\n\nThe `llm call` command supports the following options:\n\n- `--with-tools`: Enable Claude to use bash and text editor tools\n- `--cache`: Mark messages as ephemeral, which prevents them from being used in subsequent responses. This is useful for excluding context-heavy content (like large documents) from being re-tokenized in future exchanges while preserving the semantic understanding from those messages.\n- `--respond (-r)`: Continue from the last response\n- `--json (-j)`: Treat input as JSON formatted content\n- `--separator (-s)`: Specify a custom separator when joining lists of strings (default: \"\\n\\n---\\n\\n\")\n\n```mermaid\nsequenceDiagram\n    participant User\n    participant CLI as llm-anthropic.nu CLI\n    participant Store as [cross.stream](https://github.com/cablehead/xs) Store\n    participant Command as llm.call Command\n    participant API as Anthropic API\n\n    User-\u003e\u003eCLI: \"Hello Claude\" | .llm\n    CLI-\u003e\u003eStore: .append llm.call\n    Store--\u003e\u003eCommand: Executes Command\n\n    Command-\u003e\u003eStore: .head ANTHROPIC_API_KEY\n    Store--\u003e\u003eCommand: API Key\n\n    Command-\u003e\u003eStore: traverse-thread \u003cid\u003e\n    Store--\u003e\u003eCommand: Previous messages\n\n    Command-\u003e\u003eAPI: HTTP POST /v1/messages\n\n    API--\u003e\u003eCommand: SSE Stream (text chunks)\n\n    loop For each response chunk\n        Command-\u003e\u003eStore: .append llm.recv\n        Store--\u003e\u003eCLI: Stream response chunk\n        CLI--\u003e\u003eUser: Display streaming text\n    end\n\n    Command-\u003e\u003eStore: .append llm.response\n\n    alt Tool Use Request\n        CLI-\u003e\u003eUser: Display tool use request\n        User-\u003e\u003eCLI: Confirm execution\n        CLI-\u003e\u003eStore: .append with tool results\n        Store--\u003e\u003eCommand: Continue with results\n    end\n```\n\n## Why Use This Approach\n\nThe [cross.stream](https://github.com/cablehead/xs) framework offers significant advantages over traditional AI\nintegration approaches:\n\n### Event-Sourced Architecture\n\nThis system stores all interactions as a linked chain of events, creating\npowerful capabilities:\n\n- **Streaming Responses:** Any UI (terminal, web, desktop) can subscribe to see\n  Claude's responses as they arrive\n- **Temporal Navigation:** Browse conversation history at any point, fork\n  discussions from previous messages\n- **Resilience:** Interrupted responses retain all partial data\n- **Asynchronous Processing:** LLM calls run independently in the background,\n  managed by the [cross.stream](https://github.com/cablehead/xs) process\n\n### Command-Based Integration\n\nBy registering `llm.call` as a [cross.stream command](https://cablehead.github.io/xs/reference/commands/):\n\n- Operations run independently of client processes\n- State is managed through the event stream rather than memory\n- Multiple consumers can observe the same operation\n- Persistence is maintained across client restarts\n\n### Terminal-Native Workflow\n\n- Seamlessly integrates with developer command-line workflows\n- Leverages Nushell's powerful data manipulation capabilities\n- Creates composable pipelines between AI outputs and other tools\n- Provides a foundation for custom tooling built around LLM interactions\n\nThis approach creates a clean separation between API mechanisms and clients,\nmaking it easier to build specialized interfaces while maintaining a centralized\nconversation store.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablehead%2Fxs-command-llm-anthropic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcablehead%2Fxs-command-llm-anthropic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcablehead%2Fxs-command-llm-anthropic/lists"}