@wayai/cli 0.3.55 → 0.3.57

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
@@ -174,6 +174,11 @@ var init_sentry = __esm({
174
174
  });
175
175
 
176
176
  // src/lib/api-client.ts
177
+ var api_client_exports = {};
178
+ __export(api_client_exports, {
179
+ ApiClient: () => ApiClient,
180
+ ApiError: () => ApiError
181
+ });
177
182
  function isRetryableErrorBody(body) {
178
183
  try {
179
184
  const parsed = JSON.parse(body);
@@ -8230,13 +8235,14 @@ function writeVersionCache(filename, cache) {
8230
8235
  function touchVersionCache(filename) {
8231
8236
  writeVersionCache(filename, { lastCheck: Date.now(), latest: readVersionCache(filename)?.latest ?? null });
8232
8237
  }
8233
- var MAX_AGE_24H_MS, CLI_CACHE_FILE, SKILL_CACHE_FILE;
8238
+ var MAX_AGE_24H_MS, CLI_CACHE_FILE, SKILL_CACHE_FILE, ADMIN_SKILL_CACHE_FILE;
8234
8239
  var init_version_cache = __esm({
8235
8240
  "src/lib/version-cache.ts"() {
8236
8241
  "use strict";
8237
8242
  MAX_AGE_24H_MS = 24 * 60 * 60 * 1e3;
8238
8243
  CLI_CACHE_FILE = "update-check.json";
8239
8244
  SKILL_CACHE_FILE = "skill-update-check.json";
8245
+ ADMIN_SKILL_CACHE_FILE = "admin-skill-update-check.json";
8240
8246
  }
8241
8247
  });
8242
8248
 
@@ -8244,6 +8250,9 @@ var init_version_cache = __esm({
8244
8250
  import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
8245
8251
  import { join as join7 } from "path";
8246
8252
  import * as yaml3 from "js-yaml";
8253
+ function skillInstallPaths(skillName) {
8254
+ return HARNESS_SKILL_DIRS.map((dir) => `${dir}/skills/${skillName}/${SKILL_FILENAME}`);
8255
+ }
8247
8256
  function parseFrontmatterVersion(content) {
8248
8257
  const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(content);
8249
8258
  if (!match) return null;
@@ -8257,9 +8266,9 @@ function parseFrontmatterVersion(content) {
8257
8266
  const v = parsed.version;
8258
8267
  return typeof v === "string" ? v : null;
8259
8268
  }
8260
- function findInstalledSkills(projectRoot) {
8269
+ function findInstalledSkills(projectRoot, paths = SKILL_INSTALL_PATHS) {
8261
8270
  const found = [];
8262
- for (const rel of SKILL_INSTALL_PATHS) {
8271
+ for (const rel of paths) {
8263
8272
  const path22 = join7(projectRoot, rel);
8264
8273
  if (!existsSync5(path22)) continue;
8265
8274
  let version = null;
@@ -8276,21 +8285,28 @@ function lowestInstalledVersion(installs) {
8276
8285
  if (versions.length === 0) return null;
8277
8286
  return versions.reduce((lowest, v) => isNewerVersion(lowest, v) ? v : lowest);
8278
8287
  }
8279
- var DEFAULT_SKILL_RAW_URL, SKILL_INSTALL_PATHS;
8288
+ var DEFAULT_SKILL_RAW_URL, HARNESS_SKILL_DIRS, SKILL_FILENAME, SKILL_INSTALL_PATHS, ADMIN_SKILL_NAME, ADMIN_SKILL_INSTALL_PATHS;
8280
8289
  var init_skill_version = __esm({
8281
8290
  "src/lib/skill-version.ts"() {
8282
8291
  "use strict";
8283
8292
  init_utils();
8284
8293
  DEFAULT_SKILL_RAW_URL = "https://raw.githubusercontent.com/wayai-pro/wayai-skill/main/skills/wayai/SKILL.md";
8285
- SKILL_INSTALL_PATHS = [
8286
- ".claude/skills/wayai/SKILL.md",
8287
- ".opencode/skills/wayai/SKILL.md",
8288
- ".agents/skills/wayai/SKILL.md"
8289
- ];
8294
+ HARNESS_SKILL_DIRS = [".claude", ".opencode", ".agents"];
8295
+ SKILL_FILENAME = "SKILL.md";
8296
+ SKILL_INSTALL_PATHS = skillInstallPaths("wayai");
8297
+ ADMIN_SKILL_NAME = "wayai-admin";
8298
+ ADMIN_SKILL_INSTALL_PATHS = skillInstallPaths(ADMIN_SKILL_NAME);
8290
8299
  }
8291
8300
  });
8292
8301
 
8293
8302
  // src/lib/config.ts
8303
+ var config_exports = {};
8304
+ __export(config_exports, {
8305
+ deleteConfig: () => deleteConfig,
8306
+ getConfigPath: () => getConfigPath,
8307
+ readConfig: () => readConfig,
8308
+ writeConfig: () => writeConfig
8309
+ });
8294
8310
  import * as fs5 from "fs";
8295
8311
  import * as path5 from "path";
8296
8312
  import * as os from "os";
@@ -8300,6 +8316,9 @@ function configDir() {
8300
8316
  function configPath() {
8301
8317
  return path5.join(configDir(), "config.json");
8302
8318
  }
8319
+ function getConfigPath() {
8320
+ return configPath();
8321
+ }
8303
8322
  function readConfig() {
8304
8323
  if (!fs5.existsSync(configPath())) return null;
8305
8324
  try {
@@ -8335,6 +8354,11 @@ function writeConfig(config) {
8335
8354
  // owner-only read/write
8336
8355
  });
8337
8356
  }
8357
+ function deleteConfig() {
8358
+ if (fs5.existsSync(configPath())) {
8359
+ fs5.unlinkSync(configPath());
8360
+ }
8361
+ }
8338
8362
  var init_config = __esm({
8339
8363
  "src/lib/config.ts"() {
8340
8364
  "use strict";
@@ -8629,6 +8653,22 @@ var init_token_store = __esm({
8629
8653
  });
8630
8654
 
8631
8655
  // src/lib/auth.ts
8656
+ var auth_exports = {};
8657
+ __export(auth_exports, {
8658
+ OAUTH_CALLBACK_PORT: () => OAUTH_CALLBACK_PORT,
8659
+ exchangeCodeForTokens: () => exchangeCodeForTokens,
8660
+ expiresInToIso: () => expiresInToIso,
8661
+ generateCodeChallenge: () => generateCodeChallenge,
8662
+ generateCodeVerifier: () => generateCodeVerifier,
8663
+ generateState: () => generateState,
8664
+ getAccessToken: () => getAccessToken,
8665
+ getAuthKitClientId: () => getAuthKitClientId,
8666
+ getAuthKitDomain: () => getAuthKitDomain,
8667
+ refreshAccessToken: () => refreshAccessToken,
8668
+ requireAuth: () => requireAuth,
8669
+ startCallbackServer: () => startCallbackServer,
8670
+ validateToken: () => validateToken
8671
+ });
8632
8672
  import * as crypto2 from "crypto";
8633
8673
  import * as http from "http";
8634
8674
  function generateCodeVerifier() {
@@ -17301,9 +17341,15 @@ async function runSkillInstall(positional) {
17301
17341
  throw err;
17302
17342
  }
17303
17343
  const root = findGitRoot() ?? process.cwd();
17304
- const targetDir = path21.join(root, ".claude", "skills", name);
17305
- const written = writeFileMap(targetDir, res.files);
17306
- console.log(`Installed skill "${name}" \u2192 ${path21.relative(root, targetDir)}/ (${written.length} file${written.length === 1 ? "" : "s"}).`);
17344
+ const present = HARNESS_SKILL_DIRS.filter((dir) => fs17.existsSync(path21.join(root, dir)));
17345
+ const targets = present.length > 0 ? present : HARNESS_SKILL_DIRS;
17346
+ const fileCount = Object.keys(res.files).length;
17347
+ const relDirs = targets.map((harness) => {
17348
+ const targetDir = path21.join(root, harness, "skills", name);
17349
+ writeFileMap(targetDir, res.files);
17350
+ return `${path21.relative(root, targetDir)}/`;
17351
+ });
17352
+ console.log(`Installed skill "${name}" (${fileCount} file${fileCount === 1 ? "" : "s"}) \u2192 ${relDirs.join(", ")}`);
17307
17353
  console.log("Reload your agent (e.g. restart Claude Code) to pick up the skill.");
17308
17354
  }
17309
17355
  function exitOnApiError(err) {
@@ -17720,7 +17766,7 @@ Usage:
17720
17766
  wayai admin template push <slug> Publish a template from tutorials/templates/<slug>/ into the store
17721
17767
  wayai admin template pull <slug> [--out DIR] [--json] Pull a published template from the store for inspection
17722
17768
 
17723
- wayai admin skill install [name] Install a private operator skill (default: wayai-admin) into .claude/skills/
17769
+ wayai admin skill install [name] Install a private operator skill (default: wayai-admin) into each present harness's skills/ dir
17724
17770
 
17725
17771
  Sources:
17726
17772
  do Live DO SQLite (existing conversation, hub config, etc.).
@@ -17780,6 +17826,7 @@ var init_admin = __esm({
17780
17826
  init_observability();
17781
17827
  init_report_edit_args();
17782
17828
  init_workspace();
17829
+ init_skill_version();
17783
17830
  init_layout();
17784
17831
  init_template_files();
17785
17832
  init_contracts();
@@ -18239,10 +18286,39 @@ async function refreshSkillCache() {
18239
18286
  clearTimeout(timer);
18240
18287
  }
18241
18288
  }
18289
+ async function refreshAdminSkillCache() {
18290
+ let timer;
18291
+ const deadline = new Promise((resolve5) => {
18292
+ timer = setTimeout(resolve5, REFRESH_TIMEOUT_MS);
18293
+ });
18294
+ await Promise.race([deadline, fetchAndCacheAdminSkillVersion().catch(() => {
18295
+ })]);
18296
+ if (timer) clearTimeout(timer);
18297
+ }
18298
+ async function fetchAndCacheAdminSkillVersion() {
18299
+ const [{ readConfig: readConfig2 }, { getAccessToken: getAccessToken2 }, { ApiClient: ApiClient2 }] = await Promise.all([
18300
+ Promise.resolve().then(() => (init_config(), config_exports)),
18301
+ Promise.resolve().then(() => (init_auth(), auth_exports)),
18302
+ Promise.resolve().then(() => (init_api_client(), api_client_exports))
18303
+ ]);
18304
+ const config = readConfig2();
18305
+ if (!config) return;
18306
+ const accessToken = await getAccessToken2(config);
18307
+ const client = new ApiClient2({ apiUrl: config.api_url, accessToken });
18308
+ const res = await client.adminSkillInstall(ADMIN_SKILL_NAME);
18309
+ const latest = parseFrontmatterVersion(res.files[SKILL_FILENAME] ?? "");
18310
+ if (latest) {
18311
+ try {
18312
+ writeVersionCache(ADMIN_SKILL_CACHE_FILE, { lastCheck: Date.now(), latest });
18313
+ } catch {
18314
+ }
18315
+ }
18316
+ }
18242
18317
  async function refreshVersionCaches(opts) {
18243
18318
  await Promise.all([
18244
18319
  opts.cli ? refreshCliCache() : Promise.resolve(),
18245
- opts.skill ? refreshSkillCache() : Promise.resolve()
18320
+ opts.skill ? refreshSkillCache() : Promise.resolve(),
18321
+ opts.adminSkill ? refreshAdminSkillCache() : Promise.resolve()
18246
18322
  ]);
18247
18323
  }
18248
18324
 
@@ -18255,6 +18331,7 @@ import { spawn } from "child_process";
18255
18331
  var REFRESH_COMMAND = "__refresh-version-cache";
18256
18332
  var ENV_REFRESH_CLI = "WAYAI_REFRESH_CLI";
18257
18333
  var ENV_REFRESH_SKILL = "WAYAI_REFRESH_SKILL";
18334
+ var ENV_REFRESH_ADMIN_SKILL = "WAYAI_REFRESH_ADMIN_SKILL";
18258
18335
  function isUpdateCheckDisabled() {
18259
18336
  return Boolean(
18260
18337
  process.env.NO_UPDATE_NOTIFIER || process.env.WAYAI_NO_UPDATE_CHECK || process.env.CI
@@ -18264,6 +18341,7 @@ function scheduleVersionRefresh(opts, entryPath) {
18264
18341
  try {
18265
18342
  if (opts.cli) touchVersionCache(CLI_CACHE_FILE);
18266
18343
  if (opts.skill) touchVersionCache(SKILL_CACHE_FILE);
18344
+ if (opts.adminSkill) touchVersionCache(ADMIN_SKILL_CACHE_FILE);
18267
18345
  spawn(process.execPath, [entryPath, REFRESH_COMMAND], {
18268
18346
  detached: true,
18269
18347
  stdio: "ignore",
@@ -18272,7 +18350,8 @@ function scheduleVersionRefresh(opts, entryPath) {
18272
18350
  env: {
18273
18351
  ...process.env,
18274
18352
  [ENV_REFRESH_CLI]: opts.cli ? "1" : "",
18275
- [ENV_REFRESH_SKILL]: opts.skill ? "1" : ""
18353
+ [ENV_REFRESH_SKILL]: opts.skill ? "1" : "",
18354
+ [ENV_REFRESH_ADMIN_SKILL]: opts.adminSkill ? "1" : ""
18276
18355
  }
18277
18356
  }).unref();
18278
18357
  } catch {
@@ -18287,7 +18366,8 @@ function showUpdateNudges(currentVersion, entryPath) {
18287
18366
  Update available: ${currentVersion} \u2192 ${cliLatest}
18288
18367
  Run \`wayai update\` to update.`);
18289
18368
  }
18290
- const installs = findInstalledSkills(findRepoRootSync() ?? process.cwd());
18369
+ const repoRoot = findRepoRootSync() ?? process.cwd();
18370
+ const installs = findInstalledSkills(repoRoot);
18291
18371
  const localSkillVersion = installs.length > 0 ? lowestInstalledVersion(installs) : null;
18292
18372
  if (localSkillVersion) {
18293
18373
  const skillLatest = readVersionCache(SKILL_CACHE_FILE)?.latest ?? null;
@@ -18297,10 +18377,21 @@ Skill update available: ${localSkillVersion} \u2192 ${skillLatest}
18297
18377
  Run \`npx skills add wayai-pro/wayai-skill -y\` to update.`);
18298
18378
  }
18299
18379
  }
18380
+ const adminInstalls = findInstalledSkills(repoRoot, ADMIN_SKILL_INSTALL_PATHS);
18381
+ const localAdminVersion = adminInstalls.length > 0 ? lowestInstalledVersion(adminInstalls) : null;
18382
+ if (localAdminVersion) {
18383
+ const adminLatest = readVersionCache(ADMIN_SKILL_CACHE_FILE)?.latest ?? null;
18384
+ if (adminLatest && isNewerVersion(adminLatest, localAdminVersion)) {
18385
+ console.error(`
18386
+ Admin skill update available: ${localAdminVersion} \u2192 ${adminLatest}
18387
+ Run \`wayai admin skill install\` to update.`);
18388
+ }
18389
+ }
18300
18390
  const cliStale = isVersionCacheStale(CLI_CACHE_FILE);
18301
18391
  const skillStale = localSkillVersion !== null && isVersionCacheStale(SKILL_CACHE_FILE);
18302
- if (cliStale || skillStale) {
18303
- scheduleVersionRefresh({ cli: cliStale, skill: skillStale }, entryPath);
18392
+ const adminSkillStale = localAdminVersion !== null && isVersionCacheStale(ADMIN_SKILL_CACHE_FILE);
18393
+ if (cliStale || skillStale || adminSkillStale) {
18394
+ scheduleVersionRefresh({ cli: cliStale, skill: skillStale, adminSkill: adminSkillStale }, entryPath);
18304
18395
  }
18305
18396
  } catch {
18306
18397
  }
@@ -18595,7 +18686,8 @@ async function runForeground() {
18595
18686
  if (isBackgroundRefresh) {
18596
18687
  void refreshVersionCaches({
18597
18688
  cli: process.env[ENV_REFRESH_CLI] === "1",
18598
- skill: process.env[ENV_REFRESH_SKILL] === "1"
18689
+ skill: process.env[ENV_REFRESH_SKILL] === "1",
18690
+ adminSkill: process.env[ENV_REFRESH_ADMIN_SKILL] === "1"
18599
18691
  }).finally(() => process.exit(0));
18600
18692
  } else {
18601
18693
  void runForeground();