diff --git a/internal/application/service/tenant_skill_install_test.go b/internal/application/service/tenant_skill_install_test.go index abb56309..5c3d38c5 100644 --- a/internal/application/service/tenant_skill_install_test.go +++ b/internal/application/service/tenant_skill_install_test.go @@ -1401,6 +1401,20 @@ func TestSortedScriptPathsIsDeterministic(t *testing.T) { "only files the runtime can execute are scripts") } +func TestSortedScriptPathsSkipsVendoredTreesAtAnyDepth(t *testing.T) { + bundle := &SkillBundle{Files: map[string][]byte{ + "scripts/main.py": []byte("x"), + ".venv/lib/pkg/a.py": []byte("x"), + "node_modules/leftpad/index.js": []byte("x"), + "tools/.venv/lib/otherpkg/b.py": []byte("x"), + "sub/package/node_modules/pkg/c.mjs": []byte("x"), + }} + + require.Equal(t, []string{"scripts/main.py"}, + sortedScriptPaths(bundle, allScriptExtensions...), + "vendored trees are skipped at the bundle root and nested under subprojects") +} + type stubWorkspaceSandboxPolicy struct { disabled bool } diff --git a/internal/application/service/tenant_skill_verify.go b/internal/application/service/tenant_skill_verify.go index d6cf473a..8d8c73cd 100644 --- a/internal/application/service/tenant_skill_verify.go +++ b/internal/application/service/tenant_skill_verify.go @@ -426,12 +426,24 @@ var allScriptExtensions = []string{".py", ".js", ".mjs", ".cjs", ".sh"} // sortedScriptPaths returns the bundle's files with any of the given suffixes, // in a stable order so the emitted command is deterministic. +// +// Vendored dependency trees (.venv/, node_modules/) are skipped at any depth: +// they are installed dependencies, not scripts the model can name. A scientific +// stack vendors thousands of .py files, and enumerating them overflows the exec +// single-argument limit ("argument list too long") in every pass that builds +// one command from this list; the trees' health is covered by the dependency +// verification passes instead. Bundles are author-zipped, so a vendored tree +// can sit inside a subproject directory (tools/.venv/…) as easily as at the +// root — both placements are filtered. func sortedScriptPaths(bundle *SkillBundle, suffixes ...string) []string { if bundle == nil { return nil } var matches []string for rel := range bundle.Files { + if underVendoredTree(rel) { + continue + } for _, suffix := range suffixes { if strings.HasSuffix(rel, suffix) { matches = append(matches, rel) @@ -443,6 +455,17 @@ func sortedScriptPaths(bundle *SkillBundle, suffixes ...string) []string { return matches } +// underVendoredTree reports whether a bundle-relative path sits inside a +// .venv or node_modules tree, at the bundle root or nested under any prefix. +func underVendoredTree(rel string) bool { + for _, tree := range []string{".venv/", "node_modules/"} { + if strings.HasPrefix(rel, tree) || strings.Contains(rel, "/"+tree) { + return true + } + } + return false +} + // nodeDependencyNames lists the runtime dependencies package.json declares. // devDependencies are excluded: they are a build-time concern and the image // is not asked to carry them.