@refhub/cli 1.0.0

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.
@@ -0,0 +1,74 @@
1
+ // src/commands/import.ts
2
+ import { readFileSync } from 'fs';
3
+ import { resolveClient, run } from '../client.js';
4
+ import { format } from '../format.js';
5
+ function parseTags(tagsCsv) {
6
+ if (!tagsCsv)
7
+ return [];
8
+ return tagsCsv.split(',').map((t) => t.trim());
9
+ }
10
+ export async function handleImportDoi(client, vaultId, doi, tagsCsv, tableMode) {
11
+ const result = await client.importDoi(vaultId, doi, parseTags(tagsCsv));
12
+ format(result, tableMode);
13
+ }
14
+ export async function handleImportBibtex(client, vaultId, bibtex, tagsCsv, tableMode) {
15
+ const result = await client.importBibtex(vaultId, bibtex, parseTags(tagsCsv));
16
+ format(result, tableMode);
17
+ }
18
+ export async function handleImportUrl(client, vaultId, url, tagsCsv, tableMode) {
19
+ const result = await client.importUrl(vaultId, url, parseTags(tagsCsv));
20
+ format(result, tableMode);
21
+ }
22
+ export function registerImport(program) {
23
+ const imp = program.command('import').description('Import references into a vault');
24
+ imp
25
+ .command('doi')
26
+ .description('Import a reference by DOI')
27
+ .requiredOption('--vault <id>')
28
+ .requiredOption('--doi <doi>')
29
+ .option('--tags <ids>', 'comma-separated tag IDs to attach')
30
+ .action(async (opts, cmd) => {
31
+ const g = cmd.optsWithGlobals();
32
+ const client = resolveClient(g.apiKey);
33
+ await run(() => handleImportDoi(client, opts.vault, opts.doi, opts.tags, g.table ?? false));
34
+ });
35
+ imp
36
+ .command('bibtex')
37
+ .description('Import references from a BibTeX string or file')
38
+ .requiredOption('--vault <id>')
39
+ .option('--bibtex <string>', 'inline BibTeX string')
40
+ .option('--file <path>', 'path to .bib file')
41
+ .option('--tags <ids>', 'comma-separated tag IDs to attach')
42
+ .action(async (opts, cmd) => {
43
+ const g = cmd.optsWithGlobals();
44
+ if (!opts.bibtex && !opts.file) {
45
+ process.stderr.write(JSON.stringify({ error: { code: 'missing_input', message: 'Provide --bibtex <string> or --file <path>.' } }) + '\n');
46
+ process.exit(2);
47
+ }
48
+ if (opts.bibtex && opts.file) {
49
+ process.stderr.write(JSON.stringify({ error: { code: 'conflicting_input', message: 'Pass --bibtex <string> or --file <path>, not both.' } }) + '\n');
50
+ process.exit(2);
51
+ }
52
+ let bibtex;
53
+ try {
54
+ bibtex = opts.file ? readFileSync(opts.file, 'utf8') : opts.bibtex;
55
+ }
56
+ catch (e) {
57
+ process.stderr.write(JSON.stringify({ error: { code: 'file_read_error', message: `Cannot read file: ${String(e)}` } }) + '\n');
58
+ process.exit(2);
59
+ }
60
+ const client = resolveClient(g.apiKey);
61
+ await run(() => handleImportBibtex(client, opts.vault, bibtex, opts.tags, g.table ?? false));
62
+ });
63
+ imp
64
+ .command('url')
65
+ .description('Import a reference from a URL (Open Graph scrape)')
66
+ .requiredOption('--vault <id>')
67
+ .requiredOption('--url <url>')
68
+ .option('--tags <ids>', 'comma-separated tag IDs to attach')
69
+ .action(async (opts, cmd) => {
70
+ const g = cmd.optsWithGlobals();
71
+ const client = resolveClient(g.apiKey);
72
+ await run(() => handleImportUrl(client, opts.vault, opts.url, opts.tags, g.table ?? false));
73
+ });
74
+ }
@@ -0,0 +1,36 @@
1
+ import type { Command } from 'commander';
2
+ import { RefHubClient } from '../client.js';
3
+ export declare function handleItemsList(client: RefHubClient, vaultId: string, opts: {
4
+ page?: number;
5
+ limit?: number;
6
+ }, tableMode: boolean): Promise<void>;
7
+ export declare function handleItemGet(client: RefHubClient, vaultId: string, itemId: string, tableMode: boolean): Promise<void>;
8
+ export declare function handleItemAdd(client: RefHubClient, vaultId: string, opts: {
9
+ title: string;
10
+ authors?: string;
11
+ year?: number;
12
+ doi?: string;
13
+ tags?: string;
14
+ }, tableMode: boolean): Promise<void>;
15
+ export declare function handleItemUpdate(client: RefHubClient, vaultId: string, itemId: string, opts: {
16
+ title?: string;
17
+ authors?: string;
18
+ year?: number;
19
+ doi?: string;
20
+ tags?: string;
21
+ }, tableMode: boolean): Promise<void>;
22
+ export declare function handleItemDelete(client: RefHubClient, vaultId: string, itemId: string, confirmed: boolean): Promise<void>;
23
+ export declare function handleItemUpsert(client: RefHubClient, vaultId: string, filePath: string, idempotencyKey: string | undefined, tableMode: boolean): Promise<void>;
24
+ export declare function handleItemPreview(client: RefHubClient, vaultId: string, filePath: string, tableMode: boolean): Promise<void>;
25
+ export declare function handleItemSearch(client: RefHubClient, vaultId: string, opts: {
26
+ q?: string;
27
+ author?: string;
28
+ year?: number;
29
+ doi?: string;
30
+ tag?: string;
31
+ page?: number;
32
+ limit?: number;
33
+ }, tableMode: boolean): Promise<void>;
34
+ export declare function handleItemStats(client: RefHubClient, vaultId: string, tableMode: boolean): Promise<void>;
35
+ export declare function handleItemChanges(client: RefHubClient, vaultId: string, since: string, tableMode: boolean): Promise<void>;
36
+ export declare function registerItems(program: Command): void;
@@ -0,0 +1,208 @@
1
+ // src/commands/items.ts
2
+ import { readFileSync } from 'fs';
3
+ import { resolveClient, run } from '../client.js';
4
+ import { format } from '../format.js';
5
+ export async function handleItemsList(client, vaultId, opts, tableMode) {
6
+ const result = await client.listItems(vaultId, opts);
7
+ format(result, tableMode, ['id', 'title', 'authors', 'year', 'doi', 'updated_at']);
8
+ }
9
+ export async function handleItemGet(client, vaultId, itemId, tableMode) {
10
+ const result = await client.getItem(vaultId, itemId);
11
+ format(result, tableMode);
12
+ }
13
+ export async function handleItemAdd(client, vaultId, opts, tableMode) {
14
+ const item = { title: opts.title };
15
+ if (opts.authors)
16
+ item['authors'] = opts.authors.split(',').map((a) => a.trim());
17
+ if (opts.year !== undefined)
18
+ item['year'] = opts.year;
19
+ if (opts.doi)
20
+ item['doi'] = opts.doi;
21
+ if (opts.tags)
22
+ item['tag_ids'] = opts.tags.split(',').map((t) => t.trim());
23
+ const result = await client.addItems(vaultId, [item]);
24
+ format(result, tableMode, ['id', 'title', 'doi', 'year']);
25
+ }
26
+ export async function handleItemUpdate(client, vaultId, itemId, opts, tableMode) {
27
+ const body = {};
28
+ if (opts.title)
29
+ body['title'] = opts.title;
30
+ if (opts.authors)
31
+ body['authors'] = opts.authors.split(',').map((a) => a.trim());
32
+ if (opts.year !== undefined)
33
+ body['year'] = opts.year;
34
+ if (opts.doi)
35
+ body['doi'] = opts.doi;
36
+ if (opts.tags) {
37
+ process.stderr.write(JSON.stringify({ warning: 'tag_replacement', message: '--tags replaces the full tag set, not an append. Existing tags will be removed.' }) + '\n');
38
+ body['tag_ids'] = opts.tags.split(',').map((t) => t.trim());
39
+ }
40
+ const result = await client.updateItem(vaultId, itemId, body);
41
+ format(result, tableMode);
42
+ }
43
+ export async function handleItemDelete(client, vaultId, itemId, confirmed) {
44
+ if (!confirmed) {
45
+ process.stderr.write(JSON.stringify({ error: { code: 'confirm_required', message: 'Pass --confirm to acknowledge this is a hard delete with no undo.' } }) + '\n');
46
+ process.exit(2);
47
+ }
48
+ const result = await client.deleteItem(vaultId, itemId);
49
+ format(result, false);
50
+ }
51
+ export async function handleItemUpsert(client, vaultId, filePath, idempotencyKey, tableMode) {
52
+ const items = JSON.parse(readFileSync(filePath, 'utf8'));
53
+ if (!Array.isArray(items)) {
54
+ process.stderr.write(JSON.stringify({ error: { code: 'invalid_file', message: 'File must contain a JSON array of items.' } }) + '\n');
55
+ process.exit(2);
56
+ }
57
+ const result = await client.upsertItems(vaultId, items, idempotencyKey);
58
+ format(result, tableMode);
59
+ }
60
+ export async function handleItemPreview(client, vaultId, filePath, tableMode) {
61
+ const items = JSON.parse(readFileSync(filePath, 'utf8'));
62
+ if (!Array.isArray(items)) {
63
+ process.stderr.write(JSON.stringify({ error: { code: 'invalid_file', message: 'File must contain a JSON array of items.' } }) + '\n');
64
+ process.exit(2);
65
+ }
66
+ const result = await client.previewImport(vaultId, items);
67
+ format(result, tableMode);
68
+ }
69
+ export async function handleItemSearch(client, vaultId, opts, tableMode) {
70
+ const result = await client.searchItems(vaultId, {
71
+ q: opts.q,
72
+ author: opts.author,
73
+ year: opts.year,
74
+ doi: opts.doi,
75
+ tag_id: opts.tag,
76
+ page: opts.page,
77
+ limit: opts.limit,
78
+ });
79
+ format(result, tableMode, ['id', 'title', 'authors', 'year', 'doi']);
80
+ }
81
+ export async function handleItemStats(client, vaultId, tableMode) {
82
+ const result = await client.getStats(vaultId);
83
+ format(result, tableMode);
84
+ }
85
+ export async function handleItemChanges(client, vaultId, since, tableMode) {
86
+ const result = await client.getChanges(vaultId, since);
87
+ format(result, tableMode, ['id', 'title', 'updated_at']);
88
+ }
89
+ export function registerItems(program) {
90
+ const items = program.command('items').description('Manage vault items');
91
+ items
92
+ .command('list')
93
+ .description('List items in a vault')
94
+ .requiredOption('--vault <id>')
95
+ .option('--page <n>', 'page number', (v) => parseInt(v, 10))
96
+ .option('--limit <n>', 'results per page', (v) => parseInt(v, 10))
97
+ .action(async (opts, cmd) => {
98
+ const g = cmd.optsWithGlobals();
99
+ const client = resolveClient(g.apiKey);
100
+ await run(() => handleItemsList(client, opts.vault, { page: opts.page, limit: opts.limit }, g.table ?? false));
101
+ });
102
+ items
103
+ .command('get')
104
+ .argument('<itemId>')
105
+ .description('Get a single item')
106
+ .requiredOption('--vault <id>')
107
+ .action(async (itemId, opts, cmd) => {
108
+ const g = cmd.optsWithGlobals();
109
+ const client = resolveClient(g.apiKey);
110
+ await run(() => handleItemGet(client, opts.vault, itemId, g.table ?? false));
111
+ });
112
+ items
113
+ .command('add')
114
+ .description('Add an item to a vault')
115
+ .requiredOption('--vault <id>')
116
+ .requiredOption('--title <title>')
117
+ .option('--authors <authors>', 'comma-separated, e.g. "Smith J,Doe A"')
118
+ .option('--year <year>', 'publication year', (v) => parseInt(v, 10))
119
+ .option('--doi <doi>')
120
+ .option('--tags <ids>', 'comma-separated tag IDs')
121
+ .action(async (opts, cmd) => {
122
+ const g = cmd.optsWithGlobals();
123
+ const client = resolveClient(g.apiKey);
124
+ await run(() => handleItemAdd(client, opts.vault, { title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, tags: opts.tags }, g.table ?? false));
125
+ });
126
+ items
127
+ .command('update')
128
+ .argument('<itemId>')
129
+ .description('Update an item')
130
+ .requiredOption('--vault <id>')
131
+ .option('--title <title>')
132
+ .option('--authors <authors>')
133
+ .option('--year <year>', '', (v) => parseInt(v, 10))
134
+ .option('--doi <doi>')
135
+ .option('--tags <ids>', 'comma-separated tag IDs — REPLACES the full tag set')
136
+ .action(async (itemId, opts, cmd) => {
137
+ const g = cmd.optsWithGlobals();
138
+ const client = resolveClient(g.apiKey);
139
+ await run(() => handleItemUpdate(client, opts.vault, itemId, { title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, tags: opts.tags }, g.table ?? false));
140
+ });
141
+ items
142
+ .command('delete')
143
+ .argument('<itemId>')
144
+ .description('Delete an item (hard delete, no undo)')
145
+ .requiredOption('--vault <id>')
146
+ .option('--confirm', 'required: acknowledge permanent deletion')
147
+ .action(async (itemId, opts, cmd) => {
148
+ const g = cmd.optsWithGlobals();
149
+ const client = resolveClient(g.apiKey);
150
+ await run(() => handleItemDelete(client, opts.vault, itemId, opts.confirm ?? false));
151
+ });
152
+ items
153
+ .command('upsert')
154
+ .description('Bulk upsert items from a JSON file')
155
+ .requiredOption('--vault <id>')
156
+ .requiredOption('--file <path>', 'path to JSON file containing array of items')
157
+ .option('--idempotency-key <key>', 'safe retry key')
158
+ .action(async (opts, cmd) => {
159
+ const g = cmd.optsWithGlobals();
160
+ const client = resolveClient(g.apiKey);
161
+ await run(() => handleItemUpsert(client, opts.vault, opts.file, opts.idempotencyKey, g.table ?? false));
162
+ });
163
+ items
164
+ .command('preview')
165
+ .description('Dry-run upsert — shows what would change without writing')
166
+ .requiredOption('--vault <id>')
167
+ .requiredOption('--file <path>', 'path to JSON file containing array of items')
168
+ .action(async (opts, cmd) => {
169
+ const g = cmd.optsWithGlobals();
170
+ const client = resolveClient(g.apiKey);
171
+ await run(() => handleItemPreview(client, opts.vault, opts.file, g.table ?? false));
172
+ });
173
+ items
174
+ .command('search')
175
+ .description('Search items in a vault')
176
+ .requiredOption('--vault <id>')
177
+ .option('--q <query>', 'full-text search')
178
+ .option('--author <author>')
179
+ .option('--year <year>', '', (v) => parseInt(v, 10))
180
+ .option('--doi <doi>')
181
+ .option('--tag <tagId>')
182
+ .option('--page <n>', '', (v) => parseInt(v, 10))
183
+ .option('--limit <n>', '', (v) => parseInt(v, 10))
184
+ .action(async (opts, cmd) => {
185
+ const g = cmd.optsWithGlobals();
186
+ const client = resolveClient(g.apiKey);
187
+ await run(() => handleItemSearch(client, opts.vault, { q: opts.q, author: opts.author, year: opts.year, doi: opts.doi, tag: opts.tag, page: opts.page, limit: opts.limit }, g.table ?? false));
188
+ });
189
+ items
190
+ .command('stats')
191
+ .description('Get vault statistics')
192
+ .requiredOption('--vault <id>')
193
+ .action(async (opts, cmd) => {
194
+ const g = cmd.optsWithGlobals();
195
+ const client = resolveClient(g.apiKey);
196
+ await run(() => handleItemStats(client, opts.vault, g.table ?? false));
197
+ });
198
+ items
199
+ .command('changes')
200
+ .description('Get items changed since a timestamp')
201
+ .requiredOption('--vault <id>')
202
+ .requiredOption('--since <ISO>', 'ISO 8601 timestamp')
203
+ .action(async (opts, cmd) => {
204
+ const g = cmd.optsWithGlobals();
205
+ const client = resolveClient(g.apiKey);
206
+ await run(() => handleItemChanges(client, opts.vault, opts.since, g.table ?? false));
207
+ });
208
+ }
@@ -0,0 +1,11 @@
1
+ import type { Command } from 'commander';
2
+ import { RefHubClient } from '../client.js';
3
+ export declare function handleRelationsList(client: RefHubClient, vaultId: string, type: string | undefined, tableMode: boolean): Promise<void>;
4
+ export declare function handleRelationCreate(client: RefHubClient, vaultId: string, opts: {
5
+ pub: string;
6
+ related: string;
7
+ type?: string;
8
+ }, tableMode: boolean): Promise<void>;
9
+ export declare function handleRelationUpdate(client: RefHubClient, vaultId: string, relationId: string, type: string, tableMode: boolean): Promise<void>;
10
+ export declare function handleRelationDelete(client: RefHubClient, vaultId: string, relationId: string): Promise<void>;
11
+ export declare function registerRelations(program: Command): void;
@@ -0,0 +1,69 @@
1
+ import { resolveClient, run } from '../client.js';
2
+ import { format } from '../format.js';
3
+ const RELATION_TYPES = 'cites|extends|builds_on|contradicts|reviews|related';
4
+ export async function handleRelationsList(client, vaultId, type, tableMode) {
5
+ const result = await client.listRelations(vaultId, type);
6
+ format(result, tableMode, ['id', 'publication_id', 'related_publication_id', 'relation_type']);
7
+ }
8
+ export async function handleRelationCreate(client, vaultId, opts, tableMode) {
9
+ const result = await client.createRelation(vaultId, {
10
+ publication_id: opts.pub,
11
+ related_publication_id: opts.related,
12
+ relation_type: opts.type,
13
+ });
14
+ format(result, tableMode);
15
+ }
16
+ export async function handleRelationUpdate(client, vaultId, relationId, type, tableMode) {
17
+ const result = await client.updateRelation(vaultId, relationId, { relation_type: type });
18
+ format(result, tableMode);
19
+ }
20
+ export async function handleRelationDelete(client, vaultId, relationId) {
21
+ const result = await client.deleteRelation(vaultId, relationId);
22
+ format(result, false);
23
+ }
24
+ export function registerRelations(program) {
25
+ const relations = program.command('relations').description('Manage vault relations');
26
+ relations
27
+ .command('list')
28
+ .description('List relations in a vault')
29
+ .requiredOption('--vault <id>')
30
+ .option('--type <type>', RELATION_TYPES)
31
+ .action(async (opts, cmd) => {
32
+ const g = cmd.optsWithGlobals();
33
+ const client = resolveClient(g.apiKey);
34
+ await run(() => handleRelationsList(client, opts.vault, opts.type, g.table ?? false));
35
+ });
36
+ relations
37
+ .command('create')
38
+ .description('Create a relation between two publications')
39
+ .requiredOption('--vault <id>')
40
+ .requiredOption('--pub <publicationId>')
41
+ .requiredOption('--related <publicationId>')
42
+ .option('--type <type>', RELATION_TYPES)
43
+ .action(async (opts, cmd) => {
44
+ const g = cmd.optsWithGlobals();
45
+ const client = resolveClient(g.apiKey);
46
+ await run(() => handleRelationCreate(client, opts.vault, { pub: opts.pub, related: opts.related, type: opts.type }, g.table ?? false));
47
+ });
48
+ relations
49
+ .command('update')
50
+ .argument('<relationId>')
51
+ .description('Update a relation type')
52
+ .requiredOption('--vault <id>')
53
+ .requiredOption('--type <type>', RELATION_TYPES)
54
+ .action(async (relationId, opts, cmd) => {
55
+ const g = cmd.optsWithGlobals();
56
+ const client = resolveClient(g.apiKey);
57
+ await run(() => handleRelationUpdate(client, opts.vault, relationId, opts.type, g.table ?? false));
58
+ });
59
+ relations
60
+ .command('delete')
61
+ .argument('<relationId>')
62
+ .description('Delete a relation')
63
+ .requiredOption('--vault <id>')
64
+ .action(async (relationId, opts, cmd) => {
65
+ const g = cmd.optsWithGlobals();
66
+ const client = resolveClient(g.apiKey);
67
+ await run(() => handleRelationDelete(client, opts.vault, relationId));
68
+ });
69
+ }
@@ -0,0 +1,17 @@
1
+ import type { Command } from 'commander';
2
+ import { RefHubClient } from '../client.js';
3
+ export declare function handleTagsList(client: RefHubClient, vaultId: string, tableMode: boolean): Promise<void>;
4
+ export declare function handleTagCreate(client: RefHubClient, vaultId: string, opts: {
5
+ name: string;
6
+ color?: string;
7
+ parent?: string;
8
+ }, tableMode: boolean): Promise<void>;
9
+ export declare function handleTagUpdate(client: RefHubClient, vaultId: string, tagId: string, opts: {
10
+ name?: string;
11
+ color?: string;
12
+ parent?: string;
13
+ }, tableMode: boolean): Promise<void>;
14
+ export declare function handleTagDelete(client: RefHubClient, vaultId: string, tagId: string): Promise<void>;
15
+ export declare function handleTagAttach(client: RefHubClient, vaultId: string, itemId: string, tagsCsv: string): Promise<void>;
16
+ export declare function handleTagDetach(client: RefHubClient, vaultId: string, itemId: string, tagsCsv: string): Promise<void>;
17
+ export declare function registerTags(program: Command): void;
@@ -0,0 +1,109 @@
1
+ import { resolveClient, run } from '../client.js';
2
+ import { format } from '../format.js';
3
+ export async function handleTagsList(client, vaultId, tableMode) {
4
+ const result = await client.listTags(vaultId);
5
+ format(result, tableMode, ['id', 'name', 'color', 'parent_id']);
6
+ }
7
+ export async function handleTagCreate(client, vaultId, opts, tableMode) {
8
+ const body = { name: opts.name };
9
+ if (opts.color)
10
+ body.color = opts.color;
11
+ if (opts.parent)
12
+ body.parent_id = opts.parent;
13
+ const result = await client.createTag(vaultId, body);
14
+ format(result, tableMode);
15
+ }
16
+ export async function handleTagUpdate(client, vaultId, tagId, opts, tableMode) {
17
+ const body = {};
18
+ if (opts.name)
19
+ body.name = opts.name;
20
+ if (opts.color)
21
+ body.color = opts.color;
22
+ if (opts.parent)
23
+ body.parent_id = opts.parent;
24
+ const result = await client.updateTag(vaultId, tagId, body);
25
+ format(result, tableMode);
26
+ }
27
+ export async function handleTagDelete(client, vaultId, tagId) {
28
+ const result = await client.deleteTag(vaultId, tagId);
29
+ format(result, false);
30
+ }
31
+ export async function handleTagAttach(client, vaultId, itemId, tagsCsv) {
32
+ const tagIds = tagsCsv.split(',').map((t) => t.trim());
33
+ const result = await client.attachTags(vaultId, itemId, tagIds);
34
+ format(result, false);
35
+ }
36
+ export async function handleTagDetach(client, vaultId, itemId, tagsCsv) {
37
+ const tagIds = tagsCsv.split(',').map((t) => t.trim());
38
+ const result = await client.detachTags(vaultId, itemId, tagIds);
39
+ format(result, false);
40
+ }
41
+ export function registerTags(program) {
42
+ const tags = program.command('tags').description('Manage vault tags');
43
+ tags
44
+ .command('list')
45
+ .description('List tags in a vault')
46
+ .requiredOption('--vault <id>')
47
+ .action(async (opts, cmd) => {
48
+ const g = cmd.optsWithGlobals();
49
+ const client = resolveClient(g.apiKey);
50
+ await run(() => handleTagsList(client, opts.vault, g.table ?? false));
51
+ });
52
+ tags
53
+ .command('create')
54
+ .description('Create a tag')
55
+ .requiredOption('--vault <id>')
56
+ .requiredOption('--name <name>')
57
+ .option('--color <color>')
58
+ .option('--parent <tagId>', 'parent tag ID')
59
+ .action(async (opts, cmd) => {
60
+ const g = cmd.optsWithGlobals();
61
+ const client = resolveClient(g.apiKey);
62
+ await run(() => handleTagCreate(client, opts.vault, { name: opts.name, color: opts.color, parent: opts.parent }, g.table ?? false));
63
+ });
64
+ tags
65
+ .command('update')
66
+ .argument('<tagId>')
67
+ .description('Update a tag')
68
+ .requiredOption('--vault <id>')
69
+ .option('--name <name>')
70
+ .option('--color <color>')
71
+ .option('--parent <tagId>')
72
+ .action(async (tagId, opts, cmd) => {
73
+ const g = cmd.optsWithGlobals();
74
+ const client = resolveClient(g.apiKey);
75
+ await run(() => handleTagUpdate(client, opts.vault, tagId, { name: opts.name, color: opts.color, parent: opts.parent }, g.table ?? false));
76
+ });
77
+ tags
78
+ .command('delete')
79
+ .argument('<tagId>')
80
+ .description('Delete a tag')
81
+ .requiredOption('--vault <id>')
82
+ .action(async (tagId, opts, cmd) => {
83
+ const g = cmd.optsWithGlobals();
84
+ const client = resolveClient(g.apiKey);
85
+ await run(() => handleTagDelete(client, opts.vault, tagId));
86
+ });
87
+ tags
88
+ .command('attach')
89
+ .description('Attach tags to an item (idempotent)')
90
+ .requiredOption('--vault <id>')
91
+ .requiredOption('--item <itemId>')
92
+ .requiredOption('--tags <ids>', 'comma-separated tag IDs')
93
+ .action(async (opts, cmd) => {
94
+ const g = cmd.optsWithGlobals();
95
+ const client = resolveClient(g.apiKey);
96
+ await run(() => handleTagAttach(client, opts.vault, opts.item, opts.tags));
97
+ });
98
+ tags
99
+ .command('detach')
100
+ .description('Detach tags from an item')
101
+ .requiredOption('--vault <id>')
102
+ .requiredOption('--item <itemId>')
103
+ .requiredOption('--tags <ids>', 'comma-separated tag IDs')
104
+ .action(async (opts, cmd) => {
105
+ const g = cmd.optsWithGlobals();
106
+ const client = resolveClient(g.apiKey);
107
+ await run(() => handleTagDetach(client, opts.vault, opts.item, opts.tags));
108
+ });
109
+ }
@@ -0,0 +1,33 @@
1
+ import type { Command } from 'commander';
2
+ import { RefHubClient } from '../client.js';
3
+ export declare function handleVaultsList(client: RefHubClient, tableMode: boolean): Promise<void>;
4
+ export declare function handleVaultGet(client: RefHubClient, vaultId: string, tableMode: boolean): Promise<void>;
5
+ export declare function handleVaultCreate(client: RefHubClient, opts: {
6
+ name: string;
7
+ description?: string;
8
+ color?: string;
9
+ visibility?: string;
10
+ category?: string;
11
+ abstract?: string;
12
+ }, tableMode: boolean): Promise<void>;
13
+ export declare function handleVaultUpdate(client: RefHubClient, vaultId: string, opts: {
14
+ name?: string;
15
+ description?: string;
16
+ color?: string;
17
+ category?: string;
18
+ abstract?: string;
19
+ }, tableMode: boolean): Promise<void>;
20
+ export declare function handleVaultDelete(client: RefHubClient, vaultId: string, confirmed: boolean): Promise<void>;
21
+ export declare function handleVaultVisibility(client: RefHubClient, vaultId: string, opts: {
22
+ visibility: string;
23
+ slug?: string;
24
+ }, tableMode: boolean): Promise<void>;
25
+ export declare function handleSharesList(client: RefHubClient, vaultId: string, tableMode: boolean): Promise<void>;
26
+ export declare function handleShareAdd(client: RefHubClient, vaultId: string, opts: {
27
+ email: string;
28
+ role: 'viewer' | 'editor';
29
+ name?: string;
30
+ }, tableMode: boolean): Promise<void>;
31
+ export declare function handleShareUpdate(client: RefHubClient, vaultId: string, shareId: string, role: 'viewer' | 'editor', tableMode: boolean): Promise<void>;
32
+ export declare function handleShareRemove(client: RefHubClient, vaultId: string, shareId: string): Promise<void>;
33
+ export declare function registerVaults(program: Command): void;