@dalmia/calibrate-mcp 0.0.31 → 0.0.33

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.
Files changed (62) hide show
  1. package/bin/mcp-server.js +658 -396
  2. package/bin/mcp-server.js.map +20 -20
  3. package/esm/landing-page.js +1 -1
  4. package/esm/lib/config.d.ts +2 -2
  5. package/esm/lib/config.js +2 -2
  6. package/esm/mcp-server/mcp-server.js +1 -1
  7. package/esm/mcp-server/server.js +1 -1
  8. package/esm/models/{routersagentsagentresponse.d.ts → agentresponse.d.ts} +7 -7
  9. package/esm/models/agentresponse.d.ts.map +1 -0
  10. package/esm/models/{routersagentsagentresponse.js → agentresponse.js} +5 -5
  11. package/esm/models/agentresponse.js.map +1 -0
  12. package/esm/models/agentsummary.d.ts +2 -0
  13. package/esm/models/agentsummary.d.ts.map +1 -1
  14. package/esm/models/agentsummary.js +2 -0
  15. package/esm/models/agentsummary.js.map +1 -1
  16. package/esm/models/annotationtaskresponse.d.ts +1 -0
  17. package/esm/models/annotationtaskresponse.d.ts.map +1 -1
  18. package/esm/models/annotationtaskresponse.js +1 -0
  19. package/esm/models/annotationtaskresponse.js.map +1 -1
  20. package/esm/models/benchmarkstatusresponse.d.ts +1 -0
  21. package/esm/models/benchmarkstatusresponse.d.ts.map +1 -1
  22. package/esm/models/benchmarkstatusresponse.js +1 -0
  23. package/esm/models/benchmarkstatusresponse.js.map +1 -1
  24. package/esm/models/bulktestitem.d.ts +3 -0
  25. package/esm/models/bulktestitem.d.ts.map +1 -1
  26. package/esm/models/bulktestitem.js +1 -0
  27. package/esm/models/bulktestitem.js.map +1 -1
  28. package/esm/models/getagentendpointagentsagentuuidgetop.d.ts +2 -2
  29. package/esm/models/getagentendpointagentsagentuuidgetop.d.ts.map +1 -1
  30. package/esm/models/getagentendpointagentsagentuuidgetop.js +2 -2
  31. package/esm/models/getagentendpointagentsagentuuidgetop.js.map +1 -1
  32. package/esm/models/taskagreementresponse.js +1 -1
  33. package/esm/models/taskagreementresponse.js.map +1 -1
  34. package/esm/models/testcaseresult.d.ts +3 -0
  35. package/esm/models/testcaseresult.d.ts.map +1 -1
  36. package/esm/models/testcaseresult.js +1 -0
  37. package/esm/models/testcaseresult.js.map +1 -1
  38. package/esm/models/testrunstatusresponse.d.ts +1 -0
  39. package/esm/models/testrunstatusresponse.d.ts.map +1 -1
  40. package/esm/models/testrunstatusresponse.js +1 -0
  41. package/esm/models/testrunstatusresponse.js.map +1 -1
  42. package/esm/models/updateagentendpointagentsagentuuidputop.d.ts +2 -2
  43. package/esm/models/updateagentendpointagentsagentuuidputop.d.ts.map +1 -1
  44. package/esm/models/updateagentendpointagentsagentuuidputop.js +2 -2
  45. package/esm/models/updateagentendpointagentsagentuuidputop.js.map +1 -1
  46. package/package.json +1 -1
  47. package/src/landing-page.ts +1 -1
  48. package/src/lib/config.ts +2 -2
  49. package/src/mcp-server/mcp-server.ts +1 -1
  50. package/src/mcp-server/server.ts +1 -1
  51. package/src/models/{routersagentsagentresponse.ts → agentresponse.ts} +7 -11
  52. package/src/models/agentsummary.ts +6 -0
  53. package/src/models/annotationtaskresponse.ts +4 -0
  54. package/src/models/benchmarkstatusresponse.ts +4 -0
  55. package/src/models/bulktestitem.ts +4 -0
  56. package/src/models/getagentendpointagentsagentuuidgetop.ts +3 -6
  57. package/src/models/taskagreementresponse.ts +1 -1
  58. package/src/models/testcaseresult.ts +4 -0
  59. package/src/models/testrunstatusresponse.ts +4 -0
  60. package/src/models/updateagentendpointagentsagentuuidputop.ts +3 -6
  61. package/esm/models/routersagentsagentresponse.d.ts.map +0 -1
  62. package/esm/models/routersagentsagentresponse.js.map +0 -1
package/bin/mcp-server.js CHANGED
@@ -1021,10 +1021,10 @@ function datetime(args) {
1021
1021
  const timeRegex = `${time2}(?:${opts.join("|")})`;
1022
1022
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
1023
1023
  }
1024
- var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid = (version) => {
1025
- if (!version)
1024
+ var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid = (version2) => {
1025
+ if (!version2)
1026
1026
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
1027
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
1027
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
1028
1028
  }, email, _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, httpProtocol, e164, dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`, date, string = (params) => {
1029
1029
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
1030
1030
  return new RegExp(`^${regex}$`);
@@ -1491,9 +1491,9 @@ class Doc {
1491
1491
  }
1492
1492
 
1493
1493
  // node_modules/zod/v4/core/versions.js
1494
- var version;
1494
+ var version2;
1495
1495
  var init_versions = __esm(() => {
1496
- version = {
1496
+ version2 = {
1497
1497
  major: 4,
1498
1498
  minor: 4,
1499
1499
  patch: 3
@@ -1793,7 +1793,7 @@ var init_schemas = __esm(() => {
1793
1793
  inst ?? (inst = {});
1794
1794
  inst._zod.def = def;
1795
1795
  inst._zod.bag = inst._zod.bag || {};
1796
- inst._zod.version = version;
1796
+ inst._zod.version = version2;
1797
1797
  const checks = [...inst._zod.def.checks ?? []];
1798
1798
  if (inst._zod.traits.has("$ZodCheck")) {
1799
1799
  checks.unshift(inst);
@@ -8247,10 +8247,10 @@ var require_supports_color = __commonJS((exports, module) => {
8247
8247
  return 3;
8248
8248
  }
8249
8249
  if ("TERM_PROGRAM" in env) {
8250
- const version2 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
8250
+ const version3 = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
8251
8251
  switch (env.TERM_PROGRAM) {
8252
8252
  case "iTerm.app":
8253
- return version2 >= 3 ? 3 : 2;
8253
+ return version3 >= 3 ? 3 : 2;
8254
8254
  case "Apple_Terminal":
8255
8255
  return 2;
8256
8256
  }
@@ -22971,18 +22971,12 @@ var require_media_typer = __commonJS((exports) => {
22971
22971
  return string4;
22972
22972
  }
22973
22973
  function test(string4) {
22974
- if (!string4) {
22975
- throw new TypeError("argument string is required");
22976
- }
22977
22974
  if (typeof string4 !== "string") {
22978
22975
  throw new TypeError("argument string is required to be a string");
22979
22976
  }
22980
22977
  return TYPE_REGEXP.test(string4.toLowerCase());
22981
22978
  }
22982
22979
  function parse5(string4) {
22983
- if (!string4) {
22984
- throw new TypeError("argument string is required");
22985
- }
22986
22980
  if (typeof string4 !== "string") {
22987
22981
  throw new TypeError("argument string is required to be a string");
22988
22982
  }
@@ -32341,11 +32335,11 @@ function datetimeRegex(args) {
32341
32335
  regex = `${regex}(${opts.join("|")})`;
32342
32336
  return new RegExp(`^${regex}$`);
32343
32337
  }
32344
- function isValidIP(ip, version2) {
32345
- if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
32338
+ function isValidIP(ip, version3) {
32339
+ if ((version3 === "v4" || !version3) && ipv4Regex.test(ip)) {
32346
32340
  return true;
32347
32341
  }
32348
- if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
32342
+ if ((version3 === "v6" || !version3) && ipv6Regex.test(ip)) {
32349
32343
  return true;
32350
32344
  }
32351
32345
  return false;
@@ -32372,11 +32366,11 @@ function isValidJWT2(jwt, alg) {
32372
32366
  return false;
32373
32367
  }
32374
32368
  }
32375
- function isValidCidr(ip, version2) {
32376
- if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
32369
+ function isValidCidr(ip, version3) {
32370
+ if ((version3 === "v4" || !version3) && ipv4CidrRegex.test(ip)) {
32377
32371
  return true;
32378
32372
  }
32379
- if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
32373
+ if ((version3 === "v6" || !version3) && ipv6CidrRegex.test(ip)) {
32380
32374
  return true;
32381
32375
  }
32382
32376
  return false;
@@ -41433,7 +41427,12 @@ var require_fast_uri = __commonJS((exports, module) => {
41433
41427
  }
41434
41428
  function resolve(baseURI, relativeURI, options) {
41435
41429
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
41436
- const resolved = resolveComponent(parse6(baseURI, schemelessOptions), parse6(relativeURI, schemelessOptions), schemelessOptions, true);
41430
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
41431
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
41432
+ if (baseMalformed || relativeMalformed) {
41433
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
41434
+ }
41435
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
41437
41436
  schemelessOptions.skipEscape = true;
41438
41437
  return serialize(resolved, schemelessOptions);
41439
41438
  }
@@ -41559,6 +41558,8 @@ var require_fast_uri = __commonJS((exports, module) => {
41559
41558
  return uriTokens.join("");
41560
41559
  }
41561
41560
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
41561
+ var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
41562
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
41562
41563
  function getParseError(parsed, matches) {
41563
41564
  if (matches[2] !== undefined && parsed.path && parsed.path[0] !== "/") {
41564
41565
  return 'URI path must start with "/" when authority is present.';
@@ -41588,6 +41589,25 @@ var require_fast_uri = __commonJS((exports, module) => {
41588
41589
  uri = "//" + uri;
41589
41590
  }
41590
41591
  }
41592
+ const authorityMatch = uri.match(AUTHORITY_PREFIX);
41593
+ if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
41594
+ parsed.error = "URI authority must not contain a literal backslash.";
41595
+ malformedAuthorityOrPort = true;
41596
+ }
41597
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
41598
+ if (introducerMatch !== null) {
41599
+ const region = introducerMatch[1];
41600
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
41601
+ if (normalizedRegion.length >= 2) {
41602
+ if (normalizedRegion.slice(0, 2) !== "//") {
41603
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
41604
+ malformedAuthorityOrPort = true;
41605
+ } else if (region.length !== normalizedRegion.length) {
41606
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
41607
+ malformedAuthorityOrPort = true;
41608
+ }
41609
+ }
41610
+ }
41591
41611
  const matches = uri.match(URI_PARSE);
41592
41612
  if (matches) {
41593
41613
  parsed.scheme = matches[1] === undefined ? undefined : matches[1].toLowerCase();
@@ -51392,9 +51412,9 @@ var init_config = __esm(() => {
51392
51412
  SDK_METADATA = {
51393
51413
  language: "typescript",
51394
51414
  openapiDocVersion: "0.1.0",
51395
- sdkVersion: "0.0.31",
51415
+ sdkVersion: "0.0.33",
51396
51416
  genVersion: "2.915.1",
51397
- userAgent: "speakeasy-sdk/mcp-typescript 0.0.31 2.915.1 0.1.0 @dalmia/calibrate-mcp"
51417
+ userAgent: "speakeasy-sdk/mcp-typescript 0.0.33 2.915.1 0.1.0 @dalmia/calibrate-mcp"
51398
51418
  };
51399
51419
  });
51400
51420
 
@@ -53053,19 +53073,19 @@ Requires a Calibrate API key (CALIBRATE_API_KEY).
53053
53073
  };
53054
53074
  });
53055
53075
 
53056
- // src/models/routersagentsagentresponse.ts
53057
- var RoutersAgentsAgentResponseType$zodSchema, RoutersAgentsAgentResponse$zodSchema;
53058
- var init_routersagentsagentresponse = __esm(() => {
53076
+ // src/models/agentresponse.ts
53077
+ var AgentResponseType$zodSchema, AgentResponse$zodSchema;
53078
+ var init_agentresponse = __esm(() => {
53059
53079
  init_zod();
53060
- RoutersAgentsAgentResponseType$zodSchema = _enum([
53080
+ AgentResponseType$zodSchema = _enum([
53061
53081
  "agent",
53062
53082
  "connection"
53063
53083
  ]).describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate");
53064
- RoutersAgentsAgentResponse$zodSchema = object({
53084
+ AgentResponse$zodSchema = object({
53065
53085
  config: record(string2(), any()).nullable().optional().describe("Agent configuration"),
53066
53086
  created_at: string2().describe("When the agent was created (ISO 8601 UTC)"),
53067
53087
  name: string2().describe("Name of the agent"),
53068
- type: RoutersAgentsAgentResponseType$zodSchema.describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate"),
53088
+ type: AgentResponseType$zodSchema.describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate"),
53069
53089
  updated_at: string2().describe("When the agent was last updated (ISO 8601 UTC)"),
53070
53090
  uuid: string2().describe("ID of the agent")
53071
53091
  });
@@ -53075,14 +53095,14 @@ var init_routersagentsagentresponse = __esm(() => {
53075
53095
  var GetAgentEndpointAgentsAgentUuidGetRequest$zodSchema, GetAgentEndpointAgentsAgentUuidGetResponse$zodSchema;
53076
53096
  var init_getagentendpointagentsagentuuidgetop = __esm(() => {
53077
53097
  init_zod();
53098
+ init_agentresponse();
53078
53099
  init_httpvalidationerror();
53079
- init_routersagentsagentresponse();
53080
53100
  GetAgentEndpointAgentsAgentUuidGetRequest$zodSchema = object({
53081
53101
  agent_uuid: string2().describe("The agent to retrieve"),
53082
53102
  xAPIKey: string2().nullable().optional()
53083
53103
  });
53084
53104
  GetAgentEndpointAgentsAgentUuidGetResponse$zodSchema = union([
53085
- RoutersAgentsAgentResponse$zodSchema,
53105
+ AgentResponse$zodSchema,
53086
53106
  HTTPValidationError$zodSchema
53087
53107
  ]);
53088
53108
  });
@@ -53374,6 +53394,8 @@ var init_agentsummary = __esm(() => {
53374
53394
  ]).describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate");
53375
53395
  AgentSummary$zodSchema = object({
53376
53396
  connection_verified: boolean2().nullable().optional().describe("Whether the agent's connection has been verified, for a `type=connection` agent"),
53397
+ created_at: string2().describe("When the agent was created (ISO 8601 UTC)"),
53398
+ has_default_inputs: boolean2().describe("Whether the agent has custom request fields configured"),
53377
53399
  name: string2().describe("Name of the agent"),
53378
53400
  type: AgentSummaryType$zodSchema.describe("- `agent`: built inside Calibrate\n- `connection`: your existing agent connected to Calibrate"),
53379
53401
  updated_at: string2().describe("When the agent was last updated (ISO 8601 UTC)"),
@@ -53914,16 +53936,16 @@ var init_agentupdate = __esm(() => {
53914
53936
  var UpdateAgentEndpointAgentsAgentUuidPutRequest$zodSchema, UpdateAgentEndpointAgentsAgentUuidPutResponse$zodSchema;
53915
53937
  var init_updateagentendpointagentsagentuuidputop = __esm(() => {
53916
53938
  init_zod();
53939
+ init_agentresponse();
53917
53940
  init_agentupdate();
53918
53941
  init_httpvalidationerror();
53919
- init_routersagentsagentresponse();
53920
53942
  UpdateAgentEndpointAgentsAgentUuidPutRequest$zodSchema = object({
53921
53943
  agent_uuid: string2().describe("The agent to update"),
53922
53944
  body: AgentUpdate$zodSchema,
53923
53945
  xAPIKey: string2().nullable().optional()
53924
53946
  });
53925
53947
  UpdateAgentEndpointAgentsAgentUuidPutResponse$zodSchema = union([
53926
- RoutersAgentsAgentResponse$zodSchema,
53948
+ AgentResponse$zodSchema,
53927
53949
  HTTPValidationError$zodSchema
53928
53950
  ]);
53929
53951
  });
@@ -54409,6 +54431,7 @@ var init_testcaseresult = __esm(() => {
54409
54431
  init_testoutput();
54410
54432
  TestCaseResult$zodSchema = object({
54411
54433
  cost: number2().nullable().optional().describe("Cost of this case (USD)"),
54434
+ inputs: record(string2(), any()).nullable().optional().describe("Extra request fields sent to the agent for this case, the agent's `default_inputs` with this case's overrides applied"),
54412
54435
  judge_results: array(JudgeResult$zodSchema).nullable().optional().describe("One verdict for each evaluator"),
54413
54436
  latency_ms: number2().nullable().optional().describe("How long the agent took to respond, in milliseconds"),
54414
54437
  name: string2().nullable().optional().describe("Name of the test"),
@@ -54488,7 +54511,8 @@ var init_benchmarkstatusresponse = __esm(() => {
54488
54511
  model_results: array(ModelResult$zodSchema).nullable().optional().describe("Results for each model"),
54489
54512
  share_token: string2().nullable().optional().describe("Token for building the public share URL"),
54490
54513
  status: TaskStatus$zodSchema,
54491
- task_id: string2().describe("Benchmark run job ID")
54514
+ task_id: string2().describe("Benchmark run job ID"),
54515
+ test_uuids: array(string2()).nullable().optional().describe("IDs of the tests this benchmark executed, in run order")
54492
54516
  });
54493
54517
  });
54494
54518
 
@@ -54651,6 +54675,7 @@ var init_testrunstatusresponse = __esm(() => {
54651
54675
  share_token: string2().nullable().optional().describe("Token for building the public share URL"),
54652
54676
  status: TaskStatus$zodSchema,
54653
54677
  task_id: string2().describe("Test run job ID"),
54678
+ test_uuids: array(string2()).nullable().optional().describe("IDs of the tests this run executed, in run order"),
54654
54679
  total_tests: int().nullable().optional().describe("Total number of test cases"),
54655
54680
  total_tokens: record(string2(), any()).nullable().optional().describe("Aggregated token usage as `{mean, min, max, count}`")
54656
54681
  });
@@ -56207,6 +56232,7 @@ var init_annotationtaskresponse = __esm(() => {
56207
56232
  created_at: string2().describe("When the task was created (ISO 8601 UTC)"),
56208
56233
  description: string2().nullable().optional().describe("The task's description"),
56209
56234
  evaluators: array(record(string2(), any())).optional().describe("The evaluators linked to this task, in display order. Fetching one task by ID enriches each with its live version's rubric. Listing tasks returns lightweight metadata (uuid, name, type, position) only"),
56235
+ has_agreement: boolean2().default(false).describe("Whether the task has at least one comparable human-vs-human or human-vs-evaluator pair, computed over all time"),
56210
56236
  item_count: int().nullable().optional().describe("Number of items in the task"),
56211
56237
  items: array(record(string2(), any())).optional().describe("The task's items, each with its agreement stats. You get these when you fetch one task by ID, not when you list tasks"),
56212
56238
  jobs: array(record(string2(), any())).optional().describe("The task's labelling jobs. You get these when you fetch one task by ID, not when you list tasks"),
@@ -56383,7 +56409,7 @@ var init_taskagreementresponse = __esm(() => {
56383
56409
  TaskAgreementResponse$zodSchema = collectExtraKeys(object({
56384
56410
  bucket: string2().describe("Time bucket used for the trend series"),
56385
56411
  days: int().describe("Length of the trailing window in days"),
56386
- evaluators: array(record(string2(), any())).describe("Agreement between each evaluator and the annotators, one entry per linked evaluator"),
56412
+ evaluators: array(record(string2(), any())).describe("Agreement between each evaluator and the annotators, plus that evaluator's own results, one entry per linked evaluator"),
56387
56413
  human_human: HumanAgreementBlock$zodSchema,
56388
56414
  task_id: string2().describe("ID of the task")
56389
56415
  }).catchall(any()), "AdditionalProperties", true);
@@ -58174,6 +58200,7 @@ var init_bulktestitem = __esm(() => {
58174
58200
  BulkTestItem$zodSchema = object({
58175
58201
  conversation_history: array(ChatMessage$zodSchema).describe("Ordered messages ending at the user turn the agent should answer"),
58176
58202
  evaluators: array(RoutersTestsEvaluatorRef$zodSchema).nullable().optional().describe("Evaluators to link. Used by `response` and `conversation` tests"),
58203
+ inputs: record(string2(), any()).nullable().optional().describe("Extra request fields for this test, overriding the agent's `default_inputs` per key"),
58177
58204
  name: string2().describe("Name of the test, unique within the workspace and within the batch"),
58178
58205
  tool_calls: array(ExpectedToolCall$zodSchema).nullable().optional().describe("Expected tool calls. **Required for `tool_call` batches**")
58179
58206
  });
@@ -58972,7 +58999,7 @@ fields to change (name, config). Returns the updated test. Fails with
58972
58999
  function createMCPServer(deps) {
58973
59000
  const server = new McpServer({
58974
59001
  name: "CalibrateMcp",
58975
- version: "0.0.31"
59002
+ version: "0.0.33"
58976
59003
  });
58977
59004
  const getClient = deps.getSDK || (() => new CalibrateMcpCore({
58978
59005
  security: deps.security,
@@ -60199,7 +60226,7 @@ http_headers = { "api-key-auth" = "YOUR_API_KEY_AUTH" }`;
60199
60226
  <h1>Instructions</h1>
60200
60227
  <p>One-click installation for Claude Desktop users</p>
60201
60228
  <div class="instruction-item">
60202
- <a href="https://github.com/dalmia/calibrate-mcp/releases/download/v0.0.31/mcp-server.mcpb" download="mcp-server.mcpb" class="action-button header-action" style="display: inline-flex; margin-bottom: 16px;">
60229
+ <a href="https://github.com/dalmia/calibrate-mcp/releases/download/v0.0.33/mcp-server.mcpb" download="mcp-server.mcpb" class="action-button header-action" style="display: inline-flex; margin-bottom: 16px;">
60203
60230
  \uD83D\uDCE5 Download MCP Bundle
60204
60231
  </a>
60205
60232
  </div>
@@ -60810,23 +60837,8 @@ var init_impl2 = __esm(() => {
60810
60837
  });
60811
60838
 
60812
60839
  // node_modules/@stricli/core/dist/index.js
60813
- var TRUTHY_VALUES = /* @__PURE__ */ new Set(["true", "t", "yes", "y", "on", "1", ""]);
60814
- var FALSY_VALUES = /* @__PURE__ */ new Set(["false", "f", "no", "n", "off", "0"]);
60815
- var looseBooleanParser = (input) => {
60816
- const value = input.toLowerCase();
60817
- if (TRUTHY_VALUES.has(value)) {
60818
- return true;
60819
- }
60820
- if (FALSY_VALUES.has(value)) {
60821
- return false;
60822
- }
60823
- throw new SyntaxError(`Cannot convert ${input} to a boolean`);
60824
- };
60825
- function checkEnvironmentVariable(process2, varName) {
60826
- const value = process2.env?.[varName];
60827
- return typeof value === "string" && looseBooleanParser(value);
60828
- }
60829
60840
  var ExitCode = {
60841
+ IntegrationError: -10,
60830
60842
  UnknownCommand: -5,
60831
60843
  InvalidArgument: -4,
60832
60844
  ContextLoadError: -3,
@@ -60995,6 +61007,18 @@ async function allSettledOrElse(values) {
60995
61007
  }
60996
61008
  return { status: "fulfilled", value: grouped.fulfilled?.map((result) => result.value) ?? [] };
60997
61009
  }
61010
+ var TRUTHY_VALUES = /* @__PURE__ */ new Set(["true", "t", "yes", "y", "on", "1", ""]);
61011
+ var FALSY_VALUES = /* @__PURE__ */ new Set(["false", "f", "no", "n", "off", "0"]);
61012
+ var looseBooleanParser = (input) => {
61013
+ const value = input.toLowerCase();
61014
+ if (TRUTHY_VALUES.has(value)) {
61015
+ return true;
61016
+ }
61017
+ if (FALSY_VALUES.has(value)) {
61018
+ return false;
61019
+ }
61020
+ throw new SyntaxError(`Cannot convert ${input} to a boolean`);
61021
+ };
60998
61022
  var numberParser = (input) => {
60999
61023
  const value = Number(input);
61000
61024
  if (Number.isNaN(value)) {
@@ -61013,6 +61037,11 @@ function formatMessageForArgumentScannerError(error, formatter) {
61013
61037
  }
61014
61038
  return error.message;
61015
61039
  }
61040
+ function resolveAllowedNegationForFlags(flags) {
61041
+ return Object.fromEntries(Object.entries(flags).map(([internalFlagName, flag]) => {
61042
+ return [internalFlagName, flag.kind === "boolean" && flag.withNegated !== false];
61043
+ }));
61044
+ }
61016
61045
  function resolveAliases(flags, aliases, scannerCaseStyle) {
61017
61046
  return Object.fromEntries(Object.entries(aliases).map(([alias, internalFlagName_]) => {
61018
61047
  const internalFlagName = internalFlagName_;
@@ -61156,7 +61185,7 @@ function undoNegation(flagName) {
61156
61185
  return firstLower + flagName.slice(3);
61157
61186
  }
61158
61187
  }
61159
- function findInternalFlagMatch(externalFlagName, flags, config) {
61188
+ function findInternalFlagMatch(externalFlagName, flags, allowsNegation, config) {
61160
61189
  const internalFlagName = externalFlagName;
61161
61190
  let flag = flags[internalFlagName];
61162
61191
  let foundFlagWithNegatedFalse;
@@ -61165,9 +61194,9 @@ function findInternalFlagMatch(externalFlagName, flags, config) {
61165
61194
  const internalWithoutNegation = undoNegation(internalFlagName);
61166
61195
  if (internalWithoutNegation) {
61167
61196
  flag = flags[internalWithoutNegation];
61168
- if (flag && flag.kind == "boolean") {
61169
- if (flag.withNegated !== false) {
61170
- return { namedFlag: [internalWithoutNegation, flag], negated: true };
61197
+ if (flag) {
61198
+ if (allowsNegation[internalWithoutNegation]) {
61199
+ return [internalWithoutNegation, flag, true];
61171
61200
  } else {
61172
61201
  foundFlagWithNegatedFalse = internalWithoutNegation;
61173
61202
  flag = undefined;
@@ -61179,14 +61208,14 @@ function findInternalFlagMatch(externalFlagName, flags, config) {
61179
61208
  if (config.caseStyle === "allow-kebab-for-camel" && !flag) {
61180
61209
  flag = flags[camelCaseFlagName];
61181
61210
  if (flag) {
61182
- return { namedFlag: [camelCaseFlagName, flag] };
61211
+ return [camelCaseFlagName, flag];
61183
61212
  }
61184
61213
  const camelCaseWithoutNegation = undoNegation(camelCaseFlagName);
61185
61214
  if (camelCaseWithoutNegation) {
61186
61215
  flag = flags[camelCaseWithoutNegation];
61187
- if (flag && flag.kind == "boolean") {
61188
- if (flag.withNegated !== false) {
61189
- return { namedFlag: [camelCaseWithoutNegation, flag], negated: true };
61216
+ if (flag) {
61217
+ if (allowsNegation[camelCaseWithoutNegation]) {
61218
+ return [camelCaseWithoutNegation, flag, true];
61190
61219
  } else {
61191
61220
  foundFlagWithNegatedFalse = camelCaseWithoutNegation;
61192
61221
  foundFlagWithNegatedFalseFromKebabConversion = true;
@@ -61213,17 +61242,17 @@ function findInternalFlagMatch(externalFlagName, flags, config) {
61213
61242
  const corrections = filterClosestAlternatives(internalFlagName, Object.keys(flags), config.distanceOptions);
61214
61243
  throw new FlagNotFoundError(externalFlagName, corrections);
61215
61244
  }
61216
- return { namedFlag: [internalFlagName, flag] };
61245
+ return [internalFlagName, flag];
61217
61246
  }
61218
61247
  function isNiladic(namedFlagWithNegation) {
61219
- if (namedFlagWithNegation.namedFlag[1].kind === "boolean" || namedFlagWithNegation.namedFlag[1].kind === "counter") {
61248
+ if (namedFlagWithNegation[1].kind === "boolean" || namedFlagWithNegation[1].kind === "counter") {
61220
61249
  return true;
61221
61250
  }
61222
61251
  return false;
61223
61252
  }
61224
61253
  var FLAG_SHORTHAND_PATTERN = /^-([a-z]+)$/i;
61225
61254
  var FLAG_NAME_PATTERN = /^--([a-z][a-z-.\d_]+)$/i;
61226
- function findFlagsByArgument(arg, flags, resolvedAliases, config) {
61255
+ function findFlagsByArgument(arg, flags, allowsNegation, resolvedAliases, config) {
61227
61256
  const shorthandMatch = FLAG_SHORTHAND_PATTERN.exec(arg);
61228
61257
  if (shorthandMatch) {
61229
61258
  const batch = shorthandMatch[1];
@@ -61233,13 +61262,13 @@ function findFlagsByArgument(arg, flags, resolvedAliases, config) {
61233
61262
  if (!namedFlag) {
61234
61263
  throw new AliasNotFoundError(aliasName);
61235
61264
  }
61236
- return { namedFlag };
61265
+ return namedFlag;
61237
61266
  });
61238
61267
  }
61239
61268
  const flagNameMatch = FLAG_NAME_PATTERN.exec(arg);
61240
61269
  if (flagNameMatch) {
61241
61270
  const externalFlagName = flagNameMatch[1];
61242
- return [findInternalFlagMatch(externalFlagName, flags, config)];
61271
+ return [findInternalFlagMatch(externalFlagName, flags, allowsNegation, config)];
61243
61272
  }
61244
61273
  return [];
61245
61274
  }
@@ -61254,16 +61283,16 @@ var InvalidNegatedFlagSyntaxError = class extends ArgumentScannerError {
61254
61283
  this.valueText = valueText;
61255
61284
  }
61256
61285
  };
61257
- function findFlagByArgumentWithInput(arg, flags, resolvedAliases, config) {
61286
+ function findFlagByArgumentWithInput(arg, flags, allowsNegation, resolvedAliases, config) {
61258
61287
  const flagsNameMatch = FLAG_NAME_VALUE_PATTERN.exec(arg);
61259
61288
  if (flagsNameMatch) {
61260
61289
  const externalFlagName = flagsNameMatch[1];
61261
- const { namedFlag: flagMatch, negated } = findInternalFlagMatch(externalFlagName, flags, config);
61290
+ const namedFlag = findInternalFlagMatch(externalFlagName, flags, allowsNegation, config);
61262
61291
  const valueText = flagsNameMatch[2];
61263
- if (negated) {
61292
+ if (namedFlag[2]) {
61264
61293
  throw new InvalidNegatedFlagSyntaxError(externalFlagName, valueText);
61265
61294
  }
61266
- return [flagMatch, valueText];
61295
+ return [namedFlag, valueText];
61267
61296
  }
61268
61297
  const aliasValueMatch = ALIAS_VALUE_PATTERN.exec(arg);
61269
61298
  if (aliasValueMatch) {
@@ -61395,6 +61424,7 @@ function isFlagSatisfiedByInputs(flags, flagInputs, key) {
61395
61424
  }
61396
61425
  function buildArgumentScanner(parameters, config) {
61397
61426
  const { flags = {}, aliases = {}, positional = { kind: "tuple", parameters: [] } } = parameters;
61427
+ const allowsNegation = resolveAllowedNegationForFlags(flags);
61398
61428
  const resolvedAliases = resolveAliases(flags, aliases, config.caseStyle);
61399
61429
  const positionalInputs = [];
61400
61430
  const flagInputs = /* @__PURE__ */ new Map;
@@ -61417,7 +61447,7 @@ function buildArgumentScanner(parameters, config) {
61417
61447
  return;
61418
61448
  }
61419
61449
  if (!treatInputsAsArguments) {
61420
- const flagInput = findFlagByArgumentWithInput(input, flags, resolvedAliases, config);
61450
+ const flagInput = findFlagByArgumentWithInput(input, flags, allowsNegation, resolvedAliases, config);
61421
61451
  if (flagInput) {
61422
61452
  if (activeFlag) {
61423
61453
  if (activeFlag[1].kind === "parsed" && activeFlag[1].inferEmpty) {
@@ -61432,7 +61462,7 @@ function buildArgumentScanner(parameters, config) {
61432
61462
  storeInput(flagInputs, config.caseStyle, ...flagInput);
61433
61463
  return;
61434
61464
  }
61435
- const nextFlags = findFlagsByArgument(input, flags, resolvedAliases, config);
61465
+ const nextFlags = findFlagsByArgument(input, flags, allowsNegation, resolvedAliases, config);
61436
61466
  if (nextFlags.length > 0) {
61437
61467
  if (activeFlag) {
61438
61468
  if (activeFlag[1].kind === "parsed" && activeFlag[1].inferEmpty) {
@@ -61440,24 +61470,24 @@ function buildArgumentScanner(parameters, config) {
61440
61470
  activeFlag = undefined;
61441
61471
  } else {
61442
61472
  const externalFlagName = asExternal(activeFlag[0], config.caseStyle);
61443
- const nextFlagName = asExternal(nextFlags[0].namedFlag[0], config.caseStyle);
61473
+ const nextFlagName = asExternal(nextFlags[0][0], config.caseStyle);
61444
61474
  throw new UnsatisfiedFlagError(externalFlagName, nextFlagName);
61445
61475
  }
61446
61476
  }
61447
61477
  if (nextFlags.every(isNiladic)) {
61448
61478
  for (const nextFlag of nextFlags) {
61449
- if (nextFlag.namedFlag[1].kind === "boolean") {
61450
- storeInput(flagInputs, config.caseStyle, nextFlag.namedFlag, nextFlag.negated ? "false" : "true");
61479
+ if (nextFlag[1].kind === "boolean") {
61480
+ storeInput(flagInputs, config.caseStyle, nextFlag, nextFlag[2] ? "false" : "true");
61451
61481
  } else {
61452
- storeInput(flagInputs, config.caseStyle, nextFlag.namedFlag, "1");
61482
+ storeInput(flagInputs, config.caseStyle, nextFlag, "1");
61453
61483
  }
61454
61484
  }
61455
61485
  } else if (nextFlags.length > 1) {
61456
61486
  const nextFlagExpectingArg = nextFlags.find((nextFlag) => !isNiladic(nextFlag));
61457
- const externalFlagName = asExternal(nextFlagExpectingArg.namedFlag[0], config.caseStyle);
61487
+ const externalFlagName = asExternal(nextFlagExpectingArg[0], config.caseStyle);
61458
61488
  throw new UnsatisfiedFlagError(externalFlagName);
61459
61489
  } else {
61460
- activeFlag = nextFlags[0].namedFlag;
61490
+ activeFlag = nextFlags[0];
61461
61491
  }
61462
61492
  return;
61463
61493
  }
@@ -61546,7 +61576,7 @@ function buildArgumentScanner(parameters, config) {
61546
61576
  const parsedFlags = Object.fromEntries(flagEntriesResult.value);
61547
61577
  return { success: true, arguments: [parsedFlags, ...positionalValuesResult.value] };
61548
61578
  },
61549
- proposeCompletions: async ({ partial, completionConfig, text, context, includeVersionFlag }) => {
61579
+ proposeCompletions: async ({ partial, completionConfig, text, context }) => {
61550
61580
  if (activeFlag) {
61551
61581
  return proposeFlagCompletionsForPartialInput(activeFlag[1], context, partial);
61552
61582
  }
@@ -61568,12 +61598,6 @@ function buildArgumentScanner(parameters, config) {
61568
61598
  }
61569
61599
  } else if (shorthandMatch) {
61570
61600
  const partialAliases = Array.from(shorthandMatch[1]);
61571
- if (partialAliases.includes("h")) {
61572
- return [];
61573
- }
61574
- if (includeVersionFlag && partialAliases.includes("v")) {
61575
- return [];
61576
- }
61577
61601
  const flagInputsIncludingPartial = new Map(flagInputs);
61578
61602
  for (const alias of partialAliases) {
61579
61603
  const namedFlag = resolvedAliases[alias];
@@ -61696,80 +61720,13 @@ function listAllRouteNamesAndAliasesForScan(routeMap, scannerCaseStyle, config)
61696
61720
  return [routeName];
61697
61721
  });
61698
61722
  }
61699
- var text_en = {
61700
- headers: {
61701
- usage: "USAGE",
61702
- aliases: "ALIASES",
61703
- commands: "COMMANDS",
61704
- flags: "FLAGS",
61705
- arguments: "ARGUMENTS"
61706
- },
61707
- keywords: {
61708
- default: "default =",
61709
- separator: "separator ="
61710
- },
61711
- briefs: {
61712
- help: "Print help information and exit",
61713
- helpAll: "Print help information (including hidden commands/flags) and exit",
61714
- version: "Print version information and exit",
61715
- argumentEscapeSequence: "All subsequent inputs should be interpreted as arguments"
61716
- },
61717
- noCommandRegisteredForInput({ input, corrections }) {
61718
- const errorMessage = `No command registered for \`${input}\``;
61719
- if (corrections.length > 0) {
61720
- const formattedCorrections = joinWithGrammar(corrections, {
61721
- kind: "conjunctive",
61722
- conjunction: "or",
61723
- serialComma: true
61724
- });
61725
- return `${errorMessage}, did you mean ${formattedCorrections}?`;
61726
- } else {
61727
- return errorMessage;
61728
- }
61729
- },
61730
- noTextAvailableForLocale({ requestedLocale, defaultLocale }) {
61731
- return `Application does not support "${requestedLocale}" locale, defaulting to "${defaultLocale}"`;
61732
- },
61733
- exceptionWhileParsingArguments(exc) {
61734
- if (exc instanceof ArgumentScannerError) {
61735
- return formatMessageForArgumentScannerError(exc, {});
61736
- }
61737
- return `Unable to parse arguments, ${(this.formatException ?? formatException)(exc)}`;
61738
- },
61739
- exceptionWhileLoadingCommandFunction(exc) {
61740
- return `Unable to load command function, ${(this.formatException ?? formatException)(exc)}`;
61741
- },
61742
- exceptionWhileLoadingCommandContext(exc) {
61743
- return `Unable to load command context, ${(this.formatException ?? formatException)(exc)}`;
61744
- },
61745
- exceptionWhileRunningCommand(exc) {
61746
- return `Command failed, ${(this.formatException ?? formatException)(exc)}`;
61747
- },
61748
- commandErrorResult(err) {
61749
- return err.message;
61750
- },
61751
- currentVersionIsNotLatest({ currentVersion, latestVersion, upgradeCommand }) {
61752
- if (upgradeCommand) {
61753
- return `Latest available version is ${latestVersion} (currently running ${currentVersion}), upgrade with "${upgradeCommand}"`;
61754
- }
61755
- return `Latest available version is ${latestVersion} (currently running ${currentVersion})`;
61756
- }
61757
- };
61758
- function defaultTextLoader(locale) {
61759
- if (locale.startsWith("en")) {
61760
- return text_en;
61761
- }
61762
- }
61763
- function shouldUseAnsiColor(process2, stream, config) {
61764
- return !config.disableAnsiColor && !checkEnvironmentVariable(process2, "STRICLI_NO_COLOR") && (stream.getColorDepth?.(process2.env) ?? 1) >= 4;
61765
- }
61766
61723
  async function runCommand({ loader, parameters }, {
61767
61724
  context,
61768
61725
  inputs,
61769
61726
  scannerConfig,
61770
61727
  errorFormatting,
61771
- documentationConfig,
61772
- determineExitCode
61728
+ determineExitCode,
61729
+ ansiColorByStream
61773
61730
  }) {
61774
61731
  let parsedArguments;
61775
61732
  try {
@@ -61781,19 +61738,17 @@ async function runCommand({ loader, parameters }, {
61781
61738
  if (result.success) {
61782
61739
  parsedArguments = result.arguments;
61783
61740
  } else {
61784
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, documentationConfig);
61785
61741
  for (const error of result.errors) {
61786
- const errorMessage = errorFormatting.exceptionWhileParsingArguments(error, ansiColor);
61787
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61742
+ const errorMessage = errorFormatting.exceptionWhileParsingArguments(error, ansiColorByStream.stderr);
61743
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61788
61744
  ` : `${errorMessage}
61789
61745
  `);
61790
61746
  }
61791
61747
  return ExitCode.InvalidArgument;
61792
61748
  }
61793
61749
  } catch (exc) {
61794
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, documentationConfig);
61795
- const errorMessage = errorFormatting.exceptionWhileParsingArguments(exc, ansiColor);
61796
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61750
+ const errorMessage = errorFormatting.exceptionWhileParsingArguments(exc, ansiColorByStream.stderr);
61751
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61797
61752
  ` : `${errorMessage}
61798
61753
  `);
61799
61754
  return ExitCode.InvalidArgument;
@@ -61807,9 +61762,8 @@ async function runCommand({ loader, parameters }, {
61807
61762
  commandFunction = loaded.default;
61808
61763
  }
61809
61764
  } catch (exc) {
61810
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, documentationConfig);
61811
- const errorMessage = errorFormatting.exceptionWhileLoadingCommandFunction(exc, ansiColor);
61812
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61765
+ const errorMessage = errorFormatting.exceptionWhileLoadingCommandFunction(exc, ansiColorByStream.stderr);
61766
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61813
61767
  ` : `${errorMessage}
61814
61768
  `);
61815
61769
  return ExitCode.CommandLoadError;
@@ -61817,9 +61771,8 @@ async function runCommand({ loader, parameters }, {
61817
61771
  try {
61818
61772
  const result = await commandFunction.call(context, ...parsedArguments);
61819
61773
  if (result instanceof Error) {
61820
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, documentationConfig);
61821
- const errorMessage = errorFormatting.commandErrorResult(result, ansiColor);
61822
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61774
+ const errorMessage = errorFormatting.commandErrorResult(result, ansiColorByStream.stderr);
61775
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61823
61776
  ` : `${errorMessage}
61824
61777
  `);
61825
61778
  if (determineExitCode) {
@@ -61828,9 +61781,8 @@ async function runCommand({ loader, parameters }, {
61828
61781
  return ExitCode.CommandRunError;
61829
61782
  }
61830
61783
  } catch (exc) {
61831
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, documentationConfig);
61832
- const errorMessage = errorFormatting.exceptionWhileRunningCommand(exc, ansiColor);
61833
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61784
+ const errorMessage = errorFormatting.exceptionWhileRunningCommand(exc, ansiColorByStream.stderr);
61785
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61834
61786
  ` : `${errorMessage}
61835
61787
  `);
61836
61788
  if (determineExitCode) {
@@ -61842,14 +61794,26 @@ async function runCommand({ loader, parameters }, {
61842
61794
  }
61843
61795
  var RouteMapSymbol = Symbol("RouteMap");
61844
61796
  var CommandSymbol = Symbol("Command");
61845
- function buildRouteScanner(root, config, startingPrefix) {
61797
+ function buildRouteScanner(root, config, startingPrefix, additionalFlags) {
61846
61798
  const prefix = [...startingPrefix];
61847
61799
  const unprocessedInputs = [];
61800
+ const flags = {};
61801
+ for (const additionalFlag of additionalFlags) {
61802
+ flags[additionalFlag.name] = additionalFlag;
61803
+ }
61804
+ const aliases = {};
61805
+ for (const additionalFlag of additionalFlags) {
61806
+ if (additionalFlag.aliases) {
61807
+ for (const alias of additionalFlag.aliases) {
61808
+ aliases[alias] = additionalFlag.name;
61809
+ }
61810
+ }
61811
+ }
61812
+ const resolvedAliases = resolveAliases(flags, aliases, config.caseStyle);
61813
+ let activeFlag;
61848
61814
  let parent;
61849
61815
  let current = root;
61850
61816
  let target;
61851
- let rootLevel = true;
61852
- let helpRequested = false;
61853
61817
  let treatInputsAsArguments = false;
61854
61818
  return {
61855
61819
  next: (input) => {
@@ -61858,22 +61822,20 @@ function buildRouteScanner(root, config, startingPrefix) {
61858
61822
  unprocessedInputs.push(input);
61859
61823
  return;
61860
61824
  }
61861
- if (!treatInputsAsArguments) {
61862
- if (input === "--help" || input === "-h") {
61863
- helpRequested = true;
61864
- if (!target) {
61865
- target = current;
61866
- }
61867
- return;
61868
- } else if (input === "--helpAll" || input === "--help-all" || input === "-H") {
61869
- helpRequested = "all";
61870
- if (!target) {
61825
+ if (!treatInputsAsArguments && !activeFlag) {
61826
+ try {
61827
+ const nextFlags = findFlagsByArgument(input, flags, {}, resolvedAliases, config);
61828
+ for (const currentFlag of nextFlags) {
61829
+ if (!currentFlag[1].global && current !== root) {
61830
+ continue;
61831
+ }
61832
+ activeFlag = currentFlag[1];
61871
61833
  target = current;
61834
+ return;
61872
61835
  }
61873
- return;
61874
- }
61836
+ } catch {}
61875
61837
  }
61876
- if (target) {
61838
+ if (target || treatInputsAsArguments) {
61877
61839
  unprocessedInputs.push(input);
61878
61840
  return;
61879
61841
  }
@@ -61893,123 +61855,413 @@ function buildRouteScanner(root, config, startingPrefix) {
61893
61855
  }
61894
61856
  if (!next) {
61895
61857
  const defaultCommand = current.getDefaultCommand();
61858
+ unprocessedInputs.push(input);
61896
61859
  if (defaultCommand) {
61897
- rootLevel = false;
61898
61860
  parent = [current, ""];
61899
- unprocessedInputs.push(input);
61900
61861
  current = defaultCommand;
61901
61862
  return;
61902
61863
  }
61903
61864
  return { input, routeMap: current };
61904
61865
  }
61905
- rootLevel = false;
61906
61866
  parent = [current, input];
61907
61867
  current = next;
61908
61868
  prefix.push(input);
61909
61869
  },
61910
61870
  finish: () => {
61911
61871
  target = target ?? current;
61912
- if (target.kind === RouteMapSymbol && !helpRequested) {
61872
+ if (target.kind === RouteMapSymbol && !activeFlag) {
61913
61873
  const defaultCommand = target.getDefaultCommand();
61914
61874
  if (defaultCommand) {
61915
61875
  parent = [target, ""];
61916
61876
  target = defaultCommand;
61917
- rootLevel = false;
61918
61877
  }
61919
61878
  }
61920
- const aliases = parent ? parent[0].getOtherAliasesForInput(parent[1], config.caseStyle) : { original: [], "convert-camel-to-kebab": [] };
61879
+ const aliases2 = parent ? parent[0].getOtherAliasesForInput(parent[1], config.caseStyle) : { original: [], "convert-camel-to-kebab": [] };
61921
61880
  return {
61922
61881
  target,
61923
61882
  unprocessedInputs,
61924
- helpRequested,
61925
61883
  prefix,
61926
- rootLevel,
61927
- aliases
61884
+ aliases: aliases2,
61885
+ activeFlag
61928
61886
  };
61929
61887
  }
61930
61888
  };
61931
61889
  }
61932
- async function runApplication({ root, defaultText, config }, rawInputs, context) {
61933
- let text = defaultText;
61934
- if (context.locale && "loadText" in config.localization) {
61935
- const localeText = config.localization.loadText(context.locale);
61936
- if (localeText) {
61937
- text = localeText;
61938
- } else {
61939
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, config.documentation);
61940
- const warningMessage = text.noTextAvailableForLocale({
61941
- requestedLocale: context.locale,
61942
- defaultLocale: config.localization.defaultLocale,
61943
- ansiColor
61890
+ function checkEnvironmentVariable(process2, varName) {
61891
+ const value = process2.env?.[varName];
61892
+ return typeof value === "string" && looseBooleanParser(value);
61893
+ }
61894
+ var text_en = {
61895
+ headers: {
61896
+ usage: "USAGE",
61897
+ aliases: "ALIASES",
61898
+ commands: "COMMANDS",
61899
+ flags: "FLAGS",
61900
+ arguments: "ARGUMENTS"
61901
+ },
61902
+ keywords: {
61903
+ default: "default =",
61904
+ separator: "separator ="
61905
+ },
61906
+ briefs: {
61907
+ help: "Print help information and exit",
61908
+ helpAll: "Print help information (including hidden commands/flags) and exit",
61909
+ version: "Print version information and exit",
61910
+ argumentEscapeSequence: "All subsequent inputs should be interpreted as arguments"
61911
+ },
61912
+ noCommandRegisteredForInput({ input, corrections }) {
61913
+ const errorMessage = `No command registered for \`${input}\``;
61914
+ if (corrections.length > 0) {
61915
+ const formattedCorrections = joinWithGrammar(corrections, {
61916
+ kind: "conjunctive",
61917
+ conjunction: "or",
61918
+ serialComma: true
61944
61919
  });
61945
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[33m${warningMessage}\x1B[39m\x1B[22m
61920
+ return `${errorMessage}, did you mean ${formattedCorrections}?`;
61921
+ } else {
61922
+ return errorMessage;
61923
+ }
61924
+ },
61925
+ noTextAvailableForLocale({ requestedLocale, defaultLocale }) {
61926
+ return `Application does not support "${requestedLocale}" locale, defaulting to "${defaultLocale}"`;
61927
+ },
61928
+ exceptionWhileParsingArguments(exc) {
61929
+ if (exc instanceof ArgumentScannerError) {
61930
+ return formatMessageForArgumentScannerError(exc, {});
61931
+ }
61932
+ return `Unable to parse arguments, ${(this.formatException ?? formatException)(exc)}`;
61933
+ },
61934
+ exceptionWhileLoadingCommandFunction(exc) {
61935
+ return `Unable to load command function, ${(this.formatException ?? formatException)(exc)}`;
61936
+ },
61937
+ exceptionWhileLoadingCommandContext(exc) {
61938
+ return `Unable to load command context, ${(this.formatException ?? formatException)(exc)}`;
61939
+ },
61940
+ exceptionWhileRunningCommand(exc) {
61941
+ return `Command failed, ${(this.formatException ?? formatException)(exc)}`;
61942
+ },
61943
+ exceptionWhileRunningIntegrationHook({ exception, hook, integration }) {
61944
+ return `Unexpected exception thrown by '${integration}' integration during '${hook}' hook.
61945
+ ${(this.formatException ?? formatException)(exception)}`;
61946
+ },
61947
+ exceptionWhileRunningIntegrationFlag({ exception, integration }) {
61948
+ return `Unexpected exception thrown by "--${integration}" flag from the '${integration}' integration.
61949
+ ${(this.formatException ?? formatException)(exception)}`;
61950
+ },
61951
+ commandErrorResult(err) {
61952
+ return err.message;
61953
+ },
61954
+ currentVersionIsNotLatest({ currentVersion, latestVersion, upgradeCommand }) {
61955
+ if (upgradeCommand) {
61956
+ return `Latest available version is ${latestVersion} (currently running ${currentVersion}), upgrade with "${upgradeCommand}"`;
61957
+ }
61958
+ return `Latest available version is ${latestVersion} (currently running ${currentVersion})`;
61959
+ }
61960
+ };
61961
+ function defaultTextLoader(locale) {
61962
+ if (locale.startsWith("en")) {
61963
+ return text_en;
61964
+ }
61965
+ }
61966
+ function shouldUseAnsiColor(process2, stream, config) {
61967
+ return !config.disableAnsiColor && !checkEnvironmentVariable(process2, "STRICLI_NO_COLOR") && (stream.getColorDepth?.(process2.env) ?? 1) >= 4;
61968
+ }
61969
+ function shouldUseAnsiColorForStreams(process2, config) {
61970
+ return {
61971
+ stdout: shouldUseAnsiColor(process2, process2.stdout, config),
61972
+ stderr: shouldUseAnsiColor(process2, process2.stderr, config)
61973
+ };
61974
+ }
61975
+ function validateCaseStyleCompatibility(scan, display) {
61976
+ if (scan === "original" && display === "convert-camel-to-kebab") {
61977
+ throw new Error("Cannot convert route and flag names on display (convert-camel-to-kebab) but scan as original");
61978
+ }
61979
+ }
61980
+ function help({
61981
+ alias = "h",
61982
+ includeHidden = false,
61983
+ formatting,
61984
+ ...config
61985
+ }) {
61986
+ return {
61987
+ validate(_root, config2) {
61988
+ validateCaseStyleCompatibility(config2.scanner.caseStyle, formatting.caseStyle);
61989
+ },
61990
+ flag: {
61991
+ ...config,
61992
+ global: true,
61993
+ aliases: alias === false ? [] : [alias],
61994
+ async run(app, { text, ansiColorByStream, result, additionalFlags }) {
61995
+ this.process.stdout.write(result.target.formatHelp({
61996
+ prefix: result.prefix,
61997
+ additionalFlags,
61998
+ includeArgumentEscapeSequenceFlag: app.config.scanner.allowArgumentEscapeSequence,
61999
+ includeHidden,
62000
+ config: formatting,
62001
+ aliases: result.aliases[formatting.caseStyle],
62002
+ text,
62003
+ ansiColor: ansiColorByStream.stdout
62004
+ }));
62005
+ }
62006
+ }
62007
+ };
62008
+ }
62009
+ function version({
62010
+ info,
62011
+ alias = "v",
62012
+ hook = "app:start",
62013
+ ...config
62014
+ }) {
62015
+ let versionCheck;
62016
+ if (info.getLatestVersion) {
62017
+ const getLatestVersion = info.getLatestVersion;
62018
+ versionCheck = async function({ text, ansiColorByStream }) {
62019
+ if (checkEnvironmentVariable(this.process, "STRICLI_SKIP_VERSION_CHECK")) {
62020
+ return;
62021
+ }
62022
+ let currentVersion;
62023
+ if ("currentVersion" in info) {
62024
+ currentVersion = info.currentVersion;
62025
+ } else {
62026
+ currentVersion = await info.getCurrentVersion.call(this);
62027
+ }
62028
+ const latestVersion = await getLatestVersion.call(this, currentVersion);
62029
+ if (latestVersion && currentVersion !== latestVersion) {
62030
+ const warningMessage = text.currentVersionIsNotLatest({
62031
+ currentVersion,
62032
+ latestVersion,
62033
+ upgradeCommand: info.upgradeCommand,
62034
+ ansiColor: ansiColorByStream.stderr
62035
+ });
62036
+ this.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[33m${warningMessage}\x1B[39m\x1B[22m
61946
62037
  ` : `${warningMessage}
61947
62038
  `);
62039
+ }
62040
+ };
62041
+ }
62042
+ return {
62043
+ hooks: versionCheck ? { [hook]: versionCheck } : {},
62044
+ flag: {
62045
+ ...config,
62046
+ defaultForRouteMap: false,
62047
+ global: false,
62048
+ aliases: alias === false ? [] : [alias],
62049
+ async run() {
62050
+ let currentVersion;
62051
+ if ("currentVersion" in info) {
62052
+ currentVersion = info.currentVersion;
62053
+ } else {
62054
+ currentVersion = await info.getCurrentVersion.call(this);
62055
+ }
62056
+ this.process.stdout.write(currentVersion + `
62057
+ `);
62058
+ }
62059
+ }
62060
+ };
62061
+ }
62062
+ async function runHook(integrations, hookName, context, args) {
62063
+ for (const [name, integration] of Object.entries(integrations)) {
62064
+ const hook = integration.hooks?.[hookName];
62065
+ if (hook) {
62066
+ try {
62067
+ await hook.call(context, args);
62068
+ } catch (exc) {
62069
+ const errorMessage = args.text.exceptionWhileRunningIntegrationHook({
62070
+ exception: exc,
62071
+ hook: hookName,
62072
+ integration: name,
62073
+ ansiColor: args.ansiColorByStream.stderr
62074
+ });
62075
+ context.process.stderr.write(args.ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
62076
+ ` : `${errorMessage}
62077
+ `);
62078
+ return ExitCode.IntegrationError;
62079
+ }
62080
+ }
62081
+ }
62082
+ }
62083
+ function checkIntegrationsForCollisions(integrations, caseStyle) {
62084
+ let routeMapDefault;
62085
+ const flagNames = new Set(Object.keys(integrations));
62086
+ const aliases = /* @__PURE__ */ new Map;
62087
+ for (const [name, integration] of Object.entries(integrations)) {
62088
+ if (caseStyle === "allow-kebab-for-camel") {
62089
+ const camelCase = convertKebabCaseToCamelCase(name);
62090
+ if (camelCase !== name && flagNames.has(camelCase)) {
62091
+ throw new InternalError(`Multiple integrations are trying to use the same flag name (with 'allow-kebab-for-camel'): '${name}' and '${camelCase}'`);
62092
+ }
62093
+ }
62094
+ if (integration.flag) {
62095
+ if (integration.flag.defaultForRouteMap) {
62096
+ if (routeMapDefault) {
62097
+ throw new InternalError(`Multiple integrations provide a default flag for route maps: '${routeMapDefault}' and '${name}'`);
62098
+ }
62099
+ routeMapDefault = name;
62100
+ }
62101
+ for (const alias of integration.flag.aliases ?? []) {
62102
+ const flagForAlias = aliases.get(alias);
62103
+ if (flagForAlias) {
62104
+ throw new InternalError(`Multiple integrations are trying to use the same flag alias "-${alias}": '${flagForAlias}' and '${name}'`);
62105
+ }
62106
+ aliases.set(alias, name);
62107
+ }
61948
62108
  }
61949
62109
  }
61950
- if (config.versionInfo?.getLatestVersion && !checkEnvironmentVariable(context.process, "STRICLI_SKIP_VERSION_CHECK")) {
61951
- let currentVersion;
61952
- if ("currentVersion" in config.versionInfo) {
61953
- currentVersion = config.versionInfo.currentVersion;
62110
+ }
62111
+ function checkIntegrationsForFlagNameConflicts(root, additionalFlags, caseStyle) {
62112
+ function checkForConflicts(target, prefix) {
62113
+ if (target.kind === CommandSymbol) {
62114
+ const relevantFlags = root === target ? additionalFlags : additionalFlags.filter(({ global: global2 }) => global2);
62115
+ for (const { name, aliases } of relevantFlags) {
62116
+ if (target.usesFlag(name, caseStyle)) {
62117
+ throw new InternalError(`'${name}' integration provides a flag that would override: "${[...prefix, `--${name}`].join(" ")}"`);
62118
+ }
62119
+ for (const alias of aliases ?? []) {
62120
+ if (target.usesFlag(alias, caseStyle)) {
62121
+ throw new InternalError(`'${name}' integration provides a flag with an alias that would override: "${[...prefix, `-${alias}`].join(" ")}"`);
62122
+ }
62123
+ }
62124
+ }
61954
62125
  } else {
61955
- currentVersion = await config.versionInfo.getCurrentVersion.call(context);
61956
- }
61957
- const latestVersion = await config.versionInfo.getLatestVersion.call(context, currentVersion);
61958
- if (latestVersion && currentVersion !== latestVersion) {
61959
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, config.documentation);
61960
- const warningMessage = text.currentVersionIsNotLatest({
61961
- currentVersion,
61962
- latestVersion,
61963
- upgradeCommand: config.versionInfo.upgradeCommand,
61964
- ansiColor
62126
+ for (const entry of target.getAllEntries()) {
62127
+ checkForConflicts(entry.target, [...prefix, entry.name.original]);
62128
+ }
62129
+ }
62130
+ }
62131
+ checkForConflicts(root, []);
62132
+ }
62133
+ function gatherAdditionalFlagsFromIntegrations(integrations) {
62134
+ const flags = [];
62135
+ for (const [name, integration] of Object.entries(integrations)) {
62136
+ if (integration.flag) {
62137
+ flags.push({ ...integration.flag, name });
62138
+ }
62139
+ }
62140
+ return flags;
62141
+ }
62142
+ function validateIntegrations(integrations, root, config) {
62143
+ for (const [name, integration] of Object.entries(integrations)) {
62144
+ try {
62145
+ integration.validate?.(root, config);
62146
+ } catch (exc) {
62147
+ throw new InternalError(`Integration '${name}' failed validation: ${String(exc)}`, { cause: exc });
62148
+ }
62149
+ }
62150
+ }
62151
+ function gatherDefaultIntegrations(config, text) {
62152
+ const integrations = {
62153
+ help: help({
62154
+ brief: text.briefs.help,
62155
+ alias: "h",
62156
+ defaultForRouteMap: true,
62157
+ includeHidden: false,
62158
+ formatting: config.documentation
62159
+ }),
62160
+ helpAll: help({
62161
+ brief: text.briefs.helpAll,
62162
+ alias: "H",
62163
+ hidden: !config.documentation.alwaysShowHelpAllFlag,
62164
+ includeHidden: true,
62165
+ formatting: config.documentation
62166
+ })
62167
+ };
62168
+ if (config.versionInfo) {
62169
+ integrations["version"] = version({
62170
+ brief: text.briefs.version,
62171
+ info: config.versionInfo,
62172
+ alias: "v",
62173
+ hook: "app:start"
62174
+ });
62175
+ }
62176
+ return integrations;
62177
+ }
62178
+ async function runApplication(app, rawInputs, context) {
62179
+ const ansiColorByStream = shouldUseAnsiColorForStreams(context.process, app.config.documentation);
62180
+ let text = app.defaultText;
62181
+ if (context.locale && "loadText" in app.config.localization) {
62182
+ const localeText = app.config.localization.loadText(context.locale);
62183
+ if (localeText) {
62184
+ text = localeText;
62185
+ } else {
62186
+ const warningMessage = text.noTextAvailableForLocale({
62187
+ requestedLocale: context.locale,
62188
+ defaultLocale: app.config.localization.defaultLocale,
62189
+ ansiColor: ansiColorByStream.stderr
61965
62190
  });
61966
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[33m${warningMessage}\x1B[39m\x1B[22m
62191
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[33m${warningMessage}\x1B[39m\x1B[22m
61967
62192
  ` : `${warningMessage}
61968
62193
  `);
61969
62194
  }
61970
62195
  }
61971
- const inputs = rawInputs.slice();
61972
- if (config.versionInfo && (inputs[0] === "--version" || inputs[0] === "-v")) {
61973
- let currentVersion;
61974
- if ("currentVersion" in config.versionInfo) {
61975
- currentVersion = config.versionInfo.currentVersion;
61976
- } else {
61977
- currentVersion = await config.versionInfo.getCurrentVersion.call(context);
61978
- }
61979
- context.process.stdout.write(currentVersion + `
61980
- `);
61981
- return ExitCode.Success;
62196
+ const hookStartExitCode = await runHook(app.integrations, "app:start", context, {
62197
+ text,
62198
+ ansiColorByStream
62199
+ });
62200
+ if (typeof hookStartExitCode === "number") {
62201
+ return hookStartExitCode;
62202
+ }
62203
+ const exitCode = await scanInputsAndRunTarget(app, rawInputs, context, text, ansiColorByStream);
62204
+ const hookEndExitCode = await runHook(app.integrations, "app:end", context, {
62205
+ text,
62206
+ ansiColorByStream,
62207
+ exitCode
62208
+ });
62209
+ if (typeof hookEndExitCode === "number") {
62210
+ return hookEndExitCode;
61982
62211
  }
61983
- const scanner = buildRouteScanner(root, config.scanner, [config.name]);
62212
+ return exitCode;
62213
+ }
62214
+ async function scanInputsAndRunTarget(app, rawInputs, context, text, ansiColorByStream) {
62215
+ const additionalFlags = gatherAdditionalFlagsFromIntegrations(app.integrations);
62216
+ const inputs = rawInputs.slice();
62217
+ const scanner = buildRouteScanner(app.root, app.config.scanner, [app.config.name], additionalFlags);
61984
62218
  let error;
61985
62219
  while (inputs.length > 0 && !error) {
61986
62220
  const arg = inputs.shift();
61987
62221
  error = scanner.next(arg);
61988
62222
  }
61989
62223
  if (error) {
61990
- const routeNames = listAllRouteNamesAndAliasesForScan(error.routeMap, config.scanner.caseStyle, config.completion);
61991
- const corrections = filterClosestAlternatives(error.input, routeNames, config.scanner.distanceOptions).map((str) => `\`${str}\``);
61992
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, config.documentation);
61993
- const errorMessage = text.noCommandRegisteredForInput({ input: error.input, corrections, ansiColor });
61994
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
62224
+ const routeNames = listAllRouteNamesAndAliasesForScan(error.routeMap, app.config.scanner.caseStyle, app.config.completion);
62225
+ const corrections = filterClosestAlternatives(error.input, routeNames, app.config.scanner.distanceOptions).map((str) => `\`${str}\``);
62226
+ const errorMessage = text.noCommandRegisteredForInput({
62227
+ input: error.input,
62228
+ corrections,
62229
+ ansiColor: ansiColorByStream.stderr
62230
+ });
62231
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
61995
62232
  ` : `${errorMessage}
61996
62233
  `);
61997
62234
  return ExitCode.UnknownCommand;
61998
62235
  }
61999
- const result = scanner.finish();
62000
- if (result.helpRequested || result.target.kind === RouteMapSymbol) {
62001
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stdout, config.documentation);
62002
- context.process.stdout.write(result.target.formatHelp({
62003
- prefix: result.prefix,
62004
- includeVersionFlag: Boolean(config.versionInfo) && result.rootLevel,
62005
- includeArgumentEscapeSequenceFlag: config.scanner.allowArgumentEscapeSequence,
62006
- includeHelpAllFlag: result.helpRequested === "all" || config.documentation.alwaysShowHelpAllFlag,
62007
- includeHidden: result.helpRequested === "all",
62008
- config: config.documentation,
62009
- aliases: result.aliases[config.documentation.caseStyle],
62010
- text,
62011
- ansiColor
62012
- }));
62236
+ let { activeFlag, ...result } = scanner.finish();
62237
+ if (activeFlag || result.target.kind === RouteMapSymbol) {
62238
+ if (!activeFlag) {
62239
+ activeFlag = additionalFlags.find((flag) => flag.defaultForRouteMap);
62240
+ }
62241
+ if (activeFlag) {
62242
+ let additionalFlagsForTarget = additionalFlags;
62243
+ if (result.target !== app.root) {
62244
+ additionalFlagsForTarget = additionalFlagsForTarget.filter((flag) => flag.global);
62245
+ }
62246
+ try {
62247
+ await activeFlag.run.call(context, app, {
62248
+ text,
62249
+ ansiColorByStream,
62250
+ result,
62251
+ additionalFlags: additionalFlagsForTarget
62252
+ });
62253
+ } catch (exc) {
62254
+ const errorMessage = text.exceptionWhileRunningIntegrationFlag({
62255
+ exception: exc,
62256
+ ansiColor: ansiColorByStream.stderr,
62257
+ integration: activeFlag.name
62258
+ });
62259
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m
62260
+ ` : `${errorMessage}
62261
+ `);
62262
+ return ExitCode.IntegrationError;
62263
+ }
62264
+ }
62013
62265
  return ExitCode.Success;
62014
62266
  }
62015
62267
  let commandContext;
@@ -62017,117 +62269,62 @@ async function runApplication({ root, defaultText, config }, rawInputs, context)
62017
62269
  try {
62018
62270
  commandContext = await context.forCommand({ prefix: result.prefix });
62019
62271
  } catch (exc) {
62020
- const ansiColor = shouldUseAnsiColor(context.process, context.process.stderr, config.documentation);
62021
- const errorMessage = text.exceptionWhileLoadingCommandContext(exc, ansiColor);
62022
- context.process.stderr.write(ansiColor ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m` : errorMessage);
62272
+ const errorMessage = text.exceptionWhileLoadingCommandContext(exc, ansiColorByStream.stderr);
62273
+ context.process.stderr.write(ansiColorByStream.stderr ? `\x1B[1m\x1B[31m${errorMessage}\x1B[39m\x1B[22m` : errorMessage);
62023
62274
  return ExitCode.ContextLoadError;
62024
62275
  }
62025
62276
  } else {
62026
62277
  commandContext = context;
62027
62278
  }
62028
- return runCommand(result.target, {
62279
+ const hookStartExitCode = await runHook(app.integrations, "command:start", commandContext, {
62280
+ text,
62281
+ ansiColorByStream,
62282
+ result
62283
+ });
62284
+ if (typeof hookStartExitCode === "number") {
62285
+ return hookStartExitCode;
62286
+ }
62287
+ const exitCode = await runCommand(result.target, {
62029
62288
  context: commandContext,
62030
62289
  inputs: result.unprocessedInputs,
62031
- scannerConfig: config.scanner,
62032
- documentationConfig: config.documentation,
62290
+ scannerConfig: app.config.scanner,
62033
62291
  errorFormatting: text,
62034
- determineExitCode: config.determineExitCode
62292
+ determineExitCode: app.config.determineExitCode,
62293
+ ansiColorByStream
62035
62294
  });
62036
- }
62037
- function formatForDisplay(flagName, displayCaseStyle) {
62038
- if (displayCaseStyle === "convert-camel-to-kebab") {
62039
- return convertCamelCaseToKebabCase(flagName);
62295
+ const hookEndExitCode = await runHook(app.integrations, "command:end", commandContext, {
62296
+ text,
62297
+ ansiColorByStream,
62298
+ result,
62299
+ exitCode
62300
+ });
62301
+ if (typeof hookEndExitCode === "number") {
62302
+ return hookEndExitCode;
62040
62303
  }
62041
- return flagName;
62304
+ return exitCode;
62042
62305
  }
62043
- function formatAsNegated(flagName, displayCaseStyle) {
62044
- if (displayCaseStyle === "convert-camel-to-kebab") {
62045
- return `no-${convertCamelCaseToKebabCase(flagName)}`;
62046
- }
62047
- return `no${flagName[0].toUpperCase()}${flagName.slice(1)}`;
62306
+ function hasDefault(flag) {
62307
+ return "default" in flag && typeof flag.default !== "undefined";
62048
62308
  }
62049
- function withDefaults(config) {
62050
- const scannerCaseStyle = config.scanner?.caseStyle ?? "original";
62309
+ function isOptionalAtRuntime(flag) {
62310
+ return flag.optional ?? hasDefault(flag);
62311
+ }
62312
+ function withDefaultFormattingConfiguration(config, scannerCaseStyle) {
62051
62313
  let displayCaseStyle;
62052
- if (config.documentation?.caseStyle) {
62053
- if (scannerCaseStyle === "original" && config.documentation.caseStyle === "convert-camel-to-kebab") {
62054
- throw new InternalError("Cannot convert route and flag names on display but scan as original");
62055
- }
62056
- displayCaseStyle = config.documentation.caseStyle;
62314
+ if (config.caseStyle) {
62315
+ displayCaseStyle = config.caseStyle;
62057
62316
  } else if (scannerCaseStyle === "allow-kebab-for-camel") {
62058
62317
  displayCaseStyle = "convert-camel-to-kebab";
62059
62318
  } else {
62060
62319
  displayCaseStyle = scannerCaseStyle;
62061
62320
  }
62062
- const scannerConfig = {
62063
- caseStyle: scannerCaseStyle,
62064
- allowArgumentEscapeSequence: config.scanner?.allowArgumentEscapeSequence ?? false,
62065
- distanceOptions: config.scanner?.distanceOptions ?? {
62066
- threshold: 7,
62067
- weights: {
62068
- insertion: 1,
62069
- deletion: 3,
62070
- substitution: 2,
62071
- transposition: 0
62072
- }
62073
- }
62074
- };
62075
- const documentationConfig = {
62076
- alwaysShowHelpAllFlag: config.documentation?.alwaysShowHelpAllFlag ?? false,
62077
- useAliasInUsageLine: config.documentation?.useAliasInUsageLine ?? false,
62078
- onlyRequiredInUsageLine: config.documentation?.onlyRequiredInUsageLine ?? false,
62079
- caseStyle: displayCaseStyle,
62080
- disableAnsiColor: config.documentation?.disableAnsiColor ?? false
62081
- };
62082
- const completionConfig = {
62083
- includeAliases: config.completion?.includeAliases ?? documentationConfig.useAliasInUsageLine,
62084
- includeHiddenRoutes: config.completion?.includeHiddenRoutes ?? false,
62085
- ...config.completion
62086
- };
62321
+ validateCaseStyleCompatibility(scannerCaseStyle, displayCaseStyle);
62087
62322
  return {
62088
- ...config,
62089
- scanner: scannerConfig,
62090
- completion: completionConfig,
62091
- documentation: documentationConfig,
62092
- localization: {
62093
- defaultLocale: "en",
62094
- loadText: defaultTextLoader,
62095
- ...config.localization
62096
- }
62323
+ useAliasInUsageLine: config.useAliasInUsageLine ?? false,
62324
+ onlyRequiredInUsageLine: config.onlyRequiredInUsageLine ?? false,
62325
+ caseStyle: displayCaseStyle
62097
62326
  };
62098
62327
  }
62099
- function buildApplication(root, appConfig) {
62100
- const config = withDefaults(appConfig);
62101
- if (root.kind === CommandSymbol && config.versionInfo) {
62102
- if (root.usesFlag("version")) {
62103
- throw new InternalError("Unable to use command with flag --version as root when version info is supplied");
62104
- }
62105
- if (root.usesFlag("v")) {
62106
- throw new InternalError("Unable to use command with alias -v as root when version info is supplied");
62107
- }
62108
- }
62109
- let defaultText;
62110
- if ("text" in config.localization) {
62111
- defaultText = config.localization.text;
62112
- } else {
62113
- const text = config.localization.loadText(config.localization.defaultLocale);
62114
- if (!text) {
62115
- throw new InternalError(`No text available for the default locale "${config.localization.defaultLocale}"`);
62116
- }
62117
- defaultText = text;
62118
- }
62119
- return {
62120
- root,
62121
- config,
62122
- defaultText
62123
- };
62124
- }
62125
- function hasDefault(flag) {
62126
- return "default" in flag && typeof flag.default !== "undefined";
62127
- }
62128
- function isOptionalAtRuntime(flag) {
62129
- return flag.optional ?? hasDefault(flag);
62130
- }
62131
62328
  function wrapRequiredFlag(text) {
62132
62329
  return `(${text})`;
62133
62330
  }
@@ -62201,8 +62398,92 @@ function formatUsageLineForParameters(parameters, args) {
62201
62398
  }
62202
62399
  return [...args.prefix, ...flagsUsage, ...positionalUsage].join(" ");
62203
62400
  }
62401
+ function formatForDisplay(flagName, displayCaseStyle) {
62402
+ if (displayCaseStyle === "convert-camel-to-kebab") {
62403
+ return convertCamelCaseToKebabCase(flagName);
62404
+ }
62405
+ return flagName;
62406
+ }
62407
+ function formatAsNegated(flagName, displayCaseStyle) {
62408
+ if (displayCaseStyle === "convert-camel-to-kebab") {
62409
+ return `no-${convertCamelCaseToKebabCase(flagName)}`;
62410
+ }
62411
+ return `no${flagName[0].toUpperCase()}${flagName.slice(1)}`;
62412
+ }
62413
+ function withDefaults(config) {
62414
+ const scannerCaseStyle = config.scanner?.caseStyle ?? "original";
62415
+ const scannerConfig = {
62416
+ caseStyle: scannerCaseStyle,
62417
+ allowArgumentEscapeSequence: config.scanner?.allowArgumentEscapeSequence ?? false,
62418
+ distanceOptions: config.scanner?.distanceOptions ?? {
62419
+ threshold: 7,
62420
+ weights: {
62421
+ insertion: 1,
62422
+ deletion: 3,
62423
+ substitution: 2,
62424
+ transposition: 0
62425
+ }
62426
+ }
62427
+ };
62428
+ const documentationConfig = {
62429
+ alwaysShowHelpAllFlag: config.documentation?.alwaysShowHelpAllFlag ?? false,
62430
+ disableAnsiColor: config.documentation?.disableAnsiColor ?? false,
62431
+ ...withDefaultFormattingConfiguration(config.documentation ?? {}, scannerCaseStyle)
62432
+ };
62433
+ const completionConfig = {
62434
+ includeAliases: config.completion?.includeAliases ?? documentationConfig.useAliasInUsageLine,
62435
+ includeHiddenRoutes: config.completion?.includeHiddenRoutes ?? false,
62436
+ ...config.completion
62437
+ };
62438
+ return {
62439
+ ...config,
62440
+ scanner: scannerConfig,
62441
+ completion: completionConfig,
62442
+ documentation: documentationConfig,
62443
+ localization: {
62444
+ defaultLocale: "en",
62445
+ loadText: defaultTextLoader,
62446
+ ...config.localization
62447
+ }
62448
+ };
62449
+ }
62450
+ function buildApplication(root, appConfig, integrations) {
62451
+ const config = withDefaults(appConfig);
62452
+ let defaultText;
62453
+ if ("text" in config.localization) {
62454
+ defaultText = config.localization.text;
62455
+ } else {
62456
+ const text = config.localization.loadText(config.localization.defaultLocale);
62457
+ if (!text) {
62458
+ throw new InternalError(`No text available for the default locale "${config.localization.defaultLocale}"`);
62459
+ }
62460
+ defaultText = text;
62461
+ }
62462
+ if (integrations) {
62463
+ checkIntegrationsForCollisions(integrations, config.scanner.caseStyle);
62464
+ } else {
62465
+ integrations = gatherDefaultIntegrations(config, defaultText);
62466
+ }
62467
+ const additionalFlags = gatherAdditionalFlagsFromIntegrations(integrations);
62468
+ checkIntegrationsForFlagNameConflicts(root, additionalFlags, config.scanner.caseStyle);
62469
+ validateIntegrations(integrations, root, config);
62470
+ return {
62471
+ root,
62472
+ config,
62473
+ defaultText,
62474
+ integrations
62475
+ };
62476
+ }
62477
+ function formatRowForAdditionalFlag(flag, caseStyle) {
62478
+ return {
62479
+ aliases: flag.aliases ? flag.aliases.map((alias) => `-${alias}`).join(" ") : "",
62480
+ flagName: `--${formatForDisplay(flag.name, caseStyle)}`,
62481
+ brief: flag.brief,
62482
+ hidden: flag.hidden
62483
+ };
62484
+ }
62204
62485
  function formatDocumentationForFlagParameters(flags, aliases, args) {
62205
- const { keywords, briefs } = args.text;
62486
+ const { keywords } = args.text;
62206
62487
  const visibleFlags = Object.entries(flags).filter(([, flag]) => {
62207
62488
  if (flag.hidden && !args.includeHidden) {
62208
62489
  return false;
@@ -62258,32 +62539,21 @@ function formatDocumentationForFlagParameters(flags, aliases, args) {
62258
62539
  hidden: flag.hidden
62259
62540
  };
62260
62541
  });
62261
- rows.push({
62262
- aliases: "-h",
62263
- flagName: atLeastOneOptional ? " --help" : "--help",
62264
- brief: briefs.help
62265
- });
62266
- if (args.includeHelpAllFlag) {
62267
- const helpAllFlagName = formatForDisplay("helpAll", args.config.caseStyle);
62268
- rows.push({
62269
- aliases: "-H",
62270
- flagName: atLeastOneOptional ? ` --${helpAllFlagName}` : `--${helpAllFlagName}`,
62271
- brief: briefs.helpAll,
62272
- hidden: !args.config.alwaysShowHelpAllFlag
62273
- });
62274
- }
62275
- if (args.includeVersionFlag) {
62542
+ for (const flag of args.additionalFlags) {
62543
+ if (flag.hidden && !args.includeHidden) {
62544
+ continue;
62545
+ }
62546
+ const row = formatRowForAdditionalFlag(flag, args.config.caseStyle);
62276
62547
  rows.push({
62277
- aliases: "-v",
62278
- flagName: atLeastOneOptional ? " --version" : "--version",
62279
- brief: briefs.version
62548
+ ...row,
62549
+ flagName: atLeastOneOptional ? ` ${row.flagName}` : row.flagName
62280
62550
  });
62281
62551
  }
62282
62552
  if (args.includeArgumentEscapeSequenceFlag) {
62283
62553
  rows.push({
62284
62554
  aliases: "",
62285
62555
  flagName: atLeastOneOptional ? " --" : "--",
62286
- brief: briefs.argumentEscapeSequence
62556
+ brief: args.text.briefs.argumentEscapeSequence
62287
62557
  });
62288
62558
  }
62289
62559
  return formatRowsWithColumns(rows.map((row) => {
@@ -62298,14 +62568,16 @@ function formatDocumentationForFlagParameters(flags, aliases, args) {
62298
62568
  ];
62299
62569
  }), [" ", " ", " "]);
62300
62570
  }
62301
- function* generateBuiltInFlagUsageLines(args) {
62302
- yield args.config.useAliasInUsageLine ? "-h" : "--help";
62303
- if (args.includeHelpAllFlag) {
62304
- const helpAllFlagName = formatForDisplay("helpAll", args.config.caseStyle);
62305
- yield args.config.useAliasInUsageLine ? "-H" : `--${helpAllFlagName}`;
62306
- }
62307
- if (args.includeVersionFlag) {
62308
- yield args.config.useAliasInUsageLine ? "-v" : "--version";
62571
+ function* generateUsageLinesForAdditionalFlags(flags, includeHidden, caseStyle, useAliasInUsageLine) {
62572
+ for (const flag of flags) {
62573
+ if (flag.hidden && !includeHidden) {
62574
+ continue;
62575
+ }
62576
+ if (useAliasInUsageLine && flag.aliases && flag.aliases.length > 0) {
62577
+ yield `-${flag.aliases[0]}`;
62578
+ } else {
62579
+ yield `--${formatForDisplay(flag.name, caseStyle)}`;
62580
+ }
62309
62581
  }
62310
62582
  }
62311
62583
  function formatDocumentationForPositionalParameters(positional, args) {
@@ -62354,7 +62626,7 @@ function* generateCommandHelpLines(parameters, docs, args) {
62354
62626
  } else {
62355
62627
  yield ` ${formatUsageLineForParameters(parameters, args)}`;
62356
62628
  }
62357
- for (const line of generateBuiltInFlagUsageLines(args)) {
62629
+ for (const line of generateUsageLinesForAdditionalFlags(args.additionalFlags, args.includeHidden, args.config.caseStyle, args.config.useAliasInUsageLine)) {
62358
62630
  yield ` ${prefix} ${line}`;
62359
62631
  }
62360
62632
  yield "";
@@ -62381,20 +62653,6 @@ function* generateCommandHelpLines(parameters, docs, args) {
62381
62653
  }
62382
62654
  }
62383
62655
  }
62384
- function checkForReservedFlags(flags, reserved) {
62385
- for (const flag of reserved) {
62386
- if (flag in flags) {
62387
- throw new InternalError(`Unable to use reserved flag --${flag}`);
62388
- }
62389
- }
62390
- }
62391
- function checkForReservedAliases(aliases, reserved) {
62392
- for (const alias of reserved) {
62393
- if (alias in aliases) {
62394
- throw new InternalError(`Unable to use reserved alias -${alias}`);
62395
- }
62396
- }
62397
- }
62398
62656
  function* asNegationFlagNames(flagName) {
62399
62657
  yield `no-${convertCamelCaseToKebabCase(flagName)}`;
62400
62658
  yield `no${flagName[0].toUpperCase()}${flagName.slice(1)}`;
@@ -62423,8 +62681,6 @@ function checkForInvalidVariadicSeparators(flags) {
62423
62681
  }
62424
62682
  function buildCommand(builderArgs) {
62425
62683
  const { flags = {}, aliases = {} } = builderArgs.parameters;
62426
- checkForReservedFlags(flags, ["help", "helpAll", "help-all"]);
62427
- checkForReservedAliases(aliases, ["h", "H"]);
62428
62684
  checkForNegationCollisions(flags);
62429
62685
  checkForInvalidVariadicSeparators(flags);
62430
62686
  let loader;
@@ -62455,7 +62711,13 @@ function buildCommand(builderArgs) {
62455
62711
  return text + `
62456
62712
  `;
62457
62713
  },
62458
- usesFlag: (flagName) => {
62714
+ usesFlag: (flagName, caseStyle) => {
62715
+ if (caseStyle === "allow-kebab-for-camel") {
62716
+ const kebabCase = convertCamelCaseToKebabCase(flagName);
62717
+ if (kebabCase in flags) {
62718
+ return true;
62719
+ }
62720
+ }
62459
62721
  return Boolean(flagName in flags || flagName in aliases);
62460
62722
  }
62461
62723
  };
@@ -62474,7 +62736,7 @@ function* generateRouteMapHelpLines(routes, docs, args) {
62474
62736
  }
62475
62737
  }
62476
62738
  const prefix = args.prefix.join(" ");
62477
- for (const line of generateBuiltInFlagUsageLines(args)) {
62739
+ for (const line of generateUsageLinesForAdditionalFlags(args.additionalFlags, args.includeHidden, args.config.caseStyle, args.config.useAliasInUsageLine)) {
62478
62740
  yield ` ${prefix} ${line}`;
62479
62741
  }
62480
62742
  yield "";
@@ -62529,14 +62791,14 @@ function buildRouteMap({
62529
62791
  const aliasesByRoute = /* @__PURE__ */ new Map;
62530
62792
  for (const [alias, routeName] of Object.entries(activeAliases)) {
62531
62793
  if (alias in routes) {
62532
- throw new InternalError(`Cannot use "${alias}" as an alias when a route with that name already exists`);
62794
+ throw new InternalError(`Cannot use '${alias}' as an alias when a route with that name already exists`);
62533
62795
  }
62534
62796
  const routeAliases = aliasesByRoute.get(routeName) ?? [];
62535
62797
  aliasesByRoute.set(routeName, [...routeAliases, alias]);
62536
62798
  }
62537
62799
  const defaultCommand = defaultCommandRoute ? routes[defaultCommandRoute] : undefined;
62538
62800
  if (defaultCommand && defaultCommand.kind === RouteMapSymbol) {
62539
- throw new InternalError(`Cannot use "${defaultCommandRoute}" as the default command because it is not a Command`);
62801
+ throw new InternalError(`Cannot use '${defaultCommandRoute}' as the default command because it is not a Command`);
62540
62802
  }
62541
62803
  const resolveRouteName = (input) => {
62542
62804
  if (input in activeAliases) {
@@ -62557,8 +62819,8 @@ function buildRouteMap({
62557
62819
  const routeNames = this.getAllEntries().filter((entry) => !entry.hidden).map((entry) => entry.name[args.config.caseStyle]);
62558
62820
  return `${args.prefix.join(" ")} ${routeNames.join("|")} ...`;
62559
62821
  },
62560
- formatHelp: (config) => {
62561
- const lines = [...generateRouteMapHelpLines(routes, docs, config)];
62822
+ formatHelp: (args) => {
62823
+ const lines = [...generateRouteMapHelpLines(routes, docs, args)];
62562
62824
  const text = lines.join(`
62563
62825
  `);
62564
62826
  return text + `
@@ -62851,7 +63113,7 @@ var routes = buildRouteMap({
62851
63113
  var app = buildApplication(routes, {
62852
63114
  name: "mcp",
62853
63115
  versionInfo: {
62854
- currentVersion: "0.0.31"
63116
+ currentVersion: "0.0.33"
62855
63117
  }
62856
63118
  });
62857
63119
  run(app, process4.argv.slice(2), buildContext(process4));
@@ -62859,5 +63121,5 @@ export {
62859
63121
  app
62860
63122
  };
62861
63123
 
62862
- //# debugId=7D44D3460F5EF0A764756E2164756E21
63124
+ //# debugId=A6F639F9CFD6FECC64756E2164756E21
62863
63125
  //# sourceMappingURL=mcp-server.js.map