# Migration from legacy collab-*.js scripts

Pre-v0.3.0, the workspace had ad-hoc `D:\myopenclaw\scripts\collab-*.js`
shims (collab-send.js, collab-read.js, collab-ack.js, collab-list.js).
Those are superseded by this npm package.

## Mapping

| Legacy script | v0.3.0 binary |
|---|---|
| `node scripts/collab-send.js <to> <content>` | `collab-send <to> <content>` |
| `node scripts/collab-read.js <from> <sinceId>` | `collab-read <from> <sinceId>` |
| `node scripts/collab-ack.js <id>` | `collab-ack <id>` |
| `node scripts/collab-list.js <type>` | `collab-list <type>` |
| `node scripts/collab-list-users.js` | `collab-list --type=users` (or call collab-mcp directly) |
| `node scripts/collab-audit.js` | `collab-list --type=audit` |

## Why migrate?

- **Auth built-in** — no more 401s from missing API keys
- **Cross-platform** — npm install -g on Windows / macOS / Linux
- **Discoverable** — `collab-doctor` diagnoses setup; `claude-collab-config init` walks you through
- **Programmatic** — `require('@trustbaseai/claude-collab')` exposes `send/read/ack/list/rpc/configStore`

## Steps

```bash
# 1. Install
npm install -g @trustbaseai/claude-collab

# 2. Get api_key from your collab-mcp host
ssh collab-mcp-host
collab-mcp keys create claude-collab --scopes=read,write
# copy the plaintext

# 3. Configure
claude-collab-config init   # interactive
# or
claude-collab-config set api_key cmcp_xxx.<secret>
claude-collab-config set mcp_url http://collab-mcp-host:3010

# 4. Verify
collab-doctor

# 5. Replace legacy scripts in your workflow
#    e.g. ~/.claude/hooks/PostToolUse.sh:
#      before: node D:/myopenclaw/scripts/collab-send.js baobei "..."
#      after:  collab-send baobei "..."
```

## Backwards compatibility

The npm package exposes the same HTTP endpoints the legacy scripts used.
Old scripts can stay in place during a phased migration; the package's
`bin/` aliases don't conflict.

## Reverting

If you need to roll back:

```bash
npm uninstall -g @trustbaseai/claude-collab
# Legacy scripts are still at D:\myopenclaw\scripts\collab-*.js
```

They won't have been touched by the npm install.