@jingyi0605/codingns 0.6.0 → 0.6.5
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/bin/codingns.mjs +240 -2
- package/dist/public/assets/AdaptiveButlerPage-CfsUVZKl.js +3 -0
- package/dist/public/assets/{App-BZvapsi8.js → App-B9HcTkMT.js} +3 -3
- package/dist/public/assets/{BootstrapPage-gHSoa4JN.js → BootstrapPage-BgLdZEKQ.js} +1 -1
- package/dist/public/assets/ConversationPage-Cj8go7L0.js +4 -0
- package/dist/public/assets/{DesktopDetachPreviewPage-4eMRxiBW.js → DesktopDetachPreviewPage-YCBnyC58.js} +1 -1
- package/dist/public/assets/DesktopWindowPage-CrvndE23.js +2 -0
- package/dist/public/assets/FileContextPanel-CdC7GGw5.js +1 -0
- package/dist/public/assets/GitSidebar-z2SBinQh.js +6 -0
- package/dist/public/assets/MobileCreateSessionSheet-Cb2HM-y3.js +1 -0
- package/dist/public/assets/{MobileTopHeaderFrame-Bwv8Ovm_.js → MobileTopHeaderFrame-etF2HKlm.js} +1 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-CuGJ31kb.js +1 -0
- package/dist/public/assets/{RelayConnectEntryPage-D_4YL-YH.js → RelayConnectEntryPage-BB6DbGtP.js} +1 -1
- package/dist/public/assets/{ServerSettingsModal-CMSm3BZU.js → ServerSettingsModal-Bl1sacZg.js} +1 -1
- package/dist/public/assets/SessionIndexPage-NbF9gJnp.js +1 -0
- package/dist/public/assets/SettingsPage-DGsmQpLv.js +1 -0
- package/dist/public/assets/TerminalManagerPanel-BOm8Hi_v.js +1 -0
- package/dist/public/assets/{TerminalPage-DaooFaJ4.js → TerminalPage-B5JNFU6w.js} +19 -19
- package/dist/public/assets/TerminalRuntimeFallbackModal-CM3LRKOJ.js +1 -0
- package/dist/public/assets/{ToolFilesPage-CGxBvYG0.js → ToolFilesPage-GSqKQsj_.js} +1 -1
- package/dist/public/assets/ToolGitPage-BVFWMMQp.js +1 -0
- package/dist/public/assets/ToolProcessesPage-DZ456fYz.js +1 -0
- package/dist/public/assets/ToolsHomePage-DsJp0y8A.js +1 -0
- package/dist/public/assets/WorkbenchLandingPage-DyPei0e-.js +1 -0
- package/dist/public/assets/WorkbenchLayout-DlbgBT3n.js +4 -0
- package/dist/public/assets/WorkbenchModal-LNfB69qx.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-BsxumYx5.js +1 -0
- package/dist/public/assets/WorkbenchShellRoute-DhQo_0vu.css +1 -0
- package/dist/public/assets/WorkspaceDebugDetailPage-CaXj5zVI.js +1 -0
- package/dist/public/assets/WorkspaceDetailPage-DOexuuaw.js +1 -0
- package/dist/public/assets/WorkspaceHomePage-DkCHNjKD.js +1 -0
- package/dist/public/assets/{client-runtime-manager-BZpL17fc.js → client-runtime-manager-6OoYHXGd.js} +1 -1
- package/dist/public/assets/{file-tree-icon-Db5LXC8h.js → file-tree-icon-9pt1OStn.js} +1 -1
- package/dist/public/assets/index-BwlbvwaA.css +1 -0
- package/dist/public/assets/index-DSw-TkQL.js +42 -0
- package/dist/public/assets/legna-code-6TqgZ4Ls.png +0 -0
- package/dist/public/assets/{login-direct-candidate-resolver-1mxe_Oh8.js → login-direct-candidate-resolver-CLlYtBRq.js} +1 -1
- package/dist/public/assets/model-switch-api-C-l8-E1S.js +1 -0
- package/dist/public/assets/{preferences-service-DWnzl5a0.js → preferences-service-BCcfYP_d.js} +1 -1
- package/dist/public/assets/{relay-entry-C5_Iay0I.js → relay-entry-BmLkMKuq.js} +1 -1
- package/dist/public/assets/session-runtime-machine-DgtvREca.js +21 -0
- package/dist/public/assets/{terminal-runtime-meta-cdtWVfCm.js → terminal-runtime-meta-0h-75uRy.js} +1 -1
- package/dist/public/assets/useRegisteredDebugTemplates-rBVmAqh3.js +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/env.d.ts +2 -0
- package/dist/server/config/env.js +7 -0
- package/dist/server/config/env.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +4 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +12 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/butler/butler-control-session-service.d.ts +4 -1
- package/dist/server/modules/butler/butler-control-session-service.js +17 -1
- package/dist/server/modules/butler/butler-control-session-service.js.map +1 -1
- package/dist/server/modules/butler/butler-profile-service.d.ts +3 -1
- package/dist/server/modules/butler/butler-profile-service.js +16 -4
- package/dist/server/modules/butler/butler-profile-service.js.map +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.d.ts +7 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js +17 -0
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/opencli/opencli-bridge-skill-service.d.ts +12 -0
- package/dist/server/modules/opencli/opencli-bridge-skill-service.js +124 -0
- package/dist/server/modules/opencli/opencli-bridge-skill-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-catalog-service.d.ts +50 -0
- package/dist/server/modules/opencli/opencli-catalog-service.js +345 -0
- package/dist/server/modules/opencli/opencli-catalog-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-controller.d.ts +13 -0
- package/dist/server/modules/opencli/opencli-controller.js +30 -0
- package/dist/server/modules/opencli/opencli-controller.js.map +1 -0
- package/dist/server/modules/opencli/opencli-health-service.d.ts +28 -0
- package/dist/server/modules/opencli/opencli-health-service.js +106 -0
- package/dist/server/modules/opencli/opencli-health-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-install-discovery.d.ts +23 -0
- package/dist/server/modules/opencli/opencli-install-discovery.js +130 -0
- package/dist/server/modules/opencli/opencli-install-discovery.js.map +1 -0
- package/dist/server/modules/opencli/opencli-management-service.d.ts +59 -0
- package/dist/server/modules/opencli/opencli-management-service.js +152 -0
- package/dist/server/modules/opencli/opencli-management-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-builder.d.ts +11 -0
- package/dist/server/modules/opencli/opencli-runtime-builder.js +214 -0
- package/dist/server/modules/opencli/opencli-runtime-builder.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-layout.d.ts +3 -0
- package/dist/server/modules/opencli/opencli-runtime-layout.js +11 -0
- package/dist/server/modules/opencli/opencli-runtime-layout.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-profile-service.d.ts +29 -0
- package/dist/server/modules/opencli/opencli-runtime-profile-service.js +104 -0
- package/dist/server/modules/opencli/opencli-runtime-profile-service.js.map +1 -0
- package/dist/server/modules/opencli/opencli-runtime-resolver.d.ts +29 -0
- package/dist/server/modules/opencli/opencli-runtime-resolver.js +110 -0
- package/dist/server/modules/opencli/opencli-runtime-resolver.js.map +1 -0
- package/dist/server/modules/opencli/opencli-session-prompt-service.d.ts +11 -0
- package/dist/server/modules/opencli/opencli-session-prompt-service.js +66 -0
- package/dist/server/modules/opencli/opencli-session-prompt-service.js.map +1 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.d.ts +4 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js +7 -0
- package/dist/server/modules/parallel-sessions/parallel-session-controller.js.map +1 -1
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.d.ts +6 -1
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js +36 -2
- package/dist/server/modules/parallel-sessions/parallel-session-group-service.js.map +1 -1
- package/dist/server/modules/provider/opencode-model-options.d.ts +1 -0
- package/dist/server/modules/provider/opencode-model-options.js +54 -12
- package/dist/server/modules/provider/opencode-model-options.js.map +1 -1
- package/dist/server/modules/provider/provider-catalog-service.d.ts +46 -0
- package/dist/server/modules/provider/provider-catalog-service.js +249 -0
- package/dist/server/modules/provider/provider-catalog-service.js.map +1 -0
- package/dist/server/modules/provider/provider-controller.d.ts +20 -2
- package/dist/server/modules/provider/provider-controller.js +65 -5
- package/dist/server/modules/provider/provider-controller.js.map +1 -1
- package/dist/server/modules/provider/provider-disabled.d.ts +8 -0
- package/dist/server/modules/provider/provider-disabled.js +45 -0
- package/dist/server/modules/provider/provider-disabled.js.map +1 -0
- package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +3 -0
- package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js +4 -4
- package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.d.ts +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.js +17 -9
- package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -1
- package/dist/server/modules/sessions/claude-compatible-provider-registry.d.ts +16 -0
- package/dist/server/modules/sessions/claude-compatible-provider-registry.js +91 -0
- package/dist/server/modules/sessions/claude-compatible-provider-registry.js.map +1 -0
- package/dist/server/modules/sessions/claude-runtime-helper-client.d.ts +1 -0
- package/dist/server/modules/sessions/claude-runtime-helper-client.js +14 -0
- package/dist/server/modules/sessions/claude-runtime-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/codex-app-server-helper-client.d.ts +1 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js +10 -0
- package/dist/server/modules/sessions/codex-app-server-helper-client.js.map +1 -1
- package/dist/server/modules/sessions/provider-session-delete-cli.js +2 -0
- package/dist/server/modules/sessions/provider-session-delete-cli.js.map +1 -1
- package/dist/server/modules/sessions/session-controller.d.ts +7 -0
- package/dist/server/modules/sessions/session-controller.js +22 -0
- package/dist/server/modules/sessions/session-controller.js.map +1 -1
- package/dist/server/modules/sessions/session-history-service.d.ts +18 -2
- package/dist/server/modules/sessions/session-history-service.js +330 -29
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-router-service.js +9 -4
- package/dist/server/modules/sessions/session-live-runtime-router-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +22 -5
- package/dist/server/modules/sessions/session-live-runtime-service.js +350 -122
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/sessions/session-message-attachment-service.js +2 -2
- package/dist/server/modules/sessions/session-message-attachment-service.js.map +1 -1
- package/dist/server/modules/sessions/session-permission-request-service.d.ts +5 -2
- package/dist/server/modules/sessions/session-permission-request-service.js +26 -27
- package/dist/server/modules/sessions/session-permission-request-service.js.map +1 -1
- package/dist/server/modules/sessions/session-provider-config-service.d.ts +82 -0
- package/dist/server/modules/sessions/session-provider-config-service.js +925 -0
- package/dist/server/modules/sessions/session-provider-config-service.js.map +1 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.d.ts +2 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js +42 -0
- package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
- package/dist/server/modules/skills/skill-manager-service.d.ts +5 -0
- package/dist/server/modules/skills/skill-manager-service.js +26 -0
- package/dist/server/modules/skills/skill-manager-service.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +1 -0
- package/dist/server/modules/tasks/task-helper-process-handlers.js +1 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
- package/dist/server/routes/opencli.d.ts +3 -0
- package/dist/server/routes/opencli.js +7 -0
- package/dist/server/routes/opencli.js.map +1 -0
- package/dist/server/routes/providers.js +4 -2
- package/dist/server/routes/providers.js.map +1 -1
- package/dist/server/server/create-server.d.ts +8 -0
- package/dist/server/server/create-server.js +48 -12
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/storage/repositories/opencli-catalog-entry-repository.d.ts +9 -0
- package/dist/server/storage/repositories/opencli-catalog-entry-repository.js +85 -0
- package/dist/server/storage/repositories/opencli-catalog-entry-repository.js.map +1 -0
- package/dist/server/storage/repositories/opencli-provider-repository.d.ts +8 -0
- package/dist/server/storage/repositories/opencli-provider-repository.js +88 -0
- package/dist/server/storage/repositories/opencli-provider-repository.js.map +1 -0
- package/dist/server/storage/repositories/opencli-runtime-profile-repository.d.ts +11 -0
- package/dist/server/storage/repositories/opencli-runtime-profile-repository.js +127 -0
- package/dist/server/storage/repositories/opencli-runtime-profile-repository.js.map +1 -0
- package/dist/server/storage/repositories/provider-control-repository.d.ts +9 -0
- package/dist/server/storage/repositories/provider-control-repository.js +51 -0
- package/dist/server/storage/repositories/provider-control-repository.js.map +1 -0
- package/dist/server/storage/repositories/session-binding-repository.js +44 -5
- package/dist/server/storage/repositories/session-binding-repository.js.map +1 -1
- package/dist/server/storage/repositories/session-index-repository.js +6 -0
- package/dist/server/storage/repositories/session-index-repository.js.map +1 -1
- package/dist/server/storage/sqlite/client.js +72 -0
- package/dist/server/storage/sqlite/client.js.map +1 -1
- package/dist/server/storage/sqlite/schema.sql +71 -0
- package/dist/server/types/domain.d.ts +56 -0
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +5 -2
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +40 -8
- package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/index.d.ts +2 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js +2 -0
- package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +10 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +110 -35
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +131 -39
- package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +8 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +19 -6
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +1 -0
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +13 -8
- package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +5 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +103 -51
- package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +2 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +41 -21
- package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +32 -8
- package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +15 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +167 -10
- package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -1
- package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +2 -0
- package/node_modules/@codingns/session-sync-core/dist/types.d.ts +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.js +1 -1
- package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/public/assets/AdaptiveButlerPage-uFwDdN-F.js +0 -3
- package/dist/public/assets/ConversationPage-z3sXtKZ7.js +0 -4
- package/dist/public/assets/DesktopWindowPage-CZcoGApB.js +0 -2
- package/dist/public/assets/FileContextPanel-C3qex8bb.js +0 -1
- package/dist/public/assets/GitSidebar-BK6H16XU.js +0 -6
- package/dist/public/assets/MobileCreateSessionSheet-BYfbvK8o.js +0 -1
- package/dist/public/assets/MobileSheet-Ckug8hTb.js +0 -1
- package/dist/public/assets/MobileWorkspaceSwitcherHeader-RqWrBdn2.js +0 -1
- package/dist/public/assets/SessionIndexPage-DuK10DL5.js +0 -1
- package/dist/public/assets/SettingsPage-fyD-xaHL.js +0 -1
- package/dist/public/assets/TerminalManagerPanel-CCLr1Ypk.js +0 -1
- package/dist/public/assets/TerminalRuntimeFallbackModal-aUzjEBwP.js +0 -1
- package/dist/public/assets/ToolGitPage-C264yjS9.js +0 -1
- package/dist/public/assets/ToolProcessesPage-BOP4A1cb.js +0 -1
- package/dist/public/assets/ToolsHomePage-CQxGiKQA.js +0 -1
- package/dist/public/assets/WorkbenchLandingPage-CvAY68ca.js +0 -1
- package/dist/public/assets/WorkbenchLayout-DGm8Tc5M.js +0 -3
- package/dist/public/assets/WorkbenchModal-0tPIIhca.js +0 -1
- package/dist/public/assets/WorkbenchShellRoute-BF0nHWOk.css +0 -1
- package/dist/public/assets/WorkbenchShellRoute-DBBOsJo9.js +0 -1
- package/dist/public/assets/WorkspaceDebugDetailPage-CDerFYd2.js +0 -1
- package/dist/public/assets/WorkspaceDetailPage-BlJc1CHE.js +0 -1
- package/dist/public/assets/WorkspaceHomePage-BUsKJ3lv.js +0 -1
- package/dist/public/assets/default-session-permission-mode-DT4SGiwp.js +0 -1
- package/dist/public/assets/index-BZLcEHW3.js +0 -42
- package/dist/public/assets/index-BbspQPC2.css +0 -1
- package/dist/public/assets/session-runtime-machine-DdLeDqQr.js +0 -17
- package/dist/public/assets/useRegisteredDebugTemplates-oFAQNIqh.js +0 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
const OPENCLI_PACKAGE_NAME = "@jackwener/opencli";
|
|
4
|
+
export class OpenCliInstallDiscovery {
|
|
5
|
+
env;
|
|
6
|
+
catalogRootCandidates;
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.env = options.env ?? process.env;
|
|
9
|
+
this.catalogRootCandidates = options.catalogRootCandidates ?? [];
|
|
10
|
+
}
|
|
11
|
+
discover() {
|
|
12
|
+
const binaryPath = resolveExecutableFromPath("opencli", this.env.PATH ?? null);
|
|
13
|
+
if (binaryPath) {
|
|
14
|
+
const installRoot = findOpenCliRootForExecutable(binaryPath);
|
|
15
|
+
const manifestPath = installRoot ? path.join(installRoot, "cli-manifest.json") : null;
|
|
16
|
+
return {
|
|
17
|
+
installState: "installed",
|
|
18
|
+
binaryPath,
|
|
19
|
+
installPath: installRoot,
|
|
20
|
+
version: installRoot ? readPackageVersion(installRoot) : null,
|
|
21
|
+
manifestSource: installRoot && manifestPath && fs.existsSync(manifestPath)
|
|
22
|
+
? {
|
|
23
|
+
kind: "manifest",
|
|
24
|
+
rootPath: installRoot,
|
|
25
|
+
manifestPath
|
|
26
|
+
}
|
|
27
|
+
: null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
for (const candidateRoot of this.catalogRootCandidates) {
|
|
31
|
+
const resolvedRoot = path.resolve(candidateRoot);
|
|
32
|
+
const manifestPath = path.join(resolvedRoot, "cli-manifest.json");
|
|
33
|
+
if (!fs.existsSync(manifestPath)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
installState: "not_installed",
|
|
38
|
+
binaryPath: null,
|
|
39
|
+
installPath: null,
|
|
40
|
+
version: null,
|
|
41
|
+
manifestSource: {
|
|
42
|
+
kind: "local_manifest",
|
|
43
|
+
rootPath: resolvedRoot,
|
|
44
|
+
manifestPath
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
installState: "not_installed",
|
|
50
|
+
binaryPath: null,
|
|
51
|
+
installPath: null,
|
|
52
|
+
version: null,
|
|
53
|
+
manifestSource: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function resolveExecutableFromPath(binaryName, pathValue) {
|
|
58
|
+
if (!pathValue) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const pathEntries = pathValue
|
|
62
|
+
.split(path.delimiter)
|
|
63
|
+
.map((entry) => entry.trim())
|
|
64
|
+
.filter(Boolean);
|
|
65
|
+
const executableNames = process.platform === "win32"
|
|
66
|
+
? [binaryName, `${binaryName}.cmd`, `${binaryName}.exe`, `${binaryName}.bat`]
|
|
67
|
+
: [binaryName];
|
|
68
|
+
for (const directory of pathEntries) {
|
|
69
|
+
for (const executableName of executableNames) {
|
|
70
|
+
const candidatePath = path.join(directory, executableName);
|
|
71
|
+
if (isExecutable(candidatePath)) {
|
|
72
|
+
return candidatePath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function isExecutable(filePath) {
|
|
79
|
+
try {
|
|
80
|
+
fs.accessSync(filePath, fs.constants.X_OK);
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function findOpenCliRootForExecutable(binaryPath) {
|
|
88
|
+
const resolvedBinaryPath = fs.realpathSync(binaryPath);
|
|
89
|
+
let currentDir = path.dirname(resolvedBinaryPath);
|
|
90
|
+
while (true) {
|
|
91
|
+
if (looksLikeOpenCliRoot(currentDir)) {
|
|
92
|
+
return currentDir;
|
|
93
|
+
}
|
|
94
|
+
const parentDir = path.dirname(currentDir);
|
|
95
|
+
if (parentDir === currentDir) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
currentDir = parentDir;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function looksLikeOpenCliRoot(rootPath) {
|
|
102
|
+
const packageJsonPath = path.join(rootPath, "package.json");
|
|
103
|
+
const manifestPath = path.join(rootPath, "cli-manifest.json");
|
|
104
|
+
if (!fs.existsSync(packageJsonPath) || !fs.existsSync(manifestPath)) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
109
|
+
return packageJson.name === OPENCLI_PACKAGE_NAME;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function readPackageVersion(rootPath) {
|
|
116
|
+
const packageJsonPath = path.join(rootPath, "package.json");
|
|
117
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
122
|
+
return typeof packageJson.version === "string" && packageJson.version.trim().length > 0
|
|
123
|
+
? packageJson.version.trim()
|
|
124
|
+
: null;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=opencli-install-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencli-install-discovery.js","sourceRoot":"","sources":["../../../../src/modules/opencli/opencli-install-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAqBlD,MAAM,OAAO,uBAAuB;IACjB,GAAG,CAAoB;IACvB,qBAAqB,CAAoB;IAE1D,YAAY,UAA0C,EAAE;QACtD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;QACtC,IAAI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AAQ,EAAE,cAAc,CAAC,CAAC;IAE5D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAEtE,CAAC;QAEF,OAAO,OAAO,WAAW,CAAC,OAAO,KAAK,QAAQ,IAAI,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;YACrF,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE;YAC5B,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { OpenCliCatalogEntryRepository } from "../../storage/repositories/opencli-catalog-entry-repository.js";
|
|
2
|
+
import type { OpenCliProviderRepository } from "../../storage/repositories/opencli-provider-repository.js";
|
|
3
|
+
import type { OpenCliRuntimeProfileRepository } from "../../storage/repositories/opencli-runtime-profile-repository.js";
|
|
4
|
+
import type { OpenCliCatalogSnapshot, OpenCliCatalogRefreshResult, OpenCliCatalogService } from "./opencli-catalog-service.js";
|
|
5
|
+
import type { OpenCliHealthService } from "./opencli-health-service.js";
|
|
6
|
+
import type { OpenCliRuntimeResolver, OpenCliSessionRuntimeResolution } from "./opencli-runtime-resolver.js";
|
|
7
|
+
export interface OpenCliRuntimeProfileView {
|
|
8
|
+
id: string;
|
|
9
|
+
version: string;
|
|
10
|
+
sourceInstallPath: string;
|
|
11
|
+
runtimeRootPath: string;
|
|
12
|
+
status: "pending" | "ready" | "failed" | "stale";
|
|
13
|
+
contentHash: string;
|
|
14
|
+
enabledCommandIds: string[];
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
lastErrorCode: string | null;
|
|
18
|
+
lastErrorDetail: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface OpenCliOverviewDto {
|
|
21
|
+
provider: OpenCliCatalogSnapshot["provider"];
|
|
22
|
+
summary: OpenCliCatalogSnapshot["summary"];
|
|
23
|
+
effectiveCatalogSource: OpenCliCatalogSnapshot["effectiveCatalogSource"];
|
|
24
|
+
activeRuntimeProfile: OpenCliRuntimeProfileView | null;
|
|
25
|
+
}
|
|
26
|
+
export interface OpenCliCatalogDto extends OpenCliOverviewDto {
|
|
27
|
+
entries: OpenCliCatalogSnapshot["entries"];
|
|
28
|
+
siteGroups: OpenCliCatalogSnapshot["siteGroups"];
|
|
29
|
+
}
|
|
30
|
+
export interface OpenCliCheckResultDto extends OpenCliCatalogDto {
|
|
31
|
+
refreshState: OpenCliCatalogRefreshResult["refreshState"];
|
|
32
|
+
errorCode: string | null;
|
|
33
|
+
errorDetail: string | null;
|
|
34
|
+
runtimeAvailability: OpenCliSessionRuntimeResolution["availability"];
|
|
35
|
+
}
|
|
36
|
+
export interface UpdateOpenCliConfigInput {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
enabledCommandIds: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface UpdateOpenCliConfigResultDto extends OpenCliCatalogDto {
|
|
41
|
+
runtimeAvailability: OpenCliSessionRuntimeResolution["availability"];
|
|
42
|
+
runtimeErrorCode: string | null;
|
|
43
|
+
runtimeErrorDetail: string | null;
|
|
44
|
+
}
|
|
45
|
+
export declare class OpenCliManagementService {
|
|
46
|
+
private readonly providerRepository;
|
|
47
|
+
private readonly catalogEntryRepository;
|
|
48
|
+
private readonly runtimeProfileRepository;
|
|
49
|
+
private readonly catalogService;
|
|
50
|
+
private readonly healthService;
|
|
51
|
+
private readonly runtimeResolver;
|
|
52
|
+
constructor(providerRepository: OpenCliProviderRepository, catalogEntryRepository: OpenCliCatalogEntryRepository, runtimeProfileRepository: OpenCliRuntimeProfileRepository, catalogService: OpenCliCatalogService, healthService: OpenCliHealthService, runtimeResolver: OpenCliRuntimeResolver);
|
|
53
|
+
getOverview(): OpenCliOverviewDto;
|
|
54
|
+
getCatalog(): OpenCliCatalogDto;
|
|
55
|
+
check(): Promise<OpenCliCheckResultDto>;
|
|
56
|
+
updateConfig(input: UpdateOpenCliConfigInput): UpdateOpenCliConfigResultDto;
|
|
57
|
+
private refreshProviderHealth;
|
|
58
|
+
private resolveActiveRuntimeProfile;
|
|
59
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { AppError } from "../../shared/errors/app-error.js";
|
|
2
|
+
const DISABLED_RUNTIME_RESOLUTION = {
|
|
3
|
+
availability: "disabled",
|
|
4
|
+
runtimeRootPath: null,
|
|
5
|
+
runtimeBinPath: null,
|
|
6
|
+
realHome: null,
|
|
7
|
+
realUserProfile: null,
|
|
8
|
+
errorCode: null,
|
|
9
|
+
errorDetail: null
|
|
10
|
+
};
|
|
11
|
+
export class OpenCliManagementService {
|
|
12
|
+
providerRepository;
|
|
13
|
+
catalogEntryRepository;
|
|
14
|
+
runtimeProfileRepository;
|
|
15
|
+
catalogService;
|
|
16
|
+
healthService;
|
|
17
|
+
runtimeResolver;
|
|
18
|
+
constructor(providerRepository, catalogEntryRepository, runtimeProfileRepository, catalogService, healthService, runtimeResolver) {
|
|
19
|
+
this.providerRepository = providerRepository;
|
|
20
|
+
this.catalogEntryRepository = catalogEntryRepository;
|
|
21
|
+
this.runtimeProfileRepository = runtimeProfileRepository;
|
|
22
|
+
this.catalogService = catalogService;
|
|
23
|
+
this.healthService = healthService;
|
|
24
|
+
this.runtimeResolver = runtimeResolver;
|
|
25
|
+
}
|
|
26
|
+
getOverview() {
|
|
27
|
+
const snapshot = this.catalogService.getSnapshot();
|
|
28
|
+
return buildOverviewDto(snapshot, this.resolveActiveRuntimeProfile(snapshot.provider.activeRuntimeId));
|
|
29
|
+
}
|
|
30
|
+
getCatalog() {
|
|
31
|
+
const snapshot = this.catalogService.getSnapshot();
|
|
32
|
+
return buildCatalogDto(snapshot, this.resolveActiveRuntimeProfile(snapshot.provider.activeRuntimeId));
|
|
33
|
+
}
|
|
34
|
+
async check() {
|
|
35
|
+
const refreshResult = await this.catalogService.refreshCatalog();
|
|
36
|
+
const providerWithHealth = await this.refreshProviderHealth(refreshResult.provider);
|
|
37
|
+
let runtimeResolution = DISABLED_RUNTIME_RESOLUTION;
|
|
38
|
+
if (providerWithHealth.enabled && providerWithHealth.installState === "installed") {
|
|
39
|
+
runtimeResolution = this.runtimeResolver.resolveSessionRuntime();
|
|
40
|
+
}
|
|
41
|
+
const snapshot = this.catalogService.getSnapshot();
|
|
42
|
+
return {
|
|
43
|
+
...buildCatalogDto(snapshot, this.resolveActiveRuntimeProfile(snapshot.provider.activeRuntimeId)),
|
|
44
|
+
refreshState: refreshResult.refreshState,
|
|
45
|
+
errorCode: refreshResult.errorCode,
|
|
46
|
+
errorDetail: refreshResult.errorDetail,
|
|
47
|
+
runtimeAvailability: runtimeResolution.availability
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
updateConfig(input) {
|
|
51
|
+
const snapshot = this.catalogService.getSnapshot();
|
|
52
|
+
const normalizedEnabledCommandIds = normalizeEnabledCommandIds(input.enabledCommandIds);
|
|
53
|
+
assertKnownCommandIds(snapshot.entries.map((entry) => entry.commandId), normalizedEnabledCommandIds);
|
|
54
|
+
this.catalogEntryRepository.replaceEnabledStates("opencli", normalizedEnabledCommandIds);
|
|
55
|
+
this.providerRepository.upsert({
|
|
56
|
+
...snapshot.provider,
|
|
57
|
+
enabled: input.enabled,
|
|
58
|
+
activeRuntimeId: input.enabled ? snapshot.provider.activeRuntimeId : null
|
|
59
|
+
});
|
|
60
|
+
const runtimeResolution = input.enabled
|
|
61
|
+
? this.runtimeResolver.resolveSessionRuntime()
|
|
62
|
+
: DISABLED_RUNTIME_RESOLUTION;
|
|
63
|
+
const nextSnapshot = this.catalogService.getSnapshot();
|
|
64
|
+
return {
|
|
65
|
+
...buildCatalogDto(nextSnapshot, this.resolveActiveRuntimeProfile(nextSnapshot.provider.activeRuntimeId)),
|
|
66
|
+
runtimeAvailability: runtimeResolution.availability,
|
|
67
|
+
runtimeErrorCode: runtimeResolution.errorCode,
|
|
68
|
+
runtimeErrorDetail: runtimeResolution.errorDetail
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
async refreshProviderHealth(provider) {
|
|
72
|
+
const healthResult = await this.healthService.check();
|
|
73
|
+
return this.providerRepository.upsert({
|
|
74
|
+
...provider,
|
|
75
|
+
installState: healthResult.installState,
|
|
76
|
+
healthState: healthResult.healthState,
|
|
77
|
+
version: healthResult.version,
|
|
78
|
+
installPath: healthResult.installPath,
|
|
79
|
+
lastCheckedAt: healthResult.checkedAt,
|
|
80
|
+
lastErrorCode: healthResult.errorCode ?? provider.lastErrorCode,
|
|
81
|
+
lastErrorDetail: healthResult.errorDetail ?? provider.lastErrorDetail
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
resolveActiveRuntimeProfile(activeRuntimeId) {
|
|
85
|
+
if (!activeRuntimeId) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const profile = this.runtimeProfileRepository.findById(activeRuntimeId);
|
|
89
|
+
if (!profile) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
id: profile.id,
|
|
94
|
+
version: profile.version,
|
|
95
|
+
sourceInstallPath: profile.sourceInstallPath,
|
|
96
|
+
runtimeRootPath: profile.runtimeRootPath,
|
|
97
|
+
status: profile.status,
|
|
98
|
+
contentHash: profile.contentHash,
|
|
99
|
+
enabledCommandIds: parseProfileCommandIds(profile.enabledCommandIdsJson),
|
|
100
|
+
createdAt: profile.createdAt,
|
|
101
|
+
updatedAt: profile.updatedAt,
|
|
102
|
+
lastErrorCode: profile.lastErrorCode,
|
|
103
|
+
lastErrorDetail: profile.lastErrorDetail
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function buildOverviewDto(snapshot, activeRuntimeProfile) {
|
|
108
|
+
return {
|
|
109
|
+
provider: snapshot.provider,
|
|
110
|
+
summary: snapshot.summary,
|
|
111
|
+
effectiveCatalogSource: snapshot.effectiveCatalogSource,
|
|
112
|
+
activeRuntimeProfile
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function buildCatalogDto(snapshot, activeRuntimeProfile) {
|
|
116
|
+
return {
|
|
117
|
+
...buildOverviewDto(snapshot, activeRuntimeProfile),
|
|
118
|
+
entries: snapshot.entries,
|
|
119
|
+
siteGroups: snapshot.siteGroups
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function normalizeEnabledCommandIds(enabledCommandIds) {
|
|
123
|
+
return [...new Set(enabledCommandIds
|
|
124
|
+
.map((commandId) => commandId.trim())
|
|
125
|
+
.filter((commandId) => commandId.length > 0))].sort((left, right) => left.localeCompare(right));
|
|
126
|
+
}
|
|
127
|
+
function assertKnownCommandIds(knownCommandIds, nextCommandIds) {
|
|
128
|
+
const knownCommandIdSet = new Set(knownCommandIds);
|
|
129
|
+
const unknownCommandIds = nextCommandIds.filter((commandId) => !knownCommandIdSet.has(commandId));
|
|
130
|
+
if (unknownCommandIds.length === 0) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
throw new AppError({
|
|
134
|
+
statusCode: 400,
|
|
135
|
+
errorCode: "OPENCLI_UNKNOWN_COMMAND_IDS",
|
|
136
|
+
detail: `存在未知 OpenCLI 命令:${unknownCommandIds.join(", ")}`,
|
|
137
|
+
field: "enabledCommandIds"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function parseProfileCommandIds(value) {
|
|
141
|
+
try {
|
|
142
|
+
const parsed = JSON.parse(value);
|
|
143
|
+
if (!Array.isArray(parsed)) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
return parsed.filter((entry) => typeof entry === "string");
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=opencli-management-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencli-management-service.js","sourceRoot":"","sources":["../../../../src/modules/opencli/opencli-management-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAoD5D,MAAM,2BAA2B,GAAoC;IACnE,YAAY,EAAE,UAAU;IACxB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,QAAQ,EAAE,IAAI;IACd,eAAe,EAAE,IAAI;IACrB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;CAClB,CAAC;AAEF,MAAM,OAAO,wBAAwB;IAEhB;IACA;IACA;IACA;IACA;IACA;IANnB,YACmB,kBAA6C,EAC7C,sBAAqD,EACrD,wBAAyD,EACzD,cAAqC,EACrC,aAAmC,EACnC,eAAuC;QALvC,uBAAkB,GAAlB,kBAAkB,CAA2B;QAC7C,2BAAsB,GAAtB,sBAAsB,CAA+B;QACrD,6BAAwB,GAAxB,wBAAwB,CAAiC;QACzD,mBAAc,GAAd,cAAc,CAAuB;QACrC,kBAAa,GAAb,aAAa,CAAsB;QACnC,oBAAe,GAAf,eAAe,CAAwB;IACvD,CAAC;IAEJ,WAAW;QACT,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;QACnD,OAAO,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;IACzG,CAAC;IAED,UAAU;QACR,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;QACnD,OAAO,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;IACxG,CAAC;IAED,KAA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/repositories/opencli-runtime-profile-repository.js";
|
|
3
|
+
export interface OpenCliRuntimeBuilderOptions {
|
|
4
|
+
now?: () => string;
|
|
5
|
+
}
|
|
6
|
+
export declare class OpenCliRuntimeBuilder {
|
|
7
|
+
private readonly runtimeProfileRepository;
|
|
8
|
+
private readonly now;
|
|
9
|
+
constructor(runtimeProfileRepository: OpenCliRuntimeProfileRepository, options?: OpenCliRuntimeBuilderOptions);
|
|
10
|
+
buildProfile(profileOrId: string | OpenCliRuntimeProfileRecord): OpenCliRuntimeProfileRecord;
|
|
11
|
+
}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { nowIso } from "../../shared/utils/time.js";
|
|
4
|
+
import { createOpenCliRuntimeStagingRoot } from "./opencli-runtime-layout.js";
|
|
5
|
+
export class OpenCliRuntimeBuilder {
|
|
6
|
+
runtimeProfileRepository;
|
|
7
|
+
now;
|
|
8
|
+
constructor(runtimeProfileRepository, options = {}) {
|
|
9
|
+
this.runtimeProfileRepository = runtimeProfileRepository;
|
|
10
|
+
this.now = options.now ?? nowIso;
|
|
11
|
+
}
|
|
12
|
+
buildProfile(profileOrId) {
|
|
13
|
+
const profile = resolveProfile(this.runtimeProfileRepository, profileOrId);
|
|
14
|
+
if (profile.status === "ready" && runtimeRootLooksUsable(profile.runtimeRootPath)) {
|
|
15
|
+
return profile;
|
|
16
|
+
}
|
|
17
|
+
const stagingRootPath = createOpenCliRuntimeStagingRoot(profile.runtimeRootPath);
|
|
18
|
+
try {
|
|
19
|
+
const enabledCommandIds = parseEnabledCommandIds(profile.enabledCommandIdsJson);
|
|
20
|
+
const sourceLayout = readOpenCliSourceLayout(profile.sourceInstallPath);
|
|
21
|
+
const filteredManifest = filterManifestEntries(sourceLayout.manifestEntries, enabledCommandIds);
|
|
22
|
+
const enabledSites = new Set(filteredManifest.map((entry) => normalizeManifestCommandId(entry).site));
|
|
23
|
+
fs.rmSync(stagingRootPath, { recursive: true, force: true });
|
|
24
|
+
fs.mkdirSync(stagingRootPath, { recursive: true });
|
|
25
|
+
copyPackageJson(sourceLayout.packageJsonPath, path.join(stagingRootPath, "package.json"));
|
|
26
|
+
writeManifest(path.join(stagingRootPath, "cli-manifest.json"), filteredManifest);
|
|
27
|
+
linkDirectory(sourceLayout.distPath, path.join(stagingRootPath, "dist"));
|
|
28
|
+
if (sourceLayout.nodeModulesPath) {
|
|
29
|
+
linkDirectory(sourceLayout.nodeModulesPath, path.join(stagingRootPath, "node_modules"));
|
|
30
|
+
}
|
|
31
|
+
copyPrunedClis({
|
|
32
|
+
sourceClisRoot: sourceLayout.clisPath,
|
|
33
|
+
targetClisRoot: path.join(stagingRootPath, "clis"),
|
|
34
|
+
enabledSites
|
|
35
|
+
});
|
|
36
|
+
writeOpenCliShim(stagingRootPath);
|
|
37
|
+
fs.mkdirSync(path.dirname(profile.runtimeRootPath), { recursive: true });
|
|
38
|
+
fs.rmSync(profile.runtimeRootPath, { recursive: true, force: true });
|
|
39
|
+
fs.renameSync(stagingRootPath, profile.runtimeRootPath);
|
|
40
|
+
return this.runtimeProfileRepository.upsert({
|
|
41
|
+
...profile,
|
|
42
|
+
status: "ready",
|
|
43
|
+
updatedAt: this.now(),
|
|
44
|
+
lastErrorCode: null,
|
|
45
|
+
lastErrorDetail: null
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
fs.rmSync(stagingRootPath, { recursive: true, force: true });
|
|
50
|
+
return this.runtimeProfileRepository.upsert({
|
|
51
|
+
...profile,
|
|
52
|
+
status: "failed",
|
|
53
|
+
updatedAt: this.now(),
|
|
54
|
+
lastErrorCode: "OPENCLI_RUNTIME_BUILD_FAILED",
|
|
55
|
+
lastErrorDetail: error instanceof Error ? error.message : String(error)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function resolveProfile(repository, profileOrId) {
|
|
61
|
+
if (typeof profileOrId !== "string") {
|
|
62
|
+
return profileOrId;
|
|
63
|
+
}
|
|
64
|
+
const profile = repository.findById(profileOrId);
|
|
65
|
+
if (!profile) {
|
|
66
|
+
throw new Error(`OPENCLI_RUNTIME_PROFILE_NOT_FOUND:${profileOrId}`);
|
|
67
|
+
}
|
|
68
|
+
return profile;
|
|
69
|
+
}
|
|
70
|
+
function runtimeRootLooksUsable(runtimeRootPath) {
|
|
71
|
+
return [
|
|
72
|
+
path.join(runtimeRootPath, "package.json"),
|
|
73
|
+
path.join(runtimeRootPath, "cli-manifest.json"),
|
|
74
|
+
path.join(runtimeRootPath, "clis"),
|
|
75
|
+
path.join(runtimeRootPath, "bin", "opencli")
|
|
76
|
+
].every((entryPath) => fs.existsSync(entryPath));
|
|
77
|
+
}
|
|
78
|
+
function parseEnabledCommandIds(value) {
|
|
79
|
+
const parsed = JSON.parse(value);
|
|
80
|
+
if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string")) {
|
|
81
|
+
throw new Error("OPENCLI_RUNTIME_ENABLED_COMMAND_IDS_INVALID");
|
|
82
|
+
}
|
|
83
|
+
return new Set(parsed);
|
|
84
|
+
}
|
|
85
|
+
function readOpenCliSourceLayout(sourceInstallPath) {
|
|
86
|
+
const packageJsonPath = path.join(sourceInstallPath, "package.json");
|
|
87
|
+
const distPath = path.join(sourceInstallPath, "dist");
|
|
88
|
+
const clisPath = path.join(sourceInstallPath, "clis");
|
|
89
|
+
const nodeModulesPath = path.join(sourceInstallPath, "node_modules");
|
|
90
|
+
const manifestPath = path.join(sourceInstallPath, "cli-manifest.json");
|
|
91
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
92
|
+
throw new Error("OPENCLI_RUNTIME_SOURCE_PACKAGE_JSON_MISSING");
|
|
93
|
+
}
|
|
94
|
+
if (!fs.existsSync(distPath)) {
|
|
95
|
+
throw new Error("OPENCLI_RUNTIME_SOURCE_DIST_MISSING");
|
|
96
|
+
}
|
|
97
|
+
if (!fs.existsSync(clisPath)) {
|
|
98
|
+
throw new Error("OPENCLI_RUNTIME_SOURCE_CLIS_MISSING");
|
|
99
|
+
}
|
|
100
|
+
if (!fs.existsSync(manifestPath)) {
|
|
101
|
+
throw new Error("OPENCLI_RUNTIME_SOURCE_MANIFEST_MISSING");
|
|
102
|
+
}
|
|
103
|
+
const rawManifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
104
|
+
if (!Array.isArray(rawManifest)) {
|
|
105
|
+
throw new Error("OPENCLI_RUNTIME_SOURCE_MANIFEST_INVALID");
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
packageJsonPath,
|
|
109
|
+
distPath,
|
|
110
|
+
clisPath,
|
|
111
|
+
nodeModulesPath: fs.existsSync(nodeModulesPath) ? nodeModulesPath : null,
|
|
112
|
+
manifestEntries: rawManifest
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function filterManifestEntries(manifestEntries, enabledCommandIds) {
|
|
116
|
+
const filteredEntries = manifestEntries.filter((entry) => {
|
|
117
|
+
const { commandId } = normalizeManifestCommandId(entry);
|
|
118
|
+
return enabledCommandIds.has(commandId);
|
|
119
|
+
});
|
|
120
|
+
if (filteredEntries.length !== enabledCommandIds.size) {
|
|
121
|
+
const foundCommandIds = new Set(filteredEntries.map((entry) => normalizeManifestCommandId(entry).commandId));
|
|
122
|
+
for (const commandId of enabledCommandIds) {
|
|
123
|
+
if (!foundCommandIds.has(commandId)) {
|
|
124
|
+
throw new Error(`OPENCLI_RUNTIME_COMMAND_NOT_FOUND:${commandId}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return filteredEntries;
|
|
129
|
+
}
|
|
130
|
+
function normalizeManifestCommandId(entry) {
|
|
131
|
+
const site = typeof entry.site === "string" ? entry.site.trim() : "";
|
|
132
|
+
const name = typeof entry.name === "string" ? entry.name.trim() : "";
|
|
133
|
+
if (!site || !name) {
|
|
134
|
+
throw new Error("OPENCLI_RUNTIME_MANIFEST_ENTRY_INVALID");
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
commandId: `${site}/${name}`,
|
|
138
|
+
site
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function copyPackageJson(sourcePath, targetPath) {
|
|
142
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
143
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
144
|
+
}
|
|
145
|
+
function writeManifest(targetPath, manifestEntries) {
|
|
146
|
+
fs.writeFileSync(targetPath, `${JSON.stringify(manifestEntries, null, 2)}\n`, "utf8");
|
|
147
|
+
}
|
|
148
|
+
function linkDirectory(sourcePath, targetPath) {
|
|
149
|
+
fs.rmSync(targetPath, { recursive: true, force: true });
|
|
150
|
+
fs.mkdirSync(path.dirname(targetPath), { recursive: true });
|
|
151
|
+
fs.symlinkSync(sourcePath, targetPath, process.platform === "win32" ? "junction" : "dir");
|
|
152
|
+
}
|
|
153
|
+
function copyPrunedClis(input) {
|
|
154
|
+
fs.mkdirSync(input.targetClisRoot, { recursive: true });
|
|
155
|
+
const entries = fs.readdirSync(input.sourceClisRoot, { withFileTypes: true });
|
|
156
|
+
for (const entry of entries) {
|
|
157
|
+
if (!entry.isDirectory()) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
const shouldCopy = entry.name.startsWith("_") || input.enabledSites.has(entry.name);
|
|
161
|
+
if (!shouldCopy) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
fs.cpSync(path.join(input.sourceClisRoot, entry.name), path.join(input.targetClisRoot, entry.name), { recursive: true });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function writeOpenCliShim(runtimeRootPath) {
|
|
168
|
+
const binDir = path.join(runtimeRootPath, "bin");
|
|
169
|
+
const scriptPath = path.join(binDir, "opencli");
|
|
170
|
+
const cmdPath = path.join(binDir, "opencli.cmd");
|
|
171
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
172
|
+
fs.writeFileSync(scriptPath, `#!/usr/bin/env node
|
|
173
|
+
import { spawn } from "node:child_process";
|
|
174
|
+
import path from "node:path";
|
|
175
|
+
import { fileURLToPath } from "node:url";
|
|
176
|
+
|
|
177
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
178
|
+
const runtimeRoot = path.resolve(path.dirname(__filename), "..");
|
|
179
|
+
const mainScript = path.join(runtimeRoot, "dist", "src", "main.js");
|
|
180
|
+
const env = { ...process.env };
|
|
181
|
+
const realHome = env.CODINGNS_OPENCLI_REAL_HOME?.trim();
|
|
182
|
+
const realUserProfile = env.CODINGNS_OPENCLI_REAL_USERPROFILE?.trim();
|
|
183
|
+
|
|
184
|
+
if (realHome) {
|
|
185
|
+
env.HOME = realHome;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (realUserProfile) {
|
|
189
|
+
env.USERPROFILE = realUserProfile;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const child = spawn(process.execPath, ["--preserve-symlinks-main", mainScript, ...process.argv.slice(2)], {
|
|
193
|
+
stdio: "inherit",
|
|
194
|
+
env
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
child.on("error", (error) => {
|
|
198
|
+
process.stderr.write(\`\${error instanceof Error ? error.message : String(error)}\\n\`);
|
|
199
|
+
process.exit(1);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
child.on("exit", (code, signal) => {
|
|
203
|
+
if (signal) {
|
|
204
|
+
process.kill(process.pid, signal);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
process.exit(code ?? 1);
|
|
209
|
+
});
|
|
210
|
+
`, "utf8");
|
|
211
|
+
fs.chmodSync(scriptPath, 0o755);
|
|
212
|
+
fs.writeFileSync(cmdPath, "@echo off\r\nnode \"%~dp0\\opencli\" %*\r\n", "utf8");
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=opencli-runtime-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAEjD,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,EAAE,CAAC,aAAa,CACd,UAAU,EACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCH,EACG,MAAM,CACP,CAAC;IACF,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAChC,EAAE,CAAC,aAAa,CACd,OAAO,EACP,6CAA6C,EAC7C,MAAM,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function resolveOpenCliRuntimeStoreRoot(hostDataRootPath: string): string;
|
|
2
|
+
export declare function resolveOpenCliRuntimeRoot(hostDataRootPath: string, profileId: string): string;
|
|
3
|
+
export declare function createOpenCliRuntimeStagingRoot(runtimeRootPath: string): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
export function resolveOpenCliRuntimeStoreRoot(hostDataRootPath) {
|
|
3
|
+
return path.join(hostDataRootPath, "opencli-runtimes");
|
|
4
|
+
}
|
|
5
|
+
export function resolveOpenCliRuntimeRoot(hostDataRootPath, profileId) {
|
|
6
|
+
return path.join(resolveOpenCliRuntimeStoreRoot(hostDataRootPath), profileId);
|
|
7
|
+
}
|
|
8
|
+
export function createOpenCliRuntimeStagingRoot(runtimeRootPath) {
|
|
9
|
+
return `${runtimeRootPath}.tmp-${process.pid}-${Date.now()}`;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=opencli-runtime-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencli-runtime-layout.js","sourceRoot":"","sources":["../../../../src/modules/opencli/opencli-runtime-layout.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,MAAM,UAAU,8BAA8B,CAAC,gBAAwB;IACrE,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,gBAAwB,EAAE,SAAiB;IACnF,OAAO,IAAI,CAAC,IAAI,CAAC,8BAA8B,CAAC,gBAAgB,CAAC,EAAE,SAAS,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,eAAuB;IACrE,OAAO,GAAG,eAAe,QAAQ,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { OpenCliProviderRecord, OpenCliRuntimeProfileRecord } from "../../types/domain.js";
|
|
2
|
+
import type { OpenCliCatalogEntryRepository } from "../../storage/repositories/opencli-catalog-entry-repository.js";
|
|
3
|
+
import type { OpenCliProviderRepository } from "../../storage/repositories/opencli-provider-repository.js";
|
|
4
|
+
import type { OpenCliRuntimeProfileRepository } from "../../storage/repositories/opencli-runtime-profile-repository.js";
|
|
5
|
+
export interface OpenCliRuntimeProfileServiceOptions {
|
|
6
|
+
now?: () => string;
|
|
7
|
+
runtimeStorageRootPath: string;
|
|
8
|
+
}
|
|
9
|
+
export interface OpenCliDesiredRuntimeProfile {
|
|
10
|
+
provider: OpenCliProviderRecord;
|
|
11
|
+
enabledCommandIds: string[];
|
|
12
|
+
contentHash: string;
|
|
13
|
+
profile: OpenCliRuntimeProfileRecord;
|
|
14
|
+
}
|
|
15
|
+
export declare class OpenCliRuntimeProfileService {
|
|
16
|
+
private readonly providerRepository;
|
|
17
|
+
private readonly catalogEntryRepository;
|
|
18
|
+
private readonly runtimeProfileRepository;
|
|
19
|
+
private readonly now;
|
|
20
|
+
private readonly runtimeStorageRootPath;
|
|
21
|
+
constructor(providerRepository: OpenCliProviderRepository, catalogEntryRepository: OpenCliCatalogEntryRepository, runtimeProfileRepository: OpenCliRuntimeProfileRepository, options: OpenCliRuntimeProfileServiceOptions);
|
|
22
|
+
findOrCreateDesiredProfile(): OpenCliDesiredRuntimeProfile;
|
|
23
|
+
private markOutdatedProfilesAsStale;
|
|
24
|
+
}
|
|
25
|
+
export declare function computeOpenCliRuntimeProfileHash(input: {
|
|
26
|
+
version: string;
|
|
27
|
+
sourceInstallPath: string;
|
|
28
|
+
enabledCommandIds: readonly string[];
|
|
29
|
+
}): string;
|