agent-qa 0.1.2 → 0.1.3

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/cli.cjs CHANGED
@@ -631,9 +631,11 @@ function createInstallBrowsersCommand(deps = {}) {
631
631
  // src/commands/init.ts
632
632
  var import_agent_qa_core4 = require("@vostride/agent-qa-core");
633
633
  init_model_defaults();
634
+ var import_meta2 = {};
634
635
  var INIT_CACHE_DIR = import_agent_qa_core4.DEFAULT_AGENT_QA_CACHE_DIR || ".agent-qa/cache";
635
636
  var INIT_RUNTIME_DIR = import_agent_qa_core4.DEFAULT_AGENT_QA_RUNTIME_DIR || ".agent-qa";
636
637
  var SUBSCRIPTION_AUTH_PACKAGE = "@vostride/agent-qa-subscription-auth";
638
+ var PACKAGE_JSON_FILE = "package.json";
637
639
  var DEFAULT_SCREENSHOT_SIZE = "50kb";
638
640
  var DEFAULT_EFFECTIVE_RESOLUTION = 500;
639
641
  var OPENAI_SUBSCRIPTION_CONFIG = {
@@ -847,6 +849,61 @@ steps:
847
849
  function isSubscriptionProvider(provider) {
848
850
  return provider === "openai-subscription" || provider === "anthropic-subscription";
849
851
  }
852
+ function readAgentQaPackageVersion() {
853
+ try {
854
+ const manifest = JSON.parse((0, import_node_fs.readFileSync)(new URL("../../package.json", import_meta2.url), "utf-8"));
855
+ return typeof manifest.version === "string" && manifest.version.trim() ? manifest.version.trim() : null;
856
+ } catch {
857
+ return null;
858
+ }
859
+ }
860
+ function subscriptionAuthDependencyRange() {
861
+ return readAgentQaPackageVersion() ?? "*";
862
+ }
863
+ function objectRecord(value) {
864
+ return value && typeof value === "object" && !Array.isArray(value) ? value : null;
865
+ }
866
+ function configUsesSubscriptionAuth(config) {
867
+ const plugins = objectRecord(config.plugins);
868
+ const authPlugins = plugins?.auth;
869
+ if (!Array.isArray(authPlugins)) return false;
870
+ return authPlugins.some((plugin) => objectRecord(plugin)?.package === SUBSCRIPTION_AUTH_PACKAGE);
871
+ }
872
+ function upsertSubscriptionAuthPackageDependency(dir) {
873
+ const packageJsonPath = (0, import_node_path4.join)(dir, PACKAGE_JSON_FILE);
874
+ const created = !(0, import_node_fs.existsSync)(packageJsonPath);
875
+ const pkg = created ? { private: true } : JSON.parse((0, import_node_fs.readFileSync)(packageJsonPath, "utf-8"));
876
+ if (!objectRecord(pkg)) {
877
+ throw new Error(`${PACKAGE_JSON_FILE} must contain a JSON object to add ${SUBSCRIPTION_AUTH_PACKAGE}`);
878
+ }
879
+ const dependencyBlocks = ["devDependencies", "dependencies", "optionalDependencies", "peerDependencies"];
880
+ const existingBlock = dependencyBlocks.find((blockName) => {
881
+ const block = objectRecord(pkg[blockName]);
882
+ return block && Object.prototype.hasOwnProperty.call(block, SUBSCRIPTION_AUTH_PACKAGE);
883
+ });
884
+ const targetBlock = existingBlock ?? "devDependencies";
885
+ const targetDependencies = {
886
+ ...objectRecord(pkg[targetBlock]) ?? {},
887
+ [SUBSCRIPTION_AUTH_PACKAGE]: subscriptionAuthDependencyRange()
888
+ };
889
+ pkg[targetBlock] = targetDependencies;
890
+ for (const blockName of dependencyBlocks) {
891
+ if (blockName === targetBlock) continue;
892
+ const block = objectRecord(pkg[blockName]);
893
+ if (!block || !Object.prototype.hasOwnProperty.call(block, SUBSCRIPTION_AUTH_PACKAGE)) continue;
894
+ const nextBlock = { ...block };
895
+ delete nextBlock[SUBSCRIPTION_AUTH_PACKAGE];
896
+ if (Object.keys(nextBlock).length > 0) pkg[blockName] = nextBlock;
897
+ else delete pkg[blockName];
898
+ }
899
+ (0, import_node_fs.writeFileSync)(packageJsonPath, `${JSON.stringify(pkg, null, 2)}
900
+ `);
901
+ return {
902
+ path: packageJsonPath,
903
+ created,
904
+ range: String(targetDependencies[SUBSCRIPTION_AUTH_PACKAGE])
905
+ };
906
+ }
850
907
  function toLLMEntry(config) {
851
908
  const llmEntry = {
852
909
  name: config.name,
@@ -1219,10 +1276,16 @@ function createInitCommand() {
1219
1276
  (0, import_node_fs.mkdirSync)(testsDir, { recursive: true });
1220
1277
  }
1221
1278
  const config = buildDefaultConfig(platform, llmConfigs ?? provider, model, baseURL);
1279
+ const usesSubscriptionAuth = configUsesSubscriptionAuth(config);
1222
1280
  const yamlStr = (0, import_yaml3.stringify)(config);
1223
1281
  const configContent = addYamlComments(yamlStr);
1224
1282
  (0, import_node_fs.writeFileSync)(configPath, configContent);
1225
1283
  console.log(import_picocolors4.default.green(`\u2713 Created ${configPath}`));
1284
+ const subscriptionAuthDependency = usesSubscriptionAuth ? upsertSubscriptionAuthPackageDependency(dir) : null;
1285
+ if (subscriptionAuthDependency) {
1286
+ const action = subscriptionAuthDependency.created ? "Created" : "Updated";
1287
+ console.log(import_picocolors4.default.green(`\u2713 ${action} ${subscriptionAuthDependency.path}`));
1288
+ }
1226
1289
  const secretsPath = (0, import_node_path4.join)(dir, DEFAULT_SECRETS_FILE);
1227
1290
  if (force || !(0, import_node_fs.existsSync)(secretsPath)) {
1228
1291
  (0, import_node_fs.writeFileSync)(secretsPath, "");
@@ -1293,6 +1356,9 @@ function createInitCommand() {
1293
1356
  console.log("");
1294
1357
  console.log(" Created:");
1295
1358
  console.log(` ${import_picocolors4.default.dim("\u2022")} agent-qa.config.yaml`);
1359
+ if (subscriptionAuthDependency) {
1360
+ console.log(` ${import_picocolors4.default.dim("\u2022")} ${PACKAGE_JSON_FILE} dependency for ${SUBSCRIPTION_AUTH_PACKAGE}@${subscriptionAuthDependency.range}`);
1361
+ }
1296
1362
  console.log(` ${import_picocolors4.default.dim("\u2022")} ${DEFAULT_HOOKS_FILE}`);
1297
1363
  console.log(` ${import_picocolors4.default.dim("\u2022")} ${DEFAULT_AGENT_RULES_FILE}`);
1298
1364
  console.log(` ${import_picocolors4.default.dim("\u2022")} ${DEFAULT_ENV_FILE}`);
@@ -1324,7 +1390,7 @@ function createInitCommand() {
1324
1390
  console.log(` ${import_picocolors4.default.dim("\u2022")} Bearer tokens use ${import_picocolors4.default.cyan("agent-qa auth set --config default --type bearer-token")}`);
1325
1391
  }
1326
1392
  } else {
1327
- console.log(` ${import_picocolors4.default.dim("\u2022")} Install subscription auth with ${import_picocolors4.default.cyan(`npm install -D ${SUBSCRIPTION_AUTH_PACKAGE}`)}`);
1393
+ console.log(` ${import_picocolors4.default.dim("\u2022")} Fetch ${SUBSCRIPTION_AUTH_PACKAGE} with your package manager install command`);
1328
1394
  for (const llm of subscriptionLLMs) {
1329
1395
  console.log(` ${import_picocolors4.default.dim("\u2022")} Authenticate ${import_picocolors4.default.cyan(String(llm.name))} from ${import_picocolors4.default.cyan("agent-qa dashboard")}`);
1330
1396
  }
@@ -4214,7 +4280,7 @@ var import_agent_qa_core9 = require("@vostride/agent-qa-core");
4214
4280
  init_config();
4215
4281
  init_llm_utils();
4216
4282
  init_model_defaults();
4217
- var import_meta2 = {};
4283
+ var import_meta3 = {};
4218
4284
  async function startDashboardBackedServices(opts, command, labels) {
4219
4285
  try {
4220
4286
  const program2 = command.parent;
@@ -4261,7 +4327,7 @@ async function startDashboardBackedServices(opts, command, labels) {
4261
4327
  });
4262
4328
  let uiDir;
4263
4329
  try {
4264
- const require2 = (0, import_node_module2.createRequire)(import_meta2.url);
4330
+ const require2 = (0, import_node_module2.createRequire)(import_meta3.url);
4265
4331
  const pkgPath = require2.resolve("@vostride/agent-qa-dashboard-ui/package.json");
4266
4332
  uiDir = (0, import_node_path8.resolve)((0, import_node_path8.dirname)(pkgPath), "dist");
4267
4333
  } catch {
@@ -4714,8 +4780,8 @@ function printMissingSubscriptionPluginGuidance(configName, provider) {
4714
4780
  console.log(import_picocolors11.default.red(`Provider "${provider}" is configured for "${configName}", but no auth plugin is registered.`));
4715
4781
  console.log(import_picocolors11.default.dim(`Config: ${configName}`));
4716
4782
  console.log(import_picocolors11.default.dim(`Provider: ${provider}`));
4717
- console.log(import_picocolors11.default.dim("Install the subscription auth plugin:"));
4718
- console.log(import_picocolors11.default.dim(" npm install -D @vostride/agent-qa-subscription-auth"));
4783
+ console.log(import_picocolors11.default.dim("Add the subscription auth plugin to package.json and install with your package manager:"));
4784
+ console.log(import_picocolors11.default.dim(' "devDependencies": { "@vostride/agent-qa-subscription-auth": "<agent-qa version>" }'));
4719
4785
  console.log(import_picocolors11.default.dim("Declare it in agent-qa.config.yaml under plugins.auth:"));
4720
4786
  console.log(import_picocolors11.default.dim(" plugins:"));
4721
4787
  console.log(import_picocolors11.default.dim(" auth:"));
@@ -5428,7 +5494,7 @@ var import_commander17 = require("commander");
5428
5494
  var import_node_fs8 = require("fs");
5429
5495
  var import_node_path13 = require("path");
5430
5496
  var import_node_url = require("url");
5431
- var import_meta3 = {};
5497
+ var import_meta4 = {};
5432
5498
  function findPackageRoot(startDir) {
5433
5499
  let current = (0, import_node_path13.resolve)(startDir);
5434
5500
  while (true) {
@@ -5460,7 +5526,7 @@ function hasSkillDirectories(dir) {
5460
5526
  return false;
5461
5527
  }
5462
5528
  }
5463
- function resolveAgentQaSkillsDirectory(startDir = (0, import_node_path13.dirname)((0, import_node_url.fileURLToPath)(import_meta3.url))) {
5529
+ function resolveAgentQaSkillsDirectory(startDir = (0, import_node_path13.dirname)((0, import_node_url.fileURLToPath)(import_meta4.url))) {
5464
5530
  const packageRoot = findPackageRoot(startDir);
5465
5531
  const packagedSkills = (0, import_node_path13.join)(packageRoot, "skills");
5466
5532
  if (hasSkillDirectories(packagedSkills)) {