253 Commits
Author SHA1 Message Date
Willie 58ccb2bcc5 fix(uninstall): keep repos installed into a tracked repo's legacy group (#900)
Uninstalling the _team checkout matched every tracked entry grouped as
"team", so a repo installed with --into team (team/_b) lost its record
and audit acceptances too. Since #880 keeps declarations that have no
checkout on this machine, reconcile could no longer restore that record,
and the next push removed it on every machine; only trash restore of
_team brought it back.

#880 already excluded _-prefixed repo directories from the legacy match
for unlink and declaration-only removal. Move that guard into
inLegacyRepoGroup so checkout uninstall and its trash copy follow the
same rule.

Fixes #898
2026-11-14 14:25:00 +08:00
3217d44881 fix(reconcile): keep tracked repo declarations this machine has not cloned (#880)
* test(install): reproduce loss of pulled tracked records

Exercise the two-machine push and pull sequence and reconciliation states so
missing tracked clones cannot silently erase shared install intent.

* fix(reconcile): preserve tracked records missing local clones

Pull transfers tracked repository metadata but not ignored clones. Keep the
missing records during global reconciliation so another install and push cannot
erase shared intent or accepted audit findings on every machine.

* test(reconcile): isolate tracked record fixtures

Use the shared sandbox fixture for both reconciliation tests so their home
and configuration paths remain isolated from the invoking environment.

* fix(reconcile): retain all sourced tracked declarations

Legacy tracked members and unfollowed source links can hide declarations
from the local walk. Preserve sourced tracked records regardless of their
path so unrelated installs cannot erase them or their audit acceptances.

Document restoring a missing checkout before uninstalling it and cover
migration, link collisions, aliases, and explicit removal.

* test(reconcile): drop fixtures existing tests already pin

The tracked-record unit test also seeded a missing plain record and a
live plain record. TestReconcileGlobalSkills_PrunesStaleEntries already
pins both outcomes: a sourced plain record whose folder is gone is
pruned, and one on disk survives. The tracked record with no source
still catches a fix that keeps everything or skips the prune.

The two-machine test passed HOME and SKILLSHARE_CONFIG to RunCLIEnv,
which already sets both from the sandbox for each child process.
Separate homes, XDG paths, client overrides and git config remain.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(reconcile): retain tracked entry for unavailable link

Expect sourced tracked declarations to survive reconciliation with either
source-link policy, so the test matches the cross-machine retention contract.

* fix(config): prune legacy tracked members

Retain only sourced tracked repository declarations during reconciliation.
Migrated member records are not restorable as repositories and retaining them
would leave permanent misleading install requests and audit acceptances.

* fix(reconcile): preserve tracked intent across followed links

A source link can exist before a tracked repository declaration is pulled. Preserve that declaration when the linked folder is not a checkout so later reconciliation does not discard its record and audit acceptances.

* test(reconcile): cover grouped followed declarations

A followed group can contain the path of a pulled legacy repository declaration, which must retain its tracked intent while its key migrates.

* fix(test): scope collision fixture runner correctly

Keep the isolated CLI runner in the collision subtest that uses it so the integration test package can compile.

* docs(manifest): clarify tracked checkout recovery

A retained declaration cannot restore a checkout while another folder or source link occupies its destination, and restoration requires a reachable source. State those prerequisites in each manifest translation.

* fix(config): prune members under recorded repositories

A migrated underscore-named member can otherwise survive a missing checkout as a repository declaration. Check recorded ancestor paths while preserving ambiguous grouped declarations and unrelated aliases.

* docs(manifest): restore fresh-clone project guidance

Explain that project declarations without local install records remain available so teammates can install them after cloning.

* refactor(reconcile): drop the tracked-intent walker policy

Restore baseline normalization for present paths while retaining absent
repository declarations through the shared metadata predicate. Isolate the
reconcile fixtures without building a CLI and share native-client overrides
without changing the original two-machine record and audit regression.

Validation: gofmt, git diff --check and context-router check only.
Runtime, builds and tests were not executed under the source-only gate.

* fix: forget linked checkout records and declarations without checkouts

Extend the metadata and uninstall owners to remove a declaration without
reading or moving its occupant, contacting its source, or changing trash
and gitignore. A failed metadata save makes every metadata-only result fail.

Clean up global unlink records in CLI and API, preserve existing-path name
precedence, report record-only results truthfully, and list declarations in
the dashboard API with noCheckout. Keep project removal behavior unchanged.
Remove the obsolete grouped-link walker-policy assertion while preserving
grouped absent declarations and the original record/audit A/B regression.

Validation: source-only five-pass review, gofmt, git diff --check and the
context-router check. No runtime, builds, tests or frontend tooling ran.
Stop at commit 15 for the mandatory Luna checkpoint before UI and docs work.

* fix(server): reload metadata before removing declarations

Preserve CLI records and audit acceptances written while the dashboard is open. Resolve new declarations from disk and refuse stale-cache saves after a reload failure, retaining unlink success when its link already moved.

* feat(dashboard): remove a tracked repository record without a checkout

Show declaration-only rows without checkout actions or status promises. Reuse Uninstall with record-specific confirmation and feedback, keep real-checkout force handling, and refresh the missing-entry list after repository removal or unlink.

* docs: explain kept declarations and how to remove them

Document direct global declaration removal and optional restore in English and all four translations, including occupied paths and normalization after reconcile. Keep built-in guidance accurate and use the existing API removal result for dashboard success feedback after concurrent CLI changes.

* fix(dashboard): confirm restored checkouts after forceable refusals

A tracked declaration can be restored through the CLI while its dashboard
row still says there is no checkout. Treat a forceable uninstall refusal
as evidence of the current checkout and promote the existing confirmation
to its dirty or unreadable-status warning before allowing explicit force.

Author stale-row regressions for both forceable codes before the source
repair, and retain nonforceable failure and actual-result success feedback.
Validation: five serial source review passes, git diff --check, and the
context-router check. Tests, builds, runtime and frontend tooling were not
run under the source-only gate.

* test(server): persist overview declarations before routed request

The overview fixture added declarations only to the in-memory skills store,
which the real request's config reload replaced with on-disk metadata. The
hosted unit, offline, and Nix jobs consequently returned no tracked rows.

Save the complete fixture through MetadataStore before serving the request
and fail setup on a save error. Keep the middleware, assertions, and
production behavior unchanged.

* fix(server): prefer exact declarations before checkout shorthand

Removing a missing _team declaration from the dashboard could resolve the
different org/_team checkout by basename and trash it instead.

Reload metadata before declaration lookup, give exact declarations priority,
and preserve checkout resolution before non-exact declaration fallback.
Add routed absent/occupied regressions and checkout precedence guards, and
persist existing checkout fixtures so the metadata reload keeps their state.

Validation: gofmt, git diff --check, and context-router check passed.
Tests were authored but not run under the source-only fleet restriction.

* fix: preserve removal intent and report partial failures

Bind dashboard record-only removal to its canonical declaration and refuse
restored checkouts before checkout resolution or force. Refresh the row and
require another confirmation before moving a restored checkout to trash.

Keep unresolved uninstall inputs and their reasons in JSON failed results,
including all-invalid requests, partial successes and dry runs. Report unlink
metadata cleanup failures as partial results, refresh completed unlinks and
show localized warnings. Keep CLI and dashboard guidance aligned.

Regression tests were authored before source changes and remain unrun under
the source-only task restriction. Static formatting, diff and router checks
passed; no build, product runtime, frontend tooling or test suite was run.

* fix(unlink): log partial metadata cleanup failures

Write the unlink result after global metadata cleanup so load and save
failures retain their diagnostic and report partial success. Preserve the
successful link removal, warning, target and exit policy, and the existing
link, project unlink and native removal failure behavior.

Add the corrupt-metadata regression before the fix; leave it unrun under
the source-only authorization. Formatting, diff and context-router checks
pass; runtime verification remains with the coordinator.

* fix(unlink): forget records below the removed link name

Reconcile can normalize a followed link's record to untracked, and linked
collections can retain nested repository declarations. Clean the removed
namespace through the existing metadata path owner in both unlink callers,
including audit acceptances, while keeping declaration uninstall strict.

Author CLI and route regressions before the source fix for normalized and
nested records, sibling preservation, and subsequent bare install. Tests
remain unrun under the source-only task restriction; static checks only.

* fix(uninstall): refuse a restored checkout at execution

A declaration selected while absent can become a checkout before removal
runs. Recheck the resolved source-relative name in the shared metadata-only
execution owner and refuse before touching metadata, regardless of force.

Reuse the existing dashboard conflict response and refresh/reselection flow
for this refusal, preserving the earlier record-only intent guard. CLI
results already carry shared execution failures through text and JSON.

Author restoration, force, absent/occupied control and client boundary
regressions before production edits. Correct the unlink fixture name and
response-key assertion found in serial static review. All tests remain
unrun under the source-only restriction; formatting/diff/router checks pass.

* refactor(server): consolidate repository uninstall result handling

Resolve a declaration or checkout to one item and canonical name before
using the existing uninstall, conflict, log and success response tail.
Keep metadata-only removal unforced, preserve its error and cache recovery
behavior, and report movedToTrash from the selected item.

Preserve exact declaration precedence, record-only checkout refusals,
ordinary checkout errors and project behavior without changing tests.
Five serial source review passes, gofmt, diff checks and the context-router
check completed. Tests and builds remain unrun under the source-only brief.

* fix(unlink): preserve independent records and trash undo metadata

Limit unlink's legacy group matching to members so a retained declaration
such as team/_repo survives unlinking _team. Share snapshot and removal
matching while keeping generic uninstall's legacy contract unchanged.

Save the exact removed records, audit acceptances and target overrides
through uninstall's existing trash sidecar owner before pruning metadata.
Keep metadata on sidecar failure and preserve completed-unlink warnings,
fresh reloads, cache refresh and project-mode behavior.

Author owner, CLI and API regressions for namespace collisions, undo,
partial failures and project/empty controls. Source-only verification:
gofmt, diff check and context-router check passed; runtime tests, builds,
frontend checks and final make check remain unrun for root-owned gates.

* fix(install): preserve independent tracked declarations

Limit declaration-only cleanup to the precise namespace and legacy members already used by unlink. Keep independently installed prefixed repositories, their audit acceptances, and overrides when forgetting a missing checkout.

* fix(cli): explain missing tracked repository recovery by mode

Offer global record removal when restoring an unreachable source is unwanted. Keep project recovery scoped to install -p, share the hint with doctor, and align update documentation in every existing locale.

* refactor(uninstall): share declaration and unlink operations

Keep declaration resolution and unlink metadata ordering in shared owners so CLI and API preserve the same scope and recovery behavior. Consolidate domain regressions while retaining caller translation coverage.

Distinguish record-only removals in API and CLI operation logs and CLI JSON, including mixed batches and dry runs. Document outcome fields, warning semantics, and current API error codes across existing locales.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Willie <egg358358@gmail.com>
2026-11-14 13:11:27 +08:00
Willie cfe235a84d fix(install): report reinstalls from the same repo as skipped (#887)
* fix(install): report reinstalls from the same repo as skipped

checkExistingConflict read only the legacy .skillshare-meta.json
sidecar, which installs no longer write, so reinstalling a skill from
the same repo was reported as "already exists" and counted as failed,
contrary to the documented skip. It now reads the skill's record in
.metadata.json, falling back to the sidecar, and skips only the same
skill of that repo: another skill installed under the same name stays
a conflict instead of being reported as installed.

The dashboard logged an existing agent as installed and a same-repo
skill as failed. Batch installs now return those as skipped and log
them as skipped_skills, passing --into so a reinstall into a group
folder finds its record; the install dialog warns that they are
already installed. A same-repo tracked reinstall returns 409 and is
logged as skipped instead of a 500 logged as failed.

ss search installs, batch and single, log the names they skip, and
the Herdr panel reports skipped names like failed ones. The install
docs and their translations say that only the same skill is skipped.

* fix(install): install requested agents when the only skill is skipped

Reinstalling a single-skill repo with `-s alpha -a helper` returned as
soon as the skill was skipped as already installed, so the requested
agent was never installed while the command reported success. Both
single-skill branches now continue to the agent phase, as the
multi-skill path already does.
2026-11-14 00:03:17 +08:00
Willie 51306f49fa fix(install): log skipped skills and agents (#886)
After #884, an install without --force keeps existing skills and agents
and names them in the --json skipped array, but the operation log
recorded only installed and failed names, so `ss log` could not show
what an install kept.

Record the kept names as skipped_skills for CLI installs and for the
dashboard's install-from-config action, and list them in `ss log`.
The config install starts with an empty list, so the dashboard log
shows no "null" when nothing was kept.
2026-11-13 22:34:40 +08:00
Rusty Shackleford 4596c1e413 fix(install): require explicit force for JSON overwrites (#884)
* fix(install): require explicit force for JSON overwrites

Machine-readable output must not grant destructive consent. Preserve existing skills and agents unless force is explicit, and report existing skip decisions in the JSON result while retaining selection and audit behavior.

Cover edited copies in global and project modes, and update help, automation guidance, and translated command documentation.

Refs: #877

* fix(install): preserve previews and locked JSON copies

Read-only discovery must work before replacement consent, including existing
single skills and cross-path installs. Keep overwrite checks on write paths.

Require existing update or force intent to advance installed project copies
to a changed lock pin. Preserve ordinary CLI and dashboard lock following,
while JSON alone leaves local edits and incoming pins unchanged.

Cover existing-destination previews, edited locked copies and dashboard lock
following. Clarify translated docs and make the consent runbook step runnable.

Refs: #877

* fix(install): resolve installed names during previews

JSON previews must resolve recorded sources without requiring overwrite consent. Permit metadata lookup for dry runs and restore the original unforced preview regression in global and project modes.

* test(install): remove duplicate JSON consent runbook case

The global local-skill integration case already covers JSON overwrite refusal and explicit forced replacement. Remove the duplicate runbook step and restore its 18-step numbering while retaining the existing purity setup and assertion corrections.
2026-11-13 21:31:41 +08:00
Willie 08ecb7afad fix(audit): report audit-rules load errors and block installs whose audit cannot run (#882)
* fix(audit): report audit-rules load errors in global scans

The global scan entry points (ScanSkill, ScanSkillWithFollow,
ScanSkillFiltered, ScanFile) dropped the error from Rules() and scanned
with no pattern rules. One bad regex in the global audit-rules.yaml
turned every pattern check off with no warning, so audits reported
fewer findings than they should have (#879). Project mode already
returned the error.

Return the error from the global path as well, and name the failing
file in it: parse errors from loadUserRules and compile errors from
Rules() and RulesWithProject now carry the path. When a project scan
fails to compile, the global file is blamed only if it fails on its
own, so a project file that disables a broken global rule still loads.
The cached markdown split now takes the rules its caller already
loaded instead of loading them again and dropping the error.

* fix(install): block installs whose audit cannot run

Once global scans return rule-load errors, install treated the error as
a warning and installed the skill with no audit at all. update already
fails closed on a scan error, and --force there accepts findings, not
an install nobody could check.

A scan error now blocks skill, agent and tracked-repo installs and
removes what was installed. --force does not override it;
--skip-audit still bypasses scanning. The error wraps the new
install.ErrAuditScanFailed rather than audit.ErrBlocked, so install
output and the dashboard do not offer a --force retry that cannot help.

upgrade reinstalls the built-in skill with --force, which deleted the
old copy before the audit ran. A typo in audit-rules.yaml would have
left users without the skill, so upgrade now stages the download
through the update path and keeps the installed copy when the audit
fails.

update --all counted the new error as a silent skip. It is now listed
under "Blocked by security audit" with its reason and makes the run
exit non-zero. The install warning summary that counted "audit scan
error" warnings is removed, since nothing emits them any more.

Fixes #879
2026-11-13 15:14:05 +08:00
Willie 40697e03f3 fix(oplog): keep source credentials out of the operation log (#881)
An install source typed as a URL can carry a token in its userinfo or
query, and operations.log stored it as typed, so anyone reading the log
or the dashboard's log view could see the credential (#878).

Redact in oplog.Write, which every CLI and dashboard writer goes through:
the source, oldSource and newSource args lose their userinfo, query and
fragment, and the message loses the same parts where an error echoes
them. The redaction reuses update's redactRepoURL, moved to
install.RedactRepoURL. It now also covers git+https:// and ssh://
passwords, and a source typed without a scheme such as
user:token@host/owner/repo, which install clones over HTTPS.

logInstallOp logged args[0] as the source, which is a flag when one comes
first (install --into team <url> logged "--into"), so the message was
never redacted. It now logs the parsed source.

Fixes #878
2026-11-13 14:50:31 +08:00
Willie 9dbcd925d8 feat(audit): honor findings accepted with --force via --respect-accepted (#872)
* feat(audit): honor findings accepted with --force via --respect-accepted

install and update --force record the findings a user accepted in
audit_accepted, but audit ignored that record. A skill installed with
--force therefore kept failing `skillshare audit` in CI with no way to
let the accepted findings pass (#869).

audit --respect-accepted marks those findings as acknowledged. They stay
in every output (JSON acknowledged: true, a text/TUI note, "(accepted
earlier)" in Markdown, SARIF external suppressions), but they are counted
in summary.accepted instead of their severity and no longer fail the
audit. Without the flag nothing changes, so existing CI gates keep their
behavior. A changed file or snippet produces a new key and blocks again.

Tracked repositories record acceptances at the repo root with paths
relative to it, so ApplyAcceptedFindings walks up from each skill to
match them. The install, update and edit gates use the same function and
now honor repo-wide acceptances for skills inside tracked repos too.

The dashboard always honors accepted findings: the Audit page mutes them
and counts them apart, the skill Audit tab collapses them, and the
Dashboard attention card no longer lists a skill whose only blocking
findings were accepted. The CLI JSON summary and the server summary share
Result.CountOpenBySeverity so both count accepted findings the same way.
The oplog records the accepted count and the log views show it.

* fix(audit): match acceptances when a single file is scanned

A single-file scan names its findings by the file's base name, but the
ancestor lookup used the file's whole path as the prefix, so it hashed
SKILL.md/SKILL.md instead of the recorded SKILL.md. Auditing a skill file
directly with --respect-accepted, and auditing agents inside a tracked
repository in the CLI or the dashboard, still failed on unchanged
accepted findings. For a file target the prefix is now the file's own
directory.
2026-11-12 11:15:44 +08:00
Willie 9f43310a3d fix(update): repair skill sources recorded before the per-skill source fix (#866)
Before #863, `install <repo> -s <skill>` recorded "<repo>/<path>" as the
skill's source. GitLab, Bitbucket and file:// sources parse that string as
another repository, so every path that parsed the recorded source failed
for those skills: `update` of a single skill, `install <name> --update`,
the dashboard update, and the local-changes diff. #863 only changed what
new installs record.

The record still holds the repository and the path, so RecordedSource
rebuilds the source from them when the written string parses as a
different repository, and the reinstall writes the record back in the
form that parses.

In project mode the config entry that declared the old string follows the
rewritten record, because teammates install from the config. An entry a
teammate changed stays as it is, and so does a record a batch update only
respelled. The config is reloaded first: `update --prune` saves it through
another copy, and saving the stale one brought pruned skills back.

`hub draft` and `hub index` published the old string as it was written;
they now publish the source that installs the skill.

Closes #862
2026-11-11 23:34:43 +08:00
Willie c040917bc7 fix(security): enforce credential and filesystem trust boundaries (#861)
Bind provider credentials to canonical or explicitly configured HTTPS origins and preserve that policy across remote consumers. Reject cross-site credentialed reads, linked fallback directories, and discovered-agent writes outside the source; audit staged content before rooted atomic publication.

Add boundary regressions, private Git update coverage, stable cross-platform fixtures, and aligned documentation. Verified the integrated main baseline with all executed CI checks passing.
2026-11-11 23:17:54 +08:00
Willie 3872cb5525 fix(install): record a per-skill source every host can install again (#863)
* fix(install): record a per-skill source every host can install again

`install <repo> -s <skill>` joined the repository and the skill path with
a single "/". GitLab and Bitbucket URLs have no fixed depth, so the parser
read the result as a longer repository path, and file:// URLs only split
on "//". The recorded string is what a project's config.yaml shares, so
`install -p` on a fresh clone tried to clone a repository that does not
exist.

Whole-repo file:// sources now join with "//", and GitLab or Bitbucket
sources typed without ".git" or a web URL marker join with ".git/". The
other hosts keep their form.

`install --update` still recognises a record in the old form, but only
when its recorded repository and path agree, because on these hosts the
same string can also name a repository of its own. The dashboard's
install dialog matched installed skills by rebuilding the old form, so it
now accepts each form the server writes.

Closes #859

* fix(ui): mark hub results installed under the new recorded source

A hub entry that names a repository and a skill was matched against the
installed skills by an exact source or a "<source>/" prefix. A GitLab or
Bitbucket repository typed without ".git" is now recorded as
"<source>.git/<skill>", so the search row and the preview kept offering
Install, and a second install hit the already-exists warning.

The matcher now accepts the ".git/" join as well. This is the same class
as the discovery list fixed in the previous commit: both rebuild the
recorded source in the dashboard. No other dashboard or Go code matches a
recorded source by prefix.
2026-11-11 23:14:39 +08:00
Willie 828ba93f27 fix(git): keep a caller's GIT_DIR out of skillshare's git commands (#854)
* fix(git): keep a caller's GIT_DIR out of skillshare's git commands

Git exports GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE and related variables
to hooks that run in a linked worktree. Every git process skillshare
started inherited them, and those variables override the directory the
command runs in. Run from a post-checkout or post-merge hook, skillshare
therefore acted on the hook's repository instead of its own: install's
sparse clone turned on sparse checkout there (a later merge removed every
file outside the skill's path), the remote tree check's `git init --bare`
made it a bare repository, install's reconcile recorded its origin and
branch, and push staged and committed into it.

internal/gitenv builds git commands without the variables that
`git rev-parse --local-env-vars` lists for choosing a repository, work
tree, index, object store or config file. GIT_CONFIG_COUNT and
GIT_CONFIG_PARAMETERS stay, because users pass credentials through them
and install's token auth appends to the existing count. Every git call in
cmd/skillshare, internal/install, internal/git, internal/check and
internal/config now goes through it, and plugin runCommand starts native
CLIs from the same environment because they run git as well. The hooks
service keeps its own stricter filter.

Closes #852

* test(gitenv): fail on new git commands that bypass gitenv

Each git call site converted for #852 is safe only because it goes
through gitenv.Command, and about half have no test of their own. A
future exec.Command("git", ...) would silently bring the bug back, so a
syntactic guard now rejects one outside gitenv, hooks and testutil,
mirroring the sourcefs and sourcewalk ratchets.

The Environ test also checks a lowercase name, since Windows environment
names are case-insensitive, and compares against literal keys so that
removing one from repoVars fails it. The wiki records the rule.
2026-11-11 21:08:47 +08:00
Willie 816938c09c fix(cli): report why uninstall and install fail under --json (#835)
Scripts and the herdr panel could not tell why an uninstall or install
failed: uninstall --json had no error field, project mode ignored --json
(printing text and still prompting), and a multi-skill or config install
in which every skill was blocked exited 0.

- uninstall --json (skills and agents, global and -p) sets "error" with
  each failed name and reason; skills exit non-zero when all fail,
  agents when any fails. Project mode now emits pure JSON, including on
  the first run that initializes the project.
- uninstall -p agents parses its flags instead of treating --help or an
  unknown flag as an agent name, and uninstall agents --json is logged.
- install exits non-zero, naming each skill and reason, when every skill
  from a source or from config fails; installed or skipped skills make it
  a partial success that still exits 0. Config installs show each
  failure's reason, and the dashboard logs an all-failed run as an error.
- herdr asks for JSON in project scope and shows the CLI's error.
2026-11-10 20:24:44 +08:00
Rusty Shackleford 71ff2d9e14 fix(discovery): find repository-root .agents/skills (#801)
A repository-root .agents/skills now counts as a skill anchor only when the repository has no other SKILL.md outside .git and target directories, so tracked checkouts that author skills there are discovered, while repos that commit .agents/skills copies keep discovering only their authored skills.

Fixes #800
2026-11-10 16:04:20 +08:00
Willie 037c7943cf fix(audit): report credential paths in Python comments and docstrings as HIGH (#819)
Credential-access rules match whole lines, so a Python docstring that
named ~/.aws/credentials in a `cat` example counted as a CRITICAL read and
blocked the mcp-sentinel skill at the default threshold (#817).

In .py files, a built-in CRITICAL credential-access match on a comment-only
line, or inside a string that is a whole statement such as a docstring, is
now HIGH: it still shows, and still blocks under a HIGH threshold. A small
tokenizer decides this and keeps CRITICAL wherever it cannot be sure the
line never runs: argument, assigned and bracketed strings, f-strings and
their replacement fields, code before a trailing comment, files that read
__doc__ or use bare CR line breaks, and explicit severity overrides.

A lowered finding carries severityContext "python-inert" (JSON, SARIF,
`audit rules --format json`), and the dashboard, CLI text output, both
audit TUIs, install/update warnings and the markdown report say it was
lowered from CRITICAL, so it is not mistaken for a changed rule.

Closes #817
2026-11-09 23:30:37 +08:00
Willieandsim 5e90cf4b71 feat(ui): show a skill's branch and switch it from the detail page (#784)
* feat(ui): show a skill's branch and switch it from the detail page

A skill installed with --branch looked the same in the dashboard as one
from the default branch, and moving it to another branch meant a manual
reinstall from the CLI (#783).

The list, tiles, tree pane and Updates tab now tag the branch a skill was
installed from. The detail page lists the source's branches; picking one
confirms, then reinstalls through POST /api/update with a new `branch`
field, so the audit gate and the local-changes check still apply and a
branch without the skill leaves the install in place.

In project mode, reconciling config.yaml only added missing skills, so a
reinstall from another branch (the switch, or install --branch --force)
left config.yaml naming the old branch while the lock pinned the new
commit. Reconcile now moves the declared branch with the record.

Closes #783

* fix(update): make branch switches install the requested branch safely

Codex review of #784 found four ways a switch could misreport or lose work:

- A root skill installed as a full clone took the pull fast path on later
  switches, pulling its current branch instead of the requested one. The fast
  path now applies only when the checkout is already on that branch.
- A branch whose skill folder lacks SKILL.md replaced the skill with a plain
  folder. A staged update now refuses a candidate without SKILL.md when the
  installed copy has one, and keeps the install.
- Reconciling config.yaml from local metadata could rewrite a teammate's
  newer branch declaration back to a stale one on an unrelated install. The
  generic reconcile change is reverted; the switch updates only the switched
  skill's declaration.
- The config editor cache kept the old branch after a switch, so a later save
  could undo it. A successful switch now invalidates the config query.

---------

Co-authored-by: sim <sim@example.invalid>
2026-11-05 22:44:03 +08:00
9b5824806e feat(audit): detect whitespace padding that hides instructions (#755)
Long blank spans and repeated filler can move meaningful instructions out
of view during skill review. Add four padding signals under the static
analyzer with Markdown exemptions and original-source line mapping.

Reuse rule overlays so global and project toggles and severity/confidence
overrides also govern this file-level detector. Cover threshold boundaries,
benign examples, optimized scans, reports and CLI rule controls.

Implements item 17 of #746.

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>
Co-authored-by: Willie <egg358358@gmail.com>
2026-11-05 14:31:23 +08:00
Willie 53a3207a17 fix(update): keep an agent's source when updating it (#778)
* fix(update): keep an agent's source when updating it

After the first `update agents`, an agent's recorded source became
`/agents/<name>.md` with type `unknown-subdir` and no repo URL, so
`check agents` stopped looking upstream and later changes never arrived
(#777).

The batch path rebuilt the repository source from the clone URL, subdir
and branch only, leaving Raw and Type empty, and the metadata written
back was built from that empty Raw. The fallback reinstall and the
dashboard update kept the agent's full source as Raw while clearing the
subdir, so the written source repeated the agent path.

AgentRepoSource now rebuilds the repository source once, by cutting the
agent path off the recorded source, and all three paths use it, so the
source written back is the one install recorded.

Agents whose metadata was already rewritten have no repository left in
it and need to be installed again.

* fix(check): compare each agent at its own branch and report unchecked agents

Agent update checks gave wrong answers in several cases next to #777:

- Agents from one repository were compared with the first agent's
  version, so an older agent sharing a repo with a current one never
  showed its update.
- The installed branch was never sent to the remote, so an agent pinned
  to a non-default branch was compared with the default branch head.
- A tracked agent repo records its full commit while the remote hash is
  abbreviated, so a fresh clone always read as update_available; its
  checked-out branch was also ignored.
- `update agents` printed "All agents are up to date" and exited 0 when
  agents could not be checked at all: an unreachable remote, unreadable
  metadata, or a source erased by the #777 bug.

Each agent is now compared with its own version at its own branch, and
an agent whose source the old bug erased reports an error asking for a
reinstall, since its metadata no longer names a repository. Update lists
the agents it could not check and exits non-zero, counting them apart
from agents that failed to update. The docs describe the error status
and the reinstall fix.

* fix(update): repair dashboard-doubled agent sources and share the update flow

Review of the previous commits found gaps in recovering agents that
earlier updates broke, and in how the two update handlers report them:

- A dashboard update before the #777 fix appended the agent path to its
  source a second time. Those agents keep their repo URL, so check offers
  an update, but discovery then failed on the doubled path. Every copy of
  the path is now cut, and the update writes the source back correctly.
- On the dashboard, an agent whose source the CLI bug erased failed with
  "invalid source: source cannot be empty". AgentRepoSource now returns
  the same reinstall error check shows, and both use one detector.
- When every tracked agent was such an erased agent, no remote was asked,
  so the "Checking agents" spinner was never stopped and drew over the
  error rows. It is now stopped once the check returns.
- The global and project handlers repeated the check-and-update flow,
  and the project copy had already drifted (no dry-run log entry, spinner
  in --json). Both now run one shared flow.

Tests cover the erased agent next to an updatable one in global, --json,
--dry-run and project mode, and the doubled and erased sources in
AgentRepoSource.
2026-11-04 22:15:55 +08:00
Willie 16de1df814 feat(herdr): add a skillshare panel for Herdr (#766)
Herdr users run several agents side by side and had to leave it to see
which skills need an update or a sync. The panel brings that view, plus
install, update, uninstall, audit hand-off and source repository sync,
into a Herdr layout node so it survives space switches.

Install audits its own shallow clone first, because install --json names
a blocked skill without its findings; a block shows them before anything
is written. Pull conflicts show both versions side by side, and
.metadata.json merges per entry with the same rule as MergeMetadata so
installs from both machines are kept.

model.js has no Herdr imports, so make test-herdr covers it in make check
and CI. Docs gain a learn/with-herdr page with translations and a README
highlight, and the context router loads herdr/AGENTS.md with frontend.
2026-11-04 16:01:45 +08:00
Willie 51d299ff07 fix(check): ignore OS metadata files when detecting local changes (#744)
Finder writes .DS_Store into any folder it opens, and Explorer writes
Thumbs.db and desktop.ini. These counted as skill content, so opening an
installed skill in a file manager made check report it as modified, hid
update_available, and made update skip it unless run with --force, which
also lowers the audit threshold.

Skip them when hashing a skill, drop hashes earlier versions recorded for
them (from .metadata.json and from legacy sidecar migration), and keep
audit integrity from reporting them. Their content is still audited.

Closes #743
2026-11-01 20:16:09 +08:00
Willie 78a8dc7c0d fix(trash): keep install metadata when restoring from the trash (#680)
* fix(trash): keep install metadata when restoring from the trash

Uninstall pruned a skill's, tracked repo's or agent's entry from the
central .metadata.json, and only the files went to the trash, so a
restore brought back a remote install as a local one: update and check
no longer knew its source (#679).

Uninstall now saves the entries it prunes, with their audit acceptances
and target overrides, beside the trash entry, re-keyed to the trash
name so they match where restore puts the item. uninstall.Restore and
RestoreAgent merge them back after the files return, and every restore
path (CLI, trash TUI, dashboard) goes through them; the dashboard
passes its cached store so it does not go stale. The saved copy is
taken with the same rule RemoveByNames uses and copies each entry, so
legacy repo-group entries are kept and re-keying never touches the
live store.

In project mode uninstall also drops the skill's .gitignore rule and
lock pin, so a skill restore reconciles the project skills afterwards.

trash.Delete removes an entry with its saved metadata, and replaces the
direct RemoveAll calls in delete, empty and the 7-day cleanup. Items
trashed before this change have no saved metadata and still restore as
local.

* fix(trash): keep live records of another path when restoring metadata

A legacy store keys a grouped skill by its basename, so the saved copy of
frontend/foo was keyed "foo". If a different skill was installed as
root-level foo while frontend/foo sat in the trash, restoring it replaced
the root skill's record and lost its source.

Extract now writes full source-relative keys (legacy repo-group entries
keep theirs, since their Group is not their path), and Merge keeps a live
entry whose key names a different path instead of overwriting it. Merge
is shared by skill and agent restore, so both are covered.
2026-10-31 17:25:04 +08:00
Willie 7f268e88d7 fix(update): allow lazy blob fetches between partial clone and candidate (#668)
Tracked repos are shallow blob:none partial clones, so they lack the
blobs of intermediate commits. Since git 2.45.1, a local upload-pack
refuses to lazy-fetch missing objects, so both the candidate clone and
the publish fetch back into the checkout failed with "fetch-pack:
invalid index-pack output" once more than one upstream commit arrived.

Re-enable lazy fetching only for these two local transports, whose
source is our own checkout, and pass origin's auth env so private
repos can supply the blobs. Fetched blobs are hash-addressed, so the
published tree still matches the audited revision.

Closes #667
2026-10-29 22:46:11 +08:00
Willie 23c9453f87 fix(update): serialize checkout updates across skillshare processes (#666)
Two dashboards (or a dashboard and the CLI) serving the same source ran
"Update all" at once. The server mutex only covers one process, so both
pulled into the same checkouts: one saw the other's half-applied merge as
"local changes would be overwritten", and concurrent fetches into a
blob:none clone failed with "fetch-pack: invalid index-pack output".
update.TrackedRepo, install --track --update, and the in-place pull of a
git-installed skill now hold a flock in the checkout's git directory; a
second process waits up to a minute, then fails with a clear message.

Force on a git-installed skill only skipped the local-modification check
and then ran a plain pull, which refused to merge over the edits the docs
say --force discards. It now fetches and resets to upstream, so a failed
fetch still keeps the edits. Followed checkouts keep pulling, since they
must be clean and may hold the user's unpushed commits.

The pull error dropped the file list git indents under it, and the
finished-update subtitle said everything was up to date even when items
had failed.
2026-10-29 16:20:30 +08:00
Willie efc492fd7a fix(update): audit tracked candidates before publication (#647)
* fix(update): audit tracked candidates before publication

Prevent rejected tracked-update bytes from becoming readable through published target links by staging and auditing a private candidate before updating the active checkout. Publish the exact approved revision without a second upstream pull.

Preserve sparse state, audit metadata, followed checkouts, and compatible edits. Recover staged and unstaged changes after failed forced publication, including deletions, renames, and sparse exclusions. Cover the boundary deterministically and align error messages and localized documentation.

* fix(update): preserve local bytes across Git line-ending conversion

Overlay dirty worktree bytes after staging candidate patches so core.autocrlf does not silently rewrite local edits. Cover staged, unstaged, and cancelled worktree changes while retaining their index state.

Make permission-failure coverage explicitly POSIX-only and compare private checkout contents to their original bytes. Align red-team assertions with candidate rejection and register private temporary cleanup with the raw-write guard.

* test(install): normalize checkout after configuring line endings

Windows fixtures initially inherit core.autocrlf=true. Reset the isolated checkout after selecting the subtest setting so changing it to false does not turn untouched upstream files into local edits.
2026-10-26 15:59:32 +08:00
Willie 2d196c286b feat(check): show what changed in a skill since install (#623)
* feat(check): show what changed in a skill since install

#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.

* fix(install): diff local changes against the full installed commit

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.

* test(install): keep checkout line endings when editing in LocalChanges 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.
2026-10-24 17:32:34 +08:00
Willie 7a7cceefab feat(update): flag and protect skills edited since install (#622)
* feat(update): flag and protect skills edited since install

A skill installed from a repository and then edited by hand looked
exactly like an untouched one: check said up to date, and update either
reported it current or silently reinstalled it over the edit (#621).

Install already records each file's hash, so check now compares a
remote skill's files with those hashes and reports "modified", and
update skips such a skill until --force (CLI single, --all/--group,
dashboard). --force, the dashboard's Force Retry on the skipped row, or
the confirmation on the skill page discards the edit and reinstalls.

Two hash paths had to be made reliable for this to be trusted: the
dashboard's folder-wide target edit refreshed hashes by basename, so a
nested skill looked edited after skillshare's own change, and a skill
whose files cannot be hashed now counts as modified instead of being
overwritten.

* fix(server): keep earlier local edits when a target change rewrites SKILL.md

Changing a skill's targets in the dashboard rewrites its SKILL.md, and
both the folder-wide and the single-skill handler then re-hashed the
whole directory as the new baseline. An edit the user had already made
to any file in the skill was absorbed into that baseline, so the skill
stopped counting as modified and the next update overwrote the edit
without --force.

Both handlers now move only SKILL.md's recorded hash, and only when the
file still matched it before the rewrite. skillshare's own target edit
no longer reads as a local change, and an earlier edit still does. The
whole-directory refresh helpers lost their last callers and are removed.
2026-10-24 16:33:37 +08:00
Willie 330114bd6a fix(install): use frontmatter names for generic skill directories (#617)
* fix(install): use frontmatter names for generic skill directories

Resolve meaningful defaults for generic containers while preserving explicit names, tracked paths, existing update destinations, and directory-based source selection. Fall back on unsafe or colliding names to prevent overwrites.

Cover global and project installs, local and Git sources, naming overrides, tracked reports, collision safety, and updates. Closes #616.

* fix(install): preserve names during source-based updates

Resolve source-based updates against existing metadata before choosing destinations. Reject ambiguous or colliding update targets before writes, and reserve case-insensitive discovery names across filesystems.

Add global/project regressions for local and Git source updates, legacy destinations, grouping, and upstream-added collisions.

* fix(install): retain update ownership and selection checks

Only allow a metadata-verified same-source update to bypass destination conflicts. Reject occupied fallback destinations for both local and Git sources unless overwrite is explicitly forced.

Resolve destinations after skill selection so unrelated conflicts do not block filtered updates. Cover cross-source and unmanaged destinations, selected/excluded updates, and collision aborts in global and project modes.
2026-10-23 20:04:45 +08:00
Willie 7b952c02a9 fix(update): honor accepted findings in dashboard tracked updates (#599)
* fix(update): honor accepted findings in dashboard tracked updates

The dashboard ignored findings accepted through the CLI, so a tracked repo
that `update --force` let through was blocked again on the next dashboard
update, and every dashboard Force Retry had to be repeated. Regular skill
updates in the dashboard already honored and recorded acceptances, so only
tracked repos differed.

Tracked-repo updates now always honor accepted findings and record the ones
an override lets through, for both callers. The opt-in option and the
AuditGate flag it fed are removed, since no caller turns them off.

Dashboard agent tracked repos passed an empty source dir, so a nested repo
kept acceptances in its group folder under a different key than the CLI.
They now pass the agents source, as the CLI does.

* fix(update): reload the agents store after agent repo refresh

Dashboard agent tracked repos now refresh metadata in the agents source,
but a metadata change reloaded the skills store, leaving the agents store
as it was until the next request. Reload the store that matches the source.

Every caller of update.TrackedRepo now passes a source dir, so the
empty-dir guard and its doc no longer describe a supported mode. The new
agent test reuses the tracked fixture instead of rebuilding it.
2026-10-21 23:28:16 +08:00
Willie 4a5dacac6b feat(mcp): let mcp serve clients edit listed skills (#577)
* feat(mcp): let mcp serve clients edit listed skills

A remote assistant that reaches skills only through `mcp serve` could
read them but had to hand every change back to a person (#540). Skills
listed in `mcp.serve.edit.skills` can now be changed one existing file
at a time: `preview_skill_edit` writes nothing and returns the full
diff, the audit result and a preview id, and `apply_skill_edit` saves
exactly that preview, once.

Every save is tied to the revision the client read, so a file changed
in the meantime fails with a conflict instead of being overwritten.
Skills that `update` would overwrite stay read-only: tracked repos,
upstream installs, and skills nested inside an install. The skill is
validated and audited in a temporary copy before anything is written;
as with install, a finding at or above `audit.block_threshold` refuses
the edit unless it was accepted with `--force`, and findings are marked
new or existing so the client can see what its change adds.

The write is atomic, keeps the file mode, goes through sourcefs link
checks, and is recorded in the operation log. Native Skills extension
clients still see the edit tools, since the extension cannot write.

* fix(mcp): close gaps in mcp serve skill editing

Codex review of #577 found five ways the edit tools could do more, or
record less, than they promise:

- A blank pattern in mcp.serve.edit.skills was dropped by the filter,
  and no patterns match every skill, so `skills: [' ']` made every skill
  editable. Blank patterns are now a config error.
- preview_ttl was only checked when skills were listed, so the dashboard
  could save an invalid value that later stopped mcp serve. It is now
  checked whenever edit is present.
- Apply compared only the edited file's digest, so two previews of
  different files, or an edit made elsewhere in between, could save a
  skill state that was never validated or audited. Apply now checks and
  audits the skill again as it will be saved.
- Edit audits were not written to audit.log, so blocked attempts left no
  trace in `skillshare log --audit`. Each preview and apply audit is now
  logged like install's audit gate.
- The writability check migrated legacy metadata, so a "writes nothing"
  preview (and --check) could rewrite .metadata.json and delete
  registry.yaml. It now reads the store without migrating; a legacy
  registry.yaml keeps every skill read-only, and a legacy sidecar marks
  its skill as installed.
2026-10-15 22:30:39 +08:00
Willie 0c69dad6c2 fix(update): stop trusting tree hashes for skills with symlinks (#573)
* fix(update): stop trusting tree hashes for skills with symlinks

Install copies a file symlink's target, but git stores the link as a blob
holding the target path, so a skill's subtree hash stays the same when a
target outside the folder changes. Batch update skipped such skills as
current and check reported them up to date, leaving stale content installed.

A subdir that holds a symlink now has no usable tree hash: install records
none, update falls back to a reinstall, and check reports the skill as
update_available. Check lists entries with -z so links with non-ASCII names
are not missed behind git's path quoting.

Closes #572

* fix(check): split ls-tree -z output on NUL only

parseLsTreeOutput also split on newlines so the old newline fixtures kept
passing, but with -z a newline belongs to the path. A directory or symlink
whose name holds a newline was cut in two, and a symlink under it was missed.
The fixtures now use NUL-terminated entries like real -z output.

Also writes both shortcut comments in the repo's one-line form and uses
testutil.RunGit in the new update test instead of a raw exec call.

* docs(update): note that skills with symlinks always reinstall

The update page says grouped updates leave skills whose folder did not
change alone. A skill with a symlink no longer has a usable tree hash, so it
is reinstalled whenever the upstream commit moves. State that exception on
the English page and its four translations.
2026-10-15 00:22:15 +08:00
Colin MasonandWillie c4b183f6ef fix(update): read store in batch fast path (#569)
* fix(update): read store in batch fast path

The grouped update fast path read per-skill .skillshare-meta.json
sidecars. The migration to .metadata.json deletes those files, so the
check never matched and update --all reinstalled every skill on every
run.

Read the central store instead, and refresh version and commit there
instead of writing a sidecar. Require SKILL.md on disk so the update
restores a deleted install. --force now skips the check and reinstalls
everything.

* test(update): cover legacy grouped metadata keys

Grouped skills can still be stored under a basename key with a Group
field. Check that the current-skill lookup finds that entry and that the
version refresh updates it in place instead of adding a new key.

* feat(update): report up-to-date skills

The summary lumped skills the fast path skipped in with failures. Count
them as "up to date" in the summary and as up_to_date in --json
output.

* feat(update): log up-to-date count in oplog

The operations log recorded updated, skipped, pruned, and blocked counts
for update but not the new up-to-date count. Record it as up_to_date
so the log matches the summary and --json output.

* test(update): cover up-to-date batch skills

update --all reinstalled every grouped skill on every run. Check that
unchanged skills report as up to date in global and project mode, that
an upstream change updates only the changed skill, and that --force
reinstalls everything.

* docs(update): describe up-to-date batch skills

Describe how update --all and --group leave unchanged skills alone and
report them as up to date, the up_to_date JSON field, and the new
meaning of --force.

* fix(update): keep lock pins on tree-only matches

A tree-hash match after upstream HEAD moved refreshed the full commit in
the store. A project lock pin follows that field, so an unrelated
upstream commit rewrote skills.lock.json even though the skill's files
did not change. Refresh only the version, as the old sidecar refresh
did. check compares the version, so it still reports the skill as up to
date.

The help text, docs and skill reference said --all and --group skip
current skills. The skip lives in the batch path, which runs for any
update of several skills, and a single skill always takes the reinstall
path. Say that instead.

* fix(update): load the store once per batch

Each skill skipped as current reloaded .metadata.json before comparing
its version, so an unchanged batch reparsed the whole store once per
skill. Compare the version already read from the snapshot first, and
refresh the skills that do lag HEAD with one load and save after the
loop. An unchanged batch of 400 skills drops from about 520ms to 64ms.

The help text and docs said any update of several skills takes this
path. In global mode, named and glob targets carry no metadata and
reinstall on the standalone path. Name what does take it: --all,
--group, and several skills named in project mode.

---------

Co-authored-by: Willie <egg358358@gmail.com>
2026-10-14 23:36:56 +08:00
Willie 1094668408 fix(install): keep git tokens out of process arguments (#566)
Token auth rewrote the clone URL with url.<user>:<token>@host.insteadOf.
git hands the rewritten URL to git-remote-https as an argument, so any
user on the machine could read the token with ps for as long as a clone
or fetch ran. Every platform token (GitHub, GitLab, Bitbucket, Azure
DevOps, Gitea, CNB) went through the same rewrite.

git now gets the token from a credential helper scoped to the host,
which reads it from SKILLSHARE_GIT_AUTH_PASSWORD; printf is a shell
builtin, so the token never reaches an argv. An empty helper entry
first clears the user's own helpers for that host, so git neither asks
their keychain nor erases from it on a 401, and no longer stores the
skillshare token there as the URL rewrite did.

An http.extraHeader was tried first and dropped: the header goes out
before any 401, so a stale token broke installs from public repos, and
after a rejection git fell back to the user's helper and erased their
stored credentials.

Refs #565
2026-10-14 13:36:09 +08:00
Willie 89f4b9425a refactor(reconcile): share the lock pin mover, skip adoption when no record is gone (#524)
Cleanup after #523: install.MoveLockPins shared by skillmove and the project reconcile; one server store reload and reconcile dispatcher; adoption skips the source walk when no plain record's directory is missing.
2026-10-11 04:19:32 +08:00
Willie bf1731dec4 feat(move): move installed skills and folders without losing their records (#520)
Add skillshare move and POST /api/resources/batch/move so skills and
whole folders can change folder inside the source while keeping their
.metadata.json entry, accepted audit findings, lockfile pin, config
group, .gitignore and literal .skillignore lines. Moving by hand lost
the record and made the next install start over. install --into now
refuses a folder inside a skill or a tracked checkout.

Refs #510
2026-10-11 00:43:47 +08:00
Willie dcffa2ec5e fix(install): keep a moved skill's record instead of reinstalling it (#513)
* fix(install): keep a moved skill's record instead of reinstalling it

Install records are keyed by path, so a skill moved with mv shows up as
missing. "Install missing" (and bare `skillshare install`) then cloned it
again at the old path, leaving two copies that both sync to targets, and
reconcile could hand the new copy's record to the moved one.

A gone record now follows an unrecorded directory of the same name whose
files match the recorded hashes, when exactly one such directory exists.
Install-from-config skips such entries and reconcile re-keys the record,
so the moved copy keeps its source. Same-name skills with other files are
left alone, so an update can never overwrite them from that source.

Refs: #510

* fix(install): keep audit acceptances and unreadable links out of moves

Re-keying a moved skill went through Remove, which also drops the audit
findings accepted for the old path, so an unchanged skill could block or
prompt again on its next update. MoveEntry now carries them to the new key.

A record below a first-level source link that cannot be read looks gone
to Lstat, so an identical copy elsewhere could take its record while the
link was down. Such records are no longer matched as moved.

* fix(install): drop legacy-path acceptances and respect lock pins on move

A legacy basename key such as `demo` with group `old` keeps its accepted
audit findings under `old/demo`. MoveEntry removed only the key's own
acceptances, so the old path kept them and a later skill placed there
would inherit them without a new --force. It now deletes the old path.

When the lockfile pins another commit than the moved copy holds, treating
the copy as the moved skill re-keyed its stale record and let the project
lock be rewritten with the older commit. Such copies no longer count as a
move, so the pinned commit is installed as before.

* fix(install): search for moved skills only where reconcile looks

The search for a moved copy walked into installed skills and tracked
checkouts, which reconcile skips. A copy found there made install skip the
skill, then reconcile never saw the copy and pruned the record, and in
project mode the config entry with it. The search now stops at the same
boundaries.

* fix(install): never take a recorded skill as another's moved copy

Two identical skills can be recorded at different paths. When one of them
went missing, the other matched its hashes and was taken as its moved
copy, so install skipped the missing skill and reconcile pruned its record.
A directory with a record of its own is now never a move destination.

* fix(install): derive moved-copy paths from the resolved source root

sourcewalk.WalkDir reports paths under the resolved source root, but the
moved-copy search took them relative to the unresolved one. With a linked
source (or Windows short temp paths) every path came out as ../..., so the
installed-skill boundary never matched and a copy inside an installed
parent could be taken as the move, after which reconcile pruned the record.
The search now resolves the root first, as reconcile does.

* fix(install): move a record only to one copy of what the config declares

Three cases still let a move drop or misplace a record:

- In project mode the manifest can point a skill at a new source while a
  copy of the old one exists elsewhere; that copy was taken as the skill,
  so the new source was never installed. The record's source and branch
  must now match the config entry.
- A git checkout reconcile treats as tracked could be accepted before the
  tracked boundary was checked; the boundaries now run first.
- With two identical copies, reconcile re-keyed the record to whichever
  it walked first. Both reconcile and the install-from-config search now
  require exactly one destination, and reconcile decides after the walk.

* fix(install): clear accepted findings left at a move destination

A removed legacy grouped entry can leave findings accepted for its path
behind. MoveEntry only wrote the destination when the moved skill had its
own acceptances, so a skill moved into that path inherited findings it
never accepted. The destination is now cleared before the transfer.

* fix(install): follow a moved skill only while its declaration still matches

The install-from-config search compared source and branch but not the
tracking mode, so a skill switched to tracked was satisfied by an old
plain copy and never cloned.

Project reconciliation, which other installs also run, inferred moves
without looking at the manifest at all. A record whose declaration now
names another source could follow a copy of the old source, after which
the manifest entry was rewritten to that old source. Moves in project
mode now require the declaration to still match the record, through the
same MatchesDeclaration check the install path uses.

* fix(install): infer no move while a source link is unreadable

An unreadable followed source link can hide a second identical copy, so
a copy that looked unique could take the record arbitrarily. Reconcile
and the install-from-config search now infer a move only from a complete
inventory; reconcile already keeps the gone record in that case.

* fix(install): infer no move when the source walk hit an error

Both walks dropped traversal errors, so an unreadable directory that hid
a second identical copy left the visible one looking unique and it could
take the record. Any walk error now counts as an incomplete inventory,
like an unreadable source link, and no move is inferred from it.

* fix(install): keep a record whose move waits on a failed walk

When a walk error deferred a move, the walk still counted as complete, so
pruning dropped the gone record along with its accepted audit findings
and it could never follow the copy. A failed walk that deferred a move
now marks the inventory incomplete, as an unreadable source link does;
a failed walk with no move candidate keeps the old behavior.

Also correct InstallFromConfig's comments, which still said reconcile
runs only after an install.

* fix(install): move a moved skill's gitignore rule in project mode

Project reconcile added the managed ignore rule for a moved skill's new
path but left the old one, and the gitignore update only ever adds. If
the old path later held source-controlled files, Git kept ignoring them
without a word. Reconcile now reports the paths records moved away from,
and project reconcile removes their managed rules before adding the new.

* test(config): skip the unreadable-directory reconcile test on Windows

Windows does not stop reading a directory created with mode 0, and
os.Geteuid reports -1 there, so the root-only skip let the test run and
fail on the Windows runner.

* fix(install): count a candidate that cannot be hashed as an incomplete search

MovedEntryKey dropped a same-name candidate whose files could not be
hashed, so a readable identical copy beside it looked unique and could
take the record. It now returns the hash error, and reconcile and the
install-from-config search treat it like a walk error: no move is
inferred from that scan, and reconcile keeps the record waiting.
2026-10-10 23:14:52 +08:00
Willie 2ce46834e2 fix(collect,install): collect only real skills; let --track take a local git path (#508)
* fix(collect,install): collect only real skills; let --track take a local git path

collect treated every directory in a target as a local skill, so a scratch
folder was listed and `collect --force` copied it into the source. A folder
now counts only when it holds SKILL.md; the dashboard scan shares
FindLocalSkills and the dashboard collect request rejects such a folder.

`install /path/to/repo --track` failed with "requires a git repository
source" while file:///path worked. A local path that is a git repository
root is now normalized to the same file:// clone URL for --track (also past
the --branch guard); other local folders get an error that names file://.
Help text, docs (English and i18n) and the built-in skill reference follow.

* fix(install): keep the drive letter in file:// clone URLs for local --track paths

A Windows path such as C:/repo produced file://C:/repo, which makes C: the
URI authority instead of part of the path, so a tracked install from a local
Windows repository could clone the wrong location. Prefix the missing slash
so the URL is file:///C:/repo; POSIX paths are unchanged. Also cover the
dashboard install endpoint with a local-path --track test.

* fix(collect,install): keep UNC file URLs intact; require SKILL.md to be a file

The drive-letter fix lived in the helper shared with explicit file:// URLs,
which rewrote file://server/share/repo into a local path. Keep the slash
logic in the local-path --track case only and leave explicit URLs as parsed.

A subdirectory named SKILL.md passed the existence check, so a scratch folder
holding one was still collected. Both collect entry points (scan and the
dashboard request) now share sync.HasSkillFile, which rejects directories.

* fix(install): escape the local path in the file:// URL used by --track

Git decodes a file:// URL, so a repository path containing %20, %2F, a space
or # was cloned from a different path than the one IsGitRepo accepted. Build
the URL with net/url so those characters are escaped; drive-letter and POSIX
paths keep their form. The integration test now installs from a directory
whose name contains a space and a literal %20.

* fix(install): accept a local bare repository path for --track

A bare repository has HEAD and objects at its root but no .git entry, so the
local-path check rejected it while file:///same/path cloned fine. Add
IsLocalGitRepo (working tree or bare) and use it for both the --track
normalization and the --branch guard.

* test(install): build the bare repo path from a Windows file URL correctly

makeRemote returns file:///C:/dir on Windows; trimming only file:// left
/C:/dir, which filepath.Abs turned into D:\C:\dir, so the bare-repo test
failed on the Windows runner. Drop the slash before the drive letter.

* fix(install): refuse a --track local source that is the install destination

--force removes the tracked destination before cloning. When the local path
given to --track is that same directory, the removal deleted the only clone
source (and any unpushed work) before the clone failed. Compare the two with
os.SameFile, which also covers symlinked paths, and stop before touching the
destination.

* fix(install,collect): keep a tracked source inside its destination; reject special SKILL.md files

--track --force removed the destination before cloning, so a local source
nested below it (or given as an explicit file:// URL) was deleted along with
any unpushed work, and the clone then failed. Resolve the source and refuse
when it is the destination or lies under it, for dry runs too.

HasSkillFile used a not-a-directory test, so a FIFO named SKILL.md counted as
a skill and the collect copy blocked on it. Require a regular file; a
symlinked SKILL.md still resolves through os.Stat.

* fix(install): treat file://localhost URLs as local clone sources

Git clones file://localhost/path from the local filesystem, but the
containment guard only recognised an empty authority, so --track --force
could still delete a source given that way. Accept localhost (any case) as
local.

* test(install): build the localhost file URL from a slash path

On Windows the temp path starts with a drive letter, so prefixing it onto
file://localhost produced file://localhostC:\... instead of a valid URL and
the case failed on the Windows runner. Convert to slashes and add the
separator explicitly.

* fix(install): clone --track --force into a staging dir and swap it in last

--force removed the existing tracked repo before cloning, so any source that
lived under it (plain path, file:///, file://localhost, UNC, symlink or 8.3
alias) was destroyed before git could read it, and a failed clone also lost
the old repo. Clone beside the destination, run the checks and the audit on
the staging copy, then move the old repo aside, rename the new one in and
drop the backup; on any failure the staging copy is removed and the old repo
stays. The pre-removal containment refusal now covers plain local paths only
(the url.Parse special-casing is gone).

* fix(install): refuse a file:// --track source inside the forced destination

The staged swap in 7375400 still lost data for a file:///, file://localhost
or UNC source nested under the destination: the clone succeeded, the old repo
(with the source inside it) was renamed to the backup, and removing the backup
deleted the source's uncommitted work, which a clone cannot carry.

Restore the file URL to local path mapping (now including UNC hosts) so the
containment refusal covers every local spelling, not only plain paths. The
test now keeps an uncommitted file in the source and requires it to survive.

* fix(install): apply the source-inside-destination refusal only to --force

The refusal ran before the --update branch, so `install <tracked repo path>
--track --update` was rejected even though an update pulls the existing
checkout in place and removes nothing. Only the forced replacement can
destroy a source that lives under the destination, so check there.

* fix(install): report a forced clone's root skill under its tracked name

With --force the repo is discovered in the .skillshare-clone-<stamp> staging
directory, and discoverSkills names a root SKILL.md after the directory, so
the CLI summary, dashboard response and oplog listed a random staging name
instead of _foo. Use the tracked name for the root entry.

* fix(install): stage fresh tracked clones so cleanup never hits another installer

A fresh tracked install cloned straight into the destination, and the
deferred cleanup removed it on any failure. If another process created the
same tracked repo between the existence check and the clone, the failing
install deleted that process's checkout. Clone every install into its own
staging directory and rename it in last; a claimed destination makes the
rename fail and only the staging copy is removed.
2026-10-10 01:06:23 +08:00
Willie 906669df75 fix(install): reuse a tracked checkout cloned under the old basename name
Tracked repos are now named owner-repo, so repeating `install --track` for a
repo cloned earlier as _<basename> went to a new _owner-repo path and cloned a
second copy whose skills collide during sync. When that older checkout has
the same remote, keep using its name so the install skips as the same repo.
2026-10-08 12:54:45 +08:00
Willie e3af6274fc feat(install): install config entries from the dashboard and name repos by owner
Bare `skillshare install` already restores everything .metadata.json records
but the disk lacks, yet the dashboard could only re-clone missing tracked
repos through a separate rehydrate path. Expose the CLI's install-from-config
flow instead (GET /api/install/missing, POST /api/install/from-config) so both
surfaces share one detection and one installer, and drop the old
missingTrackedRepos plumbing from update responses.

The install summary now counts tracked repos and their skills apart from
standalone skills, since "Installed 1 skill" hid a whole repo. New tracked
repos are named `_<owner>-<repo>` so two `skills` repos no longer collide;
existing installs keep their names. `check` passes the stale status through
so the dashboard can offer to prune skills deleted upstream.
2026-10-08 12:01:42 +08:00
Willie 414d193114 fix(update): keep an existing skill ahead of the nested shorthand
Codex review of #481 found three problems with the shorthand change:

- `update org/team -p` and the dashboard stream updated the org/_team
  repo even when a skill exists at org/team, which used to win because
  the shorthand was not rewritten there. FindTrackedCheckoutUnlessSkill
  skips the nested shorthand when a directory exists at the typed path;
  plain names keep their repo-first behavior.
- Global `update team/` cleaned the name for repo matching but not for
  skill matching, so it silently updated `_team` instead of reporting the
  skill/repo collision that `update team` reports. resolveByBasename now
  cleans the name once for both.
- The update.md example sits in the Project Mode section but lacked -p
  (also in the four translations).
2026-10-07 23:58:43 +08:00
Willie 84ed67b13d fix(update): accept the org/team shorthand for --into repos in every entry point
A repo installed with `--track --into org` lives at `org/_team`. Only
POST /api/update accepted `org/team`; the dashboard stream and
`update -p` prefixed the whole name (`_org/team`), and global `update`
compared the full name with the basename, so each reported not found.

Move the candidate rule (the name as typed, then `_` added to the last
segment, never leaving the source root) into install.FindTrackedCheckout
and the basename match into install.MatchTrackedRepos, and use them from
the single update, the stream, project and global CLI update. A shorthand
resolves to its own `org/_team`, never to a top-level `_team`; plain names
and full paths keep their behavior.
2026-10-07 23:51:37 +08:00
Willie 84688b6e37 fix(update): keep --into repo metadata refresh on its own entry
With --into repos from #472, org/_team and a top-level _team can share a
basename. When org/_team had no entry of its own, the root-skill hash
refresh found _team's entry through GetByPath's basename-only fallback and
overwrote its hashes, which later broke _team's integrity and up-to-date
checks. The refresh now only touches the repo's own entry (exact key, or a
legacy basename key with the matching group).

resolveTrackedRepo built the prefixed --into candidate with filepath.Join,
so on Windows the dashboard result came back as org\_team while #472 made
every other repo name slash-form, and the UI could not match the row.
2026-10-07 22:47:33 +08:00
Willie e589336bef Merge origin/main (#472) into runkids/473-tracked-repo-update
Resolve the conflict in getTrackedReposImpl by keeping both sides: the
IsTrackedCheckout rule from this branch and the slash-form paths #472
returns for --into repos (org/_repo). Add a GetUpdatableSkills test for a
rewritten --into checkout next to a top-level one.
2026-10-07 22:46:15 +08:00
Willie 3479c42420 fix(update): share the tracked checkout rule and tighten the repair
Simplify and code-review passes over #474 found the fix spread over
several definitions of "tracked repo" and three holes in the repair.

One install.IsTrackedCheckout (a _-prefixed git checkout) now backs
GetTrackedRepos, GetUpdatableSkills, the dashboard routing and the repair.
GetUpdatableSkills skipping such entries replaces the two CLI resolver
filters, so `skillshare check` and the dashboard Updates tab no longer list
a rewritten repo a second time as a regular skill. The repair checks that
one path instead of walking the whole source tree.

- Reconcile sets tracked on a checkout again without dropping type or
  repo_url, so a rewritten entry that went through it was never cleaned.
  The repair now also runs when those regular-install fields remain.
- The repair used GetByPath, whose basename fallback can return another
  top-level item's entry; it now uses the repo's own key.
- A tracked entry whose checkout is gone fell through to the basename
  fallback of resolveTrackedRepo and pulled a different repo with the same
  basename. It now reports the repo as missing on disk.
2026-10-07 22:33:54 +08:00
Willie 51d0a1e5e9 fix(update): repair tracked repo entries rewritten as regular installs
The old dashboard update rewrote a tracked repo's metadata entry as a
regular install: tracked was dropped and type, repo_url and version were
added. Those repos stayed broken after the routing fix, because
`skillshare update <repo>` found the name twice (as a repo and as a
regular skill) and refused it, and nothing restored the entry.

The shared tracked-repo update now restores such an entry to what
install --track records (source, branch, group, tracked) when its path is
a checkout GetTrackedRepos lists, so regular skills are never touched.
CLI name and glob resolution skip a regular-skill match whose path is
already a tracked repo, so the update can reach that repair.

Codex review: the routing fix sent every git checkout with metadata to
the tracked-repo update, including standalone skills installed as a full
checkout, whose regular update records the new version and commit.
Their version stayed stale and update checks kept reporting an update.
Only tracked entries and _-prefixed checkouts now skip the regular path.
2026-10-07 22:16:56 +08:00
Willie c9b649143d refactor: return slash repo paths and simplify --into repo lookup
GetTrackedRepos returned OS-native paths, so every caller that compared
them with slash paths (RepoRelPath, dashboard repoPath, metadata keys)
had to convert first. Two callers in install_queries already did, and
this branch added four more. It now returns slash paths on every OS,
matching GetMissingTrackedRepos; filepath.Join and filepath.Base accept
them on Windows, and `update org/_repo` now also matches by full path
there. The per-call-site conversions are gone.

Smaller cleanups in the same code:
- repoOf takes the slash relPath and looks up prefixes by substring, so
  the walk no longer splits and joins per directory;
- repo .skillignore matchers are keyed by the same slash rel path, so
  isSkillIgnored no longer needs walkRoot;
- batch uninstall uses utils.IsTrackedRepoDir instead of a literal "_";
- the dashboard uses repoOf where it spelled out isInRepo && folderOf;
- the new tests reuse postBatchUninstall and share one --into sandbox.
2026-10-07 21:35:05 +08:00
Willie f2f663689b fix(install): warn about submodules on tracked updates
The CLI and dashboard update a tracked repo through update.TrackedRepo,
which never looked for submodules. A pull that turned a skill directory
into a submodule reported success and the skill vanished on the next
sync. TrackedRepoResult now carries the skipped-submodule warnings and
both callers show them.

Refs #433
2026-10-07 09:35:59 +08:00
Willie 0a484083e5 fix(install): warn about submodules on direct whole-repo installs
CLI search results install a repo-root skill through installFromGit without discovery, so the skipped-submodule warning has to come from that path too.
2026-10-07 02:46:26 +08:00
Willie 79bb10658a fix(install): strip submodule URL userinfo before query and fragment
A ? or # inside the userinfo used to cut away the @ before it was found, leaving the credential in place.
2026-10-07 02:40:48 +08:00
Willie b1b5bcc375 fix(install): fail closed when submodules cannot be listed and warn on tracked updates
A failed or timed-out git ls-tree used to look like a repo without submodules, letting an empty submodule path through; the refusal check now reports the failure while warnings stay best effort. Tracked updates also warn about submodules in the pulled tree.
2026-10-07 02:36:44 +08:00
Willie 6607b82e2b fix(install): escape submodule diagnostics and match ancestors by filesystem identity
Gitlink paths and .gitmodules URLs come from an untrusted repo, so quote them with %q to keep newlines and terminal escapes out of CLI output. Compare each ancestor of the subdir with the gitlink directory by os.SameFile instead of a byte-length prefix, so case and Unicode-normalization variants that open the same directory are caught.
2026-10-07 02:29:48 +08:00