@nalvietnam/avatar-cli 1.7.1 → 1.8.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/dist/index.js CHANGED
@@ -1297,6 +1297,11 @@ async function checkoutTagInSubmodule(submodulePath, tag, cwd = process.cwd()) {
1297
1297
  await git(submoduleCwd).fetch(["--tags"]);
1298
1298
  await git(submoduleCwd).checkout(tag);
1299
1299
  }
1300
+ async function checkoutBranchHeadInSubmodule(submodulePath, branch, cwd = process.cwd()) {
1301
+ const submoduleCwd = join8(cwd, submodulePath);
1302
+ await git(submoduleCwd).fetch(["origin"]);
1303
+ await git(submoduleCwd).checkout(["-B", branch, `origin/${branch}`]);
1304
+ }
1300
1305
  async function listTags(cwd = process.cwd()) {
1301
1306
  const result = await git(cwd).tags();
1302
1307
  return result.all;
@@ -4689,6 +4694,7 @@ async function buildSyncPreview(packDir, claudeDir, targetVersion) {
4689
4694
  }
4690
4695
 
4691
4696
  // src/commands/sync.ts
4697
+ var DEFAULT_PACK_BRANCH = "main";
4692
4698
  async function syncAction(opts) {
4693
4699
  const projectRoot = process.cwd();
4694
4700
  const claudeDir = join28(projectRoot, ".claude");
@@ -4708,16 +4714,23 @@ async function syncAction(opts) {
4708
4714
  `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.`
4709
4715
  );
4710
4716
  }
4717
+ const useLatestMode = opts.latest === true && !opts.version;
4711
4718
  const allTags = await listTags(packDir);
4712
- const targetVersion = opts.version ?? pickLatestStableSemVerTag(allTags);
4713
- if (!targetVersion) {
4714
- log.error(
4715
- `Kh\xF4ng t\xECm th\u1EA5y stable SemVer tag (vMAJOR.MINOR.PATCH) trong team-ai-pack submodule.
4719
+ let targetVersion;
4720
+ if (useLatestMode) {
4721
+ targetVersion = `${DEFAULT_PACK_BRANCH} (HEAD)`;
4722
+ } else {
4723
+ const picked = opts.version ?? pickLatestStableSemVerTag(allTags);
4724
+ if (!picked) {
4725
+ log.error(
4726
+ `Kh\xF4ng t\xECm th\u1EA5y stable SemVer tag (vMAJOR.MINOR.PATCH) trong team-ai-pack submodule.
4716
4727
  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.`
4718
- );
4719
- process.exit(1);
4720
- return;
4728
+ Pass --version <tag> r\xF5 r\xE0ng, ho\u1EB7c d\xF9ng --latest \u0111\u1EC3 pull HEAD branch ${DEFAULT_PACK_BRANCH}.`
4729
+ );
4730
+ process.exit(1);
4731
+ return;
4732
+ }
4733
+ targetVersion = picked;
4721
4734
  }
4722
4735
  if (opts.dryRun) {
4723
4736
  const preview = await buildSyncPreview(packDir, claudeDir, targetVersion);
@@ -4741,8 +4754,18 @@ async function syncAction(opts) {
4741
4754
  log.info("\nDry-run done. Kh\xF4ng apply thay \u0111\u1ED5i. B\u1ECF --dry-run \u0111\u1EC3 th\u1EF1c thi.");
4742
4755
  return;
4743
4756
  }
4744
- log.info(`Checking out ${targetVersion} trong submodule...`);
4745
- await checkoutTagInSubmodule(TEAM_PACK_RELATIVE_PATH, targetVersion, projectRoot);
4757
+ if (useLatestMode) {
4758
+ log.info(`Pulling HEAD c\u1EE7a branch ${DEFAULT_PACK_BRANCH} (bleeding-edge mode)...`);
4759
+ await checkoutBranchHeadInSubmodule(TEAM_PACK_RELATIVE_PATH, DEFAULT_PACK_BRANCH, projectRoot);
4760
+ const sha = await currentCommitSha(packDir);
4761
+ log.dim(` HEAD = ${sha.slice(0, 7)}`);
4762
+ log.warn(
4763
+ "\u26A0 --latest mode: workspace pin v\xE0o commit floating, kh\xF4ng reproducible. Chuy\u1EC3n v\u1EC1 tag stable: avatar sync (no flag)."
4764
+ );
4765
+ } else {
4766
+ log.info(`Checking out ${targetVersion} trong submodule...`);
4767
+ await checkoutTagInSubmodule(TEAM_PACK_RELATIVE_PATH, targetVersion, projectRoot);
4768
+ }
4746
4769
  log.info("Creating symlink farm...");
4747
4770
  const results = await syncAllMountDirs(packDir, claudeDir, opts.force === true);
4748
4771
  reportResults(results, opts.force === true);
@@ -4799,7 +4822,7 @@ function reportResults(results, force) {
4799
4822
  }
4800
4823
  }
4801
4824
  function registerSyncCommand(program2) {
4802
- program2.command("sync").description("Pull team-ai-pack m\u1EDBi nh\u1EA5t + t\u1EA1o symlink farm v\xE0o .claude/").option("--force", "Override .claude/<dir>/ n\u1EBFu l\xE0 real dir (backup tr\u01B0\u1EDBc)").option("--version <tag>", "Pin v\xE0o version c\u1EE5 th\u1EC3 (vd: v0.2.0)").option("--dry-run", "Hi\u1EC3n th\u1ECB preview, kh\xF4ng apply thay \u0111\u1ED5i").action(syncAction);
4825
+ program2.command("sync").description("Pull team-ai-pack m\u1EDBi nh\u1EA5t + t\u1EA1o symlink farm v\xE0o .claude/").option("--force", "Override .claude/<dir>/ n\u1EBFu l\xE0 real dir (backup tr\u01B0\u1EDBc)").option("--version <tag>", "Pin v\xE0o version c\u1EE5 th\u1EC3 (vd: v0.2.0)").option("--latest", "Bleeding-edge: pull HEAD c\u1EE7a main branch (b\u1ECF qua tag SemVer)").option("--dry-run", "Hi\u1EC3n th\u1ECB preview, kh\xF4ng apply thay \u0111\u1ED5i").action(syncAction);
4803
4826
  }
4804
4827
 
4805
4828
  // src/commands/tools.ts
@@ -4967,7 +4990,7 @@ async function removeSubmoduleEntry(gitmodulesPath, submodulePath) {
4967
4990
  }
4968
4991
 
4969
4992
  // src/commands/uninstall.ts
4970
- var CLI_VERSION = "1.7.1";
4993
+ var CLI_VERSION = "1.8.0";
4971
4994
  function registerUninstallCommand(program2) {
4972
4995
  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) => {
4973
4996
  try {
@@ -5049,7 +5072,7 @@ function printUninstallSuccessBox(backupPath) {
5049
5072
  }
5050
5073
 
5051
5074
  // src/index.ts
5052
- var CLI_VERSION2 = "1.7.1";
5075
+ var CLI_VERSION2 = "1.8.0";
5053
5076
  var program = new Command();
5054
5077
  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(
5055
5078
  "beforeAll",