chore: sync skills from openai/plugins
This commit is contained in:
1 parent
4955fdb9cb
commit
09c63d9e91
10 files changed
+23
-205
No files matched your search
@@ -54,15 +54,9 @@
|
||||
indicator.textContent = 'Click an option above, then return to the terminal';
|
||||
} else if (selected.length === 1) {
|
||||
const label = selected[0].querySelector('h3, .content h3, .card-body h3')?.textContent?.trim() || selected[0].dataset.choice;
|
||||
const selectedText = document.createElement('span');
|
||||
selectedText.className = 'selected-text';
|
||||
selectedText.textContent = label + ' selected';
|
||||
indicator.replaceChildren(selectedText, document.createTextNode(' — return to terminal to continue'));
|
||||
indicator.innerHTML = '<span class="selected-text">' + label + ' selected</span> — return to terminal to continue';
|
||||
} else {
|
||||
const selectedText = document.createElement('span');
|
||||
selectedText.className = 'selected-text';
|
||||
selectedText.textContent = selected.length + ' selected';
|
||||
indicator.replaceChildren(selectedText, document.createTextNode(' — return to terminal to continue'));
|
||||
indicator.innerHTML = '<span class="selected-text">' + selected.length + ' selected</span> — return to terminal to continue';
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ def fetch_gene_phewas(gene_id: str, burden_set: str) -> tuple[str, Any, int]:
|
||||
try:
|
||||
data = resp.json()
|
||||
except ValueError as exc:
|
||||
raise RuntimeError("Genebass API returned non-JSON.") from exc
|
||||
raise RuntimeError(f"Genebass API returned non-JSON for URL {url}") from exc
|
||||
return url, data, status_code
|
||||
|
||||
|
||||
@@ -207,10 +207,9 @@ def main() -> int:
|
||||
return 2
|
||||
|
||||
try:
|
||||
_query_url, data, status_code = fetch_gene_phewas(gene_id, burden_set)
|
||||
query_url, data, status_code = fetch_gene_phewas(gene_id, burden_set)
|
||||
except requests.RequestException as exc:
|
||||
message = str(exc).replace(gene_id, "<gene_id>")
|
||||
sys.stdout.write(json.dumps(error("network_error", f"Genebass request failed: {message}")))
|
||||
sys.stdout.write(json.dumps(error("network_error", f"Genebass request failed: {exc}")))
|
||||
return 1
|
||||
except RuntimeError as exc:
|
||||
message = str(exc)
|
||||
@@ -230,13 +229,14 @@ def main() -> int:
|
||||
output = {
|
||||
"ok": True,
|
||||
"source": "genebass",
|
||||
"input": {"type": "ensembl_gene_id", "provided": True},
|
||||
"input": {"type": "ensembl_gene_id", "value": gene_id},
|
||||
"burden_set": burden_set,
|
||||
"query_url": query_url,
|
||||
"gene": None,
|
||||
"association_count": 0,
|
||||
"association_count_total": 0,
|
||||
"truncated": False,
|
||||
"associations_available": False,
|
||||
"associations": [],
|
||||
"warnings": warnings,
|
||||
}
|
||||
sys.stdout.write(json.dumps(output))
|
||||
@@ -269,13 +269,14 @@ def main() -> int:
|
||||
output = {
|
||||
"ok": True,
|
||||
"source": "genebass",
|
||||
"input": {"type": "ensembl_gene_id", "provided": True},
|
||||
"input": {"type": "ensembl_gene_id", "value": gene_id},
|
||||
"burden_set": burden_set,
|
||||
"gene_available": gene_out is not None,
|
||||
"query_url": query_url,
|
||||
"gene": gene_out,
|
||||
"association_count": len(associations),
|
||||
"association_count_total": total,
|
||||
"truncated": truncated,
|
||||
"associations_available": bool(associations),
|
||||
"associations": associations,
|
||||
"warnings": warnings,
|
||||
}
|
||||
sys.stdout.write(json.dumps(output))
|
||||
|
||||
@@ -270,59 +270,6 @@ def _redact(text: str, secrets: list[str]) -> str:
|
||||
return redacted
|
||||
|
||||
|
||||
def _redact_sensitive_payload(value: Any, *, key_name: str = "") -> Any:
|
||||
if isinstance(value, dict):
|
||||
return {key: _redact_sensitive_payload(item, key_name=str(key)) for key, item in value.items()}
|
||||
if isinstance(value, list):
|
||||
return [_redact_sensitive_payload(item, key_name=key_name) for item in value]
|
||||
if _is_secret_name(key_name) and value not in (None, ""):
|
||||
return "<redacted>"
|
||||
return value
|
||||
|
||||
|
||||
def _public_manifest_summary(manifest: dict[str, Any]) -> dict[str, Any]:
|
||||
return {
|
||||
"schema_version": manifest.get("schema_version"),
|
||||
"skill": manifest.get("skill"),
|
||||
"status": manifest.get("status"),
|
||||
"generated_at": manifest.get("generated_at"),
|
||||
"preflight_mode": manifest.get("preflight_mode"),
|
||||
"dependency_policy": manifest.get("dependency_policy"),
|
||||
"platform": {
|
||||
"system": manifest.get("platform", {}).get("system"),
|
||||
"machine": manifest.get("platform", {}).get("machine"),
|
||||
"python": manifest.get("platform", {}).get("python"),
|
||||
},
|
||||
"targets": manifest.get("targets", []),
|
||||
"conversion_tools": manifest.get("conversion_tools", []),
|
||||
"runtimes": {
|
||||
name: {
|
||||
"status": entry.get("status"),
|
||||
"message": entry.get("message", ""),
|
||||
}
|
||||
for name, entry in manifest.get("runtimes", {}).items()
|
||||
if isinstance(entry, dict)
|
||||
},
|
||||
"services": {
|
||||
name: {
|
||||
"status": entry.get("status"),
|
||||
"message": entry.get("message", ""),
|
||||
}
|
||||
for name, entry in manifest.get("services", {}).items()
|
||||
if isinstance(entry, dict)
|
||||
},
|
||||
"blocker_count": len(manifest.get("blockers", [])),
|
||||
}
|
||||
|
||||
|
||||
def _public_preflight_report() -> dict[str, str]:
|
||||
return {
|
||||
"schema_version": SCHEMA_VERSION,
|
||||
"skill": SKILL,
|
||||
"report": "Detailed preflight state is omitted from this public report to avoid writing credentials or derived secret material.",
|
||||
}
|
||||
|
||||
|
||||
def _run(
|
||||
command: list[str],
|
||||
*,
|
||||
@@ -1671,17 +1618,16 @@ def main(argv: list[str] | None = None) -> int:
|
||||
args = parser.parse_args(argv)
|
||||
|
||||
manifest, env = build_manifest(args)
|
||||
report_manifest = _public_preflight_report()
|
||||
manifest_path = Path(manifest["manifest_path"])
|
||||
manifest_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
manifest_path.write_text(json.dumps(report_manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
manifest_path.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
if args.env_file:
|
||||
_write_env_file(args.env_file.expanduser().resolve(), env)
|
||||
if args.powershell_env_file:
|
||||
_write_powershell_env_file(args.powershell_env_file.expanduser().resolve(), env)
|
||||
if args.markdown_report:
|
||||
_write_markdown(args.markdown_report.expanduser().resolve(), report_manifest)
|
||||
print(json.dumps(report_manifest, indent=2, sort_keys=True))
|
||||
_write_markdown(args.markdown_report.expanduser().resolve(), manifest)
|
||||
print(json.dumps(manifest, indent=2, sort_keys=True))
|
||||
return 0 if manifest["status"] == "ready" else 1
|
||||
|
||||
|
||||
|
||||
@@ -806,24 +806,8 @@ var require_blockString = __commonJS({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const BLOCK_STRING_QUOTE = '"'.repeat(3);
|
||||
const ESCAPED_BLOCK_STRING_QUOTE = "\\" + BLOCK_STRING_QUOTE;
|
||||
function escapeBlockStringTripleQuotes(value) {
|
||||
let result = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
if (value.startsWith(BLOCK_STRING_QUOTE, index)) {
|
||||
result += ESCAPED_BLOCK_STRING_QUOTE;
|
||||
index += BLOCK_STRING_QUOTE.length;
|
||||
} else {
|
||||
result += value[index];
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function printBlockString(value, options) {
|
||||
const escapedValue = escapeBlockStringTripleQuotes(value);
|
||||
const escapedValue = value.replace(/"""/g, '\\"""');
|
||||
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
||||
const isSingleLine = lines.length === 1;
|
||||
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every(
|
||||
|
||||
@@ -806,24 +806,8 @@ var require_blockString = __commonJS({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const BLOCK_STRING_QUOTE = '"'.repeat(3);
|
||||
const ESCAPED_BLOCK_STRING_QUOTE = "\\" + BLOCK_STRING_QUOTE;
|
||||
function escapeBlockStringTripleQuotes(value) {
|
||||
let result = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
if (value.startsWith(BLOCK_STRING_QUOTE, index)) {
|
||||
result += ESCAPED_BLOCK_STRING_QUOTE;
|
||||
index += BLOCK_STRING_QUOTE.length;
|
||||
} else {
|
||||
result += value[index];
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function printBlockString(value, options) {
|
||||
const escapedValue = escapeBlockStringTripleQuotes(value);
|
||||
const escapedValue = value.replace(/"""/g, '\\"""');
|
||||
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
||||
const isSingleLine = lines.length === 1;
|
||||
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every(
|
||||
|
||||
@@ -806,24 +806,8 @@ var require_blockString = __commonJS({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const BLOCK_STRING_QUOTE = '"'.repeat(3);
|
||||
const ESCAPED_BLOCK_STRING_QUOTE = "\\" + BLOCK_STRING_QUOTE;
|
||||
function escapeBlockStringTripleQuotes(value) {
|
||||
let result = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
if (value.startsWith(BLOCK_STRING_QUOTE, index)) {
|
||||
result += ESCAPED_BLOCK_STRING_QUOTE;
|
||||
index += BLOCK_STRING_QUOTE.length;
|
||||
} else {
|
||||
result += value[index];
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function printBlockString(value, options) {
|
||||
const escapedValue = escapeBlockStringTripleQuotes(value);
|
||||
const escapedValue = value.replace(/"""/g, '\\"""');
|
||||
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
||||
const isSingleLine = lines.length === 1;
|
||||
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every(
|
||||
|
||||
@@ -806,24 +806,8 @@ var require_blockString = __commonJS({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const BLOCK_STRING_QUOTE = '"'.repeat(3);
|
||||
const ESCAPED_BLOCK_STRING_QUOTE = "\\" + BLOCK_STRING_QUOTE;
|
||||
function escapeBlockStringTripleQuotes(value) {
|
||||
let result = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
if (value.startsWith(BLOCK_STRING_QUOTE, index)) {
|
||||
result += ESCAPED_BLOCK_STRING_QUOTE;
|
||||
index += BLOCK_STRING_QUOTE.length;
|
||||
} else {
|
||||
result += value[index];
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function printBlockString(value, options) {
|
||||
const escapedValue = escapeBlockStringTripleQuotes(value);
|
||||
const escapedValue = value.replace(/"""/g, '\\"""');
|
||||
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
||||
const isSingleLine = lines.length === 1;
|
||||
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every(
|
||||
|
||||
@@ -806,24 +806,8 @@ var require_blockString = __commonJS({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const BLOCK_STRING_QUOTE = '"'.repeat(3);
|
||||
const ESCAPED_BLOCK_STRING_QUOTE = "\\" + BLOCK_STRING_QUOTE;
|
||||
function escapeBlockStringTripleQuotes(value) {
|
||||
let result = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
if (value.startsWith(BLOCK_STRING_QUOTE, index)) {
|
||||
result += ESCAPED_BLOCK_STRING_QUOTE;
|
||||
index += BLOCK_STRING_QUOTE.length;
|
||||
} else {
|
||||
result += value[index];
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function printBlockString(value, options) {
|
||||
const escapedValue = escapeBlockStringTripleQuotes(value);
|
||||
const escapedValue = value.replace(/"""/g, '\\"""');
|
||||
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
||||
const isSingleLine = lines.length === 1;
|
||||
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every(
|
||||
|
||||
@@ -806,24 +806,8 @@ var require_blockString = __commonJS({
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const BLOCK_STRING_QUOTE = '"'.repeat(3);
|
||||
const ESCAPED_BLOCK_STRING_QUOTE = "\\" + BLOCK_STRING_QUOTE;
|
||||
function escapeBlockStringTripleQuotes(value) {
|
||||
let result = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
if (value.startsWith(BLOCK_STRING_QUOTE, index)) {
|
||||
result += ESCAPED_BLOCK_STRING_QUOTE;
|
||||
index += BLOCK_STRING_QUOTE.length;
|
||||
} else {
|
||||
result += value[index];
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function printBlockString(value, options) {
|
||||
const escapedValue = escapeBlockStringTripleQuotes(value);
|
||||
const escapedValue = value.replace(/"""/g, '\\"""');
|
||||
const lines = escapedValue.split(/\r\n|[\n\r]/g);
|
||||
const isSingleLine = lines.length === 1;
|
||||
const forceLeadingNewLine = lines.length > 1 && lines.slice(1).every(
|
||||
|
||||
@@ -101,33 +101,6 @@ const warnings = [];
|
||||
|
||||
const SLOT_DIV_REGEX = /(<div[^>]*\bdata-decorative-slot="([^"]+)"[^>]*>)([\s\S]*?)(<\/div>)/g;
|
||||
|
||||
function removeHtmlComments(value) {
|
||||
let output = "";
|
||||
let index = 0;
|
||||
while (index < value.length) {
|
||||
const start = value.indexOf("<!--", index);
|
||||
if (start === -1) {
|
||||
output += value.slice(index);
|
||||
break;
|
||||
}
|
||||
output += value.slice(index, start);
|
||||
const end = value.indexOf("-->", start + 4);
|
||||
if (end === -1) {
|
||||
break;
|
||||
}
|
||||
index = end + 3;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function escapeHtmlAttribute(value) {
|
||||
return value
|
||||
.replace(/&/g, "&")
|
||||
.replace(/"/g, """)
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
}
|
||||
|
||||
for (const file of candidates) {
|
||||
const original = readFileSync(file, "utf8");
|
||||
let modified = original;
|
||||
@@ -140,7 +113,7 @@ for (const file of candidates) {
|
||||
return match;
|
||||
}
|
||||
|
||||
const stripped = removeHtmlComments(inner).trim();
|
||||
const stripped = inner.replace(/<!--[\s\S]*?-->/g, "").trim();
|
||||
|
||||
if (/<img\b/i.test(stripped)) {
|
||||
skipped.push({ file, slot: slotKey, reason: "div already contains an <img> tag (idempotent skip)" });
|
||||
@@ -153,7 +126,7 @@ for (const file of candidates) {
|
||||
}
|
||||
|
||||
fileChanged = true;
|
||||
const img = `<img src="${escapeHtmlAttribute(url)}" alt="" loading="lazy" decoding="async" class="decorative-slot-img" />`;
|
||||
const img = `<img src="${url}" alt="" loading="lazy" decoding="async" class="decorative-slot-img" />`;
|
||||
patched.push({ file, slot: slotKey });
|
||||
return `${openTag}\n ${img}${inner}${closeTag}`;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user