coding-tool-x 3.8.4 → 3.8.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/CHANGELOG.md +15 -0
- package/README.md +86 -15
- package/dist/web/assets/AgentsDrawer-BG6P3DX-.js +1 -0
- package/dist/web/assets/AgentsDrawer-Pw2k-ZAa.css +1 -0
- package/dist/web/assets/Analytics--z_FmL5P.js +1 -0
- package/dist/web/assets/Analytics-CyHhR126.css +1 -0
- package/dist/web/assets/AssetPathField-CrJtRKHy.js +1 -0
- package/dist/web/assets/ChatHistoryDrawer-B2qBQs9L.css +1 -0
- package/dist/web/assets/ChatHistoryDrawer-BiuEryJj.js +1 -0
- package/dist/web/assets/CollapseItem-BAYEsL_Q.js +1 -0
- package/dist/web/assets/CommandsDrawer-BZJxlPvV.css +1 -0
- package/dist/web/assets/CommandsDrawer-YJ-U7BXN.js +1 -0
- package/dist/web/assets/ConfigExportDrawer-Ce_hAknW.js +1 -0
- package/dist/web/assets/ConfigExportDrawer-dwruRKWr.css +1 -0
- package/dist/web/assets/ConfigTemplates-Bvr1NN6K.js +1 -0
- package/dist/web/assets/ConfigTemplatesDrawer-BfDi8yO3.css +1 -0
- package/dist/web/assets/ConfigTemplatesDrawer-BjIeHfF-.js +1 -0
- package/dist/web/assets/ConfigTemplatesPanel-AV00tm_D.js +1 -0
- package/dist/web/assets/ConfigTemplatesPanel-CWyPtk67.css +1 -0
- package/dist/web/assets/Divider-D28g1gwj.js +1 -0
- package/dist/web/assets/DrawerContent-ChXgZ1Xm.js +1 -0
- package/dist/web/assets/FavoritesDrawer-CG9eI9Ay.css +1 -0
- package/dist/web/assets/FavoritesDrawer-Cz95o4CD.js +1 -0
- package/dist/web/assets/GatewayConvertDrawer-CuNlf7AC.css +1 -0
- package/dist/web/assets/GatewayConvertDrawer-DLlbMz27.js +1 -0
- package/dist/web/assets/Home-CSuFuJ9Y.css +1 -0
- package/dist/web/assets/Home-D7CCOFQC.js +1 -0
- package/dist/web/assets/MarkdownEditor-qfVgSre_.css +1 -0
- package/dist/web/assets/MarkdownEditor-rEZ-c72L.js +1 -0
- package/dist/web/assets/McpDrawer-C0dnsZhQ.css +1 -0
- package/dist/web/assets/McpDrawer-DfoCyxU2.js +1 -0
- package/dist/web/assets/McpFormDrawer-BRbDcawn.css +1 -0
- package/dist/web/assets/McpFormDrawer-SKu8HNUR.js +1 -0
- package/dist/web/assets/PluginManager-BbeK-3rV.js +1 -0
- package/dist/web/assets/PluginsDrawer-CWVJ7yjS.js +1 -0
- package/dist/web/assets/PluginsDrawer-DM3QjprE.css +1 -0
- package/dist/web/assets/PluginsPanel-Cm2N3StG.js +1 -0
- package/dist/web/assets/PluginsPanel-D6ZqITcR.css +1 -0
- package/dist/web/assets/ProjectList-677RLZ8O.css +1 -0
- package/dist/web/assets/ProjectList-CsjnsNPv.js +1 -0
- package/dist/web/assets/PromptsDrawer-BIgiYCEQ.css +1 -0
- package/dist/web/assets/PromptsDrawer-EGd3djFa.js +1 -0
- package/dist/web/assets/RecentSessionsDrawer-CKFsOYDM.css +1 -0
- package/dist/web/assets/RecentSessionsDrawer-D1vtoLAs.js +1 -0
- package/dist/web/assets/SessionCard-BgLg49U3.js +1 -0
- package/dist/web/assets/SessionCard-aM2NHu6i.css +1 -0
- package/dist/web/assets/SessionList-BpYRz1cX.css +1 -0
- package/dist/web/assets/SessionList-TRiTklWk.js +1 -0
- package/dist/web/assets/SettingsDrawer-d5liXjHq.css +1 -0
- package/dist/web/assets/SettingsDrawer-rz2WejGY.js +1 -0
- package/dist/web/assets/SkillManager-BTjTUbHq.js +1 -0
- package/dist/web/assets/SkillManager-C0GCT2Kb.css +1 -0
- package/dist/web/assets/SkillsDrawer-BCNme-aJ.css +1 -0
- package/dist/web/assets/SkillsDrawer-pN0hbkK3.js +1 -0
- package/dist/web/assets/SkillsPanel-B3Nm5j32.css +1 -0
- package/dist/web/assets/SkillsPanel-gmBWEoiF.js +1 -0
- package/dist/web/assets/SpeedTestDrawer-Dc0WToJ_.css +1 -0
- package/dist/web/assets/SpeedTestDrawer-DcNzuVJk.js +1 -0
- package/dist/web/assets/Upload-v5rV0qTT.js +1 -0
- package/dist/web/assets/WorkspaceDrawer-CGnMu9p1.css +1 -0
- package/dist/web/assets/WorkspaceDrawer-DxmicM4U.js +1 -0
- package/dist/web/assets/WorkspaceManager-CJHCjARN.js +1 -0
- package/dist/web/assets/WorkspacePanel-D0-zHTHP.css +1 -0
- package/dist/web/assets/WorkspacePanel-D8_Zq-du.js +1 -0
- package/dist/web/assets/_plugin-vue_export-helper-BeLZJZij.js +1 -0
- package/dist/web/assets/client-UDwXBP9i.js +1 -0
- package/dist/web/assets/clipboard-B46yyoz_.js +1 -0
- package/dist/web/assets/headers-cf-QapUq.js +1 -0
- package/dist/web/assets/icons-B2Vg-IOC.js +1 -0
- package/dist/web/assets/index-C0EHRym0.css +1 -0
- package/dist/web/assets/index-DnEocV0M.js +2 -0
- package/dist/web/assets/light-Cp0t7v32.js +1 -0
- package/dist/web/assets/markdown-u082bbtj.js +1 -0
- package/dist/web/assets/platforms-CBkB45JP.js +1 -0
- package/dist/web/assets/platforms-FTpjxAT6.js +1 -0
- package/dist/web/assets/project-config-B2baPzYL.js +1 -0
- package/dist/web/assets/sessions-Cmy31slD.js +1 -0
- package/dist/web/assets/sessions-yC_oVVh8.js +1 -0
- package/dist/web/assets/skill-repo-input-B_fkGlUK.js +1 -0
- package/dist/web/assets/use-lock-html-scroll-DXIqmUW4.js +1 -0
- package/dist/web/assets/use-message-DoLM8C1C.js +1 -0
- package/dist/web/assets/useResponsiveDrawer-B3uojyvV.js +1 -0
- package/dist/web/assets/vendors-D0c_0KLP.js +1 -0
- package/dist/web/assets/vue-vendor-BqZbbXHA.js +1 -0
- package/dist/web/assets/workspaces-mjyPVGS8.js +1 -0
- package/dist/web/assets/xml-CgY3RMlX.js +1 -0
- package/dist/web/index.html +12 -8
- package/docs/native-log-memory-2026-09-16.md +43 -0
- package/docs/superpowers/plans/2026-08-26-configuration-driven-cli-platform.md +1578 -0
- package/docs/superpowers/plans/2026-08-30-project-scoped-config-control.md +1260 -0
- package/docs/superpowers/plans/2026-09-01-omp-skill-refresh-boundary.md +213 -0
- package/docs/superpowers/plans/2026-09-01-realtime-logs-panel.md +125 -0
- package/docs/superpowers/plans/2026-09-02-config-driven-platform-boundary.md +86 -0
- package/docs/superpowers/plans/2026-09-02-platform-implementation-drivers.md +508 -0
- package/docs/superpowers/plans/2026-09-03-cli-platform-correctness-boundary.md +760 -0
- package/docs/superpowers/plans/2026-09-03-dependency-security-remediation.md +133 -0
- package/docs/superpowers/plans/2026-09-04-model-catalog-pricing-sync.md +1078 -0
- package/docs/superpowers/plans/2026-09-05-codex-project-scan-500.md +128 -0
- package/docs/superpowers/plans/2026-09-06-project-skill-path-fix.md +97 -0
- package/docs/superpowers/specs/2026-08-26-configuration-driven-cli-platform-design.md +408 -0
- package/docs/superpowers/specs/2026-08-30-project-scoped-config-control-design.md +467 -0
- package/docs/superpowers/specs/2026-09-01-claude-session-content-repair-design.md +111 -0
- package/docs/superpowers/specs/2026-09-01-omp-skill-refresh-boundary-design.md +83 -0
- package/docs/superpowers/specs/2026-09-01-realtime-logs-panel-design.md +27 -0
- package/docs/superpowers/specs/2026-09-02-config-driven-platform-boundary-design.md +64 -0
- package/docs/superpowers/specs/2026-09-02-platform-implementation-driver-boundary-design.md +123 -0
- package/docs/superpowers/specs/2026-09-03-cli-platform-correctness-boundary-design.md +249 -0
- package/docs/superpowers/specs/2026-09-03-dependency-security-remediation-design.md +87 -0
- package/docs/superpowers/specs/2026-09-04-model-catalog-pricing-sync-design.md +301 -0
- package/docs/superpowers/specs/2026-09-05-codex-project-scan-500-design.md +24 -0
- package/package.json +8 -4
- package/src/commands/channels.js +88 -191
- package/src/commands/cli-type.js +19 -11
- package/src/commands/daemon.js +94 -32
- package/src/commands/doctor.js +16 -9
- package/src/commands/export-config.js +23 -5
- package/src/commands/list.js +130 -52
- package/src/commands/logs.js +44 -27
- package/src/commands/platform-command-registry.js +78 -0
- package/src/commands/plugin.js +11 -5
- package/src/commands/port-config.js +34 -52
- package/src/commands/proxy-control.js +207 -145
- package/src/commands/proxy.js +2 -2
- package/src/commands/resume.js +87 -91
- package/src/commands/search.js +137 -67
- package/src/commands/stats.js +30 -22
- package/src/commands/switch.js +1 -1
- package/src/commands/toggle-proxy.js +94 -111
- package/src/commands/ui.js +67 -6
- package/src/commands/workspace.js +90 -8
- package/src/config/default.js +6 -53
- package/src/config/loader.js +61 -24
- package/src/config/model-metadata.js +49 -59
- package/src/config/model-metadata.json +4095 -99
- package/src/config/paths.js +181 -8
- package/src/index.js +134 -71
- package/src/platforms/access.js +196 -0
- package/src/{server/services → platforms}/agents-service.js +354 -197
- package/src/platforms/channel-auth-registry.js +162 -0
- package/src/platforms/channel-auth-service.js +82 -0
- package/src/{server/services → platforms}/commands-service.js +195 -115
- package/src/platforms/driver-registry.js +59 -0
- package/src/platforms/drivers/claude/api-operations.js +62 -0
- package/src/{server/services/channels.js → platforms/drivers/claude/channels-implementation.js} +131 -33
- package/src/platforms/drivers/claude/channels.js +39 -0
- package/src/{server/services/config-sync-service.js → platforms/drivers/claude/config-sync.js} +29 -5
- package/src/{server/services → platforms/drivers/claude}/health-check.js +4 -4
- package/src/platforms/drivers/claude/health.js +22 -0
- package/src/platforms/drivers/claude/mcp.js +9 -0
- package/src/{server/services/settings-manager.js → platforms/drivers/claude/native-config-implementation.js} +13 -4
- package/src/platforms/drivers/claude/native-config.js +46 -0
- package/src/platforms/drivers/claude/native-logs.js +72 -0
- package/src/{server/services/claude-openai-gateway.js → platforms/drivers/claude/openai-gateway.js} +8 -65
- package/src/platforms/drivers/claude/project-config.js +21 -0
- package/src/platforms/drivers/claude/projects.js +62 -0
- package/src/platforms/drivers/claude/prompts.js +9 -0
- package/src/{server/proxy-server.js → platforms/drivers/claude/proxy-implementation.js} +41 -278
- package/src/platforms/drivers/claude/proxy.js +16 -0
- package/src/platforms/drivers/claude/resource-sync.js +9 -0
- package/src/platforms/drivers/claude/session-history-adapter.js +313 -0
- package/src/{server/services/sessions.js → platforms/drivers/claude/sessions-implementation.js} +145 -35
- package/src/platforms/drivers/claude/sessions.js +76 -0
- package/src/{server/services/claude-statistics-service.js → platforms/drivers/claude/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/claude/statistics.js +16 -0
- package/src/{server/services/claude-wire.js → platforms/drivers/claude/wire.js} +1 -1
- package/src/platforms/drivers/codex/api-operations.js +9 -0
- package/src/{server/services/codex-channels.js → platforms/drivers/codex/channels-implementation.js} +149 -14
- package/src/platforms/drivers/codex/channels.js +45 -0
- package/src/{server/services/codex-config.js → platforms/drivers/codex/config.js} +12 -2
- package/src/{server/services/codex-env-manager.js → platforms/drivers/codex/env-manager.js} +1 -1
- package/src/platforms/drivers/codex/mcp.js +9 -0
- package/src/{server/services/codex-settings-manager.js → platforms/drivers/codex/native-config-implementation.js} +15 -6
- package/src/platforms/drivers/codex/native-config.js +47 -0
- package/src/platforms/drivers/codex/native-logs.js +166 -0
- package/src/platforms/drivers/codex/project-config.js +21 -0
- package/src/platforms/drivers/codex/projects.js +26 -0
- package/src/platforms/drivers/codex/prompts.js +9 -0
- package/src/{server/codex-proxy-server.js → platforms/drivers/codex/proxy-implementation.js} +30 -233
- package/src/platforms/drivers/codex/proxy.js +16 -0
- package/src/platforms/drivers/codex/resource-sync.js +9 -0
- package/src/{server/services/session-history-adapters/codex.js → platforms/drivers/codex/session-history-adapter.js} +37 -23
- package/src/{server/services/codex-sessions.js → platforms/drivers/codex/sessions-implementation.js} +81 -75
- package/src/platforms/drivers/codex/sessions.js +36 -0
- package/src/{server/services/codex-statistics-service.js → platforms/drivers/codex/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/codex/statistics.js +16 -0
- package/src/platforms/drivers/gemini/api-operations.js +9 -0
- package/src/{server/services/gemini-channels.js → platforms/drivers/gemini/channels-implementation.js} +202 -37
- package/src/platforms/drivers/gemini/channels.js +39 -0
- package/src/{server/services/gemini-config.js → platforms/drivers/gemini/config.js} +12 -2
- package/src/platforms/drivers/gemini/mcp.js +9 -0
- package/src/{server/services/gemini-settings-manager.js → platforms/drivers/gemini/native-config-implementation.js} +14 -5
- package/src/platforms/drivers/gemini/native-config.js +39 -0
- package/src/platforms/drivers/gemini/native-logs.js +180 -0
- package/src/platforms/drivers/gemini/project-config.js +21 -0
- package/src/platforms/drivers/gemini/projects.js +26 -0
- package/src/platforms/drivers/gemini/prompts.js +9 -0
- package/src/{server/gemini-proxy-server.js → platforms/drivers/gemini/proxy-implementation.js} +36 -267
- package/src/platforms/drivers/gemini/proxy.js +16 -0
- package/src/platforms/drivers/gemini/resource-sync.js +9 -0
- package/src/{server/services/session-history-adapters/gemini.js → platforms/drivers/gemini/session-history-adapter.js} +70 -18
- package/src/{server/services/gemini-sessions.js → platforms/drivers/gemini/sessions-implementation.js} +53 -37
- package/src/platforms/drivers/gemini/sessions.js +47 -0
- package/src/{server/services/gemini-statistics-service.js → platforms/drivers/gemini/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/gemini/statistics.js +16 -0
- package/src/{server/services/gemini-wire.js → platforms/drivers/gemini/wire.js} +1 -1
- package/src/platforms/drivers/generic-filesystem.js +166 -0
- package/src/platforms/drivers/generic-jsonl.js +141 -0
- package/src/platforms/drivers/generic-mcp.js +44 -0
- package/src/platforms/drivers/generic-openai-compatible.js +45 -0
- package/src/platforms/drivers/generic-prompt.js +41 -0
- package/src/platforms/drivers/legacy.js +677 -0
- package/src/platforms/drivers/native-config-snapshot.js +125 -0
- package/src/platforms/drivers/native-log-utils.js +1292 -0
- package/src/platforms/drivers/notification-hooks.js +578 -0
- package/src/{server/api/omp-config.js → platforms/drivers/omp/api-operations.js} +52 -64
- package/src/{server/services/omp-auth-provider-worker.js → platforms/drivers/omp/auth-provider-worker.js} +1 -1
- package/src/{server/services/omp-auth-providers.js → platforms/drivers/omp/auth-providers.js} +1 -1
- package/src/{server/services/omp-channels.js → platforms/drivers/omp/channels-implementation.js} +166 -39
- package/src/platforms/drivers/omp/channels.js +58 -0
- package/src/{server/services/omp-config.js → platforms/drivers/omp/config.js} +53 -13
- package/src/{server/services/omp-gateway-routing.js → platforms/drivers/omp/gateway-routing.js} +14 -7
- package/src/{server/services/omp-gateway.js → platforms/drivers/omp/gateway.js} +4 -262
- package/src/platforms/drivers/omp/mcp.js +9 -0
- package/src/{server/services/omp-settings-manager.js → platforms/drivers/omp/native-config-implementation.js} +75 -10
- package/src/platforms/drivers/omp/native-config.js +46 -0
- package/src/platforms/drivers/omp/native-logs.js +52 -0
- package/src/{server/services/omp-native-plugin-adapter.js → platforms/drivers/omp/native-plugin-adapter.js} +91 -4
- package/src/platforms/drivers/omp/project-config.js +29 -0
- package/src/platforms/drivers/omp/projects.js +20 -0
- package/src/platforms/drivers/omp/prompts.js +9 -0
- package/src/{server/omp-proxy-server.js → platforms/drivers/omp/proxy-implementation.js} +6 -15
- package/src/platforms/drivers/omp/proxy.js +16 -0
- package/src/platforms/drivers/omp/resource-sync.js +9 -0
- package/src/{server/services/session-history-adapters/omp.js → platforms/drivers/omp/session-history-adapter.js} +42 -18
- package/src/{server/services/omp-sessions.js → platforms/drivers/omp/sessions-implementation.js} +130 -94
- package/src/platforms/drivers/omp/sessions.js +36 -0
- package/src/{server/services/omp-skill-discovery.js → platforms/drivers/omp/skill-discovery.js} +159 -32
- package/src/{server/services/omp-skill-settings-service.js → platforms/drivers/omp/skill-settings.js} +1 -1
- package/src/{server/services/omp-statistics-service.js → platforms/drivers/omp/statistics-implementation.js} +3 -3
- package/src/platforms/drivers/omp/statistics.js +16 -0
- package/src/platforms/drivers/opencode/api-operations.js +9 -0
- package/src/{server/services/opencode-channels.js → platforms/drivers/opencode/channels-implementation.js} +28 -9
- package/src/platforms/drivers/opencode/channels.js +40 -0
- package/src/platforms/drivers/opencode/conversion.js +41 -0
- package/src/{server/services/opencode-gateway-converter.js → platforms/drivers/opencode/gateway-converter.js} +1 -1
- package/src/platforms/drivers/opencode/mcp.js +9 -0
- package/src/{server/services/opencode-settings-manager.js → platforms/drivers/opencode/native-config-implementation.js} +17 -6
- package/src/platforms/drivers/opencode/native-config.js +26 -0
- package/src/platforms/drivers/opencode/native-logs.js +133 -0
- package/src/platforms/drivers/opencode/project-config.js +98 -0
- package/src/platforms/drivers/opencode/projects.js +20 -0
- package/src/platforms/drivers/opencode/prompts.js +9 -0
- package/src/{server/opencode-proxy-server.js → platforms/drivers/opencode/proxy-implementation.js} +27 -362
- package/src/platforms/drivers/opencode/proxy.js +16 -0
- package/src/platforms/drivers/opencode/resource-sync.js +9 -0
- package/src/{server/services/opencode-sessions.js → platforms/drivers/opencode/sessions-implementation.js} +211 -64
- package/src/platforms/drivers/opencode/sessions.js +48 -0
- package/src/{server/services/opencode-statistics-service.js → platforms/drivers/opencode/statistics-implementation.js} +2 -2
- package/src/platforms/drivers/opencode/statistics.js +16 -0
- package/src/platforms/drivers/secure-file-driver.js +272 -0
- package/src/platforms/drivers/unsupported.js +7 -0
- package/src/platforms/manifest-schema.js +398 -0
- package/src/platforms/manifests/claude.json +489 -0
- package/src/platforms/manifests/codex.json +448 -0
- package/src/platforms/manifests/gemini.json +447 -0
- package/src/platforms/manifests/omp.json +496 -0
- package/src/platforms/manifests/opencode.json +422 -0
- package/src/{server/services → platforms}/native-oauth-adapters.js +87 -417
- package/src/{server/services → platforms}/notification-hooks.js +140 -1023
- package/src/platforms/oauth-credentials-service.js +506 -0
- package/src/platforms/path-resolver.js +179 -0
- package/src/platforms/platform-path-context.js +305 -0
- package/src/platforms/registry.js +248 -0
- package/src/platforms/remote-notification-providers.js +678 -0
- package/src/platforms/runtime.js +259 -0
- package/src/{server/services/session-history-adapters/index.js → platforms/session-history-adapters.js} +8 -1
- package/src/plugins/plugin-loader.js +2 -2
- package/src/plugins/plugin-manager.js +2 -2
- package/src/plugins/registry.js +27 -10
- package/src/reset-config.js +21 -5
- package/src/server/api/agents.js +46 -72
- package/src/server/api/commands.js +16 -6
- package/src/server/api/config-registry.js +206 -59
- package/src/server/api/config-sync.js +3 -2
- package/src/server/api/config-templates.js +20 -4
- package/src/server/api/config.js +111 -102
- package/src/server/api/convert.js +54 -178
- package/src/server/api/dashboard.js +168 -102
- package/src/server/api/hooks.js +1 -1
- package/src/server/api/mcp.js +224 -84
- package/src/server/api/platform-api-config.js +102 -0
- package/src/server/api/platform-route-factory.js +215 -0
- package/src/server/api/platform-routes.js +26 -0
- package/src/server/api/platforms.js +110 -0
- package/src/server/api/plugins.js +57 -57
- package/src/server/api/project-config.js +168 -0
- package/src/server/api/prompts.js +58 -45
- package/src/server/api/settings.js +55 -8
- package/src/server/api/skills.js +262 -133
- package/src/server/api/ui-config.js +2 -2
- package/src/server/api/validation-errors.js +18 -4
- package/src/server/api/workspaces.js +47 -12
- package/src/server/index.js +164 -213
- package/src/server/platform-context.js +81 -0
- package/src/server/services/channel-balance.js +11 -20
- package/src/server/services/channel-health.js +21 -6
- package/src/server/services/channel-scheduler.js +29 -39
- package/src/server/services/channel-sync-utils.js +23 -13
- package/src/server/services/config-export-service.js +350 -319
- package/src/server/services/config-registry-service.js +280 -54
- package/src/server/services/config-sync-manager.js +172 -944
- package/src/server/services/config-templates-service.js +419 -353
- package/src/server/services/control-manifest-store.js +206 -0
- package/src/server/services/dashboard-snapshot-worker.js +656 -100
- package/src/server/services/effective-control-service.js +557 -0
- package/src/server/services/local-resource-index.js +314 -0
- package/src/server/services/mcp-service.js +607 -977
- package/src/server/services/model-detector.js +15 -10
- package/src/server/services/native-log-channel-resolver.js +214 -0
- package/src/server/services/native-log-observer.js +291 -0
- package/src/server/services/network-access.js +1 -1
- package/src/server/services/platform-catalog.js +82 -0
- package/src/server/services/platform-resolution.js +32 -29
- package/src/server/services/plugins-service.js +376 -122
- package/src/server/services/project-config-service.js +550 -0
- package/src/server/services/project-path-validation.js +31 -0
- package/src/server/services/prompts-service.js +267 -233
- package/src/server/services/proxy-runtime.js +7 -4
- package/src/server/services/remote-credential-cache.js +43 -0
- package/src/server/services/repo-scanner-base.js +182 -75
- package/src/server/services/request-logger.js +7 -4
- package/src/server/services/session-history-index.js +780 -213
- package/src/server/services/session-history-worker.js +228 -33
- package/src/server/services/session-snapshot-worker.js +124 -34
- package/src/server/services/session-snapshots.js +4 -2
- package/src/server/services/skill-artifact-store.js +355 -0
- package/src/server/services/skill-format-adapters.js +65 -0
- package/src/server/services/skill-projection-service.js +323 -0
- package/src/server/services/skill-refresh-task-service.js +275 -0
- package/src/server/services/skill-service.js +2020 -677
- package/src/server/services/snapshot-cache.js +30 -8
- package/src/server/services/speed-test.js +8 -8
- package/src/server/services/sqlite-connection.js +19 -3
- package/src/server/services/statistics-service.js +240 -57
- package/src/server/services/ui-config.js +107 -76
- package/src/server/services/usage-log-utils.js +98 -0
- package/src/server/services/web-build.js +1 -1
- package/src/server/services/workspace-service.js +59 -29
- package/src/server/utils/pricing.js +10 -19
- package/src/server/websocket-server.js +153 -28
- package/src/{server/services/base → shared}/base-channel-service.js +156 -28
- package/src/shared/capability-driver.js +104 -0
- package/src/shared/channel-auth-policy.js +27 -0
- package/src/shared/channel-driver.js +161 -0
- package/src/shared/driver-factories/api.js +180 -0
- package/src/shared/driver-factories/mcp.js +244 -0
- package/src/shared/driver-factories/projects.js +121 -0
- package/src/shared/driver-factories/prompts.js +58 -0
- package/src/shared/driver-factories/resource-sync.js +375 -0
- package/src/shared/driver-result.js +78 -0
- package/src/shared/mcp-format.js +189 -0
- package/src/shared/platforms.js +104 -167
- package/src/shared/project-config.js +512 -0
- package/src/shared/proxy-driver.js +57 -0
- package/src/{server/services/base → shared}/response-usage-parser.js +8 -4
- package/src/ui/menu.js +91 -67
- package/src/utils/port-helper.js +35 -19
- package/src/utils/session.js +1 -1
- package/dist/web/assets/Analytics-COEUXmd4.js +0 -25
- package/dist/web/assets/Analytics-RNn1BUbG.css +0 -1
- package/dist/web/assets/ConfigTemplates-DLLkS53H.js +0 -1
- package/dist/web/assets/Home-DCEyLzwX.js +0 -1
- package/dist/web/assets/Home-DYVy4cGZ.css +0 -1
- package/dist/web/assets/PluginManager-Oe1ZHoMO.js +0 -1
- package/dist/web/assets/ProjectList-CWjuAFof.js +0 -1
- package/dist/web/assets/ProjectList-VeMNXfgO.css +0 -1
- package/dist/web/assets/SessionList-C4chCPxK.css +0 -1
- package/dist/web/assets/SessionList-v3ehGg9U.js +0 -1
- package/dist/web/assets/SkillManager-BsX8Qpj0.css +0 -1
- package/dist/web/assets/SkillManager-DUF_qP5S.js +0 -1
- package/dist/web/assets/WorkspaceManager-CjAWBosO.js +0 -1
- package/dist/web/assets/icons-nGdSKQn2.js +0 -1
- package/dist/web/assets/index-D5hyHPj7.js +0 -2
- package/dist/web/assets/index-bJRG3RXH.css +0 -1
- package/dist/web/assets/markdown-BNJfEgCA.js +0 -1
- package/dist/web/assets/markdown-BfC0goYb.css +0 -10
- package/dist/web/assets/naive-ui-BALVpMgd.js +0 -1
- package/dist/web/assets/vendors-DQA4Hw9v.js +0 -7
- package/dist/web/assets/vue-vendor-B5RqjEjQ.js +0 -45
- package/src/config/model-pricing.js +0 -35
- package/src/server/api/channels.js +0 -439
- package/src/server/api/claude-hooks.js +0 -56
- package/src/server/api/claude-statistics.js +0 -57
- package/src/server/api/codex-channels.js +0 -491
- package/src/server/api/codex-projects.js +0 -117
- package/src/server/api/codex-proxy.js +0 -293
- package/src/server/api/codex-sessions.js +0 -652
- package/src/server/api/codex-statistics.js +0 -57
- package/src/server/api/gemini-channels.js +0 -392
- package/src/server/api/gemini-projects.js +0 -103
- package/src/server/api/gemini-proxy.js +0 -231
- package/src/server/api/gemini-sessions.js +0 -550
- package/src/server/api/gemini-statistics.js +0 -57
- package/src/server/api/health-check.js +0 -31
- package/src/server/api/oauth-credentials.js +0 -198
- package/src/server/api/omp-channels.js +0 -575
- package/src/server/api/omp-projects.js +0 -88
- package/src/server/api/omp-proxy.js +0 -125
- package/src/server/api/omp-sessions.js +0 -386
- package/src/server/api/omp-statistics.js +0 -40
- package/src/server/api/opencode-channels.js +0 -471
- package/src/server/api/opencode-projects.js +0 -110
- package/src/server/api/opencode-proxy.js +0 -354
- package/src/server/api/opencode-sessions.js +0 -466
- package/src/server/api/opencode-statistics.js +0 -57
- package/src/server/api/projects.js +0 -120
- package/src/server/api/proxy.js +0 -330
- package/src/server/api/sessions.js +0 -810
- package/src/server/services/oauth-credentials-service.js +0 -945
- package/src/server/services/omp-session-log-observer.js +0 -138
- package/src/server/services/opencode-gateway-adapters.js +0 -43
- package/src/server/services/project-snapshots.js +0 -59
- package/src/server/services/proxy-log-helper.js +0 -298
- package/src/server/services/session-cache.js +0 -127
- package/src/server/services/session-converter.js +0 -582
- package/src/server/services/session-history-adapters/claude.js +0 -235
- /package/src/{server/services/claude-token-recovery.js → platforms/drivers/claude/token-recovery.js} +0 -0
- /package/src/{server/services/codex-parser.js → platforms/drivers/codex/parser.js} +0 -0
- /package/src/{server/services/codex-speed-test-template.json → platforms/drivers/codex/speed-test-template.json} +0 -0
- /package/src/{server/services/codex-wire.js → platforms/drivers/codex/wire.js} +0 -0
- /package/src/{server/services/omp-auth-gateway-client.js → platforms/drivers/omp/auth-gateway-client.js} +0 -0
- /package/src/{server/services/opencode-normalization.js → platforms/drivers/opencode/normalization.js} +0 -0
- /package/src/{server/services → shared}/config-artifact-paths.js +0 -0
- /package/src/{server/services/base → shared}/proxy-utils.js +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { ok, unsupported, failed } = require('../driver-result');
|
|
4
|
+
|
|
5
|
+
function createProjectsDriver({
|
|
6
|
+
platform,
|
|
7
|
+
servicePath,
|
|
8
|
+
localServicePath,
|
|
9
|
+
requireImpl,
|
|
10
|
+
availabilityMethod = null,
|
|
11
|
+
availabilityCheck = null,
|
|
12
|
+
createProject,
|
|
13
|
+
onSuccess,
|
|
14
|
+
...context
|
|
15
|
+
} = {}) {
|
|
16
|
+
let service;
|
|
17
|
+
|
|
18
|
+
const loadService = () => {
|
|
19
|
+
if (service) return service;
|
|
20
|
+
service = requireImpl ? requireImpl(servicePath) : require(localServicePath);
|
|
21
|
+
service.configure?.({ ...context, platform, capability: 'projects' });
|
|
22
|
+
return service;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const configFor = options => platform === 'claude'
|
|
26
|
+
? options?.config || {}
|
|
27
|
+
: options || {};
|
|
28
|
+
|
|
29
|
+
const invoke = (operation, methodName, args) => {
|
|
30
|
+
try {
|
|
31
|
+
const target = loadService();
|
|
32
|
+
if (typeof target?.[methodName] !== 'function') {
|
|
33
|
+
return unsupported(platform, 'projects', operation);
|
|
34
|
+
}
|
|
35
|
+
const value = target[methodName](...args);
|
|
36
|
+
const wrap = result => {
|
|
37
|
+
if (typeof onSuccess === 'function') onSuccess(operation, result);
|
|
38
|
+
return ok(platform, 'projects', operation, result);
|
|
39
|
+
};
|
|
40
|
+
return value && typeof value.then === 'function'
|
|
41
|
+
? value.then(wrap).catch(error => failed(platform, 'projects', operation, error))
|
|
42
|
+
: wrap(value);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return failed(platform, 'projects', operation, error);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const invokeCustom = (operation, callback, args) => {
|
|
49
|
+
try {
|
|
50
|
+
const value = callback(...args);
|
|
51
|
+
const wrap = result => {
|
|
52
|
+
if (typeof onSuccess === 'function') onSuccess(operation, result);
|
|
53
|
+
return ok(platform, 'projects', operation, result);
|
|
54
|
+
};
|
|
55
|
+
return value && typeof value.then === 'function'
|
|
56
|
+
? value.then(wrap).catch(error => failed(platform, 'projects', operation, error))
|
|
57
|
+
: wrap(value);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
return failed(platform, 'projects', operation, error);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const driver = {
|
|
64
|
+
platform,
|
|
65
|
+
capability: 'projects',
|
|
66
|
+
...context,
|
|
67
|
+
listProjects(options = {}) {
|
|
68
|
+
const normalizedOptions = options || {};
|
|
69
|
+
if (platform === 'claude') {
|
|
70
|
+
const target = loadService();
|
|
71
|
+
if (typeof target?.getProjectsWithStats === 'function') {
|
|
72
|
+
return invoke('listProjects', 'getProjectsWithStats', [configFor(normalizedOptions), normalizedOptions]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return invoke('listProjects', 'getProjects', [configFor(normalizedOptions)]);
|
|
76
|
+
},
|
|
77
|
+
getProjectOrder(options = {}) {
|
|
78
|
+
return invoke('getProjectOrder', 'getProjectOrder', [configFor(options)]);
|
|
79
|
+
},
|
|
80
|
+
getProjectAndSessionCounts(options = {}) {
|
|
81
|
+
const args = platform === 'claude' ? [configFor(options), options] : [options];
|
|
82
|
+
return invoke('getProjectAndSessionCounts', 'getProjectAndSessionCounts', args);
|
|
83
|
+
},
|
|
84
|
+
counts(options = {}) {
|
|
85
|
+
return this.getProjectAndSessionCounts(options);
|
|
86
|
+
},
|
|
87
|
+
saveProjectOrder(order, options = {}) {
|
|
88
|
+
const args = platform === 'claude' ? [configFor(options), order] : [order];
|
|
89
|
+
return invoke('saveProjectOrder', 'saveProjectOrder', args);
|
|
90
|
+
},
|
|
91
|
+
deleteProject(projectId, options = {}) {
|
|
92
|
+
const args = platform === 'claude' ? [configFor(options), projectId] : [projectId];
|
|
93
|
+
return invoke('deleteProject', 'deleteProject', args);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
if (availabilityMethod) {
|
|
97
|
+
driver.isAvailable = (options = {}) => invoke(
|
|
98
|
+
'isAvailable',
|
|
99
|
+
availabilityMethod,
|
|
100
|
+
platform === 'claude' ? [configFor(options)] : [options]
|
|
101
|
+
);
|
|
102
|
+
} else if (typeof availabilityCheck === 'function') {
|
|
103
|
+
driver.isAvailable = (options = {}) => invokeCustom(
|
|
104
|
+
'isAvailable',
|
|
105
|
+
availabilityCheck,
|
|
106
|
+
[options]
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (typeof createProject === 'function') {
|
|
111
|
+
driver.createProject = (input = {}, options = {}) => invokeCustom(
|
|
112
|
+
'createProject',
|
|
113
|
+
createProject,
|
|
114
|
+
[input, options]
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return driver;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = { createProjectsDriver };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { ok, failed } = require('../driver-result');
|
|
7
|
+
|
|
8
|
+
function createPromptDriver({ platform, ...context } = {}) {
|
|
9
|
+
const { NATIVE_PATHS } = require('../../config/paths');
|
|
10
|
+
const { resolvePreferredHomeDir } = require('../../utils/home-dir');
|
|
11
|
+
const pathContext = context.pathContext || {};
|
|
12
|
+
const home = pathContext.home || resolvePreferredHomeDir(process.platform, process.env, os.homedir());
|
|
13
|
+
const configuredNative = pathContext.native || {};
|
|
14
|
+
const native = configuredNative[platform]
|
|
15
|
+
? configuredNative[platform]
|
|
16
|
+
: configuredNative;
|
|
17
|
+
const legacyNative = NATIVE_PATHS || {};
|
|
18
|
+
const claudeDir = native.dir || legacyNative.claude?.dir || path.dirname(legacyNative.claude?.settings || '') || path.join(home, '.claude');
|
|
19
|
+
const paths = {
|
|
20
|
+
claude: native.prompt || legacyNative.claude?.prompt || path.join(claudeDir, 'CLAUDE.md'),
|
|
21
|
+
codex: native.prompt || legacyNative.codex?.prompt || path.join(native.dir || legacyNative.codex?.dir || path.join(home, '.codex'), 'AGENTS.md'),
|
|
22
|
+
gemini: native.prompt || legacyNative.gemini?.prompt || path.join(native.dir || legacyNative.gemini?.dir || path.join(home, '.gemini'), 'GEMINI.md'),
|
|
23
|
+
opencode: native.prompt || legacyNative.opencode?.prompt || path.join(native.config || legacyNative.opencode?.config || path.join(home, '.config', 'opencode'), 'AGENTS.md'),
|
|
24
|
+
omp: native.prompt || legacyNative.omp?.prompt || path.join(native.dir || legacyNative.omp?.dir || path.join(home, '.omp', 'agent'), 'AGENTS.md')
|
|
25
|
+
};
|
|
26
|
+
const promptPath = paths[platform] || native.prompt;
|
|
27
|
+
if (!promptPath) throw new Error(`Prompt path is not configured for ${platform}`);
|
|
28
|
+
const read = () => fs.existsSync(promptPath) ? fs.readFileSync(promptPath, 'utf8') : '';
|
|
29
|
+
const write = content => {
|
|
30
|
+
if (typeof content !== 'string') throw new Error('提示词内容必须是字符串');
|
|
31
|
+
fs.mkdirSync(path.dirname(promptPath), { recursive: true });
|
|
32
|
+
fs.writeFileSync(promptPath, content, 'utf8');
|
|
33
|
+
return content;
|
|
34
|
+
};
|
|
35
|
+
const remove = () => {
|
|
36
|
+
if (!fs.existsSync(promptPath)) return true;
|
|
37
|
+
fs.unlinkSync(promptPath);
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
const invoke = (operation, args) => {
|
|
41
|
+
try {
|
|
42
|
+
const value = { read, write, remove }[operation](...args);
|
|
43
|
+
return ok(platform, 'prompts', operation, value);
|
|
44
|
+
} catch (error) {
|
|
45
|
+
return failed(platform, 'prompts', operation, error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
platform,
|
|
50
|
+
capability: 'prompts',
|
|
51
|
+
path: promptPath,
|
|
52
|
+
read: (...args) => invoke('read', args),
|
|
53
|
+
write: (...args) => invoke('write', args),
|
|
54
|
+
remove: (...args) => invoke('remove', args)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = { createPromptDriver };
|
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const toml = require('@iarna/toml');
|
|
7
|
+
const tomlStringify = require('@iarna/toml').stringify;
|
|
8
|
+
const { ok, failed } = require('../driver-result');
|
|
9
|
+
const { assertNoSymlinkComponents } = require('../project-config');
|
|
10
|
+
|
|
11
|
+
const CONFIG_TYPES = {
|
|
12
|
+
skills: {
|
|
13
|
+
isDirectory: true,
|
|
14
|
+
markerFile: 'SKILL.md',
|
|
15
|
+
claudeTarget: 'skills',
|
|
16
|
+
codexTarget: 'skills',
|
|
17
|
+
codexSupported: true,
|
|
18
|
+
geminiTarget: 'skills',
|
|
19
|
+
geminiSupported: true,
|
|
20
|
+
opencodeTarget: 'skills',
|
|
21
|
+
opencodeLegacyTarget: 'skill',
|
|
22
|
+
opencodeSupported: true,
|
|
23
|
+
ompTarget: 'skills',
|
|
24
|
+
ompSupported: true
|
|
25
|
+
},
|
|
26
|
+
commands: {
|
|
27
|
+
isDirectory: false,
|
|
28
|
+
extension: '.md',
|
|
29
|
+
claudeTarget: 'commands',
|
|
30
|
+
codexTarget: 'prompts',
|
|
31
|
+
codexSupported: true,
|
|
32
|
+
geminiTarget: 'commands',
|
|
33
|
+
geminiExtension: '.toml',
|
|
34
|
+
geminiSupported: true,
|
|
35
|
+
opencodeTarget: 'commands',
|
|
36
|
+
opencodeLegacyTarget: 'command',
|
|
37
|
+
opencodeSupported: true,
|
|
38
|
+
ompTarget: 'commands',
|
|
39
|
+
ompSupported: true
|
|
40
|
+
},
|
|
41
|
+
agents: {
|
|
42
|
+
isDirectory: false,
|
|
43
|
+
extension: '.md',
|
|
44
|
+
claudeTarget: 'agents',
|
|
45
|
+
codexSupported: true,
|
|
46
|
+
geminiTarget: 'agents',
|
|
47
|
+
geminiSupported: true,
|
|
48
|
+
opencodeTarget: 'agents',
|
|
49
|
+
opencodeLegacyTarget: 'agent',
|
|
50
|
+
opencodeSupported: true,
|
|
51
|
+
ompSupported: false
|
|
52
|
+
},
|
|
53
|
+
plugins: {
|
|
54
|
+
isDirectory: true,
|
|
55
|
+
claudeTarget: 'plugins',
|
|
56
|
+
codexSupported: false,
|
|
57
|
+
geminiSupported: false,
|
|
58
|
+
opencodeTarget: 'plugins',
|
|
59
|
+
opencodeLegacyTarget: 'plugin',
|
|
60
|
+
opencodeSupported: true,
|
|
61
|
+
ompTarget: 'extensions',
|
|
62
|
+
ompSupported: true
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function normalizeSafeRelativeName(name) {
|
|
67
|
+
const raw = String(name || '').replace(/\\/g, '/').trim();
|
|
68
|
+
if (!raw || raw.includes('\0') || path.isAbsolute(raw) || raw.startsWith('/')) return null;
|
|
69
|
+
const normalized = path.posix.normalize(raw).replace(/^(\.\/)+/, '');
|
|
70
|
+
return normalized && normalized !== '.' && normalized !== '..' && !normalized.startsWith('../') ? normalized : null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function ensureDir(dir) {
|
|
74
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function copyDirRecursive(src, dest) {
|
|
78
|
+
ensureDir(dest);
|
|
79
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
80
|
+
const source = path.join(src, entry.name);
|
|
81
|
+
const target = path.join(dest, entry.name);
|
|
82
|
+
if (entry.isDirectory()) copyDirRecursive(source, target);
|
|
83
|
+
else fs.copyFileSync(source, target);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function copyDirWithConversion(src, dest, transform) {
|
|
88
|
+
ensureDir(dest);
|
|
89
|
+
const textExtensions = new Set(['.md', '.txt', '.json', '.js', '.ts', '.py', '.sh', '.yaml', '.yml']);
|
|
90
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
91
|
+
const source = path.join(src, entry.name);
|
|
92
|
+
const target = path.join(dest, entry.name);
|
|
93
|
+
if (entry.isDirectory()) {
|
|
94
|
+
copyDirWithConversion(source, target, transform);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (!textExtensions.has(path.extname(entry.name).toLowerCase())) {
|
|
98
|
+
fs.copyFileSync(source, target);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
fs.writeFileSync(target, transform(source, fs.readFileSync(source, 'utf8')), 'utf8');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function removeRecursive(target) {
|
|
106
|
+
if (fs.existsSync(target)) fs.rmSync(target, { recursive: true, force: true });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function cleanupEmptyParents(dir, baseDir) {
|
|
110
|
+
const normalizedDir = path.resolve(dir);
|
|
111
|
+
const normalizedBase = path.resolve(baseDir);
|
|
112
|
+
if (!normalizedDir.startsWith(`${normalizedBase}${path.sep}`)) return;
|
|
113
|
+
try {
|
|
114
|
+
if (fs.readdirSync(dir).length === 0) {
|
|
115
|
+
fs.rmdirSync(dir);
|
|
116
|
+
cleanupEmptyParents(path.dirname(dir), baseDir);
|
|
117
|
+
}
|
|
118
|
+
} catch (_) {
|
|
119
|
+
// The target may have disappeared concurrently.
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function parseFrontmatter(content) {
|
|
124
|
+
const result = { frontmatter: {}, body: content };
|
|
125
|
+
const normalized = content.trim().replace(/^\uFEFF/, '');
|
|
126
|
+
const match = normalized.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);
|
|
127
|
+
if (!match) return result;
|
|
128
|
+
result.body = match[2].trim();
|
|
129
|
+
for (const line of match[1].split('\n')) {
|
|
130
|
+
const colonIndex = line.indexOf(':');
|
|
131
|
+
if (colonIndex === -1) continue;
|
|
132
|
+
const key = line.slice(0, colonIndex).trim();
|
|
133
|
+
let value = line.slice(colonIndex + 1).trim();
|
|
134
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
135
|
+
value = value.slice(1, -1);
|
|
136
|
+
}
|
|
137
|
+
result.frontmatter[key] = value;
|
|
138
|
+
}
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function isPlainObject(value) {
|
|
143
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function createResourceSyncDriver({ platform, configTypes = CONFIG_TYPES, resourcePaths = {}, ...context } = {}) {
|
|
147
|
+
const { PATHS, NATIVE_PATHS, HOME_DIR } = require('../../config/paths');
|
|
148
|
+
const pathContext = context.pathContext || {};
|
|
149
|
+
const home = pathContext.home || HOME_DIR || os.homedir();
|
|
150
|
+
const configuredNative = pathContext.native || {};
|
|
151
|
+
const native = configuredNative[platform]
|
|
152
|
+
? configuredNative
|
|
153
|
+
: { ...(NATIVE_PATHS || {}), [platform]: configuredNative };
|
|
154
|
+
const claudeNative = native.claude || {};
|
|
155
|
+
const codexNative = native.codex || {};
|
|
156
|
+
const geminiNative = native.gemini || {};
|
|
157
|
+
const opencodeNative = native.opencode || {};
|
|
158
|
+
const ompNative = native.omp || {};
|
|
159
|
+
const claudeDir = claudeNative.dir || path.dirname(claudeNative.settings || '') || path.join(home, '.claude');
|
|
160
|
+
const codexDir = codexNative.dir || path.dirname(codexNative.config || '') || path.join(home, '.codex');
|
|
161
|
+
const geminiDir = geminiNative.dir || path.dirname(geminiNative.settings || '') || path.join(home, '.gemini');
|
|
162
|
+
const opencodeDir = opencodeNative.config || path.join(home, '.config', 'opencode');
|
|
163
|
+
const ompDir = ompNative.dir || path.join(home, '.omp', 'agent');
|
|
164
|
+
const codexConfigPath = codexNative.config || path.join(codexDir, 'config.toml');
|
|
165
|
+
const config = {
|
|
166
|
+
home,
|
|
167
|
+
configs: PATHS.configs,
|
|
168
|
+
skillArtifacts: PATHS.skillArtifacts,
|
|
169
|
+
claudeDir,
|
|
170
|
+
codexDir,
|
|
171
|
+
geminiDir,
|
|
172
|
+
opencodeDir,
|
|
173
|
+
ompDir,
|
|
174
|
+
codexConfigPath,
|
|
175
|
+
...resourcePaths
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const getType = type => configTypes[type];
|
|
179
|
+
const isSupported = typeConfig => typeConfig && typeConfig[`${platform}Supported`] !== false;
|
|
180
|
+
const resolveSourcePath = (type, safeName, sourcePathOverride) => {
|
|
181
|
+
const sourcePath = sourcePathOverride ? path.resolve(sourcePathOverride) : path.join(config.configs, type, safeName);
|
|
182
|
+
const allowedRoots = [path.join(config.configs, type), config.skillArtifacts]
|
|
183
|
+
.filter(Boolean)
|
|
184
|
+
.map(root => path.resolve(root));
|
|
185
|
+
const allowedRoot = allowedRoots.find(root => sourcePath === root || sourcePath.startsWith(`${root}${path.sep}`));
|
|
186
|
+
if (!allowedRoot) throw new Error('Controlled source path escapes allowed storage');
|
|
187
|
+
assertNoSymlinkComponents(allowedRoot, sourcePath, fs);
|
|
188
|
+
if (sourcePathOverride && !fs.existsSync(sourcePath)) throw new Error('Controlled source path not found');
|
|
189
|
+
return sourcePath;
|
|
190
|
+
};
|
|
191
|
+
const readCodexConfig = () => fs.existsSync(config.codexConfigPath) ? toml.parse(fs.readFileSync(config.codexConfigPath, 'utf8')) : {};
|
|
192
|
+
const writeCodexConfig = value => {
|
|
193
|
+
ensureDir(path.dirname(config.codexConfigPath));
|
|
194
|
+
const tempPath = `${config.codexConfigPath}.tmp-${process.pid}-${Date.now()}`;
|
|
195
|
+
fs.writeFileSync(tempPath, tomlStringify(value), 'utf8');
|
|
196
|
+
fs.renameSync(tempPath, config.codexConfigPath);
|
|
197
|
+
};
|
|
198
|
+
const resolveCodexPath = value => {
|
|
199
|
+
const normalized = typeof value === 'string' ? value.trim() : '';
|
|
200
|
+
if (!normalized) return '';
|
|
201
|
+
if (normalized.startsWith('~/')) return path.join(config.home, normalized.slice(2));
|
|
202
|
+
return path.isAbsolute(normalized) ? normalized : path.resolve(path.dirname(config.codexConfigPath), normalized);
|
|
203
|
+
};
|
|
204
|
+
const managedCodexDir = () => path.join(config.codexDir, 'agents');
|
|
205
|
+
const managedCodexPath = name => path.join(managedCodexDir(), `${name}.toml`);
|
|
206
|
+
const isManagedCodexPath = value => {
|
|
207
|
+
const resolved = resolveCodexPath(value);
|
|
208
|
+
if (!resolved) return false;
|
|
209
|
+
const root = path.resolve(managedCodexDir());
|
|
210
|
+
return resolved === root || resolved.startsWith(`${root}${path.sep}`);
|
|
211
|
+
};
|
|
212
|
+
const readCodexAgentConfig = value => {
|
|
213
|
+
const resolved = resolveCodexPath(value);
|
|
214
|
+
if (!resolved || !fs.existsSync(resolved)) return null;
|
|
215
|
+
const content = fs.readFileSync(resolved, 'utf8');
|
|
216
|
+
try { return { content, data: toml.parse(content) }; } catch (_) { return { content, data: null }; }
|
|
217
|
+
};
|
|
218
|
+
const writeCodexAgentConfig = (value, data) => {
|
|
219
|
+
const resolved = resolveCodexPath(value);
|
|
220
|
+
ensureDir(path.dirname(resolved));
|
|
221
|
+
const tempPath = `${resolved}.tmp-${process.pid}-${Date.now()}`;
|
|
222
|
+
fs.writeFileSync(tempPath, tomlStringify(data), 'utf8');
|
|
223
|
+
fs.renameSync(tempPath, resolved);
|
|
224
|
+
};
|
|
225
|
+
const converter = () => require('../../server/services/format-converter');
|
|
226
|
+
const escapeRegExp = value => String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
227
|
+
|
|
228
|
+
function targetBasePath(type, typeConfig) {
|
|
229
|
+
if (platform === 'claude') return path.join(config.claudeDir, typeConfig.claudeTarget);
|
|
230
|
+
if (platform === 'codex') return path.join(config.codexDir, typeConfig.codexTarget);
|
|
231
|
+
if (platform === 'gemini') return path.join(config.geminiDir, typeConfig.geminiTarget);
|
|
232
|
+
if (platform === 'opencode') {
|
|
233
|
+
const modern = path.join(config.opencodeDir, typeConfig.opencodeTarget);
|
|
234
|
+
if (type === 'skills' || !typeConfig.opencodeLegacyTarget) return modern;
|
|
235
|
+
const legacy = path.join(config.opencodeDir, typeConfig.opencodeLegacyTarget);
|
|
236
|
+
return fs.existsSync(legacy) && !fs.existsSync(modern) ? legacy : modern;
|
|
237
|
+
}
|
|
238
|
+
return path.join(config.ompDir, typeConfig.ompTarget);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function targetPath(type, safeName) {
|
|
242
|
+
const typeConfig = getType(type);
|
|
243
|
+
if (platform === 'gemini' && typeConfig.geminiExtension) {
|
|
244
|
+
const extension = path.extname(safeName);
|
|
245
|
+
const targetName = safeName.replace(new RegExp(`${escapeRegExp(extension)}$`, 'i'), typeConfig.geminiExtension);
|
|
246
|
+
return path.join(targetBasePath(type, typeConfig), targetName);
|
|
247
|
+
}
|
|
248
|
+
return path.join(targetBasePath(type, typeConfig), safeName);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function syncCodex(type, safeName, sourcePath) {
|
|
252
|
+
const warnings = [];
|
|
253
|
+
if (type === 'agents') {
|
|
254
|
+
const { frontmatter } = parseFrontmatter(fs.readFileSync(sourcePath, 'utf8'));
|
|
255
|
+
const fileName = path.basename(safeName, path.extname(safeName));
|
|
256
|
+
const codexConfig = readCodexConfig();
|
|
257
|
+
codexConfig.features = isPlainObject(codexConfig.features) ? codexConfig.features : {};
|
|
258
|
+
codexConfig.features.multi_agent = true;
|
|
259
|
+
codexConfig.agents = isPlainObject(codexConfig.agents) ? codexConfig.agents : {};
|
|
260
|
+
const existing = codexConfig.agents[fileName];
|
|
261
|
+
if (Object.prototype.hasOwnProperty.call(codexConfig.agents, fileName) && !isPlainObject(existing)) {
|
|
262
|
+
return { success: false, error: `Agent name "${fileName}" conflicts with global [agents] key` };
|
|
263
|
+
}
|
|
264
|
+
const entry = isPlainObject(existing) ? { ...existing } : {};
|
|
265
|
+
entry.description = (frontmatter.description || fileName).trim();
|
|
266
|
+
const model = typeof frontmatter.model === 'string' ? frontmatter.model.trim() : '';
|
|
267
|
+
const existingConfigFile = typeof entry.config_file === 'string' ? entry.config_file.trim() : '';
|
|
268
|
+
if (model) {
|
|
269
|
+
const managedPath = isManagedCodexPath(existingConfigFile) ? existingConfigFile : managedCodexPath(fileName);
|
|
270
|
+
const parsed = readCodexAgentConfig(managedPath);
|
|
271
|
+
const data = isPlainObject(parsed?.data) ? parsed.data : {};
|
|
272
|
+
data.model = model;
|
|
273
|
+
writeCodexAgentConfig(managedPath, data);
|
|
274
|
+
entry.config_file = managedPath;
|
|
275
|
+
} else if (isManagedCodexPath(existingConfigFile)) {
|
|
276
|
+
const resolved = resolveCodexPath(existingConfigFile);
|
|
277
|
+
if (resolved && fs.existsSync(resolved)) fs.unlinkSync(resolved);
|
|
278
|
+
delete entry.config_file;
|
|
279
|
+
}
|
|
280
|
+
codexConfig.agents[fileName] = entry;
|
|
281
|
+
writeCodexConfig(codexConfig);
|
|
282
|
+
return { success: true, target: config.codexConfigPath, warnings };
|
|
283
|
+
}
|
|
284
|
+
if (type === 'skills') {
|
|
285
|
+
const target = targetPath(type, safeName);
|
|
286
|
+
copyDirWithConversion(sourcePath, target, (filePath, content) => {
|
|
287
|
+
if (path.basename(filePath) !== 'SKILL.md') return content;
|
|
288
|
+
const result = converter().convertSkillToCodex(content);
|
|
289
|
+
warnings.push(...(result.warnings || []));
|
|
290
|
+
return result.content;
|
|
291
|
+
});
|
|
292
|
+
return { success: true, target, warnings };
|
|
293
|
+
}
|
|
294
|
+
if (type === 'commands') {
|
|
295
|
+
const result = converter().convertCommandToCodex(fs.readFileSync(sourcePath, 'utf8'));
|
|
296
|
+
warnings.push(...(result.warnings || []));
|
|
297
|
+
const target = targetPath(type, safeName);
|
|
298
|
+
ensureDir(path.dirname(target));
|
|
299
|
+
fs.writeFileSync(target, result.content, 'utf8');
|
|
300
|
+
return { success: true, target, warnings };
|
|
301
|
+
}
|
|
302
|
+
return { success: false, error: 'Unexpected type' };
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function sync(type, name, sourcePathOverride = null) {
|
|
306
|
+
const typeConfig = getType(type);
|
|
307
|
+
if (!typeConfig) return { success: false, error: `Unknown config type: ${type}` };
|
|
308
|
+
if (!isSupported(typeConfig)) {
|
|
309
|
+
const reason = platform === 'omp' ? 'Not supported natively by OMP' : `Not supported by ${platform}`;
|
|
310
|
+
return { success: true, skipped: true, reason };
|
|
311
|
+
}
|
|
312
|
+
const safeName = normalizeSafeRelativeName(name);
|
|
313
|
+
if (!safeName) return { success: false, error: 'Invalid config item name' };
|
|
314
|
+
const sourcePath = resolveSourcePath(type, safeName, sourcePathOverride);
|
|
315
|
+
if (!fs.existsSync(sourcePath)) return { success: false, error: 'Source not found' };
|
|
316
|
+
if (platform === 'codex') return syncCodex(type, safeName, sourcePath);
|
|
317
|
+
const target = targetPath(type, safeName);
|
|
318
|
+
ensureDir(path.dirname(target));
|
|
319
|
+
if (typeConfig.isDirectory) copyDirRecursive(sourcePath, target);
|
|
320
|
+
else if (platform === 'gemini' && type === 'commands') {
|
|
321
|
+
const result = converter().convertCommandToGemini(fs.readFileSync(sourcePath, 'utf8'));
|
|
322
|
+
fs.writeFileSync(target, result.content, 'utf8');
|
|
323
|
+
return { success: true, target, warnings: result.warnings || [] };
|
|
324
|
+
} else fs.copyFileSync(sourcePath, target);
|
|
325
|
+
return { success: true, target };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function remove(type, name) {
|
|
329
|
+
const typeConfig = getType(type);
|
|
330
|
+
if (!typeConfig) return { success: false, error: `Unknown config type: ${type}` };
|
|
331
|
+
if (!isSupported(typeConfig)) {
|
|
332
|
+
const reason = platform === 'omp' ? 'Not supported natively by OMP' : `Not supported by ${platform}`;
|
|
333
|
+
return { success: true, skipped: true, reason };
|
|
334
|
+
}
|
|
335
|
+
const safeName = normalizeSafeRelativeName(name);
|
|
336
|
+
if (!safeName) return { success: false, error: 'Invalid config item name' };
|
|
337
|
+
if (platform === 'codex' && type === 'agents') {
|
|
338
|
+
const codexConfig = readCodexConfig();
|
|
339
|
+
const agents = isPlainObject(codexConfig.agents) ? codexConfig.agents : {};
|
|
340
|
+
const fileName = path.basename(safeName, path.extname(safeName));
|
|
341
|
+
const existing = agents[fileName];
|
|
342
|
+
if (!isPlainObject(existing)) return { success: true, message: 'Already removed' };
|
|
343
|
+
if (existing.config_file && isManagedCodexPath(existing.config_file)) {
|
|
344
|
+
const resolved = resolveCodexPath(existing.config_file);
|
|
345
|
+
if (resolved && fs.existsSync(resolved)) fs.unlinkSync(resolved);
|
|
346
|
+
}
|
|
347
|
+
delete agents[fileName];
|
|
348
|
+
codexConfig.agents = agents;
|
|
349
|
+
writeCodexConfig(codexConfig);
|
|
350
|
+
return { success: true };
|
|
351
|
+
}
|
|
352
|
+
const target = targetPath(type, safeName);
|
|
353
|
+
if (!fs.existsSync(target)) return { success: true, message: 'Already removed' };
|
|
354
|
+
if (typeConfig.isDirectory) removeRecursive(target);
|
|
355
|
+
else {
|
|
356
|
+
fs.unlinkSync(target);
|
|
357
|
+
cleanupEmptyParents(path.dirname(target), targetBasePath(type, typeConfig));
|
|
358
|
+
}
|
|
359
|
+
return { success: true };
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
const invoke = (operation, args) => {
|
|
363
|
+
try {
|
|
364
|
+
const value = operation === 'sync' ? sync(...args) : remove(...args);
|
|
365
|
+
const wrap = data => ok(platform, 'resourceSync', operation, data);
|
|
366
|
+
return value && typeof value.then === 'function' ? value.then(wrap).catch(error => failed(platform, 'resourceSync', operation, error)) : wrap(value);
|
|
367
|
+
} catch (error) {
|
|
368
|
+
return failed(platform, 'resourceSync', operation, error);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
return { platform, capability: 'resourceSync', ...context, sync: (...args) => invoke('sync', args), remove: (...args) => invoke('remove', args) };
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
module.exports = { CONFIG_TYPES, createResourceSyncDriver, normalizeSafeRelativeName };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function createDriverResult({ platform, capability, operation, status = 'ok', data, error, cause } = {}) {
|
|
4
|
+
const result = { status, platform, capability, operation };
|
|
5
|
+
if (status === 'ok' && data !== undefined) result.data = data;
|
|
6
|
+
if (error) result.error = error instanceof Error ? error.message : String(error);
|
|
7
|
+
if (cause) Object.defineProperty(result, 'cause', { value: cause, enumerable: false });
|
|
8
|
+
return result;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function normalizeDriverResult(value, context = {}) {
|
|
12
|
+
if (value && typeof value === 'object' && typeof value.status === 'string') {
|
|
13
|
+
const result = {
|
|
14
|
+
...value,
|
|
15
|
+
platform: value.platform || context.platform,
|
|
16
|
+
capability: value.capability || context.capability,
|
|
17
|
+
operation: value.operation || context.operation
|
|
18
|
+
};
|
|
19
|
+
if (value.cause) Object.defineProperty(result, 'cause', { value: value.cause, enumerable: false });
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return createDriverResult({ ...context, status: 'ok', data: value });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function driverError(result, fallback = 'Driver operation failed') {
|
|
26
|
+
if (!result || typeof result !== 'object' || !result.status || result.status === 'ok') return null;
|
|
27
|
+
if (result.cause instanceof Error) return result.cause;
|
|
28
|
+
const error = new Error(result.error || fallback);
|
|
29
|
+
error.status = result.status;
|
|
30
|
+
error.platform = result.platform;
|
|
31
|
+
error.capability = result.capability;
|
|
32
|
+
error.operation = result.operation;
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function unwrapDriverResult(result, context = {}) {
|
|
37
|
+
const normalized = normalizeDriverResult(result, context);
|
|
38
|
+
const error = driverError(normalized, `Driver operation ${normalized.operation || 'unknown'} failed`);
|
|
39
|
+
if (error) throw error;
|
|
40
|
+
return normalized.status === 'ok' ? normalized.data : normalized;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function invokeDriverOperation(driver, operation, args = [], context = {}) {
|
|
44
|
+
if (!driver || typeof driver[operation] !== 'function') {
|
|
45
|
+
return createDriverResult({ ...context, operation, status: 'unsupported' });
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const value = await driver[operation](...args);
|
|
49
|
+
return normalizeDriverResult(value, { ...context, operation });
|
|
50
|
+
} catch (error) {
|
|
51
|
+
return createDriverResult({ ...context, operation, status: 'failed', error, cause: error });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const ok = (platform, capability, operation, data) => createDriverResult({
|
|
56
|
+
platform, capability, operation, status: 'ok', data
|
|
57
|
+
});
|
|
58
|
+
const unsupported = (platform, capability, operation) => createDriverResult({
|
|
59
|
+
platform, capability, operation, status: 'unsupported'
|
|
60
|
+
});
|
|
61
|
+
const invalid = (platform, capability, operation, error) => createDriverResult({
|
|
62
|
+
platform, capability, operation, status: 'invalid', error, cause: error
|
|
63
|
+
});
|
|
64
|
+
const failed = (platform, capability, operation, error) => createDriverResult({
|
|
65
|
+
platform, capability, operation, status: 'failed', error, cause: error
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
module.exports = {
|
|
69
|
+
createDriverResult,
|
|
70
|
+
normalizeDriverResult,
|
|
71
|
+
driverError,
|
|
72
|
+
unwrapDriverResult,
|
|
73
|
+
invokeDriverOperation,
|
|
74
|
+
ok,
|
|
75
|
+
unsupported,
|
|
76
|
+
invalid,
|
|
77
|
+
failed
|
|
78
|
+
};
|