flake-update-20260505
 1#!/usr/bin/env bun
 2/**
 3 * SessionEnd hook — prompt Claude to save a session summary
 4 * to the unified AI storage (~/.local/share/ai/sessions/).
 5 */
 6
 7import { isSubagent, dateStr, yearMonth, now, SESSIONS_DIR } from "./lib.ts";
 8
 9function main() {
10  if (isSubagent()) {
11    process.exit(0);
12  }
13
14  // Ring terminal bell
15  process.stderr.write("\x07");
16
17  const d = now();
18  const ym = yearMonth(d);
19  const ds = dateStr(d);
20  const dir = `~/.local/share/ai/sessions/${ym}`;
21
22  process.stdout.write(`
23---
24
25# Automatic Session Summary
26
27**IMPORTANT**: Please create a session summary and save it to the unified AI storage.
28
29## Instructions
30
31Create a brief summary (2-4 paragraphs) of this session documenting:
32- Primary tasks accomplished
33- Key decisions or solutions
34- Files/systems modified
35- Any remaining work or next steps
36
37Save the summary using the Write tool to:
38\`${dir}/${ds}-<brief-slug>.md\`
39
40**Filename format**: \`YYYY-MM-DD-description-with-dashes.md\`
41- Use only lowercase letters, digits, and dashes
42- Keep description to 3-6 words
43- No underscores, no timestamps beyond the date, no _SESSION_ prefix
44
45**Good examples:**
46- \`${ds}-nix-systems-refactoring.md\`
47- \`${ds}-tekton-pr-review.md\`
48- \`${ds}-pi-extensions-setup.md\`
49
50**Bad examples:**
51- \`${ds}_SESSION_some-thing.md\` (underscore, SESSION prefix)
52- \`${ds}-155616_SESSION_description.md\` (timestamp noise)
53- \`some-thing.md\` (missing date)
54
55Use the **Session Entry** template:
56
57\`\`\`markdown
58# Session: <Description>
59
60**Date:** ${ds}
61**Tool:** claude
62
63## Summary
64Brief description of what was accomplished.
65
66## What Was Accomplished
67- Task 1
68- Task 2
69
70## Files Changed
71- \\\`path/to/file\\\` - Description of change
72
73## Outcome
74Result of the session.
75
76## Next Steps
77- [ ] Follow-up task
78
79### Tags
80#tag1 #tag2
81\`\`\`
82`);
83
84  process.exit(0);
85}
86
87main();