@theholocron/cli 5.0.0-alpha.374 → 5.0.0-alpha.376

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/README.md CHANGED
@@ -111,7 +111,7 @@ Every command is tagged with how much of a repo it needs:
111
111
  | ------------ | -------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
112
112
  | `global` | the CLI binary alone | `version`, `clone`, `new repo` / `plugin`, `repo upgrade …`, `auth set` / `check`, `package …`, `run lint commit-msg`, `skills …` |
113
113
  | `repo-aware` | `./holocron.config`, walking up from cwd, no plugins | `run`, `run ci`, `config show`, `repo sync readme`, `deploy on-release` |
114
- | `workspace` | the `@theholocron/holocron-plugin-*` packages resolvable | `doctor`, `repo setup`, `repo sync`, `repo cleanup branches`, `secrets …`, `deploy`, `sync github` |
114
+ | `workspace` | the `@theholocron/holocron-plugin-*` packages resolvable | `doctor`, `repo setup`, `repo sync`, `repo cleanup branches`, `secrets …`, `deploy`, `sync github`, `sync issues` |
115
115
 
116
116
  A `workspace` command run from a bare global install (no plugins next to the
117
117
  CLI) fails with one actionable line — install the plugins as devDependencies or
@@ -690,6 +690,17 @@ Provider credentials for Discord: `discord.holonet` is the **bot token** (Bot
690
690
 
691
691
  See the [command pages](https://theholocron.dev/holocron/commands/notifications-setup/) for each command's options.
692
692
 
693
+ ## Syncing issues
694
+
695
+ - **`holocron sync issues --from <a> --to <b> [--since <time>] [--yes]`** — one direction of an issue sync between two
696
+ trackers (`github`, `linear:team=ENG`); swap the ends for the other direction. Unlike `holocron migrate` it updates what
697
+ it made: it creates a missing issue, sets title, description, state, priority, labels and assignee when they differ, and
698
+ adds the comments the target lacks (oldest first, never edited or deleted). It writes nothing to the source, and changes
699
+ a target issue only when a migrate or sync made it (the recorded `holocron:migrated-from` marker or attachment). A source
700
+ issue that itself carries such an address is skipped, which stops the two directions echoing each other. The report
701
+ counts created, updated, unchanged, skipped (guard) and left, and ends with the `not carried across` list. A rate limit
702
+ stops the run with a `left` count. A target needs the optional `Issues.sync`; GitHub and Linear have it.
703
+
693
704
  ## Cleaning up
694
705
 
695
706
  - **`holocron repo properties apply [--yes]`** — adds the capabilities the organization's `holocron_capabilities`
package/dist/cli.mjs CHANGED
@@ -781,7 +781,8 @@ const COMMAND_CONTEXTS = {
781
781
  "monitoring run-resolved": "global",
782
782
  "repo sync": "workspace",
783
783
  "repo cleanup branches": "workspace",
784
- "sync github": "workspace"
784
+ "sync github": "workspace",
785
+ "sync issues": "workspace"
785
786
  };
786
787
  /**
787
788
  * The context for a command name from `argv._`. Falls back to the leading
@@ -2757,6 +2758,35 @@ const registry = createCommandRegistry([
2757
2758
  positionals: [],
2758
2759
  supportsDryRun: true
2759
2760
  },
2761
+ {
2762
+ name: "sync issues",
2763
+ description: "Keep one tracker's issues up to date from another, one direction (GitHub and Linear)",
2764
+ positionals: [],
2765
+ options: [
2766
+ {
2767
+ key: "from",
2768
+ flag: "--from",
2769
+ type: "input",
2770
+ required: true,
2771
+ message: "Read the issues from (github, linear:team=ENG):"
2772
+ },
2773
+ {
2774
+ key: "to",
2775
+ flag: "--to",
2776
+ type: "input",
2777
+ required: true,
2778
+ message: "Write them to:"
2779
+ },
2780
+ {
2781
+ key: "since",
2782
+ flag: "--since",
2783
+ type: "input",
2784
+ message: "Only issues changed since (7d, 2026-03-01):"
2785
+ }
2786
+ ],
2787
+ skipOptions: ["yes"],
2788
+ supportsDryRun: true
2789
+ },
2760
2790
  {
2761
2791
  name: "repo sync readme",
2762
2792
  description: "Sync the Installation + Usage block in README.md from package.json",
@@ -11223,7 +11253,7 @@ async function openSide(input) {
11223
11253
  };
11224
11254
  const loader = input.makeLoader?.(resolved, input.context) ?? new PluginLoader(resolved, input.context);
11225
11255
  await loader.load();
11226
- assertPluginsResolvable$1(loader, "migrate");
11256
+ assertPluginsResolvable$1(loader, input.command ?? "migrate");
11227
11257
  const side = {
11228
11258
  ok: true,
11229
11259
  provider: endpoint.provider
@@ -23801,11 +23831,174 @@ const syncGithubCommand = {
23801
23831
  })).status === "fail") process.exitCode = 1;
23802
23832
  }
23803
23833
  };
23834
+ // src/commands/sync-issues/parse-since/parse-since.ts
23835
+ const UNITS = {
23836
+ m: 6e4,
23837
+ h: 36e5,
23838
+ d: 864e5,
23839
+ w: 6048e5
23840
+ };
23841
+ /**
23842
+ * Turns the `--since` value into an ISO timestamp: a date or date and time (`2026-03-01`, `2026-03-01T09:00:00Z`) or a
23843
+ * span back from `now` (`30m`, `12h`, `7d`, `2w`). Anything else is a `ConfigError`, so a typo never reads as "all".
23844
+ */
23845
+ function parseSince(value, now = Date.now()) {
23846
+ const span = /^(\d+)([mhdw])$/.exec(value.trim());
23847
+ if (span) return new Date(now - Number(span[1]) * UNITS[span[2]]).toISOString();
23848
+ const at = Date.parse(value);
23849
+ if (Number.isNaN(at)) throw new ConfigError$1(`sync issues: --since "${value}" is not a date or a span like 30m, 12h, 7d or 2w`);
23850
+ return new Date(at).toISOString();
23851
+ }
23852
+ // src/commands/sync-issues/run-sync-issues/run-sync-issues.ts
23853
+ /**
23854
+ * `holocron sync issues` — one direction of the issue sync between two trackers.
23855
+ *
23856
+ * It reads the source's issues with `export`, drops the ones that carry an address from another tracker (the loop
23857
+ * guard: such an issue is itself a copy, so syncing it back would echo), and hands the rest to the target's `sync`,
23858
+ * which creates what is missing and brings up to date what an earlier migrate or sync made. The source is only read.
23859
+ * A rate limit stops the run with a `left` count; the next run continues. Every run ends with the same
23860
+ * `not carried across` list `migrate` prints. It writes, so it asks first (`--yes` skips the question; without a
23861
+ * terminal it refuses instead of hanging).
23862
+ */
23863
+ async function runSyncIssues(input) {
23864
+ const print = input.print ?? ((line) => console.log(line));
23865
+ const row = (status, text) => print(statusRow(status, ["sync issues", text]));
23866
+ const stop = (status, reason) => {
23867
+ row(status, reason);
23868
+ return {
23869
+ status,
23870
+ reason
23871
+ };
23872
+ };
23873
+ const from = parseEndpoint(input.from, "--from");
23874
+ const to = parseEndpoint(input.to, "--to");
23875
+ if (from.provider === to.provider && JSON.stringify(from.options) === JSON.stringify(to.options)) return stop("fail", "--from and --to are the same; name a different repo, team or provider");
23876
+ const side = {
23877
+ loaded: input.loaded,
23878
+ context: input.context,
23879
+ capabilities: ["issues"],
23880
+ command: "sync issues"
23881
+ };
23882
+ const source = await openSide({
23883
+ ...side,
23884
+ endpoint: from,
23885
+ makeLoader: input.makeLoader
23886
+ });
23887
+ if (!source.ok) return stop("fail", `source: ${source.reason}`);
23888
+ const target = await openSide({
23889
+ ...side,
23890
+ endpoint: to,
23891
+ makeLoader: input.makeLoader
23892
+ });
23893
+ if (!target.ok) return stop("fail", `target: ${target.reason}`);
23894
+ const syncer = target.issues;
23895
+ if (!syncer?.sync) return stop("skip", `the \`${target.provider}\` provider cannot be a sync target`);
23896
+ const collected = await collectRecords({
23897
+ source,
23898
+ scope: {
23899
+ kind: "issues",
23900
+ selector: {
23901
+ all: true,
23902
+ ...input.since ? { since: input.since } : {}
23903
+ }
23904
+ }
23905
+ });
23906
+ if (!collected.ok) return stop(collected.reason.startsWith("the `") ? "skip" : "fail", collected.reason);
23907
+ const { records } = collected;
23908
+ if (records.length === 0) return stop("skip", "nothing to sync");
23909
+ const guarded = records.filter((r) => r.migratedFrom !== void 0);
23910
+ const toSync = records.filter((r) => r.migratedFrom === void 0);
23911
+ for (const r of guarded) row("skip", `${r.key} is a copy of ${r.migratedFrom}; not synced back`);
23912
+ const dryRun = Boolean(input.context.dryRun);
23913
+ let results = [];
23914
+ if (toSync.length > 0) {
23915
+ if (!dryRun && !input.yes) {
23916
+ if (!(input.interactive ?? Boolean(process.stdin.isTTY))) throw new NonInteractiveError(`\`sync issues\` creates and changes issues on ${target.provider}; pass --yes to run it without asking`);
23917
+ if (!await (input.confirm ?? ((message) => confirm({
23918
+ message,
23919
+ default: false
23920
+ })))(`Sync ${toSync.length} issue(s) from ${source.provider} to ${target.provider}? Issues an earlier sync made are updated.`)) {
23921
+ row("skip", "cancelled; nothing was changed");
23922
+ return { status: "cancelled" };
23923
+ }
23924
+ }
23925
+ try {
23926
+ results = await syncer.sync(toSync, { dryRun });
23927
+ } catch (err) {
23928
+ return stop("fail", `${describeError(err)} (a second run continues where this stopped)`);
23929
+ }
23930
+ }
23931
+ for (const r of results) if (r.created) row("ok", `${r.source} → ${r.key ?? "(new)"} (${dryRun ? "would create" : "created"})`);
23932
+ else if (r.updated) row("ok", `${r.source} → ${r.key} (${dryRun ? "would update" : "updated"}: ${r.changes.join(", ")})`);
23933
+ else row("skip", `${r.source} → ${r.key} (unchanged)`);
23934
+ const done = new Set(results.map((r) => r.source));
23935
+ const counts = {
23936
+ created: results.filter((r) => r.created).length,
23937
+ updated: results.filter((r) => r.updated).length,
23938
+ unchanged: results.filter((r) => !r.created && !r.updated).length,
23939
+ guarded: guarded.length,
23940
+ left: toSync.filter((r) => !done.has(r.key)).length
23941
+ };
23942
+ if (counts.left > 0) row("skip", `stopped: ${target.provider} is rate limiting; ${counts.left} issue(s) are left for the next run`);
23943
+ row(dryRun ? "skip" : "ok", `${source.provider} to ${target.provider}: ${dryRun ? "dry run, nothing written; would create" : "created"} ${counts.created}, ${dryRun ? "would update" : "updated"} ${counts.updated}, unchanged ${counts.unchanged}, skipped (guard) ${counts.guarded}, left ${counts.left}`);
23944
+ const notCarried = tallyDropped(results);
23945
+ if (notCarried.length > 0) {
23946
+ print(" not carried across:");
23947
+ for (const { what, count } of notCarried) print(` ${what}: ${count} issue(s)`);
23948
+ }
23949
+ return {
23950
+ status: "ok",
23951
+ results,
23952
+ counts,
23953
+ notCarried
23954
+ };
23955
+ }
23956
+ // src/commands/sync-issues/sync-issues.command.ts
23957
+ const syncIssuesCommand = {
23958
+ command: "issues",
23959
+ describe: "Keep issues on one tracker up to date from another, one direction: create what is missing, update what a sync made, add comments",
23960
+ builder: (y) => y.option("from", {
23961
+ type: "string",
23962
+ demandOption: true,
23963
+ describe: "Where the issues are read from (never written): `provider` or `provider:key=value,...`"
23964
+ }).option("to", {
23965
+ type: "string",
23966
+ demandOption: true,
23967
+ describe: "Where they are written, in the same form"
23968
+ }).option("since", {
23969
+ type: "string",
23970
+ describe: "Only issues changed since this date or span back from now (2026-03-01, 7d, 12h)"
23971
+ }).option("yes", {
23972
+ type: "boolean",
23973
+ describe: "Sync without asking (a scheduled run needs it)"
23974
+ }),
23975
+ handler: async (argv) => {
23976
+ const since = argv.since ? parseSince(argv.since) : void 0;
23977
+ const tokens = tokenContext$1(argv.token);
23978
+ if (!tokens) return;
23979
+ const loaded = await loadConfig(argv.cwd);
23980
+ applyResolvedConfig(argv, loaded.resolved);
23981
+ const org = resolveOrg(argv, loaded.resolved);
23982
+ if ((await runSyncIssues({
23983
+ loaded,
23984
+ context: {
23985
+ repoRoot: argv.cwd,
23986
+ dryRun: argv.dryRun,
23987
+ ...tokens,
23988
+ org
23989
+ },
23990
+ from: argv.from,
23991
+ to: argv.to,
23992
+ ...since ? { since } : {},
23993
+ ...argv.yes ? { yes: true } : {}
23994
+ })).status === "fail") process.exitCode = 1;
23995
+ }
23996
+ };
23804
23997
  // src/commands/sync/sync.command.ts
23805
23998
  const syncCommand = {
23806
23999
  command: "sync",
23807
- describe: "Sync generated files to other repos",
23808
- builder: (y) => y.command(syncGithubCommand).command(groupMenu$1("sync")),
24000
+ describe: "Sync generated files to other repos, or issues from one tracker to another",
24001
+ builder: (y) => y.command(syncGithubCommand).command(syncIssuesCommand).command(groupMenu$1("sync")),
23809
24002
  handler: () => {}
23810
24003
  };
23811
24004
  // src/commands/tunnel/tunnel.command.ts