@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/plugin.ts ADDED
@@ -0,0 +1,31 @@
1
+ // The kernel's words, completion authors, and explicitly attributed decisions.
2
+
3
+ import { hook, type Plugin } from '@yaks/graph/plugin'
4
+ import { completing } from './completion.js'
5
+ import { deciding } from './decision.js'
6
+ import { kernelDoc } from './vocab.js'
7
+
8
+ /**
9
+ * The kernel plugin: every component ./vocab.json declares, and a
10
+ * `precondition` hook that records completion and decision attribution.
11
+ */
12
+ /// let { loadVocab, pick } = await import('@yaks/vocab')
13
+ /// let { graph } = await import('@yaks/graph')
14
+ /// let { ram } = await import('@yaks/ram')
15
+ /// let { kernelDoc } = await import('@yaks/kernel')
16
+ /// let vocab = loadVocab(pick(kernelDoc, ['completed']))
17
+ /// let g = graph({ storage: ram(vocab), vocab, plugins: [kernel()] })
18
+ /// await g.apply([{ entity: { eid: 'w1' }, completed: {} }])
19
+ /// let [work] = await g.get(['w1'])
20
+ /// work ~> { completed: { by: undefined } }
21
+ export let kernel = (): Plugin => ({
22
+ name: '@yaks/kernel',
23
+ vocab: [kernelDoc],
24
+ requests: ['$decider'],
25
+ hooks: {
26
+ precondition: hook(
27
+ ['completed', '$decider'],
28
+ (bundles, tx) => completing(deciding(bundles), tx),
29
+ ),
30
+ },
31
+ })
package/tools.js ADDED
@@ -0,0 +1,34 @@
1
+ // The implementations of the tools declared with `tool: true` in ./vocab.json,
2
+ // exported as `@yaks/kernel/tools` — the entry point a server imports to
3
+ // register them.
4
+ //
5
+ // There is one, and it is the one people call all day: a comment. A comment has
6
+ // no table of its own — it is `doc{body}` aimed by `comment{target, reply_to}` — so the
7
+ // tool returns one new entity carrying both components, and the tool runner
8
+ // commits it signed as whoever called it.
9
+ import { argsOf } from "@yaks/graph/call";
10
+ /** The implementations of the tools ./vocab.json declares. A function that
11
+ * builds them, the way every entry point here is, though this one needs nothing
12
+ * from the server: what an implementation reads arrives on the call it is
13
+ * handed. */ export let runs = ()=>({
14
+ comment_new: (call)=>{
15
+ let args = argsOf(call);
16
+ return [
17
+ {
18
+ entity: {
19
+ eid: '$comment'
20
+ },
21
+ doc: {
22
+ body: String(args.body)
23
+ },
24
+ comment: {
25
+ target: String(args.target),
26
+ ...args.reply_to ? {
27
+ reply_to: String(args.reply_to)
28
+ } : {}
29
+ }
30
+ }
31
+ ];
32
+ }
33
+ });
34
+ //# sourceMappingURL=tools.js.map
package/tools.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sources":["./tools.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AACzE,iBAAiB;AACjB,EAAE;AACF,gFAAgF;AAChF,wFAAwF;AACxF,4EAA4E;AAC5E,0CAA0C;AAG1C,SAAS,MAAM,gCAAqC;AAGpD;;;WAGW,GACX,OAAO,IAAI,OAAO,IAAY,CAAC;IAC7B,aAAa,CAAC;MACZ,IAAI,OAAO,OAAO;MAClB,OAAO;QAAC;UACN,QAAQ;YAAE,KAAK;UAAW;UAC1B,KAAK;YAAE,MAAM,OAAO,KAAK,IAAI;UAAE;UAC/B,SAAS;YACP,QAAQ,OAAO,KAAK,MAAM;YAC1B,GAAI,KAAK,QAAQ,GAAG;cAAE,UAAU,OAAO,KAAK,QAAQ;YAAE,IAAI,CAAC,CAAC;UAC9D;QACF;OAAE;IACJ;EACF,CAAC,EAAC"}
package/tools.ts ADDED
@@ -0,0 +1,30 @@
1
+ // The implementations of the tools declared with `tool: true` in ./vocab.json,
2
+ // exported as `@yaks/kernel/tools` — the entry point a server imports to
3
+ // register them.
4
+ //
5
+ // There is one, and it is the one people call all day: a comment. A comment has
6
+ // no table of its own — it is `doc{body}` aimed by `comment{target, reply_to}` — so the
7
+ // tool returns one new entity carrying both components, and the tool runner
8
+ // commits it signed as whoever called it.
9
+
10
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
11
+ import { argsOf } from '@yaks/graph/call'
12
+ import type { Runs } from 'jsr:@yaks/graph@0.2.36/tools'
13
+
14
+ /** The implementations of the tools ./vocab.json declares. A function that
15
+ * builds them, the way every entry point here is, though this one needs nothing
16
+ * from the server: what an implementation reads arrives on the call it is
17
+ * handed. */
18
+ export let runs = (): Runs => ({
19
+ comment_new: (call): Bundle[] => {
20
+ let args = argsOf(call)
21
+ return [{
22
+ entity: { eid: '$comment' },
23
+ doc: { body: String(args.body) },
24
+ comment: {
25
+ target: String(args.target),
26
+ ...(args.reply_to ? { reply_to: String(args.reply_to) } : {}),
27
+ },
28
+ }]
29
+ },
30
+ })
package/views.js ADDED
@@ -0,0 +1,29 @@
1
+ // How what this package declares is drawn. `views`, portable for every
2
+ // interface: a comment in a list is a passage (@yaks/render's `passage`), who
3
+ // wrote it, when, what it is on, and the words around what was sought. Its
4
+ // component faces are loaded only by a browser or terminal painter.
5
+ import { parse } from "@yaks/query/core";
6
+ import { define } from "@yaks/render";
7
+ import { passage } from "@yaks/render/views";
8
+ let prop = (b, comp, name)=>b[comp]?.[name];
9
+ /** A comment's `Tile`. */ export let views = define([
10
+ {
11
+ view: 'Tile',
12
+ match: parse('.comment'),
13
+ ...passage({
14
+ texts: (b)=>[
15
+ prop(b, 'doc', 'body'),
16
+ prop(b, 'doc', 'title')
17
+ ],
18
+ where: (b)=>{
19
+ let target = prop(b, 'comment', 'target');
20
+ return typeof target == 'string' ? [
21
+ 'on',
22
+ target
23
+ ] : undefined;
24
+ }
25
+ })
26
+ }
27
+ ]);
28
+ export let componentViews = ()=>import('./component-views.tsx').then((m)=>m.views);
29
+ //# sourceMappingURL=views.js.map
package/views.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.js","sources":["./views.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,8EAA8E;AAC9E,2EAA2E;AAC3E,oEAAoE;AAGpE,SAAS,KAAK,gCAAqC;AACnD,SAAS,MAAM,4BAAgD;AAC/D,SAAS,OAAO,kCAAuC;AAEvD,IAAI,OAAO,CAAC,GAAW,MAAc,OAClC,CAAC,CAAC,KAAK,EAA0C,CAAC,KAAK;AAE1D,wBAAwB,GACxB,OAAO,IAAI,QAAkB,OAAO;EAAC;IACnC,MAAM;IACN,OAAO,MAAM;IACb,GAAG,QAAQ;MACT,OAAO,CAAC,IAAM;UAAC,KAAK,GAAG,OAAO;UAAS,KAAK,GAAG,OAAO;SAAS;MAC/D,OAAO,CAAC;QACN,IAAI,SAAS,KAAK,GAAG,WAAW;QAChC,OAAO,OAAO,UAAU,WAAW;UAAC;UAAM;SAAO,GAAG;MACtD;IACF,EAAE;EACJ;CAAE,EAAC;AAEH,OAAO,IAAI,iBAAiB,IAEvB,MAAM,CAAC,yBAAyB,IAAI,CAAC,CAAC,IAAM,EAAE,KAAK,EAAC"}
package/views.ts ADDED
@@ -0,0 +1,29 @@
1
+ // How what this package declares is drawn. `views`, portable for every
2
+ // interface: a comment in a list is a passage (@yaks/render's `passage`), who
3
+ // wrote it, when, what it is on, and the words around what was sought. Its
4
+ // component faces are loaded only by a browser or terminal painter.
5
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
6
+ import type { ComponentRenderer } from 'jsr:@yaks/react@0.2.36'
7
+ import { parse } from '@yaks/query/core'
8
+ import { define, type Registry } from '@yaks/render'
9
+ import { passage } from '@yaks/render/views'
10
+
11
+ let prop = (b: Bundle, comp: string, name: string): unknown =>
12
+ (b[comp] as Record<string, unknown> | undefined)?.[name]
13
+
14
+ /** A comment's `Tile`. */
15
+ export let views: Registry = define([{
16
+ view: 'Tile',
17
+ match: parse('.comment'),
18
+ ...passage({
19
+ texts: (b) => [prop(b, 'doc', 'body'), prop(b, 'doc', 'title')],
20
+ where: (b) => {
21
+ let target = prop(b, 'comment', 'target')
22
+ return typeof target == 'string' ? ['on', target] : undefined
23
+ },
24
+ }),
25
+ }])
26
+
27
+ export let componentViews = (): Promise<
28
+ { renderers: ComponentRenderer<Bundle>[] }
29
+ > => import('./component-views.tsx').then((m) => m.views)
package/views.tsx ADDED
@@ -0,0 +1,3 @@
1
+ /** @jsxRuntime automatic *//** @jsxImportSourceTypes npm:react@19.3.0 *//** @jsxImportSource npm:react@19.3.0 */
2
+ // Keep resolved facet URLs usable while running hosts adopt the .ts export.
3
+ export * from './views.ts'
package/vocab.js ADDED
@@ -0,0 +1,34 @@
1
+ // The component declarations and nothing else, exported as
2
+ // `@yaks/kernel/vocab`. It imports no storage, no SQL and no runtime API, so a
3
+ // browser tab loading this vocabulary loads nothing else with it.
4
+ import { pick } from "@yaks/vocab/runtime";
5
+ import { kernelKeywords } from "./keywords.js";
6
+ import doc from './vocab.json' with {
7
+ type: 'json'
8
+ };
9
+ import manifest from './package.json' with {
10
+ type: 'json'
11
+ };
12
+ export { kernelKeywords };
13
+ /** The kernel vocabulary, as the document `loadVocab` takes. */ export let kernelDoc = doc;
14
+ /** Just `entity{archetype}`, for a program that loads it without the rest of
15
+ * the kernel's components. @yaks/provenance declares the stamps beside it,
16
+ * `created` and `updated`. */ export let spineDoc = pick(kernelDoc, [
17
+ 'entity'
18
+ ], 'spine');
19
+ /** The two marks anything at all can carry — `opened`, somebody looked at it,
20
+ * and `archived`, somebody put it away — for a program that loads `spineDoc`
21
+ * without the rest of the kernel's components and still wants listings to hide
22
+ * what was put away. */ export let marksDoc = pick(kernelDoc, [
23
+ 'opened',
24
+ 'archived'
25
+ ], 'marks');
26
+ /** What this package is: its manifest's description, the one place it is
27
+ * written, which a host stamps on each document here. */ export let description = manifest.description;
28
+ /** Every document this plugin declares. */ export let docs = [
29
+ kernelDoc
30
+ ];
31
+ /** The JSON Schema keywords those documents use. */ export let keywords = [
32
+ kernelKeywords
33
+ ];
34
+ //# sourceMappingURL=vocab.js.map
package/vocab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,+EAA+E;AAC/E,kEAAkE;AAElE,SAAwB,IAAI,mCAAuD;AACnF,SAAS,cAAc,wBAAuB;AAC9C,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,SAAS,cAAc,GAAE;AAEzB,8DAA8D,GAC9D,OAAO,IAAI,YAAsB,IAAe;AAEhD;;4BAE4B,GAC5B,OAAO,IAAI,WAAqB,KAAK,WAAW;EAAC;CAAS,EAAE,SAAQ;AAEpE;;;sBAGsB,GACtB,OAAO,IAAI,WAAqB,KAAK,WAAW;EAAC;EAAU;CAAW,EAAE,SAAQ;AAEhF;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAU,CAAA;AAEzC,kDAAkD,GAClD,OAAO,IAAI,WAAuB;EAAC;CAAe,CAAA"}