@ai-ecoverse/slicc-agent 3.49.0 → 3.50.0
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/README.md +11 -5
- package/dist/roles/roles.js +54 -15
- package/dist/roles/roles.js.map +2 -2
- package/dist/scoops/index.js +7 -2
- package/dist/scoops/index.js.map +2 -2
- package/dist/skills/index.js +12 -15
- package/dist/skills/index.js.map +2 -2
- package/dist/types/roles/roles.d.ts +14 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -233,7 +233,7 @@ Each scoop is owned by a background durable task, its **anchor**, so Stop in its
|
|
|
233
233
|
- `models use <provider/model> [--thinking <level>]` switches the caller's model the way the Settings picker does (`Conversation.configure`): a cone's or a scoop's own, or, in a terminal, the active cone's. An unknown id exits 1 naming the three closest ids; a model whose account isn't connected exits 1 and says to connect it in Settings.
|
|
234
234
|
- `models --help` prints the usage; an unknown verb exits 2 with it.
|
|
235
235
|
|
|
236
|
-
**Roles** are pi agent files: Markdown with a frontmatter subset (`name`, `description`, `tools`, `model`, `thinking`, `memory`, `inheritProjectContext`, `inheritGlobalContext`, …) and the role's prompt as the body, added to the scoop's instructions. The built-ins are `scout`, `worker`, `reviewer`, `oracle`, `delegate` and `gelatiere` (below).
|
|
236
|
+
**Roles** are pi agent files: Markdown with a frontmatter subset (`name`, `description`, `tools`, `model`, `thinking`, `memory`, `inheritProjectContext`, `inheritGlobalContext`, …) and the role's prompt as the body, added to the scoop's instructions. The built-ins are `scout`, `worker`, `reviewer`, `oracle`, `delegate` and `gelatiere` (below). The first source with a name wins: `~/.pi/agent/agents/`, then the built-ins, then packages (see Package resources) that name a folder in `pi-subagents.agents` or `pi.subagents.agents`. A package role that loses its name is skipped with a warning in `agent list`. A project's `.pi/agents/` will count only in trusted folders, and folders can't be trusted yet. `~/.pi/agent/settings.json` can override roles (`subagents.agentOverrides`) and set the limits `subagents.maxLiveScoops` (16 live scoops per cone) and `subagents.maxPerTurn` (64 scoops started per cone turn), which the worker counts for both kinds.
|
|
237
237
|
|
|
238
238
|
**Isolation, for now.** The file tools of a scoop write only under its folder and `/tmp`, plus the cwd of a v6-form call, and read those, their cone's working folder (`/home` by default) and `--read-only` paths; paths are normalized, `..` included, before the check. bash isn't confined, and the scoop is told so: the guard is a guardrail, not a boundary. A scoop's commands share one process group (see Bash and files on slicc-kernel), and stopping the scoop signals it, together with any group recorded for the scoop on an older kernel.
|
|
239
239
|
|
|
@@ -249,10 +249,10 @@ Skills and prompt templates work as in pi's coding-agent. pi's loaders read with
|
|
|
249
249
|
1. `~/.pi/agent/skills`;
|
|
250
250
|
2. `~/.agents/skills`;
|
|
251
251
|
3. `/usr/share/skills`, the global skills every cone and scoop sees, such as those imported from SLICC 6;
|
|
252
|
-
4.
|
|
253
|
-
5.
|
|
252
|
+
4. the built-ins, which the worker writes to `/var/lib/slicc/agent/skills` on every start;
|
|
253
|
+
5. packages whose `package.json` lists folders in `pi.skills` (see Package resources).
|
|
254
254
|
|
|
255
|
-
On a name collision the first skill found wins: an agent's own skills shadow the global ones,
|
|
255
|
+
On a name collision the first skill found wins: an agent's own skills shadow the global ones, a global skill shadows a built-in, and a built-in shadows a package's. A missing root is skipped.
|
|
256
256
|
- **The global folder.** On every start the worker, as root, creates `/usr/share/skills` if it's missing and sets it to 0755, so it's root's and readable by everyone; once kernel users give each cone its own user and the kernel checks file modes, only root (the worker, sudo or the human) writes there, and every cone and scoop reads it. Each skill's `source` is `user`, `global`, `package` or `builtin`.
|
|
257
257
|
- **Inside a root.** Folders with `SKILL.md` are found at any depth, and a `SKILL.md` ends its branch. A `.md` file with a description directly in a root counts too. Folders starting with `.` and `node_modules` are skipped. Symbolic links are followed, but each folder is read once by its real path, so a link back up a tree can't loop. Scoops may `read` the folders of the loaded skills, even outside their own folders.
|
|
258
258
|
- **Problems.** A problem (a missing description, a bad name, a collision, a line the frontmatter parser can't read) becomes one lick with `severity="warn"` per distinct problem. A skill without a description is skipped; any other problem only warns.
|
|
@@ -261,10 +261,16 @@ Skills and prompt templates work as in pi's coding-agent. pi's loaders read with
|
|
|
261
261
|
The worker watches the roots and reloads on change. A `skills` prompt section, given to cones and scoops, lists every skill's name, description and location in pi's `<available_skills>` block, and the model reads a `SKILL.md` with the `read` tool when a task matches.
|
|
262
262
|
|
|
263
263
|
**Prompt templates.**
|
|
264
|
-
- **Where they come from.** Each is a Markdown file directly in `~/.pi/agent/prompts`, in a package's `pi.prompts` (a file, a folder or `folder/*.md`),
|
|
264
|
+
- **Where they come from.** Each is a Markdown file directly in `~/.pi/agent/prompts`, one of the built-ins in `/var/lib/slicc/agent/prompts`, or in a package's `pi.prompts` (a file, a folder or `folder/*.md`), read in that order. Its name is the file name, and the first one with a name wins; a later one is a collision problem.
|
|
265
265
|
- **Frontmatter.** `description` (otherwise the first line) and `argument-hint`.
|
|
266
266
|
- **Substitutions.** `$1`, `$@`, `$ARGUMENTS`, `${1:-default}`, `${@:-default}`, `${@:N}` and `${@:N:L}`, with shell-like quoting of the arguments.
|
|
267
267
|
|
|
268
|
+
**Package resources.** Skills, prompt templates and roles also come from packages, read as files and never run. Two roots are scanned, in this order:
|
|
269
|
+
1. `/node_modules`, the kernel's certified system packages;
|
|
270
|
+
2. `/opt/user/node_modules`, "your packages": a pnpm project that root owns (0755, files 0644), which cones can't write. The agent only reads it, so it works for every user. A missing `/opt/user` is fine.
|
|
271
|
+
|
|
272
|
+
Root's global pnpm (`/usr/local/share/pnpm`) isn't scanned. The first name wins. A package name already found in an earlier root is skipped whole: none of that copy's skills, prompts or roles load. A skill, prompt or role whose name is already taken (by `~/.pi/agent`, the global folder, a built-in or an earlier package) is skipped too. Each skip, of a package that declares pi resources or of a name, is one `warn` problem lick per session, naming the package's path and what it would have shadowed. Roles report theirs in `agent list`. Extension code (PR 20) will load from `/opt/user` under the same rule, which replaces the earlier `/opt/agent-extensions` plan.
|
|
273
|
+
|
|
268
274
|
**Commands.**
|
|
269
275
|
- **How they expand.** `AgentControl.send` expands `/skill:<name> [request]` (the skill's body in a `<skill name location>` block, then the request) and `/<template> [arguments]`, exactly as pi does. Only text sent from a composer is expanded: licks and `agent send` never are.
|
|
270
276
|
- **What the composer shows.** The transcript service's `commands` lists templates (`kind: 'prompt'`) and skills (`skill:<name>`, `kind: 'skill'`), and the spectrum adapter returns them from `AgentPort.commands()`.
|
package/dist/roles/roles.js
CHANGED
|
@@ -177,21 +177,30 @@ function apply(role, override, warnings) {
|
|
|
177
177
|
);
|
|
178
178
|
return next;
|
|
179
179
|
}
|
|
180
|
-
const ORDER = ["
|
|
180
|
+
const ORDER = ["project", "user", "builtin", "package"];
|
|
181
181
|
async function loadRoles(options, context) {
|
|
182
182
|
const warnings = [];
|
|
183
183
|
const byName = /* @__PURE__ */ new Map();
|
|
184
184
|
const add = (role) => {
|
|
185
|
-
if (role)
|
|
185
|
+
if (!role) return;
|
|
186
|
+
const earlier = byName.get(role.name);
|
|
187
|
+
if (!earlier) byName.set(role.name, role);
|
|
188
|
+
else if (role.source === "package")
|
|
189
|
+
warnings.push(
|
|
190
|
+
`${role.path}: role "${role.name}" is already provided by ${earlier.path}; ignored`
|
|
191
|
+
);
|
|
186
192
|
};
|
|
187
|
-
for (const { path, text } of await options.builtin())
|
|
188
|
-
add(parseRole(text, "builtin", path, warnings));
|
|
189
193
|
const dirs = [...options.dirs].sort((a, b) => ORDER.indexOf(a.source) - ORDER.indexOf(b.source));
|
|
190
|
-
|
|
191
|
-
for (const path of await markdown(options.files, dir, context)) {
|
|
192
|
-
const
|
|
193
|
-
if (
|
|
194
|
+
const read = async (dir) => {
|
|
195
|
+
for (const path of await markdown(options.files, dir.dir, context)) {
|
|
196
|
+
const text = await options.files.readTextFile(path, context);
|
|
197
|
+
if (text.ok) add(parseRole(text.value, dir.source, path, warnings));
|
|
194
198
|
}
|
|
199
|
+
};
|
|
200
|
+
for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) < 2)) await read(dir);
|
|
201
|
+
for (const { path, text } of await options.builtin())
|
|
202
|
+
add(parseRole(text, "builtin", path, warnings));
|
|
203
|
+
for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) >= 2)) await read(dir);
|
|
195
204
|
const { overrides, limits } = await settings(
|
|
196
205
|
options.files,
|
|
197
206
|
options.settingsPath,
|
|
@@ -208,12 +217,15 @@ async function loadRoles(options, context) {
|
|
|
208
217
|
function findRole(roles, name) {
|
|
209
218
|
return roles.find((role) => role.name === name) ?? roles.find((role) => role.aliases.includes(name));
|
|
210
219
|
}
|
|
220
|
+
function folder(kind) {
|
|
221
|
+
return kind === "directory" || kind === "symlink";
|
|
222
|
+
}
|
|
211
223
|
async function manifestDirs(files, root, context) {
|
|
212
224
|
const top = await files.listDir(root, context);
|
|
213
225
|
if (!top.ok) return [];
|
|
214
226
|
const out = [];
|
|
215
227
|
for (const entry of top.value) {
|
|
216
|
-
if (entry.kind
|
|
228
|
+
if (!folder(entry.kind) || entry.name.startsWith(".")) continue;
|
|
217
229
|
if (!entry.name.startsWith("@")) {
|
|
218
230
|
out.push(`${root}/${entry.name}`);
|
|
219
231
|
continue;
|
|
@@ -221,7 +233,7 @@ async function manifestDirs(files, root, context) {
|
|
|
221
233
|
const scoped = await files.listDir(`${root}/${entry.name}`, context);
|
|
222
234
|
if (scoped.ok) {
|
|
223
235
|
for (const inner of scoped.value)
|
|
224
|
-
if (inner.kind
|
|
236
|
+
if (folder(inner.kind)) out.push(`${root}/${entry.name}/${inner.name}`);
|
|
225
237
|
}
|
|
226
238
|
}
|
|
227
239
|
return out;
|
|
@@ -237,22 +249,49 @@ function agentPaths(dir, text) {
|
|
|
237
249
|
const listed = Array.isArray(agents) ? agents : typeof agents === "string" ? [agents] : [];
|
|
238
250
|
return listed.filter((path) => typeof path === "string").map((path) => `${dir}/${path.replace(/^\.\//, "").replace(/\/$/, "")}`);
|
|
239
251
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
const
|
|
244
|
-
|
|
252
|
+
const PACKAGE_ROOTS = ["/node_modules", "/opt/user/node_modules"];
|
|
253
|
+
function declaresPi(text) {
|
|
254
|
+
try {
|
|
255
|
+
const manifest = JSON.parse(text);
|
|
256
|
+
return manifest.pi !== void 0 || manifest["pi-subagents"] !== void 0;
|
|
257
|
+
} catch {
|
|
258
|
+
return false;
|
|
245
259
|
}
|
|
260
|
+
}
|
|
261
|
+
async function piPackages(files, roots, context) {
|
|
262
|
+
const out = { packages: [], skipped: [] };
|
|
263
|
+
const seen = /* @__PURE__ */ new Map();
|
|
264
|
+
for (const root of roots)
|
|
265
|
+
for (const dir of await manifestDirs(files, root, context)) {
|
|
266
|
+
const read = await files.readTextFile(`${dir}/package.json`, context);
|
|
267
|
+
if (!read.ok) continue;
|
|
268
|
+
const name = dir.slice(root.length + 1);
|
|
269
|
+
const earlier = seen.get(name);
|
|
270
|
+
if (earlier === void 0) {
|
|
271
|
+
seen.set(name, dir);
|
|
272
|
+
out.packages.push({ dir, manifest: read.value });
|
|
273
|
+
} else if (declaresPi(read.value))
|
|
274
|
+
out.skipped.push({
|
|
275
|
+
path: dir,
|
|
276
|
+
message: `package "${name}" is already installed at ${earlier}, so this copy's skills, prompts and roles are ignored`
|
|
277
|
+
});
|
|
278
|
+
}
|
|
246
279
|
return out;
|
|
247
280
|
}
|
|
281
|
+
async function packageDirs(files, roots, context) {
|
|
282
|
+
const { packages } = await piPackages(files, roots, context);
|
|
283
|
+
return packages.flatMap(({ dir, manifest }) => agentPaths(dir, manifest));
|
|
284
|
+
}
|
|
248
285
|
export {
|
|
249
286
|
DEFAULT_LIMITS,
|
|
287
|
+
PACKAGE_ROOTS,
|
|
250
288
|
agentPaths,
|
|
251
289
|
findRole,
|
|
252
290
|
loadRoles,
|
|
253
291
|
manifestDirs,
|
|
254
292
|
packageDirs,
|
|
255
293
|
parseRole,
|
|
294
|
+
piPackages,
|
|
256
295
|
roleMemory
|
|
257
296
|
};
|
|
258
297
|
//# sourceMappingURL=roles.js.map
|
package/dist/roles/roles.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/roles/roles.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport type { RoleMemory } from '../memory/store.ts';\nimport { type FrontmatterValue, parseFrontmatter } from './frontmatter.ts';\n\nexport type RoleSource = 'builtin' | 'package' | 'user' | 'project';\nexport type Thinking = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';\n\nexport interface Role {\n name: string;\n description: string;\n prompt: string;\n mode: 'replace' | 'append';\n tools?: string[];\n model?: string;\n thinking?: Thinking;\n aliases: string[];\n output?: string;\n memory?: RoleMemory;\n context?: { project: boolean; global: boolean };\n source: RoleSource;\n path: string;\n}\n\nexport interface Roles {\n roles: Role[];\n warnings: string[];\n limits: { maxLiveScoops: number; maxPerTurn: number };\n}\n\nexport const DEFAULT_LIMITS = { maxLiveScoops: 16, maxPerTurn: 64 };\n\nconst TOOLS: Record<string, string> = {\n read: 'read',\n write: 'write',\n edit: 'edit',\n bash: 'bash',\n grep: 'bash',\n find: 'bash',\n ls: 'bash',\n memory_write: 'memory_write',\n};\n\nconst WRITERS = new Set(['write', 'edit', 'bash']);\n\nconst PASSED = new Set([\n 'codemode',\n 'list_mcp_resources',\n 'list_mcp_resource_templates',\n 'read_mcp_resource',\n]);\n\nfunction passThrough(name: string): boolean {\n return PASSED.has(name) || /^mcp__[A-Za-z0-9_*]+$/.test(name);\n}\n\nconst THINKING = new Set<string>(['off', 'minimal', 'low', 'medium', 'high', 'xhigh']);\n\nconst APPLIED = new Set([\n 'name',\n 'description',\n 'tools',\n 'model',\n 'thinking',\n 'systemPromptMode',\n 'aliases',\n 'output',\n 'package',\n 'advertise',\n 'inheritProjectContext',\n 'inheritGlobalContext',\n 'inheritSkills',\n 'memory',\n 'skills',\n 'defaultReads',\n]);\n\nexport type RoleFiles = Pick<ExecutionEnv, 'readTextFile' | 'listDir'>;\n\nexport interface RoleSourceDir {\n source: RoleSource;\n dir: string;\n}\n\nfunction list(value: FrontmatterValue | undefined): string[] {\n if (Array.isArray(value)) return value;\n if (typeof value === 'string')\n return value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n return [];\n}\n\nfunction tools(names: string[], where: string, warnings: string[]): string[] {\n const mapped: string[] = [];\n for (const name of names) {\n const tool = TOOLS[name] ?? (passThrough(name) ? name : undefined);\n if (tool) {\n if (!mapped.includes(tool)) mapped.push(tool);\n } else warnings.push(`${where}: tool \"${name}\" isn't available in SLICC; it's left out`);\n }\n return mapped;\n}\n\nexport function roleMemory(value: FrontmatterValue): RoleMemory | undefined {\n if (typeof value !== 'string') return undefined;\n const inline = /^\\{(.*)\\}$/s.exec(value.trim());\n const pairs = new Map<string, string>();\n for (const part of (inline ? (inline[1] as string) : value).split(/[,\\n]/)) {\n const found = /^\\s*([\\w-]+)\\s*:\\s*(.*?)\\s*$/.exec(part);\n if (found) pairs.set(found[1] as string, (found[2] as string).replace(/^([\"'])(.*)\\1$/, '$2'));\n }\n const scope = pairs.get('scope');\n const path = pairs.get('path');\n if ((scope !== 'user' && scope !== 'project') || !path) return undefined;\n return { scope, path };\n}\n\nfunction withMemoryWrite(\n listed: string[] | undefined,\n memory: RoleMemory | undefined\n): string[] | undefined {\n if (memory && listed?.some((tool) => WRITERS.has(tool)) && !listed.includes('memory_write'))\n return [...listed, 'memory_write'];\n return listed;\n}\n\nfunction memoryFields(\n fields: Record<string, FrontmatterValue>,\n path: string,\n warnings: string[]\n): Pick<Role, 'memory' | 'context'> & { listed: string[] | undefined } {\n const memory = fields.memory === undefined ? undefined : roleMemory(fields.memory);\n if (fields.memory !== undefined && !memory)\n warnings.push(`${path}: memory needs a scope (user or project) and a path; ignored`);\n const listed = withMemoryWrite(\n fields.tools !== undefined ? tools(list(fields.tools), path, warnings) : undefined,\n memory\n );\n const inherits =\n fields.inheritProjectContext !== undefined || fields.inheritGlobalContext !== undefined;\n return {\n ...(memory ? { memory } : {}),\n listed,\n ...(inherits\n ? {\n context: {\n project: fields.inheritProjectContext !== false,\n global: fields.inheritGlobalContext === true,\n },\n }\n : {}),\n };\n}\n\nexport function parseRole(\n text: string,\n source: RoleSource,\n path: string,\n warnings: string[]\n): Role | undefined {\n const { fields, body, problems } = parseFrontmatter(text, ['memory']);\n for (const problem of problems) warnings.push(`${path}: ${problem}`);\n const name = fields.name;\n const description = fields.description;\n if (typeof name !== 'string' || typeof description !== 'string') {\n warnings.push(`${path}: an agent file needs a name and a description; skipped`);\n return undefined;\n }\n for (const key of Object.keys(fields))\n if (!APPLIED.has(key))\n warnings.push(`${path}: \"${key}\" isn't supported in SLICC; it's ignored`);\n const thinking =\n typeof fields.thinking === 'string' && THINKING.has(fields.thinking)\n ? (fields.thinking as Thinking)\n : undefined;\n if (fields.thinking !== undefined && !thinking)\n warnings.push(`${path}: thinking \"${String(fields.thinking)}\" is unknown; ignored`);\n const { memory, listed, context } = memoryFields(fields, path, warnings);\n const pkg = typeof fields.package === 'string' && fields.package ? `${fields.package}.` : '';\n return {\n name: `${pkg}${name}`,\n description,\n prompt: body,\n mode: fields.systemPromptMode === 'append' ? 'append' : 'replace',\n ...(listed ? { tools: listed } : {}),\n ...(typeof fields.model === 'string' ? { model: fields.model } : {}),\n ...(thinking ? { thinking } : {}),\n aliases: list(fields.aliases),\n ...(typeof fields.output === 'string' ? { output: fields.output } : {}),\n ...(memory ? { memory } : {}),\n ...(context ? { context } : {}),\n source,\n path,\n };\n}\n\nasync function markdown(\n files: RoleFiles,\n dir: string,\n context: Context,\n depth = 0\n): Promise<string[]> {\n if (dir.endsWith('.md')) return [dir];\n const listed = await files.listDir(dir, context);\n if (!listed.ok || depth > 4) return [];\n const out: string[] = [];\n for (const info of listed.value) {\n const path = `${dir}/${info.name}`;\n if (info.kind === 'directory') out.push(...(await markdown(files, path, context, depth + 1)));\n else if (info.name.endsWith('.md') && !info.name.endsWith('.chain.md')) out.push(path);\n }\n return out.sort();\n}\n\ntype Override = {\n model?: unknown;\n thinking?: unknown;\n tools?: unknown;\n systemPrompt?: unknown;\n description?: unknown;\n disabled?: unknown;\n};\n\ninterface Settings {\n overrides: Record<string, Override>;\n limits: Roles['limits'];\n}\n\nfunction positive(value: unknown, fallback: number): number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : fallback;\n}\n\nasync function settings(\n files: RoleFiles,\n path: string,\n context: Context,\n warnings: string[]\n): Promise<Settings> {\n const read = await files.readTextFile(path, context);\n const empty = { overrides: {}, limits: { ...DEFAULT_LIMITS } };\n if (!read.ok) return empty;\n let parsed: {\n subagents?: {\n agentOverrides?: Record<string, Override>;\n maxLiveScoops?: unknown;\n maxPerTurn?: unknown;\n };\n };\n try {\n parsed = JSON.parse(read.value);\n } catch (error) {\n warnings.push(`${path}: not valid JSON (${(error as Error).message}); overrides ignored`);\n return empty;\n }\n const subagents = parsed.subagents ?? {};\n return {\n overrides: subagents.agentOverrides ?? {},\n limits: {\n maxLiveScoops: positive(subagents.maxLiveScoops, DEFAULT_LIMITS.maxLiveScoops),\n maxPerTurn: positive(subagents.maxPerTurn, DEFAULT_LIMITS.maxPerTurn),\n },\n };\n}\n\nfunction apply(role: Role, override: Override | undefined, warnings: string[]): Role | undefined {\n if (!override) return role;\n if (override.disabled === true) return undefined;\n const next: Role = { ...role };\n if (typeof override.model === 'string') next.model = override.model;\n if (typeof override.thinking === 'string' && THINKING.has(override.thinking))\n next.thinking = override.thinking as Thinking;\n if (typeof override.description === 'string') next.description = override.description;\n if (typeof override.systemPrompt === 'string') next.prompt = override.systemPrompt;\n if (Array.isArray(override.tools))\n next.tools = withMemoryWrite(\n tools(override.tools.map(String), `override for ${role.name}`, warnings),\n role.memory\n );\n return next;\n}\n\nexport interface LoadOptions {\n files: RoleFiles;\n builtin: () => Promise<{ path: string; text: string }[]>;\n dirs: RoleSourceDir[];\n settingsPath: string;\n}\n\nconst ORDER: RoleSource[] = ['builtin', 'package', 'user', 'project'];\n\nexport async function loadRoles(options: LoadOptions, context: Context): Promise<Roles> {\n const warnings: string[] = [];\n const byName = new Map<string, Role>();\n const add = (role: Role | undefined) => {\n if (role) byName.set(role.name, role);\n };\n for (const { path, text } of await options.builtin())\n add(parseRole(text, 'builtin', path, warnings));\n const dirs = [...options.dirs].sort((a, b) => ORDER.indexOf(a.source) - ORDER.indexOf(b.source));\n for (const { source, dir } of dirs)\n for (const path of await markdown(options.files, dir, context)) {\n const read = await options.files.readTextFile(path, context);\n if (read.ok) add(parseRole(read.value, source, path, warnings));\n }\n const { overrides, limits } = await settings(\n options.files,\n options.settingsPath,\n context,\n warnings\n );\n const roles: Role[] = [];\n for (const role of byName.values()) {\n const applied = apply(role, overrides[role.name], warnings);\n if (applied) roles.push(applied);\n }\n return { roles, warnings, limits };\n}\n\nexport function findRole(roles: readonly Role[], name: string): Role | undefined {\n return (\n roles.find((role) => role.name === name) ?? roles.find((role) => role.aliases.includes(name))\n );\n}\n\nexport async function manifestDirs(\n files: RoleFiles,\n root: string,\n context: Context\n): Promise<string[]> {\n const top = await files.listDir(root, context);\n if (!top.ok) return [];\n const out: string[] = [];\n for (const entry of top.value) {\n if (entry.kind !== 'directory' || entry.name.startsWith('.')) continue;\n if (!entry.name.startsWith('@')) {\n out.push(`${root}/${entry.name}`);\n continue;\n }\n const scoped = await files.listDir(`${root}/${entry.name}`, context);\n if (scoped.ok)\n for (const inner of scoped.value)\n if (inner.kind === 'directory') out.push(`${root}/${entry.name}/${inner.name}`);\n }\n return out;\n}\n\ntype Manifest = {\n 'pi-subagents'?: { agents?: unknown };\n pi?: { subagents?: { agents?: unknown } };\n};\n\nexport function agentPaths(dir: string, text: string): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const agents = manifest['pi-subagents']?.agents ?? manifest.pi?.subagents?.agents;\n const listed = Array.isArray(agents) ? agents : typeof agents === 'string' ? [agents] : [];\n return listed\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nexport async function packageDirs(\n files: RoleFiles,\n root: string,\n context: Context\n): Promise<string[]> {\n const out: string[] = [];\n for (const dir of await manifestDirs(files, root, context)) {\n const read = await files.readTextFile(`${dir}/package.json`, context);\n if (read.ok) out.push(...agentPaths(dir, read.value));\n }\n return out;\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAgC,wBAAwB;AA2BjD,MAAM,iBAAiB,EAAE,eAAe,IAAI,YAAY,GAAG;AAElE,MAAM,QAAgC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,cAAc;AAChB;AAEA,MAAM,UAAU,oBAAI,IAAI,CAAC,SAAS,QAAQ,MAAM,CAAC;AAEjD,MAAM,SAAS,oBAAI,IAAI;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,YAAY,MAAuB;AAC1C,SAAO,OAAO,IAAI,IAAI,KAAK,wBAAwB,KAAK,IAAI;AAC9D;AAEA,MAAM,WAAW,oBAAI,IAAY,CAAC,OAAO,WAAW,OAAO,UAAU,QAAQ,OAAO,CAAC;AAErF,MAAM,UAAU,oBAAI,IAAI;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASD,SAAS,KAAK,OAA+C;AAC3D,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO;AACjC,MAAI,OAAO,UAAU;AACnB,WAAO,MACJ,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,KAAK,CAAC,EACzB,OAAO,OAAO;AACnB,SAAO,CAA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\nimport type { RoleMemory } from '../memory/store.ts';\nimport { type FrontmatterValue, parseFrontmatter } from './frontmatter.ts';\n\nexport type RoleSource = 'builtin' | 'package' | 'user' | 'project';\nexport type Thinking = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';\n\nexport interface Role {\n name: string;\n description: string;\n prompt: string;\n mode: 'replace' | 'append';\n tools?: string[];\n model?: string;\n thinking?: Thinking;\n aliases: string[];\n output?: string;\n memory?: RoleMemory;\n context?: { project: boolean; global: boolean };\n source: RoleSource;\n path: string;\n}\n\nexport interface Roles {\n roles: Role[];\n warnings: string[];\n limits: { maxLiveScoops: number; maxPerTurn: number };\n}\n\nexport const DEFAULT_LIMITS = { maxLiveScoops: 16, maxPerTurn: 64 };\n\nconst TOOLS: Record<string, string> = {\n read: 'read',\n write: 'write',\n edit: 'edit',\n bash: 'bash',\n grep: 'bash',\n find: 'bash',\n ls: 'bash',\n memory_write: 'memory_write',\n};\n\nconst WRITERS = new Set(['write', 'edit', 'bash']);\n\nconst PASSED = new Set([\n 'codemode',\n 'list_mcp_resources',\n 'list_mcp_resource_templates',\n 'read_mcp_resource',\n]);\n\nfunction passThrough(name: string): boolean {\n return PASSED.has(name) || /^mcp__[A-Za-z0-9_*]+$/.test(name);\n}\n\nconst THINKING = new Set<string>(['off', 'minimal', 'low', 'medium', 'high', 'xhigh']);\n\nconst APPLIED = new Set([\n 'name',\n 'description',\n 'tools',\n 'model',\n 'thinking',\n 'systemPromptMode',\n 'aliases',\n 'output',\n 'package',\n 'advertise',\n 'inheritProjectContext',\n 'inheritGlobalContext',\n 'inheritSkills',\n 'memory',\n 'skills',\n 'defaultReads',\n]);\n\nexport type RoleFiles = Pick<ExecutionEnv, 'readTextFile' | 'listDir'>;\n\nexport interface RoleSourceDir {\n source: RoleSource;\n dir: string;\n}\n\nfunction list(value: FrontmatterValue | undefined): string[] {\n if (Array.isArray(value)) return value;\n if (typeof value === 'string')\n return value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n return [];\n}\n\nfunction tools(names: string[], where: string, warnings: string[]): string[] {\n const mapped: string[] = [];\n for (const name of names) {\n const tool = TOOLS[name] ?? (passThrough(name) ? name : undefined);\n if (tool) {\n if (!mapped.includes(tool)) mapped.push(tool);\n } else warnings.push(`${where}: tool \"${name}\" isn't available in SLICC; it's left out`);\n }\n return mapped;\n}\n\nexport function roleMemory(value: FrontmatterValue): RoleMemory | undefined {\n if (typeof value !== 'string') return undefined;\n const inline = /^\\{(.*)\\}$/s.exec(value.trim());\n const pairs = new Map<string, string>();\n for (const part of (inline ? (inline[1] as string) : value).split(/[,\\n]/)) {\n const found = /^\\s*([\\w-]+)\\s*:\\s*(.*?)\\s*$/.exec(part);\n if (found) pairs.set(found[1] as string, (found[2] as string).replace(/^([\"'])(.*)\\1$/, '$2'));\n }\n const scope = pairs.get('scope');\n const path = pairs.get('path');\n if ((scope !== 'user' && scope !== 'project') || !path) return undefined;\n return { scope, path };\n}\n\nfunction withMemoryWrite(\n listed: string[] | undefined,\n memory: RoleMemory | undefined\n): string[] | undefined {\n if (memory && listed?.some((tool) => WRITERS.has(tool)) && !listed.includes('memory_write'))\n return [...listed, 'memory_write'];\n return listed;\n}\n\nfunction memoryFields(\n fields: Record<string, FrontmatterValue>,\n path: string,\n warnings: string[]\n): Pick<Role, 'memory' | 'context'> & { listed: string[] | undefined } {\n const memory = fields.memory === undefined ? undefined : roleMemory(fields.memory);\n if (fields.memory !== undefined && !memory)\n warnings.push(`${path}: memory needs a scope (user or project) and a path; ignored`);\n const listed = withMemoryWrite(\n fields.tools !== undefined ? tools(list(fields.tools), path, warnings) : undefined,\n memory\n );\n const inherits =\n fields.inheritProjectContext !== undefined || fields.inheritGlobalContext !== undefined;\n return {\n ...(memory ? { memory } : {}),\n listed,\n ...(inherits\n ? {\n context: {\n project: fields.inheritProjectContext !== false,\n global: fields.inheritGlobalContext === true,\n },\n }\n : {}),\n };\n}\n\nexport function parseRole(\n text: string,\n source: RoleSource,\n path: string,\n warnings: string[]\n): Role | undefined {\n const { fields, body, problems } = parseFrontmatter(text, ['memory']);\n for (const problem of problems) warnings.push(`${path}: ${problem}`);\n const name = fields.name;\n const description = fields.description;\n if (typeof name !== 'string' || typeof description !== 'string') {\n warnings.push(`${path}: an agent file needs a name and a description; skipped`);\n return undefined;\n }\n for (const key of Object.keys(fields))\n if (!APPLIED.has(key))\n warnings.push(`${path}: \"${key}\" isn't supported in SLICC; it's ignored`);\n const thinking =\n typeof fields.thinking === 'string' && THINKING.has(fields.thinking)\n ? (fields.thinking as Thinking)\n : undefined;\n if (fields.thinking !== undefined && !thinking)\n warnings.push(`${path}: thinking \"${String(fields.thinking)}\" is unknown; ignored`);\n const { memory, listed, context } = memoryFields(fields, path, warnings);\n const pkg = typeof fields.package === 'string' && fields.package ? `${fields.package}.` : '';\n return {\n name: `${pkg}${name}`,\n description,\n prompt: body,\n mode: fields.systemPromptMode === 'append' ? 'append' : 'replace',\n ...(listed ? { tools: listed } : {}),\n ...(typeof fields.model === 'string' ? { model: fields.model } : {}),\n ...(thinking ? { thinking } : {}),\n aliases: list(fields.aliases),\n ...(typeof fields.output === 'string' ? { output: fields.output } : {}),\n ...(memory ? { memory } : {}),\n ...(context ? { context } : {}),\n source,\n path,\n };\n}\n\nasync function markdown(\n files: RoleFiles,\n dir: string,\n context: Context,\n depth = 0\n): Promise<string[]> {\n if (dir.endsWith('.md')) return [dir];\n const listed = await files.listDir(dir, context);\n if (!listed.ok || depth > 4) return [];\n const out: string[] = [];\n for (const info of listed.value) {\n const path = `${dir}/${info.name}`;\n if (info.kind === 'directory') out.push(...(await markdown(files, path, context, depth + 1)));\n else if (info.name.endsWith('.md') && !info.name.endsWith('.chain.md')) out.push(path);\n }\n return out.sort();\n}\n\ntype Override = {\n model?: unknown;\n thinking?: unknown;\n tools?: unknown;\n systemPrompt?: unknown;\n description?: unknown;\n disabled?: unknown;\n};\n\ninterface Settings {\n overrides: Record<string, Override>;\n limits: Roles['limits'];\n}\n\nfunction positive(value: unknown, fallback: number): number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : fallback;\n}\n\nasync function settings(\n files: RoleFiles,\n path: string,\n context: Context,\n warnings: string[]\n): Promise<Settings> {\n const read = await files.readTextFile(path, context);\n const empty = { overrides: {}, limits: { ...DEFAULT_LIMITS } };\n if (!read.ok) return empty;\n let parsed: {\n subagents?: {\n agentOverrides?: Record<string, Override>;\n maxLiveScoops?: unknown;\n maxPerTurn?: unknown;\n };\n };\n try {\n parsed = JSON.parse(read.value);\n } catch (error) {\n warnings.push(`${path}: not valid JSON (${(error as Error).message}); overrides ignored`);\n return empty;\n }\n const subagents = parsed.subagents ?? {};\n return {\n overrides: subagents.agentOverrides ?? {},\n limits: {\n maxLiveScoops: positive(subagents.maxLiveScoops, DEFAULT_LIMITS.maxLiveScoops),\n maxPerTurn: positive(subagents.maxPerTurn, DEFAULT_LIMITS.maxPerTurn),\n },\n };\n}\n\nfunction apply(role: Role, override: Override | undefined, warnings: string[]): Role | undefined {\n if (!override) return role;\n if (override.disabled === true) return undefined;\n const next: Role = { ...role };\n if (typeof override.model === 'string') next.model = override.model;\n if (typeof override.thinking === 'string' && THINKING.has(override.thinking))\n next.thinking = override.thinking as Thinking;\n if (typeof override.description === 'string') next.description = override.description;\n if (typeof override.systemPrompt === 'string') next.prompt = override.systemPrompt;\n if (Array.isArray(override.tools))\n next.tools = withMemoryWrite(\n tools(override.tools.map(String), `override for ${role.name}`, warnings),\n role.memory\n );\n return next;\n}\n\nexport interface LoadOptions {\n files: RoleFiles;\n builtin: () => Promise<{ path: string; text: string }[]>;\n dirs: RoleSourceDir[];\n settingsPath: string;\n}\n\nconst ORDER: RoleSource[] = ['project', 'user', 'builtin', 'package'];\n\nexport async function loadRoles(options: LoadOptions, context: Context): Promise<Roles> {\n const warnings: string[] = [];\n const byName = new Map<string, Role>();\n const add = (role: Role | undefined) => {\n if (!role) return;\n const earlier = byName.get(role.name);\n if (!earlier) byName.set(role.name, role);\n else if (role.source === 'package')\n warnings.push(\n `${role.path}: role \"${role.name}\" is already provided by ${earlier.path}; ignored`\n );\n };\n const dirs = [...options.dirs].sort((a, b) => ORDER.indexOf(a.source) - ORDER.indexOf(b.source));\n const read = async (dir: RoleSourceDir) => {\n for (const path of await markdown(options.files, dir.dir, context)) {\n const text = await options.files.readTextFile(path, context);\n if (text.ok) add(parseRole(text.value, dir.source, path, warnings));\n }\n };\n for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) < 2)) await read(dir);\n for (const { path, text } of await options.builtin())\n add(parseRole(text, 'builtin', path, warnings));\n for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) >= 2)) await read(dir);\n const { overrides, limits } = await settings(\n options.files,\n options.settingsPath,\n context,\n warnings\n );\n const roles: Role[] = [];\n for (const role of byName.values()) {\n const applied = apply(role, overrides[role.name], warnings);\n if (applied) roles.push(applied);\n }\n return { roles, warnings, limits };\n}\n\nexport function findRole(roles: readonly Role[], name: string): Role | undefined {\n return (\n roles.find((role) => role.name === name) ?? roles.find((role) => role.aliases.includes(name))\n );\n}\n\nfunction folder(kind: string): boolean {\n return kind === 'directory' || kind === 'symlink';\n}\n\nexport async function manifestDirs(\n files: RoleFiles,\n root: string,\n context: Context\n): Promise<string[]> {\n const top = await files.listDir(root, context);\n if (!top.ok) return [];\n const out: string[] = [];\n for (const entry of top.value) {\n if (!folder(entry.kind) || entry.name.startsWith('.')) continue;\n if (!entry.name.startsWith('@')) {\n out.push(`${root}/${entry.name}`);\n continue;\n }\n const scoped = await files.listDir(`${root}/${entry.name}`, context);\n if (scoped.ok)\n for (const inner of scoped.value)\n if (folder(inner.kind)) out.push(`${root}/${entry.name}/${inner.name}`);\n }\n return out;\n}\n\ntype Manifest = {\n 'pi-subagents'?: { agents?: unknown };\n pi?: { subagents?: { agents?: unknown } };\n};\n\nexport function agentPaths(dir: string, text: string): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const agents = manifest['pi-subagents']?.agents ?? manifest.pi?.subagents?.agents;\n const listed = Array.isArray(agents) ? agents : typeof agents === 'string' ? [agents] : [];\n return listed\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nexport const PACKAGE_ROOTS = ['/node_modules', '/opt/user/node_modules'];\n\nexport interface PiPackage {\n dir: string;\n manifest: string;\n}\n\nexport interface PiPackages {\n packages: PiPackage[];\n skipped: { path: string; message: string }[];\n}\n\nfunction declaresPi(text: string): boolean {\n try {\n const manifest = JSON.parse(text) as Record<string, unknown>;\n return manifest.pi !== undefined || manifest['pi-subagents'] !== undefined;\n } catch {\n return false;\n }\n}\n\nexport async function piPackages(\n files: RoleFiles,\n roots: readonly string[],\n context: Context\n): Promise<PiPackages> {\n const out: PiPackages = { packages: [], skipped: [] };\n const seen = new Map<string, string>();\n for (const root of roots)\n for (const dir of await manifestDirs(files, root, context)) {\n const read = await files.readTextFile(`${dir}/package.json`, context);\n if (!read.ok) continue;\n const name = dir.slice(root.length + 1);\n const earlier = seen.get(name);\n if (earlier === undefined) {\n seen.set(name, dir);\n out.packages.push({ dir, manifest: read.value });\n } else if (declaresPi(read.value))\n out.skipped.push({\n path: dir,\n message: `package \"${name}\" is already installed at ${earlier}, so this copy's skills, prompts and roles are ignored`,\n });\n }\n return out;\n}\n\nexport async function packageDirs(\n files: RoleFiles,\n roots: readonly string[],\n context: Context\n): Promise<string[]> {\n const { packages } = await piPackages(files, roots, context);\n return packages.flatMap(({ dir, manifest }) => agentPaths(dir, manifest));\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAgC,wBAAwB;AA2BjD,MAAM,iBAAiB,EAAE,eAAe,IAAI,YAAY,GAAG;AAElE,MAAM,QAAgC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,cAAc;AAChB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AAO,oBAAI,IAAoB;AACrC,aAAW,QAAQ;AACjB,eAAW,OAAO,MAAM,aAAa,OAAO,MAAM,OAAO,GAAG;AAC1D,YAAM,OAAO,MAAM,MAAM,aAAa,GAAG,GAAG,iBAAiB,OAAO;AACpE,UAAI,CAAC,KAAK,GAAI;AACd,YAAM,OAAO,IAAI,MAAM,KAAK,SAAS,CAAC;AACtC,YAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,UAAI,YAAY,QAAW;AACzB,aAAK,IAAI,MAAM,GAAG;AAClB,YAAI,SAAS,KAAK,EAAE,KAAK,UAAU,KAAK,MAAM,CAAC;AAAA,MACjD,WAAW,WAAW,KAAK,KAAK;AAC9B,YAAI,QAAQ,KAAK;AAAA,UACf,MAAM;AAAA,UACN,SAAS,YAAY,IAAI,6BAA6B,OAAO;AAAA,QAC/D,CAAC;AAAA,IACL;AACF,SAAO;AACT;AAEA,eAAsB,YACpB,OACA,OACA,SACmB;AACnB,QAAM,EAAE,SAAS,IAAI,MAAM,WAAW,OAAO,OAAO,OAAO;AAC3D,SAAO,SAAS,QAAQ,CAAC,EAAE,KAAK,SAAS,MAAM,WAAW,KAAK,QAAQ,CAAC;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/scoops/index.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { live } from "../agents.js";
|
|
2
2
|
import { LEGACY } from "../layout.js";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_LIMITS,
|
|
5
|
+
loadRoles,
|
|
6
|
+
PACKAGE_ROOTS,
|
|
7
|
+
packageDirs
|
|
8
|
+
} from "../roles/roles.js";
|
|
4
9
|
import { createCli, RUN_DIR } from "./cli.js";
|
|
5
10
|
import { guardExtension, scoopsExtension, scoopTasks } from "./extension.js";
|
|
6
11
|
import {
|
|
@@ -207,7 +212,7 @@ function setupScoops(registry, licks, fileTools = []) {
|
|
|
207
212
|
files: env,
|
|
208
213
|
builtin,
|
|
209
214
|
dirs: [
|
|
210
|
-
...(await packageDirs(env,
|
|
215
|
+
...(await packageDirs(env, PACKAGE_ROOTS, using)).map((dir) => ({
|
|
211
216
|
source: "package",
|
|
212
217
|
dir
|
|
213
218
|
})),
|
package/dist/scoops/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/scoops/index.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { Harness, Registry, ToolRegistration } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { type Agents, live } from '../agents.ts';\nimport type { ProcessGroups } from '../kernel/groups.ts';\nimport { type Layout, LEGACY } from '../layout.ts';\nimport type { Licks } from '../licks/licks.ts';\nimport { DEFAULT_LIMITS, loadRoles, packageDirs, type Roles } from '../roles/roles.ts';\nimport { type CliOptions, createCli, RUN_DIR } from './cli.ts';\nimport { guardExtension, scoopsExtension, scoopTasks } from './extension.ts';\nimport {\n CONTROL_DIR,\n type ControlPlane,\n controlPlane,\n type PlaneOptions,\n PROTOCOL,\n} from './requests.ts';\nimport { createScoops, type Scoops, type ScoopsHost } from './service.ts';\n\nexport const BUILTIN_ROLES = ['scout', 'worker', 'reviewer', 'oracle', 'delegate', 'gelatiere'];\nexport const PNPM_HOME = '/home/.local/share/pnpm';\nexport const BIN_DIR = '/usr/local/bin';\n\nexport type Assets = (path: string) => Promise<string>;\n\nexport function packageAssets(base: URL = new URL('../../', import.meta.url)): Assets {\n return async (path) => {\n const response = await fetch(new URL(path, base));\n if (!response.ok) throw new Error(`${path}: ${response.status}`);\n return response.text();\n };\n}\n\nexport interface AttachOptions {\n harness: Harness;\n agents: Agents;\n groups: ProcessGroups;\n env: ExecutionEnv;\n home: string;\n assets?: Assets;\n binDir?: string;\n controlDir?: string;\n sweepEvery?: number;\n alive?: (pid: number) => Promise<boolean>;\n reads: () => readonly string[];\n memory?: CliOptions['memory'];\n gelatiere?: CliOptions['gelatiere'];\n freezer?: CliOptions['freezer'];\n models?: CliOptions['models'];\n panel?: CliOptions['panel'];\n mcp?: (names: readonly string[]) => ToolRegistration[];\n layout?: Layout;\n enforced?: boolean;\n spools?: Spools;\n agentDir?: string;\n}\n\nexport interface Spools {\n users(): readonly string[];\n prepare(user: string, dir: string, context: Context): Promise<void>;\n}\n\nexport interface ScoopsRuntime {\n roles(context: Context): Promise<Roles>;\n plane: ControlPlane;\n close(context: Context): Promise<void>;\n}\n\nexport interface ScoopsSetup {\n scoops: Scoops;\n attach(options: AttachOptions, context: Context): Promise<ScoopsRuntime>;\n}\n\nexport const COMMANDS = ['agent', 'subagent', 'memory', 'gelatiere', 'freezer', 'models', 'panel'];\n\nexport const RETIRED_COMMANDS = ['sprinkle'];\n\nexport async function pnpmHomeOf(env: ExecutionEnv, context: Context): Promise<string> {\n let out = '';\n const ran = await env\n .exec(\n 'printf %s \"$PNPM_HOME\"',\n {\n onOutput: (text) => {\n out += text;\n },\n },\n context\n )\n .catch(() => undefined);\n return ran?.ok && ran.value.exitCode === 0 && /^\\/\\S*$/.test(out) ? out : PNPM_HOME;\n}\n\nexport interface Installed {\n done: boolean;\n skipped: string[];\n}\n\nasync function theirs(env: ExecutionEnv, path: string, context: Context): Promise<boolean> {\n const found = await env.fileInfo(path, context);\n if (!found.ok) return found.error.code !== 'not_found';\n if (found.value.kind !== 'file') return true;\n const read = await env.readTextFile(path, context);\n return !read.ok || !read.value.includes(PROTOCOL);\n}\n\nasync function install(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context\n): Promise<Installed> {\n const skipped: string[] = [];\n if (!(await env.createDir(binDir, { recursive: true }, context)).ok)\n return { done: false, skipped };\n for (const name of COMMANDS) {\n const path = `${binDir}/${name}`;\n if (await theirs(env, path, context)) {\n skipped.push(name);\n continue;\n }\n if (!(await env.writeFile(path, script, context)).ok) return { done: false, skipped };\n const mode = await env.exec(['chmod', '755', path], undefined, context);\n if (!mode.ok || mode.value.exitCode !== 0) return { done: false, skipped };\n }\n for (const name of RETIRED_COMMANDS) {\n const text = await env.readTextFile(`${binDir}/${name}`, context);\n if (text.ok && text.value.includes(PROTOCOL))\n await env.remove(`${binDir}/${name}`, { force: true }, context);\n }\n return { done: true, skipped };\n}\n\nexport async function installCommands(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context,\n warn: (message: string) => void = (message) => console.warn(message)\n): Promise<Installed> {\n const installed = await install(env, script, binDir, context).catch(\n (): Installed => ({ done: false, skipped: [] })\n );\n if (installed.skipped.length) {\n const paths = installed.skipped.map((name) => `${binDir}/${name}`).join(', ');\n warn(`slicc-agent: left ${paths} alone, because it isn't slicc-agent's command`);\n }\n if (installed.done) await retire(env, binDir, context).catch(() => undefined);\n return installed;\n}\n\nexport async function retire(env: ExecutionEnv, binDir: string, context: Context) {\n const old = `${await pnpmHomeOf(env, context)}/bin`;\n if (old === binDir) return;\n for (const name of [...COMMANDS, ...RETIRED_COMMANDS]) {\n const path = `${old}/${name}`;\n const text = await env.readTextFile(path, context);\n if (text.ok && text.value.includes(PROTOCOL)) await env.remove(path, { force: true }, context);\n }\n}\n\nfunction mirror(agents: Agents, env: ExecutionEnv) {\n return async (context: Context) => {\n for (const [id, record] of Object.entries(agents.state().scoops)) {\n const state = record.gone ? 'gone' : live(record) ? 'live' : 'stopped';\n const metadata = {\n handle: record.folder,\n id,\n name: record.name,\n role: record.role,\n cone: record.cone,\n state,\n };\n await env.writeFile(\n `${RUN_DIR}/${record.folder}/metadata.json`,\n `${JSON.stringify(metadata, null, 2)}\\n`,\n context\n );\n }\n };\n}\n\nfunction planeOf(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n options: AttachOptions,\n context: Context\n): ControlPlane {\n const common: PlaneOptions & { dir: string } = {\n ...(options.sweepEvery ? { sweepEvery: options.sweepEvery } : {}),\n mirror: mirror(options.agents, env),\n dir: options.controlDir ?? CONTROL_DIR,\n };\n if (!options.spools) return controlPlane(env, cli, common);\n return spooled(env, cli, options.spools, options.agents, common, context);\n}\n\nfunction spooled(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n spools: Spools,\n agents: Agents,\n options: PlaneOptions & { dir: string },\n context: Context\n): ControlPlane {\n const planes = new Map<string, Promise<ControlPlane | undefined>>();\n let off: () => void = () => undefined;\n let chain: Promise<unknown> = Promise.resolve();\n const open = async (user: string): Promise<ControlPlane | undefined> => {\n const dir = `${options.dir}/${user}`;\n try {\n await spools.prepare(user, dir, context);\n const plane = controlPlane(env, cli, { ...options, dir, user });\n await plane.start(context);\n return plane;\n } catch {\n planes.delete(user);\n return undefined;\n }\n };\n const sync = () => {\n const step = async () => {\n const wanted = new Set(spools.users());\n for (const user of wanted)\n if (!planes.has(user)) {\n const opened = open(user);\n planes.set(user, opened);\n await opened;\n }\n for (const [user, plane] of [...planes])\n if (!wanted.has(user)) {\n planes.delete(user);\n await (await plane)?.close(context);\n }\n };\n chain = chain.then(step, step);\n return chain;\n };\n const all = async () =>\n (await Promise.all(planes.values())).filter((plane): plane is ControlPlane => !!plane);\n return {\n async start() {\n off = agents.onChange(() => void sync());\n await sync();\n },\n async sweep(using) {\n for (const plane of await all()) await plane.sweep(using);\n },\n async close(using) {\n off();\n await chain;\n for (const plane of await all()) await plane.close(using);\n planes.clear();\n },\n };\n}\n\nexport function setupScoops(\n registry: Registry,\n licks: Licks,\n fileTools: readonly ToolRegistration[] = []\n): ScoopsSetup {\n let bind: (host: ScoopsHost) => void = () => undefined;\n const host = new Promise<ScoopsHost>((resolve) => {\n bind = resolve;\n });\n const lookup = () => host;\n const tasks = scoopTasks(lookup);\n const scoops = createScoops(host, () => tasks);\n let cached: Roles = { roles: [], warnings: [], limits: { ...DEFAULT_LIMITS } };\n let layout = LEGACY;\n registry.install(scoopsExtension(tasks, () => layout));\n registry.install(guardExtension(lookup, fileTools));\n return {\n scoops,\n async attach(options, context) {\n const { harness, agents, groups, env, home } = options;\n const assets = options.assets ?? packageAssets();\n layout = options.layout ?? LEGACY;\n bind({\n harness,\n agents,\n licks,\n tools: fileTools,\n groups,\n reads: options.reads,\n files: env,\n layout,\n ...(options.enforced ? { enforced: true } : {}),\n ...(options.mcp ? { mcp: options.mcp } : {}),\n });\n const builtin = async () => {\n const out: { path: string; text: string }[] = [];\n for (const name of BUILTIN_ROLES) {\n const path = `packages/vfs-root/agents/${name}.md`;\n out.push({ path: `builtin:${name}`, text: await assets(path) });\n }\n return out;\n };\n const roles = async (using: Context) => {\n cached = await loadRoles(\n {\n files: env,\n builtin,\n dirs: [\n ...(await packageDirs(env, '/node_modules', using)).map((dir) => ({\n source: 'package' as const,\n dir,\n })),\n { source: 'user', dir: `${options.agentDir ?? `${home}/.pi/agent`}/agents` },\n ],\n settingsPath: `${options.agentDir ?? `${home}/.pi/agent`}/settings.json`,\n },\n using\n );\n return cached;\n };\n await roles(context).catch(() => cached);\n const script = await assets('bin/agent').catch(() => undefined);\n if (script) {\n const binDir = options.binDir ?? BIN_DIR;\n await installCommands(env, script, binDir, context);\n }\n const cli = createCli({\n env,\n harness,\n agents,\n scoops,\n roles: () => roles(context),\n ...(options.alive ? { alive: options.alive } : {}),\n ...(options.memory ? { memory: options.memory } : {}),\n ...(options.gelatiere ? { gelatiere: options.gelatiere } : {}),\n ...(options.freezer ? { freezer: options.freezer } : {}),\n ...(options.models ? { models: options.models } : {}),\n layout,\n ...(options.panel ? { panel: options.panel } : {}),\n });\n const plane = planeOf(env, cli, options, context);\n await plane.start(context);\n return { roles, plane, close: (using) => plane.close(using) };\n },\n };\n}\n\nexport type { Rewound, Scoops } from './service.ts';\n"],
|
|
5
|
-
"mappings": "AAGA,SAAsB,YAAY;AAElC,SAAsB,cAAc;AAEpC,
|
|
4
|
+
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { Harness, Registry, ToolRegistration } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { type Agents, live } from '../agents.ts';\nimport type { ProcessGroups } from '../kernel/groups.ts';\nimport { type Layout, LEGACY } from '../layout.ts';\nimport type { Licks } from '../licks/licks.ts';\nimport {\n DEFAULT_LIMITS,\n loadRoles,\n PACKAGE_ROOTS,\n packageDirs,\n type Roles,\n} from '../roles/roles.ts';\nimport { type CliOptions, createCli, RUN_DIR } from './cli.ts';\nimport { guardExtension, scoopsExtension, scoopTasks } from './extension.ts';\nimport {\n CONTROL_DIR,\n type ControlPlane,\n controlPlane,\n type PlaneOptions,\n PROTOCOL,\n} from './requests.ts';\nimport { createScoops, type Scoops, type ScoopsHost } from './service.ts';\n\nexport const BUILTIN_ROLES = ['scout', 'worker', 'reviewer', 'oracle', 'delegate', 'gelatiere'];\nexport const PNPM_HOME = '/home/.local/share/pnpm';\nexport const BIN_DIR = '/usr/local/bin';\n\nexport type Assets = (path: string) => Promise<string>;\n\nexport function packageAssets(base: URL = new URL('../../', import.meta.url)): Assets {\n return async (path) => {\n const response = await fetch(new URL(path, base));\n if (!response.ok) throw new Error(`${path}: ${response.status}`);\n return response.text();\n };\n}\n\nexport interface AttachOptions {\n harness: Harness;\n agents: Agents;\n groups: ProcessGroups;\n env: ExecutionEnv;\n home: string;\n assets?: Assets;\n binDir?: string;\n controlDir?: string;\n sweepEvery?: number;\n alive?: (pid: number) => Promise<boolean>;\n reads: () => readonly string[];\n memory?: CliOptions['memory'];\n gelatiere?: CliOptions['gelatiere'];\n freezer?: CliOptions['freezer'];\n models?: CliOptions['models'];\n panel?: CliOptions['panel'];\n mcp?: (names: readonly string[]) => ToolRegistration[];\n layout?: Layout;\n enforced?: boolean;\n spools?: Spools;\n agentDir?: string;\n}\n\nexport interface Spools {\n users(): readonly string[];\n prepare(user: string, dir: string, context: Context): Promise<void>;\n}\n\nexport interface ScoopsRuntime {\n roles(context: Context): Promise<Roles>;\n plane: ControlPlane;\n close(context: Context): Promise<void>;\n}\n\nexport interface ScoopsSetup {\n scoops: Scoops;\n attach(options: AttachOptions, context: Context): Promise<ScoopsRuntime>;\n}\n\nexport const COMMANDS = ['agent', 'subagent', 'memory', 'gelatiere', 'freezer', 'models', 'panel'];\n\nexport const RETIRED_COMMANDS = ['sprinkle'];\n\nexport async function pnpmHomeOf(env: ExecutionEnv, context: Context): Promise<string> {\n let out = '';\n const ran = await env\n .exec(\n 'printf %s \"$PNPM_HOME\"',\n {\n onOutput: (text) => {\n out += text;\n },\n },\n context\n )\n .catch(() => undefined);\n return ran?.ok && ran.value.exitCode === 0 && /^\\/\\S*$/.test(out) ? out : PNPM_HOME;\n}\n\nexport interface Installed {\n done: boolean;\n skipped: string[];\n}\n\nasync function theirs(env: ExecutionEnv, path: string, context: Context): Promise<boolean> {\n const found = await env.fileInfo(path, context);\n if (!found.ok) return found.error.code !== 'not_found';\n if (found.value.kind !== 'file') return true;\n const read = await env.readTextFile(path, context);\n return !read.ok || !read.value.includes(PROTOCOL);\n}\n\nasync function install(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context\n): Promise<Installed> {\n const skipped: string[] = [];\n if (!(await env.createDir(binDir, { recursive: true }, context)).ok)\n return { done: false, skipped };\n for (const name of COMMANDS) {\n const path = `${binDir}/${name}`;\n if (await theirs(env, path, context)) {\n skipped.push(name);\n continue;\n }\n if (!(await env.writeFile(path, script, context)).ok) return { done: false, skipped };\n const mode = await env.exec(['chmod', '755', path], undefined, context);\n if (!mode.ok || mode.value.exitCode !== 0) return { done: false, skipped };\n }\n for (const name of RETIRED_COMMANDS) {\n const text = await env.readTextFile(`${binDir}/${name}`, context);\n if (text.ok && text.value.includes(PROTOCOL))\n await env.remove(`${binDir}/${name}`, { force: true }, context);\n }\n return { done: true, skipped };\n}\n\nexport async function installCommands(\n env: ExecutionEnv,\n script: string,\n binDir: string,\n context: Context,\n warn: (message: string) => void = (message) => console.warn(message)\n): Promise<Installed> {\n const installed = await install(env, script, binDir, context).catch(\n (): Installed => ({ done: false, skipped: [] })\n );\n if (installed.skipped.length) {\n const paths = installed.skipped.map((name) => `${binDir}/${name}`).join(', ');\n warn(`slicc-agent: left ${paths} alone, because it isn't slicc-agent's command`);\n }\n if (installed.done) await retire(env, binDir, context).catch(() => undefined);\n return installed;\n}\n\nexport async function retire(env: ExecutionEnv, binDir: string, context: Context) {\n const old = `${await pnpmHomeOf(env, context)}/bin`;\n if (old === binDir) return;\n for (const name of [...COMMANDS, ...RETIRED_COMMANDS]) {\n const path = `${old}/${name}`;\n const text = await env.readTextFile(path, context);\n if (text.ok && text.value.includes(PROTOCOL)) await env.remove(path, { force: true }, context);\n }\n}\n\nfunction mirror(agents: Agents, env: ExecutionEnv) {\n return async (context: Context) => {\n for (const [id, record] of Object.entries(agents.state().scoops)) {\n const state = record.gone ? 'gone' : live(record) ? 'live' : 'stopped';\n const metadata = {\n handle: record.folder,\n id,\n name: record.name,\n role: record.role,\n cone: record.cone,\n state,\n };\n await env.writeFile(\n `${RUN_DIR}/${record.folder}/metadata.json`,\n `${JSON.stringify(metadata, null, 2)}\\n`,\n context\n );\n }\n };\n}\n\nfunction planeOf(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n options: AttachOptions,\n context: Context\n): ControlPlane {\n const common: PlaneOptions & { dir: string } = {\n ...(options.sweepEvery ? { sweepEvery: options.sweepEvery } : {}),\n mirror: mirror(options.agents, env),\n dir: options.controlDir ?? CONTROL_DIR,\n };\n if (!options.spools) return controlPlane(env, cli, common);\n return spooled(env, cli, options.spools, options.agents, common, context);\n}\n\nfunction spooled(\n env: ExecutionEnv,\n cli: ReturnType<typeof createCli>,\n spools: Spools,\n agents: Agents,\n options: PlaneOptions & { dir: string },\n context: Context\n): ControlPlane {\n const planes = new Map<string, Promise<ControlPlane | undefined>>();\n let off: () => void = () => undefined;\n let chain: Promise<unknown> = Promise.resolve();\n const open = async (user: string): Promise<ControlPlane | undefined> => {\n const dir = `${options.dir}/${user}`;\n try {\n await spools.prepare(user, dir, context);\n const plane = controlPlane(env, cli, { ...options, dir, user });\n await plane.start(context);\n return plane;\n } catch {\n planes.delete(user);\n return undefined;\n }\n };\n const sync = () => {\n const step = async () => {\n const wanted = new Set(spools.users());\n for (const user of wanted)\n if (!planes.has(user)) {\n const opened = open(user);\n planes.set(user, opened);\n await opened;\n }\n for (const [user, plane] of [...planes])\n if (!wanted.has(user)) {\n planes.delete(user);\n await (await plane)?.close(context);\n }\n };\n chain = chain.then(step, step);\n return chain;\n };\n const all = async () =>\n (await Promise.all(planes.values())).filter((plane): plane is ControlPlane => !!plane);\n return {\n async start() {\n off = agents.onChange(() => void sync());\n await sync();\n },\n async sweep(using) {\n for (const plane of await all()) await plane.sweep(using);\n },\n async close(using) {\n off();\n await chain;\n for (const plane of await all()) await plane.close(using);\n planes.clear();\n },\n };\n}\n\nexport function setupScoops(\n registry: Registry,\n licks: Licks,\n fileTools: readonly ToolRegistration[] = []\n): ScoopsSetup {\n let bind: (host: ScoopsHost) => void = () => undefined;\n const host = new Promise<ScoopsHost>((resolve) => {\n bind = resolve;\n });\n const lookup = () => host;\n const tasks = scoopTasks(lookup);\n const scoops = createScoops(host, () => tasks);\n let cached: Roles = { roles: [], warnings: [], limits: { ...DEFAULT_LIMITS } };\n let layout = LEGACY;\n registry.install(scoopsExtension(tasks, () => layout));\n registry.install(guardExtension(lookup, fileTools));\n return {\n scoops,\n async attach(options, context) {\n const { harness, agents, groups, env, home } = options;\n const assets = options.assets ?? packageAssets();\n layout = options.layout ?? LEGACY;\n bind({\n harness,\n agents,\n licks,\n tools: fileTools,\n groups,\n reads: options.reads,\n files: env,\n layout,\n ...(options.enforced ? { enforced: true } : {}),\n ...(options.mcp ? { mcp: options.mcp } : {}),\n });\n const builtin = async () => {\n const out: { path: string; text: string }[] = [];\n for (const name of BUILTIN_ROLES) {\n const path = `packages/vfs-root/agents/${name}.md`;\n out.push({ path: `builtin:${name}`, text: await assets(path) });\n }\n return out;\n };\n const roles = async (using: Context) => {\n cached = await loadRoles(\n {\n files: env,\n builtin,\n dirs: [\n ...(await packageDirs(env, PACKAGE_ROOTS, using)).map((dir) => ({\n source: 'package' as const,\n dir,\n })),\n { source: 'user', dir: `${options.agentDir ?? `${home}/.pi/agent`}/agents` },\n ],\n settingsPath: `${options.agentDir ?? `${home}/.pi/agent`}/settings.json`,\n },\n using\n );\n return cached;\n };\n await roles(context).catch(() => cached);\n const script = await assets('bin/agent').catch(() => undefined);\n if (script) {\n const binDir = options.binDir ?? BIN_DIR;\n await installCommands(env, script, binDir, context);\n }\n const cli = createCli({\n env,\n harness,\n agents,\n scoops,\n roles: () => roles(context),\n ...(options.alive ? { alive: options.alive } : {}),\n ...(options.memory ? { memory: options.memory } : {}),\n ...(options.gelatiere ? { gelatiere: options.gelatiere } : {}),\n ...(options.freezer ? { freezer: options.freezer } : {}),\n ...(options.models ? { models: options.models } : {}),\n layout,\n ...(options.panel ? { panel: options.panel } : {}),\n });\n const plane = planeOf(env, cli, options, context);\n await plane.start(context);\n return { roles, plane, close: (using) => plane.close(using) };\n },\n };\n}\n\nexport type { Rewound, Scoops } from './service.ts';\n"],
|
|
5
|
+
"mappings": "AAGA,SAAsB,YAAY;AAElC,SAAsB,cAAc;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAA0B,WAAW,eAAe;AACpD,SAAS,gBAAgB,iBAAiB,kBAAkB;AAC5D;AAAA,EACE;AAAA,EAEA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,oBAAkD;AAEpD,MAAM,gBAAgB,CAAC,SAAS,UAAU,YAAY,UAAU,YAAY,WAAW;AACvF,MAAM,YAAY;AAClB,MAAM,UAAU;AAIhB,SAAS,cAAc,OAAY,IAAI,IAAI,UAAU,YAAY,GAAG,GAAW;AACpF,SAAO,OAAO,SAAS;AACrB,UAAM,WAAW,MAAM,MAAM,IAAI,IAAI,MAAM,IAAI,CAAC;AAChD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,GAAG,IAAI,KAAK,SAAS,MAAM,EAAE;AAC/D,WAAO,SAAS,KAAK;AAAA,EACvB;A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@ import {
|
|
|
3
3
|
defineExtension,
|
|
4
4
|
section
|
|
5
5
|
} from "@earendil-works/pi-durable";
|
|
6
|
-
import {
|
|
6
|
+
import { PACKAGE_ROOTS, piPackages } from "../roles/roles.js";
|
|
7
7
|
import {
|
|
8
8
|
expandSkillCommand,
|
|
9
9
|
formatSkillsForPrompt,
|
|
@@ -42,13 +42,8 @@ function piResources(dir, text, kind) {
|
|
|
42
42
|
const paths = Array.isArray(listed) ? listed : typeof listed === "string" ? [listed] : [];
|
|
43
43
|
return paths.filter((path) => typeof path === "string").map((path) => `${dir}/${path.replace(/^\.\//, "").replace(/\/$/, "")}`);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
for (const dir of await manifestDirs(env, "/node_modules", context)) {
|
|
48
|
-
const read = await env.readTextFile(`${dir}/package.json`, context);
|
|
49
|
-
if (read.ok) out.push(...piResources(dir, read.value, kind));
|
|
50
|
-
}
|
|
51
|
-
return out;
|
|
45
|
+
function packaged(found, kind) {
|
|
46
|
+
return found.packages.flatMap(({ dir, manifest }) => piResources(dir, manifest, kind));
|
|
52
47
|
}
|
|
53
48
|
async function installBuiltins(env, assets, context) {
|
|
54
49
|
await env.remove(SKILLS_DIR, { recursive: true, force: true }, context);
|
|
@@ -130,17 +125,15 @@ function setupSkills(registry, licks) {
|
|
|
130
125
|
const commands = replicatedState([]);
|
|
131
126
|
const reported = /* @__PURE__ */ new Set();
|
|
132
127
|
const reload = async (using) => {
|
|
128
|
+
const packages = await piPackages(env, PACKAGE_ROOTS, using);
|
|
133
129
|
const roots = [
|
|
134
130
|
...options.people ? [{ dir: GLOBAL_DIR, source: "global" }] : [
|
|
135
131
|
{ dir: `${dir}/skills`, source: "user" },
|
|
136
132
|
{ dir: `${home}/.agents/skills`, source: "user" },
|
|
137
133
|
{ dir: GLOBAL_DIR, source: "global" }
|
|
138
134
|
],
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
source: "package"
|
|
142
|
-
})),
|
|
143
|
-
{ dir: SKILLS_DIR, source: "builtin" }
|
|
135
|
+
{ dir: SKILLS_DIR, source: "builtin" },
|
|
136
|
+
...packaged(packages, "skills").map((dir2) => ({ dir: dir2, source: "package" }))
|
|
144
137
|
];
|
|
145
138
|
const loaded = await loadSkills(env, roots, using);
|
|
146
139
|
const homesLoaded = /* @__PURE__ */ new Map();
|
|
@@ -154,13 +147,17 @@ function setupSkills(registry, licks) {
|
|
|
154
147
|
own = homesLoaded;
|
|
155
148
|
const prompts = await loadTemplates(
|
|
156
149
|
env,
|
|
157
|
-
[`${dir}/prompts`, ...
|
|
150
|
+
[`${dir}/prompts`, PROMPTS_DIR, ...packaged(packages, "prompts")],
|
|
158
151
|
using
|
|
159
152
|
);
|
|
160
153
|
current = loaded.skills;
|
|
161
154
|
templates = prompts.templates;
|
|
162
155
|
commands.replace(using, commandsOf(current, templates));
|
|
163
|
-
for (const problem of [
|
|
156
|
+
for (const problem of [
|
|
157
|
+
...packages.skipped,
|
|
158
|
+
...loaded.diagnostics,
|
|
159
|
+
...prompts.diagnostics
|
|
160
|
+
]) {
|
|
164
161
|
const key = `${problem.path}
|
|
165
162
|
${problem.message}`;
|
|
166
163
|
if (reported.has(key)) continue;
|
package/dist/skills/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/skills/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { type Context, type ReplicatedState, replicatedState } from '@earendil-works/chord';\nimport {\n defineExtension,\n type Extension,\n type Registry,\n section,\n} from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileWatcher } from '@earendil-works/pi-durable/env';\nimport type { Licks } from '../licks/licks.ts';\nimport { manifestDirs } from '../roles/roles.ts';\nimport type { Command } from '../services.ts';\nimport {\n type Diagnostic,\n expandSkillCommand,\n formatSkillsForPrompt,\n loadSkills,\n type Skill,\n type SkillRoot,\n} from './skills.ts';\nimport { expandPromptTemplate, loadTemplates, type PromptTemplate } from './templates.ts';\n\nexport const BUILTIN_SKILLS = [\n 'agent',\n 'browser',\n 'gelatiere',\n 'licks',\n 'memory',\n 'skill-authoring',\n 'sprinkles',\n 'welcome',\n];\nexport const BUILTIN_PROMPTS = ['parallel-review', 'review-loop'];\nexport const SKILLS_DIR = '/var/lib/slicc/agent/skills';\nexport const PROMPTS_DIR = '/var/lib/slicc/agent/prompts';\nexport const GLOBAL_DIR = '/usr/share/skills';\nexport const RELOAD_MS = 300;\n\nexport interface SkillsRuntime {\n readonly commands: ReplicatedState<Command[]>;\n skills(): readonly Skill[];\n dirs(): string[];\n templates(): readonly PromptTemplate[];\n expand(text: string, context: Context, conversationId?: number): Promise<string>;\n reload(context: Context): Promise<void>;\n close(context: Context): Promise<void>;\n}\n\nexport interface SkillsAttach {\n env: ExecutionEnv;\n home: string;\n agentDir?: string;\n assets?: (path: string) => Promise<string>;\n reloadMs: number;\n people?: SkillPeople;\n}\n\nexport interface SkillPeople {\n homes(): readonly string[];\n homeOf(conversationId: number | undefined): string | undefined;\n envOf(home: string): Promise<ExecutionEnv | undefined>;\n}\n\nexport function userRoots(homes: readonly string[]): SkillRoot[] {\n return homes.flatMap((home) => [\n { dir: `${home}/.pi/agent/skills`, source: 'user' as const },\n { dir: `${home}/.agents/skills`, source: 'user' as const },\n ]);\n}\n\nexport interface SkillsSetup {\n extension: Extension;\n attach(options: SkillsAttach, context: Context): Promise<SkillsRuntime>;\n}\n\ntype Manifest = { pi?: { skills?: unknown; prompts?: unknown } };\n\nexport function piResources(dir: string, text: string, kind: 'skills' | 'prompts'): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const listed = manifest.pi?.[kind];\n const paths = Array.isArray(listed) ? listed : typeof listed === 'string' ? [listed] : [];\n return paths\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nasync function packaged(env: ExecutionEnv, kind: 'skills' | 'prompts', context: Context) {\n const out: string[] = [];\n for (const dir of await manifestDirs(env, '/node_modules', context)) {\n const read = await env.readTextFile(`${dir}/package.json`, context);\n if (read.ok) out.push(...piResources(dir, read.value, kind));\n }\n return out;\n}\n\nasync function installBuiltins(\n env: ExecutionEnv,\n assets: (path: string) => Promise<string>,\n context: Context\n): Promise<void> {\n await env.remove(SKILLS_DIR, { recursive: true, force: true }, context);\n await env.remove(PROMPTS_DIR, { recursive: true, force: true }, context);\n for (const name of BUILTIN_SKILLS) {\n const text = await assets(`packages/vfs-root/skills/${name}/SKILL.md`).catch(() => undefined);\n if (text === undefined) continue;\n await env.createDir(`${SKILLS_DIR}/${name}`, { recursive: true }, context);\n await env.writeFile(`${SKILLS_DIR}/${name}/SKILL.md`, text, context);\n }\n await env.createDir(PROMPTS_DIR, { recursive: true }, context);\n for (const name of BUILTIN_PROMPTS) {\n const text = await assets(`packages/vfs-root/prompts/${name}.md`).catch(() => undefined);\n if (text !== undefined) await env.writeFile(`${PROMPTS_DIR}/${name}.md`, text, context);\n }\n}\n\nexport function problemLick(problem: Diagnostic, home: string) {\n const path = problem.path.startsWith(`${home}/`)\n ? `~${problem.path.slice(home.length)}`\n : problem.path;\n return {\n channel: 'fswatch' as const,\n source: `skills:${path}`,\n title: `Skill or prompt template problem: ${path}`,\n text: problem.message,\n body: 'The file is used with this problem, or skipped if it has no description.\\nThe rules are in the slicc-agent README.',\n target: 'cone' as const,\n severity: 'warn' as const,\n eventId: `${path}\\n${problem.message}`,\n };\n}\n\nexport const SECRETS_ACTION: Command = {\n name: 'secrets',\n description: 'List the secrets the agent can use, and where each works',\n kind: 'action',\n};\n\nexport function commandsOf(\n skills: readonly Skill[],\n templates: readonly PromptTemplate[]\n): Command[] {\n return [\n ...templates.map((template) => ({\n name: template.name,\n description: template.description,\n kind: 'prompt' as const,\n })),\n ...skills.map((skill) => ({\n name: `skill:${skill.name}`,\n description: skill.description,\n kind: 'skill' as const,\n })),\n SECRETS_ACTION,\n ];\n}\n\nexport function setupSkills(registry: Registry, licks: Licks): SkillsSetup {\n let current: Skill[] = [];\n let own = new Map<string, Skill[]>();\n let people: SkillPeople | undefined;\n const mine = (conversationId: number | undefined) => {\n const at = people?.homeOf(conversationId);\n return (at ? own.get(at) : undefined) ?? current;\n };\n const extension = defineExtension({\n name: 'slicc-skills',\n sections: [\n section('skills', async (input) => {\n return formatSkillsForPrompt(mine(input.conversationId)) || undefined;\n }),\n ],\n });\n registry.install(extension);\n return {\n extension,\n async attach(options, context) {\n const { env, home } = options;\n const dir = options.agentDir ?? `${home}/.pi/agent`;\n people = options.people;\n const homes = () => options.people?.homes() ?? [];\n if (options.assets)\n await installBuiltins(env, options.assets, context).catch(() => undefined);\n await env.exec(`mkdir -p ${GLOBAL_DIR} && chmod 755 ${GLOBAL_DIR}`, undefined, context);\n let templates: PromptTemplate[] = [];\n const commands = replicatedState<Command[]>([]);\n const reported = new Set<string>();\n const reload = async (using: Context) => {\n const roots: SkillRoot[] = [\n ...(options.people\n ? [{ dir: GLOBAL_DIR, source: 'global' as const }]\n : [\n { dir: `${dir}/skills`, source: 'user' as const },\n { dir: `${home}/.agents/skills`, source: 'user' as const },\n { dir: GLOBAL_DIR, source: 'global' as const },\n ]),\n ...(await packaged(env, 'skills', using)).map((dir) => ({\n dir,\n source: 'package' as const,\n })),\n { dir: SKILLS_DIR, source: 'builtin' },\n ];\n const loaded = await loadSkills(env, roots, using);\n const homesLoaded = new Map<string, Skill[]>();\n for (const at of homes()) {\n const files = await options.people?.envOf(at);\n if (!files) continue;\n const found = await loadSkills(files, [...userRoots([at]), ...roots], using);\n homesLoaded.set(at, found.skills);\n loaded.diagnostics.push(...found.diagnostics);\n }\n own = homesLoaded;\n const prompts = await loadTemplates(\n env,\n [`${dir}/prompts`, ...(await packaged(env, 'prompts', using)), PROMPTS_DIR],\n using\n );\n current = loaded.skills;\n templates = prompts.templates;\n commands.replace(using, commandsOf(current, templates));\n for (const problem of [...loaded.diagnostics, ...prompts.diagnostics]) {\n const key = `${problem.path}\\n${problem.message}`;\n if (reported.has(key)) continue;\n reported.add(key);\n await licks.deliver(problemLick(problem, home), using).catch(() => undefined);\n }\n };\n await reload(context);\n let timer: ReturnType<typeof setTimeout> | undefined;\n const schedule = () => {\n clearTimeout(timer);\n timer = setTimeout(() => void reload(context).catch(() => undefined), options.reloadMs);\n };\n let watcher: FileWatcher | undefined;\n let seen = '';\n const watch = async (using: Context) => {\n const extra = options.people\n ? userRoots(homes()).map((root) => ({ path: root.dir, recursive: true }))\n : [\n { path: `${dir}/skills`, recursive: true },\n { path: `${home}/.agents/skills`, recursive: true },\n ];\n const key = JSON.stringify(extra);\n if (key === seen) return;\n seen = key;\n await watcher?.close(using);\n const watched = await env.watch(\n [{ path: GLOBAL_DIR, recursive: true }, { path: `${dir}/prompts` }, ...extra],\n schedule,\n using\n );\n watcher = watched.ok ? watched.value : undefined;\n };\n await watch(context);\n return {\n commands,\n skills: () => current,\n dirs: () => current.map((skill) => skill.baseDir),\n templates: () => templates,\n async expand(text, using, conversationId) {\n const at = people?.homeOf(conversationId);\n const files = at ? await people?.envOf(at) : env;\n if (!files) return text;\n const expanded = await expandSkillCommand(text, mine(conversationId), files, using);\n return expanded === text ? expandPromptTemplate(text, templates) : expanded;\n },\n async reload(using) {\n await watch(using);\n await reload(using);\n },\n async close(using) {\n clearTimeout(timer);\n await watcher?.close(using);\n },\n };\n },\n };\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAA6C,uBAAuB;AACpE;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AAGP,SAAS,
|
|
4
|
+
"sourcesContent": ["import { type Context, type ReplicatedState, replicatedState } from '@earendil-works/chord';\nimport {\n defineExtension,\n type Extension,\n type Registry,\n section,\n} from '@earendil-works/pi-durable';\nimport type { ExecutionEnv, FileWatcher } from '@earendil-works/pi-durable/env';\nimport type { Licks } from '../licks/licks.ts';\nimport { PACKAGE_ROOTS, type PiPackages, piPackages } from '../roles/roles.ts';\nimport type { Command } from '../services.ts';\nimport {\n type Diagnostic,\n expandSkillCommand,\n formatSkillsForPrompt,\n loadSkills,\n type Skill,\n type SkillRoot,\n} from './skills.ts';\nimport { expandPromptTemplate, loadTemplates, type PromptTemplate } from './templates.ts';\n\nexport const BUILTIN_SKILLS = [\n 'agent',\n 'browser',\n 'gelatiere',\n 'licks',\n 'memory',\n 'skill-authoring',\n 'sprinkles',\n 'welcome',\n];\nexport const BUILTIN_PROMPTS = ['parallel-review', 'review-loop'];\nexport const SKILLS_DIR = '/var/lib/slicc/agent/skills';\nexport const PROMPTS_DIR = '/var/lib/slicc/agent/prompts';\nexport const GLOBAL_DIR = '/usr/share/skills';\nexport const RELOAD_MS = 300;\n\nexport interface SkillsRuntime {\n readonly commands: ReplicatedState<Command[]>;\n skills(): readonly Skill[];\n dirs(): string[];\n templates(): readonly PromptTemplate[];\n expand(text: string, context: Context, conversationId?: number): Promise<string>;\n reload(context: Context): Promise<void>;\n close(context: Context): Promise<void>;\n}\n\nexport interface SkillsAttach {\n env: ExecutionEnv;\n home: string;\n agentDir?: string;\n assets?: (path: string) => Promise<string>;\n reloadMs: number;\n people?: SkillPeople;\n}\n\nexport interface SkillPeople {\n homes(): readonly string[];\n homeOf(conversationId: number | undefined): string | undefined;\n envOf(home: string): Promise<ExecutionEnv | undefined>;\n}\n\nexport function userRoots(homes: readonly string[]): SkillRoot[] {\n return homes.flatMap((home) => [\n { dir: `${home}/.pi/agent/skills`, source: 'user' as const },\n { dir: `${home}/.agents/skills`, source: 'user' as const },\n ]);\n}\n\nexport interface SkillsSetup {\n extension: Extension;\n attach(options: SkillsAttach, context: Context): Promise<SkillsRuntime>;\n}\n\ntype Manifest = { pi?: { skills?: unknown; prompts?: unknown } };\n\nexport function piResources(dir: string, text: string, kind: 'skills' | 'prompts'): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const listed = manifest.pi?.[kind];\n const paths = Array.isArray(listed) ? listed : typeof listed === 'string' ? [listed] : [];\n return paths\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nfunction packaged(found: PiPackages, kind: 'skills' | 'prompts') {\n return found.packages.flatMap(({ dir, manifest }) => piResources(dir, manifest, kind));\n}\n\nasync function installBuiltins(\n env: ExecutionEnv,\n assets: (path: string) => Promise<string>,\n context: Context\n): Promise<void> {\n await env.remove(SKILLS_DIR, { recursive: true, force: true }, context);\n await env.remove(PROMPTS_DIR, { recursive: true, force: true }, context);\n for (const name of BUILTIN_SKILLS) {\n const text = await assets(`packages/vfs-root/skills/${name}/SKILL.md`).catch(() => undefined);\n if (text === undefined) continue;\n await env.createDir(`${SKILLS_DIR}/${name}`, { recursive: true }, context);\n await env.writeFile(`${SKILLS_DIR}/${name}/SKILL.md`, text, context);\n }\n await env.createDir(PROMPTS_DIR, { recursive: true }, context);\n for (const name of BUILTIN_PROMPTS) {\n const text = await assets(`packages/vfs-root/prompts/${name}.md`).catch(() => undefined);\n if (text !== undefined) await env.writeFile(`${PROMPTS_DIR}/${name}.md`, text, context);\n }\n}\n\nexport function problemLick(problem: Diagnostic, home: string) {\n const path = problem.path.startsWith(`${home}/`)\n ? `~${problem.path.slice(home.length)}`\n : problem.path;\n return {\n channel: 'fswatch' as const,\n source: `skills:${path}`,\n title: `Skill or prompt template problem: ${path}`,\n text: problem.message,\n body: 'The file is used with this problem, or skipped if it has no description.\\nThe rules are in the slicc-agent README.',\n target: 'cone' as const,\n severity: 'warn' as const,\n eventId: `${path}\\n${problem.message}`,\n };\n}\n\nexport const SECRETS_ACTION: Command = {\n name: 'secrets',\n description: 'List the secrets the agent can use, and where each works',\n kind: 'action',\n};\n\nexport function commandsOf(\n skills: readonly Skill[],\n templates: readonly PromptTemplate[]\n): Command[] {\n return [\n ...templates.map((template) => ({\n name: template.name,\n description: template.description,\n kind: 'prompt' as const,\n })),\n ...skills.map((skill) => ({\n name: `skill:${skill.name}`,\n description: skill.description,\n kind: 'skill' as const,\n })),\n SECRETS_ACTION,\n ];\n}\n\nexport function setupSkills(registry: Registry, licks: Licks): SkillsSetup {\n let current: Skill[] = [];\n let own = new Map<string, Skill[]>();\n let people: SkillPeople | undefined;\n const mine = (conversationId: number | undefined) => {\n const at = people?.homeOf(conversationId);\n return (at ? own.get(at) : undefined) ?? current;\n };\n const extension = defineExtension({\n name: 'slicc-skills',\n sections: [\n section('skills', async (input) => {\n return formatSkillsForPrompt(mine(input.conversationId)) || undefined;\n }),\n ],\n });\n registry.install(extension);\n return {\n extension,\n async attach(options, context) {\n const { env, home } = options;\n const dir = options.agentDir ?? `${home}/.pi/agent`;\n people = options.people;\n const homes = () => options.people?.homes() ?? [];\n if (options.assets)\n await installBuiltins(env, options.assets, context).catch(() => undefined);\n await env.exec(`mkdir -p ${GLOBAL_DIR} && chmod 755 ${GLOBAL_DIR}`, undefined, context);\n let templates: PromptTemplate[] = [];\n const commands = replicatedState<Command[]>([]);\n const reported = new Set<string>();\n const reload = async (using: Context) => {\n const packages = await piPackages(env, PACKAGE_ROOTS, using);\n const roots: SkillRoot[] = [\n ...(options.people\n ? [{ dir: GLOBAL_DIR, source: 'global' as const }]\n : [\n { dir: `${dir}/skills`, source: 'user' as const },\n { dir: `${home}/.agents/skills`, source: 'user' as const },\n { dir: GLOBAL_DIR, source: 'global' as const },\n ]),\n { dir: SKILLS_DIR, source: 'builtin' },\n ...packaged(packages, 'skills').map((dir) => ({ dir, source: 'package' as const })),\n ];\n const loaded = await loadSkills(env, roots, using);\n const homesLoaded = new Map<string, Skill[]>();\n for (const at of homes()) {\n const files = await options.people?.envOf(at);\n if (!files) continue;\n const found = await loadSkills(files, [...userRoots([at]), ...roots], using);\n homesLoaded.set(at, found.skills);\n loaded.diagnostics.push(...found.diagnostics);\n }\n own = homesLoaded;\n const prompts = await loadTemplates(\n env,\n [`${dir}/prompts`, PROMPTS_DIR, ...packaged(packages, 'prompts')],\n using\n );\n current = loaded.skills;\n templates = prompts.templates;\n commands.replace(using, commandsOf(current, templates));\n for (const problem of [\n ...packages.skipped,\n ...loaded.diagnostics,\n ...prompts.diagnostics,\n ]) {\n const key = `${problem.path}\\n${problem.message}`;\n if (reported.has(key)) continue;\n reported.add(key);\n await licks.deliver(problemLick(problem, home), using).catch(() => undefined);\n }\n };\n await reload(context);\n let timer: ReturnType<typeof setTimeout> | undefined;\n const schedule = () => {\n clearTimeout(timer);\n timer = setTimeout(() => void reload(context).catch(() => undefined), options.reloadMs);\n };\n let watcher: FileWatcher | undefined;\n let seen = '';\n const watch = async (using: Context) => {\n const extra = options.people\n ? userRoots(homes()).map((root) => ({ path: root.dir, recursive: true }))\n : [\n { path: `${dir}/skills`, recursive: true },\n { path: `${home}/.agents/skills`, recursive: true },\n ];\n const key = JSON.stringify(extra);\n if (key === seen) return;\n seen = key;\n await watcher?.close(using);\n const watched = await env.watch(\n [{ path: GLOBAL_DIR, recursive: true }, { path: `${dir}/prompts` }, ...extra],\n schedule,\n using\n );\n watcher = watched.ok ? watched.value : undefined;\n };\n await watch(context);\n return {\n commands,\n skills: () => current,\n dirs: () => current.map((skill) => skill.baseDir),\n templates: () => templates,\n async expand(text, using, conversationId) {\n const at = people?.homeOf(conversationId);\n const files = at ? await people?.envOf(at) : env;\n if (!files) return text;\n const expanded = await expandSkillCommand(text, mine(conversationId), files, using);\n return expanded === text ? expandPromptTemplate(text, templates) : expanded;\n },\n async reload(using) {\n await watch(using);\n await reload(using);\n },\n async close(using) {\n clearTimeout(timer);\n await watcher?.close(using);\n },\n };\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAA6C,uBAAuB;AACpE;AAAA,EACE;AAAA,EAGA;AAAA,OACK;AAGP,SAAS,eAAgC,kBAAkB;AAE3D;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sBAAsB,qBAA0C;AAElE,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;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,KAAK;AACjB,gBAAM,OAAO,KAAK;AAAA,QACpB;AAAA,QACA,MAAM,MAAM,OAAO;AACjB,uBAAa,KAAK;AAClB,gBAAM,SAAS,MAAM,KAAK;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["dir"]
|
|
7
7
|
}
|
|
@@ -54,4 +54,17 @@ export declare function loadRoles(options: LoadOptions, context: Context): Promi
|
|
|
54
54
|
export declare function findRole(roles: readonly Role[], name: string): Role | undefined;
|
|
55
55
|
export declare function manifestDirs(files: RoleFiles, root: string, context: Context): Promise<string[]>;
|
|
56
56
|
export declare function agentPaths(dir: string, text: string): string[];
|
|
57
|
-
export declare
|
|
57
|
+
export declare const PACKAGE_ROOTS: string[];
|
|
58
|
+
export interface PiPackage {
|
|
59
|
+
dir: string;
|
|
60
|
+
manifest: string;
|
|
61
|
+
}
|
|
62
|
+
export interface PiPackages {
|
|
63
|
+
packages: PiPackage[];
|
|
64
|
+
skipped: {
|
|
65
|
+
path: string;
|
|
66
|
+
message: string;
|
|
67
|
+
}[];
|
|
68
|
+
}
|
|
69
|
+
export declare function piPackages(files: RoleFiles, roots: readonly string[], context: Context): Promise<PiPackages>;
|
|
70
|
+
export declare function packageDirs(files: RoleFiles, roots: readonly string[], context: Context): Promise<string[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-agent",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.50.0",
|
|
4
4
|
"description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@ai-ecoverse/slicc-kernel": "1.47.1",
|
|
65
65
|
"@ai-ecoverse/slicc-shared-web": "1.13.1",
|
|
66
|
-
"@ai-ecoverse/slicc-spectrum": "1.
|
|
67
|
-
"@ai-ecoverse/wasm-bash": "5.3.0-
|
|
66
|
+
"@ai-ecoverse/slicc-spectrum": "1.68.2",
|
|
67
|
+
"@ai-ecoverse/wasm-bash": "5.3.0-18",
|
|
68
68
|
"@ai-ecoverse/wasm-coreutils": "9.12.0-5",
|
|
69
69
|
"@ai-ecoverse/wasm-git": "2.55.0-15",
|
|
70
70
|
"@biomejs/biome": "2.5.15",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"esbuild": "0.28.2",
|
|
73
73
|
"fake-indexeddb": "6.2.5",
|
|
74
74
|
"lefthook": "2.1.17",
|
|
75
|
-
"monocart-coverage-reports": "2.13.
|
|
75
|
+
"monocart-coverage-reports": "2.13.2",
|
|
76
76
|
"playwright-core": "1.63.0",
|
|
77
77
|
"semantic-release": "25.0.9",
|
|
78
78
|
"typescript": "7.0.2"
|