Commit graph

958 commits

Author SHA1 Message Date
Cheney
0b1c366f8d
refactor(cli): improve publish-cli script reliability (#441)
* refactor(cli): improve publish-cli script reliability

- Move version computation and pre-flight checks before build-and-test
  to fail fast on conflicts (existing branch/tag) instead of wasting
  minutes on lint/test/build
- Add INT/TERM signal handlers to cleanup trap so Ctrl+C during build
  properly restores working tree state
- Update Makefile help text to reflect PR-based workflow

* fix(cli): use git checkout -f for robust cleanup

Address code review feedback from gemini-code-assist bot:

- Use `git checkout -f` in on-release and committed cleanup stages
  to ensure reliable branch switching even when files are staged
  but not committed (e.g., interrupted after `git add` but before
  `git commit`)
- Remove redundant `git checkout -- <file>` in on-release stage
  since `-f` already discards all local changes

This prevents cleanup failures when the script is interrupted
between staging and committing.

* fix(cli): address PR #441 review findings

- Fix ERR trap bypass: remove `if !` wrapper around `gh pr create` so
  set -e triggers the trap and prints pushed-stage recovery instructions
- Fix command injection: all node -e/-p calls now use process.env
  instead of interpolating shell variables into JS string literals
- Rewrite cli/RELEASE.md to document the new PR-based release flow
- Rewrite scripts/tests/publish-cli-test.sh with 10 tests covering
  the new flow (stubs for bun/gh, pre-flight checks, happy path,
  cleanup state machine stages)

* fix(cli): address PR #441 review findings from @dongmucat

- Bind release tag to origin/main: PR body, end-of-run hint, and
  cli/RELEASE.md now use `git tag $TAG origin/main` so the tag is
  always placed on the merged commit, regardless of local branch state
- Reject prerelease tags in version computation: if the latest cli-v*
  tag contains non-X.Y.Z characters (e.g., -rc.1), exit with a clear
  message instead of crashing in node parsing
- Add pr-scripts.yml workflow: runs publish-cli-test.sh on scripts/**
  changes so the release script regression suite gates PRs
- Add Test 11 covering prerelease tag rejection

* fix(cli): compute publish baseline from origin tags only

A failed `git push origin cli-vX.Y.Z` after a successful local tag
leaves an orphan tag locally. The previous `git tag --list` baseline
would then treat it as the latest release, causing skipped versions or
publishes based on an unreleased tag.

Switch to `git ls-remote --tags --refs origin 'cli-v*' | sort -V` so
the baseline reflects only what is actually on origin. Local orphan
tags can still collide with the computed target tag, which fails fast
with a clear message as before.

Adds test 12 covering the orphan-tag scenario.
2026-06-02 14:30:39 +08:00
dongmucat
b7b8fd3d5d
fix(deps): bump vitest to 4.1 to patch GHSA-5xrq-8626-4rwp (#474)
Vitest <4.1.0 allows arbitrary file read/execution when the UI server is
listening (GHSA-5xrq-8626-4rwp, severity: critical). Bumps vitest from
3.2.4 to 4.1.x, which also flows through to the bundled @vitest/* packages
in pnpm-lock.yaml.

Adjusts two tests for the stricter v4 mock contract: `new`-callable mocks
must be backed by a `function`/`class` implementation rather than an
arrow function (web/src/shared/lib/date-time.test.ts,
web/src/app/providers.test.ts).

Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-02 10:52:29 +08:00
dongmucat
2730d6470e
fix(web): allow anonymous downloads for global PUBLIC skills (#473)
Use `namespace === 'global'` (without @ prefix) to match the actual
route parameter value. The previous check used '@global' which never
matched, causing anonymous users to be redirected to login even for
global PUBLIC skills.

Co-authored-by: dongmucat <1127093059qq.com>
2026-06-01 17:59:55 +08:00
dongmucat
8bd7a6bc1d
Merge pull request #470 from iflytek/chore/cli-bump-0.1.7
chore(cli): bump version to 0.1.7
2026-05-29 15:57:59 +08:00
dongmucat
a6402c5873 chore(cli): bump version to 0.1.7 2026-05-29 15:43:18 +08:00
dongmucat
55b38051ce
chore(deps): bump vite/postcss/picomatch/flatted/esbuild to patch Dependabot alerts
Some checks failed
Deploy Docs / build (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
* chore(deps): bump vite/postcss/picomatch/flatted/esbuild to patch Dependabot alerts

web/:
- pnpm.overrides force vite>=6.4.2, postcss>=8.5.10, picomatch>=2.3.2/>=4.0.4, flatted>=3.4.2
- bump devDeps vite to ^6.4.2 and postcss to ^8.5.10

docs/skillhub/:
- npm overrides force vite^6.4.2, postcss^8.5.10, esbuild^0.25.0
- regenerate package-lock.json

Resolves Dependabot alerts:
- web: GHSA-p9ff-h696-f583 (vite high), GHSA-rf6f-7fwh-wjgh (flatted high),
       GHSA-qx2v-qp2m-jg93 (postcss), GHSA-4w7w-66w2-5vf9 (vite),
       GHSA-3v7f-55p6-f55p (picomatch x2)
- docs: GHSA-67mh-4wv8-2f99 (esbuild), GHSA-qx2v-qp2m-jg93 (postcss),
        GHSA-4w7w-66w2-5vf9 (vite)

* chore(deps): bump brace-expansion and add docs-build PR check

web/:
- pnpm.overrides force brace-expansion>=1.1.13 and >=2.0.3
  to address GHSA-f886-m6hf-6m8v (transitive via eslint/typescript-eslint -> minimatch)
- pnpm-lock.yaml resolves brace-expansion 1.1.15 / 2.1.1

ci:
- add docs-build job to pr-tests.yml, gated by docs/skillhub/** path filter
  so docs-only PRs and dependency overrides on docs are exercised before merge
2026-05-28 10:17:27 +08:00
dongmucat
5a238dfa2a
chore: disable gemini auto review 2026-05-27 12:20:54 +08:00
dongmucat
1cf2e481ee
Merge pull request #440 from iflytek/feat/cli-install-scope
Some checks failed
Deploy Docs / build (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(cli): add --scope option to install command
2026-05-19 13:52:08 +08:00
卡弗瑞松
6fe4c4ac15
fix(runtime): pass auth environment variables to containers (#280)
* fix(runtime): pass auth environment variables to containers

The web container's envsubst in 30-runtime-config.sh only substituted
SKILLHUB_WEB_API_BASE_URL and SKILLHUB_PUBLIC_BASE_URL, leaving auth-related
variables (authDirectEnabled, authSessionBootstrapEnabled, etc.) as literal
${...} strings in runtime-config.js. Additionally, compose.release.yml did not
pass SKILLHUB_WEB_AUTH_DIRECT_ENABLED or SKILLHUB_WEB_AUTH_DIRECT_PROVIDER to
the web container, nor SKILLHUB_AUTH_DIRECT_ENABLED to the server container.

This made it impossible to enable direct (username/password) authentication
for intranet deployments without OAuth2, even though the frontend template and
backend already supported it.

Changes:
- compose.release.yml: add SKILLHUB_AUTH_DIRECT_ENABLED to server env
- compose.release.yml: add auth direct and session bootstrap vars to web env
- 30-runtime-config.sh: expand envsubst to cover all runtime-config.js template variables
- .env.release.example: document the new auth configuration variables

All new variables default to false/empty, preserving existing GitHub OAuth behavior.

* fix: remove session bootstrap frontend config from compose

Per reviewer feedback: exposing SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_* in the
compose without matching SKILLHUB_AUTH_SESSION_BOOTSTRAP_ENABLED on the server
would cause 403 errors when frontend attempts bootstrap.

Keep this PR focused on direct auth only. Bootstrap variables are still handled
in 30-runtime-config.sh with false defaults, so runtime-config.js will have
authSessionBootstrapEnabled: "false" and frontend will not trigger bootstrap.

---------

Co-authored-by: wowo <zhenggui5228@126.com>
Co-authored-by: PR Review Helper <review-helper@local>
2026-05-19 11:00:25 +08:00
wrj97
21456b9929
fix(auth): use SimpleUrlAuthenticationSuccessHandler for OAuth2 login (#266)
* fix(auth): use SimpleUrlAuthenticationSuccessHandler for OAuth2 login

Replace SavedRequestAwareAuthenticationSuccessHandler with
SimpleUrlAuthenticationSuccessHandler to prevent redirecting to
saved API requests after OAuth2 login.

Previously, when a user accessed a protected API endpoint (e.g.,
/api/web/skills) without authentication, Spring Security would save
that request. After OAuth2 login, the handler would redirect back to
the API endpoint instead of the dashboard.

Now the handler only uses:
- returnTo parameter from session (if present)
- default target URL (/dashboard) as fallback

* test(auth): add regression for OAuth2 success redirect; restore clearAuthenticationAttributes

Cover the no-returnTo + cached-API-request branch with HttpSessionRequestCache so
the original bug (post-login redirect resolving to /api/web/skills) cannot be
silently reintroduced. Also restore clearAuthenticationAttributes() in the
returnTo branch so it stays symmetric with the default branch (super clears it).

---------

Co-authored-by: xiose <huyanlin@nuaa.edu.cn>
2026-05-19 10:59:46 +08:00
dongmucat
8c8b047cbb docs(protocol): adopt .agents/skills (plural) as canonical universal fallback
Resolve historical naming drift between protocol spec and CLI by adopting the
plural form across both docs:

- docs/07-skill-protocol.md: drop the drift caveat; the four-tier priority is
  now stated as .agents/skills / ~/.agents/skills / .claude/skills /
  ~/.claude/skills directly.
- docs/00-product-direction.md: align with the same plural form.

The CLI already uses .agents/skills (cli/src/agents/profiles/generic-fallback.ts
and cli/src/agents/resolver.ts). No code change required.
2026-05-19 10:49:31 +08:00
dongmucat
39fbff1567
Merge pull request #453 from iflytek/worktree-fix+user-list-userid-column
feat(admin): add userId column to user management list
2026-05-19 09:55:16 +08:00
dongmucat
c6fa37bb78 Merge branch 'main' into feat/cli-install-scope 2026-05-19 09:48:49 +08:00
dongmucat
60eaf11d3f
Merge pull request #427 from iflytek/worktree-cli-test-migration
test(cli): migrate comprehensive test suite from test/cli-integration-coverage
2026-05-19 09:40:50 +08:00
dongmucat
baf84acc83
Merge pull request #451 from iflytek/feature/publish-dry-run
feat(publish): add --dry-run validation endpoint and CLI option
2026-05-19 09:38:42 +08:00
dongmucat
11b69e32c0
Merge pull request #454 from iflytek/chore/remove-gemini-auto-review
chore: remove gemini code assist auto review config
2026-05-19 09:26:18 +08:00
dongmucat
655adcbcbd test(cli): add 403 scope-denied test for dry-run
Covers the new "access denied — token may lack required scope" error
path with a fake-registry 'forbidden' failure mode. Prevents the
improved 403 message from regressing silently.
2026-05-18 17:36:59 +08:00
dongmucat
fbad1cf51d chore: remove gemini code assist auto review config
Disable automated PR review by Gemini Code Assist for GitHub by removing
.gemini/config.yaml. The repository will no longer trigger Gemini-based
PR summaries or review comments.
2026-05-18 17:31:08 +08:00
dongmucat
d0e2a50b0e fix(admin): improve accessibility and E2E test precision
- Add ariaLabel prop to CopyButton for screen reader differentiation
- Pass per-user aria-label: "Copy user ID for {username}"
- Add truncation for long userIds (max-w-[14rem] + title tooltip)
- Scope E2E copy-button assertions to userId cell to avoid false positives
- Assert on span.font-mono for userId text to exclude button text
- Use toHaveText instead of getByRole name for "Copied" feedback check
2026-05-18 17:25:21 +08:00
dongmucat
a0def9463b chore(cli): improve dry-run test fixture and 403 error message
- Fix test fixture: warnings-only response now uses valid=false to
  match real backend behavior (warnings make dry-run invalid)
- Distinguish 403 from 401 in CLI error messages: 403 now says
  "access denied — token may lack required scope" with a hint to
  regenerate the token, rather than the generic "authentication failed"
2026-05-18 16:42:06 +08:00
dongmucat
d98fe8d802 fix(e2e): address review feedback on admin-users-userid-column tests
- Fix race condition: use Promise.all for goto + waitForResponse
- Remove all waitForTimeout calls, use explicit assertions/waitForResponse
- Assert clipboard content equals the actual userId (not just non-empty)
- Fix unused variable (userIdText) that would fail lint --max-warnings 0
- Trigger real search via button click instead of just filling input
- Add status filter test to cover the filter path
- Add comment explaining mock-profile approach for admin session
2026-05-18 16:37:01 +08:00
dongmucat
d7d0790b28 fix(auth): close API token scope filter gap on /api/cli/ routes
ApiTokenAuthenticationFilter authenticates /api/cli/** Bearer tokens
but ApiTokenScopeFilter.shouldNotFilter() previously skipped them.
The result: API token requests on CLI routes were authenticated and
authorization-policy-checked, but scope enforcement never ran. Tokens
without skill:publish or skill:delete could call /publish, /publish/validate,
and DELETE despite the policy table requiring those scopes.

Add /api/cli/ to the scope filter's covered prefixes and a filter-level
test that confirms a token missing skill:publish is rejected on the new
validate endpoint. Update the existing CLI controller tests to grant
the appropriate SCOPE_* authorities to their api_token principals so
they continue to pass under enforced scopes.
2026-05-18 15:51:19 +08:00
dongmucat
a2d08b76c1 feat(admin): add userId column to user management list
Add a userId column with one-click copy functionality to the admin
user management table to help administrators easily access user IDs
for batch operations like namespace member management.

Changes:
- Add userId column after username in admin users table
- Implement one-click copy button for each userId
- Add i18n translations for column header (en/zh)
- Add comprehensive E2E tests (6 test cases)

Closes #426
2026-05-18 15:35:50 +08:00
dongmucat
943294b558 fix(publish): address Codex review findings for dry-run
Fix three blockers and one contract drift issue surfaced in code review:

1. API token policy: add skill:publish scope policy and authentication
   policy for /api/cli/v1/skills/*/publish/validate. Without these the
   AntPathMatcher pattern /publish would not cover /publish/validate,
   so Bearer-token requests would be rejected by the scope filter.

2. Warnings semantics: dry-run now treats warnings as making valid=false.
   The CLI publish flow uses confirmWarnings=false, so the real publish
   rejects any warnings; dry-run must mirror that to avoid false positives.

3. Visibility parameter: validate endpoint now accepts the same
   visibility multipart field as publish. The CLI forwards --visibility
   so invalid values are caught at dry-run time rather than at publish.

4. Schema drift: resolvedSlug and resolvedVersion are nullable in
   practice (returned as null when validation fails before resolution).
   Updated schema.d.ts to reflect string | null instead of optional string.

Tests added:
- RouteSecurityPolicyRegistryTest: validate endpoint scope check
- CliDryRunValidateTest: custom + invalid visibility cases
- publish-dry-run.test.ts: --visibility forwarded to server
2026-05-18 14:50:14 +08:00
dongmucat
bdc94ad19c fix(publish): address code review findings for dry-run
- Exit non-zero (code 6) when --dry-run validation fails, enabling
  CI/CD pipeline integration
- Add archived skill check: dry-run now detects when the publisher's
  own skill is archived
- Add version-exists check: dry-run now detects when the resolved
  version is already published
- Use StandardCharsets.UTF_8 for SKILL.md content parsing
2026-05-18 10:57:14 +08:00
dongmucat
1067d0ff6e feat(publish): add --dry-run validation endpoint and CLI option
Add a validate-only endpoint (POST /api/cli/v1/skills/{namespace}/publish/validate)
that runs the full pre-publish validation chain without persisting anything.
This allows developers to check their package locally before actual publishing.

The validation covers:
- SKILL.md existence and frontmatter parsing (name, description required)
- File extension whitelist and size limits
- Credential leak scanning with line-number precision
- Slug generation and name conflict detection

CLI usage: `skillhub publish <path> --dry-run`

Closes #429
2026-05-18 10:36:58 +08:00
dongmucat
96681b021a fix(cli): label scope by userRoots membership instead of cwd prefix
When --agent is provided without --scope, scope was inferred via
root.startsWith(cwd), which mislabels user roots as project when
cwd === home. Use profile.userRoots(home) membership instead, so the
candidate scope reflects the profile's intent rather than path prefix
overlap. The chosen root path itself is unchanged.
2026-05-15 14:43:25 +08:00
dongmucat
f7ab8f4db7 feat(cli): add --scope option to install command
- Distinguish user vs project install scope via explicit --scope flag
- Interactive mode prompts for scope when --scope/--agent/--dir not provided
- Non-interactive bare install preserves existing behavior (backward compatible)
- Mutual exclusion: --dir cannot be combined with --scope or --agent
- Symmetric fallback: --scope user falls back to ~/.agents/skills,
  --scope project falls back to <cwd>/.agents/skills
- Strict TTY check requires both stdin and stdout TTY plus no --json
- Scope-aware candidate generation avoids root.startsWith(cwd) misjudgement
  when cwd === home or paths overlap
- Correct gemini-cli (.gemini/skills) and kiro-cli (.kiro/skills) paths
  in install path tables across README and guide docs
- Note CLI fallback uses .agents/skills (with s) in skill protocol doc
2026-05-15 14:43:25 +08:00
dongmucat
098616dcb6
Merge pull request #436 from iflytek/cli-bump-0.1.6
chore(cli): bump version to 0.1.6
2026-05-14 17:45:01 +08:00
dongmucat
a9bc076f81 chore(cli): bump version to 0.1.6 2026-05-14 17:18:46 +08:00
dongmucat
cf6f6e5680 test(cli): restore NpmRegistryClient unit tests and fix publish test name
Restore 9 deleted unit tests covering registry URL resolution priority,
case-insensitive env lookup, empty env fallback, default registry, non-2xx
responses, invalid JSON, missing version, and invalid registry URL.

Fix misleading test name in publish-command: 503 maps to EXIT.network
(not EXIT.generic) per the 502/503 special-case in skillhub-client.ts.
2026-05-14 16:24:49 +08:00
dongmucat
356e507cf9
Merge pull request #434 from iflytek/worktree-fix-promotion-download
fix(promotion): copy bundleReady and downloadReady when promoting skill to global
2026-05-14 15:50:06 +08:00
dongmucat
afa6b6c834
Merge pull request #417 from iflytek/fix/admin-skill-scan-bypass
fix(security): trigger security scan for admin-published skills
2026-05-14 14:50:53 +08:00
dongmucat
9dfbed2ef1
Merge pull request #422 from iflytek/feat/cli-auto-build
feat(cli): add automated build and publish workflow
2026-05-14 14:50:27 +08:00
dongmucat
2af0bf184b fix(promotion): copy bundleReady and downloadReady when promoting skill to global
When approving a promotion, the new SkillVersion was created without copying
bundleReady and downloadReady from the source version, causing the download
button to be permanently disabled for promoted skills.
2026-05-14 14:32:36 +08:00
dongmucat
cedf8392f6 test(cli): normalize ZIP entry keys for cross-platform access
Ensures both key listing and content access work on Windows by normalizing
all ZIP entry keys to forward slashes immediately after unzipSync.
2026-05-14 10:56:50 +08:00
dongmucat
c8e145d158 test(cli): normalize ZIP paths for cross-platform compatibility
Windows ZIP library produces backslashes in file paths while Unix uses forward slashes. Normalize all paths to forward slashes before assertion to ensure tests pass on all platforms.
2026-05-14 10:56:50 +08:00
dongmucat
8a7770c5e3 test(cli): fix Windows path assertion and clarify test name
- Fix Windows test failure by using regex that accepts both / and \ path separators in install-command.test.ts
- Rename contradictory test case in publish-command.test.ts from "surfaces a non-zero exit" to "is handled without crash" to match actual assertion behavior
2026-05-14 10:56:50 +08:00
dongmucat
9643e4157c test(cli): migrate comprehensive test suite from test/cli-integration-coverage
Migrated 39 test files covering CLI integration and unit testing:
- 6 new integration tests (auth-resolution, concurrency, cross-command, inventory-resilience, multi-registry, version-upgrade-flow)
- Enhanced 7 existing integration tests with comprehensive scenarios
- Updated 2 unit tests with correct exit code expectations

All tests use fake registry approach (no E2E/browser required) and pass lint/build/test checks.
2026-05-13 11:14:20 +08:00
Cheney
f59a10e36f chore(ci): remove temporary publish-script test workflow 2026-05-13 09:28:28 +08:00
Cheney
48174c9ad2 fix(cli): match 'push' anywhere in git args, not just $1
The script calls `git -C /path push ...` so the first arg is `-C`,
not `push`. Use glob match on full args instead.
2026-05-13 09:27:44 +08:00
dongmucat
5ccb7f9cf7
Merge pull request #423 from iflytek/feat/landing-cli-tab
feat(web): add CLI install tab on landing quick start
2026-05-13 09:27:39 +08:00
Cheney
dad06b465d fix(cli): fix exit code capture in tests using git wrappers
The `status="$(env ... printf | bash ... && echo 0 || echo $?)"` pattern
doesn't correctly capture the script's exit code because the command
substitution and pipe interact poorly. Use direct assignment with
`|| status=$?` instead.
2026-05-13 09:26:33 +08:00
Cheney
935054cc9e fix(cli): use git wrapper for push-failure test
The old approach (breaking origin URL) caused `git pull` to fail
before reaching the push step. Use a git wrapper that only fails
on `push` so the rest of the script runs normally.
2026-05-13 09:18:19 +08:00
Cheney
c520f38135 fix(cli): remove unreliable race-condition test, renumber tests
Remove test 7 (remote tag race condition) — the scenario is nearly
impossible with the new baseline sync logic and too complex to
reliably simulate. Fix variable naming inconsistencies from the
renumbering.
2026-05-13 09:16:19 +08:00
Cheney
1c29cfac57 test(cli): add debug logging to race-condition test wrapper 2026-05-12 18:05:02 +08:00
Cheney
85a758bbdd fix(cli): rewrite test 7 to cover real remote tag race condition
Old test 7 used `--no-tags` config to prevent fetch from pulling the
remote tag, but that doesn't reflect any real-world scenario. With the
new baseline sync logic, a pre-existing remote tag would be synced
into the local version, eliminating the conflict path the test claimed
to cover.

Replace with a git wrapper that injects the conflicting tag into origin
right before the script's `ls-remote` check, which simulates a real
race between two developers attempting to release the same version.
2026-05-12 18:02:02 +08:00
Cheney
c1c12c56eb fix(cli): gitignore test scaffolding files in publish-cli tests
Tests write stdout.log/stderr.log into the test repo root, which made
`git status --porcelain` non-empty and broke test 3 (non-main branch
abort) by tripping the dirty-tree check first.

Add a .gitignore to the test fixture repo to filter out these files.
2026-05-12 17:57:32 +08:00
Cheney
1420ffac56 test(ci): add temporary workflow to test publish-cli script
This workflow runs scripts/tests/publish-cli-test.sh in CI to verify
the publish script changes. Will be removed after verification.
2026-05-12 17:53:12 +08:00
Cheney
eeb2540a3e fix(cli): align checkout ref across all workflow jobs
publish-npm and create-release now checkout the same ref as
build-and-test (the input tag or push ref), preventing source
mismatch between npm package and GitHub Release artifacts.
2026-05-12 17:29:58 +08:00