Commit Graph
1719 Commits
Author SHA1 Message Date
Willie def12c51ca chore: update docs 2026-05-30 19:23:12 +08:00
Willie e1c4761333 fix(extras): apply output_ext when computing diff target filenames
The /api/extras/diff path resolved the copy mode but ignored a transform
extension's output_ext, so buildExtrasDiffItems compared source relative
paths against the target directory. After a .md -> .toml transform sync,
the diff looked for the original .md name and reported false drift, even
though the status path already handled this.

Export ApplyOutputExt as the single source of truth for source->target
filename mapping (previously unexported applyOutputExt) and use it in the
diff path so sync, status, and diff all agree on the transformed name.
2026-05-30 19:23:12 +08:00
Willie 2f6f6bd052 fix(git): enforce root-scope safety on commit/push instead of warning
Root-scope git operations detected hazards but proceeded anyway, letting
preventable mistakes reach the remote:

- Nested git repos were only warned about, then committed/pushed as empty
  submodules (silent data loss). Now commit/push abort (CLI non-zero exit,
  server 400) until the nested repos are disabled, and the web UI disables
  the commit/push buttons while any are present.
- The pre-stage safety sweep ran before the dry-run check, so `--dry-run`
  wrote .gitignore and ran `git rm --cached config.yaml`. The sweep/guard is
  now strictly read-only on dry-run and only reports what would change.
- Server git endpoints used EffectiveGitRoot() without validating git_root,
  so a hand-edited invalid scope silently fell back to skills. They now share
  a gitSource() guard that rejects invalid scopes with 400, mirroring the
  CLI's resolveGitRoot.
2026-05-30 19:23:12 +08:00
Willie 599c6e2160 fix(ui): honor status filter in grouped resources view
The grouped (folder tree) view ignored statusFilter in its isSearching, clear-filters, and empty-state logic, so filtering to Enabled/Disabled with no matches looked like an empty library instead of a filtered view with no results. Mirror the grid/table behavior by including statusFilter in all three checks.
2026-05-30 19:23:12 +08:00
Willie 4435429ada fix(extras): detect target conflicts in transform sync dry-run
A transform-mode dry-run counted every file as synced without inspecting the target, so it claimed it would sync files that a real non-force sync would skip. Report an existing real file (under the transformed name) as a skip needing --force, mirroring the non-dry-run path. The dry-run still never spawns the extension subprocess, so content is compared conservatively by existence rather than by output.
2026-05-30 19:23:12 +08:00
Willie 7419bc74d2 fix(extras): resolve extension target mode consistently in CLI and server
The dashboard computed extension target status with EffectiveMode, which defaults an empty mode to merge, so a valid transform extension target (extension set, no explicit mode) was always reported as drift. Introduce sync.ResolveExtensionMode as the single source of truth (empty/copy resolve to copy, anything else errors) and use it across the CLI, sync, status, and diff paths.
2026-05-30 19:23:12 +08:00
Willie fc07a3c3ea fix(config): reject invalid git_root scope keyword
An unknown git_root value silently fell back to the skills scope via ScopeDir's default case, so a typo like "agnets" made commit/push/pull operate on the wrong repository without any warning. Validate the scope at the commit/push/pull entry point (resolveGitRoot) and in ValidateConfig, reusing the existing ValidGitRoot check backed by a new ValidGitRoots list.
2026-05-30 19:23:12 +08:00
Willie 53e4a02a7b i18n(git-root): clarify config.yaml tracked notice (explain machine-specific paths) 2026-05-30 19:23:12 +08:00
Willie eda9ac75a4 feat(git-root): guard root scope against submodule traps and config leaks
At the root git_root scope, `git add -A` over the config base directory
records any subdirectory that has its own .git (e.g. the skills source) as
an empty submodule, and can commit the machine-specific config.yaml.

- Detect nested repos and warn before commit/push (CLI) or surface them on
  the Git Sync page with a one-click "Disable nested .git" action (UI),
  which renames .git to .git.disabled (reversible) and drops any stale
  gitlink from the index so the directory's files track as normal blobs.
- Keep config.yaml out of a root-scope repo automatically: ensure it is
  ignored and untrack it (git rm --cached) before staging, on both the CLI
  and the web UI commit/push paths.
- Expose nestedRepos/configTracked in GET /api/git/status and add
  POST /api/git/absorb-nested (validated against detected nested repos).
2026-05-30 19:23:12 +08:00
Willie d5c865870a refactor(ui): tidy Git Sync scope selector and not-a-repo layout
- Move the git_root scope selector from its own row into the status bar
  alongside branch/HEAD, matching the repo-info layout
- Lay out the not-a-repo Initialize button inline (justify-between) so it
  no longer floats awkwardly below the warning row
2026-05-30 19:23:12 +08:00
Willie 96ead0b361 feat(ui): make Git Sync not-a-repo state actionable
The not-a-repo state was a dead end: the scope switcher only rendered once a
repo existed, so there was no way to initialize git or set a remote from the
UI. Add an 'Initialize git repository' button that opens the existing scope
dialog (with optional remote) — POST /api/git/root already inits the scope
repo and wires origin. Dialog title/message adapt for the init case.

Also detect a missing git executable: gitStatus reports gitInstalled (via
exec.LookPath), the page shows a clear 'Git is not installed' notice instead
of a cryptic 500 on init, and handleSetGitRoot rejects with a plain message.
2026-05-30 19:23:12 +08:00
Willie e158f77f03 fix(init): route --remote through validated git.SetOrAddRemote
The CLI addRemote ran a raw "git remote add origin <url>" with the
user-supplied URL, sharing the argv flag-smuggling risk just fixed in the
git package. Delegate to git.SetOrAddRemote so the --remote flag goes
through the same leading-dash rejection and "--" terminator, removing the
duplicated exec path.
2026-05-30 19:23:12 +08:00
Willie 56766b024c fix(git): reject flag-smuggling remote URLs in SetRemoteURL/SetOrAddRemote
A remote URL beginning with '-' could be parsed by git as an option flag
(argv injection, e.g. --upload-pack=...). Validate the URL (reject a leading
dash) and pass '--' before positional args so git stops option parsing.
Covers both the new scope-switch remote path and the existing skill-repo
URL editor that funnels through SetRemoteURL.
2026-05-30 19:23:12 +08:00
Willie 53e5b2455b feat(ui): set git remote during scope switch on Git Sync page
The Git Sync scope switcher now accepts an optional remote URL, reaching
UI parity with the CLI's `init --git-root <scope> --remote <url>`. The
POST /api/git/root handler takes an optional remoteURL and wires origin on
the just-initialized scope repo via a new git.SetOrAddRemote helper (adds
origin when absent, updates the URL otherwise). Adds gitSync.scope.remote*
strings across all locales.
2026-05-30 19:23:12 +08:00
Willie 5807a4c743 feat(init): set remote during headless git_root scope switch
Combining --git-root <scope> with --remote <url> on an already-initialized
setup now switches the scope and wires the remote onto the new scope's repo
in one command, instead of warning and ignoring --git-root. Reuses the
existing scope-switch and remote-configuration paths back to back.
2026-05-30 19:23:12 +08:00
Willie 9ca77bd12e feat(init): friendlier error for global-only git flags in project mode
Project init rejected --git-root (and other git flags) with a bare 'unknown
option', which is confusing when the user just forgot that git integration is
global-only — easy to hit when the current directory has a .skillshare/ and
init auto-detects project mode. Match git-related flags (--git-root, --git,
--no-git, --remote) explicitly and explain they are global-only, pointing at
'skillshare init -g <flag>'. Add TestInitProject_GitRootFlag_RejectedAsGlobalOnly.
2026-05-30 19:23:12 +08:00
Willie 314e2b2df4 feat(init): switch git_root scope headlessly on an existing setup
Previously 'skillshare init --git-root <scope>' on an already-initialized
setup either errored with 'already initialized' (no --remote) or warned and
ignored the flag (with --remote), so there was no non-interactive way to
change the scope after init — only the web UI or a manual config edit.

handleExistingInit now treats 'init --git-root <scope>' (without --remote) as
a headless scope switch via switchGitRootScope: it inits a repo at the new
scope directory (reusing one already there, sharing doGitInitIfAbsent with the
fresh-init and server paths) and persists git_root. It does not relocate an
existing repo — switching scope means 'version a different directory', not
'move history'. Combined with --remote the flag still falls through to the
remote path, now pointing users at the standalone form instead of a bare
'ignored' warning.

Update the mismatch guidance to offer 'skillshare init --git-root <scope>' as
the first fix, and revise the git_root docs (configuration + init) to document
the headless switch, superseding the earlier 'must re-run init / not supported'
wording. Add TestGitRoot_SwitchScopeAfterInit.
2026-05-30 19:23:12 +08:00
Willie 9fb7b1eca4 docs(git-root): clarify how to change scope after init; fix misleading mismatch guidance
The mismatch guidance told users to re-run 'skillshare init', but init warns
and ignores --git-root once a repo already exists, so it never relocates the
repo. Reword the CLI message to state the real options: run 'git init' at the
new scope dir for a fresh history, or 'mv <old>/.git <new>/.git' to keep
history, or set git_root to match the existing repo.

Add a 'Changing the scope after init' section to the git_root config reference
and point the commit/push/pull pages at it, replacing the same misleading
're-run init' phrasing.
2026-05-30 19:23:12 +08:00
Willie 20b0d426a0 feat(ui): add enabled/disabled status filter to Resources page
Mirror the list TUI status filter in the web dashboard. A single
monochrome toggle button sits beside the source filter chips (separated
by a divider) and cycles All -> Enabled -> Disabled. Counts are scoped
to the active tab and compose orthogonally with the source filter.
2026-05-30 19:23:12 +08:00
Willie 32fd08c692 feat(list): filter skills by enabled/disabled status in list TUI
Large skill lists made it hard to spot which skills are disabled via
.skillignore. Add a status filter to `skillshare list`: press `s` to
cycle the All -> Enabled -> Disabled view, shown as a `Status:` chip
beside the tab bar. The `s:enabled` / `s:disabled` filter token is also
supported for combining status with other tags (e.g. `t:tracked
s:disabled`). Toggling a skill's state while a status filter is active
re-applies the filter so it leaves the view.

Closes #172
2026-05-30 19:23:12 +08:00
Willie 578be7ebd9 chore(devcontainer): move docs server from port 3000 to 8888
Port 3000 collides with other local services, blocking the devcontainer from
starting. Move the Docusaurus docs server to 8888 across the docs script,
dev-servers orchestration, compose port mapping, and forwarded ports/labels.
2026-05-30 19:23:12 +08:00
Willie 7f91625ec8 test(git-root): skip git_root tests when the container git env cannot commit
Stripped one-shot containers (read-only HOME, unwritable identity, or owner
mismatch) can make git init/commit fail during test setup, surfacing as a
misleading assertion failure deep inside a test. Add a requireWorkingGit probe
that init/config/add/commits in a throwaway temp dir up front and t.Skips with
the underlying git error when the environment cannot create commits. The probe
touches nothing outside its temp dir and does not change git_root behavior.
2026-05-30 19:23:12 +08:00
Willie f59d5e905b refactor(extensions): simplify reference converters 2026-05-30 19:23:12 +08:00
Willie bb0f3c2a0b docs(extras): correct list output and document transform conflict safety
- Fix the `extras list` plain-text example to match current output: real
  header/separator, `✓` icons, no trailing "synced" word on synced rows, and
  an extension target labeled `extension: <name>`.
- Note the per-target `extension` field in `--json` output.
- Document the transform overwrite-safety contract (symlink auto-replace;
  regular file/directory skipped without --force; --force replaces a
  conflicting directory wholesale).
- Add a one-line pointer to transform extensions in the built-in skill.
2026-05-30 19:23:12 +08:00
Willie 403b51f380 fix(extras): never destroy a target directory in transform sync without --force
The previous conflict guard lumped symlinks and directories together and
os.RemoveAll'd both unconditionally, so a real directory sitting at a
generated output path (e.g. a.toml/keep.txt) was silently deleted during
`sync extras` even without --force — more destructive than the copy/merge
path, where syncOneExtraFile only auto-replaces symlinks.

Transform conflict handling now mirrors copy semantics exactly:
- symlink  → auto-replace (os.Remove, link only)
- directory→ skip unless --force; with --force, replace wholesale (os.RemoveAll)
- file     → idempotent if identical, else skip unless --force

Also fix the real deleter: pruneExtraOrphans descended into a skipped
conflict directory and pruned its contents as orphans. It now SkipDirs any
directory occupying a claimed output path, leaving it fully untouched.

Adds regression tests for the directory-conflict skip and the forced
replacement.
2026-05-30 19:23:12 +08:00
Willie 372dd65768 fix(extras): enforce --force contract and consistent status for transform extensions
Transform-extension sync previously wrote each generated file via
runExtensionFile unconditionally, so a regular local target file (e.g. a
hand-edited hello.toml) could be overwritten from hello.md without --force,
violating the same conflict contract that copy/merge modes honor.

- Split runExtension (subprocess → bytes) from runExtensionFile (writes),
  and have syncExtraTransform apply the conflict/force rules: idempotent
  when identical, skipped on conflict without --force, overwrite with
  --force, and auto-replace leftover symlinks.
- Centralize the copy-only mode rule in SyncExtra so the API and CLI reject
  extension+merge/symlink identically; align the server sync handler's mode
  normalization (EffectiveMode's "merge" default no longer leaks through).
- CLI `extras list` no longer short-circuits to an "extension" status before
  existence/drift checks. Status is now computed via output_ext-aware
  CheckSyncStatus; a new Extension field carries the display label, decoupled
  from sync status (plain-text + TUI rendering updated).
- Roll back the optimistic cache update in the UI mode-change handler on
  failure (fixes the unused-var build break).

Adds regression tests covering conflict skip/force/idempotent/symlink-replace
and non-copy mode rejection.
2026-05-30 19:23:12 +08:00
Willie fd897ad39c refactor(ui): use stable keys for extras target lists
Replace array-index keys with data-derived keys: the Add Extra modal gives
each TargetEntry a generated id (paths can be empty/duplicate while
editing), and ExtraCard keys by the target's unique path. Prevents stale
input/render state when rows are added or removed.
2026-05-30 19:23:12 +08:00
Willie 157eddc3d9 fix(extras): never sync skillshare's .metadata.json store
Installed-skill source dirs carry a .metadata.json tracking store. Extras
discovery walked it like user content, so a transform extension renamed it
to .metadata.toml in the target. Skip the reserved file in
DiscoverExtraFiles so it is never synced or transformed in any mode.
2026-05-30 19:23:12 +08:00
Willie f88044e2cc fix(extras): report synced status for transform targets
CheckSyncStatus compared each source file against targetDir/<source-name>,
but a transform extension renames output (foo.md -> foo.toml), so the
.toml file was never found and the target was always reported as drift —
even right after a successful sync. Thread the extension's output_ext
through CheckSyncStatus so the expected target filename matches the
transformed output. The web list now resolves the spec to pass it.
2026-05-30 19:23:12 +08:00
Willie 5fbe4a76f0 feat(ui): remove installed extensions with in-use guard
Add a Remove action to each installed extension in the Config Extensions
list (DELETE /api/extensions/{name}). The list now reports used_by — the
extras whose targets reference each extension — so the row shows an
in-use badge and the confirm dialog warns, in danger style, which extras
will fail on next sync before removing. Path-traversal names are rejected
server-side. Includes server tests for usage reporting and removal.
2026-05-30 19:23:12 +08:00
Willie 9aa09de9c0 fix(extras): apply transform extension on all sync paths
The web UI sync handler, sync --all --json, and the extras TUI sync all
passed a nil ExtensionSpec to SyncExtra, so a target's configured
extension was silently ignored — files were copied verbatim (e.g. .md
stayed .md instead of being transformed to .toml). Resolve the per-target
extension on each path, mirroring the regular CLI sync. Add a server
regression test asserting the transform runs (output renamed to .toml).
2026-05-30 19:23:12 +08:00
Willie 049625522b feat(ui): guide to Config when no extensions installed
The per-target extension picker was hidden entirely when nothing was
installed, leaving no hint that transforms exist. Replace the empty space
with an 'Install an extension' link (in both the Add Extra modal and
ExtraCard) that deep-links to /config?tab=extensions; ConfigPage now reads
the tab query param to open the Extensions tab directly.
2026-05-30 19:23:12 +08:00
Willie fcbfd39be2 refactor(extensions): describe and rename built-ins by output
md2codex / md2gemini named the *input* (markdown) and read poorly. Rename
the bundled extensions after what they produce: codex-agents and
gemini-commands. Turn the BuiltinExtensions catalog into structs carrying
a human-readable description so the dashboard can explain each one before
install, and propagate the new names across tests and docs.
2026-05-30 19:23:12 +08:00
Willie ce023b180f feat(ui): show extension descriptions and clarify wording
The Available list showed only a bare name with no hint of what each
built-in does. Render the catalog description next to it. Also broaden the
section copy: extensions pipe each file through a script (not only
'convert to a format'), and reword the source-path help to make the
intent clearer.
2026-05-30 19:23:12 +08:00
Willie 9bafda4fa3 refactor(ui): use Checkbox component and lock chip in Extras targets
The raw <input type=checkbox> and greyed-out mode select looked out of
place against the hand-drawn design. Use the shared Checkbox component for
Flatten, and render a read-only lock chip (instead of a disabled select)
when an extension forces copy mode — in both the Add Extra modal and
ExtraCard so the two stay consistent.
2026-05-30 19:23:12 +08:00
Willie 3779718631 fix(ui): clarify extras source path help 2026-05-30 19:23:12 +08:00
Willie 67ac184b71 feat(ui): label and clarify target row in Add Extra modal
Add column headers (Path / Extension / Mode) so first-time users can
tell the controls apart. When an extension is selected, replace the
greyed-out mode select with a read-only "copy" lock chip plus a
"runs in copy mode" hint — the disabled control read as broken rather
than intentionally locked.
2026-05-30 19:23:12 +08:00
Willie a42cf78f19 feat(ui): add extension picker to Add Extra modal
The create-extra dialog now offers the same per-target extension
dropdown as the Extras cards. Selecting an extension forces the target
into copy mode and disables the mode selector. createExtra carries the
extension, and the server coerces such targets to copy mode on create.
2026-05-30 19:23:12 +08:00
Willie 3b927ff4f1 fix(ui): open extensions directory in file manager, not editor
The "Open directory" action launched a text editor; switch it to the
OS file manager (Finder on macOS, Explorer on Windows, xdg-open on
Linux/BSD) so it reveals the folder as users expect. Drop the editor
override parameter and the {editor} toast placeholder.
2026-05-30 19:23:12 +08:00
Willie f6eca1fc7d feat(ui): add extensions management to Config page
Add an "Extensions" tab to the Config page for managing transform
extensions in the active mode (global or project):

- GET /api/extensions lists installed extensions with their manifest
  descriptions, merged with the built-in catalog so users can see what
  is available to download.
- POST /api/extensions/install downloads a whitelisted built-in
  extension into the active mode's extensions directory.
- POST /api/extensions/open opens that directory in the user's editor,
  mirroring the skill "open in editor" affordance.

ExtensionSpec now carries the manifest description so the list can
surface it. The UI shows installed extensions with a built-in badge,
available built-ins with a Download button, and an Open-directory
action. Strings are translated across all 11 locales.
2026-05-30 19:23:12 +08:00
Willie f6c9b98562 feat(ui): add per-target extension picker to Extras page
Surface the per-target extension transform in the dashboard. A new
GET /api/extras/extensions endpoint lists extensions available in the
current mode's directory (global or project), and the Extras page renders
a picker per target. Selecting an extension forces copy mode (transforms
are copy-only) and locks the mode control; changes apply optimistically
via the query cache. Adds i18n keys across all locales.
2026-05-30 19:23:12 +08:00
Willie c0609011e4 feat(extensions): map model field and document Codex agents recipe
The md2codex reference converter now carries the agent's `model`
frontmatter into the generated TOML, matching what Codex agents expect.
Document the extras + extension recipe for converting markdown agents to
Codex TOML so the conversion works without a built-in agents target.
2026-05-30 19:23:12 +08:00
Willie 9e4563d143 chore(extensions): port reference scripts to Node.js and validate extras extension schema
Port the md2gemini and md2codex reference extensions from Python to
Node.js for broader portability (Node ships uniformly across Windows,
macOS, and Linux). Add the extension field to extraTargetConfig in the
global and project JSON schemas so editors accept it, with a schema test
guarding its presence.
2026-05-30 19:23:12 +08:00
Willie 5c3a3dff30 docs: document extras extension transforms 2026-05-30 19:23:12 +08:00
Willie 3a2a97b542 docs(extensions): add md2gemini and md2codex reference extensions 2026-05-30 19:23:12 +08:00
Willie fa87ef745f test(integration): end-to-end extras extension transform 2026-05-30 19:23:12 +08:00
Willie c200349540 feat(cmd): skip extension targets in collect; label them in list 2026-05-30 19:23:12 +08:00
Willie 519f7f9412 feat(cmd): apply extension transform during extras sync 2026-05-30 19:23:12 +08:00
Willie aa309d52d7 feat(cmd): resolve extension value and validate transform mode 2026-05-30 19:23:12 +08:00
Willie 1b9d25de7a feat(sync): implement per-file transform with output rename and prune 2026-05-30 19:23:12 +08:00