{
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 23,
              "minute": 56
            }
          ]
        }
      },
      "name": "\u5b9a\u671f\u5b9f\u884c",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        0,
        0
      ]
    },
    {
      "parameters": {
        "command": "cd /home/node/scripts && cp manictime_tokens.json /tmp/manictime_tokens.json && TOKEN_FILE=/tmp/manictime_tokens.json python3 manictime_n8n.py --days-ago 0 --start-hour 10 --end-hour 20"
      },
      "name": "ManicTime\u30c7\u30fc\u30bf\u53d6\u5f97\uff08\u696d\u52d9\u6642\u9593\uff09",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        200,
        0
      ]
    },
    {
      "parameters": {
        "jsCode": "// \u30b7\u30f3\u30d7\u30eb\u306a\u30c7\u30fc\u30bf\u6574\u5f62\uff08\u65e7\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u6e96\u62e0\uff09\nconst items = $input.all();\n\nlet manicTimeData;\ntry {\n  const stdout = items[0].json.stdout;\n  manicTimeData = JSON.parse(stdout);\n} catch (error) {\n  return [{ \n    formattedManicTimeDataForAgent: \"\u30c7\u30fc\u30bf\u89e3\u6790\u30a8\u30e9\u30fc\",\n    date: new Date().toISOString().split('T')[0]\n  }];\n}\n\nconst activities = manicTimeData.activities || [];\n\nif (activities.length === 0) {\n  return [{ \n    formattedManicTimeDataForAgent: \"No data\",\n    date: manicTimeData.date || new Date().toISOString().split('T')[0],\n    rawData: manicTimeData\n  }];\n}\n\nlet outputText = \"\";\n\n// \u65e7\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u540c\u3058\u5f62\u5f0f\u3067\u51fa\u529b\nfor (const activity of activities) {\n  const startTimeRaw = activity.start; // \"2025-09-01 10:30:00\" \u5f62\u5f0f\n  const durationSeconds = activity.duration_seconds;\n  const name = activity.name;\n  \n  // \u65e5\u4ed8\u3068\u6642\u523b\u3092\u5206\u5272\n  const [datePart, timePart] = startTimeRaw.split(' ');\n  const [year, month, day] = datePart.split('-');\n  const [hours, minutes] = timePart.split(':');\n  \n  // MM-dd-HH:mm \u5f62\u5f0f\u306b\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\n  const startTimeFormatted = `${month}-${day}-${hours}:${minutes}`;\n  \n  let durationFormatted;\n  if (durationSeconds < 60) {\n    durationFormatted = `${durationSeconds}\u79d2\u9593`;\n  } else {\n    const durationMinutes = Math.floor(durationSeconds / 60);\n    durationFormatted = `\u7d04${durationMinutes}\u5206\u9593`;\n  }\n  \n  outputText += `- ${startTimeFormatted}\u304b\u3089${durationFormatted}: ${name}\\n`;\n}\n\nreturn [{\n  formattedManicTimeDataForAgent: outputText,\n  date: manicTimeData.date || new Date().toISOString().split('T')[0],\n  rawData: manicTimeData\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        400,
        0
      ],
      "name": "JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=\u91cd\u8981\u4e8b\u9805:\u3082\u3057\u30c7\u30fc\u30bf\u304c\u306a\u3044\u5834\u5408\u306f\u3001\u30c7\u30fc\u30bf\u306a\u3057\u3068\u3060\u3051\u5831\u544a\u3057\u3066\u304f\u3060\u3055\u3044\u3002 \u4ee5\u4e0b\u306fPC\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5229\u7528\u5c65\u6b74\u3067\u3059\u3002\u5c65\u6b74\u30c7\u30fc\u30bf\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\uff1a\n{{ $json.formattedManicTimeDataForAgent }}\n(\u5185\u306f\u6307\u793a\u5185\u5bb9\u3067\u3059\u3002\u51fa\u529b\u30c7\u30fc\u30bf\u306b\u306f\u542b\u3081\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002)\n(\u3053\u306e\u30c7\u30fc\u30bf\u304b\u3089\u3001\u4ee5\u4e0b\u306e\u65e5\u5831\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306b\u5f93\u3063\u3066\u65e5\u672c\u8a9e\u3067\u65e5\u5831\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\u65e5\u5831\u306f\u3001\u81ea\u5df1\u306e\u6d3b\u52d5\u3092\u5ba2\u89b3\u7684\u306b\u632f\u308a\u8fd4\u308a\u3001\u751f\u7523\u6027\u5411\u4e0a\u3084\u8ab2\u984c\u767a\u898b\u3001\u7fcc\u65e5\u4ee5\u964d\u306e\u8a08\u753b\u7acb\u6848\u306b\u5f79\u7acb\u3066\u308b\u3053\u3068\u3092\u76ee\u7684\u3068\u3057\u307e\u3059\u3002)\n\n\n\n(\u51fa\u529b\u306f\u6b21\u306e\u884c\u304b\u3089\u59cb\u3081\u3066\u304f\u3060\u3055\u3044\u3002)\n## 1. \u672c\u65e5\u306e\u6d3b\u52d5\u30cf\u30a4\u30e9\u30a4\u30c8 \n\uff08ManicTime\u306e\u30ed\u30b0\u304b\u3089\u3001\u7279\u306b\u6642\u9593\u3092\u8cbb\u3084\u3057\u305f\u6d3b\u52d5\u3084\u3001\u7279\u5fb4\u7684\u306a\u884c\u52d5\u30d1\u30bf\u30fc\u30f3\u30925-10\u884c\u7a0b\u5ea6\u306e\u6df1\u3044\u8981\u7d04\u3092\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u6642\u9593\u306f\u3067\u304d\u308b\u3060\u3051\u6b63\u78ba\u306b\u7a4d\u7b97\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u5358\u306a\u308b\u30a2\u30d7\u30ea\u4f7f\u7528\u6642\u9593\u306e\u5831\u544a\u3067\u306f\u306a\u304f\u3001\u4f55\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u305f\u306e\u304b\u304c\u63a8\u6e2c\u3067\u304d\u308b\u3088\u3046\u306a\u8a18\u8ff0\u3092\u5fc3\u304c\u3051\u3066\u304f\u3060\u3055\u3044\u3002\uff09 \uff08\u4e00\u65e5\u306ePC\u4f5c\u696d\u306e\u5408\u8a08\u6642\u9593\u3092\u8868\u793a\u3057\u3001\u50cd\u304d\u904e\u304e\u7b49\u306e\u30b3\u30e1\u30f3\u30c8\u3092\u6b8b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09\n## 2. \u4e3b\u8981\u306a\u6d3b\u52d5\u30ab\u30c6\u30b4\u30ea\u3068\u6240\u8981\u6642\u9593 \n\uff08\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d\u3060\u3051\u3067\u306a\u304f\u3001\u30a6\u30a3\u30f3\u30c9\u30a6\u30bf\u30a4\u30c8\u30eb\u3084\u9023\u7d9a\u4f7f\u7528\u6642\u9593\u306a\u3069\u304b\u3089\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u884c\u3063\u3066\u3044\u305f\u3068\u601d\u308f\u308c\u308b\u4e3b\u8981\u306a\u6d3b\u52d5\u30ab\u30c6\u30b4\u30ea\u30923\uff5e5\u3064\u7a0b\u5ea6\u306b\u5206\u985e\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u6d3b\u52d5\u306b\u8cbb\u3084\u3055\u308c\u305f\u304a\u304a\u3088\u305d\u306e\u5408\u8a08\u6642\u9593\u3092\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09 \n## 3. \u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5229\u7528\u6642\u9593 Top 5 \n\uff08\u63d0\u4f9b\u3055\u308c\u305f\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5229\u7528\u5c65\u6b74\u304b\u3089\u3001\u5229\u7528\u6642\u9593\u304c\u9577\u3044\u4e0a\u4f4d5\u3064\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u7279\u5b9a\u3057\u3001\u305d\u308c\u305e\u308c\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u540d\u3068\u304a\u304a\u3088\u305d\u306e\u5408\u8a08\u5229\u7528\u6642\u9593\uff08\u4f8b: X\u6642\u9593Y\u5206\uff09\u3092\u30ea\u30b9\u30c8\u5f62\u5f0f\u3067\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044\u3002\uff09  \n## 4. \u5404\u6642\u9593\u3054\u3068\u306e\u4f5c\u696d\u5185\u5bb9 \n(ManicTime\u306e\u30ed\u30b0\u304b\u3089\u3001\u5404\u6642\u9593\u3054\u3068\u306e\u4f5c\u696d\u5185\u5bb9\u3092\u8981\u7d04\u3057\u3066\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044\u30020:00-1:00,1:00-2:00\u306e\u3088\u3046\u306b1\u6642\u9593\u3054\u3068\u306b\u4e26\u3073\u66ff\u3048\u3066\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4f5c\u696d\u304c\u9023\u7d9a\u3057\u3066\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u3001\u305d\u306e\u6642\u9593\u3092\u6b21\u306e\u3088\u3046\u306b\u307e\u3068\u3081\u30010:00-7:00:\u4f5c\u696d\u306a\u3057 \u3068\u3057\u3066\u304f\u3060\u3055\u3044\u3002)  \n## 5. \u632f\u308a\u8fd4\u308a\u3068\u30cd\u30af\u30b9\u30c8\u30a2\u30af\u30b7\u30e7\u30f3 \n(\u81ea\u5df1\u306e\u6d3b\u52d5\u3092\u5ba2\u89b3\u7684\u306b\u5206\u6790\u3057\u305f\u30c7\u30fc\u30bf\u3092\u5404\u9805\u76ee2~3\u884c\u7a0b\u5ea6\u3067\u8a18\u8f09\u3057\u3066\u304f\u3060\u3055\u3044\u3002) \n*   \u4eca\u65e5\u306e\u4e3b\u306a\u6210\u679c\u30fb\u9054\u6210\u3067\u304d\u305f\u3053\u3068:     \n    * \n*   \u8ab2\u984c\u3084\u53cd\u7701\u70b9\u3001\u6539\u5584\u3057\u305f\u3044\u3053\u3068:    \n    * \n*   \u4eca\u65e5\u306e\u6d3b\u52d5\u3067\u5f97\u305f\u6c17\u4ed8\u304d\u3084\u5b66\u3073:     \n    * \n*   \u660e\u65e5\u4ee5\u964d\u53d6\u308a\u7d44\u3080\u3053\u3068\u30fb\u76ee\u6a19:    \n    * \n*   \u305d\u306e\u4ed6\u7279\u8a18\u4e8b\u9805:     \n    *"
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.9,
      "position": [
        600,
        0
      ],
      "name": "AI Agent"
    },
    {
      "parameters": {
        "modelName": "models/gemini-2.0-flash"
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "typeVersion": 1,
      "position": [
        600,
        200
      ],
      "name": "Gemini"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "get",
        "owner": {
          "__rl": true,
          "value": "ibushimaru",
          "mode": "list"
        },
        "repository": {
          "__rl": true,
          "value": "ManicTime-DailyReport",
          "mode": "list"
        },
        "filePath": "=DailyReports/reports/{{ $node[\"JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62\"].json.date }}.md",
        "asBinaryProperty": false
      },
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        800,
        0
      ],
      "name": "\u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u30c1\u30a7\u30c3\u30af",
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $node[\"\u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u30c1\u30a7\u30c3\u30af\"].json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\uff1f",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1000,
        0
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "edit",
        "owner": {
          "__rl": true,
          "value": "ibushimaru",
          "mode": "list"
        },
        "repository": {
          "__rl": true,
          "value": "ManicTime-DailyReport",
          "mode": "list"
        },
        "filePath": "=DailyReports/reports/{{ $node[\"JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62\"].json.date }}.md",
        "fileContent": "={{ $node[\"AI Agent\"].json.output }}",
        "commitMessage": "=\u65e5\u5831\u66f4\u65b0: {{ $node[\"JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62\"].json.date }}"
      },
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        1200,
        -100
      ],
      "name": "GitHub\u66f4\u65b0",
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "create",
        "owner": {
          "__rl": true,
          "value": "ibushimaru",
          "mode": "list"
        },
        "repository": {
          "__rl": true,
          "value": "ManicTime-DailyReport",
          "mode": "list"
        },
        "filePath": "=DailyReports/reports/{{ $node[\"JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62\"].json.date }}.md",
        "fileContent": "={{ $node[\"AI Agent\"].json.output }}",
        "commitMessage": "=\u65e5\u5831\u4f5c\u6210: {{ $node[\"JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62\"].json.date }}"
      },
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        1200,
        100
      ],
      "name": "GitHub\u65b0\u898f\u4f5c\u6210",
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u30c7\u30fc\u30bf\u6e96\u5099\uff08\u751f\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u4fdd\u5b58\uff09\nconst data = $node[\"JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62\"].json;\n\n// ManicTime\u304b\u3089\u53d6\u5f97\u3057\u305f\u751f\u30c7\u30fc\u30bf\u3092\u305d\u306e\u307e\u307e\u4fdd\u5b58\nconst backupData = data.rawData || {\n  date: data.date,\n  error: \"No raw data available\"\n};\n\nreturn [{\n  filePath: `DailyReports/data/${data.date}.json`,\n  content: JSON.stringify(backupData, null, 2),\n  date: data.date\n}];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        600,
        -200
      ],
      "name": "JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099"
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "get",
        "owner": {
          "__rl": true,
          "value": "ibushimaru",
          "mode": "list"
        },
        "repository": {
          "__rl": true,
          "value": "ManicTime-DailyReport",
          "mode": "list"
        },
        "filePath": "={{ $json.filePath }}",
        "asBinaryProperty": false
      },
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        800,
        -200
      ],
      "name": "JSON\u5b58\u5728\u30c1\u30a7\u30c3\u30af",
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $node[\"JSON\u5b58\u5728\u30c1\u30a7\u30c3\u30af\"].json.error }}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "name": "JSON\u5b58\u5728\uff1f",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1000,
        -200
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "edit",
        "owner": {
          "__rl": true,
          "value": "ibushimaru",
          "mode": "list"
        },
        "repository": {
          "__rl": true,
          "value": "ManicTime-DailyReport",
          "mode": "list"
        },
        "filePath": "={{ $node[\"JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099\"].json.filePath }}",
        "fileContent": "={{ $node[\"JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099\"].json.content }}",
        "commitMessage": "=\u30c7\u30fc\u30bf\u66f4\u65b0: {{ $node[\"JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099\"].json.date }}"
      },
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        1200,
        -300
      ],
      "name": "JSON\u66f4\u65b0",
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "file",
        "operation": "create",
        "owner": {
          "__rl": true,
          "value": "ibushimaru",
          "mode": "list"
        },
        "repository": {
          "__rl": true,
          "value": "ManicTime-DailyReport",
          "mode": "list"
        },
        "filePath": "={{ $node[\"JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099\"].json.filePath }}",
        "fileContent": "={{ $node[\"JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099\"].json.content }}",
        "commitMessage": "=\u30c7\u30fc\u30bf\u4f5c\u6210: {{ $node[\"JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099\"].json.date }}"
      },
      "type": "n8n-nodes-base.github",
      "typeVersion": 1,
      "position": [
        1200,
        -100
      ],
      "name": "JSON\u65b0\u898f\u4f5c\u6210",
      "credentials": {
        "githubOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "\u5b9a\u671f\u5b9f\u884c": {
      "main": [
        [
          {
            "node": "ManicTime\u30c7\u30fc\u30bf\u53d6\u5f97\uff08\u696d\u52d9\u6642\u9593\uff09",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ManicTime\u30c7\u30fc\u30bf\u53d6\u5f97\uff08\u696d\u52d9\u6642\u9593\uff09": {
      "main": [
        [
          {
            "node": "JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON\u30c7\u30fc\u30bf\u3092\u6574\u5f62": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          },
          {
            "node": "JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "\u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u30c1\u30a7\u30c3\u30af",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u65e2\u5b58\u30d5\u30a1\u30a4\u30eb\u30c1\u30a7\u30c3\u30af": {
      "main": [
        [
          {
            "node": "\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\uff1f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u30d5\u30a1\u30a4\u30eb\u5b58\u5728\uff1f": {
      "main": [
        [
          {
            "node": "GitHub\u66f4\u65b0",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "GitHub\u65b0\u898f\u4f5c\u6210",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u6e96\u5099": {
      "main": [
        [
          {
            "node": "JSON\u5b58\u5728\u30c1\u30a7\u30c3\u30af",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON\u5b58\u5728\u30c1\u30a7\u30c3\u30af": {
      "main": [
        [
          {
            "node": "JSON\u5b58\u5728\uff1f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON\u5b58\u5728\uff1f": {
      "main": [
        [
          {
            "node": "JSON\u66f4\u65b0",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "JSON\u65b0\u898f\u4f5c\u6210",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}