@dsh-workbench/adapters-default 0.0.0-stage → 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +31 -2
- package/dist/adapter-set.d.ts +11 -0
- package/dist/adapter-set.js +38 -0
- package/dist/host-actions.d.ts +2 -0
- package/dist/host-actions.js +4 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +14 -0
- package/dist/plugin-surface.d.ts +10 -0
- package/dist/plugin-surface.js +22 -0
- package/dist/probe-port.d.ts +2 -0
- package/dist/probe-port.js +5 -0
- package/dist/runtime-port.d.ts +2 -0
- package/dist/runtime-port.js +32 -0
- package/dist/supply-port.d.ts +2 -0
- package/dist/supply-port.js +35 -0
- package/package.json +40 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-workbench contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dsh-workbench/adapters-default
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
工作台默认适配器集。
|
|
4
|
+
|
|
5
|
+
## 职责
|
|
6
|
+
|
|
7
|
+
- 把四个实现包组成一个普通依赖集,暴露六个逻辑适配器 id
|
|
8
|
+
- 让 `@dsh-workbench/core` 只依赖本包,就能获得默认行为
|
|
9
|
+
- 不把适配器变成独立 dsh 插件,也不需要用户额外 enable
|
|
10
|
+
|
|
11
|
+
## 入口
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { DEFAULT_ADAPTERS } from '@dsh-workbench/adapters-default';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 默认集合
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
opencli · browser · supply · profile · probe · data
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 边界
|
|
24
|
+
|
|
25
|
+
四个实现包都是本包的普通 `dependencies`,不是 optional,也不是 peer;逻辑适配器仍是 opencli / browser / supply / profile / probe / data。
|
|
26
|
+
|
|
27
|
+
## 验证
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm --filter @dsh-workbench/adapters-default run build
|
|
31
|
+
pnpm --filter @dsh-workbench/adapters-default run test
|
|
32
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DshHostContext, DshShell } from '@dsh-workbench/shared';
|
|
2
|
+
import type { AdapterSet } from '@dsh-workbench/shared/host';
|
|
3
|
+
export declare const DEFAULT_ADAPTER_SET_ID = "@dsh-workbench/adapters-default";
|
|
4
|
+
export interface DefaultAdapterSetOptions {
|
|
5
|
+
readonly shell?: DshShell | undefined;
|
|
6
|
+
readonly logger?: {
|
|
7
|
+
info?(message: string): void;
|
|
8
|
+
warn?(message: string): void;
|
|
9
|
+
} | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function createAdapterSet(ctx: DshHostContext, options?: DefaultAdapterSetOptions): AdapterSet;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ADAPTER_SET_API_VERSION, runningVersionOf } from '@dsh-workbench/shared/host';
|
|
2
|
+
import { createDataReader, opencliCommandOf } from '@dsh-workbench/adapter-runtime';
|
|
3
|
+
import { dshPluginsHandler, profileDirOf } from '@dsh-workbench/adapter-supply';
|
|
4
|
+
import { readSelfUpdateView } from '@dsh-workbench/adapter-probe';
|
|
5
|
+
import { createHostActions } from './host-actions.js';
|
|
6
|
+
import { createPluginSurface } from './plugin-surface.js';
|
|
7
|
+
import { createProbePort } from './probe-port.js';
|
|
8
|
+
import { createRuntimePort } from './runtime-port.js';
|
|
9
|
+
import { createSupplyPort } from './supply-port.js';
|
|
10
|
+
export const DEFAULT_ADAPTER_SET_ID = '@dsh-workbench/adapters-default';
|
|
11
|
+
export function createAdapterSet(ctx, options = {}) {
|
|
12
|
+
const shell = options.shell ?? ctx.get('shell');
|
|
13
|
+
const logger = options.logger ?? ctx.logger;
|
|
14
|
+
const runtime = createRuntimePort();
|
|
15
|
+
const opencli = opencliCommandOf(ctx);
|
|
16
|
+
const supply = createSupplyPort();
|
|
17
|
+
return {
|
|
18
|
+
apiVersion: ADAPTER_SET_API_VERSION,
|
|
19
|
+
id: DEFAULT_ADAPTER_SET_ID,
|
|
20
|
+
version: runningVersionOf(import.meta.url) ?? '0.0.0',
|
|
21
|
+
data: createDataReader({ shell, command: opencli.command }),
|
|
22
|
+
supply,
|
|
23
|
+
modules: supply,
|
|
24
|
+
profile: {
|
|
25
|
+
dirOf: profileDirOf,
|
|
26
|
+
dshPlugins: dshPluginsHandler,
|
|
27
|
+
selfUpdateView: readSelfUpdateView,
|
|
28
|
+
},
|
|
29
|
+
probe: createProbePort(),
|
|
30
|
+
runtime,
|
|
31
|
+
plugins: createPluginSurface({
|
|
32
|
+
shell,
|
|
33
|
+
command: opencli.command,
|
|
34
|
+
...(logger === undefined ? {} : { logger }),
|
|
35
|
+
}),
|
|
36
|
+
actions: createHostActions(),
|
|
37
|
+
};
|
|
38
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from '@dsh-workbench/adapter-runtime';
|
|
2
|
+
export * from '@dsh-workbench/adapter-supply';
|
|
3
|
+
export * from '@dsh-workbench/adapter-profile';
|
|
4
|
+
export * from '@dsh-workbench/adapter-probe';
|
|
5
|
+
export interface AdapterDescriptor {
|
|
6
|
+
readonly id: 'opencli' | 'browser' | 'supply' | 'profile' | 'probe' | 'data';
|
|
7
|
+
readonly runtime: 'host';
|
|
8
|
+
}
|
|
9
|
+
export declare const DEFAULT_ADAPTERS: readonly AdapterDescriptor[];
|
|
10
|
+
export { createSupplyPort } from './supply-port.js';
|
|
11
|
+
export { createAdapterSet, DEFAULT_ADAPTER_SET_ID } from './adapter-set.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from '@dsh-workbench/adapter-runtime';
|
|
2
|
+
export * from '@dsh-workbench/adapter-supply';
|
|
3
|
+
export * from '@dsh-workbench/adapter-profile';
|
|
4
|
+
export * from '@dsh-workbench/adapter-probe';
|
|
5
|
+
export const DEFAULT_ADAPTERS = Object.freeze([
|
|
6
|
+
Object.freeze({ id: 'opencli', runtime: 'host' }),
|
|
7
|
+
Object.freeze({ id: 'browser', runtime: 'host' }),
|
|
8
|
+
Object.freeze({ id: 'supply', runtime: 'host' }),
|
|
9
|
+
Object.freeze({ id: 'profile', runtime: 'host' }),
|
|
10
|
+
Object.freeze({ id: 'probe', runtime: 'host' }),
|
|
11
|
+
Object.freeze({ id: 'data', runtime: 'host' }),
|
|
12
|
+
]);
|
|
13
|
+
export { createSupplyPort } from './supply-port.js';
|
|
14
|
+
export { createAdapterSet, DEFAULT_ADAPTER_SET_ID } from './adapter-set.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DshShell } from '@dsh-workbench/shared';
|
|
2
|
+
import type { PluginSurface } from '@dsh-workbench/shared/host';
|
|
3
|
+
export declare function createPluginSurface(options: {
|
|
4
|
+
readonly shell?: DshShell | undefined;
|
|
5
|
+
readonly command: string;
|
|
6
|
+
readonly logger?: {
|
|
7
|
+
info?(message: string): void;
|
|
8
|
+
warn?(message: string): void;
|
|
9
|
+
} | undefined;
|
|
10
|
+
}): PluginSurface;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createOpencli } from '@dsh-workbench/adapter-runtime';
|
|
2
|
+
import { createDeclarationLookup, createPluginCatalog, createPluginUnits, } from '@dsh-workbench/adapter-supply';
|
|
3
|
+
export function createPluginSurface(options) {
|
|
4
|
+
return {
|
|
5
|
+
declarationLookup: createDeclarationLookup,
|
|
6
|
+
createUnits(input) {
|
|
7
|
+
const shell = options.shell;
|
|
8
|
+
if (shell === undefined)
|
|
9
|
+
throw new Error('没有 shell 服务,插件的命令面起不来。');
|
|
10
|
+
const catalog = createPluginCatalog({ shell, command: options.command });
|
|
11
|
+
return createPluginUnits({
|
|
12
|
+
registry: input.registry,
|
|
13
|
+
catalog,
|
|
14
|
+
rows: input.rows,
|
|
15
|
+
declared: input.declared,
|
|
16
|
+
opencliFor: (plugin) => createOpencli({ shell, plugin, command: options.command, logger: options.logger }),
|
|
17
|
+
...(input.toolNames === undefined ? {} : { toolNames: input.toolNames }),
|
|
18
|
+
...(input.logger === undefined ? {} : { logger: input.logger }),
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { opencliCommandOf } from '@dsh-workbench/adapter-runtime';
|
|
4
|
+
import { isInstalledCopy, packageRootOf, prependPath, runDetached, runtimeSeedPaths, runtimeSeedRootOf, seedRuntimeFiles, seedWorkbenchToolchain, warnUnwritableRoot, workshopSeedPlan, } from '@dsh-workbench/adapter-probe';
|
|
5
|
+
export function createRuntimePort() {
|
|
6
|
+
return {
|
|
7
|
+
packageRoot: packageRootOf,
|
|
8
|
+
opencliCommand: opencliCommandOf,
|
|
9
|
+
warnUnwritableRoot,
|
|
10
|
+
seed(ctx, options) {
|
|
11
|
+
const root = runtimeSeedRootOf(ctx);
|
|
12
|
+
if (root === null)
|
|
13
|
+
return;
|
|
14
|
+
const home = dirname(root);
|
|
15
|
+
const packageRoot = packageRootOf(options.corePackageUrl);
|
|
16
|
+
const paths = runtimeSeedPaths(root);
|
|
17
|
+
const log = options.log;
|
|
18
|
+
for (const file of seedRuntimeFiles({ root, home, packageRoot, log }))
|
|
19
|
+
log(`自举写下 ${file}`);
|
|
20
|
+
if (prependPath(paths.entryDir))
|
|
21
|
+
log(`PATH 前插 ${paths.entryDir}`);
|
|
22
|
+
seedWorkbenchToolchain(root, log);
|
|
23
|
+
const plan = workshopSeedPlan(packageRoot, home, root);
|
|
24
|
+
runDetached(plan.entry, log);
|
|
25
|
+
const workshopReady = existsSync(paths.workshopManifest) && existsSync(join(paths.workshop, 'node_modules'));
|
|
26
|
+
if (isInstalledCopy(packageRoot) && !workshopReady) {
|
|
27
|
+
log('DIY 工坊骨架不在:后台建起来(第一次会下载依赖,几百 MB)');
|
|
28
|
+
runDetached(plan.full, log);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { cliCatalogPath, isolatedHome, libInstallCommand, vendorPluginsDir } from '@dsh-workbench/adapter-runtime';
|
|
2
|
+
import { createRegistryNotebook, isNewerVersion, latestVersion, missingReleaseParts, probeRelease } from '@dsh-workbench/adapter-profile';
|
|
3
|
+
import { opencliInstallCommand, startSelfUpdate } from '@dsh-workbench/adapter-probe';
|
|
4
|
+
import { declarationGaps, declarationRefusalOf, moduleDeclarationOf, packageRouteOf, pathDeclarationOf, pluginInstallPlan, profileDirOf, profileModules, readBundleManager, readInstalledModule, readProfilePackage, refusalReason, registryDeclarationOf, resolvePluginSource, splitNpmSpec, } from '@dsh-workbench/adapter-supply';
|
|
5
|
+
export function createSupplyPort() {
|
|
6
|
+
const port = {
|
|
7
|
+
isolatedHome,
|
|
8
|
+
cliCatalogPath,
|
|
9
|
+
vendorPluginsDir,
|
|
10
|
+
opencliInstallCommand,
|
|
11
|
+
profileDirOf,
|
|
12
|
+
profileModules,
|
|
13
|
+
readInstalledModule,
|
|
14
|
+
readProfilePackage,
|
|
15
|
+
readBundleManager,
|
|
16
|
+
createRegistryNotebook,
|
|
17
|
+
declarationGaps,
|
|
18
|
+
moduleDeclarationOf,
|
|
19
|
+
registryDeclarationOf,
|
|
20
|
+
pathDeclarationOf,
|
|
21
|
+
declarationRefusalOf,
|
|
22
|
+
refusalReason,
|
|
23
|
+
latestVersion,
|
|
24
|
+
missingReleaseParts,
|
|
25
|
+
isNewerVersion,
|
|
26
|
+
pluginInstallPlan,
|
|
27
|
+
packageRouteOf,
|
|
28
|
+
probeRelease,
|
|
29
|
+
resolvePluginSource,
|
|
30
|
+
splitNpmSpec,
|
|
31
|
+
libInstallCommand,
|
|
32
|
+
startSelfUpdate,
|
|
33
|
+
};
|
|
34
|
+
return { ...port, env: port, modules: port };
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/adapters-default",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"description": "Default host adapter set installed with @dsh-workbench/core.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@dsh-workbench/adapter-probe": "1.0.0-beta.0",
|
|
17
|
+
"@dsh-workbench/adapter-profile": "1.0.0-beta.0",
|
|
18
|
+
"@dsh-workbench/adapter-runtime": "1.0.0-beta.0",
|
|
19
|
+
"@dsh-workbench/adapter-supply": "1.0.0-beta.0",
|
|
20
|
+
"@dsh-workbench/shared": "1.0.0-beta.0"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/novaeth/dsh-workbench.git",
|
|
29
|
+
"directory": "packages/adapters-default"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^24.19.0",
|
|
33
|
+
"vitest": "^5.0.2",
|
|
34
|
+
"@vitest/coverage-v8": "^5.0.2"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc -p tsconfig.json",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"arch": "arch-guard",
|
|
40
|
+
"check:runtimes": "node ../../scripts/check-adapter-package.mjs --runtime",
|
|
41
|
+
"coverage": "vitest run --coverage --coverage.reporter=text-summary --testTimeout=20000"
|
|
42
|
+
}
|
|
6
43
|
}
|