agentic-preview is a local-first CLI that creates preview URLs for artifacts.
# From npm
npm i @codebolt/agentic-preview
# Start with
npx agentic-preview --help# Local development
npm install
npm link# Basic preview
agentic-preview preview ./my-app
agentic-preview preview ./index.html --type image
# Preview a remote URL artifact
agentic-preview preview "https://example.com" --type url
# Preview output formats
agentic-preview --json preview ./my-app
agentic-preview --json preview ./static-page.html
agentic-preview --json providers list
# Session management
# Show only currently running previews by default
agentic-preview list
# Show all sessions including stopped/closed previews
agentic-preview list --all
agentic-preview stop <previewId>
# Provider management
agentic-preview providers list
agentic-preview providers add-command --id my-provider --name "My Provider" --command "node ./provider.js" --artifact-types "static_site,dynamic_site" --required-credentials "MY_PROVIDER_API_KEY"
agentic-preview providers default static_site my-provider
agentic-preview providers enable my-provider # prompts to capture required keys once missing
agentic-preview providers disable my-provider
agentic-preview providers remove my-providerstatic_site(default for folders)dynamic_siteimagevideofileurl
If you do not pass --type, folder inputs default to static_site.
agentic-preview ships with:
builtin-static(managed): local static file server forstatic_siteanddynamic_site.builtin-file(non-managed): opens local media/text files directly.builtin-url(non-managed): passes through URL artifacts.
Managed providers create preview sessions that can be stopped with agentic-preview stop <previewId>.
Configuration is stored at:
<HOME>/.agentic-preview/config.jsonby default- or overridden with
AGENTIC_PREVIEW_HOME.
Example:
setx AGENTIC_PREVIEW_HOME "C:\Users\%USERNAME%\.agentic-preview-home"You can register your own preview provider using providers add-command.
agentic-preview providers add-command \
--id my-cmd-provider \
--name "My Command Provider" \
--command "node ./my-provider.js" \
--artifact-types "static_site,dynamic_site" \
--required-credentials "MY_PROVIDER_TOKEN" \
--managed \
--supports-stop \
--stop-command "node ./my-provider.js" \
--description "Optional description"Flags:
--idunique provider identifier.--namedisplay name.--commandcommand to execute on preview start.--artifact-typescomma-separated supported artifact types.--required-credentialscomma-separated credential keys required by the provider.--managed(optional) marks session as managed.--supports-stop(optional) enables explicitstopflow.--stop-commandrequired if--supports-stopis set and you want explicit stop support.--timeout-msoptional command timeout.--descriptionoptional metadata.
Notes:
providers enable <providerId>will prompt for any missing credential values before enabling.- captured credentials are stored at
<HOME>/.agentic-preview/config.jsoninproviderCredentials.
agentic-preview invokes your provider by:
- launching the command with shell
- passing JSON payload on stdin
- expecting a JSON response on stdout.
Start payload shape (example):
{
"action": "start",
"previewId": "preview-....",
"providerId": "my-cmd-provider",
"artifact": {
"id": "artifact-...",
"kind": "directory|file|url",
"type": "static_site",
"path": "C:\\path\\to\\artifact",
"entrypoint": "index.html",
"sourceType": "directory|file",
"title": "my-app"
},
"options": {}
}Your command must print JSON with:
{
"kind": "url",
"openIn": "browser",
"url": "https://... | file:///...",
"label": "optional human label",
"message": "optional status text",
"metadata": {}
}kindshould beurlfor now.openIncan bebrowser(default) and is used by callers that may also support dynamic panels in other integrations.urlis required and is shown in the UI/CLI.
Optional stop command (if enabled):
agentic-previewwill invoke--stop-commandwith this payload onstop:
{
"action": "stop",
"previewId": "preview-...",
"providerId": "my-cmd-provider",
"artifact": { ... }
}If no stop output is required, exit code 0 is enough.
my-provider.js:
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8');
const payload = JSON.parse(input || '{}');
if (payload.action === 'stop') {
// optional cleanup
console.log(JSON.stringify({ ok: true, message: 'Stopped' }));
process.exit(0);
}
console.log(JSON.stringify({
kind: 'url',
openIn: 'browser',
url: `file://${payload.artifact.path}`,
label: 'Local command provider',
message: `Preview started for ${payload.artifact.title}`,
}));- Add again with same
--idto replace. - Remove:
agentic-preview providers remove my-cmd-provider- Use
providers disableto keep config but mark disabled.
agentic-preview includes a runnable sample provider in:
samples/command-provider
Register it with:
node src/index.js providers add-command --id sample-command-provider --name "Sample Command Provider" --command "node <repo-root>/samples/command-provider/provider.js" --artifact-types "static_site,dynamic_site,image,video,file,url" --managed --supports-stop --stop-command "node <repo-root>/samples/command-provider/provider.js" --description "Local sample command provider"Then preview and stop:
node src/index.js preview . --json
node src/index.js stop <previewId> --jsonagentic-preview providers default static_site my-cmd-provider
agentic-preview providers enable my-cmd-provider
agentic-preview providers disable my-cmd-provider
agentic-preview --json providers list
agentic-preview --json list
agentic-preview --json stop preview-xxxx- "Provider ... is not available or disabled": check
providers listand providerenabledstate. Command returned no JSON output: your provider script did not print a valid JSON object to stdout.No provider supports artifact type: no enabled provider matches the artifact type.