@fungi.computer/shiitake-extensions 0.10.2 → 0.11.1

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.
@@ -249,5 +249,5 @@ export function createConversationAgents(storage) {
249
249
  export function oysterAgentExtensions(source, skills) {
250
250
  return botanicalExtensionsWithSubagents(skills === undefined
251
251
  ? botanicalAgentExtensions
252
- : botanicalExtensionsWithSkillSource(botanicalAgentExtensions, skills.source, { empty: skills.empty, scanOnStart: false }), source);
252
+ : botanicalExtensionsWithSkillSource(botanicalAgentExtensions, skills.source, { empty: skills.empty }), source);
253
253
  }
package/dist/roster.d.ts CHANGED
@@ -12,7 +12,6 @@ export declare function botanicalExtensionsWithSubagents(base: ExtensionRosterV0
12
12
  /** Add read-only skill discovery over `source` to any roster. */
13
13
  export declare function botanicalExtensionsWithSkillSource(base: ExtensionRosterV0, source: SkillSource, options?: Readonly<{
14
14
  empty?: string;
15
- scanOnStart?: boolean;
16
15
  }>): ExtensionRosterV0;
17
16
  /** A host with a SkillSource grants read-only skill discovery for its own runs. */
18
17
  export declare function botanicalExtensionsWithSkills(source: SkillSource): ExtensionRosterV0;
@@ -3,14 +3,8 @@ import type { SkillSource } from "./source.js";
3
3
  /** Host admission for skill discovery prompts, load tools and human controls. */
4
4
  export declare const skillsGrant: ExtensionGrantV0;
5
5
  /** Skills use only the generic prompt and run-tools doors; the host owns files. */
6
- export declare function skillsExtension({ source, empty, scanOnStart, }: Readonly<{
6
+ export declare function skillsExtension({ source, empty, }: Readonly<{
7
7
  source: SkillSource;
8
8
  /** What to say when no skills are installed, where the host keeps them. */
9
9
  empty?: string | undefined;
10
- /**
11
- * Scan when the run activates. A host whose source acquires a Computer
12
- * leaves this off so addressing a Session acquires nothing; the first
13
- * model request then takes the scan.
14
- */
15
- scanOnStart?: boolean | undefined;
16
10
  }>): RosteredExtensionV0;
@@ -164,12 +164,13 @@ function reportDiagnostics(catalog) {
164
164
  })), { discard: true });
165
165
  }
166
166
  /** Skills use only the generic prompt and run-tools doors; the host owns files. */
167
- export function skillsExtension({ source, empty, scanOnStart = true, }) {
167
+ export function skillsExtension({ source, empty, }) {
168
168
  // Commands run inside a synchronous core transaction, so /skills shows the
169
- // latest discovery: taken at activation and again before each model request.
170
- let latest;
171
- const discover = Effect.promise((signal) => source.catalog(signal)).pipe(Effect.tap((found) => Effect.sync(() => {
172
- latest = found;
169
+ // latest discovery for its Session, taken before each model request. A
170
+ // source may answer differently per Session, so no Session sees another's.
171
+ const latest = new Map();
172
+ const discover = (sessionId) => Effect.promise((signal) => source.catalog({ sessionId, signal })).pipe(Effect.tap((found) => Effect.sync(() => {
173
+ latest.set(sessionId, found);
173
174
  })));
174
175
  return defineExtension({ id, version: "1.1.0" })
175
176
  .config(empty === undefined ? config : { ...config, empty })
@@ -190,30 +191,32 @@ export function skillsExtension({ source, empty, scanOnStart = true, }) {
190
191
  commands: {
191
192
  specs: commands,
192
193
  handlers: () => ({
193
- skills: ({ input }) => Effect.sync(() => latest === undefined
194
- ? done({
195
- type: "info",
196
- message: "Skill discovery has not finished yet.",
197
- })
198
- : skillsStep(latest, input.name)),
194
+ skills: {
195
+ // Scan outside the transaction when this Session has no catalog yet,
196
+ // so /skills works before the first model request.
197
+ prepare: ({ sessionId, input }) => Effect.gen(function* () {
198
+ const found = latest.get(sessionId) ??
199
+ (yield* discover(sessionId).pipe(
200
+ // A failed scan reads as "not finished"; the next run scans again.
201
+ Effect.catchCause(() => Effect.succeed(undefined))));
202
+ const step = found === undefined
203
+ ? done({
204
+ type: "info",
205
+ message: "Skill discovery has not finished yet.",
206
+ })
207
+ : skillsStep(found, input.name);
208
+ return Effect.succeed(step);
209
+ }),
210
+ },
199
211
  }),
200
212
  },
201
- hooks: {
202
- start: () => scanOnStart
203
- ? Effect.tryPromise((signal) => source.catalog(signal)).pipe(Effect.tap((found) => Effect.sync(() => {
204
- latest = found;
205
- })),
206
- // A failed first scan leaves /skills waiting for the next run's scan.
207
- Effect.ignore)
208
- : Effect.void,
209
- },
210
- prompt: () => Effect.gen(function* () {
211
- const catalog = yield* discover;
213
+ prompt: (_context, run) => Effect.gen(function* () {
214
+ const catalog = yield* discover(run.sessionId);
212
215
  yield* reportDiagnostics(catalog);
213
216
  return promptSections(catalog);
214
217
  }),
215
- tools: () => Effect.gen(function* () {
216
- const catalog = yield* discover;
218
+ tools: (_context, run) => Effect.gen(function* () {
219
+ const catalog = yield* discover(run.sessionId);
217
220
  return Mycelium.module({
218
221
  id: "botanical.skills",
219
222
  name: "skill",
@@ -234,7 +237,12 @@ export function skillsExtension({ source, empty, scanOnStart = true, }) {
234
237
  supportingFiles: z.array(z.string()),
235
238
  }),
236
239
  execute: async ({ name, file }, context) => {
237
- const loaded = await source.read(name, file === "SKILL.md" ? undefined : file, context.signal);
240
+ const loaded = await source.read({
241
+ sessionId: run.sessionId,
242
+ name,
243
+ file: file === "SKILL.md" ? undefined : file,
244
+ signal: context.signal,
245
+ });
238
246
  return {
239
247
  ...loaded,
240
248
  supportingFiles: [...loaded.supportingFiles],
@@ -1,4 +1,4 @@
1
- /** Where a skill folder came from: the work itself, the person, or an installed extension. */
1
+ /** Where a skill folder came from: the work, the person, an installed extension, or the platform. */
2
2
  export type SkillOrigin = Readonly<{
3
3
  /** Project-local or personal skill discovery root. */
4
4
  kind: "project" | "personal";
@@ -7,6 +7,9 @@ export type SkillOrigin = Readonly<{
7
7
  kind: "extension";
8
8
  /** Identity of the extension supplying the skill. */
9
9
  extensionId: string;
10
+ }> | Readonly<{
11
+ /** Skill bundled with the host's own build, not found on any disk. */
12
+ kind: "platform";
10
13
  }>;
11
14
  /** Host-owned discovery metadata; bodies are loaded only through skill.load. */
12
15
  export type SkillDescription = Readonly<{
@@ -42,12 +45,30 @@ export type SkillCatalog = Readonly<{
42
45
  /** Discovery problems and informational outcomes. */
43
46
  diagnostics: readonly SkillDiagnostic[];
44
47
  }>;
48
+ /** The run asking for discovery: a host may show different Sessions different skills. */
49
+ export type SkillCatalogRequest = Readonly<{
50
+ /** Session whose run is asking. */
51
+ sessionId: string;
52
+ /** Cancels the scan. */
53
+ signal: AbortSignal;
54
+ }>;
55
+ /** One skill file requested by a run. */
56
+ export type SkillReadRequest = Readonly<{
57
+ /** Session whose run is asking. */
58
+ sessionId: string;
59
+ /** Name of the skill to load. */
60
+ name: string;
61
+ /** Contained supporting file; undefined selects SKILL.md. */
62
+ file: string | undefined;
63
+ /** Cancels the read. */
64
+ signal: AbortSignal;
65
+ }>;
45
66
  /** Read-only host port. The host owns frontmatter, discovery and containment. */
46
67
  export type SkillSource = Readonly<{
47
68
  /** Discover available skills without loading their bodies. */
48
- catalog: (signal: AbortSignal) => Promise<SkillCatalog>;
69
+ catalog: (request: SkillCatalogRequest) => Promise<SkillCatalog>;
49
70
  /** Load the selected skill body or one contained supporting file. */
50
- read: (name: string, file: string | undefined, signal: AbortSignal) => Promise<Readonly<{
71
+ read: (request: SkillReadRequest) => Promise<Readonly<{
51
72
  /** Name of the loaded skill. */
52
73
  name: string;
53
74
  /** Selected file within the skill. */
@@ -57,11 +57,11 @@ Add read-only skill discovery over `source` to any roster.
57
57
 
58
58
  #### Parameters
59
59
 
60
- | Parameter | Type |
61
- | --------- | ------------------------------------------------------------------ |
62
- | `base` | `ExtensionRosterV0` |
63
- | `source` | [`SkillSource`](skills/source.md#skillsource) |
64
- | `options` | `Readonly`\<\{ `empty?`: `string`; `scanOnStart?`: `boolean`; \}\> |
60
+ | Parameter | Type |
61
+ | --------- | --------------------------------------------- |
62
+ | `base` | `ExtensionRosterV0` |
63
+ | `source` | [`SkillSource`](skills/source.md#skillsource) |
64
+ | `options` | `Readonly`\<\{ `empty?`: `string`; \}\> |
65
65
 
66
66
  #### Returns
67
67
 
@@ -30,9 +30,9 @@ Skills use only the generic prompt and run-tools doors; the host owns files.
30
30
 
31
31
  #### Parameters
32
32
 
33
- | Parameter | Type |
34
- | ------------------- | -------------------------------------------------------------------------------------------------------------------- |
35
- | `__namedParameters` | `Readonly`\<\{ `source`: [`SkillSource`](source.md#skillsource); `empty?`: `string`; `scanOnStart?`: `boolean`; \}\> |
33
+ | Parameter | Type |
34
+ | ------------------- | ----------------------------------------------------------------------------------------- |
35
+ | `__namedParameters` | `Readonly`\<\{ `source`: [`SkillSource`](source.md#skillsource); `empty?`: `string`; \}\> |
36
36
 
37
37
  #### Returns
38
38
 
@@ -20,11 +20,14 @@ type SkillOrigin =
20
20
  | Readonly<{
21
21
  kind: "extension";
22
22
  extensionId: string;
23
+ }>
24
+ | Readonly<{
25
+ kind: "platform";
23
26
  }>;
24
27
  ```
25
28
 
26
- Where a skill folder came from: the work itself, the person, or an installed
27
- extension.
29
+ Where a skill folder came from: the work, the person, an installed extension, or
30
+ the platform.
28
31
 
29
32
  ---
30
33
 
@@ -80,16 +83,41 @@ Discovered skill descriptions and diagnostics from the same scan.
80
83
 
81
84
  ---
82
85
 
86
+ ### SkillCatalogRequest
87
+
88
+ ```ts
89
+ type SkillCatalogRequest = Readonly<{
90
+ sessionId: string;
91
+ signal: AbortSignal;
92
+ }>;
93
+ ```
94
+
95
+ The run asking for discovery: a host may show different Sessions different
96
+ skills.
97
+
98
+ ---
99
+
100
+ ### SkillReadRequest
101
+
102
+ ```ts
103
+ type SkillReadRequest = Readonly<{
104
+ sessionId: string;
105
+ name: string;
106
+ file: string | undefined;
107
+ signal: AbortSignal;
108
+ }>;
109
+ ```
110
+
111
+ One skill file requested by a run.
112
+
113
+ ---
114
+
83
115
  ### SkillSource
84
116
 
85
117
  ```ts
86
118
  type SkillSource = Readonly<{
87
- catalog: (signal) => Promise<SkillCatalog>;
88
- read: (
89
- name,
90
- file,
91
- signal,
92
- ) => Promise<
119
+ catalog: (request) => Promise<SkillCatalog>;
120
+ read: (request) => Promise<
93
121
  Readonly<{
94
122
  name: string;
95
123
  file: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fungi.computer/shiitake-extensions",
3
- "version": "0.10.2",
3
+ "version": "0.11.1",
4
4
  "author": "Levi <levi@technomancy.dev>",
5
5
  "private": false,
6
6
  "description": "Botanical's product Shiitake extensions: goal, loop and Almanac on the generic extension surface",
@@ -122,7 +122,7 @@
122
122
  "@fungi.computer/cairn": "0.1.0",
123
123
  "@fungi.computer/knapsack": "0.4.13",
124
124
  "@fungi.computer/mycelium": "0.4.0",
125
- "@fungi.computer/shiitake": "0.18.2",
125
+ "@fungi.computer/shiitake": "0.18.3",
126
126
  "@fungi.computer/watchdog": "0.1.3",
127
127
  "@fungi.computer/whistle": "0.3.0",
128
128
  "effect": "4.0.2",