diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json new file mode 100644 index 0000000..d537c8a --- /dev/null +++ b/.claude-plugin/marketplace.json @@ -0,0 +1,26 @@ +{ + "name": "kagi-cli", + "owner": { + "name": "Microck", + "url": "https://github.com/Microck" + }, + "metadata": { + "description": "Marketplace for the Kagi CLI plugin.", + "version": "1.0.0" + }, + "plugins": [ + { + "name": "kagi", + "source": "./", + "description": "Kagi CLI skills for research, page content, Assistant, monitoring, and account configuration.", + "version": "0.15.0", + "author": { + "name": "Microck", + "url": "https://github.com/Microck" + }, + "homepage": "https://github.com/Microck/kagi-cli#readme", + "license": "MIT", + "keywords": ["kagi", "search", "cli", "research", "assistant"] + } + ] +} diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..109e9a2 --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,14 @@ +{ + "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json", + "name": "kagi", + "version": "0.15.0", + "description": "Kagi CLI skills for research, page content, Assistant, monitoring, and account configuration.", + "author": { + "name": "Microck", + "url": "https://github.com/Microck" + }, + "homepage": "https://github.com/Microck/kagi-cli#readme", + "repository": "https://github.com/Microck/kagi-cli", + "license": "MIT", + "keywords": ["kagi", "search", "cli", "research", "assistant"] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 67458c7..513fef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ Before `1.0.0`, breaking changes may still ship in minor releases. ### Added -- `kagi skills` now includes focused guides for research, page content, Assistant conversations, monitoring and automation, and account configuration. +- Install the repository as a Claude Code plugin through its bundled marketplace manifest. +- `kagi skills` now includes a unified `kagi-usage` guide for search and page content, a `kagi-ai` guide for spending Assistant allowance, and focused guides for Assistant conversations, monitoring and automation, and account configuration. ### Fixed diff --git a/README.md b/README.md index d0ed7a1..65e316a 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ for the full command-to-token matrix, use the [`auth-matrix`](https://kagi.micr. | --- | --- | | `kagi search` | search Kagi with `json` by default, or render as `toon`, `pretty`, `compact`, `markdown`, or `csv` | | `kagi agent` | print the embedded agent skill guide for choosing commands, auth paths, and output formats | -| `kagi skills` | list and load embedded, version-matched agent skills with `skills get kagi` as the agent starting point | +| `kagi skills` | list and load embedded, version-matched agent skills with `skills get kagi-usage` as the agent starting point | | `kagi batch` | run multiple searches in parallel with JSON, TOON, compact, pretty, markdown, or csv output and shared filters | | `kagi auth` | launch the auth wizard, or inspect, validate, and save credentials | | `kagi completion` | generate or install shell completions for bash, zsh, fish, or PowerShell | diff --git a/docs/commands/skills.mdx b/docs/commands/skills.mdx index ff6fe76..4018181 100644 --- a/docs/commands/skills.mdx +++ b/docs/commands/skills.mdx @@ -10,14 +10,15 @@ Load embedded, version-matched usage guidance for agents and automation. The top-level help points agents here first: ```bash -kagi skills get kagi +kagi skills get kagi-usage ``` Skills ship with the installed CLI binary, so their command examples and credential guidance match that exact `kagi` version. -The `kagi` skill is a router. It points to focused workflow skills so agents do -not need to load the full command surface for every task. +The `kagi-usage` skill covers search and page content directly, and points to +the focused workflow skills so agents do not need to load the full command +surface for every task. ## Synopsis @@ -29,7 +30,7 @@ kagi skills path [NAME] kagi agent ``` -`kagi agent` is a convenience alias for `kagi skills get kagi`. +`kagi agent` is a convenience alias for `kagi skills get kagi-usage`. ## `kagi skills` @@ -46,33 +47,33 @@ kagi skills list Print an embedded skill guide to stdout with frontmatter stripped. ```bash -kagi skills get kagi +kagi skills get kagi-usage ``` Available skills: | Skill | Use for | | --- | --- | -| `kagi` | Route an unclear Kagi task | -| `kagi-research` | Search, Quick Answer, News, source discovery, and verification | -| `kagi-content` | Extraction, summarization, page questions, and translation | +| `kagi-usage` | Search, page content, and routing for any other Kagi task | +| `kagi-ai` | Paid AI reasoning, coding, research, file analysis, and model selection | | `kagi-assistant` | Conversations, threads, attachments, and custom assistants | | `kagi-monitoring` | Batch, watch, notifications, history, caching, and MCP | | `kagi-account-config` | Auth, profiles, lenses, bangs, redirects, and site preferences | -Load the router when the workflow is unclear, or load a focused skill directly: +Load `kagi-usage` for search and page work, or load a focused skill directly: ```bash -kagi skills get kagi -kagi skills get kagi-research -kagi skills get kagi-content +kagi skills get kagi-usage +kagi skills get kagi-ai +kagi skills get kagi-assistant +kagi skills get kagi-monitoring ``` `--full` is accepted for Harbor-style compatibility. The current embedded skills have no separate references, so `--full` prints the same body as `get`. ```bash -kagi skills get kagi --full +kagi skills get kagi-usage --full ``` ## `kagi skills path` @@ -81,8 +82,8 @@ Print the embedded skill locator. ```bash kagi skills path -kagi skills path kagi -kagi skills path kagi-research +kagi skills path kagi-usage +kagi skills path kagi-assistant ``` Because Kagi embeds skills into the Rust binary instead of installing a diff --git a/skills/kagi-account-config/SKILL.md b/skills/kagi-account-config/SKILL.md index 5f078c4..1d3a476 100644 --- a/skills/kagi-account-config/SKILL.md +++ b/skills/kagi-account-config/SKILL.md @@ -9,7 +9,7 @@ allowed-tools: Bash(kagi:*) Inspect current state before changing it. Never print, echo, or paste stored credential values into output. -## Credential Model +## Credential model | Credential | Main capabilities | | --- | --- | @@ -19,9 +19,9 @@ credential values into output. Environment variables override `.kagi.toml`. `--profile NAME` selects a named profile. Base search prefers session auth when both search credentials are -available unless `preferred_auth = "api"` is configured. +available, unless `preferred_auth = "api"` is configured. -## Inspect And Verify Auth +## Inspect and verify auth ```bash kagi auth status @@ -38,7 +38,7 @@ kagi auth kagi auth set --session-token "https://kagi.com/search?token=..." ``` -Do not pass secrets on a shared shell command line. Prefer the interactive +Never pass secrets on a shared shell command line. Prefer the interactive wizard or protected environment injection in shared environments. ## Profiles @@ -50,9 +50,9 @@ kagi --profile work auth status kagi --profile personal search "query" --format toon ``` -Verify the selected profile before any setting mutation. +Verify the selected profile before changing any setting. -## Search Settings +## Search settings Inspect before creating, updating, or deleting: @@ -73,10 +73,10 @@ kagi bang custom create \ --template "https://docs.rs/releases/search?query=%s" ``` -Use each command's `--help` for mutation-specific flags. Do not delete or -overwrite account settings without explicit user intent. +Use each command's `--help` for the flags a mutation needs. Never delete or +overwrite an account setting unless the user asked for it. -## Custom Assistants +## Custom assistants ```bash kagi assistant custom list @@ -86,12 +86,12 @@ kagi assistant custom get "Researcher" Conversation and thread use belongs in `kagi-assistant`. This skill owns the account-level configuration of custom assistants. -## Completion Criteria +## Completion criteria Configuration work is complete when: -- the active profile and credential source are known; +- you know the active profile and credential source; - the requested setting is visible through its read command; - no secret value appears in output or persisted scripts; - unrelated account settings remain unchanged; and -- destructive changes were explicitly requested. +- you made a destructive change only when the user asked for it. diff --git a/skills/kagi-ai/SKILL.md b/skills/kagi-ai/SKILL.md new file mode 100644 index 0000000..c783675 --- /dev/null +++ b/skills/kagi-ai/SKILL.md @@ -0,0 +1,126 @@ +--- +name: kagi-ai +description: "Use Kagi's paid AI allowance for reasoning, coding, research, file analysis, structured generation, or model comparison. Use when a task should spend Assistant value instead of only searching the web or transforming one known page." +allowed-tools: Bash(kagi:*) Skill(kagi:*) +--- + +# Kagi AI + +Spend the Assistant allowance on reasoning and synthesis. When the active plan +includes unlimited Summarizer or Translate usage, use those tools for direct +transformations and reserve the allowance for harder work. + +## Choose the lane + +| Need | Lane | +| --- | --- | +| Find or verify sources | Load `kagi-usage` and search | +| Summarize one URL or text | `kagi summarize --subscriber` | +| Translate supplied text | `kagi translate` | +| Get a fast cited answer | `kagi quick` | +| Reason, code, synthesize, or analyze files | `kagi assistant` | +| Run multi-step research or tool use | An account-visible Research assistant | +| Manage threads or custom assistants | Load `kagi-assistant` | + +The Assistant allowance is separate from API credit. A plan's monthly value +sets its token allowance across Assistant models. Premium models, web access, +large files, and long thread histories consume more of that allowance. + +## Start with live account state + +```bash +kagi auth status +kagi assistant models +kagi assistant custom list +``` + +Use only model slugs and assistant names returned by the account. When the +model catalog is empty, use the account default instead of guessing a slug. +Kagi Quick and Kagi Research are usable through `--assistant` only when they +appear in the assistant listing. + +## Use Assistant deliberately + +Use a closed model call for reasoning that needs no current information: + +```bash +kagi assistant \ + "find the weakest assumption in this design and propose a simpler one" \ + --no-web-access \ + --format markdown +``` + +Enable web access when the answer needs current sources: + +```bash +kagi assistant \ + "compare these database options for this workload and cite current limits" \ + --web-access \ + --format markdown +``` + +Choose a live model explicitly only when its cost, speed, or capability matters: + +```bash +kagi assistant \ + "review this migration plan for data-loss risks" \ + --model MODEL_SLUG \ + --no-web-access \ + --format markdown +``` + +For a model comparison, send the same bounded prompt to each model in a fresh +thread. Compare correctness, latency, and usefulness, not prose style alone. + +## Analyze files + +Attach only the files needed for the answer. Assistant accepts documents, +spreadsheets, images, and audio; one upload can be at most 30 MB. + +```bash +kagi assistant \ + --attach ./report.pdf \ + "extract the decision, evidence, risks, and unresolved questions" \ + --no-web-access \ + --format markdown +``` + +Uploaded content remains in the thread context. Start a new thread when the +next task should not inherit it. + +## Require structured output + +Use a built-in contract for reusable decisions, plans, and checklists: + +```bash +kagi assistant \ + "decide whether this service is ready to launch" \ + --contract decision \ + --format json +``` + +Use `--contract-file PATH` when the consumer needs a different small JSON +shape. Contract mode validates the response and makes one repair attempt. + +## Budget discipline + +1. Use subscriber Summarizer or Translate for direct transformations when the + active plan includes them. +2. Use the account default or a lower-cost model for simple work. +3. Disable web access for closed-context work. +4. Keep prompts specific and attach only relevant files. +5. Start a new thread for an unrelated task. +6. Reserve Research assistants and premium models for work that needs their + extra tools or reasoning depth. + +## Completion criteria + +AI work is complete when: + +- the selected lane matches the task; +- every explicit model or assistant came from live account discovery; +- web access and attachments are limited to what the answer needs; +- structured output passes its contract when a machine will consume it; +- the response answers the task instead of spending allowance on avoidable + transformations; and +- you changed or deleted account state only when the user asked. diff --git a/skills/kagi-assistant/SKILL.md b/skills/kagi-assistant/SKILL.md index 5bf9a05..fcd379b 100644 --- a/skills/kagi-assistant/SKILL.md +++ b/skills/kagi-assistant/SKILL.md @@ -6,12 +6,13 @@ allowed-tools: Bash(kagi:*) # Kagi Assistant -Use Assistant for conversational synthesis and continuity. Use -`kagi-research` for source discovery and `kagi-content` for one known page. +Use Assistant for conversation mechanics and continuity. Use `kagi-ai` to +choose when to spend AI allowance, and `kagi-usage` for direct search or page +work. Assistant commands require `KAGI_SESSION_TOKEN`. -## Start A Conversation +## Start a conversation ```bash kagi auth status @@ -19,11 +20,11 @@ kagi assistant "draft a migration checklist" --format markdown kagi assistant "compare these options" --format toon ``` -State the desired deliverable, constraints, and audience in the prompt. Do not -hide required output structure in follow-up shell processing when the Assistant -can produce it directly. +State the deliverable, constraints, and audience in the prompt. Never rebuild +the output structure in follow-up shell processing when the Assistant can +produce it directly. -## Continue A Thread +## Continue a thread ```bash kagi assistant --thread-id THREAD_ID "add rollback steps" @@ -35,13 +36,13 @@ kagi assistant thread export THREAD_ID --format markdown Reuse a thread only when its prior context still belongs to the task. Start a new thread when stale context could bias the answer. -Delete a thread only when the user asked for deletion: +Delete a thread only when the user asks for it: ```bash kagi assistant thread delete THREAD_ID ``` -## Attach Local Context +## Attach local context ```bash kagi assistant \ @@ -50,10 +51,10 @@ kagi assistant \ --format markdown ``` -Attach only files needed for the task. Mention the file's role in the prompt so -the Assistant knows whether it is evidence, a template, or background. +Attach only files the task needs. Name the file's role in the prompt so the +Assistant knows whether it is evidence, a template, or background. -## Stream Responses +## Stream responses Use human streaming for interactive terminal work. Use structured streaming when another program consumes events. @@ -66,9 +67,9 @@ kagi assistant \ "produce a release checklist" ``` -Do not parse human-oriented streaming output as a machine contract. +Never parse human streaming output as a machine contract. -## Custom Assistants +## Custom assistants ```bash kagi assistant custom list @@ -82,12 +83,12 @@ kagi assistant custom create \ Inspect an existing custom assistant before changing the workflow around it. Account configuration belongs in `kagi-account-config`. -## Completion Criteria +## Completion criteria Assistant work is complete when: -- the correct thread or a clean new thread was used; -- required files and constraints were supplied; -- output format matches its consumer; +- you used the correct thread or a clean new one; +- you supplied the required files and constraints; +- the output format matches its consumer; - the final response answers the current prompt, not stale thread context; and -- destructive thread actions occurred only with explicit user intent. +- you deleted a thread only when the user asked for it. diff --git a/skills/kagi-content/SKILL.md b/skills/kagi-content/SKILL.md deleted file mode 100644 index da4b3b3..0000000 --- a/skills/kagi-content/SKILL.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -name: kagi-content -description: Read, extract, summarize, question, or translate a URL or supplied text with Kagi. Use when the source is already known and the user needs its readable content, key points, an answer about the page, or a translation. -allowed-tools: Bash(kagi:*) ---- - -# Kagi Content - -Use the narrowest content command. Do not run a broad web search when the user -already supplied the source. - -## Choose The Command - -| Outcome | Command | Credential | -| --- | --- | --- | -| Full readable page markdown | `kagi extract` | `KAGI_API_KEY` | -| Summary of a URL or text | `kagi summarize` | session or legacy API token | -| Answer about one page | `kagi ask-page` | session token | -| Translation | `kagi translate` | session token | - -Run `kagi auth status` before selecting between subscriber and API -summarization. - -## Extract A Page - -Use `extract` when downstream work needs the article body rather than a -summary. - -```bash -kagi extract "https://example.com/article" -``` - -Prefer extraction over browser scraping for readable main content. Extraction -requires the current `KAGI_API_KEY`, not the legacy `KAGI_API_TOKEN`. - -## Summarize - -Prefer subscriber mode when a session token is available. - -```bash -kagi summarize --subscriber --url "https://example.com/article" -kagi summarize --subscriber --text "long text" -kagi summarize --subscriber \ - --url "https://example.com/article" \ - --summary-type keypoints -``` - -Use the public API mode only when the legacy API token is configured or its -engine controls are required. - -```bash -kagi summarize --url "https://example.com/article" -kagi summarize --text "long text" --engine cecil -``` - -Do not summarize content that must be quoted or checked precisely. Extract it -and inspect the relevant passage instead. - -## Ask One Page - -Use `ask-page` for a focused question whose evidence should come from one URL. - -```bash -kagi ask-page \ - "https://example.com/article" \ - "what evidence supports the main claim?" \ - --format markdown -``` - -If the question requires outside evidence or comparison, switch to -`kagi-research`. - -## Translate - -```bash -kagi translate \ - --text "Bonjour tout le monde" \ - --target-language EN -``` - -Preserve code, URLs, product names, and other text that should not be -translated. State the desired target language explicitly. - -## Completion Criteria - -Content work is complete when: - -- the command matches the requested transformation; -- the output stays grounded in the supplied URL or text; -- quotes remain distinguishable from summaries; -- the requested language and format are preserved; and -- any source-access failure is reported rather than filled with guesses. diff --git a/skills/kagi-monitoring/SKILL.md b/skills/kagi-monitoring/SKILL.md index 00b2fdf..08fd1e0 100644 --- a/skills/kagi-monitoring/SKILL.md +++ b/skills/kagi-monitoring/SKILL.md @@ -4,12 +4,12 @@ description: Automate repeated Kagi queries with batch search, watches, notifica allowed-tools: Bash(kagi:*) --- -# Kagi Monitoring And Automation +# Kagi Monitoring and Automation Build repeatable workflows from structured Kagi output. Keep stdout machine-readable and send progress or diagnostics to stderr. -## Choose The Workflow +## Choose the workflow | Need | Command | | --- | --- | @@ -21,7 +21,7 @@ machine-readable and send progress or diagnostics to stderr. Run `kagi auth status` before automating authenticated commands. -## Batch Search +## Batch search ```bash kagi batch "rust" "zig" "go" --format toon --limit 3 @@ -29,28 +29,28 @@ printf 'rust\nzig\ngo\n' | kagi batch --format compact ``` Use argument queries for short fixed sets and stdin for generated lists. Keep -the query list as the recoverable input so failed runs can be repeated. +the query list as the recoverable input so a failed run can be repeated. -## Watch Search Results +## Watch search results ```bash kagi watch "site:example.com release notes" --interval 300 ``` Define what counts as a meaningful change before starting a long-running -watch. Use a descriptive query and an interval that matches the source's likely -update rate. +watch. Use a descriptive query and an interval that matches how often the +source updates. ## Notifications Use `kagi notify --help` to select the configured delivery target, then connect -it to a watch or batch result. Do not put secrets in notification text or +it to a watch or batch result. Never put secrets in notification text or command history. -## History And Caching +## History and caching Use `kagi history` to inspect local command records before duplicating work. -Use `--local-cache` only for calls where stale data is acceptable. Do not cache +Use `--local-cache` only for calls where stale data is acceptable. Never cache research that must reflect a current price, release, outage, or policy. ## MCP @@ -61,24 +61,24 @@ Use the stdio server when another agent host needs Kagi tools: kagi mcp ``` -Keep MCP stdout reserved for protocol messages. Treat logs written to stdout as -a protocol-breaking bug. +Keep MCP stdout reserved for protocol messages. Treat a log written to stdout +as a protocol-breaking bug. -## Automation Rules +## Automation rules - Prefer `json`, `compact`, or `toon` over `pretty`. -- Preserve nonzero exit codes instead of converting failure into empty output. -- Keep credentials in Kagi auth storage or environment variables, not scripts. +- Preserve nonzero exit codes instead of turning failure into empty output. +- Keep credentials in Kagi auth storage or environment variables, never scripts. - Limit concurrency to what the endpoint and account can sustain. - Record enough input to reproduce a failed item. - Use a process supervisor or scheduler for long-running watches. -## Completion Criteria +## Completion criteria Automation is complete when: - inputs and outputs have stable machine-readable shapes; - failures remain observable and retryable; -- credential values do not appear in scripts or logs; +- credential values never appear in scripts or logs; - cache and polling choices match the freshness requirement; and - long-running processes have a clear owner and stop condition. diff --git a/skills/kagi-research/SKILL.md b/skills/kagi-research/SKILL.md deleted file mode 100644 index acfeac6..0000000 --- a/skills/kagi-research/SKILL.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -name: kagi-research -description: Research, compare, verify, or discover information with Kagi Search, Quick Answer, News, and Small Web. Use when the user needs source discovery, current facts, multiple perspectives, or a cited answer rather than one known page. -allowed-tools: Bash(kagi:*) ---- - -# Kagi Research - -Use Kagi to discover sources, narrow the question, and return evidence that -matches the user's requested depth. - -## Choose The Research Lane - -| Need | Command | -| --- | --- | -| Direct answer with references | `kagi quick` | -| Ranked web results | `kagi search` | -| Search and summarize top pages | `kagi search --follow N` | -| Current news stories | `kagi news` or `kagi search --news` | -| Independent personal sites | `kagi smallweb` | -| Several independent queries | `kagi batch` | - -`quick`, search filters, and the subscriber search path require session auth. -The current Search API uses `KAGI_API_KEY`. Public `news` and `smallweb` need no -credentials. - -## Workflow - -1. Define the claim or question that needs evidence. -2. Run `kagi auth status`. -3. Start with one broad search or `quick` for a bounded factual question. -4. Split the topic into distinct queries when one query cannot cover it. -5. Prefer primary sources and direct evidence. -6. Use `--follow` only when summaries of the top result pages are useful. -7. Report source disagreement instead of flattening it. - -```bash -kagi auth status -kagi search "rust async cancellation" --format toon --limit 5 -kagi quick "what is the current Kagi Search API endpoint?" --format markdown -``` - -## Search Controls - -```bash -kagi search "query" --region us --format toon --limit 10 -kagi search "query" --time month --order recency --format json -kagi search "query" --snap reddit --format toon -kagi search "query" --lens 2 --format toon -kagi search "query" --follow 3 --format markdown -``` - -Session-only controls include `--lens`, `--time`, `--order`, `--verbatim`, -personalization flags, and News vertical search. Use `--local-cache` only when -stale results are acceptable. - -## Query Design - -- Quote exact error messages or disputed phrases. -- Add official domains with `site:` when a primary source is known. -- Use native-language query terms for regional or multilingual research. -- Separate discovery, counterevidence, and recency into different queries. -- Use `--region` as a result bias, not as a language guarantee. - -```bash -kagi batch \ - "topic official documentation" \ - "topic limitations" \ - "topic independent review" \ - --format toon --limit 5 -``` - -## News And Discovery - -```bash -kagi news --category tech --limit 10 -kagi news --list-categories -kagi news --chaos -kagi search "open source ai" --news --format toon -kagi smallweb -``` - -Use `news` for the public Kagi News feed. Use `search --news` when the query must -filter the News vertical. - -## Completion Criteria - -Research is complete when: - -- the answer addresses the exact question; -- important claims trace to source URLs; -- source quality and recency match the claim; -- disagreements or uncertainty are explicit; and -- the output uses the requested format and depth. diff --git a/skills/kagi-usage/SKILL.md b/skills/kagi-usage/SKILL.md new file mode 100644 index 0000000..3fdbd8a --- /dev/null +++ b/skills/kagi-usage/SKILL.md @@ -0,0 +1,205 @@ +--- +name: kagi-usage +description: "Search the web, extract or summarize a page, translate it, or check the news with the kagi CLI instead of WebSearch or WebFetch. Load this first for any Kagi task: it covers search and page content, and routes Assistant, automation, and account work to the right skill." +allowed-tools: Bash(kagi:*) Skill(kagi:*) +--- + +# Kagi CLI + +Search the web and read pages with `kagi`. Route every other Kagi task to the +skill named below. + +## Route the task + +| User intent | Where | +| --- | --- | +| Find, compare, or verify information from the web | Search the web (below) | +| Read, summarize, question, or translate a known page | Work with one page (below) | +| Use paid AI for reasoning, coding, research, or files | `kagi-ai` | +| Continue a conversation or manage Assistant state | `kagi-assistant` | +| Run searches in bulk or monitor changes over time | `kagi-monitoring` | +| Configure credentials or account search behavior | `kagi-account-config` | + +Load the skill when it appears in the available skills listing. Otherwise run +`kagi skills get ` for the same guidance. + +```bash +kagi skills list +kagi skills get kagi-assistant +``` + +## Search the web + +Discover sources, narrow the question, and return evidence that matches the +depth the user asked for. + +| Need | Command | +| --- | --- | +| Direct answer with references | `kagi quick` | +| Ranked web results | `kagi search` | +| Search and summarize top pages | `kagi search --follow N` | +| Current news stories | `kagi news` or `kagi search --news` | +| Independent personal sites | `kagi smallweb` | +| Several independent queries | `kagi batch` | + +`quick`, session-only search controls, and the subscriber search path require +session auth. +The current Search API uses `KAGI_API_KEY`. Public `news` and `smallweb` need no +credentials. + +1. Define the claim or question that needs evidence. +2. Start with one broad search, or `quick` for a bounded factual question. +3. Split the topic into distinct queries when one query cannot cover it. +4. Prefer primary sources and direct evidence. +5. Use `--follow` only when the user needs the top result pages summarized. +6. Report source disagreement instead of flattening it. + +```bash +kagi search "rust async cancellation" --format toon --limit 5 +kagi quick "what is the current Kagi Search API endpoint?" --format markdown +``` + +### Search controls + +```bash +kagi search "query" --region us --format toon --limit 10 +kagi search "query" --time month --order recency --format json +kagi search "query" --snap reddit --format toon +kagi search "query" --lens 2 --format toon +kagi search "query" --follow 3 --format markdown +``` + +Session-only controls include `--lens`, `--time`, `--order`, `--verbatim`, +personalization flags, and News vertical search. Use `--local-cache` only when +stale results are acceptable. + +### Query design + +- Quote exact error messages or disputed phrases. +- Add official domains with `site:` when a primary source is known. +- Use native-language query terms for regional or multilingual research. +- Separate discovery, counterevidence, and recency into different queries. +- Use `--region` as a result bias, never as a language guarantee. + +```bash +kagi batch \ + "topic official documentation" \ + "topic limitations" \ + "topic independent review" \ + --format toon --limit 5 +``` + +### News and discovery + +```bash +kagi news --category tech --limit 10 +kagi news --list-categories +kagi news --chaos +kagi search "open source ai" --news --format toon +kagi smallweb +``` + +Use `news` for the public Kagi News feed. Use `search --news` when the query must +filter the News vertical. + +## Work with one page + +Work from the source the user supplied. Search the web only when the task needs +evidence that page cannot give. + +| Outcome | Command | Credential | +| --- | --- | --- | +| Full readable page markdown | `kagi extract` | `KAGI_API_KEY` | +| Summary of a URL or text | `kagi summarize` | session or legacy API token | +| Answer about one page | `kagi ask-page` | session token | +| Translation | `kagi translate` | session token | + +### Extract a page + +Use `extract` when downstream work needs the article body rather than a +summary. Prefer `extract` over browser scraping for readable main content. It +requires the current `KAGI_API_KEY`, never the legacy `KAGI_API_TOKEN`. + +```bash +kagi extract "https://example.com/article" +``` + +### Summarize + +Prefer subscriber mode when a session token is available. + +```bash +kagi summarize --subscriber --url "https://example.com/article" +kagi summarize --subscriber --text "long text" +kagi summarize --subscriber \ + --url "https://example.com/article" \ + --summary-type keypoints +``` + +Use the public API mode only when the legacy API token is configured or the +task needs its engine controls. + +```bash +kagi summarize --url "https://example.com/article" +kagi summarize --text "long text" --engine cecil +``` + +Never summarize content that must be quoted or checked precisely. Extract it +and inspect the relevant passage instead. + +### Ask one page + +Use `ask-page` for a focused question whose evidence should come from one URL. + +```bash +kagi ask-page \ + "https://example.com/article" \ + "what evidence supports the main claim?" \ + --format markdown +``` + +When the question needs outside evidence or comparison, search the web instead. + +### Translate + +```bash +kagi translate \ + --text "Bonjour tout le monde" \ + --target-language EN +``` + +Preserve code, URLs, product names, and other text that must stay untranslated. +State the target language explicitly. + +## Shared rules + +1. Run `kagi auth status` before treating a command as unavailable. +2. Choose the narrowest command that produces the requested outcome. +3. Use `--format json` for programmatic parsing. +4. Use `--format toon` for compact LLM context. +5. Use `--format markdown` for prose that a person will read. +6. Run `kagi auth check` when credentials exist but a request fails. +7. Never print credential values. + +```bash +kagi auth status +kagi auth check +``` + +## Completion criteria + +Web research is complete when: + +- the answer addresses the exact question; +- important claims trace to source URLs; +- source quality and recency match the claim; +- disagreement and uncertainty appear in the output; and +- the output uses the requested format and depth. + +Page work is complete when: + +- the command matches the requested transformation; +- the output stays grounded in the supplied URL or text; +- quotes remain distinguishable from summaries; +- the output keeps the requested language and format; and +- you report a source-access failure instead of guessing past it. diff --git a/skills/kagi/SKILL.md b/skills/kagi/SKILL.md deleted file mode 100644 index 9fc78fe..0000000 --- a/skills/kagi/SKILL.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -name: kagi -description: Route Kagi CLI work to version-matched skills for research, page content, Assistant, monitoring, or account configuration. Use when a task involves Kagi but the correct command or specialized Kagi skill is not yet clear. -allowed-tools: Bash(kagi:*) ---- - -# Kagi CLI - -Use this skill as the entry point for `kagi`. Route the task to the narrowest -workflow skill before running substantive commands. - -## Route The Task - -| User intent | Load | -| --- | --- | -| Find, compare, or verify information from the web | `kagi skills get kagi-research` | -| Read, summarize, question, or translate a page | `kagi skills get kagi-content` | -| Start or continue an Assistant conversation | `kagi skills get kagi-assistant` | -| Run searches in bulk or monitor changes over time | `kagi skills get kagi-monitoring` | -| Configure credentials or account search behavior | `kagi skills get kagi-account-config` | - -```bash -kagi skills list -kagi skills get kagi-research -``` - -If one task crosses boundaries, load only the skills needed for the next action. -For example, research first with `kagi-research`, then load `kagi-content` only -when a result page needs closer reading. - -## Shared Rules - -1. Run `kagi auth status` before deciding that a command is available. -2. Choose the narrowest command for the requested outcome. -3. Use `--format json` for programmatic parsing. -4. Use `--format toon` for compact LLM context. -5. Use `--format markdown` for prose that a person will read. -6. Run `kagi auth check` when credentials exist but a request fails. -7. Never print credential values. - -```bash -kagi auth status -kagi auth check -``` - -## Completion Criteria - -Routing is complete when the narrowest workflow skill has been loaded and its -completion criteria have been satisfied. Do not keep this router in context -when a specialized skill contains all remaining guidance. diff --git a/src/agent.rs b/src/agent.rs index d682f4f..e281e13 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -8,11 +8,10 @@ pub struct EmbeddedSkill { } /// Core skill name used by `kagi skills`. -pub const KAGI_SKILL: &str = "kagi"; +pub const KAGI_SKILL: &str = "kagi-usage"; -const KAGI_SKILL_SOURCE: &str = include_str!("../skills/kagi/SKILL.md"); -const KAGI_RESEARCH_SKILL_SOURCE: &str = include_str!("../skills/kagi-research/SKILL.md"); -const KAGI_CONTENT_SKILL_SOURCE: &str = include_str!("../skills/kagi-content/SKILL.md"); +const KAGI_SKILL_SOURCE: &str = include_str!("../skills/kagi-usage/SKILL.md"); +const KAGI_AI_SKILL_SOURCE: &str = include_str!("../skills/kagi-ai/SKILL.md"); const KAGI_ASSISTANT_SKILL_SOURCE: &str = include_str!("../skills/kagi-assistant/SKILL.md"); const KAGI_MONITORING_SKILL_SOURCE: &str = include_str!("../skills/kagi-monitoring/SKILL.md"); const KAGI_ACCOUNT_CONFIG_SKILL_SOURCE: &str = @@ -21,18 +20,13 @@ const KAGI_ACCOUNT_CONFIG_SKILL_SOURCE: &str = const SKILLS: &[EmbeddedSkill] = &[ EmbeddedSkill { name: KAGI_SKILL, - description: "Route Kagi CLI tasks to the right embedded workflow skill", + description: "Search the web, read pages, and route other Kagi tasks to their skill", source: KAGI_SKILL_SOURCE, }, EmbeddedSkill { - name: "kagi-research", - description: "Research a topic with Kagi Search, Quick Answer, News, and source follow-up", - source: KAGI_RESEARCH_SKILL_SOURCE, - }, - EmbeddedSkill { - name: "kagi-content", - description: "Extract, summarize, question, or translate web page content", - source: KAGI_CONTENT_SKILL_SOURCE, + name: "kagi-ai", + description: "Spend Kagi AI allowance on reasoning, research, coding, and file analysis", + source: KAGI_AI_SKILL_SOURCE, }, EmbeddedSkill { name: "kagi-assistant", @@ -144,9 +138,8 @@ mod tests { assert_eq!( names, [ - "kagi", - "kagi-research", - "kagi-content", + "kagi-usage", + "kagi-ai", "kagi-assistant", "kagi-monitoring", "kagi-account-config", @@ -163,5 +156,9 @@ mod tests { "{name} should expose a frontmatter-free skill body" ); } + + let ai = skill_content("kagi-ai").expect("kagi-ai should be embedded"); + assert!(ai.contains("Assistant allowance")); + assert!(ai.contains("kagi assistant")); } } diff --git a/src/cli.rs b/src/cli.rs index a89c355..523de43 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -258,14 +258,14 @@ Features: - Full Kagi API coverage with session token support Agent usage: - kagi skills get kagi + kagi skills get kagi-usage Skills ship with the CLI and are always version-matched. They include workflow patterns, credential guidance, and copy-paste examples. Prefer this over guessing commands from flag docs alone. skills [list] List available skills - skills get kagi Core CLI usage guide + skills get kagi-usage Core CLI usage guide skills get Load a specialized skill skills path [name] Print the embedded skill locator", propagate_version = true diff --git a/tests/integration-cli.rs b/tests/integration-cli.rs index 63cf1f1..57916f4 100644 --- a/tests/integration-cli.rs +++ b/tests/integration-cli.rs @@ -128,8 +128,8 @@ fn help_points_agents_to_agent_guide() { "expected agent help section, got:\n{stdout}" ); assert!( - stdout.contains("kagi skills get kagi"), - "expected help to mention kagi skills get kagi, got:\n{stdout}" + stdout.contains("kagi skills get kagi-usage"), + "expected help to mention kagi skills get kagi-usage, got:\n{stdout}" ); assert!( stdout.contains("skills [list]"), @@ -241,7 +241,7 @@ fn agent_command_prints_embedded_skill_guide_without_auth() { #[test] fn skills_get_prints_core_guide_without_auth() { let tempdir = TempDir::new().expect("tempdir"); - let output = run_kagi(&["skills", "get", "kagi"], &[], tempdir.path()); + let output = run_kagi(&["skills", "get", "kagi-usage"], &[], tempdir.path()); assert_success(&output); let stdout = String::from_utf8_lossy(&output.stdout); @@ -250,7 +250,7 @@ fn skills_get_prints_core_guide_without_auth() { "expected markdown skill guide, got:\n{stdout}" ); assert!( - stdout.contains("kagi skills get kagi"), + stdout.contains("kagi skills get "), "expected skills command guidance, got:\n{stdout}" ); } @@ -263,9 +263,8 @@ fn skills_list_and_path_are_auth_free() { assert_success(&list); let stdout = String::from_utf8_lossy(&list.stdout); for skill in [ - "kagi", - "kagi-research", - "kagi-content", + "kagi-usage", + "kagi-ai", "kagi-assistant", "kagi-monitoring", "kagi-account-config", @@ -283,18 +282,22 @@ fn skills_list_and_path_are_auth_free() { "embedded://skills" ); - let skill_path = run_kagi(&["skills", "path", "kagi"], &[], tempdir.path()); + let skill_path = run_kagi(&["skills", "path", "kagi-usage"], &[], tempdir.path()); assert_success(&skill_path); assert_eq!( String::from_utf8_lossy(&skill_path.stdout).trim(), - "embedded://skills/kagi" + "embedded://skills/kagi-usage" ); } #[test] fn skills_get_full_prints_body_without_frontmatter() { let tempdir = TempDir::new().expect("tempdir"); - let output = run_kagi(&["skills", "get", "kagi", "--full"], &[], tempdir.path()); + let output = run_kagi( + &["skills", "get", "kagi-usage", "--full"], + &[], + tempdir.path(), + ); assert_success(&output); let stdout = String::from_utf8_lossy(&output.stdout);