Skip to content

fix: resolve prompt paths against the repo root, not the current directory - #30

Merged
sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/repo-root-paths
Nov 15, 2026
Merged

sujal-maheshwari2004 merged 1 commit into
mainfrom
fix/repo-root-paths

Conversation

@sujal-maheshwari2004

Copy link
Copy Markdown
Member

Fixes #17.

openRepo found the repo from any subdirectory, but prompt discovery, URIs and file writes were relative to the current directory. A prompt's URI comes from its repo path, so running from acme/ published support/agent.prompt as priompt://support/agent, a different org. diff, commit, promote and log broke the same way.

Change

  • At startup, promptctl moves to the worktree root and records where it was started (cwdInRepo).
  • Path arguments to log, promote and publish go through repoPath, so relative, ./-prefixed and absolute paths all become repo-relative.
  • A bare publish (no paths) from a subdirectory publishes only the prompts under that subdirectory, instead of the whole repo. Validation before commit/push stays repo-wide.
  • Outside a git repo nothing changes: publish still works on plain files.

Tested

  • New TestSubdirectoryPathsResolveAgainstRepoRoot: from acme/support, three forms of the path (agent.prompt, ./agent.prompt, absolute) all map to acme/support/agent.prompt / priompt://acme/support/agent, and diff reports no prompt changes vs HEAD.
  • End to end against a local priompt serve, running publish from acme/:
    • main: published priompt://support/agent
    • this branch: published priompt://acme/support/agent
  • go vet ./... and go test ./... pass.

Touches the same file as #29 but different functions, so it should merge cleanly in either order.

…ctory

openRepo found the repo from any subdirectory, but prompt discovery, URIs and
file writes were relative to cwd. Run from acme/, publish sent
support/agent.prompt as priompt://support/agent (another org), diff reported
every prompt as deleted plus new, and commit/promote/log failed.

main now chdirs to the worktree root and path arguments are mapped to
repo-relative paths (relative, ./-prefixed or absolute). A bare publish from a
subdirectory publishes the prompts under that subdirectory. Outside a repo
nothing changes.

Fixes #17
@sujal-maheshwari2004
sujal-maheshwari2004 merged commit 69115d5 into main Nov 15, 2026
1 check passed
@sujal-maheshwari2004
sujal-maheshwari2004 deleted the fix/repo-root-paths branch November 15, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running promptctl from a subdirectory publishes prompts under the wrong org

1 participant