hacknote 0.1.0

CLI for HackNote — manage notes from the command line
# hacknote-cli

A command-line interface for [HackNote](https://app.hacknote.co) — create, read, update, and delete notes, manage projects and tags, and search across your team, all from the terminal.

## Installation

```bash
git clone git@github.com:xinxiaotech/hacknote-cli.git
cd hacknote-cli
npm install
npm run build
npm install -g .
```

Verify:

```bash
hacknote --version
```

## Quick Start

### 1. Get an API Key

Log in to HackNote → Account Settings → API Tokens → create a new token.

### 2. Set your API key

```bash
hacknote config set-key <your-api-key>
```

### 3. Find your Team ID

```bash
hacknote teams list
```

```
┌──────────────────┬──────────┬────────┬─────────┐
│ ID               │ Name     │ Slug   │ Role    │
├──────────────────┼──────────┼────────┼─────────┤
│ 17c261f7d8fWbdml │ My Team  │ myteam │ Owner   │
└──────────────────┴──────────┴────────┴─────────┘
```

---

## Finding IDs from the URL

HackNote URLs follow this pattern:

```
https://app.hacknote.co/@team/<teamId>/@project/<projectKey>/<noteKey>
```

Example:

```
https://app.hacknote.co/@team/17c261f7d8fWbdml/@project/19c4c1e9341x5h8i/19c4fdb4ff9WIBpm
                               ^^^^^^^^^^^^^^^^           ^^^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^
                               teamId                     projectKey        noteKey
```

---

## Command Reference

### `config`

```bash
hacknote config set-key <apiKey>   # Save your API key
hacknote config show               # Show current configuration
```

---

### `profile`

```bash
hacknote profile                   # Show current user info
```

---

### `teams`

```bash
hacknote teams list                          # List all teams you belong to
hacknote teams get <teamId>                  # Show team details
hacknote teams create <name>                 # Create a new team
hacknote teams create <name> --slug <slug>   # Create with a custom slug
```

---

### `projects`

Project lists are read in real time over WebSocket.

```bash
hacknote projects list <teamId>                        # List all projects in a team
hacknote projects create <teamId> <title>              # Create a new project
```

---

### `notes`

Listing, updating, and deleting notes use WebSocket. Creating notes and reading content use the REST API.

**List notes**

```bash
hacknote notes list <teamId> <projectKey>
hacknote notes list <teamId> <projectKey> --all   # Include hidden notes
hacknote notes list-published <projectId>         # List all published notes in a project
hacknote notes list-published <projectId> --raw   # Raw JSON output
```

**Read note content**

Fetches the latest content from version history:

```bash
hacknote notes get <teamId> <projectKey> <noteKey>
hacknote notes get <teamId> <projectKey> <noteKey> --raw   # Raw content only
```

Use `--raw` with redirection to save to a file:

```bash
hacknote notes get <teamId> <projectKey> <noteKey> --raw > note.md
```

**Create a note**

```bash
# Inline content
hacknote notes create <teamId> <projectKey> --content "# Title\n\nBody text"

# From a file
hacknote notes create <teamId> <projectKey> --file note.md

# From stdin
cat note.md | hacknote notes create <teamId> <projectKey>

# Place in a folder
hacknote notes create <teamId> <projectKey> --file note.md --folder <folderKey>
```

**Update a note**

```bash
hacknote notes update <teamId> <projectKey> <noteKey> --content "New content"
hacknote notes update <teamId> <projectKey> <noteKey> --file updated.md
cat updated.md | hacknote notes update <teamId> <projectKey> <noteKey>
```

**Delete a note**

```bash
hacknote notes delete <teamId> <projectKey> <noteKey>
hacknote notes delete <teamId> <projectKey> <noteKey> --yes   # Skip confirmation
```

**Version history**

```bash
hacknote notes versions <teamId> <projectKey> <noteKey>
```

---

### `search`

```bash
hacknote search <teamId> <query>
hacknote search <teamId> <query> --limit 50   # Default: 20 results
```

---

### `tags`

```bash
hacknote tags list <teamId> <projectKey> <noteKey>          # List tags on a note
hacknote tags list-team <teamId>                            # List all tags in a team
hacknote tags add <teamId> <projectKey> <noteKey> <tag>     # Add a tag
hacknote tags remove <teamId> <projectKey> <noteKey> <tag>  # Remove a tag
```

---

## Updating

```bash
cd hacknote-cli
git pull
npm run build
npm install -g .
```