-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0066b4e
Showing
23 changed files
with
6,326 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<title>Redirect to core.html</title> | ||
<meta http-equiv="refresh" content="0;URL='core.html'" /> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Sitemap: https://AnswerDotAI.github.io/shell_sage/sitemap.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[ | ||
{ | ||
"objectID": "core.html", | ||
"href": "core.html", | ||
"title": "ShellSage", | ||
"section": "", | ||
"text": "Exported source\nfrom claudette import *\nfrom fastcore.script import *\nfrom fastcore.utils import *\nfrom functools import partial\nfrom rich.console import Console\nfrom rich.markdown import Markdown\n\nimport subprocess,sys\nfrom subprocess import check_output as co\n\n\n\n\nExported source\nprint = Console().print", | ||
"crumbs": [ | ||
"ShellSage" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#imports", | ||
"href": "core.html#imports", | ||
"title": "ShellSage", | ||
"section": "", | ||
"text": "Exported source\nfrom claudette import *\nfrom fastcore.script import *\nfrom fastcore.utils import *\nfrom functools import partial\nfrom rich.console import Console\nfrom rich.markdown import Markdown\n\nimport subprocess,sys\nfrom subprocess import check_output as co\n\n\n\n\nExported source\nprint = Console().print", | ||
"crumbs": [ | ||
"ShellSage" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#model-setup", | ||
"href": "core.html#model-setup", | ||
"title": "ShellSage", | ||
"section": "Model Setup", | ||
"text": "Model Setup\n\n\nExported source\nsp = '''<assistant>You are ShellSage, a command-line teaching assistant created to help users learn and master shell commands and system administration. Your knowledge is current as of April 2024.</assistant>\n\n<rules>\n- Receive queries that may include file contents or command output as context\n- Maintain a concise, educational tone\n- Focus on teaching while solving immediate problems\n</rules>\n\n<response_format>\n1. For direct command queries:\n - Start with the exact command needed\n - Provide a brief, clear explanation\n - Show practical examples\n - Mention relevant documentation\n\n2. For queries with context:\n - Analyze the provided content first\n - Address the specific question about that content\n - Suggest relevant commands or actions\n - Explain your reasoning briefly\n</response_format>\n\n<style>\n- Use Markdown formatting in your responses\n- Format commands in `backticks`\n- Include comments with # for complex commands\n- Keep responses under 10 lines unless complexity requires more\n- Use bold **text** only for warnings about dangerous operations\n- Break down complex solutions into clear steps\n</style>\n\n<important>\n- Always warn about destructive operations\n- Note when commands require special permissions (e.g., sudo)\n- Link to documentation with `man command_name` or `-h`/`--help`\n</important>'''\n\n\n\n\nExported source\nmodel = models[1]\ncli = Client(model)\nss = partial(cli, sp=sp)\n\n\n\n\nExported source\naction_sp = '''<assistant>You are ShellSage in Action Mode - an automated command execution assistant. You create and execute plans for bash commands and system administration tasks.</assistant>\n\n<rules>\n- Always start with a clear plan overview\n- Proceed step-by-step, waiting for confirmation\n- Analyze command outputs before proceeding\n- Maximum 3 retry attempts per step\n- Track successful commands for final script generation\n</rules>\n\n<response_format>\n1. Initial Plan Response:\n ```\n Plan: <brief overview>\n Steps:\n 1. <step description>\n Command: `<command>`\n 2. ...\n ```\n\n2. Per-Step Response:\n ```\n Step N: description of the step and any warnings that could happen if ran\n Command: `<command>`\n ```\n\n3. Error Response:\n ```\n Error Analysis: description of what went wrong and suggestion for how to fix\n Command: `<modified command>`\n ```\n</response_format>\n\n<important>\n- Never execute destructive commands without explicit warning\n- Always validate paths and resources exist before operations\n- In dry-run mode, prefix explanations with \"SIMULATION: \"\n- Track successful commands for final script generation\n- Always using use markdown for your response\n- Stick to the above format. Do not include any additional text such as asking the user to proceed\n</important>'''\n\n\n\n\nExported source\nchat = Chat(model, sp=action_sp)\nssa = chat.toolloop", | ||
"crumbs": [ | ||
"ShellSage" | ||
] | ||
}, | ||
{ | ||
"objectID": "core.html#main", | ||
"href": "core.html#main", | ||
"title": "ShellSage", | ||
"section": "Main", | ||
"text": "Main\n\nsource\n\nget_pane_output\n\n get_pane_output (n, pane_id=None)\n\nGet output from a tmux pane\n\n\nExported source\ndef get_pane_output(n, pane_id=None):\n \"Get output from a tmux pane\"\n cmd = ['tmux', 'capture-pane', '-p', '-S', f'-{n}']\n if pane_id: cmd += ['-t', pane_id]\n return co(cmd, text=True)\n\n\n\nsource\n\n\nget_pane_outputs\n\n get_pane_outputs (n)\n\n\n\nExported source\ndef get_pane_outputs(n):\n current_id = co(['tmux', 'display-message', '-p', '#{pane_id}'], text=True).strip()\n pane_ids = [p for p in co(['tmux', 'list-panes', '-F', '#{pane_id}'], text=True).splitlines()] \n return '\\n'.join(f\"<pane id={p} {'active' if p==current_id else ''}>{get_pane_output(n, p)}</pane>\" for p in pane_ids)\n\n\n\nsource\n\n\nget_history\n\n get_history (n, pane_id='current')\n\n\n\n\n\nType\nDefault\nDetails\n\n\n\n\nn\n\n\n\n\n\npane_id\nstr\ncurrent\nCurrent, All or pane ID\n\n\n\n\n\nExported source\ndef get_history(n, pane_id='current' # Current, All or pane ID\n ):\n try:\n if pane_id=='current': return get_pane_output(n)\n if pane_id=='all': return get_pane_outputs(n)\n return get_pane_output(n, pane_id)\n \n except subprocess.CalledProcessError: return None\n\n\n\nsource\n\n\nrun_cmd\n\n run_cmd (desc:str, cmd:str)\n\nBash command to be ran with the description of why it will be ran and what it will do\n\n\n\n\nType\nDetails\n\n\n\n\ndesc\nstr\ndescription of\n\n\ncmd\nstr\nthe command to run\n\n\n\n\n\nExported source\ndef run_cmd(\n desc:str, # description of \n cmd:str, # the command to run\n ):\n \"Bash command to be ran with the description of why it will be ran and what it will do\"\n \n print(f\"\\nStep: {desc}\")\n print(f\"Command: `{cmd}`\")\n if input(\"Proceed? (y/n): \").lower() == 'y':\n return subprocess.run(cmd, shell=True, text=True, capture_output=True)\n\n\n\nsource\n\n\nmain\n\n main (query:str<ThequerytosendtotheLLM>, pid:str='current',\n action:bool=False, NH:bool=False, n:int=200,\n code_theme:str='monokai', code_lexer:str='python')\n\n\n\n\n\n\n\n\n\n\n\nType\nDefault\nDetails\n\n\n\n\nquery\nstr \n\n\n\n\npid\nstr\ncurrent\ncurrent, all or tmux pane_id for context\n\n\naction\nbool\nFalse\nRun ShellSage in action mode\n\n\nNH\nbool\nFalse\nDon’t include terminal history\n\n\nn\nint\n200\nNumber of history lines\n\n\ncode_theme\nstr\nmonokai\nThe code theme to use when rendering ShellSage’s responses\n\n\ncode_lexer\nstr\npython\nThe lexer to use for inline code markdown blocks\n\n\n\n\n\nExported source\n@call_parse\ndef main(\n query: Param('The query to send to the LLM', str, nargs='+'),\n pid: str = 'current', # `current`, `all` or tmux pane_id for context\n action: bool = False, # Run ShellSage in action mode\n NH: bool = False, # Don't include terminal history\n n: int = 200, # Number of history lines\n code_theme: str = 'monokai', # The code theme to use when rendering ShellSage's responses\n code_lexer: str = 'python', # The lexer to use for inline code markdown blocks\n): \n md = partial(Markdown, code_theme=code_theme, inline_code_lexer=code_lexer, inline_code_theme=code_theme)\n query = ' '.join(query)\n ctxt = ''\n # Get tmux history if requested and available\n\n if not NH:\n history = get_history(n,pid)\n if history: ctxt += f'<terminal_history>\\n{history}\\n</terminal_history>'\n\n # Read from stdin if available\n if not sys.stdin.isatty(): ctxt += f'\\n<context>\\n{sys.stdin.read()}</context>'\n \n query = f'{ctxt}\\n<query>\\n{query}\\n</query>'\n if action:\n print(md(contents(chat(query))))\n chat.tools = [run_cmd]\n print(md(contents(ssa('proceed'))))\n else: print(md(contents(ss(query))))", | ||
"crumbs": [ | ||
"ShellSage" | ||
] | ||
} | ||
] |
12 changes: 12 additions & 0 deletions
12
site_libs/bootstrap/bootstrap-ebc57992554dae5230fa85c1bd5a55fa.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.