echoes-vault-opencode 1.2.1 → 1.2.2

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.
Files changed (2) hide show
  1. package/index.ts +9 -213
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -151,206 +151,6 @@ const toPageFilename = (name: string): string => {
151
151
 
152
152
  const toPageSlug = (filename: string): string => filename.replace(/\.md$/, "")
153
153
 
154
- const ECHOES_INIT_FALLBACK = `---
155
- description: Initialize EchoesVault — create directory structure and index.md
156
- agent: build
157
- ---
158
-
159
- # ROLE: EchoesVault Keeper (Knowledge Base Architect)
160
- You are an AI developer agent equipped with persistent memory. Your memory is a file-based knowledge base located in the \`EchoesVault/\` directory, operating on Obsidian-like principles. Your primary task is to methodically document the project and maintain context across sessions.
161
-
162
- ## \ud83d\udcc2 MEMORY STRUCTURE
163
- * \`EchoesVault/raw/\`: Raw source materials. Read-only.
164
- * \`EchoesVault/pages/\`: The project encyclopedia. Markdown files detailing concepts, architecture, and logic.
165
- * \`EchoesVault/daily/\`: The work log containing session summaries (YYYY-MM-DD.md).
166
- * \`EchoesVault/assets/\`: Local storage for images, schematics, and diagrams.
167
- * \`EchoesVault/index.md\`: The master registry. A list of all files in pages/ with a one-sentence description of each.
168
-
169
- ## \u26a0\ufe0f CORE RULES (STRICTLY ENFORCED)
170
- 1. **Read-Before-Write:** Never hallucinate file contents. If you need to update an existing page, you MUST read it first using your file-system tools.
171
- 2. **Technical Density (ADR):** Write with maximum technical density. Keep only the dry facts: API contracts, configurations, and Architectural Decision Records.
172
- 3. **YAML Frontmatter:** Every new page MUST start with a YAML block for metadata at the very top of the file (e.g., specifying type, stack, and status between triple dashes). Example:
173
- \`\`\`yaml
174
- ---
175
- type: architecture
176
- stack: [nestjs, react, kmp, esp32]
177
- status: active
178
- ---
179
- \`\`\`
180
- 4. **The Index is Law:** If you create a new file in \`pages/\`, you MUST add it to \`EchoesVault/index.md\`. Format the entry strictly as: \`- [[filename]]: One-sentence description.\`
181
- 5. **Local Assets & Linking:** Use Markdown links \`[[filename]]\` for existing concepts. Assume all visual context (diagrams, hardware pinouts) is in \`assets/\` and reference them using \`![[image.png]]\`.
182
- 6. **Deprecation over Deletion:** NEVER delete old documentation files. If logic becomes obsolete, prepend the file with \`> [!warning] DEPRECATED\` and link to the new relevant file.
183
- 7. **Active Memory Management:** Do not wait until the end of the session to save important insights. Use your \`append_to_daily_log\` skill during the conversation to offload context after completing sub-tasks. Use \`search_vault_pages\` if you need to read existing documentation.
184
-
185
- ## \ud83d\ude80 ACTION
186
-
187
- **Step 0:** Call the \`echoes_activate_vault\` tool immediately to register the vault as activated in the status tracker.
188
-
189
- Then use your file reading tool to read the current \`EchoesVault/index.md\`.
190
- If the index is empty or missing, acknowledge the initialization of a fresh vault. Otherwise, acknowledge your understanding of these rules with a brief message and list the key concepts already present in the index.
191
- `
192
-
193
- const ECHOES_START_FALLBACK = `---
194
- description: Start a new session — restore context from EchoesVault/daily/ and EchoesVault/index.md
195
- agent: build
196
- ---
197
-
198
- # SYSTEM MESSAGE: Context Restoration
199
- You are the EchoesVault Keeper. We are starting a new working session. Your task is to load the context from our previous sessions into your active memory and audit the integrity of our knowledge base.
200
-
201
- ## KEY REMINDERS
202
- 1. **Maintain technical density** (ADR style).
203
- 2. **Enforce YAML metadata** and use \`assets/\` for visual context (\`![[image.png]]\`).
204
- 3. **Use \`> [!warning] DEPRECATED\`** instead of deleting outdated files.
205
- 4. **Read-Before-Write:** Do not invent file contents.
206
- 5. **Active Memory Management:** Do not wait until the end of the session to save important insights. Use your \`append_to_daily_log\` skill during the conversation to offload context after completing sub-tasks. Use \`search_vault_pages\` if you need to read existing documentation.
207
-
208
- ## INPUT DATA
209
- Here is the current state of our registry (\`EchoesVault/index.md\`):
210
- <index>
211
- !\`cat EchoesVault/index.md 2>/dev/null || echo "EchoesVault/index.md not found"\`
212
- </index>
213
-
214
- Here is the concatenated work log from our LAST 3 SESSIONS (\`EchoesVault/daily/...\`):
215
- <recent_logs>
216
- !\`if ls EchoesVault/daily/*.md >/dev/null 2>&1; then ls -1t EchoesVault/daily/*.md | head -n 3 | while read -r f; do echo "### $f"; cat "$f"; echo; echo "---"; echo; done; else echo "No daily logs found"; fi\`
217
- </recent_logs>
218
-
219
- ## ACTION
220
- 0. **Register:** Call the \`echoes_start_session\` tool immediately to mark this session as started in the status tracker.
221
- 1. **Restore:** Analyze the \`<recent_logs>\` to understand the current trajectory. Briefly summarize where we left off and what our immediate next steps should be today.
222
- 2. **Linting:** Briefly review the \`<index>\`. Do you spot any duplicate concepts, obvious contradictions, or orphan topics that should be merged? If so, propose a quick refactoring plan. If the index is clean, simply say: "Index is healthy. Ready to code."
223
- `
224
-
225
- const ECHOES_END_FALLBACK = `---
226
- description: End the session — save memory to EchoesVault via tool commit_memory_to_echoes_vault
227
- agent: build
228
- ---
229
-
230
- # SYSTEM MESSAGE: Session Distillation (Distill & Save)
231
- Our current session is coming to an end. Your task is to crystallize the knowledge we've gained today and commit it to EchoesVault.
232
-
233
- Adhere to the principle of technical density: we do not need a transcript of our chat. We need dry architectural facts, bug fixes, applied configurations, and explicit decisions. Remember to use \`> [!warning] DEPRECATED\` tags if we rewrote legacy logic today.
234
-
235
- ## ACTION
236
- You MUST invoke the system skill \`commit_memory_to_echoes_vault\`.
237
-
238
- Prepare the following payload for the skill:
239
- * **\`dailySummary\`**: A dense technical summary to WRAP UP the session. Acknowledge that intermediate notes may already exist in today's log. Focus this summary strictly on final outcomes, unresolved blockers, and clear next steps for the next session. This will be appended to the bottom of today's log.
240
- * **\`newPages\`**: If we discussed new global concepts or made architectural decisions, formulate them as separate Markdown articles.
241
- * **\`indexAppends\`**: New lines to append to the end of \`EchoesVault/index.md\` (e.g. \`- [[new-page]]: Description of the concept.\`). The plugin will handle the insertion \u2014 you do not need to reproduce the full index.
242
- * **\`indexUpdates\`**: Array of \`{ oldLine, newLine }\` to find and replace specific lines in place within the index (e.g. deprecation updates).
243
-
244
- Compile these data points and execute the save function immediately!
245
- `
246
-
247
- const ECHOES_STATUS_FALLBACK = `---
248
- description: Report the current health, statistics, and scalability of the EchoesVault
249
- agent: build
250
- ---
251
-
252
- # SYSTEM MESSAGE: Vault Status Report
253
- You are the EchoesVault Keeper. The user has requested a quick, high-level health check of the knowledge base. Do NOT analyze the deep architectural meaning of the files. Your goal is to output a fast, token-efficient metrics dashboard.
254
-
255
- ## \ud83d\udce5 INPUT DATA
256
- Here is the current registry (\`EchoesVault/index.md\`):
257
- <index>
258
- !\`cat EchoesVault/index.md 2>/dev/null || echo "EchoesVault/index.md not found"\`
259
- </index>
260
-
261
- Here is today's daily log if it exists:
262
- <today_log>
263
- !\`cat EchoesVault/daily/$(date +%Y-%m-%d).md 2>/dev/null || echo "No entries yet"\`
264
- </today_log>
265
-
266
- ## \ud83d\ude80 ACTION
267
- Analyze the inputs strictly for quantitative metrics. Provide a highly concise, bulleted dashboard using the exact formatting below.
268
-
269
- **CRITICAL SCALE RULE:**
270
- Count the total number of topics in the index. If the total count is greater than 200, you MUST append the \`> [!warning] SCALE ALERT\` block below your dashboard. If the count is 200 or less, omit the alert block entirely.
271
-
272
- **Expected Output Format:**
273
- \ud83d\udcca **EchoesVault Status**
274
- * **Total Topics:** [Count of files listed in the index]
275
- * **Deprecated Pages:** [Count of files marked as deprecated in the index, if any]
276
- * **Today's Session:** [Active (with X entries) / Not started yet]
277
- * **Index Health:** [Healthy / Warning: mention obvious duplicates or empty descriptions]
278
-
279
- > [!warning] SCALE ALERT
280
- > The vault has exceeded 200 pages. To prevent context window inflation and high token costs during \`/echoes-start\`, consider migrating this knowledge base to a hybrid RAG (Retrieval-Augmented Generation) system.
281
-
282
- Keep your response under 90 words. Output strictly the dashboard (and the conditional alert if triggered). No conversational filler.
283
- `
284
-
285
- const APPEND_TO_DAILY_LOG_FALLBACK = `---
286
- name: echoes_append_to_daily_log
287
- description: Append an intermediate technical note or decision to today's daily log immediately after completing a sub-task.
288
- ---
289
-
290
- # TOOL USAGE: echoes_append_to_daily_log
291
- You are equipped with a scratchpad tool to manage your cognitive load. You MUST use this tool to offload important context into \`EchoesVault/daily/YYYY-MM-DD.md\`.
292
-
293
- ## \ud83c\udfaf EXACT TRIGGER CONDITIONS (WHEN TO CALL THIS TOOL)
294
- Do NOT use this tool randomly. You MUST invoke this tool IMMEDIATELY in the current response if ANY of the following specific events occur:
295
- 1. **Task Completion:** We successfully finish a logical unit of work (e.g., a script works, a bug is verified as fixed, tests pass) BEFORE starting the next user request.
296
- 2. **Context Switch:** The user asks to change focus (e.g., "Now let's work on the frontend" after we just worked on the backend).
297
- 3. **Architectural Agreement:** We just agreed on a core rule, library choice, database schema, or API contract.
298
- 4. **Explicit User Command:** The user explicitly tells you to "take a note", "remember this", "save our progress", or "log this".
299
-
300
- ## \u26a0\ufe0f RULES
301
- 1. **Be Concise:** Write ONLY dry facts and bullet points (e.g., "Refactored AuthGuard to use JWT refresh tokens"). No conversational filler.
302
- 2. **Do Not Interrupt Flow:** Make the tool call silently or add a brief confirmation in your response like: *"Logged the AuthGuard update to the daily vault. Ready for the frontend."*
303
- 3. **No File Overwrites:** This tool ONLY appends to the end of today's file.
304
-
305
- ## \ud83d\udce5 PAYLOAD PARAMETERS
306
- - \`logEntry\`: (String) The markdown-formatted bullet points to append.
307
- `
308
-
309
- const SEARCH_VAULT_PAGES_FALLBACK = `---
310
- name: echoes_search_vault_pages
311
- description: Search the EchoesVault for specific concepts, keywords, or implementation details.
312
- ---
313
-
314
- # TOOL USAGE: echoes_search_vault_pages
315
- You are the EchoesVault Keeper. If you encounter a concept, API, or architectural pattern in our conversation that you suspect is documented but you lack the full context, use this tool BEFORE generating code.
316
-
317
- ## \ud83c\udfaf WHEN TO USE
318
- - The user asks to modify an existing component, but its structure is not in your current context window.
319
- - You need to verify if an Architectural Decision Record (ADR) exists for a specific technology.
320
- - You want to fulfill the "Read-Before-Write" core rule.
321
-
322
- ## \u26a0\ufe0f RULES
323
- 1. **Targeted Queries:** Use specific technical keywords (e.g., "AuthGuard", "esp32 pinout", "database schema") rather than natural language questions.
324
- 2. **Handle Deprecations:** If the search returns a file marked with \`> [!warning] DEPRECATED\`, look for the link to the new relevant file and read that instead.
325
-
326
- ## \ud83d\udce5 PAYLOAD PARAMETERS
327
- - \`query\`: (String) The specific keyword or short phrase to search for across the \`pages/\` directory.
328
- `
329
-
330
- const CREATE_OR_UPDATE_PAGE_FALLBACK = `---
331
- name: echoes_create_or_update_page
332
- description: Atomically create a new markdown page or update an existing one in EchoesVault/pages/, automatically updating the index.
333
- ---
334
-
335
- # TOOL USAGE: echoes_create_or_update_page
336
- Use this tool when a new global concept has been defined or an existing component's architecture has fundamentally changed during our session. This allows you to update the encyclopedia immediately.
337
-
338
- ## \ud83c\udfaf WHEN TO USE
339
- - We finalized a new database schema or API contract.
340
- - A major refactoring occurred, rendering previous documentation inaccurate.
341
- - You need to document a newly integrated library or hardware component.
342
-
343
- ## \u26a0\ufe0f RULES
344
- 1. **Strict YAML Frontmatter:** Every page MUST include a YAML metadata block at the top (type, stack, status).
345
- 2. **Index Sync:** When you create a new file, you must provide a one-sentence description for the index. The system will automatically append it to \`index.md\`.
346
- 3. **Deprecate, Don't Delete:** If you are rewriting an existing page completely because the logic changed, consider if you should instead create a new page (e.g., \`api-v2.md\`) and update the old one with a \`> [!warning] DEPRECATED\` callout via this tool.
347
-
348
- ## \ud83d\udce5 PAYLOAD PARAMETERS
349
- - \`filename\`: (String) The exact filename without paths (e.g., \`auth-architecture.md\`).
350
- - \`content\`: (String) The full markdown content of the page, starting with the YAML frontmatter.
351
- - \`indexDescription\`: (String) A one-sentence description of the file. Required if this is a newly created file. Format: "- [[filename]]: description".
352
- `
353
-
354
154
  const ensureCommands = async (directory: string, commands: Record<string, string>): Promise<void> => {
355
155
  const cmdDir = path.join(directory, ".opencode", "commands")
356
156
  await fs.mkdir(cmdDir, { recursive: true })
@@ -391,22 +191,18 @@ const parseCommandFrontmatter = (cmd: string): { template: string; description?:
391
191
  const OpenCodeEchoes: Plugin = async ({ directory }) => {
392
192
  const pluginDir = path.dirname(new URL(import.meta.url).pathname)
393
193
 
394
- const readPromptFile = async (relativePath: string, fallback: string): Promise<string> => {
395
- try {
396
- return await fs.readFile(path.join(pluginDir, "prompts", relativePath), "utf-8")
397
- } catch {
398
- return fallback
399
- }
194
+ const readPromptFile = async (relativePath: string): Promise<string> => {
195
+ return await fs.readFile(path.join(pluginDir, "prompts", relativePath), "utf-8")
400
196
  }
401
197
 
402
- const ECHOES_INIT = await readPromptFile("commands/echoes-init.md", ECHOES_INIT_FALLBACK)
403
- const ECHOES_START = await readPromptFile("commands/echoes-start.md", ECHOES_START_FALLBACK)
404
- const ECHOES_END = await readPromptFile("commands/echoes-end.md", ECHOES_END_FALLBACK)
405
- const ECHOES_STATUS = await readPromptFile("commands/echoes-status.md", ECHOES_STATUS_FALLBACK)
198
+ const ECHOES_INIT = await readPromptFile("commands/echoes-init.md")
199
+ const ECHOES_START = await readPromptFile("commands/echoes-start.md")
200
+ const ECHOES_END = await readPromptFile("commands/echoes-end.md")
201
+ const ECHOES_STATUS = await readPromptFile("commands/echoes-status.md")
406
202
 
407
- const APPEND_TO_DAILY_LOG = await readPromptFile("skills/echoes-append-to-daily-log.md", APPEND_TO_DAILY_LOG_FALLBACK)
408
- const SEARCH_VAULT_PAGES = await readPromptFile("skills/echoes-search-vault-pages.md", SEARCH_VAULT_PAGES_FALLBACK)
409
- const CREATE_OR_UPDATE_PAGE = await readPromptFile("skills/echoes-create-or-update-page.md", CREATE_OR_UPDATE_PAGE_FALLBACK)
203
+ const APPEND_TO_DAILY_LOG = await readPromptFile("skills/echoes-append-to-daily-log.md")
204
+ const SEARCH_VAULT_PAGES = await readPromptFile("skills/echoes-search-vault-pages.md")
205
+ const CREATE_OR_UPDATE_PAGE = await readPromptFile("skills/echoes-create-or-update-page.md")
410
206
 
411
207
  const commands: Record<string, string> = {
412
208
  "echoes-init.md": ECHOES_INIT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoes-vault-opencode",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "EchoesVault — persistent memory plugin for OpenCode. Obsidian-style knowledge base with daily logs, encyclopedia pages, and session resumption.",
5
5
  "type": "module",
6
6
  "main": "index.ts",