teamix-evo 0.18.6 → 0.19.2
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/dist/index.js +20 -552
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -2395,11 +2395,11 @@ var uninstallCommand = new Command5("uninstall").description(
|
|
|
2395
2395
|
`Will remove ${removable.length} file(s); keep ${kept} managed file(s).`
|
|
2396
2396
|
);
|
|
2397
2397
|
if (!opts.yes) {
|
|
2398
|
-
const
|
|
2398
|
+
const confirm6 = await prompts.confirm({
|
|
2399
2399
|
message: "\u786E\u8BA4\u5378\u8F7D tokens \u53D8\u4F53\uFF1F",
|
|
2400
2400
|
initialValue: false
|
|
2401
2401
|
});
|
|
2402
|
-
if (prompts.isCancel(
|
|
2402
|
+
if (prompts.isCancel(confirm6) || !confirm6) {
|
|
2403
2403
|
logger.info("Cancelled.");
|
|
2404
2404
|
return;
|
|
2405
2405
|
}
|
|
@@ -4583,11 +4583,11 @@ async function runFullUninstall(args) {
|
|
|
4583
4583
|
`Will remove ${resources.length} skill file(s) installed by ${SKILLS_PACKAGE3}.`
|
|
4584
4584
|
);
|
|
4585
4585
|
if (!opts.yes) {
|
|
4586
|
-
const
|
|
4586
|
+
const confirm6 = await prompts4.confirm({
|
|
4587
4587
|
message: "\u786E\u8BA4\u5378\u8F7D\uFF1F\u6B64\u64CD\u4F5C\u4F1A\u5220\u9664\u4E0A\u8FF0\u6587\u4EF6\u3002",
|
|
4588
4588
|
initialValue: false
|
|
4589
4589
|
});
|
|
4590
|
-
if (prompts4.isCancel(
|
|
4590
|
+
if (prompts4.isCancel(confirm6) || !confirm6) {
|
|
4591
4591
|
logger.info("Cancelled.");
|
|
4592
4592
|
return;
|
|
4593
4593
|
}
|
|
@@ -4640,11 +4640,11 @@ async function runPartialUninstall(args) {
|
|
|
4640
4640
|
`Will remove ${matched.length} skill(s): ${matched.join(", ")} (${toRemove.length} file(s)).`
|
|
4641
4641
|
);
|
|
4642
4642
|
if (!opts.yes) {
|
|
4643
|
-
const
|
|
4643
|
+
const confirm6 = await prompts4.confirm({
|
|
4644
4644
|
message: "\u786E\u8BA4\u5378\u8F7D\uFF1F\u6B64\u64CD\u4F5C\u4F1A\u5220\u9664\u4E0A\u8FF0\u6587\u4EF6\u3002",
|
|
4645
4645
|
initialValue: false
|
|
4646
4646
|
});
|
|
4647
|
-
if (prompts4.isCancel(
|
|
4647
|
+
if (prompts4.isCancel(confirm6) || !confirm6) {
|
|
4648
4648
|
logger.info("Cancelled.");
|
|
4649
4649
|
return;
|
|
4650
4650
|
}
|
|
@@ -9449,11 +9449,11 @@ async function runScaffoldPhase(cwd, variant, opts) {
|
|
|
9449
9449
|
projectName: path39.basename(cwd)
|
|
9450
9450
|
});
|
|
9451
9451
|
if (pm === "pnpm") {
|
|
9452
|
-
const
|
|
9452
|
+
const fs33 = await import("fs/promises");
|
|
9453
9453
|
const pkgPath = path39.join(cwd, "package.json");
|
|
9454
|
-
const pkg = JSON.parse(await
|
|
9454
|
+
const pkg = JSON.parse(await fs33.readFile(pkgPath, "utf-8"));
|
|
9455
9455
|
pkg.packageManager = `pnpm@${PACKAGE_VERSIONS.pnpm}`;
|
|
9456
|
-
await
|
|
9456
|
+
await fs33.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
9457
9457
|
}
|
|
9458
9458
|
logger.info(
|
|
9459
9459
|
` \u2714 \u6A21\u677F ${result.preset.displayName}\uFF08variant: ${result.variant}\uFF09`
|
|
@@ -9520,7 +9520,7 @@ async function detectLintVersions(projectRoot) {
|
|
|
9520
9520
|
const pkgJson = pkgJsonRaw ? JSON.parse(pkgJsonRaw) : null;
|
|
9521
9521
|
const devDeps = pkgJson?.devDependencies ?? {};
|
|
9522
9522
|
const deps = pkgJson?.dependencies ?? {};
|
|
9523
|
-
const
|
|
9523
|
+
const resolve11 = async (pkg) => {
|
|
9524
9524
|
const declared = devDeps[pkg] ?? deps[pkg] ?? null;
|
|
9525
9525
|
if (!declared) return null;
|
|
9526
9526
|
const installedPkgJson = await readFileOrNull(
|
|
@@ -9530,8 +9530,8 @@ async function detectLintVersions(projectRoot) {
|
|
|
9530
9530
|
return { declared, installed };
|
|
9531
9531
|
};
|
|
9532
9532
|
const [eslintConfig, stylelintConfig] = await Promise.all([
|
|
9533
|
-
|
|
9534
|
-
|
|
9533
|
+
resolve11(LINT_PACKAGES[0]),
|
|
9534
|
+
resolve11(LINT_PACKAGES[1])
|
|
9535
9535
|
]);
|
|
9536
9536
|
return { eslintConfig, stylelintConfig };
|
|
9537
9537
|
}
|
|
@@ -9809,41 +9809,6 @@ async function pruneSnapshots(projectRoot, keep = DEFAULT_KEEP, opts = {}) {
|
|
|
9809
9809
|
}
|
|
9810
9810
|
return removed.reverse();
|
|
9811
9811
|
}
|
|
9812
|
-
async function restoreSnapshot(projectRoot, ts) {
|
|
9813
|
-
const snapshotRoot = path43.join(projectRoot, TEAMIX_DIR6, SNAPSHOTS_DIR);
|
|
9814
|
-
const target = path43.join(snapshotRoot, ts);
|
|
9815
|
-
try {
|
|
9816
|
-
const stat6 = await fs31.stat(target);
|
|
9817
|
-
if (!stat6.isDirectory()) {
|
|
9818
|
-
throw new Error(`Snapshot path is not a directory: ${target}`);
|
|
9819
|
-
}
|
|
9820
|
-
} catch (err) {
|
|
9821
|
-
if (err.code === "ENOENT") {
|
|
9822
|
-
throw new Error(
|
|
9823
|
-
`Snapshot not found: "${ts}". Run \`teamix-evo restore --list\` to see available timestamps.`
|
|
9824
|
-
);
|
|
9825
|
-
}
|
|
9826
|
-
throw err;
|
|
9827
|
-
}
|
|
9828
|
-
await createSnapshot(projectRoot, { reason: "restore", protectedTs: ts });
|
|
9829
|
-
const teamixDir = path43.join(projectRoot, TEAMIX_DIR6);
|
|
9830
|
-
const live = await fs31.readdir(teamixDir, { withFileTypes: true });
|
|
9831
|
-
for (const entry of live) {
|
|
9832
|
-
if (entry.name === SNAPSHOTS_DIR) continue;
|
|
9833
|
-
await fs31.rm(path43.join(teamixDir, entry.name), {
|
|
9834
|
-
recursive: true,
|
|
9835
|
-
force: true
|
|
9836
|
-
});
|
|
9837
|
-
}
|
|
9838
|
-
const snapshotEntries = await fs31.readdir(target, { withFileTypes: true });
|
|
9839
|
-
for (const entry of snapshotEntries) {
|
|
9840
|
-
if (entry.name === META_FILE) continue;
|
|
9841
|
-
const src = path43.join(target, entry.name);
|
|
9842
|
-
const dst = path43.join(teamixDir, entry.name);
|
|
9843
|
-
await fs31.cp(src, dst, { recursive: true });
|
|
9844
|
-
}
|
|
9845
|
-
logger.debug(`Restored .teamix-evo/ from snapshot ${ts}`);
|
|
9846
|
-
}
|
|
9847
9812
|
|
|
9848
9813
|
// src/core/graft-init.ts
|
|
9849
9814
|
init_error();
|
|
@@ -10379,523 +10344,26 @@ var graftCommand = new Command39("graft").description("\u53E0\u52A0 Teamix Evo A
|
|
|
10379
10344
|
});
|
|
10380
10345
|
|
|
10381
10346
|
// src/commands/restore/index.ts
|
|
10382
|
-
import { Command as Command40 } from "commander";
|
|
10383
|
-
import * as path46 from "path";
|
|
10384
|
-
import * as prompts8 from "@clack/prompts";
|
|
10385
10347
|
init_logger();
|
|
10386
|
-
|
|
10348
|
+
import { Command as Command40 } from "commander";
|
|
10387
10349
|
function createRestoreCommand() {
|
|
10388
|
-
return new Command40("restore").description(
|
|
10389
|
-
"
|
|
10390
|
-
|
|
10391
|
-
const cwd = path46.resolve(opts.cwd ?? process.cwd());
|
|
10392
|
-
try {
|
|
10393
|
-
const snapshots = await listSnapshots(cwd);
|
|
10394
|
-
if (opts.list) {
|
|
10395
|
-
printSnapshotTable(snapshots);
|
|
10396
|
-
return;
|
|
10397
|
-
}
|
|
10398
|
-
if (!ts) {
|
|
10399
|
-
logger.info("\u7528\u6CD5\uFF1A");
|
|
10400
|
-
logger.info(
|
|
10401
|
-
" teamix-evo restore --list \u5217\u51FA\u53EF\u7528 snapshot"
|
|
10402
|
-
);
|
|
10403
|
-
logger.info(
|
|
10404
|
-
" teamix-evo restore <ts> [-y] \u56DE\u6EDA\u5230\u6307\u5B9A snapshot"
|
|
10405
|
-
);
|
|
10406
|
-
logger.info("");
|
|
10407
|
-
if (snapshots.length === 0) {
|
|
10408
|
-
logger.warn(
|
|
10409
|
-
"\u5F53\u524D .teamix-evo/.snapshots/ \u4E3A\u7A7A\uFF08\u6216\u5DE5\u7A0B\u672A\u63A5\u5165 teamix-evo\uFF09\u3002"
|
|
10410
|
-
);
|
|
10411
|
-
} else {
|
|
10412
|
-
logger.info(`\u5F53\u524D\u5171 ${snapshots.length} \u4E2A\u53EF\u7528 snapshot\u3002`);
|
|
10413
|
-
}
|
|
10414
|
-
process.exitCode = 1;
|
|
10415
|
-
return;
|
|
10416
|
-
}
|
|
10417
|
-
const target = snapshots.find((s) => s.ts === ts);
|
|
10418
|
-
if (!target) {
|
|
10419
|
-
logger.error(`\u672A\u627E\u5230 snapshot\uFF1A${ts}`);
|
|
10420
|
-
logger.info("");
|
|
10421
|
-
logger.info(
|
|
10422
|
-
"\u8FD0\u884C `teamix-evo restore --list` \u67E5\u770B\u53EF\u7528 snapshot \u5217\u8868\u3002"
|
|
10423
|
-
);
|
|
10424
|
-
process.exitCode = 1;
|
|
10425
|
-
return;
|
|
10426
|
-
}
|
|
10427
|
-
const isInteractive = Boolean(process.stdin.isTTY);
|
|
10428
|
-
if (!opts.yes && isInteractive) {
|
|
10429
|
-
logger.info("");
|
|
10430
|
-
logger.info(`\u5373\u5C06\u56DE\u6EDA\u5230 snapshot\uFF1A${target.ts}`);
|
|
10431
|
-
if (target.reason) logger.info(` \u2022 \u539F\u56E0\uFF1A${target.reason}`);
|
|
10432
|
-
if (target.isoTs) logger.info(` \u2022 \u65F6\u95F4\uFF1A${target.isoTs}`);
|
|
10433
|
-
logger.info(
|
|
10434
|
-
"\u8BE5\u64CD\u4F5C\u4F1A\u8986\u76D6\u5F53\u524D .teamix-evo/ \u5185\u5BB9\uFF08\u9664 .snapshots/ \u5916\uFF09\u3002"
|
|
10435
|
-
);
|
|
10436
|
-
logger.info(
|
|
10437
|
-
'\u56DE\u6EDA\u524D\u4F1A\u81EA\u52A8\u518D\u505A\u4E00\u6B21 reason="restore" \u7684\u5B89\u5168 snapshot\uFF0C\u53EF\u4E8C\u6B21\u56DE\u6EDA\u3002'
|
|
10438
|
-
);
|
|
10439
|
-
const confirmed = await prompts8.confirm({
|
|
10440
|
-
message: "\u7EE7\u7EED\u56DE\u6EDA\uFF1F"
|
|
10441
|
-
});
|
|
10442
|
-
if (prompts8.isCancel(confirmed) || !confirmed) {
|
|
10443
|
-
logger.info("\u5DF2\u53D6\u6D88\u3002");
|
|
10444
|
-
return;
|
|
10445
|
-
}
|
|
10446
|
-
}
|
|
10447
|
-
await restoreSnapshot(cwd, ts);
|
|
10448
|
-
logger.success(`\u5DF2\u56DE\u6EDA\u5230 snapshot\uFF1A${ts}`);
|
|
10449
|
-
logger.info(
|
|
10450
|
-
'\u63D0\u793A\uFF1A\u672C\u6B21\u64CD\u4F5C\u524D\u7684\u72B6\u6001\u5DF2\u4FDD\u5B58\u4E3A\u65B0\u7684 reason="restore" snapshot\uFF0C\u5982\u9700\u518D\u6B21\u56DE\u6EDA\u53EF\u6267\u884C `teamix-evo restore --list` \u67E5\u770B\u3002'
|
|
10451
|
-
);
|
|
10452
|
-
} catch (err) {
|
|
10453
|
-
const message = getErrorMessage(err);
|
|
10454
|
-
logger.error(`restore \u5931\u8D25\uFF1A${message}`);
|
|
10455
|
-
logger.debug(err.stack ?? "");
|
|
10456
|
-
process.exitCode = 1;
|
|
10457
|
-
}
|
|
10350
|
+
return new Command40("restore").description("[\u5DF2\u5F03\u7528] \u5FEB\u7167\u6062\u590D\uFF08\u80FD\u529B\u5DF2\u79FB\u9664\uFF09").argument("[ts]", "(\u5DF2\u5F03\u7528)").option("--list", "(\u5DF2\u5F03\u7528)").option("--cwd <dir>", "(\u5DF2\u5F03\u7528)").option("-y, --yes", "(\u5DF2\u5F03\u7528)").action(() => {
|
|
10351
|
+
logger.warn("`teamix-evo restore` \u5DF2\u5F03\u7528\u5E76\u79FB\u9664\uFF0C\u8BE5\u80FD\u529B\u4E0D\u518D\u63D0\u4F9B\u3002");
|
|
10352
|
+
process.exitCode = 1;
|
|
10458
10353
|
});
|
|
10459
10354
|
}
|
|
10460
10355
|
var restoreCommand = createRestoreCommand();
|
|
10461
|
-
function printSnapshotTable(snapshots) {
|
|
10462
|
-
if (snapshots.length === 0) {
|
|
10463
|
-
logger.warn("\u672A\u627E\u5230\u53EF\u7528 snapshot\u3002");
|
|
10464
|
-
logger.info("");
|
|
10465
|
-
logger.info(
|
|
10466
|
-
"\u63D0\u793A\uFF1Asnapshot \u7531 `teamix-evo init` / `teamix-evo update` \u5728\u6267\u884C\u524D\u81EA\u52A8\u751F\u6210\uFF1B"
|
|
10467
|
-
);
|
|
10468
|
-
logger.info(
|
|
10469
|
-
"\u82E5\u5DE5\u7A0B\u521A\u63A5\u5165\u6216\u4ECE\u672A\u8FD0\u884C\u8FC7\u8FD9\u4E9B\u547D\u4EE4\uFF0C\u76EE\u5F55\u4F1A\u662F\u7A7A\u7684\uFF08\u8FD9\u662F\u6B63\u5E38\u72B6\u6001\uFF09\u3002"
|
|
10470
|
-
);
|
|
10471
|
-
return;
|
|
10472
|
-
}
|
|
10473
|
-
logger.info(`\u5171 ${snapshots.length} \u4E2A snapshot\uFF08\u6700\u65B0\u5728\u524D\uFF09\uFF1A`);
|
|
10474
|
-
logger.info("");
|
|
10475
|
-
for (let i = 0; i < snapshots.length; i++) {
|
|
10476
|
-
const s = snapshots[i];
|
|
10477
|
-
const reason = s.reason ?? "(unknown)";
|
|
10478
|
-
const iso = s.isoTs ?? "(meta missing)";
|
|
10479
|
-
logger.info(` [${i + 1}] ${s.ts}`);
|
|
10480
|
-
logger.info(` reason=${reason} iso=${iso}`);
|
|
10481
|
-
}
|
|
10482
|
-
logger.info("");
|
|
10483
|
-
logger.info("\u56DE\u6EDA\u547D\u4EE4\uFF1Ateamix-evo restore <ts>");
|
|
10484
|
-
}
|
|
10485
10356
|
|
|
10486
10357
|
// src/commands/switch/index.ts
|
|
10487
|
-
import { Command as Command41 } from "commander";
|
|
10488
|
-
import * as path48 from "path";
|
|
10489
|
-
import * as prompts9 from "@clack/prompts";
|
|
10490
|
-
|
|
10491
|
-
// src/core/variant-switch.ts
|
|
10492
|
-
init_fs();
|
|
10493
|
-
import * as path47 from "path";
|
|
10494
|
-
import * as fs33 from "fs/promises";
|
|
10495
|
-
import {
|
|
10496
|
-
loadTokensPackageManifest as loadTokensPackageManifest3,
|
|
10497
|
-
getVariantEntry as getVariantEntry3
|
|
10498
|
-
} from "@teamix-evo/registry";
|
|
10499
|
-
init_error();
|
|
10500
10358
|
init_logger();
|
|
10501
|
-
|
|
10502
|
-
var DEFAULT_TOKENS_PACKAGE3 = "@teamix-evo/tokens";
|
|
10503
|
-
var CONSUMER_BASENAME_BY_UPSTREAM2 = {
|
|
10504
|
-
"theme.css": "tokens.theme.css",
|
|
10505
|
-
"overrides.css": "tokens.overrides.css"
|
|
10506
|
-
};
|
|
10507
|
-
async function runVariantSwitch(options) {
|
|
10508
|
-
const { projectRoot, newVariant, apply = false } = options;
|
|
10509
|
-
const packageName = options.packageName ?? DEFAULT_TOKENS_PACKAGE3;
|
|
10510
|
-
const config = await readProjectConfig(projectRoot);
|
|
10511
|
-
if (!config?.packages?.tokens) {
|
|
10512
|
-
return { status: "not-initialized" };
|
|
10513
|
-
}
|
|
10514
|
-
const currentVariant = config.packages.tokens.variant;
|
|
10515
|
-
if (currentVariant === newVariant) {
|
|
10516
|
-
return { status: "already-on-variant", variant: currentVariant };
|
|
10517
|
-
}
|
|
10518
|
-
const packageRoot = options.packageRoot ?? resolveTokensPackageRoot(packageName);
|
|
10519
|
-
const catalog = await loadTokensPackageManifest3(packageRoot);
|
|
10520
|
-
const variantEntry = getVariantEntry3(catalog, newVariant);
|
|
10521
|
-
if (!variantEntry) {
|
|
10522
|
-
return {
|
|
10523
|
-
status: "variant-not-found",
|
|
10524
|
-
requested: newVariant,
|
|
10525
|
-
available: catalog.variants.map((v) => v.name)
|
|
10526
|
-
};
|
|
10527
|
-
}
|
|
10528
|
-
const upstreamByBasename = /* @__PURE__ */ new Map();
|
|
10529
|
-
for (const fileRel of variantEntry.files) {
|
|
10530
|
-
upstreamByBasename.set(
|
|
10531
|
-
path47.basename(fileRel),
|
|
10532
|
-
path47.join(packageRoot, fileRel)
|
|
10533
|
-
);
|
|
10534
|
-
}
|
|
10535
|
-
const prior = await readInstalledManifest(projectRoot) ?? {
|
|
10536
|
-
schemaVersion: 1,
|
|
10537
|
-
installed: []
|
|
10538
|
-
};
|
|
10539
|
-
const installedIdx = prior.installed.findIndex(
|
|
10540
|
-
(p2) => p2.package === packageName
|
|
10541
|
-
);
|
|
10542
|
-
const priorResources = installedIdx >= 0 ? prior.installed[installedIdx].resources : [];
|
|
10543
|
-
const priorVersion = installedIdx >= 0 ? prior.installed[installedIdx].version : "0.0.0";
|
|
10544
|
-
const changes = [];
|
|
10545
|
-
for (const resource of priorResources) {
|
|
10546
|
-
const consumerBasename = path47.basename(resource.target);
|
|
10547
|
-
const upstreamBasename = lookupUpstreamBasename2(consumerBasename);
|
|
10548
|
-
const upstreamAbs = upstreamBasename ? upstreamByBasename.get(upstreamBasename) : void 0;
|
|
10549
|
-
if (resource.strategy === "frozen") {
|
|
10550
|
-
changes.push({
|
|
10551
|
-
target: resource.target,
|
|
10552
|
-
kind: "preserve",
|
|
10553
|
-
strategy: "frozen",
|
|
10554
|
-
reason: "frozen \u2014 user-owned, never auto-overwritten"
|
|
10555
|
-
});
|
|
10556
|
-
continue;
|
|
10557
|
-
}
|
|
10558
|
-
if (!upstreamAbs) {
|
|
10559
|
-
changes.push({
|
|
10560
|
-
target: resource.target,
|
|
10561
|
-
kind: "preserve",
|
|
10562
|
-
strategy: resource.strategy,
|
|
10563
|
-
reason: `no upstream counterpart in variant "${newVariant}"`
|
|
10564
|
-
});
|
|
10565
|
-
continue;
|
|
10566
|
-
}
|
|
10567
|
-
const upstreamContent = await fs33.readFile(upstreamAbs, "utf-8");
|
|
10568
|
-
if (resource.strategy === "regenerable") {
|
|
10569
|
-
const newHash = computeHash(upstreamContent);
|
|
10570
|
-
if (newHash === resource.hash) {
|
|
10571
|
-
changes.push({
|
|
10572
|
-
target: resource.target,
|
|
10573
|
-
kind: "unchanged",
|
|
10574
|
-
strategy: "regenerable",
|
|
10575
|
-
reason: "identical bytes between old and new variant"
|
|
10576
|
-
});
|
|
10577
|
-
} else {
|
|
10578
|
-
changes.push({
|
|
10579
|
-
target: resource.target,
|
|
10580
|
-
kind: "rewrite",
|
|
10581
|
-
strategy: "regenerable",
|
|
10582
|
-
reason: `regenerable swap (${currentVariant} \u2192 ${newVariant})`
|
|
10583
|
-
});
|
|
10584
|
-
}
|
|
10585
|
-
continue;
|
|
10586
|
-
}
|
|
10587
|
-
changes.push({
|
|
10588
|
-
target: resource.target,
|
|
10589
|
-
kind: "managed-update",
|
|
10590
|
-
strategy: "managed",
|
|
10591
|
-
reason: "managed regions replayed; outside content preserved"
|
|
10592
|
-
});
|
|
10593
|
-
}
|
|
10594
|
-
if (!apply) {
|
|
10595
|
-
return {
|
|
10596
|
-
status: "dry-run",
|
|
10597
|
-
from: currentVariant,
|
|
10598
|
-
to: newVariant,
|
|
10599
|
-
toVersion: variantEntry.version,
|
|
10600
|
-
changes
|
|
10601
|
-
};
|
|
10602
|
-
}
|
|
10603
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
10604
|
-
let snapshot = null;
|
|
10605
|
-
let snapshotError;
|
|
10606
|
-
try {
|
|
10607
|
-
logger.debug(
|
|
10608
|
-
`[variant-switch] capturing snapshot (reason=switch, from=${currentVariant}, to=${newVariant})`
|
|
10609
|
-
);
|
|
10610
|
-
snapshot = await createSnapshot(projectRoot, { reason: "switch" });
|
|
10611
|
-
logger.debug(
|
|
10612
|
-
`[variant-switch] snapshot captured: ${snapshot?.ts ?? "(none)"}`
|
|
10613
|
-
);
|
|
10614
|
-
} catch (err) {
|
|
10615
|
-
snapshotError = getErrorMessage(err);
|
|
10616
|
-
logger.debug(`[variant-switch] snapshot capture failed: ${snapshotError}`);
|
|
10617
|
-
}
|
|
10618
|
-
const refreshedResources = [];
|
|
10619
|
-
for (const resource of priorResources) {
|
|
10620
|
-
const consumerAbs = path47.isAbsolute(resource.target) ? resource.target : path47.join(projectRoot, resource.target);
|
|
10621
|
-
const consumerBasename = path47.basename(resource.target);
|
|
10622
|
-
const upstreamBasename = lookupUpstreamBasename2(consumerBasename);
|
|
10623
|
-
const upstreamAbs = upstreamBasename ? upstreamByBasename.get(upstreamBasename) : void 0;
|
|
10624
|
-
if (resource.strategy === "regenerable" && upstreamAbs) {
|
|
10625
|
-
const upstreamContent = await fs33.readFile(upstreamAbs, "utf-8");
|
|
10626
|
-
await writeFileSafe(consumerAbs, upstreamContent);
|
|
10627
|
-
logger.debug(`[variant-switch] rewrite regenerable: ${resource.target}`);
|
|
10628
|
-
refreshedResources.push({
|
|
10629
|
-
...resource,
|
|
10630
|
-
hash: computeHash(upstreamContent)
|
|
10631
|
-
});
|
|
10632
|
-
continue;
|
|
10633
|
-
}
|
|
10634
|
-
if (resource.strategy === "managed" && upstreamAbs && await fileExists(consumerAbs)) {
|
|
10635
|
-
const upstreamContent = await fs33.readFile(upstreamAbs, "utf-8");
|
|
10636
|
-
const consumerContent = await fs33.readFile(consumerAbs, "utf-8");
|
|
10637
|
-
const merged = mergeManagedRegions(upstreamContent, consumerContent);
|
|
10638
|
-
if (merged !== consumerContent) {
|
|
10639
|
-
await writeFileSafe(consumerAbs, merged);
|
|
10640
|
-
logger.debug(`[variant-switch] managed-update: ${resource.target}`);
|
|
10641
|
-
} else {
|
|
10642
|
-
logger.debug(
|
|
10643
|
-
`[variant-switch] managed-update no-op (bytes unchanged): ${resource.target}`
|
|
10644
|
-
);
|
|
10645
|
-
}
|
|
10646
|
-
refreshedResources.push({
|
|
10647
|
-
...resource,
|
|
10648
|
-
hash: computeHash(merged)
|
|
10649
|
-
});
|
|
10650
|
-
continue;
|
|
10651
|
-
}
|
|
10652
|
-
refreshedResources.push(resource);
|
|
10653
|
-
}
|
|
10654
|
-
const lock = {
|
|
10655
|
-
schemaVersion: 1,
|
|
10656
|
-
variant: {
|
|
10657
|
-
name: variantEntry.name,
|
|
10658
|
-
displayName: variantEntry.displayName,
|
|
10659
|
-
version: variantEntry.version,
|
|
10660
|
-
from: packageName
|
|
10661
|
-
},
|
|
10662
|
-
packageVersion: catalog.version,
|
|
10663
|
-
linked: variantEntry.linked,
|
|
10664
|
-
installedAt: now
|
|
10665
|
-
};
|
|
10666
|
-
await writeFileSafe(
|
|
10667
|
-
path47.join(projectRoot, ".teamix-evo", "tokens-lock.json"),
|
|
10668
|
-
JSON.stringify(lock, null, 2) + "\n"
|
|
10669
|
-
);
|
|
10670
|
-
logger.debug(
|
|
10671
|
-
`[variant-switch] tokens-lock.json updated (variant=${newVariant}, version=${variantEntry.version})`
|
|
10672
|
-
);
|
|
10673
|
-
const renames = selectApplicableRenames(
|
|
10674
|
-
variantEntry.renames ?? [],
|
|
10675
|
-
"0.0.0",
|
|
10676
|
-
variantEntry.version
|
|
10677
|
-
);
|
|
10678
|
-
const renamesMap = {};
|
|
10679
|
-
for (const r of renames) renamesMap[r.from] = r.to;
|
|
10680
|
-
const switchTs = now;
|
|
10681
|
-
config.priorVariant = currentVariant;
|
|
10682
|
-
config.packages.tokens.variant = newVariant;
|
|
10683
|
-
config.packages.tokens.version = variantEntry.version;
|
|
10684
|
-
const history = config.tokenRenameHistory ?? [];
|
|
10685
|
-
history.push({
|
|
10686
|
-
ts: switchTs,
|
|
10687
|
-
fromVariant: currentVariant,
|
|
10688
|
-
toVariant: newVariant,
|
|
10689
|
-
renames: renamesMap
|
|
10690
|
-
});
|
|
10691
|
-
config.tokenRenameHistory = history;
|
|
10692
|
-
await writeProjectConfig(projectRoot, config);
|
|
10693
|
-
logger.debug(
|
|
10694
|
-
`[variant-switch] config.json updated (priorVariant=${currentVariant}, variant=${newVariant}, renames=${renames.length})`
|
|
10695
|
-
);
|
|
10696
|
-
if (installedIdx >= 0) {
|
|
10697
|
-
prior.installed[installedIdx] = {
|
|
10698
|
-
...prior.installed[installedIdx],
|
|
10699
|
-
variant: newVariant,
|
|
10700
|
-
version: variantEntry.version,
|
|
10701
|
-
installedAt: now,
|
|
10702
|
-
resources: refreshedResources
|
|
10703
|
-
};
|
|
10704
|
-
await writeInstalledManifest(projectRoot, prior);
|
|
10705
|
-
logger.debug(
|
|
10706
|
-
`[variant-switch] installed manifest updated (resources=${refreshedResources.length})`
|
|
10707
|
-
);
|
|
10708
|
-
}
|
|
10709
|
-
let hintPath;
|
|
10710
|
-
if (renames.length > 0) {
|
|
10711
|
-
const hint = await writeTokensUpgradeHint({
|
|
10712
|
-
projectRoot,
|
|
10713
|
-
trigger: "switch",
|
|
10714
|
-
fromVariant: currentVariant,
|
|
10715
|
-
toVariant: newVariant,
|
|
10716
|
-
fromVersion: priorVersion,
|
|
10717
|
-
toVersion: variantEntry.version,
|
|
10718
|
-
renames,
|
|
10719
|
-
isoTs: switchTs
|
|
10720
|
-
});
|
|
10721
|
-
if (hint) hintPath = hint.path;
|
|
10722
|
-
}
|
|
10723
|
-
if (hintPath) {
|
|
10724
|
-
logger.debug(`[variant-switch] upgrade hint written: ${hintPath}`);
|
|
10725
|
-
}
|
|
10726
|
-
logger.debug(
|
|
10727
|
-
`[variant-switch] apply complete (from=${currentVariant}, to=${newVariant}, toVersion=${variantEntry.version})`
|
|
10728
|
-
);
|
|
10729
|
-
try {
|
|
10730
|
-
const lock2 = await readSkillsLock(projectRoot);
|
|
10731
|
-
if (lock2) {
|
|
10732
|
-
const projectSkillIds = Object.entries(lock2.skills).filter(([, v]) => v.scope === "project").map(([id]) => id);
|
|
10733
|
-
const globalSkillIds = Object.entries(lock2.skills).filter(([, v]) => v.scope === "global").map(([id]) => id);
|
|
10734
|
-
await runGenerateAgentsMd({
|
|
10735
|
-
projectRoot,
|
|
10736
|
-
variant: newVariant,
|
|
10737
|
-
skillIds: projectSkillIds,
|
|
10738
|
-
globalSkillIds,
|
|
10739
|
-
mode: "merge-managed"
|
|
10740
|
-
});
|
|
10741
|
-
}
|
|
10742
|
-
} catch (err) {
|
|
10743
|
-
logger.warn(
|
|
10744
|
-
`AGENTS.md \u5237\u65B0\u5931\u8D25\uFF08\u975E\u5173\u952E\uFF09\uFF1A${err instanceof Error ? err.message : String(err)}`
|
|
10745
|
-
);
|
|
10746
|
-
}
|
|
10747
|
-
return {
|
|
10748
|
-
status: "switched",
|
|
10749
|
-
from: currentVariant,
|
|
10750
|
-
to: newVariant,
|
|
10751
|
-
toVersion: variantEntry.version,
|
|
10752
|
-
changes,
|
|
10753
|
-
snapshot,
|
|
10754
|
-
...snapshotError ? { snapshotError } : {},
|
|
10755
|
-
renames,
|
|
10756
|
-
...hintPath ? { hintPath } : {}
|
|
10757
|
-
};
|
|
10758
|
-
}
|
|
10759
|
-
function lookupUpstreamBasename2(consumerBasename) {
|
|
10760
|
-
for (const [upstream, consumer] of Object.entries(
|
|
10761
|
-
CONSUMER_BASENAME_BY_UPSTREAM2
|
|
10762
|
-
)) {
|
|
10763
|
-
if (consumer === consumerBasename) return upstream;
|
|
10764
|
-
}
|
|
10765
|
-
return consumerBasename;
|
|
10766
|
-
}
|
|
10767
|
-
|
|
10768
|
-
// src/commands/switch/index.ts
|
|
10769
|
-
init_logger();
|
|
10770
|
-
init_error();
|
|
10771
|
-
var KIND_ICON = {
|
|
10772
|
-
rewrite: "\u270E",
|
|
10773
|
-
"managed-update": "\u2295",
|
|
10774
|
-
preserve: "\u2298",
|
|
10775
|
-
unchanged: "="
|
|
10776
|
-
};
|
|
10777
|
-
var KIND_LABEL = {
|
|
10778
|
-
rewrite: "rewrite",
|
|
10779
|
-
"managed-update": "managed-update",
|
|
10780
|
-
preserve: "preserve",
|
|
10781
|
-
unchanged: "unchanged"
|
|
10782
|
-
};
|
|
10359
|
+
import { Command as Command41 } from "commander";
|
|
10783
10360
|
function createSwitchCommand() {
|
|
10784
|
-
return new Command41("switch").description(
|
|
10785
|
-
"
|
|
10786
|
-
|
|
10787
|
-
const cwd = path48.resolve(opts.cwd ?? process.cwd());
|
|
10788
|
-
const apply = opts.apply ?? false;
|
|
10789
|
-
try {
|
|
10790
|
-
const plan = await runVariantSwitch({
|
|
10791
|
-
projectRoot: cwd,
|
|
10792
|
-
newVariant,
|
|
10793
|
-
apply: false
|
|
10794
|
-
});
|
|
10795
|
-
if (plan.status === "not-initialized") {
|
|
10796
|
-
logger.warn(
|
|
10797
|
-
"\u5F53\u524D\u76EE\u5F55\u672A\u68C0\u6D4B\u5230 .teamix-evo/ \u2014 \u8BE5\u5DE5\u7A0B\u5C1A\u672A\u63A5\u5165 teamix-evo\u3002"
|
|
10798
|
-
);
|
|
10799
|
-
logger.info("\u8BF7\u5148\u8FD0\u884C `npx teamix-evo@latest init` \u63A5\u5165\u3002");
|
|
10800
|
-
process.exitCode = 1;
|
|
10801
|
-
return;
|
|
10802
|
-
}
|
|
10803
|
-
if (plan.status === "already-on-variant") {
|
|
10804
|
-
logger.success(`\u5F53\u524D variant \u5DF2\u662F "${plan.variant}"\uFF0C\u65E0\u9700\u5207\u6362\u3002`);
|
|
10805
|
-
return;
|
|
10806
|
-
}
|
|
10807
|
-
if (plan.status === "variant-not-found") {
|
|
10808
|
-
logger.error(`\u672A\u77E5 variant\uFF1A"${plan.requested}"`);
|
|
10809
|
-
logger.info(`\u53EF\u7528 variant\uFF1A${plan.available.join(", ") || "(none)"}`);
|
|
10810
|
-
logger.info(
|
|
10811
|
-
"\u8FD0\u884C `teamix-evo tokens list-variants` \u53EF\u67E5\u770B\u5B8C\u6574\u5217\u8868\u3002"
|
|
10812
|
-
);
|
|
10813
|
-
process.exitCode = 1;
|
|
10814
|
-
return;
|
|
10815
|
-
}
|
|
10816
|
-
printChangePlan(plan.from, plan.to, plan.toVersion, plan.changes);
|
|
10817
|
-
if (!apply) {
|
|
10818
|
-
logger.info("");
|
|
10819
|
-
logger.info(
|
|
10820
|
-
"\u4EE5\u4E0A\u4E3A dry-run \u8BA1\u5212\u3002\u5982\u9700\u771F\u6B63\u5207\u6362\uFF0C\u8BF7\u52A0 --apply\uFF08\u5EFA\u8BAE\u5148 commit \u5F53\u524D\u6539\u52A8\uFF09\u3002"
|
|
10821
|
-
);
|
|
10822
|
-
return;
|
|
10823
|
-
}
|
|
10824
|
-
const isInteractive = Boolean(process.stdin.isTTY);
|
|
10825
|
-
if (!opts.yes && isInteractive) {
|
|
10826
|
-
logger.info("");
|
|
10827
|
-
logger.info(
|
|
10828
|
-
"switch --apply \u4F1A\u91CD\u5199 regenerable \u6587\u4EF6\u5E76\u66F4\u65B0 .teamix-evo/ \u72B6\u6001\u3002"
|
|
10829
|
-
);
|
|
10830
|
-
logger.info(
|
|
10831
|
-
'\u6267\u884C\u524D\u4F1A\u81EA\u52A8\u6355\u83B7 reason="switch" snapshot\uFF0C\u53EF\u901A\u8FC7 `teamix-evo restore <ts>` \u56DE\u6EDA\u3002'
|
|
10832
|
-
);
|
|
10833
|
-
const confirmed = await prompts9.confirm({
|
|
10834
|
-
message: `\u7EE7\u7EED\u5207\u6362\u81F3 "${newVariant}"\uFF1F`
|
|
10835
|
-
});
|
|
10836
|
-
if (prompts9.isCancel(confirmed) || !confirmed) {
|
|
10837
|
-
logger.info("\u5DF2\u53D6\u6D88\u3002");
|
|
10838
|
-
return;
|
|
10839
|
-
}
|
|
10840
|
-
}
|
|
10841
|
-
const applied = await runVariantSwitch({
|
|
10842
|
-
projectRoot: cwd,
|
|
10843
|
-
newVariant,
|
|
10844
|
-
apply: true
|
|
10845
|
-
});
|
|
10846
|
-
if (applied.status !== "switched") {
|
|
10847
|
-
logger.error(`switch \u5F02\u5E38\uFF1A\u72B6\u6001 ${applied.status}`);
|
|
10848
|
-
process.exitCode = 1;
|
|
10849
|
-
return;
|
|
10850
|
-
}
|
|
10851
|
-
logger.success(
|
|
10852
|
-
`\u5DF2\u5207\u6362\u81F3 variant "${applied.to}" (v${applied.toVersion})\u3002`
|
|
10853
|
-
);
|
|
10854
|
-
if (applied.snapshot) {
|
|
10855
|
-
logger.info(
|
|
10856
|
-
`\u{1F4BE} snapshot\uFF1A${applied.snapshot.ts}\uFF08\u56DE\u6EDA\uFF1A\`teamix-evo restore ${applied.snapshot.ts}\`\uFF09`
|
|
10857
|
-
);
|
|
10858
|
-
} else if (applied.snapshotError) {
|
|
10859
|
-
logger.debug(`snapshot \u6355\u83B7\u5931\u8D25\uFF1A${applied.snapshotError}`);
|
|
10860
|
-
}
|
|
10861
|
-
if (applied.hintPath) {
|
|
10862
|
-
logger.info("");
|
|
10863
|
-
logger.info(`\u{1F4A1} token rename hint: ${applied.hintPath}`);
|
|
10864
|
-
logger.info(
|
|
10865
|
-
` \u68C0\u6D4B\u5230 ${applied.renames.length} \u4E2A token rename\uFF0C\u5EFA\u8BAE\u8C03\u7528 \`teamix-evo-manage\` skill \u626B src/** \u7ED9 codemod \u5EFA\u8BAE\uFF08ADR 0019 \xA7D4\uFF09\u3002`
|
|
10866
|
-
);
|
|
10867
|
-
} else {
|
|
10868
|
-
logger.info(
|
|
10869
|
-
"\u63D0\u793A\uFF1A\u672C\u6B21\u5207\u6362\u672A\u68C0\u6D4B\u5230 token rename\uFF08\u65B0 variant \u672A\u58F0\u660E renames \u6216 sinceVersion \u5747\u5728\u8303\u56F4\u5916\uFF09\u3002"
|
|
10870
|
-
);
|
|
10871
|
-
}
|
|
10872
|
-
} catch (err) {
|
|
10873
|
-
const message = getErrorMessage(err);
|
|
10874
|
-
logger.error(`switch \u5931\u8D25\uFF1A${message}`);
|
|
10875
|
-
logger.debug(err.stack ?? "");
|
|
10876
|
-
process.exitCode = 1;
|
|
10877
|
-
}
|
|
10361
|
+
return new Command41("switch").description("[\u5DF2\u5F03\u7528] \u53D8\u4F53\u5207\u6362\uFF08\u80FD\u529B\u5DF2\u79FB\u9664\uFF09").argument("[new-variant]", "(\u5DF2\u5F03\u7528)").option("--cwd <dir>", "(\u5DF2\u5F03\u7528)").option("--apply", "(\u5DF2\u5F03\u7528)").option("-y, --yes", "(\u5DF2\u5F03\u7528)").action(() => {
|
|
10362
|
+
logger.warn("`teamix-evo switch` \u5DF2\u5F03\u7528\u5E76\u79FB\u9664\uFF0C\u8BE5\u80FD\u529B\u4E0D\u518D\u63D0\u4F9B\u3002");
|
|
10363
|
+
process.exitCode = 1;
|
|
10878
10364
|
});
|
|
10879
10365
|
}
|
|
10880
10366
|
var switchCommand = createSwitchCommand();
|
|
10881
|
-
function printChangePlan(from, to, toVersion, changes) {
|
|
10882
|
-
logger.info("");
|
|
10883
|
-
logger.info(`variant \u5207\u6362\u8BA1\u5212\uFF1A${from} \u2192 ${to} (v${toVersion})`);
|
|
10884
|
-
logger.info("");
|
|
10885
|
-
if (changes.length === 0) {
|
|
10886
|
-
logger.warn(
|
|
10887
|
-
"\u6CA1\u6709\u53EF\u5904\u7406\u7684\u8D44\u6E90\uFF08installed manifest \u4E3A\u7A7A\uFF09\u3002\u8BF7\u5148\u8FD0\u884C `teamix-evo init`\u3002"
|
|
10888
|
-
);
|
|
10889
|
-
return;
|
|
10890
|
-
}
|
|
10891
|
-
for (const change of changes) {
|
|
10892
|
-
const icon = KIND_ICON[change.kind];
|
|
10893
|
-
const label = KIND_LABEL[change.kind];
|
|
10894
|
-
logger.info(
|
|
10895
|
-
` ${icon} [${label}] ${change.target} (${change.strategy}) \u2014 ${change.reason}`
|
|
10896
|
-
);
|
|
10897
|
-
}
|
|
10898
|
-
}
|
|
10899
10367
|
|
|
10900
10368
|
// src/index.ts
|
|
10901
10369
|
var require9 = createRequire9(import.meta.url);
|