Skip to content

Commit 168f668

Browse files
authored
Prepare factory package publish metadata (#370)
1 parent 3a80b03 commit 168f668

5 files changed

Lines changed: 109 additions & 23 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env node
2+
import { dirname, join } from 'node:path'
3+
import { fileURLToPath, pathToFileURL } from 'node:url'
4+
const here = dirname(fileURLToPath(import.meta.url))
5+
const entry = join(here, '..', 'dist', 'cli', 'fleet.js')
6+
const mod = await import(pathToFileURL(entry).href)
7+
await mod.main(process.argv.slice(2))

packages/factory-sdk/bin/fleet.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const cliArgs = rawArgs.filter((arg) => arg !== '--rebuild')
1818

1919
mkdirSync(cacheDir, { recursive: true })
2020

21-
// The SDK package is type=commonjs, so Node strip-types loads .ts as CJS and rejects ESM imports.
21+
// The workspace passthrough runs raw TS sources before p4 makes the dist CLI Node-runnable.
2222
// Bundle the thin CLI entry locally instead; esbuild is declared in this package for that launcher path.
2323
const { buildSync } = require('esbuild')
2424
const buildOptions = {

packages/factory-sdk/package.json

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
{
2-
"name": "@pear/factory-sdk",
3-
"private": true,
4-
"type": "commonjs",
5-
"bin": {
6-
"fleet": "bin/fleet.mjs"
7-
},
8-
"devDependencies": {
9-
"esbuild": "^0.24.2"
10-
},
2+
"name": "@agent-relay/factory",
3+
"version": "0.1.0",
4+
"description": "Agent factory — triage, dispatch, merge-gate for relayfile-driven workspaces",
5+
"license": "UNLICENSED",
6+
"repository": { "type": "git", "url": "https://github.com/AgentWorkforce/factory" },
7+
"type": "module",
8+
"engines": { "node": ">=20" },
9+
"publishConfig": { "access": "public" },
10+
"main": "./dist/index.js",
11+
"types": "./dist/index.d.ts",
12+
"files": ["dist", "bin/factory.mjs", "package.json", "README.md"],
13+
"bin": { "factory": "bin/factory.mjs" },
1114
"exports": {
12-
".": {
13-
"types": "./src/index.ts",
14-
"default": "./src/index.ts"
15-
},
16-
"./testing": {
17-
"types": "./src/testing/index.ts",
18-
"default": "./src/testing/index.ts"
19-
},
20-
"./writeback": {
21-
"types": "./src/writeback/index.ts",
22-
"default": "./src/writeback/index.ts"
23-
}
24-
}
15+
".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" },
16+
"./testing": { "types": "./dist/testing/index.d.ts", "import": "./dist/testing/index.js" },
17+
"./writeback": { "types": "./dist/writeback/index.d.ts", "import": "./dist/writeback/index.js" }
18+
},
19+
"scripts": { "build": "tsc -p tsconfig.build.json", "test": "vitest run" },
20+
"devDependencies": { "esbuild": "^0.24.2" }
2521
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"composite": false,
5+
"outDir": "./dist",
6+
"rootDir": "./src",
7+
"declaration": true,
8+
"declarationMap": true,
9+
"sourceMap": true,
10+
"module": "ESNext",
11+
"moduleResolution": "Bundler",
12+
"noEmit": false
13+
},
14+
"include": ["src/**/*"],
15+
"exclude": ["**/*.test.ts", "**/__tests__/**", "src/testing/**/*.test.ts"]
16+
}

0 commit comments

Comments
 (0)