@staff0rd/assist 0.870.3 → 0.871.0

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
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.870.3",
9
+ version: "0.871.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -1205,6 +1205,7 @@ function buildRunEntry(name, command, args, options2) {
1205
1205
  if (options2?.cwd) entry.cwd = options2.cwd;
1206
1206
  if (options2?.server !== void 0) entry.server = options2.server;
1207
1207
  if (options2?.port !== void 0) entry.port = options2.port;
1208
+ if (options2?.env) entry.env = options2.env;
1208
1209
  return entry;
1209
1210
  }
1210
1211
 
@@ -2917,9 +2918,9 @@ function getDocumentedConfigKeys() {
2917
2918
  return documentedKeys;
2918
2919
  }
2919
2920
  function renderConfigHelp(entries, preamble) {
2920
- const width = Math.max(...entries.map((entry) => entry.setter.length));
2921
+ const width2 = Math.max(...entries.map((entry) => entry.setter.length));
2921
2922
  const lines2 = entries.map(
2922
- (entry) => ` ${entry.setter.padEnd(width)} # ${entry.note}`
2923
+ (entry) => ` ${entry.setter.padEnd(width2)} # ${entry.note}`
2923
2924
  );
2924
2925
  const body = preamble ? ["", preamble, "", "Config:", ...lines2] : ["", "Config:", ...lines2];
2925
2926
  return body.join("\n");
@@ -3148,14 +3149,14 @@ function adviceHookPayload(cwd) {
3148
3149
  import chalk25 from "chalk";
3149
3150
  function explainAdvice(context, fragments = loadAdviceFragments()) {
3150
3151
  const decisions = selectAdvice(fragments, context);
3151
- const width = Math.max(
3152
+ const width2 = Math.max(
3152
3153
  ...decisions.map((decision) => decision.fragment.name.length)
3153
3154
  );
3154
3155
  const titleWidth = Math.max(
3155
3156
  ...decisions.map((decision) => decision.fragment.title.length)
3156
3157
  );
3157
3158
  return decisions.map(
3158
- ({ fragment, included, reason: reason4 }) => `${included ? chalk25.green("\u2713") : chalk25.dim("\u2717")} ${fragment.name.padEnd(width)} ${chalk25.dim(fragment.title.padEnd(titleWidth))} ${reason4}`
3159
+ ({ fragment, included, reason: reason4 }) => `${included ? chalk25.green("\u2713") : chalk25.dim("\u2717")} ${fragment.name.padEnd(width2)} ${chalk25.dim(fragment.title.padEnd(titleWidth))} ${reason4}`
3159
3160
  ).join("\n");
3160
3161
  }
3161
3162
 
@@ -6955,8 +6956,8 @@ function repoPrefixer(items2, allRepos) {
6955
6956
  items2.flatMap((i) => i.origin ? [i.origin] : [])
6956
6957
  );
6957
6958
  const repoNameOf = (item) => item.origin ? labels.get(item.origin) ?? "" : "";
6958
- const width = Math.max(0, ...items2.map((i) => repoNameOf(i).length));
6959
- return (item) => `${chalk52.dim(repoNameOf(item).padEnd(width))} `;
6959
+ const width2 = Math.max(0, ...items2.map((i) => repoNameOf(i).length));
6960
+ return (item) => `${chalk52.dim(repoNameOf(item).padEnd(width2))} `;
6960
6961
  }
6961
6962
  async function list(options2) {
6962
6963
  const allItems = await loadBacklog(options2.allRepos);
@@ -7198,8 +7199,8 @@ import chalk54 from "chalk";
7198
7199
  import { Marked } from "marked";
7199
7200
  import { markedTerminal } from "marked-terminal";
7200
7201
  function renderMarkdownTerminal(text18) {
7201
- const width = process.stdout.columns || 80;
7202
- const marked = new Marked(markedTerminal({ width, reflowText: true }));
7202
+ const width2 = process.stdout.columns || 80;
7203
+ const marked = new Marked(markedTerminal({ width: width2, reflowText: true }));
7203
7204
  marked.use({
7204
7205
  renderer: {
7205
7206
  text(token) {
@@ -13670,7 +13671,7 @@ var rootConfigHelp = {
13670
13671
  var runConfigHelp = [
13671
13672
  {
13672
13673
  key: "run",
13673
- setter: "assist run add <name> <command> [--server [group]] [--repo]",
13674
+ setter: "assist run add <name> <command> [--env KEY=VALUE] [--server [group]] [--repo]",
13674
13675
  note: "configured commands runnable via assist run <name>"
13675
13676
  }
13676
13677
  ];
@@ -36363,36 +36364,11 @@ function buildHighLevelRecord(subject, decision) {
36363
36364
  };
36364
36365
  }
36365
36366
 
36366
- // src/commands/review/highLevel/highLevelChangedFileCount.ts
36367
- function highLevelChangedFileCount(structure) {
36368
- return structure.added + structure.removed + structure.modified;
36369
- }
36370
-
36371
- // src/commands/review/highLevel/highLevelTestCount.ts
36372
- function countNodes(nodes) {
36373
- return nodes.reduce(
36374
- (sum3, node) => sum3 + (node.kind === "it" ? 1 : countNodes(node.children)),
36375
- 0
36376
- );
36377
- }
36378
- function highLevelTestCount(files) {
36379
- return countNodes(files.flatMap((file) => file.tests));
36380
- }
36381
-
36382
36367
  // src/commands/review/highLevel/highLevelPreviewMetadata.ts
36383
36368
  function highLevelPreviewMetadata(subject) {
36384
36369
  return [
36385
36370
  { label: "Branch", value: subject.headRef },
36386
36371
  { label: "Head", value: subject.headSha.slice(0, 7) },
36387
- {
36388
- label: "Changed files",
36389
- value: String(highLevelChangedFileCount(subject.structure))
36390
- },
36391
- { label: "Critical files", value: String(subject.criticalDiffs.length) },
36392
- {
36393
- label: "Changed tests",
36394
- value: String(highLevelTestCount(subject.tests))
36395
- },
36396
36372
  ...subject.saved ? [{ label: "Reopened from", value: subject.saved.reviewedAt }] : []
36397
36373
  ];
36398
36374
  }
@@ -36789,6 +36765,11 @@ function formatHighLevelTests(files, testPaths) {
36789
36765
  ].join("\n");
36790
36766
  }
36791
36767
 
36768
+ // src/commands/review/highLevel/highLevelChangedFileCount.ts
36769
+ function highLevelChangedFileCount(structure) {
36770
+ return structure.added + structure.removed + structure.modified;
36771
+ }
36772
+
36792
36773
  // src/commands/review/highLevel/printHighLevelChecklist.ts
36793
36774
  function printHighLevelChecklist(subject) {
36794
36775
  console.log(
@@ -39465,7 +39446,7 @@ function listRules(target, options2 = {}) {
39465
39446
  return;
39466
39447
  }
39467
39448
  const base = findRepoRoot(scopeDirectory(resolved));
39468
- const width = Math.max(...rules2.map((rule) => rule.code.length));
39449
+ const width2 = Math.max(...rules2.map((rule) => rule.code.length));
39469
39450
  let shown;
39470
39451
  for (const rule of rules2) {
39471
39452
  if (rule.source !== shown) {
@@ -39475,10 +39456,10 @@ function listRules(target, options2 = {}) {
39475
39456
  );
39476
39457
  }
39477
39458
  console.log(
39478
- ` ${chalk246.cyan(rule.code.padEnd(width))} ${rule.title ?? rule.text}`
39459
+ ` ${chalk246.cyan(rule.code.padEnd(width2))} ${rule.title ?? rule.text}`
39479
39460
  );
39480
39461
  if (options2.full && rule.title)
39481
- console.log(` ${" ".repeat(width)} ${chalk246.dim(rule.text)}`);
39462
+ console.log(` ${" ".repeat(width2)} ${chalk246.dim(rule.text)}`);
39482
39463
  }
39483
39464
  }
39484
39465
 
@@ -40811,8 +40792,8 @@ function registerSync(program2) {
40811
40792
  import { existsSync as existsSync77 } from "fs";
40812
40793
 
40813
40794
  // src/commands/transcript/convert/formatTimestamp.ts
40814
- function pad(value, width) {
40815
- return String(value).padStart(width, "0");
40795
+ function pad(value, width2) {
40796
+ return String(value).padStart(width2, "0");
40816
40797
  }
40817
40798
  function formatTimestamp2(ms) {
40818
40799
  const totalSeconds = Math.floor(ms / 1e3);
@@ -43295,6 +43276,56 @@ async function run3(name, args) {
43295
43276
  execRunConfig(findRunConfig(name), args);
43296
43277
  }
43297
43278
 
43279
+ // src/commands/run/extractOption.ts
43280
+ function extractOption(args, flag) {
43281
+ const index2 = args.indexOf(flag);
43282
+ if (index2 === -1) return { value: void 0, remaining: args };
43283
+ return {
43284
+ value: args[index2 + 1],
43285
+ remaining: [...args.slice(0, index2), ...args.slice(index2 + 2)]
43286
+ };
43287
+ }
43288
+
43289
+ // src/commands/run/link.ts
43290
+ function findLinkIndex() {
43291
+ const idx = process.argv.indexOf("link");
43292
+ if (idx === -1 || idx + 1 >= process.argv.length) return -1;
43293
+ return idx;
43294
+ }
43295
+ function parseLinkArgs() {
43296
+ const idx = findLinkIndex();
43297
+ if (idx === -1) return null;
43298
+ const path109 = process.argv[idx + 1];
43299
+ const rest = process.argv.slice(idx + 2);
43300
+ const { value: prefix2 } = extractOption(rest, "--prefix");
43301
+ if (!prefix2) return null;
43302
+ return { path: path109, prefix: prefix2 };
43303
+ }
43304
+ function hasDuplicateLink(runList, linkPath) {
43305
+ return runList.some(
43306
+ (r) => typeof r === "object" && r !== null && "link" in r && r.link === linkPath
43307
+ );
43308
+ }
43309
+ function link2() {
43310
+ const parsed = parseLinkArgs();
43311
+ if (!parsed) {
43312
+ console.error("Usage: assist run link <path> --prefix <prefix>");
43313
+ process.exit(1);
43314
+ }
43315
+ const config = loadProjectConfig();
43316
+ if (!config.run) config.run = [];
43317
+ const runList = config.run;
43318
+ if (hasDuplicateLink(runList, parsed.path)) {
43319
+ console.error(`Link to "${parsed.path}" already exists`);
43320
+ process.exit(1);
43321
+ }
43322
+ runList.push({ link: parsed.path, prefix: parsed.prefix });
43323
+ saveConfig(config);
43324
+ console.log(
43325
+ `Linked run configurations from: ${parsed.path} (prefix: ${parsed.prefix})`
43326
+ );
43327
+ }
43328
+
43298
43329
  // src/commands/run/add.ts
43299
43330
  import { mkdirSync as mkdirSync34, writeFileSync as writeFileSync52 } from "fs";
43300
43331
  import { join as join101 } from "path";
@@ -43327,16 +43358,6 @@ function addRepoRunConfig(entry, repoName, cwd = process.cwd()) {
43327
43358
  });
43328
43359
  }
43329
43360
 
43330
- // src/commands/run/extractOption.ts
43331
- function extractOption(args, flag) {
43332
- const index2 = args.indexOf(flag);
43333
- if (index2 === -1) return { value: void 0, remaining: args };
43334
- return {
43335
- value: args[index2 + 1],
43336
- remaining: [...args.slice(0, index2), ...args.slice(index2 + 2)]
43337
- };
43338
- }
43339
-
43340
43361
  // src/commands/run/extractOptionalValueFlag.ts
43341
43362
  function extractOptionalValueFlag(args, flag) {
43342
43363
  const index2 = args.indexOf(flag);
@@ -43352,6 +43373,35 @@ function extractOptionalValueFlag(args, flag) {
43352
43373
  };
43353
43374
  }
43354
43375
 
43376
+ // src/commands/run/extractRepeatedOption.ts
43377
+ function extractRepeatedOption(args, flag) {
43378
+ const values = [];
43379
+ const remaining = [];
43380
+ for (let i = 0; i < args.length; i++) {
43381
+ if (args[i] === flag && i + 1 < args.length) {
43382
+ values.push(args[++i]);
43383
+ } else {
43384
+ remaining.push(args[i]);
43385
+ }
43386
+ }
43387
+ return { values, remaining };
43388
+ }
43389
+
43390
+ // src/commands/run/parseEnvPairs.ts
43391
+ function parseEnvPairs(pairs) {
43392
+ if (pairs.length === 0) return void 0;
43393
+ const env = {};
43394
+ for (const pair of pairs) {
43395
+ const eq48 = pair.indexOf("=");
43396
+ if (eq48 <= 0) {
43397
+ console.error(`--env must be KEY=VALUE, got "${pair}"`);
43398
+ process.exit(1);
43399
+ }
43400
+ env[pair.slice(0, eq48)] = pair.slice(eq48 + 1);
43401
+ }
43402
+ return env;
43403
+ }
43404
+
43355
43405
  // src/commands/run/requireParsedArgs.ts
43356
43406
  function findAddIndex() {
43357
43407
  const addIndex = process.argv.indexOf("add");
@@ -43369,7 +43419,8 @@ function parsePort(raw) {
43369
43419
  }
43370
43420
  function extractAddArgs(addIndex) {
43371
43421
  const rawArgs = process.argv.slice(addIndex + 3);
43372
- const cwd = extractOption(rawArgs, "--cwd");
43422
+ const env = extractRepeatedOption(rawArgs, "--env");
43423
+ const cwd = extractOption(env.remaining, "--cwd");
43373
43424
  const port = extractOption(cwd.remaining, "--port");
43374
43425
  const server = extractOptionalValueFlag(port.remaining, "--server");
43375
43426
  const repo = extractOptionalValueFlag(server.remaining, "--repo");
@@ -43380,7 +43431,8 @@ function extractAddArgs(addIndex) {
43380
43431
  options: {
43381
43432
  cwd: cwd.value,
43382
43433
  server: server.value,
43383
- port: parsePort(port.value)
43434
+ port: parsePort(port.value),
43435
+ env: parseEnvPairs(env.values)
43384
43436
  },
43385
43437
  repo: repo.value
43386
43438
  };
@@ -43440,44 +43492,75 @@ async function add4() {
43440
43492
  console.log(`Added run configuration: ${name} -> ${display}`);
43441
43493
  }
43442
43494
 
43443
- // src/commands/run/link.ts
43444
- function findLinkIndex() {
43445
- const idx = process.argv.indexOf("link");
43446
- if (idx === -1 || idx + 1 >= process.argv.length) return -1;
43447
- return idx;
43448
- }
43449
- function parseLinkArgs() {
43450
- const idx = findLinkIndex();
43451
- if (idx === -1) return null;
43452
- const path109 = process.argv[idx + 1];
43453
- const rest = process.argv.slice(idx + 2);
43454
- const { value: prefix2 } = extractOption(rest, "--prefix");
43455
- if (!prefix2) return null;
43456
- return { path: path109, prefix: prefix2 };
43457
- }
43458
- function hasDuplicateLink(runList, linkPath) {
43459
- return runList.some(
43460
- (r) => typeof r === "object" && r !== null && "link" in r && r.link === linkPath
43461
- );
43462
- }
43463
- function link2() {
43464
- const parsed = parseLinkArgs();
43465
- if (!parsed) {
43466
- console.error("Usage: assist run link <path> --prefix <prefix>");
43467
- process.exit(1);
43468
- }
43469
- const config = loadProjectConfig();
43470
- if (!config.run) config.run = [];
43471
- const runList = config.run;
43472
- if (hasDuplicateLink(runList, parsed.path)) {
43473
- console.error(`Link to "${parsed.path}" already exists`);
43474
- process.exit(1);
43475
- }
43476
- runList.push({ link: parsed.path, prefix: parsed.prefix });
43477
- saveConfig(config);
43478
- console.log(
43479
- `Linked run configurations from: ${parsed.path} (prefix: ${parsed.prefix})`
43480
- );
43495
+ // src/commands/run/runAddHelpText.ts
43496
+ var properties = [
43497
+ ["name", "<name>", "what you type after assist run"],
43498
+ ["command", "<command>", "executable to spawn"],
43499
+ ["args", "[args...]", "static args appended to the command"],
43500
+ ["cwd", "--cwd <dir>", "working directory, relative to the config file"],
43501
+ [
43502
+ "env",
43503
+ "--env KEY=VALUE",
43504
+ "environment variable for the command (repeatable)"
43505
+ ],
43506
+ ["server", "--server [group]", "singleton dev server, optionally grouped"],
43507
+ ["port", "--port <port>", "display-only port on the serving card"],
43508
+ [
43509
+ "pre",
43510
+ "set in config",
43511
+ "shell commands run before this one, each as a list item"
43512
+ ],
43513
+ [
43514
+ "filter",
43515
+ "set in config",
43516
+ "verify: entries only run when a changed file matches this glob"
43517
+ ],
43518
+ ["quiet", "set in config", "suppress the command's output unless it fails"],
43519
+ [
43520
+ "params",
43521
+ "set in config",
43522
+ "positional params (name, required, default, description)"
43523
+ ]
43524
+ ];
43525
+ var width = Math.max(...properties.map(([key]) => key.length));
43526
+ var flagWidth = Math.max(...properties.map(([, flag]) => flag.length));
43527
+ var runAddHelpText = [
43528
+ "",
43529
+ "Run entry properties:",
43530
+ ...properties.map(
43531
+ ([key, flag, note]) => ` ${key.padEnd(width)} ${flag.padEnd(flagWidth)} ${note}`
43532
+ ),
43533
+ "",
43534
+ 'The command is spawned without a shell, so "FOO=bar cmd", "&&", pipes and redirects do not work; use --env for environment variables and pre for setup steps.',
43535
+ "",
43536
+ 'Options go after <command>. --server and --repo take the next argument as their value unless it starts with "-", so put them last or before another option:',
43537
+ " assist run add dev npm run dev --env PORT=3000 --server --port 3000 --repo",
43538
+ "",
43539
+ "Properties marked 'set in config' are edited in assist.yml directly, e.g.:",
43540
+ " params:",
43541
+ ' - name: env # assist run deploy prod \u2192 appends "prod"',
43542
+ " required: true",
43543
+ " - name: tag",
43544
+ " default: latest"
43545
+ ].join("\n");
43546
+
43547
+ // src/commands/run/registerRunAdd.ts
43548
+ function registerRunAdd(runCommand) {
43549
+ runCommand.command("add").description(
43550
+ "Add a new run configuration to assist.yml, or with --repo to the shared db"
43551
+ ).argument("<name>", "Name for the run configuration").argument("<command>", "Command to execute").argument("[args...]", "Static args to pass to the command").option(
43552
+ "--cwd <dir>",
43553
+ "Working directory (resolved relative to the config file)"
43554
+ ).option(
43555
+ "--server [group]",
43556
+ "Mark as a singleton dev server, optionally in a named group (default group: default)"
43557
+ ).option("--port <port>", "Display-only port shown on the serving card").option(
43558
+ "--env <KEY=VALUE>",
43559
+ "Environment variable for the command (repeatable)"
43560
+ ).option(
43561
+ "--repo [name]",
43562
+ "Write to a repo's override in the shared db, seen by every node, instead of assist.yml (defaults to the current repo; no command file is created)"
43563
+ ).addHelpText("after", runAddHelpText).allowUnknownOption().allowExcessArguments().action(() => add4());
43481
43564
  }
43482
43565
 
43483
43566
  // src/commands/run/remove.ts
@@ -43533,21 +43616,7 @@ async function remove(name, options2 = {}) {
43533
43616
  // src/commands/run/registerRunSubcommands.ts
43534
43617
  function registerRunSubcommands(runCommand) {
43535
43618
  runCommand.command("list").description("List configured run commands").option("-v, --verbose", "Show full command details").action((opts) => listRunConfigs(!!opts.verbose));
43536
- runCommand.command("add").description(
43537
- "Add a new run configuration to assist.yml, or with --repo to the shared db"
43538
- ).argument("<name>", "Name for the run configuration").argument("<command>", "Command to execute").argument("[args...]", "Static args to pass to the command").option(
43539
- "--cwd <dir>",
43540
- "Working directory (resolved relative to the config file)"
43541
- ).option(
43542
- "--server [group]",
43543
- "Mark as a singleton dev server, optionally in a named group (default group: default)"
43544
- ).option("--port <port>", "Display-only port shown on the serving card").option(
43545
- "--repo [name]",
43546
- "Write to a repo's override in the shared db, seen by every node, instead of assist.yml (defaults to the current repo; no command file is created)"
43547
- ).addHelpText(
43548
- "after",
43549
- '\nOptions go after <command>. --server and --repo take the next argument as their value unless it starts with "-", so put them last or before another option:\n assist run add dev npm run dev --server --port 3000 --repo\n\nPositional params can be added to the config manually:\n params:\n - name: env # assist run deploy prod \u2192 appends "prod"\n required: true\n - name: tag\n default: latest'
43550
- ).allowUnknownOption().allowExcessArguments().action(() => add4());
43619
+ registerRunAdd(runCommand);
43551
43620
  runCommand.command("link").description("Link run configurations from another project's assist.yml").argument("<path>", "Relative path to the linked project").requiredOption("--prefix <prefix>", "Namespace prefix for linked commands").allowUnknownOption().action(() => link2());
43552
43621
  runCommand.command("remove").description(
43553
43622
  "Remove a run configuration from assist.yml, or with --repo from the shared db"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.870.3",
3
+ "version": "0.871.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {