@vibesdotdev/plugins 0.0.0-stage → 1.0.0-rc.1
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/LICENSE +18 -0
- package/README.md +54 -2
- package/VIBES.md +165 -0
- package/dist/ai/index.d.ts +4 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +3 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/plugin.impl.cloud.d.ts +4 -0
- package/dist/ai/plugin.impl.cloud.d.ts.map +1 -0
- package/dist/ai/plugin.impl.cloud.js +32 -0
- package/dist/ai/plugin.impl.cloud.js.map +1 -0
- package/dist/ai/plugin.impl.consumer.d.ts +7 -0
- package/dist/ai/plugin.impl.consumer.d.ts.map +1 -0
- package/dist/ai/plugin.impl.consumer.js +222 -0
- package/dist/ai/plugin.impl.consumer.js.map +1 -0
- package/dist/auth/consumer.plugin.d.ts +3 -0
- package/dist/auth/consumer.plugin.d.ts.map +1 -0
- package/dist/auth/consumer.plugin.js +105 -0
- package/dist/auth/consumer.plugin.js.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/plugin.d.ts +4 -0
- package/dist/auth/plugin.d.ts.map +1 -0
- package/dist/auth/plugin.js +33 -0
- package/dist/auth/plugin.js.map +1 -0
- package/dist/automation/consumer.plugin.d.ts +3 -0
- package/dist/automation/consumer.plugin.d.ts.map +1 -0
- package/dist/automation/consumer.plugin.js +92 -0
- package/dist/automation/consumer.plugin.js.map +1 -0
- package/dist/automation/index.d.ts +2 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +2 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/plugin.d.ts +4 -0
- package/dist/automation/plugin.d.ts.map +1 -0
- package/dist/automation/plugin.js +30 -0
- package/dist/automation/plugin.js.map +1 -0
- package/dist/bun/host.d.ts +44 -0
- package/dist/bun/host.d.ts.map +1 -0
- package/dist/bun/host.js +71 -0
- package/dist/bun/host.js.map +1 -0
- package/dist/cli/child-failure.d.ts +37 -0
- package/dist/cli/child-failure.d.ts.map +1 -0
- package/dist/cli/child-failure.js +86 -0
- package/dist/cli/child-failure.js.map +1 -0
- package/dist/cli/context.d.ts +12 -0
- package/dist/cli/context.d.ts.map +1 -0
- package/dist/cli/context.js +11 -0
- package/dist/cli/context.js.map +1 -0
- package/dist/cli/execution.d.ts +10 -0
- package/dist/cli/execution.d.ts.map +1 -0
- package/dist/cli/execution.js +20 -0
- package/dist/cli/execution.js.map +1 -0
- package/dist/cli/failure-facts.d.ts +16 -0
- package/dist/cli/failure-facts.d.ts.map +1 -0
- package/dist/cli/failure-facts.js +39 -0
- package/dist/cli/failure-facts.js.map +1 -0
- package/dist/cli/package-manager.consumer.d.ts +106 -0
- package/dist/cli/package-manager.consumer.d.ts.map +1 -0
- package/dist/cli/package-manager.consumer.js +258 -0
- package/dist/cli/package-manager.consumer.js.map +1 -0
- package/dist/cli/plugin.d.ts +9 -0
- package/dist/cli/plugin.d.ts.map +1 -0
- package/dist/cli/plugin.js +34 -0
- package/dist/cli/plugin.js.map +1 -0
- package/dist/cli/plugins.add.cli-command.descriptor.d.ts +36 -0
- package/dist/cli/plugins.add.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.add.cli-command.descriptor.js +31 -0
- package/dist/cli/plugins.add.cli-command.descriptor.js.map +1 -0
- package/dist/cli/plugins.add.cli-command.impl.consumer.d.ts +63 -0
- package/dist/cli/plugins.add.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/plugins.add.cli-command.impl.consumer.js +206 -0
- package/dist/cli/plugins.add.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/plugins.cli-group.descriptor.d.ts +4 -0
- package/dist/cli/plugins.cli-group.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.cli-group.descriptor.js +10 -0
- package/dist/cli/plugins.cli-group.descriptor.js.map +1 -0
- package/dist/cli/plugins.host.cli-command.descriptor.d.ts +31 -0
- package/dist/cli/plugins.host.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.host.cli-command.descriptor.js +37 -0
- package/dist/cli/plugins.host.cli-command.descriptor.js.map +1 -0
- package/dist/cli/plugins.host.cli-command.impl.consumer.d.ts +29 -0
- package/dist/cli/plugins.host.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/plugins.host.cli-command.impl.consumer.js +109 -0
- package/dist/cli/plugins.host.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/plugins.link.cli-command.descriptor.d.ts +35 -0
- package/dist/cli/plugins.link.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.link.cli-command.descriptor.js +32 -0
- package/dist/cli/plugins.link.cli-command.descriptor.js.map +1 -0
- package/dist/cli/plugins.link.cli-command.impl.consumer.d.ts +31 -0
- package/dist/cli/plugins.link.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/plugins.link.cli-command.impl.consumer.js +104 -0
- package/dist/cli/plugins.link.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/plugins.list.cli-command.descriptor.d.ts +26 -0
- package/dist/cli/plugins.list.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.list.cli-command.descriptor.js +22 -0
- package/dist/cli/plugins.list.cli-command.descriptor.js.map +1 -0
- package/dist/cli/plugins.list.cli-command.impl.consumer.d.ts +116 -0
- package/dist/cli/plugins.list.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/plugins.list.cli-command.impl.consumer.js +343 -0
- package/dist/cli/plugins.list.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/plugins.remove.cli-command.descriptor.d.ts +31 -0
- package/dist/cli/plugins.remove.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.remove.cli-command.descriptor.js +26 -0
- package/dist/cli/plugins.remove.cli-command.descriptor.js.map +1 -0
- package/dist/cli/plugins.remove.cli-command.impl.consumer.d.ts +30 -0
- package/dist/cli/plugins.remove.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/plugins.remove.cli-command.impl.consumer.js +80 -0
- package/dist/cli/plugins.remove.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/plugins.unlink.cli-command.descriptor.d.ts +31 -0
- package/dist/cli/plugins.unlink.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/plugins.unlink.cli-command.descriptor.js +21 -0
- package/dist/cli/plugins.unlink.cli-command.descriptor.js.map +1 -0
- package/dist/cli/plugins.unlink.cli-command.impl.consumer.d.ts +76 -0
- package/dist/cli/plugins.unlink.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/plugins.unlink.cli-command.impl.consumer.js +190 -0
- package/dist/cli/plugins.unlink.cli-command.impl.consumer.js.map +1 -0
- package/dist/cli/registry-sign-in.consumer.d.ts +80 -0
- package/dist/cli/registry-sign-in.consumer.d.ts.map +1 -0
- package/dist/cli/registry-sign-in.consumer.js +199 -0
- package/dist/cli/registry-sign-in.consumer.js.map +1 -0
- package/dist/cli/roll.d.ts +230 -0
- package/dist/cli/roll.d.ts.map +1 -0
- package/dist/cli/roll.js +569 -0
- package/dist/cli/roll.js.map +1 -0
- package/dist/cli/schemas/context.d.ts +10 -0
- package/dist/cli/schemas/context.d.ts.map +1 -0
- package/dist/cli/schemas/context.js +3 -0
- package/dist/cli/schemas/context.js.map +1 -0
- package/dist/cli/schemas/scopes.d.ts +37 -0
- package/dist/cli/schemas/scopes.d.ts.map +1 -0
- package/dist/cli/schemas/scopes.js +11 -0
- package/dist/cli/schemas/scopes.js.map +1 -0
- package/dist/cli/schemas/unlink.d.ts +18 -0
- package/dist/cli/schemas/unlink.d.ts.map +1 -0
- package/dist/cli/schemas/unlink.js +3 -0
- package/dist/cli/schemas/unlink.js.map +1 -0
- package/dist/cli/schemas/update.d.ts +77 -0
- package/dist/cli/schemas/update.d.ts.map +1 -0
- package/dist/cli/schemas/update.js +3 -0
- package/dist/cli/schemas/update.js.map +1 -0
- package/dist/cli/scopes.d.ts +50 -0
- package/dist/cli/scopes.d.ts.map +1 -0
- package/dist/cli/scopes.js +90 -0
- package/dist/cli/scopes.js.map +1 -0
- package/dist/cli/seed.d.ts +232 -0
- package/dist/cli/seed.d.ts.map +1 -0
- package/dist/cli/seed.js +590 -0
- package/dist/cli/seed.js.map +1 -0
- package/dist/cli/self-update.d.ts +120 -0
- package/dist/cli/self-update.d.ts.map +1 -0
- package/dist/cli/self-update.js +274 -0
- package/dist/cli/self-update.js.map +1 -0
- package/dist/cli/update.cli-command.descriptor.d.ts +62 -0
- package/dist/cli/update.cli-command.descriptor.d.ts.map +1 -0
- package/dist/cli/update.cli-command.descriptor.js +49 -0
- package/dist/cli/update.cli-command.descriptor.js.map +1 -0
- package/dist/cli/update.cli-command.impl.consumer.d.ts +178 -0
- package/dist/cli/update.cli-command.impl.consumer.d.ts.map +1 -0
- package/dist/cli/update.cli-command.impl.consumer.js +750 -0
- package/dist/cli/update.cli-command.impl.consumer.js.map +1 -0
- package/dist/comms/consumer.plugin.d.ts +3 -0
- package/dist/comms/consumer.plugin.d.ts.map +1 -0
- package/dist/comms/consumer.plugin.js +108 -0
- package/dist/comms/consumer.plugin.js.map +1 -0
- package/dist/comms/index.d.ts +2 -0
- package/dist/comms/index.d.ts.map +1 -0
- package/dist/comms/index.js +2 -0
- package/dist/comms/index.js.map +1 -0
- package/dist/comms/plugin.d.ts +4 -0
- package/dist/comms/plugin.d.ts.map +1 -0
- package/dist/comms/plugin.js +30 -0
- package/dist/comms/plugin.js.map +1 -0
- package/dist/consumer.d.ts +3 -0
- package/dist/consumer.d.ts.map +1 -0
- package/dist/consumer.js +3 -0
- package/dist/consumer.js.map +1 -0
- package/dist/consumer.plugin.d.ts +63 -0
- package/dist/consumer.plugin.d.ts.map +1 -0
- package/dist/consumer.plugin.js +89 -0
- package/dist/consumer.plugin.js.map +1 -0
- package/dist/core/consumer.plugin.d.ts +4 -0
- package/dist/core/consumer.plugin.d.ts.map +1 -0
- package/dist/core/consumer.plugin.js +364 -0
- package/dist/core/consumer.plugin.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/optional-member.d.ts +11 -0
- package/dist/core/optional-member.d.ts.map +1 -0
- package/dist/core/optional-member.js +68 -0
- package/dist/core/optional-member.js.map +1 -0
- package/dist/core/optional-plugin.d.ts +40 -0
- package/dist/core/optional-plugin.d.ts.map +1 -0
- package/dist/core/optional-plugin.js +107 -0
- package/dist/core/optional-plugin.js.map +1 -0
- package/dist/core/plugin.d.ts +10 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/plugin.js +64 -0
- package/dist/core/plugin.js.map +1 -0
- package/dist/core/setup-requirements.descriptors.d.ts +7 -0
- package/dist/core/setup-requirements.descriptors.d.ts.map +1 -0
- package/dist/core/setup-requirements.descriptors.js +117 -0
- package/dist/core/setup-requirements.descriptors.js.map +1 -0
- package/dist/data/consumer.plugin.d.ts +3 -0
- package/dist/data/consumer.plugin.d.ts.map +1 -0
- package/dist/data/consumer.plugin.js +99 -0
- package/dist/data/consumer.plugin.js.map +1 -0
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +2 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/plugin.d.ts +4 -0
- package/dist/data/plugin.d.ts.map +1 -0
- package/dist/data/plugin.js +37 -0
- package/dist/data/plugin.js.map +1 -0
- package/dist/devtools/consumer.plugin.d.ts +3 -0
- package/dist/devtools/consumer.plugin.d.ts.map +1 -0
- package/dist/devtools/consumer.plugin.js +323 -0
- package/dist/devtools/consumer.plugin.js.map +1 -0
- package/dist/devtools/index.d.ts +2 -0
- package/dist/devtools/index.d.ts.map +1 -0
- package/dist/devtools/index.js +2 -0
- package/dist/devtools/index.js.map +1 -0
- package/dist/devtools/plugin.d.ts +4 -0
- package/dist/devtools/plugin.d.ts.map +1 -0
- package/dist/devtools/plugin.js +34 -0
- package/dist/devtools/plugin.js.map +1 -0
- package/dist/filesystem/index.d.ts +2 -0
- package/dist/filesystem/index.d.ts.map +1 -0
- package/dist/filesystem/index.js +2 -0
- package/dist/filesystem/index.js.map +1 -0
- package/dist/filesystem/plugin.d.ts +4 -0
- package/dist/filesystem/plugin.d.ts.map +1 -0
- package/dist/filesystem/plugin.js +21 -0
- package/dist/filesystem/plugin.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +7 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +16 -0
- package/dist/plugin.js.map +1 -0
- package/dist/schemas/ai.d.ts +119 -0
- package/dist/schemas/ai.d.ts.map +1 -0
- package/dist/schemas/ai.js +84 -0
- package/dist/schemas/ai.js.map +1 -0
- package/dist/schemas/auth.d.ts +15 -0
- package/dist/schemas/auth.d.ts.map +1 -0
- package/dist/schemas/auth.js +19 -0
- package/dist/schemas/auth.js.map +1 -0
- package/dist/schemas/automation.d.ts +66 -0
- package/dist/schemas/automation.d.ts.map +1 -0
- package/dist/schemas/automation.js +36 -0
- package/dist/schemas/automation.js.map +1 -0
- package/dist/schemas/comms.d.ts +13 -0
- package/dist/schemas/comms.d.ts.map +1 -0
- package/dist/schemas/comms.js +27 -0
- package/dist/schemas/comms.js.map +1 -0
- package/dist/schemas/core.d.ts +102 -0
- package/dist/schemas/core.d.ts.map +1 -0
- package/dist/schemas/core.js +124 -0
- package/dist/schemas/core.js.map +1 -0
- package/dist/schemas/data.d.ts +13 -0
- package/dist/schemas/data.d.ts.map +1 -0
- package/dist/schemas/data.js +25 -0
- package/dist/schemas/data.js.map +1 -0
- package/dist/schemas/devtools.d.ts +33 -0
- package/dist/schemas/devtools.d.ts.map +1 -0
- package/dist/schemas/devtools.js +56 -0
- package/dist/schemas/devtools.js.map +1 -0
- package/dist/schemas/family.d.ts +11 -0
- package/dist/schemas/family.d.ts.map +1 -0
- package/dist/schemas/family.js +21 -0
- package/dist/schemas/family.js.map +1 -0
- package/dist/schemas/filesystem.d.ts +25 -0
- package/dist/schemas/filesystem.d.ts.map +1 -0
- package/dist/schemas/filesystem.js +24 -0
- package/dist/schemas/filesystem.js.map +1 -0
- package/dist/schemas/host.d.ts +10 -0
- package/dist/schemas/host.d.ts.map +1 -0
- package/dist/schemas/host.js +2 -0
- package/dist/schemas/host.js.map +1 -0
- package/dist/schemas/optional-member.d.ts +67 -0
- package/dist/schemas/optional-member.d.ts.map +1 -0
- package/dist/schemas/optional-member.js +31 -0
- package/dist/schemas/optional-member.js.map +1 -0
- package/dist/schemas/roll.d.ts +47 -0
- package/dist/schemas/roll.d.ts.map +1 -0
- package/dist/schemas/roll.js +18 -0
- package/dist/schemas/roll.js.map +1 -0
- package/dist/schemas/tui.d.ts +33 -0
- package/dist/schemas/tui.d.ts.map +1 -0
- package/dist/schemas/tui.js +95 -0
- package/dist/schemas/tui.js.map +1 -0
- package/dist/schemas/ui.d.ts +15 -0
- package/dist/schemas/ui.d.ts.map +1 -0
- package/dist/schemas/ui.js +45 -0
- package/dist/schemas/ui.js.map +1 -0
- package/dist/tui/code-sessions-tui-plugin-shim.d.ts +7 -0
- package/dist/tui/code-sessions-tui-plugin-shim.d.ts.map +1 -0
- package/dist/tui/code-sessions-tui-plugin-shim.js +2 -0
- package/dist/tui/code-sessions-tui-plugin-shim.js.map +1 -0
- package/dist/tui/index.d.ts +8 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +8 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/plugin.d.ts +53 -0
- package/dist/tui/plugin.d.ts.map +1 -0
- package/dist/tui/plugin.js +350 -0
- package/dist/tui/plugin.js.map +1 -0
- package/dist/ui/consumer.plugin.d.ts +3 -0
- package/dist/ui/consumer.plugin.d.ts.map +1 -0
- package/dist/ui/consumer.plugin.js +75 -0
- package/dist/ui/consumer.plugin.js.map +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/plugin.d.ts +4 -0
- package/dist/ui/plugin.d.ts.map +1 -0
- package/dist/ui/plugin.js +35 -0
- package/dist/ui/plugin.js.map +1 -0
- package/host-start.mjs +39 -0
- package/host.mjs +24 -0
- package/package.json +437 -4
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { CommandExecutionStartInfo } from '@vibesdotdev/cli/schemas/surface';
|
|
2
|
+
import type { CLICommandAssetDescriptor } from '@vibesdotdev/cli/schemas/types';
|
|
3
|
+
import { CapabilityError, type RuntimePackagePlugins } from '@vibesdotdev/kernel';
|
|
4
|
+
import { type WorkspacePluginListing } from '@vibesdotdev/kernel/bootstrap';
|
|
5
|
+
import { PluginsCLICommand, type PluginsCLIContext } from './context.ts';
|
|
6
|
+
import type { StrandedMember } from './schemas/unlink.ts';
|
|
7
|
+
/**
|
|
8
|
+
* Which members of the glob about to be dropped are still selected.
|
|
9
|
+
*
|
|
10
|
+
* Pure and exported: the refusal below is the difference between a command
|
|
11
|
+
* that says no and a command that bricks the scope, so it is a unit test
|
|
12
|
+
* rather than a claim about a code path nobody re-runs. A specifier's package
|
|
13
|
+
* is the host's package-plugin rule (`packages.getPackageName`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function findStrandedMembers(input: {
|
|
16
|
+
members: readonly string[];
|
|
17
|
+
plugins: readonly string[];
|
|
18
|
+
dependencies: Readonly<Record<string, string>>;
|
|
19
|
+
}, packages: Pick<RuntimePackagePlugins, 'getPackageName'>): StrandedMember[];
|
|
20
|
+
/**
|
|
21
|
+
* The refusal when the scope's plugin declarations could not be read (a
|
|
22
|
+
* `vibes.config.ts` that throws on import, a `package.json` that is not JSON).
|
|
23
|
+
* The enabled list is then unknown, so the safety check cannot run: the
|
|
24
|
+
* command fails closed, naming every file that failed, and never falls back to
|
|
25
|
+
* the manifest list or to "nothing enabled".
|
|
26
|
+
*/
|
|
27
|
+
export declare function unreadableSelectionsRefusal(listing: WorkspacePluginListing): CapabilityError;
|
|
28
|
+
/** The refusal `vibes plugins unlink` prints instead of wedging the scope. */
|
|
29
|
+
export declare function formatStrandedRefusal(input: {
|
|
30
|
+
glob: string;
|
|
31
|
+
scope: string;
|
|
32
|
+
root: string;
|
|
33
|
+
stranded: readonly StrandedMember[];
|
|
34
|
+
}): string;
|
|
35
|
+
/**
|
|
36
|
+
* `vibes plugins unlink <glob>` — drop a link glob and re-install the scope.
|
|
37
|
+
*
|
|
38
|
+
* ### The check happens BEFORE the write, because the remedy has to be reachable
|
|
39
|
+
*
|
|
40
|
+
* The draft removed the glob, ran `bun install`, and printed the still-selected
|
|
41
|
+
* members afterwards. Measured: the install FAILS (`error: Workspace dependency
|
|
42
|
+
* "@fx/local" not found`), so the line naming the remedy was never reached, the
|
|
43
|
+
* manifest was left with a dangling `workspace:*` dependency, and neither
|
|
44
|
+
* `vibes update` nor `vibes update --repair` could re-install the scope. A
|
|
45
|
+
* diagnostic printed after the step that cannot survive is not a diagnostic.
|
|
46
|
+
*
|
|
47
|
+
* So a glob that still supplies an ENABLED specifier or a `workspace:`
|
|
48
|
+
* dependency is refused up front, with `vibes plugins remove` as the exact next
|
|
49
|
+
* command — including under `--dry-run`, because "Would unlink" for an
|
|
50
|
+
* operation the real run refuses is the same lie in a quieter voice. We still
|
|
51
|
+
* do not silently disable anything: which of "unlink" and "remove" the user
|
|
52
|
+
* meant is their decision, and quietly editing the plugin list to make a
|
|
53
|
+
* command succeed is exactly the silent repair this program is removing.
|
|
54
|
+
*/
|
|
55
|
+
export default class PluginsUnlinkCLICommand extends PluginsCLICommand {
|
|
56
|
+
constructor(descriptor: CLICommandAssetDescriptor, context: PluginsCLIContext);
|
|
57
|
+
execute(args: CommandExecutionStartInfo['args'], options: CommandExecutionStartInfo['options']): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Specifiers the scope currently has ENABLED (the plugin list, not the deps).
|
|
60
|
+
*
|
|
61
|
+
* Read through the same resolution the workspace composition reads
|
|
62
|
+
* (`vibes.config.{ts,js,json}#plugins` primary,
|
|
63
|
+
* `package.json#vibes.plugins` fallback): Runtime's one reader over the
|
|
64
|
+
* handed runtime's selected `runtime/loader`. This is a SAFETY read: it is what
|
|
65
|
+
* stops `vibes plugins unlink` from dropping a glob that still supplies an
|
|
66
|
+
* enabled plugin. Resolving it through the writer's target resolver
|
|
67
|
+
* (`resolveWorkspaceListTarget`) reported an empty list for a
|
|
68
|
+
* `vibes.config.ts`, so the refusal could not fire for exactly the workspaces
|
|
69
|
+
* that use the documented surface. A declaration that failed to load
|
|
70
|
+
* refuses (`workspace-selections-unreadable`): an unknown list is never read
|
|
71
|
+
* as the manifest's or as empty.
|
|
72
|
+
*/
|
|
73
|
+
private selectionsFor;
|
|
74
|
+
private report;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=plugins.unlink.cli-command.impl.consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.unlink.cli-command.impl.consumer.d.ts","sourceRoot":"","sources":["../../src/cli/plugins.unlink.cli-command.impl.consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,EACN,eAAe,EAIf,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAA+B,KAAK,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEzG,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQ1D;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAClC,KAAK,EAAE;IACN,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/C,EACD,QAAQ,EAAE,IAAI,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,GACrD,cAAc,EAAE,CAUlB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CAY5F;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;CACpC,GAAG,MAAM,CAkBT;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,iBAAiB;gBACzD,UAAU,EAAE,yBAAyB,EAAE,OAAO,EAAE,iBAAiB;IAIvE,OAAO,CAAC,IAAI,EAAE,yBAAyB,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,yBAAyB,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsEpH;;;;;;;;;;;;;;OAcG;YACW,aAAa;IAW3B,OAAO,CAAC,MAAM;CAuBd"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { getRuntimePath } from '@vibesdotdev/paths';
|
|
2
|
+
import { CapabilityError, getRuntimePackagePlugins } from '@vibesdotdev/kernel';
|
|
3
|
+
import { readWorkspacePluginSurfaces } from '@vibesdotdev/kernel/bootstrap';
|
|
4
|
+
import { z } from 'zod/v4';
|
|
5
|
+
import { PluginsCLICommand } from "./context.js";
|
|
6
|
+
import { runBunOrThrow } from "./package-manager.consumer.js";
|
|
7
|
+
import { resolveSingleScope } from "./scopes.js";
|
|
8
|
+
/** The command's inputs, each read on its own: a missing or non-text glob is empty, a missing flag is off. */
|
|
9
|
+
const UnlinkInputSchema = z.object({
|
|
10
|
+
glob: z.string().trim().catch(''),
|
|
11
|
+
dryRun: z.boolean().catch(false)
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* Which members of the glob about to be dropped are still selected.
|
|
15
|
+
*
|
|
16
|
+
* Pure and exported: the refusal below is the difference between a command
|
|
17
|
+
* that says no and a command that bricks the scope, so it is a unit test
|
|
18
|
+
* rather than a claim about a code path nobody re-runs. A specifier's package
|
|
19
|
+
* is the host's package-plugin rule (`packages.getPackageName`).
|
|
20
|
+
*/
|
|
21
|
+
export function findStrandedMembers(input, packages) {
|
|
22
|
+
const stranded = [];
|
|
23
|
+
for (const name of input.members) {
|
|
24
|
+
const enabledBy = input.plugins.filter((specifier) => packages.getPackageName(specifier) === name);
|
|
25
|
+
const range = input.dependencies[name];
|
|
26
|
+
const declaredAs = range?.startsWith('workspace:') ? range : null;
|
|
27
|
+
if (enabledBy.length === 0 && declaredAs === null)
|
|
28
|
+
continue;
|
|
29
|
+
stranded.push({ name, enabledBy, declaredAs });
|
|
30
|
+
}
|
|
31
|
+
return stranded;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The refusal when the scope's plugin declarations could not be read (a
|
|
35
|
+
* `vibes.config.ts` that throws on import, a `package.json` that is not JSON).
|
|
36
|
+
* The enabled list is then unknown, so the safety check cannot run: the
|
|
37
|
+
* command fails closed, naming every file that failed, and never falls back to
|
|
38
|
+
* the manifest list or to "nothing enabled".
|
|
39
|
+
*/
|
|
40
|
+
export function unreadableSelectionsRefusal(listing) {
|
|
41
|
+
const files = listing.failures.map((failure) => failure.path);
|
|
42
|
+
const [first] = listing.failures;
|
|
43
|
+
const cause = listing.failures.length === 1 && first
|
|
44
|
+
? first.error
|
|
45
|
+
: new AggregateError(listing.failures.map((failure) => failure.error), 'Workspace plugin declarations failed to load');
|
|
46
|
+
return new CapabilityError(`Cannot read the plugin selections of ${listing.root}: ${files.join(', ')} failed to load. ` +
|
|
47
|
+
'Nothing was changed; fix the file and re-run.', 'INVALID_INPUT', { reason: 'workspace-selections-unreadable', retryable: false, details: { root: listing.root, files }, cause });
|
|
48
|
+
}
|
|
49
|
+
/** The refusal `vibes plugins unlink` prints instead of wedging the scope. */
|
|
50
|
+
export function formatStrandedRefusal(input) {
|
|
51
|
+
const detail = input.stranded
|
|
52
|
+
.map((member) => {
|
|
53
|
+
const parts = [
|
|
54
|
+
...(member.enabledBy.length ? [`enabled by ${member.enabledBy.join(', ')}`] : []),
|
|
55
|
+
...(member.declaredAs ? [`declared '${member.declaredAs}'`] : [])
|
|
56
|
+
];
|
|
57
|
+
return `${member.name} (${parts.join('; ')})`;
|
|
58
|
+
})
|
|
59
|
+
.join(', ');
|
|
60
|
+
const names = input.stranded.map((member) => member.name).join(' ');
|
|
61
|
+
return (`Refusing to unlink '${input.glob}' from the ${input.scope} scope (${input.root}): it still ` +
|
|
62
|
+
`supplies ${input.stranded.length} selected member(s) — ${detail}. Dropping the glob now ` +
|
|
63
|
+
`leaves a declaration bun cannot resolve, so the next install fails with ` +
|
|
64
|
+
`'Workspace dependency not found' and the scope stops booting. Disable them first, then ` +
|
|
65
|
+
`re-run this unlink:\n vibes plugins remove --${input.scope} ${names}`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* `vibes plugins unlink <glob>` — drop a link glob and re-install the scope.
|
|
69
|
+
*
|
|
70
|
+
* ### The check happens BEFORE the write, because the remedy has to be reachable
|
|
71
|
+
*
|
|
72
|
+
* The draft removed the glob, ran `bun install`, and printed the still-selected
|
|
73
|
+
* members afterwards. Measured: the install FAILS (`error: Workspace dependency
|
|
74
|
+
* "@fx/local" not found`), so the line naming the remedy was never reached, the
|
|
75
|
+
* manifest was left with a dangling `workspace:*` dependency, and neither
|
|
76
|
+
* `vibes update` nor `vibes update --repair` could re-install the scope. A
|
|
77
|
+
* diagnostic printed after the step that cannot survive is not a diagnostic.
|
|
78
|
+
*
|
|
79
|
+
* So a glob that still supplies an ENABLED specifier or a `workspace:`
|
|
80
|
+
* dependency is refused up front, with `vibes plugins remove` as the exact next
|
|
81
|
+
* command — including under `--dry-run`, because "Would unlink" for an
|
|
82
|
+
* operation the real run refuses is the same lie in a quieter voice. We still
|
|
83
|
+
* do not silently disable anything: which of "unlink" and "remove" the user
|
|
84
|
+
* meant is their decision, and quietly editing the plugin list to make a
|
|
85
|
+
* command succeed is exactly the silent repair this program is removing.
|
|
86
|
+
*/
|
|
87
|
+
export default class PluginsUnlinkCLICommand extends PluginsCLICommand {
|
|
88
|
+
constructor(descriptor, context) {
|
|
89
|
+
super(descriptor, context);
|
|
90
|
+
}
|
|
91
|
+
async execute(args, options) {
|
|
92
|
+
const flags = { ...args, ...options };
|
|
93
|
+
const input = UnlinkInputSchema.parse({ ...flags, glob: args.glob });
|
|
94
|
+
const raw = input.glob;
|
|
95
|
+
if (!raw)
|
|
96
|
+
throw new Error('plugins unlink requires the exact glob to remove');
|
|
97
|
+
const scope = await resolveSingleScope(this.runtime, flags, { fallback: 'global' });
|
|
98
|
+
const plugins = await getRuntimePackagePlugins(this.runtime);
|
|
99
|
+
const paths = await getRuntimePath(this.runtime);
|
|
100
|
+
const current = plugins.readWorkspaceGlobs(scope.root);
|
|
101
|
+
// Accept the glob as written, or as the caller happens to have typed the
|
|
102
|
+
// path (absolute where the manifest is relative and vice versa).
|
|
103
|
+
const candidates = new Set([
|
|
104
|
+
raw,
|
|
105
|
+
paths.isAbsolute(raw) ? paths.relative(scope.root, raw) : paths.resolve(scope.root, raw)
|
|
106
|
+
]);
|
|
107
|
+
const glob = current.find((entry) => candidates.has(entry));
|
|
108
|
+
if (!glob) {
|
|
109
|
+
throw new Error(`the ${scope.kind} scope (${scope.root}) does not link '${raw}'. ` +
|
|
110
|
+
`Linked globs: ${current.join(', ') || 'none'}`);
|
|
111
|
+
}
|
|
112
|
+
const members = [...plugins.expandWorkspaceMembers(scope.root, [glob]).keys()].sort();
|
|
113
|
+
const stranded = findStrandedMembers({
|
|
114
|
+
members,
|
|
115
|
+
plugins: await this.selectionsFor(plugins, scope),
|
|
116
|
+
dependencies: plugins.readScopeDependencies(scope.root)
|
|
117
|
+
}, plugins);
|
|
118
|
+
if (stranded.length) {
|
|
119
|
+
throw new Error(formatStrandedRefusal({ glob, scope: scope.kind, root: scope.root, stranded }));
|
|
120
|
+
}
|
|
121
|
+
if (input.dryRun) {
|
|
122
|
+
this.report(plugins, { scope: scope.kind, root: scope.root, glob, members, removed: false, dryRun: true });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const removed = await plugins.removeWorkspaceGlob(scope.root, glob);
|
|
126
|
+
try {
|
|
127
|
+
await runBunOrThrow({ runtime: this.runtime, action: 'install', cwd: scope.root });
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
// Nothing selected this glob's members (checked above), so an install
|
|
131
|
+
// failure here is something else — a foreign declaration, a broken
|
|
132
|
+
// sibling glob. Re-state what was already written and how to undo it,
|
|
133
|
+
// because the manifest has changed and the bun error alone does not
|
|
134
|
+
// say so. The install failure itself stays the cause.
|
|
135
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
136
|
+
throw new CapabilityError(`${detail}\n` +
|
|
137
|
+
`'${glob}' was already removed from ${scope.root}/package.json` +
|
|
138
|
+
`${members.length ? ` (members: ${members.join(', ')})` : ''}. ` +
|
|
139
|
+
`Restore it with: vibes plugins link '${glob}' --${scope.kind}`, 'UNAVAILABLE', {
|
|
140
|
+
reason: 'plugin-unlink-install-failed',
|
|
141
|
+
retryable: false,
|
|
142
|
+
details: { root: scope.root, glob, members },
|
|
143
|
+
cause: error
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
this.report(plugins, { scope: scope.kind, root: scope.root, glob, members, removed });
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Specifiers the scope currently has ENABLED (the plugin list, not the deps).
|
|
150
|
+
*
|
|
151
|
+
* Read through the same resolution the workspace composition reads
|
|
152
|
+
* (`vibes.config.{ts,js,json}#plugins` primary,
|
|
153
|
+
* `package.json#vibes.plugins` fallback): Runtime's one reader over the
|
|
154
|
+
* handed runtime's selected `runtime/loader`. This is a SAFETY read: it is what
|
|
155
|
+
* stops `vibes plugins unlink` from dropping a glob that still supplies an
|
|
156
|
+
* enabled plugin. Resolving it through the writer's target resolver
|
|
157
|
+
* (`resolveWorkspaceListTarget`) reported an empty list for a
|
|
158
|
+
* `vibes.config.ts`, so the refusal could not fire for exactly the workspaces
|
|
159
|
+
* that use the documented surface. A declaration that failed to load
|
|
160
|
+
* refuses (`workspace-selections-unreadable`): an unknown list is never read
|
|
161
|
+
* as the manifest's or as empty.
|
|
162
|
+
*/
|
|
163
|
+
async selectionsFor(plugins, scope) {
|
|
164
|
+
if (scope.kind === 'global')
|
|
165
|
+
return plugins.readGlobalPluginScope(scope.root).plugins;
|
|
166
|
+
const loader = await this.runtime
|
|
167
|
+
.query('runtime/loader')
|
|
168
|
+
.enabled()
|
|
169
|
+
.resolve();
|
|
170
|
+
const listing = await readWorkspacePluginSurfaces(scope.root, { loader });
|
|
171
|
+
if (listing.failures.length > 0)
|
|
172
|
+
throw unreadableSelectionsRefusal(listing);
|
|
173
|
+
return listing.effective?.plugins ?? [];
|
|
174
|
+
}
|
|
175
|
+
report(plugins, payload) {
|
|
176
|
+
if (this.format === 'json') {
|
|
177
|
+
this.ui.json({ ...payload, globs: plugins.readWorkspaceGlobs(payload.root) });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const verb = payload.dryRun ? 'Would unlink' : payload.removed ? 'Unlinked' : 'Not linked:';
|
|
181
|
+
this.ui.success(`${verb} ${payload.glob} from the ${payload.scope} scope (${payload.root})`);
|
|
182
|
+
if (payload.members.length) {
|
|
183
|
+
this.ui.warn(`${payload.members.length} member(s) are no longer supplied by a link glob: ` +
|
|
184
|
+
`${payload.members.join(', ')}. None of them is enabled or declared in this scope ` +
|
|
185
|
+
`(that is checked before the write), but another root that expects them will not ` +
|
|
186
|
+
`resolve them from here.`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=plugins.unlink.cli-command.impl.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.unlink.cli-command.impl.consumer.js","sourceRoot":"","sources":["../../src/cli/plugins.unlink.cli-command.impl.consumer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACN,eAAe,EACf,wBAAwB,EAIxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAA+B,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAA0B,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD,8GAA8G;AAC9G,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;CAChC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAClC,KAIC,EACD,QAAuD;IAEvD,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,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installs (`vibes update`, `vibes plugins`).
|
|
3
|
+
*
|
|
4
|
+
* packages.vibes.dev 404-hides a missing or rejected credential rather than
|
|
5
|
+
* returning 401, so a signed-out install fails with
|
|
6
|
+
* `GET https://packages.vibes.dev/@vibesdotdev%2f… - 404` and reads like an
|
|
7
|
+
* unpublished package. Two measures close that:
|
|
8
|
+
*
|
|
9
|
+
* - Before bun runs, a person at a terminal with no install credential is
|
|
10
|
+
* signed in through `auth.login`, resolved as a `cli/command` through the
|
|
11
|
+
* runtime. After it, the caller's bearer resolves from the device session.
|
|
12
|
+
* - After bun fails, a registry 404 with no install credential is re-stated as
|
|
13
|
+
* the sign-in it actually is.
|
|
14
|
+
*
|
|
15
|
+
* The install credential is resolved for the runtime the install was handed
|
|
16
|
+
* (rc01 §3 "Child credentials"): a named `VIBES_REGISTRY_TOKEN` in the host's
|
|
17
|
+
* declared secrets store, else the caller's bearer from auth's
|
|
18
|
+
* `resolveCallerBearer` (registry reads authenticate as the caller, rc05
|
|
19
|
+
* §2.2). Nothing is read from the environment.
|
|
20
|
+
*
|
|
21
|
+
* Both run inside `runBunOrThrow`, the one choke point every install path uses.
|
|
22
|
+
* What they say goes to stderr through `cli/ui`, never into a command's output.
|
|
23
|
+
*/
|
|
24
|
+
import { type VibesRuntime } from '@vibesdotdev/kernel';
|
|
25
|
+
export type RegistrySignIn = 'bound' | 'signed-in' | 'unbound';
|
|
26
|
+
/** The registry that 404-hides a signed-out request: the one the global home is seeded with. */
|
|
27
|
+
/** The one variable bun's scoped-registry config reads (`VIBES_REGISTRY_JWT` folded into it). */
|
|
28
|
+
export declare const REGISTRY_TOKEN_KEY = "VIBES_REGISTRY_TOKEN";
|
|
29
|
+
/**
|
|
30
|
+
* The credential a registry install presents, in a declared order:
|
|
31
|
+
*
|
|
32
|
+
* 1. a named `VIBES_REGISTRY_TOKEN` the host's declared secrets store holds (a
|
|
33
|
+
* lease `vibes secrets exec` or a CI step published, or a token stored with
|
|
34
|
+
* `vibes secrets set`), through `runtime.resolveCredential`;
|
|
35
|
+
* 2. else the caller's bearer, through auth's `resolveCallerBearer`.
|
|
36
|
+
*
|
|
37
|
+
* Only a typed absence moves on or ends in `null`: `credential-not-set` for the
|
|
38
|
+
* named token, `not-signed-in` or an anonymous caller for the bearer. Every
|
|
39
|
+
* other failure throws.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveRegistryInstallCredential(runtime: VibesRuntime): Promise<string | null>;
|
|
42
|
+
/** The install credential as child-only env for Bun. Callers never pass a token. */
|
|
43
|
+
export declare function registryInstallEnv(runtime: VibesRuntime): Promise<Record<string, string>>;
|
|
44
|
+
export declare function registryCredentialBound(runtime: VibesRuntime): Promise<boolean>;
|
|
45
|
+
/**
|
|
46
|
+
* Sign in when nothing is bound and a person can answer. Never prompts a
|
|
47
|
+
* supervisor.
|
|
48
|
+
*
|
|
49
|
+
* A broken `auth.login` is reported with its cause and the install goes on
|
|
50
|
+
* signed out. Stopping here would block `vibes update --global`, the command
|
|
51
|
+
* that reinstalls a broken auth package, and installs that fetch nothing
|
|
52
|
+
* private. If bun then meets a hidden package, `explainRegistryFailure` names
|
|
53
|
+
* the sign-in.
|
|
54
|
+
*/
|
|
55
|
+
export declare function ensureRegistrySignIn(runtime: VibesRuntime, options: {
|
|
56
|
+
interactive: boolean;
|
|
57
|
+
}): Promise<RegistrySignIn>;
|
|
58
|
+
/** One registry request bun reported as failed. */
|
|
59
|
+
export interface BunRequestFailure {
|
|
60
|
+
method: string;
|
|
61
|
+
url: URL;
|
|
62
|
+
status: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The registry requests bun reports as failed in its stderr.
|
|
66
|
+
*
|
|
67
|
+
* `bun install` has no machine-readable reporter: a failed request exists
|
|
68
|
+
* only as the line `error: GET <url> - <status>` (measured on Bun 1.4.0
|
|
69
|
+
* against a registry answering 404). This is the one place that reads that
|
|
70
|
+
* line; callers decide on the fields it returns.
|
|
71
|
+
*/
|
|
72
|
+
export declare function bunRequestFailures(stderr: string): BunRequestFailure[];
|
|
73
|
+
/**
|
|
74
|
+
* Re-state a signed-out registry 404 as the sign-in it is. Other failures pass
|
|
75
|
+
* through. The decision reads `bunStderr`, bun's own output, not the summary
|
|
76
|
+
* in `failure`: that summary is trimmed for a person to read, so it is not a
|
|
77
|
+
* record to classify from.
|
|
78
|
+
*/
|
|
79
|
+
export declare function explainRegistryFailure(runtime: VibesRuntime, failure: Error, bunStderr: string): Promise<Error>;
|
|
80
|
+
//# sourceMappingURL=registry-sign-in.consumer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-sign-in.consumer.d.ts","sourceRoot":"","sources":["../../src/cli/registry-sign-in.consumer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,EAA+E,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMrI,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,WAAW,GAAG,SAAS,CAAC;AAO/D,gGAAgG;AAEhG,iGAAiG;AACjG,eAAO,MAAM,kBAAkB,yBAAyB,CAAC;AAGzD;;;;;;;;;;;GAWG;AACH,wBAAsB,gCAAgC,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASpG;AAWD,oFAAoF;AACpF,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAQ/F;AAED,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAErF;AA+CD;;;;;;;;;GASG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE;IAAE,WAAW,EAAE,OAAO,CAAA;CAAE,GAC/B,OAAO,CAAC,cAAc,CAAC,CAgBzB;AAED,mDAAmD;AACnD,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,MAAM,CAAC;CACf;AAeD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAStE;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,KAAK,EACd,SAAS,EAAE,MAAM,GACf,OAAO,CAAC,KAAK,CAAC,CAehB"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry sign-in for host-side installs (`vibes update`, `vibes plugins`).
|
|
3
|
+
*
|
|
4
|
+
* packages.vibes.dev 404-hides a missing or rejected credential rather than
|
|
5
|
+
* returning 401, so a signed-out install fails with
|
|
6
|
+
* `GET https://packages.vibes.dev/@vibesdotdev%2f… - 404` and reads like an
|
|
7
|
+
* unpublished package. Two measures close that:
|
|
8
|
+
*
|
|
9
|
+
* - Before bun runs, a person at a terminal with no install credential is
|
|
10
|
+
* signed in through `auth.login`, resolved as a `cli/command` through the
|
|
11
|
+
* runtime. After it, the caller's bearer resolves from the device session.
|
|
12
|
+
* - After bun fails, a registry 404 with no install credential is re-stated as
|
|
13
|
+
* the sign-in it actually is.
|
|
14
|
+
*
|
|
15
|
+
* The install credential is resolved for the runtime the install was handed
|
|
16
|
+
* (rc01 §3 "Child credentials"): a named `VIBES_REGISTRY_TOKEN` in the host's
|
|
17
|
+
* declared secrets store, else the caller's bearer from auth's
|
|
18
|
+
* `resolveCallerBearer` (registry reads authenticate as the caller, rc05
|
|
19
|
+
* §2.2). Nothing is read from the environment.
|
|
20
|
+
*
|
|
21
|
+
* Both run inside `runBunOrThrow`, the one choke point every install path uses.
|
|
22
|
+
* What they say goes to stderr through `cli/ui`, never into a command's output.
|
|
23
|
+
*/
|
|
24
|
+
import { DefaultCLICommandImplementation } from '@vibesdotdev/cli/kinds';
|
|
25
|
+
import { CapabilityError, CaughtFailureSchema, isCapabilityError } from '@vibesdotdev/kernel';
|
|
26
|
+
import { LoggedErrorSchema } from '@vibesdotdev/logging';
|
|
27
|
+
import { redactedExcerpt } from '@vibesdotdev/shared/utils';
|
|
28
|
+
import { resolveCallerBearer } from '@vibesdotdev/auth/caller-bearer';
|
|
29
|
+
import { resolveSeedRegistryUrl } from "./seed.js";
|
|
30
|
+
const LOGIN_COMMAND_ID = 'auth.login';
|
|
31
|
+
/** The registry that 404-hides a signed-out request: the one the global home is seeded with. */
|
|
32
|
+
/** The one variable bun's scoped-registry config reads (`VIBES_REGISTRY_JWT` folded into it). */
|
|
33
|
+
export const REGISTRY_TOKEN_KEY = 'VIBES_REGISTRY_TOKEN';
|
|
34
|
+
const BUN_CONFIG_TOKEN_KEY = 'BUN_CONFIG_TOKEN';
|
|
35
|
+
/**
|
|
36
|
+
* The credential a registry install presents, in a declared order:
|
|
37
|
+
*
|
|
38
|
+
* 1. a named `VIBES_REGISTRY_TOKEN` the host's declared secrets store holds (a
|
|
39
|
+
* lease `vibes secrets exec` or a CI step published, or a token stored with
|
|
40
|
+
* `vibes secrets set`), through `runtime.resolveCredential`;
|
|
41
|
+
* 2. else the caller's bearer, through auth's `resolveCallerBearer`.
|
|
42
|
+
*
|
|
43
|
+
* Only a typed absence moves on or ends in `null`: `credential-not-set` for the
|
|
44
|
+
* named token, `not-signed-in` or an anonymous caller for the bearer. Every
|
|
45
|
+
* other failure throws.
|
|
46
|
+
*/
|
|
47
|
+
export async function resolveRegistryInstallCredential(runtime) {
|
|
48
|
+
const named = await runtime.resolveCredential({ source: 'secret', key: REGISTRY_TOKEN_KEY });
|
|
49
|
+
if (named.ok)
|
|
50
|
+
return named.value;
|
|
51
|
+
if (named.error.reason !== 'credential-not-set')
|
|
52
|
+
throw named.error;
|
|
53
|
+
const bearer = await bearerOutcome(runtime);
|
|
54
|
+
if (bearer.ok)
|
|
55
|
+
return bearer.value;
|
|
56
|
+
// Only the typed absence of a session is "no credential"; every other failure is carried.
|
|
57
|
+
if (isCapabilityError(bearer.failure) && bearer.failure.reason === 'not-signed-in')
|
|
58
|
+
return null;
|
|
59
|
+
throw bearer.failure;
|
|
60
|
+
}
|
|
61
|
+
/** The caller's bearer, or the failure resolving it raised, captured once. */
|
|
62
|
+
async function bearerOutcome(runtime) {
|
|
63
|
+
try {
|
|
64
|
+
return { ok: true, value: await resolveCallerBearer(runtime) };
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return { ok: false, failure: CaughtFailureSchema.parse(error) };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** The install credential as child-only env for Bun. Callers never pass a token. */
|
|
71
|
+
export async function registryInstallEnv(runtime) {
|
|
72
|
+
const token = await resolveRegistryInstallCredential(runtime);
|
|
73
|
+
return token
|
|
74
|
+
? {
|
|
75
|
+
[REGISTRY_TOKEN_KEY]: token,
|
|
76
|
+
[BUN_CONFIG_TOKEN_KEY]: token
|
|
77
|
+
}
|
|
78
|
+
: {};
|
|
79
|
+
}
|
|
80
|
+
export async function registryCredentialBound(runtime) {
|
|
81
|
+
return (await resolveRegistryInstallCredential(runtime)) !== null;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* `auth.login` as this runtime composes it. `absent` when no auth plugin
|
|
85
|
+
* registered a real one, which is an ordinary composition. That includes the
|
|
86
|
+
* `DefaultCLICommandImplementation` the kind hands back for a descriptor with
|
|
87
|
+
* no loader: the CLI owner reads that stub as "nothing real is registered in
|
|
88
|
+
* this scope" (`register-commands.ts`), and so does this. `broken` is a
|
|
89
|
+
* registered command whose loader threw, kept apart so it is never passed off
|
|
90
|
+
* as "no auth here".
|
|
91
|
+
*/
|
|
92
|
+
async function resolveLogin(runtime) {
|
|
93
|
+
if (!runtime.hasKind('cli/command'))
|
|
94
|
+
return { state: 'absent' };
|
|
95
|
+
const query = runtime
|
|
96
|
+
.query('cli/command')
|
|
97
|
+
.withId(LOGIN_COMMAND_ID);
|
|
98
|
+
if (!(await query.existsAsync()))
|
|
99
|
+
return { state: 'absent' };
|
|
100
|
+
let login;
|
|
101
|
+
try {
|
|
102
|
+
login = await query.resolve();
|
|
103
|
+
}
|
|
104
|
+
catch (cause) {
|
|
105
|
+
return { state: 'broken', cause: CaughtFailureSchema.parse(cause) };
|
|
106
|
+
}
|
|
107
|
+
if (login instanceof DefaultCLICommandImplementation)
|
|
108
|
+
return { state: 'absent' };
|
|
109
|
+
return { state: 'ready', login };
|
|
110
|
+
}
|
|
111
|
+
/** The runtime's own refusal reasons that wrap an asset's failure (as `cause`) in its `kind:id` context. */
|
|
112
|
+
const RUNTIME_WRAPPED_REASONS = new Set(['dependency-absent', 'load-failed', 'provide-failed']);
|
|
113
|
+
function brokenLoginNotice(cause) {
|
|
114
|
+
// The runtime's message names the failed asset only; the module's own failure is its cause.
|
|
115
|
+
const own = isCapabilityError(cause) && RUNTIME_WRAPPED_REASONS.has(cause.reason) ? cause.cause : cause;
|
|
116
|
+
// Logging's total describer reads the message once and never throws; the excerpt is bounded and credential-free.
|
|
117
|
+
const reason = redactedExcerpt(LoggedErrorSchema.parse(own).message);
|
|
118
|
+
return (`Sign-in ('${LOGIN_COMMAND_ID}') failed to load, so this install runs signed out: ${reason}\n` +
|
|
119
|
+
' Private Vibes packages need a credential: store VIBES_REGISTRY_TOKEN with `vibes secrets set`, ' +
|
|
120
|
+
'or pass --non-interactive to skip sign-in.');
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sign in when nothing is bound and a person can answer. Never prompts a
|
|
124
|
+
* supervisor.
|
|
125
|
+
*
|
|
126
|
+
* A broken `auth.login` is reported with its cause and the install goes on
|
|
127
|
+
* signed out. Stopping here would block `vibes update --global`, the command
|
|
128
|
+
* that reinstalls a broken auth package, and installs that fetch nothing
|
|
129
|
+
* private. If bun then meets a hidden package, `explainRegistryFailure` names
|
|
130
|
+
* the sign-in.
|
|
131
|
+
*/
|
|
132
|
+
export async function ensureRegistrySignIn(runtime, options) {
|
|
133
|
+
if (await registryCredentialBound(runtime))
|
|
134
|
+
return 'bound';
|
|
135
|
+
if (!options.interactive)
|
|
136
|
+
return 'unbound';
|
|
137
|
+
const resolution = await resolveLogin(runtime);
|
|
138
|
+
if (resolution.state === 'absent')
|
|
139
|
+
return 'unbound';
|
|
140
|
+
// `warn` is the CLI toolkit's stderr channel; `info` writes to stdout, where
|
|
141
|
+
// it would land in front of a `-o yaml` payload.
|
|
142
|
+
const ui = await runtime.context('cli/ui');
|
|
143
|
+
if (resolution.state === 'broken') {
|
|
144
|
+
ui.warn(brokenLoginNotice(resolution.cause));
|
|
145
|
+
return 'unbound';
|
|
146
|
+
}
|
|
147
|
+
ui.warn('Private Vibes packages need a sign-in first.');
|
|
148
|
+
// The command takes its runtime from its context, like any CLI action.
|
|
149
|
+
await resolution.login.execute({}, { interactive: true }, { runtime, ui });
|
|
150
|
+
return (await registryCredentialBound(runtime)) ? 'signed-in' : 'unbound';
|
|
151
|
+
}
|
|
152
|
+
const BUN_REQUEST_FAILURE = /^error: ([A-Z]+) (\S+) - (\d{3})$/;
|
|
153
|
+
/** ANSI/VT control sequences (CSI, OSC, and two-byte escapes), which bun colours its errors with. */
|
|
154
|
+
const ESC = String.fromCodePoint(27);
|
|
155
|
+
const BEL = String.fromCodePoint(7);
|
|
156
|
+
const CSI = String.fromCodePoint(155);
|
|
157
|
+
const TERMINAL_CONTROL = new RegExp(`${ESC}(?:\\[[0-?]*[ -/]*[@-~]|\\][^${BEL}${ESC}]*(?:${BEL}|${ESC}\\\\)|[@-Z\\\\-_])|${CSI}[0-?]*[ -/]*[@-~]`, 'g');
|
|
158
|
+
/** `text` without terminal control sequences. */
|
|
159
|
+
function stripTerminalControls(text) {
|
|
160
|
+
return text.replace(TERMINAL_CONTROL, '');
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The registry requests bun reports as failed in its stderr.
|
|
164
|
+
*
|
|
165
|
+
* `bun install` has no machine-readable reporter: a failed request exists
|
|
166
|
+
* only as the line `error: GET <url> - <status>` (measured on Bun 1.4.0
|
|
167
|
+
* against a registry answering 404). This is the one place that reads that
|
|
168
|
+
* line; callers decide on the fields it returns.
|
|
169
|
+
*/
|
|
170
|
+
export function bunRequestFailures(stderr) {
|
|
171
|
+
const failures = [];
|
|
172
|
+
for (const line of stripTerminalControls(stderr).split('\n')) {
|
|
173
|
+
const match = BUN_REQUEST_FAILURE.exec(line.trim());
|
|
174
|
+
const url = match?.[2] ? URL.parse(match[2]) : null;
|
|
175
|
+
if (!match?.[1] || !match[3] || !url)
|
|
176
|
+
continue;
|
|
177
|
+
failures.push({ method: match[1], url, status: Number(match[3]) });
|
|
178
|
+
}
|
|
179
|
+
return failures;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Re-state a signed-out registry 404 as the sign-in it is. Other failures pass
|
|
183
|
+
* through. The decision reads `bunStderr`, bun's own output, not the summary
|
|
184
|
+
* in `failure`: that summary is trimmed for a person to read, so it is not a
|
|
185
|
+
* record to classify from.
|
|
186
|
+
*/
|
|
187
|
+
export async function explainRegistryFailure(runtime, failure, bunStderr) {
|
|
188
|
+
if (await registryCredentialBound(runtime))
|
|
189
|
+
return failure;
|
|
190
|
+
const hidingRegistryHost = new URL(await resolveSeedRegistryUrl(runtime)).host;
|
|
191
|
+
const hidden = bunRequestFailures(bunStderr).some((request) => request.status === 404 && request.url.host === hidingRegistryHost);
|
|
192
|
+
if (!hidden)
|
|
193
|
+
return failure;
|
|
194
|
+
return new CapabilityError('Private Vibes packages were hidden because this machine is not signed in.\n' +
|
|
195
|
+
' run: vibes auth login\n' +
|
|
196
|
+
' then: vibes update --global\n' +
|
|
197
|
+
'Unattended hosts: store a `vibes registry token create` token as VIBES_REGISTRY_TOKEN with `vibes secrets set`.', 'AUTH_REQUIRED', { reason: 'registry-sign-in-required', retryable: false, cause: failure });
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=registry-sign-in.consumer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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