@vibesdotdev/cli 0.0.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/README.md +41 -0
- package/SPEC.md +97 -0
- package/bin/vibes.ts +26 -0
- package/dist/api/client/factory.d.ts +29 -0
- package/dist/api/client/factory.d.ts.map +1 -0
- package/dist/api/client/factory.js +189 -0
- package/dist/api/client/factory.js.map +1 -0
- package/dist/api/schemas/common.d.ts +58 -0
- package/dist/api/schemas/common.d.ts.map +1 -0
- package/dist/api/schemas/common.js +48 -0
- package/dist/api/schemas/common.js.map +1 -0
- package/dist/api/schemas/types.d.ts +30 -0
- package/dist/api/schemas/types.d.ts.map +1 -0
- package/dist/api/schemas/types.js +2 -0
- package/dist/api/schemas/types.js.map +1 -0
- package/dist/api/services/api.d.ts +14 -0
- package/dist/api/services/api.d.ts.map +1 -0
- package/dist/api/services/api.js +110 -0
- package/dist/api/services/api.js.map +1 -0
- package/dist/api/types.d.ts +6 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +5 -0
- package/dist/api/types.js.map +1 -0
- package/dist/bin.d.ts +28 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +73 -0
- package/dist/bin.js.map +1 -0
- package/dist/bootstrap.d.ts +14 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +14 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/cli.plugin.d.ts +20 -0
- package/dist/cli.plugin.d.ts.map +1 -0
- package/dist/cli.plugin.js +170 -0
- package/dist/cli.plugin.js.map +1 -0
- package/dist/commands/completion/bash.d.ts +8 -0
- package/dist/commands/completion/bash.d.ts.map +1 -0
- package/dist/commands/completion/bash.js +60 -0
- package/dist/commands/completion/bash.js.map +1 -0
- package/dist/commands/completion/completion.descriptor.d.ts +10 -0
- package/dist/commands/completion/completion.descriptor.d.ts.map +1 -0
- package/dist/commands/completion/completion.descriptor.js +41 -0
- package/dist/commands/completion/completion.descriptor.js.map +1 -0
- package/dist/commands/completion/completion.impl.d.ts +12 -0
- package/dist/commands/completion/completion.impl.d.ts.map +1 -0
- package/dist/commands/completion/completion.impl.js +167 -0
- package/dist/commands/completion/completion.impl.js.map +1 -0
- package/dist/commands/completion/fig.d.ts +12 -0
- package/dist/commands/completion/fig.d.ts.map +1 -0
- package/dist/commands/completion/fig.js +71 -0
- package/dist/commands/completion/fig.js.map +1 -0
- package/dist/commands/completion/fish.d.ts +8 -0
- package/dist/commands/completion/fish.d.ts.map +1 -0
- package/dist/commands/completion/fish.js +38 -0
- package/dist/commands/completion/fish.js.map +1 -0
- package/dist/commands/completion/tree.d.ts +33 -0
- package/dist/commands/completion/tree.d.ts.map +1 -0
- package/dist/commands/completion/tree.js +75 -0
- package/dist/commands/completion/tree.js.map +1 -0
- package/dist/commands/completion/zsh-widget.d.ts +13 -0
- package/dist/commands/completion/zsh-widget.d.ts.map +1 -0
- package/dist/commands/completion/zsh-widget.js +39 -0
- package/dist/commands/completion/zsh-widget.js.map +1 -0
- package/dist/commands/completion/zsh.d.ts +9 -0
- package/dist/commands/completion/zsh.d.ts.map +1 -0
- package/dist/commands/completion/zsh.js +146 -0
- package/dist/commands/completion/zsh.js.map +1 -0
- package/dist/commands/profile/_utils.d.ts +21 -0
- package/dist/commands/profile/_utils.d.ts.map +1 -0
- package/dist/commands/profile/_utils.js +61 -0
- package/dist/commands/profile/_utils.js.map +1 -0
- package/dist/commands/profile/profile-group.descriptor.d.ts +4 -0
- package/dist/commands/profile/profile-group.descriptor.d.ts.map +1 -0
- package/dist/commands/profile/profile-group.descriptor.js +12 -0
- package/dist/commands/profile/profile-group.descriptor.js.map +1 -0
- package/dist/commands/profile/profile.create.descriptor.d.ts +4 -0
- package/dist/commands/profile/profile.create.descriptor.d.ts.map +1 -0
- package/dist/commands/profile/profile.create.descriptor.js +22 -0
- package/dist/commands/profile/profile.create.descriptor.js.map +1 -0
- package/dist/commands/profile/profile.create.impl.d.ts +10 -0
- package/dist/commands/profile/profile.create.impl.d.ts.map +1 -0
- package/dist/commands/profile/profile.create.impl.js +29 -0
- package/dist/commands/profile/profile.create.impl.js.map +1 -0
- package/dist/commands/profile/profile.delete.descriptor.d.ts +4 -0
- package/dist/commands/profile/profile.delete.descriptor.d.ts.map +1 -0
- package/dist/commands/profile/profile.delete.descriptor.js +29 -0
- package/dist/commands/profile/profile.delete.descriptor.js.map +1 -0
- package/dist/commands/profile/profile.delete.impl.d.ts +11 -0
- package/dist/commands/profile/profile.delete.impl.d.ts.map +1 -0
- package/dist/commands/profile/profile.delete.impl.js +50 -0
- package/dist/commands/profile/profile.delete.impl.js.map +1 -0
- package/dist/commands/profile/profile.info.descriptor.d.ts +4 -0
- package/dist/commands/profile/profile.info.descriptor.d.ts.map +1 -0
- package/dist/commands/profile/profile.info.descriptor.js +23 -0
- package/dist/commands/profile/profile.info.descriptor.js.map +1 -0
- package/dist/commands/profile/profile.info.impl.d.ts +10 -0
- package/dist/commands/profile/profile.info.impl.d.ts.map +1 -0
- package/dist/commands/profile/profile.info.impl.js +33 -0
- package/dist/commands/profile/profile.info.impl.js.map +1 -0
- package/dist/commands/profile/profile.list.descriptor.d.ts +4 -0
- package/dist/commands/profile/profile.list.descriptor.d.ts.map +1 -0
- package/dist/commands/profile/profile.list.descriptor.js +16 -0
- package/dist/commands/profile/profile.list.descriptor.js.map +1 -0
- package/dist/commands/profile/profile.list.impl.d.ts +10 -0
- package/dist/commands/profile/profile.list.impl.d.ts.map +1 -0
- package/dist/commands/profile/profile.list.impl.js +33 -0
- package/dist/commands/profile/profile.list.impl.js.map +1 -0
- package/dist/commands/profile/profile.use.descriptor.d.ts +4 -0
- package/dist/commands/profile/profile.use.descriptor.d.ts.map +1 -0
- package/dist/commands/profile/profile.use.descriptor.js +23 -0
- package/dist/commands/profile/profile.use.descriptor.js.map +1 -0
- package/dist/commands/profile/profile.use.impl.d.ts +10 -0
- package/dist/commands/profile/profile.use.impl.d.ts.map +1 -0
- package/dist/commands/profile/profile.use.impl.js +24 -0
- package/dist/commands/profile/profile.use.impl.js.map +1 -0
- package/dist/commands/runtime/_logging.d.ts +11 -0
- package/dist/commands/runtime/_logging.d.ts.map +1 -0
- package/dist/commands/runtime/_logging.js +40 -0
- package/dist/commands/runtime/_logging.js.map +1 -0
- package/dist/commands/runtime/codegen.command.descriptor.d.ts +15 -0
- package/dist/commands/runtime/codegen.command.descriptor.d.ts.map +1 -0
- package/dist/commands/runtime/codegen.command.descriptor.js +18 -0
- package/dist/commands/runtime/codegen.command.descriptor.js.map +1 -0
- package/dist/commands/runtime/codegen.command.impl.d.ts +4 -0
- package/dist/commands/runtime/codegen.command.impl.d.ts.map +1 -0
- package/dist/commands/runtime/codegen.command.impl.js +39 -0
- package/dist/commands/runtime/codegen.command.impl.js.map +1 -0
- package/dist/commands/runtime/codegen.d.ts +17 -0
- package/dist/commands/runtime/codegen.d.ts.map +1 -0
- package/dist/commands/runtime/codegen.js +65 -0
- package/dist/commands/runtime/codegen.js.map +1 -0
- package/dist/commands/runtime/index.d.ts +4 -0
- package/dist/commands/runtime/index.d.ts.map +1 -0
- package/dist/commands/runtime/index.js +8 -0
- package/dist/commands/runtime/index.js.map +1 -0
- package/dist/commands/runtime/plugin.d.ts +2 -0
- package/dist/commands/runtime/plugin.d.ts.map +1 -0
- package/dist/commands/runtime/plugin.js +7 -0
- package/dist/commands/runtime/plugin.js.map +1 -0
- package/dist/commands/runtime/runtime-group.descriptor.d.ts +4 -0
- package/dist/commands/runtime/runtime-group.descriptor.d.ts.map +1 -0
- package/dist/commands/runtime/runtime-group.descriptor.js +10 -0
- package/dist/commands/runtime/runtime-group.descriptor.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +11 -0
- package/dist/config.js.map +1 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +5 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/namespace/hook.d.ts +12 -0
- package/dist/core/namespace/hook.d.ts.map +1 -0
- package/dist/core/namespace/hook.js +15 -0
- package/dist/core/namespace/hook.js.map +1 -0
- package/dist/core/namespace/index.d.ts +18 -0
- package/dist/core/namespace/index.d.ts.map +1 -0
- package/dist/core/namespace/index.js +214 -0
- package/dist/core/namespace/index.js.map +1 -0
- package/dist/core/namespace/schemas/index.d.ts +25 -0
- package/dist/core/namespace/schemas/index.d.ts.map +1 -0
- package/dist/core/namespace/schemas/index.js +2 -0
- package/dist/core/namespace/schemas/index.js.map +1 -0
- package/dist/core/plugins/types.d.ts +81 -0
- package/dist/core/plugins/types.d.ts.map +1 -0
- package/dist/core/plugins/types.js +6 -0
- package/dist/core/plugins/types.js.map +1 -0
- package/dist/core/runtime/context.d.ts +25 -0
- package/dist/core/runtime/context.d.ts.map +1 -0
- package/dist/core/runtime/context.js +30 -0
- package/dist/core/runtime/context.js.map +1 -0
- package/dist/core/runtime/hooks.d.ts +12 -0
- package/dist/core/runtime/hooks.d.ts.map +1 -0
- package/dist/core/runtime/hooks.js +2 -0
- package/dist/core/runtime/hooks.js.map +1 -0
- package/dist/core/runtime/shared/context.d.ts +33 -0
- package/dist/core/runtime/shared/context.d.ts.map +1 -0
- package/dist/core/runtime/shared/context.js +51 -0
- package/dist/core/runtime/shared/context.js.map +1 -0
- package/dist/core/runtime/shared/options.d.ts +20 -0
- package/dist/core/runtime/shared/options.d.ts.map +1 -0
- package/dist/core/runtime/shared/options.js +61 -0
- package/dist/core/runtime/shared/options.js.map +1 -0
- package/dist/core/schemas/manifest.d.ts +24 -0
- package/dist/core/schemas/manifest.d.ts.map +1 -0
- package/dist/core/schemas/manifest.js +6 -0
- package/dist/core/schemas/manifest.js.map +1 -0
- package/dist/core/schemas/types.d.ts +7 -0
- package/dist/core/schemas/types.d.ts.map +1 -0
- package/dist/core/schemas/types.js +2 -0
- package/dist/core/schemas/types.js.map +1 -0
- package/dist/core/ui/interface.d.ts +12 -0
- package/dist/core/ui/interface.d.ts.map +1 -0
- package/dist/core/ui/interface.js +6 -0
- package/dist/core/ui/interface.js.map +1 -0
- package/dist/docs/cli.commands.docs.descriptor.d.ts +4 -0
- package/dist/docs/cli.commands.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/cli.commands.docs.descriptor.js +207 -0
- package/dist/docs/cli.commands.docs.descriptor.js.map +1 -0
- package/dist/docs/cli.groups.docs.descriptor.d.ts +4 -0
- package/dist/docs/cli.groups.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/cli.groups.docs.descriptor.js +330 -0
- package/dist/docs/cli.groups.docs.descriptor.js.map +1 -0
- package/dist/docs/cli.output.docs.descriptor.d.ts +4 -0
- package/dist/docs/cli.output.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/cli.output.docs.descriptor.js +442 -0
- package/dist/docs/cli.output.docs.descriptor.js.map +1 -0
- package/dist/docs/types.d.ts +19 -0
- package/dist/docs/types.d.ts.map +1 -0
- package/dist/docs/types.js +2 -0
- package/dist/docs/types.js.map +1 -0
- package/dist/errors.d.ts +74 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +113 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/cli-startup.logger.descriptor.d.ts +7 -0
- package/dist/logging/cli-startup.logger.descriptor.d.ts.map +1 -0
- package/dist/logging/cli-startup.logger.descriptor.js +13 -0
- package/dist/logging/cli-startup.logger.descriptor.js.map +1 -0
- package/dist/logging.d.ts +4 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +21 -0
- package/dist/logging.js.map +1 -0
- package/dist/patterns/config-namespace.d.ts +23 -0
- package/dist/patterns/config-namespace.d.ts.map +1 -0
- package/dist/patterns/config-namespace.js +218 -0
- package/dist/patterns/config-namespace.js.map +1 -0
- package/dist/patterns/crud.d.ts +23 -0
- package/dist/patterns/crud.d.ts.map +1 -0
- package/dist/patterns/crud.js +164 -0
- package/dist/patterns/crud.js.map +1 -0
- package/dist/patterns/index.d.ts +13 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +13 -0
- package/dist/patterns/index.js.map +1 -0
- package/dist/patterns/log-viewer.d.ts +19 -0
- package/dist/patterns/log-viewer.d.ts.map +1 -0
- package/dist/patterns/log-viewer.js +74 -0
- package/dist/patterns/log-viewer.js.map +1 -0
- package/dist/patterns/pattern-types.d.ts +21 -0
- package/dist/patterns/pattern-types.d.ts.map +1 -0
- package/dist/patterns/pattern-types.js +7 -0
- package/dist/patterns/pattern-types.js.map +1 -0
- package/dist/patterns/process-manager.d.ts +21 -0
- package/dist/patterns/process-manager.d.ts.map +1 -0
- package/dist/patterns/process-manager.js +134 -0
- package/dist/patterns/process-manager.js.map +1 -0
- package/dist/patterns/resolver.contracts.d.ts +14 -0
- package/dist/patterns/resolver.contracts.d.ts.map +1 -0
- package/dist/patterns/resolver.contracts.js +9 -0
- package/dist/patterns/resolver.contracts.js.map +1 -0
- package/dist/patterns/resolver.d.ts +40 -0
- package/dist/patterns/resolver.d.ts.map +1 -0
- package/dist/patterns/resolver.js +63 -0
- package/dist/patterns/resolver.js.map +1 -0
- package/dist/patterns/schemas.d.ts +496 -0
- package/dist/patterns/schemas.d.ts.map +1 -0
- package/dist/patterns/schemas.js +105 -0
- package/dist/patterns/schemas.js.map +1 -0
- package/dist/patterns/tool-wrapper.d.ts +18 -0
- package/dist/patterns/tool-wrapper.d.ts.map +1 -0
- package/dist/patterns/tool-wrapper.js +130 -0
- package/dist/patterns/tool-wrapper.js.map +1 -0
- package/dist/providers.d.ts +105 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +164 -0
- package/dist/providers.js.map +1 -0
- package/dist/schemas/descriptors.d.ts +130 -0
- package/dist/schemas/descriptors.d.ts.map +1 -0
- package/dist/schemas/descriptors.js +96 -0
- package/dist/schemas/descriptors.js.map +1 -0
- package/dist/schemas/surface.d.ts +40 -0
- package/dist/schemas/surface.d.ts.map +1 -0
- package/dist/schemas/surface.js +2 -0
- package/dist/schemas/surface.js.map +1 -0
- package/dist/schemas/types.d.ts +202 -0
- package/dist/schemas/types.d.ts.map +1 -0
- package/dist/schemas/types.js +2 -0
- package/dist/schemas/types.js.map +1 -0
- package/dist/support/ui-toolkit.d.ts +62 -0
- package/dist/support/ui-toolkit.d.ts.map +1 -0
- package/dist/support/ui-toolkit.js +172 -0
- package/dist/support/ui-toolkit.js.map +1 -0
- package/dist/surface/CLISurface.d.ts +16 -0
- package/dist/surface/CLISurface.d.ts.map +1 -0
- package/dist/surface/CLISurface.js +173 -0
- package/dist/surface/CLISurface.js.map +1 -0
- package/dist/surface/attach-tui-action.d.ts +12 -0
- package/dist/surface/attach-tui-action.d.ts.map +1 -0
- package/dist/surface/attach-tui-action.js +48 -0
- package/dist/surface/attach-tui-action.js.map +1 -0
- package/dist/surface/build-context.d.ts +4 -0
- package/dist/surface/build-context.d.ts.map +1 -0
- package/dist/surface/build-context.js +49 -0
- package/dist/surface/build-context.js.map +1 -0
- package/dist/surface/command-group-policy.d.ts +7 -0
- package/dist/surface/command-group-policy.d.ts.map +1 -0
- package/dist/surface/command-group-policy.js +42 -0
- package/dist/surface/command-group-policy.js.map +1 -0
- package/dist/surface/discovery-cache.d.ts +17 -0
- package/dist/surface/discovery-cache.d.ts.map +1 -0
- package/dist/surface/discovery-cache.js +106 -0
- package/dist/surface/discovery-cache.js.map +1 -0
- package/dist/surface/register-commands.d.ts +15 -0
- package/dist/surface/register-commands.d.ts.map +1 -0
- package/dist/surface/register-commands.js +197 -0
- package/dist/surface/register-commands.js.map +1 -0
- package/dist/surface/register-groups.d.ts +15 -0
- package/dist/surface/register-groups.d.ts.map +1 -0
- package/dist/surface/register-groups.js +52 -0
- package/dist/surface/register-groups.js.map +1 -0
- package/dist/surface.d.ts +9 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +8 -0
- package/dist/surface.js.map +1 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/schemas/types.d.ts +2 -0
- package/dist/ui/schemas/types.d.ts.map +1 -0
- package/dist/ui/schemas/types.js +2 -0
- package/dist/ui/schemas/types.js.map +1 -0
- package/dist/ui/toolkit/VibesUIToolkit.d.ts +2 -0
- package/dist/ui/toolkit/VibesUIToolkit.d.ts.map +1 -0
- package/dist/ui/toolkit/VibesUIToolkit.js +2 -0
- package/dist/ui/toolkit/VibesUIToolkit.js.map +1 -0
- package/dist/ui.context.descriptor.d.ts +21 -0
- package/dist/ui.context.descriptor.d.ts.map +1 -0
- package/dist/ui.context.descriptor.js +12 -0
- package/dist/ui.context.descriptor.js.map +1 -0
- package/dist/utils/open.d.ts +2 -0
- package/dist/utils/open.d.ts.map +1 -0
- package/dist/utils/open.js +30 -0
- package/dist/utils/open.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +186 -0
- package/src/api/client/factory.ts +265 -0
- package/src/api/schemas/common.ts +50 -0
- package/src/api/schemas/types.ts +32 -0
- package/src/api/services/api.ts +129 -0
- package/src/api/types.ts +12 -0
- package/src/bin.ts +84 -0
- package/src/bootstrap.ts +19 -0
- package/src/cli.plugin.d.ts +19 -0
- package/src/cli.plugin.ts +202 -0
- package/src/commands/completion/bash.ts +68 -0
- package/src/commands/completion/completion.descriptor.ts +48 -0
- package/src/commands/completion/completion.impl.ts +188 -0
- package/src/commands/completion/fig.ts +78 -0
- package/src/commands/completion/fish.ts +52 -0
- package/src/commands/completion/tree.ts +115 -0
- package/src/commands/completion/zsh-widget.ts +39 -0
- package/src/commands/completion/zsh.ts +165 -0
- package/src/commands/profile/_utils.ts +72 -0
- package/src/commands/profile/profile-group.descriptor.ts +14 -0
- package/src/commands/profile/profile.create.descriptor.ts +24 -0
- package/src/commands/profile/profile.create.impl.ts +44 -0
- package/src/commands/profile/profile.delete.descriptor.ts +31 -0
- package/src/commands/profile/profile.delete.impl.ts +71 -0
- package/src/commands/profile/profile.info.descriptor.ts +25 -0
- package/src/commands/profile/profile.info.impl.ts +51 -0
- package/src/commands/profile/profile.list.descriptor.ts +18 -0
- package/src/commands/profile/profile.list.impl.ts +46 -0
- package/src/commands/profile/profile.use.descriptor.ts +25 -0
- package/src/commands/profile/profile.use.impl.ts +39 -0
- package/src/commands/runtime/_logging.ts +47 -0
- package/src/commands/runtime/codegen.command.descriptor.ts +18 -0
- package/src/commands/runtime/codegen.command.impl.ts +44 -0
- package/src/commands/runtime/codegen.ts +84 -0
- package/src/commands/runtime/index.ts +14 -0
- package/src/commands/runtime/plugin.ts +7 -0
- package/src/commands/runtime/runtime-group.descriptor.ts +12 -0
- package/src/config.ts +22 -0
- package/src/core/index.ts +9 -0
- package/src/core/namespace/hook.ts +25 -0
- package/src/core/namespace/index.ts +298 -0
- package/src/core/namespace/schemas/index.ts +25 -0
- package/src/core/plugins/types.ts +87 -0
- package/src/core/runtime/context.ts +50 -0
- package/src/core/runtime/hooks.ts +12 -0
- package/src/core/runtime/shared/context.ts +65 -0
- package/src/core/runtime/shared/options.ts +60 -0
- package/src/core/schemas/manifest.ts +26 -0
- package/src/core/schemas/types.ts +6 -0
- package/src/core/ui/interface.ts +12 -0
- package/src/docs/cli.commands.docs.descriptor.ts +210 -0
- package/src/docs/cli.groups.docs.descriptor.ts +333 -0
- package/src/docs/cli.output.docs.descriptor.ts +445 -0
- package/src/docs/types.ts +18 -0
- package/src/errors.ts +123 -0
- package/src/index.ts +76 -0
- package/src/logging/cli-startup.logger.descriptor.ts +16 -0
- package/src/logging.ts +35 -0
- package/src/patterns/config-namespace.ts +251 -0
- package/src/patterns/crud.ts +217 -0
- package/src/patterns/index.ts +24 -0
- package/src/patterns/log-viewer.ts +118 -0
- package/src/patterns/pattern-types.ts +22 -0
- package/src/patterns/process-manager.ts +180 -0
- package/src/patterns/resolver.contracts.ts +15 -0
- package/src/patterns/resolver.ts +86 -0
- package/src/patterns/schemas.ts +146 -0
- package/src/patterns/tool-wrapper.ts +165 -0
- package/src/providers.ts +282 -0
- package/src/schemas/descriptors.d.ts +119 -0
- package/src/schemas/descriptors.ts +136 -0
- package/src/schemas/surface.ts +52 -0
- package/src/schemas/types.d.ts +195 -0
- package/src/schemas/types.ts +225 -0
- package/src/support/ui-toolkit.ts +224 -0
- package/src/surface/CLISurface.ts +193 -0
- package/src/surface/attach-tui-action.ts +76 -0
- package/src/surface/build-context.ts +49 -0
- package/src/surface/command-group-policy.ts +52 -0
- package/src/surface/discovery-cache.ts +143 -0
- package/src/surface/register-commands.ts +266 -0
- package/src/surface/register-groups.ts +84 -0
- package/src/surface.ts +9 -0
- package/src/types.ts +3 -0
- package/src/ui/schemas/types.ts +1 -0
- package/src/ui/toolkit/VibesUIToolkit.ts +1 -0
- package/src/ui.context.descriptor.ts +13 -0
- package/src/utils/open.ts +36 -0
- package/src/version.ts +10 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process Manager Pattern Implementation
|
|
3
|
+
*
|
|
4
|
+
* Generates start/stop/restart/status commands for a daemon.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Command } from 'commander';
|
|
8
|
+
import type { VibesRuntime } from '@vibesdotdev/runtime/api/runtime';
|
|
9
|
+
import type { CLIProcessManagerGroupDescriptor } from './schemas';
|
|
10
|
+
import type { PatternImplementation } from './pattern-types';
|
|
11
|
+
import type { CommandContext } from '../schemas/surface';
|
|
12
|
+
|
|
13
|
+
/** Extended context with PM client available */
|
|
14
|
+
interface PMCommandContext extends CommandContext {
|
|
15
|
+
pm?: {
|
|
16
|
+
start(processId: string, opts: Record<string, unknown>): Promise<void>;
|
|
17
|
+
stop(processId: string, opts: Record<string, unknown>): Promise<void>;
|
|
18
|
+
restart(processId: string, opts: Record<string, unknown>): Promise<void>;
|
|
19
|
+
status(processId: string): Promise<Record<string, unknown>>;
|
|
20
|
+
logs(processId: string, opts: Record<string, unknown>): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class ProcessManagerPatternImpl implements PatternImplementation<CLIProcessManagerGroupDescriptor> {
|
|
25
|
+
constructor(private runtime: VibesRuntime) {}
|
|
26
|
+
|
|
27
|
+
async register(
|
|
28
|
+
descriptor: CLIProcessManagerGroupDescriptor,
|
|
29
|
+
parent: Command,
|
|
30
|
+
context: CommandContext
|
|
31
|
+
): Promise<void> {
|
|
32
|
+
const { name, description, processManager } = descriptor;
|
|
33
|
+
const cmds = processManager.commands ?? {};
|
|
34
|
+
|
|
35
|
+
const groupCmd = parent.command(name).description(description);
|
|
36
|
+
|
|
37
|
+
if (cmds.start !== false) this.registerStart(groupCmd, descriptor, context);
|
|
38
|
+
if (cmds.stop !== false) this.registerStop(groupCmd, descriptor, context);
|
|
39
|
+
if (cmds.restart !== false) this.registerRestart(groupCmd, descriptor, context);
|
|
40
|
+
if (cmds.status !== false) this.registerStatus(groupCmd, descriptor, context);
|
|
41
|
+
if (cmds.logs !== false) this.registerLogs(groupCmd, descriptor, context);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private registerStart(
|
|
45
|
+
parent: Command,
|
|
46
|
+
d: CLIProcessManagerGroupDescriptor,
|
|
47
|
+
ctx: CommandContext
|
|
48
|
+
): void {
|
|
49
|
+
parent
|
|
50
|
+
.command('start')
|
|
51
|
+
.description(`Start ${d.name}`)
|
|
52
|
+
.option('--detach', 'Run in background', true)
|
|
53
|
+
.option('--env <vars...>', 'Environment variables')
|
|
54
|
+
.action(async (opts) => {
|
|
55
|
+
const pm = (ctx as PMCommandContext).pm;
|
|
56
|
+
if (!pm?.start) {
|
|
57
|
+
ctx.ui?.error('Process manager not available');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const env: Record<string, string> = {};
|
|
62
|
+
if (opts.env) {
|
|
63
|
+
for (const pair of opts.env) {
|
|
64
|
+
const [k, ...v] = pair.split('=');
|
|
65
|
+
env[k] = v.join('=');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await pm.start(d.processManager.processId, { detach: opts.detach, env });
|
|
70
|
+
ctx.ui?.success(`Started ${d.name}`);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private registerStop(
|
|
75
|
+
parent: Command,
|
|
76
|
+
d: CLIProcessManagerGroupDescriptor,
|
|
77
|
+
ctx: CommandContext
|
|
78
|
+
): void {
|
|
79
|
+
parent
|
|
80
|
+
.command('stop')
|
|
81
|
+
.description(`Stop ${d.name}`)
|
|
82
|
+
.option('--force', 'Force stop')
|
|
83
|
+
.option('--timeout <s>', 'Timeout', '10')
|
|
84
|
+
.action(async (opts) => {
|
|
85
|
+
const pm = (ctx as PMCommandContext).pm;
|
|
86
|
+
if (!pm?.stop) {
|
|
87
|
+
ctx.ui?.error('Process manager not available');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
await pm.stop(d.processManager.processId, {
|
|
92
|
+
force: opts.force,
|
|
93
|
+
timeout: parseInt(opts.timeout, 10) * 1000
|
|
94
|
+
});
|
|
95
|
+
ctx.ui?.success(`Stopped ${d.name}`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private registerRestart(
|
|
100
|
+
parent: Command,
|
|
101
|
+
d: CLIProcessManagerGroupDescriptor,
|
|
102
|
+
ctx: CommandContext
|
|
103
|
+
): void {
|
|
104
|
+
parent
|
|
105
|
+
.command('restart')
|
|
106
|
+
.description(`Restart ${d.name}`)
|
|
107
|
+
.option('--force', 'Force restart')
|
|
108
|
+
.action(async (opts) => {
|
|
109
|
+
const pm = (ctx as PMCommandContext).pm;
|
|
110
|
+
if (!pm?.restart) {
|
|
111
|
+
ctx.ui?.error('Process manager not available');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
await pm.restart(d.processManager.processId, { force: opts.force });
|
|
116
|
+
ctx.ui?.success(`Restarted ${d.name}`);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
private registerStatus(
|
|
121
|
+
parent: Command,
|
|
122
|
+
d: CLIProcessManagerGroupDescriptor,
|
|
123
|
+
ctx: CommandContext
|
|
124
|
+
): void {
|
|
125
|
+
parent
|
|
126
|
+
.command('status')
|
|
127
|
+
.description(`Show status of ${d.name}`)
|
|
128
|
+
.option('-f, --format <format>', 'Output format', 'table')
|
|
129
|
+
.option('--health', 'Include health check')
|
|
130
|
+
.action(async (opts) => {
|
|
131
|
+
const pm = (ctx as PMCommandContext).pm;
|
|
132
|
+
if (!pm?.status) {
|
|
133
|
+
ctx.ui?.error('Process manager not available');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const status = await pm.status(d.processManager.processId);
|
|
138
|
+
|
|
139
|
+
if (opts.health && d.processManager.healthCheck?.url) {
|
|
140
|
+
try {
|
|
141
|
+
const res = await fetch(d.processManager.healthCheck.url);
|
|
142
|
+
status.health = { ok: res.ok, code: res.status };
|
|
143
|
+
} catch (e) {
|
|
144
|
+
status.health = { ok: false, error: String(e) };
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (opts.format === 'json') {
|
|
149
|
+
ctx.ui?.json(status);
|
|
150
|
+
} else {
|
|
151
|
+
ctx.ui?.info(`${d.name}: ${status.state ?? 'unknown'}`);
|
|
152
|
+
if (status.pid) ctx.ui?.info(` PID: ${status.pid}`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private registerLogs(
|
|
158
|
+
parent: Command,
|
|
159
|
+
d: CLIProcessManagerGroupDescriptor,
|
|
160
|
+
ctx: CommandContext
|
|
161
|
+
): void {
|
|
162
|
+
parent
|
|
163
|
+
.command('logs')
|
|
164
|
+
.description(`View logs for ${d.name}`)
|
|
165
|
+
.option('-n, --lines <n>', 'Lines', '50')
|
|
166
|
+
.option('-f, --follow', 'Follow')
|
|
167
|
+
.action(async (opts) => {
|
|
168
|
+
const pm = (ctx as PMCommandContext).pm;
|
|
169
|
+
if (!pm?.logs) {
|
|
170
|
+
ctx.ui?.error('Process manager not available');
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
await pm.logs(d.processManager.processId, {
|
|
175
|
+
lines: parseInt(opts.lines, 10),
|
|
176
|
+
follow: opts.follow
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pattern resolver contracts.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `./resolver.ts` so each pattern implementation can
|
|
5
|
+
* implement `PatternImplementation` without forming a cycle back through
|
|
6
|
+
* the resolver (which itself dynamically imports the pattern modules).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { Command } from 'commander';
|
|
10
|
+
import type { CommandContext } from '../schemas/surface';
|
|
11
|
+
import type { CLIPatternDescriptor } from './schemas';
|
|
12
|
+
|
|
13
|
+
export interface PatternImplementation<TDescriptor extends CLIPatternDescriptor> {
|
|
14
|
+
register(descriptor: TDescriptor, parent: Command, context: CommandContext): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Pattern Resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves pattern descriptors to Commander.js commands.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Command } from 'commander';
|
|
8
|
+
import type { VibesRuntime } from '@vibesdotdev/runtime/api/runtime';
|
|
9
|
+
import type { CLIPatternDescriptor } from './schemas';
|
|
10
|
+
import { isPatternDescriptor, getPatternType } from './schemas';
|
|
11
|
+
import { CRUDPatternImpl } from './crud';
|
|
12
|
+
import { ToolWrapperPatternImpl } from './tool-wrapper';
|
|
13
|
+
import { LogViewerPatternImpl } from './log-viewer';
|
|
14
|
+
import { ProcessManagerPatternImpl } from './process-manager';
|
|
15
|
+
import { ConfigNamespacePatternImpl } from './config-namespace';
|
|
16
|
+
import type { CommandContext } from '../schemas/surface';
|
|
17
|
+
import type { PatternImplementation } from './pattern-types';
|
|
18
|
+
export type { PatternImplementation } from './pattern-types';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Pattern resolver
|
|
22
|
+
*/
|
|
23
|
+
export class PatternResolver {
|
|
24
|
+
private patterns = new Map<string, PatternImplementation<any>>();
|
|
25
|
+
|
|
26
|
+
constructor(private runtime: VibesRuntime) {}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register a pattern implementation
|
|
30
|
+
*/
|
|
31
|
+
registerPattern<T extends CLIPatternDescriptor>(
|
|
32
|
+
patternType: string,
|
|
33
|
+
implementation: PatternImplementation<T>
|
|
34
|
+
): void {
|
|
35
|
+
this.patterns.set(patternType, implementation);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Check if descriptor is a pattern
|
|
40
|
+
*/
|
|
41
|
+
isPattern(descriptor: unknown): descriptor is CLIPatternDescriptor {
|
|
42
|
+
return isPatternDescriptor(descriptor);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resolve and register a pattern descriptor
|
|
47
|
+
*/
|
|
48
|
+
async resolve(
|
|
49
|
+
descriptor: CLIPatternDescriptor,
|
|
50
|
+
parent: Command,
|
|
51
|
+
context: CommandContext
|
|
52
|
+
): Promise<void> {
|
|
53
|
+
const patternType = getPatternType(descriptor);
|
|
54
|
+
const impl = this.patterns.get(patternType);
|
|
55
|
+
|
|
56
|
+
if (!impl) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`No pattern implementation for '${patternType}'. Available: ${[...this.patterns.keys()].join(', ')}`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
await impl.register(descriptor, parent, context);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get available pattern types
|
|
67
|
+
*/
|
|
68
|
+
getPatternTypes(): string[] {
|
|
69
|
+
return [...this.patterns.keys()];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Create pattern resolver with built-in patterns
|
|
75
|
+
*/
|
|
76
|
+
export async function createPatternResolver(runtime: VibesRuntime): Promise<PatternResolver> {
|
|
77
|
+
const resolver = new PatternResolver(runtime);
|
|
78
|
+
|
|
79
|
+
resolver.registerPattern('crud', new CRUDPatternImpl(runtime));
|
|
80
|
+
resolver.registerPattern('tool-wrapper', new ToolWrapperPatternImpl(runtime));
|
|
81
|
+
resolver.registerPattern('log-viewer', new LogViewerPatternImpl(runtime));
|
|
82
|
+
resolver.registerPattern('process-manager', new ProcessManagerPatternImpl(runtime));
|
|
83
|
+
resolver.registerPattern('config-namespace', new ConfigNamespacePatternImpl(runtime));
|
|
84
|
+
|
|
85
|
+
return resolver;
|
|
86
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Pattern Schemas
|
|
3
|
+
*
|
|
4
|
+
* Extended CLI descriptor schemas that support pattern-based command generation.
|
|
5
|
+
* Uses pattern schemas from the universal runtime.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as z from 'zod/v4';
|
|
9
|
+
import { RuntimeDescriptorSchema } from '@vibesdotdev/runtime/schemas/descriptor';
|
|
10
|
+
import {
|
|
11
|
+
type ConfigNamespacePatternConfig,
|
|
12
|
+
type CRUDPatternConfig,
|
|
13
|
+
type LogViewerPatternConfig,
|
|
14
|
+
PatternTargetSchema,
|
|
15
|
+
CRUDPatternConfigSchema,
|
|
16
|
+
ToolWrapperPatternConfigSchema,
|
|
17
|
+
LogViewerPatternConfigSchema,
|
|
18
|
+
ProcessManagerPatternConfigSchema,
|
|
19
|
+
ConfigNamespacePatternConfigSchema,
|
|
20
|
+
type PatternTarget,
|
|
21
|
+
type ProcessManagerPatternConfig,
|
|
22
|
+
type ToolWrapperPatternConfig
|
|
23
|
+
} from '@vibesdotdev/runtime/schemas/pattern';
|
|
24
|
+
import type {
|
|
25
|
+
CLIConfigNamespaceGroupDescriptor,
|
|
26
|
+
CLICRUDGroupDescriptor,
|
|
27
|
+
CLILogViewerGroupDescriptor,
|
|
28
|
+
CLIPatternDescriptor,
|
|
29
|
+
CLIProcessManagerGroupDescriptor,
|
|
30
|
+
CLIToolWrapperCommandDescriptor
|
|
31
|
+
} from '../schemas/types';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* CLI Group with CRUD pattern
|
|
35
|
+
*/
|
|
36
|
+
export const CLICRUDGroupDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
37
|
+
kind: z.literal('cli/group'),
|
|
38
|
+
name: z.string().min(1),
|
|
39
|
+
description: z.string().min(1),
|
|
40
|
+
parent: z.string().optional(),
|
|
41
|
+
pattern: z.literal('crud'),
|
|
42
|
+
target: PatternTargetSchema,
|
|
43
|
+
crud: CRUDPatternConfigSchema,
|
|
44
|
+
surfaces: z.array(z.enum(['cli', 'web', 'worker', 'bridge'])).default(['cli']),
|
|
45
|
+
internal: z.boolean().default(false)
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* CLI Command with tool-wrapper pattern
|
|
50
|
+
*/
|
|
51
|
+
export const CLIToolWrapperCommandDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
52
|
+
kind: z.literal('cli/command'),
|
|
53
|
+
name: z.string().min(1),
|
|
54
|
+
description: z.string().optional(),
|
|
55
|
+
group: z.string().min(1),
|
|
56
|
+
pattern: z.literal('tool-wrapper'),
|
|
57
|
+
target: PatternTargetSchema,
|
|
58
|
+
toolWrapper: ToolWrapperPatternConfigSchema,
|
|
59
|
+
surfaces: z.array(z.enum(['cli', 'web', 'worker', 'bridge'])).default(['cli']),
|
|
60
|
+
internal: z.boolean().default(false),
|
|
61
|
+
order: z.number().int().optional()
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* CLI Group with log-viewer pattern
|
|
66
|
+
*/
|
|
67
|
+
export const CLILogViewerGroupDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
68
|
+
kind: z.literal('cli/group'),
|
|
69
|
+
name: z.string().min(1),
|
|
70
|
+
description: z.string().min(1),
|
|
71
|
+
parent: z.string().optional(),
|
|
72
|
+
pattern: z.literal('log-viewer'),
|
|
73
|
+
target: PatternTargetSchema,
|
|
74
|
+
logViewer: LogViewerPatternConfigSchema,
|
|
75
|
+
surfaces: z.array(z.enum(['cli', 'web', 'worker', 'bridge'])).default(['cli']),
|
|
76
|
+
internal: z.boolean().default(false)
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* CLI Group with process-manager pattern
|
|
81
|
+
*/
|
|
82
|
+
export const CLIProcessManagerGroupDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
83
|
+
kind: z.literal('cli/group'),
|
|
84
|
+
name: z.string().min(1),
|
|
85
|
+
description: z.string().min(1),
|
|
86
|
+
parent: z.string().optional(),
|
|
87
|
+
pattern: z.literal('process-manager'),
|
|
88
|
+
target: PatternTargetSchema,
|
|
89
|
+
processManager: ProcessManagerPatternConfigSchema,
|
|
90
|
+
surfaces: z.array(z.enum(['cli', 'web', 'worker', 'bridge'])).default(['cli']),
|
|
91
|
+
internal: z.boolean().default(false)
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* CLI Group with config-namespace pattern
|
|
96
|
+
*/
|
|
97
|
+
export const CLIConfigNamespaceGroupDescriptorSchema = RuntimeDescriptorSchema.extend({
|
|
98
|
+
kind: z.literal('cli/group'),
|
|
99
|
+
name: z.string().min(1),
|
|
100
|
+
description: z.string().min(1),
|
|
101
|
+
parent: z.string().optional(),
|
|
102
|
+
pattern: z.literal('config-namespace'),
|
|
103
|
+
target: PatternTargetSchema.optional(),
|
|
104
|
+
configNamespace: ConfigNamespacePatternConfigSchema,
|
|
105
|
+
surfaces: z.array(z.enum(['cli', 'web', 'worker', 'bridge'])).default(['cli']),
|
|
106
|
+
internal: z.boolean().default(false)
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Union of all pattern-based CLI descriptors
|
|
111
|
+
*/
|
|
112
|
+
export const CLIPatternDescriptorSchema = z.union([
|
|
113
|
+
CLICRUDGroupDescriptorSchema,
|
|
114
|
+
CLIToolWrapperCommandDescriptorSchema,
|
|
115
|
+
CLILogViewerGroupDescriptorSchema,
|
|
116
|
+
CLIProcessManagerGroupDescriptorSchema,
|
|
117
|
+
CLIConfigNamespaceGroupDescriptorSchema
|
|
118
|
+
]);
|
|
119
|
+
|
|
120
|
+
export type {
|
|
121
|
+
CLIConfigNamespaceGroupDescriptor,
|
|
122
|
+
CLICRUDGroupDescriptor,
|
|
123
|
+
CLILogViewerGroupDescriptor,
|
|
124
|
+
CLIPatternDescriptor,
|
|
125
|
+
CLIProcessManagerGroupDescriptor,
|
|
126
|
+
CLIToolWrapperCommandDescriptor
|
|
127
|
+
} from '../schemas/types';
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Type guard for pattern descriptors
|
|
131
|
+
*/
|
|
132
|
+
export function isPatternDescriptor(descriptor: unknown): descriptor is CLIPatternDescriptor {
|
|
133
|
+
if (!descriptor || typeof descriptor !== 'object') return false;
|
|
134
|
+
return (
|
|
135
|
+
'pattern' in descriptor && typeof (descriptor as Record<string, unknown>).pattern === 'string'
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get pattern type from descriptor
|
|
141
|
+
*/
|
|
142
|
+
export function getPatternType(
|
|
143
|
+
descriptor: CLIPatternDescriptor
|
|
144
|
+
): 'crud' | 'tool-wrapper' | 'log-viewer' | 'process-manager' | 'config-namespace' {
|
|
145
|
+
return descriptor.pattern;
|
|
146
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Wrapper Pattern Implementation
|
|
3
|
+
*
|
|
4
|
+
* Wraps a tools/tool as a CLI command.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Command } from 'commander';
|
|
8
|
+
import type { VibesRuntime } from '@vibesdotdev/runtime/api/runtime';
|
|
9
|
+
import type { CLIToolWrapperCommandDescriptor } from './schemas';
|
|
10
|
+
import type { PatternImplementation } from './pattern-types';
|
|
11
|
+
import type { CommandContext } from '../schemas/surface';
|
|
12
|
+
import type { ToolCallContext } from '@vibesdotdev/runtime/schemas/tool-call';
|
|
13
|
+
import type { LoggerImplementation } from '@vibesdotdev/logging/kinds/logger';
|
|
14
|
+
|
|
15
|
+
type ToolAssetDescriptor = {
|
|
16
|
+
id: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type ToolImplementation = {
|
|
22
|
+
execute(input: Record<string, unknown>, runtime: VibesRuntime, context: ToolCallContext): Promise<unknown>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export class ToolWrapperPatternImpl implements PatternImplementation<CLIToolWrapperCommandDescriptor> {
|
|
26
|
+
constructor(private runtime: VibesRuntime) {}
|
|
27
|
+
|
|
28
|
+
async register(
|
|
29
|
+
descriptor: CLIToolWrapperCommandDescriptor,
|
|
30
|
+
parent: Command,
|
|
31
|
+
context: CommandContext
|
|
32
|
+
): Promise<void> {
|
|
33
|
+
const { target, toolWrapper, name, group } = descriptor;
|
|
34
|
+
|
|
35
|
+
// Get tool descriptor for metadata
|
|
36
|
+
const toolDesc = this.runtime
|
|
37
|
+
.query(target.kind)
|
|
38
|
+
.withId(target.id)
|
|
39
|
+
.firstDescriptor() as ToolAssetDescriptor | null;
|
|
40
|
+
|
|
41
|
+
const description = descriptor.description ?? toolDesc?.description ?? `Run ${name}`;
|
|
42
|
+
|
|
43
|
+
const cmd = parent.command(name).description(description);
|
|
44
|
+
|
|
45
|
+
// Add arguments
|
|
46
|
+
if (toolWrapper?.arguments) {
|
|
47
|
+
for (const arg of toolWrapper.arguments) {
|
|
48
|
+
const variadic = arg.variadic ? '...' : '';
|
|
49
|
+
const spec = arg.required ? `<${arg.name}${variadic}>` : `[${arg.name}${variadic}]`;
|
|
50
|
+
cmd.argument(spec, arg.description ?? arg.name);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Add options
|
|
55
|
+
if (toolWrapper?.options) {
|
|
56
|
+
for (const opt of toolWrapper.options) {
|
|
57
|
+
// Note: In Commander.js, choices must be added as part of addOption(), not chained
|
|
58
|
+
if (opt.choices && opt.choices.length > 0) {
|
|
59
|
+
const { Option } = await import('commander');
|
|
60
|
+
const option = new Option(opt.flags, opt.description ?? opt.toolParam);
|
|
61
|
+
if (opt.default !== undefined) option.default(opt.default);
|
|
62
|
+
option.choices(opt.choices);
|
|
63
|
+
cmd.addOption(option);
|
|
64
|
+
} else {
|
|
65
|
+
cmd.option(opt.flags, opt.description ?? opt.toolParam, opt.default as string);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Add output format option (avoid clashing with global --format)
|
|
71
|
+
const outputCfg = toolWrapper?.output ?? { format: 'raw' as const };
|
|
72
|
+
cmd.option('--output-format <format>', 'Output format', outputCfg.format);
|
|
73
|
+
|
|
74
|
+
cmd.action(async (...args: unknown[]) => {
|
|
75
|
+
const opts = args.pop() as Record<string, unknown>;
|
|
76
|
+
const posArgs = args as unknown[];
|
|
77
|
+
|
|
78
|
+
// Build tool input
|
|
79
|
+
const input: Record<string, unknown> = {};
|
|
80
|
+
|
|
81
|
+
if (toolWrapper?.arguments) {
|
|
82
|
+
toolWrapper.arguments.forEach((arg: (typeof toolWrapper.arguments)[number], i: number) => {
|
|
83
|
+
if (i < posArgs.length) {
|
|
84
|
+
input[arg.toolParam] = posArgs[i];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (toolWrapper?.options) {
|
|
90
|
+
for (const opt of toolWrapper.options) {
|
|
91
|
+
const optName = this.extractOptionName(opt.flags);
|
|
92
|
+
if (opts[optName] !== undefined) {
|
|
93
|
+
input[opt.toolParam] = opts[optName];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Execute tool
|
|
99
|
+
const tool = await this.runtime.resolve<ToolImplementation>(target.kind, target.id);
|
|
100
|
+
const logger = await this.runtime.resolve<LoggerImplementation>('logging/logger', 'cli');
|
|
101
|
+
const toolCallCtx: ToolCallContext = {
|
|
102
|
+
callId: `cli:${target.id}:${Date.now()}`,
|
|
103
|
+
logger: logger.child(target.id)
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const result = await tool.execute(input, this.runtime, toolCallCtx);
|
|
107
|
+
|
|
108
|
+
this.output(
|
|
109
|
+
result,
|
|
110
|
+
String(opts.outputFormat ?? outputCfg.format),
|
|
111
|
+
context,
|
|
112
|
+
outputCfg.extractField
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private extractOptionName(flags: string): string {
|
|
118
|
+
const long = flags.match(/--(\w[\w-]*)/);
|
|
119
|
+
if (long) return long[1].replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
120
|
+
const short = flags.match(/-(\w)/);
|
|
121
|
+
if (short) return short[1];
|
|
122
|
+
throw new Error(`Cannot extract option name from: ${flags}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private output(data: unknown, format: string, ctx: CommandContext, extractField?: string): void {
|
|
126
|
+
let output = data;
|
|
127
|
+
if (extractField && typeof data === 'object' && data !== null) {
|
|
128
|
+
output = (data as Record<string, unknown>)[extractField] ?? data;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!ctx.ui) {
|
|
132
|
+
if (format === 'raw' && typeof output === 'string') {
|
|
133
|
+
process.stdout.write(`${output}\n`);
|
|
134
|
+
} else {
|
|
135
|
+
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
switch (format) {
|
|
141
|
+
case 'raw':
|
|
142
|
+
if (typeof output === 'string') {
|
|
143
|
+
process.stdout.write(`${output}\n`);
|
|
144
|
+
} else {
|
|
145
|
+
ctx.ui.json(output);
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
case 'json':
|
|
149
|
+
ctx.ui.json(output);
|
|
150
|
+
break;
|
|
151
|
+
case 'yaml':
|
|
152
|
+
ctx.ui.yaml(output);
|
|
153
|
+
break;
|
|
154
|
+
case 'table':
|
|
155
|
+
if (Array.isArray(output)) {
|
|
156
|
+
ctx.ui.table(output);
|
|
157
|
+
} else {
|
|
158
|
+
ctx.ui.yaml(output);
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
ctx.ui.json(output);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|