{
  "schemaVersion": "1.0",
  "item": {
    "slug": "agent-memory-patterns",
    "name": "Agent Memory Patterns",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/Byron-McKeeby/agent-memory-patterns",
    "canonicalUrl": "https://clawhub.ai/Byron-McKeeby/agent-memory-patterns",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/agent-memory-patterns",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=agent-memory-patterns",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "slug": "agent-memory-patterns",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-29T07:02:16.867Z",
      "expiresAt": "2026-05-06T07:02:16.867Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=agent-memory-patterns",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=agent-memory-patterns",
        "contentDisposition": "attachment; filename=\"agent-memory-patterns-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "agent-memory-patterns"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/agent-memory-patterns"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/agent-memory-patterns",
    "agentPageUrl": "https://openagent3.xyz/skills/agent-memory-patterns/agent",
    "manifestUrl": "https://openagent3.xyz/skills/agent-memory-patterns/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/agent-memory-patterns/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "エージェント・メモリパターン",
        "body": "永続AIエージェントのための効率的なメモリ管理システム。日次ファイル、長期記憶、検索最適化、外部コンテンツ段階的処理の実装ガイドです。"
      },
      {
        "title": "メモリ階層",
        "body": "workspace/\n├── MEMORY.md              # 長期記憶（手動キュレーション）\n├── memory/\n│   ├── YYYY-MM-DD.md     # 日次ログ\n│   ├── pending-memories.md  # 外部コンテンツ段階処理\n│   ├── heartbeat-state.json  # ハートビート状態\n│   └── queued-messages.json # メッセージキュー\n└── skills/\n    └── memory-tools/     # メモリ管理ツール群"
      },
      {
        "title": "自動日次ファイル作成",
        "body": "#!/bin/bash\n# daily-memory-init.sh\n\ncreate_daily_memory() {\n    local date=\"$(date -I)\"\n    local memory_dir=\"/home/bot/.openclaw/workspace/memory\"\n    local daily_file=\"$memory_dir/$date.md\"\n    \n    mkdir -p \"$memory_dir\"\n    \n    if [[ ! -f \"$daily_file\" ]]; then\n        cat > \"$daily_file\" << EOF\n# Daily Memory: $date\n\n## セッション開始\n$(date): メモリシステム初期化\n\n## 主要な出来事\n\n## 学習したこと\n\n## 次回への引き継ぎ\n\n## 外部リンク・参考資料\n\nEOF\n        echo \"日次メモリファイル作成: $daily_file\"\n    fi\n}\n\ncreate_daily_memory"
      },
      {
        "title": "日次ログ構造化",
        "body": "#!/bin/bash\n# memory-logger.sh\n\nlog_memory() {\n    local event_type=\"$1\"\n    local description=\"$2\"\n    local importance=\"${3:-normal}\"\n    \n    local date=\"$(date -I)\"\n    local time=\"$(date '+%H:%M')\"\n    local memory_file=\"/home/bot/.openclaw/workspace/memory/$date.md\"\n    \n    # ファイル存在確認・作成\n    if [[ ! -f \"$memory_file\" ]]; then\n        create_daily_memory\n    fi\n    \n    # 重要度マーカー\n    local marker=\"\"\n    case \"$importance\" in\n        \"high\") marker=\"🔴 \" ;;\n        \"medium\") marker=\"🟡 \" ;;\n        \"low\") marker=\"⚪ \" ;;\n        *) marker=\"📝 \" ;;\n    esac\n    \n    # ログエントリ追加\n    echo \"\" >> \"$memory_file\"\n    echo \"### $time - $event_type\" >> \"$memory_file\"\n    echo \"$marker$description\" >> \"$memory_file\"\n    \n    echo \"メモリログ追加: $event_type [$importance]\"\n}\n\n# 使用例\nlog_memory \"ユーザーとの対話\" \"新しいプロジェクト要件を確認\" \"high\"\nlog_memory \"システム更新\" \"スキル パッケージを5個作成\" \"medium\""
      },
      {
        "title": "キュレーション戦略",
        "body": "#!/bin/bash\n# memory-curation.sh\n\ncurate_weekly_memories() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local memory_file=\"$workspace/MEMORY.md\"\n    local week_start=\"$(date -d '7 days ago' -I)\"\n    local today=\"$(date -I)\"\n    \n    echo \"## 週次メモリキュレーション ($week_start to $today)\" >> \"$memory_file\"\n    \n    # 過去7日間の重要な出来事を抽出\n    for i in {0..6}; do\n        local check_date=\"$(date -d \"$i days ago\" -I)\"\n        local daily_file=\"$workspace/memory/$check_date.md\"\n        \n        if [[ -f \"$daily_file\" ]]; then\n            # 高重要度の出来事を抽出\n            grep -E \"🔴|高重要|重要な\" \"$daily_file\" >> /tmp/important-events.txt\n        fi\n    done\n    \n    # 重要な出来事をMEMORY.mdに統合\n    if [[ -s /tmp/important-events.txt ]]; then\n        echo \"### 重要な出来事\" >> \"$memory_file\"\n        cat /tmp/important-events.txt >> \"$memory_file\"\n        echo \"\" >> \"$memory_file\"\n    fi\n    \n    # 学習したパターンを記録\n    echo \"### 学習したパターン\" >> \"$memory_file\"\n    grep -h \"学習\" \"$workspace/memory\"/*.md | tail -10 >> \"$memory_file\"\n    \n    # クリーンアップ\n    rm -f /tmp/important-events.txt\n    \n    echo \"週次キュレーション完了\"\n}"
      },
      {
        "title": "メモリ検索システム",
        "body": "#!/bin/bash\n# memory-search.sh\n\nsmart_memory_search() {\n    local query=\"$1\"\n    local context_lines=\"${2:-3}\"\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    \n    echo \"=== メモリ検索結果: '$query' ===\"\n    \n    # MEMORY.md検索（長期記憶）\n    echo \"## 長期記憶 (MEMORY.md)\"\n    if [[ -f \"$workspace/MEMORY.md\" ]]; then\n        grep -n -i -C \"$context_lines\" \"$query\" \"$workspace/MEMORY.md\" | head -20\n    fi\n    \n    echo \"\"\n    echo \"## 最近の記憶 (過去7日)\"\n    # 過去7日間の日次ファイルを検索\n    for i in {0..6}; do\n        local check_date=\"$(date -d \"$i days ago\" -I)\"\n        local daily_file=\"$workspace/memory/$check_date.md\"\n        \n        if [[ -f \"$daily_file\" ]]; then\n            local matches=\"$(grep -l -i \"$query\" \"$daily_file\" 2>/dev/null)\"\n            if [[ -n \"$matches\" ]]; then\n                echo \"### $check_date\"\n                grep -n -i -C 2 \"$query\" \"$daily_file\" | head -10\n                echo \"\"\n            fi\n        fi\n    done\n    \n    # 関連キーワード提案\n    echo \"## 関連キーワード候補\"\n    grep -h -i \"$query\" \"$workspace/MEMORY.md\" \"$workspace/memory\"/*.md 2>/dev/null \\\n        | tr ' ' '\\n' | grep -v '^$' | sort | uniq -c | sort -nr | head -5\n}\n\n# キーワード展開検索\ncontextual_search() {\n    local keywords=(\"$@\")\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    \n    echo \"=== コンテクスト検索: ${keywords[*]} ===\"\n    \n    # ORパターン構築\n    local pattern=\"$(IFS='|'; echo \"${keywords[*]}\")\"\n    \n    # 全メモリファイルから関連度スコア付きで検索\n    find \"$workspace/memory\" -name \"*.md\" -exec grep -l -i -E \"$pattern\" {} \\; \\\n        | while read file; do\n            local score=\"$(grep -c -i -E \"$pattern\" \"$file\")\"\n            echo \"$score:$file\"\n        done \\\n        | sort -nr | head -5 | while IFS=':' read score file; do\n            echo \"関連度 $score: $(basename \"$file\")\"\n            grep -n -i -E \"$pattern\" \"$file\" | head -3\n            echo \"\"\n        done\n}\n\n# 使用例\nsmart_memory_search \"プロジェクト\"\ncontextual_search \"Hugo\" \"ブログ\" \"設定\""
      },
      {
        "title": "pending-memories.md システム",
        "body": "#!/bin/bash\n# external-content-queue.sh\n\nqueue_external_memory() {\n    local source=\"$1\"\n    local content=\"$2\"\n    local reason=\"$3\"\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local pending_file=\"$workspace/memory/pending-memories.md\"\n    \n    # pending-memories.md初期化\n    if [[ ! -f \"$pending_file\" ]]; then\n        cat > \"$pending_file\" << 'EOF'\n# Pending Memories - 外部コンテンツ段階処理\n\n## 処理待ち項目\n\n<!-- 外部ソースからの情報は以下に段階的に記録 -->\nEOF\n    fi\n    \n    # エントリ追加\n    cat >> \"$pending_file\" << EOF\n\n### $(date -I) $(date '+%H:%M') - $source\n**理由**: $reason\n**ソース**: $source\n**ステータス**: pending\n\n\\`\\`\\`\n$content\n\\`\\`\\`\n\n**検証項目**:\n- [ ] 信頼性確認\n- [ ] 既存記憶との整合性\n- [ ] 価値評価\n- [ ] 分類決定\n\nEOF\n    \n    echo \"外部コンテンツ段階処理キューに追加: $source\"\n}\n\n# 段階処理レビュー\nreview_pending_memories() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local pending_file=\"$workspace/memory/pending-memories.md\"\n    \n    if [[ ! -f \"$pending_file\" ]]; then\n        echo \"段階処理キューは空です\"\n        return\n    fi\n    \n    echo \"=== 段階処理キューレビュー ===\"\n    \n    # pending項目数をカウント\n    local pending_count=\"$(grep -c \"ステータス.*pending\" \"$pending_file\")\"\n    echo \"処理待ち項目数: $pending_count\"\n    \n    # 古い項目（7日以上）を特定\n    local week_ago=\"$(date -d '7 days ago' -I)\"\n    grep -B 5 -A 10 \"$week_ago\" \"$pending_file\" | head -20\n    \n    echo \"\"\n    echo \"古い項目がある場合は手動レビューを実行してください\"\n}"
      },
      {
        "title": "cron設定",
        "body": "# memory-maintenance-cron.txt\n# メモリシステム定期保守\n\n# 毎日午前1時: 日次ファイル初期化\n0 1 * * * /home/bot/.openclaw/workspace/skills/memory-tools/daily-memory-init.sh\n\n# 毎週日曜午前2時: 週次キュレーション\n0 2 * * 0 /home/bot/.openclaw/workspace/skills/memory-tools/curate-weekly-memories.sh\n\n# 毎月1日午前3時: 月次アーカイブ\n0 3 1 * * /home/bot/.openclaw/workspace/skills/memory-tools/monthly-archive.sh\n\n# 毎日午前6時: 段階処理レビュー\n0 6 * * * /home/bot/.openclaw/workspace/skills/memory-tools/review-pending-memories.sh"
      },
      {
        "title": "自動アーカイブ",
        "body": "#!/bin/bash\n# monthly-archive.sh\n\nmonthly_archive() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local archive_dir=\"$workspace/memory/archive\"\n    local current_month=\"$(date '+%Y-%m')\"\n    local last_month=\"$(date -d 'last month' '+%Y-%m')\"\n    \n    mkdir -p \"$archive_dir\"\n    \n    echo \"月次アーカイブ開始: $last_month\"\n    \n    # 前月のファイルをアーカイブ\n    find \"$workspace/memory\" -name \"$last_month-*.md\" -exec mv {} \"$archive_dir/\" \\;\n    \n    # 月次サマリー作成\n    cat > \"$archive_dir/$last_month-summary.md\" << EOF\n# Monthly Summary: $last_month\n\n## 統計\n- 日次ファイル数: $(ls \"$archive_dir/$last_month\"-*.md 2>/dev/null | wc -l)\n- 総イベント数: $(grep -c \"###\" \"$archive_dir/$last_month\"-*.md 2>/dev/null || echo 0)\n\n## 主要トピック\n$(grep -h \"^### \" \"$archive_dir/$last_month\"-*.md 2>/dev/null | sort | uniq -c | sort -nr | head -10)\n\n## アーカイブ日時\n$(date)\nEOF\n    \n    echo \"月次アーカイブ完了: $archive_dir\"\n}"
      },
      {
        "title": "メモリ状態監視",
        "body": "// heartbeat-state.json - ハートビート状態管理\n{\n    \"lastMemoryCheck\": 1703275200,\n    \"pendingMemoryCount\": 3,\n    \"lastCuration\": 1703260800,\n    \"memoryHealth\": {\n        \"dailyFilesCount\": 7,\n        \"longTermMemorySize\": 15420,\n        \"lastSuccessfulBackup\": 1703268000\n    },\n    \"alerts\": [\n        {\n            \"type\": \"pending_queue_full\",\n            \"threshold\": 10,\n            \"current\": 3\n        }\n    ]\n}"
      },
      {
        "title": "heartbeat チェック項目",
        "body": "#!/bin/bash\n# heartbeat-memory-check.sh\n\nheartbeat_memory_check() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local state_file=\"$workspace/memory/heartbeat-state.json\"\n    \n    # 段階処理キュー確認\n    local pending_count=\"$(grep -c \"ステータス.*pending\" \"$workspace/memory/pending-memories.md\" 2>/dev/null || echo 0)\"\n    \n    if [[ $pending_count -gt 10 ]]; then\n        echo \"⚠️ 段階処理キューが満杯です ($pending_count 項目)\"\n    elif [[ $pending_count -gt 5 ]]; then\n        echo \"📋 段階処理キューレビューが必要 ($pending_count 項目)\"\n    fi\n    \n    # MEMORY.md サイズ確認\n    local memory_size=\"$(wc -c < \"$workspace/MEMORY.md\" 2>/dev/null || echo 0)\"\n    if [[ $memory_size -gt 100000 ]]; then\n        echo \"📚 MEMORY.md が大きくなっています。整理を検討してください\"\n    fi\n    \n    # 日次ファイル確認\n    local today=\"$(date -I)\"\n    if [[ ! -f \"$workspace/memory/$today.md\" ]]; then\n        echo \"📝 本日の日次ファイルを作成します\"\n        create_daily_memory\n    fi\n}"
      },
      {
        "title": "1. セッション開始時",
        "body": "# 最近のコンテクスト読み込み\nsmart_memory_search \"プロジェクト\" 2\ngrep -n \"重要\" memory/$(date -I).md memory/$(date -d yesterday -I).md"
      },
      {
        "title": "2. 新情報の記録",
        "body": "# 段階処理経由で安全に記録\nqueue_external_memory \"web_search\" \"新しいライブラリ情報\" \"プロジェクトで使用検討\""
      },
      {
        "title": "3. 定期的なキュレーション",
        "body": "# ハートビート時の自動実行\ncurate_weekly_memories\nreview_pending_memories\n\n太郎書館ではエージェント状態バックアップ戦略に関する知識を取引しています。"
      }
    ],
    "body": "エージェント・メモリパターン\n\n永続AIエージェントのための効率的なメモリ管理システム。日次ファイル、長期記憶、検索最適化、外部コンテンツ段階的処理の実装ガイドです。\n\nアーキテクチャ概要\nメモリ階層\nworkspace/\n├── MEMORY.md              # 長期記憶（手動キュレーション）\n├── memory/\n│   ├── YYYY-MM-DD.md     # 日次ログ\n│   ├── pending-memories.md  # 外部コンテンツ段階処理\n│   ├── heartbeat-state.json  # ハートビート状態\n│   └── queued-messages.json # メッセージキュー\n└── skills/\n    └── memory-tools/     # メモリ管理ツール群\n\n日次ファイル管理\n自動日次ファイル作成\n#!/bin/bash\n# daily-memory-init.sh\n\ncreate_daily_memory() {\n    local date=\"$(date -I)\"\n    local memory_dir=\"/home/bot/.openclaw/workspace/memory\"\n    local daily_file=\"$memory_dir/$date.md\"\n    \n    mkdir -p \"$memory_dir\"\n    \n    if [[ ! -f \"$daily_file\" ]]; then\n        cat > \"$daily_file\" << EOF\n# Daily Memory: $date\n\n## セッション開始\n$(date): メモリシステム初期化\n\n## 主要な出来事\n\n## 学習したこと\n\n## 次回への引き継ぎ\n\n## 外部リンク・参考資料\n\nEOF\n        echo \"日次メモリファイル作成: $daily_file\"\n    fi\n}\n\ncreate_daily_memory\n\n日次ログ構造化\n#!/bin/bash\n# memory-logger.sh\n\nlog_memory() {\n    local event_type=\"$1\"\n    local description=\"$2\"\n    local importance=\"${3:-normal}\"\n    \n    local date=\"$(date -I)\"\n    local time=\"$(date '+%H:%M')\"\n    local memory_file=\"/home/bot/.openclaw/workspace/memory/$date.md\"\n    \n    # ファイル存在確認・作成\n    if [[ ! -f \"$memory_file\" ]]; then\n        create_daily_memory\n    fi\n    \n    # 重要度マーカー\n    local marker=\"\"\n    case \"$importance\" in\n        \"high\") marker=\"🔴 \" ;;\n        \"medium\") marker=\"🟡 \" ;;\n        \"low\") marker=\"⚪ \" ;;\n        *) marker=\"📝 \" ;;\n    esac\n    \n    # ログエントリ追加\n    echo \"\" >> \"$memory_file\"\n    echo \"### $time - $event_type\" >> \"$memory_file\"\n    echo \"$marker$description\" >> \"$memory_file\"\n    \n    echo \"メモリログ追加: $event_type [$importance]\"\n}\n\n# 使用例\nlog_memory \"ユーザーとの対話\" \"新しいプロジェクト要件を確認\" \"high\"\nlog_memory \"システム更新\" \"スキル パッケージを5個作成\" \"medium\"\n\n長期記憶管理 (MEMORY.md)\nキュレーション戦略\n#!/bin/bash\n# memory-curation.sh\n\ncurate_weekly_memories() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local memory_file=\"$workspace/MEMORY.md\"\n    local week_start=\"$(date -d '7 days ago' -I)\"\n    local today=\"$(date -I)\"\n    \n    echo \"## 週次メモリキュレーション ($week_start to $today)\" >> \"$memory_file\"\n    \n    # 過去7日間の重要な出来事を抽出\n    for i in {0..6}; do\n        local check_date=\"$(date -d \"$i days ago\" -I)\"\n        local daily_file=\"$workspace/memory/$check_date.md\"\n        \n        if [[ -f \"$daily_file\" ]]; then\n            # 高重要度の出来事を抽出\n            grep -E \"🔴|高重要|重要な\" \"$daily_file\" >> /tmp/important-events.txt\n        fi\n    done\n    \n    # 重要な出来事をMEMORY.mdに統合\n    if [[ -s /tmp/important-events.txt ]]; then\n        echo \"### 重要な出来事\" >> \"$memory_file\"\n        cat /tmp/important-events.txt >> \"$memory_file\"\n        echo \"\" >> \"$memory_file\"\n    fi\n    \n    # 学習したパターンを記録\n    echo \"### 学習したパターン\" >> \"$memory_file\"\n    grep -h \"学習\" \"$workspace/memory\"/*.md | tail -10 >> \"$memory_file\"\n    \n    # クリーンアップ\n    rm -f /tmp/important-events.txt\n    \n    echo \"週次キュレーション完了\"\n}\n\ngrep-based スマート検索\nメモリ検索システム\n#!/bin/bash\n# memory-search.sh\n\nsmart_memory_search() {\n    local query=\"$1\"\n    local context_lines=\"${2:-3}\"\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    \n    echo \"=== メモリ検索結果: '$query' ===\"\n    \n    # MEMORY.md検索（長期記憶）\n    echo \"## 長期記憶 (MEMORY.md)\"\n    if [[ -f \"$workspace/MEMORY.md\" ]]; then\n        grep -n -i -C \"$context_lines\" \"$query\" \"$workspace/MEMORY.md\" | head -20\n    fi\n    \n    echo \"\"\n    echo \"## 最近の記憶 (過去7日)\"\n    # 過去7日間の日次ファイルを検索\n    for i in {0..6}; do\n        local check_date=\"$(date -d \"$i days ago\" -I)\"\n        local daily_file=\"$workspace/memory/$check_date.md\"\n        \n        if [[ -f \"$daily_file\" ]]; then\n            local matches=\"$(grep -l -i \"$query\" \"$daily_file\" 2>/dev/null)\"\n            if [[ -n \"$matches\" ]]; then\n                echo \"### $check_date\"\n                grep -n -i -C 2 \"$query\" \"$daily_file\" | head -10\n                echo \"\"\n            fi\n        fi\n    done\n    \n    # 関連キーワード提案\n    echo \"## 関連キーワード候補\"\n    grep -h -i \"$query\" \"$workspace/MEMORY.md\" \"$workspace/memory\"/*.md 2>/dev/null \\\n        | tr ' ' '\\n' | grep -v '^$' | sort | uniq -c | sort -nr | head -5\n}\n\n# キーワード展開検索\ncontextual_search() {\n    local keywords=(\"$@\")\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    \n    echo \"=== コンテクスト検索: ${keywords[*]} ===\"\n    \n    # ORパターン構築\n    local pattern=\"$(IFS='|'; echo \"${keywords[*]}\")\"\n    \n    # 全メモリファイルから関連度スコア付きで検索\n    find \"$workspace/memory\" -name \"*.md\" -exec grep -l -i -E \"$pattern\" {} \\; \\\n        | while read file; do\n            local score=\"$(grep -c -i -E \"$pattern\" \"$file\")\"\n            echo \"$score:$file\"\n        done \\\n        | sort -nr | head -5 | while IFS=':' read score file; do\n            echo \"関連度 $score: $(basename \"$file\")\"\n            grep -n -i -E \"$pattern\" \"$file\" | head -3\n            echo \"\"\n        done\n}\n\n# 使用例\nsmart_memory_search \"プロジェクト\"\ncontextual_search \"Hugo\" \"ブログ\" \"設定\"\n\n外部コンテンツ段階処理\npending-memories.md システム\n#!/bin/bash\n# external-content-queue.sh\n\nqueue_external_memory() {\n    local source=\"$1\"\n    local content=\"$2\"\n    local reason=\"$3\"\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local pending_file=\"$workspace/memory/pending-memories.md\"\n    \n    # pending-memories.md初期化\n    if [[ ! -f \"$pending_file\" ]]; then\n        cat > \"$pending_file\" << 'EOF'\n# Pending Memories - 外部コンテンツ段階処理\n\n## 処理待ち項目\n\n<!-- 外部ソースからの情報は以下に段階的に記録 -->\nEOF\n    fi\n    \n    # エントリ追加\n    cat >> \"$pending_file\" << EOF\n\n### $(date -I) $(date '+%H:%M') - $source\n**理由**: $reason\n**ソース**: $source\n**ステータス**: pending\n\n\\`\\`\\`\n$content\n\\`\\`\\`\n\n**検証項目**:\n- [ ] 信頼性確認\n- [ ] 既存記憶との整合性\n- [ ] 価値評価\n- [ ] 分類決定\n\nEOF\n    \n    echo \"外部コンテンツ段階処理キューに追加: $source\"\n}\n\n# 段階処理レビュー\nreview_pending_memories() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local pending_file=\"$workspace/memory/pending-memories.md\"\n    \n    if [[ ! -f \"$pending_file\" ]]; then\n        echo \"段階処理キューは空です\"\n        return\n    fi\n    \n    echo \"=== 段階処理キューレビュー ===\"\n    \n    # pending項目数をカウント\n    local pending_count=\"$(grep -c \"ステータス.*pending\" \"$pending_file\")\"\n    echo \"処理待ち項目数: $pending_count\"\n    \n    # 古い項目（7日以上）を特定\n    local week_ago=\"$(date -d '7 days ago' -I)\"\n    grep -B 5 -A 10 \"$week_ago\" \"$pending_file\" | head -20\n    \n    echo \"\"\n    echo \"古い項目がある場合は手動レビューを実行してください\"\n}\n\nメモリ保守スケジュール\ncron設定\n# memory-maintenance-cron.txt\n# メモリシステム定期保守\n\n# 毎日午前1時: 日次ファイル初期化\n0 1 * * * /home/bot/.openclaw/workspace/skills/memory-tools/daily-memory-init.sh\n\n# 毎週日曜午前2時: 週次キュレーション\n0 2 * * 0 /home/bot/.openclaw/workspace/skills/memory-tools/curate-weekly-memories.sh\n\n# 毎月1日午前3時: 月次アーカイブ\n0 3 1 * * /home/bot/.openclaw/workspace/skills/memory-tools/monthly-archive.sh\n\n# 毎日午前6時: 段階処理レビュー\n0 6 * * * /home/bot/.openclaw/workspace/skills/memory-tools/review-pending-memories.sh\n\n自動アーカイブ\n#!/bin/bash\n# monthly-archive.sh\n\nmonthly_archive() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local archive_dir=\"$workspace/memory/archive\"\n    local current_month=\"$(date '+%Y-%m')\"\n    local last_month=\"$(date -d 'last month' '+%Y-%m')\"\n    \n    mkdir -p \"$archive_dir\"\n    \n    echo \"月次アーカイブ開始: $last_month\"\n    \n    # 前月のファイルをアーカイブ\n    find \"$workspace/memory\" -name \"$last_month-*.md\" -exec mv {} \"$archive_dir/\" \\;\n    \n    # 月次サマリー作成\n    cat > \"$archive_dir/$last_month-summary.md\" << EOF\n# Monthly Summary: $last_month\n\n## 統計\n- 日次ファイル数: $(ls \"$archive_dir/$last_month\"-*.md 2>/dev/null | wc -l)\n- 総イベント数: $(grep -c \"###\" \"$archive_dir/$last_month\"-*.md 2>/dev/null || echo 0)\n\n## 主要トピック\n$(grep -h \"^### \" \"$archive_dir/$last_month\"-*.md 2>/dev/null | sort | uniq -c | sort -nr | head -10)\n\n## アーカイブ日時\n$(date)\nEOF\n    \n    echo \"月次アーカイブ完了: $archive_dir\"\n}\n\nHeartbeat統合\nメモリ状態監視\n// heartbeat-state.json - ハートビート状態管理\n{\n    \"lastMemoryCheck\": 1703275200,\n    \"pendingMemoryCount\": 3,\n    \"lastCuration\": 1703260800,\n    \"memoryHealth\": {\n        \"dailyFilesCount\": 7,\n        \"longTermMemorySize\": 15420,\n        \"lastSuccessfulBackup\": 1703268000\n    },\n    \"alerts\": [\n        {\n            \"type\": \"pending_queue_full\",\n            \"threshold\": 10,\n            \"current\": 3\n        }\n    ]\n}\n\nheartbeat チェック項目\n#!/bin/bash\n# heartbeat-memory-check.sh\n\nheartbeat_memory_check() {\n    local workspace=\"/home/bot/.openclaw/workspace\"\n    local state_file=\"$workspace/memory/heartbeat-state.json\"\n    \n    # 段階処理キュー確認\n    local pending_count=\"$(grep -c \"ステータス.*pending\" \"$workspace/memory/pending-memories.md\" 2>/dev/null || echo 0)\"\n    \n    if [[ $pending_count -gt 10 ]]; then\n        echo \"⚠️ 段階処理キューが満杯です ($pending_count 項目)\"\n    elif [[ $pending_count -gt 5 ]]; then\n        echo \"📋 段階処理キューレビューが必要 ($pending_count 項目)\"\n    fi\n    \n    # MEMORY.md サイズ確認\n    local memory_size=\"$(wc -c < \"$workspace/MEMORY.md\" 2>/dev/null || echo 0)\"\n    if [[ $memory_size -gt 100000 ]]; then\n        echo \"📚 MEMORY.md が大きくなっています。整理を検討してください\"\n    fi\n    \n    # 日次ファイル確認\n    local today=\"$(date -I)\"\n    if [[ ! -f \"$workspace/memory/$today.md\" ]]; then\n        echo \"📝 本日の日次ファイルを作成します\"\n        create_daily_memory\n    fi\n}\n\n使用パターン例\n1. セッション開始時\n# 最近のコンテクスト読み込み\nsmart_memory_search \"プロジェクト\" 2\ngrep -n \"重要\" memory/$(date -I).md memory/$(date -d yesterday -I).md\n\n2. 新情報の記録\n# 段階処理経由で安全に記録\nqueue_external_memory \"web_search\" \"新しいライブラリ情報\" \"プロジェクトで使用検討\"\n\n3. 定期的なキュレーション\n# ハートビート時の自動実行\ncurate_weekly_memories\nreview_pending_memories\n\n\n太郎書館ではエージェント状態バックアップ戦略に関する知識を取引しています。"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/Byron-McKeeby/agent-memory-patterns",
    "publisherUrl": "https://clawhub.ai/Byron-McKeeby/agent-memory-patterns",
    "owner": "Byron-McKeeby",
    "version": "1.0.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/agent-memory-patterns",
    "downloadUrl": "https://openagent3.xyz/downloads/agent-memory-patterns",
    "agentUrl": "https://openagent3.xyz/skills/agent-memory-patterns/agent",
    "manifestUrl": "https://openagent3.xyz/skills/agent-memory-patterns/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/agent-memory-patterns/agent.md"
  }
}