@keelcodes/cli 0.1.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 +201 -0
- package/README.md +141 -0
- package/dist/args.d.ts +29 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +86 -0
- package/dist/args.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +5 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands.d.ts +30 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +360 -0
- package/dist/commands.js.map +1 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +22 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +26 -0
- package/dist/io.js.map +1 -0
- package/dist/run.d.ts +12 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +79 -0
- package/dist/run.js.map +1 -0
- package/dist/version.d.ts +9 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +11 -0
- package/dist/version.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Keel contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# @keelcodes/cli
|
|
2
|
+
|
|
3
|
+
The `keel` command line — the operator-facing side of Keel, built so the checks
|
|
4
|
+
you would run by hand are scriptable.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pnpm --filter @keelcodes/cli build
|
|
8
|
+
node cli/dist/bin.js help
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Installed as a dependency it publishes two equivalent binaries, `keel` and `kc`
|
|
12
|
+
(the short alias avoids a collision with the unrelated `teamkeel` CLI):
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
keel version
|
|
16
|
+
kc version
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
### `keel version`
|
|
22
|
+
|
|
23
|
+
Print the CLI's own name and version, read from `package.json` so it cannot
|
|
24
|
+
drift. `--json` for machine-readable output.
|
|
25
|
+
|
|
26
|
+
### `keel policy check`
|
|
27
|
+
|
|
28
|
+
Normalise an authored policy, print its canonical commitment hash, and — when a
|
|
29
|
+
target is given — dry-run a call against it with the **same** `evaluateCall` the
|
|
30
|
+
MCP server and the on-chain hook use.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
keel policy check --policy policy.json
|
|
34
|
+
# policy 0x9f… (rules…)
|
|
35
|
+
|
|
36
|
+
keel policy check --policy policy.json --target 0xToken… --value 500
|
|
37
|
+
# commitment 0x9f…
|
|
38
|
+
# call target=0xtoken… value=500 selector=0x
|
|
39
|
+
# allow rule=0
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Exit codes compose with a shell: **0** when the policy normalises (and the call,
|
|
43
|
+
if any, is allowed), **1** when a call is denied or the policy is malformed, **2**
|
|
44
|
+
on a usage error.
|
|
45
|
+
|
|
46
|
+
The policy file is the authored `PolicyInput` shape, with wei amounts as decimal
|
|
47
|
+
strings because JSON has no bigint:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"validAfter": "0",
|
|
52
|
+
"validUntil": "0",
|
|
53
|
+
"rules": [
|
|
54
|
+
{
|
|
55
|
+
"target": "0x0000000000000000000000000000000000000001",
|
|
56
|
+
"selectors": ["0xa9059cbb"],
|
|
57
|
+
"maxPerTx": "1000000000000000000",
|
|
58
|
+
"maxDaily": "5000000000000000000",
|
|
59
|
+
"maxCalls": 20,
|
|
60
|
+
"tokenLimits": [{ "token": "0x…", "maxPerTx": "0", "maxDaily": "0" }]
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Use `-` as the path to read the policy from stdin.
|
|
67
|
+
|
|
68
|
+
### `keel migrate route`
|
|
69
|
+
|
|
70
|
+
Route a session record to its module generation, using the same
|
|
71
|
+
`createModuleRegistry` / `routeSession` the relay uses.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
keel migrate route --registry registry.json --id s-1
|
|
75
|
+
# session s-1 (no moduleVersion)
|
|
76
|
+
# → v2 encoding=onchain multiSession=true enforcedLimits=true
|
|
77
|
+
|
|
78
|
+
keel migrate route --registry registry.json --id s-2 --module-version v1 --json
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The registry file is either an array of module descriptors or an object with a
|
|
82
|
+
`defaultVersion` and a `modules` array:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"defaultVersion": "v2",
|
|
87
|
+
"modules": [
|
|
88
|
+
{ "version": "v1", "encoding": "payload", "multiSession": false, "enforcedLimits": false },
|
|
89
|
+
{ "version": "v2", "encoding": "onchain", "multiSession": true, "enforcedLimits": true }
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
A session with no `module-version` routes to the default generation — the lazy
|
|
95
|
+
half of lazy migration. An unregistered version exits **1** with
|
|
96
|
+
`unknown-module-version`.
|
|
97
|
+
|
|
98
|
+
### `keel conformance list` / `keel conformance run`
|
|
99
|
+
|
|
100
|
+
`list` prints the bundled suites; `run` executes one against a live chain and
|
|
101
|
+
prints a per-assertion report. Exit code **1** when any check fails.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
keel conformance list
|
|
105
|
+
# ERC-7579 · ERC-7579 (Modular Smart Accounts) · 6 checks
|
|
106
|
+
# ERC-7710 · ERC-7710 (Smart Contract Delegation) · 7 checks
|
|
107
|
+
# ERC-7715 · ERC-7715 (Request Permissions from Wallets) · 4 checks
|
|
108
|
+
# ERC-8004 · ERC-8004 (Trustless Agents) · 6 checks
|
|
109
|
+
|
|
110
|
+
keel conformance run --rpc http://localhost:8545 --account 0x… --module 0x… --type 4
|
|
111
|
+
keel conformance run --suite erc7710 --rpc http://localhost:8545 --manager 0x…
|
|
112
|
+
keel conformance run --suite erc8004 --rpc http://localhost:8545 --identity-registry 0x… --agent-id 1
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
- **erc7579** (default): `--account`, `--module`, `--type` (module type id, default
|
|
116
|
+
`1`).
|
|
117
|
+
- **erc7710**: `--manager`.
|
|
118
|
+
- **erc8004**: `--identity-registry`, `--agent-id`, optional `--reputation-registry`.
|
|
119
|
+
- **erc7715** needs a wallet (EIP-1193) provider, which a CLI cannot construct —
|
|
120
|
+
run it through the SDK.
|
|
121
|
+
|
|
122
|
+
`--rpc` falls back to `KEEL_RPC_URL`. Add `--json` to emit the raw report.
|
|
123
|
+
|
|
124
|
+
## Global options
|
|
125
|
+
|
|
126
|
+
Options may be written `--name value`, `--name=value` or `-n value`; `--` ends
|
|
127
|
+
option parsing. `--json` is supported by every command; `--help` (or `keel help`)
|
|
128
|
+
prints usage.
|
|
129
|
+
|
|
130
|
+
## Develop
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
pnpm --filter @keelcodes/cli build
|
|
134
|
+
pnpm --filter @keelcodes/cli typecheck
|
|
135
|
+
pnpm --filter @keelcodes/cli test
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Commands are written against a small `CliIo` port (`out`, `err`, `readText`,
|
|
139
|
+
`readStdin`, `env`), so the whole surface is tested in memory — see
|
|
140
|
+
[`src/cli.test.ts`](src/cli.test.ts). The design intent is in
|
|
141
|
+
[`docs/KEEL_PLAN.md`](../../docs/KEEL_PLAN.md) §4.4 ⑥.
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed command-line arguments: positionals plus named options.
|
|
3
|
+
*
|
|
4
|
+
* Options are collected in order, so a repeated option keeps every value and
|
|
5
|
+
* `get` returns the last one. The surface is deliberately tiny — the CLI has a
|
|
6
|
+
* handful of flags and no need for a parser dependency.
|
|
7
|
+
*/
|
|
8
|
+
export interface ParsedArgs {
|
|
9
|
+
readonly positionals: readonly string[];
|
|
10
|
+
/** The last value given for `name`, or `undefined`. */
|
|
11
|
+
get(name: string): string | undefined;
|
|
12
|
+
/** Every value given for `name`, in order. */
|
|
13
|
+
all(name: string): readonly string[];
|
|
14
|
+
/** Whether `name` was given at all. */
|
|
15
|
+
has(name: string): boolean;
|
|
16
|
+
/** Whether the boolean `name` was given. */
|
|
17
|
+
bool(name: string): boolean;
|
|
18
|
+
/** Like `get`, but throws a {@link UsageError} when absent. */
|
|
19
|
+
require(name: string): string;
|
|
20
|
+
/** Parses `name` as an integer, or `undefined` when absent. */
|
|
21
|
+
int(name: string): bigint | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parses argv in `--name value`, `--name=value` and `-n value` forms. Names in
|
|
25
|
+
* `booleanFlags` take no value; `--` ends option parsing and everything after it
|
|
26
|
+
* is positional.
|
|
27
|
+
*/
|
|
28
|
+
export declare function parseArgs(argv: readonly string[], booleanFlags?: readonly string[]): ParsedArgs;
|
|
29
|
+
//# sourceMappingURL=args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,uDAAuD;IACvD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACtC,8CAA8C;IAC9C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACrC,uCAAuC;IACvC,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,4CAA4C;IAC5C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,+DAA+D;IAC/D,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,+DAA+D;IAC/D,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CACvC;AA6CD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,YAAY,GAAE,SAAS,MAAM,EAAO,GAAG,UAAU,CAgDnG"}
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { UsageError } from './errors.js';
|
|
2
|
+
class Args {
|
|
3
|
+
positionals;
|
|
4
|
+
values;
|
|
5
|
+
constructor(values, positionals) {
|
|
6
|
+
this.values = values;
|
|
7
|
+
this.positionals = positionals;
|
|
8
|
+
}
|
|
9
|
+
get(name) {
|
|
10
|
+
const list = this.values.get(name);
|
|
11
|
+
return list === undefined ? undefined : list[list.length - 1];
|
|
12
|
+
}
|
|
13
|
+
all(name) {
|
|
14
|
+
return this.values.get(name) ?? [];
|
|
15
|
+
}
|
|
16
|
+
has(name) {
|
|
17
|
+
return this.values.has(name);
|
|
18
|
+
}
|
|
19
|
+
bool(name) {
|
|
20
|
+
return this.get(name) === 'true';
|
|
21
|
+
}
|
|
22
|
+
require(name) {
|
|
23
|
+
const value = this.get(name);
|
|
24
|
+
if (value === undefined)
|
|
25
|
+
throw new UsageError(`missing required option --${name}`);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
int(name) {
|
|
29
|
+
const value = this.get(name);
|
|
30
|
+
if (value === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
try {
|
|
33
|
+
return BigInt(value);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
throw new UsageError(`--${name} must be an integer, got "${value}"`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parses argv in `--name value`, `--name=value` and `-n value` forms. Names in
|
|
42
|
+
* `booleanFlags` take no value; `--` ends option parsing and everything after it
|
|
43
|
+
* is positional.
|
|
44
|
+
*/
|
|
45
|
+
export function parseArgs(argv, booleanFlags = []) {
|
|
46
|
+
const flags = new Set(booleanFlags);
|
|
47
|
+
const values = new Map();
|
|
48
|
+
const positionals = [];
|
|
49
|
+
const add = (name, value) => {
|
|
50
|
+
const list = values.get(name) ?? [];
|
|
51
|
+
list.push(value);
|
|
52
|
+
values.set(name, list);
|
|
53
|
+
};
|
|
54
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
55
|
+
const token = argv[index];
|
|
56
|
+
if (token === '--') {
|
|
57
|
+
positionals.push(...argv.slice(index + 1));
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
const long = token.startsWith('--') ? token.slice(2) : undefined;
|
|
61
|
+
const short = long === undefined && token.startsWith('-') && token.length > 1 ? token.slice(1) : undefined;
|
|
62
|
+
if (long === undefined && short === undefined) {
|
|
63
|
+
positionals.push(token);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const name = long ?? short;
|
|
67
|
+
const equals = name.indexOf('=');
|
|
68
|
+
if (equals !== -1) {
|
|
69
|
+
add(name.slice(0, equals), name.slice(equals + 1));
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (flags.has(name)) {
|
|
73
|
+
add(name, 'true');
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const next = argv[index + 1];
|
|
77
|
+
// A leading dash is an option, not a value — except for `-` (stdin) and negative numbers.
|
|
78
|
+
if (next === undefined || (next.startsWith('-') && next !== '-' && !/^-?\d/.test(next))) {
|
|
79
|
+
throw new UsageError(`option ${long === undefined ? `-${name}` : `--${name}`} needs a value`);
|
|
80
|
+
}
|
|
81
|
+
add(name, next);
|
|
82
|
+
index += 1;
|
|
83
|
+
}
|
|
84
|
+
return new Args(values, positionals);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAyBzC,MAAM,IAAI;IACC,WAAW,CAAoB;IACvB,MAAM,CAAwB;IAE/C,YAAY,MAA6B,EAAE,WAA8B;QACvE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;IACnC,CAAC;IAED,OAAO,CAAC,IAA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I,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACxF,MAAM,IAAI,UAAU,CAAC,UAAU,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,gBAAgB,CAAC,CAAC;QAChG,CAAC;QACD,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAChB,KAAK,IAAI,CAAC,CAAC;IACb,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type PolicyInput } from '@keelcodes/policy';
|
|
2
|
+
import type { ParsedArgs } from './args.js';
|
|
3
|
+
import { type CliIo } from './io.js';
|
|
4
|
+
/** `keel version` — print the CLI's own name and version. */
|
|
5
|
+
export declare function versionCommand(args: ParsedArgs, io: CliIo): number;
|
|
6
|
+
/**
|
|
7
|
+
* `keel policy check` — normalise a policy and print its commitment. When a
|
|
8
|
+
* target is given, also dry-run a call against it. Exit code 1 when the call is
|
|
9
|
+
* denied, so it composes with `&&` in a script.
|
|
10
|
+
*/
|
|
11
|
+
export declare function policyCheck(args: ParsedArgs, io: CliIo): Promise<number>;
|
|
12
|
+
/**
|
|
13
|
+
* `keel migrate route` — route a session record to its module generation using a
|
|
14
|
+
* registry read from a JSON file.
|
|
15
|
+
*/
|
|
16
|
+
export declare function migrateRoute(args: ParsedArgs, io: CliIo): Promise<number>;
|
|
17
|
+
/** `keel conformance list` — print the available suites and their check counts. */
|
|
18
|
+
export declare function conformanceList(args: ParsedArgs, io: CliIo): number;
|
|
19
|
+
/**
|
|
20
|
+
* `keel conformance run` — run one suite against a live chain. Exit code 1 when
|
|
21
|
+
* the suite fails (any check, or a critical one).
|
|
22
|
+
*/
|
|
23
|
+
export declare function conformanceRun(args: ParsedArgs, io: CliIo): Promise<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Parses a policy as authored: the {@link PolicyInput} shape, with wei amounts
|
|
26
|
+
* written as decimal strings because JSON has no bigint. Throws a plain `Error`
|
|
27
|
+
* on a malformed shape — `normalizePolicy` then validates the meaning.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parsePolicyInput(value: unknown): PolicyInput;
|
|
30
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAcA,OAAO,EAQL,KAAK,WAAW,EAGjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAa,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAWhD,6DAA6D;AAC7D,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAKlE;AAED;;;;GAIG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA0C9E;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B/E;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAenE;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAajF;AAqHD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CAY5D"}
|