@coze-arch/cli 0.1.4-alpha.4711a7 → 0.1.4-alpha.5377b5

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.
Files changed (39) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/dev_build.sh +3 -3
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +2 -0
  3. package/lib/__templates__/expo/.cozeproj/scripts/prepare-node-modules.sh +149 -0
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +3 -3
  5. package/lib/__templates__/expo/pnpm-lock.yaml +5 -5
  6. package/lib/__templates__/expo/server/package.json +1 -1
  7. package/lib/__templates__/nextjs/next.config.ts +1 -0
  8. package/lib/__templates__/nextjs/package.json +2 -2
  9. package/lib/__templates__/nextjs/pnpm-lock.yaml +20 -20
  10. package/lib/__templates__/nextjs/scripts/build.ps1 +1 -1
  11. package/lib/__templates__/nextjs/scripts/build.sh +2 -2
  12. package/lib/__templates__/nextjs/scripts/dev.sh +2 -0
  13. package/lib/__templates__/nextjs/scripts/prepare-node-modules.sh +149 -0
  14. package/lib/__templates__/nextjs/scripts/prepare.sh +1 -4
  15. package/lib/__templates__/nextjs/src/server.ts +1 -1
  16. package/lib/__templates__/nextjs/template.config.js +0 -59
  17. package/lib/__templates__/nuxt-vue/package.json +1 -1
  18. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +5 -5
  19. package/lib/__templates__/nuxt-vue/scripts/build.sh +1 -1
  20. package/lib/__templates__/nuxt-vue/scripts/dev.sh +2 -0
  21. package/lib/__templates__/nuxt-vue/scripts/prepare-node-modules.sh +149 -0
  22. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +1 -4
  23. package/lib/__templates__/pi-agent/package.json +1 -1
  24. package/lib/__templates__/pi-agent/pnpm-lock.yaml +5 -5
  25. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +3 -2
  26. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +3 -0
  27. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +3 -1
  28. package/lib/__templates__/taro/.cozeproj/scripts/prepare-node-modules.sh +149 -0
  29. package/lib/__templates__/taro/pnpm-lock.yaml +5 -5
  30. package/lib/__templates__/taro/server/package.json +1 -1
  31. package/lib/__templates__/vite/package.json +1 -1
  32. package/lib/__templates__/vite/pnpm-lock.yaml +5 -5
  33. package/lib/__templates__/vite/scripts/build.sh +1 -1
  34. package/lib/__templates__/vite/scripts/dev.sh +2 -0
  35. package/lib/__templates__/vite/scripts/prepare-node-modules.sh +149 -0
  36. package/lib/__templates__/vite/scripts/prepare.sh +1 -4
  37. package/lib/__templates__/vite/template.config.js +0 -59
  38. package/lib/cli.js +34 -12
  39. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
  if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
3
3
  set -euo pipefail
4
- ROOT_DIR="$(pwd)"
4
+ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
5
5
  PREVIEW_DIR="/source/preview"
6
6
  SOURCE_DIR="/source"
7
7
 
@@ -34,8 +34,8 @@ echo "==================== 安装项目依赖 ===================="
34
34
  if [ ! -f "package.json" ]; then
35
35
  echo "项目目录下无 package.json,不是合法的 Node.js 项目"
36
36
  fi
37
- # 步骤 2.1/2.2:安装项目依赖
38
- pnpm install --registry=https://registry.npmmirror.com || echo "Expo 项目依赖安装失败(pnpm 执行出错)"
37
+ # 步骤 2.1/2.2:通过受管入口安装项目依赖
38
+ bash "$ROOT_DIR/.cozeproj/scripts/prepare-node-modules.sh" --registry=https://registry.npmmirror.com
39
39
 
40
40
  echo "检查根目录 post_install.py"
41
41
  if [ -f "$PREVIEW_DIR/post_install.py" ]; then
@@ -135,6 +135,7 @@ shift
135
135
  child_pid=$!
136
136
 
137
137
  # 先忽略 TERM,才能在向整组发 TERM(自己也在组里)之后存活下来补一发 KILL。
138
+ if [[ -z "${COZE_EVAL:-}" && -z "${COZE_PROJECT_TYPE:-}" ]]; then
138
139
  ( trap "" TERM
139
140
  sleep "${timeout_seconds}"
140
141
  echo "[dev] 后台进程运行超过 ${timeout_seconds}s,回收进程组 $$。"
@@ -142,6 +143,7 @@ child_pid=$!
142
143
  sleep 5
143
144
  kill -KILL -- "-$$" 2>/dev/null || true
144
145
  ) &
146
+ fi
145
147
 
146
148
  wait "${child_pid}"
147
149
  kill -KILL -- "-$$" 2>/dev/null || true
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env bash
2
+ # Install dependencies on local disk and expose them to the source tree by symlink.
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
6
+ if [ "$(basename "$(dirname "$SCRIPT_DIR")")" = ".cozeproj" ]; then
7
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
8
+ else
9
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
10
+ fi
11
+
12
+ command -v pnpm >/dev/null 2>&1 || {
13
+ echo "[node_modules] pnpm is required" >&2
14
+ exit 1
15
+ }
16
+
17
+ DRIVE_ROOT="${COZE_DRIVE_ROOT:-/Coze/Drive}"
18
+ if [ -d "$DRIVE_ROOT" ]; then
19
+ DRIVE_ROOT="$(cd "$DRIVE_ROOT" && pwd -P)"
20
+ else
21
+ DRIVE_ROOT="${DRIVE_ROOT%/}"
22
+ fi
23
+ case "$PROJECT_ROOT" in
24
+ "$DRIVE_ROOT"|"$DRIVE_ROOT"/*) ;;
25
+ *)
26
+ (cd "$PROJECT_ROOT" && pnpm install "$@")
27
+ exit 0
28
+ ;;
29
+ esac
30
+
31
+ NM_ROOT="/tmp/nm"
32
+ PROJECT_ID="$(basename "$PROJECT_ROOT")-$(printf '%s' "$PROJECT_ROOT" | cksum | awk '{print $1}')"
33
+ mkdir -p "$NM_ROOT"
34
+ WORK_DIR="$NM_ROOT/$PROJECT_ID"
35
+ case "$WORK_DIR" in
36
+ "$DRIVE_ROOT"|"$DRIVE_ROOT"/*)
37
+ echo "[node_modules] local dependency directory must not be on Coze Drive: $WORK_DIR" >&2
38
+ exit 1
39
+ ;;
40
+ esac
41
+
42
+ LOCK_DIR="$NM_ROOT/$PROJECT_ID.lock"
43
+ while ! mkdir "$LOCK_DIR" 2>/dev/null; do
44
+ echo "[node_modules] Waiting for another dependency preparation for this project..."
45
+ sleep 1
46
+ done
47
+ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
48
+
49
+ mkdir -p "$WORK_DIR"
50
+
51
+ # Mirror the project with symlinks. node_modules stays real in WORK_DIR;
52
+ # workspace directories stay real too, so pnpm never writes them to Drive.
53
+ mirror_root() {
54
+ local entry name
55
+ while IFS= read -r -d '' entry; do
56
+ name="$(basename "$entry")"
57
+ case "$name" in
58
+ node_modules|pnpm-lock.yaml) continue ;;
59
+ client|server)
60
+ [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
+ ;;
62
+ esac
63
+ rm -rf "$entry"
64
+ done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
65
+
66
+ while IFS= read -r -d '' entry; do
67
+ name="$(basename "$entry")"
68
+ case "$name" in
69
+ node_modules|pnpm-lock.yaml) continue ;;
70
+ client|server)
71
+ [ -f "$entry/package.json" ] && continue
72
+ ;;
73
+ esac
74
+ ln -s "$entry" "$WORK_DIR/$name"
75
+ done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
76
+ }
77
+
78
+ mirror_workspace() {
79
+ local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
+ local entry name
81
+ if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
+ rm -rf "$work_dir"
83
+ fi
84
+ mkdir -p "$work_dir"
85
+
86
+ while IFS= read -r -d '' entry; do
87
+ [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
+ done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
+
90
+ while IFS= read -r -d '' entry; do
91
+ name="$(basename "$entry")"
92
+ [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
+ done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
94
+ }
95
+
96
+ mirror_root
97
+ for workspace in client server; do
98
+ if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
99
+ mirror_workspace "$workspace"
100
+ fi
101
+ done
102
+
103
+ # pnpm refuses to update a symlinked lockfile, so install against a local copy.
104
+ rm -rf "$WORK_DIR/pnpm-lock.yaml"
105
+ if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
106
+ cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
107
+ fi
108
+
109
+ echo "[node_modules] Installing dependencies in $WORK_DIR"
110
+ if ! (cd "$WORK_DIR" && pnpm install "$@"); then
111
+ rm -f "$WORK_DIR/pnpm-lock.yaml"
112
+ exit 1
113
+ fi
114
+
115
+ if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
116
+ temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
117
+ cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
118
+ chmod 0644 "$temporary_lockfile"
119
+ mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
120
+ fi
121
+
122
+ link_node_modules() {
123
+ local source_dir="$1" target_dir="$2"
124
+ local current=""
125
+ mkdir -p "$target_dir"
126
+ if [ -L "$source_dir/node_modules" ]; then
127
+ current="$(readlink "$source_dir/node_modules")"
128
+ case "$current" in
129
+ "$NM_ROOT"/*/node_modules|"$NM_ROOT"/*/*/node_modules) ;;
130
+ *)
131
+ echo "[node_modules] refusing to replace unmanaged symlink: $source_dir/node_modules" >&2
132
+ exit 1
133
+ ;;
134
+ esac
135
+ rm "$source_dir/node_modules"
136
+ elif [ -e "$source_dir/node_modules" ]; then
137
+ rm -rf "$source_dir/node_modules"
138
+ fi
139
+ ln -s "$target_dir" "$source_dir/node_modules"
140
+ }
141
+
142
+ link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
143
+ for workspace in client server; do
144
+ if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
145
+ link_node_modules "$PROJECT_ROOT/$workspace" "$WORK_DIR/$workspace/node_modules"
146
+ fi
147
+ done
148
+
149
+ echo "[node_modules] Dependencies ready"
@@ -1,7 +1,7 @@
1
1
  #!/bin/bash
2
2
  if [ -z "${BASH_VERSION:-}" ]; then exec /usr/bin/env bash "$0" "$@"; fi
3
3
  set -euo pipefail
4
- ROOT_DIR="$(pwd)"
4
+ ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
5
5
 
6
6
  # ==================== 工具函数 ====================
7
7
  info() {
@@ -32,8 +32,8 @@ info "==================== 安装 Node 依赖 ===================="
32
32
  info "开始安装 Node 依赖"
33
33
  if [ -f "$ROOT_DIR/package.json" ]; then
34
34
  info "进入目录:$ROOT_DIR"
35
- info "正在执行:pnpm install"
36
- (cd "$ROOT_DIR" && pnpm install --registry=https://registry.npmmirror.com) || error "Node 依赖安装失败"
35
+ info "正在执行受管依赖准备入口"
36
+ bash "$ROOT_DIR/.cozeproj/scripts/prepare-node-modules.sh" --registry=https://registry.npmmirror.com || error "Node 依赖安装失败"
37
37
  else
38
38
  warn "未找到 $ROOT_DIR/package.json 文件,请检查路径是否正确"
39
39
  fi
@@ -269,8 +269,8 @@ importers:
269
269
  specifier: ^2.8.5
270
270
  version: 2.8.6
271
271
  coze-coding-dev-sdk:
272
- specifier: ^0.7.25
273
- version: 0.7.25(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0)
272
+ specifier: ^0.7.28
273
+ version: 0.7.28(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0)
274
274
  dayjs:
275
275
  specifier: ^1.11.20
276
276
  version: 1.11.20
@@ -2643,8 +2643,8 @@ packages:
2643
2643
  resolution: {integrity: sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA==}
2644
2644
  engines: {node: '>=10'}
2645
2645
 
2646
- coze-coding-dev-sdk@0.7.25:
2647
- resolution: {integrity: sha512-5683ngikMdsRW0slGTE2OAZ1Fyj0lhkC4fGNOwsqKc35e68/gtg9KmmtK9CK9SZ+5/oIn/4wLoHXFB0gHJtO2A==}
2646
+ coze-coding-dev-sdk@0.7.28:
2647
+ resolution: {integrity: sha512-ku7AiVWUmgCrUuMT1m2iTmHIwG39EfmcAhPASd8M7XyKxIC6A1cjIIe/3YpStRsj8pMF9LU+pxHWxisf+F44oQ==}
2648
2648
  engines: {node: '>=18.0.0'}
2649
2649
  hasBin: true
2650
2650
 
@@ -9088,7 +9088,7 @@ snapshots:
9088
9088
  path-type: 4.0.0
9089
9089
  yaml: 1.10.2
9090
9090
 
9091
- coze-coding-dev-sdk@0.7.25(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0):
9091
+ coze-coding-dev-sdk@0.7.28(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0):
9092
9092
  dependencies:
9093
9093
  '@langchain/core': 1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6))
9094
9094
  '@langchain/openai': 1.2.3(@langchain/core@1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6)))(ws@8.19.0)
@@ -12,7 +12,7 @@
12
12
  "dependencies": {
13
13
  "@supabase/supabase-js": "2.95.3",
14
14
  "cors": "^2.8.5",
15
- "coze-coding-dev-sdk": "^0.7.25",
15
+ "coze-coding-dev-sdk": "^0.7.28",
16
16
  "dayjs": "^1.11.20",
17
17
  "dotenv": "^17.2.3",
18
18
  "drizzle-orm": "^0.45.1",
@@ -3,6 +3,7 @@ import type { NextConfig } from 'next';
3
3
  const nextConfig: NextConfig = {
4
4
  // outputFileTracingRoot: path.resolve(__dirname, '../../'), // Uncomment and add 'import path from "path"' if needed
5
5
  /* config options here */
6
+ serverExternalPackages: ['coze-coding-dev-sdk'],
6
7
  allowedDevOrigins: ['*.dev.coze.site'],
7
8
  images: {
8
9
  remotePatterns: [
@@ -47,7 +47,7 @@
47
47
  "class-variance-authority": "^0.7.1",
48
48
  "clsx": "^2.1.1",
49
49
  "cmdk": "^1.1.1",
50
- "coze-coding-dev-sdk": "^0.7.25",
50
+ "coze-coding-dev-sdk": "^0.7.28",
51
51
  "date-fns": "^4.1.0",
52
52
  "dotenv": "^17.2.3",
53
53
  "drizzle-kit": "^0.31.8",
@@ -81,7 +81,7 @@
81
81
  "@types/react": "^19",
82
82
  "@types/react-dom": "^19",
83
83
  "eslint": "^9",
84
- "eslint-config-next": "16.3.3",
84
+ "eslint-config-next": "16.1.1",
85
85
  "only-allow": "^1.2.2",
86
86
  "react-dev-inspector": "^2.0.1",
87
87
  "shadcn": "latest",
@@ -111,8 +111,8 @@ importers:
111
111
  specifier: ^1.1.1
112
112
  version: 1.1.1(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)
113
113
  coze-coding-dev-sdk:
114
- specifier: ^0.7.25
115
- version: 0.7.25(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0)
114
+ specifier: ^0.7.28
115
+ version: 0.7.28(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0)
116
116
  date-fns:
117
117
  specifier: ^4.1.0
118
118
  version: 4.1.0
@@ -208,8 +208,8 @@ importers:
208
208
  specifier: ^9
209
209
  version: 9.39.2(jiti@2.6.1)
210
210
  eslint-config-next:
211
- specifier: 16.3.3
212
- version: 16.3.3(@typescript-eslint/parser@8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
211
+ specifier: 16.1.1
212
+ version: 16.1.1(@typescript-eslint/parser@8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
213
213
  only-allow:
214
214
  specifier: ^1.2.2
215
215
  version: 1.2.2
@@ -644,11 +644,11 @@ packages:
644
644
 
645
645
  '@esbuild-kit/core-utils@3.3.2':
646
646
  resolution: {integrity: sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ==}
647
- deprecated: 'Merged into tsx: https://tsx.is'
647
+ deprecated: 'Merged into tsx: https://tsx.hirok.io'
648
648
 
649
649
  '@esbuild-kit/esm-loader@2.6.5':
650
650
  resolution: {integrity: sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA==}
651
- deprecated: 'Merged into tsx: https://tsx.is'
651
+ deprecated: 'Merged into tsx: https://tsx.hirok.io'
652
652
 
653
653
  '@esbuild/aix-ppc64@0.25.12':
654
654
  resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==}
@@ -1437,8 +1437,8 @@ packages:
1437
1437
  '@next/env@16.1.1':
1438
1438
  resolution: {integrity: sha512-3oxyM97Sr2PqiVyMyrZUtrtM3jqqFxOQJVuKclDsgj/L728iZt/GyslkN4NwarledZATCenbk4Offjk1hQmaAA==}
1439
1439
 
1440
- '@next/eslint-plugin-next@16.3.3':
1441
- resolution: {integrity: sha512-pbEh30vvjKpDoTAmo1v3q2uM4JUi8QaEBpbmjWvGfoec2jLghy/WNtvzAT0bk+Ik9oz6etjt4YjXEk4BQnicCw==}
1440
+ '@next/eslint-plugin-next@16.1.1':
1441
+ resolution: {integrity: sha512-Ovb/6TuLKbE1UiPcg0p39Ke3puyTCIKN9hGbNItmpQsp+WX3qrjO3WaMVSi6JHr9X1NrmthqIguVHodMJbh/dw==}
1442
1442
 
1443
1443
  '@next/swc-darwin-arm64@16.1.1':
1444
1444
  resolution: {integrity: sha512-JS3m42ifsVSJjSTzh27nW+Igfha3NdBOFScr9C80hHGrWx55pTrVL23RJbqir7k7/15SKlrLHhh/MQzqBBYrQA==}
@@ -3379,8 +3379,8 @@ packages:
3379
3379
  typescript:
3380
3380
  optional: true
3381
3381
 
3382
- coze-coding-dev-sdk@0.7.25:
3383
- resolution: {integrity: sha512-5683ngikMdsRW0slGTE2OAZ1Fyj0lhkC4fGNOwsqKc35e68/gtg9KmmtK9CK9SZ+5/oIn/4wLoHXFB0gHJtO2A==}
3382
+ coze-coding-dev-sdk@0.7.28:
3383
+ resolution: {integrity: sha512-ku7AiVWUmgCrUuMT1m2iTmHIwG39EfmcAhPASd8M7XyKxIC6A1cjIIe/3YpStRsj8pMF9LU+pxHWxisf+F44oQ==}
3384
3384
  engines: {node: '>=18.0.0'}
3385
3385
  hasBin: true
3386
3386
 
@@ -3805,8 +3805,8 @@ packages:
3805
3805
  resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==}
3806
3806
  engines: {node: '>=10'}
3807
3807
 
3808
- eslint-config-next@16.3.3:
3809
- resolution: {integrity: sha512-teqtsR26tnlfXFHfVLTM/4tzEzU8DMu6GS1sddZzhfGzgd2f2ofbgDUcsk6cssSCzX6Tk6fmWifJcdANSdPJrw==}
3808
+ eslint-config-next@16.1.1:
3809
+ resolution: {integrity: sha512-55nTpVWm3qeuxoQKLOjQVciKZJUphKrNM0fCcQHAIOGl6VFXgaqeMfv0aKJhs7QtcnlAPhNVqsqRfRjeKBPIUA==}
3810
3810
  peerDependencies:
3811
3811
  eslint: '>=9.0.0'
3812
3812
  typescript: '>=3.3.1'
@@ -3898,6 +3898,7 @@ packages:
3898
3898
  eslint@9.39.2:
3899
3899
  resolution: {integrity: sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==}
3900
3900
  engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
3901
+ deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options.
3901
3902
  hasBin: true
3902
3903
  peerDependencies:
3903
3904
  jiti: '*'
@@ -4204,7 +4205,7 @@ packages:
4204
4205
 
4205
4206
  glob@7.2.3:
4206
4207
  resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
4207
- deprecated: Glob versions prior to v9 are no longer supported
4208
+ deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
4208
4209
 
4209
4210
  global-modules@2.0.0:
4210
4211
  resolution: {integrity: sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==}
@@ -5476,6 +5477,7 @@ packages:
5476
5477
  recharts@2.15.4:
5477
5478
  resolution: {integrity: sha512-UT/q6fwS3c1dHbXv2uFgYJ9BMFHu3fwnd7AYZaEQhXuYQ4hgsxLvsUXzGdKeZrW5xopzDCvuA2N41WJ88I7zIw==}
5478
5479
  engines: {node: '>=14'}
5480
+ deprecated: 1.x and 2.x branches are no longer active. Bump to Recharts v3 to receive latest features and bugfixes. See https://github.com/recharts/recharts/wiki/3.0-migration-guide
5479
5481
  peerDependencies:
5480
5482
  react: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
5481
5483
  react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
@@ -6093,6 +6095,7 @@ packages:
6093
6095
 
6094
6096
  uuid@10.0.0:
6095
6097
  resolution: {integrity: sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==}
6098
+ deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
6096
6099
  hasBin: true
6097
6100
 
6098
6101
  validate-npm-package-name@7.0.2:
@@ -7631,12 +7634,9 @@ snapshots:
7631
7634
 
7632
7635
  '@next/env@16.1.1': {}
7633
7636
 
7634
- '@next/eslint-plugin-next@16.3.3(eslint@9.39.2(jiti@2.6.1))':
7637
+ '@next/eslint-plugin-next@16.1.1':
7635
7638
  dependencies:
7636
- '@eslint-community/eslint-utils': 4.9.1(eslint@9.39.2(jiti@2.6.1))
7637
7639
  fast-glob: 3.3.1
7638
- transitivePeerDependencies:
7639
- - eslint
7640
7640
 
7641
7641
  '@next/swc-darwin-arm64@16.1.1':
7642
7642
  optional: true
@@ -9672,7 +9672,7 @@ snapshots:
9672
9672
  optionalDependencies:
9673
9673
  typescript: 5.9.3
9674
9674
 
9675
- coze-coding-dev-sdk@0.7.25(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0):
9675
+ coze-coding-dev-sdk@0.7.28(openai@6.16.0(ws@8.19.0)(zod@4.3.6))(ws@8.19.0):
9676
9676
  dependencies:
9677
9677
  '@langchain/core': 1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6))
9678
9678
  '@langchain/openai': 1.2.3(@langchain/core@1.1.17(openai@6.16.0(ws@8.19.0)(zod@4.3.6)))(ws@8.19.0)
@@ -10116,9 +10116,9 @@ snapshots:
10116
10116
 
10117
10117
  escape-string-regexp@4.0.0: {}
10118
10118
 
10119
- eslint-config-next@16.3.3(@typescript-eslint/parser@8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3):
10119
+ eslint-config-next@16.1.1(@typescript-eslint/parser@8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3):
10120
10120
  dependencies:
10121
- '@next/eslint-plugin-next': 16.3.3(eslint@9.39.2(jiti@2.6.1))
10121
+ '@next/eslint-plugin-next': 16.1.1
10122
10122
  eslint: 9.39.2(jiti@2.6.1)
10123
10123
  eslint-import-resolver-node: 0.3.9
10124
10124
  eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0)(eslint@9.39.2(jiti@2.6.1))
@@ -8,7 +8,7 @@ Write-Host "Installing dependencies..."
8
8
  if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
9
9
 
10
10
  Write-Host "Building the Next.js project..."
11
- & pnpm next build
11
+ & pnpm next build --webpack
12
12
  if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
13
13
 
14
14
  Write-Host "Bundling server with tsup..."
@@ -6,10 +6,10 @@ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
6
6
  cd "${COZE_WORKSPACE_PATH}"
7
7
 
8
8
  echo "Installing dependencies..."
9
- pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
9
+ bash "$COZE_WORKSPACE_PATH/scripts/prepare-node-modules.sh" --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
10
10
 
11
11
  echo "Building the Next.js project..."
12
- pnpm next build
12
+ pnpm next build --webpack
13
13
 
14
14
  echo "Bundling server with tsup..."
15
15
  pnpm tsup src/server.ts --format cjs --platform node --target node20 --outDir dist --no-splitting --no-minify
@@ -77,6 +77,7 @@ shift
77
77
  child_pid=$!
78
78
 
79
79
  # 先忽略 TERM,才能在向整组发 TERM(自己也在组里)之后存活下来补一发 KILL。
80
+ if [[ -z "${COZE_EVAL:-}" && -z "${COZE_PROJECT_TYPE:-}" ]]; then
80
81
  ( trap "" TERM
81
82
  sleep "${timeout_seconds}"
82
83
  echo "[dev] 后台进程运行超过 ${timeout_seconds}s,回收进程组 $$。"
@@ -84,6 +85,7 @@ child_pid=$!
84
85
  sleep 5
85
86
  kill -KILL -- "-$$" 2>/dev/null || true
86
87
  ) &
88
+ fi
87
89
 
88
90
  wait "${child_pid}"
89
91
  kill -KILL -- "-$$" 2>/dev/null || true
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env bash
2
+ # Install dependencies on local disk and expose them to the source tree by symlink.
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
6
+ if [ "$(basename "$(dirname "$SCRIPT_DIR")")" = ".cozeproj" ]; then
7
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
8
+ else
9
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
10
+ fi
11
+
12
+ command -v pnpm >/dev/null 2>&1 || {
13
+ echo "[node_modules] pnpm is required" >&2
14
+ exit 1
15
+ }
16
+
17
+ DRIVE_ROOT="${COZE_DRIVE_ROOT:-/Coze/Drive}"
18
+ if [ -d "$DRIVE_ROOT" ]; then
19
+ DRIVE_ROOT="$(cd "$DRIVE_ROOT" && pwd -P)"
20
+ else
21
+ DRIVE_ROOT="${DRIVE_ROOT%/}"
22
+ fi
23
+ case "$PROJECT_ROOT" in
24
+ "$DRIVE_ROOT"|"$DRIVE_ROOT"/*) ;;
25
+ *)
26
+ (cd "$PROJECT_ROOT" && pnpm install "$@")
27
+ exit 0
28
+ ;;
29
+ esac
30
+
31
+ NM_ROOT="/tmp/nm"
32
+ PROJECT_ID="$(basename "$PROJECT_ROOT")-$(printf '%s' "$PROJECT_ROOT" | cksum | awk '{print $1}')"
33
+ mkdir -p "$NM_ROOT"
34
+ WORK_DIR="$NM_ROOT/$PROJECT_ID"
35
+ case "$WORK_DIR" in
36
+ "$DRIVE_ROOT"|"$DRIVE_ROOT"/*)
37
+ echo "[node_modules] local dependency directory must not be on Coze Drive: $WORK_DIR" >&2
38
+ exit 1
39
+ ;;
40
+ esac
41
+
42
+ LOCK_DIR="$NM_ROOT/$PROJECT_ID.lock"
43
+ while ! mkdir "$LOCK_DIR" 2>/dev/null; do
44
+ echo "[node_modules] Waiting for another dependency preparation for this project..."
45
+ sleep 1
46
+ done
47
+ trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
48
+
49
+ mkdir -p "$WORK_DIR"
50
+
51
+ # Mirror the project with symlinks. node_modules stays real in WORK_DIR;
52
+ # workspace directories stay real too, so pnpm never writes them to Drive.
53
+ mirror_root() {
54
+ local entry name
55
+ while IFS= read -r -d '' entry; do
56
+ name="$(basename "$entry")"
57
+ case "$name" in
58
+ node_modules|pnpm-lock.yaml) continue ;;
59
+ client|server)
60
+ [ -f "$PROJECT_ROOT/$name/package.json" ] && continue
61
+ ;;
62
+ esac
63
+ rm -rf "$entry"
64
+ done < <(find "$WORK_DIR" -mindepth 1 -maxdepth 1 -print0)
65
+
66
+ while IFS= read -r -d '' entry; do
67
+ name="$(basename "$entry")"
68
+ case "$name" in
69
+ node_modules|pnpm-lock.yaml) continue ;;
70
+ client|server)
71
+ [ -f "$entry/package.json" ] && continue
72
+ ;;
73
+ esac
74
+ ln -s "$entry" "$WORK_DIR/$name"
75
+ done < <(find "$PROJECT_ROOT" -mindepth 1 -maxdepth 1 -print0)
76
+ }
77
+
78
+ mirror_workspace() {
79
+ local workspace="$1" source_dir="$PROJECT_ROOT/$1" work_dir="$WORK_DIR/$1"
80
+ local entry name
81
+ if [ -L "$work_dir" ] || { [ -e "$work_dir" ] && [ ! -d "$work_dir" ]; }; then
82
+ rm -rf "$work_dir"
83
+ fi
84
+ mkdir -p "$work_dir"
85
+
86
+ while IFS= read -r -d '' entry; do
87
+ [ "$(basename "$entry")" = "node_modules" ] || rm -rf "$entry"
88
+ done < <(find "$work_dir" -mindepth 1 -maxdepth 1 -print0)
89
+
90
+ while IFS= read -r -d '' entry; do
91
+ name="$(basename "$entry")"
92
+ [ "$name" = "node_modules" ] || ln -s "$entry" "$work_dir/$name"
93
+ done < <(find "$source_dir" -mindepth 1 -maxdepth 1 -print0)
94
+ }
95
+
96
+ mirror_root
97
+ for workspace in client server; do
98
+ if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
99
+ mirror_workspace "$workspace"
100
+ fi
101
+ done
102
+
103
+ # pnpm refuses to update a symlinked lockfile, so install against a local copy.
104
+ rm -rf "$WORK_DIR/pnpm-lock.yaml"
105
+ if [ -f "$PROJECT_ROOT/pnpm-lock.yaml" ]; then
106
+ cp "$PROJECT_ROOT/pnpm-lock.yaml" "$WORK_DIR/pnpm-lock.yaml"
107
+ fi
108
+
109
+ echo "[node_modules] Installing dependencies in $WORK_DIR"
110
+ if ! (cd "$WORK_DIR" && pnpm install "$@"); then
111
+ rm -f "$WORK_DIR/pnpm-lock.yaml"
112
+ exit 1
113
+ fi
114
+
115
+ if [ -f "$WORK_DIR/pnpm-lock.yaml" ]; then
116
+ temporary_lockfile="$(mktemp "$PROJECT_ROOT/.pnpm-lock.yaml.XXXXXX")"
117
+ cp "$WORK_DIR/pnpm-lock.yaml" "$temporary_lockfile"
118
+ chmod 0644 "$temporary_lockfile"
119
+ mv -f "$temporary_lockfile" "$PROJECT_ROOT/pnpm-lock.yaml"
120
+ fi
121
+
122
+ link_node_modules() {
123
+ local source_dir="$1" target_dir="$2"
124
+ local current=""
125
+ mkdir -p "$target_dir"
126
+ if [ -L "$source_dir/node_modules" ]; then
127
+ current="$(readlink "$source_dir/node_modules")"
128
+ case "$current" in
129
+ "$NM_ROOT"/*/node_modules|"$NM_ROOT"/*/*/node_modules) ;;
130
+ *)
131
+ echo "[node_modules] refusing to replace unmanaged symlink: $source_dir/node_modules" >&2
132
+ exit 1
133
+ ;;
134
+ esac
135
+ rm "$source_dir/node_modules"
136
+ elif [ -e "$source_dir/node_modules" ]; then
137
+ rm -rf "$source_dir/node_modules"
138
+ fi
139
+ ln -s "$target_dir" "$source_dir/node_modules"
140
+ }
141
+
142
+ link_node_modules "$PROJECT_ROOT" "$WORK_DIR/node_modules"
143
+ for workspace in client server; do
144
+ if [ -f "$PROJECT_ROOT/$workspace/package.json" ]; then
145
+ link_node_modules "$PROJECT_ROOT/$workspace" "$WORK_DIR/$workspace/node_modules"
146
+ fi
147
+ done
148
+
149
+ echo "[node_modules] Dependencies ready"
@@ -6,7 +6,4 @@ COZE_WORKSPACE_PATH="${COZE_WORKSPACE_PATH:-$(pwd)}"
6
6
  cd "${COZE_WORKSPACE_PATH}"
7
7
 
8
8
  echo "Installing dependencies..."
9
- pnpm install --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
10
- if command -v coze-dev > /dev/null 2>&1 && coze-dev check-bins --help > /dev/null 2>&1; then
11
- coze-dev check-bins --fix
12
- fi
9
+ bash "$COZE_WORKSPACE_PATH/scripts/prepare-node-modules.sh" --prefer-frozen-lockfile --prefer-offline --loglevel debug --reporter=append-only
@@ -7,7 +7,7 @@ const hostname = process.env.HOSTNAME || 'localhost';
7
7
  const port = parseInt(process.env.PORT || '<%= port %>', 10);
8
8
 
9
9
  // Create Next.js app
10
- const app = next({ dev, hostname, port });
10
+ const app = next({ dev, hostname, port, webpack: true });
11
11
  const handle = app.getRequestHandler();
12
12
 
13
13
  app.prepare().then(() => {