Refactor session-start-context.sh — project-scoped context loading #143
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/claude-custom#143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
plan-pal-e-agency→ Phase 20Repo
forgejo_admin/claude-customUser Story
As the superuser, when I open Claude Code in
~/basketball-api, I see basketball context (basketball plan TOC, basketball board items, basketball-related briefing). I don't see pal-e-docs CSS phases or mcd-tracker routes. Same token budget, higher signal per token.story:superuser-manageContext
session-start-context.sh(554 lines) already has project detection infrastructure but doesn't scope context by the detected project. It loads ALL plan TOCs for active projects, queries ALL in-progress phases for dynamic briefing, and aggregates board counts across ALL boards. The project page is dumped as first 40 lines of stripped HTML (unstructured).Five targeted changes — all within the existing hook architecture, all fail-open:
20a: Fix project detection — Current detection matches git remote against project
repo_url, but only 4/20 projects haverepo_urlset. Instead, extract repo name fromgit remote -v, curl/repos/{repo-name}, getproject_slugfrom the response. The/reposendpoint has ALL 19 repos with project associations. Fallback: if no match, load everything (current behavior).20b: Scope plan TOCs — Current: full TOC for any project with in_progress board items. New: full TOC for detected project's plan ONLY. Other active plans get one-liner (title + slug + project). The
inject_toclogic at line ~187 needs to checkmatched_project_sluginstead of (or in addition to)projects_with_active_work.20c: Scope dynamic briefing — Current: semantic search queries all in-progress phase titles with no project filter. New: add
&project={detected_slug}to the semantic search URL at line 259. The API already supports theprojectquery param (tested, works). Fallback: if no project detected, query without filter (current behavior).20d: Scope board items — Current: aggregated counts across all boards ("18 in-progress, 12 todo"). New: show detected project's board items in detail (titles for in_progress, qa, needs_approval items). Other boards as "board-{slug}: N in_progress, M todo" one-liners.
20e: Structured project context — Current: first 40 lines of stripped HTML from project page (lines 461-474). New: fetch TOC via
/notes/{page-slug}/toc, look foruser-storiesanchor. Inject vision paragraph + "User Stories available atget_section(slug, 'user-stories')" reference. Don't inject raw HTML dump.File Targets
Files the agent should modify:
hooks/session-start-context.sh— refactor for project-scoped contextFiles the agent should NOT touch:
hooks/session-start-board-sync.sh— board sync is separate, works finehooks/boards-config.sh— board list is correctAcceptance Criteria
~/basketball-api→ project detected aswestside-basketball(via repos endpoint)~/claude-custom→ project detected aspal-e-agency~/pal-e-platform→ project detected aspal-e-platform&project={slug}paramTest Expectations
~/basketball-api— verify output scopes to westside-basketball/tmp(no git repo) — verify fallback to full contextConstraints
/repos/{slug}endpoint returns{"slug": "...", "repo_url": "...", "project": {"slug": "...", "name": "..."}}?q=...&limit=N&project=SLUG(tested, works)git clone ~/claude-custom /tmp/claude-custom-{branch}Checklist
Related
plan-pal-e-agency— parent planphase-pal-e-agency-20-context-scoped-sessions— parent phaseglossary— Enterprise definitionphase-pal-e-agency-19-user-stories— user stories now exist on all project pagesReading issue for QA review context.