@act-sdk/cli
v2.0.1
Published
CLI for Act SDK
Readme
@act-sdk/cli
Command-line tools for scaffolding and syncing Act SDK projects.
Use Without Installing
npx @act-sdk/cli initThis only works after @act-sdk/cli has been published to npm.
Local Development
pnpm --filter @act-sdk/cli run build
node packages/cli/dist/index.js initIf you want a global command locally:
cd packages/cli
npm link
act-sdk initInstall Globally (Optional)
npm install -g @act-sdk/cli
act-sdk --helpCommands
act-sdk init
Scaffolds act-sdk.config.ts and providers/act-provider.tsx into your project and installs required dependencies.
The generated config:
- exports
actandactSdkConfig - includes an explicit
endpoint - uses
process.env.NEXT_PUBLIC_ACT_SDK_API_KEY
You can define actions anywhere in your app by importing act from act-sdk.config.ts.
The generated provider file imports act and actSdkConfig and wraps your app with @act-sdk/react.
act-sdk init
act-sdk init --skip-installact-sdk add <component>
Adds UI components (currently command for the Act command bar).
act-sdk add commandact-sdk sync
Extracts action definitions from your project and syncs them to your endpoint.
act-sdk sync
act-sdk sync --config ./act-sdk.config.ts --project .Required Config
act-sdk sync expects an act-sdk.config.ts (or --config) containing:
apiKeyprojectIddescription- optional
endpoint(defaults tohttps://www.act-sdk.dev)
Example: wiring the Act command bar
After running:
npx @act-sdk/cli init
npx @act-sdk/cli add commandyou’ll have:
act-sdk.config.tsexportingactandactSdkConfigproviders/act-provider.tsxexportingActSdkProvidercomponents/act-sdk/command.tsxexportingActCommand
Wrap your app once with the provider (for example in a Next.js root layout):
'use client';
import type { ReactNode } from 'react';
import { ActSdkProvider } from '@/providers/act-provider';
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="en">
<body>
<ActSdkProvider>{children}</ActSdkProvider>
</body>
</html>
);
}Then mount the command bar so users can type natural-language intents (e.g. “delete user [email protected]”):
import { ActCommand } from '@/components/act-sdk/command';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<ActSdkProvider>
{children}
<ActCommand /> {/* ⌘K / Ctrl+K opens the command bar */}
</ActSdkProvider>
</body>
</html>
);
}ActCommand internally uses useAct() from @act-sdk/react, so anything a user types (or selects from suggestions) is sent as an intent that can call your typed actions.
