lattris 0.2.0 → 0.2.2
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 -4
- package/dist/dispatch-form.js +78 -9
- package/dist/dispatch-words.js +35 -26
- package/dist/dispatch.js +2 -2
- package/dist/entry/setup.js +14 -2
- package/dist/main.js +2 -6
- package/dist/memory/access.js +88 -0
- package/dist/memory/capture-common.js +109 -5
- package/dist/memory/capture-help.js +18 -9
- package/dist/memory/capture-note.js +26 -16
- package/dist/memory/capture-session.js +18 -16
- package/dist/memory/get-help.js +12 -1
- package/dist/memory/get.js +38 -5
- package/dist/memory/recording.js +36 -27
- package/dist/memory/transcript.js +3 -0
- package/dist/memory/views.js +12 -3
- package/dist/nouns/contact.js +119 -23
- package/dist/nouns/index.js +29 -2
- package/dist/nouns/invite.js +45 -19
- package/dist/nouns/questions.js +56 -3
- package/dist/nouns/share.js +199 -30
- package/dist/nouns/words.js +21 -6
- package/dist/registry/memory.js +8 -2
- package/dist/render/rows.js +46 -1
- package/dist/request/door.js +2 -1
- package/package.json +2 -2
package/dist/nouns/share.js
CHANGED
|
@@ -1,21 +1,111 @@
|
|
|
1
|
-
import { formatAudiences } from "../render/rows.js";
|
|
1
|
+
import { audienceOf, formatAccessRow, formatAudiences, waitsForNameSentence } from "../render/rows.js";
|
|
2
|
+
import { renderRunHint, sanitizeForTerminal } from "../render/text.js";
|
|
2
3
|
import { consent } from "./consent.js";
|
|
3
|
-
const
|
|
4
|
+
const ALL_CONTACTS = 'all-contacts';
|
|
5
|
+
const AUDIENCE_WORDS = '--with is required. Use public, all-contacts, or one of your contact names or ids.\n';
|
|
6
|
+
const DENY_WORDS = '--to is required. Use all-contacts or one of your contact names or ids.\n';
|
|
7
|
+
const PUBLIC_CANNOT_BE_DENIED = 'public cannot be denied: a deny names a contact or all-contacts. To stop sharing with everyone, unshare --with public.\n';
|
|
4
8
|
export const SHARE_HELP = [
|
|
5
|
-
'share —
|
|
9
|
+
'share — allow an audience to see a memory: public, all your contacts,',
|
|
10
|
+
'or one contact. A contact needs no Lattris account; a linked contact also',
|
|
11
|
+
'sees it on the website. A memory someone shared with you takes a contact',
|
|
12
|
+
"share too, for your own contacts; public is the owner's alone.",
|
|
6
13
|
'',
|
|
7
14
|
'Usage:',
|
|
8
|
-
' lattris share memory <id-or-prefix> --with <public-
|
|
15
|
+
' lattris share memory <id-or-prefix> --with <public | all-contacts | contact> [--yes]',
|
|
9
16
|
'',
|
|
10
|
-
' --with public, or an exact contact name or id from
|
|
11
|
-
'
|
|
12
|
-
'
|
|
17
|
+
' --with public, all-contacts, or an exact contact name or id from',
|
|
18
|
+
' `lattris contact list`. The words public and all-contacts win',
|
|
19
|
+
' over a contact of that name; reach such a contact by its id.',
|
|
20
|
+
' group:<name> is reserved for groups, which are not built yet.',
|
|
21
|
+
' --yes required when not at a terminal; at a terminal you are always',
|
|
22
|
+
' asked, --yes or not.',
|
|
13
23
|
'',
|
|
14
|
-
'
|
|
15
|
-
'
|
|
24
|
+
'A deny on the memory beats any allow: the answer names who is still shut',
|
|
25
|
+
'out, and `lattris remove deny` lifts it. Sharing with an audience that',
|
|
26
|
+
'already has access succeeds and changes nothing.',
|
|
16
27
|
'',
|
|
17
28
|
'Alias: publish → share'
|
|
18
29
|
].join('\n');
|
|
30
|
+
export const DENY_HELP = [
|
|
31
|
+
'deny — shut a memory to one contact or to all your contacts, whatever',
|
|
32
|
+
'else allows it. Nothing is asked: a deny is the safe direction. A memory',
|
|
33
|
+
'someone shared with you takes a deny too, for your own contacts.',
|
|
34
|
+
'',
|
|
35
|
+
'Usage:',
|
|
36
|
+
' lattris deny memory <id-or-prefix> --to <all-contacts | contact>',
|
|
37
|
+
'',
|
|
38
|
+
' --to all-contacts, or an exact contact name or id from',
|
|
39
|
+
' `lattris contact list`. public cannot be denied. group:<name>',
|
|
40
|
+
' is reserved for groups, which are not built yet.',
|
|
41
|
+
'',
|
|
42
|
+
'A deny cannot hold while the memory is public or shared on the website',
|
|
43
|
+
'with the person it would shut out; the refusal names the share in the',
|
|
44
|
+
'way. `lattris remove deny` lifts a deny.'
|
|
45
|
+
].join('\n');
|
|
46
|
+
export const REMOVE_DENY_HELP = [
|
|
47
|
+
'remove deny — lift a deny from a memory, for one contact or for all your',
|
|
48
|
+
'contacts. It opens the memory to whatever allows it, so it asks at a',
|
|
49
|
+
'terminal and needs --yes on a pipe. A memory someone shared with you',
|
|
50
|
+
'takes it too, for your own denies.',
|
|
51
|
+
'',
|
|
52
|
+
'Usage:',
|
|
53
|
+
' lattris remove deny [memory] <id-or-prefix> --to <all-contacts | contact> [--yes]',
|
|
54
|
+
'',
|
|
55
|
+
'Alias: undeny memory <id> → remove deny <id>'
|
|
56
|
+
].join('\n');
|
|
57
|
+
const isAccessGrant = (grant) => typeof grant === 'object' &&
|
|
58
|
+
grant !== null &&
|
|
59
|
+
'shutBy' in grant &&
|
|
60
|
+
Array.isArray(grant.shutBy);
|
|
61
|
+
const whoWasShared = (grant, context) => context.contact?.displayName !== undefined
|
|
62
|
+
? sanitizeForTerminal(context.contact.displayName)
|
|
63
|
+
: context.reserved === ALL_CONTACTS
|
|
64
|
+
? 'all contacts'
|
|
65
|
+
: String(grant.kind ?? '');
|
|
66
|
+
const shareSentences = (grant, context) => {
|
|
67
|
+
const lines = [
|
|
68
|
+
`Shared memory ${context.memory?.id ?? context.positionals[0]} with ${whoWasShared(grant, context)}`
|
|
69
|
+
];
|
|
70
|
+
if (!isAccessGrant(grant))
|
|
71
|
+
return lines;
|
|
72
|
+
if (grant.paired) {
|
|
73
|
+
lines.push(`${sanitizeForTerminal(grant.contactName ?? '')} is linked to an account, so the website shows it too.`);
|
|
74
|
+
}
|
|
75
|
+
else if (grant.unpairedBecause === 'owner-has-no-name') {
|
|
76
|
+
lines.push(waitsForNameSentence(grant.contactName ?? ''));
|
|
77
|
+
}
|
|
78
|
+
if (grant.shutBy.length > 0) {
|
|
79
|
+
const denies = grant.shutBy.map(formatAccessRow).join(', ');
|
|
80
|
+
lines.push(grant.kind === 'contact'
|
|
81
|
+
? `${sanitizeForTerminal(grant.contactName ?? '')} is still shut out by: ${denies}`
|
|
82
|
+
: `Still shut out by a deny of their own: ${grant.shutBy.map(audienceOf).join(', ')}`);
|
|
83
|
+
}
|
|
84
|
+
return lines;
|
|
85
|
+
};
|
|
86
|
+
const otherEffectWords = (asked) => (body, context) => {
|
|
87
|
+
if (body.code !== 'memory:withdraw-effect-mismatch')
|
|
88
|
+
return '';
|
|
89
|
+
const found = body.detail?.effect === 'deny' ? 'deny' : 'allow';
|
|
90
|
+
if (found === asked)
|
|
91
|
+
return '';
|
|
92
|
+
const id = context.memory?.id ?? context.positionals[0];
|
|
93
|
+
const who = context.contact?.id ?? ALL_CONTACTS;
|
|
94
|
+
return found === 'deny'
|
|
95
|
+
? `This is a deny, not a share. Lift it with: ${renderRunHint(['remove', 'deny', id, '--to', who])}\n`
|
|
96
|
+
: `This is a share, not a deny. Withdraw it with: ${renderRunHint(['unshare', 'memory', id, '--with', who])}\n`;
|
|
97
|
+
};
|
|
98
|
+
const inTheWay = (body) => {
|
|
99
|
+
const rows = body.detail?.blockedBy;
|
|
100
|
+
if (!Array.isArray(rows) || rows.length === 0)
|
|
101
|
+
return '';
|
|
102
|
+
return `In the way: ${rows.map(formatAccessRow).join(', ')}\n`;
|
|
103
|
+
};
|
|
104
|
+
const contactBody = (effect) => ({
|
|
105
|
+
kind: { value: 'contact' },
|
|
106
|
+
contactId: { context: 'contact.id' },
|
|
107
|
+
effect: { value: effect }
|
|
108
|
+
});
|
|
19
109
|
const shareVerb = {
|
|
20
110
|
verb: 'share',
|
|
21
111
|
nouns: ['memory', 'memories'],
|
|
@@ -26,14 +116,11 @@ const shareVerb = {
|
|
|
26
116
|
positionals: 1,
|
|
27
117
|
idPositionals: [0],
|
|
28
118
|
steps: {
|
|
29
|
-
requireFlag: {
|
|
30
|
-
key: 'with',
|
|
31
|
-
message: '--with is required. Use public or one of your contact names or ids.\n'
|
|
32
|
-
},
|
|
119
|
+
requireFlag: { key: 'with', message: AUDIENCE_WORDS },
|
|
33
120
|
pipedNeedsYes: {
|
|
34
121
|
message: 'Refusing to share without confirmation on a non-interactive session. Pass --yes to skip the prompt.\n'
|
|
35
122
|
},
|
|
36
|
-
contact: { from: ['flag:with'], publicWord: 'public',
|
|
123
|
+
contact: { from: ['flag:with'], publicWord: 'public', reserved: [ALL_CONTACTS] },
|
|
37
124
|
memory: 'at-tty',
|
|
38
125
|
confirm: {
|
|
39
126
|
question: 'Share "{title}" ({memory.id}) with {audience}? [y/N] ',
|
|
@@ -44,27 +131,98 @@ const shareVerb = {
|
|
|
44
131
|
request: {
|
|
45
132
|
method: 'POST',
|
|
46
133
|
path: '/memories/{memory.id}/grants',
|
|
47
|
-
body:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
bodyWithPublic: { audience: 'public' }
|
|
134
|
+
body: contactBody('allow'),
|
|
135
|
+
bodyWithPublic: { audience: 'public' },
|
|
136
|
+
bodyFor: { [ALL_CONTACTS]: { kind: 'all_contacts' } }
|
|
52
137
|
},
|
|
53
138
|
ambiguousRefusal: true,
|
|
54
|
-
|
|
139
|
+
refusalWords: inTheWay,
|
|
140
|
+
render: (grant, context) => shareSentences(grant, context).join('\n')
|
|
55
141
|
}
|
|
56
142
|
};
|
|
143
|
+
const denyVerb = {
|
|
144
|
+
verb: 'deny',
|
|
145
|
+
nouns: ['memory', 'memories'],
|
|
146
|
+
form: {
|
|
147
|
+
usage: 'Usage: lattris deny memory <id> --to <all-contacts | contact>',
|
|
148
|
+
flags: { '--to': 'to' },
|
|
149
|
+
positionals: 1,
|
|
150
|
+
idPositionals: [0],
|
|
151
|
+
steps: {
|
|
152
|
+
requireFlag: { key: 'to', message: DENY_WORDS },
|
|
153
|
+
contact: {
|
|
154
|
+
from: ['flag:to'],
|
|
155
|
+
reserved: [ALL_CONTACTS],
|
|
156
|
+
refusedWords: { public: PUBLIC_CANNOT_BE_DENIED }
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
request: {
|
|
160
|
+
method: 'POST',
|
|
161
|
+
path: '/memories/{memory.id}/grants',
|
|
162
|
+
body: contactBody('deny'),
|
|
163
|
+
bodyFor: { [ALL_CONTACTS]: { kind: 'all_contacts', effect: 'deny' } }
|
|
164
|
+
},
|
|
165
|
+
ambiguousRefusal: true,
|
|
166
|
+
refusalWords: inTheWay,
|
|
167
|
+
render: (_grant, context) => `Denied memory ${context.positionals[0]} to ${context.contact ? sanitizeForTerminal(context.contact.displayName) : 'all contacts'}`
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const liftingForm = {
|
|
171
|
+
usage: 'Usage: lattris remove deny [memory] <id> --to <all-contacts | contact> [--yes]',
|
|
172
|
+
flags: { '--to': 'to' },
|
|
173
|
+
switches: ['--yes'],
|
|
174
|
+
positionals: 1,
|
|
175
|
+
idPositionals: [0],
|
|
176
|
+
steps: {
|
|
177
|
+
requireFlag: { key: 'to', message: DENY_WORDS },
|
|
178
|
+
pipedNeedsYes: {
|
|
179
|
+
message: 'Refusing to lift a deny without confirmation on a non-interactive session. Pass --yes to skip the prompt.\n'
|
|
180
|
+
},
|
|
181
|
+
contact: {
|
|
182
|
+
from: ['flag:to'],
|
|
183
|
+
reserved: [ALL_CONTACTS],
|
|
184
|
+
refusedWords: { public: PUBLIC_CANNOT_BE_DENIED }
|
|
185
|
+
},
|
|
186
|
+
memory: 'at-tty',
|
|
187
|
+
confirm: {
|
|
188
|
+
question: 'Lift the deny on "{title}" ({memory.id}) for {audience}? [y/N] ',
|
|
189
|
+
onNo: { text: 'Cancelled.\n', to: 'stderr' },
|
|
190
|
+
onInterrupted: { text: 'Cancelled.\n', exit: 1 }
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
request: {
|
|
194
|
+
method: 'DELETE',
|
|
195
|
+
path: '/memories/{memory.id}/grants/contact/{contact.id}?effect=deny',
|
|
196
|
+
pathFor: { [ALL_CONTACTS]: '/memories/{memory.id}/grants/all-contacts?effect=deny' }
|
|
197
|
+
},
|
|
198
|
+
ambiguousRefusal: true,
|
|
199
|
+
refusalWords: otherEffectWords('deny'),
|
|
200
|
+
renderTo: 'stderr',
|
|
201
|
+
render: (_data, context) => `Lifted the deny on memory ${context.memory?.id ?? context.positionals[0]} for ${context.contact ? sanitizeForTerminal(context.contact.displayName) : 'all contacts'}`
|
|
202
|
+
};
|
|
203
|
+
const removeDenyVerb = {
|
|
204
|
+
verb: 'remove',
|
|
205
|
+
nouns: ['deny'],
|
|
206
|
+
form: { ...liftingForm, dropLeadingWords: ['memory'] }
|
|
207
|
+
};
|
|
208
|
+
const undenyVerb = { verb: 'undeny', nouns: ['memory', 'memories'], form: liftingForm };
|
|
57
209
|
export const UNSHARE_HELP = [
|
|
58
210
|
'unshare — withdraw an audience from a memory. No confirmation — withdrawal',
|
|
59
|
-
'is the safe direction.',
|
|
211
|
+
'is the safe direction. A memory someone shared with you takes it too, for',
|
|
212
|
+
"your own contact shares; public is the owner's alone.",
|
|
60
213
|
'',
|
|
61
214
|
'Usage:',
|
|
62
|
-
' lattris unshare memory <id-or-prefix> --with <public-
|
|
215
|
+
' lattris unshare memory <id-or-prefix> --with <public | all-contacts | contact>',
|
|
63
216
|
'',
|
|
64
|
-
' --with public, or an exact contact name or id from
|
|
217
|
+
' --with public, all-contacts, or an exact contact name or id from',
|
|
218
|
+
' `lattris contact list`. For a contact, the website row paired',
|
|
219
|
+
' with its allow goes too, and so does a website share written',
|
|
220
|
+
' before contact shares existed. group:<name> is reserved for',
|
|
221
|
+
' groups, which are not built yet.',
|
|
65
222
|
'',
|
|
66
223
|
'Bare (no --with): refuses and shows what the memory is currently shared',
|
|
67
|
-
'with, so you can see the state and the fix in one line.',
|
|
224
|
+
'with, so you can see the state and the fix in one line. A deny is lifted',
|
|
225
|
+
'with `lattris remove deny`, not here.',
|
|
68
226
|
'',
|
|
69
227
|
'Alias: unpublish → unshare'
|
|
70
228
|
].join('\n');
|
|
@@ -77,22 +235,33 @@ const unshareVerb = {
|
|
|
77
235
|
positionals: 1,
|
|
78
236
|
idPositionals: [0],
|
|
79
237
|
steps: {
|
|
80
|
-
contact: { from: ['flag:with'], publicWord: 'public',
|
|
238
|
+
contact: { from: ['flag:with'], publicWord: 'public', reserved: [ALL_CONTACTS] },
|
|
81
239
|
memory: 'always',
|
|
82
240
|
noAudienceReport: {
|
|
83
241
|
key: 'with',
|
|
84
|
-
first:
|
|
242
|
+
first: AUDIENCE_WORDS,
|
|
85
243
|
second: '"{title}" ({memory.id}) is currently shared with: {audiences}\n'
|
|
86
244
|
}
|
|
87
245
|
},
|
|
88
246
|
request: {
|
|
89
247
|
method: 'DELETE',
|
|
90
|
-
path: '/memories/{memory.id}/grants/
|
|
91
|
-
pathWithPublic: '/memories/{memory.id}/grants/public'
|
|
248
|
+
path: '/memories/{memory.id}/grants/contact/{contact.id}?effect=allow',
|
|
249
|
+
pathWithPublic: '/memories/{memory.id}/grants/public',
|
|
250
|
+
pathFor: { [ALL_CONTACTS]: '/memories/{memory.id}/grants/all-contacts?effect=allow' },
|
|
251
|
+
fallback: {
|
|
252
|
+
status: 404,
|
|
253
|
+
path: '/memories/{memory.id}/grants/person/{contact.claimedPersonId}',
|
|
254
|
+
when: 'contact.linked'
|
|
255
|
+
}
|
|
92
256
|
},
|
|
93
257
|
ambiguousRefusal: true,
|
|
258
|
+
refusalWords: otherEffectWords('allow'),
|
|
94
259
|
renderTo: 'stderr',
|
|
95
|
-
render: (_data, context) => `Unshared memory ${context.memory?.id ?? ''} from ${context.contact
|
|
260
|
+
render: (_data, context) => `Unshared memory ${context.memory?.id ?? ''} from ${context.contact
|
|
261
|
+
? sanitizeForTerminal(context.contact.displayName)
|
|
262
|
+
: context.reserved === ALL_CONTACTS
|
|
263
|
+
? 'all contacts'
|
|
264
|
+
: 'public'}`
|
|
96
265
|
}
|
|
97
266
|
};
|
|
98
267
|
export const audiencesOf = (memory) => formatAudiences(memory.audiences);
|
|
@@ -100,6 +269,6 @@ export const grants = {
|
|
|
100
269
|
name: 'grants',
|
|
101
270
|
words: { singular: 'grant', plural: 'grants' },
|
|
102
271
|
help: SHARE_HELP,
|
|
103
|
-
verbs: [shareVerb, unshareVerb, consent]
|
|
272
|
+
verbs: [shareVerb, unshareVerb, denyVerb, removeDenyVerb, undenyVerb, consent]
|
|
104
273
|
};
|
|
105
274
|
//# sourceMappingURL=share.js.map
|
package/dist/nouns/words.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const VERB_ALIASES = {
|
|
2
2
|
read: 'get',
|
|
3
3
|
show: 'get',
|
|
4
4
|
view: 'get',
|
|
@@ -7,6 +7,11 @@ export const VERB_ALIASES = {
|
|
|
7
7
|
publish: 'share',
|
|
8
8
|
unpublish: 'unshare'
|
|
9
9
|
};
|
|
10
|
+
export const resolveVerb = (typed, next) => typed === 'remove' && next === 'deny'
|
|
11
|
+
? 'remove'
|
|
12
|
+
: Object.hasOwn(VERB_ALIASES, typed)
|
|
13
|
+
? VERB_ALIASES[typed]
|
|
14
|
+
: typed;
|
|
10
15
|
export const USAGE_LINES = [
|
|
11
16
|
' lattris login Sign in via the browser (PKCE) and store the session',
|
|
12
17
|
' lattris setup Transition this repo’s Claude to Lattris as its memory system',
|
|
@@ -18,16 +23,21 @@ export const USAGE_LINES = [
|
|
|
18
23
|
' lattris capture memory Capture a memory — `echo "…" | lattris capture memory`',
|
|
19
24
|
' lattris capture session <transcript> Save an AI conversation — the whole chain from its file',
|
|
20
25
|
' lattris capture recording Keep a recording \u2014 held audio, a source, or a transcript file',
|
|
21
|
-
' lattris get memories List your memories, newest first, with filters',
|
|
22
|
-
' lattris contact create "<name>" Record a person or an AI you work with (--ai); add, list, get, update',
|
|
23
|
-
' lattris invite <contact>
|
|
26
|
+
' lattris get memories List your memories, newest first, with filters (--for <contact> for what they may see)',
|
|
27
|
+
' lattris contact create "<name>" Record a person or an AI you work with (--ai, --phone); add, list, get, update, delete, link',
|
|
28
|
+
' lattris invite <contact> [--email <address>] Mint an invitation for one of your person contacts, admitting one address',
|
|
24
29
|
' lattris get invites List the invitations you have minted',
|
|
25
30
|
' lattris get memory <id> Read one memory back \u2014 words and edges (--links/--depth/--content)',
|
|
26
31
|
' lattris ask <handle> Leave a question on someone\u2019s tree \u2014 `echo "\u2026" | lattris ask <handle>`',
|
|
27
32
|
' lattris get questions The questions on your tree, open first (--mine: ones you asked)',
|
|
28
33
|
' lattris close question <id> Close a question (--close-as updated|declined|already-answered)',
|
|
29
|
-
' lattris
|
|
30
|
-
' lattris
|
|
34
|
+
' lattris accept contact <id> Say yes to a request to link you as a contact: both sides link',
|
|
35
|
+
' lattris decline contact <id> Say no to one; nothing changes and the asker is not told',
|
|
36
|
+
' lattris share memory <id> Allow an audience to see it (--with public | all-contacts | <contact>)',
|
|
37
|
+
' lattris unshare memory <id> Withdraw an audience (--with public | all-contacts | <contact>)',
|
|
38
|
+
' lattris deny memory <id> Shut it to a contact or all contacts, whatever allows it (--to)',
|
|
39
|
+
' lattris remove deny <id> Lift a deny (--to all-contacts | <contact>)',
|
|
40
|
+
' lattris get access <id> May a contact or a number see it, and because of what (--for)',
|
|
31
41
|
' lattris consent <id> Put a memory shared with you on your graph (--withdraw reverses)',
|
|
32
42
|
' lattris link <from> <to> State that one memory leads to another (--verb, --reason)',
|
|
33
43
|
' lattris unlink <from> <to> Remove that claim (--verb; the blocks stay)',
|
|
@@ -58,6 +68,8 @@ export const COMMAND_WORDS = new Set([
|
|
|
58
68
|
'get',
|
|
59
69
|
'ask',
|
|
60
70
|
'close',
|
|
71
|
+
'accept',
|
|
72
|
+
'decline',
|
|
61
73
|
'delete',
|
|
62
74
|
'update',
|
|
63
75
|
'link',
|
|
@@ -65,6 +77,9 @@ export const COMMAND_WORDS = new Set([
|
|
|
65
77
|
'invite',
|
|
66
78
|
'share',
|
|
67
79
|
'unshare',
|
|
80
|
+
'deny',
|
|
81
|
+
'undeny',
|
|
82
|
+
'remove',
|
|
68
83
|
'consent',
|
|
69
84
|
'restore',
|
|
70
85
|
'erase',
|
package/dist/registry/memory.js
CHANGED
|
@@ -4,6 +4,7 @@ import { CAPTURE_INDEX, CAPTURE_NOTE_HELP, CAPTURE_SESSION_HELP } from "../memor
|
|
|
4
4
|
import { asksForSessionForm, captureMemory } from "../memory/capture-note.js";
|
|
5
5
|
import { DELETE_HELP, deleteMemory } from "../memory/delete.js";
|
|
6
6
|
import { ERASE_HELP, eraseMemory } from "../memory/erase.js";
|
|
7
|
+
import { GET_ACCESS_HELP, getAccess } from "../memory/access.js";
|
|
7
8
|
import { GET_HELP } from "../memory/get-help.js";
|
|
8
9
|
import { getMemories } from "../memory/get.js";
|
|
9
10
|
import { getDeleted, getHistory } from "../memory/history.js";
|
|
@@ -37,6 +38,7 @@ export const memoryNouns = [
|
|
|
37
38
|
},
|
|
38
39
|
{ verb: 'get', nouns: ['history'], handler: getHistory },
|
|
39
40
|
{ verb: 'get', nouns: ['deleted'], handler: getDeleted },
|
|
41
|
+
{ verb: 'get', nouns: ['access'], handler: getAccess },
|
|
40
42
|
{ verb: 'update', nouns: ['memory', 'memories'], handler: updateMemory },
|
|
41
43
|
{ verb: 'delete', nouns: ['memory', 'memories'], handler: deleteMemory },
|
|
42
44
|
{ verb: 'restore', nouns: ['memory', 'memories', 'note'], handler: restoreMemory },
|
|
@@ -73,10 +75,14 @@ export const memoryVerbs = {
|
|
|
73
75
|
badNoun: { stderr: 'Unknown capture form: {noun}\n\n', stdout: `${CAPTURE_INDEX}\n` }
|
|
74
76
|
},
|
|
75
77
|
get: {
|
|
76
|
-
help: (args) => ['datasets', 'dataset', 'rows', 'row'].includes(args[0])
|
|
78
|
+
help: (args) => ['datasets', 'dataset', 'rows', 'row'].includes(args[0])
|
|
79
|
+
? GET_DATASETS_HELP
|
|
80
|
+
: args[0] === 'access'
|
|
81
|
+
? GET_ACCESS_HELP
|
|
82
|
+
: GET_HELP,
|
|
77
83
|
bareIsHelp: true,
|
|
78
84
|
badNoun: {
|
|
79
|
-
stderr: 'Usage: lattris get memories | lattris get memory <id> | 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'
|
|
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'
|
|
80
86
|
}
|
|
81
87
|
},
|
|
82
88
|
update: {
|
package/dist/render/rows.js
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
|
-
import { sanitizeForTerminal } from "./text.js";
|
|
1
|
+
import { renderRunHint, sanitizeForTerminal } from "./text.js";
|
|
2
|
+
import { isUuidKey } from "../store/write-identity.js";
|
|
2
3
|
export const formatContact = (c) => `${sanitizeForTerminal(c.displayName)} · ${c.type} · ${c.id}` +
|
|
3
4
|
`${c.claimedPersonId ? ' · linked' : ''}` +
|
|
4
5
|
`${c.email ? ` · email ${sanitizeForTerminal(c.email)}` : ''}` +
|
|
6
|
+
`${c.phone ? ` · phone ${sanitizeForTerminal(c.phone)}` : ''}` +
|
|
5
7
|
`${c.rootBlockId ? ` · root ${c.rootBlockId}` : ''}`;
|
|
8
|
+
export const resolveContact = (contacts, selector) => {
|
|
9
|
+
if (isUuidKey(selector)) {
|
|
10
|
+
const contact = contacts.find((c) => c.id.toLowerCase() === selector.toLowerCase());
|
|
11
|
+
return contact ? { kind: 'found', contact } : { kind: 'missing-id' };
|
|
12
|
+
}
|
|
13
|
+
const folded = selector.toLowerCase();
|
|
14
|
+
const matches = contacts.filter((c) => c.displayName.toLowerCase() === folded);
|
|
15
|
+
if (matches.length === 1)
|
|
16
|
+
return { kind: 'found', contact: matches[0] };
|
|
17
|
+
if (matches.length > 1)
|
|
18
|
+
return { kind: 'ambiguous', matches };
|
|
19
|
+
return { kind: 'missing-name', displayName: selector };
|
|
20
|
+
};
|
|
21
|
+
export const isGroupWord = (word) => word.trim().toLowerCase().startsWith('group:');
|
|
22
|
+
export const groupsNotBuilt = (word) => `${sanitizeForTerminal(word)} names a group, and groups are not built yet. A contact called that is reached by its id.\n`;
|
|
23
|
+
export const audienceOf = (r) => r.kind === 'public'
|
|
24
|
+
? 'public'
|
|
25
|
+
: r.kind === 'all_contacts'
|
|
26
|
+
? 'all contacts'
|
|
27
|
+
: r.kind === 'person'
|
|
28
|
+
? `${sanitizeForTerminal(r.contactName ?? r.personId ?? '')} (website)`
|
|
29
|
+
: sanitizeForTerminal(r.contactName ?? r.contactId ?? '');
|
|
30
|
+
export const formatAccessRow = (r) => `${r.effect} ${audienceOf(r)}`;
|
|
31
|
+
export const waitsForNameSentence = (name) => `${sanitizeForTerminal(name)} is linked to an account, but the website share waits until you set your name (${renderRunHint(['set', 'name'])}).`;
|
|
32
|
+
export const waitsForNameLines = (rows) => (rows ?? [])
|
|
33
|
+
.filter((r) => r.unpairedBecause === 'owner-has-no-name' && r.contactName)
|
|
34
|
+
.map((r) => waitsForNameSentence(r.contactName ?? ''));
|
|
35
|
+
export const formatAccess = (rows) => rows.length === 0 ? '(nothing set)' : rows.map(formatAccessRow).join('; ');
|
|
36
|
+
export const describeForContact = (c, asked) => c === null
|
|
37
|
+
? `no contact holds ${sanitizeForTerminal(asked ?? 'that number')}; a stranger sees public memories only`
|
|
38
|
+
: `${sanitizeForTerminal(c.displayName)} (${c.type}${c.phone ? `, ${sanitizeForTerminal(c.phone)}` : ''})`;
|
|
39
|
+
const askerLine = (q) => `${sanitizeForTerminal(q.askerName ?? '(unnamed)')} (@${sanitizeForTerminal(q.sharerHandle ?? '(unknown)')})`;
|
|
6
40
|
export const formatQuestion = (q) => {
|
|
7
41
|
const lines = [`id ${q.id}`, `createdAt ${q.createdAt}`];
|
|
8
42
|
if (q.kind === 'share') {
|
|
9
43
|
lines.push(`shared by @${sanitizeForTerminal(q.sharerHandle ?? '(unknown)')}`, `memory ${q.aboutBlockId ?? '(missing)'}`, `seen ${q.seenAt ?? '(unseen)'}`);
|
|
10
44
|
return lines.join('\n');
|
|
11
45
|
}
|
|
46
|
+
if (q.kind === 'contact_link') {
|
|
47
|
+
lines.push(`link request ${askerLine(q)} asks to link you as a contact`, q.closedAs === null
|
|
48
|
+
? `answer ${renderRunHint(['accept', 'contact', q.id])} or ${renderRunHint(['decline', 'contact', q.id])}`
|
|
49
|
+
: `closed as ${sanitizeForTerminal(q.closedAs)}${q.closedAt ? ` ${q.closedAt}` : ''}`);
|
|
50
|
+
return lines.join('\n');
|
|
51
|
+
}
|
|
12
52
|
if (q.aboutBlockId)
|
|
13
53
|
lines.push(`about ${q.aboutBlockId}`);
|
|
14
54
|
lines.push(q.closedAs === null
|
|
@@ -27,6 +67,11 @@ export const formatAsked = (q) => {
|
|
|
27
67
|
lines.push(` createdAt ${q.createdAt}`);
|
|
28
68
|
return lines.join('\n');
|
|
29
69
|
};
|
|
70
|
+
export const formatLinkAnswer = (q) => q.closedAs === 'accepted'
|
|
71
|
+
? `Linked ${askerLine(q)} as a contact; their contact now stands for your account.`
|
|
72
|
+
: q.closedAs === 'superseded'
|
|
73
|
+
? `Nothing linked: a contact on ${askerLine(q)}'s side already stands for an account, so the request is closed as superseded.`
|
|
74
|
+
: `Declined the link request from ${askerLine(q)}. Nothing changed, and they are not told.`;
|
|
30
75
|
export const formatClosed = (q) => `Closed question ${q.id} (${sanitizeForTerminal(q.closedAs ?? '')})${q.closeBlockId ? ` → ${q.closeBlockId}` : ''}`;
|
|
31
76
|
export const formatEdgeReceipt = (heading, e) => [
|
|
32
77
|
`${heading} (verb: ${sanitizeForTerminal(e.verb)})`,
|
package/dist/request/door.js
CHANGED
|
@@ -8,6 +8,7 @@ export const parseErrorBody = (text) => {
|
|
|
8
8
|
return {};
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
+
const SECURITY_CODE = /^(?:security|auth)[:/]/;
|
|
11
12
|
export const classifyApiError = (status, body) => {
|
|
12
13
|
if (body.next?.action) {
|
|
13
14
|
return { message: body.message ?? 'Action required.', next: body.next, exit: EXIT.DOOR };
|
|
@@ -19,7 +20,7 @@ export const classifyApiError = (status, body) => {
|
|
|
19
20
|
exit: EXIT.NOAUTH
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
if (status === 403) {
|
|
23
|
+
if (status === 403 && (body.code === undefined || SECURITY_CODE.test(body.code))) {
|
|
23
24
|
return {
|
|
24
25
|
message: body.message ?? 'Your session lacks a required scope.',
|
|
25
26
|
next: { action: 'login' },
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lattris",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "First-party CLI for Lattris
|
|
5
|
+
"description": "First-party CLI for Lattris — sign in, capture notes and sessions, and read your own tree from the terminal.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"lattris",
|
|
8
8
|
"cli",
|