gestalt-mobile 0.64.0 → 0.65.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 +18 -2
- package/dist/client/assets/{index-Cj7IlGeB.js → index-BGdM2y_5.js} +15 -15
- package/dist/client/assets/{index-DS139o-V.css → index-tqrTVa26.css} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/server/server/composition.js +9 -4
- package/dist/server/server/features/autopilot/application/service.js +32 -6
- package/dist/server/server/features/skills/list-available/endpoint.js +1 -0
- package/dist/server/server/features/skills/model/skill-profile.js +8 -0
- package/dist/server/server/platform/kimi/kimi-skill-catalog.js +29 -3
- package/dist/server/server/platform/kimi/kimi-skills-materializer.js +6 -5
- package/dist/server/server/platform/skills/cached-skill-catalog.js +9 -5
- package/dist/server/server/platform/skills/managed-skill-catalog.js +61 -0
- package/dist/server/server/platform/skills/managed-skill-provenance.js +173 -0
- package/dist/server/server/platform/skills/verified-skill-catalog.js +30 -0
- package/package.json +1 -1
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { realpath } from 'node:fs/promises';
|
|
7
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
7
8
|
import { availableSkillSchema, } from '../../features/skills/model/skill-profile.js';
|
|
8
9
|
const DISCOVERY_TIMEOUT_MS = 5_000;
|
|
9
10
|
/**
|
|
@@ -17,15 +18,40 @@ const DISCOVERY_TIMEOUT_MS = 5_000;
|
|
|
17
18
|
export class KimiSkillCatalog {
|
|
18
19
|
servers;
|
|
19
20
|
available;
|
|
20
|
-
|
|
21
|
+
managedSkills;
|
|
22
|
+
constructor(servers, available, managedSkills) {
|
|
21
23
|
this.servers = servers;
|
|
22
24
|
this.available = available;
|
|
25
|
+
this.managedSkills = managedSkills;
|
|
23
26
|
}
|
|
24
27
|
async list(workspace) {
|
|
25
28
|
if (!this.available || !this.servers)
|
|
26
29
|
return { skills: [], errors: [] };
|
|
30
|
+
const [native, managed] = await Promise.all([
|
|
31
|
+
this.listNative(workspace, this.servers),
|
|
32
|
+
this.managedSkills?.list(workspace) ?? { skills: [], errors: [] },
|
|
33
|
+
]);
|
|
34
|
+
const managedPaths = new Set(managed.skills.map((skill) => skill.path));
|
|
35
|
+
const nativeSkills = [];
|
|
36
|
+
for (const skill of native.skills) {
|
|
37
|
+
let entry = skill.path;
|
|
38
|
+
try {
|
|
39
|
+
entry = await realpath(skill.path.endsWith('/SKILL.md') ? skill.path : join(skill.path, 'SKILL.md'));
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// Keep native metadata for paths that cannot be resolved locally.
|
|
43
|
+
}
|
|
44
|
+
if (!managedPaths.has(entry))
|
|
45
|
+
nativeSkills.push(skill);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
skills: [...nativeSkills, ...managed.skills],
|
|
49
|
+
errors: [...native.errors, ...managed.errors],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
async listNative(workspace, servers) {
|
|
27
53
|
try {
|
|
28
|
-
const handle = await
|
|
54
|
+
const handle = await servers.ensure('default', []);
|
|
29
55
|
const canonicalWorkspace = resolve(workspace);
|
|
30
56
|
const workspaces = (await withTimeout(handle.client.get('/api/v1/workspaces'), DISCOVERY_TIMEOUT_MS, 'kimi workspace list timed out'));
|
|
31
57
|
const entries = Array.isArray(workspaces.items) ? workspaces.items : [];
|
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { mkdirSync, readdirSync, rmSync, symlinkSync } from 'node:fs';
|
|
7
|
-
import { basename, isAbsolute, join } from 'node:path';
|
|
7
|
+
import { basename, dirname, isAbsolute, join } from 'node:path';
|
|
8
8
|
/**
|
|
9
9
|
* Materializes a kimi skills directory from a gestalt skill selection: one
|
|
10
10
|
* symlink per enabled entry, named by the entry's basename. kimi discovers
|
|
11
11
|
* both directory skills (a folder holding `SKILL.md`) and flat `.md` skills
|
|
12
|
-
* in an `extra_skill_dirs` entry
|
|
13
|
-
*
|
|
12
|
+
* in an `extra_skill_dirs` entry. Canonical SKILL.md identities link their
|
|
13
|
+
* parent folder so names and relative references retain the directory shape.
|
|
14
14
|
*
|
|
15
15
|
* Note: `extra_skill_dirs` only *adds* directories on top of kimi's automatic
|
|
16
16
|
* user/project discovery — unlike codex's `skills.config` override, kimi web
|
|
@@ -28,12 +28,13 @@ export function materializeKimiSkillsDir(skillsDir, selection) {
|
|
|
28
28
|
continue;
|
|
29
29
|
if (!isAbsolute(entry.path))
|
|
30
30
|
continue;
|
|
31
|
-
const
|
|
31
|
+
const target = basename(entry.path) === 'SKILL.md' ? dirname(entry.path) : entry.path;
|
|
32
|
+
const name = basename(target);
|
|
32
33
|
if (taken.has(name)) {
|
|
33
34
|
skipped.push(entry.path);
|
|
34
35
|
continue;
|
|
35
36
|
}
|
|
36
|
-
symlinkSync(
|
|
37
|
+
symlinkSync(target, join(skillsDir, name));
|
|
37
38
|
taken.add(name);
|
|
38
39
|
linked.push(entry.path);
|
|
39
40
|
}
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { resolve } from 'node:path';
|
|
7
|
+
import { verifySkillProvenance } from './verified-skill-catalog.js';
|
|
7
8
|
/** In-memory editor catalog: discovery runs only when the relay starts or a user refreshes it. */
|
|
8
9
|
export class CachedSkillCatalog {
|
|
9
10
|
discover;
|
|
10
11
|
validate;
|
|
12
|
+
provenance;
|
|
11
13
|
entries = new Map();
|
|
12
|
-
constructor(discover, validate) {
|
|
14
|
+
constructor(discover, validate, provenance) {
|
|
13
15
|
this.discover = discover;
|
|
14
16
|
this.validate = validate;
|
|
17
|
+
this.provenance = provenance;
|
|
15
18
|
}
|
|
16
19
|
async list(provider, profile, workspace) {
|
|
17
20
|
const result = this.entries.get(this.key(provider, profile, workspace)) ?? {
|
|
@@ -22,18 +25,19 @@ export class CachedSkillCatalog {
|
|
|
22
25
|
},
|
|
23
26
|
],
|
|
24
27
|
};
|
|
25
|
-
if (!this.validate)
|
|
26
|
-
return result;
|
|
27
28
|
// Validation is a live capability projection over the last discovered
|
|
28
29
|
// catalog. Keep the discovery baseline so a transient outage can recover
|
|
29
30
|
// on the next list without requiring package rediscovery.
|
|
30
|
-
|
|
31
|
+
const current = this.validate
|
|
32
|
+
? await this.validate(provider, profile, workspace, result)
|
|
33
|
+
: result;
|
|
34
|
+
return this.provenance ? verifySkillProvenance(current, this.provenance) : current;
|
|
31
35
|
}
|
|
32
36
|
async refresh(provider, profile, workspace) {
|
|
33
37
|
try {
|
|
34
38
|
const result = await this.discover(provider, profile, workspace);
|
|
35
39
|
this.entries.set(this.key(provider, profile, workspace), result);
|
|
36
|
-
return result;
|
|
40
|
+
return this.provenance ? verifySkillProvenance(result, this.provenance) : result;
|
|
37
41
|
}
|
|
38
42
|
catch {
|
|
39
43
|
const result = {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { readFile, readdir, realpath } from 'node:fs/promises';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { parseDocument } from 'yaml';
|
|
9
|
+
/**
|
|
10
|
+
* Make the optional collection available to providers that do not discover
|
|
11
|
+
* Codex home. This is ordinary filesystem discovery: receipt/integrity failures
|
|
12
|
+
* affect provenance independently, never whether a user can select a skill.
|
|
13
|
+
*/
|
|
14
|
+
export class ManagedSkillCatalog {
|
|
15
|
+
codexHome;
|
|
16
|
+
constructor(codexHome) {
|
|
17
|
+
this.codexHome = codexHome;
|
|
18
|
+
}
|
|
19
|
+
async list() {
|
|
20
|
+
const skills = [];
|
|
21
|
+
const root = join(this.codexHome, 'gestalt-skills', 'skills');
|
|
22
|
+
try {
|
|
23
|
+
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
24
|
+
if (!entry.isDirectory() || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(entry.name))
|
|
25
|
+
continue;
|
|
26
|
+
try {
|
|
27
|
+
const path = await realpath(join(root, entry.name, 'SKILL.md'));
|
|
28
|
+
const text = await readFile(path, 'utf8');
|
|
29
|
+
const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
|
|
30
|
+
if (!frontmatter)
|
|
31
|
+
continue;
|
|
32
|
+
const document = parseDocument(frontmatter[1], { strict: true, uniqueKeys: true });
|
|
33
|
+
if (document.errors.length)
|
|
34
|
+
continue;
|
|
35
|
+
const metadata = document.toJS();
|
|
36
|
+
if (metadata?.name !== entry.name)
|
|
37
|
+
continue;
|
|
38
|
+
skills.push({
|
|
39
|
+
name: entry.name,
|
|
40
|
+
path,
|
|
41
|
+
enabled: true,
|
|
42
|
+
scope: 'user',
|
|
43
|
+
...(typeof metadata.description === 'string'
|
|
44
|
+
? { description: metadata.description }
|
|
45
|
+
: {}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// A missing/invalid entry cannot suppress other installed skills.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// The optional collection may not be installed.
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
skills: skills.sort((left, right) => left.path.localeCompare(right.path)),
|
|
58
|
+
errors: [],
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import { lstat, readFile, readdir, realpath } from 'node:fs/promises';
|
|
8
|
+
import { isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
9
|
+
import { parseDocument } from 'yaml';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
const repository = 'dyne/gestalt-skills';
|
|
12
|
+
const source = 'https://github.com/dyne/gestalt-skills';
|
|
13
|
+
const digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
14
|
+
const bundledFile = z.object({ path: z.string().min(1).max(512), sha256: digest }).strict();
|
|
15
|
+
const collectionSkill = z
|
|
16
|
+
.object({
|
|
17
|
+
name: z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)
|
|
20
|
+
.max(63),
|
|
21
|
+
entry: z.string().min(1).max(512),
|
|
22
|
+
files: z.array(bundledFile).min(1).max(4096),
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
const manifestSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
schemaVersion: z.literal(1),
|
|
28
|
+
repository: z.literal(repository),
|
|
29
|
+
source: z.literal(source),
|
|
30
|
+
version: z.string().regex(/^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/),
|
|
31
|
+
skills: z.array(collectionSkill).min(1).max(256),
|
|
32
|
+
})
|
|
33
|
+
.strict();
|
|
34
|
+
const receiptSchema = manifestSchema
|
|
35
|
+
.omit({ source: true })
|
|
36
|
+
.extend({
|
|
37
|
+
source: z.literal(source),
|
|
38
|
+
revision: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/),
|
|
39
|
+
manifestSha256: digest,
|
|
40
|
+
managedRoot: z.string(),
|
|
41
|
+
discoveryRoot: z.string(),
|
|
42
|
+
verifiedSource: z.literal(true),
|
|
43
|
+
packageFiles: z.array(bundledFile).length(1),
|
|
44
|
+
installedAt: z.iso.datetime(),
|
|
45
|
+
transactionId: z.string().regex(/^[a-f0-9]{48}$/),
|
|
46
|
+
})
|
|
47
|
+
.strict();
|
|
48
|
+
function sha256(bytes) {
|
|
49
|
+
return createHash('sha256').update(bytes).digest('hex');
|
|
50
|
+
}
|
|
51
|
+
async function ordinaryBytes(path, limit) {
|
|
52
|
+
const stat = await lstat(path);
|
|
53
|
+
if (!stat.isFile() || stat.size > limit)
|
|
54
|
+
throw new Error('Invalid managed file.');
|
|
55
|
+
return readFile(path);
|
|
56
|
+
}
|
|
57
|
+
function json(bytes) {
|
|
58
|
+
const text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
59
|
+
// JSON.parse enforces JSON syntax; the YAML reader additionally rejects
|
|
60
|
+
// duplicate decoded mapping keys, including JSON escape spellings.
|
|
61
|
+
const value = JSON.parse(text);
|
|
62
|
+
if (parseDocument(text, { strict: true, uniqueKeys: true }).errors.length)
|
|
63
|
+
throw new Error('Invalid managed JSON.');
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
function inside(root, path) {
|
|
67
|
+
const child = relative(root, path);
|
|
68
|
+
return child !== '' && child !== '..' && !child.startsWith(`..${sep}`) && !isAbsolute(child);
|
|
69
|
+
}
|
|
70
|
+
function bundledPath(root, path) {
|
|
71
|
+
if (path.includes('\\') || path.split('/').some((part) => !part || part === '.' || part === '..'))
|
|
72
|
+
throw new Error('Invalid bundled path.');
|
|
73
|
+
const absolute = resolve(root, path);
|
|
74
|
+
if (!inside(root, absolute) || isAbsolute(path))
|
|
75
|
+
throw new Error('Invalid bundled path.');
|
|
76
|
+
return absolute;
|
|
77
|
+
}
|
|
78
|
+
async function inventory(root) {
|
|
79
|
+
const result = [];
|
|
80
|
+
for (const entry of await readdir(root, { withFileTypes: true })) {
|
|
81
|
+
const path = join(root, entry.name);
|
|
82
|
+
if (entry.isDirectory())
|
|
83
|
+
result.push(...(await inventory(path)));
|
|
84
|
+
else if (entry.isFile())
|
|
85
|
+
result.push(path);
|
|
86
|
+
else
|
|
87
|
+
throw new Error('Invalid managed inventory.');
|
|
88
|
+
}
|
|
89
|
+
return result.sort();
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Trust only the configured home, never a root inferred from a discovered path.
|
|
93
|
+
* Verification is local provenance/integrity, not protection against an owner
|
|
94
|
+
* replacing both the package and its installer receipt. No state is cached.
|
|
95
|
+
*/
|
|
96
|
+
export class ManagedSkillProvenance {
|
|
97
|
+
codexHome;
|
|
98
|
+
constructor(codexHome) {
|
|
99
|
+
this.codexHome = codexHome;
|
|
100
|
+
}
|
|
101
|
+
async verify(paths) {
|
|
102
|
+
const verified = new Map();
|
|
103
|
+
if (!paths.length)
|
|
104
|
+
return verified;
|
|
105
|
+
try {
|
|
106
|
+
const home = await realpath(this.codexHome);
|
|
107
|
+
const root = join(home, 'gestalt-skills');
|
|
108
|
+
const discovery = join(home, 'skills');
|
|
109
|
+
// Home aliases are supported; the collection/discovery roots themselves
|
|
110
|
+
// must be the installer-owned locations, not links to arbitrary copies.
|
|
111
|
+
if ((await realpath(root)) !== root || (await realpath(discovery)) !== discovery)
|
|
112
|
+
return verified;
|
|
113
|
+
const manifestBytes = await ordinaryBytes(join(root, 'manifest.json'), 2 * 1024 * 1024);
|
|
114
|
+
const receipt = receiptSchema.parse(json(await ordinaryBytes(join(root, 'receipt.json'), 2 * 1024 * 1024)));
|
|
115
|
+
const manifest = manifestSchema.parse(json(manifestBytes));
|
|
116
|
+
if (receipt.managedRoot !== root ||
|
|
117
|
+
receipt.discoveryRoot !== discovery ||
|
|
118
|
+
receipt.manifestSha256 !== sha256(manifestBytes) ||
|
|
119
|
+
receipt.version !== manifest.version ||
|
|
120
|
+
JSON.stringify(receipt.skills) !== JSON.stringify(manifest.skills) ||
|
|
121
|
+
receipt.packageFiles[0].path !== 'LICENSE')
|
|
122
|
+
return verified;
|
|
123
|
+
const expected = [];
|
|
124
|
+
const entries = new Set();
|
|
125
|
+
const names = manifest.skills.map((skill) => skill.name);
|
|
126
|
+
if (names.join('\n') !== [...new Set(names)].sort().join('\n'))
|
|
127
|
+
return verified;
|
|
128
|
+
for (const skill of manifest.skills) {
|
|
129
|
+
if (skill.entry !== `skills/${skill.name}/SKILL.md`)
|
|
130
|
+
return verified;
|
|
131
|
+
const entry = bundledPath(root, skill.entry);
|
|
132
|
+
entries.add(entry);
|
|
133
|
+
const skillRoot = join(root, 'skills', skill.name);
|
|
134
|
+
const filePaths = skill.files.map((file) => file.path);
|
|
135
|
+
if (!filePaths.includes(skill.entry) ||
|
|
136
|
+
filePaths.join('\n') !== [...new Set(filePaths)].sort().join('\n'))
|
|
137
|
+
return verified;
|
|
138
|
+
for (const file of skill.files) {
|
|
139
|
+
const path = bundledPath(root, file.path);
|
|
140
|
+
if (!inside(skillRoot, path) || (await realpath(path)) !== path)
|
|
141
|
+
return verified;
|
|
142
|
+
if (sha256(await ordinaryBytes(path, 16 * 1024 * 1024)) !== file.sha256)
|
|
143
|
+
return verified;
|
|
144
|
+
expected.push(path);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (JSON.stringify(await inventory(join(root, 'skills'))) !== JSON.stringify(expected.sort()))
|
|
148
|
+
return verified;
|
|
149
|
+
const license = receipt.packageFiles[0];
|
|
150
|
+
if (sha256(await ordinaryBytes(join(root, license.path), 16 * 1024 * 1024)) !== license.sha256)
|
|
151
|
+
return verified;
|
|
152
|
+
// Resolve aliases only after validating the trusted installation. The
|
|
153
|
+
// returned map retains each provider's existing path identity.
|
|
154
|
+
for (const path of paths) {
|
|
155
|
+
try {
|
|
156
|
+
if (isAbsolute(path) && entries.has(await realpath(path)))
|
|
157
|
+
verified.set(path, {
|
|
158
|
+
kind: 'gestalt-verified',
|
|
159
|
+
repository,
|
|
160
|
+
revision: receipt.revision,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
/* Removed/unreadable skills remain ordinary discovery metadata. */
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
/* Optional receipts must never make ordinary skill discovery unusable. */
|
|
170
|
+
}
|
|
171
|
+
return verified;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
/** Discard supplied metadata before projecting current server-owned verification. */
|
|
7
|
+
export async function verifySkillProvenance(result, verifier) {
|
|
8
|
+
const verified = await verifier.verify(result.skills.map((skill) => skill.path));
|
|
9
|
+
return {
|
|
10
|
+
...result,
|
|
11
|
+
skills: result.skills.map((skill) => {
|
|
12
|
+
const ordinary = { ...skill };
|
|
13
|
+
delete ordinary.provenance;
|
|
14
|
+
const provenance = verified.get(skill.path);
|
|
15
|
+
return { ...ordinary, ...(provenance ? { provenance } : {}) };
|
|
16
|
+
}),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Provider-neutral decoration after each provider has parsed its wire response. */
|
|
20
|
+
export class VerifiedSkillCatalog {
|
|
21
|
+
catalog;
|
|
22
|
+
verifier;
|
|
23
|
+
constructor(catalog, verifier) {
|
|
24
|
+
this.catalog = catalog;
|
|
25
|
+
this.verifier = verifier;
|
|
26
|
+
}
|
|
27
|
+
async list(workspace) {
|
|
28
|
+
return verifySkillProvenance(await this.catalog.list(workspace), this.verifier);
|
|
29
|
+
}
|
|
30
|
+
}
|