Commit graph

894 commits

Author SHA1 Message Date
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
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
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
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
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
Cheney
70b962a4c8 fix(cli): harden release pipeline per PR #422 review
1. npm version check: three-state logic (exists/missing/error) to prevent
   silent skip on network failures, registry 5xx, or auth issues.

2. workflow_dispatch: checkout the specified tag and validate SHA matches,
   preventing builds from wrong ref.

3. Atomic push: use `git push --atomic` and detect unpushed tags via
   `git ls-remote` instead of `--no-merged` (catches branch-pushed-but-
   tag-failed state).
2026-05-12 17:15:35 +08:00
Cheney
8126faa452 fix(cli): detect and guide recovery of unpushed release artifacts
Add pre-flight check in publish-cli.sh to detect unpushed commits and tags
from previous failed pushes. When detected, the script exits with clear
recovery instructions:

1. Retry push (for transient network failures)
2. Rollback and re-release (for clean restart)

This prevents the baseline sync logic from skipping failed versions when
local tags participate in version calculation after a push failure.

Addresses feedback from dongmucat in PR #422.
2026-05-12 16:14:47 +08:00
Cheney
159886b76d fix(cli): ensure create-release depends on publish-npm and rewrite publish-cli tests
1. Update release-cli.yml to make create-release depend on publish-npm with proper skip_npm handling, preventing half-released state where GitHub Release exists but npm package is unavailable.

2. Rewrite publish-cli-test.sh to cover the new publish flow: main branch check, dirty tree detection, tag baseline sync, version bumping, tag conflict detection, user cancellation, and atomic push verification.
2026-05-12 16:12:57 +08:00
dongjiang
41b1d03cfc
Add AGENTS.md and SKILL.md to support AI tools (#393)
Signed-off-by: dongjiang <dongjiang1989@126.com>
2026-05-12 15:35:17 +08:00
dongmucat
fed4eeb2b9 fix(web): make quick start tab icons exhaustive 2026-05-12 14:08:29 +08:00
dongmucat
8931f6d241 feat(web): add CLI install tab on landing quick start
Add a third peer tab 'CLI' to LandingQuickStartSection that surfaces the
official install command 'npm i -g @astron-team/skillhub'. Layout uses
grid-cols-1 md:grid-cols-3 so mobile shows tabs stacked and desktop
shows three equal-width columns.

Addresses iflytek/skillhub#419 (homepage Quick Start part only).
2026-05-12 11:05:02 +08:00
Cheney
490ddfa548 fix(cli): push branch and tag atomically in publish-cli.sh 2026-05-12 11:01:50 +08:00
Cheney
378216c6da feat(cli): add automated build and publish workflow
- Add release-cli.yml GitHub Actions workflow: build, test, npm publish,
  and GitHub Release triggered by cli-v* tags
- Rewrite scripts/publish-cli.sh: local bump + commit + tag + push,
  enforces main branch, idempotent tag checks
- Add concurrency group and release idempotency to workflow
- Add make publish-cli / publish-cli-minor / publish-cli-major targets
- Add cli/RELEASE.md documenting the full release process
2026-05-12 10:32:06 +08:00
dongmucat
15e55e8055
Merge pull request #418 from iflytek/fix/cli-update-registry
fix(cli): respect configured npm registry
2026-05-11 15:18:29 +08:00
dongmucat
836267fd45 fix(cli): respect configured npm registry 2026-05-11 14:53:20 +08:00
dongmucat
554cad5b2e
Merge pull request #416 from iflytek/fix/cli-publish-version-sync
fix(cli): sync publish version flow
2026-05-11 14:14:32 +08:00
dongmucat
cebad0bbd7 refactor(security): use explicit SCANNING check in processScanResult
Gemini review feedback: the previous != PUBLISHED condition was too broad
and could inadvertently overwrite terminal states like REJECTED or YANKED.
Now explicitly check == SCANNING before transitioning status.
2026-05-11 13:56:08 +08:00
dongmucat
299659bf93 fix(cli): avoid publish temp file leak 2026-05-11 13:43:31 +08:00
dongmucat
ec4598efec fix(security): trigger security scan for admin-published skills
Super admin auto-publish flow was skipping security scanning entirely.
Now triggerScan is called regardless of autoPublish flag, while preserving
the PUBLISHED status (scan runs as post-publish audit rather than blocking).

Closes #415
2026-05-11 11:36:08 +08:00