@dsh-plugin/dsh-pack-plugin 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +178 -3
- package/cordis.patch.yml +9 -0
- package/icons/folder-zip-line.svg +1 -0
- package/lib/ball.js +597 -0
- package/lib/client.js +2934 -0
- package/lib/host.js +51745 -0
- package/lib/migrate-helper.js +35346 -0
- package/lib/progress-main.cjs +79 -0
- package/lib/progress-window.ps1 +114 -0
- package/lib/progress.html +126 -0
- package/lib/publish-to-github/SKILL.md +132 -0
- package/package.json +77 -4
- package/src/ball-entry.js +5 -0
- package/src/ball-host.js +99 -0
- package/src/ball-settings.js +352 -0
- package/src/ball.js +418 -0
- package/src/channel.js +12 -0
- package/src/client-plugin.js +58 -0
- package/src/client-rpc.js +14 -0
- package/src/client.js +5 -0
- package/src/core/discovery.js +192 -0
- package/src/core/dspack.js +93 -0
- package/src/core/extension-files.js +102 -0
- package/src/core/extension-install.js +295 -0
- package/src/core/extension-patch.js +369 -0
- package/src/core/extension-skills.js +164 -0
- package/src/core/extension-validate.js +127 -0
- package/src/core/extensions.js +207 -0
- package/src/core/home-store.js +32 -0
- package/src/core/host.js +149 -0
- package/src/core/index.js +59 -0
- package/src/core/inspect.js +162 -0
- package/src/core/install.js +775 -0
- package/src/core/managed-install.js +84 -0
- package/src/core/manifest.js +717 -0
- package/src/core/market.js +268 -0
- package/src/core/mcp-composition.js +189 -0
- package/src/core/mcp-install.js +112 -0
- package/src/core/mcp-transport.js +116 -0
- package/src/core/pack.js +371 -0
- package/src/core/plugin-metadata.js +355 -0
- package/src/core/registry.js +316 -0
- package/src/core/repo.js +339 -0
- package/src/core/scan.js +78 -0
- package/src/core/security.js +101 -0
- package/src/core/special.js +50 -0
- package/src/core/tar.js +103 -0
- package/src/core/update-config.js +234 -0
- package/src/core/update.js +792 -0
- package/src/core/vendored.js +715 -0
- package/src/core/workspace.js +95 -0
- package/src/endpoints.js +455 -0
- package/src/ensure-manager.js +186 -0
- package/src/host-node.js +625 -0
- package/src/host.js +17 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +39 -0
- package/src/junction.js +142 -0
- package/src/migrate-helper.js +225 -0
- package/src/migrate.js +56 -0
- package/src/packaged.js +9 -0
- package/src/profiles.js +106 -0
- package/src/progress-main.cjs +79 -0
- package/src/progress-window.ps1 +114 -0
- package/src/progress.html +126 -0
- package/src/progress.js +132 -0
- package/src/rpc.js +157 -0
- package/src/runtime.js +43 -0
- package/src/section-gate.js +50 -0
- package/src/settings-nav-icon.js +188 -0
- package/src/settings.js +1611 -0
- package/src/skills/index.js +90 -0
- package/src/skills/publish-to-github/SKILL.md +132 -0
- package/src/tasks.js +145 -0
- package/src/v6-dialogs.js +312 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { sanitizeSlug } from './manifest.js';
|
|
2
|
+
import { planExtensionInstall } from './extensions.js';
|
|
3
|
+
import { packBaselineFiles, installedSkillLocation, recoverPackUpdate, syncPackTree } from './update.js';
|
|
4
|
+
|
|
5
|
+
/** 在独立目录中还原包内容,再以安装基线为准提交文件、配置和依赖。 */
|
|
6
|
+
export async function managedInstall(host, manifest, entries, opts, handlers) {
|
|
7
|
+
const whole = manifest.type === 'dshhome';
|
|
8
|
+
const profilesRoot = host.resolvePath(opts.profilesRoot || host.joinPath(host.homedir(), '.dsh', 'profiles'));
|
|
9
|
+
const home = whole
|
|
10
|
+
? host.resolvePath(opts.home || host.joinPath(host.homedir(), '.dsh'))
|
|
11
|
+
: host.resolvePath(host.joinPath(profilesRoot, '..'));
|
|
12
|
+
const profileName = whole ? undefined : sanitizeSlug(opts.name || manifest.profileName || manifest.name);
|
|
13
|
+
const names = whole ? Object.keys(manifest.profiles) : [profileName];
|
|
14
|
+
for (const name of names) {
|
|
15
|
+
if (!name || !/^[^\\/:*?"<>|\x00-\x1f]+$/u.test(name) || /[. ]$/u.test(name) || name === '.' || name === '..') {
|
|
16
|
+
throw new Error('整合包中的配置档名称无效');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const target = whole ? home : host.joinPath(profilesRoot, profileName);
|
|
20
|
+
const profilesDir = whole ? 'profiles' : host.basename(profilesRoot);
|
|
21
|
+
if (opts.recoverInterrupted) await recoverPackUpdate(host, home, profilesDir);
|
|
22
|
+
const exists = Boolean(await host.stat(target));
|
|
23
|
+
const updating = !!(opts.update || (exists && opts.force));
|
|
24
|
+
if (updating && !exists) throw new Error(`找不到要更新的目标:${target}`);
|
|
25
|
+
if (exists && !updating && !opts.dryRun) throw new Error(`目标已存在,请使用更新操作:${target}`);
|
|
26
|
+
const scratch = await host.mkdtemp('dspack-prepare-');
|
|
27
|
+
const stagedHome = host.joinPath(scratch, 'home');
|
|
28
|
+
try {
|
|
29
|
+
const skillLocation = whole ? null : await installedSkillLocation(host, home, profilesDir, profileName);
|
|
30
|
+
const skillRoot = (root) => skillLocation ? host.joinPath(root, skillLocation) : handlers.skillRoot?.(root, profileName);
|
|
31
|
+
const listing = opts.dryRun && opts.listResourcesOnly;
|
|
32
|
+
const result = listing ? null : await handlers.stage(stagedHome, whole ? host.joinPath(home, 'profiles') : profilesRoot);
|
|
33
|
+
const plan = await planExtensionInstall(host, {
|
|
34
|
+
home: stagedHome, staging: true, profileName, profileDir: whole ? undefined : host.joinPath(stagedHome, 'profiles', profileName),
|
|
35
|
+
skillRoot: skillRoot(stagedHome), actualSkillRoot: skillRoot(home), manifest, entries,
|
|
36
|
+
credentialHome: home, credentialProfileDir: whole ? undefined : target,
|
|
37
|
+
credentialCwd: opts.credentialCwd,
|
|
38
|
+
credentialEnvironment: opts.credentialEnvironment,
|
|
39
|
+
baselineFiles: await packBaselineFiles(host,home,manifest,profileName,profilesDir), profilesDir,
|
|
40
|
+
installAnchor: opts.installAnchor, overlayPaths: opts.overlayPaths,
|
|
41
|
+
credentials: opts.credentials, confirmedCredentials: opts.confirmedCredentials,
|
|
42
|
+
decisions: opts.decisions,
|
|
43
|
+
});
|
|
44
|
+
const resourceKeys = new Set(plan.items.map(item => item.key));
|
|
45
|
+
for (const key of Object.keys(opts.decisions || {})) {
|
|
46
|
+
if (!resourceKeys.has(key)) throw new Error('未找到指定的导入资源:' + key);
|
|
47
|
+
}
|
|
48
|
+
if (listing) return { resourcesOnly: true, manifest, dir: target, exists, items: plan.items, dryRun: true };
|
|
49
|
+
await plan.apply();
|
|
50
|
+
const previous = updating && opts.previousSource ? await handlers.previous(host.joinPath(scratch, 'previous')) : undefined;
|
|
51
|
+
if (profilesDir !== 'profiles') {
|
|
52
|
+
for (const root of [stagedHome, previous?.stagedHome].filter(Boolean)) {
|
|
53
|
+
await host.move(host.joinPath(root, 'profiles'), host.joinPath(root, profilesDir));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const mapProfilePath = rel => profilesDir !== 'profiles' && rel.startsWith('profiles/') ? profilesDir + rel.slice(8) : rel;
|
|
57
|
+
const changes = await syncPackTree(host, {
|
|
58
|
+
home, stagedHome, profilesDir,
|
|
59
|
+
manifest, profileName, mode: updating ? 'update' : 'install',
|
|
60
|
+
dryRun: !!opts.dryRun, recoverInterrupted: opts.recoverInterrupted === true, resolutions: opts.resolutions, previewToken: opts.previewToken, previous,
|
|
61
|
+
validateProfiles: async (dirs) => {
|
|
62
|
+
for (const dir of dirs) {
|
|
63
|
+
const name = host.basename(dir);
|
|
64
|
+
await handlers.verify(dir, whole ? manifest.profiles[name] : manifest, host.joinPath(stagedHome, profilesDir, name));
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
finalize: opts.noInstall ? undefined : (affected) => handlers.finalize({
|
|
68
|
+
...affected, stagedProfiles: host.joinPath(stagedHome, profilesDir),
|
|
69
|
+
}),
|
|
70
|
+
preservePaths: plan.preservePaths.map(mapProfilePath),
|
|
71
|
+
directories: plan.directories.map(mapProfilePath),
|
|
72
|
+
executablePaths: (plan.executablePaths ?? []).map(mapProfilePath),
|
|
73
|
+
verifyMcp: () => plan.verifyMcp({allowUnresolved:opts.noInstall === true}),
|
|
74
|
+
commitCredentials: Object.values(opts.credentials || {}).some(Boolean) ? plan.commitCredentials : undefined,
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
...result, ...changes, manifest, dir: target, profileName, exists,
|
|
78
|
+
installed: !opts.dryRun && !opts.noInstall, dryRun: !!opts.dryRun,
|
|
79
|
+
items: plan.items, updated: updating && !opts.dryRun,
|
|
80
|
+
};
|
|
81
|
+
} finally {
|
|
82
|
+
await host.rm(scratch, { recursive: true, force: true });
|
|
83
|
+
}
|
|
84
|
+
}
|