@rewrlution/papyrus-cli 0.0.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 +699 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/auth/index.d.ts +2 -0
- package/dist/commands/auth/index.js +18 -0
- package/dist/commands/auth/index.js.map +1 -0
- package/dist/commands/auth/login.d.ts +1 -0
- package/dist/commands/auth/login.js +8 -0
- package/dist/commands/auth/login.js.map +1 -0
- package/dist/commands/auth/logout.d.ts +1 -0
- package/dist/commands/auth/logout.js +5 -0
- package/dist/commands/auth/logout.js.map +1 -0
- package/dist/commands/auth/register.d.ts +1 -0
- package/dist/commands/auth/register.js +8 -0
- package/dist/commands/auth/register.js.map +1 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/journal/add.d.ts +2 -0
- package/dist/commands/journal/add.js +5 -0
- package/dist/commands/journal/add.js.map +1 -0
- package/dist/commands/journal/amend.d.ts +2 -0
- package/dist/commands/journal/amend.js +5 -0
- package/dist/commands/journal/amend.js.map +1 -0
- package/dist/commands/journal/edit.d.ts +6 -0
- package/dist/commands/journal/edit.js +60 -0
- package/dist/commands/journal/edit.js.map +1 -0
- package/dist/commands/journal/index.d.ts +2 -0
- package/dist/commands/journal/index.js +32 -0
- package/dist/commands/journal/index.js.map +1 -0
- package/dist/commands/journal/list.d.ts +1 -0
- package/dist/commands/journal/list.js +20 -0
- package/dist/commands/journal/list.js.map +1 -0
- package/dist/commands/journal/show.d.ts +2 -0
- package/dist/commands/journal/show.js +35 -0
- package/dist/commands/journal/show.js.map +1 -0
- package/dist/commands/journal/sync.d.ts +1 -0
- package/dist/commands/journal/sync.js +9 -0
- package/dist/commands/journal/sync.js.map +1 -0
- package/dist/commands/types.d.ts +9 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/types.js.map +1 -0
- package/dist/components/Browser.d.ts +29 -0
- package/dist/components/Browser.js +124 -0
- package/dist/components/Browser.js.map +1 -0
- package/dist/components/BrowserFooter.d.ts +6 -0
- package/dist/components/BrowserFooter.js +6 -0
- package/dist/components/BrowserFooter.js.map +1 -0
- package/dist/components/BrowserHeader.d.ts +6 -0
- package/dist/components/BrowserHeader.js +6 -0
- package/dist/components/BrowserHeader.js.map +1 -0
- package/dist/components/ColdStart.d.ts +6 -0
- package/dist/components/ColdStart.js +24 -0
- package/dist/components/ColdStart.js.map +1 -0
- package/dist/components/FormInput.d.ts +10 -0
- package/dist/components/FormInput.js +7 -0
- package/dist/components/FormInput.js.map +1 -0
- package/dist/components/JournalListView.d.ts +10 -0
- package/dist/components/JournalListView.js +40 -0
- package/dist/components/JournalListView.js.map +1 -0
- package/dist/components/JournalViewer.d.ts +32 -0
- package/dist/components/JournalViewer.js +146 -0
- package/dist/components/JournalViewer.js.map +1 -0
- package/dist/components/LoginForm.d.ts +1 -0
- package/dist/components/LoginForm.js +68 -0
- package/dist/components/LoginForm.js.map +1 -0
- package/dist/components/Logo.d.ts +1 -0
- package/dist/components/Logo.js +57 -0
- package/dist/components/Logo.js.map +1 -0
- package/dist/components/RegisterForm.d.ts +1 -0
- package/dist/components/RegisterForm.js +72 -0
- package/dist/components/RegisterForm.js.map +1 -0
- package/dist/components/StatusMessage.d.ts +7 -0
- package/dist/components/StatusMessage.js +19 -0
- package/dist/components/StatusMessage.js.map +1 -0
- package/dist/components/SyncProgress.d.ts +1 -0
- package/dist/components/SyncProgress.js +46 -0
- package/dist/components/SyncProgress.js.map +1 -0
- package/dist/lib/api/api-client.d.ts +23 -0
- package/dist/lib/api/api-client.js +111 -0
- package/dist/lib/api/api-client.js.map +1 -0
- package/dist/lib/api/index.d.ts +3 -0
- package/dist/lib/api/index.js +6 -0
- package/dist/lib/api/index.js.map +1 -0
- package/dist/lib/auth/index.d.ts +1 -0
- package/dist/lib/auth/index.js +2 -0
- package/dist/lib/auth/index.js.map +1 -0
- package/dist/lib/auth/require-auth.d.ts +67 -0
- package/dist/lib/auth/require-auth.js +107 -0
- package/dist/lib/auth/require-auth.js.map +1 -0
- package/dist/lib/storage/base-storage.d.ts +50 -0
- package/dist/lib/storage/base-storage.js +91 -0
- package/dist/lib/storage/base-storage.js.map +1 -0
- package/dist/lib/storage/config-store.d.ts +40 -0
- package/dist/lib/storage/config-store.js +63 -0
- package/dist/lib/storage/config-store.js.map +1 -0
- package/dist/lib/storage/index.d.ts +12 -0
- package/dist/lib/storage/index.js +13 -0
- package/dist/lib/storage/index.js.map +1 -0
- package/dist/lib/storage/journal-storage.d.ts +46 -0
- package/dist/lib/storage/journal-storage.js +78 -0
- package/dist/lib/storage/journal-storage.js.map +1 -0
- package/dist/lib/storage/sync-meta-store.d.ts +37 -0
- package/dist/lib/storage/sync-meta-store.js +50 -0
- package/dist/lib/storage/sync-meta-store.js.map +1 -0
- package/dist/lib/storage/token-store.d.ts +25 -0
- package/dist/lib/storage/token-store.js +40 -0
- package/dist/lib/storage/token-store.js.map +1 -0
- package/dist/lib/sync/sync-engine.d.ts +13 -0
- package/dist/lib/sync/sync-engine.js +96 -0
- package/dist/lib/sync/sync-engine.js.map +1 -0
- package/dist/utils/date.d.ts +58 -0
- package/dist/utils/date.js +117 -0
- package/dist/utils/date.js.map +1 -0
- package/dist/utils/editor.d.ts +2 -0
- package/dist/utils/editor.js +81 -0
- package/dist/utils/editor.js.map +1 -0
- package/dist/utils/template.d.ts +2 -0
- package/dist/utils/template.js +17 -0
- package/dist/utils/template.js.map +1 -0
- package/dist/utils/token.d.ts +20 -0
- package/dist/utils/token.js +64 -0
- package/dist/utils/token.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
# Papyrus CLI
|
|
2
|
+
|
|
3
|
+
> AI-powered journaling for developers, right in your terminal.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@rewrlution/papyrus-cli)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
|
|
8
|
+
## What is Papyrus?
|
|
9
|
+
|
|
10
|
+
Papyrus is a command-line journaling tool designed for developers who want to capture their thoughts, progress, and insights without leaving the terminal. It combines the simplicity of markdown files with the power of cloud sync and AI assistance.
|
|
11
|
+
|
|
12
|
+
**Key Features:**
|
|
13
|
+
|
|
14
|
+
- 📝 **Quick Journaling** - Write journal entries in your favorite editor (vim, nano, VS Code)
|
|
15
|
+
- 📅 **Date-based Organization** - Entries organized by date (YYYYMMDD format)
|
|
16
|
+
- 🔍 **Interactive Browser** - Browse and read journals with vim-style navigation
|
|
17
|
+
- ☁️ **Cloud Sync** - Sync journals across devices
|
|
18
|
+
- 🔐 **Secure** - JWT authentication with local token storage
|
|
19
|
+
- 💾 **Local-First** - All journals stored locally in markdown format
|
|
20
|
+
- 🎨 **Terminal UI** - Beautiful React-based interface rendered in your terminal
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### From npm (Recommended)
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Install globally
|
|
28
|
+
npm install -g @rewrlution/papyrus-cli
|
|
29
|
+
|
|
30
|
+
# Or with pnpm
|
|
31
|
+
pnpm add -g @rewrlution/papyrus-cli
|
|
32
|
+
|
|
33
|
+
# Or with yarn
|
|
34
|
+
yarn global add @rewrlution/papyrus-cli
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### From Source (Development)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Clone the monorepo
|
|
41
|
+
git clone https://github.com/your-username/papyrus.git
|
|
42
|
+
cd papyrus
|
|
43
|
+
|
|
44
|
+
# Install dependencies
|
|
45
|
+
pnpm install
|
|
46
|
+
|
|
47
|
+
# Build packages
|
|
48
|
+
pnpm build
|
|
49
|
+
|
|
50
|
+
# Link CLI globally
|
|
51
|
+
cd packages/cli
|
|
52
|
+
pnpm link --global
|
|
53
|
+
|
|
54
|
+
# Now you can use papyrus anywhere
|
|
55
|
+
papyrus --version
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
### 1. Register an Account
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
papyrus register
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Follow the interactive prompts to create an account.
|
|
67
|
+
|
|
68
|
+
### 2. Log In
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
papyrus login
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Enter your email and password.
|
|
75
|
+
|
|
76
|
+
### 3. Create Your First Journal Entry
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
papyrus add
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
This opens your default editor. Write your thoughts, save, and close.
|
|
83
|
+
|
|
84
|
+
### 4. Browse Your Journals
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
papyrus list
|
|
88
|
+
# Or use the short alias
|
|
89
|
+
papyrus ls
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Use arrow keys or `j/k` to navigate, press `Enter` to read an entry.
|
|
93
|
+
|
|
94
|
+
### 5. Sync to Cloud
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
papyrus sync
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Your journals are now backed up and available on other devices!
|
|
101
|
+
|
|
102
|
+
## Commands
|
|
103
|
+
|
|
104
|
+
### Journal Commands
|
|
105
|
+
|
|
106
|
+
#### `papyrus add [-d <date>]`
|
|
107
|
+
|
|
108
|
+
Create a new journal entry.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Create entry for today
|
|
112
|
+
papyrus add
|
|
113
|
+
|
|
114
|
+
# Create entry for specific date
|
|
115
|
+
papyrus add -d 20260104
|
|
116
|
+
papyrus add -d yesterday
|
|
117
|
+
papyrus add -d tomorrow
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**What it does:**
|
|
121
|
+
|
|
122
|
+
- Opens your default editor ($EDITOR, $VISUAL, or fallback)
|
|
123
|
+
- Creates a new markdown file in `~/.local/share/papyrus/journals/`
|
|
124
|
+
- Filename format: `YYYYMMDD.md`
|
|
125
|
+
|
|
126
|
+
#### `papyrus amend [-d <date>]`
|
|
127
|
+
|
|
128
|
+
Modify an existing journal entry.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# Amend today's entry
|
|
132
|
+
papyrus amend
|
|
133
|
+
|
|
134
|
+
# Amend specific date
|
|
135
|
+
papyrus amend -d 20260103
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**What it does:**
|
|
139
|
+
|
|
140
|
+
- Opens existing journal in your editor
|
|
141
|
+
- Fails if entry doesn't exist (use `add` to create)
|
|
142
|
+
|
|
143
|
+
#### `papyrus show [-d <date>]`
|
|
144
|
+
|
|
145
|
+
Display a journal entry in the terminal.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Show today's entry
|
|
149
|
+
papyrus show
|
|
150
|
+
|
|
151
|
+
# Show specific date
|
|
152
|
+
papyrus show -d 20260101
|
|
153
|
+
papyrus show -d yesterday
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Features:**
|
|
157
|
+
|
|
158
|
+
- Scrollable viewer with line numbers
|
|
159
|
+
- Vim-style navigation (`j/k`, `g/G`, `h/l`)
|
|
160
|
+
- Horizontal panning for long lines
|
|
161
|
+
- Progress indicator
|
|
162
|
+
|
|
163
|
+
**Keyboard Shortcuts:**
|
|
164
|
+
|
|
165
|
+
- `↑`/`↓` or `j`/`k` - Scroll up/down
|
|
166
|
+
- `←`/`→` or `h`/`l` - Pan left/right
|
|
167
|
+
- `PgUp`/`PgDn` or `Space` - Page up/down
|
|
168
|
+
- `g` or `Home` - Jump to top
|
|
169
|
+
- `G` or `End` - Jump to bottom
|
|
170
|
+
- `0` - Jump to start of line
|
|
171
|
+
- `q` or `Esc` - Quit
|
|
172
|
+
|
|
173
|
+
#### `papyrus list` or `papyrus ls`
|
|
174
|
+
|
|
175
|
+
Browse all journal entries interactively.
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
papyrus list
|
|
179
|
+
# Or
|
|
180
|
+
papyrus ls
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Features:**
|
|
184
|
+
|
|
185
|
+
- Virtual scrolling (handles 1000+ entries smoothly)
|
|
186
|
+
- Circular navigation (wraps at top/bottom)
|
|
187
|
+
- Today marker (blue dot)
|
|
188
|
+
- Selection indicator
|
|
189
|
+
|
|
190
|
+
**Keyboard Shortcuts:**
|
|
191
|
+
|
|
192
|
+
- `↑`/`↓` or `j`/`k` - Navigate list
|
|
193
|
+
- `Enter` or `Space` - Open entry in reader
|
|
194
|
+
- `q` or `Esc` - Quit (in list view) or return to list (in reader)
|
|
195
|
+
|
|
196
|
+
#### `papyrus sync`
|
|
197
|
+
|
|
198
|
+
Sync journals with the cloud.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
papyrus sync
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**What it does:**
|
|
205
|
+
|
|
206
|
+
- Compares local and remote journals using content hashes
|
|
207
|
+
- Uploads new/modified entries
|
|
208
|
+
- Downloads remote changes
|
|
209
|
+
- Resolves conflicts automatically (merges both versions)
|
|
210
|
+
- Shows progress with real-time updates
|
|
211
|
+
|
|
212
|
+
**Requires:** Authentication (run `papyrus login` first)
|
|
213
|
+
|
|
214
|
+
### Authentication Commands
|
|
215
|
+
|
|
216
|
+
#### `papyrus register`
|
|
217
|
+
|
|
218
|
+
Create a new account.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
papyrus register
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
**Interactive prompts:**
|
|
225
|
+
|
|
226
|
+
1. Email address
|
|
227
|
+
2. Password (min 8 chars, uppercase, lowercase, number, special char)
|
|
228
|
+
3. Confirm password
|
|
229
|
+
|
|
230
|
+
#### `papyrus login`
|
|
231
|
+
|
|
232
|
+
Log in to your account.
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
papyrus login
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Interactive prompts:**
|
|
239
|
+
|
|
240
|
+
1. Email address
|
|
241
|
+
2. Password
|
|
242
|
+
|
|
243
|
+
**What it does:**
|
|
244
|
+
|
|
245
|
+
- Authenticates with the server
|
|
246
|
+
- Stores JWT token locally in `~/.config/papyrus/token`
|
|
247
|
+
- Token expires after 7 days (configurable)
|
|
248
|
+
|
|
249
|
+
#### `papyrus logout`
|
|
250
|
+
|
|
251
|
+
Log out and clear stored token.
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
papyrus logout
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## Configuration
|
|
258
|
+
|
|
259
|
+
### Storage Locations
|
|
260
|
+
|
|
261
|
+
Papyrus follows the XDG Base Directory specification:
|
|
262
|
+
|
|
263
|
+
**On Linux/macOS:**
|
|
264
|
+
|
|
265
|
+
- Journals: `~/.local/share/papyrus/journals/`
|
|
266
|
+
- Config: `~/.config/papyrus/`
|
|
267
|
+
- Token: `~/.config/papyrus/token`
|
|
268
|
+
- Sync metadata: `~/.local/share/papyrus/sync-meta.json`
|
|
269
|
+
|
|
270
|
+
**On Windows:**
|
|
271
|
+
|
|
272
|
+
- Journals: `%LOCALAPPDATA%\papyrus\journals\`
|
|
273
|
+
- Config: `%APPDATA%\papyrus\`
|
|
274
|
+
- Token: `%APPDATA%\papyrus\token`
|
|
275
|
+
- Sync metadata: `%LOCALAPPDATA%\papyrus\sync-meta.json`
|
|
276
|
+
|
|
277
|
+
### Editor Configuration
|
|
278
|
+
|
|
279
|
+
Papyrus uses your system's default editor. Priority order:
|
|
280
|
+
|
|
281
|
+
1. `$EDITOR` environment variable
|
|
282
|
+
2. `$VISUAL` environment variable
|
|
283
|
+
3. Detected editors: `vim`, `vi`, `nano`, `code` (VS Code), `notepad` (Windows)
|
|
284
|
+
|
|
285
|
+
**Set your preferred editor:**
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Bash/Zsh
|
|
289
|
+
export EDITOR=vim
|
|
290
|
+
|
|
291
|
+
# Or add to ~/.bashrc or ~/.zshrc
|
|
292
|
+
echo 'export EDITOR=vim' >> ~/.bashrc
|
|
293
|
+
|
|
294
|
+
# Windows (PowerShell)
|
|
295
|
+
$env:EDITOR = "code --wait"
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**VS Code users:** Add `--wait` flag so Papyrus waits for you to close the file:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
export EDITOR="code --wait"
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Date Formats
|
|
305
|
+
|
|
306
|
+
Papyrus accepts flexible date input:
|
|
307
|
+
|
|
308
|
+
- `today` - Current date
|
|
309
|
+
- `yesterday` - One day ago
|
|
310
|
+
- `tomorrow` - One day ahead
|
|
311
|
+
- `YYYYMMDD` - Specific date (e.g., `20260104`)
|
|
312
|
+
- `YYYY-MM-DD` - ISO format (e.g., `2026-01-04`)
|
|
313
|
+
- `+N` or `-N` - Days from today (e.g., `+7`, `-3`)
|
|
314
|
+
|
|
315
|
+
## Development
|
|
316
|
+
|
|
317
|
+
### Prerequisites
|
|
318
|
+
|
|
319
|
+
- Node.js 18 or higher
|
|
320
|
+
- pnpm 10 or higher
|
|
321
|
+
- Git
|
|
322
|
+
|
|
323
|
+
### Setup Development Environment
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Clone monorepo
|
|
327
|
+
git clone https://github.com/your-username/papyrus.git
|
|
328
|
+
cd papyrus
|
|
329
|
+
|
|
330
|
+
# Install dependencies
|
|
331
|
+
pnpm install
|
|
332
|
+
|
|
333
|
+
# Build shared package (required dependency)
|
|
334
|
+
cd packages/shared
|
|
335
|
+
pnpm build
|
|
336
|
+
|
|
337
|
+
# Return to CLI package
|
|
338
|
+
cd ../cli
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Development Workflow
|
|
342
|
+
|
|
343
|
+
```bash
|
|
344
|
+
# Watch mode (auto-reloads on changes)
|
|
345
|
+
pnpm dev
|
|
346
|
+
|
|
347
|
+
# Build
|
|
348
|
+
pnpm build
|
|
349
|
+
|
|
350
|
+
# Run tests
|
|
351
|
+
pnpm test
|
|
352
|
+
|
|
353
|
+
# Run built CLI
|
|
354
|
+
pnpm start
|
|
355
|
+
|
|
356
|
+
# Or run directly with tsx
|
|
357
|
+
tsx src/cli.tsx add --date today
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Project Structure
|
|
361
|
+
|
|
362
|
+
```
|
|
363
|
+
packages/cli/
|
|
364
|
+
├── src/
|
|
365
|
+
│ ├── cli.tsx # Entry point
|
|
366
|
+
│ ├── commands/ # Command handlers
|
|
367
|
+
│ │ ├── auth/ # Auth commands (login, register, logout)
|
|
368
|
+
│ │ └── journal/ # Journal commands (add, show, list, sync)
|
|
369
|
+
│ ├── components/ # React/Ink UI components
|
|
370
|
+
│ ├── lib/ # Business logic
|
|
371
|
+
│ │ ├── api/ # API client
|
|
372
|
+
│ │ ├── auth/ # Auth middleware
|
|
373
|
+
│ │ ├── storage/ # Local storage
|
|
374
|
+
│ │ └── sync/ # Sync engine
|
|
375
|
+
│ └── utils/ # Utilities (date, editor, token)
|
|
376
|
+
├── docs/ # Documentation
|
|
377
|
+
├── tests/ # Tests
|
|
378
|
+
├── dist/ # Build output
|
|
379
|
+
└── package.json
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### Running Tests
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
# Run tests once
|
|
386
|
+
pnpm test
|
|
387
|
+
|
|
388
|
+
# Watch mode
|
|
389
|
+
pnpm test --watch
|
|
390
|
+
|
|
391
|
+
# With UI
|
|
392
|
+
pnpm test --ui
|
|
393
|
+
|
|
394
|
+
# From monorepo root
|
|
395
|
+
pnpm test --filter=@rewrlution/papyrus-cli
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Local Testing
|
|
399
|
+
|
|
400
|
+
Test the CLI as if installed globally:
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
# Build and link
|
|
404
|
+
pnpm build
|
|
405
|
+
pnpm link --global
|
|
406
|
+
|
|
407
|
+
# Test commands
|
|
408
|
+
papyrus --version
|
|
409
|
+
papyrus add
|
|
410
|
+
|
|
411
|
+
# Unlink when done
|
|
412
|
+
pnpm unlink --global
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
### Building for Production
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
# Clean build
|
|
419
|
+
rm -rf dist
|
|
420
|
+
pnpm build
|
|
421
|
+
|
|
422
|
+
# Test tarball (simulates npm publish)
|
|
423
|
+
npm pack
|
|
424
|
+
|
|
425
|
+
# Install from tarball
|
|
426
|
+
npm install -g ./rewrlution-papyrus-cli-*.tgz
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Deployment
|
|
430
|
+
|
|
431
|
+
### Versioning
|
|
432
|
+
|
|
433
|
+
Papyrus follows [Semantic Versioning](https://semver.org/):
|
|
434
|
+
|
|
435
|
+
- **MAJOR**: Breaking changes (e.g., command renamed)
|
|
436
|
+
- **MINOR**: New features (e.g., new command added)
|
|
437
|
+
- **PATCH**: Bug fixes (e.g., error handling fixed)
|
|
438
|
+
|
|
439
|
+
### Release Process
|
|
440
|
+
|
|
441
|
+
```bash
|
|
442
|
+
# 1. Update version in package.json
|
|
443
|
+
vim packages/cli/package.json
|
|
444
|
+
# Change "version": "0.0.1" to "0.0.2"
|
|
445
|
+
|
|
446
|
+
# 2. Update CHANGELOG.md
|
|
447
|
+
vim packages/cli/CHANGELOG.md
|
|
448
|
+
# Document changes
|
|
449
|
+
|
|
450
|
+
# 3. Commit changes
|
|
451
|
+
git add packages/cli/package.json packages/cli/CHANGELOG.md
|
|
452
|
+
git commit -m "chore(cli): bump version to 0.0.2"
|
|
453
|
+
|
|
454
|
+
# 4. Create tag
|
|
455
|
+
# For bug fixes (1.0.0 → 1.0.1)
|
|
456
|
+
npm version patch
|
|
457
|
+
git push --follow-tags
|
|
458
|
+
|
|
459
|
+
# For new features (1.0.0 → 1.1.0)
|
|
460
|
+
npm version minor
|
|
461
|
+
git push --follow-tags
|
|
462
|
+
|
|
463
|
+
# For breaking changes (1.0.0 → 2.0.0)
|
|
464
|
+
npm version major
|
|
465
|
+
git push --follow-tags
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The `npm version` command:
|
|
469
|
+
|
|
470
|
+
- ✅ Updates `package.json`
|
|
471
|
+
- ✅ Creates a git commit
|
|
472
|
+
- ✅ Creates a git tag
|
|
473
|
+
- ✅ All in one command!
|
|
474
|
+
|
|
475
|
+
## Quick Reference Card:
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# Normal development (no publish)
|
|
479
|
+
git add .
|
|
480
|
+
git commit -m "Add feature"
|
|
481
|
+
git push origin main
|
|
482
|
+
|
|
483
|
+
# When ready to release (publishes to npm)
|
|
484
|
+
npm version patch # or minor/major
|
|
485
|
+
git push --follow-tags
|
|
486
|
+
|
|
487
|
+
# Delete tags (only use it if you create a tag by mistake)
|
|
488
|
+
git tag -d v1.0.0
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**For detailed deployment instructions, see [Deployment Guide](./docs/10-DEPLOYMENT-GUIDE.md).**
|
|
492
|
+
|
|
493
|
+
## Architecture
|
|
494
|
+
|
|
495
|
+
### Technology Stack
|
|
496
|
+
|
|
497
|
+
- **TypeScript** - Type-safe development
|
|
498
|
+
- **Commander.js** - CLI framework (git-like commands)
|
|
499
|
+
- **Ink** - React for terminal UIs
|
|
500
|
+
- **React** - UI component library
|
|
501
|
+
- **Axios** - HTTP client for API calls
|
|
502
|
+
- **date-fns** - Date manipulation
|
|
503
|
+
- **env-paths** - XDG-compliant path resolution
|
|
504
|
+
- **Zod** - Runtime type validation (from shared package)
|
|
505
|
+
|
|
506
|
+
### Key Design Decisions
|
|
507
|
+
|
|
508
|
+
**Why Ink (React)?**
|
|
509
|
+
|
|
510
|
+
- Declarative UI (easier than imperative terminal APIs)
|
|
511
|
+
- Component reusability
|
|
512
|
+
- State management with hooks
|
|
513
|
+
- Familiar for React developers
|
|
514
|
+
|
|
515
|
+
**Why Local-First?**
|
|
516
|
+
|
|
517
|
+
- Fast (no network latency)
|
|
518
|
+
- Works offline
|
|
519
|
+
- User owns their data (markdown files)
|
|
520
|
+
- Sync is optional enhancement
|
|
521
|
+
|
|
522
|
+
**Why XDG Base Directory?**
|
|
523
|
+
|
|
524
|
+
- Standard on Linux/Unix
|
|
525
|
+
- Predictable locations
|
|
526
|
+
- Respects user preferences
|
|
527
|
+
- Clean home directory
|
|
528
|
+
|
|
529
|
+
**Why Hash-Based Sync?**
|
|
530
|
+
|
|
531
|
+
- Efficient (compare hashes, not full content)
|
|
532
|
+
- Detects changes reliably
|
|
533
|
+
- Enables three-way merge
|
|
534
|
+
- No server-side state required
|
|
535
|
+
|
|
536
|
+
## Troubleshooting
|
|
537
|
+
|
|
538
|
+
### "Command not found: papyrus"
|
|
539
|
+
|
|
540
|
+
**Cause:** CLI not installed or not in PATH.
|
|
541
|
+
|
|
542
|
+
**Solution:**
|
|
543
|
+
|
|
544
|
+
```bash
|
|
545
|
+
# Check if installed
|
|
546
|
+
npm list -g @rewrlution/papyrus-cli
|
|
547
|
+
|
|
548
|
+
# Reinstall
|
|
549
|
+
npm install -g @rewrlution/papyrus-cli
|
|
550
|
+
|
|
551
|
+
# Check PATH
|
|
552
|
+
echo $PATH # Should include npm global bin directory
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
### "No text editor found"
|
|
556
|
+
|
|
557
|
+
**Cause:** No supported editor detected.
|
|
558
|
+
|
|
559
|
+
**Solution:**
|
|
560
|
+
|
|
561
|
+
```bash
|
|
562
|
+
# Set EDITOR environment variable
|
|
563
|
+
export EDITOR=vim
|
|
564
|
+
|
|
565
|
+
# Or install a supported editor
|
|
566
|
+
sudo apt-get install vim # Linux
|
|
567
|
+
brew install vim # macOS
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
### "Not authenticated"
|
|
571
|
+
|
|
572
|
+
**Cause:** Not logged in or token expired.
|
|
573
|
+
|
|
574
|
+
**Solution:**
|
|
575
|
+
|
|
576
|
+
```bash
|
|
577
|
+
# Log in again
|
|
578
|
+
papyrus login
|
|
579
|
+
|
|
580
|
+
# Check token status
|
|
581
|
+
ls ~/.config/papyrus/token # Should exist
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
### "Sync failed"
|
|
585
|
+
|
|
586
|
+
**Cause:** Network issues or server down.
|
|
587
|
+
|
|
588
|
+
**Solution:**
|
|
589
|
+
|
|
590
|
+
```bash
|
|
591
|
+
# Check internet connection
|
|
592
|
+
ping api.papyrus.com
|
|
593
|
+
|
|
594
|
+
# Try again later
|
|
595
|
+
papyrus sync
|
|
596
|
+
|
|
597
|
+
# Check server status
|
|
598
|
+
# https://status.papyrus.com (if available)
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
### "Cannot find module '@rewrlution/papyrus-shared'"
|
|
602
|
+
|
|
603
|
+
**Cause:** Development environment not set up correctly.
|
|
604
|
+
|
|
605
|
+
**Solution:**
|
|
606
|
+
|
|
607
|
+
```bash
|
|
608
|
+
# Build shared package first
|
|
609
|
+
cd packages/shared
|
|
610
|
+
pnpm build
|
|
611
|
+
|
|
612
|
+
# Then build CLI
|
|
613
|
+
cd ../cli
|
|
614
|
+
pnpm build
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
## Contributing
|
|
618
|
+
|
|
619
|
+
We welcome contributions! Here's how you can help:
|
|
620
|
+
|
|
621
|
+
### Reporting Bugs
|
|
622
|
+
|
|
623
|
+
1. Check existing issues: https://github.com/your-username/papyrus/issues
|
|
624
|
+
2. Create new issue with:
|
|
625
|
+
- Clear description
|
|
626
|
+
- Steps to reproduce
|
|
627
|
+
- Expected vs actual behavior
|
|
628
|
+
- Environment (OS, Node version)
|
|
629
|
+
- Error messages/screenshots
|
|
630
|
+
|
|
631
|
+
### Suggesting Features
|
|
632
|
+
|
|
633
|
+
1. Open a discussion: https://github.com/your-username/papyrus/discussions
|
|
634
|
+
2. Describe the feature and use case
|
|
635
|
+
3. Consider implementation approach
|
|
636
|
+
4. Be open to feedback
|
|
637
|
+
|
|
638
|
+
### Contributing Code
|
|
639
|
+
|
|
640
|
+
1. Fork the repository
|
|
641
|
+
2. Create a feature branch: `git checkout -b feature/my-feature`
|
|
642
|
+
3. Make changes following code style
|
|
643
|
+
4. Add tests
|
|
644
|
+
5. Update documentation
|
|
645
|
+
6. Run tests: `pnpm test`
|
|
646
|
+
7. Run linter: `pnpm lint`
|
|
647
|
+
8. Commit: `git commit -m "feat(cli): add search command"`
|
|
648
|
+
9. Push: `git push origin feature/my-feature`
|
|
649
|
+
10. Open Pull Request
|
|
650
|
+
|
|
651
|
+
**Code Style:**
|
|
652
|
+
|
|
653
|
+
- Use TypeScript
|
|
654
|
+
- Follow existing patterns
|
|
655
|
+
- Add JSDoc comments for public APIs
|
|
656
|
+
- Keep functions small and focused
|
|
657
|
+
- Write tests for new features
|
|
658
|
+
|
|
659
|
+
**Commit Messages:**
|
|
660
|
+
|
|
661
|
+
- Follow [Conventional Commits](https://www.conventionalcommits.org/)
|
|
662
|
+
- Format: `type(scope): description`
|
|
663
|
+
- Types: `feat`, `fix`, `docs`, `chore`, `test`, `refactor`
|
|
664
|
+
- Examples:
|
|
665
|
+
- `feat(cli): add search command`
|
|
666
|
+
- `fix(sync): handle conflict resolution`
|
|
667
|
+
- `docs: update README with examples`
|
|
668
|
+
|
|
669
|
+
## Documentation
|
|
670
|
+
|
|
671
|
+
- **[CLAUDE.md](./CLAUDE.md)** - Complete development guide
|
|
672
|
+
- **[Deployment Guide](./docs/10-DEPLOYMENT-GUIDE.md)** - CI/CD and npm publishing
|
|
673
|
+
- **[Tutorials](./docs/)** - Step-by-step implementation guides
|
|
674
|
+
- **[Architecture Decisions](./docs/)** - Design rationale
|
|
675
|
+
|
|
676
|
+
## License
|
|
677
|
+
|
|
678
|
+
MIT License - see [LICENSE](../../LICENSE) file for details.
|
|
679
|
+
|
|
680
|
+
## Support
|
|
681
|
+
|
|
682
|
+
- **GitHub Issues**: https://github.com/your-username/papyrus/issues
|
|
683
|
+
- **Discussions**: https://github.com/your-username/papyrus/discussions
|
|
684
|
+
- **Email**: support@papyrus.com (if available)
|
|
685
|
+
|
|
686
|
+
## Acknowledgments
|
|
687
|
+
|
|
688
|
+
Built with:
|
|
689
|
+
|
|
690
|
+
- [Commander.js](https://github.com/tj/commander.js) - CLI framework
|
|
691
|
+
- [Ink](https://github.com/vadimdemedes/ink) - Terminal UI
|
|
692
|
+
- [React](https://react.dev) - UI library
|
|
693
|
+
- [Zod](https://zod.dev) - Validation
|
|
694
|
+
|
|
695
|
+
---
|
|
696
|
+
|
|
697
|
+
**Made with ❤️ by developers, for developers.**
|
|
698
|
+
|
|
699
|
+
Happy journaling! 📝
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { render } from 'ink';
|
|
5
|
+
import { registerJournalCommands, registerAuthCommands, } from './commands/index.js';
|
|
6
|
+
import { Logo } from './components/Logo.js';
|
|
7
|
+
render(_jsx(Logo, {}));
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name('papyrus')
|
|
11
|
+
.description('AI-powered developer journaling')
|
|
12
|
+
.version('1.0.0');
|
|
13
|
+
registerAuthCommands(program);
|
|
14
|
+
registerJournalCommands(program);
|
|
15
|
+
program.parse(process.argv);
|
|
16
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";;AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,MAAM,CAAC,KAAC,IAAI,KAAG,CAAC,CAAC;AAEjB,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CAAC,iCAAiC,CAAC;KAC9C,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAC9B,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAEjC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|