@navbook/cli 0.3.0 → 0.5.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.
Files changed (78) hide show
  1. package/dist/args.d.ts +28 -0
  2. package/dist/args.js +48 -0
  3. package/dist/args.js.map +1 -0
  4. package/dist/commands/complete.d.ts +10 -0
  5. package/dist/commands/complete.js +59 -51
  6. package/dist/commands/complete.js.map +1 -1
  7. package/dist/commands/compose.d.ts +35 -0
  8. package/dist/commands/doctor.d.ts +15 -0
  9. package/dist/commands/entity.d.ts +73 -0
  10. package/dist/commands/entity.js +59 -44
  11. package/dist/commands/entity.js.map +1 -1
  12. package/dist/commands/init.d.ts +11 -0
  13. package/dist/commands/install.d.ts +17 -0
  14. package/dist/commands/install.js +6 -3
  15. package/dist/commands/install.js.map +1 -1
  16. package/dist/commands/issue.d.ts +35 -0
  17. package/dist/commands/issue.js +4 -5
  18. package/dist/commands/issue.js.map +1 -1
  19. package/dist/commands/plugin.d.ts +36 -0
  20. package/dist/commands/plugin.js +386 -0
  21. package/dist/commands/plugin.js.map +1 -0
  22. package/dist/commands/policy.d.ts +58 -0
  23. package/dist/commands/policy.js +28 -2
  24. package/dist/commands/policy.js.map +1 -1
  25. package/dist/commands/pr-elsewhere.d.ts +40 -0
  26. package/dist/commands/pr-elsewhere.js +209 -0
  27. package/dist/commands/pr-elsewhere.js.map +1 -0
  28. package/dist/commands/pr.d.ts +69 -0
  29. package/dist/commands/pr.js +132 -68
  30. package/dist/commands/pr.js.map +1 -1
  31. package/dist/context.d.ts +42 -0
  32. package/dist/context.js +2 -0
  33. package/dist/context.js.map +1 -1
  34. package/dist/editor.d.ts +23 -0
  35. package/dist/editor.js +4 -0
  36. package/dist/editor.js.map +1 -1
  37. package/dist/errors.d.ts +17 -0
  38. package/dist/install/completions.d.ts +19 -0
  39. package/dist/install/hook.d.ts +32 -0
  40. package/dist/install/hook.js +48 -4
  41. package/dist/install/hook.js.map +1 -1
  42. package/dist/main.d.ts +21 -0
  43. package/dist/main.js +112 -8
  44. package/dist/main.js.map +1 -1
  45. package/dist/plugins/commands.d.ts +69 -0
  46. package/dist/plugins/commands.js +148 -0
  47. package/dist/plugins/commands.js.map +1 -0
  48. package/dist/plugins/hint.d.ts +23 -0
  49. package/dist/plugins/hint.js +65 -0
  50. package/dist/plugins/hint.js.map +1 -0
  51. package/dist/plugins/host.d.ts +125 -0
  52. package/dist/plugins/host.js +18 -0
  53. package/dist/plugins/host.js.map +1 -0
  54. package/dist/plugins/loader.d.ts +54 -0
  55. package/dist/plugins/loader.js +165 -0
  56. package/dist/plugins/loader.js.map +1 -0
  57. package/dist/plugins/resolve.d.ts +50 -0
  58. package/dist/plugins/resolve.js +134 -0
  59. package/dist/plugins/resolve.js.map +1 -0
  60. package/dist/plugins/runtime.d.ts +69 -0
  61. package/dist/plugins/runtime.js +256 -0
  62. package/dist/plugins/runtime.js.map +1 -0
  63. package/dist/plugins/store.d.ts +96 -0
  64. package/dist/plugins/store.js +186 -0
  65. package/dist/plugins/store.js.map +1 -0
  66. package/dist/program.d.ts +49 -0
  67. package/dist/program.js +353 -114
  68. package/dist/program.js.map +1 -1
  69. package/dist/prompt.d.ts +31 -0
  70. package/dist/render/colors.d.ts +13 -0
  71. package/dist/render/detail.d.ts +22 -0
  72. package/dist/render/table.d.ts +32 -0
  73. package/dist/render/table.js +123 -13
  74. package/dist/render/table.js.map +1 -1
  75. package/dist/sort.d.ts +27 -0
  76. package/package.json +9 -2
  77. package/dist/commands/feature.js +0 -202
  78. package/dist/commands/feature.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/install/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MA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AAC;AAC/C,CAAC"}
package/dist/main.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `nav` entry point.
4
+ */
5
+ import { type ExitCode } from "./errors.ts";
6
+ export interface RunOptions {
7
+ argv?: string[];
8
+ cwd?: string;
9
+ env?: NodeJS.ProcessEnv;
10
+ stdout?: NodeJS.WriteStream;
11
+ stderr?: NodeJS.WriteStream;
12
+ }
13
+ /**
14
+ * Run the CLI and return its exit code. Never throws for expected failures.
15
+ *
16
+ * Asynchronous because a plugin's code is imported when one of its commands
17
+ * runs (spec 04 §4.3), and `import()` is a promise. Nothing else about the
18
+ * CLI became async: every built-in verb is still synchronous from end to end,
19
+ * and a run with no plugins awaits nothing that was not already resolved.
20
+ */
21
+ export declare function run(opts?: RunOptions): Promise<ExitCode>;
package/dist/main.js CHANGED
@@ -7,31 +7,135 @@ import { WorkspaceError } from "@navbook/core";
7
7
  import { CommanderError } from "commander";
8
8
  import { makeContext } from "./context.js";
9
9
  import { NavError } from "./errors.js";
10
- import { buildProgram } from "./program.js";
11
- /** Run the CLI and return its exit code. Never throws for expected failures. */
12
- export function run(opts = {}) {
10
+ import { hintUndeclared } from "./plugins/hint.js";
11
+ import { missingLine, resolvePlugins, skippedLine, } from "./plugins/resolve.js";
12
+ import { PluginRuntime } from "./plugins/runtime.js";
13
+ import { BUILTIN_NOUNS, buildProgram } from "./program.js";
14
+ /** The reading of a repository there was none of, used when discovery failed. */
15
+ const NO_DECLARATION = {
16
+ plugins: new Map(),
17
+ declared: false,
18
+ problems: [],
19
+ };
20
+ /**
21
+ * Run the CLI and return its exit code. Never throws for expected failures.
22
+ *
23
+ * Asynchronous because a plugin's code is imported when one of its commands
24
+ * runs (spec 04 §4.3), and `import()` is a promise. Nothing else about the
25
+ * CLI became async: every built-in verb is still synchronous from end to end,
26
+ * and a run with no plugins awaits nothing that was not already resolved.
27
+ */
28
+ export async function run(opts = {}) {
13
29
  const argv = opts.argv ?? process.argv.slice(2);
14
30
  const stdout = opts.stdout ?? process.stdout;
15
31
  const stderr = opts.stderr ?? process.stderr;
32
+ const env = opts.env ?? process.env;
33
+ // Built once and memoised. `ext` is filled in below, before any command
34
+ // runs, when and only when the words typed call for it.
16
35
  let ctx = null;
17
- const getCtx = () => {
18
- ctx ??= makeContext({ cwd: opts.cwd, env: opts.env, stdout, stderr });
36
+ let ext;
37
+ // A second context, for the commands that work outside a repository (the
38
+ // plugin store's verbs), which a missing repository must not fail. Kept
39
+ // apart so a command that does need one still gets the complaint.
40
+ let looseCtx = null;
41
+ const getCtx = (want = {}) => {
42
+ if (want.requireRepo === false) {
43
+ looseCtx ??= makeContext({
44
+ cwd: opts.cwd,
45
+ env: opts.env,
46
+ stdout,
47
+ stderr,
48
+ requireRepo: false,
49
+ });
50
+ return looseCtx;
51
+ }
52
+ ctx ??= makeContext({ cwd: opts.cwd, env: opts.env, stdout, stderr, ...(ext ? { ext } : {}) });
19
53
  return ctx;
20
54
  };
21
- const program = buildProgram(getCtx);
55
+ let plugins;
56
+ try {
57
+ plugins = loadPluginRuntime(getCtx, env, stderr);
58
+ }
59
+ catch (error) {
60
+ return report(error, stderr);
61
+ }
62
+ // The one place plugin code may be imported before parsing, and only because
63
+ // the tree cannot be read without it: a registered directory would otherwise
64
+ // parse as an uninterpreted path and a registered key as raw YAML. Decided
65
+ // from the manifests, so a run that needs none pays nothing (spec 04 §4.3).
66
+ if (plugins.needsCoreFor(argv)) {
67
+ try {
68
+ ext = await plugins.coreExtensions(getCtx());
69
+ // Drop any context built while resolving, so nothing that reads the tree
70
+ // can have been handed one without the extensions.
71
+ ctx = null;
72
+ }
73
+ catch (error) {
74
+ return report(error, stderr);
75
+ }
76
+ }
77
+ const program = buildProgram(getCtx, plugins);
22
78
  program.exitOverride();
23
79
  program.configureOutput({
24
80
  writeOut: (text) => stdout.write(text),
25
81
  writeErr: (text) => stderr.write(text),
26
82
  });
27
83
  try {
28
- program.parse(argv, { from: "user" });
84
+ await program.parseAsync(argv, { from: "user" });
29
85
  return 0;
30
86
  }
31
87
  catch (error) {
32
88
  return report(error, stderr);
33
89
  }
34
90
  }
91
+ /**
92
+ * Resolve what plugins this invocation has, and say what is missing.
93
+ *
94
+ * Reading the declaration needs a repository, and plenty of commands work
95
+ * without one (`nav id`, `nav --help`, `nav init`). A context that cannot be
96
+ * built is therefore not an error here: it means there is no declaration to
97
+ * read, and whichever command runs next will complain about the missing
98
+ * repository in its own words if it needs one.
99
+ */
100
+ function loadPluginRuntime(getCtx, env, stderr) {
101
+ let resolved;
102
+ try {
103
+ resolved = resolvePlugins(getCtx(), env);
104
+ }
105
+ catch {
106
+ resolved = { active: [], missing: [], skipped: [], declaration: NO_DECLARATION };
107
+ }
108
+ const runtime = new PluginRuntime(resolved, BUILTIN_NOUNS);
109
+ // Said once per run, before anything is parsed, so the reason a command is
110
+ // missing is on screen above the complaint that it is missing.
111
+ for (const line of runtime.notices)
112
+ stderr.write(`${line}\n`);
113
+ for (const { name, reason } of resolved.skipped)
114
+ stderr.write(`${skippedLine(name, reason)}\n`);
115
+ for (const name of resolved.missing) {
116
+ stderr.write(`${missingLine(name, navDirOf(getCtx))}\n`);
117
+ }
118
+ // Said here rather than per command: whatever runs next, the reason `nav` is
119
+ // ignoring a directory belongs above its output, not buried in it.
120
+ try {
121
+ const ctx = getCtx();
122
+ if (ctx.hasNavbook) {
123
+ hintUndeclared(ctx, resolved.declaration, resolved.active.flatMap((plugin) => plugin.manifest.format?.root ?? []));
124
+ }
125
+ }
126
+ catch {
127
+ // No repository: there is no tree to have namespaces in.
128
+ }
129
+ return runtime;
130
+ }
131
+ function navDirOf(getCtx) {
132
+ try {
133
+ return getCtx().navDir;
134
+ }
135
+ catch {
136
+ return ".navbook";
137
+ }
138
+ }
35
139
  function report(error, stderr) {
36
140
  if (error instanceof CommanderError) {
37
141
  // Commander already wrote help or the version string.
@@ -93,6 +197,6 @@ function invokedDirectly() {
93
197
  if (invokedDirectly()) {
94
198
  exitQuietlyOnClosedPipe(process.stdout);
95
199
  exitQuietlyOnClosedPipe(process.stderr);
96
- process.exitCode = run();
200
+ process.exitCode = await run();
97
201
  }
98
202
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AACA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAY,WAAW,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAU5C,gFAAgF;AAChF,MAAM,UAAU,GAAG,CAAC,OAAmB,EAAE;IACvC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAE7C,IAAI,GAAG,GAAe,IAAI,CAAC;IAC3B,MAAM,MAAM,GAAG,GAAQ,EAAE;QACvB,GAAG,KAAK,WAAW,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAEF,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO,CAAC,YAAY,EAAE,CAAC;IACvB,OAAO,CAAC,eAAe,CAAC;QACtB,QAAQ,EAAE,CAAC,IAAI,EA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MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,eAAe,EAAE,EAAE,CAAC;IACtB,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,CAAC,QAAQ,GAAG,MAAM,GAAG,EAAE,CAAC;AACjC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Building Commander commands out of manifests — spec 04 §4.3.
3
+ *
4
+ * Every command a plugin adds is built from its declaration, with no plugin
5
+ * code loaded. That is what makes `nav --help` and shell completion work
6
+ * without paying for an import, and it is what the manifest's shapes exist to
7
+ * make possible. The plugin's own module is imported inside the action, the
8
+ * moment somebody actually runs the command.
9
+ *
10
+ * A name that collides with a built-in noun, or with one an earlier plugin
11
+ * took, is refused and the plugin skipped, because a word that means different
12
+ * things depending on load order is worse than one that means nothing.
13
+ */
14
+ import type { CommandSpec, OptionSpec, VerbContribution } from "@navbook/core";
15
+ import { Command } from "commander";
16
+ import type { Ctx } from "../context.ts";
17
+ import type { LoadedPlugin } from "./resolve.ts";
18
+ /** Everything the CLI needs to know about one plugin's declared commands. */
19
+ export interface PluginCommands {
20
+ /** Top-level nouns, by name, with the plugin that declared each. */
21
+ nouns: Map<string, {
22
+ plugin: LoadedPlugin;
23
+ spec: CommandSpec;
24
+ }>;
25
+ /** Contributions to existing verbs, keyed by the verb as typed. */
26
+ contributions: Map<string, {
27
+ plugin: LoadedPlugin;
28
+ spec: VerbContribution;
29
+ }[]>;
30
+ /** Plugins dropped for a collision, by name, so callers need not parse a message. */
31
+ skipped: Set<string>;
32
+ /** One line per plugin skipped, for stderr. */
33
+ problems: string[];
34
+ }
35
+ /**
36
+ * Sort out which plugin owns what, refusing collisions.
37
+ *
38
+ * `taken` is the built-in noun vocabulary. A plugin colliding with one of
39
+ * those loses outright; two plugins colliding with each other are resolved by
40
+ * which was resolved first, and the loser is named.
41
+ */
42
+ export declare function collectCommands(plugins: readonly LoadedPlugin[], taken: readonly string[]): PluginCommands;
43
+ /** How a plugin command's action is run once its module is loaded. */
44
+ export type RunCommand = (plugin: LoadedPlugin, path: string, args: string[], opts: Record<string, unknown>) => Promise<void>;
45
+ /** Build one plugin noun into a Commander command tree. */
46
+ export declare function buildPluginCommand(plugin: LoadedPlugin, spec: CommandSpec, getCtx: () => Ctx, run: RunCommand): Command;
47
+ /** Apply one declared option to a command. */
48
+ export declare function applyOption(command: Command, spec: OptionSpec): void;
49
+ /**
50
+ * Why a declared option cannot be applied, or null when it can.
51
+ *
52
+ * Two different rules, because two different namespaces are at stake.
53
+ *
54
+ * On a plugin's **own** command the plugin owns every flag, so a short one is
55
+ * its business: `nav feature open -m "…"` reads exactly as `nav issue open -m
56
+ * "…"` does, and denying it would make a plugin's commands feel like
57
+ * second-class ones for no gain.
58
+ *
59
+ * On a **contribution** to a built-in verb the namespace is shared, and short
60
+ * flags are the scarce part of it — `-m`, `-y`, `-n` already mean things
61
+ * across the whole CLI. A plugin taking one there would be discovered by
62
+ * whoever installed two plugins rather than by whoever wrote the second, so
63
+ * they are refused outright rather than raced for.
64
+ *
65
+ * A long flag that is already taken is refused either way, and checked before
66
+ * Commander sees it: `.option()` throws on a duplicate, which would take the
67
+ * whole CLI down over one plugin's manifest.
68
+ */
69
+ export declare function optionCollision(command: Command, spec: OptionSpec, where?: "own" | "contribution"): string | null;
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Building Commander commands out of manifests — spec 04 §4.3.
3
+ *
4
+ * Every command a plugin adds is built from its declaration, with no plugin
5
+ * code loaded. That is what makes `nav --help` and shell completion work
6
+ * without paying for an import, and it is what the manifest's shapes exist to
7
+ * make possible. The plugin's own module is imported inside the action, the
8
+ * moment somebody actually runs the command.
9
+ *
10
+ * A name that collides with a built-in noun, or with one an earlier plugin
11
+ * took, is refused and the plugin skipped, because a word that means different
12
+ * things depending on load order is worse than one that means nothing.
13
+ */
14
+ import { Command, Option } from "commander";
15
+ import { finiteNumber, wholeNumber } from "../args.js";
16
+ /**
17
+ * Sort out which plugin owns what, refusing collisions.
18
+ *
19
+ * `taken` is the built-in noun vocabulary. A plugin colliding with one of
20
+ * those loses outright; two plugins colliding with each other are resolved by
21
+ * which was resolved first, and the loser is named.
22
+ */
23
+ export function collectCommands(plugins, taken) {
24
+ const nouns = new Map();
25
+ const contributions = new Map();
26
+ const skipped = new Set();
27
+ const problems = [];
28
+ const builtin = new Set(taken);
29
+ for (const plugin of plugins) {
30
+ const declared = plugin.manifest.cli;
31
+ if (declared === undefined)
32
+ continue;
33
+ const clash = (declared.commands ?? []).find((spec) => builtin.has(spec.name) || nouns.has(spec.name));
34
+ if (clash !== undefined) {
35
+ const owner = builtin.has(clash.name)
36
+ ? "a built-in command"
37
+ : `plugin ${nouns.get(clash.name)?.plugin.name}`;
38
+ problems.push(`nav: plugin ${plugin.name} skipped: '${clash.name}' is already ${owner} (spec 04 §4.3)`);
39
+ skipped.add(plugin.name);
40
+ continue;
41
+ }
42
+ for (const spec of declared.commands ?? [])
43
+ nouns.set(spec.name, { plugin, spec });
44
+ for (const spec of declared.contributions ?? []) {
45
+ const existing = contributions.get(spec.on) ?? [];
46
+ existing.push({ plugin, spec });
47
+ contributions.set(spec.on, existing);
48
+ }
49
+ }
50
+ return { nouns, contributions, skipped, problems };
51
+ }
52
+ /** Build one plugin noun into a Commander command tree. */
53
+ export function buildPluginCommand(plugin, spec, getCtx, run) {
54
+ return buildCommand(plugin, spec, spec.name, getCtx, run);
55
+ }
56
+ function buildCommand(plugin, spec, path, getCtx, run) {
57
+ const command = new Command(spec.name).description(spec.description);
58
+ // A group — a noun with verbs under it — has no action of its own, and
59
+ // Commander's implicit `help` verb is dropped for the reason the built-in
60
+ // nouns drop it: it prints exactly what `--help` prints.
61
+ if (spec.commands?.length) {
62
+ command.helpCommand(false);
63
+ for (const child of spec.commands) {
64
+ command.addCommand(buildCommand(plugin, child, `${path} ${child.name}`, getCtx, run));
65
+ }
66
+ return command;
67
+ }
68
+ for (const argument of spec.arguments ?? [])
69
+ command.argument(...argumentOf(argument));
70
+ for (const option of spec.options ?? [])
71
+ applyOption(command, option);
72
+ command.action(async (...received) => {
73
+ // Commander hands the action its positional arguments, then the parsed
74
+ // options, then the command itself. The declared arguments say how many
75
+ // positionals there are, so the split needs no guessing.
76
+ const count = spec.arguments?.length ?? 0;
77
+ const args = received.slice(0, count);
78
+ const opts = (received[count] ?? {});
79
+ // Touch the context before loading the plugin: a command run outside a
80
+ // repository should say so in the CLI's own words rather than in whatever
81
+ // the plugin says when it finds no tree.
82
+ getCtx();
83
+ await run(plugin, path, args, opts);
84
+ });
85
+ return command;
86
+ }
87
+ /** A declared argument, in the `[name]` / `<name...>` shape Commander parses. */
88
+ function argumentOf(spec) {
89
+ const dots = spec.variadic === true ? "..." : "";
90
+ const name = spec.optional === true ? `[${spec.name}${dots}]` : `<${spec.name}${dots}>`;
91
+ return [name, spec.description ?? ""];
92
+ }
93
+ /** Apply one declared option to a command. */
94
+ export function applyOption(command, spec) {
95
+ const option = new Option(spec.flags, spec.description);
96
+ if (spec.repeatable === true) {
97
+ option.argParser((value, previous = []) => [...previous, value]);
98
+ option.default([]);
99
+ }
100
+ else if (spec.parse === "int") {
101
+ // The parsers the built-in options use, so a plugin's count is refused
102
+ // where the built-in ones are: `parseInt` read `2.5` as 2 and `3abc` as 3,
103
+ // and `Number` reads `0x10` and `1e1` and rounds past 2^53 (#kw143sq9).
104
+ option.argParser(wholeNumber(null));
105
+ }
106
+ else if (spec.parse === "number") {
107
+ option.argParser(finiteNumber);
108
+ }
109
+ if (spec.default !== undefined)
110
+ option.default(spec.default);
111
+ command.addOption(option);
112
+ }
113
+ /**
114
+ * Why a declared option cannot be applied, or null when it can.
115
+ *
116
+ * Two different rules, because two different namespaces are at stake.
117
+ *
118
+ * On a plugin's **own** command the plugin owns every flag, so a short one is
119
+ * its business: `nav feature open -m "…"` reads exactly as `nav issue open -m
120
+ * "…"` does, and denying it would make a plugin's commands feel like
121
+ * second-class ones for no gain.
122
+ *
123
+ * On a **contribution** to a built-in verb the namespace is shared, and short
124
+ * flags are the scarce part of it — `-m`, `-y`, `-n` already mean things
125
+ * across the whole CLI. A plugin taking one there would be discovered by
126
+ * whoever installed two plugins rather than by whoever wrote the second, so
127
+ * they are refused outright rather than raced for.
128
+ *
129
+ * A long flag that is already taken is refused either way, and checked before
130
+ * Commander sees it: `.option()` throws on a duplicate, which would take the
131
+ * whole CLI down over one plugin's manifest.
132
+ */
133
+ export function optionCollision(command, spec, where = "contribution") {
134
+ const flags = spec.flags.split(/[ ,|]+/).filter((part) => part.startsWith("-"));
135
+ if (where === "contribution") {
136
+ const short = flags.find((flag) => /^-[^-]/.test(flag));
137
+ if (short !== undefined) {
138
+ return `'${short}' is a short flag, which a plugin may not add to a built-in verb`;
139
+ }
140
+ }
141
+ for (const flag of flags) {
142
+ if (command.options.some((existing) => existing.long === flag || existing.short === flag)) {
143
+ return `'${flag}' is already an option of '${command.name()}'`;
144
+ }
145
+ }
146
+ return null;
147
+ }
148
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/plugins/commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgBvD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAgC,EAChC,KAAwB;IAExB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuD,CAAC;IAC7E,MAAM,aAAa,GAAG,IAAI,GAAG,EAA8D,CAAC;IAC5F,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;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AC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,EAAE,CAAC;YAC1F,OAAO,IAAI,IAAI,8BAA8B,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Saying that a tree holds data this `nav` cannot read.
3
+ *
4
+ * Spec 02 §2.12 requires a tool to preserve an extension namespace it does not
5
+ * understand, and allows it to say the namespace is undeclared. Saying so is
6
+ * the whole value of the declaration to somebody who has just cloned: the
7
+ * files are there, `nav` is ignoring them, and nothing else on screen would
8
+ * explain why.
9
+ *
10
+ * One line, on stderr, and never an error. The tree is conforming; this `nav`
11
+ * simply has less of it than the repository expects.
12
+ */
13
+ import type { PluginDeclarationReading } from "@navbook/core";
14
+ import type { Ctx } from "../context.ts";
15
+ /**
16
+ * Say once that the tree holds namespaces nothing here reads.
17
+ *
18
+ * `loaded` is the directories a plugin claimed, which are read rather than
19
+ * ignored and so are not worth a word. `declaration` is what the marker says:
20
+ * a namespace whose plugin is declared but missing has already been reported
21
+ * by name, and saying it twice helps nobody.
22
+ */
23
+ export declare function hintUndeclared(ctx: Ctx, declaration: PluginDeclarationReading, loaded: readonly string[]): void;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Saying that a tree holds data this `nav` cannot read.
3
+ *
4
+ * Spec 02 §2.12 requires a tool to preserve an extension namespace it does not
5
+ * understand, and allows it to say the namespace is undeclared. Saying so is
6
+ * the whole value of the declaration to somebody who has just cloned: the
7
+ * files are there, `nav` is ignoring them, and nothing else on screen would
8
+ * explain why.
9
+ *
10
+ * One line, on stderr, and never an error. The tree is conforming; this `nav`
11
+ * simply has less of it than the repository expects.
12
+ */
13
+ import { readdirSync } from "node:fs";
14
+ /** Names this format defines at the top of the root; never a namespace. */
15
+ const FORMAT_NAMES = new Set(["issues", "prs", "archive", "sync", "navbook.json"]);
16
+ /**
17
+ * Namespaces this project knows the plugin for, so the hint can name it.
18
+ *
19
+ * Only the grandfathered pair is listed, and deliberately: a namespace whose
20
+ * plugin nobody here knows about gets the generic line below, which is the
21
+ * honest thing to say about a directory some other project's plugin wrote.
22
+ */
23
+ const KNOWN = {
24
+ specs: "@navbook/plugin-kb",
25
+ };
26
+ /**
27
+ * Directories at the top of the root that this format does not define.
28
+ *
29
+ * One `readdir` rather than a parse of the tree: the caller has usually just
30
+ * read the whole repository, and reading it a second time to find out what the
31
+ * first read ignored would cost more than the hint is worth.
32
+ */
33
+ function namespaceDirs(navRoot) {
34
+ try {
35
+ return readdirSync(navRoot, { withFileTypes: true })
36
+ .filter((entry) => entry.isDirectory() && !FORMAT_NAMES.has(entry.name))
37
+ .map((entry) => entry.name)
38
+ .sort();
39
+ }
40
+ catch {
41
+ return [];
42
+ }
43
+ }
44
+ /**
45
+ * Say once that the tree holds namespaces nothing here reads.
46
+ *
47
+ * `loaded` is the directories a plugin claimed, which are read rather than
48
+ * ignored and so are not worth a word. `declaration` is what the marker says:
49
+ * a namespace whose plugin is declared but missing has already been reported
50
+ * by name, and saying it twice helps nobody.
51
+ */
52
+ export function hintUndeclared(ctx, declaration, loaded) {
53
+ const claimed = new Set(loaded);
54
+ for (const name of namespaceDirs(ctx.navRoot)) {
55
+ if (claimed.has(name))
56
+ continue;
57
+ const plugin = KNOWN[name];
58
+ if (plugin !== undefined && declaration.plugins.has(plugin))
59
+ continue;
60
+ ctx.stderr.write(plugin === undefined
61
+ ? `nav: ${ctx.navDir}/${name}/ is not a shape this nav reads; it is preserved untouched (spec 02 §2.12)\n`
62
+ : `nav: ${ctx.navDir}/${name}/ belongs to ${plugin}, which ${ctx.navDir}/navbook.json does not declare; add it and run 'nav plugin install'\n`);
63
+ }
64
+ }
65
+ //# sourceMappingURL=hint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hint.js","sourceR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