@refhub/cli 1.6.0 → 1.7.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.
- package/README.md +50 -1
- package/dist/client.d.ts +44 -1
- package/dist/client.js +49 -0
- package/dist/commands/inbox.d.ts +15 -0
- package/dist/commands/inbox.js +159 -0
- package/dist/commands/items.d.ts +5 -0
- package/dist/commands/items.js +27 -1
- package/dist/commands/relations.js +2 -0
- package/dist/commands/relationsScan.d.ts +23 -0
- package/dist/commands/relationsScan.js +137 -0
- package/dist/commands/sections.d.ts +15 -0
- package/dist/commands/sections.js +77 -0
- package/dist/index.js +4 -0
- package/dist/types.d.ts +29 -0
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ refhub vaults shares remove <vaultId> <shareId>
|
|
|
93
93
|
refhub items list --vault <id> [--page] [--limit]
|
|
94
94
|
refhub items get --vault <id> <itemId>
|
|
95
95
|
refhub items add --vault <id> --title <t> [--authors "Smith J,Doe A"] [--year] [--doi] [--url] [--pdf-url] [--tags <id,id>] [--notes]
|
|
96
|
-
refhub items update --vault <id> <itemId> [--title] [--authors] [--year] [--doi] [--url] [--pdf-url] [--tags <id,id>] [--notes]
|
|
96
|
+
refhub items update --vault <id> <itemId> [--title] [--authors] [--year] [--doi] [--url] [--pdf-url] [--tags <id,id>] [--notes] [--section <sectionId> | --unset-section] [--featured | --unfeature] [--featured-note <text>]
|
|
97
97
|
refhub items delete --vault <id> <itemId> --confirm
|
|
98
98
|
refhub items upsert --vault <id> --file <items.json> [--idempotency-key]
|
|
99
99
|
refhub items preview --vault <id> --file <items.json>
|
|
@@ -106,6 +106,21 @@ refhub items changes --vault <id> --since <ISO>
|
|
|
106
106
|
|
|
107
107
|
`--pdf-url` sets the frontend's `publisher_pdf` field (a link to a publisher-hosted PDF). it is distinct from the frontend's `drive_pdf` field (the Google Drive-hosted copy created by `refhub pdf upload`, see below) — the Drive copy is readable back afterward too, as `drive_pdf_url` on item reads (see the `pdf` command below).
|
|
108
108
|
|
|
109
|
+
`--section`/`--unset-section`/`--featured`/`--unfeature`/`--featured-note` are vault-local curation fields — grouping and highlighting items for display on public vault pages. **Setting any of them requires vault owner access**, even for an api key with `vaults:write` scope held by a non-owner editor share — the backend runs a second, owner-level access check for these specific fields, separate from the editor-level check for everything else `items update` can change.
|
|
110
|
+
|
|
111
|
+
### sections
|
|
112
|
+
|
|
113
|
+
Curated sections group a vault's items for display on public vault pages. Listing needs only viewer access; create/update/delete require **owner** access (`vaults:admin` scope, and the caller must own the vault — an editor share cannot manage sections even with `vaults:admin`).
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
refhub sections list --vault <id>
|
|
117
|
+
refhub sections create --vault <id> --name <n> [--description] [--position]
|
|
118
|
+
refhub sections update --vault <id> <sectionId> [--name] [--description] [--position]
|
|
119
|
+
refhub sections delete --vault <id> <sectionId>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
deleting a section unfiles its items (`section_id` is cleared) rather than deleting them.
|
|
123
|
+
|
|
109
124
|
### tags
|
|
110
125
|
|
|
111
126
|
```bash
|
|
@@ -126,6 +141,39 @@ refhub relations update --vault <id> <relationId> --type <...>
|
|
|
126
141
|
refhub relations delete --vault <id> <relationId>
|
|
127
142
|
```
|
|
128
143
|
|
|
144
|
+
`refhub relations scan` is client-side orchestration on top of the existing `discover`/manual-relation building blocks — there is no dedicated backend route for it, same as `enrich`. For each vault item with a DOI, it looks up the item's Semantic Scholar paper id, fetches its references and citations, and matches each returned paper against sibling items already in the same vault (DOI match first, falling back to an exact, case-insensitive title match), mirroring the RefHub frontend's own relationship-suggestion matching. Every match becomes a `cites` relation — item → reference for references, matched-paper → item for citations — skipping any pair that already has a relation between them.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
refhub relations scan --vault <id> [--item <itemId>] [--dry-run] [--limit <n>]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
- omit `--item` to scan every item in the vault that has a DOI
|
|
151
|
+
- `--dry-run` reports what would be created without writing anything
|
|
152
|
+
- `--limit` caps references/citations fetched per item from Semantic Scholar (1–25, same as `discover references`/`discover citations`)
|
|
153
|
+
- rate-limited client-side to roughly 1 item/s (each item makes 3 Semantic Scholar requests); backend cache/rate-limit/stale fallback also applies
|
|
154
|
+
- only ever proposes `relation_type: "cites"` — there's no basis in citation-graph data alone for `extends`/`contradicts`/etc., those remain manual via `relations create`/`update`
|
|
155
|
+
|
|
156
|
+
### inbox
|
|
157
|
+
|
|
158
|
+
capture papers now, file them into a vault later. unlike every other command group, inbox items have no `--vault` — they belong to the account until `accept` files one.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
refhub inbox list [--page <n>] [--limit <n>]
|
|
162
|
+
refhub inbox capture doi <doi>
|
|
163
|
+
refhub inbox capture bibtex (--bibtex <string> | --file <path>) # bulk -- one inbox item per entry
|
|
164
|
+
refhub inbox capture manual --title <title>
|
|
165
|
+
refhub inbox accept <itemId> --vault <id> [--tags <id,id>]
|
|
166
|
+
refhub inbox reject <itemId> --confirm
|
|
167
|
+
refhub inbox merge <itemId> --confirm
|
|
168
|
+
refhub inbox postpone <itemId>
|
|
169
|
+
refhub inbox delete <itemId> --confirm
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
- `list` is paginated server-side (default 50 per page, max 200) — pass `--page`/`--limit` to see more than the first page.
|
|
173
|
+
- `merge` files the item as a duplicate of whatever match the backend already found for it (`duplicate_of_publication_id`) — it does not accept a `--vault`/target of your own choosing.
|
|
174
|
+
- `reject`/`merge`/`delete` require `--confirm`: none of the three can be undone. `accept` and `postpone` don't need it — accept files real data rather than discarding it, and postpone only reorders the queue.
|
|
175
|
+
- `capture bibtex` inserts entries one at a time server-side with no idempotency key — if one entry fails partway through a large batch, earlier entries in that batch are already created. Check `inbox list` before retrying the same content to avoid duplicates (tracked for a real fix as `.netlify#40`).
|
|
176
|
+
|
|
129
177
|
### import
|
|
130
178
|
|
|
131
179
|
```bash
|
|
@@ -224,6 +272,7 @@ rate-limited responses (429) include `retry_after_seconds`.
|
|
|
224
272
|
|
|
225
273
|
- `vaults delete` and `items delete` require `--confirm` — hard deletes, no undo
|
|
226
274
|
- `vaults archive` requires `--confirm` — permanent read-only lockdown, no undo, no unarchive command exists
|
|
275
|
+
- `inbox reject`, `inbox merge`, and `inbox delete` require `--confirm` — none of the three can be undone
|
|
227
276
|
- `items upsert` without `--idempotency-key` emits a `partial_write_risk` warning before exiting 1 on failure
|
|
228
277
|
- `items update --tags` warns that the tags list is a full replacement
|
|
229
278
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiResponse, Vault, VaultDetail, Share, Item, UpsertResult, PreviewResult, Tag, Relation, BibTeXImportResult, AuditEntry, VaultStats, RelationType, SemanticScholarPaper, SemanticScholarDoiMetadata } from './types.js';
|
|
1
|
+
import type { ApiResponse, Vault, VaultDetail, Share, Item, UpsertResult, PreviewResult, Tag, Relation, BibTeXImportResult, AuditEntry, VaultStats, RelationType, SemanticScholarPaper, SemanticScholarDoiMetadata, Section, InboxItem } from './types.js';
|
|
2
2
|
export declare class RefHubError extends Error {
|
|
3
3
|
readonly code: string;
|
|
4
4
|
readonly request_id: string;
|
|
@@ -74,6 +74,10 @@ export declare class RefHubClient {
|
|
|
74
74
|
tag_ids?: string[];
|
|
75
75
|
notes?: string;
|
|
76
76
|
pdf_url?: string;
|
|
77
|
+
section_id?: string | null;
|
|
78
|
+
section_position?: number;
|
|
79
|
+
featured?: boolean;
|
|
80
|
+
featured_note?: string | null;
|
|
77
81
|
}): Promise<ApiResponse<Item>>;
|
|
78
82
|
deleteItem(vaultId: string, itemId: string): Promise<ApiResponse<{
|
|
79
83
|
id: string;
|
|
@@ -113,6 +117,20 @@ export declare class RefHubClient {
|
|
|
113
117
|
item_id: string;
|
|
114
118
|
tag_ids: string[];
|
|
115
119
|
}>>;
|
|
120
|
+
listSections(vaultId: string): Promise<ApiResponse<Section[]>>;
|
|
121
|
+
createSection(vaultId: string, body: {
|
|
122
|
+
name: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
position?: number;
|
|
125
|
+
}): Promise<ApiResponse<Section>>;
|
|
126
|
+
updateSection(vaultId: string, sectionId: string, body: {
|
|
127
|
+
name?: string;
|
|
128
|
+
description?: string;
|
|
129
|
+
position?: number;
|
|
130
|
+
}): Promise<ApiResponse<Section>>;
|
|
131
|
+
deleteSection(vaultId: string, sectionId: string): Promise<ApiResponse<{
|
|
132
|
+
id: string;
|
|
133
|
+
}>>;
|
|
116
134
|
listRelations(vaultId: string, type?: string): Promise<ApiResponse<Relation[]>>;
|
|
117
135
|
createRelation(vaultId: string, body: {
|
|
118
136
|
publication_id: string;
|
|
@@ -125,6 +143,31 @@ export declare class RefHubClient {
|
|
|
125
143
|
deleteRelation(vaultId: string, relationId: string): Promise<ApiResponse<{
|
|
126
144
|
id: string;
|
|
127
145
|
}>>;
|
|
146
|
+
listInbox(params?: {
|
|
147
|
+
page?: number;
|
|
148
|
+
limit?: number;
|
|
149
|
+
}): Promise<ApiResponse<InboxItem[]>>;
|
|
150
|
+
captureInboxDoi(doi: string): Promise<ApiResponse<InboxItem>>;
|
|
151
|
+
captureInboxBibtex(bibtex: string): Promise<ApiResponse<InboxItem[]>>;
|
|
152
|
+
captureInboxManual(title: string): Promise<ApiResponse<InboxItem>>;
|
|
153
|
+
acceptInboxItem(itemId: string, vaultId: string, tagIds?: string[]): Promise<ApiResponse<{
|
|
154
|
+
vault_publication_id: string;
|
|
155
|
+
publication_id: string;
|
|
156
|
+
}>>;
|
|
157
|
+
rejectInboxItem(itemId: string): Promise<ApiResponse<{
|
|
158
|
+
id: string;
|
|
159
|
+
}>>;
|
|
160
|
+
mergeInboxItem(itemId: string): Promise<ApiResponse<{
|
|
161
|
+
id: string;
|
|
162
|
+
filed_publication_id: string;
|
|
163
|
+
}>>;
|
|
164
|
+
postponeInboxItem(itemId: string): Promise<ApiResponse<{
|
|
165
|
+
id: string;
|
|
166
|
+
sort_order: number;
|
|
167
|
+
}>>;
|
|
168
|
+
deleteInboxItem(itemId: string): Promise<ApiResponse<{
|
|
169
|
+
id: string;
|
|
170
|
+
}>>;
|
|
128
171
|
importDoi(vaultId: string, doi: string, tagIds?: string[]): Promise<ApiResponse<{
|
|
129
172
|
item: Item;
|
|
130
173
|
}>>;
|
package/dist/client.js
CHANGED
|
@@ -155,6 +155,19 @@ export class RefHubClient {
|
|
|
155
155
|
detachTags(vaultId, itemId, tagIds) {
|
|
156
156
|
return this.req('POST', `/vaults/${vaultId}/tags/detach`, { item_id: itemId, tag_ids: tagIds });
|
|
157
157
|
}
|
|
158
|
+
// ── Sections ─────────────────────────────────────────────────────────────────
|
|
159
|
+
listSections(vaultId) {
|
|
160
|
+
return this.req('GET', `/vaults/${vaultId}/sections`);
|
|
161
|
+
}
|
|
162
|
+
createSection(vaultId, body) {
|
|
163
|
+
return this.req('POST', `/vaults/${vaultId}/sections`, body);
|
|
164
|
+
}
|
|
165
|
+
updateSection(vaultId, sectionId, body) {
|
|
166
|
+
return this.req('PATCH', `/vaults/${vaultId}/sections/${sectionId}`, body);
|
|
167
|
+
}
|
|
168
|
+
deleteSection(vaultId, sectionId) {
|
|
169
|
+
return this.req('DELETE', `/vaults/${vaultId}/sections/${sectionId}`);
|
|
170
|
+
}
|
|
158
171
|
// ── Relations ────────────────────────────────────────────────────────────────
|
|
159
172
|
listRelations(vaultId, type) {
|
|
160
173
|
const qs = type ? `?type=${encodeURIComponent(type)}` : '';
|
|
@@ -169,6 +182,42 @@ export class RefHubClient {
|
|
|
169
182
|
deleteRelation(vaultId, relationId) {
|
|
170
183
|
return this.req('DELETE', `/vaults/${vaultId}/relations/${relationId}`);
|
|
171
184
|
}
|
|
185
|
+
// ── Inbox ────────────────────────────────────────────────────────────────────
|
|
186
|
+
// Account-scoped, not vault-scoped -- an inbox item has no vault until accept()
|
|
187
|
+
// files it into one, unlike every other resource above.
|
|
188
|
+
listInbox(params = {}) {
|
|
189
|
+
const q = new URLSearchParams();
|
|
190
|
+
if (params.page !== undefined)
|
|
191
|
+
q.set('page', String(params.page));
|
|
192
|
+
if (params.limit !== undefined)
|
|
193
|
+
q.set('limit', String(params.limit));
|
|
194
|
+
const qs = q.toString() ? `?${q}` : '';
|
|
195
|
+
return this.req('GET', `/inbox${qs}`);
|
|
196
|
+
}
|
|
197
|
+
captureInboxDoi(doi) {
|
|
198
|
+
return this.req('POST', '/inbox', { source_type: 'doi', source_ref: doi });
|
|
199
|
+
}
|
|
200
|
+
captureInboxBibtex(bibtex) {
|
|
201
|
+
return this.req('POST', '/inbox', { source_type: 'bibtex', source_ref: bibtex });
|
|
202
|
+
}
|
|
203
|
+
captureInboxManual(title) {
|
|
204
|
+
return this.req('POST', '/inbox', { source_type: 'manual', parsed_fields: { title } });
|
|
205
|
+
}
|
|
206
|
+
acceptInboxItem(itemId, vaultId, tagIds = []) {
|
|
207
|
+
return this.req('POST', `/inbox/${itemId}/accept`, { vault_id: vaultId, tag_ids: tagIds });
|
|
208
|
+
}
|
|
209
|
+
rejectInboxItem(itemId) {
|
|
210
|
+
return this.req('POST', `/inbox/${itemId}/reject`);
|
|
211
|
+
}
|
|
212
|
+
mergeInboxItem(itemId) {
|
|
213
|
+
return this.req('POST', `/inbox/${itemId}/merge`);
|
|
214
|
+
}
|
|
215
|
+
postponeInboxItem(itemId) {
|
|
216
|
+
return this.req('POST', `/inbox/${itemId}/postpone`);
|
|
217
|
+
}
|
|
218
|
+
deleteInboxItem(itemId) {
|
|
219
|
+
return this.req('DELETE', `/inbox/${itemId}`);
|
|
220
|
+
}
|
|
172
221
|
// ── Import ───────────────────────────────────────────────────────────────────
|
|
173
222
|
importDoi(vaultId, doi, tagIds = []) {
|
|
174
223
|
return this.req('POST', `/vaults/${vaultId}/import/doi`, { doi, tag_ids: tagIds });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { RefHubClient } from '../client.js';
|
|
3
|
+
export declare function handleInboxList(client: RefHubClient, opts: {
|
|
4
|
+
page?: number;
|
|
5
|
+
limit?: number;
|
|
6
|
+
}, tableMode: boolean): Promise<void>;
|
|
7
|
+
export declare function handleInboxCaptureDoi(client: RefHubClient, doi: string, tableMode: boolean): Promise<void>;
|
|
8
|
+
export declare function handleInboxCaptureBibtex(client: RefHubClient, bibtex: string, tableMode: boolean): Promise<void>;
|
|
9
|
+
export declare function handleInboxCaptureManual(client: RefHubClient, title: string, tableMode: boolean): Promise<void>;
|
|
10
|
+
export declare function handleInboxAccept(client: RefHubClient, itemId: string, vaultId: string, tagsCsv: string | undefined, tableMode: boolean): Promise<void>;
|
|
11
|
+
export declare function handleInboxReject(client: RefHubClient, itemId: string, confirmed: boolean): Promise<void>;
|
|
12
|
+
export declare function handleInboxMerge(client: RefHubClient, itemId: string, confirmed: boolean, tableMode: boolean): Promise<void>;
|
|
13
|
+
export declare function handleInboxPostpone(client: RefHubClient, itemId: string, tableMode: boolean): Promise<void>;
|
|
14
|
+
export declare function handleInboxDelete(client: RefHubClient, itemId: string, confirmed: boolean): Promise<void>;
|
|
15
|
+
export declare function registerInbox(program: Command): void;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// src/commands/inbox.ts
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { resolveClient, run } from '../client.js';
|
|
4
|
+
import { format } from '../format.js';
|
|
5
|
+
export async function handleInboxList(client, opts, tableMode) {
|
|
6
|
+
const result = await client.listInbox(opts);
|
|
7
|
+
format(result, tableMode, ['id', 'status', 'source_type', 'source_ref', 'suggested_vault_id', 'created_at']);
|
|
8
|
+
}
|
|
9
|
+
export async function handleInboxCaptureDoi(client, doi, tableMode) {
|
|
10
|
+
const result = await client.captureInboxDoi(doi);
|
|
11
|
+
format(result, tableMode);
|
|
12
|
+
}
|
|
13
|
+
export async function handleInboxCaptureBibtex(client, bibtex, tableMode) {
|
|
14
|
+
const result = await client.captureInboxBibtex(bibtex);
|
|
15
|
+
format(result, tableMode);
|
|
16
|
+
}
|
|
17
|
+
export async function handleInboxCaptureManual(client, title, tableMode) {
|
|
18
|
+
const result = await client.captureInboxManual(title);
|
|
19
|
+
format(result, tableMode);
|
|
20
|
+
}
|
|
21
|
+
export async function handleInboxAccept(client, itemId, vaultId, tagsCsv, tableMode) {
|
|
22
|
+
const tagIds = tagsCsv ? tagsCsv.split(',').map((t) => t.trim()) : [];
|
|
23
|
+
const result = await client.acceptInboxItem(itemId, vaultId, tagIds);
|
|
24
|
+
format(result, tableMode);
|
|
25
|
+
}
|
|
26
|
+
export async function handleInboxReject(client, itemId, confirmed) {
|
|
27
|
+
if (!confirmed) {
|
|
28
|
+
process.stderr.write(JSON.stringify({ error: { code: 'confirm_required', message: 'Pass --confirm to acknowledge there is no way to un-reject an inbox item.' } }) + '\n');
|
|
29
|
+
process.exit(2);
|
|
30
|
+
}
|
|
31
|
+
const result = await client.rejectInboxItem(itemId);
|
|
32
|
+
format(result, false);
|
|
33
|
+
}
|
|
34
|
+
export async function handleInboxMerge(client, itemId, confirmed, tableMode) {
|
|
35
|
+
if (!confirmed) {
|
|
36
|
+
process.stderr.write(JSON.stringify({ error: { code: 'confirm_required', message: 'Pass --confirm to acknowledge there is no way to un-merge an inbox item.' } }) + '\n');
|
|
37
|
+
process.exit(2);
|
|
38
|
+
}
|
|
39
|
+
const result = await client.mergeInboxItem(itemId);
|
|
40
|
+
format(result, tableMode);
|
|
41
|
+
}
|
|
42
|
+
export async function handleInboxPostpone(client, itemId, tableMode) {
|
|
43
|
+
const result = await client.postponeInboxItem(itemId);
|
|
44
|
+
format(result, tableMode);
|
|
45
|
+
}
|
|
46
|
+
export async function handleInboxDelete(client, itemId, confirmed) {
|
|
47
|
+
if (!confirmed) {
|
|
48
|
+
process.stderr.write(JSON.stringify({ error: { code: 'confirm_required', message: 'Pass --confirm to acknowledge this is a hard delete with no undo.' } }) + '\n');
|
|
49
|
+
process.exit(2);
|
|
50
|
+
}
|
|
51
|
+
const result = await client.deleteInboxItem(itemId);
|
|
52
|
+
format(result, false);
|
|
53
|
+
}
|
|
54
|
+
export function registerInbox(program) {
|
|
55
|
+
const inbox = program.command('inbox').description('Capture and triage papers before filing them into a vault');
|
|
56
|
+
inbox
|
|
57
|
+
.command('list')
|
|
58
|
+
.description('List pending inbox items')
|
|
59
|
+
.option('--page <n>', 'page number', (v) => parseInt(v, 10))
|
|
60
|
+
.option('--limit <n>', 'results per page (server default 50, max 200)', (v) => parseInt(v, 10))
|
|
61
|
+
.action(async (opts, cmd) => {
|
|
62
|
+
const g = cmd.optsWithGlobals();
|
|
63
|
+
const client = resolveClient(g.apiKey);
|
|
64
|
+
await run(() => handleInboxList(client, { page: opts.page, limit: opts.limit }, g.table ?? false));
|
|
65
|
+
});
|
|
66
|
+
const capture = inbox.command('capture').description('Capture a paper into the inbox');
|
|
67
|
+
capture
|
|
68
|
+
.command('doi')
|
|
69
|
+
.description('Capture by DOI')
|
|
70
|
+
.argument('<doi>')
|
|
71
|
+
.action(async (doi, _opts, cmd) => {
|
|
72
|
+
const g = cmd.optsWithGlobals();
|
|
73
|
+
const client = resolveClient(g.apiKey);
|
|
74
|
+
await run(() => handleInboxCaptureDoi(client, doi, g.table ?? false));
|
|
75
|
+
});
|
|
76
|
+
capture
|
|
77
|
+
.command('bibtex')
|
|
78
|
+
.description('Capture from a BibTeX string or file (bulk -- one inbox item per entry)')
|
|
79
|
+
.option('--bibtex <string>', 'inline BibTeX string')
|
|
80
|
+
.option('--file <path>', 'path to .bib file')
|
|
81
|
+
.action(async (opts, cmd) => {
|
|
82
|
+
const g = cmd.optsWithGlobals();
|
|
83
|
+
if (!opts.bibtex && !opts.file) {
|
|
84
|
+
process.stderr.write(JSON.stringify({ error: { code: 'missing_input', message: 'Provide --bibtex <string> or --file <path>.' } }) + '\n');
|
|
85
|
+
process.exit(2);
|
|
86
|
+
}
|
|
87
|
+
if (opts.bibtex && opts.file) {
|
|
88
|
+
process.stderr.write(JSON.stringify({ error: { code: 'conflicting_input', message: 'Pass --bibtex <string> or --file <path>, not both.' } }) + '\n');
|
|
89
|
+
process.exit(2);
|
|
90
|
+
}
|
|
91
|
+
let bibtex;
|
|
92
|
+
try {
|
|
93
|
+
bibtex = opts.file ? readFileSync(opts.file, 'utf8') : opts.bibtex;
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
process.stderr.write(JSON.stringify({ error: { code: 'file_read_error', message: `Cannot read file: ${String(e)}` } }) + '\n');
|
|
97
|
+
process.exit(2);
|
|
98
|
+
}
|
|
99
|
+
const client = resolveClient(g.apiKey);
|
|
100
|
+
await run(() => handleInboxCaptureBibtex(client, bibtex, g.table ?? false));
|
|
101
|
+
});
|
|
102
|
+
capture
|
|
103
|
+
.command('manual')
|
|
104
|
+
.description('Capture a manual entry (title only)')
|
|
105
|
+
.requiredOption('--title <title>')
|
|
106
|
+
.action(async (opts, cmd) => {
|
|
107
|
+
const g = cmd.optsWithGlobals();
|
|
108
|
+
const client = resolveClient(g.apiKey);
|
|
109
|
+
await run(() => handleInboxCaptureManual(client, opts.title, g.table ?? false));
|
|
110
|
+
});
|
|
111
|
+
inbox
|
|
112
|
+
.command('accept')
|
|
113
|
+
.argument('<itemId>')
|
|
114
|
+
.description('File a pending item into a vault')
|
|
115
|
+
.requiredOption('--vault <id>')
|
|
116
|
+
.option('--tags <ids>', 'comma-separated tag IDs to attach')
|
|
117
|
+
.action(async (itemId, opts, cmd) => {
|
|
118
|
+
const g = cmd.optsWithGlobals();
|
|
119
|
+
const client = resolveClient(g.apiKey);
|
|
120
|
+
await run(() => handleInboxAccept(client, itemId, opts.vault, opts.tags, g.table ?? false));
|
|
121
|
+
});
|
|
122
|
+
inbox
|
|
123
|
+
.command('reject')
|
|
124
|
+
.argument('<itemId>')
|
|
125
|
+
.description('Discard a pending item (no undo)')
|
|
126
|
+
.option('--confirm', 'required: acknowledge there is no way to un-reject')
|
|
127
|
+
.action(async (itemId, opts, cmd) => {
|
|
128
|
+
const client = resolveClient(cmd.optsWithGlobals().apiKey);
|
|
129
|
+
await run(() => handleInboxReject(client, itemId, opts.confirm ?? false));
|
|
130
|
+
});
|
|
131
|
+
inbox
|
|
132
|
+
.command('merge')
|
|
133
|
+
.argument('<itemId>')
|
|
134
|
+
.description('File a pending item as a duplicate of the match RefHub already found (no undo)')
|
|
135
|
+
.option('--confirm', 'required: acknowledge there is no way to un-merge')
|
|
136
|
+
.action(async (itemId, opts, cmd) => {
|
|
137
|
+
const g = cmd.optsWithGlobals();
|
|
138
|
+
const client = resolveClient(g.apiKey);
|
|
139
|
+
await run(() => handleInboxMerge(client, itemId, opts.confirm ?? false, g.table ?? false));
|
|
140
|
+
});
|
|
141
|
+
inbox
|
|
142
|
+
.command('postpone')
|
|
143
|
+
.argument('<itemId>')
|
|
144
|
+
.description('Move a pending item to the back of the queue')
|
|
145
|
+
.action(async (itemId, _opts, cmd) => {
|
|
146
|
+
const g = cmd.optsWithGlobals();
|
|
147
|
+
const client = resolveClient(g.apiKey);
|
|
148
|
+
await run(() => handleInboxPostpone(client, itemId, g.table ?? false));
|
|
149
|
+
});
|
|
150
|
+
inbox
|
|
151
|
+
.command('delete')
|
|
152
|
+
.argument('<itemId>')
|
|
153
|
+
.description('Delete an inbox item regardless of status (hard delete, no undo)')
|
|
154
|
+
.option('--confirm', 'required: acknowledge this is a permanent deletion')
|
|
155
|
+
.action(async (itemId, opts, cmd) => {
|
|
156
|
+
const client = resolveClient(cmd.optsWithGlobals().apiKey);
|
|
157
|
+
await run(() => handleInboxDelete(client, itemId, opts.confirm ?? false));
|
|
158
|
+
});
|
|
159
|
+
}
|
package/dist/commands/items.d.ts
CHANGED
|
@@ -24,6 +24,11 @@ export declare function handleItemUpdate(client: RefHubClient, vaultId: string,
|
|
|
24
24
|
tags?: string;
|
|
25
25
|
notes?: string;
|
|
26
26
|
pdfUrl?: string;
|
|
27
|
+
section?: string;
|
|
28
|
+
unsetSection?: boolean;
|
|
29
|
+
featured?: boolean;
|
|
30
|
+
unfeature?: boolean;
|
|
31
|
+
featuredNote?: string;
|
|
27
32
|
}, tableMode: boolean): Promise<void>;
|
|
28
33
|
export declare function handleItemDelete(client: RefHubClient, vaultId: string, itemId: string, confirmed: boolean): Promise<void>;
|
|
29
34
|
export declare function handleItemUpsert(client: RefHubClient, vaultId: string, filePath: string, idempotencyKey: string | undefined, tableMode: boolean): Promise<void>;
|
package/dist/commands/items.js
CHANGED
|
@@ -49,6 +49,16 @@ export async function handleItemUpdate(client, vaultId, itemId, opts, tableMode)
|
|
|
49
49
|
process.stderr.write(JSON.stringify({ warning: 'tag_replacement', message: '--tags replaces the full tag set, not an append. Existing tags will be removed.' }) + '\n');
|
|
50
50
|
body['tag_ids'] = opts.tags.split(',').map((t) => t.trim());
|
|
51
51
|
}
|
|
52
|
+
if (opts.section !== undefined)
|
|
53
|
+
body['section_id'] = opts.section;
|
|
54
|
+
if (opts.unsetSection)
|
|
55
|
+
body['section_id'] = null;
|
|
56
|
+
if (opts.featured)
|
|
57
|
+
body['featured'] = true;
|
|
58
|
+
if (opts.unfeature)
|
|
59
|
+
body['featured'] = false;
|
|
60
|
+
if (opts.featuredNote !== undefined)
|
|
61
|
+
body['featured_note'] = opts.featuredNote;
|
|
52
62
|
const result = await client.updateItem(vaultId, itemId, body);
|
|
53
63
|
format(result, tableMode);
|
|
54
64
|
}
|
|
@@ -151,10 +161,26 @@ export function registerItems(program) {
|
|
|
151
161
|
.option('--tags <ids>', 'comma-separated tag IDs — REPLACES the full tag set')
|
|
152
162
|
.option('--notes <text>', 'free-text notes on the item')
|
|
153
163
|
.option('--pdf-url <url>', "publisher PDF link (the frontend's publisher_pdf field)")
|
|
164
|
+
.option('--section <sectionId>', 'file this item under a curated section — requires vault owner access')
|
|
165
|
+
.option('--unset-section', 'remove this item from its current section — requires vault owner access')
|
|
166
|
+
.option('--featured', 'mark this item as featured — requires vault owner access')
|
|
167
|
+
.option('--unfeature', 'remove this item from featured — requires vault owner access')
|
|
168
|
+
.option('--featured-note <text>', 'curator note shown alongside the featured item — requires vault owner access')
|
|
154
169
|
.action(async (itemId, opts, cmd) => {
|
|
170
|
+
if (opts.section && opts.unsetSection) {
|
|
171
|
+
process.stderr.write(JSON.stringify({ error: { code: 'invalid_options', message: 'Pass at most one of --section or --unset-section.' } }) + '\n');
|
|
172
|
+
process.exit(2);
|
|
173
|
+
}
|
|
174
|
+
if (opts.featured && opts.unfeature) {
|
|
175
|
+
process.stderr.write(JSON.stringify({ error: { code: 'invalid_options', message: 'Pass at most one of --featured or --unfeature.' } }) + '\n');
|
|
176
|
+
process.exit(2);
|
|
177
|
+
}
|
|
155
178
|
const g = cmd.optsWithGlobals();
|
|
156
179
|
const client = resolveClient(g.apiKey);
|
|
157
|
-
await run(() => handleItemUpdate(client, opts.vault, itemId, {
|
|
180
|
+
await run(() => handleItemUpdate(client, opts.vault, itemId, {
|
|
181
|
+
title: opts.title, authors: opts.authors, year: opts.year, doi: opts.doi, url: opts.url, tags: opts.tags, notes: opts.notes, pdfUrl: opts.pdfUrl,
|
|
182
|
+
section: opts.section, unsetSection: opts.unsetSection, featured: opts.featured, unfeature: opts.unfeature, featuredNote: opts.featuredNote,
|
|
183
|
+
}, g.table ?? false));
|
|
158
184
|
});
|
|
159
185
|
items
|
|
160
186
|
.command('delete')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveClient, run } from '../client.js';
|
|
2
2
|
import { format } from '../format.js';
|
|
3
|
+
import { registerRelationsScan } from './relationsScan.js';
|
|
3
4
|
const RELATION_TYPES = 'cites|extends|builds_on|contradicts|reviews|related';
|
|
4
5
|
export async function handleRelationsList(client, vaultId, type, tableMode) {
|
|
5
6
|
const result = await client.listRelations(vaultId, type);
|
|
@@ -66,4 +67,5 @@ export function registerRelations(program) {
|
|
|
66
67
|
const client = resolveClient(g.apiKey);
|
|
67
68
|
await run(() => handleRelationDelete(client, opts.vault, relationId));
|
|
68
69
|
});
|
|
70
|
+
registerRelationsScan(relations);
|
|
69
71
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { RefHubClient } from '../client.js';
|
|
3
|
+
import type { Item, Relation, SemanticScholarPaper } from '../types.js';
|
|
4
|
+
export declare function findMatchingItem(paper: SemanticScholarPaper, items: Item[], excludeId: string): Item | undefined;
|
|
5
|
+
export type ScanOutcome = 'skipped_no_doi' | 'lookup_failed' | 'no_matches' | 'scanned';
|
|
6
|
+
export interface ScanItemResult {
|
|
7
|
+
outcome: ScanOutcome;
|
|
8
|
+
suggested: number;
|
|
9
|
+
created: number;
|
|
10
|
+
skippedDuplicate: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Scans one item's Semantic Scholar references (papers it cites) and
|
|
14
|
+
* citations (papers that cite it), matches each against `allItems`, and
|
|
15
|
+
* creates a "cites" relation for every new match. `existingRelations` is
|
|
16
|
+
* mutated with pending creations so a whole-vault scan doesn't propose the
|
|
17
|
+
* same pair twice across items.
|
|
18
|
+
*/
|
|
19
|
+
export declare function scanItemRelations(item: Item, client: RefHubClient, vaultId: string, allItems: Item[], existingRelations: Relation[], opts: {
|
|
20
|
+
dryRun: boolean;
|
|
21
|
+
limit?: number;
|
|
22
|
+
}): Promise<ScanItemResult>;
|
|
23
|
+
export declare function registerRelationsScan(relations: Command): void;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { resolveClient, run } from '../client.js';
|
|
2
|
+
function normalizeDoi(doi) {
|
|
3
|
+
return doi.trim().toLowerCase().replace(/^https?:\/\/(dx\.)?doi\.org\//, '');
|
|
4
|
+
}
|
|
5
|
+
function normalizeTitle(title) {
|
|
6
|
+
return title.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
7
|
+
}
|
|
8
|
+
export function findMatchingItem(paper, items, excludeId) {
|
|
9
|
+
const paperDoi = paper.external_ids?.['DOI'] ?? paper.external_ids?.['doi'];
|
|
10
|
+
if (paperDoi) {
|
|
11
|
+
const normalized = normalizeDoi(paperDoi);
|
|
12
|
+
const doiMatch = items.find((i) => i.id !== excludeId && i.doi && normalizeDoi(i.doi) === normalized);
|
|
13
|
+
if (doiMatch)
|
|
14
|
+
return doiMatch;
|
|
15
|
+
}
|
|
16
|
+
if (paper.title) {
|
|
17
|
+
const normalized = normalizeTitle(paper.title);
|
|
18
|
+
return items.find((i) => i.id !== excludeId && i.title && normalizeTitle(i.title) === normalized);
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
function relationExists(relations, publicationId, relatedPublicationId) {
|
|
23
|
+
return relations.some((r) => r.publication_id === publicationId && r.related_publication_id === relatedPublicationId);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Scans one item's Semantic Scholar references (papers it cites) and
|
|
27
|
+
* citations (papers that cite it), matches each against `allItems`, and
|
|
28
|
+
* creates a "cites" relation for every new match. `existingRelations` is
|
|
29
|
+
* mutated with pending creations so a whole-vault scan doesn't propose the
|
|
30
|
+
* same pair twice across items.
|
|
31
|
+
*/
|
|
32
|
+
export async function scanItemRelations(item, client, vaultId, allItems, existingRelations, opts) {
|
|
33
|
+
if (!item.doi)
|
|
34
|
+
return { outcome: 'skipped_no_doi', suggested: 0, created: 0, skippedDuplicate: 0 };
|
|
35
|
+
const lookup = await client.semanticScholarLookup({ doi: item.doi });
|
|
36
|
+
const paperId = lookup.data.paper_id;
|
|
37
|
+
if (!paperId)
|
|
38
|
+
return { outcome: 'lookup_failed', suggested: 0, created: 0, skippedDuplicate: 0 };
|
|
39
|
+
const [referencesResult, citationsResult] = await Promise.all([
|
|
40
|
+
client.semanticScholarPaperList('references', paperId, opts.limit),
|
|
41
|
+
client.semanticScholarPaperList('citations', paperId, opts.limit),
|
|
42
|
+
]);
|
|
43
|
+
let suggested = 0;
|
|
44
|
+
let created = 0;
|
|
45
|
+
let skippedDuplicate = 0;
|
|
46
|
+
// references: this item cites the matched paper
|
|
47
|
+
for (const paper of referencesResult.data) {
|
|
48
|
+
const matched = findMatchingItem(paper, allItems, item.id);
|
|
49
|
+
if (!matched)
|
|
50
|
+
continue;
|
|
51
|
+
suggested++;
|
|
52
|
+
if (relationExists(existingRelations, item.id, matched.id)) {
|
|
53
|
+
skippedDuplicate++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!opts.dryRun) {
|
|
57
|
+
await client.createRelation(vaultId, { publication_id: item.id, related_publication_id: matched.id, relation_type: 'cites' });
|
|
58
|
+
}
|
|
59
|
+
existingRelations.push({ id: 'pending', vault_id: vaultId, publication_id: item.id, related_publication_id: matched.id, relation_type: 'cites', created_at: '', updated_at: '' });
|
|
60
|
+
created++;
|
|
61
|
+
}
|
|
62
|
+
// citations: the matched paper cites this item
|
|
63
|
+
for (const paper of citationsResult.data) {
|
|
64
|
+
const matched = findMatchingItem(paper, allItems, item.id);
|
|
65
|
+
if (!matched)
|
|
66
|
+
continue;
|
|
67
|
+
suggested++;
|
|
68
|
+
if (relationExists(existingRelations, matched.id, item.id)) {
|
|
69
|
+
skippedDuplicate++;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (!opts.dryRun) {
|
|
73
|
+
await client.createRelation(vaultId, { publication_id: matched.id, related_publication_id: item.id, relation_type: 'cites' });
|
|
74
|
+
}
|
|
75
|
+
existingRelations.push({ id: 'pending', vault_id: vaultId, publication_id: matched.id, related_publication_id: item.id, relation_type: 'cites', created_at: '', updated_at: '' });
|
|
76
|
+
created++;
|
|
77
|
+
}
|
|
78
|
+
return { outcome: suggested === 0 ? 'no_matches' : 'scanned', suggested, created, skippedDuplicate };
|
|
79
|
+
}
|
|
80
|
+
export function registerRelationsScan(relations) {
|
|
81
|
+
relations
|
|
82
|
+
.command('scan')
|
|
83
|
+
.description('Scan Semantic Scholar references/citations and create "cites" relations to sibling items in this vault, matched by DOI or exact title')
|
|
84
|
+
.requiredOption('--vault <id>')
|
|
85
|
+
.option('--item <itemId>', 'scan a single item instead of the whole vault')
|
|
86
|
+
.option('--dry-run', 'show what would be created without writing')
|
|
87
|
+
.option('--limit <n>', 'references/citations fetched per item from Semantic Scholar, 1-25', (v) => parseInt(v, 10))
|
|
88
|
+
.action(async (opts, cmd) => {
|
|
89
|
+
const g = cmd.optsWithGlobals();
|
|
90
|
+
const client = resolveClient(g.apiKey);
|
|
91
|
+
const dryRun = opts.dryRun ?? false;
|
|
92
|
+
await run(async () => {
|
|
93
|
+
const vaultResult = await client.getVault(opts.vault);
|
|
94
|
+
const allItems = vaultResult.data.items;
|
|
95
|
+
const existingRelations = [...vaultResult.data.relations];
|
|
96
|
+
const targets = opts.item ? allItems.filter((i) => i.id === opts.item) : allItems;
|
|
97
|
+
if (opts.item && targets.length === 0) {
|
|
98
|
+
process.stderr.write(JSON.stringify({ error: { code: 'item_not_found', message: `Item ${opts.item} not found in vault ${opts.vault}.` } }) + '\n');
|
|
99
|
+
process.exit(2);
|
|
100
|
+
}
|
|
101
|
+
const withDoi = targets.filter((i) => i.doi);
|
|
102
|
+
if (withDoi.length === 0) {
|
|
103
|
+
process.stdout.write(JSON.stringify({ data: { dry_run: dryRun, scanned: 0, suggested: 0, created: 0, skipped_duplicate: 0, no_doi: targets.length, message: 'No items with a DOI to scan.' } }, null, 2) + '\n');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
let suggested = 0;
|
|
107
|
+
let created = 0;
|
|
108
|
+
let skippedDuplicate = 0;
|
|
109
|
+
let noMatches = 0;
|
|
110
|
+
let lookupFailed = 0;
|
|
111
|
+
for (const item of withDoi) {
|
|
112
|
+
const result = await scanItemRelations(item, client, opts.vault, allItems, existingRelations, { dryRun, limit: opts.limit });
|
|
113
|
+
suggested += result.suggested;
|
|
114
|
+
created += result.created;
|
|
115
|
+
skippedDuplicate += result.skippedDuplicate;
|
|
116
|
+
if (result.outcome === 'no_matches')
|
|
117
|
+
noMatches++;
|
|
118
|
+
if (result.outcome === 'lookup_failed')
|
|
119
|
+
lookupFailed++;
|
|
120
|
+
// pace Semantic Scholar calls — each item makes a lookup + references + citations request
|
|
121
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
122
|
+
}
|
|
123
|
+
process.stdout.write(JSON.stringify({
|
|
124
|
+
data: {
|
|
125
|
+
dry_run: dryRun,
|
|
126
|
+
scanned: withDoi.length,
|
|
127
|
+
no_doi: targets.length - withDoi.length,
|
|
128
|
+
lookup_failed: lookupFailed,
|
|
129
|
+
no_matches: noMatches,
|
|
130
|
+
suggested,
|
|
131
|
+
created,
|
|
132
|
+
skipped_duplicate: skippedDuplicate,
|
|
133
|
+
},
|
|
134
|
+
}, null, 2) + '\n');
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { RefHubClient } from '../client.js';
|
|
3
|
+
export declare function handleSectionsList(client: RefHubClient, vaultId: string, tableMode: boolean): Promise<void>;
|
|
4
|
+
export declare function handleSectionCreate(client: RefHubClient, vaultId: string, opts: {
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
position?: number;
|
|
8
|
+
}, tableMode: boolean): Promise<void>;
|
|
9
|
+
export declare function handleSectionUpdate(client: RefHubClient, vaultId: string, sectionId: string, opts: {
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
position?: number;
|
|
13
|
+
}, tableMode: boolean): Promise<void>;
|
|
14
|
+
export declare function handleSectionDelete(client: RefHubClient, vaultId: string, sectionId: string): Promise<void>;
|
|
15
|
+
export declare function registerSections(program: Command): void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { resolveClient, run } from '../client.js';
|
|
2
|
+
import { format } from '../format.js';
|
|
3
|
+
export async function handleSectionsList(client, vaultId, tableMode) {
|
|
4
|
+
const result = await client.listSections(vaultId);
|
|
5
|
+
format(result, tableMode, ['id', 'name', 'description', 'position']);
|
|
6
|
+
}
|
|
7
|
+
export async function handleSectionCreate(client, vaultId, opts, tableMode) {
|
|
8
|
+
const body = { name: opts.name };
|
|
9
|
+
if (opts.description !== undefined)
|
|
10
|
+
body.description = opts.description;
|
|
11
|
+
if (opts.position !== undefined)
|
|
12
|
+
body.position = opts.position;
|
|
13
|
+
const result = await client.createSection(vaultId, body);
|
|
14
|
+
format(result, tableMode);
|
|
15
|
+
}
|
|
16
|
+
export async function handleSectionUpdate(client, vaultId, sectionId, opts, tableMode) {
|
|
17
|
+
const body = {};
|
|
18
|
+
if (opts.name !== undefined)
|
|
19
|
+
body.name = opts.name;
|
|
20
|
+
if (opts.description !== undefined)
|
|
21
|
+
body.description = opts.description;
|
|
22
|
+
if (opts.position !== undefined)
|
|
23
|
+
body.position = opts.position;
|
|
24
|
+
const result = await client.updateSection(vaultId, sectionId, body);
|
|
25
|
+
format(result, tableMode);
|
|
26
|
+
}
|
|
27
|
+
export async function handleSectionDelete(client, vaultId, sectionId) {
|
|
28
|
+
const result = await client.deleteSection(vaultId, sectionId);
|
|
29
|
+
format(result, false);
|
|
30
|
+
}
|
|
31
|
+
export function registerSections(program) {
|
|
32
|
+
const sections = program.command('sections').description('Manage curated vault sections (owner-only writes)');
|
|
33
|
+
sections
|
|
34
|
+
.command('list')
|
|
35
|
+
.description('List sections in a vault')
|
|
36
|
+
.requiredOption('--vault <id>')
|
|
37
|
+
.action(async (opts, cmd) => {
|
|
38
|
+
const g = cmd.optsWithGlobals();
|
|
39
|
+
const client = resolveClient(g.apiKey);
|
|
40
|
+
await run(() => handleSectionsList(client, opts.vault, g.table ?? false));
|
|
41
|
+
});
|
|
42
|
+
sections
|
|
43
|
+
.command('create')
|
|
44
|
+
.description('Create a section (owner-only)')
|
|
45
|
+
.requiredOption('--vault <id>')
|
|
46
|
+
.requiredOption('--name <name>')
|
|
47
|
+
.option('--description <text>')
|
|
48
|
+
.option('--position <n>', 'sort position, defaults to 0', (v) => parseInt(v, 10))
|
|
49
|
+
.action(async (opts, cmd) => {
|
|
50
|
+
const g = cmd.optsWithGlobals();
|
|
51
|
+
const client = resolveClient(g.apiKey);
|
|
52
|
+
await run(() => handleSectionCreate(client, opts.vault, { name: opts.name, description: opts.description, position: opts.position }, g.table ?? false));
|
|
53
|
+
});
|
|
54
|
+
sections
|
|
55
|
+
.command('update')
|
|
56
|
+
.argument('<sectionId>')
|
|
57
|
+
.description('Update a section (owner-only)')
|
|
58
|
+
.requiredOption('--vault <id>')
|
|
59
|
+
.option('--name <name>')
|
|
60
|
+
.option('--description <text>')
|
|
61
|
+
.option('--position <n>', '', (v) => parseInt(v, 10))
|
|
62
|
+
.action(async (sectionId, opts, cmd) => {
|
|
63
|
+
const g = cmd.optsWithGlobals();
|
|
64
|
+
const client = resolveClient(g.apiKey);
|
|
65
|
+
await run(() => handleSectionUpdate(client, opts.vault, sectionId, { name: opts.name, description: opts.description, position: opts.position }, g.table ?? false));
|
|
66
|
+
});
|
|
67
|
+
sections
|
|
68
|
+
.command('delete')
|
|
69
|
+
.argument('<sectionId>')
|
|
70
|
+
.description('Delete a section (owner-only) — items in it are unfiled, not deleted')
|
|
71
|
+
.requiredOption('--vault <id>')
|
|
72
|
+
.action(async (sectionId, opts, cmd) => {
|
|
73
|
+
const g = cmd.optsWithGlobals();
|
|
74
|
+
const client = resolveClient(g.apiKey);
|
|
75
|
+
await run(() => handleSectionDelete(client, opts.vault, sectionId));
|
|
76
|
+
});
|
|
77
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createRequire } from 'module';
|
|
|
4
4
|
import { registerVaults } from './commands/vaults.js';
|
|
5
5
|
import { registerItems } from './commands/items.js';
|
|
6
6
|
import { registerTags } from './commands/tags.js';
|
|
7
|
+
import { registerSections } from './commands/sections.js';
|
|
7
8
|
import { registerRelations } from './commands/relations.js';
|
|
8
9
|
import { registerImport } from './commands/import.js';
|
|
9
10
|
import { registerExport } from './commands/export.js';
|
|
@@ -11,6 +12,7 @@ import { registerAudit } from './commands/audit.js';
|
|
|
11
12
|
import { registerEnrich } from './commands/enrich.js';
|
|
12
13
|
import { registerPdf } from './commands/pdf.js';
|
|
13
14
|
import { registerDiscover } from './commands/discover.js';
|
|
15
|
+
import { registerInbox } from './commands/inbox.js';
|
|
14
16
|
const require = createRequire(import.meta.url);
|
|
15
17
|
const { version } = require('../package.json');
|
|
16
18
|
const program = new Command();
|
|
@@ -23,6 +25,7 @@ program
|
|
|
23
25
|
registerVaults(program);
|
|
24
26
|
registerItems(program);
|
|
25
27
|
registerTags(program);
|
|
28
|
+
registerSections(program);
|
|
26
29
|
registerRelations(program);
|
|
27
30
|
registerImport(program);
|
|
28
31
|
registerExport(program);
|
|
@@ -30,4 +33,5 @@ registerAudit(program);
|
|
|
30
33
|
registerEnrich(program);
|
|
31
34
|
registerDiscover(program);
|
|
32
35
|
registerPdf(program);
|
|
36
|
+
registerInbox(program);
|
|
33
37
|
program.parseAsync();
|
package/dist/types.d.ts
CHANGED
|
@@ -29,10 +29,23 @@ export interface Item {
|
|
|
29
29
|
pdf_url?: string;
|
|
30
30
|
drive_pdf_url?: string | null;
|
|
31
31
|
tag_ids: string[];
|
|
32
|
+
section_id?: string | null;
|
|
33
|
+
section_position?: number;
|
|
34
|
+
featured?: boolean;
|
|
35
|
+
featured_note?: string | null;
|
|
32
36
|
version: number;
|
|
33
37
|
created_at: string;
|
|
34
38
|
updated_at: string;
|
|
35
39
|
}
|
|
40
|
+
export interface Section {
|
|
41
|
+
id: string;
|
|
42
|
+
vault_id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string | null;
|
|
45
|
+
position: number;
|
|
46
|
+
created_at: string;
|
|
47
|
+
updated_at: string;
|
|
48
|
+
}
|
|
36
49
|
export interface Tag {
|
|
37
50
|
id: string;
|
|
38
51
|
vault_id: string;
|
|
@@ -100,6 +113,22 @@ export interface AuditEntry {
|
|
|
100
113
|
metadata?: Record<string, unknown>;
|
|
101
114
|
created_at: string;
|
|
102
115
|
}
|
|
116
|
+
export type InboxSourceType = 'doi' | 'bibtex' | 'manual';
|
|
117
|
+
export type InboxItemStatus = 'pending' | 'accepted' | 'rejected' | 'merged';
|
|
118
|
+
export interface InboxItem {
|
|
119
|
+
id: string;
|
|
120
|
+
status: InboxItemStatus;
|
|
121
|
+
source_type: InboxSourceType;
|
|
122
|
+
source_ref: string;
|
|
123
|
+
parsed_fields: Record<string, unknown>;
|
|
124
|
+
suggested_vault_id: string | null;
|
|
125
|
+
suggested_tag_ids: string[] | null;
|
|
126
|
+
duplicate_of_publication_id: string | null;
|
|
127
|
+
filed_publication_id: string | null;
|
|
128
|
+
sort_order: number;
|
|
129
|
+
created_at: string;
|
|
130
|
+
updated_at: string;
|
|
131
|
+
}
|
|
103
132
|
export interface ApiResponse<T> {
|
|
104
133
|
data: T;
|
|
105
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refhub/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "refhub CLI execution layer for agent skills",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/refhub-io/refhub-cli/issues"
|
|
13
13
|
},
|
|
14
|
-
"engines": {
|
|
15
|
-
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18"
|
|
16
|
+
},
|
|
17
|
+
"bin": {
|
|
18
|
+
"refhub": "bin/refhub.js"
|
|
19
|
+
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"build": "tsc",
|
|
18
22
|
"test": "vitest run",
|
|
@@ -20,7 +24,10 @@
|
|
|
20
24
|
"smoke": "tsx scripts/smoke.ts",
|
|
21
25
|
"dev": "tsx src/index.ts"
|
|
22
26
|
},
|
|
23
|
-
"files": [
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"bin"
|
|
30
|
+
],
|
|
24
31
|
"publishConfig": {
|
|
25
32
|
"access": "public"
|
|
26
33
|
},
|