@estiva-app/conversation 0.13.0 → 0.15.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/CHANGELOG.md CHANGED
@@ -6,6 +6,43 @@ none. A change to how an event is read is a MINOR in `0.x` even when no
6
6
  signature moved, because two apps on different versions would then disagree
7
7
  about a conversation.
8
8
 
9
+ ## 0.15.0 — 2026-10-19
10
+
11
+ **Search matches every typed word as the start of a word** (record
12
+ *search-matches-every-word-as-a-word-start*). `referenceMatch` now keeps a
13
+ text only when each typed word starts one of its words, in any order; `"…"`
14
+ needs those whole words next to each other, in order; `-word` drops a text with
15
+ a word starting that way; a quote with no closing partner is ignored; `or` and
16
+ `key:value` are ordinary words; punctuation at a typed word's ends is ignored.
17
+ A query that only leaves words out matches nothing. A match inside a word is
18
+ gone: "ssue" no longer finds "issue". A hit where every typed word is a whole
19
+ word now ranks above one where a word is only started, so "short" lists
20
+ *Remove Short summary* above *Shortcuts*: the scores are 8 the whole text, 7–5
21
+ whole words (its start, one run at a word start, every word somewhere) and 3–1
22
+ the same for word starts; only `> 0` was ever read outside this package.
23
+ `referenceSearch` no longer lets an empty answer for words that are only left
24
+ out (`-draft`), or for a query with a quote still open (`"x -y`), stop a longer
25
+ query.
26
+
27
+ SPEC: §5.2 changed — a relay matches every typed word as a word start on a REQ
28
+ and on `/query` alike, and a reader's check of a title uses the same rule, so
29
+ it never drops a hit the relay found.
30
+
31
+ ## 0.14.0 — 2026-10-19
32
+
33
+ **A reply to a comment on part of a page copies that comment's place**
34
+ (COMM-5). `CommentRef.place` takes the comment's `block` and `quote` tags, and
35
+ `buildReply` writes them verbatim after its `p`, before its `h`; any other tag
36
+ handed to it, and any `block` or `quote` among the reply's own `tags`, is
37
+ dropped. `placeOf(comment)` reads a comment's place off its event. So a thread
38
+ keeps its place on the page when its comment is deleted, and an app holding
39
+ only a reply can place it (record *a-reply-on-a-page-keeps-its-threads-place*).
40
+ A caller that passes no `place` writes the reply as before.
41
+
42
+ SPEC: §13.6 changed — a reply now copies its top-level comment's `block` and
43
+ `quote` instead of carrying none; a reader places a thread by its comment's
44
+ anchor while it is readable, else by its earliest reply's.
45
+
9
46
  ## 0.13.0 — 2026-10-17
10
47
 
11
48
  **What the shared comment box holds, as the message it writes, and back**
package/README.md CHANGED
@@ -24,7 +24,7 @@ pass, the clock is a `createdAtMs` you pass, and drafts take their storage.
24
24
  | --- | --- | --- |
25
25
  | comment or mention | §6.4 | `isCommentOn`, `strengthOn`, `threadStrength`, `anchorsOf`, `isReply`, `namedInBody` |
26
26
  | threading | §6.4 *Replies* | `parentOf`, `groupThreads` |
27
- | writing | §6.4 | `buildComment`, `buildReply`, `referenceTagsFor`, `mentionTagsFor` |
27
+ | writing | §6.4, §13.6 | `buildComment`, `buildReply`, `placeOf`, `referenceTagsFor`, `mentionTagsFor` |
28
28
  | what a composer's pick writes | §13.1 | `mentionText`, `messageReference`, `urgentTagsFor`, `URGENT_TAG` |
29
29
  | what the shared comment box holds, as the message it writes, and back | §13.1 | `composerText`, `composerDocument`, `withoutNewUrgency`, `composerDraft` |
30
30
  | what `[` offers, and in what order | §13.1 | `rankReferences`, `referenceMatch`, `fileReference`, `referenceSearch`, `MESSAGE_TIER`, `FILE_TIER`, `REFERENCE_CAPS` |
@@ -38,15 +38,35 @@ export interface CommentRef {
38
38
  * then carries no `p`, because a wrong one notifies the wrong person.
39
39
  */
40
40
  author?: string;
41
+ /**
42
+ * Where on its object the comment is: its own `block` and `quote` tags
43
+ * ({@link placeOf}). The reply copies them, so its thread keeps its place
44
+ * once the comment is deleted (§13.6). Absent when the comment is on the
45
+ * whole object or outside the read.
46
+ */
47
+ place?: readonly NostrTag[];
41
48
  }
49
+ /**
50
+ * A comment's place, as its event carries it: its `block` and `quote` tags,
51
+ * verbatim, for {@link CommentRef.place}. Empty when it is on the whole object.
52
+ *
53
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-reply-on-a-page-keeps-its-threads-place.md
54
+ */
55
+ export declare function placeOf(comment: {
56
+ tags: readonly NostrTag[];
57
+ }): NostrTag[];
42
58
  /**
43
59
  * A reply to a comment — §6.4 *Replies*, C16. Tag order: `A`, `K`, `P`, `e`,
44
- * `k`, `[p]`, `h`, `ts`, `[imeta…]`, then `tags`.
60
+ * `k`, `[p]`, `[block, quote]`, `h`, `ts`, `[imeta…]`, then `tags`.
45
61
  *
46
62
  * **Flat, one level deep**: `e` names the thread's top-level comment, never
47
63
  * another reply. **No lowercase `a`** for the object: NIP-22 reads it as the
48
64
  * parent, so it would claim the reply is itself a top-level comment. The reply
49
- * is found by `#e` on the comment.
65
+ * is found by `#e` on the comment. **Its comment's place, copied** (§13.6):
66
+ * the `block` and `quote` tags of `comment.place` as written, and no other
67
+ * tag from it.
68
+ *
69
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-reply-on-a-page-keeps-its-threads-place.md
50
70
  */
51
71
  export declare function buildReply(pubkey: string, createdAtMs: number, args: {
52
72
  comment: CommentRef;
@@ -1 +1 @@
1
- {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAA4B,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAmB9G;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,GAC5H,aAAa,CAsBf;AAED,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,oBAA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MAAM,CAAA;IACV,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;CAC5B;AAKD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,GAAG,QAAQ,EAAE,CAG1E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,GAChH,aAAa,CAuBf;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAExG"}
package/dist/builders.js CHANGED
@@ -59,19 +59,35 @@ export function buildComment(pubkey, createdAtMs, args) {
59
59
  content: args.body,
60
60
  };
61
61
  }
62
+ /** The tags that say where on its object a comment is (§13.6): `block` and `quote`. */
63
+ const PLACE_TAGS = new Set(['block', 'quote']);
64
+ /**
65
+ * A comment's place, as its event carries it: its `block` and `quote` tags,
66
+ * verbatim, for {@link CommentRef.place}. Empty when it is on the whole object.
67
+ *
68
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-reply-on-a-page-keeps-its-threads-place.md
69
+ */
70
+ export function placeOf(comment) {
71
+ // One of each, the first, as every reader reads it: a stranger's extra tags are not copied under the replier's key.
72
+ return [...PLACE_TAGS].map((name) => comment.tags.find((t) => t[0] === name)).filter((t) => !!t);
73
+ }
62
74
  /**
63
75
  * A reply to a comment — §6.4 *Replies*, C16. Tag order: `A`, `K`, `P`, `e`,
64
- * `k`, `[p]`, `h`, `ts`, `[imeta…]`, then `tags`.
76
+ * `k`, `[p]`, `[block, quote]`, `h`, `ts`, `[imeta…]`, then `tags`.
65
77
  *
66
78
  * **Flat, one level deep**: `e` names the thread's top-level comment, never
67
79
  * another reply. **No lowercase `a`** for the object: NIP-22 reads it as the
68
80
  * parent, so it would claim the reply is itself a top-level comment. The reply
69
- * is found by `#e` on the comment.
81
+ * is found by `#e` on the comment. **Its comment's place, copied** (§13.6):
82
+ * the `block` and `quote` tags of `comment.place` as written, and no other
83
+ * tag from it.
84
+ *
85
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-reply-on-a-page-keeps-its-threads-place.md
70
86
  */
71
87
  export function buildReply(pubkey, createdAtMs, args) {
72
88
  assertFolder(args.folder);
73
89
  const [kind, author] = kindAndAuthor(args.comment.anchor);
74
- const earned = (args.tags ?? []).filter((t) => !(t[0] === 'a' && t[1] === args.comment.anchor));
90
+ const earned = (args.tags ?? []).filter((t) => !(t[0] === 'a' && t[1] === args.comment.anchor) && !PLACE_TAGS.has(t[0]));
75
91
  return {
76
92
  pubkey,
77
93
  created_at: toNostrSeconds(createdAtMs),
@@ -83,6 +99,7 @@ export function buildReply(pubkey, createdAtMs, args) {
83
99
  ['e', args.comment.id],
84
100
  ['k', String(KIND_COMMENT)],
85
101
  ...(args.comment.author ? [['p', args.comment.author]] : []),
102
+ ...(args.comment.place ? placeOf({ tags: args.comment.place }).map((t) => [...t]) : []),
86
103
  ['h', args.folder],
87
104
  ['ts', String(Math.floor(createdAtMs))],
88
105
  ...(args.files ?? []).map(imetaTag),
@@ -1 +1 @@
1
- {"version":3,"file":"builders.js","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QA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M,CAAC;YACb,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,CAAC,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YAC3B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvF,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;YAClB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;YACvC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnC,GAAG,MAAM;SACV;QACD,OAAO,EAAE,IAAI,CAAC,IAAI;KACnB,CAAA;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA2D;IAC7F,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAA;AACrD,CAAC"}
package/dist/edits.d.ts CHANGED
@@ -81,7 +81,7 @@ export declare function foldAttachments(events: readonly SignedEvent[]): Record<
81
81
  * edit removes a card. Which of these the body still names is
82
82
  * `cardsIn`'s question, asked of the folded body. Messages with none are absent.
83
83
  *
84
- * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/where-a-link-sits-and-which-file-gets-the-card.md
84
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
85
85
  */
86
86
  export declare function foldEmbeds(events: readonly SignedEvent[]): Record<string, Embed[]>;
87
87
  //# sourceMappingURL=edits.d.ts.map
package/dist/edits.js CHANGED
@@ -128,7 +128,7 @@ export function foldAttachments(events) {
128
128
  * edit removes a card. Which of these the body still names is
129
129
  * `cardsIn`'s question, asked of the folded body. Messages with none are absent.
130
130
  *
131
- * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/where-a-link-sits-and-which-file-gets-the-card.md
131
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
132
132
  */
133
133
  export function foldEmbeds(events) {
134
134
  const out = {};
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export declare const CONVERSATION_VERSION = "0.13.0";
15
+ export declare const CONVERSATION_VERSION = "0.15.0";
16
16
  export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
17
17
  export { trustedTs, orderingMs, byOrder } from './order.js';
18
18
  export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, type Strength, } from './strength.js';
@@ -20,7 +20,7 @@ export { parentOf, groupThreads, type Threaded } from './threads.js';
20
20
  export { editTargetOf, editsByTarget, foldEdits, foldAttachments, foldEmbeds, type EditFold } from './edits.js';
21
21
  export { REACTION_HORIZON, REACTION_EMOJI, reactionTargetOf, reactionEmojiOf, reactionHorizon, reactionEventsOf, foldReactions, groupReactions, type ReactionHorizon, type ReactionEvent, type Reaction, } from './reactions.js';
22
22
  export { decorationsOf, type Decoration, type Decorations, type Resolution, type QueryFn } from './decorations.js';
23
- export { buildComment, buildReply, offersEditAndDelete, type CommentRef } from './builders.js';
23
+ export { buildComment, buildReply, offersEditAndDelete, placeOf, type CommentRef } from './builders.js';
24
24
  export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js';
25
25
  export { composerDocument, composerDraft, composerText, withoutNewUrgency, type ComposerDraft, type ComposerLabels, type ComposerText, } from './composer.js';
26
26
  export { FILE_TIER, fileReference, MESSAGE_TIER, rankReferences, REFERENCE_CAPS, referenceMatch, referenceSearch, refMatch, type RankedReferences, type RankReferencesInput, type ReferenceCandidate, type ReferenceSearch, type ReferenceSearchFn, type ReferenceSearchOptions, type ReferenceType, } from './references.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE/G,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,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AAa,EACb,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX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A"}
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export const CONVERSATION_VERSION = '0.13.0';
15
+ export const CONVERSATION_VERSION = '0.15.0';
16
16
  export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
17
17
  export { trustedTs, orderingMs, byOrder } from './order.js';
18
18
  export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, } from './strength.js';
@@ -20,7 +20,7 @@ export { parentOf, groupThreads } from './threads.js';
20
20
  export { editTargetOf, editsByTarget, foldEdits, foldAttachments, foldEmbeds } from './edits.js';
21
21
  export { REACTION_HORIZON, REACTION_EMOJI, reactionTargetOf, reactionEmojiOf, reactionHorizon, reactionEventsOf, foldReactions, groupReactions, } from './reactions.js';
22
22
  export { decorationsOf } from './decorations.js';
23
- export { buildComment, buildReply, offersEditAndDelete } from './builders.js';
23
+ export { buildComment, buildReply, offersEditAndDelete, placeOf } from './builders.js';
24
24
  export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js';
25
25
  export { composerDocument, composerDraft, composerText, withoutNewUrgency, } from './composer.js';
26
26
  export { FILE_TIER, fileReference, MESSAGE_TIER, rankReferences, REFERENCE_CAPS, referenceMatch, referenceSearch, refMatch, } from './references.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aA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AW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,iBAAiB,GAGlB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,GAYjB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GAErB,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,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,GAYjB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
@@ -70,9 +70,21 @@ export interface RankReferencesInput {
70
70
  exclude?: readonly string[];
71
71
  }
72
72
  /**
73
- * How well `text` holds `query`: 4 the whole of it, 3 its start, 2 the start of
74
- * a word, 1 anywhere — or every word of the query at a word's start. 0 is no
75
- * match. Case and runs of spaces are ignored.
73
+ * How well `text` holds `query`, by the rule every Estiva search uses (SPEC
74
+ * §5.2): each typed word matches the start of a word, in any order; `"…"`
75
+ * matches those whole words next to each other; `-word` leaves out a text with
76
+ * a word starting that way. Punctuation at a typed word's ends is ignored, and
77
+ * so is case. A query with nothing to find but words left out matches nothing.
78
+ *
79
+ * Of the texts that match, a hit where every typed word is a whole word ranks
80
+ * above one where a word is only started (the record: "re" finds hundreds), and
81
+ * within each, by where it was found: the whole text, its start, what was typed
82
+ * as one run at the start of a word, every word somewhere. So 8 is the whole
83
+ * text, 7–5 whole words, 3–1 word starts, and 0 no match.
84
+ *
85
+ * Every text the rule finds, this finds, so a title the relay found by the rule
86
+ * is never dropped. A relay MAY find more (another may stem or fold accents;
87
+ * buzz caps a typed word at 4 pieces), and this drops what the rule does not.
76
88
  */
77
89
  export declare function referenceMatch(text: string, query: string): number;
78
90
  /**
@@ -121,9 +133,8 @@ export interface ReferenceSearch {
121
133
  }
122
134
  export interface ReferenceSearchOptions {
123
135
  /**
124
- * Must find no more for `q + " words"` than for `q` (every word, the last as
125
- * a prefix: buzz's prefix mode), since a longer query after an empty answer
126
- * is not asked.
136
+ * Must find no more for `q + " words"` than for `q` (every word must match,
137
+ * SPEC §5.2), since a longer query after an empty answer is not asked.
127
138
  */
128
139
  search: ReferenceSearchFn;
129
140
  /** The pause after a keystroke before asking. Default 200ms. */
@@ -149,7 +160,7 @@ export interface ReferenceSearchOptions {
149
160
  * keeps its answer, which is still true of that query.
150
161
  *
151
162
  * Once a query found nothing, adding whole words to it is not asked (08d7f243):
152
- * relay search is every word, the last as a prefix, so `see [the fig` cannot
163
+ * relay search needs every word to match (SPEC §5.2), so `see [the fig` cannot
153
164
  * find what `the` did not, and a sentence typed after an unmatched `[` would
154
165
  * otherwise spend the rate limit on every longer version of itself. A failure
155
166
  * is not "nothing", so it never stops a longer query.
@@ -1 +1 @@
1
- {"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAuBA,+FAA+F;AAC/F,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;AAElF,+BAA+B;AAC/B,MAAM,WAAW,kBAAkB;IACjC,gGAAgG;IAChG,EAAE,EAAE,MAAM,CAAA;IACV,iGAAiG;IACjG,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,aAAa,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAA;IACZ,+EAA+E;IAC/E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OA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,EAAE,KAAK,EAAE,KAAK,EAAE,QAAa,EAAE,IAAqB,EAAE,OAAY,EAAE,EAAE,mBAAmB,GAAG,gBAAgB,CAgCpJ;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,8FAA8F;AAC9F,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC,CAAA;AAKzF,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,kBAAkB,EAAE,CAAA;IAClD,4DAA4D;IAC5D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;IAC3C;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAAA;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,MAAM,EAAE,iBAAiB,CAAA;IACzB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,OAAa,EAAE,OAAc,EAAE,SAAa,EAAE,EAAE,sBAAsB,GAAG,eAAe,CAgFjI"}
@@ -28,38 +28,104 @@ export const FILE_TIER = { folder: 0, recent: 1, search: 2 };
28
28
  export const REFERENCE_CAPS = { messages: 4, files: 6 };
29
29
  const normalize = (text) => text.toLowerCase().replace(/\s+/g, ' ').trim();
30
30
  const isWordStart = (text, at) => at === 0 || !/[\p{L}\p{N}]/u.test(text[at - 1]);
31
+ /** The words of `text`: its runs of letters and digits, so `SUM-7.` is `sum`, `7`. */
32
+ const wordsOf = (text) => text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [];
31
33
  /**
32
- * How well `text` holds `query`: 4 the whole of it, 3 its start, 2 the start of
33
- * a word, 1 anywhere — or every word of the query at a word's start. 0 is no
34
- * match. Case and runs of spaces are ignored.
34
+ * Splits typed text as the relay does (buzz's `parse_word_start`): `"…"` is a
35
+ * phrase, a word opening with `-` is left out, anything else is a word, `or`
36
+ * and `key:value` included. A quote with no closing partner is ignored, so
37
+ * `"short summ` finds by word starts while it is typed.
35
38
  */
39
+ function searchTerms(query) {
40
+ const terms = [];
41
+ let rest = query;
42
+ while ((rest = rest.trimStart())) {
43
+ if (rest.startsWith('"')) {
44
+ const end = rest.indexOf('"', 1);
45
+ if (end > 0) {
46
+ const phrase = rest.slice(1, end).trim();
47
+ if (phrase)
48
+ terms.push({ kind: 'phrase', text: phrase });
49
+ rest = rest.slice(end + 1);
50
+ }
51
+ else
52
+ rest = rest.slice(1);
53
+ continue;
54
+ }
55
+ const end = rest.search(/[\s"]/u);
56
+ const token = end < 0 ? rest : rest.slice(0, end);
57
+ rest = end < 0 ? '' : rest.slice(end);
58
+ if (token.startsWith('-')) {
59
+ if (token.length > 1)
60
+ terms.push({ kind: 'not', text: token.slice(1) });
61
+ }
62
+ else
63
+ terms.push({ kind: 'word', text: token });
64
+ }
65
+ return terms;
66
+ }
67
+ /** Whether `words` holds every word of `typed` at the start of one of its words. */
68
+ const startsWords = (words, typed) => {
69
+ const wanted = wordsOf(typed);
70
+ return wanted.length > 0 && wanted.every((w) => words.some((word) => word.startsWith(w)));
71
+ };
72
+ /** Whether `words` holds the whole words of `phrase`, next to each other and in order. */
73
+ const holdsPhrase = (words, phrase) => {
74
+ const wanted = wordsOf(phrase);
75
+ if (wanted.length === 0)
76
+ return false;
77
+ for (let at = 0; at + wanted.length <= words.length; at++)
78
+ if (wanted.every((w, i) => words[at + i] === w))
79
+ return true;
80
+ return false;
81
+ };
82
+ /**
83
+ * How well `text` holds `query`, by the rule every Estiva search uses (SPEC
84
+ * §5.2): each typed word matches the start of a word, in any order; `"…"`
85
+ * matches those whole words next to each other; `-word` leaves out a text with
86
+ * a word starting that way. Punctuation at a typed word's ends is ignored, and
87
+ * so is case. A query with nothing to find but words left out matches nothing.
88
+ *
89
+ * Of the texts that match, a hit where every typed word is a whole word ranks
90
+ * above one where a word is only started (the record: "re" finds hundreds), and
91
+ * within each, by where it was found: the whole text, its start, what was typed
92
+ * as one run at the start of a word, every word somewhere. So 8 is the whole
93
+ * text, 7–5 whole words, 3–1 word starts, and 0 no match.
94
+ *
95
+ * Every text the rule finds, this finds, so a title the relay found by the rule
96
+ * is never dropped. A relay MAY find more (another may stem or fold accents;
97
+ * buzz caps a typed word at 4 pieces), and this drops what the rule does not.
98
+ */
99
+ // why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/search-matches-every-word-as-a-word-start.md
36
100
  export function referenceMatch(text, query) {
37
- const t = normalize(text);
38
- const q = normalize(query);
39
- if (!q)
101
+ const terms = searchTerms(query);
102
+ const wanted = wantedOf(terms);
103
+ if (wanted.length === 0)
104
+ return 0;
105
+ const words = wordsOf(text);
106
+ const holds = (t) => (t.kind === 'phrase' ? holdsPhrase(words, t.text) : startsWords(words, t.text));
107
+ if (!wanted.every(holds) || terms.some((t) => t.kind === 'not' && startsWords(words, t.text)))
40
108
  return 0;
109
+ const whole = wanted.every((w) => w.kind === 'phrase' || wordsOf(w.text).every((piece) => words.includes(piece))) ? 4 : 0;
110
+ const t = normalize(text);
111
+ const q = normalize(wanted.map((w) => w.text.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, '')).join(' '));
41
112
  if (t === q)
42
- return 4;
113
+ return 8;
43
114
  if (t.startsWith(q))
44
- return 3;
45
- let at = t.indexOf(q);
46
- if (at < 0) {
47
- const words = q.split(' ');
48
- if (words.length < 2)
49
- return 0;
50
- const starts = (w) => {
51
- for (let i = t.indexOf(w); i >= 0; i = t.indexOf(w, i + 1))
52
- if (isWordStart(t, i))
53
- return true;
54
- return false;
55
- };
56
- return words.every(starts) ? 1 : 0;
57
- }
58
- for (; at >= 0; at = t.indexOf(q, at + 1))
115
+ return whole + 3;
116
+ for (let at = t.indexOf(q); at >= 0; at = t.indexOf(q, at + 1))
59
117
  if (isWordStart(t, at))
60
- return 2;
61
- return 1;
118
+ return whole + 2;
119
+ return whole + 1;
62
120
  }
121
+ /** The terms that ask for something: words and phrases with a letter or digit, not words left out. */
122
+ const wantedOf = (terms) => terms.filter((t) => t.kind !== 'not' && wordsOf(t.text).length > 0);
123
+ /**
124
+ * Whether a longer query's answer is within `query`'s: it asks for a word and
125
+ * no quote is still open, since closing it can turn `"x -y` (y left out) into
126
+ * `"x -y z"` (a phrase that needs y).
127
+ */
128
+ const narrowsBy = (query) => wantedOf(searchTerms(query)).length > 0 && (query.split('"').length - 1) % 2 === 0;
63
129
  /**
64
130
  * How well an issue's ref (`CON-33`) holds `query`: only from its start, and
65
131
  * only once what was typed has a digit or a hyphen (Miky, 2026-10-05) — so
@@ -69,7 +135,8 @@ export function referenceMatch(text, query) {
69
135
  */
70
136
  export function refMatch(ref, query) {
71
137
  const score = ref && /[\d-]/.test(query) ? referenceMatch(ref, query) : 0;
72
- return score >= 3 ? score : 0;
138
+ // 8, 7 and 3: the whole ref or its start.
139
+ return score === 8 || score % 4 === 3 ? score : 0;
73
140
  }
74
141
  /** Keeps each id once, at its closest tier. */
75
142
  function closest(candidates) {
@@ -146,7 +213,7 @@ const timers = globalThis;
146
213
  * keeps its answer, which is still true of that query.
147
214
  *
148
215
  * Once a query found nothing, adding whole words to it is not asked (08d7f243):
149
- * relay search is every word, the last as a prefix, so `see [the fig` cannot
216
+ * relay search needs every word to match (SPEC §5.2), so `see [the fig` cannot
150
217
  * find what `the` did not, and a sentence typed after an unmatched `[` would
151
218
  * otherwise spend the rate limit on every longer version of itself. A failure
152
219
  * is not "nothing", so it never stops a longer query.
@@ -157,8 +224,8 @@ export function referenceSearch({ search, delayMs = 200, retryMs = 5000, minLeng
157
224
  const foundNothing = (query) => {
158
225
  for (let at = query.indexOf(' '); at >= 0; at = query.indexOf(' ', at + 1)) {
159
226
  const prefix = query.slice(0, at);
160
- // `--` searches no word at all, so its empty answer says nothing of `-- budget`.
161
- if (!/[\p{L}\p{N}]/u.test(prefix))
227
+ // `--` or `-draft` asks for no word at all, so its empty answer says nothing of `-draft budget`.
228
+ if (!narrowsBy(prefix))
162
229
  continue;
163
230
  const shorter = answered.get(prefix);
164
231
  if (shorter && shorter.length === 0 && !failures.has(shorter))
@@ -1 +1 @@
1
- {"version":3,"file":"references.js","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAsClD,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAW,CAAA;AAE3D,+EAA+E;AAC/E,MAAM,CAAC,MAAM,SAAS,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAW,CAAA;AAErE,mGAAmG;AACnG,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAW,CAAA;AAsBhE,MAAM,SAAS,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;AAElF,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAE,CAAC,CAAA;AAElG;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,KAAa;IACxD,MAAM,CAAC,GAAG,SAAS,CAAC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HANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/conversation",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "The conversation rules of the Estiva SPEC (§6.2–§6.8, §11): comment and mention strengths, threading, the edit, reaction and attachment folds, NIP-22 comment and reply builders, drafts, NIP-RS read state, membership and unread. A convenience an app adopts, never a requirement.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/builders.ts CHANGED
@@ -76,16 +76,41 @@ export interface CommentRef {
76
76
  * then carries no `p`, because a wrong one notifies the wrong person.
77
77
  */
78
78
  author?: string
79
+ /**
80
+ * Where on its object the comment is: its own `block` and `quote` tags
81
+ * ({@link placeOf}). The reply copies them, so its thread keeps its place
82
+ * once the comment is deleted (§13.6). Absent when the comment is on the
83
+ * whole object or outside the read.
84
+ */
85
+ place?: readonly NostrTag[]
86
+ }
87
+
88
+ /** The tags that say where on its object a comment is (§13.6): `block` and `quote`. */
89
+ const PLACE_TAGS = new Set(['block', 'quote'])
90
+
91
+ /**
92
+ * A comment's place, as its event carries it: its `block` and `quote` tags,
93
+ * verbatim, for {@link CommentRef.place}. Empty when it is on the whole object.
94
+ *
95
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-reply-on-a-page-keeps-its-threads-place.md
96
+ */
97
+ export function placeOf(comment: { tags: readonly NostrTag[] }): NostrTag[] {
98
+ // One of each, the first, as every reader reads it: a stranger's extra tags are not copied under the replier's key.
99
+ return [...PLACE_TAGS].map((name) => comment.tags.find((t) => t[0] === name)).filter((t): t is NostrTag => !!t)
79
100
  }
80
101
 
81
102
  /**
82
103
  * A reply to a comment — §6.4 *Replies*, C16. Tag order: `A`, `K`, `P`, `e`,
83
- * `k`, `[p]`, `h`, `ts`, `[imeta…]`, then `tags`.
104
+ * `k`, `[p]`, `[block, quote]`, `h`, `ts`, `[imeta…]`, then `tags`.
84
105
  *
85
106
  * **Flat, one level deep**: `e` names the thread's top-level comment, never
86
107
  * another reply. **No lowercase `a`** for the object: NIP-22 reads it as the
87
108
  * parent, so it would claim the reply is itself a top-level comment. The reply
88
- * is found by `#e` on the comment.
109
+ * is found by `#e` on the comment. **Its comment's place, copied** (§13.6):
110
+ * the `block` and `quote` tags of `comment.place` as written, and no other
111
+ * tag from it.
112
+ *
113
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-reply-on-a-page-keeps-its-threads-place.md
89
114
  */
90
115
  export function buildReply(
91
116
  pubkey: string,
@@ -94,7 +119,7 @@ export function buildReply(
94
119
  ): UnsignedEvent {
95
120
  assertFolder(args.folder)
96
121
  const [kind, author] = kindAndAuthor(args.comment.anchor)
97
- const earned = (args.tags ?? []).filter((t) => !(t[0] === 'a' && t[1] === args.comment.anchor))
122
+ const earned = (args.tags ?? []).filter((t) => !(t[0] === 'a' && t[1] === args.comment.anchor) && !PLACE_TAGS.has(t[0]))
98
123
  return {
99
124
  pubkey,
100
125
  created_at: toNostrSeconds(createdAtMs),
@@ -106,6 +131,7 @@ export function buildReply(
106
131
  ['e', args.comment.id],
107
132
  ['k', String(KIND_COMMENT)],
108
133
  ...(args.comment.author ? [['p', args.comment.author]] : []),
134
+ ...(args.comment.place ? placeOf({ tags: args.comment.place }).map((t) => [...t]) : []),
109
135
  ['h', args.folder],
110
136
  ['ts', String(Math.floor(createdAtMs))],
111
137
  ...(args.files ?? []).map(imetaTag),
package/src/edits.ts CHANGED
@@ -146,7 +146,7 @@ export function foldAttachments(events: readonly SignedEvent[]): Record<string,
146
146
  * edit removes a card. Which of these the body still names is
147
147
  * `cardsIn`'s question, asked of the folded body. Messages with none are absent.
148
148
  *
149
- * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/where-a-link-sits-and-which-file-gets-the-card.md
149
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md
150
150
  */
151
151
  export function foldEmbeds(events: readonly SignedEvent[]): Record<string, Embed[]> {
152
152
  const out: Record<string, Embed[]> = {}
package/src/index.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * apps: it imports no app's data layer, opens no socket, and takes every
13
13
  * environment touch — the relay read, the clock, storage — as a parameter.
14
14
  */
15
- export const CONVERSATION_VERSION = '0.13.0'
15
+ export const CONVERSATION_VERSION = '0.15.0'
16
16
 
17
17
  export {
18
18
  KIND_MESSAGE,
@@ -62,7 +62,7 @@ export {
62
62
 
63
63
  export { decorationsOf, type Decoration, type Decorations, type Resolution, type QueryFn } from './decorations.js'
64
64
 
65
- export { buildComment, buildReply, offersEditAndDelete, type CommentRef } from './builders.js'
65
+ export { buildComment, buildReply, offersEditAndDelete, placeOf, type CommentRef } from './builders.js'
66
66
 
67
67
  export { eventsNamedInBody, mentionText, messageReference, quoteTagsFor, URGENT_TAG, urgentTagsFor } from './compose.js'
68
68
 
package/src/references.ts CHANGED
@@ -90,31 +90,102 @@ const normalize = (text: string) => text.toLowerCase().replace(/\s+/g, ' ').trim
90
90
 
91
91
  const isWordStart = (text: string, at: number) => at === 0 || !/[\p{L}\p{N}]/u.test(text[at - 1]!)
92
92
 
93
+ /** The words of `text`: its runs of letters and digits, so `SUM-7.` is `sum`, `7`. */
94
+ const wordsOf = (text: string): string[] => text.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? []
95
+
96
+ /** One piece of a typed query: a word, `"a phrase"`, or `-a word` left out. */
97
+ interface SearchTerm {
98
+ kind: 'word' | 'phrase' | 'not'
99
+ text: string
100
+ }
101
+
93
102
  /**
94
- * How well `text` holds `query`: 4 the whole of it, 3 its start, 2 the start of
95
- * a word, 1 anywhere — or every word of the query at a word's start. 0 is no
96
- * match. Case and runs of spaces are ignored.
103
+ * Splits typed text as the relay does (buzz's `parse_word_start`): `"…"` is a
104
+ * phrase, a word opening with `-` is left out, anything else is a word, `or`
105
+ * and `key:value` included. A quote with no closing partner is ignored, so
106
+ * `"short summ` finds by word starts while it is typed.
97
107
  */
98
- export function referenceMatch(text: string, query: string): number {
99
- const t = normalize(text)
100
- const q = normalize(query)
101
- if (!q) return 0
102
- if (t === q) return 4
103
- if (t.startsWith(q)) return 3
104
- let at = t.indexOf(q)
105
- if (at < 0) {
106
- const words = q.split(' ')
107
- if (words.length < 2) return 0
108
- const starts = (w: string) => {
109
- for (let i = t.indexOf(w); i >= 0; i = t.indexOf(w, i + 1)) if (isWordStart(t, i)) return true
110
- return false
108
+ function searchTerms(query: string): SearchTerm[] {
109
+ const terms: SearchTerm[] = []
110
+ let rest = query
111
+ while ((rest = rest.trimStart())) {
112
+ if (rest.startsWith('"')) {
113
+ const end = rest.indexOf('"', 1)
114
+ if (end > 0) {
115
+ const phrase = rest.slice(1, end).trim()
116
+ if (phrase) terms.push({ kind: 'phrase', text: phrase })
117
+ rest = rest.slice(end + 1)
118
+ } else rest = rest.slice(1)
119
+ continue
111
120
  }
112
- return words.every(starts) ? 1 : 0
121
+ const end = rest.search(/[\s"]/u)
122
+ const token = end < 0 ? rest : rest.slice(0, end)
123
+ rest = end < 0 ? '' : rest.slice(end)
124
+ if (token.startsWith('-')) {
125
+ if (token.length > 1) terms.push({ kind: 'not', text: token.slice(1) })
126
+ } else terms.push({ kind: 'word', text: token })
113
127
  }
114
- for (; at >= 0; at = t.indexOf(q, at + 1)) if (isWordStart(t, at)) return 2
115
- return 1
128
+ return terms
116
129
  }
117
130
 
131
+ /** Whether `words` holds every word of `typed` at the start of one of its words. */
132
+ const startsWords = (words: readonly string[], typed: string) => {
133
+ const wanted = wordsOf(typed)
134
+ return wanted.length > 0 && wanted.every((w) => words.some((word) => word.startsWith(w)))
135
+ }
136
+
137
+ /** Whether `words` holds the whole words of `phrase`, next to each other and in order. */
138
+ const holdsPhrase = (words: readonly string[], phrase: string) => {
139
+ const wanted = wordsOf(phrase)
140
+ if (wanted.length === 0) return false
141
+ for (let at = 0; at + wanted.length <= words.length; at++) if (wanted.every((w, i) => words[at + i] === w)) return true
142
+ return false
143
+ }
144
+
145
+ /**
146
+ * How well `text` holds `query`, by the rule every Estiva search uses (SPEC
147
+ * §5.2): each typed word matches the start of a word, in any order; `"…"`
148
+ * matches those whole words next to each other; `-word` leaves out a text with
149
+ * a word starting that way. Punctuation at a typed word's ends is ignored, and
150
+ * so is case. A query with nothing to find but words left out matches nothing.
151
+ *
152
+ * Of the texts that match, a hit where every typed word is a whole word ranks
153
+ * above one where a word is only started (the record: "re" finds hundreds), and
154
+ * within each, by where it was found: the whole text, its start, what was typed
155
+ * as one run at the start of a word, every word somewhere. So 8 is the whole
156
+ * text, 7–5 whole words, 3–1 word starts, and 0 no match.
157
+ *
158
+ * Every text the rule finds, this finds, so a title the relay found by the rule
159
+ * is never dropped. A relay MAY find more (another may stem or fold accents;
160
+ * buzz caps a typed word at 4 pieces), and this drops what the rule does not.
161
+ */
162
+ // why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/search-matches-every-word-as-a-word-start.md
163
+ export function referenceMatch(text: string, query: string): number {
164
+ const terms = searchTerms(query)
165
+ const wanted = wantedOf(terms)
166
+ if (wanted.length === 0) return 0
167
+ const words = wordsOf(text)
168
+ const holds = (t: SearchTerm) => (t.kind === 'phrase' ? holdsPhrase(words, t.text) : startsWords(words, t.text))
169
+ if (!wanted.every(holds) || terms.some((t) => t.kind === 'not' && startsWords(words, t.text))) return 0
170
+ const whole = wanted.every((w) => w.kind === 'phrase' || wordsOf(w.text).every((piece) => words.includes(piece))) ? 4 : 0
171
+ const t = normalize(text)
172
+ const q = normalize(wanted.map((w) => w.text.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, '')).join(' '))
173
+ if (t === q) return 8
174
+ if (t.startsWith(q)) return whole + 3
175
+ for (let at = t.indexOf(q); at >= 0; at = t.indexOf(q, at + 1)) if (isWordStart(t, at)) return whole + 2
176
+ return whole + 1
177
+ }
178
+
179
+ /** The terms that ask for something: words and phrases with a letter or digit, not words left out. */
180
+ const wantedOf = (terms: readonly SearchTerm[]) => terms.filter((t) => t.kind !== 'not' && wordsOf(t.text).length > 0)
181
+
182
+ /**
183
+ * Whether a longer query's answer is within `query`'s: it asks for a word and
184
+ * no quote is still open, since closing it can turn `"x -y` (y left out) into
185
+ * `"x -y z"` (a phrase that needs y).
186
+ */
187
+ const narrowsBy = (query: string) => wantedOf(searchTerms(query)).length > 0 && (query.split('"').length - 1) % 2 === 0
188
+
118
189
  /**
119
190
  * How well an issue's ref (`CON-33`) holds `query`: only from its start, and
120
191
  * only once what was typed has a digit or a hyphen (Miky, 2026-10-05) — so
@@ -124,7 +195,8 @@ export function referenceMatch(text: string, query: string): number {
124
195
  */
125
196
  export function refMatch(ref: string | undefined, query: string): number {
126
197
  const score = ref && /[\d-]/.test(query) ? referenceMatch(ref, query) : 0
127
- return score >= 3 ? score : 0
198
+ // 8, 7 and 3: the whole ref or its start.
199
+ return score === 8 || score % 4 === 3 ? score : 0
128
200
  }
129
201
 
130
202
  /** Keeps each id once, at its closest tier. */
@@ -218,9 +290,8 @@ export interface ReferenceSearch {
218
290
 
219
291
  export interface ReferenceSearchOptions {
220
292
  /**
221
- * Must find no more for `q + " words"` than for `q` (every word, the last as
222
- * a prefix: buzz's prefix mode), since a longer query after an empty answer
223
- * is not asked.
293
+ * Must find no more for `q + " words"` than for `q` (every word must match,
294
+ * SPEC §5.2), since a longer query after an empty answer is not asked.
224
295
  */
225
296
  search: ReferenceSearchFn
226
297
  /** The pause after a keystroke before asking. Default 200ms. */
@@ -247,7 +318,7 @@ export interface ReferenceSearchOptions {
247
318
  * keeps its answer, which is still true of that query.
248
319
  *
249
320
  * Once a query found nothing, adding whole words to it is not asked (08d7f243):
250
- * relay search is every word, the last as a prefix, so `see [the fig` cannot
321
+ * relay search needs every word to match (SPEC §5.2), so `see [the fig` cannot
251
322
  * find what `the` did not, and a sentence typed after an unmatched `[` would
252
323
  * otherwise spend the rate limit on every longer version of itself. A failure
253
324
  * is not "nothing", so it never stops a longer query.
@@ -258,8 +329,8 @@ export function referenceSearch({ search, delayMs = 200, retryMs = 5000, minLeng
258
329
  const foundNothing = (query: string) => {
259
330
  for (let at = query.indexOf(' '); at >= 0; at = query.indexOf(' ', at + 1)) {
260
331
  const prefix = query.slice(0, at)
261
- // `--` searches no word at all, so its empty answer says nothing of `-- budget`.
262
- if (!/[\p{L}\p{N}]/u.test(prefix)) continue
332
+ // `--` or `-draft` asks for no word at all, so its empty answer says nothing of `-draft budget`.
333
+ if (!narrowsBy(prefix)) continue
263
334
  const shorter = answered.get(prefix)
264
335
  if (shorter && shorter.length === 0 && !failures.has(shorter)) return true
265
336
  }