Commit graph

880 commits

Author SHA1 Message Date
jangrui
ea3bf08e19 fix(tests): 移除 LocalAuthServiceTest 中不必要的 ldapProperties stub
将 ldapProperties.isEnabled() 的默认 stub 从 setUp() 移到
login_withUnknownUsername_stillPerformsDummyPasswordCheck 中,
消除 7 个测试方法的 UnnecessaryStubbingException。

Signed-off-by: jangrui <admin@jangrui.com>
2026-06-04 07:07:59 +08:00
jangrui
d09d6172c1 fix: 修复编译和启动错误
- application.yml: 合并重复的 management.health 节点,解决 DuplicateKeyException
- LocalAuthServiceTest.java: 补充 PlatformPrincipal/Set import 和类闭合括号

Signed-off-by: jangrui <admin@jangrui.com>
2026-06-04 07:07:59 +08:00
jangrui
9ff3baf756 fix: 修复 Gemini Code Assist 指出的关键问题
基于 PR #283 的代码审查反馈,修复了多个关键问题:

## 🔴 Critical 修复

### 1. 修复 LDAP 账号重复创建问题
**问题**: 如果 LDAP 用户的 mail 属性缺失或为空,每次登录都会创建新的 UserAccount,导致:
- 同一用户产生多个账号
- 用户数据在不同会话间丢失
- 数据库中出现大量重复账号

**修复**:
- 当 mail 属性为空时,使用 "ldap:{username}@internal" 作为唯一标识符
- 确保同一 LDAP 用户始终映射到同一个本地账号
- 保持用户数据的连续性

```java
// 修复前:email 为 null 时会创建新账号
String normalizedEmail = email != null ? email.toLowerCase() : null;

// 修复后:使用稳定的唯一标识符
String normalizedEmail = email != null ? email.toLowerCase() : "ldap:" + username + "@internal";
```

## 🟠 High 优先级修复

### 2. 修复测试代码中的 PlatformPrincipal 构造函数错误
**问题**: 测试中使用了错误的构造函数参数,导致编译错误

**修复**: 更正为正确的参数顺序:
```java
// 修复前
new PlatformPrincipal(userId, displayName, email, Set.of(), Set.of(), Set.of())

// 修复后
new PlatformPrincipal(userId, displayName, email, null, "ldap", Set.of("USER"))
```

### 3. 修复资源泄露问题
**问题**: `NamingEnumeration<SearchResult>` 没有正确关闭,导致 LDAP 连接泄露

**修复**: 在 finally 块中显式关闭 NamingEnumeration
```java
finally {
    if (results != null) {
        try {
            results.close();
        } catch (Exception e) {
            log.warn("Failed to close LDAP search results", e);
        }
    }
    closeContext(ctx);
}
```

## 📝 测试覆盖

- 添加了 3 个新测试用例验证 LDAP 回退功能
- 所有测试用例使用正确的构造函数
- 确保原有测试不受 LDAP 功能影响

## 🔗 相关链接

- 原始 PR: #283
- 修复 PR: #437
- Issue: #260

这些修复确保了 LDAP 认证功能的稳定性和正确性。

Signed-off-by: jangrui <admin@jangrui.com>
2026-06-04 07:07:59 +08:00
jangrui
48c15ca30c fix(tests): 明确配置 LDAP mock 默认行为并添加 LDAP 回退测试
问题分析:
- 原有测试未显式设置 ldapProperties.isEnabled() 的返回值
- 虽然 Mockito 默认返回 false,但为了测试稳定性应显式配置
- 缺少对 LDAP 回退功能的测试覆盖

修复内容:
1. 在 setUp() 中显式设置 ldapProperties.isEnabled() 返回 false
   - 确保所有原有测试不受 LDAP 功能影响
   - 提高测试的可读性和维护性

2. 添加三个新的测试用例:
   - login_withUnknownUsername_fallsBackToLdap_whenEnabled
     验证 LDAP 启用时,本地用户不存在会回退到 LDAP 认证
   - login_withUnknownUsername_fails_whenLdapAuthenticationFails
     验证 LDAP 认证失败时正确抛出异常
   - login_withUnknownUsername_fails_whenLdapDisabled
     验证 LDAP 禁用时不会调用 LDAP 服务

这些修改确保了:
- 原有测试的稳定性和可预测性
- LDAP 回退功能的正确性
- 测试覆盖的完整性

Refs: https://github.com/iflytek/skillhub/pull/283
Signed-off-by: jangrui <admin@jangrui.com>
2026-06-04 07:07:59 +08:00
Shawn Chen
0b4714f735 新增支持LDAP登录https://github.com/iflytek/skillhub/issues/260
Signed-off-by: jangrui <admin@jangrui.com>
2026-06-04 07:07:59 +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
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
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
dongmucat
e7aecc4050 fix(cli): sync publish version flow 2026-05-11 11:00:10 +08:00
dongmucat
84914c9d94
Merge pull request #359 from iflytek/feature/skillhub-cli-v1
Some checks failed
Deploy Docs / build (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(cli): add SkillHub CLI v1
2026-05-09 17:25:24 +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
3aef0ed4bc
Merge pull request #412 from iflytek/fix/namespace-management-gaps
fix(namespace): close namespace management gaps (#351)
2026-05-09 16:07:10 +08:00
dongmucat
ab06c75737 Merge branch 'main' into fix/namespace-management-gaps
Resolved conflicts by keeping both sides:
- web/src/api/client.ts: preserve paginated listMembers(slug, {page,size})
  and add delete(slug) from main.
- web/src/shared/hooks/use-namespace-queries.ts: keep useUpdateNamespace
  and useTransferNamespaceOwnership from this branch, plus useDeleteNamespace
  from main.
2026-05-09 15:13:44 +08:00
dongmucat
2821262fa4
Merge pull request #408 from iflytek/fix/namespace-delete-341
fix(namespace): support team namespace deletion
2026-05-09 15:04:06 +08:00
dongmucat
ab6fd07530
Merge pull request #414 from iflytek/fix/web-js-compat
fix(web): restore compatibility with Chromium 83 (Debian 10)
2026-05-09 15:03:02 +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
30f3a84ce0 fix(namespace): remove optimistic update on member add to avoid cross-page duplication
appendNamespaceMember was being called via setQueriesData across all cached
pages, causing the new member to appear at the end of every page. The
invalidation will refresh the list correctly.
2026-05-09 14:22:16 +08:00
dongmucat
9b64cbedba feat(namespace): add edit/transfer UI with pagination support
Add namespace edit dialog, transfer ownership dialog, and member list pagination. Update API layer to support pagination (PagedResponse), add useUpdateNamespace and useTransferNamespaceOwnership hooks with pagination-aware optimistic updates. Integrate edit button in NamespaceHeader and transfer button on members page. Add i18n keys for all new features (en + zh).
2026-05-09 14:22:16 +08:00
dongmucat
2f640e42a3 feat(namespace): add transfer ownership endpoint
Implement POST /namespaces/{slug}/transfer-ownership to allow namespace owners to transfer ownership to existing members. Includes comprehensive test coverage for success and failure scenarios (non-owner, target not found, frozen namespace).
2026-05-09 14:22:16 +08:00
Cheney
702bbff216 Merge branch 'main' into fix/web-js-compat 2026-05-09 14:18:05 +08:00
Cheney
81f7e3943f fix(web): scope legacy browser target to production build only
The top-level esbuild.target also applied to dev/test transforms, which
broke vitest suites that use top-level await (Chromium 83 / ES2020 does
not support it). Only build.target and optimizeDeps.esbuildOptions.target
need the legacy target; remove the global esbuild.target override.
2026-05-09 13:55:57 +08:00
Cheney
e869a4d365 fix(web): restore compatibility with Chromium 83 (Debian 10)
Publish page dropdowns (namespace/visibility) failed to open on older
Chromium because Vite 6 defaults build target to chrome87 and some
bundled deps call runtime APIs absent in Chrome 83 (replaceAll, .at,
hasOwn). Lower esbuild/vite target to chrome83, add browserslist, drop
??= in bootstrap, and inject runtime polyfills before main loads.
2026-05-09 13:55:50 +08:00