Update openspecPath in .claude/project-context.json so the SessionStart hook
injects the chosen project's openspec docs folder. This replaces hand-editing
the absolute path with a menu choice.
Steps:
Read
.claude/project-context.jsonfrom the current project root.- If the file does not exist, tell the user to run
setup-project-contextfirst and stop. - If it cannot be parsed as JSON, show the parse error and stop.
- If the file does not exist, tell the user to run
Collect the
projectsarray (entries with a non-emptypath). Present the choices to the user withAskUserQuestion:- One option per registered project, labelled by
name(falling back topath), with the resulting<path>/openspecshown in the description. - Plus a "Clear (use working-dir openspec)" option that sets
openspecPathto""— the hook then falls back to<project-root>/openspecautomatically. - If
projectsis empty, tell the user there are no registered projects to pick from and stop.
- One option per registered project, labelled by
Write the result back into
.claude/project-context.json:- For a project choice, set
openspecPathto<chosen project path>/openspec(forward slashes, no trailing slash). - For "Clear", set
openspecPathto"". - Preserve every other field (
roleBasedDelegation,projects, ordering, formatting) unchanged — only theopenspecPathvalue is modified.
- For a project choice, set
Report the new
openspecPathvalue and remind the user:- The change takes effect on the next session start —
/reload-pluginsdoes not re-run SessionStart, so start a new session or/clear. - If the chosen project has no
openspecfolder, the hook automatically falls back to the working-directoryopenspecat injection time.
- The change takes effect on the next session start —