Commit graph

49 commits

Author SHA1 Message Date
dongmucat
6ee746d371 chore(cli): bump version to 0.1.9
Signed-off-by: dongmucat <1127093059@qq.com>
2026-07-22 17:35:05 +08:00
betterlmy
f519b08a73 fix(cli): preflight canonical install targets
Signed-off-by: betterlmy <betterlmy@icloud.com>
2026-07-17 17:20:22 +08:00
betterlmy
8b84201516 feat: add generic user-level agent install target
Signed-off-by: betterlmy <betterlmy@icloud.com>
2026-07-17 11:39:29 +08:00
dongmucat
78b8b34ed1 chore(cli): bump version to 0.1.8
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-18 15:54:23 +08:00
dongmucat
f8ea4e67e4
feat(cli): support anonymous public search and install
feat(cli): support anonymous public search and install
2026-06-18 14:29:45 +08:00
dongmucat
ea73c305b8
Merge pull request #534 from SenLinLeo/fix/install-target-enter-selection
fix(cli): treat highlighted install target as selected
2026-06-18 09:43:48 +08:00
dongmucat
9520cf63e0 fix(cli): add token auth to search
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-17 11:35:16 +08:00
dongmucat
e50140272b fix(security): close review hardening gaps
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-16 17:48:15 +08:00
SenLinLeo
b44c65443d fix(cli): treat highlighted install target as selected
Signed-off-by: SenLinLeo <1664761477@qq.com>
2026-06-16 16:30:30 +08:00
dongmucat
7d0402e937 fix(security): address review blockers
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-16 14:19:39 +08:00
dongmucat
40d7de8462 fix(security): harden review findings
Signed-off-by: dongmucat <1127093059@qq.com>
2026-06-12 14:40:30 +08:00
XiaoSeS
2bb7dedaf4
feat(cli,domain): support non-global namespace skill download (#497)
* feat(cli,domain): support non-global namespace skill download

Parse namespace from skill name using -- separator (e.g.,
astroclaw--api-gateway) so users don't need --namespace flag.
Allow anonymous download for any PUBLIC skill regardless of namespace.

CLI changes:
- Add cli/src/shared/skill-name-parser.ts utility
- Update install and remove commands to parse skill name argument
- 10 unit tests covering edge cases

Domain changes:
- SkillDownloadService.isAnonymousDownloadAllowed: drop namespace
  type check, only require PUBLIC visibility
- Update test to expect success for team-namespace public skill

Synced from SAAS commit 26c67e31b1221249cf9b73321d1b726d8ba6e6df

* fix(cli): use bun:test instead of vitest in skill-name-parser test
2026-06-05 16:20:34 +08:00
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
a6402c5873 chore(cli): bump version to 0.1.7 2026-05-29 15:43:18 +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
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
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
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
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
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
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
836267fd45 fix(cli): respect configured npm registry 2026-05-11 14:53:20 +08:00
dongmucat
e7aecc4050 fix(cli): sync publish version flow 2026-05-11 11:00:10 +08:00
dongmucat
d77a7d67c9 fix(cli): return correct exit code for network failures
- Handle 502/503 status codes as network errors (EXIT.network = 3)
- Previously these were treated as generic errors (EXIT.generic = 1)
- Fixes integration tests for login and search network failure scenarios
- Bump version to 0.1.4
2026-05-09 17:09:16 +08:00
dongmucat
58a48e2670 docs: restructure CLI README and sync guide docs with improvements
变更摘要:

- 重构 cli/README.md 大纲结构,参考 guide 文档重新组织章节逻辑

- 补充 Windows PowerShell/CMD 环境变量设置方式到三份文档

- Command Reference 表格补全 --json、--registry、--token 等选项

- 英文 guide Registry 优先级第3条补充文件路径与中文版对齐

- 两份 guide 末尾补充 License 章节,Local Development 补 Windows 说明

- README 各章节标题添加语义化 emoji icon

关键文件:

- cli/README.md

- docs/skillhub/en/guide/cli.md

- docs/skillhub/guide/cli.md
2026-05-09 15:01:00 +08:00
dongmucat
a14d89d8c9 refactor(cli): improve doctor command semantics and transparency
变更摘要:

- doctor 命令重构:从重建改为扫描并合并语义,保留扫描范围外的条目

- 修复字段命名:itemsRestored → itemsScanned/itemsPreserved,语义更清晰

- 改进用户提示:输出区分扫描到的和保留的条目,帮助文档补充保留行为说明

- 补充代码注释:说明同 slug 不同 installDir 允许并存的设计意图

- 统一错误码:download/handleJsonResponse 的非 2xx 响应统一使用 EXIT.generic

- 新增测试覆盖:合并场景、刷新场景、冲突不删除无关条目等边界情况

关键文件:

- cli/src/services/doctor-service.ts

- cli/src/commands/doctor.ts

- cli/src/commands/help.ts

- cli/test/unit/services/doctor-service.test.ts

- cli/test/integration/doctor-command.test.ts
2026-05-09 11:30:36 +08:00
dongmucat
e249db35a3 test(cli): add comprehensive integration tests and fix update command bugs
- Add integration tests for doctor, install, list, publish, remove, whoami commands
- Expand fake-registry with resolve/delete state capture for real assertions
- Fix update command: use correct package name @astron-team/skillhub from constants
- Refactor runUpdateCommand to accept string[] instead of fragile string splitting
- Add dependency injection to updateCommand for testable unit tests without global mocks
- Replace package.json import with codegen (scripts/generate-pkg-info.ts) to avoid
  leaking devDependencies into the build artifact
- Fix startNetworkFailureServer TOCTOU race by keeping listener alive
- Add TODO markers for known help command bugs (--json not forwarded, unknown topic crash)
- Extend update integration test timeout for real npm registry checks
2026-05-07 14:46:40 +08:00
dongmucat
ea8168f290 docs(cli): beautify README with icons and improve registry documentation 2026-05-06 17:45:53 +08:00
dongmucat
92dd64f36e docs(cli): refine registry usage examples 2026-05-06 17:32:13 +08:00
dongmucat
9ee60dc018 chore(cli): bump version to 0.1.1 2026-05-06 17:11:46 +08:00
dongmucat
0534d1d59a fix(cli): add publishConfig.access field to package.json 2026-05-06 16:57:12 +08:00
dongmucat
d5abeb6ca9 feat(cli): add npm publish workflow and update package scope
- Add publish script with env validation, git checks, and build/test/pack preflights
- Add comprehensive test suite for publish workflow (302 lines)
- Update cli/package.json with @astron-team scope and full npm metadata
- Add README.md with user-focused documentation and registry info
- Add .env.example template for publish configuration
- Add Apache 2.0 LICENSE
- Add Makefile targets for build/test/lint/typecheck/publish workflows
- All publish targets include .env.local validation
- Update installation instructions across all documentation to use @astron-team/skillhub
2026-05-06 16:34:59 +08:00
dongmucat
43a201c8d5 fix(cli): use fileURLToPath for cross-platform cwd path compatibility
The issue was that new URL().pathname returns Unix-style paths on Windows
(e.g., /D:/a/skillhub/...) which Bun.spawn() cannot resolve correctly.
Using fileURLToPath() converts the URL to a proper platform-specific path.

Changes:
- cli/test/helpers/run-cli.ts: use fileURLToPath for cwd
- cli/test/integration/version-command.test.ts: same fix for build spawn
2026-04-29 16:13:50 +08:00
dongmucat
704f2d2af4 fix(cli): verify Bun.which() path exists before using on Windows
Bun.which('bun') on Windows CI returns a non-existent path
(C:\Users\runneradmin\.bun\bin\bun.exe), causing all integration
tests to fail. Add existsSync() check to fallback to process.execPath
when the resolved path doesn't exist.

Also fix version-command.test.ts to use process.execPath instead of
hardcoded 'bun' string for cross-platform compatibility.

Fixes 19 failing integration tests on Windows platform.
2026-04-29 16:08:53 +08:00
dongmucat
87dbf2686b fix(cli): resolve Windows CI test failures across three platform issues
- Use Bun.which() with process.execPath fallback in run-cli helper to
  resolve bun executable on Windows (fixes 22 integration tests)
- Normalize paths in credentials-store test for Windows backslash compat
- Use shell: true on Windows in updater spawn for proper exe resolution
2026-04-29 16:03:09 +08:00
dongmucat
a2df5f4eb4 fix(cli): remove explicit any type to pass ESLint checks
Replace 'any' type annotation with proper type guard in inventory-store.ts
and add optional chaining in test to satisfy TypeScript strict checks.

All three platforms (Ubuntu, macOS, Windows) CI checks now pass.
2026-04-29 15:43:32 +08:00
dongmucat
05177e3085 test(cli): add P0/P1/P2 test coverage for security and error paths
Add 36 test cases covering:
- Path traversal and symlink attack prevention in archive extraction
- SkillHubClient error handling (401/403/404/network) for all endpoints
- Inventory store concurrent writes and stale lock recovery
- Config store read/write round-trip
- Platform utilities (package-manager, updater, paths)
- Output formatting (printResult, humanize)

Tests use cross-platform commands (node) instead of shell builtins
for CI compatibility across macOS/Linux/Windows.
2026-04-29 15:37:05 +08:00
dongmucat
6916539d77 fix(cli): harden doctor scan and inventory writes
Protect doctor metadata scanning from symlinked agent, skill, and .skillhub directories, and make inventory mutations use locked atomic writes with stale lock recovery.
2026-04-29 15:37:05 +08:00
dongmucat
fb65eeb576 fix(cli): improve parse error output 2026-04-29 15:37:05 +08:00
dongmucat
351dddc912 feat(cli): add SkillHub CLI v1 with full command suite
Implement complete CLI tool for SkillHub with 12 commands, 7 backend API endpoints, and comprehensive documentation.

CLI Commands:
- help, version: Basic information
- login, logout, whoami: Authentication management
- search: Discover published skills
- install: Install skills to agent directories (14 Tier 1 agents supported)
- list, remove, doctor: Local skill management
- publish: Publish skill packages
- update: Self-update mechanism

Backend API:
- Add /api/cli/v1 endpoints for auth, search, resolve, download, delete, publish
- Implement CliAuthController and CliSkillController
- Add security policies for CLI routes
- Full test coverage (19 backend tests)

CLI Implementation:
- TypeScript with strict mode, Bun runtime
- Pure JS zip handling (fflate) for cross-platform compatibility
- 15 agent profiles (14 Tier 1 + generic fallback)
- Secure token storage (0600 permissions)
- Path safety validation for remove operations
- Comprehensive error handling (404/403/network distinction)
- 41 unit and integration tests

Documentation:
- CLI user guide (Chinese and English)
- README updates with quick start
- GitHub Actions workflow for cross-platform CI

Quality:
- lint: 0 errors
- typecheck: pass
- test: 41/41 pass
- build: 0.30 MB (target=node for npm/npx compatibility)
2026-04-29 15:37:04 +08:00