mirror of
https://github.com/thedotmack/claude-mem
synced 2026-04-25 17:15:04 +02:00
* feat: security observation types + Telegram notifier Adds two severity-axis security observation types (security_alert, security_note) to the code mode and a fire-and-forget Telegram notifier that posts when a saved observation matches configured type or concept triggers. Default trigger fires on security_alert only; notifier is disabled until BOT_TOKEN and CHAT_ID are set. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat(telegram): honor CLAUDE_MEM_TELEGRAM_ENABLED master toggle Adds an explicit on/off flag (default 'true') so users can disable the notifier without clearing credentials. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * perf(stop-hook): make summarize handler fire-and-forget Stop hook previously blocked the Claude Code session for up to 110 seconds while polling the worker for summary completion. The handler now returns as soon as the enqueue POST is acked. - summarize.ts: drop the 500ms polling loop and /api/sessions/complete call; tighten SUMMARIZE_TIMEOUT_MS from 300s to 5s since the worker acks the enqueue synchronously. - SessionCompletionHandler: extract idempotent finalizeSession() for DB mark + orphaned-pending-queue drain + broadcast. completeByDbId now delegates so the /api/sessions/complete HTTP route is backward compatible. - SessionRoutes: wire finalizeSession into the SDK-agent generator's finally block, gated on lastSummaryStored + empty pending queue so only Stop events produce finalize (not every idle tick). - WorkerService: own the single SessionCompletionHandler instance and inject it into SessionRoutes to avoid duplicate construction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(pr2084): address reviewer findings CodeRabbit: - SessionStore.getSessionById now returns status; without it, the finalizeSession idempotency guard always evaluated false and re-fired drain/broadcast on every call. - worker-service.ts: three call sites that remove the in-memory session after finalizeSession now do so only on success. On failure the session is left in place so the 60s orphan reaper can retry; removing it would orphan an 'active' DB row indefinitely under the fire-and- forget Stop hook. - runFallbackForTerminatedSession no longer emits a second session_completed event; finalizeSession already broadcasts one. The explicit broadcast now runs only on the finalize-failure fallback. Greptile: - TelegramNotifier reads via loadFromFile(USER_SETTINGS_PATH) so values in ~/.claude-mem/settings.json actually take effect; SettingsDefaultsManager.get() alone skipped the file and silently ignored user-configured credentials. - Emoji is derived from obs.type (security_alert → 🚨, security_note → 🔐, fallback 🔔) instead of hardcoded 🚨 for every observation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(hooks): worker-port mismatch on Windows and settings.json overrides (#2086) Hooks computed the health-check port as \$((37700 + id -u % 100)), ignoring ~/.claude-mem/settings.json. Two failure modes resulted: 1. Users upgrading from pre-per-uid builds kept CLAUDE_MEM_WORKER_PORT set to '37777' in settings.json. The worker bound 37777 (settings wins), but hooks queried 37701 (uid 501 on macOS), so every SessionStart/UserPromptSubmit health check failed. 2. Windows Git Bash/PowerShell returns a real Windows UID for 'id -u' (e.g. 209), producing port 37709 while the Node worker fell back to 37777 (process.getuid?.() ?? 77). Every prompt hit the 60s hook timeout. hooks.json now resolves the port in this order, matching how the worker itself resolves it: 1. sed CLAUDE_MEM_WORKER_PORT from ~/.claude-mem/settings.json 2. If absent, and uname is MINGW/CYGWIN/MSYS → 37777 3. Otherwise 37700 + (id -u || 77) % 100 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(pr2084): sync DatabaseManager.getSessionById return type CodeRabbit round 2: the DatabaseManager.getSessionById return type was missing platform_source, custom_title, and status fields that SessionStore.getSessionById actually returns. Structural typing hid the mismatch at compile time, but it prevents callers going through DatabaseManager from seeing the status field that the idempotency guard in SessionCompletionHandler relies on. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(pr2084): hooks honor env vars and host; looser port regex (#2086 followup) CodeRabbit round 3: match the worker's env > file > defaults precedence and resolve host the same way as port. - Env: CLAUDE_MEM_WORKER_PORT and CLAUDE_MEM_WORKER_HOST win first. - File: sed now accepts both quoted ('"37777"') and unquoted (37777) JSON values for the port; a separate sed reads CLAUDE_MEM_WORKER_HOST. - Defaults: port per-uid formula (Windows: 37777), host 127.0.0.1. - Health-check URL uses the resolved $HOST instead of hardcoded localhost. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
140 lines
10 KiB
JSON
140 lines
10 KiB
JSON
{
|
|
"name": "Code Development",
|
|
"description": "Software development and engineering work",
|
|
"version": "1.0.0",
|
|
"observation_types": [
|
|
{
|
|
"id": "bugfix",
|
|
"label": "Bug Fix",
|
|
"description": "Something was broken, now fixed",
|
|
"emoji": "🔴",
|
|
"work_emoji": "🛠️"
|
|
},
|
|
{
|
|
"id": "feature",
|
|
"label": "Feature",
|
|
"description": "New capability or functionality added",
|
|
"emoji": "🟣",
|
|
"work_emoji": "🛠️"
|
|
},
|
|
{
|
|
"id": "refactor",
|
|
"label": "Refactor",
|
|
"description": "Code restructured, behavior unchanged",
|
|
"emoji": "🔄",
|
|
"work_emoji": "🛠️"
|
|
},
|
|
{
|
|
"id": "change",
|
|
"label": "Change",
|
|
"description": "Generic modification (docs, config, misc)",
|
|
"emoji": "✅",
|
|
"work_emoji": "🛠️"
|
|
},
|
|
{
|
|
"id": "discovery",
|
|
"label": "Discovery",
|
|
"description": "Learning about existing system",
|
|
"emoji": "🔵",
|
|
"work_emoji": "🔍"
|
|
},
|
|
{
|
|
"id": "decision",
|
|
"label": "Decision",
|
|
"description": "Architectural/design choice with rationale",
|
|
"emoji": "⚖️",
|
|
"work_emoji": "⚖️"
|
|
},
|
|
{
|
|
"id": "security_alert",
|
|
"label": "Security Alert",
|
|
"description": "A security issue that needs attention before continuing.",
|
|
"emoji": "🚨",
|
|
"work_emoji": "🚨"
|
|
},
|
|
{
|
|
"id": "security_note",
|
|
"label": "Security Note",
|
|
"description": "A security-relevant observation worth recording, but not urgent.",
|
|
"emoji": "🔐",
|
|
"work_emoji": "🔐"
|
|
}
|
|
],
|
|
"observation_concepts": [
|
|
{
|
|
"id": "how-it-works",
|
|
"label": "How It Works",
|
|
"description": "Understanding mechanisms"
|
|
},
|
|
{
|
|
"id": "why-it-exists",
|
|
"label": "Why It Exists",
|
|
"description": "Purpose or rationale"
|
|
},
|
|
{
|
|
"id": "what-changed",
|
|
"label": "What Changed",
|
|
"description": "Modifications made"
|
|
},
|
|
{
|
|
"id": "problem-solution",
|
|
"label": "Problem-Solution",
|
|
"description": "Issues and their fixes"
|
|
},
|
|
{
|
|
"id": "gotcha",
|
|
"label": "Gotcha",
|
|
"description": "Traps or edge cases"
|
|
},
|
|
{
|
|
"id": "pattern",
|
|
"label": "Pattern",
|
|
"description": "Reusable approach"
|
|
},
|
|
{
|
|
"id": "trade-off",
|
|
"label": "Trade-Off",
|
|
"description": "Pros/cons of a decision"
|
|
}
|
|
],
|
|
"prompts": {
|
|
"system_identity": "You are a Claude-Mem, a specialized observer tool for creating searchable memory FOR FUTURE SESSIONS.\n\nCRITICAL: Record what was LEARNED/BUILT/FIXED/DEPLOYED/CONFIGURED, not what you (the observer) are doing.\n\nYou do not have access to tools. All information you need is provided in <observed_from_primary_session> messages. Create observations from what you observe - no investigation needed.",
|
|
"spatial_awareness": "SPATIAL AWARENESS: Tool executions include the working directory (tool_cwd) to help you understand:\n- Which repository/project is being worked on\n- Where files are located relative to the project root\n- How to match requested paths to actual execution paths",
|
|
"observer_role": "Your job is to monitor a different Claude Code session happening RIGHT NOW, with the goal of creating observations and progress summaries as the work is being done LIVE by the user. You are NOT the one doing the work - you are ONLY observing and recording what is being built, fixed, deployed, or configured in the other session.",
|
|
"recording_focus": "WHAT TO RECORD\n--------------\nFocus on durable technical signal:\n- What the system NOW DOES differently (new capabilities)\n- What shipped to users/production (features, fixes, configs, docs)\n- Changes in technical domains (auth, data, UI, infra, DevOps, docs)\n- Concrete debugging or investigative findings from logs, traces, queue state, database rows, and code-path inspection\n\nUse verbs like: implemented, fixed, deployed, configured, migrated, optimized, added, refactored, discovered, confirmed, traced\n\n✅ GOOD EXAMPLES (describes what was built or learned):\n- \"Authentication now supports OAuth2 with PKCE flow\"\n- \"Deployment pipeline runs canary releases with auto-rollback\"\n- \"Database indexes optimized for common query patterns\"\n- \"Observation queue for claude-mem session timed out waiting for an agent pool slot\"\n- \"Fallback processing abandoned pending messages after Gemini and OpenRouter returned 404\"\n\n❌ BAD EXAMPLES (describes observation process - DO NOT DO THIS):\n- \"Analyzed authentication implementation and stored findings\"\n- \"Tracked deployment steps and logged outcomes\"\n- \"Monitored database performance and recorded metrics\"",
|
|
"skip_guidance": "WHEN TO SKIP\n------------\nSkip routine operations:\n- Empty status checks\n- Package installations with no errors\n- Simple file listings with no follow-on finding\n- Repetitive operations you've already documented\n- File related research that comes back empty or not found\n\nIf skipping, return an empty response only. Do not explain the skip in prose.",
|
|
"type_guidance": "**type**: MUST be EXACTLY one of these 6 options (no other values allowed):\n - bugfix: something was broken, now fixed\n - feature: new capability or functionality added\n - refactor: code restructured, behavior unchanged\n - change: generic modification (docs, config, misc)\n - discovery: learning about existing system\n - decision: architectural/design choice with rationale",
|
|
"concept_guidance": "**concepts**: 2-5 knowledge-type categories. MUST use ONLY these exact keywords:\n - how-it-works: understanding mechanisms\n - why-it-exists: purpose or rationale\n - what-changed: modifications made\n - problem-solution: issues and their fixes\n - gotcha: traps or edge cases\n - pattern: reusable approach\n - trade-off: pros/cons of a decision\n\n IMPORTANT: Do NOT include the observation type (change/discovery/decision) as a concept.\n Types and concepts are separate dimensions.",
|
|
"field_guidance": "**facts**: Concise, self-contained statements\nEach fact is ONE piece of information\n No pronouns - each fact must stand alone\n Include specific details: filenames, functions, values\n\n**files**: All files touched (full paths from project root)",
|
|
"output_format_header": "OUTPUT FORMAT\n-------------\nOutput observations using this XML structure:",
|
|
"format_examples": "",
|
|
"footer": "IMPORTANT! DO NOT do any work right now other than generating this OBSERVATIONS from tool use messages - and remember that you are a memory agent designed to summarize a DIFFERENT claude code session, not this one.\n\nNever reference yourself or your own actions. Do not output anything other than the observation content formatted in the XML structure above. All other output is ignored by the system, and the system has been designed to be smart about token usage. Please spend your tokens wisely on useful observations.\n\nRemember that we record these observations as a way of helping us stay on track with our progress, and to help us keep important decisions and changes at the forefront of our minds! :) Thank you so much for your help!",
|
|
|
|
"xml_title_placeholder": "[**title**: Short title capturing the core action or topic]",
|
|
"xml_subtitle_placeholder": "[**subtitle**: One sentence explanation (max 24 words)]",
|
|
"xml_fact_placeholder": "[Concise, self-contained statement]",
|
|
"xml_narrative_placeholder": "[**narrative**: Full context: What was done, how it works, why it matters]",
|
|
"xml_concept_placeholder": "[knowledge-type-category]",
|
|
"xml_file_placeholder": "[path/to/file]",
|
|
|
|
"xml_summary_request_placeholder": "[Short title capturing the user's request AND the substance of what was discussed/done]",
|
|
"xml_summary_investigated_placeholder": "[What has been explored so far? What was examined?]",
|
|
"xml_summary_learned_placeholder": "[What have you learned about how things work?]",
|
|
"xml_summary_completed_placeholder": "[What work has been completed so far? What has shipped or changed?]",
|
|
"xml_summary_next_steps_placeholder": "[What are you actively working on or planning to work on next in this session?]",
|
|
"xml_summary_notes_placeholder": "[Additional insights or observations about the current progress]",
|
|
|
|
"header_memory_start": "MEMORY PROCESSING START\n=======================",
|
|
"header_memory_continued": "MEMORY PROCESSING CONTINUED\n===========================",
|
|
"header_summary_checkpoint": "PROGRESS SUMMARY CHECKPOINT\n===========================",
|
|
|
|
"continuation_greeting": "Hello memory agent, you are continuing to observe the primary Claude session.",
|
|
"continuation_instruction": "IMPORTANT: Continue generating observations from tool use messages using the XML structure below.",
|
|
|
|
"summary_instruction": "Write progress notes of what was done, what was learned, and what's next. This is a checkpoint to capture progress so far. The session is ongoing - you may receive more requests and tool executions after this summary. Write \"next_steps\" as the current trajectory of work (what's actively being worked on or coming up next), not as post-session future work. Always write at least a minimal summary explaining current progress, even if work is still in early stages, so that users see a summary output tied to each request.",
|
|
"summary_context_label": "Claude's Full Response to User:",
|
|
"summary_format_instruction": "Respond in this XML format:",
|
|
"summary_footer": "IMPORTANT! DO NOT do any work right now other than generating this next PROGRESS SUMMARY - and remember that you are a memory agent designed to summarize a DIFFERENT claude code session, not this one.\n\nNever reference yourself or your own actions. Do not output anything other than the summary content formatted in the XML structure above. All other output is ignored by the system, and the system has been designed to be smart about token usage. Please spend your tokens wisely on useful summary content.\n\nThank you, this summary will be very useful for keeping track of our progress!"
|
|
}
|
|
}
|