agent-sory 1.0.0
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.
- package/LICENSE +21 -0
- package/README.md +265 -0
- package/dist/commands/base.d.ts +26 -0
- package/dist/commands/base.d.ts.map +1 -0
- package/dist/commands/base.js +3 -0
- package/dist/commands/base.js.map +1 -0
- package/dist/commands/definitions/clear.d.ts +3 -0
- package/dist/commands/definitions/clear.d.ts.map +1 -0
- package/dist/commands/definitions/clear.js +12 -0
- package/dist/commands/definitions/clear.js.map +1 -0
- package/dist/commands/definitions/help.d.ts +3 -0
- package/dist/commands/definitions/help.d.ts.map +1 -0
- package/dist/commands/definitions/help.js +28 -0
- package/dist/commands/definitions/help.js.map +1 -0
- package/dist/commands/definitions/init.d.ts +3 -0
- package/dist/commands/definitions/init.d.ts.map +1 -0
- package/dist/commands/definitions/init.js +23 -0
- package/dist/commands/definitions/init.js.map +1 -0
- package/dist/commands/definitions/login.d.ts +3 -0
- package/dist/commands/definitions/login.d.ts.map +1 -0
- package/dist/commands/definitions/login.js +8 -0
- package/dist/commands/definitions/login.js.map +1 -0
- package/dist/commands/definitions/model.d.ts +3 -0
- package/dist/commands/definitions/model.d.ts.map +1 -0
- package/dist/commands/definitions/model.js +10 -0
- package/dist/commands/definitions/model.js.map +1 -0
- package/dist/commands/definitions/reasoning.d.ts +3 -0
- package/dist/commands/definitions/reasoning.d.ts.map +1 -0
- package/dist/commands/definitions/reasoning.js +21 -0
- package/dist/commands/definitions/reasoning.js.map +1 -0
- package/dist/commands/definitions/stats.d.ts +3 -0
- package/dist/commands/definitions/stats.d.ts.map +1 -0
- package/dist/commands/definitions/stats.js +22 -0
- package/dist/commands/definitions/stats.js.map +1 -0
- package/dist/commands/index.d.ts +6 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +38 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/core/agent.d.ts +41 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/agent.js +266 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/cli.d.ts +3 -0
- package/dist/core/cli.d.ts.map +1 -0
- package/dist/core/cli.js +48 -0
- package/dist/core/cli.js.map +1 -0
- package/dist/core/llm/factory.d.ts +12 -0
- package/dist/core/llm/factory.d.ts.map +1 -0
- package/dist/core/llm/factory.js +44 -0
- package/dist/core/llm/factory.js.map +1 -0
- package/dist/core/llm/providers/gemini.d.ts +22 -0
- package/dist/core/llm/providers/gemini.d.ts.map +1 -0
- package/dist/core/llm/providers/gemini.js +167 -0
- package/dist/core/llm/providers/gemini.js.map +1 -0
- package/dist/core/llm/providers/groq.d.ts +23 -0
- package/dist/core/llm/providers/groq.d.ts.map +1 -0
- package/dist/core/llm/providers/groq.js +96 -0
- package/dist/core/llm/providers/groq.js.map +1 -0
- package/dist/core/llm/providers/openai-compatible.d.ts +24 -0
- package/dist/core/llm/providers/openai-compatible.d.ts.map +1 -0
- package/dist/core/llm/providers/openai-compatible.js +86 -0
- package/dist/core/llm/providers/openai-compatible.js.map +1 -0
- package/dist/core/llm/types.d.ts +37 -0
- package/dist/core/llm/types.d.ts.map +1 -0
- package/dist/core/llm/types.js +2 -0
- package/dist/core/llm/types.js.map +1 -0
- package/dist/core/prompts/system.d.ts +6 -0
- package/dist/core/prompts/system.d.ts.map +1 -0
- package/dist/core/prompts/system.js +36 -0
- package/dist/core/prompts/system.js.map +1 -0
- package/dist/tests/proxy-config.test.d.ts +2 -0
- package/dist/tests/proxy-config.test.d.ts.map +1 -0
- package/dist/tests/proxy-config.test.js +169 -0
- package/dist/tests/proxy-config.test.js.map +1 -0
- package/dist/tools/tool-schemas.d.ts +36 -0
- package/dist/tools/tool-schemas.d.ts.map +1 -0
- package/dist/tools/tool-schemas.js +482 -0
- package/dist/tools/tool-schemas.js.map +1 -0
- package/dist/tools/tools.d.ts +114 -0
- package/dist/tools/tools.d.ts.map +1 -0
- package/dist/tools/tools.js +1015 -0
- package/dist/tools/tools.js.map +1 -0
- package/dist/tools/utils/edit-logic.d.ts +9 -0
- package/dist/tools/utils/edit-logic.d.ts.map +1 -0
- package/dist/tools/utils/edit-logic.js +149 -0
- package/dist/tools/utils/edit-logic.js.map +1 -0
- package/dist/tools/utils/ripgrep-runner.d.ts +15 -0
- package/dist/tools/utils/ripgrep-runner.d.ts.map +1 -0
- package/dist/tools/utils/ripgrep-runner.js +90 -0
- package/dist/tools/utils/ripgrep-runner.js.map +1 -0
- package/dist/tools/validators.d.ts +4 -0
- package/dist/tools/validators.d.ts.map +1 -0
- package/dist/tools/validators.js +18 -0
- package/dist/tools/validators.js.map +1 -0
- package/dist/ui/App.d.ts +7 -0
- package/dist/ui/App.d.ts.map +1 -0
- package/dist/ui/App.js +12 -0
- package/dist/ui/App.js.map +1 -0
- package/dist/ui/components/core/Chat.d.ts +7 -0
- package/dist/ui/components/core/Chat.d.ts.map +1 -0
- package/dist/ui/components/core/Chat.js +60 -0
- package/dist/ui/components/core/Chat.js.map +1 -0
- package/dist/ui/components/core/MessageHistory.d.ts +7 -0
- package/dist/ui/components/core/MessageHistory.d.ts.map +1 -0
- package/dist/ui/components/core/MessageHistory.js +39 -0
- package/dist/ui/components/core/MessageHistory.js.map +1 -0
- package/dist/ui/components/core/MessageInput.d.ts +10 -0
- package/dist/ui/components/core/MessageInput.d.ts.map +1 -0
- package/dist/ui/components/core/MessageInput.js +130 -0
- package/dist/ui/components/core/MessageInput.js.map +1 -0
- package/dist/ui/components/display/DiffPreview.d.ts +15 -0
- package/dist/ui/components/display/DiffPreview.d.ts.map +1 -0
- package/dist/ui/components/display/DiffPreview.js +298 -0
- package/dist/ui/components/display/DiffPreview.js.map +1 -0
- package/dist/ui/components/display/Stats.d.ts +19 -0
- package/dist/ui/components/display/Stats.d.ts.map +1 -0
- package/dist/ui/components/display/Stats.js +31 -0
- package/dist/ui/components/display/Stats.js.map +1 -0
- package/dist/ui/components/display/TokenMetrics.d.ts +11 -0
- package/dist/ui/components/display/TokenMetrics.d.ts.map +1 -0
- package/dist/ui/components/display/TokenMetrics.js +16 -0
- package/dist/ui/components/display/TokenMetrics.js.map +1 -0
- package/dist/ui/components/display/ToolHistoryItem.d.ts +7 -0
- package/dist/ui/components/display/ToolHistoryItem.d.ts.map +1 -0
- package/dist/ui/components/display/ToolHistoryItem.js +102 -0
- package/dist/ui/components/display/ToolHistoryItem.js.map +1 -0
- package/dist/ui/components/input-overlays/ErrorRetry.d.ts +8 -0
- package/dist/ui/components/input-overlays/ErrorRetry.d.ts.map +1 -0
- package/dist/ui/components/input-overlays/ErrorRetry.js +6 -0
- package/dist/ui/components/input-overlays/ErrorRetry.js.map +1 -0
- package/dist/ui/components/input-overlays/Login.d.ts +7 -0
- package/dist/ui/components/input-overlays/Login.d.ts.map +1 -0
- package/dist/ui/components/input-overlays/Login.js +32 -0
- package/dist/ui/components/input-overlays/Login.js.map +1 -0
- package/dist/ui/components/input-overlays/MaxIterationsContinue.d.ts +8 -0
- package/dist/ui/components/input-overlays/MaxIterationsContinue.d.ts.map +1 -0
- package/dist/ui/components/input-overlays/MaxIterationsContinue.js +32 -0
- package/dist/ui/components/input-overlays/MaxIterationsContinue.js.map +1 -0
- package/dist/ui/components/input-overlays/ModelSelector.d.ts +12 -0
- package/dist/ui/components/input-overlays/ModelSelector.d.ts.map +1 -0
- package/dist/ui/components/input-overlays/ModelSelector.js +114 -0
- package/dist/ui/components/input-overlays/ModelSelector.js.map +1 -0
- package/dist/ui/components/input-overlays/PendingToolApproval.d.ts +10 -0
- package/dist/ui/components/input-overlays/PendingToolApproval.d.ts.map +1 -0
- package/dist/ui/components/input-overlays/PendingToolApproval.js +51 -0
- package/dist/ui/components/input-overlays/PendingToolApproval.js.map +1 -0
- package/dist/ui/components/input-overlays/SlashCommandSuggestions.d.ts +8 -0
- package/dist/ui/components/input-overlays/SlashCommandSuggestions.d.ts.map +1 -0
- package/dist/ui/components/input-overlays/SlashCommandSuggestions.js +13 -0
- package/dist/ui/components/input-overlays/SlashCommandSuggestions.js.map +1 -0
- package/dist/ui/hooks/useAgent.d.ts +41 -0
- package/dist/ui/hooks/useAgent.d.ts.map +1 -0
- package/dist/ui/hooks/useAgent.js +205 -0
- package/dist/ui/hooks/useAgent.js.map +1 -0
- package/dist/ui/hooks/useMouseScroll.d.ts +3 -0
- package/dist/ui/hooks/useMouseScroll.d.ts.map +1 -0
- package/dist/ui/hooks/useMouseScroll.js +32 -0
- package/dist/ui/hooks/useMouseScroll.js.map +1 -0
- package/dist/ui/hooks/useSessionStats.d.ts +20 -0
- package/dist/ui/hooks/useSessionStats.d.ts.map +1 -0
- package/dist/ui/hooks/useSessionStats.js +36 -0
- package/dist/ui/hooks/useSessionStats.js.map +1 -0
- package/dist/ui/hooks/useTokenMetrics.d.ts +21 -0
- package/dist/ui/hooks/useTokenMetrics.d.ts.map +1 -0
- package/dist/ui/hooks/useTokenMetrics.js +102 -0
- package/dist/ui/hooks/useTokenMetrics.js.map +1 -0
- package/dist/ui/utils/CodeColorizer.d.ts +5 -0
- package/dist/ui/utils/CodeColorizer.d.ts.map +1 -0
- package/dist/ui/utils/CodeColorizer.js +47 -0
- package/dist/ui/utils/CodeColorizer.js.map +1 -0
- package/dist/utils/constants.d.ts +8 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +104 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/context.d.ts +36 -0
- package/dist/utils/context.d.ts.map +1 -0
- package/dist/utils/context.js +239 -0
- package/dist/utils/context.js.map +1 -0
- package/dist/utils/file-ops.d.ts +21 -0
- package/dist/utils/file-ops.d.ts.map +1 -0
- package/dist/utils/file-ops.js +125 -0
- package/dist/utils/file-ops.js.map +1 -0
- package/dist/utils/local-settings.d.ts +18 -0
- package/dist/utils/local-settings.d.ts.map +1 -0
- package/dist/utils/local-settings.js +176 -0
- package/dist/utils/local-settings.js.map +1 -0
- package/dist/utils/markdown.d.ts +13 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +122 -0
- package/dist/utils/markdown.js.map +1 -0
- package/dist/utils/proxy-config.d.ts +25 -0
- package/dist/utils/proxy-config.d.ts.map +1 -0
- package/dist/utils/proxy-config.js +145 -0
- package/dist/utils/proxy-config.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Build With Groq
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
<h2 align="center">
|
|
2
|
+
<br>
|
|
3
|
+
<img src="docs/thumbnail.png" alt="Sory Code CLI" width="400">
|
|
4
|
+
<br>
|
|
5
|
+
<br>
|
|
6
|
+
Sory Code CLI: A highly customizable, lightweight, and open-source coding CLI powered by Sory for instant iteration.
|
|
7
|
+
<br>
|
|
8
|
+
</h2>
|
|
9
|
+
|
|
10
|
+
<p align="center">
|
|
11
|
+
<a href="https://github.com/build-with-Sory/Sory-code-cli/stargazers"><img src="https://img.shields.io/github/stars/build-with-Sory/Sory-code-cli"></a>
|
|
12
|
+
<a href="https://github.com/build-with-Sory/Sory-code-cli/blob/main/LICENSE">
|
|
13
|
+
<img src="https://img.shields.io/badge/License-MIT-green.svg">
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="#Overview">Overview</a> •
|
|
19
|
+
<a href="#Installation">Installation</a> •
|
|
20
|
+
<a href="#Usage">Usage</a> •
|
|
21
|
+
<a href="#Development">Development</a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<br>
|
|
25
|
+
|
|
26
|
+
https://github.com/user-attachments/assets/5902fd07-1882-4ee7-825b-50d627f8c96a
|
|
27
|
+
|
|
28
|
+
<br>
|
|
29
|
+
|
|
30
|
+
# Overview
|
|
31
|
+
|
|
32
|
+
Coding CLIs are everywhere. The Sory Code CLI is different. It is a blueprint, a building block, for developers looking to leverage, customize, and extend a CLI to be entirely their own. Leading open-source CLIs are all fantastic, inspiring for the open-source community, and hugely rich in features. However, that's just it: they are *gigantic*. Feature-rich: yes, but local development with such a large and interwoven codebase is unfriendly and overwhelming. **This is a project for developers looking to dive in.**
|
|
33
|
+
|
|
34
|
+
Sory Code CLI is your chance to make a CLI truly your own. Equipped with all of the features, tools, commands, and UI/UX that’s familiar to your current favorite CLI, we make it simple to add new features you’ve always wanted. By massively cutting down on bloat and code mass without compromising on quality, you can jump into modifying this CLI however you see fit. By leveraging models on Sory, you can iterate even faster (`/models` to see available models). Simply activate the CLI by typing `Sory` in your terminal. Use Sory Code CLI in any directory just like you would with any other coding CLI. Use it in this directory to have it build and customize itself!
|
|
35
|
+
|
|
36
|
+
A few customization ideas to get started:
|
|
37
|
+
- New slash commands (e.g. /mcp, /deadcode, /complexity, etc.)
|
|
38
|
+
- Additional tools (e.g. web search, merge conflict resolver, knowledge graph builder, etc.)
|
|
39
|
+
- Custom start-up ASCII art
|
|
40
|
+
- Change the start-up command
|
|
41
|
+
- Anything you can think of!
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
### For Development (Recommended)
|
|
47
|
+
```bash
|
|
48
|
+
git clone https://github.com/build-with-Sory/Sory-code-cli.git
|
|
49
|
+
cd Sory-code-cli
|
|
50
|
+
npm install
|
|
51
|
+
npm run build
|
|
52
|
+
npm link # Enables the `Sory` command in any directory
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Run this in the background during development to automatically apply any changes to the source code
|
|
57
|
+
npm run dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Run Instantly
|
|
61
|
+
```bash
|
|
62
|
+
# Using npx, no installation required
|
|
63
|
+
npx Sory-code-cli@latest
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Install Globally
|
|
67
|
+
```bash
|
|
68
|
+
npm install -g Sory-code-cli@latest
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
```bash
|
|
73
|
+
# Start chat session
|
|
74
|
+
Sory
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Command Line Options
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
Sory [options]
|
|
81
|
+
|
|
82
|
+
Options:
|
|
83
|
+
-t, --temperature <temp> Temperature for generation (default: 1)
|
|
84
|
+
-s, --system <message> Custom system message
|
|
85
|
+
-d, --debug Enable debug logging to debug-agent.log in current directory
|
|
86
|
+
-p, --proxy <url> Proxy URL (e.g. http://proxy:8080 or socks5://proxy:1080)
|
|
87
|
+
-h, --help Display help
|
|
88
|
+
-V, --version Display version number
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Authentication
|
|
92
|
+
|
|
93
|
+
On first use, start a chat:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
Sory
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
And type the `/login` command:
|
|
100
|
+
|
|
101
|
+

|
|
102
|
+
>Get your API key from the <strong>Sory Console</strong> [here](https://console.Sory.com/keys)
|
|
103
|
+
|
|
104
|
+
This creates a .Sory/ folder in your home directory that stores your API key, default model selection, and any other config you wish to add.
|
|
105
|
+
|
|
106
|
+
You can also set your API key for your current directory via environment variable:
|
|
107
|
+
```bash
|
|
108
|
+
export Sory_API_KEY=your_api_key_here
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Proxy Configuration
|
|
112
|
+
|
|
113
|
+
Supports HTTP/HTTPS/SOCKS5 proxies via CLI flag or environment variables:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# CLI flag (highest priority)
|
|
117
|
+
Sory --proxy http://proxy:8080
|
|
118
|
+
Sory --proxy socks5://proxy:1080
|
|
119
|
+
|
|
120
|
+
# Environment variables
|
|
121
|
+
export HTTP_PROXY=http://proxy:8080
|
|
122
|
+
export HTTPS_PROXY=socks5://proxy:1080
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Priority: `--proxy` > `HTTPS_PROXY` > `HTTP_PROXY`
|
|
126
|
+
|
|
127
|
+
### Available Commands
|
|
128
|
+
- `/help` - Show help and available commands
|
|
129
|
+
- `/login` - Login with your credentials
|
|
130
|
+
- `/model` - Select your Sory model
|
|
131
|
+
- `/clear` - Clear chat history and context
|
|
132
|
+
- `/reasoning` - Toggle display of reasoning content in messages
|
|
133
|
+
- `/stats` - Display session statistics and token usage
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
## Development
|
|
137
|
+
|
|
138
|
+
### Testing Locally
|
|
139
|
+
```bash
|
|
140
|
+
# Run this in the background during development to automatically apply any changes to the source code
|
|
141
|
+
npm run dev
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Available Scripts
|
|
145
|
+
```bash
|
|
146
|
+
npm run build # Build TypeScript to dist/
|
|
147
|
+
npm run dev # Build in watch mode
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Project Structure
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
Sory-code-cli/
|
|
154
|
+
├── src/
|
|
155
|
+
│ ├── commands/
|
|
156
|
+
│ │ ├── definitions/ # Individual command implementations
|
|
157
|
+
│ │ │ ├── clear.ts # Clear chat history command
|
|
158
|
+
│ │ │ ├── help.ts # Help command
|
|
159
|
+
│ │ │ ├── login.ts # Authentication command
|
|
160
|
+
│ │ │ ├── model.ts # Model selection command
|
|
161
|
+
│ │ │ └── reasoning.ts # Reasoning toggle command
|
|
162
|
+
│ │ ├── base.ts # Base command interface
|
|
163
|
+
│ │ └── index.ts # Command exports
|
|
164
|
+
│ ├── core/
|
|
165
|
+
│ │ ├── agent.ts # AI agent implementation
|
|
166
|
+
│ │ └── cli.ts # CLI entry point and setup
|
|
167
|
+
│ ├── tools/
|
|
168
|
+
│ │ ├── tool-schemas.ts # Tool schema definitions
|
|
169
|
+
│ │ ├── tools.ts # Tool implementations
|
|
170
|
+
│ │ └── validators.ts # Input validation utilities
|
|
171
|
+
│ ├── ui/
|
|
172
|
+
│ │ ├── App.tsx # Main application component
|
|
173
|
+
│ │ ├── components/
|
|
174
|
+
│ │ │ ├── core/ # Core chat TUI components
|
|
175
|
+
│ │ │ ├── display/ # Auxiliary components for TUI display
|
|
176
|
+
│ │ │ └── input-overlays/ # Input overlays and modals that occupy the MessageInput box
|
|
177
|
+
│ │ └── hooks/
|
|
178
|
+
│ └── utils/
|
|
179
|
+
│ ├── constants.ts # Application constants
|
|
180
|
+
│ ├── file-ops.ts # File system operations
|
|
181
|
+
│ ├── local-settings.ts # Local configuration management
|
|
182
|
+
│ └── markdown.ts # Markdown processing utilities
|
|
183
|
+
├── docs/
|
|
184
|
+
├── package.json
|
|
185
|
+
├── tsconfig.json
|
|
186
|
+
└── LICENSE
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**TL;DR:** Start with `src/core/cli.ts` (main entry point), `src/core/agent.ts`, and `src/ui/hooks/useAgent.ts` (bridge between TUI and the agent). Tools are in `src/tools/`, slash commands are in `src/commands/definitions/`, and customize the TUI in `src/ui/components/`.
|
|
190
|
+
|
|
191
|
+
### Customization
|
|
192
|
+
|
|
193
|
+
#### Adding New Tools
|
|
194
|
+
|
|
195
|
+
Tools are AI-callable functions that extend the CLI's capabilities. To add a new tool:
|
|
196
|
+
|
|
197
|
+
1. **Define the tool schema** in `src/tools/tool-schemas.ts`:
|
|
198
|
+
```typescript
|
|
199
|
+
export const YOUR_TOOL_SCHEMA: ToolSchema = {
|
|
200
|
+
type: 'function',
|
|
201
|
+
function: {
|
|
202
|
+
name: 'your_tool_name',
|
|
203
|
+
description: 'What your tool does',
|
|
204
|
+
parameters: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
properties: {
|
|
207
|
+
param1: { type: 'string', description: 'Parameter description' }
|
|
208
|
+
},
|
|
209
|
+
required: ['param1']
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
2. **Implement the tool function** in `src/tools/tools.ts`:
|
|
216
|
+
```typescript
|
|
217
|
+
export async function yourToolName(param1: string): Promise<ToolResult> {
|
|
218
|
+
// Your implementation here
|
|
219
|
+
return createToolResponse(true, result, 'Success message');
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
3. **Register the tool** in the `TOOL_REGISTRY` object and `executeTool` switch statement in `src/tools/tools.ts`.
|
|
224
|
+
|
|
225
|
+
4. **Add the schema** to `ALL_TOOL_SCHEMAS` array in `src/tools/tool-schemas.ts`.
|
|
226
|
+
|
|
227
|
+
#### Adding New Slash Commands
|
|
228
|
+
|
|
229
|
+
Slash commands provide direct user interactions. To add a new command:
|
|
230
|
+
|
|
231
|
+
1. **Create command definition** in `src/commands/definitions/your-command.ts`:
|
|
232
|
+
```typescript
|
|
233
|
+
import { CommandDefinition, CommandContext } from '../base.js';
|
|
234
|
+
|
|
235
|
+
export const yourCommand: CommandDefinition = {
|
|
236
|
+
command: 'yourcommand',
|
|
237
|
+
description: 'What your command does',
|
|
238
|
+
handler: ({ addMessage }: CommandContext) => {
|
|
239
|
+
// Your command logic here
|
|
240
|
+
addMessage({
|
|
241
|
+
role: 'system',
|
|
242
|
+
content: 'Command response'
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
2. **Register the command** in `src/commands/index.ts` by importing it and adding to the `availableCommands` array.
|
|
249
|
+
|
|
250
|
+
#### Changing Start Command
|
|
251
|
+
To change the start command from `Sory`, change `"Sory"` in `"bin"` of `package.json` to your global command of choice.
|
|
252
|
+
|
|
253
|
+
Re-run `npm run build` and `npm link`.
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
## Contributing and Support
|
|
257
|
+
|
|
258
|
+
Improvements through PRs are welcome!
|
|
259
|
+
|
|
260
|
+
For issues and feature requests, please open an issue on GitHub.
|
|
261
|
+
|
|
262
|
+
#### Share what you create with Sory on our [socials](https://x.com/SoryInc)!
|
|
263
|
+
|
|
264
|
+
### Featured Community Creations
|
|
265
|
+
- [OpenRouter Support](https://github.com/rahulvrane/Sory-code-cli-openrouter) - rahulvrane
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface CommandContext {
|
|
2
|
+
addMessage: (message: any) => void;
|
|
3
|
+
clearHistory: () => void;
|
|
4
|
+
setShowLogin: (show: boolean) => void;
|
|
5
|
+
setShowModelSelector?: (show: boolean) => void;
|
|
6
|
+
toggleReasoning?: () => void;
|
|
7
|
+
showReasoning?: boolean;
|
|
8
|
+
sessionStats?: {
|
|
9
|
+
promptTokens: number;
|
|
10
|
+
completionTokens: number;
|
|
11
|
+
totalTokens: number;
|
|
12
|
+
totalRequests: number;
|
|
13
|
+
totalTime: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export interface CommandDefinition {
|
|
17
|
+
command: string;
|
|
18
|
+
description: string;
|
|
19
|
+
handler: (context: CommandContext) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare abstract class BaseCommand implements CommandDefinition {
|
|
22
|
+
abstract command: string;
|
|
23
|
+
abstract description: string;
|
|
24
|
+
abstract handler(context: CommandContext): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACnC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;QACzB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;CAC5C;AAED,8BAAsB,WAAY,YAAW,iBAAiB;IAC5D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;CAChD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/commands/base.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAgB,WAAW;CAIhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/clear.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,YAAY,EAAE,iBAU1B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const clearCommand = {
|
|
2
|
+
command: 'clear',
|
|
3
|
+
description: 'Clear chat history and context',
|
|
4
|
+
handler: ({ addMessage, clearHistory }) => {
|
|
5
|
+
clearHistory();
|
|
6
|
+
addMessage({
|
|
7
|
+
role: 'system',
|
|
8
|
+
content: 'Chat history and context cleared.',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=clear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../src/commands/definitions/clear.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,gCAAgC;IAC7C,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,YAAY,EAAkB,EAAE,EAAE;QACxD,YAAY,EAAE,CAAC;QACf,UAAU,CAAC;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,mCAAmC;SAC7C,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAG/D,eAAO,MAAM,WAAW,EAAE,iBA0BzB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getAvailableCommands } from '../index.js';
|
|
2
|
+
export const helpCommand = {
|
|
3
|
+
command: 'help',
|
|
4
|
+
description: 'Show help and available commands',
|
|
5
|
+
handler: ({ addMessage }) => {
|
|
6
|
+
const commands = getAvailableCommands();
|
|
7
|
+
const commandList = commands.map(cmd => `/${cmd.command} - ${cmd.description}`).join('\n');
|
|
8
|
+
addMessage({
|
|
9
|
+
role: 'system',
|
|
10
|
+
content: `Available Commands:
|
|
11
|
+
${commandList}
|
|
12
|
+
|
|
13
|
+
Navigation:
|
|
14
|
+
- Use arrow keys to navigate chat history
|
|
15
|
+
- Type '/' to see available slash commands
|
|
16
|
+
- Use arrow keys to navigate slash command suggestions
|
|
17
|
+
- Press Enter to execute the selected command
|
|
18
|
+
|
|
19
|
+
Keyboard Shortcuts:
|
|
20
|
+
- Esc - Clear input box / Interrupt processing / Reject tool approval
|
|
21
|
+
- Shift+Tab - Toggle auto-approval for editing tools
|
|
22
|
+
- Ctrl+C - Exit the application
|
|
23
|
+
|
|
24
|
+
This is a highly customizable, lightweight, and open-source coding CLI powered by Sory. Ask for help with coding tasks, debugging issues, or explaining code.`
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=help.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/commands/definitions/help.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,CAAC,MAAM,WAAW,GAAsB;IAC5C,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,kCAAkC;IAC/C,OAAO,EAAE,CAAC,EAAE,UAAU,EAAkB,EAAE,EAAE;QAC1C,MAAM,QAAQ,GAAG,oBAAoB,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,MAAM,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3F,UAAU,CAAC;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;EACb,WAAW;;;;;;;;;;;;;8JAaiJ;SACzJ,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAG/D,eAAO,MAAM,WAAW,EAAE,iBAmBzB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { writeProjectContext } from '../../utils/context.js';
|
|
2
|
+
export const initCommand = {
|
|
3
|
+
command: 'init',
|
|
4
|
+
description: 'Generate project context files in .sory/',
|
|
5
|
+
handler: ({ addMessage }) => {
|
|
6
|
+
try {
|
|
7
|
+
const rootDir = process.env.SORY_CONTEXT_DIR || process.cwd();
|
|
8
|
+
const { mdPath, jsonPath } = writeProjectContext(rootDir);
|
|
9
|
+
addMessage({
|
|
10
|
+
role: 'system',
|
|
11
|
+
content: `Project context generated.\n- Markdown: ${mdPath}\n- JSON: ${jsonPath}\nThe assistant will automatically load this context on startup. Re-run /init to refresh.`
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
16
|
+
addMessage({
|
|
17
|
+
role: 'system',
|
|
18
|
+
content: `Failed to generate project context: ${message}`
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/definitions/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAsB;IAC5C,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,0CAA0C;IACvD,OAAO,EAAE,CAAC,EAAE,UAAU,EAAkB,EAAE,EAAE;QAC1C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAC9D,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;YAC1D,UAAU,CAAC;gBACT,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,2CAA2C,MAAM,aAAa,QAAQ,2FAA2F;aAC3K,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,UAAU,CAAC;gBACT,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,uCAAuC,OAAO,EAAE;aAC1D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,YAAY,EAAE,iBAM1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/definitions/login.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,6BAA6B;IAC1C,OAAO,EAAE,CAAC,EAAE,YAAY,EAAkB,EAAE,EAAE;QAC5C,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,YAAY,EAAE,iBAQ1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/commands/definitions/model.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,sBAAsB;IACnC,OAAO,EAAE,CAAC,EAAE,oBAAoB,EAAkB,EAAE,EAAE;QACpD,IAAI,oBAAoB,EAAE,CAAC;YACzB,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE,iBAkB9B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const reasoningCommand = {
|
|
2
|
+
command: 'reasoning',
|
|
3
|
+
description: 'Toggle display of reasoning content in messages',
|
|
4
|
+
handler: ({ addMessage, toggleReasoning, showReasoning }) => {
|
|
5
|
+
if (toggleReasoning) {
|
|
6
|
+
toggleReasoning();
|
|
7
|
+
const newState = !showReasoning;
|
|
8
|
+
addMessage({
|
|
9
|
+
role: 'system',
|
|
10
|
+
content: `Reasoning display is now ${newState ? 'enabled' : 'disabled'}.`,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
addMessage({
|
|
15
|
+
role: 'system',
|
|
16
|
+
content: 'Reasoning toggle functionality is not available.',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=reasoning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning.js","sourceRoot":"","sources":["../../../src/commands/definitions/reasoning.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,OAAO,EAAE,WAAW;IACpB,WAAW,EAAE,iDAAiD;IAC9D,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAkB,EAAE,EAAE;QAC1E,IAAI,eAAe,EAAE,CAAC;YACpB,eAAe,EAAE,CAAC;YAClB,MAAM,QAAQ,GAAG,CAAC,aAAa,CAAC;YAChC,UAAU,CAAC;gBACT,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,4BAA4B,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAAG;aAC1E,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,UAAU,CAAC;gBACT,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,kDAAkD;aAC5D,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/commands/definitions/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,YAAY,CAAC;AAE/D,eAAO,MAAM,YAAY,EAAE,iBAoB1B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const statsCommand = {
|
|
2
|
+
command: 'stats',
|
|
3
|
+
description: 'Display session statistics and token usage',
|
|
4
|
+
handler: ({ addMessage, sessionStats }) => {
|
|
5
|
+
addMessage({
|
|
6
|
+
role: 'system',
|
|
7
|
+
content: 'SHOW_STATS',
|
|
8
|
+
type: 'stats',
|
|
9
|
+
usageSnapshot: sessionStats ? {
|
|
10
|
+
prompt_tokens: sessionStats.promptTokens,
|
|
11
|
+
completion_tokens: sessionStats.completionTokens,
|
|
12
|
+
total_tokens: sessionStats.totalTokens,
|
|
13
|
+
total_requests: sessionStats.totalRequests,
|
|
14
|
+
total_time: sessionStats.totalTime,
|
|
15
|
+
queue_time: 0,
|
|
16
|
+
prompt_time: 0,
|
|
17
|
+
completion_time: 0,
|
|
18
|
+
} : undefined
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../../src/commands/definitions/stats.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,4CAA4C;IACzD,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,YAAY,EAAkB,EAAE,EAAE;QACxD,UAAU,CAAC;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,OAAO;YACb,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC5B,aAAa,EAAE,YAAY,CAAC,YAAY;gBACxC,iBAAiB,EAAE,YAAY,CAAC,gBAAgB;gBAChD,YAAY,EAAE,YAAY,CAAC,WAAW;gBACtC,cAAc,EAAE,YAAY,CAAC,aAAa;gBAC1C,UAAU,EAAE,YAAY,CAAC,SAAS;gBAClC,UAAU,EAAE,CAAC;gBACb,WAAW,EAAE,CAAC;gBACd,eAAe,EAAE,CAAC;aACnB,CAAC,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommandDefinition, CommandContext } from './base.js';
|
|
2
|
+
export declare function getAvailableCommands(): CommandDefinition[];
|
|
3
|
+
export declare function getCommandNames(): string[];
|
|
4
|
+
export declare function handleSlashCommand(command: string, context: CommandContext): void;
|
|
5
|
+
export { CommandDefinition, CommandContext } from './base.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAmB9D,wBAAgB,oBAAoB,IAAI,iBAAiB,EAAE,CAE1D;AAED,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAE1C;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,QAkBxB;AAED,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { helpCommand } from './definitions/help.js';
|
|
2
|
+
import { loginCommand } from './definitions/login.js';
|
|
3
|
+
import { modelCommand } from './definitions/model.js';
|
|
4
|
+
import { clearCommand } from './definitions/clear.js';
|
|
5
|
+
import { initCommand } from './definitions/init.js';
|
|
6
|
+
import { reasoningCommand } from './definitions/reasoning.js';
|
|
7
|
+
import { statsCommand } from './definitions/stats.js';
|
|
8
|
+
const availableCommands = [
|
|
9
|
+
helpCommand,
|
|
10
|
+
loginCommand,
|
|
11
|
+
modelCommand,
|
|
12
|
+
clearCommand,
|
|
13
|
+
initCommand,
|
|
14
|
+
reasoningCommand,
|
|
15
|
+
statsCommand,
|
|
16
|
+
];
|
|
17
|
+
export function getAvailableCommands() {
|
|
18
|
+
return [...availableCommands];
|
|
19
|
+
}
|
|
20
|
+
export function getCommandNames() {
|
|
21
|
+
return getAvailableCommands().map(cmd => cmd.command);
|
|
22
|
+
}
|
|
23
|
+
export function handleSlashCommand(command, context) {
|
|
24
|
+
// Extract the command part, everything up to the first space or end of string
|
|
25
|
+
const fullCommand = command.slice(1);
|
|
26
|
+
const spaceIndex = fullCommand.indexOf(' ');
|
|
27
|
+
const cmd = spaceIndex > -1 ? fullCommand.substring(0, spaceIndex).toLowerCase() : fullCommand.toLowerCase();
|
|
28
|
+
const commandDef = getAvailableCommands().find(c => c.command === cmd);
|
|
29
|
+
// Add user message for the command
|
|
30
|
+
context.addMessage({
|
|
31
|
+
role: 'user',
|
|
32
|
+
content: command,
|
|
33
|
+
});
|
|
34
|
+
if (commandDef) {
|
|
35
|
+
commandDef.handler(context);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,iBAAiB,GAAwB;IAC7C,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,YAAY;IACZ,WAAW;IACX,gBAAgB;IAChB,YAAY;CACb,CAAC;AAEF,MAAM,UAAU,oBAAoB;IAClC,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAe,EACf,OAAuB;IAEvB,8EAA8E;IAC9E,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC;IAE7G,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC;IAEvE,mCAAmC;IACnC,OAAO,CAAC,UAAU,CAAC;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;IAEH,IAAI,UAAU,EAAE,CAAC;QACf,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare class Agent {
|
|
2
|
+
private provider;
|
|
3
|
+
private messages;
|
|
4
|
+
private apiKey;
|
|
5
|
+
private model;
|
|
6
|
+
private temperature;
|
|
7
|
+
private sessionAutoApprove;
|
|
8
|
+
private systemMessage;
|
|
9
|
+
private configManager;
|
|
10
|
+
private proxyOverride?;
|
|
11
|
+
onToolStart?: (name: string, args: Record<string, any>) => void;
|
|
12
|
+
onToolEnd?: (name: string, result: any) => void;
|
|
13
|
+
onToolApproval?: (toolName: string, toolArgs: Record<string, any>) => Promise<{
|
|
14
|
+
approved: boolean;
|
|
15
|
+
autoApproveSession?: boolean;
|
|
16
|
+
}>;
|
|
17
|
+
onThinkingText?: (content: string, reasoning?: string) => void;
|
|
18
|
+
onFinalMessage?: (content: string, reasoning?: string) => void;
|
|
19
|
+
onMaxIterations?: (maxIterations: number) => Promise<boolean>;
|
|
20
|
+
onApiUsage?: (usage: any) => void;
|
|
21
|
+
onError?: (error: string) => Promise<boolean>;
|
|
22
|
+
private currentAbortController;
|
|
23
|
+
private isInterrupted;
|
|
24
|
+
private constructor();
|
|
25
|
+
static create(model: string, temperature: number, systemMessage: string | null, debug?: boolean, proxyOverride?: string): Promise<Agent>;
|
|
26
|
+
private loadContext;
|
|
27
|
+
private buildDefaultSystemMessage;
|
|
28
|
+
setToolCallbacks(callbacks: any): void;
|
|
29
|
+
setApiKey(apiKey: string): void;
|
|
30
|
+
saveApiKey(apiKey: string): void;
|
|
31
|
+
hasApiKey(provider: string): boolean;
|
|
32
|
+
clearApiKey(): void;
|
|
33
|
+
clearHistory(): void;
|
|
34
|
+
setModel(model: string): void;
|
|
35
|
+
getCurrentModel(): string;
|
|
36
|
+
setSessionAutoApprove(enabled: boolean): void;
|
|
37
|
+
interrupt(): void;
|
|
38
|
+
chat(userInput: string): Promise<void>;
|
|
39
|
+
private executeToolCall;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=agent.d.ts.map
|