@vuau/agent-memory 0.2.0 → 0.2.1
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/bin/cli.js +6 -9
- package/dist/index.js +67 -46
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -15,15 +15,12 @@ var COPILOT_INSTRUCTIONS = ".github/copilot-instructions.md";
|
|
|
15
15
|
|
|
16
16
|
// src/core/scaffold.ts
|
|
17
17
|
function getTemplatesDir() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
const candidate2 = resolve(__dirname, "../../templates");
|
|
25
|
-
if (existsSync(candidate2)) return candidate2;
|
|
26
|
-
throw new Error("Cannot locate templates directory");
|
|
18
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const fromSource = resolve(thisDir, "../../templates");
|
|
20
|
+
if (existsSync(fromSource)) return fromSource;
|
|
21
|
+
const fromDist = resolve(thisDir, "../templates");
|
|
22
|
+
if (existsSync(fromDist)) return fromDist;
|
|
23
|
+
throw new Error(`Cannot locate templates directory (checked ${fromSource} and ${fromDist})`);
|
|
27
24
|
}
|
|
28
25
|
var TEMPLATES_DIR = getTemplatesDir();
|
|
29
26
|
function readTemplate(name) {
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/opencode/plugin.ts
|
|
2
|
-
import { existsSync as existsSync2
|
|
2
|
+
import { existsSync as existsSync2 } from "fs";
|
|
3
3
|
import { resolve as resolve2 } from "path";
|
|
4
4
|
|
|
5
5
|
// src/core/scaffold.ts
|
|
@@ -17,15 +17,12 @@ var COPILOT_INSTRUCTIONS = ".github/copilot-instructions.md";
|
|
|
17
17
|
|
|
18
18
|
// src/core/scaffold.ts
|
|
19
19
|
function getTemplatesDir() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
const candidate2 = resolve(__dirname, "../../templates");
|
|
27
|
-
if (existsSync(candidate2)) return candidate2;
|
|
28
|
-
throw new Error("Cannot locate templates directory");
|
|
20
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const fromSource = resolve(thisDir, "../../templates");
|
|
22
|
+
if (existsSync(fromSource)) return fromSource;
|
|
23
|
+
const fromDist = resolve(thisDir, "../templates");
|
|
24
|
+
if (existsSync(fromDist)) return fromDist;
|
|
25
|
+
throw new Error(`Cannot locate templates directory (checked ${fromSource} and ${fromDist})`);
|
|
29
26
|
}
|
|
30
27
|
var TEMPLATES_DIR = getTemplatesDir();
|
|
31
28
|
function readTemplate(name) {
|
|
@@ -151,67 +148,91 @@ var MemoryLifecyclePlugin = async ({ client, directory }) => {
|
|
|
151
148
|
const agentsFile = resolve2(directory, AGENTS_MD);
|
|
152
149
|
let editCount = 0;
|
|
153
150
|
let specFilesEdited = [];
|
|
151
|
+
let sessionStartTime = null;
|
|
152
|
+
const showToast = async (message, variant = "info") => {
|
|
153
|
+
try {
|
|
154
|
+
await client.tui.showToast({
|
|
155
|
+
body: { message, variant }
|
|
156
|
+
});
|
|
157
|
+
} catch {
|
|
158
|
+
await log("info", message);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const log = async (level, message, extra) => {
|
|
162
|
+
try {
|
|
163
|
+
await client.app.log({
|
|
164
|
+
body: {
|
|
165
|
+
service: "agent-memory",
|
|
166
|
+
level,
|
|
167
|
+
message,
|
|
168
|
+
extra
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
} catch {
|
|
172
|
+
}
|
|
173
|
+
};
|
|
154
174
|
return {
|
|
155
175
|
event: async ({ event }) => {
|
|
156
176
|
if (event.type === "session.created") {
|
|
177
|
+
sessionStartTime = Date.now();
|
|
178
|
+
editCount = 0;
|
|
179
|
+
specFilesEdited = [];
|
|
157
180
|
const hasAgentsMd = existsSync2(agentsFile);
|
|
158
181
|
const hasMemory = existsSync2(memoryFile);
|
|
182
|
+
const hasTasks = existsSync2(tasksFile);
|
|
159
183
|
if (!hasMemory && hasAgentsMd) {
|
|
160
184
|
try {
|
|
161
185
|
const result = scaffold(directory, { copilotInstructions: false });
|
|
162
186
|
if (result.created.length > 0) {
|
|
163
|
-
await
|
|
164
|
-
|
|
165
|
-
message: `Agent memory initialized: ${result.created.join(", ")}`,
|
|
166
|
-
variant: "success"
|
|
167
|
-
}
|
|
168
|
-
});
|
|
187
|
+
await showToast(`Agent memory initialized: ${result.created.join(", ")}`, "success");
|
|
188
|
+
await log("info", "Auto-scaffolded .agents/ structure", { created: result.created });
|
|
169
189
|
}
|
|
170
190
|
} catch (err) {
|
|
171
|
-
await
|
|
172
|
-
body: {
|
|
173
|
-
service: "agent-memory",
|
|
174
|
-
level: "warn",
|
|
175
|
-
message: `Auto-scaffold failed: ${err}`
|
|
176
|
-
}
|
|
177
|
-
});
|
|
191
|
+
await log("warn", `Auto-scaffold failed: ${err}`);
|
|
178
192
|
}
|
|
179
193
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
level: "info",
|
|
186
|
-
message: `Memory: ${hasMemory}, Tasks: ${existsSync2(tasksFile)}`
|
|
187
|
-
}
|
|
194
|
+
await log("debug", "Session started", {
|
|
195
|
+
hasAgentsMd,
|
|
196
|
+
hasMemory,
|
|
197
|
+
hasTasks,
|
|
198
|
+
directory
|
|
188
199
|
});
|
|
189
200
|
}
|
|
190
|
-
if (event.type === "session.idle"
|
|
191
|
-
if (existsSync2(tasksFile)) {
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
201
|
+
if (event.type === "session.idle") {
|
|
202
|
+
if (editCount >= 3 && existsSync2(tasksFile)) {
|
|
203
|
+
const sessionDuration = sessionStartTime ? Math.round((Date.now() - sessionStartTime) / 1e3 / 60) : 0;
|
|
204
|
+
await showToast(
|
|
205
|
+
`${editCount} file edits (${sessionDuration}m). Consider updating .agents/TASKS.md`,
|
|
206
|
+
"info"
|
|
207
|
+
);
|
|
208
|
+
await log("info", "Session idle with significant edits", {
|
|
209
|
+
editCount,
|
|
210
|
+
specFilesEdited,
|
|
211
|
+
sessionDurationMinutes: sessionDuration
|
|
212
|
+
});
|
|
202
213
|
}
|
|
203
214
|
}
|
|
204
215
|
},
|
|
205
|
-
|
|
206
|
-
|
|
216
|
+
// ─────────────────────────────────────────────────────────────
|
|
217
|
+
// TOOL EXECUTE AFTER — track edits
|
|
218
|
+
// ─────────────────────────────────────────────────────────────
|
|
219
|
+
"tool.execute.after": async (input, _output) => {
|
|
220
|
+
const toolName = input.tool;
|
|
221
|
+
const filePath = input.args?.filePath || "";
|
|
222
|
+
if (toolName === "edit" || toolName === "write") {
|
|
207
223
|
editCount++;
|
|
208
|
-
const filePath = input.args?.filePath || "";
|
|
209
224
|
if (filePath.includes(SPEC_DIR)) {
|
|
210
225
|
const shortPath = filePath.split(SPEC_DIR + "/").pop() || filePath;
|
|
211
226
|
if (!specFilesEdited.includes(shortPath)) {
|
|
212
227
|
specFilesEdited.push(shortPath);
|
|
213
228
|
}
|
|
214
229
|
}
|
|
230
|
+
if (editCount % 5 === 0) {
|
|
231
|
+
await log("debug", `Edit milestone: ${editCount} files modified`, {
|
|
232
|
+
latestFile: filePath,
|
|
233
|
+
specFilesEdited
|
|
234
|
+
});
|
|
235
|
+
}
|
|
215
236
|
}
|
|
216
237
|
}
|
|
217
238
|
};
|