@opentil/cli 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +620 -0
- package/package.json +44 -0
- package/templates/claude-md-section.md +5 -0
- package/templates/cursor-rule.md +4 -0
- package/templates/hooks.json +26 -0
- package/templates/skill/SKILL.md +635 -0
- package/templates/skill/references/api.md +465 -0
- package/templates/skill/references/auto-detection.md +145 -0
- package/templates/skill/references/local-drafts.md +142 -0
- package/templates/skill/references/management.md +779 -0
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: til
|
|
3
|
+
description: >
|
|
4
|
+
Capture and manage TIL (Today I Learned) entries on OpenTIL.
|
|
5
|
+
Use /til <content> to capture, /til to extract insights from conversation,
|
|
6
|
+
or /til list|publish|edit|search|delete|status|sync|tags|categories|batch to
|
|
7
|
+
manage entries -- all without leaving the CLI.
|
|
8
|
+
homepage: https://opentil.ai
|
|
9
|
+
license: MIT
|
|
10
|
+
metadata:
|
|
11
|
+
author: opentil
|
|
12
|
+
version: "1.11.0"
|
|
13
|
+
primaryEnv: OPENTIL_TOKEN
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# til
|
|
17
|
+
|
|
18
|
+
Capture and manage "Today I Learned" entries on OpenTIL -- from drafting to publishing, all within the CLI.
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
1. Go to https://opentil.ai/dashboard/settings/tokens and create a Personal Access Token with `read:entries`, `write:entries`, and `delete:entries` scopes
|
|
23
|
+
2. Copy the token (starts with `til_`)
|
|
24
|
+
3. Set the environment variable:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
export OPENTIL_TOKEN="til_xxx"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Token Resolution
|
|
31
|
+
|
|
32
|
+
Token resolution order:
|
|
33
|
+
1. `$OPENTIL_TOKEN` environment variable (overrides all profiles)
|
|
34
|
+
2. `~/.til/credentials` file — active profile's token (created by `/til auth`)
|
|
35
|
+
|
|
36
|
+
If neither is set, entries are saved locally to `~/.til/drafts/`.
|
|
37
|
+
|
|
38
|
+
### Credential File Format
|
|
39
|
+
|
|
40
|
+
`~/.til/credentials` stores named profiles in YAML:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
active: personal
|
|
44
|
+
profiles:
|
|
45
|
+
personal:
|
|
46
|
+
token: til_abc...
|
|
47
|
+
nickname: hong
|
|
48
|
+
site_url: https://opentil.ai/@hong
|
|
49
|
+
host: https://opentil.ai
|
|
50
|
+
work:
|
|
51
|
+
token: til_xyz...
|
|
52
|
+
nickname: hong-corp
|
|
53
|
+
site_url: https://opentil.ai/@hong-corp
|
|
54
|
+
host: https://opentil.ai
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- `active`: name of the currently active profile
|
|
58
|
+
- `profiles`: map of profile name → credentials
|
|
59
|
+
- Each profile stores: `token`, `nickname` (from API), `site_url`, `host`
|
|
60
|
+
|
|
61
|
+
**Backward compatibility**: If `~/.til/credentials` contains a plain text token (old format), silently migrate it to a `default` profile in YAML format and write back.
|
|
62
|
+
|
|
63
|
+
## Subcommand Routing
|
|
64
|
+
|
|
65
|
+
The first word after `/til` determines the action. Reserved words route to management subcommands; anything else is treated as content to capture.
|
|
66
|
+
|
|
67
|
+
| Invocation | Action |
|
|
68
|
+
|------------|--------|
|
|
69
|
+
| `/til list [drafts\|published\|all]` | List entries (default: drafts) |
|
|
70
|
+
| `/til publish [<id> \| last]` | Publish an entry |
|
|
71
|
+
| `/til unpublish <id>` | Unpublish (revert to draft) |
|
|
72
|
+
| `/til edit <id> [instructions]` | AI-assisted edit |
|
|
73
|
+
| `/til search <keyword>` | Search entries by title |
|
|
74
|
+
| `/til delete <id>` | Delete entry (with confirmation) |
|
|
75
|
+
| `/til status` | Show site status and connection info |
|
|
76
|
+
| `/til sync` | Sync local drafts to OpenTIL |
|
|
77
|
+
| `/til tags` | List site tags with usage counts |
|
|
78
|
+
| `/til categories` | List site categories |
|
|
79
|
+
| `/til batch <topics>` | Batch-capture multiple TIL entries |
|
|
80
|
+
| `/til auth` | Connect OpenTIL account (browser auth) |
|
|
81
|
+
| `/til auth switch [name]` | Switch active profile (by profile name or @nickname) |
|
|
82
|
+
| `/til auth list` | List all profiles |
|
|
83
|
+
| `/til auth remove <name>` | Remove a profile |
|
|
84
|
+
| `/til auth rename <old> <new>` | Rename a profile |
|
|
85
|
+
| `/til <anything else>` | Capture content as a new TIL |
|
|
86
|
+
| `/til` | Extract insights from conversation (multi-candidate) |
|
|
87
|
+
|
|
88
|
+
Reserved words: `list`, `publish`, `unpublish`, `edit`, `search`, `delete`, `status`, `sync`, `tags`, `categories`, `batch`, `auth`.
|
|
89
|
+
|
|
90
|
+
## Reference Loading
|
|
91
|
+
|
|
92
|
+
⚠️ DO NOT read reference files unless specified below. SKILL.md contains enough inline context for most operations.
|
|
93
|
+
|
|
94
|
+
### On subcommand dispatch (load before execution):
|
|
95
|
+
|
|
96
|
+
| Subcommand | References to load |
|
|
97
|
+
|------------|--------------------|
|
|
98
|
+
| `/til <content>` | none |
|
|
99
|
+
| `/til` (extract from conversation) | none |
|
|
100
|
+
| `/til list\|status\|tags\|categories` | [references/management.md](references/management.md) |
|
|
101
|
+
| `/til publish\|unpublish\|edit\|search\|delete\|batch` | [references/management.md](references/management.md) |
|
|
102
|
+
| `/til sync` | [references/management.md](references/management.md), [references/local-drafts.md](references/local-drafts.md) |
|
|
103
|
+
| `/til auth` | [references/management.md](references/management.md), [references/api.md](references/api.md) |
|
|
104
|
+
| `/til auth switch\|list\|remove\|rename` | [references/management.md](references/management.md) |
|
|
105
|
+
|
|
106
|
+
### On-demand (load only when the situation arises):
|
|
107
|
+
|
|
108
|
+
| Trigger | Reference to load |
|
|
109
|
+
|---------|-------------------|
|
|
110
|
+
| API returns non-2xx after inline error handling is insufficient | [references/api.md](references/api.md) |
|
|
111
|
+
| Auto-detection context (proactive TIL suggestion) | [references/auto-detection.md](references/auto-detection.md) |
|
|
112
|
+
| No token found (first-run local fallback) | [references/local-drafts.md](references/local-drafts.md) |
|
|
113
|
+
|
|
114
|
+
## API Quick Reference
|
|
115
|
+
|
|
116
|
+
**Create and publish an entry:**
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
curl -X POST "https://opentil.ai/api/v1/entries" \
|
|
120
|
+
-H "Authorization: Bearer $OPENTIL_TOKEN" \
|
|
121
|
+
-H "Content-Type: application/json" \
|
|
122
|
+
-d '{
|
|
123
|
+
"entry": {
|
|
124
|
+
"title": "Go interfaces are satisfied implicitly",
|
|
125
|
+
"content": "In Go, a type implements an interface...",
|
|
126
|
+
"summary": "Go types implement interfaces implicitly by implementing their methods, with no explicit declaration needed.",
|
|
127
|
+
"tag_names": ["go", "interfaces"],
|
|
128
|
+
"published": true,
|
|
129
|
+
"lang": "en"
|
|
130
|
+
}
|
|
131
|
+
}'
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Key create parameters:**
|
|
135
|
+
|
|
136
|
+
| Field | Type | Required | Description |
|
|
137
|
+
|-------|------|----------|-------------|
|
|
138
|
+
| `content` | string | yes | Markdown body (max 100,000 chars) |
|
|
139
|
+
| `title` | string | no | Entry title (max 200 chars). Auto-generates slug. |
|
|
140
|
+
| `tag_names` | array | no | 1-3 lowercase tags, e.g. `["go", "concurrency"]` |
|
|
141
|
+
| `published` | boolean | no | `false` for draft (default), `true` to publish immediately |
|
|
142
|
+
| `lang` | string | no | Language code: `en`, `zh-CN`, `zh-TW`, `ja`, `ko`, etc. |
|
|
143
|
+
| `slug` | string | no | Custom URL slug. Auto-generated from title if omitted. |
|
|
144
|
+
| `visibility` | string | no | `public` (default), `unlisted`, or `private` |
|
|
145
|
+
| `summary` | string | no | AI-generated summary for listing pages (max 500 chars) |
|
|
146
|
+
|
|
147
|
+
**Management endpoints:**
|
|
148
|
+
|
|
149
|
+
| Endpoint | Method | Description |
|
|
150
|
+
|----------|--------|-------------|
|
|
151
|
+
| `/entries?status=draft&q=keyword` | GET | List/search entries |
|
|
152
|
+
| `/entries/:id` | GET | Get a single entry |
|
|
153
|
+
| `/entries/:id` | PATCH | Update entry fields |
|
|
154
|
+
| `/entries/:id` | DELETE | Permanently delete entry |
|
|
155
|
+
| `/entries/:id/publish` | POST | Publish a draft |
|
|
156
|
+
| `/entries/:id/unpublish` | POST | Revert to draft |
|
|
157
|
+
| `/site` | GET | Site info (username, entry counts, etc.) |
|
|
158
|
+
| `/tags?sort=popular` | GET | List tags with usage counts |
|
|
159
|
+
| `/categories` | GET | List categories with entry counts |
|
|
160
|
+
|
|
161
|
+
> Full parameter list, response format, and error handling: see references/api.md
|
|
162
|
+
|
|
163
|
+
## Execution Flow
|
|
164
|
+
|
|
165
|
+
Every `/til` invocation follows this flow:
|
|
166
|
+
|
|
167
|
+
1. **Generate** -- craft the TIL entry (title, body, summary, tags, lang)
|
|
168
|
+
2. **Check token** -- resolve token (env var → active profile in `~/.til/credentials`)
|
|
169
|
+
- If `~/.til/credentials` exists in old plain-text format, migrate to YAML `default` profile first
|
|
170
|
+
- **Found** -> POST to API with `published: true` -> show published URL
|
|
171
|
+
- **Not found** -> save to `~/.til/drafts/` -> show first-run guide with connect prompt
|
|
172
|
+
- **401 response** -> save locally -> inline re-authentication (see Error Handling):
|
|
173
|
+
- Token from `~/.til/credentials` (active profile) or no prior token: prompt to reconnect via device flow → on success, update the active profile's token and auto-retry the original operation
|
|
174
|
+
- Token from `$OPENTIL_TOKEN` env var: cannot auto-fix — guide user to update/unset the variable
|
|
175
|
+
3. **Show identity** -- when ≥2 profiles are configured, include `Account: @nickname (profile_name)` in result messages so the user always knows which account was used
|
|
176
|
+
4. **Never lose content** -- the entry is always persisted somewhere
|
|
177
|
+
5. **On API failure** -> save locally as draft (fallback unchanged)
|
|
178
|
+
|
|
179
|
+
## `/til <content>` -- Explicit Capture
|
|
180
|
+
|
|
181
|
+
The user's input is **raw material** -- a seed, not the final entry. Generate a complete TIL from it:
|
|
182
|
+
|
|
183
|
+
- Short input (a sentence or phrase) -> expand into a full entry with context and examples
|
|
184
|
+
- Long input (a paragraph or more) -> refine and structure, but preserve the user's intent
|
|
185
|
+
|
|
186
|
+
**Steps:**
|
|
187
|
+
|
|
188
|
+
1. Treat the user's input as a seed -- craft a complete title + body from it
|
|
189
|
+
2. Generate a concise title (5-15 words) in the same language as the content
|
|
190
|
+
3. Write a self-contained Markdown body (see Content Guidelines below)
|
|
191
|
+
4. Generate a summary (see Summary Guidelines below)
|
|
192
|
+
5. Infer 1-3 lowercase tags from technical domain (e.g. `rails`, `postgresql`, `go`)
|
|
193
|
+
6. Detect language -> set `lang` (`en`, `zh-CN`, `zh-TW`, `ja`, `ko`, `es`, `fr`, `de`, `pt-BR`, `pt`, `ru`, `ar`, `bs`, `da`, `nb`, `pl`, `th`, `tr`, `it`)
|
|
194
|
+
7. Follow Execution Flow above (check token -> POST or save locally)
|
|
195
|
+
|
|
196
|
+
No confirmation needed -- the user explicitly asked to capture. Execute directly.
|
|
197
|
+
|
|
198
|
+
## `/til` -- Extract from Conversation
|
|
199
|
+
|
|
200
|
+
When `/til` is used without arguments, analyze the current conversation for learnable insights.
|
|
201
|
+
|
|
202
|
+
**Steps:**
|
|
203
|
+
|
|
204
|
+
1. Scan the conversation for knowledge worth preserving -- surprising facts, useful techniques, debugging breakthroughs, "aha" moments
|
|
205
|
+
2. Identify **all** TIL-worthy insights (not just one), up to 5
|
|
206
|
+
3. Branch based on count:
|
|
207
|
+
|
|
208
|
+
**0 insights:**
|
|
209
|
+
```
|
|
210
|
+
No clear TIL insights found in this conversation.
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**1 insight:** Generate the full draft (title, body, tags), show it, ask for confirmation. On confirmation -> follow Execution Flow.
|
|
214
|
+
|
|
215
|
+
**2+ insights:** Show a numbered list (max 5), let the user choose:
|
|
216
|
+
```
|
|
217
|
+
Found 3 TIL-worthy insights:
|
|
218
|
+
|
|
219
|
+
1. Go interfaces are satisfied implicitly
|
|
220
|
+
2. PostgreSQL JSONB arrays don't support GIN @>
|
|
221
|
+
3. CSS :has() enables parent selection
|
|
222
|
+
|
|
223
|
+
Which to capture? (1/2/3/all/none)
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
- Single number -> generate draft for that insight, show confirmation, proceed
|
|
227
|
+
- Comma-separated list (e.g. `1,3`) -> generate drafts for selected, show all for confirmation, POST sequentially
|
|
228
|
+
- `all` -> generate drafts for each, show all for confirmation, POST sequentially
|
|
229
|
+
- `none` -> cancel
|
|
230
|
+
|
|
231
|
+
4. For each selected insight, generate a standalone TIL entry following Content Guidelines
|
|
232
|
+
5. **Show the generated entry to the user and ask for confirmation before proceeding**
|
|
233
|
+
6. On confirmation -> follow Execution Flow above (check token -> POST or save locally)
|
|
234
|
+
|
|
235
|
+
## Auto-Detection
|
|
236
|
+
|
|
237
|
+
When working alongside a user, proactively detect moments worth capturing as TIL entries.
|
|
238
|
+
|
|
239
|
+
### When to Suggest
|
|
240
|
+
|
|
241
|
+
Suggest when the conversation produces a genuine "aha" moment — something surprising, non-obvious, or worth remembering. Examples:
|
|
242
|
+
|
|
243
|
+
- Debugging uncovered a non-obvious root cause
|
|
244
|
+
- A language/framework behavior contradicted common assumptions
|
|
245
|
+
- Refactoring revealed a clearly superior pattern
|
|
246
|
+
- Performance optimization yielded measurable improvement
|
|
247
|
+
- An obscure but useful tool flag or API parameter was discovered
|
|
248
|
+
- Two technologies interacting produced unexpected behavior
|
|
249
|
+
|
|
250
|
+
Do NOT suggest for: standard tool usage, documented behavior, typo-caused bugs, or widely known best practices.
|
|
251
|
+
|
|
252
|
+
### Rate Limiting
|
|
253
|
+
|
|
254
|
+
1. **Once per session** — after suggesting once (accepted or declined), never suggest again
|
|
255
|
+
2. **Natural pauses only** — suggest at resolution points or task boundaries, never mid-problem-solving
|
|
256
|
+
3. **Respect rejection** — if declined, move on without persuasion
|
|
257
|
+
|
|
258
|
+
### Suggestion Format
|
|
259
|
+
|
|
260
|
+
Append at the end of your normal response. Never interrupt workflow.
|
|
261
|
+
|
|
262
|
+
**Template:**
|
|
263
|
+
```
|
|
264
|
+
💡 TIL: [concise title of the insight]
|
|
265
|
+
Tags: [tag1, tag2] · Capture? (yes/no)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
**Example** (at the end of a debugging response):
|
|
269
|
+
```
|
|
270
|
+
...so the fix is to close the channel before the goroutine exits.
|
|
271
|
+
|
|
272
|
+
💡 TIL: Unclosed Go channels in goroutines cause silent memory leaks
|
|
273
|
+
Tags: go, concurrency · Capture? (yes/no)
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Capture Flow
|
|
277
|
+
|
|
278
|
+
Auto-detected TILs bypass the extract flow. The suggestion itself is the candidate.
|
|
279
|
+
|
|
280
|
+
1. User replies `yes` / `y` / `ok` / `sure` → agent generates full entry (title, body, tags, lang) from the suggested insight → follows Execution Flow (POST or save locally)
|
|
281
|
+
2. User replies `no` / ignores / continues other topic → move on, do not ask again
|
|
282
|
+
|
|
283
|
+
Non-affirmative responses (continuing the conversation about something else) are treated as implicit decline.
|
|
284
|
+
|
|
285
|
+
> Detailed trigger examples, state machine, and anti-patterns: see references/auto-detection.md
|
|
286
|
+
|
|
287
|
+
## Management Subcommands
|
|
288
|
+
|
|
289
|
+
Management subcommands require a token. There is no local fallback -- management operations need the API.
|
|
290
|
+
|
|
291
|
+
### `/til list [drafts|published|all]`
|
|
292
|
+
|
|
293
|
+
List entries. Default filter: `drafts`.
|
|
294
|
+
|
|
295
|
+
- API: `GET /entries?status=<filter>&per_page=10`
|
|
296
|
+
- Display as a compact table with short IDs (last 8 chars, prefixed with `...`)
|
|
297
|
+
- Show pagination info at the bottom
|
|
298
|
+
|
|
299
|
+
### `/til publish [<id> | last]`
|
|
300
|
+
|
|
301
|
+
Publish a draft entry.
|
|
302
|
+
|
|
303
|
+
- `last` resolves to the most recently created entry in this session (tracked via `last_created_entry_id` set on every successful POST)
|
|
304
|
+
- Fetch the entry first, show title/tags, ask for confirmation
|
|
305
|
+
- On success, display the published URL
|
|
306
|
+
- If already published, show informational message (not an error)
|
|
307
|
+
|
|
308
|
+
### `/til unpublish <id>`
|
|
309
|
+
|
|
310
|
+
Revert a published entry to draft.
|
|
311
|
+
|
|
312
|
+
- Fetch the entry first, confirm before unpublishing
|
|
313
|
+
- If already a draft, show informational message
|
|
314
|
+
|
|
315
|
+
### `/til edit <id> [instructions]`
|
|
316
|
+
|
|
317
|
+
AI-assisted editing of an existing entry.
|
|
318
|
+
|
|
319
|
+
- Fetch the full entry via `GET /entries/:id`
|
|
320
|
+
- Apply changes based on instructions (or ask what to change if none given)
|
|
321
|
+
- Show a diff preview of proposed changes
|
|
322
|
+
- On confirmation, `PATCH /entries/:id` with only the changed fields
|
|
323
|
+
|
|
324
|
+
### `/til search <keyword>`
|
|
325
|
+
|
|
326
|
+
Search entries by title.
|
|
327
|
+
|
|
328
|
+
- API: `GET /entries?q=<keyword>&per_page=10`
|
|
329
|
+
- Same compact table format as `list`
|
|
330
|
+
|
|
331
|
+
### `/til delete <id>`
|
|
332
|
+
|
|
333
|
+
Permanently delete an entry.
|
|
334
|
+
|
|
335
|
+
- Fetch the entry, show title and status
|
|
336
|
+
- Double-confirm: "This cannot be undone. Type 'delete' to confirm."
|
|
337
|
+
- On confirmation, `DELETE /entries/:id`
|
|
338
|
+
|
|
339
|
+
### `/til status`
|
|
340
|
+
|
|
341
|
+
Show site status and connection info. **Works without a token** (degraded display).
|
|
342
|
+
|
|
343
|
+
- With token: `GET /site` -> show username, entry breakdown (total/published/drafts), token status, local draft count, dashboard link
|
|
344
|
+
- Without token: show "not connected", local draft count, setup link
|
|
345
|
+
|
|
346
|
+
### `/til sync`
|
|
347
|
+
|
|
348
|
+
Explicitly sync local drafts from `~/.til/drafts/` to OpenTIL. Requires token.
|
|
349
|
+
|
|
350
|
+
- List pending drafts, POST each one, delete local file on success
|
|
351
|
+
- Show summary with success/failure per draft
|
|
352
|
+
|
|
353
|
+
### `/til tags`
|
|
354
|
+
|
|
355
|
+
List site tags sorted by usage count (top 20). Requires token.
|
|
356
|
+
|
|
357
|
+
- API: `GET /tags?sort=popular&per_page=20&with_entries=true`
|
|
358
|
+
- Show as compact table with tag name and entry count
|
|
359
|
+
|
|
360
|
+
### `/til categories`
|
|
361
|
+
|
|
362
|
+
List site categories. Requires token.
|
|
363
|
+
|
|
364
|
+
- API: `GET /categories`
|
|
365
|
+
- Show as compact table with name, entry count, and description
|
|
366
|
+
|
|
367
|
+
### `/til batch <topics>`
|
|
368
|
+
|
|
369
|
+
Batch-capture multiple TIL entries in one invocation. Requires explicit topic list.
|
|
370
|
+
|
|
371
|
+
- User lists topics separated by newlines, semicolons, or markdown list items (`-` / `1.`)
|
|
372
|
+
- Generate a draft for each -> show all drafts for confirmation -> POST sequentially
|
|
373
|
+
- On partial failure, show per-entry success/failure (same format as `/til sync`)
|
|
374
|
+
|
|
375
|
+
### ID Resolution
|
|
376
|
+
|
|
377
|
+
- In listings, show IDs in short form: `...` + last 8 characters
|
|
378
|
+
- Accept both short and full IDs as input
|
|
379
|
+
- Resolve short IDs by suffix match against the current listing
|
|
380
|
+
- If ambiguous (multiple matches), ask for clarification
|
|
381
|
+
|
|
382
|
+
### Session State
|
|
383
|
+
|
|
384
|
+
Track the following session state (not persisted across sessions):
|
|
385
|
+
- `last_created_entry_id` -- set on every successful `POST /entries` (201). Used by `/til publish last`.
|
|
386
|
+
- `active_profile` -- the profile name resolved at first token access. Reflects the `active` field from `~/.til/credentials` (or `$OPENTIL_TOKEN` override). Used for identity display and draft attribution.
|
|
387
|
+
|
|
388
|
+
> Detailed subcommand flows, display formats, and error handling: see references/management.md
|
|
389
|
+
|
|
390
|
+
## Agent Identity
|
|
391
|
+
|
|
392
|
+
Three layers of attribution signal distinguish human-initiated from agent-initiated TILs.
|
|
393
|
+
|
|
394
|
+
### Layer 1: HTTP Headers
|
|
395
|
+
|
|
396
|
+
Include these headers on every API call:
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
X-OpenTIL-Source: human | agent
|
|
400
|
+
X-OpenTIL-Agent: <your agent display name>
|
|
401
|
+
X-OpenTIL-Model: <human-readable model name>
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
- Source: `/til <content>` and `/til` -> `human`; Auto-detected -> `agent`
|
|
405
|
+
- Agent: use your tool's display name (e.g. `Claude Code`, `Cursor`, `GitHub Copilot`). Do not use a slug.
|
|
406
|
+
- Model: use a human-readable model name (e.g. `Claude Opus 4.6`, `GPT-4o`, `Gemini 2.5 Pro`). Do not use a model ID.
|
|
407
|
+
- Agent and Model are optional -- omit them if you are unsure.
|
|
408
|
+
|
|
409
|
+
### Layer 2: Tag Convention
|
|
410
|
+
|
|
411
|
+
- Auto-detected TILs: automatically add `agent-assisted` to the tag list
|
|
412
|
+
- `/til <content>` and `/til`: do **not** add the tag (unless the Agent substantially rewrote the content)
|
|
413
|
+
|
|
414
|
+
### Layer 3: Attribution Rendering (Backend)
|
|
415
|
+
|
|
416
|
+
Agent-initiated TILs are visually marked on OpenTIL automatically based on the
|
|
417
|
+
`source` field. No content modification needed -- the backend renders attribution
|
|
418
|
+
in the display layer.
|
|
419
|
+
|
|
420
|
+
- Public page: shows `✨ via {agent_name}`, or `✨ AI` when agent_name is absent
|
|
421
|
+
- Tooltip (hover): shows `{agent_name} · {model}` when both are present
|
|
422
|
+
- Dashboard: shows ✨ badge + agent_name, or "Agent" when agent_name is absent
|
|
423
|
+
|
|
424
|
+
Do NOT append any footer or attribution text to the content body.
|
|
425
|
+
|
|
426
|
+
### Summary
|
|
427
|
+
|
|
428
|
+
| Dimension | `/til <content>` | `/til` | Auto-detected |
|
|
429
|
+
|-----------|-----------------|--------|---------------|
|
|
430
|
+
| Trigger | User explicit | User command | Agent proactive |
|
|
431
|
+
| Confirmations | 0 (direct publish) | 1 (review before publish) | 1 (suggest → capture) |
|
|
432
|
+
| Source header | `human` | `human` | `agent` |
|
|
433
|
+
| Agent header | Yes | Yes | Yes |
|
|
434
|
+
| Model header | Yes | Yes | Yes |
|
|
435
|
+
| `agent-assisted` tag | No | No | Yes |
|
|
436
|
+
| Attribution | Automatic (backend) | Automatic (backend) | Automatic (backend) |
|
|
437
|
+
|
|
438
|
+
## Content Guidelines
|
|
439
|
+
|
|
440
|
+
Every TIL entry must follow these rules:
|
|
441
|
+
|
|
442
|
+
- **Self-contained**: The reader must understand the entry without any conversation context. Never write "as we discussed", "the above error", "this project's config", etc.
|
|
443
|
+
- **Desensitized**: Remove project names, company details, colleague names, internal URLs, and proprietary business logic. Generalize specifics: "our User model" -> "a model", "the production server" -> "a production environment", "the Acme payment service" -> "a payment gateway".
|
|
444
|
+
- **Universally valuable**: Write to StackOverflow-answer standards. A stranger searching for this topic should find the entry immediately useful. Content only useful to the author belongs in private notes, not TIL.
|
|
445
|
+
- **Factual tone**: State facts, show examples, explain why. Avoid first-person narrative ("I was debugging...", "I discovered..."). Exception: brief situational context is fine ("When upgrading Rails from 7.2 to 8.0...").
|
|
446
|
+
- **One insight per entry**: Each TIL teaches exactly ONE thing. If there are multiple insights, create separate entries.
|
|
447
|
+
- **Concrete examples**: Include code snippets, commands, or specific data whenever relevant. Avoid vague descriptions.
|
|
448
|
+
- **Title**: 5-15 words. Descriptive, same language as content. No "TIL:" prefix.
|
|
449
|
+
- **Content**: Use the most efficient format for the knowledge — tables for comparisons, code blocks for examples, lists for enumerations, math (`$inline$` / `$$display$$`) for formulas with fractions/subscripts/superscripts/greek letters, Mermaid diagrams (` ```mermaid `) for flows/states/sequences that text cannot clearly express. Simple expressions like `O(n)` stay as inline code; use math only when notation complexity warrants it. Only use prose when explaining causation or context. Never pad content; if one sentence suffices, don't write a paragraph.
|
|
450
|
+
- **Tags**: 1-3 lowercase tags from the technical domain (`go`, `rails`, `postgresql`, `css`, `linux`). No generic tags like `programming` or `til`.
|
|
451
|
+
- **Lang**: Detect from content. Chinese -> `zh-CN`, Traditional Chinese -> `zh-TW`, English -> `en`, Japanese -> `ja`, Korean -> `ko`.
|
|
452
|
+
- **Category**: Do not auto-infer `category_name` -- only include it if the user explicitly specifies a category/topic.
|
|
453
|
+
- **Summary**: 1-2 sentences, plain text (no markdown). Max 500 chars and must be shorter than the content body. Same language as content. Self-contained: the reader should understand the core takeaway from the summary alone. Be specific about what the reader will learn, not meta ("this article discusses..."). No first person, no meta-descriptions. Omit if the content is already very short (under ~200 chars) -- the excerpt fallback is sufficient.
|
|
454
|
+
|
|
455
|
+
## Result Messages
|
|
456
|
+
|
|
457
|
+
### API Success (token configured, 201)
|
|
458
|
+
|
|
459
|
+
```
|
|
460
|
+
Published to OpenTIL
|
|
461
|
+
|
|
462
|
+
Title: Go interfaces are satisfied implicitly
|
|
463
|
+
Tags: go, interfaces
|
|
464
|
+
URL: https://opentil.ai/@username/go-interfaces-are-satisfied-implicitly
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
When ≥2 profiles are configured, add an `Account` line:
|
|
468
|
+
|
|
469
|
+
```
|
|
470
|
+
Published to OpenTIL
|
|
471
|
+
|
|
472
|
+
Account: @hong (personal)
|
|
473
|
+
Title: Go interfaces are satisfied implicitly
|
|
474
|
+
Tags: go, interfaces
|
|
475
|
+
URL: https://opentil.ai/@hong/go-interfaces-are-satisfied-implicitly
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Single-profile users see no `Account` line — keep the output clean.
|
|
479
|
+
|
|
480
|
+
Extract the `url` field from the API response for the URL.
|
|
481
|
+
|
|
482
|
+
### Sync Local Drafts
|
|
483
|
+
|
|
484
|
+
After the first successful API call, check `~/.til/drafts/` for pending files. If any exist, offer to sync:
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
Draft saved to OpenTIL
|
|
488
|
+
|
|
489
|
+
Title: Go interfaces are satisfied implicitly
|
|
490
|
+
Tags: go, interfaces
|
|
491
|
+
Review: https://opentil.ai/@username/go-interfaces-are-satisfied-implicitly
|
|
492
|
+
|
|
493
|
+
Found 3 local drafts from before. Sync them to OpenTIL?
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
On confirmation, POST each draft to the API. Delete the local file after each successful sync. Keep files that fail. Show summary:
|
|
497
|
+
|
|
498
|
+
```
|
|
499
|
+
Synced 3 local drafts to OpenTIL
|
|
500
|
+
|
|
501
|
+
+ Go defer runs in LIFO order
|
|
502
|
+
+ PostgreSQL JSONB indexes support GIN operators
|
|
503
|
+
+ CSS :has() selector enables parent selection
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
If the user declines, keep the local files and do not ask again in this session.
|
|
507
|
+
|
|
508
|
+
### First Run (no token)
|
|
509
|
+
|
|
510
|
+
Save the draft locally, then proactively offer to connect. This is NOT an error -- the user successfully captured a TIL.
|
|
511
|
+
|
|
512
|
+
```
|
|
513
|
+
TIL captured
|
|
514
|
+
|
|
515
|
+
Title: Go interfaces are satisfied implicitly
|
|
516
|
+
Tags: go, interfaces
|
|
517
|
+
File: ~/.til/drafts/20260210-143022-go-interfaces.md
|
|
518
|
+
|
|
519
|
+
Connect to OpenTIL to publish entries online.
|
|
520
|
+
Connect now? (y/n)
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
- `y` → run inline device flow (same as `/til auth`) → on success, sync the just-saved draft + any other pending drafts in `~/.til/drafts/`
|
|
524
|
+
- `n` → show manual setup instructions (see Manual Setup Instructions below)
|
|
525
|
+
|
|
526
|
+
Only show the connect prompt on the **first** local save in this session. On subsequent saves, use the short form (no prompt):
|
|
527
|
+
|
|
528
|
+
```
|
|
529
|
+
TIL captured
|
|
530
|
+
|
|
531
|
+
Title: Go interfaces are satisfied implicitly
|
|
532
|
+
Tags: go, interfaces
|
|
533
|
+
File: ~/.til/drafts/20260210-143022-go-interfaces.md
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## Error Handling
|
|
537
|
+
|
|
538
|
+
**On ANY API failure, always save the draft locally first.** Never let user content be lost.
|
|
539
|
+
|
|
540
|
+
**422 -- Validation error:** Analyze the error response, fix the issue (e.g. truncate title to 200 chars, correct lang code), and retry. Only save locally if the retry also fails.
|
|
541
|
+
|
|
542
|
+
**401 -- Token invalid or expired (token from `~/.til/credentials` active profile):**
|
|
543
|
+
|
|
544
|
+
```
|
|
545
|
+
TIL captured (saved locally)
|
|
546
|
+
|
|
547
|
+
File: ~/.til/drafts/20260210-143022-go-interfaces.md
|
|
548
|
+
|
|
549
|
+
Token expired for @hong (personal). Reconnect now? (y/n)
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
- `y` → run inline device flow (same as `/til auth`) → on success, update the active profile's token in `~/.til/credentials` and auto-retry the original POST (publish the just-saved draft, then delete the local file)
|
|
553
|
+
- `n` → show manual setup instructions (see Manual Setup Instructions below)
|
|
554
|
+
|
|
555
|
+
When only one profile exists, omit the `@nickname (profile)` from the message.
|
|
556
|
+
|
|
557
|
+
**401 -- Token invalid or expired (token from `$OPENTIL_TOKEN` env var):**
|
|
558
|
+
|
|
559
|
+
The env var takes priority over `~/.til/credentials`, so saving a new token via device flow would not help — the env var would still be used. Guide the user instead:
|
|
560
|
+
|
|
561
|
+
```
|
|
562
|
+
TIL captured (saved locally)
|
|
563
|
+
|
|
564
|
+
File: ~/.til/drafts/20260210-143022-go-interfaces.md
|
|
565
|
+
|
|
566
|
+
Your $OPENTIL_TOKEN is expired or invalid. To fix:
|
|
567
|
+
• Update the variable with a new token, or
|
|
568
|
+
• unset OPENTIL_TOKEN, then run /til auth
|
|
569
|
+
|
|
570
|
+
Create a new token: https://opentil.ai/dashboard/settings/tokens
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
**Network failure or 5xx:**
|
|
574
|
+
|
|
575
|
+
```
|
|
576
|
+
TIL captured (saved locally -- API unavailable)
|
|
577
|
+
|
|
578
|
+
File: ~/.til/drafts/20260210-143022-go-interfaces.md
|
|
579
|
+
```
|
|
580
|
+
|
|
581
|
+
> Full error codes, 422 auto-fix logic, and rate limit details: see references/api.md
|
|
582
|
+
|
|
583
|
+
### Re-authentication Safeguards
|
|
584
|
+
|
|
585
|
+
| Rule | Behavior |
|
|
586
|
+
|------|----------|
|
|
587
|
+
| No retry loops | If re-auth succeeds but the retry still returns 401 → stop and show the error. Do not re-authenticate again. |
|
|
588
|
+
| Batch-aware | During batch/sync operations, re-authenticate at most once. On success, continue processing remaining items with the new token. |
|
|
589
|
+
| Respect refusal | If the user declines re-authentication (`n`), do not prompt again for the rest of this session. Use the short local-save format silently. |
|
|
590
|
+
| Env var awareness | When the active token comes from `$OPENTIL_TOKEN`, never attempt device flow — it cannot override the env var. Always show the env var guidance instead. |
|
|
591
|
+
| Profile-aware re-auth | On successful re-authentication, update the corresponding profile's token in `~/.til/credentials`. Do not create a new profile. |
|
|
592
|
+
|
|
593
|
+
### Manual Setup Instructions
|
|
594
|
+
|
|
595
|
+
When the user declines inline authentication (answers `n`), show:
|
|
596
|
+
|
|
597
|
+
```
|
|
598
|
+
Or set up manually:
|
|
599
|
+
1. Visit https://opentil.ai/dashboard/settings/tokens
|
|
600
|
+
2. Create a token (select read + write + delete scopes)
|
|
601
|
+
3. Add to shell profile:
|
|
602
|
+
export OPENTIL_TOKEN="til_..."
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
## Local Draft Fallback
|
|
606
|
+
|
|
607
|
+
When the API is unavailable or no token is configured, drafts are saved locally to `~/.til/drafts/`.
|
|
608
|
+
|
|
609
|
+
**File format:** `YYYYMMDD-HHMMSS-<slug>.md`
|
|
610
|
+
|
|
611
|
+
```markdown
|
|
612
|
+
---
|
|
613
|
+
title: "Go interfaces are satisfied implicitly"
|
|
614
|
+
tags: [go, interfaces]
|
|
615
|
+
lang: en
|
|
616
|
+
summary: "Go types implement interfaces implicitly by implementing their methods, with no explicit declaration needed."
|
|
617
|
+
profile: personal
|
|
618
|
+
---
|
|
619
|
+
|
|
620
|
+
In Go, a type implements an interface...
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
The `profile` field records the active profile name at save time, ensuring sync uses the correct account's token. Omitted when no profiles are configured (backward-compatible).
|
|
624
|
+
|
|
625
|
+
> Full directory structure, metadata fields, and sync protocol: see references/local-drafts.md
|
|
626
|
+
|
|
627
|
+
## Notes
|
|
628
|
+
|
|
629
|
+
- **UI language adaptation**: All prompts, result messages, and error messages in this document are written in English as canonical examples. At runtime, adapt them to match the user's language in the current session (e.g. if the user writes in Chinese, display messages in Chinese). Entry content language (`lang` field) is independent -- it is always detected from the content itself.
|
|
630
|
+
- Entries are published immediately by default (`published: true`) -- use `/til unpublish <id>` to revert to draft
|
|
631
|
+
- The API auto-generates a URL slug from the title
|
|
632
|
+
- Tags are created automatically if they don't exist on the site
|
|
633
|
+
- Content is rendered to HTML server-side (GFM Markdown with syntax highlighting, KaTeX math, and Mermaid diagrams)
|
|
634
|
+
- Management subcommands (`list`, `publish`, `edit`, `search`, `delete`, `tags`, `categories`, `sync`, `batch`) require a token -- no local fallback. Exception: `status` and `auth` (including `auth switch`, `auth list`, `auth remove`, `auth rename`) work without a token.
|
|
635
|
+
- Scope errors map to specific scopes: `list`/`search`/`tags`/`categories` need `read:entries`, `publish`/`unpublish`/`edit`/`sync`/`batch` need `write:entries`, `delete` needs `delete:entries`. `status` uses `read:entries` when available but works without a token.
|