Skip to content

Commit 6d8ec2c

Browse files
authored
Add SimpleDoc/SimpleLog spec (#13)
* Add SimpleDoc/SimpleLog spec * Normalize SimpleLog spec * Remove non-ASCII from SimpleLog spec * Rename SimpleLog spec file * Align SimpleLog spec title * Add simpledoc log command * Support multiline simpledoc log entries * Auto-read stdin for simpledoc log * Revise SimpleLog format and frontmatter * Adjust SimpleLog entry formatting * Remove auto timestamps from SimpleLog * Log latest SimpleLog CLI tests * Mention SimpleLog spec in README * Document SimpleLog usage in skill * Add agent logging guidance to skill * Log ongoing progress in skill guidance * Broaden skill logging guidance * Document SimpleDoc config files * Expand SimpleDoc config spec * Add config support for SimpleDoc tools * Refactor config helpers * Allow date-only docs * Refactor frontmatter helpers * Use npx in CLI guidance * Add config and log tests * Track SimpleLog section start
1 parent 6d837c6 commit 6d8ec2c

28 files changed

+1814
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules
33
dist
44
dist-test
5+
.simpledoc.local.json

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm exec -- lint-staged
1+
npm run -s precommit

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ SimpleDoc defines two types of files:
1111
1. **Date-prefixed files**: SHOULD be used for most documents, e.g. `docs/2025-12-22-an-awesome-doc.md`.
1212
2. **Capitalized files**: SHOULD be used for general documents that are not tied to a specific time, e.g. `README.md`.
1313

14+
SimpleDoc also includes optional subspecs for specialized document types, such as the SimpleLog daily log format in `docs/SIMPLELOG_SPEC.md`.
15+
Configuration for tooling can be shared in `simpledoc.json` and overridden per-user in `.simpledoc.local.json` (see `docs/SIMPLEDOC_CONFIG_SPEC.md`).
16+
1417
### 1. Date-prefixed files
1518

1619
- Date-prefixed Markdown files SHOULD be used for most documents that are tied to a specific time.
1720
- MUST put date-prefixed files in a top level `docs/` folder, or a subfolder `docs/<topic>/`. Subfolders MAY be nested indefinitely.
1821
- MUST use ISO 8601 date prefixes (`YYYY-MM-DD`) — the date MUST contain dashes.
1922
- After the date prefix, lowercase filenames SHOULD use dashes (`-`) as word delimiters (kebab-case). Avoid spaces and underscores.
23+
- The date prefix MAY be the entire filename (for example, daily logs like `docs/logs/2026-02-04.md`).
2024
- MUST NOT use capital letters in filename for Latin, Greek, Cyrillic and other writing systems that have lowercase/uppercase distinction.
2125
- MAY use non-ASCII characters, e.g. `docs/2025-12-22-postmortem-login-ausfälle.md`, `docs/2025-12-22-功能-设计说明.md`.
2226
- Date-prefixed files SHOULD contain YAML frontmatter with at least `title`, `author` and `date` fields, but we are all people and sometimes don't have time to write a proper frontmatter, so it is not required. E.g.

docs/SIMPLEDOC_CONFIG_SPEC.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# SimpleDoc Config
2+
3+
> Repository and local configuration for SimpleDoc tools
4+
5+
## 1) Config files
6+
7+
SimpleDoc tooling MAY read two JSON config files at the repo root:
8+
9+
- `simpledoc.json` (committed, shared defaults)
10+
- `.simpledoc.local.json` (uncommitted, per-user overrides)
11+
12+
Both files are optional.
13+
14+
## 2) File format
15+
16+
- MUST be valid JSON.
17+
- MUST be UTF-8.
18+
- MUST use LF (`\n`) newlines.
19+
20+
## 3) Precedence
21+
22+
Configuration values are resolved in this order (highest wins):
23+
24+
1. CLI flags
25+
2. `.simpledoc.local.json`
26+
3. `simpledoc.json`
27+
4. Tool defaults
28+
29+
## 4) Schema
30+
31+
Top-level object. Current keys:
32+
33+
```json
34+
{
35+
"docs": {
36+
"root": "docs"
37+
},
38+
"frontmatter": {
39+
"defaults": {
40+
"author": "Jane Doe <[email protected]>",
41+
"tags": ["docs", "simpledoc"],
42+
"titlePrefix": "Daily Log"
43+
}
44+
},
45+
"check": {
46+
"ignore": ["docs/generated/**", "docs/_drafts/**"]
47+
},
48+
"simplelog": {
49+
"root": "docs/logs",
50+
"thresholdMinutes": 5,
51+
"timezone": "Europe/Berlin"
52+
}
53+
}
54+
```
55+
56+
### docs.root
57+
58+
- **Type:** string
59+
- **Meaning:** Root directory for SimpleDoc-managed documentation.
60+
- **Resolution:** If relative, it is resolved from the repo root.
61+
- **Default:** `docs`
62+
- **Notes:** Tools like `npx -y @simpledoc/simpledoc check` and `npx -y @simpledoc/simpledoc migrate` SHOULD treat this as the documentation root.
63+
64+
### frontmatter.defaults
65+
66+
- **Type:** object
67+
- **Meaning:** Default frontmatter values to use when a tool needs to create or insert frontmatter.
68+
- **Notes:** These values SHOULD only fill missing fields and MUST NOT overwrite existing frontmatter.
69+
70+
Supported keys:
71+
72+
- `author` (string): Default `Name <email>` to use.
73+
- `tags` (string array): Default tags to add (optional).
74+
- `titlePrefix` (string): Prefix used when generating titles (optional).
75+
76+
### check.ignore
77+
78+
- **Type:** array of strings
79+
- **Meaning:** Glob-like patterns to ignore when scanning for violations in `npx -y @simpledoc/simpledoc check` (and optionally other scans).
80+
- **Resolution:** Patterns are matched relative to the repo root.
81+
- **Notes:** Ignored paths SHOULD be skipped entirely during scans.
82+
83+
### simplelog.root
84+
85+
- **Type:** string
86+
- **Meaning:** Root directory for SimpleLog daily files.
87+
- **Resolution:** If relative, it is resolved from the repo root.
88+
- **Default:** `${docs.root}/logs` (falls back to `docs/logs` if `docs.root` is unset).
89+
- **Recommendation:** Use a shared path in `simpledoc.json` (e.g. `docs/logs`) and a per-user path in `.simpledoc.local.json` when needed (e.g. `docs/logs/_local/<name>`).
90+
91+
### simplelog.thresholdMinutes
92+
93+
- **Type:** number
94+
- **Meaning:** Default threshold (in minutes) for starting a new session section.
95+
- **Default:** 5
96+
- **Notes:** CLI flags should override this when provided.
97+
98+
### simplelog.timezone
99+
100+
- **Type:** string
101+
- **Meaning:** IANA timezone ID to use when creating new SimpleLog files and sections.
102+
- **Default:** System timezone (or `UTC` if unavailable).
103+
- **Notes:** If a SimpleLog file exists with a `tz` frontmatter value, that value SHOULD take precedence for that file.
104+
105+
## 5) Usage examples
106+
107+
### Shared default (committed)
108+
109+
`simpledoc.json`
110+
111+
```json
112+
{
113+
"docs": {
114+
"root": "docs"
115+
},
116+
"frontmatter": {
117+
"defaults": {
118+
"author": "Jane Doe <[email protected]>",
119+
"tags": ["docs", "simpledoc"]
120+
}
121+
},
122+
"check": {
123+
"ignore": ["docs/generated/**"]
124+
},
125+
"simplelog": {
126+
"root": "docs/logs"
127+
}
128+
}
129+
```
130+
131+
### Local override (uncommitted)
132+
133+
`.simpledoc.local.json`
134+
135+
```json
136+
{
137+
"docs": {
138+
"root": "docs"
139+
},
140+
"frontmatter": {
141+
"defaults": {
142+
"author": "Alice Example <[email protected]>"
143+
}
144+
},
145+
"simplelog": {
146+
"root": "docs/logs/_local/alice",
147+
"thresholdMinutes": 2,
148+
"timezone": "Europe/Berlin"
149+
}
150+
}
151+
```
152+
153+
## 6) Git ignore
154+
155+
Teams SHOULD add `.simpledoc.local.json` to `.gitignore` to prevent accidental commits.

docs/SIMPLEDOC_SPEC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SimpleDoc defines two types of files:
1717
- MUST put date-prefixed files in a top level `docs/` folder, or a subfolder `docs/<topic>/`. Subfolders MAY be nested indefinitely.
1818
- MUST use ISO 8601 date prefixes (`YYYY-MM-DD`) — the date MUST contain dashes.
1919
- After the date prefix, lowercase filenames SHOULD use dashes (`-`) as word delimiters (kebab-case). Avoid spaces and underscores.
20+
- The date prefix MAY be the entire filename (for example, daily logs like `docs/logs/2026-02-04.md`).
2021
- MUST NOT use capital letters in filename for Latin, Greek, Cyrillic and other writing systems that have lowercase/uppercase distinction.
2122
- MAY use non-ASCII characters, e.g. `docs/2025-12-22-postmortem-login-ausfälle.md`, `docs/2025-12-22-功能-设计说明.md`.
2223
- Date-prefixed files SHOULD contain YAML frontmatter with at least `title`, `author` and `date` fields, but we are all people and sometimes don't have time to write a proper frontmatter, so it is not required. E.g.

docs/SIMPLELOG_SPEC.md

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# SimpleLog
2+
3+
> SimpleDoc subspec: Daily Markdown Log (DML) v1 - Specification
4+
5+
## 1) Storage layout
6+
7+
- **Root directory:** any path. When used inside a SimpleDoc codebase, logs SHOULD live under `docs/` or `docs/<topic>/` to remain compliant with SimpleDoc.
8+
- **Daily file name:** `YYYY-MM-DD.md` (local date in the chosen "primary" timezone).
9+
- Example: `2025-12-01.md`
10+
- **Optional subdirectories** (recommended when many files):
11+
- `YYYY/YYYY-MM-DD.md` or `YYYY/MM/YYYY-MM-DD.md`
12+
- Example: `2025/2025-12-01.md`
13+
14+
## 2) File encoding and newlines
15+
16+
- MUST be UTF-8.
17+
- MUST use LF (`\n`) newlines.
18+
- SHOULD end with a trailing newline.
19+
20+
## 3) Frontmatter (required)
21+
22+
Files MUST start with YAML frontmatter that follows SimpleDoc conventions.
23+
24+
Required fields:
25+
26+
- `title`: human-readable title for the day.
27+
- `author`: `Name <email>` (RFC 5322 name-addr format).
28+
- `date`: `YYYY-MM-DD`.
29+
- `tz`: IANA timezone ID (e.g., `Europe/Berlin`).
30+
- `created`: ISO-8601 timestamp with offset.
31+
32+
Optional fields:
33+
34+
- `last_section`: ISO-8601 timestamp with offset (start time of the latest section).
35+
- `updated`: ISO-8601 timestamp with offset.
36+
37+
Example:
38+
39+
```md
40+
---
41+
title: Daily Log 2025-12-01
42+
author: Jane Doe <[email protected]>
43+
date: 2025-12-01
44+
tz: Europe/Berlin
45+
created: 2025-12-01T00:00:00+01:00
46+
last_section: 2025-12-01T09:13:00+01:00
47+
---
48+
```
49+
50+
Notes:
51+
52+
- The file date is interpreted in the `tz` timezone.
53+
- DST transitions are supported because each entry includes an offset.
54+
55+
## 4) Session sections (threshold)
56+
57+
Entries are grouped into session sections. Section titles SHOULD reflect the local time of the first entry in that section.
58+
59+
- **Section heading format (required):** `## HH:MM`
60+
- `HH` is 24-hour, zero-padded (`00-23`).
61+
62+
Example:
63+
64+
```md
65+
## 09:13
66+
67+
## 14:03
68+
```
69+
70+
Rules:
71+
72+
- SHOULD be in chronological order.
73+
- A section may exist with no entries.
74+
75+
## 5) Entry format (appendable, human-readable, parseable)
76+
77+
Each entry is a block of text separated by at least one blank line. The entry body is freeform; the only reserved syntax is the session section headings.
78+
79+
Recommended entry body conventions (all optional):
80+
81+
- Severity token: `[INFO]`, `[WARN]`, `[ERROR]`, etc.
82+
- Tags: `#tag` tokens
83+
- Key-values: `key=value` tokens (values may be quoted)
84+
- Optional timestamp prefix if you want exact times per entry, e.g. `09:14:10+01:00 ...`.
85+
86+
Examples:
87+
88+
```md
89+
Standup notes #team
90+
91+
[WARN] API latency spike service=orders p95_ms=840
92+
93+
09:14:10+01:00 Deployed v1.8.2 #deploy ticket=ABC-123
94+
```
95+
96+
Multiline entries:
97+
98+
- Continuation lines are allowed and are stored as-is.
99+
- CLI implementations SHOULD NOT alter indentation; they only ensure a blank line separates entries.
100+
101+
Example:
102+
103+
```md
104+
Incident review #ops
105+
106+
- suspected cause: cache stampede
107+
- mitigation: rate-limit + warmup
108+
```
109+
110+
## 6) Optional full timestamp derivation
111+
112+
If an entry begins with a timestamp prefix, you can derive a full timestamp by combining it with the file date:
113+
114+
- file date `YYYY-MM-DD`
115+
- entry prefix `HH:MM[:SS]+HH:MM` or `HH:MM[:SS]-HH:MM`
116+
117+
Full timestamp:
118+
119+
- `YYYY-MM-DDTHH:MM[:SS]+HH:MM` or `YYYY-MM-DDTHH:MM[:SS]-HH:MM`
120+
121+
Example:
122+
123+
- File: `2025-12-01.md`
124+
- Entry: `09:14:10+01:00 ...`
125+
- Full timestamp: `2025-12-01T09:14:10+01:00`
126+
127+
## 7) CLI append behavior (normative)
128+
129+
When the CLI writes an entry (config is resolved via `simpledoc.json` / `.simpledoc.local.json` if present; see `docs/SIMPLEDOC_CONFIG_SPEC.md`):
130+
131+
1. Determine "now" in the primary timezone from frontmatter (or CLI config).
132+
2. Select file by the local date in that timezone: `YYYY-MM-DD.md`.
133+
3. If the file does not exist, create it with the required frontmatter.
134+
4. Start a new session section when either:
135+
- no section exists yet, or
136+
- the last section start time is older than the threshold (for example, 5 minutes).
137+
The new section title MUST be the current local time in `HH:MM` format.
138+
CLI implementations SHOULD store the section start time in frontmatter as `last_section` and use it for threshold comparisons.
139+
5. Ensure there is a blank line between the last existing line and the new entry.
140+
6. Append the new entry block using the exact input text (no indentation changes).
141+
142+
This guarantees the tool only appends (no in-file insertion) while keeping session grouping.
143+
144+
## 8) Complete example file
145+
146+
`2025-12-01.md`
147+
148+
```md
149+
---
150+
title: Daily Log 2025-12-01
151+
author: Jane Doe <[email protected]>
152+
date: 2025-12-01
153+
tz: Europe/Berlin
154+
created: 2025-12-01T00:00:00+01:00
155+
last_section: 2025-12-01T14:27:00+01:00
156+
---
157+
158+
## 09:13
159+
160+
Checked alerts #ops
161+
162+
[WARN] Elevated error rate service=api code=502
163+
notes="started after deploy"
164+
165+
## 14:03
166+
167+
Deployed v1.8.2 #deploy ticket=ABC-123
168+
169+
## 14:27
170+
171+
Incident review #ops
172+
173+
- suspected cause: cache stampede
174+
- mitigation: rate-limit + warmup
175+
```
176+
177+
## 9) Multiple timezones in one file (optional)
178+
179+
If you need multiple timezones in one file (rare, but possible):
180+
181+
- Keep the frontmatter `tz` as the default.
182+
- Allow an optional zone ID after the offset if you include a timestamp prefix, e.g. `10:00:00+01:00 Europe/Berlin ...`.

0 commit comments

Comments
 (0)