defimport_skill(self,resolved:ResolvedSkill,*,with_scripts:bool=False,force:bool=False,confirm_dangerous:bool=False,)->ImportResult:"""Install *resolved* into ``<target_root>/<source>/<name>/``. Returns an :class:`ImportResult` with status, paths, translated tools, untranslated tools, and warnings. """result=ImportResult()target_dir=self._target_root/resolved.source/resolved.nameresult.target_path=target_dir# Skip if already installed and force is Falseiftarget_dir.exists()andnotforce:result.skipped=Trueresult.warnings.append(f"Skill already installed at {target_dir} (use force=True to overwrite)")returnresult# 1. Parse source SKILL.mdsource_md=resolved.path/"SKILL.md"ifnotsource_md.exists():source_md=resolved.path/"skill.md"ifnotsource_md.exists():result.success=Falseresult.warnings.append(f"No SKILL.md found in {resolved.path}")returnresulttry:frontmatter,body=self._read_skill_md(source_md)manifest=self._parser.parse_frontmatter(frontmatter,markdown_content=body)exceptExceptionasexc:result.success=Falseresult.warnings.append(f"Parse error: {exc}")returnresult# 1a. Classify trust and check for dangerous capabilities *before*# writing anything to disk. Everything the importer handles comes from# an external source (github/hermes/openclaw), so the BUNDLED and# WORKSPACE tiers never apply here, and no resolver verifies index# membership yet — a signature alone still classifies as UNREVIEWED.# Community skills get no special treatment just because they came# from a named source.result.trust_tier=classify_trust_tier(has_signature=bool(manifest.signature),)result.dangerous_capabilities=has_dangerous_capabilities(manifest)ifresult.dangerous_capabilitiesandresult.trust_tier==TrustTier.UNREVIEWED:result.requires_confirmation=Trueifnotconfirm_dangerous:result.success=Falseresult.warnings.append("Refusing to install: this unreviewed skill requests "f"dangerous capabilities {result.dangerous_capabilities}. ""Re-run with confirm_dangerous=True (or `--yes-dangerous` ""on the CLI) only if you trust the source and have ""reviewed what it does.")returnresultresult.warnings.append("Installed with dangerous capabilities "f"{result.dangerous_capabilities} — confirmed by caller. ""This skill can run shell commands, open network listeners, ""and/or write to the filesystem.")# 2. Translate tool referencestranslated_body,untranslated=self._translator.translate_markdown(body)result.untranslated_tools=untranslated# Compute the list of translations actually appliedapplied:List[str]=[]forext,internalinself._translator._table.items():ifextinbodyandextnotintranslated_body:applied.append(f"{ext}->{internal}")result.translated_tools=applied# 3. Write the target directoryiftarget_dir.exists():shutil.rmtree(target_dir)target_dir.mkdir(parents=True)# 3a. Translated SKILL.mdnew_md=self._render_skill_md(frontmatter,translated_body)(target_dir/"SKILL.md").write_text(new_md,encoding="utf-8")# 3b. Always-copied subdirsforsubdirinCOPIED_SUBDIRS:src_sub=resolved.path/subdirifsrc_sub.exists():shutil.copytree(src_sub,target_dir/subdir)# 3c. Scripts (gated by with_scripts)scripts_src=resolved.path/"scripts"ifscripts_src.exists()andwith_scripts:shutil.copytree(scripts_src,target_dir/"scripts")result.scripts_imported=Trueelifscripts_src.exists():result.warnings.append("Skipped scripts/ directory (use with_scripts=True to import)")# 4. Write .source metadataself._write_source_metadata(target_dir,resolved,result)returnresult