Skip to content

feat(cli): oa check, the dependencies of a lockfile against a repository - #476

Merged
M0Rf30 merged 4 commits into
openartifact:mainfrom
orcamedia:feat/oa-check
Nov 13, 2026
Merged

M0Rf30 merged 4 commits into
openartifact:mainfrom
orcamedia:feat/oa-check

Conversation

@orcamedia

Copy link
Copy Markdown
Contributor

Second PR of #471: oa check, starting with composer.lock and package-lock.json as agreed. It uses the batch endpoint from #473.

oa check php --lockfile composer.lock
oa check npm-all --lockfile package-lock.json --no-dev
STATUS   PACKAGE            VERSION  FROM       REASON
held     guzzlehttp/guzzle  6.5.8    php-proxy  blocked by repository curation: EOL, use 7.x
unknown  monolog/monolog    3.5.0    php-proxy  the proxy has not cached the upstream metadata of this package ...

4 dependencies: 1 available, 1 held, 0 not found, 2 unknown.

Command

  • Lockfiles: the format comes from the file name: composer.lock, package-lock.json or npm-shrinkwrap.json. Shell completion offers .lock and .json files. Lockfiles are capped at 64 MiB.
  • Requests: at most 1000 entries per request, the server's limit.
  • Output: a table of what isn't available, then a summary. --format json prints every result with summary, kind and dev per entry.
  • Exit status: 1 when anything is held or not found, also unknown with --fail-on-unknown, otherwise 0, like oa gate. --no-dev leaves out development-only dependencies.
  • Help: listed under "CI and delivery", next to gate.

Parsers (pkg/lockfile, standard library only)

  • composer.lock: packages and packages-dev. Path-repository packages are skipped, and metapackages without a dist are kept.
  • package-lock.json v2/v3: the packages map. Only entries under node_modules/ count; the root and workspace folders are skipped. An alias is named by its name field. Links, inBundle, and git or file sources are skipped. dev and devOptional mark development dependencies.
  • package-lock.json v1: the nested dependencies tree (depth bounded at 256). npm: aliases are resolved; bundled entries and git/github/file versions are skipped.
  • Output: sorted, with each name and version once. A version counts as development-only only if every occurrence of it is.

Fuzz targets: FuzzComposerLock and FuzzPackageLock, seeded from the test fixtures. They assert that output is non-empty, sorted and unique, that npm versions are registry versions, and that parsing is deterministic. Locally each ran 30 s (about 15M execs each) without a failure. The fixtures are covered in REUSE.toml.

Tests

  • Parsers: table tests over three realistic fixtures that exercise every skip rule, plus rejection of non-object, invalid and unknown inputs, and KindOf.
  • oa check: runs the real binary against a fake server:
    • everything available;
    • held plus not found exits 1, with the table and summary;
    • unknown alone passes, and fails with --fail-on-unknown;
    • --no-dev;
    • development dependencies are checked by default;
    • 1001 dependencies go out as two requests of 1000 and 1, and the JSON report;
    • refusals: no --lockfile, an unknown file name, an invalid lockfile, and a 403 from the server (an error, not a verdict).
  • Against a real server (Composer group, Packagist proxy with a block rule): the output above. The path package was skipped, and the development dependency guzzle 7.8.1 was available.

Checks

  • golangci-lint run ./... passes.
  • go test -short -race passes for internal/oacli and pkg/lockfile, along with go test ./tests/ (the guard on the binary's imports).
  • make deadcode and make docs-check (CLI reference regenerated) pass, the -tags noai,nomcp build passes, and reuse lint reports compliance.

Docs: a "Check dependencies before installing" section in docs/integrations/ci.md, and an Unreleased upgrade note.

More lockfile parsers (poetry.lock/requirements.txt, go.sum, Cargo.lock, ...) will come in later PRs, one per format, each with a fuzz target.

🤖 Generated with Claude Code

orcamedia and others added 2 commits November 12, 2026 23:34
oa check <repo> --lockfile FILE reads the package versions a
composer.lock, package-lock.json or npm-shrinkwrap.json pins and asks the
repository about them through POST /availability, at most 1000 per
request. It prints what is not available with the reason and exits 1
when a dependency is held or not found (or unknown, with
--fail-on-unknown); --format json prints every result with a summary,
--no-dev skips development-only dependencies.

pkg/lockfile (standard library only) parses both formats: composer.lock
packages and packages-dev without path packages; package-lock.json
lockfileVersion 2/3 packages (an alias by its name field; links, bundled
packages, workspace folders and git or file sources left out) and the
lockfileVersion 1 dependency tree (npm: aliases, depth bounded). The
output is sorted and each name and version appears once. FuzzComposerLock
and FuzzPackageLock assert that invariant and that parsing is
deterministic.

Refs openartifact#471.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fixtures pinned real packages at old versions (vite 5.1.4, express
4.18.2, ...). Trivy's fs scan reads lockfiles anywhere in the tree and
its gate fails on their known vulnerabilities. The parsers only need the
shape, so the fixtures now name acme packages on example.test hosts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
# Conflicts:
#	docs/getting-started/upgrading.md
# Conflicts:
#	docs/getting-started/upgrading.md
@M0Rf30
M0Rf30 merged commit 4a1c9d1 into openartifact:main Nov 13, 2026
19 checks passed
@orcamedia
orcamedia deleted the feat/oa-check branch November 13, 2026 16:51
orcamedia added a commit to openartifact/openartifact-agent-plugin that referenced this pull request Nov 13, 2026
Version 0.2.0: the `check-lockfile` skill, using the
`check_dependencies` tool that landed in openartifact/openartifact#473.

## What the skill tells the agent

1. **Find the repository** the project installs from, the
`/repos/<name>` in its package manager config. A group is fine, since
`check_dependencies` answers for one.
2. **Extract the pinned versions with `jq`**, not by reading the
lockfile into context. The filters apply the rules of `oa check`
(openartifact/openartifact#476): path packages, links, bundled packages,
workspace folders, and git or file dependencies are left out. There are
instructions for when `jq` is missing, and for lockfileVersion 1.
3. **Call `check_dependencies`** with at most 1000 entries per call.
4. **Report by status:**
- `held`, with the reason, rule id or `until` time, and the deciding
repository;
   - `not_found`;
- `unknown`, explained as "the proxy hasn't cached this package yet",
not as a block.
5. **Suggest fixes that respect the registry**, with no public-registry
fallback, handing off to `check-dependency` for an available version.

Servers without the tool (any release before #473) get a check of the
direct dependencies through `check_availability`, and the agent says the
whole lockfile couldn't be checked.

## Checked

- I ran both `jq` commands exactly as written in the skill against the
parser fixtures of #476. They return the same lists as the Go parser (4
and 5 dependencies).
- End to end against a server built from current `main`: the extracted
list from a `composer.lock` went to `check_dependencies` on a Composer
group. Guzzle 6.5.8 came back held ("EOL, use 7.x"), 7.8.1 available,
and two uncached packages unknown.
- `scripts/check-plugin.py` passes and `reuse lint` reports compliance.
CI's Agent Skills job validates the new skill.

Not tested: a full agent session using the skill. The tool is on `main`
but not in a server release yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Areef <[email protected]>
Co-authored-by: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants