@creator-notes/cli 0.2.0 → 0.2.1
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 +149 -0
- package/SKILL.md +105 -226
- package/dist/cn.js +13 -1
- package/dist/cn.js.map +1 -1
- package/dist/commands/auth.d.ts +7 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +12 -9
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +153 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/workspace.d.ts +10 -0
- package/dist/commands/workspace.d.ts.map +1 -1
- package/dist/commands/workspace.js +43 -13
- package/dist/commands/workspace.js.map +1 -1
- package/dist/lib/auth-store.d.ts.map +1 -1
- package/dist/lib/auth-store.js +2 -1
- package/dist/lib/auth-store.js.map +1 -1
- package/dist/lib/style.d.ts +10 -0
- package/dist/lib/style.d.ts.map +1 -0
- package/dist/lib/style.js +17 -0
- package/dist/lib/style.js.map +1 -0
- package/package.json +2 -1
package/README.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# @creator-notes/cli
|
|
2
|
+
|
|
3
|
+
CLI for [CreatorNotes](https://creatornotes.app) — create notes, build canvases, search knowledge, and manage workspaces from the terminal.
|
|
4
|
+
|
|
5
|
+
Works as a standalone CLI (`cn`) and as an MCP server (`cn-mcp`) for AI assistants like Claude.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @creator-notes/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cn init # Interactive setup (auth + workspace)
|
|
17
|
+
cn notes list # Browse your notes
|
|
18
|
+
cn notes create --markdown-file ./note.md --type "Meeting"
|
|
19
|
+
cn search semantic "onboarding flow"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Commands
|
|
23
|
+
|
|
24
|
+
| Command | Alias | Description |
|
|
25
|
+
|---------|-------|-------------|
|
|
26
|
+
| `cn init` | | Interactive setup wizard |
|
|
27
|
+
| `cn auth login` | | Authenticate via browser or API token |
|
|
28
|
+
| `cn notes list\|get\|create\|update\|delete` | `cn n` | Manage notes |
|
|
29
|
+
| `cn notes bulk-create` | | Create multiple interlinked notes atomically |
|
|
30
|
+
| `cn versions list\|create` | `cn v` | Note version history |
|
|
31
|
+
| `cn canvas list\|get\|create\|delete` | `cn c` | Manage canvases |
|
|
32
|
+
| `cn canvas add-node\|add-text\|add-list\|add-link` | | Add nodes to canvas |
|
|
33
|
+
| `cn canvas bulk-add\|bulk-move\|bulk-remove` | | Bulk canvas operations |
|
|
34
|
+
| `cn canvas from-template` | | Create canvas from template |
|
|
35
|
+
| `cn search semantic` | `cn s` | Semantic search across notes |
|
|
36
|
+
| `cn timeline` | `cn tl` | Recent activity feed |
|
|
37
|
+
| `cn relationships list` | `cn rel` | Note relationships |
|
|
38
|
+
| `cn types list\|create\|update` | `cn t` | Manage note types (supertags) |
|
|
39
|
+
| `cn memory query\|facts\|entities` | `cn mem` | Query workspace knowledge |
|
|
40
|
+
| `cn workspace list\|select\|current` | | Workspace management |
|
|
41
|
+
| `cn config get-server\|set-server` | | CLI configuration |
|
|
42
|
+
| `cn mcp setup` | | Print MCP server config for Claude |
|
|
43
|
+
|
|
44
|
+
## Global Flags
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
--json Output raw JSON (for piping / scripting)
|
|
48
|
+
-q, --quiet Minimal output (IDs only)
|
|
49
|
+
-w, --workspace <id> Override active workspace
|
|
50
|
+
--server <url> Override server URL
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Authentication
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# Browser-based OAuth (recommended)
|
|
57
|
+
cn auth login
|
|
58
|
+
|
|
59
|
+
# API token (CI / non-interactive)
|
|
60
|
+
cn auth login --token <key>
|
|
61
|
+
|
|
62
|
+
# Check session
|
|
63
|
+
cn auth status
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Notes
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Create from markdown file
|
|
70
|
+
cn notes create --markdown-file ./standup.md --title "Daily Standup" --type "Meeting"
|
|
71
|
+
|
|
72
|
+
# Create with tags
|
|
73
|
+
cn notes create --markdown "Quick idea" --type "Insight" --tags "ux,onboarding"
|
|
74
|
+
|
|
75
|
+
# List with filters
|
|
76
|
+
cn notes list --type Meeting --pinned --limit 10
|
|
77
|
+
|
|
78
|
+
# Get by display ID
|
|
79
|
+
cn notes get MEETING-42
|
|
80
|
+
|
|
81
|
+
# Update metadata
|
|
82
|
+
cn notes update MEETING-42 --pin --tags "important,q2"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Content Updates
|
|
86
|
+
|
|
87
|
+
Content and metadata are separate operations:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Update content -> create a new version
|
|
91
|
+
cn versions create MEETING-42 --description "Added action items" --markdown-file ./updated.md
|
|
92
|
+
|
|
93
|
+
# Update metadata (title, tags, pin, archive)
|
|
94
|
+
cn notes update MEETING-42 --title "New Title"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Canvas
|
|
98
|
+
|
|
99
|
+
Values in `<angle-brackets>` are placeholders — replace them with real IDs from your workspace.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
# Create a canvas and add notes
|
|
103
|
+
cn canvas create "Sprint Review"
|
|
104
|
+
cn canvas bulk-add <canvasId> --notes '[{"noteId":"NOTE-1","x":100,"y":100},{"noteId":"NOTE-2","x":500,"y":100}]'
|
|
105
|
+
cn canvas add-edge <canvasId> --source <nodeId> --target <nodeId> --label "blocks"
|
|
106
|
+
|
|
107
|
+
# Create from template
|
|
108
|
+
cn canvas from-template sprint-retrospective --populate
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Available templates: `sprint-retrospective`, `swot-analysis`, `kanban-board`, `feature-prioritization`, `meeting-notes`, `product-roadmap`
|
|
112
|
+
|
|
113
|
+
## MCP Server
|
|
114
|
+
|
|
115
|
+
Use CreatorNotes as an MCP tool server for Claude Desktop or other AI assistants:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Print config to add to Claude Desktop
|
|
119
|
+
cn mcp setup
|
|
120
|
+
|
|
121
|
+
# Or run directly
|
|
122
|
+
cn-mcp
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Scripting
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Chain commands with quiet mode
|
|
129
|
+
NOTE_ID=$(cn notes create --markdown "Quick note" --type "Note" -q)
|
|
130
|
+
cn canvas add-node <canvasId> --note "$NOTE_ID"
|
|
131
|
+
|
|
132
|
+
# JSON output for parsing
|
|
133
|
+
cn notes list --json | jq '.[0].displayId'
|
|
134
|
+
|
|
135
|
+
# Bulk create interlinked notes with @key placeholders
|
|
136
|
+
cn notes bulk-create --notes '[
|
|
137
|
+
{"key":"A","title":"Problem","type":"PainPoint","markdownFile":"./problem.md"},
|
|
138
|
+
{"key":"B","title":"Solution","type":"Insight","markdownFile":"./solution.md"}
|
|
139
|
+
]' --json
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Requirements
|
|
143
|
+
|
|
144
|
+
- Node.js >= 18
|
|
145
|
+
- A [CreatorNotes](https://creatornotes.app) account
|
|
146
|
+
|
|
147
|
+
## License
|
|
148
|
+
|
|
149
|
+
MIT
|
package/SKILL.md
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
# CreatorNotes CLI (`cn`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A command-line interface for CreatorNotes — create notes, build canvases, search knowledge, and manage workspaces from the terminal.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Getting Started
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### Install
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @creator-notes/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Authenticate
|
|
10
14
|
|
|
11
|
-
Before starting, confirm the active workspace:
|
|
12
15
|
```bash
|
|
13
|
-
|
|
16
|
+
cn auth login # Opens browser for OAuth
|
|
17
|
+
cn auth login --token <key> # Direct API key
|
|
18
|
+
cn auth status # Check current session
|
|
14
19
|
```
|
|
15
20
|
|
|
16
|
-
|
|
21
|
+
### Select a Workspace
|
|
22
|
+
|
|
17
23
|
```bash
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
cn workspace list
|
|
25
|
+
cn workspace select <id>
|
|
26
|
+
cn workspace current # Verify active workspace
|
|
20
27
|
```
|
|
21
28
|
|
|
22
29
|
## Command Reference
|
|
@@ -26,149 +33,146 @@ npx cn workspace select <id>
|
|
|
26
33
|
--json Output raw JSON (best for piping / parsing)
|
|
27
34
|
-q, --quiet Minimal output (IDs only — useful for scripting)
|
|
28
35
|
-w, --workspace <id> Override active workspace
|
|
29
|
-
--server <url> Override server URL
|
|
36
|
+
--server <url> Override server URL (default: https://creatornotes.app)
|
|
30
37
|
```
|
|
31
38
|
|
|
32
39
|
### Notes (`cn notes` / `cn n`)
|
|
33
40
|
```bash
|
|
34
41
|
# List notes (default 20, excludes drafts)
|
|
35
|
-
|
|
42
|
+
cn notes list [--search <query>] [--type <type>] [--tags <csv>] [--pinned] [--limit <n>]
|
|
36
43
|
|
|
37
44
|
# Get a single note by display ID or Convex ID
|
|
38
|
-
|
|
45
|
+
cn notes get <id> [--all-versions]
|
|
39
46
|
|
|
40
47
|
# Create a note
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
cn notes create --markdown-file <path.md> [--title <title>] [--type <type>] [--tags <csv>] [--draft]
|
|
49
|
+
cn notes create --markdown "<content>" [--title <title>] [--type <type>] [--tags <csv>] [--draft] # inline (short content only)
|
|
50
|
+
cn notes create --content-file <path.json> # TipTap JSON from file
|
|
51
|
+
cn notes create --content-stdin # TipTap JSON from stdin
|
|
45
52
|
|
|
46
53
|
# Update metadata only (not content — use versions for that)
|
|
47
|
-
|
|
54
|
+
cn notes update <id> [--title <t>] [--type <t>] [--tags <csv>] [--archive] [--unarchive] [--pin] [--unpin]
|
|
48
55
|
|
|
49
56
|
# Delete (archive)
|
|
50
|
-
|
|
57
|
+
cn notes delete <id>
|
|
51
58
|
|
|
52
59
|
# Bulk archive/unarchive multiple notes at once
|
|
53
|
-
|
|
60
|
+
cn notes bulk-archive --ids '["MEETING-1","PRD-3","IDEA-7"]' [--unarchive]
|
|
54
61
|
|
|
55
62
|
# Bulk create interlinked notes in one atomic transaction
|
|
56
63
|
# Use @key placeholders for cross-references — resolved to real displayIds server-side
|
|
57
|
-
|
|
64
|
+
cn notes bulk-create --notes '[{"key":"A","title":"Note A","type":"Insight","markdownFile":"./a.md"},{"key":"B","title":"Note B","type":"Problem","markdownFile":"./b.md"}]' --json
|
|
58
65
|
|
|
59
66
|
# Text search
|
|
60
|
-
|
|
67
|
+
cn notes search <query> [--type <type>] [--limit <n>]
|
|
61
68
|
```
|
|
62
69
|
|
|
63
70
|
### Versions (`cn versions` / `cn v`)
|
|
64
71
|
```bash
|
|
65
72
|
# List versions
|
|
66
|
-
|
|
73
|
+
cn versions list <noteId>
|
|
67
74
|
|
|
68
75
|
# Create a new version (updates note content)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
cn versions create <noteId> --description "what changed" --markdown-file <path.md>
|
|
77
|
+
cn versions create <noteId> --description "what changed" --markdown "<short content>" # inline (short only)
|
|
78
|
+
cn versions create <noteId> --description "what changed" --content-file <path.json>
|
|
72
79
|
```
|
|
73
80
|
|
|
74
81
|
### Canvas (`cn canvas` / `cn c`)
|
|
75
82
|
```bash
|
|
76
83
|
# List / get (archived canvases excluded by default)
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
cn canvas list [--include-archived]
|
|
85
|
+
cn canvas get <canvasId>
|
|
79
86
|
|
|
80
87
|
# AI digest (summary) of canvas
|
|
81
|
-
|
|
88
|
+
cn canvas digest <canvasId>
|
|
82
89
|
|
|
83
90
|
# Create / delete
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
cn canvas create "<name>"
|
|
92
|
+
cn canvas delete <canvasId>
|
|
93
|
+
cn canvas set-as-home <canvasId>
|
|
87
94
|
|
|
88
95
|
# Add nodes to canvas
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
cn canvas add-node <canvasId> --note <noteId> [--x <n>] [--y <n>]
|
|
97
|
+
cn canvas add-text <canvasId> --text "<content>" [--size heading|paragraph] [--x <n>] [--y <n>]
|
|
98
|
+
cn canvas add-list <canvasId> --name "<name>" --notes <id1,id2,...> [--view list|grid] [--x <n>] [--y <n>]
|
|
99
|
+
cn canvas add-link <canvasId> --target <otherCanvasId> [--x <n>] [--y <n>]
|
|
93
100
|
|
|
94
101
|
# Bulk add multiple notes at once (more efficient than repeated add-node)
|
|
95
|
-
|
|
102
|
+
cn canvas bulk-add <canvasId> --notes '[{"noteId":"NOTE-1","x":100,"y":100},{"noteId":"NOTE-2","x":400,"y":100}]'
|
|
96
103
|
|
|
97
104
|
# Move / remove nodes
|
|
98
|
-
|
|
99
|
-
|
|
105
|
+
cn canvas move-node <canvasId> --node <nodeId> --x <n> --y <n>
|
|
106
|
+
cn canvas remove-node <canvasId> --node <nodeId>
|
|
100
107
|
|
|
101
108
|
# Bulk remove multiple nodes at once
|
|
102
|
-
|
|
109
|
+
cn canvas bulk-remove <canvasId> --nodes '["nodeId1","nodeId2"]'
|
|
103
110
|
|
|
104
111
|
# Bulk move multiple nodes at once (more efficient than repeated move-node)
|
|
105
|
-
|
|
112
|
+
cn canvas bulk-move <canvasId> --moves '[{"nodeId":"abc","nodeType":"note","x":200,"y":300},{"nodeId":"def","nodeType":"text","x":500,"y":300}]'
|
|
106
113
|
# nodeType: note | text | list | canvas (defaults to "note")
|
|
107
114
|
|
|
108
115
|
# Connect nodes
|
|
109
|
-
|
|
116
|
+
cn canvas add-edge <canvasId> --source <nodeId> --target <nodeId> [--label "<text>"]
|
|
110
117
|
|
|
111
118
|
# Templates — create structured canvases from predefined layouts
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
cn canvas templates # List available templates
|
|
120
|
+
cn canvas from-template <templateId> [--title "<title>"] # Create empty skeleton
|
|
121
|
+
cn canvas from-template <templateId> --populate # Auto-populate zones with matching notes
|
|
115
122
|
# Templates: sprint-retrospective, swot-analysis, kanban-board, feature-prioritization, meeting-notes, product-roadmap
|
|
116
123
|
```
|
|
117
124
|
|
|
118
125
|
### Timeline (`cn timeline` / `cn tl`)
|
|
119
126
|
```bash
|
|
120
127
|
# Show recent changes (default: last 7 days)
|
|
121
|
-
|
|
128
|
+
cn timeline [--since <when>] [--until <when>] [--type <noteType>] [--note <filter>] [--limit <n>]
|
|
122
129
|
|
|
123
130
|
# Examples
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
cn timeline # last 7 days
|
|
132
|
+
cn timeline --since 30d # last 30 days
|
|
133
|
+
cn timeline --since 2w --type Meeting # meetings in last 2 weeks
|
|
134
|
+
cn timeline --since 7d --note standup # filter by note name
|
|
128
135
|
# Supported --since formats: relative (7d, 2w, 3h, 30m), ISO date (2026-03-21), unix ms
|
|
129
136
|
```
|
|
130
137
|
|
|
131
138
|
### Relationships (`cn relationships` / `cn rel`)
|
|
132
139
|
```bash
|
|
133
|
-
|
|
140
|
+
cn rel list [--note <displayId>]
|
|
134
141
|
```
|
|
135
142
|
|
|
136
143
|
### Semantic Search (`cn search` / `cn s`)
|
|
137
144
|
```bash
|
|
138
|
-
|
|
145
|
+
cn search semantic "<query>" [--limit <n>] [--canvas <canvasId>]
|
|
139
146
|
```
|
|
140
147
|
|
|
141
148
|
### Types (`cn types` / `cn t`)
|
|
142
149
|
```bash
|
|
143
150
|
# List all types (supertags) in the workspace
|
|
144
|
-
|
|
151
|
+
cn types list
|
|
145
152
|
|
|
146
153
|
# Create a new type
|
|
147
|
-
|
|
154
|
+
cn types create <name> [--prefix <PREFIX>] [--display-name <name>] [--description <text>] [--color <hex>]
|
|
148
155
|
|
|
149
156
|
# Update an existing type
|
|
150
|
-
|
|
157
|
+
cn types update <name> [--prefix <PREFIX>] [--display-name <name>] [--description <text>] [--color <hex>]
|
|
151
158
|
```
|
|
152
159
|
|
|
153
160
|
### Memory (`cn memory` / `cn mem`)
|
|
154
161
|
```bash
|
|
155
162
|
# Search facts and entities by relevance
|
|
156
|
-
|
|
163
|
+
cn memory query "<query>" [--limit <n>] [--source <conversation|notes>]
|
|
157
164
|
|
|
158
165
|
# List all workspace facts (extracted from notes and conversations)
|
|
159
|
-
|
|
166
|
+
cn memory facts [--source <conversation|notes>]
|
|
160
167
|
|
|
161
168
|
# List all entities (people, topics, orgs) identified by Zep
|
|
162
|
-
|
|
169
|
+
cn memory entities [--source <conversation|notes>]
|
|
163
170
|
```
|
|
164
171
|
|
|
165
|
-
###
|
|
172
|
+
### Config
|
|
166
173
|
```bash
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
npx cn auth status
|
|
170
|
-
npx cn config get-server
|
|
171
|
-
npx cn config set-server <url>
|
|
174
|
+
cn config get-server
|
|
175
|
+
cn config set-server <url>
|
|
172
176
|
```
|
|
173
177
|
|
|
174
178
|
## Best Practices
|
|
@@ -178,7 +182,7 @@ npx cn config set-server <url>
|
|
|
178
182
|
- Convex IDs (e.g., `n17a43p7aenrxyr...`) also work but are less readable.
|
|
179
183
|
- When creating notes, capture the display ID from the output for subsequent commands.
|
|
180
184
|
|
|
181
|
-
### Note Types
|
|
185
|
+
### Note Types
|
|
182
186
|
- The `--type` parameter must reference an **existing supertag** in the workspace. Free-text type strings are rejected.
|
|
183
187
|
- Before creating a note, check available types with `cn types list`.
|
|
184
188
|
- If the type you need doesn't exist, create it first: `cn types create "MyType" --prefix "MT"`
|
|
@@ -186,10 +190,9 @@ npx cn config set-server <url>
|
|
|
186
190
|
- The display ID prefix (e.g., `UPDATE-`, `PP-`) comes from the supertag's `prefix` field.
|
|
187
191
|
|
|
188
192
|
### Content via Markdown
|
|
189
|
-
- For multi-line content, **
|
|
193
|
+
- For multi-line content, **use `--markdown-file`**: write content to a file first, then pass the path.
|
|
190
194
|
```bash
|
|
191
|
-
|
|
192
|
-
npx cn notes create --markdown-file /tmp/note.md --title "My Note" --type "Note"
|
|
195
|
+
cn notes create --markdown-file ./note.md --title "My Note" --type "Note"
|
|
193
196
|
```
|
|
194
197
|
- Only use inline `--markdown "..."` for very short, single-line content.
|
|
195
198
|
- The server converts markdown to TipTap JSON automatically.
|
|
@@ -198,7 +201,7 @@ npx cn config set-server <url>
|
|
|
198
201
|
- Simple mention shorthand: `[NOTE-123]` or `[NOTE-123: Title]` (defaults to "references")
|
|
199
202
|
|
|
200
203
|
### Updating Content vs Metadata
|
|
201
|
-
- To change note **content**, create a new **version**: `cn versions create <id> --description "..." --markdown
|
|
204
|
+
- To change note **content**, create a new **version**: `cn versions create <id> --description "..." --markdown-file ./updated.md`
|
|
202
205
|
- To change note **title/type/tags/pin/archive**, use: `cn notes update <id> --title "..."`
|
|
203
206
|
- These are separate operations by design.
|
|
204
207
|
|
|
@@ -206,13 +209,13 @@ npx cn config set-server <url>
|
|
|
206
209
|
- Use `--json` to get raw JSON output for parsing with `jq` or piping between commands.
|
|
207
210
|
- Use `-q` (quiet) to get just the ID, useful for chaining:
|
|
208
211
|
```bash
|
|
209
|
-
NOTE_ID=$(
|
|
210
|
-
|
|
212
|
+
NOTE_ID=$(cn notes create --markdown "Quick note" -q)
|
|
213
|
+
cn canvas add-node <canvasId> --note "$NOTE_ID"
|
|
211
214
|
```
|
|
212
215
|
|
|
213
|
-
### Canvas Layout
|
|
216
|
+
### Canvas Layout
|
|
214
217
|
|
|
215
|
-
When adding 3+ notes to a canvas, **plan all positions upfront** and use `bulk-add` in a single call
|
|
218
|
+
When adding 3+ notes to a canvas, **plan all positions upfront** and use `bulk-add` in a single call instead of repeated `add-node` calls.
|
|
216
219
|
|
|
217
220
|
#### Layout Constants
|
|
218
221
|
|
|
@@ -221,7 +224,6 @@ When adding 3+ notes to a canvas, **plan all positions upfront** and use `bulk-a
|
|
|
221
224
|
| Node (rendered) | 280 | 100 |
|
|
222
225
|
| Grid cell (node + padding) | 400 | 180 |
|
|
223
226
|
| Edge label | ~80 | ~14 |
|
|
224
|
-
| Label collision zone | 80 horizontal | 14 vertical |
|
|
225
227
|
|
|
226
228
|
Node center offset from top-left: `(+140, +50)`.
|
|
227
229
|
|
|
@@ -229,137 +231,40 @@ Node center offset from top-left: `(+140, +50)`.
|
|
|
229
231
|
|
|
230
232
|
Use `--size` to control text node font size (default: `heading`):
|
|
231
233
|
|
|
232
|
-
| Size |
|
|
233
|
-
|
|
234
|
-
| `heading` (default) |
|
|
235
|
-
| `paragraph` |
|
|
236
|
-
|
|
237
|
-
For reference, the UI default for double-click-created text nodes is 60px (`text-[4rem]`). The CLI sizes are intentionally smaller since CLI-created text is typically structural.
|
|
238
|
-
|
|
239
|
-
**Rule of thumb:** Use `heading` for structural/navigational text and `paragraph` for explanatory or secondary text. When a canvas has both titles and descriptions, mix sizes to create visual hierarchy.
|
|
240
|
-
|
|
241
|
-
#### Algorithm: Hierarchical Layout
|
|
242
|
-
|
|
243
|
-
Follow these steps **before making any API calls**.
|
|
244
|
-
|
|
245
|
-
**Step 1 — Build the graph.** List all notes and their edge relationships:
|
|
246
|
-
```
|
|
247
|
-
A -> B (label: "drives")
|
|
248
|
-
A -> C (label: "informs")
|
|
249
|
-
B -> D (label: "blocks")
|
|
250
|
-
C -> D (label: "requires")
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
**Step 2 — Assign ranks (top-down layers).**
|
|
254
|
-
- Rank 0: nodes with no incoming edges (roots)
|
|
255
|
-
- Rank N: `max(rank of all parents) + 1`
|
|
256
|
-
- If a cycle exists, place the node at the higher rank
|
|
257
|
-
|
|
258
|
-
Example:
|
|
259
|
-
```
|
|
260
|
-
Rank 0: A
|
|
261
|
-
Rank 1: B, C
|
|
262
|
-
Rank 2: D
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
**Step 3 — Calculate positions.**
|
|
266
|
-
- `Y = 100 + rank × 180`
|
|
267
|
-
- For each rank with N nodes: `totalWidth = N × 400 − 120`
|
|
268
|
-
- Find the widest rank's totalWidth (`maxWidth`)
|
|
269
|
-
- `startX = 100 + (maxWidth − totalWidth) / 2`
|
|
270
|
-
- Each node: `X = startX + index × 400`
|
|
271
|
-
|
|
272
|
-
Example (widest rank has 2 nodes → maxWidth = 680):
|
|
273
|
-
```
|
|
274
|
-
Rank 0 (1 node): startX = 100 + (680−280)/2 = 300 → A: (300, 100)
|
|
275
|
-
Rank 1 (2 nodes): startX = 100 + (680−680)/2 = 100 → B: (100, 280) C: (500, 280)
|
|
276
|
-
Rank 2 (1 node): startX = 300 → D: (300, 460)
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
**Step 4 — Compute edge label midpoints.** For each edge, the label renders at the midpoint of source and target node centers:
|
|
280
|
-
- Node center = `(nodeX + 140, nodeY + 50)`
|
|
281
|
-
- Label position = `((srcCenterX + tgtCenterX) / 2, (srcCenterY + tgtCenterY) / 2)`
|
|
234
|
+
| Size | Use for |
|
|
235
|
+
|------|---------|
|
|
236
|
+
| `heading` (default) | Section headers, zone titles, canvas labels |
|
|
237
|
+
| `paragraph` | Descriptions, annotations, supporting context |
|
|
282
238
|
|
|
283
|
-
|
|
284
|
-
A(300,100)->B(100,280): centers (440,150)→(240,330) → label (340, 240)
|
|
285
|
-
A(300,100)->C(500,280): centers (440,150)→(640,330) → label (540, 240)
|
|
286
|
-
B(100,280)->D(300,460): centers (240,330)→(440,510) → label (340, 420)
|
|
287
|
-
C(500,280)->D(300,460): centers (640,330)→(440,510) → label (540, 420)
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
**Step 5 — Check label collisions.** Two labels collide when `|dx| < 80 AND |dy| < 14`. Check every pair:
|
|
291
|
-
```
|
|
292
|
-
(340,240) vs (540,240): |dx|=200 > 80 → OK
|
|
293
|
-
(340,240) vs (340,420): |dy|=180 > 14 → OK
|
|
294
|
-
(340,420) vs (540,420): |dx|=200 > 80 → OK
|
|
295
|
-
... all other pairs also clear. No collisions.
|
|
296
|
-
```
|
|
239
|
+
#### Positioning Algorithm
|
|
297
240
|
|
|
298
|
-
**
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
4. **Recalculate ALL label midpoints** (not just the pair that collided)
|
|
303
|
-
5. Re-check all pairs. Repeat up to **3 iterations**. If still colliding, accept it
|
|
241
|
+
1. **Build the graph** — list all notes and their relationships.
|
|
242
|
+
2. **Assign ranks** — Rank 0 for root nodes (no incoming edges), Rank N = `max(parent ranks) + 1`.
|
|
243
|
+
3. **Calculate positions** — `Y = 100 + rank × 180`. Center each rank horizontally with 400px spacing between nodes.
|
|
244
|
+
4. **Use `bulk-add`** for all nodes, then add edges with `add-edge`.
|
|
304
245
|
|
|
305
|
-
|
|
306
|
-
```bash
|
|
307
|
-
npx cn canvas bulk-add <canvasId> --notes '[{"noteId":"A-ID","x":300,"y":100},{"noteId":"B-ID","x":100,"y":280},{"noteId":"C-ID","x":500,"y":280},{"noteId":"D-ID","x":300,"y":460}]' --json
|
|
308
|
-
# Parse node IDs from --json output, then:
|
|
309
|
-
npx cn canvas add-edge <canvasId> --source <A-nodeId> --target <B-nodeId> --label "drives"
|
|
310
|
-
npx cn canvas add-edge <canvasId> --source <A-nodeId> --target <C-nodeId> --label "informs"
|
|
311
|
-
npx cn canvas add-edge <canvasId> --source <B-nodeId> --target <D-nodeId> --label "blocks"
|
|
312
|
-
npx cn canvas add-edge <canvasId> --source <C-nodeId> --target <D-nodeId> --label "requires"
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
#### Quick Reference: Common Topologies
|
|
246
|
+
#### Common Topologies
|
|
316
247
|
|
|
317
248
|
**Linear chain** (A→B→C→D): stack vertically at X=300, Y increments of 180.
|
|
318
|
-
```
|
|
319
|
-
A:(300,100) B:(300,280) C:(300,460) D:(300,640)
|
|
320
|
-
```
|
|
321
|
-
No label collisions (all labels share X=440 but different Y).
|
|
322
249
|
|
|
323
250
|
**Fan-out** (A→B, A→C, A→D): root on top, children spread horizontally at 400px intervals.
|
|
324
|
-
```
|
|
325
|
-
A:(500,100) B:(100,280) C:(500,280) D:(900,280)
|
|
326
|
-
```
|
|
327
|
-
Labels at distinct X positions — no collisions.
|
|
328
|
-
|
|
329
|
-
**Diamond** (A→B, A→C, B→D, C→D): the worked example above. 2-column layout.
|
|
330
|
-
|
|
331
|
-
**Wide fan** (5+ children): 400px spacing per child.
|
|
332
|
-
```
|
|
333
|
-
Root:(900,100) C1:(100,280) C2:(500,280) C3:(900,280) C4:(1300,280) C5:(1700,280)
|
|
334
|
-
```
|
|
335
251
|
|
|
336
|
-
|
|
252
|
+
**Diamond** (A→B, A→C, B→D, C→D): 2-column layout centered under root.
|
|
337
253
|
|
|
338
|
-
|
|
339
|
-
2. **Use `bulk-add` for 3+ notes, not repeated `add-node`.** One call, all positions.
|
|
340
|
-
3. **400px horizontal / 180px vertical** minimum spacing between node top-left origins.
|
|
341
|
-
4. **Check every pair of edge label midpoints.** Collision = `|dx| < 80 AND |dy| < 14`.
|
|
342
|
-
5. **Nudge horizontally by ±100px** to fix collisions. Recalculate all midpoints after each nudge. Max 3 iterations.
|
|
343
|
-
6. **Parse `bulk-add --json` output** to get node IDs for `add-edge` commands.
|
|
254
|
+
### Interlinking Notes
|
|
344
255
|
|
|
345
|
-
|
|
346
|
-
When creating multiple notes that belong together (e.g., for a canvas, onboarding guide, or knowledge map), you MUST interlink them at two levels:
|
|
256
|
+
When creating multiple related notes, interlink at two levels:
|
|
347
257
|
|
|
348
|
-
**1. Relationship mentions inside note content** —
|
|
349
|
-
-
|
|
350
|
-
-
|
|
351
|
-
- The server resolves placeholders to real display IDs
|
|
352
|
-
- Workflow:
|
|
353
|
-
1. Write all markdown files to `/tmp/`, using `[@key: Title](relationship:type)` for cross-references
|
|
354
|
-
2. Run `cn notes bulk-create --notes '[{"key":"A",...,"markdownFile":"/tmp/a.md"},...]' --json`
|
|
355
|
-
3. Parse the JSON output for display IDs and Convex IDs
|
|
258
|
+
**1. Relationship mentions inside note content** — connects notes in the knowledge graph:
|
|
259
|
+
- Use `cn notes bulk-create` with `@key` placeholders for cross-references.
|
|
260
|
+
- Example: `[@B: The Problem](relationship:references)` in markdown.
|
|
261
|
+
- The server resolves placeholders to real display IDs in one atomic transaction.
|
|
356
262
|
|
|
357
|
-
**2. Canvas edges between nodes** —
|
|
358
|
-
- After adding
|
|
359
|
-
- Use descriptive labels
|
|
360
|
-
- `cn canvas add-edge <canvasId> --source <nodeId> --target <nodeId> --label "relationship"`
|
|
263
|
+
**2. Canvas edges between nodes** — visual connections on the canvas:
|
|
264
|
+
- After adding nodes, connect them with `cn canvas add-edge`.
|
|
265
|
+
- Use descriptive labels (e.g., "triggers", "depends on").
|
|
361
266
|
|
|
362
|
-
Both levels are needed
|
|
267
|
+
Both levels are needed — edges are visual-only, mentions are content-level.
|
|
363
268
|
|
|
364
269
|
#### Placeholder Syntax for `bulk-create`
|
|
365
270
|
|
|
@@ -368,43 +273,17 @@ Use `[@key: Title](relationship:type)` where `key` matches a note's `key` field
|
|
|
368
273
|
This builds on [@B: The Problem](relationship:references) and enables [@C: The Workflow](relationship:derived-from).
|
|
369
274
|
```
|
|
370
275
|
|
|
371
|
-
The `@` prefix distinguishes placeholders from real display IDs. If a placeholder key doesn't match any note in the batch, the entire operation fails (nothing gets created).
|
|
372
|
-
|
|
373
276
|
Supported relationship types: `depends-on`, `blocks`, `related-to`, `derived-from`, `references`, `extends`, `implements`, `invalidates`, `duplicates`
|
|
374
277
|
|
|
375
|
-
###
|
|
376
|
-
Before creating or updating notes on a topic, **query Zep memory first** to understand what is already known. Use iterative traversal:
|
|
278
|
+
### Memory
|
|
377
279
|
|
|
378
|
-
|
|
379
|
-
2. **Follow interesting entities:** If the results mention related people, teams, initiatives, or dependencies, run follow-up queries on those (e.g., `cn memory query "Draft content team"`, `cn memory query "InfoTrack certificates"`).
|
|
380
|
-
3. **Check temporal validity:** Facts have `validAt`/`invalidAt` timestamps. Superseded facts (with `invalidAt` in the past) show what *was* true — prefer current facts for recommendations, but cite historical facts when explaining how something evolved.
|
|
381
|
-
4. **Synthesize across hops:** After 2-3 queries, combine the facts into a coherent summary before acting. This gives much richer context than a single query.
|
|
280
|
+
Before creating or updating notes on a topic, **query memory first** to understand what is already known:
|
|
382
281
|
|
|
383
|
-
**
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
- When the user asks about people, teams, or initiatives — entities track these
|
|
388
|
-
|
|
389
|
-
**When NOT to use memory:**
|
|
390
|
-
- For simple CRUD operations (create a note, add a node) where the user gives explicit content
|
|
391
|
-
- When the user says they want a fresh take without prior context
|
|
282
|
+
1. **Start broad:** `cn memory query "<topic>"` — get the top facts and entities.
|
|
283
|
+
2. **Follow entities:** Run follow-up queries on related people, teams, or initiatives.
|
|
284
|
+
3. **Check temporal validity:** Facts have `validAt`/`invalidAt` timestamps — prefer current facts.
|
|
285
|
+
4. **Synthesize:** Combine facts from 2-3 queries before acting.
|
|
392
286
|
|
|
393
287
|
### Error Handling
|
|
394
|
-
- If a command fails with auth errors, run `
|
|
395
|
-
- If workspace-related errors occur, verify
|
|
396
|
-
|
|
397
|
-
## Rules
|
|
398
|
-
|
|
399
|
-
- **ALWAYS write each bash command as a single line.** Never split variable assignments and commands across multiple lines. Use inline env vars: `CANVAS=abc npx cn canvas get $CANVAS` — NOT separate lines. Multi-line commands trigger permission prompts.
|
|
400
|
-
- Always run commands from `/workspaces/pm-notes` directory so `npx cn` resolves correctly.
|
|
401
|
-
- Always use `--json` when you need to parse output programmatically.
|
|
402
|
-
- **NEVER leave multi-note work disconnected.** When creating 2+ related notes, use `cn notes bulk-create` with `@key` placeholders to create all notes with cross-references in one atomic call. Then add canvas edges if the notes are on a canvas. Both levels (content mentions + canvas edges) are mandatory.
|
|
403
|
-
- Do NOT use interactive mode flags — the CLI uses interactive prompts (select menus) in TTY mode which do not work in this environment. Always use `--json` or `-q` to bypass interactive prompts.
|
|
404
|
-
- Prefer semantic search (`cn search semantic`) over text search (`cn notes search`) when looking for conceptually related notes.
|
|
405
|
-
- **Clickable links after creation:** When you create a note or canvas, include a clickable link in your response so the user can open it directly in CreatorNotes. Use the server URL from `cn config get-server` (default `https://creatornotes.app`):
|
|
406
|
-
- **Note:** `[DISPLAY-ID: Title](https://creatornotes.app/ws/{workspaceId}?noteId={noteConvexId})`
|
|
407
|
-
- **Canvas:** `[Canvas Name](https://creatornotes.app/ws/{workspaceId}?canvasId={canvasId})`
|
|
408
|
-
- Always extract the IDs from the `--json` output of the create command.
|
|
409
|
-
- **Mention syntax in markdown must be standalone.** NEVER wrap `[NOTE-XXX: Title](relationship:references)` mentions inside bold `**...**` markers or other inline formatting — this causes the raw markdown text to render alongside the mention chip, producing duplicated/garbled output.
|
|
410
|
-
- **When adding 3+ notes to a canvas, ALWAYS use `bulk-add` with pre-calculated positions.** Never use repeated `add-node` calls. Follow the Canvas Layout Planning algorithm above to compute positions and avoid edge label overlap.
|
|
288
|
+
- If a command fails with auth errors, run `cn auth status` to verify credentials.
|
|
289
|
+
- If workspace-related errors occur, verify with `cn workspace current`.
|
package/dist/cn.js
CHANGED
|
@@ -12,16 +12,19 @@ import { registerTimelineCommands } from "./commands/timeline.js";
|
|
|
12
12
|
import { registerTypesCommands } from "./commands/types.js";
|
|
13
13
|
import { registerMemoryCommands } from "./commands/memory.js";
|
|
14
14
|
import { registerMcpCommands } from "./commands/mcp.js";
|
|
15
|
+
import { registerInitCommand } from "./commands/init.js";
|
|
16
|
+
import { loadConfig, getServerConfig } from "./lib/auth-store.js";
|
|
15
17
|
const program = new Command();
|
|
16
18
|
program
|
|
17
19
|
.name("cn")
|
|
18
20
|
.description("CreatorNotes CLI — manage notes, canvases, and knowledge from the terminal")
|
|
19
|
-
.version("0.1
|
|
21
|
+
.version("0.2.1")
|
|
20
22
|
.option("--json", "Output raw JSON")
|
|
21
23
|
.option("-q, --quiet", "Minimal output (IDs only)")
|
|
22
24
|
.option("-w, --workspace <id>", "Override active workspace ID")
|
|
23
25
|
.option("--server <url>", "Override server URL");
|
|
24
26
|
// Register all command groups
|
|
27
|
+
registerInitCommand(program);
|
|
25
28
|
registerAuthCommands(program);
|
|
26
29
|
registerConfigCommands(program);
|
|
27
30
|
registerWorkspaceCommands(program);
|
|
@@ -34,5 +37,14 @@ registerTimelineCommands(program);
|
|
|
34
37
|
registerTypesCommands(program);
|
|
35
38
|
registerMemoryCommands(program);
|
|
36
39
|
registerMcpCommands(program);
|
|
40
|
+
// Default action: show help + first-run hint when invoked with no arguments
|
|
41
|
+
program.action(() => {
|
|
42
|
+
const config = loadConfig();
|
|
43
|
+
const sc = getServerConfig(config, config.currentServer);
|
|
44
|
+
if (!sc?.token) {
|
|
45
|
+
console.log('Tip: Run "cn init" to get started.\n');
|
|
46
|
+
}
|
|
47
|
+
program.help();
|
|
48
|
+
});
|
|
37
49
|
program.parse();
|
|
38
50
|
//# sourceMappingURL=cn.js.map
|
package/dist/cn.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cn.js","sourceRoot":"","sources":["../src/cn.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAA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;AACjB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/commands/auth.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
export declare function registerAuthCommands(program: Command): void;
|
|
3
|
+
export interface LoginResult {
|
|
4
|
+
email: string;
|
|
5
|
+
serverUrl: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function browserLogin(serverUrl: string, json: boolean, options?: {
|
|
8
|
+
quiet?: boolean;
|
|
9
|
+
}): Promise<LoginResult>;
|
|
3
10
|
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyG3D"}
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyG3D;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC5B,OAAO,CAAC,WAAW,CAAC,CA4FtB"}
|
package/dist/commands/auth.js
CHANGED
|
@@ -104,7 +104,8 @@ export function registerAuthCommands(program) {
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
async function browserLogin(serverUrl, json) {
|
|
107
|
+
export async function browserLogin(serverUrl, json, options) {
|
|
108
|
+
const quiet = options?.quiet ?? false;
|
|
108
109
|
return new Promise((resolve, reject) => {
|
|
109
110
|
const server = createServer((req, res) => {
|
|
110
111
|
const url = new URL(req.url || "/", `http://localhost`);
|
|
@@ -141,14 +142,16 @@ async function browserLogin(serverUrl, json) {
|
|
|
141
142
|
// Send success response (browser uses fetch, not redirect)
|
|
142
143
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
143
144
|
res.end(JSON.stringify({ ok: true }));
|
|
144
|
-
if (
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
if (!quiet) {
|
|
146
|
+
if (json) {
|
|
147
|
+
outputJson({ status: "authenticated", server: serverUrl, email });
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
console.log(`\nAuthenticated as ${email || "unknown"} on ${serverUrl}`);
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
153
|
server.close();
|
|
151
|
-
resolve();
|
|
154
|
+
resolve({ email: email || "unknown", serverUrl });
|
|
152
155
|
});
|
|
153
156
|
// Listen on ephemeral port
|
|
154
157
|
server.listen(0, "localhost", async () => {
|
|
@@ -159,7 +162,7 @@ async function browserLogin(serverUrl, json) {
|
|
|
159
162
|
}
|
|
160
163
|
const port = addr.port;
|
|
161
164
|
const authUrl = `${serverUrl}/auth/cli?callbackPort=${port}`;
|
|
162
|
-
if (!json) {
|
|
165
|
+
if (!quiet && !json) {
|
|
163
166
|
console.log("Opening browser for authentication...");
|
|
164
167
|
console.log(`If the browser doesn't open, visit: ${authUrl}`);
|
|
165
168
|
}
|
|
@@ -169,7 +172,7 @@ async function browserLogin(serverUrl, json) {
|
|
|
169
172
|
}
|
|
170
173
|
catch {
|
|
171
174
|
// If open fails, user can manually visit the URL
|
|
172
|
-
if (!json) {
|
|
175
|
+
if (!quiet && !json) {
|
|
173
176
|
console.log("Could not open browser automatically.");
|
|
174
177
|
}
|
|
175
178
|
}
|
|
@@ -1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AAC;gBACP,iDAAiD;gBACjD,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;oBACpB,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;gBACvD,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,0BAA0B;QAC1B,UAAU,CAAC,GAAG,EAAE;YACd,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC,CAAC;QACnE,CAAC,EAAE,OAAO,CAAC,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAiDpC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAqB1D"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { loadConfig, getServerConfig, } from "../lib/auth-store.js";
|
|
2
|
+
import { ApiClient } from "../lib/api-client.js";
|
|
3
|
+
import { browserLogin } from "./auth.js";
|
|
4
|
+
import { fetchAndSelectWorkspace } from "./workspace.js";
|
|
5
|
+
import { bold, dim, green, cyan, CHECK, ARROW, WARN } from "../lib/style.js";
|
|
6
|
+
function printBanner(version) {
|
|
7
|
+
const width = 41; // inner width of the box
|
|
8
|
+
const title = "CreatorNotes CLI";
|
|
9
|
+
const ver = `v${version}`;
|
|
10
|
+
const pad = (text) => text + " ".repeat(Math.max(0, width - 3 - text.length));
|
|
11
|
+
console.log();
|
|
12
|
+
console.log(" ┌" + "─".repeat(width) + "┐");
|
|
13
|
+
console.log(" │" + " ".repeat(width) + "│");
|
|
14
|
+
console.log(` │ ${bold(pad(title))}│`);
|
|
15
|
+
console.log(` │ ${dim(pad(ver))}│`);
|
|
16
|
+
console.log(" │" + " ".repeat(width) + "│");
|
|
17
|
+
console.log(" └" + "─".repeat(width) + "┘");
|
|
18
|
+
console.log();
|
|
19
|
+
}
|
|
20
|
+
function printStepHeader(step, total, label) {
|
|
21
|
+
const tag = dim(`── Step ${step} of ${total}:`);
|
|
22
|
+
const line = dim("─".repeat(Math.max(0, 40 - label.length)));
|
|
23
|
+
console.log(` ${tag} ${label} ${line}`);
|
|
24
|
+
console.log();
|
|
25
|
+
}
|
|
26
|
+
function printDivider(label) {
|
|
27
|
+
const line = dim("─".repeat(Math.max(0, 43 - label.length)));
|
|
28
|
+
console.log();
|
|
29
|
+
console.log(` ${dim("──")} ${bold(label)} ${line}`);
|
|
30
|
+
console.log();
|
|
31
|
+
}
|
|
32
|
+
function printNextSteps() {
|
|
33
|
+
console.log(` Next up — try these commands:`);
|
|
34
|
+
console.log();
|
|
35
|
+
console.log(` ${ARROW} ${cyan("cn notes list")} Browse your notes`);
|
|
36
|
+
console.log(` ${ARROW} ${cyan("cn notes create")} Create a new note`);
|
|
37
|
+
console.log(` ${ARROW} ${cyan('cn search "keyword"')} Search across everything`);
|
|
38
|
+
console.log(` ${ARROW} ${cyan("cn --help")} See all commands`);
|
|
39
|
+
console.log();
|
|
40
|
+
}
|
|
41
|
+
export function registerInitCommand(program) {
|
|
42
|
+
program
|
|
43
|
+
.command("init")
|
|
44
|
+
.description("Set up authentication and workspace")
|
|
45
|
+
.action(async () => {
|
|
46
|
+
try {
|
|
47
|
+
await runInit(program);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
// Clean exit on Ctrl+C during prompts
|
|
51
|
+
if (error &&
|
|
52
|
+
typeof error === "object" &&
|
|
53
|
+
"name" in error &&
|
|
54
|
+
error.name === "ExitPromptError") {
|
|
55
|
+
console.log("\n Setup cancelled.");
|
|
56
|
+
process.exit(0);
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function runInit(program) {
|
|
63
|
+
const version = program.version() || "0.1.0";
|
|
64
|
+
printBanner(version);
|
|
65
|
+
// Non-TTY: can't do interactive setup
|
|
66
|
+
if (!process.stdout.isTTY) {
|
|
67
|
+
console.log(" Non-interactive mode detected. Run these commands manually:");
|
|
68
|
+
console.log(` ${cyan("cn auth login --token <YOUR_TOKEN>")}`);
|
|
69
|
+
console.log(` ${cyan("cn workspace select <WORKSPACE_ID>")}`);
|
|
70
|
+
console.log();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// Detect current state
|
|
74
|
+
const config = loadConfig();
|
|
75
|
+
const serverUrl = config.currentServer;
|
|
76
|
+
const sc = getServerConfig(config, serverUrl);
|
|
77
|
+
const isAuthenticated = !!(sc?.token);
|
|
78
|
+
const hasWorkspace = !!(sc?.workspaceId);
|
|
79
|
+
// Already fully configured
|
|
80
|
+
if (isAuthenticated && hasWorkspace) {
|
|
81
|
+
console.log(` ${CHECK} Already authenticated as ${bold(sc?.email || "unknown")}`);
|
|
82
|
+
console.log(` ${CHECK} Workspace is active`);
|
|
83
|
+
console.log();
|
|
84
|
+
console.log(` You're all set! Here are some commands to try:`);
|
|
85
|
+
console.log();
|
|
86
|
+
printNextSteps();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Count remaining steps
|
|
90
|
+
const stepsNeeded = (isAuthenticated ? 0 : 1) + (hasWorkspace ? 0 : 1);
|
|
91
|
+
let currentStep = 0;
|
|
92
|
+
console.log(` Welcome! This will walk you through setup.`);
|
|
93
|
+
console.log();
|
|
94
|
+
// ── Step: Authentication ──────────────────────────────────
|
|
95
|
+
let email = sc?.email || "unknown";
|
|
96
|
+
if (!isAuthenticated) {
|
|
97
|
+
currentStep++;
|
|
98
|
+
printStepHeader(currentStep, stepsNeeded, "Authentication");
|
|
99
|
+
console.log(` Opening your browser to sign in...`);
|
|
100
|
+
const result = await browserLogin(serverUrl, false, { quiet: true });
|
|
101
|
+
email = result.email;
|
|
102
|
+
console.log(` ${CHECK} Authenticated as ${bold(email)}`);
|
|
103
|
+
console.log();
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
console.log(` ${CHECK} Authenticated as ${bold(email)} ${dim("(already configured)")}`);
|
|
107
|
+
console.log();
|
|
108
|
+
}
|
|
109
|
+
// Reload config to get current token (may have changed after auth)
|
|
110
|
+
const currentConfig = loadConfig();
|
|
111
|
+
const currentSc = getServerConfig(currentConfig, serverUrl);
|
|
112
|
+
const token = currentSc?.token || "";
|
|
113
|
+
// ── Step: Workspace ───────────────────────────────────────
|
|
114
|
+
let workspaceName = "";
|
|
115
|
+
if (!hasWorkspace) {
|
|
116
|
+
currentStep++;
|
|
117
|
+
printStepHeader(currentStep, stepsNeeded, "Workspace");
|
|
118
|
+
const result = await fetchAndSelectWorkspace(serverUrl, token);
|
|
119
|
+
if (!result) {
|
|
120
|
+
console.log(` ${WARN} No workspaces found. Create one at ${cyan(serverUrl)} first.`);
|
|
121
|
+
console.log();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
workspaceName = result.name;
|
|
125
|
+
console.log(` ${CHECK} Workspace ${bold(`"${workspaceName}"`)} selected`);
|
|
126
|
+
console.log();
|
|
127
|
+
}
|
|
128
|
+
// ── Verification ──────────────────────────────────────────
|
|
129
|
+
printDivider("All set!");
|
|
130
|
+
// Reload final state
|
|
131
|
+
const finalSc = getServerConfig(loadConfig(), serverUrl);
|
|
132
|
+
console.log(` ${CHECK} ${dim("Authentication")} ${email}`);
|
|
133
|
+
if (workspaceName) {
|
|
134
|
+
console.log(` ${CHECK} ${dim("Workspace")} ${workspaceName}`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
console.log(` ${CHECK} ${dim("Workspace")} active`);
|
|
138
|
+
}
|
|
139
|
+
// Quick connectivity check
|
|
140
|
+
if (finalSc?.token && finalSc?.workspaceId) {
|
|
141
|
+
try {
|
|
142
|
+
const api = new ApiClient(serverUrl, finalSc.token);
|
|
143
|
+
await api.get(`/api/notes?workspaceId=${finalSc.workspaceId}&limit=1&excludeContent=true`);
|
|
144
|
+
console.log(` ${CHECK} ${dim("Connection")} ${green("connected")}`);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
console.log(` ${WARN} ${dim("Connection")} could not reach API`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
console.log();
|
|
151
|
+
printNextSteps();
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE7E,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC,yBAAyB;IAC3C,MAAM,KAAK,GAAG,kBAAkB,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,OAAO,EAAE,CAAC;IAC1B,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACtF,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,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AC;YACpD,MAAM,GAAG,CAAC,GAAG,CACX,0BAA0B,OAAO,CAAC,WAAW,8BAA8B,CAC5E,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,GAAG,CAAC,YAAY,CAAC,WAAW,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI,GAAG,CAAC,YAAY,CAAC,6BAA6B,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,EAAE,CAAC;IACd,cAAc,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
+
export interface WorkspaceChoice {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Select a workspace from a pre-fetched list, or fetch from the API if not provided.
|
|
8
|
+
* Auto-selects if only one workspace exists.
|
|
9
|
+
* Returns null if no workspaces are available.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchAndSelectWorkspace(serverUrl: string, token: string, currentWorkspaceId?: string, prefetchedWorkspaces?: Array<Record<string, unknown>>): Promise<WorkspaceChoice | null>;
|
|
2
12
|
export declare function registerWorkspaceCommands(program: Command): void;
|
|
3
13
|
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/commands/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/commands/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,kBAAkB,CAAC,EAAE,MAAM,EAC3B,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACpD,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAoCjC;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmGhE"}
|
|
@@ -4,6 +4,44 @@ import { resolveBaseConfig } from "../lib/config.js";
|
|
|
4
4
|
import { loadConfig, setWorkspaceId } from "../lib/auth-store.js";
|
|
5
5
|
import { handleError, AuthError } from "../lib/errors.js";
|
|
6
6
|
import { outputJson, outputTable } from "../lib/output.js";
|
|
7
|
+
/**
|
|
8
|
+
* Select a workspace from a pre-fetched list, or fetch from the API if not provided.
|
|
9
|
+
* Auto-selects if only one workspace exists.
|
|
10
|
+
* Returns null if no workspaces are available.
|
|
11
|
+
*/
|
|
12
|
+
export async function fetchAndSelectWorkspace(serverUrl, token, currentWorkspaceId, prefetchedWorkspaces) {
|
|
13
|
+
let list;
|
|
14
|
+
if (prefetchedWorkspaces) {
|
|
15
|
+
list = prefetchedWorkspaces;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
const api = new ApiClient(serverUrl, token);
|
|
19
|
+
const data = await api.get("/api/workspaces");
|
|
20
|
+
const workspaces = data.workspaces || data;
|
|
21
|
+
list = Array.isArray(workspaces) ? workspaces : [];
|
|
22
|
+
}
|
|
23
|
+
if (list.length === 0)
|
|
24
|
+
return null;
|
|
25
|
+
let chosenId;
|
|
26
|
+
let chosenName;
|
|
27
|
+
if (list.length === 1) {
|
|
28
|
+
chosenId = String(list[0]._id || list[0].id || "");
|
|
29
|
+
chosenName = String(list[0].name || "(unnamed)");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
chosenId = await select({
|
|
33
|
+
message: "Select a workspace to activate:",
|
|
34
|
+
choices: list.map((w) => ({
|
|
35
|
+
name: `${String(w.name || "(unnamed)")}${(w._id || w.id) === currentWorkspaceId ? " (active)" : ""}`,
|
|
36
|
+
value: String(w._id || w.id || ""),
|
|
37
|
+
})),
|
|
38
|
+
});
|
|
39
|
+
chosenName = String(list.find((w) => String(w._id || w.id) === chosenId)?.name || "(unnamed)");
|
|
40
|
+
}
|
|
41
|
+
const config = loadConfig();
|
|
42
|
+
setWorkspaceId(config, serverUrl, chosenId);
|
|
43
|
+
return { id: chosenId, name: chosenName };
|
|
44
|
+
}
|
|
7
45
|
export function registerWorkspaceCommands(program) {
|
|
8
46
|
const ws = program
|
|
9
47
|
.command("workspace")
|
|
@@ -26,21 +64,13 @@ export function registerWorkspaceCommands(program) {
|
|
|
26
64
|
}
|
|
27
65
|
else if (process.stdout.isTTY) {
|
|
28
66
|
const list = Array.isArray(workspaces) ? workspaces : [];
|
|
29
|
-
|
|
67
|
+
const result = await fetchAndSelectWorkspace(cfg.serverUrl, cfg.token, cfg.workspaceId, list);
|
|
68
|
+
if (!result) {
|
|
30
69
|
console.log("No workspaces found.");
|
|
31
|
-
return;
|
|
32
70
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
name: `${String(w.name || "(unnamed)")}${(w._id || w.id) === cfg.workspaceId ? " (active)" : ""}`,
|
|
37
|
-
value: String(w._id || w.id || ""),
|
|
38
|
-
})),
|
|
39
|
-
});
|
|
40
|
-
const config = loadConfig();
|
|
41
|
-
setWorkspaceId(config, cfg.serverUrl, chosen);
|
|
42
|
-
const name = list.find((w) => String(w._id || w.id) === chosen)?.name;
|
|
43
|
-
console.log(`Active workspace set to ${name || chosen}`);
|
|
71
|
+
else {
|
|
72
|
+
console.log(`Active workspace set to ${result.name}`);
|
|
73
|
+
}
|
|
44
74
|
}
|
|
45
75
|
else {
|
|
46
76
|
const rows = (Array.isArray(workspaces) ? workspaces : []).map((w) => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/commands/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAc,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/commands/workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAc,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAO3D;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,SAAiB,EACjB,KAAa,EACb,kBAA2B,EAC3B,oBAAqD;IAErD,IAAI,IAAoC,CAAC;IACzC,IAAI,oBAAoB,EAAE,CAAC;QACzB,IAAI,GAAG,oBAAoB,CAAC;IAC9B,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,SAAS,EAAE,KAAK,CAA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MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC;YACpD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,GAAG,CAAyC,mBAAmB,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;YACzG,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC;YAEzC,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;gBACb,UAAU,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,cAAe,SAAiB,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC;gBAClE,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;gBAC7C,IAAK,SAAiB,CAAC,cAAc,EAAE,CAAC;oBACtC,OAAO,CAAC,GAAG,CAAC,cAAe,SAAiB,CAAC,cAAc,EAAE,CAAC,CAAC;gBACjE,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"auth-store.d.ts","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;CACvB;AAgBD,wBAAgB,UAAU,IAAI,SAAS,CAOtC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAQlD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAGvF;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,GACzB,IAAI,CAGN;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAG7E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAG3E;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,SAAS,EACjB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,GAClB,IAAI,CAMN"}
|
package/dist/lib/auth-store.js
CHANGED
|
@@ -3,11 +3,12 @@ import { join } from "node:path";
|
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
const CONFIG_DIR = join(homedir(), ".creatornotes");
|
|
5
5
|
const CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
6
|
+
const DEFAULT_SERVER = process.env.CN_SERVER_URL || "https://creatornotes.app";
|
|
6
7
|
function defaultConfig() {
|
|
7
8
|
return {
|
|
8
9
|
version: 1,
|
|
9
10
|
servers: {},
|
|
10
|
-
currentServer:
|
|
11
|
+
currentServer: DEFAULT_SERVER,
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
export function loadConfig() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAclC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD,SAAS,aAAa;IACpB,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"auth-store.js","sourceRoot":"","sources":["../../src/lib/auth-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAclC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAEpD,MAAM,cAAc,GAClB,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,0BAA0B,CAAC;AAE1D,SAAS,aAAa;IACpB,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,cAAc;KAC9B,CAAC;AACJ,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S,CAAC;IACjC,UAAU,CAAC,MAAM,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,MAAiB,EACjB,SAAiB,EACjB,WAAmB;IAEnB,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,EAAE,EAAE,CAAC;QACP,EAAE,CAAC,WAAW,GAAG,WAAW,CAAC;QAC7B,UAAU,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const bold: (text: string) => string;
|
|
2
|
+
export declare const dim: (text: string) => string;
|
|
3
|
+
export declare const green: (text: string) => string;
|
|
4
|
+
export declare const cyan: (text: string) => string;
|
|
5
|
+
export declare const yellow: (text: string) => string;
|
|
6
|
+
export declare const red: (text: string) => string;
|
|
7
|
+
export declare const CHECK: string;
|
|
8
|
+
export declare const ARROW: string;
|
|
9
|
+
export declare const WARN: string;
|
|
10
|
+
//# sourceMappingURL=style.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../src/lib/style.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,IAAI,SAJD,MAAM,WAIyB,CAAC;AAChD,eAAO,MAAM,GAAG,SALA,MAAM,WAKwB,CAAC;AAC/C,eAAO,MAAM,KAAK,SANF,MAAM,WAM2B,CAAC;AAClD,eAAO,MAAM,IAAI,SAPD,MAAM,WAO0B,CAAC;AACjD,eAAO,MAAM,MAAM,SARH,MAAM,WAQ4B,CAAC;AACnD,eAAO,MAAM,GAAG,SATA,MAAM,WASyB,CAAC;AAEhD,eAAO,MAAM,KAAK,QAAa,CAAC;AAChC,eAAO,MAAM,KAAK,QAAY,CAAC;AAC/B,eAAO,MAAM,IAAI,QAAc,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// ANSI escape code helpers — zero dependencies.
|
|
2
|
+
const isColorSupported = process.env.NO_COLOR === undefined &&
|
|
3
|
+
process.env.FORCE_COLOR !== "0" &&
|
|
4
|
+
(process.env.FORCE_COLOR !== undefined || process.stdout.isTTY);
|
|
5
|
+
function wrap(code, resetCode) {
|
|
6
|
+
return (text) => isColorSupported ? `${code}${text}${resetCode}` : text;
|
|
7
|
+
}
|
|
8
|
+
export const bold = wrap("\x1b[1m", "\x1b[22m");
|
|
9
|
+
export const dim = wrap("\x1b[2m", "\x1b[22m");
|
|
10
|
+
export const green = wrap("\x1b[32m", "\x1b[39m");
|
|
11
|
+
export const cyan = wrap("\x1b[36m", "\x1b[39m");
|
|
12
|
+
export const yellow = wrap("\x1b[33m", "\x1b[39m");
|
|
13
|
+
export const red = wrap("\x1b[31m", "\x1b[39m");
|
|
14
|
+
export const CHECK = green("✓");
|
|
15
|
+
export const ARROW = cyan("→");
|
|
16
|
+
export const WARN = yellow("!");
|
|
17
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/lib/style.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS;IAClC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,GAAG;IAC/B,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAElE,SAAS,IAAI,CAAC,IAAY,EAAE,SAAiB;IAC3C,OAAO,CAAC,IAAY,EAAE,EAAE,CACtB,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAChD,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEhD,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/B,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creator-notes/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
+
"README.md",
|
|
12
13
|
"SKILL.md"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|