@yaks/persona 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.
- package/LICENSE +202 -0
- package/README.md +401 -2
- package/_dist/comp.d.ts +13 -0
- package/_dist/comp.d.ts.map +1 -0
- package/_dist/effects.d.ts +22 -0
- package/_dist/effects.d.ts.map +1 -0
- package/_dist/mod.d.ts +40 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/name.d.ts +49 -0
- package/_dist/name.d.ts.map +1 -0
- package/_dist/owed.d.ts +56 -0
- package/_dist/owed.d.ts.map +1 -0
- package/_dist/part.d.ts +4 -0
- package/_dist/part.d.ts.map +1 -0
- package/_dist/shipped.d.ts +30 -0
- package/_dist/shipped.d.ts.map +1 -0
- package/_dist/skill-checkout.d.ts +6 -0
- package/_dist/skill-checkout.d.ts.map +1 -0
- package/_dist/skill-effects.d.ts +25 -0
- package/_dist/skill-effects.d.ts.map +1 -0
- package/_dist/skill-mirror-io.d.ts +7 -0
- package/_dist/skill-mirror-io.d.ts.map +1 -0
- package/_dist/skill-mirror.d.ts +15 -0
- package/_dist/skill-mirror.d.ts.map +1 -0
- package/_dist/skill-text.d.ts +28 -0
- package/_dist/skill-text.d.ts.map +1 -0
- package/_dist/skills.d.ts +22 -0
- package/_dist/skills.d.ts.map +1 -0
- package/_dist/tools.d.ts +9 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/ui.d.ts +6 -0
- package/_dist/ui.d.ts.map +1 -0
- package/_dist/views.d.ts +19 -0
- package/_dist/views.d.ts.map +1 -0
- package/_dist/vocab.d.ts +7 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/voice.d.ts +47 -0
- package/_dist/voice.d.ts.map +1 -0
- package/_dist/worn.d.ts +55 -0
- package/_dist/worn.d.ts.map +1 -0
- package/carried.js +201 -0
- package/carried.js.map +1 -0
- package/carried.ts +269 -0
- package/comp.js +31 -0
- package/comp.js.map +1 -0
- package/comp.ts +38 -0
- package/deno.json +1 -0
- package/desk.js +201 -0
- package/desk.js.map +1 -0
- package/desk.ts +301 -0
- package/effects.js +106 -0
- package/effects.js.map +1 -0
- package/effects.ts +120 -0
- package/files.js +305 -0
- package/files.js.map +1 -0
- package/files.ts +319 -0
- package/inspect.js +66 -0
- package/inspect.js.map +1 -0
- package/inspect.ts +30 -0
- package/mod.js +40 -0
- package/mod.js.map +1 -0
- package/mod.ts +61 -0
- package/name.js +161 -0
- package/name.js.map +1 -0
- package/name.ts +184 -0
- package/owed.js +196 -0
- package/owed.js.map +1 -0
- package/owed.ts +256 -0
- package/package.json +83 -4
- package/part.js +4 -0
- package/part.js.map +1 -0
- package/part.ts +4 -0
- package/shipped.js +130 -0
- package/shipped.js.map +1 -0
- package/shipped.ts +131 -0
- package/skill-checkout.js +92 -0
- package/skill-checkout.js.map +1 -0
- package/skill-checkout.ts +121 -0
- package/skill-effects.js +244 -0
- package/skill-effects.js.map +1 -0
- package/skill-effects.ts +274 -0
- package/skill-mirror-io.js +193 -0
- package/skill-mirror-io.js.map +1 -0
- package/skill-mirror-io.ts +212 -0
- package/skill-mirror.js +659 -0
- package/skill-mirror.js.map +1 -0
- package/skill-mirror.ts +640 -0
- package/skill-text.js +158 -0
- package/skill-text.js.map +1 -0
- package/skill-text.ts +183 -0
- package/skills.js +238 -0
- package/skills.js.map +1 -0
- package/skills.ts +383 -0
- package/text.js +59 -0
- package/text.js.map +1 -0
- package/text.ts +60 -0
- package/tools.js +76 -0
- package/tools.js.map +1 -0
- package/tools.ts +91 -0
- package/ui.js +19 -0
- package/ui.js.map +1 -0
- package/ui.ts +34 -0
- package/views.js +27 -0
- package/views.js.map +1 -0
- package/views.ts +29 -0
- package/vocab.js +14 -0
- package/vocab.js.map +1 -0
- package/vocab.json +270 -0
- package/vocab.ts +16 -0
- package/voice.js +105 -0
- package/voice.js.map +1 -0
- package/voice.ts +133 -0
- package/worn.js +328 -0
- package/worn.js.map +1 -0
- package/worn.ts +336 -0
package/carried.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a persona or a skill gives an agent, typed into where it shows: the
|
|
3
|
+
* body of its Full page (`Full.Body`). A persona says the project it works
|
|
4
|
+
* for, then its own text; a skill its description, then its instructions.
|
|
5
|
+
* Under them come the documents it carries: those it contains (`contains`
|
|
6
|
+
* edges) and those it reads (`reads` edges), in the order an agent is given
|
|
7
|
+
* them. Each shows its title over its body, and a click on either types into
|
|
8
|
+
* it where it stands (@yaks/ux `Edit.Text`): nothing to open first, and
|
|
9
|
+
* nothing on it drags. A tool it contains is offered to an agent, not said,
|
|
10
|
+
* so it is among the page's relationships rather than here.
|
|
11
|
+
*
|
|
12
|
+
* Under each list a press writes a new document into it: one with nothing
|
|
13
|
+
* written yet, linked by that list's relation after the others, its title
|
|
14
|
+
* open for typing.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h } from "react";
|
|
18
|
+
import * as ui from "@yaks/ui";
|
|
19
|
+
import { at, Edit, put, useEdit } from "@yaks/ux";
|
|
20
|
+
import { mention, Words } from "@yaks/inspect";
|
|
21
|
+
import { mint } from "@yaks/graph/identity";
|
|
22
|
+
import { EDGE, link, placed, relations } from "@yaks/edge";
|
|
23
|
+
import { PERSONA } from "./comp.js";
|
|
24
|
+
import { NAMED } from "./voice.js";
|
|
25
|
+
import { CONTAINS, READS, served } from "./worn.js";
|
|
26
|
+
/** How many links from a persona or a skill its page reads. */ export let EDGES = 500;
|
|
27
|
+
let str = (b, name, prop)=>{
|
|
28
|
+
let v = b?.[name]?.[prop];
|
|
29
|
+
return typeof v == 'string' ? v : '';
|
|
30
|
+
};
|
|
31
|
+
let rows = (a)=>a?.rows ?? [];
|
|
32
|
+
let far = (b)=>str(b, EDGE, 'to');
|
|
33
|
+
/** What a persona's or a skill's body asks: the links leaving it. */ export let asks = (e)=>({
|
|
34
|
+
out: `.${EDGE}.from=${e.entity.eid}&*&.limit=${EDGES}`
|
|
35
|
+
});
|
|
36
|
+
// The owner of each list's carried documents' `Edit` state on one page, so
|
|
37
|
+
// the press that writes a new document opens its title before it is drawn.
|
|
38
|
+
// Each list owns its own: a document carried in both shows in both, and a
|
|
39
|
+
// click types into the one clicked, not both, whose focus would fight.
|
|
40
|
+
let owner = (from, tag)=>`carried/${from}/${tag}`;
|
|
41
|
+
/** One carried document: its title over its body, each typed into on a
|
|
42
|
+
* click. */ let Carried = ({ io, end, from, tag })=>{
|
|
43
|
+
let eid = end.entity.eid;
|
|
44
|
+
let titled = at(owner(from, tag), eid, 'doc', 'title');
|
|
45
|
+
let edit = useEdit(eid, 'doc', 'title', {
|
|
46
|
+
at: titled,
|
|
47
|
+
value: str(end, 'doc', 'title')
|
|
48
|
+
});
|
|
49
|
+
return /*#__PURE__*/ h(ui.Doc, {
|
|
50
|
+
mod: io.edits ? 'typed' : undefined,
|
|
51
|
+
'data-carried': eid
|
|
52
|
+
}, /*#__PURE__*/ h(ui.Doc.Title, {
|
|
53
|
+
onClick: io.edits && !edit.open ? edit.begin : undefined
|
|
54
|
+
}, /*#__PURE__*/ h(Edit.Text, {
|
|
55
|
+
e: end,
|
|
56
|
+
comp: 'doc',
|
|
57
|
+
prop: 'title',
|
|
58
|
+
at: titled,
|
|
59
|
+
inline: true,
|
|
60
|
+
readOnly: !io.edits
|
|
61
|
+
})), /*#__PURE__*/ h(Words, {
|
|
62
|
+
io,
|
|
63
|
+
e: end,
|
|
64
|
+
comp: 'doc',
|
|
65
|
+
prop: 'body',
|
|
66
|
+
at: at(owner(from, tag), eid, 'doc', 'body'),
|
|
67
|
+
click: true
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
/** The bundles that write a new document `eid` into `from`'s list of
|
|
71
|
+
* `links` by `tag`, after the others. */ /// let doc = written('p', 'contains', [], 'd')
|
|
72
|
+
/// doc[0] -> { entity: { eid: 'd' }, doc: { title: '', body: '' } }
|
|
73
|
+
/// doc[1].edge -> { from: 'p', to: 'd', ord: 1 }
|
|
74
|
+
export let written = (from, tag, links, eid)=>[
|
|
75
|
+
{
|
|
76
|
+
entity: {
|
|
77
|
+
eid
|
|
78
|
+
},
|
|
79
|
+
doc: {
|
|
80
|
+
title: '',
|
|
81
|
+
body: ''
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
...placed(links, link(from, tag, eid), links.length)
|
|
85
|
+
];
|
|
86
|
+
/** One list of what it carries, under its heading: each document typed into
|
|
87
|
+
* where it shows, and the press that writes a new one into it. */ let List = ({ io, from, tag, heading, sub, links, ends })=>{
|
|
88
|
+
let held = new Map(rows(ends).map((b)=>[
|
|
89
|
+
b.entity.eid,
|
|
90
|
+
b
|
|
91
|
+
]));
|
|
92
|
+
let docs = [
|
|
93
|
+
...new Set(links.map(far))
|
|
94
|
+
].map((to)=>held.get(to)).filter((b)=>!!b?.doc);
|
|
95
|
+
let write = ()=>{
|
|
96
|
+
let eid = mint();
|
|
97
|
+
io.set(put(at(owner(from, tag), eid, 'doc', 'title'), {
|
|
98
|
+
open: true
|
|
99
|
+
}));
|
|
100
|
+
void io.apply(written(from, tag, links, eid));
|
|
101
|
+
};
|
|
102
|
+
return /*#__PURE__*/ h(ui.Section, {
|
|
103
|
+
'data-section': heading
|
|
104
|
+
}, /*#__PURE__*/ h(ui.Section.Title, {}, heading, /*#__PURE__*/ h(ui.Section.Count, {}, String(docs.length))), /*#__PURE__*/ h(ui.Section.Sub, {}, sub), ...docs.map((end)=>/*#__PURE__*/ h(Carried, {
|
|
105
|
+
key: end.entity.eid,
|
|
106
|
+
io,
|
|
107
|
+
end,
|
|
108
|
+
from,
|
|
109
|
+
tag
|
|
110
|
+
})), !docs.length ? links.length && !ends?.ready ? /*#__PURE__*/ h(ui.Loading, {}) : /*#__PURE__*/ h(ui.Rows.More, {}, 'none yet') : null, io.edits ? /*#__PURE__*/ h(ui.Button, {
|
|
111
|
+
type: 'button',
|
|
112
|
+
mod: 'add',
|
|
113
|
+
'data-write': tag,
|
|
114
|
+
onClick: write
|
|
115
|
+
}, '+ new document') : null);
|
|
116
|
+
};
|
|
117
|
+
/** What a persona or a skill carries: a list for each relation it carries
|
|
118
|
+
* documents by, with what each says to an agent. */ let Lists = ({ e, io, got, subs })=>{
|
|
119
|
+
let from = e.entity.eid;
|
|
120
|
+
let tags = relations(io.vocab);
|
|
121
|
+
let out = rows(got.out).filter(far);
|
|
122
|
+
let ids = [
|
|
123
|
+
...new Set(out.map(far))
|
|
124
|
+
];
|
|
125
|
+
let ends = io.ask(ids.length ? {
|
|
126
|
+
ends: `.entity.eid=${ids.join(',')}&*`
|
|
127
|
+
} : {}).ends;
|
|
128
|
+
return /*#__PURE__*/ h('div', {}, ...[
|
|
129
|
+
CONTAINS,
|
|
130
|
+
READS
|
|
131
|
+
].filter((rel)=>tags[rel]).map((rel)=>/*#__PURE__*/ h(List, {
|
|
132
|
+
key: rel,
|
|
133
|
+
io,
|
|
134
|
+
from,
|
|
135
|
+
tag: tags[rel],
|
|
136
|
+
heading: rel.charAt(0).toUpperCase() + rel.slice(1),
|
|
137
|
+
sub: subs[rel],
|
|
138
|
+
links: out.filter((b)=>b[tags[rel]]).toSorted(served),
|
|
139
|
+
ends
|
|
140
|
+
})));
|
|
141
|
+
};
|
|
142
|
+
/** A persona's body: the project it works for, its own text, then what it
|
|
143
|
+
* carries. */ export let PersonaBody = (p)=>{
|
|
144
|
+
let { e, io } = p;
|
|
145
|
+
let home = str(e, PERSONA, 'home');
|
|
146
|
+
return /*#__PURE__*/ h('div', {
|
|
147
|
+
'data-body': e.entity.eid
|
|
148
|
+
}, /*#__PURE__*/ h(ui.Body, {
|
|
149
|
+
mod: 'short'
|
|
150
|
+
}, 'works for ', home ? null : 'no project ', home || io.edits ? /*#__PURE__*/ h(Edit, {
|
|
151
|
+
e,
|
|
152
|
+
comp: PERSONA,
|
|
153
|
+
prop: 'home',
|
|
154
|
+
editable: io.edits,
|
|
155
|
+
handle: true,
|
|
156
|
+
name: 'project',
|
|
157
|
+
show: (_, v)=>typeof v == 'string' && v ? mention(io, v) : null
|
|
158
|
+
}) : null), /*#__PURE__*/ h(Words, {
|
|
159
|
+
io,
|
|
160
|
+
e,
|
|
161
|
+
comp: 'doc',
|
|
162
|
+
prop: 'body',
|
|
163
|
+
click: true
|
|
164
|
+
}), /*#__PURE__*/ h(Lists, {
|
|
165
|
+
...p,
|
|
166
|
+
subs: {
|
|
167
|
+
[CONTAINS]: 'each said in full to an agent wearing it, in this order; a tool it contains is offered to that agent, not said',
|
|
168
|
+
[READS]: `each listed by id and title under “${NAMED}” at the end of its text, for an agent to ask for`
|
|
169
|
+
}
|
|
170
|
+
}));
|
|
171
|
+
};
|
|
172
|
+
/** A skill's body: its description and its instructions, as an agent loads
|
|
173
|
+
* them, then what it carries. */ export let SkillBody = (p)=>{
|
|
174
|
+
let { e, io } = p;
|
|
175
|
+
return /*#__PURE__*/ h('div', {
|
|
176
|
+
'data-body': e.entity.eid
|
|
177
|
+
}, /*#__PURE__*/ h(Words, {
|
|
178
|
+
io,
|
|
179
|
+
e,
|
|
180
|
+
comp: 'doc',
|
|
181
|
+
prop: 'body',
|
|
182
|
+
empty: 'no description yet',
|
|
183
|
+
click: true
|
|
184
|
+
}), /*#__PURE__*/ h(ui.Section, {
|
|
185
|
+
'data-section': 'Instructions'
|
|
186
|
+
}, /*#__PURE__*/ h(ui.Section.Title, {}, 'Instructions'), /*#__PURE__*/ h(Words, {
|
|
187
|
+
io,
|
|
188
|
+
e,
|
|
189
|
+
comp: 'content',
|
|
190
|
+
prop: 'body',
|
|
191
|
+
empty: 'none are written yet',
|
|
192
|
+
click: true
|
|
193
|
+
})), /*#__PURE__*/ h(Lists, {
|
|
194
|
+
...p,
|
|
195
|
+
subs: {
|
|
196
|
+
[CONTAINS]: 'the documents it contains, in order',
|
|
197
|
+
[READS]: 'the documents it reads'
|
|
198
|
+
}
|
|
199
|
+
}));
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=carried.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AChB,qBAAO,EACL,OACA;IAAE,aAAa,EAAE,MAAM,CAAC,GAAG;EAAC,iBAC5B,EAAE,OAAO;IACP;IACA;IACA,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;EACT,kBACA,EACE,GAAG,OAAO,EACV;IAAE,gBAAgB;EAAe,iBACjC,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,+BACxB,EAAE,OAAO;IACP;IACA;IACA,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;EACT,mBAEF,EAAE,OAAO;IACP,GAAG,CAAC;IACJ,MAAM;MACJ,CAAC,SAAS,EAAE;MACZ,CAAC,MAAM,EAAE;IACX;EACF;AAEJ,EAAC"}
|
package/carried.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a persona or a skill gives an agent, typed into where it shows: the
|
|
3
|
+
* body of its Full page (`Full.Body`). A persona says the project it works
|
|
4
|
+
* for, then its own text; a skill its description, then its instructions.
|
|
5
|
+
* Under them come the documents it carries: those it contains (`contains`
|
|
6
|
+
* edges) and those it reads (`reads` edges), in the order an agent is given
|
|
7
|
+
* them. Each shows its title over its body, and a click on either types into
|
|
8
|
+
* it where it stands (@yaks/ux `Edit.Text`): nothing to open first, and
|
|
9
|
+
* nothing on it drags. A tool it contains is offered to an agent, not said,
|
|
10
|
+
* so it is among the page's relationships rather than here.
|
|
11
|
+
*
|
|
12
|
+
* Under each list a press writes a new document into it: one with nothing
|
|
13
|
+
* written yet, linked by that list's relation after the others, its title
|
|
14
|
+
* open for typing.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, type JSX, type ReactNode } from 'react'
|
|
20
|
+
import * as ui from '@yaks/ui'
|
|
21
|
+
import { at, Edit, put, useEdit } from '@yaks/ux'
|
|
22
|
+
import {
|
|
23
|
+
type Answer,
|
|
24
|
+
type Asks,
|
|
25
|
+
type Bundle,
|
|
26
|
+
type Io,
|
|
27
|
+
mention,
|
|
28
|
+
type Props,
|
|
29
|
+
Words,
|
|
30
|
+
} from '@yaks/inspect'
|
|
31
|
+
import { mint } from '@yaks/graph/identity'
|
|
32
|
+
import { EDGE, link, placed, relations } from '@yaks/edge'
|
|
33
|
+
import { PERSONA } from './comp.js'
|
|
34
|
+
import { NAMED } from './voice.js'
|
|
35
|
+
import { CONTAINS, READS, served } from './worn.js'
|
|
36
|
+
|
|
37
|
+
/** How many links from a persona or a skill its page reads. */
|
|
38
|
+
export let EDGES = 500
|
|
39
|
+
|
|
40
|
+
type Comp = Record<string, unknown>
|
|
41
|
+
let str = (b: Bundle | undefined, name: string, prop: string): string => {
|
|
42
|
+
let v = (b?.[name] as Comp | undefined)?.[prop]
|
|
43
|
+
return typeof v == 'string' ? v : ''
|
|
44
|
+
}
|
|
45
|
+
let rows = (a?: Answer): Bundle[] => a?.rows ?? []
|
|
46
|
+
let far = (b: Bundle): string => str(b, EDGE, 'to')
|
|
47
|
+
|
|
48
|
+
/** What a persona's or a skill's body asks: the links leaving it. */
|
|
49
|
+
export let asks = (e: Bundle): Asks => ({
|
|
50
|
+
out: `.${EDGE}.from=${e.entity.eid}&*&.limit=${EDGES}`,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
// The owner of each list's carried documents' `Edit` state on one page, so
|
|
54
|
+
// the press that writes a new document opens its title before it is drawn.
|
|
55
|
+
// Each list owns its own: a document carried in both shows in both, and a
|
|
56
|
+
// click types into the one clicked, not both, whose focus would fight.
|
|
57
|
+
let owner = (from: string, tag: string) => `carried/${from}/${tag}`
|
|
58
|
+
|
|
59
|
+
/** One carried document: its title over its body, each typed into on a
|
|
60
|
+
* click. */
|
|
61
|
+
let Carried = (
|
|
62
|
+
{ io, end, from, tag }: { io: Io; end: Bundle; from: string; tag: string },
|
|
63
|
+
): JSX.Element => {
|
|
64
|
+
let eid = end.entity.eid
|
|
65
|
+
let titled = at(owner(from, tag), eid, 'doc', 'title')
|
|
66
|
+
let edit = useEdit(eid, 'doc', 'title', {
|
|
67
|
+
at: titled,
|
|
68
|
+
value: str(end, 'doc', 'title'),
|
|
69
|
+
})
|
|
70
|
+
return h(
|
|
71
|
+
ui.Doc,
|
|
72
|
+
{ mod: io.edits ? 'typed' : undefined, 'data-carried': eid },
|
|
73
|
+
h(
|
|
74
|
+
ui.Doc.Title,
|
|
75
|
+
{ onClick: io.edits && !edit.open ? edit.begin : undefined },
|
|
76
|
+
h(Edit.Text, {
|
|
77
|
+
e: end,
|
|
78
|
+
comp: 'doc',
|
|
79
|
+
prop: 'title',
|
|
80
|
+
at: titled,
|
|
81
|
+
inline: true,
|
|
82
|
+
readOnly: !io.edits,
|
|
83
|
+
}),
|
|
84
|
+
),
|
|
85
|
+
h(Words, {
|
|
86
|
+
io,
|
|
87
|
+
e: end,
|
|
88
|
+
comp: 'doc',
|
|
89
|
+
prop: 'body',
|
|
90
|
+
at: at(owner(from, tag), eid, 'doc', 'body'),
|
|
91
|
+
click: true,
|
|
92
|
+
}),
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The bundles that write a new document `eid` into `from`'s list of
|
|
97
|
+
* `links` by `tag`, after the others. */
|
|
98
|
+
/// let doc = written('p', 'contains', [], 'd')
|
|
99
|
+
/// doc[0] -> { entity: { eid: 'd' }, doc: { title: '', body: '' } }
|
|
100
|
+
/// doc[1].edge -> { from: 'p', to: 'd', ord: 1 }
|
|
101
|
+
export let written = (
|
|
102
|
+
from: string,
|
|
103
|
+
tag: string,
|
|
104
|
+
links: Bundle[],
|
|
105
|
+
eid: string,
|
|
106
|
+
): Bundle[] => [
|
|
107
|
+
{ entity: { eid }, doc: { title: '', body: '' } },
|
|
108
|
+
...placed(links, link(from, tag, eid), links.length),
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
/** One list of what it carries, under its heading: each document typed into
|
|
112
|
+
* where it shows, and the press that writes a new one into it. */
|
|
113
|
+
let List = (
|
|
114
|
+
{ io, from, tag, heading, sub, links, ends }: {
|
|
115
|
+
io: Io
|
|
116
|
+
from: string
|
|
117
|
+
tag: string
|
|
118
|
+
heading: string
|
|
119
|
+
sub: ReactNode
|
|
120
|
+
links: Bundle[]
|
|
121
|
+
ends?: Answer
|
|
122
|
+
},
|
|
123
|
+
): JSX.Element => {
|
|
124
|
+
let held = new Map(rows(ends).map((b) => [b.entity.eid, b]))
|
|
125
|
+
let docs = [...new Set(links.map(far))]
|
|
126
|
+
.map((to) => held.get(to))
|
|
127
|
+
.filter((b): b is Bundle => !!b?.doc)
|
|
128
|
+
let write = () => {
|
|
129
|
+
let eid = mint()
|
|
130
|
+
io.set(put(at(owner(from, tag), eid, 'doc', 'title'), { open: true }))
|
|
131
|
+
void io.apply(written(from, tag, links, eid))
|
|
132
|
+
}
|
|
133
|
+
return h(
|
|
134
|
+
ui.Section,
|
|
135
|
+
{ 'data-section': heading },
|
|
136
|
+
h(
|
|
137
|
+
ui.Section.Title,
|
|
138
|
+
{},
|
|
139
|
+
heading,
|
|
140
|
+
h(ui.Section.Count, {}, String(docs.length)),
|
|
141
|
+
),
|
|
142
|
+
h(ui.Section.Sub, {}, sub),
|
|
143
|
+
...docs.map((end) =>
|
|
144
|
+
h(Carried, { key: end.entity.eid, io, end, from, tag })
|
|
145
|
+
),
|
|
146
|
+
!docs.length
|
|
147
|
+
? links.length && !ends?.ready
|
|
148
|
+
? h(ui.Loading, {})
|
|
149
|
+
: h(ui.Rows.More, {}, 'none yet')
|
|
150
|
+
: null,
|
|
151
|
+
io.edits
|
|
152
|
+
? h(ui.Button, {
|
|
153
|
+
type: 'button',
|
|
154
|
+
mod: 'add',
|
|
155
|
+
'data-write': tag,
|
|
156
|
+
onClick: write,
|
|
157
|
+
}, '+ new document')
|
|
158
|
+
: null,
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** What a persona or a skill carries: a list for each relation it carries
|
|
163
|
+
* documents by, with what each says to an agent. */
|
|
164
|
+
let Lists = (
|
|
165
|
+
{ e, io, got, subs }: Props & {
|
|
166
|
+
subs: Record<string, ReactNode>
|
|
167
|
+
},
|
|
168
|
+
): JSX.Element => {
|
|
169
|
+
let from = e.entity.eid
|
|
170
|
+
let tags = relations(io.vocab)
|
|
171
|
+
let out = rows(got.out).filter(far)
|
|
172
|
+
let ids = [...new Set(out.map(far))]
|
|
173
|
+
let ends = io.ask(
|
|
174
|
+
ids.length ? { ends: `.entity.eid=${ids.join(',')}&*` } : {},
|
|
175
|
+
).ends
|
|
176
|
+
return h(
|
|
177
|
+
'div',
|
|
178
|
+
{},
|
|
179
|
+
...[CONTAINS, READS].filter((rel) => tags[rel]).map((rel) =>
|
|
180
|
+
h(List, {
|
|
181
|
+
key: rel,
|
|
182
|
+
io,
|
|
183
|
+
from,
|
|
184
|
+
tag: tags[rel],
|
|
185
|
+
heading: rel.charAt(0).toUpperCase() + rel.slice(1),
|
|
186
|
+
sub: subs[rel],
|
|
187
|
+
links: out.filter((b) => b[tags[rel]]).toSorted(served),
|
|
188
|
+
ends,
|
|
189
|
+
})
|
|
190
|
+
),
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** A persona's body: the project it works for, its own text, then what it
|
|
195
|
+
* carries. */
|
|
196
|
+
export let PersonaBody = (p: Props): JSX.Element => {
|
|
197
|
+
let { e, io } = p
|
|
198
|
+
let home = str(e, PERSONA, 'home')
|
|
199
|
+
return h(
|
|
200
|
+
'div',
|
|
201
|
+
{ 'data-body': e.entity.eid },
|
|
202
|
+
h(
|
|
203
|
+
ui.Body,
|
|
204
|
+
{ mod: 'short' },
|
|
205
|
+
'works for ',
|
|
206
|
+
home ? null : 'no project ',
|
|
207
|
+
home || io.edits
|
|
208
|
+
? h(Edit, {
|
|
209
|
+
e,
|
|
210
|
+
comp: PERSONA,
|
|
211
|
+
prop: 'home',
|
|
212
|
+
editable: io.edits,
|
|
213
|
+
handle: true,
|
|
214
|
+
name: 'project',
|
|
215
|
+
show: (_: string | null, v: unknown) =>
|
|
216
|
+
typeof v == 'string' && v ? mention(io, v) : null,
|
|
217
|
+
})
|
|
218
|
+
: null,
|
|
219
|
+
),
|
|
220
|
+
h(Words, { io, e, comp: 'doc', prop: 'body', click: true }),
|
|
221
|
+
h(Lists, {
|
|
222
|
+
...p,
|
|
223
|
+
subs: {
|
|
224
|
+
[CONTAINS]:
|
|
225
|
+
'each said in full to an agent wearing it, in this order; a tool it contains is offered to that agent, not said',
|
|
226
|
+
[READS]:
|
|
227
|
+
`each listed by id and title under “${NAMED}” at the end of its text, for an agent to ask for`,
|
|
228
|
+
},
|
|
229
|
+
}),
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** A skill's body: its description and its instructions, as an agent loads
|
|
234
|
+
* them, then what it carries. */
|
|
235
|
+
export let SkillBody = (p: Props): JSX.Element => {
|
|
236
|
+
let { e, io } = p
|
|
237
|
+
return h(
|
|
238
|
+
'div',
|
|
239
|
+
{ 'data-body': e.entity.eid },
|
|
240
|
+
h(Words, {
|
|
241
|
+
io,
|
|
242
|
+
e,
|
|
243
|
+
comp: 'doc',
|
|
244
|
+
prop: 'body',
|
|
245
|
+
empty: 'no description yet',
|
|
246
|
+
click: true,
|
|
247
|
+
}),
|
|
248
|
+
h(
|
|
249
|
+
ui.Section,
|
|
250
|
+
{ 'data-section': 'Instructions' },
|
|
251
|
+
h(ui.Section.Title, {}, 'Instructions'),
|
|
252
|
+
h(Words, {
|
|
253
|
+
io,
|
|
254
|
+
e,
|
|
255
|
+
comp: 'content',
|
|
256
|
+
prop: 'body',
|
|
257
|
+
empty: 'none are written yet',
|
|
258
|
+
click: true,
|
|
259
|
+
}),
|
|
260
|
+
),
|
|
261
|
+
h(Lists, {
|
|
262
|
+
...p,
|
|
263
|
+
subs: {
|
|
264
|
+
[CONTAINS]: 'the documents it contains, in order',
|
|
265
|
+
[READS]: 'the documents it reads',
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
)
|
|
269
|
+
}
|
package/comp.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The components this package ships, and the names its own code refers to them
|
|
2
|
+
// by.
|
|
3
|
+
//
|
|
4
|
+
// person{} a human being, as this graph knows them
|
|
5
|
+
// persona{home} instructions an agent runs with — the `doc` body on the
|
|
6
|
+
// same entity is the instruction text
|
|
7
|
+
// skill{invoke, arguments, paths, fork, options}
|
|
8
|
+
// instructions loaded on demand
|
|
9
|
+
//
|
|
10
|
+
// The declarations themselves are in `./vocab.json` — plain JSON Schema,
|
|
11
|
+
// readable by anything that reads JSON. This file re-exports that document
|
|
12
|
+
// under the name callers import, and keeps the explanation of why it is shaped
|
|
13
|
+
// the way it is.
|
|
14
|
+
//
|
|
15
|
+
// An agent is not a person: a persona is what an agent runs with. Keeping the
|
|
16
|
+
// two apart is what makes an author stamp worth reading.
|
|
17
|
+
import doc from './vocab.json' with {
|
|
18
|
+
type: 'json'
|
|
19
|
+
};
|
|
20
|
+
/** The component that marks a human being. */ export let PERSON = 'person';
|
|
21
|
+
/** The component that marks a persona; the `doc` on the same entity holds
|
|
22
|
+
* the instruction text. */ export let PERSONA = 'persona';
|
|
23
|
+
/** The component that marks instructions loaded on demand. */ export let SKILL = 'skill';
|
|
24
|
+
/**
|
|
25
|
+
* The persona vocabulary, loaded beside {@link https://jsr.io/@yaks/doc |
|
|
26
|
+
* @yaks/doc}'s and your own: `loadVocab([docDoc, personaDoc, ...mine])`. Every
|
|
27
|
+
* component here is used together with a `doc` — a person has a name, a
|
|
28
|
+
* persona and a skill their instruction text — which is why this document is
|
|
29
|
+
* never loaded without that one.
|
|
30
|
+
*/ export let personaDoc = doc;
|
|
31
|
+
//# sourceMappingURL=comp.js.map
|
package/comp.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comp.js","sources":["./comp.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,MAAM;AACN,EAAE;AACF,8DAA8D;AAC9D,8EAA8E;AAC9E,0DAA0D;AAC1D,mDAAmD;AACnD,oDAAoD;AACpD,EAAE;AACF,yEAAyE;AACzE,2EAA2E;AAC3E,+EAA+E;AAC/E,iBAAiB;AACjB,EAAE;AACF,8EAA8E;AAC9E,yDAAyD;AAGzD,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AAEpD,4CAA4C,GAC5C,OAAO,IAAI,SAAS,SAAQ;AAE5B;yBACyB,GACzB,OAAO,IAAI,UAAU,UAAS;AAE9B,4DAA4D,GAC5D,OAAO,IAAI,QAAQ,QAAO;AAE1B;;;;;;CAMC,GACD,OAAO,IAAI,aAAuB,IAAe"}
|
package/comp.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// The components this package ships, and the names its own code refers to them
|
|
2
|
+
// by.
|
|
3
|
+
//
|
|
4
|
+
// person{} a human being, as this graph knows them
|
|
5
|
+
// persona{home} instructions an agent runs with — the `doc` body on the
|
|
6
|
+
// same entity is the instruction text
|
|
7
|
+
// skill{invoke, arguments, paths, fork, options}
|
|
8
|
+
// instructions loaded on demand
|
|
9
|
+
//
|
|
10
|
+
// The declarations themselves are in `./vocab.json` — plain JSON Schema,
|
|
11
|
+
// readable by anything that reads JSON. This file re-exports that document
|
|
12
|
+
// under the name callers import, and keeps the explanation of why it is shaped
|
|
13
|
+
// the way it is.
|
|
14
|
+
//
|
|
15
|
+
// An agent is not a person: a persona is what an agent runs with. Keeping the
|
|
16
|
+
// two apart is what makes an author stamp worth reading.
|
|
17
|
+
|
|
18
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
19
|
+
import doc from './vocab.json' with { type: 'json' }
|
|
20
|
+
|
|
21
|
+
/** The component that marks a human being. */
|
|
22
|
+
export let PERSON = 'person'
|
|
23
|
+
|
|
24
|
+
/** The component that marks a persona; the `doc` on the same entity holds
|
|
25
|
+
* the instruction text. */
|
|
26
|
+
export let PERSONA = 'persona'
|
|
27
|
+
|
|
28
|
+
/** The component that marks instructions loaded on demand. */
|
|
29
|
+
export let SKILL = 'skill'
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The persona vocabulary, loaded beside {@link https://jsr.io/@yaks/doc |
|
|
33
|
+
* @yaks/doc}'s and your own: `loadVocab([docDoc, personaDoc, ...mine])`. Every
|
|
34
|
+
* component here is used together with a `doc` — a person has a name, a
|
|
35
|
+
* persona and a skill their instruction text — which is why this document is
|
|
36
|
+
* never loaded without that one.
|
|
37
|
+
*/
|
|
38
|
+
export let personaDoc: VocabDoc = doc as VocabDoc
|
package/deno.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"publish":{"exclude":["**/*_test.ts","./testing.ts"]},"name":"@yaks/persona","version":"0.2.36","license":"Apache-2.0","description":"Who is acting and with what instructions — the people a graph knows, the personas an agent runs with, the skills it loads on demand, and a persona rendered as one markdown document.","exports":{".":"./mod.ts","./vocab":"./vocab.ts","./name":"./name.ts","./part":"./part.ts","./tools":"./tools.ts","./effects":"./effects.ts","./skills":"./skills.ts","./skill-checkout":"./skill-checkout.ts","./skill-mirror":"./skill-mirror.ts","./skill-text":"./skill-text.ts","./views":"./views.ts","./ui":"./ui.ts"},"imports":{"@yaks/persona":"./mod.ts","@yaks/persona/vocab":"./vocab.ts","@yaks/persona/name":"./name.ts","@yaks/persona/part":"./part.ts","@yaks/persona/tools":"./tools.ts","@yaks/persona/effects":"./effects.ts","@yaks/persona/skills":"./skills.ts","@yaks/persona/skill-checkout":"./skill-checkout.ts","@yaks/persona/skill-mirror":"./skill-mirror.ts","@yaks/persona/skill-text":"./skill-text.ts","@yaks/persona/views":"./views.ts","@yaks/persona/ui":"./ui.ts"}}
|