# Barry Video

`barry-video` is Barry's Inbeidou workflow package for OpenClaw, Codex, and Claude Code.

It packages two layers together:

- Skills: natural-language routing and workflow guidance under [`skills/`](./skills)
- Tools: real executable capability registered in [`index.ts`](./index.ts) for OpenClaw

## Detailed spec

The full implementation and packaging spec is documented in [`docs/barry-video-spec.md`](./docs/barry-video-spec.md).

## What this package includes

- Account info
- Credit balance
- AI product pricing
- Translation language catalogs
- Short drama discovery for Dramabox and similar platforms
- Media library upload/list/delete
- Smart analysis
- Smart clipping
- Video translation
- Generated works list/detail/download/delete
- Social account listing
- Social publish create/records/delete
- One-shot clip -> download -> publish pipeline
- Raw backend passthrough for future CLI commands

## Repository layout

```text
barry-video/
├── index.ts
├── openclaw.plugin.json
├── package.json
├── bin/
├── scripts/
└── skills/
```

## How it works

1. `openclaw.plugin.json` tells OpenClaw this package provides a plugin and bundled skills.
2. `package.json` exposes the package as an installable OpenClaw extension.
3. `index.ts` registers tool-use actions that shell into the working backend at `inbeidou_cli.py`.
4. `skills/` tells the model when to use which tool based on natural language.
5. `scripts/install-local.sh` installs the package into `~/.openclaw`, syncs bundled skills into `~/.codex/skills` and `~/.claude/skills`, prefers copying a local backend snapshot when available, and otherwise falls back to the bundled backend shipped inside the npm package.

## Local install

```bash
cd /Users/ming/barry-video
./scripts/install-local.sh
```

Or:

```bash
npx -y barry-video install
```

By default, install now does this in one flow:

- Installs the OpenClaw plugin and skills into `~/.openclaw`
- Installs the same skills into `~/.codex/skills`
- Installs the same skills into `~/.claude/skills`
- Writes Barry Video plugin config
- If no token is already configured, automatically prints the official WeChat login QR directly in the terminal
- Waits for scan confirmation, then saves the token

Optional environment variables for install:

```bash
export BARRY_VIDEO_BACKEND="$HOME/inbeidou_cli.py"
export INBEIDOU_TOKEN="your-token"
export BARRY_VIDEO_DEFAULT_ACCOUNT_IDS="109,108"
export BARRY_VIDEO_DEFAULT_PUBLISH_PLATFORM="FACEBOOK"
export CODEX_HOME="$HOME/.codex"
```

If you are installing on a different runtime user or machine, set `INBEIDOU_TOKEN` or `BARRY_VIDEO_AUTH_TOKEN` so the bundled backend can authenticate without depending on a local hardcoded script.

## Login without pasting tokens

The package now supports the official Inbeidou QR login flow.

```bash
npx -y barry-video login
```

What it does:

- Calls the official Inbeidou QR login API
- Renders the returned QR image directly in the terminal
- Polls the login status automatically
- Saves the returned token into `~/.openclaw/openclaw.json`
- Caches a local copy at `~/.barry-video/auth.json`

Notes:

- `barry-video install` automatically enters this login flow after install when no token exists
- `--no-open` is still accepted for backward compatibility, but the login flow no longer depends on `127.0.0.1`
- The original QR image is also saved at `~/.barry-video/last-login-qr.jpg` as a fallback

Useful commands:

```bash
barry-video login --no-open
barry-video status
barry-video logout
```

After login, `barry-video backend ...` will auto-load the saved token if `INBEIDOU_TOKEN` is not already set.

If you want install without opening login, use:

```bash
barry-video install --no-login
```

## Smoke test

```bash
cd /Users/ming/barry-video
./scripts/smoke-test.sh
```

## Package for distribution

```bash
cd /Users/ming/barry-video
./scripts/package-release.sh
```

## Publish to your own GitHub

```bash
cd /Users/ming/barry-video
git init
git add .
git commit -m "Initial Barry Video OpenClaw package"
git branch -M main
git remote add origin git@github.com:a77ming/barry-video.git
git push -u origin main
```

## Publish to npm later

If you want OpenClaw to install it with npm, publish this package and then keep the same package name or update `openclaw.install.npmSpec` in [`package.json`](./package.json).

```bash
npm login
npm publish --access public
```
