@nalvietnam/avatar-cli 1.6.2 → 1.6.4
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
|
@@ -1850,9 +1850,31 @@ import { spawnSync as spawnSync10 } from "child_process";
|
|
|
1850
1850
|
import { existsSync as existsSync5 } from "fs";
|
|
1851
1851
|
import { join as join14 } from "path";
|
|
1852
1852
|
import { confirm as confirm2 } from "@inquirer/prompts";
|
|
1853
|
+
|
|
1854
|
+
// src/lib/detect-reasoning-model-from-name.ts
|
|
1855
|
+
var REASONING_PATTERNS = [
|
|
1856
|
+
// Anthropic Claude 4+ với extended thinking.
|
|
1857
|
+
// Match: claude-opus-4-7, claude-opus-4-8, claude-sonnet-4-5, claude-opus-4-1, ...
|
|
1858
|
+
/^claude-(opus|sonnet)-4/i,
|
|
1859
|
+
// Anthropic Claude 5+ (future-proof — assume reasoning theo trend).
|
|
1860
|
+
/^claude-(opus|sonnet|haiku)-[5-9]/i,
|
|
1861
|
+
// OpenAI o-series (o1, o3, o4).
|
|
1862
|
+
/^o1(-|$)/i,
|
|
1863
|
+
/^o3(-|$)/i,
|
|
1864
|
+
/^o4(-|$)/i,
|
|
1865
|
+
// LLMLite NAL alias mapping — phổ biến nal-claude-opus-* trỏ tới opus-4+.
|
|
1866
|
+
// (Conservative: chỉ match nếu name có chứa opus/sonnet + version số.)
|
|
1867
|
+
/nal-claude-(opus|sonnet)-?4/i
|
|
1868
|
+
];
|
|
1869
|
+
function isReasoningModel(modelName) {
|
|
1870
|
+
if (!modelName) return false;
|
|
1871
|
+
return REASONING_PATTERNS.some((pattern) => pattern.test(modelName));
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
// src/lib/run-gitnexus-wiki-conditional.ts
|
|
1853
1875
|
var WIKI_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
1854
|
-
var
|
|
1855
|
-
var
|
|
1876
|
+
var FALLBACK_LLMLITE_MODEL = "nal-claude";
|
|
1877
|
+
var FALLBACK_ANTHROPIC_MODEL = "claude-sonnet-4-5";
|
|
1856
1878
|
function normalizeAnthropicBaseUrl(rawBaseUrl) {
|
|
1857
1879
|
const cleaned = rawBaseUrl.replace(/\/+$/, "");
|
|
1858
1880
|
if (cleaned.endsWith("/v1")) return `${cleaned}/`;
|
|
@@ -1867,14 +1889,16 @@ async function readSettingsForWikiCredentials(workspacePath) {
|
|
|
1867
1889
|
const env = settings.env || {};
|
|
1868
1890
|
const baseUrl = typeof env.ANTHROPIC_BASE_URL === "string" ? env.ANTHROPIC_BASE_URL : null;
|
|
1869
1891
|
if (!baseUrl) return null;
|
|
1870
|
-
const
|
|
1892
|
+
const topLevelModel = typeof settings.model === "string" ? settings.model : "";
|
|
1893
|
+
const envModel = typeof env.ANTHROPIC_MODEL === "string" ? env.ANTHROPIC_MODEL : "";
|
|
1894
|
+
const userModel = topLevelModel.length > 0 ? topLevelModel : envModel;
|
|
1871
1895
|
const anthropicKey = typeof env.ANTHROPIC_API_KEY === "string" ? env.ANTHROPIC_API_KEY : null;
|
|
1872
1896
|
if (anthropicKey) {
|
|
1873
1897
|
return {
|
|
1874
1898
|
provider: "anthropic",
|
|
1875
1899
|
apiKey: anthropicKey,
|
|
1876
1900
|
baseUrl: normalizeAnthropicBaseUrl(baseUrl),
|
|
1877
|
-
model: userModel.length > 0 ? userModel :
|
|
1901
|
+
model: userModel.length > 0 ? userModel : FALLBACK_ANTHROPIC_MODEL
|
|
1878
1902
|
};
|
|
1879
1903
|
}
|
|
1880
1904
|
const llmliteToken = typeof env.ANTHROPIC_AUTH_TOKEN === "string" ? env.ANTHROPIC_AUTH_TOKEN : null;
|
|
@@ -1883,7 +1907,7 @@ async function readSettingsForWikiCredentials(workspacePath) {
|
|
|
1883
1907
|
provider: "llmlite",
|
|
1884
1908
|
apiKey: llmliteToken,
|
|
1885
1909
|
baseUrl,
|
|
1886
|
-
model: userModel.length > 0 ? userModel :
|
|
1910
|
+
model: userModel.length > 0 ? userModel : FALLBACK_LLMLITE_MODEL
|
|
1887
1911
|
};
|
|
1888
1912
|
}
|
|
1889
1913
|
return null;
|
|
@@ -1917,19 +1941,29 @@ async function runGitnexusWikiConditional(workspacePath) {
|
|
|
1917
1941
|
);
|
|
1918
1942
|
return { ran: false, skipped: true, reason: "user-declined" };
|
|
1919
1943
|
}
|
|
1944
|
+
const reasoningMode = isReasoningModel(creds.model);
|
|
1945
|
+
const args = [
|
|
1946
|
+
"wiki",
|
|
1947
|
+
".",
|
|
1948
|
+
"--api-key",
|
|
1949
|
+
creds.apiKey,
|
|
1950
|
+
"--base-url",
|
|
1951
|
+
creds.baseUrl,
|
|
1952
|
+
"--model",
|
|
1953
|
+
creds.model
|
|
1954
|
+
];
|
|
1955
|
+
if (reasoningMode) {
|
|
1956
|
+
args.push("--reasoning-model");
|
|
1957
|
+
}
|
|
1920
1958
|
const sp = spinnerWithElapsed(
|
|
1921
|
-
`Generating wiki via ${creds.baseUrl} (${creds.provider}) model=${creds.model}`
|
|
1922
|
-
);
|
|
1923
|
-
const result = spawnSync10(
|
|
1924
|
-
"gitnexus",
|
|
1925
|
-
["wiki", ".", "--api-key", creds.apiKey, "--base-url", creds.baseUrl, "--model", creds.model],
|
|
1926
|
-
{
|
|
1927
|
-
cwd: workspacePath,
|
|
1928
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
1929
|
-
timeout: WIKI_TIMEOUT_MS,
|
|
1930
|
-
encoding: "utf8"
|
|
1931
|
-
}
|
|
1959
|
+
`Generating wiki via ${creds.baseUrl} (${creds.provider}) model=${creds.model}${reasoningMode ? " [reasoning]" : ""}`
|
|
1932
1960
|
);
|
|
1961
|
+
const result = spawnSync10("gitnexus", args, {
|
|
1962
|
+
cwd: workspacePath,
|
|
1963
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
1964
|
+
timeout: WIKI_TIMEOUT_MS,
|
|
1965
|
+
encoding: "utf8"
|
|
1966
|
+
});
|
|
1933
1967
|
if (result.status !== 0 || result.signal === "SIGTERM") {
|
|
1934
1968
|
const reason = result.signal === "SIGTERM" ? "timeout" : "non-zero-exit";
|
|
1935
1969
|
sp.fail(`Wiki gen ${reason} (exit ${result.status ?? "null"})`);
|
|
@@ -4806,7 +4840,7 @@ async function removeSubmoduleEntry(gitmodulesPath, submodulePath) {
|
|
|
4806
4840
|
}
|
|
4807
4841
|
|
|
4808
4842
|
// src/commands/uninstall.ts
|
|
4809
|
-
var CLI_VERSION = "1.6.
|
|
4843
|
+
var CLI_VERSION = "1.6.4";
|
|
4810
4844
|
function registerUninstallCommand(program2) {
|
|
4811
4845
|
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) => {
|
|
4812
4846
|
try {
|
|
@@ -4888,7 +4922,7 @@ function printUninstallSuccessBox(backupPath) {
|
|
|
4888
4922
|
}
|
|
4889
4923
|
|
|
4890
4924
|
// src/index.ts
|
|
4891
|
-
var CLI_VERSION2 = "1.6.
|
|
4925
|
+
var CLI_VERSION2 = "1.6.4";
|
|
4892
4926
|
var program = new Command();
|
|
4893
4927
|
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(
|
|
4894
4928
|
"beforeAll",
|