@ordewell/core 0.12.2 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/{ModeResolver-CA2fUU9h.d.mts → ModeResolver-CkZnbIqs.d.mts} +1 -1
  2. package/dist/{ModeResolver-B64aUZXJ.d.ts → ModeResolver-DS-aCVOP.d.ts} +1 -1
  3. package/dist/{Task-CxGgN6I0.d.mts → Task-D3O49EUo.d.mts} +43 -6
  4. package/dist/{Task-CxGgN6I0.d.ts → Task-D3O49EUo.d.ts} +43 -6
  5. package/dist/{chunk-RZ23BMVR.mjs → chunk-3S5IVTZM.mjs} +80 -22
  6. package/dist/chunk-3S5IVTZM.mjs.map +1 -0
  7. package/dist/{chunk-FX33UKAD.mjs → chunk-IOYBL3E5.mjs} +3 -3
  8. package/dist/{chunk-UDUATSCJ.mjs → chunk-MJKCU4U7.mjs} +1 -1
  9. package/dist/{chunk-UDUATSCJ.mjs.map → chunk-MJKCU4U7.mjs.map} +1 -1
  10. package/dist/{chunk-PKJTN2PD.mjs → chunk-POD3KZQW.mjs} +7 -1
  11. package/dist/chunk-POD3KZQW.mjs.map +1 -0
  12. package/dist/{chunk-2IFKPYPO.mjs → chunk-YZDWWXCB.mjs} +58 -17
  13. package/dist/chunk-YZDWWXCB.mjs.map +1 -0
  14. package/dist/{eventStore-CTCSKS9E.d.ts → eventStore-BcoMsZtU.d.mts} +23 -7
  15. package/dist/{eventStore-CcB8yELZ.d.mts → eventStore-CSFKy48Y.d.ts} +23 -7
  16. package/dist/index.d.mts +251 -243
  17. package/dist/index.d.ts +251 -243
  18. package/dist/index.js +3059 -1448
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +2716 -1203
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/parsing.d.mts +2 -2
  23. package/dist/parsing.d.ts +2 -2
  24. package/dist/parsing.js +43 -15
  25. package/dist/parsing.js.map +1 -1
  26. package/dist/parsing.mjs +3 -3
  27. package/dist/plan-utils.d.mts +4 -4
  28. package/dist/plan-utils.d.ts +4 -4
  29. package/dist/plan-utils.js +65 -14
  30. package/dist/plan-utils.js.map +1 -1
  31. package/dist/plan-utils.mjs +15 -3
  32. package/dist/plan-utils.mjs.map +1 -1
  33. package/dist/{runSettingsText-lKLDsyli.d.ts → runSettingsText-BFaZSPRG.d.ts} +686 -26
  34. package/dist/{runSettingsText-DFVpe6aU.d.mts → runSettingsText-DWsmcnBq.d.mts} +686 -26
  35. package/dist/testing.d.mts +46 -3
  36. package/dist/testing.d.ts +46 -3
  37. package/dist/testing.js +66 -4
  38. package/dist/testing.js.map +1 -1
  39. package/dist/testing.mjs +52 -5
  40. package/dist/testing.mjs.map +1 -1
  41. package/docker/task.Dockerfile +7 -4
  42. package/package.json +1 -1
  43. package/dist/chunk-2IFKPYPO.mjs.map +0 -1
  44. package/dist/chunk-PKJTN2PD.mjs.map +0 -1
  45. package/dist/chunk-RZ23BMVR.mjs.map +0 -1
  46. /package/dist/{chunk-FX33UKAD.mjs.map → chunk-IOYBL3E5.mjs.map} +0 -0
@@ -1,5 +1,5 @@
1
- import { b3 as RunnerId, bp as Task } from './Task-CxGgN6I0.mjs';
2
- import { R as RunnerModeInfo } from './ModeResolver-CA2fUU9h.mjs';
1
+ import { b4 as RunnerId, bq as Task } from './Task-D3O49EUo.mjs';
2
+ import { R as RunnerModeInfo } from './ModeResolver-CkZnbIqs.mjs';
3
3
 
4
4
  declare function parsePlanJson(raw: string, runners: RunnerId[], runnerModes?: Record<RunnerId, RunnerModeInfo[]>, autonomousDefault?: boolean): Task[];
5
5
 
package/dist/parsing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { b3 as RunnerId, bp as Task } from './Task-CxGgN6I0.js';
2
- import { R as RunnerModeInfo } from './ModeResolver-B64aUZXJ.js';
1
+ import { b4 as RunnerId, bq as Task } from './Task-D3O49EUo.js';
2
+ import { R as RunnerModeInfo } from './ModeResolver-DS-aCVOP.js';
3
3
 
4
4
  declare function parsePlanJson(raw: string, runners: RunnerId[], runnerModes?: Record<RunnerId, RunnerModeInfo[]>, autonomousDefault?: boolean): Task[];
5
5
 
package/dist/parsing.js CHANGED
@@ -322,11 +322,14 @@ var lesser = (limit) => (parent, request) => {
322
322
  return { value: Math.min(parent[limit], asked ?? parent[limit]) };
323
323
  };
324
324
  function intersectModels(parent, asked = {}) {
325
- const models = { ...asked, ...parent };
326
- for (const runner of Object.keys(parent)) {
327
- if (asked[runner]) models[runner] = parent[runner].filter((model) => asked[runner].includes(model));
325
+ const models = { ...parent };
326
+ for (const [runner, wanted] of Object.entries(asked)) {
327
+ const held = parent[runner] ?? [];
328
+ const kept = held.length > 0 ? held.filter((model) => wanted.includes(model)) : wanted;
329
+ if (kept.length === 0) return { refused: { field: "limits.models", asked: `${runner}: ${wanted.join(", ") || "nothing"}`, there: `${runner}: ${held.join(", ") || "any"}` } };
330
+ models[runner] = kept;
328
331
  }
329
- return models;
332
+ return { value: models };
330
333
  }
331
334
  var LIMIT_RULES = {
332
335
  tokens: ({ tokens }, { tokens: asked }) => {
@@ -346,8 +349,12 @@ var LIMIT_RULES = {
346
349
  },
347
350
  delegatedTasks: lesser("delegatedTasks"),
348
351
  tasksPerPlan: lesser("tasksPerPlan"),
349
- runners: ({ runners }, { runners: asked }) => ({ value: asked ? runners.filter((runner) => asked.includes(runner)) : runners }),
350
- models: ({ models }, { models: asked }) => ({ value: intersectModels(models, asked) })
352
+ runners: ({ runners }, { runners: asked }) => {
353
+ if (!asked) return { value: runners };
354
+ const kept = runners.filter((runner) => asked.includes(runner));
355
+ return kept.length > 0 ? { value: kept } : { refused: { field: "limits.runners", asked: asked.join(", ") || "nothing", there: runners.join(", ") || "nothing" } };
356
+ },
357
+ models: ({ models }, { models: asked }) => intersectModels(models, asked)
351
358
  };
352
359
  var COMMAND_GRANTS = {
353
360
  run_plan: "control",
@@ -476,6 +483,11 @@ function delegationErrors(tasks, rules = {}) {
476
483
  const paths = task.protectedPaths;
477
484
  if (!task.readOnly && (!Array.isArray(paths) || paths.length === 0 || !paths.every((p) => typeof p === "string" && p.trim()))) {
478
485
  fail(task, "protectedPaths", `${where} is a delegated task that lands, with no "protectedPaths": name the paths its child may not change, what its check runs and the configuration that runs it`);
486
+ } else if (!task.readOnly) {
487
+ for (const rule of paths ?? []) {
488
+ const fault = protectedPathFault(rule);
489
+ if (fault) fail(task, "protectedPaths", `${where} protects "${rule}", which ${fault}`);
490
+ }
479
491
  }
480
492
  if (task.scope !== void 0 && !scopeOk(task.scope)) fail(task, "scope", `${where} has a "scope" that is not lists of text: "paths", "provides" and "consumes", at most ${SCOPE_LIMITS.items} items of one line and ${SCOPE_LIMITS.item} characters each`);
481
493
  const unknown = (task.grants ?? []).filter((grant) => !GRANTS.includes(grant));
@@ -513,20 +525,35 @@ function scopeOk(scope) {
513
525
  function judges(task, delegated, runnerModes) {
514
526
  return readsOnly(task, runnerModes) || !delegated.readOnly && task.type === "script" && task.readOnly === true;
515
527
  }
528
+ function pathSteps(path) {
529
+ return path.trim().replace(/\\/g, "/").split("/").filter((step) => step !== "" && step !== ".");
530
+ }
531
+ function foldedPath(path) {
532
+ return pathSteps(path).join("/").normalize("NFC").toUpperCase().toLowerCase();
533
+ }
534
+ function protectedPathFault(rule) {
535
+ const path = rule.trim().replace(/\\/g, "/");
536
+ if (path.startsWith("/") || /^[a-z]:\//i.test(path)) return "is not relative to the repository, and a diff lists nothing else: name it from the repository's root";
537
+ const steps = pathSteps(path);
538
+ if (steps.includes("..")) return "is outside the repository: name a path inside it";
539
+ if (steps.every((step) => /^\*+$/.test(step))) return 'covers the whole repository, so its child could land nothing: name what it may not change, or make the task "readOnly"';
540
+ if (/[?{}]|^!/.test(path) || path.includes("*") && /[[\]]/.test(path)) return "reads as a wildcard, and only `*` is a wildcard here, with `**` for any depth: name each path";
541
+ return null;
542
+ }
516
543
  function underProtectedPath(file, protectedPath) {
517
- const rule = protectedPath.trim().replace(/^\.\//, "").replace(/\\/g, "/");
518
- if (!rule) return false;
519
- if (rule.includes("*")) return globRegExp(rule).test(file);
520
- const bare = rule.replace(/\/+$/, "");
521
- return file === bare || file.startsWith(`${bare}/`);
544
+ if (!protectedPath.trim()) return false;
545
+ const rule = foldedPath(protectedPath).replace(/(?:\/\*\*)+$/, "");
546
+ const path = foldedPath(file);
547
+ if (rule.includes("*")) return globRegExp(rule).test(path);
548
+ return !rule || path === rule || path.startsWith(`${rule}/`);
522
549
  }
523
550
  function fixedStart(rule) {
524
- const bare = rule.trim().replace(/^\.\//, "").replace(/\\/g, "/");
551
+ const bare = foldedPath(rule);
525
552
  const star = bare.indexOf("*");
526
553
  return star === -1 ? bare : bare.slice(0, star);
527
554
  }
528
555
  function pathsMeet(a, b) {
529
- if (underProtectedPath(a.replace(/\/+$/, ""), b) || underProtectedPath(b.replace(/\/+$/, ""), a)) return true;
556
+ if (underProtectedPath(a, b) || underProtectedPath(b, a)) return true;
530
557
  if (!a.includes("*") || !b.includes("*")) return false;
531
558
  const [one, other] = [fixedStart(a), fixedStart(b)];
532
559
  return one.startsWith(other) || other.startsWith(one);
@@ -557,9 +584,10 @@ function scopeOverlaps(tasks) {
557
584
  });
558
585
  return said;
559
586
  }
587
+ var GLOB_STARS = { "*": "[^/]*", "**": ".*", "**/": "(?:.*/)?" };
560
588
  function globRegExp(rule) {
561
- const pattern = rule.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\/?|\*/g, (star) => star === "*" ? "[^/]*" : "(?:.*/)?");
562
- return new RegExp(`^${pattern}(?:/.*)?$`);
589
+ const pattern = rule.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*\/|\*\*|\*/g, (star) => GLOB_STARS[star]);
590
+ return new RegExp(`^${rule.includes("/") ? "" : "(?:.*/)?"}${pattern}(?:/.*)?$`, "s");
563
591
  }
564
592
 
565
593
  // src/services/PlannedTask.ts