llm-secure-cli 1.0.1__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 (103) hide show
  1. llm_secure_cli-1.0.1/LICENSE +201 -0
  2. llm_secure_cli-1.0.1/PKG-INFO +219 -0
  3. llm_secure_cli-1.0.1/README.md +180 -0
  4. llm_secure_cli-1.0.1/llm_cli/__init__.py +0 -0
  5. llm_secure_cli-1.0.1/llm_cli/apps/__init__.py +0 -0
  6. llm_secure_cli-1.0.1/llm_cli/apps/cli_common.py +145 -0
  7. llm_secure_cli-1.0.1/llm_cli/apps/configure.py +433 -0
  8. llm_secure_cli-1.0.1/llm_cli/apps/identity_tool.py +71 -0
  9. llm_secure_cli-1.0.1/llm_cli/apps/mcp_server.py +168 -0
  10. llm_secure_cli-1.0.1/llm_cli/apps/model_listing.py +323 -0
  11. llm_secure_cli-1.0.1/llm_cli/apps/pqc_decrypt.py +66 -0
  12. llm_secure_cli-1.0.1/llm_cli/apps/unified.py +193 -0
  13. llm_secure_cli-1.0.1/llm_cli/clients/__init__.py +0 -0
  14. llm_secure_cli-1.0.1/llm_cli/clients/base.py +408 -0
  15. llm_secure_cli-1.0.1/llm_cli/clients/base_helpers.py +241 -0
  16. llm_secure_cli-1.0.1/llm_cli/clients/claude.py +209 -0
  17. llm_secure_cli-1.0.1/llm_cli/clients/command_handler.py +517 -0
  18. llm_secure_cli-1.0.1/llm_cli/clients/completer.py +94 -0
  19. llm_secure_cli-1.0.1/llm_cli/clients/config.py +203 -0
  20. llm_secure_cli-1.0.1/llm_cli/clients/config_models.py +140 -0
  21. llm_secure_cli-1.0.1/llm_cli/clients/exceptions.py +27 -0
  22. llm_secure_cli-1.0.1/llm_cli/clients/gemini.py +477 -0
  23. llm_secure_cli-1.0.1/llm_cli/clients/gemini_handlers.py +272 -0
  24. llm_secure_cli-1.0.1/llm_cli/clients/grok.py +430 -0
  25. llm_secure_cli-1.0.1/llm_cli/clients/managers.py +376 -0
  26. llm_secure_cli-1.0.1/llm_cli/clients/mcp_manager.py +244 -0
  27. llm_secure_cli-1.0.1/llm_cli/clients/ollama.py +200 -0
  28. llm_secure_cli-1.0.1/llm_cli/clients/openai.py +494 -0
  29. llm_secure_cli-1.0.1/llm_cli/clients/registry.py +85 -0
  30. llm_secure_cli-1.0.1/llm_cli/clients/session.py +533 -0
  31. llm_secure_cli-1.0.1/llm_cli/clients/session_ui.py +144 -0
  32. llm_secure_cli-1.0.1/llm_cli/clients/tool_executor.py +455 -0
  33. llm_secure_cli-1.0.1/llm_cli/consts.py +15 -0
  34. llm_secure_cli-1.0.1/llm_cli/mamba_core/__init__.py +0 -0
  35. llm_secure_cli-1.0.1/llm_cli/mamba_core/mamba_numpy.py +625 -0
  36. llm_secure_cli-1.0.1/llm_cli/mamba_core/utils.py +102 -0
  37. llm_secure_cli-1.0.1/llm_cli/mcp_lib.py +510 -0
  38. llm_secure_cli-1.0.1/llm_cli/modules/__init__.py +0 -0
  39. llm_secure_cli-1.0.1/llm_cli/modules/custom_markdown.py +46 -0
  40. llm_secure_cli-1.0.1/llm_cli/modules/media_utils.py +179 -0
  41. llm_secure_cli-1.0.1/llm_cli/modules/models.py +76 -0
  42. llm_secure_cli-1.0.1/llm_cli/modules/tool_registry.py +312 -0
  43. llm_secure_cli-1.0.1/llm_cli/modules/tools/__init__.py +0 -0
  44. llm_secure_cli-1.0.1/llm_cli/modules/tools/explorer.py +94 -0
  45. llm_secure_cli-1.0.1/llm_cli/modules/tools/file_ops.py +467 -0
  46. llm_secure_cli-1.0.1/llm_cli/modules/tools/interpreter.py +303 -0
  47. llm_secure_cli-1.0.1/llm_cli/modules/tools/web.py +89 -0
  48. llm_secure_cli-1.0.1/llm_cli/security/__init__.py +4 -0
  49. llm_secure_cli-1.0.1/llm_cli/security/audit.py +217 -0
  50. llm_secure_cli-1.0.1/llm_cli/security/cass.py +100 -0
  51. llm_secure_cli-1.0.1/llm_cli/security/identity.py +315 -0
  52. llm_secure_cli-1.0.1/llm_cli/security/integrity.py +581 -0
  53. llm_secure_cli-1.0.1/llm_cli/security/intent_analyzer.py +165 -0
  54. llm_secure_cli-1.0.1/llm_cli/security/path_validator.py +69 -0
  55. llm_secure_cli-1.0.1/llm_cli/security/policy.py +368 -0
  56. llm_secure_cli-1.0.1/llm_cli/security/pqc.py +475 -0
  57. llm_secure_cli-1.0.1/llm_cli/security/resource_manager.py +65 -0
  58. llm_secure_cli-1.0.1/llm_cli/security/sentinel.py +362 -0
  59. llm_secure_cli-1.0.1/llm_cli/security/static_analyzer.py +234 -0
  60. llm_secure_cli-1.0.1/llm_cli/ui.py +33 -0
  61. llm_secure_cli-1.0.1/llm_secure_cli.egg-info/PKG-INFO +219 -0
  62. llm_secure_cli-1.0.1/llm_secure_cli.egg-info/SOURCES.txt +101 -0
  63. llm_secure_cli-1.0.1/llm_secure_cli.egg-info/dependency_links.txt +1 -0
  64. llm_secure_cli-1.0.1/llm_secure_cli.egg-info/entry_points.txt +5 -0
  65. llm_secure_cli-1.0.1/llm_secure_cli.egg-info/requires.txt +26 -0
  66. llm_secure_cli-1.0.1/llm_secure_cli.egg-info/top_level.txt +1 -0
  67. llm_secure_cli-1.0.1/pyproject.toml +96 -0
  68. llm_secure_cli-1.0.1/setup.cfg +4 -0
  69. llm_secure_cli-1.0.1/tests/test_attachment.py +49 -0
  70. llm_secure_cli-1.0.1/tests/test_audio_support.py +119 -0
  71. llm_secure_cli-1.0.1/tests/test_claude_client.py +254 -0
  72. llm_secure_cli-1.0.1/tests/test_cli_args.py +52 -0
  73. llm_secure_cli-1.0.1/tests/test_clients_mcp_manager.py +60 -0
  74. llm_secure_cli-1.0.1/tests/test_configure_utils.py +36 -0
  75. llm_secure_cli-1.0.1/tests/test_conversation_history.py +90 -0
  76. llm_secure_cli-1.0.1/tests/test_edit_file_fuzzy.py +122 -0
  77. llm_secure_cli-1.0.1/tests/test_explorer.py +116 -0
  78. llm_secure_cli-1.0.1/tests/test_file_ops.py +82 -0
  79. llm_secure_cli-1.0.1/tests/test_gemini_features.py +61 -0
  80. llm_secure_cli-1.0.1/tests/test_grok_image.py +123 -0
  81. llm_secure_cli-1.0.1/tests/test_grok_video.py +143 -0
  82. llm_secure_cli-1.0.1/tests/test_interpreter.py +70 -0
  83. llm_secure_cli-1.0.1/tests/test_log_trimming.py +46 -0
  84. llm_secure_cli-1.0.1/tests/test_mamba_math.py +188 -0
  85. llm_secure_cli-1.0.1/tests/test_mcp_lib.py +318 -0
  86. llm_secure_cli-1.0.1/tests/test_mcp_server.py +176 -0
  87. llm_secure_cli-1.0.1/tests/test_mcp_tracing.py +109 -0
  88. llm_secure_cli-1.0.1/tests/test_ollama_client.py +97 -0
  89. llm_secure_cli-1.0.1/tests/test_openai_client.py +451 -0
  90. llm_secure_cli-1.0.1/tests/test_openai_image.py +123 -0
  91. llm_secure_cli-1.0.1/tests/test_path_validator.py +53 -0
  92. llm_secure_cli-1.0.1/tests/test_path_validator_advanced.py +49 -0
  93. llm_secure_cli-1.0.1/tests/test_pdf_processing.py +112 -0
  94. llm_secure_cli-1.0.1/tests/test_pqc.py +225 -0
  95. llm_secure_cli-1.0.1/tests/test_reasoning_anomaly.py +88 -0
  96. llm_secure_cli-1.0.1/tests/test_search_files.py +75 -0
  97. llm_secure_cli-1.0.1/tests/test_session_and_executor.py +214 -0
  98. llm_secure_cli-1.0.1/tests/test_static_analyzer.py +68 -0
  99. llm_secure_cli-1.0.1/tests/test_stdout_conflicts.py +74 -0
  100. llm_secure_cli-1.0.1/tests/test_tool_registry_consistency.py +101 -0
  101. llm_secure_cli-1.0.1/tests/test_unified_provider_switching.py +89 -0
  102. llm_secure_cli-1.0.1/tests/test_web_tools.py +107 -0
  103. llm_secure_cli-1.0.1/tests/test_zero_trust.py +177 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: llm-secure-cli
3
+ Version: 1.0.1
4
+ Summary: A Unified Command-Line Interface for Multiple LLMs
5
+ Author-email: Yoshihiro Ando <yosh5295@gmail.com>
6
+ License: Apache License 2.0
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: curl_cffi>=0.15.0b2
15
+ Requires-Dist: filetype
16
+ Requires-Dist: markdownify
17
+ Requires-Dist: prompt-toolkit
18
+ Requires-Dist: pdfplumber
19
+ Requires-Dist: requests
20
+ Requires-Dist: rich
21
+ Requires-Dist: tomli-w
22
+ Requires-Dist: PyJWT[crypto]
23
+ Requires-Dist: cryptography>=46.0.0
24
+ Requires-Dist: dilithium-py
25
+ Requires-Dist: kyber-py
26
+ Requires-Dist: numpy
27
+ Requires-Dist: psutil
28
+ Provides-Extra: test
29
+ Requires-Dist: pytest; extra == "test"
30
+ Requires-Dist: pytest-asyncio; extra == "test"
31
+ Requires-Dist: pytest-mock; extra == "test"
32
+ Requires-Dist: pytest-cov; extra == "test"
33
+ Requires-Dist: types-requests; extra == "test"
34
+ Requires-Dist: types-setuptools; extra == "test"
35
+ Provides-Extra: dev
36
+ Requires-Dist: mypy; extra == "dev"
37
+ Requires-Dist: ruff; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # llm-cli: A Unified Terminal Interface for Multiple LLMs
41
+
42
+ ![CI](https://github.com/yosh95/llm-cli/actions/workflows/ci.yml/badge.svg?branch=main)
43
+
44
+ `llm-cli` is a high-assurance command-line tool designed for interacting with Large Language Models (LLMs). It provides a unified, stable interface for Gemini, OpenAI, Claude, xAI, and local models via Ollama, prioritizing cognitive focus, secure execution, and extensible automation.
45
+
46
+ [English] | [日本語](#japanese-description)
47
+
48
+ <p align="center">
49
+ <img src="images/architecture_diagram_en.png" width="800" alt="llm-cli Architecture & Security Guardrails" />
50
+ </p>
51
+
52
+ ---
53
+
54
+ ## 🚀 Quick Start
55
+
56
+ 1. **Install**:
57
+ ```bash
58
+ git clone https://github.com/yosh95/llm-cli.git
59
+ cd llm-cli
60
+ pip install .
61
+ ```
62
+ 2. **Configure**: Run `llm-cli-config` to set your API keys (e.g., Gemini) or Ollama URL.
63
+ 3. **Chat**: Type `llm-cli` to start an interactive session.
64
+ 4. **Help**: Type `/help` inside the chat to see all commands.
65
+
66
+ ### One-Shot Examples
67
+ ```bash
68
+ # Ask a question using the default provider (e.g., Gemini)
69
+ llm-cli "What is the capital of France?"
70
+
71
+ # Use a local model via Ollama
72
+ llm-cli -p ollama -m llama3 "Explain quantum computing"
73
+
74
+ # Analyze a local file or a URL
75
+ llm-cli "Summarize this PDF" ./document.pdf
76
+ llm-cli "Analyze this website" https://example.com
77
+ ```
78
+
79
+ ## ✨ Core Features (Product Ready)
80
+
81
+ - **Unified Provider Access**: Seamlessly switch between Google (Gemini), OpenAI, Anthropic (Claude), xAI (Grok), and **Local LLMs (Ollama)**.
82
+ - **Autonomous Agent**: Let the AI manage files, execute Python code (replacing risky shell commands), and search the web.
83
+ - **MCP (Model Context Protocol) Support**: Connect to remote resources or services. Manage files on remote servers via SSH or integrate with third-party tools via Docker.
84
+ - **Multimodal capabilities**: Support for Images, PDFs, Audio, and Video.
85
+ - **Operational Stability**: A clean, flicker-free UI designed for long-term "Deep Work" sessions and SSH-based environments.
86
+ - **Human-in-the-Loop**: All critical actions (file edits, code execution) require explicit human approval by default.
87
+
88
+ ### 🤖 Autonomous Agent & Tool Use
89
+ The AI agent autonomously uses tools to perform complex tasks, such as understanding project structures before editing code.
90
+
91
+ <p align="center">
92
+ <img src="images/screenshot-tool-calling.png" width="800" alt="Autonomous Agent and Tool Use" />
93
+ </p>
94
+
95
+ ---
96
+
97
+ ## 🛡️ Security & Governance (High-Assurance Framework)
98
+
99
+ As a tool designed with **CISSP/CISA/CCSP** principles and **EU AI Act** compliance in mind, `llm-cli` implements a multi-layered security architecture to mitigate the risks associated with autonomous AI agents.
100
+
101
+ ### 1. Execution Security & Isolation
102
+ - **No-Shell Architecture**: To prevent command injection, system interactions are performed via Python execution with `shell=False`.
103
+ - **Sandboxing (Linux)**: Optional isolation using `bubblewrap` to contain the AI's execution environment.
104
+ - **Explanation Enforcement**: Every tool automatically mandates an `explanation` parameter, forcing the LLM to justify its intent in natural language before execution.
105
+ - **Static Analysis**: Pre-execution scanning of AI-generated code for suspicious imports or risky patterns.
106
+
107
+ ### 2. Identity & Non-Repudiation (Post-Quantum Ready)
108
+ - **Hybrid Identity Tokens**: Uses **RS256** combined with **Post-Quantum Cryptography (ML-DSA)** to sign tool execution requests, ensuring long-term non-repudiation.
109
+ - **Client Integrity Attestation**: The client generates a signed manifest of its own source code state to prove the integrity of the execution environment.
110
+ - **Bi-directional Verification**: Tool results are signed by the client, allowing the LLM to verify that the observations it receives are authentic and untampered.
111
+
112
+ ### 3. Observability & Anomaly Detection
113
+ - **Reasoning Sentinel (SSM-based)**: A built-in **Mamba (State Space Model)** implementation monitors the LLM's reasoning tokens in real-time. It detects statistical anomalies that may indicate prompt injection or "model hallucination" leading to risky behavior.
114
+ - **Tamper-Evident Audit Logs**: Audit trails are protected using **Chained Hashing** and optionally encrypted with **ML-KEM (Kyber)** for confidentiality.
115
+ - **Merkle Tree Anchoring**: Log batches are anchored via Merkle Roots to prevent historical revisionism.
116
+
117
+ ### 4. Regulatory Alignment (EU AI Act)
118
+ `llm-cli` provides technical controls aligned with the obligations of a **GPAI (General Purpose AI) Deployer**:
119
+ - **Transparency**: Clear explanation of AI-driven actions and reasoning integrity scores.
120
+ - **Robustness**: Real-time monitoring and anomaly detection.
121
+ - **Accountability**: Cryptographically signed audit trails for forensic analysis.
122
+
123
+ ---
124
+
125
+ ## 📖 Advanced Commands & Power User Tips
126
+
127
+ Inside the `llm-cli` interactive session:
128
+ - `/help`: Display all available commands.
129
+ - `/p <provider>` / `/m <model>`: Switch the AI engine on the fly.
130
+ - `/attach <path/URL>`: Add a file or website content to the context.
131
+ - `/tools on|off`: Enable/disable autonomous tool use.
132
+ - `/i`: Show session integrity and Reasoning Sentinel (anomaly) scores.
133
+ - `/save` / `/load`: Manage conversation history.
134
+ - `/cp`: Checkpoint (Summarize and clear history).
135
+ - `/mcp`: Toggle or manage MCP server integrations.
136
+
137
+ ### 💡 Power User Tips
138
+ - **Backgrounding (`Ctrl+Z`)**: Suspend the session to perform shell operations, then use `fg` to return.
139
+ - **External Editor (`Ctrl+X, Ctrl+E`)**: Open the current prompt in your default editor (`vim`, `nano`, etc.) for complex editing.
140
+ - **Templates**: Define reusable prompts in `~/.config/llm_cli/config.toml` and call them with `/t <name>`.
141
+
142
+ ## 🔑 Security Management
143
+ Use the `llm-cli-security` tool to manage your cryptographic identity:
144
+ ```bash
145
+ llm-cli-security keygen # Generate RSA and PQC (ML-DSA/ML-KEM) keys
146
+ llm-cli-security manifest # Rebuild integrity manifest for remote attestation
147
+ llm-cli-security decrypt-log ~/.llm_cli/audit.jsonl -o decrypted.jsonl
148
+ ```
149
+
150
+ ## 📜 License
151
+ Licensed under [Apache License 2.0](LICENSE).
152
+
153
+ For detailed architectural insights and the academic background of our security framework, please refer to the **[Technical Report (Pre-print)](paper/comprehensive_framework/paper.pdf)**.
154
+
155
+ ---
156
+
157
+ <a id="japanese-description"></a>
158
+
159
+ # llm-cli: 複数LLM対応 統合コマンドラインインターフェース
160
+
161
+ `llm-cli` は、Gemini, OpenAI, Claude, Grok、および Ollama を介したローカルLLMを一元的に操作できる、高い安全性を備えたCLIツールです。開発者の「深い集中(Deep Work)」を妨げない安定した対話環境と、プロフェッショナルな要求に応える高度なセキュリティ機能を両立しています。
162
+
163
+ <p align="center">
164
+ <img src="images/architecture_diagram_ja.png" width="800" alt="llm-cli アーキテクチャと多層防御" />
165
+ </p>
166
+
167
+ ## 🚀 クイックスタート
168
+
169
+ 1. **インストール**:
170
+ ```bash
171
+ git clone https://github.com/yosh95/llm-cli.git
172
+ cd llm-cli
173
+ pip install .
174
+ ```
175
+ 2. **初期設定**: `llm-cli-config` を実行し、GeminiなどのAPIキーやOllamaのURLを設定。
176
+ 3. **対話開始**: `llm-cli` コマンドでスタート。
177
+ 4. **ヘルプ**: チャット内で `/help` と入力するとコマンド一覧が表示されます。
178
+
179
+ ## ✨ 主な機能 (実用ツールとして)
180
+
181
+ - **統合インターフェース**: `llm-cli` コマンド一つで主要なクラウドLLMと **Ollama (Local)** にアクセス。
182
+ - **自律型エージェント**: ファイル操作、Python実行、Web検索、URL解析をAIが自律的に実行。
183
+ - **MCP (Model Context Protocol) 対応**: リモートサーバーや外部サービスとの連携をサポート。
184
+ - **マルチモーダル対応**: 画像、PDF、音声、動画の入力をサポート。画像・動画の生成も可能。
185
+ - **集中力を削がないUI**: 画面のちらつきを抑え、SSH越しでも安定して動作するクリーンなターミナル出力。
186
+
187
+ ### 🤖 自律型エージェントのツール実行
188
+ AIがディレクトリ構造を確認し、コードを読み取ってから作業を行う様子。
189
+
190
+ <p align="center">
191
+ <img src="images/screenshot-tool-calling.png" width="800" alt="自律型エージェントのツール実行" />
192
+ </p>
193
+
194
+ ## 🛡️ セキュリティとガバナンス (プロフェッショナル向け)
195
+
196
+ 本ツールは **CISSP/CISA/CCSP** の各ドメインにおける管理策、および **EU AI Act(欧州AI法)** の技術的要件を意識して設計されています。
197
+
198
+ ### 1. 実行環境の安全性と隔離
199
+ - **No-Shell アーキテクチャ**: システム操作は `shell=False` のPython実行に限定。シェルインジェクションを構造的に防止。
200
+ - **サンドボックス**: Linux環境では `bubblewrap` によるプロセスの隔離が可能です。
201
+ - **Human-in-the-Loop**: 全てのツール実行に AI による意図の説明を強制し、人間の承認を介するワークフローを提供。
202
+
203
+ ### 2. アイデンティティと非否認性 (耐量子暗号)
204
+ - **ハイブリッド署名**: **RS256** と **耐量子暗号 (ML-DSA)** を組み合わせ、ツール実行リクエストの正当性を長期的に保証(非否認性)。
205
+ - **完全性検証**: クライアント自身のソースコードの状態を署名付きマニフェストで証明し、実行環境の健全性を担保。
206
+
207
+ ### 3. 観測可能性と異常検知
208
+ - **推論異常モニタ (Reasoning Sentinel)**: **Mamba (SSM)** の実装により、LLMの推論プロセスをリアルタイム監視。プロンプトインジェクション等による統計的異常を検知。
209
+ - **改ざん防止監査ログ**: ハッシュ連鎖(Chained Hashing)によるログ保護と、**ML-KEM (Kyber)** による機密性保護。
210
+
211
+ ### 💡 パワーユーザー向け機能
212
+ - **一時中断 (`Ctrl+Z`)**: セッションをバックグラウンドに送り、シェルに戻る。`fg` で復帰可能。
213
+ - **外部エディタ編集 (`Ctrl+X, Ctrl+E`)**: プロンプト入力を `vim` や `nano` で編集。
214
+ - **テンプレート**: 頻繁に使うプロンプトを設定ファイルに定義し、`/t <名前>` で呼び出し。
215
+
216
+ ---
217
+
218
+ ## 📜 ライセンス
219
+ [Apache License 2.0](LICENSE) に基づき公開されています。技術的な詳細については [テクニカルレポート](paper/comprehensive_framework/paper.pdf) を参照してください。
@@ -0,0 +1,180 @@
1
+ # llm-cli: A Unified Terminal Interface for Multiple LLMs
2
+
3
+ ![CI](https://github.com/yosh95/llm-cli/actions/workflows/ci.yml/badge.svg?branch=main)
4
+
5
+ `llm-cli` is a high-assurance command-line tool designed for interacting with Large Language Models (LLMs). It provides a unified, stable interface for Gemini, OpenAI, Claude, xAI, and local models via Ollama, prioritizing cognitive focus, secure execution, and extensible automation.
6
+
7
+ [English] | [日本語](#japanese-description)
8
+
9
+ <p align="center">
10
+ <img src="images/architecture_diagram_en.png" width="800" alt="llm-cli Architecture & Security Guardrails" />
11
+ </p>
12
+
13
+ ---
14
+
15
+ ## 🚀 Quick Start
16
+
17
+ 1. **Install**:
18
+ ```bash
19
+ git clone https://github.com/yosh95/llm-cli.git
20
+ cd llm-cli
21
+ pip install .
22
+ ```
23
+ 2. **Configure**: Run `llm-cli-config` to set your API keys (e.g., Gemini) or Ollama URL.
24
+ 3. **Chat**: Type `llm-cli` to start an interactive session.
25
+ 4. **Help**: Type `/help` inside the chat to see all commands.
26
+
27
+ ### One-Shot Examples
28
+ ```bash
29
+ # Ask a question using the default provider (e.g., Gemini)
30
+ llm-cli "What is the capital of France?"
31
+
32
+ # Use a local model via Ollama
33
+ llm-cli -p ollama -m llama3 "Explain quantum computing"
34
+
35
+ # Analyze a local file or a URL
36
+ llm-cli "Summarize this PDF" ./document.pdf
37
+ llm-cli "Analyze this website" https://example.com
38
+ ```
39
+
40
+ ## ✨ Core Features (Product Ready)
41
+
42
+ - **Unified Provider Access**: Seamlessly switch between Google (Gemini), OpenAI, Anthropic (Claude), xAI (Grok), and **Local LLMs (Ollama)**.
43
+ - **Autonomous Agent**: Let the AI manage files, execute Python code (replacing risky shell commands), and search the web.
44
+ - **MCP (Model Context Protocol) Support**: Connect to remote resources or services. Manage files on remote servers via SSH or integrate with third-party tools via Docker.
45
+ - **Multimodal capabilities**: Support for Images, PDFs, Audio, and Video.
46
+ - **Operational Stability**: A clean, flicker-free UI designed for long-term "Deep Work" sessions and SSH-based environments.
47
+ - **Human-in-the-Loop**: All critical actions (file edits, code execution) require explicit human approval by default.
48
+
49
+ ### 🤖 Autonomous Agent & Tool Use
50
+ The AI agent autonomously uses tools to perform complex tasks, such as understanding project structures before editing code.
51
+
52
+ <p align="center">
53
+ <img src="images/screenshot-tool-calling.png" width="800" alt="Autonomous Agent and Tool Use" />
54
+ </p>
55
+
56
+ ---
57
+
58
+ ## 🛡️ Security & Governance (High-Assurance Framework)
59
+
60
+ As a tool designed with **CISSP/CISA/CCSP** principles and **EU AI Act** compliance in mind, `llm-cli` implements a multi-layered security architecture to mitigate the risks associated with autonomous AI agents.
61
+
62
+ ### 1. Execution Security & Isolation
63
+ - **No-Shell Architecture**: To prevent command injection, system interactions are performed via Python execution with `shell=False`.
64
+ - **Sandboxing (Linux)**: Optional isolation using `bubblewrap` to contain the AI's execution environment.
65
+ - **Explanation Enforcement**: Every tool automatically mandates an `explanation` parameter, forcing the LLM to justify its intent in natural language before execution.
66
+ - **Static Analysis**: Pre-execution scanning of AI-generated code for suspicious imports or risky patterns.
67
+
68
+ ### 2. Identity & Non-Repudiation (Post-Quantum Ready)
69
+ - **Hybrid Identity Tokens**: Uses **RS256** combined with **Post-Quantum Cryptography (ML-DSA)** to sign tool execution requests, ensuring long-term non-repudiation.
70
+ - **Client Integrity Attestation**: The client generates a signed manifest of its own source code state to prove the integrity of the execution environment.
71
+ - **Bi-directional Verification**: Tool results are signed by the client, allowing the LLM to verify that the observations it receives are authentic and untampered.
72
+
73
+ ### 3. Observability & Anomaly Detection
74
+ - **Reasoning Sentinel (SSM-based)**: A built-in **Mamba (State Space Model)** implementation monitors the LLM's reasoning tokens in real-time. It detects statistical anomalies that may indicate prompt injection or "model hallucination" leading to risky behavior.
75
+ - **Tamper-Evident Audit Logs**: Audit trails are protected using **Chained Hashing** and optionally encrypted with **ML-KEM (Kyber)** for confidentiality.
76
+ - **Merkle Tree Anchoring**: Log batches are anchored via Merkle Roots to prevent historical revisionism.
77
+
78
+ ### 4. Regulatory Alignment (EU AI Act)
79
+ `llm-cli` provides technical controls aligned with the obligations of a **GPAI (General Purpose AI) Deployer**:
80
+ - **Transparency**: Clear explanation of AI-driven actions and reasoning integrity scores.
81
+ - **Robustness**: Real-time monitoring and anomaly detection.
82
+ - **Accountability**: Cryptographically signed audit trails for forensic analysis.
83
+
84
+ ---
85
+
86
+ ## 📖 Advanced Commands & Power User Tips
87
+
88
+ Inside the `llm-cli` interactive session:
89
+ - `/help`: Display all available commands.
90
+ - `/p <provider>` / `/m <model>`: Switch the AI engine on the fly.
91
+ - `/attach <path/URL>`: Add a file or website content to the context.
92
+ - `/tools on|off`: Enable/disable autonomous tool use.
93
+ - `/i`: Show session integrity and Reasoning Sentinel (anomaly) scores.
94
+ - `/save` / `/load`: Manage conversation history.
95
+ - `/cp`: Checkpoint (Summarize and clear history).
96
+ - `/mcp`: Toggle or manage MCP server integrations.
97
+
98
+ ### 💡 Power User Tips
99
+ - **Backgrounding (`Ctrl+Z`)**: Suspend the session to perform shell operations, then use `fg` to return.
100
+ - **External Editor (`Ctrl+X, Ctrl+E`)**: Open the current prompt in your default editor (`vim`, `nano`, etc.) for complex editing.
101
+ - **Templates**: Define reusable prompts in `~/.config/llm_cli/config.toml` and call them with `/t <name>`.
102
+
103
+ ## 🔑 Security Management
104
+ Use the `llm-cli-security` tool to manage your cryptographic identity:
105
+ ```bash
106
+ llm-cli-security keygen # Generate RSA and PQC (ML-DSA/ML-KEM) keys
107
+ llm-cli-security manifest # Rebuild integrity manifest for remote attestation
108
+ llm-cli-security decrypt-log ~/.llm_cli/audit.jsonl -o decrypted.jsonl
109
+ ```
110
+
111
+ ## 📜 License
112
+ Licensed under [Apache License 2.0](LICENSE).
113
+
114
+ For detailed architectural insights and the academic background of our security framework, please refer to the **[Technical Report (Pre-print)](paper/comprehensive_framework/paper.pdf)**.
115
+
116
+ ---
117
+
118
+ <a id="japanese-description"></a>
119
+
120
+ # llm-cli: 複数LLM対応 統合コマンドラインインターフェース
121
+
122
+ `llm-cli` は、Gemini, OpenAI, Claude, Grok、および Ollama を介したローカルLLMを一元的に操作できる、高い安全性を備えたCLIツールです。開発者の「深い集中(Deep Work)」を妨げない安定した対話環境と、プロフェッショナルな要求に応える高度なセキュリティ機能を両立しています。
123
+
124
+ <p align="center">
125
+ <img src="images/architecture_diagram_ja.png" width="800" alt="llm-cli アーキテクチャと多層防御" />
126
+ </p>
127
+
128
+ ## 🚀 クイックスタート
129
+
130
+ 1. **インストール**:
131
+ ```bash
132
+ git clone https://github.com/yosh95/llm-cli.git
133
+ cd llm-cli
134
+ pip install .
135
+ ```
136
+ 2. **初期設定**: `llm-cli-config` を実行し、GeminiなどのAPIキーやOllamaのURLを設定。
137
+ 3. **対話開始**: `llm-cli` コマンドでスタート。
138
+ 4. **ヘルプ**: チャット内で `/help` と入力するとコマンド一覧が表示されます。
139
+
140
+ ## ✨ 主な機能 (実用ツールとして)
141
+
142
+ - **統合インターフェース**: `llm-cli` コマンド一つで主要なクラウドLLMと **Ollama (Local)** にアクセス。
143
+ - **自律型エージェント**: ファイル操作、Python実行、Web検索、URL解析をAIが自律的に実行。
144
+ - **MCP (Model Context Protocol) 対応**: リモートサーバーや外部サービスとの連携をサポート。
145
+ - **マルチモーダル対応**: 画像、PDF、音声、動画の入力をサポート。画像・動画の生成も可能。
146
+ - **集中力を削がないUI**: 画面のちらつきを抑え、SSH越しでも安定して動作するクリーンなターミナル出力。
147
+
148
+ ### 🤖 自律型エージェントのツール実行
149
+ AIがディレクトリ構造を確認し、コードを読み取ってから作業を行う様子。
150
+
151
+ <p align="center">
152
+ <img src="images/screenshot-tool-calling.png" width="800" alt="自律型エージェントのツール実行" />
153
+ </p>
154
+
155
+ ## 🛡️ セキュリティとガバナンス (プロフェッショナル向け)
156
+
157
+ 本ツールは **CISSP/CISA/CCSP** の各ドメインにおける管理策、および **EU AI Act(欧州AI法)** の技術的要件を意識して設計されています。
158
+
159
+ ### 1. 実行環境の安全性と隔離
160
+ - **No-Shell アーキテクチャ**: システム操作は `shell=False` のPython実行に限定。シェルインジェクションを構造的に防止。
161
+ - **サンドボックス**: Linux環境では `bubblewrap` によるプロセスの隔離が可能です。
162
+ - **Human-in-the-Loop**: 全てのツール実行に AI による意図の説明を強制し、人間の承認を介するワークフローを提供。
163
+
164
+ ### 2. アイデンティティと非否認性 (耐量子暗号)
165
+ - **ハイブリッド署名**: **RS256** と **耐量子暗号 (ML-DSA)** を組み合わせ、ツール実行リクエストの正当性を長期的に保証(非否認性)。
166
+ - **完全性検証**: クライアント自身のソースコードの状態を署名付きマニフェストで証明し、実行環境の健全性を担保。
167
+
168
+ ### 3. 観測可能性と異常検知
169
+ - **推論異常モニタ (Reasoning Sentinel)**: **Mamba (SSM)** の実装により、LLMの推論プロセスをリアルタイム監視。プロンプトインジェクション等による統計的異常を検知。
170
+ - **改ざん防止監査ログ**: ハッシュ連鎖(Chained Hashing)によるログ保護と、**ML-KEM (Kyber)** による機密性保護。
171
+
172
+ ### 💡 パワーユーザー向け機能
173
+ - **一時中断 (`Ctrl+Z`)**: セッションをバックグラウンドに送り、シェルに戻る。`fg` で復帰可能。
174
+ - **外部エディタ編集 (`Ctrl+X, Ctrl+E`)**: プロンプト入力を `vim` や `nano` で編集。
175
+ - **テンプレート**: 頻繁に使うプロンプトを設定ファイルに定義し、`/t <名前>` で呼び出し。
176
+
177
+ ---
178
+
179
+ ## 📜 ライセンス
180
+ [Apache License 2.0](LICENSE) に基づき公開されています。技術的な詳細については [テクニカルレポート](paper/comprehensive_framework/paper.pdf) を参照してください。
File without changes
File without changes