@wrenautomation/aerie 0.8.6 → 0.8.7

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.
@@ -20,5 +20,7 @@ export interface Milestone {
20
20
  export declare function readMilestones(root: string): Milestone[];
21
21
  /** Backlog.md's name for a new file; an existing file keeps its name when the title changes. */
22
22
  export declare function fileName(t: Pick<Task, "id" | "title">): string;
23
+ /** `statuses` from the board's config.yml, or null */
24
+ export declare function boardStatuses(root: string): string[] | null;
23
25
  /** `task_prefix` from the board's config.yml, or null. */
24
26
  export declare function taskPrefix(root: string): string | null;
@@ -60,6 +60,14 @@ export function fileName(t) {
60
60
  .replace(/-+/g, "-");
61
61
  return `${t.id.toLowerCase()} - ${slug}.md`;
62
62
  }
63
+ /** `statuses` from the board's config.yml, or null */
64
+ export function boardStatuses(root) {
65
+ const file = join(root, "config.yml");
66
+ if (!existsSync(file))
67
+ return null;
68
+ const v = load(readFileSync(file, "utf8"))?.statuses;
69
+ return Array.isArray(v) && v.length && v.every((x) => typeof x === "string") ? v : null;
70
+ }
63
71
  /** `task_prefix` from the board's config.yml, or null. */
64
72
  export function taskPrefix(root) {
65
73
  const file = join(root, "config.yml");
@@ -1 +1 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/backlog/files.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAUvC,MAAM,KAAK,GAAY,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,gBAAgB,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,GAAc;IACpD,MAAM,IA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vB,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,IAAI,KAAK,CAAC;AAC9C,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,CAAC,GAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAmC,EAAE,QAAQ,CAAC;IACxF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1F,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IACtC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,CAAC,GAAG,iDAAiD,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7F,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACxB,CAAC"}
@@ -1,3 +1,3 @@
1
- export { type BoardFile, fileName, type Milestone, readBoard, readMilestones, taskPrefix, } from "./files.js";
1
+ export { type BoardFile, boardStatuses, fileName, type Milestone, readBoard, readMilestones, taskPrefix, } from "./files.js";
2
2
  export { parseTask, SECTIONS } from "./parse.js";
3
3
  export { renderTask } from "./render.js";
@@ -1,4 +1,4 @@
1
- export { fileName, readBoard, readMilestones, taskPrefix, } from "./files.js";
1
+ export { boardStatuses, fileName, readBoard, readMilestones, taskPrefix, } from "./files.js";
2
2
  export { parseTask, SECTIONS } from "./parse.js";
3
3
  export { renderTask } from "./render.js";
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backlog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAER,SAAS,EACT,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backlog/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,QAAQ,EAER,SAAS,EACT,cAAc,EACd,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
package/dist/bin.js CHANGED
@@ -11,6 +11,11 @@ var __export = (target, all) => {
11
11
  };
12
12
 
13
13
  // src/core/task.ts
14
+ function statusIn(all, s) {
15
+ const hit = all.find((x) => x.toLowerCase() === s.trim().toLowerCase());
16
+ if (!hit) throw new Error(`unknown status "${s}" (one of: ${all.join(", ")})`);
17
+ return hit;
18
+ }
14
19
  function instant(v) {
15
20
  if (v == null || v === "") return void 0;
16
21
  if (v instanceof Date) return v.toISOString().replace(/\.\d{3}Z$/, "Z");
@@ -37,6 +42,7 @@ var init_task = __esm({
37
42
  STATUSES = [
38
43
  "To Do",
39
44
  "In Progress",
45
+ "In Testing",
40
46
  "Needs Human Input",
41
47
  "Backlog",
42
48
  "Parked",
@@ -31184,6 +31190,8 @@ function aerieStore(o) {
31184
31190
  async function create(input2, by, opts = {}) {
31185
31191
  const id = await write3(by, async (tx) => {
31186
31192
  const parent = input2.parentId ? await must(input2.parentId, tx) : null;
31193
+ if (input2.status !== void 0)
31194
+ input2 = { ...input2, status: await statusName(tx, input2.status) };
31187
31195
  if (input2.milestone)
31188
31196
  input2 = { ...input2, milestone: await milestoneOf(tx, input2.milestone) };
31189
31197
  const id2 = await nextId(tx, parent?.id);
@@ -31222,6 +31230,7 @@ function aerieStore(o) {
31222
31230
  if (opts.expect !== void 0 && opts.expect !== row.version)
31223
31231
  throw new AerieError(`stale: ${row.id} is at version ${row.version}`, 409);
31224
31232
  const was = await must(row.id, tx);
31233
+ if (e.status !== void 0) e = { ...e, status: await statusName(tx, e.status) };
31225
31234
  if (e.parentId) e = { ...e, parentId: (await must(e.parentId, tx)).id };
31226
31235
  if (e.milestone) e = { ...e, milestone: await milestoneOf(tx, e.milestone) };
31227
31236
  const t = applyEdit(was, e, now());
@@ -31341,7 +31350,7 @@ function aerieStore(o) {
31341
31350
  if (Object.keys(set3).length) await tx.update(actor).set(set3).where(eq(actor.id, id));
31342
31351
  });
31343
31352
  }
31344
- async function statusOf2(ids) {
31353
+ async function statusOf(ids) {
31345
31354
  if (!ids.length) return /* @__PURE__ */ new Map();
31346
31355
  const rows3 = await db.select({ id: task.id, status: task.status }).from(task).where(inArray(sql`upper(${task.id})`, [...new Set(ids.map((x) => x.toUpperCase()))]));
31347
31356
  return new Map(rows3.map((r) => [r.id.toUpperCase(), r.status]));
@@ -31356,6 +31365,22 @@ function aerieStore(o) {
31356
31365
  dependencies: task.dependencies
31357
31366
  }).from(task);
31358
31367
  }
31368
+ async function statuses(q = db) {
31369
+ const r = await q.select({ v: setting.value }).from(setting).where(eq(setting.key, "statuses"));
31370
+ try {
31371
+ const v = JSON.parse(r[0]?.v ?? "null");
31372
+ if (Array.isArray(v) && v.length && v.every((x) => typeof x === "string")) return v;
31373
+ } catch {
31374
+ }
31375
+ return [...STATUSES];
31376
+ }
31377
+ async function statusName(q, v) {
31378
+ try {
31379
+ return statusIn(await statuses(q), v);
31380
+ } catch (e) {
31381
+ throw new AerieError(e.message);
31382
+ }
31383
+ }
31359
31384
  async function getSetting(key) {
31360
31385
  const r = await db.select({ v: setting.value }).from(setting).where(eq(setting.key, key));
31361
31386
  return r[0]?.v ?? null;
@@ -31513,7 +31538,7 @@ function aerieStore(o) {
31513
31538
  setActor,
31514
31539
  milestones,
31515
31540
  putMilestones,
31516
- statusOf: statusOf2,
31541
+ statusOf,
31517
31542
  dependencyRows,
31518
31543
  mirrorFiles,
31519
31544
  setMirrorFile,
@@ -31526,6 +31551,7 @@ function aerieStore(o) {
31526
31551
  ask,
31527
31552
  decide,
31528
31553
  prefixOf,
31554
+ statuses,
31529
31555
  getSetting,
31530
31556
  setSetting
31531
31557
  };
@@ -33474,7 +33500,8 @@ var init_http = __esm({
33474
33500
  EDIT = {
33475
33501
  title: external_exports.string().trim().min(1).max(500).optional(),
33476
33502
  description: TEXT.optional(),
33477
- status: external_exports.enum(STATUSES).optional(),
33503
+ status: external_exports.string().trim().min(1).max(100).optional(),
33504
+ // the store checks it against the board
33478
33505
  priority: external_exports.enum(["high", "medium", "low"]).nullish(),
33479
33506
  type: external_exports.string().max(100).nullish(),
33480
33507
  milestone: external_exports.string().max(200).nullish(),
@@ -33784,6 +33811,7 @@ var init_remote = __esm({
33784
33811
  ]),
33785
33812
  views: read([BY], 0),
33786
33813
  prefixOf: read(),
33814
+ statuses: read(),
33787
33815
  mirrorAreas: read(),
33788
33816
  getSetting: read([external_exports.string().min(1).max(100)]),
33789
33817
  create: write2(
@@ -40195,6 +40223,12 @@ function fileName(t) {
40195
40223
  const slug = t.title.replace(/[^A-Za-z0-9._\s-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
40196
40224
  return `${t.id.toLowerCase()} - ${slug}.md`;
40197
40225
  }
40226
+ function boardStatuses(root) {
40227
+ const file2 = join(root, "config.yml");
40228
+ if (!existsSync(file2)) return null;
40229
+ const v = load(readFileSync(file2, "utf8"))?.statuses;
40230
+ return Array.isArray(v) && v.length && v.every((x) => typeof x === "string") ? v : null;
40231
+ }
40198
40232
  function taskPrefix(root) {
40199
40233
  const file2 = join(root, "config.yml");
40200
40234
  if (!existsSync(file2)) return null;
@@ -41628,12 +41662,8 @@ async function pickerOf(a) {
41628
41662
  const spec = await a.getSetting("router_model");
41629
41663
  return spec ? modelPicker(spec) : void 0;
41630
41664
  }
41631
- function ruleFilter(o) {
41632
- const status = (o.status ?? []).map((x) => {
41633
- const hit = STATUSES.find((s) => s.toLowerCase() === x.toLowerCase());
41634
- if (!hit) throw new Error(`unknown status "${x}"`);
41635
- return hit;
41636
- });
41665
+ function ruleFilter(o, statuses) {
41666
+ const status = (o.status ?? []).map((x) => statusIn(statuses, x));
41637
41667
  return {
41638
41668
  ...o.area?.length ? { area: o.area } : {},
41639
41669
  ...o.onlyArea ? { subtree: false } : {},
@@ -41684,7 +41714,7 @@ function registerRunCommands(program3, ctx) {
41684
41714
  const o = cmd.optsWithGlobals();
41685
41715
  const r = await a.addRouteRule(
41686
41716
  {
41687
- filter: ruleFilter(o),
41717
+ filter: ruleFilter(o, await a.statuses()),
41688
41718
  runner: runnerOf(o.runner),
41689
41719
  model: o.model ?? null,
41690
41720
  lane: o.lane ?? null,
@@ -41913,6 +41943,14 @@ init_core3();
41913
41943
  init_store();
41914
41944
  var sha = (s) => createHash("sha256").update(s).digest("hex");
41915
41945
  var ALL = ["tasks", "drafts", "archive/tasks", "archive/drafts"];
41946
+ async function syncStatuses(a, root, by) {
41947
+ const list2 = boardStatuses(root);
41948
+ if (!list2) return false;
41949
+ const v = JSON.stringify(list2);
41950
+ if (await a.getSetting("statuses") === v) return false;
41951
+ await a.setSetting("statuses", v, by);
41952
+ return true;
41953
+ }
41916
41954
  async function mirror(a, root, o = {}) {
41917
41955
  const r = {
41918
41956
  wrote: [],
@@ -41923,6 +41961,7 @@ async function mirror(a, root, o = {}) {
41923
41961
  left: [],
41924
41962
  committed: false
41925
41963
  };
41964
+ if (!o.only && !o.dryRun) await syncStatuses(a, root, o.by ?? "@backlog");
41926
41965
  const areas = new Set(await a.mirrorAreas());
41927
41966
  const state = new Map((await a.mirrorFiles(o.only)).map((m) => [m.taskId, m]));
41928
41967
  const disk = /* @__PURE__ */ new Map();
@@ -42485,12 +42524,6 @@ var nums = (v, prev = []) => [
42485
42524
  ];
42486
42525
  var print3 = (x) => void process.stdout.write(typeof x === "string" ? x : `${JSON.stringify(x, null, 2)}
42487
42526
  `);
42488
- function statusOf(s) {
42489
- if (s === void 0) return void 0;
42490
- const hit = STATUSES.find((x) => x.toLowerCase() === s.trim().toLowerCase());
42491
- if (!hit) throw new Error(`unknown status "${s}" (one of: ${STATUSES.join(", ")})`);
42492
- return hit;
42493
- }
42494
42527
  function checksEdit(o, k) {
42495
42528
  const K = k === "ac" ? "Ac" : "Dod";
42496
42529
  const e = {
@@ -42510,7 +42543,7 @@ function editOf(o) {
42510
42543
  };
42511
42544
  put("title", o.title);
42512
42545
  put("description", o.description ?? o.desc);
42513
- put("status", statusOf(o.status));
42546
+ put("status", o.status);
42514
42547
  put("priority", o.priority);
42515
42548
  put("type", o.type);
42516
42549
  put("milestone", o.clearMilestone ? null : o.milestone);
@@ -42561,11 +42594,21 @@ function editFlags(c, create) {
42561
42594
  }
42562
42595
  function registerCommands(program3, ctx) {
42563
42596
  program3.version(ctx.version, "-v, --version");
42597
+ async function statusesOf(a) {
42598
+ return ctx.mirrorDir && boardStatuses(ctx.mirrorDir) || a.statuses();
42599
+ }
42600
+ async function syncBoard(a, o) {
42601
+ if (ctx.mirrorDir && o.status !== void 0) await syncStatuses(a, ctx.mirrorDir, ctx.by);
42602
+ }
42564
42603
  async function show(a, t, o, kind) {
42565
- const [rows3, file2] = await Promise.all([a.dependencyRows(), fileOf(a, t.id)]);
42604
+ const [rows3, file2, statuses] = await Promise.all([
42605
+ a.dependencyRows(),
42606
+ fileOf(a, t.id),
42607
+ statusesOf(a)
42608
+ ]);
42566
42609
  const v = {
42567
42610
  rows: rows3,
42568
- statuses: STATUSES,
42611
+ statuses,
42569
42612
  ...file2 ? { file: file2, path: relative(dirname3(ctx.mirrorDir), file2) } : {},
42570
42613
  ...ctx.exact ? { exact: true } : {}
42571
42614
  };
@@ -42595,6 +42638,7 @@ function registerCommands(program3, ctx) {
42595
42638
  const task2 = program3.command("task").description("tasks, with Backlog.md's flags");
42596
42639
  editFlags(task2.command("create").argument("<title>").description("make a task"), true).action(
42597
42640
  (title, o) => ctx.withStore(async (a) => {
42641
+ await syncBoard(a, o);
42598
42642
  const e = editOf(o);
42599
42643
  if (o.acceptanceCriteria?.length)
42600
42644
  e.ac = { add: [...e.ac?.add ?? [], ...o.acceptanceCriteria] };
@@ -42616,6 +42660,7 @@ ${file2 ? `File: ${file2}
42616
42660
  );
42617
42661
  editFlags(task2.command("edit").argument("<id>").description("change a task"), false).action(
42618
42662
  (id, o) => ctx.withStore(async (a) => {
42663
+ await syncBoard(a, o);
42619
42664
  const e = editOf(o);
42620
42665
  if (o.archive) {
42621
42666
  const cur = await a.get(id);
@@ -42654,8 +42699,9 @@ ${file2 ? `File: ${file2}
42654
42699
  );
42655
42700
  const listCmd = (c) => c.option("-s, --status <status>", "status").option("-a, --assignee <name>", "assignee").option("-l, --label <labels>", "all of these labels", many).option("-p, --parent <id>", "children of").option("-m, --milestone <m>", "milestone id").option("--priority <p>", "priority").option("--type <type>", "type").option("--area <path>", "area and its subtree (repeatable)", each2).option("--only-area", "the area itself, not its subtree").option("--holder <holder>", "held by (peers holder)").option("--open-checks", "some AC or DoD open").option("--all", "drafts and archive too").option("--sort <field[:desc]>", `sort by ${SORT_FIELDS.join(", ")} (repeatable)`, each2).option("--plain", "plain text (default)").option("--json", "JSON");
42656
42701
  async function runList(a, o) {
42702
+ const statuses = await statusesOf(a);
42657
42703
  const f = {
42658
- ...o.status ? { status: [statusOf(o.status)] } : {},
42704
+ ...o.status ? { status: [statusIn(statuses, o.status)] } : {},
42659
42705
  ...o.assignee ? { assignee: o.assignee } : {},
42660
42706
  ...o.label ? { label: o.label } : {},
42661
42707
  ...o.parent ? { parent: (await a.get(o.parent))?.id ?? o.parent } : {},
@@ -42679,9 +42725,9 @@ ${file2 ? `File: ${file2}
42679
42725
  print3({
42680
42726
  schemaVersion: 1,
42681
42727
  kind: "task-list",
42682
- tasks: ts.map((t) => listItem(t, status, STATUSES))
42728
+ tasks: ts.map((t) => listItem(t, status, statuses))
42683
42729
  });
42684
- } else print3(listPlain(ts, STATUSES));
42730
+ } else print3(listPlain(ts, statuses));
42685
42731
  }
42686
42732
  listCmd(task2.command("list").description("list tasks")).action(
42687
42733
  (o) => ctx.withStore((a) => runList(a, o))
@@ -42690,14 +42736,15 @@ ${file2 ? `File: ${file2}
42690
42736
  (query, o) => ctx.withStore(async (a) => {
42691
42737
  if (o.type && o.type !== "task")
42692
42738
  throw new Error(`aerie holds tasks only; ${o.type}s stay in Backlog.md`);
42739
+ const statuses = await statusesOf(a);
42693
42740
  const ts = await a.list({
42694
- ...o.status ? { status: o.status.map(statusOf) } : {},
42741
+ ...o.status ? { status: o.status.map((x) => statusIn(statuses, x)) } : {},
42695
42742
  ...o.priority ? { priority: [o.priority] } : {},
42696
42743
  ...o.taskType ? { type: o.taskType } : {},
42697
42744
  ...o.area ? { area: o.area } : {},
42698
42745
  ...o.all ? { place: ["tasks", "drafts", "archive/tasks", "archive/drafts"] } : {}
42699
42746
  });
42700
- const out = new Set((o.excludeStatus ?? []).map(statusOf));
42747
+ const out = new Set((o.excludeStatus ?? []).map((x) => statusIn(statuses, x)));
42701
42748
  let hits = rank(
42702
42749
  ts.filter((t) => !out.has(t.status)),
42703
42750
  query ?? ""
@@ -42712,7 +42759,7 @@ ${file2 ? `File: ${file2}
42712
42759
  print3({
42713
42760
  schemaVersion: 1,
42714
42761
  kind: "search",
42715
- results: hits.map((h) => ({ type: "task", data: listItem(h.task, status, STATUSES) }))
42762
+ results: hits.map((h) => ({ type: "task", data: listItem(h.task, status, statuses) }))
42716
42763
  });
42717
42764
  } else print3(searchPlain(hits));
42718
42765
  })
@@ -42731,8 +42778,8 @@ ${file2 ? `File: ${file2}
42731
42778
  ];
42732
42779
  const config2 = program3.command("config").description(`board settings: statuses, task_prefix, ${SETTINGS.join(", ")}`);
42733
42780
  config2.command("get").argument("<key>").action(
42734
- (key) => key === "statuses" ? print3(`${STATUSES.join(", ")}
42735
- `) : key === "task_prefix" || key === "prefix" ? ctx.withStore(async (a) => print3(`${(await a.prefixOf()).toLowerCase()}
42781
+ (key) => key === "statuses" ? ctx.withStore(async (a) => print3(`${(await statusesOf(a)).join(", ")}
42782
+ `)) : key === "task_prefix" || key === "prefix" ? ctx.withStore(async (a) => print3(`${(await a.prefixOf()).toLowerCase()}
42736
42783
  `)) : SETTINGS.includes(key) ? ctx.withStore(async (a) => print3(`${await a.getSetting(key) ?? ""}
42737
42784
  `)) : print3("\n")
42738
42785
  );
@@ -42904,6 +42951,7 @@ ${ms2.map((m) => ` ${m.id}: ${m.title} (${m.done}/${m.total} done)`).join("\n")
42904
42951
  }
42905
42952
  const pre = taskPrefix(dir);
42906
42953
  if (pre) await a.setSetting("prefix", pre, ctx.by, true);
42954
+ await syncStatuses(a, dir, ctx.by);
42907
42955
  await a.putMilestones(ms2, ctx.by);
42908
42956
  const r = await a.importTasks(
42909
42957
  files.map((f) => ({ task: f.task, place: f.where })),