@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.
Files changed (115) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +401 -2
  3. package/_dist/comp.d.ts +13 -0
  4. package/_dist/comp.d.ts.map +1 -0
  5. package/_dist/effects.d.ts +22 -0
  6. package/_dist/effects.d.ts.map +1 -0
  7. package/_dist/mod.d.ts +40 -0
  8. package/_dist/mod.d.ts.map +1 -0
  9. package/_dist/name.d.ts +49 -0
  10. package/_dist/name.d.ts.map +1 -0
  11. package/_dist/owed.d.ts +56 -0
  12. package/_dist/owed.d.ts.map +1 -0
  13. package/_dist/part.d.ts +4 -0
  14. package/_dist/part.d.ts.map +1 -0
  15. package/_dist/shipped.d.ts +30 -0
  16. package/_dist/shipped.d.ts.map +1 -0
  17. package/_dist/skill-checkout.d.ts +6 -0
  18. package/_dist/skill-checkout.d.ts.map +1 -0
  19. package/_dist/skill-effects.d.ts +25 -0
  20. package/_dist/skill-effects.d.ts.map +1 -0
  21. package/_dist/skill-mirror-io.d.ts +7 -0
  22. package/_dist/skill-mirror-io.d.ts.map +1 -0
  23. package/_dist/skill-mirror.d.ts +15 -0
  24. package/_dist/skill-mirror.d.ts.map +1 -0
  25. package/_dist/skill-text.d.ts +28 -0
  26. package/_dist/skill-text.d.ts.map +1 -0
  27. package/_dist/skills.d.ts +22 -0
  28. package/_dist/skills.d.ts.map +1 -0
  29. package/_dist/tools.d.ts +9 -0
  30. package/_dist/tools.d.ts.map +1 -0
  31. package/_dist/ui.d.ts +6 -0
  32. package/_dist/ui.d.ts.map +1 -0
  33. package/_dist/views.d.ts +19 -0
  34. package/_dist/views.d.ts.map +1 -0
  35. package/_dist/vocab.d.ts +7 -0
  36. package/_dist/vocab.d.ts.map +1 -0
  37. package/_dist/voice.d.ts +47 -0
  38. package/_dist/voice.d.ts.map +1 -0
  39. package/_dist/worn.d.ts +55 -0
  40. package/_dist/worn.d.ts.map +1 -0
  41. package/carried.js +201 -0
  42. package/carried.js.map +1 -0
  43. package/carried.ts +269 -0
  44. package/comp.js +31 -0
  45. package/comp.js.map +1 -0
  46. package/comp.ts +38 -0
  47. package/deno.json +1 -0
  48. package/desk.js +201 -0
  49. package/desk.js.map +1 -0
  50. package/desk.ts +301 -0
  51. package/effects.js +106 -0
  52. package/effects.js.map +1 -0
  53. package/effects.ts +120 -0
  54. package/files.js +305 -0
  55. package/files.js.map +1 -0
  56. package/files.ts +319 -0
  57. package/inspect.js +66 -0
  58. package/inspect.js.map +1 -0
  59. package/inspect.ts +30 -0
  60. package/mod.js +40 -0
  61. package/mod.js.map +1 -0
  62. package/mod.ts +61 -0
  63. package/name.js +161 -0
  64. package/name.js.map +1 -0
  65. package/name.ts +184 -0
  66. package/owed.js +196 -0
  67. package/owed.js.map +1 -0
  68. package/owed.ts +256 -0
  69. package/package.json +83 -4
  70. package/part.js +4 -0
  71. package/part.js.map +1 -0
  72. package/part.ts +4 -0
  73. package/shipped.js +130 -0
  74. package/shipped.js.map +1 -0
  75. package/shipped.ts +131 -0
  76. package/skill-checkout.js +92 -0
  77. package/skill-checkout.js.map +1 -0
  78. package/skill-checkout.ts +121 -0
  79. package/skill-effects.js +244 -0
  80. package/skill-effects.js.map +1 -0
  81. package/skill-effects.ts +274 -0
  82. package/skill-mirror-io.js +193 -0
  83. package/skill-mirror-io.js.map +1 -0
  84. package/skill-mirror-io.ts +212 -0
  85. package/skill-mirror.js +659 -0
  86. package/skill-mirror.js.map +1 -0
  87. package/skill-mirror.ts +640 -0
  88. package/skill-text.js +158 -0
  89. package/skill-text.js.map +1 -0
  90. package/skill-text.ts +183 -0
  91. package/skills.js +238 -0
  92. package/skills.js.map +1 -0
  93. package/skills.ts +383 -0
  94. package/text.js +59 -0
  95. package/text.js.map +1 -0
  96. package/text.ts +60 -0
  97. package/tools.js +76 -0
  98. package/tools.js.map +1 -0
  99. package/tools.ts +91 -0
  100. package/ui.js +19 -0
  101. package/ui.js.map +1 -0
  102. package/ui.ts +34 -0
  103. package/views.js +27 -0
  104. package/views.js.map +1 -0
  105. package/views.ts +29 -0
  106. package/vocab.js +14 -0
  107. package/vocab.js.map +1 -0
  108. package/vocab.json +270 -0
  109. package/vocab.ts +16 -0
  110. package/voice.js +105 -0
  111. package/voice.js.map +1 -0
  112. package/voice.ts +133 -0
  113. package/worn.js +328 -0
  114. package/worn.js.map +1 -0
  115. package/worn.ts +336 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Jeff Peterson
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,402 @@
1
- # Temporary Holding Version
1
+ # @yaks/persona
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Define human identities and agent instructions in a graph, and assemble an
4
+ agent's instructions into Markdown. The graph stores `person`, `persona` and
5
+ `skill` components alongside document text and relationships. This package
6
+ supplies their schemas and read/render functions, and writes each project's
7
+ personas and skills into its checkout; it opens no database and starts no agent.
8
+
9
+ ```sh
10
+ deno add jsr:@yaks/persona
11
+ ```
12
+
13
+ - `person` — a human being the graph knows, addressable by name.
14
+ - `persona{home, base}` — a set of instructions an agent runs with. The `doc`
15
+ body on the same entity is the instruction text, `home` is the project it
16
+ works for, and `base` is the persona it is worn on, which may be kept in
17
+ another store. The component declares `governed`, meaning it should be
18
+ associated with a project, so [@yaks/project](../project)'s check reports a
19
+ persona no project can reach.
20
+ - `skill{invoke, arguments, paths, fork, options}` — instructions an agent loads
21
+ on demand ([Repository skills](#repository-skills)).
22
+
23
+ A person identifies a human and a persona contains agent instructions. Keeping
24
+ them apart lets provenance fields such as `created.by` identify the actual
25
+ author. What a session wearing a persona is about is the session's, not the
26
+ persona's: a session opened on a topic ([@yaks/topic](../topic)) names it as
27
+ `session.topic` and wears one persona, the oracle, whatever the topic.
28
+
29
+ ## Rendering a persona
30
+
31
+ A persona links to the documents it is built from — a `contains` edge for each
32
+ document included in full, a `reads` edge for each one mentioned by id only —
33
+ and those documents, plus the persona's own body, render as a single markdown
34
+ document: what an agent is given at the top of its context.
35
+
36
+ The example creates an in-memory graph and renders one persona. An entity is a
37
+ record with an id; a bundle is a JSON object containing that entity's
38
+ components. Use a persistent storage adapter instead of `ram` to retain these
39
+ records.
40
+
41
+ ```ts
42
+ import { docDoc } from '@yaks/doc'
43
+ import { graph } from '@yaks/graph'
44
+ import { personaDoc, voice, wear } from '@yaks/persona'
45
+ import { ram } from '@yaks/ram'
46
+ import { loadVocab } from '@yaks/vocab'
47
+
48
+ let vocab = loadVocab([docDoc, personaDoc])
49
+ let storage = ram(vocab)
50
+ let g = graph({ storage, vocab })
51
+ await g.apply([{
52
+ entity: { eid: 'reviewer' },
53
+ persona: {},
54
+ doc: { title: 'Code reviewer', body: 'Check changes against the tests.' },
55
+ }])
56
+ let worn = await wear(storage, vocab)('reviewer')
57
+ if (worn) console.log(voice(vocab)(worn))
58
+ ```
59
+
60
+ `wear(storage, vocab)(eid)` reads a persona by its stored entity id and follows
61
+ its document relationships. It needs only a storage's `read` and `get`
62
+ (`Reads`), so a page can hand it one answered from what the page holds. It
63
+ returns `undefined` if that entity is missing or is not a persona.
64
+ `voice(vocab)(worn)` returns Markdown containing the persona's instructions,
65
+ each included document in full, and a `Reads` list of referenced documents. Load
66
+ @yaks/edge plus the schemas declaring `contains` and `reads` to use those
67
+ relationships. The minimal example has no linked documents.
68
+
69
+ Rendering behavior:
70
+
71
+ Six things this shape decides:
72
+
73
+ - **It returns text.** Where the document goes — `AGENTS.md` in a repo, the
74
+ system prompt of a spawned agent, a card in a browser — is the caller's
75
+ decision. The persona files below are one caller.
76
+ - **A proposal is not said.** A document carrying [@yaks/kernel](../kernel)'s
77
+ `proposed` is left out, by either edge, until a `decided` approves it; a
78
+ declined one stays out. Linking a proposal to a persona files it where it
79
+ belongs without making the persona say it.
80
+ - **A linked entity's words stay where they are.** Its title is `doc.title` and
81
+ its text is `doc.body`, falling back to `content.body` when the doc body is
82
+ empty or absent. A [memory](../memory) marked on a comment or transcript entry
83
+ renders those words in full, just as a memory on a doc does. A linked entity
84
+ needs `doc` or `content`; its kind does not decide whether it is included.
85
+ - **An included persona's documents are included recursively.** Its instruction
86
+ text is included like any other document, and the documents it links to are
87
+ added to the ones this persona links to, so a base persona reaches every
88
+ persona built on top of it and nobody copies its text. A persona linked by
89
+ `reads` is only listed by id.
90
+ - **A contained tool is offered, not said.** A registered tool
91
+ ([@yaks/tools](../tools)' `tool{name}`) that a persona contains, or that a
92
+ persona it includes contains, is in `worn.tools` and never in its text.
93
+ `offer(worn)` names them, and a native session wearing the persona is offered
94
+ those tools and no others ([@yaks/harness](../harness)). A persona containing
95
+ none leaves a session its runner's own tools. `wearing(g, path, as)` is the
96
+ persona an agent wears, chosen or common, whatever its files already say.
97
+ - **A base is worn beneath, wherever it is kept.** A persona with `persona.base`
98
+ is said base first: the base's text and documents, then its own, as `fold`
99
+ says several personas. An edge stays within one store, so the base is named by
100
+ its eid, and `wear(storage, vocab, bases)` reads it from `bases` (by default
101
+ the same storage). That is how one platform persona sits under every space's
102
+ own, read again each time it is worn, with nothing copied into the spaces.
103
+
104
+ At each nesting level, documents are ordered by their edge's `ord` property,
105
+ then by the target entity id. Missing `ord` values sort last. Nested personas
106
+ are read breadth-first for up to eight levels; cycles and repeated inclusions
107
+ are removed. Full inclusion takes precedence over a `reads` reference. This
108
+ stable ordering replaces the legacy materializer's time-decaying score, which
109
+ could change output even without a graph write.
110
+
111
+ ## The persona files
112
+
113
+ A harness started in a checkout reads its instructions from files, so each
114
+ project's personas are written into its checkout:
115
+
116
+ - the persona the project `contains` is `.tasks/AGENTS.md`, which the
117
+ repository's `CLAUDE.md` and `AGENTS.md` link to (for a sub-project with a
118
+ checkout of its own, folded with the common personas above it);
119
+ - every other persona whose `home` is the project, or a sub-project landing in
120
+ its checkout (below), is `.tasks/personas/<name>.md`, which a
121
+ `.claude/agents/<name>.md` links to. `<name>` is the persona's
122
+ [@yaks/alias](../alias) name, or its id; an alias that is itself an id (an old
123
+ number kept when a series was renumbered) is not a name. The file opens with
124
+ the frontmatter a Claude agent file needs (`name`, `description`), and leaves
125
+ out what `AGENTS.md` already says, since the two are read together.
126
+
127
+ Each file is `voice`'s text under a line naming the persona it was generated
128
+ from. The checkout is the main worktree of the project's
129
+ [@yaks/project](../project) `repo` → [@yaks/git](../git) `repository`: the
130
+ `worktree` whose `gitdir` is the repository's `common` directory. A linked
131
+ worktree never gets the files, whoever cut it. An archived project keeps what it
132
+ last had.
133
+
134
+ The files are a write-only [@yaks/mirror](../mirror) binding: the graph owns
135
+ them. A hand edit is put back; one made while the graph also moved is left and
136
+ reported; the file of a renamed or deleted persona is removed. The links in
137
+ `.claude/agents` follow the files: a specialist no link names gets `<name>.md`,
138
+ and a link into `.tasks/personas` naming no current file is removed, so a
139
+ renamed persona's link moves with its file. Anything else in `.claude/agents` is
140
+ left alone. What each file last agreed on is kept in `mirror/personas.json`
141
+ beside the database.
142
+
143
+ `persona_sync` writes them (`check` reports what would change instead). A host
144
+ keeps them current after every write that touches a persona or a document one
145
+ says, when its config asks:
146
+
147
+ ```json
148
+ { "use": "@yaks/persona", "with": { "files": true } }
149
+ ```
150
+
151
+ It is off by default because the paths come from the graph, not the database: a
152
+ host opened on a copy of a graph would write into the checkouts the original
153
+ names.
154
+
155
+ ## A persona a package ships
156
+
157
+ The persona files go from the graph to a checkout. A package may also ship a
158
+ persona as files, which a store keeps the other way round: the files own it.
159
+ Each is a content file ([@yaks/yaml](../yaml)'s `front`): the frontmatter is the
160
+ bundle and the document under it is the `doc` body. One file carries `persona`
161
+ and lists under `contains` the names of the others, in the order it says them;
162
+ each other file is a document it contains. A name is the file's name without
163
+ `.md`.
164
+
165
+ ```md
166
+ ---
167
+ persona: {}
168
+ doc:
169
+ title: Helper
170
+ contains: [tone]
171
+ ---
172
+
173
+ Help.
174
+ ```
175
+
176
+ `shipped(files, eid)` reads the texts, by file name, into the persona's rows:
177
+ the persona, each document, and a `contains` edge to each in order, or a `reads`
178
+ edge to each it lists under `reads`, named by id and title for an agent to open
179
+ (@yaks/harness `readOpen`). `eid` gives the row a name stands for, so the files
180
+ name no entity. A set without exactly one persona, a document the persona does
181
+ not contain, or a name no file holds is refused. `kept(storage, rows)` is what a
182
+ store still needs written to keep them: each row it does not already hold as the
183
+ files say it, and the removal of each `contains` or `reads` edge the persona has
184
+ there that the files no longer say. It writes nothing where the store already
185
+ agrees. Both take texts rather than a directory, so a host without a filesystem
186
+ is handed them when it is built. yaks.app's Operator is worn on one:
187
+ `plugins/yaks.app/persona/`, kept in its directory.
188
+
189
+ ## Repository skills
190
+
191
+ Skills are reusable instructions, not tools. A skill has a stable minted id and
192
+ `skill{invoke, arguments, paths, fork, options}` beside `doc{title, body}` and
193
+ `content{body}`. The title is its folder name, the document body is its short
194
+ description, and the content body is the instructions. Unknown Claude YAML
195
+ fields survive in `options`; parsing does not run or expand them.
196
+
197
+ A `references` edge from the skill to a separate `file{path, root}`
198
+ ([@yaks/file](../file)), rooted in the repository, locates its
199
+ `.claude/skills/<title>/SKILL.md`. The locator uses the existing file identity
200
+ and has no content. Companion files use `file` plus `content`. Renaming a title
201
+ keeps the skill id, moves its companions, and changes the locator only after the
202
+ repository change lands. An unlinked skill remains readable in the graph but
203
+ cannot be exported into a repository.
204
+
205
+ ```ts ignore
206
+ import { loadSkill, skillsAt } from '@yaks/persona/skill-checkout'
207
+ import { syncSkills } from '@yaks/persona/skill-mirror'
208
+
209
+ let catalogue = await skillsAt(graph, sessionCheckout)
210
+ let skill = await loadSkill(graph, 'testing', sessionCheckout)
211
+ let report = await syncSkills(
212
+ graph,
213
+ primaryCheckout,
214
+ '/tmp/skills-baseline.json',
215
+ )
216
+ ```
217
+
218
+ `skillCatalog(graph, repository?)` returns descriptions without instruction
219
+ bodies; `graphSkill(graph, title, repository?)` loads one exact graph skill.
220
+ `repoSkills(graph, repository?)` reads complete graph skills. With a repository,
221
+ it reads only that repository’s instruction bodies and refuses ambiguous
222
+ locators on each selected skill. `skillScope(graph, repository)` returns those
223
+ `skills` and their `places` together for consumers that need both.
224
+ `skillLocation` follows one locator and `skillLocations(graph, skills)` resolves
225
+ a batch of locators together. `skillFiles(graph, repository)` renders
226
+ repository-relative text; `renderFiles(skills, locations, files)` renders an
227
+ already-read snapshot without further graph reads. Everything in
228
+ `@yaks/persona/skills` reads only the graph, so a host without a filesystem (a
229
+ yaks.app space's Operator) loads its skills the same way. `skillsAt` and
230
+ `loadSkill` (`@yaks/persona/skill-checkout`) overlay a session checkout's files
231
+ read-only: local edits, additions and deletions are visible without importing
232
+ them. A missing or ambiguous title is refused. Instructions are loaded by title
233
+ only when needed; discovery needs just titles and descriptions.
234
+
235
+ `syncSkills` uses [@yaks/mirror](../mirror) to reconcile tracked text files in
236
+ the primary checkout with graph values, on whichever branch it has checked out.
237
+ Only current local checkouts are polled. Imports are atomic, attributed and
238
+ guarded against concurrent graph changes. Concurrent file/graph changes are
239
+ conflicts, not last-writer wins. Exports use a clean dedicated linked worktree,
240
+ commit only skills and land before updating the agreement. A dirty primary
241
+ checkout blocks pending exports. A git-common lock serializes manual and
242
+ automatic passes.
243
+
244
+ The host enables this independently of persona files:
245
+
246
+ ```json
247
+ { "use": "@yaks/persona", "with": { "skills": true } }
248
+ ```
249
+
250
+ The awaited `skill_files` effect reconciles graph edits; `skill_watch` polls the
251
+ files continuously with a singleton watcher lease. A poll only stats what a sync
252
+ would read (each root's Git index and HEAD and everything under
253
+ `.claude/skills`) and syncs when that moved, while anything changed within the
254
+ last two seconds (an equal-size rewrite in one timestamp tick moves no stat), or
255
+ when the last sync of a root left a conflict or refusal. Per-root agreements are
256
+ stored under `mirror/skills` beside the configured database. Without a database
257
+ (or with `:memory:`), effects retain agreement bytes in instance memory and
258
+ materialize an owned temporary directory for each awaited handler batch. A live
259
+ watcher keeps that directory until shutdown or failure; cleanup is awaited. They
260
+ never fall back to another host's database environment. This option is off by
261
+ default because repository paths come from the graph.
262
+
263
+ ## What an agent is owed
264
+
265
+ The persona files reach only the checkout a person keeps. An agent's own
266
+ worktree of the same repository has the repository's `AGENTS.md` link but not
267
+ the ignored `.tasks` directory it points into. So a harness starting an agent
268
+ asks what it is owed:
269
+
270
+ ```ts ignore
271
+ import { owed } from '@yaks/persona'
272
+
273
+ let owes = await owed(graph, checkout, [agentsMdText])
274
+ // owes: { source: 'N-1', text: '# N-1 …' } | undefined
275
+ ```
276
+
277
+ `owed(graph, path, files)` finds the project whose repository has a checkout
278
+ holding `path` (the nearest directory at or above it the graph knows as a
279
+ worktree), and returns its common persona (`source` is its id, `text` is
280
+ `voice`'s rendering), unless one of `files` (the text of each instruction file
281
+ the agent's provider reads there) is exactly that persona's file: the same
282
+ banner and the same text the persona files would write now. A stale file, or
283
+ another repository's, leaves the persona owed. The harness gives it through the
284
+ provider's own instruction mechanism and the provider still reads its files. A
285
+ fourth argument says who the agent is: `{ persona }`, a persona id or registered
286
+ name, chooses that persona instead of the checkout's common one (an unknown
287
+ persona is refused); `{ work }`, the task or project the agent works on, makes
288
+ it the common persona of the work's lineage, less what a file there already says
289
+ of the checkout's.
290
+
291
+ A harness that says the persona whole on every ask, instead of once beside the
292
+ files, asks the reverse: `unsaid(graph, path, files, as)` is each of `files` but
293
+ one that is exactly the projection of the persona worn, or of the checkout's
294
+ where the worn one says all of it, which would say the same twice and go stale
295
+ beside it.
296
+
297
+ `carried(graph, path)` is that common persona alone, as `wear` returns it: the
298
+ persona a session started anywhere in the checkout wears (@yaks/session's
299
+ `session_context`).
300
+
301
+ ## Sub-projects
302
+
303
+ A sub-project ([@yaks/project](../project)) hears every common persona along its
304
+ lineage: its own first, if it has one, then each project's above it, folded into
305
+ one document with nothing said twice. One without a persona of its own hears its
306
+ parent's. One without a `repo` of its own lands in its nearest ancestor's
307
+ checkout, so its personas, its common one included, are written there as
308
+ specialists, each saying its home's common persona beside the checkout's
309
+ `AGENTS.md`.
310
+
311
+ ## Names
312
+
313
+ A persona's name is its `doc{title}`, the name alone. `NAMES` are the ones a new
314
+ persona is given: short, plain to say aloud, mostly trees and creatures.
315
+ `pick(eid, taken)` is the first from the entity's own place in them that `taken`
316
+ lacks, and `christened(eid, others)` one clear of the names `others` go by
317
+ (those its people already reach), so personas named in one pass, which cannot
318
+ read each other's, still choose apart. `given(said)` is a name a person typed,
319
+ its spaces closed up, refused when it is empty or longer than `LONGEST` (40)
320
+ characters. `named(said, others)` is a name given as a persona is made: what
321
+ `given` takes, refused when one of `others` already goes by it.
322
+
323
+ `@yaks/persona/ui`'s `NameCard` is where its people change it: a card of the
324
+ kit's parts holding one field, `name`. The host's form holds the card, so where
325
+ the name is sent is the host's (yaks.app's Operator page posts it to `?name`).
326
+
327
+ ## The desk
328
+
329
+ `@yaks/persona/views` draws what agents are given wherever the browsing app
330
+ ([@yaks/browse](../browse)) does, in a browser and a terminal alike, as a
331
+ writer's desk: every persona and skill on one side, the one being written in the
332
+ middle, and what an agent gets on the other.
333
+
334
+ The sidebar offers it as **Context** (`destinations`), at `/?page=context`:
335
+ every persona with the project it works for and every skill with its description
336
+ (`Context.Page`). A field over them finds one by the words of its title and
337
+ description; Enter opens the first, and Escape clears it. What is typed there is
338
+ the person's draft, through the UX host's `drafts` (@yaks/ux).
339
+
340
+ A persona or a skill opens on its `Context` tab: the desk, titles only, the one
341
+ open lit; its Full page in the middle, without the chat a page has beside it;
342
+ and on the right, as wide as a chat beside any page, what an agent gets: a
343
+ session to try it, where the host draws a conversation (`Conversation`; browse's
344
+ chat), and the text it is given. Stacked, as on a phone, the Full page comes
345
+ first and the desk last.
346
+
347
+ The body of its Full page (`Full.Body`, and a card's face, `Card.Context`) is
348
+ where it is written, every part typed into where it shows:
349
+
350
+ - a persona says the project it works for, picked where it stands, then its own
351
+ text; a skill its description, then its instructions;
352
+ - then a list for each relation it carries documents by, headed by the
353
+ relation's name: **Contains** (`contains` edges: for a persona, each said in
354
+ full, in the order an agent is given them, `served`) and **Reads** (`reads`
355
+ edges: each listed by id and title under the text's `## Reads`). Each document
356
+ shows its title over its body, and a click on either types into it in place
357
+ (@yaks/ux's `Edit.Text`, @yaks/inspect's `Words`): nothing to open first, and
358
+ nothing on it drags. A tool it contains is offered to an agent, not said, so
359
+ it is among the page's relationships rather than here;
360
+ - under each list, **+ new document** writes a document with nothing in it yet
361
+ into the list, linked by its relation after the others (`written`), with its
362
+ title open for typing.
363
+
364
+ The **Markdown view** of a persona or a skill (`Markdown`, more specific than
365
+ any doc's, so it is the one browse's Markdown tab draws) is the text an agent
366
+ receives. A persona's is `voice` of `wear`, what `persona_read` returns and a
367
+ session wearing it is given, composed in the page by that same code over what
368
+ the page holds (@yaks/inspect's `useReading`) and composed again whenever a
369
+ write moves anything it read. A skill's is its SKILL.md (`renderSkill`). Either
370
+ is drawn as its source, as written.
371
+
372
+ ## Exports
373
+
374
+ | subpath | what it provides |
375
+ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
376
+ | `.` | `wear`, `voice`, `owed`, `unsaid`, `wearing`, `offer`, `common`, `shipped`, `kept`, the [names](#names), the component names, and the vocabulary document |
377
+ | `./vocab` | the component declarations alone |
378
+ | `./part` | `PART`, what stands between the parts of what an agent is told, importing nothing else |
379
+ | `./tools` | `runs(host)` — `persona_read` returns the Markdown, `persona_sync` writes |
380
+ | `./effects` | `effects(host, {files, skills})` — independently enables persona files and skills |
381
+ | `./skills` | Graph skill reads and read-only checkout views |
382
+ | `./skill-text` | Portable skill parsing, frontmatter and rendering |
383
+ | `./skill-mirror` | `syncSkills`, `skillRoots` — bidirectional landed repository mirror |
384
+ | `./views` | `inspectViews()`, `tabs`, `destinations`, `icons` — the desk, as the browsing app draws it |
385
+ | `./ui` | `NameCard` — where a persona's people change its name |
386
+
387
+ The two edge relations are borrowed rather than invented here: `contains` is
388
+ [@yaks/task](../task)'s and `reads` is [@yaks/kernel](../kernel)'s. A relation
389
+ the composed vocabulary does not declare contributes nothing rather than
390
+ throwing — a graph with no `contains` in it has a persona that includes no
391
+ documents, which is a fair reading of that graph.
392
+
393
+ `host` in `runs(host)` is the process that opened the graph; its config names
394
+ the database the persona files' memory is kept beside. Tool calls supply the
395
+ graph separately.
396
+
397
+ ## Compatibility
398
+
399
+ `.` and `./vocab` run in Deno, Node and the browser — they call no platform API.
400
+ `./views` are Preact components a host mounts through @yaks/inspect's contract,
401
+ and `./ui`'s card is one a host draws in its own form. `./tools` and `./effects`
402
+ write files through @yaks/file.
@@ -0,0 +1,13 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ /** The component that marks a human being. */ export declare let PERSON: string;
3
+ /** The component that marks a persona; the `doc` on the same entity holds
4
+ * the instruction text. */ export declare let PERSONA: string;
5
+ /** The component that marks instructions loaded on demand. */ export declare let SKILL: string;
6
+ /**
7
+ * The persona vocabulary, loaded beside {@link https://jsr.io/@yaks/doc |
8
+ * @yaks/doc}'s and your own: `loadVocab([docDoc, personaDoc, ...mine])`. Every
9
+ * component here is used together with a `doc` — a person has a name, a
10
+ * persona and a skill their instruction text — which is why this document is
11
+ * never loaded without that one.
12
+ */ export declare let personaDoc: VocabDoc;
13
+ //# sourceMappingURL=comp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comp.d.ts","sources":["../comp.ts"],"names":[],"mappings":"AAiBA,cAAc,QAAQ,2BAAgC;AAGtD,4CAA4C,GAC5C,OAAO,YAAI,eAAiB;AAE5B;yBACyB,GACzB,OAAO,YAAI,gBAAmB;AAE9B,4DAA4D,GAC5D,OAAO,YAAI,cAAe;AAE1B;;;;;;CAMC,GACD,OAAO,YAAI,YAAY,SAA0B"}
@@ -0,0 +1,22 @@
1
+ import type { Handlers } from "@yaks/effects";
2
+ import type { Eid } from "@yaks/graph";
3
+ import { type SkillHost, type SkillRuntime } from "./skill-effects.js";
4
+ /** What this plugin reads from its entry in a config. */ export type Options = {
5
+ files?: boolean;
6
+ skills?: boolean;
7
+ };
8
+ /** How long a burst of writes settles before one pass answers all of it. */ export declare let AFTER: number;
9
+ /** Injectable boundaries for tests: the skills' (./skill-effects.ts), and how
10
+ * long a burst settles. */ export type Runtime = SkillRuntime & {
11
+ after?: number;
12
+ };
13
+ type Fired = Parameters<Handlers[string]>;
14
+ /** Whether a write moves the persona files, given the entities the last pass
15
+ * said (none until a pass has been made, and then every write counts). Text or
16
+ * a link counts when it touches what the last pass said, a link that went
17
+ * read by the ends its `edge` had (@yaks/effects `Event.before`); a persona
18
+ * moving always does. A project with a repository put away or brought back
19
+ * does too: the last pass never said it while it was archived, and its
20
+ * checkout is what the files are written into. */ export declare let moves: (e: Fired[0], tx: Fired[1], said: Set<Eid>) => Promise<boolean>;
21
+ /** The code that keeps the persona files current, when `files` is on. */ export declare let effects: (host: SkillHost, options?: Options, runtime?: Runtime) => Handlers;
22
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.d.ts","sources":["../effects.ts"],"names":[],"mappings":"AAuBA,cAAc,QAAQ,6BAAkC;AACxD,cAAoB,GAAG,2BAAgC;AAKvD,SAEE,KAAK,SAAS,EACd,KAAK,YAAY,6BACQ;AAE3B,uDAAuD,GACvD,YAAY;EAAY,QAAQ,OAAO;EAAE,SAAS,OAAO;;AAEzD,0EAA0E,GAC1E,OAAO,YAAI,cAAa;AAExB;yBACyB,GACzB,YAAY,UAAU;EAAiB,QAAQ,MAAM;;KAEhD,QAAQ,WAAW,SAAS,MAAM;AAEvC;;;;;;gDAMgD,GAChD,OAAO,YAAI,QACT,GAAG,MAAM,IACT,IAAI,MAAM,IACV,MAAM,IAAI,SACT,QAAQ,OAAO,EAcjB;AAED,uEAAuE,GACvE,OAAO,YAAI,UACT,MAAM,WACN,UAAS,SACT,UAAS,YACR,SAwCF"}