@klaudworks/rmr 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1114,17 +1114,17 @@ var require_visit = __commonJS((exports) => {
1114
1114
  visit.BREAK = BREAK;
1115
1115
  visit.SKIP = SKIP;
1116
1116
  visit.REMOVE = REMOVE;
1117
- function visit_(key, node, visitor, path) {
1118
- const ctrl = callVisitor(key, node, visitor, path);
1117
+ function visit_(key, node, visitor, path2) {
1118
+ const ctrl = callVisitor(key, node, visitor, path2);
1119
1119
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
1120
- replaceNode(key, path, ctrl);
1121
- return visit_(key, ctrl, visitor, path);
1120
+ replaceNode(key, path2, ctrl);
1121
+ return visit_(key, ctrl, visitor, path2);
1122
1122
  }
1123
1123
  if (typeof ctrl !== "symbol") {
1124
1124
  if (identity.isCollection(node)) {
1125
- path = Object.freeze(path.concat(node));
1125
+ path2 = Object.freeze(path2.concat(node));
1126
1126
  for (let i = 0;i < node.items.length; ++i) {
1127
- const ci = visit_(i, node.items[i], visitor, path);
1127
+ const ci = visit_(i, node.items[i], visitor, path2);
1128
1128
  if (typeof ci === "number")
1129
1129
  i = ci - 1;
1130
1130
  else if (ci === BREAK)
@@ -1135,13 +1135,13 @@ var require_visit = __commonJS((exports) => {
1135
1135
  }
1136
1136
  }
1137
1137
  } else if (identity.isPair(node)) {
1138
- path = Object.freeze(path.concat(node));
1139
- const ck = visit_("key", node.key, visitor, path);
1138
+ path2 = Object.freeze(path2.concat(node));
1139
+ const ck = visit_("key", node.key, visitor, path2);
1140
1140
  if (ck === BREAK)
1141
1141
  return BREAK;
1142
1142
  else if (ck === REMOVE)
1143
1143
  node.key = null;
1144
- const cv = visit_("value", node.value, visitor, path);
1144
+ const cv = visit_("value", node.value, visitor, path2);
1145
1145
  if (cv === BREAK)
1146
1146
  return BREAK;
1147
1147
  else if (cv === REMOVE)
@@ -1162,17 +1162,17 @@ var require_visit = __commonJS((exports) => {
1162
1162
  visitAsync.BREAK = BREAK;
1163
1163
  visitAsync.SKIP = SKIP;
1164
1164
  visitAsync.REMOVE = REMOVE;
1165
- async function visitAsync_(key, node, visitor, path) {
1166
- const ctrl = await callVisitor(key, node, visitor, path);
1165
+ async function visitAsync_(key, node, visitor, path2) {
1166
+ const ctrl = await callVisitor(key, node, visitor, path2);
1167
1167
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
1168
- replaceNode(key, path, ctrl);
1169
- return visitAsync_(key, ctrl, visitor, path);
1168
+ replaceNode(key, path2, ctrl);
1169
+ return visitAsync_(key, ctrl, visitor, path2);
1170
1170
  }
1171
1171
  if (typeof ctrl !== "symbol") {
1172
1172
  if (identity.isCollection(node)) {
1173
- path = Object.freeze(path.concat(node));
1173
+ path2 = Object.freeze(path2.concat(node));
1174
1174
  for (let i = 0;i < node.items.length; ++i) {
1175
- const ci = await visitAsync_(i, node.items[i], visitor, path);
1175
+ const ci = await visitAsync_(i, node.items[i], visitor, path2);
1176
1176
  if (typeof ci === "number")
1177
1177
  i = ci - 1;
1178
1178
  else if (ci === BREAK)
@@ -1183,13 +1183,13 @@ var require_visit = __commonJS((exports) => {
1183
1183
  }
1184
1184
  }
1185
1185
  } else if (identity.isPair(node)) {
1186
- path = Object.freeze(path.concat(node));
1187
- const ck = await visitAsync_("key", node.key, visitor, path);
1186
+ path2 = Object.freeze(path2.concat(node));
1187
+ const ck = await visitAsync_("key", node.key, visitor, path2);
1188
1188
  if (ck === BREAK)
1189
1189
  return BREAK;
1190
1190
  else if (ck === REMOVE)
1191
1191
  node.key = null;
1192
- const cv = await visitAsync_("value", node.value, visitor, path);
1192
+ const cv = await visitAsync_("value", node.value, visitor, path2);
1193
1193
  if (cv === BREAK)
1194
1194
  return BREAK;
1195
1195
  else if (cv === REMOVE)
@@ -1216,23 +1216,23 @@ var require_visit = __commonJS((exports) => {
1216
1216
  }
1217
1217
  return visitor;
1218
1218
  }
1219
- function callVisitor(key, node, visitor, path) {
1219
+ function callVisitor(key, node, visitor, path2) {
1220
1220
  if (typeof visitor === "function")
1221
- return visitor(key, node, path);
1221
+ return visitor(key, node, path2);
1222
1222
  if (identity.isMap(node))
1223
- return visitor.Map?.(key, node, path);
1223
+ return visitor.Map?.(key, node, path2);
1224
1224
  if (identity.isSeq(node))
1225
- return visitor.Seq?.(key, node, path);
1225
+ return visitor.Seq?.(key, node, path2);
1226
1226
  if (identity.isPair(node))
1227
- return visitor.Pair?.(key, node, path);
1227
+ return visitor.Pair?.(key, node, path2);
1228
1228
  if (identity.isScalar(node))
1229
- return visitor.Scalar?.(key, node, path);
1229
+ return visitor.Scalar?.(key, node, path2);
1230
1230
  if (identity.isAlias(node))
1231
- return visitor.Alias?.(key, node, path);
1231
+ return visitor.Alias?.(key, node, path2);
1232
1232
  return;
1233
1233
  }
1234
- function replaceNode(key, path, node) {
1235
- const parent = path[path.length - 1];
1234
+ function replaceNode(key, path2, node) {
1235
+ const parent = path2[path2.length - 1];
1236
1236
  if (identity.isCollection(parent)) {
1237
1237
  parent.items[key] = node;
1238
1238
  } else if (identity.isPair(parent)) {
@@ -1789,10 +1789,10 @@ var require_Collection = __commonJS((exports) => {
1789
1789
  var createNode = require_createNode();
1790
1790
  var identity = require_identity();
1791
1791
  var Node = require_Node();
1792
- function collectionFromPath(schema, path, value) {
1792
+ function collectionFromPath(schema, path2, value) {
1793
1793
  let v = value;
1794
- for (let i = path.length - 1;i >= 0; --i) {
1795
- const k = path[i];
1794
+ for (let i = path2.length - 1;i >= 0; --i) {
1795
+ const k = path2[i];
1796
1796
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
1797
1797
  const a = [];
1798
1798
  a[k] = v;
@@ -1811,7 +1811,7 @@ var require_Collection = __commonJS((exports) => {
1811
1811
  sourceObjects: new Map
1812
1812
  });
1813
1813
  }
1814
- var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
1814
+ var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
1815
1815
 
1816
1816
  class Collection extends Node.NodeBase {
1817
1817
  constructor(type, schema) {
@@ -1832,11 +1832,11 @@ var require_Collection = __commonJS((exports) => {
1832
1832
  copy.range = this.range.slice();
1833
1833
  return copy;
1834
1834
  }
1835
- addIn(path, value) {
1836
- if (isEmptyPath(path))
1835
+ addIn(path2, value) {
1836
+ if (isEmptyPath(path2))
1837
1837
  this.add(value);
1838
1838
  else {
1839
- const [key, ...rest] = path;
1839
+ const [key, ...rest] = path2;
1840
1840
  const node = this.get(key, true);
1841
1841
  if (identity.isCollection(node))
1842
1842
  node.addIn(rest, value);
@@ -1846,8 +1846,8 @@ var require_Collection = __commonJS((exports) => {
1846
1846
  throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
1847
1847
  }
1848
1848
  }
1849
- deleteIn(path) {
1850
- const [key, ...rest] = path;
1849
+ deleteIn(path2) {
1850
+ const [key, ...rest] = path2;
1851
1851
  if (rest.length === 0)
1852
1852
  return this.delete(key);
1853
1853
  const node = this.get(key, true);
@@ -1856,8 +1856,8 @@ var require_Collection = __commonJS((exports) => {
1856
1856
  else
1857
1857
  throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`);
1858
1858
  }
1859
- getIn(path, keepScalar) {
1860
- const [key, ...rest] = path;
1859
+ getIn(path2, keepScalar) {
1860
+ const [key, ...rest] = path2;
1861
1861
  const node = this.get(key, true);
1862
1862
  if (rest.length === 0)
1863
1863
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -1872,15 +1872,15 @@ var require_Collection = __commonJS((exports) => {
1872
1872
  return n == null || allowScalar && identity.isScalar(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
1873
1873
  });
1874
1874
  }
1875
- hasIn(path) {
1876
- const [key, ...rest] = path;
1875
+ hasIn(path2) {
1876
+ const [key, ...rest] = path2;
1877
1877
  if (rest.length === 0)
1878
1878
  return this.has(key);
1879
1879
  const node = this.get(key, true);
1880
1880
  return identity.isCollection(node) ? node.hasIn(rest) : false;
1881
1881
  }
1882
- setIn(path, value) {
1883
- const [key, ...rest] = path;
1882
+ setIn(path2, value) {
1883
+ const [key, ...rest] = path2;
1884
1884
  if (rest.length === 0) {
1885
1885
  this.set(key, value);
1886
1886
  } else {
@@ -4262,9 +4262,9 @@ var require_Document = __commonJS((exports) => {
4262
4262
  if (assertCollection(this.contents))
4263
4263
  this.contents.add(value);
4264
4264
  }
4265
- addIn(path, value) {
4265
+ addIn(path2, value) {
4266
4266
  if (assertCollection(this.contents))
4267
- this.contents.addIn(path, value);
4267
+ this.contents.addIn(path2, value);
4268
4268
  }
4269
4269
  createAlias(node, name) {
4270
4270
  if (!node.anchor) {
@@ -4313,30 +4313,30 @@ var require_Document = __commonJS((exports) => {
4313
4313
  delete(key) {
4314
4314
  return assertCollection(this.contents) ? this.contents.delete(key) : false;
4315
4315
  }
4316
- deleteIn(path) {
4317
- if (Collection.isEmptyPath(path)) {
4316
+ deleteIn(path2) {
4317
+ if (Collection.isEmptyPath(path2)) {
4318
4318
  if (this.contents == null)
4319
4319
  return false;
4320
4320
  this.contents = null;
4321
4321
  return true;
4322
4322
  }
4323
- return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
4323
+ return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
4324
4324
  }
4325
4325
  get(key, keepScalar) {
4326
4326
  return identity.isCollection(this.contents) ? this.contents.get(key, keepScalar) : undefined;
4327
4327
  }
4328
- getIn(path, keepScalar) {
4329
- if (Collection.isEmptyPath(path))
4328
+ getIn(path2, keepScalar) {
4329
+ if (Collection.isEmptyPath(path2))
4330
4330
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
4331
- return identity.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : undefined;
4331
+ return identity.isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : undefined;
4332
4332
  }
4333
4333
  has(key) {
4334
4334
  return identity.isCollection(this.contents) ? this.contents.has(key) : false;
4335
4335
  }
4336
- hasIn(path) {
4337
- if (Collection.isEmptyPath(path))
4336
+ hasIn(path2) {
4337
+ if (Collection.isEmptyPath(path2))
4338
4338
  return this.contents !== undefined;
4339
- return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
4339
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path2) : false;
4340
4340
  }
4341
4341
  set(key, value) {
4342
4342
  if (this.contents == null) {
@@ -4345,13 +4345,13 @@ var require_Document = __commonJS((exports) => {
4345
4345
  this.contents.set(key, value);
4346
4346
  }
4347
4347
  }
4348
- setIn(path, value) {
4349
- if (Collection.isEmptyPath(path)) {
4348
+ setIn(path2, value) {
4349
+ if (Collection.isEmptyPath(path2)) {
4350
4350
  this.contents = value;
4351
4351
  } else if (this.contents == null) {
4352
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
4352
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path2), value);
4353
4353
  } else if (assertCollection(this.contents)) {
4354
- this.contents.setIn(path, value);
4354
+ this.contents.setIn(path2, value);
4355
4355
  }
4356
4356
  }
4357
4357
  setSchema(version, options = {}) {
@@ -6240,9 +6240,9 @@ var require_cst_visit = __commonJS((exports) => {
6240
6240
  visit.BREAK = BREAK;
6241
6241
  visit.SKIP = SKIP;
6242
6242
  visit.REMOVE = REMOVE;
6243
- visit.itemAtPath = (cst, path) => {
6243
+ visit.itemAtPath = (cst, path2) => {
6244
6244
  let item = cst;
6245
- for (const [field, index] of path) {
6245
+ for (const [field, index] of path2) {
6246
6246
  const tok = item?.[field];
6247
6247
  if (tok && "items" in tok) {
6248
6248
  item = tok.items[index];
@@ -6251,23 +6251,23 @@ var require_cst_visit = __commonJS((exports) => {
6251
6251
  }
6252
6252
  return item;
6253
6253
  };
6254
- visit.parentCollection = (cst, path) => {
6255
- const parent = visit.itemAtPath(cst, path.slice(0, -1));
6256
- const field = path[path.length - 1][0];
6254
+ visit.parentCollection = (cst, path2) => {
6255
+ const parent = visit.itemAtPath(cst, path2.slice(0, -1));
6256
+ const field = path2[path2.length - 1][0];
6257
6257
  const coll = parent?.[field];
6258
6258
  if (coll && "items" in coll)
6259
6259
  return coll;
6260
6260
  throw new Error("Parent collection not found");
6261
6261
  };
6262
- function _visit(path, item, visitor) {
6263
- let ctrl = visitor(item, path);
6262
+ function _visit(path2, item, visitor) {
6263
+ let ctrl = visitor(item, path2);
6264
6264
  if (typeof ctrl === "symbol")
6265
6265
  return ctrl;
6266
6266
  for (const field of ["key", "value"]) {
6267
6267
  const token = item[field];
6268
6268
  if (token && "items" in token) {
6269
6269
  for (let i = 0;i < token.items.length; ++i) {
6270
- const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
6270
+ const ci = _visit(Object.freeze(path2.concat([[field, i]])), token.items[i], visitor);
6271
6271
  if (typeof ci === "number")
6272
6272
  i = ci - 1;
6273
6273
  else if (ci === BREAK)
@@ -6278,10 +6278,10 @@ var require_cst_visit = __commonJS((exports) => {
6278
6278
  }
6279
6279
  }
6280
6280
  if (typeof ctrl === "function" && field === "key")
6281
- ctrl = ctrl(item, path);
6281
+ ctrl = ctrl(item, path2);
6282
6282
  }
6283
6283
  }
6284
- return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
6284
+ return typeof ctrl === "function" ? ctrl(item, path2) : ctrl;
6285
6285
  }
6286
6286
  exports.visit = visit;
6287
6287
  });
@@ -8041,15 +8041,6 @@ var isOptionSymbol = Symbol(`clipanion/isOption`);
8041
8041
  function makeCommandOption(spec) {
8042
8042
  return { ...spec, [isOptionSymbol]: true };
8043
8043
  }
8044
- function rerouteArguments(a, b) {
8045
- if (typeof a === `undefined`)
8046
- return [a, b];
8047
- if (typeof a === `object` && a !== null && !Array.isArray(a)) {
8048
- return [undefined, a];
8049
- } else {
8050
- return [a, b];
8051
- }
8052
- }
8053
8044
  function cleanValidationError(message, { mergeName = false } = {}) {
8054
8045
  const match = message.match(/^([^:]+): (.*)$/m);
8055
8046
  if (!match)
@@ -8069,23 +8060,6 @@ ${errors.map((error) => `
8069
8060
  - ${cleanValidationError(error)}`).join(``)}`);
8070
8061
  }
8071
8062
  }
8072
- function applyValidator(name, value, validator) {
8073
- if (typeof validator === `undefined`)
8074
- return value;
8075
- const errors = [];
8076
- const coercions = [];
8077
- const coercion = (v) => {
8078
- const orig = value;
8079
- value = v;
8080
- return coercion.bind(null, orig);
8081
- };
8082
- const check = validator(value, { errors, coercions, coercion });
8083
- if (!check)
8084
- throw formatError(`Invalid value for ${name}`, errors);
8085
- for (const [, op] of coercions)
8086
- op();
8087
- return value;
8088
- }
8089
8063
 
8090
8064
  // node_modules/clipanion/lib/advanced/Command.mjs
8091
8065
  class Command {
@@ -9414,208 +9388,19 @@ VersionCommand.paths = [[`-v`], [`--version`]];
9414
9388
  var exports_options = {};
9415
9389
  __export(exports_options, {
9416
9390
  rerouteArguments: () => rerouteArguments,
9417
- makeCommandOption: () => makeCommandOption,
9418
- isOptionSymbol: () => isOptionSymbol,
9419
- formatError: () => formatError,
9420
- cleanValidationError: () => cleanValidationError,
9391
+ makeCommandOption: () => makeCommandOption2,
9392
+ isOptionSymbol: () => isOptionSymbol2,
9393
+ formatError: () => formatError2,
9394
+ cleanValidationError: () => cleanValidationError2,
9421
9395
  applyValidator: () => applyValidator,
9422
9396
  String: () => String2,
9423
9397
  Rest: () => Rest,
9424
- Proxy: () => Proxy,
9398
+ Proxy: () => Proxy2,
9425
9399
  Counter: () => Counter,
9426
9400
  Boolean: () => Boolean2,
9427
9401
  Array: () => Array2
9428
9402
  });
9429
9403
 
9430
- // node_modules/clipanion/lib/advanced/options/Array.mjs
9431
- function Array2(descriptor, initialValueBase, optsBase) {
9432
- const [initialValue, opts] = rerouteArguments(initialValueBase, optsBase !== null && optsBase !== undefined ? optsBase : {});
9433
- const { arity = 1 } = opts;
9434
- const optNames = descriptor.split(`,`);
9435
- const nameSet = new Set(optNames);
9436
- return makeCommandOption({
9437
- definition(builder) {
9438
- builder.addOption({
9439
- names: optNames,
9440
- arity,
9441
- hidden: opts === null || opts === undefined ? undefined : opts.hidden,
9442
- description: opts === null || opts === undefined ? undefined : opts.description,
9443
- required: opts.required
9444
- });
9445
- },
9446
- transformer(builder, key, state) {
9447
- let usedName;
9448
- let currentValue = typeof initialValue !== `undefined` ? [...initialValue] : undefined;
9449
- for (const { name, value } of state.options) {
9450
- if (!nameSet.has(name))
9451
- continue;
9452
- usedName = name;
9453
- currentValue = currentValue !== null && currentValue !== undefined ? currentValue : [];
9454
- currentValue.push(value);
9455
- }
9456
- if (typeof currentValue !== `undefined`) {
9457
- return applyValidator(usedName !== null && usedName !== undefined ? usedName : key, currentValue, opts.validator);
9458
- } else {
9459
- return currentValue;
9460
- }
9461
- }
9462
- });
9463
- }
9464
- // node_modules/clipanion/lib/advanced/options/Boolean.mjs
9465
- function Boolean2(descriptor, initialValueBase, optsBase) {
9466
- const [initialValue, opts] = rerouteArguments(initialValueBase, optsBase !== null && optsBase !== undefined ? optsBase : {});
9467
- const optNames = descriptor.split(`,`);
9468
- const nameSet = new Set(optNames);
9469
- return makeCommandOption({
9470
- definition(builder) {
9471
- builder.addOption({
9472
- names: optNames,
9473
- allowBinding: false,
9474
- arity: 0,
9475
- hidden: opts.hidden,
9476
- description: opts.description,
9477
- required: opts.required
9478
- });
9479
- },
9480
- transformer(builer, key, state) {
9481
- let currentValue = initialValue;
9482
- for (const { name, value } of state.options) {
9483
- if (!nameSet.has(name))
9484
- continue;
9485
- currentValue = value;
9486
- }
9487
- return currentValue;
9488
- }
9489
- });
9490
- }
9491
- // node_modules/clipanion/lib/advanced/options/Counter.mjs
9492
- function Counter(descriptor, initialValueBase, optsBase) {
9493
- const [initialValue, opts] = rerouteArguments(initialValueBase, optsBase !== null && optsBase !== undefined ? optsBase : {});
9494
- const optNames = descriptor.split(`,`);
9495
- const nameSet = new Set(optNames);
9496
- return makeCommandOption({
9497
- definition(builder) {
9498
- builder.addOption({
9499
- names: optNames,
9500
- allowBinding: false,
9501
- arity: 0,
9502
- hidden: opts.hidden,
9503
- description: opts.description,
9504
- required: opts.required
9505
- });
9506
- },
9507
- transformer(builder, key, state) {
9508
- let currentValue = initialValue;
9509
- for (const { name, value } of state.options) {
9510
- if (!nameSet.has(name))
9511
- continue;
9512
- currentValue !== null && currentValue !== undefined || (currentValue = 0);
9513
- if (!value) {
9514
- currentValue = 0;
9515
- } else {
9516
- currentValue += 1;
9517
- }
9518
- }
9519
- return currentValue;
9520
- }
9521
- });
9522
- }
9523
- // node_modules/clipanion/lib/advanced/options/Rest.mjs
9524
- function Rest(opts = {}) {
9525
- return makeCommandOption({
9526
- definition(builder, key) {
9527
- var _a;
9528
- builder.addRest({
9529
- name: (_a = opts.name) !== null && _a !== undefined ? _a : key,
9530
- required: opts.required
9531
- });
9532
- },
9533
- transformer(builder, key, state) {
9534
- const isRestPositional = (index) => {
9535
- const positional = state.positionals[index];
9536
- if (positional.extra === NoLimits)
9537
- return true;
9538
- if (positional.extra === false && index < builder.arity.leading.length)
9539
- return true;
9540
- return false;
9541
- };
9542
- let count = 0;
9543
- while (count < state.positionals.length && isRestPositional(count))
9544
- count += 1;
9545
- return state.positionals.splice(0, count).map(({ value }) => value);
9546
- }
9547
- });
9548
- }
9549
- // node_modules/clipanion/lib/advanced/options/String.mjs
9550
- function StringOption(descriptor, initialValueBase, optsBase) {
9551
- const [initialValue, opts] = rerouteArguments(initialValueBase, optsBase !== null && optsBase !== undefined ? optsBase : {});
9552
- const { arity = 1 } = opts;
9553
- const optNames = descriptor.split(`,`);
9554
- const nameSet = new Set(optNames);
9555
- return makeCommandOption({
9556
- definition(builder) {
9557
- builder.addOption({
9558
- names: optNames,
9559
- arity: opts.tolerateBoolean ? 0 : arity,
9560
- hidden: opts.hidden,
9561
- description: opts.description,
9562
- required: opts.required
9563
- });
9564
- },
9565
- transformer(builder, key, state, context) {
9566
- let usedName;
9567
- let currentValue = initialValue;
9568
- if (typeof opts.env !== `undefined` && context.env[opts.env]) {
9569
- usedName = opts.env;
9570
- currentValue = context.env[opts.env];
9571
- }
9572
- for (const { name, value } of state.options) {
9573
- if (!nameSet.has(name))
9574
- continue;
9575
- usedName = name;
9576
- currentValue = value;
9577
- }
9578
- if (typeof currentValue === `string`) {
9579
- return applyValidator(usedName !== null && usedName !== undefined ? usedName : key, currentValue, opts.validator);
9580
- } else {
9581
- return currentValue;
9582
- }
9583
- }
9584
- });
9585
- }
9586
- function StringPositional(opts = {}) {
9587
- const { required = true } = opts;
9588
- return makeCommandOption({
9589
- definition(builder, key) {
9590
- var _a;
9591
- builder.addPositional({
9592
- name: (_a = opts.name) !== null && _a !== undefined ? _a : key,
9593
- required: opts.required
9594
- });
9595
- },
9596
- transformer(builder, key, state) {
9597
- var _a;
9598
- for (let i = 0;i < state.positionals.length; ++i) {
9599
- if (state.positionals[i].extra === NoLimits)
9600
- continue;
9601
- if (required && state.positionals[i].extra === true)
9602
- continue;
9603
- if (!required && state.positionals[i].extra === false)
9604
- continue;
9605
- const [positional] = state.positionals.splice(i, 1);
9606
- return applyValidator((_a = opts.name) !== null && _a !== undefined ? _a : key, positional.value, opts.validator);
9607
- }
9608
- return;
9609
- }
9610
- });
9611
- }
9612
- function String2(descriptor, ...args) {
9613
- if (typeof descriptor === `string`) {
9614
- return StringOption(descriptor, ...args);
9615
- } else {
9616
- return StringPositional(descriptor);
9617
- }
9618
- }
9619
9404
  // src/lib/errors.ts
9620
9405
  class RmrError extends Error {
9621
9406
  code;
@@ -11274,6 +11059,41 @@ function getHarnessAdapter(name) {
11274
11059
 
11275
11060
  // src/lib/process-runner.ts
11276
11061
  import { spawn } from "node:child_process";
11062
+ import path from "node:path";
11063
+ var PATH_PARAMETER_KEYS = new Set(["file_path", "filepath", "path", "notebook_path"]);
11064
+ var PARAMETER_MAX_LENGTH = 60;
11065
+ var RAW_INPUT_MAX_LENGTH = 100;
11066
+ function truncateFromEnd(value, maxLength) {
11067
+ if (value.length <= maxLength) {
11068
+ return value;
11069
+ }
11070
+ return value.slice(0, maxLength - 3) + "...";
11071
+ }
11072
+ function truncateFromBeginning(value, maxLength) {
11073
+ if (value.length <= maxLength) {
11074
+ return value;
11075
+ }
11076
+ return "..." + value.slice(-(maxLength - 3));
11077
+ }
11078
+ function isPathParameterKey(key) {
11079
+ return PATH_PARAMETER_KEYS.has(key.toLowerCase());
11080
+ }
11081
+ function looksLikeFilePath(value) {
11082
+ return path.isAbsolute(value) || value.includes("/") || value.includes("\\") || value.startsWith("./") || value.startsWith("../") || value.startsWith("~/");
11083
+ }
11084
+ function stripWorkspacePrefix(filePath, workspaceRoot) {
11085
+ if (!path.isAbsolute(filePath)) {
11086
+ return filePath;
11087
+ }
11088
+ const relativePath = path.relative(workspaceRoot, filePath);
11089
+ if (relativePath && !relativePath.startsWith("..") && !path.isAbsolute(relativePath)) {
11090
+ return relativePath;
11091
+ }
11092
+ if (relativePath === "") {
11093
+ return ".";
11094
+ }
11095
+ return filePath;
11096
+ }
11277
11097
  function formatToolInput(toolInput) {
11278
11098
  try {
11279
11099
  const parsed = JSON.parse(toolInput);
@@ -11281,14 +11101,17 @@ function formatToolInput(toolInput) {
11281
11101
  if (entries.length === 0) {
11282
11102
  return "";
11283
11103
  }
11104
+ const workspaceRoot = process.cwd();
11284
11105
  const parts = entries.map(([key, value]) => {
11285
11106
  const strValue = typeof value === "string" ? value : JSON.stringify(value);
11286
- const truncated = strValue.length > 60 ? strValue.slice(0, 57) + "..." : strValue;
11107
+ const isPathLike = typeof value === "string" && isPathParameterKey(key) && looksLikeFilePath(value);
11108
+ const formatted = isPathLike ? stripWorkspacePrefix(strValue, workspaceRoot) : strValue;
11109
+ const truncated = isPathLike ? truncateFromBeginning(formatted, PARAMETER_MAX_LENGTH) : truncateFromEnd(formatted, PARAMETER_MAX_LENGTH);
11287
11110
  return `${key}=${truncated}`;
11288
11111
  });
11289
11112
  return parts.join(" ");
11290
11113
  } catch {
11291
- return toolInput.length > 100 ? toolInput.slice(0, 97) + "..." : toolInput;
11114
+ return truncateFromEnd(toolInput, RAW_INPUT_MAX_LENGTH);
11292
11115
  }
11293
11116
  }
11294
11117
  async function runHarnessCommand(command, parseStreamLine) {
@@ -12218,41 +12041,6 @@ class RootCommand extends BaseCommand {
12218
12041
  }
12219
12042
  }
12220
12043
 
12221
- // src/lib/logger.ts
12222
- var colors = {
12223
- reset: "\x1B[0m",
12224
- bold: "\x1B[1m",
12225
- red: "\x1B[31m",
12226
- yellow: "\x1B[33m",
12227
- cyan: "\x1B[36m",
12228
- green: "\x1B[32m"
12229
- };
12230
- function wrap(color, text) {
12231
- return `${color}${text}${colors.reset}`;
12232
- }
12233
- var logger = {
12234
- header(text) {
12235
- process.stdout.write(`${wrap(colors.bold + colors.cyan, text)}
12236
- `);
12237
- },
12238
- info(text) {
12239
- process.stdout.write(`${text}
12240
- `);
12241
- },
12242
- success(text) {
12243
- process.stdout.write(`${wrap(colors.green, text)}
12244
- `);
12245
- },
12246
- warn(text) {
12247
- process.stderr.write(`${wrap(colors.yellow, text)}
12248
- `);
12249
- },
12250
- error(text) {
12251
- process.stderr.write(`${wrap(colors.red, text)}
12252
- `);
12253
- }
12254
- };
12255
-
12256
12044
  // src/commands/run.ts
12257
12045
  import { readFile as readFile4, stat } from "node:fs/promises";
12258
12046
  import { resolve as resolve9 } from "node:path";
@@ -12315,6 +12103,9 @@ async function resolveWorkflowPath(inputPath) {
12315
12103
  throw new UserInputError(`Failed to access workflow path "${absolutePath}": ${getErrorMessage(error)}`);
12316
12104
  }
12317
12105
  }
12106
+ function workflowRequiresTask(workflow) {
12107
+ return workflow.steps.some((step) => step.requires.inputs.includes("task"));
12108
+ }
12318
12109
 
12319
12110
  class RunCommand extends BaseCommand {
12320
12111
  static paths = [["run"]];
@@ -12402,7 +12193,7 @@ class RunCommand extends BaseCommand {
12402
12193
  }
12403
12194
  throw new UserInputError(`Failed to load workflow "${workflowPath}": ${getErrorMessage(error)}`);
12404
12195
  }
12405
- const { task, displayTask } = await this.resolveTask();
12196
+ const { task, displayTask } = workflowRequiresTask(workflow) ? await this.resolveTask() : { task: "", displayTask: "(none)" };
12406
12197
  const runId = generateRunId();
12407
12198
  const runState = createInitialRunState({
12408
12199
  runId,
@@ -12451,13 +12242,13 @@ try {
12451
12242
  process.exitCode = Math.max(process.exitCode ?? 0, exitCode);
12452
12243
  } catch (error) {
12453
12244
  if (error instanceof RmrError) {
12454
- logger.error(`${error.code}: ${error.message}`);
12245
+ ui.error(`${error.code}: ${error.message}`);
12455
12246
  process.exitCode = 1;
12456
12247
  } else if (error instanceof Error) {
12457
- logger.error(error.message);
12248
+ ui.error(error.message);
12458
12249
  process.exitCode = 1;
12459
12250
  } else {
12460
- logger.error("Unknown error");
12251
+ ui.error("Unknown error");
12461
12252
  process.exitCode = 1;
12462
12253
  }
12463
12254
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@klaudworks/rex",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@klaudworks/rex",
9
- "version": "1.0.1",
9
+ "version": "1.1.1",
10
10
  "dependencies": {
11
11
  "clipanion": "^4.0.0-rc.4",
12
12
  "yaml": "^2.8.2"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@klaudworks/rmr",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "description": "Define multi-step coding workflows for AI agents",
5
5
  "license": "MIT",
6
6
  "repository": {