Skip to content

Commit

Permalink
deploy: 578b148
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 6, 2024
0 parents commit 0066b4e
Show file tree
Hide file tree
Showing 23 changed files with 6,326 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
985 changes: 985 additions & 0 deletions core.html

Large diffs are not rendered by default.

411 changes: 411 additions & 0 deletions core.html.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions index.html
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>
1 change: 1 addition & 0 deletions robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sitemap: https://AnswerDotAI.github.io/shell_sage/sitemap.xml
42 changes: 42 additions & 0 deletions search.json
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 = '''&lt;assistant&gt;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.&lt;/assistant&gt;\n\n&lt;rules&gt;\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&lt;/rules&gt;\n\n&lt;response_format&gt;\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&lt;/response_format&gt;\n\n&lt;style&gt;\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&lt;/style&gt;\n\n&lt;important&gt;\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&lt;/important&gt;'''\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 = '''&lt;assistant&gt;You are ShellSage in Action Mode - an automated command execution assistant. You create and execute plans for bash commands and system administration tasks.&lt;/assistant&gt;\n\n&lt;rules&gt;\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&lt;/rules&gt;\n\n&lt;response_format&gt;\n1. Initial Plan Response:\n ```\n Plan: &lt;brief overview&gt;\n Steps:\n 1. &lt;step description&gt;\n Command: `&lt;command&gt;`\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: `&lt;command&gt;`\n ```\n\n3. Error Response:\n ```\n Error Analysis: description of what went wrong and suggestion for how to fix\n Command: `&lt;modified command&gt;`\n ```\n&lt;/response_format&gt;\n\n&lt;important&gt;\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&lt;/important&gt;'''\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\"&lt;pane id={p} {'active' if p==current_id else ''}&gt;{get_pane_output(n, p)}&lt;/pane&gt;\" 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&lt;ThequerytosendtotheLLM&gt;, 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'&lt;terminal_history&gt;\\n{history}\\n&lt;/terminal_history&gt;'\n\n # Read from stdin if available\n if not sys.stdin.isatty(): ctxt += f'\\n&lt;context&gt;\\n{sys.stdin.read()}&lt;/context&gt;'\n \n query = f'{ctxt}\\n&lt;query&gt;\\n{query}\\n&lt;/query&gt;'\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"
]
}
]

Large diffs are not rendered by default.

Loading

0 comments on commit 0066b4e

Please sign in to comment.