diff --git a/README.md b/README.md index 4b38d78..c7ea610 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,7 @@ Language ecosystems and development tools across multiple categories. **Languages:** Ada, C, C#, C++, COBOL, Clojure, Common Lisp, Crystal, D, Dart, Deno, Elixir, Elm, Emacs Lisp, Erlang, F#, Fortran, GDScript, Gleam, Go, Groovy, Haskell, Haxe, Java, JavaScript, Julia, Kotlin, Lua, Mojo, Nim, Nix, OCaml, Objective-C, Odin, PHP, Perl, Prolog, Python, R, Racket, Roc, Ruby, Rust, Scala, Scheme, Solidity, Swift, Tcl, TypeScript, V, VHDL, Verilog, Zig. -**Package Managers:** Alire, Bun, Bundler, Cabal, Cargo, CocoaPods, Composer, Conan, Conda, DUB, Deno Modules, Flit, Gleam Packages, Go Modules, Gradle, Hatch, Haxelib, Jsonnet Bundler, Maven, Mill, Mint, Mix, Nix Flakes, NuGet, PDM, Pipenv, Pkg, Poetry, Quicklisp, RubyGems, Scala CLI, Shards, Stack, Swift Package Manager, Yarn, cpanm, dotnet CLI, elm, fpm, npm, opam, pip, pnpm, pub, rebar3, renv, sbt, setuptools, uv, vcpkg. +**Package Managers:** APM, Alire, Bun, Bundler, Cabal, Cargo, CocoaPods, Composer, Conan, Conda, DUB, Deno Modules, Flit, Gleam Packages, Go Modules, Gradle, Hatch, Haxelib, Jsonnet Bundler, Maven, Mill, Mint, Mix, Nix Flakes, NuGet, PDM, Pipenv, Pkg, Poetry, Quicklisp, RubyGems, Scala CLI, Shards, Stack, Swift Package Manager, Yarn, cpanm, dotnet CLI, elm, fpm, npm, opam, pip, pnpm, pub, rebar3, renv, sbt, setuptools, uv, vcpkg. **Test:** ASV, AVA, Alcotest, Artillery, Bats, BenchmarkTools.jl, Bruno, Catch2, Cucumber, Cypress, EUnit, ExUnit, Gatling, Ginkgo, Google Test, Hspec, Hurl, JUnit, Jasmine, Jest, Kotest, Lighthouse CI, Locust, MSW, MUnit, Minitest, Mocha, Newman, PHPUnit, Pest, Playwright, REST Client, RSpec, ScalaCheck, ScalaTest, Selenium, Testify, Testing Library, Vitest, Weaver, XCTest, axe-core, benchmark-ips, cargo test, clojure.test, criterion, crystal spec, dart test, deno test, dotnet test, gleam test, go test, hyperfine, k6, kotlin.test, nf-test, pytest, pytest-benchmark, specs2, tape, testament, testthat, tinytest, tox, utest, vdiffr, zig test. diff --git a/detect/apm_test.go b/detect/apm_test.go new file mode 100644 index 0000000..eb1466d --- /dev/null +++ b/detect/apm_test.go @@ -0,0 +1,103 @@ +package detect + +import ( + "slices" + "strings" + "testing" + "testing/fstest" + + "github.com/git-pkgs/brief" +) + +const ( + apmManifest = "name: agent-workspace\nversion: 1.0.0\ndependencies:\n apm:\n - microsoft/apm-sample-package#v1.0.0\n" + apmLockfile = "lockfile_version: \"2\"\ndependencies:\n - repo_url: microsoft/apm-sample-package\n resolved_commit: a1b2c3d4e5f6789012345678901234567890abcd\n resolved_ref: v1.0.0\n depth: 1\n" +) + +func TestAPMDetection(t *testing.T) { + for _, tc := range []struct{ file, body string }{ + {"apm.yml", apmManifest}, + {"apm.lock.yaml", apmLockfile}, + {"apm.lock", apmLockfile}, + } { + t.Run(tc.file, func(t *testing.T) { + dir := t.TempDir() + writeProjectFile(t, dir, tc.file, tc.body) + r := runOn(t, dir) + if !slices.Contains(packageManagerNames(r), "APM") { + t.Errorf("package managers = %v, want APM", packageManagerNames(r)) + } + if !slices.ContainsFunc(r.Manifests, func(m brief.ManifestInfo) bool { + return m.Path == tc.file && m.Ecosystem == "apm" + }) { + t.Errorf("manifests = %+v, want %s", r.Manifests, tc.file) + } + if !slices.ContainsFunc(r.Dependencies, func(d brief.DepInfo) bool { + return d.Manifest == tc.file && d.Name == "github.com/microsoft/apm-sample-package" + }) { + t.Errorf("dependencies = %+v", r.Dependencies) + } + }) + } +} + +func TestAPMAlongsideOtherPackageManager(t *testing.T) { + dir := t.TempDir() + writeProjectFile(t, dir, "package.json", `{"name":"x","dependencies":{"lodash":"^4.17.21"}}`) + writeProjectFile(t, dir, "package-lock.json", `{"name":"x","lockfileVersion":3,"packages":{}}`) + writeProjectFile(t, dir, "index.js", "") + writeProjectFile(t, dir, "apm.yml", apmManifest) + names := packageManagerNames(runOn(t, dir)) + if !slices.Contains(names, "APM") || !slices.Contains(names, "npm") { + t.Errorf("package managers = %v, want APM and npm", names) + } +} + +func TestAPMIgnoresInstalledModules(t *testing.T) { + dir := t.TempDir() + writeProjectFile(t, dir, "apm.yml", apmManifest) + writeProjectFile(t, dir, "apm_modules/microsoft/apm-sample-package/apm.yml", "name: sample\nversion: 1.0.0\ndependencies:\n apm:\n - other/transitive\n") + writeProjectFile(t, dir, "apm_modules/microsoft/apm-sample-package/scripts/check.py", "print('hi')\n") + engine := New(loadKB(t), dir) + r, err := engine.Run() + if err != nil { + t.Fatal(err) + } + if !slices.Equal(engine.projectFiles, []string{"apm.yml"}) { + t.Errorf("project files = %v, want only apm.yml", engine.projectFiles) + } + for _, m := range r.Manifests { + if m.Path != "apm.yml" { + t.Errorf("unexpected manifest %+v", m) + } + } + for _, d := range r.Dependencies { + if strings.HasSuffix(d.Name, "other/transitive") { + t.Errorf("dependency from installed module: %+v", d) + } + } +} + +func TestAPMChangedFiles(t *testing.T) { + knowledge := loadKB(t) + project := fstest.MapFS{"apm.yml": {Data: []byte(apmManifest)}} + for _, changed := range []string{"apm.yml", "apm.lock.yaml", "apm.lock"} { + scan, err := NewFS(knowledge, project).RunTools(ToolScanOptions{ChangedFiles: []string{changed}}) + if err != nil { + t.Fatal(err) + } + if !scanCheckedTool(scan, "package_manager", "APM") { + t.Errorf("%s: APM not rechecked: %+v", changed, scan.Checked) + } + if changed == "apm.yml" && !scanHasTool(scan, "package_manager", "APM") { + t.Errorf("%s: APM not detected: %+v", changed, scan.Tools) + } + } + + dir := t.TempDir() + writeProjectFile(t, dir, "apm.yml", apmManifest) + filtered := FilterByChangedFiles(runOn(t, dir), knowledge, []string{"apm.yml"}) + if !slices.Contains(packageManagerNames(filtered), "APM") || len(filtered.Manifests) == 0 { + t.Errorf("filtered = %v, %+v", packageManagerNames(filtered), filtered.Manifests) + } +} diff --git a/go.mod b/go.mod index 3608ce7..a53fd78 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/git-pkgs/outline v0.2.4 github.com/git-pkgs/purl v0.2.1 github.com/git-pkgs/registries v0.13.2 - github.com/git-pkgs/roles v0.1.3 + github.com/git-pkgs/roles v0.1.4 github.com/klauspost/compress v1.20.4 github.com/ulikunitz/xz v0.5.17 go.yaml.in/yaml/v3 v3.0.6 diff --git a/go.sum b/go.sum index 107f4d2..f0e8a6d 100644 --- a/go.sum +++ b/go.sum @@ -43,8 +43,8 @@ github.com/git-pkgs/purl v0.2.1 h1:b46hRlOMbrG6aXjjFJdYixGi5WTh0TLlAnH9iNeuOS0= github.com/git-pkgs/purl v0.2.1/go.mod h1:l8rCfvt5iXVrFIcoQ8+vCLOaHhrtEW2id0LENP+IzMw= github.com/git-pkgs/registries v0.13.2 h1:3fWinubUZbBEJ+kDii3O5kzqHJMJBmJK1X9FefAow+I= github.com/git-pkgs/registries v0.13.2/go.mod h1:UlX6jcAd4ftRBVVNzB4mQg32tfSNCk/L2pO4Wtplnho= -github.com/git-pkgs/roles v0.1.3 h1:BkXoBFg0/4szCvBes8mD+UApRe1jITaZ/4bs+XtRxdw= -github.com/git-pkgs/roles v0.1.3/go.mod h1:USQTDlh22S7jNyAxU5SwtMfXjbX0lyJpVsGLTccyYis= +github.com/git-pkgs/roles v0.1.4 h1:GjQEqBpVe7wwLpjs/K1SdLwSlsLa/YkzwAagXORY7tI= +github.com/git-pkgs/roles v0.1.4/go.mod h1:USQTDlh22S7jNyAxU5SwtMfXjbX0lyJpVsGLTccyYis= github.com/git-pkgs/spdx v0.3.6 h1:tbkqeYLKgAcDV1qPZNAkNxpNMTx9EfoNQQhcVEHApzs= github.com/git-pkgs/spdx v0.3.6/go.mod h1:7ughkhiQFBYsZRGCBb4pbdBYXQ3y+qZE4rg5MPGmeHs= github.com/git-pkgs/vers v0.7.2 h1:Ctex1O+Ai/FONmyDaw37EolBXg0og6UdxbCjjYbeRHs= diff --git a/knowledge/_shared/_manifests.toml b/knowledge/_shared/_manifests.toml index 8ac5050..af2d3b7 100644 --- a/knowledge/_shared/_manifests.toml +++ b/knowledge/_shared/_manifests.toml @@ -38,4 +38,7 @@ files = [ "META.json", "DESCRIPTION", "renv.lock", + "apm.yml", + "apm.lock.yaml", + "apm.lock", ] diff --git a/knowledge/_shared/apm.toml b/knowledge/_shared/apm.toml new file mode 100644 index 0000000..304b24c --- /dev/null +++ b/knowledge/_shared/apm.toml @@ -0,0 +1,21 @@ +[tool] +name = "APM" +category = "package_manager" +homepage = "https://microsoft.github.io/apm/" +docs = "https://microsoft.github.io/apm/reference/manifest-schema/" +repo = "https://github.com/microsoft/apm" +description = "Agent Package Manager for AI agent skills, prompts and plugins" + +[detect] +files = ["apm.yml", "apm.lock.yaml", "apm.lock"] + +[commands] +run = "apm install" +alternatives = ["apm install --frozen", "apm deps list"] + +[config] +files = ["apm.yml", "apm.lock.yaml", "apm.lock"] +lockfile = "apm.lock.yaml" + +[taxonomy] +role = ["package-manager"]