fix: monorepo build order
This commit is contained in:
18
AGENTS.md
18
AGENTS.md
@@ -41,10 +41,7 @@ npm run build --workspace=@page-agent/website
|
||||
|
||||
We adopt a very simple monorepo solution: ts reference + vite alias.
|
||||
|
||||
We use the same vite config for dev and bundling. Local packages (even when they are published to npm) will be bundled into artifacts instead of installed from npm.
|
||||
That is why we put local packages in devDependencies (with version "*") rather than dependencies.
|
||||
|
||||
You must update relative tsconfig and vite config if you add/remove/rename a package.
|
||||
You must update tsconfig and vite config if you add/remove/rename a package.
|
||||
|
||||
```bash
|
||||
packages/
|
||||
@@ -69,6 +66,17 @@ packages/
|
||||
└── dom/ # DOM tree extraction
|
||||
```
|
||||
|
||||
`workspaces` must be written in topological order to guarantee build order.
|
||||
|
||||
```json
|
||||
"workspaces": [
|
||||
// internal deps ...
|
||||
"packages/page-controller",
|
||||
"packages/page-agent",
|
||||
"packages/website"
|
||||
],
|
||||
```
|
||||
|
||||
### Module Boundaries (Critical)
|
||||
|
||||
- **Website** (`packages/website/`): CAN import from `page-agent` for demos. Alias `@/` → `website/src/`
|
||||
@@ -143,7 +151,6 @@ Query params configure `PageAgentConfig` automatically in `src/entry.ts`.
|
||||
| `src/utils/bus.ts` | Type-safe event bus for decoupled communication |
|
||||
| `src/ui/` | UI components (Panel, SimulatorMask) with CSS modules |
|
||||
| `src/llms/` | LLM integration and communication layer |
|
||||
| `src/patches/` | Framework-specific optimizations (React, Antd) |
|
||||
| `vite.config.js` | Library build configuration (ES + UMD) |
|
||||
|
||||
### Page Controller (`packages/page-controller/`)
|
||||
@@ -154,6 +161,7 @@ Query params configure `PageAgentConfig` automatically in `src/entry.ts`.
|
||||
| `src/actions.ts` | Element interaction implementations (click, input, scroll) |
|
||||
| `src/dom/dom_tree/index.js` | Core DOM extraction engine (ported from browser-use) |
|
||||
| `src/dom/getPageInfo.ts` | Page scroll/size information |
|
||||
| `src/patches/` | Framework-specific optimizations (React, Antd) |
|
||||
| `src/types.ts` | TypeScript interfaces for controller |
|
||||
|
||||
### Website (`packages/website/`)
|
||||
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -9,7 +9,9 @@
|
||||
"version": "0.0.6",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
"packages/page-controller",
|
||||
"packages/page-agent",
|
||||
"packages/website"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^20.1.0",
|
||||
@@ -7000,12 +7002,10 @@
|
||||
"version": "0.0.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@page-agent/page-controller": "^0.0.6",
|
||||
"ai-motion": "^0.4.7",
|
||||
"chalk": "^5.6.2",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@page-agent/page-controller": "*"
|
||||
}
|
||||
},
|
||||
"packages/page-controller": {
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
"version": "0.0.6",
|
||||
"type": "module",
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
"packages/page-controller",
|
||||
"packages/page-agent",
|
||||
"packages/website"
|
||||
],
|
||||
"description": "AI-powered UI agent for web applications",
|
||||
"author": "Simon<gaomeng1900>",
|
||||
|
||||
@@ -49,9 +49,7 @@
|
||||
"dependencies": {
|
||||
"ai-motion": "^0.4.7",
|
||||
"chalk": "^5.6.2",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@page-agent/page-controller": "*"
|
||||
"zod": "^4.1.12",
|
||||
"@page-agent/page-controller": "^0.0.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,19 +41,53 @@ const packages = readdirSync(packagesDir, { withFileTypes: true })
|
||||
|
||||
let hasChanges = !!versionArg
|
||||
|
||||
/**
|
||||
* Check if a dependency name is a page-agent internal package
|
||||
*/
|
||||
function isInternalPackage(name) {
|
||||
return name === 'page-agent' || name.startsWith('@page-agent/')
|
||||
}
|
||||
|
||||
/**
|
||||
* Update internal package versions in dependencies object
|
||||
* @returns {boolean} Whether any changes were made
|
||||
*/
|
||||
function updateInternalDeps(deps, newVersion) {
|
||||
if (!deps) return false
|
||||
let changed = false
|
||||
for (const [name, version] of Object.entries(deps)) {
|
||||
if (isInternalPackage(name) && version !== newVersion) {
|
||||
deps[name] = newVersion
|
||||
changed = true
|
||||
}
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
||||
for (const pkg of packages) {
|
||||
const pkgPath = join(packagesDir, pkg, 'package.json')
|
||||
if (!existsSync(pkgPath)) continue
|
||||
|
||||
const pkgJson = JSON.parse(readFileSync(pkgPath, 'utf-8'))
|
||||
const oldVersion = pkgJson.version
|
||||
let pkgChanged = false
|
||||
|
||||
if (oldVersion === newVersion) {
|
||||
// Update package version
|
||||
if (oldVersion !== newVersion) {
|
||||
pkgJson.version = newVersion
|
||||
pkgChanged = true
|
||||
}
|
||||
|
||||
// Update internal dependencies (dependencies only, devDeps keep "*")
|
||||
if (updateInternalDeps(pkgJson.dependencies, newVersion)) {
|
||||
pkgChanged = true
|
||||
}
|
||||
|
||||
if (!pkgChanged) {
|
||||
console.log(chalk.dim(` ${pkgJson.name}: ${newVersion} (unchanged)`))
|
||||
continue
|
||||
}
|
||||
|
||||
pkgJson.version = newVersion
|
||||
writeFileSync(pkgPath, JSON.stringify(pkgJson, null, '\t') + '\n')
|
||||
console.log(
|
||||
chalk.green('✓') +
|
||||
|
||||
Reference in New Issue
Block a user