@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 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
- try {
19
- const thisDir = dirname(fileURLToPath(import.meta.url));
20
- const candidate = resolve(thisDir, "../../templates");
21
- if (existsSync(candidate)) return candidate;
22
- } catch {
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, readFileSync as readFileSync2 } from "fs";
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
- try {
21
- const thisDir = dirname(fileURLToPath(import.meta.url));
22
- const candidate = resolve(thisDir, "../../templates");
23
- if (existsSync(candidate)) return candidate;
24
- } catch {
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 client.tui.showToast({
164
- body: {
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 client.app.log({
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
- editCount = 0;
181
- specFilesEdited = [];
182
- await client.app.log({
183
- body: {
184
- service: "agent-memory",
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" && editCount >= 3) {
191
- if (existsSync2(tasksFile)) {
192
- const content = readFileSync2(tasksFile, "utf-8");
193
- const inProgressSection = content.split("## In Progress")[1];
194
- if (inProgressSection?.trim()) {
195
- await client.tui.showToast({
196
- body: {
197
- message: `${editCount} edits this session. Update .agents/TASKS.md before ending.`,
198
- variant: "info"
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
- "tool.execute.after": async (input) => {
206
- if (input.tool === "edit" || input.tool === "write") {
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vuau/agent-memory",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Structured AI memory for codebases — OpenCode plugin + scaffolding CLI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",