@dsh-workbench/shared 1.1.12 → 1.1.14-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/README.md +6 -4
- package/dist/api/dsh.d.ts +2 -0
- package/dist/config/constants.d.ts +2 -0
- package/dist/config/constants.js +2 -0
- package/dist/contract/command.d.ts +2 -0
- package/dist/contract/unit-declaration.js +3 -2
- package/dist/host/data-root.js +5 -3
- package/dist/host/flow/step.d.ts +11 -0
- package/dist/host/flow/step.js +21 -0
- package/dist/host/host-kit.d.ts +7 -2
- package/dist/host/host-kit.js +4 -1
- package/dist/host/install-failure.js +1 -1
- package/dist/host/lib-install.d.ts +1 -0
- package/dist/host/lib-install.js +4 -3
- package/dist/host/paths.js +8 -7
- package/dist/host/payload.d.ts +12 -0
- package/dist/host/payload.js +16 -0
- package/dist/host/preflight.d.ts +4 -2
- package/dist/host/shell-text.d.ts +11 -1
- package/dist/host/shell-text.js +11 -3
- package/dist/host/shell.d.ts +2 -0
- package/dist/host/shell.js +41 -11
- package/dist/host/tool-approval.d.ts +20 -0
- package/dist/host/tool-approval.js +20 -0
- package/dist/host/unit-face.d.ts +5 -0
- package/dist/host/unit-plugin.d.ts +33 -0
- package/dist/host/unit-plugin.js +25 -0
- package/dist/host/workspace-store.js +12 -6
- package/dist/host.d.ts +3 -0
- package/dist/host.js +3 -0
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/index.d.ts +5 -1
- package/dist/i18n/zh.d.ts +4 -0
- package/dist/i18n/zh.js +4 -0
- package/dist/lib/board-fact.d.ts +2 -1
- package/dist/lib/board-fact.js +10 -4
- package/dist/lib/ui.d.ts +8 -1
- package/dist/lib/ui.js +21 -3
- package/dist/lib/unit-plugin.d.ts +28 -0
- package/dist/lib/unit-plugin.js +23 -0
- package/dist/testing/host-fakes.d.ts +2 -0
- package/dist/testing/host-fakes.js +1 -1
- package/package.json +2 -2
- package/src/api/dsh.ts +2 -0
- package/src/components/__tests__/long-task-row.test.ts +1 -1
- package/src/config/constants.ts +3 -0
- package/src/contract/command.ts +2 -0
- package/src/contract/unit-declaration.ts +3 -2
- package/src/host/__tests__/data-root.test.ts +47 -0
- package/src/host/__tests__/plugin-helpers.test.ts +68 -0
- package/src/host/__tests__/runtime-layout.test.ts +5 -4
- package/src/host/__tests__/shell-text.test.ts +32 -7
- package/src/host/__tests__/shell.test.ts +94 -0
- package/src/host/data-root.ts +6 -3
- package/src/host/flow/__tests__/step.test.ts +43 -0
- package/src/host/flow/step.ts +21 -0
- package/src/host/host-kit.ts +11 -3
- package/src/host/install-failure.ts +1 -1
- package/src/host/lib-install.ts +5 -3
- package/src/host/paths.ts +8 -7
- package/src/host/payload.ts +17 -0
- package/src/host/preflight.ts +4 -2
- package/src/host/shell-text.ts +16 -2
- package/src/host/shell.ts +52 -12
- package/src/host/tool-approval.ts +31 -0
- package/src/host/unit-face.ts +5 -0
- package/src/host/unit-plugin.ts +49 -0
- package/src/host/workspace-store.ts +13 -6
- package/src/host.ts +3 -0
- package/src/i18n/en.ts +4 -0
- package/src/i18n/zh.ts +4 -0
- package/src/lib/__tests__/board-fact.test.ts +8 -0
- package/src/lib/__tests__/ui.test.ts +26 -0
- package/src/lib/board-fact.ts +11 -4
- package/src/lib/ui.ts +21 -3
- package/src/testing/host-fakes.ts +3 -1
- package/dist/components/SelectFieldWheel.d.ts +0 -9
- package/dist/components/SelectFieldWheel.js +0 -35
- package/dist/host/channel-plugin.d.ts +0 -15
- package/dist/host/channel-plugin.js +0 -42
- package/dist/host/command-name.d.ts +0 -1
- package/dist/host/command-name.js +0 -14
- package/dist/host/opencli-runner.d.ts +0 -26
- package/dist/host/opencli-runner.js +0 -50
- package/dist/host/plugin-source.d.ts +0 -33
- package/dist/host/plugin-source.js +0 -91
- package/dist/host/runner.d.ts +0 -26
- package/dist/host/runner.js +0 -50
- package/dist/host/runtime-links.d.ts +0 -7
- package/dist/host/runtime-links.js +0 -25
- package/dist/lib/version.d.ts +0 -4
- package/dist/lib/version.js +0 -21
- package/dist/testing/git.d.ts +0 -3
- package/dist/testing/git.js +0 -36
package/dist/host/runner.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { DataRequest, DataResult } from '../contract/data.js';
|
|
2
|
-
/**
|
|
3
|
-
* 一条 opencli 命令的执行器:同一形状的 `execFile('opencli', args)`,结果只留 stdout。
|
|
4
|
-
*/
|
|
5
|
-
export type LibRunner = (args: readonly string[]) => Promise<{
|
|
6
|
-
readonly stdout: string;
|
|
7
|
-
}>;
|
|
8
|
-
export type OpencliRunner = LibRunner;
|
|
9
|
-
/**
|
|
10
|
-
* 读缝(`DataReader.read`)的形状;模块直接把自己的 `data.read` 传进来即可。
|
|
11
|
-
*/
|
|
12
|
-
export type OpencliRead = (request: DataRequest) => Promise<DataResult<unknown>>;
|
|
13
|
-
export interface OpencliRunnerOptions {
|
|
14
|
-
readonly timeoutMs?: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 把读缝包成一条 opencli 命令的执行器:给还按 `execFile('opencli', args)` 收结果的编排库用,
|
|
18
|
-
* 让它们跑在面板用的那份 opencli 上(同一套插件、同一份登录态)。
|
|
19
|
-
*
|
|
20
|
-
* 失败按 opencli 自己的约定还原:未登录是 `code: AUTH_REQUIRED` + 退出码 77,编排库的
|
|
21
|
-
* 「等登录再重试」才接得上;其它失败保留 `Command failed: opencli …` 那句外壳。
|
|
22
|
-
* @param read 模块手里的读缝(`data.read`)。
|
|
23
|
-
* @param options `timeoutMs` 透传给读缝;不传就用读缝自己的默认值。
|
|
24
|
-
* @returns 执行器;直接交给编排库的 `setOpencliRunner`。
|
|
25
|
-
*/
|
|
26
|
-
export declare function opencliRunnerOf(read: OpencliRead, options?: OpencliRunnerOptions): OpencliRunner;
|
package/dist/host/runner.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const AUTH_REQUIRED_EXIT_CODE = 77;
|
|
2
|
-
function textOf(value) {
|
|
3
|
-
return typeof value === 'string' ? value : '';
|
|
4
|
-
}
|
|
5
|
-
function failedOf(args, error) {
|
|
6
|
-
const head = `Command failed: opencli ${args.join(' ')}`;
|
|
7
|
-
const auth = error?.pageCode === 'auth-required';
|
|
8
|
-
const helpUrl = textOf(error?.helpUrl);
|
|
9
|
-
const detail = textOf(error?.detail);
|
|
10
|
-
const hint = textOf(error?.hint);
|
|
11
|
-
const failed = new Error([
|
|
12
|
-
head,
|
|
13
|
-
...(auth
|
|
14
|
-
? ['code: AUTH_REQUIRED', `message: ${textOf(error?.message)}`]
|
|
15
|
-
: [textOf(error?.message) || 'opencli 这条命令没跑通']),
|
|
16
|
-
...(detail === '' ? [] : [detail]),
|
|
17
|
-
...(hint === '' ? [] : [hint]),
|
|
18
|
-
...(auth && helpUrl !== ''
|
|
19
|
-
? [`help: Please open Chrome or Chromium and log in to ${helpUrl}`]
|
|
20
|
-
: []),
|
|
21
|
-
].join('\n'));
|
|
22
|
-
if (auth)
|
|
23
|
-
failed.code = AUTH_REQUIRED_EXIT_CODE;
|
|
24
|
-
return failed;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* 把读缝包成一条 opencli 命令的执行器:给还按 `execFile('opencli', args)` 收结果的编排库用,
|
|
28
|
-
* 让它们跑在面板用的那份 opencli 上(同一套插件、同一份登录态)。
|
|
29
|
-
*
|
|
30
|
-
* 失败按 opencli 自己的约定还原:未登录是 `code: AUTH_REQUIRED` + 退出码 77,编排库的
|
|
31
|
-
* 「等登录再重试」才接得上;其它失败保留 `Command failed: opencli …` 那句外壳。
|
|
32
|
-
* @param read 模块手里的读缝(`data.read`)。
|
|
33
|
-
* @param options `timeoutMs` 透传给读缝;不传就用读缝自己的默认值。
|
|
34
|
-
* @returns 执行器;直接交给编排库的 `setOpencliRunner`。
|
|
35
|
-
*/
|
|
36
|
-
export function opencliRunnerOf(read, options = {}) {
|
|
37
|
-
return async (args) => {
|
|
38
|
-
const result = await read({
|
|
39
|
-
kind: 'command',
|
|
40
|
-
adapter: 'opencli',
|
|
41
|
-
argv: [...args],
|
|
42
|
-
...(options.timeoutMs === undefined
|
|
43
|
-
? {}
|
|
44
|
-
: { timeoutMs: options.timeoutMs }),
|
|
45
|
-
});
|
|
46
|
-
if (result.ok)
|
|
47
|
-
return { stdout: JSON.stringify(result.data) };
|
|
48
|
-
throw failedOf(args, result.error);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 让共用依赖也能 import opencli:把隔离运行时里那份 opencli 链接到 libs 的 node_modules。
|
|
3
|
-
* 跑在 libs 里的命令(比如 opencli-workflow 带的 gitops)会按包名找 @jackwener/opencli,
|
|
4
|
-
* 找不到就起不来 —— 它不在 libs 的依赖里,是运行时提供的那一份。
|
|
5
|
-
* @returns 这次真的建了链接就 `true`;已经有了、或运行时那份还没装,就是 `false`。
|
|
6
|
-
*/
|
|
7
|
-
export declare function ensureLibsOpencliPeer(): boolean;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, symlinkSync } from 'node:fs';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { OPENCLI_NPM_PACKAGE, libsPrefix, toolchainOpencliDir } from './paths.js';
|
|
4
|
-
/**
|
|
5
|
-
* 让共用依赖也能 import opencli:把隔离运行时里那份 opencli 链接到 libs 的 node_modules。
|
|
6
|
-
* 跑在 libs 里的命令(比如 opencli-workflow 带的 gitops)会按包名找 @jackwener/opencli,
|
|
7
|
-
* 找不到就起不来 —— 它不在 libs 的依赖里,是运行时提供的那一份。
|
|
8
|
-
* @returns 这次真的建了链接就 `true`;已经有了、或运行时那份还没装,就是 `false`。
|
|
9
|
-
*/
|
|
10
|
-
export function ensureLibsOpencliPeer() {
|
|
11
|
-
const link = `${libsPrefix()}/node_modules/${OPENCLI_NPM_PACKAGE}`;
|
|
12
|
-
if (existsSync(link))
|
|
13
|
-
return false;
|
|
14
|
-
const target = toolchainOpencliDir();
|
|
15
|
-
if (!existsSync(target))
|
|
16
|
-
return false;
|
|
17
|
-
try {
|
|
18
|
-
mkdirSync(dirname(link), { recursive: true });
|
|
19
|
-
symlinkSync(target, link);
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}
|
package/dist/lib/version.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function isValidVersion(value: string): boolean;
|
|
2
|
-
export declare function isPrereleaseVersion(value: string): boolean;
|
|
3
|
-
export declare function compareVersions(left: string, right: string): number | undefined;
|
|
4
|
-
export declare function isNewerVersion(latest: string, installed: string): boolean;
|
package/dist/lib/version.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import semver from 'semver';
|
|
2
|
-
export function isValidVersion(value) {
|
|
3
|
-
return semver.valid(value.trim()) !== null;
|
|
4
|
-
}
|
|
5
|
-
export function isPrereleaseVersion(value) {
|
|
6
|
-
const parsed = semver.valid(value.trim());
|
|
7
|
-
return parsed !== null && semver.prerelease(parsed) !== null;
|
|
8
|
-
}
|
|
9
|
-
export function compareVersions(left, right) {
|
|
10
|
-
const a = semver.valid(left.trim());
|
|
11
|
-
const b = semver.valid(right.trim());
|
|
12
|
-
if (a === null || b === null)
|
|
13
|
-
return undefined;
|
|
14
|
-
return semver.compare(a, b);
|
|
15
|
-
}
|
|
16
|
-
export function isNewerVersion(latest, installed) {
|
|
17
|
-
if (latest === installed)
|
|
18
|
-
return false;
|
|
19
|
-
const compared = compareVersions(latest, installed);
|
|
20
|
-
return compared === undefined ? true : compared > 0;
|
|
21
|
-
}
|
package/dist/testing/git.d.ts
DELETED
package/dist/testing/git.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { quoteShellArg, tailLines } from '../host/shell-text.js';
|
|
2
|
-
import { runShell } from '../host/shell.js';
|
|
3
|
-
export function createFakeGit(shell) {
|
|
4
|
-
return {
|
|
5
|
-
async origin(path) {
|
|
6
|
-
const key = path.trim();
|
|
7
|
-
if (!key)
|
|
8
|
-
return { kind: 'unknown', reason: 'no-path' };
|
|
9
|
-
const result = await runShell(shell, `git -C ${quoteShellArg(key)} remote get-url origin`);
|
|
10
|
-
if (result.exitCode !== 0)
|
|
11
|
-
return { kind: 'no-origin', detail: tailLines(result.stderr, 3) };
|
|
12
|
-
return { kind: 'ok', remote: result.stdout.trim() };
|
|
13
|
-
},
|
|
14
|
-
async branch(path) {
|
|
15
|
-
const key = path.trim();
|
|
16
|
-
if (!key)
|
|
17
|
-
return { kind: 'unknown', reason: 'no-path' };
|
|
18
|
-
const result = await runShell(shell, `git -C ${quoteShellArg(key)} rev-parse --abbrev-ref HEAD`);
|
|
19
|
-
const name = result.stdout.trim();
|
|
20
|
-
if (result.exitCode !== 0)
|
|
21
|
-
return { kind: 'no-branch', detail: tailLines(result.stderr, 3) };
|
|
22
|
-
if (name === '' || name === 'HEAD')
|
|
23
|
-
return { kind: 'no-branch', detail: name };
|
|
24
|
-
return { kind: 'ok', branch: name };
|
|
25
|
-
},
|
|
26
|
-
async head(path) {
|
|
27
|
-
const key = path.trim();
|
|
28
|
-
if (!key)
|
|
29
|
-
return { kind: 'unknown', reason: 'no-path' };
|
|
30
|
-
const result = await runShell(shell, `git -C ${quoteShellArg(key)} rev-parse HEAD`);
|
|
31
|
-
if (result.exitCode !== 0)
|
|
32
|
-
return { kind: 'no-head', detail: tailLines(result.stderr, 3) };
|
|
33
|
-
return { kind: 'ok', commit: result.stdout.trim() };
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|