Skip to content

feat(cli): add manifest gate and reject bare-name specs#25

Merged
amondnet merged 7 commits into
mainfrom
feat/add-docs-cli-split
Apr 8, 2026
Merged

feat(cli): add manifest gate and reject bare-name specs#25
amondnet merged 7 commits into
mainfrom
feat/add-docs-cli-split

Conversation

@amondnet

@amondnet amondnet commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • CLI add command now auto-resolves omitted versions from the project's lockfile/manifest (bun.lock → package-lock.json → pnpm-lock.yaml → yarn.lock → package.json range).
  • Bare-name specs (ask docs add next) are now rejected at the command layer — users must use npm:next (ecosystem prefix) or vercel/next.js (GitHub shorthand).
  • skills/add-docs/SKILL.md split into a CLI-call-centric happy path (137 lines, was 332) plus a references/inline-pipeline.md fallback for CLI-unavailable environments. CLI is now the single source of truth for the fetch/save pipeline.

Why

The old add-docs skill inlined a ~332-line pipeline that mirrored packages/cli/src/ logic, creating ongoing drift risk between the two implementations. This change makes CLI the SSOT and leaves the skill to do only what LLMs are good at: intent translation (bare name → ecosystem prefix, lockfile lookup). It also guarantees downloaded docs match the version actually installed in the project, not whatever npm currently labels latest.

Breaking: ask docs add next used to silently auto-detect ecosystem. It now errors with a guide message. Acceptable in v0.x.

Changes

Commit Description
c23a03b feat(cli): add npm manifest reader for lockfile-based version resolution
7e12ba1 feat(cli): integrate manifest gate and bare-name rejection in add command
efd5ce1 refactor(skills): split add-docs into happy path and inline fallback reference
952e5e8 docs: document add-docs CLI manifest gate and bare-name rejection
42418d6 test(cli): add scoped-package coverage for all 4 lockfile parsers
eedee53 fix(cli): simplify flag parsing by removing redundant fallback checks
f089c96 fix(cli): document why parsed.version mutation in Gate B is load-bearing

New flags

  • --no-manifest — skip lockfile/manifest lookup (preserves old 'latest' behavior)
  • --from-manifest — require a manifest hit; error if package not found locally

Test Plan

  • bun run --cwd packages/cli build — tsc clean
  • bun run --cwd packages/cli test192 pass / 0 fail (188 pre-existing + 4 new scoped-package tests + 21 new manifest/gates tests)
  • Manual: ask docs add next → exits 1 with bare-name guide
  • Manual: ask docs add --no-manifest npm:zod → manifest lookup skipped
  • SKILL.md line budget: wc -l skills/add-docs/SKILL.md → 137 (≤180)
  • Code review loop (2 iterations, all Important issues fixed)
  • CI: lint/build/test (babysit will monitor)

Out of scope (follow-up tracks)

  • Manifest readers for pypi, pub, cargo, go, hex, maven
  • Monorepo workspace lockfiles (root lockfile only for now)
  • Exact-vs-range distinction in ManifestHit consumption
  • SKILL.md fallback trigger wording ("on non-zero exit, load references/...")

Closes #23


Summary by cubic

Adds a manifest gate to @pleaseai/ask CLI docs add to auto-resolve versions from project lockfiles so downloaded docs match what’s installed. Also rejects bare-name specs and makes the add-docs skill CLI-first to avoid drift.

  • New Features

    • Auto-resolve omitted versions for ecosystem:name from project manifests (bun.lock → package-lock.json → pnpm-lock.yaml → yarn.lock → package.json). Skip with --no-manifest; require with --from-manifest.
    • Reject bare-name specs (e.g. ask docs add next). Use npm:next or owner/repo[@ref] instead.
    • Split skills/add-docs/SKILL.md into a short CLI-first flow with a fallback references/inline-pipeline.md.
  • Migration

    • Replace ask docs add next with ask docs add npm:next (or vercel/next.js).
    • Use --no-manifest to keep old “latest” behavior, or --from-manifest to fail if the package isn’t in your lockfile.

Written for commit f089c96. Summary will update on new commits.

amondnet added 7 commits April 8, 2026 16:19
Introduces a stateless manifest reader module that inspects a project's
lockfiles and manifests to find the installed version of a dependency.
Lookup order: bun.lock > package-lock.json > pnpm-lock.yaml > yarn.lock
> package.json (range). Lockfile hits return exact versions; package.json
falls back to a range string with `exact: false` so callers can delegate
to NpmResolver for semver normalization.

The reader is pure and filesystem-driven, making it trivial to unit test
with programmatic tmpdir fixtures (no committed fixture files).

Refs #23
…mand

Add Gate A (reject bare-name specs like `ask docs add next`) and Gate B
(auto-resolve version from project lockfile/manifest when omitted) to the
`add` command. Both gates are extracted as testable helpers
(checkBareNameGate, runManifestGate) so the policy can be unit-tested
without spinning up the full command.

New flags:
  --no-manifest    Skip lockfile/manifest lookup (preserve old 'latest' behavior)
  --from-manifest  Require manifest hit; error if package not found locally

Bare-name rejection error message guides users to either an ecosystem
prefix (`npm:next`) or the GitHub shorthand (`vercel/next.js`). The
parser (parseDocSpec) is intentionally NOT changed — it still returns
`kind: 'name'` so other callers and the regression test in
registry.test.ts continue to work; the rejection is a command-layer policy.

Refs #23
…reference

The add-docs SKILL.md previously inlined a 332-line pipeline that mirrored
packages/cli/src/ logic, creating constant drift risk between the two
implementations. Restructure the skill so:

  - SKILL.md (137 lines) holds only the happy path: parse user intent,
    detect ecosystem, build a CLI spec, run `bunx @pleaseai/ask docs add`,
    then verify the outputs. CLI is the single source of truth.

  - references/inline-pipeline.md (255 lines) holds the original
    Step 3a~8 pipeline verbatim, with a warning header naming CLI as the
    source of truth and per-step CLI equivalents for cross-reference.
    Read on demand only when the CLI is unavailable (offline, sandbox, etc.).

This is progressive disclosure — happy path stays in agent context every
session, fallback is fetched only when needed. The line budget (≤180 for
SKILL.md per AC-6) is met.

Refs #23
Update CLAUDE.md gotchas with the two new command-layer behaviors so
future agents understand the contract:

  - bare-name specs (`ask docs add next`) are rejected at the command
    layer via Gate A; users must use `npm:next` or `vercel/next.js`
  - omitting a version triggers Gate B, which reads the project
    lockfile (bun.lock → package-lock.json → pnpm-lock.yaml → yarn.lock
    → package.json range) to pin the installed version. Disable with
    --no-manifest, require with --from-manifest.

Also update README.md examples to show the new spec grammar and remove
the now-rejected bare-name example.

Refs #23
Add test cases for @nuxt/ui@3.1.0 in bun.lock, package-lock.json,
pnpm-lock.yaml, and yarn.lock to verify each parser correctly handles
the leading @ in scoped package names.

Refs #23
citty exposes kebab-case flags under the original key as defined in
addCmd.args, so args['no-manifest'] and args['from-manifest'] are the
canonical access paths. Remove the dead args.manifest===false and
Record<string, unknown> camelCase casts.

Refs #23
The mutation is not dead code: the ecosystem resolver fallback at
~line 365 calls resolver.resolve(parsed.name, parsed.version) directly,
so parsed.version must be updated alongside effectiveSpec to pass the
manifest-resolved version into the resolver.

Refs #23
@codecov

codecov Bot commented Apr 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/manifest/index.ts 28.57% 5 Missing ⚠️
packages/cli/src/manifest/npm.ts 93.15% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ask-registry with  Cloudflare Pages  Cloudflare Pages

Latest commit: f089c96
Status: ✅  Deploy successful!
Preview URL: https://9777e459.ask-registry.pages.dev
Branch Preview URL: https://feat-add-docs-cli-split.ask-registry.pages.dev

View logs

@amondnet amondnet marked this pull request as ready for review April 8, 2026 08:56
@amondnet amondnet merged commit 816352b into main Apr 8, 2026
4 checks passed
This was referenced Apr 8, 2026
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.

track: add-docs-cli-split-20260408

1 participant