@collectui/cli 0.2.40 → 0.2.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@collectui/cli",
3
- "version": "0.2.40",
3
+ "version": "0.2.41",
4
4
  "description": "One CLI for every shadcn library on CollectUI Dash — login once, configure registries & MCP, scaffold agent-ready projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -220,12 +220,15 @@ export function resolveClients(flags, pinnedAgents = []) {
220
220
  /** MCP 写入作用域(--scope > 交互选择,默认 global——2026-12-07 用户定案:
221
221
  * claude=~/.claude.json / cursor=~/.cursor/mcp.json / vscode=User/mcp.json /
222
222
  * codex 恒全局;project = 各自项目内文件)。返回 "global" | "project"。 */
223
- export async function chooseScope(flags, reporter, { interactive = true } = {}) {
223
+ export async function chooseScope(flags, reporter, { interactive = true, me } = {}) {
224
224
  const raw = String(flags.scope ?? "").toLowerCase();
225
225
  if (raw === "global" || raw === "project") return raw;
226
226
  if (raw) {
227
227
  throw usageError(`--scope must be global or project (got: ${flags.scope})`);
228
228
  }
229
+ // 账户偏好 cli-scope(dash「CLI 偏好」/ cui prefs set scope):设置过
230
+ // 就直接用不再问(2026-12-07 用户定案:scope 也是偏好)
231
+ if (me?.cliScope === "global" || me?.cliScope === "project") return me.cliScope;
229
232
  // 无头(headless/--yes)保守回 project:不碰用户 home(CI/测试/Agent 的
230
233
  // 意外副作用);交互场景默认问、选中 global——2026-12-07 用户定案
231
234
  if (!interactive || reporter.headless || reporter.yes) return "project";
@@ -33,7 +33,7 @@ async function mcpConfigCommand(sub, flags, rest, reporter) {
33
33
  reporter.addSecrets((me.keys ?? []).map((k) => k.key).filter(Boolean));
34
34
  const { units } = await selectLibs({ flags, me, reporter });
35
35
  // show 是只读命令:不弹多选,按默认集打印(init/configure 才交互挑 Agent)
36
- const scope = await chooseScope(flags, reporter, { interactive: sub !== "show" });
36
+ const scope = await chooseScope(flags, reporter, { interactive: sub !== "show", me });
37
37
  const clients = await chooseClients(flags, me, reporter, {
38
38
  interactive: sub !== "show",
39
39
  scope,
@@ -24,6 +24,7 @@ const KEY_MAP = {
24
24
  "pinned-agents": "copy-agent-pinned",
25
25
  libs: "cli-default-libs",
26
26
  "dash-mcp": "cli-dash-mcp",
27
+ scope: "cli-scope",
27
28
  };
28
29
 
29
30
  const PM_VALUES = [...VALID_PM];
@@ -46,6 +47,7 @@ export async function prefsCmd(flags, rest, reporter) {
46
47
  ? me.cliDefaultLibs.join(",")
47
48
  : "(unset — defaults to all owned)",
48
49
  "dash-mcp": me?.cliDashMcp === false ? "off" : "on (default)",
50
+ scope: me?.cliScope ?? "(unset — asks interactively, default global)",
49
51
  };
50
52
  if (sub === "get") {
51
53
  const key = rest[1];
@@ -89,6 +91,13 @@ export async function prefsCmd(flags, rest, reporter) {
89
91
  const v = String(value).toLowerCase();
90
92
  value = ["off", "0", "false", "no"].includes(v) ? "0" : "1";
91
93
  }
94
+ if (key === "scope") {
95
+ const v = String(value).toLowerCase();
96
+ if (v !== "global" && v !== "project") {
97
+ throw usageError(`scope must be global or project (got: ${value})`);
98
+ }
99
+ value = v;
100
+ }
92
101
  const token = requireToken(flags, reporter);
93
102
  await jsonRequest(`${dashUrl()}/api/account/prefs`, {
94
103
  method: "POST",
@@ -122,6 +131,7 @@ Account-wide preferences (stored in Dash, shared across machines):
122
131
  pinned-agents Default MCP agent set (empty = claude,cursor,vscode)
123
132
  libs Default library set (comma slugs; empty = all owned)
124
133
  dash-mcp Include the collectui MCP server: on | off (default on)
134
+ scope MCP config location: global | project (unset = ask, default global)
125
135
 
126
136
  Examples:
127
137
  cui prefs ls
@@ -182,7 +182,7 @@ export async function runSetup({ flags, rest = [], reporter, mode }) {
182
182
  !officialScaffold && // 官方 init 自带依赖安装
183
183
  flags.install !== false &&
184
184
  !flags["no-install"];
185
- const scope = await chooseScope(flags, reporter);
185
+ const scope = await chooseScope(flags, reporter, { me });
186
186
  const clients = await chooseClients(flags, me, reporter, { scope });
187
187
  const projectName = flags.name ? String(flags.name) : basename(target) || "collectui-app";
188
188