@wholiver_hu/metis 0.80.13 → 0.80.15
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/cli/startup-ui.js +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/builtins/dream-mode.d.ts +4 -0
- package/dist/core/builtins/dream-mode.d.ts.map +1 -0
- package/dist/core/builtins/dream-mode.js +487 -0
- package/dist/core/builtins/dream-mode.js.map +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +4 -3
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +6 -6
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +12 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +16 -12
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/index.d.ts +6 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +45 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/log.d.ts +25 -0
- package/dist/core/tools/log.d.ts.map +1 -0
- package/dist/core/tools/log.js +83 -0
- package/dist/core/tools/log.js.map +1 -0
- package/dist/core/tools/remember-user-intent.d.ts +11 -0
- package/dist/core/tools/remember-user-intent.d.ts.map +1 -0
- package/dist/core/tools/remember-user-intent.js +35 -0
- package/dist/core/tools/remember-user-intent.js.map +1 -0
- package/dist/core/tools/user-intent.d.ts +9 -0
- package/dist/core/tools/user-intent.d.ts.map +1 -0
- package/dist/core/tools/user-intent.js +31 -0
- package/dist/core/tools/user-intent.js.map +1 -0
- package/dist/core/user-intent.d.ts +4 -0
- package/dist/core/user-intent.d.ts.map +1 -0
- package/dist/core/user-intent.js +47 -0
- package/dist/core/user-intent.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +30 -15
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +0 -10
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/examples/extensions/dream-mode.ts +1 -121
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
|
@@ -1,121 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import { homedir } from "os";
|
|
4
|
-
import { writeFileSync, readFileSync, existsSync } from "fs";
|
|
5
|
-
|
|
6
|
-
interface DreamState {
|
|
7
|
-
enabled: boolean;
|
|
8
|
-
lastDreamDate?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const DREAM_STATE_PATH = resolve(homedir(), ".metis/dream_state.json");
|
|
12
|
-
|
|
13
|
-
function readState(): DreamState {
|
|
14
|
-
try {
|
|
15
|
-
if (existsSync(DREAM_STATE_PATH)) {
|
|
16
|
-
return JSON.parse(readFileSync(DREAM_STATE_PATH, "utf-8"));
|
|
17
|
-
}
|
|
18
|
-
} catch {}
|
|
19
|
-
return { enabled: false };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function writeState(state: DreamState) {
|
|
23
|
-
try {
|
|
24
|
-
writeFileSync(DREAM_STATE_PATH, JSON.stringify(state, null, 2), "utf-8");
|
|
25
|
-
} catch {}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getTodayString(): string {
|
|
29
|
-
const now = new Date();
|
|
30
|
-
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const DREAM_PROMPT = `
|
|
34
|
-
[DREAM PHASE REQUIRED]
|
|
35
|
-
Before fulfilling the user's request, you MUST first perform the Dream Phase.
|
|
36
|
-
Instructions:
|
|
37
|
-
1. Read the short-term working log in .temp/ (using your read file tools).
|
|
38
|
-
2. Read the unified long-term memory map: .metis/brain-map.md.
|
|
39
|
-
3. Extract Episodic Memory: Write ONE brief summary node of the overall task into the Episodic section of brain-map.md (e.g. "Worked on X"). Start it with [Weight: 3].
|
|
40
|
-
4. Extract Semantic Memory (Hippocampus Filter): ONLY extract specific nodes for high cognitive effort events (unexpected quirks, hard bugs). Ignore routine CRUD or UI tasks. Start them with [Weight: 5].
|
|
41
|
-
5. Create Synapses: When adding new nodes, search brain-map.md for related existing nodes and add bidirectional "[Related: #ID]" links.
|
|
42
|
-
6. Apply Forgetting Curve: Check all [Last-Accessed] dates in brain-map.md. Reduce the [Weight] of nodes not accessed in over 3 days by 1.
|
|
43
|
-
7. Garbage Collection: If any node's [Weight] drops to 0, REMOVE it from brain-map.md AND you MUST physically delete/archive its corresponding full-text file in .metis/memory/ or .metis/lessons/.
|
|
44
|
-
8. Clear the short-term working log to signify waking up fresh.
|
|
45
|
-
9. Finally, proceed to answer the user's prompt normally.
|
|
46
|
-
`;
|
|
47
|
-
|
|
48
|
-
export default function dreamMode(metis: ExtensionAPI): void {
|
|
49
|
-
// Let the user toggle the dream mode on/off
|
|
50
|
-
metis.registerCommand("/dream", {
|
|
51
|
-
description: "Toggle automatic brain-like memory consolidation (sleep mode).",
|
|
52
|
-
handler: async (ctx) => {
|
|
53
|
-
const state = readState();
|
|
54
|
-
state.enabled = !state.enabled;
|
|
55
|
-
writeState(state);
|
|
56
|
-
ctx.ui.notify(
|
|
57
|
-
`Dream Mode ${state.enabled ? "enabled" : "disabled"}. ${state.enabled ? "Memory consolidation will happen automatically once per day." : ""}`,
|
|
58
|
-
);
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// Inject the dream instructions if it's a new day and dream mode is enabled
|
|
63
|
-
metis.on("context", (event, ctx) => {
|
|
64
|
-
const state = readState();
|
|
65
|
-
if (!state.enabled) return;
|
|
66
|
-
|
|
67
|
-
const today = getTodayString();
|
|
68
|
-
if (state.lastDreamDate !== today) {
|
|
69
|
-
// Find the system prompt message to append our dream instruction
|
|
70
|
-
const systemMsg = event.messages.find((m) => m.role === "system");
|
|
71
|
-
if (systemMsg && typeof systemMsg.content === "string") {
|
|
72
|
-
systemMsg.content += `\n\n${DREAM_PROMPT}`;
|
|
73
|
-
ctx.ui.notify("Dream Phase injection added to current task context.");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Mark dream as complete after a successful loop
|
|
79
|
-
metis.on("agent_end", (event, ctx) => {
|
|
80
|
-
const state = readState();
|
|
81
|
-
if (!state.enabled) return;
|
|
82
|
-
|
|
83
|
-
const today = getTodayString();
|
|
84
|
-
// If we finished a task and the last dream wasn't today, mark it as done for today.
|
|
85
|
-
// We assume the prompt injection was successful and the agent did the dream tasks.
|
|
86
|
-
if (state.lastDreamDate !== today) {
|
|
87
|
-
state.lastDreamDate = today;
|
|
88
|
-
writeState(state);
|
|
89
|
-
ctx.ui.notify("Dream Phase completed successfully for today.");
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// 1 AM Cron Job for users who leave Metis open 24/7
|
|
94
|
-
let cronInterval: NodeJS.Timeout | undefined;
|
|
95
|
-
|
|
96
|
-
metis.on("session_start", (_event, ctx) => {
|
|
97
|
-
if (cronInterval) {
|
|
98
|
-
clearInterval(cronInterval);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
cronInterval = setInterval(() => {
|
|
102
|
-
const state = readState();
|
|
103
|
-
if (!state.enabled) return;
|
|
104
|
-
|
|
105
|
-
const now = new Date();
|
|
106
|
-
const today = getTodayString();
|
|
107
|
-
|
|
108
|
-
// Check if it's 1 AM and we haven't dreamed today
|
|
109
|
-
if (now.getHours() === 1 && state.lastDreamDate !== today && !ctx.hasPendingMessages() && ctx.isIdle()) {
|
|
110
|
-
// Tell the user that the background dream is pending upon next action
|
|
111
|
-
ctx.ui.notify("It's 1 AM! Your next prompt will automatically trigger a Dream Phase to consolidate memories.");
|
|
112
|
-
}
|
|
113
|
-
}, 60 * 1000); // check every minute
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
metis.on("session_shutdown", () => {
|
|
117
|
-
if (cronInterval) {
|
|
118
|
-
clearInterval(cronInterval);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
1
|
+
export { default } from "../../src/core/builtins/dream-mode.ts";
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wholiver_hu/metis",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.15",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@wholiver_hu/metis",
|
|
9
|
-
"version": "0.80.
|
|
9
|
+
"version": "0.80.15",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"@earendil-works/metis-agent-core",
|
|
12
12
|
"@earendil-works/metis-ai",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wholiver_hu/metis",
|
|
3
|
-
"version": "0.80.
|
|
3
|
+
"version": "0.80.15",
|
|
4
4
|
"description": "Metis coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"metisConfig": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
33
|
"clean": "shx rm -rf dist",
|
|
34
|
-
"build": "tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js dist/rpc-entry.js && npm run copy-assets",
|
|
34
|
+
"build": "npm run clean && tsgo -p tsconfig.build.json && shx chmod +x dist/cli.js dist/rpc-entry.js && npm run copy-assets",
|
|
35
35
|
"build:binary": "npm --prefix ../tui run build && npm --prefix ../ai run build && npm --prefix ../agent run build && npm run build && bun build --compile ./dist/bun/cli.js ./src/utils/image-resize-worker.ts --outfile dist/metis && npm run copy-binary-assets",
|
|
36
36
|
"copy-assets": "shx mkdir -p dist/modes/interactive/theme && shx cp src/modes/interactive/theme/*.json dist/modes/interactive/theme/ && shx mkdir -p dist/modes/interactive/assets && shx cp src/modes/interactive/assets/*.png dist/modes/interactive/assets/ && shx mkdir -p dist/core/export-html/vendor && shx cp src/core/export-html/template.html src/core/export-html/template.css src/core/export-html/template.js dist/core/export-html/ && shx cp src/core/export-html/vendor/*.js dist/core/export-html/vendor/",
|
|
37
37
|
"copy-binary-assets": "shx cp package.json dist/ && shx cp README.md dist/ && shx cp CHANGELOG.md dist/ && shx mkdir -p dist/theme && shx cp src/modes/interactive/theme/*.json dist/theme/ && shx mkdir -p dist/assets && shx cp src/modes/interactive/assets/*.png dist/assets/ && shx mkdir -p dist/export-html/vendor && shx cp src/core/export-html/template.html dist/export-html/ && shx cp src/core/export-html/vendor/*.js dist/export-html/vendor/ && shx cp -r docs dist/ && shx cp -r examples dist/ && shx cp ../../node_modules/@silvia-odwyer/photon-node/photon_rs_bg.wasm dist/",
|