@klaudworks/rmr 1.0.0 → 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;
@@ -10921,23 +10706,31 @@ class CompletionCommand extends BaseCommand {
10921
10706
  }
10922
10707
 
10923
10708
  // src/lib/run-state.ts
10924
- import { readFile, writeFile } from "node:fs/promises";
10709
+ import { appendFile, readFile, writeFile } from "node:fs/promises";
10925
10710
  import { resolve as resolve3 } from "node:path";
10926
10711
  function pad(input) {
10927
10712
  return String(input).padStart(2, "0");
10928
10713
  }
10929
10714
  function generateRunId(now = new Date) {
10930
- const yyyy = now.getUTCFullYear();
10931
- const mm = pad(now.getUTCMonth() + 1);
10932
- const dd = pad(now.getUTCDate());
10933
- const hh = pad(now.getUTCHours());
10934
- const min = pad(now.getUTCMinutes());
10935
- const sec = pad(now.getUTCSeconds());
10936
- return `${yyyy}${mm}${dd}-${hh}${min}${sec}Z`;
10715
+ const yyyy = now.getFullYear();
10716
+ const mm = pad(now.getMonth() + 1);
10717
+ const dd = pad(now.getDate());
10718
+ const hh = pad(now.getHours());
10719
+ const min = pad(now.getMinutes());
10720
+ const sec = pad(now.getSeconds());
10721
+ return `${yyyy}${mm}${dd}-${hh}${min}${sec}`;
10937
10722
  }
10938
10723
  function runFilePath(config, runId) {
10939
10724
  return resolve3(config.runsDir, `${runId}.json`);
10940
10725
  }
10726
+ function runLogPath(config, runId) {
10727
+ return resolve3(config.runsDir, `${runId}.log`);
10728
+ }
10729
+ async function appendToRunLog(config, runId, content) {
10730
+ const path = runLogPath(config, runId);
10731
+ await appendFile(path, content, "utf8");
10732
+ return path;
10733
+ }
10941
10734
  function createInitialRunState(options) {
10942
10735
  const firstStep = options.workflow.steps[0];
10943
10736
  if (!firstStep) {
@@ -11219,7 +11012,7 @@ var adapters = {
11219
11012
  },
11220
11013
  createStreamParser: createOpenCodeStreamParser,
11221
11014
  resumeTemplate(sessionId) {
11222
- return `opencode run --session ${sessionId}`;
11015
+ return `opencode --session ${sessionId}`;
11223
11016
  }
11224
11017
  },
11225
11018
  codex: {
@@ -11236,7 +11029,7 @@ var adapters = {
11236
11029
  },
11237
11030
  createStreamParser: createCodexStreamParser,
11238
11031
  resumeTemplate(sessionId) {
11239
- return `codex exec resume ${sessionId} "<prompt>"`;
11032
+ return `codex resume ${sessionId}`;
11240
11033
  }
11241
11034
  },
11242
11035
  copilot: {
@@ -11266,6 +11059,41 @@ function getHarnessAdapter(name) {
11266
11059
 
11267
11060
  // src/lib/process-runner.ts
11268
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
+ }
11269
11097
  function formatToolInput(toolInput) {
11270
11098
  try {
11271
11099
  const parsed = JSON.parse(toolInput);
@@ -11273,14 +11101,17 @@ function formatToolInput(toolInput) {
11273
11101
  if (entries.length === 0) {
11274
11102
  return "";
11275
11103
  }
11104
+ const workspaceRoot = process.cwd();
11276
11105
  const parts = entries.map(([key, value]) => {
11277
11106
  const strValue = typeof value === "string" ? value : JSON.stringify(value);
11278
- 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);
11279
11110
  return `${key}=${truncated}`;
11280
11111
  });
11281
11112
  return parts.join(" ");
11282
11113
  } catch {
11283
- return toolInput.length > 100 ? toolInput.slice(0, 97) + "..." : toolInput;
11114
+ return truncateFromEnd(toolInput, RAW_INPUT_MAX_LENGTH);
11284
11115
  }
11285
11116
  }
11286
11117
  async function runHarnessCommand(command, parseStreamLine) {
@@ -11472,6 +11303,19 @@ function applyOutputToContext(context, stepId, values) {
11472
11303
  context[`${stepId}.${key}`] = value;
11473
11304
  }
11474
11305
  }
11306
+ function formatStepLogEntry(params) {
11307
+ const separator = `${"=".repeat(80)}
11308
+ `;
11309
+ const output = params.combinedOutput.length > 0 ? params.combinedOutput.endsWith(`
11310
+ `) ? params.combinedOutput : `${params.combinedOutput}
11311
+ ` : `
11312
+ `;
11313
+ return `${separator}STEP: ${params.stepId} (step ${params.stepNumber}) | Started: ${params.startedAt}
11314
+ ` + `${separator}` + `${output}
11315
+ ` + `${separator}STEP: ${params.stepId} (step ${params.stepNumber}) | Completed: ${params.completedAt} | Status: ${params.status}
11316
+ ` + `${separator}
11317
+ `;
11318
+ }
11475
11319
  async function runWorkflow(config, workflow, runState, options) {
11476
11320
  if (options.overrides?.stepId) {
11477
11321
  runState.current_step = options.overrides.stepId;
@@ -11516,6 +11360,15 @@ Note: ${injectedHint}` : resolvedPrompt;
11516
11360
  runState.last_harness.session_id = result.sessionId;
11517
11361
  }
11518
11362
  if (result.exitCode !== 0) {
11363
+ const completedAt = new Date().toISOString();
11364
+ await appendToRunLog(config, runState.run_id, formatStepLogEntry({
11365
+ stepId: step.id,
11366
+ stepNumber,
11367
+ startedAt: stepStartedAt,
11368
+ completedAt,
11369
+ status: "paused",
11370
+ combinedOutput: result.combinedOutput
11371
+ }));
11519
11372
  await pauseRun(config, runState, harnessExitReason({
11520
11373
  stepId: step.id,
11521
11374
  harness,
@@ -11527,6 +11380,15 @@ Note: ${injectedHint}` : resolvedPrompt;
11527
11380
  return runState;
11528
11381
  }
11529
11382
  if (result.combinedOutput.includes(HUMAN_SENTINEL)) {
11383
+ const completedAt = new Date().toISOString();
11384
+ await appendToRunLog(config, runState.run_id, formatStepLogEntry({
11385
+ stepId: step.id,
11386
+ stepNumber,
11387
+ startedAt: stepStartedAt,
11388
+ completedAt,
11389
+ status: "paused",
11390
+ combinedOutput: result.combinedOutput
11391
+ }));
11530
11392
  await pauseRun(config, runState, `HUMAN_INTERVENTION_REQUIRED at step "${step.id}".`, harness, runState.last_harness.session_id);
11531
11393
  return runState;
11532
11394
  }
@@ -11536,6 +11398,15 @@ Note: ${injectedHint}` : resolvedPrompt;
11536
11398
  validateRequiredOutputKeys(stepOutput, step.requires.outputs);
11537
11399
  } catch (error) {
11538
11400
  const message = error instanceof Error ? error.message : "Failed to parse step output.";
11401
+ const completedAt = new Date().toISOString();
11402
+ await appendToRunLog(config, runState.run_id, formatStepLogEntry({
11403
+ stepId: step.id,
11404
+ stepNumber,
11405
+ startedAt: stepStartedAt,
11406
+ completedAt,
11407
+ status: "paused",
11408
+ combinedOutput: result.combinedOutput
11409
+ }));
11539
11410
  await pauseRun(config, runState, message, harness, runState.last_harness.session_id);
11540
11411
  return runState;
11541
11412
  }
@@ -11543,19 +11414,46 @@ Note: ${injectedHint}` : resolvedPrompt;
11543
11414
  applyOutputToContext(runState.context, step.id, stepOutput.values);
11544
11415
  const nextState = stepOutput.next_state ?? step.next_step;
11545
11416
  if (!isValidTarget(workflow, nextState)) {
11417
+ const completedAt = new Date().toISOString();
11418
+ await appendToRunLog(config, runState.run_id, formatStepLogEntry({
11419
+ stepId: step.id,
11420
+ stepNumber,
11421
+ startedAt: stepStartedAt,
11422
+ completedAt,
11423
+ status: "paused",
11424
+ combinedOutput: result.combinedOutput
11425
+ }));
11546
11426
  await pauseRun(config, runState, `Invalid next_state "${nextState}" at step "${step.id}".`, harness, runState.last_harness.session_id);
11547
11427
  return runState;
11548
11428
  }
11549
11429
  if (nextState === "human_intervention") {
11430
+ const completedAt = new Date().toISOString();
11431
+ await appendToRunLog(config, runState.run_id, formatStepLogEntry({
11432
+ stepId: step.id,
11433
+ stepNumber,
11434
+ startedAt: stepStartedAt,
11435
+ completedAt,
11436
+ status: "paused",
11437
+ combinedOutput: result.combinedOutput
11438
+ }));
11550
11439
  await pauseRun(config, runState, `Step "${step.id}" requested human intervention.`, harness, runState.last_harness.session_id);
11551
11440
  return runState;
11552
11441
  }
11442
+ const stepCompletedAt = new Date().toISOString();
11443
+ await appendToRunLog(config, runState.run_id, formatStepLogEntry({
11444
+ stepId: step.id,
11445
+ stepNumber,
11446
+ startedAt: stepStartedAt,
11447
+ completedAt: stepCompletedAt,
11448
+ status: "success",
11449
+ combinedOutput: result.combinedOutput
11450
+ }));
11553
11451
  const stepExecution = {
11554
11452
  step_number: stepNumber,
11555
11453
  step_id: step.id,
11556
11454
  session_id: runState.last_harness?.session_id ?? null,
11557
11455
  started_at: stepStartedAt,
11558
- completed_at: new Date().toISOString()
11456
+ completed_at: stepCompletedAt
11559
11457
  };
11560
11458
  runState.step_history.push(stepExecution);
11561
11459
  stepNumber++;
@@ -11839,15 +11737,15 @@ class ContinueCommand extends BaseCommand {
11839
11737
  description: "Resume a previously created run by run id.",
11840
11738
  details: "Loads `.rmr/runs/<run-id>.json` and continues orchestration from the stored step unless overridden. If a harness session id exists (or is provided), rmr attempts harness resume first.",
11841
11739
  examples: [
11842
- ["Resume a paused run", "$0 continue 20260316-153210Z"],
11843
- ["Resume from a specific step", "$0 continue 20260316-153210Z --step verify"],
11740
+ ["Resume a paused run", "$0 continue 20260316-153210"],
11741
+ ["Resume from a specific step", "$0 continue 20260316-153210 --step verify"],
11844
11742
  [
11845
11743
  "Resume with a hint",
11846
- '$0 continue 20260316-153210Z --hint "Plan mode only: read and propose changes, do not edit files."'
11744
+ '$0 continue 20260316-153210 --hint "Plan mode only: read and propose changes, do not edit files."'
11847
11745
  ],
11848
11746
  [
11849
11747
  "Force session override",
11850
- "$0 continue 20260316-153210Z --session-id abc123"
11748
+ "$0 continue 20260316-153210 --session-id abc123"
11851
11749
  ]
11852
11750
  ]
11853
11751
  });
@@ -12143,41 +12041,6 @@ class RootCommand extends BaseCommand {
12143
12041
  }
12144
12042
  }
12145
12043
 
12146
- // src/lib/logger.ts
12147
- var colors = {
12148
- reset: "\x1B[0m",
12149
- bold: "\x1B[1m",
12150
- red: "\x1B[31m",
12151
- yellow: "\x1B[33m",
12152
- cyan: "\x1B[36m",
12153
- green: "\x1B[32m"
12154
- };
12155
- function wrap(color, text) {
12156
- return `${color}${text}${colors.reset}`;
12157
- }
12158
- var logger = {
12159
- header(text) {
12160
- process.stdout.write(`${wrap(colors.bold + colors.cyan, text)}
12161
- `);
12162
- },
12163
- info(text) {
12164
- process.stdout.write(`${text}
12165
- `);
12166
- },
12167
- success(text) {
12168
- process.stdout.write(`${wrap(colors.green, text)}
12169
- `);
12170
- },
12171
- warn(text) {
12172
- process.stderr.write(`${wrap(colors.yellow, text)}
12173
- `);
12174
- },
12175
- error(text) {
12176
- process.stderr.write(`${wrap(colors.red, text)}
12177
- `);
12178
- }
12179
- };
12180
-
12181
12044
  // src/commands/run.ts
12182
12045
  import { readFile as readFile4, stat } from "node:fs/promises";
12183
12046
  import { resolve as resolve9 } from "node:path";
@@ -12240,6 +12103,9 @@ async function resolveWorkflowPath(inputPath) {
12240
12103
  throw new UserInputError(`Failed to access workflow path "${absolutePath}": ${getErrorMessage(error)}`);
12241
12104
  }
12242
12105
  }
12106
+ function workflowRequiresTask(workflow) {
12107
+ return workflow.steps.some((step) => step.requires.inputs.includes("task"));
12108
+ }
12243
12109
 
12244
12110
  class RunCommand extends BaseCommand {
12245
12111
  static paths = [["run"]];
@@ -12327,7 +12193,7 @@ class RunCommand extends BaseCommand {
12327
12193
  }
12328
12194
  throw new UserInputError(`Failed to load workflow "${workflowPath}": ${getErrorMessage(error)}`);
12329
12195
  }
12330
- const { task, displayTask } = await this.resolveTask();
12196
+ const { task, displayTask } = workflowRequiresTask(workflow) ? await this.resolveTask() : { task: "", displayTask: "(none)" };
12331
12197
  const runId = generateRunId();
12332
12198
  const runState = createInitialRunState({
12333
12199
  runId,
@@ -12376,13 +12242,13 @@ try {
12376
12242
  process.exitCode = Math.max(process.exitCode ?? 0, exitCode);
12377
12243
  } catch (error) {
12378
12244
  if (error instanceof RmrError) {
12379
- logger.error(`${error.code}: ${error.message}`);
12245
+ ui.error(`${error.code}: ${error.message}`);
12380
12246
  process.exitCode = 1;
12381
12247
  } else if (error instanceof Error) {
12382
- logger.error(error.message);
12248
+ ui.error(error.message);
12383
12249
  process.exitCode = 1;
12384
12250
  } else {
12385
- logger.error("Unknown error");
12251
+ ui.error("Unknown error");
12386
12252
  process.exitCode = 1;
12387
12253
  }
12388
12254
  }
@@ -1,14 +1,3 @@
1
- # Feature development workflow for rmr.
2
- # Three steps: plan (research + plan), implement, verify (review).
3
- # The verify step can loop back to implement or escalate to human intervention.
4
- #
5
- # Prompt files are co-located with this workflow in the same folder.
6
- # Template variables reference step outputs: {{step_id.key}}
7
- #
8
- # Routing is controlled by <rmr:next_state> in agent output.
9
- # The planner can reject a task by setting next_state=done.
10
- # The reviewer can request changes by setting next_state=implement.
11
-
12
1
  id: feature-dev
13
2
  name: Feature Development
14
3
  harness: claude
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@klaudworks/rex",
3
- "version": "1.0.0",
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.0",
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.0",
3
+ "version": "1.1.1",
4
4
  "description": "Define multi-step coding workflows for AI agents",
5
5
  "license": "MIT",
6
6
  "repository": {