ai-tui-shell 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. ai_tui_shell-0.1.0/.gitignore +143 -0
  2. ai_tui_shell-0.1.0/LICENSE +21 -0
  3. ai_tui_shell-0.1.0/NOTICE +27 -0
  4. ai_tui_shell-0.1.0/PKG-INFO +180 -0
  5. ai_tui_shell-0.1.0/README.md +121 -0
  6. ai_tui_shell-0.1.0/config.example.toml +73 -0
  7. ai_tui_shell-0.1.0/pyproject.toml +217 -0
  8. ai_tui_shell-0.1.0/src/ai_tui_shell/__init__.py +14 -0
  9. ai_tui_shell-0.1.0/src/ai_tui_shell/__main__.py +14 -0
  10. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/__init__.py +237 -0
  11. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/anthropic_provider.py +403 -0
  12. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/conversation_store.py +238 -0
  13. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/models.py +120 -0
  14. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/ollama_provider.py +251 -0
  15. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/openai_provider.py +335 -0
  16. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/retry.py +262 -0
  17. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/stub_provider.py +162 -0
  18. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/token_budget.py +140 -0
  19. ai_tui_shell-0.1.0/src/ai_tui_shell/ai/tools.py +500 -0
  20. ai_tui_shell-0.1.0/src/ai_tui_shell/app.py +681 -0
  21. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/__init__.py +37 -0
  22. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/aggregator.py +198 -0
  23. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/executor.py +456 -0
  24. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/library.py +157 -0
  25. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/models.py +341 -0
  26. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/picker.py +155 -0
  27. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/placeholders.py +275 -0
  28. ai_tui_shell-0.1.0/src/ai_tui_shell/batch/repository.py +90 -0
  29. ai_tui_shell-0.1.0/src/ai_tui_shell/cli.py +765 -0
  30. ai_tui_shell-0.1.0/src/ai_tui_shell/config/__init__.py +14 -0
  31. ai_tui_shell-0.1.0/src/ai_tui_shell/config/db.py +204 -0
  32. ai_tui_shell-0.1.0/src/ai_tui_shell/config/migrations.py +186 -0
  33. ai_tui_shell-0.1.0/src/ai_tui_shell/config/paths.py +80 -0
  34. ai_tui_shell-0.1.0/src/ai_tui_shell/config/secrets.py +272 -0
  35. ai_tui_shell-0.1.0/src/ai_tui_shell/config/settings.py +248 -0
  36. ai_tui_shell-0.1.0/src/ai_tui_shell/core/__init__.py +12 -0
  37. ai_tui_shell-0.1.0/src/ai_tui_shell/core/event_bus.py +307 -0
  38. ai_tui_shell-0.1.0/src/ai_tui_shell/core/logging_setup.py +165 -0
  39. ai_tui_shell-0.1.0/src/ai_tui_shell/core/proxy_env.py +47 -0
  40. ai_tui_shell-0.1.0/src/ai_tui_shell/crypto/__init__.py +11 -0
  41. ai_tui_shell-0.1.0/src/ai_tui_shell/crypto/audit_chain.py +168 -0
  42. ai_tui_shell-0.1.0/src/ai_tui_shell/domain/ai.py +349 -0
  43. ai_tui_shell-0.1.0/src/ai_tui_shell/domain/skill.py +170 -0
  44. ai_tui_shell-0.1.0/src/ai_tui_shell/hosts/__init__.py +14 -0
  45. ai_tui_shell-0.1.0/src/ai_tui_shell/hosts/manager.py +94 -0
  46. ai_tui_shell-0.1.0/src/ai_tui_shell/hosts/models.py +125 -0
  47. ai_tui_shell-0.1.0/src/ai_tui_shell/hosts/repository.py +87 -0
  48. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/__init__.py +31 -0
  49. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/approval_cache.py +144 -0
  50. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/ast_check.py +242 -0
  51. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/audit.py +115 -0
  52. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/audit_middleware.py +314 -0
  53. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/engine.py +353 -0
  54. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/llm_classifier.py +221 -0
  55. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/models.py +200 -0
  56. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/modes.py +117 -0
  57. ai_tui_shell-0.1.0/src/ai_tui_shell/policy/static_rules.py +172 -0
  58. ai_tui_shell-0.1.0/src/ai_tui_shell/services/__init__.py +9 -0
  59. ai_tui_shell-0.1.0/src/ai_tui_shell/services/ai_service.py +523 -0
  60. ai_tui_shell-0.1.0/src/ai_tui_shell/services/policy_service.py +226 -0
  61. ai_tui_shell-0.1.0/src/ai_tui_shell/sftp/__init__.py +12 -0
  62. ai_tui_shell-0.1.0/src/ai_tui_shell/sftp/transfer_queue.py +339 -0
  63. ai_tui_shell-0.1.0/src/ai_tui_shell/skills/__init__.py +18 -0
  64. ai_tui_shell-0.1.0/src/ai_tui_shell/skills/builtin.py +83 -0
  65. ai_tui_shell-0.1.0/src/ai_tui_shell/skills/installer.py +129 -0
  66. ai_tui_shell-0.1.0/src/ai_tui_shell/skills/library.py +210 -0
  67. ai_tui_shell-0.1.0/src/ai_tui_shell/skills/manager.py +115 -0
  68. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/__init__.py +15 -0
  69. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/auth.py +131 -0
  70. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/client.py +221 -0
  71. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/keepalive.py +123 -0
  72. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/known_hosts.py +138 -0
  73. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/pty_session.py +516 -0
  74. ai_tui_shell-0.1.0/src/ai_tui_shell/ssh/sftp_session.py +780 -0
  75. ai_tui_shell-0.1.0/src/ai_tui_shell/terminal/__init__.py +10 -0
  76. ai_tui_shell-0.1.0/src/ai_tui_shell/terminal/screen.py +252 -0
  77. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/__init__.py +5 -0
  78. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/components.py +400 -0
  79. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/css/app.tcss +34 -0
  80. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/css/terminal.tcss +18 -0
  81. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/design.py +371 -0
  82. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/keybindings.py +46 -0
  83. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/rabbit_art.py +928 -0
  84. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/__init__.py +5 -0
  85. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/ai_panel.py +352 -0
  86. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/approval_prompt.py +212 -0
  87. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/batch_modal.py +665 -0
  88. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/host_manager.py +651 -0
  89. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/main_screen.py +1300 -0
  90. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/settings_screen.py +945 -0
  91. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/sftp_browser.py +415 -0
  92. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/screens/skill_manager.py +232 -0
  93. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/text.py +222 -0
  94. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/theme.py +132 -0
  95. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/__init__.py +5 -0
  96. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/ai_sidebar.py +402 -0
  97. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/panel_resize_handle.py +148 -0
  98. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/rabbit_stage.py +497 -0
  99. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/sftp_tree.py +227 -0
  100. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/terminal_view.py +365 -0
  101. ai_tui_shell-0.1.0/src/ai_tui_shell/ui/widgets/transfer_queue.py +138 -0
  102. ai_tui_shell-0.1.0/src/ai_tui_shell/version.py +12 -0
@@ -0,0 +1,143 @@
1
+ # ===========================================================================
2
+ # AI TUI Shell — .gitignore
3
+ # 顺序:字节码 → 打包 → 测试/检查缓存 → 虚拟环境与配置 → 密钥 → 运行数据
4
+ # → IDE/OS → 协作工具本地配置 → 前端(预留)
5
+ # 原则:只忽略「生成物」和「本机私有文件」;源码、测试固件、模板、
6
+ # *.example.* 配置一律入库。
7
+ # ===========================================================================
8
+
9
+ # ---------------------------------------------------------------------------
10
+ # Python 字节码 / 编译产物
11
+ # ---------------------------------------------------------------------------
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+ *.so
16
+ *.pyd
17
+
18
+ # ---------------------------------------------------------------------------
19
+ # 打包 / 构建
20
+ # ---------------------------------------------------------------------------
21
+ .Python
22
+ build/
23
+ dist/
24
+ sdist/
25
+ wheels/
26
+ *.egg-info/
27
+ *.egg
28
+ .eggs/
29
+ pip-wheel-metadata/
30
+ pip-log.txt
31
+ MANIFEST
32
+ .installed.cfg
33
+ # uv.lock / poetry.lock / requirements*.txt 是依赖事实来源,不要忽略。
34
+
35
+ # ---------------------------------------------------------------------------
36
+ # 测试 / 覆盖率 / 静态检查缓存
37
+ # ---------------------------------------------------------------------------
38
+ .pytest_cache/
39
+ .mypy_cache/
40
+ .dmypy.json
41
+ dmypy.json
42
+ .ruff_cache/
43
+ .pyright_cache/
44
+ .tox/
45
+ .nox/
46
+ .hypothesis/
47
+ .cache/
48
+ .coverage
49
+ .coverage.*
50
+ coverage.xml
51
+ *.cover
52
+ htmlcov/
53
+ junit*.xml
54
+ nosetests.xml
55
+ cython_debug/
56
+
57
+ # ---------------------------------------------------------------------------
58
+ # 虚拟环境 / 本地配置(example 模板保留)
59
+ # ---------------------------------------------------------------------------
60
+ .venv/
61
+ venv/
62
+ env/
63
+ ENV/
64
+ !config.example.toml
65
+ # 用户真实配置含主机、凭据、API Key,禁止入库
66
+ /config.toml
67
+ config.local.toml
68
+ secrets.toml
69
+
70
+ # ---------------------------------------------------------------------------
71
+ # 密钥与凭据(绝不入库)
72
+ # ---------------------------------------------------------------------------
73
+ .env
74
+ .env.*
75
+ !.env.example
76
+ *.pem
77
+ *.key
78
+ *.p12
79
+ *.pfx
80
+ id_rsa*
81
+ id_ed25519*
82
+ id_ecdsa*
83
+ # 若将来测试确需固定密钥,用取反规则单独放行:
84
+ # !tests/fixtures/**/*.pem
85
+
86
+ # ---------------------------------------------------------------------------
87
+ # 本机运行时数据
88
+ # platformdirs 默认落在用户目录;这里只兜住「仓库内相对路径」的情况。
89
+ # 锚定 /data/ 是为了不误伤未来可能出现的 src/ai_tui_shell/data/ 与
90
+ # tests/fixtures/data/ 之类需要入库的目录。
91
+ # ---------------------------------------------------------------------------
92
+ /data/
93
+ /logs/
94
+ *.sqlite
95
+ *.sqlite3
96
+ *.db
97
+ *.db-journal
98
+ *.db-wal
99
+ *.db-shm
100
+ vault.enc
101
+ audit-*.jsonl
102
+ audit-*.anchor
103
+ known_hosts.local
104
+ state/
105
+ tmp/
106
+ *.log
107
+
108
+ # ---------------------------------------------------------------------------
109
+ # IDE / 编辑器 / 操作系统
110
+ # ---------------------------------------------------------------------------
111
+ .idea/
112
+ .vscode/
113
+ *.swp
114
+ *.swo
115
+ *.sw?
116
+ *~
117
+ *.bak
118
+ *.orig
119
+ *.rej
120
+ .DS_Store
121
+ ._*
122
+ Thumbs.db
123
+ desktop.ini
124
+
125
+ # ---------------------------------------------------------------------------
126
+ # 协作工具的「本机私有」配置
127
+ # .claude/workflows/ 是团队共享的工作流,保留入库;
128
+ # .workbuddy/ 只有本机 agent 记忆与缓存,整体忽略。
129
+ # ---------------------------------------------------------------------------
130
+ .claude
131
+ .workbuddy/
132
+
133
+ # ---------------------------------------------------------------------------
134
+ # 前端工具链(当前无前端,预留)
135
+ # ---------------------------------------------------------------------------
136
+ node_modules/
137
+ .npm/
138
+ .pnpm-store/
139
+ yarn-error.log
140
+ pnpm-debug.log
141
+ # 其它
142
+ docs/
143
+ CHANGELOG.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 wuwen_0308
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ AI TUI Shell
2
+ Copyright (c) 2026 AI TUI Shell Authors
3
+
4
+ This product includes software developed by third parties:
5
+
6
+ asyncssh (https://github.com/ronf/asyncssh)
7
+ Copyright (c) 2014-2025 by Ron Frederick
8
+ Licensed under the Eclipse Public License, Version 2.0 (EPL-2.0)
9
+ Source-available modifications clause applies; see https://www.eclipse.org/legal/epl-2.0/
10
+
11
+ pyte (https://github.com/deathaxe/pyte)
12
+ Copyright (c) 2008-2025 Selectel; original by Christopher Nilsson
13
+ Licensed under the MIT License
14
+
15
+ textual (https://github.com/Textualize/textual)
16
+ Copyright (c) 2021-2025 Textualize
17
+ Licensed under the MIT License
18
+
19
+ cryptography (https://github.com/pyca/cryptography)
20
+ Licensed under the Apache License 2.0 / BSD License
21
+
22
+ argon2-cffi (https://github.com/hynek/argon2-cffi)
23
+ Licensed under the MIT License
24
+
25
+ For the full license texts of these and other dependencies, see the
26
+ LICENSE-THIRD-PARTY file generated by `pip-licenses` or your package
27
+ manager's license command.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.5
2
+ Name: ai-tui-shell
3
+ Version: 0.1.0
4
+ Summary: AI-integrated secure SSH terminal emulator with SFTP, batch execution, and an auditable command policy engine
5
+ Project-URL: Homepage, https://gitee.com/wuwen_0308/ai-tui-shell
6
+ Project-URL: Repository, https://gitee.com/wuwen_0308/ai-tui-shell.git
7
+ Project-URL: Issues, https://gitee.com/wuwen_0308/ai-tui-shell/issues
8
+ Author: AI TUI Shell Authors
9
+ License: MIT
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: ai,audit,sftp,ssh,terminal,tui
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Environment :: Console :: Curses
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: System Administrators
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Internet
24
+ Classifier: Topic :: Security
25
+ Classifier: Topic :: System :: Networking
26
+ Classifier: Topic :: System :: Systems Administration
27
+ Classifier: Topic :: Terminals
28
+ Requires-Python: >=3.11
29
+ Requires-Dist: aiosqlite>=0.20
30
+ Requires-Dist: anthropic>=0.40
31
+ Requires-Dist: asyncssh<3,>=2.17
32
+ Requires-Dist: bashlex>=0.18
33
+ Requires-Dist: httpx>=0.27
34
+ Requires-Dist: keyring>=25
35
+ Requires-Dist: platformdirs>=4
36
+ Requires-Dist: pydantic>=2.9
37
+ Requires-Dist: pyte>=0.8.2
38
+ Requires-Dist: pyyaml>=6
39
+ Requires-Dist: structlog>=24
40
+ Requires-Dist: textual<1,>=0.85
41
+ Requires-Dist: tomli-w>=1.0
42
+ Provides-Extra: all
43
+ Requires-Dist: ollama>=0.4; extra == 'all'
44
+ Requires-Dist: openai>=1.50; extra == 'all'
45
+ Provides-Extra: dev
46
+ Requires-Dist: mypy>=1.13; extra == 'dev'
47
+ Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
48
+ Requires-Dist: pytest-cov>=5; extra == 'dev'
49
+ Requires-Dist: pytest-timeout>=2.3; extra == 'dev'
50
+ Requires-Dist: pytest>=8; extra == 'dev'
51
+ Requires-Dist: respx>=0.21; extra == 'dev'
52
+ Requires-Dist: ruff>=0.7; extra == 'dev'
53
+ Requires-Dist: types-pyyaml>=6; extra == 'dev'
54
+ Provides-Extra: ollama
55
+ Requires-Dist: ollama>=0.4; extra == 'ollama'
56
+ Provides-Extra: openai
57
+ Requires-Dist: openai>=1.50; extra == 'openai'
58
+ Description-Content-Type: text/markdown
59
+
60
+ # AI TUI Shell
61
+
62
+ > AI-integrated secure SSH terminal with SFTP, batch execution, and an auditable command policy engine.
63
+
64
+ AI TUI Shell is a local-first Python TUI for managing SSH sessions. It combines a true terminal emulator with SFTP file management, an AI assistant, batch command execution, and an auditable command-execution policy engine.
65
+
66
+ ## Features
67
+
68
+ - **SSH terminal** with full PTY, ANSI/256-color/truecolor, scrollback, and resizable splits
69
+ - **SFTP browser** with upload/download, resumable transfers, and chmod/chown
70
+ - **AI assistant** — Anthropic Claude (default), OpenAI-compatible, or local Ollama
71
+ - **Three policy modes** for command execution:
72
+ - `full_trust` — execute everything, audit only
73
+ - `ai_decides` — AI classifies risk, prompts when uncertain
74
+ - `strict` — every command requires user confirmation
75
+ - **Audit middleware** — pluggable HTTP gateway to third-party audit systems with two modes:
76
+ - `sync_pre_exec` — block command until audit approves
77
+ - `async_post_exec` — fire-and-forget audit after execution
78
+ - **Batch execution** — run a command template across N hosts with `${host}` / `${user}` / `${port}` / `${prompt:label}` placeholders and aggregated output
79
+ - **AI skills** — installable skill packs that constrain the tool set the AI may use
80
+ - **Credential storage** — OS keychain (Windows Credential Manager / macOS Keychain / Linux Secret Service); the database keeps only a reference
81
+ - **Tamper-evident audit log** — hash-chained `audit/policy.jsonl`
82
+
83
+ ## Quick Start
84
+
85
+ ```bash
86
+ # Create a project-local virtualenv (Python 3.11+ required)
87
+ python -m venv .venv
88
+
89
+ # Windows
90
+ .\.venv\Scripts\Activate.ps1
91
+ # macOS / Linux
92
+ source .venv/bin/activate
93
+
94
+ # Install (editable, with dev extras)
95
+ pip install -e ".[dev]"
96
+
97
+ # Launch the TUI (default command)
98
+ ashell
99
+
100
+ # Register a host (the CLI is the fastest way in)
101
+ ashell host add --label web1 --hostname 10.0.0.5 --username deploy
102
+ ashell host list
103
+ ashell host test web1
104
+
105
+ # Verify an audit log
106
+ ashell audit verify
107
+ ```
108
+
109
+ Credentials are stored in the OS keychain (Windows Credential Manager /
110
+ macOS Keychain / Linux Secret Service) — the database keeps only a reference.
111
+ Passwords are never accepted as a plain command-line value; use the
112
+ interactive prompt or `--password-stdin`. See `docs/usage.md` for details.
113
+
114
+ Full command surface: `ashell tui | audit verify | host add|list|remove|test |
115
+ skill add|list|show|remove | list-tools`.
116
+
117
+ ### Windows notes
118
+
119
+ - If `pip install` fails with "No matching distribution found", your configured
120
+ PyPI mirror may be unreachable. Install from PyPI directly:
121
+ `pip install -i https://pypi.org/simple -e ".[dev]"`
122
+ - In Git Bash / mintty, `isatty()` lies and `getpass` cannot hide input;
123
+ `host add` detects this and falls back to a visible prompt with a warning.
124
+ Use `--password-stdin` (or the TUI host manager) to keep the password off
125
+ the screen.
126
+ - A `NO_PROXY` entry containing a bracketed IPv6 literal (`[::1]`, written by
127
+ some proxy tools) crashes httpx 0.28.1 on the first HTTP request. AI TUI Shell
128
+ normalises this at startup; no manual workaround is needed.
129
+
130
+ ## Configuration
131
+
132
+ Configuration lives at:
133
+
134
+ | OS | Path |
135
+ |---|---|
136
+ | Windows | `%LOCALAPPDATA%\shellforge\shellforge\config.toml` |
137
+ | macOS | `~/Library/Application Support/shellforge/config.toml` |
138
+ | Linux | `$XDG_CONFIG_HOME/shellforge/config.toml` (or `~/.config/shellforge`) |
139
+
140
+ Runtime state (SQLite database, audit logs) lives under the matching
141
+ data/logs directories. See `config.example.toml` for the full schema.
142
+ Environment overrides: `SHELLFORGE_CONFIG_DIR`, `SHELLFORGE_DATA_DIR`,
143
+ `SHELLFORGE_LOGS_DIR`, `SHELLFORGE_CACHE_DIR`, `SHELLFORGE_LOG_LEVEL`,
144
+ `SHELLFORGE_AI_API_KEY`.
145
+
146
+ Type the API key into the TUI (Settings → AI); it is stored in the OS
147
+ keychain, one entry per provider, and never written to the config file.
148
+
149
+ ## Architecture
150
+
151
+ Single Python process; one asyncio event loop owned by the
152
+ **Textual** TUI (host app).
153
+
154
+ The per-session PTY reader, renderer (30 FPS), keepalive sender, and
155
+ async-audit poster are plain `asyncio` tasks. Cross-component
156
+ communication goes through `core/event_bus.py` only.
157
+
158
+ See `docs/architecture.md` for the full design and `docs/policy.md` for the command policy reference.
159
+
160
+ ## Verification
161
+
162
+ ```bash
163
+ # Unit tests (no Docker needed)
164
+ pytest tests/unit -p no:cacheprovider --timeout=30
165
+
166
+ # Integration tests spin up three sshd containers via docker-compose
167
+ docker compose -f tests/fixtures/docker-compose.yml up -d
168
+ pytest tests/integration -v
169
+ ```
170
+
171
+ `tests/e2e/` currently holds import-level smoke tests; scenarios that
172
+ drive the real TUI are planned for v0.2.
173
+
174
+ ## License
175
+
176
+ Proprietary. AI TUI Shell depends on `asyncssh` which is EPL-2.0 licensed; see `NOTICE` for attribution.
177
+
178
+ ## Status
179
+
180
+ Alpha (v0.1.0). See `docs/planning.md` for the milestone roadmap.
@@ -0,0 +1,121 @@
1
+ # AI TUI Shell
2
+
3
+ > AI-integrated secure SSH terminal with SFTP, batch execution, and an auditable command policy engine.
4
+
5
+ AI TUI Shell is a local-first Python TUI for managing SSH sessions. It combines a true terminal emulator with SFTP file management, an AI assistant, batch command execution, and an auditable command-execution policy engine.
6
+
7
+ ## Features
8
+
9
+ - **SSH terminal** with full PTY, ANSI/256-color/truecolor, scrollback, and resizable splits
10
+ - **SFTP browser** with upload/download, resumable transfers, and chmod/chown
11
+ - **AI assistant** — Anthropic Claude (default), OpenAI-compatible, or local Ollama
12
+ - **Three policy modes** for command execution:
13
+ - `full_trust` — execute everything, audit only
14
+ - `ai_decides` — AI classifies risk, prompts when uncertain
15
+ - `strict` — every command requires user confirmation
16
+ - **Audit middleware** — pluggable HTTP gateway to third-party audit systems with two modes:
17
+ - `sync_pre_exec` — block command until audit approves
18
+ - `async_post_exec` — fire-and-forget audit after execution
19
+ - **Batch execution** — run a command template across N hosts with `${host}` / `${user}` / `${port}` / `${prompt:label}` placeholders and aggregated output
20
+ - **AI skills** — installable skill packs that constrain the tool set the AI may use
21
+ - **Credential storage** — OS keychain (Windows Credential Manager / macOS Keychain / Linux Secret Service); the database keeps only a reference
22
+ - **Tamper-evident audit log** — hash-chained `audit/policy.jsonl`
23
+
24
+ ## Quick Start
25
+
26
+ ```bash
27
+ # Create a project-local virtualenv (Python 3.11+ required)
28
+ python -m venv .venv
29
+
30
+ # Windows
31
+ .\.venv\Scripts\Activate.ps1
32
+ # macOS / Linux
33
+ source .venv/bin/activate
34
+
35
+ # Install (editable, with dev extras)
36
+ pip install -e ".[dev]"
37
+
38
+ # Launch the TUI (default command)
39
+ ashell
40
+
41
+ # Register a host (the CLI is the fastest way in)
42
+ ashell host add --label web1 --hostname 10.0.0.5 --username deploy
43
+ ashell host list
44
+ ashell host test web1
45
+
46
+ # Verify an audit log
47
+ ashell audit verify
48
+ ```
49
+
50
+ Credentials are stored in the OS keychain (Windows Credential Manager /
51
+ macOS Keychain / Linux Secret Service) — the database keeps only a reference.
52
+ Passwords are never accepted as a plain command-line value; use the
53
+ interactive prompt or `--password-stdin`. See `docs/usage.md` for details.
54
+
55
+ Full command surface: `ashell tui | audit verify | host add|list|remove|test |
56
+ skill add|list|show|remove | list-tools`.
57
+
58
+ ### Windows notes
59
+
60
+ - If `pip install` fails with "No matching distribution found", your configured
61
+ PyPI mirror may be unreachable. Install from PyPI directly:
62
+ `pip install -i https://pypi.org/simple -e ".[dev]"`
63
+ - In Git Bash / mintty, `isatty()` lies and `getpass` cannot hide input;
64
+ `host add` detects this and falls back to a visible prompt with a warning.
65
+ Use `--password-stdin` (or the TUI host manager) to keep the password off
66
+ the screen.
67
+ - A `NO_PROXY` entry containing a bracketed IPv6 literal (`[::1]`, written by
68
+ some proxy tools) crashes httpx 0.28.1 on the first HTTP request. AI TUI Shell
69
+ normalises this at startup; no manual workaround is needed.
70
+
71
+ ## Configuration
72
+
73
+ Configuration lives at:
74
+
75
+ | OS | Path |
76
+ |---|---|
77
+ | Windows | `%LOCALAPPDATA%\shellforge\shellforge\config.toml` |
78
+ | macOS | `~/Library/Application Support/shellforge/config.toml` |
79
+ | Linux | `$XDG_CONFIG_HOME/shellforge/config.toml` (or `~/.config/shellforge`) |
80
+
81
+ Runtime state (SQLite database, audit logs) lives under the matching
82
+ data/logs directories. See `config.example.toml` for the full schema.
83
+ Environment overrides: `SHELLFORGE_CONFIG_DIR`, `SHELLFORGE_DATA_DIR`,
84
+ `SHELLFORGE_LOGS_DIR`, `SHELLFORGE_CACHE_DIR`, `SHELLFORGE_LOG_LEVEL`,
85
+ `SHELLFORGE_AI_API_KEY`.
86
+
87
+ Type the API key into the TUI (Settings → AI); it is stored in the OS
88
+ keychain, one entry per provider, and never written to the config file.
89
+
90
+ ## Architecture
91
+
92
+ Single Python process; one asyncio event loop owned by the
93
+ **Textual** TUI (host app).
94
+
95
+ The per-session PTY reader, renderer (30 FPS), keepalive sender, and
96
+ async-audit poster are plain `asyncio` tasks. Cross-component
97
+ communication goes through `core/event_bus.py` only.
98
+
99
+ See `docs/architecture.md` for the full design and `docs/policy.md` for the command policy reference.
100
+
101
+ ## Verification
102
+
103
+ ```bash
104
+ # Unit tests (no Docker needed)
105
+ pytest tests/unit -p no:cacheprovider --timeout=30
106
+
107
+ # Integration tests spin up three sshd containers via docker-compose
108
+ docker compose -f tests/fixtures/docker-compose.yml up -d
109
+ pytest tests/integration -v
110
+ ```
111
+
112
+ `tests/e2e/` currently holds import-level smoke tests; scenarios that
113
+ drive the real TUI are planned for v0.2.
114
+
115
+ ## License
116
+
117
+ Proprietary. AI TUI Shell depends on `asyncssh` which is EPL-2.0 licensed; see `NOTICE` for attribution.
118
+
119
+ ## Status
120
+
121
+ Alpha (v0.1.0). See `docs/planning.md` for the milestone roadmap.
@@ -0,0 +1,73 @@
1
+ # AI TUI Shell example configuration
2
+ # Copy to one of:
3
+ # Windows: %LOCALAPPDATA%\shellforge\shellforge\config.toml
4
+ # macOS: ~/Library/Application Support/shellforge/config.toml
5
+ # Linux: $XDG_CONFIG_HOME/shellforge/config.toml
6
+ #
7
+ # All sections are optional; defaults are documented in docs/configuration.md
8
+ # Day-to-day usage is documented in docs/usage.md
9
+
10
+ [app]
11
+ theme = "monokai" # 主题名,见 ui/theme.py 的 THEME_CATALOG
12
+ default_policy = "ai_decides" # full_trust | ai_decides | strict
13
+ log_level = "INFO" # DEBUG | INFO | WARNING | ERROR
14
+
15
+ [paths]
16
+ # config_dir = "" # overrides platformdirs default
17
+ # data_dir = ""
18
+ # logs_dir = ""
19
+ # cache_dir = ""
20
+
21
+ [ai]
22
+ provider = "anthropic" # anthropic | openai | ollama
23
+ model = "claude-sonnet-5"
24
+ # The API key itself is NOT in this file:
25
+ # type it into the TUI (Settings -> [AI] -> API key)
26
+ # and it is stored in the OS keychain, one entry
27
+ # per provider (ai:anthropic, ai:openai, ...)
28
+ base_url = "" # custom endpoint; blank = provider default
29
+ # e.g. "https://llm.internal/v1" for an
30
+ # OpenAI-compatible gateway
31
+ max_tokens = 4096
32
+ temperature = 0.2
33
+ reasoning_effort = "off" # off | low | medium | high — thinking
34
+ # intensity for models that support it
35
+ classify_timeout_seconds = 4.0
36
+ max_context_tokens = 60000
37
+ panel_width = 38 # AI side panel width in columns (24-120);
38
+ # drag the panel's left edge to change it
39
+ active_skill = "" # loaded AI skill; empty = default behaviour.
40
+ # See `ashell skill list`
41
+
42
+ [policy]
43
+ approval_cache_ttl_seconds = 600
44
+ static_allowlist_extra = []
45
+ static_denylist_extra = []
46
+ fail_safe_risk = 0.7
47
+ risky_operators = ["sudo", "ssh", "kubectl", "docker", "curl|bash", "rm -rf", "mkfs", "dd "]
48
+
49
+ [audit_middleware]
50
+ endpoint = "" # e.g. https://audit.corp.local/v1/decide;
51
+ # empty = the middleware is off
52
+ timeout_ms = 1500
53
+ cache_ttl_s = 300
54
+ fail_open_in_strict = false
55
+ auth_header_env = "" # env var containing "Bearer xxx"
56
+
57
+ [terminal]
58
+ renderer_fps = 30
59
+
60
+ [ssh]
61
+ keepalive_interval = 20
62
+ known_hosts = "" # default: ~/.ssh/known_hosts
63
+
64
+ [batch]
65
+ default_timeout_seconds = 30.0
66
+ default_max_concurrency = 8
67
+
68
+ # Per-host overrides (use the host label as key)
69
+ [host_overrides."prod-web-01"]
70
+ default_policy = "strict"
71
+
72
+ [host_overrides."dev-sandbox"]
73
+ default_policy = "ai_decides"