lattris 0.2.2 → 0.2.4
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 +1 -1
- package/dist/build.json +1 -1
- package/dist/dispatch-form.js +41 -8
- package/dist/dispatch-words.js +4 -2
- package/dist/help.js +1 -1
- package/dist/memory/access.js +3 -1
- package/dist/memory/capture-help.js +3 -1
- package/dist/memory/get-help.js +3 -1
- package/dist/memory/get.js +73 -11
- package/dist/memory/source.js +85 -0
- package/dist/memory/types.js +2 -0
- package/dist/memory/update-help.js +1 -1
- package/dist/memory/views.js +75 -4
- package/dist/nouns/edges.js +3 -1
- package/dist/nouns/index.js +12 -1
- package/dist/nouns/invite.js +13 -14
- package/dist/nouns/share.js +73 -10
- package/dist/nouns/subscribers.js +163 -0
- package/dist/nouns/types.js +2 -0
- package/dist/nouns/words.js +6 -0
- package/dist/registry/memory.js +14 -2
- package/dist/render/shares.js +28 -0
- package/dist/store/write-identity.js +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ sign you up.
|
|
|
41
41
|
## What it does
|
|
42
42
|
|
|
43
43
|
```
|
|
44
|
-
lattris capture write a note, a session or a
|
|
44
|
+
lattris capture write a note, a session, a recording or a source, or rows of a dataset
|
|
45
45
|
lattris note a single note
|
|
46
46
|
lattris session a session and its turns
|
|
47
47
|
lattris recording a recording and its transcript
|
package/dist/build.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"commit":"
|
|
1
|
+
{"commit":"dc66fbb3976033f182a724475ba45e03afd5ec17","builtAt":"2026-11-05T05:03:06Z"}
|
package/dist/dispatch-form.js
CHANGED
|
@@ -3,6 +3,7 @@ import { emit } from "./render/output.js";
|
|
|
3
3
|
import { confirmAction } from "./render/prompt.js";
|
|
4
4
|
import { ambiguousText, formatContact, groupsNotBuilt, isGroupWord } from "./render/rows.js";
|
|
5
5
|
import { renderRunHint, sanitizeForTerminal } from "./render/text.js";
|
|
6
|
+
import { NO_LONGER_SHARED } from "./render/shares.js";
|
|
6
7
|
import { signedIn } from "./request/access-token.js";
|
|
7
8
|
import { refusalOf } from "./request/api-fetch.js";
|
|
8
9
|
import { EXIT, isRefusal } from "./store/exit.js";
|
|
@@ -58,9 +59,13 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
58
59
|
if (body && form.request.emptyBodyMessage && Object.keys(body).length === 0) {
|
|
59
60
|
return refuse(form.request.emptyBodyMessage);
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
|
|
62
|
+
let accessToken;
|
|
63
|
+
if (form.credential !== 'none') {
|
|
64
|
+
const signed = await signedIn(io, cfg);
|
|
65
|
+
if (typeof signed !== 'string')
|
|
66
|
+
return signed;
|
|
67
|
+
accessToken = signed;
|
|
68
|
+
}
|
|
64
69
|
let missingName;
|
|
65
70
|
let recording = false;
|
|
66
71
|
const reserved = [
|
|
@@ -126,9 +131,29 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
126
131
|
}
|
|
127
132
|
if (steps.memory === 'always' || (steps.memory === 'at-tty' && io.stdin.isTTY)) {
|
|
128
133
|
const fetched = await io.api(accessToken, `${cfg.apiUrl}/memories/${encodeURIComponent(typed.positionals[0])}`);
|
|
129
|
-
if (
|
|
134
|
+
if (fetched.ok) {
|
|
135
|
+
context.memory = fetched.data;
|
|
136
|
+
}
|
|
137
|
+
else if (steps.memoryMayBeGone &&
|
|
138
|
+
fetched.status === 404 &&
|
|
139
|
+
fetched.body.code === 'memory:not-found') {
|
|
140
|
+
context.gone = true;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
return refusalOf(fetched, ambiguousText(fetched.body));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (steps.subscriber) {
|
|
147
|
+
const fetched = await io.api(accessToken, `${cfg.apiUrl}/subscribers/${encodeURIComponent(typed.positionals[0])}`);
|
|
148
|
+
if (!fetched.ok) {
|
|
130
149
|
return refusalOf(fetched, ambiguousText(fetched.body));
|
|
131
|
-
|
|
150
|
+
}
|
|
151
|
+
context.subscriber = fetched.data;
|
|
152
|
+
}
|
|
153
|
+
if (steps.noAudienceReport &&
|
|
154
|
+
typed.flags[steps.noAudienceReport.key] === undefined &&
|
|
155
|
+
context.gone) {
|
|
156
|
+
return refuse(steps.noAudienceReport.first);
|
|
132
157
|
}
|
|
133
158
|
if (steps.noAudienceReport && typed.flags[steps.noAudienceReport.key] === undefined) {
|
|
134
159
|
const title = sanitizeForTerminal(context.memory?.title ?? '(untitled)');
|
|
@@ -148,10 +173,13 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
148
173
|
: steps.confirm.question, {
|
|
149
174
|
...Object.fromEntries(typed.positionals.map((p, i) => [`p${i}`, sanitizeForTerminal(p)])),
|
|
150
175
|
name,
|
|
151
|
-
title:
|
|
152
|
-
|
|
176
|
+
title: context.gone
|
|
177
|
+
? NO_LONGER_SHARED
|
|
178
|
+
: sanitizeForTerminal(context.memory?.title ?? '(untitled)'),
|
|
179
|
+
'memory.id': context.memory?.id ?? sanitizeForTerminal(typed.positionals[0] ?? ''),
|
|
153
180
|
'contact.id': context.contact?.id ?? '',
|
|
154
181
|
email: sanitizeForTerminal(context.email ?? ''),
|
|
182
|
+
'subscriber.email': sanitizeForTerminal(context.subscriber?.email ?? ''),
|
|
155
183
|
audience: context.contact?.displayName ?? describeAudience(selector ?? '')
|
|
156
184
|
});
|
|
157
185
|
const answer = await confirmAction(io, question);
|
|
@@ -213,6 +241,10 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
213
241
|
context.contact?.claimedPersonId) {
|
|
214
242
|
result = await send(new URL(`${cfg.apiUrl}${fillPath(fallback.path, typed, context)}`));
|
|
215
243
|
}
|
|
244
|
+
const instead = result.ok ? undefined : form.refusalInstead?.[result.body.code ?? ''];
|
|
245
|
+
if (!result.ok && instead !== undefined) {
|
|
246
|
+
return refuse(fillIn(instead, { 'subscriber.email': sanitizeForTerminal(context.subscriber?.email ?? '') }), result.exit);
|
|
247
|
+
}
|
|
216
248
|
if (!result.ok) {
|
|
217
249
|
return refusalOf(result, (form.ambiguousRefusal ? ambiguousText(result.body) : '') +
|
|
218
250
|
(form.refusalWords?.(result.body, context) ?? ''));
|
|
@@ -244,7 +276,8 @@ export const runForm = async (cfg, io, form, rest) => {
|
|
|
244
276
|
emit(io, result.data, result.rawText, (data) => form.render(data, typedView));
|
|
245
277
|
const next = form.page ? result.data[form.page.cursor] : undefined;
|
|
246
278
|
if (form.page && typeof next === 'string' && io.stdout.isTTY) {
|
|
247
|
-
|
|
279
|
+
const carried = Object.entries(form.page.carry ?? {}).flatMap(([flag, key]) => typed.flags[key] === undefined ? [] : [flag, typed.flags[key]]);
|
|
280
|
+
io.stderr.write(`More: ${renderRunHint([...form.page.hint, ...carried, '--cursor', next])}\n`);
|
|
248
281
|
}
|
|
249
282
|
};
|
|
250
283
|
//# sourceMappingURL=dispatch-form.js.map
|
package/dist/dispatch-words.js
CHANGED
|
@@ -86,8 +86,10 @@ export const readWords = (form, rest) => {
|
|
|
86
86
|
export const valueOf = (source, typed, stdin, context) => {
|
|
87
87
|
if ('flag' in source)
|
|
88
88
|
return typed.flags[source.flag];
|
|
89
|
-
if ('positional' in source)
|
|
90
|
-
|
|
89
|
+
if ('positional' in source) {
|
|
90
|
+
const value = typed.positionals[source.positional];
|
|
91
|
+
return source.trim && value !== undefined ? value.trim() : value;
|
|
92
|
+
}
|
|
91
93
|
if ('stdin' in source)
|
|
92
94
|
return stdin;
|
|
93
95
|
if ('context' in source) {
|
package/dist/help.js
CHANGED
|
@@ -40,7 +40,7 @@ export const usage = (term) => {
|
|
|
40
40
|
' LATTRIS_API lattris-api base (http://localhost:54301)',
|
|
41
41
|
' LATTRIS_CLIENT_ID OAuth client id (lattris-cli)',
|
|
42
42
|
' LATTRIS_REDIRECT_PORT loopback callback (4577)',
|
|
43
|
-
' LATTRIS_SESSION_ID names this session on every note write (required off a terminal)',
|
|
43
|
+
' LATTRIS_SESSION_ID names this session on every note or source write (required off a terminal)',
|
|
44
44
|
' LATTRIS_AGENT a readable label for it (optional)',
|
|
45
45
|
'',
|
|
46
46
|
'Session resolution (which identity a command acts as), in order:',
|
package/dist/memory/access.js
CHANGED
|
@@ -20,7 +20,9 @@ export const GET_ACCESS_HELP = [
|
|
|
20
20
|
'',
|
|
21
21
|
'Answers open or shut, and the rows that decided it: the denies that reach',
|
|
22
22
|
'the contact when one does, the allows that reach them when open, or',
|
|
23
|
-
'nothing when nothing is set.'
|
|
23
|
+
'nothing when nothing is set. A memory no longer shared with you answers',
|
|
24
|
+
'nothing here: your shares on it decide nothing until it is shared again,',
|
|
25
|
+
'and `lattris get shares` lists them.'
|
|
24
26
|
].join('\n');
|
|
25
27
|
const ACCESS_FLAGS = { '--for': 'for' };
|
|
26
28
|
const isPhoneWord = (word) => word.startsWith('+');
|
|
@@ -5,6 +5,7 @@ export const CAPTURE_INDEX = [
|
|
|
5
5
|
' note written words — --type defaults to it',
|
|
6
6
|
' session a conversation with an AI, kept as an append-only ledger',
|
|
7
7
|
' recording audio, its source, and its transcript',
|
|
8
|
+
' source a link you keep: a page, a post, a video',
|
|
8
9
|
' rows rows of a dataset, newline-delimited JSON',
|
|
9
10
|
'',
|
|
10
11
|
'Go one word deeper:',
|
|
@@ -13,6 +14,7 @@ export const CAPTURE_INDEX = [
|
|
|
13
14
|
' lattris capture memory --type session how to save a conversation (capture session accepted too)',
|
|
14
15
|
' lattris capture session <transcript.jsonl> save a Claude Code conversation, whole chain',
|
|
15
16
|
' lattris capture recording how to save audio + transcript',
|
|
17
|
+
' lattris capture source how to keep a link',
|
|
16
18
|
' lattris capture rows how to save rows into a dataset',
|
|
17
19
|
'',
|
|
18
20
|
'To read what you have kept: lattris get memories',
|
|
@@ -60,7 +62,7 @@ noticed "Mum seemed quieter than usual today."
|
|
|
60
62
|
no intent "That thing about the school waiting list — look into it."
|
|
61
63
|
"Summary of the article on sleep — haven't decided what I make of it."
|
|
62
64
|
|
|
63
|
-
to save text arrives on stdin — no quoting; up to
|
|
65
|
+
to save text arrives on stdin — no quoting; up to 128KB.
|
|
64
66
|
|
|
65
67
|
lattris capture which forms exist
|
|
66
68
|
lattris capture memory prints this (capture note accepted too)
|
package/dist/memory/get-help.js
CHANGED
|
@@ -31,7 +31,8 @@ export const GET_HELP = [
|
|
|
31
31
|
' --limit <n> page size, 1-100 (default 50)',
|
|
32
32
|
' --cursor <token> the nextCursor from a previous page',
|
|
33
33
|
' --by <handle> one wall on the website address; an id without a',
|
|
34
|
-
' session needs it, while a full address carries it',
|
|
34
|
+
' session needs it, while a full address carries it;',
|
|
35
|
+
' an id shared with you is found without it',
|
|
35
36
|
' --shared-with-me list memories other people granted to you; each row',
|
|
36
37
|
' names its owner and whether it is on your graph',
|
|
37
38
|
' --for <contact> what one of your contacts may see of your memories and',
|
|
@@ -66,6 +67,7 @@ export const GET_HELP = [
|
|
|
66
67
|
'Your own read of a memory also prints `access`: every allow and deny on it.',
|
|
67
68
|
'',
|
|
68
69
|
"A memory's web address is <site>/by/<owner-handle>/memories/<slug>-<memory-handle>.",
|
|
70
|
+
'A website address keeps its own links, depth and content; a flag typed here wins for that lever.',
|
|
69
71
|
'A /by read asks for JSON with Accept: application/json; it sends a bearer',
|
|
70
72
|
'only when the session has a live one. `get memory` prints the address at a TTY.',
|
|
71
73
|
'',
|
package/dist/memory/get.js
CHANGED
|
@@ -1,28 +1,76 @@
|
|
|
1
1
|
import { parseArgs } from "../request/flags.js";
|
|
2
2
|
import { contactIdFor } from "../memory/access.js";
|
|
3
3
|
import { getRevision } from "../memory/history.js";
|
|
4
|
-
import { composeAddress, formatMemoryDetail, formatMemoryPage, formatNodeWalk, ownHandleFor, parseWebsiteMemoryAddress } from "../memory/views.js";
|
|
4
|
+
import { composeAddress, formatMemoryDetail, formatMemoryPage, formatNodeWalk, leversFor, leversInAddress, ownHandleFor, parseWebsiteMemoryAddress } from "../memory/views.js";
|
|
5
5
|
import { emit } from "../render/output.js";
|
|
6
6
|
import { ambiguousText } from "../render/rows.js";
|
|
7
|
-
import { renderRunHint } from "../render/text.js";
|
|
7
|
+
import { renderRunHint, sanitizeForTerminal } from "../render/text.js";
|
|
8
8
|
import { optionalAccessToken, signedIn } from "../request/access-token.js";
|
|
9
9
|
import { refusalOf } from "../request/api-fetch.js";
|
|
10
|
-
import { refusal } from "../store/exit.js";
|
|
10
|
+
import { EXIT, refusal } from "../store/exit.js";
|
|
11
11
|
import { loadSession, saveSession } from "../store/session.js";
|
|
12
|
+
import { isUuidKey } from "../store/write-identity.js";
|
|
13
|
+
const valuesOf = (value) => (Array.isArray(value) ? value : [value]);
|
|
12
14
|
export const buildGetMemoryUrl = (webUrl, ownerHandle, ref, flags) => {
|
|
13
15
|
const url = new URL(`${webUrl}/by/${encodeURIComponent(ownerHandle)}/memories/${encodeURIComponent(ref)}`);
|
|
14
16
|
const links = flags.links ?? '1';
|
|
15
17
|
const bare = links === '0' && flags.depth === undefined && flags.content === undefined;
|
|
16
18
|
if (!bare) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (flags.
|
|
21
|
-
|
|
19
|
+
for (const value of valuesOf(links)) {
|
|
20
|
+
url.searchParams.append('links', value);
|
|
21
|
+
}
|
|
22
|
+
if (flags.depth !== undefined) {
|
|
23
|
+
for (const value of valuesOf(flags.depth)) {
|
|
24
|
+
url.searchParams.append('depth', value);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (flags.content !== undefined) {
|
|
28
|
+
for (const value of valuesOf(flags.content)) {
|
|
29
|
+
url.searchParams.append('content', value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
22
32
|
}
|
|
23
33
|
return url;
|
|
24
34
|
};
|
|
25
|
-
const
|
|
35
|
+
const SHARED_PAGE_SIZE = '100';
|
|
36
|
+
const SHARED_PAGES_MAX = 5;
|
|
37
|
+
const isSharedRow = (row) => typeof row.ownerHandle === 'string' && row.ownerHandle !== '';
|
|
38
|
+
const answersRef = (ref) => (row) => isUuidKey(ref)
|
|
39
|
+
? row.id === ref.toLowerCase()
|
|
40
|
+
: row.handle === ref.slice(ref.lastIndexOf('-') + 1);
|
|
41
|
+
const sharedRows = async (cfg, io, accessToken, cursor, pagesLeft) => {
|
|
42
|
+
const url = new URL(`${cfg.apiUrl}/memories`);
|
|
43
|
+
url.searchParams.set('sharedWithMe', '1');
|
|
44
|
+
url.searchParams.set('content', '0');
|
|
45
|
+
url.searchParams.set('limit', SHARED_PAGE_SIZE);
|
|
46
|
+
if (cursor !== null) {
|
|
47
|
+
url.searchParams.set('cursor', cursor);
|
|
48
|
+
}
|
|
49
|
+
const result = await io.api(accessToken, url);
|
|
50
|
+
if (!result.ok) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
const rows = result.data.items.filter(isSharedRow);
|
|
54
|
+
if (!result.data.nextCursor || pagesLeft === 1) {
|
|
55
|
+
return rows;
|
|
56
|
+
}
|
|
57
|
+
const rest = await sharedRows(cfg, io, accessToken, result.data.nextCursor, pagesLeft - 1);
|
|
58
|
+
return rest === undefined ? undefined : rows.concat(rest);
|
|
59
|
+
};
|
|
60
|
+
const sharedMatches = async (cfg, io, accessToken, ref) => {
|
|
61
|
+
const rows = await sharedRows(cfg, io, accessToken, null, SHARED_PAGES_MAX);
|
|
62
|
+
if (rows === undefined) {
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
const byId = new Map(rows.filter(answersRef(ref)).map((row) => [row.id, row]));
|
|
66
|
+
return Array.from(byId.values());
|
|
67
|
+
};
|
|
68
|
+
const sharedAmbiguityText = (matches) => 'That handle names memories shared with you by more than one owner.\n' +
|
|
69
|
+
matches
|
|
70
|
+
.map((m) => ` ${m.id} @${sanitizeForTerminal(m.ownerHandle)} ${sanitizeForTerminal(m.title ?? '(untitled)')}\n`)
|
|
71
|
+
.join('') +
|
|
72
|
+
'Use get memory <id> --by <owner-handle>.\n';
|
|
73
|
+
const getMemory = async (cfg, io, idOrAddress, flags, by, lookShared) => {
|
|
26
74
|
const isAddress = /^https?:\/\//i.test(idOrAddress);
|
|
27
75
|
const address = isAddress ? parseWebsiteMemoryAddress(cfg.webUrl, idOrAddress) : undefined;
|
|
28
76
|
if (isAddress && !address) {
|
|
@@ -50,13 +98,27 @@ const getMemory = async (cfg, io, idOrAddress, flags, by) => {
|
|
|
50
98
|
return refusal('A memory id needs its wall: use get memory <website-address> or get memory <id> --by <owner-handle>.\n');
|
|
51
99
|
}
|
|
52
100
|
accessToken ??= await optionalAccessToken(io, cfg);
|
|
53
|
-
const
|
|
101
|
+
const levers = address === undefined ? flags : leversFor(flags, leversInAddress(idOrAddress));
|
|
102
|
+
const url = buildGetMemoryUrl(cfg.webUrl, ownerHandle, address?.ref ?? idOrAddress, levers);
|
|
54
103
|
const enveloped = url.search !== '';
|
|
55
104
|
const result = await io.api(accessToken, url, {
|
|
56
105
|
headers: { Accept: 'application/json' },
|
|
57
106
|
retryAnonymousOn401: true
|
|
58
107
|
}, 'web');
|
|
59
108
|
if (!result.ok) {
|
|
109
|
+
if (lookShared &&
|
|
110
|
+
result.body.code === 'memory:not-found' &&
|
|
111
|
+
!address &&
|
|
112
|
+
!by &&
|
|
113
|
+
accessToken !== undefined) {
|
|
114
|
+
const matches = await sharedMatches(cfg, io, accessToken, idOrAddress);
|
|
115
|
+
if (matches.length === 1) {
|
|
116
|
+
return getMemory(cfg, io, matches[0].id, flags, matches[0].ownerHandle, false);
|
|
117
|
+
}
|
|
118
|
+
if (matches.length > 1) {
|
|
119
|
+
return refusal(sharedAmbiguityText(matches), EXIT.GENERIC);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
60
122
|
return refusalOf(result, ambiguousText(result.body) +
|
|
61
123
|
(result.body.code === 'memory:not-found' && !address && !by
|
|
62
124
|
? 'For another wall, use get memory <website-address> or get memory <id> --by <owner-handle>.\n'
|
|
@@ -216,7 +278,7 @@ export const getMemories = async (cfg, io, rest, noun) => {
|
|
|
216
278
|
}
|
|
217
279
|
return getRevision(cfg, io, id, flags.revision);
|
|
218
280
|
}
|
|
219
|
-
return getMemory(cfg, io, id, { links: flags.links, depth: flags.depth, content: flags.content }, flags.by);
|
|
281
|
+
return getMemory(cfg, io, id, { links: flags.links, depth: flags.depth, content: flags.content }, flags.by, true);
|
|
220
282
|
}
|
|
221
283
|
else if (noun === 'memories') {
|
|
222
284
|
const walkFlag = WALK_ONLY_FLAGS.find((k) => flags[k] !== undefined);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { sourceFacts } from "../memory/views.js";
|
|
2
|
+
import { emit } from "../render/output.js";
|
|
3
|
+
import { sanitizeForTerminal } from "../render/text.js";
|
|
4
|
+
import { signedIn } from "../request/access-token.js";
|
|
5
|
+
import { refusalOf } from "../request/api-fetch.js";
|
|
6
|
+
import { parseArgs } from "../request/flags.js";
|
|
7
|
+
import { isRefusal, refusal } from "../store/exit.js";
|
|
8
|
+
import { SOURCE_SESSION_ID_DOOR, noteWriteHeaders, requireWriteIdentity } from "../store/write-identity.js";
|
|
9
|
+
const CAPTURE_SOURCE_USAGE = 'Usage: lattris capture source <url> [--title-at-source "…"] [--site "…"] [--author "…"] [--published-at <time>] [--title "…"]';
|
|
10
|
+
export const CAPTURE_SOURCE_HELP = `capture source — keep a link: a page, a post, a video.
|
|
11
|
+
|
|
12
|
+
Lattris never visits the page: its title, site, author and date are what you
|
|
13
|
+
say here.
|
|
14
|
+
|
|
15
|
+
Keeping a link you already keep answers the source you have, even when the
|
|
16
|
+
address differs a little, and changes nothing, so running it again is safe.
|
|
17
|
+
|
|
18
|
+
${CAPTURE_SOURCE_USAGE}
|
|
19
|
+
|
|
20
|
+
<url> the page's full address, starting https:// or http://
|
|
21
|
+
--title-at-source the page's own title, as the page gives it
|
|
22
|
+
--site the site it is on, such as a publication
|
|
23
|
+
--author who wrote it, as the page says
|
|
24
|
+
--published-at when it was published (ISO 8601, with its time and zone)
|
|
25
|
+
--title your own one line for it
|
|
26
|
+
|
|
27
|
+
It is private until you share it (lattris share memory <id> --with <audience>).
|
|
28
|
+
Your thoughts on it go in a note, linked to it with lattris link, from the
|
|
29
|
+
source to the note or from the note to the source; a verb the pair cannot take
|
|
30
|
+
is refused with the ones it can.
|
|
31
|
+
|
|
32
|
+
saved → prints the id and what the source keeps. lattris get memories --type
|
|
33
|
+
source lists your sources, and --q finds one by words of its title or address.`;
|
|
34
|
+
const SOURCE_FLAG_NAMES = {
|
|
35
|
+
'--title-at-source': 'titleAtSource',
|
|
36
|
+
'--site': 'site',
|
|
37
|
+
'--author': 'author',
|
|
38
|
+
'--published-at': 'publishedAt',
|
|
39
|
+
'--title': 'title'
|
|
40
|
+
};
|
|
41
|
+
const CREATED = 201;
|
|
42
|
+
const formatSourceReceipt = (s, created) => {
|
|
43
|
+
const lines = [
|
|
44
|
+
created ? `Saved source ${s.id}` : `Already kept source ${s.id}; nothing changed.`
|
|
45
|
+
];
|
|
46
|
+
if (s.title) {
|
|
47
|
+
lines.push(` title ${sanitizeForTerminal(s.title)}`);
|
|
48
|
+
}
|
|
49
|
+
for (const fact of sourceFacts(s)) {
|
|
50
|
+
lines.push(` ${fact}`);
|
|
51
|
+
}
|
|
52
|
+
lines.push(` capturedAt ${s.capturedAt}`);
|
|
53
|
+
return lines.join('\n');
|
|
54
|
+
};
|
|
55
|
+
export const captureSource = async (cfg, io, args) => {
|
|
56
|
+
if (args.length === 0) {
|
|
57
|
+
io.stdout.write(`${CAPTURE_SOURCE_HELP}\n`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const { flags, positionals, unknown } = parseArgs(SOURCE_FLAG_NAMES, args);
|
|
61
|
+
if (unknown !== undefined) {
|
|
62
|
+
return refusal(`Unknown flag: ${unknown}\n`);
|
|
63
|
+
}
|
|
64
|
+
if (positionals.length !== 1) {
|
|
65
|
+
return refusal(`${CAPTURE_SOURCE_USAGE}\n`);
|
|
66
|
+
}
|
|
67
|
+
const identity = requireWriteIdentity(io.store, io.stdin.isTTY, SOURCE_SESSION_ID_DOOR);
|
|
68
|
+
if (isRefusal(identity)) {
|
|
69
|
+
return identity;
|
|
70
|
+
}
|
|
71
|
+
const accessToken = await signedIn(io, cfg);
|
|
72
|
+
if (typeof accessToken !== 'string') {
|
|
73
|
+
return accessToken;
|
|
74
|
+
}
|
|
75
|
+
const saved = await io.api(accessToken, `${cfg.apiUrl}/memories/sources`, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, noteWriteHeaders(identity)),
|
|
78
|
+
body: JSON.stringify(Object.assign({ url: positionals[0] }, flags))
|
|
79
|
+
});
|
|
80
|
+
if (!saved.ok) {
|
|
81
|
+
return refusalOf(saved);
|
|
82
|
+
}
|
|
83
|
+
emit(io, saved.data, saved.rawText, (s) => formatSourceReceipt(s, saved.status === CREATED));
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=source.js.map
|
|
@@ -52,7 +52,7 @@ export const UPDATE_HELP = [
|
|
|
52
52
|
' names every word found. Rephrase first; override only when',
|
|
53
53
|
' the wording is meant.',
|
|
54
54
|
'',
|
|
55
|
-
' Content arrives on stdin, like capture — no quoting, up to
|
|
55
|
+
' Content arrives on stdin, like capture — no quoting, up to 128KB. Pipe',
|
|
56
56
|
' nothing and the words are left exactly as they were.',
|
|
57
57
|
'',
|
|
58
58
|
' The write carries the fingerprint you read. If another session changed',
|
package/dist/memory/views.js
CHANGED
|
@@ -4,9 +4,35 @@ import { stripTrailingSlash } from "../store/environment.js";
|
|
|
4
4
|
export const formatDeletedLine = (b) => `${b.id} ${b.deletedAt ?? '-'} rev ${b.revisionNo ?? '-'} ${b.fingerprint ?? '-'} ${sanitizeForTerminal(b.title ?? '(untitled)')}`;
|
|
5
5
|
export const formatDeletedPage = (page) => page.items.map((i) => formatDeletedLine(i)).join('\n');
|
|
6
6
|
const graphWord = (b) => b.consented === undefined ? '' : `${b.consented ? 'on graph' : 'off graph'} `;
|
|
7
|
+
const rowLabel = (b) => {
|
|
8
|
+
if (b.source === undefined) {
|
|
9
|
+
return sanitizeForTerminal(b.title ?? '(untitled)');
|
|
10
|
+
}
|
|
11
|
+
const named = b.title === null ? b.source.titleAtSource : b.title;
|
|
12
|
+
return `${sanitizeForTerminal(named ?? '(untitled)')} ${sanitizeForTerminal(b.source.url, Infinity)}`;
|
|
13
|
+
};
|
|
7
14
|
export const formatBlockLine = (b) => b.ownerHandle === undefined
|
|
8
|
-
? `${b.id} ${b.handle} ${b.capturedAt} ${b.intent ?? '-'} ${b.visibility.public ? 'public' : '-'} ${
|
|
9
|
-
: `${b.id} ${b.handle} ${b.capturedAt} by ${sanitizeForTerminal(b.ownerDisplayName ?? b.ownerHandle)} (@${b.ownerHandle}) ${graphWord(b)}${
|
|
15
|
+
? `${b.id} ${b.handle} ${b.capturedAt} ${b.intent ?? '-'} ${b.visibility.public ? 'public' : '-'} ${rowLabel(b)}`
|
|
16
|
+
: `${b.id} ${b.handle} ${b.capturedAt} by ${sanitizeForTerminal(b.ownerDisplayName ?? b.ownerHandle)} (@${b.ownerHandle}) ${graphWord(b)}${rowLabel(b)}`;
|
|
17
|
+
export const sourceFacts = (s) => {
|
|
18
|
+
if (s.url === undefined) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
const lines = [`url ${sanitizeForTerminal(s.url, Infinity)}`];
|
|
22
|
+
if (s.titleAtSource) {
|
|
23
|
+
lines.push(`page title ${sanitizeForTerminal(s.titleAtSource)}`);
|
|
24
|
+
}
|
|
25
|
+
if (s.site) {
|
|
26
|
+
lines.push(`site ${sanitizeForTerminal(s.site)}`);
|
|
27
|
+
}
|
|
28
|
+
if (s.author) {
|
|
29
|
+
lines.push(`author ${sanitizeForTerminal(s.author)}`);
|
|
30
|
+
}
|
|
31
|
+
if (s.publishedAt) {
|
|
32
|
+
lines.push(`published ${s.publishedAt}`);
|
|
33
|
+
}
|
|
34
|
+
return lines;
|
|
35
|
+
};
|
|
10
36
|
const SLUG_MAX = 60;
|
|
11
37
|
const slugify = (title) => (title ?? '')
|
|
12
38
|
.toLowerCase()
|
|
@@ -42,6 +68,39 @@ export const parseWebsiteMemoryAddress = (webUrl, value) => {
|
|
|
42
68
|
return undefined;
|
|
43
69
|
}
|
|
44
70
|
};
|
|
71
|
+
const WALK_LEVERS = ['links', 'depth', 'content'];
|
|
72
|
+
export const leversInAddress = (value) => {
|
|
73
|
+
const levers = {};
|
|
74
|
+
if (!URL.canParse(value)) {
|
|
75
|
+
return levers;
|
|
76
|
+
}
|
|
77
|
+
const { searchParams } = new URL(value);
|
|
78
|
+
for (const lever of WALK_LEVERS) {
|
|
79
|
+
const values = searchParams.getAll(lever);
|
|
80
|
+
if (values.length === 1) {
|
|
81
|
+
levers[lever] = values[0];
|
|
82
|
+
}
|
|
83
|
+
if (values.length > 1) {
|
|
84
|
+
levers[lever] = values;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return levers;
|
|
88
|
+
};
|
|
89
|
+
export const leversFor = (flags, address) => {
|
|
90
|
+
const levers = {};
|
|
91
|
+
const bareTyped = flags.links === '0';
|
|
92
|
+
for (const lever of WALK_LEVERS) {
|
|
93
|
+
const typed = flags[lever];
|
|
94
|
+
const carried = address[lever];
|
|
95
|
+
if (typed !== undefined) {
|
|
96
|
+
levers[lever] = typed;
|
|
97
|
+
}
|
|
98
|
+
else if (carried !== undefined && !bareTyped) {
|
|
99
|
+
levers[lever] = carried;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return levers;
|
|
103
|
+
};
|
|
45
104
|
export const ownHandleFor = async (cfg, io, accessToken) => {
|
|
46
105
|
try {
|
|
47
106
|
const me = await io.api(accessToken, `${cfg.apiUrl}/person/me`);
|
|
@@ -74,6 +133,9 @@ export const formatMemoryDetail = (m, address) => {
|
|
|
74
133
|
lines.push(`title ${sanitizeForTerminal(m.title)}`);
|
|
75
134
|
if (m.source)
|
|
76
135
|
lines.push(`source ${sanitizeForTerminal(m.source)}`);
|
|
136
|
+
for (const fact of sourceFacts(m)) {
|
|
137
|
+
lines.push(fact);
|
|
138
|
+
}
|
|
77
139
|
lines.push(`audiences ${formatAudiences(m.audiences)}`);
|
|
78
140
|
if (Array.isArray(m.access))
|
|
79
141
|
lines.push(`access ${formatAccess(m.access)}`);
|
|
@@ -90,7 +152,7 @@ export const formatMemoryDetail = (m, address) => {
|
|
|
90
152
|
if (Array.isArray(m.turns)) {
|
|
91
153
|
lines.push('', m.turns.map((t) => formatSessionTurn(t)).join('\n\n'));
|
|
92
154
|
}
|
|
93
|
-
else {
|
|
155
|
+
else if (m.url === undefined) {
|
|
94
156
|
lines.push('', sanitizeForTerminal(m.content ?? '', Infinity));
|
|
95
157
|
}
|
|
96
158
|
return lines.join('\n');
|
|
@@ -116,12 +178,21 @@ export const formatFindingAid = (a) => {
|
|
|
116
178
|
lines.push(`structure ${a.structureHash}`);
|
|
117
179
|
return lines.join('\n');
|
|
118
180
|
};
|
|
181
|
+
const treeOf = (owner) => owner.displayName === null
|
|
182
|
+
? "on another person's tree"
|
|
183
|
+
: `on ${sanitizeForTerminal(owner.displayName)}'s tree`;
|
|
119
184
|
export const formatWalkLink = (l) => {
|
|
120
185
|
const arrow = l.direction === 'out' ? '\u2192' : '\u2190';
|
|
121
186
|
const title = l.node.title ? ` ${sanitizeForTerminal(l.node.title)}` : '';
|
|
122
187
|
const reason = l.reason ? ` \u2014 ${sanitizeForTerminal(l.reason, Infinity)}` : '';
|
|
123
188
|
const dir = l.direction === 'out' ? 'out' : 'in ';
|
|
124
|
-
|
|
189
|
+
const foreign = l.node.foreign;
|
|
190
|
+
if (foreign === undefined) {
|
|
191
|
+
return `${dir} ${sanitizeForTerminal(l.verb)} ${arrow} ${l.node.handle} (${l.node.type})${title}${reason}`;
|
|
192
|
+
}
|
|
193
|
+
const name = l.node.title ? sanitizeForTerminal(l.node.title) : l.node.handle;
|
|
194
|
+
const why = l.reason ? ` \u2014 ${sanitizeForTerminal(l.reason, Infinity)}` : '';
|
|
195
|
+
return `${dir} ${sanitizeForTerminal(l.verb)} ${arrow} ${name} \u00b7 ${treeOf(foreign.owner)}${why}`;
|
|
125
196
|
};
|
|
126
197
|
export const formatNodeWalk = (w, address) => {
|
|
127
198
|
const parts = [
|
package/dist/nouns/edges.js
CHANGED
|
@@ -20,7 +20,9 @@ const LINK_HELP = [
|
|
|
20
20
|
' <from> the cause-side block — full id or a >=4-char prefix; an',
|
|
21
21
|
' ambiguous prefix refuses and lists the matches',
|
|
22
22
|
' <to> the effect-side block — the FULL id (the wire addresses the',
|
|
23
|
-
' edge by it; it does not search)',
|
|
23
|
+
' edge by it; it does not search): one of your own, or a',
|
|
24
|
+
' block on another person’s tree that is public now — only',
|
|
25
|
+
' references crosses',
|
|
24
26
|
' --verb required; the server’s registry is the ONE authority on the',
|
|
25
27
|
' vocabulary — an unknown verb refuses WITH the accepted set',
|
|
26
28
|
' for the exact pair sent, and the CLI carries no copy',
|
package/dist/nouns/index.js
CHANGED
|
@@ -7,9 +7,20 @@ import { LINK_HELP, edges } from "./edges.js";
|
|
|
7
7
|
import { INVITE_HELP, invites } from "./invite.js";
|
|
8
8
|
import { ACCEPT_HELP, ACCEPT_USAGE, ASK_HELP, CLOSE_HELP, CLOSE_USAGE, DECLINE_HELP, DECLINE_USAGE, questions } from "./questions.js";
|
|
9
9
|
import { DENY_HELP, REMOVE_DENY_HELP, SHARE_HELP, UNSHARE_HELP, grants } from "./share.js";
|
|
10
|
-
|
|
10
|
+
import { SUBSCRIBE_HELP, subscribers, subscriptions } from "./subscribers.js";
|
|
11
|
+
export const listNouns = [
|
|
12
|
+
contacts,
|
|
13
|
+
questions,
|
|
14
|
+
edges,
|
|
15
|
+
invites,
|
|
16
|
+
grants,
|
|
17
|
+
datasets,
|
|
18
|
+
subscribers,
|
|
19
|
+
subscriptions
|
|
20
|
+
];
|
|
11
21
|
export const listVerbs = {
|
|
12
22
|
ask: { help: ASK_HELP, helpBeforeAuth: true },
|
|
23
|
+
subscribe: { help: SUBSCRIBE_HELP, helpBeforeAuth: true },
|
|
13
24
|
close: {
|
|
14
25
|
help: CLOSE_HELP,
|
|
15
26
|
helpBeforeAuth: true,
|
package/dist/nouns/invite.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { formatContact } from "../render/rows.js";
|
|
2
2
|
import { sanitizeForTerminal } from "../render/text.js";
|
|
3
|
-
const inviteLink = (webUrl, token) => `${webUrl}/i/${token}`;
|
|
3
|
+
export const inviteLink = (webUrl, token) => `${webUrl}/i/${token}`;
|
|
4
|
+
const NOT_EMAILED = 'Not emailed: an internal Lattris address. Hand them this link.';
|
|
5
|
+
export const mintedLines = (webUrl, minted, address) => `${minted.emailed ? `Sending the invite to ${address}.` : NOT_EMAILED}\n\n` +
|
|
6
|
+
` ${inviteLink(webUrl, minted.token)}\n\n` +
|
|
7
|
+
`You can see it again with: lattris get invites`;
|
|
4
8
|
const formatInvite = (webUrl, i) => {
|
|
5
9
|
const label = i.targetName ? ` — ${sanitizeForTerminal(i.targetName)}` : '';
|
|
6
10
|
const admits = i.email ? `\n admits ${sanitizeForTerminal(i.email)}` : '';
|
|
@@ -12,18 +16,18 @@ const formatInvite = (webUrl, i) => {
|
|
|
12
16
|
}
|
|
13
17
|
if (i.revokedAt)
|
|
14
18
|
return `revoked${label}${admits}\n minted ${i.createdAt}`;
|
|
19
|
+
if (i.email === null || i.token === null) {
|
|
20
|
+
return `out of date${label}\n minted ${i.createdAt}`;
|
|
21
|
+
}
|
|
15
22
|
return `live${label}${admits}\n ${inviteLink(webUrl, i.token)}\n minted ${i.createdAt}`;
|
|
16
23
|
};
|
|
17
24
|
const INVITE_HELP = [
|
|
18
25
|
'invite — bring one person in.',
|
|
19
26
|
'',
|
|
20
|
-
'Mints a single-use invitation
|
|
21
|
-
'
|
|
22
|
-
'',
|
|
23
|
-
'
|
|
24
|
-
'address may register at all is a separate decision, made by hand — so a',
|
|
25
|
-
'person can hold a good invitation and still be turned away. Tell them that',
|
|
26
|
-
'when you send it.',
|
|
27
|
+
'Mints a single-use invitation, emails the link to the address it admits,',
|
|
28
|
+
'and prints it. Only an account signed in with that address can take it, and',
|
|
29
|
+
'it is spent when it is taken. An invitation from the Lattris account to a',
|
|
30
|
+
'lattris.com address is not emailed: hand the person the link.',
|
|
27
31
|
'',
|
|
28
32
|
'Usage:',
|
|
29
33
|
' lattris invite <contact-name-or-id> [--email <address>] [--yes]',
|
|
@@ -93,12 +97,7 @@ const inviteVerb = {
|
|
|
93
97
|
: context.recordedEmail
|
|
94
98
|
? `Recorded ${admitted} on ${sanitizeForTerminal(contact.displayName)}.\n\n`
|
|
95
99
|
: '';
|
|
96
|
-
return
|
|
97
|
-
`Invitation minted${i.targetName ? ` for ${sanitizeForTerminal(i.targetName)}` : ''}, admitting ${admitted}.\n\n` +
|
|
98
|
-
` ${inviteLink(context.webUrl, i.token)}\n\n` +
|
|
99
|
-
`Hand it to ONE person — it is spent when someone signs up with it.\n` +
|
|
100
|
-
`It is not permission to join; whether they may register is decided separately.\n` +
|
|
101
|
-
`You can see it again with: lattris get invites`);
|
|
100
|
+
return first + mintedLines(context.webUrl, i, admitted);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
};
|
package/dist/nouns/share.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { audienceOf, formatAccessRow, formatAudiences, waitsForNameSentence } from "../render/rows.js";
|
|
2
2
|
import { renderRunHint, sanitizeForTerminal } from "../render/text.js";
|
|
3
|
+
import { formatSharesPage, goneSentence } from "../render/shares.js";
|
|
3
4
|
import { consent } from "./consent.js";
|
|
4
5
|
const ALL_CONTACTS = 'all-contacts';
|
|
5
6
|
const AUDIENCE_WORDS = '--with is required. Use public, all-contacts, or one of your contact names or ids.\n';
|
|
@@ -23,7 +24,8 @@ export const SHARE_HELP = [
|
|
|
23
24
|
'',
|
|
24
25
|
'A deny on the memory beats any allow: the answer names who is still shut',
|
|
25
26
|
'out, and `lattris remove deny` lifts it. Sharing with an audience that',
|
|
26
|
-
'already has access succeeds and changes nothing.',
|
|
27
|
+
'already has access succeeds and changes nothing. `lattris get shares`',
|
|
28
|
+
'lists every share and deny you have set.',
|
|
27
29
|
'',
|
|
28
30
|
'Alias: publish → share'
|
|
29
31
|
].join('\n');
|
|
@@ -41,7 +43,8 @@ export const DENY_HELP = [
|
|
|
41
43
|
'',
|
|
42
44
|
'A deny cannot hold while the memory is public or shared on the website',
|
|
43
45
|
'with the person it would shut out; the refusal names the share in the',
|
|
44
|
-
'way. `lattris remove deny` lifts a deny
|
|
46
|
+
'way. `lattris remove deny` lifts a deny, and `lattris get shares` lists',
|
|
47
|
+
'the ones you have set.'
|
|
45
48
|
].join('\n');
|
|
46
49
|
export const REMOVE_DENY_HELP = [
|
|
47
50
|
'remove deny — lift a deny from a memory, for one contact or for all your',
|
|
@@ -52,6 +55,10 @@ export const REMOVE_DENY_HELP = [
|
|
|
52
55
|
'Usage:',
|
|
53
56
|
' lattris remove deny [memory] <id-or-prefix> --to <all-contacts | contact> [--yes]',
|
|
54
57
|
'',
|
|
58
|
+
'It works on a memory that is no longer shared with you too, for your own',
|
|
59
|
+
'denies, so a deny never holds a contact for good. `lattris get shares`',
|
|
60
|
+
'lists the denies you have set.',
|
|
61
|
+
'',
|
|
55
62
|
'Alias: undeny memory <id> → remove deny <id>'
|
|
56
63
|
].join('\n');
|
|
57
64
|
const isAccessGrant = (grant) => typeof grant === 'object' &&
|
|
@@ -184,6 +191,7 @@ const liftingForm = {
|
|
|
184
191
|
refusedWords: { public: PUBLIC_CANNOT_BE_DENIED }
|
|
185
192
|
},
|
|
186
193
|
memory: 'at-tty',
|
|
194
|
+
memoryMayBeGone: true,
|
|
187
195
|
confirm: {
|
|
188
196
|
question: 'Lift the deny on "{title}" ({memory.id}) for {audience}? [y/N] ',
|
|
189
197
|
onNo: { text: 'Cancelled.\n', to: 'stderr' },
|
|
@@ -198,7 +206,12 @@ const liftingForm = {
|
|
|
198
206
|
ambiguousRefusal: true,
|
|
199
207
|
refusalWords: otherEffectWords('deny'),
|
|
200
208
|
renderTo: 'stderr',
|
|
201
|
-
render: (_data, context) =>
|
|
209
|
+
render: (_data, context) => {
|
|
210
|
+
const who = context.contact ? sanitizeForTerminal(context.contact.displayName) : 'all contacts';
|
|
211
|
+
return context.gone
|
|
212
|
+
? goneSentence(`Your deny for ${who} was lifted.`)
|
|
213
|
+
: `Lifted the deny on memory ${context.memory?.id ?? context.positionals[0]} for ${who}`;
|
|
214
|
+
}
|
|
202
215
|
};
|
|
203
216
|
const removeDenyVerb = {
|
|
204
217
|
verb: 'remove',
|
|
@@ -222,7 +235,9 @@ export const UNSHARE_HELP = [
|
|
|
222
235
|
'',
|
|
223
236
|
'Bare (no --with): refuses and shows what the memory is currently shared',
|
|
224
237
|
'with, so you can see the state and the fix in one line. A deny is lifted',
|
|
225
|
-
'with `lattris remove deny`, not here.',
|
|
238
|
+
'with `lattris remove deny`, not here. On a memory that is no longer',
|
|
239
|
+
'shared with you, it removes your own contact shares still; `lattris get',
|
|
240
|
+
'shares` lists them.',
|
|
226
241
|
'',
|
|
227
242
|
'Alias: unpublish → unshare'
|
|
228
243
|
].join('\n');
|
|
@@ -237,6 +252,7 @@ const unshareVerb = {
|
|
|
237
252
|
steps: {
|
|
238
253
|
contact: { from: ['flag:with'], publicWord: 'public', reserved: [ALL_CONTACTS] },
|
|
239
254
|
memory: 'always',
|
|
255
|
+
memoryMayBeGone: true,
|
|
240
256
|
noAudienceReport: {
|
|
241
257
|
key: 'with',
|
|
242
258
|
first: AUDIENCE_WORDS,
|
|
@@ -257,11 +273,58 @@ const unshareVerb = {
|
|
|
257
273
|
ambiguousRefusal: true,
|
|
258
274
|
refusalWords: otherEffectWords('allow'),
|
|
259
275
|
renderTo: 'stderr',
|
|
260
|
-
render: (_data, context) =>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
276
|
+
render: (_data, context) => {
|
|
277
|
+
const who = context.contact
|
|
278
|
+
? sanitizeForTerminal(context.contact.displayName)
|
|
279
|
+
: context.reserved === ALL_CONTACTS
|
|
280
|
+
? 'all contacts'
|
|
281
|
+
: 'public';
|
|
282
|
+
return context.gone
|
|
283
|
+
? goneSentence(`Your share with ${who} was removed.`)
|
|
284
|
+
: `Unshared memory ${context.memory?.id ?? ''} from ${who}`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
export const GET_SHARES_HELP = [
|
|
289
|
+
'get shares — every share and deny you have set, on your memories, on the',
|
|
290
|
+
'ones shared with you, and on ones shared with you once and no longer.',
|
|
291
|
+
'',
|
|
292
|
+
'Usage:',
|
|
293
|
+
' lattris get shares [--for <contact>] [--limit <n>] [--cursor <token>]',
|
|
294
|
+
'',
|
|
295
|
+
' --for one of your contacts, by exact name or id from',
|
|
296
|
+
' `lattris contact list`: the shares and denies that name them,',
|
|
297
|
+
' and the ones you set for all contacts. This is what you said',
|
|
298
|
+
' about them; `lattris get memories --for` is what they may see.',
|
|
299
|
+
' --limit rows per page; --cursor continues where a page stopped.',
|
|
300
|
+
'',
|
|
301
|
+
'A memory no longer shared with you shows its id alone: your shares and',
|
|
302
|
+
'denies on it stay, decide nothing until it is shared again, and',
|
|
303
|
+
'`lattris unshare` and `lattris remove deny` still take them away.'
|
|
304
|
+
].join('\n');
|
|
305
|
+
const getSharesVerb = {
|
|
306
|
+
verb: 'get',
|
|
307
|
+
nouns: ['shares'],
|
|
308
|
+
form: {
|
|
309
|
+
usage: 'Usage: lattris get shares [--for <contact>] [--limit <n>] [--cursor <token>]',
|
|
310
|
+
flags: { '--for': 'for', '--limit': 'limit', '--cursor': 'cursor' },
|
|
311
|
+
positionals: 0,
|
|
312
|
+
steps: { contact: { from: ['flag:for'] } },
|
|
313
|
+
request: {
|
|
314
|
+
method: 'GET',
|
|
315
|
+
path: '/memories/shares',
|
|
316
|
+
query: {
|
|
317
|
+
forContact: { context: 'contact.id' },
|
|
318
|
+
limit: { flag: 'limit' },
|
|
319
|
+
cursor: { flag: 'cursor' }
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
page: {
|
|
323
|
+
cursor: 'nextCursor',
|
|
324
|
+
hint: ['get', 'shares'],
|
|
325
|
+
carry: { '--for': 'for', '--limit': 'limit' }
|
|
326
|
+
},
|
|
327
|
+
render: (page, context) => formatSharesPage(page, context.contact?.displayName ?? context.flags.for)
|
|
265
328
|
}
|
|
266
329
|
};
|
|
267
330
|
export const audiencesOf = (memory) => formatAudiences(memory.audiences);
|
|
@@ -269,6 +332,6 @@ export const grants = {
|
|
|
269
332
|
name: 'grants',
|
|
270
333
|
words: { singular: 'grant', plural: 'grants' },
|
|
271
334
|
help: SHARE_HELP,
|
|
272
|
-
verbs: [shareVerb, unshareVerb, denyVerb, removeDenyVerb, undenyVerb, consent]
|
|
335
|
+
verbs: [shareVerb, unshareVerb, denyVerb, removeDenyVerb, undenyVerb, getSharesVerb, consent]
|
|
273
336
|
};
|
|
274
337
|
//# sourceMappingURL=share.js.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { sanitizeForTerminal } from "../render/text.js";
|
|
2
|
+
import { mintedLines } from "./invite.js";
|
|
3
|
+
import { verbsOf } from "./form.js";
|
|
4
|
+
const relationWords = (relation) => relation.replace(/-/g, ' ');
|
|
5
|
+
export const formatSubscriber = (s, asking = false) => `${sanitizeForTerminal(s.email)} · ${sanitizeForTerminal(s.status)} · ${s.id}` +
|
|
6
|
+
`${s.name ? ` · ${sanitizeForTerminal(s.name)}` : ''}` +
|
|
7
|
+
`${s.relation ? ` · ${sanitizeForTerminal(relationWords(s.relation))}` : ''}` +
|
|
8
|
+
`${s.wantsAccess && !asking ? ' · wants to try Lattris' : ''}` +
|
|
9
|
+
`${s.reason ? ` · “${sanitizeForTerminal(s.reason)}”` : ''}`;
|
|
10
|
+
export const SUBSCRIBE_HELP = [
|
|
11
|
+
'subscribe — leave your email on someone’s public page, to stay in touch.',
|
|
12
|
+
'',
|
|
13
|
+
'Needs no account and no session: a reader’s own AI can do it for them. The',
|
|
14
|
+
'page owner reads the list; nothing is sent to the address but a confirmation,',
|
|
15
|
+
'and the subscription stands only once that confirmation is clicked.',
|
|
16
|
+
'',
|
|
17
|
+
'Usage:',
|
|
18
|
+
' lattris subscribe <handle> <email> [--try]',
|
|
19
|
+
'',
|
|
20
|
+
' <handle> the page’s address, as it appears at /by/<handle>',
|
|
21
|
+
' <email> the address the confirmation goes to',
|
|
22
|
+
' --try say you would like to try Lattris',
|
|
23
|
+
'',
|
|
24
|
+
'The answer is the same whatever is already true about the address: "Check',
|
|
25
|
+
'your inbox to confirm." An address already confirmed is sent nothing; one',
|
|
26
|
+
'that asked recently waits a minute between confirmations, three a day.',
|
|
27
|
+
'The confirm page the email links to asks the optional questions. A page',
|
|
28
|
+
'with nothing public, or a handle that names nobody, is answered not found,',
|
|
29
|
+
'and the two are not told apart.'
|
|
30
|
+
].join('\n');
|
|
31
|
+
const SUBSCRIBERS_HELP = [
|
|
32
|
+
'subscribers — the readers who left their email on your public page.',
|
|
33
|
+
'',
|
|
34
|
+
'Usage:',
|
|
35
|
+
' lattris subscribers list [--status pending|confirmed|unsubscribed] [--wants-access]',
|
|
36
|
+
' every subscriber of yours, newest first;',
|
|
37
|
+
' --wants-access: only the ones who asked to',
|
|
38
|
+
' try Lattris',
|
|
39
|
+
' lattris subscribers get <id> one subscriber, by its full id or a unique prefix',
|
|
40
|
+
' lattris subscribers delete <id> [--yes] forget one: their address and answers are',
|
|
41
|
+
' deleted; asks at a terminal, needs --yes on a pipe',
|
|
42
|
+
' lattris subscribers admit <id> [--yes] invite one who asked to try Lattris; asks at a',
|
|
43
|
+
' terminal, needs --yes on a pipe',
|
|
44
|
+
'',
|
|
45
|
+
'A subscriber is not an account and not a contact: an address, whether it was',
|
|
46
|
+
'confirmed, and what the reader chose to say (a name, how they know you, what',
|
|
47
|
+
'brought them, whether they would like to try Lattris). pending has not clicked',
|
|
48
|
+
'the confirmation yet and is forgotten with its link after seven days;',
|
|
49
|
+
'unsubscribed stays, with the answers cleared, so a return needs a fresh',
|
|
50
|
+
'confirmation.'
|
|
51
|
+
].join('\n');
|
|
52
|
+
const subscribeVerb = {
|
|
53
|
+
verb: 'subscribe',
|
|
54
|
+
form: {
|
|
55
|
+
usage: 'Usage: lattris subscribe <handle> <email> [--try]',
|
|
56
|
+
switches: ['--try'],
|
|
57
|
+
positionals: 2,
|
|
58
|
+
credential: 'none',
|
|
59
|
+
request: {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
path: '/by/{p0}/subscribers',
|
|
62
|
+
body: {
|
|
63
|
+
email: { positional: 1, trim: true },
|
|
64
|
+
wantsAccess: { switch: '--try', value: true }
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
render: (data) => sanitizeForTerminal(data.message)
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export const subscriptions = {
|
|
71
|
+
name: 'subscriptions',
|
|
72
|
+
words: { singular: 'subscription', plural: 'subscriptions' },
|
|
73
|
+
help: SUBSCRIBE_HELP,
|
|
74
|
+
verbs: [subscribeVerb]
|
|
75
|
+
};
|
|
76
|
+
export const subscribers = {
|
|
77
|
+
name: 'subscribers',
|
|
78
|
+
words: { singular: 'subscribers', plural: 'subscribers' },
|
|
79
|
+
grammar: 'noun-first',
|
|
80
|
+
help: SUBSCRIBERS_HELP,
|
|
81
|
+
helpBeforeAuth: true,
|
|
82
|
+
unknownVerb: 'Unknown subscribers verb: {verb}\n\n' + SUBSCRIBERS_HELP + '\n',
|
|
83
|
+
verbs: verbsOf({
|
|
84
|
+
list: {
|
|
85
|
+
usage: 'Usage: lattris subscribers list [--status pending|confirmed|unsubscribed] [--wants-access]',
|
|
86
|
+
flags: { '--status': 'status' },
|
|
87
|
+
switches: ['--wants-access'],
|
|
88
|
+
positionals: 0,
|
|
89
|
+
unknownFlagIsUsage: true,
|
|
90
|
+
request: {
|
|
91
|
+
method: 'GET',
|
|
92
|
+
path: '/subscribers',
|
|
93
|
+
query: {
|
|
94
|
+
status: { flag: 'status' },
|
|
95
|
+
wantsAccess: { switch: '--wants-access', value: 'true' }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
render: (list, context) => {
|
|
99
|
+
const rows = list;
|
|
100
|
+
const asking = context.on.has('--wants-access');
|
|
101
|
+
if (rows.length === 0) {
|
|
102
|
+
return asking
|
|
103
|
+
? 'Nobody has asked to try Lattris yet.'
|
|
104
|
+
: 'No subscribers yet. Nobody has left their email on your page.';
|
|
105
|
+
}
|
|
106
|
+
return rows.map((s) => formatSubscriber(s, asking)).join('\n');
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
get: {
|
|
110
|
+
usage: 'Usage: lattris subscribers get <id>',
|
|
111
|
+
positionals: 1,
|
|
112
|
+
idPositionals: [0],
|
|
113
|
+
unknownFlagIsUsage: true,
|
|
114
|
+
request: { method: 'GET', path: '/subscribers/{p0}' },
|
|
115
|
+
render: (s) => formatSubscriber(s)
|
|
116
|
+
},
|
|
117
|
+
delete: {
|
|
118
|
+
usage: 'Usage: lattris subscribers delete <id> [--yes]',
|
|
119
|
+
switches: ['--yes'],
|
|
120
|
+
positionals: 1,
|
|
121
|
+
idPositionals: [0],
|
|
122
|
+
steps: {
|
|
123
|
+
pipedNeedsYes: {
|
|
124
|
+
message: 'Refusing to forget a subscriber without confirmation on a non-interactive session. Pass --yes to skip the prompt.\n'
|
|
125
|
+
},
|
|
126
|
+
confirm: {
|
|
127
|
+
question: 'Forget subscriber {p0}? Their address and answers are deleted. [y/N] ',
|
|
128
|
+
onNo: { text: 'Cancelled.\n', to: 'stderr' },
|
|
129
|
+
onInterrupted: { text: 'Cancelled.\n', exit: 1 }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
request: { method: 'DELETE', path: '/subscribers/{p0}' },
|
|
133
|
+
renderTo: 'stderr',
|
|
134
|
+
render: (_answer, context) => `Forgot subscriber ${sanitizeForTerminal(context.positionals[0])}`
|
|
135
|
+
},
|
|
136
|
+
admit: {
|
|
137
|
+
usage: 'Usage: lattris subscribers admit <id> [--yes]',
|
|
138
|
+
switches: ['--yes'],
|
|
139
|
+
positionals: 1,
|
|
140
|
+
idPositionals: [0],
|
|
141
|
+
steps: {
|
|
142
|
+
pipedNeedsYes: {
|
|
143
|
+
message: 'Refusing to admit a subscriber without confirmation on a non-interactive session. Pass --yes to skip the prompt.\n'
|
|
144
|
+
},
|
|
145
|
+
subscriber: true,
|
|
146
|
+
confirm: {
|
|
147
|
+
question: 'Invite {subscriber.email} to Lattris? [y/N] ',
|
|
148
|
+
onNo: { text: 'Not invited.\n', to: 'stdout' }
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
request: { method: 'POST', path: '/subscribers/{p0}/admit' },
|
|
152
|
+
refusalInstead: {
|
|
153
|
+
'subscriber:already-invited': '{subscriber.email} already has an invite. Revoke it in Settings to send a new one.\n',
|
|
154
|
+
'subscriber:already-joined': '{subscriber.email} has already joined.\n'
|
|
155
|
+
},
|
|
156
|
+
render: (data, context) => {
|
|
157
|
+
const i = data;
|
|
158
|
+
return mintedLines(context.webUrl, i, sanitizeForTerminal(i.email));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
})
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=subscribers.js.map
|
package/dist/nouns/words.js
CHANGED
|
@@ -23,10 +23,13 @@ export const USAGE_LINES = [
|
|
|
23
23
|
' lattris capture memory Capture a memory — `echo "…" | lattris capture memory`',
|
|
24
24
|
' lattris capture session <transcript> Save an AI conversation — the whole chain from its file',
|
|
25
25
|
' lattris capture recording Keep a recording \u2014 held audio, a source, or a transcript file',
|
|
26
|
+
' lattris capture source <url> Keep a link \u2014 a page, a post, a video \u2014 with its title, site, author and date',
|
|
26
27
|
' lattris get memories List your memories, newest first, with filters (--for <contact> for what they may see)',
|
|
27
28
|
' lattris contact create "<name>" Record a person or an AI you work with (--ai, --phone); add, list, get, update, delete, link',
|
|
28
29
|
' lattris invite <contact> [--email <address>] Mint an invitation for one of your person contacts, admitting one address',
|
|
29
30
|
' lattris get invites List the invitations you have minted',
|
|
31
|
+
' lattris subscribe <handle> <email> Leave your email on someone’s public page, no account needed (--try)',
|
|
32
|
+
' lattris subscribers list The readers who left their email on your page (--status, --wants-access); get, delete, admit',
|
|
30
33
|
' lattris get memory <id> Read one memory back \u2014 words and edges (--links/--depth/--content)',
|
|
31
34
|
' lattris ask <handle> Leave a question on someone\u2019s tree \u2014 `echo "\u2026" | lattris ask <handle>`',
|
|
32
35
|
' lattris get questions The questions on your tree, open first (--mine: ones you asked)',
|
|
@@ -38,6 +41,7 @@ export const USAGE_LINES = [
|
|
|
38
41
|
' lattris deny memory <id> Shut it to a contact or all contacts, whatever allows it (--to)',
|
|
39
42
|
' lattris remove deny <id> Lift a deny (--to all-contacts | <contact>)',
|
|
40
43
|
' lattris get access <id> May a contact or a number see it, and because of what (--for)',
|
|
44
|
+
' lattris get shares Every share and deny you have set (--for <contact>: what you said about them)',
|
|
41
45
|
' lattris consent <id> Put a memory shared with you on your graph (--withdraw reverses)',
|
|
42
46
|
' lattris link <from> <to> State that one memory leads to another (--verb, --reason)',
|
|
43
47
|
' lattris unlink <from> <to> Remove that claim (--verb; the blocks stay)',
|
|
@@ -85,6 +89,8 @@ export const COMMAND_WORDS = new Set([
|
|
|
85
89
|
'erase',
|
|
86
90
|
'resend',
|
|
87
91
|
'contact',
|
|
92
|
+
'subscribe',
|
|
93
|
+
'subscribers',
|
|
88
94
|
'logout',
|
|
89
95
|
'--as'
|
|
90
96
|
]);
|
package/dist/registry/memory.js
CHANGED
|
@@ -6,12 +6,14 @@ import { DELETE_HELP, deleteMemory } from "../memory/delete.js";
|
|
|
6
6
|
import { ERASE_HELP, eraseMemory } from "../memory/erase.js";
|
|
7
7
|
import { GET_ACCESS_HELP, getAccess } from "../memory/access.js";
|
|
8
8
|
import { GET_HELP } from "../memory/get-help.js";
|
|
9
|
+
import { GET_SHARES_HELP } from "../nouns/share.js";
|
|
9
10
|
import { getMemories } from "../memory/get.js";
|
|
10
11
|
import { getDeleted, getHistory } from "../memory/history.js";
|
|
11
12
|
import { CAPTURE_RECORDING_HELP, captureRecording } from "../memory/recording.js";
|
|
12
13
|
import { updateRecording } from "../memory/recording-update.js";
|
|
13
14
|
import { RESEND_HELP, resend } from "../memory/resend.js";
|
|
14
15
|
import { RESTORE_HELP, restoreMemory } from "../memory/restore.js";
|
|
16
|
+
import { CAPTURE_SOURCE_HELP, captureSource } from "../memory/source.js";
|
|
15
17
|
import { UPDATE_HELP } from "../memory/update-help.js";
|
|
16
18
|
import { updateMemory } from "../memory/update.js";
|
|
17
19
|
export const memoryNouns = [
|
|
@@ -54,6 +56,12 @@ export const memoryNouns = [
|
|
|
54
56
|
{ verb: 'capture', nouns: ['recording'], handler: captureRecording },
|
|
55
57
|
{ verb: 'update', nouns: ['recording', 'recordings'], handler: updateRecording }
|
|
56
58
|
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'sources',
|
|
62
|
+
words: { singular: 'source', plural: 'sources' },
|
|
63
|
+
help: CAPTURE_SOURCE_HELP,
|
|
64
|
+
verbs: [{ verb: 'capture', nouns: ['source'], handler: captureSource }]
|
|
57
65
|
}
|
|
58
66
|
];
|
|
59
67
|
const captureHelp = (args) => {
|
|
@@ -65,6 +73,8 @@ const captureHelp = (args) => {
|
|
|
65
73
|
return CAPTURE_NOTE_HELP;
|
|
66
74
|
if (args[0] === 'recording')
|
|
67
75
|
return CAPTURE_RECORDING_HELP;
|
|
76
|
+
if (args[0] === 'source')
|
|
77
|
+
return CAPTURE_SOURCE_HELP;
|
|
68
78
|
return CAPTURE_INDEX;
|
|
69
79
|
};
|
|
70
80
|
export const memoryVerbs = {
|
|
@@ -79,10 +89,12 @@ export const memoryVerbs = {
|
|
|
79
89
|
? GET_DATASETS_HELP
|
|
80
90
|
: args[0] === 'access'
|
|
81
91
|
? GET_ACCESS_HELP
|
|
82
|
-
:
|
|
92
|
+
: args[0] === 'shares'
|
|
93
|
+
? GET_SHARES_HELP
|
|
94
|
+
: GET_HELP,
|
|
83
95
|
bareIsHelp: true,
|
|
84
96
|
badNoun: {
|
|
85
|
-
stderr: 'Usage: lattris get memories | lattris get memory <id> | lattris get access <id> --for <contact | number> | lattris get history <id> | lattris get deleted | lattris get invites | lattris get questions | lattris get datasets | lattris get dataset <name> | lattris get rows <name> | lattris get row <name> <id>\n'
|
|
97
|
+
stderr: 'Usage: lattris get memories | lattris get memory <id> | lattris get access <id> --for <contact | number> | lattris get shares [--for <contact>] | lattris get history <id> | lattris get deleted | lattris get invites | lattris get questions | lattris get datasets | lattris get dataset <name> | lattris get rows <name> | lattris get row <name> <id>\n'
|
|
86
98
|
}
|
|
87
99
|
},
|
|
88
100
|
update: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { formatAccessRow } from "./rows.js";
|
|
2
|
+
import { sanitizeForTerminal } from "./text.js";
|
|
3
|
+
export const NO_LONGER_SHARED = '(no longer shared with you)';
|
|
4
|
+
const titleOf = (r) => r.state === 'unshared' ? NO_LONGER_SHARED : sanitizeForTerminal(r.title ?? '(untitled)');
|
|
5
|
+
const ownerOf = (r) => r.state === 'mine'
|
|
6
|
+
? 'mine'
|
|
7
|
+
: r.state === 'deleted'
|
|
8
|
+
? 'mine, in deleted items'
|
|
9
|
+
: `by ${sanitizeForTerminal(r.ownerDisplayName ?? r.ownerHandle)} (@${sanitizeForTerminal(r.ownerHandle)})`;
|
|
10
|
+
export const formatSharesPage = (page, forName) => {
|
|
11
|
+
if (page.items.length === 0) {
|
|
12
|
+
return forName === undefined
|
|
13
|
+
? 'You have set nothing on any memory.'
|
|
14
|
+
: `Nothing you have set names ${sanitizeForTerminal(forName)}.`;
|
|
15
|
+
}
|
|
16
|
+
const lines = [];
|
|
17
|
+
let current;
|
|
18
|
+
for (const row of page.items) {
|
|
19
|
+
if (row.blockId !== current) {
|
|
20
|
+
current = row.blockId;
|
|
21
|
+
lines.push(`${row.blockId} ${titleOf(row)} ${ownerOf(row)}`);
|
|
22
|
+
}
|
|
23
|
+
lines.push(` ${formatAccessRow(row)}`);
|
|
24
|
+
}
|
|
25
|
+
return lines.join('\n');
|
|
26
|
+
};
|
|
27
|
+
export const goneSentence = (done) => `That memory is no longer shared with you. ${done}`;
|
|
28
|
+
//# sourceMappingURL=shares.js.map
|
|
@@ -133,16 +133,17 @@ export const resolveWriteIdentityDetail = (store, atTerminal) => {
|
|
|
133
133
|
const sessionId = mintTerminalIdentity(store, join(sessionDir(store), 'sessions'), key);
|
|
134
134
|
return { kind: 'ok', identity: { sessionId, agentLabel } };
|
|
135
135
|
};
|
|
136
|
-
export const requireWriteIdentity = (store, atTerminal) => {
|
|
136
|
+
export const requireWriteIdentity = (store, atTerminal, door = SESSION_ID_DOOR) => {
|
|
137
137
|
const r = resolveWriteIdentityDetail(store, atTerminal);
|
|
138
138
|
if (r.kind === 'ok')
|
|
139
139
|
return r.identity;
|
|
140
|
-
return refusal(`${r.kind === 'invalid' ? r.words :
|
|
140
|
+
return refusal(`${r.kind === 'invalid' ? r.words : door}\n`, EXIT.USAGE);
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
'Off a terminal there is no session to infer: set LATTRIS_SESSION_ID to a stable ' +
|
|
142
|
+
const NAME_THE_SESSION = 'Off a terminal there is no session to infer: set LATTRIS_SESSION_ID to a stable ' +
|
|
144
143
|
'name for this worker or run (1 to 128 characters), and LATTRIS_AGENT to a readable ' +
|
|
145
144
|
'label if you want one. Nothing was written.';
|
|
145
|
+
export const SESSION_ID_DOOR = `This write changes a note’s history and has to name the session doing it. ${NAME_THE_SESSION}`;
|
|
146
|
+
export const SOURCE_SESSION_ID_DOOR = `Saving a source has to name the session doing it. ${NAME_THE_SESSION}`;
|
|
146
147
|
export const noteWriteHeaders = (identity, idempotencyKey) => ({
|
|
147
148
|
'X-Lattris-Session-Id': identity.sessionId,
|
|
148
149
|
...(identity.agentLabel ? { 'X-Lattris-Agent': identity.agentLabel } : {}),
|