Introduce a build-time edition hook so downstream overlays (e.g. Wukong)
can customize auth UX, config dir, static server list, visible products,
and extra root commands while keeping the default open-source behavior.
- Add pkg/edition (defaults) and pkg/editiontest contract tests; Makefile
target edition-test; CI job edition-tests.
- Root: optional RegisterExtraCommands with tool caller adapter; inject
static servers to skip market discovery when configured; deduplicate
top-level commands so overlay wins; extend hideNonDirectRuntimeCommands
with edition VisibleProducts and static commands (recovery/schema/mcp).
- Auth/config: gate login subcommand and auth login hints for embedded
editions; optional token auto-purge; edition ConfigDir override.
- version: human-readable multi-line output plus JSON with edition,
architecture, build, commit.
- Relocate internal/{config,convert,validate} to pkg/; add pkg/cli and
pkg/cmdutil (flags/time helpers).
- CI: optional notify-downstream job (GitLab trigger via secrets) on main
push; open_source_policy_test adjusted for new layout.
Secrets (repo settings): WUKONG_TRIGGER_TOKEN, WUKONG_TRIGGER_URL — optional;
if unset, downstream step is skipped.
Made-with: Cursor
85 lines
1.9 KiB
Go
85 lines
1.9 KiB
Go
package unit_test
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestOpenSourceTreeOmitsEmbeddedHostMarkers(t *testing.T) {
|
|
_, filename, _, ok := runtime.Caller(0)
|
|
if !ok {
|
|
t.Fatal("runtime.Caller(0) failed")
|
|
}
|
|
|
|
root := filepath.Clean(filepath.Join(filepath.Dir(filename), "..", ".."))
|
|
forbidden := []string{
|
|
"DWS_" + "BUILD_MODE",
|
|
"com.dingtalk.scenario." + "wukong",
|
|
"WUKONG_" + "SKILLS_DIR",
|
|
"Embedded" + "Mode",
|
|
"CleanTokenOn" + "Expiry",
|
|
"HideAuth" + "LoginCommand",
|
|
"EnablePrivate" + "UtilityCommands",
|
|
"UseExecutable" + "ConfigDir",
|
|
"DeleteExeRelative" + "TokenOnAuthErr",
|
|
"WriteToken" + "Marker",
|
|
"Token" + "Marker",
|
|
"tokenJSON" + "File",
|
|
"REWIND_" + "REQUEST_ID",
|
|
"REWIND_" + "SESSION_ID",
|
|
"REWIND_" + "MESSAGE_ID",
|
|
"MergeWukong" + "MCPHeaders",
|
|
"buildMode ==" + " \"real\"",
|
|
}
|
|
|
|
var matches []string
|
|
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, walkErr error) error {
|
|
if walkErr != nil {
|
|
return walkErr
|
|
}
|
|
if d.IsDir() {
|
|
switch d.Name() {
|
|
case ".git", ".worktrees", "node_modules", "dist", "plans":
|
|
return filepath.SkipDir
|
|
}
|
|
return nil
|
|
}
|
|
if !isScannableSourceFile(path) {
|
|
return nil
|
|
}
|
|
|
|
content, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return fmt.Errorf("read %s: %w", path, err)
|
|
}
|
|
for _, needle := range forbidden {
|
|
if strings.Contains(string(content), needle) {
|
|
rel, _ := filepath.Rel(root, path)
|
|
matches = append(matches, rel+": "+needle)
|
|
}
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("WalkDir() error = %v", err)
|
|
}
|
|
|
|
if len(matches) > 0 {
|
|
t.Fatalf("found forbidden proprietary markers in OSS tree:\n%s", strings.Join(matches, "\n"))
|
|
}
|
|
}
|
|
|
|
func isScannableSourceFile(path string) bool {
|
|
switch filepath.Ext(path) {
|
|
case ".go", ".md", ".sh", ".ps1", ".yml", ".yaml", ".tmpl":
|
|
return true
|
|
default:
|
|
return filepath.Base(path) == "Makefile"
|
|
}
|
|
}
|