teamix-evo 0.3.1 → 0.4.1

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,45 +152,47 @@ 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
- | 命令 | 说明 |
172
- | --------------------------------------------------- | ------------------------------------------------- |
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 |
178
- | `teamix-evo skills add [name...]` | 装 skills(写源 + 镜像 IDE);不传 = 全装 |
179
- | `teamix-evo skills list` | 列出所有 skill 的安装状态 |
180
- | `teamix-evo skills update` | 升级 skills(保留 managed 改动) |
181
- | `teamix-evo skills sync [name...]` | 源 → IDE 镜像(漂移恢复用) |
182
- | `teamix-evo skills doctor` | 检测源/镜像漂移(ADR 0013) |
183
- | `teamix-evo skills uninstall` | 卸载 skills(源 + 镜像 + lock) |
184
- | `teamix-evo ui init` | 初始化 ui 配置(aliases / iconLibrary / tsx / rsc) |
185
- | `teamix-evo ui add <id...>` | 安装指定 ui 组件源码 |
186
- | `teamix-evo ui list [--installed]` | 列出可用/已安装 ui 组件 |
187
- | `teamix-evo biz-ui list-variants` | 列出 biz-ui 包内提供的业务变体 |
188
- | `teamix-evo biz-ui add <id...> --variant <name>` | 安装变体感知业务组件(`--variant` 必填) |
189
- | `teamix-evo templates list-variants` | 列出 templates 包内提供的页面模板变体 |
190
- | `teamix-evo templates add <id...> --variant <name>` | 安装变体感知页面模板(`--variant` 必填) |
170
+ | 命令 | 说明 |
171
+ | --------------------------------------------------- | -------------------------------------------------------------- |
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 |
177
+ | `teamix-evo skills add [name...]` | 装 skills(写源 + 镜像 IDE);不传 = 全装 |
178
+ | `teamix-evo skills list` | 列出所有 skill 的安装状态 |
179
+ | `teamix-evo skills update` | 升级 skills(保留 managed 改动) |
180
+ | `teamix-evo skills sync [name...]` | 源 → IDE 镜像(漂移恢复用) |
181
+ | `teamix-evo skills doctor` | 检测源/镜像漂移(ADR 0013) |
182
+ | `teamix-evo skills uninstall` | 卸载 skills(源 + 镜像 + lock) |
183
+ | `teamix-evo ui init` | 初始化 ui 配置(aliases / iconLibrary / tsx / rsc) |
184
+ | `teamix-evo ui add <id...>` | 安装指定 ui 组件源码 |
185
+ | `teamix-evo ui list [--installed]` | 列出可用/已安装 ui 组件 |
186
+ | `teamix-evo biz-ui list-variants` | 列出 biz-ui 包内提供的业务变体 |
187
+ | `teamix-evo biz-ui add <id...> --variant <name>` | 安装变体感知业务组件(`--variant` 必填) |
188
+ | `teamix-evo templates list-variants` | 列出 templates 包内提供的页面模板变体 |
189
+ | `teamix-evo templates add <id...> --variant <name>` | 安装变体感知页面模板(`--variant` 必填) |
190
+ | `teamix-evo logs analyze [...]` | 分析 vibe-logger AI 调用链(`.log/ai/**/*.jsonl`) |
191
+ | `teamix-evo logs trace [...]` | 按会话还原 AI 调用链(prompt → PreToolUse → PostToolUse → Stop) |
191
192
 
192
193
  > 占位组件 → 真组件的升级流程**不是** CLI 子命令,由
193
- > [`teamix-evo-ui-upgrade`](../../packages/skills/skills/teamix-evo-ui-upgrade/SKILL.md)
194
- > skill 在 IDE 内驱动,底层仍调用 `teamix-evo ui add`。
194
+ > [`teamix-evo-manage`](../../packages/skills/src/teamix-evo-manage/SKILL.md)
195
+ > skill 在 IDE 内驱动「场景 6」,底层仍调用 `teamix-evo ui add`。
195
196
 
196
197
  ### 全局装 skill(`--scope global`)
197
198
 
@@ -216,7 +217,7 @@ cd ~/.teamix-evo-global && npx teamix-evo skills update
216
217
 
217
218
  ```
218
219
  本包 → @teamix-evo/registry(协议层)
219
- 本包 → @teamix-evo/design(设计资源,运行时解析)
220
+ 本包 → @teamix-evo/tokens(设计 tokens,运行时解析)
220
221
  本包 → @teamix-evo/skills(技能资源,运行时解析)
221
222
  本包 → @teamix-evo/ui(UI 资源,manifest + 源码)
222
223
  ```
@@ -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. */
@@ -161,6 +179,12 @@ interface RunUiAddOptions {
161
179
  overwrite?: boolean;
162
180
  /** Override the ui package name (defaults to "@teamix-evo/ui"). */
163
181
  packageName?: string;
182
+ /**
183
+ * When true, allow installing entries that live in `manifest.deprecatedEntries`
184
+ * (ADR 0028). Default: false — deprecated ids are treated as unknown and the
185
+ * call errors with a hint pointing the user at the active replacement.
186
+ */
187
+ includeDeprecated?: boolean;
164
188
  }
165
189
  interface RunUiAddResult {
166
190
  packageName: string;
@@ -170,8 +194,6 @@ interface RunUiAddResult {
170
194
  written: number;
171
195
  /** Number of files skipped due to frozen + exists. */
172
196
  skipped: number;
173
- /** Meta files dropped under .teamix-evo/design/components/. */
174
- metaFiles: string[];
175
197
  /** Aggregate npm dependencies of the installed entries. */
176
198
  npmDependencies: Record<string, string>;
177
199
  /** Per-file install records merged into the installed manifest. */
@@ -192,12 +214,19 @@ interface RunUiListOptions {
192
214
  installedOnly?: boolean;
193
215
  /** Override the ui package name (defaults to "@teamix-evo/ui"). */
194
216
  packageName?: string;
217
+ /**
218
+ * When true, also include archived entries from `manifest.deprecatedEntries`
219
+ * (ADR 0028). They are flagged with `deprecated: true` in the result.
220
+ */
221
+ includeDeprecated?: boolean;
195
222
  }
196
223
  interface UiEntryListItem {
197
224
  id: string;
198
225
  type: UiEntry['type'];
199
226
  description: string;
200
227
  installed: boolean;
228
+ /** True when the entry comes from `manifest.deprecatedEntries` (ADR 0028). */
229
+ deprecated: boolean;
201
230
  }
202
231
  interface RunUiListResult {
203
232
  packageName: string;
@@ -319,6 +348,8 @@ interface SkillSyncOptions {
319
348
  id: string;
320
349
  name: string;
321
350
  updateStrategy: SkillEntry['updateStrategy'];
351
+ /** Managed-region ids for region-aware mirror sync. */
352
+ managedRegions?: readonly string[];
322
353
  }>;
323
354
  ides: readonly SkillIde[];
324
355
  scope: SkillScope;
@@ -335,6 +366,8 @@ interface SkillSyncResult {
335
366
  declare function syncSkillsToIdes(options: SkillSyncOptions): Promise<SkillSyncResult>;
336
367
  /**
337
368
  * Remove all installed skill files. Returns the absolute paths removed.
369
+ * After files are unlinked, walks up the directory tree pruning empty dirs
370
+ * until a non-empty ancestor is reached (#33).
338
371
  */
339
372
  declare function removeSkillFiles(records: InstalledResource[]): Promise<string[]>;
340
373
 
@@ -345,6 +378,13 @@ interface UiInstallOptions {
345
378
  manifest: UiPackageManifest;
346
379
  /** Absolute ui package root (used to resolve entry source paths) */
347
380
  packageRoot: string;
381
+ /**
382
+ * Optional per-entry package root override. When set, entries in the map
383
+ * resolve their `file.source` against the mapped root instead of `packageRoot`.
384
+ * Used by variant-aware packages (biz-ui / templates) that pull in
385
+ * @teamix-evo/ui transitive deps — each entry resolves from its source package.
386
+ */
387
+ entryPackageRoot?: Map<string, string>;
348
388
  /** Aliases configured in `packages.ui.aliases` */
349
389
  aliases: UiAliases;
350
390
  /** Entry ids the user explicitly requested to add */
@@ -363,8 +403,6 @@ interface UiInstallResult {
363
403
  written: number;
364
404
  /** Number of files skipped because they already exist (frozen) */
365
405
  skipped: number;
366
- /** Meta files dropped under .teamix-evo/design/components/ */
367
- metaFiles: string[];
368
406
  }
369
407
  /**
370
408
  * Install the requested ui entries (transitively resolving registryDependencies).
@@ -379,7 +417,7 @@ declare function removeUiFiles(records: InstalledResource[]): Promise<string[]>;
379
417
  /**
380
418
  * Load the variant manifest and _data.json for template rendering.
381
419
  *
382
- * @param packageName - e.g. "@teamix-evo/design"
420
+ * @param packageName - e.g. "@teamix-evo/tokens"
383
421
  * @param variant - e.g. "opentrek"
384
422
  * @returns manifest and data for template rendering
385
423
  */
@@ -422,7 +460,8 @@ declare function getTeamixDir(projectRoot: string): string;
422
460
  declare function ensureTeamixDir(projectRoot: string): Promise<string>;
423
461
  /**
424
462
  * Read the project config from .teamix-evo/config.json.
425
- * Returns null if the file does not exist.
463
+ * Returns null if the file does not exist; THROWS on corrupted content
464
+ * so callers don't silently clobber prior config (#32 #18).
426
465
  */
427
466
  declare function readProjectConfig(projectRoot: string): Promise<ProjectConfig | null>;
428
467
  /**
@@ -431,7 +470,10 @@ declare function readProjectConfig(projectRoot: string): Promise<ProjectConfig |
431
470
  declare function writeProjectConfig(projectRoot: string, config: ProjectConfig): Promise<void>;
432
471
  /**
433
472
  * Read the installed manifest from .teamix-evo/manifest.json.
434
- * Returns null if the file does not exist.
473
+ * Returns null if the file does not exist; THROWS on corrupted content so
474
+ * callers don't silently lose prior installs by treating broken JSON as
475
+ * "fresh install" (#32 #18). Use `readInstalledManifestOrNull` for the
476
+ * old lenient behavior.
435
477
  */
436
478
  declare function readInstalledManifest(projectRoot: string): Promise<InstalledManifest | null>;
437
479
  /**
@@ -439,4 +481,4 @@ declare function readInstalledManifest(projectRoot: string): Promise<InstalledMa
439
481
  */
440
482
  declare function writeInstalledManifest(projectRoot: string, manifest: InstalledManifest): Promise<void>;
441
483
 
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 };
484
+ 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 };