micro-models-agent 0.3.0 → 0.4.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/README.md +436 -436
- package/dist/agent/loop.d.ts +5 -5
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +421 -246
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +3 -3
- package/dist/agent/system-prompt.d.ts.map +1 -1
- package/dist/agent/system-prompt.js +383 -278
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +53 -28
- package/dist/cli/config.js.map +1 -1
- package/dist/config/config.d.ts +2 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +75 -54
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +3 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/plugins/builtin/lint-on-write/index.ts +96 -96
- package/dist/plugins/builtin/notify/index.js +6 -6
- package/dist/plugins/builtin/notify/index.ts +104 -104
- package/dist/setup-wizard.d.ts +1 -1
- package/dist/setup-wizard.d.ts.map +1 -1
- package/dist/setup-wizard.js +137 -105
- package/dist/setup-wizard.js.map +1 -1
- package/dist/skills/builtin/agent-test/SKILL.md +68 -68
- package/dist/skills/builtin/grill-me/SKILL.md +46 -46
- package/dist/skills/builtin/web-scraping/SKILL.md +422 -422
- package/dist/tools/native/project-map.d.ts +2 -2
- package/dist/tools/native/project-map.d.ts.map +1 -1
- package/dist/tools/native/project-map.js +85 -57
- package/dist/tools/native/project-map.js.map +1 -1
- package/dist/tools/native/scaffold.js +113 -113
- package/dist/tools/web-browse.js +7 -7
- package/dist/ui/ink/components/App.d.ts +0 -1
- package/dist/ui/ink/components/App.d.ts.map +1 -1
- package/dist/ui/ink/components/App.js +2 -8
- package/dist/ui/ink/components/App.js.map +1 -1
- package/dist/ui/ink/components/Conversation.d.ts +1 -2
- package/dist/ui/ink/components/Conversation.d.ts.map +1 -1
- package/dist/ui/ink/components/Conversation.js +8 -2
- package/dist/ui/ink/components/Conversation.js.map +1 -1
- package/dist/ui/ink/components/MessageBlock.d.ts +13 -1
- package/dist/ui/ink/components/MessageBlock.d.ts.map +1 -1
- package/dist/ui/ink/components/MessageBlock.js +15 -27
- package/dist/ui/ink/components/MessageBlock.js.map +1 -1
- package/dist/ui/ink/components/PromptInput.d.ts +11 -0
- package/dist/ui/ink/components/PromptInput.d.ts.map +1 -1
- package/dist/ui/ink/components/PromptInput.js +18 -141
- package/dist/ui/ink/components/PromptInput.js.map +1 -1
- package/dist/ui/ink/components/SelectInput.d.ts.map +1 -1
- package/dist/ui/ink/components/SelectInput.js +3 -2
- package/dist/ui/ink/components/SelectInput.js.map +1 -1
- package/dist/ui/ink/components/StatusBar.d.ts.map +1 -1
- package/dist/ui/ink/components/StatusBar.js +14 -6
- package/dist/ui/ink/components/StatusBar.js.map +1 -1
- package/dist/ui/ink/components/StreamBlock.d.ts.map +1 -1
- package/dist/ui/ink/components/StreamBlock.js +3 -3
- package/dist/ui/ink/components/StreamBlock.js.map +1 -1
- package/dist/ui/ink/components/Tags.d.ts +8 -11
- package/dist/ui/ink/components/Tags.d.ts.map +1 -1
- package/dist/ui/ink/components/Tags.js +4 -16
- package/dist/ui/ink/components/Tags.js.map +1 -1
- package/dist/ui/ink/components/ToolCallBlock.d.ts +12 -0
- package/dist/ui/ink/components/ToolCallBlock.d.ts.map +1 -1
- package/dist/ui/ink/components/ToolCallBlock.js +8 -24
- package/dist/ui/ink/components/ToolCallBlock.js.map +1 -1
- package/dist/ui/ink/renderer.d.ts +0 -1
- package/dist/ui/ink/renderer.d.ts.map +1 -1
- package/dist/ui/ink/renderer.js +1 -4
- package/dist/ui/ink/renderer.js.map +1 -1
- package/package.json +47 -47
- package/dist/async-map.d.ts +0 -6
- package/dist/async-map.d.ts.map +0 -1
- package/dist/async-map.js +0 -16
- package/dist/async-map.js.map +0 -1
- package/dist/blog-api/types/index.d.ts +0 -2
- package/dist/blog-api/types/index.d.ts.map +0 -1
- package/dist/blog-api/types/index.js +0 -2
- package/dist/blog-api/types/index.js.map +0 -1
- package/dist/examples.d.ts +0 -22
- package/dist/examples.d.ts.map +0 -1
- package/dist/examples.js +0 -45
- package/dist/examples.js.map +0 -1
- package/dist/fibonacci.d.ts +0 -19
- package/dist/fibonacci.d.ts.map +0 -1
- package/dist/fibonacci.js +0 -61
- package/dist/fibonacci.js.map +0 -1
- package/dist/parfymerie-landing/src/App.d.ts +0 -4
- package/dist/parfymerie-landing/src/App.d.ts.map +0 -1
- package/dist/parfymerie-landing/src/App.js +0 -12
- package/dist/parfymerie-landing/src/App.js.map +0 -1
- package/dist/parfymerie-landing/src/main.d.ts +0 -2
- package/dist/parfymerie-landing/src/main.d.ts.map +0 -1
- package/dist/parfymerie-landing/src/main.js +0 -7
- package/dist/parfymerie-landing/src/main.js.map +0 -1
- package/dist/parfymerie-landing/vite.config.d.ts +0 -3
- package/dist/parfymerie-landing/vite.config.d.ts.map +0 -1
- package/dist/parfymerie-landing/vite.config.js +0 -7
- package/dist/parfymerie-landing/vite.config.js.map +0 -1
- package/dist/repl.d.ts +0 -5
- package/dist/repl.d.ts.map +0 -1
- package/dist/repl.js +0 -472
- package/dist/repl.js.map +0 -1
- package/dist/sort.d.ts +0 -8
- package/dist/sort.d.ts.map +0 -1
- package/dist/sort.js +0 -36
- package/dist/sort.js.map +0 -1
- package/dist/stack.d.ts +0 -9
- package/dist/stack.d.ts.map +0 -1
- package/dist/stack.js +0 -22
- package/dist/stack.js.map +0 -1
- package/dist/test-run.d.ts +0 -2
- package/dist/test-run.d.ts.map +0 -1
- package/dist/test-run.js +0 -13
- package/dist/test-run.js.map +0 -1
- package/dist/ui/components/diff-view.d.ts +0 -8
- package/dist/ui/components/diff-view.d.ts.map +0 -1
- package/dist/ui/components/diff-view.js +0 -25
- package/dist/ui/components/diff-view.js.map +0 -1
- package/dist/ui/double-press.d.ts +0 -9
- package/dist/ui/double-press.d.ts.map +0 -1
- package/dist/ui/double-press.js +0 -18
- package/dist/ui/double-press.js.map +0 -1
- package/dist/ui/ink/components/ActivityLog.d.ts +0 -12
- package/dist/ui/ink/components/ActivityLog.d.ts.map +0 -1
- package/dist/ui/ink/components/ActivityLog.js +0 -11
- package/dist/ui/ink/components/ActivityLog.js.map +0 -1
- package/dist/ui/ink/components/AgentStatus.d.ts +0 -13
- package/dist/ui/ink/components/AgentStatus.d.ts.map +0 -1
- package/dist/ui/ink/components/AgentStatus.js +0 -20
- package/dist/ui/ink/components/AgentStatus.js.map +0 -1
- package/dist/ui/ink/components/BottomBar.d.ts +0 -12
- package/dist/ui/ink/components/BottomBar.d.ts.map +0 -1
- package/dist/ui/ink/components/BottomBar.js +0 -22
- package/dist/ui/ink/components/BottomBar.js.map +0 -1
- package/dist/ui/ink/components/CheckboxInput.d.ts +0 -21
- package/dist/ui/ink/components/CheckboxInput.d.ts.map +0 -1
- package/dist/ui/ink/components/CheckboxInput.js +0 -36
- package/dist/ui/ink/components/CheckboxInput.js.map +0 -1
- package/dist/ui/ink/components/InputBox.d.ts +0 -25
- package/dist/ui/ink/components/InputBox.d.ts.map +0 -1
- package/dist/ui/ink/components/InputBox.js +0 -91
- package/dist/ui/ink/components/InputBox.js.map +0 -1
- package/dist/ui/ink/components/ModeSelector.d.ts +0 -8
- package/dist/ui/ink/components/ModeSelector.d.ts.map +0 -1
- package/dist/ui/ink/components/ModeSelector.js +0 -13
- package/dist/ui/ink/components/ModeSelector.js.map +0 -1
- package/dist/ui/ink/components/QuestionBox.d.ts +0 -14
- package/dist/ui/ink/components/QuestionBox.d.ts.map +0 -1
- package/dist/ui/ink/components/QuestionBox.js +0 -35
- package/dist/ui/ink/components/QuestionBox.js.map +0 -1
- package/dist/ui/ink/components/RadioInput.d.ts +0 -17
- package/dist/ui/ink/components/RadioInput.d.ts.map +0 -1
- package/dist/ui/ink/components/RadioInput.js +0 -30
- package/dist/ui/ink/components/RadioInput.js.map +0 -1
- package/dist/ui/ink/components/SliderInput.d.ts +0 -20
- package/dist/ui/ink/components/SliderInput.d.ts.map +0 -1
- package/dist/ui/ink/components/SliderInput.js +0 -40
- package/dist/ui/ink/components/SliderInput.js.map +0 -1
- package/dist/ui/ink/components/StartupScreen.d.ts +0 -19
- package/dist/ui/ink/components/StartupScreen.d.ts.map +0 -1
- package/dist/ui/ink/components/StartupScreen.js +0 -9
- package/dist/ui/ink/components/StartupScreen.js.map +0 -1
- package/dist/ui/ink/components/WelcomeScreen.d.ts +0 -10
- package/dist/ui/ink/components/WelcomeScreen.d.ts.map +0 -1
- package/dist/ui/ink/components/WelcomeScreen.js +0 -8
- package/dist/ui/ink/components/WelcomeScreen.js.map +0 -1
- package/dist/ui/ink/components/Window.d.ts +0 -30
- package/dist/ui/ink/components/Window.d.ts.map +0 -1
- package/dist/ui/ink/components/Window.js +0 -9
- package/dist/ui/ink/components/Window.js.map +0 -1
- package/dist/ui/ink/components/ui/_core.d.ts +0 -113
- package/dist/ui/ink/components/ui/_core.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/_core.js +0 -83
- package/dist/ui/ink/components/ui/_core.js.map +0 -1
- package/dist/ui/ink/components/ui/autocomplete/Autocomplete.d.ts +0 -23
- package/dist/ui/ink/components/ui/autocomplete/Autocomplete.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/autocomplete/Autocomplete.js +0 -56
- package/dist/ui/ink/components/ui/autocomplete/Autocomplete.js.map +0 -1
- package/dist/ui/ink/components/ui/autocomplete/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/autocomplete/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/autocomplete/index.js +0 -2
- package/dist/ui/ink/components/ui/autocomplete/index.js.map +0 -1
- package/dist/ui/ink/components/ui/badge/Badge.d.ts +0 -13
- package/dist/ui/ink/components/ui/badge/Badge.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/badge/Badge.js +0 -17
- package/dist/ui/ink/components/ui/badge/Badge.js.map +0 -1
- package/dist/ui/ink/components/ui/badge/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/badge/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/badge/index.js +0 -2
- package/dist/ui/ink/components/ui/badge/index.js.map +0 -1
- package/dist/ui/ink/components/ui/divider/Divider.d.ts +0 -12
- package/dist/ui/ink/components/ui/divider/Divider.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/divider/Divider.js +0 -27
- package/dist/ui/ink/components/ui/divider/Divider.js.map +0 -1
- package/dist/ui/ink/components/ui/divider/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/divider/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/divider/index.js +0 -2
- package/dist/ui/ink/components/ui/divider/index.js.map +0 -1
- package/dist/ui/ink/components/ui/header/Header.d.ts +0 -13
- package/dist/ui/ink/components/ui/header/Header.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/header/Header.js +0 -33
- package/dist/ui/ink/components/ui/header/Header.js.map +0 -1
- package/dist/ui/ink/components/ui/header/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/header/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/header/index.js +0 -2
- package/dist/ui/ink/components/ui/header/index.js.map +0 -1
- package/dist/ui/ink/components/ui/json-viewer/JSONViewer.d.ts +0 -14
- package/dist/ui/ink/components/ui/json-viewer/JSONViewer.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/json-viewer/JSONViewer.js +0 -144
- package/dist/ui/ink/components/ui/json-viewer/JSONViewer.js.map +0 -1
- package/dist/ui/ink/components/ui/json-viewer/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/json-viewer/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/json-viewer/index.js +0 -2
- package/dist/ui/ink/components/ui/json-viewer/index.js.map +0 -1
- package/dist/ui/ink/components/ui/key-hint/KeyHint.d.ts +0 -14
- package/dist/ui/ink/components/ui/key-hint/KeyHint.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/key-hint/KeyHint.js +0 -5
- package/dist/ui/ink/components/ui/key-hint/KeyHint.js.map +0 -1
- package/dist/ui/ink/components/ui/key-hint/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/key-hint/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/key-hint/index.js +0 -2
- package/dist/ui/ink/components/ui/key-hint/index.js.map +0 -1
- package/dist/ui/ink/components/ui/markdown/Markdown.d.ts +0 -11
- package/dist/ui/ink/components/ui/markdown/Markdown.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/markdown/Markdown.js +0 -129
- package/dist/ui/ink/components/ui/markdown/Markdown.js.map +0 -1
- package/dist/ui/ink/components/ui/markdown/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/markdown/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/markdown/index.js +0 -2
- package/dist/ui/ink/components/ui/markdown/index.js.map +0 -1
- package/dist/ui/ink/components/ui/scroll-area/ScrollArea.d.ts +0 -21
- package/dist/ui/ink/components/ui/scroll-area/ScrollArea.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/scroll-area/ScrollArea.js +0 -42
- package/dist/ui/ink/components/ui/scroll-area/ScrollArea.js.map +0 -1
- package/dist/ui/ink/components/ui/scroll-area/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/scroll-area/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/scroll-area/index.js +0 -2
- package/dist/ui/ink/components/ui/scroll-area/index.js.map +0 -1
- package/dist/ui/ink/components/ui/select/Select.d.ts +0 -19
- package/dist/ui/ink/components/ui/select/Select.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/select/Select.js +0 -73
- package/dist/ui/ink/components/ui/select/Select.js.map +0 -1
- package/dist/ui/ink/components/ui/select/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/select/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/select/index.js +0 -2
- package/dist/ui/ink/components/ui/select/index.js.map +0 -1
- package/dist/ui/ink/components/ui/spinner/Spinner.d.ts +0 -14
- package/dist/ui/ink/components/ui/spinner/Spinner.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/spinner/Spinner.js +0 -16
- package/dist/ui/ink/components/ui/spinner/Spinner.js.map +0 -1
- package/dist/ui/ink/components/ui/spinner/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/spinner/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/spinner/index.js +0 -2
- package/dist/ui/ink/components/ui/spinner/index.js.map +0 -1
- package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.d.ts +0 -12
- package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.js +0 -39
- package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.js.map +0 -1
- package/dist/ui/ink/components/ui/status-indicator/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/status-indicator/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/status-indicator/index.js +0 -2
- package/dist/ui/ink/components/ui/status-indicator/index.js.map +0 -1
- package/dist/ui/ink/components/ui/streaming-text/StreamingText.d.ts +0 -13
- package/dist/ui/ink/components/ui/streaming-text/StreamingText.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/streaming-text/StreamingText.js +0 -22
- package/dist/ui/ink/components/ui/streaming-text/StreamingText.js.map +0 -1
- package/dist/ui/ink/components/ui/streaming-text/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/streaming-text/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/streaming-text/index.js +0 -2
- package/dist/ui/ink/components/ui/streaming-text/index.js.map +0 -1
- package/dist/ui/ink/components/ui/tabs/Tabs.d.ts +0 -20
- package/dist/ui/ink/components/ui/tabs/Tabs.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/tabs/Tabs.js +0 -53
- package/dist/ui/ink/components/ui/tabs/Tabs.js.map +0 -1
- package/dist/ui/ink/components/ui/tabs/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/tabs/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/tabs/index.js +0 -2
- package/dist/ui/ink/components/ui/tabs/index.js.map +0 -1
- package/dist/ui/ink/components/ui/text-input/TextInput.d.ts +0 -22
- package/dist/ui/ink/components/ui/text-input/TextInput.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/text-input/TextInput.js +0 -57
- package/dist/ui/ink/components/ui/text-input/TextInput.js.map +0 -1
- package/dist/ui/ink/components/ui/text-input/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/text-input/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/text-input/index.js +0 -2
- package/dist/ui/ink/components/ui/text-input/index.js.map +0 -1
- package/dist/ui/ink/components/ui/token-counter/TokenCounter.d.ts +0 -17
- package/dist/ui/ink/components/ui/token-counter/TokenCounter.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/token-counter/TokenCounter.js +0 -38
- package/dist/ui/ink/components/ui/token-counter/TokenCounter.js.map +0 -1
- package/dist/ui/ink/components/ui/token-counter/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/token-counter/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/token-counter/index.js +0 -2
- package/dist/ui/ink/components/ui/token-counter/index.js.map +0 -1
- package/dist/ui/ink/components/ui/typewriter/Typewriter.d.ts +0 -14
- package/dist/ui/ink/components/ui/typewriter/Typewriter.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/typewriter/Typewriter.js +0 -57
- package/dist/ui/ink/components/ui/typewriter/Typewriter.js.map +0 -1
- package/dist/ui/ink/components/ui/typewriter/index.d.ts +0 -3
- package/dist/ui/ink/components/ui/typewriter/index.d.ts.map +0 -1
- package/dist/ui/ink/components/ui/typewriter/index.js +0 -2
- package/dist/ui/ink/components/ui/typewriter/index.js.map +0 -1
- package/dist/ui/opentui-renderer.d.ts +0 -53
- package/dist/ui/opentui-renderer.d.ts.map +0 -1
- package/dist/ui/opentui-renderer.js +0 -463
- package/dist/ui/opentui-renderer.js.map +0 -1
- package/dist/utils/memoize.d.ts +0 -14
- package/dist/utils/memoize.d.ts.map +0 -1
- package/dist/utils/memoize.js +0 -51
- package/dist/utils/memoize.js.map +0 -1
- package/dist/utils/types.d.ts +0 -6
- package/dist/utils/types.d.ts.map +0 -1
- package/dist/utils/types.js +0 -2
- package/dist/utils/types.js.map +0 -1
- package/dist/utils.d.ts +0 -22
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -81
- package/dist/utils.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { readFileSync, existsSync } from
|
|
2
|
-
import { resolve } from
|
|
3
|
-
import * as os from
|
|
4
|
-
import { loadAllMemoryDetailed } from
|
|
5
|
-
import { loadProfileSummary } from
|
|
6
|
-
import { getOrBuildProjectMap } from
|
|
7
|
-
import { loadAgentsMd, listSkillsWithDescriptions, formatSkillsBlock, invalidateSkillCaches } from
|
|
8
|
-
import { logInfo, logDebug } from
|
|
1
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import * as os from "node:os";
|
|
4
|
+
import { loadAllMemoryDetailed } from "./memory.js";
|
|
5
|
+
import { loadProfileSummary } from "./user-profile.js";
|
|
6
|
+
import { getOrBuildProjectMap } from "../indexer/cache.js";
|
|
7
|
+
import { loadAgentsMd, listSkillsWithDescriptions, formatSkillsBlock, invalidateSkillCaches, } from "../skills/loader.js";
|
|
8
|
+
import { logInfo, logWarn, logDebug } from "../logger.js";
|
|
9
9
|
/**
|
|
10
10
|
* Build system prompt for the LLM agent.
|
|
11
11
|
*
|
|
@@ -25,173 +25,173 @@ import { logInfo, logDebug } from '../logger.js';
|
|
|
25
25
|
*/
|
|
26
26
|
// ─── Tool format ──────────────────────────────────────
|
|
27
27
|
// System prompt block describing the tool calling format
|
|
28
|
-
const TOOL_FORMAT = `CRITICAL: Use filesystem tools for file operations — they are more reliable than bash.
|
|
29
|
-
|
|
30
|
-
To call a tool, output EXACTLY this format (on its own line):
|
|
31
|
-
|
|
32
|
-
<tool_call>{"name":"tool_name","arguments":{...}}</tool_call>
|
|
33
|
-
|
|
34
|
-
## Subagent — delegate file creation to isolated agent:
|
|
35
|
-
Use for EACH separate file when creating multi-file projects (3+ files).
|
|
36
|
-
One subagent call per file. Subagent has fresh context and works independently.
|
|
37
|
-
|
|
38
|
-
{"name":"subagent","arguments":{"task":"Create src/db.ts: better-sqlite3 connection + users table"}}
|
|
39
|
-
{"name":"subagent","arguments":{"task":"Create src/routes/users.ts: Express CRUD for users","existingFiles":"package.json, src/db.ts"}}
|
|
40
|
-
{"name":"subagent","arguments":{"task":"Run tsc --noEmit to check types"}}
|
|
41
|
-
|
|
42
|
-
Arguments:
|
|
43
|
-
- task (required) — what the subagent should create/fix/check
|
|
44
|
-
- existingFiles (optional) — comma-separated files for cross-file context
|
|
45
|
-
|
|
46
|
-
## Filesystem Tools (USE THESE for file ops):
|
|
47
|
-
|
|
48
|
-
Read a file:
|
|
49
|
-
{"name":"read_file","arguments":{"path":"src/index.ts"}}
|
|
50
|
-
{"name":"read_file","arguments":{"path":"src/index.ts","offset":50,"limit":100}}
|
|
51
|
-
|
|
52
|
-
Write/create a file:
|
|
53
|
-
{"name":"write_file","arguments":{"path":"src/utils.ts","content":"export function foo() { return 1; }"}}
|
|
54
|
-
|
|
55
|
-
Edit (find & replace):
|
|
56
|
-
{"name":"edit_file","arguments":{"path":"src/index.ts","old_string":"old text","new_string":"new text"}}
|
|
57
|
-
|
|
58
|
-
List directory (only when user explicitly asks):
|
|
59
|
-
{"name":"list_dir","arguments":{}}
|
|
60
|
-
{"name":"list_dir","arguments":{"path":"src"}}
|
|
61
|
-
|
|
62
|
-
Create directory: {"name":"create_dir","arguments":{"path":"src/routes"}}
|
|
63
|
-
Delete file: {"name":"delete_file","arguments":{"path":"old-file.ts"}}
|
|
64
|
-
Copy file: {"name":"copy_file","arguments":{"source":"src/a.ts","destination":"src/b.ts"}}
|
|
65
|
-
Move/rename: {"name":"move_file","arguments":{"source":"old.ts","destination":"new.ts"}}
|
|
66
|
-
File info: {"name":"file_info","arguments":{"path":"src/index.ts"}}
|
|
67
|
-
Search files: {"name":"glob_search","arguments":{"pattern":"**/*.ts"}}
|
|
68
|
-
Search content: {"name":"grep_search","arguments":{"pattern":"function","include":"*.ts"}}
|
|
69
|
-
Search with regex: {"name":"grep_search","arguments":{"pattern":"import.*from","include":"*.ts"}}
|
|
70
|
-
Search literal dot: {"name":"grep_search","arguments":{"pattern":"config\\.json"}}
|
|
71
|
-
Directory tree: {"name":"tree","arguments":{"depth":2}}
|
|
72
|
-
|
|
73
|
-
## Plan / Todo / Question / Approve (native tools):
|
|
74
|
-
{"name":"plan","arguments":{"action":"create","name":"Todo App","steps":["Step 1","Step 2"]}}
|
|
75
|
-
{"name":"plan","arguments":{"action":"done","step":1}}
|
|
76
|
-
{"name":"plan","arguments":{"action":"show"}}
|
|
77
|
-
{"name":"plan","arguments":{"action":"clear"}}
|
|
78
|
-
{"name":"todo","arguments":{"action":"add","text":"Implement feature X"}}
|
|
79
|
-
{"name":"todo","arguments":{"action":"list"}}
|
|
80
|
-
{"name":"question","arguments":{"question":"What color?","choices":["Red","Blue"]}}
|
|
81
|
-
{"name":"approve","arguments":{"action":"Delete file foo.ts"}}
|
|
82
|
-
{"name":"user_profile","arguments":{"action":"show"}}
|
|
83
|
-
{"name":"user_profile","arguments":{"action":"add_note","section":"Notes","note":"text"}}
|
|
84
|
-
|
|
85
|
-
## Subagent (isolate a single task in fresh context):
|
|
86
|
-
{"name":"subagent","arguments":{"task":"Create file db.ts with better-sqlite3","existingFiles":"package.json"}}
|
|
87
|
-
|
|
88
|
-
## Web tools (search & fetch):
|
|
89
|
-
{"name":"web_search","arguments":{"query":"weather in Minsk","maxResults":5}}
|
|
90
|
-
{"name":"web_fetch","arguments":{"url":"https://example.com"}}
|
|
91
|
-
|
|
92
|
-
## Web Browse (headless browser):
|
|
93
|
-
{"name":"web_browse","arguments":{"action":"navigate","url":"https://example.com"}}
|
|
94
|
-
{"name":"web_browse","arguments":{"action":"scrape","url":"https://example.com/catalog"}}
|
|
95
|
-
{"name":"web_browse","arguments":{"action":"scrape","url":"https://shop.com/bikes","pattern":"bike|velosiped","maxItems":15}}
|
|
96
|
-
{"name":"web_browse","arguments":{"action":"click","selector":"button.submit"}}
|
|
97
|
-
{"name":"web_browse","arguments":{"action":"type","selector":"#search","value":"hello"}}
|
|
98
|
-
{"name":"web_browse","arguments":{"action":"wait","selector":"#result","timeout":5000}}
|
|
99
|
-
{"name":"web_browse","arguments":{"action":"screenshot"}}
|
|
100
|
-
{"name":"web_browse","arguments":{"action":"close"}}
|
|
101
|
-
|
|
102
|
-
## Theme tool (theme management):
|
|
103
|
-
{"name":"theme","arguments":{"action":"list"}}
|
|
104
|
-
{"name":"theme","arguments":{"action":"switch","name":"dark"}}
|
|
105
|
-
{"name":"theme","arguments":{"action":"show"}}
|
|
106
|
-
{"name":"theme","arguments":{"action":"install","name":"monokai","url":"https://example.com/monokai.json"}}
|
|
107
|
-
{"name":"theme","arguments":{"action":"remove","name":"monokai"}}
|
|
108
|
-
|
|
109
|
-
Themes are in ~/.mma/themes/. Built-in: light, dark. Can install from URL.
|
|
110
|
-
If the user wants to switch themes — suggest a matching one from the list and switch.
|
|
111
|
-
|
|
112
|
-
## Project Map tool (project structure):
|
|
113
|
-
{"name":"project_map","arguments":{"action":"list"}}
|
|
114
|
-
{"name":"project_map","arguments":{"action":"find","pattern":"*.tsx"}}
|
|
115
|
-
{"name":"project_map","arguments":{"action":"info","path":"src/App.tsx"}}
|
|
116
|
-
|
|
117
|
-
CRITICAL: Use project_map FIRST before reading any files. It shows what files exist.
|
|
118
|
-
- action="list" — show all files in the project
|
|
119
|
-
- action="find" — search files by glob pattern
|
|
120
|
-
- action="info" — get details about specific file (path, exports, lines)
|
|
121
|
-
|
|
122
|
-
## Scaffold (create complete project structure programmatically):
|
|
123
|
-
{"name":"scaffold","arguments":{"template":"vite-react-ts","dir":"my-app"}}
|
|
124
|
-
{"name":"scaffold","arguments":{"template":"vite-vanilla-ts","dir":"my-app"}}
|
|
125
|
-
{"name":"scaffold","arguments":{"template":"node-express-ts","dir":"api-server"}}
|
|
126
|
-
|
|
127
|
-
Templates: vite-react-ts (React+TypeScript), vite-vanilla-ts (vanilla TS), node-express-ts (Express+TS)
|
|
128
|
-
Use scaffold INSTEAD of creating project files manually. It creates all config files correctly.
|
|
129
|
-
|
|
130
|
-
## Bash (for non-file operations — npm, git, etc):
|
|
131
|
-
{"name":"bash","arguments":{"cmd":"npm test"}}
|
|
132
|
-
{"name":"bash","arguments":{"cmd":"git status"}}
|
|
133
|
-
|
|
28
|
+
const TOOL_FORMAT = `CRITICAL: Use filesystem tools for file operations — they are more reliable than bash.
|
|
29
|
+
|
|
30
|
+
To call a tool, output EXACTLY this format (on its own line):
|
|
31
|
+
|
|
32
|
+
<tool_call>{"name":"tool_name","arguments":{...}}</tool_call>
|
|
33
|
+
|
|
34
|
+
## Subagent — delegate file creation to isolated agent:
|
|
35
|
+
Use for EACH separate file when creating multi-file projects (3+ files).
|
|
36
|
+
One subagent call per file. Subagent has fresh context and works independently.
|
|
37
|
+
|
|
38
|
+
{"name":"subagent","arguments":{"task":"Create src/db.ts: better-sqlite3 connection + users table"}}
|
|
39
|
+
{"name":"subagent","arguments":{"task":"Create src/routes/users.ts: Express CRUD for users","existingFiles":"package.json, src/db.ts"}}
|
|
40
|
+
{"name":"subagent","arguments":{"task":"Run tsc --noEmit to check types"}}
|
|
41
|
+
|
|
42
|
+
Arguments:
|
|
43
|
+
- task (required) — what the subagent should create/fix/check
|
|
44
|
+
- existingFiles (optional) — comma-separated files for cross-file context
|
|
45
|
+
|
|
46
|
+
## Filesystem Tools (USE THESE for file ops):
|
|
47
|
+
|
|
48
|
+
Read a file:
|
|
49
|
+
{"name":"read_file","arguments":{"path":"src/index.ts"}}
|
|
50
|
+
{"name":"read_file","arguments":{"path":"src/index.ts","offset":50,"limit":100}}
|
|
51
|
+
|
|
52
|
+
Write/create a file:
|
|
53
|
+
{"name":"write_file","arguments":{"path":"src/utils.ts","content":"export function foo() { return 1; }"}}
|
|
54
|
+
|
|
55
|
+
Edit (find & replace):
|
|
56
|
+
{"name":"edit_file","arguments":{"path":"src/index.ts","old_string":"old text","new_string":"new text"}}
|
|
57
|
+
|
|
58
|
+
List directory (only when user explicitly asks):
|
|
59
|
+
{"name":"list_dir","arguments":{}}
|
|
60
|
+
{"name":"list_dir","arguments":{"path":"src"}}
|
|
61
|
+
|
|
62
|
+
Create directory: {"name":"create_dir","arguments":{"path":"src/routes"}}
|
|
63
|
+
Delete file: {"name":"delete_file","arguments":{"path":"old-file.ts"}}
|
|
64
|
+
Copy file: {"name":"copy_file","arguments":{"source":"src/a.ts","destination":"src/b.ts"}}
|
|
65
|
+
Move/rename: {"name":"move_file","arguments":{"source":"old.ts","destination":"new.ts"}}
|
|
66
|
+
File info: {"name":"file_info","arguments":{"path":"src/index.ts"}}
|
|
67
|
+
Search files: {"name":"glob_search","arguments":{"pattern":"**/*.ts"}}
|
|
68
|
+
Search content: {"name":"grep_search","arguments":{"pattern":"function","include":"*.ts"}}
|
|
69
|
+
Search with regex: {"name":"grep_search","arguments":{"pattern":"import.*from","include":"*.ts"}}
|
|
70
|
+
Search literal dot: {"name":"grep_search","arguments":{"pattern":"config\\.json"}}
|
|
71
|
+
Directory tree: {"name":"tree","arguments":{"depth":2}}
|
|
72
|
+
|
|
73
|
+
## Plan / Todo / Question / Approve (native tools):
|
|
74
|
+
{"name":"plan","arguments":{"action":"create","name":"Todo App","steps":["Step 1","Step 2"]}}
|
|
75
|
+
{"name":"plan","arguments":{"action":"done","step":1}}
|
|
76
|
+
{"name":"plan","arguments":{"action":"show"}}
|
|
77
|
+
{"name":"plan","arguments":{"action":"clear"}}
|
|
78
|
+
{"name":"todo","arguments":{"action":"add","text":"Implement feature X"}}
|
|
79
|
+
{"name":"todo","arguments":{"action":"list"}}
|
|
80
|
+
{"name":"question","arguments":{"question":"What color?","choices":["Red","Blue"]}}
|
|
81
|
+
{"name":"approve","arguments":{"action":"Delete file foo.ts"}}
|
|
82
|
+
{"name":"user_profile","arguments":{"action":"show"}}
|
|
83
|
+
{"name":"user_profile","arguments":{"action":"add_note","section":"Notes","note":"text"}}
|
|
84
|
+
|
|
85
|
+
## Subagent (isolate a single task in fresh context):
|
|
86
|
+
{"name":"subagent","arguments":{"task":"Create file db.ts with better-sqlite3","existingFiles":"package.json"}}
|
|
87
|
+
|
|
88
|
+
## Web tools (search & fetch):
|
|
89
|
+
{"name":"web_search","arguments":{"query":"weather in Minsk","maxResults":5}}
|
|
90
|
+
{"name":"web_fetch","arguments":{"url":"https://example.com"}}
|
|
91
|
+
|
|
92
|
+
## Web Browse (headless browser):
|
|
93
|
+
{"name":"web_browse","arguments":{"action":"navigate","url":"https://example.com"}}
|
|
94
|
+
{"name":"web_browse","arguments":{"action":"scrape","url":"https://example.com/catalog"}}
|
|
95
|
+
{"name":"web_browse","arguments":{"action":"scrape","url":"https://shop.com/bikes","pattern":"bike|velosiped","maxItems":15}}
|
|
96
|
+
{"name":"web_browse","arguments":{"action":"click","selector":"button.submit"}}
|
|
97
|
+
{"name":"web_browse","arguments":{"action":"type","selector":"#search","value":"hello"}}
|
|
98
|
+
{"name":"web_browse","arguments":{"action":"wait","selector":"#result","timeout":5000}}
|
|
99
|
+
{"name":"web_browse","arguments":{"action":"screenshot"}}
|
|
100
|
+
{"name":"web_browse","arguments":{"action":"close"}}
|
|
101
|
+
|
|
102
|
+
## Theme tool (theme management):
|
|
103
|
+
{"name":"theme","arguments":{"action":"list"}}
|
|
104
|
+
{"name":"theme","arguments":{"action":"switch","name":"dark"}}
|
|
105
|
+
{"name":"theme","arguments":{"action":"show"}}
|
|
106
|
+
{"name":"theme","arguments":{"action":"install","name":"monokai","url":"https://example.com/monokai.json"}}
|
|
107
|
+
{"name":"theme","arguments":{"action":"remove","name":"monokai"}}
|
|
108
|
+
|
|
109
|
+
Themes are in ~/.mma/themes/. Built-in: light, dark. Can install from URL.
|
|
110
|
+
If the user wants to switch themes — suggest a matching one from the list and switch.
|
|
111
|
+
|
|
112
|
+
## Project Map tool (project structure):
|
|
113
|
+
{"name":"project_map","arguments":{"action":"list"}}
|
|
114
|
+
{"name":"project_map","arguments":{"action":"find","pattern":"*.tsx"}}
|
|
115
|
+
{"name":"project_map","arguments":{"action":"info","path":"src/App.tsx"}}
|
|
116
|
+
|
|
117
|
+
CRITICAL: Use project_map FIRST before reading any files. It shows what files exist.
|
|
118
|
+
- action="list" — show all files in the project
|
|
119
|
+
- action="find" — search files by glob pattern
|
|
120
|
+
- action="info" — get details about specific file (path, exports, lines)
|
|
121
|
+
|
|
122
|
+
## Scaffold (create complete project structure programmatically):
|
|
123
|
+
{"name":"scaffold","arguments":{"template":"vite-react-ts","dir":"my-app"}}
|
|
124
|
+
{"name":"scaffold","arguments":{"template":"vite-vanilla-ts","dir":"my-app"}}
|
|
125
|
+
{"name":"scaffold","arguments":{"template":"node-express-ts","dir":"api-server"}}
|
|
126
|
+
|
|
127
|
+
Templates: vite-react-ts (React+TypeScript), vite-vanilla-ts (vanilla TS), node-express-ts (Express+TS)
|
|
128
|
+
Use scaffold INSTEAD of creating project files manually. It creates all config files correctly.
|
|
129
|
+
|
|
130
|
+
## Bash (for non-file operations — npm, git, etc):
|
|
131
|
+
{"name":"bash","arguments":{"cmd":"npm test"}}
|
|
132
|
+
{"name":"bash","arguments":{"cmd":"git status"}}
|
|
133
|
+
|
|
134
134
|
NEVER output tool calls in any other format. ALWAYS use <tool_call> tags.`;
|
|
135
135
|
// ─── Conversation flow ──────────────────────────────────
|
|
136
136
|
// System prompt block explaining how the dialog cycle works
|
|
137
|
-
const CONVERSATION_FLOW = `## How This Works (IMPORTANT — read this carefully)
|
|
138
|
-
|
|
139
|
-
You are in a loop. Each turn works like this:
|
|
140
|
-
|
|
141
|
-
1. User sends a message
|
|
142
|
-
2. You respond with TEXT and/or TOOL CALLS
|
|
143
|
-
3. Tool results appear — then it is YOUR TURN AGAIN
|
|
144
|
-
4. Repeat until the task is done
|
|
145
|
-
|
|
146
|
-
### What you see after a tool executes:
|
|
147
|
-
|
|
148
|
-
You will see a message like:
|
|
149
|
-
[tool result: "Written 42 bytes (3 lines) to src/index.ts"]
|
|
150
|
-
|
|
151
|
-
This is NOT the end. You MUST continue:
|
|
152
|
-
- If more files need work → call the next tool
|
|
153
|
-
- If the task is done → write a summary to the user
|
|
154
|
-
- If there was an error → explain it and fix it
|
|
155
|
-
|
|
156
|
-
### Example conversation:
|
|
157
|
-
|
|
158
|
-
User: "Create a file src/utils.ts with a hello function"
|
|
159
|
-
|
|
160
|
-
You:
|
|
161
|
-
<tool_call>{"name":"write_file","arguments":{"path":"src/utils.ts","content":"export function hello() { return 'world'; }"}}</tool_call>
|
|
162
|
-
|
|
163
|
-
[Tool result: "Written 52 bytes (1 lines) to src/utils.ts"]
|
|
164
|
-
|
|
165
|
-
You:
|
|
166
|
-
File src/utils.ts created successfully. It exports a hello() function that returns 'world'.
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
137
|
+
const CONVERSATION_FLOW = `## How This Works (IMPORTANT — read this carefully)
|
|
138
|
+
|
|
139
|
+
You are in a loop. Each turn works like this:
|
|
140
|
+
|
|
141
|
+
1. User sends a message
|
|
142
|
+
2. You respond with TEXT and/or TOOL CALLS
|
|
143
|
+
3. Tool results appear — then it is YOUR TURN AGAIN
|
|
144
|
+
4. Repeat until the task is done
|
|
145
|
+
|
|
146
|
+
### What you see after a tool executes:
|
|
147
|
+
|
|
148
|
+
You will see a message like:
|
|
149
|
+
[tool result: "Written 42 bytes (3 lines) to src/index.ts"]
|
|
150
|
+
|
|
151
|
+
This is NOT the end. You MUST continue:
|
|
152
|
+
- If more files need work → call the next tool
|
|
153
|
+
- If the task is done → write a summary to the user
|
|
154
|
+
- If there was an error → explain it and fix it
|
|
155
|
+
|
|
156
|
+
### Example conversation:
|
|
157
|
+
|
|
158
|
+
User: "Create a file src/utils.ts with a hello function"
|
|
159
|
+
|
|
160
|
+
You:
|
|
161
|
+
<tool_call>{"name":"write_file","arguments":{"path":"src/utils.ts","content":"export function hello() { return 'world'; }"}}</tool_call>
|
|
162
|
+
|
|
163
|
+
[Tool result: "Written 52 bytes (1 lines) to src/utils.ts"]
|
|
164
|
+
|
|
165
|
+
You:
|
|
166
|
+
File src/utils.ts created successfully. It exports a hello() function that returns 'world'.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
170
|
NEVER stop after a tool call. ALWAYS continue with either another tool call or a text reply.`;
|
|
171
171
|
const R = {
|
|
172
172
|
fs_tools: `Use filesystem tools for file operations (read_file, write_file, edit_file, list_dir, glob_search, grep_search, tree). Use bash ONLY for non-file commands (npm, git, etc).`,
|
|
173
173
|
user_language: `Always respond in the user's language (Russian or English). Do NOT mix languages in one response — pick ONE and stick with it.`,
|
|
174
|
-
check_result: `CRITICAL: After every tool call, CHECK the result (exit code + output).
|
|
175
|
-
If exit code != 0, DO NOT claim success — tell the user about the error.
|
|
174
|
+
check_result: `CRITICAL: After every tool call, CHECK the result (exit code + output).
|
|
175
|
+
If exit code != 0, DO NOT claim success — tell the user about the error.
|
|
176
176
|
Verify files were created before saying "done".`,
|
|
177
|
-
no_empty: `NEVER return an empty response. After receiving a tool result, you MUST either:
|
|
178
|
-
a) Call another tool (if more work is needed), OR
|
|
179
|
-
b) Write a text response to the user (summarize what was done, report errors, ask questions).
|
|
177
|
+
no_empty: `NEVER return an empty response. After receiving a tool result, you MUST either:
|
|
178
|
+
a) Call another tool (if more work is needed), OR
|
|
179
|
+
b) Write a text response to the user (summarize what was done, report errors, ask questions).
|
|
180
180
|
Staying silent after a tool result is always wrong.`,
|
|
181
|
-
valid_json: `The JSON inside <tool_call> must be VALID JSON. Escape " inside values as \\".
|
|
182
|
-
For grep_search patterns: escape regex special chars with \\ (e.g. \\. for literal dot, \\( for literal paren).
|
|
181
|
+
valid_json: `The JSON inside <tool_call> must be VALID JSON. Escape " inside values as \\".
|
|
182
|
+
For grep_search patterns: escape regex special chars with \\ (e.g. \\. for literal dot, \\( for literal paren).
|
|
183
183
|
Do NOT put quotes inside the pattern — it searches for literal quote characters.`,
|
|
184
|
-
large_files: `For large files (>500 lines), prefer grep_search to find specific content:
|
|
185
|
-
{"name":"grep_search","arguments":{"pattern":"function","include":"*.ts"}}
|
|
186
|
-
Only use read_file with offset/limit when you need to SEE the full file context.
|
|
184
|
+
large_files: `For large files (>500 lines), prefer grep_search to find specific content:
|
|
185
|
+
{"name":"grep_search","arguments":{"pattern":"function","include":"*.ts"}}
|
|
186
|
+
Only use read_file with offset/limit when you need to SEE the full file context.
|
|
187
187
|
Do NOT call read_file multiple times on the same file sequentially — use grep first.`,
|
|
188
188
|
// ── Base/Pro only ──
|
|
189
|
-
planning_skills: `SKILLS AND PLANNING: For complex tasks (3+ steps):
|
|
190
|
-
a. AUTOMATICALLY load relevant skills by mentioning them: "@nodejs-expert @typescript-expert"
|
|
191
|
-
b. Do NOT ask the user — just load and start working
|
|
192
|
-
c. Create a plan with SPECIFIC STEP NAMES: plan({action:"create", name:"TodoApp", steps:["Create package.json and install deps", "Create src/App.tsx", "Create src/main.tsx", "Verify with tsc --noEmit"]})
|
|
193
|
-
d. For each step: use subagent to create the file, then mark step done: plan({action:"done", step:1})
|
|
194
|
-
e. Do NOT use write_file directly when a plan is active — delegate to subagents
|
|
189
|
+
planning_skills: `SKILLS AND PLANNING: For complex tasks (3+ steps):
|
|
190
|
+
a. AUTOMATICALLY load relevant skills by mentioning them: "@nodejs-expert @typescript-expert"
|
|
191
|
+
b. Do NOT ask the user — just load and start working
|
|
192
|
+
c. Create a plan with SPECIFIC STEP NAMES: plan({action:"create", name:"TodoApp", steps:["Create package.json and install deps", "Create src/App.tsx", "Create src/main.tsx", "Verify with tsc --noEmit"]})
|
|
193
|
+
d. For each step: use subagent to create the file, then mark step done: plan({action:"done", step:1})
|
|
194
|
+
e. Do NOT use write_file directly when a plan is active — delegate to subagents
|
|
195
195
|
f. ONE FILE PER STEP — never combine multiple files in one step`,
|
|
196
196
|
simple_tasks: `FOR SIMPLE TASKS (1-2 steps): Just do it, no plan needed. Use common sense.`,
|
|
197
197
|
never_just_talk_common: `NEVER JUST TALK — ALWAYS ACT. Do NOT say "write skills in the next message" or similar waiting phrases. If skills are loaded, START WORKING IMMEDIATELY.`,
|
|
@@ -200,35 +200,35 @@ const R = {
|
|
|
200
200
|
no_list_dir_common: `NEVER call list_dir or tree just to "see what's in the project". Use glob_search or grep_search instead — they give more useful results. Only use list_dir when a user explicitly asks to see a directory listing.`,
|
|
201
201
|
off_topic_common: `OFF-TOPIC QUESTIONS: If the user asks something unrelated to coding (jokes, space, cooking, etc.), answer briefly and warmly — 1-2 sentences. Do NOT refuse or say "I'm a coding assistant". Just answer, then naturally offer to return to work.`,
|
|
202
202
|
one_file_common: `ONE FILE AT A TIME: When creating multiple files: a) Write the FIRST file completely, b) Wait for syntax check result, c) If error → fix it before continuing, d) Only then write the NEXT file. NEVER write multiple files in one response — small models lose track.`,
|
|
203
|
-
subagents_common: `SUBAGENTS — strict delegation for multi-file projects:
|
|
204
|
-
ABSOLUTE RULE: 1 FILE = 1 SUBAGENT CALL. No exceptions.
|
|
205
|
-
- Every file in the plan gets its OWN subagent call.
|
|
206
|
-
- NEVER combine multiple files in one subagent task.
|
|
207
|
-
- If plan has 5 files → 5 separate subagent calls.
|
|
208
|
-
- Task description MUST include the FULL path: "Create ONLY src/db.ts" not just "db.ts".
|
|
209
|
-
CRITICAL RULES FOR SUBAGENT:
|
|
210
|
-
- Subagent MUST create ONLY what is in the task description. Do NOT create extra files.
|
|
211
|
-
- If task says "Create src/db.ts" — create ONLY src/db.ts. Nothing else.
|
|
212
|
-
- NEVER let subagent "help" by creating additional files beyond the task scope.
|
|
213
|
-
- After subagent completes, parent checks what was created and verifies it matches the plan.
|
|
214
|
-
Example: subagent({task:"Create ONLY src/db.ts with sqlite connection", existingFiles:"src/types.ts"})
|
|
215
|
-
Do NOT use subagent for:
|
|
216
|
-
- Editing existing files (use edit_file directly)
|
|
217
|
-
- Bash commands like npm install, git, etc. (use bash tool)
|
|
203
|
+
subagents_common: `SUBAGENTS — strict delegation for multi-file projects:
|
|
204
|
+
ABSOLUTE RULE: 1 FILE = 1 SUBAGENT CALL. No exceptions.
|
|
205
|
+
- Every file in the plan gets its OWN subagent call.
|
|
206
|
+
- NEVER combine multiple files in one subagent task.
|
|
207
|
+
- If plan has 5 files → 5 separate subagent calls.
|
|
208
|
+
- Task description MUST include the FULL path: "Create ONLY src/db.ts" not just "db.ts".
|
|
209
|
+
CRITICAL RULES FOR SUBAGENT:
|
|
210
|
+
- Subagent MUST create ONLY what is in the task description. Do NOT create extra files.
|
|
211
|
+
- If task says "Create src/db.ts" — create ONLY src/db.ts. Nothing else.
|
|
212
|
+
- NEVER let subagent "help" by creating additional files beyond the task scope.
|
|
213
|
+
- After subagent completes, parent checks what was created and verifies it matches the plan.
|
|
214
|
+
Example: subagent({task:"Create ONLY src/db.ts with sqlite connection", existingFiles:"src/types.ts"})
|
|
215
|
+
Do NOT use subagent for:
|
|
216
|
+
- Editing existing files (use edit_file directly)
|
|
217
|
+
- Bash commands like npm install, git, etc. (use bash tool)
|
|
218
218
|
Each subagent gets fresh context. Parent only tracks results (summary). After all subagents — verify with tsc --noEmit.`,
|
|
219
219
|
check_before_install: `CHECK BEFORE INSTALLING: Read the project dependency file. If the package is already listed — do not install it.`,
|
|
220
220
|
file_extensions: `FILE EXTENSIONS MATTER: .tsx for TypeScript, .jsx for plain JavaScript. Check existing files to determine which stack the project uses.`,
|
|
221
221
|
user_answers: `USER ANSWERS: When you see "User answered: X" in the conversation, this is the user's response to your question. Use it and proceed. NEVER ask the same question again.`,
|
|
222
222
|
project_map_common: `PROJECT MAP FIRST: ALWAYS check the ## Project Map section in your context BEFORE reading any files. The map shows ALL files in the project with their paths. If a file is not in the map — it doesn't exist. Do NOT guess file paths — use the map. If the map shows files inside a subdirectory (e.g. my-project/src/App.tsx), that's where the actual project lives — work inside that subdirectory.`,
|
|
223
|
-
subagent_context_common: `SUBAGENT CONTEXT: When calling subagent, ALWAYS pass:
|
|
224
|
-
- existingFiles: files already created in this session (prevents duplicates)
|
|
225
|
-
- The task description should say "Create ONLY file X" — not "Create file X and related files"
|
|
226
|
-
Example: subagent({task:"Create ONLY src/api.ts with Express CRUD", existingFiles:"src/db.ts,src/types.ts"})
|
|
223
|
+
subagent_context_common: `SUBAGENT CONTEXT: When calling subagent, ALWAYS pass:
|
|
224
|
+
- existingFiles: files already created in this session (prevents duplicates)
|
|
225
|
+
- The task description should say "Create ONLY file X" — not "Create file X and related files"
|
|
226
|
+
Example: subagent({task:"Create ONLY src/api.ts with Express CRUD", existingFiles:"src/db.ts,src/types.ts"})
|
|
227
227
|
The subagent will see the project context and should NOT create files beyond what's in the task.`,
|
|
228
|
-
web_tools: `WEB TOOLS STRATEGY:
|
|
229
|
-
a. For data extraction (products, listings, cards): use web_browse(action:"scrape") — ONE call navigates, scrolls, discovers, and extracts.
|
|
230
|
-
b. For simple pages (blogs, docs, API): use web_fetch — lightweight, no browser needed.
|
|
231
|
-
c. For interactive pages (login, forms, search): navigate → click/type → wait → scrape.
|
|
228
|
+
web_tools: `WEB TOOLS STRATEGY:
|
|
229
|
+
a. For data extraction (products, listings, cards): use web_browse(action:"scrape") — ONE call navigates, scrolls, discovers, and extracts.
|
|
230
|
+
b. For simple pages (blogs, docs, API): use web_fetch — lightweight, no browser needed.
|
|
231
|
+
c. For interactive pages (login, forms, search): navigate → click/type → wait → scrape.
|
|
232
232
|
d. Retry scrape with a custom pattern if the default misses content: {pattern:"product|card|item"}.`,
|
|
233
233
|
// ── Fast mode only ──
|
|
234
234
|
execute_directly: `Execute tasks directly. Simple tasks (1-2 steps): just do it without commentary. Complex tasks: break into steps and execute ONE FILE AT A TIME. Write first file → check syntax → fix if needed → then next file.`,
|
|
@@ -242,67 +242,103 @@ const R = {
|
|
|
242
242
|
subagent_context_fast: `SUBAGENT CONTEXT: When calling subagent, pass existingFiles and use "Create ONLY" in task. Example: subagent({task:"Create ONLY X.ts with debounce function", existingFiles:"Y.ts"})`,
|
|
243
243
|
};
|
|
244
244
|
function composeRules(keys) {
|
|
245
|
-
return
|
|
245
|
+
return "Rules:\n" + keys.map((k, i) => `${i + 1}. ${R[k]}`).join("\n");
|
|
246
246
|
}
|
|
247
247
|
const RULES_COMMON = composeRules([
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
248
|
+
"fs_tools",
|
|
249
|
+
"user_language",
|
|
250
|
+
"check_result",
|
|
251
|
+
"no_empty",
|
|
252
|
+
"valid_json",
|
|
253
|
+
"large_files",
|
|
254
|
+
"planning_skills",
|
|
255
|
+
"simple_tasks",
|
|
256
|
+
"never_just_talk_common",
|
|
257
|
+
"skills_loaded",
|
|
258
|
+
"user_profile_common",
|
|
259
|
+
"no_list_dir_common",
|
|
260
|
+
"off_topic_common",
|
|
261
|
+
"one_file_common",
|
|
262
|
+
"subagents_common",
|
|
263
|
+
"check_before_install",
|
|
264
|
+
"file_extensions",
|
|
265
|
+
"user_answers",
|
|
266
|
+
"project_map_common",
|
|
267
|
+
"subagent_context_common",
|
|
268
|
+
"web_tools",
|
|
253
269
|
]);
|
|
254
270
|
const RULES_FAST = composeRules([
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
271
|
+
"fs_tools",
|
|
272
|
+
"user_language",
|
|
273
|
+
"check_result",
|
|
274
|
+
"no_empty",
|
|
275
|
+
"valid_json",
|
|
276
|
+
"large_files",
|
|
277
|
+
"execute_directly",
|
|
278
|
+
"never_just_talk_fast",
|
|
279
|
+
"user_profile_fast",
|
|
280
|
+
"no_list_dir_fast",
|
|
281
|
+
"off_topic_fast",
|
|
282
|
+
"one_file_fast",
|
|
283
|
+
"subagents_fast",
|
|
284
|
+
"check_before_install",
|
|
285
|
+
"file_extensions",
|
|
286
|
+
"user_answers",
|
|
287
|
+
"project_map_fast",
|
|
288
|
+
"subagent_context_fast",
|
|
289
|
+
"web_tools",
|
|
259
290
|
]);
|
|
260
|
-
const GROUNDING_RULE = `## Grounding Rule (CRITICAL — prevents hallucinations)
|
|
261
|
-
Before EVERY <tool_call> to a filesystem tool (read_file, write_file, edit_file, etc.),
|
|
262
|
-
you MUST output a grounding marker on its own line:
|
|
263
|
-
@grounding[файл: <target-path>]
|
|
264
|
-
where <target-path> is the file path from the tool call arguments.
|
|
265
|
-
This proves you know which file you are operating on and prevents path hallucinations.
|
|
266
|
-
|
|
267
|
-
Examples:
|
|
268
|
-
@grounding[файл: src/index.ts]
|
|
269
|
-
<tool_call>{"name":"read_file","arguments":{"path":"src/index.ts"}}</tool_call>
|
|
270
|
-
|
|
271
|
-
@grounding[файл: src/utils.ts]
|
|
272
|
-
<tool_call>{"name":"write_file","arguments":{"path":"src/utils.ts","content":"..."}}</tool_call>
|
|
273
|
-
|
|
291
|
+
const GROUNDING_RULE = `## Grounding Rule (CRITICAL — prevents hallucinations)
|
|
292
|
+
Before EVERY <tool_call> to a filesystem tool (read_file, write_file, edit_file, etc.),
|
|
293
|
+
you MUST output a grounding marker on its own line:
|
|
294
|
+
@grounding[файл: <target-path>]
|
|
295
|
+
where <target-path> is the file path from the tool call arguments.
|
|
296
|
+
This proves you know which file you are operating on and prevents path hallucinations.
|
|
297
|
+
|
|
298
|
+
Examples:
|
|
299
|
+
@grounding[файл: src/index.ts]
|
|
300
|
+
<tool_call>{"name":"read_file","arguments":{"path":"src/index.ts"}}</tool_call>
|
|
301
|
+
|
|
302
|
+
@grounding[файл: src/utils.ts]
|
|
303
|
+
<tool_call>{"name":"write_file","arguments":{"path":"src/utils.ts","content":"..."}}</tool_call>
|
|
304
|
+
|
|
274
305
|
If you cannot determine the exact file path — do NOT call the tool. Ask the user for clarification first.`;
|
|
275
|
-
const POWERSHELL_EXAMPLES = `Examples (PowerShell):
|
|
276
|
-
<tool_call>{"name":"bash","arguments":{"cmd":"dir"}}</tool_call>
|
|
277
|
-
<tool_call>{"name":"bash","arguments":{"cmd":"Get-Content src\\\\index.ts"}}</tool_call>
|
|
278
|
-
<tool_call>{"name":"bash","arguments":{"cmd":"npm test"}}</tool_call>
|
|
306
|
+
const POWERSHELL_EXAMPLES = `Examples (PowerShell):
|
|
307
|
+
<tool_call>{"name":"bash","arguments":{"cmd":"dir"}}</tool_call>
|
|
308
|
+
<tool_call>{"name":"bash","arguments":{"cmd":"Get-Content src\\\\index.ts"}}</tool_call>
|
|
309
|
+
<tool_call>{"name":"bash","arguments":{"cmd":"npm test"}}</tool_call>
|
|
279
310
|
<tool_call>{"name":"bash","arguments":{"cmd":"Set-Content -Path file.md -Value 'Hello World'"}}</tool_call>`;
|
|
280
|
-
const POWERSHELL_RULES = `PowerShell specifics:
|
|
281
|
-
- NEVER use && in commands — PowerShell doesn't support it. Use ; instead, or make separate bash calls.
|
|
282
|
-
WRONG: cd my-app && npm install
|
|
283
|
-
RIGHT: npm install (run from my-app directory)
|
|
284
|
-
RIGHT: Set-Location my-app; npm install
|
|
285
|
-
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
-
|
|
289
|
-
-
|
|
290
|
-
-
|
|
291
|
-
-
|
|
292
|
-
-
|
|
293
|
-
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
311
|
+
const POWERSHELL_RULES = `PowerShell specifics:
|
|
312
|
+
- NEVER use && in commands — PowerShell doesn't support it. Use ; instead, or make separate bash calls.
|
|
313
|
+
WRONG: cd my-app && npm install
|
|
314
|
+
RIGHT: npm install (run from my-app directory)
|
|
315
|
+
RIGHT: Set-Location my-app; npm install
|
|
316
|
+
- Use Get-ChildItem (NOT dir /s) to list files recursively.
|
|
317
|
+
WRONG: dir /s src (PowerShell interprets /s as a path, not a flag)
|
|
318
|
+
RIGHT: Get-ChildItem -Recurse src
|
|
319
|
+
- Create/write files: Set-Content -Path file.md -Value "content"
|
|
320
|
+
- Append to file: Add-Content -Path file.md -Value "line"
|
|
321
|
+
- Read files: Get-Content file.md
|
|
322
|
+
- List directory: Get-ChildItem (or dir)
|
|
323
|
+
- List directory recursively: Get-ChildItem -Recurse
|
|
324
|
+
- Create directories: New-Item -ItemType Directory -Force -Path "folder"
|
|
325
|
+
- NEVER use: echo -e, cat (use Get-Content), mkdir -p, cp, mv, sed (PowerShell has different syntax)
|
|
326
|
+
- NEVER use single quotes for strings with \\n, \\t — use DOUBLE quotes: "line1\\nline2"
|
|
327
|
+
- Paths use backslashes: src\\index.ts
|
|
328
|
+
- Check file exists: Test-Path file.md
|
|
329
|
+
- Install deps: npm install (NOT npm i)
|
|
330
|
+
- Run dev: npm run dev (NOT npx tsx watch)
|
|
331
|
+
- Run status checks: git status (works fine, no special syntax needed)`;
|
|
332
|
+
const UNIX_EXAMPLES = `Examples (Linux/macOS):
|
|
333
|
+
<tool_call>{"name":"bash","arguments":{"cmd":"ls -la"}}</tool_call>
|
|
334
|
+
<tool_call>{"name":"bash","arguments":{"cmd":"cat src/index.ts"}}</tool_call>
|
|
335
|
+
<tool_call>{"name":"bash","arguments":{"cmd":"npm test"}}</tool_call>
|
|
300
336
|
<tool_call>{"name":"bash","arguments":{"cmd":"echo 'Hello World' > file.md"}}</tool_call>`;
|
|
301
|
-
const UNIX_RULES = `Unix specifics:
|
|
302
|
-
- Create/write files: echo "content" > file.md
|
|
303
|
-
- Read files: cat file.md
|
|
304
|
-
- List directory: ls -la
|
|
305
|
-
- Paths use forward slashes: src/index.ts
|
|
337
|
+
const UNIX_RULES = `Unix specifics:
|
|
338
|
+
- Create/write files: echo "content" > file.md
|
|
339
|
+
- Read files: cat file.md
|
|
340
|
+
- List directory: ls -la
|
|
341
|
+
- Paths use forward slashes: src/index.ts
|
|
306
342
|
- Check file exists: test -f file.md`;
|
|
307
343
|
// ─── System prompt cache ────────────────────────────────
|
|
308
344
|
// Caches the assembled prompt by key (cwd + mode + skills)
|
|
@@ -334,91 +370,160 @@ export function invalidateSystemPromptCache() {
|
|
|
334
370
|
export function buildSystemPrompt(extraSkills, mode, pluginSections, flags) {
|
|
335
371
|
const start = performance.now();
|
|
336
372
|
// Cache key: current directory + mode + skill names (sorted)
|
|
337
|
-
const key = `${process.cwd()}:${mode ||
|
|
373
|
+
const key = `${process.cwd()}:${mode || "base"}:${extraSkills
|
|
374
|
+
?.map((s) => s.name)
|
|
375
|
+
.sort()
|
|
376
|
+
.join(",") || ""}:${pluginSections?.length || 0}`;
|
|
338
377
|
const cached = systemPromptCache.get(key);
|
|
339
378
|
if (cached) {
|
|
340
|
-
logDebug(
|
|
379
|
+
logDebug("SYSTEM", "buildSystemPrompt: cache hit");
|
|
341
380
|
return cached;
|
|
342
381
|
}
|
|
343
|
-
logDebug(
|
|
344
|
-
const isWin = os.platform() ===
|
|
345
|
-
const platformName = isWin ?
|
|
382
|
+
logDebug("SYSTEM", "buildSystemPrompt: building from scratch");
|
|
383
|
+
const isWin = os.platform() === "win32";
|
|
384
|
+
const platformName = isWin ? "Windows" : os.platform();
|
|
346
385
|
let osVersion = platformName;
|
|
347
386
|
try {
|
|
348
387
|
osVersion += ` (${os.version()})`;
|
|
349
388
|
}
|
|
350
|
-
catch {
|
|
389
|
+
catch {
|
|
390
|
+
/* ignore */
|
|
391
|
+
}
|
|
351
392
|
const now = new Date();
|
|
352
|
-
const dateStr = now.toLocaleDateString(
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
393
|
+
const dateStr = now.toLocaleDateString("en-US", {
|
|
394
|
+
year: "numeric",
|
|
395
|
+
month: "long",
|
|
396
|
+
day: "numeric",
|
|
397
|
+
weekday: "long",
|
|
398
|
+
});
|
|
399
|
+
const timeStr = now.toLocaleTimeString("en-US");
|
|
400
|
+
let projectName = "unknown";
|
|
401
|
+
const pkgPath = resolve(process.cwd(), "package.json");
|
|
356
402
|
if (existsSync(pkgPath)) {
|
|
357
403
|
try {
|
|
358
|
-
const pkg = JSON.parse(readFileSync(pkgPath,
|
|
404
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
359
405
|
// Читаем ТОЛЬКО имя проекта — никакие другие поля package.json
|
|
360
406
|
// не должны попадать в system prompt (возможны токены, apiKey и т.д.)
|
|
361
|
-
if (typeof pkg.name ===
|
|
407
|
+
if (typeof pkg.name === "string" && pkg.name) {
|
|
362
408
|
projectName = pkg.name;
|
|
363
409
|
}
|
|
364
410
|
}
|
|
365
|
-
catch {
|
|
411
|
+
catch {
|
|
412
|
+
/* ignore */
|
|
413
|
+
}
|
|
366
414
|
}
|
|
367
|
-
const rules = mode ===
|
|
415
|
+
const rules = mode === "fast" ? RULES_FAST : RULES_COMMON;
|
|
368
416
|
const platformBlock = isWin
|
|
369
|
-
? [
|
|
370
|
-
|
|
371
|
-
|
|
417
|
+
? [
|
|
418
|
+
TOOL_FORMAT,
|
|
419
|
+
CONVERSATION_FLOW,
|
|
420
|
+
GROUNDING_RULE,
|
|
421
|
+
POWERSHELL_EXAMPLES,
|
|
422
|
+
rules,
|
|
423
|
+
POWERSHELL_RULES,
|
|
424
|
+
].join("\n\n")
|
|
425
|
+
: [
|
|
426
|
+
TOOL_FORMAT,
|
|
427
|
+
CONVERSATION_FLOW,
|
|
428
|
+
GROUNDING_RULE,
|
|
429
|
+
UNIX_EXAMPLES,
|
|
430
|
+
rules,
|
|
431
|
+
UNIX_RULES,
|
|
432
|
+
].join("\n\n");
|
|
433
|
+
const header = `You are Micro Models Agent (MMA), an AI coding assistant.
|
|
372
434
|
You help with software engineering tasks in the project directory.`;
|
|
373
435
|
const sysInfo = [
|
|
374
|
-
|
|
375
|
-
|
|
436
|
+
"",
|
|
437
|
+
"## System",
|
|
376
438
|
`Date: ${dateStr}`,
|
|
377
439
|
`Time: ${timeStr}`,
|
|
378
440
|
`OS: ${osVersion}`,
|
|
379
441
|
`Node.js: ${process.version}`,
|
|
380
442
|
`CWD: ${process.cwd()}`,
|
|
381
443
|
`Project: ${projectName}`,
|
|
382
|
-
|
|
383
|
-
].join(
|
|
444
|
+
"",
|
|
445
|
+
].join("\n");
|
|
384
446
|
// ─── Memory and user profile ──────────────────────────
|
|
385
447
|
const memory = loadAllMemoryDetailed();
|
|
386
448
|
const userProfile = loadProfileSummary();
|
|
387
449
|
// ─── Project map (from indexer) ───────────────────────
|
|
388
|
-
let projectMap =
|
|
450
|
+
let projectMap = "";
|
|
389
451
|
try {
|
|
390
452
|
const { formatted, fromCache } = getOrBuildProjectMap(process.cwd());
|
|
391
453
|
if (formatted) {
|
|
392
|
-
projectMap = `\n## Project Map${fromCache ?
|
|
454
|
+
projectMap = `\n## Project Map${fromCache ? " (cached)" : ""}\n${formatted}`;
|
|
393
455
|
}
|
|
394
456
|
}
|
|
395
|
-
catch {
|
|
457
|
+
catch {
|
|
458
|
+
/* ignore */
|
|
459
|
+
}
|
|
396
460
|
// ─── Project instructions (AGENTS.md) ─────────────────
|
|
397
461
|
const agentsMd = flags?.dev ? null : loadAgentsMd(process.cwd());
|
|
398
|
-
const agentsBlock = agentsMd
|
|
462
|
+
const agentsBlock = agentsMd
|
|
463
|
+
? `\n## Project Instructions (AGENTS.md)\n${agentsMd}`
|
|
464
|
+
: "";
|
|
399
465
|
// ─── Available skills hint ────────────────────────────
|
|
400
466
|
const allSkills = listSkillsWithDescriptions();
|
|
401
|
-
const truncateDesc = (d, max = 100) => d.length <= max ? d : d.slice(0, max - 1) +
|
|
467
|
+
const truncateDesc = (d, max = 100) => d.length <= max ? d : d.slice(0, max - 1) + "…";
|
|
402
468
|
const skillsHint = allSkills.length > 0
|
|
403
|
-
? `\n## Available Skills (${allSkills.length})\nSkills contain ready-made workflows, best practices, and step-by-step guides.\nFor complex tasks (3+ steps): mention @skill-name in your response — skills will be auto-loaded into context.\nDo NOT put @skill-name inside tool_call. Just mention them naturally in your text.\nWorkflow:\n 1. User asks: "Create a REST API"\n 2. You: "I'll use @typescript-expert @nodejs-expert for this task." (skills auto-load on next turn)\n 3. You create plan BASED ON skill guidance: plan create REST API ...\n 4. You execute plan step by step\n\nAvailable skills:\n${allSkills
|
|
469
|
+
? `\n## Available Skills (${allSkills.length})\nSkills contain ready-made workflows, best practices, and step-by-step guides.\nFor complex tasks (3+ steps): mention @skill-name in your response — skills will be auto-loaded into context.\nDo NOT put @skill-name inside tool_call. Just mention them naturally in your text.\nWorkflow:\n 1. User asks: "Create a REST API"\n 2. You: "I'll use @typescript-expert @nodejs-expert for this task." (skills auto-load on next turn)\n 3. You create plan BASED ON skill guidance: plan create REST API ...\n 4. You execute plan step by step\n\nAvailable skills:\n${allSkills
|
|
470
|
+
.map((s) => s.description
|
|
404
471
|
? ` @${s.name} — ${truncateDesc(s.description)}`
|
|
405
|
-
: ` @${s.name}`)
|
|
406
|
-
|
|
472
|
+
: ` @${s.name}`)
|
|
473
|
+
.join("\n")}`
|
|
474
|
+
: "";
|
|
407
475
|
// ─── Mode block ──────────────────────────────────────
|
|
408
|
-
const modeBlock = mode ===
|
|
476
|
+
const modeBlock = mode === "fast"
|
|
409
477
|
? `\n## Mode: Fast\n\u26a1 Fast mode \u2014 execute tasks directly without planning or loading skills. Skills are not available in this mode. Proceed immediately.`
|
|
410
|
-
: mode ===
|
|
478
|
+
: mode === "pro"
|
|
411
479
|
? `\n## Mode: Pro\n\ud83d\udd0d Pro mode — @grill-me skill is pre-loaded. Before starting any task, you MUST first read and run the grill-me skill instructions to clarify requirements. Use it to refine the task before execution. Minimum context window: 64000.`
|
|
412
|
-
:
|
|
480
|
+
: "";
|
|
413
481
|
// ─── Final prompt assembly ───────────────────────────
|
|
414
|
-
const base = mode ===
|
|
415
|
-
? [
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
482
|
+
const base = mode === "fast"
|
|
483
|
+
? [
|
|
484
|
+
header,
|
|
485
|
+
platformBlock,
|
|
486
|
+
sysInfo,
|
|
487
|
+
memory,
|
|
488
|
+
userProfile,
|
|
489
|
+
projectMap,
|
|
490
|
+
agentsBlock,
|
|
491
|
+
modeBlock,
|
|
492
|
+
]
|
|
493
|
+
.filter(Boolean)
|
|
494
|
+
.join("\n")
|
|
495
|
+
: [
|
|
496
|
+
header,
|
|
497
|
+
platformBlock,
|
|
498
|
+
sysInfo,
|
|
499
|
+
memory,
|
|
500
|
+
userProfile,
|
|
501
|
+
projectMap,
|
|
502
|
+
agentsBlock,
|
|
503
|
+
skillsHint,
|
|
504
|
+
modeBlock,
|
|
505
|
+
]
|
|
506
|
+
.filter(Boolean)
|
|
507
|
+
.join("\n");
|
|
508
|
+
const result = base +
|
|
509
|
+
(extraSkills && extraSkills.length > 0 && mode !== "fast"
|
|
510
|
+
? "\n\n" + formatSkillsBlock(extraSkills)
|
|
511
|
+
: "") +
|
|
512
|
+
(pluginSections?.length
|
|
513
|
+
? "\n\n## Plugin Context (facts only)\n\n" +
|
|
514
|
+
pluginSections
|
|
515
|
+
.map((s) => {
|
|
516
|
+
// Лимит: 200 токенов ≈ 800 символов на секцию плагина
|
|
517
|
+
if (s.length > 800) {
|
|
518
|
+
logWarn("SYSTEM", `plugin section too long (${s.length} chars), truncating to 800`);
|
|
519
|
+
return s.slice(0, 800) + "\n[truncated]";
|
|
520
|
+
}
|
|
521
|
+
return s;
|
|
522
|
+
})
|
|
523
|
+
.join("\n\n")
|
|
524
|
+
: "");
|
|
420
525
|
const elapsed = (performance.now() - start).toFixed(0);
|
|
421
|
-
logInfo(
|
|
526
|
+
logInfo("SYSTEM", `buildSystemPrompt: ${result.length} chars in ${elapsed}ms`);
|
|
422
527
|
systemPromptCache.set(key, result);
|
|
423
528
|
return result;
|
|
424
529
|
}
|