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
49 lines
1.8 KiB
Go
49 lines
1.8 KiB
Go
package agent
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/Tencent/WeKnora/internal/agent/skills"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFormatSkillsMetadataIncludesShellGuidanceOnlyWhenEnabled(t *testing.T) {
|
|
metadata := []*skills.SkillMetadata{{Name: "demo", Description: "demo skill"}}
|
|
|
|
enabled := formatSkillsMetadata(metadata, true)
|
|
require.Contains(t, enabled, "shell_exec")
|
|
assert.Contains(t, enabled, "Freely execute shell commands")
|
|
|
|
// Cross-tool routing is what this section is for, so the skill-environment
|
|
// rules stay: which tool runs a script, and where an on-demand package goes.
|
|
assert.Contains(t, enabled, "execute_skill_script")
|
|
assert.Contains(t, enabled, "/workspace/...")
|
|
assert.Contains(t, enabled, "do not `list_sandbox_files`")
|
|
assert.Contains(t, enabled, "read_skill(skill_name, file_path)")
|
|
assert.Contains(t, enabled, ".skill-packages")
|
|
assert.Contains(t, enabled, "install_deps.py")
|
|
|
|
// How to drive one tool belongs to that tool's description, which ships with
|
|
// every request anyway. Repeating it here costs the tokens twice and lets
|
|
// the two copies drift; TestShellExecDescriptionOwnsItsMechanics covers the
|
|
// other half of this split.
|
|
for _, mechanic := range []string{
|
|
"never nest ASCII",
|
|
"do not prefix `cd /workspace &&`",
|
|
"Binary output is suppressed",
|
|
"use `file` for an unknown type",
|
|
"Increase `max_output_bytes`",
|
|
"Non-zero exit codes are normal",
|
|
} {
|
|
assert.NotContains(t, enabled, mechanic)
|
|
}
|
|
|
|
disabled := formatSkillsMetadata(metadata, false)
|
|
assert.NotContains(t, disabled, "shell_exec")
|
|
// The workspace layout describes where skill scripts read and write, so it
|
|
// stays even when the agent has no shell of its own.
|
|
assert.Contains(t, disabled, "whose working directory is `/workspace`")
|
|
assert.Contains(t, disabled, "/workspace/output")
|
|
}
|