@iasiv5/dsh-skills 1.0.6 → 1.2.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/NOTICE.md +7 -10
- package/README.md +1 -1
- package/package.json +1 -1
- package/skills/answer-me-with-html/SKILL.md +3 -1
- package/skills/answer-me-with-html/references/settings.md +1 -1
- package/skills/answer-me-with-html/references/video.md +1 -0
- package/skills/answer-me-with-html/scripts/am.mjs +2567 -2064
- package/skills/docx/LICENSE.txt +202 -0
- package/skills/docx/SKILL.md +91 -0
- package/skills/docx/scripts/__init__.py +1 -0
- package/skills/docx/scripts/accept_changes.py +135 -0
- package/skills/docx/scripts/comment.py +368 -0
- package/skills/docx/scripts/merge_runs.py +310 -0
- package/skills/docx/scripts/office/helpers/__init__.py +111 -0
- package/skills/docx/scripts/office/helpers/pptx_chart.py +170 -0
- package/skills/docx/scripts/office/helpers/pptx_slide.py +60 -0
- package/skills/docx/scripts/office/helpers/pptx_theme.py +114 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/docx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/docx/scripts/office/soffice.py +192 -0
- package/skills/docx/scripts/office/validate.py +173 -0
- package/skills/docx/scripts/office/validators/__init__.py +15 -0
- package/skills/docx/scripts/office/validators/base.py +875 -0
- package/skills/docx/scripts/office/validators/docx.py +466 -0
- package/skills/docx/scripts/office/validators/pptx.py +441 -0
- package/skills/docx/scripts/office/validators/redlining.py +299 -0
- package/skills/docx/scripts/templates/comments.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtended.xml +3 -0
- package/skills/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/skills/docx/scripts/templates/commentsIds.xml +3 -0
- package/skills/docx/scripts/templates/people.xml +3 -0
- package/skills/impeccable/SKILL.md +87 -0
- package/skills/impeccable/reference/adapt.md +318 -0
- package/skills/impeccable/reference/adapt.native.md +58 -0
- package/skills/impeccable/reference/android.md +46 -0
- package/skills/impeccable/reference/animate.md +89 -0
- package/skills/impeccable/reference/audit.md +150 -0
- package/skills/impeccable/reference/audit.native.md +143 -0
- package/skills/impeccable/reference/bolder.md +33 -0
- package/skills/impeccable/reference/clarify.md +94 -0
- package/skills/impeccable/reference/colorize.md +86 -0
- package/skills/impeccable/reference/component-review.md +63 -0
- package/skills/impeccable/reference/craft-floor.md +44 -0
- package/skills/impeccable/reference/craft.md +5 -0
- package/skills/impeccable/reference/critique.md +819 -0
- package/skills/impeccable/reference/degraded/asset-producer.md +42 -0
- package/skills/impeccable/reference/degraded/documenter.md +24 -0
- package/skills/impeccable/reference/degraded/finish-reviewer.md +38 -0
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +93 -0
- package/skills/impeccable/reference/delight.md +70 -0
- package/skills/impeccable/reference/distill.md +111 -0
- package/skills/impeccable/reference/doctor.md +54 -0
- package/skills/impeccable/reference/document.md +416 -0
- package/skills/impeccable/reference/extract.md +69 -0
- package/skills/impeccable/reference/generate.md +101 -0
- package/skills/impeccable/reference/harden.md +362 -0
- package/skills/impeccable/reference/hooks.md +120 -0
- package/skills/impeccable/reference/init.md +133 -0
- package/skills/impeccable/reference/ios.md +51 -0
- package/skills/impeccable/reference/layout.md +84 -0
- package/skills/impeccable/reference/live-setup.md +104 -0
- package/skills/impeccable/reference/live.md +327 -0
- package/skills/impeccable/reference/mode-operate.md +21 -0
- package/skills/impeccable/reference/mode-persuade.md +19 -0
- package/skills/impeccable/reference/mode-read.md +21 -0
- package/skills/impeccable/reference/new-work.md +152 -0
- package/skills/impeccable/reference/onboard.md +235 -0
- package/skills/impeccable/reference/operate.md +61 -0
- package/skills/impeccable/reference/optimize.md +257 -0
- package/skills/impeccable/reference/overdrive.md +127 -0
- package/skills/impeccable/reference/polish.md +105 -0
- package/skills/impeccable/reference/quieter.md +99 -0
- package/skills/impeccable/reference/region-map.md +26 -0
- package/skills/impeccable/reference/routing.md +24 -0
- package/skills/impeccable/reference/shape.md +59 -0
- package/skills/impeccable/reference/typeset.md +90 -0
- package/skills/impeccable/reference/visualize.md +47 -0
- package/skills/impeccable/scripts/VERSION +1 -0
- package/skills/impeccable/scripts/command-metadata.json +98 -0
- package/skills/impeccable/scripts/data/font-index-failures.json +121 -0
- package/skills/impeccable/scripts/data/font-index.json +1 -0
- package/skills/impeccable/scripts/engine-checksums.txt +9 -0
- package/skills/impeccable/scripts/impeccable +291 -0
- package/skills/impeccable/scripts/impeccable.cmd +337 -0
- package/skills/impeccable/scripts/live-browser-dom.js +320 -0
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -0
- package/skills/impeccable/scripts/live-browser-session.js +183 -0
- package/skills/impeccable/scripts/live-browser.js +13872 -0
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -0
- package/skills/pdf/LICENSE.txt +202 -0
- package/skills/pdf/SKILL.md +314 -0
- package/skills/pdf/forms.md +294 -0
- package/skills/pdf/reference.md +612 -0
- package/skills/pdf/scripts/check_bounding_boxes.py +65 -0
- package/skills/pdf/scripts/check_fillable_fields.py +11 -0
- package/skills/pdf/scripts/convert_pdf_to_images.py +33 -0
- package/skills/pdf/scripts/create_validation_image.py +37 -0
- package/skills/pdf/scripts/extract_form_field_info.py +122 -0
- package/skills/pdf/scripts/extract_form_structure.py +115 -0
- package/skills/pdf/scripts/fill_fillable_fields.py +98 -0
- package/skills/pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
- package/skills/xlsx/LICENSE.txt +202 -0
- package/skills/xlsx/SKILL.md +99 -0
- package/skills/xlsx/scripts/office/helpers/__init__.py +111 -0
- package/skills/xlsx/scripts/office/helpers/pptx_chart.py +170 -0
- package/skills/xlsx/scripts/office/helpers/pptx_slide.py +60 -0
- package/skills/xlsx/scripts/office/helpers/pptx_theme.py +114 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
- package/skills/xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
- package/skills/xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
- package/skills/xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
- package/skills/xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
- package/skills/xlsx/scripts/office/soffice.py +192 -0
- package/skills/xlsx/scripts/office/validate.py +173 -0
- package/skills/xlsx/scripts/office/validators/__init__.py +15 -0
- package/skills/xlsx/scripts/office/validators/base.py +875 -0
- package/skills/xlsx/scripts/office/validators/docx.py +466 -0
- package/skills/xlsx/scripts/office/validators/pptx.py +441 -0
- package/skills/xlsx/scripts/office/validators/redlining.py +299 -0
- package/skills/xlsx/scripts/recalc.py +308 -0
- package/skills-manifest.json +36 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Engine binary digests for the pinned ENGINE_VERSION: <engine-version> <asset> <sha256>.
|
|
2
|
+
# The launchers, the npm shim, `impeccable install` and scripts/fetch-engine.mjs verify
|
|
3
|
+
# every engine download against this file. Written by
|
|
4
|
+
# `node scripts/check-engine-release.mjs --record` after each engine release.
|
|
5
|
+
0.1.22 impeccable-darwin-arm64 afaf25d233e69580ec4566c0bbe07438ed18a67ba6ba8541fc079eadf842fa44
|
|
6
|
+
0.1.22 impeccable-darwin-x64 e4456dd6907d4c9a9097df79007d7258826b28c9a0fa6f1959921a971f64ead8
|
|
7
|
+
0.1.22 impeccable-linux-x64 5dd7f4ad6c19f37f4e2a1465b7fade03c84de9fbeda77a0454e31570d4849533
|
|
8
|
+
0.1.22 impeccable-linux-arm64 951e06ff7d487bcf3f605e943f3fc110abfa5f2bb2a1704a2d9a068641e55b44
|
|
9
|
+
0.1.22 impeccable-windows-x64.exe 4bacf8c756ec3fda3b9fcb69bf1869d4d700ff471be1e31cbff669222dcd8ff2
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Impeccable launcher. Runs the platform binary shipped next to this script:
|
|
3
|
+
# <this dir>/bin/<os>-<arch>/impeccable
|
|
4
|
+
# Order: $IMPECCABLE_BIN, the sibling binary, ~/.impeccable/bin/impeccable,
|
|
5
|
+
# the version-pinned cache, then `impeccable` on PATH. Never needs Node.
|
|
6
|
+
# The unversioned home binary and the PATH candidate are validated with the
|
|
7
|
+
# engine-probe handshake first: the retired 3.x npm CLI also installed a bin
|
|
8
|
+
# named `impeccable`, and exec'ing it would fail every verb with
|
|
9
|
+
# "Unknown command". The sibling binary must also report the version in
|
|
10
|
+
# VERSION: it is gitignored, so a skill upgrade that copies files over this
|
|
11
|
+
# directory leaves the old engine in place. A local build of the same version
|
|
12
|
+
# passes, which is why it is not hashed. IMPECCABLE_BIN is the operator's
|
|
13
|
+
# explicit choice and is exec'd without a probe. The version-pinned cache and
|
|
14
|
+
# the download are verified against engine-checksums.txt (next to this
|
|
15
|
+
# script), never against anything published beside the binary; a
|
|
16
|
+
# <binary>.verified stamp holding the manifest digest and the binary's size
|
|
17
|
+
# skips rehashing until either changes or the binary is newer than the stamp.
|
|
18
|
+
# No path hashes on every run: hooks run this launcher on every edit.
|
|
19
|
+
set -eu
|
|
20
|
+
|
|
21
|
+
# True when the candidate answers the engine handshake (prints
|
|
22
|
+
# "impeccable-engine <version>", exit 0). Quiet and fast (<100ms).
|
|
23
|
+
# IMPECCABLE_LAUNCHER_PROBE marks the child as a probe: a copy of this
|
|
24
|
+
# launcher reached recursively (e.g. symlinked onto PATH as `impeccable`)
|
|
25
|
+
# then skips its own probes and refuses to download, so probing stays cheap
|
|
26
|
+
# and can never loop.
|
|
27
|
+
probe_ok() {
|
|
28
|
+
probe_out=$(IMPECCABLE_LAUNCHER_PROBE=1 "$1" engine-probe 2>/dev/null) || return 1
|
|
29
|
+
case "$probe_out" in
|
|
30
|
+
impeccable-engine*) probe_version=${probe_out#impeccable-engine }; return 0 ;;
|
|
31
|
+
esac
|
|
32
|
+
return 1
|
|
33
|
+
}
|
|
34
|
+
probing=${IMPECCABLE_LAUNCHER_PROBE:-}
|
|
35
|
+
|
|
36
|
+
# Prints the digest engine-checksums.txt records for engine version $1 and
|
|
37
|
+
# asset $2 (lines are "<version> <asset> <sha256>"), nothing when there is none.
|
|
38
|
+
# A CR is a separator too (CRLF checkouts), and a last line with no newline
|
|
39
|
+
# still counts.
|
|
40
|
+
manifest_digest() {
|
|
41
|
+
[ -f "$manifest" ] || return 0
|
|
42
|
+
sep=$(printf ' \t\r')
|
|
43
|
+
while IFS="$sep" read -r m_version m_asset m_sum _ || [ -n "$m_version" ]; do
|
|
44
|
+
case "$m_version" in ''|'#'*) continue ;; esac
|
|
45
|
+
if [ "$m_version" = "$1" ] && [ "$m_asset" = "$2" ]; then
|
|
46
|
+
printf '%s' "$m_sum"
|
|
47
|
+
return 0
|
|
48
|
+
fi
|
|
49
|
+
done < "$manifest"
|
|
50
|
+
return 0
|
|
51
|
+
}
|
|
52
|
+
# Sets $expected (and, on Windows on ARM, which runs x64 binaries,
|
|
53
|
+
# $expected_x64) from engine-checksums.txt.
|
|
54
|
+
read_expected() {
|
|
55
|
+
expected=$(manifest_digest "$version" "$asset")
|
|
56
|
+
expected_x64=""
|
|
57
|
+
if [ "$os" = windows ] && [ "$arch" = arm64 ]; then
|
|
58
|
+
expected_x64=$(manifest_digest "$version" impeccable-windows-x64.exe)
|
|
59
|
+
fi
|
|
60
|
+
}
|
|
61
|
+
# Sets $size to the byte count of the cached binary (BSD wc pads it).
|
|
62
|
+
cached_size() {
|
|
63
|
+
size=$(wc -c < "$cached") || size=""
|
|
64
|
+
size=${size##* }
|
|
65
|
+
}
|
|
66
|
+
# Sets $actual to the sha256 of $1, empty when no hash tool works.
|
|
67
|
+
hash_file() {
|
|
68
|
+
actual=""
|
|
69
|
+
if command -v shasum >/dev/null 2>&1; then
|
|
70
|
+
if digest=$(shasum -a 256 "$1" 2>/dev/null); then actual=${digest%% *}; fi
|
|
71
|
+
elif command -v sha256sum >/dev/null 2>&1; then
|
|
72
|
+
if digest=$(sha256sum "$1" 2>/dev/null); then actual=${digest%% *}; fi
|
|
73
|
+
fi
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
77
|
+
# VS Code syncs a plugin without the executable bit. Its hooks run this through
|
|
78
|
+
# sh, so restore the bit for the commands the skill runs directly (#1249).
|
|
79
|
+
[ -x "$0" ] || chmod +x "$0" 2>/dev/null || :
|
|
80
|
+
manifest="$dir/engine-checksums.txt"
|
|
81
|
+
|
|
82
|
+
# What the binary needs to know about its home: the skill directory (for
|
|
83
|
+
# reference/*.md and command-metadata.json) and how to name itself in the
|
|
84
|
+
# commands it prints. Exported BEFORE any exec below, including the
|
|
85
|
+
# IMPECCABLE_BIN override: an engine binary reached with no IMPECCABLE_SKILL_DIR
|
|
86
|
+
# cannot find reference/*.md (so native platform refs never inline) or read its
|
|
87
|
+
# own version (so UPDATE_AVAILABLE never fires). Setting it here covers every
|
|
88
|
+
# candidate the launcher can exec.
|
|
89
|
+
: "${IMPECCABLE_SKILL_DIR:=$(CDPATH= cd -- "$dir/.." && pwd)}"
|
|
90
|
+
: "${IMPECCABLE_SELF:=$0}"
|
|
91
|
+
export IMPECCABLE_SKILL_DIR IMPECCABLE_SELF
|
|
92
|
+
|
|
93
|
+
if [ -n "${IMPECCABLE_BIN:-}" ] && [ -x "${IMPECCABLE_BIN}" ]; then
|
|
94
|
+
exec "${IMPECCABLE_BIN}" "$@"
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
case "$(uname -s 2>/dev/null || echo unknown)" in
|
|
98
|
+
Darwin) os=darwin ;;
|
|
99
|
+
Linux) os=linux ;;
|
|
100
|
+
MINGW*|MSYS*|CYGWIN*|Windows_NT) os=windows ;;
|
|
101
|
+
*) os=unknown ;;
|
|
102
|
+
esac
|
|
103
|
+
case "$(uname -m 2>/dev/null || echo unknown)" in
|
|
104
|
+
arm64|aarch64) arch=arm64 ;;
|
|
105
|
+
x86_64|amd64) arch=x64 ;;
|
|
106
|
+
*) arch=unknown ;;
|
|
107
|
+
esac
|
|
108
|
+
|
|
109
|
+
version=""
|
|
110
|
+
[ -f "$dir/VERSION" ] && version=$(tr -d '[:space:]' < "$dir/VERSION")
|
|
111
|
+
bin="$dir/bin/$os-$arch/impeccable"
|
|
112
|
+
[ "$os" = windows ] && bin="$bin.exe"
|
|
113
|
+
|
|
114
|
+
# Lost the executable bit in transit (zip extraction, some copiers).
|
|
115
|
+
if [ -f "$bin" ] && { [ -x "$bin" ] || chmod +x "$bin" 2>/dev/null; }; then
|
|
116
|
+
if [ -n "$probing" ] || [ -z "$version" ] || { probe_ok "$bin" && [ "$probe_version" = "$version" ]; }; then
|
|
117
|
+
exec "$bin" "$@"
|
|
118
|
+
fi
|
|
119
|
+
echo "impeccable: skipping $bin: it reports engine ${probe_version:-unknown} but this skill pins $version; delete it to stop this warning" >&2
|
|
120
|
+
fi
|
|
121
|
+
# On Windows (an MSYS/Git Bash shell) the cached names carry .exe so this
|
|
122
|
+
# launcher and impeccable.cmd share one cache.
|
|
123
|
+
exe=""
|
|
124
|
+
[ "$os" = windows ] && exe=".exe"
|
|
125
|
+
home_bin="${HOME:-/nonexistent}/.impeccable/bin/impeccable$exe"
|
|
126
|
+
if [ -z "$probing" ] && [ -x "$home_bin" ] && probe_ok "$home_bin"; then
|
|
127
|
+
exec "$home_bin" "$@"
|
|
128
|
+
fi
|
|
129
|
+
# Version-pinned user cache, filled by the download below or by `impeccable update`.
|
|
130
|
+
cache_root="${IMPECCABLE_HOME:-${HOME:-/nonexistent}/.impeccable}"
|
|
131
|
+
cached="$cache_root/bin/$version/impeccable$exe"
|
|
132
|
+
asset="impeccable-$os-$arch"
|
|
133
|
+
[ "$os" = windows ] && asset="$asset.exe"
|
|
134
|
+
if [ -n "$version" ] && [ -x "$cached" ]; then
|
|
135
|
+
read_expected
|
|
136
|
+
cached_size
|
|
137
|
+
stamp=""
|
|
138
|
+
stamp_size=""
|
|
139
|
+
{ IFS="$(printf ' \t\r')" read -r stamp stamp_size _ < "$cached.verified"; } 2>/dev/null || :
|
|
140
|
+
if [ -n "$stamp" ] && [ "$stamp_size" = "$size" ] && { [ "$stamp" = "$expected" ] || [ "$stamp" = "$expected_x64" ]; } && [ ! "$cached" -nt "$cached.verified" ]; then
|
|
141
|
+
exec "$cached" "$@"
|
|
142
|
+
fi
|
|
143
|
+
hash_file "$cached"
|
|
144
|
+
if [ -n "$actual" ] && { [ "$actual" = "$expected" ] || [ "$actual" = "$expected_x64" ]; }; then
|
|
145
|
+
{ echo "$actual $size" > "$cached.verified"; } 2>/dev/null || :
|
|
146
|
+
exec "$cached" "$@"
|
|
147
|
+
fi
|
|
148
|
+
echo "impeccable: cannot verify the cached engine $cached against $manifest; not using it" >&2
|
|
149
|
+
fi
|
|
150
|
+
if [ -z "$probing" ] && command -v impeccable >/dev/null 2>&1 && probe_ok impeccable; then
|
|
151
|
+
exec impeccable "$@"
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
# Last resort: fetch this version's binary for the current platform from the
|
|
155
|
+
# public release channel into the user cache. Needs network; sandboxes without
|
|
156
|
+
# egress preinstall the binary on PATH instead.
|
|
157
|
+
setup_help() {
|
|
158
|
+
echo "Engine $version setup needs network access and write permission to $cache_root/bin/$version." >&2
|
|
159
|
+
echo "Run this launcher ($0) with engine-probe in a terminal that has those permissions, then retry the original command." >&2
|
|
160
|
+
echo "Alternatively, set IMPECCABLE_HOME to a writable cache location, or IMPECCABLE_BIN to a preinstalled engine binary." >&2
|
|
161
|
+
}
|
|
162
|
+
fetch_url() {
|
|
163
|
+
http_status=""
|
|
164
|
+
download_host=""
|
|
165
|
+
if command -v curl >/dev/null 2>&1; then
|
|
166
|
+
fetch_result=0
|
|
167
|
+
metadata=$(curl -fsSL --retry 2 -w '%{http_code} %{url_effective}' -o "$tmp" "$1" 2>/dev/null) || fetch_result=$?
|
|
168
|
+
http_status=${metadata%% *}
|
|
169
|
+
effective_url=${metadata#* }
|
|
170
|
+
# Only the authority is needed, never the signed storage URL's query.
|
|
171
|
+
download_host=${effective_url#*://}
|
|
172
|
+
download_host=${download_host%%/*}
|
|
173
|
+
download_host=${download_host##*@}
|
|
174
|
+
case "$download_host" in
|
|
175
|
+
\[*) download_host=${download_host%%]*}] ;;
|
|
176
|
+
*) download_host=${download_host%%:*} ;;
|
|
177
|
+
esac
|
|
178
|
+
download_host=$(printf '%s' "$download_host" | tr '[:upper:]' '[:lower:]')
|
|
179
|
+
return "$fetch_result"
|
|
180
|
+
elif command -v wget >/dev/null 2>&1; then
|
|
181
|
+
wget -q -O "$tmp" "$1" 2>/dev/null
|
|
182
|
+
else
|
|
183
|
+
return 1
|
|
184
|
+
fi
|
|
185
|
+
}
|
|
186
|
+
check_download() {
|
|
187
|
+
download_file=${1:-$tmp}
|
|
188
|
+
if [ ! -f "$download_file" ]; then
|
|
189
|
+
echo "impeccable: download completed but the file was removed before execution: $url; check your antivirus quarantine or logs. Refusing to continue; do not disable protection." >&2
|
|
190
|
+
exit 127
|
|
191
|
+
fi
|
|
192
|
+
if [ ! -s "$download_file" ]; then
|
|
193
|
+
rm -f "$download_file"
|
|
194
|
+
echo "impeccable: downloaded file is empty: $url; refusing the unverified download" >&2
|
|
195
|
+
exit 127
|
|
196
|
+
fi
|
|
197
|
+
}
|
|
198
|
+
if [ -n "$probing" ]; then
|
|
199
|
+
# Inside another launcher's probe: no download, fail fast and quiet.
|
|
200
|
+
exit 127
|
|
201
|
+
fi
|
|
202
|
+
if [ -n "$version" ] && [ "$os" != unknown ] && [ "$arch" != unknown ]; then
|
|
203
|
+
base="${IMPECCABLE_DOWNLOAD_BASE:-https://github.com/pbakaus/impeccable/releases/download}"
|
|
204
|
+
url="$base/engine-v$version/$asset"
|
|
205
|
+
read_expected
|
|
206
|
+
# Fail closed before any network traffic or cache write.
|
|
207
|
+
if [ -z "$expected" ] && [ -z "$expected_x64" ]; then
|
|
208
|
+
echo "impeccable: no checksum for engine $version ($asset) in $manifest; refusing the unverified download" >&2
|
|
209
|
+
exit 127
|
|
210
|
+
fi
|
|
211
|
+
tmp="$cache_root/bin/$version/.impeccable.part.$$"
|
|
212
|
+
# An interrupted download (Ctrl-C, a hook timeout) would otherwise leave the
|
|
213
|
+
# PID-named staging file behind for good. The handlers must exit explicitly.
|
|
214
|
+
cleanup() { rm -f "$tmp" 2>/dev/null || :; }
|
|
215
|
+
trap 'cleanup; exit 129' HUP
|
|
216
|
+
trap 'cleanup; exit 130' INT
|
|
217
|
+
trap 'cleanup; exit 143' TERM
|
|
218
|
+
if ! mkdir -p "$cache_root/bin/$version" 2>/dev/null; then
|
|
219
|
+
echo "impeccable: engine $version is not installed; cannot create cache directory: $cache_root/bin/$version" >&2
|
|
220
|
+
setup_help
|
|
221
|
+
exit 127
|
|
222
|
+
fi
|
|
223
|
+
# Check the actual staging file, not just directory existence: a cache from
|
|
224
|
+
# an earlier run can be readable but no longer writable inside a sandbox.
|
|
225
|
+
if ! (umask 077; : > "$tmp") 2>/dev/null; then
|
|
226
|
+
echo "impeccable: engine $version is not installed; cannot write to cache directory: $cache_root/bin/$version" >&2
|
|
227
|
+
setup_help
|
|
228
|
+
exit 127
|
|
229
|
+
fi
|
|
230
|
+
fetched=0
|
|
231
|
+
if [ -n "$expected" ] && fetch_url "$url"; then
|
|
232
|
+
fetched=1
|
|
233
|
+
elif [ -n "$expected_x64" ]; then
|
|
234
|
+
# Windows on ARM runs x64 binaries; fall back when no arm64 asset exists.
|
|
235
|
+
url="$base/engine-v$version/impeccable-windows-x64.exe"
|
|
236
|
+
expected=$expected_x64
|
|
237
|
+
fetch_url "$url" && fetched=1
|
|
238
|
+
fi
|
|
239
|
+
if [ "$fetched" = 1 ]; then
|
|
240
|
+
check_download
|
|
241
|
+
# No sha256 tool refuses the download too.
|
|
242
|
+
hash_file "$tmp"
|
|
243
|
+
check_download
|
|
244
|
+
if [ -z "$actual" ]; then
|
|
245
|
+
rm -f "$tmp"
|
|
246
|
+
echo "impeccable: cannot verify $url (no sha256 tool, or hashing failed); refusing the unverified download" >&2
|
|
247
|
+
exit 127
|
|
248
|
+
fi
|
|
249
|
+
if [ "$actual" != "$expected" ]; then
|
|
250
|
+
rm -f "$tmp"
|
|
251
|
+
echo "impeccable: checksum mismatch downloading $url" >&2
|
|
252
|
+
exit 127
|
|
253
|
+
fi
|
|
254
|
+
check_download
|
|
255
|
+
if ! chmod +x "$tmp" 2>/dev/null; then
|
|
256
|
+
check_download
|
|
257
|
+
rm -f "$tmp"
|
|
258
|
+
echo "impeccable: could not make the verified download executable: $url" >&2
|
|
259
|
+
exit 127
|
|
260
|
+
fi
|
|
261
|
+
check_download
|
|
262
|
+
if ! mv -f "$tmp" "$cached" 2>/dev/null; then
|
|
263
|
+
check_download
|
|
264
|
+
rm -f "$tmp"
|
|
265
|
+
echo "impeccable: could not cache the verified download: $url" >&2
|
|
266
|
+
exit 127
|
|
267
|
+
fi
|
|
268
|
+
check_download "$cached"
|
|
269
|
+
cached_size
|
|
270
|
+
{ echo "$actual $size" > "$cached.verified"; } 2>/dev/null || :
|
|
271
|
+
exec "$cached" "$@"
|
|
272
|
+
fi
|
|
273
|
+
rm -f "$tmp" 2>/dev/null
|
|
274
|
+
case "$http_status" in
|
|
275
|
+
5[0-9][0-9])
|
|
276
|
+
case "$download_host" in
|
|
277
|
+
github.com|*.github.com|githubusercontent.com|*.githubusercontent.com)
|
|
278
|
+
echo "impeccable: could not download engine $version: GitHub's downloads are failing right now (HTTP $http_status from $download_host). This is an outage on GitHub's side, not a problem with your setup or the CLI, so updating won't help. Check https://www.githubstatus.com and run the same command again once GitHub has recovered." >&2 ;;
|
|
279
|
+
*)
|
|
280
|
+
echo "impeccable: could not download engine $version: $download_host is failing right now (HTTP $http_status), a server error on $download_host's side. Try again later." >&2 ;;
|
|
281
|
+
esac
|
|
282
|
+
exit 127 ;;
|
|
283
|
+
esac
|
|
284
|
+
echo "impeccable: could not download engine $version from $url; check network access, the release URL, and curl or wget availability." >&2
|
|
285
|
+
setup_help
|
|
286
|
+
exit 127
|
|
287
|
+
fi
|
|
288
|
+
|
|
289
|
+
echo "impeccable: no engine binary for $os-$arch found (looked in $bin, $cached, PATH)." >&2
|
|
290
|
+
echo "Download impeccable-$os-$arch from https://github.com/pbakaus/impeccable/releases (tag engine-v$version) into $cache_root/bin/$version/impeccable$exe (then chmod +x), or set IMPECCABLE_BIN to a preinstalled engine binary. Docs: https://impeccable.style" >&2
|
|
291
|
+
exit 127
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
rem Impeccable launcher (Windows). Runs bin\windows-<arch>\impeccable.exe next
|
|
4
|
+
rem to this file, else a cached or freshly downloaded engine binary.
|
|
5
|
+
rem
|
|
6
|
+
rem Structure notes (this file is exercised by dry parsing and string-level
|
|
7
|
+
rem tests, not yet on a real Windows machine):
|
|
8
|
+
rem - No multi-line parenthesized blocks: cmd expands %var% at block parse
|
|
9
|
+
rem time, which made the old download path read back empty %url%/%cached%.
|
|
10
|
+
rem Linear goto flow keeps every expansion on its own line, and avoids
|
|
11
|
+
rem delayed expansion eating ! characters in user arguments.
|
|
12
|
+
rem - The unversioned user binary and the PATH candidate are validated with
|
|
13
|
+
rem the engine-probe handshake (see :probe) so the retired 3.x npm CLI,
|
|
14
|
+
rem whose bin is also named impeccable, is never exec'd. The sibling binary
|
|
15
|
+
rem must also report the version in VERSION: it is not tracked, so a skill
|
|
16
|
+
rem upgrade can leave an old engine in place. IMPECCABLE_BIN stays trusted.
|
|
17
|
+
rem - Downloads and the version-pinned cache are verified via certutil
|
|
18
|
+
rem against engine-checksums.txt next to this file, and fail closed; a
|
|
19
|
+
rem .verified stamp lets later runs skip hashing the cache while it holds
|
|
20
|
+
rem the manifest digest and the binary's size and is not older than the
|
|
21
|
+
rem binary. On ARM64 the arm64 asset is tried first and the x64 asset is the
|
|
22
|
+
rem fallback (Windows on ARM runs x64 binaries), each only when the manifest
|
|
23
|
+
rem has a line for it.
|
|
24
|
+
if not defined IMPECCABLE_SKILL_DIR set "IMPECCABLE_SKILL_DIR=%~dp0.."
|
|
25
|
+
if not defined IMPECCABLE_SELF set "IMPECCABLE_SELF=%~f0"
|
|
26
|
+
set "arch=x64"
|
|
27
|
+
if /I "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "arch=arm64"
|
|
28
|
+
|
|
29
|
+
if not defined IMPECCABLE_BIN goto no_env_bin
|
|
30
|
+
if not exist "%IMPECCABLE_BIN%" goto no_env_bin
|
|
31
|
+
set "run=%IMPECCABLE_BIN%"
|
|
32
|
+
goto run
|
|
33
|
+
:no_env_bin
|
|
34
|
+
|
|
35
|
+
set "version="
|
|
36
|
+
if exist "%~dp0VERSION" set /p version=<"%~dp0VERSION"
|
|
37
|
+
set "bin=%~dp0bin\windows-%arch%\impeccable.exe"
|
|
38
|
+
if not exist "%bin%" goto no_sibling
|
|
39
|
+
if defined IMPECCABLE_LAUNCHER_PROBE goto sibling_ok
|
|
40
|
+
if not defined version goto sibling_ok
|
|
41
|
+
call :probe "%bin%"
|
|
42
|
+
if "%probe_version%"=="%version%" goto sibling_ok
|
|
43
|
+
if not defined probe_version set "probe_version=unknown"
|
|
44
|
+
echo impeccable: skipping "%bin%": it reports engine %probe_version% but this skill pins %version%; delete it to stop this warning 1>&2
|
|
45
|
+
goto no_sibling
|
|
46
|
+
:sibling_ok
|
|
47
|
+
set "run=%bin%"
|
|
48
|
+
goto run
|
|
49
|
+
:no_sibling
|
|
50
|
+
|
|
51
|
+
set "home_bin=%USERPROFILE%\.impeccable\bin\impeccable.exe"
|
|
52
|
+
if not exist "%home_bin%" goto no_home_bin
|
|
53
|
+
if defined IMPECCABLE_LAUNCHER_PROBE goto no_home_bin
|
|
54
|
+
call :probe "%home_bin%"
|
|
55
|
+
if not "%probe_ok%"=="1" goto no_home_bin
|
|
56
|
+
set "run=%home_bin%"
|
|
57
|
+
goto run
|
|
58
|
+
:no_home_bin
|
|
59
|
+
|
|
60
|
+
if not defined IMPECCABLE_HOME set "IMPECCABLE_HOME=%USERPROFILE%\.impeccable"
|
|
61
|
+
set "cached=%IMPECCABLE_HOME%\bin\%version%\impeccable.exe"
|
|
62
|
+
set "asset=impeccable-windows-%arch%.exe"
|
|
63
|
+
set "manifest=%~dp0engine-checksums.txt"
|
|
64
|
+
if not defined version goto no_cache
|
|
65
|
+
if not exist "%cached%" goto no_cache
|
|
66
|
+
call :read_expected
|
|
67
|
+
for %%f in ("%cached%") do set "size=%%~zf"
|
|
68
|
+
set "stamp="
|
|
69
|
+
if exist "%cached%.verified" for /f "usebackq tokens=1,2" %%s in ("%cached%.verified") do set "stamp=%%s"& set "stamp_size=%%t"
|
|
70
|
+
if not defined stamp goto cache_hash
|
|
71
|
+
if not "%stamp_size%"=="%size%" goto cache_hash
|
|
72
|
+
if /I "%stamp%"=="%expected%" goto cache_stamp_matches
|
|
73
|
+
if /I "%stamp%"=="%expected_x64%" goto cache_stamp_matches
|
|
74
|
+
goto cache_hash
|
|
75
|
+
:cache_stamp_matches
|
|
76
|
+
rem Newest first: the stamp must be listed before the binary it vouches for.
|
|
77
|
+
set "newest="
|
|
78
|
+
for /f "delims=" %%f in ('dir /b /a:-d /o:-d "%cached%*" 2^>nul') do if not defined newest set "newest=%%f"
|
|
79
|
+
if /I "%newest%"=="impeccable.exe.verified" goto cache_trusted
|
|
80
|
+
:cache_hash
|
|
81
|
+
call :sha256 "%cached%" "%TEMP%\impeccable-hash-%RANDOM%%RANDOM%.txt"
|
|
82
|
+
if not defined actual goto cache_unverified
|
|
83
|
+
if /I "%actual%"=="%expected%" goto cache_verified
|
|
84
|
+
if /I "%actual%"=="%expected_x64%" goto cache_verified
|
|
85
|
+
:cache_unverified
|
|
86
|
+
echo impeccable: cannot verify the cached engine "%cached%" against "%manifest%"; not using it 1>&2
|
|
87
|
+
goto no_cache
|
|
88
|
+
:cache_verified
|
|
89
|
+
(>"%cached%.verified" echo %actual% %size%) 2>nul
|
|
90
|
+
:cache_trusted
|
|
91
|
+
set "run=%cached%"
|
|
92
|
+
goto run
|
|
93
|
+
:no_cache
|
|
94
|
+
|
|
95
|
+
if defined IMPECCABLE_LAUNCHER_PROBE goto download
|
|
96
|
+
where impeccable >nul 2>nul
|
|
97
|
+
if errorlevel 1 goto download
|
|
98
|
+
call :probe impeccable
|
|
99
|
+
if not "%probe_ok%"=="1" goto download
|
|
100
|
+
impeccable %*
|
|
101
|
+
exit /b %errorlevel%
|
|
102
|
+
|
|
103
|
+
:download
|
|
104
|
+
rem Last resort: fetch this version's binary from the release channel into
|
|
105
|
+
rem the version-pinned user cache, verify it, then run it. Never inside
|
|
106
|
+
rem another launcher's probe: fail fast and quiet instead.
|
|
107
|
+
if defined IMPECCABLE_LAUNCHER_PROBE exit /b 127
|
|
108
|
+
if not defined version goto fail
|
|
109
|
+
call :read_expected
|
|
110
|
+
if not defined expected if not defined expected_x64 goto no_checksum
|
|
111
|
+
where curl.exe >nul 2>nul
|
|
112
|
+
if errorlevel 1 goto curl_missing
|
|
113
|
+
if not defined IMPECCABLE_DOWNLOAD_BASE set "IMPECCABLE_DOWNLOAD_BASE=https://github.com/pbakaus/impeccable/releases/download"
|
|
114
|
+
if exist "%IMPECCABLE_HOME%\bin\%version%\" goto cache_ready
|
|
115
|
+
mkdir "%IMPECCABLE_HOME%\bin\%version%" >nul 2>nul
|
|
116
|
+
if errorlevel 1 goto cache_directory_failed
|
|
117
|
+
:cache_ready
|
|
118
|
+
rem Stage the download in a directory only this run owns, as the sh launcher
|
|
119
|
+
rem does with .impeccable.part.$$: concurrent first runs (parallel hooks, two
|
|
120
|
+
rem agents) must never write, hash or move each other's files. mkdir fails
|
|
121
|
+
rem when the name exists, so it claims the name atomically. RANDOM alone is
|
|
122
|
+
rem not enough because cmd seeds it from the clock in whole seconds; the
|
|
123
|
+
rem timestamp and the retry on collision keep same-second runs apart. A cache
|
|
124
|
+
rem directory that refuses every mkdir is reported as unwritable.
|
|
125
|
+
set "attempt=0"
|
|
126
|
+
:claim_staging
|
|
127
|
+
set /a attempt+=1
|
|
128
|
+
if %attempt% GTR 20 goto cache_write_failed
|
|
129
|
+
set "stamp=%TIME: =0%"
|
|
130
|
+
set "stamp=%stamp::=%"
|
|
131
|
+
set "stamp=%stamp:.=%"
|
|
132
|
+
set "stamp=%stamp:,=%"
|
|
133
|
+
set "staging=%IMPECCABLE_HOME%\bin\%version%\.impeccable.part.%stamp%-%RANDOM%%RANDOM%"
|
|
134
|
+
mkdir "%staging%" >nul 2>nul
|
|
135
|
+
if errorlevel 1 goto claim_staging
|
|
136
|
+
set "part=%staging%\impeccable.exe"
|
|
137
|
+
rem Redirection failures do not reliably update ERRORLEVEL in cmd.exe;
|
|
138
|
+
rem branch on the command's failure directly.
|
|
139
|
+
(type nul >"%part%") 2>nul || goto staging_write_failed
|
|
140
|
+
set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
|
|
141
|
+
if not defined expected goto fetch_x64
|
|
142
|
+
call :fetch_url
|
|
143
|
+
if not errorlevel 1 goto verify
|
|
144
|
+
:fetch_x64
|
|
145
|
+
if not defined expected_x64 goto download_failed
|
|
146
|
+
set "asset=impeccable-windows-x64.exe"
|
|
147
|
+
set "expected=%expected_x64%"
|
|
148
|
+
set "url=%IMPECCABLE_DOWNLOAD_BASE%/engine-v%version%/%asset%"
|
|
149
|
+
call :fetch_url
|
|
150
|
+
if errorlevel 1 goto download_failed
|
|
151
|
+
|
|
152
|
+
:verify
|
|
153
|
+
call :check_download
|
|
154
|
+
if errorlevel 1 exit /b 127
|
|
155
|
+
rem Mirrors the sh launcher and fails closed: a freshly downloaded binary
|
|
156
|
+
rem runs only after its hash matches the digest read from engine-checksums.txt.
|
|
157
|
+
rem An empty certutil result refuses the download instead of running an
|
|
158
|
+
rem unverified binary.
|
|
159
|
+
call :sha256 "%part%" "%staging%\hash.txt"
|
|
160
|
+
call :check_download
|
|
161
|
+
if errorlevel 1 exit /b 127
|
|
162
|
+
if not defined actual goto verify_refuse
|
|
163
|
+
if /I "%actual%"=="%expected%" goto place
|
|
164
|
+
call :discard_staging
|
|
165
|
+
echo impeccable: checksum mismatch downloading %url% 1>&2
|
|
166
|
+
exit /b 127
|
|
167
|
+
|
|
168
|
+
:verify_refuse
|
|
169
|
+
call :check_download
|
|
170
|
+
if errorlevel 1 exit /b 127
|
|
171
|
+
call :discard_staging
|
|
172
|
+
echo impeccable: cannot verify %url% (certutil could not hash it); refusing the unverified download 1>&2
|
|
173
|
+
exit /b 127
|
|
174
|
+
|
|
175
|
+
:fetch_url
|
|
176
|
+
set "http_status="
|
|
177
|
+
set "effective_url="
|
|
178
|
+
set "download_host="
|
|
179
|
+
curl.exe -fsSL --retry 2 -w "%%{http_code} %%{url_effective}" -o "%part%" "%url%" >"%staging%\http.txt" 2>nul
|
|
180
|
+
set "fetch_result=%errorlevel%"
|
|
181
|
+
for /f "usebackq tokens=1" %%a in ("%staging%\http.txt") do set "http_status=%%a"
|
|
182
|
+
for /f "usebackq tokens=2" %%a in ("%staging%\http.txt") do set "effective_url=%%a"
|
|
183
|
+
rem Token 2 is the authority after scheme://. Drop userinfo and the port.
|
|
184
|
+
for /f "tokens=2 delims=/" %%h in ("%effective_url%") do set "download_host=%%h"
|
|
185
|
+
for /f "tokens=1,* delims=@" %%h in ("%download_host%") do if not "%%i"=="" set "download_host=%%i"
|
|
186
|
+
rem Bracketed IPv6 hosts contain colons that are not port separators.
|
|
187
|
+
if "%download_host:~0,1%"=="[" goto fetch_ipv6
|
|
188
|
+
for /f "tokens=1 delims=:" %%h in ("%download_host%") do set "download_host=%%h"
|
|
189
|
+
exit /b %fetch_result%
|
|
190
|
+
:fetch_ipv6
|
|
191
|
+
for /f "tokens=1 delims=]" %%h in ("%download_host%") do set "download_host=%%h]"
|
|
192
|
+
exit /b %fetch_result%
|
|
193
|
+
|
|
194
|
+
:read_expected
|
|
195
|
+
rem Sets expected (and, on ARM64, expected_x64: Windows on ARM runs x64
|
|
196
|
+
rem binaries) from engine-checksums.txt.
|
|
197
|
+
call :manifest_digest "%asset%" expected
|
|
198
|
+
set "expected_x64="
|
|
199
|
+
if "%arch%"=="arm64" call :manifest_digest impeccable-windows-x64.exe expected_x64
|
|
200
|
+
exit /b 0
|
|
201
|
+
|
|
202
|
+
:manifest_digest
|
|
203
|
+
rem Sets the variable named %2 to the digest the first engine-checksums.txt
|
|
204
|
+
rem line for this version and asset %1 records, empty when there is none.
|
|
205
|
+
set "%~2="
|
|
206
|
+
if not exist "%manifest%" exit /b 0
|
|
207
|
+
for /f "usebackq tokens=1-3" %%a in ("%manifest%") do if "%%a"=="%version%" if /I "%%b"=="%~1" if not defined %~2 set "%~2=%%c"
|
|
208
|
+
exit /b 0
|
|
209
|
+
|
|
210
|
+
:sha256
|
|
211
|
+
rem Sets actual to the sha256 of %~1, empty when certutil fails. %~2 is the
|
|
212
|
+
rem scratch file for its output. Check certutil's status before parsing: its
|
|
213
|
+
rem error text on stdout is not a digest.
|
|
214
|
+
set "actual="
|
|
215
|
+
certutil -hashfile "%~1" SHA256 >"%~2" 2>nul
|
|
216
|
+
if errorlevel 1 goto sha256_done
|
|
217
|
+
for /f "usebackq skip=1 delims=" %%h in ("%~2") do if not defined actual set "actual=%%h"
|
|
218
|
+
if not defined actual goto sha256_done
|
|
219
|
+
set "actual=%actual: =%"
|
|
220
|
+
:sha256_done
|
|
221
|
+
del "%~2" >nul 2>nul
|
|
222
|
+
exit /b 0
|
|
223
|
+
|
|
224
|
+
:check_download
|
|
225
|
+
set "download_file=%~1"
|
|
226
|
+
if not defined download_file set "download_file=%part%"
|
|
227
|
+
if not exist "%download_file%" goto download_missing
|
|
228
|
+
for %%f in ("%download_file%") do if %%~zf==0 goto download_empty
|
|
229
|
+
exit /b 0
|
|
230
|
+
|
|
231
|
+
:download_missing
|
|
232
|
+
call :discard_staging
|
|
233
|
+
echo impeccable: download completed but the file was removed before execution: %url%; check your antivirus quarantine or logs. Refusing to continue; do not disable protection. 1>&2
|
|
234
|
+
exit /b 127
|
|
235
|
+
|
|
236
|
+
:download_empty
|
|
237
|
+
del "%download_file%" >nul 2>nul
|
|
238
|
+
call :discard_staging
|
|
239
|
+
echo impeccable: downloaded file is empty: %url%; refusing the unverified download 1>&2
|
|
240
|
+
exit /b 127
|
|
241
|
+
|
|
242
|
+
:discard_staging
|
|
243
|
+
rem Removes this run's staging directory and whatever is left in it. Never
|
|
244
|
+
rem touches another run's staging directory or the cached binary.
|
|
245
|
+
if defined staging rd /s /q "%staging%" >nul 2>nul
|
|
246
|
+
exit /b 0
|
|
247
|
+
|
|
248
|
+
:place
|
|
249
|
+
call :check_download
|
|
250
|
+
if errorlevel 1 exit /b 127
|
|
251
|
+
move /y "%part%" "%cached%" >nul 2>nul
|
|
252
|
+
if errorlevel 1 goto place_failed
|
|
253
|
+
call :discard_staging
|
|
254
|
+
call :check_download "%cached%"
|
|
255
|
+
if errorlevel 1 exit /b 127
|
|
256
|
+
for %%f in ("%cached%") do set "size=%%~zf"
|
|
257
|
+
(>"%cached%.verified" echo %actual% %size%) 2>nul
|
|
258
|
+
set "run=%cached%"
|
|
259
|
+
goto run
|
|
260
|
+
|
|
261
|
+
:place_failed
|
|
262
|
+
call :check_download
|
|
263
|
+
if errorlevel 1 exit /b 127
|
|
264
|
+
call :discard_staging
|
|
265
|
+
echo impeccable: could not cache the verified download: %url% 1>&2
|
|
266
|
+
exit /b 127
|
|
267
|
+
|
|
268
|
+
:run
|
|
269
|
+
"%run%" %*
|
|
270
|
+
exit /b %errorlevel%
|
|
271
|
+
|
|
272
|
+
:probe
|
|
273
|
+
rem Sets probe_ok=1 when %1 answers the engine handshake: prints
|
|
274
|
+
rem "impeccable-engine <version>" and exits 0, and probe_version to that
|
|
275
|
+
rem version. The 3.x npm CLI answers any unknown verb with "Unknown command",
|
|
276
|
+
rem exit 1, so it never passes.
|
|
277
|
+
set "probe_ok="
|
|
278
|
+
set "probe_version="
|
|
279
|
+
set "probe_tmp=%TEMP%\impeccable-probe-%RANDOM%%RANDOM%.txt"
|
|
280
|
+
set "IMPECCABLE_LAUNCHER_PROBE=1"
|
|
281
|
+
"%~1" engine-probe >"%probe_tmp%" 2>nul
|
|
282
|
+
set "probe_err=%ERRORLEVEL%"
|
|
283
|
+
set "IMPECCABLE_LAUNCHER_PROBE="
|
|
284
|
+
if not "%probe_err%"=="0" goto probe_done
|
|
285
|
+
findstr /b /c:"impeccable-engine" "%probe_tmp%" >nul 2>nul
|
|
286
|
+
if errorlevel 1 goto probe_done
|
|
287
|
+
set "probe_ok=1"
|
|
288
|
+
for /f "usebackq tokens=2" %%v in ("%probe_tmp%") do if not defined probe_version set "probe_version=%%v"
|
|
289
|
+
:probe_done
|
|
290
|
+
del "%probe_tmp%" >nul 2>nul
|
|
291
|
+
exit /b 0
|
|
292
|
+
|
|
293
|
+
:no_checksum
|
|
294
|
+
echo impeccable: no checksum for engine %version% (%asset%) in "%manifest%"; refusing the unverified download 1>&2
|
|
295
|
+
exit /b 127
|
|
296
|
+
|
|
297
|
+
:cache_directory_failed
|
|
298
|
+
echo impeccable: engine %version% is not installed; cannot create cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2
|
|
299
|
+
goto setup_failed
|
|
300
|
+
|
|
301
|
+
:staging_write_failed
|
|
302
|
+
call :discard_staging
|
|
303
|
+
|
|
304
|
+
:cache_write_failed
|
|
305
|
+
echo impeccable: engine %version% is not installed; cannot write to cache directory: "%IMPECCABLE_HOME%\bin\%version%" 1>&2
|
|
306
|
+
goto setup_failed
|
|
307
|
+
|
|
308
|
+
:curl_missing
|
|
309
|
+
echo impeccable: cannot download engine %version%; curl.exe is unavailable. 1>&2
|
|
310
|
+
goto setup_failed
|
|
311
|
+
|
|
312
|
+
:download_failed
|
|
313
|
+
call :discard_staging
|
|
314
|
+
if not "%http_status:~0,1%"=="5" goto download_generic
|
|
315
|
+
if "%http_status:~2,1%"=="" goto download_generic
|
|
316
|
+
if /I "%download_host%"=="github.com" goto download_github
|
|
317
|
+
if /I "%download_host:~-11%"==".github.com" goto download_github
|
|
318
|
+
if /I "%download_host%"=="githubusercontent.com" goto download_github
|
|
319
|
+
if /I "%download_host:~-22%"==".githubusercontent.com" goto download_github
|
|
320
|
+
echo impeccable: could not download engine %version%: %download_host% is failing right now (HTTP %http_status%), a server error on %download_host%'s side. Try again later. 1>&2
|
|
321
|
+
exit /b 127
|
|
322
|
+
:download_github
|
|
323
|
+
echo impeccable: could not download engine %version%: GitHub's downloads are failing right now (HTTP %http_status% from %download_host%). This is an outage on GitHub's side, not a problem with your setup or the CLI, so updating won't help. Check https://www.githubstatus.com and run the same command again once GitHub has recovered. 1>&2
|
|
324
|
+
exit /b 127
|
|
325
|
+
:download_generic
|
|
326
|
+
echo impeccable: could not download engine %version% from %url%; check network access and the release URL. 1>&2
|
|
327
|
+
|
|
328
|
+
:setup_failed
|
|
329
|
+
echo Engine %version% setup needs network access and write permission to "%IMPECCABLE_HOME%\bin\%version%". 1>&2
|
|
330
|
+
echo Run this launcher ("%~f0") with engine-probe in a terminal that has those permissions, then retry the original command. 1>&2
|
|
331
|
+
echo Alternatively, set IMPECCABLE_HOME to a writable cache location, or IMPECCABLE_BIN to a preinstalled engine binary. 1>&2
|
|
332
|
+
exit /b 127
|
|
333
|
+
|
|
334
|
+
:fail
|
|
335
|
+
echo impeccable: no engine binary found (looked in %bin%, %cached%, PATH). 1>&2
|
|
336
|
+
echo Download impeccable-windows-%arch%.exe from https://github.com/pbakaus/impeccable/releases (tag engine-v%version%) and save it as %cached%, or set IMPECCABLE_BIN to a preinstalled engine binary. Docs: https://impeccable.style 1>&2
|
|
337
|
+
exit /b 127
|