4e21ca937a
Deploy Documentation / deploy (push) Has been cancelled
Canary / Prepare Version (push) Has been cancelled
Canary / build-cli (push) Has been cancelled
Canary / Upload Install Script (push) Has been cancelled
Canary / bundle-desktop (push) Has been cancelled
Canary / bundle-desktop-intel (push) Has been cancelled
Canary / bundle-desktop-linux (push) Has been cancelled
Canary / bundle-desktop-windows (push) Has been cancelled
Canary / bundle-desktop-windows-cuda (push) Has been cancelled
Canary / Release (push) Has been cancelled
Unused Dependencies / machete (push) Has been cancelled
CI / changes (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / H5 Plaza Tests and Build (push) Has been cancelled
Live Provider Tests / check-fork (push) Has been cancelled
Live Provider Tests / changes (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
Live Provider Tests / goose server HTTP integration tests (push) Has been cancelled
Publish Ask AI Bot Docker Image / docker (push) Has been cancelled
Publish Docker Image / docker (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fork goose with custom MCP widgets, platform extensions (aider, git, web, search), MindSpace H5 backend/frontend, Plaza/Ops UIs, and deploy scripts for tkmind.cn. Co-authored-by: Cursor <cursoragent@cursor.com>
78 lines
3.0 KiB
JavaScript
78 lines
3.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import fs from 'node:fs';
|
|
import os from 'node:os';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import {
|
|
buildPublicUrl,
|
|
buildPublishConstraints,
|
|
buildSandboxSessionConstraints,
|
|
ensureUserPublishLayout,
|
|
isPathInsidePublishDir,
|
|
PUBLISH_ROOT_DIR,
|
|
} from './user-publish.mjs';
|
|
import { syncSkillsToWorkspace } from './skills-registry.mjs';
|
|
import { listPlatformSkillCatalog } from './skills-registry.mjs';
|
|
|
|
test('publish dir and public url use username slug', () => {
|
|
const platformRoot = path.dirname(fileURLToPath(import.meta.url));
|
|
const h5Root = fs.mkdtempSync(path.join(os.tmpdir(), 'h5-'));
|
|
const layout = ensureUserPublishLayout({
|
|
h5Root,
|
|
publicBaseUrl: 'https://goo.tkmind.cn',
|
|
user: { username: 'john' },
|
|
});
|
|
assert.equal(layout.slug, 'john');
|
|
assert.ok(layout.publishDir.endsWith(`${path.sep}${PUBLISH_ROOT_DIR}${path.sep}john`));
|
|
assert.equal(layout.publicUrl, `https://goo.tkmind.cn/${PUBLISH_ROOT_DIR}/john/`);
|
|
assert.equal(
|
|
buildPublicUrl('https://goo.tkmind.cn', 'john', 'report.html'),
|
|
`https://goo.tkmind.cn/${PUBLISH_ROOT_DIR}/john/report.html`,
|
|
);
|
|
const catalog = listPlatformSkillCatalog(platformRoot);
|
|
syncSkillsToWorkspace({
|
|
h5Root: platformRoot,
|
|
publishDir: layout.publishDir,
|
|
skillMap: { 'static-page-publish': true },
|
|
catalog,
|
|
user: { username: 'john' },
|
|
publicBaseUrl: 'https://goo.tkmind.cn',
|
|
});
|
|
const skillPath = path.join(layout.publishDir, '.agents', 'skills', 'static-page-publish', 'SKILL.md');
|
|
assert.ok(fs.existsSync(skillPath));
|
|
const skillText = fs.readFileSync(skillPath, 'utf8');
|
|
assert.match(skillText, new RegExp(`goo\\.tkmind\\.cn/${PUBLISH_ROOT_DIR}/john`));
|
|
assert.match(skillText, /\[.*\]\(.*\)/);
|
|
assert.match(skillText, /mindspace-cover/);
|
|
assert.match(skillText, /\.thumbnail\.svg/);
|
|
});
|
|
|
|
test('buildPublishConstraints scopes default search to user workspace', () => {
|
|
const publishDir = `/var/h5/${PUBLISH_ROOT_DIR}/john`;
|
|
const constraints = buildPublishConstraints({
|
|
slug: 'john',
|
|
publicBaseUrl: 'https://goo.tkmind.cn',
|
|
publishDir,
|
|
});
|
|
assert.match(constraints, /唯一文件根目录/);
|
|
assert.match(constraints, /禁止用公网 URL 列目录/);
|
|
assert.match(constraints, /oa\//);
|
|
});
|
|
|
|
test('buildSandboxSessionConstraints documents shell and forbids public url browsing', () => {
|
|
const text = buildSandboxSessionConstraints({
|
|
baseConstraints: 'base',
|
|
developerTools: ['write', 'edit', 'shell', 'tree'],
|
|
});
|
|
assert.match(text, /shell 已开启/);
|
|
assert.match(text, /禁止.*curl/);
|
|
assert.match(text, /tree 已开启/);
|
|
});
|
|
|
|
test('isPathInsidePublishDir blocks escape', () => {
|
|
const publishDir = `/var/h5/${PUBLISH_ROOT_DIR}/john`;
|
|
assert.equal(isPathInsidePublishDir(publishDir, `/var/h5/${PUBLISH_ROOT_DIR}/john/report.html`), true);
|
|
assert.equal(isPathInsidePublishDir(publishDir, `/var/h5/${PUBLISH_ROOT_DIR}/other/x.html`), false);
|
|
});
|