Skip to content

feat(check): show what changed in a skill since install - #623

Merged
runkids merged 3 commits into
mainfrom
runkids/skill-local-diff
Oct 24, 2026
Merged

runkids merged 3 commits into
mainfrom
runkids/skill-local-diff

Conversation

@runkids

@runkids runkids commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (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

 install.LocalChanges(entry, parseOpts, dir)
+  files whose hash ≠ recorded FileHashes      → modified / added / deleted (no network)
+  any modified/deleted?                       → install source @ entry.Version into a temp dir
+    no recorded commit                        → error (HEAD would show upstream changes as the user's)
+  textdiff.Files(installed, local) per file

+skillshare check <name> --diff                 → per-file diff, then `update <name> --force` hint
+GET /api/resources/{relPath}/local-changes     → {files: [{path, status, diff}]}
 dashboard
+  skill page "Modified locally" dialog        → lists the diffs before Force overwrite
+  Updates tab modified row                    → "View changes" → that dialog (?changes=1)
 check / update skip hints                     → now point at `check <name> --diff`
  • generateUnifiedDiff moved from cmd/skillshare to textdiff.Files so CLI and server share it (callers unchanged in behavior).
  • The route uses the new MetadataStore.GetExact (no basename-only fallback) and refuses non-local names, so _team%2Ffoo or x%2F..%2F..%2Ffoo cannot borrow foo's record or read outside the source.
  • check --diff added to all five shell completions.

Evidence

  • Before: check says alpha local changes since install; nothing shows what changed.
    After:
    $ skillshare check alpha --diff
    ! alpha     3 files changed since install
                added NOTES.md
                  + my notes
                modified SKILL.md
                    ...
                    Step one.
                  - Step two.
                  + Step two, my way.
                  + Step three.
                deleted run.sh
                  - echo hi
    Next
      skillshare update alpha --force  discard them and reinstall
    
  • Dashboard (browser): Updates tab row shows Modified locally + View changes; it opens the skill page dialog with the per-file diffs (green/red lines) above Force: overwrite local edits.
  • Tests: 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 Next hints in check and update. GetByPath keeps its behavior (it now calls GetExact first).

Checks run

  • make check in the devcontainer (docs-check, fmt-check, lint, unit + integration): pass
  • UI: tsc --noEmit, vitest run (785), pnpm run build: pass
  • python3 scripts/ai-context.py check: ok
  • Not run: website build, Windows, E2E runbooks

Not covered

  • Followed first-level links and skills inside tracked repos have no dedicated --diff test (tracked members have no record of their own, so the route returns 404 and the dialog shows the load error).
  • Diffs show whole files (unchanged lines included), as diff --patch does; binary and >1MB files show a one-line notice.
  • The fetch is not cancelled when the dialog closes.

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

#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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T09:05:02.068942Z 7554277 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread internal/install/local_changes.go Outdated
return nil, fmt.Errorf("invalid source: %w", err)
}
source.ApplyRecordedBranch(entry.Branch)
source.Commit = entry.Version

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@runkids

runkids commented Oct 24, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 7554277ac0

ℹ️ 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".

…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.
@runkids
runkids merged commit 2d196c2 into main Oct 24, 2026
8 checks passed
@runkids
runkids deleted the runkids/skill-local-diff branch October 24, 2026 09:32
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.

There are no prompts or indicators after manually editing the skill retrieved from GitHub.

1 participant