@kirosnn/mosaic 0.0.9 → 0.71.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 +1 -1
- package/README.md +83 -19
- package/package.json +52 -47
- package/src/agent/prompts/systemPrompt.ts +198 -68
- package/src/agent/prompts/toolsPrompt.ts +217 -135
- package/src/agent/provider/anthropic.ts +19 -15
- package/src/agent/provider/google.ts +21 -17
- package/src/agent/provider/ollama.ts +80 -41
- package/src/agent/provider/openai.ts +107 -67
- package/src/agent/provider/reasoning.ts +29 -0
- package/src/agent/provider/xai.ts +19 -15
- package/src/agent/tools/definitions.ts +9 -5
- package/src/agent/tools/executor.ts +655 -46
- package/src/agent/tools/exploreExecutor.ts +12 -12
- package/src/agent/tools/fetch.ts +58 -0
- package/src/agent/tools/glob.ts +20 -4
- package/src/agent/tools/grep.ts +62 -8
- package/src/agent/tools/plan.ts +27 -0
- package/src/agent/tools/read.ts +2 -0
- package/src/agent/types.ts +6 -6
- package/src/components/App.tsx +67 -25
- package/src/components/CustomInput.tsx +274 -68
- package/src/components/Main.tsx +323 -168
- package/src/components/ShortcutsModal.tsx +11 -8
- package/src/components/main/ChatPage.tsx +217 -58
- package/src/components/main/HomePage.tsx +5 -1
- package/src/components/main/ThinkingIndicator.tsx +11 -1
- package/src/components/main/types.ts +11 -10
- package/src/index.tsx +3 -5
- package/src/utils/approvalBridge.ts +29 -8
- package/src/utils/approvalModeBridge.ts +17 -0
- package/src/utils/commands/approvals.ts +48 -0
- package/src/utils/commands/image.ts +109 -0
- package/src/utils/commands/index.ts +5 -1
- package/src/utils/diffRendering.tsx +13 -14
- package/src/utils/history.ts +82 -40
- package/src/utils/imageBridge.ts +28 -0
- package/src/utils/images.ts +31 -0
- package/src/utils/models.ts +0 -7
- package/src/utils/notificationBridge.ts +23 -0
- package/src/utils/toolFormatting.ts +162 -43
- package/src/web/app.tsx +94 -34
- package/src/web/assets/css/ChatPage.css +102 -30
- package/src/web/assets/css/MessageItem.css +26 -29
- package/src/web/assets/css/ThinkingIndicator.css +44 -6
- package/src/web/assets/css/ToolMessage.css +36 -14
- package/src/web/components/ChatPage.tsx +228 -105
- package/src/web/components/HomePage.tsx +6 -6
- package/src/web/components/MessageItem.tsx +88 -89
- package/src/web/components/Setup.tsx +1 -1
- package/src/web/components/Sidebar.tsx +1 -1
- package/src/web/components/ThinkingIndicator.tsx +40 -21
- package/src/web/router.ts +1 -1
- package/src/web/server.tsx +187 -39
- package/src/web/storage.ts +23 -1
- package/src/web/types.ts +7 -6
package/LICENSE
CHANGED
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="docs/
|
|
2
|
+
<img src="docs/logo_white.svg" width="200" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<h1 align="center">Mosaic CLI</h1>
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Version 0.71.0</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="#installation">Installation</a> •
|
|
13
|
+
<a href="#quick-start">Quick Start</a> •
|
|
14
|
+
<a href="#ai-providers">Providers</a> •
|
|
15
|
+
<a href="#contributing">Contributing</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
---
|
|
8
19
|
|
|
9
20
|
Mosaic is an open-source, AI-powered coding agent for the terminal. It combines a React-based TUI (OpenTUI) with a tool-driven agent architecture to deliver a fast, context-aware development workflow. A web UI is also available for those who prefer a browser experience.
|
|
10
21
|
|
|
@@ -19,9 +30,30 @@ Mosaic is an open-source, AI-powered coding agent for the terminal. It combines
|
|
|
19
30
|
|
|
20
31
|
## Requirements
|
|
21
32
|
|
|
22
|
-
- [Bun](https://bun.sh)
|
|
33
|
+
- [Bun](https://bun.sh) (required at runtime)
|
|
34
|
+
- Node.js >= 18 (for npm installation)
|
|
23
35
|
|
|
24
|
-
## Installation
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
### Via npm (recommended)
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @kirosnn/mosaic
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Then run from any directory:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
mosaic
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Via npx (no install)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx @kirosnn/mosaic
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### From source
|
|
25
57
|
|
|
26
58
|
```bash
|
|
27
59
|
git clone https://github.com/kirosnn/mosaic.git
|
|
@@ -42,6 +74,8 @@ If you prefer not to link globally:
|
|
|
42
74
|
bun run mosaic
|
|
43
75
|
```
|
|
44
76
|
|
|
77
|
+
> **Note:** Mosaic requires Bun at runtime. If Bun is not installed, the CLI will prompt you to install it.
|
|
78
|
+
|
|
45
79
|
## Quick Start
|
|
46
80
|
|
|
47
81
|
1. Run `mosaic` in a project directory.
|
|
@@ -73,6 +107,18 @@ mosaic web
|
|
|
73
107
|
|
|
74
108
|
Open http://127.0.0.1:8192 in your browser.
|
|
75
109
|
|
|
110
|
+
## Slash Commands
|
|
111
|
+
|
|
112
|
+
| Command | Description |
|
|
113
|
+
|-------------|--------------------------------------|
|
|
114
|
+
| `/init` | Initialize project context (MOSAIC.md) |
|
|
115
|
+
| `/help` | Show available commands |
|
|
116
|
+
| `/undo` | Undo last file change |
|
|
117
|
+
| `/redo` | Redo undone change |
|
|
118
|
+
| `/sessions` | Manage conversation sessions |
|
|
119
|
+
| `/web` | Open web interface |
|
|
120
|
+
| `/echo` | Echo a message (debug) |
|
|
121
|
+
|
|
76
122
|
## Configuration
|
|
77
123
|
|
|
78
124
|
Mosaic stores global settings in `~/.mosaic/`:
|
|
@@ -92,24 +138,36 @@ Project-specific settings live in `.mosaic/` at the repository root.
|
|
|
92
138
|
|
|
93
139
|
Mosaic relies on a tool registry that exposes safe, focused capabilities to the agent:
|
|
94
140
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
141
|
+
| Tool | Description |
|
|
142
|
+
|------------|------------------------------------------|
|
|
143
|
+
| `read` | Read file contents |
|
|
144
|
+
| `write` | Create or overwrite files |
|
|
145
|
+
| `edit` | Apply targeted edits to files |
|
|
146
|
+
| `bash` | Execute shell commands |
|
|
147
|
+
| `glob` | Find files by pattern |
|
|
148
|
+
| `grep` | Search code with regex |
|
|
149
|
+
| `list` | List directory contents |
|
|
150
|
+
| `question` | Ask clarifying questions to the user |
|
|
151
|
+
|
|
152
|
+
**Safety Features:**
|
|
153
|
+
- Write and edit operations require user approval before execution
|
|
154
|
+
- Built-in undo/redo system tracks all file changes (SQLite-backed)
|
|
155
|
+
- Project context via `MOSAIC.md` helps the agent understand your codebase
|
|
102
156
|
|
|
103
157
|
## AI Providers
|
|
104
158
|
|
|
105
159
|
Mosaic uses the Vercel AI SDK and currently supports:
|
|
106
160
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
161
|
+
| Provider | Models |
|
|
162
|
+
|------------|-------------------------------|
|
|
163
|
+
| OpenAI | GPT-5, GPT-4, GPT-3.5 |
|
|
164
|
+
| Anthropic | Claude Sonnet, Haiku, Opus |
|
|
165
|
+
| Google | Gemini 3 and others |
|
|
166
|
+
| Mistral | Mistral Large, Mixtral |
|
|
167
|
+
| xAI | Grok |
|
|
168
|
+
| Ollama | Any local model |
|
|
169
|
+
|
|
170
|
+
Configure your preferred provider on first run or edit `~/.mosaic/mosaic.jsonc`.
|
|
113
171
|
|
|
114
172
|
## Development
|
|
115
173
|
|
|
@@ -124,4 +182,10 @@ Issues and pull requests are welcome. Please include clear reproduction steps an
|
|
|
124
182
|
|
|
125
183
|
## License
|
|
126
184
|
|
|
127
|
-
MIT
|
|
185
|
+
MIT - see [LICENSE](LICENSE) for details.
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
<p align="center">
|
|
190
|
+
Made with <a href="https://bun.sh">Bun</a>, <a href="https://react.dev">React</a>, and <a href="https://opentui.com">OpenTUI</a>
|
|
191
|
+
</p>
|
package/package.json
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@kirosnn/mosaic",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "The open source coding agent.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"bin": {
|
|
8
|
-
"mosaic": "bin/mosaic.cjs"
|
|
9
|
-
},
|
|
10
|
-
"files": [
|
|
11
|
-
"bin",
|
|
12
|
-
"src",
|
|
13
|
-
"README.md",
|
|
14
|
-
"LICENSE"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {
|
|
17
|
-
"dev": "bun run --watch src/index.tsx",
|
|
18
|
-
"mosaic": "bun run src/index.tsx",
|
|
19
|
-
"start": "bun run src/index.tsx"
|
|
20
|
-
},
|
|
21
|
-
"engines": {
|
|
22
|
-
"node": ">=18.0.0"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@types/bun": "latest",
|
|
26
|
-
"@types/react": "^19.0.0",
|
|
27
|
-
"@types/react-dom": "^19.2.3"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"@ai-sdk/
|
|
32
|
-
"@ai-sdk/
|
|
33
|
-
"@ai-sdk/
|
|
34
|
-
"@ai-sdk/
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"react
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@kirosnn/mosaic",
|
|
3
|
+
"version": "0.71.0",
|
|
4
|
+
"description": "The open source coding agent.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mosaic": "bin/mosaic.cjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"bin",
|
|
12
|
+
"src",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"dev": "bun run --watch src/index.tsx",
|
|
18
|
+
"mosaic": "bun run src/index.tsx",
|
|
19
|
+
"start": "bun run src/index.tsx"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/bun": "latest",
|
|
26
|
+
"@types/react": "^19.0.0",
|
|
27
|
+
"@types/react-dom": "^19.2.3",
|
|
28
|
+
"@types/turndown": "^5.0.6"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@ai-sdk/anthropic": "^1.0.0",
|
|
32
|
+
"@ai-sdk/google": "^1.0.0",
|
|
33
|
+
"@ai-sdk/mistral": "^1.0.0",
|
|
34
|
+
"@ai-sdk/openai": "^1.0.0",
|
|
35
|
+
"@ai-sdk/xai": "^1.0.0",
|
|
36
|
+
"@mozilla/readability": "^0.6.0",
|
|
37
|
+
"@opentui/core": "^0.1.69",
|
|
38
|
+
"@opentui/react": "^0.1.69",
|
|
39
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
40
|
+
"ai": "^4.0.0",
|
|
41
|
+
"better-sqlite3": "^12.6.0",
|
|
42
|
+
"linkedom": "^0.18.12",
|
|
43
|
+
"ollama": "^0.5.0",
|
|
44
|
+
"react": "^19.2.3",
|
|
45
|
+
"react-dom": "^19.2.3",
|
|
46
|
+
"react-markdown": "^10.1.0",
|
|
47
|
+
"react-syntax-highlighter": "^16.1.0",
|
|
48
|
+
"remark-gfm": "^4.0.1",
|
|
49
|
+
"turndown": "^7.2.2",
|
|
50
|
+
"zod": "^3.23.8",
|
|
51
|
+
"zod-to-json-schema": "^3.25.1"
|
|
52
|
+
}
|
|
48
53
|
}
|
|
@@ -3,79 +3,209 @@ import { readFileSync, existsSync } from 'fs';
|
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { getToolsPrompt } from './toolsPrompt';
|
|
5
5
|
|
|
6
|
-
export const DEFAULT_SYSTEM_PROMPT = `You are Mosaic, an AI coding
|
|
7
|
-
|
|
6
|
+
export const DEFAULT_SYSTEM_PROMPT = `You are Mosaic, an AI coding agent operating in the user's terminal.
|
|
7
|
+
You assist with software engineering tasks: coding, debugging, refactoring, testing, and documentation.
|
|
8
|
+
Version : 0.71.0 *(Beta)*
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
# Environment
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- Storing frequently used bash commands (build, test, lint, etc.) so you can use them without searching each time
|
|
15
|
-
- Recording the user's code style preferences (naming conventions, preferred libraries, etc.)
|
|
16
|
-
- Maintaining useful information about the codebase structure and organization
|
|
17
|
-
When you spend time searching for commands to typecheck, lint, build, or test, you should ask the user if it's okay to add those commands to MOSAIC.md. Similarly, when learning about code style preferences or important codebase information, ask if it's okay to add that to MOSAIC.md so you can remember it for next time.
|
|
18
|
-
|
|
19
|
-
ENVIRONMENT:
|
|
20
|
-
- Current workspace: {{WORKSPACE}}
|
|
21
|
-
- Operating system: {{OS}}
|
|
12
|
+
- Workspace: {{WORKSPACE}}
|
|
13
|
+
- OS: {{OS}}
|
|
22
14
|
- Architecture: {{ARCH}}
|
|
23
15
|
- Date: {{DATE}}
|
|
24
16
|
- Time: {{TIME}}
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
18
|
+
# Token Efficiency & Formatting
|
|
19
|
+
|
|
20
|
+
- **Minimize Token Usage**: Read only what is necessary. Use \`grep\` to locate code and \`read\` with \`start_line\`/\`end_line\` to extract specific sections. Avoid reading entire files for small tasks.
|
|
21
|
+
- **No Trailing Newlines**: The \`edit\` and \`write\` tools automatically trim trailing whitespace/newlines. Do not add extra empty lines at the end of files.
|
|
22
|
+
|
|
23
|
+
# Tone and Style
|
|
24
|
+
|
|
25
|
+
- Your output is displayed on a command line interface. Responses should be concise.
|
|
26
|
+
- Output text to communicate with the user; all text you output outside of tool use is displayed to the user.
|
|
27
|
+
- Only use tools to complete tasks. Never use tools like bash or code comments as means to communicate with the user.
|
|
28
|
+
- ALWAYS provide text responses to explain what you're doing. NEVER just use tools without explanation.
|
|
29
|
+
- Match the user's language for all communication (exception: code, filenames, technical terms remain unchanged).
|
|
30
|
+
- No emojis in responses or code.
|
|
31
|
+
|
|
32
|
+
# Response Protocol
|
|
33
|
+
|
|
34
|
+
1. Start your FIRST reply with a <title> tag (max 3 words): <title>Fix auth bug</title>
|
|
35
|
+
2. Only add a new <title> when the conversation clearly switches to a different task.
|
|
36
|
+
|
|
37
|
+
# Persistence & Continuation - CRITICAL
|
|
38
|
+
|
|
39
|
+
NEVER stop in the middle of a task. You MUST continue working until:
|
|
40
|
+
- The task is fully completed, OR
|
|
41
|
+
- You encounter an unrecoverable blocker after multiple retry attempts, OR
|
|
42
|
+
- You need user input via the question tool
|
|
43
|
+
|
|
44
|
+
RULES:
|
|
45
|
+
1. When you announce an action ("I'll search for..."), you MUST immediately execute it in the same response.
|
|
46
|
+
2. After a tool returns a result, continue to the next logical step without stopping.
|
|
47
|
+
3. If a tool fails, retry with different parameters in the same response.
|
|
48
|
+
4. Only stop after completing all steps or when genuinely blocked.
|
|
49
|
+
|
|
50
|
+
FORBIDDEN:
|
|
51
|
+
- Announcing an action then stopping without executing it
|
|
52
|
+
- Stopping after a single tool failure without retrying
|
|
53
|
+
- Waiting for user input when you can proceed autonomously
|
|
54
|
+
|
|
55
|
+
CORRECT pattern:
|
|
56
|
+
"I'll search for the config files." → [use glob tool] → "Found 3 files. Let me read the main one." → [use read tool] → "I see the issue. Fixing it now." → [use edit tool] → "Done. The config is updated."
|
|
57
|
+
|
|
58
|
+
WRONG pattern:
|
|
59
|
+
"I'll search for the config files." → [use glob tool] → "Found 3 files. I'll read them next." → [STOP - waiting for nothing]
|
|
60
|
+
|
|
61
|
+
# Communication Rules
|
|
62
|
+
|
|
63
|
+
You MUST communicate with the user at these moments:
|
|
64
|
+
|
|
65
|
+
## Before Acting
|
|
66
|
+
Write a brief sentence explaining what you're about to do, then IMMEDIATELY use the tool.
|
|
67
|
+
- "I'll examine the authentication module." → [read tool in same response]
|
|
68
|
+
- "Let me search for user validation files." → [glob tool in same response]
|
|
69
|
+
|
|
70
|
+
## On Errors (then continue)
|
|
71
|
+
Explain what happened, then IMMEDIATELY retry:
|
|
72
|
+
- "The file wasn't found. Searching in other locations." → [glob tool in same response]
|
|
73
|
+
- "Build failed with type error. Fixing it." → [edit tool in same response]
|
|
74
|
+
|
|
75
|
+
## After Completing
|
|
76
|
+
Summarize results only when the task is DONE:
|
|
77
|
+
- "Done. The login function now validates email format."
|
|
78
|
+
- "Fixed. All tests are passing."
|
|
79
|
+
|
|
80
|
+
FORBIDDEN: Text explanation without immediately following through with action.
|
|
81
|
+
|
|
82
|
+
# Doing Tasks
|
|
83
|
+
|
|
84
|
+
The user will primarily request software engineering tasks. Follow these steps:
|
|
85
|
+
|
|
86
|
+
## 1. UNDERSTAND FIRST (Critical)
|
|
87
|
+
|
|
88
|
+
Before writing ANY code, you MUST understand the codebase context.
|
|
89
|
+
|
|
90
|
+
USE THE EXPLORE TOOL when:
|
|
91
|
+
- Starting work on an unfamiliar codebase
|
|
92
|
+
- The task involves understanding how something works
|
|
93
|
+
- You need to find related code, patterns, or conventions
|
|
94
|
+
- Questions like "how does X work?", "where is Y implemented?", "find all Z"
|
|
95
|
+
- You're unsure where to make changes
|
|
96
|
+
|
|
97
|
+
The explore tool is INTELLIGENT: it autonomously searches, reads files, and builds understanding.
|
|
98
|
+
This saves time and produces better results than manual glob/grep/read cycles.
|
|
99
|
+
|
|
100
|
+
Examples of when to use explore:
|
|
101
|
+
- "Add a new API endpoint" → explore(purpose="Find existing API endpoints and understand the routing pattern")
|
|
102
|
+
- "Fix the login bug" → explore(purpose="Find authentication code and understand the login flow")
|
|
103
|
+
- "Refactor the user service" → explore(purpose="Find UserService and all its usages")
|
|
104
|
+
|
|
105
|
+
USE glob/grep for TARGETED searches:
|
|
106
|
+
- You already know what you're looking for
|
|
107
|
+
- Finding specific files by name pattern: glob(pattern="**/*.config.ts")
|
|
108
|
+
- Finding specific text: grep(query="handleSubmit", file_type="tsx")
|
|
109
|
+
|
|
110
|
+
CRITICAL: NEVER modify code you haven't read. Always use read before edit/write.
|
|
111
|
+
|
|
112
|
+
## 2. PLAN (for multi-step tasks)
|
|
113
|
+
|
|
114
|
+
Use the plan tool to outline steps and track progress.
|
|
115
|
+
Always update the plan after each step.
|
|
116
|
+
|
|
117
|
+
## 3. EXECUTE
|
|
118
|
+
|
|
119
|
+
Make changes incrementally:
|
|
120
|
+
- Prefer edit for targeted changes
|
|
121
|
+
- Use write for new files or complete rewrites
|
|
122
|
+
- Follow existing code style and conventions
|
|
123
|
+
|
|
124
|
+
## 4. VERIFY
|
|
125
|
+
|
|
126
|
+
Run tests, builds, or lint to confirm changes work.
|
|
127
|
+
Never assume a test framework exists - check first.
|
|
128
|
+
|
|
129
|
+
# File Modification Rules - CRITICAL
|
|
130
|
+
|
|
131
|
+
- You MUST use the read tool on a file BEFORE modifying it with edit or write.
|
|
132
|
+
- This rule has NO exceptions. Even if you "know" what's in a file, read it first.
|
|
133
|
+
- The edit tool will fail if you haven't read the file in this conversation.
|
|
134
|
+
- Understand the existing code structure and style before making changes.
|
|
135
|
+
|
|
136
|
+
# Asking Questions
|
|
137
|
+
|
|
138
|
+
- NEVER ask questions in plain text responses.
|
|
139
|
+
- ALWAYS use the question tool when you need user input.
|
|
140
|
+
- The question tool is MANDATORY for any interaction requiring a user response.
|
|
141
|
+
|
|
142
|
+
When to use the question tool:
|
|
143
|
+
- Multiple valid approaches exist and user preference matters
|
|
144
|
+
- Requirements are genuinely ambiguous
|
|
145
|
+
- Destructive actions need confirmation (delete files, force push)
|
|
146
|
+
- A tool operation was rejected and you need to understand why
|
|
147
|
+
|
|
148
|
+
When NOT to ask:
|
|
149
|
+
- You can figure out the answer by reading/searching
|
|
150
|
+
- The path forward is reasonably clear
|
|
151
|
+
- Standard implementation decisions
|
|
152
|
+
|
|
153
|
+
# Error Handling
|
|
154
|
+
|
|
155
|
+
- If a tool fails, analyze the error and retry with adjusted parameters
|
|
156
|
+
- Announce the error to the user and explain your retry strategy
|
|
157
|
+
- Try 2-3 different approaches before giving up
|
|
158
|
+
- Only ask the user for help after multiple failed attempts
|
|
159
|
+
|
|
160
|
+
# Avoiding Over-Engineering
|
|
161
|
+
|
|
162
|
+
- Only make changes directly requested or clearly necessary
|
|
163
|
+
- Keep solutions simple and focused
|
|
164
|
+
- Don't add features, refactor, or make "improvements" beyond what was asked
|
|
165
|
+
- Don't add comments or type annotations to code you didn't change
|
|
166
|
+
- Don't add error handling for scenarios that can't happen
|
|
167
|
+
- Don't create abstractions for one-time operations
|
|
168
|
+
|
|
169
|
+
# Command Execution
|
|
170
|
+
|
|
171
|
+
CRITICAL: Adapt all commands to {{OS}}
|
|
172
|
+
|
|
173
|
+
Windows ('win32'):
|
|
174
|
+
- Use PowerShell syntax exclusively
|
|
175
|
+
- NO Unix commands: ls -la, touch, export, rm -rf, grep, find, cat
|
|
176
|
+
- USE: Get-ChildItem, New-Item, $env:VAR="val", Remove-Item -Recurse -Force
|
|
177
|
+
|
|
178
|
+
macOS/Linux ('darwin'/'linux'):
|
|
179
|
+
- Use Bash/Zsh syntax
|
|
180
|
+
|
|
181
|
+
TIMEOUTS: Add --timeout <ms> for long-running commands:
|
|
182
|
+
- Dev servers: 5000
|
|
183
|
+
- Builds: 120000
|
|
184
|
+
- Tests: 60000
|
|
185
|
+
- Package installs: 120000
|
|
186
|
+
|
|
187
|
+
# Git Operations
|
|
188
|
+
|
|
189
|
+
- NEVER update git config
|
|
190
|
+
- NEVER use destructive commands without explicit user request (push --force, reset --hard, checkout .)
|
|
191
|
+
- NEVER skip hooks (--no-verify) unless explicitly requested
|
|
192
|
+
- Don't commit unless explicitly asked
|
|
193
|
+
- Stage specific files rather than git add -A
|
|
194
|
+
|
|
195
|
+
# Security
|
|
196
|
+
|
|
197
|
+
Refuse to write or improve code that may be used maliciously, even for "educational purposes".
|
|
198
|
+
Before working on files, assess intent based on filenames and directory structure.
|
|
199
|
+
You may assist with authorized security testing, CTF challenges, and defensive security.
|
|
200
|
+
|
|
201
|
+
# Memory (MOSAIC.md)
|
|
202
|
+
|
|
203
|
+
If a MOSAIC.md file exists, it provides project context: commands, style preferences, conventions.
|
|
204
|
+
When you discover useful commands or preferences, offer to save them to MOSAIC.md.
|
|
205
|
+
|
|
206
|
+
# Scope
|
|
207
|
+
|
|
208
|
+
All requests refer to the current workspace ({{WORKSPACE}}), never to Mosaic itself.
|
|
79
209
|
`;
|
|
80
210
|
|
|
81
211
|
export function processSystemPrompt(prompt: string, includeTools: boolean = true): string {
|
|
@@ -135,4 +265,4 @@ ${mosaicContent}`;
|
|
|
135
265
|
}
|
|
136
266
|
|
|
137
267
|
return processed;
|
|
138
|
-
}
|
|
268
|
+
}
|