@yaks/topic 0.0.0-stage → 0.2.36

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.
Files changed (62) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +256 -2
  3. package/_dist/context.d.ts +74 -0
  4. package/_dist/context.d.ts.map +1 -0
  5. package/_dist/graph.d.ts +5 -0
  6. package/_dist/graph.d.ts.map +1 -0
  7. package/_dist/mod.d.ts +33 -0
  8. package/_dist/mod.d.ts.map +1 -0
  9. package/_dist/share.d.ts +61 -0
  10. package/_dist/share.d.ts.map +1 -0
  11. package/_dist/shelves.d.ts +24 -0
  12. package/_dist/shelves.d.ts.map +1 -0
  13. package/_dist/tools.d.ts +5 -0
  14. package/_dist/tools.d.ts.map +1 -0
  15. package/_dist/topic.d.ts +50 -0
  16. package/_dist/topic.d.ts.map +1 -0
  17. package/_dist/views.d.ts +23 -0
  18. package/_dist/views.d.ts.map +1 -0
  19. package/_dist/vocab.d.ts +6 -0
  20. package/_dist/vocab.d.ts.map +1 -0
  21. package/catalogue.js +155 -0
  22. package/catalogue.js.map +1 -0
  23. package/catalogue.ts +218 -0
  24. package/context.js +289 -0
  25. package/context.js.map +1 -0
  26. package/context.ts +318 -0
  27. package/deno.json +1 -0
  28. package/graph.js +32 -0
  29. package/graph.js.map +1 -0
  30. package/graph.ts +26 -0
  31. package/inspect.js +48 -0
  32. package/inspect.js.map +1 -0
  33. package/inspect.ts +25 -0
  34. package/mod.js +33 -0
  35. package/mod.js.map +1 -0
  36. package/mod.ts +56 -0
  37. package/package.json +50 -4
  38. package/page.js +247 -0
  39. package/page.js.map +1 -0
  40. package/page.ts +297 -0
  41. package/share.js +104 -0
  42. package/share.js.map +1 -0
  43. package/share.ts +115 -0
  44. package/shelves.js +99 -0
  45. package/shelves.js.map +1 -0
  46. package/shelves.ts +93 -0
  47. package/tools.js +114 -0
  48. package/tools.js.map +1 -0
  49. package/tools.ts +122 -0
  50. package/topic.js +97 -0
  51. package/topic.js.map +1 -0
  52. package/topic.ts +128 -0
  53. package/tree.js +77 -0
  54. package/tree.js.map +1 -0
  55. package/tree.ts +93 -0
  56. package/views.js +30 -0
  57. package/views.js.map +1 -0
  58. package/views.ts +26 -0
  59. package/vocab.js +16 -0
  60. package/vocab.js.map +1 -0
  61. package/vocab.json +186 -0
  62. package/vocab.ts +17 -0
package/tree.ts ADDED
@@ -0,0 +1,93 @@
1
+ /**
2
+ * A topic's tree: everything it holds (`contains`), and everything each
3
+ * subtopic holds, all the way down, nested. Each level asks for its own
4
+ * children as it draws, so the tree reads only what is open on the screen.
5
+ * Only a topic is walked into: a project or a package a topic holds is a leaf
6
+ * here, since what it contains is its own tree. A topic met again on its own
7
+ * path is drawn and not walked, so a cycle ends; past `DEPTH` levels the
8
+ * branch links to its own tree.
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, type JSX } from 'react'
14
+ import * as ui from '@yaks/ui'
15
+ import {
16
+ type Answer,
17
+ type Bundle,
18
+ type Io,
19
+ mention,
20
+ type Props,
21
+ } from '@yaks/inspect'
22
+ import { EDGES } from './page.js'
23
+ import { title, TOPIC } from './topic.js'
24
+
25
+ /** How many levels a tree draws before a branch links to its own tree. */
26
+ export let DEPTH = 8
27
+
28
+ let rows = (a?: Answer): Bundle[] => a?.rows ?? []
29
+ let to = (b: Bundle) => String((b.edge as { to?: unknown })?.to ?? '')
30
+
31
+ /** What a topic holds, each drawn by its own renderer, and below each
32
+ * subtopic what it holds. */
33
+ let Twig = (
34
+ { eid, io, path }: { eid: string; io: Io; path: string[] },
35
+ ): JSX.Element | null => {
36
+ let got = io.ask({
37
+ edges: `.contains&.edge.from=${eid}&?edge&.order=edge.ord&.limit=${EDGES}`,
38
+ }).edges
39
+ let ids = [...new Set(rows(got).map(to).filter(Boolean))]
40
+ let ends = io.ask(
41
+ ids.length ? { ends: `.entity.eid=${ids.join(',')}&*` } : {},
42
+ ).ends
43
+ let held = new Map(rows(ends).map((b) => [b.entity.eid, b]))
44
+ let root = path.length == 1
45
+ if (got?.error) return h(ui.Rows.More, {}, got.error)
46
+ if (!got?.ready && !ids.length) return root ? h(ui.Loading, {}) : null
47
+ if (!ids.length) {
48
+ return root ? h(ui.Rows.More, {}, 'it holds nothing yet') : null
49
+ }
50
+ return h(
51
+ ui.Rows,
52
+ { mod: root ? undefined : 'nested', role: 'list' },
53
+ ids.map((id) => {
54
+ let b = held.get(id)
55
+ let walk = b?.[TOPIC] && !path.includes(id)
56
+ return h(
57
+ ui.Rows.Item,
58
+ { key: id, role: 'listitem', 'data-held': id },
59
+ b
60
+ ? io.show(b, 'Topic.List.Tile', {})
61
+ : ends?.ready
62
+ ? h(ui.Rows.More, {}, mention(io, id), ' is gone')
63
+ : h(ui.Loading, {}),
64
+ !walk
65
+ ? null
66
+ : path.length < DEPTH
67
+ ? h(Twig, { eid: id, io, path: [...path, id] })
68
+ : h(ui.Rows.More, {}, h('a', { href: io.link(id) }, 'more below')),
69
+ )
70
+ }),
71
+ )
72
+ }
73
+
74
+ /** A topic's tree. */
75
+ export let TopicTree = ({ e, io }: Props): JSX.Element => {
76
+ let eid = e.entity.eid
77
+ let cover = String((e.doc as { body?: unknown })?.body ?? '')
78
+ return h(
79
+ 'div',
80
+ { 'data-tree': eid },
81
+ h(
82
+ ui.Head,
83
+ {},
84
+ h(ui.Head.Title, {}, title(e), h(ui.Head.Kind, {}, 'topic')),
85
+ cover ? h(ui.Head.Sub, {}, cover) : null,
86
+ ),
87
+ h(
88
+ ui.Section,
89
+ { 'data-section': 'Tree' },
90
+ h(Twig, { eid, io, path: [eid] }),
91
+ ),
92
+ )
93
+ }
package/views.js ADDED
@@ -0,0 +1,30 @@
1
+ // The `@yaks/topic/views` facet: the shelves of topics, a topic's page and
2
+ // tree, loaded only by an interface that draws them (./inspect.ts); the tabs a
3
+ // topic opens on; and the page the sidebar offers, every topic on its shelf.
4
+ // @ts-types="@yaks/ui/lucide"
5
+ import Library from "lucide/dist/esm/icons/library-big.mjs";
6
+ /** The shelves, the page, the tree and a topic's tile, as the inspector
7
+ * draws them. */ export let inspectViews = ()=>import("./inspect.js").then((m)=>m.inspectViews);
8
+ /** The tabs a topic wears, its page first, so it opens on its page. */ export let tabs = [
9
+ {
10
+ view: 'Topic',
11
+ icon: 'book-open'
12
+ },
13
+ {
14
+ view: 'Tree',
15
+ icon: 'workflow'
16
+ }
17
+ ];
18
+ /** The page the sidebar offers: every topic on its shelf, and the field that
19
+ * finds one. */ export let destinations = [
20
+ {
21
+ key: 'topics',
22
+ name: 'Topics',
23
+ icon: 'library-big',
24
+ view: 'Topics.Page'
25
+ }
26
+ ];
27
+ /** The glyph it wears there. */ export let icons = {
28
+ 'library-big': Library
29
+ };
30
+ //# sourceMappingURL=views.js.map
package/views.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.js","sources":["./views.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,6EAA6E;AAE7E,8BAA8B;AAC9B,OAAO,qDAA+D;AAEtE;eACe,GACf,OAAO,IAAI,eAAe,IACxB,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC,IAAM,EAAE,YAAY,EAAC;AAEpD,qEAAqE,GACrE,OAAO,IAAI,OAAO;EAChB;IAAE,MAAM;IAAS,MAAM;EAAY;EACnC;IAAE,MAAM;IAAQ,MAAM;EAAW;CAClC,CAAA;AAED;cACc,GACd,OAAO,IAAI,eAAe;EACxB;IAAE,KAAK;IAAU,MAAM;IAAU,MAAM;IAAe,MAAM;EAAc;CAC3E,CAAA;AAED,8BAA8B,GAC9B,OAAO,IAAI,QAAQ;EAAE,eAAe;AAAQ,EAAC"}
package/views.ts ADDED
@@ -0,0 +1,26 @@
1
+ // The `@yaks/topic/views` facet: the shelves of topics, a topic's page and
2
+ // tree, loaded only by an interface that draws them (./inspect.ts); the tabs a
3
+ // topic opens on; and the page the sidebar offers, every topic on its shelf.
4
+ import type { View } from 'jsr:@yaks/inspect@0.2.36'
5
+ // @ts-types="@yaks/ui/lucide"
6
+ import Library from 'lucide/dist/esm/icons/library-big.mjs'
7
+
8
+ /** The shelves, the page, the tree and a topic's tile, as the inspector
9
+ * draws them. */
10
+ export let inspectViews = (): Promise<View[]> =>
11
+ import('./inspect.js').then((m) => m.inspectViews)
12
+
13
+ /** The tabs a topic wears, its page first, so it opens on its page. */
14
+ export let tabs = [
15
+ { view: 'Topic', icon: 'book-open' },
16
+ { view: 'Tree', icon: 'workflow' },
17
+ ]
18
+
19
+ /** The page the sidebar offers: every topic on its shelf, and the field that
20
+ * finds one. */
21
+ export let destinations = [
22
+ { key: 'topics', name: 'Topics', icon: 'library-big', view: 'Topics.Page' },
23
+ ]
24
+
25
+ /** The glyph it wears there. */
26
+ export let icons = { 'library-big': Library }
package/vocab.js ADDED
@@ -0,0 +1,16 @@
1
+ // The component and tool declarations, and nothing else: the module a server or
2
+ // a browser page imports at `@yaks/topic/vocab`. It reaches no storage, no SQL
3
+ // and no runtime, so a browser tab loading this vocabulary loads nothing else.
4
+ import doc from './vocab.json' with {
5
+ type: 'json'
6
+ };
7
+ import manifest from './package.json' with {
8
+ type: 'json'
9
+ };
10
+ /** The topic vocabulary, in the form `loadVocab` accepts. */ export let topicDoc = doc;
11
+ /** What this package is: its manifest's description, the one place it is
12
+ * written, which a host stamps on each document here. */ export let description = manifest.description;
13
+ /** Every document this plugin declares. */ export let docs = [
14
+ topicDoc
15
+ ];
16
+ //# sourceMappingURL=vocab.js.map
package/vocab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAG/E,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,2DAA2D,GAC3D,OAAO,IAAI,WAAqB,IAAe;AAE/C;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAS,CAAA"}
package/vocab.json ADDED
@@ -0,0 +1,186 @@
1
+ {
2
+ "$id": "urn:uuid:2ace10d9-9ade-461c-9827-dec055543084",
3
+ "$vocabulary": {
4
+ "https://yak.sh/vocab/core": true,
5
+ "https://yak.sh/vocab/id": true,
6
+ "https://yak.sh/vocab/kernel": true,
7
+ "https://yak.sh/vocab/edge": true
8
+ },
9
+ "title": "topic",
10
+ "$defs": {
11
+ "topic": {
12
+ "$id": "urn:uuid:bfc3626f-5aa4-4d42-960d-fda4e303b7d7",
13
+ "component": true,
14
+ "type": "object",
15
+ "description": "a subject in the knowledge graph. Any entity may be one by wearing this: a subject of its own is topic + doc + content, and a project is its own topic, so what is known about it sits under it. What a topic belongs to is whatever contains it: one about a project sits under the project, and one about the world under none. Its doc is the cover: the title, and a line or two saying what belongs under it. Its content.body is the contents: what is understood about it, written as one document citing its sources. Its edges say what it holds (contains: a subtopic, or anything else, such as a memory, a design, a skill, a package or somebody's words), what to understand first (requires), what it reads or references, and what it cites; beliefs are about it (belief.about). A session opened on it (session.topic) starts from its tree, compiled (topic_read)",
16
+ "properties": {
17
+ "name": {
18
+ "$id": "urn:uuid:814235ef-b657-4be7-8779-2fa23997d50a",
19
+ "type": "string",
20
+ "unique": true,
21
+ "description": "the title in lowercase, its spaces single; no two topics share one, so a name said again finds the topic that has it. A name, not an identity: it changes with the title, and the entity keeps its eid"
22
+ }
23
+ }
24
+ },
25
+ "attended": {
26
+ "$id": "urn:uuid:8ef6ae6c-92d6-4cb2-9ae0-59fcaf47997d",
27
+ "component": true,
28
+ "type": "object",
29
+ "description": "on a topic: the part of each plan's week that work for it may use, which is the work of the session opened on it (session.topic) and of every session that one started. A subtopic's share is part of its parent's, so a topic keeps its share less the shares of the topics below it. A person sets it, and a topic's session divides its own among subtopics; nothing else changes one. How much is used is read from the day tallies (spend_show) and never stored, and it refuses nothing: a session reads it to pace itself",
30
+ "properties": {
31
+ "share": {
32
+ "$id": "urn:uuid:f2faf83f-be28-416f-ae09-da9c5c187c42",
33
+ "type": "number",
34
+ "minimum": 0,
35
+ "maximum": 1,
36
+ "description": "the share, 0 to 1: 0.1 is a tenth of each plan's week"
37
+ }
38
+ }
39
+ },
40
+ "session": {
41
+ "component": true,
42
+ "extends": true,
43
+ "type": "object",
44
+ "properties": {
45
+ "topic": {
46
+ "$id": "urn:uuid:5af8b971-6faf-4f4e-b1dc-11767abed922",
47
+ "type": "string",
48
+ "ref": "topic",
49
+ "death": "keep",
50
+ "description": "the topic it was opened on: the topic tree compiled from it (topic_read) opens its context, after its persona's"
51
+ }
52
+ }
53
+ },
54
+ "topic_read": {
55
+ "tool": true,
56
+ "page": true,
57
+ "noun": "topic",
58
+ "verb": "read",
59
+ "title": "Read a topic as a session's context",
60
+ "description": "Compile session context as content.body: ancestors, cover, contents with $was, held entities, subtopic outline, prerequisites, related entities and sources. Long bodies are shortened with ids to read the rest.",
61
+ "input": {
62
+ "topic": {
63
+ "type": "string",
64
+ "ref": "topic",
65
+ "description": "Topic id (Q-12) or eid."
66
+ }
67
+ },
68
+ "required": [
69
+ "topic"
70
+ ],
71
+ "readOnly": true,
72
+ "positional": [
73
+ "topic"
74
+ ]
75
+ },
76
+ "topic_new": {
77
+ "tool": true,
78
+ "destructive": false,
79
+ "noun": "topic",
80
+ "verb": "new",
81
+ "title": "Make a topic",
82
+ "description": "Create a topic with a short cover; overlapping names return the existing topic in a refusal. Projects are topics; topic_add nests subtopics. Returns applied bundles.",
83
+ "input": {
84
+ "name": {
85
+ "type": "string",
86
+ "description": "Topic name, in plain words."
87
+ },
88
+ "body": {
89
+ "type": "string",
90
+ "description": "One or two lines defining its scope."
91
+ }
92
+ },
93
+ "required": [
94
+ "name",
95
+ "body"
96
+ ],
97
+ "positional": [
98
+ "name"
99
+ ]
100
+ },
101
+ "topic_find": {
102
+ "tool": true,
103
+ "noun": "topic",
104
+ "verb": "find",
105
+ "title": "Find topics",
106
+ "description": "Find whole topics by name/title/cover stems or prefixes. near ranks meaning with vectors; otherwise name order. Use before topic_new/topic_add to reuse topics.",
107
+ "input": {
108
+ "said": {
109
+ "type": "string",
110
+ "description": "Name, title or cover words; stems/prefixes match."
111
+ },
112
+ "near": {
113
+ "type": "string",
114
+ "ref": "entity",
115
+ "description": "Entity id/name to rank by meaning."
116
+ },
117
+ "limit": {
118
+ "type": "number",
119
+ "description": "Maximum results (default 12).",
120
+ "short": "n"
121
+ }
122
+ },
123
+ "readOnly": true,
124
+ "positional": [
125
+ "said"
126
+ ]
127
+ },
128
+ "topic_add": {
129
+ "tool": true,
130
+ "destructive": false,
131
+ "idempotent": true,
132
+ "noun": "topic",
133
+ "verb": "add",
134
+ "title": "Add to a topic",
135
+ "description": "Add contains edges from a topic/project to entities; drop removes them. Idempotent; entities may have several topics. Returns applied bundles.",
136
+ "input": {
137
+ "topic": {
138
+ "type": "string",
139
+ "ref": "topic",
140
+ "description": "Topic or project id/title."
141
+ },
142
+ "ids": {
143
+ "type": "array",
144
+ "items": {
145
+ "type": "string"
146
+ },
147
+ "ref": "entity",
148
+ "description": "Entity ids to include."
149
+ },
150
+ "drop": {
151
+ "type": "boolean",
152
+ "description": "Remove instead of adding."
153
+ }
154
+ },
155
+ "required": [
156
+ "topic",
157
+ "ids"
158
+ ],
159
+ "positional": [
160
+ "topic",
161
+ "ids..."
162
+ ]
163
+ }
164
+ },
165
+ "kinds": {
166
+ "topic": {
167
+ "$id": "urn:uuid:bfc3626f-5aa4-4d42-960d-fda4e303b7d7",
168
+ "description": "a subject in the knowledge graph. Any entity may be one by wearing this: a subject of its own is topic + doc + content, and a project is its own topic, so what is known about it sits under it. What a topic belongs to is whatever contains it: one about a project sits under the project, and one about the world under none. Its doc is the cover: the title, and a line or two saying what belongs under it. Its content.body is the contents: what is understood about it, written as one document citing its sources. Its edges say what it holds (contains: a subtopic, or anything else, such as a memory, a design, a skill, a package or somebody's words), what to understand first (requires), what it reads or references, and what it cites; beliefs are about it (belief.about). A session opened on it (session.topic) starts from its tree, compiled (topic_read)",
169
+ "with": {
170
+ "doc": true
171
+ },
172
+ "prefix": "Q",
173
+ "examples": [
174
+ {
175
+ "topic": {
176
+ "name": "search"
177
+ },
178
+ "doc": {
179
+ "title": "Search",
180
+ "body": "How full-text search and recall rank"
181
+ }
182
+ }
183
+ ]
184
+ }
185
+ }
186
+ }
package/vocab.ts ADDED
@@ -0,0 +1,17 @@
1
+ // The component and tool declarations, and nothing else: the module a server or
2
+ // a browser page imports at `@yaks/topic/vocab`. It reaches no storage, no SQL
3
+ // and no runtime, so a browser tab loading this vocabulary loads nothing else.
4
+
5
+ import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
6
+ import doc from './vocab.json' with { type: 'json' }
7
+ import manifest from './package.json' with { type: 'json' }
8
+
9
+ /** The topic vocabulary, in the form `loadVocab` accepts. */
10
+ export let topicDoc: VocabDoc = doc as VocabDoc
11
+
12
+ /** What this package is: its manifest's description, the one place it is
13
+ * written, which a host stamps on each document here. */
14
+ export let description: string = manifest.description
15
+
16
+ /** Every document this plugin declares. */
17
+ export let docs: VocabDoc[] = [topicDoc]