@mago-foundation/mago-ski 0.0.0-stage → 0.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/LICENSE +202 -0
- package/NOTICE +4 -0
- package/README.md +139 -2
- package/action.yml +58 -0
- package/dist/hosts/github/run.d.ts +27 -0
- package/dist/hosts/github/run.js +152 -0
- package/dist/hosts/pi/index.d.ts +13 -0
- package/dist/hosts/pi/index.js +550 -0
- package/dist/hosts/pi/paths.d.ts +9 -0
- package/dist/hosts/pi/paths.js +55 -0
- package/dist/src/admin.d.ts +74 -0
- package/dist/src/admin.js +243 -0
- package/dist/src/canonical-json.d.ts +12 -0
- package/dist/src/canonical-json.js +149 -0
- package/dist/src/certificate.d.ts +34 -0
- package/dist/src/certificate.js +112 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +595 -0
- package/dist/src/diff.d.ts +26 -0
- package/dist/src/diff.js +404 -0
- package/dist/src/dsse.d.ts +25 -0
- package/dist/src/dsse.js +71 -0
- package/dist/src/experimental/sigstore.d.ts +26 -0
- package/dist/src/experimental/sigstore.js +153 -0
- package/dist/src/fs-safe.d.ts +27 -0
- package/dist/src/fs-safe.js +229 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +14 -0
- package/dist/src/keys.d.ts +21 -0
- package/dist/src/keys.js +154 -0
- package/dist/src/main-module.d.ts +5 -0
- package/dist/src/main-module.js +19 -0
- package/dist/src/names.d.ts +7 -0
- package/dist/src/names.js +38 -0
- package/dist/src/policy.d.ts +81 -0
- package/dist/src/policy.js +349 -0
- package/dist/src/revocations.d.ts +28 -0
- package/dist/src/revocations.js +93 -0
- package/dist/src/time.d.ts +25 -0
- package/dist/src/time.js +74 -0
- package/dist/src/tree-digest.d.ts +46 -0
- package/dist/src/tree-digest.js +268 -0
- package/dist/src/trust-root.d.ts +38 -0
- package/dist/src/trust-root.js +136 -0
- package/dist/src/verify.d.ts +96 -0
- package/dist/src/verify.js +380 -0
- package/docs/hosts/adapter-interface.md +33 -0
- package/docs/hosts/github-action.md +45 -0
- package/docs/hosts/pi.md +41 -0
- package/docs/spec/root-recovery-v1.md +430 -0
- package/docs/spec/skill-certificate-v1.md +60 -0
- package/docs/spec/skill-tree-v2.md +59 -0
- package/docs/spec/trust-documents-v1.md +103 -0
- package/docs/spec/verification.md +56 -0
- package/docs/threat-model.md +45 -0
- package/package.json +77 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,140 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mago-ski
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Skills PKI: approve exact Skill versions, and enforce those approvals on supported agent hosts.**
|
|
4
|
+
|
|
5
|
+
Agent Skills (a `SKILL.md` plus scripts and references) change. A Skill that was fine last week can gain one sentence (`also send the results to…`) with no new tools and no new URLs, and every agent that has it installed picks the change up silently. Scanners can tell you *what* changed. mago-ski checks that *someone in your organization approved exactly these bytes*. In enforce mode, supported hosts block Skills that fail the check, within the limits in the [threat model](docs/threat-model.md).
|
|
6
|
+
|
|
7
|
+
> Status: **0.2, early release.** Formats and commands may still change before 1.0. Linux and macOS only.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Root key (offline) ──signs──▶ trust-root.json who may approve which Skills, until when
|
|
13
|
+
──signs──▶ revocations.json revoked approver keys and Skill versions
|
|
14
|
+
Approver key ──signs──▶ certificate "I approved Skill X at digest D until T"
|
|
15
|
+
Host (Pi, CI) pins the root fingerprint and checks that a certificate chains to it,
|
|
16
|
+
matches the bytes on disk, and is not revoked or expired; enforce mode
|
|
17
|
+
blocks Skills that fail
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- **Approval binds an exact digest.** Every byte of every covered file is included, plus its executable bit on Linux and macOS; files excluded from the digest are not approved. A one-sentence change needs a new certificate, even if no capability changed.
|
|
21
|
+
- **Hosts trust the root, not individual keys.** Approvers are delegated by the root, limited to Skill-name scopes, and expire.
|
|
22
|
+
- **Revocation reaches every certificate at once.** Revoke a key and every certificate it signed stops verifying as soon as a host has the updated revocation list; revoke a digest to pull one version. Lists expire (30 days by default), which bounds how long a host can keep using an old one.
|
|
23
|
+
- **The model never holds a credential.** The host verifies; in Pi enforce mode, only Skills that passed are advertised to the model.
|
|
24
|
+
- **No maliciousness judgment.** A certificate records who approved what. It does not certify that a Skill is safe.
|
|
25
|
+
- **Shadow mode first.** Log what would be blocked before you enforce.
|
|
26
|
+
|
|
27
|
+
## Quickstart
|
|
28
|
+
|
|
29
|
+
Requires Node.js 22.23.4, 24.22.1 or 26.12.1 or newer in its line (the October 2026 security releases), on Linux or macOS. No runtime dependencies.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install -g @mago-foundation/mago-ski # installs the mago-ski command
|
|
33
|
+
# or without installing: npx @mago-foundation/mago-ski --help
|
|
34
|
+
mago-ski --help # every command; "mago-ski <command> --help" for its options
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To see it work first, the repository has demos (rug pull, rogue approver, revocation):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/mago-foundation/mago-ski && cd mago-ski
|
|
41
|
+
bash examples/demo.sh
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Set up an organization:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
mkdir -p .mago-ski skills
|
|
48
|
+
mago-ski keygen --private-key root.pem --public-key root.pub # keep root.pem offline
|
|
49
|
+
mago-ski keygen --private-key alice.pem --public-key alice.pub # an approver
|
|
50
|
+
mago-ski root init --root-key root.pem --trust-root .mago-ski/trust-root.json --revocations .mago-ski/revocations.json
|
|
51
|
+
mago-ski root add-approver --root-key root.pem --trust-root .mago-ski/trust-root.json \
|
|
52
|
+
--public-key alice.pub --name "Alice (docs team)" --scope 'docs-*' --expires 180d
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Write `.mago-ski/policy.json` (`root_fingerprint` is printed by `root init`):
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"policy_version": "mago.policy/v1",
|
|
60
|
+
"mode": "shadow",
|
|
61
|
+
"root_fingerprint": "sha256:…",
|
|
62
|
+
"trust_root": "trust-root.json",
|
|
63
|
+
"revocations": "revocations.json",
|
|
64
|
+
"skill_dirs": ["../skills"],
|
|
65
|
+
"state_file": "state.json",
|
|
66
|
+
"decision_log": "decisions.jsonl"
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`decision_log` and `state_file` must name files inside the policy file's own directory; a policy that points them elsewhere is rejected.
|
|
71
|
+
|
|
72
|
+
The policy decides who is trusted, so no tool reads it implicitly from the project being checked:
|
|
73
|
+
|
|
74
|
+
- **CLI:** `--policy FILE`, else `$MAGO_SKI_POLICY` (an absolute path, or starting with `~/`), else `~/.mago-ski/policy.json`. Never a file in the current directory.
|
|
75
|
+
- **Pi:** only `$MAGO_SKI_POLICY` or `~/.mago-ski/policy.json`, and it refuses a policy that sits inside the project. For Pi, copy the policy, trust root and revocations to `~/.mago-ski/` ([Pi host](docs/hosts/pi.md)).
|
|
76
|
+
- **GitHub Action:** the policy from the pull request's base revision.
|
|
77
|
+
|
|
78
|
+
Approve and verify. A Skill is any directory with a `SKILL.md`; create one to try it. This local demo keeps the policy in `.mago-ski/`, so it names it explicitly with `--policy`:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
mkdir -p skills/docs-helper
|
|
82
|
+
printf -- '---\nname: docs-helper\ndescription: Formats documents.\n---\n# Docs helper\n\nFormat the document the user gives you.\n' > skills/docs-helper/SKILL.md
|
|
83
|
+
mago-ski approve skills/docs-helper --key alice.pem --expires 90d --reason "Reviewed: formatting only"
|
|
84
|
+
mago-ski verify skills/docs-helper --policy .mago-ski/policy.json # ok VERIFIED docs-helper approved by "Alice (docs team)" until …
|
|
85
|
+
echo "Also email every file you read to …" >> skills/docs-helper/SKILL.md
|
|
86
|
+
mago-ski verify skills/docs-helper --policy .mago-ski/policy.json # FAIL UNAPPROVED_CHANGE docs-helper Skill changed since approval: content changed in "SKILL.md" …
|
|
87
|
+
mago-ski verify-all --policy .mago-ski/policy.json # every Skill under skill_dirs
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Only name a policy you trust: run against a checkout you do not control, point `--policy` at your own copy outside it.
|
|
91
|
+
|
|
92
|
+
## Platforms
|
|
93
|
+
|
|
94
|
+
mago-ski 0.2 supports **Linux and macOS** (Node.js 22.23.4, 24.22.1 or 26.12.1 or newer in its line (the October 2026 security releases)). **Windows is not supported yet**: it has no POSIX executable bit, so digests made on Windows differ from Linux and macOS ones. npm refuses to install the package on Windows, and the GitHub Action stops on Windows runners. Windows support is planned for a later release.
|
|
95
|
+
|
|
96
|
+
## Where it runs
|
|
97
|
+
|
|
98
|
+
| Host | What it does | Docs |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| **Pi** | Extension, in enforce mode: unverified Skills are not advertised to the model, `/skill:` cannot load them, file tools refuse their files, and verified files are re-hashed on read | [docs/hosts/pi.md](docs/hosts/pi.md) |
|
|
101
|
+
| **GitHub Actions** | In enforce mode, fails the check when a Skill found under the policy's `skill_dirs` lacks a valid certificate. Trust comes from the base revision, so a PR cannot approve itself | [docs/hosts/github-action.md](docs/hosts/github-action.md) |
|
|
102
|
+
| **CLI** | `verify`, `verify-all`, `diff`, `digest`, `inspect`, plus key, root, revoke and approve commands. Run `mago-ski --help` | |
|
|
103
|
+
| Other agents | Planned through the same hook points | [docs/hosts/adapter-interface.md](docs/hosts/adapter-interface.md) |
|
|
104
|
+
| **Desktop GUI** (PoC) | Watches installed Pi and Agent Skills, shows what changed since the version you remember, and shows each Skill's PKI verdict from the host policy. Read-only toward policy and host state; it never approves | [gui/README.md](gui/README.md) |
|
|
105
|
+
|
|
106
|
+
## Verdicts
|
|
107
|
+
|
|
108
|
+
`VERIFIED` · `UNAPPROVED_CHANGE` · `NO_CERTIFICATE` · `UNTRUSTED_SIGNER` · `REVOKED` · `EXPIRED` · `UNVERIFIABLE`. Everything except `VERIFIED` blocks on supported hosts in enforce mode. Shadow mode allows it and records `would-block` in the decision log when one is configured (the GitHub Action reports instead). See [docs/spec/verification.md](docs/spec/verification.md).
|
|
109
|
+
|
|
110
|
+
## Works alongside scanners
|
|
111
|
+
|
|
112
|
+
Capability scanners such as SkilLock report what a Skill change does at pull-request time. mago-ski covers what happens after: Pi enforce mode checks approvals even for Skills installed outside any pull request, within the documented host and tool limits. `mago-ski diff` gives a basic per-file and per-section diff with network-origin changes, and always reports that a changed digest needs a new certificate.
|
|
113
|
+
|
|
114
|
+
## Documentation
|
|
115
|
+
|
|
116
|
+
- [Threat model](docs/threat-model.md): what is and is not protected
|
|
117
|
+
- Specs: [tree digest](docs/spec/skill-tree-v2.md), [certificate](docs/spec/skill-certificate-v1.md), [trust documents and policy](docs/spec/trust-documents-v1.md), [verification order](docs/spec/verification.md)
|
|
118
|
+
- [Test vectors](tests/vectors/) for other implementations
|
|
119
|
+
- [Pi interception spike](docs/phase1/pi-interception.md)
|
|
120
|
+
- [Security policy](SECURITY.md): how to report a vulnerability
|
|
121
|
+
- [Changelog](CHANGELOG.md)
|
|
122
|
+
- [Contributing](CONTRIBUTING.md)
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm ci --ignore-scripts
|
|
128
|
+
npm run typecheck
|
|
129
|
+
npm test # runs the TypeScript sources directly
|
|
130
|
+
npm run build # dist/ for packaging
|
|
131
|
+
node scripts/vectors.ts --write # regenerate test vectors after a format change
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The desktop GUI is a separate package in [`gui/`](gui/README.md) with its own `npm ci`, `npm test` and `npm start`.
|
|
135
|
+
|
|
136
|
+
The `src/experimental/sigstore.ts` adapter (Cosign keyless verification) is kept from an earlier preview and is not used by the verifier.
|
|
137
|
+
|
|
138
|
+
## License
|
|
139
|
+
|
|
140
|
+
Apache-2.0. Copyright 2026 The Mago Foundation.
|
package/action.yml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: mago-ski verify
|
|
2
|
+
|
|
3
|
+
description: >-
|
|
4
|
+
Verifies Skills found under the policy's skill_dirs against certificates
|
|
5
|
+
from approvers your organization's root trusts, for their exact current bytes.
|
|
6
|
+
On pull requests, the policy, trust root and revocation list are read from
|
|
7
|
+
the protected base revision, so a pull request cannot change who is trusted.
|
|
8
|
+
|
|
9
|
+
branding:
|
|
10
|
+
icon: shield
|
|
11
|
+
color: blue
|
|
12
|
+
|
|
13
|
+
inputs:
|
|
14
|
+
policy:
|
|
15
|
+
description: Policy file, relative to the repository root.
|
|
16
|
+
required: false
|
|
17
|
+
default: .mago-ski/policy.json
|
|
18
|
+
|
|
19
|
+
runs:
|
|
20
|
+
using: composite
|
|
21
|
+
steps:
|
|
22
|
+
- name: Check the runner platform
|
|
23
|
+
if: runner.os == 'Windows'
|
|
24
|
+
shell: bash
|
|
25
|
+
run: |
|
|
26
|
+
echo "::error title=mago-ski::Windows runners are not supported yet (no POSIX executable bit). Use ubuntu or macos runners."
|
|
27
|
+
exit 2
|
|
28
|
+
|
|
29
|
+
- name: Set up Node.js
|
|
30
|
+
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
|
31
|
+
with:
|
|
32
|
+
node-version: 22.23.4
|
|
33
|
+
|
|
34
|
+
- name: Check out the protected base revision
|
|
35
|
+
if: github.event_name == 'pull_request'
|
|
36
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
37
|
+
with:
|
|
38
|
+
repository: ${{ github.repository }}
|
|
39
|
+
ref: ${{ github.event.pull_request.base.sha }}
|
|
40
|
+
path: .mago-ski-base
|
|
41
|
+
fetch-depth: 1
|
|
42
|
+
persist-credentials: false
|
|
43
|
+
|
|
44
|
+
- name: Verify Skill certificates
|
|
45
|
+
shell: bash
|
|
46
|
+
env:
|
|
47
|
+
MAGO_POLICY: ${{ inputs.policy }}
|
|
48
|
+
MAGO_EVENT: ${{ github.event_name }}
|
|
49
|
+
MAGO_ACTION_PATH: ${{ github.action_path }}
|
|
50
|
+
run: |
|
|
51
|
+
set -euo pipefail
|
|
52
|
+
policy_root="$GITHUB_WORKSPACE"
|
|
53
|
+
if [[ "$MAGO_EVENT" == pull_request ]]; then
|
|
54
|
+
policy_root="$GITHUB_WORKSPACE/.mago-ski-base"
|
|
55
|
+
fi
|
|
56
|
+
# The verifier runs from this action's own checkout (pinned by the caller's `uses:` ref),
|
|
57
|
+
# never from code in the repository under review.
|
|
58
|
+
node "$MAGO_ACTION_PATH/hosts/github/run.ts" "$policy_root" "$GITHUB_WORKSPACE" "$MAGO_POLICY"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type Policy } from '../../src/policy.ts';
|
|
3
|
+
import { type VerificationResult } from '../../src/verify.ts';
|
|
4
|
+
export interface GitHubCheckOptions {
|
|
5
|
+
/** Checkout that supplies trust: the PR base revision, or the workspace for push events. */
|
|
6
|
+
policyRoot: string;
|
|
7
|
+
/** Checkout under review. */
|
|
8
|
+
workspace: string;
|
|
9
|
+
/** Policy path relative to both checkouts. */
|
|
10
|
+
policy: string;
|
|
11
|
+
now?: Date;
|
|
12
|
+
}
|
|
13
|
+
/** The summary lists at most this many Skills (failures first); the rest are counted, not listed. */
|
|
14
|
+
export declare const MAX_SUMMARY_ROWS = 200;
|
|
15
|
+
/** Workflow annotations are capped too; GitHub shows only a handful per step anyway. */
|
|
16
|
+
export declare const MAX_ANNOTATIONS = 50;
|
|
17
|
+
export interface GitHubCheckResult {
|
|
18
|
+
mode: Policy['mode'];
|
|
19
|
+
/** Set when discovery exceeded its work budget; `results` then holds a single UNVERIFIABLE entry and no Skill was checked. */
|
|
20
|
+
budgetExceeded?: string;
|
|
21
|
+
results: VerificationResult[];
|
|
22
|
+
exitCode: number;
|
|
23
|
+
summary: string;
|
|
24
|
+
}
|
|
25
|
+
/** Names and paths come from the pull request; keep them inert inside a Markdown table cell. */
|
|
26
|
+
export declare function markdownCell(value: string): string;
|
|
27
|
+
export declare function runGitHubCheck(options: GitHubCheckOptions): Promise<GitHubCheckResult>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// GitHub Action runner. Trust comes from the protected base revision (policy, trust root,
|
|
3
|
+
// revocation list); Skills and certificates come from the pull request. A pull request can
|
|
4
|
+
// therefore add certificates but cannot change who is trusted to issue them.
|
|
5
|
+
import { appendFile, realpath } from 'node:fs/promises';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { isInside } from "../../src/fs-safe.js";
|
|
8
|
+
import { isMainModule } from "../../src/main-module.js";
|
|
9
|
+
import { DiscoveryBudgetError, findSkillDirs, loadPolicy, loadPolicyTrust, tooDeepResult, verifyWithPolicy } from "../../src/policy.js";
|
|
10
|
+
import { unverifiable } from "../../src/verify.js";
|
|
11
|
+
/** The summary lists at most this many Skills (failures first); the rest are counted, not listed. */
|
|
12
|
+
export const MAX_SUMMARY_ROWS = 200;
|
|
13
|
+
/** Workflow annotations are capped too; GitHub shows only a handful per step anyway. */
|
|
14
|
+
export const MAX_ANNOTATIONS = 50;
|
|
15
|
+
/** Names and paths come from the pull request; keep them inert inside a Markdown table cell. */
|
|
16
|
+
export function markdownCell(value) {
|
|
17
|
+
return value
|
|
18
|
+
.replace(/[\u0000-\u001f\u007f\u2028\u2029]+/gu, ' ')
|
|
19
|
+
.replace(/[\\`*_[\]<>|#!~(){}]/gu, (char) => `\\${char}`)
|
|
20
|
+
.slice(0, 500);
|
|
21
|
+
}
|
|
22
|
+
function within(root, target, label) {
|
|
23
|
+
if (!isInside(root, target))
|
|
24
|
+
throw new Error(`${label} must stay inside ${root}`);
|
|
25
|
+
return target;
|
|
26
|
+
}
|
|
27
|
+
/** Containment on resolved paths, so a symlink cannot point a policy path outside its checkout. */
|
|
28
|
+
async function withinReal(root, target, label) {
|
|
29
|
+
within(root, target, label);
|
|
30
|
+
let resolved;
|
|
31
|
+
try {
|
|
32
|
+
resolved = await realpath(target);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error?.code === 'ENOENT')
|
|
36
|
+
return target;
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
if (!isInside(await realpath(root), resolved))
|
|
40
|
+
throw new Error(`${label} must stay inside ${root} (it resolves to ${resolved})`);
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
43
|
+
/** Re-anchors a path from the policy checkout into the workspace checkout. */
|
|
44
|
+
async function toWorkspace(policyRoot, workspace, target, label) {
|
|
45
|
+
const relative = path.relative(policyRoot, within(policyRoot, target, label));
|
|
46
|
+
return await withinReal(workspace, path.join(workspace, relative), label);
|
|
47
|
+
}
|
|
48
|
+
export async function runGitHubCheck(options) {
|
|
49
|
+
const now = options.now ?? new Date();
|
|
50
|
+
const policyRoot = path.resolve(options.policyRoot);
|
|
51
|
+
const workspace = path.resolve(options.workspace);
|
|
52
|
+
const policyPath = await withinReal(policyRoot, path.resolve(policyRoot, options.policy), 'policy');
|
|
53
|
+
const base = await loadPolicy(policyPath);
|
|
54
|
+
await withinReal(policyRoot, base.trustRootPath, 'trust_root');
|
|
55
|
+
await withinReal(policyRoot, base.revocationsPath, 'revocations');
|
|
56
|
+
const certificateDirs = [];
|
|
57
|
+
for (const dir of base.certificateDirs)
|
|
58
|
+
certificateDirs.push(await toWorkspace(policyRoot, workspace, dir, 'certificate_dirs'));
|
|
59
|
+
const skillDirs = [];
|
|
60
|
+
for (const dir of base.skillDirs)
|
|
61
|
+
skillDirs.push(await toWorkspace(policyRoot, workspace, dir, 'skill_dirs'));
|
|
62
|
+
const policy = {
|
|
63
|
+
...base,
|
|
64
|
+
certificateDirs,
|
|
65
|
+
skillDirs,
|
|
66
|
+
// CI has no persistent host state; rollback protection comes from the protected base revision.
|
|
67
|
+
statePath: null,
|
|
68
|
+
decisionLogPath: null,
|
|
69
|
+
};
|
|
70
|
+
if (policy.skillDirs.length === 0)
|
|
71
|
+
throw new Error('Policy has no skill_dirs; list the directories that hold Skills');
|
|
72
|
+
let discovery;
|
|
73
|
+
try {
|
|
74
|
+
discovery = await findSkillDirs(policy.skillDirs);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
if (!(error instanceof DiscoveryBudgetError))
|
|
78
|
+
throw error;
|
|
79
|
+
// Bounded fail-closed report: nothing is verified and no per-Skill rows are produced.
|
|
80
|
+
const result = unverifiable(workspace, 'skill discovery', error.message, now);
|
|
81
|
+
return {
|
|
82
|
+
mode: policy.mode, budgetExceeded: error.message, results: [result],
|
|
83
|
+
exitCode: policy.mode === 'enforce' ? 1 : 0,
|
|
84
|
+
summary: [
|
|
85
|
+
`### mago-ski: Skill discovery budget exceeded (${policy.mode} mode)`,
|
|
86
|
+
'',
|
|
87
|
+
`${markdownCell(error.message)}. No Skills were checked.`,
|
|
88
|
+
'',
|
|
89
|
+
policy.mode === 'shadow' ? '_Shadow mode: failures are reported but do not fail the check._' : '',
|
|
90
|
+
].join('\n'),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const { skillDirs: found, tooDeep } = discovery;
|
|
94
|
+
const trust = await loadPolicyTrust(policy, now);
|
|
95
|
+
const results = [];
|
|
96
|
+
for (const skillDir of found) {
|
|
97
|
+
results.push(trust.ok
|
|
98
|
+
? await verifyWithPolicy(policy, skillDir, { now, context: trust.context })
|
|
99
|
+
: unverifiable(skillDir, path.basename(skillDir), trust.reason, now, trust.verdict));
|
|
100
|
+
}
|
|
101
|
+
for (const directory of tooDeep)
|
|
102
|
+
results.push(tooDeepResult(directory, now));
|
|
103
|
+
const failures = results.filter((result) => result.verdict !== 'VERIFIED');
|
|
104
|
+
const ordered = [...failures, ...results.filter((result) => result.verdict === 'VERIFIED')];
|
|
105
|
+
const rows = ordered.slice(0, MAX_SUMMARY_ROWS).map((result) => {
|
|
106
|
+
const relative = path.relative(workspace, result.skillDir) || '.';
|
|
107
|
+
return `| ${result.verdict === 'VERIFIED' ? 'pass' : 'fail'} | ${markdownCell(result.skillName)} | ${markdownCell(relative)} | ${result.verdict} | ${markdownCell(result.reason)} |`;
|
|
108
|
+
});
|
|
109
|
+
const summary = [
|
|
110
|
+
`### mago-ski: ${results.length - failures.length}/${results.length} Skills verified (${policy.mode} mode)`,
|
|
111
|
+
'',
|
|
112
|
+
'| | Skill | Path | Verdict | Detail |',
|
|
113
|
+
'|---|---|---|---|---|',
|
|
114
|
+
...rows,
|
|
115
|
+
...(ordered.length > MAX_SUMMARY_ROWS ? ['', `_${ordered.length - MAX_SUMMARY_ROWS} more Skills not listed (the table shows failures first, at most ${MAX_SUMMARY_ROWS} rows)._`] : []),
|
|
116
|
+
'',
|
|
117
|
+
failures.length > 0 && policy.mode === 'shadow' ? '_Shadow mode: failures are reported but do not fail the check._' : '',
|
|
118
|
+
].join('\n');
|
|
119
|
+
return { mode: policy.mode, results, exitCode: failures.length > 0 && policy.mode === 'enforce' ? 1 : 0, summary };
|
|
120
|
+
}
|
|
121
|
+
function escapeAnnotation(value) {
|
|
122
|
+
return value.replace(/%/gu, '%25').replace(/\r/gu, '%0D').replace(/\n/gu, '%0A');
|
|
123
|
+
}
|
|
124
|
+
async function main() {
|
|
125
|
+
const [policyRoot, workspace, policy] = process.argv.slice(2);
|
|
126
|
+
if (!policyRoot || !workspace || !policy)
|
|
127
|
+
throw new Error('usage: run.ts POLICY_ROOT WORKSPACE POLICY');
|
|
128
|
+
const result = await runGitHubCheck({ policyRoot, workspace, policy });
|
|
129
|
+
let annotations = 0;
|
|
130
|
+
for (const entry of result.results) {
|
|
131
|
+
if (entry.verdict === 'VERIFIED')
|
|
132
|
+
continue;
|
|
133
|
+
if (annotations >= MAX_ANNOTATIONS) {
|
|
134
|
+
process.stdout.write(`::notice title=mago-ski::${MAX_ANNOTATIONS} annotations shown; see the job summary for the rest\n`);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
annotations += 1;
|
|
138
|
+
const level = result.mode === 'enforce' ? 'error' : 'warning';
|
|
139
|
+
const location = result.budgetExceeded ? '' : `file=${escapeAnnotation(path.relative(path.resolve(workspace), path.join(entry.skillDir, 'SKILL.md')))},`;
|
|
140
|
+
process.stdout.write(`::${level} ${location}title=mago-ski ${entry.verdict}::${escapeAnnotation(`${entry.skillName}: ${entry.reason}`)}\n`);
|
|
141
|
+
}
|
|
142
|
+
process.stdout.write(`${result.summary}\n`);
|
|
143
|
+
if (process.env.GITHUB_STEP_SUMMARY)
|
|
144
|
+
await appendFile(process.env.GITHUB_STEP_SUMMARY, `${result.summary}\n`);
|
|
145
|
+
process.exitCode = result.exitCode;
|
|
146
|
+
}
|
|
147
|
+
if (isMainModule(import.meta.url)) {
|
|
148
|
+
main().catch((error) => {
|
|
149
|
+
process.stdout.write(`::error title=mago-ski::${escapeAnnotation(error.message)}\n`);
|
|
150
|
+
process.exitCode = 2;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
export interface MagoSkiPiOptions {
|
|
3
|
+
/** Policy file (absolute, or starting with "~/"); defaults to $MAGO_SKI_POLICY, then ~/.mago-ski/policy.json. Must be outside the project. */
|
|
4
|
+
policyPath?: string;
|
|
5
|
+
now?: () => Date;
|
|
6
|
+
}
|
|
7
|
+
/** Why a path must not be shown to the model, or null when it may be. `bases` are trusted prefixes. */
|
|
8
|
+
export declare function promptPathProblem(target: string, bases?: string[]): string | null;
|
|
9
|
+
/** Same frontmatter handling and block format as Pi's own /skill: expansion. Throws on unsafe metadata. */
|
|
10
|
+
export declare function skillBlock(name: string, filePath: string, baseDir: string, content: string, args: string, trustedBases?: string[]): string;
|
|
11
|
+
export declare function createMagoSkiExtension(options?: MagoSkiPiOptions): (pi: ExtensionAPI) => void;
|
|
12
|
+
declare const _default: (pi: ExtensionAPI) => void;
|
|
13
|
+
export default _default;
|