@kiipu/cli 0.0.9 → 0.0.10

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.
@@ -43,13 +43,13 @@ export function getHelpResult(command) {
43
43
  'Kiipu CLI',
44
44
  '',
45
45
  'Usage:',
46
- ' kiipu note create --content "<text>"',
47
- ' kiipu note create "<text>"',
46
+ ' kiipu note create --content "<text>" [--title "<title>"]',
47
+ ' kiipu note create "<text>" [--title "<title>"]',
48
48
  ' kiipu note list [--tag <tag>] [--sort <updatedAt|createdAt|title>] [--starred] [--deleted]',
49
49
  ' kiipu note search <query>',
50
50
  ' kiipu note search --query "<query>"',
51
51
  ' kiipu note show --id <noteId>',
52
- ' kiipu note update --id <noteId> --content "<text>" [--title "<title>"] [--visibility public|private] [--tags <a,b,c>]',
52
+ ' kiipu note update --id <noteId> --content "<text>" [--title "<title>"] [--visibility public|private]',
53
53
  ' kiipu note star --id <noteId>',
54
54
  ' kiipu note pin --id <noteId>',
55
55
  ' kiipu note delete --id <noteId>',
@@ -79,16 +79,16 @@ export function getHelpResult(command) {
79
79
  ' --sort <field> One of updatedAt, createdAt, or title',
80
80
  ' --starred List only starred notes',
81
81
  ' --deleted List only deleted notes',
82
- ' --title "<title>" Optional title for note update',
82
+ ' --title "<title>" Optional title for note create or update',
83
83
  ' --visibility <value> Optional visibility for note update',
84
- ' --tags <a,b,c> Optional comma-separated tags for note update',
84
+ ' Tags are derived from #tag tokens in note content',
85
85
  '',
86
86
  'Examples:',
87
- ' kiipu note create "Hello Kiipu"',
87
+ ' kiipu note create "Hello Kiipu" --title "Welcome"',
88
88
  ' kiipu note list --sort updatedAt',
89
89
  ' kiipu note search "roadmap"',
90
90
  ' kiipu note show --id 123',
91
- ' kiipu note update --id 123 --content "Updated text" --tags work,#notes',
91
+ ' kiipu note update --id 123 --content "Updated text #work #notes"',
92
92
  ' kiipu note star --id 123',
93
93
  ' kiipu note pin --id 123',
94
94
  ' kiipu note create --content "Hello Kiipu"',
@@ -18,7 +18,7 @@ const sortValues = new Set(['updatedAt', 'createdAt', 'title']);
18
18
  function usage(action) {
19
19
  switch (action) {
20
20
  case 'create':
21
- return 'Usage: kiipu note create --content "<text>"\n or: kiipu note create "<text>"';
21
+ return 'Usage: kiipu note create --content "<text>" [--title "<title>"]\n or: kiipu note create "<text>" [--title "<title>"]';
22
22
  case 'list':
23
23
  return 'Usage: kiipu note list [--tag <tag>] [--sort <updatedAt|createdAt|title>] [--starred] [--deleted]';
24
24
  case 'search':
@@ -26,7 +26,7 @@ function usage(action) {
26
26
  case 'show':
27
27
  return 'Usage: kiipu note show --id <noteId>';
28
28
  case 'update':
29
- return 'Usage: kiipu note update --id <noteId> --content "<text>" [--title "<title>"] [--visibility public|private] [--tags <a,b,c>]';
29
+ return 'Usage: kiipu note update --id <noteId> [--content "<text>" [--title "<title>"]] [--visibility public|private]';
30
30
  case 'star':
31
31
  return 'Usage: kiipu note star --id <noteId>';
32
32
  case 'pin':
@@ -85,26 +85,6 @@ function parseNoteId(args, action) {
85
85
  const noteId = readFlag(args, '--id')?.trim();
86
86
  return noteId ? noteId : error(usage(action));
87
87
  }
88
- function parseTags(input) {
89
- if (!input) {
90
- return undefined;
91
- }
92
- const unique = new Map();
93
- for (const chunk of input.split(',')) {
94
- const cleaned = chunk.trim().replace(/^#+/, '').replace(/\s+/g, ' ');
95
- if (!cleaned) {
96
- continue;
97
- }
98
- const normalized = cleaned.toLowerCase();
99
- if (!unique.has(normalized)) {
100
- unique.set(normalized, cleaned);
101
- }
102
- if (unique.size === 8) {
103
- break;
104
- }
105
- }
106
- return Array.from(unique.values());
107
- }
108
88
  function toCliNote(note) {
109
89
  return {
110
90
  id: note.id,
@@ -122,11 +102,12 @@ function toCliNote(note) {
122
102
  }
123
103
  async function handleMutationAction(config, action, args) {
124
104
  if (action === 'create') {
125
- const content = (readFlag(args, '--content') ?? stripKnownFlags(args, ['--content'])[0])?.trim();
105
+ const content = (readFlag(args, '--content') ?? stripKnownFlags(args, ['--content', '--title'])[0])?.trim();
126
106
  if (!content) {
127
107
  return error(usage('create'));
128
108
  }
129
- return executeNoteAction(config, { action: 'create', content });
109
+ const title = readFlag(args, '--title')?.trim();
110
+ return executeNoteAction(config, { action: 'create', content, ...(title ? { title } : {}) });
130
111
  }
131
112
  const noteId = parseNoteId(args, action);
132
113
  if (typeof noteId !== 'string') {
@@ -230,28 +211,48 @@ async function handleUpdate(config, args) {
230
211
  return noteId;
231
212
  }
232
213
  const content = readFlag(args, '--content')?.trim();
233
- if (!content) {
234
- return error(usage('update'));
235
- }
236
214
  const visibility = readFlag(args, '--visibility');
237
215
  if (visibility && visibility !== 'public' && visibility !== 'private') {
238
216
  return error(`Invalid --visibility value. ${usage('update')}`);
239
217
  }
240
218
  const title = readFlag(args, '--title');
241
219
  const tags = readFlag(args, '--tags');
242
- const response = await client.updateNote(noteId, {
243
- rawText: content,
244
- ...(title !== undefined ? { title: title || null } : {}),
245
- ...(visibility === 'public' || visibility === 'private' ? { visibility } : {}),
246
- ...(tags ? { tags: parseTags(tags) } : {}),
247
- });
248
- if (!response.ok) {
249
- return error(response.error.message);
220
+ if (tags !== undefined) {
221
+ return error('Tags are now derived from note content. Add #tag directly in --content.');
222
+ }
223
+ if (!content && title !== undefined) {
224
+ return error(`--title requires --content. ${usage('update')}`);
225
+ }
226
+ if (!content && !visibility) {
227
+ return error(usage('update'));
228
+ }
229
+ let updatedNote;
230
+ if (content) {
231
+ const response = await client.updateNote(noteId, {
232
+ rawText: content,
233
+ ...(title !== undefined ? { title: title || null } : {}),
234
+ });
235
+ if (!response.ok) {
236
+ return error(response.error.message);
237
+ }
238
+ updatedNote = response.data;
239
+ }
240
+ if (visibility === 'public' || visibility === 'private') {
241
+ const response = await client.updateNoteMetadata(noteId, {
242
+ visibility,
243
+ });
244
+ if (!response.ok) {
245
+ return error(response.error.message);
246
+ }
247
+ updatedNote = response.data;
248
+ }
249
+ if (!updatedNote) {
250
+ return error(usage('update'));
250
251
  }
251
252
  return {
252
253
  ok: true,
253
- message: `Note updated.\n\n${formatNoteDetail(toCliNote(response.data))}`,
254
- data: response.data,
254
+ message: `Note updated.\n\n${formatNoteDetail(toCliNote(updatedNote))}`,
255
+ data: updatedNote,
255
256
  };
256
257
  }
257
258
  async function handleStar(config, args) {
@@ -93,6 +93,12 @@ export class KiipuUserApiClient {
93
93
  body: JSON.stringify(input),
94
94
  });
95
95
  }
96
+ updateNoteMetadata(id, input) {
97
+ return this.request(`/notes/${id}/metadata`, {
98
+ method: 'PATCH',
99
+ body: JSON.stringify(input),
100
+ });
101
+ }
96
102
  toggleStar(id) {
97
103
  return this.request(`/notes/${id}/star`, {
98
104
  method: 'PATCH',
@@ -31,10 +31,10 @@ export async function executeNoteAction(config, input) {
31
31
  requestedAt: new Date().toISOString(),
32
32
  traceId: `${input.traceIdPrefix ?? 'note'}-${Date.now()}`,
33
33
  rawText: input.content,
34
+ ...(input.title ? { title: input.title } : {}),
34
35
  sourceType: 'skill_command',
35
36
  sourceMessageId: input.sourceMessageId ?? `local-${Date.now()}`,
36
37
  visibility: 'public',
37
- tags: ['kiipu'],
38
38
  });
39
39
  if (!response.ok) {
40
40
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kiipu/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Kiipu CLI for local authentication, doctor checks, and direct note actions.",
5
5
  "license": "MIT",
6
6
  "type": "module",