-
Notifications
You must be signed in to change notification settings - Fork 14
refactor: simplify notes skill scripts with standardized output format #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # list-topics - List all topic directories (non-underscore top-level folders) | ||
| # Usage: list-topics | ||
| # Output: One topic name per line | ||
|
|
||
| # Get the directory where this script is located | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| # Validate and get notes directory | ||
| NOTES_DIR=$("$SCRIPT_DIR/echo-notes-dir.sh") | ||
|
|
||
| # Find all top-level directories that don't start with underscore | ||
| # -maxdepth 1: only top level | ||
| # -type d: directories only | ||
| # -not -name '_*': exclude underscore-prefixed | ||
| # -not -name '.': exclude current dir | ||
| # -not -name '.*': exclude hidden dirs | ||
| # Note: Trailing slash needed for symlink support | ||
| topics=$(find "$NOTES_DIR/" -maxdepth 1 -type d \ | ||
| -not -name '_*' \ | ||
| -not -name '.' \ | ||
| -not -name '.*' \ | ||
| -printf '%f\n' | sort) | ||
|
|
||
| # Count and output with summary | ||
| count=$(echo "$topics" | grep -c '^' || echo "0") | ||
|
|
||
| if [ "$count" -eq 0 ]; then | ||
| echo "No topics found." | ||
| else | ||
| echo "Found $count topic(s):" | ||
| echo "" | ||
| echo "$topics" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Notes Directory Layout | ||
|
|
||
| **Notes directory:** !`./.claude/skills/_shared/notes/echo-notes-dir.sh` | ||
|
|
||
| ## Folder Structure | ||
|
|
||
| ``` | ||
| ./.notes/ | ||
| ├── [topic]/ # Topic-based folders (e.g., pgflow-demo, ci-optimization) | ||
| │ ├── WIP-*.md # Work in progress (quick captures, drafts) | ||
| │ └── *.md # Refined notes (ready to use) | ||
| │ | ||
| ├── _archive/ # Archived/completed work | ||
| │ └── [topic]/ # Organized by original topic | ||
| │ | ||
| ├── _reference/ # Knowledge base (optional) | ||
| │ └── *.md # Reference docs, guides, non-actionable info | ||
| │ | ||
| └── roadmap.md # (optional) Project roadmap | ||
| ``` | ||
|
|
||
| ## File Naming | ||
|
|
||
| - **WIP prefix**: `WIP-descriptive-name.md` for work in progress | ||
| - **No prefix**: `descriptive-name.md` for refined notes | ||
| - **Kebab-case**: Use hyphens, lowercase, no spaces | ||
| - **Extension**: Always `.md` | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. **Capture**: Create `[topic]/WIP-note.md` (note-capture skill) | ||
| 2. **Refine**: Edit and improve over time (note-refine skill) | ||
| 3. **Finalize**: Remove WIP prefix when ready (note-organize skill) | ||
| 4. **Archive**: Move to `_archive/[topic]/` when done (note-organize skill) | ||
|
|
||
| ## Important Notes | ||
|
|
||
| - Always use `./.notes/` (relative to repo root) | ||
| - Working directory (`$PWD`) must be repository root | ||
| - Use relative paths for scripts: `./.claude/skills/_shared/notes/` | ||
| - Topics are inferred from folder names (use `list-topics.sh` script) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # summarize-notes - Add AI summaries to note listings | ||
| # Usage: list-titles.sh scratch/ | summarize-notes.sh | ||
| # or: search-notes.sh "pattern" | summarize-notes.sh | ||
| # | ||
| # Expected input format: | ||
| # Line 1: Header (e.g., "PATH | TITLE") | ||
| # Line 2+: Data rows (e.g., ".notes/foo.md | My Note") | ||
| # If only header exists (no data rows), means no notes found | ||
| # | ||
| # Adds SUMMARY column with fast AI-generated summaries (parallel processing) | ||
|
|
||
| # Model and prompt | ||
| MODEL="groq:meta-llama/llama-4-scout-17b-16e-instruct" | ||
| PROMPT="summarize this file in two sentences, only output summary" | ||
|
|
||
| # Check if 'parallel' is available | ||
| if ! command -v parallel &> /dev/null; then | ||
| echo "Error: GNU parallel not installed. Install with: sudo pacman -S parallel" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Check if 'aichat' command is available | ||
| if ! command -v aichat &> /dev/null; then | ||
| echo "Error: 'aichat' command not found. Make sure it's installed and in PATH." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Process a single line | ||
| process_line() { | ||
| local line="$1" | ||
| local line_number="$2" | ||
| # Use exported MODEL and PROMPT environment variables | ||
|
|
||
| # First line is always the header - append SUMMARY column | ||
| if [ "$line_number" -eq 1 ]; then | ||
| echo "$line | SUMMARY" | ||
| return | ||
| fi | ||
|
|
||
| # Extract path (everything before first |) | ||
| local path="${line%%|*}" | ||
| # Trim whitespace (bash parameter expansion) | ||
| path="${path#"${path%%[![:space:]]*}"}" | ||
| path="${path%"${path##*[![:space:]]}"}" | ||
|
|
||
| # Skip if file doesn't exist | ||
| if [ ! -f "$path" ]; then | ||
| return # Skip failed files silently | ||
| fi | ||
|
|
||
| # Get summary (pass prompt as separate words, not quoted) | ||
| local summary | ||
| summary=$(aichat --model "$MODEL" -f "$path" $PROMPT 2>/dev/null || echo "") | ||
|
|
||
| # Skip if summary failed | ||
| if [ -z "$summary" ]; then | ||
| return | ||
| fi | ||
|
|
||
| # Collapse multiline to single line (replace newlines with spaces, collapse multiple spaces) | ||
| summary=$(echo "$summary" | tr '\n' ' ' | sed 's/ */ /g') | ||
| # Trim whitespace (bash parameter expansion) | ||
| summary="${summary#"${summary%%[![:space:]]*}"}" | ||
| summary="${summary%"${summary##*[![:space:]]}"}" | ||
|
|
||
| # Append summary | ||
| echo "$line | $summary" | ||
| } | ||
|
|
||
| export -f process_line | ||
| export MODEL PROMPT | ||
|
|
||
| # Read stdin, number lines, and process in parallel (16 jobs) | ||
| cat -n | parallel -j 16 --keep-order --colsep '\t' process_line {2} {1} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## Available Topics | ||
|
|
||
| !`./.claude/skills/_shared/notes/list-topics.sh` |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| --- | ||
| name: note-capture | ||
| description: Save conversation context to topic notes. Use when user says "capture note [about X]", "save to notes", "create note [in topic]", "note this [for topic]", "add note to [topic]". IMPORTANT - User must say "note" or "notes" explicitly. | ||
| allowed-tools: Write, Bash, AskUserQuestion | ||
| --- | ||
|
|
||
| # Note Capture | ||
|
|
||
| Save conversation context to `.notes/[topic]/WIP-[name].md` | ||
|
|
||
| @../_shared/notes/topics.md | ||
|
|
||
| <critical> | ||
| - ALWAYS use AskUserQuestion for topic selection | ||
| - User MUST say "note" or "notes" (not just "save this") | ||
| </critical> | ||
|
|
||
| ## Workflow | ||
|
|
||
| **1. Determine topic:** | ||
|
|
||
| If user specified topic explicitly → use it | ||
|
|
||
| Otherwise use AskUserQuestion to select from available topics above. | ||
|
|
||
| **2. Create file:** | ||
| - Filename: `WIP-[descriptive-name].md` (kebab-case) | ||
| - Location: `.notes/[topic]/WIP-[name].md` | ||
| - Format: H1 title on first line | ||
|
|
||
| **3. Confirm:** | ||
| - Tell user where saved | ||
| - Suggest `notes-sync` skill to commit | ||
|
|
||
| ## File Format | ||
|
|
||
| ```markdown | ||
| # [Descriptive title] | ||
|
|
||
| [Content from conversation] | ||
| ``` | ||
|
|
||
| H1 can be informal: questions, TODOs, context notes. | ||
|
|
||
| ## Examples | ||
|
|
||
| **With explicit topic:** | ||
| - "capture note about deployment in pgflow-demo" | ||
| - "add note to ci-optimization about parallel jobs" | ||
|
|
||
| **Inferred topic:** | ||
| - "capture note about this CI discussion" → Ask: which topic? | ||
| - "note this for later" → Ask: which topic + what to capture? | ||
|
|
||
| @../_shared/notes/notes-layout.md |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silent skipping of failed files creates inconsistent output with missing rows. When a file doesn't exist or summary generation fails, the function returns without outputting anything, causing the output to have fewer rows than the input. This breaks the table format and users won't know which files failed.
Fix: Always output the original line, even if processing fails:
This ensures consistent row count and informs users of failures.
Spotted by Graphite Agent

Is this helpful? React 👍 or 👎 to let us know.