pnote 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -7
- package/dist/index.js +115 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ pnote notes
|
|
|
21
21
|
pnote notes get abc123
|
|
22
22
|
|
|
23
23
|
# Copy snippet to clipboard
|
|
24
|
-
pnote snippet copy abc123
|
|
24
|
+
pnote notes snippet copy abc123
|
|
25
25
|
|
|
26
26
|
# Search
|
|
27
27
|
pnote search "portrait"
|
|
@@ -45,7 +45,9 @@ pnote notes # List all notes
|
|
|
45
45
|
pnote notes --tag "AI/art" # Filter by tag
|
|
46
46
|
pnote notes --archived # Show archived
|
|
47
47
|
pnote notes --pinned # Show pinned only
|
|
48
|
+
pnote notes --protected # Show only PIN-protected notes
|
|
48
49
|
pnote notes get <id> # Get note details
|
|
50
|
+
pnote notes get <id> --latest # Get note with latest snippet only
|
|
49
51
|
pnote notes create "Title" # Create new note
|
|
50
52
|
pnote notes update <id> --title "New Title" # Update title
|
|
51
53
|
pnote notes update <id> --tags a b c # Replace tags
|
|
@@ -57,12 +59,12 @@ pnote notes delete <id> # Delete note
|
|
|
57
59
|
### Snippets
|
|
58
60
|
|
|
59
61
|
```bash
|
|
60
|
-
pnote snippet <note-id>
|
|
61
|
-
pnote snippet <note-id>
|
|
62
|
-
pnote snippet copy <note-id>
|
|
63
|
-
echo "content" | pnote snippet add <note-id>
|
|
64
|
-
echo "updated" | pnote snippet update <snippet-id>
|
|
65
|
-
pnote snippet favorite <snippet-id>
|
|
62
|
+
pnote notes snippet <note-id> # Show latest snippet (pipe-friendly)
|
|
63
|
+
pnote notes snippet list <note-id> # List all versions
|
|
64
|
+
pnote notes snippet copy <note-id> # Copy to clipboard
|
|
65
|
+
echo "content" | pnote notes snippet add <note-id> # Add new version
|
|
66
|
+
echo "updated" | pnote notes snippet update <snippet-id> # Update existing
|
|
67
|
+
pnote notes snippet favorite <snippet-id> # Toggle favorite
|
|
66
68
|
```
|
|
67
69
|
|
|
68
70
|
### Tags
|
|
@@ -90,6 +92,38 @@ pnote search "query" --notes-only # Notes only
|
|
|
90
92
|
pnote search "query" --limit 50 # Limit results
|
|
91
93
|
```
|
|
92
94
|
|
|
95
|
+
|
|
96
|
+
### PIN Protection
|
|
97
|
+
|
|
98
|
+
Notes can be PIN-protected (encrypted server-side). Set your PIN in the PromptNote web app under Settings.
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pnote pin status # Check PIN configuration and cache status
|
|
102
|
+
pnote pin list # List protected notes (metadata only)
|
|
103
|
+
|
|
104
|
+
# Access protected notes
|
|
105
|
+
PNOTE_PIN=1234 pnote notes --protected
|
|
106
|
+
PNOTE_PIN=1234 pnote notes get <protected-note-id>
|
|
107
|
+
echo "1234" | pnote notes get <id> --pin-stdin
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**PIN resolution order:** `-p` flag → `--pin-stdin` → `PNOTE_PIN` env var → 5-min session cache → interactive prompt (TTY only).
|
|
111
|
+
|
|
112
|
+
### Agent Skills Sync
|
|
113
|
+
|
|
114
|
+
Sync agent skill files between PromptNote cloud and your local agent directories.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnote skills # List skills in cloud
|
|
118
|
+
pnote skills pull # Pull all globally (~/.agents/skills/ + symlinks)
|
|
119
|
+
pnote skills pull <name> # Pull a specific skill globally
|
|
120
|
+
pnote skills pull --project # Pull project-level (.agents/skills/ + symlinks)
|
|
121
|
+
pnote skills pull --dry-run # Preview without writing files
|
|
122
|
+
pnote skills push <dir> # Upload local skill directory to cloud
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Skills are written to `.agents/skills/<name>/` (canonical store) and symlinked into `.claude/skills/`, `.windsurf/skills/`, and other installed agent directories automatically.
|
|
126
|
+
|
|
93
127
|
## Global Options
|
|
94
128
|
|
|
95
129
|
| Option | Description |
|
|
@@ -105,6 +139,7 @@ pnote search "query" --limit 50 # Limit results
|
|
|
105
139
|
| Variable | Description |
|
|
106
140
|
|----------|-------------|
|
|
107
141
|
| `PNOTE_TOKEN` | PAT token (overrides stored credentials) |
|
|
142
|
+
| `PNOTE_PIN` | PIN for accessing protected notes |
|
|
108
143
|
| `NO_COLOR` | Disable colors |
|
|
109
144
|
| `PNOTE_API_ENDPOINT` | Custom API endpoint |
|
|
110
145
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command12 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/lib/errors.ts
|
|
7
7
|
import pc from "picocolors";
|
|
@@ -2361,6 +2361,28 @@ function printNotice(current, latest, packageName) {
|
|
|
2361
2361
|
].join("\n");
|
|
2362
2362
|
process.stderr.write(box);
|
|
2363
2363
|
}
|
|
2364
|
+
function getVersionHelpLine(currentVersion, cliName) {
|
|
2365
|
+
const useColor = process.stderr.isTTY && !process.env.NO_COLOR && process.env.TERM !== "dumb";
|
|
2366
|
+
const dim = useColor ? pc15.dim : (s) => s;
|
|
2367
|
+
const yellow = useColor ? pc15.yellow : (s) => s;
|
|
2368
|
+
const bold = useColor ? pc15.bold : (s) => s;
|
|
2369
|
+
let newer = null;
|
|
2370
|
+
try {
|
|
2371
|
+
const cache = readCache();
|
|
2372
|
+
if (cache && isOlderVersion(currentVersion, cache.latestVersion)) {
|
|
2373
|
+
newer = cache.latestVersion;
|
|
2374
|
+
}
|
|
2375
|
+
} catch {
|
|
2376
|
+
}
|
|
2377
|
+
if (newer) {
|
|
2378
|
+
return `
|
|
2379
|
+
${dim("v" + currentVersion)} \u2192 ${bold(yellow("v" + newer))} ${dim(`(run: ${cliName} update)`)}
|
|
2380
|
+
`;
|
|
2381
|
+
}
|
|
2382
|
+
return `
|
|
2383
|
+
${dim("v" + currentVersion)}
|
|
2384
|
+
`;
|
|
2385
|
+
}
|
|
2364
2386
|
async function checkAndNotifyUpdate(currentVersion, packageName) {
|
|
2365
2387
|
if (!process.stderr.isTTY) return;
|
|
2366
2388
|
if (process.env.NO_UPDATE_NOTIFIER) return;
|
|
@@ -2386,12 +2408,98 @@ async function checkAndNotifyUpdate(currentVersion, packageName) {
|
|
|
2386
2408
|
}
|
|
2387
2409
|
}
|
|
2388
2410
|
|
|
2411
|
+
// src/commands/update.ts
|
|
2412
|
+
import { Command as Command10 } from "commander";
|
|
2413
|
+
import { spawnSync } from "child_process";
|
|
2414
|
+
import pc16 from "picocolors";
|
|
2415
|
+
function isOlderVersion2(current, latest) {
|
|
2416
|
+
const parse = (v) => v.split(".").map(Number);
|
|
2417
|
+
const [cMaj, cMin, cPat] = parse(current);
|
|
2418
|
+
const [lMaj, lMin, lPat] = parse(latest);
|
|
2419
|
+
if (cMaj !== lMaj) return cMaj < lMaj;
|
|
2420
|
+
if (cMin !== lMin) return cMin < lMin;
|
|
2421
|
+
return cPat < lPat;
|
|
2422
|
+
}
|
|
2423
|
+
function detectPackageManager() {
|
|
2424
|
+
const ua = process.env.npm_config_user_agent ?? "";
|
|
2425
|
+
if (ua.startsWith("pnpm")) return "pnpm";
|
|
2426
|
+
return "npm";
|
|
2427
|
+
}
|
|
2428
|
+
var updateCommand = new Command10("update").description("Check for updates and upgrade to the latest version").action(async () => {
|
|
2429
|
+
const noColor = !process.stderr.isTTY || !!process.env.NO_COLOR || process.env.TERM === "dumb";
|
|
2430
|
+
const bold = noColor ? (s) => s : pc16.bold;
|
|
2431
|
+
const dim = noColor ? (s) => s : pc16.dim;
|
|
2432
|
+
const green = noColor ? (s) => s : pc16.green;
|
|
2433
|
+
try {
|
|
2434
|
+
process.stderr.write(dim("Checking for updates\u2026") + "\n");
|
|
2435
|
+
const res = await fetch(
|
|
2436
|
+
`https://registry.npmjs.org/${"pnote"}/latest`,
|
|
2437
|
+
{ signal: AbortSignal.timeout(5e3) }
|
|
2438
|
+
);
|
|
2439
|
+
if (!res.ok) throw new Error(`Registry returned ${res.status}`);
|
|
2440
|
+
const data = await res.json();
|
|
2441
|
+
const latest = data.version;
|
|
2442
|
+
const current = "0.4.3";
|
|
2443
|
+
if (!isOlderVersion2(current, latest)) {
|
|
2444
|
+
console.log(green("\u2713") + ` Already on the latest version (${bold("v" + current)})`);
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
const pm = detectPackageManager();
|
|
2448
|
+
const installArgs = pm === "pnpm" ? ["add", "-g", "pnote"] : ["install", "-g", "pnote"];
|
|
2449
|
+
const installCmd = `${pm} ${installArgs.join(" ")}`;
|
|
2450
|
+
console.log(`Update available: ${dim("v" + current)} \u2192 ${bold("v" + latest)}`);
|
|
2451
|
+
console.log(dim("Running: ") + bold(installCmd));
|
|
2452
|
+
console.log("");
|
|
2453
|
+
const result = spawnSync(pm, installArgs, { stdio: "inherit" });
|
|
2454
|
+
if (result.status !== 0) {
|
|
2455
|
+
process.exit(result.status ?? 1);
|
|
2456
|
+
}
|
|
2457
|
+
console.log("");
|
|
2458
|
+
console.log(green("\u2713") + ` Updated to ${bold("v" + latest)}`);
|
|
2459
|
+
} catch (err) {
|
|
2460
|
+
handleError(err);
|
|
2461
|
+
}
|
|
2462
|
+
});
|
|
2463
|
+
|
|
2464
|
+
// src/commands/schema.ts
|
|
2465
|
+
import { Command as Command11 } from "commander";
|
|
2466
|
+
function mapOption(opt) {
|
|
2467
|
+
const result = {
|
|
2468
|
+
flags: opt.flags,
|
|
2469
|
+
description: opt.description
|
|
2470
|
+
};
|
|
2471
|
+
if (opt.defaultValue !== void 0) {
|
|
2472
|
+
result.defaultValue = opt.defaultValue;
|
|
2473
|
+
}
|
|
2474
|
+
return result;
|
|
2475
|
+
}
|
|
2476
|
+
function mapCommand(cmd) {
|
|
2477
|
+
return {
|
|
2478
|
+
name: cmd.name(),
|
|
2479
|
+
description: cmd.description(),
|
|
2480
|
+
aliases: cmd.aliases(),
|
|
2481
|
+
options: cmd.options.map(mapOption),
|
|
2482
|
+
subcommands: cmd.commands.map(mapCommand)
|
|
2483
|
+
};
|
|
2484
|
+
}
|
|
2485
|
+
var schemaCommand = new Command11("schema").description("Output full command schema as JSON (for AI agent discovery)").action((_opts, cmd) => {
|
|
2486
|
+
const root = cmd.parent ?? cmd;
|
|
2487
|
+
const schema = {
|
|
2488
|
+
name: root.name(),
|
|
2489
|
+
version: "0.4.3",
|
|
2490
|
+
description: root.description(),
|
|
2491
|
+
globalOptions: root.options.map(mapOption),
|
|
2492
|
+
commands: root.commands.map(mapCommand)
|
|
2493
|
+
};
|
|
2494
|
+
console.log(JSON.stringify(schema, null, 2));
|
|
2495
|
+
});
|
|
2496
|
+
|
|
2389
2497
|
// src/index.ts
|
|
2390
|
-
var program = new
|
|
2391
|
-
program.name("pnote").description("pnote - The PromptNote CLI").version("0.4.
|
|
2498
|
+
var program = new Command12();
|
|
2499
|
+
program.name("pnote").description("pnote - The PromptNote CLI").version("0.4.3", "-V, --version", "Show version number").option("--json", "Output as JSON (for scripting)").option("--no-color", "Disable colored output").option("--plain", "Force plain text output (no formatting)").option("-p, --pin <pin>", "PIN for accessing protected notes").option("--pin-stdin", "Read PIN from stdin (first line only)").configureHelp({
|
|
2392
2500
|
sortSubcommands: true,
|
|
2393
2501
|
sortOptions: true
|
|
2394
|
-
}).addHelpText(
|
|
2502
|
+
}).addHelpText("before", () => getVersionHelpLine("0.4.3", program.name())).addHelpText(
|
|
2395
2503
|
"after",
|
|
2396
2504
|
`
|
|
2397
2505
|
PIN Protection:
|
|
@@ -2420,8 +2528,10 @@ program.addCommand(searchCommand);
|
|
|
2420
2528
|
program.addCommand(shareCommand);
|
|
2421
2529
|
program.addCommand(pinCommand);
|
|
2422
2530
|
program.addCommand(skillsCommand);
|
|
2531
|
+
program.addCommand(updateCommand);
|
|
2532
|
+
program.addCommand(schemaCommand);
|
|
2423
2533
|
program.hook("preAction", async () => {
|
|
2424
|
-
await checkAndNotifyUpdate("0.4.
|
|
2534
|
+
await checkAndNotifyUpdate("0.4.3", "pnote");
|
|
2425
2535
|
});
|
|
2426
2536
|
process.on("SIGINT", () => {
|
|
2427
2537
|
console.error("\nInterrupted");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/lib/errors.ts","../src/commands/auth/index.ts","../src/commands/auth/login.ts","../src/lib/config.ts","../src/commands/auth/token.ts","../src/lib/api.ts","../src/commands/auth/logout.ts","../src/commands/auth/whoami.ts","../src/commands/notes/index.ts","../src/lib/output.ts","../src/commands/notes/list.ts","../src/commands/notes/get.ts","../src/commands/notes/create.ts","../src/commands/notes/archive.ts","../src/commands/notes/pin.ts","../src/commands/notes/delete.ts","../src/commands/notes/update.ts","../src/commands/notes/snippetCmd.ts","../src/commands/snippet/show.ts","../src/commands/snippet/copy.ts","../src/lib/clipboard.ts","../src/commands/snippet/add.ts","../src/commands/snippet/update.ts","../src/commands/snippet/favorite.ts","../src/lib/pin.ts","../src/commands/snippet/index.ts","../src/commands/tags/index.ts","../src/commands/tags/list.ts","../src/commands/tags/rename.ts","../src/commands/tags/merge.ts","../src/commands/search.ts","../src/commands/share/index.ts","../src/commands/share/tags.ts","../src/commands/share/notes.ts","../src/commands/skills/index.ts","../src/commands/skills/list.ts","../src/commands/skills/pull.ts","../src/commands/skills/push.ts","../src/commands/pin/index.ts","../src/commands/pin/statusAction.ts","../src/commands/pin/listAction.ts","../src/lib/update-check.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { handleError } from './lib/errors.js';\nimport { authCommand } from './commands/auth/index.js';\nimport { notesCommand } from './commands/notes/index.js';\nimport { snippetCommand } from './commands/snippet/index.js';\nimport { tagsCommand } from './commands/tags/index.js';\nimport { searchCommand } from './commands/search.js';\nimport { shareCommand } from './commands/share/index.js';\nimport { skillsCommand } from './commands/skills/index.js';\nimport { pinCommand } from './commands/pin/index.js';\nimport { checkAndNotifyUpdate } from './lib/update-check.js';\n\ndeclare const CLI_VERSION: string;\ndeclare const CLI_PACKAGE_NAME: string;\n\nconst program = new Command();\n\nprogram\n .name('pnote')\n .description('pnote - The PromptNote CLI')\n .version(CLI_VERSION, '-V, --version', 'Show version number')\n .option('--json', 'Output as JSON (for scripting)')\n .option('--no-color', 'Disable colored output')\n .option('--plain', 'Force plain text output (no formatting)')\n .option('-p, --pin <pin>', 'PIN for accessing protected notes')\n .option('--pin-stdin', 'Read PIN from stdin (first line only)')\n .configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n })\n .addHelpText(\n 'after',\n `\nPIN Protection:\n Protected notes require a PIN to access their content.\n You can provide the PIN in several ways:\n -p, --pin <pin> Pass PIN directly (visible in history)\n --pin-stdin Read PIN from stdin\n PNOTE_PIN Set as environment variable (recommended)\n\nExamples:\n $ pnote notes List all notes\n $ pnote notes --tag \"AI/art\" Filter notes by tag\n $ pnote notes get abc123 -p 1234 Get protected note with PIN\n $ export PNOTE_PIN=1234 && pnote notes\n $ pnote snippet copy abc123 Copy snippet to clipboard\n $ pnote search \"portrait\" Search notes and snippets\n\nDocumentation: https://promptnoteapp.com/docs\n`\n );\n\n// Add commands\nprogram.addCommand(authCommand);\nprogram.addCommand(notesCommand);\nprogram.addCommand(snippetCommand);\nprogram.addCommand(tagsCommand);\nprogram.addCommand(searchCommand);\nprogram.addCommand(shareCommand);\nprogram.addCommand(pinCommand);\nprogram.addCommand(skillsCommand);\n\n// Update check before every command (non-blocking on cache hit, 2s max on miss)\nprogram.hook('preAction', async () => {\n await checkAndNotifyUpdate(CLI_VERSION, CLI_PACKAGE_NAME);\n});\n\n// Handle signals\nprocess.on('SIGINT', () => {\n console.error('\\nInterrupted');\n process.exit(130);\n});\n\nprocess.on('SIGTERM', () => {\n process.exit(0);\n});\n\n// Suppress broken pipe errors (when piping to head, etc.)\nprocess.stdout.on('error', (err) => {\n if (err.code === 'EPIPE') {\n process.exit(0);\n }\n throw err;\n});\n\n// Parse and run\nprogram.parseAsync(process.argv).catch((error) => {\n const noColor = program.opts().noColor ?? process.env.NO_COLOR !== undefined;\n handleError(error, noColor);\n});\n","import pc from 'picocolors';\n\n// Exit codes following Unix conventions\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTH_ERROR: 2,\n NOT_FOUND: 3,\n NETWORK_ERROR: 4,\n} as const;\n\nexport type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];\n\nexport class CLIError extends Error {\n constructor(\n message: string,\n public exitCode: ExitCodeType = ExitCode.GENERAL_ERROR,\n public hint?: string\n ) {\n super(message);\n this.name = 'CLIError';\n }\n}\n\nexport class AuthError extends CLIError {\n constructor(message: string, hint?: string) {\n super(message, ExitCode.AUTH_ERROR, hint);\n this.name = 'AuthError';\n }\n}\n\nexport class NotFoundError extends CLIError {\n constructor(resource: string, id: string) {\n super(`${resource} not found (id: ${id})`, ExitCode.NOT_FOUND);\n this.name = 'NotFoundError';\n }\n}\n\nexport class NetworkError extends CLIError {\n constructor(message: string = 'Network error. Check your connection.') {\n super(message, ExitCode.NETWORK_ERROR);\n this.name = 'NetworkError';\n }\n}\n\n// Error formatting for stderr\n\nexport function formatError(error: unknown, noColor: boolean = false): string {\n const red = noColor ? (s: string) => s : pc.red;\n const dim = noColor ? (s: string) => s : pc.dim;\n\n if (error instanceof CLIError) {\n let message = `${red('Error:')} ${error.message}`;\n if (error.hint) {\n message += `\\n${dim('Hint:')} ${error.hint}`;\n }\n return message;\n }\n\n if (error instanceof Error) {\n return `${red('Error:')} ${error.message}`;\n }\n\n return `${red('Error:')} ${String(error)}`;\n}\n\n// Handle errors and exit\n\nexport function handleError(error: unknown, noColor: boolean = false): never {\n console.error(formatError(error, noColor));\n\n if (error instanceof CLIError) {\n process.exit(error.exitCode);\n }\n\n process.exit(ExitCode.GENERAL_ERROR);\n}\n\n// Parse API errors\n\nexport function parseApiError(statusCode: number, body: string): CLIError {\n try {\n const parsed = JSON.parse(body);\n const message = parsed.error?.message || parsed.message || body;\n\n switch (statusCode) {\n case 401:\n return new AuthError(\n message.includes('Unauthorized') ? 'Not logged in or invalid token' : message,\n \"Run 'pnote auth login' to authenticate\"\n );\n case 403:\n return new CLIError('Permission denied', ExitCode.AUTH_ERROR);\n case 404:\n return new CLIError('Resource not found', ExitCode.NOT_FOUND);\n default:\n return new CLIError(message);\n }\n } catch {\n return new CLIError(`HTTP ${statusCode}: ${body}`);\n }\n}\n","import { Command } from 'commander';\nimport { loginAction } from './login.js';\nimport { tokenAction } from './token.js';\nimport { logoutAction } from './logout.js';\nimport { whoamiAction } from './whoami.js';\n\nexport const authCommand = new Command('auth')\n .description('Manage authentication')\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote auth login Open browser to login\n $ pnote auth token pn_xxx Set token directly\n $ pnote auth whoami Show current user\n $ pnote auth logout Remove credentials\n`\n );\n\nauthCommand\n .command('login')\n .description('Login to PromptNote (opens browser)')\n .action(loginAction);\n\nauthCommand\n .command('token')\n .description('Set API token directly')\n .argument('<token>', 'Personal Access Token (pn_xxx)')\n .action(tokenAction);\n\nauthCommand\n .command('logout')\n .description('Remove stored credentials')\n .action(logoutAction);\n\nauthCommand\n .command('whoami')\n .description('Show current authenticated user')\n .action(whoamiAction);\n","import pc from 'picocolors';\nimport { isLoggedIn, getCredentialsPath } from '../../lib/config.js';\n\nexport async function loginAction(): Promise<void> {\n if (isLoggedIn()) {\n console.log(pc.yellow('Already logged in.'));\n console.log(pc.dim(`Credentials stored at: ${getCredentialsPath()}`));\n console.log('');\n console.log(`Run ${pc.cyan(\"'pnote auth logout'\")} to logout first.`);\n return;\n }\n\n console.log(pc.bold('Login to PromptNote'));\n console.log('');\n console.log('To authenticate, you need a Personal Access Token (PAT).');\n console.log('');\n console.log(pc.dim('Steps:'));\n console.log(' 1. Open ' + pc.cyan('https://app.promptnoteapp.com'));\n console.log(' 2. Go to Settings > API Tokens');\n console.log(' 3. Generate a new token');\n console.log(' 4. Run: ' + pc.cyan(\"pnote auth token <your-token>\"));\n console.log('');\n console.log(pc.dim('Or set the PNOTE_TOKEN environment variable.'));\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, chmodSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport type { Credentials, Config } from '../types/index.js';\n\n// XDG Base Directory paths\nexport function getConfigDir(): string {\n const xdgConfig = process.env.XDG_CONFIG_HOME;\n if (xdgConfig) {\n return join(xdgConfig, 'pnote');\n }\n\n // macOS: also check ~/Library/Application Support\n const platform = process.platform;\n if (platform === 'darwin') {\n const macPath = join(homedir(), 'Library', 'Application Support', 'pnote');\n if (existsSync(macPath)) {\n return macPath;\n }\n }\n\n // Default to ~/.config/pnote\n return join(homedir(), '.config', 'pnote');\n}\n\nfunction ensureConfigDir(): string {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n return dir;\n}\n\n// Credentials management\n\nconst CREDENTIALS_FILE = 'credentials.json';\n\nexport function getCredentialsPath(): string {\n return join(getConfigDir(), CREDENTIALS_FILE);\n}\n\nexport function loadCredentials(): Credentials | null {\n // Priority 1: Environment variable\n const envToken = process.env.PNOTE_TOKEN;\n if (envToken) {\n return {\n token: envToken,\n created_at: new Date().toISOString(),\n };\n }\n\n // Priority 2: Credentials file\n const path = getCredentialsPath();\n if (!existsSync(path)) {\n return null;\n }\n\n try {\n const content = readFileSync(path, 'utf-8');\n return JSON.parse(content) as Credentials;\n } catch {\n return null;\n }\n}\n\nexport function saveCredentials(credentials: Credentials): void {\n const dir = ensureConfigDir();\n const path = join(dir, CREDENTIALS_FILE);\n\n writeFileSync(path, JSON.stringify(credentials, null, 2), 'utf-8');\n\n // Set file permissions to 600 (owner read/write only)\n chmodSync(path, 0o600);\n}\n\nexport function deleteCredentials(): boolean {\n const path = getCredentialsPath();\n if (existsSync(path)) {\n unlinkSync(path);\n return true;\n }\n return false;\n}\n\n// Token utilities\n\nexport function getToken(): string | null {\n const creds = loadCredentials();\n return creds?.token ?? null;\n}\n\nexport function isLoggedIn(): boolean {\n return getToken() !== null;\n}\n\nexport function validateTokenFormat(token: string): boolean {\n // PAT format: pn_ + 32 characters\n return /^pn_[A-Za-z0-9_-]{20,50}$/.test(token);\n}\n\n// Config management (optional, for future use)\n\nconst CONFIG_FILE = 'config.json';\n\nexport function loadConfig(): Config {\n const path = join(getConfigDir(), CONFIG_FILE);\n if (!existsSync(path)) {\n return {};\n }\n\n try {\n const content = readFileSync(path, 'utf-8');\n return JSON.parse(content) as Config;\n } catch {\n return {};\n }\n}\n\nexport function saveConfig(config: Config): void {\n const dir = ensureConfigDir();\n const path = join(dir, CONFIG_FILE);\n writeFileSync(path, JSON.stringify(config, null, 2), 'utf-8');\n}\n\n// API Endpoint\n\nconst DEFAULT_API_ENDPOINT = 'https://tafnybfhwybgijozwfyq.supabase.co/functions/v1/promptnote-mcp/mcp';\n\nexport function getApiEndpoint(): string {\n const config = loadConfig();\n return config.api_endpoint ?? process.env.PNOTE_API_ENDPOINT ?? DEFAULT_API_ENDPOINT;\n}\n\n// PIN utilities\n\n/**\n * Get PIN from environment variable\n * Note: This is for display/status purposes only.\n * The MCP server reads PROMPTNOTE_PIN from its own environment configuration,\n * not from CLI requests. To access protected notes via MCP, users must configure\n * PROMPTNOTE_PIN in their MCP server config (e.g., claude_desktop_config.json).\n *\n * For CLI-specific operations, we use PNOTE_PIN to maintain consistency.\n */\nexport function getEnvPin(): string | null {\n return process.env.PNOTE_PIN ?? process.env.PROMPTNOTE_PIN ?? null;\n}\n","import pc from 'picocolors';\nimport { validateTokenFormat, saveCredentials, getCredentialsPath } from '../../lib/config.js';\nimport { verifyToken } from '../../lib/api.js';\nimport { CLIError, handleError } from '../../lib/errors.js';\n\nexport async function tokenAction(token: string): Promise<void> {\n // Validate token format\n if (!validateTokenFormat(token)) {\n throw new CLIError(\n 'Invalid token format',\n 1,\n \"Token should start with 'pn_' followed by 20-50 characters\"\n );\n }\n\n console.log(pc.dim('Verifying token...'));\n\n try {\n const result = await verifyToken(token);\n\n if (!result.valid) {\n throw new CLIError(\n 'Invalid token',\n 2,\n 'The token was rejected by the server. Please generate a new one.'\n );\n }\n\n // Save credentials\n saveCredentials({\n token,\n email: result.email,\n created_at: new Date().toISOString(),\n });\n\n console.log(pc.green('✓') + ' Token saved successfully!');\n console.log(pc.dim(`Credentials stored at: ${getCredentialsPath()}`));\n console.log('');\n console.log(`You can now use ${pc.cyan('pnote')} commands.`);\n } catch (error) {\n handleError(error);\n }\n}\n","import { getToken, getApiEndpoint } from './config.js';\nimport { AuthError, NetworkError, CLIError, ExitCode } from './errors.js';\n\n// REST API base URL (replace /mcp with /v1)\nfunction getRestApiBase(): string {\n const mcpEndpoint = getApiEndpoint();\n return mcpEndpoint.replace(/\\/mcp$/, '/v1');\n}\n\nexport interface RequestOptions {\n pin?: string;\n timeout?: number;\n}\n\n// Generic REST API call\nasync function callRestApi<T>(\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE',\n path: string,\n body?: Record<string, unknown>,\n options: RequestOptions = {}\n): Promise<T> {\n const token = getToken();\n if (!token) {\n throw new AuthError(\n 'Not logged in',\n \"Run 'pnote auth login' or 'pnote auth token <token>' to authenticate\"\n );\n }\n\n const baseUrl = getRestApiBase();\n const url = `${baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n };\n\n // Add PIN header if provided\n if (options.pin) {\n headers['X-PromptNote-PIN'] = options.pin;\n }\n\n let response: Response;\n try {\n const fetchOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(options.timeout ?? 30000),\n };\n\n if (body && (method === 'POST' || method === 'PATCH')) {\n fetchOptions.body = JSON.stringify(body);\n }\n\n response = await fetch(url, fetchOptions);\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'TimeoutError' || error.name === 'AbortError') {\n throw new NetworkError('Request timed out. Please try again.');\n }\n if (error.message.includes('fetch')) {\n throw new NetworkError('Unable to connect to PromptNote API. Check your internet connection.');\n }\n }\n throw new NetworkError();\n }\n\n // Handle HTTP errors\n if (!response.ok) {\n const errorBody = await response.json().catch(() => ({})) as { message?: string };\n\n if (response.status === 401) {\n throw new AuthError(\n errorBody.message || 'Invalid or expired token',\n \"Run 'pnote auth login' to re-authenticate\"\n );\n }\n\n if (response.status === 403) {\n throw new CLIError('Permission denied', ExitCode.AUTH_ERROR);\n }\n\n if (response.status === 404) {\n throw new CLIError(errorBody.message || 'Resource not found', ExitCode.NOT_FOUND);\n }\n\n if (response.status === 400) {\n throw new CLIError(errorBody.message || 'Invalid request', ExitCode.GENERAL_ERROR);\n }\n\n throw new CLIError(`API error (${response.status}): ${errorBody.message || 'Unknown error'}`);\n }\n\n return response.json() as Promise<T>;\n}\n\n// ============================================================\n// Notes API\n// ============================================================\n\nexport interface ListNotesParams {\n tag?: string;\n archived?: boolean;\n pinned?: boolean;\n deleted?: boolean;\n protected?: boolean;\n note_type?: 'note' | 'skill';\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport async function listNotes<T>(params: ListNotesParams = {}, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n if (params.tag) query.set('tag', params.tag);\n if (params.archived !== undefined) query.set('archived', String(params.archived));\n if (params.pinned !== undefined) query.set('pinned', String(params.pinned));\n if (params.deleted !== undefined) query.set('deleted', String(params.deleted));\n if (params.protected !== undefined) query.set('protected', String(params.protected));\n if (params.note_type) query.set('note_type', params.note_type);\n if (params.search) query.set('search', params.search);\n if (params.limit) query.set('limit', String(params.limit));\n if (params.offset) query.set('offset', String(params.offset));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function getNote<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', `/notes/${id}`, undefined, options);\n}\n\nexport async function createNote<T>(\n data: { title: string; tags?: string[]; content?: string; note_type?: 'note' | 'skill' },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/notes', data, options);\n}\n\nexport async function updateNote<T>(\n id: string,\n data: { title?: string; tags?: string[]; archived?: boolean; pinned?: boolean },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('PATCH', `/notes/${id}`, data, options);\n}\n\nexport async function deleteNote<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('DELETE', `/notes/${id}`, undefined, options);\n}\n\n// ============================================================\n// Snippets API\n// ============================================================\n\nexport interface ListSnippetsParams {\n note_id: string;\n include_deleted?: boolean;\n limit?: number;\n}\n\nexport async function listSnippets<T>(params: ListSnippetsParams, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n query.set('note_id', params.note_id);\n if (params.include_deleted !== undefined) query.set('include_deleted', String(params.include_deleted));\n if (params.limit) query.set('limit', String(params.limit));\n\n return callRestApi<T>('GET', `/snippets?${query.toString()}`, undefined, options);\n}\n\nexport async function getSnippet<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', `/snippets/${id}`, undefined, options);\n}\n\nexport async function createSnippet<T>(\n data: { note_id: string; content: string; title?: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/snippets', data, options);\n}\n\nexport async function updateSnippet<T>(\n id: string,\n data: { content?: string; title?: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('PATCH', `/snippets/${id}`, data, options);\n}\n\nexport async function toggleFavorite<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('POST', `/snippets/${id}/favorite`, {}, options);\n}\n\n// ============================================================\n// Tags API\n// ============================================================\n\nexport interface ListTagsParams {\n include_archived?: boolean;\n}\n\nexport async function listTags<T>(params: ListTagsParams = {}, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n if (params.include_archived !== undefined) query.set('include_archived', String(params.include_archived));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/tags${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function renameTag<T>(\n data: { old_tag: string; new_tag: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/tags/rename', data, options);\n}\n\nexport async function mergeTags<T>(\n data: { source_tags: string[]; target_tag: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/tags/merge', data, options);\n}\n\n// ============================================================\n// Search API\n// ============================================================\n\nexport interface SearchParams {\n query: string;\n search_notes?: boolean;\n search_snippets?: boolean;\n limit?: number;\n}\n\nexport async function search<T>(params: SearchParams, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n query.set('q', params.query);\n if (params.search_notes !== undefined) query.set('search_notes', String(params.search_notes));\n if (params.search_snippets !== undefined) query.set('search_snippets', String(params.search_snippets));\n if (params.limit) query.set('limit', String(params.limit));\n\n return callRestApi<T>('GET', `/search?${query.toString()}`, undefined, options);\n}\n\n// ============================================================\n// PIN API\n// ============================================================\n\nexport async function checkPinStatus<T>(options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', '/pin/status', undefined, options);\n}\n\nexport async function listProtectedNotes<T>(\n params: { limit?: number; offset?: number } = {},\n options: RequestOptions = {}\n): Promise<T> {\n const query = new URLSearchParams();\n if (params.limit) query.set('limit', String(params.limit));\n if (params.offset) query.set('offset', String(params.offset));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/pin/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function verifyPin<T>(pin: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('POST', '/pin/verify', { pin }, options);\n}\n\n// ============================================================\n// Sharing API\n// ============================================================\n\nexport async function listSharedTags<T>(options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', '/share/tags', undefined, options);\n}\n\nexport async function getSharedTagNotes<T>(\n id: string,\n params: { limit?: number } = {},\n options: RequestOptions = {}\n): Promise<T> {\n const query = new URLSearchParams();\n if (params.limit) query.set('limit', String(params.limit));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/share/tags/${id}/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function listSharedNotes<T>(\n params: { include_revoked?: boolean } = {},\n options: RequestOptions = {}\n): Promise<T> {\n const query = new URLSearchParams();\n if (params.include_revoked !== undefined) query.set('include_revoked', String(params.include_revoked));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/share/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\n// ============================================================\n// Legacy MCP API (for backward compatibility and token verification)\n// ============================================================\n\nimport type { MCPRequest, MCPResponse } from '../types/index.js';\n\nlet requestId = 0;\n\nfunction getNextId(): number {\n return ++requestId;\n}\n\n/**\n * @deprecated Use REST API functions instead (listNotes, getNote, etc.)\n */\nexport async function callMCP<T>(\n toolName: string,\n args: Record<string, unknown> = {}\n): Promise<T> {\n const token = getToken();\n if (!token) {\n throw new AuthError(\n 'Not logged in',\n \"Run 'pnote auth login' or 'pnote auth token <token>' to authenticate\"\n );\n }\n\n const endpoint = getApiEndpoint();\n\n const request: MCPRequest = {\n jsonrpc: '2.0',\n id: getNextId(),\n method: 'tools/call',\n params: {\n name: toolName,\n arguments: args,\n },\n };\n\n let response: Response;\n try {\n response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify(request),\n signal: AbortSignal.timeout(30000),\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'TimeoutError' || error.name === 'AbortError') {\n throw new NetworkError('Request timed out. Please try again.');\n }\n if (error.message.includes('fetch')) {\n throw new NetworkError('Unable to connect to PromptNote API. Check your internet connection.');\n }\n }\n throw new NetworkError();\n }\n\n if (!response.ok) {\n const body = await response.text();\n\n if (response.status === 401) {\n throw new AuthError(\n 'Invalid or expired token',\n \"Run 'pnote auth login' to re-authenticate\"\n );\n }\n\n if (response.status === 403) {\n throw new CLIError('Permission denied', ExitCode.AUTH_ERROR);\n }\n\n throw new CLIError(`API error (${response.status}): ${body}`);\n }\n\n const mcpResponse = (await response.json()) as MCPResponse;\n\n if (mcpResponse.error) {\n throw new CLIError(`MCP error: ${mcpResponse.error.message}`);\n }\n\n if (!mcpResponse.result) {\n throw new CLIError('Invalid response from API');\n }\n\n const content = mcpResponse.result.content;\n if (!content || content.length === 0) {\n throw new CLIError('Empty response from API');\n }\n\n if (mcpResponse.result.isError) {\n const errorText = content[0]?.text || 'Unknown error';\n\n if (errorText.includes('not found') || errorText.includes('PGRST116')) {\n throw new CLIError('Resource not found', ExitCode.NOT_FOUND);\n }\n if (errorText.includes('Unauthorized')) {\n throw new AuthError(errorText);\n }\n\n throw new CLIError(errorText);\n }\n\n const textContent = content[0]?.text;\n if (!textContent) {\n throw new CLIError('No content in response');\n }\n\n try {\n return JSON.parse(textContent) as T;\n } catch {\n return textContent as T;\n }\n}\n\n// Verify token is valid by making a simple API call (using REST API)\nexport async function verifyToken(token: string): Promise<{ valid: boolean; email?: string }> {\n const baseUrl = getApiEndpoint().replace(/\\/mcp$/, '/v1');\n\n try {\n const response = await fetch(`${baseUrl}/notes?limit=1`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n signal: AbortSignal.timeout(10000),\n });\n\n if (response.status === 401) {\n return { valid: false };\n }\n\n if (!response.ok) {\n return { valid: false };\n }\n\n return { valid: true };\n } catch {\n throw new NetworkError('Unable to verify token. Check your internet connection.');\n }\n}\n","import pc from 'picocolors';\nimport { deleteCredentials, isLoggedIn } from '../../lib/config.js';\n\nexport async function logoutAction(): Promise<void> {\n if (!isLoggedIn()) {\n console.log(pc.dim('Not logged in.'));\n return;\n }\n\n const deleted = deleteCredentials();\n\n if (deleted) {\n console.log(pc.green('✓') + ' Logged out successfully.');\n } else {\n console.log(pc.dim('No credentials to remove.'));\n }\n\n // Remind about environment variable\n if (process.env.PNOTE_TOKEN) {\n console.log('');\n console.log(\n pc.yellow('Note:') +\n ' PNOTE_TOKEN environment variable is still set.'\n );\n console.log(pc.dim('Unset it with: unset PNOTE_TOKEN'));\n }\n}\n","import pc from 'picocolors';\nimport { loadCredentials, isLoggedIn, getCredentialsPath } from '../../lib/config.js';\nimport { listNotes } from '../../lib/api.js';\nimport { handleError, AuthError } from '../../lib/errors.js';\nimport type { ListNotesResponse } from '../../types/index.js';\n\nexport async function whoamiAction(): Promise<void> {\n if (!isLoggedIn()) {\n throw new AuthError(\n 'Not logged in',\n \"Run 'pnote auth login' to authenticate\"\n );\n }\n\n const creds = loadCredentials();\n if (!creds) {\n throw new AuthError('No credentials found');\n }\n\n try {\n // Verify token is still valid by making a simple API call\n const result = await listNotes<ListNotesResponse>({ limit: 1 });\n\n console.log(pc.green('✓') + ' Authenticated');\n console.log('');\n\n if (creds.email) {\n console.log(pc.dim('Email: ') + creds.email);\n }\n\n console.log(pc.dim('Token: ') + creds.token.slice(0, 7) + '...' + creds.token.slice(-4));\n console.log(pc.dim('Stored: ') + getCredentialsPath());\n\n if (process.env.PNOTE_TOKEN) {\n console.log(pc.dim('Source: ') + 'PNOTE_TOKEN environment variable');\n } else {\n console.log(pc.dim('Source: ') + 'credentials file');\n }\n\n console.log('');\n console.log(pc.dim(`Total notes: ${result.count}`));\n } catch (error) {\n handleError(error);\n }\n}\n","import { Command } from 'commander';\nimport { listNotesAction } from './list.js';\nimport { getNoteAction } from './get.js';\nimport { createNoteAction } from './create.js';\nimport { archiveNoteAction } from './archive.js';\nimport { pinNoteAction } from './pin.js';\nimport { deleteNoteAction } from './delete.js';\nimport { updateNoteAction } from './update.js';\nimport { notesSnippetCommand } from './snippetCmd.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n // Resolve PIN from various sources\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true, // Don't prompt interactively for list/search operations\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const notesCommand = new Command('notes')\n .description('List and manage notes')\n .option('--tag <tag>', 'Filter by tag (e.g., \"AI/art\")')\n .option('--archived', 'Show archived notes')\n .option('--pinned', 'Show only pinned notes')\n .option('--deleted', 'Show deleted notes')\n .option('--protected', 'Show only PIN-protected notes')\n .option('--search <query>', 'Search notes by title')\n .option('--limit <n>', 'Limit number of results', '50')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listNotesAction(options, ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote notes List all active notes\n $ pnote notes --tag \"AI/art\" Filter by tag\n $ pnote notes --archived Show archived notes\n $ pnote notes --pinned Show only pinned notes\n $ pnote notes get abc123 Get note with all snippet versions\n $ pnote notes get abc123 --latest Get note with only latest snippet\n $ pnote notes create \"My Note\" Create a new note\n $ pnote notes snippet abc123 Show latest snippet (pipe-friendly)\n $ pnote notes snippet list abc123 Show all snippet versions\n $ cat file.txt | pnote notes snippet add abc123\n`\n );\n\nnotesCommand\n .command('get')\n .description('Get a note with all its snippet versions')\n .argument('<id>', 'Note ID')\n .option('--latest', 'Show only the latest snippet version')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await getNoteAction(id, options, ctx);\n });\n\nnotesCommand\n .command('create')\n .description('Create a new note')\n .argument('<title>', 'Note title')\n .option('--tags <tags...>', 'Tags for the note')\n .option('--content <content>', 'Initial snippet content')\n .action(async (title: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await createNoteAction(title, options, ctx);\n });\n\nnotesCommand\n .command('archive')\n .description('Archive or unarchive a note')\n .argument('<id>', 'Note ID')\n .option('--undo', 'Unarchive the note')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await archiveNoteAction(id, options, ctx);\n });\n\nnotesCommand\n .command('pin')\n .description('Pin or unpin a note')\n .argument('<id>', 'Note ID')\n .action(async (id: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pinNoteAction(id, ctx);\n });\n\nnotesCommand\n .command('update')\n .description('Update a note title or tags')\n .argument('<id>', 'Note ID')\n .option('--title <title>', 'New title')\n .option('--tags <tags...>', 'New tags (replaces existing)')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await updateNoteAction(id, options, ctx);\n });\n\nnotesCommand\n .command('delete')\n .description('Delete a note (soft delete)')\n .argument('<id>', 'Note ID')\n .option('--force', 'Skip confirmation')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await deleteNoteAction(id, options, ctx);\n });\n\nnotesCommand.addCommand(notesSnippetCommand);\n","import pc from 'picocolors';\nimport type {\n CLIContext, Note, Snippet, Tag, TagHierarchy,\n ListSharedTagsResponse, GetSharedTagNotesResponse, ListSharedNotesResponse,\n} from '../types/index.js';\n\n// Check if output should use colors\nfunction shouldUseColor(ctx: CLIContext): boolean {\n if (ctx.noColor) return false;\n if (process.env.NO_COLOR) return false;\n if (process.env.TERM === 'dumb') return false;\n return process.stdout.isTTY ?? false;\n}\n\n// Check if output should be formatted for humans\nfunction isHumanOutput(ctx: CLIContext): boolean {\n if (ctx.json) return false;\n if (ctx.plain) return false;\n return process.stdout.isTTY ?? false;\n}\n\n// Color helpers\nfunction getColors(ctx: CLIContext) {\n const useColor = shouldUseColor(ctx);\n return {\n dim: useColor ? pc.dim : (s: string) => s,\n bold: useColor ? pc.bold : (s: string) => s,\n green: useColor ? pc.green : (s: string) => s,\n yellow: useColor ? pc.yellow : (s: string) => s,\n blue: useColor ? pc.blue : (s: string) => s,\n cyan: useColor ? pc.cyan : (s: string) => s,\n red: useColor ? pc.red : (s: string) => s,\n magenta: useColor ? pc.magenta : (s: string) => s,\n };\n}\n\n// Format relative time\nfunction formatRelativeTime(dateStr: string): string {\n const date = new Date(dateStr);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffSecs = Math.floor(diffMs / 1000);\n const diffMins = Math.floor(diffSecs / 60);\n const diffHours = Math.floor(diffMins / 60);\n const diffDays = Math.floor(diffHours / 24);\n\n if (diffDays > 30) {\n return date.toLocaleDateString();\n }\n if (diffDays > 0) {\n return `${diffDays}d ago`;\n }\n if (diffHours > 0) {\n return `${diffHours}h ago`;\n }\n if (diffMins > 0) {\n return `${diffMins}m ago`;\n }\n return 'just now';\n}\n\n// Truncate string with ellipsis\nfunction truncate(str: string, maxLen: number): string {\n if (str.length <= maxLen) return str;\n return str.slice(0, maxLen - 1) + '…';\n}\n\n// Pad string to fixed width\nfunction pad(str: string, width: number): string {\n if (str.length >= width) return str.slice(0, width);\n return str + ' '.repeat(width - str.length);\n}\n\n// Output JSON to stdout\nexport function outputJson(data: unknown): void {\n console.log(JSON.stringify(data, null, 2));\n}\n\n// Output notes list\nexport function outputNotes(notes: Note[], ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(notes);\n return;\n }\n\n if (notes.length === 0) {\n const c = getColors(ctx);\n console.log(c.dim('No notes found.'));\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n // Table header\n console.log(\n c.dim(pad('ID', 12)) +\n ' ' +\n c.dim(pad('TITLE', 30)) +\n ' ' +\n c.dim(pad('TAGS', 20)) +\n ' ' +\n c.dim('UPDATED')\n );\n\n for (const note of notes) {\n const id = truncate(note.id.slice(0, 8), 12);\n const title = truncate(note.title || '(untitled)', 30);\n const tags = truncate(note.tags.join(', ') || '-', 20);\n const updated = formatRelativeTime(note.updated_at);\n\n let line = pad(id, 12) + ' ' + pad(title, 30) + ' ' + pad(tags, 20) + ' ' + updated;\n\n // Add indicators\n const indicators: string[] = [];\n if (note.pinned) indicators.push(c.yellow('*'));\n if (note.archived) indicators.push(c.dim('[A]'));\n if (note.is_protected) indicators.push(c.magenta('[P]'));\n\n if (indicators.length > 0) {\n line = indicators.join('') + ' ' + line;\n }\n\n console.log(line);\n }\n } else {\n // Plain output - one note per line, tab-separated\n for (const note of notes) {\n console.log(\n [note.id, note.title, note.tags.join(','), note.updated_at].join('\\t')\n );\n }\n }\n}\n\n// Output single note with its snippet history\nexport function outputNote(note: Note, snippets: Snippet[], ctx: CLIContext): void {\n const latestSnippet = snippets.length > 0 ? snippets[snippets.length - 1] : null;\n\n if (ctx.json) {\n outputJson({ ...note, snippets, latest_snippet: latestSnippet });\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n console.log(c.bold(note.title || '(untitled)'));\n console.log(c.dim('ID: ') + note.id);\n console.log(c.dim('Tags: ') + (note.tags.length > 0 ? note.tags.join(', ') : '-'));\n console.log(c.dim('Created: ') + new Date(note.created_at).toLocaleString());\n console.log(c.dim('Updated: ') + new Date(note.updated_at).toLocaleString());\n\n const status: string[] = [];\n if (note.pinned) status.push(c.yellow('pinned'));\n if (note.archived) status.push(c.dim('archived'));\n if (note.is_protected) status.push(c.magenta('protected'));\n if (status.length > 0) {\n console.log(c.dim('Status: ') + status.join(', '));\n }\n\n if (snippets.length === 0) {\n console.log('');\n console.log(c.dim('(no content)'));\n } else {\n for (const snippet of snippets) {\n const header = `v${snippet.version}` +\n (snippet.favorite ? c.yellow(' ★') : '') +\n c.dim(` (${formatRelativeTime(snippet.created_at)})`);\n console.log('');\n console.log(c.dim('--- Snippet ') + c.bold(header) + c.dim(' ---'));\n console.log(snippet.content);\n }\n }\n } else {\n // Plain output\n console.log(`Title: ${note.title}`);\n console.log(`ID: ${note.id}`);\n console.log(`Tags: ${note.tags.join(', ')}`);\n for (const snippet of snippets) {\n console.log('');\n console.log(`v${snippet.version}\\t${snippet.content}`);\n }\n }\n}\n\n// Output snippet content\nexport function outputSnippet(snippet: Snippet, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(snippet);\n return;\n }\n\n // For snippet, just output the content directly (useful for piping)\n console.log(snippet.content);\n}\n\n// Output snippets list\nexport function outputSnippets(snippets: Snippet[], ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(snippets);\n return;\n }\n\n if (snippets.length === 0) {\n const c = getColors(ctx);\n console.log(c.dim('No snippets found.'));\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n for (const snippet of snippets) {\n const header = `v${snippet.version}` +\n (snippet.favorite ? c.yellow(' ★') : '') +\n c.dim(` (${formatRelativeTime(snippet.created_at)})`);\n\n console.log(c.bold(header));\n console.log(snippet.content);\n console.log('');\n }\n } else {\n for (const snippet of snippets) {\n console.log(`v${snippet.version}\\t${snippet.id}\\t${snippet.content.slice(0, 100)}`);\n }\n }\n}\n\n// Output tags tree\nexport function outputTags(tags: Tag[], hierarchy: TagHierarchy, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson({ tags, hierarchy });\n return;\n }\n\n if (tags.length === 0) {\n const c = getColors(ctx);\n console.log(c.dim('No tags found.'));\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n // Build tree structure\n const roots: string[] = [];\n const childrenMap: Map<string, string[]> = new Map();\n\n for (const tag of tags) {\n const parts = tag.tag.split('/');\n if (parts.length === 1) {\n roots.push(tag.tag);\n } else {\n const parent = parts.slice(0, -1).join('/');\n const children = childrenMap.get(parent) || [];\n children.push(tag.tag);\n childrenMap.set(parent, children);\n }\n }\n\n // Sort roots\n roots.sort();\n\n const tagCountMap = new Map(tags.map((t) => [t.tag, t.count]));\n\n function printTree(tagPath: string, prefix: string, isLast: boolean): void {\n const count = tagCountMap.get(tagPath) || 0;\n const name = tagPath.split('/').pop() || tagPath;\n const connector = isLast ? '└── ' : '├── ';\n\n console.log(prefix + connector + c.cyan(name) + c.dim(` (${count})`));\n\n const children = childrenMap.get(tagPath) || [];\n children.sort();\n\n const newPrefix = prefix + (isLast ? ' ' : '│ ');\n children.forEach((child, i) => {\n printTree(child, newPrefix, i === children.length - 1);\n });\n }\n\n roots.forEach((root, i) => {\n const count = tagCountMap.get(root) || 0;\n console.log(c.cyan(root) + c.dim(` (${count})`));\n\n const children = childrenMap.get(root) || [];\n children.sort();\n children.forEach((child, j) => {\n printTree(child, '', j === children.length - 1);\n });\n });\n } else {\n // Plain output\n for (const tag of tags) {\n console.log(`${tag.tag}\\t${tag.count}`);\n }\n }\n}\n\n// Output search results\nexport function outputSearchResults(\n query: string,\n notes: Note[],\n snippets: Array<{\n id: string;\n note_id: string;\n note_title: string;\n version: number;\n content_preview: string;\n favorite: boolean;\n }>,\n ctx: CLIContext\n): void {\n if (ctx.json) {\n outputJson({ query, notes, snippets });\n return;\n }\n\n const c = getColors(ctx);\n\n if (notes.length === 0 && snippets.length === 0) {\n console.log(c.dim(`No results for \"${query}\"`));\n return;\n }\n\n if (notes.length > 0) {\n console.log(c.bold(`Notes (${notes.length})`));\n console.log('');\n for (const note of notes) {\n console.log(\n ' ' + c.cyan(note.id.slice(0, 8)) + ' ' + note.title + ' ' + c.dim(note.tags.join(', '))\n );\n }\n console.log('');\n }\n\n if (snippets.length > 0) {\n console.log(c.bold(`Snippets (${snippets.length})`));\n console.log('');\n for (const snippet of snippets) {\n console.log(\n ' ' +\n c.cyan(snippet.note_id.slice(0, 8)) +\n ' ' +\n snippet.note_title +\n c.dim(` v${snippet.version}`)\n );\n console.log(' ' + c.dim(truncate(snippet.content_preview, 60)));\n }\n }\n}\n\n// Output shared tags list\nexport function outputSharedTags(data: ListSharedTagsResponse, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(data);\n return;\n }\n\n const c = getColors(ctx);\n const totalCount = data.owned.count + data.shared_with_me.count;\n\n if (totalCount === 0) {\n console.log(c.dim('No shared tags.'));\n return;\n }\n\n if (isHumanOutput(ctx)) {\n if (data.owned.count > 0) {\n console.log(c.bold(`Owned (${data.owned.count})`));\n console.log('');\n for (const tag of data.owned.tags) {\n console.log(\n ' ' + c.cyan(tag.id.slice(0, 8)) + ' ' +\n pad(tag.tag_path, 24) + ' ' +\n c.dim(formatRelativeTime(tag.created_at))\n );\n }\n console.log('');\n }\n\n if (data.shared_with_me.count > 0) {\n console.log(c.bold(`Shared with me (${data.shared_with_me.count})`));\n console.log('');\n for (const tag of data.shared_with_me.tags) {\n console.log(\n ' ' + c.cyan(tag.id.slice(0, 8)) + ' ' +\n pad(tag.tag_path, 24) + ' ' +\n c.dim('joined ' + formatRelativeTime(tag.joined_at))\n );\n }\n }\n } else {\n for (const tag of data.owned.tags) {\n console.log(['owned', tag.id, tag.tag_path, tag.created_at].join('\\t'));\n }\n for (const tag of data.shared_with_me.tags) {\n console.log(['shared', tag.id, tag.tag_path, tag.joined_at].join('\\t'));\n }\n }\n}\n\n// Output shared tag notes\nexport function outputSharedTagNotes(data: GetSharedTagNotesResponse, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(data);\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n const role = data.shared_tag.is_owner ? 'owner' : 'member';\n console.log(c.bold(data.shared_tag.tag_path) + c.dim(` (${role}, ${data.members_count} members)`));\n console.log('');\n\n if (data.notes.length === 0) {\n console.log(c.dim(' No notes in this shared tag.'));\n return;\n }\n\n console.log(\n ' ' + c.dim(pad('ID', 10)) +\n ' ' + c.dim(pad('TITLE', 24)) +\n ' ' + c.dim(pad('AUTHOR', 20)) +\n ' ' + c.dim('UPDATED')\n );\n\n for (const note of data.notes) {\n const author = note.is_own ? 'you' : (note.author.email || 'unknown');\n console.log(\n ' ' + pad(note.id.slice(0, 8), 10) +\n ' ' + pad(truncate(note.title, 24), 24) +\n ' ' + pad(truncate(author, 20), 20) +\n ' ' + formatRelativeTime(note.updated_at)\n );\n }\n } else {\n for (const note of data.notes) {\n const author = note.is_own ? 'you' : (note.author.email || 'unknown');\n console.log([note.id, note.title, author, note.updated_at].join('\\t'));\n }\n }\n}\n\n// Output shared notes (public links)\nexport function outputSharedNotes(data: ListSharedNotesResponse, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(data);\n return;\n }\n\n const c = getColors(ctx);\n\n if (data.count === 0) {\n console.log(c.dim('No shared notes.'));\n return;\n }\n\n if (isHumanOutput(ctx)) {\n console.log(c.bold(`Shared Notes (${data.count})`));\n console.log('');\n\n for (const share of data.shares) {\n const revoked = share.is_revoked ? c.red(' [R]') : '';\n console.log(\n ' ' + truncate(share.note_title, 20) +\n ' ' + c.cyan(share.share_url) +\n ' ' + c.dim(`${share.view_count} views`) +\n ' ' + c.dim(formatRelativeTime(share.created_at)) +\n revoked\n );\n }\n } else {\n for (const share of data.shares) {\n console.log(\n [share.note_title, share.share_url, share.view_count, share.is_revoked, share.created_at].join('\\t')\n );\n }\n }\n}\n\n// Output simple message\nexport function outputMessage(message: string, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson({ message });\n return;\n }\n\n const c = getColors(ctx);\n console.log(c.green('✓') + ' ' + message);\n}\n\n// Output to stderr (for status messages when piping)\nexport function logStatus(message: string): void {\n if (process.stderr.isTTY) {\n console.error(pc.dim(message));\n }\n}\n","import { listNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputNotes } from '../../lib/output.js';\nimport type { ListNotesResponse, CLIContext } from '../../types/index.js';\n\ninterface ListNotesOptions {\n tag?: string;\n archived?: boolean;\n pinned?: boolean;\n deleted?: boolean;\n protected?: boolean;\n search?: string;\n limit?: string;\n}\n\nexport async function listNotesAction(\n options: ListNotesOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await listNotes<ListNotesResponse>(\n {\n tag: options.tag,\n archived: options.archived ?? false,\n pinned: options.pinned,\n deleted: options.deleted ?? false,\n protected: options.protected,\n search: options.search,\n limit: options.limit ? parseInt(options.limit, 10) : 50,\n },\n { pin: ctx.pin }\n );\n\n outputNotes(result.notes, ctx);\n\n // Show warning for protected notes if any\n if (result.warning && !ctx.json) {\n console.error('');\n console.error(result.warning);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { getNote } from '../../lib/api.js';\nimport { handleError, NotFoundError } from '../../lib/errors.js';\nimport { outputNote } from '../../lib/output.js';\nimport type { GetNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface GetNoteOptions {\n latest?: boolean;\n}\n\nexport async function getNoteAction(id: string, options: GetNoteOptions, ctx: CLIContext): Promise<void> {\n try {\n const result = await getNote<GetNoteResponse>(id, { pin: ctx.pin });\n\n if (!result) {\n throw new NotFoundError('Note', id);\n }\n\n const snippets = options.latest\n ? (result.latest_snippet ? [result.latest_snippet] : [])\n : (result.snippets || []);\n\n outputNote(result, snippets, ctx);\n\n // Show protection status warning if applicable\n if (result.protection_status?.error && !ctx.json) {\n console.error('');\n console.error('Warning: ' + result.protection_status.error);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { createNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { CreateNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface CreateNoteOptions {\n tags?: string[];\n content?: string;\n}\n\nexport async function createNoteAction(\n title: string,\n options: CreateNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let content = options.content;\n\n // If stdin has content and no --content flag, read from stdin\n if (!content && !process.stdin.isTTY) {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n const stdinContent = Buffer.concat(chunks).toString('utf-8').trim();\n if (stdinContent) {\n content = stdinContent;\n }\n }\n\n const result = await createNote<CreateNoteResponse>(\n {\n title,\n tags: options.tags && options.tags.length > 0 ? options.tags : undefined,\n content,\n },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Created note: ${result.note.title} (${result.note.id})`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { updateNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { UpdateNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface ArchiveNoteOptions {\n undo?: boolean;\n}\n\nexport async function archiveNoteAction(\n id: string,\n options: ArchiveNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const archived = !options.undo;\n\n const result = await updateNote<UpdateNoteResponse>(\n id,\n { archived },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const action = archived ? 'Archived' : 'Unarchived';\n outputMessage(`${action} note: ${result.note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { getNote, updateNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { GetNoteResponse, UpdateNoteResponse, CLIContext } from '../../types/index.js';\n\nexport async function pinNoteAction(id: string, ctx: CLIContext): Promise<void> {\n try {\n // First get current pin status\n const note = await getNote<GetNoteResponse>(id, { pin: ctx.pin });\n const newPinned = !note.pinned;\n\n const result = await updateNote<UpdateNoteResponse>(\n id,\n { pinned: newPinned },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const action = newPinned ? 'Pinned' : 'Unpinned';\n outputMessage(`${action} note: ${result.note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import pc from 'picocolors';\nimport { createInterface } from 'node:readline';\nimport { getNote, deleteNote } from '../../lib/api.js';\nimport { handleError, CLIError, ExitCode } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { GetNoteResponse, DeleteNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface DeleteNoteOptions {\n force?: boolean;\n}\n\nasync function confirm(message: string): Promise<boolean> {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(message + ' [y/N] ', (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport async function deleteNoteAction(\n id: string,\n options: DeleteNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n // Get note details first\n const note = await getNote<GetNoteResponse>(id, { pin: ctx.pin });\n\n // Confirm deletion unless --force or --json\n if (!options.force && !ctx.json) {\n if (!process.stdin.isTTY) {\n throw new CLIError(\n 'Cannot confirm deletion in non-interactive mode',\n ExitCode.GENERAL_ERROR,\n 'Use --force for non-interactive deletion'\n );\n }\n\n console.log(`About to delete: ${pc.bold(note.title)}`);\n const confirmed = await confirm('Are you sure?');\n\n if (!confirmed) {\n console.log(pc.dim('Cancelled.'));\n return;\n }\n }\n\n const result = await deleteNote<DeleteNoteResponse>(id, { pin: ctx.pin });\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Deleted note: ${note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { updateNote } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { UpdateNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface UpdateNoteOptions {\n title?: string;\n tags?: string[];\n}\n\nexport async function updateNoteAction(\n id: string,\n options: UpdateNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n if (!options.title && !options.tags) {\n throw new CLIError(\n 'No changes provided',\n 1,\n 'Use --title or --tags to specify what to update'\n );\n }\n\n const data: { title?: string; tags?: string[] } = {};\n if (options.title) data.title = options.title;\n if (options.tags) data.tags = options.tags;\n\n const result = await updateNote<UpdateNoteResponse>(id, data, { pin: ctx.pin });\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Updated note: ${result.note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { Command } from 'commander';\nimport { getNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSnippets } from '../../lib/output.js';\nimport { showSnippetAction } from '../snippet/show.js';\nimport { copySnippetAction } from '../snippet/copy.js';\nimport { addSnippetAction } from '../snippet/add.js';\nimport { updateSnippetAction } from '../snippet/update.js';\nimport { favoriteSnippetAction } from '../snippet/favorite.js';\nimport type { GetNoteResponse, CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const notesSnippetCommand = new Command('snippet')\n .description('Read and manage snippets for a note')\n .argument('[note-id]', 'Note ID to show latest snippet for')\n .action(async (noteId: string | undefined, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n if (noteId) {\n await showSnippetAction(noteId, {}, ctx);\n } else {\n cmd.help();\n }\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote notes snippet abc123 Show latest snippet (pipe-friendly)\n $ pnote notes snippet list abc123 Show all versions\n $ pnote notes snippet copy abc123 Copy to clipboard\n $ cat file.txt | pnote notes snippet add abc123\n`\n );\n\n// list — show all snippet versions for a note\nnotesSnippetCommand\n .command('list')\n .description('List all snippet versions for a note')\n .argument('<note-id>', 'Note ID')\n .action(async (noteId: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n try {\n const result = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n outputSnippets(result.snippets || [], ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n });\n\n// copy — copy latest (or specific version) snippet to clipboard\nnotesSnippetCommand\n .command('copy')\n .description('Copy snippet content to clipboard')\n .argument('<note-id>', 'Note ID')\n .option('--version <n>', 'Specific version number')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await copySnippetAction(noteId, options, ctx);\n });\n\n// add — add a new snippet version from stdin\nnotesSnippetCommand\n .command('add')\n .description('Add a new snippet version (from stdin)')\n .argument('<note-id>', 'Note ID')\n .option('--title <title>', 'Snippet title')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await addSnippetAction(noteId, options, ctx);\n });\n\n// update — update an existing snippet from stdin\nnotesSnippetCommand\n .command('update')\n .description('Update an existing snippet (from stdin)')\n .argument('<snippet-id>', 'Snippet ID')\n .option('--title <title>', 'New snippet title')\n .action(async (snippetId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await updateSnippetAction(snippetId, options, ctx);\n });\n\n// favorite — toggle favorite on a snippet\nnotesSnippetCommand\n .command('favorite')\n .description('Toggle favorite status on a snippet')\n .argument('<snippet-id>', 'Snippet ID')\n .action(async (snippetId: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await favoriteSnippetAction(snippetId, ctx);\n });\n","import { getNote, listSnippets } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSnippet, outputSnippets } from '../../lib/output.js';\nimport type { GetNoteResponse, ListSnippetsResponse, CLIContext } from '../../types/index.js';\n\ninterface ShowSnippetOptions {\n all?: boolean;\n}\n\nexport async function showSnippetAction(\n noteId: string,\n options: ShowSnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n if (options.all) {\n // Show all versions\n const result = await listSnippets<ListSnippetsResponse>(\n { note_id: noteId, limit: 100 },\n { pin: ctx.pin }\n );\n\n outputSnippets(result.snippets, ctx);\n } else {\n // Show latest snippet only\n const result = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n\n if (result.latest_snippet) {\n outputSnippet(result.latest_snippet, ctx);\n } else {\n if (!ctx.json) {\n console.error('No snippet content found.');\n }\n process.exit(3);\n }\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import pc from 'picocolors';\nimport { getNote, listSnippets } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { copyToClipboard } from '../../lib/clipboard.js';\nimport { logStatus } from '../../lib/output.js';\nimport type { GetNoteResponse, ListSnippetsResponse, Snippet, CLIContext } from '../../types/index.js';\n\ninterface CopySnippetOptions {\n version?: string;\n}\n\nexport async function copySnippetAction(\n noteId: string,\n options: CopySnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let snippet: Snippet | null = null;\n\n if (options.version) {\n // Get specific version\n const versionNum = parseInt(options.version, 10);\n if (isNaN(versionNum)) {\n throw new CLIError('Invalid version number');\n }\n\n const result = await listSnippets<ListSnippetsResponse>(\n { note_id: noteId, limit: 100 },\n { pin: ctx.pin }\n );\n\n snippet = result.snippets.find((s) => s.version === versionNum) || null;\n\n if (!snippet) {\n throw new CLIError(`Version ${versionNum} not found`);\n }\n } else {\n // Get latest\n const result = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n snippet = result.latest_snippet;\n }\n\n if (!snippet) {\n throw new CLIError('No snippet content found');\n }\n\n try {\n await copyToClipboard(snippet.content);\n logStatus('Copied to clipboard');\n\n // If JSON mode, output the snippet data\n if (ctx.json) {\n console.log(JSON.stringify({ copied: true, content: snippet.content }));\n }\n } catch (clipboardError) {\n // Fallback: print to stdout\n if (!ctx.json) {\n console.error(pc.yellow('Clipboard not available, printing to stdout:'));\n console.error('');\n }\n console.log(snippet.content);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { default as clipboardy } from 'clipboardy';\nimport { CLIError } from './errors.js';\n\nexport async function copyToClipboard(text: string): Promise<void> {\n try {\n await clipboardy.write(text);\n } catch (error) {\n // Fallback: output to stdout with a warning\n if (error instanceof Error && error.message.includes('xsel')) {\n throw new CLIError(\n 'Clipboard not available. Install xsel or xclip on Linux.',\n 1,\n 'Content will be printed to stdout instead.'\n );\n }\n throw new CLIError('Failed to copy to clipboard');\n }\n}\n\nexport async function readFromClipboard(): Promise<string> {\n try {\n return await clipboardy.read();\n } catch {\n throw new CLIError('Failed to read from clipboard');\n }\n}\n","import { createSnippet } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { CreateSnippetResponse, CLIContext } from '../../types/index.js';\n\ninterface AddSnippetOptions {\n title?: string;\n}\n\nexport async function addSnippetAction(\n noteId: string,\n options: AddSnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let content: string;\n\n // Read content from stdin\n if (process.stdin.isTTY) {\n throw new CLIError(\n 'No content provided',\n 1,\n \"Pipe content to this command: echo 'content' | pnote snippet add <note-id>\"\n );\n }\n\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n content = Buffer.concat(chunks).toString('utf-8');\n\n // Trim trailing newline but preserve internal formatting\n if (content.endsWith('\\n')) {\n content = content.slice(0, -1);\n }\n\n if (!content) {\n throw new CLIError('Empty content provided');\n }\n\n const result = await createSnippet<CreateSnippetResponse>(\n {\n note_id: noteId,\n content,\n title: options.title,\n },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Created snippet v${result.snippet.version}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { updateSnippet } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { CLIContext } from '../../types/index.js';\n\ninterface UpdateSnippetOptions {\n title?: string;\n}\n\ninterface UpdateSnippetResponse {\n message: string;\n snippet: {\n id: string;\n version: number;\n content: string;\n title: string | null;\n favorite: boolean;\n };\n}\n\nexport async function updateSnippetAction(\n snippetId: string,\n options: UpdateSnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n // Read content from stdin\n let content: string | undefined;\n\n if (!process.stdin.isTTY) {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n content = Buffer.concat(chunks).toString('utf-8');\n\n // Trim trailing newline but preserve internal formatting\n if (content.endsWith('\\n')) {\n content = content.slice(0, -1);\n }\n\n if (!content) {\n content = undefined;\n }\n }\n\n // Must provide content or title\n if (!content && !options.title) {\n throw new CLIError(\n 'No content or title provided',\n 1,\n \"Pipe content to this command: echo 'content' | pnote snippet update <snippet-id>\"\n );\n }\n\n const data: { content?: string; title?: string } = {};\n if (content) data.content = content;\n if (options.title) data.title = options.title;\n\n const result = await updateSnippet<UpdateSnippetResponse>(\n snippetId,\n data,\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage('Updated snippet', ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { toggleFavorite } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { ToggleFavoriteResponse, CLIContext } from '../../types/index.js';\n\nexport async function favoriteSnippetAction(\n snippetId: string,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await toggleFavorite<ToggleFavoriteResponse>(snippetId, { pin: ctx.pin });\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const status = result.snippet.favorite ? 'favorited' : 'unfavorited';\n outputMessage(`Snippet ${status}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { createInterface } from 'node:readline';\nimport { existsSync, readFileSync, writeFileSync, unlinkSync, statSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport pc from 'picocolors';\n\n// PIN session cache settings\nconst PIN_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\nconst PIN_MAX_ATTEMPTS = 3;\n\nfunction getPinCachePath(): string {\n const uid = process.getuid?.() ?? 'unknown';\n return join(tmpdir(), `pnote-pin-${uid}`);\n}\n\n// Session cache management\n\nexport function getCachedPin(): string | null {\n const cachePath = getPinCachePath();\n\n if (!existsSync(cachePath)) {\n return null;\n }\n\n try {\n const stat = statSync(cachePath);\n const age = Date.now() - stat.mtimeMs;\n\n if (age > PIN_CACHE_TTL_MS) {\n // Cache expired, remove it\n unlinkSync(cachePath);\n return null;\n }\n\n const content = readFileSync(cachePath, 'utf-8').trim();\n return content || null;\n } catch {\n return null;\n }\n}\n\nexport function setCachedPin(pin: string): void {\n const cachePath = getPinCachePath();\n\n try {\n writeFileSync(cachePath, pin, { mode: 0o600 });\n } catch {\n // Silently fail - cache is optional\n }\n}\n\nexport function clearCachedPin(): boolean {\n const cachePath = getPinCachePath();\n\n if (existsSync(cachePath)) {\n try {\n unlinkSync(cachePath);\n return true;\n } catch {\n return false;\n }\n }\n return false;\n}\n\n// PIN input methods\n\n/**\n * Read PIN from stdin (for --pin-stdin option)\n * Only reads the first line\n */\nexport async function readPinFromStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n // Only read first line\n const content = Buffer.concat(chunks).toString('utf-8');\n if (content.includes('\\n')) {\n break;\n }\n }\n\n const content = Buffer.concat(chunks).toString('utf-8');\n const firstLine = content.split('\\n')[0]?.trim() || '';\n\n if (!firstLine) {\n throw new Error('No PIN provided via stdin');\n }\n\n return firstLine;\n}\n\n/**\n * Prompt user for PIN interactively\n * Hides input and supports retry\n */\nexport async function promptForPin(\n noteTitle?: string,\n hint?: string,\n maxAttempts: number = PIN_MAX_ATTEMPTS\n): Promise<string | null> {\n if (!process.stdin.isTTY) {\n return null;\n }\n\n // Show context\n if (noteTitle) {\n console.error(pc.yellow('🔒') + ` Note \"${noteTitle}\" is PIN-protected.`);\n } else {\n console.error(pc.yellow('🔒') + ' This action requires your PIN.');\n }\n\n if (hint) {\n console.error(pc.dim(`Hint: ${hint}`));\n }\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const pin = await readPinHidden(\n attempt > 1 ? `Enter PIN (${attempt}/${maxAttempts}): ` : 'Enter PIN: '\n );\n\n if (pin) {\n return pin;\n }\n\n if (attempt < maxAttempts) {\n console.error(pc.red('Invalid or empty PIN. Try again.'));\n }\n }\n\n console.error(pc.red('Too many attempts.'));\n return null;\n}\n\n/**\n * Read a line with hidden input (for PIN entry)\n */\nasync function readPinHidden(prompt: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stderr,\n terminal: true,\n });\n\n // Disable echo\n if (process.stdin.isTTY) {\n process.stdin.setRawMode?.(true);\n }\n\n process.stderr.write(prompt);\n\n let pin = '';\n\n const onKeypress = (key: Buffer) => {\n const char = key.toString();\n\n if (char === '\\r' || char === '\\n') {\n // Enter pressed\n process.stderr.write('\\n');\n cleanup();\n resolve(pin);\n } else if (char === '\\u0003') {\n // Ctrl+C\n process.stderr.write('\\n');\n cleanup();\n process.exit(130);\n } else if (char === '\\u007F' || char === '\\b') {\n // Backspace\n if (pin.length > 0) {\n pin = pin.slice(0, -1);\n // Move cursor back and clear\n process.stderr.write('\\b \\b');\n }\n } else if (char.length === 1 && char >= ' ') {\n // Regular character\n pin += char;\n process.stderr.write('*');\n }\n };\n\n const cleanup = () => {\n process.stdin.removeListener('data', onKeypress);\n if (process.stdin.isTTY) {\n process.stdin.setRawMode?.(false);\n }\n rl.close();\n };\n\n process.stdin.on('data', onKeypress);\n });\n}\n\n/**\n * Get PIN from all sources in priority order\n *\n * Priority:\n * 1. --pin argument (passed in ctx.pin)\n * 2. --pin-stdin (if pinFromStdin is true)\n * 3. PNOTE_PIN environment variable\n * 4. Session cache\n * 5. Interactive prompt (if TTY)\n * 6. null (not available)\n */\nexport async function resolvePin(options: {\n pinArg?: string;\n pinFromStdin?: boolean;\n noteTitle?: string;\n hint?: string;\n skipCache?: boolean;\n skipPrompt?: boolean;\n}): Promise<string | null> {\n const { pinArg, pinFromStdin, noteTitle, hint, skipCache, skipPrompt } = options;\n\n // 1. Command line argument (highest priority)\n if (pinArg) {\n return pinArg;\n }\n\n // 2. stdin\n if (pinFromStdin) {\n try {\n return await readPinFromStdin();\n } catch {\n return null;\n }\n }\n\n // 3. Environment variable\n const envPin = process.env.PNOTE_PIN;\n if (envPin) {\n return envPin;\n }\n\n // 4. Session cache\n if (!skipCache) {\n const cached = getCachedPin();\n if (cached) {\n return cached;\n }\n }\n\n // 5. Interactive prompt\n if (!skipPrompt && process.stdin.isTTY) {\n const pin = await promptForPin(noteTitle, hint);\n if (pin) {\n // Cache for future use\n setCachedPin(pin);\n return pin;\n }\n }\n\n // 6. Not available\n return null;\n}\n\n/**\n * Check if PIN is required but not available\n * Returns error message if PIN is needed but missing\n */\nexport function checkPinRequired(\n isProtected: boolean,\n pin: string | null | undefined\n): string | null {\n if (!isProtected) {\n return null;\n }\n\n if (pin) {\n return null;\n }\n\n if (!process.stdin.isTTY) {\n return 'PIN required but not provided. Use -p <pin> or set PNOTE_PIN environment variable.';\n }\n\n return null;\n}\n","import { Command } from 'commander';\nimport { showSnippetAction } from './show.js';\nimport { copySnippetAction } from './copy.js';\nimport { addSnippetAction } from './add.js';\nimport { updateSnippetAction } from './update.js';\nimport { favoriteSnippetAction } from './favorite.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nconst DEPRECATION_NOTICE = '\\nDeprecated: \"pnote snippet\" is deprecated. Use \"pnote notes snippet\" instead.\\n\\n';\n\nexport const snippetCommand = new Command('snippet')\n .description('Read and manage snippets (note versions) [deprecated: use \"notes snippet\"]')\n .argument('[note-id]', 'Note ID to show snippet for')\n .option('--all', 'Show all snippet versions')\n .hook('preAction', () => {\n process.stderr.write(DEPRECATION_NOTICE);\n })\n .action(async (noteId: string | undefined, options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n if (noteId) {\n await showSnippetAction(noteId, options, ctx);\n } else {\n cmd.help();\n }\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote snippet abc123 Show latest snippet\n $ pnote snippet abc123 --all Show all versions\n $ pnote snippet copy abc123 Copy to clipboard\n $ cat file.txt | pnote snippet add abc123\n`\n );\n\nsnippetCommand\n .command('copy')\n .description('Copy snippet content to clipboard')\n .argument('<note-id>', 'Note ID')\n .option('--version <n>', 'Specific version number')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await copySnippetAction(noteId, options, ctx);\n });\n\nsnippetCommand\n .command('add')\n .description('Add a new snippet version (from stdin)')\n .argument('<note-id>', 'Note ID')\n .option('--title <title>', 'Snippet title')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await addSnippetAction(noteId, options, ctx);\n });\n\nsnippetCommand\n .command('update')\n .description('Update an existing snippet (from stdin)')\n .argument('<snippet-id>', 'Snippet ID')\n .option('--title <title>', 'New snippet title')\n .action(async (snippetId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await updateSnippetAction(snippetId, options, ctx);\n });\n\nsnippetCommand\n .command('favorite')\n .description('Toggle favorite status on a snippet')\n .argument('<snippet-id>', 'Snippet ID')\n .action(async (snippetId: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await favoriteSnippetAction(snippetId, ctx);\n });\n","import { Command } from 'commander';\nimport { listTagsAction } from './list.js';\nimport { renameTagAction } from './rename.js';\nimport { mergeTagsAction } from './merge.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const tagsCommand = new Command('tags')\n .description('List and manage tags')\n .option('--include-archived', 'Include tags from archived notes')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listTagsAction(options, ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote tags List all tags\n $ pnote tags rename \"old\" \"new\" Rename a tag\n $ pnote tags merge \"tag1\" \"tag2\" --into \"target\"\n`\n );\n\ntagsCommand\n .command('rename')\n .description('Rename a tag across all notes')\n .argument('<old-tag>', 'Current tag name')\n .argument('<new-tag>', 'New tag name')\n .action(async (oldTag: string, newTag: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await renameTagAction(oldTag, newTag, ctx);\n });\n\ntagsCommand\n .command('merge')\n .description('Merge multiple tags into one')\n .argument('<source-tags...>', 'Tags to merge (space-separated)')\n .requiredOption('--into <target>', 'Target tag to merge into')\n .action(async (sourceTags: string[], options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await mergeTagsAction(sourceTags, options.into, ctx);\n });\n","import { listTags } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputTags } from '../../lib/output.js';\nimport type { ListTagsResponse, CLIContext } from '../../types/index.js';\n\ninterface ListTagsOptions {\n includeArchived?: boolean;\n}\n\nexport async function listTagsAction(\n options: ListTagsOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await listTags<ListTagsResponse>(\n { include_archived: options.includeArchived ?? false },\n { pin: ctx.pin }\n );\n\n outputTags(result.tags, result.hierarchy, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { renameTag } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { RenameTagResponse, CLIContext } from '../../types/index.js';\n\nexport async function renameTagAction(\n oldTag: string,\n newTag: string,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await renameTag<RenameTagResponse>(\n { old_tag: oldTag, new_tag: newTag },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(\n `Renamed \"${oldTag}\" to \"${newTag}\" (${result.notes_updated} notes updated)`,\n ctx\n );\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { mergeTags } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { MergeTagsResponse, CLIContext } from '../../types/index.js';\n\nexport async function mergeTagsAction(\n sourceTags: string[],\n targetTag: string,\n ctx: CLIContext\n): Promise<void> {\n try {\n // Validate that source doesn't include target\n if (sourceTags.includes(targetTag)) {\n throw new CLIError('Source tags cannot include the target tag');\n }\n\n if (sourceTags.length === 0) {\n throw new CLIError('At least one source tag is required');\n }\n\n const result = await mergeTags<MergeTagsResponse>(\n { source_tags: sourceTags, target_tag: targetTag },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const sourceList = sourceTags.map((t) => `\"${t}\"`).join(', ');\n outputMessage(\n `Merged ${sourceList} into \"${targetTag}\" (${result.notes_updated} notes updated)`,\n ctx\n );\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { Command } from 'commander';\nimport { search } from '../lib/api.js';\nimport { handleError } from '../lib/errors.js';\nimport { outputSearchResults } from '../lib/output.js';\nimport { resolvePin } from '../lib/pin.js';\nimport type { SearchResponse, CLIContext } from '../types/index.js';\n\ninterface SearchOptions {\n notesOnly?: boolean;\n snippetsOnly?: boolean;\n limit?: string;\n}\n\nasync function searchAction(\n query: string,\n options: SearchOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let search_notes = true;\n let search_snippets = true;\n\n if (options.notesOnly) {\n search_notes = true;\n search_snippets = false;\n } else if (options.snippetsOnly) {\n search_notes = false;\n search_snippets = true;\n }\n\n const result = await search<SearchResponse>(\n {\n query,\n search_notes,\n search_snippets,\n limit: options.limit ? parseInt(options.limit, 10) : 20,\n },\n { pin: ctx.pin }\n );\n\n outputSearchResults(query, result.notes, result.snippets, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n\nexport const searchCommand = new Command('search')\n .description('Search notes and snippets')\n .argument('<query>', 'Search query')\n .option('--notes-only', 'Only search note titles and tags')\n .option('--snippets-only', 'Only search snippet content')\n .option('--limit <n>', 'Limit results', '20')\n .action(async (query: string, options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n const ctx: CLIContext = {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n await searchAction(query, options, ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote search \"portrait\" Search all\n $ pnote search \"AI\" --notes-only Search note titles only\n $ pnote search \"code\" --limit 50 Limit results\n`\n );\n","import { Command } from 'commander';\nimport { listSharedTagsAction, getSharedTagNotesAction } from './tags.js';\nimport { listSharedNotesAction } from './notes.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const shareCommand = new Command('share')\n .description('View shared tags and shared note links')\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote share tags List shared tags\n $ pnote share tags abc123 View notes in shared tag\n $ pnote share notes List public share links\n $ pnote share notes --include-revoked\n`\n );\n\n// pnote share tags [id]\nshareCommand\n .command('tags')\n .description('List shared tags or view notes in a shared tag')\n .argument('[id]', 'Shared tag ID to view notes')\n .option('--limit <n>', 'Limit notes returned')\n .action(async (id: string | undefined, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n if (id) {\n await getSharedTagNotesAction(id, options, ctx);\n } else {\n await listSharedTagsAction(ctx);\n }\n });\n\n// pnote share notes\nshareCommand\n .command('notes')\n .description('List public share links for your notes')\n .option('--include-revoked', 'Include revoked share links')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listSharedNotesAction(options, ctx);\n });\n","import { listSharedTags, getSharedTagNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSharedTags, outputSharedTagNotes } from '../../lib/output.js';\nimport type {\n ListSharedTagsResponse,\n GetSharedTagNotesResponse,\n CLIContext,\n} from '../../types/index.js';\n\ninterface SharedTagNotesOptions {\n limit?: string;\n}\n\nexport async function listSharedTagsAction(ctx: CLIContext): Promise<void> {\n try {\n const result = await listSharedTags<ListSharedTagsResponse>({ pin: ctx.pin });\n outputSharedTags(result, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n\nexport async function getSharedTagNotesAction(\n id: string,\n options: SharedTagNotesOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await getSharedTagNotes<GetSharedTagNotesResponse>(\n id,\n { limit: options.limit ? parseInt(options.limit, 10) : undefined },\n { pin: ctx.pin }\n );\n outputSharedTagNotes(result, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { listSharedNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSharedNotes } from '../../lib/output.js';\nimport type { ListSharedNotesResponse, CLIContext } from '../../types/index.js';\n\ninterface SharedNotesOptions {\n includeRevoked?: boolean;\n}\n\nexport async function listSharedNotesAction(\n options: SharedNotesOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await listSharedNotes<ListSharedNotesResponse>(\n { include_revoked: options.includeRevoked },\n { pin: ctx.pin }\n );\n outputSharedNotes(result, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { Command } from 'commander';\nimport { listSkillsAction } from './list.js';\nimport { pullSkillsAction } from './pull.js';\nimport { pushSkillsAction } from './push.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const skillsCommand = new Command('skills')\n .description('Manage agent skills (sync between cloud and local)')\n .action(async (_options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listSkillsAction(ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote skills List all skills in cloud\n $ pnote skills pull Pull all skills globally (~/.agents/skills/ + symlinks)\n $ pnote skills pull myskill Pull a specific skill globally\n $ pnote skills pull --project Pull project-level (.agents/skills/ + .claude/skills/ etc.)\n $ pnote skills pull --dry-run Preview without writing files\n $ pnote skills push ./my-skill Upload a local skill directory\n\nSkills are stored as notes with type \"skill\" and title \"skill-name/filename.md\".\nPull writes to the canonical .agents/skills/ store and symlinks into each installed\nagent's directory (.claude/skills/, .windsurf/skills/, .augment/skills/, etc.),\nmatching the layout used by npx skills for seamless coexistence.\n`\n );\n\nskillsCommand\n .command('pull')\n .description('Download skills from cloud to local (global by default)')\n .argument('[skill-name]', 'Specific skill to pull (pulls all if omitted)')\n .option('--project', 'Install project-level (./agents/skills/ + .claude/skills/ etc.)')\n .option('--dir <path>', 'Custom output directory — direct write, no symlinks')\n .option('--dry-run', 'Show what would be downloaded without writing files')\n .action(async (skillName: string | undefined, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pullSkillsAction(skillName, options, ctx);\n });\n\nskillsCommand\n .command('push')\n .description('Upload a local skill directory to cloud')\n .argument('<dir>', 'Path to skill directory (must contain SKILL.md)')\n .option('--name <name>', 'Override skill name (default: directory name)')\n .action(async (dir: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pushSkillsAction(dir, options, ctx);\n });\n","import { listNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson, logStatus } from '../../lib/output.js';\nimport type { ListNotesResponse, CLIContext } from '../../types/index.js';\nimport pc from 'picocolors';\n\n/**\n * List all skill notes from cloud, grouped by skill name.\n */\nexport async function listSkillsAction(ctx: CLIContext): Promise<void> {\n try {\n const result = await listNotes<ListNotesResponse>(\n { note_type: 'skill', limit: 200 },\n { pin: ctx.pin }\n );\n\n const skills = result.notes;\n\n if (ctx.json) {\n // Group by skill name for JSON output\n const grouped: Record<string, typeof skills> = {};\n for (const note of skills) {\n const slashIdx = note.title.indexOf('/');\n const skillName = slashIdx > 0 ? note.title.slice(0, slashIdx) : note.title;\n if (!grouped[skillName]) grouped[skillName] = [];\n grouped[skillName].push(note);\n }\n outputJson(grouped);\n return;\n }\n\n if (skills.length === 0) {\n console.log(pc.dim('No skills found. Create one with:'));\n console.log(pc.dim(' pnote skills push ./my-skill'));\n return;\n }\n\n // Group skills by name prefix (before first /)\n const grouped = new Map<string, typeof skills>();\n for (const note of skills) {\n const slashIdx = note.title.indexOf('/');\n const skillName = slashIdx > 0 ? note.title.slice(0, slashIdx) : note.title;\n if (!grouped.has(skillName)) grouped.set(skillName, []);\n grouped.get(skillName)!.push(note);\n }\n\n console.log(pc.bold(`Skills (${grouped.size})`));\n console.log('');\n\n for (const [name, files] of grouped) {\n const fileNames = files.map(f => {\n const slashIdx = f.title.indexOf('/');\n return slashIdx > 0 ? f.title.slice(slashIdx + 1) : f.title;\n });\n console.log(\n ' ' + pc.cyan(name) +\n pc.dim(` (${files.length} file${files.length !== 1 ? 's' : ''})`) +\n ' ' + pc.dim(fileNames.join(', '))\n );\n }\n\n console.log('');\n console.log(pc.dim('Pull to local: pnote skills pull'));\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as os from 'node:os';\nimport { listNotes, getNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport type { ListNotesResponse, GetNoteResponse, CLIContext } from '../../types/index.js';\nimport pc from 'picocolors';\n\nexport interface PullOptions {\n dir?: string;\n project?: boolean;\n dryRun?: boolean;\n}\n\ntype InstallMode = 'custom' | 'global' | 'project';\n\ntype Colors = {\n green: (s: string) => string;\n dim: (s: string) => string;\n yellow: (s: string) => string;\n bold: (s: string) => string;\n red: (s: string) => string;\n};\n\n// Canonical store: <root>/.agents/skills/<name>/ (mirrors npx skills layout)\nconst AGENTS_STORE = '.agents/skills';\n\n// Agent dirs that receive symlinks → canonical store.\n// .claude is first and always created (most widely used).\n// Others are created only if the agent is installed (~/.<dir>/ exists).\nconst AGENT_SYMLINK_DIRS = [\n '.claude/skills',\n '.windsurf/skills',\n '.augment/skills',\n '.agent/skills',\n] as const;\n\nfunction makeColors(useColor: boolean): Colors {\n if (useColor) {\n return {\n green: pc.green,\n dim: pc.dim,\n yellow: pc.yellow,\n bold: pc.bold,\n red: pc.red,\n };\n }\n return {\n green: (s: string) => s,\n dim: (s: string) => s,\n yellow: (s: string) => s,\n bold: (s: string) => s,\n red: (s: string) => s,\n };\n}\n\nfunction resolveMode(options: PullOptions): { mode: InstallMode; root: string } {\n if (options.dir) return { mode: 'custom', root: path.resolve(options.dir) };\n if (options.project) return { mode: 'project', root: process.cwd() };\n return { mode: 'global', root: os.homedir() };\n}\n\n/**\n * Create a symlink at linkPath pointing to ../../.agents/skills/<skillName> (relative).\n * Handles all existing-path cases: correct symlink (skip), wrong symlink, real dir, real file.\n * Real directories from old `pnote skills pull` are migrated automatically.\n */\nfunction ensureSymlink(\n linkPath: string,\n skillName: string,\n dryRun: boolean,\n c: Colors,\n log: (msg: string) => void\n): void {\n // Relative target: from <root>/.<agent>/skills/<name> → <root>/.agents/skills/<name>\n const relTarget = path.join('..', '..', AGENTS_STORE, skillName);\n\n if (dryRun) {\n log(` ${c.dim('would link')} ${linkPath} → ${relTarget}`);\n return;\n }\n\n // Ensure parent directory exists\n fs.mkdirSync(path.dirname(linkPath), { recursive: true });\n\n // Inspect existing path without following symlinks (lstat handles broken symlinks)\n let existingStat: fs.Stats | null = null;\n try {\n existingStat = fs.lstatSync(linkPath);\n } catch {\n // Path does not exist at all — proceed to create symlink\n }\n\n if (existingStat) {\n if (existingStat.isSymbolicLink()) {\n // Already a symlink — skip if correct, replace if wrong\n if (fs.readlinkSync(linkPath) === relTarget) return;\n fs.unlinkSync(linkPath);\n } else if (existingStat.isDirectory()) {\n // Real directory from old pnote skills pull — migrate to symlink.\n // Content is safe to remove: we're replacing with cloud-fetched content.\n fs.rmSync(linkPath, { recursive: true });\n log(` ${c.yellow('↗')} migrated ${c.dim(linkPath)} (replaced directory with symlink)`);\n } else {\n // Regular file — remove and replace\n fs.unlinkSync(linkPath);\n }\n }\n\n fs.symlinkSync(relTarget, linkPath);\n log(` ${c.dim('⇢')} ${linkPath}`);\n}\n\n/**\n * Write skill files to canonical agents store and create agent symlinks.\n * Custom --dir mode writes directly to <root>/<name>/ with no symlinks.\n */\nfunction installSkill(\n root: string,\n mode: InstallMode,\n skillName: string,\n files: Array<{ fileName: string; content: string }>,\n dryRun: boolean,\n c: Colors,\n log: (msg: string) => void\n): string[] {\n const home = os.homedir();\n\n if (mode === 'custom') {\n // Direct write to <root>/<skillName>/ — no symlinks (backward compat for --dir)\n for (const { fileName, content } of files) {\n const destPath = path.join(root, skillName, fileName);\n if (dryRun) {\n log(` ${c.dim('would write')} ${destPath}`);\n } else {\n fs.mkdirSync(path.dirname(destPath), { recursive: true });\n fs.writeFileSync(destPath, content, 'utf-8');\n log(` ${c.green('✓')} ${destPath}`);\n }\n }\n return [];\n }\n\n // Write actual files to canonical agents store: <root>/.agents/skills/<name>/\n for (const { fileName, content } of files) {\n const destPath = path.join(root, AGENTS_STORE, skillName, fileName);\n if (dryRun) {\n log(` ${c.dim('would write')} ${destPath}`);\n } else {\n fs.mkdirSync(path.dirname(destPath), { recursive: true });\n fs.writeFileSync(destPath, content, 'utf-8');\n log(` ${c.green('✓')} ${destPath}`);\n }\n }\n\n // Create symlinks in each agent dir\n const linkedAgents: string[] = [];\n for (const agentSkillsDir of AGENT_SYMLINK_DIRS) {\n const agentRootDir = agentSkillsDir.split('/')[0]; // e.g. '.claude'\n const isClaude = agentRootDir === '.claude';\n\n // .claude always gets a symlink.\n // Other agents: only if the agent is installed (its home dir exists).\n if (!isClaude && !fs.existsSync(path.join(home, agentRootDir))) continue;\n\n const linkPath = path.join(root, agentSkillsDir, skillName);\n ensureSymlink(linkPath, skillName, dryRun, c, log);\n linkedAgents.push(agentRootDir);\n }\n\n return linkedAgents;\n}\n\n/**\n * Pull skills from cloud → local filesystem.\n *\n * Modes:\n * default (global) → writes to ~/.agents/skills/<name>/ + symlinks in ~/.claude/skills/ etc.\n * --project → writes to .agents/skills/<name>/ + symlinks in .claude/skills/ etc. (cwd)\n * --dir <path> → writes directly to <path>/<name>/ (no symlinks, backward compat)\n *\n * The layout mirrors npx skills exactly, so the two tools coexist without conflict.\n * Skills pulled here appear alongside registry skills in ~/.agents/skills/ and are\n * accessible from Claude Code, Windsurf, Augment, and any other installed agents.\n */\nexport async function pullSkillsAction(\n skillName: string | undefined,\n options: PullOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const { mode, root } = resolveMode(options);\n const useColor = !ctx.noColor && process.stdout.isTTY;\n const c = makeColors(useColor);\n const log = ctx.json ? (_msg: string) => {} : (msg: string) => console.log(msg);\n\n // Fetch all skill notes from cloud\n const result = await listNotes<ListNotesResponse>(\n { note_type: 'skill', limit: 200 },\n { pin: ctx.pin }\n );\n\n let skills = result.notes;\n\n // Filter by skill name if specified\n if (skillName) {\n skills = skills.filter(n => n.title.split('/')[0] === skillName);\n if (skills.length === 0) {\n console.error(pc.red(`No skill found with name \"${skillName}\"`));\n process.exit(1);\n }\n }\n\n if (skills.length === 0) {\n if (!ctx.json) console.log(c.dim('No skills to pull.'));\n if (ctx.json) outputJson({ pulled: 0, skipped: 0, mode, root, skills: {} });\n return;\n }\n\n // Group notes by skill name (prefix before first /)\n const grouped = new Map<string, Array<{ fileName: string; noteId: string }>>();\n for (const note of skills) {\n const slashIdx = note.title.indexOf('/');\n if (slashIdx <= 0) {\n if (!ctx.json) console.error(`Skipping \"${note.title}\" (invalid title format, expected \"name/file\")`);\n continue;\n }\n const sName = note.title.slice(0, slashIdx);\n const fileName = note.title.slice(slashIdx + 1);\n if (!grouped.has(sName)) grouped.set(sName, []);\n grouped.get(sName)!.push({ fileName, noteId: note.id });\n }\n\n let totalPulled = 0;\n let totalSkipped = 0;\n const jsonResults: Record<string, { files: string[]; agents: string[] }> = {};\n\n for (const [sName, fileEntries] of grouped) {\n log(`\\n${c.bold(sName)}`);\n\n // Fetch content for each file\n const files: Array<{ fileName: string; content: string }> = [];\n for (const { fileName, noteId } of fileEntries) {\n const noteData = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n const content = noteData.latest_snippet?.content;\n if (!content) {\n if (!ctx.json) console.error(` Skipping \"${sName}/${fileName}\" (no snippet content)`);\n totalSkipped++;\n continue;\n }\n files.push({ fileName, content });\n }\n\n if (files.length === 0) continue;\n\n const linkedAgents = installSkill(root, mode, sName, files, options.dryRun ?? false, c, log);\n totalPulled += files.length;\n\n jsonResults[sName] = {\n files: files.map(f => f.fileName),\n agents: linkedAgents,\n };\n }\n\n if (!ctx.json) {\n console.log('');\n if (options.dryRun) {\n console.log(c.dim(`Dry run: ${totalPulled} file(s) would be pulled, ${totalSkipped} skipped`));\n } else {\n const scopeLabel =\n mode === 'custom' ? root :\n mode === 'project' ? 'project (.agents/skills/)' :\n 'global (~/.agents/skills/)';\n console.log(\n `Pulled ${totalPulled} file(s) — ${scopeLabel}` +\n (totalSkipped > 0 ? `, ${totalSkipped} skipped` : '')\n );\n }\n }\n\n if (ctx.json) {\n outputJson({ pulled: totalPulled, skipped: totalSkipped, mode, root, skills: jsonResults });\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { listNotes, createNote, createSnippet, getNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport type { ListNotesResponse, CreateNoteResponse, CreateSnippetResponse, GetNoteResponse, CLIContext } from '../../types/index.js';\nimport pc from 'picocolors';\n\ninterface PushOptions {\n name?: string;\n}\n\n/**\n * Push a local skill directory → cloud.\n * Each file becomes a note with title \"skill-name/filename\" and note_type='skill'.\n * Content is stored as the latest snippet.\n */\nexport async function pushSkillsAction(\n dir: string,\n options: PushOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const resolvedDir = path.resolve(dir);\n\n // Validate directory exists\n if (!fs.existsSync(resolvedDir) || !fs.statSync(resolvedDir).isDirectory()) {\n console.error(pc.red(`Not a directory: ${resolvedDir}`));\n process.exit(1);\n }\n\n // Check for SKILL.md\n const skillMdPath = path.join(resolvedDir, 'SKILL.md');\n if (!fs.existsSync(skillMdPath)) {\n console.error(pc.red(`No SKILL.md found in ${resolvedDir}`));\n console.error(pc.dim('A valid skill directory must contain a SKILL.md file.'));\n process.exit(1);\n }\n\n // Determine skill name\n const skillName = options.name || path.basename(resolvedDir);\n\n // Collect all files (non-recursive for now, matching typical skill structure)\n const files = collectFiles(resolvedDir, resolvedDir);\n\n if (files.length === 0) {\n console.log(pc.dim('No files to push.'));\n return;\n }\n\n // Fetch existing skill notes to check for updates\n const existing = await listNotes<ListNotesResponse>(\n { note_type: 'skill', limit: 200 },\n { pin: ctx.pin }\n );\n\n const existingMap = new Map<string, string>(); // title → note_id\n for (const note of existing.notes) {\n existingMap.set(note.title, note.id);\n }\n\n let created = 0;\n let updated = 0;\n\n for (const relPath of files) {\n const noteTitle = `${skillName}/${relPath}`;\n const filePath = path.join(resolvedDir, relPath);\n const content = fs.readFileSync(filePath, 'utf-8');\n\n const existingId = existingMap.get(noteTitle);\n\n if (existingId) {\n // Update existing: add new snippet version\n await createSnippet<CreateSnippetResponse>(\n { note_id: existingId, content },\n { pin: ctx.pin }\n );\n console.log(`${pc.yellow('↻')} ${noteTitle} ${pc.dim('(new version)')}`);\n updated++;\n } else {\n // Create new note with content\n await createNote<CreateNoteResponse>(\n { title: noteTitle, content, note_type: 'skill' },\n { pin: ctx.pin }\n );\n console.log(`${pc.green('+')} ${noteTitle}`);\n created++;\n }\n }\n\n console.log('');\n console.log(\n `Pushed ${pc.bold(skillName)}: ` +\n (created > 0 ? `${created} created` : '') +\n (created > 0 && updated > 0 ? ', ' : '') +\n (updated > 0 ? `${updated} updated` : '')\n );\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n\n/**\n * Collect files recursively from a directory, returning relative paths.\n * Skips hidden files/dirs and common non-skill files.\n */\nfunction collectFiles(baseDir: string, currentDir: string): string[] {\n const files: string[] = [];\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n // Skip hidden files and common non-skill entries\n if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;\n\n const fullPath = path.join(currentDir, entry.name);\n const relPath = path.relative(baseDir, fullPath);\n\n if (entry.isFile()) {\n files.push(relPath);\n } else if (entry.isDirectory()) {\n files.push(...collectFiles(baseDir, fullPath));\n }\n }\n\n return files;\n}\n","import { Command } from 'commander';\nimport { pinStatusAction } from './statusAction.js';\nimport { pinListAction } from './listAction.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const pinCommand = new Command('pin')\n .description('Manage PIN protection for notes')\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote pin status Check PIN configuration and access\n $ pnote pin list List all protected notes (metadata only)\n $ PNOTE_PIN=1234 pnote pin status Check with PIN provided via env\n`\n );\n\npinCommand\n .command('status')\n .description('Check PIN configuration status and access to protected notes')\n .action(async (_options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pinStatusAction(ctx);\n });\n\npinCommand\n .command('list')\n .description('List all PIN-protected notes (metadata only, no content)')\n .option('--limit <n>', 'Maximum number of results', '50')\n .option('--offset <n>', 'Skip N results (for pagination)')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pinListAction(options, ctx);\n });\n","import pc from 'picocolors';\nimport { checkPinStatus } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport { getCachedPin } from '../../lib/pin.js';\nimport type { PinStatusResponse, CLIContext } from '../../types/index.js';\n\nexport async function pinStatusAction(ctx: CLIContext): Promise<void> {\n try {\n const result = await checkPinStatus<PinStatusResponse>({ pin: ctx.pin });\n\n if (ctx.json) {\n outputJson({\n ...result,\n pnote_pin_env_set: !!process.env.PNOTE_PIN,\n pin_cached: !!getCachedPin(),\n });\n return;\n }\n\n const useColor = !ctx.noColor && process.stdout.isTTY;\n const c = {\n green: useColor ? pc.green : (s: string) => s,\n red: useColor ? pc.red : (s: string) => s,\n yellow: useColor ? pc.yellow : (s: string) => s,\n dim: useColor ? pc.dim : (s: string) => s,\n bold: useColor ? pc.bold : (s: string) => s,\n magenta: useColor ? pc.magenta : (s: string) => s,\n };\n\n const yes = c.green('✓');\n const no = c.red('✗');\n\n console.log(c.bold('PIN Status'));\n console.log('');\n\n // Account PIN setup\n const hasPin = result.user_has_pin_setup;\n console.log(` Account PIN set: ${hasPin ? yes : no}`);\n if (result.pin_hint) {\n console.log(` PIN hint: ${c.dim(result.pin_hint)}`);\n }\n console.log(` Protected notes: ${c.magenta(String(result.protected_notes_count))}`);\n\n console.log('');\n console.log(c.bold('PIN Sources (CLI)'));\n console.log('');\n\n // PNOTE_PIN env var\n const envSet = !!process.env.PNOTE_PIN;\n console.log(` PNOTE_PIN env: ${envSet ? yes : no}${envSet ? c.dim(' (recommended)') : ''}`);\n\n // Session cache\n const cached = !!getCachedPin();\n console.log(` Session cache: ${cached ? yes + c.dim(' (active, <5min)') : no}`);\n\n // Provided PIN validity\n if (result.pin_provided) {\n const valid = result.pin_valid;\n console.log(` Provided PIN valid: ${valid ? yes : no}`);\n } else {\n console.log(` Provided PIN: ${c.dim('not provided')}`);\n }\n\n console.log('');\n const canAccess = result.can_access_protected;\n if (canAccess) {\n console.log(yes + ' ' + c.green('Can access protected notes'));\n } else if (!hasPin) {\n console.log(c.dim(' No protected notes — PIN not configured on account'));\n } else {\n console.log(no + ' ' + c.red('Cannot access protected notes'));\n console.log('');\n console.log(c.dim(' Set PIN via: export PNOTE_PIN=<pin>'));\n console.log(c.dim(' Or use: pnote notes get <id> -p <pin>'));\n console.log(c.dim(' Or use: echo <pin> | pnote notes get <id> --pin-stdin'));\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import pc from 'picocolors';\nimport { listProtectedNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport type { ListProtectedNotesResponse, CLIContext } from '../../types/index.js';\n\ninterface ListPinOptions {\n limit?: string;\n offset?: string;\n}\n\nexport async function pinListAction(options: ListPinOptions, ctx: CLIContext): Promise<void> {\n try {\n const result = await listProtectedNotes<ListProtectedNotesResponse>(\n {\n limit: options.limit ? parseInt(options.limit, 10) : 50,\n offset: options.offset ? parseInt(options.offset, 10) : undefined,\n },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n return;\n }\n\n const useColor = !ctx.noColor && process.stdout.isTTY;\n const c = {\n dim: useColor ? pc.dim : (s: string) => s,\n bold: useColor ? pc.bold : (s: string) => s,\n cyan: useColor ? pc.cyan : (s: string) => s,\n yellow: useColor ? pc.yellow : (s: string) => s,\n magenta: useColor ? pc.magenta : (s: string) => s,\n };\n\n const isHuman = !ctx.json && !ctx.plain && process.stdout.isTTY;\n\n if (result.notes.length === 0) {\n console.log(c.dim('No protected notes.'));\n return;\n }\n\n if (isHuman) {\n console.log(c.bold(`Protected Notes (${result.count})`));\n if (result.hint) {\n console.log(c.dim(`PIN hint: ${result.hint}`));\n }\n if (!result.can_decrypt) {\n console.log(c.dim('Note: Content not shown — set PNOTE_PIN to access content.'));\n }\n console.log('');\n\n const pad = (s: string, w: number) => s.length >= w ? s.slice(0, w) : s + ' '.repeat(w - s.length);\n const truncate = (s: string, w: number) => s.length <= w ? s : s.slice(0, w - 1) + '…';\n\n console.log(\n ' ' + c.dim(pad('ID', 10)) +\n ' ' + c.dim(pad('TITLE', 30)) +\n ' ' + c.dim(pad('TAGS', 20)) +\n ' ' + c.dim('PROTECTED')\n );\n\n for (const note of result.notes) {\n const date = new Date(note.protected_at);\n const updated = date.toLocaleDateString();\n const pinned = note.pinned ? c.yellow('* ') : ' ';\n console.log(\n pinned +\n pad(note.id.slice(0, 8), 10) +\n ' ' + pad(truncate(note.title, 30), 30) +\n ' ' + pad(truncate(note.tags.join(', ') || '-', 20), 20) +\n ' ' + c.magenta(updated)\n );\n }\n } else {\n // Plain output\n for (const note of result.notes) {\n console.log([note.id, note.title, note.tags.join(','), note.protected_at].join('\\t'));\n }\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport pc from 'picocolors';\nimport { getConfigDir } from './config.js';\n\nconst CACHE_FILE = 'update-check.json';\nconst CHECK_INTERVAL = 60 * 60 * 1000; // 1 hour\nconst FETCH_TIMEOUT = 2000; // 2 seconds\n\ninterface UpdateCache {\n lastCheck: number;\n latestVersion: string;\n}\n\nfunction getCachePath(): string {\n return join(getConfigDir(), CACHE_FILE);\n}\n\nfunction readCache(): UpdateCache | null {\n try {\n const path = getCachePath();\n if (!existsSync(path)) return null;\n return JSON.parse(readFileSync(path, 'utf-8')) as UpdateCache;\n } catch {\n return null;\n }\n}\n\nfunction writeCache(cache: UpdateCache): void {\n try {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n writeFileSync(getCachePath(), JSON.stringify(cache), 'utf-8');\n } catch {\n // Silent — cache write failure is non-critical\n }\n}\n\nasync function fetchLatestVersion(packageName: string): Promise<string | null> {\n try {\n const res = await fetch(\n `https://registry.npmjs.org/${packageName}/latest`,\n { signal: AbortSignal.timeout(FETCH_TIMEOUT) }\n );\n if (!res.ok) return null;\n const data = (await res.json()) as { version?: string };\n return data.version ?? null;\n } catch {\n return null;\n }\n}\n\n/** Compare two semver strings (a.b.c). Returns true if current < latest. */\nfunction isOlderVersion(current: string, latest: string): boolean {\n const parse = (v: string) => v.split('.').map(Number);\n const [cMaj, cMin, cPat] = parse(current);\n const [lMaj, lMin, lPat] = parse(latest);\n if (cMaj !== lMaj) return cMaj < lMaj;\n if (cMin !== lMin) return cMin < lMin;\n return cPat < lPat;\n}\n\nfunction printNotice(current: string, latest: string, packageName: string): void {\n const useColor = process.stderr.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb';\n const yellow = useColor ? pc.yellow : (s: string) => s;\n const bold = useColor ? pc.bold : (s: string) => s;\n const dim = useColor ? pc.dim : (s: string) => s;\n\n const msg = `Update available: ${dim(current)} → ${bold(latest)}`;\n const cmd = `Run ${bold(`npm i -g ${packageName}`)} to update`;\n const lines = [msg, cmd];\n\n // Measure widest line (strip ANSI for length)\n const strip = (s: string) => s.replace(/\\x1b\\[[0-9;]*m/g, '');\n const maxLen = Math.max(...lines.map((l) => strip(l).length));\n const pad = (s: string) => s + ' '.repeat(maxLen - strip(s).length);\n\n const top = yellow('┌' + '─'.repeat(maxLen + 2) + '┐');\n const bot = yellow('└' + '─'.repeat(maxLen + 2) + '┘');\n const row = (s: string) => yellow('│') + ' ' + pad(s) + ' ' + yellow('│');\n\n const box = [\n '',\n top,\n row(lines[0]),\n row(lines[1]),\n bot,\n '',\n ].join('\\n');\n\n process.stderr.write(box);\n}\n\nexport async function checkAndNotifyUpdate(\n currentVersion: string,\n packageName: string,\n): Promise<void> {\n // Guards: skip when not appropriate\n if (!process.stderr.isTTY) return;\n if (process.env.NO_UPDATE_NOTIFIER) return;\n if (process.env.CI) return;\n if (process.env.NODE_ENV === 'test') return;\n\n try {\n const cache = readCache();\n let latestVersion: string | null = null;\n\n if (cache && Date.now() - cache.lastCheck < CHECK_INTERVAL) {\n // Cache is fresh — use it\n latestVersion = cache.latestVersion;\n } else {\n // Cache is stale or missing — fetch from registry\n latestVersion = await fetchLatestVersion(packageName);\n if (latestVersion) {\n writeCache({ lastCheck: Date.now(), latestVersion });\n } else if (cache) {\n // Fetch failed but we have stale cache — use it\n latestVersion = cache.latestVersion;\n }\n }\n\n if (latestVersion && isOlderVersion(currentVersion, latestVersion)) {\n printNotice(currentVersion, latestVersion, packageName);\n }\n } catch {\n // Silent — update check must never break the CLI\n }\n}\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,OAAO,QAAQ;AAGR,IAAM,WAAW;AAAA,EACtB,SAAS;AAAA,EACT,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,eAAe;AACjB;AAIO,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC,YACE,SACO,WAAyB,SAAS,eAClC,MACP;AACA,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,YAAN,cAAwB,SAAS;AAAA,EACtC,YAAY,SAAiB,MAAe;AAC1C,UAAM,SAAS,SAAS,YAAY,IAAI;AACxC,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,gBAAN,cAA4B,SAAS;AAAA,EAC1C,YAAY,UAAkB,IAAY;AACxC,UAAM,GAAG,QAAQ,mBAAmB,EAAE,KAAK,SAAS,SAAS;AAC7D,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,eAAN,cAA2B,SAAS;AAAA,EACzC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E,MAAM,CAAC,UAAU;AAChD,QAAM,UAAU,QAAQ,KAAK,EAAE,WAAW,QAAQ,IAAI,aAAa;AACnE,cAAY,OAAO,OAAO;AAC5B,CAAC;","names":["Command","pc","path","pc","pc","path","pc","pc","pc","pc","pc","Command","pc","c","printTree","pc","resolve","pc","Command","pc","pc","createInterface","existsSync","readFileSync","writeFileSync","unlinkSync","join","pc","content","pc","resolve","createInterface","Command","buildContext","Command","Command","buildContext","Command","Command","buildContext","Command","Command","Command","Command","buildContext","Command","Command","pc","grouped","pc","fs","path","pc","buildContext","Command","Command","pc","pc","pc","pc","pad","truncate","buildContext","Command","existsSync","readFileSync","writeFileSync","mkdirSync","join","pc","join","path","existsSync","readFileSync","mkdirSync","writeFileSync","pc","pad","Command"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/lib/errors.ts","../src/commands/auth/index.ts","../src/commands/auth/login.ts","../src/lib/config.ts","../src/commands/auth/token.ts","../src/lib/api.ts","../src/commands/auth/logout.ts","../src/commands/auth/whoami.ts","../src/commands/notes/index.ts","../src/lib/output.ts","../src/commands/notes/list.ts","../src/commands/notes/get.ts","../src/commands/notes/create.ts","../src/commands/notes/archive.ts","../src/commands/notes/pin.ts","../src/commands/notes/delete.ts","../src/commands/notes/update.ts","../src/commands/notes/snippetCmd.ts","../src/commands/snippet/show.ts","../src/commands/snippet/copy.ts","../src/lib/clipboard.ts","../src/commands/snippet/add.ts","../src/commands/snippet/update.ts","../src/commands/snippet/favorite.ts","../src/lib/pin.ts","../src/commands/snippet/index.ts","../src/commands/tags/index.ts","../src/commands/tags/list.ts","../src/commands/tags/rename.ts","../src/commands/tags/merge.ts","../src/commands/search.ts","../src/commands/share/index.ts","../src/commands/share/tags.ts","../src/commands/share/notes.ts","../src/commands/skills/index.ts","../src/commands/skills/list.ts","../src/commands/skills/pull.ts","../src/commands/skills/push.ts","../src/commands/pin/index.ts","../src/commands/pin/statusAction.ts","../src/commands/pin/listAction.ts","../src/lib/update-check.ts","../src/commands/update.ts","../src/commands/schema.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { handleError } from './lib/errors.js';\nimport { authCommand } from './commands/auth/index.js';\nimport { notesCommand } from './commands/notes/index.js';\nimport { snippetCommand } from './commands/snippet/index.js';\nimport { tagsCommand } from './commands/tags/index.js';\nimport { searchCommand } from './commands/search.js';\nimport { shareCommand } from './commands/share/index.js';\nimport { skillsCommand } from './commands/skills/index.js';\nimport { pinCommand } from './commands/pin/index.js';\nimport { checkAndNotifyUpdate, getVersionHelpLine } from './lib/update-check.js';\nimport { updateCommand } from './commands/update.js';\nimport { schemaCommand } from './commands/schema.js';\n\ndeclare const CLI_VERSION: string;\ndeclare const CLI_PACKAGE_NAME: string;\n\nconst program = new Command();\n\nprogram\n .name('pnote')\n .description('pnote - The PromptNote CLI')\n .version(CLI_VERSION, '-V, --version', 'Show version number')\n .option('--json', 'Output as JSON (for scripting)')\n .option('--no-color', 'Disable colored output')\n .option('--plain', 'Force plain text output (no formatting)')\n .option('-p, --pin <pin>', 'PIN for accessing protected notes')\n .option('--pin-stdin', 'Read PIN from stdin (first line only)')\n .configureHelp({\n sortSubcommands: true,\n sortOptions: true,\n })\n .addHelpText('before', () => getVersionHelpLine(CLI_VERSION, program.name()))\n .addHelpText(\n 'after',\n `\nPIN Protection:\n Protected notes require a PIN to access their content.\n You can provide the PIN in several ways:\n -p, --pin <pin> Pass PIN directly (visible in history)\n --pin-stdin Read PIN from stdin\n PNOTE_PIN Set as environment variable (recommended)\n\nExamples:\n $ pnote notes List all notes\n $ pnote notes --tag \"AI/art\" Filter notes by tag\n $ pnote notes get abc123 -p 1234 Get protected note with PIN\n $ export PNOTE_PIN=1234 && pnote notes\n $ pnote snippet copy abc123 Copy snippet to clipboard\n $ pnote search \"portrait\" Search notes and snippets\n\nDocumentation: https://promptnoteapp.com/docs\n`\n );\n\n// Add commands\nprogram.addCommand(authCommand);\nprogram.addCommand(notesCommand);\nprogram.addCommand(snippetCommand);\nprogram.addCommand(tagsCommand);\nprogram.addCommand(searchCommand);\nprogram.addCommand(shareCommand);\nprogram.addCommand(pinCommand);\nprogram.addCommand(skillsCommand);\nprogram.addCommand(updateCommand);\nprogram.addCommand(schemaCommand);\n\n// Update check before every command (non-blocking on cache hit, 2s max on miss)\nprogram.hook('preAction', async () => {\n await checkAndNotifyUpdate(CLI_VERSION, CLI_PACKAGE_NAME);\n});\n\n// Handle signals\nprocess.on('SIGINT', () => {\n console.error('\\nInterrupted');\n process.exit(130);\n});\n\nprocess.on('SIGTERM', () => {\n process.exit(0);\n});\n\n// Suppress broken pipe errors (when piping to head, etc.)\nprocess.stdout.on('error', (err) => {\n if (err.code === 'EPIPE') {\n process.exit(0);\n }\n throw err;\n});\n\n// Parse and run\nprogram.parseAsync(process.argv).catch((error) => {\n const noColor = program.opts().noColor ?? process.env.NO_COLOR !== undefined;\n handleError(error, noColor);\n});\n","import pc from 'picocolors';\n\n// Exit codes following Unix conventions\nexport const ExitCode = {\n SUCCESS: 0,\n GENERAL_ERROR: 1,\n AUTH_ERROR: 2,\n NOT_FOUND: 3,\n NETWORK_ERROR: 4,\n} as const;\n\nexport type ExitCodeType = (typeof ExitCode)[keyof typeof ExitCode];\n\nexport class CLIError extends Error {\n constructor(\n message: string,\n public exitCode: ExitCodeType = ExitCode.GENERAL_ERROR,\n public hint?: string\n ) {\n super(message);\n this.name = 'CLIError';\n }\n}\n\nexport class AuthError extends CLIError {\n constructor(message: string, hint?: string) {\n super(message, ExitCode.AUTH_ERROR, hint);\n this.name = 'AuthError';\n }\n}\n\nexport class NotFoundError extends CLIError {\n constructor(resource: string, id: string) {\n super(`${resource} not found (id: ${id})`, ExitCode.NOT_FOUND);\n this.name = 'NotFoundError';\n }\n}\n\nexport class NetworkError extends CLIError {\n constructor(message: string = 'Network error. Check your connection.') {\n super(message, ExitCode.NETWORK_ERROR);\n this.name = 'NetworkError';\n }\n}\n\n// Error formatting for stderr\n\nexport function formatError(error: unknown, noColor: boolean = false): string {\n const red = noColor ? (s: string) => s : pc.red;\n const dim = noColor ? (s: string) => s : pc.dim;\n\n if (error instanceof CLIError) {\n let message = `${red('Error:')} ${error.message}`;\n if (error.hint) {\n message += `\\n${dim('Hint:')} ${error.hint}`;\n }\n return message;\n }\n\n if (error instanceof Error) {\n return `${red('Error:')} ${error.message}`;\n }\n\n return `${red('Error:')} ${String(error)}`;\n}\n\n// Handle errors and exit\n\nexport function handleError(error: unknown, noColor: boolean = false): never {\n console.error(formatError(error, noColor));\n\n if (error instanceof CLIError) {\n process.exit(error.exitCode);\n }\n\n process.exit(ExitCode.GENERAL_ERROR);\n}\n\n// Parse API errors\n\nexport function parseApiError(statusCode: number, body: string): CLIError {\n try {\n const parsed = JSON.parse(body);\n const message = parsed.error?.message || parsed.message || body;\n\n switch (statusCode) {\n case 401:\n return new AuthError(\n message.includes('Unauthorized') ? 'Not logged in or invalid token' : message,\n \"Run 'pnote auth login' to authenticate\"\n );\n case 403:\n return new CLIError('Permission denied', ExitCode.AUTH_ERROR);\n case 404:\n return new CLIError('Resource not found', ExitCode.NOT_FOUND);\n default:\n return new CLIError(message);\n }\n } catch {\n return new CLIError(`HTTP ${statusCode}: ${body}`);\n }\n}\n","import { Command } from 'commander';\nimport { loginAction } from './login.js';\nimport { tokenAction } from './token.js';\nimport { logoutAction } from './logout.js';\nimport { whoamiAction } from './whoami.js';\n\nexport const authCommand = new Command('auth')\n .description('Manage authentication')\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote auth login Open browser to login\n $ pnote auth token pn_xxx Set token directly\n $ pnote auth whoami Show current user\n $ pnote auth logout Remove credentials\n`\n );\n\nauthCommand\n .command('login')\n .description('Login to PromptNote (opens browser)')\n .action(loginAction);\n\nauthCommand\n .command('token')\n .description('Set API token directly')\n .argument('<token>', 'Personal Access Token (pn_xxx)')\n .action(tokenAction);\n\nauthCommand\n .command('logout')\n .description('Remove stored credentials')\n .action(logoutAction);\n\nauthCommand\n .command('whoami')\n .description('Show current authenticated user')\n .action(whoamiAction);\n","import pc from 'picocolors';\nimport { isLoggedIn, getCredentialsPath } from '../../lib/config.js';\n\nexport async function loginAction(): Promise<void> {\n if (isLoggedIn()) {\n console.log(pc.yellow('Already logged in.'));\n console.log(pc.dim(`Credentials stored at: ${getCredentialsPath()}`));\n console.log('');\n console.log(`Run ${pc.cyan(\"'pnote auth logout'\")} to logout first.`);\n return;\n }\n\n console.log(pc.bold('Login to PromptNote'));\n console.log('');\n console.log('To authenticate, you need a Personal Access Token (PAT).');\n console.log('');\n console.log(pc.dim('Steps:'));\n console.log(' 1. Open ' + pc.cyan('https://app.promptnoteapp.com'));\n console.log(' 2. Go to Settings > API Tokens');\n console.log(' 3. Generate a new token');\n console.log(' 4. Run: ' + pc.cyan(\"pnote auth token <your-token>\"));\n console.log('');\n console.log(pc.dim('Or set the PNOTE_TOKEN environment variable.'));\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync, chmodSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\nimport type { Credentials, Config } from '../types/index.js';\n\n// XDG Base Directory paths\nexport function getConfigDir(): string {\n const xdgConfig = process.env.XDG_CONFIG_HOME;\n if (xdgConfig) {\n return join(xdgConfig, 'pnote');\n }\n\n // macOS: also check ~/Library/Application Support\n const platform = process.platform;\n if (platform === 'darwin') {\n const macPath = join(homedir(), 'Library', 'Application Support', 'pnote');\n if (existsSync(macPath)) {\n return macPath;\n }\n }\n\n // Default to ~/.config/pnote\n return join(homedir(), '.config', 'pnote');\n}\n\nfunction ensureConfigDir(): string {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n return dir;\n}\n\n// Credentials management\n\nconst CREDENTIALS_FILE = 'credentials.json';\n\nexport function getCredentialsPath(): string {\n return join(getConfigDir(), CREDENTIALS_FILE);\n}\n\nexport function loadCredentials(): Credentials | null {\n // Priority 1: Environment variable\n const envToken = process.env.PNOTE_TOKEN;\n if (envToken) {\n return {\n token: envToken,\n created_at: new Date().toISOString(),\n };\n }\n\n // Priority 2: Credentials file\n const path = getCredentialsPath();\n if (!existsSync(path)) {\n return null;\n }\n\n try {\n const content = readFileSync(path, 'utf-8');\n return JSON.parse(content) as Credentials;\n } catch {\n return null;\n }\n}\n\nexport function saveCredentials(credentials: Credentials): void {\n const dir = ensureConfigDir();\n const path = join(dir, CREDENTIALS_FILE);\n\n writeFileSync(path, JSON.stringify(credentials, null, 2), 'utf-8');\n\n // Set file permissions to 600 (owner read/write only)\n chmodSync(path, 0o600);\n}\n\nexport function deleteCredentials(): boolean {\n const path = getCredentialsPath();\n if (existsSync(path)) {\n unlinkSync(path);\n return true;\n }\n return false;\n}\n\n// Token utilities\n\nexport function getToken(): string | null {\n const creds = loadCredentials();\n return creds?.token ?? null;\n}\n\nexport function isLoggedIn(): boolean {\n return getToken() !== null;\n}\n\nexport function validateTokenFormat(token: string): boolean {\n // PAT format: pn_ + 32 characters\n return /^pn_[A-Za-z0-9_-]{20,50}$/.test(token);\n}\n\n// Config management (optional, for future use)\n\nconst CONFIG_FILE = 'config.json';\n\nexport function loadConfig(): Config {\n const path = join(getConfigDir(), CONFIG_FILE);\n if (!existsSync(path)) {\n return {};\n }\n\n try {\n const content = readFileSync(path, 'utf-8');\n return JSON.parse(content) as Config;\n } catch {\n return {};\n }\n}\n\nexport function saveConfig(config: Config): void {\n const dir = ensureConfigDir();\n const path = join(dir, CONFIG_FILE);\n writeFileSync(path, JSON.stringify(config, null, 2), 'utf-8');\n}\n\n// API Endpoint\n\nconst DEFAULT_API_ENDPOINT = 'https://tafnybfhwybgijozwfyq.supabase.co/functions/v1/promptnote-mcp/mcp';\n\nexport function getApiEndpoint(): string {\n const config = loadConfig();\n return config.api_endpoint ?? process.env.PNOTE_API_ENDPOINT ?? DEFAULT_API_ENDPOINT;\n}\n\n// PIN utilities\n\n/**\n * Get PIN from environment variable\n * Note: This is for display/status purposes only.\n * The MCP server reads PROMPTNOTE_PIN from its own environment configuration,\n * not from CLI requests. To access protected notes via MCP, users must configure\n * PROMPTNOTE_PIN in their MCP server config (e.g., claude_desktop_config.json).\n *\n * For CLI-specific operations, we use PNOTE_PIN to maintain consistency.\n */\nexport function getEnvPin(): string | null {\n return process.env.PNOTE_PIN ?? process.env.PROMPTNOTE_PIN ?? null;\n}\n","import pc from 'picocolors';\nimport { validateTokenFormat, saveCredentials, getCredentialsPath } from '../../lib/config.js';\nimport { verifyToken } from '../../lib/api.js';\nimport { CLIError, handleError } from '../../lib/errors.js';\n\nexport async function tokenAction(token: string): Promise<void> {\n // Validate token format\n if (!validateTokenFormat(token)) {\n throw new CLIError(\n 'Invalid token format',\n 1,\n \"Token should start with 'pn_' followed by 20-50 characters\"\n );\n }\n\n console.log(pc.dim('Verifying token...'));\n\n try {\n const result = await verifyToken(token);\n\n if (!result.valid) {\n throw new CLIError(\n 'Invalid token',\n 2,\n 'The token was rejected by the server. Please generate a new one.'\n );\n }\n\n // Save credentials\n saveCredentials({\n token,\n email: result.email,\n created_at: new Date().toISOString(),\n });\n\n console.log(pc.green('✓') + ' Token saved successfully!');\n console.log(pc.dim(`Credentials stored at: ${getCredentialsPath()}`));\n console.log('');\n console.log(`You can now use ${pc.cyan('pnote')} commands.`);\n } catch (error) {\n handleError(error);\n }\n}\n","import { getToken, getApiEndpoint } from './config.js';\nimport { AuthError, NetworkError, CLIError, ExitCode } from './errors.js';\n\n// REST API base URL (replace /mcp with /v1)\nfunction getRestApiBase(): string {\n const mcpEndpoint = getApiEndpoint();\n return mcpEndpoint.replace(/\\/mcp$/, '/v1');\n}\n\nexport interface RequestOptions {\n pin?: string;\n timeout?: number;\n}\n\n// Generic REST API call\nasync function callRestApi<T>(\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE',\n path: string,\n body?: Record<string, unknown>,\n options: RequestOptions = {}\n): Promise<T> {\n const token = getToken();\n if (!token) {\n throw new AuthError(\n 'Not logged in',\n \"Run 'pnote auth login' or 'pnote auth token <token>' to authenticate\"\n );\n }\n\n const baseUrl = getRestApiBase();\n const url = `${baseUrl}${path}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n };\n\n // Add PIN header if provided\n if (options.pin) {\n headers['X-PromptNote-PIN'] = options.pin;\n }\n\n let response: Response;\n try {\n const fetchOptions: RequestInit = {\n method,\n headers,\n signal: AbortSignal.timeout(options.timeout ?? 30000),\n };\n\n if (body && (method === 'POST' || method === 'PATCH')) {\n fetchOptions.body = JSON.stringify(body);\n }\n\n response = await fetch(url, fetchOptions);\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'TimeoutError' || error.name === 'AbortError') {\n throw new NetworkError('Request timed out. Please try again.');\n }\n if (error.message.includes('fetch')) {\n throw new NetworkError('Unable to connect to PromptNote API. Check your internet connection.');\n }\n }\n throw new NetworkError();\n }\n\n // Handle HTTP errors\n if (!response.ok) {\n const errorBody = await response.json().catch(() => ({})) as { message?: string };\n\n if (response.status === 401) {\n throw new AuthError(\n errorBody.message || 'Invalid or expired token',\n \"Run 'pnote auth login' to re-authenticate\"\n );\n }\n\n if (response.status === 403) {\n throw new CLIError('Permission denied', ExitCode.AUTH_ERROR);\n }\n\n if (response.status === 404) {\n throw new CLIError(errorBody.message || 'Resource not found', ExitCode.NOT_FOUND);\n }\n\n if (response.status === 400) {\n throw new CLIError(errorBody.message || 'Invalid request', ExitCode.GENERAL_ERROR);\n }\n\n throw new CLIError(`API error (${response.status}): ${errorBody.message || 'Unknown error'}`);\n }\n\n return response.json() as Promise<T>;\n}\n\n// ============================================================\n// Notes API\n// ============================================================\n\nexport interface ListNotesParams {\n tag?: string;\n archived?: boolean;\n pinned?: boolean;\n deleted?: boolean;\n protected?: boolean;\n note_type?: 'note' | 'skill';\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport async function listNotes<T>(params: ListNotesParams = {}, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n if (params.tag) query.set('tag', params.tag);\n if (params.archived !== undefined) query.set('archived', String(params.archived));\n if (params.pinned !== undefined) query.set('pinned', String(params.pinned));\n if (params.deleted !== undefined) query.set('deleted', String(params.deleted));\n if (params.protected !== undefined) query.set('protected', String(params.protected));\n if (params.note_type) query.set('note_type', params.note_type);\n if (params.search) query.set('search', params.search);\n if (params.limit) query.set('limit', String(params.limit));\n if (params.offset) query.set('offset', String(params.offset));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function getNote<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', `/notes/${id}`, undefined, options);\n}\n\nexport async function createNote<T>(\n data: { title: string; tags?: string[]; content?: string; note_type?: 'note' | 'skill' },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/notes', data, options);\n}\n\nexport async function updateNote<T>(\n id: string,\n data: { title?: string; tags?: string[]; archived?: boolean; pinned?: boolean },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('PATCH', `/notes/${id}`, data, options);\n}\n\nexport async function deleteNote<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('DELETE', `/notes/${id}`, undefined, options);\n}\n\n// ============================================================\n// Snippets API\n// ============================================================\n\nexport interface ListSnippetsParams {\n note_id: string;\n include_deleted?: boolean;\n limit?: number;\n}\n\nexport async function listSnippets<T>(params: ListSnippetsParams, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n query.set('note_id', params.note_id);\n if (params.include_deleted !== undefined) query.set('include_deleted', String(params.include_deleted));\n if (params.limit) query.set('limit', String(params.limit));\n\n return callRestApi<T>('GET', `/snippets?${query.toString()}`, undefined, options);\n}\n\nexport async function getSnippet<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', `/snippets/${id}`, undefined, options);\n}\n\nexport async function createSnippet<T>(\n data: { note_id: string; content: string; title?: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/snippets', data, options);\n}\n\nexport async function updateSnippet<T>(\n id: string,\n data: { content?: string; title?: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('PATCH', `/snippets/${id}`, data, options);\n}\n\nexport async function toggleFavorite<T>(id: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('POST', `/snippets/${id}/favorite`, {}, options);\n}\n\n// ============================================================\n// Tags API\n// ============================================================\n\nexport interface ListTagsParams {\n include_archived?: boolean;\n}\n\nexport async function listTags<T>(params: ListTagsParams = {}, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n if (params.include_archived !== undefined) query.set('include_archived', String(params.include_archived));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/tags${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function renameTag<T>(\n data: { old_tag: string; new_tag: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/tags/rename', data, options);\n}\n\nexport async function mergeTags<T>(\n data: { source_tags: string[]; target_tag: string },\n options: RequestOptions = {}\n): Promise<T> {\n return callRestApi<T>('POST', '/tags/merge', data, options);\n}\n\n// ============================================================\n// Search API\n// ============================================================\n\nexport interface SearchParams {\n query: string;\n search_notes?: boolean;\n search_snippets?: boolean;\n limit?: number;\n}\n\nexport async function search<T>(params: SearchParams, options: RequestOptions = {}): Promise<T> {\n const query = new URLSearchParams();\n query.set('q', params.query);\n if (params.search_notes !== undefined) query.set('search_notes', String(params.search_notes));\n if (params.search_snippets !== undefined) query.set('search_snippets', String(params.search_snippets));\n if (params.limit) query.set('limit', String(params.limit));\n\n return callRestApi<T>('GET', `/search?${query.toString()}`, undefined, options);\n}\n\n// ============================================================\n// PIN API\n// ============================================================\n\nexport async function checkPinStatus<T>(options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', '/pin/status', undefined, options);\n}\n\nexport async function listProtectedNotes<T>(\n params: { limit?: number; offset?: number } = {},\n options: RequestOptions = {}\n): Promise<T> {\n const query = new URLSearchParams();\n if (params.limit) query.set('limit', String(params.limit));\n if (params.offset) query.set('offset', String(params.offset));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/pin/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function verifyPin<T>(pin: string, options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('POST', '/pin/verify', { pin }, options);\n}\n\n// ============================================================\n// Sharing API\n// ============================================================\n\nexport async function listSharedTags<T>(options: RequestOptions = {}): Promise<T> {\n return callRestApi<T>('GET', '/share/tags', undefined, options);\n}\n\nexport async function getSharedTagNotes<T>(\n id: string,\n params: { limit?: number } = {},\n options: RequestOptions = {}\n): Promise<T> {\n const query = new URLSearchParams();\n if (params.limit) query.set('limit', String(params.limit));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/share/tags/${id}/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\nexport async function listSharedNotes<T>(\n params: { include_revoked?: boolean } = {},\n options: RequestOptions = {}\n): Promise<T> {\n const query = new URLSearchParams();\n if (params.include_revoked !== undefined) query.set('include_revoked', String(params.include_revoked));\n\n const queryString = query.toString();\n return callRestApi<T>('GET', `/share/notes${queryString ? `?${queryString}` : ''}`, undefined, options);\n}\n\n// ============================================================\n// Legacy MCP API (for backward compatibility and token verification)\n// ============================================================\n\nimport type { MCPRequest, MCPResponse } from '../types/index.js';\n\nlet requestId = 0;\n\nfunction getNextId(): number {\n return ++requestId;\n}\n\n/**\n * @deprecated Use REST API functions instead (listNotes, getNote, etc.)\n */\nexport async function callMCP<T>(\n toolName: string,\n args: Record<string, unknown> = {}\n): Promise<T> {\n const token = getToken();\n if (!token) {\n throw new AuthError(\n 'Not logged in',\n \"Run 'pnote auth login' or 'pnote auth token <token>' to authenticate\"\n );\n }\n\n const endpoint = getApiEndpoint();\n\n const request: MCPRequest = {\n jsonrpc: '2.0',\n id: getNextId(),\n method: 'tools/call',\n params: {\n name: toolName,\n arguments: args,\n },\n };\n\n let response: Response;\n try {\n response = await fetch(endpoint, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n body: JSON.stringify(request),\n signal: AbortSignal.timeout(30000),\n });\n } catch (error) {\n if (error instanceof Error) {\n if (error.name === 'TimeoutError' || error.name === 'AbortError') {\n throw new NetworkError('Request timed out. Please try again.');\n }\n if (error.message.includes('fetch')) {\n throw new NetworkError('Unable to connect to PromptNote API. Check your internet connection.');\n }\n }\n throw new NetworkError();\n }\n\n if (!response.ok) {\n const body = await response.text();\n\n if (response.status === 401) {\n throw new AuthError(\n 'Invalid or expired token',\n \"Run 'pnote auth login' to re-authenticate\"\n );\n }\n\n if (response.status === 403) {\n throw new CLIError('Permission denied', ExitCode.AUTH_ERROR);\n }\n\n throw new CLIError(`API error (${response.status}): ${body}`);\n }\n\n const mcpResponse = (await response.json()) as MCPResponse;\n\n if (mcpResponse.error) {\n throw new CLIError(`MCP error: ${mcpResponse.error.message}`);\n }\n\n if (!mcpResponse.result) {\n throw new CLIError('Invalid response from API');\n }\n\n const content = mcpResponse.result.content;\n if (!content || content.length === 0) {\n throw new CLIError('Empty response from API');\n }\n\n if (mcpResponse.result.isError) {\n const errorText = content[0]?.text || 'Unknown error';\n\n if (errorText.includes('not found') || errorText.includes('PGRST116')) {\n throw new CLIError('Resource not found', ExitCode.NOT_FOUND);\n }\n if (errorText.includes('Unauthorized')) {\n throw new AuthError(errorText);\n }\n\n throw new CLIError(errorText);\n }\n\n const textContent = content[0]?.text;\n if (!textContent) {\n throw new CLIError('No content in response');\n }\n\n try {\n return JSON.parse(textContent) as T;\n } catch {\n return textContent as T;\n }\n}\n\n// Verify token is valid by making a simple API call (using REST API)\nexport async function verifyToken(token: string): Promise<{ valid: boolean; email?: string }> {\n const baseUrl = getApiEndpoint().replace(/\\/mcp$/, '/v1');\n\n try {\n const response = await fetch(`${baseUrl}/notes?limit=1`, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${token}`,\n },\n signal: AbortSignal.timeout(10000),\n });\n\n if (response.status === 401) {\n return { valid: false };\n }\n\n if (!response.ok) {\n return { valid: false };\n }\n\n return { valid: true };\n } catch {\n throw new NetworkError('Unable to verify token. Check your internet connection.');\n }\n}\n","import pc from 'picocolors';\nimport { deleteCredentials, isLoggedIn } from '../../lib/config.js';\n\nexport async function logoutAction(): Promise<void> {\n if (!isLoggedIn()) {\n console.log(pc.dim('Not logged in.'));\n return;\n }\n\n const deleted = deleteCredentials();\n\n if (deleted) {\n console.log(pc.green('✓') + ' Logged out successfully.');\n } else {\n console.log(pc.dim('No credentials to remove.'));\n }\n\n // Remind about environment variable\n if (process.env.PNOTE_TOKEN) {\n console.log('');\n console.log(\n pc.yellow('Note:') +\n ' PNOTE_TOKEN environment variable is still set.'\n );\n console.log(pc.dim('Unset it with: unset PNOTE_TOKEN'));\n }\n}\n","import pc from 'picocolors';\nimport { loadCredentials, isLoggedIn, getCredentialsPath } from '../../lib/config.js';\nimport { listNotes } from '../../lib/api.js';\nimport { handleError, AuthError } from '../../lib/errors.js';\nimport type { ListNotesResponse } from '../../types/index.js';\n\nexport async function whoamiAction(): Promise<void> {\n if (!isLoggedIn()) {\n throw new AuthError(\n 'Not logged in',\n \"Run 'pnote auth login' to authenticate\"\n );\n }\n\n const creds = loadCredentials();\n if (!creds) {\n throw new AuthError('No credentials found');\n }\n\n try {\n // Verify token is still valid by making a simple API call\n const result = await listNotes<ListNotesResponse>({ limit: 1 });\n\n console.log(pc.green('✓') + ' Authenticated');\n console.log('');\n\n if (creds.email) {\n console.log(pc.dim('Email: ') + creds.email);\n }\n\n console.log(pc.dim('Token: ') + creds.token.slice(0, 7) + '...' + creds.token.slice(-4));\n console.log(pc.dim('Stored: ') + getCredentialsPath());\n\n if (process.env.PNOTE_TOKEN) {\n console.log(pc.dim('Source: ') + 'PNOTE_TOKEN environment variable');\n } else {\n console.log(pc.dim('Source: ') + 'credentials file');\n }\n\n console.log('');\n console.log(pc.dim(`Total notes: ${result.count}`));\n } catch (error) {\n handleError(error);\n }\n}\n","import { Command } from 'commander';\nimport { listNotesAction } from './list.js';\nimport { getNoteAction } from './get.js';\nimport { createNoteAction } from './create.js';\nimport { archiveNoteAction } from './archive.js';\nimport { pinNoteAction } from './pin.js';\nimport { deleteNoteAction } from './delete.js';\nimport { updateNoteAction } from './update.js';\nimport { notesSnippetCommand } from './snippetCmd.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n // Resolve PIN from various sources\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true, // Don't prompt interactively for list/search operations\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const notesCommand = new Command('notes')\n .description('List and manage notes')\n .option('--tag <tag>', 'Filter by tag (e.g., \"AI/art\")')\n .option('--archived', 'Show archived notes')\n .option('--pinned', 'Show only pinned notes')\n .option('--deleted', 'Show deleted notes')\n .option('--protected', 'Show only PIN-protected notes')\n .option('--search <query>', 'Search notes by title')\n .option('--limit <n>', 'Limit number of results', '50')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listNotesAction(options, ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote notes List all active notes\n $ pnote notes --tag \"AI/art\" Filter by tag\n $ pnote notes --archived Show archived notes\n $ pnote notes --pinned Show only pinned notes\n $ pnote notes get abc123 Get note with all snippet versions\n $ pnote notes get abc123 --latest Get note with only latest snippet\n $ pnote notes create \"My Note\" Create a new note\n $ pnote notes snippet abc123 Show latest snippet (pipe-friendly)\n $ pnote notes snippet list abc123 Show all snippet versions\n $ cat file.txt | pnote notes snippet add abc123\n`\n );\n\nnotesCommand\n .command('get')\n .description('Get a note with all its snippet versions')\n .argument('<id>', 'Note ID')\n .option('--latest', 'Show only the latest snippet version')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await getNoteAction(id, options, ctx);\n });\n\nnotesCommand\n .command('create')\n .description('Create a new note')\n .argument('<title>', 'Note title')\n .option('--tags <tags...>', 'Tags for the note')\n .option('--content <content>', 'Initial snippet content')\n .action(async (title: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await createNoteAction(title, options, ctx);\n });\n\nnotesCommand\n .command('archive')\n .description('Archive or unarchive a note')\n .argument('<id>', 'Note ID')\n .option('--undo', 'Unarchive the note')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await archiveNoteAction(id, options, ctx);\n });\n\nnotesCommand\n .command('pin')\n .description('Pin or unpin a note')\n .argument('<id>', 'Note ID')\n .action(async (id: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pinNoteAction(id, ctx);\n });\n\nnotesCommand\n .command('update')\n .description('Update a note title or tags')\n .argument('<id>', 'Note ID')\n .option('--title <title>', 'New title')\n .option('--tags <tags...>', 'New tags (replaces existing)')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await updateNoteAction(id, options, ctx);\n });\n\nnotesCommand\n .command('delete')\n .description('Delete a note (soft delete)')\n .argument('<id>', 'Note ID')\n .option('--force', 'Skip confirmation')\n .action(async (id: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await deleteNoteAction(id, options, ctx);\n });\n\nnotesCommand.addCommand(notesSnippetCommand);\n","import pc from 'picocolors';\nimport type {\n CLIContext, Note, Snippet, Tag, TagHierarchy,\n ListSharedTagsResponse, GetSharedTagNotesResponse, ListSharedNotesResponse,\n} from '../types/index.js';\n\n// Check if output should use colors\nfunction shouldUseColor(ctx: CLIContext): boolean {\n if (ctx.noColor) return false;\n if (process.env.NO_COLOR) return false;\n if (process.env.TERM === 'dumb') return false;\n return process.stdout.isTTY ?? false;\n}\n\n// Check if output should be formatted for humans\nfunction isHumanOutput(ctx: CLIContext): boolean {\n if (ctx.json) return false;\n if (ctx.plain) return false;\n return process.stdout.isTTY ?? false;\n}\n\n// Color helpers\nfunction getColors(ctx: CLIContext) {\n const useColor = shouldUseColor(ctx);\n return {\n dim: useColor ? pc.dim : (s: string) => s,\n bold: useColor ? pc.bold : (s: string) => s,\n green: useColor ? pc.green : (s: string) => s,\n yellow: useColor ? pc.yellow : (s: string) => s,\n blue: useColor ? pc.blue : (s: string) => s,\n cyan: useColor ? pc.cyan : (s: string) => s,\n red: useColor ? pc.red : (s: string) => s,\n magenta: useColor ? pc.magenta : (s: string) => s,\n };\n}\n\n// Format relative time\nfunction formatRelativeTime(dateStr: string): string {\n const date = new Date(dateStr);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffSecs = Math.floor(diffMs / 1000);\n const diffMins = Math.floor(diffSecs / 60);\n const diffHours = Math.floor(diffMins / 60);\n const diffDays = Math.floor(diffHours / 24);\n\n if (diffDays > 30) {\n return date.toLocaleDateString();\n }\n if (diffDays > 0) {\n return `${diffDays}d ago`;\n }\n if (diffHours > 0) {\n return `${diffHours}h ago`;\n }\n if (diffMins > 0) {\n return `${diffMins}m ago`;\n }\n return 'just now';\n}\n\n// Truncate string with ellipsis\nfunction truncate(str: string, maxLen: number): string {\n if (str.length <= maxLen) return str;\n return str.slice(0, maxLen - 1) + '…';\n}\n\n// Pad string to fixed width\nfunction pad(str: string, width: number): string {\n if (str.length >= width) return str.slice(0, width);\n return str + ' '.repeat(width - str.length);\n}\n\n// Output JSON to stdout\nexport function outputJson(data: unknown): void {\n console.log(JSON.stringify(data, null, 2));\n}\n\n// Output notes list\nexport function outputNotes(notes: Note[], ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(notes);\n return;\n }\n\n if (notes.length === 0) {\n const c = getColors(ctx);\n console.log(c.dim('No notes found.'));\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n // Table header\n console.log(\n c.dim(pad('ID', 12)) +\n ' ' +\n c.dim(pad('TITLE', 30)) +\n ' ' +\n c.dim(pad('TAGS', 20)) +\n ' ' +\n c.dim('UPDATED')\n );\n\n for (const note of notes) {\n const id = truncate(note.id.slice(0, 8), 12);\n const title = truncate(note.title || '(untitled)', 30);\n const tags = truncate(note.tags.join(', ') || '-', 20);\n const updated = formatRelativeTime(note.updated_at);\n\n let line = pad(id, 12) + ' ' + pad(title, 30) + ' ' + pad(tags, 20) + ' ' + updated;\n\n // Add indicators\n const indicators: string[] = [];\n if (note.pinned) indicators.push(c.yellow('*'));\n if (note.archived) indicators.push(c.dim('[A]'));\n if (note.is_protected) indicators.push(c.magenta('[P]'));\n\n if (indicators.length > 0) {\n line = indicators.join('') + ' ' + line;\n }\n\n console.log(line);\n }\n } else {\n // Plain output - one note per line, tab-separated\n for (const note of notes) {\n console.log(\n [note.id, note.title, note.tags.join(','), note.updated_at].join('\\t')\n );\n }\n }\n}\n\n// Output single note with its snippet history\nexport function outputNote(note: Note, snippets: Snippet[], ctx: CLIContext): void {\n const latestSnippet = snippets.length > 0 ? snippets[snippets.length - 1] : null;\n\n if (ctx.json) {\n outputJson({ ...note, snippets, latest_snippet: latestSnippet });\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n console.log(c.bold(note.title || '(untitled)'));\n console.log(c.dim('ID: ') + note.id);\n console.log(c.dim('Tags: ') + (note.tags.length > 0 ? note.tags.join(', ') : '-'));\n console.log(c.dim('Created: ') + new Date(note.created_at).toLocaleString());\n console.log(c.dim('Updated: ') + new Date(note.updated_at).toLocaleString());\n\n const status: string[] = [];\n if (note.pinned) status.push(c.yellow('pinned'));\n if (note.archived) status.push(c.dim('archived'));\n if (note.is_protected) status.push(c.magenta('protected'));\n if (status.length > 0) {\n console.log(c.dim('Status: ') + status.join(', '));\n }\n\n if (snippets.length === 0) {\n console.log('');\n console.log(c.dim('(no content)'));\n } else {\n for (const snippet of snippets) {\n const header = `v${snippet.version}` +\n (snippet.favorite ? c.yellow(' ★') : '') +\n c.dim(` (${formatRelativeTime(snippet.created_at)})`);\n console.log('');\n console.log(c.dim('--- Snippet ') + c.bold(header) + c.dim(' ---'));\n console.log(snippet.content);\n }\n }\n } else {\n // Plain output\n console.log(`Title: ${note.title}`);\n console.log(`ID: ${note.id}`);\n console.log(`Tags: ${note.tags.join(', ')}`);\n for (const snippet of snippets) {\n console.log('');\n console.log(`v${snippet.version}\\t${snippet.content}`);\n }\n }\n}\n\n// Output snippet content\nexport function outputSnippet(snippet: Snippet, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(snippet);\n return;\n }\n\n // For snippet, just output the content directly (useful for piping)\n console.log(snippet.content);\n}\n\n// Output snippets list\nexport function outputSnippets(snippets: Snippet[], ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(snippets);\n return;\n }\n\n if (snippets.length === 0) {\n const c = getColors(ctx);\n console.log(c.dim('No snippets found.'));\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n for (const snippet of snippets) {\n const header = `v${snippet.version}` +\n (snippet.favorite ? c.yellow(' ★') : '') +\n c.dim(` (${formatRelativeTime(snippet.created_at)})`);\n\n console.log(c.bold(header));\n console.log(snippet.content);\n console.log('');\n }\n } else {\n for (const snippet of snippets) {\n console.log(`v${snippet.version}\\t${snippet.id}\\t${snippet.content.slice(0, 100)}`);\n }\n }\n}\n\n// Output tags tree\nexport function outputTags(tags: Tag[], hierarchy: TagHierarchy, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson({ tags, hierarchy });\n return;\n }\n\n if (tags.length === 0) {\n const c = getColors(ctx);\n console.log(c.dim('No tags found.'));\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n // Build tree structure\n const roots: string[] = [];\n const childrenMap: Map<string, string[]> = new Map();\n\n for (const tag of tags) {\n const parts = tag.tag.split('/');\n if (parts.length === 1) {\n roots.push(tag.tag);\n } else {\n const parent = parts.slice(0, -1).join('/');\n const children = childrenMap.get(parent) || [];\n children.push(tag.tag);\n childrenMap.set(parent, children);\n }\n }\n\n // Sort roots\n roots.sort();\n\n const tagCountMap = new Map(tags.map((t) => [t.tag, t.count]));\n\n function printTree(tagPath: string, prefix: string, isLast: boolean): void {\n const count = tagCountMap.get(tagPath) || 0;\n const name = tagPath.split('/').pop() || tagPath;\n const connector = isLast ? '└── ' : '├── ';\n\n console.log(prefix + connector + c.cyan(name) + c.dim(` (${count})`));\n\n const children = childrenMap.get(tagPath) || [];\n children.sort();\n\n const newPrefix = prefix + (isLast ? ' ' : '│ ');\n children.forEach((child, i) => {\n printTree(child, newPrefix, i === children.length - 1);\n });\n }\n\n roots.forEach((root, i) => {\n const count = tagCountMap.get(root) || 0;\n console.log(c.cyan(root) + c.dim(` (${count})`));\n\n const children = childrenMap.get(root) || [];\n children.sort();\n children.forEach((child, j) => {\n printTree(child, '', j === children.length - 1);\n });\n });\n } else {\n // Plain output\n for (const tag of tags) {\n console.log(`${tag.tag}\\t${tag.count}`);\n }\n }\n}\n\n// Output search results\nexport function outputSearchResults(\n query: string,\n notes: Note[],\n snippets: Array<{\n id: string;\n note_id: string;\n note_title: string;\n version: number;\n content_preview: string;\n favorite: boolean;\n }>,\n ctx: CLIContext\n): void {\n if (ctx.json) {\n outputJson({ query, notes, snippets });\n return;\n }\n\n const c = getColors(ctx);\n\n if (notes.length === 0 && snippets.length === 0) {\n console.log(c.dim(`No results for \"${query}\"`));\n return;\n }\n\n if (notes.length > 0) {\n console.log(c.bold(`Notes (${notes.length})`));\n console.log('');\n for (const note of notes) {\n console.log(\n ' ' + c.cyan(note.id.slice(0, 8)) + ' ' + note.title + ' ' + c.dim(note.tags.join(', '))\n );\n }\n console.log('');\n }\n\n if (snippets.length > 0) {\n console.log(c.bold(`Snippets (${snippets.length})`));\n console.log('');\n for (const snippet of snippets) {\n console.log(\n ' ' +\n c.cyan(snippet.note_id.slice(0, 8)) +\n ' ' +\n snippet.note_title +\n c.dim(` v${snippet.version}`)\n );\n console.log(' ' + c.dim(truncate(snippet.content_preview, 60)));\n }\n }\n}\n\n// Output shared tags list\nexport function outputSharedTags(data: ListSharedTagsResponse, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(data);\n return;\n }\n\n const c = getColors(ctx);\n const totalCount = data.owned.count + data.shared_with_me.count;\n\n if (totalCount === 0) {\n console.log(c.dim('No shared tags.'));\n return;\n }\n\n if (isHumanOutput(ctx)) {\n if (data.owned.count > 0) {\n console.log(c.bold(`Owned (${data.owned.count})`));\n console.log('');\n for (const tag of data.owned.tags) {\n console.log(\n ' ' + c.cyan(tag.id.slice(0, 8)) + ' ' +\n pad(tag.tag_path, 24) + ' ' +\n c.dim(formatRelativeTime(tag.created_at))\n );\n }\n console.log('');\n }\n\n if (data.shared_with_me.count > 0) {\n console.log(c.bold(`Shared with me (${data.shared_with_me.count})`));\n console.log('');\n for (const tag of data.shared_with_me.tags) {\n console.log(\n ' ' + c.cyan(tag.id.slice(0, 8)) + ' ' +\n pad(tag.tag_path, 24) + ' ' +\n c.dim('joined ' + formatRelativeTime(tag.joined_at))\n );\n }\n }\n } else {\n for (const tag of data.owned.tags) {\n console.log(['owned', tag.id, tag.tag_path, tag.created_at].join('\\t'));\n }\n for (const tag of data.shared_with_me.tags) {\n console.log(['shared', tag.id, tag.tag_path, tag.joined_at].join('\\t'));\n }\n }\n}\n\n// Output shared tag notes\nexport function outputSharedTagNotes(data: GetSharedTagNotesResponse, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(data);\n return;\n }\n\n const c = getColors(ctx);\n\n if (isHumanOutput(ctx)) {\n const role = data.shared_tag.is_owner ? 'owner' : 'member';\n console.log(c.bold(data.shared_tag.tag_path) + c.dim(` (${role}, ${data.members_count} members)`));\n console.log('');\n\n if (data.notes.length === 0) {\n console.log(c.dim(' No notes in this shared tag.'));\n return;\n }\n\n console.log(\n ' ' + c.dim(pad('ID', 10)) +\n ' ' + c.dim(pad('TITLE', 24)) +\n ' ' + c.dim(pad('AUTHOR', 20)) +\n ' ' + c.dim('UPDATED')\n );\n\n for (const note of data.notes) {\n const author = note.is_own ? 'you' : (note.author.email || 'unknown');\n console.log(\n ' ' + pad(note.id.slice(0, 8), 10) +\n ' ' + pad(truncate(note.title, 24), 24) +\n ' ' + pad(truncate(author, 20), 20) +\n ' ' + formatRelativeTime(note.updated_at)\n );\n }\n } else {\n for (const note of data.notes) {\n const author = note.is_own ? 'you' : (note.author.email || 'unknown');\n console.log([note.id, note.title, author, note.updated_at].join('\\t'));\n }\n }\n}\n\n// Output shared notes (public links)\nexport function outputSharedNotes(data: ListSharedNotesResponse, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson(data);\n return;\n }\n\n const c = getColors(ctx);\n\n if (data.count === 0) {\n console.log(c.dim('No shared notes.'));\n return;\n }\n\n if (isHumanOutput(ctx)) {\n console.log(c.bold(`Shared Notes (${data.count})`));\n console.log('');\n\n for (const share of data.shares) {\n const revoked = share.is_revoked ? c.red(' [R]') : '';\n console.log(\n ' ' + truncate(share.note_title, 20) +\n ' ' + c.cyan(share.share_url) +\n ' ' + c.dim(`${share.view_count} views`) +\n ' ' + c.dim(formatRelativeTime(share.created_at)) +\n revoked\n );\n }\n } else {\n for (const share of data.shares) {\n console.log(\n [share.note_title, share.share_url, share.view_count, share.is_revoked, share.created_at].join('\\t')\n );\n }\n }\n}\n\n// Output simple message\nexport function outputMessage(message: string, ctx: CLIContext): void {\n if (ctx.json) {\n outputJson({ message });\n return;\n }\n\n const c = getColors(ctx);\n console.log(c.green('✓') + ' ' + message);\n}\n\n// Output to stderr (for status messages when piping)\nexport function logStatus(message: string): void {\n if (process.stderr.isTTY) {\n console.error(pc.dim(message));\n }\n}\n","import { listNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputNotes } from '../../lib/output.js';\nimport type { ListNotesResponse, CLIContext } from '../../types/index.js';\n\ninterface ListNotesOptions {\n tag?: string;\n archived?: boolean;\n pinned?: boolean;\n deleted?: boolean;\n protected?: boolean;\n search?: string;\n limit?: string;\n}\n\nexport async function listNotesAction(\n options: ListNotesOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await listNotes<ListNotesResponse>(\n {\n tag: options.tag,\n archived: options.archived ?? false,\n pinned: options.pinned,\n deleted: options.deleted ?? false,\n protected: options.protected,\n search: options.search,\n limit: options.limit ? parseInt(options.limit, 10) : 50,\n },\n { pin: ctx.pin }\n );\n\n outputNotes(result.notes, ctx);\n\n // Show warning for protected notes if any\n if (result.warning && !ctx.json) {\n console.error('');\n console.error(result.warning);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { getNote } from '../../lib/api.js';\nimport { handleError, NotFoundError } from '../../lib/errors.js';\nimport { outputNote } from '../../lib/output.js';\nimport type { GetNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface GetNoteOptions {\n latest?: boolean;\n}\n\nexport async function getNoteAction(id: string, options: GetNoteOptions, ctx: CLIContext): Promise<void> {\n try {\n const result = await getNote<GetNoteResponse>(id, { pin: ctx.pin });\n\n if (!result) {\n throw new NotFoundError('Note', id);\n }\n\n const snippets = options.latest\n ? (result.latest_snippet ? [result.latest_snippet] : [])\n : (result.snippets || []);\n\n outputNote(result, snippets, ctx);\n\n // Show protection status warning if applicable\n if (result.protection_status?.error && !ctx.json) {\n console.error('');\n console.error('Warning: ' + result.protection_status.error);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { createNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { CreateNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface CreateNoteOptions {\n tags?: string[];\n content?: string;\n}\n\nexport async function createNoteAction(\n title: string,\n options: CreateNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let content = options.content;\n\n // If stdin has content and no --content flag, read from stdin\n if (!content && !process.stdin.isTTY) {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n const stdinContent = Buffer.concat(chunks).toString('utf-8').trim();\n if (stdinContent) {\n content = stdinContent;\n }\n }\n\n const result = await createNote<CreateNoteResponse>(\n {\n title,\n tags: options.tags && options.tags.length > 0 ? options.tags : undefined,\n content,\n },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Created note: ${result.note.title} (${result.note.id})`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { updateNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { UpdateNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface ArchiveNoteOptions {\n undo?: boolean;\n}\n\nexport async function archiveNoteAction(\n id: string,\n options: ArchiveNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const archived = !options.undo;\n\n const result = await updateNote<UpdateNoteResponse>(\n id,\n { archived },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const action = archived ? 'Archived' : 'Unarchived';\n outputMessage(`${action} note: ${result.note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { getNote, updateNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { GetNoteResponse, UpdateNoteResponse, CLIContext } from '../../types/index.js';\n\nexport async function pinNoteAction(id: string, ctx: CLIContext): Promise<void> {\n try {\n // First get current pin status\n const note = await getNote<GetNoteResponse>(id, { pin: ctx.pin });\n const newPinned = !note.pinned;\n\n const result = await updateNote<UpdateNoteResponse>(\n id,\n { pinned: newPinned },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const action = newPinned ? 'Pinned' : 'Unpinned';\n outputMessage(`${action} note: ${result.note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import pc from 'picocolors';\nimport { createInterface } from 'node:readline';\nimport { getNote, deleteNote } from '../../lib/api.js';\nimport { handleError, CLIError, ExitCode } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { GetNoteResponse, DeleteNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface DeleteNoteOptions {\n force?: boolean;\n}\n\nasync function confirm(message: string): Promise<boolean> {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(message + ' [y/N] ', (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport async function deleteNoteAction(\n id: string,\n options: DeleteNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n // Get note details first\n const note = await getNote<GetNoteResponse>(id, { pin: ctx.pin });\n\n // Confirm deletion unless --force or --json\n if (!options.force && !ctx.json) {\n if (!process.stdin.isTTY) {\n throw new CLIError(\n 'Cannot confirm deletion in non-interactive mode',\n ExitCode.GENERAL_ERROR,\n 'Use --force for non-interactive deletion'\n );\n }\n\n console.log(`About to delete: ${pc.bold(note.title)}`);\n const confirmed = await confirm('Are you sure?');\n\n if (!confirmed) {\n console.log(pc.dim('Cancelled.'));\n return;\n }\n }\n\n const result = await deleteNote<DeleteNoteResponse>(id, { pin: ctx.pin });\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Deleted note: ${note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { updateNote } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { UpdateNoteResponse, CLIContext } from '../../types/index.js';\n\ninterface UpdateNoteOptions {\n title?: string;\n tags?: string[];\n}\n\nexport async function updateNoteAction(\n id: string,\n options: UpdateNoteOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n if (!options.title && !options.tags) {\n throw new CLIError(\n 'No changes provided',\n 1,\n 'Use --title or --tags to specify what to update'\n );\n }\n\n const data: { title?: string; tags?: string[] } = {};\n if (options.title) data.title = options.title;\n if (options.tags) data.tags = options.tags;\n\n const result = await updateNote<UpdateNoteResponse>(id, data, { pin: ctx.pin });\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Updated note: ${result.note.title}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { Command } from 'commander';\nimport { getNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSnippets } from '../../lib/output.js';\nimport { showSnippetAction } from '../snippet/show.js';\nimport { copySnippetAction } from '../snippet/copy.js';\nimport { addSnippetAction } from '../snippet/add.js';\nimport { updateSnippetAction } from '../snippet/update.js';\nimport { favoriteSnippetAction } from '../snippet/favorite.js';\nimport type { GetNoteResponse, CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const notesSnippetCommand = new Command('snippet')\n .description('Read and manage snippets for a note')\n .argument('[note-id]', 'Note ID to show latest snippet for')\n .action(async (noteId: string | undefined, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n if (noteId) {\n await showSnippetAction(noteId, {}, ctx);\n } else {\n cmd.help();\n }\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote notes snippet abc123 Show latest snippet (pipe-friendly)\n $ pnote notes snippet list abc123 Show all versions\n $ pnote notes snippet copy abc123 Copy to clipboard\n $ cat file.txt | pnote notes snippet add abc123\n`\n );\n\n// list — show all snippet versions for a note\nnotesSnippetCommand\n .command('list')\n .description('List all snippet versions for a note')\n .argument('<note-id>', 'Note ID')\n .action(async (noteId: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n try {\n const result = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n outputSnippets(result.snippets || [], ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n });\n\n// copy — copy latest (or specific version) snippet to clipboard\nnotesSnippetCommand\n .command('copy')\n .description('Copy snippet content to clipboard')\n .argument('<note-id>', 'Note ID')\n .option('--version <n>', 'Specific version number')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await copySnippetAction(noteId, options, ctx);\n });\n\n// add — add a new snippet version from stdin\nnotesSnippetCommand\n .command('add')\n .description('Add a new snippet version (from stdin)')\n .argument('<note-id>', 'Note ID')\n .option('--title <title>', 'Snippet title')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await addSnippetAction(noteId, options, ctx);\n });\n\n// update — update an existing snippet from stdin\nnotesSnippetCommand\n .command('update')\n .description('Update an existing snippet (from stdin)')\n .argument('<snippet-id>', 'Snippet ID')\n .option('--title <title>', 'New snippet title')\n .action(async (snippetId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await updateSnippetAction(snippetId, options, ctx);\n });\n\n// favorite — toggle favorite on a snippet\nnotesSnippetCommand\n .command('favorite')\n .description('Toggle favorite status on a snippet')\n .argument('<snippet-id>', 'Snippet ID')\n .action(async (snippetId: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await favoriteSnippetAction(snippetId, ctx);\n });\n","import { getNote, listSnippets } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSnippet, outputSnippets } from '../../lib/output.js';\nimport type { GetNoteResponse, ListSnippetsResponse, CLIContext } from '../../types/index.js';\n\ninterface ShowSnippetOptions {\n all?: boolean;\n}\n\nexport async function showSnippetAction(\n noteId: string,\n options: ShowSnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n if (options.all) {\n // Show all versions\n const result = await listSnippets<ListSnippetsResponse>(\n { note_id: noteId, limit: 100 },\n { pin: ctx.pin }\n );\n\n outputSnippets(result.snippets, ctx);\n } else {\n // Show latest snippet only\n const result = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n\n if (result.latest_snippet) {\n outputSnippet(result.latest_snippet, ctx);\n } else {\n if (!ctx.json) {\n console.error('No snippet content found.');\n }\n process.exit(3);\n }\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import pc from 'picocolors';\nimport { getNote, listSnippets } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { copyToClipboard } from '../../lib/clipboard.js';\nimport { logStatus } from '../../lib/output.js';\nimport type { GetNoteResponse, ListSnippetsResponse, Snippet, CLIContext } from '../../types/index.js';\n\ninterface CopySnippetOptions {\n version?: string;\n}\n\nexport async function copySnippetAction(\n noteId: string,\n options: CopySnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let snippet: Snippet | null = null;\n\n if (options.version) {\n // Get specific version\n const versionNum = parseInt(options.version, 10);\n if (isNaN(versionNum)) {\n throw new CLIError('Invalid version number');\n }\n\n const result = await listSnippets<ListSnippetsResponse>(\n { note_id: noteId, limit: 100 },\n { pin: ctx.pin }\n );\n\n snippet = result.snippets.find((s) => s.version === versionNum) || null;\n\n if (!snippet) {\n throw new CLIError(`Version ${versionNum} not found`);\n }\n } else {\n // Get latest\n const result = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n snippet = result.latest_snippet;\n }\n\n if (!snippet) {\n throw new CLIError('No snippet content found');\n }\n\n try {\n await copyToClipboard(snippet.content);\n logStatus('Copied to clipboard');\n\n // If JSON mode, output the snippet data\n if (ctx.json) {\n console.log(JSON.stringify({ copied: true, content: snippet.content }));\n }\n } catch (clipboardError) {\n // Fallback: print to stdout\n if (!ctx.json) {\n console.error(pc.yellow('Clipboard not available, printing to stdout:'));\n console.error('');\n }\n console.log(snippet.content);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { default as clipboardy } from 'clipboardy';\nimport { CLIError } from './errors.js';\n\nexport async function copyToClipboard(text: string): Promise<void> {\n try {\n await clipboardy.write(text);\n } catch (error) {\n // Fallback: output to stdout with a warning\n if (error instanceof Error && error.message.includes('xsel')) {\n throw new CLIError(\n 'Clipboard not available. Install xsel or xclip on Linux.',\n 1,\n 'Content will be printed to stdout instead.'\n );\n }\n throw new CLIError('Failed to copy to clipboard');\n }\n}\n\nexport async function readFromClipboard(): Promise<string> {\n try {\n return await clipboardy.read();\n } catch {\n throw new CLIError('Failed to read from clipboard');\n }\n}\n","import { createSnippet } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { CreateSnippetResponse, CLIContext } from '../../types/index.js';\n\ninterface AddSnippetOptions {\n title?: string;\n}\n\nexport async function addSnippetAction(\n noteId: string,\n options: AddSnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let content: string;\n\n // Read content from stdin\n if (process.stdin.isTTY) {\n throw new CLIError(\n 'No content provided',\n 1,\n \"Pipe content to this command: echo 'content' | pnote snippet add <note-id>\"\n );\n }\n\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n content = Buffer.concat(chunks).toString('utf-8');\n\n // Trim trailing newline but preserve internal formatting\n if (content.endsWith('\\n')) {\n content = content.slice(0, -1);\n }\n\n if (!content) {\n throw new CLIError('Empty content provided');\n }\n\n const result = await createSnippet<CreateSnippetResponse>(\n {\n note_id: noteId,\n content,\n title: options.title,\n },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(`Created snippet v${result.snippet.version}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { updateSnippet } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { CLIContext } from '../../types/index.js';\n\ninterface UpdateSnippetOptions {\n title?: string;\n}\n\ninterface UpdateSnippetResponse {\n message: string;\n snippet: {\n id: string;\n version: number;\n content: string;\n title: string | null;\n favorite: boolean;\n };\n}\n\nexport async function updateSnippetAction(\n snippetId: string,\n options: UpdateSnippetOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n // Read content from stdin\n let content: string | undefined;\n\n if (!process.stdin.isTTY) {\n const chunks: Buffer[] = [];\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n }\n content = Buffer.concat(chunks).toString('utf-8');\n\n // Trim trailing newline but preserve internal formatting\n if (content.endsWith('\\n')) {\n content = content.slice(0, -1);\n }\n\n if (!content) {\n content = undefined;\n }\n }\n\n // Must provide content or title\n if (!content && !options.title) {\n throw new CLIError(\n 'No content or title provided',\n 1,\n \"Pipe content to this command: echo 'content' | pnote snippet update <snippet-id>\"\n );\n }\n\n const data: { content?: string; title?: string } = {};\n if (content) data.content = content;\n if (options.title) data.title = options.title;\n\n const result = await updateSnippet<UpdateSnippetResponse>(\n snippetId,\n data,\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage('Updated snippet', ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { toggleFavorite } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { ToggleFavoriteResponse, CLIContext } from '../../types/index.js';\n\nexport async function favoriteSnippetAction(\n snippetId: string,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await toggleFavorite<ToggleFavoriteResponse>(snippetId, { pin: ctx.pin });\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const status = result.snippet.favorite ? 'favorited' : 'unfavorited';\n outputMessage(`Snippet ${status}`, ctx);\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { createInterface } from 'node:readline';\nimport { existsSync, readFileSync, writeFileSync, unlinkSync, statSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';\nimport pc from 'picocolors';\n\n// PIN session cache settings\nconst PIN_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes\nconst PIN_MAX_ATTEMPTS = 3;\n\nfunction getPinCachePath(): string {\n const uid = process.getuid?.() ?? 'unknown';\n return join(tmpdir(), `pnote-pin-${uid}`);\n}\n\n// Session cache management\n\nexport function getCachedPin(): string | null {\n const cachePath = getPinCachePath();\n\n if (!existsSync(cachePath)) {\n return null;\n }\n\n try {\n const stat = statSync(cachePath);\n const age = Date.now() - stat.mtimeMs;\n\n if (age > PIN_CACHE_TTL_MS) {\n // Cache expired, remove it\n unlinkSync(cachePath);\n return null;\n }\n\n const content = readFileSync(cachePath, 'utf-8').trim();\n return content || null;\n } catch {\n return null;\n }\n}\n\nexport function setCachedPin(pin: string): void {\n const cachePath = getPinCachePath();\n\n try {\n writeFileSync(cachePath, pin, { mode: 0o600 });\n } catch {\n // Silently fail - cache is optional\n }\n}\n\nexport function clearCachedPin(): boolean {\n const cachePath = getPinCachePath();\n\n if (existsSync(cachePath)) {\n try {\n unlinkSync(cachePath);\n return true;\n } catch {\n return false;\n }\n }\n return false;\n}\n\n// PIN input methods\n\n/**\n * Read PIN from stdin (for --pin-stdin option)\n * Only reads the first line\n */\nexport async function readPinFromStdin(): Promise<string> {\n const chunks: Buffer[] = [];\n\n for await (const chunk of process.stdin) {\n chunks.push(chunk);\n // Only read first line\n const content = Buffer.concat(chunks).toString('utf-8');\n if (content.includes('\\n')) {\n break;\n }\n }\n\n const content = Buffer.concat(chunks).toString('utf-8');\n const firstLine = content.split('\\n')[0]?.trim() || '';\n\n if (!firstLine) {\n throw new Error('No PIN provided via stdin');\n }\n\n return firstLine;\n}\n\n/**\n * Prompt user for PIN interactively\n * Hides input and supports retry\n */\nexport async function promptForPin(\n noteTitle?: string,\n hint?: string,\n maxAttempts: number = PIN_MAX_ATTEMPTS\n): Promise<string | null> {\n if (!process.stdin.isTTY) {\n return null;\n }\n\n // Show context\n if (noteTitle) {\n console.error(pc.yellow('🔒') + ` Note \"${noteTitle}\" is PIN-protected.`);\n } else {\n console.error(pc.yellow('🔒') + ' This action requires your PIN.');\n }\n\n if (hint) {\n console.error(pc.dim(`Hint: ${hint}`));\n }\n\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n const pin = await readPinHidden(\n attempt > 1 ? `Enter PIN (${attempt}/${maxAttempts}): ` : 'Enter PIN: '\n );\n\n if (pin) {\n return pin;\n }\n\n if (attempt < maxAttempts) {\n console.error(pc.red('Invalid or empty PIN. Try again.'));\n }\n }\n\n console.error(pc.red('Too many attempts.'));\n return null;\n}\n\n/**\n * Read a line with hidden input (for PIN entry)\n */\nasync function readPinHidden(prompt: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stderr,\n terminal: true,\n });\n\n // Disable echo\n if (process.stdin.isTTY) {\n process.stdin.setRawMode?.(true);\n }\n\n process.stderr.write(prompt);\n\n let pin = '';\n\n const onKeypress = (key: Buffer) => {\n const char = key.toString();\n\n if (char === '\\r' || char === '\\n') {\n // Enter pressed\n process.stderr.write('\\n');\n cleanup();\n resolve(pin);\n } else if (char === '\\u0003') {\n // Ctrl+C\n process.stderr.write('\\n');\n cleanup();\n process.exit(130);\n } else if (char === '\\u007F' || char === '\\b') {\n // Backspace\n if (pin.length > 0) {\n pin = pin.slice(0, -1);\n // Move cursor back and clear\n process.stderr.write('\\b \\b');\n }\n } else if (char.length === 1 && char >= ' ') {\n // Regular character\n pin += char;\n process.stderr.write('*');\n }\n };\n\n const cleanup = () => {\n process.stdin.removeListener('data', onKeypress);\n if (process.stdin.isTTY) {\n process.stdin.setRawMode?.(false);\n }\n rl.close();\n };\n\n process.stdin.on('data', onKeypress);\n });\n}\n\n/**\n * Get PIN from all sources in priority order\n *\n * Priority:\n * 1. --pin argument (passed in ctx.pin)\n * 2. --pin-stdin (if pinFromStdin is true)\n * 3. PNOTE_PIN environment variable\n * 4. Session cache\n * 5. Interactive prompt (if TTY)\n * 6. null (not available)\n */\nexport async function resolvePin(options: {\n pinArg?: string;\n pinFromStdin?: boolean;\n noteTitle?: string;\n hint?: string;\n skipCache?: boolean;\n skipPrompt?: boolean;\n}): Promise<string | null> {\n const { pinArg, pinFromStdin, noteTitle, hint, skipCache, skipPrompt } = options;\n\n // 1. Command line argument (highest priority)\n if (pinArg) {\n return pinArg;\n }\n\n // 2. stdin\n if (pinFromStdin) {\n try {\n return await readPinFromStdin();\n } catch {\n return null;\n }\n }\n\n // 3. Environment variable\n const envPin = process.env.PNOTE_PIN;\n if (envPin) {\n return envPin;\n }\n\n // 4. Session cache\n if (!skipCache) {\n const cached = getCachedPin();\n if (cached) {\n return cached;\n }\n }\n\n // 5. Interactive prompt\n if (!skipPrompt && process.stdin.isTTY) {\n const pin = await promptForPin(noteTitle, hint);\n if (pin) {\n // Cache for future use\n setCachedPin(pin);\n return pin;\n }\n }\n\n // 6. Not available\n return null;\n}\n\n/**\n * Check if PIN is required but not available\n * Returns error message if PIN is needed but missing\n */\nexport function checkPinRequired(\n isProtected: boolean,\n pin: string | null | undefined\n): string | null {\n if (!isProtected) {\n return null;\n }\n\n if (pin) {\n return null;\n }\n\n if (!process.stdin.isTTY) {\n return 'PIN required but not provided. Use -p <pin> or set PNOTE_PIN environment variable.';\n }\n\n return null;\n}\n","import { Command } from 'commander';\nimport { showSnippetAction } from './show.js';\nimport { copySnippetAction } from './copy.js';\nimport { addSnippetAction } from './add.js';\nimport { updateSnippetAction } from './update.js';\nimport { favoriteSnippetAction } from './favorite.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nconst DEPRECATION_NOTICE = '\\nDeprecated: \"pnote snippet\" is deprecated. Use \"pnote notes snippet\" instead.\\n\\n';\n\nexport const snippetCommand = new Command('snippet')\n .description('Read and manage snippets (note versions) [deprecated: use \"notes snippet\"]')\n .argument('[note-id]', 'Note ID to show snippet for')\n .option('--all', 'Show all snippet versions')\n .hook('preAction', () => {\n process.stderr.write(DEPRECATION_NOTICE);\n })\n .action(async (noteId: string | undefined, options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n if (noteId) {\n await showSnippetAction(noteId, options, ctx);\n } else {\n cmd.help();\n }\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote snippet abc123 Show latest snippet\n $ pnote snippet abc123 --all Show all versions\n $ pnote snippet copy abc123 Copy to clipboard\n $ cat file.txt | pnote snippet add abc123\n`\n );\n\nsnippetCommand\n .command('copy')\n .description('Copy snippet content to clipboard')\n .argument('<note-id>', 'Note ID')\n .option('--version <n>', 'Specific version number')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await copySnippetAction(noteId, options, ctx);\n });\n\nsnippetCommand\n .command('add')\n .description('Add a new snippet version (from stdin)')\n .argument('<note-id>', 'Note ID')\n .option('--title <title>', 'Snippet title')\n .action(async (noteId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await addSnippetAction(noteId, options, ctx);\n });\n\nsnippetCommand\n .command('update')\n .description('Update an existing snippet (from stdin)')\n .argument('<snippet-id>', 'Snippet ID')\n .option('--title <title>', 'New snippet title')\n .action(async (snippetId: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await updateSnippetAction(snippetId, options, ctx);\n });\n\nsnippetCommand\n .command('favorite')\n .description('Toggle favorite status on a snippet')\n .argument('<snippet-id>', 'Snippet ID')\n .action(async (snippetId: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await favoriteSnippetAction(snippetId, ctx);\n });\n","import { Command } from 'commander';\nimport { listTagsAction } from './list.js';\nimport { renameTagAction } from './rename.js';\nimport { mergeTagsAction } from './merge.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const tagsCommand = new Command('tags')\n .description('List and manage tags')\n .option('--include-archived', 'Include tags from archived notes')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listTagsAction(options, ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote tags List all tags\n $ pnote tags rename \"old\" \"new\" Rename a tag\n $ pnote tags merge \"tag1\" \"tag2\" --into \"target\"\n`\n );\n\ntagsCommand\n .command('rename')\n .description('Rename a tag across all notes')\n .argument('<old-tag>', 'Current tag name')\n .argument('<new-tag>', 'New tag name')\n .action(async (oldTag: string, newTag: string, _options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await renameTagAction(oldTag, newTag, ctx);\n });\n\ntagsCommand\n .command('merge')\n .description('Merge multiple tags into one')\n .argument('<source-tags...>', 'Tags to merge (space-separated)')\n .requiredOption('--into <target>', 'Target tag to merge into')\n .action(async (sourceTags: string[], options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await mergeTagsAction(sourceTags, options.into, ctx);\n });\n","import { listTags } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputTags } from '../../lib/output.js';\nimport type { ListTagsResponse, CLIContext } from '../../types/index.js';\n\ninterface ListTagsOptions {\n includeArchived?: boolean;\n}\n\nexport async function listTagsAction(\n options: ListTagsOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await listTags<ListTagsResponse>(\n { include_archived: options.includeArchived ?? false },\n { pin: ctx.pin }\n );\n\n outputTags(result.tags, result.hierarchy, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { renameTag } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { RenameTagResponse, CLIContext } from '../../types/index.js';\n\nexport async function renameTagAction(\n oldTag: string,\n newTag: string,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await renameTag<RenameTagResponse>(\n { old_tag: oldTag, new_tag: newTag },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n outputMessage(\n `Renamed \"${oldTag}\" to \"${newTag}\" (${result.notes_updated} notes updated)`,\n ctx\n );\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { mergeTags } from '../../lib/api.js';\nimport { handleError, CLIError } from '../../lib/errors.js';\nimport { outputMessage, outputJson } from '../../lib/output.js';\nimport type { MergeTagsResponse, CLIContext } from '../../types/index.js';\n\nexport async function mergeTagsAction(\n sourceTags: string[],\n targetTag: string,\n ctx: CLIContext\n): Promise<void> {\n try {\n // Validate that source doesn't include target\n if (sourceTags.includes(targetTag)) {\n throw new CLIError('Source tags cannot include the target tag');\n }\n\n if (sourceTags.length === 0) {\n throw new CLIError('At least one source tag is required');\n }\n\n const result = await mergeTags<MergeTagsResponse>(\n { source_tags: sourceTags, target_tag: targetTag },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n } else {\n const sourceList = sourceTags.map((t) => `\"${t}\"`).join(', ');\n outputMessage(\n `Merged ${sourceList} into \"${targetTag}\" (${result.notes_updated} notes updated)`,\n ctx\n );\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { Command } from 'commander';\nimport { search } from '../lib/api.js';\nimport { handleError } from '../lib/errors.js';\nimport { outputSearchResults } from '../lib/output.js';\nimport { resolvePin } from '../lib/pin.js';\nimport type { SearchResponse, CLIContext } from '../types/index.js';\n\ninterface SearchOptions {\n notesOnly?: boolean;\n snippetsOnly?: boolean;\n limit?: string;\n}\n\nasync function searchAction(\n query: string,\n options: SearchOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n let search_notes = true;\n let search_snippets = true;\n\n if (options.notesOnly) {\n search_notes = true;\n search_snippets = false;\n } else if (options.snippetsOnly) {\n search_notes = false;\n search_snippets = true;\n }\n\n const result = await search<SearchResponse>(\n {\n query,\n search_notes,\n search_snippets,\n limit: options.limit ? parseInt(options.limit, 10) : 20,\n },\n { pin: ctx.pin }\n );\n\n outputSearchResults(query, result.notes, result.snippets, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n\nexport const searchCommand = new Command('search')\n .description('Search notes and snippets')\n .argument('<query>', 'Search query')\n .option('--notes-only', 'Only search note titles and tags')\n .option('--snippets-only', 'Only search snippet content')\n .option('--limit <n>', 'Limit results', '20')\n .action(async (query: string, options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n const ctx: CLIContext = {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n await searchAction(query, options, ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote search \"portrait\" Search all\n $ pnote search \"AI\" --notes-only Search note titles only\n $ pnote search \"code\" --limit 50 Limit results\n`\n );\n","import { Command } from 'commander';\nimport { listSharedTagsAction, getSharedTagNotesAction } from './tags.js';\nimport { listSharedNotesAction } from './notes.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const shareCommand = new Command('share')\n .description('View shared tags and shared note links')\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote share tags List shared tags\n $ pnote share tags abc123 View notes in shared tag\n $ pnote share notes List public share links\n $ pnote share notes --include-revoked\n`\n );\n\n// pnote share tags [id]\nshareCommand\n .command('tags')\n .description('List shared tags or view notes in a shared tag')\n .argument('[id]', 'Shared tag ID to view notes')\n .option('--limit <n>', 'Limit notes returned')\n .action(async (id: string | undefined, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n\n if (id) {\n await getSharedTagNotesAction(id, options, ctx);\n } else {\n await listSharedTagsAction(ctx);\n }\n });\n\n// pnote share notes\nshareCommand\n .command('notes')\n .description('List public share links for your notes')\n .option('--include-revoked', 'Include revoked share links')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listSharedNotesAction(options, ctx);\n });\n","import { listSharedTags, getSharedTagNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSharedTags, outputSharedTagNotes } from '../../lib/output.js';\nimport type {\n ListSharedTagsResponse,\n GetSharedTagNotesResponse,\n CLIContext,\n} from '../../types/index.js';\n\ninterface SharedTagNotesOptions {\n limit?: string;\n}\n\nexport async function listSharedTagsAction(ctx: CLIContext): Promise<void> {\n try {\n const result = await listSharedTags<ListSharedTagsResponse>({ pin: ctx.pin });\n outputSharedTags(result, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n\nexport async function getSharedTagNotesAction(\n id: string,\n options: SharedTagNotesOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await getSharedTagNotes<GetSharedTagNotesResponse>(\n id,\n { limit: options.limit ? parseInt(options.limit, 10) : undefined },\n { pin: ctx.pin }\n );\n outputSharedTagNotes(result, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { listSharedNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputSharedNotes } from '../../lib/output.js';\nimport type { ListSharedNotesResponse, CLIContext } from '../../types/index.js';\n\ninterface SharedNotesOptions {\n includeRevoked?: boolean;\n}\n\nexport async function listSharedNotesAction(\n options: SharedNotesOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const result = await listSharedNotes<ListSharedNotesResponse>(\n { include_revoked: options.includeRevoked },\n { pin: ctx.pin }\n );\n outputSharedNotes(result, ctx);\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { Command } from 'commander';\nimport { listSkillsAction } from './list.js';\nimport { pullSkillsAction } from './pull.js';\nimport { pushSkillsAction } from './push.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\n// Helper to build CLI context with PIN support\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const skillsCommand = new Command('skills')\n .description('Manage agent skills (sync between cloud and local)')\n .action(async (_options, cmd) => {\n const globalOpts = cmd.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await listSkillsAction(ctx);\n })\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote skills List all skills in cloud\n $ pnote skills pull Pull all skills globally (~/.agents/skills/ + symlinks)\n $ pnote skills pull myskill Pull a specific skill globally\n $ pnote skills pull --project Pull project-level (.agents/skills/ + .claude/skills/ etc.)\n $ pnote skills pull --dry-run Preview without writing files\n $ pnote skills push ./my-skill Upload a local skill directory\n\nSkills are stored as notes with type \"skill\" and title \"skill-name/filename.md\".\nPull writes to the canonical .agents/skills/ store and symlinks into each installed\nagent's directory (.claude/skills/, .windsurf/skills/, .augment/skills/, etc.),\nmatching the layout used by npx skills for seamless coexistence.\n`\n );\n\nskillsCommand\n .command('pull')\n .description('Download skills from cloud to local (global by default)')\n .argument('[skill-name]', 'Specific skill to pull (pulls all if omitted)')\n .option('--project', 'Install project-level (./agents/skills/ + .claude/skills/ etc.)')\n .option('--dir <path>', 'Custom output directory — direct write, no symlinks')\n .option('--dry-run', 'Show what would be downloaded without writing files')\n .action(async (skillName: string | undefined, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pullSkillsAction(skillName, options, ctx);\n });\n\nskillsCommand\n .command('push')\n .description('Upload a local skill directory to cloud')\n .argument('<dir>', 'Path to skill directory (must contain SKILL.md)')\n .option('--name <name>', 'Override skill name (default: directory name)')\n .action(async (dir: string, options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pushSkillsAction(dir, options, ctx);\n });\n","import { listNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson, logStatus } from '../../lib/output.js';\nimport type { ListNotesResponse, CLIContext } from '../../types/index.js';\nimport pc from 'picocolors';\n\n/**\n * List all skill notes from cloud, grouped by skill name.\n */\nexport async function listSkillsAction(ctx: CLIContext): Promise<void> {\n try {\n const result = await listNotes<ListNotesResponse>(\n { note_type: 'skill', limit: 200 },\n { pin: ctx.pin }\n );\n\n const skills = result.notes;\n\n if (ctx.json) {\n // Group by skill name for JSON output\n const grouped: Record<string, typeof skills> = {};\n for (const note of skills) {\n const slashIdx = note.title.indexOf('/');\n const skillName = slashIdx > 0 ? note.title.slice(0, slashIdx) : note.title;\n if (!grouped[skillName]) grouped[skillName] = [];\n grouped[skillName].push(note);\n }\n outputJson(grouped);\n return;\n }\n\n if (skills.length === 0) {\n console.log(pc.dim('No skills found. Create one with:'));\n console.log(pc.dim(' pnote skills push ./my-skill'));\n return;\n }\n\n // Group skills by name prefix (before first /)\n const grouped = new Map<string, typeof skills>();\n for (const note of skills) {\n const slashIdx = note.title.indexOf('/');\n const skillName = slashIdx > 0 ? note.title.slice(0, slashIdx) : note.title;\n if (!grouped.has(skillName)) grouped.set(skillName, []);\n grouped.get(skillName)!.push(note);\n }\n\n console.log(pc.bold(`Skills (${grouped.size})`));\n console.log('');\n\n for (const [name, files] of grouped) {\n const fileNames = files.map(f => {\n const slashIdx = f.title.indexOf('/');\n return slashIdx > 0 ? f.title.slice(slashIdx + 1) : f.title;\n });\n console.log(\n ' ' + pc.cyan(name) +\n pc.dim(` (${files.length} file${files.length !== 1 ? 's' : ''})`) +\n ' ' + pc.dim(fileNames.join(', '))\n );\n }\n\n console.log('');\n console.log(pc.dim('Pull to local: pnote skills pull'));\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as os from 'node:os';\nimport { listNotes, getNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport type { ListNotesResponse, GetNoteResponse, CLIContext } from '../../types/index.js';\nimport pc from 'picocolors';\n\nexport interface PullOptions {\n dir?: string;\n project?: boolean;\n dryRun?: boolean;\n}\n\ntype InstallMode = 'custom' | 'global' | 'project';\n\ntype Colors = {\n green: (s: string) => string;\n dim: (s: string) => string;\n yellow: (s: string) => string;\n bold: (s: string) => string;\n red: (s: string) => string;\n};\n\n// Canonical store: <root>/.agents/skills/<name>/ (mirrors npx skills layout)\nconst AGENTS_STORE = '.agents/skills';\n\n// Agent dirs that receive symlinks → canonical store.\n// .claude is first and always created (most widely used).\n// Others are created only if the agent is installed (~/.<dir>/ exists).\nconst AGENT_SYMLINK_DIRS = [\n '.claude/skills',\n '.windsurf/skills',\n '.augment/skills',\n '.agent/skills',\n] as const;\n\nfunction makeColors(useColor: boolean): Colors {\n if (useColor) {\n return {\n green: pc.green,\n dim: pc.dim,\n yellow: pc.yellow,\n bold: pc.bold,\n red: pc.red,\n };\n }\n return {\n green: (s: string) => s,\n dim: (s: string) => s,\n yellow: (s: string) => s,\n bold: (s: string) => s,\n red: (s: string) => s,\n };\n}\n\nfunction resolveMode(options: PullOptions): { mode: InstallMode; root: string } {\n if (options.dir) return { mode: 'custom', root: path.resolve(options.dir) };\n if (options.project) return { mode: 'project', root: process.cwd() };\n return { mode: 'global', root: os.homedir() };\n}\n\n/**\n * Create a symlink at linkPath pointing to ../../.agents/skills/<skillName> (relative).\n * Handles all existing-path cases: correct symlink (skip), wrong symlink, real dir, real file.\n * Real directories from old `pnote skills pull` are migrated automatically.\n */\nfunction ensureSymlink(\n linkPath: string,\n skillName: string,\n dryRun: boolean,\n c: Colors,\n log: (msg: string) => void\n): void {\n // Relative target: from <root>/.<agent>/skills/<name> → <root>/.agents/skills/<name>\n const relTarget = path.join('..', '..', AGENTS_STORE, skillName);\n\n if (dryRun) {\n log(` ${c.dim('would link')} ${linkPath} → ${relTarget}`);\n return;\n }\n\n // Ensure parent directory exists\n fs.mkdirSync(path.dirname(linkPath), { recursive: true });\n\n // Inspect existing path without following symlinks (lstat handles broken symlinks)\n let existingStat: fs.Stats | null = null;\n try {\n existingStat = fs.lstatSync(linkPath);\n } catch {\n // Path does not exist at all — proceed to create symlink\n }\n\n if (existingStat) {\n if (existingStat.isSymbolicLink()) {\n // Already a symlink — skip if correct, replace if wrong\n if (fs.readlinkSync(linkPath) === relTarget) return;\n fs.unlinkSync(linkPath);\n } else if (existingStat.isDirectory()) {\n // Real directory from old pnote skills pull — migrate to symlink.\n // Content is safe to remove: we're replacing with cloud-fetched content.\n fs.rmSync(linkPath, { recursive: true });\n log(` ${c.yellow('↗')} migrated ${c.dim(linkPath)} (replaced directory with symlink)`);\n } else {\n // Regular file — remove and replace\n fs.unlinkSync(linkPath);\n }\n }\n\n fs.symlinkSync(relTarget, linkPath);\n log(` ${c.dim('⇢')} ${linkPath}`);\n}\n\n/**\n * Write skill files to canonical agents store and create agent symlinks.\n * Custom --dir mode writes directly to <root>/<name>/ with no symlinks.\n */\nfunction installSkill(\n root: string,\n mode: InstallMode,\n skillName: string,\n files: Array<{ fileName: string; content: string }>,\n dryRun: boolean,\n c: Colors,\n log: (msg: string) => void\n): string[] {\n const home = os.homedir();\n\n if (mode === 'custom') {\n // Direct write to <root>/<skillName>/ — no symlinks (backward compat for --dir)\n for (const { fileName, content } of files) {\n const destPath = path.join(root, skillName, fileName);\n if (dryRun) {\n log(` ${c.dim('would write')} ${destPath}`);\n } else {\n fs.mkdirSync(path.dirname(destPath), { recursive: true });\n fs.writeFileSync(destPath, content, 'utf-8');\n log(` ${c.green('✓')} ${destPath}`);\n }\n }\n return [];\n }\n\n // Write actual files to canonical agents store: <root>/.agents/skills/<name>/\n for (const { fileName, content } of files) {\n const destPath = path.join(root, AGENTS_STORE, skillName, fileName);\n if (dryRun) {\n log(` ${c.dim('would write')} ${destPath}`);\n } else {\n fs.mkdirSync(path.dirname(destPath), { recursive: true });\n fs.writeFileSync(destPath, content, 'utf-8');\n log(` ${c.green('✓')} ${destPath}`);\n }\n }\n\n // Create symlinks in each agent dir\n const linkedAgents: string[] = [];\n for (const agentSkillsDir of AGENT_SYMLINK_DIRS) {\n const agentRootDir = agentSkillsDir.split('/')[0]; // e.g. '.claude'\n const isClaude = agentRootDir === '.claude';\n\n // .claude always gets a symlink.\n // Other agents: only if the agent is installed (its home dir exists).\n if (!isClaude && !fs.existsSync(path.join(home, agentRootDir))) continue;\n\n const linkPath = path.join(root, agentSkillsDir, skillName);\n ensureSymlink(linkPath, skillName, dryRun, c, log);\n linkedAgents.push(agentRootDir);\n }\n\n return linkedAgents;\n}\n\n/**\n * Pull skills from cloud → local filesystem.\n *\n * Modes:\n * default (global) → writes to ~/.agents/skills/<name>/ + symlinks in ~/.claude/skills/ etc.\n * --project → writes to .agents/skills/<name>/ + symlinks in .claude/skills/ etc. (cwd)\n * --dir <path> → writes directly to <path>/<name>/ (no symlinks, backward compat)\n *\n * The layout mirrors npx skills exactly, so the two tools coexist without conflict.\n * Skills pulled here appear alongside registry skills in ~/.agents/skills/ and are\n * accessible from Claude Code, Windsurf, Augment, and any other installed agents.\n */\nexport async function pullSkillsAction(\n skillName: string | undefined,\n options: PullOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const { mode, root } = resolveMode(options);\n const useColor = !ctx.noColor && process.stdout.isTTY;\n const c = makeColors(useColor);\n const log = ctx.json ? (_msg: string) => {} : (msg: string) => console.log(msg);\n\n // Fetch all skill notes from cloud\n const result = await listNotes<ListNotesResponse>(\n { note_type: 'skill', limit: 200 },\n { pin: ctx.pin }\n );\n\n let skills = result.notes;\n\n // Filter by skill name if specified\n if (skillName) {\n skills = skills.filter(n => n.title.split('/')[0] === skillName);\n if (skills.length === 0) {\n console.error(pc.red(`No skill found with name \"${skillName}\"`));\n process.exit(1);\n }\n }\n\n if (skills.length === 0) {\n if (!ctx.json) console.log(c.dim('No skills to pull.'));\n if (ctx.json) outputJson({ pulled: 0, skipped: 0, mode, root, skills: {} });\n return;\n }\n\n // Group notes by skill name (prefix before first /)\n const grouped = new Map<string, Array<{ fileName: string; noteId: string }>>();\n for (const note of skills) {\n const slashIdx = note.title.indexOf('/');\n if (slashIdx <= 0) {\n if (!ctx.json) console.error(`Skipping \"${note.title}\" (invalid title format, expected \"name/file\")`);\n continue;\n }\n const sName = note.title.slice(0, slashIdx);\n const fileName = note.title.slice(slashIdx + 1);\n if (!grouped.has(sName)) grouped.set(sName, []);\n grouped.get(sName)!.push({ fileName, noteId: note.id });\n }\n\n let totalPulled = 0;\n let totalSkipped = 0;\n const jsonResults: Record<string, { files: string[]; agents: string[] }> = {};\n\n for (const [sName, fileEntries] of grouped) {\n log(`\\n${c.bold(sName)}`);\n\n // Fetch content for each file\n const files: Array<{ fileName: string; content: string }> = [];\n for (const { fileName, noteId } of fileEntries) {\n const noteData = await getNote<GetNoteResponse>(noteId, { pin: ctx.pin });\n const content = noteData.latest_snippet?.content;\n if (!content) {\n if (!ctx.json) console.error(` Skipping \"${sName}/${fileName}\" (no snippet content)`);\n totalSkipped++;\n continue;\n }\n files.push({ fileName, content });\n }\n\n if (files.length === 0) continue;\n\n const linkedAgents = installSkill(root, mode, sName, files, options.dryRun ?? false, c, log);\n totalPulled += files.length;\n\n jsonResults[sName] = {\n files: files.map(f => f.fileName),\n agents: linkedAgents,\n };\n }\n\n if (!ctx.json) {\n console.log('');\n if (options.dryRun) {\n console.log(c.dim(`Dry run: ${totalPulled} file(s) would be pulled, ${totalSkipped} skipped`));\n } else {\n const scopeLabel =\n mode === 'custom' ? root :\n mode === 'project' ? 'project (.agents/skills/)' :\n 'global (~/.agents/skills/)';\n console.log(\n `Pulled ${totalPulled} file(s) — ${scopeLabel}` +\n (totalSkipped > 0 ? `, ${totalSkipped} skipped` : '')\n );\n }\n }\n\n if (ctx.json) {\n outputJson({ pulled: totalPulled, skipped: totalSkipped, mode, root, skills: jsonResults });\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { listNotes, createNote, createSnippet, getNote } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport type { ListNotesResponse, CreateNoteResponse, CreateSnippetResponse, GetNoteResponse, CLIContext } from '../../types/index.js';\nimport pc from 'picocolors';\n\ninterface PushOptions {\n name?: string;\n}\n\n/**\n * Push a local skill directory → cloud.\n * Each file becomes a note with title \"skill-name/filename\" and note_type='skill'.\n * Content is stored as the latest snippet.\n */\nexport async function pushSkillsAction(\n dir: string,\n options: PushOptions,\n ctx: CLIContext\n): Promise<void> {\n try {\n const resolvedDir = path.resolve(dir);\n\n // Validate directory exists\n if (!fs.existsSync(resolvedDir) || !fs.statSync(resolvedDir).isDirectory()) {\n console.error(pc.red(`Not a directory: ${resolvedDir}`));\n process.exit(1);\n }\n\n // Check for SKILL.md\n const skillMdPath = path.join(resolvedDir, 'SKILL.md');\n if (!fs.existsSync(skillMdPath)) {\n console.error(pc.red(`No SKILL.md found in ${resolvedDir}`));\n console.error(pc.dim('A valid skill directory must contain a SKILL.md file.'));\n process.exit(1);\n }\n\n // Determine skill name\n const skillName = options.name || path.basename(resolvedDir);\n\n // Collect all files (non-recursive for now, matching typical skill structure)\n const files = collectFiles(resolvedDir, resolvedDir);\n\n if (files.length === 0) {\n console.log(pc.dim('No files to push.'));\n return;\n }\n\n // Fetch existing skill notes to check for updates\n const existing = await listNotes<ListNotesResponse>(\n { note_type: 'skill', limit: 200 },\n { pin: ctx.pin }\n );\n\n const existingMap = new Map<string, string>(); // title → note_id\n for (const note of existing.notes) {\n existingMap.set(note.title, note.id);\n }\n\n let created = 0;\n let updated = 0;\n\n for (const relPath of files) {\n const noteTitle = `${skillName}/${relPath}`;\n const filePath = path.join(resolvedDir, relPath);\n const content = fs.readFileSync(filePath, 'utf-8');\n\n const existingId = existingMap.get(noteTitle);\n\n if (existingId) {\n // Update existing: add new snippet version\n await createSnippet<CreateSnippetResponse>(\n { note_id: existingId, content },\n { pin: ctx.pin }\n );\n console.log(`${pc.yellow('↻')} ${noteTitle} ${pc.dim('(new version)')}`);\n updated++;\n } else {\n // Create new note with content\n await createNote<CreateNoteResponse>(\n { title: noteTitle, content, note_type: 'skill' },\n { pin: ctx.pin }\n );\n console.log(`${pc.green('+')} ${noteTitle}`);\n created++;\n }\n }\n\n console.log('');\n console.log(\n `Pushed ${pc.bold(skillName)}: ` +\n (created > 0 ? `${created} created` : '') +\n (created > 0 && updated > 0 ? ', ' : '') +\n (updated > 0 ? `${updated} updated` : '')\n );\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n\n/**\n * Collect files recursively from a directory, returning relative paths.\n * Skips hidden files/dirs and common non-skill files.\n */\nfunction collectFiles(baseDir: string, currentDir: string): string[] {\n const files: string[] = [];\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n // Skip hidden files and common non-skill entries\n if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;\n\n const fullPath = path.join(currentDir, entry.name);\n const relPath = path.relative(baseDir, fullPath);\n\n if (entry.isFile()) {\n files.push(relPath);\n } else if (entry.isDirectory()) {\n files.push(...collectFiles(baseDir, fullPath));\n }\n }\n\n return files;\n}\n","import { Command } from 'commander';\nimport { pinStatusAction } from './statusAction.js';\nimport { pinListAction } from './listAction.js';\nimport type { CLIContext } from '../../types/index.js';\nimport { resolvePin } from '../../lib/pin.js';\n\nasync function buildContext(globalOpts: Record<string, unknown>): Promise<CLIContext> {\n const pin = await resolvePin({\n pinArg: globalOpts.pin as string | undefined,\n pinFromStdin: globalOpts.pinStdin as boolean | undefined,\n skipPrompt: true,\n });\n\n return {\n json: (globalOpts.json as boolean) ?? false,\n noColor: (globalOpts.noColor as boolean) ?? false,\n plain: (globalOpts.plain as boolean) ?? false,\n pin: pin ?? undefined,\n };\n}\n\nexport const pinCommand = new Command('pin')\n .description('Manage PIN protection for notes')\n .addHelpText(\n 'after',\n `\nExamples:\n $ pnote pin status Check PIN configuration and access\n $ pnote pin list List all protected notes (metadata only)\n $ PNOTE_PIN=1234 pnote pin status Check with PIN provided via env\n`\n );\n\npinCommand\n .command('status')\n .description('Check PIN configuration status and access to protected notes')\n .action(async (_options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pinStatusAction(ctx);\n });\n\npinCommand\n .command('list')\n .description('List all PIN-protected notes (metadata only, no content)')\n .option('--limit <n>', 'Maximum number of results', '50')\n .option('--offset <n>', 'Skip N results (for pagination)')\n .action(async (options, cmd) => {\n const globalOpts = cmd.parent?.parent?.opts() || {};\n const ctx = await buildContext(globalOpts);\n await pinListAction(options, ctx);\n });\n","import pc from 'picocolors';\nimport { checkPinStatus } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport { getCachedPin } from '../../lib/pin.js';\nimport type { PinStatusResponse, CLIContext } from '../../types/index.js';\n\nexport async function pinStatusAction(ctx: CLIContext): Promise<void> {\n try {\n const result = await checkPinStatus<PinStatusResponse>({ pin: ctx.pin });\n\n if (ctx.json) {\n outputJson({\n ...result,\n pnote_pin_env_set: !!process.env.PNOTE_PIN,\n pin_cached: !!getCachedPin(),\n });\n return;\n }\n\n const useColor = !ctx.noColor && process.stdout.isTTY;\n const c = {\n green: useColor ? pc.green : (s: string) => s,\n red: useColor ? pc.red : (s: string) => s,\n yellow: useColor ? pc.yellow : (s: string) => s,\n dim: useColor ? pc.dim : (s: string) => s,\n bold: useColor ? pc.bold : (s: string) => s,\n magenta: useColor ? pc.magenta : (s: string) => s,\n };\n\n const yes = c.green('✓');\n const no = c.red('✗');\n\n console.log(c.bold('PIN Status'));\n console.log('');\n\n // Account PIN setup\n const hasPin = result.user_has_pin_setup;\n console.log(` Account PIN set: ${hasPin ? yes : no}`);\n if (result.pin_hint) {\n console.log(` PIN hint: ${c.dim(result.pin_hint)}`);\n }\n console.log(` Protected notes: ${c.magenta(String(result.protected_notes_count))}`);\n\n console.log('');\n console.log(c.bold('PIN Sources (CLI)'));\n console.log('');\n\n // PNOTE_PIN env var\n const envSet = !!process.env.PNOTE_PIN;\n console.log(` PNOTE_PIN env: ${envSet ? yes : no}${envSet ? c.dim(' (recommended)') : ''}`);\n\n // Session cache\n const cached = !!getCachedPin();\n console.log(` Session cache: ${cached ? yes + c.dim(' (active, <5min)') : no}`);\n\n // Provided PIN validity\n if (result.pin_provided) {\n const valid = result.pin_valid;\n console.log(` Provided PIN valid: ${valid ? yes : no}`);\n } else {\n console.log(` Provided PIN: ${c.dim('not provided')}`);\n }\n\n console.log('');\n const canAccess = result.can_access_protected;\n if (canAccess) {\n console.log(yes + ' ' + c.green('Can access protected notes'));\n } else if (!hasPin) {\n console.log(c.dim(' No protected notes — PIN not configured on account'));\n } else {\n console.log(no + ' ' + c.red('Cannot access protected notes'));\n console.log('');\n console.log(c.dim(' Set PIN via: export PNOTE_PIN=<pin>'));\n console.log(c.dim(' Or use: pnote notes get <id> -p <pin>'));\n console.log(c.dim(' Or use: echo <pin> | pnote notes get <id> --pin-stdin'));\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import pc from 'picocolors';\nimport { listProtectedNotes } from '../../lib/api.js';\nimport { handleError } from '../../lib/errors.js';\nimport { outputJson } from '../../lib/output.js';\nimport type { ListProtectedNotesResponse, CLIContext } from '../../types/index.js';\n\ninterface ListPinOptions {\n limit?: string;\n offset?: string;\n}\n\nexport async function pinListAction(options: ListPinOptions, ctx: CLIContext): Promise<void> {\n try {\n const result = await listProtectedNotes<ListProtectedNotesResponse>(\n {\n limit: options.limit ? parseInt(options.limit, 10) : 50,\n offset: options.offset ? parseInt(options.offset, 10) : undefined,\n },\n { pin: ctx.pin }\n );\n\n if (ctx.json) {\n outputJson(result);\n return;\n }\n\n const useColor = !ctx.noColor && process.stdout.isTTY;\n const c = {\n dim: useColor ? pc.dim : (s: string) => s,\n bold: useColor ? pc.bold : (s: string) => s,\n cyan: useColor ? pc.cyan : (s: string) => s,\n yellow: useColor ? pc.yellow : (s: string) => s,\n magenta: useColor ? pc.magenta : (s: string) => s,\n };\n\n const isHuman = !ctx.json && !ctx.plain && process.stdout.isTTY;\n\n if (result.notes.length === 0) {\n console.log(c.dim('No protected notes.'));\n return;\n }\n\n if (isHuman) {\n console.log(c.bold(`Protected Notes (${result.count})`));\n if (result.hint) {\n console.log(c.dim(`PIN hint: ${result.hint}`));\n }\n if (!result.can_decrypt) {\n console.log(c.dim('Note: Content not shown — set PNOTE_PIN to access content.'));\n }\n console.log('');\n\n const pad = (s: string, w: number) => s.length >= w ? s.slice(0, w) : s + ' '.repeat(w - s.length);\n const truncate = (s: string, w: number) => s.length <= w ? s : s.slice(0, w - 1) + '…';\n\n console.log(\n ' ' + c.dim(pad('ID', 10)) +\n ' ' + c.dim(pad('TITLE', 30)) +\n ' ' + c.dim(pad('TAGS', 20)) +\n ' ' + c.dim('PROTECTED')\n );\n\n for (const note of result.notes) {\n const date = new Date(note.protected_at);\n const updated = date.toLocaleDateString();\n const pinned = note.pinned ? c.yellow('* ') : ' ';\n console.log(\n pinned +\n pad(note.id.slice(0, 8), 10) +\n ' ' + pad(truncate(note.title, 30), 30) +\n ' ' + pad(truncate(note.tags.join(', ') || '-', 20), 20) +\n ' ' + c.magenta(updated)\n );\n }\n } else {\n // Plain output\n for (const note of result.notes) {\n console.log([note.id, note.title, note.tags.join(','), note.protected_at].join('\\t'));\n }\n }\n } catch (error) {\n handleError(error, ctx.noColor);\n }\n}\n","import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';\nimport { join } from 'node:path';\nimport pc from 'picocolors';\nimport { getConfigDir } from './config.js';\n\nconst CACHE_FILE = 'update-check.json';\nconst CHECK_INTERVAL = 60 * 60 * 1000; // 1 hour\nconst FETCH_TIMEOUT = 2000; // 2 seconds\n\ninterface UpdateCache {\n lastCheck: number;\n latestVersion: string;\n}\n\nfunction getCachePath(): string {\n return join(getConfigDir(), CACHE_FILE);\n}\n\nfunction readCache(): UpdateCache | null {\n try {\n const path = getCachePath();\n if (!existsSync(path)) return null;\n return JSON.parse(readFileSync(path, 'utf-8')) as UpdateCache;\n } catch {\n return null;\n }\n}\n\nfunction writeCache(cache: UpdateCache): void {\n try {\n const dir = getConfigDir();\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true, mode: 0o700 });\n }\n writeFileSync(getCachePath(), JSON.stringify(cache), 'utf-8');\n } catch {\n // Silent — cache write failure is non-critical\n }\n}\n\nasync function fetchLatestVersion(packageName: string): Promise<string | null> {\n try {\n const res = await fetch(\n `https://registry.npmjs.org/${packageName}/latest`,\n { signal: AbortSignal.timeout(FETCH_TIMEOUT) }\n );\n if (!res.ok) return null;\n const data = (await res.json()) as { version?: string };\n return data.version ?? null;\n } catch {\n return null;\n }\n}\n\n/** Compare two semver strings (a.b.c). Returns true if current < latest. */\nfunction isOlderVersion(current: string, latest: string): boolean {\n const parse = (v: string) => v.split('.').map(Number);\n const [cMaj, cMin, cPat] = parse(current);\n const [lMaj, lMin, lPat] = parse(latest);\n if (cMaj !== lMaj) return cMaj < lMaj;\n if (cMin !== lMin) return cMin < lMin;\n return cPat < lPat;\n}\n\nfunction printNotice(current: string, latest: string, packageName: string): void {\n const useColor = process.stderr.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb';\n const yellow = useColor ? pc.yellow : (s: string) => s;\n const bold = useColor ? pc.bold : (s: string) => s;\n const dim = useColor ? pc.dim : (s: string) => s;\n\n const msg = `Update available: ${dim(current)} → ${bold(latest)}`;\n const cmd = `Run ${bold(`npm i -g ${packageName}`)} to update`;\n const lines = [msg, cmd];\n\n // Measure widest line (strip ANSI for length)\n const strip = (s: string) => s.replace(/\\x1b\\[[0-9;]*m/g, '');\n const maxLen = Math.max(...lines.map((l) => strip(l).length));\n const pad = (s: string) => s + ' '.repeat(maxLen - strip(s).length);\n\n const top = yellow('┌' + '─'.repeat(maxLen + 2) + '┐');\n const bot = yellow('└' + '─'.repeat(maxLen + 2) + '┘');\n const row = (s: string) => yellow('│') + ' ' + pad(s) + ' ' + yellow('│');\n\n const box = [\n '',\n top,\n row(lines[0]),\n row(lines[1]),\n bot,\n '',\n ].join('\\n');\n\n process.stderr.write(box);\n}\n\n/**\n * Returns a styled version line for use in addHelpText('before').\n * Shows update hint inline if a newer version is cached.\n * Always instant — reads from cache file synchronously (no network).\n */\nexport function getVersionHelpLine(currentVersion: string, cliName: string): string {\n const useColor = process.stderr.isTTY && !process.env.NO_COLOR && process.env.TERM !== 'dumb';\n const dim = useColor ? pc.dim : (s: string) => s;\n const yellow = useColor ? pc.yellow : (s: string) => s;\n const bold = useColor ? pc.bold : (s: string) => s;\n\n let newer: string | null = null;\n try {\n const cache = readCache();\n if (cache && isOlderVersion(currentVersion, cache.latestVersion)) {\n newer = cache.latestVersion;\n }\n } catch { /* silent */ }\n\n if (newer) {\n return `\\n ${dim('v' + currentVersion)} → ${bold(yellow('v' + newer))} ${dim(`(run: ${cliName} update)`)}\\n`;\n }\n return `\\n ${dim('v' + currentVersion)}\\n`;\n}\n\nexport async function checkAndNotifyUpdate(\n currentVersion: string,\n packageName: string,\n): Promise<void> {\n // Guards: skip when not appropriate\n if (!process.stderr.isTTY) return;\n if (process.env.NO_UPDATE_NOTIFIER) return;\n if (process.env.CI) return;\n if (process.env.NODE_ENV === 'test') return;\n\n try {\n const cache = readCache();\n let latestVersion: string | null = null;\n\n if (cache && Date.now() - cache.lastCheck < CHECK_INTERVAL) {\n // Cache is fresh — use it\n latestVersion = cache.latestVersion;\n } else {\n // Cache is stale or missing — fetch from registry\n latestVersion = await fetchLatestVersion(packageName);\n if (latestVersion) {\n writeCache({ lastCheck: Date.now(), latestVersion });\n } else if (cache) {\n // Fetch failed but we have stale cache — use it\n latestVersion = cache.latestVersion;\n }\n }\n\n if (latestVersion && isOlderVersion(currentVersion, latestVersion)) {\n printNotice(currentVersion, latestVersion, packageName);\n }\n } catch {\n // Silent — update check must never break the CLI\n }\n}\n","import { Command } from 'commander';\nimport { spawnSync } from 'node:child_process';\nimport pc from 'picocolors';\nimport { handleError } from '../lib/errors.js';\n\ndeclare const CLI_VERSION: string;\ndeclare const CLI_PACKAGE_NAME: string;\n\nfunction isOlderVersion(current: string, latest: string): boolean {\n const parse = (v: string) => v.split('.').map(Number);\n const [cMaj, cMin, cPat] = parse(current);\n const [lMaj, lMin, lPat] = parse(latest);\n if (cMaj !== lMaj) return cMaj < lMaj;\n if (cMin !== lMin) return cMin < lMin;\n return cPat < lPat;\n}\n\nfunction detectPackageManager(): 'pnpm' | 'npm' {\n const ua = process.env.npm_config_user_agent ?? '';\n if (ua.startsWith('pnpm')) return 'pnpm';\n return 'npm';\n}\n\nexport const updateCommand = new Command('update')\n .description('Check for updates and upgrade to the latest version')\n .action(async () => {\n const noColor = !process.stderr.isTTY || !!process.env.NO_COLOR || process.env.TERM === 'dumb';\n const bold = noColor ? (s: string) => s : pc.bold;\n const dim = noColor ? (s: string) => s : pc.dim;\n const green = noColor ? (s: string) => s : pc.green;\n\n try {\n process.stderr.write(dim('Checking for updates…') + '\\n');\n\n const res = await fetch(\n `https://registry.npmjs.org/${CLI_PACKAGE_NAME}/latest`,\n { signal: AbortSignal.timeout(5000) }\n );\n if (!res.ok) throw new Error(`Registry returned ${res.status}`);\n\n const data = (await res.json()) as { version: string };\n const latest = data.version;\n const current = CLI_VERSION;\n\n if (!isOlderVersion(current, latest)) {\n console.log(green('✓') + ` Already on the latest version (${bold('v' + current)})`);\n return;\n }\n\n const pm = detectPackageManager();\n const installArgs = pm === 'pnpm'\n ? ['add', '-g', CLI_PACKAGE_NAME]\n : ['install', '-g', CLI_PACKAGE_NAME];\n const installCmd = `${pm} ${installArgs.join(' ')}`;\n\n console.log(`Update available: ${dim('v' + current)} → ${bold('v' + latest)}`);\n console.log(dim('Running: ') + bold(installCmd));\n console.log('');\n\n const result = spawnSync(pm, installArgs, { stdio: 'inherit' });\n\n if (result.status !== 0) {\n process.exit(result.status ?? 1);\n }\n\n console.log('');\n console.log(green('✓') + ` Updated to ${bold('v' + latest)}`);\n } catch (err) {\n handleError(err);\n }\n });\n","import { Command, type Option } from 'commander';\n\ndeclare const CLI_VERSION: string;\n\ninterface SchemaOption {\n flags: string;\n description: string;\n defaultValue?: unknown;\n}\n\ninterface SchemaCommand {\n name: string;\n description: string;\n aliases: string[];\n options: SchemaOption[];\n subcommands: SchemaCommand[];\n}\n\ninterface SchemaOutput {\n name: string;\n version: string;\n description: string;\n globalOptions: SchemaOption[];\n commands: SchemaCommand[];\n}\n\nfunction mapOption(opt: Option): SchemaOption {\n const result: SchemaOption = {\n flags: opt.flags,\n description: opt.description,\n };\n if (opt.defaultValue !== undefined) {\n result.defaultValue = opt.defaultValue;\n }\n return result;\n}\n\nfunction mapCommand(cmd: Command): SchemaCommand {\n return {\n name: cmd.name(),\n description: cmd.description(),\n aliases: cmd.aliases(),\n options: cmd.options.map(mapOption),\n subcommands: cmd.commands.map(mapCommand),\n };\n}\n\nexport const schemaCommand = new Command('schema')\n .description('Output full command schema as JSON (for AI agent discovery)')\n .action((_opts: Record<string, unknown>, cmd: Command) => {\n const root = cmd.parent ?? cmd;\n const schema: SchemaOutput = {\n name: root.name(),\n version: CLI_VERSION,\n description: root.description(),\n globalOptions: root.options.map(mapOption),\n commands: root.commands.map(mapCommand),\n };\n console.log(JSON.stringify(schema, null, 2));\n });\n"],"mappings":";;;AAAA,SAAS,WAAAA,iBAAe;;;ACAxB,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AW,aAAa;AAChC,QAAQ,WAAW,aAAa;AAChC,QAAQ,WAAW,aAAa;AAGhC,QAAQ,KAAK,aAAa,YAAY;AACpC,QAAM,qBAAqB,SAAa,OAAgB;AAC1D,CAAC;AAGD,QAAQ,GAAG,UAAU,MAAM;AACzB,UAAQ,MAAM,eAAe;AAC7B,UAAQ,KAAK,GAAG;AAClB,CAAC;AAED,QAAQ,GAAG,WAAW,MAAM;AAC1B,UAAQ,KAAK,CAAC;AAChB,CAAC;AAGD,QAAQ,OAAO,GAAG,SAAS,CAAC,QAAQ;AAClC,MAAI,IAAI,SAAS,SAAS;AACxB,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,QAAM;AACR,CAAC;AAGD,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,UAAU;AAChD,QAAM,UAAU,QAAQ,KAAK,EAAE,WAAW,QAAQ,IAAI,aAAa;AACnE,cAAY,OAAO,OAAO;AAC5B,CAAC;","names":["Command","pc","path","pc","pc","path","pc","pc","pc","pc","pc","Command","pc","c","printTree","pc","resolve","pc","Command","pc","pc","createInterface","existsSync","readFileSync","writeFileSync","unlinkSync","join","pc","content","pc","resolve","createInterface","Command","buildContext","Command","Command","buildContext","Command","Command","buildContext","Command","Command","Command","Command","buildContext","Command","Command","pc","grouped","pc","fs","path","pc","buildContext","Command","Command","pc","pc","pc","pc","pad","truncate","buildContext","Command","existsSync","readFileSync","writeFileSync","mkdirSync","join","pc","join","path","existsSync","readFileSync","mkdirSync","writeFileSync","pc","pad","Command","pc","isOlderVersion","Command","pc","Command","Command"]}
|