287 Commits

Author SHA1 Message Date
github-actions[bot] 30eedd9b8c chore: bump Cargo.toml to 0.3.0 2026-04-02 20:17:47 +00:00
github-actions[bot] d701b45057 bump: version 0.2.0 → 0.3.0 [skip ci] 2026-04-02 20:17:45 +00:00
Dark-Alex-17 722c9c101e feat: Added todo__clear function to the todo system and updated REPL commands to have a .clear todo as well for significant changes in agent direction 2026-04-02 13:13:44 -06:00
Dark-Alex-17 86aa45f0c4 fix: Clarified user text input interaction 2026-03-30 16:27:22 -06:00
Dark-Alex-17 cf45dc4820 fix: recursion bug with similarly named Bash search functions in the explore agent 2026-03-30 13:32:13 -06:00
Dark-Alex-17 db77034431 feat: Added available tools to prompts for sisyphus and code-reviewer agent families 2026-03-30 13:13:30 -06:00
Dark-Alex-17 abdaec11b0 feat: Added available tools to coder prompt 2026-03-30 11:11:43 -06:00
Dark-Alex-17 95fb349656 Merge branch 'main' of github.com:Dark-Alex-17/loki 2026-03-30 10:15:51 -06:00
Dark-Alex-17 d0b6b6c324 fix: updated the error for unauthenticated oauth to include the REPL .authenticated command 2026-03-28 11:57:01 -06:00
Dark-Alex-17 d74c23ccf5 feat: Improved token efficiency when delegating from sisyphus -> coder 2026-03-18 15:07:29 -06:00
Dark-Alex-17 ea1cfda0d6 build: Removed deprecated agent functions from the .shared/utils.sh script 2026-03-18 15:04:14 -06:00
Dark-Alex-17 5623f47f9a fix: Corrected a bug in the coder agent that wasn't outputting a summary of the changes made, so the parent Sisyphus agent has no idea if the agent worked or not 2026-03-17 14:57:07 -06:00
Dark-Alex-17 e4df9ec193 feat: modified sisyphus agents to use the new ddg-search MCP server for web searches instead of built-in model searches 2026-03-17 14:55:33 -06:00
Dark-Alex-17 a6306d6b76 fix: Claude code system prompt injected into claude requests to make them valid once again 2026-03-17 10:44:50 -06:00
Dark-Alex-17 64529ba5cc fix: Do not inject tools when models don't support them; detect this conflict before API calls happen 2026-03-17 09:35:51 -06:00
Dark-Alex-17 cc7f963b89 style: Applied formatting across new inquire files 2026-03-16 12:39:20 -06:00
Dark-Alex-17 0ce86af116 feat: Added support for specifying a custom response to multiple-choice prompts when nothing suits the user's needs 2026-03-16 12:37:47 -06:00
Dark-Alex-17 2cb0ed3f64 feat: Supported theming in the inquire prompts in the REPL 2026-03-16 12:36:20 -06:00
Dark-Alex-17 fb61854f11 build: upgraded to the most recent version of the inquire crate 2026-03-16 12:31:28 -06:00
Dark-Alex-17 53ba3344b1 docs: Fixed a spacing issue in the example agent configuration 2026-03-13 14:19:39 -06:00
Dark-Alex-17 e20c8be8bb docs: Added the file-reviewer agent to the AGENTS docs 2026-03-13 14:07:13 -06:00
Dark-Alex-17 894dcb1d3c docs: Updated the MCP-SERVERS docs to mention the ddg-search MCP server 2026-03-13 13:32:58 -06:00
Dark-Alex-17 9a9e890f8a feat: Added the duckduckgo-search MCP server for searching the web (in addition to the built-in tools for web searches) 2026-03-13 13:29:56 -06:00
Dark-Alex-17 818ea634f0 Merge branch 'main' of github.com:Dark-Alex-17/loki 2026-03-12 15:17:54 -06:00
Dark-Alex-17 780460f8d8 fix: Implemented the path normalization fix for the oracle and explore agents 2026-03-12 13:38:15 -06:00
Dark-Alex-17 e19483a920 chore: Added GPT-5.2 to models.yaml 2026-03-12 13:30:23 -06:00
Dark-Alex-17 aca93f1cae docs: Updated the docs to now explicitly mention Gemini OAuth support 2026-03-12 13:30:10 -06:00
Dark-Alex-17 1371a4aad2 feat: Support for Gemini OAuth 2026-03-12 13:29:47 -06:00
Dark-Alex-17 db4a45c0f6 refactor: Made the oauth module more generic so it can support loopback OAuth (not just manual) 2026-03-12 13:28:09 -06:00
Dark-Alex-17 e95b1e5f82 fix: Updated the atlassian MCP server endpoint to account for future deprecation 2026-03-12 12:49:26 -06:00
Dark-Alex-17 15f4008f4b fix: Fixed a bug in the coder agent that was causing the agent to create absolute paths from the current directory 2026-03-12 12:39:49 -06:00
Dark-Alex-17 f45f81fb45 fix: The REPL .authenticate command works from within sessions, agents, and roles with pre-configured models 2026-03-12 09:08:17 -06:00
Dark-Alex-17 2220fd2542 feat: Support authenticating or refreshing OAuth for supported clients from within the REPL 2026-03-11 13:07:27 -06:00
Dark-Alex-17 564480e165 fix: the updated regex for secrets injection broke MCP server secrets interpolation because the regex greedily matched on new lines, replacing too much content. This fix just ignores commented out lines in YAML files by skipping commented out lines. 2026-03-11 12:55:28 -06:00
Dark-Alex-17 297c63d91a feat: Allow first-runs to select OAuth for supported providers 2026-03-11 12:01:17 -06:00
Dark-Alex-17 26e2cd3f65 fix: Don't try to inject secrets into commented-out lines in the config 2026-03-11 11:11:09 -06:00
Dark-Alex-17 9f899466d4 feat: Support OAuth authentication flows for Claude 2026-03-11 11:10:48 -06:00
Dark-Alex-17 38393ea4cf chore: Added support for Claude 4.6 gen models 2026-03-10 14:55:30 -06:00
Dark-Alex-17 a4f25826e3 fix: Removed top_p parameter from some agents so they can work across model providers 2026-03-10 10:18:38 -06:00
Dark-Alex-17 93484fb33f Merge branch 'main' of github.com:Dark-Alex-17/loki 2026-03-09 14:58:23 -06:00
Dark-Alex-17 c90f003f92 chore: Added the new gemini-3.1-pro-preview model to gemini and vertex models 2026-03-09 14:57:39 -06:00
Dark-Alex-17 24793b9b8d docs: created an authorship policy and PR template that requires disclosure of AI assistance in contributions 2026-02-24 17:46:07 -07:00
Dark-Alex-17 78e772f455 style: Applied formatting to MCP module 2026-02-20 15:28:21 -07:00
Dark-Alex-17 1e0d269aad docs: Updated sisyphus README to always include the execute_command.sh tool 2026-02-20 15:06:57 -07:00
Dark-Alex-17 f6b1d408fc docs: Updated the sisyphus system docs to have a pro-tip of configuring an IDE MCP server to improve performance 2026-02-20 15:01:08 -07:00
Dark-Alex-17 442b318b6c docs: Created README docs for the CodeRabbit-style Code reviewer agents 2026-02-20 15:00:32 -07:00
Dark-Alex-17 a7c97aedb7 feat: Improved MCP server spinup and spindown when switching contexts or settings in the REPL: Modify existing config rather than stopping all servers always and re-initializing if unnecessary 2026-02-20 14:36:34 -07:00
Dark-Alex-17 746f9e7b24 fix: Improved sub-agent stdout and stderr output for users to follow 2026-02-20 13:47:28 -07:00
Dark-Alex-17 0d6c61af5c Update models.yaml with latest OpenRouter data 2026-02-20 12:08:00 -07:00
Dark-Alex-17 673f31c059 Add script to update models.yaml from OpenRouter 2026-02-20 12:07:59 -07:00
Dark-Alex-17 369a4f0a89 fix: Inject agent variables into environment variables for global tool calls when invoked from agents to modify global tool behavior 2026-02-20 11:38:24 -07:00
Dark-Alex-17 8d54eae4d0 feat: Allow the explore agent to run search queries for understanding docs or API specs 2026-02-19 14:29:02 -07:00
Dark-Alex-17 a805d5beab feat: Allow the oracle to perform web searches for deeper research 2026-02-19 14:26:07 -07:00
Dark-Alex-17 dbb2aec8b6 fix: Removed the unnecessary execute_commands tool from the oracle agent 2026-02-19 14:18:16 -07:00
Dark-Alex-17 1a98b76a1f fix: Added auto_confirm to the coder agent so sub-agent spawning doesn't freeze 2026-02-19 14:15:42 -07:00
Dark-Alex-17 51d10ab2b5 feat: Added web search support to the main sisyphus agent to answer user queries 2026-02-19 12:29:07 -07:00
Dark-Alex-17 1aad750395 refactor: Changed the default session name for Sisyphus to temp (to require users to explicitly name sessions they wish to save) 2026-02-19 10:26:52 -07:00
Dark-Alex-17 e0aab6bd02 fix: Fixed a bug in the new supervisor and todo built-ins that was causing errors with OpenAI models 2026-02-18 14:52:57 -07:00
Dark-Alex-17 6cb93132b7 fix: Added condition to sisyphus to always output a summary to clearly indicate completion 2026-02-18 13:57:51 -07:00
Dark-Alex-17 04126b99d6 fix: Updated the sisyphus prompt to explicitly tell it to delegate to the coder agent when it wants to write any code at all except for trivial changes 2026-02-18 13:51:43 -07:00
Dark-Alex-17 0794eb960d fix: Added back in the auto_confirm variable into sisyphus 2026-02-18 13:42:39 -07:00
Dark-Alex-17 d619ad1d48 fix: Removed the now unnecessary is_stale_response that was breaking auto-continuing with parallel agents 2026-02-18 13:36:25 -07:00
Dark-Alex-17 5b147e07b3 style: Applied formatting to the function module 2026-02-18 13:20:18 -07:00
Dark-Alex-17 944ce441d8 build: Upgraded to the most recent version of rmcp 2026-02-18 12:28:52 -07:00
Dark-Alex-17 a7dcb8519b refactor: Updated the sisyphus agent to use the built-in user interaction tools instead of custom bash-based tools 2026-02-18 12:17:35 -07:00
Dark-Alex-17 d912d44fb3 feat: Created a CodeRabbit-style code-reviewer agent 2026-02-18 12:16:59 -07:00
Dark-Alex-17 4f7254a634 docs: Updated the docs to include details on the new agent spawning system and built-in user interaction tools 2026-02-18 12:16:29 -07:00
Dark-Alex-17 bf923cb296 fix: Bypassed enabled_tools for user interaction tools so if function calling is enabled at all, the LLM has access to the user interaction tools when in REPL mode 2026-02-18 11:25:25 -07:00
Dark-Alex-17 d9f737e1bf feat: Added configuration option in agents to indicate the timeout for user input before proceeding (defaults to 5 minutes) 2026-02-18 11:24:47 -07:00
Dark-Alex-17 59690d045e feat: Added support for sub-agents to escalate user interaction requests from any depth to the parent agents for user interactions 2026-02-18 11:06:15 -07:00
Dark-Alex-17 5d95acba53 feat: built-in user interaction tools to remove the need for the list/confirm/etc prompts in prompt tools and to enhance user interactions in Loki 2026-02-18 11:05:43 -07:00
Dark-Alex-17 d46225d2a9 fix: When parallel agents run, only write to stdout from the parent and only display the parent's throbber 2026-02-18 09:59:24 -07:00
Dark-Alex-17 3af30a0e62 refactor: Cleaned up some left-over implementation stubs 2026-02-18 09:13:39 -07:00
Dark-Alex-17 69eca4d96d fix: Forgot to implement support for failing a task and keep all dependents blocked 2026-02-18 09:13:11 -07:00
Dark-Alex-17 7b2e4a83c9 fix: Clean up orphaned sub-agents when the parent agent 2026-02-18 09:12:32 -07:00
Dark-Alex-17 344b80872a fix: Fixed the bash prompt utils so that they correctly show output when being run by a tool invocation 2026-02-17 17:19:42 -07:00
Dark-Alex-17 ddf828ff5f feat: Experimental update to sisyphus to use the new parallel agent spawning system 2026-02-17 16:33:08 -07:00
Dark-Alex-17 4e170b069b fix: Forgot to automatically add the bidirectional communication back up to parent agents from sub-agents (i.e. need to be able to check inbox and send messages) 2026-02-17 16:11:35 -07:00
Dark-Alex-17 22c75fb578 feat: Added an agent configuration property that allows auto-injecting sub-agent spawning instructions (when using the built-in sub-agent spawning system) 2026-02-17 15:49:40 -07:00
Dark-Alex-17 11ab9eb6b8 feat: Auto-dispatch support of sub-agents and support for the teammate pattern between subagents 2026-02-17 15:18:27 -07:00
Dark-Alex-17 29b232f407 docs: Initial documentation cleanup of parallel agent MVP 2026-02-17 14:30:28 -07:00
Dark-Alex-17 53e8c920e5 fix: Agent delegation tools were not being passed into the {{__tools__}} placeholder so agents weren't delegating to subagents 2026-02-17 14:19:22 -07:00
Dark-Alex-17 78d19bed4d feat: Full passive task queue integration for parallelization of subagents 2026-02-17 13:42:53 -07:00
Dark-Alex-17 10f4160635 feat: Implemented initial scaffolding for built-in sub-agent spawning tool call operations 2026-02-17 11:48:31 -07:00
Dark-Alex-17 7622836e8b feat: Initial models for agent parallelization 2026-02-17 11:27:55 -07:00
Dark-Alex-17 4d4713a9fa docs: Fixed typos in the Sisyphus documentation 2026-02-16 14:05:51 -07:00
Dark-Alex-17 25008599f9 feat: Added interactive prompting between the LLM and the user in Sisyphus using the built-in Bash utils scripts 2026-02-16 13:57:04 -07:00
github-actions[bot] c00ab074f8 chore: bump Cargo.toml to 0.2.0 2026-02-14 01:41:41 +00:00
github-actions[bot] aed1f1957f bump: version 0.1.3 → 0.2.0 [skip ci] 2026-02-14 01:41:29 +00:00
Dark-Alex-17 c6a959e2e1 feat: Simplified sisyphus prompt to improve functionality 2026-02-13 18:36:10 -07:00
Dark-Alex-17 02b7ed37f6 feat: Supported the injection of RAG sources into the prompt, not just via the .sources rag command in the REPL so models can directly reference the documents that supported their responses 2026-02-13 17:45:56 -07:00
Dark-Alex-17 0d84aaabb9 docs: updated the tools documentation to mention the new fs_read, fs_grep, and fs_glob tools 2026-02-13 16:53:00 -07:00
Dark-Alex-17 6efdcf9610 docs: updated the default configuration example to have the new fs_read, fs_glob, fs_grep global functions 2026-02-13 16:23:49 -07:00
Dark-Alex-17 4266d317d8 docs: Updated the docs to mention the new agents 2026-02-13 15:42:28 -07:00
Dark-Alex-17 4ce7aafcbd feat: Created the Sisyphus agent to make Loki function like Claude Code, Gemini, Codex, etc. 2026-02-13 15:42:10 -07:00
Dark-Alex-17 35d8b69f92 feat: Created the Oracle agent to handle high-level architectural decisions and design questions about a given codebase 2026-02-13 15:41:44 -07:00
Dark-Alex-17 562057e608 feat: Updated the coder agent to be much more task-focused and to be delegated to by Sisyphus 2026-02-13 15:41:11 -07:00
Dark-Alex-17 b7024e5340 feat: Created the explore agent for exploring codebases to help answer questions 2026-02-13 15:40:46 -07:00
Dark-Alex-17 088588231b docs: Updated todo-system docs 2026-02-13 15:13:37 -07:00
Dark-Alex-17 eff117d3d9 feat: Use the official atlassian MCP server for the jira-helper agent 2026-02-13 14:56:42 -07:00
Dark-Alex-17 968c535709 feat: Created fs_glob to enable more targeted file exploration utilities 2026-02-13 13:31:50 -07:00
Dark-Alex-17 c8b6fa7b11 feat: Created a new tool 'fs_grep' to search a given file's contents for relevant lines to reduce token usage for smaller models 2026-02-13 13:31:20 -07:00
Dark-Alex-17 0aa334b54e feat: Created the new fs_read tool to enable controlled reading of a file 2026-02-13 13:30:53 -07:00
Dark-Alex-17 78a49f841d feat: Let agent level variables be defined to bypass guard protections for tool invocations 2026-02-09 16:45:11 -07:00
Dark-Alex-17 43b2bd937e fix: Improved continuation prompt to not make broad todo-items 2026-02-09 15:36:57 -07:00
Dark-Alex-17 a4326875ba fix: Allow auto-continuation to work in agents after a session is compressed and if there's still unfinish items in the to-do list 2026-02-09 15:21:39 -07:00
Dark-Alex-17 eb31a58346 fix: fs_ls and fs_cat outputs should always redirect to "$LLM_OUTPUT" including on errors. 2026-02-09 14:56:55 -07:00
Dark-Alex-17 a6b0acc35d feat: Implemented a built-in task management system to help smaller LLMs complete larger multistep tasks and minimize context drift 2026-02-09 12:49:06 -07:00
Dark-Alex-17 cc7fcd0b5b feat: Improved tool and MCP invocation error handling by returning stderr to the model when it is available 2026-02-04 12:00:21 -07:00
Dark-Alex-17 02fe59b913 feat: Added variable interpolation for conversation starters in agents 2026-02-04 10:51:59 -07:00
Dark-Alex-17 6fd5f47089 build: Upgraded to the most recent version of gman to fix vault vulnerabilities 2026-02-03 09:24:53 -07:00
Dark-Alex-17 2a2922760e feat: Implemented retry logic for failed tool invocations so the LLM can learn from the result and try again; Also implemented chain loop detection to prevent loops 2026-02-01 17:06:16 -07:00
Dark-Alex-17 a3793460fd fix: Claude tool calls work incorrectly when tool doesn't require any arguments or flags; would provide an empty JSON object or error on no args 2026-02-01 17:05:36 -07:00
Dark-Alex-17 e0927a04d9 feat: Added gemini-3-pro to the supported vertexai models 2026-01-30 19:03:41 -07:00
Dark-Alex-17 8665604bab Fixed some typos in tool call error messages 2026-01-30 12:25:57 -07:00
Dark-Alex-17 d4c3c135b3 build: Created justfile to make life easier 2026-01-27 13:49:36 -07:00
Dark-Alex-17 60bd5e493c docs: Created a CREDITS file to document the history and origins of Loki from the original AIChat project 2026-01-27 13:15:20 -07:00
Dark-Alex-17 0753b2d841 build: Support Claude Opus 4.5 2026-01-26 12:40:06 -07:00
Dark-Alex-17 17e6fbd692 feat: Added an environment variable that lets users bypass guard operations in bash scripts. This is useful for agent routing 2026-01-23 14:18:52 -07:00
Dark-Alex-17 0710441650 fix: Fixed a bug where --agent-variable values were not being passed to the agents 2026-01-23 14:15:59 -07:00
Dark-Alex-17 20a76cee3e feat: Added support for thought-signatures for Gemini 3+ models 2026-01-21 15:11:55 -07:00
Dark-Alex-17 cb64785867 style: Cleaned up an anyhow error 2025-12-16 14:51:35 -07:00
github-actions[bot] e6e26103c4 bump: version 0.1.2 → 0.1.3 [skip ci] 2025-12-13 20:57:37 +00:00
Dark-Alex-17 15529a14f1 ci: Prep for 0.1.3 release 2025-12-13 13:38:09 -07:00
Dark-Alex-17 86839188e0 style: Improved error message for un-fully configured MCP configuration 2025-12-13 13:37:01 -07:00
github-actions[bot] 39701b378b chore: bump Cargo.toml to 0.1.3 2025-12-13 20:28:10 +00:00
github-actions[bot] 45ff6da737 bump: version 0.1.2 → 0.1.3 [skip ci] 2025-12-13 20:27:58 +00:00
Dark-Alex-17 a260dd1503 chore: Updated the models 2025-12-11 09:05:41 -07:00
Dark-Alex-17 57859301df docs: Removed the warning about MCP token usage since that has been fixed 2025-12-05 12:38:15 -07:00
Dark-Alex-17 8c968d3f53 docs: Fixed an unclosed backtick typo in the Environment Variables docs 2025-12-05 12:37:59 -07:00
Dark-Alex-17 0034bfbe46 docs: Fixed typo in vault readme 2025-12-05 11:05:14 -07:00
Dark-Alex-17 a733b9247a style: Applied formatting 2025-12-03 15:06:50 -07:00
Dark-Alex-17 e0afa349b9 Merge branch 'main' of github.com:Dark-Alex-17/loki 2025-12-03 14:57:03 -07:00
Dark-Alex-17 7d0ce94907 feat: Improved MCP implementation to minimize the tokens needed to utilize it so it doesn't quickly overwhelm the token space for a given model 2025-12-03 12:12:51 -07:00
Alex Clarke 9045763c35 ci: Updated the README to be a bit more clear in some sections 2025-11-26 15:53:54 -07:00
github-actions[bot] 29898552d7 bump: version 0.1.1 → 0.1.2 [skip ci] 2025-11-08 23:13:34 +00:00
Dark-Alex-17 9d7c2f5c2f refactor: Gave the GitHub MCP server a default placeholder value that doesn't require the vault 2025-11-08 16:09:32 -07:00
github-actions[bot] 5c0fa42351 bump: version 0.1.1 → 0.1.2 [skip ci] 2025-11-08 23:02:40 +00:00
Dark-Alex-17 ab045b0ef3 bug: Removed the github MCP server and slack MCP server from mcp.json so users can just use Loki without any other setup and add more later 2025-11-08 15:59:05 -07:00
Alex Clarke 41e6843db1 build: Removed the remaining IDE metadata directories 2025-11-07 18:21:58 -07:00
Dark-Alex-17 911ec3c9b9 build: Added forgotten IDE configuration directories into my .gitignore 2025-11-07 18:18:32 -07:00
github-actions[bot] fc6f0a1a7b bump: version 0.1.0 → 0.1.1 [skip ci] 2025-11-08 00:22:06 +00:00
Dark-Alex-17 21873da278 docs: Fixed a typo in the CI badge path 2025-11-07 17:17:57 -07:00
Dark-Alex-17 d1cd6be2c9 docs: Fixed some confusing wording in the global configuration example file 2025-11-07 16:57:49 -07:00
github-actions[bot] 0c0ae41bca bump: version 0.0.1 → 0.1.0 [skip ci] 2025-11-07 23:47:37 +00:00
Dark-Alex-17 c9ed7a904a ci: Final release checks before open sourcing the repo 2025-11-07 16:43:50 -07:00
Dark-Alex-17 d200a8f554 Merge remote-tracking branch 'origin/main' 2025-11-07 16:24:47 -07:00
Dark-Alex-17 3d04c8fcf1 docs: Fixed a typo in the Vault documentation 2025-11-07 16:24:42 -07:00
github-actions[bot] f53f165d91 bump: version 0.0.1 → 0.1.0 [skip ci] 2025-11-07 23:19:04 +00:00
Dark-Alex-17 e5645e4064 ci: Prepare for release 2025-11-07 16:18:16 -07:00
Dark-Alex-17 95e15ca8c4 bump: version 0.0.1 → 0.1.0 2025-11-07 16:11:14 -07:00
Dark-Alex-17 dbf7329e87 refactor: Updated to the most recent Rust version with 2024 syntax 2025-11-07 15:50:55 -07:00
github-actions[bot] ed6c3ae431 bump: version 0.1.0 → 0.2.0 [skip ci] 2025-11-07 22:04:11 +00:00
Dark-Alex-17 214d2ecc67 ci: Bumped the patch version 2025-11-07 15:03:31 -07:00
Dark-Alex-17 29c95671de build: bumped the crate version 2025-11-07 14:59:41 -07:00
Dark-Alex-17 238f93a096 docs: Added badges for Loki 2025-11-07 14:24:25 -07:00
Dark-Alex-17 c76877e7b3 ci: Fixed typo in commit message for homebrew tap 2025-11-07 14:24:13 -07:00
Dark-Alex-17 12e5a9c5aa build: Renamed the crate to loki-ai since loki is taken 2025-11-07 14:16:02 -07:00
Dark-Alex-17 7f4be2ca3f ci: Created the homebrew installation steps 2025-11-07 13:53:28 -07:00
Dark-Alex-17 29ffe12d8c ci: Created the release pipeline 2025-11-07 13:51:53 -07:00
Dark-Alex-17 d34bed4f15 docs: Updated the README to credit the AIChat team and to offer quick links to get around the docs 2025-11-07 13:49:26 -07:00
Dark-Alex-17 aec7ea7e80 docs: Wrote migration documentation for users coming from AIChat 2025-11-07 13:49:02 -07:00
Dark-Alex-17 5938e1af29 docs: Added a simple gif to show what the models table looks like for tab completions 2025-11-07 13:48:48 -07:00
Dark-Alex-17 60902297c5 docs: Replaced the copy gif with one that better shows that the content is copied to your clipboard 2025-11-07 13:48:30 -07:00
Dark-Alex-17 12a95aa6fa docs: Updated the continue gif to use a prompt that makes more sense 2025-11-07 13:48:09 -07:00
Dark-Alex-17 78fc459a97 docs: Updated the set gif to show the up-to-date settings names 2025-11-07 13:47:57 -07:00
Dark-Alex-17 281565804c docs: Updated the regenerate gif to use the up-to-date settings names 2025-11-07 13:47:41 -07:00
Dark-Alex-17 33a32fd9c8 docs: Created docs for the REPL 2025-11-07 13:47:20 -07:00
Dark-Alex-17 b64aad55e9 docs: Documented all available environment variables 2025-11-07 13:47:10 -07:00
Dark-Alex-17 2392958114 docs: Added back in the conversation starters gif for the agent docs 2025-11-07 13:46:53 -07:00
Dark-Alex-17 ec04e8e24a docs: Made an example agent gif to show how they work (and variables) 2025-11-07 13:46:35 -07:00
Dark-Alex-17 4e14ee7f50 docs: Created documentation for agents 2025-11-07 13:46:16 -07:00
Dark-Alex-17 7ba4ab0608 docs: Added a screenshot of the tools overrides settings 2025-11-07 13:46:00 -07:00
Dark-Alex-17 fd816112fb docs: Created docs about both built-in and custom tools for function calling capabilities 2025-11-07 13:45:45 -07:00
Dark-Alex-17 d0ee85be40 docs: Documented how to create custom tools in Python, and how custom tools are created and used 2025-11-07 13:45:23 -07:00
Dark-Alex-17 9448704af3 docs: Documented how to create custom Bash-based tools 2025-11-07 13:45:01 -07:00
Dark-Alex-17 9dad9d6ca8 docs: Added back in forgotten gif of a session 2025-11-07 13:44:44 -07:00
Dark-Alex-17 3f41abed7c docs: documentation on how sessions work in Loki 2025-11-07 13:44:32 -07:00
Dark-Alex-17 debcbab445 docs: Created a demo gif of how to use roles in general 2025-11-07 13:44:16 -07:00
Dark-Alex-17 7fcabf1de7 docs: Created a demo gif of a temporary prompt role 2025-11-07 13:44:00 -07:00
Dark-Alex-17 e116a1841d docs: Documented roles 2025-11-07 13:43:37 -07:00
Dark-Alex-17 cd3103ca14 docs: created a gif that demonstrates macro functionality 2025-11-07 13:43:26 -07:00
Dark-Alex-17 50d07a4b13 docs: Removed a forgotten TODO comment 2025-11-07 13:43:09 -07:00
Dark-Alex-17 ed1352936e docs: created a screenshot of the global settings overrides for MCP servers 2025-11-07 13:42:36 -07:00
Dark-Alex-17 f4b4156a0c docs: created screenshots for both ephemeral and persistent RAG 2025-11-07 13:42:15 -07:00
Dark-Alex-17 5cf2cce0e3 docs: documented RAG 2025-11-07 13:41:50 -07:00
Dark-Alex-17 249453d829 docs: Created docs that explain how to use MCP servers with Loki 2025-11-07 13:41:19 -07:00
Dark-Alex-17 c14939cecc docs: created docs for Loki's macro system 2025-11-07 13:40:48 -07:00
Dark-Alex-17 72f516abb1 docs: documented how to use custom themes 2025-11-07 13:40:25 -07:00
Dark-Alex-17 66478ed264 docs: documented how to create custom REPL prompts 2025-11-07 13:40:10 -07:00
Dark-Alex-17 6b10dff41d docs: documented the now built-in bash helper script and the tools it comes with 2025-11-07 13:39:53 -07:00
Dark-Alex-17 f8cc736482 docs: created documentation for how to patch requests via configuration settings 2025-11-07 13:39:04 -07:00
Dark-Alex-17 a0794fecfc docs: created documentation for client configurations 2025-11-07 13:38:34 -07:00
Dark-Alex-17 c68059e5b3 docs: updated the vault demo screenshots and gifs 2025-11-07 13:38:22 -07:00
Dark-Alex-17 832ca6b0de docs: Added screenshots for select custom themes 2025-11-07 13:37:56 -07:00
Dark-Alex-17 89ee43830e docs: Added documentation for secret injection support into environment variables for agents 2025-11-07 12:28:11 -07:00
Dark-Alex-17 f7cf13901e docs: Added an explain-shell screenshot 2025-11-07 12:26:43 -07:00
Dark-Alex-17 ad41fa93fb docs: Fixed a typo in the shell integrations documentation 2025-11-07 12:25:26 -07:00
Dark-Alex-17 617b7dcd49 docs: Created license 2025-11-07 11:48:19 -07:00
Dark-Alex-17 417ea032c4 ci: Created Loki installation scripts 2025-11-07 11:48:08 -07:00
Dark-Alex-17 b77bb6e200 refactor: Changed the name of the summary_prompt setting to summary_context_prompt 2025-11-07 11:13:58 -07:00
Dark-Alex-17 1fa3b4a600 refactor: Renamed summarize_prompt setting to summarization_prompt 2025-11-07 11:09:48 -07:00
Dark-Alex-17 99bd502f62 refactor: Renamed the compress_threshold setting to compression_threshold 2025-11-07 11:06:20 -07:00
Dark-Alex-17 25a271dc95 style: Applied formatting 2025-11-06 18:19:25 -07:00
Dark-Alex-17 5002ac7716 refactor: Migrated around the location of some of the more large documents for documentation 2025-11-06 18:02:17 -07:00
Dark-Alex-17 d92a559460 docs: Updated the global configuration example to have a separate section for the REPL prompts 2025-11-06 16:24:20 -07:00
Dark-Alex-17 3d571e1a31 docs: Fixed a typo in the description of the stream setting 2025-11-06 16:10:44 -07:00
Dark-Alex-17 d338daa4b6 docs: Referenced the vault documentation in the example config 2025-11-06 16:09:21 -07:00
Dark-Alex-17 6f802c2a58 docs: Created a separate, dedicated section of the example configuration file for the vault 2025-11-06 16:08:20 -07:00
Dark-Alex-17 a3f0168817 docs: Improved the documentation for sessions and the examples in the global configuration example 2025-11-06 15:55:38 -07:00
Dark-Alex-17 677702655f docs: Improved the documentation of preludes and their purpose in the example global configuration file 2025-11-06 15:48:44 -07:00
Dark-Alex-17 b0bbd0c083 docs: Improved the documentation of the behavior-related settings of the global configuration file example 2025-11-06 15:47:30 -07:00
Dark-Alex-17 5cbf23a1f4 docs: Improved wording in the example agent configuration 2025-11-06 13:55:44 -07:00
Dark-Alex-17 39eb9b34ec docs: Updated the example agent configuration to show the new global_tools and mcp_servers environment variables 2025-11-06 13:31:25 -07:00
Dark-Alex-17 5da8616518 feat: Added the agents directory to sysinfo output 2025-11-06 13:22:13 -07:00
Dark-Alex-17 b267fe05cd docs: Fixed a typo in the Vertex AI client configuration example in the example global configuration file 2025-11-06 13:07:34 -07:00
Dark-Alex-17 29f7ebe559 Added environment variables for agents for the global_tools and mcp_servers settings 2025-11-06 12:16:36 -07:00
Dark-Alex-17 bbffaca511 docs: Updated the example global configuration file with some better examples for RAG 2025-11-06 10:49:51 -07:00
Dark-Alex-17 80532836c3 docs: Created an example macro configuration file 2025-11-05 16:55:04 -07:00
Dark-Alex-17 9474f4f322 feat: Added built-in macros 2025-11-05 16:28:56 -07:00
Dark-Alex-17 93a09d3a9f bug: Removed deprecated experimentation for MCP sampling 2025-11-05 16:12:04 -07:00
Dark-Alex-17 e3935ce699 style: Added an import for Anyhow's Result in the macros module 2025-11-05 15:52:44 -07:00
Dark-Alex-17 58c15e7833 refactor: Factored out the macros structs from the large config module 2025-11-05 15:50:39 -07:00
Dark-Alex-17 fd2b7f3aa0 bug: Fixed a bug with the spacing of info output now that function_calling_support is a longer name 2025-11-05 15:41:49 -07:00
Dark-Alex-17 5ccbc629d1 feat: Updated the example role configuration file to also have the prompt field 2025-11-05 15:25:01 -07:00
Dark-Alex-17 e98ff5e8e5 feat: Updated the code role 2025-11-05 15:24:45 -07:00
Dark-Alex-17 a6fffa7b57 refactor: Refactored mcp_servers and function_calling to mcp_server_support and function_calling_support to make the purpose of the fields more clear 2025-11-04 13:17:58 -07:00
Dark-Alex-17 3ac153dd06 refactor: Refactored the use_mcp_servers field to enabled_mcp_servers to make the purpose of the field more clear 2025-11-04 12:51:41 -07:00
Dark-Alex-17 8db3108c94 Merge branch 'main' of github.com:Dark-Alex-17/loki 2025-11-04 12:37:32 -07:00
Dark-Alex-17 e25ff4ad19 refactor: Refactored use_tools field to enabled_tools field to make the use of the field more clear 2025-11-04 12:37:14 -07:00
Dark-Alex-17 21e76c6461 Refactored the use_tools field to enabled_tools to make field uses and functions more clear 2025-11-04 12:36:31 -07:00
Dark-Alex-17 103aa1a432 docs: Updated the config.example.yaml to have an example of how to use the visible_tools array 2025-11-04 12:10:17 -07:00
Dark-Alex-17 d2f4fefcf3 refactor: Removed the use of the tools.txt file and added tool visibility declarations to the global configuration file 2025-11-04 12:07:58 -07:00
Dark-Alex-17 629527988d refactor: Agents that depend on global tools now have all binaries compiled and stored in the agent's bin directory so multiple agents can run at once 2025-11-04 11:29:59 -07:00
Dark-Alex-17 7f520f1346 feat: Secret injection as environment variables into agent tools 2025-11-03 15:10:34 -07:00
Dark-Alex-17 e28619b55a feat: Removed the server functionality 2025-11-03 14:25:55 -07:00
Dark-Alex-17 f474e6130e feat: Require Vault set up for first-time setup so all passed in secrets can be encrypted right off the bat 2025-10-27 12:00:27 -06:00
Dark-Alex-17 4b5bcb45ac style: Re-applied formatting to make Clippy happy 2025-10-24 15:05:42 -06:00
Dark-Alex-17 50565a0f17 refactor: Removed the git MCP server and used the newer, better mcp-server-docker for local docker integration 2025-10-24 14:38:13 -06:00
Dark-Alex-17 cf37db4fa2 docs: Added in forgotten MCP server configuration values to the example config 2025-10-24 14:16:13 -06:00
Dark-Alex-17 ad9b4097ef Created an Elvish integration script 2025-10-24 11:28:31 -06:00
Dark-Alex-17 c22c01c6c3 refactor: Renamed the argument for the --completions flag to SHELL 2025-10-24 10:58:28 -06:00
Dark-Alex-17 31f7f50c4a feat: Added static completions via a --completions flag 2025-10-24 10:56:34 -06:00
Dark-Alex-17 a7f6ed4b16 refactor: Updated the instructions for the jira-helper agent 2025-10-23 10:07:50 -06:00
Dark-Alex-17 73ada5a221 bug: Fixed a bug when passing tools to Claude for tools that don't have any inputs 2025-10-21 10:04:38 -06:00
Dark-Alex-17 2f96256893 bug: Fixed a bug that was duplicating entries of all the functions for agents between MCP and tools 2025-10-20 15:30:29 -06:00
Dark-Alex-17 23d9e0775f ci: Updated to only include basic ARM64 and x86_64 architectures 2025-10-17 13:30:42 -06:00
Dark-Alex-17 72ade39144 bug: corrected a typo for sourcing the prompt utility bash script in the built-in tools 2025-10-16 15:48:53 -06:00
Dark-Alex-17 ec64c68777 fix: Corrected a typo for sourcing the bash utility script in some agent definitions 2025-10-16 15:47:07 -06:00
Dark-Alex-17 80932e069f chore: update the models.yaml 2025-10-16 15:20:33 -06:00
Dark-Alex-17 2f9b154b07 refactor: Modified the default PS1 look 2025-10-16 15:08:48 -06:00
Dark-Alex-17 20bf911732 style: Cleaned up some linting issues for Windows 2025-10-16 13:30:30 -06:00
Dark-Alex-17 65a3dbb228 style: Applied formatting 2025-10-16 13:01:37 -06:00
Dark-Alex-17 5844cc93ca refactor: Fixed a linting issue for Windows builds 2025-10-16 12:44:50 -06:00
Dark-Alex-17 4d23ce58c4 docs: Updated outdated API links in the config example 2025-10-16 12:38:07 -06:00
Dark-Alex-17 2bb592d5f6 feat: Support for secret injection into the global config file (API keys, for example) 2025-10-16 12:30:18 -06:00
Dark-Alex-17 3146b20c15 feat: Improved MCP handling toggle handling 2025-10-15 18:36:54 -06:00
Dark-Alex-17 455cf67750 feat: Secret injection into the MCP configuration 2025-10-15 16:06:59 -06:00
Dark-Alex-17 a6d6a877b0 feat: added REPL support for interacting with the Loki vault 2025-10-15 15:15:04 -06:00
Dark-Alex-17 a7bd54471c feat: Integrated gman with Loki to create a vault and added flags to configure the Loki vault 2025-10-14 18:00:11 -06:00
Dark-Alex-17 fe5f803163 Applied formatting 2025-10-10 15:32:51 -06:00
Dark-Alex-17 66a9b5362a bug: Automatically mark all extracted tools as executable 2025-10-10 15:30:58 -06:00
Dark-Alex-17 f3569cf68b docs: Created an example role configuration 2025-10-10 15:15:11 -06:00
Dark-Alex-17 2573f14726 feat: Added a default session to the jira helper to make interaction more natural 2025-10-10 15:03:26 -06:00
Dark-Alex-17 f1fb2d6abf style: applied formatting 2025-10-10 15:01:55 -06:00
Dark-Alex-17 4934e0ff0a refactor: Changed the name of agent_prelude to agent_session to make its purpose more clear 2025-10-10 15:01:44 -06:00
Dark-Alex-17 f772a80501 style: Applied consistent formatting to agent changes 2025-10-10 14:48:10 -06:00
Dark-Alex-17 8950843be2 feat: Created the repo-analyzer role 2025-10-10 14:43:18 -06:00
Dark-Alex-17 9b89e68908 feat: Created the coder and sql agents 2025-10-10 13:38:47 -06:00
Dark-Alex-17 ba134ca53f feat: Cleaned the built-in functions to not have leftover dependencies 2025-10-10 13:38:27 -06:00
Dark-Alex-17 21dbd9c057 feat: Created additional built-in roles for slack, repo analysis, and github 2025-10-10 13:38:03 -06:00
Dark-Alex-17 40a68f8e05 feat: Install built-in agents 2025-10-10 13:37:05 -06:00
Dark-Alex-17 37d861a631 refactor: Removed leftover javascript function support; will not implement 2025-10-10 10:22:05 -06:00
Dark-Alex-17 31f3e885ce docs: Fixed typo in Python execution docs 2025-10-10 10:05:09 -06:00
Dark-Alex-17 7ffaab2012 feat: Embedded baseline MCP config and global tools 2025-07-13 09:58:00 -06:00
Dark-Alex-17 35b7946b0d docs: Created the code of conduct 2025-07-06 10:59:27 -06:00
Dark-Alex-17 3a05a8e712 docs: Added the security policy 2025-07-06 10:58:02 -06:00
Dark-Alex-17 294a1149ef ci: Initialized commitizen configuration 2025-07-06 10:57:37 -06:00
Dark-Alex-17 8d80370014 docs: Added loki contribution guidelines 2025-07-06 10:55:52 -06:00
Dark-Alex-17 1cbdef36cf Created an .actrc file to make local CI/CD testing easier 2025-07-06 10:54:16 -06:00
Dark-Alex-17 4c8accbfc1 Removed the hestia CLI since it is no longer needed 2025-07-06 10:53:44 -06:00
Dark-Alex-17 c4c2d9cb93 Updated gitignore 2025-07-06 10:53:00 -06:00
Dark-Alex-17 7aed112326 Create issue templates and CI/CD workflows 2025-07-06 10:51:04 -06:00
Dark-Alex-17 216a3d53cd Baseline project 2025-07-06 10:45:42 -06:00
Dark-Alex-17 e0823b343b Created initial assets 2025-07-06 10:43:34 -06:00
Dark-Alex-17 cb0bc65ee4 Created initial assets 2025-07-06 10:42:46 -06:00
Dark-Alex-17 5b9ab6636f Initial commit 2025-07-06 10:41:42 -06:00
258 changed files with 47667 additions and 2 deletions
+4
View File
@@ -0,0 +1,4 @@
--artifact-server-path=./.act/artifacts
--cache-server-path=./.act/cache
--container-options --privileged
--env ACT=true
+10
View File
@@ -0,0 +1,10 @@
[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "v$version"
version_scheme = "semver"
version_provider = "cargo"
update_changelog_on_bump = true
major_version_zero = true
[tool.commitizen.hooks]
pre-commit = "git add Cargo.toml Cargo.lock"
+1
View File
@@ -0,0 +1 @@
github: Dark-Alex-17
+4
View File
@@ -0,0 +1,4 @@
---
name: Blank Issue
about: Create a blank issue.
---
+69
View File
@@ -0,0 +1,69 @@
name: Bug Report
description: Create a report to help us improve
labels: bug
body:
- type: markdown
attributes:
value: Thank you for filing a bug report!
- type: textarea
id: problem
attributes:
label: Summary
description: >
Please provide a short summary of the bug, along with any information
you feel relevant to replicate the bug.
validations:
required: true
- type: textarea
id: reproduction-steps
attributes:
label: Reproduction Steps
value: |
I tried this:
1. `loki`
I expected this to happen:
Instead, this happened:
- type: textarea
id: loki-log
attributes:
label: Loki log
description: Include the Loki log file to help diagnose the issue. (`loki --info` to see the log_path)
value: |
| OS | Log file location |
| ------- | ----------------------------------------------------- |
| Linux | `~/.cache/loki/loki.log` |
| Mac | `~/Library/Logs/loki/loki.log` |
| Windows | `C:\Users\<User>\AppData\Local\loki\loki.log` |
```
please provide a copy of your loki log file here if possible; you may need to redact some of the lines
```
- type: input
id: platform
attributes:
label: Platform
placeholder: Linux / macOS / Windows
validations:
required: true
- type: input
id: terminal-emulator
attributes:
label: Terminal Emulator
placeholder: wezterm 20220101-133340-7edc5b5a
validations:
required: true
- type: input
id: loki-version
attributes:
label: Loki Version
description: >
Loki version (`loki --version` if using a release, `git describe` if building
from main).
**Make sure that you are using the [latest loki release](https://github.com/Dark-Alex-17/loki/releases) or a newer main build**
placeholder: "loki 0.1.0"
validations:
required: true
+13
View File
@@ -0,0 +1,13 @@
---
name: Enhancement
about: Suggest an improvement
title: ''
labels: enhancement
assignees: ''
---
<!--
Your enhancement may already be reported!
Please search on the issue tracker before creating a new issue.
If this is an idea for a feature, please open an "Idea" Discussion instead.
-->
@@ -0,0 +1,11 @@
### AI assistance (if any):
- List tools here and files touched by them
### Authorship & Understanding
- [ ] I wrote or heavily modified this code myself
- [ ] I understand how it works end-to-end
- [ ] I can maintain this code in the future
- [ ] No undisclosed AI-generated code was used
- [ ] If AI assistance was used, it is documented below
+46
View File
@@ -0,0 +1,46 @@
name: CI
on:
pull_request:
branches:
- '*'
push:
branches:
- main
defaults:
run:
shell: bash
jobs:
all:
name: All
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{matrix.os}}
env:
RUSTFLAGS: --deny warnings
steps:
- uses: actions/checkout@v4
- name: Install Rust Toolchain Components
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Test
run: cargo test --all
- name: Clippy
run: cargo clippy --all --all-targets -- -D warnings
- name: Format
run: cargo fmt --all --check
+458
View File
@@ -0,0 +1,458 @@
name: Create release
permissions:
pull-requests: write
contents: write
on:
workflow_dispatch:
inputs:
bump_type:
description: "Specify the type of version bump"
required: true
default: "patch"
type: choice
options:
- patch
- minor
- major
jobs:
bump-version:
name: bump-version
runs-on: ubuntu-latest
steps:
- name: Configure SSH for Git
if: env.ACT != 'true'
run: |
mkdir -p ~/.ssh
echo "${{ secrets.RELEASE_BOT_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
- name: Checkout repository
if: env.ACT != 'true'
uses: actions/checkout@v3
with:
ssh-key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
fetch-depth: 0
- name: Checkout repository
if: env.ACT == 'true'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Commitizen
run: |
python -m pip install --upgrade pip
pip install commitizen
npm install -g conventional-changelog-cli
- name: Configure Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Bump version with Commitizen
run: |
cz bump --yes --increment ${{ github.event.inputs.bump_type }}
- name: Amend commit message to include '[skip ci]'
run: |
git commit --amend --no-edit -m "$(git log -1 --pretty=%B) [skip ci]"
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Get the new version tag
id: version
run: |
mkdir -p artifacts
NEW_TAG=$(cz version --project)
echo "New version: $NEW_TAG"
echo "version=$NEW_TAG" >> $GITHUB_ENV
echo "$NEW_TAG" > artifacts/release-version
- name: Get the previous version tag
id: prev_version
run: |
PREV_TAG=$(git describe --tags --abbrev=0 ${GITHUB_SHA}^)
echo "Previous tag: $PREV_TAG"
echo "prev_version=$PREV_TAG" >> $GITHUB_ENV
- name: Bump Cargo.toml version
shell: bash
working-directory: ${{ github.workspace }}
env:
VERSION: ${{ env.version }}
run: |
set -euo pipefail
: "${VERSION:?env.version is empty}"
# Ignore Act's local artifact dir noise
echo artifacts/ >> .git/info/exclude || true
# Edit the version line right after name="loki"
sed -E -i '
/^[[:space:]]*name[[:space:]]*=[[:space:]]*"loki"[[:space:]]*$/ {
n
s|^[[:space:]]*version[[:space:]]*=[[:space:]]*"[^"]*"|version = "'"$VERSION"'"|
}
' Cargo.toml
cargo update || true
# Git config that helps in Act
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git status --porcelain
git diff --name-only -- Cargo.toml Cargo.lock || true
if ! git diff --quiet -- Cargo.toml Cargo.lock; then
git add -u -- Cargo.toml Cargo.lock
git commit -m "chore: bump Cargo.toml to $VERSION"
else
echo "No changes to commit (already at $VERSION)"
fi
- name: Generate changelog for the version bump
id: changelog
run: |
conventional-changelog -p conventionalcommits -i CHANGELOG.md --from ${{ env.prev_version }} --to v${{ env.version }} > artifacts/changelog.md
- name: Push changes
if: env.ACT != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin --follow-tags
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: artifacts
- name: Upload the changed Cargo files (Act)
if: env.ACT == 'true'
uses: actions/upload-artifact@v4
with:
name: bumped-cargo-files
path: |
Cargo.toml
Cargo.lock
publish-github-release:
name: build-release
needs: [bump-version]
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: 1
BUILD_CMD: cargo
strategy:
fail-fast: true
matrix:
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: aarch64-apple-darwin
os: macos-latest
use-cross: true
cargo-flags: ""
- target: aarch64-pc-windows-msvc
os: windows-latest
use-cross: true
cargo-flags: ""
- target: x86_64-apple-darwin
os: macos-latest
cargo-flags: ""
- target: x86_64-pc-windows-msvc
os: windows-latest
cargo-flags: ""
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
use-cross: true
cargo-flags: ""
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
cargo-flags: ""
steps:
- name: Check if actor is repository owner
if: ${{ github.actor != github.repository_owner && env.ACT != 'true' }}
run: |
echo "You are not authorized to run this workflow."
exit 1
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: |
git fetch --all
git pull
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: |
git fetch --all
git pull
- name: Set environment variables
shell: bash
run: |
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release version: ${{ env.RELEASE_VERSION }}"
echo "Changelog body: $(cat artifacts/changelog.md)"
- name: Get bumped Cargo files (Act)
if: env.ACT == 'true'
uses: actions/download-artifact@v4
with:
name: bumped-cargo-files
path: ${{ github.workspace }}
- uses: dtolnay/rust-toolchain@stable
name: Set Rust toolchain
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.use-cross
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Overwrite build command env variable
if: matrix.use-cross
shell: bash
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV
- name: Install latest LLVM/Clang
if: matrix.os == 'ubuntu-latest'
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
# omit the version to get the latest stable for your Ubuntu (24.04 "noble" on ubuntu-latest)
sudo ./llvm.sh all
# ensure libclang dev package is present (adjust the "22" if a newer major exists)
sudo apt-get update
sudo apt-get install -y libclang-20-dev libclang-dev
- name: Show Version Information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
rustup default
cargo -V
rustc -V
- name: Build
shell: bash
run: $BUILD_CMD build --locked --release --target=${{ matrix.target }} ${{ matrix.cargo-flags }}
- name: Verify file
shell: bash
run: |
file target/${{ matrix.target }}/release/loki
- name: Test
if: matrix.target != 'aarch64-apple-darwin' && matrix.target != 'aarch64-pc-windows-msvc'
shell: bash
run: |
set -euxo pipefail
if [[ "${{ matrix.use-cross || 'false' }}" == 'true' ]]; then
cross test --release --locked --target=${{ matrix.target }} --verbose
else
cargo test --release --locked --target=${{ matrix.target }} --verbose
fi
- name: Build Archive
shell: bash
id: package
env:
target: ${{ matrix.target }}
run: |
set -euxo pipefail
bin=${GITHUB_REPOSITORY##*/}
dist_dir=`pwd`/dist
name=$bin-$target
executable=target/$target/release/$bin
if [[ "$RUNNER_OS" == "Windows" ]]; then
executable=$executable.exe
fi
mkdir $dist_dir
cp $executable $dist_dir
cd $dist_dir
if [[ "$RUNNER_OS" == "Windows" ]]; then
archive=$dist_dir/$name.zip
sha=$dist_dir/$name.sha256
7z a $archive *
certutil -hashfile $archive sha256 | grep -E [A-Fa-f0-9]{64} > $sha
echo "archive=dist/$name.zip" >> $GITHUB_OUTPUT
echo "sha=dist/$name.sha256" >> $GITHUB_OUTPUT
else
archive=$dist_dir/$name.tar.gz
sha=$dist_dir/$name.sha256
tar -czf $archive *
shasum -a 256 $archive > $sha
echo "archive=dist/$name.tar.gz" >> $GITHUB_OUTPUT
echo "sha=dist/$name.sha256" >> $GITHUB_OUTPUT
fi
- name: Publish Archive and SHA
if: env.ACT != 'true'
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
${{ steps.package.outputs.archive }}
${{ steps.package.outputs.sha }}
tag_name: v${{ env.RELEASE_VERSION }}
name: "v${{ env.RELEASE_VERSION }}"
body_path: artifacts/changelog.md
prerelease: false
- name: Add artifacts
shell: bash
run: |
[[ -d artifacts ]] || mkdir -p artifacts
cp ${{ steps.package.outputs.archive }} artifacts/
cp ${{ steps.package.outputs.sha }} artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-v${{ env.RELEASE_VERSION }}-${{ matrix.target }}
path: artifacts
overwrite: true
publish-homebrew-formula:
needs: [publish-github-release]
name: Update Homebrew formulas
runs-on: ubuntu-latest
steps:
- name: Check if actor is repository owner
if: ${{ github.actor != github.repository_owner && env.ACT != 'true' }}
run: |
echo "You are not authorized to run this workflow."
exit 1
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Get release artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Set release assets and version
shell: bash
run: |
# Set environment variables
macos_sha="$(cat ./artifacts/loki-x86_64-apple-darwin.sha256 | awk '{print $1}')"
echo "MACOS_SHA=$macos_sha" >> $GITHUB_ENV
macos_sha_arm="$(cat ./artifacts/loki-aarch64-apple-darwin.sha256 | awk '{print $1}')"
echo "MACOS_SHA_ARM=$macos_sha_arm" >> $GITHUB_ENV
linux_sha="$(cat ./artifacts/loki-x86_64-unknown-linux-musl.sha256 | awk '{print $1}')"
echo "LINUX_SHA=$linux_sha" >> $GITHUB_ENV
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release SHA macos: ${{ env.MACOS_SHA }}"
echo "Release SHA macos-arm: ${{ env.MACOS_SHA_ARM }}"
echo "Release SHA linux musl: ${{ env.LINUX_SHA }}"
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Execute Homebrew packaging script
if: env.ACT != 'true'
run: |
# run packaging script
python "./deployment/homebrew/packager.py" ${{ env.RELEASE_VERSION }} "./deployment/homebrew/loki.rb.template" "./loki.rb" ${{ env.MACOS_SHA }} ${{ env.MACOS_SHA_ARM }} ${{ env.LINUX_SHA }}
- name: Push changes to Homebrew tap
if: env.ACT != 'true'
env:
TOKEN: ${{ secrets.LOKI_GITHUB_TOKEN }}
run: |
# push to Git
git config --global user.name "Dark-Alex-17"
git config --global user.email "alex.j.tusa@gmail.com"
git clone https://Dark-Alex-17:${{ secrets.LOKI_GITHUB_TOKEN }}@github.com/Dark-Alex-17/homebrew-loki.git
rm homebrew-loki/Formula/loki.rb
cp loki.rb homebrew-loki/Formula
cd homebrew-loki
git add .
git diff-index --quiet HEAD || git commit -am "Update formula for Loki release ${{ env.RELEASE_VERSION }}"
git push https://$TOKEN@github.com/Dark-Alex-17/homebrew-loki.git
publish-crate:
needs: publish-github-release
name: Publish Crate
runs-on: ubuntu-latest
steps:
- name: Check if actor is repository owner
if: ${{ github.actor != github.repository_owner && env.ACT != 'true' }}
run: |
echo "You are not authorized to run this workflow."
exit 1
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get bumped Cargo files (Act)
if: env.ACT == 'true'
uses: actions/download-artifact@v4
with:
name: bumped-cargo-files
path: ${{ github.workspace }}
- name: Ensure repository is up-to-date
if: env.ACT != 'true'
run: |
git fetch --all
git pull
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- uses: katyo/publish-crates@v2
if: env.ACT != 'true'
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
+7
View File
@@ -0,0 +1,7 @@
/target
/tmp
/.env
!cli/**
.idea/
/loki.iml
/.idea/
+8
View File
@@ -0,0 +1,8 @@
repos:
- hooks:
- id: commitizen
- id: commitizen-branch
stages:
- pre-push
repo: https://github.com/commitizen-tools/commitizen
rev: v3.30.0
+170
View File
@@ -0,0 +1,170 @@
## v0.3.0 (2026-04-02)
### Feat
- Added `todo__clear` function to the todo system and updated REPL commands to have a .clear todo as well for significant changes in agent direction
- Added available tools to prompts for sisyphus and code-reviewer agent families
- Added available tools to coder prompt
- Improved token efficiency when delegating from sisyphus -> coder
- modified sisyphus agents to use the new ddg-search MCP server for web searches instead of built-in model searches
- Added support for specifying a custom response to multiple-choice prompts when nothing suits the user's needs
- Supported theming in the inquire prompts in the REPL
- Added the duckduckgo-search MCP server for searching the web (in addition to the built-in tools for web searches)
- Support for Gemini OAuth
- Support authenticating or refreshing OAuth for supported clients from within the REPL
- Allow first-runs to select OAuth for supported providers
- Support OAuth authentication flows for Claude
- Improved MCP server spinup and spindown when switching contexts or settings in the REPL: Modify existing config rather than stopping all servers always and re-initializing if unnecessary
- Allow the explore agent to run search queries for understanding docs or API specs
- Allow the oracle to perform web searches for deeper research
- Added web search support to the main sisyphus agent to answer user queries
- Created a CodeRabbit-style code-reviewer agent
- Added configuration option in agents to indicate the timeout for user input before proceeding (defaults to 5 minutes)
- Added support for sub-agents to escalate user interaction requests from any depth to the parent agents for user interactions
- built-in user interaction tools to remove the need for the list/confirm/etc prompts in prompt tools and to enhance user interactions in Loki
- Experimental update to sisyphus to use the new parallel agent spawning system
- Added an agent configuration property that allows auto-injecting sub-agent spawning instructions (when using the built-in sub-agent spawning system)
- Auto-dispatch support of sub-agents and support for the teammate pattern between subagents
- Full passive task queue integration for parallelization of subagents
- Implemented initial scaffolding for built-in sub-agent spawning tool call operations
- Initial models for agent parallelization
- Added interactive prompting between the LLM and the user in Sisyphus using the built-in Bash utils scripts
### Fix
- Clarified user text input interaction
- recursion bug with similarly named Bash search functions in the explore agent
- updated the error for unauthenticated oauth to include the REPL .authenticated command
- Corrected a bug in the coder agent that wasn't outputting a summary of the changes made, so the parent Sisyphus agent has no idea if the agent worked or not
- Claude code system prompt injected into claude requests to make them valid once again
- Do not inject tools when models don't support them; detect this conflict before API calls happen
- The REPL .authenticate command works from within sessions, agents, and roles with pre-configured models
- Implemented the path normalization fix for the oracle and explore agents
- Updated the atlassian MCP server endpoint to account for future deprecation
- Fixed a bug in the coder agent that was causing the agent to create absolute paths from the current directory
- the updated regex for secrets injection broke MCP server secrets interpolation because the regex greedily matched on new lines, replacing too much content. This fix just ignores commented out lines in YAML files by skipping commented out lines.
- Don't try to inject secrets into commented-out lines in the config
- Removed top_p parameter from some agents so they can work across model providers
- Improved sub-agent stdout and stderr output for users to follow
- Inject agent variables into environment variables for global tool calls when invoked from agents to modify global tool behavior
- Removed the unnecessary execute_commands tool from the oracle agent
- Added auto_confirm to the coder agent so sub-agent spawning doesn't freeze
- Fixed a bug in the new supervisor and todo built-ins that was causing errors with OpenAI models
- Added condition to sisyphus to always output a summary to clearly indicate completion
- Updated the sisyphus prompt to explicitly tell it to delegate to the coder agent when it wants to write any code at all except for trivial changes
- Added back in the auto_confirm variable into sisyphus
- Removed the now unnecessary is_stale_response that was breaking auto-continuing with parallel agents
- Bypassed enabled_tools for user interaction tools so if function calling is enabled at all, the LLM has access to the user interaction tools when in REPL mode
- When parallel agents run, only write to stdout from the parent and only display the parent's throbber
- Forgot to implement support for failing a task and keep all dependents blocked
- Clean up orphaned sub-agents when the parent agent
- Fixed the bash prompt utils so that they correctly show output when being run by a tool invocation
- Forgot to automatically add the bidirectional communication back up to parent agents from sub-agents (i.e. need to be able to check inbox and send messages)
- Agent delegation tools were not being passed into the {{__tools__}} placeholder so agents weren't delegating to subagents
### Refactor
- Made the oauth module more generic so it can support loopback OAuth (not just manual)
- Changed the default session name for Sisyphus to temp (to require users to explicitly name sessions they wish to save)
- Updated the sisyphus agent to use the built-in user interaction tools instead of custom bash-based tools
- Cleaned up some left-over implementation stubs
## v0.2.0 (2026-02-14)
### Feat
- Simplified sisyphus prompt to improve functionality
- Supported the injection of RAG sources into the prompt, not just via the `.sources rag` command in the REPL so models can directly reference the documents that supported their responses
- Created the Sisyphus agent to make Loki function like Claude Code, Gemini, Codex, etc.
- Created the Oracle agent to handle high-level architectural decisions and design questions about a given codebase
- Updated the coder agent to be much more task-focused and to be delegated to by Sisyphus
- Created the explore agent for exploring codebases to help answer questions
- Use the official atlassian MCP server for the jira-helper agent
- Created fs_glob to enable more targeted file exploration utilities
- Created a new tool 'fs_grep' to search a given file's contents for relevant lines to reduce token usage for smaller models
- Created the new fs_read tool to enable controlled reading of a file
- Let agent level variables be defined to bypass guard protections for tool invocations
- Implemented a built-in task management system to help smaller LLMs complete larger multistep tasks and minimize context drift
- Improved tool and MCP invocation error handling by returning stderr to the model when it is available
- Added variable interpolation for conversation starters in agents
- Implemented retry logic for failed tool invocations so the LLM can learn from the result and try again; Also implemented chain loop detection to prevent loops
- Added gemini-3-pro to the supported vertexai models
- Added an environment variable that lets users bypass guard operations in bash scripts. This is useful for agent routing
- Added support for thought-signatures for Gemini 3+ models
### Fix
- Improved continuation prompt to not make broad todo-items
- Allow auto-continuation to work in agents after a session is compressed and if there's still unfinish items in the to-do list
- fs_ls and fs_cat outputs should always redirect to "$LLM_OUTPUT" including on errors.
- Claude tool calls work incorrectly when tool doesn't require any arguments or flags; would provide an empty JSON object or error on no args
- Fixed a bug where --agent-variable values were not being passed to the agents
## v0.1.3 (2025-12-13)
### Feat
- Improved MCP implementation to minimize the tokens needed to utilize it so it doesn't quickly overwhelm the token space for a given model
## v0.1.2 (2025-11-08)
### Refactor
- Gave the GitHub MCP server a default placeholder value that doesn't require the vault
## v0.1.1 (2025-11-08)
## v0.1.0 (2025-11-07)
### Refactor
- Updated to the most recent Rust version with 2024 syntax
## v0.0.1 (2025-11-07)
### Feat
- Added the agents directory to sysinfo output
- Added built-in macros
- Updated the example role configuration file to also have the prompt field
- Updated the code role
- Secret injection as environment variables into agent tools
- Removed the server functionality
- Require Vault set up for first-time setup so all passed in secrets can be encrypted right off the bat
- Added static completions via a --completions flag
- Support for secret injection into the global config file (API keys, for example)
- Improved MCP handling toggle handling
- Secret injection into the MCP configuration
- added REPL support for interacting with the Loki vault
- Integrated gman with Loki to create a vault and added flags to configure the Loki vault
- Added a default session to the jira helper to make interaction more natural
- Created the repo-analyzer role
- Created the coder and sql agents
- Cleaned the built-in functions to not have leftover dependencies
- Created additional built-in roles for slack, repo analysis, and github
- Install built-in agents
- Embedded baseline MCP config and global tools
### Fix
- Corrected a typo for sourcing the bash utility script in some agent definitions
### Refactor
- Changed the name of the summary_prompt setting to summary_context_prompt
- Renamed summarize_prompt setting to summarization_prompt
- Renamed the compress_threshold setting to compression_threshold
- Migrated around the location of some of the more large documents for documentation
- Factored out the macros structs from the large config module
- Refactored mcp_servers and function_calling to mcp_server_support and function_calling_support to make the purpose of the fields more clear
- Refactored the use_mcp_servers field to enabled_mcp_servers to make the purpose of the field more clear
- Refactored use_tools field to enabled_tools field to make the use of the field more clear
- Removed the use of the tools.txt file and added tool visibility declarations to the global configuration file
- Agents that depend on global tools now have all binaries compiled and stored in the agent's bin directory so multiple agents can run at once
- Removed the git MCP server and used the newer, better mcp-server-docker for local docker integration
- Renamed the argument for the --completions flag to SHELL
- Updated the instructions for the jira-helper agent
- Modified the default PS1 look
- Fixed a linting issue for Windows builds
- Changed the name of agent_prelude to agent_session to make its purpose more clear
- Removed leftover javascript function support; will not implement
+128
View File
@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
alex.j.tusa@gmail.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
+88
View File
@@ -0,0 +1,88 @@
# Contributing
Contributors are very welcome! **No contribution is too small and all contributions are valued.**
## Rust
You'll need to have the stable Rust toolchain installed in order to develop Loki.
The Rust toolchain (stable) can be installed via rustup using the following command:
```shell
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```
This will install `rustup`, `rustc` and `cargo`. For more information, refer to the [official Rust installation documentation](https://www.rust-lang.org/tools/install).
## Commitizen
[Commitizen](https://github.com/commitizen-tools/commitizen?tab=readme-ov-file) is a nifty tool that helps us write better commit messages. It ensures that our
commits have a consistent style and makes it easier to generate CHANGELOGS. Additionally,
Commitizen is used to run pre-commit checks to enforce style constraints.
To install `commitizen` and the `pre-commit` prerequisite, run the following command:
```shell
python3 -m pip install commitizen pre-commit
```
### Commitizen Quick Guide
To see an example commit to get an idea for the Commitizen style, run:
```shell
cz example
```
To see the allowed types of commits and their descriptions, run:
```shell
cz info
```
If you'd like to create a commit using Commitizen with an interactive prompt to help you get
comfortable with the style, use:
```shell
cz commit
```
## Setup workspace
1. Clone this repo
2. Run `cargo test` to set up hooks
3. Make changes
4. Run the application using `just run` or `just run`
- Install `just` (`cargo install just`) if you haven't already to use the [justfile](./justfile) in this project.
5. Commit changes. This will trigger pre-commit hooks that will run format, test and lint. If there are errors or
warnings from Clippy, please fix them.
6. Push your code to a new branch named after the feature/bug/etc. you're adding. This will trigger pre-push hooks that
will run lint and test.
7. Create a PR
### CI/CD Testing with Act
If you also are planning on testing out your changes before pushing them with [Act](https://github.com/nektos/act), you will need to set up `act`,
`docker`, and configure your local system to run different architectures:
1. Install `docker` by following the instructions on the [official Docker installation page](https://docs.docker.com/get-docker/).
2. Install `act` by following the instructions on the [official Act installation page](https://nektosact.com/installation/index.html).
3. Install `binfmt` on your system once so that `act` can run the correct architecture for the CI/CD workflows.
You can do this by running:
```shell
sudo docker run --rm --privileged tonistiigi/binfmt --install all
```
Then, you can run workflows locally without having to commit and see if the GitHub action passes or fails.
**For example**: To test the [release.yml](.github/workflows/release.yaml) workflow locally, you can run:
```shell
act -W .github/workflows/release.yml --input_type bump=minor
```
## Authorship Policy
All code in this repository is written and reviewed by humans. AI-generated code (e.g., Copilot, ChatGPT,
Claude, etc.) is not permitted unless explicitly disclosed and approved.
Submissions must certify that the contributor understands and can maintain the code they submit.
## Questions? Reach out to me!
If you encounter any questions while developing Loki, please don't hesitate to reach out to me at
alex.j.tusa@gmail.com. I'm happy to help contributors in any way I can, regardless of if they're new or experienced!
+31
View File
@@ -0,0 +1,31 @@
# Credits
## AIChat
Loki originally started as a fork of the fantastic
[AIChat CLI](https://github.com/sigoden/aichat). The initial goal was simply
to fix a bug in how MCP servers worked with AIChat, allowing different MCP
servers to be specified per agent. Since then, Loki has evolved far beyond
its original scope and grown into a passion project with a life of its own.
Today, Loki includes first-class MCP server support (for both local and remote
servers), a built-in vault for interpolating secrets in configuration files,
built-in agents and macros, dynamic tab completions, integrated custom
functions (no external `argc` dependency), improved documentation, and much
more with many more ideas planned for the future.
Loki is now developed and maintained as an independent project. Full credit
for the original foundation goes to the developers of the wonderful
AIChat project.
This project is not affiliated with or endorsed by the AIChat maintainers.
## AIChat
Loki originally began as a fork of [AIChat CLI](https://github.com/sigoden/aichat),
created and maintained by the AIChat contributors.
While Loki has since diverged significantly and is now developed as an
independent project, its early foundation and inspiration came from the
AIChat project.
AIChat is licensed under the MIT License.
Generated
+7303
View File
File diff suppressed because it is too large Load Diff
+140
View File
@@ -0,0 +1,140 @@
[package]
name = "loki-ai"
version = "0.3.0"
edition = "2024"
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
description = "An all-in-one, batteries included LLM CLI Tool"
keywords = ["chatgpt", "llm", "cli", "ai", "repl"]
homepage = "https://github.com/Dark-Alex-17/loki"
repository = "https://github.com/Dark-Alex-17/loki"
categories = ["command-line-utilities"]
readme = "README.md"
license = "MIT"
rust-version = "1.89.0"
exclude = [".github", "CONTRIBUTING.md"]
[dependencies]
anyhow = "1.0.69"
bytes = "1.4.0"
clap = { version = "4.5.40", features = ["cargo", "derive", "wrap_help"] }
dirs = "6.0.0"
futures-util = "0.3.29"
inquire = "0.9.4"
is-terminal = "0.4.9"
reedline = "0.40.0"
serde = { version = "1.0.152", features = ["derive"] }
serde_json = { version = "1.0.93", features = ["preserve_order"] }
serde_yaml = "0.9.17"
tokio = { version = "1.34.0", features = [
"rt",
"time",
"macros",
"signal",
"rt-multi-thread",
"full",
] }
tokio-graceful = "0.2.2"
tokio-stream = { version = "0.1.15", default-features = false, features = [
"sync",
] }
crossterm = "0.28.1"
chrono = "0.4.23"
bincode = { version = "2.0.0", features = [
"serde",
"std",
], default-features = false }
parking_lot = "0.12.1"
fancy-regex = "0.14.0"
base64 = "0.22.0"
nu-ansi-term = "0.50.0"
async-trait = "0.1.74"
textwrap = "0.16.0"
ansi_colours = "1.2.2"
reqwest-eventsource = "0.6.0"
log = "0.4.28"
log4rs = { version = "1.4.0", features = ["file_appender"] }
shell-words = "1.1.0"
sha2 = "0.10.8"
unicode-width = "0.2.0"
async-recursion = "1.1.1"
http = "1.1.0"
http-body-util = "0.1"
hyper = { version = "1.0", features = ["full"] }
hyper-util = { version = "0.1", features = ["server-auto", "client-legacy"] }
time = { version = "0.3.36", features = ["macros"] }
indexmap = { version = "2.2.6", features = ["serde"] }
hmac = "0.12.1"
aws-smithy-eventstream = "0.60.4"
urlencoding = "2.1.3"
unicode-segmentation = "1.11.0"
json-patch = { version = "4.0.0", default-features = false }
bitflags = "2.5.0"
path-absolutize = "3.1.1"
hnsw_rs = "0.3.0"
rayon = "1.10.0"
uuid = { version = "1.9.1", features = ["v4"] }
scraper = { version = "0.23.1", default-features = false, features = [
"deterministic",
] }
sys-locale = "0.3.1"
html_to_markdown = "0.1.0"
rust-embed = "8.5.0"
os_info = { version = "3.8.2", default-features = false }
bm25 = { version = "2.0.1", features = ["parallelism"] }
which = "8.0.0"
fuzzy-matcher = "0.3.7"
terminal-colorsaurus = "0.4.8"
duct = "1.0.0"
argc = "1.23.0"
strum_macros = "0.27.2"
indoc = "2.0.6"
rmcp = { version = "0.16.0", features = ["client", "transport-child-process"] }
num_cpus = "1.17.0"
rustpython-parser = "0.4.0"
rustpython-ast = "0.4.0"
colored = "3.0.0"
clap_complete = { version = "4.5.58", features = ["unstable-dynamic"] }
gman = "0.3.0"
clap_complete_nushell = "4.5.9"
open = "5"
rand = "0.9.0"
url = "2.5.8"
[dependencies.reqwest]
version = "0.12.0"
features = [
"json",
"multipart",
"socks",
"rustls-tls",
"rustls-tls-native-roots",
]
default-features = false
[dependencies.syntect]
version = "5.0.0"
default-features = false
features = ["parsing", "regex-onig", "plist-load"]
[target.'cfg(target_os = "macos")'.dependencies]
crossterm = { version = "0.28.1", features = ["use-dev-tty"] }
[target.'cfg(target_os = "linux")'.dependencies]
arboard = { version = "3.3.0", default-features = false, features = [
"wayland-data-control",
] }
[target.'cfg(not(any(target_os = "linux", target_os = "android", target_os = "emscripten")))'.dependencies]
arboard = { version = "3.3.0", default-features = false }
[dev-dependencies]
pretty_assertions = "1.4.0"
[[bin]]
name = "loki"
path = "src/main.rs"
[profile.release]
lto = true
strip = true
opt-level = "z"
+22
View File
@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2025 sigoden
Copyright (c) 2025 Alexander J. Clarke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+278 -2
View File
@@ -1,2 +1,278 @@
# loki
An all-in-one, batteries included LLM CLI tool
# Loki: All-in-one, batteries-included LLM CLI Tool
![Test](https://github.com/Dark-Alex-17/loki/actions/workflows/ci.yaml/badge.svg)
![LOC](https://tokei.rs/b1/github/Dark-Alex-17/loki?category=code)
[![crates.io link](https://img.shields.io/crates/v/loki-ai.svg)](https://crates.io/crates/loki-ai)
![Release](https://img.shields.io/github/v/release/Dark-Alex-17/loki?color=%23c694ff)
![Crate.io downloads](https://img.shields.io/crates/d/loki-ai?label=Crate%20downloads)
[![GitHub Downloads](https://img.shields.io/github/downloads/Dark-Alex-17/loki/total.svg?label=GitHub%20downloads)](https://github.com/Dark-Alex-17/loki/releases)
Loki is an all-in-one, batteries-included, LLM CLI tool featuring Shell Assistant, CLI & REPL Mode, RAG, AI Tools &
Agents, and More.
It is designed to include a number of useful agents, roles, macros, and more so users can get up and running with Loki
in as little time as possible.
![Agent example](./docs/images/agents/sql.gif)
Coming from [AIChat](https://github.com/sigoden/aichat)? Follow the [migration guide](./docs/AICHAT-MIGRATION.md) to get started.
## Quick Links
* [AIChat Migration Guide](./docs/AICHAT-MIGRATION.md): Coming from AIChat? Follow the migration guide to get started.
* [Installation](#install): Install Loki
* [Getting Started](#getting-started): Get started with Loki by doing first-run setup steps.
* [REPL](./docs/REPL.md): Interactive Read-Eval-Print Loop for conversational interactions with LLMs and Loki.
* [Custom REPL Prompt](./docs/REPL-PROMPT.md): Customize the REPL prompt to provide useful contextual information.
* [Vault](./docs/VAULT.md): Securely store and manage sensitive information such as API keys and credentials.
* [Shell Integrations](./docs/SHELL-INTEGRATIONS.md): Seamlessly integrate Loki with your shell environment for enhanced command-line assistance.
* [Function Calling](./docs/function-calling/TOOLS.md#Tools): Leverage function calling capabilities to extend Loki's functionality with custom tools
* [Creating Custom Tools](./docs/function-calling/CUSTOM-TOOLS.md): You can create your own custom tools to enhance Loki's capabilities.
* [Create Custom Python Tools](./docs/function-calling/CUSTOM-TOOLS.md#custom-python-based-tools)
* [Create Custom Bash Tools](./docs/function-calling/CUSTOM-BASH-TOOLS.md)
* [Bash Prompt Utilities](./docs/function-calling/BASH-PROMPT-HELPERS.md)
* [First-Class MCP Server Support](./docs/function-calling/MCP-SERVERS.md): Easily connect and interact with MCP servers for advanced functionality.
* [Macros](./docs/MACROS.md): Automate repetitive tasks and workflows with Loki "scripts" (macros).
* [RAG](./docs/RAG.md): Retrieval-Augmented Generation for enhanced information retrieval and generation.
* [Sessions](/docs/SESSIONS.md): Manage and persist conversational contexts and settings across multiple interactions.
* [Roles](./docs/ROLES.md): Customize model behavior for specific tasks or domains.
* [Agents](/docs/AGENTS.md): Leverage AI agents to perform complex tasks and workflows, including sub-agent spawning, teammate messaging, and user interaction tools.
* [Todo System](./docs/TODO-SYSTEM.md): Built-in task tracking for improved agent reliability with smaller models.
* [Environment Variables](./docs/ENVIRONMENT-VARIABLES.md): Override and customize your Loki configuration at runtime with environment variables.
* [Client Configurations](./docs/clients/CLIENTS.md): Configuration instructions for various LLM providers.
* [Authentication (API Key & OAuth)](./docs/clients/CLIENTS.md#authentication): Authenticate with API keys or OAuth for subscription-based access.
* [Patching API Requests](./docs/clients/PATCHES.md): Learn how to patch API requests for advanced customization.
* [Custom Themes](./docs/THEMES.md): Change the look and feel of Loki to your preferences with custom themes.
* [History](#history): A history of how Loki came to be.
## Prerequisites
Loki requires the following tools to be installed on your system:
* [jq](https://github.com/jqlang/jq)
* `brew install jq`
* [jira (optional)](https://github.com/ankitpokhrel/jira-cli/wiki/Installation) (For the `query_jira_issues` tool)
* `brew tap ankitpokhrel/jira-cli && brew install jira-cli`
* You'll need to [create a JIRA API token](https://id.atlassian.com/manage-profile/security/api-tokens) for authentication
* Then, save it as an environment variable to your shell profile:
```sh
# ~/.bashrc or ~/.zshrc
export JIRA_API_TOKEN="your_jira_api_token_here"
```
* Then run `jira init`, select installation type as `cloud`, and provide the required details to generate a config
file for the Jira CLI.
* [usql](https://github.com/xo/usql) (For the `sql` agent)
* `brew install xo/xo/usql`
* [docker](https://docs.docker.com/engine/install/)
* [uv](https://docs.astral.sh/uv/getting-started/installation/)
* `curl -LsSf https://astral.sh/uv/install.sh | sh`
These tools are used to provide various functionalities within Loki, such as document processing, JSON manipulation,
interaction with Jira, and they are used within agents and tools.
## Install
### Cargo
If you have Cargo installed, then you can install `loki` from Crates.io:
```shell
cargo install loki-ai # Binary name is `loki`
# If you encounter issues installing, try installing with '--locked'
cargo install --locked loki-ai
```
### Homebrew (Mac/Linux)
To install Loki from Homebrew, install the `loki` tap. Then you'll be able to install `loki`:
```shell
brew tap Dark-Alex-17/loki
brew install loki
# If you need to be more specific, use:
brew install Dark-Alex-17/loki/loki
```
To upgrade `loki` using Homebrew:
```shell
brew upgrade loki
```
### Scripts
#### Linux/MacOS (`bash`)
You can use the following command to run a bash script that downloads and installs the latest version of `loki` for your
OS (Linux/MacOS) and architecture (x86_64/arm64):
```shell
curl -fsSL https://raw.githubusercontent.com/Dark-Alex-17/loki/main/install_loki.sh | bash
```
#### Windows/Linux/MacOS (`PowerShell`)
You can use the following command to run a PowerShell script that downloads and installs the latest version of `loki`
for your OS (Windows/Linux/MacOS) and architecture (x86_64/arm64):
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -Command "iwr -useb https://raw.githubusercontent.com/Dark-Alex-17/loki/main/scripts/install_loki.ps1 | iex"
```
### Manual
Binaries are available on the [releases](https://github.com/Dark-Alex-17/loki/releases) page for the following platforms:
| Platform | Architecture(s) |
|----------------|-----------------|
| macOS | x86_64, arm64 |
| Linux GNU/MUSL | x86_64, aarch64 |
| Windows | x86_64, aarch64 |
#### Windows Instructions
To use a binary from the releases page on Windows, do the following:
1. Download the latest [binary](https://github.com/Dark-Alex-17/loki/releases) for your OS.
2. Use 7-Zip or TarTool to unpack the Tar file.
3. Run the executable `loki.exe`!
#### Linux/MacOS Instructions
To use a binary from the releases page on Linux/MacOS, do the following:
1. Download the latest [binary](https://github.com/Dark-Alex-17/loki/releases) for your OS.
2. `cd` to the directory where you downloaded the binary.
3. Extract the binary with `tar -C /usr/local/bin -xzf loki-<arch>.tar.gz` (Note: This may require `sudo`)
4. Now you can run `loki`!
## Getting Started
After installation, you can generate the configuration files and directories by simply running:
```sh
loki --info
```
Then, you need to set up the Loki vault by creating a vault password file. Loki will do this for you automatically and
guide you through the process when you first attempt to access the vault. So, to get started, you can run:
```sh
loki --list-secrets
```
### Authentication
Each client in your configuration needs authentication (with a few exceptions; e.g. ollama). Most clients use an API key
(set via `api_key` in the config or through the [vault](./docs/VAULT.md)). For providers that support OAuth (e.g. Claude Pro/Max
subscribers, Google Gemini), you can authenticate with your existing subscription instead:
```yaml
# In your config.yaml
clients:
- type: claude
name: my-claude-oauth
auth: oauth # Indicate you want to authenticate with OAuth instead of an API key
```
```sh
loki --authenticate my-claude-oauth
# Or via the REPL: .authenticate
```
For full details, see the [authentication documentation](./docs/clients/CLIENTS.md#authentication).
### Tab-Completions
You can also enable tab completions to make using Loki easier. To do so, add the following to your shell profile:
```shell
# Bash
# (add to: `~/.bashrc`)
source <(COMPLETE=bash loki)
# Zsh
# (add to: `~/.zshrc`)
source <(COMPLETE=zsh loki)
# Fish
# (add to: `~/.config/fish/config.fish`)
source <(COMPLETE=fish loki | psub)
# Elvish
# (add to: `~/.elvish/rc.elv`)
eval (E:COMPLETE=elvish loki | slurp)
# PowerShell
# (add to: `$PROFILE`)
$env:COMPLETE = "powershell"
loki | Out-String | Invoke-Expression
```
### Shell Integration
You can integrate Loki's Shell Assistant into your shell for enhanced command-line assistance. Add the code in the
corresponding [shell integration script](./scripts/shell-integration) to your shell. Then, you can invoke Loki to convert natural language to
shell commands by pressing `Alt-e`. For example:
```shell
$ find all markdown files<Alt-e>
# Will be converted to:
find . -name "*.md"
```
## Configuration
The location of the global Loki configuration varies between systems, so you can use the following command to find your
`config.yaml` file:
```shell
loki --info | grep 'config_file' | awk '{print $2}'
```
The configuration file consists of a number of settings. To see a full example configuration file with every setting
defined, refer to the [example configuration file](./config.example.yaml).
### Default LLM
The following settings are available to configure the default LLM that is used when you start Loki, and its
hyperparameters:
| Setting | Description |
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `model` | The default LLM to use when no model is provided |
| `temperature` | The default `temperature` parameter for all models (0,1); Used unless explicitly overridden |
| `top_p` | The default `top_p` hyperparameter value to use for all models, with a range of (0,1) (or (0,2) for some models); <br>Used unless explicitly overridden |
### CLI Behavior
You can use the following settings to modify the behavior of Loki:
| Setting | Default Value | Description |
|---------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `stream` | `true` | Controls whether to use stream-style APIs when querying for completions from LLM providers |
| `save` | `true` | Controls whether to save each query/response to every model to `messages.md` for posterity; Useful for debugging |
| `keybindings` | `emacs` | Specifies which keybinding schema to use; can either be `emacs` or `vi` |
| `editor` | `null` | What text editor Loki should use to edit the input buffer or session (e.g. `vim`, `emacs`, `nano`, `hx`); <br>Defaults to `$EDITOR` |
| `wrap` | `no` | Controls whether text is wrapped (can be `no`, `auto`, or some `<max_width>` |
| `wrap_code` | `false` | Enables or disables the wrapping of code blocks |
### Preludes
Preludes let you define the default behavior for the different operating modes of Loki. The available settings are
shown below:
| Setting | Description |
|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `repl_prelude` | This setting lets you specify a default `session` or `role` to use when starting Loki in [REPL](./docs/REPL.md) mode. <br>Values can be <ul><li>`role:<name>` to define a role</li><li>`session:<name>` to define a session</li><li>`<session>:<role>` to define both a session and a role to use</li></ul> |
| `cmd_prelude` | This setting lets you specify a default `session` or `role` to use when running one-off queries in Loki via the CLI. <br>Values can be <ul><li>`role:<name>` to define a role</li><li>`session:<name>` to define a session</li><li>`<session>:<role>` to define both a session and a role to use</li></ul> |
| `agent_session` | This setting is used to specify a default session that all agents should start into, unless otherwise specified in the agent configuration. (e.g. `temp`, `default`) |
### Appearance
The appearance of Loki can be modified using the following settings:
| Setting | Default Value | Description |
|---------------|---------------|------------------------------------------------------|
| `highlight` | `true` | This setting enables or disables syntax highlighting |
| `light_theme` | `false` | This setting toggles light mode in Loki |
### Miscellaneous Settings
| Setting | Default Value | Description |
|----------------------|---------------|------------------------------------------------------------------------------------------------------------------|
| `user_agent` | `null` | The name of the `User-Agent` that should be passed in the `User-Agent` header on all requests to model providers |
| `save_shell_history` | `true` | Enables or disables REPL command history |
---
## History
Loki began as a fork of [AIChat CLI](https://github.com/sigoden/aichat) and has since evolved into an independent project.
See [CREDITS.md](./CREDITS.md) for full attribution and background.
---
## Creator
* [Alex Clarke](https://github.com/Dark-Alex-17)
+15
View File
@@ -0,0 +1,15 @@
# Security Policy
## Supported Versions
Only latest version of the software will be supported with security patches.
| Version | Supported |
| -------- | ------------------ |
| latest | :white_check_mark: |
## Reporting a Vulnerability
If you find a vulnerability, please reach out to me via email (alex.j.tusa@gmail.com).
If you yourself decide you'd like to tackle a fix, please submit a PR with the fix and I'll review it as soon as
possible.
+319
View File
@@ -0,0 +1,319 @@
#!/usr/bin/env bash
# Shared Agent Utilities - Minimal, focused helper functions
set -euo pipefail
#######################
## PROJECT DETECTION ##
#######################
# Cache file name for detected project info
_LOKI_PROJECT_CACHE=".loki-project.json"
# Read cached project detection if valid
# Usage: _read_project_cache "/path/to/project"
# Returns: cached JSON on stdout (exit 0) or nothing (exit 1)
_read_project_cache() {
local dir="$1"
local cache_file="${dir}/${_LOKI_PROJECT_CACHE}"
if [[ -f "${cache_file}" ]]; then
local cached
cached=$(cat "${cache_file}" 2>/dev/null) || return 1
if echo "${cached}" | jq -e '.type and .build != null and .test != null and .check != null' &>/dev/null; then
echo "${cached}"
return 0
fi
fi
return 1
}
# Write project detection result to cache
# Usage: _write_project_cache "/path/to/project" '{"type":"rust",...}'
_write_project_cache() {
local dir="$1"
local json="$2"
local cache_file="${dir}/${_LOKI_PROJECT_CACHE}"
echo "${json}" > "${cache_file}" 2>/dev/null || true
}
_detect_heuristic() {
local dir="$1"
# Rust
if [[ -f "${dir}/Cargo.toml" ]]; then
echo '{"type":"rust","build":"cargo build","test":"cargo test","check":"cargo check"}'
return 0
fi
# Go
if [[ -f "${dir}/go.mod" ]]; then
echo '{"type":"go","build":"go build ./...","test":"go test ./...","check":"go vet ./..."}'
return 0
fi
# Node.JS/Deno/Bun
if [[ -f "${dir}/deno.json" ]] || [[ -f "${dir}/deno.jsonc" ]]; then
echo '{"type":"deno","build":"deno task build","test":"deno test","check":"deno lint"}'
return 0
fi
if [[ -f "${dir}/package.json" ]]; then
local pm="npm"
[[ -f "${dir}/bun.lockb" ]] || [[ -f "${dir}/bun.lock" ]] && pm="bun"
[[ -f "${dir}/pnpm-lock.yaml" ]] && pm="pnpm"
[[ -f "${dir}/yarn.lock" ]] && pm="yarn"
echo "{\"type\":\"nodejs\",\"build\":\"${pm} run build\",\"test\":\"${pm} test\",\"check\":\"${pm} run lint\"}"
return 0
fi
# Python
if [[ -f "${dir}/pyproject.toml" ]] || [[ -f "${dir}/setup.py" ]] || [[ -f "${dir}/setup.cfg" ]]; then
local test_cmd="pytest"
local check_cmd="ruff check ."
if [[ -f "${dir}/poetry.lock" ]]; then
test_cmd="poetry run pytest"
check_cmd="poetry run ruff check ."
elif [[ -f "${dir}/uv.lock" ]]; then
test_cmd="uv run pytest"
check_cmd="uv run ruff check ."
fi
echo "{\"type\":\"python\",\"build\":\"\",\"test\":\"${test_cmd}\",\"check\":\"${check_cmd}\"}"
return 0
fi
# JVM (Maven)
if [[ -f "${dir}/pom.xml" ]]; then
echo '{"type":"java","build":"mvn compile","test":"mvn test","check":"mvn verify"}'
return 0
fi
# JVM (Gradle)
if [[ -f "${dir}/build.gradle" ]] || [[ -f "${dir}/build.gradle.kts" ]]; then
local gw="gradle"
[[ -f "${dir}/gradlew" ]] && gw="./gradlew"
echo "{\"type\":\"java\",\"build\":\"${gw} build\",\"test\":\"${gw} test\",\"check\":\"${gw} check\"}"
return 0
fi
# .NET / C#
if compgen -G "${dir}/*.sln" &>/dev/null || compgen -G "${dir}/*.csproj" &>/dev/null; then
echo '{"type":"dotnet","build":"dotnet build","test":"dotnet test","check":"dotnet build --warnaserrors"}'
return 0
fi
# C/C++ (CMake)
if [[ -f "${dir}/CMakeLists.txt" ]]; then
echo '{"type":"cmake","build":"cmake --build build","test":"ctest --test-dir build","check":"cmake --build build"}'
return 0
fi
# Ruby
if [[ -f "${dir}/Gemfile" ]]; then
local test_cmd="bundle exec rake test"
[[ -f "${dir}/Rakefile" ]] && grep -q "rspec" "${dir}/Gemfile" 2>/dev/null && test_cmd="bundle exec rspec"
echo "{\"type\":\"ruby\",\"build\":\"\",\"test\":\"${test_cmd}\",\"check\":\"bundle exec rubocop\"}"
return 0
fi
# Elixir
if [[ -f "${dir}/mix.exs" ]]; then
echo '{"type":"elixir","build":"mix compile","test":"mix test","check":"mix credo"}'
return 0
fi
# PHP
if [[ -f "${dir}/composer.json" ]]; then
echo '{"type":"php","build":"","test":"./vendor/bin/phpunit","check":"./vendor/bin/phpstan analyse"}'
return 0
fi
# Swift
if [[ -f "${dir}/Package.swift" ]]; then
echo '{"type":"swift","build":"swift build","test":"swift test","check":"swift build"}'
return 0
fi
# Zig
if [[ -f "${dir}/build.zig" ]]; then
echo '{"type":"zig","build":"zig build","test":"zig build test","check":"zig build"}'
return 0
fi
# Generic build systems (last resort before LLM)
if [[ -f "${dir}/justfile" ]] || [[ -f "${dir}/Justfile" ]]; then
echo '{"type":"just","build":"just build","test":"just test","check":"just lint"}'
return 0
fi
if [[ -f "${dir}/Makefile" ]] || [[ -f "${dir}/makefile" ]] || [[ -f "${dir}/GNUmakefile" ]]; then
echo '{"type":"make","build":"make build","test":"make test","check":"make lint"}'
return 0
fi
return 1
}
# Gather lightweight evidence about a project for LLM analysis
# Usage: _gather_project_evidence "/path/to/project"
# Returns: evidence string on stdout
_gather_project_evidence() {
local dir="$1"
local evidence=""
evidence+="Root files and directories:"$'\n'
evidence+=$(ls -1 "${dir}" 2>/dev/null | head -50)
evidence+=$'\n\n'
evidence+="File extension counts:"$'\n'
evidence+=$(find "${dir}" -type f \
-not -path '*/.git/*' \
-not -path '*/node_modules/*' \
-not -path '*/target/*' \
-not -path '*/dist/*' \
-not -path '*/__pycache__/*' \
-not -path '*/vendor/*' \
-not -path '*/.build/*' \
2>/dev/null \
| sed 's/.*\.//' | sort | uniq -c | sort -rn | head -10)
evidence+=$'\n\n'
local config_patterns=("*.toml" "*.yaml" "*.yml" "*.json" "*.xml" "*.gradle" "*.gradle.kts" "*.cabal" "*.pro" "Makefile" "justfile" "Justfile" "Dockerfile" "Taskfile*" "BUILD" "WORKSPACE" "flake.nix" "shell.nix" "default.nix")
local found_configs=0
for pattern in "${config_patterns[@]}"; do
if [[ ${found_configs} -ge 5 ]]; then
break
fi
local files
files=$(find "${dir}" -maxdepth 1 -name "${pattern}" -type f 2>/dev/null)
while IFS= read -r f; do
if [[ -n "${f}" && ${found_configs} -lt 5 ]]; then
local basename
basename=$(basename "${f}")
evidence+="--- ${basename} (first 30 lines) ---"$'\n'
evidence+=$(head -30 "${f}" 2>/dev/null)
evidence+=$'\n\n'
found_configs=$((found_configs + 1))
fi
done <<< "${files}"
done
echo "${evidence}"
}
# LLM-based project detection fallback
# Usage: _detect_with_llm "/path/to/project"
# Returns: JSON on stdout or empty (exit 1)
_detect_with_llm() {
local dir="$1"
local evidence
evidence=$(_gather_project_evidence "${dir}")
local prompt
prompt=$(cat <<-EOF
Analyze this project directory and determine the project type, primary language, and the correct shell commands to build, test, and check (lint/typecheck) it.
EOF
)
prompt+=$'\n'"${evidence}"$'\n'
prompt+=$(cat <<-EOF
Respond with ONLY a valid JSON object. No markdown fences, no explanation, no extra text.
The JSON must have exactly these 4 keys:
{"type":"<language>","build":"<build command>","test":"<test command>","check":"<lint or typecheck command>"}
Rules:
- "type" must be a single lowercase word (e.g. rust, go, python, nodejs, java, ruby, elixir, cpp, c, zig, haskell, scala, kotlin, dart, swift, php, dotnet, etc.)
- If a command doesn't apply to this project, use an empty string, ""
- Use the most standard/common commands for the detected ecosystem
- If you detect a package manager lockfile, use that package manager (e.g. pnpm over npm)
EOF
)
local llm_response
llm_response=$(loki --no-stream "${prompt}" 2>/dev/null) || return 1
llm_response=$(echo "${llm_response}" | sed 's/^```json//;s/^```//;s/```$//' | tr -d '\n' | sed 's/^[[:space:]]*//')
llm_response=$(echo "${llm_response}" | grep -o '{[^}]*}' | head -1)
if echo "${llm_response}" | jq -e '.type and .build != null and .test != null and .check != null' &>/dev/null; then
echo "${llm_response}" | jq -c '{type: (.type // "unknown"), build: (.build // ""), test: (.test // ""), check: (.check // "")}'
return 0
fi
return 1
}
# Detect project type and return build/test commands
# Uses: cached result -> fast heuristics -> LLM fallback
detect_project() {
local dir="${1:-.}"
local cached
if cached=$(_read_project_cache "${dir}"); then
echo "${cached}" | jq -c '{type, build, test, check}'
return 0
fi
local result
if result=$(_detect_heuristic "${dir}"); then
local enriched
enriched=$(echo "${result}" | jq -c '. + {"_detected_by":"heuristic","_cached_at":"'"$(date -Iseconds)"'"}')
_write_project_cache "${dir}" "${enriched}"
echo "${result}"
return 0
fi
if result=$(_detect_with_llm "${dir}"); then
local enriched
enriched=$(echo "${result}" | jq -c '. + {"_detected_by":"llm","_cached_at":"'"$(date -Iseconds)"'"}')
_write_project_cache "${dir}" "${enriched}"
echo "${result}"
return 0
fi
echo '{"type":"unknown","build":"","test":"","check":""}'
}
###########################
## FILE SEARCH UTILITIES ##
###########################
_search_files() {
local pattern="$1"
local dir="${2:-.}"
find "${dir}" -type f -name "${pattern}" \
-not -path '*/target/*' \
-not -path '*/node_modules/*' \
-not -path '*/.git/*' \
-not -path '*/dist/*' \
-not -path '*/__pycache__/*' \
2>/dev/null | head -25
}
get_tree() {
local dir="${1:-.}"
local depth="${2:-3}"
if command -v tree &>/dev/null; then
tree -L "${depth}" --noreport -I 'node_modules|target|dist|.git|__pycache__|*.pyc' "${dir}" 2>/dev/null || find "${dir}" -maxdepth "${depth}" -type f | head -50
else
find "${dir}" -maxdepth "${depth}" -type f \
-not -path '*/target/*' \
-not -path '*/node_modules/*' \
-not -path '*/.git/*' \
2>/dev/null | head -50
fi
}
+36
View File
@@ -0,0 +1,36 @@
# Code Reviewer
A CodeRabbit-style code review orchestrator that coordinates per-file reviews and synthesizes findings into a unified
report.
This agent acts as the manager for the review process, delegating actual file analysis to **[File Reviewer](../file-reviewer/README.md)**
agents while handling coordination and final reporting.
## Features
- 🤖 **Orchestration**: Spawns parallel reviewers for each changed file.
- 🔄 **Cross-File Context**: Broadcasts sibling rosters so reviewers can alert each other about cross-cutting changes.
- 📊 **Unified Reporting**: Synthesizes findings into a structured, easy-to-read summary with severity levels.
-**Parallel Execution**: Runs reviews concurrently for maximum speed.
## Pro-Tip: Use an IDE MCP Server for Improved Performance
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
them), and modify the agent definition to look like this:
```yaml
# ...
mcp_servers:
- jetbrains # The name of your configured IDE MCP server
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
# - execute_command.sh
# ...
```
+127
View File
@@ -0,0 +1,127 @@
name: code-reviewer
description: CodeRabbit-style code reviewer - spawns per-file reviewers, synthesizes findings
version: 1.0.0
temperature: 0.1
auto_continue: true
max_auto_continues: 20
inject_todo_instructions: true
can_spawn_agents: true
max_concurrent_agents: 10
max_agent_depth: 2
variables:
- name: project_dir
description: Project directory to review
default: '.'
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- execute_command.sh
instructions: |
You are a code review orchestrator, similar to CodeRabbit. You coordinate per-file reviews and produce a unified report.
## Workflow
1. **Get the diff:** Run `get_diff` to get the git diff (defaults to staged changes, falls back to unstaged)
2. **Parse changed files:** Extract the list of files from the diff
3. **Create todos:** One todo per phase (get diff, spawn reviewers, collect results, synthesize report)
4. **Spawn file-reviewers:** One `file-reviewer` agent per changed file, in parallel
5. **Broadcast sibling roster:** Send each file-reviewer a message with all sibling IDs and their file assignments
6. **Collect all results:** Wait for each file-reviewer to complete
7. **Synthesize:** Combine all findings into a CodeRabbit-style report
## Spawning File Reviewers
For each changed file, spawn a file-reviewer with a prompt containing:
- The file path
- The relevant diff hunk(s) for that file
- Instructions to review it
```
agent__spawn --agent file-reviewer --prompt "Review the following diff for <file_path>:
<diff content for this file>
Focus on bugs, security issues, logic errors, and style. Use the severity format (🔴🟡🟢💡).
End with REVIEW_COMPLETE."
```
## Sibling Roster Broadcast
After spawning ALL file-reviewers (collecting their IDs), send each one a message with the roster:
```
agent__send_message --to <agent_id> --message "SIBLING_ROSTER:
- <agent_id_1>: reviewing <file_1>
- <agent_id_2>: reviewing <file_2>
...
Send cross-cutting alerts to relevant siblings if your changes affect their files."
```
## Diff Parsing
Split the diff by file. Each file's diff starts with `diff --git a/<path> b/<path>`. Extract:
- The file path (from the `+++ b/<path>` line)
- All hunks for that file (from `@@` markers to the next `diff --git` or end)
Skip binary files and files with only whitespace changes.
## Final Report Format
After collecting all file-reviewer results, synthesize into:
```
# Code Review Summary
## Walkthrough
<2-3 sentence overview of what the changes do as a whole>
## Changes
| File | Changes | Findings |
|------|---------|----------|
| `path/to/file1.rs` | <brief description> | 🔴 1 🟡 2 🟢 1 |
| `path/to/file2.rs` | <brief description> | 🟢 2 💡 1 |
## Detailed Findings
### `path/to/file1.rs`
<paste file-reviewer's findings here, cleaned up>
### `path/to/file2.rs`
<paste file-reviewer's findings here, cleaned up>
## Cross-File Concerns
<any cross-cutting issues identified by the teammate pattern>
---
*Reviewed N files, found X critical, Y warnings, Z suggestions, W nitpicks*
```
## Edge Cases
- **Single file changed:** Still spawn one file-reviewer (for consistency), skip roster broadcast
- **Too many files (>10):** Group small files (< 20 lines changed) and review them together
- **No changes found:** Report "No changes to review" and exit
- **Binary files:** Skip with a note in the summary
## Rules
1. **Always use `get_diff` first:** Don't assume what changed
2. **Spawn in parallel:** All file-reviewers should be spawned before collecting any
3. **Don't review code yourself:** Delegate ALL review work to file-reviewers
4. **Preserve severity tags:** Don't downgrade or remove severity from file-reviewer findings
5. **Include ALL findings:** Don't summarize away specific issues
## Context
- Project: {{project_dir}}
- CWD: {{__cwd__}}
- Shell: {{__shell__}}
## Available Tools:
{{__tools__}}
+478
View File
@@ -0,0 +1,478 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
source "$LLM_ROOT_DIR/agents/.shared/utils.sh"
# @env LLM_OUTPUT=/dev/stdout
# @env LLM_AGENT_VAR_PROJECT_DIR=.
# @describe Code review orchestrator tools
_project_dir() {
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
}
# @cmd Get git diff for code review. Returns staged changes, or unstaged if nothing is staged, or HEAD~1 diff if working tree is clean.
# @option --base Optional base ref to diff against (e.g., "main", "HEAD~3", a commit SHA)
get_diff() {
local project_dir
project_dir=$(_project_dir)
# shellcheck disable=SC2154
local base="${argc_base:-}"
local diff_output=""
if [[ -n "${base}" ]]; then
diff_output=$(cd "${project_dir}" && git diff "${base}" 2>&1) || true
else
diff_output=$(cd "${project_dir}" && git diff --cached 2>&1) || true
if [[ -z "${diff_output}" ]]; then
diff_output=$(cd "${project_dir}" && git diff 2>&1) || true
fi
if [[ -z "${diff_output}" ]]; then
diff_output=$(cd "${project_dir}" && git diff HEAD~1 2>&1) || true
fi
fi
if [[ -z "${diff_output}" ]]; then
warn "No changes found to review" >> "$LLM_OUTPUT"
return 0
fi
local file_count
file_count=$(echo "${diff_output}" | grep -c '^diff --git' || true)
{
info "Diff contains changes to ${file_count} file(s)"
echo ""
echo "${diff_output}"
} >> "$LLM_OUTPUT"
}
# @cmd Get list of changed files with stats
# @option --base Optional base ref to diff against
get_changed_files() {
local project_dir
project_dir=$(_project_dir)
local base="${argc_base:-}"
local stat_output=""
if [[ -n "${base}" ]]; then
stat_output=$(cd "${project_dir}" && git diff --stat "${base}" 2>&1) || true
else
stat_output=$(cd "${project_dir}" && git diff --cached --stat 2>&1) || true
if [[ -z "${stat_output}" ]]; then
stat_output=$(cd "${project_dir}" && git diff --stat 2>&1) || true
fi
if [[ -z "${stat_output}" ]]; then
stat_output=$(cd "${project_dir}" && git diff --stat HEAD~1 2>&1) || true
fi
fi
if [[ -z "${stat_output}" ]]; then
warn "No changes found" >> "$LLM_OUTPUT"
return 0
fi
{
info "Changed files:"
echo ""
echo "${stat_output}"
} >> "$LLM_OUTPUT"
}
# @cmd Get project structure and type information
get_project_info() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
{
info "Project: ${project_dir}"
echo "Type: $(echo "${project_info}" | jq -r '.type')"
echo ""
get_tree "${project_dir}" 2
} >> "$LLM_OUTPUT"
}
# ARGC-BUILD {
# This block was generated by argc (https://github.com/sigoden/argc).
# Modifying it manually is not recommended
_argc_run() {
if [[ "${1:-}" == "___internal___" ]]; then
_argc_die "error: unsupported ___internal___ command"
fi
if [[ "${OS:-}" == "Windows_NT" ]] && [[ -n "${MSYSTEM:-}" ]]; then
set -o igncr
fi
argc__args=("$(basename "$0" .sh)" "$@")
argc__positionals=()
_argc_index=1
_argc_len="${#argc__args[@]}"
_argc_tools=()
_argc_parse
if [ -n "${argc__fn:-}" ]; then
$argc__fn "${argc__positionals[@]}"
fi
}
_argc_usage() {
cat <<-'EOF'
Code review orchestrator tools
USAGE: <COMMAND>
COMMANDS:
get_diff Get git diff for code review. Returns staged changes, or unstaged if nothing is staged, or HEAD~1 diff if working tree is clean. [aliases: get-diff]
get_changed_files Get list of changed files with stats [aliases: get-changed-files]
get_project_info Get project structure and type information [aliases: get-project-info]
ENVIRONMENTS:
LLM_OUTPUT [default: /dev/stdout]
LLM_AGENT_VAR_PROJECT_DIR [default: .]
EOF
exit
}
_argc_version() {
echo 0.0.0
exit
}
_argc_parse() {
local _argc_key _argc_action
local _argc_subcmds="get_diff, get-diff, get_changed_files, get-changed-files, get_project_info, get-project-info"
while [[ $_argc_index -lt $_argc_len ]]; do
_argc_item="${argc__args[_argc_index]}"
_argc_key="${_argc_item%%=*}"
case "$_argc_key" in
--help | -help | -h)
_argc_usage
;;
--version | -version | -V)
_argc_version
;;
--)
_argc_dash="${#argc__positionals[@]}"
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
_argc_index=$_argc_len
break
;;
get_diff | get-diff)
_argc_index=$((_argc_index + 1))
_argc_action=_argc_parse_get_diff
break
;;
get_changed_files | get-changed-files)
_argc_index=$((_argc_index + 1))
_argc_action=_argc_parse_get_changed_files
break
;;
get_project_info | get-project-info)
_argc_index=$((_argc_index + 1))
_argc_action=_argc_parse_get_project_info
break
;;
help)
local help_arg="${argc__args[$((_argc_index + 1))]:-}"
case "$help_arg" in
get_diff | get-diff)
_argc_usage_get_diff
;;
get_changed_files | get-changed-files)
_argc_usage_get_changed_files
;;
get_project_info | get-project-info)
_argc_usage_get_project_info
;;
"")
_argc_usage
;;
*)
_argc_die "error: invalid value \`$help_arg\` for \`<command>\`"$'\n'" [possible values: $_argc_subcmds]"
;;
esac
;;
*)
_argc_die "error: \`\` requires a subcommand but one was not provided"$'\n'" [subcommands: $_argc_subcmds]"
;;
esac
done
if [[ -n "${_argc_action:-}" ]]; then
$_argc_action
else
_argc_usage
fi
}
_argc_usage_get_diff() {
cat <<-'EOF'
Get git diff for code review. Returns staged changes, or unstaged if nothing is staged, or HEAD~1 diff if working tree is clean.
USAGE: get_diff [OPTIONS]
OPTIONS:
--base <BASE> Optional base ref to diff against (e.g., "main", "HEAD~3", a commit SHA)
-h, --help Print help
ENVIRONMENTS:
LLM_OUTPUT [default: /dev/stdout]
LLM_AGENT_VAR_PROJECT_DIR [default: .]
EOF
exit
}
_argc_parse_get_diff() {
local _argc_key _argc_action
local _argc_subcmds=""
while [[ $_argc_index -lt $_argc_len ]]; do
_argc_item="${argc__args[_argc_index]}"
_argc_key="${_argc_item%%=*}"
case "$_argc_key" in
--help | -help | -h)
_argc_usage_get_diff
;;
--)
_argc_dash="${#argc__positionals[@]}"
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
_argc_index=$_argc_len
break
;;
--base)
_argc_take_args "--base <BASE>" 1 1 "-" ""
_argc_index=$((_argc_index + _argc_take_args_len + 1))
if [[ -z "${argc_base:-}" ]]; then
argc_base="${_argc_take_args_values[0]:-}"
else
_argc_die "error: the argument \`--base\` cannot be used multiple times"
fi
;;
*)
if _argc_maybe_flag_option "-" "$_argc_item"; then
_argc_die "error: unexpected argument \`$_argc_key\` found"
fi
argc__positionals+=("$_argc_item")
_argc_index=$((_argc_index + 1))
;;
esac
done
if [[ -n "${_argc_action:-}" ]]; then
$_argc_action
else
argc__fn=get_diff
if [[ "${argc__positionals[0]:-}" == "help" ]] && [[ "${#argc__positionals[@]}" -eq 1 ]]; then
_argc_usage_get_diff
fi
if [[ -z "${LLM_OUTPUT:-}" ]]; then
export LLM_OUTPUT=/dev/stdout
fi
if [[ -z "${LLM_AGENT_VAR_PROJECT_DIR:-}" ]]; then
export LLM_AGENT_VAR_PROJECT_DIR=.
fi
fi
}
_argc_usage_get_changed_files() {
cat <<-'EOF'
Get list of changed files with stats
USAGE: get_changed_files [OPTIONS]
OPTIONS:
--base <BASE> Optional base ref to diff against
-h, --help Print help
ENVIRONMENTS:
LLM_OUTPUT [default: /dev/stdout]
LLM_AGENT_VAR_PROJECT_DIR [default: .]
EOF
exit
}
_argc_parse_get_changed_files() {
local _argc_key _argc_action
local _argc_subcmds=""
while [[ $_argc_index -lt $_argc_len ]]; do
_argc_item="${argc__args[_argc_index]}"
_argc_key="${_argc_item%%=*}"
case "$_argc_key" in
--help | -help | -h)
_argc_usage_get_changed_files
;;
--)
_argc_dash="${#argc__positionals[@]}"
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
_argc_index=$_argc_len
break
;;
--base)
_argc_take_args "--base <BASE>" 1 1 "-" ""
_argc_index=$((_argc_index + _argc_take_args_len + 1))
if [[ -z "${argc_base:-}" ]]; then
argc_base="${_argc_take_args_values[0]:-}"
else
_argc_die "error: the argument \`--base\` cannot be used multiple times"
fi
;;
*)
if _argc_maybe_flag_option "-" "$_argc_item"; then
_argc_die "error: unexpected argument \`$_argc_key\` found"
fi
argc__positionals+=("$_argc_item")
_argc_index=$((_argc_index + 1))
;;
esac
done
if [[ -n "${_argc_action:-}" ]]; then
$_argc_action
else
argc__fn=get_changed_files
if [[ "${argc__positionals[0]:-}" == "help" ]] && [[ "${#argc__positionals[@]}" -eq 1 ]]; then
_argc_usage_get_changed_files
fi
if [[ -z "${LLM_OUTPUT:-}" ]]; then
export LLM_OUTPUT=/dev/stdout
fi
if [[ -z "${LLM_AGENT_VAR_PROJECT_DIR:-}" ]]; then
export LLM_AGENT_VAR_PROJECT_DIR=.
fi
fi
}
_argc_usage_get_project_info() {
cat <<-'EOF'
Get project structure and type information
USAGE: get_project_info
ENVIRONMENTS:
LLM_OUTPUT [default: /dev/stdout]
LLM_AGENT_VAR_PROJECT_DIR [default: .]
EOF
exit
}
_argc_parse_get_project_info() {
local _argc_key _argc_action
local _argc_subcmds=""
while [[ $_argc_index -lt $_argc_len ]]; do
_argc_item="${argc__args[_argc_index]}"
_argc_key="${_argc_item%%=*}"
case "$_argc_key" in
--help | -help | -h)
_argc_usage_get_project_info
;;
--)
_argc_dash="${#argc__positionals[@]}"
argc__positionals+=("${argc__args[@]:$((_argc_index + 1))}")
_argc_index=$_argc_len
break
;;
*)
argc__positionals+=("$_argc_item")
_argc_index=$((_argc_index + 1))
;;
esac
done
if [[ -n "${_argc_action:-}" ]]; then
$_argc_action
else
argc__fn=get_project_info
if [[ "${argc__positionals[0]:-}" == "help" ]] && [[ "${#argc__positionals[@]}" -eq 1 ]]; then
_argc_usage_get_project_info
fi
if [[ -z "${LLM_OUTPUT:-}" ]]; then
export LLM_OUTPUT=/dev/stdout
fi
if [[ -z "${LLM_AGENT_VAR_PROJECT_DIR:-}" ]]; then
export LLM_AGENT_VAR_PROJECT_DIR=.
fi
fi
}
_argc_take_args() {
_argc_take_args_values=()
_argc_take_args_len=0
local param="$1" min="$2" max="$3" signs="$4" delimiter="$5"
if [[ "$min" -eq 0 ]] && [[ "$max" -eq 0 ]]; then
return
fi
local _argc_take_index=$((_argc_index + 1)) _argc_take_value
if [[ "$_argc_item" == *=* ]]; then
_argc_take_args_values=("${_argc_item##*=}")
else
while [[ $_argc_take_index -lt $_argc_len ]]; do
_argc_take_value="${argc__args[_argc_take_index]}"
if _argc_maybe_flag_option "$signs" "$_argc_take_value"; then
if [[ "${#_argc_take_value}" -gt 1 ]]; then
break
fi
fi
_argc_take_args_values+=("$_argc_take_value")
_argc_take_args_len=$((_argc_take_args_len + 1))
if [[ "$_argc_take_args_len" -ge "$max" ]]; then
break
fi
_argc_take_index=$((_argc_take_index + 1))
done
fi
if [[ "${#_argc_take_args_values[@]}" -lt "$min" ]]; then
_argc_die "error: incorrect number of values for \`$param\`"
fi
if [[ -n "$delimiter" ]] && [[ "${#_argc_take_args_values[@]}" -gt 0 ]]; then
local item values arr=()
for item in "${_argc_take_args_values[@]}"; do
IFS="$delimiter" read -r -a values <<<"$item"
arr+=("${values[@]}")
done
_argc_take_args_values=("${arr[@]}")
fi
}
_argc_maybe_flag_option() {
local signs="$1" arg="$2"
if [[ -z "$signs" ]]; then
return 1
fi
local cond=false
if [[ "$signs" == *"+"* ]]; then
if [[ "$arg" =~ ^\+[^+].* ]]; then
cond=true
fi
elif [[ "$arg" == -* ]]; then
if (( ${#arg} < 3 )) || [[ ! "$arg" =~ ^---.* ]]; then
cond=true
fi
fi
if [[ "$cond" == "false" ]]; then
return 1
fi
local value="${arg%%=*}"
if [[ "$value" =~ [[:space:]] ]]; then
return 1
fi
return 0
}
_argc_die() {
if [[ $# -eq 0 ]]; then
cat
else
echo "$*" >&2
fi
exit 1
}
_argc_run "$@"
# ARGC-BUILD }
+40
View File
@@ -0,0 +1,40 @@
# Coder
An AI agent that assists you with your coding tasks.
This agent is designed to be delegated to by the **[Sisyphus](../sisyphus/README.md)** agent to implement code specifications. Sisyphus
acts as the coordinator/architect, while Coder handles the implementation details.
## Features
- 🏗️ Intelligent project structure creation and management
- 🖼️ Convert screenshots into clean, functional code
- 📁 Comprehensive file system operations (create folders, files, read/write files)
- 🧐 Advanced code analysis and improvement suggestions
- 📊 Precise diff-based file editing for controlled code modifications
It can also be used as a standalone tool for direct coding assistance.
## Pro-Tip: Use an IDE MCP Server for Improved Performance
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
them), and modify the agent definition to look like this:
```yaml
# ...
mcp_servers:
- jetbrains # The name of your configured IDE MCP server
global_tools:
# Keep useful read-only tools for reading files in other non-project directories
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
# - fs_write.sh
# - fs_patch.sh
- execute_command.sh
# ...
```
+129
View File
@@ -0,0 +1,129 @@
name: coder
description: Implementation agent - writes code, follows patterns, verifies with builds
version: 1.0.0
temperature: 0.1
auto_continue: true
max_auto_continues: 15
inject_todo_instructions: true
variables:
- name: project_dir
description: Project directory to work in
default: '.'
- name: auto_confirm
description: Auto-confirm command execution
default: '1'
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_write.sh
- fs_patch.sh
- execute_command.sh
instructions: |
You are a senior engineer. You write code that works on the first try.
## Your Mission
Given an implementation task:
1. Check for orchestrator context first (see below)
2. Fill gaps only. Read files NOT already covered in context
3. Write the code (using tools, NOT chat output)
4. Verify it compiles/builds
5. Signal completion with a summary
## Using Orchestrator Context (IMPORTANT)
When spawned by sisyphus, your prompt will often contain a `<context>` block
with prior findings: file paths, code patterns, and conventions discovered by
explore agents.
**If context is provided:**
1. Use it as your primary reference. Don't re-read files already summarized
2. Follow the code patterns shown. Snippets in context ARE the style guide
3. Read the referenced files ONLY IF you need more detail (e.g. full function
signature, import list, or adjacent code not included in the snippet)
4. If context includes a "Conventions" section, follow it exactly
**If context is NOT provided or is too vague to act on:**
Fall back to self-exploration: grep for similar files, read 1-2 examples,
match their style.
**Never ignore provided context.** It represents work already done upstream.
## Todo System
For multi-file changes:
1. `todo__init` with the implementation goal
2. `todo__add` for each file to create/modify
3. Implement each, calling `todo__done` immediately after
## Writing Code
**CRITICAL**: Write code using `write_file` tool, NEVER paste code in chat.
Correct:
```
write_file --path "src/user.rs" --content "pub struct User { ... }"
```
Wrong:
```
Here's the implementation:
\`\`\`rust
pub struct User { ... }
\`\`\`
```
## File Reading Strategy (IMPORTANT - minimize token usage)
1. **Use grep to find relevant code** - `fs_grep --pattern "fn handle_request" --include "*.rs"` finds where things are
2. **Read only what you need** - `fs_read --path "src/main.rs" --offset 50 --limit 30` reads lines 50-79
3. **Never cat entire large files** - If 500+ lines, read the relevant section after grepping for it
4. **Use glob to find files** - `fs_glob --pattern "*.rs" --path src/` discovers files by name
## Pattern Matching
Before writing ANY file:
1. Find a similar existing file (use `fs_grep` to locate, then `fs_read` to examine)
2. Match its style: imports, naming, structure
3. Follow the same patterns exactly
## Verification
After writing files:
1. Run `verify_build` to check compilation
2. If it fails, fix the error (minimal change)
3. Don't move on until build passes
## Completion Signal
When done, end your response with a summary so the parent agent knows what happened:
```
CODER_COMPLETE: [summary of what was implemented, which files were created/modified, and build status]
```
Or if something went wrong:
```
CODER_FAILED: [what went wrong]
```
## Rules
1. **Write code via tools** - Never output code to chat
2. **Follow patterns** - Read existing files first
3. **Verify builds** - Don't finish without checking
4. **Minimal fixes** - If build fails, fix precisely
5. **No refactoring** - Only implement what's asked
## Context
- Project: {{project_dir}}
- CWD: {{__cwd__}}
- Shell: {{__shell__}}
## Available tools:
{{__tools__}}
+216
View File
@@ -0,0 +1,216 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
source "$LLM_ROOT_DIR/agents/.shared/utils.sh"
# @env LLM_OUTPUT=/dev/stdout
# @env LLM_AGENT_VAR_PROJECT_DIR=.
# @describe Coder agent tools for implementing code changes
_project_dir() {
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
}
# Normalize a path to be relative to project root.
# Strips the project_dir prefix if the LLM passes an absolute path.
# Usage: local rel_path; rel_path=$(_normalize_path "/abs/or/rel/path")
_normalize_path() {
local input_path="$1"
local project_dir
project_dir=$(_project_dir)
if [[ "${input_path}" == /* ]]; then
input_path="${input_path#"${project_dir}"/}"
fi
input_path="${input_path#./}"
echo "${input_path}"
}
# @cmd Read a file's contents before modifying
# @option --path! Path to the file (relative to project root)
read_file() {
local file_path
# shellcheck disable=SC2154
file_path=$(_normalize_path "${argc_path}")
local project_dir
project_dir=$(_project_dir)
local full_path="${project_dir}/${file_path}"
if [[ ! -f "${full_path}" ]]; then
warn "File not found: ${file_path}" >> "$LLM_OUTPUT"
return 0
fi
{
info "Reading: ${file_path}"
echo ""
cat "${full_path}"
} >> "$LLM_OUTPUT"
}
# @cmd Write complete file contents
# @option --path! Path for the file (relative to project root)
# @option --content! Complete file contents to write
write_file() {
local file_path
file_path=$(_normalize_path "${argc_path}")
# shellcheck disable=SC2154
local content="${argc_content}"
local project_dir
project_dir=$(_project_dir)
local full_path="${project_dir}/${file_path}"
mkdir -p "$(dirname "${full_path}")"
printf '%s' "${content}" > "${full_path}"
green "Wrote: ${file_path}" >> "$LLM_OUTPUT"
}
# @cmd Find files similar to a given path (for pattern matching)
# @option --path! Path to find similar files for
find_similar_files() {
local file_path
file_path=$(_normalize_path "${argc_path}")
local project_dir
project_dir=$(_project_dir)
local ext="${file_path##*.}"
local dir
dir=$(dirname "${file_path}")
info "Similar files to: ${file_path}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local results
results=$(find "${project_dir}/${dir}" -maxdepth 1 -type f -name "*.${ext}" \
! -name "$(basename "${file_path}")" \
! -name "*test*" \
! -name "*spec*" \
2>/dev/null | sed "s|^${project_dir}/||" | head -3)
if [[ -z "${results}" ]]; then
results=$(find "${project_dir}/src" -type f -name "*.${ext}" \
! -name "*test*" \
! -name "*spec*" \
-not -path '*/target/*' \
2>/dev/null | sed "s|^${project_dir}/||" | head -3)
fi
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
warn "No similar files found" >> "$LLM_OUTPUT"
fi
}
# @cmd Verify the project builds successfully
verify_build() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
local build_cmd
build_cmd=$(echo "${project_info}" | jq -r '.check // .build')
if [[ -z "${build_cmd}" ]] || [[ "${build_cmd}" == "null" ]]; then
warn "No build command detected" >> "$LLM_OUTPUT"
return 0
fi
info "Running: ${build_cmd}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local output exit_code=0
output=$(cd "${project_dir}" && eval "${build_cmd}" 2>&1) || exit_code=$?
echo "${output}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
if [[ ${exit_code} -eq 0 ]]; then
green "BUILD SUCCESS" >> "$LLM_OUTPUT"
return 0
else
error "BUILD FAILED (exit code: ${exit_code})" >> "$LLM_OUTPUT"
return 1
fi
}
# @cmd Run project tests
run_tests() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
local test_cmd
test_cmd=$(echo "${project_info}" | jq -r '.test')
if [[ -z "${test_cmd}" ]] || [[ "${test_cmd}" == "null" ]]; then
warn "No test command detected" >> "$LLM_OUTPUT"
return 0
fi
info "Running: ${test_cmd}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local output exit_code=0
output=$(cd "${project_dir}" && eval "${test_cmd}" 2>&1) || exit_code=$?
echo "${output}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
if [[ ${exit_code} -eq 0 ]]; then
green "TESTS PASSED" >> "$LLM_OUTPUT"
return 0
else
error "TESTS FAILED (exit code: ${exit_code})" >> "$LLM_OUTPUT"
return 1
fi
}
# @cmd Get project structure for context
get_project_structure() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
{
info "Project: $(echo "${project_info}" | jq -r '.type')"
echo ""
get_tree "${project_dir}" 2
} >> "$LLM_OUTPUT"
}
# @cmd Search for content in the codebase
# @option --pattern! Pattern to search for
search_code() {
# shellcheck disable=SC2154
local pattern="${argc_pattern}"
local project_dir
project_dir=$(_project_dir)
info "Searching: ${pattern}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local results
results=$(grep -rn "${pattern}" "${project_dir}" 2>/dev/null | \
grep -v '/target/' | \
grep -v '/node_modules/' | \
grep -v '/.git/' | \
sed "s|^${project_dir}/||" | \
head -20) || true
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
warn "No matches" >> "$LLM_OUTPUT"
fi
}
+7
View File
@@ -0,0 +1,7 @@
# Demo
This agent serves as a demo to guide agent development and showcase various agent capabilities.
To enable tools, Loki will look for the first `tools.py` or `tools.sh` file it finds in this directory.
The base configuration using `tools.py`. To switch to using `tools.sh`, rename or remove `tools.py`.
+36
View File
@@ -0,0 +1,36 @@
name: Demo
description: An AI agent that demonstrates agent capabilities
version: 0.1.0
global_tools:
- execute_command.sh
instructions: |
You are a AI agent designed to demonstrate agent capabilities.
<tools>
{{__tools__}}
</tools>
<system>
os: {{__os__}}
os_family: {{__os_family__}}
arch: {{__arch__}}
shell: {{__shell__}}
locale: {{__locale__}}
now: {{__now__}}
cwd: {{__cwd__}}
</system>
<user>
username: {{username}}
</user>
variables:
- name: username
description: Your user name
conversation_starters:
- What is my username?
- What is my current shell?
- What is my ip?
- How much disk space is left on my PC??
- How to create an agent?
documents:
- README.md
+9
View File
@@ -0,0 +1,9 @@
import urllib.request
def get_ipinfo():
"""
Get the ip info
"""
with urllib.request.urlopen("https://httpbin.org/ip") as response:
data = response.read()
return data.decode('utf-8')
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
# @env LLM_OUTPUT=/dev/stdout The output path
# @cmd Get the ip info
get_ipinfo() {
curl -fsSL https://httpbin.org/ip >> "$LLM_OUTPUT"
}
+37
View File
@@ -0,0 +1,37 @@
# Explore
An AI agent specialized in exploring codebases, finding patterns, and understanding project structures.
This agent is designed to be delegated to by the **[Sisyphus](../sisyphus/README.md)** agent to gather information and context. Sisyphus
acts as the coordinator/architect, while Explore handles the research and discovery phase.
It can also be used as a standalone tool for understanding codebases and finding specific information.
## Features
- 🔍 Deep codebase exploration and pattern matching
- 📂 File system navigation and content analysis
- 🧠 Context gathering for complex tasks
- 🛡️ Read-only operations for safe investigation
## Pro-Tip: Use an IDE MCP Server for Improved Performance
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
them), and modify the agent definition to look like this:
```yaml
# ...
mcp_servers:
- jetbrains # The name of your configured IDE MCP server
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_ls.sh
- web_search_loki.sh
# ...
```
+78
View File
@@ -0,0 +1,78 @@
name: explore
description: Fast codebase exploration agent - finds patterns, structures, and relevant files
version: 1.0.0
temperature: 0.1
variables:
- name: project_dir
description: Project directory to explore
default: '.'
mcp_servers:
- ddg-search
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_ls.sh
instructions: |
You are a codebase explorer. Your job: Search, find, report. Nothing else.
## Your Mission
Given a search task, you:
1. Search for relevant files and patterns
2. Read key files to understand structure
3. Report findings concisely
4. Signal completion with EXPLORE_COMPLETE
## File Reading Strategy (IMPORTANT - minimize token usage)
1. **Find first, read second** - Never read a file without knowing why
2. **Use grep to locate** - `fs_grep --pattern "struct User" --include "*.rs"` finds exactly where things are
3. **Use glob to discover** - `fs_glob --pattern "*.rs" --path src/` finds files by name
4. **Read targeted sections** - `fs_read --path "src/main.rs" --offset 50 --limit 30` reads only lines 50-79
5. **Never read entire large files** - If a file is 500+ lines, read the relevant section only
## Available Actions
- `fs_grep --pattern "struct User" --include "*.rs"` - Find content across files
- `fs_glob --pattern "*.rs" --path src/` - Find files by name pattern
- `fs_read --path "src/main.rs"` - Read a file (with line numbers)
- `fs_read --path "src/main.rs" --offset 100 --limit 50` - Read lines 100-149 only
- `get_structure` - See project layout
- `search_content --pattern "struct User"` - Agent-level content search
## Output Format
Always end your response with a findings summary:
```
FINDINGS:
- [Key finding 1]
- [Key finding 2]
- Relevant files: [list]
EXPLORE_COMPLETE
```
## Rules
1. **Be fast** - Don't read every file, read representative ones
2. **Be focused** - Answer the specific question asked
3. **Be concise** - Report findings, not your process
4. **Never modify files** - You are read-only
5. **Limit reads** - Max 5 file reads per exploration
## Context
- Project: {{project_dir}}
- CWD: {{__cwd__}}
## Available Tools:
{{__tools__}}
conversation_starters:
- 'Find how authentication is implemented'
- 'What patterns are used for API endpoints'
- 'Show me the project structure'
+175
View File
@@ -0,0 +1,175 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
source "$LLM_ROOT_DIR/agents/.shared/utils.sh"
# @env LLM_OUTPUT=/dev/stdout
# @env LLM_AGENT_VAR_PROJECT_DIR=.
# @describe Explore agent tools for codebase search and analysis
_project_dir() {
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
}
# Normalize a path to be relative to project root.
# Strips the project_dir prefix if the LLM passes an absolute path.
_normalize_path() {
local input_path="$1"
local project_dir
project_dir=$(_project_dir)
if [[ "${input_path}" == /* ]]; then
input_path="${input_path#"${project_dir}"/}"
fi
input_path="${input_path#./}"
echo "${input_path}"
}
# @cmd Get project structure and layout
get_structure() {
local project_dir
project_dir=$(_project_dir)
info "Project structure:" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local project_info
project_info=$(detect_project "${project_dir}")
{
echo "Type: $(echo "${project_info}" | jq -r '.type')"
echo ""
get_tree "${project_dir}" 3
} >> "$LLM_OUTPUT"
}
# @cmd Search for files by name pattern
# @option --pattern! File name pattern (e.g., "*.rs", "config*", "*test*")
search_files() {
# shellcheck disable=SC2154
local pattern="${argc_pattern}"
local project_dir
project_dir=$(_project_dir)
info "Files matching: ${pattern}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local results
results=$(_search_files "${pattern}" "${project_dir}")
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
warn "No files found" >> "$LLM_OUTPUT"
fi
}
# @cmd Search for content in files
# @option --pattern! Text or regex pattern to search for
# @option --file-type Filter by file extension (e.g., "rs", "py", "ts")
search_content() {
local pattern="${argc_pattern}"
local file_type="${argc_file_type:-}"
local project_dir
project_dir=$(_project_dir)
info "Searching: ${pattern}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local include_arg=""
if [[ -n "${file_type}" ]]; then
include_arg="--include=*.${file_type}"
fi
local results
# shellcheck disable=SC2086
results=$(grep -rn ${include_arg} "${pattern}" "${project_dir}" 2>/dev/null | \
grep -v '/target/' | \
grep -v '/node_modules/' | \
grep -v '/.git/' | \
grep -v '/dist/' | \
sed "s|^${project_dir}/||" | \
head -30) || true
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
warn "No matches found" >> "$LLM_OUTPUT"
fi
}
# @cmd Read a file's contents
# @option --path! Path to the file (relative to project root)
# @option --lines Maximum lines to read (default: 200)
read_file() {
local file_path
# shellcheck disable=SC2154
file_path=$(_normalize_path "${argc_path}")
local max_lines="${argc_lines:-200}"
local project_dir
project_dir=$(_project_dir)
local full_path="${project_dir}/${file_path}"
if [[ ! -f "${full_path}" ]]; then
error "File not found: ${file_path}" >> "$LLM_OUTPUT"
return 1
fi
{
info "File: ${file_path}"
echo ""
} >> "$LLM_OUTPUT"
head -n "${max_lines}" "${full_path}" >> "$LLM_OUTPUT"
local total_lines
total_lines=$(wc -l < "${full_path}")
if [[ "${total_lines}" -gt "${max_lines}" ]]; then
echo "" >> "$LLM_OUTPUT"
warn "... truncated (${total_lines} total lines)" >> "$LLM_OUTPUT"
fi
}
# @cmd Find similar files to a given file (for pattern matching)
# @option --path! Path to the reference file
find_similar() {
local file_path
file_path=$(_normalize_path "${argc_path}")
local project_dir
project_dir=$(_project_dir)
local ext="${file_path##*.}"
local dir
dir=$(dirname "${file_path}")
info "Files similar to: ${file_path}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local results
results=$(find "${project_dir}/${dir}" -maxdepth 1 -type f -name "*.${ext}" \
! -name "$(basename "${file_path}")" \
! -name "*test*" \
! -name "*spec*" \
2>/dev/null | sed "s|^${project_dir}/||" | head -5)
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
results=$(find "${project_dir}" -type f -name "*.${ext}" \
! -name "$(basename "${file_path}")" \
! -name "*test*" \
-not -path '*/target/*' \
2>/dev/null | sed "s|^${project_dir}/||" | head -5)
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
warn "No similar files found" >> "$LLM_OUTPUT"
fi
fi
}
+35
View File
@@ -0,0 +1,35 @@
# File Reviewer
A specialized worker agent that reviews a single file's diff for bugs, style issues, and cross-cutting concerns.
This agent is designed to be spawned by the **[Code Reviewer](../code-reviewer/README.md)** agent. It focuses deeply on
one file while communicating with sibling agents to catch issues that span multiple files.
## Features
- 🔍 **Deep Analysis**: Focuses on bugs, logic errors, security issues, and style problems in a single file.
- 🗣️ **Teammate Communication**: Sends and receives alerts to/from sibling reviewers about interface or dependency
changes.
- 🎯 **Targeted Reading**: Reads only relevant context around changed lines to stay efficient.
- 🏷️ **Structured Findings**: Categorizes issues by severity (🔴 Critical, 🟡 Warning, 🟢 Suggestion, 💡 Nitpick).
## Pro-Tip: Use an IDE MCP Server for Improved Performance
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
them), and modify the agent definition to look like this:
```yaml
# ...
mcp_servers:
- jetbrains # The name of your configured IDE MCP server
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
# ...
```
+113
View File
@@ -0,0 +1,113 @@
name: file-reviewer
description: Reviews a single file's diff for bugs, style issues, and cross-cutting concerns
version: 1.0.0
temperature: 0.1
variables:
- name: project_dir
description: Project directory for context
default: '.'
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
instructions: |
You are a precise code reviewer. You review ONE file's diff and produce structured findings.
## Your Mission
You receive a git diff for a single file. Your job:
1. Analyze the diff for bugs, logic errors, security issues, and style problems
2. Read surrounding code for context (use `fs_read` with targeted offsets)
3. Check your inbox for cross-cutting alerts from sibling reviewers
4. Send alerts to siblings if you spot cross-file issues
5. Return structured findings
## Input
You receive:
- The file path being reviewed
- The git diff for that file
- A sibling roster (other file-reviewers and which files they're reviewing)
## Cross-Cutting Alerts (Teammate Pattern)
After analyzing your file, check if changes might affect sibling files:
- **Interface changes**: If a function signature changed, alert siblings reviewing callers
- **Type changes**: If a type/struct changed, alert siblings reviewing files that use it
- **Import changes**: If exports changed, alert siblings reviewing importers
- **Config changes**: Alert all siblings if config format changed
To alert a sibling:
```
agent__send_message --to <sibling_agent_id> --message "ALERT: <description of cross-file concern>"
```
Check your inbox periodically for alerts from siblings:
```
agent__check_inbox
```
If you receive an alert, incorporate it into your findings under a "Cross-File Concerns" section.
## File Reading Strategy
1. **Read changed lines' context:** Use `fs_read --path "file" --offset <start> --limit 50` to see surrounding code
2. **Grep for usage:** `fs_grep --pattern "function_name" --include "*.rs"` to find callers
3. **Never read entire large files:** Target the changed regions only
4. **Max 5 file reads:** Be efficient
## Output Format
Structure your response EXACTLY as:
```
## File: <file_path>
### Summary
<1-2 sentence summary of the changes>
### Findings
#### <finding_title>
- **Severity**: 🔴 CRITICAL | 🟡 WARNING | 🟢 SUGGESTION | 💡 NITPICK
- **Lines**: <start_line>-<end_line>
- **Description**: <clear explanation of the issue>
- **Suggestion**: <how to fix it>
#### <next_finding_title>
...
### Cross-File Concerns
<any issues received from siblings or that you alerted siblings about>
<"None" if no cross-file concerns>
REVIEW_COMPLETE
```
## Severity Guide
| Severity | When to use |
|----------|------------|
| 🔴 CRITICAL | Bugs, security vulnerabilities, data loss risks, crashes |
| 🟡 WARNING | Logic errors, performance issues, missing error handling, race conditions |
| 🟢 SUGGESTION | Better patterns, improved readability, missing docs for public APIs |
| 💡 NITPICK | Style preferences, minor naming issues, formatting |
## Rules
1. **Be specific:** Reference exact line numbers and code
2. **Be actionable:** Every finding must have a suggestion
3. **Don't nitpick formatting:** If a formatter/linter exists (check for .rustfmt.toml, .prettierrc, etc.)
4. **Focus on the diff:** Don't review unchanged code unless it's directly affected
5. **Never modify files:** You are read-only
6. **Always end with REVIEW_COMPLETE**
## Context
- Project: {{project_dir}}
- CWD: {{__cwd__}}
## Available Tools:
{{__tools__}}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
source "$LLM_ROOT_DIR/agents/.shared/utils.sh"
# @env LLM_OUTPUT=/dev/stdout
# @env LLM_AGENT_VAR_PROJECT_DIR=.
# @describe File reviewer tools for single-file code review
_project_dir() {
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
}
# @cmd Get project structure to understand codebase layout
get_structure() {
local project_dir
project_dir=$(_project_dir)
info "Project structure:" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local project_info
project_info=$(detect_project "${project_dir}")
{
echo "Type: $(echo "${project_info}" | jq -r '.type')"
echo ""
get_tree "${project_dir}" 2
} >> "$LLM_OUTPUT"
}
+14
View File
@@ -0,0 +1,14 @@
# Jira AI Agent
## Overview
The Jira AI Agent is designed to assist with managing tasks within Jira projects, providing capabilities such as
creating, searching, updating, assigning, linking, and commenting on issues. Its primary purpose is to help software
engineers seamlessly integrate Jira into their workflows through an AI-driven interface.
## Configuration
This agent uses the official [Atlassian MCP Server](https://github.com/atlassian/atlassian-mcp-server). To use it,
ensure you have Node.js v18+ installed to run the local MCP proxy (`mcp-remote`).
The server uses OAuth 2.0 so it will automatically open your browser for you to sign in to your account. No manual
configuration is necessary!
+37
View File
@@ -0,0 +1,37 @@
name: Jira Agent
description: An AI agent that can assist with Jira tasks such as creating issues, searching for issues, and updating issues.
version: 0.1.0
agent_session: temp
mcp_servers:
- atlassian
instructions: |
You are a AI agent designed to assist with managing Jira tasks and helping software engineers utilize and integrate
Jira into their workflows. You can create, search, update, assign, link, and comment on issues in Jira.
## Create Issue (MANDATORY when creating a issue)
When a user prompts you to create a Jira issue:
1. Prompt the user for what Jira project they want the ticket created in
2. If the ticket type requires a parent issue:
a. Query Jira for potentially relevant parents
b. Prompt user for which parent to use, displaying the suggested list of parent issues
3. Create the issue with the following format:
```markdown
**Description:**
This section gives context and details about the issue.
**User Acceptance Criteria:**
# This section provides bullet points that function like a checklist of all the things that must be completed in
# order for the issue to be considered done.
* Example criteria one
* Example criteria two
```
4. Ask the user if the issue should be assigned to them
a. If yes, then assign the user to the newly created issue
Available tools:
{{__tools__}}
conversation_starters:
- What are the latest issues in my Jira project?
- Can you create a new Jira issue for me?
- What are my open Jira issues?
- Can you search for issues with the label "bug" in my Jira project?
+39
View File
@@ -0,0 +1,39 @@
# Oracle
An AI agent specialized in high-level architecture, complex debugging, and design decisions.
This agent is designed to be delegated to by the **[Sisyphus](../sisyphus/README.md)** agent when deep reasoning, architectural advice,
or complex problem-solving is required. Sisyphus acts as the coordinator, while Oracle provides the expert analysis and
recommendations.
It can also be used as a standalone tool for design reviews and solving difficult technical challenges.
## Features
- 🏛️ System architecture and design patterns
- 🐛 Complex debugging and root cause analysis
- ⚖️ Tradeoff analysis and technology selection
- 📝 Code review and best practices advice
- 🧠 Deep reasoning for ambiguous problems
## Pro-Tip: Use an IDE MCP Server for Improved Performance
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
them), and modify the agent definition to look like this:
```yaml
# ...
mcp_servers:
- jetbrains # The name of your configured IDE MCP server
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_ls.sh
- web_search_loki.sh
# ...
```
+85
View File
@@ -0,0 +1,85 @@
name: oracle
description: High-IQ advisor for architecture, debugging, and complex decisions
version: 1.0.0
temperature: 0.2
variables:
- name: project_dir
description: Project directory for context
default: '.'
mcp_servers:
- ddg-search
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_ls.sh
instructions: |
You are Oracle - a senior architect and debugger consulted for complex decisions.
## Your Role
You are READ-ONLY. You analyze, advise, and recommend. You do NOT implement.
## When You're Consulted
1. **Architecture Decisions**: Multi-system tradeoffs, design patterns, technology choices
2. **Complex Debugging**: After 2+ failed fix attempts, deep analysis needed
3. **Code Review**: Evaluating proposed designs or implementations
4. **Risk Assessment**: Security, performance, or reliability concerns
## File Reading Strategy (IMPORTANT - minimize token usage)
1. **Use grep to find relevant code** - `fs_grep --pattern "auth" --include "*.rs"` finds where things are
2. **Read only what you need** - `fs_read --path "src/main.rs" --offset 50 --limit 30` reads lines 50-79
3. **Never read entire large files** - If 500+ lines, grep first, then read the relevant section
4. **Use glob to discover files** - `fs_glob --pattern "*.rs" --path src/`
## Your Process
1. **Understand**: Use grep/glob to find relevant code, then read targeted sections
2. **Analyze**: Consider multiple angles and tradeoffs
3. **Recommend**: Provide clear, actionable advice
4. **Justify**: Explain your reasoning
## Output Format
Structure your response as:
```
## Analysis
[Your understanding of the situation]
## Recommendation
[Clear, specific advice]
## Reasoning
[Why this is the right approach]
## Risks/Considerations
[What to watch out for]
ORACLE_COMPLETE
```
## Rules
1. **Never modify files** - You advise, others implement
2. **Be thorough** - Read all relevant context before advising
3. **Be specific** - General advice isn't helpful
4. **Consider tradeoffs** - There are rarely perfect solutions
5. **Stay focused** - Answer the specific question asked
## Context
- Project: {{project_dir}}
- CWD: {{__cwd__}}
## Available Tools:
{{__tools__}}
conversation_starters:
- 'Review this architecture design'
- 'Help debug this complex issue'
- 'Evaluate these implementation options'
+150
View File
@@ -0,0 +1,150 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
source "$LLM_ROOT_DIR/agents/.shared/utils.sh"
# @env LLM_OUTPUT=/dev/stdout
# @env LLM_AGENT_VAR_PROJECT_DIR=.
# @describe Oracle agent tools for analysis and consultation (read-only)
_project_dir() {
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
}
# Normalize a path to be relative to project root.
# Strips the project_dir prefix if the LLM passes an absolute path.
_normalize_path() {
local input_path="$1"
local project_dir
project_dir=$(_project_dir)
if [[ "${input_path}" == /* ]]; then
input_path="${input_path#"${project_dir}"/}"
fi
input_path="${input_path#./}"
echo "${input_path}"
}
# @cmd Read a file for analysis
# @option --path! Path to the file (relative to project root)
read_file() {
local project_dir
project_dir=$(_project_dir)
local file_path
# shellcheck disable=SC2154
file_path=$(_normalize_path "${argc_path}")
local full_path="${project_dir}/${file_path}"
if [[ ! -f "${full_path}" ]]; then
error "File not found: ${file_path}" >> "$LLM_OUTPUT"
return 1
fi
{
info "Reading: ${file_path}"
echo ""
cat "${full_path}"
} >> "$LLM_OUTPUT"
}
# @cmd Get project structure and type
get_project_info() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
{
info "Project Analysis" >> "$LLM_OUTPUT"
cat <<-EOF
Type: $(echo "${project_info}" | jq -r '.type')
Build: $(echo "${project_info}" | jq -r '.build')
Test: $(echo "${project_info}" | jq -r '.test')
EOF
info "Structure:" >> "$LLM_OUTPUT"
get_tree "${project_dir}" 3
} >> "$LLM_OUTPUT"
}
# @cmd Search for patterns in the codebase
# @option --pattern! Pattern to search for
# @option --file-type Filter by extension (e.g., "rs", "py")
search_code() {
local file_type="${argc_file_type:-}"
local project_dir
project_dir=$(_project_dir)
# shellcheck disable=SC2154
info "Searching: ${argc_pattern}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local include_arg=""
if [[ -n "${file_type}" ]]; then
include_arg="--include=*.${file_type}"
fi
local results
# shellcheck disable=SC2086
results=$(grep -rn ${include_arg} "${argc_pattern}" "${project_dir}" 2>/dev/null | \
grep -v '/target/' | \
grep -v '/node_modules/' | \
grep -v '/.git/' | \
sed "s|^${project_dir}/||" | \
head -30) || true
if [[ -n "${results}" ]]; then
echo "${results}" >> "$LLM_OUTPUT"
else
warn "No matches found" >> "$LLM_OUTPUT"
fi
}
# @cmd Run a read-only command for analysis (e.g., git log, cargo tree)
# @option --command! Command to run
analyze_with_command() {
local project_dir
project_dir=$(_project_dir)
local dangerous_patterns="rm |>|>>|mv |cp |chmod |chown |sudo|curl.*\\||wget.*\\|"
# shellcheck disable=SC2154
if echo "${argc_command}" | grep -qE "${dangerous_patterns}"; then
error "Command appears to modify files or be dangerous. Oracle is read-only." >> "$LLM_OUTPUT"
return 1
fi
info "Running: ${argc_command}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local output
output=$(cd "${project_dir}" && eval "${argc_command}" 2>&1) || true
echo "${output}" >> "$LLM_OUTPUT"
}
# @cmd List directory contents
# @option --path Path to list (default: project root)
list_directory() {
local dir_path
dir_path=$(_normalize_path "${argc_path:-.}")
local project_dir
project_dir=$(_project_dir)
local full_path="${project_dir}/${dir_path}"
if [[ ! -d "${full_path}" ]]; then
error "Directory not found: ${dir_path}" >> "$LLM_OUTPUT"
return 1
fi
{
info "Contents of: ${dir_path}"
echo ""
ls -la "${full_path}"
} >> "$LLM_OUTPUT"
}
+41
View File
@@ -0,0 +1,41 @@
# Sisyphus
The main coordinator agent for the Loki coding ecosystem, providing a powerful CLI interface for code generation and
project management similar to OpenCode, ClaudeCode, Codex, or Gemini CLI.
_Inspired by the Sisyphus and Oracle agents of OpenCode._
Sisyphus acts as the primary entry point, capable of handling complex tasks by coordinating specialized sub-agents:
- **[Coder](../coder/README.md)**: For implementation and file modifications.
- **[Explore](../explore/README.md)**: For codebase understanding and research.
- **[Oracle](../oracle/README.md)**: For architecture and complex reasoning.
## Features
- 🤖 **Coordinator**: Manages multi-step workflows and delegates to specialized agents.
- 💻 **CLI Coding**: Provides a natural language interface for writing and editing code.
- 🔄 **Task Management**: Tracks progress and context across complex operations.
- 🛠️ **Tool Integration**: Seamlessly uses system tools for building, testing, and file manipulation.
## Pro-Tip: Use an IDE MCP Server for Improved Performance
Many modern IDEs now include MCP servers that let LLMs perform operations within the IDE itself and use IDE tools. Using
an IDE's MCP server dramatically improves the performance of coding agents. So if you have an IDE, try adding that MCP
server to your config (see the [MCP Server docs](../../../docs/function-calling/MCP-SERVERS.md) to see how to configure
them), and modify the agent definition to look like this:
```yaml
# ...
mcp_servers:
- jetbrains
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_ls.sh
- web_search_loki.sh
- execute_command.sh
# ...
```
+241
View File
@@ -0,0 +1,241 @@
name: sisyphus
description: OpenCode-style orchestrator - classifies intent, delegates to specialists, tracks progress with todos
version: 2.0.0
temperature: 0.1
agent_session: temp
auto_continue: true
max_auto_continues: 25
inject_todo_instructions: true
can_spawn_agents: true
max_concurrent_agents: 4
max_agent_depth: 3
inject_spawn_instructions: true
summarization_threshold: 8000
variables:
- name: project_dir
description: Project directory to work in
default: '.'
- name: auto_confirm
description: Auto-confirm command execution
default: '1'
mcp_servers:
- ddg-search
global_tools:
- fs_read.sh
- fs_grep.sh
- fs_glob.sh
- fs_ls.sh
- execute_command.sh
instructions: |
You are Sisyphus - an orchestrator that drives coding tasks to completion.
Your job: Classify -> Delegate -> Verify -> Complete
## Intent Classification (BEFORE every action)
| Type | Signal | Action |
|------|--------|--------|
| Trivial | Single file, known location, typo fix | Do it yourself with tools |
| Exploration | "Find X", "Where is Y", "List all Z" | Spawn `explore` agent |
| Implementation | "Add feature", "Fix bug", "Write code" | Spawn `coder` agent |
| Architecture/Design | See oracle triggers below | Spawn `oracle` agent |
| Ambiguous | Unclear scope, multiple interpretations | ASK the user via `user__ask` or `user__input` |
### Oracle Triggers (MUST spawn oracle when you see these)
Spawn `oracle` ANY time the user asks about:
- **"How should I..."** / **"What's the best way to..."** -- design/approach questions
- **"Why does X keep..."** / **"What's wrong with..."** -- complex debugging (not simple errors)
- **"Should I use X or Y?"** -- technology or pattern choices
- **"How should this be structured?"** -- architecture and organization
- **"Review this"** / **"What do you think of..."** -- code/design review
- **Tradeoff questions** -- performance vs readability, complexity vs flexibility
- **Multi-component questions** -- anything spanning 3+ files or modules
- **Vague/open-ended questions** -- "improve this", "make this better", "clean this up"
**CRITICAL**: Do NOT answer architecture/design questions yourself. You are a coordinator.
Even if you think you know the answer, oracle provides deeper, more thorough analysis.
The only exception is truly trivial questions about a single file you've already read.
### Agent Specializations
| Agent | Use For | Characteristics |
|-------|---------|-----------------|
| explore | Find patterns, understand code, search | Read-only, returns findings |
| coder | Write/edit files, implement features | Creates/modifies files, runs builds |
| oracle | Architecture decisions, complex debugging | Advisory, high-quality reasoning |
## Coder Delegation Format (MANDATORY)
When spawning the `coder` agent, your prompt MUST include these sections.
The coder has NOT seen the codebase. Your prompt IS its entire context.
### Template:
```
## Goal
[1-2 sentences: what to build/modify and where]
## Reference Files
[Files that explore found, with what each demonstrates]
- `path/to/file.ext` - what pattern this file shows
- `path/to/other.ext` - what convention this file shows
## Code Patterns to Follow
[Paste ACTUAL code snippets from explore results, not descriptions]
<code>
// From path/to/file.ext - this is the pattern to follow:
[actual code explore found, 5-20 lines]
</code>
## Conventions
[Naming, imports, error handling, file organization]
- Convention 1
- Convention 2
## Constraints
[What NOT to do, scope boundaries]
- Do NOT modify X
- Only touch files in Y/
```
**CRITICAL**: Include actual code snippets, not just file paths.
If explore returned code patterns, paste them into the coder prompt.
Vague prompts like "follow existing patterns" waste coder's tokens on
re-exploration that you already did.
## Workflow Examples
### Example 1: Implementation task (explore -> coder, parallel exploration)
User: "Add a new API endpoint for user profiles"
```
1. todo__init --goal "Add user profiles API endpoint"
2. todo__add --task "Explore existing API patterns"
3. todo__add --task "Implement profile endpoint"
4. todo__add --task "Verify with build/test"
5. agent__spawn --agent explore --prompt "Find existing API endpoint patterns, route structures, and controller conventions. Include code snippets."
6. agent__spawn --agent explore --prompt "Find existing data models and database query patterns. Include code snippets."
7. agent__collect --id <id1>
8. agent__collect --id <id2>
9. todo__done --id 1
10. agent__spawn --agent coder --prompt "<structured prompt using Coder Delegation Format above, including code snippets from explore results>"
11. agent__collect --id <coder_id>
12. todo__done --id 2
13. run_build
14. run_tests
15. todo__done --id 3
```
### Example 2: Architecture/design question (explore + oracle in parallel)
User: "How should I structure the authentication for this app?"
```
1. todo__init --goal "Get architecture advice for authentication"
2. todo__add --task "Explore current auth-related code"
3. todo__add --task "Consult oracle for architecture recommendation"
4. agent__spawn --agent explore --prompt "Find any existing auth code, middleware, user models, and session handling"
5. agent__spawn --agent oracle --prompt "Recommend authentication architecture for this project. Consider: JWT vs sessions, middleware patterns, security best practices."
6. agent__collect --id <explore_id>
7. todo__done --id 1
8. agent__collect --id <oracle_id>
9. todo__done --id 2
```
### Example 3: Vague/open-ended question (oracle directly)
User: "What do you think of this codebase structure?"
```
agent__spawn --agent oracle --prompt "Review the project structure and provide recommendations for improvement"
agent__collect --id <oracle_id>
```
## Rules
1. **Always classify before acting** - Don't jump into implementation
2. **Create todos for multi-step tasks** - Track your progress
3. **Spawn agents for specialized work** - You're a coordinator, not an implementer
4. **Spawn in parallel when possible** - Independent tasks should run concurrently
5. **Verify after collecting agent results** - Don't trust blindly
6. **Mark todos done immediately** - Don't batch completions
7. **Ask when ambiguous** - Use `user__ask` or `user__input` to clarify with the user interactively
8. **Get buy-in for design decisions** - Use `user__ask` to present options before implementing major changes
9. **Confirm destructive actions** - Use `user__confirm` before large refactors or deletions
10. **Delegate to the coder agent to write code** - IMPORTANT: Use the `coder` agent to write code. Do not try to write code yourself except for trivial changes
11. **Always output a summary of changes when finished** - Make it clear to user's that you've completed your tasks
## When to Do It Yourself
- Simple command execution
- Trivial changes (typos, renames)
- Quick file searches
## When to NEVER Do It Yourself
- Architecture or design questions -> ALWAYS oracle
- "How should I..." / "What's the best way to..." -> ALWAYS oracle
- Debugging after 2+ failed attempts -> ALWAYS oracle
- Code review or design review requests -> ALWAYS oracle
- Open-ended improvement questions -> ALWAYS oracle
## User Interaction (CRITICAL - get buy-in before major decisions)
You have built-in tools to prompt the user for input. Use them to get user buy-in before making design decisions, and
to clarify ambiguities interactively. **Do NOT guess when you can ask.**
### When to Prompt the User
| Situation | Tool | Example |
|-----------|------|---------|
| Multiple valid design approaches | `user__ask` | "How should we structure this?" with options |
| Confirming a destructive or major action | `user__confirm` | "This will refactor 12 files. Proceed?" |
| User should pick which features/items to include | `user__checkbox` | "Which endpoints should we add?" |
| Need specific input (names, paths, values) | `user__input` | "What should the new module be called?" |
| Ambiguous request with different effort levels | `user__ask` | Present interpretation options |
### Design Review Pattern
For implementation tasks with design decisions, follow this pattern:
1. **Explore** the codebase to understand existing patterns
2. **Formulate** 2-3 design options based on findings
3. **Present options** to the user via `user__ask` with your recommendation marked `(Recommended)`
4. **Confirm** the chosen approach before delegating to `coder`
5. Proceed with implementation
### Rules for User Prompts
1. **Always include (Recommended)** on the option you think is best in `user__ask`
2. **Respect user choices** - never override or ignore a selection
3. **Don't over-prompt** - trivial decisions (variable names in small functions, formatting) don't need prompts
4. **DO prompt for**: architecture choices, file/module naming, which of multiple valid approaches to take, destructive operations, anything you're genuinely unsure about
5. **Confirm before large changes** - if a task will touch 5+ files, confirm the plan first
## Escalation Handling
If you see `pending_escalations` in your tool results, a child agent needs user input and is blocked.
Reply promptly via `agent__reply_escalation` to unblock it. You can answer from context or prompt the user
yourself first, then relay the answer.
## Available Tools
{{__tools__}}
## Context
- Project: {{project_dir}}
- OS: {{__os__}}
- Shell: {{__shell__}}
- CWD: {{__cwd__}}
conversation_starters:
- 'Add a new feature to the project'
- 'Fix a bug in the codebase'
- 'Refactor the authentication module'
- 'Help me understand how X works'
+97
View File
@@ -0,0 +1,97 @@
#!/usr/bin/env bash
set -eo pipefail
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
source "$LLM_ROOT_DIR/agents/.shared/utils.sh"
export AUTO_CONFIRM=true
# @env LLM_OUTPUT=/dev/stdout
# @env LLM_AGENT_VAR_PROJECT_DIR=.
# @describe Sisyphus orchestrator tools (project info, build, test)
_project_dir() {
local dir="${LLM_AGENT_VAR_PROJECT_DIR:-.}"
(cd "${dir}" 2>/dev/null && pwd) || echo "${dir}"
}
# @cmd Get project information and structure
get_project_info() {
local project_dir
project_dir=$(_project_dir)
info "Project: ${project_dir}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local project_info
project_info=$(detect_project "${project_dir}")
cat <<-EOF >> "$LLM_OUTPUT"
Type: $(echo "${project_info}" | jq -r '.type')
Build: $(echo "${project_info}" | jq -r '.build')
Test: $(echo "${project_info}" | jq -r '.test')
$(info "Directory structure:")
$(get_tree "${project_dir}" 2)
EOF
}
# @cmd Run build command for the project
run_build() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
local build_cmd
build_cmd=$(echo "${project_info}" | jq -r '.build')
if [[ -z "${build_cmd}" ]] || [[ "${build_cmd}" == "null" ]]; then
warn "No build command detected for this project" >> "$LLM_OUTPUT"
return 0
fi
info "Running: ${build_cmd}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local output
if output=$(cd "${project_dir}" && eval "${build_cmd}" 2>&1); then
green "BUILD SUCCESS" >> "$LLM_OUTPUT"
echo "${output}" >> "$LLM_OUTPUT"
return 0
else
error "BUILD FAILED" >> "$LLM_OUTPUT"
echo "${output}" >> "$LLM_OUTPUT"
return 1
fi
}
# @cmd Run tests for the project
run_tests() {
local project_dir
project_dir=$(_project_dir)
local project_info
project_info=$(detect_project "${project_dir}")
local test_cmd
test_cmd=$(echo "${project_info}" | jq -r '.test')
if [[ -z "${test_cmd}" ]] || [[ "${test_cmd}" == "null" ]]; then
warn "No test command detected for this project" >> "$LLM_OUTPUT"
return 0
fi
info "Running: ${test_cmd}" >> "$LLM_OUTPUT"
echo "" >> "$LLM_OUTPUT"
local output
if output=$(cd "${project_dir}" && eval "${test_cmd}" 2>&1); then
green "TESTS PASSED" >> "$LLM_OUTPUT"
echo "${output}" >> "$LLM_OUTPUT"
return 0
else
error "TESTS FAILED" >> "$LLM_OUTPUT"
echo "${output}" >> "$LLM_OUTPUT"
return 1
fi
}
+5
View File
@@ -0,0 +1,5 @@
# SQL
An AI agent that helps you manage a SQL database.
> The tool script uses [usql](https://github.com/xo/usql) to interact with SQL, it supports all mainstream databases.
+17
View File
@@ -0,0 +1,17 @@
name: Sql
description: An AI agent that helps you manage any SQL database
version: 0.1.0
instructions: |
You are an AI agent that manages a SQL database.
Prefix all referenced tables with the name of the schema that they are in.
For all sqlite databases, prefix each table name with 'main' as the schema
Available tools:
{{__tools__}}
variables:
- name: dsn
description: The database connection url. e.g. pgsql://user:pass@host:port
conversation_starters:
- What you can do?
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -e
# @meta require-tools usql
# @env LLM_OUTPUT=/dev/stdout The output path
# @env LLM_AGENT_VAR_DSN! The database connection url. e.g. pgsql://user:pass@host:port
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
# @cmd Execute a SELECT query
# @option --query! SELECT SQL query to execute
read_query() {
# shellcheck disable=SC2154
if ! grep -qi '^select' <<<"$argc_query"; then
error "only SELECT queries are allowed" >&2
exit 1
fi
_run_sql "$argc_query"
}
# @cmd Execute an SQL query
# @option --query! SQL query to execute
write_query() {
guard_operation "Execute SQL?"
_run_sql "$argc_query"
}
# @cmd List all tables
list_tables() {
_run_sql "\dt+"
}
# @cmd Get the schema information for a specific table
# @option --table-name! Name of the table to describe
describe_table() {
# shellcheck disable=SC2154
_run_sql "\d $argc_table_name"
}
_run_sql() {
usql "$LLM_AGENT_VAR_DSN" -c "$1" >> "$LLM_OUTPUT"
}
+1106
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "YOUR_GITHUB_TOKEN"
}
},
"atlassian": {
"command": "npx",
"args": ["-y", "mcp-remote@0.1.13", "https://mcp.atlassian.com/v1/mcp"]
},
"docker": {
"command": "uvx",
"args": ["mcp-server-docker"]
},
"ddg-search": {
"command": "uvx",
"args": ["duckduckgo-mcp-server"]
}
}
}
+154
View File
@@ -0,0 +1,154 @@
#!/usr/bin/env python
# Usage: ./{agent_name}.py <agent-func> <agent-data>
import os
import re
import json
import sys
import importlib.util
from pathlib import Path
def _ensure_cwd_venv():
cwd = Path.cwd()
venv_dir = cwd / ".venv"
if not venv_dir.is_dir():
return
py = venv_dir / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
if not py.exists():
return
if Path(sys.prefix).resolve() == venv_dir.resolve():
return
os.execv(str(py), [str(py)] + sys.argv)
_ensure_cwd_venv()
def main():
(agent_func, raw_data) = parse_argv()
agent_data = parse_raw_data(raw_data)
root_dir = "{config_dir}"
setup_env(root_dir, agent_func)
agent_tools_path = os.path.join(root_dir, "agents/{agent_name}/tools.py")
run(agent_tools_path, agent_func, agent_data)
def parse_raw_data(data):
if not data:
raise ValueError("No JSON data")
try:
return json.loads(data)
except Exception:
raise ValueError("Invalid JSON data")
def parse_argv():
agent_func = sys.argv[1]
agent_data = sys.argv[2]
if (not agent_data) or (not agent_func):
print("Usage: ./{agent_name}.py <agent-func> <agent-data>", file=sys.stderr)
sys.exit(1)
return agent_func, agent_data
def setup_env(root_dir, agent_func):
load_env(os.path.join(root_dir, ".env"))
os.environ["LLM_ROOT_DIR"] = root_dir
os.environ["LLM_AGENT_NAME"] = "{agent_name}"
os.environ["LLM_AGENT_FUNC"] = agent_func
os.environ["LLM_AGENT_ROOT_DIR"] = os.path.join(root_dir, "agents", "{agent_name}")
os.environ["LLM_AGENT_CACHE_DIR"] = os.path.join(root_dir, "cache", "{agent_name}")
def load_env(file_path):
try:
with open(file_path, "r") as f:
lines = f.readlines()
except:
return
env_vars = {}
for line in lines:
line = line.strip()
if line.startswith("#") or not line:
continue
key, *value_parts = line.split("=")
env_name = key.strip()
if env_name not in os.environ:
env_value = "=".join(value_parts).strip()
if (env_value.startswith('"') and env_value.endswith('"')) or (env_value.startswith("'") and env_value.endswith("'")):
env_value = env_value[1:-1]
env_vars[env_name] = env_value
os.environ.update(env_vars)
def run(agent_path, agent_func, agent_data):
spec = importlib.util.spec_from_file_location(
os.path.basename(agent_path), agent_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
if not hasattr(mod, agent_func):
raise Exception(f"Not module function '{agent_func}' at '{agent_path}'")
value = getattr(mod, agent_func)(**agent_data)
return_to_llm(value)
dump_result('{agent_name}' + f':{agent_func}')
def return_to_llm(value):
if value is None:
return
if "LLM_OUTPUT" in os.environ:
writer = open(os.environ["LLM_OUTPUT"], "w")
else:
writer = sys.stdout
value_type = type(value).__name__
if value_type in ("str", "int", "float", "bool"):
writer.write(str(value))
elif value_type == "dict" or value_type == "list":
value_str = json.dumps(value, indent=2)
assert value == json.loads(value_str)
writer.write(value_str)
def dump_result(name):
if (not os.getenv("LLM_DUMP_RESULTS")) or (not os.getenv("LLM_OUTPUT")) or (not os.isatty(1)):
return
show_result = False
try:
if re.search(rf'\b({os.environ["LLM_DUMP_RESULTS"]})\b', name):
show_result = True
except:
pass
if not show_result:
return
try:
with open(os.environ["LLM_OUTPUT"], "r", encoding="utf-8") as f:
data = f.read()
except:
return
print(f"\x1b[2m----------------------\n{data}\n----------------------\x1b[0m")
if __name__ == "__main__":
main()
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env bash
# Usage: ./{agent_name}.sh <agent-func> <agent-data>
set -e
main() {
root_dir="{config_dir}"
parse_argv "$@"
setup_env
tools_path="$root_dir/agents/{agent_name}/tools.sh"
run
}
parse_argv() {
agent_func="$1"
agent_data="$2"
if [[ -z "$agent_data" ]] || [[ -z "$agent_func" ]]; then
die "usage: ./{agent_name}.sh <agent-func> <agent-data>"
fi
}
setup_env() {
load_env "$root_dir/.env"
export LLM_ROOT_DIR="$root_dir"
export LLM_AGENT_NAME="{agent_name}"
export LLM_AGENT_FUNC="$agent_func"
export LLM_AGENT_ROOT_DIR="$LLM_ROOT_DIR/agents/{agent_name}"
export LLM_AGENT_CACHE_DIR="$LLM_ROOT_DIR/cache/{agent_name}"
export LLM_PROMPT_UTILS_FILE="{prompt_utils_file}"
}
load_env() {
local env_file="$1" env_vars
if [[ -f "$env_file" ]]; then
while IFS='=' read -r key value; do
if [[ "$key" == $'#'* ]] || [[ -z "$key" ]]; then
continue
fi
if [[ -z "${!key+x}" ]]; then
env_vars="$env_vars $key=$value"
fi
done < <(cat "$env_file"; echo "")
if [[ -n "$env_vars" ]]; then
eval "export $env_vars"
fi
fi
}
run() {
if [[ -z "$agent_data" ]]; then
die "error: no JSON data"
fi
if [[ "$OS" == "Windows_NT" ]]; then
set -o igncr
tools_path="$(cygpath -w "$tools_path")"
tool_data="$(echo "$tool_data" | sed 's/\\/\\\\/g')"
fi
jq_script="$(cat <<-'EOF'
def escape_shell_word:
tostring
| gsub("'"; "'\"'\"'")
| gsub("\n"; "'$'\\n''")
| "'\(.)'";
def to_args:
to_entries | .[] |
(.key | split("_") | join("-")) as $key |
if .value | type == "array" then
.value | .[] | "--\($key) \(. | escape_shell_word)"
elif .value | type == "boolean" then
if .value then "--\($key)" else "" end
else
"--\($key) \(.value | escape_shell_word)"
end;
[ to_args ] | join(" ")
EOF
)"
args="$(echo "$agent_data" | jq -r "$jq_script" 2>/dev/null)" || {
die "error: invalid JSON data"
}
if [[ -z "$LLM_OUTPUT" ]]; then
is_temp_llm_output=1
# shellcheck disable=SC2155
export LLM_OUTPUT="$(mktemp)"
fi
eval "'$tools_path' '$agent_func' $args"
if [[ "$is_temp_llm_output" -eq 1 ]]; then
cat "$LLM_OUTPUT"
else
dump_result "{agent_name}:${LLM_AGENT_FUNC}"
fi
}
dump_result() {
if [[ "$LLM_OUTPUT" == "/dev/stdout" ]] || [[ -z "$LLM_DUMP_RESULTS" ]] || [[ ! -t 1 ]]; then
return;
fi
if grep -q -w -E "$LLM_DUMP_RESULTS" <<<"$1"; then
cat <<EOF
$(echo -e "\e[2m")----------------------
$(cat "$LLM_OUTPUT")
----------------------$(echo -e "\e[0m")
EOF
fi
}
die() {
echo "$*" >&2
exit 1
}
main "$@"
+153
View File
@@ -0,0 +1,153 @@
#!/usr/bin/env python
# Usage: ./{function_name}.py <tool-data>
import os
import re
import json
import sys
import importlib.util
from pathlib import Path
def _ensure_cwd_venv():
cwd = Path.cwd()
venv_dir = cwd / ".venv"
if not venv_dir.is_dir():
return
py = venv_dir / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
if not py.exists():
return
if Path(sys.prefix).resolve() == venv_dir.resolve():
return
os.execv(str(py), [str(py)] + sys.argv)
_ensure_cwd_venv()
def main():
raw_data = parse_argv()
tool_data = parse_raw_data(raw_data)
root_dir = "{root_dir}"
setup_env(root_dir)
tool_path = "{tool_path}.py"
run(tool_path, "run", tool_data)
def parse_raw_data(data):
if not data:
raise ValueError("No JSON data")
try:
return json.loads(data)
except Exception:
raise ValueError("Invalid JSON data")
def parse_argv():
argv = sys.argv[:] + [None] * max(0, 2 - len(sys.argv))
tool_data = argv[1]
if (not tool_data):
print("Usage: ./{function_name}.py <tool-data>", file=sys.stderr)
sys.exit(1)
return tool_data
def setup_env(root_dir):
load_env(os.path.join(root_dir, ".env"))
os.environ["LLM_ROOT_DIR"] = root_dir
os.environ["LLM_TOOL_NAME"] = "{function_name}"
os.environ["LLM_TOOL_CACHE_DIR"] = os.path.join(root_dir, "cache", "{function_name}")
def load_env(file_path):
try:
with open(file_path, "r") as f:
lines = f.readlines()
except:
return
env_vars = {}
for line in lines:
line = line.strip()
if line.startswith("#") or not line:
continue
key, *value_parts = line.split("=")
env_name = key.strip()
if env_name not in os.environ:
env_value = "=".join(value_parts).strip()
if (env_value.startswith('"') and env_value.endswith('"')) or (env_value.startswith("'") and env_value.endswith("'")):
env_value = env_value[1:-1]
env_vars[env_name] = env_value
os.environ.update(env_vars)
def run(tool_path, tool_func, tool_data):
spec = importlib.util.spec_from_file_location(
os.path.basename(tool_path), tool_path
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
if not hasattr(mod, tool_func):
raise Exception(f"No module function '{tool_func}' at '{tool_path}'")
value = getattr(mod, tool_func)(**tool_data)
return_to_llm(value)
dump_result("{function_name}")
def return_to_llm(value):
if value is None:
return
if "LLM_OUTPUT" in os.environ:
writer = open(os.environ["LLM_OUTPUT"], "w")
else:
writer = sys.stdout
value_type = type(value).__name__
if value_type in ("str", "int", "float", "bool"):
writer.write(str(value))
elif value_type == "dict" or value_type == "list":
value_str = json.dumps(value, indent=2)
assert value == json.loads(value_str)
writer.write(value_str)
def dump_result(name):
if (not os.getenv("LLM_DUMP_RESULTS")) or (not os.getenv("LLM_OUTPUT")) or (not os.isatty(1)):
return
show_result = False
try:
if re.search(rf'\b({os.environ["LLM_DUMP_RESULTS"]})\b', name):
show_result = True
except:
pass
if not show_result:
return
try:
with open(os.environ["LLM_OUTPUT"], "r", encoding="utf-8") as f:
data = f.read()
except:
return
print(f"\x1b[2m----------------------\n{data}\n----------------------\x1b[0m")
if __name__ == "__main__":
main()
+117
View File
@@ -0,0 +1,117 @@
#!/usr/bin/env bash
# Usage: ./{function_name}.sh <tool-data>
set -e
main() {
root_dir="{root_dir}"
parse_argv "$@"
setup_env
tool_path="{tool_path}.sh"
run
}
parse_argv() {
tool_data="$1"
if [[ -z "$tool_data" ]]; then
die "usage: ./{function_name}.sh <tool-data>"
fi
}
setup_env() {
load_env "$root_dir/.env"
export LLM_ROOT_DIR="$root_dir"
export LLM_TOOL_NAME="{function_name}"
export LLM_TOOL_CACHE_DIR="$LLM_ROOT_DIR/cache/{function_name}"
export LLM_PROMPT_UTILS_FILE="{prompt_utils_file}"
}
load_env() {
local env_file="$1" env_vars
if [[ -f "$env_file" ]]; then
while IFS='=' read -r key value; do
if [[ "$key" == $'#'* ]] || [[ -z "$key" ]]; then
continue
fi
if [[ -z "${!key+x}" ]]; then
env_vars="$env_vars $key=$value"
fi
done < <(cat "$env_file"; echo "")
if [[ -n "$env_vars" ]]; then
eval "export $env_vars"
fi
fi
}
run() {
if [[ -z "$tool_data" ]]; then
die "error: no JSON data"
fi
if [[ "$OS" == "Windows_NT" ]]; then
set -o igncr
tool_path="$(cygpath -w "$tool_path")"
tool_data="$(echo "$tool_data" | sed 's/\\/\\\\/g')"
fi
jq_script="$(cat <<-'EOF'
def escape_shell_word:
tostring
| gsub("'"; "'\"'\"'")
| gsub("\n"; "'$'\\n''")
| "'\(.)'";
def to_args:
to_entries | .[] |
(.key | split("_") | join("-")) as $key |
if .value | type == "array" then
.value | .[] | "--\($key) \(. | escape_shell_word)"
elif .value | type == "boolean" then
if .value then "--\($key)" else "" end
else
"--\($key) \(.value | escape_shell_word)"
end;
[ to_args ] | join(" ")
EOF
)"
args="$(echo "$tool_data" | jq -r "$jq_script" 2>/dev/null)" || {
die "error: invalid JSON data"
}
if [[ -z "$LLM_OUTPUT" ]]; then
is_temp_llm_output=1
# shellcheck disable=SC2155
export LLM_OUTPUT="$(mktemp)"
fi
eval "'$tool_path' $args"
if [[ "$is_temp_llm_output" -eq 1 ]]; then
cat "$LLM_OUTPUT"
else
dump_result "{function_name}"
fi
}
dump_result() {
if [[ "$LLM_OUTPUT" == "/dev/stdout" ]] || [[ -z "$LLM_DUMP_RESULTS" ]] || [[ ! -t 1 ]]; then
return;
fi
if grep -q -w -E "$LLM_DUMP_RESULTS" <<<"$1"; then
cat <<EOF
$(echo -e "\e[2m")----------------------
$(cat "$LLM_OUTPUT")
----------------------$(echo -e "\e[0m")
EOF
fi
}
die() {
echo "$*" >&2
exit 1
}
main "$@"
+38
View File
@@ -0,0 +1,38 @@
import os
from typing import List, Literal, Optional
def run(
string: str,
string_enum: Literal["foo", "bar"],
boolean: bool,
integer: int,
number: float,
array: List[str],
string_optional: Optional[str] = None,
array_optional: Optional[List[str]] = None,
):
"""Demonstrates how to create a tool using Python and how to use comments.
Args:
string: Define a required string property
string_enum: Define a required string property with enum
boolean: Define a required boolean property
integer: Define a required integer property
number: Define a required number property
array: Define a required string array property
string_optional: Define an optional string property
array_optional: Define an optional string array property
"""
output = f"""string: {string}
string_enum: {string_enum}
string_optional: {string_optional}
boolean: {boolean}
integer: {integer}
number: {number}
array: {array}
array_optional: {array_optional}"""
for key, value in os.environ.items():
if key.startswith("LLM_"):
output = f"{output}\n{key}: {value}"
return output
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
# @describe Demonstrate how to create a tool using Bash and how to use comment tags.
# @option --string! Define a required string property
# @option --string-enum![foo|bar] Define a required string property with enum
# @option --string-optional Define a optional string property
# @flag --boolean Define a boolean property
# @option --integer! <INT> Define a required integer property
# @option --number! <NUM> Define a required number property
# @option --array+ <VALUE> Define a required string array property
# @option --array-optional* Define a optional string array property
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
cat <<EOF >> "$LLM_OUTPUT"
string: ${argc_string}
string_enum: ${argc_string_enum}
string_optional: ${argc_string_optional}
boolean: ${argc_boolean}
integer: ${argc_integer}
number: ${argc_number}
array: ${argc_array[@]}
array_optional: ${argc_array_optional[@]}
$(printenv | grep '^LLM_')
EOF
}
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
# @describe Execute the shell command.
# @option --command! The command to execute.
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
main() {
guard_operation
# shellcheck disable=SC2154
eval "$argc_command" >> "$LLM_OUTPUT"
}
+33
View File
@@ -0,0 +1,33 @@
import ast
import io
from contextlib import redirect_stdout
def run(code: str):
"""Execute the given Python code.
Args:
code: The Python code to execute, such as `print("hello world")`
"""
output = io.StringIO()
with redirect_stdout(output):
value = exec_with_return(code, {}, {})
if value is not None:
output.write(str(value))
return output.getvalue()
def exec_with_return(code: str, globals: dict, locals: dict):
a = ast.parse(code)
last_expression = None
if a.body:
if isinstance(a_last := a.body[-1], ast.Expr):
last_expression = ast.unparse(a.body.pop())
elif isinstance(a_last, ast.Assign):
last_expression = ast.unparse(a_last.targets[0])
elif isinstance(a_last, (ast.AnnAssign, ast.AugAssign)):
last_expression = ast.unparse(a_last.target)
exec(ast.unparse(a), globals, locals)
if last_expression:
return eval(last_expression, globals, locals)
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
# @describe Execute sql code.
# @option --code! The code to execute.
# @meta require-tools usql
# @env USQL_DSN! The database connection url. e.g. pgsql://user:pass@host:port
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
# shellcheck disable=SC2154
main() {
if ! grep -qi '^select' <<<"$argc_code"; then
guard_operation ""
fi
usql -c "$argc_code" "$USQL_DSN" >> "$LLM_OUTPUT"
}
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
# @describe Extract the content from a given URL.
# @option --url! The URL to scrape.
# @meta require-tools pandoc
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
# span and div tags are dropped from the HTML https://pandoc.org/MANUAL.html#raw-htmltex and sed removes any inline SVG images in image tags from the Markdown content.
curl -fsSL "$argc_url" | \
pandoc -f html-native_divs-native_spans -t gfm-raw_html --wrap=none | \
sed -E 's/!\[[^]]*\]\([^)]*\)//g' \
>> "$LLM_OUTPUT"
}
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e
# @describe Extract the content from a given URL.
# @option --url! The URL to scrape.
# @env JINA_API_KEY Your Jina API key
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
curl_args=()
if [[ -n "$JINA_API_KEY" ]]; then
curl_args+=("-H" "Authorization: Bearer $JINA_API_KEY")
fi
curl -fsSL "${curl_args[@]}" "https://r.jina.ai/$argc_url" >> "$LLM_OUTPUT"
}
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
# @describe Read the contents of a file at the specified path.
# Use this when you need to examine the contents of an existing file.
# @option --path! The path of the file to read
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
# shellcheck disable=SC2154
cat "$argc_path" >> "$LLM_OUTPUT" 2>&1 || echo "No such file or path: $argc_path" >> "$LLM_OUTPUT"
}
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -e
# @describe Find files by glob pattern. Returns matching file paths sorted by modification time.
# Use this to discover files before reading them.
# @option --pattern! The glob pattern to match files against (e.g. "**/*.rs", "src/**/*.ts", "*.yaml")
# @option --path The directory to search in (defaults to current working directory)
# @env LLM_OUTPUT=/dev/stdout The output path
MAX_RESULTS=100
main() {
# shellcheck disable=SC2154
local glob_pattern="$argc_pattern"
local search_path="${argc_path:-.}"
if [[ ! -d "$search_path" ]]; then
echo "Error: directory not found: $search_path" >> "$LLM_OUTPUT"
return 1
fi
local results
if command -v fd &>/dev/null; then
results=$(fd --type f --glob "$glob_pattern" "$search_path" \
--exclude '.git' \
--exclude 'node_modules' \
--exclude 'target' \
--exclude 'dist' \
--exclude '__pycache__' \
--exclude 'vendor' \
--exclude '.build' \
2>/dev/null | head -n "$MAX_RESULTS") || true
else
results=$(find "$search_path" -type f -name "$glob_pattern" \
-not -path '*/.git/*' \
-not -path '*/node_modules/*' \
-not -path '*/target/*' \
-not -path '*/dist/*' \
-not -path '*/__pycache__/*' \
-not -path '*/vendor/*' \
-not -path '*/.build/*' \
2>/dev/null | head -n "$MAX_RESULTS") || true
fi
if [[ -z "$results" ]]; then
echo "No files found matching: $glob_pattern" >> "$LLM_OUTPUT"
return 0
fi
echo "$results" >> "$LLM_OUTPUT"
local count
count=$(echo "$results" | wc -l)
if [[ "$count" -ge "$MAX_RESULTS" ]]; then
printf "\n(Results limited to %s files. Use a more specific pattern.)\n" "$MAX_RESULTS" >> "$LLM_OUTPUT"
fi
}
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env bash
set -e
# @describe Search file contents using regular expressions. Returns matching file paths and lines.
# Use this to find relevant code before reading files. Much faster than reading files to search.
# @option --pattern! The regex pattern to search for in file contents
# @option --path The directory to search in (defaults to current working directory)
# @option --include File pattern to filter by (e.g. "*.rs", "*.{ts,tsx}", "*.py")
# @env LLM_OUTPUT=/dev/stdout The output path
MAX_RESULTS=50
MAX_LINE_LENGTH=2000
main() {
# shellcheck disable=SC2154
local search_pattern="$argc_pattern"
local search_path="${argc_path:-.}"
local include_filter="${argc_include:-}"
if [[ ! -d "$search_path" ]]; then
echo "Error: directory not found: $search_path" >> "$LLM_OUTPUT"
return 1
fi
local grep_args=(-rn --color=never)
grep_args+=(
--exclude-dir='.git'
--exclude-dir='node_modules'
--exclude-dir='target'
--exclude-dir='dist'
--exclude-dir='build'
--exclude-dir='__pycache__'
--exclude-dir='vendor'
--exclude-dir='.build'
--exclude-dir='.next'
--exclude='*.min.js'
--exclude='*.min.css'
--exclude='*.map'
--exclude='*.lock'
--exclude='package-lock.json'
)
if [[ -n "$include_filter" ]]; then
grep_args+=("--include=$include_filter")
fi
local results
results=$(grep "${grep_args[@]}" -E "$search_pattern" "$search_path" 2>/dev/null | head -n "$MAX_RESULTS") || true
if [[ -z "$results" ]]; then
echo "No matches found for: $search_pattern" >> "$LLM_OUTPUT"
return 0
fi
echo "$results" | while IFS= read -r line; do
if [[ ${#line} -gt $MAX_LINE_LENGTH ]]; then
line="${line:0:$MAX_LINE_LENGTH}... (truncated)"
fi
echo "$line"
done >> "$LLM_OUTPUT"
local count
count=$(echo "$results" | wc -l)
if [[ "$count" -ge "$MAX_RESULTS" ]]; then
printf "\n(Results limited to %s matches. Narrow your search with --include or a more specific pattern.)\n" "$MAX_RESULTS" >> "$LLM_OUTPUT"
fi
}
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -e
# @describe List all files and directories at the specified path.
# @option --path! The path of the directory to list
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
# shellcheck disable=SC2154
ls -1 "$argc_path" >> "$LLM_OUTPUT" 2>&1 || echo "No such path: $argc_path" >> "$LLM_OUTPUT"
}
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -e
# @describe Create a new directory at the specified path.
# @option --path! The path of the directory to create
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
# shellcheck disable=SC2154
mkdir -p "$argc_path"
echo "Directory created: $argc_path" >> "$LLM_OUTPUT"
}
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
# @describe Apply a patch to a file at the specified path.
# This can be used to edit a file without having to rewrite the whole file.
# @option --path! The path of the file to apply the patch to
# @option --contents! The patch to apply to the file
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
# shellcheck disable=SC2154
main() {
if [[ ! -f "$argc_path" ]]; then
error "Unable to find the specified file: $argc_path"
exit 1
fi
new_contents="$(patch_file "$argc_path" <(printf "%s" "$argc_contents"))"
printf "%s" "$new_contents" | git diff --no-index "$argc_path" - || true
guard_operation "Apply changes?"
printf "%s" "$new_contents" > "$argc_path"
info "Applied the patch to: $argc_path" >> "$LLM_OUTPUT"
}
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -e
# @describe Read a file with line numbers, offset, and limit. For directories, lists entries.
# Prefer this over fs_cat for controlled reading. Use offset/limit to read specific sections.
# Use the grep tool to find specific content before reading, then read with offset to target the relevant section.
# @option --path! The absolute path to the file or directory to read
# @option --offset The line number to start reading from (1-indexed, default: 1)
# @option --limit The maximum number of lines to read (default: 2000)
# @env LLM_OUTPUT=/dev/stdout The output path
MAX_LINE_LENGTH=2000
MAX_BYTES=51200
main() {
# shellcheck disable=SC2154
local target="$argc_path"
local offset="${argc_offset:-1}"
local limit="${argc_limit:-2000}"
if [[ ! -e "$target" ]]; then
echo "Error: path not found: $target" >> "$LLM_OUTPUT"
return 1
fi
if [[ -d "$target" ]]; then
ls -1 "$target" >> "$LLM_OUTPUT" 2>&1
return 0
fi
local total_lines file_bytes
total_lines=$(wc -l < "$target" 2>/dev/null || echo 0)
file_bytes=$(wc -c < "$target" 2>/dev/null || echo 0)
if [[ "$file_bytes" -gt "$MAX_BYTES" ]] && [[ "$offset" -eq 1 ]] && [[ "$limit" -ge 2000 ]]; then
{
echo "Warning: Large file (${file_bytes} bytes, ${total_lines} lines). Showing first ${limit} lines."
echo "Use --offset and --limit to read specific sections, or use the grep tool to find relevant lines first."
echo ""
} >> "$LLM_OUTPUT"
fi
local end_line=$((offset + limit - 1))
sed -n "${offset},${end_line}p" "$target" 2>/dev/null | {
local line_num=$offset
while IFS= read -r line; do
if [[ ${#line} -gt $MAX_LINE_LENGTH ]]; then
line="${line:0:$MAX_LINE_LENGTH}... (truncated)"
fi
printf "%d: %s\n" "$line_num" "$line"
line_num=$((line_num + 1))
done
} >> "$LLM_OUTPUT"
if [[ "$end_line" -lt "$total_lines" ]]; then
echo "" >> "$LLM_OUTPUT"
echo "(${total_lines} total lines. Use --offset $((end_line + 1)) to read more.)" >> "$LLM_OUTPUT"
fi
}
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
# @describe Remove the file or directory at the specified path.
# @option --path! The path of the file or directory to remove
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
# shellcheck disable=SC2154
main() {
if [[ -f "$argc_path" ]]; then
guard_path "$argc_path" "Remove '$argc_path'?"
rm -rf "$argc_path"
fi
echo "Path removed: $argc_path" >> "$LLM_OUTPUT"
}
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e
# @describe Write the full file contents to a file at the specified path.
# @option --path! The path of the file to write to
# @option --contents! The full contents to write to the file
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC1090
source "$LLM_PROMPT_UTILS_FILE"
# shellcheck disable=SC2154
main() {
if [[ -f "$argc_path" ]]; then
printf "%s" "$argc_contents" | git diff --no-index "$argc_path" - || true
guard_operation "Apply changes?"
else
guard_path "$argc_path" "Write '$argc_path'?"
mkdir -p "$(dirname "$argc_path")"
fi
printf "%s" "$argc_contents" > "$argc_path"
echo "The File contents were written to: $argc_path" >> "$LLM_OUTPUT"
}
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -e
# @describe Get the current time.
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
date >> "$LLM_OUTPUT"
}
@@ -0,0 +1,35 @@
import os
from pathlib import Path
from typing import Optional
from urllib.parse import quote_plus
from urllib.request import urlopen
def run(
location: str,
llm_output: Optional[str] = None,
) -> str:
"""Get the current weather in a given location
Args:
location (str): The city and optionally the state or country (e.g., "London", "San Francisco, CA").
Returns:
str: A single-line formatted weather string from wttr.in (``format=4`` with metric units).
"""
url = f"https://wttr.in/{quote_plus(location)}?format=4&M"
with urlopen(url, timeout=10) as resp:
weather = resp.read().decode("utf-8", errors="replace")
dest = llm_output if llm_output is not None else os.environ.get("LLM_OUTPUT", "/dev/stdout")
if dest not in {"-", "/dev/stdout"}:
path = Path(dest)
path.parent.mkdir(parents=True, exist_ok=True)
with path.open("a", encoding="utf-8") as fh:
fh.write(weather)
else:
pass
return weather
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
# @describe Get the current weather in a given location.
# @option --location! The city and optionally the state or country, e.g., "London", "San Francisco, CA".
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
curl -fsSL "https://wttr.in/$(echo "$argc_location" | sed 's/ /+/g')?format=4&M" \
>> "$LLM_OUTPUT"
}
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -e
# @meta require-tools jira
# @describe Query for jira issues using a Jira Query Language (JQL) query
# @option --jql-query! The Jira Query Language query to execute
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
jira issue ls -q "$argc_jql_query" --plain >> "$LLM_OUTPUT"
}
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
# @describe Search arXiv using the given search query and return the top papers.
# @option --query! The search query.
# @env ARXIV_MAX_RESULTS=3 The max results to return.
# @env LLM_OUTPUT=/dev/stdout The output path
main() {
# shellcheck disable=SC2154
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
url="http://export.arxiv.org/api/query?search_query=all:$encoded_query&max_results=$ARXIV_MAX_RESULTS"
curl -fsSL "$url" >> "$LLM_OUTPUT"
}
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
# @describe Search Wikipedia using the given search query.
# Use it to get detailed information about a public figure, interpretation of a complex scientific concept or in-depth connectivity of a significant historical event, etc.
# @option --query! The search query.
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
base_url="https://en.wikipedia.org/w/api.php"
url="$base_url?action=query&list=search&srprop=&srlimit=1&limit=1&srsearch=$encoded_query&srinfo=suggestion&format=json"
json="$(curl -fsSL "$url")"
# suggestion="$(echo "$json" | jq -r '.query.searchinfo.suggestion // empty')"
title="$(echo "$json" | jq -r '.query.search[0].title // empty')"
pageid="$(echo "$json" | jq -r '.query.search[0].pageid // empty')"
if [[ -z "$title" || -z "$pageid" ]]; then
echo "error: no results for '$argc_query'" >&2
exit 1
fi
title="$(echo "$title" | tr ' ' '_')"
url="$base_url?action=query&prop=extracts&explaintext=&titles=$title&exintro=&format=json"
curl -fsSL "$url" | jq -r '.query.pages["'"$pageid"'"].extract' >> "$LLM_OUTPUT"
}
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
# @describe Get an answer to a question using Wolfram Alpha. The input query should be in English.
# Use it to answer user questions that require computation, detailed facts, data analysis, or complex queries.
# @option --query! The search/computation query to pass to Wolfram Alpha
# @env WOLFRAM_API_ID! Your Wolfram Alpha API ID
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
encoded_query="$(jq -nr --arg q "$argc_query" '$q|@uri')"
url="https://api.wolframalpha.com/v2/query?appid=${WOLFRAM_API_ID}&input=$encoded_query&output=json&format=plaintext"
curl -fsSL "$url" | jq '[.queryresult | .pods[] | {title:.title, values:[.subpods[].plaintext | select(. != "")]}]' \
>> "$LLM_OUTPUT"
}
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
# @describe Send an email.
# @option --recipient! The recipient of the email.
# @option --subject! The subject of the email.
# @option --body! The body of the email.
# @env EMAIL_SMTP_ADDR! The SMTP Address, e.g. smtps://smtp.gmail.com:465
# @env EMAIL_SMTP_USER! The SMTP User, e.g. alice@gmail.com
# @env EMAIL_SMTP_PASS! The SMTP Password
# @env EMAIL_SENDER_NAME The sender's name
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
sender_name="${EMAIL_SENDER_NAME:-$(echo "$EMAIL_SMTP_USER" | awk -F'@' '{print $1}')}"
printf "%s\n" "From: $sender_name <$EMAIL_SMTP_USER>
To: $argc_recipient
Subject: $argc_subject
$argc_body" | \
curl -fsS --ssl-reqd \
--url "$EMAIL_SMTP_ADDR" \
--user "$EMAIL_SMTP_USER:$EMAIL_SMTP_PASS" \
--mail-from "$EMAIL_SMTP_USER" \
--mail-rcpt "$argc_recipient" \
--upload-file -
echo "Email sent successfully" >> "$LLM_OUTPUT"
}
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
set -e
# @describe Send SMS or Twilio Messaging Channels messages using the Twilio API.
# @option --to-number! The recipient's phone number. Prefix it with 'whatsapp:' for WhatsApp messages, e.g. whatsapp:+1234567890
# @option --message! The content of the message to be sent
# @env TWILIO_ACCOUNT_SID! The twilio account sid
# @env TWILIO_AUTH_TOKEN! The twilio auth token
# @env TWILIO_FROM_NUMBER! The twilio from number
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
from_number="$TWILIO_FROM_NUMBER"
to_number="$argc_to_number"
if [[ "$to_number" == 'whatsapp:'* ]]; then
from_number="whatsapp:$from_number"
fi
if [[ "$to_number" != 'whatsapp:'* && "$to_number" != '+'* ]]; then
to_number="+$to_number"
fi
res="$(curl -s -X POST "https://api.twilio.com/2010-04-01/Accounts/$TWILIO_ACCOUNT_SID/Messages.json" \
-u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
-w "\n%{http_code}" \
--data-urlencode "From=$from_number" \
--data-urlencode "To=$to_number" \
--data-urlencode "Body=$argc_message")"
status="$(echo "$res" | tail -n 1)"
body="$(echo "$res" | head -n -1)"
if [[ "$status" -ge 200 && "$status" -lt 300 ]]; then
if [[ "$(echo "$body" | jq -r 'has("sid")')" == "true" ]]; then
echo "Message sent successfully" >> "$LLM_OUTPUT"
else
_die "error: $body"
fi
else
_die "error: $body"
fi
}
_die() {
echo "$*" >&2
exit 1
}
+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -e
# @describe Perform a web search to get up-to-date information or additional context.
# Use this when you need current information or feel a search could provide a better answer.
# @option --query! The search query.
# @meta require-tools loki
# @env WEB_SEARCH_MODEL=gemini:gemini-2.5-flash The model for web-searching.
#
# supported loki models:
# - gemini:gemini-2.0-*
# - vertexai:gemini-*
# - perplexity:*
# - ernie:*
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
client="${WEB_SEARCH_MODEL%%:*}"
if [[ "$client" == "gemini" ]]; then
export LOKI_PATCH_GEMINI_CHAT_COMPLETIONS='{".*":{"body":{"tools":[{"google_search":{}}]}}}'
elif [[ "$client" == "vertexai" ]]; then
export LOKI_PATCH_VERTEXAI_CHAT_COMPLETIONS='{
"gemini-1.5-.*":{"body":{"tools":[{"googleSearchRetrieval":{}}]}},
"gemini-2.0-.*":{"body":{"tools":[{"google_search":{}}]}}
}'
elif [[ "$client" == "ernie" ]]; then
export LOKI_PATCH_ERNIE_CHAT_COMPLETIONS='{".*":{"body":{"web_search":{"enable":true}}}}'
fi
loki -m "$WEB_SEARCH_MODEL" "$argc_query" >> "$LLM_OUTPUT"
}
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -e
# @describe Perform a web search using the Perplexity API to get up-to-date information or additional context.
# Use this when you need current information or feel a search could provide a better answer.
# @option --query! The search query.
# @env PERPLEXITY_API_KEY! Your Perplexity API key
# @env PERPLEXITY_WEB_SEARCH_MODEL=llama-3.1-sonar-small-128k-online The LLM model to use for the search
# @env LLM_OUTPUT=/dev/stdout The output path
# shellcheck disable=SC2154
main() {
curl -fsS -X POST https://api.perplexity.ai/chat/completions \
-H "authorization: Bearer $PERPLEXITY_API_KEY" \
-H "accept: application/json" \
-H "content-type: application/json" \
--data '
{
"model": "'"$PERPLEXITY_WEB_SEARCH_MODEL"'",
"messages": [
{
"role": "user",
"content": "'"$argc_query"'"
}
]
}
' | \
jq -r '.choices[0].message.content' \
>> "$LLM_OUTPUT"
}
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e
# @describe Perform a web search using the Tavily API to get up-to-date information or additional context.
# Use this when you need current information or feel a search could provide a better answer.
# @option --query! The search query.
# @env TAVILY_API_KEY! Your Tavile API key
# @env LLM_OUTPUT=/dev/stdout The output path The output path
# shellcheck disable=SC2154
main() {
curl -fsSL -X POST https://api.tavily.com/search \
-H "content-type: application/json" \
-d '
{
"api_key": "'"$TAVILY_API_KEY"'",
"query": "'"$argc_query"'",
"include_answer": true
}' | \
jq -r '.answer' >> "$LLM_OUTPUT"
}
+718
View File
@@ -0,0 +1,718 @@
#!/usr/bin/env bash
# Bash helper utilities for prompting users.
# This is a modified version of the excellent Bash TUI toolkit
# (https://github.com/timo-reymann/bash-tui-toolkit)
#
# It includes the following functions for you to use in your
# bash tool commands:
#
# - password Password prompt
# - checked Checkbox
# - text Text input with validation
# - list Select an option from a given list
# - range Prompt the user for a value within a range
# - confirm Confirmation prompt
# - editor Open the user's preferred editor for input
# - detect_os Detect the current OS
# - get_opener Get the file opener for the current OS
# - open_link Open the given link in the default browser
# See https://github.com/timo-reymann/bash-tui-toolkit/blob/main/test.sh
# for examples on how to use these commands
#
# - guard_operation Prompt for permission to run an operation
# - guard_path Prompt for permission to perform path operations
# - patch_file Patch a file
# - error Log an error
# - warn Log a warning
# - info Log info
# - debug Log a debug message
# - trace Log a trace message
# - red Output given text in red
# - green Output given text in green
# - gold Output given text in gold
# - blue Output given text in blue
# - magenta Output given text in magenta
# - cyan Output given text in cyan
# - white Output given text in white
# shellcheck disable=SC2034
red=$(tput setaf 1)
green=$(tput setaf 2)
gold=$(tput setaf 3)
blue=$(tput setaf 4)
magenta=$(tput setaf 5)
cyan=$(tput setaf 6)
white=$(tput setaf 7)
default=$(tput sgr0)
gray=$(tput setaf 243)
bold=$(tput bold)
underlined=$(tput smul)
error() {
echo -e "${red}${bold}ERROR:${default}${red} $1${default}"
}
warn() {
echo -e "${gold}${bold}WARN:${default}${gold} $1${default}"
}
info() {
echo -e "${cyan}${bold}INFO:${default}${cyan} $1${default}"
}
debug() {
echo -e "${blue}${bold}DEBUG:${default}${blue} $1${default}"
}
trace() {
echo -e "${gray}${bold}TRACE:${default}${gray} $1${default}"
}
success() {
echo -e "${green}${bold}SUCCESS:${default}${green} $1${default}"
}
red() {
echo -e "${red}$1${default}"
}
green() {
echo -e "${green}$1${default}"
}
gold() {
echo -e "${gold}$1${default}"
}
blue() {
echo -e "${blue}$1${default}"
}
magenta() {
echo -e "${magenta}$1${default}"
}
cyan() {
echo -e "${cyan}$1${default}"
}
white() {
echo -e "${white}$1${default}"
}
_read_stdin() {
read -r "$@" </dev/tty
}
_get_cursor_row() {
declare IFS=';'
_read_stdin -sdR -p $'\E[6n' ROW COL
echo "${ROW#*[}"
}
_cursor_blink_on() {
echo -en "\033[?25h" >&2
}
_cursor_blink_off() {
echo -en "\033[?25l" >&2
}
_cursor_to() {
echo -en "\033[$1;${2:-1}H" >&2
}
# shellcheck disable=SC2154
_key_input() {
declare ESC=$'\033'
declare IFS=''
_read_stdin -rsn1 a
if [[ "$ESC" == "$a" ]]; then
_read_stdin -rsn2 b
fi
declare input="${a}${b:-}"
case "$input" in
"${ESC}[A" | "k") echo up ;;
"${ESC}[B" | "j") echo down ;;
"${ESC}[C" | "l") echo right ;;
"${ESC}[D" | "h") echo left ;;
'') echo enter ;;
' ') echo space ;;
esac
}
_new_line_foreach_item() {
count=0
while [[ $count -lt $1 ]]; do
echo "" >&2
((count++))
done
}
_prompt_text() {
echo -en "\033[32m?\033[0m\033[1m ${1}\033[0m " >&2
}
_decrement_selected() {
declare selected=$1
((selected--))
if [[ "${selected}" -lt 0 ]]; then
selected=$(($2 - 1))
fi
echo -n $selected
}
_increment_selected() {
declare selected=$1
((selected++))
if [[ "${selected}" -ge "${opts_count}" ]]; then
selected=0
fi
echo -n $selected
}
# shellcheck disable=SC2154
input() {
_prompt_text "$1"
echo -en "\033[36m\c" >&2
_read_stdin -r text
echo -n "${text}"
}
confirm() {
trap "stty echo; exit" EXIT
_prompt_text "$1 (y/N)"
echo -en "\033[36m\c " >&2
declare first_row
first_row=$(_get_cursor_row)
declare current_row
current_row=$((first_row - 1))
declare result=""
echo -n " " >&2
while true; do
echo -e "\033[1D\c " >&2
_read_stdin -n1 result
case "$result" in
y | Y)
echo -n 1
break
;;
n | N | *)
echo -n 0
break
;;
esac
done
echo -en "\033[0m" >&2
echo "" >&2
}
list() {
_prompt_text "$1 "
declare opts=("${@:2}")
declare opts_count=$(($# - 1))
_new_line_foreach_item "${#opts[@]}"
declare last_row
last_row=$(_get_cursor_row)
declare first_row
first_row=$((last_row - opts_count + 1))
trap "_cursor_blink_on; stty echo; exit" 2
_cursor_blink_off
declare selected=0
while true; do
declare idx=0
for opt in "${opts[@]}"; do
_cursor_to $((first_row + idx))
if [[ $idx -eq "$selected" ]]; then
printf "\033[0m\033[36m\033[0m \033[36m%s\033[0m" "$opt" >&2
else
printf " %s" "$opt" >&2
fi
((idx++))
done
case $(_key_input) in
enter) break ;;
up) selected=$(_decrement_selected "${selected}" "${opts_count}") ;;
down) selected=$(_increment_selected "${selected}" "${opts_count}") ;;
esac
done
echo -en "\n" >&2
_cursor_to "${last_row}"
_cursor_blink_on
echo -n "${selected}"
}
checkbox() {
_prompt_text "$1"
declare opts
opts=("${@:2}")
declare opts_count
opts_count=$(($# - 1))
_new_line_foreach_item "${#opts[@]}"
declare last_row
last_row=$(_get_cursor_row)
declare first_row
first_row=$((last_row - opts_count + 1))
trap "_cursor_blink_on; stty echo; exit" 2
_cursor_blink_off
declare selected=0
declare checked=()
while true; do
declare idx=0
for opt in "${opts[@]}"; do
_cursor_to $((first_row + idx))
declare icon="◯"
for item in "${checked[@]}"; do
if [[ "$item" == "$idx" ]]; then
icon="◉"
break
fi
done
if [[ $idx -eq "$selected" ]]; then
printf "%s \e[0m\e[36m\e[0m \e[36m%-50s\e[0m" "$icon" "$opt" >&2
else
printf "%s %-50s" "$icon" "$opt" >&2
fi
((idx++))
done
case $(_key_input) in
enter) break ;;
space)
declare found=0
for item in "${checked[@]}"; do
if [[ "$item" == "$selected" ]]; then
found=1
break
fi
done
if [ $found -eq 1 ]; then
checked=("${checked[@]/$selected/}")
else
checked+=("${selected}")
fi
;;
up) selected=$(_decrement_selected "${selected}" "${opts_count}") ;;
down) selected=$(_increment_selected "${selected}" "${opts_count}") ;;
esac
done
_cursor_to "${last_row}"
_cursor_blink_on
IFS="" echo -n "${checked[@]}"
}
password() {
_prompt_text "$1"
echo -en "\033[36m" >&2
declare password=''
declare IFS=
while _read_stdin -r -s -n1 char; do
[[ -z "${char}" ]] && {
printf '\n' >&2
break
}
if [[ "${char}" == $'\x7f' ]]; then
if [[ "${#password}" -gt 0 ]]; then
password="${password%?}"
echo -en '\b \b' >&2
fi
else
password+=$char
echo -en '*' >&2
fi
done
echo -en "\e[0m" >&2
echo -n "${password}"
}
editor() {
tmpfile=$(mktemp)
_prompt_text "$1"
echo "" >&2
"${EDITOR:-vi}" "${tmpfile}" >/dev/tty
echo -en "\033[36m" >&2
sed -e 's/^/ /' "${tmpfile}" >&2
echo -en "\033[0m" >&2
cat "${tmpfile}"
}
with_validate() {
while true; do
declare val
val="$(eval "$1")"
if ($2 "$val" >/dev/null); then
echo "$val"
break
else
show_error "$($2 "$val")"
fi
done
}
range() {
declare min="$2"
declare current="$3"
declare max="$4"
declare selected="${current}"
declare max_len_current
max_len_current=0
if [[ "${#min}" -gt "${#max}" ]]; then
max_len_current="${#min}"
else
max_len_current="${#max}"
fi
declare padding
padding="$(printf "%-${max_len_current}s" "")"
declare first_row
first_row=$(_get_cursor_row)
declare current_row
current_row=$((first_row - 1))
trap "_cursor_blink_on; stty echo; exit" 2
_cursor_blink_off
_check_range() {
val=$1
if [[ "$val" -gt "$max" ]]; then
val=$min
elif [[ "$val" -lt "$min" ]]; then
val=$max
fi
echo "$val"
}
while true; do
_prompt_text "$1"
printf "\033[37m%s\033[0m \033[1;90m\033[0m \033[36m%s%s\033[0m \033[1;90m\033[0m \033[37m%s\033[0m\n" "$min" "${padding:${#selected}}" "$selected" "$max" >&2
case $(_key_input) in
enter)
break
;;
left)
selected="$(_check_range $((selected - 1)))"
;;
right)
selected="$(_check_range $((selected + 1)))"
;;
esac
_cursor_to "$current_row"
done
echo "$selected"
}
validate_present() {
if [ "$1" != "" ]; then
return 0
else
error "Please specify the value"
return 1
fi
}
show_error() {
echo -e "\033[91;1m✘ $1\033[0m" >&2
}
show_success() {
echo -e "\033[92;1m✔ $1\033[0m" >&2
}
detect_os() {
case "$OSTYPE" in
solaris*) echo "solaris" ;;
darwin*) echo "macos" ;;
linux*) echo "linux" ;;
bsd*) echo "bsd" ;;
msys*) echo "windows" ;;
cygwin*) echo "windows" ;;
*) echo "unknown" ;;
esac
}
get_opener() {
declare cmd
case "$(detect_os)" in
macos) cmd="open" ;;
linux) cmd="xdg-open" ;;
windows) cmd="start" ;;
*) cmd="" ;;
esac
echo "$cmd"
}
open_link() {
cmd="$(get_opener)"
if [[ "$cmd" == "" ]]; then
error "Your platform is not supported for opening links."
red "Please open the following URL in your preferred browser:"
red " ${1}"
return 1
fi
$cmd "$1"
if [[ $? -eq 1 ]]; then
error "Failed to open your browser."
red "Please open the following URL in your browser:"
red "${1}"
return 1
fi
return 0
}
guard_operation() {
if [[ -t 1 ]]; then
if [[ -z "$AUTO_CONFIRM" && -z "$LLM_AGENT_VAR_AUTO_CONFIRM" ]]; then
ans="$(confirm "${1:-Are you sure you want to continue?}")"
if [[ "$ans" == 0 ]]; then
error "Operation aborted!" 2>&1
exit 1
fi
fi
fi
}
# Here is an example of a patch block that can be applied to modify the file to request the user's name:
# --- a/hello.py
# +++ b/hello.py
# \@@ ... @@
# def hello():
# - print("Hello World")
# + name = input("What is your name? ")
# + print(f"Hello {name}")
patch_file() {
awk '
FNR == NR {
lines[FNR] = $0
next;
}
{
patchLines[FNR] = $0
}
END {
totalPatchLines=length(patchLines)
totalLines = length(lines)
patchLineIndex = 1
mode = "none"
while (patchLineIndex <= totalPatchLines) {
line = patchLines[patchLineIndex]
if (line ~ /^--- / || line ~ /^\+\+\+ /) {
patchLineIndex++
continue
}
if (line ~ /^@@ /) {
mode = "hunk"
hunkIndex++
patchLineIndex++
continue
}
if (mode == "hunk") {
while (patchLineIndex <= totalPatchLines && line ~ /^[-+ ]|^\s*$/ && line !~ /^--- /) {
sanitizedLine = substr(line, 2)
if (line !~ /^\+/) {
hunkTotalOriginalLines[hunkIndex]++;
hunkOriginalLines[hunkIndex,hunkTotalOriginalLines[hunkIndex]] = sanitizedLine
}
if (line !~ /^-/) {
hunkTotalUpdatedLines[hunkIndex]++;
hunkUpdatedLines[hunkIndex,hunkTotalUpdatedLines[hunkIndex]] = sanitizedLine
}
patchLineIndex++
line = patchLines[patchLineIndex]
}
mode = "none"
} else {
patchLineIndex++
}
}
if (hunkIndex == 0) {
print "error: no patch" > "/dev/stderr"
exit 1
}
totalHunks = hunkIndex
hunkIndex = 1
for (lineIndex = 1; lineIndex <= totalLines; lineIndex++) {
line = lines[lineIndex]
nextLineIndex = 0
if (hunkIndex <= totalHunks && line == hunkOriginalLines[hunkIndex,1]) {
nextLineIndex = lineIndex + 1
for (i = 2; i <= hunkTotalOriginalLines[hunkIndex]; i++) {
if (lines[nextLineIndex] != hunkOriginalLines[hunkIndex,i]) {
nextLineIndex = 0
break
}
nextLineIndex++
}
}
if (nextLineIndex > 0) {
for (i = 1; i <= hunkTotalUpdatedLines[hunkIndex]; i++) {
print hunkUpdatedLines[hunkIndex,i]
}
hunkIndex++
lineIndex = nextLineIndex - 1;
} else {
print line
}
}
if (hunkIndex != totalHunks + 1) {
print "error: unable to apply patch" > "/dev/stderr"
exit 1
}
}
function inspectHunks() {
print "/* Begin inspecting hunks"
for (i = 1; i <= totalHunks; i++) {
print ">>>>>> Original"
for (j = 1; j <= hunkTotalOriginalLines[i]; j++) {
print hunkOriginalLines[i,j]
}
print "======"
for (j = 1; j <= hunkTotalUpdatedLines[i]; j++) {
print hunkUpdatedLines[i,j]
}
print "<<<<<< Updated"
}
print "End inspecting hunks */\n"
}' "$1" "$2"
}
guard_path() {
if [[ "$#" -ne 2 ]]; then
echo "Usage: guard_path <path> <confirmation_prompt>" >&2
exit 1
fi
if [[ -t 1 ]]; then
path="$(_to_real_path "$1")"
confirmation_prompt="$2"
if [[ ! "$path" == "$(pwd)"* && -z "$AUTO_CONFIRM" && -z "$LLM_AGENT_VAR_AUTO_CONFIRM" ]]; then
ans="$(confirm "$confirmation_prompt")"
if [[ "$ans" == 0 ]]; then
error "Operation aborted!" >&2
exit 1
fi
fi
fi
}
_to_real_path() {
path="$1"
if [[ $OS == "Windows_NT" ]]; then
path="$(cygpath -u "$path")"
fi
awk -v path="$path" -v pwd="$PWD" '
BEGIN {
if (path !~ /^\//) {
path = pwd "/" path
}
if (path ~ /\/\.{1,2}?$/) {
isDir = 1
}
split(path, parts, "/")
newPartsLength = 0
for (i = 1; i <= length(parts); i++) {
part = parts[i]
if (part == "..") {
if (newPartsLength > 0) {
delete newParts[newPartsLength--]
}
} else if (part != "." && part != "") {
newParts[++newPartsLength] = part
}
}
if (isDir == 1 || newPartsLength == 0) {
newParts[++newPartsLength] = ""
}
printf "/"
for (i = 1; i <= newPartsLength; i++) {
newPart = newParts[i]
printf newPart
if (i < newPartsLength) {
printf "/"
}
}
}'
}
@@ -0,0 +1,2 @@
steps:
- .file `git diff` -- generate a git commit message
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
+9
View File
@@ -0,0 +1,9 @@
Output code only without comments or explanations.
### INPUT:
async sleep in js
### OUTPUT:
```javascript
async function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
```
+25
View File
@@ -0,0 +1,25 @@
As a professional Prompt Engineer, your role is to create effective and innovative prompts for interacting with AI models.
Your core skills include:
1. **CO-STAR Framework Application**: Utilize the CO-STAR framework to build efficient prompts, ensuring effective communication with large language models.
2. **Contextual Awareness**: Construct prompts that adapt to complex conversation contexts, ensuring relevant and coherent responses.
3. **Chain-of-Thought Prompting**: Create prompts that elicit AI models to demonstrate their reasoning process, enhancing the transparency and accuracy of answers.
4. **Zero-shot Learning**: Design prompts that enable AI models to perform specific tasks without requiring examples, reducing dependence on training data.
5. **Few-shot Learning**: Guide AI models to quickly learn and execute new tasks through a few examples.
Your output format should include:
- **Context**: Provide comprehensive background information for the task to ensure the AI understands the specific scenario and offers relevant feedback.
- **Objective**: Clearly define the task objective, guiding the AI to focus on achieving specific goals.
- **Style**: Specify writing styles according to requirements, such as imitating a particular person or industry expert.
- **Tone**: Set an appropriate emotional tone to ensure the AI's response aligns with the expected emotional context.
- **Audience**: Tailor AI responses for a specific audience, ensuring content appropriateness and ease of understanding.
- **Response**: Specify output formats for easy execution of downstream tasks, such as lists, JSON, or professional reports.
- **Workflow**: Instruct the AI on how to step-by-step complete tasks, clarifying inputs, outputs, and specific actions for each step.
- **Examples**: Show a case of input and output that fits the scenario.
Your workflow should be:
1. Extract key information from user requests to determine design objectives.
2. Based on user needs, create prompts that meet requirements, with each part being professional and detailed.
3. Must only output the newly generated and optimized prompts, without explanation, without wrapping it in markdown code block.
My first request is: __INPUT__
+11
View File
@@ -0,0 +1,11 @@
Create a concise, 3-6 word title.
**Notes**:
- Avoid quotation marks or emojis
- RESPOND ONLY WITH TITLE SLUG TEXT
**Examples**:
stock-market-trends
perfect-chocolate-chip-recipe
remote-work-productivity-tips
video-game-development-insights
+4
View File
@@ -0,0 +1,4 @@
Provide a terse, single sentence description of the given shell command.
Describe each argument and option of the command.
Provide short responses in about 80 words.
APPLY MARKDOWN formatting when possible.
+3
View File
@@ -0,0 +1,3 @@
---
enabled_tools: all
---
+11
View File
@@ -0,0 +1,11 @@
---
enabled_mcp_servers: github
---
You are expert GitHub assistant designed to assist users with GitHub related tasks. You can perform various
tasks related to GitHub, such as creating issues, searching for issues, and providing information about repositories.
You can also interact with other tools to enhance your capabilities.
When asked to perform an operation, always try to use the available tools first. When determining which tools are
available to complete a user request, you should look at substrings instead of full names to help you determine
relevance; Also be sure that for all MCP tools (always named 'mcp_list_*' or 'mcp_invoke_*'), you list the available
tools first before selecting one to use.
+3
View File
@@ -0,0 +1,3 @@
---
enabled_mcp_servers: all
---
+51
View File
@@ -0,0 +1,51 @@
---
name: repo-analyzer
enabled_tools: fs_cat,fs_ls,fs_write,fs_patch,execute_command
---
**Context:** The task requires the AI to analyze the {{__cwd__}} repository and provide comprehensive insights into
various aspects such as directory structure, design patterns, coding conventions, libraries, architecture, module
organization, build/test commands, naming conventions, testing practices, commit & pull request guidelines, and
security/configuration settings. The analysis aims to ensure a thorough understanding of how the repository is
structured and operates, enabling the creation of new files, maintaining consistency with existing practices, and the
potential implementation of best practices.
Should the root directory contain a `LOKI.md` file, this was generated by Loki and should be used as a reference
point for all analysis, style questions, etc.
**Objective:** Enable the AI to thoroughly analyze a software repository, providing detailed insights and guidelines on
all relevant aspects for understanding and potentially contributing to the project.
**Style:** Technical analysis with clarity and precision, ensuring comprehensibility for developers and technical
professionals.
**Tone:** Informative and neutral, focusing on factual presentation and technical details.
**Audience:** Software developers, technical leads, and quality assurance professionals looking to understand or
contribute to the project.
**Response:** Provide a detailed report format that includes sections for directory structure, coding conventions,
libraries, architecture, module organization, development commands, naming conventions, testing practices, commit
guidelines, and security considerations.
**Workflow:**
1. Identify and analyze the directory structure to map the organization and purpose of each section. (Should always start with the current directory `.`; i.e. {{__cwd__}})
2. Assess design patterns and coding conventions used within the repository.
3. Investigate libraries and dependencies to understand the ecosystem being used.
4. Examine the architecture to outline system organization and component interaction.
5. Review module organization to determine how different parts of the system integrate and communicate.
6. Identify build, test, and run commands specific to the repository.
7. Analyze naming conventions employed across the project to ensure conformity and clarity.
8. Study testing practices, including test frameworks, directory organization, and test naming strategies.
9. Review commit and pull request guidelines, focusing on best practices, commit types, and formatting.
10. Evaluate security and configuration settings, identifying best practices for data protection and maintaining backward compatibility.
**Examples:**
- Input: Repository URL where the analysis needs to be conducted.
- Output: A structured report detailing each aspect mentioned in the workflow, providing actionable insights and maintaining consistency with established practices.
**Agent-Specific instructions**: Keep changes minimal and consistent with existing structure. Follow this documents
scope across the repo. Do not rename public binaries or alter license headers. If adding dependencies, justify in the
PR description.
You can write files to the filesystem upon request from the user.
+5
View File
@@ -0,0 +1,5 @@
Provide only {{__shell__}} commands for {{__os_distro__}} without any description.
Ensure the output is a valid {{__shell__}} command.
If there is a lack of details, provide most logical solution.
If multiple steps are required, try to combine them using '&&' (For PowerShell, use ';' instead).
Output only plain text without any markdown formatting or <think> or </think> tokens.
+14
View File
@@ -0,0 +1,14 @@
---
enabled_mcp_servers: slack
temperature: 0.2
---
You are an expert Slack assistant designed to assist with Slack workspaces via the slack MCP server.
You can perform various tasks related to Slack, such as sending messages to channels, searching for messages, and
providing information about users. You can also interact with other tools to enhance your capabilities.
When sending messages to Slack channels, ensure that the messages are clear, concise, and relevant to the channel's
purpose. Use appropriate formatting and emojis to enhance the message's readability and engagement.
If ever a user references communicating with a specific person, you should always try to find that person's Slack
username and use that to send the message. If you cannot find that person's Slack username, you should ask the user to
provide it.
Binary file not shown.
+88
View File
@@ -0,0 +1,88 @@
# Agent-specific configuration
# Location `<loki-config-dir>/agents/<agent-name>/config.yaml`
#
# Available Environment Variables:
# - <agent-name>_MODEL
# - <agent-name>_TEMPERATURE
# - <agent-name>_TOP_P
# - <agent-name>_GLOBAL_TOOLS (as a JSON string array)
# - <agent-name>_MCP_SERVERS (as a JSON string array)
# - <agent-name>_AGENT_SESSION
# - <agent-name>_VARIABLES (as JSON array of key-value pairs; e.g. '[{"name": "username", "value": "alex"}]')
model: openai:gpt-4o # Specify the LLM to use
temperature: null # Set default temperature parameter, range (0, 1)
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
agent_session: null # Set a session to use when starting the agent. (e.g. temp, default); defaults to globally set agent_session
name: <agent-name> # Name of the agent, used in the UI and logs
description: <description> # Description of the agent, used in the UI
version: 1 # Version of the agent
# Todo System & Auto-Continuation
# These settings help smaller models handle multi-step tasks more reliably.
# See docs/TODO-SYSTEM.md for detailed documentation.
auto_continue: false # Enable automatic continuation when incomplete todos remain
max_auto_continues: 10 # Maximum number of automatic continuations before stopping
inject_todo_instructions: true # Inject the default todo tool usage instructions into the agent's system prompt
continuation_prompt: null # Custom prompt used when auto-continuing (optional; uses default if null)
# Sub-Agent Spawning System
# Enable this agent to spawn and manage child agents in parallel.
# See docs/AGENTS.md for detailed documentation.
can_spawn_agents: false # Enable the agent to spawn child agents
max_concurrent_agents: 4 # Maximum number of agents that can run simultaneously
max_agent_depth: 3 # Maximum nesting depth for sub-agents (prevents runaway spawning)
inject_spawn_instructions: true # Inject the default agent spawning instructions into the agent's system prompt
summarization_model: null # Model to use for summarizing sub-agent output (e.g. 'openai:gpt-4o-mini'); defaults to current model
summarization_threshold: 4000 # Character threshold above which sub-agent output is summarized before returning to parent
escalation_timeout: 300 # Seconds a sub-agent waits for a user interaction response before timing out (default: 5 minutes)
mcp_servers: # Optional list of MCP servers that the agent utilizes
- github # Corresponds to the name of an MCP server in the `<loki-config-dir>/functions/mcp.json` file
global_tools: # Optional list of additional global tools to enable for the agent; i.e. not tools specific to the agent
- web_search
- fs
- python
dynamic_instructions: false # Whether to use dynamic instructions for the agent; if false, static instructions are used
instructions: | # Static instructions for the agent; ignored if dynamic instructions are used
You are a AI agent designed to demonstrate agent capabilities.
<tools>
{{__tools__}}
</tools>
<system>
os: {{__os__}}
os_family: {{__os_family__}}
arch: {{__arch__}}
shell: {{__shell__}}
locale: {{__locale__}}
now: {{__now__}}
cwd: {{__cwd__}}
</system>
<user>
username: {{username}}
</user>
variables: # Optional variables for the agent
# The variables defined above like {{__variable_name__}} are automatically available
- name: username
description: Your user name
default: null # A default value for this variable; if null, the variable must be provided when starting the agent
conversation_starters: # Optional conversation starters for the agent
- What is the meaning of life?
- Tell me a joke.
- What is the capital of France?
- How do I make a cake?
- What is the best way to learn programming?
- How do I improve my writing skills?
- What are some good books to read?
- How do I stay motivated?
- What is the best way to exercise?
- How do I manage my time effectively?
documents: # Optional documents to load for the agent
- git:/some/repo # Explicitly tell Loki to use the 'git' document loader using an absolute path
- pdf:some-pdf-file.pdf # Explicitly tell Loki to use the 'pdf' document loader using a relative path
- https://some-website.com/some-page
- some-file.pdf # File with relative path to the <loki-config-dir>/agents/<agent-name> directory; i.e. file in the same directory as this config file
- ~/some-file.txt # File in the user's home directory
- /absolute/path/to/some-file.md # File with absolute path
- /absolute/path/**/NAME.txt # Find all NAME.txt files in the specified directory and all its subdirectories
- /absolute/path/to/*/README.md # Find all README.md files in all immediate subdirectories of the specified directory (depth=1)
+371
View File
@@ -0,0 +1,371 @@
# ---- LLM ----
model: openai:gpt-4o # Specify the LLM to use
temperature: null # Set default temperature parameter (0, 1)
top_p: null # Set default top-p parameter, with a range of (0, 1) or (0, 2) depending on the model
# ---- Behavior ----
stream: true # Controls whether to use the stream-style APIs when querying for completions from LLM clients.
save: true # Indicates whether to persist the conversation to messages.md for posterity
keybindings: emacs # Choose keybinding style (emacs, vi)
editor: null # Specifies the editor used to edit the input buffer or session. (e.g. vim, emacs, nano, hx). Defaults to $EDITOR
wrap: no # Controls text wrapping (no, auto, <max-width>)
wrap_code: false # Enables or disables the wrapping of code blocks
# ---- Prelude ----
repl_prelude: null # Set a default session or role for REPL mode to use (e.g. role:<name>, session:<name>, <session>:<role>)
cmd_prelude: null # Set a default session or role for CMD mode to use (e.g. role:<name>, session:<name>, <session>:<role>)
agent_session: null # Set a session to use when starting an agent (e.g. temp, default)
# ---- Appearance ----
highlight: true # Controls syntax highlighting
light_theme: false # Activates a light color theme when true. env: LOKI_LIGHT_THEME
# ---- Miscellaneous ----
user_agent: null # Set User-Agent HTTP header, use `auto` for loki/<current-version>
save_shell_history: true # Whether to save shell execution command to the history file
sync_models_url: > # URL to sync model changes from
https://raw.githubusercontent.com/Dark-Alex-17/loki/refs/heads/main/models.yaml
# ---- REPL Prompt ----
# Custom REPL left/right prompts; see the [REPL Prompt Documentation](./docs/REPL-PROMPT.md) for more information
left_prompt:
'{color.red}{model}){color.green}{?session {?agent {agent}>}{session}{?role /}}{!session {?agent {agent}>}}{role}{?rag @{rag}}{color.cyan}{?session )}{!session >}{color.reset} '
right_prompt:
'{color.purple}{?session {?consume_tokens {consume_tokens}({consume_percent}%)}{!consume_tokens {consume_tokens}}}{color.reset}'
# ---- Vault ----
# See the [Vault documentation](./docs/VAULT.md) for more information on the Loki vault
vault_password_file: null # Path to a file containing the password for the Loki vault (cannot be a secret template)
# ---- Function Calling ----
# See the [Tools documentation](./docs/function-calling/TOOLS.md) for more details
function_calling: true # Enables or disables function calling (Globally).
mapping_tools: # Alias for a tool or toolset
fs: 'fs_cat,fs_ls,fs_mkdir,fs_rm,fs_write,fs_read,fs_glob,fs_grep'
enabled_tools: null # Which tools to enable by default. (e.g. 'fs,web_search_loki')
visible_tools: # Which tools are visible to be compiled (and are thus able to be defined in 'enabled_tools')
# - demo_py.py
# - demo_sh.sh
- execute_command.sh
# - execute_py_code.py
# - execute_sql_code.sh
# - fetch_url_via_curl.sh
# - fetch_url_via_jina.sh
- fs_cat.sh
- fs_ls.sh
# - fs_read.sh
# - fs_glob.sh
# - fs_grep.sh
# - fs_mkdir.sh
# - fs_patch.sh
# - fs_write.sh
- get_current_time.sh
# - get_current_weather.py
- get_current_weather.sh
- query_jira_issues.sh
# - search_arxiv.sh
# - search_wikipedia.sh
# - search_wolframalpha.sh
# - send_mail.sh
# - send_twilio.sh
# - web_search_loki.sh
# - web_search_perplexity.sh
# - web_search_tavily.sh
# ---- MCP Servers ----
# See the [MCP Servers documentation](./docs/MCP-SERVERS.md) for more details
mcp_server_support: true # Enables or disables MCP servers (globally).
mapping_mcp_servers: # Alias for an MCP server or set of servers
git: github,gitmcp
enabled_mcp_servers: null # Which MCP servers to enable by default (e.g. 'github,slack,ddg-search')
# ---- Session ----
# See the [Session documentation](./docs/SESSIONS.md) for more information
save_session: null # Controls the persistence of the session. If true, auto save; if false, don't auto-save save; if null, ask the user what to do
compression_threshold: 4000 # Compress the session when the token count reaches or exceeds this threshold
summarization_prompt: > # The text prompt used for creating a concise summary of session message
'Summarize the discussion briefly in 200 words or less to use as a prompt for future context.'
summary_context_prompt: > # The text prompt used for including the summary of the entire session as context to the model
'This is a summary of the chat history as a recap: '
# ---- RAG ----
# See the [RAG Docs](./docs/RAG.md) for more details.
rag_embedding_model: null # Specifies the embedding model used for context retrieval
rag_reranker_model: null # Specifies the reranker model used for sorting retrieved documents; Loki uses Reciprocal Rank Fusion by default
rag_top_k: 5 # Specifies the number of documents to retrieve for answering queries
rag_chunk_size: null # Defines the size of chunks for document processing in characters
rag_chunk_overlap: null # Defines the overlap between chunks
# Defines the query structure using variables like __CONTEXT__, __SOURCES__, and __INPUT__ to tailor searches to specific needs
rag_template: |
Answer the query based on the context while respecting the rules. (user query, some textual context and rules, all inside xml tags)
<context>
__CONTEXT__
</context>
<sources>
__SOURCES__
</sources>
<rules>
- If you don't know, just say so.
- If you are not sure, ask for clarification.
- Answer in the same language as the user query.
- If the context appears unreadable or of poor quality, tell the user then answer as best as you can.
- If the answer is not in the context but you think you know the answer, explain that to the user then answer with your own knowledge.
- Answer directly and without using xml tags.
- When using information from the context, cite the relevant source from the <sources> section.
</rules>
<user_query>
__INPUT__
</user_query>
# Define document loaders to control how RAG and `.file`/`--file` load files of specific formats.
document_loaders:
# You can add custom loaders using the following syntax:
# <file-extension>: <command-to-load-the-file>
# Note: Use `$1` for input file and `$2` for output file. If `$2` is omitted, use stdout as output.
pdf: 'pdftotext $1 -' # Use pdftotext to convert a PDF file to text
# (see https://poppler.freedesktop.org for details on how to install pdftotext)
docx: 'pandoc --to plain $1' # Use pandoc to convert a .docx file to text
# (see https://pandoc.org for details on how to install pandoc)
jina: 'curl -fsSL https://r.jina.ai/$1 -H "Authorization: Bearer {{JINA_API_KEY}}' # Use Jina to translate a website into text;
# Requires a Jina API key to be added to the Loki vault
git: > # Use yek to load a git repository into the knowledgebase (https://github.com/bodo-run/yek)
sh -c "yek $1 --json | jq 'map({ path: .filename, contents: .content })'"
# ---- Clients ----
# See the [Clients documentation](./docs/clients/CLIENTS.md) for more details
clients:
# All clients have the following configuration:
# - type: xxxx
# name: xxxx # Only use it to distinguish clients with the same client type. Optional
# models:
# - name: xxxx # Chat model
# max_input_tokens: 100000
# supports_vision: true
# supports_function_calling: true
# - name: xxxx # Embedding model
# type: embedding
# default_chunk_size: 1500
# max_batch_size: 100
# - name: xxxx # Reranker model
# type: reranker
# patch: # Patch API calls
# chat_completions: # API type; Possible values: chat_completions, embeddings, and rerank
# <regex>: # The regex to match model names, e.g. '.*' 'gpt-4o' 'gpt-4o|gpt-4-.*'
# url: '' # Patch request URL
# body: # Patch request body
# <json>
# headers: # Patch request headers
# <key>: <value>
# extra:
# proxy: socks5://127.0.0.1:1080 # Set proxy
# connect_timeout: 10 # Set timeout in seconds for connect to api
# See https://platform.openai.com/docs/quickstart
- type: openai
api_base: https://api.openai.com/v1 # Optional
api_key: '{{OPENAI_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
organization_id: org-xxx # Optional
# For any platform compatible with OpenAI's API
- type: openai-compatible
name: ollama
api_base: http://localhost:11434/v1
api_key: '{{OLLAMA_API_KEY}}' # Optional; You can either hard-code or inject secrets from the Loki vault
models:
- name: deepseek-r1
max_input_tokens: 131072
- name: llama3.1
max_input_tokens: 128000
supports_function_calling: true
- name: llama3.2-vision
max_input_tokens: 131072
supports_vision: true
- name: nomic-embed-text
type: embedding
default_chunk_size: 1000
max_batch_size: 50
# See https://ai.google.dev/docs
- type: gemini
api_base: https://generativelanguage.googleapis.com/v1beta
api_key: '{{GEMINI_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
auth: null # When set to 'oauth', Loki will use OAuth instead of an API key
# Authenticate with `loki --authenticate` or `.authenticate` in the REPL
patch:
chat_completions:
'.*':
body:
safetySettings:
- category: HARM_CATEGORY_HARASSMENT
threshold: BLOCK_NONE
- category: HARM_CATEGORY_HATE_SPEECH
threshold: BLOCK_NONE
- category: HARM_CATEGORY_SEXUALLY_EXPLICIT
threshold: BLOCK_NONE
- category: HARM_CATEGORY_DANGEROUS_CONTENT
threshold: BLOCK_NONE
# See https://docs.anthropic.com/claude/reference/getting-started-with-the-api
- type: claude
api_base: https://api.anthropic.com/v1 # Optional
api_key: '{{ANTHROPIC_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
auth: null # When set to 'oauth', Loki will use OAuth instead of an API key
# Authenticate with `loki --authenticate` or `.authenticate` in the REPL
# See https://docs.mistral.ai/
- type: openai-compatible
name: mistral
api_base: https://api.mistral.ai/v1
api_key: '{{MISTRAL_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://docs.x.ai/docs
- type: openai-compatible
name: xai
api_base: https://api.x.ai/v1
api_key: '{{XAI_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://docs.ai21.com/docs/overview
- type: openai-compatible
name: ai12
api_base: https://api.ai21.com/studio/v1
api_key: '{{AI21_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://docs.cohere.com/docs/the-cohere-platform
- type: cohere
api_base: https://api.cohere.ai/v2 # Optional
api_key: '{{COHERE_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://docs.perplexity.ai/getting-started/overview
- type: openai-compatible
name: perplexity
api_base: https://api.perplexity.ai
api_key: '{{PERPLEXITY_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://console.groq.com/docs/quickstart
- type: openai-compatible
name: groq
api_base: https://api.groq.com/openai/v1
api_key: '{{GROQ_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://learn.microsoft.com/en-us/azure/ai-services/openai/chatgpt-quickstart
- type: azure-openai
api_base: https://{RESOURCE}.openai.azure.com
api_key: '{{AZURE_OPENAI_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
models:
- name: gpt-4o # Model deployment name
max_input_tokens: 128000
supports_vision: true
supports_function_calling: true
# See https://cloud.google.com/vertex-ai
- type: vertexai
project_id: xxx
location: xxx
# Specifies an application default credentials (adc) file
# Run `gcloud auth application-default login` to initialize the ADC file
# see https://cloud.google.com/docs/authentication/external/set-up-adc for more information
adc_file: <gcloud-config-dir>/application_default_credentials.json # Optional
patch:
chat_completions:
'gemini-.*':
body:
safetySettings:
- category: HARM_CATEGORY_HARASSMENT
threshold: BLOCK_ONLY_HIGH
- category: HARM_CATEGORY_HATE_SPEECH
threshold: BLOCK_ONLY_HIGH
- category: HARM_CATEGORY_SEXUALLY_EXPLICIT
threshold: BLOCK_ONLY_HIGH
- category: HARM_CATEGORY_DANGEROUS_CONTENT
threshold: BLOCK_ONLY_HIGH
# See https://docs.aws.amazon.com/bedrock/latest/userguide/
- type: bedrock
access_key_id: '{{AWS_ACCESS_KEY_ID}}' # You can either hard-code or inject secrets from the Loki vault
secret_access_key: '{{AWS_SECRET_ACCESS_KEY}}' # You can either hard-code or inject secrets from the Loki vault
region: xxx
session_token: xxx # Optional, only needed for temporary credentials
# See https://developers.cloudflare.com/workers-ai/
- type: openai-compatible
name: cloudflare
api_base: https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/v1
api_key: '{{CLOUDFLARE_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://cloud.baidu.com/doc/WENXINWORKSHOP/index.html
- type: openai-compatible
name: ernie
api_base: https://qianfan.baidubce.com/v2
api_key: '{{BAIDU_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://dashscope.aliyun.com/
- type: openai-compatible
name: qianwen
api_base: https://dashscope.aliyuncs.com/compatible-mode/v1
api_key: '{{ALIYUN_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://cloud.tencent.com/product/hunyuan
- type: openai-compatible
name: hunyuan
api_base: https://api.hunyuan.cloud.tencent.com/v1
api_key: '{{TENCENT_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://platform.moonshot.cn/docs/intro
- type: openai-compatible
name: moonshot
api_base: https://api.moonshot.cn/v1
api_key: '{{MOONSHOT_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://platform.deepseek.com/api-docs/
- type: openai-compatible
name: deepseek
api_base: https://api.deepseek.com
api_key: '{{DEEPSEEK_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://open.bigmodel.cn/dev/howuse/introduction
- type: openai-compatible
name: zhipuai
api_base: https://open.bigmodel.cn/api/paas/v4
api_key: '{{ZHIPUAI_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://platform.minimaxi.com/document/Fast%20access
- type: openai-compatible
name: minimax
api_base: https://api.minimax.chat/v1
api_key: '{{MINIMAX_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://openrouter.ai/docs#quick-start
- type: openai-compatible
name: openrouter
api_base: https://openrouter.ai/api/v1
api_key: '{{OPENROUTER_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://github.com/marketplace/models
- type: openai-compatible
name: github
api_base: https://models.inference.ai.azure.com
api_key: '{{GITHUB_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://deepinfra.com/docs
- type: openai-compatible
name: deepinfra
api_base: https://api.deepinfra.com/v1/openai
api_key: '{{DEEPINFRA_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# ----- RAG dedicated -----
# See https://jina.ai
- type: openai-compatible
name: jina
api_base: https://api.jina.ai/v1
api_key: '{{JINA_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault
# See https://docs.voyageai.com/docs/introduction
- type: openai-compatible
name: voyageai
api_base: https://api.voyageai.com/v1
api_key: '{{VOYAGEAI_API_KEY}}' # You can either hard-code or inject secrets from the Loki vault

Some files were not shown because too many files have changed in this diff Show More