@dsh-workbench/shared 0.3.11 → 1.0.0-beta.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 +97 -0
- package/dist/api/blocker-table.d.ts +3 -3
- package/dist/api/blocker-table.js +47 -23
- package/dist/api/dsh.d.ts +1 -1
- package/dist/api/workbench-client.js +2 -1
- package/dist/components/Activity.css +0 -1
- package/dist/components/ApprovalDetail.css +1 -2
- package/dist/components/ApprovalDetail.d.ts +1 -1
- package/dist/components/ApprovalPlan.css +0 -1
- package/dist/components/Card.css +0 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/CardBoundary.d.ts +1 -1
- package/dist/components/CardHead.css +0 -1
- package/dist/components/CardHead.d.ts +1 -1
- package/dist/components/ChoiceGroup.css +1 -2
- package/dist/components/ConfirmBar.d.ts +1 -1
- package/dist/components/ConfirmBar.js +1 -1
- package/dist/components/Form.css +1 -1
- package/dist/components/FormActions.js +1 -1
- package/dist/components/FormNodes.js +5 -1
- package/dist/components/FormRows.css +1 -0
- package/dist/components/FormRows.d.ts +4 -2
- package/dist/components/FormRows.js +5 -4
- package/dist/components/LongTaskRow.css +1 -2
- package/dist/components/LongTaskRow.d.ts +1 -1
- package/dist/components/LongTaskRow.js +1 -1
- package/dist/components/Note.css +0 -1
- package/dist/components/ResourceStates.css +0 -1
- package/dist/components/SettingsSection.css +0 -1
- package/dist/components/Spinner.css +0 -1
- package/dist/components/Stack.css +0 -1
- package/dist/components/StateBlock.css +0 -1
- package/dist/components/board-module.d.ts +3 -3
- package/dist/components/icons.d.ts +1 -1
- package/dist/components/icons.js +11 -4
- package/dist/config/constants.d.ts +2 -4
- package/dist/config/constants.js +2 -7
- package/dist/contract/adapters.d.ts +10 -0
- package/dist/contract/cli.d.ts +3 -0
- package/dist/contract/command.d.ts +22 -0
- package/dist/contract/data.d.ts +127 -0
- package/dist/contract/extension.d.ts +14 -0
- package/dist/contract/extension.js +1 -0
- package/dist/{api → contract}/facts.d.ts +12 -3
- package/dist/{api → contract}/facts.js +19 -1
- package/dist/contract/git.d.ts +38 -0
- package/dist/contract/git.js +1 -0
- package/dist/contract/lib.d.ts +4 -0
- package/dist/contract/lib.js +1 -0
- package/dist/contract/needs.d.ts +132 -0
- package/dist/contract/needs.js +232 -0
- package/dist/contract/plugin-source.d.ts +1 -0
- package/dist/contract/plugin-source.js +1 -0
- package/dist/contract/protocol/bundle-install.d.ts +136 -0
- package/dist/contract/protocol/bundle-install.js +12 -0
- package/dist/contract/protocol/config-sync.d.ts +55 -0
- package/dist/contract/protocol/config-sync.js +2 -0
- package/dist/contract/protocol/diy.d.ts +4 -0
- package/dist/contract/protocol/diy.js +4 -0
- package/dist/contract/protocol/dsh-plugins.d.ts +11 -0
- package/dist/contract/protocol/dsh-plugins.js +1 -0
- package/dist/contract/protocol/long-tasks.d.ts +13 -0
- package/dist/contract/protocol/long-tasks.js +1 -0
- package/dist/contract/protocol/market-index.d.ts +195 -0
- package/dist/contract/protocol/market-index.js +7 -0
- package/dist/contract/protocol/platform.d.ts +44 -0
- package/dist/contract/protocol/platform.js +1 -0
- package/dist/contract/protocol/preflight-wake.d.ts +7 -0
- package/dist/contract/protocol/preflight-wake.js +1 -0
- package/dist/contract/protocol/profile-create.d.ts +30 -0
- package/dist/contract/protocol/profile-create.js +2 -0
- package/dist/contract/protocol/sidebar-edition.d.ts +14 -0
- package/dist/contract/protocol/sidebar-edition.js +2 -0
- package/dist/contract/protocol/unit-manifests.d.ts +6 -0
- package/dist/contract/protocol/unit-manifests.js +1 -0
- package/dist/contract/unit-board.js +1 -0
- package/dist/contract/unit-capability.d.ts +34 -0
- package/dist/contract/unit-capability.js +1 -0
- package/dist/{host → contract}/unit-declaration.d.ts +7 -5
- package/dist/{api → contract}/unit-declaration.js +19 -13
- package/dist/contract/unit.d.ts +57 -0
- package/dist/contract/unit.js +24 -0
- package/dist/contract/workbench-contract.d.ts +15 -0
- package/dist/contract/workbench-contract.js +1 -0
- package/dist/host/adapter-set.d.ts +26 -0
- package/dist/host/adapter-set.js +244 -0
- package/dist/host/adapter-types.d.ts +79 -0
- package/dist/host/adapter-types.js +23 -0
- package/dist/host/adapters.d.ts +28 -0
- package/dist/host/adapters.js +9 -0
- package/dist/host/browser.d.ts +3 -0
- package/dist/host/browser.js +3 -0
- package/dist/host/changelog.d.ts +21 -0
- package/dist/host/changelog.js +188 -0
- package/dist/host/channel-plugin.d.ts +15 -0
- package/dist/host/channel-plugin.js +42 -0
- package/dist/host/cli.d.ts +4 -0
- package/dist/host/cli.js +7 -0
- package/dist/host/command-name.d.ts +1 -0
- package/dist/host/command-name.js +14 -0
- package/dist/host/data-error.d.ts +13 -0
- package/dist/host/data-error.js +20 -0
- package/dist/host/data-root.js +3 -0
- package/dist/host/diy-debug.js +2 -1
- package/dist/host/diy-record.js +2 -1
- package/dist/host/extension.d.ts +7 -0
- package/dist/host/extension.js +39 -0
- package/dist/host/facts.d.ts +1 -1
- package/dist/host/facts.js +3 -2
- package/dist/host/git.d.ts +2 -33
- package/dist/host/git.js +2 -2
- package/dist/host/http.js +2 -2
- package/dist/host/lib-capabilities.d.ts +22 -0
- package/dist/host/lib-capabilities.js +37 -0
- package/dist/host/lib-install.d.ts +9 -0
- package/dist/host/lib-install.js +10 -0
- package/dist/host/long-task.d.ts +1 -1
- package/dist/host/long-task.js +4 -3
- package/dist/host/market-index.d.ts +22 -0
- package/dist/host/market-index.js +379 -0
- package/dist/host/needs.d.ts +4 -0
- package/dist/host/needs.js +2 -0
- package/dist/host/patch.d.ts +9 -0
- package/dist/host/patch.js +78 -0
- package/dist/host/paths.d.ts +12 -0
- package/dist/host/paths.js +28 -0
- package/dist/host/platform.d.ts +14 -0
- package/dist/host/platform.js +40 -0
- package/dist/host/plugin-source.d.ts +8 -6
- package/dist/host/plugin-source.js +43 -33
- package/dist/host/plugin.d.ts +4 -0
- package/dist/host/plugin.js +39 -0
- package/dist/host/port-types.d.ts +192 -0
- package/dist/host/port-types.js +1 -0
- package/dist/host/preflight.d.ts +28 -0
- package/dist/host/preflight.js +1 -0
- package/dist/host/profile-port.d.ts +4 -0
- package/dist/host/profile-port.js +4 -0
- package/dist/host/provision.d.ts +2 -2
- package/dist/host/provision.js +5 -3
- package/dist/host/recipe-rules.d.ts +5 -0
- package/dist/host/recipe-rules.js +382 -0
- package/dist/host/recipe.d.ts +14 -0
- package/dist/host/recipe.js +283 -0
- package/dist/host/release-packages.generated.d.ts +1 -0
- package/dist/host/release-packages.generated.js +10 -0
- package/dist/host/shell-text.d.ts +9 -2
- package/dist/host/shell-text.js +15 -3
- package/dist/host/shell.d.ts +2 -0
- package/dist/host/shell.js +7 -0
- package/dist/host/spec.d.ts +8 -0
- package/dist/host/spec.js +24 -0
- package/dist/host/supply-index.d.ts +34 -0
- package/dist/host/supply-index.js +202 -0
- package/dist/host/supply-port.d.ts +5 -0
- package/dist/host/supply-port.js +39 -0
- package/dist/host/time.d.ts +12 -0
- package/dist/host/time.js +19 -0
- package/dist/host/tokens.d.ts +26 -0
- package/dist/host/tokens.js +154 -0
- package/dist/host/tool-kit.d.ts +0 -6
- package/dist/host/tool-kit.js +0 -22
- package/dist/host/unit-face.d.ts +12 -4
- package/dist/host/version-range.d.ts +2 -0
- package/dist/host/version-range.js +13 -0
- package/dist/host/version.d.ts +4 -0
- package/dist/host/version.js +27 -0
- package/dist/host.d.ts +53 -16
- package/dist/host.js +53 -16
- package/dist/i18n/en.js +225 -71
- package/dist/i18n/index.d.ts +299 -73
- package/dist/i18n/merge.js +1 -1
- package/dist/i18n/need-text.d.ts +26 -0
- package/dist/i18n/need-text.js +26 -0
- package/dist/i18n/settings.d.ts +70 -0
- package/dist/i18n/settings.js +136 -0
- package/dist/i18n/zh.d.ts +298 -72
- package/dist/i18n/zh.js +227 -73
- package/dist/index.d.ts +27 -7
- package/dist/index.js +27 -7
- package/dist/{api → lib}/dsh-client.d.ts +11 -1
- package/dist/lib/dsh-client.js +1 -0
- package/dist/lib/market-index.d.ts +7 -0
- package/dist/lib/market-index.js +25 -0
- package/dist/lib/react.d.ts +0 -40
- package/dist/lib/react.js +0 -36
- package/dist/lib/ui.js +3 -9
- package/dist/lib/version.d.ts +4 -0
- package/dist/lib/version.js +21 -0
- package/dist/testing/data.d.ts +13 -0
- package/dist/testing/data.js +46 -0
- package/dist/testing/declaration.d.ts +1 -1
- package/dist/testing/declaration.js +1 -1
- package/dist/testing/host-fakes.d.ts +0 -13
- package/dist/testing/host-fakes.js +0 -24
- package/dist/testing/needs.d.ts +16 -0
- package/dist/testing/needs.js +46 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2 -0
- package/package.json +22 -4
- package/src/api/__tests__/blocker-table.test.ts +135 -86
- package/src/api/blocker-table.ts +52 -26
- package/src/api/dsh.ts +1 -1
- package/src/api/host-write.ts +0 -1
- package/src/api/workbench-client.test.ts +2 -2
- package/src/api/workbench-client.ts +2 -1
- package/src/components/Activity.css +0 -1
- package/src/components/ApprovalDetail.css +1 -2
- package/src/components/ApprovalDetail.tsx +1 -1
- package/src/components/ApprovalPlan.css +0 -1
- package/src/components/Card.css +0 -1
- package/src/components/Card.tsx +1 -1
- package/src/components/CardAnchor.test.tsx +1 -1
- package/src/components/CardBoundary.tsx +1 -1
- package/src/components/CardHead.css +0 -1
- package/src/components/CardHead.tsx +1 -1
- package/src/components/ChoiceGroup.css +1 -2
- package/src/components/ConfirmBar.tsx +1 -1
- package/src/components/Form.css +1 -1
- package/src/components/Form.test.tsx +6 -0
- package/src/components/Form.tsx +1 -1
- package/src/components/FormActions.tsx +1 -1
- package/src/components/FormNodes.tsx +6 -1
- package/src/components/FormRows.css +1 -0
- package/src/components/FormRows.test.tsx +30 -0
- package/src/components/FormRows.tsx +9 -5
- package/src/components/LongTaskRow.css +1 -2
- package/src/components/LongTaskRow.tsx +1 -1
- package/src/components/Note.css +0 -1
- package/src/components/ResourceStates.css +0 -1
- package/src/components/SelectFieldNodes.tsx +0 -1
- package/src/components/SettingsSection.css +0 -1
- package/src/components/Spinner.css +0 -1
- package/src/components/Stack.css +0 -1
- package/src/components/StateBlock.css +0 -1
- package/src/components/__tests__/long-task-row.test.ts +1 -1
- package/src/components/board-module.ts +3 -3
- package/src/components/icons.tsx +16 -8
- package/src/config/constants.ts +2 -8
- package/src/{api → contract}/__tests__/facts.test.ts +73 -25
- package/src/{api → contract}/__tests__/long-task.test.ts +3 -3
- package/src/contract/__tests__/needs.test.ts +74 -0
- package/src/{host → contract}/__tests__/unit-declaration.test.ts +1 -1
- package/src/contract/__tests__/unit.test.ts +43 -0
- package/src/contract/adapters.ts +9 -0
- package/src/contract/cli.ts +3 -0
- package/src/contract/command.ts +25 -0
- package/src/contract/data.ts +146 -0
- package/src/contract/extension.ts +20 -0
- package/src/{api → contract}/facts.ts +34 -4
- package/src/contract/git.ts +20 -0
- package/src/contract/lib.ts +5 -0
- package/src/contract/needs.ts +331 -0
- package/src/contract/plugin-source.ts +1 -0
- package/src/contract/protocol/bundle-install.ts +198 -0
- package/src/contract/protocol/config-sync.ts +65 -0
- package/src/contract/protocol/diy.ts +4 -0
- package/src/contract/protocol/dsh-plugins.ts +13 -0
- package/src/contract/protocol/long-tasks.ts +16 -0
- package/src/contract/protocol/market-index.ts +246 -0
- package/src/contract/protocol/platform.ts +47 -0
- package/src/contract/protocol/preflight-wake.ts +17 -0
- package/src/contract/protocol/profile-create.ts +36 -0
- package/src/contract/protocol/sidebar-edition.ts +19 -0
- package/src/contract/protocol/unit-manifests.ts +8 -0
- package/src/{api → contract}/unit-board.ts +0 -1
- package/src/contract/unit-capability.ts +37 -0
- package/src/{host → contract}/unit-declaration.ts +22 -18
- package/src/contract/unit.ts +76 -0
- package/src/contract/workbench-contract.ts +30 -0
- package/src/host/__tests__/adapter-set.test.ts +228 -0
- package/src/host/__tests__/adapters.test.ts +27 -0
- package/src/host/__tests__/changelog.test.ts +102 -0
- package/src/host/__tests__/command-name.test.ts +16 -0
- package/src/host/__tests__/diy-record.test.ts +3 -3
- package/src/host/__tests__/facts.test.ts +5 -5
- package/src/host/__tests__/long-task.test.ts +1 -1
- package/src/host/__tests__/market-index.test.ts +179 -0
- package/src/host/__tests__/plugin-ledger.test.ts +10 -10
- package/src/host/__tests__/provision.test.ts +7 -6
- package/src/host/__tests__/shell-text.test.ts +16 -1
- package/src/host/__tests__/supply-index.test.ts +137 -0
- package/src/host/__tests__/tokens.test.ts +110 -0
- package/src/host/__tests__/version-range.test.ts +21 -0
- package/src/host/adapter-set.ts +299 -0
- package/src/host/adapter-types.ts +105 -0
- package/src/host/adapters.ts +50 -0
- package/src/host/browser.ts +3 -0
- package/src/host/changelog.ts +212 -0
- package/src/host/channel-plugin.ts +55 -0
- package/src/host/cli.ts +11 -0
- package/src/host/command-name.ts +15 -0
- package/src/host/data-error.ts +21 -0
- package/src/host/data-root.ts +2 -0
- package/src/host/diy-debug.ts +2 -1
- package/src/host/diy-record.ts +2 -1
- package/src/host/extension.test.ts +55 -0
- package/src/host/extension.ts +57 -0
- package/src/host/facts.ts +4 -3
- package/src/host/git.ts +8 -16
- package/src/host/http.ts +2 -2
- package/src/host/lib-capabilities.ts +52 -0
- package/src/host/lib-install.ts +18 -0
- package/src/host/long-task.ts +4 -3
- package/src/host/market-index.ts +383 -0
- package/src/host/needs.ts +6 -0
- package/src/host/patch.ts +93 -0
- package/src/host/paths.ts +37 -0
- package/src/host/platform.ts +48 -0
- package/src/host/plugin-source.ts +48 -56
- package/src/host/plugin.ts +39 -0
- package/src/host/port-types.ts +223 -0
- package/src/host/preflight.ts +31 -0
- package/src/host/profile-port.ts +9 -0
- package/src/host/provision.ts +7 -4
- package/src/host/recipe-rules.ts +330 -0
- package/src/host/recipe.test.ts +334 -0
- package/src/host/recipe.ts +323 -0
- package/src/host/release-packages.generated.ts +10 -0
- package/src/host/shell-text.ts +15 -3
- package/src/host/shell.ts +9 -0
- package/src/host/spec.ts +32 -0
- package/src/host/supply-index.ts +256 -0
- package/src/host/supply-port.ts +45 -0
- package/src/host/time.ts +22 -0
- package/src/host/tokens.ts +186 -0
- package/src/host/tool-kit.ts +0 -35
- package/src/host/unit-face.ts +12 -4
- package/src/host/version-range.ts +13 -0
- package/src/host/version.ts +30 -0
- package/src/host.ts +53 -16
- package/src/i18n/en.ts +225 -71
- package/src/i18n/merge.test.ts +6 -6
- package/src/i18n/merge.ts +1 -1
- package/src/i18n/need-text.ts +27 -0
- package/src/i18n/settings.ts +141 -0
- package/src/i18n/zh.ts +228 -73
- package/src/index.ts +27 -7
- package/src/lib/blocker-action.ts +0 -1
- package/src/{api → lib}/dsh-client.ts +12 -1
- package/src/lib/market-index.ts +36 -0
- package/src/lib/react.ts +0 -40
- package/src/lib/text.test.ts +2 -2
- package/src/lib/ui.test.ts +6 -5
- package/src/lib/ui.ts +3 -9
- package/src/testing/__tests__/declaration.test.ts +1 -1
- package/src/testing/data.ts +66 -0
- package/src/testing/declaration.ts +2 -2
- package/src/testing/host-fakes.ts +0 -38
- package/src/testing/needs.ts +80 -0
- package/src/testing.ts +2 -0
- package/dist/api/unit-declaration.d.ts +0 -65
- package/dist/api/unit.d.ts +0 -85
- package/dist/api/unit.js +0 -8
- package/dist/api/workbench-contract.d.ts +0 -44
- package/dist/components/MockStrip.css +0 -39
- package/dist/components/MockStrip.d.ts +0 -15
- package/dist/components/MockStrip.js +0 -8
- package/dist/components/SaveBar.css +0 -7
- package/dist/host/browser-find.d.ts +0 -38
- package/dist/host/browser-find.js +0 -242
- package/dist/host/browser-read.d.ts +0 -28
- package/dist/host/browser-read.js +0 -243
- package/dist/host/opencli-runtime.d.ts +0 -25
- package/dist/host/opencli-runtime.js +0 -56
- package/dist/host/opencli-window.d.ts +0 -2
- package/dist/host/opencli-window.js +0 -8
- package/dist/host/opencli.d.ts +0 -37
- package/dist/host/opencli.js +0 -155
- package/dist/host/unit-declaration.js +0 -213
- package/dist/host/unit-libs.d.ts +0 -37
- package/dist/lib/diy-debug.d.ts +0 -80
- package/dist/lib/diy-debug.js +0 -88
- package/dist/lib/diy-record.d.ts +0 -135
- package/dist/lib/diy-record.js +0 -162
- package/dist/lib/lint-probe.d.ts +0 -1
- package/dist/lib/lint-probe.js +0 -6
- package/dist/lib/panel-state.d.ts +0 -120
- package/dist/lib/panel-state.js +0 -176
- package/src/api/__tests__/unit.test.ts +0 -38
- package/src/api/unit.ts +0 -93
- package/src/api/workbench-contract.ts +0 -59
- package/src/host/__tests__/browser-find.test.ts +0 -330
- package/src/host/__tests__/browser-read.test.ts +0 -228
- package/src/host/__tests__/opencli-runtime.test.ts +0 -46
- package/src/host/browser-find.ts +0 -311
- package/src/host/browser-read.ts +0 -311
- package/src/host/opencli-runtime.ts +0 -79
- package/src/host/opencli-window.ts +0 -11
- package/src/host/opencli.ts +0 -213
- package/src/host/unit-libs.ts +0 -41
- /package/dist/{api/blocker.js → contract/adapters.js} +0 -0
- /package/dist/{api → contract}/blocker.d.ts +0 -0
- /package/dist/{api/dsh-client.js → contract/blocker.js} +0 -0
- /package/dist/{api/unit-board.js → contract/cli.js} +0 -0
- /package/dist/{api/workbench-contract.js → contract/command.js} +0 -0
- /package/dist/{host/unit-libs.js → contract/data.js} +0 -0
- /package/dist/{api → contract}/long-task.d.ts +0 -0
- /package/dist/{api → contract}/long-task.js +0 -0
- /package/dist/{api → contract}/unit-board.d.ts +0 -0
- /package/src/{api → contract}/blocker.ts +0 -0
- /package/src/{api → contract}/long-task.ts +0 -0
|
@@ -23,6 +23,7 @@ export interface WorkspaceSnapshot {
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* 会话一行的来源(标题、空会话、在跑与否、被谁留住);retainedBy 按视图名记留住它的份数,mainView 大于 0 即正被主视图占着。
|
|
26
|
+
* projectionValues 是 dsh 的会话投影,外壳只读 `agentPreset` 一位(没选过模式时没有这一位)。
|
|
26
27
|
*/
|
|
27
28
|
export interface SessionSummary {
|
|
28
29
|
readonly id: string;
|
|
@@ -32,6 +33,7 @@ export interface SessionSummary {
|
|
|
32
33
|
readonly updatedAt: number;
|
|
33
34
|
readonly origin?: string;
|
|
34
35
|
readonly retainedBy: Readonly<Partial<Record<string, number>>>;
|
|
36
|
+
readonly projectionValues?: Readonly<Record<string, unknown>>;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -298,10 +300,19 @@ export interface DshSessionsRemote {
|
|
|
298
300
|
}
|
|
299
301
|
|
|
300
302
|
/**
|
|
301
|
-
*
|
|
303
|
+
* remote.agentPresets 写口:给还没开跑的会话挑模式(同一件事就是模式选择器点一下);
|
|
304
|
+
* 会话发出第一条消息后 dsh 会拒(模式已锁)。
|
|
305
|
+
*/
|
|
306
|
+
export interface DshAgentPresetsRemote {
|
|
307
|
+
select(sessionId: string, presetId: string): Promise<unknown>;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* dsh 客户端的远端写口集合;会话与模式两家。
|
|
302
312
|
*/
|
|
303
313
|
export interface DshClientRemote {
|
|
304
314
|
readonly sessions: DshSessionsRemote;
|
|
315
|
+
readonly agentPresets?: DshAgentPresetsRemote;
|
|
305
316
|
}
|
|
306
317
|
|
|
307
318
|
/**
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { MarketIndexSource, MarketLocalizedText } from '../contract/protocol/market-index.js';
|
|
2
|
+
|
|
3
|
+
const BRANCH = /^[A-Za-z0-9][A-Za-z0-9._/-]*$/;
|
|
4
|
+
|
|
5
|
+
export function marketBranchOk(value: string): boolean {
|
|
6
|
+
const branch = value.trim();
|
|
7
|
+
return (
|
|
8
|
+
BRANCH.test(branch) &&
|
|
9
|
+
!branch.includes('..') &&
|
|
10
|
+
!branch.endsWith('/') &&
|
|
11
|
+
!branch.endsWith('.') &&
|
|
12
|
+
!branch.includes('@{')
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function marketText(value: MarketLocalizedText | undefined, locale: string): string {
|
|
17
|
+
if (value === undefined) return '';
|
|
18
|
+
const zh = value.zh ?? '';
|
|
19
|
+
const en = value.en ?? '';
|
|
20
|
+
return locale.toLowerCase().startsWith('zh') ? zh || en : en || zh;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function marketInstallTarget(
|
|
24
|
+
name: string,
|
|
25
|
+
version: string,
|
|
26
|
+
source: MarketIndexSource,
|
|
27
|
+
): { readonly spec: string; readonly registry?: string } {
|
|
28
|
+
if (source.type === 'npm') {
|
|
29
|
+
const registry = (source.registry ?? '').trim();
|
|
30
|
+
return { spec: `${name}@${version}`, ...(registry === '' ? {} : { registry }) };
|
|
31
|
+
}
|
|
32
|
+
const base = `git+${source.url.trim().replace(/^git\+/, '')}#${source.commit}`;
|
|
33
|
+
const path = (source.path ?? '').trim().replace(/^\/+/, '');
|
|
34
|
+
return { spec: path === '' ? base : `${base}&path:/${path}` };
|
|
35
|
+
}
|
|
36
|
+
|
package/src/lib/react.ts
CHANGED
|
@@ -2,61 +2,21 @@ import type * as ReactTypes from 'react';
|
|
|
2
2
|
|
|
3
3
|
const react = require('react') as typeof ReactTypes;
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* React 的 `createElement` 换个短名字再导出 —— 这套代码用 `h(...)` 写元素。
|
|
7
|
-
*/
|
|
8
5
|
export const h = react.createElement;
|
|
9
6
|
|
|
10
|
-
/**
|
|
11
|
-
* React 的 `Fragment` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
12
|
-
*/
|
|
13
7
|
export const Fragment = react.Fragment;
|
|
14
8
|
|
|
15
|
-
/**
|
|
16
|
-
* React 的 `Component` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
17
|
-
*/
|
|
18
9
|
export const Component = react.Component;
|
|
19
10
|
|
|
20
|
-
/**
|
|
21
|
-
* React 的 `createContext` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
22
|
-
*/
|
|
23
11
|
export const createContext = react.createContext;
|
|
24
|
-
/**
|
|
25
|
-
* React 的 `useContext` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
26
|
-
*/
|
|
27
12
|
export const useContext = react.useContext;
|
|
28
13
|
|
|
29
|
-
/**
|
|
30
|
-
* React 的 `useState` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
31
|
-
*/
|
|
32
14
|
export const useState = react.useState;
|
|
33
|
-
/**
|
|
34
|
-
* React 的 `useEffect` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
35
|
-
*/
|
|
36
15
|
export const useEffect = react.useEffect;
|
|
37
|
-
/**
|
|
38
|
-
* React 的 `useLayoutEffect` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
39
|
-
*/
|
|
40
16
|
export const useLayoutEffect = react.useLayoutEffect;
|
|
41
|
-
/**
|
|
42
|
-
* React 的 `useMemo` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
43
|
-
*/
|
|
44
17
|
export const useMemo = react.useMemo;
|
|
45
|
-
/**
|
|
46
|
-
* React 的 `useCallback` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
47
|
-
*/
|
|
48
18
|
export const useCallback = react.useCallback;
|
|
49
|
-
/**
|
|
50
|
-
* React 的 `useRef` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
51
|
-
*/
|
|
52
19
|
export const useRef = react.useRef;
|
|
53
|
-
/**
|
|
54
|
-
* React 的 `useSyncExternalStore` 原样再导出 —— 共享包的哑组件用它;模块写 JSX 一律直接 import react(这一份不进公开入口)。
|
|
55
|
-
*/
|
|
56
20
|
export const useSyncExternalStore = react.useSyncExternalStore;
|
|
57
21
|
|
|
58
|
-
/**
|
|
59
|
-
* 借来的三个类型从 `react-types.ts` 转一手:那份是**公开面**(模块 `import type` 从根入口拿),
|
|
60
|
-
* 组件内部照旧从这里引,别在两处各写一遍名字。
|
|
61
|
-
*/
|
|
62
22
|
export type { ReactNode, CSSProperties, ChangeEvent } from './react-types.js';
|
package/src/lib/text.test.ts
CHANGED
|
@@ -16,7 +16,7 @@ describe('parseJsonLoose', () => {
|
|
|
16
16
|
expect(parseJsonLoose('[1,2]\n完成')).toEqual([1, 2]);
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
it('★ 噪音行自己带方括号时也不认错起点(真机:
|
|
19
|
+
it('★ 噪音行自己带方括号时也不认错起点(真机:acme 的调试命令先打两行带 [] 的话)', () => {
|
|
20
20
|
const stdout = [
|
|
21
21
|
'数据源 [dify_dataset] 调试成功',
|
|
22
22
|
'结构类型: 3, 字段: code, name',
|
|
@@ -38,7 +38,7 @@ describe('parseJsonLoose', () => {
|
|
|
38
38
|
]);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
it('解析不出来给 undefined,让调用方报
|
|
41
|
+
it('解析不出来给 undefined,让调用方报 demo-bad-output', () => {
|
|
42
42
|
expect(parseJsonLoose('')).toBeUndefined();
|
|
43
43
|
expect(parseJsonLoose('not json at all')).toBeUndefined();
|
|
44
44
|
expect(parseJsonLoose('[1,2')).toBeUndefined();
|
package/src/lib/ui.test.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
3
|
import {
|
|
3
4
|
cx,
|
|
@@ -15,7 +16,7 @@ const t: TimeTranslate = (key, params) => {
|
|
|
15
16
|
return `${key}:${String(params.n ?? params.t ?? '')}`;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const NOW =
|
|
19
|
+
const NOW = dayjs('2026-09-27T12:00:00.000Z').valueOf();
|
|
19
20
|
|
|
20
21
|
describe('cx', () => {
|
|
21
22
|
it('拼上真值、丢掉假值', () => {
|
|
@@ -55,7 +56,7 @@ describe('relativeTime', () => {
|
|
|
55
56
|
|
|
56
57
|
expect(old).not.toContain('time.');
|
|
57
58
|
expect(old.match(/:/g)).toHaveLength(2);
|
|
58
|
-
expect(old).toContain(String(
|
|
59
|
+
expect(old).toContain(String(dayjs(NOW).year()));
|
|
59
60
|
});
|
|
60
61
|
|
|
61
62
|
it('非法时间戳给空串而不是 NaN', () => {
|
|
@@ -125,12 +126,12 @@ describe('parseLocalTimestamp', () => {
|
|
|
125
126
|
it('按本地时区解析 Coding 的时间戳形态', () => {
|
|
126
127
|
const parsed = parseLocalTimestamp('2026-09-27 08:18:36');
|
|
127
128
|
expect(Number.isFinite(parsed)).toBe(true);
|
|
128
|
-
expect(parsed).toBe(
|
|
129
|
+
expect(parsed).toBe(dayjs('2026-09-27T08:18:36').valueOf());
|
|
129
130
|
});
|
|
130
131
|
|
|
131
132
|
it('也接受 ISO 的 T 分隔写法', () => {
|
|
132
133
|
expect(parseLocalTimestamp('2026-09-27T08:18:36')).toBe(
|
|
133
|
-
|
|
134
|
+
dayjs('2026-09-27T08:18:36').valueOf(),
|
|
134
135
|
);
|
|
135
136
|
});
|
|
136
137
|
|
|
@@ -142,7 +143,7 @@ describe('parseLocalTimestamp', () => {
|
|
|
142
143
|
|
|
143
144
|
it('容忍首尾空白', () => {
|
|
144
145
|
expect(parseLocalTimestamp(' 2026-09-27 08:18:36 ')).toBe(
|
|
145
|
-
|
|
146
|
+
dayjs('2026-09-27T08:18:36').valueOf(),
|
|
146
147
|
);
|
|
147
148
|
});
|
|
148
149
|
});
|
package/src/lib/ui.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
/**
|
|
2
3
|
* 拼类名:只留真值、用空格连接(`false` / `null` / `undefined` / 空串都丢掉)。
|
|
3
4
|
* @param parts - 若干类名或条件值。
|
|
@@ -91,14 +92,7 @@ export function relativeTime(epochMs: number, t: TimeTranslate): string {
|
|
|
91
92
|
if (diff < 60 * MINUTE) return t('time.minutes', { n: Math.floor(diff / MINUTE) });
|
|
92
93
|
if (diff < 24 * 60 * MINUTE) return t('time.hours', { n: Math.floor(diff / (60 * MINUTE)) });
|
|
93
94
|
if (diff < 7 * 24 * 60 * MINUTE) return t('time.days', { n: Math.floor(diff / (24 * 60 * MINUTE)) });
|
|
94
|
-
return
|
|
95
|
-
year: 'numeric',
|
|
96
|
-
month: 'numeric',
|
|
97
|
-
day: 'numeric',
|
|
98
|
-
hour: '2-digit',
|
|
99
|
-
minute: '2-digit',
|
|
100
|
-
second: '2-digit',
|
|
101
|
-
});
|
|
95
|
+
return dayjs(epochMs).format('YYYY/M/D HH:mm:ss');
|
|
102
96
|
}
|
|
103
97
|
|
|
104
98
|
/**
|
|
@@ -122,5 +116,5 @@ const LOCAL_TIMESTAMP = /^(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/;
|
|
|
122
116
|
export function parseLocalTimestamp(text: string | null | undefined): number {
|
|
123
117
|
const raw = String(text ?? '').trim();
|
|
124
118
|
if (!LOCAL_TIMESTAMP.test(raw)) return Number.NaN;
|
|
125
|
-
return
|
|
119
|
+
return dayjs(raw.replace(' ', 'T')).valueOf();
|
|
126
120
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { CallOverrides, DataReader, DataRequest, RecipeCalls, RecipeResults, RequestRecipe } from '../contract/data.js';
|
|
2
|
+
|
|
3
|
+
export interface RecipeCall {
|
|
4
|
+
readonly kind: 'request' | 'submit' | 'many';
|
|
5
|
+
readonly recipe: RequestRecipe;
|
|
6
|
+
readonly overrides?: CallOverrides | undefined;
|
|
7
|
+
readonly calls?: RecipeCalls | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const NO_DATA = {
|
|
11
|
+
ok: false as const,
|
|
12
|
+
error: { code: 'invalid-request' as const, message: '测试没有注入 DataReader' },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function filled(names: readonly string[], value: unknown): RecipeResults {
|
|
16
|
+
const out: Record<string, unknown> = {};
|
|
17
|
+
for (const name of names) out[name] = value;
|
|
18
|
+
return out as RecipeResults;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createNoopDataReader(): DataReader {
|
|
22
|
+
return {
|
|
23
|
+
read: async () => NO_DATA,
|
|
24
|
+
request: async () => NO_DATA,
|
|
25
|
+
requestMany: async <T = unknown>(_recipe: RequestRecipe, calls: RecipeCalls): Promise<RecipeResults<T>> =>
|
|
26
|
+
filled(Object.keys(calls), NO_DATA) as RecipeResults<T>,
|
|
27
|
+
submit: async () => NO_DATA,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createFakeDataReader(
|
|
32
|
+
reply: unknown | ((request: DataRequest, index: number) => unknown) = { ok: true, data: null },
|
|
33
|
+
recipeReply: unknown | ((call: RecipeCall, index: number) => unknown) = { ok: true, data: null },
|
|
34
|
+
): DataReader & {
|
|
35
|
+
readonly requests: readonly DataRequest[];
|
|
36
|
+
readonly calls: readonly RecipeCall[];
|
|
37
|
+
} {
|
|
38
|
+
const requests: DataRequest[] = [];
|
|
39
|
+
const calls: RecipeCall[] = [];
|
|
40
|
+
const answer = (call: RecipeCall): unknown =>
|
|
41
|
+
typeof recipeReply === 'function' ? recipeReply(call, calls.length - 1) : recipeReply;
|
|
42
|
+
const reader = {
|
|
43
|
+
async read(request: DataRequest): Promise<unknown> {
|
|
44
|
+
requests.push(request);
|
|
45
|
+
return typeof reply === 'function' ? reply(request, requests.length - 1) : reply;
|
|
46
|
+
},
|
|
47
|
+
async request(recipe: RequestRecipe, overrides?: CallOverrides): Promise<unknown> {
|
|
48
|
+
calls.push({ kind: 'request', recipe, overrides });
|
|
49
|
+
return answer(calls[calls.length - 1] as RecipeCall);
|
|
50
|
+
},
|
|
51
|
+
async requestMany(recipe: RequestRecipe, plan: RecipeCalls): Promise<RecipeResults> {
|
|
52
|
+
calls.push({ kind: 'many', recipe, calls: plan });
|
|
53
|
+
const answered = answer(calls[calls.length - 1] as RecipeCall);
|
|
54
|
+
return typeof answered === 'object' && answered !== null && !('ok' in answered)
|
|
55
|
+
? (answered as RecipeResults)
|
|
56
|
+
: filled(Object.keys(plan), answered);
|
|
57
|
+
},
|
|
58
|
+
async submit(recipe: RequestRecipe, overrides?: CallOverrides): Promise<unknown> {
|
|
59
|
+
calls.push({ kind: 'submit', recipe, overrides });
|
|
60
|
+
return answer(calls[calls.length - 1] as RecipeCall);
|
|
61
|
+
},
|
|
62
|
+
} as unknown as DataReader;
|
|
63
|
+
return Object.assign(reader, { requests, calls });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const fakeDataReader = createFakeDataReader;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import type { UnitManifest } from '../
|
|
4
|
-
import { readDeclaration } from '../
|
|
3
|
+
import type { UnitManifest } from '../contract/unit.js';
|
|
4
|
+
import { readDeclaration } from '../contract/unit-declaration.js';
|
|
5
5
|
|
|
6
6
|
export function declarationOfPackage(pkg: string, packageJson: URL | string): UnitManifest {
|
|
7
7
|
const at = typeof packageJson === 'string' ? packageJson : fileURLToPath(packageJson);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
2
|
import type { DshShell } from '../api/dsh.js';
|
|
3
|
-
import type { Opencli, OpencliResult } from '../host/opencli.js';
|
|
4
3
|
|
|
5
4
|
export interface ShellCall {
|
|
6
5
|
command: string;
|
|
@@ -66,43 +65,6 @@ export function createFakeShell(replies: ShellReply[] | ((call: ShellCall, index
|
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
export interface OpencliCall {
|
|
70
|
-
args: readonly string[];
|
|
71
|
-
key?: string;
|
|
72
|
-
workdir?: string;
|
|
73
|
-
session?: string;
|
|
74
|
-
refresh?: boolean;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function createFakeOpencli(
|
|
78
|
-
replies: Array<unknown | Error> | ((call: OpencliCall, index: number) => unknown | Error) = [],
|
|
79
|
-
) {
|
|
80
|
-
const calls: OpencliCall[] = [];
|
|
81
|
-
|
|
82
|
-
const opencli: Opencli = {
|
|
83
|
-
async json(args, options = {}) {
|
|
84
|
-
const call: OpencliCall = {
|
|
85
|
-
args,
|
|
86
|
-
...(options.key === undefined ? {} : { key: options.key }),
|
|
87
|
-
...(options.workdir === undefined ? {} : { workdir: options.workdir }),
|
|
88
|
-
...(options.session === undefined ? {} : { session: options.session }),
|
|
89
|
-
};
|
|
90
|
-
calls.push(call);
|
|
91
|
-
const index = calls.length - 1;
|
|
92
|
-
const reply =
|
|
93
|
-
typeof replies === 'function' ? replies(call, index) : (replies[index] ?? []);
|
|
94
|
-
|
|
95
|
-
if (reply instanceof Error) throw reply;
|
|
96
|
-
return { value: reply, at: Date.now() } satisfies OpencliResult;
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
opencli,
|
|
102
|
-
calls,
|
|
103
|
-
keys: () => calls.map((call) => call.key),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
68
|
|
|
107
69
|
export function createFakeLogger() {
|
|
108
70
|
const warnings: string[] = [];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BinNeed,
|
|
3
|
+
EnvNeed,
|
|
4
|
+
ExtensionNeed,
|
|
5
|
+
LibNeed,
|
|
6
|
+
Need,
|
|
7
|
+
NeedKind,
|
|
8
|
+
SupplySource,
|
|
9
|
+
} from '../contract/needs.js';
|
|
10
|
+
import type { NeedState } from '../contract/unit-capability.js';
|
|
11
|
+
import type { UnitCapability } from '../contract/unit-capability.js';
|
|
12
|
+
import type { UnitManifest } from '../contract/unit.js';
|
|
13
|
+
|
|
14
|
+
export const fakeNpmSource: SupplySource = {
|
|
15
|
+
kind: 'npm',
|
|
16
|
+
registryEnv: 'WB_TEST_REGISTRY',
|
|
17
|
+
registryDefault: 'https://registry.invalid/',
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function extensionNeedOf(name: string, extra: Partial<ExtensionNeed> = {}): ExtensionNeed {
|
|
21
|
+
return {
|
|
22
|
+
kind: 'extension',
|
|
23
|
+
runtime: 'opencli',
|
|
24
|
+
name,
|
|
25
|
+
commands: [`${name}-read`],
|
|
26
|
+
purpose: '测试',
|
|
27
|
+
...extra,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function libNeedOf(name: string, extra: Partial<LibNeed> = {}): LibNeed {
|
|
32
|
+
return { kind: 'lib', name, purpose: '测试', ...extra };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function binNeedOf(name: string, extra: Partial<BinNeed> = {}): BinNeed {
|
|
36
|
+
return { kind: 'bin', name, purpose: '测试', ...extra };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function envNeedOf(name: string, extra: Partial<EnvNeed> = {}): EnvNeed {
|
|
40
|
+
return { kind: 'env', name, purpose: '测试', ...extra };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function manifestOf(
|
|
44
|
+
options: {
|
|
45
|
+
readonly id?: string | undefined;
|
|
46
|
+
readonly needs?: readonly Need[] | undefined;
|
|
47
|
+
readonly card?: UnitManifest['card'];
|
|
48
|
+
} = {},
|
|
49
|
+
): UnitManifest {
|
|
50
|
+
return {
|
|
51
|
+
id: options.id ?? 'fixture',
|
|
52
|
+
card: options.card === undefined ? { titleKey: `${options.id ?? 'fixture'}.mine`, order: 10 } : options.card,
|
|
53
|
+
tools: [],
|
|
54
|
+
host: { inject: [] },
|
|
55
|
+
...(options.needs === undefined ? {} : { needs: options.needs }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function needStateOf(
|
|
60
|
+
need: Need,
|
|
61
|
+
status: NeedState['status'] = 'ok',
|
|
62
|
+
extra: Partial<NeedState> = {},
|
|
63
|
+
): NeedState {
|
|
64
|
+
return {
|
|
65
|
+
id: need.id ?? `${need.kind}:${need.name}`,
|
|
66
|
+
kind: need.kind as NeedKind,
|
|
67
|
+
name: need.name,
|
|
68
|
+
status,
|
|
69
|
+
detail: `测试:${need.name}`,
|
|
70
|
+
...extra,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function capabilityOf(
|
|
75
|
+
unit: string,
|
|
76
|
+
needs: readonly NeedState[] = [],
|
|
77
|
+
extra: Partial<UnitCapability> = {},
|
|
78
|
+
): UnitCapability {
|
|
79
|
+
return { unit, status: needs.some((need) => need.status !== 'ok') ? 'missing' : 'ok', needs, ...extra };
|
|
80
|
+
}
|
package/src/testing.ts
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { UnitEnvNeeds, UnitHostNeeds, UnitManifest } from './unit.js';
|
|
2
|
-
/**
|
|
3
|
-
* 声明协议当前版本;模块清单的 dsh.workbench.apiVersion 要写这个整数。
|
|
4
|
-
*/
|
|
5
|
-
export declare const WORKBENCH_API_VERSION = 1;
|
|
6
|
-
/**
|
|
7
|
-
* 外壳愿意认的协议版本;不在表里的模块当场被拒,不猜语义。
|
|
8
|
-
*/
|
|
9
|
-
export declare const SUPPORTED_API_VERSIONS: readonly number[];
|
|
10
|
-
/**
|
|
11
|
-
* 清单里那半张卡片声明:文案键加排序位;卡片默认显不显示不在这里(那是运行期面板配置的事)。
|
|
12
|
-
*/
|
|
13
|
-
export interface UnitCardDeclaration {
|
|
14
|
-
readonly titleKey: string;
|
|
15
|
-
readonly order: number;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 清单里的一条工具声明:进 dsh 工具表的全名、会不会写,以及生成物里的键名。
|
|
19
|
-
*/
|
|
20
|
-
export interface UnitToolDeclaration {
|
|
21
|
-
readonly name: string;
|
|
22
|
-
readonly writes: boolean;
|
|
23
|
-
readonly key?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* 模块清单里 dsh.workbench 那一段的完整形状(协议版本、单元 id、卡片、工具、宿主与环境需要)。
|
|
27
|
-
*/
|
|
28
|
-
export interface UnitDeclaration {
|
|
29
|
-
readonly apiVersion: number;
|
|
30
|
-
readonly unit: string;
|
|
31
|
-
readonly card: UnitCardDeclaration | null;
|
|
32
|
-
readonly tools: readonly UnitToolDeclaration[];
|
|
33
|
-
readonly host: UnitHostNeeds;
|
|
34
|
-
readonly env?: UnitEnvNeeds;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* 协议认得的全部键;写了别的键不会被采纳(外壳静默忽略),所以字段名拼错不会有提示。
|
|
38
|
-
*/
|
|
39
|
-
export declare const DECLARATION_KEYS: readonly string[];
|
|
40
|
-
/**
|
|
41
|
-
* 协议要求必写的键;env 不在其中(没有环境需要就不写)。
|
|
42
|
-
*/
|
|
43
|
-
export declare const DECLARATION_REQUIRED_KEYS: readonly string[];
|
|
44
|
-
/**
|
|
45
|
-
* 查清单里 dsh.workbench 那一段的形状,回一串给人看的问题(中文,带字段路径)。
|
|
46
|
-
* @param subject 报错时用的主语,一般是包名。
|
|
47
|
-
* @param raw 清单里那段原始值,可能什么都不是。
|
|
48
|
-
* @returns 空数组表示形状过得去;版本不对就当场返回(后面的字段无从判起)。
|
|
49
|
-
*/
|
|
50
|
-
export declare function declarationProblemsOf(subject: string, raw: unknown): readonly string[];
|
|
51
|
-
/**
|
|
52
|
-
* 读一份清单的结果:要么带着规整过的声明与 manifest,要么只带一串问题。
|
|
53
|
-
*/
|
|
54
|
-
export interface DeclarationRead {
|
|
55
|
-
readonly declaration?: UnitDeclaration;
|
|
56
|
-
readonly manifest?: UnitManifest;
|
|
57
|
-
readonly problems: readonly string[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* 读一份清单:先查形状,过了再把声明规整成 manifest。
|
|
61
|
-
* @param subject 报错时用的主语。
|
|
62
|
-
* @param raw 清单里 dsh.workbench 那段原始值。
|
|
63
|
-
* @returns 有问题时只有 problems;没问题时 declaration 与 manifest 都给,manifest 里的字符串已 trim。
|
|
64
|
-
*/
|
|
65
|
-
export declare function readDeclaration(subject: string, raw: unknown): DeclarationRead;
|
package/dist/api/unit.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 一张卡片在清单里的静态声明(文案键加排序位);默认显不显示由运行期面板配置定。
|
|
3
|
-
*/
|
|
4
|
-
export interface UnitCard {
|
|
5
|
-
readonly titleKey: string;
|
|
6
|
-
readonly order: number;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* 一条工具在清单里的样子:全名加会不会写;审批按 writes 认领。
|
|
10
|
-
*/
|
|
11
|
-
export interface UnitTool {
|
|
12
|
-
readonly name: string;
|
|
13
|
-
readonly writes: boolean;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 模块要外壳的哪些服务:inject 缺一个就挂不上,optional 缺了照挂。
|
|
17
|
-
*/
|
|
18
|
-
export interface UnitHostNeeds {
|
|
19
|
-
readonly inject: readonly string[];
|
|
20
|
-
readonly optional?: readonly string[];
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* 一个 opencli 插件的来源三选一(git / 本地 / npm);npm 那支的安装源先看 registryEnv 那个环境变量,没设才用 registryDefault。
|
|
24
|
-
*/
|
|
25
|
-
export type PluginSource = {
|
|
26
|
-
readonly kind: 'git';
|
|
27
|
-
readonly url: string;
|
|
28
|
-
} | {
|
|
29
|
-
readonly kind: 'local';
|
|
30
|
-
readonly env: string;
|
|
31
|
-
} | {
|
|
32
|
-
readonly kind: 'npm';
|
|
33
|
-
readonly package: string;
|
|
34
|
-
readonly registryEnv: string;
|
|
35
|
-
readonly registryDefault?: string;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* 模块要的一个 opencli 插件:名字、它得提供的命令,以及装它的来源(没写就是不代装)。
|
|
39
|
-
*/
|
|
40
|
-
export interface UnitPluginNeed {
|
|
41
|
-
readonly name: string;
|
|
42
|
-
readonly commands?: readonly string[];
|
|
43
|
-
readonly installSource?: PluginSource;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 模块要的一个共用库:名字、期望范围与它为什么要这个版本(purpose 会进申报文案)。
|
|
47
|
-
*/
|
|
48
|
-
export interface UnitLibNeed {
|
|
49
|
-
readonly name: string;
|
|
50
|
-
readonly version?: string | undefined;
|
|
51
|
-
readonly registryEnv: string;
|
|
52
|
-
readonly registryDefault: string;
|
|
53
|
-
readonly purpose: string;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* 模块的整份环境需要:一条自检命令,加上插件与共用库两张表。
|
|
57
|
-
*/
|
|
58
|
-
export interface UnitEnvNeeds {
|
|
59
|
-
readonly command?: string;
|
|
60
|
-
readonly plugins?: readonly UnitPluginNeed[];
|
|
61
|
-
readonly libs?: readonly UnitLibNeed[];
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* 已装插件与源上最新版那一对,用来判该不该提示升级;latest 缺省表示还没查到。
|
|
65
|
-
*/
|
|
66
|
-
export interface PluginRelease {
|
|
67
|
-
readonly installed: string;
|
|
68
|
-
readonly latest?: string;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* 装配期用的模块清单:单元 id、卡片、工具与宿主 / 环境需要,比声明少一层协议包装。
|
|
72
|
-
*/
|
|
73
|
-
export interface UnitManifest {
|
|
74
|
-
readonly id: string;
|
|
75
|
-
readonly card: UnitCard | null;
|
|
76
|
-
readonly tools: readonly UnitTool[];
|
|
77
|
-
readonly host: UnitHostNeeds;
|
|
78
|
-
readonly env?: UnitEnvNeeds;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* 判这个模块要不要往外装东西。
|
|
82
|
-
* @param manifest 模块清单。
|
|
83
|
-
* @returns 插件与共用库两张表都空时给 false。
|
|
84
|
-
*/
|
|
85
|
-
export declare function hasEnvSupply(manifest: UnitManifest): boolean;
|
package/dist/api/unit.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { PluginRelease } from '../api/unit.js';
|
|
2
|
-
/**
|
|
3
|
-
* 供给动作的那几档(装 / 升 / 卸,模块、共用依赖与插件各一套);写口按它分派。
|
|
4
|
-
*/
|
|
5
|
-
export type ProvisionAction = 'install' | 'update' | 'uninstall' | 'update-dependency' | 'install-bundle' | 'update-bundle' | 'remove-bundle' | 'cancel-install' | 'update-plugin' | 'uninstall-plugin' | 'update-workbench';
|
|
6
|
-
/**
|
|
7
|
-
* 宿主报的一个 opencli 插件此刻的状态:装没装、缺哪些命令、该不该升,以及怎么升。
|
|
8
|
-
*/
|
|
9
|
-
export interface PluginStatePayload {
|
|
10
|
-
readonly name: string;
|
|
11
|
-
readonly status: 'ok' | 'outdated' | 'missing';
|
|
12
|
-
readonly missing: readonly string[];
|
|
13
|
-
readonly install?: 'ready' | 'not-declared' | 'env-missing' | 'malformed';
|
|
14
|
-
readonly command?: string;
|
|
15
|
-
readonly release?: PluginRelease;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 宿主对「这个单元现在能不能用」的那份读数:状态、缺的命令与插件、修复动作和供给细节。
|
|
19
|
-
*/
|
|
20
|
-
export interface CapabilityPayload {
|
|
21
|
-
readonly unit: string;
|
|
22
|
-
readonly status: 'ok' | 'failed' | 'missing-commands' | 'missing-plugin' | 'unchecked';
|
|
23
|
-
readonly plugin?: string;
|
|
24
|
-
readonly required: readonly string[];
|
|
25
|
-
readonly missing: readonly string[];
|
|
26
|
-
readonly detail: string;
|
|
27
|
-
readonly command?: string;
|
|
28
|
-
readonly fix?: 'install' | 'update';
|
|
29
|
-
readonly plugins?: readonly PluginStatePayload[];
|
|
30
|
-
readonly released?: boolean;
|
|
31
|
-
readonly install?: 'ready' | 'not-declared' | 'env-missing' | 'malformed';
|
|
32
|
-
readonly libs?: readonly LibStatePayload[];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 宿主报的一个共用库此刻的状态(装没装、版本对不对)与它为什么要这个版本。
|
|
36
|
-
*/
|
|
37
|
-
export interface LibStatePayload {
|
|
38
|
-
readonly name: string;
|
|
39
|
-
readonly purpose: string;
|
|
40
|
-
readonly status: 'ok' | 'outdated' | 'missing' | 'unsatisfied';
|
|
41
|
-
readonly installed?: string;
|
|
42
|
-
readonly latest?: string;
|
|
43
|
-
readonly command?: string;
|
|
44
|
-
}
|