summaryrefslogtreecommitdiffhomepage
path: root/.rules/plan/calendar-phase-7.md
blob: 8bd0aaf465bff38d60bd8809036e5fafec8d337d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Phase 7: AI Tools for Date-Based Notes

**Status:** Not started
**Depends on:** Phase 1 (daily-notes.ts)
**Output files:** `src/context/tools/read-daily-note.json`, `src/context/tools/write-daily-note.json`, modifications to `src/tools.ts`

---

## Overview

Two new tools the AI can use to interact with the calendar structure: `read_daily_note` and `write_daily_note`.

---

## `read_daily_note` Tool

### JSON Definition (`src/context/tools/read-daily-note.json`)

```json
{
  "id": "read_daily_note",
  "label": "Read Daily Note",
  "description": "Read the daily note for a specific date",
  "friendlyName": "Read Daily Note",
  "requiresApproval": false,
  "definition": {
    "type": "function",
    "function": {
      "name": "read_daily_note",
      "description": "Read the daily note for a given date. Use 'today' for the current date, or provide a date in YYYY-MM-DD format.",
      "parameters": {
        "type": "object",
        "required": ["date"],
        "properties": {
          "date": {
            "type": "string",
            "description": "The date to read. Use 'today', 'yesterday', 'tomorrow', or a YYYY-MM-DD date string."
          }
        }
      }
    }
  }
}
```

### Execute Logic

1. Parse the `date` argument — handle `"today"`, `"yesterday"`, `"tomorrow"`, or parse `YYYY-MM-DD` with `moment()`
2. Compute the path using `getDailyNotePath()`
3. If file exists: read and return content (same format as `read_file`)
4. If not: return `"No daily note exists for {date}."`

---

## `write_daily_note` Tool

### JSON Definition (`src/context/tools/write-daily-note.json`)

```json
{
  "id": "write_daily_note",
  "label": "Write Daily Note",
  "description": "Write or append to the daily note for a specific date",
  "friendlyName": "Write Daily Note",
  "requiresApproval": true,
  "definition": {
    "type": "function",
    "function": {
      "name": "write_daily_note",
      "description": "Write content to the daily note for a given date. Creates the note if it does not exist. Use mode 'append' to add to the end, or 'overwrite' to replace all content.",
      "parameters": {
        "type": "object",
        "required": ["date", "content"],
        "properties": {
          "date": {
            "type": "string",
            "description": "The date to write to. Use 'today', 'yesterday', 'tomorrow', or a YYYY-MM-DD date string."
          },
          "content": {
            "type": "string",
            "description": "The content to write."
          },
          "mode": {
            "type": "string",
            "description": "Write mode: 'append' (default) adds to the end, 'overwrite' replaces all content."
          }
        }
      }
    }
  }
}
```

### Execute Logic

1. Parse date (same as read)
2. If file does not exist: create it with content (using `createDailyNote()` then write)
3. If file exists:
   - `"append"` (default): `app.vault.append(file, "\n" + content)`
   - `"overwrite"`: `app.vault.modify(file, content)`
4. Return confirmation message

---

## Registration in `src/tools.ts`

- Import both JSON files
- Add `TOOL_REGISTRY` entries that spread the JSON context and add runtime callbacks (`summarize`, `summarizeResult`, `execute`, and optionally `approvalMessage`)
- Follow the existing pattern for other tools