huaweicloud-devkit 1.1.13 → 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 -9
- 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} +210 -36
- 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 -60
- 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/{sandbox/hdkitservice-api.mjs → lib/hdkit/hdkitservice-api.ts} +99 -118
- 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/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 -135
- 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 -446
- 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/detect-framework.mjs +0 -402
- package/plugins/huaweicloud-core/src/hcloud-cli.mjs +0 -825
- 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/hwlink-api.mjs +0 -224
- package/plugins/huaweicloud-core/src/sandbox/session-manager.mjs +0 -2594
- package/plugins/huaweicloud-core/src/setup-cli.mjs +0 -5379
- 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 -3190
- 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,464 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
import { DEPENDENCIES, type DependencyId } from '../lib/dependency-model.ts';
|
|
6
|
+
import type { ResolvedDependency } from '../lib/dep-resolve.ts';
|
|
7
|
+
|
|
8
|
+
// Install receipts: the uninstall half's ground truth for "this devkit placed
|
|
9
|
+
// that binary". A receipt exists only for a binary this devkit installed and
|
|
10
|
+
// verified, so `dep uninstall` can remove exactly what it placed and never a
|
|
11
|
+
// user-managed binary. The receipt directory rides the repo's shared home
|
|
12
|
+
// convention (HUAWEICLOUD_HOME || homedir() → ~/.config/huaweicloud/), the
|
|
13
|
+
// same rule as mcp-config-backup.ts, update-check.ts, and officeace-paths.ts.
|
|
14
|
+
//
|
|
15
|
+
// This module is also the leaf home of the dep subsystem's shared contracts
|
|
16
|
+
// (DepUninstallResult, ResolvedUninstallContext,
|
|
17
|
+
// ManagedChildInstallResult) and the best-effort receipt recorder: the
|
|
18
|
+
// per-dependency installers (installers/hcloud.ts, installers/gateway.ts)
|
|
19
|
+
// and the decision core (provision.ts) all consume them, so they must sit
|
|
20
|
+
// below both.
|
|
21
|
+
//
|
|
22
|
+
// Receipts are single-phase on purpose: the receipt is written ONLY after the
|
|
23
|
+
// installing run verified the binary landed. A pending/two-phase scheme (mark
|
|
24
|
+
// intent, install, confirm) was reviewed and rejected: a receipt that
|
|
25
|
+
// survives a crash cannot distinguish devkit's half-install from the user's
|
|
26
|
+
// own install, and devkit must never claim what it did not place. Crash
|
|
27
|
+
// recovery needs no reconciliation — a crashed install left no receipt, so a
|
|
28
|
+
// later uninstall simply refuses and points at the documented escape hatch.
|
|
29
|
+
//
|
|
30
|
+
// Receipt mutations and the uninstall decision serialize on a lock in the
|
|
31
|
+
// receipt dir: a DIRECTORY claimed with mkdir (atomic, EEXIST means held)
|
|
32
|
+
// carrying the holder's pid. A lock is taken over only when its pid is
|
|
33
|
+
// verifiably dead (or wedged past a window exceeding the longest critical
|
|
34
|
+
// section), so a live holder's lock is never removed and no rename ever
|
|
35
|
+
// opens a free-path window — see the lock section below for the full design
|
|
36
|
+
// and the residual. Concurrent install+uninstall converges: worst case the
|
|
37
|
+
// install re-places the binary after an uninstall completed.
|
|
38
|
+
//
|
|
39
|
+
// Every function takes the receipt dir as an optional parameter (defaulting
|
|
40
|
+
// to the real convention) so tests run against a temp directory — the same
|
|
41
|
+
// injectability pattern as mcp-config-backup.ts's base parameter.
|
|
42
|
+
|
|
43
|
+
export interface DepReceipt {
|
|
44
|
+
binary: DependencyId;
|
|
45
|
+
provisioner: 'devkit';
|
|
46
|
+
/** Gateway installs record the tier that placed them (tier-aware uninstall). */
|
|
47
|
+
tier?: 'uv' | 'pipx' | 'pip3';
|
|
48
|
+
/** The path devkit placed (hcloud); gateway installs record the tier instead. */
|
|
49
|
+
path?: string;
|
|
50
|
+
installedAt: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function receiptDir(base: string = process.env.HUAWEICLOUD_HOME || homedir()): string {
|
|
54
|
+
return join(base, '.config', 'huaweicloud', 'deps');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function receiptPath(id: DependencyId, dir: string): string {
|
|
58
|
+
return join(dir, `${id}.json`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// A record that does not attribute the binary to this devkit (wrong id,
|
|
62
|
+
// foreign provisioner, missing timestamp) reads as absent: uninstall then
|
|
63
|
+
// refuses rather than deleting something it cannot claim.
|
|
64
|
+
export function readReceipt(id: DependencyId, dir: string = receiptDir()): DepReceipt | null {
|
|
65
|
+
const file = receiptPath(id, dir);
|
|
66
|
+
if (!existsSync(file)) return null;
|
|
67
|
+
try {
|
|
68
|
+
const parsed: unknown = JSON.parse(readFileSync(file, 'utf8'));
|
|
69
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return null;
|
|
70
|
+
const record = parsed as Record<string, unknown>;
|
|
71
|
+
if (record.binary !== id || record.provisioner !== 'devkit' || typeof record.installedAt !== 'string') {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const receipt: DepReceipt = { binary: id, provisioner: 'devkit', installedAt: record.installedAt };
|
|
75
|
+
if (record.tier === 'uv' || record.tier === 'pipx' || record.tier === 'pip3') receipt.tier = record.tier;
|
|
76
|
+
if (typeof record.path === 'string' && record.path.length > 0) receipt.path = record.path;
|
|
77
|
+
return receipt;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Atomic write (temp file + rename, the update-check.ts skip-state pattern):
|
|
84
|
+
// a reader never observes a half-written receipt, and a crash mid-write
|
|
85
|
+
// leaves only a stray .tmp, never a corrupt <id>.json.
|
|
86
|
+
export function writeReceipt(receipt: DepReceipt, dir: string = receiptDir()): void {
|
|
87
|
+
if (DEPENDENCIES[receipt.binary]?.kind === 'sandbox-resident') {
|
|
88
|
+
throw new Error(`${receipt.binary} is sandbox-resident; the host never manages it, so it cannot carry a receipt`);
|
|
89
|
+
}
|
|
90
|
+
withDepLock(() => {
|
|
91
|
+
mkdirSync(dir, { recursive: true });
|
|
92
|
+
const file = receiptPath(receipt.binary, dir);
|
|
93
|
+
const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
|
|
94
|
+
writeFileSync(tmp, `${JSON.stringify(receipt, null, 2)}\n`, 'utf8');
|
|
95
|
+
renameSync(tmp, file);
|
|
96
|
+
}, dir);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function removeReceipt(id: DependencyId, dir: string = receiptDir()): void {
|
|
100
|
+
withDepLock(() => {
|
|
101
|
+
rmSync(receiptPath(id, dir), { force: true });
|
|
102
|
+
}, dir);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const RECEIPTS_WARN = ' \x1b[33m[WARN]\x1b[0m';
|
|
106
|
+
|
|
107
|
+
// Receipt writes are best-effort bookkeeping after a verifiably successful
|
|
108
|
+
// install: a failed write must not fail the install (the binary is real, the
|
|
109
|
+
// escape hatch still exists), and an already-present binary never reaches
|
|
110
|
+
// this function — the provisioning loop skips before the installer runs, so
|
|
111
|
+
// devkit only ever claims a binary this run placed.
|
|
112
|
+
export function recordInstallReceipt(receipt: DepReceipt): void {
|
|
113
|
+
try {
|
|
114
|
+
writeReceipt(receipt);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.log(
|
|
117
|
+
`${RECEIPTS_WARN} could not write the install receipt for ${receipt.binary}: ${error instanceof Error ? error.message : String(error)}`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// The result every receipt-gated uninstall returns: ok=false renders via
|
|
123
|
+
// console.error with exit code 1 in the dep CLI.
|
|
124
|
+
export interface DepUninstallResult {
|
|
125
|
+
/** False renders via console.error with exit code 1 in the dep CLI. */
|
|
126
|
+
ok: boolean;
|
|
127
|
+
message: string;
|
|
128
|
+
detail?: string[];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// The seams an installer's uninstall body needs, normalized to required
|
|
132
|
+
// fields by the decision core (provision.ts's placedUninstall) before the
|
|
133
|
+
// per-dependency uninstaller runs: the env to resolve under, the shared
|
|
134
|
+
// dependency-resolution chain, and the command runner for tier withdrawals
|
|
135
|
+
// and sudo escalation. Injected overrides from DepUninstallOptions keep
|
|
136
|
+
// their precedence; the defaults are applied exactly once, at the gate.
|
|
137
|
+
export interface ResolvedUninstallContext {
|
|
138
|
+
env: NodeJS.ProcessEnv;
|
|
139
|
+
resolveDependency: (_id: DependencyId, _env: NodeJS.ProcessEnv) => ResolvedDependency | null;
|
|
140
|
+
runCommand: (_command: string, _args: readonly string[]) => { status: number | null; stdout: string; stderr: string };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// The outcome a managed-child install reports to the policy loop: ok plus
|
|
144
|
+
// the display detail for the "installed via <tier>" line. The gateway
|
|
145
|
+
// installer refines tier to its own tool union (GatewayInstallTier); the
|
|
146
|
+
// shared shape keeps the decision core and the installer interfaces free
|
|
147
|
+
// of gateway vocabulary.
|
|
148
|
+
export interface ManagedChildInstallResult {
|
|
149
|
+
ok: boolean;
|
|
150
|
+
tier: string | null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
// The lock. Sync critical sections only: the uninstall decision and the
|
|
155
|
+
// receipt mutations are plain fs operations, so the guard is a plain sync
|
|
156
|
+
// function. Same-process re-entry (an uninstall body calling removeReceipt)
|
|
157
|
+
// recurses instead of deadlocking on its own lock.
|
|
158
|
+
//
|
|
159
|
+
// DESIGN: the lock is a DIRECTORY claimed with mkdir (O_EXCL semantics —
|
|
160
|
+
// EEXIST means someone holds it), carrying a pid file written by the holder
|
|
161
|
+
// AFTER the claim, into the holder's own directory, where no other process
|
|
162
|
+
// can observe a half-written state as stealable. A path FILE plus rename
|
|
163
|
+
// takeover was tried three times and kept failing the two-contender
|
|
164
|
+
// mutual-exclusion test; the directory design narrows the windows but does
|
|
165
|
+
// NOT remove the race class structurally — round-11 live-reproduced a
|
|
166
|
+
// double hold through the takeover path (two contenders both pass the
|
|
167
|
+
// re-read against the same dead lock; the slower one's mutation lands
|
|
168
|
+
// after the faster one's fresh claim and steals it). Every mutation of the
|
|
169
|
+
// lock path is therefore a SELF-VALIDATING rename:
|
|
170
|
+
//
|
|
171
|
+
// - acquiring = mkdir; the only writer of the pid file is the holder, and
|
|
172
|
+
// it writes into its OWN directory (no cross-process half-state);
|
|
173
|
+
// - a lock is taken over ONLY when its pid file names a process that is
|
|
174
|
+
// verifiably dead (a dead owner can never be inside its section or
|
|
175
|
+
// release later) or when the takeover window expired on a wedged holder
|
|
176
|
+
// (documented residual: a >90s "live" holder is assumed wedged; the
|
|
177
|
+
// critical sections cap at ~60s);
|
|
178
|
+
// - the takeover renames the lock to a per-process stash and re-reads
|
|
179
|
+
// the stash's pid: only a stash still naming the SAME judged-dead
|
|
180
|
+
// holder honors the win; anything else means the rename stole a live
|
|
181
|
+
// claim and the stash is restored;
|
|
182
|
+
// - an EMPTY lock directory (holder between mkdir and its pid write —
|
|
183
|
+
// microseconds) is unknown, never stealable: waiters poll past it;
|
|
184
|
+
// - release is the same self-validating rename: the lock moves to a
|
|
185
|
+
// stash whose pid must still name THIS process before removal, so a
|
|
186
|
+
// wedged holder releasing after a takeover restores the taker's claim
|
|
187
|
+
// instead of deleting it.
|
|
188
|
+
//
|
|
189
|
+
// Residual: pid reuse could make a dead holder's pid look alive — that only
|
|
190
|
+
// DELAYS a takeover past the window (bounded, converges). A crash between
|
|
191
|
+
// a winning rename and its verification leaves a reclaimable stash; the
|
|
192
|
+
// acquire-time sweep removes those.
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
const LOCK_DIR_NAME = 'lock';
|
|
196
|
+
const LOCK_PID_FILE = 'pid';
|
|
197
|
+
const LOCK_POLL_MS = 50;
|
|
198
|
+
// A live holder doing real work is waited out; a holder wedged past this
|
|
199
|
+
// window is taken over anyway — the guard must never block forever. The
|
|
200
|
+
// window must exceed the longest critical section (the tier uninstall's
|
|
201
|
+
// 60s spawnSync) plus resolution margin, or a legitimate holder still
|
|
202
|
+
// inside its section gets its lock taken over mid-flight.
|
|
203
|
+
const LOCK_TAKEOVER_MS = 90_000;
|
|
204
|
+
|
|
205
|
+
const lockDepth = new Map<string, number>();
|
|
206
|
+
const heldDirs = new Set<string>();
|
|
207
|
+
let exitCleanupInstalled = false;
|
|
208
|
+
|
|
209
|
+
function lockDirPath(dir: string): string {
|
|
210
|
+
return join(dir, LOCK_DIR_NAME);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function isPidAlive(pid: number): boolean {
|
|
214
|
+
// kill(pid, 0) succeeds against an unreaped zombie: the holder exited but
|
|
215
|
+
// its parent never waited, so the pid stays allocated and the kernel still
|
|
216
|
+
// answers the signal probe. A crashed holder's lock must not be treated as
|
|
217
|
+
// live for the whole takeover window, so on Linux /proc/<pid>/stat is the
|
|
218
|
+
// truth (state Z means the process can never run again) and kill(pid, 0) is
|
|
219
|
+
// only the fallback for other platforms and read failures.
|
|
220
|
+
if (process.platform === 'linux') {
|
|
221
|
+
try {
|
|
222
|
+
const stat = readFileSync(`/proc/${pid}/stat`, 'utf8');
|
|
223
|
+
// comm is parenthesized and may itself contain ')' or spaces, so the
|
|
224
|
+
// state is the first field after the LAST closing paren.
|
|
225
|
+
const state = stat.slice(stat.lastIndexOf(')') + 2).split(' ')[0];
|
|
226
|
+
return state !== 'Z';
|
|
227
|
+
} catch {
|
|
228
|
+
// Unreadable /proc (reaped pid, or an exotic mount): fall through.
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
process.kill(pid, 0);
|
|
233
|
+
return true;
|
|
234
|
+
} catch (error) {
|
|
235
|
+
// EPERM: the process exists but belongs to another user. ESRCH: dead.
|
|
236
|
+
return (error as NodeJS.ErrnoException).code === 'EPERM';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function sleepSync(ms: number): void {
|
|
241
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// The holder's pid, read from the pid file inside its lock directory. null
|
|
245
|
+
// means the directory is empty (the holder is between mkdir and its pid
|
|
246
|
+
// write) or unreadable — unknown, which callers treat as "keep waiting",
|
|
247
|
+
// never as stealable.
|
|
248
|
+
function readHolderPid(dir: string): number | null {
|
|
249
|
+
return readPidAt(join(lockDirPath(dir), LOCK_PID_FILE));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// The pid inside a takeover stash — same layout as a live lock directory,
|
|
253
|
+
// at an arbitrary path. Round-11: the arbitration validates the stash's
|
|
254
|
+
// contents AFTER winning the rename, so a rename that stole a live claim
|
|
255
|
+
// is detected and restored instead of honored.
|
|
256
|
+
function readStashHolderPid(stashDir: string): number | null {
|
|
257
|
+
return readPidAt(join(stashDir, LOCK_PID_FILE));
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function readPidAt(pidFile: string): number | null {
|
|
261
|
+
try {
|
|
262
|
+
const pid = Number.parseInt(readFileSync(pidFile, 'utf8').trim(), 10);
|
|
263
|
+
return Number.isSafeInteger(pid) && pid > 0 ? pid : null;
|
|
264
|
+
} catch {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Crash-orphaned takeover/release stashes: a process that died between
|
|
270
|
+
// its winning rename and the stash rm left `${lock}.*.takeover` (or
|
|
271
|
+
// `.release`) behind. The lock machinery never looks at them again, so
|
|
272
|
+
// they would accumulate forever (round-11). Any stale stash is
|
|
273
|
+
// unclaimed by construction — a live winner renames its OWN stash away —
|
|
274
|
+
// so a best-effort sweep at acquire time is safe.
|
|
275
|
+
function sweepStaleStashes(dir: string): void {
|
|
276
|
+
try {
|
|
277
|
+
for (const entry of readdirSync(dir)) {
|
|
278
|
+
if (entry.startsWith(`${LOCK_DIR_NAME}.`) && (entry.endsWith('.takeover') || entry.endsWith('.release'))) {
|
|
279
|
+
rmSync(join(dir, entry), { recursive: true, force: true });
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} catch {
|
|
283
|
+
// unreadable or absent receipt dir: the claim below will recreate it
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function acquireLock(dir: string, takeoverMs: number = LOCK_TAKEOVER_MS): void {
|
|
288
|
+
mkdirSync(dir, { recursive: true });
|
|
289
|
+
sweepStaleStashes(dir);
|
|
290
|
+
const lock = lockDirPath(dir);
|
|
291
|
+
const deadline = Date.now() + takeoverMs;
|
|
292
|
+
for (;;) {
|
|
293
|
+
// Identity of the directory THIS iteration creates at the lock path —
|
|
294
|
+
// the claim is only complete once the pid file lands in THAT directory.
|
|
295
|
+
// Round-9 (CI, live-reproduced under CPU load): a past-deadline rival
|
|
296
|
+
// takes the empty dir over between the mkdir and the pid write, and the
|
|
297
|
+
// preempted creator then either threw ENOENT out of withDepLock
|
|
298
|
+
// (crashing the caller — the observed [0,1]) or its write landed in the
|
|
299
|
+
// rival's REPLACEMENT dir, overwriting the rival's pid and letting both
|
|
300
|
+
// processes hold at once (the observed overlaps). The identity re-stat
|
|
301
|
+
// after the write closes both: a directory that is no longer the one we
|
|
302
|
+
// created means the claim was lost — re-contend instead of entering the
|
|
303
|
+
// section. ino + birthtimeMs together discriminate a recycled-inode
|
|
304
|
+
// replacement (same ino, later birth time); on filesystems reporting
|
|
305
|
+
// neither (some Windows/network mounts) the check degrades to a no-op
|
|
306
|
+
// and only the ENOENT catch below remains.
|
|
307
|
+
try {
|
|
308
|
+
mkdirSync(lock);
|
|
309
|
+
// Written into our OWN directory after the atomic claim: no other
|
|
310
|
+
// process ever sees this file half-written, and no other process ever
|
|
311
|
+
// writes it. The mkdir alone is the claim; the pid file is the
|
|
312
|
+
// attribution takeovers judge on.
|
|
313
|
+
const claimed = statSync(lock);
|
|
314
|
+
writeFileSync(join(lock, LOCK_PID_FILE), `${process.pid}\n`);
|
|
315
|
+
const rechecked = statSync(lock);
|
|
316
|
+
if (rechecked.ino !== claimed.ino || rechecked.birthtimeMs !== claimed.birthtimeMs) {
|
|
317
|
+
sleepSync(LOCK_POLL_MS);
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
return;
|
|
321
|
+
} catch (error) {
|
|
322
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
323
|
+
// EEXIST: the path is held, contend for it below. ENOENT: our fresh
|
|
324
|
+
// claim was taken over (renamed away) before the pid write could land
|
|
325
|
+
// — a lost claim, never a crash. Anything else is a real error.
|
|
326
|
+
if (code !== 'EEXIST' && code !== 'ENOENT') throw error;
|
|
327
|
+
}
|
|
328
|
+
const holder = readHolderPid(dir);
|
|
329
|
+
// A live holder is waited out for as long as ITS OWN claim is younger
|
|
330
|
+
// than the takeover window — the claim's age, not this waiter's
|
|
331
|
+
// patience, is the wedgedness truth. Measuring the window on the
|
|
332
|
+
// waiter's clock (the old `Date.now() < deadline` here) misjudges a
|
|
333
|
+
// claim that STARTED after the waiter's deadline expired — the round-9
|
|
334
|
+
// overlap, live-reproduced under CPU load: two past-deadline
|
|
335
|
+
// contenders, the second seizing the first's fresh claim mid-section.
|
|
336
|
+
// The pid file is written once, at claim time, so its mtime is the
|
|
337
|
+
// claim's birth certificate; an unreadable one means the holder state
|
|
338
|
+
// just changed — re-read on the next poll, never seize on stale data.
|
|
339
|
+
if (holder !== null && isPidAlive(holder)) {
|
|
340
|
+
let claimIsFresh = true;
|
|
341
|
+
try {
|
|
342
|
+
claimIsFresh = Date.now() - statSync(join(lock, LOCK_PID_FILE)).mtimeMs < takeoverMs;
|
|
343
|
+
} catch {
|
|
344
|
+
// pid file vanished between the read and this stat: the holder
|
|
345
|
+
// state changed underneath — treat as fresh so the next poll
|
|
346
|
+
// re-reads instead of judging on stale data.
|
|
347
|
+
}
|
|
348
|
+
if (claimIsFresh) {
|
|
349
|
+
sleepSync(LOCK_POLL_MS);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
// An empty directory (holder mid-create, microseconds) is unknown and
|
|
354
|
+
// never stealable — wait it out; a crashed creator's empty dir is
|
|
355
|
+
// reclaimed only past the takeover window below.
|
|
356
|
+
if (holder === null && Date.now() < deadline) {
|
|
357
|
+
sleepSync(LOCK_POLL_MS);
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
// Verified removal — the judgment above may be STALE: another taker can
|
|
361
|
+
// have replaced the lock between our read and this point, and removing
|
|
362
|
+
// its fresh claim would let two processes hold at once. Re-read
|
|
363
|
+
// immediately before removing, and only remove when the pid still names
|
|
364
|
+
// the SAME verifiably-dead holder (or the directory is still empty past
|
|
365
|
+
// the window): while the dead holder's directory stands, no new claim
|
|
366
|
+
// can exist — claims need the path absent — so a re-read that still
|
|
367
|
+
// matches is safe to act on. A changed pid means the lock is someone
|
|
368
|
+
// else's now: keep waiting.
|
|
369
|
+
if (readHolderPid(dir) !== holder) {
|
|
370
|
+
sleepSync(LOCK_POLL_MS);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
// The removal is a SELF-VALIDATING arbitration (round-11: the bare
|
|
374
|
+
// rename did not close the race — a loser whose rename lands after
|
|
375
|
+
// the winner's mkdir steals the winner's FRESH live lock; both hold.
|
|
376
|
+
// Live-reproduced with a stalled contender). renameSync moves the
|
|
377
|
+
// lock to a per-process stash, then the stash's pid is re-read: only
|
|
378
|
+
// a stash that still names the SAME judged-dead holder (or the
|
|
379
|
+
// empty-past-deadline case) honors the win. A stash naming anyone
|
|
380
|
+
// else means the rename stole a live claim — restore it and wait.
|
|
381
|
+
const uniqueStash = `${lock}.${process.pid}.${Date.now()}.takeover`;
|
|
382
|
+
try {
|
|
383
|
+
renameSync(lock, uniqueStash);
|
|
384
|
+
} catch {
|
|
385
|
+
sleepSync(LOCK_POLL_MS);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
const stashHolder = readStashHolderPid(uniqueStash);
|
|
389
|
+
const stashStillOurs = holder === null ? stashHolder === null : stashHolder === holder;
|
|
390
|
+
if (!stashStillOurs) {
|
|
391
|
+
// The rename took a live claim: put it back and wait.
|
|
392
|
+
try {
|
|
393
|
+
renameSync(uniqueStash, lock);
|
|
394
|
+
} catch {
|
|
395
|
+
// The lock path is occupied again — the stash is orphaned; the
|
|
396
|
+
// entry sweep below reclaims it.
|
|
397
|
+
}
|
|
398
|
+
sleepSync(LOCK_POLL_MS);
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
rmSync(uniqueStash, { recursive: true, force: true });
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// Remove the lock only while its pid file still names this process, and
|
|
406
|
+
// do it as a SELF-VALIDATING rename (round-11): the read-then-rmSync
|
|
407
|
+
// shape had the same steal window the acquisition path had — a wedged
|
|
408
|
+
// holder releasing just after a takeover could delete the NEW holder's
|
|
409
|
+
// lock between its pid read and its rm. Renaming to a per-process stash
|
|
410
|
+
// and verifying the stash's pid still names THIS process makes the
|
|
411
|
+
// release fail-safe: a stash naming anyone else means the lock was taken
|
|
412
|
+
// over, and the stash is restored.
|
|
413
|
+
function releaseLock(dir: string): void {
|
|
414
|
+
const lock = lockDirPath(dir);
|
|
415
|
+
const stash = `${lock}.${process.pid}.${Date.now()}.release`;
|
|
416
|
+
try {
|
|
417
|
+
renameSync(lock, stash);
|
|
418
|
+
} catch {
|
|
419
|
+
return; // already gone or taken over: nothing to release
|
|
420
|
+
}
|
|
421
|
+
if (readStashHolderPid(stash) === process.pid) {
|
|
422
|
+
rmSync(stash, { recursive: true, force: true });
|
|
423
|
+
} else {
|
|
424
|
+
// The lock was taken over between our rename and this read: restore
|
|
425
|
+
// the taker's claim. A failed restore leaves a reclaimable stash.
|
|
426
|
+
try {
|
|
427
|
+
renameSync(stash, lock);
|
|
428
|
+
} catch {
|
|
429
|
+
// the sweep in acquireLock reclaims the orphan
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function installExitCleanup(): void {
|
|
435
|
+
if (exitCleanupInstalled) return;
|
|
436
|
+
exitCleanupInstalled = true;
|
|
437
|
+
// finally blocks do not run through process.exit(); this is the safety net.
|
|
438
|
+
process.on('exit', () => {
|
|
439
|
+
for (const dir of heldDirs) releaseLock(dir);
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export function withDepLock<T>(fn: () => T, dir: string = receiptDir(), takeoverMs: number = LOCK_TAKEOVER_MS): T {
|
|
444
|
+
const depth = lockDepth.get(dir) ?? 0;
|
|
445
|
+
if (depth > 0) {
|
|
446
|
+
lockDepth.set(dir, depth + 1);
|
|
447
|
+
try {
|
|
448
|
+
return fn();
|
|
449
|
+
} finally {
|
|
450
|
+
lockDepth.set(dir, depth - 1);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
acquireLock(dir, takeoverMs);
|
|
454
|
+
installExitCleanup();
|
|
455
|
+
heldDirs.add(dir);
|
|
456
|
+
lockDepth.set(dir, 1);
|
|
457
|
+
try {
|
|
458
|
+
return fn();
|
|
459
|
+
} finally {
|
|
460
|
+
lockDepth.set(dir, 0);
|
|
461
|
+
releaseLock(dir);
|
|
462
|
+
heldDirs.delete(dir);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// The single-project spec matcher of the detect-framework family: the
|
|
2
|
+
// branch chain that maps one project directory onto a FrameworkSpec from
|
|
3
|
+
// the table (config-file signatures first, then dependency heuristics and
|
|
4
|
+
// the deps+src fallback). Returns the spec — the scan orchestration
|
|
5
|
+
// (detect-framework-scan.ts) turns it into the public detection result;
|
|
6
|
+
// the monorepo branch lives there too (its result shape is not a spec).
|
|
7
|
+
// The public face stays src/detect-framework.ts.
|
|
8
|
+
import { existsSync } from 'node:fs';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
|
|
11
|
+
import { FRAMEWORKS, type FrameworkSpec } from './detect-framework-table.ts';
|
|
12
|
+
import { readVitepressOutDir, resolveAngularOutput } from './detect-framework-pkg.ts';
|
|
13
|
+
|
|
14
|
+
export function matchFrameworkSpec(
|
|
15
|
+
projectPath: string,
|
|
16
|
+
pkg: Record<string, unknown> | null,
|
|
17
|
+
deps: Record<string, unknown>,
|
|
18
|
+
): FrameworkSpec | null {
|
|
19
|
+
if (
|
|
20
|
+
existsSync(join(projectPath, 'next.config.js')) ||
|
|
21
|
+
existsSync(join(projectPath, 'next.config.mjs')) ||
|
|
22
|
+
existsSync(join(projectPath, 'next.config.ts')) ||
|
|
23
|
+
existsSync(join(projectPath, 'next.config.cjs'))
|
|
24
|
+
) {
|
|
25
|
+
return FRAMEWORKS.nextjs;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (
|
|
29
|
+
existsSync(join(projectPath, 'nuxt.config.js')) ||
|
|
30
|
+
existsSync(join(projectPath, 'nuxt.config.mjs')) ||
|
|
31
|
+
existsSync(join(projectPath, 'nuxt.config.ts')) ||
|
|
32
|
+
existsSync(join(projectPath, 'nuxt.config.cjs')) ||
|
|
33
|
+
existsSync(join(projectPath, 'nuxt.config.mts'))
|
|
34
|
+
) {
|
|
35
|
+
return FRAMEWORKS.nuxt;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if ('@tarojs/taro' in deps) {
|
|
39
|
+
return FRAMEWORKS.taro;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ('@dcloudio/uni-app' in deps || 'uni-app' in deps) {
|
|
43
|
+
return FRAMEWORKS.uniapp;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (existsSync(join(projectPath, '.vitepress'))) {
|
|
47
|
+
const outDir = readVitepressOutDir(projectPath);
|
|
48
|
+
return outDir ? { ...FRAMEWORKS.vitepress, outputDir: outDir } : FRAMEWORKS.vitepress;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (
|
|
52
|
+
existsSync(join(projectPath, 'docusaurus.config.js')) ||
|
|
53
|
+
existsSync(join(projectPath, 'docusaurus.config.ts')) ||
|
|
54
|
+
existsSync(join(projectPath, 'docusaurus.config.mjs')) ||
|
|
55
|
+
existsSync(join(projectPath, 'docusaurus.config.cjs'))
|
|
56
|
+
) {
|
|
57
|
+
return FRAMEWORKS.docusaurus;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (existsSync(join(projectPath, 'hugo.toml')) || existsSync(join(projectPath, 'config.toml'))) {
|
|
61
|
+
return FRAMEWORKS.hugo;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (existsSync(join(projectPath, '_config.yml'))) {
|
|
65
|
+
return FRAMEWORKS.hexo;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (existsSync(join(projectPath, 'angular.json'))) {
|
|
69
|
+
const outputDir = resolveAngularOutput(projectPath, pkg);
|
|
70
|
+
return { ...FRAMEWORKS.angular, outputDir };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (
|
|
74
|
+
existsSync(join(projectPath, 'vite.config.js')) ||
|
|
75
|
+
existsSync(join(projectPath, 'vite.config.mjs')) ||
|
|
76
|
+
existsSync(join(projectPath, 'vite.config.ts')) ||
|
|
77
|
+
existsSync(join(projectPath, 'vite.config.cjs')) ||
|
|
78
|
+
existsSync(join(projectPath, 'vite.config.mts'))
|
|
79
|
+
) {
|
|
80
|
+
return FRAMEWORKS.vite;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if ('@vue/cli-service' in deps) {
|
|
84
|
+
return FRAMEWORKS.vueCli;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// CRA heuristic — main 1.1.9's exact block (6-dep union, public/index.html
|
|
88
|
+
// OR root index.html). The upstream react-scripts tighten (9481ba2) applies
|
|
89
|
+
// to the deps+src FALLBACK below, not to this shape.
|
|
90
|
+
if (
|
|
91
|
+
'react-scripts' in deps ||
|
|
92
|
+
'react' in deps ||
|
|
93
|
+
'@angular/core' in deps ||
|
|
94
|
+
'vue' in deps ||
|
|
95
|
+
'svelte' in deps ||
|
|
96
|
+
'solid-js' in deps
|
|
97
|
+
) {
|
|
98
|
+
if (existsSync(join(projectPath, 'public', 'index.html')) || existsSync(join(projectPath, 'index.html'))) {
|
|
99
|
+
return FRAMEWORKS.cra;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (
|
|
104
|
+
existsSync(join(projectPath, 'index.html')) ||
|
|
105
|
+
existsSync(join(projectPath, 'public', 'index.html')) ||
|
|
106
|
+
existsSync(join(projectPath, 'src', 'index.html'))
|
|
107
|
+
) {
|
|
108
|
+
return FRAMEWORKS.static;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Deps + src-entry fallback: a framework dependency with a src/ entry but
|
|
112
|
+
// no config file — vue → vue-cli, react-scripts → CRA, svelte/solid → vite.
|
|
113
|
+
// CRA here is react-scripts ONLY (the upstream tighten).
|
|
114
|
+
if (pkg) {
|
|
115
|
+
const entryPoints = [
|
|
116
|
+
'src/main.js',
|
|
117
|
+
'src/main.ts',
|
|
118
|
+
'src/main.jsx',
|
|
119
|
+
'src/main.tsx',
|
|
120
|
+
'src/App.vue',
|
|
121
|
+
'src/app.vue',
|
|
122
|
+
'src/main.vue',
|
|
123
|
+
'src/index.js',
|
|
124
|
+
'src/index.ts',
|
|
125
|
+
'src/index.jsx',
|
|
126
|
+
'src/index.tsx',
|
|
127
|
+
];
|
|
128
|
+
const hasEntry = entryPoints.some((p) => existsSync(join(projectPath, p)));
|
|
129
|
+
if (hasEntry) {
|
|
130
|
+
if ('vue' in deps || '@vue/cli-service' in deps) {
|
|
131
|
+
return FRAMEWORKS.vueCli;
|
|
132
|
+
}
|
|
133
|
+
if ('react-scripts' in deps) {
|
|
134
|
+
return FRAMEWORKS.cra;
|
|
135
|
+
}
|
|
136
|
+
if ('svelte' in deps || 'solid-js' in deps) {
|
|
137
|
+
return FRAMEWORKS.vite;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// The package/project readers of the detect-framework family: package.json
|
|
2
|
+
// parsing, package-manager detection, dependency collection, and the two
|
|
3
|
+
// output-dir resolvers (VitePress config scan, angular.json walk). Pure
|
|
4
|
+
// filesystem readers — no framework matching, no result shaping. The public
|
|
5
|
+
// face stays src/detect-framework.ts.
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
|
|
9
|
+
import { asRecord } from './lib/as-record.ts';
|
|
10
|
+
|
|
11
|
+
export function readPkg(projectPath: string): Record<string, unknown> | null {
|
|
12
|
+
const pkgPath = join(projectPath, 'package.json');
|
|
13
|
+
if (!existsSync(pkgPath)) return null;
|
|
14
|
+
try {
|
|
15
|
+
const parsed: unknown = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
16
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return null;
|
|
17
|
+
return parsed as Record<string, unknown>;
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function detectPackageManager(projectPath: string, pkg: Record<string, unknown> | null): string {
|
|
24
|
+
if (existsSync(join(projectPath, 'pnpm-lock.yaml'))) return 'pnpm';
|
|
25
|
+
if (existsSync(join(projectPath, 'yarn.lock'))) return 'yarn';
|
|
26
|
+
if (existsSync(join(projectPath, 'package-lock.json'))) return 'npm';
|
|
27
|
+
if (existsSync(join(projectPath, 'bun.lockb'))) return 'bun';
|
|
28
|
+
const declaredValue = pkg?.packageManager;
|
|
29
|
+
const declared = typeof declaredValue === 'string' ? declaredValue.split('@')[0] : '';
|
|
30
|
+
if (declared && ['pnpm', 'yarn', 'npm', 'bun'].includes(declared)) return declared;
|
|
31
|
+
return 'npm';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function collectDeps(pkg: Record<string, unknown> | null): Record<string, unknown> {
|
|
35
|
+
if (!pkg) return {};
|
|
36
|
+
return { ...asRecord(pkg.dependencies), ...asRecord(pkg.devDependencies) };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function readVitepressOutDir(projectPath: string): string | null {
|
|
40
|
+
const configFiles = ['config.mts', 'config.ts', 'config.mjs', 'config.js'];
|
|
41
|
+
for (const cf of configFiles) {
|
|
42
|
+
const configPath = join(projectPath, '.vitepress', cf);
|
|
43
|
+
if (!existsSync(configPath)) continue;
|
|
44
|
+
try {
|
|
45
|
+
const content = readFileSync(configPath, 'utf8');
|
|
46
|
+
const match = content.match(/outDir\s*:\s*['"`]?([^'"`\s,}]+)['"`]?/);
|
|
47
|
+
// The capture group is +-quantified; it always participates when the regex matches.
|
|
48
|
+
if (match) return match[1]!;
|
|
49
|
+
} catch {
|
|
50
|
+
// unreadable config: fall through to the next config file; null keeps the caller's default
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function resolveAngularOutput(projectPath: string, pkg: Record<string, unknown> | null): string {
|
|
57
|
+
try {
|
|
58
|
+
const angularJson = join(projectPath, 'angular.json');
|
|
59
|
+
if (existsSync(angularJson)) {
|
|
60
|
+
const config = asRecord(JSON.parse(readFileSync(angularJson, 'utf8')));
|
|
61
|
+
const projects = asRecord(config.projects);
|
|
62
|
+
const defaultProjectValue = config.defaultProject;
|
|
63
|
+
const defaultProject =
|
|
64
|
+
typeof defaultProjectValue === 'string' && defaultProjectValue ? defaultProjectValue : Object.keys(projects)[0];
|
|
65
|
+
const project = asRecord(defaultProject !== undefined ? projects[defaultProject] : undefined);
|
|
66
|
+
const architect = asRecord(project.architect);
|
|
67
|
+
const build = asRecord(architect.build);
|
|
68
|
+
const outputPath = asRecord(build.options).outputPath;
|
|
69
|
+
if (defaultProject && typeof outputPath === 'string' && outputPath) {
|
|
70
|
+
return outputPath;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
// ignore parse errors
|
|
75
|
+
}
|
|
76
|
+
const nameValue = pkg?.name;
|
|
77
|
+
const name = typeof nameValue === 'string' && nameValue ? nameValue : 'app';
|
|
78
|
+
return `dist/${name}`;
|
|
79
|
+
}
|