dwf-ai-connector 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  DWF AI Connector 是一个面向 DWF(低代码平台)的 AI Agent 控制台,帮助用户通过自然语言与 DWF 环境交互,完成数据建模、应用建模、对象管理等操作。
4
4
 
5
5
  它包含一个 React 前端、多个 Node.js 后端服务,以及 MCP(Model Context Protocol)工具服务,支持通过浏览器或第三方 MCP 客户端使用。
6
- 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
6
+
7
7
  ---
8
8
 
9
9
  ## 架构概览
@@ -227,7 +227,22 @@ npm install -g .
227
227
  dwf-ai-connector
228
228
  ```
229
229
 
230
- > **注意**:Windows 下 `npm install -g .` 会创建指向源码目录的 symlink,因此修改代码后只需重新 `npm run build` 即可生效。但如果修改了 `package.json` 的 `bin` / `files` 字段,需要重新 `npm install -g .`。
230
+ > **注意**:Windows 下 `npm install -g .` 会创建指向源码目录的 symlink,因此修改代码后只需重新 `npm run build` 即可生效。但如果修改了 `package.json` 的 `bin` / `files` / `dependencies` 字段,需要重新 `npm install -g .`。
231
+
232
+ ### 开发与测试全局安装
233
+
234
+ 如果你正在修改 CLI 代码并想通过全局安装验证:
235
+
236
+ ```powershell
237
+ # 修改代码后
238
+ npm run build
239
+
240
+ # 重新全局安装(因为 package.json 可能变了)
241
+ npm install -g .
242
+
243
+ # 运行测试
244
+ dwf-ai-connector
245
+ ```
231
246
 
232
247
  ### CLI 参数
233
248
 
@@ -268,18 +283,32 @@ CLI 默认使用以下端口和环境变量,可通过标准环境变量覆盖
268
283
  ## 发布到 npm
269
284
 
270
285
  ```bash
271
- # 1. 确保已登录
272
- npm whoami
286
+ # 1. 确保已登录到官方 registry(不要指向 cnpm 等镜像)
287
+ npm whoami --registry https://registry.npmjs.org/
273
288
 
274
289
  # 2. 发布(prepack 自动执行 npm run build)
275
- npm publish
290
+ npm publish --registry https://registry.npmjs.org/ --access public
276
291
  ```
277
292
 
278
- `package.json` 的 `files` 字段控制发布内容,仅包含:
279
- - `bin/` — CLI 入口
293
+ ### 发布注意事项
294
+
295
+ - **Registry**:如果本地 `npm config get registry` 返回的是 `https://registry.npmmirror.com/` 等镜像,必须显式加 `--registry https://registry.npmjs.org/`,否则 `npm login` 和 `npm publish` 都会指向镜像而失败。
296
+ - **2FA**:如果账号开启双因素认证,普通密码登录无法 publish。请使用 **Classic Token - Automation** 类型或 **Granular Access Token(启用 Bypass 2FA)**,并通过 `npm config set //registry.npmjs.org/:_authToken=你的token` 设置。
297
+ - **版本号**:每次发布必须提升 `package.json` 的 `version` 字段。`prepack` 会自动重新 build,确保 `dist/` 是最新的。
298
+ - **测试发布**:正式发布前可用 `npm pack --dry-run` 预览 tarball 内容。
299
+
300
+ `package.json` 的 `files` 字段控制发布内容,包含:
301
+
302
+ - `bin/` — CLI 入口(`dwf-ai-connector.js` + `postinstall.js`)
280
303
  - `apps/web/dist/` — 前端构建产物
304
+ - `packages/shared/package.json` + `dist/` — 共享类型包
281
305
  - `services/*/dist/` — 各服务构建产物
282
- - `packages/*/dist/` — 共享包构建产物
306
+ - `services/agent-runtime/skills/builtin/` — 内置 Skills
307
+ - `services/dwf-cli/config/` — CLI 工具注册表
308
+ - `services/dwf-mcp-server/package.json` + `dist/` + `config/` — MCP 服务
309
+ - `README.md`
310
+
311
+ 内部 workspace 包(`@dwf/shared`、`@dwf/dwf-mcp-server`)不会作为独立包发布。安装时 `postinstall` 脚本会自动把它们复制到 `node_modules/@dwf/` 下,供运行时解析。
283
312
 
284
313
  ## 开发命令
285
314
 
@@ -305,6 +334,68 @@ npm run dev -w @dwf/dwf-backend
305
334
 
306
335
  ## 常见问题
307
336
 
337
+ ### 全局安装后启动报错 `Cannot find package 'xxx'`
338
+
339
+ 原因:npm 全局安装时,`@dwf/shared` 和 `@dwf/dwf-mcp-server` 这两个内部 workspace 包没有自动进入 `node_modules/@dwf/`,postinstall 脚本没有正确执行。
340
+
341
+ 解决:
342
+
343
+ 1. 确认安装时 postinstall 已执行(重新安装):
344
+ ```bash
345
+ npm uninstall -g dwf-ai-connector
346
+ npm install dwf-ai-connector -g
347
+ ```
348
+
349
+ 2. 检查目录是否存在:
350
+ ```bash
351
+ ls "$(npm root -g)/dwf-ai-connector/node_modules/@dwf/shared/dist/index.js"
352
+ ls "$(npm root -g)/dwf-ai-connector/node_modules/@dwf/dwf-mcp-server/dist/index.js"
353
+ ```
354
+
355
+ 3. 如果确实缺失,可能是 `npm install` 加了 `--ignore-scripts`。手动执行:
356
+ ```bash
357
+ cd "$(npm root -g)/dwf-ai-connector"
358
+ node bin/postinstall.js
359
+ ```
360
+
361
+ ### 全局安装后启动报错 `EACCES` / `EPERM`
362
+
363
+ Windows 下可能是旧安装残留导致。关闭所有 node 进程后删除残留目录:
364
+
365
+ ```powershell
366
+ # 结束所有 node 进程
367
+ Get-Process node | Stop-Process -Force
368
+
369
+ # 删除残留安装目录
370
+ Remove-Item -Recurse -Force "$env:APPDATA\nvm\v22.17.0\node_modules\dwf-ai-connector"
371
+
372
+ # 重新安装
373
+ npm install dwf-ai-connector -g
374
+ ```
375
+
376
+ ### 端口被占用
377
+
378
+ CLI 默认使用 9088 / 5180 / 5190。如果启动失败提示 `EADDRINUSE`:
379
+
380
+ ```powershell
381
+ # 查找占用端口的进程
382
+ Get-NetTCPConnection -LocalPort 9088,5180,5190 | Select-Object LocalPort, OwningProcess
383
+
384
+ # 结束对应进程
385
+ Stop-Process -Id <PID> -Force
386
+ ```
387
+
388
+ ### npm login 跳转到 cnpm 或返回 401/404
389
+
390
+ 原因:本地 registry 配置成了镜像。
391
+
392
+ 解决:所有 npm 发布命令都显式指定官方 registry:
393
+
394
+ ```bash
395
+ npm login --registry https://registry.npmjs.org/
396
+ npm publish --registry https://registry.npmjs.org/ --access public
397
+ ```
398
+
308
399
  ### 启动时报错 `PostgreSQL dependencies not available`
309
400
 
310
401
  原因:当前 `DATABASE_URL` 以 `postgresql://` 开头,但工作区没有安装 `pg` 包。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dwf-ai-connector",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "DWF AI Connector - AI Agent console for DWF low-code platform",
5
5
  "license": "MIT",
6
6
  "author": "DWF Team",
@@ -36,13 +36,16 @@
36
36
  "files": [
37
37
  "bin/",
38
38
  "apps/web/dist/",
39
+ "packages/shared/package.json",
39
40
  "packages/shared/dist/",
40
41
  "services/agent-gateway/dist/",
41
42
  "services/agent-runtime/dist/",
42
43
  "services/agent-runtime/skills/builtin/",
43
44
  "services/dwf-backend/dist/",
45
+ "services/dwf-backend/config/",
44
46
  "services/dwf-cli/dist/",
45
47
  "services/dwf-cli/config/",
48
+ "services/dwf-mcp-server/package.json",
46
49
  "services/dwf-mcp-server/dist/",
47
50
  "services/dwf-mcp-server/config/",
48
51
  "README.md"
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@dwf/shared",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json"
16
+ }
17
+ }