-
Notifications
You must be signed in to change notification settings - Fork 6
feat(hooks): wire sessionStart and sessionEnd lifecycle hooks #158
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
Open
raykao
wants to merge
4
commits into
ChrisRomp:main
Choose a base branch
from
raykao:feat/session-lifecycle-hooks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+165
−1
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ae2aeb5
feat(hooks): wire sessionStart and sessionEnd lifecycle hooks
raykao 1e69de5
fix(hooks): address code review — event ordering and stale cache
raykao 85ed66c
fix(hooks): use absolute path /bin/bash to avoid ENOENT on spawn
raykao 8c29c9e
fix(hooks): track session working directory at creation time
raykao 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
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
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,111 @@ | ||
| --- | ||
| name: Beads Task Memory | ||
| description: Persistent task tracking for this workspace using bd (Beads). Use this skill to create, track, and close tasks across sessions. | ||
| --- | ||
|
|
||
| # Beads Task Memory Skill | ||
|
|
||
| This workspace uses [Beads](https://github.com/steveyegge/beads) (`bd`) for persistent, structured task memory backed by [Dolt](https://github.com/dolthub/dolt). Tasks survive session restarts and can be shared across multiple bots via Dolt sync. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - `bd` CLI installed: `npm install -g @beads/bd` or `brew install beads` | ||
| - `bd init --quiet --stealth` run in the workspace directory | ||
| - `BEADS_DIR` and `BEADS_ACTOR` set in workspace `.env` (auto-injected by copilot-bridge) | ||
|
|
||
| ## Session Start Workflow | ||
|
|
||
| Run at the beginning of every session to recover context: | ||
|
|
||
| ```bash | ||
| bd prime # Print workflow context and pending work | ||
| bd ready --json # List tasks with no open blockers (what to work on next) | ||
| ``` | ||
|
|
||
| ## Task Operations | ||
|
|
||
| ### Creating tasks | ||
|
|
||
| ```bash | ||
| bd create --title="Short descriptive title" --description="Why this exists and what done looks like" --type=task --priority=2 | ||
| ``` | ||
|
|
||
| - Types: `task`, `feature`, `bug`, `epic`, `chore`, `decision` | ||
| - Priority: `0` (critical) → `4` (backlog). Use numbers, not words. | ||
| - For descriptions with special chars, pipe via stdin: `echo "description" | bd create --title="Title" --stdin` | ||
| - **NEVER** use `bd edit` — it opens `$EDITOR` and blocks the agent. | ||
|
|
||
| ### Claiming and progressing work | ||
|
|
||
| ```bash | ||
| bd update <id> --claim # Atomically claim a task (sets assignee + in_progress) | ||
| bd update <id> --status=done # Update status without closing | ||
| bd update <id> --notes="..." # Add notes inline | ||
| ``` | ||
|
|
||
| ### Closing tasks | ||
|
|
||
| ```bash | ||
| bd close <id> --reason="What was done" | ||
| bd close <id1> <id2> <id3> # Close multiple at once | ||
| ``` | ||
|
|
||
| ### Viewing and searching | ||
|
|
||
| ```bash | ||
| bd show <id> # Full task details + audit trail | ||
| bd list # All open issues | ||
| bd list --status=in_progress # Active work | ||
| bd search "keyword" # Full-text search | ||
| bd stats # Project health summary | ||
| ``` | ||
|
|
||
| ### Dependencies | ||
|
|
||
| ```bash | ||
| bd dep add <child-id> <parent-id> # child depends on parent (parent blocks child) | ||
| bd blocked # Show all blocked issues | ||
| ``` | ||
|
|
||
| ### Persistent knowledge | ||
|
|
||
| ```bash | ||
| bd remember "key insight or decision" # Store cross-session knowledge | ||
| bd memories "keyword" # Search stored knowledge | ||
| ``` | ||
|
|
||
| **Call `bd remember` at the moment of discovery — not at the end of the session.** Dolt commits immediately on every write, so memories survive any shutdown. Batching to the end risks losing them if the session is interrupted. | ||
|
|
||
| Trigger `bd remember` whenever: | ||
| - A non-obvious decision is made (e.g. "use X not Y because Z") | ||
| - A gotcha, failure mode, or workaround is found | ||
| - A config value or path turns out to be critical or surprising | ||
| - Any fact that would take >5 minutes to re-discover next session | ||
|
|
||
| Format: a concise, self-contained sentence — include the *why*, not just the *what*. | ||
|
|
||
| ## Session End Workflow | ||
|
|
||
| Close completed tasks and back up before ending a session: | ||
|
|
||
| ```bash | ||
| bd close <id1> <id2> ... # Close all completed work | ||
| bd backup export-git # Snapshot to git branch (zero-infrastructure backup) | ||
| ``` | ||
|
|
||
| ## When to Use Beads | ||
|
|
||
| - Any task that spans multiple tool calls or may be interrupted mid-session | ||
| - Multi-step work with subtasks (use epics + child tasks) | ||
| - Decisions that should be recorded for future sessions | ||
| - Anything you'd otherwise write to `MEMORY.md` | ||
|
|
||
| When Beads is available, prefer `bd remember` over `MEMORY.md` for persistent knowledge — Beads is queryable, versioned, and concurrency-safe. | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ```bash | ||
| bd doctor # Check Dolt server health | ||
| bd dolt start # Manually start Dolt server if needed | ||
| bd dolt status # Check server status | ||
| ``` |
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.
Hardcoding the bash executable to
/bin/bashon non-Windows can be a portability regression: it bypasses the user’sPATHand can force an older bash (notably macOS ships bash 3.2 at /bin/bash), breaking hooks that rely on bash 4+ features. Prefer resolvingbashfrom PATH (or using/usr/bin/env bash) so the configured environment determines which bash runs.