@nalvietnam/avatar-cli 1.7.0 → 1.7.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/dist/index.js CHANGED
@@ -1301,9 +1301,13 @@ async function listTags(cwd = process.cwd()) {
1301
1301
  const result = await git(cwd).tags();
1302
1302
  return result.all;
1303
1303
  }
1304
- async function latestTag(cwd = process.cwd()) {
1305
- const tags = await listTags(cwd);
1306
- return tags.length > 0 ? tags[tags.length - 1] ?? null : null;
1304
+ async function tagAtHead(cwd = process.cwd()) {
1305
+ try {
1306
+ const result = await git(cwd).raw(["describe", "--tags", "--exact-match", "HEAD"]);
1307
+ return result.trim() || null;
1308
+ } catch {
1309
+ return null;
1310
+ }
1307
1311
  }
1308
1312
  async function currentCommitSha(cwd = process.cwd()) {
1309
1313
  const result = await git(cwd).revparse(["HEAD"]);
@@ -2430,6 +2434,31 @@ async function ensureTeamPackAccessWithRetry(args) {
2430
2434
  }
2431
2435
  }
2432
2436
 
2437
+ // src/lib/pick-latest-stable-semver-tag.ts
2438
+ var SEMVER_REGEX3 = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;
2439
+ function parseSemVerTag(tag) {
2440
+ const match = tag.match(SEMVER_REGEX3);
2441
+ if (!match) return null;
2442
+ const [, major, minor, patch, prerelease] = match;
2443
+ return {
2444
+ raw: tag,
2445
+ major: Number.parseInt(major ?? "0", 10),
2446
+ minor: Number.parseInt(minor ?? "0", 10),
2447
+ patch: Number.parseInt(patch ?? "0", 10),
2448
+ prerelease: prerelease ?? null
2449
+ };
2450
+ }
2451
+ function pickLatestStableSemVerTag(tags, includePrerelease = false) {
2452
+ const parsed = tags.map(parseSemVerTag).filter((t) => t !== null).filter((t) => includePrerelease || t.prerelease === null);
2453
+ if (parsed.length === 0) return null;
2454
+ parsed.sort((a, b) => {
2455
+ if (a.major !== b.major) return a.major - b.major;
2456
+ if (a.minor !== b.minor) return a.minor - b.minor;
2457
+ return a.patch - b.patch;
2458
+ });
2459
+ return parsed[parsed.length - 1]?.raw ?? null;
2460
+ }
2461
+
2433
2462
  // src/lib/resolve-team-pack-repo-url.ts
2434
2463
  var ORG_DEFAULT = "git@github.com:nalvn/team-ai-pack.git";
2435
2464
  function resolveTeamPackRepoUrl() {
@@ -2476,7 +2505,9 @@ async function addTeamPackSubmodule(projectRoot, tag, ssoEmail) {
2476
2505
  }
2477
2506
  let target = tag ?? null;
2478
2507
  if (!target) {
2479
- target = await latestTag(join16(projectRoot, TEAM_PACK_RELATIVE_PATH));
2508
+ const submoduleDir = join16(projectRoot, TEAM_PACK_RELATIVE_PATH);
2509
+ const allTags = await listTags(submoduleDir);
2510
+ target = pickLatestStableSemVerTag(allTags);
2480
2511
  }
2481
2512
  if (target) {
2482
2513
  await checkoutTagInSubmodule(TEAM_PACK_RELATIVE_PATH, target, projectRoot);
@@ -2485,7 +2516,7 @@ async function addTeamPackSubmodule(projectRoot, tag, ssoEmail) {
2485
2516
  }
2486
2517
  async function readPinnedPackVersion(projectRoot) {
2487
2518
  const submoduleRoot = join16(projectRoot, TEAM_PACK_RELATIVE_PATH);
2488
- const tag = await latestTag(submoduleRoot);
2519
+ const tag = await tagAtHead(submoduleRoot);
2489
2520
  if (tag) return tag;
2490
2521
  const sha = await currentCommitSha(submoduleRoot);
2491
2522
  return sha.slice(0, 7);
@@ -4636,9 +4667,11 @@ async function listCommitsBetween(packDir, fromSha, toRef) {
4636
4667
  }
4637
4668
  }
4638
4669
  async function buildSyncPreview(packDir, claudeDir, targetVersion) {
4670
+ const currentTagOrNull = await tagAtHead(packDir);
4639
4671
  const currentSha = await currentCommitSha(packDir);
4640
- const currentVersion = currentSha.slice(0, 7);
4641
- const target = targetVersion ?? await latestTag(packDir) ?? "HEAD";
4672
+ const currentVersion = currentTagOrNull ?? currentSha.slice(0, 7);
4673
+ const allTags = await listTags(packDir);
4674
+ const target = targetVersion ?? pickLatestStableSemVerTag(allTags) ?? "HEAD";
4642
4675
  const commits = await listCommitsBetween(packDir, currentSha, target);
4643
4676
  const mountStatuses = [];
4644
4677
  for (const dir of TEAM_PACK_MOUNT_DIRS) {
@@ -4675,10 +4708,13 @@ async function syncAction(opts) {
4675
4708
  `Kh\xF4ng fetch \u0111\u01B0\u1EE3c tags t\u1EEB origin (${err instanceof Error ? err.message : err}). S\u1EBD d\xF9ng tag local hi\u1EC7n c\xF3.`
4676
4709
  );
4677
4710
  }
4678
- const targetVersion = opts.version ?? await latestTag(packDir);
4711
+ const allTags = await listTags(packDir);
4712
+ const targetVersion = opts.version ?? pickLatestStableSemVerTag(allTags);
4679
4713
  if (!targetVersion) {
4680
4714
  log.error(
4681
- "Kh\xF4ng t\xECm th\u1EA5y tag n\xE0o trong team-ai-pack submodule. Pass --version <tag> r\xF5 r\xE0ng, ho\u1EB7c ki\u1EC3m tra repo c\xF3 tag \u0111\u01B0\u1EE3c kh\xF4ng."
4715
+ `Kh\xF4ng t\xECm th\u1EA5y stable SemVer tag (vMAJOR.MINOR.PATCH) trong team-ai-pack submodule.
4716
+ Tags hi\u1EC7n c\xF3: ${allTags.length > 0 ? allTags.join(", ") : "(none)"}
4717
+ Pass --version <tag> r\xF5 r\xE0ng, ho\u1EB7c tag pack theo SemVer convention.`
4682
4718
  );
4683
4719
  process.exit(1);
4684
4720
  return;
@@ -4931,7 +4967,7 @@ async function removeSubmoduleEntry(gitmodulesPath, submodulePath) {
4931
4967
  }
4932
4968
 
4933
4969
  // src/commands/uninstall.ts
4934
- var CLI_VERSION = "1.7.0";
4970
+ var CLI_VERSION = "1.7.1";
4935
4971
  function registerUninstallCommand(program2) {
4936
4972
  program2.command("uninstall").description("G\u1EE1 Avatar kh\u1ECFi project \u2014 backup t\u1EF1 \u0111\u1ED9ng (M11)").option("--yes", "Skip confirm prompt").option("--no-backup", "Kh\xF4ng t\u1EA1o backup tr\u01B0\u1EDBc khi x\xF3a (nguy hi\u1EC3m)").option("--keep-submodule", "Gi\u1EEF submodule .claude/pack/").option("--keep-hooks", "Gi\u1EEF git hooks post-merge, pre-push").option("--dry-run", "Hi\u1EC3n th\u1ECB danh s\xE1ch s\u1EBD x\xF3a, kh\xF4ng th\u1EF1c thi").action(async (opts) => {
4937
4973
  try {
@@ -5013,7 +5049,7 @@ function printUninstallSuccessBox(backupPath) {
5013
5049
  }
5014
5050
 
5015
5051
  // src/index.ts
5016
- var CLI_VERSION2 = "1.7.0";
5052
+ var CLI_VERSION2 = "1.7.1";
5017
5053
  var program = new Command();
5018
5054
  program.name("avatar").description("AI harness CLI for NAL Vietnam engineering").version(CLI_VERSION2, "-v, --version", "Hi\u1EC3n th\u1ECB phi\xEAn b\u1EA3n Avatar CLI").addHelpText(
5019
5055
  "beforeAll",