teamix-evo 0.3.0 → 0.4.0

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
@@ -18,14 +18,13 @@ packages/cli/
18
18
  ├── src/
19
19
  │ ├── index.ts # 入口:Commander 注册
20
20
  │ ├── commands/
21
- │ │ ├── design/ # design init <variant> / list / list-variants
21
+ │ │ ├── tokens/ # tokens init <variant> / list / list-variants
22
22
  │ │ │ │ # / update(stub) / uninstall
23
23
  │ │ ├── skills/ # source-mirror 模型见 ADR 0013
24
24
  │ │ │ │ # add / list / update / sync / doctor / uninstall
25
25
  │ │ └── ui/ # init / add / list
26
26
  │ ├── core/ # 业务编排层(programmatic API,subpath 导出)
27
- │ │ ├── design-init.ts # walk-and-merge 装机
28
- │ │ ├── design-pack-classify.ts # 路径分类(W1.4 tokens 提层)
27
+ │ │ ├── tokens-init.ts # 变体自包含装机(ADR 0020)
29
28
  │ │ ├── installer.ts # UI 资源安装引擎
30
29
  │ │ ├── updater.ts # 三策略更新引擎(frozen/regenerable/managed)
31
30
  │ │ ├── ui-{add,init,list,client,installer}.ts
@@ -131,8 +130,8 @@ pnpm --filter teamix-evo test:watch
131
130
 
132
131
  测试文件位于 `src/__tests__/`,覆盖:
133
132
 
134
- - `core-api.test.ts` — programmatic core API(runDesignInit / runSkillsAdd / runUiAdd)
135
- - `design-init-skills-link.test.ts` — design init ↔ skills auto-install 联动
133
+ - `core-api.test.ts` — programmatic core API(runTokensInit / runSkillsAdd / runUiAdd)
134
+ - `tokens-init-skills-link.test.ts` — tokens init ↔ skills auto-install 联动
136
135
  - `installer.test.ts` — UI 资源安装(frozen / regenerable)
137
136
  - `ui-installer.test.ts` — UI 装机引擎(依赖图 / alias 转换)
138
137
  - `skills-installer.test.ts` — skills 装机(source-mirror)
@@ -153,28 +152,28 @@ pnpm --filter teamix-evo build
153
152
 
154
153
  ```bash
155
154
  # 构建后在任意目录执行
156
- node /path/to/packages/cli/dist/index.js design init opentrek
155
+ node /path/to/packages/cli/dist/index.js tokens init opentrek
157
156
 
158
157
  # 或通过 pnpm 链接
159
158
  cd packages/cli && pnpm link --global
160
- teamix-evo design init opentrek
159
+ teamix-evo tokens init opentrek
161
160
  ```
162
161
 
163
162
  开启调试日志:
164
163
 
165
164
  ```bash
166
- TEAMIX_DEBUG=1 teamix-evo design init opentrek
165
+ TEAMIX_DEBUG=1 teamix-evo tokens init opentrek
167
166
  ```
168
167
 
169
168
  ## 命令参考
170
169
 
171
170
  | 命令 | 说明 |
172
171
  | --------------------------------------------------- | ------------------------------------------------- |
173
- | `teamix-evo design init <variant>` | 初始化设计体系(variant 必填) |
174
- | `teamix-evo design list-variants` | 列出可用 variant |
175
- | `teamix-evo design list` | 查看已装机的 variant |
176
- | `teamix-evo design update` | 更新已装资源(stub,v0.7 见 ADR 0019) |
177
- | `teamix-evo design uninstall` | 卸载已装 design |
172
+ | `teamix-evo tokens init <variant>` | 初始化 tokens |
173
+ | `teamix-evo tokens list-variants` | 列出可用 variant |
174
+ | `teamix-evo tokens list` | 查看已装机的 variant |
175
+ | `teamix-evo tokens update` | 更新已装资源(stub,v0.7 见 ADR 0019) |
176
+ | `teamix-evo tokens uninstall` | 卸载已装 tokens |
178
177
  | `teamix-evo skills add [name...]` | 装 skills(写源 + 镜像 IDE);不传 = 全装 |
179
178
  | `teamix-evo skills list` | 列出所有 skill 的安装状态 |
180
179
  | `teamix-evo skills update` | 升级 skills(保留 managed 改动) |
@@ -188,10 +187,11 @@ TEAMIX_DEBUG=1 teamix-evo design init opentrek
188
187
  | `teamix-evo biz-ui add <id...> --variant <name>` | 安装变体感知业务组件(`--variant` 必填) |
189
188
  | `teamix-evo templates list-variants` | 列出 templates 包内提供的页面模板变体 |
190
189
  | `teamix-evo templates add <id...> --variant <name>` | 安装变体感知页面模板(`--variant` 必填) |
190
+ | `teamix-evo logs analyze [...]` | 分析 vibe-logger AI 调用链(`.log/ai/**/*.jsonl`) |
191
191
 
192
192
  > 占位组件 → 真组件的升级流程**不是** CLI 子命令,由
193
- > [`teamix-evo-ui-upgrade`](../../packages/skills/skills/teamix-evo-ui-upgrade/SKILL.md)
194
- > skill 在 IDE 内驱动,底层仍调用 `teamix-evo ui add`。
193
+ > [`teamix-evo-manage`](../../packages/skills/src/teamix-evo-manage/SKILL.md)
194
+ > skill 在 IDE 内驱动「场景 6」,底层仍调用 `teamix-evo ui add`。
195
195
 
196
196
  ### 全局装 skill(`--scope global`)
197
197
 
@@ -216,7 +216,7 @@ cd ~/.teamix-evo-global && npx teamix-evo skills update
216
216
 
217
217
  ```
218
218
  本包 → @teamix-evo/registry(协议层)
219
- 本包 → @teamix-evo/design(设计资源,运行时解析)
219
+ 本包 → @teamix-evo/tokens(设计 tokens,运行时解析)
220
220
  本包 → @teamix-evo/skills(技能资源,运行时解析)
221
221
  本包 → @teamix-evo/ui(UI 资源,manifest + 源码)
222
222
  ```
@@ -1,17 +1,17 @@
1
1
  import { InstalledResource, SkillIde, SkillScope, UiAliases, UiEntry, VariantManifest, SkillsPackageManifest, SkillEntry, UiPackageManifest, InstalledManifest, ProjectConfig } from '@teamix-evo/registry';
2
2
  export { InstalledManifest, InstalledResource, ProjectConfig, SkillIde, SkillScope, TailwindVersion, UiAliases } from '@teamix-evo/registry';
3
3
 
4
- interface RunDesignInitOptions {
4
+ interface RunTokensInitOptions {
5
5
  /** Absolute project root directory. */
6
6
  projectRoot: string;
7
- /** Design variant id (e.g. `"opentrek"`, `"uni-manager"`). */
7
+ /** Tokens variant id (e.g. `"opentrek"`, `"uni-manager"`). */
8
8
  variant: string;
9
9
  /** IDE identifier written into config.json (e.g. `"qoder"`, `"claude"`). */
10
10
  ide: string;
11
- /** Override the design package name (defaults to `"@teamix-evo/design"`). */
11
+ /** Override the tokens package name (defaults to `"@teamix-evo/tokens"`). */
12
12
  packageName?: string;
13
13
  /**
14
- * Override resolution of the design package root. When provided, skips
14
+ * Override resolution of the tokens package root. When provided, skips
15
15
  * `require.resolve("<packageName>/package.json")`. Useful for tests that
16
16
  * want to point at a fixture tree, and for embedding inside `create`
17
17
  * where the package may not yet be installed in the consumer.
@@ -19,10 +19,11 @@ interface RunDesignInitOptions {
19
19
  packageRoot?: string;
20
20
  }
21
21
  /**
22
- * Outcome of the post-init skill auto-install step. `attempted` lists the skill
23
- * ids we tried to install (baseline + variant overlay); `addedSkillIds` is what
24
- * was actually installed (the rest were already present); `missing` lists skill
25
- * ids that aren't in the manifest (warned, not fatal).
22
+ * Outcome of the post-init skill auto-install step. `attempted` is the variant
23
+ * skill id we tried to install; `addedSkillIds` is what was actually installed
24
+ * (empty if the skill was already present); `missing` lists ids that aren't in
25
+ * the manifest (warned, not fatal). Per ADR / "skills self-contained" decision,
26
+ * each variant skill is fully self-contained — no separate baseline skill.
26
27
  */
27
28
  interface SkillsAutoInstallResult {
28
29
  attempted: string[];
@@ -30,37 +31,54 @@ interface SkillsAutoInstallResult {
30
31
  skippedSkillIds: string[];
31
32
  missing: string[];
32
33
  }
33
- type RunDesignInitResult = {
34
+ type RunTokensInitResult = {
34
35
  status: 'installed';
35
36
  packageName: string;
36
37
  variant: string;
37
38
  version: string;
38
39
  count: number;
39
40
  resources: InstalledResource[];
40
- /** Per ADR 0010 §4 diagnostics. */
41
- merge: {
42
- overrides: string[];
43
- variantAdds: string[];
44
- defaultPassThrough: string[];
45
- };
46
- /** Result of the auto-install of baseline + variant design-rules skills. */
41
+ /** Result of the auto-install of the matching design skill. */
47
42
  skills?: SkillsAutoInstallResult;
48
43
  } | {
49
44
  status: 'already-initialized';
50
45
  existingVariant: string;
46
+ } | {
47
+ status: 'variant-mismatch';
48
+ existingVariant: string;
49
+ requestedVariant: string;
51
50
  };
52
51
  /**
53
- * Programmatic equivalent of `teamix-evo design init <variant>`.
52
+ * Programmatic equivalent of `teamix-evo tokens init <variant>`.
54
53
  *
55
54
  * Side effects:
56
55
  * - Creates `<projectRoot>/.teamix-evo/`
57
- * - Walks `default/` + `variants/<variant>/`, classifies each file by path
58
- * convention, writes to consumer (skipping `frozen` files that already exist)
59
- * - Writes `pack.lock.json`, `config.json`, `manifest.json` (installed)
56
+ * - Copies the variant's `theme.css` to `<projectRoot>/tokens/tokens.theme.css`
57
+ * - Ensures `<projectRoot>/tokens/tokens.overrides.css` exists (frozen)
58
+ * - Writes `tokens-lock.json`, `config.json`, `manifest.json` (installed)
60
59
  *
61
60
  * No interactive prompts, no `process.exit`. Throws on hard failure (P8).
62
61
  */
63
- declare function runDesignInit(options: RunDesignInitOptions): Promise<RunDesignInitResult>;
62
+ declare function runTokensInit(options: RunTokensInitOptions): Promise<RunTokensInitResult>;
63
+ /**
64
+ * List all variants advertised by the top-level tokens catalog. Used by
65
+ * `teamix-evo tokens list-variants`.
66
+ */
67
+ interface ListVariantsResult {
68
+ packageName: string;
69
+ packageVersion: string;
70
+ variants: Array<{
71
+ name: string;
72
+ displayName: string;
73
+ version: string;
74
+ description?: string;
75
+ linked?: {
76
+ 'biz-ui'?: string;
77
+ templates?: string;
78
+ };
79
+ }>;
80
+ }
81
+ declare function listTokenVariants(packageName?: string, packageRoot?: string): Promise<ListVariantsResult>;
64
82
 
65
83
  interface RunSkillsAddOptions {
66
84
  /** Absolute project root directory. */
@@ -141,6 +159,7 @@ type RunUiInitResult = {
141
159
  iconLibrary: string;
142
160
  tsx: boolean;
143
161
  rsc: boolean;
162
+ preferencesCss: 'deployed' | 'skipped' | 'source-missing';
144
163
  } | {
145
164
  status: 'already-initialized';
146
165
  };
@@ -170,8 +189,6 @@ interface RunUiAddResult {
170
189
  written: number;
171
190
  /** Number of files skipped due to frozen + exists. */
172
191
  skipped: number;
173
- /** Meta files dropped under .teamix-evo/design/components/. */
174
- metaFiles: string[];
175
192
  /** Aggregate npm dependencies of the installed entries. */
176
193
  npmDependencies: Record<string, string>;
177
194
  /** Per-file install records merged into the installed manifest. */
@@ -319,6 +336,8 @@ interface SkillSyncOptions {
319
336
  id: string;
320
337
  name: string;
321
338
  updateStrategy: SkillEntry['updateStrategy'];
339
+ /** Managed-region ids for region-aware mirror sync. */
340
+ managedRegions?: readonly string[];
322
341
  }>;
323
342
  ides: readonly SkillIde[];
324
343
  scope: SkillScope;
@@ -335,6 +354,8 @@ interface SkillSyncResult {
335
354
  declare function syncSkillsToIdes(options: SkillSyncOptions): Promise<SkillSyncResult>;
336
355
  /**
337
356
  * Remove all installed skill files. Returns the absolute paths removed.
357
+ * After files are unlinked, walks up the directory tree pruning empty dirs
358
+ * until a non-empty ancestor is reached (#33).
338
359
  */
339
360
  declare function removeSkillFiles(records: InstalledResource[]): Promise<string[]>;
340
361
 
@@ -345,6 +366,13 @@ interface UiInstallOptions {
345
366
  manifest: UiPackageManifest;
346
367
  /** Absolute ui package root (used to resolve entry source paths) */
347
368
  packageRoot: string;
369
+ /**
370
+ * Optional per-entry package root override. When set, entries in the map
371
+ * resolve their `file.source` against the mapped root instead of `packageRoot`.
372
+ * Used by variant-aware packages (biz-ui / templates) that pull in
373
+ * @teamix-evo/ui transitive deps — each entry resolves from its source package.
374
+ */
375
+ entryPackageRoot?: Map<string, string>;
348
376
  /** Aliases configured in `packages.ui.aliases` */
349
377
  aliases: UiAliases;
350
378
  /** Entry ids the user explicitly requested to add */
@@ -363,8 +391,6 @@ interface UiInstallResult {
363
391
  written: number;
364
392
  /** Number of files skipped because they already exist (frozen) */
365
393
  skipped: number;
366
- /** Meta files dropped under .teamix-evo/design/components/ */
367
- metaFiles: string[];
368
394
  }
369
395
  /**
370
396
  * Install the requested ui entries (transitively resolving registryDependencies).
@@ -379,7 +405,7 @@ declare function removeUiFiles(records: InstalledResource[]): Promise<string[]>;
379
405
  /**
380
406
  * Load the variant manifest and _data.json for template rendering.
381
407
  *
382
- * @param packageName - e.g. "@teamix-evo/design"
408
+ * @param packageName - e.g. "@teamix-evo/tokens"
383
409
  * @param variant - e.g. "opentrek"
384
410
  * @returns manifest and data for template rendering
385
411
  */
@@ -422,7 +448,8 @@ declare function getTeamixDir(projectRoot: string): string;
422
448
  declare function ensureTeamixDir(projectRoot: string): Promise<string>;
423
449
  /**
424
450
  * Read the project config from .teamix-evo/config.json.
425
- * Returns null if the file does not exist.
451
+ * Returns null if the file does not exist; THROWS on corrupted content
452
+ * so callers don't silently clobber prior config (#32 #18).
426
453
  */
427
454
  declare function readProjectConfig(projectRoot: string): Promise<ProjectConfig | null>;
428
455
  /**
@@ -431,7 +458,10 @@ declare function readProjectConfig(projectRoot: string): Promise<ProjectConfig |
431
458
  declare function writeProjectConfig(projectRoot: string, config: ProjectConfig): Promise<void>;
432
459
  /**
433
460
  * Read the installed manifest from .teamix-evo/manifest.json.
434
- * Returns null if the file does not exist.
461
+ * Returns null if the file does not exist; THROWS on corrupted content so
462
+ * callers don't silently lose prior installs by treating broken JSON as
463
+ * "fresh install" (#32 #18). Use `readInstalledManifestOrNull` for the
464
+ * old lenient behavior.
435
465
  */
436
466
  declare function readInstalledManifest(projectRoot: string): Promise<InstalledManifest | null>;
437
467
  /**
@@ -439,4 +469,4 @@ declare function readInstalledManifest(projectRoot: string): Promise<InstalledMa
439
469
  */
440
470
  declare function writeInstalledManifest(projectRoot: string, manifest: InstalledManifest): Promise<void>;
441
471
 
442
- export { DEFAULT_UI_ALIASES, DEFAULT_UI_ICON_LIBRARY, type InstallOptions, type InstallResult, type RunDesignInitOptions, type RunDesignInitResult, type RunSkillsAddOptions, type RunSkillsAddResult, type RunUiAddOptions, type RunUiAddResult, type RunUiInitOptions, type RunUiInitResult, type RunUiListOptions, type RunUiListResult, type SkillInstallOptions, type SkillInstallResult, type SkillSyncOptions, type SkillSyncResult, type SkillUpdateOptions, type SkillUpdateResult, type UiEntryListItem, type UiInstallOptions, type UiInstallResult, ensureTeamixDir, getTeamixDir, installResources, installSkills, installUiEntries, loadSkillsData, loadUiData, loadVariantData, readInstalledManifest, readProjectConfig, removeSkillFiles, removeUiFiles, runDesignInit, runSkillsAdd, runUiAdd, runUiInit, runUiList, syncSkillsToIdes, updateSkills, writeInstalledManifest, writeProjectConfig };
472
+ export { DEFAULT_UI_ALIASES, DEFAULT_UI_ICON_LIBRARY, type InstallOptions, type InstallResult, type ListVariantsResult, type RunSkillsAddOptions, type RunSkillsAddResult, type RunTokensInitOptions, type RunTokensInitResult, type RunUiAddOptions, type RunUiAddResult, type RunUiInitOptions, type RunUiInitResult, type RunUiListOptions, type RunUiListResult, type SkillInstallOptions, type SkillInstallResult, type SkillSyncOptions, type SkillSyncResult, type SkillUpdateOptions, type SkillUpdateResult, type UiEntryListItem, type UiInstallOptions, type UiInstallResult, ensureTeamixDir, getTeamixDir, installResources, installSkills, installUiEntries, listTokenVariants, loadSkillsData, loadUiData, loadVariantData, readInstalledManifest, readProjectConfig, removeSkillFiles, removeUiFiles, runSkillsAdd, runTokensInit, runUiAdd, runUiInit, runUiList, syncSkillsToIdes, updateSkills, writeInstalledManifest, writeProjectConfig };