@inventarch/cli 3.5.1 → 3.6.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 (203) hide show
  1. package/NOTICE +2 -0
  2. package/README.md +2 -1
  3. package/SPEC.md +13 -4
  4. package/THIRD_PARTY_NOTICES.txt +49 -0
  5. package/assets/host/44dc1fa77e0235df35e1dd05d5a5ce8c2b19d4545caf0b8579f2f4e1b9efbbc6.tgz +0 -0
  6. package/assets/host.json +4 -4
  7. package/dist/args.d.ts +9 -0
  8. package/dist/args.d.ts.map +1 -1
  9. package/dist/args.js.map +1 -1
  10. package/dist/bin.d.ts +3 -0
  11. package/dist/bin.d.ts.map +1 -0
  12. package/dist/bin.js +53 -0
  13. package/dist/bin.js.map +1 -0
  14. package/dist/claude-cli.d.ts +13 -1
  15. package/dist/claude-cli.d.ts.map +1 -1
  16. package/dist/claude-cli.js +31 -1
  17. package/dist/claude-cli.js.map +1 -1
  18. package/dist/commands.d.ts +17 -0
  19. package/dist/commands.d.ts.map +1 -1
  20. package/dist/commands.js +66 -3
  21. package/dist/commands.js.map +1 -1
  22. package/dist/committed-host.d.ts.map +1 -1
  23. package/dist/committed-host.js +14 -2
  24. package/dist/committed-host.js.map +1 -1
  25. package/dist/console/app.d.ts +47 -0
  26. package/dist/console/app.d.ts.map +1 -0
  27. package/dist/console/app.js +921 -0
  28. package/dist/console/app.js.map +1 -0
  29. package/dist/console/batch-next.d.ts +54 -0
  30. package/dist/console/batch-next.d.ts.map +1 -0
  31. package/dist/console/batch-next.js +260 -0
  32. package/dist/console/batch-next.js.map +1 -0
  33. package/dist/console/batch-plan.d.ts +109 -0
  34. package/dist/console/batch-plan.d.ts.map +1 -0
  35. package/dist/console/batch-plan.js +308 -0
  36. package/dist/console/batch-plan.js.map +1 -0
  37. package/dist/console/batch-run.d.ts +195 -0
  38. package/dist/console/batch-run.d.ts.map +1 -0
  39. package/dist/console/batch-run.js +868 -0
  40. package/dist/console/batch-run.js.map +1 -0
  41. package/dist/console/batch-screen.d.ts +36 -0
  42. package/dist/console/batch-screen.d.ts.map +1 -0
  43. package/dist/console/batch-screen.js +113 -0
  44. package/dist/console/batch-screen.js.map +1 -0
  45. package/dist/console/grid.d.ts +30 -0
  46. package/dist/console/grid.d.ts.map +1 -0
  47. package/dist/console/grid.js +87 -0
  48. package/dist/console/grid.js.map +1 -0
  49. package/dist/console/keys.d.ts +54 -0
  50. package/dist/console/keys.d.ts.map +1 -0
  51. package/dist/console/keys.js +204 -0
  52. package/dist/console/keys.js.map +1 -0
  53. package/dist/console/layout-all.d.ts +70 -0
  54. package/dist/console/layout-all.d.ts.map +1 -0
  55. package/dist/console/layout-all.js +401 -0
  56. package/dist/console/layout-all.js.map +1 -0
  57. package/dist/console/layout-repo.d.ts +65 -0
  58. package/dist/console/layout-repo.d.ts.map +1 -0
  59. package/dist/console/layout-repo.js +275 -0
  60. package/dist/console/layout-repo.js.map +1 -0
  61. package/dist/console/load.d.ts +33 -0
  62. package/dist/console/load.d.ts.map +1 -0
  63. package/dist/console/load.js +166 -0
  64. package/dist/console/load.js.map +1 -0
  65. package/dist/console/offers.d.ts +39 -0
  66. package/dist/console/offers.d.ts.map +1 -0
  67. package/dist/console/offers.js +285 -0
  68. package/dist/console/offers.js.map +1 -0
  69. package/dist/console/run.d.ts +56 -0
  70. package/dist/console/run.d.ts.map +1 -0
  71. package/dist/console/run.js +210 -0
  72. package/dist/console/run.js.map +1 -0
  73. package/dist/console/state.d.ts +127 -0
  74. package/dist/console/state.d.ts.map +1 -0
  75. package/dist/console/state.js +273 -0
  76. package/dist/console/state.js.map +1 -0
  77. package/dist/console/terminal.d.ts +60 -0
  78. package/dist/console/terminal.d.ts.map +1 -0
  79. package/dist/console/terminal.js +114 -0
  80. package/dist/console/terminal.js.map +1 -0
  81. package/dist/console/width-table.d.ts +10 -0
  82. package/dist/console/width-table.d.ts.map +1 -0
  83. package/dist/console/width-table.js +753 -0
  84. package/dist/console/width-table.js.map +1 -0
  85. package/dist/console/width.d.ts +18 -0
  86. package/dist/console/width.d.ts.map +1 -0
  87. package/dist/console/width.js +114 -0
  88. package/dist/console/width.js.map +1 -0
  89. package/dist/console/workspaces-state.d.ts +93 -0
  90. package/dist/console/workspaces-state.d.ts.map +1 -0
  91. package/dist/console/workspaces-state.js +192 -0
  92. package/dist/console/workspaces-state.js.map +1 -0
  93. package/dist/consumer.d.ts +13 -8
  94. package/dist/consumer.d.ts.map +1 -1
  95. package/dist/consumer.js +22 -34
  96. package/dist/consumer.js.map +1 -1
  97. package/dist/discovery.d.ts +8 -0
  98. package/dist/discovery.d.ts.map +1 -0
  99. package/dist/discovery.js +36 -0
  100. package/dist/discovery.js.map +1 -0
  101. package/dist/distribute.d.ts +9 -0
  102. package/dist/distribute.d.ts.map +1 -1
  103. package/dist/distribute.js +70 -13
  104. package/dist/distribute.js.map +1 -1
  105. package/dist/doctor-authority.d.ts.map +1 -1
  106. package/dist/doctor-authority.js +7 -4
  107. package/dist/doctor-authority.js.map +1 -1
  108. package/dist/doctor-extensions.d.ts +36 -0
  109. package/dist/doctor-extensions.d.ts.map +1 -0
  110. package/dist/doctor-extensions.js +118 -0
  111. package/dist/doctor-extensions.js.map +1 -0
  112. package/dist/doctor-mounts.d.ts.map +1 -1
  113. package/dist/doctor-mounts.js +3 -2
  114. package/dist/doctor-mounts.js.map +1 -1
  115. package/dist/doctor-user.d.ts +64 -0
  116. package/dist/doctor-user.d.ts.map +1 -1
  117. package/dist/doctor-user.js +309 -34
  118. package/dist/doctor-user.js.map +1 -1
  119. package/dist/doctor.d.ts +22 -1
  120. package/dist/doctor.d.ts.map +1 -1
  121. package/dist/doctor.js +81 -32
  122. package/dist/doctor.js.map +1 -1
  123. package/dist/fix.d.ts +67 -0
  124. package/dist/fix.d.ts.map +1 -0
  125. package/dist/fix.js +136 -0
  126. package/dist/fix.js.map +1 -0
  127. package/dist/handoff.d.ts +65 -0
  128. package/dist/handoff.d.ts.map +1 -0
  129. package/dist/handoff.js +264 -0
  130. package/dist/handoff.js.map +1 -0
  131. package/dist/host-projection.d.ts.map +1 -1
  132. package/dist/host-projection.js +1 -8
  133. package/dist/host-projection.js.map +1 -1
  134. package/dist/host.d.ts +9 -3
  135. package/dist/host.d.ts.map +1 -1
  136. package/dist/host.js +23 -7
  137. package/dist/host.js.map +1 -1
  138. package/dist/init.d.ts +4 -6
  139. package/dist/init.d.ts.map +1 -1
  140. package/dist/init.js +80 -9
  141. package/dist/init.js.map +1 -1
  142. package/dist/local-cli.d.ts +67 -0
  143. package/dist/local-cli.d.ts.map +1 -0
  144. package/dist/local-cli.js +269 -0
  145. package/dist/local-cli.js.map +1 -0
  146. package/dist/main.d.ts +47 -3
  147. package/dist/main.d.ts.map +1 -1
  148. package/dist/main.js +121 -26
  149. package/dist/main.js.map +1 -1
  150. package/dist/marketplace-record.d.ts +7 -1
  151. package/dist/marketplace-record.d.ts.map +1 -1
  152. package/dist/marketplace-record.js +6 -3
  153. package/dist/marketplace-record.js.map +1 -1
  154. package/dist/package-manager.d.ts +43 -0
  155. package/dist/package-manager.d.ts.map +1 -0
  156. package/dist/package-manager.js +164 -0
  157. package/dist/package-manager.js.map +1 -0
  158. package/dist/position.d.ts.map +1 -1
  159. package/dist/position.js +16 -2
  160. package/dist/position.js.map +1 -1
  161. package/dist/preview.d.ts.map +1 -1
  162. package/dist/preview.js +11 -3
  163. package/dist/preview.js.map +1 -1
  164. package/dist/profile.d.ts +1 -1
  165. package/dist/profile.d.ts.map +1 -1
  166. package/dist/profile.js +3 -4
  167. package/dist/profile.js.map +1 -1
  168. package/dist/program.d.ts +10 -0
  169. package/dist/program.d.ts.map +1 -1
  170. package/dist/program.js +38 -1
  171. package/dist/program.js.map +1 -1
  172. package/dist/project.js +2 -2
  173. package/dist/project.js.map +1 -1
  174. package/dist/render.d.ts +7 -2
  175. package/dist/render.d.ts.map +1 -1
  176. package/dist/render.js +42 -3
  177. package/dist/render.js.map +1 -1
  178. package/dist/self.d.ts +6 -0
  179. package/dist/self.d.ts.map +1 -0
  180. package/dist/self.js +20 -0
  181. package/dist/self.js.map +1 -0
  182. package/dist/tracked-lock.d.ts +15 -0
  183. package/dist/tracked-lock.d.ts.map +1 -0
  184. package/dist/tracked-lock.js +37 -0
  185. package/dist/tracked-lock.js.map +1 -0
  186. package/dist/tracked.d.ts +125 -0
  187. package/dist/tracked.d.ts.map +1 -0
  188. package/dist/tracked.js +436 -0
  189. package/dist/tracked.js.map +1 -0
  190. package/dist/user-host.d.ts +7 -3
  191. package/dist/user-host.d.ts.map +1 -1
  192. package/dist/user-host.js +24 -11
  193. package/dist/user-host.js.map +1 -1
  194. package/dist/workspace-state.d.ts +15 -0
  195. package/dist/workspace-state.d.ts.map +1 -0
  196. package/dist/workspace-state.js +35 -0
  197. package/dist/workspace-state.js.map +1 -0
  198. package/dist/workspaces.d.ts +37 -0
  199. package/dist/workspaces.d.ts.map +1 -0
  200. package/dist/workspaces.js +319 -0
  201. package/dist/workspaces.js.map +1 -0
  202. package/package.json +9 -8
  203. package/assets/host/e594fd978a0f8a9f042bf40ab124779067e1c88e4a72b7ce57261ca0e48a984c.tgz +0 -0
package/dist/fix.js ADDED
@@ -0,0 +1,136 @@
1
+ import { parseArguments } from './args.js';
2
+ import { COMMANDS, ownedOptions } from './commands.js';
3
+ import { quote } from './render.js';
4
+ /**
5
+ * The grammar of one action of `spec`: the command's options minus every option another action owns. A command with
6
+ * no actions has one grammar, whatever its positionals; an action the command does not declare has none (`null`).
7
+ */
8
+ export function actionGrammar(spec, action) {
9
+ if (spec.actions === undefined)
10
+ return spec.grammar;
11
+ if (action === undefined || !Object.hasOwn(spec.actions, action))
12
+ return null;
13
+ const owned = ownedOptions(spec);
14
+ return {
15
+ ...spec.grammar,
16
+ options: spec.grammar.options.filter((option) => (owned[option.name] ?? action) === action),
17
+ };
18
+ }
19
+ /** The form parsed under its action's grammar; `null` for an unknown command, an unknown action or a usage error. */
20
+ function parse(argv, commands) {
21
+ const [name, ...rest] = argv;
22
+ const spec = commands.find((command) => command.name === name);
23
+ if (spec === undefined)
24
+ return null;
25
+ try {
26
+ // The action is the first positional, read under the command's whole grammar; the form is then parsed again
27
+ // under that action's own, so an option another action owns refuses here as it does at run time.
28
+ const action = spec.actions === undefined ? undefined : parseArguments(rest, spec.grammar).positionals[0];
29
+ const grammar = actionGrammar(spec, action);
30
+ if (grammar === null)
31
+ return null;
32
+ return { spec, grammar, action, args: parseArguments(rest, grammar) };
33
+ }
34
+ catch {
35
+ return null;
36
+ }
37
+ }
38
+ const present = (args, name) => args.flag(name) || args.value(name) !== undefined;
39
+ /**
40
+ * The flow rules over the parsed form (consumer CLI contract §2.12); the first that holds decides:
41
+ * 1. an option given in the form conflicts with `apply` → confirm;
42
+ * 2. the grammar requires `apply` → confirm;
43
+ * 3. the grammar offers an optional `apply` → preview-apply;
44
+ * 4. the grammar offers `preview` → preview-flag;
45
+ * 5. the action's, then the command's, declared flow;
46
+ * 6. a catalog mode of read or validate → immediate;
47
+ * 7. otherwise none.
48
+ */
49
+ export function deriveFlow(argv, commands = COMMANDS) {
50
+ const parsed = parse(argv, commands);
51
+ if (parsed === null)
52
+ return null;
53
+ const { spec, grammar, action, args } = parsed;
54
+ const apply = grammar.options.find((option) => option.name === 'apply');
55
+ const conflictsWithApply = grammar.options.some((option) => option.name !== 'apply' &&
56
+ present(args, option.name) &&
57
+ ((option.conflicts ?? []).includes('apply') || (apply?.conflicts ?? []).includes(option.name)));
58
+ if (conflictsWithApply)
59
+ return 'confirm';
60
+ if (apply?.required === true)
61
+ return 'confirm';
62
+ if (apply !== undefined)
63
+ return 'preview-apply';
64
+ if (grammar.options.some((option) => option.name === 'preview'))
65
+ return 'preview-flag';
66
+ const declared = (action === undefined ? undefined : spec.actions?.[action]?.flow) ?? spec.flow;
67
+ if (declared !== undefined)
68
+ return declared;
69
+ if (spec.catalog?.mode === 'read' || spec.catalog?.mode === 'validate')
70
+ return 'immediate';
71
+ return null;
72
+ }
73
+ const join = (argv) => argv.map(quote).join(' ');
74
+ /** The text a fix shows: `ia` and its quoted argv, or the quoted external argv. */
75
+ export const displayFix = (fix) => (fix.program === 'ia' ? `ia ${join(fix.argv)}` : join(fix.argv));
76
+ /**
77
+ * The remedy and fix of one `ia` command. `--root <root>` is appended only when the command requires a root and the
78
+ * form lacks one; the remedy is then that same argv displayed, so the two never differ. A form no flow derives for
79
+ * keeps its remedy and has no fix.
80
+ */
81
+ export function iaFix(argv, writesTo, root) {
82
+ const spec = COMMANDS.find((command) => command.name === argv[0]);
83
+ const needsRoot = root !== undefined &&
84
+ spec?.grammar.options.some((option) => option.name === 'root' && option.required === true) === true &&
85
+ !argv.slice(1).some((token) => token === '--root' || token.startsWith('--root='));
86
+ const full = needsRoot ? [...argv, '--root', root] : [...argv];
87
+ const flow = deriveFlow(full);
88
+ const remedy = `ia ${join(full)}`;
89
+ return { remedy, fix: flow === null ? null : { program: 'ia', argv: full, flow, writesTo } };
90
+ }
91
+ /** An external program's remedy and fix: always confirmed, since the console cannot preview another program. */
92
+ export function externalFix(argv, writesTo) {
93
+ const fix = { program: 'external', argv: [...argv], flow: 'confirm', writesTo };
94
+ return { remedy: displayFix(fix), fix };
95
+ }
96
+ const APPLY = '--apply', YES = ['--yes', '-y'];
97
+ /**
98
+ * The form the console runs before its confirmation: a preview-apply form without `--apply` and `--yes`, a
99
+ * preview-flag form with `--preview`; `null` for a flow that has no preview.
100
+ */
101
+ export function previewArgv(fix) {
102
+ if (fix.program !== 'ia')
103
+ return null;
104
+ if (fix.flow === 'preview-apply')
105
+ return fix.argv.filter((token) => token !== APPLY && !YES.includes(token));
106
+ if (fix.flow === 'preview-flag')
107
+ return fix.argv.includes('--preview') ? [...fix.argv] : [...fix.argv, '--preview'];
108
+ return null;
109
+ }
110
+ /**
111
+ * The form the console runs after its own confirmation. A form that applies (a preview-apply one, or one that holds
112
+ * `--apply`, as a required apply does) gains `--apply` when it is preview-apply and lacks it, and `--yes` when the
113
+ * grammar has one and the form lacks it: with piped stdio the child refuses `--apply` without `--yes`, and with
114
+ * inherited stdio it would ask a second time. Every other form, and every external one, is returned unchanged.
115
+ */
116
+ export function confirmedArgv(fix) {
117
+ if (fix.program !== 'ia')
118
+ return fix.argv;
119
+ // An extension's own command has no core grammar to read: its declared flow decides, and a preview-apply form
120
+ // applies with `--apply`, added once. `--yes` is not added, since the extension's grammar may not take it.
121
+ if (!COMMANDS.some((command) => command.name === fix.argv[0]))
122
+ return fix.flow === 'preview-apply' && !fix.argv.includes(APPLY) ? [...fix.argv, APPLY] : fix.argv;
123
+ const parsed = parse(fix.argv, COMMANDS);
124
+ if (parsed === null)
125
+ return fix.argv;
126
+ const applies = fix.flow === 'preview-apply' || parsed.args.flag('apply');
127
+ if (!applies)
128
+ return fix.argv;
129
+ const out = [...fix.argv];
130
+ if (fix.flow === 'preview-apply' && !parsed.args.flag('apply'))
131
+ out.push(APPLY);
132
+ if (parsed.grammar.options.some((option) => option.name === 'yes') && !parsed.args.flag('yes'))
133
+ out.push('--yes');
134
+ return out;
135
+ }
136
+ //# sourceMappingURL=fix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fix.js","sourceRoot":"","sources":["../src/fix.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAiBpC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAiB,EAAE,MAA0B;IACzE,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC;IACpD,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9E,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACjC,OAAO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G,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChF,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAClH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,65 @@
1
+ import type { LocalCli } from './local-cli.js';
2
+ /** Set only by the copy that hands off, to its package root's real path; any non-empty value stops a second hand-off. */
3
+ export declare const HANDOFF_FROM = "IA_HANDOFF_FROM";
4
+ /** `1` turns hand-off off: this copy answers. */
5
+ export declare const NO_HANDOFF = "IA_NO_HANDOFF";
6
+ /** git ran and exited non-zero: no answer about the copy (a bad config, an unsafe directory, a locked index, or no repository). */
7
+ export declare const EXITED = "exited";
8
+ /** `true` or `false` when git answered, `EXITED` when it ran and failed, `null` when it timed out, was killed or was not found. */
9
+ export type GitAnswer = boolean | typeof EXITED | null;
10
+ /**
11
+ * Whether the installed copy at `packageRoot` is the repository's: git tracks a file of it, or git could not say and a
12
+ * `.git` exists at or above it. A copy committed to the repository is the repository's code, not an install the user
13
+ * ran, so a typed command never runs it. Asked only when a hand-off is about to happen. When git exits non-zero, is
14
+ * stopped by its timeout or cannot be started, the answer is the work tree's: inside one the copy is refused, so a git
15
+ * that cannot answer never lets a repository's copy run. Only without git and without any `.git` above, or outside
16
+ * every repository (git answers non-zero and no `.git` is above), is nothing tracked.
17
+ */
18
+ export declare function committed(packageRoot: string): boolean;
19
+ /**
20
+ * `committed`, remembered per copy for as long as the returned function lives. The console makes one for its life, so
21
+ * the synchronous git call (2 s timeout) is made once per copy rather than at every load and every step. An answer is
22
+ * kept only with the disk state it was given for (`copyState`: a few `stat` calls per ask): once the copy is replaced at
23
+ * its path or the repository's index changes, git is asked again, so a committed copy never runs on an answer about
24
+ * another copy or an older index. Only an answer git gave (an exit of 0) is remembered: a question it could not answer
25
+ * (a non-zero exit, a timeout, a kill, or no git on the path) reads as `committed` reads it this time, from the work
26
+ * tree, and is asked again next time. One exception: a non-zero exit for a copy with no `.git` at or above it is
27
+ * remembered as not committed, since git exits that way outside every repository, nothing there can be tracked, and a
28
+ * repository appearing changes the state. Nothing is remembered while a GIT_ variable chooses the repository. The memo only
29
+ * saves asking; which copy runs is still decided from the disk each time (`runnableCopy`).
30
+ */
31
+ export declare function rememberCommitted(ask?: (packageRoot: string) => GitAnswer, env?: Readonly<Record<string, string | undefined>>): (packageRoot: string) => boolean;
32
+ /** The first `--root` before `--`, when it names a workspace; without one, the workspace discovered from `cwd`. */
33
+ export declare function rootFromArgv(argv: readonly string[], cwd: string, iaHome: string | undefined): string | undefined;
34
+ /**
35
+ * The workspace's installed copy an `ia` may run for the workspace at `root`, or `null` (consumer-cli-contract §1.2):
36
+ * the copy resolveWorkspaceCli finds, up to the workspaces root that hoists it. A copy other than `running` is refused
37
+ * when the user set `IA_NO_HANDOFF=1` or the repository commits it, so neither a typed command (handoffTarget) nor the
38
+ * console (console/load.ts, console/app.ts) ever runs the repository's own code. The running copy is returned as found,
39
+ * since running it runs nothing new; git is asked only about another copy, and a git that cannot answer inside a work
40
+ * tree refuses the copy (committed).
41
+ */
42
+ export declare function runnableCopy(root: string, input: {
43
+ readonly env: Readonly<Record<string, string | undefined>>;
44
+ /** The running copy's package root. */
45
+ readonly running: string;
46
+ readonly committed?: (packageRoot: string) => boolean;
47
+ }): LocalCli | null;
48
+ /**
49
+ * The workspace's installed copy when it is not this one, or `null`. Bare `ia`, `--user`, an extension's commands and
50
+ * `doctor --host` always answer here, as does a malformed IA home (`iaHome` undefined), which this copy refuses. As in
51
+ * dispatch (consumer.ts), an extension never takes a core token: such a token is the core command's, and hands off.
52
+ */
53
+ export declare function handoffTarget(input: {
54
+ readonly argv: readonly string[];
55
+ readonly cwd: string;
56
+ readonly env: Readonly<Record<string, string | undefined>>;
57
+ readonly packageRoot: string;
58
+ readonly iaHome: string | undefined;
59
+ readonly extensions: readonly string[];
60
+ readonly coreTokens: ReadonlySet<string>;
61
+ readonly committed?: (packageRoot: string) => boolean;
62
+ }): LocalCli | null;
63
+ /** Runs the target with inherited stdio and returns its exit code; throws when it cannot be started. */
64
+ export declare function handOff(target: LocalCli, argv: readonly string[], env: NodeJS.ProcessEnv, from: string): number;
65
+ //# sourceMappingURL=handoff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C,yHAAyH;AACzH,eAAO,MAAM,YAAY,oBAAoB,CAAC;AAC9C,iDAAiD;AACjD,eAAO,MAAM,UAAU,kBAAkB,CAAC;AA2B1C,mIAAmI;AACnI,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,mIAAmI;AACnI,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,MAAM,GAAG,IAAI,CAAC;AAuBvD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAGtD;AAqDD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,GAAE,CAAC,WAAW,EAAE,MAAM,KAAK,SAAkB,EAChD,GAAG,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAe,GAC9D,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAoBlC;AAGD,mHAAmH;AACnH,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAejH;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE;IACL,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;CACvD,GACA,QAAQ,GAAG,IAAI,CAKjB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE;IACnC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC;CACvD,GAAG,QAAQ,GAAG,IAAI,CAmBlB;AAeD,wGAAwG;AACxG,wBAAgB,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAa/G"}
@@ -0,0 +1,264 @@
1
+ /**
2
+ * consumer-cli-contract §1.2's first step: a command typed into another `ia` runs on the `@inventarch/cli` the
3
+ * workspace pins and has installed. Deciding reads only directories, `package.json` files and a `pnpm-workspace.yaml`, and asks git once whether
4
+ * the copy is committed; nothing is parsed yet, so an argument the workspace's copy accepts and this copy does not still
5
+ * reaches it. The tokens are not parsed either: a value spelled like `--user` or `--root` (`--search --user`) routes as
6
+ * the flag, and this copy answers, as it does for any typed command it cannot place.
7
+ */
8
+ import { spawnSync } from 'node:child_process';
9
+ import { existsSync, readFileSync, realpathSync, statSync } from 'node:fs';
10
+ import { dirname, join, resolve } from 'node:path';
11
+ import { sameFile } from '@inventarch/db/internal/paths';
12
+ import { discoverRoot } from './discovery.js';
13
+ import { resolveWorkspaceCli } from './local-cli.js';
14
+ import { findProgram, programEnv, programHome, withoutGitRouting } from './program.js';
15
+ /** Set only by the copy that hands off, to its package root's real path; any non-empty value stops a second hand-off. */
16
+ export const HANDOFF_FROM = 'IA_HANDOFF_FROM';
17
+ /** `1` turns hand-off off: this copy answers. */
18
+ export const NO_HANDOFF = 'IA_NO_HANDOFF';
19
+ /** The tokens before `--`, where an option is still an option. */
20
+ const options = (argv) => {
21
+ const end = argv.indexOf('--');
22
+ return end === -1 ? argv : argv.slice(0, end);
23
+ };
24
+ const real = (path) => {
25
+ try {
26
+ return realpathSync(path);
27
+ }
28
+ catch {
29
+ return path;
30
+ }
31
+ };
32
+ /** Whether a `.git` directory or file exists at `dir` or any parent: a work tree git was, or would have been, asked about. */
33
+ function insideWorkTree(dir) {
34
+ let current = real(dir);
35
+ for (;;) {
36
+ if (existsSync(join(current, '.git')))
37
+ return true;
38
+ const parent = dirname(current);
39
+ if (parent === current)
40
+ return false;
41
+ current = parent;
42
+ }
43
+ }
44
+ /** git ran and exited non-zero: no answer about the copy (a bad config, an unsafe directory, a locked index, or no repository). */
45
+ export const EXITED = 'exited';
46
+ /**
47
+ * What git says about the installed copy at `packageRoot`: whether it tracks any file of it, or no answer: `EXITED`
48
+ * when it ran and exited non-zero, `null` when it was stopped by its timeout, was killed, could not start or is not on
49
+ * the path. Only an exit of 0 is an answer. git is found as program.ts finds it and runs without the caller's `GIT_*`
50
+ * routing variables.
51
+ */
52
+ function askGit(packageRoot) {
53
+ const git = findProgram('git', process.env);
54
+ if (git === null)
55
+ return null;
56
+ const result = spawnSync(git, ['--no-optional-locks', '-C', packageRoot, 'ls-files', '--', '.'], {
57
+ cwd: programHome(),
58
+ env: programEnv(withoutGitRouting(process.env)),
59
+ encoding: 'utf8',
60
+ timeout: 2000,
61
+ windowsHide: true,
62
+ });
63
+ if (result.error !== undefined || result.status === null)
64
+ return null;
65
+ if (result.status !== 0)
66
+ return EXITED;
67
+ return result.stdout.trim() !== '';
68
+ }
69
+ /**
70
+ * Whether the installed copy at `packageRoot` is the repository's: git tracks a file of it, or git could not say and a
71
+ * `.git` exists at or above it. A copy committed to the repository is the repository's code, not an install the user
72
+ * ran, so a typed command never runs it. Asked only when a hand-off is about to happen. When git exits non-zero, is
73
+ * stopped by its timeout or cannot be started, the answer is the work tree's: inside one the copy is refused, so a git
74
+ * that cannot answer never lets a repository's copy run. Only without git and without any `.git` above, or outside
75
+ * every repository (git answers non-zero and no `.git` is above), is nothing tracked.
76
+ */
77
+ export function committed(packageRoot) {
78
+ const answer = askGit(packageRoot);
79
+ return typeof answer === 'boolean' ? answer : insideWorkTree(packageRoot);
80
+ }
81
+ /** The variables that move git's repository or index away from the one found up from the copy's directory. */
82
+ const GIT_LOCATION = ['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_COMMON_DIR', 'GIT_CEILING_DIRECTORIES'];
83
+ /** A file's identity on disk: device, inode, size and times, or `-` when it is absent. Any change reads as another file. */
84
+ const identity = (path) => {
85
+ try {
86
+ const stat = statSync(path, { bigint: true });
87
+ return `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
88
+ }
89
+ catch {
90
+ return '-';
91
+ }
92
+ };
93
+ /**
94
+ * The index git reads for `dir`: the first `.git` up from it that git would take (a directory with `HEAD`, or a file
95
+ * naming its `gitdir:` as a linked worktree or submodule has), or null outside a repository.
96
+ */
97
+ function gitIndexOf(dir) {
98
+ for (let at = dir;; at = dirname(at)) {
99
+ const dotGit = join(at, '.git');
100
+ // Read the file form first and let the read itself say what is there: a directory or nothing throws, so no
101
+ // separate check can go stale before the read.
102
+ let text = null;
103
+ try {
104
+ text = readFileSync(dotGit, 'utf8');
105
+ }
106
+ catch {
107
+ // A directory, nothing there, or not readable.
108
+ }
109
+ if (text !== null) {
110
+ const gitdir = /^gitdir:\s*(.+?)\s*$/m.exec(text)?.[1];
111
+ if (gitdir !== undefined)
112
+ return join(resolve(at, gitdir), 'index');
113
+ }
114
+ else if (existsSync(join(dotGit, 'HEAD'))) {
115
+ return join(dotGit, 'index');
116
+ }
117
+ if (dirname(at) === at)
118
+ return null;
119
+ }
120
+ }
121
+ /**
122
+ * What git's answer about the copy at `packageRoot` depends on, as the disk shows it: the copy's real path, its
123
+ * `package.json`, and the index of the repository git finds from it. `git ls-files` reads only that index, so the answer
124
+ * cannot change while all three stay the same: committing or adding the copy rewrites the index, and a copy moved into the
125
+ * path (or a link pointed elsewhere) changes the path or the manifest. Null while a GIT_ variable chooses the repository.
126
+ */
127
+ function copyState(packageRoot, env) {
128
+ if (GIT_LOCATION.some((name) => env[name] !== undefined))
129
+ return null;
130
+ const at = real(packageRoot);
131
+ const index = gitIndexOf(at);
132
+ return [at, identity(join(at, 'package.json')), index ?? '-', index === null ? '-' : identity(index)].join('\0');
133
+ }
134
+ /**
135
+ * `committed`, remembered per copy for as long as the returned function lives. The console makes one for its life, so
136
+ * the synchronous git call (2 s timeout) is made once per copy rather than at every load and every step. An answer is
137
+ * kept only with the disk state it was given for (`copyState`: a few `stat` calls per ask): once the copy is replaced at
138
+ * its path or the repository's index changes, git is asked again, so a committed copy never runs on an answer about
139
+ * another copy or an older index. Only an answer git gave (an exit of 0) is remembered: a question it could not answer
140
+ * (a non-zero exit, a timeout, a kill, or no git on the path) reads as `committed` reads it this time, from the work
141
+ * tree, and is asked again next time. One exception: a non-zero exit for a copy with no `.git` at or above it is
142
+ * remembered as not committed, since git exits that way outside every repository, nothing there can be tracked, and a
143
+ * repository appearing changes the state. Nothing is remembered while a GIT_ variable chooses the repository. The memo only
144
+ * saves asking; which copy runs is still decided from the disk each time (`runnableCopy`).
145
+ */
146
+ export function rememberCommitted(ask = askGit, env = process.env) {
147
+ const known = new Map();
148
+ return (packageRoot) => {
149
+ // Read before asking, so a change while git answers is seen as a change next time rather than kept.
150
+ const state = copyState(packageRoot, env);
151
+ const remembered = known.get(packageRoot);
152
+ if (state !== null && remembered?.state === state)
153
+ return remembered.answer;
154
+ let answer = ask(packageRoot);
155
+ // Outside every repository git exits non-zero each time: that is "not committed" for as long as no repository
156
+ // appears (it would change the state's index part). Any other exit may be mended by what the state does not show.
157
+ if (answer === EXITED && state !== null && state.split('\0')[2] === '-' && !insideWorkTree(packageRoot)) {
158
+ answer = false;
159
+ }
160
+ if (typeof answer !== 'boolean' || state === null) {
161
+ known.delete(packageRoot);
162
+ return typeof answer === 'boolean' ? answer : insideWorkTree(packageRoot);
163
+ }
164
+ known.set(packageRoot, { state, answer });
165
+ return answer;
166
+ };
167
+ }
168
+ const ROOT = '--root=';
169
+ /** The first `--root` before `--`, when it names a workspace; without one, the workspace discovered from `cwd`. */
170
+ export function rootFromArgv(argv, cwd, iaHome) {
171
+ const tokens = options(argv);
172
+ for (let index = 0; index < tokens.length; index += 1) {
173
+ const token = tokens[index];
174
+ const value = token === '--root' ? tokens[index + 1] : token.startsWith(ROOT) ? token.slice(ROOT.length) : null;
175
+ if (value === null)
176
+ continue;
177
+ if (value === undefined || value === '')
178
+ return undefined;
179
+ // At its real path, as the command opens it (consumer.ts): a root reached through a link takes the CLI its real
180
+ // parents pin, which is the workspace the command then acts on.
181
+ const root = real(resolve(cwd, value));
182
+ // As discovery does (discovery.ts), a directory whose `.ia` is the IA home is never a workspace.
183
+ const home = iaHome !== undefined && sameFile(resolve(root, '.ia'), iaHome);
184
+ return existsSync(resolve(root, '.ia/src')) && !home ? root : undefined;
185
+ }
186
+ return discoverRoot(cwd, iaHome);
187
+ }
188
+ /**
189
+ * The workspace's installed copy an `ia` may run for the workspace at `root`, or `null` (consumer-cli-contract §1.2):
190
+ * the copy resolveWorkspaceCli finds, up to the workspaces root that hoists it. A copy other than `running` is refused
191
+ * when the user set `IA_NO_HANDOFF=1` or the repository commits it, so neither a typed command (handoffTarget) nor the
192
+ * console (console/load.ts, console/app.ts) ever runs the repository's own code. The running copy is returned as found,
193
+ * since running it runs nothing new; git is asked only about another copy, and a git that cannot answer inside a work
194
+ * tree refuses the copy (committed).
195
+ */
196
+ export function runnableCopy(root, input) {
197
+ const local = resolveWorkspaceCli(root).local;
198
+ if (local === null || sameFile(local.packageRoot, input.running))
199
+ return local;
200
+ if (input.env[NO_HANDOFF] === '1')
201
+ return null;
202
+ return (input.committed ?? committed)(local.packageRoot) ? null : local;
203
+ }
204
+ /**
205
+ * The workspace's installed copy when it is not this one, or `null`. Bare `ia`, `--user`, an extension's commands and
206
+ * `doctor --host` always answer here, as does a malformed IA home (`iaHome` undefined), which this copy refuses. As in
207
+ * dispatch (consumer.ts), an extension never takes a core token: such a token is the core command's, and hands off.
208
+ */
209
+ export function handoffTarget(input) {
210
+ const { argv, env } = input;
211
+ const command = argv[0];
212
+ if (command === undefined)
213
+ return null;
214
+ if (!input.coreTokens.has(command) && input.extensions.includes(command))
215
+ return null;
216
+ if ((env[HANDOFF_FROM] ?? '') !== '' || input.iaHome === undefined)
217
+ return null;
218
+ const tokens = options(argv);
219
+ if (tokens.includes('--user'))
220
+ return null;
221
+ if (command === 'doctor' && tokens.some((token) => token === '--host' || token.startsWith('--host=')))
222
+ return null;
223
+ const root = rootFromArgv(argv, input.cwd, input.iaHome);
224
+ const local = root === undefined
225
+ ? null
226
+ : runnableCopy(root, {
227
+ env,
228
+ running: input.packageRoot,
229
+ ...(input.committed === undefined ? {} : { committed: input.committed }),
230
+ });
231
+ return local === null || sameFile(local.packageRoot, input.packageRoot) ? null : local;
232
+ }
233
+ /**
234
+ * The signals a terminal sends the whole foreground group. While the child runs, this copy ignores them: the child
235
+ * receives each itself and decides, so the prompt does not return while it is still finishing, and Windows does not
236
+ * end this copy with its own status in place of the child's.
237
+ */
238
+ const FORWARDED = [
239
+ 'SIGINT',
240
+ 'SIGTERM',
241
+ 'SIGHUP',
242
+ ...(process.platform === 'win32' ? ['SIGBREAK'] : []),
243
+ ];
244
+ const ignore = () => { };
245
+ /** Runs the target with inherited stdio and returns its exit code; throws when it cannot be started. */
246
+ export function handOff(target, argv, env, from) {
247
+ for (const signal of FORWARDED)
248
+ process.on(signal, ignore);
249
+ try {
250
+ const result = spawnSync(process.execPath, [target.entry, ...argv], {
251
+ stdio: 'inherit',
252
+ env: { ...env, [HANDOFF_FROM]: from },
253
+ });
254
+ if (result.error !== undefined)
255
+ throw result.error;
256
+ // §3: a child that ended on a signal ends this invocation as an interruption, 130.
257
+ return result.status ?? 130;
258
+ }
259
+ finally {
260
+ for (const signal of FORWARDED)
261
+ process.off(signal, ignore);
262
+ }
263
+ }
264
+ //# sourceMappingURL=handoff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../src/handoff.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEvF,yHAAyH;AACzH,MAAM,CAAC,MAAM,YAAY,G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WAAW,qBAAqB;IACpC,6GAA6G;IAC7G,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,QAAQ,CAAC;IAC/D,kGAAkG;IAClG,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,UAAU,GAAG,IAAI,EAC3B,UAAU,GAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAe,EAC9C,QAAQ,CAAC,EAAE,aAAa,EACxB,KAAK,GAAE,SAAgB,GACtB,qBAAqB,CAyEvB;AA6BD,2GAA2G;AAC3G,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,UAAU,GAAG,IAAI,EAC3B,KAAK,EAAE,SAAS,EAChB,MAAM,CAAC,EAAE,YAAY,GACpB,QAAQ,CAuBV;AAUD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAkB5F;AACD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAiBtE;AA2BD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,aAAa,GAAG,IAAI,CA8C9E"}
@@ -33,16 +33,9 @@ import { packetCatalog } from './commands.js';
33
33
  import { Refusal } from './consumer.js';
34
34
  import { refusedPath, SETTINGS, skillFolderOf, STATE } from './host.js';
35
35
  import { codeOf, openSession } from './session.js';
36
+ import { requireAdmitted } from './workspace-state.js';
36
37
  /** This CLI's id@version, which the receipt records and only the applying CLI knows. */
37
38
  const CLI = `@inventarch/cli@${JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version}`;
38
- /**
39
- * §4: the target must admit — zero error findings — before anything is rendered or registered. The refusal is the
40
- * CLI's own classification of the target, so it is IA-CLI-CONFLICT and names the command that shows the findings.
41
- */
42
- function requireAdmitted(session, root) {
43
- if (session.admission().status !== 'admitted')
44
- throw new Refusal('IA-CLI-CONFLICT', 'The workspace does not admit; host registration needs a workspace with zero error findings', 3, { path: root }, 'Run "ia validate" and fix the reported errors.');
45
- }
46
39
  /**
47
40
  * A host-generation refusal (workspace-runtime's ProjectionError, which carries its code in `diagnostic`) as this CLI's
48
41
  * refusal: its IA-PROJECTION-* code and message, located at the workspace, naming the command that shows the records.