@yaks/kernel 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 (65) hide show
  1. package/Comments.tsx +300 -0
  2. package/LICENSE +202 -0
  3. package/README.md +332 -2
  4. package/_dist/cites.d.ts +18 -0
  5. package/_dist/cites.d.ts.map +1 -0
  6. package/_dist/comment-host.d.ts +30 -0
  7. package/_dist/comment-host.d.ts.map +1 -0
  8. package/_dist/comments.d.ts +20 -0
  9. package/_dist/comments.d.ts.map +1 -0
  10. package/_dist/graph.d.ts +3 -0
  11. package/_dist/graph.d.ts.map +1 -0
  12. package/_dist/keywords.d.ts +9 -0
  13. package/_dist/keywords.d.ts.map +1 -0
  14. package/_dist/mod.d.ts +26 -0
  15. package/_dist/mod.d.ts.map +1 -0
  16. package/_dist/plugin.d.ts +6 -0
  17. package/_dist/plugin.d.ts.map +1 -0
  18. package/_dist/tools.d.ts +6 -0
  19. package/_dist/tools.d.ts.map +1 -0
  20. package/_dist/views.d.ts +8 -0
  21. package/_dist/views.d.ts.map +1 -0
  22. package/_dist/vocab.d.ts +16 -0
  23. package/_dist/vocab.d.ts.map +1 -0
  24. package/cites.js +61 -0
  25. package/cites.js.map +1 -0
  26. package/cites.ts +63 -0
  27. package/comment-host.js +11 -0
  28. package/comment-host.js.map +1 -0
  29. package/comment-host.ts +35 -0
  30. package/comments.js +51 -0
  31. package/comments.js.map +1 -0
  32. package/comments.ts +59 -0
  33. package/completion.js +33 -0
  34. package/completion.js.map +1 -0
  35. package/completion.ts +33 -0
  36. package/component-views.tsx +34 -0
  37. package/decision.js +17 -0
  38. package/decision.js.map +1 -0
  39. package/decision.ts +14 -0
  40. package/deno.json +1 -0
  41. package/graph.js +7 -0
  42. package/graph.js.map +1 -0
  43. package/graph.ts +8 -0
  44. package/keywords.js +31 -0
  45. package/keywords.js.map +1 -0
  46. package/keywords.ts +29 -0
  47. package/meta/kernel.vocab.json +20 -0
  48. package/mod.js +26 -0
  49. package/mod.js.map +1 -0
  50. package/mod.ts +26 -0
  51. package/package.json +56 -4
  52. package/plugin.js +33 -0
  53. package/plugin.js.map +1 -0
  54. package/plugin.ts +31 -0
  55. package/tools.js +34 -0
  56. package/tools.js.map +1 -0
  57. package/tools.ts +30 -0
  58. package/views.js +29 -0
  59. package/views.js.map +1 -0
  60. package/views.ts +29 -0
  61. package/views.tsx +3 -0
  62. package/vocab.js +34 -0
  63. package/vocab.js.map +1 -0
  64. package/vocab.json +765 -0
  65. package/vocab.ts +34 -0
package/cites.ts ADDED
@@ -0,0 +1,63 @@
1
+ // A citation of a graph entity keeps the content it was checked against.
2
+ // The hash ignores server-owned stamps, so bookkeeping cannot make a claim
3
+ // stale. File and symbol citations have a narrower answer in @yaks/git.
4
+
5
+ import { cmp } from '@yaks/fp'
6
+ import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
7
+ import { comps } from '@yaks/graph/bundle'
8
+ import { Refused } from '@yaks/graph/errors'
9
+ import { sha256 } from '@yaks/graph/sha256'
10
+ import type { Vocab } from 'jsr:@yaks/vocab@0.2.36'
11
+
12
+ export let CITES = 'cites'
13
+
14
+ let written = (c: Comp, props: string[]): Comp => {
15
+ let out: Comp = {}
16
+ for (let p of props.toSorted()) if (c[p] != null) out[p] = c[p]
17
+ return out
18
+ }
19
+
20
+ /** SHA-256 over an entity's client-written properties, in a fixed order. */
21
+ export let content = (vocab: Vocab) => (b: Bundle): string => {
22
+ let kept: [string, Comp][] = []
23
+ for (let [name, c] of comps(b)) {
24
+ let info = vocab.comp(name)
25
+ if (!c || !info?.wire) continue
26
+ if (!info.writable.length && info.stamped.length) continue
27
+ kept.push([name, written(c, info.writable)])
28
+ }
29
+ kept.sort(([a], [b]) => cmp(a, b))
30
+ return sha256(JSON.stringify(kept))
31
+ }
32
+
33
+ export type Status =
34
+ | { state: 'current' }
35
+ | { state: 'moved'; changes?: string[] }
36
+ | { state: 'unverified' }
37
+ | { state: 'unknown'; why: string }
38
+
39
+ /** Whether the cited entity still says what was verified. */
40
+ export let status = (cite: Bundle, to: Bundle, vocab: Vocab): Status => {
41
+ if (!cite.verified) return { state: 'unverified' }
42
+ if (to.tombstone) return { state: 'moved' }
43
+ let row = cite[CITES]
44
+ let hash = row && typeof row == 'object' && 'hash' in row
45
+ ? row.hash
46
+ : undefined
47
+ if (typeof hash != 'string' || !hash) {
48
+ return { state: 'unknown', why: 'verified against no content hash' }
49
+ }
50
+ return hash == content(vocab)(to) ? { state: 'current' } : {
51
+ state: 'moved',
52
+ }
53
+ }
54
+
55
+ /** The patch recording that somebody checked this citation's target. */
56
+ export let verify = (cite: Bundle, to: Bundle, vocab: Vocab): Bundle => {
57
+ if (to.tombstone) throw new Refused('cannot verify a deleted entity')
58
+ return {
59
+ entity: { eid: cite.entity.eid },
60
+ verified: {},
61
+ [CITES]: { hash: content(vocab)(to) },
62
+ }
63
+ }
@@ -0,0 +1,11 @@
1
+ // The doors comments need from whichever interface mounts them. The domain
2
+ // owns comment bundles; a host owns subscriptions, navigation and rendering.
3
+ let current;
4
+ /** Bind the domain to an interface before mounting its views. */ export let configureComments = (host)=>{
5
+ current = host;
6
+ };
7
+ export let commentHost = ()=>{
8
+ if (!current) throw new Error('Comments need an interface host');
9
+ return current;
10
+ };
11
+ //# sourceMappingURL=comment-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comment-host.js","sources":["./comment-host.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,6EAA6E;AAyB7E,IAAI;AACJ,+DAA+D,GAC/D,OAAO,IAAI,oBAAoB,CAAC;EAC9B,UAAU;AACZ,EAAC;AACD,OAAO,IAAI,cAAc;EACvB,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM;EAC9B,OAAO;AACT,EAAC"}
@@ -0,0 +1,35 @@
1
+ // The doors comments need from whichever interface mounts them. The domain
2
+ // owns comment bundles; a host owns subscriptions, navigation and rendering.
3
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
4
+ /* @ts-types="npm:@types/react@19.3.0" */ import type { ReactNode } from 'npm:react@19.3.0'
5
+
6
+ export type CommentHost = {
7
+ get: (eid: string) => Bundle
8
+ id: (b: Bundle) => string
9
+ useRows: (query: string) => Bundle[]
10
+ useModel: (eid: string) => string | undefined
11
+ useRepo: (b: Bundle) => string | undefined
12
+ usePage: (name: string, place: string) => {
13
+ value?: Record<string, unknown>
14
+ set: (value: Record<string, unknown>) => void
15
+ }
16
+ render: (b: Bundle, view: string) => ReactNode
17
+ link: (b: Bundle) => Record<string, unknown>
18
+ markdown: (text: string, repo?: string) => ReactNode
19
+ pending: (b: Bundle) => boolean
20
+ has: (comp: string) => boolean
21
+ modelName: (model?: string) => string | undefined
22
+ when: (at?: string) => string
23
+ timestamp: (at?: string) => string
24
+ command: (line: string) => boolean
25
+ hints: (line: string) => { name: string; args: string; about: string }[]
26
+ }
27
+ let current: CommentHost | undefined
28
+ /** Bind the domain to an interface before mounting its views. */
29
+ export let configureComments = (host: CommentHost): void => {
30
+ current = host
31
+ }
32
+ export let commentHost = (): CommentHost => {
33
+ if (!current) throw new Error('Comments need an interface host')
34
+ return current
35
+ }
package/comments.js ADDED
@@ -0,0 +1,51 @@
1
+ // Comments form branches on one thread. Missing parents and malformed cycles
2
+ // stay visible as roots; grouping never drops somebody's words.
3
+ export let branches = (rows)=>{
4
+ let ordered = [
5
+ ...rows
6
+ ].sort((a, b)=>String(a.created?.at ?? '').localeCompare(String(b.created?.at ?? '')) || (a.entity.num ?? 0) - (b.entity.num ?? 0) || a.entity.eid.localeCompare(b.entity.eid));
7
+ let nodes = new Map(ordered.map((row)=>[
8
+ row.entity.eid,
9
+ {
10
+ row,
11
+ children: []
12
+ }
13
+ ]));
14
+ let parents = new Map();
15
+ for (let row of ordered){
16
+ let parent = nodes.get(row.comment?.reply_to ?? '')?.row;
17
+ if (parent?.comment && parent.comment.target == row.comment?.target) {
18
+ parents.set(row.entity.eid, parent.entity.eid);
19
+ }
20
+ }
21
+ let done = new Set();
22
+ for (let row of ordered){
23
+ let path = new Set(), at = row.entity.eid;
24
+ while(at && !done.has(at)){
25
+ if (path.has(at)) {
26
+ parents.delete(at);
27
+ break;
28
+ }
29
+ path.add(at);
30
+ at = parents.get(at);
31
+ }
32
+ for (let eid of path)done.add(eid);
33
+ }
34
+ let roots = [];
35
+ for (let [eid, node] of nodes){
36
+ let parent = nodes.get(parents.get(eid) ?? '');
37
+ let into = parent ? parent.children : roots;
38
+ into.push(node);
39
+ }
40
+ return roots;
41
+ };
42
+ /** Who a thread names in its bylines: each note's writer and the instrument
43
+ * it came through, once each, so a host can ask for them by name. */ /// writers([{ entity: { eid: 'c1' }, created: { by: 'u1', via: 's1' } }, { entity: { eid: 'c2' }, created: { by: 'u1' } }])
44
+ /// -> ['u1', 's1']
45
+ export let writers = (rows)=>[
46
+ ...new Set(rows.flatMap((b)=>[
47
+ b.created?.by,
48
+ b.created?.via
49
+ ]).filter((id)=>!!id))
50
+ ];
51
+ //# sourceMappingURL=comments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comments.js","sources":["./comments.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,gEAAgE;AAUhE,OAAO,IAAI,WAAW,CAAC;EACrB,IAAI,UAAU;OAAI;GAAK,CAAC,IAAI,CAAC,CAAC,GAAG,IAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,QAClE,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KACxC,EAAE,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC,GAAG;EAEzC,IAAI,QAAQ,IAAI,IACd,QAAQ,GAAG,CAAC,CAAC,MAAQ;MAAC,IAAI,MAAM,CAAC,GAAG;MAAE;QAAE;QAAK,UAAU,EAAE;MAAC;KAAE;EAE9D,IAAI,UAAU,IAAI;EAClB,KAAK,IAAI,OAAO,QAAS;IACvB,IAAI,SAAS,MAAM,GAAG,CAAC,IAAI,OAAO,EAAE,YAAY,KAAK;IACrD,IAAI,QAAQ,WAAW,OAAO,OAAO,CAAC,MAAM,IAAI,IAAI,OAAO,EAAE,QAAQ;MACnE,QAAQ,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,OAAO,MAAM,CAAC,GAAG;IAC/C;EACF;EACA,IAAI,OAAO,IAAI;EACf,KAAK,IAAI,OAAO,QAAS;IACvB,IAAI,OAAO,IAAI,OAAe,KAAyB,IAAI,MAAM,CAAC,GAAG;IACrE,MAAO,MAAM,CAAC,KAAK,GAAG,CAAC,IAAK;MAC1B,IAAI,KAAK,GAAG,CAAC,KAAK;QAChB,QAAQ,MAAM,CAAC;QACf;MACF;MACA,KAAK,GAAG,CAAC;MACT,KAAK,QAAQ,GAAG,CAAC;IACnB;IACA,KAAK,IAAI,OAAO,KAAM,KAAK,GAAG,CAAC;EACjC;EACA,IAAI,QAAkB,EAAE;EACxB,KAAK,IAAI,CAAC,KAAK,KAAK,IAAI,MAAO;IAC7B,IAAI,SAAS,MAAM,GAAG,CAAC,QAAQ,GAAG,CAAC,QAAQ;IAC3C,IAAI,OAAO,SAAS,OAAO,QAAQ,GAAG;IACtC,KAAK,IAAI,CAAC;EACZ;EACA,OAAO;AACT,EAAC;AAED;mEACmE,GACnE,4HAA4H;AAC5H,qBAAqB;AACrB,OAAO,IAAI,UAAU,CAAC,OAAiC;OAClD,IAAI,IACL,KAAK,OAAO,CAAC,CAAC,IAAM;QAAC,EAAE,OAAO,EAAE;QAAI,EAAE,OAAO,EAAE;OAAI,EAChD,MAAM,CAAC,CAAC,KAAqB,CAAC,CAAC;GAErC,CAAA"}
package/comments.ts ADDED
@@ -0,0 +1,59 @@
1
+ // Comments form branches on one thread. Missing parents and malformed cycles
2
+ // stay visible as roots; grouping never drops somebody's words.
3
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
4
+
5
+ export type CommentRow = Bundle & {
6
+ created?: { at?: string; by?: string; via?: string }
7
+ comment?: { target: string; reply_to?: string }
8
+ }
9
+
10
+ export type Branch = { row: CommentRow; children: Branch[] }
11
+
12
+ export let branches = (rows: CommentRow[]): Branch[] => {
13
+ let ordered = [...rows].sort((a, b) =>
14
+ String(a.created?.at ?? '').localeCompare(String(b.created?.at ?? '')) ||
15
+ (a.entity.num ?? 0) - (b.entity.num ?? 0) ||
16
+ a.entity.eid.localeCompare(b.entity.eid)
17
+ )
18
+ let nodes = new Map<string, Branch>(
19
+ ordered.map((row) => [row.entity.eid, { row, children: [] }]),
20
+ )
21
+ let parents = new Map<string, string>()
22
+ for (let row of ordered) {
23
+ let parent = nodes.get(row.comment?.reply_to ?? '')?.row
24
+ if (parent?.comment && parent.comment.target == row.comment?.target) {
25
+ parents.set(row.entity.eid, parent.entity.eid)
26
+ }
27
+ }
28
+ let done = new Set<string>()
29
+ for (let row of ordered) {
30
+ let path = new Set<string>(), at: string | undefined = row.entity.eid
31
+ while (at && !done.has(at)) {
32
+ if (path.has(at)) {
33
+ parents.delete(at)
34
+ break
35
+ }
36
+ path.add(at)
37
+ at = parents.get(at)
38
+ }
39
+ for (let eid of path) done.add(eid)
40
+ }
41
+ let roots: Branch[] = []
42
+ for (let [eid, node] of nodes) {
43
+ let parent = nodes.get(parents.get(eid) ?? '')
44
+ let into = parent ? parent.children : roots
45
+ into.push(node)
46
+ }
47
+ return roots
48
+ }
49
+
50
+ /** Who a thread names in its bylines: each note's writer and the instrument
51
+ * it came through, once each, so a host can ask for them by name. */
52
+ /// writers([{ entity: { eid: 'c1' }, created: { by: 'u1', via: 's1' } }, { entity: { eid: 'c2' }, created: { by: 'u1' } }])
53
+ /// -> ['u1', 's1']
54
+ export let writers = (rows: CommentRow[]): string[] => [
55
+ ...new Set(
56
+ rows.flatMap((b) => [b.created?.by, b.created?.via])
57
+ .filter((id): id is string => !!id),
58
+ ),
59
+ ]
package/completion.js ADDED
@@ -0,0 +1,33 @@
1
+ // Who finished a piece of work, kept on the `completed` mark across later
2
+ // edits.
3
+ //
4
+ // The hook runs in the `precondition` phase, before @yaks/graph fills in the
5
+ // mark's `{at, by, via}`. For every bundle that writes `completed`, `by` is
6
+ // the one the incoming component names, which only trusted server code can
7
+ // (the wire refuses a stamped property), as a repair or a restore does. A
8
+ // write naming none reads the row already stored: if that row had a
9
+ // `completed` component, its `by` is carried over, so a later patch of the
10
+ // same mark cannot change who finished the work; otherwise `by` is the
11
+ // `$actor.by` the `apply()` call carries, or null.
12
+ import { after } from "@yaks/fp";
13
+ export let completing = (bundles, tx)=>{
14
+ let writes = bundles.filter((b)=>b.completed != null);
15
+ if (!writes.length) return bundles;
16
+ let actor = bundles.find((b)=>b.$actor)?.$actor?.by;
17
+ return after(tx.get(writes.map((b)=>b.entity.eid)), (rows)=>{
18
+ let previous = new Map(rows.map((b)=>[
19
+ b.entity.eid,
20
+ b.completed
21
+ ]));
22
+ for (let b of writes){
23
+ let old = previous.get(b.entity.eid);
24
+ let named = b.completed.by;
25
+ b.completed = {
26
+ ...b.completed,
27
+ by: named !== undefined ? named : old ? old.by ?? null : actor ?? null
28
+ };
29
+ }
30
+ return bundles;
31
+ });
32
+ };
33
+ //# sourceMappingURL=completion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completion.js","sources":["./completion.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,SAAS;AACT,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,2EAA2E;AAC3E,uEAAuE;AACvE,mDAAmD;AAEnD,SAAS,KAAK,wBAA6B;AAI3C,OAAO,IAAI,aAAmB,CAAC,SAAS;EACtC,IAAI,SAAS,QAAQ,MAAM,CAAC,CAAC,IAAM,EAAE,SAAS,IAAI;EAClD,IAAI,CAAC,OAAO,MAAM,EAAE,OAAO;EAC3B,IAAI,QAAQ,QAAQ,IAAI,CAAC,CAAC,IAAM,EAAE,MAAM,GAAG,QAAQ;EACnD,OAAO,MAAM,GAAG,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,IAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IACrD,IAAI,WAAW,IAAI,IAAI,KAAK,GAAG,CAAC,CAAC,IAAM;QAAC,EAAE,MAAM,CAAC,GAAG;QAAE,EAAE,SAAS;OAAS;IAC1E,KAAK,IAAI,KAAK,OAAQ;MACpB,IAAI,MAAM,SAAS,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG;MACnC,IAAI,QAAQ,AAAC,EAAE,SAAS,CAAU,EAAE;MACpC,EAAE,SAAS,GAAG;QACZ,GAAI,EAAE,SAAS;QACf,IAAI,UAAU,YAAY,QAAQ,MAAM,IAAI,EAAE,IAAI,OAAO,SAAS;MACpE;IACF;IACA,OAAO;EACT;AACF,EAAC"}
package/completion.ts ADDED
@@ -0,0 +1,33 @@
1
+ // Who finished a piece of work, kept on the `completed` mark across later
2
+ // edits.
3
+ //
4
+ // The hook runs in the `precondition` phase, before @yaks/graph fills in the
5
+ // mark's `{at, by, via}`. For every bundle that writes `completed`, `by` is
6
+ // the one the incoming component names, which only trusted server code can
7
+ // (the wire refuses a stamped property), as a repair or a restore does. A
8
+ // write naming none reads the row already stored: if that row had a
9
+ // `completed` component, its `by` is carried over, so a later patch of the
10
+ // same mark cannot change who finished the work; otherwise `by` is the
11
+ // `$actor.by` the `apply()` call carries, or null.
12
+
13
+ import { after } from '@yaks/fp'
14
+ import type { Comp } from 'jsr:@yaks/graph@0.2.36/bundle'
15
+ import type { Hook } from 'jsr:@yaks/graph@0.2.36/plugin'
16
+
17
+ export let completing: Hook = (bundles, tx) => {
18
+ let writes = bundles.filter((b) => b.completed != null)
19
+ if (!writes.length) return bundles
20
+ let actor = bundles.find((b) => b.$actor)?.$actor?.by
21
+ return after(tx.get(writes.map((b) => b.entity.eid)), (rows) => {
22
+ let previous = new Map(rows.map((b) => [b.entity.eid, b.completed as Comp]))
23
+ for (let b of writes) {
24
+ let old = previous.get(b.entity.eid)
25
+ let named = (b.completed as Comp).by
26
+ b.completed = {
27
+ ...(b.completed as Comp),
28
+ by: named !== undefined ? named : old ? old.by ?? null : actor ?? null,
29
+ }
30
+ }
31
+ return bundles
32
+ })
33
+ }
@@ -0,0 +1,34 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ // Comment and commit faces contributed to the shared renderer registry.
3
+ import { parse } from 'jsr:@yaks/query@0.2.36'
4
+ import type { ComponentRenderer } from 'jsr:@yaks/react@0.2.36'
5
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
6
+ import { commentHost } from './comment-host.ts'
7
+ import { Note } from './Comments.tsx'
8
+
9
+ export let views: { renderers: ComponentRenderer<Bundle>[] } = {
10
+ renderers: [
11
+ {
12
+ view: 'Thread.Body',
13
+ match: parse('.comment'),
14
+ Render: ({ e }) => {
15
+ let host = commentHost()
16
+ let repo = host.useRepo(e)
17
+ return host.markdown(
18
+ String((e.doc as Record<string, unknown> | undefined)?.body ?? ''),
19
+ repo,
20
+ )
21
+ },
22
+ },
23
+ {
24
+ view: 'Thread.Note',
25
+ match: parse('.comment'),
26
+ Render: ({ e }) => <Note c={e} />,
27
+ },
28
+ {
29
+ view: 'Thread.Note',
30
+ match: parse('.commit'),
31
+ Render: ({ e }) => <Note c={e} reply={false} />,
32
+ },
33
+ ],
34
+ }
package/decision.js ADDED
@@ -0,0 +1,17 @@
1
+ // Recording somebody's explicit decision attributes the mark to that person.
2
+ // The signed writer stays the caller for authorization and the journal.
3
+ export let deciding = (bundles)=>bundles.map((b)=>{
4
+ if (b.$decider == null) return b;
5
+ let out = {
6
+ ...b
7
+ };
8
+ delete out.$decider;
9
+ if (out.decided) {
10
+ out.decided = {
11
+ ...out.decided,
12
+ by: String(b.$decider)
13
+ };
14
+ }
15
+ return out;
16
+ });
17
+ //# sourceMappingURL=decision.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision.js","sources":["./decision.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,wEAAwE;AAGxE,OAAO,IAAI,WAAW,CAAC,UACrB,QAAQ,GAAG,CAAC,CAAC;IACX,IAAI,EAAE,QAAQ,IAAI,MAAM,OAAO;IAC/B,IAAI,MAAM;MAAE,GAAG,CAAC;IAAC;IACjB,OAAO,IAAI,QAAQ;IACnB,IAAI,IAAI,OAAO,EAAE;MACf,IAAI,OAAO,GAAG;QAAE,GAAG,IAAI,OAAO;QAAU,IAAI,OAAO,EAAE,QAAQ;MAAE;IACjE;IACA,OAAO;EACT,GAAE"}
package/decision.ts ADDED
@@ -0,0 +1,14 @@
1
+ // Recording somebody's explicit decision attributes the mark to that person.
2
+ // The signed writer stays the caller for authorization and the journal.
3
+ import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36/bundle'
4
+
5
+ export let deciding = (bundles: Bundle[]): Bundle[] =>
6
+ bundles.map((b) => {
7
+ if (b.$decider == null) return b
8
+ let out = { ...b }
9
+ delete out.$decider
10
+ if (out.decided) {
11
+ out.decided = { ...out.decided as Comp, by: String(b.$decider) }
12
+ }
13
+ return out
14
+ })
package/deno.json ADDED
@@ -0,0 +1 @@
1
+ {"publish":{"exclude":["**/*_test.ts"]},"name":"@yaks/kernel","version":"0.2.36","license":"Apache-2.0","description":"Shared identity, marks and relationship components for graphs of work, with vocabulary documents, a completion plugin, citation helpers and a comment tool.","exports":{".":"./mod.ts","./vocab":"./vocab.ts","./graph":"./graph.ts","./tools":"./tools.ts","./Comments":"./Comments.tsx","./comment-host":"./comment-host.ts","./comments":"./comments.ts","./views":"./views.ts","./component-views":"./component-views.tsx"},"imports":{"@yaks/kernel":"./mod.ts","@yaks/kernel/vocab":"./vocab.ts","@yaks/kernel/graph":"./graph.ts","@yaks/kernel/tools":"./tools.ts","@yaks/kernel/Comments":"./Comments.tsx","@yaks/kernel/comment-host":"./comment-host.ts","@yaks/kernel/comments":"./comments.ts","@yaks/kernel/views":"./views.ts","@yaks/kernel/component-views":"./component-views.tsx"}}
package/graph.js ADDED
@@ -0,0 +1,7 @@
1
+ // What the graph does with a write about the kernel's marks: the module a
2
+ // server imports as `@yaks/kernel/graph`.
3
+ import { kernel } from "./plugin.js";
4
+ /** The kernel components, and the hook that records who completed something. */ export let plugins = ()=>[
5
+ kernel()
6
+ ];
7
+ //# sourceMappingURL=graph.js.map
package/graph.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.js","sources":["./graph.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0CAA0C;AAG1C,SAAS,MAAM,sBAAqB;AAEpC,8EAA8E,GAC9E,OAAO,IAAI,UAAU,IAAgB;IAAC;GAAS,CAAA"}
package/graph.ts ADDED
@@ -0,0 +1,8 @@
1
+ // What the graph does with a write about the kernel's marks: the module a
2
+ // server imports as `@yaks/kernel/graph`.
3
+
4
+ import type { Plugin } from 'jsr:@yaks/graph@0.2.36'
5
+ import { kernel } from './plugin.js'
6
+
7
+ /** The kernel components, and the hook that records who completed something. */
8
+ export let plugins = (): Plugin[] => [kernel()]
package/keywords.js ADDED
@@ -0,0 +1,31 @@
1
+ // The registration: the custom JSON Schema keywords @yaks/kernel adds to a
2
+ // component vocabulary, declared in JSON Schema's own extension form.
3
+ // `meta/kernel.vocab.json` is the authored source (each keyword's schema and
4
+ // the prose describing it); this module gives it a name and the shape
5
+ // `loadVocab(docs, [kernelKeywords])` expects.
6
+ //
7
+ // Three keywords, because three things about a graph of work are not the core
8
+ // meta-model's business: which components a project answers for, which
9
+ // components stay out of the snapshot a client loads at startup, and where a
10
+ // text property's suggested values come from.
11
+ import doc from './meta/kernel.vocab.json' with {
12
+ type: 'json'
13
+ };
14
+ /** The URI a vocabulary file declares under `$vocabulary` to use these
15
+ * keywords. */ export let KERNEL_URI = 'https://yak.sh/vocab/kernel';
16
+ /**
17
+ * The kernel keyword vocabulary, ready to register: `loadVocab(docs,
18
+ * [kernelKeywords])` carries `governed` and `lazy` onto the components that
19
+ * declare them and `well` onto the properties that do.
20
+ */ export let kernelKeywords = {
21
+ uri: KERNEL_URI,
22
+ comp: [
23
+ 'governed',
24
+ 'lazy'
25
+ ],
26
+ prop: [
27
+ 'well'
28
+ ],
29
+ doc
30
+ };
31
+ //# sourceMappingURL=keywords.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keywords.js","sources":["./keywords.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,sEAAsE;AACtE,6EAA6E;AAC7E,sEAAsE;AACtE,+CAA+C;AAC/C,EAAE;AACF,8EAA8E;AAC9E,uEAAuE;AACvE,6EAA6E;AAC7E,8CAA8C;AAG9C,OAAO,SAAS,gCAAgC;EAAE,MAAM;AAAO,EAAC;AAEhE;aACa,GACb,OAAO,IAAI,aAAa,8BAA6B;AAErD;;;;CAIC,GACD,OAAO,IAAI,iBAA2B;EACpC,KAAK;EACL,MAAM;IAAC;IAAY;GAAO;EAC1B,MAAM;IAAC;GAAO;EACd;AACF,EAAC"}
package/keywords.ts ADDED
@@ -0,0 +1,29 @@
1
+ // The registration: the custom JSON Schema keywords @yaks/kernel adds to a
2
+ // component vocabulary, declared in JSON Schema's own extension form.
3
+ // `meta/kernel.vocab.json` is the authored source (each keyword's schema and
4
+ // the prose describing it); this module gives it a name and the shape
5
+ // `loadVocab(docs, [kernelKeywords])` expects.
6
+ //
7
+ // Three keywords, because three things about a graph of work are not the core
8
+ // meta-model's business: which components a project answers for, which
9
+ // components stay out of the snapshot a client loads at startup, and where a
10
+ // text property's suggested values come from.
11
+
12
+ import type { Keywords } from 'jsr:@yaks/vocab@0.2.36'
13
+ import doc from './meta/kernel.vocab.json' with { type: 'json' }
14
+
15
+ /** The URI a vocabulary file declares under `$vocabulary` to use these
16
+ * keywords. */
17
+ export let KERNEL_URI = 'https://yak.sh/vocab/kernel'
18
+
19
+ /**
20
+ * The kernel keyword vocabulary, ready to register: `loadVocab(docs,
21
+ * [kernelKeywords])` carries `governed` and `lazy` onto the components that
22
+ * declare them and `well` onto the properties that do.
23
+ */
24
+ export let kernelKeywords: Keywords = {
25
+ uri: KERNEL_URI,
26
+ comp: ['governed', 'lazy'],
27
+ prop: ['well'],
28
+ doc,
29
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://yak.sh/vocab/kernel",
4
+ "title": "yaks kernel keyword vocabulary",
5
+ "description": "Three keywords a graph of work needs that the core meta-model does not define: which components a project answers for, which components stay out of the snapshot a client loads at startup, and where a text property's suggested values come from.",
6
+ "$defs": {
7
+ "governed": {
8
+ "description": "true = a project answers for the entities carrying this component, reached by edges rooted at the project. It is what a project's reach is computed over.",
9
+ "type": "boolean"
10
+ },
11
+ "lazy": {
12
+ "description": "true = this component's rows are left out of the snapshot a client loads at startup; a reader asks for them by the partition they belong to.",
13
+ "type": "boolean"
14
+ },
15
+ "well": {
16
+ "description": "Names a list of suggested values for this text property, offered for completion beside the values the property already holds. The list is registered by whoever holds the values, so the schema stays declarative.",
17
+ "type": "string"
18
+ }
19
+ }
20
+ }
package/mod.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The components most graphs of work need: the `entity` row every entity has,
3
+ * the marks recording what happened to a thing and who did it (`proposed`,
4
+ * `decided`, `quarantined`), the lifecycle marks a status is read from
5
+ * (`completed`, `failed`, `broken`, `resolved`, `verified`), the things that
6
+ * attach to an entity (`comment`, `image`, `favorite`), and the tags that give
7
+ * an edge its meaning (`about`, `reads`, `references`, `supersedes`, …). The
8
+ * stamps every write leaves, `created` and `updated`, are @yaks/provenance's.
9
+ *
10
+ * It ships the vocabulary, three keywords that describe what the core
11
+ * meta-model does not (see {@link kernelKeywords}), and the pure content hash
12
+ * and freshness answer for citations. The
13
+ * `entity` row is the identity row every entity has; what is KEPT beside the
14
+ * eid is each plugin's own — the archetype is @yaks/archetype's word and the
15
+ * number a human id is built from is @yaks/id's.
16
+ *
17
+ * Who a write is signed as is not here, and it is not a name out of a config
18
+ * file: a write that did not arrive through an authenticated HTTP or MCP
19
+ * request is signed as the `process` row this run wrote about itself
20
+ * (@yaks/process `started`), because a program that runs twice is two writers —
21
+ * two `yak` commands over one database file are two of them.
22
+ */ export { KERNEL_URI, kernelKeywords } from "./keywords.js";
23
+ export { kernelDoc, marksDoc, spineDoc } from "./vocab.js";
24
+ export { kernel } from "./plugin.js";
25
+ export * from "./cites.js";
26
+ //# sourceMappingURL=mod.js.map
package/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sources":["./mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,SAAS,UAAU,EAAE,cAAc,wBAAuB;AAC1D,SAAS,SAAS,EAAE,QAAQ,EAAE,QAAQ,qBAAoB;AAC1D,SAAS,MAAM,sBAAqB;AACpC,2BAA0B"}
package/mod.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The components most graphs of work need: the `entity` row every entity has,
3
+ * the marks recording what happened to a thing and who did it (`proposed`,
4
+ * `decided`, `quarantined`), the lifecycle marks a status is read from
5
+ * (`completed`, `failed`, `broken`, `resolved`, `verified`), the things that
6
+ * attach to an entity (`comment`, `image`, `favorite`), and the tags that give
7
+ * an edge its meaning (`about`, `reads`, `references`, `supersedes`, …). The
8
+ * stamps every write leaves, `created` and `updated`, are @yaks/provenance's.
9
+ *
10
+ * It ships the vocabulary, three keywords that describe what the core
11
+ * meta-model does not (see {@link kernelKeywords}), and the pure content hash
12
+ * and freshness answer for citations. The
13
+ * `entity` row is the identity row every entity has; what is KEPT beside the
14
+ * eid is each plugin's own — the archetype is @yaks/archetype's word and the
15
+ * number a human id is built from is @yaks/id's.
16
+ *
17
+ * Who a write is signed as is not here, and it is not a name out of a config
18
+ * file: a write that did not arrive through an authenticated HTTP or MCP
19
+ * request is signed as the `process` row this run wrote about itself
20
+ * (@yaks/process `started`), because a program that runs twice is two writers —
21
+ * two `yak` commands over one database file are two of them.
22
+ */
23
+ export { KERNEL_URI, kernelKeywords } from './keywords.js'
24
+ export { kernelDoc, marksDoc, spineDoc } from './vocab.js'
25
+ export { kernel } from './plugin.js'
26
+ export * from './cites.js'
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@yaks/kernel",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.36",
4
+ "homepage": "https://jsr.io/@yaks/kernel",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./_dist/mod.d.ts",
9
+ "default": "./mod.js"
10
+ },
11
+ "./vocab": {
12
+ "types": "./_dist/vocab.d.ts",
13
+ "default": "./vocab.js"
14
+ },
15
+ "./graph": {
16
+ "types": "./_dist/graph.d.ts",
17
+ "default": "./graph.js"
18
+ },
19
+ "./tools": {
20
+ "types": "./_dist/tools.d.ts",
21
+ "default": "./tools.js"
22
+ },
23
+ "./Comments": {
24
+ "default": "./Comments.tsx"
25
+ },
26
+ "./comment-host": {
27
+ "types": "./_dist/comment-host.d.ts",
28
+ "default": "./comment-host.js"
29
+ },
30
+ "./comments": {
31
+ "types": "./_dist/comments.d.ts",
32
+ "default": "./comments.js"
33
+ },
34
+ "./views": {
35
+ "types": "./_dist/views.d.ts",
36
+ "default": "./views.js"
37
+ },
38
+ "./component-views": {
39
+ "default": "./component-views.tsx"
40
+ }
41
+ },
42
+ "license": "Apache-2.0",
43
+ "dependencies": {
44
+ "@yaks/draft": "0.2.36",
45
+ "@yaks/fp": "0.2.36",
46
+ "@yaks/graph": "0.2.36",
47
+ "@yaks/query": "0.2.36",
48
+ "@yaks/react": "0.2.36",
49
+ "@yaks/render": "0.2.36",
50
+ "@yaks/ui": "0.2.36",
51
+ "@yaks/ux": "0.2.36",
52
+ "@yaks/vocab": "0.2.36",
53
+ "@types/react": "19.3.0",
54
+ "react": "19.3.0"
55
+ },
56
+ "description": "Shared identity, marks and relationship components for graphs of work, with vocabulary documents, a completion plugin, citation helpers and a comment tool.",
57
+ "repository": "https://github.com/yak-sh/yak.git"
58
+ }
package/plugin.js ADDED
@@ -0,0 +1,33 @@
1
+ // The kernel's words, completion authors, and explicitly attributed decisions.
2
+ import { hook } from "@yaks/graph/plugin";
3
+ import { completing } from "./completion.js";
4
+ import { deciding } from "./decision.js";
5
+ import { kernelDoc } from "./vocab.js";
6
+ /**
7
+ * The kernel plugin: every component ./vocab.json declares, and a
8
+ * `precondition` hook that records completion and decision attribution.
9
+ */ /// let { loadVocab, pick } = await import('@yaks/vocab')
10
+ /// let { graph } = await import('@yaks/graph')
11
+ /// let { ram } = await import('@yaks/ram')
12
+ /// let { kernelDoc } = await import('@yaks/kernel')
13
+ /// let vocab = loadVocab(pick(kernelDoc, ['completed']))
14
+ /// let g = graph({ storage: ram(vocab), vocab, plugins: [kernel()] })
15
+ /// await g.apply([{ entity: { eid: 'w1' }, completed: {} }])
16
+ /// let [work] = await g.get(['w1'])
17
+ /// work ~> { completed: { by: undefined } }
18
+ export let kernel = ()=>({
19
+ name: '@yaks/kernel',
20
+ vocab: [
21
+ kernelDoc
22
+ ],
23
+ requests: [
24
+ '$decider'
25
+ ],
26
+ hooks: {
27
+ precondition: hook([
28
+ 'completed',
29
+ '$decider'
30
+ ], (bundles, tx)=>completing(deciding(bundles), tx))
31
+ }
32
+ });
33
+ //# sourceMappingURL=plugin.js.map
package/plugin.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["./plugin.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,SAAS,IAAI,kCAAoD;AACjE,SAAS,UAAU,0BAAyB;AAC5C,SAAS,QAAQ,wBAAuB;AACxC,SAAS,SAAS,qBAAoB;AAEtC;;;CAGC,GACD,yDAAyD;AACzD,+CAA+C;AAC/C,2CAA2C;AAC3C,oDAAoD;AACpD,yDAAyD;AACzD,sEAAsE;AACtE,6DAA6D;AAC7D,oCAAoC;AACpC,4CAA4C;AAC5C,OAAO,IAAI,SAAS,IAAc,CAAC;IACjC,MAAM;IACN,OAAO;MAAC;KAAU;IAClB,UAAU;MAAC;KAAW;IACtB,OAAO;MACL,cAAc,KACZ;QAAC;QAAa;OAAW,EACzB,CAAC,SAAS,KAAO,WAAW,SAAS,UAAU;IAEnD;EACF,CAAC,EAAC"}