@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
package/package.json
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibesdotdev/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"vibes": "./bin/vibes.ts"
|
|
7
|
+
},
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"bun": "./src/index.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./bootstrap": {
|
|
18
|
+
"types": "./dist/bootstrap.d.ts",
|
|
19
|
+
"bun": "./src/bootstrap.ts",
|
|
20
|
+
"import": "./dist/bootstrap.js",
|
|
21
|
+
"default": "./dist/bootstrap.js"
|
|
22
|
+
},
|
|
23
|
+
"./plugin": {
|
|
24
|
+
"types": "./dist/cli.plugin.d.ts",
|
|
25
|
+
"bun": "./src/cli.plugin.ts",
|
|
26
|
+
"import": "./dist/cli.plugin.js",
|
|
27
|
+
"default": "./dist/cli.plugin.js"
|
|
28
|
+
},
|
|
29
|
+
"./cli.plugin": {
|
|
30
|
+
"types": "./dist/cli.plugin.d.ts",
|
|
31
|
+
"bun": "./src/cli.plugin.ts",
|
|
32
|
+
"import": "./dist/cli.plugin.js",
|
|
33
|
+
"default": "./dist/cli.plugin.js"
|
|
34
|
+
},
|
|
35
|
+
"./config": {
|
|
36
|
+
"types": "./dist/config.d.ts",
|
|
37
|
+
"bun": "./src/config.ts",
|
|
38
|
+
"import": "./dist/config.js",
|
|
39
|
+
"default": "./dist/config.js"
|
|
40
|
+
},
|
|
41
|
+
"./core": {
|
|
42
|
+
"types": "./dist/core/index.d.ts",
|
|
43
|
+
"bun": "./src/core/index.ts",
|
|
44
|
+
"import": "./dist/core/index.js",
|
|
45
|
+
"default": "./dist/core/index.js"
|
|
46
|
+
},
|
|
47
|
+
"./cli/runtime/shared/context": {
|
|
48
|
+
"types": "./dist/core/runtime/shared/context.d.ts",
|
|
49
|
+
"bun": "./src/core/runtime/shared/context.ts",
|
|
50
|
+
"import": "./dist/core/runtime/shared/context.js",
|
|
51
|
+
"default": "./dist/core/runtime/shared/context.js"
|
|
52
|
+
},
|
|
53
|
+
"./cli/runtime/shared/options": {
|
|
54
|
+
"types": "./dist/core/runtime/shared/options.d.ts",
|
|
55
|
+
"bun": "./src/core/runtime/shared/options.ts",
|
|
56
|
+
"import": "./dist/core/runtime/shared/options.js",
|
|
57
|
+
"default": "./dist/core/runtime/shared/options.js"
|
|
58
|
+
},
|
|
59
|
+
"./*": {
|
|
60
|
+
"types": "./dist/*.d.ts",
|
|
61
|
+
"bun": "./src/*.ts",
|
|
62
|
+
"import": "./dist/*.js",
|
|
63
|
+
"default": "./dist/*.js"
|
|
64
|
+
},
|
|
65
|
+
"./*.js": {
|
|
66
|
+
"types": "./dist/*.d.ts",
|
|
67
|
+
"bun": "./src/*.ts",
|
|
68
|
+
"import": "./dist/*.js",
|
|
69
|
+
"default": "./dist/*.js"
|
|
70
|
+
},
|
|
71
|
+
"./*/*": {
|
|
72
|
+
"types": "./dist/*/*.d.ts",
|
|
73
|
+
"bun": "./src/*/*.ts",
|
|
74
|
+
"import": "./dist/*/*.js",
|
|
75
|
+
"default": "./dist/*/*.js"
|
|
76
|
+
},
|
|
77
|
+
"./*/*.js": {
|
|
78
|
+
"types": "./dist/*/*.d.ts",
|
|
79
|
+
"bun": "./src/*/*.ts",
|
|
80
|
+
"import": "./dist/*/*.js",
|
|
81
|
+
"default": "./dist/*/*.js"
|
|
82
|
+
},
|
|
83
|
+
"./*/*/*": {
|
|
84
|
+
"types": "./dist/*/*/*.d.ts",
|
|
85
|
+
"bun": "./src/*/*/*.ts",
|
|
86
|
+
"import": "./dist/*/*/*.js",
|
|
87
|
+
"default": "./dist/*/*/*.js"
|
|
88
|
+
},
|
|
89
|
+
"./*/*/*.js": {
|
|
90
|
+
"types": "./dist/*/*/*.d.ts",
|
|
91
|
+
"bun": "./src/*/*/*.ts",
|
|
92
|
+
"import": "./dist/*/*/*.js",
|
|
93
|
+
"default": "./dist/*/*/*.js"
|
|
94
|
+
},
|
|
95
|
+
"./*/*/*/*": {
|
|
96
|
+
"types": "./dist/*/*/*/*.d.ts",
|
|
97
|
+
"bun": "./src/*/*/*/*.ts",
|
|
98
|
+
"import": "./dist/*/*/*/*.js",
|
|
99
|
+
"default": "./dist/*/*/*/*.js"
|
|
100
|
+
},
|
|
101
|
+
"./*/*/*/*.js": {
|
|
102
|
+
"types": "./dist/*/*/*/*.d.ts",
|
|
103
|
+
"bun": "./src/*/*/*/*.ts",
|
|
104
|
+
"import": "./dist/*/*/*/*.js",
|
|
105
|
+
"default": "./dist/*/*/*/*.js"
|
|
106
|
+
},
|
|
107
|
+
"./*/*/*/*/*": {
|
|
108
|
+
"types": "./dist/*/*/*/*/*.d.ts",
|
|
109
|
+
"bun": "./src/*/*/*/*/*.ts",
|
|
110
|
+
"import": "./dist/*/*/*/*/*.js",
|
|
111
|
+
"default": "./dist/*/*/*/*/*.js"
|
|
112
|
+
},
|
|
113
|
+
"./*/*/*/*/*.js": {
|
|
114
|
+
"types": "./dist/*/*/*/*/*.d.ts",
|
|
115
|
+
"bun": "./src/*/*/*/*/*.ts",
|
|
116
|
+
"import": "./dist/*/*/*/*/*.js",
|
|
117
|
+
"default": "./dist/*/*/*/*/*.js"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"publishConfig": {
|
|
121
|
+
"registry": "https://registry.npmjs.org",
|
|
122
|
+
"access": "public"
|
|
123
|
+
},
|
|
124
|
+
"repository": {
|
|
125
|
+
"type": "git",
|
|
126
|
+
"url": "git+https://github.com/vibesdotdev/monorepo.git",
|
|
127
|
+
"directory": "packages/cli"
|
|
128
|
+
},
|
|
129
|
+
"peerDependencies": {
|
|
130
|
+
"@vibesdotdev/config": "0.0.1",
|
|
131
|
+
"@vibesdotdev/localdb": "0.0.1",
|
|
132
|
+
"@vibesdotdev/runtime": "0.0.1",
|
|
133
|
+
"@vibesdotdev/logging": "0.0.1",
|
|
134
|
+
"@vibesdotdev/runtime-surface-cli": "0.0.1",
|
|
135
|
+
"@vibesdotdev/storage": "0.0.1",
|
|
136
|
+
"@vibesdotdev/tui": "0.0.1"
|
|
137
|
+
},
|
|
138
|
+
"dependencies": {
|
|
139
|
+
"@vibesdotdev/client": "0.1.0",
|
|
140
|
+
"@vibesdotdev/config": "0.0.1",
|
|
141
|
+
"@vibesdotdev/localdb": "0.0.1",
|
|
142
|
+
"@vibesdotdev/logging": "0.0.1",
|
|
143
|
+
"@vibesdotdev/runtime": "0.0.1",
|
|
144
|
+
"@vibesdotdev/runtime-bun": "0.0.0",
|
|
145
|
+
"@vibesdotdev/runtime-environment-bun": "0.0.0",
|
|
146
|
+
"@vibesdotdev/storage": "0.0.1",
|
|
147
|
+
"@vibesdotdev/tui": "0.0.1",
|
|
148
|
+
"commander": "^14.0.3",
|
|
149
|
+
"yaml": "^2.9.0",
|
|
150
|
+
"zod": "^4.3.6",
|
|
151
|
+
"@vibesdotdev/runtime-surface-cli": "0.0.1"
|
|
152
|
+
},
|
|
153
|
+
"scripts": {
|
|
154
|
+
"test": "bun test",
|
|
155
|
+
"check": "bun --bun tsc -p tsconfig.json --noEmit",
|
|
156
|
+
"build": "tsc -p tsconfig.json"
|
|
157
|
+
},
|
|
158
|
+
"license": "MIT",
|
|
159
|
+
"files": [
|
|
160
|
+
"dist",
|
|
161
|
+
"src",
|
|
162
|
+
"bin",
|
|
163
|
+
"README.md",
|
|
164
|
+
"SPEC.md",
|
|
165
|
+
"LICENSE",
|
|
166
|
+
"!src/**/__tests__/**",
|
|
167
|
+
"!src/**/__stubs__/**",
|
|
168
|
+
"!src/**/*.test.ts",
|
|
169
|
+
"!src/**/*.test.tsx",
|
|
170
|
+
"!src/**/*.spec.ts",
|
|
171
|
+
"!src/**/*.spec.tsx",
|
|
172
|
+
"!dist/**/__tests__/**",
|
|
173
|
+
"!dist/**/__stubs__/**",
|
|
174
|
+
"!dist/**/*.test.js",
|
|
175
|
+
"!dist/**/*.test.js.map",
|
|
176
|
+
"!dist/**/*.test.d.ts",
|
|
177
|
+
"!dist/**/*.test.d.ts.map",
|
|
178
|
+
"!dist/**/*.spec.js",
|
|
179
|
+
"!dist/**/*.spec.js.map",
|
|
180
|
+
"!dist/**/*.spec.d.ts",
|
|
181
|
+
"!dist/**/*.spec.d.ts.map"
|
|
182
|
+
],
|
|
183
|
+
"vibes": {
|
|
184
|
+
"visibility": "public-framework"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API client factory - creates configured clients for CLI commands
|
|
3
|
+
* This is the central service that replaces direct database access
|
|
4
|
+
* Uses the cfg -> env -> auth hooks system for configuration
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getRuntimeEnv } from '@vibesdotdev/runtime';
|
|
8
|
+
import type { RuntimeContext } from '../types.ts';
|
|
9
|
+
import type { APIClientConfig } from '../schemas/types.ts';
|
|
10
|
+
import { apiClientConfigSchema } from '../schemas/common.ts';
|
|
11
|
+
import { VibesClient } from '@vibesdotdev/client/core';
|
|
12
|
+
import type { ClientConfig } from '@vibesdotdev/client/core';
|
|
13
|
+
import { createCLIClient, createHttp2Fetch } from '@vibesdotdev/client/node';
|
|
14
|
+
import { getContext } from '@vibesdotdev/cli/core/runtime/context';
|
|
15
|
+
|
|
16
|
+
type EnvironmentContext = {
|
|
17
|
+
name?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
data?: {
|
|
20
|
+
apiUrl?: string;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
};
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type AuthCredentials = {
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
sessionToken?: string;
|
|
29
|
+
refreshToken?: string;
|
|
30
|
+
expiresAt?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function getRuntimeEnvironment(context?: RuntimeContext): EnvironmentContext | null {
|
|
34
|
+
const runtimeCtx = (context as unknown as Record<string, unknown>) ?? {};
|
|
35
|
+
const environment = (runtimeCtx.environment ?? getContext().environment) as
|
|
36
|
+
| EnvironmentContext
|
|
37
|
+
| undefined;
|
|
38
|
+
return environment ?? null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function resolveDebugFlag(context?: RuntimeContext): Promise<boolean> {
|
|
42
|
+
const runtimeCtx = (context as unknown as Record<string, unknown>) ?? {};
|
|
43
|
+
const ctxWithConfig = (runtimeCtx.config ? runtimeCtx : getContext()) as {
|
|
44
|
+
config?: { get: (key: string, scope: string) => Promise<unknown> };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (!ctxWithConfig.config?.get) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const debug = await ctxWithConfig.config.get('debug', 'global');
|
|
53
|
+
return typeof debug === 'boolean' ? debug : false;
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function buildAuthConfig(
|
|
60
|
+
credentials: AuthCredentials | null | undefined,
|
|
61
|
+
baseUrl: string
|
|
62
|
+
): ClientConfig['auth'] {
|
|
63
|
+
if (!credentials) {
|
|
64
|
+
return { type: 'none' };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (credentials.apiKey) {
|
|
68
|
+
return { type: 'apiKey', credentials: credentials.apiKey };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (credentials.sessionToken) {
|
|
72
|
+
return {
|
|
73
|
+
type: 'bearer',
|
|
74
|
+
tokenProvider: async () => credentials.sessionToken ?? null,
|
|
75
|
+
refreshHandler: async () => {
|
|
76
|
+
if (!credentials.refreshToken) return null;
|
|
77
|
+
try {
|
|
78
|
+
const response = await fetch(`${baseUrl}/api/auth/session`, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
headers: { 'Content-Type': 'application/json' },
|
|
81
|
+
body: JSON.stringify({ refreshToken: credentials.refreshToken })
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const data = (await response.json()) as {
|
|
89
|
+
token?: string;
|
|
90
|
+
refreshToken?: string;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (!data.token) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
type: 'bearer',
|
|
99
|
+
credentials: data.token,
|
|
100
|
+
tokenProvider: async () => data.token ?? null
|
|
101
|
+
};
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return { type: 'none' };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function applyEnvironmentHeaders(
|
|
113
|
+
config: ClientConfig,
|
|
114
|
+
headers: Record<string, string> | undefined
|
|
115
|
+
): ClientConfig {
|
|
116
|
+
if (!headers || Object.keys(headers).length === 0) {
|
|
117
|
+
return config;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const beforeRequest = async (request: Request): Promise<Request> => {
|
|
121
|
+
const updated = new Headers(request.headers);
|
|
122
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
123
|
+
if (value !== undefined) {
|
|
124
|
+
updated.set(key, value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return new Request(request, { headers: updated });
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
...config,
|
|
132
|
+
hooks: {
|
|
133
|
+
...config.hooks,
|
|
134
|
+
beforeRequest
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Create a configured API client using current environment and auth settings
|
|
141
|
+
* This is what ALL CLI modules should use instead of direct database access
|
|
142
|
+
*
|
|
143
|
+
* Uses the hooks system: cfg -> env -> auth -> api
|
|
144
|
+
*/
|
|
145
|
+
export async function createConfiguredClient(context?: RuntimeContext): Promise<VibesClient> {
|
|
146
|
+
const runtimeCtx = context ?? (getContext() as RuntimeContext);
|
|
147
|
+
const environment = getRuntimeEnvironment(runtimeCtx);
|
|
148
|
+
const credentials = ((runtimeCtx as unknown as Record<string, unknown>)?.authCredentials ??
|
|
149
|
+
getContext().authCredentials) as AuthCredentials | undefined;
|
|
150
|
+
|
|
151
|
+
const resolvedBaseUrl =
|
|
152
|
+
environment?.data?.apiUrl ??
|
|
153
|
+
environment?.url ??
|
|
154
|
+
getRuntimeEnv('VIBES_API_URL');
|
|
155
|
+
|
|
156
|
+
const baseUrl = resolvedBaseUrl ?? 'http://localhost:5173';
|
|
157
|
+
const debug = await resolveDebugFlag(runtimeCtx);
|
|
158
|
+
|
|
159
|
+
const initialConfig: ClientConfig = {
|
|
160
|
+
baseUrl,
|
|
161
|
+
auth: buildAuthConfig(credentials, baseUrl),
|
|
162
|
+
debug,
|
|
163
|
+
fetch: createHttp2Fetch(baseUrl) as typeof fetch
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const configWithHeaders = applyEnvironmentHeaders(
|
|
167
|
+
initialConfig,
|
|
168
|
+
environment?.data?.headers ?? environment?.headers
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
return createCLIClient(configWithHeaders);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Create API client configuration for debugging/inspection
|
|
176
|
+
*/
|
|
177
|
+
export async function createAPIClientConfig(context?: RuntimeContext): Promise<APIClientConfig> {
|
|
178
|
+
const runtimeCtx = context ?? (getContext() as RuntimeContext);
|
|
179
|
+
const environment = getRuntimeEnvironment(runtimeCtx);
|
|
180
|
+
|
|
181
|
+
if (!environment) {
|
|
182
|
+
throw new Error('No environment configured');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const baseUrl = environment.data?.apiUrl ?? environment.url;
|
|
186
|
+
if (!baseUrl) {
|
|
187
|
+
throw new Error('No environment configured');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const credentials = ((runtimeCtx as unknown as Record<string, unknown>)?.authCredentials ??
|
|
191
|
+
getContext().authCredentials) as AuthCredentials | undefined;
|
|
192
|
+
|
|
193
|
+
const auth: APIClientConfig['auth'] = credentials?.apiKey
|
|
194
|
+
? { type: 'apiKey', apiKey: credentials.apiKey }
|
|
195
|
+
: credentials?.sessionToken
|
|
196
|
+
? {
|
|
197
|
+
type: 'session',
|
|
198
|
+
sessionToken: credentials.sessionToken,
|
|
199
|
+
refreshToken: credentials.refreshToken ?? undefined
|
|
200
|
+
}
|
|
201
|
+
: { type: 'none' };
|
|
202
|
+
|
|
203
|
+
const tierCandidate =
|
|
204
|
+
environment.data && typeof environment.data === 'object'
|
|
205
|
+
? (environment.data as { tier?: string }).tier
|
|
206
|
+
: undefined;
|
|
207
|
+
const tier: APIClientConfig['tier'] =
|
|
208
|
+
tierCandidate === 'dev' ||
|
|
209
|
+
tierCandidate === 'staging' ||
|
|
210
|
+
tierCandidate === 'production' ||
|
|
211
|
+
tierCandidate === 'local'
|
|
212
|
+
? tierCandidate
|
|
213
|
+
: 'local';
|
|
214
|
+
|
|
215
|
+
const debug = await resolveDebugFlag(runtimeCtx);
|
|
216
|
+
|
|
217
|
+
return apiClientConfigSchema.parse({
|
|
218
|
+
baseUrl,
|
|
219
|
+
environment: environment.name ?? 'local',
|
|
220
|
+
tier,
|
|
221
|
+
auth,
|
|
222
|
+
headers: environment.data?.headers ?? environment.headers,
|
|
223
|
+
timeout: 30000,
|
|
224
|
+
retries: 3,
|
|
225
|
+
debug
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Test API connection
|
|
231
|
+
*/
|
|
232
|
+
export async function testAPIConnection(
|
|
233
|
+
endpoint = '/api/health',
|
|
234
|
+
context?: RuntimeContext
|
|
235
|
+
): Promise<{
|
|
236
|
+
success: boolean;
|
|
237
|
+
status: number;
|
|
238
|
+
latency: number;
|
|
239
|
+
error?: string;
|
|
240
|
+
}> {
|
|
241
|
+
try {
|
|
242
|
+
const client = await createConfiguredClient(context);
|
|
243
|
+
const start = Date.now();
|
|
244
|
+
|
|
245
|
+
const response = await client.request(endpoint, {
|
|
246
|
+
method: 'GET',
|
|
247
|
+
timeout: 10000
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const latency = Date.now() - start;
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
success: true,
|
|
254
|
+
status: 200, // VibesClient abstracts status codes
|
|
255
|
+
latency
|
|
256
|
+
};
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
success: false,
|
|
260
|
+
status: 0,
|
|
261
|
+
latency: 0,
|
|
262
|
+
error: error instanceof Error ? error.message : String(error)
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import z from 'zod/v4';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* API client configuration schemas
|
|
5
|
+
*/
|
|
6
|
+
export const apiClientConfigSchema = z.object({
|
|
7
|
+
baseUrl: z.url(),
|
|
8
|
+
environment: z.string(),
|
|
9
|
+
tier: z.enum(['local', 'dev', 'staging', 'production']),
|
|
10
|
+
auth: z.discriminatedUnion('type', [
|
|
11
|
+
z.object({
|
|
12
|
+
type: z.literal('none')
|
|
13
|
+
}),
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal('apiKey'),
|
|
16
|
+
apiKey: z.string()
|
|
17
|
+
}),
|
|
18
|
+
z.object({
|
|
19
|
+
type: z.literal('session'),
|
|
20
|
+
sessionToken: z.string(),
|
|
21
|
+
refreshToken: z.string().optional()
|
|
22
|
+
})
|
|
23
|
+
]),
|
|
24
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
25
|
+
timeout: z.number().default(30000),
|
|
26
|
+
retries: z.number().default(3),
|
|
27
|
+
debug: z.boolean().default(false)
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* API client test schemas
|
|
32
|
+
*/
|
|
33
|
+
export const apiTestSchema = z.object({
|
|
34
|
+
endpoint: z.string().optional(),
|
|
35
|
+
method: z.enum(['GET', 'POST', 'PUT', 'DELETE']).default('GET'),
|
|
36
|
+
timeout: z.number().optional()
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* API connection status schema
|
|
41
|
+
*/
|
|
42
|
+
export const apiConnectionStatusSchema = z.object({
|
|
43
|
+
connected: z.boolean(),
|
|
44
|
+
environment: z.string(),
|
|
45
|
+
baseUrl: z.string(),
|
|
46
|
+
authType: z.enum(['none', 'apiKey', 'session']),
|
|
47
|
+
lastChecked: z.iso.datetime(),
|
|
48
|
+
latency: z.number().optional(),
|
|
49
|
+
error: z.string().optional()
|
|
50
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { z } from 'zod/v4';
|
|
2
|
+
import type { apiClientConfigSchema, apiTestSchema, apiConnectionStatusSchema } from './common.ts';
|
|
3
|
+
|
|
4
|
+
export type APIClientConfig = z.infer<typeof apiClientConfigSchema>;
|
|
5
|
+
export type APITestInput = z.infer<typeof apiTestSchema>;
|
|
6
|
+
export type APIConnectionStatus = z.infer<typeof apiConnectionStatusSchema>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* API service result types
|
|
10
|
+
*/
|
|
11
|
+
export interface APITestResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
status: APIConnectionStatus;
|
|
14
|
+
response?: {
|
|
15
|
+
status: number;
|
|
16
|
+
statusText: string;
|
|
17
|
+
headers: Record<string, string>;
|
|
18
|
+
data?: unknown;
|
|
19
|
+
};
|
|
20
|
+
error?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface APIDebugResult {
|
|
24
|
+
config: APIClientConfig;
|
|
25
|
+
status: APIConnectionStatus;
|
|
26
|
+
diagnostics: {
|
|
27
|
+
environmentResolved: boolean;
|
|
28
|
+
authResolved: boolean;
|
|
29
|
+
baseUrlValid: boolean;
|
|
30
|
+
credentialsValid: boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API service - provides API testing and debugging commands
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { RuntimeContext } from '../types.ts';
|
|
6
|
+
import type {
|
|
7
|
+
APITestInput,
|
|
8
|
+
APITestResult,
|
|
9
|
+
APIDebugResult,
|
|
10
|
+
APIConnectionStatus
|
|
11
|
+
} from '../schemas/types.ts';
|
|
12
|
+
import { apiTestSchema } from '../schemas/common.ts';
|
|
13
|
+
import { createAPIClientConfig, testAPIConnection } from '../client/factory.ts';
|
|
14
|
+
import { loadStoredCredentials, loadStoredEnvironment } from '@vibesdotdev/config/client';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Execute API test command
|
|
18
|
+
*/
|
|
19
|
+
export async function executeAPITest(
|
|
20
|
+
input: APITestInput,
|
|
21
|
+
context: RuntimeContext
|
|
22
|
+
): Promise<APITestResult> {
|
|
23
|
+
try {
|
|
24
|
+
const validatedInput = apiTestSchema.parse(input);
|
|
25
|
+
|
|
26
|
+
const environment = await loadStoredEnvironment();
|
|
27
|
+
if (!environment) {
|
|
28
|
+
throw new Error('No environment configured');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const credentials = await loadStoredCredentials(environment.name);
|
|
32
|
+
let authType: 'none' | 'apiKey' | 'session' = 'none';
|
|
33
|
+
if (credentials?.apiKey) authType = 'apiKey';
|
|
34
|
+
else if (credentials?.sessionToken) authType = 'session';
|
|
35
|
+
|
|
36
|
+
// Test connection
|
|
37
|
+
const testResult = await testAPIConnection(validatedInput.endpoint, context);
|
|
38
|
+
|
|
39
|
+
const status: APIConnectionStatus = {
|
|
40
|
+
connected: testResult.success,
|
|
41
|
+
environment: environment.name,
|
|
42
|
+
baseUrl: environment.apiUrl,
|
|
43
|
+
authType,
|
|
44
|
+
lastChecked: new Date().toISOString(),
|
|
45
|
+
latency: testResult.latency,
|
|
46
|
+
error: testResult.error
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const result: APITestResult = {
|
|
50
|
+
success: testResult.success,
|
|
51
|
+
status
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (testResult.success) {
|
|
55
|
+
result.response = {
|
|
56
|
+
status: testResult.status,
|
|
57
|
+
statusText: 'OK',
|
|
58
|
+
headers: {},
|
|
59
|
+
data: { message: 'Connection successful' }
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
result.error = testResult.error;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return result;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
context.logger?.error('Failed to test API', error);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Execute API debug command
|
|
74
|
+
*/
|
|
75
|
+
export async function executeAPIDebug(context: RuntimeContext): Promise<APIDebugResult> {
|
|
76
|
+
try {
|
|
77
|
+
// Get API client config
|
|
78
|
+
const config = await createAPIClientConfig(context);
|
|
79
|
+
|
|
80
|
+
// Get current environment
|
|
81
|
+
const environment = await loadStoredEnvironment();
|
|
82
|
+
const credentials = await loadStoredCredentials(environment?.name);
|
|
83
|
+
|
|
84
|
+
// Run diagnostics
|
|
85
|
+
const diagnostics = {
|
|
86
|
+
environmentResolved: !!environment,
|
|
87
|
+
authResolved: !!(credentials?.apiKey || credentials?.sessionToken),
|
|
88
|
+
baseUrlValid: !!environment?.apiUrl && environment.apiUrl.startsWith('http'),
|
|
89
|
+
credentialsValid: !!(
|
|
90
|
+
credentials?.apiKey ||
|
|
91
|
+
(credentials?.sessionToken && !isTokenExpired(credentials.expiresAt))
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// Get connection status
|
|
96
|
+
const testResult = await testAPIConnection('/api/health', context);
|
|
97
|
+
const status: APIConnectionStatus = {
|
|
98
|
+
connected: testResult.success,
|
|
99
|
+
environment: environment?.name || 'none',
|
|
100
|
+
baseUrl: environment?.apiUrl || 'none',
|
|
101
|
+
authType: config.auth.type,
|
|
102
|
+
lastChecked: new Date().toISOString(),
|
|
103
|
+
latency: testResult.latency,
|
|
104
|
+
error: testResult.error
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
config,
|
|
109
|
+
status,
|
|
110
|
+
diagnostics
|
|
111
|
+
};
|
|
112
|
+
} catch (error) {
|
|
113
|
+
context.logger?.error('Failed to debug API', error);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Helper to check if token is expired
|
|
120
|
+
*/
|
|
121
|
+
function isTokenExpired(expiresAt?: string): boolean {
|
|
122
|
+
if (!expiresAt) return false;
|
|
123
|
+
try {
|
|
124
|
+
const expiry = new Date(expiresAt);
|
|
125
|
+
return expiry.getTime() < Date.now();
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
package/src/api/types.ts
ADDED