@nalvietnam/avatar-cli 1.9.0 → 1.10.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
@@ -2482,7 +2482,8 @@ var TeamPackAccessAbortedError = class extends Error {
2482
2482
  this.name = "TeamPackAccessAbortedError";
2483
2483
  }
2484
2484
  };
2485
- async function addTeamPackSubmodule(projectRoot, tag, ssoEmail) {
2485
+ var DEFAULT_PACK_BRANCH = "main";
2486
+ async function addTeamPackSubmodule(projectRoot, tag, ssoEmail, latest = false) {
2486
2487
  const url = resolveTeamPackRepoUrl();
2487
2488
  const repoSlug = parseRepoSlugFromGitUrl(url);
2488
2489
  if (repoSlug) {
@@ -2508,12 +2509,17 @@ async function addTeamPackSubmodule(projectRoot, tag, ssoEmail) {
2508
2509
  }
2509
2510
  throw err;
2510
2511
  }
2511
- let target = tag ?? null;
2512
- if (!target) {
2513
- const submoduleDir = join16(projectRoot, TEAM_PACK_RELATIVE_PATH);
2514
- const allTags = await listTags(submoduleDir);
2515
- target = pickLatestStableSemVerTag(allTags);
2512
+ if (tag) {
2513
+ await checkoutTagInSubmodule(TEAM_PACK_RELATIVE_PATH, tag, projectRoot);
2514
+ return { pinnedTag: tag };
2515
+ }
2516
+ if (latest) {
2517
+ await checkoutBranchHeadInSubmodule(TEAM_PACK_RELATIVE_PATH, DEFAULT_PACK_BRANCH, projectRoot);
2518
+ return { pinnedTag: `${DEFAULT_PACK_BRANCH} (HEAD)` };
2516
2519
  }
2520
+ const submoduleDir = join16(projectRoot, TEAM_PACK_RELATIVE_PATH);
2521
+ const allTags = await listTags(submoduleDir);
2522
+ const target = pickLatestStableSemVerTag(allTags);
2517
2523
  if (target) {
2518
2524
  await checkoutTagInSubmodule(TEAM_PACK_RELATIVE_PATH, target, projectRoot);
2519
2525
  }
@@ -2573,10 +2579,10 @@ async function handleSshPermissionError() {
2573
2579
  ]
2574
2580
  });
2575
2581
  }
2576
- async function addTeamPackSubmoduleWithRetryOnNetworkFail(projectRoot, tag, ssoEmail) {
2582
+ async function addTeamPackSubmoduleWithRetryOnNetworkFail(projectRoot, tag, ssoEmail, latest = false) {
2577
2583
  while (true) {
2578
2584
  try {
2579
- const result = await addTeamPackSubmodule(projectRoot, tag, ssoEmail);
2585
+ const result = await addTeamPackSubmodule(projectRoot, tag, ssoEmail, latest);
2580
2586
  return { pinnedTag: result.pinnedTag, skipped: false };
2581
2587
  } catch (err) {
2582
2588
  if (err instanceof TeamPackAccessAbortedError) throw err;
@@ -3999,7 +4005,7 @@ function parseBootstrapStrategyOpts(opts) {
3999
4005
  );
4000
4006
  }
4001
4007
  function registerInitCommand(program2) {
4002
- program2.command("init").description("Kh\u1EDFi t\u1EA1o Avatar \u2014 3 flow t\u1EF1 nh\u1EADn di\u1EC7n (repo / folder / new)").option("--project-status <val>", "existing-remote | existing-folder | new-project").option("--folder-path <path>", "\u0110\u01B0\u1EDDng d\u1EABn folder hi\u1EC7n c\xF3 (flow existing-folder)").option("--create-remote", "Force t\u1EA1o remote qua gh (flow existing-folder ho\u1EB7c new-project)").option("--repo-visibility <val>", "private (m\u1EB7c \u0111\u1ECBnh) | public").option("--repo-org <name>", "GitHub org/owner cho repo m\u1EDBi").option("--client-repo <url>", "URL git remote (flow existing-remote)").option("--workspace-name <name>", "T\xEAn workspace").option("--workspace-parent <path>", "Th\u01B0 m\u1EE5c cha t\u1EA1o workspace (m\u1EB7c \u0111\u1ECBnh . \u2014 CWD)").option("--pack-version <tag>", "Pin team-ai-pack v\xE0o tag c\u1EE5 th\u1EC3").option("--team-owner <email>", "Email team owner (b\u1ECF qua prompt)").option("--description <text>", "M\xF4 t\u1EA3 1 d\xF2ng c\u1EE7a d\u1EF1 \xE1n").option("--skip-scan", "B\u1ECF qua project-scanner sau scaffold").option("--skip-team-pack", "B\u1ECF qua submodule team-ai-pack (test mode)").option("--force", "B\u1ECF qua prompt khi workspace path \u0111\xE3 t\u1ED3n t\u1EA1i").option("--yes", "Auto-confirm t\u1EA5t c\u1EA3 prompt").option("--no-commit", "Skip commit workspace initial state (m\u1EB7c \u0111\u1ECBnh LU\xD4N commit)").option("--workspace-remote", "T\u1EA1o GitHub remote cho workspace root (default: prompt)").option("--ai-skip", "B\u1ECF qua phase AI setup (CI/test mode \u2014 ch\u1EA1y `avatar ai setup` sau)").option(
4008
+ program2.command("init").description("Kh\u1EDFi t\u1EA1o Avatar \u2014 3 flow t\u1EF1 nh\u1EADn di\u1EC7n (repo / folder / new)").option("--project-status <val>", "existing-remote | existing-folder | new-project").option("--folder-path <path>", "\u0110\u01B0\u1EDDng d\u1EABn folder hi\u1EC7n c\xF3 (flow existing-folder)").option("--create-remote", "Force t\u1EA1o remote qua gh (flow existing-folder ho\u1EB7c new-project)").option("--repo-visibility <val>", "private (m\u1EB7c \u0111\u1ECBnh) | public").option("--repo-org <name>", "GitHub org/owner cho repo m\u1EDBi").option("--client-repo <url>", "URL git remote (flow existing-remote)").option("--workspace-name <name>", "T\xEAn workspace").option("--workspace-parent <path>", "Th\u01B0 m\u1EE5c cha t\u1EA1o workspace (m\u1EB7c \u0111\u1ECBnh . \u2014 CWD)").option("--pack-version <tag>", "Pin team-ai-pack v\xE0o tag c\u1EE5 th\u1EC3").option("--latest", "Pull HEAD c\u1EE7a team-ai-pack main branch (b\u1ECF qua tag SemVer, bleeding-edge)").option("--team-owner <email>", "Email team owner (b\u1ECF qua prompt)").option("--description <text>", "M\xF4 t\u1EA3 1 d\xF2ng c\u1EE7a d\u1EF1 \xE1n").option("--skip-scan", "B\u1ECF qua project-scanner sau scaffold").option("--skip-team-pack", "B\u1ECF qua submodule team-ai-pack (test mode)").option("--force", "B\u1ECF qua prompt khi workspace path \u0111\xE3 t\u1ED3n t\u1EA1i").option("--yes", "Auto-confirm t\u1EA5t c\u1EA3 prompt").option("--no-commit", "Skip commit workspace initial state (m\u1EB7c \u0111\u1ECBnh LU\xD4N commit)").option("--workspace-remote", "T\u1EA1o GitHub remote cho workspace root (default: prompt)").option("--ai-skip", "B\u1ECF qua phase AI setup (CI/test mode \u2014 ch\u1EA1y `avatar ai setup` sau)").option(
4003
4009
  "--gitnexus-skip",
4004
4010
  "B\u1ECF qua phase GitNexus setup (M10 \u2014 ch\u1EA1y `avatar gitnexus install` sau)"
4005
4011
  ).option(
@@ -4101,6 +4107,7 @@ async function runInitFromExistingRemote(opts, ownerEmail) {
4101
4107
  skipTeamPack: opts.skipTeamPack,
4102
4108
  description: opts.description ?? `Avatar workspace cho ${remoteUrl}`,
4103
4109
  packVersion: opts.packVersion,
4110
+ packLatest: opts.latest,
4104
4111
  autoYes: opts.yes,
4105
4112
  skipCommit: opts.commit === false,
4106
4113
  createWorkspaceRemote: opts.workspaceRemote,
@@ -4138,6 +4145,7 @@ async function runInitFromExistingFolder(opts, ownerEmail) {
4138
4145
  skipTeamPack: opts.skipTeamPack,
4139
4146
  description: opts.description ?? `Avatar workspace cho folder ${folderPath}`,
4140
4147
  packVersion: opts.packVersion,
4148
+ packLatest: opts.latest,
4141
4149
  autoYes: opts.yes,
4142
4150
  skipCommit: opts.commit === false,
4143
4151
  createWorkspaceRemote: opts.workspaceRemote,
@@ -4187,7 +4195,9 @@ async function runInitFromScratch(opts, ownerEmail) {
4187
4195
  const result = await addTeamPackSubmoduleWithRetryOnNetworkFail(
4188
4196
  workspacePath,
4189
4197
  opts.packVersion,
4190
- ownerEmail
4198
+ ownerEmail,
4199
+ opts.latest === true && !opts.packVersion
4200
+ // v1.10.0: latest mode khi flag set + không có explicit tag
4191
4201
  );
4192
4202
  pinnedTag = result.pinnedTag ?? "HEAD";
4193
4203
  sp.succeed(`Pin team-ai-pack v\xE0o ${pinnedTag}`);
@@ -4263,7 +4273,9 @@ async function scaffoldWorkspaceWithSrcSubmodule(args) {
4263
4273
  const result = await addTeamPackSubmoduleWithRetryOnNetworkFail(
4264
4274
  args.workspacePath,
4265
4275
  args.packVersion,
4266
- args.ssoEmail
4276
+ args.ssoEmail,
4277
+ args.packLatest === true && !args.packVersion
4278
+ // v1.10.0
4267
4279
  );
4268
4280
  pinnedTag = result.pinnedTag ?? "HEAD";
4269
4281
  sp.succeed(`Pin team-ai-pack v\xE0o ${pinnedTag}`);
@@ -4736,7 +4748,7 @@ async function buildSyncPreview(packDir, claudeDir, targetVersion) {
4736
4748
  }
4737
4749
 
4738
4750
  // src/commands/sync.ts
4739
- var DEFAULT_PACK_BRANCH = "main";
4751
+ var DEFAULT_PACK_BRANCH2 = "main";
4740
4752
  async function syncAction(opts) {
4741
4753
  const projectRoot = process.cwd();
4742
4754
  const claudeDir = join28(projectRoot, ".claude");
@@ -4760,14 +4772,14 @@ async function syncAction(opts) {
4760
4772
  const allTags = await listTags(packDir);
4761
4773
  let targetVersion;
4762
4774
  if (useLatestMode) {
4763
- targetVersion = `${DEFAULT_PACK_BRANCH} (HEAD)`;
4775
+ targetVersion = `${DEFAULT_PACK_BRANCH2} (HEAD)`;
4764
4776
  } else {
4765
4777
  const picked = opts.version ?? pickLatestStableSemVerTag(allTags);
4766
4778
  if (!picked) {
4767
4779
  log.error(
4768
4780
  `Kh\xF4ng t\xECm th\u1EA5y stable SemVer tag (vMAJOR.MINOR.PATCH) trong team-ai-pack submodule.
4769
4781
  Tags hi\u1EC7n c\xF3: ${allTags.length > 0 ? allTags.join(", ") : "(none)"}
4770
- Pass --version <tag> r\xF5 r\xE0ng, ho\u1EB7c d\xF9ng --latest \u0111\u1EC3 pull HEAD branch ${DEFAULT_PACK_BRANCH}.`
4782
+ Pass --version <tag> r\xF5 r\xE0ng, ho\u1EB7c d\xF9ng --latest \u0111\u1EC3 pull HEAD branch ${DEFAULT_PACK_BRANCH2}.`
4771
4783
  );
4772
4784
  process.exit(1);
4773
4785
  return;
@@ -4797,8 +4809,8 @@ async function syncAction(opts) {
4797
4809
  return;
4798
4810
  }
4799
4811
  if (useLatestMode) {
4800
- log.info(`Pulling HEAD c\u1EE7a branch ${DEFAULT_PACK_BRANCH} (bleeding-edge mode)...`);
4801
- await checkoutBranchHeadInSubmodule(TEAM_PACK_RELATIVE_PATH, DEFAULT_PACK_BRANCH, projectRoot);
4812
+ log.info(`Pulling HEAD c\u1EE7a branch ${DEFAULT_PACK_BRANCH2} (bleeding-edge mode)...`);
4813
+ await checkoutBranchHeadInSubmodule(TEAM_PACK_RELATIVE_PATH, DEFAULT_PACK_BRANCH2, projectRoot);
4802
4814
  const sha = await currentCommitSha(packDir);
4803
4815
  log.dim(` HEAD = ${sha.slice(0, 7)}`);
4804
4816
  log.warn(
@@ -5032,7 +5044,7 @@ async function removeSubmoduleEntry(gitmodulesPath, submodulePath) {
5032
5044
  }
5033
5045
 
5034
5046
  // src/commands/uninstall.ts
5035
- var CLI_VERSION = "1.9.0";
5047
+ var CLI_VERSION = "1.10.0";
5036
5048
  function registerUninstallCommand(program2) {
5037
5049
  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) => {
5038
5050
  try {
@@ -5114,7 +5126,7 @@ function printUninstallSuccessBox(backupPath) {
5114
5126
  }
5115
5127
 
5116
5128
  // src/index.ts
5117
- var CLI_VERSION2 = "1.9.0";
5129
+ var CLI_VERSION2 = "1.10.0";
5118
5130
  var program = new Command();
5119
5131
  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(
5120
5132
  "beforeAll",