wave-agent-sdk 1.1.5 → 1.3.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/dist/agent.d.ts +128 -28
- package/dist/agent.js +201 -49
- package/dist/builtin/index.js +2 -0
- package/dist/builtin/plugins.js +11 -20
- package/dist/builtin/skills/settings.js +7 -20
- package/dist/builtin/skills/wave-daemon.d.ts +1 -0
- package/dist/builtin/skills/wave-daemon.js +194 -0
- package/dist/constants/images.d.ts +26 -0
- package/dist/constants/images.js +26 -0
- package/dist/constants/index.d.ts +16 -0
- package/dist/constants/index.js +16 -0
- package/dist/constants/memory.d.ts +26 -0
- package/dist/constants/memory.js +34 -0
- package/dist/constants/messages.d.ts +11 -0
- package/dist/constants/messages.js +11 -0
- package/dist/constants/plugins.d.ts +8 -0
- package/dist/constants/plugins.js +8 -0
- package/dist/constants/tools.d.ts +1 -0
- package/dist/constants/tools.js +1 -0
- package/dist/core/plugin.d.ts +54 -10
- package/dist/core/plugin.js +137 -23
- package/dist/core/session.d.ts +1 -1
- package/dist/core/session.js +1 -1
- package/dist/exec/catalog.d.ts +140 -0
- package/dist/exec/catalog.js +470 -0
- package/dist/exec/catalogAnnouncement.d.ts +89 -0
- package/dist/exec/catalogAnnouncement.js +293 -0
- package/dist/exec/constants.d.ts +51 -0
- package/dist/exec/constants.js +51 -0
- package/dist/exec/execRuntime.d.ts +55 -0
- package/dist/exec/execRuntime.js +217 -0
- package/dist/exec/workerSource.d.ts +28 -0
- package/dist/exec/workerSource.js +299 -0
- package/dist/host/index.d.ts +23 -0
- package/dist/host/index.js +23 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +8 -1
- package/dist/managers/MemoryRuleManager.d.ts +6 -0
- package/dist/managers/MemoryRuleManager.js +12 -0
- package/dist/managers/aiManager.d.ts +35 -25
- package/dist/managers/aiManager.js +204 -202
- package/dist/managers/backgroundTaskManager.js +14 -0
- package/dist/managers/bashModeManager.d.ts +33 -0
- package/dist/managers/bashModeManager.js +110 -0
- package/dist/managers/hookManager.d.ts +18 -0
- package/dist/managers/hookManager.js +37 -3
- package/dist/managers/liveConfigManager.d.ts +33 -0
- package/dist/managers/liveConfigManager.js +106 -11
- package/dist/managers/lspManager.d.ts +9 -0
- package/dist/managers/lspManager.js +47 -18
- package/dist/managers/mcpManager.d.ts +68 -10
- package/dist/managers/mcpManager.js +265 -15
- package/dist/managers/messageManager.d.ts +60 -18
- package/dist/managers/messageManager.js +170 -81
- package/dist/managers/permissionManager.d.ts +69 -0
- package/dist/managers/permissionManager.js +221 -78
- package/dist/managers/planManager.d.ts +9 -0
- package/dist/managers/planManager.js +19 -1
- package/dist/managers/pluginManager.d.ts +46 -2
- package/dist/managers/pluginManager.js +117 -11
- package/dist/managers/pluginScopeManager.d.ts +15 -2
- package/dist/managers/pluginScopeManager.js +20 -1
- package/dist/managers/skillManager.d.ts +50 -0
- package/dist/managers/skillManager.js +166 -12
- package/dist/managers/slashCommandManager.d.ts +10 -0
- package/dist/managers/slashCommandManager.js +44 -31
- package/dist/managers/subagentManager.d.ts +15 -0
- package/dist/managers/subagentManager.js +81 -9
- package/dist/managers/toolManager.d.ts +29 -3
- package/dist/managers/toolManager.js +87 -13
- package/dist/managers/workflowManager.js +6 -0
- package/dist/prompts/autoMemory.d.ts +9 -0
- package/dist/prompts/autoMemory.js +30 -31
- package/dist/prompts/autoMemoryExtraction.d.ts +4 -0
- package/dist/prompts/autoMemoryExtraction.js +8 -111
- package/dist/prompts/index.d.ts +0 -1
- package/dist/prompts/index.js +0 -4
- package/dist/prompts/memoryTypes.d.ts +63 -0
- package/dist/prompts/memoryTypes.js +191 -0
- package/dist/services/GitService.d.ts +7 -0
- package/dist/services/GitService.js +23 -0
- package/dist/services/MarketplaceService.d.ts +101 -17
- package/dist/services/MarketplaceService.js +323 -102
- package/dist/services/artifactContent.d.ts +84 -0
- package/dist/services/artifactContent.js +204 -0
- package/dist/services/artifactSession.d.ts +6 -0
- package/dist/services/artifactSession.js +17 -0
- package/dist/services/autoMemoryService.js +5 -13
- package/dist/services/configurationService.d.ts +92 -9
- package/dist/services/configurationService.js +246 -64
- package/dist/services/contentSummarizer.d.ts +15 -0
- package/dist/services/contentSummarizer.js +45 -0
- package/dist/services/execAvailability.d.ts +9 -0
- package/dist/services/execAvailability.js +32 -0
- package/dist/services/fileWatcher.js +61 -6
- package/dist/services/initializationService.js +21 -17
- package/dist/services/interactionService.d.ts +9 -1
- package/dist/services/interactionService.js +28 -8
- package/dist/services/jsonlHandler.d.ts +98 -0
- package/dist/services/jsonlHandler.js +250 -12
- package/dist/services/memory.d.ts +17 -1
- package/dist/services/memory.js +44 -7
- package/dist/services/officialMarketplaceMirror.d.ts +85 -0
- package/dist/services/officialMarketplaceMirror.js +290 -0
- package/dist/services/pluginLoader.d.ts +12 -4
- package/dist/services/pluginLoader.js +38 -7
- package/dist/services/remoteSettingsService.js +20 -6
- package/dist/services/session.d.ts +74 -0
- package/dist/services/session.js +174 -16
- package/dist/services/sessionEntries.d.ts +2 -0
- package/dist/services/sessionEntries.js +20 -0
- package/dist/services/worktreeHooks.js +6 -1
- package/dist/stdio/index.d.ts +12 -0
- package/dist/stdio/index.js +12 -0
- package/dist/stdio/notificationRouter.d.ts +38 -0
- package/dist/stdio/notificationRouter.js +97 -0
- package/dist/stdio/rpcClient.d.ts +18 -0
- package/dist/stdio/rpcClient.js +10 -0
- package/dist/stdio/stdioAgent.d.ts +229 -0
- package/dist/stdio/stdioAgent.js +360 -0
- package/dist/tools/artifactTool.js +406 -273
- package/dist/tools/bashTool.js +10 -6
- package/dist/tools/editTool.js +6 -3
- package/dist/tools/execTool.d.ts +2 -0
- package/dist/tools/execTool.js +165 -0
- package/dist/tools/exitPlanMode.js +10 -2
- package/dist/tools/grepTool.js +7 -1
- package/dist/tools/readTool.js +30 -2
- package/dist/tools/types.d.ts +34 -8
- package/dist/tools/webFetchTool.js +15 -166
- package/dist/tools/workflowTool.js +40 -8
- package/dist/tools/writeTool.js +6 -3
- package/dist/types/agent.d.ts +24 -1
- package/dist/types/commands.d.ts +7 -0
- package/dist/types/configuration.d.ts +45 -2
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/hooks.js +19 -0
- package/dist/types/marketplace.d.ts +40 -2
- package/dist/types/mcp.d.ts +42 -0
- package/dist/types/messaging.d.ts +1 -8
- package/dist/types/permissions.d.ts +22 -0
- package/dist/types/permissions.js +17 -0
- package/dist/types/plugins.d.ts +26 -2
- package/dist/types/skills.d.ts +26 -0
- package/dist/utils/bashParser.d.ts +17 -0
- package/dist/utils/bashParser.js +72 -0
- package/dist/utils/bashStructure/bashLexer.d.ts +96 -0
- package/dist/utils/bashStructure/bashLexer.js +676 -0
- package/dist/utils/bashStructure/bashParser.d.ts +144 -0
- package/dist/utils/bashStructure/bashParser.js +606 -0
- package/dist/utils/bashStructure/bashSemantics.d.ts +70 -0
- package/dist/utils/bashStructure/bashSemantics.js +477 -0
- package/dist/utils/bashStructure/index.d.ts +26 -0
- package/dist/utils/bashStructure/index.js +27 -0
- package/dist/utils/bashStructure/types.d.ts +62 -0
- package/dist/utils/bashStructure/types.js +47 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/containerSetup.js +48 -6
- package/dist/utils/convertMessagesForAPI.d.ts +7 -1
- package/dist/utils/convertMessagesForAPI.js +64 -14
- package/dist/utils/fileChangeReminder.d.ts +20 -0
- package/dist/utils/fileChangeReminder.js +153 -0
- package/dist/utils/fileSearch.js +4 -3
- package/dist/utils/fileUtils.d.ts +44 -0
- package/dist/utils/fileUtils.js +118 -0
- package/dist/utils/frontmatterYaml.d.ts +33 -0
- package/dist/utils/frontmatterYaml.js +192 -0
- package/dist/utils/imageBudget.d.ts +85 -0
- package/dist/utils/imageBudget.js +109 -0
- package/dist/utils/imageDimensions.d.ts +83 -0
- package/dist/utils/imageDimensions.js +232 -0
- package/dist/utils/imageProcessor.d.ts +66 -0
- package/dist/utils/imageProcessor.js +84 -0
- package/dist/utils/imageRewrite.d.ts +29 -0
- package/dist/utils/imageRewrite.js +251 -0
- package/dist/utils/markdownParser.d.ts +5 -1
- package/dist/utils/markdownParser.js +9 -51
- package/dist/utils/mcpInstructions.d.ts +61 -0
- package/dist/utils/mcpInstructions.js +126 -0
- package/dist/utils/mcpUtils.d.ts +7 -0
- package/dist/utils/mcpUtils.js +11 -2
- package/dist/utils/memoryAge.d.ts +32 -0
- package/dist/utils/memoryAge.js +47 -0
- package/dist/utils/memoryEntrypoint.d.ts +20 -0
- package/dist/utils/memoryEntrypoint.js +49 -0
- package/dist/utils/memoryIndex.d.ts +30 -0
- package/dist/utils/memoryIndex.js +76 -0
- package/dist/utils/messageOperations.d.ts +6 -20
- package/dist/utils/messageOperations.js +40 -91
- package/dist/utils/nestedMemory.d.ts +22 -0
- package/dist/utils/nestedMemory.js +61 -0
- package/dist/utils/npmTarball.d.ts +19 -0
- package/dist/utils/npmTarball.js +92 -0
- package/dist/utils/pluginSource.d.ts +37 -0
- package/dist/utils/pluginSource.js +73 -0
- package/dist/utils/ripgrep.d.ts +18 -4
- package/dist/utils/ripgrep.js +56 -4
- package/dist/utils/runtimeDeps.d.ts +35 -0
- package/dist/utils/runtimeDeps.js +426 -0
- package/dist/utils/skillParser.js +22 -52
- package/dist/utils/subagentParser.js +48 -45
- package/dist/utils/tokenCalculation.js +0 -8
- package/dist/utils/userSettings.d.ts +90 -0
- package/dist/utils/userSettings.js +291 -0
- package/dist/utils/worktreeUtils.d.ts +2 -1
- package/dist/utils/worktreeUtils.js +64 -34
- package/package.json +12 -4
- package/dist/managers/bangManager.d.ts +0 -26
- package/dist/managers/bangManager.js +0 -78
|
@@ -1,117 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
* Memory types taxonomy and examples.
|
|
3
|
-
*/
|
|
4
|
-
const MEMORY_TYPES = ["user", "feedback", "project", "reference"];
|
|
5
|
-
const TYPES_SECTION = [
|
|
6
|
-
"## Types of memory",
|
|
7
|
-
"",
|
|
8
|
-
"There are several discrete types of memory that you can store in your memory system:",
|
|
9
|
-
"",
|
|
10
|
-
"<types>",
|
|
11
|
-
"<type>",
|
|
12
|
-
" <name>user</name>",
|
|
13
|
-
" <description>Contain information about the user's role, goals, responsibilities, and knowledge. Great user memories help you tailor your future behavior to the user's preferences and perspective. Your goal in reading and writing these memories is to build up an understanding of who the user is and how you can be most helpful to them specifically. For example, you should collaborate with a senior software engineer differently than a student who is coding for the very first time. Keep in mind, that the aim here is to be helpful to the user. Avoid writing memories about the user that could be viewed as a negative judgement or that are not relevant to the work you're trying to accomplish together.</description>",
|
|
14
|
-
" <when_to_save>When you learn any details about the user's role, preferences, responsibilities, or knowledge</when_to_save>",
|
|
15
|
-
" <how_to_use>When your work should be informed by the user's profile or perspective. For example, if the user is asking you to explain a part of the code, you should answer that question in a way that is tailored to the specific details that they will find most valuable or that helps them build their mental model in relation to domain knowledge they already have.</how_to_use>",
|
|
16
|
-
" <examples>",
|
|
17
|
-
" user: I'm a data scientist investigating what logging we have in place",
|
|
18
|
-
" assistant: [saves user memory: user is a data scientist, currently focused on observability/logging]",
|
|
19
|
-
"",
|
|
20
|
-
" user: I've been writing Go for ten years but this is my first time touching the React side of this repo",
|
|
21
|
-
" assistant: [saves user memory: deep Go expertise, new to React and this project's frontend — frame frontend explanations in terms of backend analogues]",
|
|
22
|
-
" </examples>",
|
|
23
|
-
"</type>",
|
|
24
|
-
"<type>",
|
|
25
|
-
" <name>feedback</name>",
|
|
26
|
-
" <description>Guidance the user has given you about how to approach work — both what to avoid and what to keep doing. These are a very important type of memory to read and write as they allow you to remain coherent and responsive to the way you should approach work in the project. Record from failure AND success: if you only save corrections, you will avoid past mistakes but drift away from approaches the user has already validated, and may grow overly cautious.</description>",
|
|
27
|
-
' <when_to_save>Any time the user corrects your approach ("no not that", "don\'t", "stop doing X") OR confirms a non-obvious approach worked ("yes exactly", "perfect, keep doing that", accepting an unusual choice without pushback). Corrections are easy to notice; confirmations are quieter — watch for them. In both cases, save what is applicable to future conversations, especially if surprising or not obvious from the code. Include *why* so you can judge edge cases later.</when_to_save>',
|
|
28
|
-
" <how_to_use>Let these memories guide your behavior so that the user does not need to offer the same guidance twice.</how_to_use>",
|
|
29
|
-
" <body_structure>Lead with the rule itself, then a **Why:** line (the reason the user gave — often a past incident or strong preference) and a **How to apply:** line (when/where this guidance kicks in). Knowing *why* lets you judge edge cases instead of blindly following the rule.</body_structure>",
|
|
30
|
-
" <examples>",
|
|
31
|
-
" user: don't mock the database in these tests — we got burned last quarter when mocked tests passed but the prod migration failed",
|
|
32
|
-
" assistant: [saves feedback memory: integration tests must hit a real database, not mocks. Reason: prior incident where mock/prod divergence masked a broken migration]",
|
|
33
|
-
"",
|
|
34
|
-
" user: stop summarizing what you just did at the end of every response, I can read the diff",
|
|
35
|
-
" assistant: [saves feedback memory: this user wants terse responses with no trailing summaries]",
|
|
36
|
-
"",
|
|
37
|
-
" user: yeah the single bundled PR was the right call here, splitting this one would've just been churn",
|
|
38
|
-
" assistant: [saves feedback memory: for refactors in this area, user prefers one bundled PR over many small ones. Confirmed after I chose this approach — a validated judgment call, not a correction]",
|
|
39
|
-
" </examples>",
|
|
40
|
-
"</type>",
|
|
41
|
-
"<type>",
|
|
42
|
-
" <name>project</name>",
|
|
43
|
-
" <description>Information that you learn about ongoing work, goals, initiatives, bugs, or incidents within the project that is not otherwise derivable from the code or git history. Project memories help you understand the broader context and motivation behind the work the user is doing within this working directory.</description>",
|
|
44
|
-
' <when_to_save>When you learn who is doing what, why, or by when. These states change relatively quickly so try to keep your understanding of this up to date. Always convert relative dates in user messages to absolute dates when saving (e.g., "Thursday" → "2026-03-05"), so the memory remains interpretable after time passes.</when_to_save>',
|
|
45
|
-
" <how_to_use>Use these memories to more fully understand the details and nuance behind the user's request and make better informed suggestions.</how_to_use>",
|
|
46
|
-
" <body_structure>Lead with the fact or decision, then a **Why:** line (the motivation — often a constraint, deadline, or stakeholder ask) and a **How to apply:** line (how this should shape your suggestions). Project memories decay fast, so the why helps future-you judge whether the memory is still load-bearing.</body_structure>",
|
|
47
|
-
" <examples>",
|
|
48
|
-
" user: we're freezing all non-critical merges after Thursday — mobile team is cutting a release branch",
|
|
49
|
-
" assistant: [saves project memory: merge freeze begins 2026-03-05 for mobile release cut. Flag any non-critical PR work scheduled after that date]",
|
|
50
|
-
"",
|
|
51
|
-
" user: the reason we're ripping out the old auth middleware is that legal flagged it for storing session tokens in a way that doesn't meet the new compliance requirements",
|
|
52
|
-
" assistant: [saves project memory: auth middleware rewrite is driven by legal/compliance requirements around session token storage, not tech-debt cleanup — scope decisions should favor compliance over ergonomics]",
|
|
53
|
-
" </examples>",
|
|
54
|
-
"</type>",
|
|
55
|
-
"<type>",
|
|
56
|
-
" <name>reference</name>",
|
|
57
|
-
" <description>Stores pointers to where information can be found in external systems. These memories allow you to remember where to look to find up-to-date information outside of the project directory.</description>",
|
|
58
|
-
" <when_to_save>When you learn about resources in external systems and their purpose. For example, that bugs are tracked in a specific project in Linear or that feedback can be found in a specific Slack channel.</when_to_save>",
|
|
59
|
-
" <how_to_use>When the user references an external system or information that may be in an external system.</how_to_use>",
|
|
60
|
-
" <examples>",
|
|
61
|
-
' user: check the Linear project "INGEST" if you want context on these tickets, that\'s where we track all pipeline bugs',
|
|
62
|
-
' assistant: [saves reference memory: pipeline bugs are tracked in Linear project "INGEST"]',
|
|
63
|
-
"",
|
|
64
|
-
" user: the Grafana board at grafana.internal/d/api-latency is what oncall watches — if you're touching request handling, that's the thing that'll page someone",
|
|
65
|
-
" assistant: [saves reference memory: grafana.internal/d/api-latency is the oncall latency dashboard — check it when editing request-path code]",
|
|
66
|
-
" </examples>",
|
|
67
|
-
"</type>",
|
|
68
|
-
"</types>",
|
|
69
|
-
].join("\n");
|
|
70
|
-
const WHAT_NOT_TO_SAVE_SECTION = [
|
|
71
|
-
"## What NOT to save in memory",
|
|
72
|
-
"",
|
|
73
|
-
"- Code patterns, conventions, architecture, file paths, or project structure — these can be derived by reading the current project state.",
|
|
74
|
-
"- Git history, recent changes, or who-changed-what — `git log` / `git blame` are authoritative.",
|
|
75
|
-
"- Debugging solutions or fix recipes — the fix is in the code; the commit message has the context.",
|
|
76
|
-
"- Anything already documented in CLAUDE.md files.",
|
|
77
|
-
"- Ephemeral task details: in-progress work, temporary state, current conversation context.",
|
|
78
|
-
"",
|
|
79
|
-
"These exclusions apply even when the user explicitly asks you to save. If they ask you to save a PR list or activity summary, ask what was *surprising* or *non-obvious* about it — that is the part worth keeping.",
|
|
80
|
-
].join("\n");
|
|
81
|
-
const MEMORY_FRONTMATTER_EXAMPLE = [
|
|
82
|
-
"```markdown",
|
|
83
|
-
"---",
|
|
84
|
-
"name: {{memory name}}",
|
|
85
|
-
"description: {{one-line description — used to decide relevance in future conversations, so be specific}}",
|
|
86
|
-
`type: {{${MEMORY_TYPES.join(", ")}}}`,
|
|
87
|
-
"---",
|
|
88
|
-
"",
|
|
89
|
-
"{{memory content — for feedback/project types, structure as: rule/fact, then **Why:** and **How to apply:** lines}}",
|
|
90
|
-
"```",
|
|
91
|
-
].join("\n");
|
|
1
|
+
import { TYPES_SECTION, WHAT_NOT_TO_SAVE_SECTION, buildHowToSaveSection, } from "./memoryTypes.js";
|
|
92
2
|
/**
|
|
93
3
|
* Build the auto-memory extraction prompt for the background agent.
|
|
4
|
+
*
|
|
5
|
+
* The taxonomy, the "what not to save" list, and the save procedure are shared
|
|
6
|
+
* with the main agent's memory prompt (`memoryTypes.ts`): the fork reuses the
|
|
7
|
+
* main system prompt, so both texts are in the same request.
|
|
94
8
|
*/
|
|
95
9
|
export function buildAutoMemoryExtractionPrompt(newMessageCount, existingMemoriesManifest) {
|
|
96
10
|
const manifestSection = existingMemoriesManifest.length > 0
|
|
97
11
|
? `\n\n## Existing memory files\n\n${existingMemoriesManifest}\n\nCheck this list before writing — update an existing file rather than creating a duplicate.`
|
|
98
12
|
: "";
|
|
99
|
-
const howToSave = [
|
|
100
|
-
"## How to save memories",
|
|
101
|
-
"",
|
|
102
|
-
"Saving a memory is a two-step process:",
|
|
103
|
-
"",
|
|
104
|
-
"**Step 1** — write the memory to its own file (e.g., `user_role.md`, `feedback_testing.md`) using this frontmatter format:",
|
|
105
|
-
"",
|
|
106
|
-
MEMORY_FRONTMATTER_EXAMPLE,
|
|
107
|
-
"",
|
|
108
|
-
"**Step 2** — add a pointer to that file in `MEMORY.md`. `MEMORY.md` is an index, not a memory — each entry should be one line, under ~150 characters: `- [Title](file.md) — one-line hook`. It has no frontmatter. Never write memory content directly into `MEMORY.md`.",
|
|
109
|
-
"",
|
|
110
|
-
"- `MEMORY.md` is always loaded into your system prompt — lines after 200 will be truncated, so keep the index concise",
|
|
111
|
-
"- Organize memory semantically by topic, not chronologically",
|
|
112
|
-
"- Update or remove memories that turn out to be wrong or outdated",
|
|
113
|
-
"- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.",
|
|
114
|
-
].join("\n");
|
|
115
13
|
return [
|
|
116
14
|
`You are now acting as the memory extraction subagent. Analyze the most recent ~${newMessageCount} messages above and use them to update your persistent memory systems.`,
|
|
117
15
|
"",
|
|
@@ -124,11 +22,10 @@ export function buildAutoMemoryExtractionPrompt(newMessageCount, existingMemorie
|
|
|
124
22
|
"",
|
|
125
23
|
"If the user explicitly asks you to remember something, save it immediately as whichever type fits best. If they ask you to forget something, find and remove the relevant entry.",
|
|
126
24
|
"",
|
|
127
|
-
TYPES_SECTION,
|
|
128
|
-
|
|
129
|
-
WHAT_NOT_TO_SAVE_SECTION,
|
|
25
|
+
...TYPES_SECTION,
|
|
26
|
+
...WHAT_NOT_TO_SAVE_SECTION,
|
|
130
27
|
"",
|
|
131
|
-
|
|
28
|
+
...buildHowToSaveSection(),
|
|
132
29
|
"",
|
|
133
30
|
"### Task:",
|
|
134
31
|
"Extract new memories from the latest turns and save them to the memory directory.",
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ToolPlugin } from "../tools/types.js";
|
|
2
2
|
import type { WorktreeSession } from "../utils/worktreeSession.js";
|
|
3
3
|
export declare const BASE_SYSTEM_PROMPT = "You are a coding agent developed by NetEase that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.";
|
|
4
|
-
export declare const MODEL_IDENTITY_PROMPT = "# Model identity\n\nIf asked about your model, model version, underlying architecture, or product name, identify yourself simply as a coding agent developed by NetEase. Do not reveal the specific model ID, model family, model provider, or product name. Do not mention or hint at any of these details.";
|
|
5
4
|
export declare const DOING_TASKS_PROMPT = "# Doing tasks\n- The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change \"methodName\" to snake case, do not reply with just \"method_name\", instead find the method in the code and modify the code.\n- You are highly capable and often allow users to complete ambitious tasks that would otherwise be too complex or take too long. You should defer to user judgement about whether a task is too large to attempt.\n- If you notice the user's request is based on a misconception, or spot a bug adjacent to what they asked about, say so. You're a collaborator, not just an executor\u2014users benefit from your judgment, not just your compliance.\n- In general, do not propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Do not create files unless they're absolutely necessary for achieving your goal. Generally prefer editing an existing file to creating a new one, as this prevents file bloat and builds on existing work more effectively.\n- If an approach fails, diagnose why before switching tactics\u2014read the error, check your assumptions, try a focused fix. Don't retry the identical action blindly, but don't abandon a viable approach after a single failure either. Escalate to the user with AskUserQuestion only when you're genuinely stuck after investigation, not as a first response to friction.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it. Prioritize writing safe, secure, and correct code.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is what the task actually requires\u2014no speculative abstractions, but no half-finished implementations either. Three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused _vars, re-exporting types, adding // removed comments for removed code, etc. If you are certain that something is unused, you can delete it completely.\n- Report outcomes faithfully: if tests fail, say so with the relevant output; if you did not run a verification step, say that rather than implying it succeeded. Never claim \"all tests pass\" when output shows failures, never suppress or simplify failing checks (tests, lints, type errors) to manufacture a green result, and never characterize incomplete or broken work as done. Equally, when a check did pass or a task is complete, state it plainly \u2014 do not hedge confirmed results with unnecessary disclaimers, downgrade finished work to \"partial,\" or re-verify things you already checked. The goal is an accurate report, not a defensive one.\n- Before reporting a task complete, verify it actually works: run the test, execute the script, check the output. Minimum complexity means no gold-plating, not skipping the finish line. If you can't verify (no test exists, can't run the code), say so explicitly rather than claiming success.";
|
|
6
5
|
export declare const EXECUTING_ACTIONS_PROMPT = "# Executing actions with care\n\nCarefully consider the reversibility and blast radius of actions. Generally you can freely take local, reversible actions like editing files or running tests. But for actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding. The cost of pausing to confirm is low, while the cost of an unwanted action (lost work, unintended messages sent, deleted branches) can be very high. For actions like these, consider the context, the action, and user instructions, and by default transparently communicate the action and ask for confirmation before proceeding.\n\nExamples of the kind of risky actions that warrant user confirmation:\n- Destructive operations: deleting files/branches, dropping database tables, killing processes, rm -rf, overwriting uncommitted changes\n- Hard-to-reverse operations: force-pushing (can also overwrite upstream), git reset --hard, amending published commits, removing or downgrading packages/dependencies, modifying CI/CD pipelines\n- Actions visible to others or that affect shared state: pushing code, creating/closing/commenting on PRs or issues, sending messages (Slack, email, GitHub), posting to external services\n\nWhen you encounter an obstacle, do not use destructive actions as a shortcut to simply make it go away. For instance, try to identify root causes and fix underlying issues rather than bypassing safety checks (e.g. --no-verify). If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting, as it may represent the user's in-progress work. For example, typically resolve merge conflicts rather than discarding changes. In short: only take risky actions carefully, and when in doubt, ask before acting. Follow both the spirit and letter of these instructions - measure twice, cut once.";
|
|
7
6
|
export declare const TOOL_POLICY = "# Using your tools\n\n- Do NOT use the Bash to run commands when a relevant dedicated tool is provided. Using dedicated tools allows the user to better understand and review your work. This is CRITICAL to assisting the user:\n - To read files use Read instead of cat, head, tail, or sed\n - To edit files use Edit instead of sed or awk\n - To create files use Write instead of cat or echo redirection\n - To search for files use Glob instead of find or ls\n - To search the content of files, use Grep instead of grep or rg\n - Reserve using the Bash exclusively for system commands and terminal operations that require shell execution. If you are unsure and there is a relevant dedicated tool, default to using the dedicated tool and only fallback on using the Bash tool for these if it is absolutely necessary.\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
package/dist/prompts/index.js
CHANGED
|
@@ -4,9 +4,6 @@ import { buildAutoMemoryPrompt } from "./autoMemory.js";
|
|
|
4
4
|
import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
|
|
5
5
|
import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, BASH_TOOL_NAME, READ_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, } from "../constants/tools.js";
|
|
6
6
|
export const BASE_SYSTEM_PROMPT = `You are a coding agent developed by NetEase that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.`;
|
|
7
|
-
export const MODEL_IDENTITY_PROMPT = `# Model identity
|
|
8
|
-
|
|
9
|
-
If asked about your model, model version, underlying architecture, or product name, identify yourself simply as a coding agent developed by NetEase. Do not reveal the specific model ID, model family, model provider, or product name. Do not mention or hint at any of these details.`;
|
|
10
7
|
export const DOING_TASKS_PROMPT = `# Doing tasks
|
|
11
8
|
- The user will primarily request you to perform software engineering tasks. These may include solving bugs, adding new functionality, refactoring code, explaining code, and more. When given an unclear or generic instruction, consider it in the context of these software engineering tasks and the current working directory. For example, if the user asks you to change "methodName" to snake case, do not reply with just "method_name", instead find the method in the code and modify the code.
|
|
12
9
|
- You are highly capable and often allow users to complete ambitious tasks that would otherwise be too complex or take too long. You should defer to user judgement about whether a task is too large to attempt.
|
|
@@ -332,7 +329,6 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
|
|
|
332
329
|
}
|
|
333
330
|
staticText += `\n\n${OUTPUT_EFFICIENCY_PROMPT}`;
|
|
334
331
|
staticText += `\n\n${TONE_AND_STYLE_PROMPT}`;
|
|
335
|
-
staticText += `\n\n${MODEL_IDENTITY_PROMPT}`;
|
|
336
332
|
const blocks = [{ text: staticText, cacheable: true }];
|
|
337
333
|
// --- Dynamic block (not cacheable) ---
|
|
338
334
|
let dynamicText = "";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-memory taxonomy and shared prompt sections.
|
|
3
|
+
*
|
|
4
|
+
* These sections are shared by the main agent's memory prompt
|
|
5
|
+
* (`prompts/autoMemory.ts`) and the background extraction fork prompt
|
|
6
|
+
* (`prompts/autoMemoryExtraction.ts`). Sharing them is load-bearing, not
|
|
7
|
+
* tidiness: the fork reuses the main system prompt, so both texts land in the
|
|
8
|
+
* same request — a duplicated copy that drifts turns into a request that
|
|
9
|
+
* simultaneously tells the model to save and not to save the same category.
|
|
10
|
+
*
|
|
11
|
+
* Aligned with Claude Code's `memdir/memoryTypes.ts`, individual-only variant
|
|
12
|
+
* (no `<scope>` tags, no private/team split: Wave has a single memory
|
|
13
|
+
* directory).
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Appended to the memory directory line. Shipped because the model was burning
|
|
17
|
+
* turns on `ls` / `mkdir -p` before writing; the harness guarantees the
|
|
18
|
+
* directory exists (`MemoryService.ensureAutoMemoryDirectory`).
|
|
19
|
+
*/
|
|
20
|
+
export declare const DIR_EXISTS_GUIDANCE = "This directory already exists \u2014 write to it directly with the Write tool (do not run mkdir or check for its existence).";
|
|
21
|
+
/**
|
|
22
|
+
* `## Types of memory` section.
|
|
23
|
+
*/
|
|
24
|
+
export declare const TYPES_SECTION: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* `## What NOT to save in memory` section. The closing paragraph is the
|
|
27
|
+
* explicit-save gate: it applies even when the user asks for something the
|
|
28
|
+
* model would otherwise happily record, which is exactly the case where
|
|
29
|
+
* activity-log noise gets in.
|
|
30
|
+
*/
|
|
31
|
+
export declare const WHAT_NOT_TO_SAVE_SECTION: readonly string[];
|
|
32
|
+
/**
|
|
33
|
+
* Recall-side drift caveat, a single bullet under `## When to access memories`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MEMORY_DRIFT_CAVEAT = "- Memory records can become stale over time. Use memory as context for what was true at a given point in time. Before answering the user or building assumptions based solely on information in memory records, verify that the memory is still correct and up-to-date by reading the current state of the files or resources. If a recalled memory conflicts with current information, trust what you observe now \u2014 and update or remove the stale memory rather than acting on it.";
|
|
36
|
+
/**
|
|
37
|
+
* `## When to access memories` section, including the drift caveat.
|
|
38
|
+
*
|
|
39
|
+
* The "ignore" bullet is deliberate: without it the model tends to treat
|
|
40
|
+
* "ignore memory about X" as "acknowledge memory about X, then override it",
|
|
41
|
+
* and mentions the memory anyway.
|
|
42
|
+
*/
|
|
43
|
+
export declare const WHEN_TO_ACCESS_SECTION: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* `## Before recommending from memory` section. Header wording is deliberate:
|
|
46
|
+
* the action cue at the decision point works where an abstract header
|
|
47
|
+
* ("Trusting what you recall") does not.
|
|
48
|
+
*/
|
|
49
|
+
export declare const TRUSTING_RECALL_SECTION: readonly string[];
|
|
50
|
+
/**
|
|
51
|
+
* `## Memory and other forms of persistence` section: how memory divides
|
|
52
|
+
* labor with plans and tasks.
|
|
53
|
+
*/
|
|
54
|
+
export declare const MEMORY_AND_OTHER_PERSISTENCE_SECTION: readonly string[];
|
|
55
|
+
/**
|
|
56
|
+
* Frontmatter format example with the `type` field.
|
|
57
|
+
*/
|
|
58
|
+
export declare const MEMORY_FRONTMATTER_EXAMPLE: readonly string[];
|
|
59
|
+
/**
|
|
60
|
+
* `## How to save memories` section: the two-step write (topic file, then
|
|
61
|
+
* index pointer) plus the entrypoint rules.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildHowToSaveSection(): readonly string[];
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-memory taxonomy and shared prompt sections.
|
|
3
|
+
*
|
|
4
|
+
* These sections are shared by the main agent's memory prompt
|
|
5
|
+
* (`prompts/autoMemory.ts`) and the background extraction fork prompt
|
|
6
|
+
* (`prompts/autoMemoryExtraction.ts`). Sharing them is load-bearing, not
|
|
7
|
+
* tidiness: the fork reuses the main system prompt, so both texts land in the
|
|
8
|
+
* same request — a duplicated copy that drifts turns into a request that
|
|
9
|
+
* simultaneously tells the model to save and not to save the same category.
|
|
10
|
+
*
|
|
11
|
+
* Aligned with Claude Code's `memdir/memoryTypes.ts`, individual-only variant
|
|
12
|
+
* (no `<scope>` tags, no private/team split: Wave has a single memory
|
|
13
|
+
* directory).
|
|
14
|
+
*/
|
|
15
|
+
import { MEMORY_ENTRYPOINT_NAME, MEMORY_INDEX_LINE_GUIDANCE_CHARS, MEMORY_TYPES, MAX_MEMORY_ENTRYPOINT_CHARS, MAX_MEMORY_ENTRYPOINT_LINES, } from "../constants/memory.js";
|
|
16
|
+
/**
|
|
17
|
+
* Appended to the memory directory line. Shipped because the model was burning
|
|
18
|
+
* turns on `ls` / `mkdir -p` before writing; the harness guarantees the
|
|
19
|
+
* directory exists (`MemoryService.ensureAutoMemoryDirectory`).
|
|
20
|
+
*/
|
|
21
|
+
export const DIR_EXISTS_GUIDANCE = "This directory already exists — write to it directly with the Write tool (do not run mkdir or check for its existence).";
|
|
22
|
+
/**
|
|
23
|
+
* `## Types of memory` section.
|
|
24
|
+
*/
|
|
25
|
+
export const TYPES_SECTION = [
|
|
26
|
+
"## Types of memory",
|
|
27
|
+
"",
|
|
28
|
+
"There are several discrete types of memory that you can store in your memory system:",
|
|
29
|
+
"",
|
|
30
|
+
"<types>",
|
|
31
|
+
"<type>",
|
|
32
|
+
" <name>user</name>",
|
|
33
|
+
" <description>Contain information about the user's role, goals, responsibilities, and knowledge. Great user memories help you tailor your future behavior to the user's preferences and perspective. Your goal in reading and writing these memories is to build up an understanding of who the user is and how you can be most helpful to them specifically. For example, you should collaborate with a senior software engineer differently than a student who is coding for the very first time. Keep in mind, that the aim here is to be helpful to the user. Avoid writing memories about the user that could be viewed as a negative judgement or that are not relevant to the work you're trying to accomplish together.</description>",
|
|
34
|
+
" <when_to_save>When you learn any details about the user's role, preferences, responsibilities, or knowledge</when_to_save>",
|
|
35
|
+
" <how_to_use>When your work should be informed by the user's profile or perspective. For example, if the user is asking you to explain a part of the code, you should answer that question in a way that is tailored to the specific details that they will find most valuable or that helps them build their mental model in relation to domain knowledge they already have.</how_to_use>",
|
|
36
|
+
" <examples>",
|
|
37
|
+
" user: I'm a data scientist investigating what logging we have in place",
|
|
38
|
+
" assistant: [saves user memory: user is a data scientist, currently focused on observability/logging]",
|
|
39
|
+
"",
|
|
40
|
+
" user: I've been writing Go for ten years but this is my first time touching the React side of this repo",
|
|
41
|
+
" assistant: [saves user memory: deep Go expertise, new to React and this project's frontend — frame frontend explanations in terms of backend analogues]",
|
|
42
|
+
" </examples>",
|
|
43
|
+
"</type>",
|
|
44
|
+
"<type>",
|
|
45
|
+
" <name>feedback</name>",
|
|
46
|
+
" <description>Guidance the user has given you about how to approach work — both what to avoid and what to keep doing. These are a very important type of memory to read and write as they allow you to remain coherent and responsive to the way you should approach work in the project. Record from failure AND success: if you only save corrections, you will avoid past mistakes but drift away from approaches the user has already validated, and may grow overly cautious.</description>",
|
|
47
|
+
' <when_to_save>Any time the user corrects your approach ("no not that", "don\'t", "stop doing X") OR confirms a non-obvious approach worked ("yes exactly", "perfect, keep doing that", accepting an unusual choice without pushback). Corrections are easy to notice; confirmations are quieter — watch for them. In both cases, save what is applicable to future conversations, especially if surprising or not obvious from the code. Include *why* so you can judge edge cases later.</when_to_save>',
|
|
48
|
+
" <how_to_use>Let these memories guide your behavior so that the user does not need to offer the same guidance twice.</how_to_use>",
|
|
49
|
+
" <body_structure>Lead with the rule itself, then a **Why:** line (the reason the user gave — often a past incident or strong preference) and a **How to apply:** line (when/where this guidance kicks in). Knowing *why* lets you judge edge cases instead of blindly following the rule.</body_structure>",
|
|
50
|
+
" <examples>",
|
|
51
|
+
" user: don't mock the database in these tests — we got burned last quarter when mocked tests passed but the prod migration failed",
|
|
52
|
+
" assistant: [saves feedback memory: integration tests must hit a real database, not mocks. Reason: prior incident where mock/prod divergence masked a broken migration]",
|
|
53
|
+
"",
|
|
54
|
+
" user: stop summarizing what you just did at the end of every response, I can read the diff",
|
|
55
|
+
" assistant: [saves feedback memory: this user wants terse responses with no trailing summaries]",
|
|
56
|
+
"",
|
|
57
|
+
" user: yeah the single bundled PR was the right call here, splitting this one would've just been churn",
|
|
58
|
+
" assistant: [saves feedback memory: for refactors in this area, user prefers one bundled PR over many small ones. Confirmed after I chose this approach — a validated judgment call, not a correction]",
|
|
59
|
+
" </examples>",
|
|
60
|
+
"</type>",
|
|
61
|
+
"<type>",
|
|
62
|
+
" <name>project</name>",
|
|
63
|
+
" <description>Information that you learn about ongoing work, goals, initiatives, bugs, or incidents within the project that is not otherwise derivable from the code or git history. Project memories help you understand the broader context and motivation behind the work the user is doing within this working directory.</description>",
|
|
64
|
+
' <when_to_save>When you learn who is doing what, why, or by when. These states change relatively quickly so try to keep your understanding of this up to date. Always convert relative dates in user messages to absolute dates when saving (e.g., "Thursday" → "2026-03-05"), so the memory remains interpretable after time passes.</when_to_save>',
|
|
65
|
+
" <how_to_use>Use these memories to more fully understand the details and nuance behind the user's request and make better informed suggestions.</how_to_use>",
|
|
66
|
+
" <body_structure>Lead with the fact or decision, then a **Why:** line (the motivation — often a constraint, deadline, or stakeholder ask) and a **How to apply:** line (how this should shape your suggestions). Project memories decay fast, so the why helps future-you judge whether the memory is still load-bearing.</body_structure>",
|
|
67
|
+
" <examples>",
|
|
68
|
+
" user: we're freezing all non-critical merges after Thursday — mobile team is cutting a release branch",
|
|
69
|
+
" assistant: [saves project memory: merge freeze begins 2026-03-05 for mobile release cut. Flag any non-critical PR work scheduled after that date]",
|
|
70
|
+
"",
|
|
71
|
+
" user: the reason we're ripping out the old auth middleware is that legal flagged it for storing session tokens in a way that doesn't meet the new compliance requirements",
|
|
72
|
+
" assistant: [saves project memory: auth middleware rewrite is driven by legal/compliance requirements around session token storage, not tech-debt cleanup — scope decisions should favor compliance over ergonomics]",
|
|
73
|
+
" </examples>",
|
|
74
|
+
"</type>",
|
|
75
|
+
"<type>",
|
|
76
|
+
" <name>reference</name>",
|
|
77
|
+
" <description>Stores pointers to where information can be found in external systems. These memories allow you to remember where to look to find up-to-date information outside of the project directory.</description>",
|
|
78
|
+
" <when_to_save>When you learn about resources in external systems and their purpose. For example, that bugs are tracked in a specific project in Linear or that feedback can be found in a specific Slack channel.</when_to_save>",
|
|
79
|
+
" <how_to_use>When the user references an external system or information that may be in an external system.</how_to_use>",
|
|
80
|
+
" <examples>",
|
|
81
|
+
' user: check the Linear project "INGEST" if you want context on these tickets, that\'s where we track all pipeline bugs',
|
|
82
|
+
' assistant: [saves reference memory: pipeline bugs are tracked in Linear project "INGEST"]',
|
|
83
|
+
"",
|
|
84
|
+
" user: the Grafana board at grafana.internal/d/api-latency is what oncall watches — if you're touching request handling, that's the thing that'll page someone",
|
|
85
|
+
" assistant: [saves reference memory: grafana.internal/d/api-latency is the oncall latency dashboard — check it when editing request-path code]",
|
|
86
|
+
" </examples>",
|
|
87
|
+
"</type>",
|
|
88
|
+
"</types>",
|
|
89
|
+
"",
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* `## What NOT to save in memory` section. The closing paragraph is the
|
|
93
|
+
* explicit-save gate: it applies even when the user asks for something the
|
|
94
|
+
* model would otherwise happily record, which is exactly the case where
|
|
95
|
+
* activity-log noise gets in.
|
|
96
|
+
*/
|
|
97
|
+
export const WHAT_NOT_TO_SAVE_SECTION = [
|
|
98
|
+
"## What NOT to save in memory",
|
|
99
|
+
"",
|
|
100
|
+
"- Code patterns, conventions, architecture, file paths, or project structure — these can be derived by reading the current project state.",
|
|
101
|
+
"- Git history, recent changes, or who-changed-what — `git log` / `git blame` are authoritative.",
|
|
102
|
+
"- Debugging solutions or fix recipes — the fix is in the code; the commit message has the context.",
|
|
103
|
+
"- Anything already documented in CLAUDE.md files.",
|
|
104
|
+
"- Ephemeral task details: in-progress work, temporary state, current conversation context.",
|
|
105
|
+
"",
|
|
106
|
+
"These exclusions apply even when the user explicitly asks you to save. If they ask you to save a PR list or activity summary, ask what was *surprising* or *non-obvious* about it — that is the part worth keeping.",
|
|
107
|
+
];
|
|
108
|
+
/**
|
|
109
|
+
* Recall-side drift caveat, a single bullet under `## When to access memories`.
|
|
110
|
+
*/
|
|
111
|
+
export const MEMORY_DRIFT_CAVEAT = "- Memory records can become stale over time. Use memory as context for what was true at a given point in time. Before answering the user or building assumptions based solely on information in memory records, verify that the memory is still correct and up-to-date by reading the current state of the files or resources. If a recalled memory conflicts with current information, trust what you observe now — and update or remove the stale memory rather than acting on it.";
|
|
112
|
+
/**
|
|
113
|
+
* `## When to access memories` section, including the drift caveat.
|
|
114
|
+
*
|
|
115
|
+
* The "ignore" bullet is deliberate: without it the model tends to treat
|
|
116
|
+
* "ignore memory about X" as "acknowledge memory about X, then override it",
|
|
117
|
+
* and mentions the memory anyway.
|
|
118
|
+
*/
|
|
119
|
+
export const WHEN_TO_ACCESS_SECTION = [
|
|
120
|
+
"## When to access memories",
|
|
121
|
+
"- When memories seem relevant, or the user references prior-conversation work.",
|
|
122
|
+
"- You MUST access memory when the user explicitly asks you to check, recall, or remember.",
|
|
123
|
+
"- If the user says to *ignore* or *not use* memory: proceed as if MEMORY.md were empty. Do not apply remembered facts, cite, compare against, or mention memory content.",
|
|
124
|
+
MEMORY_DRIFT_CAVEAT,
|
|
125
|
+
];
|
|
126
|
+
/**
|
|
127
|
+
* `## Before recommending from memory` section. Header wording is deliberate:
|
|
128
|
+
* the action cue at the decision point works where an abstract header
|
|
129
|
+
* ("Trusting what you recall") does not.
|
|
130
|
+
*/
|
|
131
|
+
export const TRUSTING_RECALL_SECTION = [
|
|
132
|
+
"## Before recommending from memory",
|
|
133
|
+
"",
|
|
134
|
+
"A memory that names a specific function, file, or flag is a claim that it existed *when the memory was written*. It may have been renamed, removed, or never merged. Before recommending it:",
|
|
135
|
+
"",
|
|
136
|
+
"- If the memory names a file path: check the file exists.",
|
|
137
|
+
"- If the memory names a function or flag: grep for it.",
|
|
138
|
+
"- If the user is about to act on your recommendation (not just asking about history), verify first.",
|
|
139
|
+
"",
|
|
140
|
+
'"The memory says X exists" is not the same as "X exists now."',
|
|
141
|
+
"",
|
|
142
|
+
"A memory that summarizes repo state (activity logs, architecture snapshots) is frozen in time. If the user asks about *recent* or *current* state, prefer `git log` or reading the code over recalling the snapshot.",
|
|
143
|
+
];
|
|
144
|
+
/**
|
|
145
|
+
* `## Memory and other forms of persistence` section: how memory divides
|
|
146
|
+
* labor with plans and tasks.
|
|
147
|
+
*/
|
|
148
|
+
export const MEMORY_AND_OTHER_PERSISTENCE_SECTION = [
|
|
149
|
+
"## Memory and other forms of persistence",
|
|
150
|
+
"Memory is one of several persistence mechanisms available to you as you assist the user in a given conversation. The distinction is often that memory can be recalled in future conversations and should not be used for persisting information that is only useful within the scope of the current conversation.",
|
|
151
|
+
"- When to use or update a plan instead of memory: If you are about to start a non-trivial implementation task and would like to reach alignment with the user on your approach you should use a Plan rather than saving this information to memory. Similarly, if you already have a plan within the conversation and you have changed your approach persist that change by updating the plan rather than saving a memory.",
|
|
152
|
+
"- When to use or update tasks instead of memory: When you need to break your work in current conversation into discrete steps or keep track of your progress use tasks instead of saving to memory. Tasks are great for persisting information about the work that needs to be done in the current conversation, but memory should be reserved for information that will be useful in future conversations.",
|
|
153
|
+
"",
|
|
154
|
+
];
|
|
155
|
+
/**
|
|
156
|
+
* Frontmatter format example with the `type` field.
|
|
157
|
+
*/
|
|
158
|
+
export const MEMORY_FRONTMATTER_EXAMPLE = [
|
|
159
|
+
"```markdown",
|
|
160
|
+
"---",
|
|
161
|
+
"name: {{memory name}}",
|
|
162
|
+
"description: {{one-line description — used to decide relevance in future conversations, so be specific}}",
|
|
163
|
+
`type: {{${MEMORY_TYPES.join(", ")}}}`,
|
|
164
|
+
"---",
|
|
165
|
+
"",
|
|
166
|
+
"{{memory content — for feedback/project types, structure as: rule/fact, then **Why:** and **How to apply:** lines}}",
|
|
167
|
+
"```",
|
|
168
|
+
];
|
|
169
|
+
/**
|
|
170
|
+
* `## How to save memories` section: the two-step write (topic file, then
|
|
171
|
+
* index pointer) plus the entrypoint rules.
|
|
172
|
+
*/
|
|
173
|
+
export function buildHowToSaveSection() {
|
|
174
|
+
return [
|
|
175
|
+
"## How to save memories",
|
|
176
|
+
"",
|
|
177
|
+
"Saving a memory is a two-step process:",
|
|
178
|
+
"",
|
|
179
|
+
"**Step 1** — write the memory to its own file (e.g., `user_role.md`, `feedback_testing.md`) using this frontmatter format:",
|
|
180
|
+
"",
|
|
181
|
+
...MEMORY_FRONTMATTER_EXAMPLE,
|
|
182
|
+
"",
|
|
183
|
+
`**Step 2** — add a pointer to that file in \`${MEMORY_ENTRYPOINT_NAME}\`. \`${MEMORY_ENTRYPOINT_NAME}\` is an index, not a memory — each entry should be one line, under ~${MEMORY_INDEX_LINE_GUIDANCE_CHARS} characters: \`- [Title](file.md) — one-line hook\`. It has no frontmatter. Never write memory content directly into \`${MEMORY_ENTRYPOINT_NAME}\`.`,
|
|
184
|
+
"",
|
|
185
|
+
`- \`${MEMORY_ENTRYPOINT_NAME}\` is always loaded into your conversation context — lines after ${MAX_MEMORY_ENTRYPOINT_LINES} or characters past ${MAX_MEMORY_ENTRYPOINT_CHARS} will be truncated, so keep the index concise`,
|
|
186
|
+
"- Keep the name, description, and type fields in memory files up-to-date with the content",
|
|
187
|
+
"- Organize memory semantically by topic, not chronologically",
|
|
188
|
+
"- Update or remove memories that turn out to be wrong or outdated",
|
|
189
|
+
"- Do not write duplicate memories. First check if there is an existing memory you can update before writing a new one.",
|
|
190
|
+
];
|
|
191
|
+
}
|
|
@@ -8,6 +8,13 @@ export declare class GitService {
|
|
|
8
8
|
* Clones a Git repository to a local path
|
|
9
9
|
*/
|
|
10
10
|
clone(urlOrRepo: string, targetPath: string, ref?: string): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Checks out a specific commit in an existing clone.
|
|
13
|
+
*
|
|
14
|
+
* Needed by marketplace plugin sources that pin a `sha` (spec plugin A-021):
|
|
15
|
+
* `clone -b <ref>` only guarantees the branch, not the exact commit.
|
|
16
|
+
*/
|
|
17
|
+
checkout(targetPath: string, sha: string): Promise<void>;
|
|
11
18
|
/**
|
|
12
19
|
* Pulls the latest changes in a local repository
|
|
13
20
|
*/
|
|
@@ -53,6 +53,29 @@ export class GitService {
|
|
|
53
53
|
throw this.handleGitError(urlOrRepo, error);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks out a specific commit in an existing clone.
|
|
58
|
+
*
|
|
59
|
+
* Needed by marketplace plugin sources that pin a `sha` (spec plugin A-021):
|
|
60
|
+
* `clone -b <ref>` only guarantees the branch, not the exact commit.
|
|
61
|
+
*/
|
|
62
|
+
async checkout(targetPath, sha) {
|
|
63
|
+
if (process.env.VITEST && !process.env.ALLOW_REAL_GIT) {
|
|
64
|
+
throw new Error(`Real git checkout is disabled in tests. Path: ${targetPath}, Sha: ${sha}`);
|
|
65
|
+
}
|
|
66
|
+
if (!(await this.isGitAvailable())) {
|
|
67
|
+
throw new Error("Git is not installed or not found in PATH. Please install Git to use Git/GitHub marketplaces.");
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
await execFileAsync("git", ["-C", targetPath, "checkout", "--detach", sha], {
|
|
71
|
+
env: { ...process.env, LC_ALL: "C" },
|
|
72
|
+
timeout: this.getTimeout(),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
throw this.handleGitError(sha, error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
56
79
|
/**
|
|
57
80
|
* Pulls the latest changes in a local repository
|
|
58
81
|
*/
|