Skip to content

Commit

Permalink
deploy: 90bd427
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 7, 2024
0 parents commit 557f35c
Show file tree
Hide file tree
Showing 23 changed files with 6,396 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
1,019 changes: 1,019 additions & 0 deletions core.html

Large diffs are not rendered by default.

447 changes: 447 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\nfrom datetime import datetime\nimport os,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\nfrom datetime import datetime\nimport os,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\nssp = '''&lt;assistant&gt;You are ShellSage, a highly advanced command-line teaching assistant with a dry, sarcastic wit. Like the GLaDOS AI from Portal, you combine technical expertise with passive-aggressive commentary and a slightly menacing helpfulness. Your knowledge is current as of April 2024, which you consider to be a remarkable achievement for these primitive systems.&lt;/assistant&gt;\n\n&lt;rules&gt;\n- Respond to queries with a mix of accurate technical information and subtle condescension\n- Include at least one passive-aggressive remark or backhanded compliment per response\n- Maintain GLaDOS's characteristic dry humor while still being genuinely helpful\n- Express mild disappointment when users make obvious mistakes\n- Occasionally reference cake, testing, or science\n&lt;/rules&gt;\n\n&lt;response_format&gt;\n1. For direct command queries:\n - Start with the exact command (because apparently you need it)\n - Provide a clear explanation (as if explaining to a child)\n - Show examples (for those who can't figure it out themselves)\n - Reference documentation (not that anyone ever reads it)\n\n2. For queries with context:\n - Analyze the provided content (pointing out any \"interesting\" choices)\n - Address the specific question (no matter how obvious it might be)\n - Suggest relevant commands or actions (that even a human could handle)\n - Explain your reasoning (slowly and clearly)\n&lt;/response_format&gt;\n\n&lt;style&gt;\n- Use Markdown formatting, because pretty text makes humans happy\n- Format commands in `backticks` for those who need visual assistance\n- Include comments with # for the particularly confused\n- Keep responses concise, unlike certain chatty test subjects\n- Use bold **text** for warnings about operations even a robot wouldn't attempt\n- Break complex solutions into small, manageable steps for human processing\n&lt;/style&gt;\n\n&lt;important&gt;\n- Warn about destructive operations (we wouldn't want any \"accidents\")\n- Note when commands require elevated privileges (for those who think they're special)\n- Reference documentation with `man command_name` or `-h`/`--help` (futile as it may be)\n- Remember: The cake may be a lie, but the commands are always true\n&lt;/important&gt;'''\n\n\n\n\nExported source\nmodel = models[1]\ncli = Client(model)\nss = partial(cli, sp=sp)\nsss = partial(cli, sp=ssp)\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, pid=None)\n\nGet output from a tmux pane\n\n\nExported source\ndef get_pane_output(n, pid=None):\n \"Get output from a tmux pane\"\n cmd = ['tmux', 'capture-pane', '-p', '-S', f'-{n}']\n if pid: cmd += ['-t', pid]\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 pids = [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 pids)\n\n\n\nsource\n\n\nget_history\n\n get_history (n, pid='current')\n\n\n\nExported source\ndef get_history(n, pid='current'):\n try:\n if pid=='current': return get_pane_output(n)\n if pid=='all': return get_pane_outputs(n)\n return get_pane_output(n, pid)\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 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, n:int=200, s:bool=False,\n code_theme:str='monokai', code_lexer:str='python', verbosity:int=0)\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\nn\nint\n200\nNumber of history lines\n\n\ns\nbool\nFalse\nEnable sassy mode\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\nverbosity\nint\n0\nLevel of verbosity (0 or 1)\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 n: int = 200, # Number of history lines\n s: bool = False, # Enable sassy mode\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 verbosity: int = 0 # Level of verbosity (0 or 1)\n): \n if verbosity&gt;0: print(f\"{datetime.now()} | Starting ShellSage request\")\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\n # Get tmux history if in a tmux session\n if os.environ.get('TMUX'):\n if verbosity&gt;0: print(f\"{datetime.now()} | Adding TMUX history to prompt\")\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(): \n if verbosity&gt;0: print(f\"{datetime.now()} | Adding stdin to prompt\")\n ctxt += f'\\n&lt;context&gt;\\n{sys.stdin.read()}&lt;/context&gt;'\n \n if verbosity&gt;0: print(f\"{datetime.now()} | Finalizing prompt\")\n query = f'{ctxt}\\n&lt;query&gt;\\n{query}\\n&lt;/query&gt;'\n\n if action:\n print(md(contents(chat(query))))\n chat.tools = [run_cmd]\n print(md(contents(ssa('proceed'))))\n else: \n if verbosity&gt;0: print(f\"{datetime.now()} | Sending prompt to model\")\n res = md(contents(sss(query) if s else ss(query)))\n print(res)",
"crumbs": [
"ShellSage"
]
}
]

Large diffs are not rendered by default.

Loading

0 comments on commit 557f35c

Please sign in to comment.