@mercury-fw/core 0.29.3 → 0.29.4
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @mercury-fw/core
|
|
2
2
|
|
|
3
|
+
## 0.29.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 63f3da2: - Before writing to the wiki, the agent looks for a document on the same topic and updates it, instead of adding a new one each time.
|
|
8
|
+
- The agent no longer writes wiki notes restating a CLI's syntax or flags, which the plugin's skill and `--help` already cover.
|
|
9
|
+
- A learned command correction is keyed by the flag or subcommand it is about, without the tool's name, so corrections on the same flag land in the same note.
|
|
10
|
+
- The prompts that extract command corrections and facts about the user are in English.
|
|
11
|
+
- @mercury-fw/plugin-types@0.29.4
|
|
12
|
+
- @mercury-fw/channel-types@0.29.4
|
|
13
|
+
- @mercury-fw/cli-engine@0.29.4
|
|
14
|
+
- @mercury-fw/confirm-engine@0.29.4
|
|
15
|
+
|
|
3
16
|
## 0.29.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercury-fw/core",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"test": "bun test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@mercury-fw/channel-types": "0.29.
|
|
35
|
-
"@mercury-fw/cli-engine": "0.29.
|
|
36
|
-
"@mercury-fw/confirm-engine": "0.29.
|
|
37
|
-
"@mercury-fw/plugin-types": "0.29.
|
|
34
|
+
"@mercury-fw/channel-types": "0.29.4",
|
|
35
|
+
"@mercury-fw/cli-engine": "0.29.4",
|
|
36
|
+
"@mercury-fw/confirm-engine": "0.29.4",
|
|
37
|
+
"@mercury-fw/plugin-types": "0.29.4",
|
|
38
38
|
"@qdrant/js-client-rest": "^1.19.0",
|
|
39
39
|
"ai": "^7.0.126",
|
|
40
40
|
"ai-sdk-ollama": "^4.4.0",
|
|
@@ -34,13 +34,12 @@ type GenerateObjectFn = (params: {
|
|
|
34
34
|
}) => Promise<{ object: SemanticFact[] }>;
|
|
35
35
|
|
|
36
36
|
const SYSTEM_PROMPT =
|
|
37
|
-
"
|
|
38
|
-
'
|
|
39
|
-
'
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"anche in futuro. Restituisci un array vuoto se non c'è nulla che qualifica tra i topic ammessi.";
|
|
37
|
+
"Extract stable, recurring facts about the user from this conversation, choosing the topic only " +
|
|
38
|
+
'among these four: "team", "role", "preferred-language", "tools-used". Each fact is a {topic, value} ' +
|
|
39
|
+
'pair: "value" is what was stated or clearly implied for that topic. Don\'t extract the user\'s ' +
|
|
40
|
+
"identity or name: Mercury already tracks it separately. Don't extract details of a single task that " +
|
|
41
|
+
"only hold for this session, only things plausibly still true later. Return an empty array if nothing " +
|
|
42
|
+
"qualifies under the allowed topics.";
|
|
44
43
|
|
|
45
44
|
// index.ts prepends this to every user message before it reaches history,
|
|
46
45
|
// so the model knows who it's talking to within a turn — bookkeeping
|
|
@@ -80,11 +80,12 @@ export function buildSystemPrompt(opts: {
|
|
|
80
80
|
"- For anything else — documentation, project status, how some tool or process is used, team conventions — consult the wiki FIRST (grep/read_file/list_files), before trying a CLI or answering from general knowledge.",
|
|
81
81
|
"- If the wiki doesn't have the answer, try a live CLI query if one is relevant, before giving up.",
|
|
82
82
|
"- If you still don't know after checking both, say so plainly — don't guess or invent an answer.",
|
|
83
|
-
"- If you learn something worth remembering (a
|
|
83
|
+
"- If you learn something worth remembering (a correction from the user, a new convention, how this team uses a tool), first grep the wiki for a document on the same topic: if there is one, read it and update it with write_file; create a new, clearly-named file only when nothing covers it.",
|
|
84
84
|
"",
|
|
85
85
|
"DON'T:",
|
|
86
86
|
"- DON'T claim something is documented in the wiki without actually reading it via read_file/grep first.",
|
|
87
87
|
"- DON'T write_file over an existing curated document without reading it first — write_file replaces the whole file, it doesn't merge, so an unread overwrite silently destroys whatever was already there.",
|
|
88
|
+
"- DON'T write a wiki document restating a CLI's syntax or flags — a plugin's skill and --help are the source for those, and a note written after a failed attempt ends up contradicting them.",
|
|
88
89
|
].join("\n"),
|
|
89
90
|
);
|
|
90
91
|
lines.push(
|
|
@@ -30,14 +30,17 @@ type GenerateObjectFn = (params: {
|
|
|
30
30
|
prompt: string;
|
|
31
31
|
}) => Promise<{ object: z.infer<typeof ProceduralCorrectionCandidateSchema>[] }>;
|
|
32
32
|
|
|
33
|
+
// The note's file is `<tool>-<topic>.md`, so the tool's name in the topic
|
|
34
|
+
// doubles it, and two wordings of one rule make two files (#112).
|
|
33
35
|
const SYSTEM_PROMPT =
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
'
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
36
|
+
"You are shown a command attempt that failed and a later one, for the same tool, that succeeded in " +
|
|
37
|
+
"the same conversation turn. Describe the correction learned as a {topic, value} pair. " +
|
|
38
|
+
'"topic" is a short, stable key for this correction: the name of the flag or subcommand it is about, ' +
|
|
39
|
+
"in kebab-case, without the tool's name (the tool is already known: \"select-flag\", not " +
|
|
40
|
+
'"jira-select-flag"); a correction about the same flag as another one gets the same key. ' +
|
|
41
|
+
'"value" is the practical rule to remember, in one sentence, useful to anyone who runs this command ' +
|
|
42
|
+
"later, not only to whoever found it now. If the second attempt isn't really a correction of the " +
|
|
43
|
+
"first one's error (e.g. the user simply asked for something else), return an empty array.";
|
|
41
44
|
|
|
42
45
|
/** Same normalization `semantic-fact-extractor.ts` used to apply to identity/preference topics — still needed here since this topic is free text, not a closed enum (procedural corrections are open-ended by nature). */
|
|
43
46
|
function normalizeTopic(topic: string): string {
|
|
@@ -116,9 +119,9 @@ export function createToolCorrectionExtractor(
|
|
|
116
119
|
schema: ProceduralCorrectionCandidateSchema,
|
|
117
120
|
instructions: SYSTEM_PROMPT,
|
|
118
121
|
prompt:
|
|
119
|
-
`
|
|
120
|
-
`
|
|
121
|
-
`
|
|
122
|
+
`Failed command: ${failed.command}\n` +
|
|
123
|
+
`Error: ${failed.error ?? "(no message)"}\n` +
|
|
124
|
+
`Corrected command (succeeded): ${corrected.command}`,
|
|
122
125
|
});
|
|
123
126
|
for (const candidate of object) {
|
|
124
127
|
corrections.push({ tool: failed.binary, topic: normalizeTopic(candidate.topic), value: candidate.value });
|