wave-agent-sdk 1.2.0 → 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 +58 -4
- package/dist/agent.js +91 -19
- package/dist/builtin/index.js +2 -0
- package/dist/builtin/skills/settings.js +1 -12
- 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 +53 -13
- package/dist/core/plugin.js +134 -26
- 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 +5 -0
- package/dist/index.js +6 -0
- package/dist/managers/MemoryRuleManager.d.ts +6 -0
- package/dist/managers/MemoryRuleManager.js +12 -0
- package/dist/managers/aiManager.d.ts +35 -1
- package/dist/managers/aiManager.js +190 -21
- package/dist/managers/backgroundTaskManager.js +14 -0
- package/dist/managers/hookManager.d.ts +13 -0
- package/dist/managers/hookManager.js +31 -4
- package/dist/managers/liveConfigManager.d.ts +33 -0
- package/dist/managers/liveConfigManager.js +103 -8
- package/dist/managers/lspManager.d.ts +9 -0
- package/dist/managers/lspManager.js +47 -18
- package/dist/managers/mcpManager.d.ts +45 -10
- package/dist/managers/mcpManager.js +103 -1
- package/dist/managers/messageManager.d.ts +48 -5
- package/dist/managers/messageManager.js +107 -21
- package/dist/managers/permissionManager.d.ts +40 -0
- package/dist/managers/permissionManager.js +63 -8
- 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 +19 -0
- package/dist/managers/skillManager.js +44 -0
- package/dist/managers/slashCommandManager.d.ts +10 -0
- package/dist/managers/slashCommandManager.js +35 -3
- package/dist/managers/subagentManager.d.ts +8 -0
- package/dist/managers/subagentManager.js +20 -0
- package/dist/managers/toolManager.d.ts +29 -3
- package/dist/managers/toolManager.js +87 -13
- 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/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 +318 -119
- 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 +60 -9
- package/dist/services/configurationService.js +129 -54
- 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 +19 -15
- package/dist/services/interactionService.d.ts +9 -1
- package/dist/services/interactionService.js +28 -8
- package/dist/services/jsonlHandler.d.ts +84 -0
- package/dist/services/jsonlHandler.js +209 -14
- package/dist/services/memory.d.ts +3 -1
- package/dist/services/memory.js +13 -9
- package/dist/services/officialMarketplaceMirror.js +3 -2
- package/dist/services/pluginLoader.d.ts +12 -4
- package/dist/services/pluginLoader.js +38 -7
- package/dist/services/remoteSettingsService.js +16 -2
- package/dist/services/session.d.ts +74 -0
- package/dist/services/session.js +144 -3
- package/dist/services/sessionEntries.d.ts +2 -0
- package/dist/services/sessionEntries.js +20 -0
- package/dist/stdio/index.d.ts +3 -1
- package/dist/stdio/index.js +3 -1
- package/dist/stdio/notificationRouter.js +1 -0
- package/dist/stdio/stdioAgent.d.ts +14 -7
- package/dist/stdio/stdioAgent.js +19 -0
- package/dist/tools/artifactTool.js +406 -273
- package/dist/tools/bashTool.js +8 -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/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 +20 -5
- package/dist/types/configuration.d.ts +39 -1
- package/dist/types/marketplace.d.ts +40 -2
- package/dist/types/mcp.d.ts +39 -0
- 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 +15 -0
- package/dist/utils/constants.d.ts +10 -0
- package/dist/utils/constants.js +10 -0
- package/dist/utils/containerSetup.js +43 -0
- 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 +33 -0
- package/dist/utils/fileUtils.js +81 -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 -2
- package/dist/utils/messageOperations.js +40 -29
- 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 +39 -43
- package/dist/utils/userSettings.d.ts +90 -0
- package/dist/utils/userSettings.js +291 -0
- package/package.json +10 -7
|
@@ -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
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KnownMarketplace, KnownMarketplacesRegistry, InstalledPlugin, InstalledPluginsRegistry, MarketplaceManifest, MarketplaceSource } from "../types/marketplace.js";
|
|
1
|
+
import { KnownMarketplace, KnownMarketplacesRegistry, InstalledPlugin, InstalledPluginsRegistry, MarketplaceManifest, MarketplaceSource, PluginInstallLocation } from "../types/marketplace.js";
|
|
2
2
|
import { ConfigurationService } from "./configurationService.js";
|
|
3
3
|
import type { Scope } from "../types/configuration.js";
|
|
4
4
|
/**
|
|
@@ -11,7 +11,18 @@ import type { Scope } from "../types/configuration.js";
|
|
|
11
11
|
* known_marketplaces.json is kept as a cache for installLocation/lastUpdated metadata.
|
|
12
12
|
*/
|
|
13
13
|
export declare class MarketplaceService {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* 已持有市场操作锁的调用链标记(重入判据)。
|
|
16
|
+
*
|
|
17
|
+
* 用 AsyncLocalStorage 而不是进程内布尔值:锁内发起的嵌套调用(如
|
|
18
|
+
* refreshMarketplaces → updateMarketplace → installPlugin)必须跳过再次加锁,
|
|
19
|
+
* 否则会自锁;但**另一条并发调用链**必须老老实实排队。布尔值无法区分这两者
|
|
20
|
+
* ——第二个并发调用会以为「已在锁内」而跳过锁直接执行,于是两个操作并行改同一
|
|
21
|
+
* 个市场检出(并发两次 `git pull` 同一检出必然失败,spec 插件市场 场景 14)。
|
|
22
|
+
*/
|
|
23
|
+
private static readonly lockChain;
|
|
24
|
+
/** In-flight [refreshMarketplaces] call (single-flight, spec 插件市场 场景 13). */
|
|
25
|
+
private refreshInFlight;
|
|
15
26
|
private pluginsDir;
|
|
16
27
|
private knownMarketplacesPath;
|
|
17
28
|
private installedPluginsPath;
|
|
@@ -49,7 +60,7 @@ export declare class MarketplaceService {
|
|
|
49
60
|
private isStaleLock;
|
|
50
61
|
/**
|
|
51
62
|
* Acquires a file-based lock (with PID tracking for stale lock detection) and executes the provided function.
|
|
52
|
-
* Supports re-entrancy within the same
|
|
63
|
+
* Supports re-entrancy within the same call chain (see [lockChain]).
|
|
53
64
|
*/
|
|
54
65
|
private withLock;
|
|
55
66
|
/**
|
|
@@ -78,6 +89,21 @@ export declare class MarketplaceService {
|
|
|
78
89
|
* Saves the installed plugins registry
|
|
79
90
|
*/
|
|
80
91
|
saveInstalledPlugins(registry: InstalledPluginsRegistry): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Whether an install record belongs to the given install location.
|
|
94
|
+
*
|
|
95
|
+
* Records written before scopes were tracked carry no `scope`; they stand for
|
|
96
|
+
* "installed once on this machine" and match any scope, so uninstalling them
|
|
97
|
+
* keeps working (they are that plugin's only record). They still match by
|
|
98
|
+
* project path, so records of two different projects stay distinguishable.
|
|
99
|
+
*/
|
|
100
|
+
private matchesInstallLocation;
|
|
101
|
+
/**
|
|
102
|
+
* The install location a record is keyed by. Scope-less legacy records are
|
|
103
|
+
* treated as user-scope when they have to be re-created (e.g. by an update).
|
|
104
|
+
*/
|
|
105
|
+
private locationOf;
|
|
106
|
+
private describeInstallLocations;
|
|
81
107
|
/**
|
|
82
108
|
* Loads a marketplace manifest from a local path
|
|
83
109
|
*/
|
|
@@ -94,6 +120,18 @@ export declare class MarketplaceService {
|
|
|
94
120
|
* Finds which scope declared a marketplace (user, project, local, or builtin)
|
|
95
121
|
*/
|
|
96
122
|
getMarketplaceDeclaringSource(name: string): Scope | "builtin" | null;
|
|
123
|
+
/**
|
|
124
|
+
* 已注册的市场(作用域配置 + 缓存注册表合并去重),用于添加前的判重
|
|
125
|
+
*/
|
|
126
|
+
private listRegisteredMarketplaces;
|
|
127
|
+
/**
|
|
128
|
+
* 添加市场前判重(spec ecosystem/plugin「设置页插件市场」场景 16):来源重复或
|
|
129
|
+
* 清单声明的名称与已有市场同名时不允许添加。只传 source 时仅判来源(用于克隆
|
|
130
|
+
* 之前,避免为一个已存在的来源白克隆一次)。
|
|
131
|
+
*/
|
|
132
|
+
private assertMarketplaceAddable;
|
|
133
|
+
/** 两个市场来源是否指向同一处(同类型比 url/repo/path,忽略 ref) */
|
|
134
|
+
private static isSameMarketplaceSource;
|
|
97
135
|
/**
|
|
98
136
|
* Adds a new marketplace (local directory, GitHub repo, or Git URL)
|
|
99
137
|
*/
|
|
@@ -114,28 +152,74 @@ export declare class MarketplaceService {
|
|
|
114
152
|
private uninstallPluginsByMarketplace;
|
|
115
153
|
/**
|
|
116
154
|
* Updates a specific marketplace or all marketplaces
|
|
155
|
+
*
|
|
156
|
+
* `refreshCheckout` (default true) pulls the checkout from its upstream; pass
|
|
157
|
+
* false to upgrade plugins against the current checkout only — the interactive
|
|
158
|
+
* "批量更新插件" path does that, because opening the plugin-marketplace surface
|
|
159
|
+
* already refreshed the checkout (spec 插件市场 A-013).
|
|
160
|
+
*
|
|
161
|
+
* Returns the number of installed plugins whose version actually changed
|
|
162
|
+
* during this run (0 = everything was already up to date) — the GUI hosts
|
|
163
|
+
* use it to tell "已更新 N 个插件" apart from "已是最新" (spec 插件市场 场景 13).
|
|
117
164
|
*/
|
|
118
165
|
updateMarketplace(name?: string, options?: {
|
|
119
166
|
updatePlugins?: boolean;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
*
|
|
127
|
-
*/
|
|
128
|
-
|
|
167
|
+
refreshCheckout?: boolean;
|
|
168
|
+
}): Promise<number>;
|
|
169
|
+
/**
|
|
170
|
+
* 交互界面的「批量更新插件」:按当前清单把该市场内所有已安装且有新版本的插件
|
|
171
|
+
* 升级到最新,**不拉取检出**——清单的新鲜度由打开插件市场界面时的那次刷新保证
|
|
172
|
+
* (spec 插件市场 A-013/场景 14)。检出尚未据此刷新的场景(无界面可依赖的非交互
|
|
173
|
+
* 命令)走 [updateMarketplace] 的默认行为。
|
|
174
|
+
*/
|
|
175
|
+
updateMarketplacePlugins(name?: string): Promise<number>;
|
|
176
|
+
/**
|
|
177
|
+
* Refreshes the local checkout of every registered marketplace.
|
|
178
|
+
*
|
|
179
|
+
* Callers are the plugin-marketplace surfaces (GUI settings view / CLI plugin
|
|
180
|
+
* manager), refreshed when the user opens them — the agent-startup path no
|
|
181
|
+
* longer refreshes anything (spec 插件市场 A-013 场景 5).
|
|
182
|
+
*
|
|
183
|
+
* This is a fixed behavior with no opt-in/opt-out: `autoUpdate` no longer
|
|
184
|
+
* exists, so all marketplaces are refreshed alike (A-014). Refreshing only
|
|
185
|
+
* updates the checkout — installed plugins are never reinstalled here, so a
|
|
186
|
+
* newer plugin version surfaces as an explicit "更新" (per plugin) /
|
|
187
|
+
* "批量更新插件" (batch) action instead of being applied behind the user's
|
|
188
|
+
* back.
|
|
189
|
+
*
|
|
190
|
+
* Single-flight: a call landing while a refresh is running reuses it instead
|
|
191
|
+
* of pulling every checkout twice (spec 场景 13).
|
|
192
|
+
*/
|
|
193
|
+
refreshMarketplaces(): Promise<void>;
|
|
129
194
|
/**
|
|
130
195
|
* Installs a plugin from a marketplace
|
|
196
|
+
*
|
|
197
|
+
* @param location 该次安装记账的位置(spec plugin A-015)。缺省只在内部调用
|
|
198
|
+
* (宿主加载时补装)出现,此时写入一条不带作用域的历史形态记录。
|
|
131
199
|
*/
|
|
132
|
-
installPlugin(pluginAtMarketplace: string,
|
|
200
|
+
installPlugin(pluginAtMarketplace: string, location?: PluginInstallLocation): Promise<InstalledPlugin>;
|
|
133
201
|
/**
|
|
134
202
|
* Uninstalls a plugin
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
*
|
|
203
|
+
*
|
|
204
|
+
* With a [location], only that scope's install record is removed — other
|
|
205
|
+
* scopes (including other projects' project/local records) keep theirs, and
|
|
206
|
+
* the shared cache directory is deleted only once no record references it
|
|
207
|
+
* (spec plugin A-015). Without one, every record of the plugin is removed
|
|
208
|
+
* (used by [updatePlugin] and the marketplace-level cleanup).
|
|
209
|
+
*/
|
|
210
|
+
uninstallPlugin(pluginAtMarketplace: string, location?: PluginInstallLocation): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* Moves a plugin's install record to another location(「更换安装作用域」):
|
|
213
|
+
* the record currently at [from] (or the plugin's only record when [from] is
|
|
214
|
+
* omitted or unknown) is rewritten to [to], so that uninstalling the plugin
|
|
215
|
+
* at its new scope still finds it (spec plugin A-015). A duplicate record
|
|
216
|
+
* already at [to] wins and the moved one is dropped.
|
|
217
|
+
*/
|
|
218
|
+
relocatePlugin(pluginAtMarketplace: string, from: PluginInstallLocation | undefined, to: PluginInstallLocation): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Updates a plugin (uninstall followed by install). Every install record of
|
|
221
|
+
* the plugin is re-created at its original location, so the install scopes
|
|
222
|
+
* stay unchanged (spec plugin「设置页插件市场」场景 12 / A-015).
|
|
139
223
|
*/
|
|
140
224
|
updatePlugin(pluginAtMarketplace: string): Promise<InstalledPlugin>;
|
|
141
225
|
}
|