@lark-apaas/miaoda-cli 0.1.9 → 0.1.10

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.
@@ -64,6 +64,12 @@ async function handleAppInit(opts) {
64
64
  const upgradedPackages = (0, sync_1.upgradePlatformDeps)(targetDir, 'init');
65
65
  // skills 同步软失败:拉不到 coding-steering 包不该阻断 writeSparkMeta /
66
66
  // activateGitHooks(之前会让 .spark/meta.json 没写,下次 init 半渲染状态又得重跑全套)。
67
+ // 按 stack 分流 outputLayout:
68
+ // - nestjs-react-fullstack:本地主战场,用 flat 布局
69
+ // (.agents/skills + .claude/skills 软链),不再创建 .agent/ 老目录
70
+ // - 其他 stack:仍走默认 nested (.agent/skills/steering/<stack>/skills/),
71
+ // 跟沙箱端 update-skills.sh 老链路对齐,避免破坏
72
+ const outputLayout = stack === 'nestjs-react-fullstack' ? 'flat' : 'nested';
67
73
  let steeringResult;
68
74
  let steeringError;
69
75
  try {
@@ -72,6 +78,7 @@ async function handleAppInit(opts) {
72
78
  targetDir,
73
79
  version: opts.conf?.steeringVersion,
74
80
  logPrefix: 'init',
81
+ outputLayout,
75
82
  });
76
83
  }
77
84
  catch (err) {
@@ -7,6 +7,7 @@ exports.handleAppUpgrade = void 0;
7
7
  exports.handleAppSync = handleAppSync;
8
8
  exports.runStackSync = runStackSync;
9
9
  exports.summarizeSyncResults = summarizeSyncResults;
10
+ exports.listManagedDeps = listManagedDeps;
10
11
  exports.upgradePlatformDeps = upgradePlatformDeps;
11
12
  const node_child_process_1 = require("node:child_process");
12
13
  const node_fs_1 = __importDefault(require("node:fs"));
@@ -82,15 +83,17 @@ async function handleAppSync(opts) {
82
83
  const upgradedPackages = upgradePlatformDeps(targetDir, 'sync');
83
84
  // 3. activate git hooks(template 自带 .githooks/pre-commit,core.hooksPath 一次性设置)
84
85
  const hookActivation = (0, githooks_1.activateGitHooks)(targetDir);
85
- // 4. npm install —— 跟 init 一样软失败,install 挂了不该阻断 emit / sync 总结输出。
86
- // 把本次实际有 from→to 变化的管控包**显式**作为位置参数传给 npm install,强制 npm 重新
87
- // resolve lockfile entry。原因:user app 老 lockfile 可能锁着 alpha 版本,纯 `npm install`
88
- // lockfile 锁定值跟 package.json spec ("latest" range) 兼容会保留 alpha,导致 sync 后
89
- // package.json 写了 latest 但实际还是装 alpha。显式 `npm install foo@latest bar@latest`
90
- // 会重新解析这些包,lockfile 跟着更新。没变化的包不动,避免 noisy lockfile diff。
86
+ // 4. npm install —— 跟 init 一样软失败,install 挂了不该阻断 emit / sync 总结输出。
87
+ // user app 装着的**所有**管控包显式作为位置参数传给 npm install,强制 npm 重新
88
+ // resolve lockfile entry。原因:
89
+ // - 即便 package.json spec 已经是 "latest"(没有 from→to 变化),user app lockfile
90
+ // 可能锁着具体老版本 (如 fullstack-vite-preset@1.0.9),纯 `npm install` 会按 lockfile
91
+ // 拉老版,绕过 spec "latest" 的解析意图
92
+ // - 显式 `npm install foo@latest bar@latest` 让 npm 重新解析,lockfile 跟着更新到当前 latest
93
+ // - 没装的管控包不动 (sync 的职责是对齐,不是塞依赖)
91
94
  // --ignore-scripts 绕开 action-plugin postinstall 在缺平台 env 时的 ENOENT。
92
- // --registry 跟 init 钉同一份 npmmirror,避免 user 全局 ~/.npmrc 把 sync 拉到 ~~一个~~
93
- // 另一个源(详见 services/app/init/install.ts 上的注释)。MIAODA_NPM_REGISTRY env 兜底。
95
+ // --registry 跟 init 钉同一份 npmmirror,避免 user 全局 ~/.npmrc 把 sync 拉到另一个源
96
+ // (详见 services/app/init/install.ts 上的注释)。MIAODA_NPM_REGISTRY env 兜底。
94
97
  const installArgs = [
95
98
  'install',
96
99
  '--no-audit',
@@ -99,8 +102,8 @@ async function handleAppSync(opts) {
99
102
  '--registry',
100
103
  (0, install_1.resolveNpmInstallRegistry)(),
101
104
  ];
102
- for (const bump of upgradedPackages) {
103
- installArgs.push(`${bump.name}@${bump.to}`);
105
+ for (const name of listManagedDeps(targetDir)) {
106
+ installArgs.push(`${name}@${MANAGED_PLATFORM_PACKAGES[name]}`);
104
107
  }
105
108
  (0, logger_1.log)('sync', `Running npm ${installArgs.join(' ')}...`);
106
109
  let installError;
@@ -200,6 +203,29 @@ function readPackageJson(pkgJsonPath) {
200
203
  return null;
201
204
  return JSON.parse(node_fs_1.default.readFileSync(pkgJsonPath, 'utf-8'));
202
205
  }
206
+ /**
207
+ * 列出 user app 装着的 @lark-apaas/* 管控包 (在 MANAGED_PLATFORM_PACKAGES 白名单内的)。
208
+ * sync handler 用来给 `npm install` 显式列管控包名 + @latest,强制 npm 重新 resolve
209
+ * lockfile entry —— 即便 package.json spec 已经是 "latest" 没 from→to 变化,
210
+ * 老 lockfile 锁的具体老版本(如 fullstack-vite-preset@1.0.9)也会被刷掉。
211
+ */
212
+ function listManagedDeps(targetDir) {
213
+ const pkg = readPackageJson(node_path_1.default.join(targetDir, 'package.json'));
214
+ if (!pkg)
215
+ return [];
216
+ const names = new Set();
217
+ for (const section of ['dependencies', 'devDependencies']) {
218
+ const deps = pkg[section];
219
+ if (!deps || typeof deps !== 'object')
220
+ continue;
221
+ for (const name of Object.keys(deps)) {
222
+ if (Object.prototype.hasOwnProperty.call(MANAGED_PLATFORM_PACKAGES, name)) {
223
+ names.add(name);
224
+ }
225
+ }
226
+ }
227
+ return [...names];
228
+ }
203
229
  /**
204
230
  * 把 user app package.json 里已装的 @lark-apaas/* 平台包改写成 MANAGED_PLATFORM_PACKAGES
205
231
  * 表里的目标 spec(缺省 `"latest"`)。由 `miaoda app sync` 和 `miaoda app init`(template
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-cli",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Miaoda 平台命令行工具,面向 Agent 调用",
5
5
  "type": "commonjs",
6
6
  "bin": {