Repository navigation
feat(check): show what changed in a skill since install - #623
Conversation
#622 made a hand-edited skill visible as modified and kept update from overwriting it, but there was still no way to see the edits before deciding to keep or discard them (#621). LocalChanges compares the skill's files with the hashes recorded at install, fetches the source at the recorded commit only when a recorded file changed, and diffs each file against it, so the diff shows the user's edits even after upstream moves on. A skill without a recorded commit is refused rather than diffed against HEAD, which would show upstream changes as the user's. It backs `check <name> --diff`, GET /api/resources/{name}/local-changes, and the dashboard: the Modified locally dialog on the skill page lists the diffs, and the Updates tab links a modified skill to it. update's skip hints now point at --diff. The route looks up the exact record and refuses non-local names, so a nested or ../ path cannot borrow a top-level skill's record or read outside the source. The file diff helper moved to textdiff so the CLI and server share it.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc4989beeb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return nil, fmt.Errorf("invalid source: %w", err) | ||
| } | ||
| source.ApplyRecordedBranch(entry.Branch) | ||
| source.Commit = entry.Version |
There was a problem hiding this comment.
Prefer the recorded full commit SHA for the diff baseline
For ordinary Git installs, entry.Version is abbreviated (getGitCommit uses rev-parse --short), while entry.Commit already records the full SHA. Passing the abbreviated value makes targeted remote fetching fail and sends checkoutCommit through its all-branches/tags fallback with --unshallow (internal/install/install_git.go:266–285; git fetch -h describes this as “convert to a complete repository”). Consequently, viewing one edited skill can download the repository's entire history. If upstream rebased or force-pushed away the installed commit, the comparison can fail altogether even when fetching its full SHA would succeed. Prefer a valid entry.Commit, falling back to entry.Version for legacy records.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7554277. Confirmed: Version comes from rev-parse --short, so checkoutCommit took the all-branches --unshallow fallback.
LocalChanges now pins the new installedCommit(entry): the full entry.Commit when it is the same commit as Version (prefix match), otherwise Version. The prefix check matters because Commit can be left over from an older install after an update rewrote Version; using it then would diff against the wrong baseline. Records without a SHA still error out. LocalChanges is the only place that pins a commit from the stored entry, so there are no other instances.
Covered by TestInstalledCommit (full, legacy without Commit, stale Commit, no Version).
entry.Version holds the short SHA from `rev-parse --short`. A targeted fetch needs the full SHA, so checkoutCommit fell back to fetching every branch and tag with --unshallow: viewing one edited skill could download the repository's whole history, and fail when the commit is only reachable by its full SHA. Use entry.Commit, the full SHA install records, when it is the same commit as Version; a Commit left from an older install, or a legacy record without one, falls back to Version.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…s test On Windows git checks the installed copy out with CRLF, so overwriting SKILL.md with LF content made every line differ and the expected diff failed. Edit the installed file in place, as an editor would, and compare the diff without carriage returns.
Type
proposals/only — see CONTRIBUTING.md)None ticked: maintainer-authored phase 2 of issue #621, not a proposal.
Linked Issue
Closes #621 (phase 2: view the differences; phase 1 shipped in #622)
Summary
generateUnifiedDiffmoved fromcmd/skillsharetotextdiff.Filesso CLI and server share it (callers unchanged in behavior).MetadataStore.GetExact(no basename-only fallback) and refuses non-local names, so_team%2Ffooorx%2F..%2F..%2Ffoocannot borrowfoo's record or read outside the source.check --diffadded to all five shell completions.Evidence
checksaysalpha local changes since install; nothing shows what changed.After:
TestLocalChanges_*(diff is against the installed commit after upstream moved; unchanged / added-only don't fetch; no recorded commit is refused),TestHandleSkillLocalChanges_*(diff via route; nested and../names 404 — failed with 500 and an outside path before the fix),TestCheckDiff*(global, project mode, flag combinations),TestCompletion_CheckDiff_AllShells.Merge Danger
Door: two-way
Blast Radius: check
Read-only additions: a new flag, a new GET route, and dialog content. The only changed output is the modified-skill
Nexthints incheckandupdate.GetByPathkeeps its behavior (it now callsGetExactfirst).Checks run
make checkin the devcontainer (docs-check, fmt-check, lint, unit + integration): passtsc --noEmit,vitest run(785),pnpm run build: passpython3 scripts/ai-context.py check: okNot covered
--difftest (tracked members have no record of their own, so the route returns 404 and the dialog shows the load error).diff --patchdoes; binary and >1MB files show a one-line notice.Checklist
make check) — for code changes