@wayai/cli 0.3.42 → 0.3.43
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 +163 -124
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6860,6 +6860,15 @@ function findGitRoot() {
|
|
|
6860
6860
|
return null;
|
|
6861
6861
|
}
|
|
6862
6862
|
}
|
|
6863
|
+
function findRepoRootSync() {
|
|
6864
|
+
let current = process.cwd();
|
|
6865
|
+
while (true) {
|
|
6866
|
+
if (fs2.existsSync(path2.join(current, ".git"))) return current;
|
|
6867
|
+
const parent = path2.dirname(current);
|
|
6868
|
+
if (parent === current) return null;
|
|
6869
|
+
current = parent;
|
|
6870
|
+
}
|
|
6871
|
+
}
|
|
6863
6872
|
function detectWorkspace() {
|
|
6864
6873
|
const gitRoot = findGitRoot();
|
|
6865
6874
|
if (!gitRoot) return null;
|
|
@@ -7313,8 +7322,8 @@ var init_utils = __esm({
|
|
|
7313
7322
|
});
|
|
7314
7323
|
|
|
7315
7324
|
// src/lib/version-cache.ts
|
|
7316
|
-
import { existsSync as existsSync4, readFileSync as readFileSync5 } from "fs";
|
|
7317
|
-
import { join as join6 } from "path";
|
|
7325
|
+
import { existsSync as existsSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync2, mkdirSync } from "fs";
|
|
7326
|
+
import { dirname as dirname3, join as join6 } from "path";
|
|
7318
7327
|
import { homedir as homedir2 } from "os";
|
|
7319
7328
|
function getVersionCachePath(filename = CLI_CACHE_FILE) {
|
|
7320
7329
|
return join6(homedir2(), ".wayai", filename);
|
|
@@ -7337,6 +7346,20 @@ function readCachedLatest(filename = CLI_CACHE_FILE, maxAgeMs = MAX_AGE_24H_MS)
|
|
|
7337
7346
|
if (Date.now() - cache.lastCheck > maxAgeMs) return null;
|
|
7338
7347
|
return cache.latest;
|
|
7339
7348
|
}
|
|
7349
|
+
function isVersionCacheStale(filename = CLI_CACHE_FILE, maxAgeMs = MAX_AGE_24H_MS) {
|
|
7350
|
+
const cache = readVersionCache(filename);
|
|
7351
|
+
if (!cache) return true;
|
|
7352
|
+
return Date.now() - cache.lastCheck > maxAgeMs;
|
|
7353
|
+
}
|
|
7354
|
+
function writeVersionCache(filename, cache) {
|
|
7355
|
+
const path19 = getVersionCachePath(filename);
|
|
7356
|
+
const dir = dirname3(path19);
|
|
7357
|
+
if (!existsSync4(dir)) mkdirSync(dir, { recursive: true });
|
|
7358
|
+
writeFileSync2(path19, JSON.stringify(cache));
|
|
7359
|
+
}
|
|
7360
|
+
function touchVersionCache(filename) {
|
|
7361
|
+
writeVersionCache(filename, { lastCheck: Date.now(), latest: readVersionCache(filename)?.latest ?? null });
|
|
7362
|
+
}
|
|
7340
7363
|
var MAX_AGE_24H_MS, CLI_CACHE_FILE, SKILL_CACHE_FILE;
|
|
7341
7364
|
var init_version_cache = __esm({
|
|
7342
7365
|
"src/lib/version-cache.ts"() {
|
|
@@ -8535,7 +8558,7 @@ async function tryOpenBrowser(url) {
|
|
|
8535
8558
|
return false;
|
|
8536
8559
|
}
|
|
8537
8560
|
try {
|
|
8538
|
-
const { execFile
|
|
8561
|
+
const { execFile } = await import("child_process");
|
|
8539
8562
|
const platform2 = process.platform;
|
|
8540
8563
|
let cmd;
|
|
8541
8564
|
let args2;
|
|
@@ -8550,7 +8573,7 @@ async function tryOpenBrowser(url) {
|
|
|
8550
8573
|
args2 = [url];
|
|
8551
8574
|
}
|
|
8552
8575
|
return new Promise((resolve4) => {
|
|
8553
|
-
|
|
8576
|
+
execFile(cmd, args2, (err) => resolve4(!err));
|
|
8554
8577
|
});
|
|
8555
8578
|
} catch {
|
|
8556
8579
|
return false;
|
|
@@ -8911,20 +8934,20 @@ __export(init_exports, {
|
|
|
8911
8934
|
parseArgs: () => parseArgs3,
|
|
8912
8935
|
writeWorkspaceFiles: () => writeWorkspaceFiles
|
|
8913
8936
|
});
|
|
8914
|
-
import { existsSync as existsSync8, mkdirSync as
|
|
8937
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
8915
8938
|
import path9 from "path";
|
|
8916
8939
|
function writeWorkspaceFiles(gitRoot) {
|
|
8917
8940
|
const created = [];
|
|
8918
8941
|
for (const { name, content } of SHIM_FILES) {
|
|
8919
8942
|
const filePath = path9.join(gitRoot, name);
|
|
8920
8943
|
if (!existsSync8(filePath)) {
|
|
8921
|
-
|
|
8944
|
+
writeFileSync6(filePath, content);
|
|
8922
8945
|
created.push(name);
|
|
8923
8946
|
}
|
|
8924
8947
|
}
|
|
8925
8948
|
const hubsDir = resolveLayout(gitRoot).hubsDir;
|
|
8926
8949
|
if (!existsSync8(hubsDir)) {
|
|
8927
|
-
|
|
8950
|
+
mkdirSync4(hubsDir, { recursive: true });
|
|
8928
8951
|
created.push(`${path9.relative(gitRoot, hubsDir)}/`);
|
|
8929
8952
|
}
|
|
8930
8953
|
return created;
|
|
@@ -16256,7 +16279,7 @@ var init_admin = __esm({
|
|
|
16256
16279
|
|
|
16257
16280
|
// src/commands/report-create.ts
|
|
16258
16281
|
import { readFileSync as readFileSync14 } from "fs";
|
|
16259
|
-
import { dirname as
|
|
16282
|
+
import { dirname as dirname7, join as join19 } from "path";
|
|
16260
16283
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16261
16284
|
function getCliVersion() {
|
|
16262
16285
|
try {
|
|
@@ -16367,7 +16390,7 @@ var init_report_create = __esm({
|
|
|
16367
16390
|
init_auth();
|
|
16368
16391
|
init_repo_config();
|
|
16369
16392
|
init_api_client();
|
|
16370
|
-
__dirname =
|
|
16393
|
+
__dirname = dirname7(fileURLToPath2(import.meta.url));
|
|
16371
16394
|
}
|
|
16372
16395
|
});
|
|
16373
16396
|
|
|
@@ -16643,18 +16666,125 @@ var init_update = __esm({
|
|
|
16643
16666
|
// src/index.ts
|
|
16644
16667
|
init_sentry();
|
|
16645
16668
|
init_utils();
|
|
16669
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
16670
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
16671
|
+
import { dirname as dirname8, join as join20 } from "path";
|
|
16672
|
+
|
|
16673
|
+
// src/lib/version-refresh.ts
|
|
16674
|
+
init_version_cache();
|
|
16675
|
+
init_skill_version();
|
|
16676
|
+
import { exec } from "child_process";
|
|
16677
|
+
var REFRESH_TIMEOUT_MS = 1e4;
|
|
16678
|
+
function refreshCliCache() {
|
|
16679
|
+
return new Promise((resolve4) => {
|
|
16680
|
+
exec("npm view @wayai/cli version", { timeout: REFRESH_TIMEOUT_MS }, (err, stdout) => {
|
|
16681
|
+
if (!err) {
|
|
16682
|
+
const latest = stdout.trim();
|
|
16683
|
+
if (latest) {
|
|
16684
|
+
try {
|
|
16685
|
+
writeVersionCache(CLI_CACHE_FILE, { lastCheck: Date.now(), latest });
|
|
16686
|
+
} catch {
|
|
16687
|
+
}
|
|
16688
|
+
}
|
|
16689
|
+
}
|
|
16690
|
+
resolve4();
|
|
16691
|
+
});
|
|
16692
|
+
});
|
|
16693
|
+
}
|
|
16694
|
+
async function refreshSkillCache() {
|
|
16695
|
+
const url = process.env.WAYAI_SKILL_RAW_URL || DEFAULT_SKILL_RAW_URL;
|
|
16696
|
+
const controller = new AbortController();
|
|
16697
|
+
const timer = setTimeout(() => controller.abort(), REFRESH_TIMEOUT_MS);
|
|
16698
|
+
try {
|
|
16699
|
+
const res = await fetch(url, { signal: controller.signal });
|
|
16700
|
+
if (res.ok) {
|
|
16701
|
+
const latest = parseFrontmatterVersion(await res.text());
|
|
16702
|
+
if (latest) {
|
|
16703
|
+
try {
|
|
16704
|
+
writeVersionCache(SKILL_CACHE_FILE, { lastCheck: Date.now(), latest });
|
|
16705
|
+
} catch {
|
|
16706
|
+
}
|
|
16707
|
+
}
|
|
16708
|
+
}
|
|
16709
|
+
} catch {
|
|
16710
|
+
} finally {
|
|
16711
|
+
clearTimeout(timer);
|
|
16712
|
+
}
|
|
16713
|
+
}
|
|
16714
|
+
async function refreshVersionCaches(opts) {
|
|
16715
|
+
await Promise.all([
|
|
16716
|
+
opts.cli ? refreshCliCache() : Promise.resolve(),
|
|
16717
|
+
opts.skill ? refreshSkillCache() : Promise.resolve()
|
|
16718
|
+
]);
|
|
16719
|
+
}
|
|
16720
|
+
|
|
16721
|
+
// src/lib/update-nudge.ts
|
|
16722
|
+
init_utils();
|
|
16646
16723
|
init_version_cache();
|
|
16647
16724
|
init_skill_version();
|
|
16648
16725
|
init_workspace();
|
|
16649
|
-
import {
|
|
16650
|
-
|
|
16651
|
-
|
|
16652
|
-
|
|
16653
|
-
|
|
16726
|
+
import { spawn } from "child_process";
|
|
16727
|
+
var REFRESH_COMMAND = "__refresh-version-cache";
|
|
16728
|
+
var ENV_REFRESH_CLI = "WAYAI_REFRESH_CLI";
|
|
16729
|
+
var ENV_REFRESH_SKILL = "WAYAI_REFRESH_SKILL";
|
|
16730
|
+
function isUpdateCheckDisabled() {
|
|
16731
|
+
return Boolean(
|
|
16732
|
+
process.env.NO_UPDATE_NOTIFIER || process.env.WAYAI_NO_UPDATE_CHECK || process.env.CI
|
|
16733
|
+
);
|
|
16734
|
+
}
|
|
16735
|
+
function scheduleVersionRefresh(opts, entryPath) {
|
|
16736
|
+
try {
|
|
16737
|
+
if (opts.cli) touchVersionCache(CLI_CACHE_FILE);
|
|
16738
|
+
if (opts.skill) touchVersionCache(SKILL_CACHE_FILE);
|
|
16739
|
+
spawn(process.execPath, [entryPath, REFRESH_COMMAND], {
|
|
16740
|
+
detached: true,
|
|
16741
|
+
stdio: "ignore",
|
|
16742
|
+
windowsHide: true,
|
|
16743
|
+
// no flashing console window on Windows (fires on every command past the TTL)
|
|
16744
|
+
env: {
|
|
16745
|
+
...process.env,
|
|
16746
|
+
[ENV_REFRESH_CLI]: opts.cli ? "1" : "",
|
|
16747
|
+
[ENV_REFRESH_SKILL]: opts.skill ? "1" : ""
|
|
16748
|
+
}
|
|
16749
|
+
}).unref();
|
|
16750
|
+
} catch {
|
|
16751
|
+
}
|
|
16752
|
+
}
|
|
16753
|
+
function showUpdateNudges(currentVersion, entryPath) {
|
|
16754
|
+
if (isUpdateCheckDisabled() || !process.stderr.isTTY) return;
|
|
16755
|
+
try {
|
|
16756
|
+
const cliLatest = readVersionCache(CLI_CACHE_FILE)?.latest ?? null;
|
|
16757
|
+
if (cliLatest && isNewerVersion(cliLatest, currentVersion)) {
|
|
16758
|
+
console.error(`
|
|
16759
|
+
Update available: ${currentVersion} \u2192 ${cliLatest}
|
|
16760
|
+
Run \`wayai update\` to update.`);
|
|
16761
|
+
}
|
|
16762
|
+
const installs = findInstalledSkills(findRepoRootSync() ?? process.cwd());
|
|
16763
|
+
const localSkillVersion = installs.length > 0 ? lowestInstalledVersion(installs) : null;
|
|
16764
|
+
if (localSkillVersion) {
|
|
16765
|
+
const skillLatest = readVersionCache(SKILL_CACHE_FILE)?.latest ?? null;
|
|
16766
|
+
if (skillLatest && isNewerVersion(skillLatest, localSkillVersion)) {
|
|
16767
|
+
console.error(`
|
|
16768
|
+
Skill update available: ${localSkillVersion} \u2192 ${skillLatest}
|
|
16769
|
+
Run \`npx skills add wayai-pro/wayai-skill -y\` to update.`);
|
|
16770
|
+
}
|
|
16771
|
+
}
|
|
16772
|
+
const cliStale = isVersionCacheStale(CLI_CACHE_FILE);
|
|
16773
|
+
const skillStale = localSkillVersion !== null && isVersionCacheStale(SKILL_CACHE_FILE);
|
|
16774
|
+
if (cliStale || skillStale) {
|
|
16775
|
+
scheduleVersionRefresh({ cli: cliStale, skill: skillStale }, entryPath);
|
|
16776
|
+
}
|
|
16777
|
+
} catch {
|
|
16778
|
+
}
|
|
16779
|
+
}
|
|
16780
|
+
|
|
16781
|
+
// src/index.ts
|
|
16782
|
+
var __dirname2 = dirname8(fileURLToPath3(import.meta.url));
|
|
16654
16783
|
var pkg = JSON.parse(readFileSync15(join20(__dirname2, "..", "package.json"), "utf-8"));
|
|
16655
16784
|
var [, , command, ...args] = process.argv;
|
|
16785
|
+
var isBackgroundRefresh = command === REFRESH_COMMAND;
|
|
16656
16786
|
var OWN_HELP_COMMANDS = /* @__PURE__ */ new Set(["eval", "admin", "report"]);
|
|
16657
|
-
initSentry(command);
|
|
16787
|
+
if (!isBackgroundRefresh) initSentry(command);
|
|
16658
16788
|
async function main() {
|
|
16659
16789
|
if (shouldInterceptHelp(command, args, OWN_HELP_COMMANDS)) {
|
|
16660
16790
|
printHelp3();
|
|
@@ -16907,119 +17037,28 @@ Examples:
|
|
|
16907
17037
|
`.trim());
|
|
16908
17038
|
}
|
|
16909
17039
|
var SKIP_UPDATE_CHECK = ["--version", "-v", "--help", "-h", "help", "update"];
|
|
16910
|
-
|
|
16911
|
-
function isUpdateCheckDisabled() {
|
|
16912
|
-
return Boolean(
|
|
16913
|
-
process.env.NO_UPDATE_NOTIFIER || process.env.WAYAI_NO_UPDATE_CHECK || process.env.CI
|
|
16914
|
-
);
|
|
16915
|
-
}
|
|
16916
|
-
function checkForUpdates() {
|
|
16917
|
-
if (isUpdateCheckDisabled()) return;
|
|
17040
|
+
async function runForeground() {
|
|
16918
17041
|
try {
|
|
16919
|
-
|
|
16920
|
-
|
|
16921
|
-
|
|
16922
|
-
if (cache && Date.now() - cache.lastCheck < UPDATE_CHECK_INTERVAL_MS) {
|
|
16923
|
-
if (cache.latest && isNewerVersion(cache.latest, pkg.version)) {
|
|
16924
|
-
console.error(
|
|
16925
|
-
`
|
|
16926
|
-
Update available: ${pkg.version} \u2192 ${cache.latest}
|
|
16927
|
-
Run \`wayai update\` to update.`
|
|
16928
|
-
);
|
|
16929
|
-
}
|
|
16930
|
-
return;
|
|
17042
|
+
await main();
|
|
17043
|
+
if (command && !SKIP_UPDATE_CHECK.includes(command) && !wantsHelp(args)) {
|
|
17044
|
+
showUpdateNudges(pkg.version, fileURLToPath3(import.meta.url));
|
|
16931
17045
|
}
|
|
16932
|
-
|
|
16933
|
-
|
|
16934
|
-
|
|
16935
|
-
|
|
17046
|
+
await closeSentry();
|
|
17047
|
+
} catch (err) {
|
|
17048
|
+
if (shouldReportToSentry(err)) {
|
|
17049
|
+
captureException2(err);
|
|
16936
17050
|
}
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
{ timeout: 5e3, shell: true },
|
|
16941
|
-
(err, stdout) => {
|
|
16942
|
-
if (err) return;
|
|
16943
|
-
const latest = stdout.trim();
|
|
16944
|
-
try {
|
|
16945
|
-
writeFileSync11(cachePath, JSON.stringify({ lastCheck: Date.now(), latest }));
|
|
16946
|
-
} catch {
|
|
16947
|
-
}
|
|
16948
|
-
if (latest && isNewerVersion(latest, pkg.version)) {
|
|
16949
|
-
console.error(
|
|
16950
|
-
`
|
|
16951
|
-
Update available: ${pkg.version} \u2192 ${latest}
|
|
16952
|
-
Run \`wayai update\` to update.`
|
|
16953
|
-
);
|
|
16954
|
-
}
|
|
16955
|
-
}
|
|
16956
|
-
);
|
|
16957
|
-
} catch {
|
|
17051
|
+
await closeSentry();
|
|
17052
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
17053
|
+
process.exit(1);
|
|
16958
17054
|
}
|
|
16959
17055
|
}
|
|
16960
|
-
|
|
16961
|
-
|
|
16962
|
-
|
|
16963
|
-
|
|
16964
|
-
|
|
16965
|
-
|
|
16966
|
-
|
|
16967
|
-
if (!localVersion) return;
|
|
16968
|
-
const cachePath = getVersionCachePath(SKILL_CACHE_FILE);
|
|
16969
|
-
const cacheDir = dirname7(cachePath);
|
|
16970
|
-
const cache = readVersionCache(SKILL_CACHE_FILE);
|
|
16971
|
-
if (cache && Date.now() - cache.lastCheck < UPDATE_CHECK_INTERVAL_MS) {
|
|
16972
|
-
if (cache.latest && isNewerVersion(cache.latest, localVersion)) {
|
|
16973
|
-
console.error(
|
|
16974
|
-
`
|
|
16975
|
-
Skill update available: ${localVersion} \u2192 ${cache.latest}
|
|
16976
|
-
Run \`npx skills add wayai-pro/wayai-skill -y\` to update.`
|
|
16977
|
-
);
|
|
16978
|
-
}
|
|
16979
|
-
return;
|
|
16980
|
-
}
|
|
16981
|
-
try {
|
|
16982
|
-
if (!existsSync15(cacheDir)) mkdirSync10(cacheDir, { recursive: true });
|
|
16983
|
-
writeFileSync11(cachePath, JSON.stringify({ lastCheck: Date.now(), latest: cache?.latest ?? null }));
|
|
16984
|
-
} catch {
|
|
16985
|
-
}
|
|
16986
|
-
const url = process.env.WAYAI_SKILL_RAW_URL || DEFAULT_SKILL_RAW_URL;
|
|
16987
|
-
const controller = new AbortController();
|
|
16988
|
-
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
16989
|
-
fetch(url, { signal: controller.signal }).then((res) => res.ok ? res.text() : null).then((text) => {
|
|
16990
|
-
clearTimeout(timer);
|
|
16991
|
-
if (!text) return;
|
|
16992
|
-
const latest = parseFrontmatterVersion(text);
|
|
16993
|
-
if (!latest) return;
|
|
16994
|
-
try {
|
|
16995
|
-
writeFileSync11(cachePath, JSON.stringify({ lastCheck: Date.now(), latest }));
|
|
16996
|
-
} catch {
|
|
16997
|
-
}
|
|
16998
|
-
if (isNewerVersion(latest, localVersion)) {
|
|
16999
|
-
console.error(
|
|
17000
|
-
`
|
|
17001
|
-
Skill update available: ${localVersion} \u2192 ${latest}
|
|
17002
|
-
Run \`npx skills add wayai-pro/wayai-skill -y\` to update.`
|
|
17003
|
-
);
|
|
17004
|
-
}
|
|
17005
|
-
}).catch(() => {
|
|
17006
|
-
clearTimeout(timer);
|
|
17007
|
-
});
|
|
17008
|
-
} catch {
|
|
17009
|
-
}
|
|
17056
|
+
if (isBackgroundRefresh) {
|
|
17057
|
+
void refreshVersionCaches({
|
|
17058
|
+
cli: process.env[ENV_REFRESH_CLI] === "1",
|
|
17059
|
+
skill: process.env[ENV_REFRESH_SKILL] === "1"
|
|
17060
|
+
}).finally(() => process.exit(0));
|
|
17061
|
+
} else {
|
|
17062
|
+
void runForeground();
|
|
17010
17063
|
}
|
|
17011
|
-
main().then(async () => {
|
|
17012
|
-
if (command && !SKIP_UPDATE_CHECK.includes(command) && !wantsHelp(args)) {
|
|
17013
|
-
checkForUpdates();
|
|
17014
|
-
checkForSkillUpdates();
|
|
17015
|
-
}
|
|
17016
|
-
await closeSentry();
|
|
17017
|
-
}).catch(async (err) => {
|
|
17018
|
-
if (shouldReportToSentry(err)) {
|
|
17019
|
-
captureException2(err);
|
|
17020
|
-
}
|
|
17021
|
-
await closeSentry();
|
|
17022
|
-
console.error(err instanceof Error ? err.message : String(err));
|
|
17023
|
-
process.exit(1);
|
|
17024
|
-
});
|
|
17025
17064
|
//# sourceMappingURL=index.js.map
|