WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
package skillscmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
skillsfs "github.com/Tencent/WeKnora/cli/skills"
|
||||
)
|
||||
|
||||
// TestEmbeddedSkillsPresent: the binary embeds the bundled skills with their
|
||||
// SKILL.md (the parity tests guard the command vocabulary; this guards the
|
||||
// embed itself stays wired).
|
||||
func TestEmbeddedSkillsPresent(t *testing.T) {
|
||||
skills, err := skillsfs.List()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, skills, "at least one skill must be embedded")
|
||||
for _, s := range skills {
|
||||
assert.NotEmpty(t, s.Files, "%s must embed files", s.Name)
|
||||
var hasMD bool
|
||||
for _, f := range s.Files {
|
||||
if filepath.Base(f) == "SKILL.md" {
|
||||
hasMD = true
|
||||
}
|
||||
}
|
||||
assert.True(t, hasMD, "%s must embed a SKILL.md", s.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// TestWriteSkills_WritesAndIsIdempotent: install writes every embedded file
|
||||
// preserving the dir structure; a second run without --force overwrites
|
||||
// nothing (returns no newly-written paths); --force rewrites them.
|
||||
func TestWriteSkills_WritesAndIsIdempotent(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
skills, err := skillsfs.List()
|
||||
require.NoError(t, err)
|
||||
|
||||
// First install: every file written.
|
||||
written, err := writeSkills(skills, dir, false)
|
||||
require.NoError(t, err)
|
||||
var total int
|
||||
for _, s := range skills {
|
||||
total += len(s.Files)
|
||||
}
|
||||
assert.Len(t, written, total, "first install writes every embedded file")
|
||||
for _, p := range written {
|
||||
_, statErr := os.Stat(p)
|
||||
assert.NoError(t, statErr, "written file must exist: %s", p)
|
||||
}
|
||||
|
||||
// Second install without --force: nothing overwritten.
|
||||
again, err := writeSkills(skills, dir, false)
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, again, "without --force, existing files are left untouched")
|
||||
|
||||
// With --force: all rewritten.
|
||||
forced, err := writeSkills(skills, dir, true)
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, forced, total, "--force rewrites every file")
|
||||
}
|
||||
|
||||
// TestResolveDir: explicit --dir wins; empty falls back to ~/.claude/skills.
|
||||
func TestResolveDir(t *testing.T) {
|
||||
got, err := resolveDir("/custom/path")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "/custom/path", got)
|
||||
|
||||
def, err := resolveDir("")
|
||||
require.NoError(t, err)
|
||||
assert.True(t, filepath.IsAbs(def), "default dir must be absolute")
|
||||
assert.Contains(t, def, filepath.Join(".claude", "skills"))
|
||||
}
|
||||
|
||||
// TestResolveDir_ExpandsTilde pins that a leading ~ in --dir is expanded to the
|
||||
// home directory instead of creating a literal "~" directory. Regression:
|
||||
// `skills install --dir '~/foo'` (quoted, so the shell doesn't expand it) used
|
||||
// to create a bogus ./~ tree.
|
||||
func TestResolveDir_ExpandsTilde(t *testing.T) {
|
||||
home, err := os.UserHomeDir()
|
||||
require.NoError(t, err)
|
||||
|
||||
got, err := resolveDir("~/agents/skills")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, filepath.Join(home, "agents", "skills"), got)
|
||||
assert.NotContains(t, got, "~", "~ must be expanded, not left literal")
|
||||
|
||||
bare, err := resolveDir("~")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, home, bare)
|
||||
|
||||
// A ~ that is NOT a leading path segment is left untouched (not a home ref).
|
||||
lit, err := resolveDir("/tmp/a~b")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "/tmp/a~b", lit)
|
||||
}
|
||||
Reference in New Issue
Block a user