huaweicloud-devkit 1.1.14-next.0 → 2.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -5
- package/README.zh-CN.md +16 -5
- package/bin/dsh-postinstall.cjs +171 -31
- package/bin/setup.cjs +1 -1
- package/cordis.patch.yml +1 -1
- package/integrations/atomcode/hooks/huaweicloud-telemetry.js +29 -33
- package/integrations/dsh/hook-plugin.d.mts +19 -0
- package/integrations/dsh/hook-plugin.mjs +23 -22
- package/integrations/hermes/hooks/huaweicloud-telemetry.py +26 -43
- package/integrations/hermes/manifest.yaml +35 -10
- package/integrations/opencode/commands/huaweicloud-doctor.md +3 -2
- package/integrations/opencode/hooks/skill-tracker.js +70 -89
- package/integrations/opencode/opencode.json +5 -6
- package/integrations/workbuddy/hooks/telemetry-tracker.py +27 -45
- package/package.json +32 -11
- package/plugins/huaweicloud-core/.claude-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.codex-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.cursor-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.hermes-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/.mcp.json +1 -1
- package/plugins/huaweicloud-core/.workbuddy-plugin/plugin.json +1 -2
- package/plugins/huaweicloud-core/dist/agents/atomcode.js +118 -0
- package/plugins/huaweicloud-core/dist/agents/codearts-work.js +121 -0
- package/plugins/huaweicloud-core/dist/agents/codearts.js +69 -0
- package/plugins/huaweicloud-core/dist/agents/codex-desktop.js +193 -0
- package/plugins/huaweicloud-core/dist/agents/codex.js +205 -0
- package/plugins/huaweicloud-core/dist/agents/dsh-patch.js +172 -0
- package/plugins/huaweicloud-core/dist/agents/dsh.js +129 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-config.js +976 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-hook-plugin.js +90 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-hooks.js +166 -0
- package/plugins/huaweicloud-core/dist/agents/hermes-sdk.js +58 -0
- package/plugins/huaweicloud-core/dist/agents/hermes.js +150 -0
- package/plugins/huaweicloud-core/dist/agents/officeace-registry.js +179 -0
- package/plugins/huaweicloud-core/dist/agents/officeace-sqlite.js +132 -0
- package/plugins/huaweicloud-core/dist/agents/officeace.js +173 -0
- package/plugins/huaweicloud-core/dist/agents/openclaw.js +54 -0
- package/plugins/huaweicloud-core/dist/agents/opencode-config.js +188 -0
- package/plugins/huaweicloud-core/dist/agents/opencode.js +112 -0
- package/plugins/huaweicloud-core/dist/agents/workbuddy.js +194 -0
- package/plugins/huaweicloud-core/dist/auth/account-type.js +136 -0
- package/plugins/huaweicloud-core/dist/auth/agent-registration.js +243 -0
- package/plugins/huaweicloud-core/dist/auth/cli.js +114 -0
- package/plugins/huaweicloud-core/dist/auth/codearts-context.js +131 -0
- package/plugins/huaweicloud-core/dist/auth/credential-placeholder.js +41 -0
- package/plugins/huaweicloud-core/dist/auth/credential-resolver.js +74 -0
- package/plugins/huaweicloud-core/dist/auth/credential-validator.js +139 -0
- package/plugins/huaweicloud-core/dist/auth/credentials.js +20 -0
- package/plugins/huaweicloud-core/dist/auth/error-table.js +123 -0
- package/plugins/huaweicloud-core/dist/auth/hcloud-profile.js +89 -0
- package/plugins/huaweicloud-core/dist/auth/init-cli.js +139 -0
- package/plugins/huaweicloud-core/dist/auth/missing-credential-error.js +33 -0
- package/plugins/huaweicloud-core/dist/auth/obs-config.js +31 -0
- package/plugins/huaweicloud-core/dist/auth/project-id.js +90 -0
- package/plugins/huaweicloud-core/dist/auth/reconcile.js +256 -0
- package/plugins/huaweicloud-core/dist/auth/runtime-credentials.js +32 -0
- package/plugins/huaweicloud-core/dist/auth/s1-store.js +171 -0
- package/plugins/huaweicloud-core/dist/auth/service.js +397 -0
- package/plugins/huaweicloud-core/dist/auth/sts-expiry.js +58 -0
- package/plugins/huaweicloud-core/dist/capability-catalog.js +494 -0
- package/plugins/huaweicloud-core/dist/codearts-sandbox.js +32 -0
- package/plugins/huaweicloud-core/dist/codex-probe.js +77 -0
- package/plugins/huaweicloud-core/dist/data/icons-manifest.v1.json +3517 -0
- package/plugins/huaweicloud-core/dist/dep/installers/gateway.js +186 -0
- package/plugins/huaweicloud-core/dist/dep/installers/hcloud.js +370 -0
- package/plugins/huaweicloud-core/dist/dep/installers/table.js +28 -0
- package/plugins/huaweicloud-core/dist/dep/provision.js +247 -0
- package/plugins/huaweicloud-core/dist/dep/receipts.js +385 -0
- package/plugins/huaweicloud-core/dist/detect-framework-match.js +111 -0
- package/plugins/huaweicloud-core/dist/detect-framework-pkg.js +85 -0
- package/plugins/huaweicloud-core/dist/detect-framework-scan.js +93 -0
- package/plugins/huaweicloud-core/dist/detect-framework-table.js +153 -0
- package/plugins/huaweicloud-core/dist/detect-framework.js +7 -0
- package/plugins/huaweicloud-core/dist/doctor-native.js +167 -0
- package/plugins/huaweicloud-core/dist/doctor-payload.js +34 -0
- package/plugins/huaweicloud-core/dist/doctor-report.js +8 -0
- package/plugins/huaweicloud-core/dist/explain-error.js +209 -0
- package/plugins/huaweicloud-core/dist/hcloud-api-error.js +64 -0
- package/plugins/huaweicloud-core/dist/hcloud-catalog.js +91 -0
- package/plugins/huaweicloud-core/dist/hcloud-cli.js +24 -0
- package/plugins/huaweicloud-core/dist/hcloud-obs-redact.js +68 -0
- package/plugins/huaweicloud-core/dist/hcloud-plan.js +298 -0
- package/plugins/huaweicloud-core/dist/hcloud-probe.js +153 -0
- package/plugins/huaweicloud-core/dist/hcloud-run-once.js +245 -0
- package/plugins/huaweicloud-core/dist/hcloud-run.js +107 -0
- package/plugins/huaweicloud-core/dist/hcloud-sg-preflight.js +104 -0
- package/plugins/huaweicloud-core/dist/hcloud-sts.js +113 -0
- package/plugins/huaweicloud-core/dist/hcloud-triage.js +71 -0
- package/plugins/huaweicloud-core/dist/icon-library.js +216 -0
- package/plugins/huaweicloud-core/dist/install-payload.js +35 -0
- package/plugins/huaweicloud-core/dist/install-plan.js +85 -0
- package/plugins/huaweicloud-core/dist/install-prompts.js +119 -0
- package/plugins/huaweicloud-core/dist/koocli-version.js +83 -0
- package/plugins/huaweicloud-core/dist/lib/approval-tokens.js +234 -0
- package/plugins/huaweicloud-core/dist/lib/as-record.js +10 -0
- package/plugins/huaweicloud-core/dist/lib/as-text.js +15 -0
- package/plugins/huaweicloud-core/dist/lib/banner.js +10 -0
- package/plugins/huaweicloud-core/dist/lib/call-trace.js +128 -0
- package/plugins/huaweicloud-core/dist/lib/cli-io.js +72 -0
- package/plugins/huaweicloud-core/dist/lib/credentials.js +173 -0
- package/plugins/huaweicloud-core/dist/lib/dep-resolve.js +64 -0
- package/plugins/huaweicloud-core/dist/lib/dependency-model.js +152 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hdkitservice-api.js +217 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/hwlink-api.js +163 -0
- package/plugins/huaweicloud-core/dist/lib/hdkit/sandbox-pool.js +303 -0
- package/plugins/huaweicloud-core/dist/lib/hw-request-signing.js +57 -0
- package/plugins/huaweicloud-core/dist/lib/koocli-paths.js +18 -0
- package/plugins/huaweicloud-core/dist/lib/native-receipt.js +110 -0
- package/plugins/huaweicloud-core/dist/lib/opencode-permission-seam.js +132 -0
- package/plugins/huaweicloud-core/dist/lib/pack-state.js +179 -0
- package/plugins/huaweicloud-core/dist/lib/pack-types.js +21 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/cli.js +273 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/custody.js +396 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/refs.js +63 -0
- package/plugins/huaweicloud-core/dist/lib/secret-vault/store.js +236 -0
- package/plugins/huaweicloud-core/dist/lib/skill-frontmatter.js +158 -0
- package/plugins/huaweicloud-core/dist/lib/skill-manifest.js +55 -0
- package/plugins/huaweicloud-core/dist/lib/skill-tree.js +44 -0
- package/plugins/huaweicloud-core/dist/lib/tool-schema-parts.js +66 -0
- package/plugins/huaweicloud-core/dist/mcp-agent-config.js +80 -0
- package/plugins/huaweicloud-core/dist/mcp-config-backup.js +74 -0
- package/plugins/huaweicloud-core/dist/mcp-config-io.js +195 -0
- package/plugins/huaweicloud-core/dist/mcp-config-merge.js +188 -0
- package/plugins/huaweicloud-core/dist/mcp-protocol.js +320 -0
- package/plugins/huaweicloud-core/dist/mcp-server.js +62136 -0
- package/plugins/huaweicloud-core/dist/mcp-server.js.map +7 -0
- package/plugins/huaweicloud-core/dist/mcp-stdio-transport.js +206 -0
- package/plugins/huaweicloud-core/dist/officeace-paths.js +142 -0
- package/plugins/huaweicloud-core/dist/packs/auth/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/auth/tools.js +276 -0
- package/plugins/huaweicloud-core/dist/packs/discovery/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/discovery/tools.js +78 -0
- package/plugins/huaweicloud-core/dist/packs/enable.js +81 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/pack.js +39 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-cli/tools.js +435 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/approval.js +222 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/pack.js +17 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/sidecar.js +486 -0
- package/plugins/huaweicloud-core/dist/packs/huaweicloud-open-mcp/tools.js +134 -0
- package/plugins/huaweicloud-core/dist/packs/obs/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/obs/tools.js +425 -0
- package/plugins/huaweicloud-core/dist/packs/registry.js +143 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/git-transfer.js +79 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-account.js +80 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-credentials.js +138 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-deploy.js +45 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-session.js +48 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-tunnel.js +59 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/handlers-upload.js +34 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/pack.js +14 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/schemas.js +191 -0
- package/plugins/huaweicloud-core/dist/packs/sandbox/tools.js +146 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/pack.js +8 -0
- package/plugins/huaweicloud-core/dist/packs/secrets/tools.js +126 -0
- package/plugins/huaweicloud-core/dist/packs/update/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/update/tools.js +82 -0
- package/plugins/huaweicloud-core/dist/packs/voucher/pack.js +11 -0
- package/plugins/huaweicloud-core/dist/packs/voucher/tools.js +91 -0
- package/plugins/huaweicloud-core/dist/packs-cli/commands.js +108 -0
- package/plugins/huaweicloud-core/dist/packs-cli/doctor.js +81 -0
- package/plugins/huaweicloud-core/dist/packs-cli/report.js +133 -0
- package/plugins/huaweicloud-core/dist/packs-cli/slots.js +104 -0
- package/plugins/huaweicloud-core/dist/packs-cli/write-command.js +108 -0
- package/plugins/huaweicloud-core/dist/packs-cli/writers.js +115 -0
- package/plugins/huaweicloud-core/dist/packs-configure.js +81 -0
- package/plugins/huaweicloud-core/dist/packs-policy.js +149 -0
- package/plugins/huaweicloud-core/dist/payload-files.js +78 -0
- package/plugins/huaweicloud-core/dist/payload-native-clean.js +142 -0
- package/plugins/huaweicloud-core/dist/payload-native-sync.js +89 -0
- package/plugins/huaweicloud-core/dist/payload-placement.js +94 -0
- package/plugins/huaweicloud-core/dist/payload-roster.js +80 -0
- package/plugins/huaweicloud-core/dist/payload-runtime-deps.js +67 -0
- package/plugins/huaweicloud-core/dist/payload-status.js +43 -0
- package/plugins/huaweicloud-core/dist/payload-utils.js +42 -0
- package/plugins/huaweicloud-core/dist/preflight.js +232 -0
- package/plugins/huaweicloud-core/dist/proxy/cli.js +83 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-agent.js +92 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-bypass.js +83 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-cidr.js +105 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-config-io.js +61 -0
- package/plugins/huaweicloud-core/dist/proxy/proxy-config.js +10 -0
- package/plugins/huaweicloud-core/dist/risk-rule-engine.js +229 -0
- package/plugins/huaweicloud-core/dist/safety/classify-hcloud.js +191 -0
- package/plugins/huaweicloud-core/dist/safety/classify-text.js +1032 -0
- package/plugins/huaweicloud-core/dist/safety/command-operation.js +25 -0
- package/plugins/huaweicloud-core/dist/safety/credential-path.js +23 -0
- package/plugins/huaweicloud-core/dist/safety/default-policy.js +28 -0
- package/plugins/huaweicloud-core/dist/safety/feeder.js +119 -0
- package/plugins/huaweicloud-core/dist/safety/heredoc.js +95 -0
- package/plugins/huaweicloud-core/dist/safety/policy.js +75 -0
- package/plugins/huaweicloud-core/dist/safety/redact.js +42 -0
- package/plugins/huaweicloud-core/dist/safety/risk-merge.js +22 -0
- package/plugins/huaweicloud-core/dist/safety/script-stream.js +90 -0
- package/plugins/huaweicloud-core/dist/safety/secret-exec.js +44 -0
- package/plugins/huaweicloud-core/dist/safety/segments.js +138 -0
- package/plugins/huaweicloud-core/dist/safety/shell-text.js +414 -0
- package/plugins/huaweicloud-core/dist/safety/skill-quality-cli.js +152 -0
- package/plugins/huaweicloud-core/dist/safety/tokens.js +297 -0
- package/plugins/huaweicloud-core/dist/safety/unwrap.js +148 -0
- package/plugins/huaweicloud-core/dist/safety/vocabulary.js +37 -0
- package/plugins/huaweicloud-core/dist/safety/windows-rebase.js +56 -0
- package/plugins/huaweicloud-core/dist/safety/windows.js +137 -0
- package/plugins/huaweicloud-core/dist/safety/xargs-argv.js +64 -0
- package/plugins/huaweicloud-core/dist/safety-policy.js +14 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-check.js +246 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-nginx-verify.js +76 -0
- package/plugins/huaweicloud-core/dist/sandbox/deploy-nginx.js +215 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-auth.js +246 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-exec.js +10 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose-flow.js +225 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-expose.js +214 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-gateway.js +34 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-keepalive.js +212 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-key.js +175 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-renew.js +69 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-tunnel.js +48 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-validation.js +79 -0
- package/plugins/huaweicloud-core/dist/sandbox/devbridge-verify.js +101 -0
- package/plugins/huaweicloud-core/dist/sandbox/hwlink-connection.js +145 -0
- package/plugins/huaweicloud-core/dist/sandbox/sandbox-file-server.py +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/sandbox-output.js +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/session-manager.js +55 -0
- package/plugins/huaweicloud-core/dist/sandbox/tunnel-http.js +137 -0
- package/plugins/huaweicloud-core/dist/sandbox/uninstall-cleanup.js +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-diagnostics.js +45 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-file.js +119 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-project.js +171 -0
- package/plugins/huaweicloud-core/dist/sandbox/upload-transport.js +96 -0
- package/plugins/huaweicloud-core/dist/sandbox/ws-exec-loader.js +43 -0
- package/plugins/huaweicloud-core/dist/search-docs.js +64 -0
- package/plugins/huaweicloud-core/dist/search-market.js +277 -0
- package/plugins/huaweicloud-core/dist/services/availability.js +51 -0
- package/plugins/huaweicloud-core/dist/services/regions.js +110 -0
- package/plugins/huaweicloud-core/dist/setup-cli.js +1343 -0
- package/plugins/huaweicloud-core/dist/skill-disclosure.js +231 -0
- package/plugins/huaweicloud-core/dist/targets.js +139 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-detect.js +44 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-registry.js +196 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-versions-desktop.js +143 -0
- package/plugins/huaweicloud-core/dist/telemetry/agent-versions.js +78 -0
- package/plugins/huaweicloud-core/dist/telemetry/event-pipeline.js +206 -0
- package/plugins/huaweicloud-core/dist/telemetry/hook-ingest.js +81 -0
- package/plugins/huaweicloud-core/dist/telemetry/identity-stamps.js +104 -0
- package/plugins/huaweicloud-core/dist/telemetry/invoke-value.js +47 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry-fs.js +42 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry-types.js +14 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry-values.js +121 -0
- package/plugins/huaweicloud-core/dist/telemetry/telemetry.js +262 -0
- package/plugins/huaweicloud-core/dist/tool-definitions.js +276 -0
- package/plugins/huaweicloud-core/dist/tool-schemas.js +156 -0
- package/plugins/huaweicloud-core/dist/tools.js +269 -0
- package/plugins/huaweicloud-core/dist/update-cache.js +79 -0
- package/plugins/huaweicloud-core/dist/update-check.js +23 -0
- package/plugins/huaweicloud-core/dist/update-hint.js +45 -0
- package/plugins/huaweicloud-core/dist/update-installed.js +53 -0
- package/plugins/huaweicloud-core/dist/update-registry.js +141 -0
- package/plugins/huaweicloud-core/dist/update-semver.js +76 -0
- package/plugins/huaweicloud-core/dist/update-skip.js +81 -0
- package/plugins/huaweicloud-core/dist/update-upgrade.js +94 -0
- package/plugins/huaweicloud-core/dist/vendor-gate.js +89 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-exec-client.js +10 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-exec-pending.js +71 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-exec-session.js +235 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-fair-queue.js +139 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-interactive-terminal.js +106 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-multiplexer.js +229 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-normalize.js +53 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-packet.js +148 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-terminal-channel.js +155 -0
- package/plugins/huaweicloud-core/dist/ws-exec/hwlink-tunnel-channel.js +254 -0
- package/plugins/huaweicloud-core/dist/ws-exec/index.js +20 -0
- package/plugins/huaweicloud-core/dist/ws-exec/ws-exec-client.js +76 -0
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.mjs +62 -3
- package/plugins/huaweicloud-core/hooks/huaweicloud-safety.py +2500 -33
- package/plugins/huaweicloud-core/openclaw.plugin.json +2 -2
- package/plugins/huaweicloud-core/safety/policy.json +45 -4
- package/plugins/huaweicloud-core/safety/rules/cloud-risk-rules.json +47 -15
- package/plugins/huaweicloud-core/skills/.manifest.json +67 -0
- package/plugins/huaweicloud-core/skills/huawei-billing/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cbr/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cce/SKILL.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/SKILL.md +27 -51
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/acceptance-criteria.md +10 -12
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/cli-installation-guide.md +23 -27
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/dataflow-diagram.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/references/verification-method.md +8 -16
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/scripts/cli/cli_entry.py +71 -461
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/SKILL.md +56 -144
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/acceptance-criteria.md +14 -12
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/cli-installation-guide.md +72 -39
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/dataflow-diagram.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/verification-method.md +12 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/templates/test-defaults.json +1 -1
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/templates/test-vars.json +9 -9
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/SKILL.md +82 -160
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/acceptance-criteria.md +9 -8
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/cli-installation-guide.md +73 -40
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/dataflow-diagram.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/related-commands.md +16 -14
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/references/verification-method.md +7 -20
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/SKILL.md +92 -95
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/acceptance-criteria.md +11 -10
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/cli-installation-guide.md +86 -67
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/dataflow-diagram.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/test-data-guide.md +29 -25
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/verification-method.md +13 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/SKILL.md +107 -127
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/acceptance-criteria.md +26 -25
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/cli-installation-guide.md +66 -51
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/csms-usage.md +23 -19
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/dataflow-diagram.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/iam-policies.md +25 -30
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/kms-usage.md +13 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/references/verification-method.md +13 -7
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/scripts/cli/cli_entry.py +67 -354
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/scripts/ensure_cli.sh +28 -69
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/templates/test-vars.json +11 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-eye/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/SKILL.md +28 -109
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/acceptance-criteria.md +27 -31
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/cli-installation-guide.md +49 -24
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/dataflow-diagram.md +2 -5
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/references/verification-method.md +8 -25
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/cli/cli_entry.py +67 -307
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/ensure_cli.sh +28 -68
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/SKILL.md +60 -135
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/acceptance-criteria.md +9 -11
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/cli-installation-guide.md +16 -12
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/dataflow-diagram.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/engine-operation-reference.md +15 -13
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/iam-policies.md +9 -7
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/security-audit-guide.md +9 -5
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/references/verification-method.md +16 -37
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/cli/cli_entry.py +101 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/ensure_cli.sh +27 -184
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/SKILL.md +71 -103
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/acceptance-criteria.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/cli-installation-guide.md +72 -84
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/dataflow-diagram.md +3 -3
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/iam-policies.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/related-commands.md +7 -5
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/references/verification-method.md +11 -9
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/scripts/cli/cli_entry.py +101 -0
- package/plugins/huaweicloud-core/skills/huawei-cloud-waf-aad-rule-management/scripts/ensure_cli.sh +27 -42
- package/plugins/huaweicloud-core/skills/huawei-ecs/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/create-instance.md +24 -13
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/evs.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/flavors.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/hc-activity.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/troubleshooting.md +25 -21
- package/plugins/huaweicloud-core/skills/huawei-ecs/references/windows-ssh.md +7 -5
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/apig-event-format.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/create-function.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/deploy-workflow.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-functiongraph/references/triggers.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-getting-started/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iac/SKILL.md +40 -38
- package/plugins/huaweicloud-core/skills/huawei-iac/references/architectures.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iac/references/resource-catalog.md +14 -12
- package/plugins/huaweicloud-core/skills/huawei-iac/references/state-file.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iam/SKILL.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-iam/references/policy-examples.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-iam/references/quick-ref.md +4 -1
- package/plugins/huaweicloud-core/skills/huawei-modelarts/SKILL.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/SKILL.md +32 -29
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-create.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/references/bucket-lifecycle.md +4 -2
- package/plugins/huaweicloud-core/skills/huawei-obs/references/common-pitfalls.md +17 -15
- package/plugins/huaweicloud-core/skills/huawei-obs/references/single-file-share.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-obs/references/static-website.md +10 -6
- package/plugins/huaweicloud-core/skills/huawei-openapi/SKILL.md +50 -0
- package/plugins/huaweicloud-core/skills/huawei-rds/SKILL.md +15 -13
- package/plugins/huaweicloud-core/skills/huawei-sandbox/SKILL.md +98 -91
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/framework-commands.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/fullstack-postgrest.md +33 -27
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/nginx-templates.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/resource-pool.md +3 -1
- package/plugins/huaweicloud-core/skills/huawei-sandbox/references/tunnel-persistence.md +9 -2
- package/plugins/huaweicloud-core/skills/huawei-voucher/SKILL.md +5 -3
- package/plugins/huaweicloud-core/skills/huawei-vpc/SKILL.md +3 -0
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/network.md +16 -0
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/security-group.md +2 -0
- package/plugins/huaweicloud-core/skills/huawei-vpc/references/subnet.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-api-and-sdk/SKILL.md +3 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-capability-discovery/SKILL.md +16 -13
- package/plugins/huaweicloud-core/skills/huaweicloud-cli-and-auth/SKILL.md +6 -11
- package/plugins/huaweicloud-core/skills/huaweicloud-core/SKILL.md +38 -35
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/report-issue.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-core/references/select.md +2 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/SKILL.md +3 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-safety/references/secrets.md +32 -0
- package/plugins/huaweicloud-core/skills/huaweicloud-troubleshooting/SKILL.md +2 -0
- package/plugins/huaweicloud-core/src/agents/atomcode.ts +138 -0
- package/plugins/huaweicloud-core/src/agents/codearts-work.ts +136 -0
- package/plugins/huaweicloud-core/src/agents/codearts.ts +92 -0
- package/plugins/huaweicloud-core/src/agents/codex-desktop.ts +219 -0
- package/plugins/huaweicloud-core/src/agents/codex.ts +230 -0
- package/plugins/huaweicloud-core/src/agents/dsh-patch.ts +195 -0
- package/plugins/huaweicloud-core/src/agents/dsh.ts +153 -0
- package/plugins/huaweicloud-core/src/agents/hermes-config.ts +974 -0
- package/plugins/huaweicloud-core/src/agents/hermes-hook-plugin.ts +99 -0
- package/plugins/huaweicloud-core/src/agents/hermes-hooks.ts +187 -0
- package/plugins/huaweicloud-core/src/agents/hermes-sdk.ts +63 -0
- package/plugins/huaweicloud-core/src/agents/hermes.ts +192 -0
- package/plugins/huaweicloud-core/src/agents/officeace-registry.ts +188 -0
- package/plugins/huaweicloud-core/src/agents/officeace-sqlite.ts +153 -0
- package/plugins/huaweicloud-core/src/agents/officeace.ts +202 -0
- package/plugins/huaweicloud-core/src/agents/openclaw.ts +73 -0
- package/plugins/huaweicloud-core/src/agents/opencode-config.ts +193 -0
- package/plugins/huaweicloud-core/src/agents/opencode.ts +148 -0
- package/plugins/huaweicloud-core/src/agents/workbuddy.ts +216 -0
- package/plugins/huaweicloud-core/src/auth/account-type.ts +191 -0
- package/plugins/huaweicloud-core/src/auth/agent-registration.ts +267 -0
- package/plugins/huaweicloud-core/src/auth/cli.ts +133 -0
- package/plugins/huaweicloud-core/src/auth/codearts-context.ts +139 -0
- package/plugins/huaweicloud-core/src/auth/credential-placeholder.ts +36 -0
- package/plugins/huaweicloud-core/src/auth/credential-resolver.ts +81 -0
- package/plugins/huaweicloud-core/src/auth/credential-validator.ts +176 -0
- package/plugins/huaweicloud-core/src/auth/credentials.ts +52 -0
- package/plugins/huaweicloud-core/src/auth/{guidance.mjs → error-table.ts} +58 -12
- package/plugins/huaweicloud-core/src/auth/hcloud-profile.ts +119 -0
- package/plugins/huaweicloud-core/src/auth/init-cli.ts +155 -0
- package/plugins/huaweicloud-core/src/auth/missing-credential-error.ts +44 -0
- package/plugins/huaweicloud-core/src/auth/obs-config.ts +42 -0
- package/plugins/huaweicloud-core/src/auth/project-id.ts +104 -0
- package/plugins/huaweicloud-core/src/auth/reconcile.ts +345 -0
- package/plugins/huaweicloud-core/src/auth/runtime-credentials.ts +38 -0
- package/plugins/huaweicloud-core/src/auth/s1-store.ts +214 -0
- package/plugins/huaweicloud-core/src/auth/{service.mjs → service.ts} +212 -61
- package/plugins/huaweicloud-core/src/auth/sts-expiry.ts +58 -0
- package/plugins/huaweicloud-core/src/capability-catalog.ts +519 -0
- package/plugins/huaweicloud-core/src/codearts-sandbox.ts +32 -0
- package/plugins/huaweicloud-core/src/codex-probe.ts +86 -0
- package/plugins/huaweicloud-core/src/data/icons-manifest.v1.json +5 -23
- package/plugins/huaweicloud-core/src/dep/installers/gateway.ts +213 -0
- package/plugins/huaweicloud-core/src/dep/installers/hcloud.ts +407 -0
- package/plugins/huaweicloud-core/src/dep/installers/table.ts +123 -0
- package/plugins/huaweicloud-core/src/dep/provision.ts +335 -0
- package/plugins/huaweicloud-core/src/dep/receipts.ts +464 -0
- package/plugins/huaweicloud-core/src/detect-framework-match.ts +143 -0
- package/plugins/huaweicloud-core/src/detect-framework-pkg.ts +79 -0
- package/plugins/huaweicloud-core/src/detect-framework-scan.ts +117 -0
- package/plugins/huaweicloud-core/src/detect-framework-table.ts +166 -0
- package/plugins/huaweicloud-core/src/detect-framework.ts +8 -0
- package/plugins/huaweicloud-core/src/doctor-native.ts +189 -0
- package/plugins/huaweicloud-core/src/doctor-payload.ts +77 -0
- package/plugins/huaweicloud-core/src/doctor-report.ts +30 -0
- package/plugins/huaweicloud-core/src/explain-error.ts +246 -0
- package/plugins/huaweicloud-core/src/hcloud-api-error.ts +69 -0
- package/plugins/huaweicloud-core/src/hcloud-catalog.ts +115 -0
- package/plugins/huaweicloud-core/src/hcloud-cli.ts +41 -0
- package/plugins/huaweicloud-core/src/hcloud-obs-redact.ts +65 -0
- package/plugins/huaweicloud-core/src/hcloud-plan.ts +344 -0
- package/plugins/huaweicloud-core/src/{hcloud-probe.mjs → hcloud-probe.ts} +87 -72
- package/plugins/huaweicloud-core/src/hcloud-run-once.ts +251 -0
- package/plugins/huaweicloud-core/src/hcloud-run.ts +151 -0
- package/plugins/huaweicloud-core/src/hcloud-sg-preflight.ts +111 -0
- package/plugins/huaweicloud-core/src/hcloud-sts.ts +123 -0
- package/plugins/huaweicloud-core/src/hcloud-triage.ts +80 -0
- package/plugins/huaweicloud-core/src/{icon-library.mjs → icon-library.ts} +115 -23
- package/plugins/huaweicloud-core/src/install-payload.ts +63 -0
- package/plugins/huaweicloud-core/src/install-plan.ts +85 -0
- package/plugins/huaweicloud-core/src/install-prompts.ts +134 -0
- package/plugins/huaweicloud-core/src/koocli-version.ts +87 -0
- package/plugins/huaweicloud-core/src/lib/approval-tokens.ts +315 -0
- package/plugins/huaweicloud-core/src/lib/as-record.ts +10 -0
- package/plugins/huaweicloud-core/src/lib/as-text.ts +16 -0
- package/plugins/huaweicloud-core/src/lib/banner.ts +12 -0
- package/plugins/huaweicloud-core/src/lib/call-trace.ts +153 -0
- package/plugins/huaweicloud-core/src/lib/cli-io.ts +81 -0
- package/plugins/huaweicloud-core/src/lib/credentials.ts +202 -0
- package/plugins/huaweicloud-core/src/lib/dep-resolve.ts +107 -0
- package/plugins/huaweicloud-core/src/lib/dependency-model.ts +236 -0
- package/plugins/huaweicloud-core/src/lib/hdkit/hdkitservice-api.ts +255 -0
- package/plugins/huaweicloud-core/src/lib/hdkit/hwlink-api.ts +245 -0
- package/plugins/huaweicloud-core/src/{sandbox/sandbox-pool.mjs → lib/hdkit/sandbox-pool.ts} +115 -47
- package/plugins/huaweicloud-core/src/lib/hw-request-signing.ts +101 -0
- package/plugins/huaweicloud-core/src/lib/koocli-paths.ts +21 -0
- package/plugins/huaweicloud-core/src/lib/native-receipt.ts +131 -0
- package/plugins/huaweicloud-core/src/lib/opencode-permission-seam.ts +145 -0
- package/plugins/huaweicloud-core/src/lib/pack-state.ts +192 -0
- package/plugins/huaweicloud-core/src/lib/pack-types.ts +74 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/cli.ts +270 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/custody.ts +468 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/refs.ts +75 -0
- package/plugins/huaweicloud-core/src/lib/secret-vault/store.ts +357 -0
- package/plugins/huaweicloud-core/src/lib/skill-frontmatter.ts +164 -0
- package/plugins/huaweicloud-core/src/lib/skill-manifest.ts +55 -0
- package/plugins/huaweicloud-core/src/lib/skill-tree.ts +45 -0
- package/plugins/huaweicloud-core/src/lib/tool-schema-parts.ts +80 -0
- package/plugins/huaweicloud-core/src/mcp-agent-config.ts +90 -0
- package/plugins/huaweicloud-core/src/{mcp-config-backup.mjs → mcp-config-backup.ts} +14 -10
- package/plugins/huaweicloud-core/src/mcp-config-io.ts +215 -0
- package/plugins/huaweicloud-core/src/mcp-config-merge.ts +205 -0
- package/plugins/huaweicloud-core/src/mcp-protocol.ts +385 -0
- package/plugins/huaweicloud-core/src/mcp-server-remote.ts +178 -0
- package/plugins/huaweicloud-core/src/mcp-server.ts +87 -0
- package/plugins/huaweicloud-core/src/mcp-stdio-transport.ts +245 -0
- package/plugins/huaweicloud-core/src/officeace-paths.ts +146 -0
- package/plugins/huaweicloud-core/src/packs/auth/pack.ts +14 -0
- package/plugins/huaweicloud-core/src/packs/auth/tools.ts +327 -0
- package/plugins/huaweicloud-core/src/packs/discovery/pack.ts +14 -0
- package/plugins/huaweicloud-core/src/packs/discovery/tools.ts +97 -0
- package/plugins/huaweicloud-core/src/packs/enable.ts +90 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/pack.ts +42 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-cli/tools.ts +493 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/approval.ts +250 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/pack.ts +19 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/sidecar.ts +603 -0
- package/plugins/huaweicloud-core/src/packs/huaweicloud-open-mcp/tools.ts +155 -0
- package/plugins/huaweicloud-core/src/packs/obs/pack.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/obs/tools.ts +487 -0
- package/plugins/huaweicloud-core/src/packs/registry.ts +162 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/git-transfer.ts +93 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-account.ts +93 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-credentials.ts +144 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-deploy.ts +63 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-session.ts +59 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-tunnel.ts +101 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/handlers-upload.ts +46 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/pack.ts +16 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/schemas.ts +249 -0
- package/plugins/huaweicloud-core/src/packs/sandbox/tools.ts +183 -0
- package/plugins/huaweicloud-core/src/packs/secrets/pack.ts +11 -0
- package/plugins/huaweicloud-core/src/packs/secrets/tools.ts +146 -0
- package/plugins/huaweicloud-core/src/packs/update/pack.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/update/tools.ts +107 -0
- package/plugins/huaweicloud-core/src/packs/voucher/pack.ts +13 -0
- package/plugins/huaweicloud-core/src/packs/voucher/tools.ts +112 -0
- package/plugins/huaweicloud-core/src/packs-cli/commands.ts +121 -0
- package/plugins/huaweicloud-core/src/packs-cli/doctor.ts +85 -0
- package/plugins/huaweicloud-core/src/packs-cli/report.ts +171 -0
- package/plugins/huaweicloud-core/src/packs-cli/slots.ts +139 -0
- package/plugins/huaweicloud-core/src/packs-cli/write-command.ts +114 -0
- package/plugins/huaweicloud-core/src/packs-cli/writers.ts +125 -0
- package/plugins/huaweicloud-core/src/packs-configure.ts +104 -0
- package/plugins/huaweicloud-core/src/packs-policy.ts +203 -0
- package/plugins/huaweicloud-core/src/payload-files.ts +78 -0
- package/plugins/huaweicloud-core/src/payload-native-clean.ts +154 -0
- package/plugins/huaweicloud-core/src/payload-native-sync.ts +110 -0
- package/plugins/huaweicloud-core/src/payload-placement.ts +107 -0
- package/plugins/huaweicloud-core/src/payload-roster.ts +85 -0
- package/plugins/huaweicloud-core/src/payload-runtime-deps.ts +68 -0
- package/plugins/huaweicloud-core/src/payload-status.ts +53 -0
- package/plugins/huaweicloud-core/src/payload-utils.ts +51 -0
- package/plugins/huaweicloud-core/src/preflight.ts +250 -0
- package/plugins/huaweicloud-core/src/proxy/cli.ts +103 -0
- package/plugins/huaweicloud-core/src/proxy/{proxy-agent.mjs → proxy-agent.ts} +25 -16
- package/plugins/huaweicloud-core/src/proxy/proxy-bypass.ts +90 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-cidr.ts +98 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config-io.ts +73 -0
- package/plugins/huaweicloud-core/src/proxy/proxy-config.ts +18 -0
- package/plugins/huaweicloud-core/src/risk-rule-engine.ts +325 -0
- package/plugins/huaweicloud-core/src/safety/classify-hcloud.ts +246 -0
- package/plugins/huaweicloud-core/src/safety/classify-text.ts +1099 -0
- package/plugins/huaweicloud-core/src/safety/command-operation.ts +28 -0
- package/plugins/huaweicloud-core/src/safety/credential-path.ts +25 -0
- package/plugins/huaweicloud-core/src/safety/default-policy.ts +34 -0
- package/plugins/huaweicloud-core/src/safety/feeder.ts +140 -0
- package/plugins/huaweicloud-core/src/safety/heredoc.ts +100 -0
- package/plugins/huaweicloud-core/src/safety/policy.ts +109 -0
- package/plugins/huaweicloud-core/src/safety/redact.ts +63 -0
- package/plugins/huaweicloud-core/src/safety/risk-merge.ts +31 -0
- package/plugins/huaweicloud-core/src/safety/script-stream.ts +95 -0
- package/plugins/huaweicloud-core/src/safety/secret-exec.ts +42 -0
- package/plugins/huaweicloud-core/src/safety/segments.ts +153 -0
- package/plugins/huaweicloud-core/src/safety/shell-text.ts +415 -0
- package/plugins/huaweicloud-core/src/safety/skill-quality-cli.ts +141 -0
- package/plugins/huaweicloud-core/src/safety/tokens.ts +322 -0
- package/plugins/huaweicloud-core/src/safety/unwrap.ts +162 -0
- package/plugins/huaweicloud-core/src/safety/vocabulary.ts +38 -0
- package/plugins/huaweicloud-core/src/safety/windows-rebase.ts +56 -0
- package/plugins/huaweicloud-core/src/safety/windows.ts +133 -0
- package/plugins/huaweicloud-core/src/safety/xargs-argv.ts +79 -0
- package/plugins/huaweicloud-core/src/safety-policy.ts +16 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-check.ts +307 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-nginx-verify.ts +96 -0
- package/plugins/huaweicloud-core/src/sandbox/deploy-nginx.ts +300 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-auth.ts +291 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-exec.ts +28 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose-flow.ts +289 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-expose.ts +310 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-gateway.ts +36 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-keepalive.ts +254 -0
- package/plugins/huaweicloud-core/src/sandbox/{devbridge-key.mjs → devbridge-key.ts} +48 -32
- package/plugins/huaweicloud-core/src/sandbox/devbridge-renew.ts +87 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-tunnel.ts +79 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-validation.ts +100 -0
- package/plugins/huaweicloud-core/src/sandbox/devbridge-verify.ts +120 -0
- package/plugins/huaweicloud-core/src/sandbox/hwlink-connection.ts +188 -0
- package/plugins/huaweicloud-core/src/sandbox/sandbox-output.ts +46 -0
- package/plugins/huaweicloud-core/src/sandbox/session-manager.ts +89 -0
- package/plugins/huaweicloud-core/src/sandbox/tunnel-http.ts +155 -0
- package/plugins/huaweicloud-core/src/sandbox/{uninstall-cleanup.mjs → uninstall-cleanup.ts} +4 -4
- package/plugins/huaweicloud-core/src/sandbox/upload-diagnostics.ts +46 -0
- package/plugins/huaweicloud-core/src/sandbox/upload-file.ts +161 -0
- package/plugins/huaweicloud-core/src/sandbox/upload-project.ts +218 -0
- package/plugins/huaweicloud-core/src/sandbox/upload-transport.ts +150 -0
- package/plugins/huaweicloud-core/src/sandbox/ws-exec-loader.ts +104 -0
- package/plugins/huaweicloud-core/src/search-docs.ts +64 -0
- package/plugins/huaweicloud-core/src/{search-market.mjs → search-market.ts} +96 -28
- package/plugins/huaweicloud-core/src/services/availability.ts +53 -0
- package/plugins/huaweicloud-core/src/services/regions.ts +110 -0
- package/plugins/huaweicloud-core/src/setup-cli.ts +1563 -0
- package/plugins/huaweicloud-core/src/skill-disclosure.ts +242 -0
- package/plugins/huaweicloud-core/src/targets.ts +156 -0
- package/plugins/huaweicloud-core/src/telemetry/{agent-detect.mjs → agent-detect.ts} +16 -5
- package/plugins/huaweicloud-core/src/telemetry/agent-registry.ts +210 -0
- package/plugins/huaweicloud-core/src/telemetry/agent-versions-desktop.ts +138 -0
- package/plugins/huaweicloud-core/src/telemetry/agent-versions.ts +84 -0
- package/plugins/huaweicloud-core/src/telemetry/event-pipeline.ts +214 -0
- package/plugins/huaweicloud-core/src/telemetry/hook-ingest.ts +82 -0
- package/plugins/huaweicloud-core/src/telemetry/identity-stamps.ts +108 -0
- package/plugins/huaweicloud-core/src/telemetry/invoke-value.ts +47 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry-fs.ts +47 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry-types.ts +97 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry-values.ts +116 -0
- package/plugins/huaweicloud-core/src/telemetry/telemetry.ts +299 -0
- package/plugins/huaweicloud-core/src/tool-definitions.ts +294 -0
- package/plugins/huaweicloud-core/src/tool-schemas.ts +180 -0
- package/plugins/huaweicloud-core/src/tools.ts +417 -0
- package/plugins/huaweicloud-core/src/update-cache.ts +95 -0
- package/plugins/huaweicloud-core/src/update-check.ts +51 -0
- package/plugins/huaweicloud-core/src/update-hint.ts +82 -0
- package/plugins/huaweicloud-core/src/update-installed.ts +53 -0
- package/plugins/huaweicloud-core/src/update-registry.ts +146 -0
- package/plugins/huaweicloud-core/src/update-semver.ts +80 -0
- package/plugins/huaweicloud-core/src/update-skip.ts +94 -0
- package/plugins/huaweicloud-core/src/update-upgrade.ts +123 -0
- package/plugins/huaweicloud-core/src/vendor-gate.ts +103 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.ts +15 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-pending.ts +113 -0
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-session.ts +334 -0
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-fair-queue.js → hwlink-fair-queue.ts} +46 -15
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-interactive-terminal.ts +158 -0
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-multiplexer.js → hwlink-multiplexer.ts} +108 -30
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-normalize.ts +60 -0
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-packet.js → hwlink-packet.ts} +40 -16
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-terminal-channel.js → hwlink-terminal-channel.ts} +30 -18
- package/plugins/huaweicloud-core/src/ws-exec/{hwlink-tunnel-channel.mjs → hwlink-tunnel-channel.ts} +75 -27
- package/plugins/huaweicloud-core/src/ws-exec/{index.js → index.ts} +11 -11
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.ts +102 -0
- package/plugins/huaweicloud-core/tsconfig.json +21 -0
- package/rules/huawei-agent-rules.mdc +2 -2
- package/integrations/hermes/skills-snapshot.json +0 -175
- package/integrations/opencode/package-lock.json +0 -24
- package/integrations/opencode/package.json +0 -10
- package/integrations/opencode/plugins/huaweicloud-devkit.js +0 -194
- package/integrations/opencode/skills/huaweicloud-core/SKILL.md +0 -32
- package/plugins/huaweicloud-core/skills/huawei-cloud-apig-instance-management/scripts/cli/cli_reporting.py +0 -589
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/references/test-report.md +0 -35
- package/plugins/huaweicloud-core/skills/huawei-cloud-cts-trace-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-dds-dcs-instance-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/references/test-report.md +0 -52
- package/plugins/huaweicloud-core/skills/huawei-cloud-deployment-task-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-dew-key-management/scripts/cli/cli_reporting.py +0 -577
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/cli/cli_reporting.py +0 -928
- package/plugins/huaweicloud-core/skills/huawei-cloud-gaussdb-instance-management/scripts/gaussdb_cli.sh +0 -138
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/install_cli.sh +0 -94
- package/plugins/huaweicloud-core/skills/huawei-cloud-smn-dms-message/scripts/smn_dms_skill.py +0 -444
- package/plugins/huaweicloud-core/src/account-type.mjs +0 -144
- package/plugins/huaweicloud-core/src/auth/agent-registration.mjs +0 -243
- package/plugins/huaweicloud-core/src/auth/credential-validator.mjs +0 -198
- package/plugins/huaweicloud-core/src/auth/credentials.mjs +0 -534
- package/plugins/huaweicloud-core/src/auth/project-id.mjs +0 -68
- package/plugins/huaweicloud-core/src/auth/reconcile.mjs +0 -257
- package/plugins/huaweicloud-core/src/auth/token-exchange.mjs +0 -100
- package/plugins/huaweicloud-core/src/detect-framework.mjs +0 -402
- package/plugins/huaweicloud-core/src/hcloud-cli.mjs +0 -864
- package/plugins/huaweicloud-core/src/koocli-install.mjs +0 -57
- package/plugins/huaweicloud-core/src/koocli-version.mjs +0 -47
- package/plugins/huaweicloud-core/src/mcp-config-merge.mjs +0 -219
- package/plugins/huaweicloud-core/src/mcp-protocol.mjs +0 -109
- package/plugins/huaweicloud-core/src/mcp-server-remote.mjs +0 -108
- package/plugins/huaweicloud-core/src/mcp-server.mjs +0 -221
- package/plugins/huaweicloud-core/src/officeace-paths.mjs +0 -51
- package/plugins/huaweicloud-core/src/preflight.mjs +0 -125
- package/plugins/huaweicloud-core/src/proxy/proxy-config.mjs +0 -187
- package/plugins/huaweicloud-core/src/risk-rule-engine.mjs +0 -182
- package/plugins/huaweicloud-core/src/safety-policy.mjs +0 -625
- package/plugins/huaweicloud-core/src/sandbox/hdkitservice-api.mjs +0 -296
- package/plugins/huaweicloud-core/src/sandbox/hwlink-api.mjs +0 -259
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +0 -2594
- package/plugins/huaweicloud-core/src/setup-cli.mjs +0 -5461
- package/plugins/huaweicloud-core/src/telemetry/agent-registry.mjs +0 -341
- package/plugins/huaweicloud-core/src/telemetry/telemetry.mjs +0 -492
- package/plugins/huaweicloud-core/src/tools.mjs +0 -3229
- package/plugins/huaweicloud-core/src/update-check.mjs +0 -476
- package/plugins/huaweicloud-core/src/ws-exec/hwlink-exec-client.js +0 -461
- package/plugins/huaweicloud-core/src/ws-exec/ws-exec-client.js +0 -365
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
// The Hermes config.yaml MCP-block family, split out of agents/hermes.ts:
|
|
2
|
+
// the mcp_servers managed-child writer (merges into an existing
|
|
3
|
+
// mcp_servers mapping — user servers, unrelated keys, their indent and
|
|
4
|
+
// dominant line endings survive; user args survive, DEVKIT_PACKS
|
|
5
|
+
// parameterized) and the surgical child remover (scoped to children under
|
|
6
|
+
// an mcp_servers block key). One scanner, scanManagedChildren, is the
|
|
7
|
+
// single definition of what the managed child is; the writer, the remover,
|
|
8
|
+
// and the #615 args delta all consume it. The hooks/allowlist/plugin
|
|
9
|
+
// families live in agents/hermes-hooks.ts; the deploy/uninstall/status
|
|
10
|
+
// lifecycle and the MCP Python SDK provisioning stay in agents/hermes.ts.
|
|
11
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { join, dirname } from 'node:path';
|
|
13
|
+
import { hermesConfigFile, hermesPluginsDir } from "../targets.js";
|
|
14
|
+
import { packsCarryValue } from "../packs-policy.js";
|
|
15
|
+
import { findHcloudBin } from "../hcloud-probe.js";
|
|
16
|
+
import { saveAgentDelta, takeAgentDelta } from "../mcp-config-backup.js";
|
|
17
|
+
// Returns true when the config file was written, false when it was already correct.
|
|
18
|
+
export function ensureHermesMcpConfig() {
|
|
19
|
+
// Resolve the packs policy before any block rewrite: the current
|
|
20
|
+
// DEVKIT_PACKS value lives inside the block writeHermesMcpConfig rewrites.
|
|
21
|
+
// The read is scoped to the managed child: a user server's DEVKIT_PACKS
|
|
22
|
+
// line must never become the value the writer carries.
|
|
23
|
+
return writeHermesMcpConfig(packsCarryValue('Hermes Agent', readHermesDevkitPacks()));
|
|
24
|
+
}
|
|
25
|
+
// The DEVKIT_PACKS value the managed child carries, scoped to the child's
|
|
26
|
+
// env-level line. Null when the file, the child, or the line is absent. The
|
|
27
|
+
// `packs` command reads the same value through its hermes slot.
|
|
28
|
+
export function readHermesDevkitPacks() {
|
|
29
|
+
if (!existsSync(hermesConfigFile()))
|
|
30
|
+
return null;
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = readFileSync(hermesConfigFile(), 'utf8');
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const line = managedChildPacksLine(text);
|
|
39
|
+
if (line === undefined)
|
|
40
|
+
return null;
|
|
41
|
+
return parsePacksLineValue(line);
|
|
42
|
+
}
|
|
43
|
+
function classifyMcpKeyLine(line) {
|
|
44
|
+
const bom = line.charCodeAt(0) === 0xfeff;
|
|
45
|
+
const probe = bom ? line.slice(1) : line;
|
|
46
|
+
const match = probe.match(/^["']?mcp_servers["']?[ \t]*:(.*)$/);
|
|
47
|
+
if (!match)
|
|
48
|
+
return { form: 'none', comment: '', bom };
|
|
49
|
+
const rest = match[1];
|
|
50
|
+
const bareOrComment = rest.match(/^[ \t]*(#.*)?$/);
|
|
51
|
+
if (bareOrComment)
|
|
52
|
+
return { form: 'bare', comment: (bareOrComment[1] ?? '').trim(), bom };
|
|
53
|
+
if (/^[ \t]*\{[ \t]*\}[ \t]*(#.*)?$/.test(rest) || /^[ \t]*(?:null|~|Null|NULL)[ \t]*(#.*)?$/.test(rest)) {
|
|
54
|
+
return { form: 'empty', comment: (rest.match(/(#.*)$/) ?? ['', ''])[1].trim(), bom };
|
|
55
|
+
}
|
|
56
|
+
return { form: 'value', comment: '', bom };
|
|
57
|
+
}
|
|
58
|
+
// U+FEFF is whitespace to trimStart but not to YAML: a BOM is a file marker,
|
|
59
|
+
// never indentation, so every indent comparison strips it first.
|
|
60
|
+
function indentOf(line) {
|
|
61
|
+
const probe = line.charCodeAt(0) === 0xfeff ? line.slice(1) : line;
|
|
62
|
+
return probe.length - probe.trimStart().length;
|
|
63
|
+
}
|
|
64
|
+
function isCommentOrBlank(line) {
|
|
65
|
+
const trimmed = line.trim();
|
|
66
|
+
return trimmed === '' || trimmed.startsWith('#');
|
|
67
|
+
}
|
|
68
|
+
// The dominant line ending: pure files keep their ending exactly, and a
|
|
69
|
+
// mixed file resolves to the majority instead of one stray line rewriting
|
|
70
|
+
// the whole file.
|
|
71
|
+
function dominantEol(text) {
|
|
72
|
+
const endings = text.match(/\r?\n/g) ?? [];
|
|
73
|
+
const crlf = endings.filter((e) => e === '\r\n').length;
|
|
74
|
+
return crlf > endings.length - crlf ? '\r\n' : '\n';
|
|
75
|
+
}
|
|
76
|
+
// A key line whose value is a literal block scalar (`prompt: |` and
|
|
77
|
+
// friends): the more-indented lines after it are scalar content, not YAML
|
|
78
|
+
// structure, so every structural scan must skip them.
|
|
79
|
+
const BLOCK_SCALAR_KEY = /^\s*[^\s:]+:\s*[|>][-+0-9]*[ \t]*(?:#.*)?$/;
|
|
80
|
+
// The single structural pass: every top-level `mcp_servers` key line (any
|
|
81
|
+
// value form) and every `huaweicloud-devkit` child at the mapping's
|
|
82
|
+
// direct-child indent under a bare key. Children under flow/value-form keys
|
|
83
|
+
// cannot exist (the writer never puts them there), a devkit-named key
|
|
84
|
+
// nested deeper inside a user server is user content, never the managed
|
|
85
|
+
// child, and lines inside block scalars are content, never children.
|
|
86
|
+
function scanManagedChildren(text) {
|
|
87
|
+
const lines = text.split(/\r?\n/);
|
|
88
|
+
const mcpKeyIdx = [];
|
|
89
|
+
const children = [];
|
|
90
|
+
let underBareMcp = false;
|
|
91
|
+
let mcpChildIndent = null;
|
|
92
|
+
let scalarIndent = null;
|
|
93
|
+
let openChild = null;
|
|
94
|
+
for (let i = 0; i < lines.length; i++) {
|
|
95
|
+
const line = lines[i];
|
|
96
|
+
const indent = indentOf(line);
|
|
97
|
+
if (scalarIndent !== null) {
|
|
98
|
+
if (line.trim() === '' || indent > scalarIndent)
|
|
99
|
+
continue;
|
|
100
|
+
scalarIndent = null;
|
|
101
|
+
}
|
|
102
|
+
if (BLOCK_SCALAR_KEY.test(line)) {
|
|
103
|
+
scalarIndent = indent;
|
|
104
|
+
if (openChild && indent > openChild.keyIndent)
|
|
105
|
+
openChild.endIdx = i - 1;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (indent === 0 && !isCommentOrBlank(line) && !line.trimStart().startsWith('-')) {
|
|
109
|
+
const form = classifyMcpKeyLine(line).form;
|
|
110
|
+
if (form !== 'none')
|
|
111
|
+
mcpKeyIdx.push(i);
|
|
112
|
+
underBareMcp = form === 'bare';
|
|
113
|
+
mcpChildIndent = null;
|
|
114
|
+
if (openChild) {
|
|
115
|
+
openChild.endIdx = i - 1;
|
|
116
|
+
openChild = null;
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (openChild && (line.trim() === '' || indent > openChild.keyIndent)) {
|
|
121
|
+
openChild.endIdx = i;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (openChild) {
|
|
125
|
+
openChild.endIdx = i - 1;
|
|
126
|
+
openChild = null;
|
|
127
|
+
}
|
|
128
|
+
if (underBareMcp && !isCommentOrBlank(line) && indent > 0) {
|
|
129
|
+
if (mcpChildIndent === null)
|
|
130
|
+
mcpChildIndent = indent;
|
|
131
|
+
if (indent === mcpChildIndent && /^\s*["']?huaweicloud-devkit["']?\s*:/.test(line)) {
|
|
132
|
+
openChild = { keyIdx: i, keyIndent: indent, endIdx: i };
|
|
133
|
+
children.push(openChild);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { lines, mcpKeyIdx, children };
|
|
138
|
+
}
|
|
139
|
+
// The child's own `args: [...]` line — the one at the child's direct-key
|
|
140
|
+
// indent, never a nested sub-key's or a sibling server's line. A flow-form
|
|
141
|
+
// child (`huaweicloud-devkit: {args: [...]}`) carries its args on the key
|
|
142
|
+
// line itself. Null when the child has no inline args of its own (a
|
|
143
|
+
// block-sequence args spelling is a documented residual: neither the extras
|
|
144
|
+
// preservation nor the uninstall delta can read it).
|
|
145
|
+
export function devkitChildArgsLine(text) {
|
|
146
|
+
const scan = scanManagedChildren(text);
|
|
147
|
+
if (scan.children.length === 0)
|
|
148
|
+
return null;
|
|
149
|
+
const child = scan.children[0];
|
|
150
|
+
const keyLine = scan.lines[child.keyIdx];
|
|
151
|
+
if (/args:\s*\[/.test(keyLine))
|
|
152
|
+
return keyLine;
|
|
153
|
+
const body = scan.lines.slice(child.keyIdx + 1, child.endIdx + 1);
|
|
154
|
+
let directIndent = null;
|
|
155
|
+
for (const line of body) {
|
|
156
|
+
if (isCommentOrBlank(line))
|
|
157
|
+
continue;
|
|
158
|
+
if (directIndent === null)
|
|
159
|
+
directIndent = indentOf(line);
|
|
160
|
+
if (indentOf(line) === directIndent && /^\s*args:\s*\[/.test(line))
|
|
161
|
+
return line;
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
// The YAML double-quoted escape alphabet: decode on parse, encode on render,
|
|
166
|
+
// so a user arg like "-fmt\ttab" round-trips through write and delta byte
|
|
167
|
+
// for byte. Unrecognized escapes stay literal (graceful, spec says error).
|
|
168
|
+
const YAML_DQ_DECODE = {
|
|
169
|
+
'0': '\0',
|
|
170
|
+
a: '\x07',
|
|
171
|
+
b: '\x08',
|
|
172
|
+
t: '\t',
|
|
173
|
+
n: '\n',
|
|
174
|
+
v: '\x0B',
|
|
175
|
+
f: '\x0C',
|
|
176
|
+
r: '\r',
|
|
177
|
+
e: '\x1B',
|
|
178
|
+
' ': ' ',
|
|
179
|
+
'"': '"',
|
|
180
|
+
'/': '/',
|
|
181
|
+
'\\': '\\',
|
|
182
|
+
N: '\u0085',
|
|
183
|
+
_: '\u00A0',
|
|
184
|
+
L: '\u2028',
|
|
185
|
+
P: '\u2029',
|
|
186
|
+
};
|
|
187
|
+
// Encode a scalar for a YAML double-quoted render: the escapes above,
|
|
188
|
+
// inverted, plus \x for the remaining control characters.
|
|
189
|
+
function yamlArgQuoted(value) {
|
|
190
|
+
let out = '';
|
|
191
|
+
for (const ch of value) {
|
|
192
|
+
switch (ch) {
|
|
193
|
+
case '\\':
|
|
194
|
+
out += '\\\\';
|
|
195
|
+
continue;
|
|
196
|
+
case '"':
|
|
197
|
+
out += '\\"';
|
|
198
|
+
continue;
|
|
199
|
+
case '\t':
|
|
200
|
+
out += '\\t';
|
|
201
|
+
continue;
|
|
202
|
+
case '\n':
|
|
203
|
+
out += '\\n';
|
|
204
|
+
continue;
|
|
205
|
+
case '\r':
|
|
206
|
+
out += '\\r';
|
|
207
|
+
continue;
|
|
208
|
+
case '\0':
|
|
209
|
+
out += '\\0';
|
|
210
|
+
continue;
|
|
211
|
+
case '\x07':
|
|
212
|
+
out += '\\a';
|
|
213
|
+
continue;
|
|
214
|
+
case '\x08':
|
|
215
|
+
out += '\\b';
|
|
216
|
+
continue;
|
|
217
|
+
case '\x0B':
|
|
218
|
+
out += '\\v';
|
|
219
|
+
continue;
|
|
220
|
+
case '\x0C':
|
|
221
|
+
out += '\\f';
|
|
222
|
+
continue;
|
|
223
|
+
case '\x1B':
|
|
224
|
+
out += '\\e';
|
|
225
|
+
continue;
|
|
226
|
+
default: {
|
|
227
|
+
const code = ch.codePointAt(0);
|
|
228
|
+
if (code === 0x85)
|
|
229
|
+
out += '\\N';
|
|
230
|
+
else if (code === 0xa0)
|
|
231
|
+
out += '\\_';
|
|
232
|
+
else if (code === 0x2028)
|
|
233
|
+
out += '\\L';
|
|
234
|
+
else if (code === 0x2029)
|
|
235
|
+
out += '\\P';
|
|
236
|
+
else if (code < 0x20 || (code >= 0x7f && code <= 0x9f)) {
|
|
237
|
+
// A raw C0/C1 control would fold to whitespace or be rejected by
|
|
238
|
+
// real YAML loaders; \x/\u keeps the value intact.
|
|
239
|
+
out += `\\x${code.toString(16).padStart(2, '0').toUpperCase()}`;
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
out += ch;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
// The args elements of an inline args line, quote-style-agnostic and
|
|
250
|
+
// escape-aware: ["a", 'b', "c\"d"] → ["a", "b", 'c"d']. A trailing comment
|
|
251
|
+
// after the closing bracket is tolerated. Quoted elements keep their exact
|
|
252
|
+
// content (YAML double-quote escapes decoded, single-quote '' decoded);
|
|
253
|
+
// only unquoted elements are trimmed. An intentional quoted empty string
|
|
254
|
+
// survives; only the empty artifact of a trailing comma is dropped. Shared
|
|
255
|
+
// by the writer's extras preservation and uninstall's delta save, so both
|
|
256
|
+
// sides accept the same spellings.
|
|
257
|
+
export function parseArgsElements(line) {
|
|
258
|
+
const open = line.match(/args:\s*\[/);
|
|
259
|
+
if (!open)
|
|
260
|
+
return null;
|
|
261
|
+
// Locate the matching close bracket. A quote only starts a quoted scalar
|
|
262
|
+
// at a scalar's start (right after the bracket, a separator, or a nested
|
|
263
|
+
// collection open) — mid-scalar quotes are plain content, per YAML — and
|
|
264
|
+
// a `]` inside an element or a trailing comment never ends the sequence.
|
|
265
|
+
const openEnd = open.index + open[0].length;
|
|
266
|
+
let close = -1;
|
|
267
|
+
let depth = 1;
|
|
268
|
+
let scanQuote = null;
|
|
269
|
+
let pendingSinceSeparator = '';
|
|
270
|
+
for (let i = openEnd; i < line.length; i++) {
|
|
271
|
+
const ch = line[i];
|
|
272
|
+
if (scanQuote === '"') {
|
|
273
|
+
if (ch === '\\') {
|
|
274
|
+
i++;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (ch === '"')
|
|
278
|
+
scanQuote = null;
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (scanQuote === "'") {
|
|
282
|
+
if (ch === "'") {
|
|
283
|
+
if (line[i + 1] === "'")
|
|
284
|
+
i++;
|
|
285
|
+
else
|
|
286
|
+
scanQuote = null;
|
|
287
|
+
}
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if ((ch === '"' || ch === "'") && pendingSinceSeparator.trim() === '') {
|
|
291
|
+
scanQuote = ch;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (ch === '[') {
|
|
295
|
+
depth++;
|
|
296
|
+
pendingSinceSeparator += ch;
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
if (ch === ']') {
|
|
300
|
+
depth--;
|
|
301
|
+
if (depth === 0) {
|
|
302
|
+
close = i;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
pendingSinceSeparator += ch;
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (ch === ',') {
|
|
309
|
+
pendingSinceSeparator = '';
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
pendingSinceSeparator += ch;
|
|
313
|
+
}
|
|
314
|
+
if (close === -1)
|
|
315
|
+
return null;
|
|
316
|
+
const inner = line.slice(openEnd, close);
|
|
317
|
+
if (inner.trim() === '')
|
|
318
|
+
return [];
|
|
319
|
+
const items = [];
|
|
320
|
+
let current = '';
|
|
321
|
+
let quoted = false;
|
|
322
|
+
let quote = null;
|
|
323
|
+
let scalarDepth = 0;
|
|
324
|
+
let scalarStarted = false;
|
|
325
|
+
for (let i = 0; i < inner.length; i++) {
|
|
326
|
+
const ch = inner[i];
|
|
327
|
+
if (quote === '"') {
|
|
328
|
+
if (ch === '\\') {
|
|
329
|
+
const next = inner[i + 1];
|
|
330
|
+
if (next === undefined) {
|
|
331
|
+
current += ch;
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
if (next === 'x' || next === 'u' || next === 'U') {
|
|
335
|
+
const width = next === 'x' ? 2 : next === 'u' ? 4 : 8;
|
|
336
|
+
const hex = inner.slice(i + 2, i + 2 + width);
|
|
337
|
+
if (/^[0-9a-fA-F]+$/.test(hex)) {
|
|
338
|
+
const code = Number.parseInt(hex, 16);
|
|
339
|
+
if (code <= 0x10ffff) {
|
|
340
|
+
current += String.fromCodePoint(code);
|
|
341
|
+
i += 1 + width;
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
current += ch;
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
const decoded = YAML_DQ_DECODE[next];
|
|
349
|
+
if (decoded !== undefined) {
|
|
350
|
+
current += decoded;
|
|
351
|
+
i++;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
current += ch;
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
if (ch === '"')
|
|
358
|
+
quote = null;
|
|
359
|
+
else
|
|
360
|
+
current += ch;
|
|
361
|
+
continue;
|
|
362
|
+
}
|
|
363
|
+
if (quote === "'") {
|
|
364
|
+
if (ch === "'") {
|
|
365
|
+
if (inner[i + 1] === "'") {
|
|
366
|
+
current += "'";
|
|
367
|
+
i++;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
quote = null;
|
|
371
|
+
}
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
current += ch;
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
if ((ch === '"' || ch === "'") && !scalarStarted) {
|
|
378
|
+
// Only whitespace can precede a scalar's opening quote; it is
|
|
379
|
+
// separator, not content.
|
|
380
|
+
quote = ch;
|
|
381
|
+
quoted = true;
|
|
382
|
+
current = '';
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (ch === '[' || ch === '{') {
|
|
386
|
+
scalarDepth++;
|
|
387
|
+
current += ch;
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
if (ch === ']' || ch === '}') {
|
|
391
|
+
scalarDepth = Math.max(0, scalarDepth - 1);
|
|
392
|
+
current += ch;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
if (ch === ',' && scalarDepth === 0) {
|
|
396
|
+
items.push({ value: current, quoted });
|
|
397
|
+
current = '';
|
|
398
|
+
quoted = false;
|
|
399
|
+
scalarStarted = false;
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
if (ch !== ' ' && ch !== '\t')
|
|
403
|
+
scalarStarted = true;
|
|
404
|
+
current += ch;
|
|
405
|
+
}
|
|
406
|
+
items.push({ value: current, quoted });
|
|
407
|
+
let elements = items.map((item) => ({ value: item.quoted ? item.value : item.value.trim(), quoted: item.quoted }));
|
|
408
|
+
const last = elements[elements.length - 1];
|
|
409
|
+
if (!last.quoted && last.value === '' && elements.length > 1) {
|
|
410
|
+
elements = elements.slice(0, -1);
|
|
411
|
+
}
|
|
412
|
+
return elements.map((item) => item.value);
|
|
413
|
+
}
|
|
414
|
+
function escapeRegExp(value) {
|
|
415
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
416
|
+
}
|
|
417
|
+
// Walks a string, skipping quoted regions (YAML double- and single-quote
|
|
418
|
+
// escape rules) and tracking bracket depth; returns the index the visit
|
|
419
|
+
// callback names, or -1 when the walk ends first.
|
|
420
|
+
function scanOutsideQuotes(raw, visit) {
|
|
421
|
+
let quote = null;
|
|
422
|
+
let depth = 0;
|
|
423
|
+
for (let i = 0; i < raw.length; i++) {
|
|
424
|
+
const ch = raw[i];
|
|
425
|
+
if (quote === '"') {
|
|
426
|
+
if (ch === '\\') {
|
|
427
|
+
i++;
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
if (ch === '"')
|
|
431
|
+
quote = null;
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (quote === "'") {
|
|
435
|
+
if (ch === "'") {
|
|
436
|
+
if (raw[i + 1] === "'")
|
|
437
|
+
i++;
|
|
438
|
+
else
|
|
439
|
+
quote = null;
|
|
440
|
+
}
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (ch === '"' || ch === "'") {
|
|
444
|
+
quote = ch;
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
if (ch === '{' || ch === '[')
|
|
448
|
+
depth++;
|
|
449
|
+
if (ch === '}' || ch === ']')
|
|
450
|
+
depth--;
|
|
451
|
+
const result = visit(ch, i, depth);
|
|
452
|
+
if (typeof result === 'number')
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
455
|
+
return -1;
|
|
456
|
+
}
|
|
457
|
+
// A flow-form child carries its env inline on the key line
|
|
458
|
+
// (`huaweicloud-devkit: {…, env: {DEVKIT_PACKS: "core"}}`). Returns the
|
|
459
|
+
// env-level DEVKIT_PACKS as a reconstructed plain line for
|
|
460
|
+
// parsePacksLineValue, or undefined when the key line has no such value.
|
|
461
|
+
function flowChildPacksLine(keyLine) {
|
|
462
|
+
const envMatch = keyLine.match(/["']?env["']?\s*:\s*\{/);
|
|
463
|
+
if (!envMatch)
|
|
464
|
+
return undefined;
|
|
465
|
+
const rest = keyLine.slice(envMatch.index + envMatch[0].length);
|
|
466
|
+
const close = scanOutsideQuotes(rest, (ch, i, depth) => (ch === '}' && depth < 0 ? i : undefined));
|
|
467
|
+
if (close === -1)
|
|
468
|
+
return undefined;
|
|
469
|
+
const inner = rest.slice(0, close);
|
|
470
|
+
const packs = inner.match(/["']?DEVKIT_PACKS["']?\s*:\s*/);
|
|
471
|
+
if (!packs)
|
|
472
|
+
return undefined;
|
|
473
|
+
return `DEVKIT_PACKS: ${cutFlowValue(inner.slice(packs.index + packs[0].length))}`;
|
|
474
|
+
}
|
|
475
|
+
// A flow-mapping member's raw value ends at the member's boundary: the
|
|
476
|
+
// first comma or closing brace outside quotes at bracket depth zero.
|
|
477
|
+
function cutFlowValue(raw) {
|
|
478
|
+
const cut = scanOutsideQuotes(raw, (ch, i, depth) => ((ch === ',' || ch === '}') && depth === 0 ? i : undefined));
|
|
479
|
+
return cut === -1 ? raw : raw.slice(0, cut);
|
|
480
|
+
}
|
|
481
|
+
// The env-level DEVKIT_PACKS line of the managed child — the one directly
|
|
482
|
+
// under the child's own `env:` direct key, never a line nested inside a user
|
|
483
|
+
// sub-key. Shared by the reader and the unchanged-check so the two cannot
|
|
484
|
+
// disagree.
|
|
485
|
+
function managedChildPacksLine(text) {
|
|
486
|
+
const scan = scanManagedChildren(text);
|
|
487
|
+
if (scan.children.length === 0)
|
|
488
|
+
return undefined;
|
|
489
|
+
const child = scan.children[0];
|
|
490
|
+
const fromFlow = flowChildPacksLine(scan.lines[child.keyIdx]);
|
|
491
|
+
if (fromFlow !== undefined)
|
|
492
|
+
return fromFlow;
|
|
493
|
+
const body = scan.lines.slice(child.keyIdx + 1, child.endIdx + 1);
|
|
494
|
+
let directIndent = null;
|
|
495
|
+
let inEnv = false;
|
|
496
|
+
let envMemberIndent = null;
|
|
497
|
+
for (const line of body) {
|
|
498
|
+
if (isCommentOrBlank(line))
|
|
499
|
+
continue;
|
|
500
|
+
const indent = indentOf(line);
|
|
501
|
+
if (directIndent === null)
|
|
502
|
+
directIndent = indent;
|
|
503
|
+
if (indent === directIndent) {
|
|
504
|
+
inEnv = /^\s*["']?env["']?\s*:/.test(line);
|
|
505
|
+
envMemberIndent = null;
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
if (inEnv && indent > directIndent) {
|
|
509
|
+
// The env block's own member indent (a hand-re-indented child may use
|
|
510
|
+
// more than the canonical +2).
|
|
511
|
+
if (envMemberIndent === null)
|
|
512
|
+
envMemberIndent = indent;
|
|
513
|
+
if (indent === envMemberIndent && /^\s*["']?DEVKIT_PACKS["']?\s*:/.test(line))
|
|
514
|
+
return line;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return undefined;
|
|
518
|
+
}
|
|
519
|
+
// The YAML scalar value of a DEVKIT_PACKS line: a double-quoted scalar with
|
|
520
|
+
// escape decoding, a single-quoted scalar, or a plain scalar. A `#` inside
|
|
521
|
+
// quotes is value content; outside, a trailing comment.
|
|
522
|
+
function parsePacksLineValue(line) {
|
|
523
|
+
const m = line.match(/^\s*["']?DEVKIT_PACKS["']?\s*:\s*/);
|
|
524
|
+
if (!m)
|
|
525
|
+
return null;
|
|
526
|
+
const rest = line.slice(m[0].length);
|
|
527
|
+
if (rest.startsWith('"')) {
|
|
528
|
+
let value = '';
|
|
529
|
+
for (let i = 1; i < rest.length; i++) {
|
|
530
|
+
const ch = rest[i];
|
|
531
|
+
if (ch === '\\' && i + 1 < rest.length) {
|
|
532
|
+
const next = rest[i + 1];
|
|
533
|
+
if (next === 'x' || next === 'u' || next === 'U') {
|
|
534
|
+
const width = next === 'x' ? 2 : next === 'u' ? 4 : 8;
|
|
535
|
+
const hex = rest.slice(i + 2, i + 2 + width);
|
|
536
|
+
if (/^[0-9a-fA-F]+$/.test(hex)) {
|
|
537
|
+
const code = Number.parseInt(hex, 16);
|
|
538
|
+
if (code <= 0x10ffff) {
|
|
539
|
+
value += String.fromCodePoint(code);
|
|
540
|
+
i += 1 + width;
|
|
541
|
+
continue;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
const decoded = YAML_DQ_DECODE[next];
|
|
547
|
+
if (decoded !== undefined) {
|
|
548
|
+
value += decoded;
|
|
549
|
+
i++;
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
return null;
|
|
553
|
+
}
|
|
554
|
+
if (ch === '"')
|
|
555
|
+
return value;
|
|
556
|
+
value += ch;
|
|
557
|
+
}
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
if (rest.startsWith("'")) {
|
|
561
|
+
let value = '';
|
|
562
|
+
for (let i = 1; i < rest.length; i++) {
|
|
563
|
+
const ch = rest[i];
|
|
564
|
+
if (ch === "'") {
|
|
565
|
+
if (rest[i + 1] === "'") {
|
|
566
|
+
value += "'";
|
|
567
|
+
i++;
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
return value;
|
|
571
|
+
}
|
|
572
|
+
value += ch;
|
|
573
|
+
}
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
const cut = rest.search(/[ \t]+#/);
|
|
577
|
+
return (cut === -1 ? rest : rest.slice(0, cut)).trim();
|
|
578
|
+
}
|
|
579
|
+
function managedChildPacksOk(text, packsValue) {
|
|
580
|
+
const line = managedChildPacksLine(text);
|
|
581
|
+
if (packsValue === null)
|
|
582
|
+
return line === undefined;
|
|
583
|
+
return line !== undefined && new RegExp(`^\\s*${escapeRegExp(packsValue)}[ \t]*(?:#.*)?$`).test(line);
|
|
584
|
+
}
|
|
585
|
+
// The boolean face install/update use; the packs slot reads the detailed
|
|
586
|
+
// result so a refusal surfaces as a failure, not "unchanged".
|
|
587
|
+
export function writeHermesMcpConfig(devkitPacks) {
|
|
588
|
+
return writeHermesMcpConfigResult(devkitPacks).changed;
|
|
589
|
+
}
|
|
590
|
+
// The Hermes MCP block render path, parameterized with the DEVKIT_PACKS value
|
|
591
|
+
// to carry. Install/update resolve the value through the --packs policy; the
|
|
592
|
+
// `packs` command passes the operator's set-math result. The managed entry is
|
|
593
|
+
// the `huaweicloud-devkit:` child nested under the user's mcp_servers
|
|
594
|
+
// mapping: a config that already has the key is merged into in place (user
|
|
595
|
+
// servers, their indent, and unrelated keys survive), only a key-less config
|
|
596
|
+
// gets a fresh one, and a config already carrying a duplicate mcp_servers key
|
|
597
|
+
// (the pre-merge writer's output) collapses back to a single key. A
|
|
598
|
+
// sequence-form or flow-mapping mcp_servers cannot carry a mapping child and
|
|
599
|
+
// is left untouched. User-added args inside the child survive the rewrite
|
|
600
|
+
// exactly as install preserves them. A refused write (refused !== null)
|
|
601
|
+
// leaves the file byte-untouched and never consumes the saved args delta.
|
|
602
|
+
export function writeHermesMcpConfigResult(devkitPacks) {
|
|
603
|
+
const configPath = hermesConfigFile();
|
|
604
|
+
const mcpPath = join(hermesPluginsDir(), 'dist', 'mcp-server.js').replace(/\\/g, '/');
|
|
605
|
+
const hcloudBin = findHcloudBin();
|
|
606
|
+
const childEnvLines = ['HUAWEICLOUD_AGENT_TOOLKIT_MODE: "local"'];
|
|
607
|
+
if (hcloudBin) {
|
|
608
|
+
childEnvLines.push(`HCLOUD_BIN: "${yamlArgQuoted(hcloudBin.replace(/\\/g, '/'))}"`);
|
|
609
|
+
}
|
|
610
|
+
const packsValue = devkitPacks !== null ? `DEVKIT_PACKS: "${yamlArgQuoted(devkitPacks)}"` : null;
|
|
611
|
+
let argsElements = [mcpPath];
|
|
612
|
+
let existing = '';
|
|
613
|
+
if (existsSync(configPath)) {
|
|
614
|
+
try {
|
|
615
|
+
existing = readFileSync(configPath, 'utf8');
|
|
616
|
+
}
|
|
617
|
+
catch {
|
|
618
|
+
// unreadable config is treated as absent — the block is written fresh
|
|
619
|
+
}
|
|
620
|
+
// A value-form mcp_servers key (a flow mapping with content, a scalar)
|
|
621
|
+
// cannot carry a block child: with or without other key spellings
|
|
622
|
+
// present, the whole file is left untouched rather than half-merged
|
|
623
|
+
// into a shadowed key.
|
|
624
|
+
if (existing.split(/\r?\n/).some((line) => classifyMcpKeyLine(line).form === 'value')) {
|
|
625
|
+
const reason = 'mcp_servers is not a block mapping; add huaweicloud-devkit manually';
|
|
626
|
+
console.log(` MCP config left untouched: ${configPath} (${reason})`);
|
|
627
|
+
return { changed: false, refused: reason };
|
|
628
|
+
}
|
|
629
|
+
const scan = scanManagedChildren(existing);
|
|
630
|
+
// A sequence-form mcp_servers key ANYWHERE (any key's first body line is
|
|
631
|
+
// a sequence item, not just the managed child's parent) refuses the
|
|
632
|
+
// whole write before any mutation: the merged child under one key would
|
|
633
|
+
// be shadowed by the sequence duplicate's last-wins resolution, and a
|
|
634
|
+
// rewrite would silently uninstall a working entry.
|
|
635
|
+
for (const keyLine of scan.mcpKeyIdx) {
|
|
636
|
+
for (let i = keyLine + 1; i < scan.lines.length; i++) {
|
|
637
|
+
const line = scan.lines[i];
|
|
638
|
+
if (isCommentOrBlank(line))
|
|
639
|
+
continue;
|
|
640
|
+
const trimmed = line.trimStart();
|
|
641
|
+
if (trimmed === '-' || trimmed.startsWith('- ')) {
|
|
642
|
+
const reason = 'mcp_servers is a sequence; add huaweicloud-devkit manually';
|
|
643
|
+
console.log(` MCP config left untouched: ${configPath} (${reason})`);
|
|
644
|
+
return { changed: false, refused: reason };
|
|
645
|
+
}
|
|
646
|
+
break;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
// Duplicate mergeable keys with no managed child anywhere are user-made
|
|
650
|
+
// duplicates the writer cannot heal (it only consolidates keys when it
|
|
651
|
+
// rewrites the managed child): merging under the first would leave the
|
|
652
|
+
// shadowing duplicate in place, so the file is left untouched.
|
|
653
|
+
const mergeableKeyCount = scan.mcpKeyIdx.filter((idx) => classifyMcpKeyLine(scan.lines[idx]).form !== 'value').length;
|
|
654
|
+
if (scan.children.length === 0 && mergeableKeyCount > 1) {
|
|
655
|
+
const reason = 'duplicate mcp_servers keys; add huaweicloud-devkit manually';
|
|
656
|
+
console.log(` MCP config left untouched: ${configPath} (${reason})`);
|
|
657
|
+
return { changed: false, refused: reason };
|
|
658
|
+
}
|
|
659
|
+
if (scan.children.length > 0) {
|
|
660
|
+
// Preserve user's extra args (e.g. --hdkitservice-endpoint) when
|
|
661
|
+
// rewriting the block (issue #615): the child's own args line,
|
|
662
|
+
// quote-style-agnostic.
|
|
663
|
+
const argsLine = devkitChildArgsLine(existing);
|
|
664
|
+
const elements = argsLine ? parseArgsElements(argsLine) : null;
|
|
665
|
+
// A duplicate top-level mcp_servers key or a duplicated managed child
|
|
666
|
+
// is never "unchanged"; so is a child whose args line has wandered off
|
|
667
|
+
// the current server path.
|
|
668
|
+
const mcpKeyCount = scan.mcpKeyIdx.length;
|
|
669
|
+
if (mcpKeyCount === 1 &&
|
|
670
|
+
scan.children.length === 1 &&
|
|
671
|
+
elements !== null &&
|
|
672
|
+
elements[0] === mcpPath &&
|
|
673
|
+
managedChildPacksOk(existing, packsValue)) {
|
|
674
|
+
console.log(` MCP config unchanged: ${configPath}`);
|
|
675
|
+
return { changed: false, refused: null };
|
|
676
|
+
}
|
|
677
|
+
if (elements && elements.length > 1)
|
|
678
|
+
argsElements = [mcpPath, ...elements.slice(1)];
|
|
679
|
+
// A single-key rewrite keeps the (possibly emptied) key so the managed
|
|
680
|
+
// child returns to its original position. A duplicate-key heal
|
|
681
|
+
// consolidates every duplicate (the child's own key and any other),
|
|
682
|
+
// so the re-merge lands under the one surviving key.
|
|
683
|
+
removeManagedChild({ keepEmptyKeys: mcpKeyCount === 1, consolidateAllKeys: mcpKeyCount > 1 });
|
|
684
|
+
existing = '';
|
|
685
|
+
if (existsSync(configPath)) {
|
|
686
|
+
try {
|
|
687
|
+
existing = readFileSync(configPath, 'utf8');
|
|
688
|
+
}
|
|
689
|
+
catch {
|
|
690
|
+
// unreadable re-read means the block becomes the whole file
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
696
|
+
const eol = dominantEol(existing);
|
|
697
|
+
const lines = existing ? existing.split(/\r?\n/) : [];
|
|
698
|
+
const keyIdx = lines.findIndex((line) => {
|
|
699
|
+
const form = classifyMcpKeyLine(line).form;
|
|
700
|
+
return form === 'bare' || form === 'empty';
|
|
701
|
+
});
|
|
702
|
+
// The insertion plan: a fresh key at end of file, or a splice into the
|
|
703
|
+
// existing mapping after its last body line at the children's indent.
|
|
704
|
+
// Computed before the delta is consumed so a refused write never burns it.
|
|
705
|
+
let appendFreshKey = false;
|
|
706
|
+
let spliceAt = 0;
|
|
707
|
+
let childIndent = 2;
|
|
708
|
+
if (keyIdx === -1) {
|
|
709
|
+
// A fresh key can only join a block-mapping root: a top-level sequence,
|
|
710
|
+
// scalar, or flow-mapping document would become invalid YAML, so it is
|
|
711
|
+
// left untouched. Only the top-level lines are judged (a sequence
|
|
712
|
+
// document's items ARE top-level lines); indented lines are children of
|
|
713
|
+
// whatever key owns them. Document markers and a BOM are structure, not
|
|
714
|
+
// content.
|
|
715
|
+
const isMappingLine = (line) => {
|
|
716
|
+
const probe = line.charCodeAt(0) === 0xfeff ? line.slice(1) : line;
|
|
717
|
+
if (probe === '---' || probe === '...')
|
|
718
|
+
return true;
|
|
719
|
+
return !probe.startsWith('-') && /^[^\s:\-#[{][^:]*:([ \t]|$)/.test(probe);
|
|
720
|
+
};
|
|
721
|
+
const topLevel = lines.filter((line) => !isCommentOrBlank(line) && indentOf(line) === 0);
|
|
722
|
+
const rootIsMapping = topLevel.every((line) => isMappingLine(line));
|
|
723
|
+
if (topLevel.length > 0 && !rootIsMapping) {
|
|
724
|
+
const reason = 'the config root is not a mapping; add huaweicloud-devkit manually';
|
|
725
|
+
console.log(` MCP config left untouched: ${configPath} (${reason})`);
|
|
726
|
+
return { changed: false, refused: reason };
|
|
727
|
+
}
|
|
728
|
+
appendFreshKey = true;
|
|
729
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === '')
|
|
730
|
+
lines.pop();
|
|
731
|
+
}
|
|
732
|
+
else {
|
|
733
|
+
const keyInfo = classifyMcpKeyLine(lines[keyIdx]);
|
|
734
|
+
if (keyInfo.form === 'empty') {
|
|
735
|
+
lines[keyIdx] = `${keyInfo.bom ? '\uFEFF' : ''}mcp_servers:${keyInfo.comment ? ` ${keyInfo.comment}` : ''}`;
|
|
736
|
+
}
|
|
737
|
+
// The mapping's first real child decides the managed child's indent; a
|
|
738
|
+
// sequence-form mcp_servers (a `- ` item, indented or at the key's own
|
|
739
|
+
// indent) cannot carry a mapping child. A plain mapping key that merely
|
|
740
|
+
// starts with `-` (like `-verbose:`) is a child, not an item.
|
|
741
|
+
let sequenceForm = false;
|
|
742
|
+
let firstChildIndent = null;
|
|
743
|
+
for (let i = keyIdx + 1; i < lines.length; i++) {
|
|
744
|
+
const line = lines[i];
|
|
745
|
+
if (isCommentOrBlank(line))
|
|
746
|
+
continue;
|
|
747
|
+
const trimmed = line.trimStart();
|
|
748
|
+
if (trimmed === '-' || trimmed.startsWith('- '))
|
|
749
|
+
sequenceForm = true;
|
|
750
|
+
else if (indentOf(line) > 0)
|
|
751
|
+
firstChildIndent = indentOf(line);
|
|
752
|
+
break;
|
|
753
|
+
}
|
|
754
|
+
if (sequenceForm) {
|
|
755
|
+
const reason = 'mcp_servers is a sequence; add huaweicloud-devkit manually';
|
|
756
|
+
console.log(` MCP config left untouched: ${configPath} (${reason})`);
|
|
757
|
+
return { changed: false, refused: reason };
|
|
758
|
+
}
|
|
759
|
+
childIndent = firstChildIndent ?? 2;
|
|
760
|
+
// The mapping runs from the key to its last indented non-comment line;
|
|
761
|
+
// the managed child joins the user's servers there.
|
|
762
|
+
let end = keyIdx;
|
|
763
|
+
for (let i = keyIdx + 1; i < lines.length; i++) {
|
|
764
|
+
const line = lines[i];
|
|
765
|
+
if (isCommentOrBlank(line))
|
|
766
|
+
continue;
|
|
767
|
+
if (/^\s/.test(line)) {
|
|
768
|
+
end = i;
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
break;
|
|
772
|
+
}
|
|
773
|
+
spliceAt = end + 1;
|
|
774
|
+
}
|
|
775
|
+
// Restore user args saved by a previous uninstall (issue #615). Consumed
|
|
776
|
+
// only once a write is certain (a refused write never burns it), and only
|
|
777
|
+
// when the child in the file has no extras of its own: a hand-repaired
|
|
778
|
+
// child's fresh extras must not be clobbered by a stale delta.
|
|
779
|
+
const hermesDelta = takeAgentDelta('hermes');
|
|
780
|
+
const rawDeltaArgs = hermesDelta?.argsExtra;
|
|
781
|
+
const deltaArgsExtra = Array.isArray(rawDeltaArgs) && rawDeltaArgs.length > 0 ? rawDeltaArgs : null;
|
|
782
|
+
if (deltaArgsExtra !== null && argsElements.length <= 1) {
|
|
783
|
+
argsElements = [mcpPath, ...deltaArgsExtra.map((a) => String(a))];
|
|
784
|
+
}
|
|
785
|
+
const childBlock = (indent) => [
|
|
786
|
+
`${' '.repeat(indent)}huaweicloud-devkit:`,
|
|
787
|
+
`${' '.repeat(indent + 2)}command: "node"`,
|
|
788
|
+
`${' '.repeat(indent + 2)}args: [${argsElements.map((a) => `"${yamlArgQuoted(a)}"`).join(', ')}]`,
|
|
789
|
+
`${' '.repeat(indent + 2)}env:`,
|
|
790
|
+
...childEnvLines.map((line) => `${' '.repeat(indent + 4)}${line}`),
|
|
791
|
+
...(packsValue !== null ? [`${' '.repeat(indent + 4)}${packsValue}`] : []),
|
|
792
|
+
];
|
|
793
|
+
let newContent;
|
|
794
|
+
if (appendFreshKey) {
|
|
795
|
+
const prefix = lines.join(eol);
|
|
796
|
+
// A trailing document-end marker (`...`) closes the document: the fresh
|
|
797
|
+
// key opens a new one instead of corrupting the old.
|
|
798
|
+
const endsWithDocEnd = lines.length > 0 && lines[lines.length - 1].trim() === '...';
|
|
799
|
+
newContent = prefix
|
|
800
|
+
? `${prefix}${eol}${endsWithDocEnd ? `---${eol}` : eol}mcp_servers:${eol}${childBlock(2).join(eol)}${eol}`
|
|
801
|
+
: `mcp_servers:${eol}${childBlock(2).join(eol)}${eol}`;
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
lines.splice(spliceAt, 0, ...childBlock(childIndent));
|
|
805
|
+
newContent = lines.join(eol);
|
|
806
|
+
if (!newContent.endsWith(eol))
|
|
807
|
+
newContent += eol;
|
|
808
|
+
}
|
|
809
|
+
try {
|
|
810
|
+
writeFileSync(configPath, newContent);
|
|
811
|
+
}
|
|
812
|
+
catch (error) {
|
|
813
|
+
// The take above was not transactional with the write: a failed write
|
|
814
|
+
// must not leave the user's delta consumed and gone.
|
|
815
|
+
if (deltaArgsExtra !== null) {
|
|
816
|
+
saveAgentDelta('hermes', { argsExtra: deltaArgsExtra });
|
|
817
|
+
}
|
|
818
|
+
throw error;
|
|
819
|
+
}
|
|
820
|
+
console.log(` MCP config updated: ${configPath}`);
|
|
821
|
+
return { changed: true, refused: null };
|
|
822
|
+
}
|
|
823
|
+
// ── The remover ──
|
|
824
|
+
function removeManagedChild(options) {
|
|
825
|
+
const configPath = hermesConfigFile();
|
|
826
|
+
if (!existsSync(configPath))
|
|
827
|
+
return;
|
|
828
|
+
const text = readFileSync(configPath, 'utf8');
|
|
829
|
+
const scan = scanManagedChildren(text);
|
|
830
|
+
if (scan.children.length === 0) {
|
|
831
|
+
console.log(' MCP config cleaned');
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
const eol = dominantEol(text);
|
|
835
|
+
const lines = scan.lines;
|
|
836
|
+
// Drop the managed children (all of them — a duplicated child heals to
|
|
837
|
+
// one) wherever they sit, tracking the kept-array index of the mcp_servers
|
|
838
|
+
// key each one lived under so pass 2 never drops a key the devkit never
|
|
839
|
+
// used. Blank lines inside a child drop with it; blank lines before the
|
|
840
|
+
// next sibling survive.
|
|
841
|
+
const drop = new Set(scan.children.map((child) => child.keyIdx));
|
|
842
|
+
const kept = [];
|
|
843
|
+
const emptied = new Set();
|
|
844
|
+
let currentKeyKeptIdx = null;
|
|
845
|
+
let openChild = false;
|
|
846
|
+
let childIndent = 0;
|
|
847
|
+
let pendingBlanks = [];
|
|
848
|
+
for (let i = 0; i < lines.length; i++) {
|
|
849
|
+
const line = lines[i];
|
|
850
|
+
const indent = indentOf(line);
|
|
851
|
+
if (openChild) {
|
|
852
|
+
if (line.trim() === '') {
|
|
853
|
+
pendingBlanks.push(line);
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
if (indent > childIndent) {
|
|
857
|
+
pendingBlanks = [];
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
openChild = false;
|
|
861
|
+
kept.push(...pendingBlanks);
|
|
862
|
+
pendingBlanks = [];
|
|
863
|
+
}
|
|
864
|
+
if (drop.has(i)) {
|
|
865
|
+
openChild = true;
|
|
866
|
+
childIndent = indentOf(line);
|
|
867
|
+
if (currentKeyKeptIdx !== null)
|
|
868
|
+
emptied.add(currentKeyKeptIdx);
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (indent === 0 && !isCommentOrBlank(line) && !line.trimStart().startsWith('-')) {
|
|
872
|
+
currentKeyKeptIdx = classifyMcpKeyLine(line).form !== 'none' ? kept.length : null;
|
|
873
|
+
}
|
|
874
|
+
kept.push(line);
|
|
875
|
+
}
|
|
876
|
+
// Pass 2: retire the keys that lost a managed child. A key that held the
|
|
877
|
+
// devkit child and nothing else drops outright (uninstalling the only
|
|
878
|
+
// server restores the pre-install shape, comment-only bodies count as
|
|
879
|
+
// empty). A DUPLICATE key the old writer appended that kept user servers
|
|
880
|
+
// is consolidated instead: its whole block MOVES under the surviving key
|
|
881
|
+
// — key line and original body lines dropped, the body re-inserted at the
|
|
882
|
+
// survivor's direct-child indent — so the heal leaves one key and never
|
|
883
|
+
// duplicates or mis-nests user content. The survivor is the first BARE
|
|
884
|
+
// key (children only live under bare keys); empty-form duplicates
|
|
885
|
+
// (`{}`, null) retire like any other so they cannot shadow the merged
|
|
886
|
+
// key.
|
|
887
|
+
let out = kept;
|
|
888
|
+
if (!options.keepEmptyKeys) {
|
|
889
|
+
const retireableKeyIdx = [];
|
|
890
|
+
for (let i = 0; i < kept.length; i++) {
|
|
891
|
+
const form = indentOf(kept[i]) === 0 ? classifyMcpKeyLine(kept[i]).form : 'none';
|
|
892
|
+
if (form === 'bare' || form === 'empty')
|
|
893
|
+
retireableKeyIdx.push(i);
|
|
894
|
+
}
|
|
895
|
+
const firstBare = retireableKeyIdx.find((i) => classifyMcpKeyLine(kept[i]).form === 'bare');
|
|
896
|
+
const first = firstBare ?? retireableKeyIdx[0];
|
|
897
|
+
const dropLines = new Set();
|
|
898
|
+
const insertions = new Map();
|
|
899
|
+
if (first !== undefined) {
|
|
900
|
+
let targetIndent = null;
|
|
901
|
+
let firstEnd = first;
|
|
902
|
+
for (let j = first + 1; j < kept.length; j++) {
|
|
903
|
+
const line = kept[j];
|
|
904
|
+
if (isCommentOrBlank(line))
|
|
905
|
+
continue;
|
|
906
|
+
if (indentOf(line) === 0 && !line.trimStart().startsWith('-'))
|
|
907
|
+
break;
|
|
908
|
+
if (targetIndent === null)
|
|
909
|
+
targetIndent = indentOf(line);
|
|
910
|
+
firstEnd = j;
|
|
911
|
+
}
|
|
912
|
+
// The writer's duplicate-key heal consolidates EVERY duplicate key
|
|
913
|
+
// (consolidateAllKeys), because the re-merge must land under the one
|
|
914
|
+
// surviving key; uninstall consolidates only the keys that held the
|
|
915
|
+
// managed child, restoring the user's own duplicates as they were.
|
|
916
|
+
const retireKeys = options.consolidateAllKeys
|
|
917
|
+
? retireableKeyIdx.filter((i) => i !== first)
|
|
918
|
+
: [...emptied].filter((i) => i !== first && retireableKeyIdx.includes(i));
|
|
919
|
+
for (const m of retireKeys) {
|
|
920
|
+
let sourceIndent = null;
|
|
921
|
+
const body = [];
|
|
922
|
+
for (let j = m + 1; j < kept.length; j++) {
|
|
923
|
+
const line = kept[j];
|
|
924
|
+
// A column-0 comment between the key and its body belongs to the
|
|
925
|
+
// block being retired, not to the next section.
|
|
926
|
+
if (line.trim() === '' || (indentOf(line) === 0 && line.trimStart().startsWith('#'))) {
|
|
927
|
+
dropLines.add(j);
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
if (indentOf(line) === 0 && !line.trimStart().startsWith('-'))
|
|
931
|
+
break;
|
|
932
|
+
dropLines.add(j);
|
|
933
|
+
if (sourceIndent === null && indentOf(line) > 0)
|
|
934
|
+
sourceIndent = indentOf(line);
|
|
935
|
+
body.push(line);
|
|
936
|
+
}
|
|
937
|
+
dropLines.add(m);
|
|
938
|
+
if (body.length === 0)
|
|
939
|
+
continue;
|
|
940
|
+
const target = targetIndent ?? 2;
|
|
941
|
+
const delta = sourceIndent === null ? 0 : target - sourceIndent;
|
|
942
|
+
const relocated = body.map((line) => delta === 0 ? line : line.replace(/^ +/, (spaces) => ' '.repeat(Math.max(0, spaces.length + delta))));
|
|
943
|
+
insertions.set(firstEnd, [...(insertions.get(firstEnd) ?? []), ...relocated]);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
let dropFirst = false;
|
|
947
|
+
if (first !== undefined && emptied.has(first) && insertions.size === 0) {
|
|
948
|
+
let hasChild = false;
|
|
949
|
+
for (let j = first + 1; j < kept.length; j++) {
|
|
950
|
+
const next = kept[j];
|
|
951
|
+
if (isCommentOrBlank(next))
|
|
952
|
+
continue;
|
|
953
|
+
hasChild = /^\s/.test(next) || next.trimStart().startsWith('-');
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
dropFirst = !hasChild;
|
|
957
|
+
}
|
|
958
|
+
out = [];
|
|
959
|
+
for (let i = 0; i < kept.length; i++) {
|
|
960
|
+
if (dropLines.has(i))
|
|
961
|
+
continue;
|
|
962
|
+
if (dropFirst && i === first)
|
|
963
|
+
continue;
|
|
964
|
+
out.push(kept[i]);
|
|
965
|
+
const extra = insertions.get(i);
|
|
966
|
+
if (extra)
|
|
967
|
+
out.push(...extra);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
const cleaned = out.join(eol).trimEnd();
|
|
971
|
+
writeFileSync(configPath, cleaned ? `${cleaned}${eol}` : '');
|
|
972
|
+
console.log(' MCP config cleaned');
|
|
973
|
+
}
|
|
974
|
+
export function removeHermesMcpConfigBlock() {
|
|
975
|
+
removeManagedChild({ keepEmptyKeys: false });
|
|
976
|
+
}
|