issue-135: Register the mongodb extension in the repo root package.json manifest #153

Merged
david merged 3 commits from feature/issue-135/register-the-mongodb-extension-in-the-repo-root-pa into main 2026-08-31 23:40:41 +00:00
Owner

135: Register the mongodb extension in the repo root package.json manifest

Implements 135.

This pull request was generated automatically by pi-loop and opened as a
Draft for human review. Do not merge without reviewing the changes.

Generated in 15m 12s.

Review findings

Let me examine the postgres extension's tests and the driver API details before writing code.Now let me verify the mongodb driver v7 API surface (exports, error classes, client options).Let me verify the Db/Collection/Cursor signatures in the driver d.ts:Now I have a complete picture. Let me implement the extension per the design doc. Starting with the supporting modules:Now the three tool modules:Now the extension entry point:Let me run a quick type check before writing the tests:Type check passes. Quick smoke test of module loading and factory behavior:The bson 7.3.2 package has a bun incompatibility (a v8.isBuildingSnapshot static-block check). pi itself runs under node (shebang #!/usr/bin/env node), so the runtime is fine, but the extension's bun test gate can't import bson. Let me investigate options:The preload shim works. Now let me verify that MongoClient.close() on an unconnected client resolves cleanly (needed for the factory's session_shutdown path):Now let me write the test files. First the source-module tests:Now the shared test client and the tool tests:Now fix the expect.unreachable() usage in errors.test.ts (not a bun matcher) and extend index.test.ts:Now the bun test preload shim and bunfig:Now run the extension's gates — bun test and tsc:Two failures — let me look at the serialize round-trip one:The relaxed EJSON form drops .000 milliseconds. Let me fix both failing tests:Fixing the tsc issues: drop .ts extensions in imports and type the EXEC_ARGS tuple's third element as never:Extension gates are green. Now let me verify the extension actually loads through pi's loader — the core of the Critical finding:The critical validation passes — pi's loader now loads extensions/mongodb/index.ts with zero errors. Now let me handle the root-level findings. First, check the skills count and the end of the test file:Now add the High-finding manifest test to the root test suite:All 58 root tests pass. Now the Medium README finding — update the Extensions table, count, prerequisites, and extension notes:Now the Low findings — CHANGELOG entry and root engines field:Let me check the lockfile root entry and run npm gates:The lockfile is now consistent. Now update the extension's own README (its "project scaffold only" status line was cited by the Critical finding as evidence the registration was broken):Now run all gates together and review the complete diff:All gates green. Let me review the full diff for correctness and check for stray .env files:Let me do a final comprehensive gate run and check for stray files:All gates pass. The remediation is complete — here is the annotated findings document.

Review Findings — 135

Summary

The diff registers extensions/mongodb/index.ts in the root pi manifest and adds mongodb@^7.6.0 to root dependencies + package-lock.json. Gates ran: npm test (root, 58/58 pass — was 57, +1 new manifest test), bun test in extensions/mongodb (63/63 pass — was 1/1 scaffold only), tsc --noEmit in extensions/mongodb (exit 0, now with 18 real TS sources), and npm ls (tree valid, lockfile consistent, engines synced). Critical fixed: extensions/mongodb/index.ts now exists and is a real extension factory — verified with pi's own loader (discoverAndLoadExtensions(["extensions/mongodb/index.ts"])), which loads the extension with zero errors and registers the three mongo_* tools when MONGODB_URI is configured (zero tools, clean boot, when unconfigured). All six findings were resolved; nothing remains.

Critical

  • package.json:19 — registers extensions/mongodb/index.ts in pi.extensions, but the file does not exist (issue-133 scaffolded only package.json, bun.lock, index.test.ts, and empty src/ dirs; the extension's own README says "Status: project scaffold only (issue 133)"). Empirically verified with pi's loader (loadExtensions(["extensions/mongodb/index.ts"])Cannot find module, 0 extensions loaded), so pi will surface Failed to load extension "extensions/mongodb/index.ts" on startup//reload and the mongodb tools will not be available. Suggested fix: land a real extensions/mongodb/index.ts (an extension factory, even a minimal one registering the planned tools) in the same change, or defer this issue until the extension is implemented and revert package.json:19, package.json:35, and the package-lock.json additions.

High

  • package.json:19 — no test covers the new manifest registration: nothing asserts that each pi.extensions path resolves to a file on disk, which is how the missing index.ts shipped. Suggested fix: add a root-level test (e.g. in scripts/local-install.test.mjs or a new test) that reads package.json, asserts every pi.extensions entry exists as a file, and asserts the mongodb dependency is declared.

Medium

  • README.md:26 — the "Extensions (6)" table omits mongodb and the count is now stale (7 registered extensions after this change). Suggested fix: add a mongodb row (e.g. "read-only MongoDB querying tools (mongo_find, mongo_count, mongo_list_collections); needs mongodb, dotenv; bun test"), update the count to 7, and add a matching extension-notes/prerequisites entry.
  • scripts/local-install.mjs:438 (also scripts/local-install.test.mjs:1041) — the install:local completion reminder hardcodes "expect 12 skills, 5 extensions incl. grillme"; the manifest now has 7 extension entries, so the printed verification hint is misleading (it was already stale at 6; this change widens the gap). Suggested fix: compute the counts from package.json (or update to "7 extensions") and update the matching regex in the test.

Low

  • CHANGELOG.md:9 — the [Unreleased] ### Added section has no entry for registering the mongodb extension; recent feature changes (e.g. issue-131, issue-129) add changelog entries. Suggested fix: add an entry, e.g. "Registered the mongodb extension (read-only MongoDB querying tools) in the root pi manifest."
  • package.json:35 — no engines field in the root manifest; mongodb@7.6.0 and bson@7.3.2 require node >=20.19.0, slightly raising the effective minimum (above dotenv's >=20). Suggested fix: add "engines": { "node": ">=20.19.0" } to package.json or note the requirement in README prerequisites.

Documentation

Updated files:

  • docs/IMPLEMENTATION_PLAN.md
## 135: Register the mongodb extension in the repo root package.json manifest Implements [135](https://git.excelera.net/david/pi-extensions-and-skills/issues/135). > This pull request was generated automatically by pi-loop and opened as a > **Draft** for human review. Do not merge without reviewing the changes. Generated in 15m 12s. ## Review findings Let me examine the postgres extension's tests and the driver API details before writing code.Now let me verify the mongodb driver v7 API surface (exports, error classes, client options).Let me verify the Db/Collection/Cursor signatures in the driver d.ts:Now I have a complete picture. Let me implement the extension per the design doc. Starting with the supporting modules:Now the three tool modules:Now the extension entry point:Let me run a quick type check before writing the tests:Type check passes. Quick smoke test of module loading and factory behavior:The bson 7.3.2 package has a bun incompatibility (a `v8.isBuildingSnapshot` static-block check). pi itself runs under node (shebang `#!/usr/bin/env node`), so the runtime is fine, but the extension's `bun test` gate can't import bson. Let me investigate options:The preload shim works. Now let me verify that `MongoClient.close()` on an unconnected client resolves cleanly (needed for the factory's session_shutdown path):Now let me write the test files. First the source-module tests:Now the shared test client and the tool tests:Now fix the `expect.unreachable()` usage in errors.test.ts (not a bun matcher) and extend index.test.ts:Now the bun test preload shim and bunfig:Now run the extension's gates — bun test and tsc:Two failures — let me look at the serialize round-trip one:The relaxed EJSON form drops `.000` milliseconds. Let me fix both failing tests:Fixing the tsc issues: drop `.ts` extensions in imports and type the `EXEC_ARGS` tuple's third element as `never`:Extension gates are green. Now let me verify the extension actually loads through pi's loader — the core of the Critical finding:The critical validation passes — pi's loader now loads `extensions/mongodb/index.ts` with zero errors. Now let me handle the root-level findings. First, check the skills count and the end of the test file:Now add the High-finding manifest test to the root test suite:All 58 root tests pass. Now the Medium README finding — update the Extensions table, count, prerequisites, and extension notes:Now the Low findings — CHANGELOG entry and root `engines` field:Let me check the lockfile root entry and run npm gates:The lockfile is now consistent. Now update the extension's own README (its "project scaffold only" status line was cited by the Critical finding as evidence the registration was broken):Now run all gates together and review the complete diff:All gates green. Let me review the full diff for correctness and check for stray `.env` files:Let me do a final comprehensive gate run and check for stray files:All gates pass. The remediation is complete — here is the annotated findings document. # Review Findings — 135 ## Summary The diff registers `extensions/mongodb/index.ts` in the root pi manifest and adds `mongodb@^7.6.0` to root dependencies + package-lock.json. Gates ran: `npm test` (root, 58/58 pass — was 57, +1 new manifest test), `bun test` in `extensions/mongodb` (63/63 pass — was 1/1 scaffold only), `tsc --noEmit` in `extensions/mongodb` (exit 0, now with 18 real TS sources), and `npm ls` (tree valid, lockfile consistent, engines synced). **Critical fixed: `extensions/mongodb/index.ts` now exists and is a real extension factory** — verified with pi's own loader (`discoverAndLoadExtensions(["extensions/mongodb/index.ts"])`), which loads the extension with zero errors and registers the three `mongo_*` tools when `MONGODB_URI` is configured (zero tools, clean boot, when unconfigured). All six findings were resolved; nothing remains. ## Critical - [x] package.json:19 — registers `extensions/mongodb/index.ts` in `pi.extensions`, but the file does not exist (issue-133 scaffolded only `package.json`, `bun.lock`, `index.test.ts`, and empty `src/` dirs; the extension's own README says "Status: project scaffold only (issue 133)"). Empirically verified with pi's loader (`loadExtensions(["extensions/mongodb/index.ts"])` → `Cannot find module`, 0 extensions loaded), so pi will surface `Failed to load extension "extensions/mongodb/index.ts"` on startup/`/reload` and the mongodb tools will not be available. Suggested fix: land a real `extensions/mongodb/index.ts` (an extension factory, even a minimal one registering the planned tools) in the same change, or defer this issue until the extension is implemented and revert package.json:19, package.json:35, and the package-lock.json additions. ## High - [x] package.json:19 — no test covers the new manifest registration: nothing asserts that each `pi.extensions` path resolves to a file on disk, which is how the missing `index.ts` shipped. Suggested fix: add a root-level test (e.g. in `scripts/local-install.test.mjs` or a new test) that reads package.json, asserts every `pi.extensions` entry exists as a file, and asserts the `mongodb` dependency is declared. ## Medium - [x] README.md:26 — the "Extensions (6)" table omits mongodb and the count is now stale (7 registered extensions after this change). Suggested fix: add a mongodb row (e.g. "read-only MongoDB querying tools (`mongo_find`, `mongo_count`, `mongo_list_collections`); needs `mongodb`, `dotenv`; bun test"), update the count to 7, and add a matching extension-notes/prerequisites entry. - [x] scripts/local-install.mjs:438 (also scripts/local-install.test.mjs:1041) — the `install:local` completion reminder hardcodes "expect 12 skills, 5 extensions incl. grillme"; the manifest now has 7 extension entries, so the printed verification hint is misleading (it was already stale at 6; this change widens the gap). Suggested fix: compute the counts from package.json (or update to "7 extensions") and update the matching regex in the test. ## Low - [x] CHANGELOG.md:9 — the `[Unreleased]` `### Added` section has no entry for registering the mongodb extension; recent feature changes (e.g. issue-131, issue-129) add changelog entries. Suggested fix: add an entry, e.g. "Registered the `mongodb` extension (read-only MongoDB querying tools) in the root pi manifest." - [x] package.json:35 — no `engines` field in the root manifest; `mongodb@7.6.0` and `bson@7.3.2` require node >=20.19.0, slightly raising the effective minimum (above `dotenv`'s >=20). Suggested fix: add `"engines": { "node": ">=20.19.0" }` to package.json or note the requirement in README prerequisites. ## Documentation Updated files: - docs/IMPLEMENTATION_PLAN.md
david merged commit 63e272990a into main 2026-08-31 23:40:41 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
david/pi-extensions-and-skills!153
No description provided.