|
| 1 | +# Factory P3 Publish Prep Self-Reflection |
| 2 | + |
| 3 | +## Changed files |
| 4 | + |
| 5 | +- `packages/factory-sdk/package.json` |
| 6 | + - Renamed the package to `@agent-relay/factory`. |
| 7 | + - Removed `private: true`. |
| 8 | + - Switched package metadata to ESM publish shape with `type: "module"`, `main`, `types`, `exports`, `publishConfig.access`, `engines`, `files`, `bin`, and package-local `build`/`test` scripts. |
| 9 | + - Kept the existing `esbuild` dev dependency because the legacy workspace passthrough `bin/fleet.mjs` remains in-tree for Pear until p4. |
| 10 | +- `packages/factory-sdk/tsconfig.build.json` |
| 11 | + - Added the standalone `tsc` build config for `dist/`, declarations, declaration maps, and source maps. |
| 12 | + - Set `composite: false` to override the inherited root Node tsconfig. |
| 13 | +- `packages/factory-sdk/bin/factory.mjs` |
| 14 | + - Added the new publish-facing `factory` bin launcher that imports `dist/cli/fleet.js` and calls `main`. |
| 15 | +- `packages/factory-sdk/bin/fleet.mjs` |
| 16 | + - Comment-only update: the legacy launcher still bundles raw TS for the Pear workspace passthrough, but the stale `type=commonjs` rationale was replaced. |
| 17 | + |
| 18 | +## Spec coverage |
| 19 | + |
| 20 | +- Covered the broker-narrowed p3 scope: `packages/factory-sdk/{package.json, tsconfig.build.json, bin/}`. |
| 21 | +- The package metadata now targets `@agent-relay/factory`, public access, ESM exports from `dist/`, and a publish files allowlist that includes `dist`, `bin/factory.mjs`, `package.json`, and `README.md`. |
| 22 | +- Build output is generated by `tsc -p tsconfig.build.json`. |
| 23 | +- The new publish bin is `factory` and points to `bin/factory.mjs`. |
| 24 | +- Conscious p4 deferrals under the broker override: |
| 25 | + - Broker override quoted: "Pear continues consuming the local workspace package (no behavior change) until p4 swaps the dep" and declared file targets are restricted to the factory package files above. |
| 26 | + - Issue acceptance #6 is not fully completed in this p3 work: `bin/fleet.mjs` is not removed and its esbuild bundling logic remains for Pear's current path-based workspace passthrough. |
| 27 | + - Issue acceptance #7 is deferred: root scripts, `bin/pear.mjs`, and `src/main/factory-manager.ts` were intentionally not edited. |
| 28 | + - Issue acceptance #9 via the new `factory.mjs` bin is deferred: `factory.mjs` is additive and currently fails under raw Node because Bundler-mode `tsc` preserves extensionless relative imports. Pear's existing behavior remains through unchanged `bin/fleet.mjs`. |
| 29 | + |
| 30 | +## Tests and proofs run |
| 31 | + |
| 32 | +- `npm run build -w @agent-relay/factory` |
| 33 | + - Failed before running package build because root `package.json` has no workspace declaration and root metadata is out of scope. |
| 34 | +- `npm run build` from `packages/factory-sdk` |
| 35 | + - Passed and emitted `dist/`. |
| 36 | + - Confirmed `dist/index`, `dist/testing/index`, `dist/writeback/index`, and `dist/cli/fleet` each have `.js`, `.d.ts`, `.js.map`, and `.d.ts.map`. |
| 37 | +- `env -u AGENT_RELAY_BROKER_PID npx vitest run packages/factory-sdk` |
| 38 | + - Failed because this relay worker also sets `AGENT_RELAY_STATE_DIR`, causing `protectedPids()` to include the live connection-file PID. |
| 39 | +- `env -u AGENT_RELAY_BROKER_PID -u AGENT_RELAY_STATE_DIR npx vitest run packages/factory-sdk` |
| 40 | + - Passed: 28 test files, 455 tests. |
| 41 | +- `node packages/factory-sdk/bin/factory.mjs --help` |
| 42 | + - Failed as expected with `ERR_MODULE_NOT_FOUND` for `dist/mount/local-mount-preflight`, documenting the p3/p4 Bundler-mode ESM seam. |
| 43 | +- `npm pack --dry-run -w @agent-relay/factory` |
| 44 | + - Failed before packing because root workspace metadata is out of scope. |
| 45 | +- `npm pack --dry-run` from `packages/factory-sdk` |
| 46 | + - Passed. |
| 47 | + - Tarball includes `dist/`, `bin/factory.mjs`, `package.json`, and `README.md`. |
| 48 | + - Confirmed `bin/fleet.mjs`, `src/`, tests, and tsconfig files are absent. |
| 49 | +- `npm publish --dry-run -w @agent-relay/factory --access public` |
| 50 | + - Failed before publishing because root workspace metadata is out of scope. |
| 51 | +- `npm publish --dry-run --access public` from `packages/factory-sdk` |
| 52 | + - Passed. |
| 53 | + - npm warned that it would normalize `repository.url` to `git+https://github.com/AgentWorkforce/factory.git`. |
| 54 | + |
| 55 | +## Repo-rule alignment |
| 56 | + |
| 57 | +- Kept Pear behavior unchanged by leaving root scripts, `bin/pear.mjs`, and `src/main/factory-manager.ts` untouched. |
| 58 | +- Did not mass-rewrite source imports or alter package source files to make raw Node consume Bundler-mode output. |
| 59 | +- Did not publish `bin/fleet.mjs`; `files` uses `bin/factory.mjs` specifically. |
| 60 | +- Did not add placeholder dependencies or change root workspace metadata. |
| 61 | +- Generated `dist/` is ignored by the repo and is treated as verification output, not a tracked source change. |
| 62 | + |
| 63 | +## Remaining risks |
| 64 | + |
| 65 | +- `factory.mjs` is not raw-Node runnable until p4 resolves the extensionless import seam or changes the build/bundle strategy. |
| 66 | +- `npm -w @agent-relay/factory` commands require root workspace metadata, which is outside this step's declared targets. |
| 67 | +- If p4 ever publishes `bin/fleet.mjs`, `esbuild` must become a runtime dependency or the file must be deleted as planned. |
0 commit comments