@cavelon/cli 0.2.16 → 0.2.17

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.
@@ -3343,6 +3343,37 @@ var require_utils = __commonJS({
3343
3343
  }
3344
3344
  return output.join("");
3345
3345
  }
3346
+ function removeDotSegmentsRelative(path4) {
3347
+ if (path4 === "" || path4[0] === "/") {
3348
+ return removeDotSegments(path4);
3349
+ }
3350
+ const segments = path4.split("/");
3351
+ const last = segments.length - 1;
3352
+ const output = [];
3353
+ let trailingDirectory = false;
3354
+ for (let i = 0; i <= last; i++) {
3355
+ const segment = segments[i];
3356
+ if (segment === "." || segment === "..") {
3357
+ if (segment === "..") {
3358
+ if (output.length !== 0 && output[output.length - 1] !== "..") {
3359
+ output.pop();
3360
+ } else {
3361
+ output.push("..");
3362
+ }
3363
+ }
3364
+ trailingDirectory = i === last;
3365
+ } else {
3366
+ output.push(segment);
3367
+ }
3368
+ }
3369
+ if (trailingDirectory && output[output.length - 1] !== "..") {
3370
+ output.push("");
3371
+ }
3372
+ if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
3373
+ output.unshift(".");
3374
+ }
3375
+ return output.join("/");
3376
+ }
3346
3377
  var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3347
3378
  var HOST_DELIM_RE = /[@/?#:]/g;
3348
3379
  var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
@@ -3603,6 +3634,7 @@ var require_utils = __commonJS({
3603
3634
  encodeFragment,
3604
3635
  escapePreservingEscapes,
3605
3636
  removeDotSegments,
3637
+ removeDotSegmentsRelative,
3606
3638
  isIPv4,
3607
3639
  isUUID,
3608
3640
  normalizeIPv6,
@@ -3826,16 +3858,18 @@ var require_schemes = __commonJS({
3826
3858
  var require_fast_uri = __commonJS({
3827
3859
  "node_modules/fast-uri/index.js"(exports, module) {
3828
3860
  "use strict";
3829
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3861
+ var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3830
3862
  var { SCHEMES, getSchemeHandler } = require_schemes();
3831
3863
  var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3832
3864
  var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3833
- function decodeValidScheme(scheme) {
3834
- const decodedScheme = unescape(String(scheme));
3835
- if (!VALID_SCHEME.test(decodedScheme)) {
3865
+ var MALFORMED_HOST_ERROR = "URI host is malformed.";
3866
+ var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
3867
+ function validateScheme(scheme) {
3868
+ const stringScheme = String(scheme);
3869
+ if (!VALID_SCHEME.test(stringScheme)) {
3836
3870
  throw new TypeError(MALFORMED_SCHEME_ERROR);
3837
3871
  }
3838
- return decodedScheme;
3872
+ return stringScheme;
3839
3873
  }
3840
3874
  function normalize(uri, options) {
3841
3875
  if (typeof uri === "string") {
@@ -3872,6 +3906,9 @@ var require_fast_uri = __commonJS({
3872
3906
  const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3873
3907
  const resolvedHost = resolved.host;
3874
3908
  const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3909
+ if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
3910
+ throw new Error(MALFORMED_HOST_ERROR);
3911
+ }
3875
3912
  canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3876
3913
  const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
3877
3914
  if (resolved.error && !encodedASCIIHost) {
@@ -3913,14 +3950,15 @@ var require_fast_uri = __commonJS({
3913
3950
  if (relative.path[0] === "/") {
3914
3951
  target.path = removeDotSegments(relative.path);
3915
3952
  } else {
3916
- if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3953
+ const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
3954
+ if (baseHasAuthority && !base.path) {
3917
3955
  target.path = "/" + relative.path;
3918
3956
  } else if (!base.path) {
3919
3957
  target.path = relative.path;
3920
3958
  } else {
3921
3959
  target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3922
3960
  }
3923
- target.path = removeDotSegments(target.path);
3961
+ target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
3924
3962
  }
3925
3963
  target.query = relative.query;
3926
3964
  }
@@ -3958,12 +3996,13 @@ var require_fast_uri = __commonJS({
3958
3996
  const options = Object.assign({}, opts);
3959
3997
  const uriTokens = [];
3960
3998
  if (component.scheme) {
3961
- component.scheme = decodeValidScheme(component.scheme);
3999
+ component.scheme = validateScheme(component.scheme);
3962
4000
  }
3963
4001
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3964
4002
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3965
4003
  const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3966
- const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
4004
+ const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
4005
+ const pathNoScheme = !options.skipEscape && schemelessReference;
3967
4006
  if (component.path !== void 0) {
3968
4007
  if (!options.skipEscape) {
3969
4008
  component.path = serializePathEncoding(component.path, pathNoScheme);
@@ -3972,7 +4011,7 @@ var require_fast_uri = __commonJS({
3972
4011
  }
3973
4012
  }
3974
4013
  if (options.reference !== "suffix" && component.scheme) {
3975
- component.scheme = decodeValidScheme(component.scheme);
4014
+ component.scheme = validateScheme(component.scheme);
3976
4015
  uriTokens.push(component.scheme, ":");
3977
4016
  }
3978
4017
  const authority = recomposeAuthority(component);
@@ -3988,9 +4027,9 @@ var require_fast_uri = __commonJS({
3988
4027
  if (component.path !== void 0) {
3989
4028
  let s = component.path;
3990
4029
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3991
- s = removeDotSegments(s);
4030
+ s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
3992
4031
  }
3993
- if (pathNoScheme) {
4032
+ if (schemelessReference) {
3994
4033
  s = serializePathEncoding(s, true);
3995
4034
  }
3996
4035
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
@@ -4037,16 +4076,34 @@ var require_fast_uri = __commonJS({
4037
4076
  return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4038
4077
  }
4039
4078
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4079
+ if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
4080
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
4081
+ return true;
4082
+ }
4040
4083
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4084
+ let url;
4041
4085
  try {
4042
- parsed.host = new URL("http://" + parsed.host).hostname;
4086
+ url = new URL("http://" + parsed.host);
4043
4087
  } catch (e) {
4044
4088
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4045
4089
  return true;
4046
4090
  }
4091
+ if (!isHostOnlyURL(url)) {
4092
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
4093
+ return true;
4094
+ }
4095
+ parsed.host = url.hostname;
4047
4096
  }
4048
4097
  return false;
4049
4098
  }
4099
+ function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
4100
+ return Boolean(
4101
+ parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
4102
+ );
4103
+ }
4104
+ function isHostOnlyURL(url) {
4105
+ return url.username === "" && url.password === "" && url.port === "" && url.pathname === "/" && url.search === "" && url.hash === "" && url.hostname !== "";
4106
+ }
4050
4107
  function parseWithStatus(uri, opts) {
4051
4108
  const options = Object.assign({}, opts);
4052
4109
  const parsed = {
@@ -4101,9 +4158,8 @@ var require_fast_uri = __commonJS({
4101
4158
  parsed.query = matches[7];
4102
4159
  parsed.fragment = matches[8];
4103
4160
  if (parsed.scheme !== void 0) {
4104
- const decodedScheme = unescape(parsed.scheme);
4105
- if (VALID_SCHEME.test(decodedScheme)) {
4106
- parsed.scheme = decodedScheme.toLowerCase();
4161
+ if (VALID_SCHEME.test(parsed.scheme)) {
4162
+ parsed.scheme = parsed.scheme.toLowerCase();
4107
4163
  } else {
4108
4164
  parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4109
4165
  malformedScheme = true;
@@ -4131,7 +4187,7 @@ var require_fast_uri = __commonJS({
4131
4187
  malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4132
4188
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4133
4189
  if (malformedIPLiteral) {
4134
- parsed.error = parsed.error || "URI host is malformed.";
4190
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
4135
4191
  malformedAuthorityOrPort = true;
4136
4192
  }
4137
4193
  } else {
@@ -4159,7 +4215,7 @@ var require_fast_uri = __commonJS({
4159
4215
  if (!isIP) {
4160
4216
  host = normalizePercentEncoding(host.toLowerCase());
4161
4217
  }
4162
- parsed.host = reescapeHostDelimiters(host, isIP);
4218
+ parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
4163
4219
  }
4164
4220
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4165
4221
  if (parsed.path) {
@@ -3343,6 +3343,37 @@ var require_utils = __commonJS({
3343
3343
  }
3344
3344
  return output.join("");
3345
3345
  }
3346
+ function removeDotSegmentsRelative(path3) {
3347
+ if (path3 === "" || path3[0] === "/") {
3348
+ return removeDotSegments(path3);
3349
+ }
3350
+ const segments = path3.split("/");
3351
+ const last = segments.length - 1;
3352
+ const output = [];
3353
+ let trailingDirectory = false;
3354
+ for (let i = 0; i <= last; i++) {
3355
+ const segment = segments[i];
3356
+ if (segment === "." || segment === "..") {
3357
+ if (segment === "..") {
3358
+ if (output.length !== 0 && output[output.length - 1] !== "..") {
3359
+ output.pop();
3360
+ } else {
3361
+ output.push("..");
3362
+ }
3363
+ }
3364
+ trailingDirectory = i === last;
3365
+ } else {
3366
+ output.push(segment);
3367
+ }
3368
+ }
3369
+ if (trailingDirectory && output[output.length - 1] !== "..") {
3370
+ output.push("");
3371
+ }
3372
+ if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
3373
+ output.unshift(".");
3374
+ }
3375
+ return output.join("/");
3376
+ }
3346
3377
  var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
3347
3378
  var HOST_DELIM_RE = /[@/?#:]/g;
3348
3379
  var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
@@ -3603,6 +3634,7 @@ var require_utils = __commonJS({
3603
3634
  encodeFragment,
3604
3635
  escapePreservingEscapes,
3605
3636
  removeDotSegments,
3637
+ removeDotSegmentsRelative,
3606
3638
  isIPv4,
3607
3639
  isUUID,
3608
3640
  normalizeIPv6,
@@ -3826,16 +3858,18 @@ var require_schemes = __commonJS({
3826
3858
  var require_fast_uri = __commonJS({
3827
3859
  "node_modules/fast-uri/index.js"(exports, module) {
3828
3860
  "use strict";
3829
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3861
+ var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3830
3862
  var { SCHEMES, getSchemeHandler } = require_schemes();
3831
3863
  var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3832
3864
  var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3833
- function decodeValidScheme(scheme) {
3834
- const decodedScheme = unescape(String(scheme));
3835
- if (!VALID_SCHEME.test(decodedScheme)) {
3865
+ var MALFORMED_HOST_ERROR = "URI host is malformed.";
3866
+ var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
3867
+ function validateScheme(scheme) {
3868
+ const stringScheme = String(scheme);
3869
+ if (!VALID_SCHEME.test(stringScheme)) {
3836
3870
  throw new TypeError(MALFORMED_SCHEME_ERROR);
3837
3871
  }
3838
- return decodedScheme;
3872
+ return stringScheme;
3839
3873
  }
3840
3874
  function normalize(uri, options) {
3841
3875
  if (typeof uri === "string") {
@@ -3872,6 +3906,9 @@ var require_fast_uri = __commonJS({
3872
3906
  const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3873
3907
  const resolvedHost = resolved.host;
3874
3908
  const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3909
+ if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
3910
+ throw new Error(MALFORMED_HOST_ERROR);
3911
+ }
3875
3912
  canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3876
3913
  const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
3877
3914
  if (resolved.error && !encodedASCIIHost) {
@@ -3913,14 +3950,15 @@ var require_fast_uri = __commonJS({
3913
3950
  if (relative.path[0] === "/") {
3914
3951
  target.path = removeDotSegments(relative.path);
3915
3952
  } else {
3916
- if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3953
+ const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
3954
+ if (baseHasAuthority && !base.path) {
3917
3955
  target.path = "/" + relative.path;
3918
3956
  } else if (!base.path) {
3919
3957
  target.path = relative.path;
3920
3958
  } else {
3921
3959
  target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3922
3960
  }
3923
- target.path = removeDotSegments(target.path);
3961
+ target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
3924
3962
  }
3925
3963
  target.query = relative.query;
3926
3964
  }
@@ -3958,12 +3996,13 @@ var require_fast_uri = __commonJS({
3958
3996
  const options = Object.assign({}, opts);
3959
3997
  const uriTokens = [];
3960
3998
  if (component.scheme) {
3961
- component.scheme = decodeValidScheme(component.scheme);
3999
+ component.scheme = validateScheme(component.scheme);
3962
4000
  }
3963
4001
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3964
4002
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3965
4003
  const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3966
- const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
4004
+ const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
4005
+ const pathNoScheme = !options.skipEscape && schemelessReference;
3967
4006
  if (component.path !== void 0) {
3968
4007
  if (!options.skipEscape) {
3969
4008
  component.path = serializePathEncoding(component.path, pathNoScheme);
@@ -3972,7 +4011,7 @@ var require_fast_uri = __commonJS({
3972
4011
  }
3973
4012
  }
3974
4013
  if (options.reference !== "suffix" && component.scheme) {
3975
- component.scheme = decodeValidScheme(component.scheme);
4014
+ component.scheme = validateScheme(component.scheme);
3976
4015
  uriTokens.push(component.scheme, ":");
3977
4016
  }
3978
4017
  const authority = recomposeAuthority(component);
@@ -3988,9 +4027,9 @@ var require_fast_uri = __commonJS({
3988
4027
  if (component.path !== void 0) {
3989
4028
  let s = component.path;
3990
4029
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3991
- s = removeDotSegments(s);
4030
+ s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
3992
4031
  }
3993
- if (pathNoScheme) {
4032
+ if (schemelessReference) {
3994
4033
  s = serializePathEncoding(s, true);
3995
4034
  }
3996
4035
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
@@ -4037,16 +4076,34 @@ var require_fast_uri = __commonJS({
4037
4076
  return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4038
4077
  }
4039
4078
  function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4079
+ if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
4080
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
4081
+ return true;
4082
+ }
4040
4083
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4084
+ let url;
4041
4085
  try {
4042
- parsed.host = new URL("http://" + parsed.host).hostname;
4086
+ url = new URL("http://" + parsed.host);
4043
4087
  } catch (e) {
4044
4088
  parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4045
4089
  return true;
4046
4090
  }
4091
+ if (!isHostOnlyURL(url)) {
4092
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
4093
+ return true;
4094
+ }
4095
+ parsed.host = url.hostname;
4047
4096
  }
4048
4097
  return false;
4049
4098
  }
4099
+ function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
4100
+ return Boolean(
4101
+ parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
4102
+ );
4103
+ }
4104
+ function isHostOnlyURL(url) {
4105
+ return url.username === "" && url.password === "" && url.port === "" && url.pathname === "/" && url.search === "" && url.hash === "" && url.hostname !== "";
4106
+ }
4050
4107
  function parseWithStatus(uri, opts) {
4051
4108
  const options = Object.assign({}, opts);
4052
4109
  const parsed = {
@@ -4101,9 +4158,8 @@ var require_fast_uri = __commonJS({
4101
4158
  parsed.query = matches[7];
4102
4159
  parsed.fragment = matches[8];
4103
4160
  if (parsed.scheme !== void 0) {
4104
- const decodedScheme = unescape(parsed.scheme);
4105
- if (VALID_SCHEME.test(decodedScheme)) {
4106
- parsed.scheme = decodedScheme.toLowerCase();
4161
+ if (VALID_SCHEME.test(parsed.scheme)) {
4162
+ parsed.scheme = parsed.scheme.toLowerCase();
4107
4163
  } else {
4108
4164
  parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4109
4165
  malformedScheme = true;
@@ -4131,7 +4187,7 @@ var require_fast_uri = __commonJS({
4131
4187
  malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4132
4188
  parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4133
4189
  if (malformedIPLiteral) {
4134
- parsed.error = parsed.error || "URI host is malformed.";
4190
+ parsed.error = parsed.error || MALFORMED_HOST_ERROR;
4135
4191
  malformedAuthorityOrPort = true;
4136
4192
  }
4137
4193
  } else {
@@ -4159,7 +4215,7 @@ var require_fast_uri = __commonJS({
4159
4215
  if (!isIP) {
4160
4216
  host = normalizePercentEncoding(host.toLowerCase());
4161
4217
  }
4162
- parsed.host = reescapeHostDelimiters(host, isIP);
4218
+ parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
4163
4219
  }
4164
4220
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
4165
4221
  if (parsed.path) {
@@ -11,6 +11,13 @@ format as a JSON Schema; `cavelon` splits it along that schema's top-level
11
11
  sections, so the files follow whatever the instance version defines. Do not
12
12
  assume a section or field exists: check the schema or the docs first.
13
13
 
14
+ Before reading from or changing the instance, follow cavelon-loop's connection
15
+ readiness check: discover the actual session's tools and call `whoami`.
16
+ Tell the person if tools, login or instance access fail; announce any CLI
17
+ fallback and check its `whoami`. Local authoring can continue without live
18
+ verification. Loaded skills alone do not establish a working connection.
19
+ An intentionally CLI-only setup checks `cavelon whoami --json` directly.
20
+
14
21
  ## New solutions: make the Canvas useful
15
22
 
16
23
  For a new ordinary chat or trigger solution, include its connected **Chat
@@ -6,6 +6,13 @@ license: Apache-2.0
6
6
 
7
7
  # Long-running work: loops and Sandboxes
8
8
 
9
+ Before instance work, follow cavelon-loop's connection readiness check:
10
+ discover this session's Cavelon tools and call `whoami`. Report unavailable
11
+ tools, login or instance access with a repair step; announce CLI fallback and
12
+ check its `whoami` too. A disconnected session is not evidence that a loop is
13
+ stopped or a job failed. Loaded skills do not establish a working connection.
14
+ An intentionally CLI-only setup checks `cavelon whoami --json` directly.
15
+
9
16
  A **Masterloop** node runs one solution again and again in bounded iterations
10
17
  until its check passes, its budget or deadline runs out, or a person stops it.
11
18
  Each iteration returns `continue`, `wait`, `done` or `blocked`. A loop starts
@@ -13,6 +13,16 @@ use it when you parse the result.
13
13
 
14
14
  ## Before anything
15
15
 
16
+ - **Verify the connection before instance work.** Discover this session's
17
+ Cavelon tools (use the client's tool search if deferred), then call
18
+ `whoami` for the selected solution folder. Loaded skills do not establish
19
+ connectivity. Tell the person immediately if the tools are unavailable,
20
+ login is missing or the instance cannot be reached, with a repair step.
21
+ Announce CLI fallback explicitly and check its `whoami` too. See
22
+ [connection readiness](references/connection-readiness.md) for diagnosis,
23
+ recovery and when to repeat the check. An intentionally CLI-only client
24
+ starts with `cavelon whoami --json` instead, without a missing-MCP warning.
25
+ Local authoring may continue.
16
26
  - **Select the local solution folder.** In a repository with several solutions,
17
27
  pass `solution_dir`, such as `solutions/review`, on MCP calls. It resolves
18
28
  inside the server's startup workspace and selects that folder's
@@ -39,10 +49,12 @@ use it when you parse the result.
39
49
  person who does it (the description says who), as for a secret. Where the
40
50
  instance does not say (an older one), try, and a refusal names what the
41
51
  credential lacks.
42
- - **Never handle a token.** If a command exits 7 (not authorised) or says no
43
- token, ask the person to run `cavelon login --instance <url>` themselves (in a
44
- terminal, or with a `!` prefix where your client offers one). Never ask them
45
- to paste a token to you, and never put one in a file or an argument.
52
+ - **Never handle a token.** A missing, expired or revoked credential needs
53
+ `cavelon login --instance <url>`, run by the person in their own terminal
54
+ (or with a `!` prefix where the client offers one). Exit 7 can also mean a
55
+ permission or tenant refusal: follow its role/target guidance rather than
56
+ requesting another login. Never ask for a token or put one in a file or
57
+ an argument.
46
58
  - **Secrets are set by a person.** When a preview or `cavelon secrets list`
47
59
  names a secret that is not set, tell the person the exact command to run in
48
60
  their terminal, `cavelon secrets set <name>` (as `apply` prints it, with its
@@ -200,7 +212,9 @@ in a pinned recovery snapshot and clears the draft; report its warnings.
200
212
  agent alone leaves the Canvas debug entry incomplete. Follow the
201
213
  authoring skill's Canvas entrypoints reference, including its Masterloop
202
214
  iteration exceptions. This does not activate a trigger or run its demo.
203
- 3. **Validate** offline: `cavelon validate`. Fix every error; `cavelon explain
215
+ 3. **Validate** the package: `cavelon validate`. Use `--offline` when the
216
+ instance must not be contacted; it uses cached metadata and reports checks
217
+ it cannot make. Fix every error; `cavelon explain
204
218
  <code>` says what a code means and how to fix it. Besides the schema it
205
219
  finds duplicate slugs, handoffs and test assertions naming an agent the
206
220
  package lacks, fields the schema does not have (with "did you mean"), and
@@ -0,0 +1,48 @@
1
+ # Check the connection before instance work
2
+
3
+ Loaded skills, a plugin marked installed, and a successful MCP handshake are
4
+ different from a working, authenticated instance connection. Before the first
5
+ instance operation for a selected solution folder in this session:
6
+
7
+ If this client intentionally uses CLI-only access, start with
8
+ `cavelon whoami --json` in the selected folder/target instead. Do not report
9
+ a missing MCP connection for a setup that does not use MCP. For native
10
+ Cavelon integrations, discover their `whoami` tool as you would an MCP tool.
11
+
12
+ 1. For an MCP/native-tool integration, discover the Cavelon tools in the
13
+ **actual coding-agent session**. Use the
14
+ client's tool search where tools are deferred; not seeing an eagerly listed
15
+ tool does not establish that the server is absent. Find `whoami`, rather
16
+ than guessing a client-specific tool prefix.
17
+ 2. Call that `whoami`, with the same `solution_dir` and tenant selection
18
+ the task will use. On success, briefly tell the person that Cavelon is
19
+ connected and authenticated and check the returned target and permissions.
20
+ A successful call does not grant permissions its credential lacks.
21
+ 3. If discovery or the call fails, **tell the person before proceeding**:
22
+
23
+ | Observation | What to explain and how to recover |
24
+ |---|---|
25
+ | No usable Cavelon tools after discovery, or a transport failure | Cavelon's MCP connection is unavailable in this session. In Claude Code open `/mcp`, inspect the Cavelon server and reconnect it. Run `cavelon setup --check --agents claude` in a terminal for installation/start/login diagnostics; repair what it reports, then restart or reconnect the coding agent. Other clients use their own MCP/tools panel. |
26
+ | `no_instance` | No instance is selected for this folder. Check its `cavelon.yaml`/environment; for a new setup, a person runs `cavelon login --instance <url>` in their own terminal. |
27
+ | No token, expired/revoked token or an authentication refusal | Explain that Cavelon needs login again. A person runs `cavelon login --instance <url>` themselves. Never read, request or paste their token. |
28
+ | Network, TLS, DNS or instance failure | Explain that the instance cannot be reached and pass on the error's safe repair hint. Do not describe it as a missing plugin or ask for another token without an authentication error. |
29
+ | Permission or tenant refusal | The server is reachable, but this credential cannot perform that operation or enter that tenant. Follow the returned permission/target guidance. |
30
+
31
+ **Do not silently fall back.** A working CLI is a valid alternative, but say
32
+ "Cavelon MCP is unavailable; I am using the CLI instead" and check
33
+ `cavelon whoami --json` for the selected folder/target before using it. The
34
+ same permissions and confirmation rules apply. Offline authoring and
35
+ formatting may continue; do not claim instance validation, a test run, an
36
+ import or a deployment without a successful result from that operation.
37
+
38
+ Report a warning once while its cause stays the same. Check again after a
39
+ reconnect, login, selected-target change or subsequent connection failure,
40
+ and announce recovery once. Do not probe the connection before every tool.
41
+
42
+ Claude Code's plugin startup hook shows a notice in a Cavelon workspace,
43
+ including repositories with child solutions. It checks only whether `cavelon`
44
+ or `npx` is on PATH, without executing either, fetching packages, reading
45
+ credentials or contacting the instance. Its notice says the connection is
46
+ **not yet verified**, not failed. SessionStart runs before MCP is available;
47
+ the in-session check above supplies the actual evidence. A new-solution
48
+ request in an unrelated folder gets this check when the skill is first used.
@@ -6,10 +6,17 @@ license: Apache-2.0
6
6
 
7
7
  # Testing and optimizing a Cavelon solution
8
8
 
9
- A solution is ready when its test suites pass on the instance, not when the
10
- package validates. Test against a draft solution or a test tenant
9
+ Readiness comes from the instance's published test gate and other checks;
10
+ package validation alone does not establish it. Test against a draft solution or a test tenant
11
11
  (`--env test`), never by trying things on an active solution.
12
12
 
13
+ Before instance tests, follow cavelon-loop's connection readiness check:
14
+ discover the actual session's Cavelon tools and call `whoami`. Tell the
15
+ person immediately if discovery, login or instance access fails. Announce
16
+ CLI fallback and check its `whoami` too; never claim tests ran without their
17
+ successful instance results. Loaded skills alone do not prove connectivity.
18
+ An intentionally CLI-only setup checks `cavelon whoami --json` directly.
19
+
13
20
  ## Canvas debug readiness
14
21
 
15
22
  For a newly authored ordinary chat/trigger solution, check its connected
@@ -50,8 +57,11 @@ Write cases for:
50
57
 
51
58
  A step's `evaluation_criteria` can hold, besides the judge's criteria (plain
52
59
  sentences), **assertions**: objects with a `type` and a `value`, checked in
53
- code before the judge runs. A failed assertion fails the step whatever the
54
- judge says, so use them for facts with one right answer:
60
+ code before the judge runs. A failed gating assertion fails the step whatever
61
+ the judge says, so use them for facts with one right answer. Where the schema
62
+ offers `gate: false`, a report-only assertion is evaluated and shown without
63
+ failing the step; the plain-language reference in cavelon-authoring has an
64
+ example. Check the criterion schema before using that field.
55
65
 
56
66
  | Type | Value | Passes when |
57
67
  |---|---|---|
@@ -151,7 +161,9 @@ each call under your shell's time limit). `test run --wait --timeout 5m` does
151
161
  both in one call where your client allows long commands; when its wait ends
152
162
  first, its last line is the command that resumes, with the same timeout. Exit 1 after a run
153
163
  means a case failed, even though the run itself finished; the output names the
154
- cases that did not pass and why, and `cavelon trace <run>` shows each one. Exit
164
+ cases that did not pass and why, and `cavelon trace <run>` shows each one.
165
+ This case-result exit code is separate from the instance's readiness verdict,
166
+ which can use a configured pass threshold, tag minimums and gate profile. Exit
155
167
  1 also means the run measured nothing comparable (steps not run, technical
156
168
  errors, no pass rate): it is no evidence the solution works, so do not go on to
157
169
  `activate`; find the cause and run again. Exit 5 means answers wait for a
@@ -174,9 +186,16 @@ The case's own reason (which knowledge base, which value) is in the output of
174
186
  Without `--suite`, `test run` runs every suite of the solution except those
175
187
  that never vote in readiness: a campaign's question check (tagged `engagement`
176
188
  and `rule:<id>`, made by the Admin's Engagement editor, and never part of the
177
- package). They are listed under `skipped` and never change the exit code; a
178
- failed question there is a content gap for the campaign's author.
179
- `--suite <name>` runs one when asked.
189
+ package), or a suite a person switched out of the vote. They are listed under
190
+ `skipped` and never change the exit code; a failed question there is a content
191
+ gap for the campaign's author. `--suite <name>` runs one when asked.
192
+
193
+ `--profile <key>` runs a suite's run profile (its `settings.profiles`, chosen
194
+ by tags) instead of the whole suite, for example a smoke profile before a
195
+ deploy; without `--suite`, every suite that has it, the others skipped as
196
+ `no_profile`. Where a suite's `gate.profile` names a profile, only a run of it
197
+ counts for publishing: run that one before asking for activation. `--tags`
198
+ runs the cases carrying one of the tags and never counts for publishing.
180
199
 
181
200
  ## Database query tools
182
201
 
@@ -279,8 +298,10 @@ the Admin. Then:
279
298
  says how to fix it.
280
299
 
281
300
  Unattended schedules, where offered by the instance, are enabled by a person in
282
- the Admin. A schedule or automatic run is useful regression evidence but does
283
- not replace the latest manually started whole-suite run required for activation.
301
+ the Admin. A schedule or automatic run is useful regression evidence. Before
302
+ activation/publication, run the manual selection required by the instance's
303
+ published readiness policy: its gate profile when configured, otherwise the
304
+ whole suite. A whole-suite run does not substitute for a required gate profile.
284
305
  Read the instance's current Graph Check errors and published catalog; fix the
285
306
  named node/configuration before trying activation again.
286
307
 
@@ -412,7 +433,8 @@ previews first and is the person's decision: show the preview; over MCP the
412
433
  client asks them when you confirm with its token, and from your shell they run
413
434
  the confirm command in their own terminal. Do not add a separate chat approval
414
435
  before that native dialog; an explicitly enabled YOLO mode still asks for this
415
- critical change. When every suite passes,
436
+ critical change. Review test failures and run the readiness selection required
437
+ by the instance; when its published readiness checks pass,
416
438
  `cavelon activate --harness <name or slug>` goes through the readiness gate; if the
417
439
  token may not activate, a person activates in the Admin. A solution that a
418
440
  channel or an active trigger reaches goes live for them at once, so its
@@ -422,6 +444,5 @@ whose reach or route effect is unknown. It needs no confirm only when no
422
444
  channel or active trigger reaches it and readiness explicitly says
423
445
  `takes_default_route: false`. The preview reserves no route state; the
424
446
  successful result's `took_default_route` fields report the actual effect.
425
- Show it; over MCP the
426
- client asks them when you confirm with its token, and from your shell they run
427
- the confirm command in their own terminal.
447
+ Where the preview requires a person, show it and use that single native
448
+ approval or the person's own-terminal command.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cavelon/cli",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "The cavelon binary: CLI and local MCP server for building Cavelon solutions with a coding agent.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/goodguys-gmbh/cavelon-dev-kit",
@@ -46,7 +46,7 @@
46
46
  "@types/node": "^20.19.0",
47
47
  "esbuild": "0.28.2",
48
48
  "eslint": "^10.12.0",
49
- "typebox": "1.4.2",
49
+ "typebox": "1.4.3",
50
50
  "typescript": "~6.0.3",
51
51
  "typescript-eslint": "^8.71.0",
52
52
  "vitest": "^4.0.0",