@knosi/cli
v0.2.3
Published
Knosi CLI — Claude Code daemon, OAuth login, raw AI capture saves, usage reporting, and skill install
Maintainers
Readme
@knosi/cli
Knosi CLI for Second Brain.
Runs on your machine and supports four workflows:
- the Claude Code task daemon (chat + structured)
- OAuth login against your Knosi deployment
- explicit raw AI capture saves for Claude Code skills
- local Claude Code / Codex token usage reporting
Prerequisites
- Claude CLI installed and logged in (
claude --version) - Node.js >= 20
Usage
npx @knosi/cli --url https://your-second-brain.vercel.appThe daemon will:
- Poll the server for queued AI tasks (chat + structured data)
- Execute them using your local Claude CLI
- Stream results back to the server
- Scan local Claude Code / Codex logs every 5 min and upload token usage to
/api/usage - Fire a daily Claude "hello" ping at 05:59 local time to keep the CLI warm
Press Ctrl+C to stop.
One-shot Usage Sync
npx @knosi/cli usage reportScans ~/.claude/projects/**/*.jsonl (and ~/.codex/state*.sqlite when better-sqlite3 is available), aggregates token counts per (date, provider, model), and POSTs to the configured server. Requires knosi auth login first.
OAuth Login
npx @knosi/cli auth login https://www.knosi.xyzThis starts a local callback server on 127.0.0.1:6274, opens the browser, completes OAuth against Knosi, and stores CLI credentials in ~/.knosi/cli.json.
Save a Raw AI Capture
cat payload.json | npx @knosi/cli save-ai-note --jsonPayload shape:
{
"sourceApp": "claude-code",
"title": "Optional custom title",
"capturedAtLabel": "2026-04-12 15:20 SGT",
"messages": [
{ "role": "user", "content": "Question" },
{ "role": "assistant", "content": "Answer" }
],
"sourceMeta": {
"projectPath": "/Users/bytedance/second-brain"
}
}Install the Claude Code Skill
npx @knosi/cli install-skillThis copies the bundled template to:
~/.claude/skills/save-to-knosi/SKILL.mdOptions
| Flag | Description | Default |
|------|-------------|---------|
| --url <url> | Second Brain server URL | https://www.knosi.xyz |
| --model <model> | Override Claude model | (from task) |
| --once | Process one round then exit | false |
| --claude-bin <path> | Path to Claude CLI binary | claude |
Releasing
@knosi/cli is published automatically by the Publish @knosi/cli GitHub Actions workflow (.github/workflows/publish-cli.yml):
- Bump
packages/cli/package.json→version. - Commit + push to
main. - The workflow runs the CLI unit tests, compares the local version with the one on the npm registry, and publishes only if the local version is strictly greater.
The workflow needs a repo secret named NPM_TOKEN holding an npm automation token (not a classic one — automation tokens bypass 2FA, which is what lets CI publish non-interactively). Create one under npmjs.com → Access Tokens → "Generate New Token" → Automation, scope it to @knosi/cli publish access, then add it to GitHub repo Settings → Secrets and variables → Actions as NPM_TOKEN.
