@wirecat/cli-core 0.19.0 → 0.19.2
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/README.md +31 -0
- package/config/wirecat/LICENSE +204 -0
- package/config/wirecat/biome.base.json +56 -0
- package/config/wirecat/check.mjs +41 -0
- package/config/wirecat/cspell.json +80 -0
- package/config/wirecat/lefthook.yml +34 -0
- package/config/wirecat/manifest.json +23 -0
- package/config/wirecat/markdownlint.json +10 -0
- package/config/wirecat/rumdl.toml +9 -0
- package/dist/deadline.d.ts +14 -0
- package/dist/deadline.d.ts.map +1 -0
- package/dist/deadline.js +85 -0
- package/dist/deadline.js.map +1 -0
- package/dist/executable.d.ts.map +1 -1
- package/dist/executable.js +5 -10
- package/dist/executable.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/output-buffer.d.ts +16 -0
- package/dist/output-buffer.d.ts.map +1 -0
- package/dist/output-buffer.js +69 -0
- package/dist/output-buffer.js.map +1 -0
- package/dist/result-fields.d.ts +4 -0
- package/dist/result-fields.d.ts.map +1 -0
- package/dist/result-fields.js +56 -0
- package/dist/result-fields.js.map +1 -0
- package/package.json +13 -5
package/README.md
CHANGED
|
@@ -36,6 +36,9 @@ streams.stderr // []
|
|
|
36
36
|
| `renderer` · `pretty` | `pretty` / `json` / `jsonl`; tables for lists, labelled lines for objects; `quiet` keeps only failures on stderr |
|
|
37
37
|
| `errors` · `exit-codes` | 14 closed error codes, one exit number each, so a script can branch on `$?` |
|
|
38
38
|
| `keyring` | `KeyringStore` with the system, memory and deliberately-broken implementations |
|
|
39
|
+
| `fieldsOf` · `projectFields` | validated field selection preserving list metadata and operation identifiers |
|
|
40
|
+
| `createOutputBuffer` | bounded UTF-8 output held until successful completion and resource cleanup |
|
|
41
|
+
| `createDeadline` | cooperative command cancellation with injected sleep and a parent abort signal |
|
|
39
42
|
| `time` | monotonic and wall clocks, and the one sleep that both timeouts and backoff use |
|
|
40
43
|
| `logger` | the four-method interface a host adapts Pino to — this package logs nothing itself |
|
|
41
44
|
| `paths` | `env-paths` for config, state and cache, each overridable by environment variable |
|
|
@@ -60,6 +63,34 @@ does not call:
|
|
|
60
63
|
import { providerWaitMs, statusToCode } from "@wirecat/cli-core/http"
|
|
61
64
|
```
|
|
62
65
|
|
|
66
|
+
**Portable command control stays independent of provider and store lifetimes.**
|
|
67
|
+
`fieldsOf("id,speaker.id")` parses up to 128 field paths; `projectFields(value, paths)` selects data
|
|
68
|
+
from objects or list items while preserving the list envelope and `operationId` / `sendId`.
|
|
69
|
+
`items.id` also works for bare objects and JSONL items. Unknown fields are omitted; parent selections
|
|
70
|
+
win over their children. Unsafe prototype paths are refused, including when paths are passed directly.
|
|
71
|
+
|
|
72
|
+
`createOutputBuffer({ maxOutputBytes })` retains raw output chunks until `flush(write)` or `discard()`.
|
|
73
|
+
Its default limit is 4 MiB; zero disables the limit. It counts actual UTF-8 bytes, including delimiters
|
|
74
|
+
the caller passes, and adds no newlines. Use a new buffer for each command and flush only after resource
|
|
75
|
+
cleanup succeeds; discard on failure. A flush consumes the buffer even when its writer throws.
|
|
76
|
+
The `bytes` property reports the cumulative accepted byte count. A writer failure can leave partial
|
|
77
|
+
output; buffering only guarantees no output before flushing.
|
|
78
|
+
|
|
79
|
+
Optional `{ fields, format: "json" | "jsonl" }` projects before counting bytes. With projection,
|
|
80
|
+
each `data(text)` must contain a complete JSON value or complete JSONL lines; fragments fail before
|
|
81
|
+
buffering. Without projection, arbitrary text chunks work. Hosts can instead project values before
|
|
82
|
+
rendering and buffer the renderer's raw text. For core renderers, pass the line delimiter explicitly
|
|
83
|
+
when adapting `Streams.data`: `data: (text) => buffer.data(text + "\n")`.
|
|
84
|
+
|
|
85
|
+
`createDeadline({ timeoutMs, signal, sleep })` supplies a command signal and `race(body)`. An omitted
|
|
86
|
+
timeout creates no timer; zero is an immediate deadline, and the maximum is 2147483647 milliseconds.
|
|
87
|
+
Pass its signal to every cancellable operation and check it before writes. On timeout or parent
|
|
88
|
+
cancellation, `race` waits for the body to settle before rejecting, so a caller can safely close
|
|
89
|
+
resources afterwards. An operation ignoring its signal can delay completion; this helper never
|
|
90
|
+
abandons it in the background. A body's more precise `outcome_unknown` error survives interruption.
|
|
91
|
+
Call `dispose()` in `finally` to remove the timer and parent listener. There are no process signal
|
|
92
|
+
handlers, retries, automatic resource cleanup or HTTP behavior in these helpers.
|
|
93
|
+
|
|
63
94
|
**The command registry is `@wirecat/cli-core/commands`** — the whole command tree as data, like
|
|
64
95
|
`rails routes`, for an agent to read instead of `--help` and for generated documentation. It walks
|
|
65
96
|
the live [Commander](https://github.com/tj/commander.js) tree, so a command built in a loop from a
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
Copyright (c) 2026 Viacheslav Ptsarev
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Apache License
|
|
5
|
+
Version 2.0, January 2004
|
|
6
|
+
http://www.apache.org/licenses/
|
|
7
|
+
|
|
8
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
9
|
+
|
|
10
|
+
1. Definitions.
|
|
11
|
+
|
|
12
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
13
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
14
|
+
|
|
15
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
16
|
+
the copyright owner that is granting the License.
|
|
17
|
+
|
|
18
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
19
|
+
other entities that control, are controlled by, or are under common
|
|
20
|
+
control with that entity. For the purposes of this definition,
|
|
21
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
22
|
+
direction or management of such entity, whether by contract or
|
|
23
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
24
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
25
|
+
|
|
26
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
27
|
+
exercising permissions granted by this License.
|
|
28
|
+
|
|
29
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
30
|
+
including but not limited to software source code, documentation
|
|
31
|
+
source, and configuration files.
|
|
32
|
+
|
|
33
|
+
"Object" form shall mean any form resulting from mechanical
|
|
34
|
+
transformation or translation of a Source form, including but
|
|
35
|
+
not limited to compiled object code, generated documentation,
|
|
36
|
+
and conversions to other media types.
|
|
37
|
+
|
|
38
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
39
|
+
Object form, made available under the License, as indicated by a
|
|
40
|
+
copyright notice that is included in or attached to the work
|
|
41
|
+
(an example is provided in the Appendix below).
|
|
42
|
+
|
|
43
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
44
|
+
form, that is based on (or derived from) the Work and for which the
|
|
45
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
46
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
47
|
+
of this License, Derivative Works shall not include works that remain
|
|
48
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
49
|
+
the Work and Derivative Works thereof.
|
|
50
|
+
|
|
51
|
+
"Contribution" shall mean any work of authorship, including
|
|
52
|
+
the original version of the Work and any modifications or additions
|
|
53
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
54
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
55
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
56
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
57
|
+
means any form of electronic, verbal, or written communication sent
|
|
58
|
+
to the Licensor or its representatives, including but not limited to
|
|
59
|
+
communication on electronic mailing lists, source code control systems,
|
|
60
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
61
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
62
|
+
excluding communication that is conspicuously marked or otherwise
|
|
63
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
64
|
+
|
|
65
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
66
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
67
|
+
subsequently incorporated within the Work.
|
|
68
|
+
|
|
69
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
70
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
71
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
72
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
73
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
74
|
+
Work and such Derivative Works in Source or Object form.
|
|
75
|
+
|
|
76
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
77
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
78
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
79
|
+
(except as stated in this section) patent license to make, have made,
|
|
80
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
81
|
+
where such license applies only to those patent claims licensable
|
|
82
|
+
by such Contributor that are necessarily infringed by their
|
|
83
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
84
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
85
|
+
institute patent litigation against any entity (including a
|
|
86
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
87
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
88
|
+
or contributory patent infringement, then any patent licenses
|
|
89
|
+
granted to You under this License for that Work shall terminate
|
|
90
|
+
as of the date such litigation is filed.
|
|
91
|
+
|
|
92
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
93
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
94
|
+
modifications, and in Source or Object form, provided that You
|
|
95
|
+
meet the following conditions:
|
|
96
|
+
|
|
97
|
+
(a) You must give any other recipients of the Work or
|
|
98
|
+
Derivative Works a copy of this License; and
|
|
99
|
+
|
|
100
|
+
(b) You must cause any modified files to carry prominent notices
|
|
101
|
+
stating that You changed the files; and
|
|
102
|
+
|
|
103
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
104
|
+
that You distribute, all copyright, patent, trademark, and
|
|
105
|
+
attribution notices from the Source form of the Work,
|
|
106
|
+
excluding those notices that do not pertain to any part of
|
|
107
|
+
the Derivative Works; and
|
|
108
|
+
|
|
109
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
110
|
+
distribution, then any Derivative Works that You distribute must
|
|
111
|
+
include a readable copy of the attribution notices contained
|
|
112
|
+
within such NOTICE file, excluding those notices that do not
|
|
113
|
+
pertain to any part of the Derivative Works, in at least one
|
|
114
|
+
of the following places: within a NOTICE text file distributed
|
|
115
|
+
as part of the Derivative Works; within the Source form or
|
|
116
|
+
documentation, if provided along with the Derivative Works; or,
|
|
117
|
+
within a display generated by the Derivative Works, if and
|
|
118
|
+
wherever such third-party notices normally appear. The contents
|
|
119
|
+
of the NOTICE file are for informational purposes only and
|
|
120
|
+
do not modify the License. You may add Your own attribution
|
|
121
|
+
notices within Derivative Works that You distribute, alongside
|
|
122
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
123
|
+
that such additional attribution notices cannot be construed
|
|
124
|
+
as modifying the License.
|
|
125
|
+
|
|
126
|
+
You may add Your own copyright statement to Your modifications and
|
|
127
|
+
may provide additional or different license terms and conditions
|
|
128
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
129
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
130
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
131
|
+
the conditions stated in this License.
|
|
132
|
+
|
|
133
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
134
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
135
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
136
|
+
this License, without any additional terms or conditions.
|
|
137
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
138
|
+
the terms of any separate license agreement you may have executed
|
|
139
|
+
with Licensor regarding such Contributions.
|
|
140
|
+
|
|
141
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
142
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
143
|
+
except as required for reasonable and customary use in describing the
|
|
144
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
145
|
+
|
|
146
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
147
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
148
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
149
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
150
|
+
implied, including, without limitation, any warranties or conditions
|
|
151
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
152
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
153
|
+
appropriateness of using or redistributing the Work and assume any
|
|
154
|
+
risks associated with Your exercise of permissions under this License.
|
|
155
|
+
|
|
156
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
157
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
158
|
+
unless required by applicable law (such as deliberate and grossly
|
|
159
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
160
|
+
liable to You for damages, including any direct, indirect, special,
|
|
161
|
+
incidental, or consequential damages of any character arising as a
|
|
162
|
+
result of this License or out of the use or inability to use the
|
|
163
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
164
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
165
|
+
other commercial damages or losses), even if such Contributor
|
|
166
|
+
has been advised of the possibility of such damages.
|
|
167
|
+
|
|
168
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
169
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
170
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
171
|
+
or other liability obligations and/or rights consistent with this
|
|
172
|
+
License. However, in accepting such obligations, You may act only
|
|
173
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
174
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
175
|
+
defend, and hold each Contributor harmless for any liability
|
|
176
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
177
|
+
of your accepting any such warranty or additional liability.
|
|
178
|
+
|
|
179
|
+
END OF TERMS AND CONDITIONS
|
|
180
|
+
|
|
181
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
182
|
+
|
|
183
|
+
To apply the Apache License to your work, attach the following
|
|
184
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
185
|
+
replaced with your own identifying information. (Don't include
|
|
186
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
187
|
+
comment syntax for the file format. We also recommend that a
|
|
188
|
+
file or class name and description of purpose be included on the
|
|
189
|
+
same "printed page" as the copyright notice for easier
|
|
190
|
+
identification within third-party archives.
|
|
191
|
+
|
|
192
|
+
Copyright [yyyy] [name of copyright owner]
|
|
193
|
+
|
|
194
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
195
|
+
you may not use this file except in compliance with the License.
|
|
196
|
+
You may obtain a copy of the License at
|
|
197
|
+
|
|
198
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
199
|
+
|
|
200
|
+
Unless required by applicable law or agreed to in writing, software
|
|
201
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
202
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
203
|
+
See the License for the specific language governing permissions and
|
|
204
|
+
limitations under the License.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"vcs": {
|
|
3
|
+
"enabled": true,
|
|
4
|
+
"clientKind": "git",
|
|
5
|
+
"useIgnoreFile": true
|
|
6
|
+
},
|
|
7
|
+
"formatter": {
|
|
8
|
+
"enabled": true,
|
|
9
|
+
"indentStyle": "space",
|
|
10
|
+
"indentWidth": 2,
|
|
11
|
+
"lineWidth": 120
|
|
12
|
+
},
|
|
13
|
+
"javascript": {
|
|
14
|
+
"formatter": {
|
|
15
|
+
"quoteStyle": "double",
|
|
16
|
+
"semicolons": "asNeeded",
|
|
17
|
+
"trailingCommas": "all",
|
|
18
|
+
"arrowParentheses": "always"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"linter": {
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"rules": {
|
|
24
|
+
"preset": "recommended",
|
|
25
|
+
"style": {
|
|
26
|
+
"useConst": "error",
|
|
27
|
+
"noNonNullAssertion": "error"
|
|
28
|
+
},
|
|
29
|
+
"correctness": {
|
|
30
|
+
"noUnusedImports": "error",
|
|
31
|
+
"noUnusedVariables": "error"
|
|
32
|
+
},
|
|
33
|
+
"suspicious": {
|
|
34
|
+
"noExplicitAny": "error",
|
|
35
|
+
"noConsole": {
|
|
36
|
+
"level": "error",
|
|
37
|
+
"options": {
|
|
38
|
+
"allow": ["error"]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"overrides": [
|
|
45
|
+
{
|
|
46
|
+
"includes": ["scripts/**"],
|
|
47
|
+
"linter": {
|
|
48
|
+
"rules": {
|
|
49
|
+
"suspicious": {
|
|
50
|
+
"noConsole": "off"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createHash } from "node:crypto"
|
|
2
|
+
import { readFileSync } from "node:fs"
|
|
3
|
+
import { dirname, resolve } from "node:path"
|
|
4
|
+
import { fileURLToPath } from "node:url"
|
|
5
|
+
|
|
6
|
+
const directory = dirname(fileURLToPath(import.meta.url))
|
|
7
|
+
const root = resolve(directory, "../..")
|
|
8
|
+
const manifest = JSON.parse(readFileSync(resolve(directory, "manifest.json"), "utf8"))
|
|
9
|
+
const errors = []
|
|
10
|
+
|
|
11
|
+
for (const [name, expected] of Object.entries(manifest.files)) {
|
|
12
|
+
const actual = createHash("sha256")
|
|
13
|
+
.update(readFileSync(resolve(directory, name)))
|
|
14
|
+
.digest("hex")
|
|
15
|
+
if (actual !== expected) errors.push(`Managed standard changed: ${name}`)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const packageJson = JSON.parse(readFileSync(resolve(root, "package.json"), "utf8"))
|
|
19
|
+
for (const [name, expected] of Object.entries(manifest.devDependencies)) {
|
|
20
|
+
if (packageJson.devDependencies?.[name] !== expected) errors.push(`Expected ${name}@${expected}`)
|
|
21
|
+
}
|
|
22
|
+
if (packageJson.packageManager !== manifest.packageManager) errors.push("Package manager differs from shared standard")
|
|
23
|
+
|
|
24
|
+
const biome = JSON.parse(readFileSync(resolve(root, "biome.json"), "utf8"))
|
|
25
|
+
if (!biome.extends?.includes("./config/wirecat/biome.base.json"))
|
|
26
|
+
errors.push("Biome does not extend the shared standard")
|
|
27
|
+
const spell = JSON.parse(readFileSync(resolve(root, "cspell.json"), "utf8"))
|
|
28
|
+
if (!spell.import?.includes("./config/wirecat/cspell.json")) errors.push("CSpell does not import the shared standard")
|
|
29
|
+
const markdown = JSON.parse(readFileSync(resolve(root, ".markdownlint-cli2.jsonc"), "utf8"))
|
|
30
|
+
if (markdown.config?.extends !== "./config/wirecat/markdownlint.json")
|
|
31
|
+
errors.push("Markdown does not extend the shared standard")
|
|
32
|
+
const hooks = readFileSync(resolve(root, "lefthook.yml"), "utf8")
|
|
33
|
+
if (!/^\s*-\s*config\/wirecat\/lefthook\.yml\s*$/m.test(hooks))
|
|
34
|
+
errors.push("Git hooks do not extend the shared standard")
|
|
35
|
+
|
|
36
|
+
if (errors.length) {
|
|
37
|
+
process.stderr.write(`${errors.join("\n")}\nUpdate standards centrally or put project overrides in root configs.\n`)
|
|
38
|
+
process.exitCode = 1
|
|
39
|
+
} else {
|
|
40
|
+
process.stdout.write(`Shared standards match ${manifest.revision}.\n`)
|
|
41
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2",
|
|
3
|
+
"language": "en,en-GB,ru,es",
|
|
4
|
+
"ignoreRegExpList": [
|
|
5
|
+
"/^\\s*(```|~~~)[\\s\\S]*?^\\s*\\1/gm",
|
|
6
|
+
"/`[^`\\n]*`/g",
|
|
7
|
+
"/<!--[\\s\\S]*?-->/g",
|
|
8
|
+
"/\\]\\([^)]*\\)/g",
|
|
9
|
+
"/<[^>]+>/g",
|
|
10
|
+
"/^---[\\s\\S]*?^---/gm"
|
|
11
|
+
],
|
|
12
|
+
"words": [
|
|
13
|
+
"armv",
|
|
14
|
+
"brazecli",
|
|
15
|
+
"bunx",
|
|
16
|
+
"claude",
|
|
17
|
+
"codegen",
|
|
18
|
+
"CodeWiki",
|
|
19
|
+
"DeepWiki",
|
|
20
|
+
"Excalidraw",
|
|
21
|
+
"frontmatter",
|
|
22
|
+
"Fumadocs",
|
|
23
|
+
"gitleaks",
|
|
24
|
+
"Hermes",
|
|
25
|
+
"JSONL",
|
|
26
|
+
"keyring",
|
|
27
|
+
"kwallet",
|
|
28
|
+
"leemour",
|
|
29
|
+
"libc",
|
|
30
|
+
"libsecret",
|
|
31
|
+
"Lucene",
|
|
32
|
+
"LUKS",
|
|
33
|
+
"Mermaid",
|
|
34
|
+
"mtcute",
|
|
35
|
+
"npmjs",
|
|
36
|
+
"ONNX",
|
|
37
|
+
"pioh",
|
|
38
|
+
"Repomix",
|
|
39
|
+
"riscv",
|
|
40
|
+
"Shiki",
|
|
41
|
+
"subcommand",
|
|
42
|
+
"tailnet",
|
|
43
|
+
"tailscale",
|
|
44
|
+
"tgcli",
|
|
45
|
+
"unpushed",
|
|
46
|
+
"userbot",
|
|
47
|
+
"volta",
|
|
48
|
+
"webhooks",
|
|
49
|
+
"WireCat",
|
|
50
|
+
"wirecat",
|
|
51
|
+
"автодополнение",
|
|
52
|
+
"бана",
|
|
53
|
+
"вебхук",
|
|
54
|
+
"вебхуки",
|
|
55
|
+
"капчу",
|
|
56
|
+
"контрибьюторы",
|
|
57
|
+
"листателя",
|
|
58
|
+
"Минцифры",
|
|
59
|
+
"опкод",
|
|
60
|
+
"отсканируете",
|
|
61
|
+
"переголосовать",
|
|
62
|
+
"пулл",
|
|
63
|
+
"реквесты",
|
|
64
|
+
"рендерер",
|
|
65
|
+
"спиннера",
|
|
66
|
+
"схлопнет",
|
|
67
|
+
"схлопывает",
|
|
68
|
+
"токенам",
|
|
69
|
+
"токене",
|
|
70
|
+
"токеном",
|
|
71
|
+
"токену",
|
|
72
|
+
"хэша",
|
|
73
|
+
"хэшем"
|
|
74
|
+
],
|
|
75
|
+
"import": [
|
|
76
|
+
"@cspell/dict-en-gb/cspell-ext.json",
|
|
77
|
+
"@cspell/dict-ru_ru/cspell-ext.json",
|
|
78
|
+
"@cspell/dict-es-es/cspell-ext.json"
|
|
79
|
+
]
|
|
80
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Git hooks. Installed by the `prepare` npm script, which pnpm runs on every install — necessary
|
|
2
|
+
# because pnpm blocks dependencies' build scripts by default, so lefthook's own postinstall never
|
|
3
|
+
# fires and the hooks would otherwise silently never land.
|
|
4
|
+
#
|
|
5
|
+
# Install by hand: pnpm exec lefthook install
|
|
6
|
+
# Skip for one commit: LEFTHOOK=0 git commit …
|
|
7
|
+
|
|
8
|
+
pre-commit:
|
|
9
|
+
parallel: true
|
|
10
|
+
commands:
|
|
11
|
+
biome:
|
|
12
|
+
glob: "*.{ts,tsx,js,mjs,cjs,json,jsonc}"
|
|
13
|
+
# Staged files only. The whole-repo run is the CI gate; running it per-commit is how people
|
|
14
|
+
# end up reaching for --no-verify, which is worse than no hook.
|
|
15
|
+
run: pnpm exec biome check --no-errors-on-unmatched --files-ignore-unknown=true {staged_files}
|
|
16
|
+
|
|
17
|
+
gitleaks:
|
|
18
|
+
# Staged content only, and it warns rather than blocks when gitleaks is not installed: a
|
|
19
|
+
# fresh clone must still be able to commit. CI is the gate that cannot be skipped.
|
|
20
|
+
run: |
|
|
21
|
+
if command -v gitleaks >/dev/null 2>&1; then
|
|
22
|
+
gitleaks git --staged --no-banner --redact .
|
|
23
|
+
else
|
|
24
|
+
echo "gitleaks is not installed — staged changes were NOT scanned for secrets."
|
|
25
|
+
echo " install: https://github.com/gitleaks/gitleaks#installing (CI scans regardless)"
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
pre-push:
|
|
29
|
+
parallel: true
|
|
30
|
+
commands:
|
|
31
|
+
typecheck:
|
|
32
|
+
# A messaging CLI's parity check builds into the same dist/ as typecheck, so it runs here, after
|
|
33
|
+
# it, rather than as a command of its own beside it. A project without the script skips it.
|
|
34
|
+
run: pnpm -s run --if-present typecheck && pnpm -s run --if-present parity:check
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"source": "https://github.com/WireCatLabs/community",
|
|
3
|
+
"revision": "bfd56be79ac1c39c3692bf83eb7ea8bc046682f0",
|
|
4
|
+
"files": {
|
|
5
|
+
"biome.base.json": "83a43910f2530e21d720e3ad4c3fc7fcb16ba36253c6dbc720b3c68a4dd80893",
|
|
6
|
+
"cspell.json": "8241122ed4d461976a838099b265ef8f2689a066608257b6fdc250d9b49b58aa",
|
|
7
|
+
"lefthook.yml": "6a19c2473a570d29e33abf90470af68af9d990aac94971f4cb6d2698788c61b4",
|
|
8
|
+
"markdownlint.json": "5ed7d6980054c539f3f3c0e47a090f1a725b15be2c486a769a836bc6cd48ad2d",
|
|
9
|
+
"rumdl.toml": "048b929176f13234324f5825d1e811397f1491b9cb6684a1953e268e2c2ed863",
|
|
10
|
+
"check.mjs": "34b266411eaab7707030915f645308e86784b1574b21fa44ca974861a90c9ce1"
|
|
11
|
+
},
|
|
12
|
+
"packageManager": "pnpm@11.20.0",
|
|
13
|
+
"node": ">=22",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@biomejs/biome": "2.5.15",
|
|
16
|
+
"@cspell/dict-en-gb": "5.0.34",
|
|
17
|
+
"@cspell/dict-es-es": "3.0.9",
|
|
18
|
+
"@cspell/dict-ru_ru": "2.3.3",
|
|
19
|
+
"cspell": "10.3.6",
|
|
20
|
+
"lefthook": "2.1.16",
|
|
21
|
+
"markdownlint-cli2": "0.23.3"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# MD013 (line length): prose is wrapped by hand at 100–120 and tables cannot wrap.
|
|
2
|
+
# MD041 (first line a heading): READMEs open with the logo; docs-check --pages checks the pages.
|
|
3
|
+
# MD057 (relative links): docs-check follows every link and anchor already.
|
|
4
|
+
[global]
|
|
5
|
+
disable = ["MD013", "MD041", "MD057"]
|
|
6
|
+
exclude = ["docs/commands.md", "node_modules", "dist", "docs_ai"]
|
|
7
|
+
|
|
8
|
+
[MD033]
|
|
9
|
+
allowed-elements = ["p", "img", "a", "br", "details", "summary", "sup", "sub", "kbd"]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type SleepLike } from "./time.js";
|
|
2
|
+
export interface DeadlineOptions {
|
|
3
|
+
timeoutMs?: number;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
sleep?: SleepLike;
|
|
6
|
+
}
|
|
7
|
+
export interface Deadline {
|
|
8
|
+
readonly signal: AbortSignal;
|
|
9
|
+
/** On abort, waits for the body to settle before throwing; the body must cooperate to finish promptly. */
|
|
10
|
+
race<T>(body: (signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare const createDeadline: ({ timeoutMs, signal, sleep }?: DeadlineOptions) => Deadline;
|
|
14
|
+
//# sourceMappingURL=deadline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../src/deadline.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,WAAW,CAAA;AAErD,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AACD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,0GAA0G;IAC1G,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAA;IAC9D,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,eAAO,MAAM,cAAc,kCAA8C,eAAe,KAAQ,QA6E/F,CAAA"}
|
package/dist/deadline.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CliError } from "./errors.js";
|
|
2
|
+
import { realSleep } from "./time.js";
|
|
3
|
+
export const createDeadline = ({ timeoutMs, signal, sleep = realSleep } = {}) => {
|
|
4
|
+
if (timeoutMs !== undefined && (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647))
|
|
5
|
+
throw new CliError("validation_error", "timeoutMs must be an integer from zero through 2147483647");
|
|
6
|
+
const controller = new AbortController();
|
|
7
|
+
const timer = new AbortController();
|
|
8
|
+
let disposed = false;
|
|
9
|
+
const abort = (reason) => {
|
|
10
|
+
if (controller.signal.aborted)
|
|
11
|
+
return;
|
|
12
|
+
controller.abort(reason);
|
|
13
|
+
timer.abort();
|
|
14
|
+
signal?.removeEventListener("abort", onAbort);
|
|
15
|
+
};
|
|
16
|
+
const onAbort = () => abort(signal?.reason instanceof CliError ? signal.reason : new CliError("cancelled", "command cancelled"));
|
|
17
|
+
if (signal?.aborted)
|
|
18
|
+
onAbort();
|
|
19
|
+
else
|
|
20
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
21
|
+
if (timeoutMs !== undefined && !controller.signal.aborted) {
|
|
22
|
+
let waiting;
|
|
23
|
+
try {
|
|
24
|
+
waiting = sleep(timeoutMs, timer.signal, "timeout");
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
waiting = Promise.reject(new Error("deadline timer failed"));
|
|
28
|
+
}
|
|
29
|
+
void waiting.then(() => {
|
|
30
|
+
if (!disposed && !timer.signal.aborted)
|
|
31
|
+
abort(new CliError("timeout", "the command did not finish before its deadline", {
|
|
32
|
+
reason: "command_timeout",
|
|
33
|
+
timeoutMs,
|
|
34
|
+
retryable: false,
|
|
35
|
+
}));
|
|
36
|
+
}, () => {
|
|
37
|
+
if (!disposed && !timer.signal.aborted)
|
|
38
|
+
abort(new CliError("configuration_error", "command deadline timer failed"));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
signal: controller.signal,
|
|
43
|
+
async race(body) {
|
|
44
|
+
if (disposed)
|
|
45
|
+
throw new CliError("validation_error", "deadline is already disposed");
|
|
46
|
+
if (controller.signal.aborted)
|
|
47
|
+
throw controller.signal.reason;
|
|
48
|
+
let interrupt = () => { };
|
|
49
|
+
const interrupted = new Promise((_, reject) => {
|
|
50
|
+
interrupt = () => reject(controller.signal.reason);
|
|
51
|
+
controller.signal.addEventListener("abort", interrupt, { once: true });
|
|
52
|
+
});
|
|
53
|
+
const running = Promise.resolve().then(() => {
|
|
54
|
+
if (controller.signal.aborted)
|
|
55
|
+
throw controller.signal.reason;
|
|
56
|
+
return body(controller.signal);
|
|
57
|
+
});
|
|
58
|
+
try {
|
|
59
|
+
return await Promise.race([running, interrupted]);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (controller.signal.aborted) {
|
|
63
|
+
// A caller may close resources only after its operation can no longer use them.
|
|
64
|
+
let settled;
|
|
65
|
+
await running.catch((reason) => {
|
|
66
|
+
settled = reason;
|
|
67
|
+
});
|
|
68
|
+
if (settled instanceof CliError && settled.code === "outcome_unknown")
|
|
69
|
+
throw settled;
|
|
70
|
+
throw controller.signal.reason;
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
controller.signal.removeEventListener("abort", interrupt);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
dispose() {
|
|
79
|
+
disposed = true;
|
|
80
|
+
timer.abort();
|
|
81
|
+
signal?.removeEventListener("abort", onAbort);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=deadline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deadline.js","sourceRoot":"","sources":["../src/deadline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,SAAS,EAAkB,MAAM,WAAW,CAAA;AAcrD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,GAAG,SAAS,EAAE,GAAoB,EAAE,EAAY,EAAE;IACzG,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,IAAI,SAAS,GAAG,UAAU,CAAC;QAC1G,MAAM,IAAI,QAAQ,CAAC,kBAAkB,EAAE,2DAA2D,CAAC,CAAA;IACrG,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAA;IACxC,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAA;IACnC,IAAI,QAAQ,GAAG,KAAK,CAAA;IACpB,MAAM,KAAK,GAAG,CAAC,MAAgB,EAAE,EAAE;QACjC,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;YAAE,OAAM;QACrC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QACxB,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC/C,CAAC,CAAA;IACD,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,KAAK,CAAC,MAAM,EAAE,MAAM,YAAY,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,QAAQ,C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AAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;YAC3D,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,GAAG,IAAI,CAAA;YACf,KAAK,CAAC,KAAK,EAAE,CAAA;YACb,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QAC/C,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/dist/executable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../src/executable.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,YAClB,MAAM,OACV,MAAM,CAAC,UAAU,aACZ,MAAM,CAAC,QAAQ,WACjB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,KAChC,
|
|
1
|
+
{"version":3,"file":"executable.d.ts","sourceRoot":"","sources":["../src/executable.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,YAClB,MAAM,OACV,MAAM,CAAC,UAAU,aACZ,MAAM,CAAC,QAAQ,WACjB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,KAChC,MAcF,CAAA;AAED,eAAO,MAAM,qBAAqB,QAC3B,MAAM,CAAC,UAAU,aACZ,MAAM,CAAC,QAAQ,KACxB,MAAM,CAAC,UAcT,CAAA"}
|
package/dist/executable.js
CHANGED
|
@@ -5,37 +5,32 @@ export const executableOnPath = (command, env, platform = process.platform, exis
|
|
|
5
5
|
if (platform !== "win32" || win32.isAbsolute(command))
|
|
6
6
|
return command;
|
|
7
7
|
if (/[\\/]/.test(command))
|
|
8
|
-
|
|
8
|
+
return command;
|
|
9
9
|
const extensions = win32.extname(command)
|
|
10
10
|
? [""]
|
|
11
|
-
: (variable(env, "PATHEXT") ?? ".EXE;.COM;.CMD;.BAT")
|
|
12
|
-
.split(";")
|
|
13
|
-
.filter((ext) => /^\.(?:exe|com|cmd|bat)$/i.test(ext));
|
|
14
|
-
// Relative/empty PATH entries would reintroduce the current-folder executable search.
|
|
11
|
+
: (variable(env, "PATHEXT") ?? ".EXE;.COM;.CMD;.BAT").split(";").filter((ext) => /^\.[a-z0-9]+$/i.test(ext));
|
|
15
12
|
for (const entry of (variable(env, "PATH") ?? "").split(";")) {
|
|
16
13
|
const directory = entry.replace(/^"(.*)"$/, "$1");
|
|
17
|
-
if (!win32.isAbsolute(directory))
|
|
18
|
-
continue;
|
|
19
14
|
for (const extension of extensions) {
|
|
20
15
|
const candidate = win32.join(directory, command + extension);
|
|
21
16
|
if (exists(candidate))
|
|
22
17
|
return candidate;
|
|
23
18
|
}
|
|
24
19
|
}
|
|
25
|
-
|
|
20
|
+
return command;
|
|
26
21
|
};
|
|
27
22
|
export const executableEnvironment = (env, platform = process.platform) => {
|
|
28
23
|
if (platform !== "win32")
|
|
29
24
|
return env;
|
|
30
25
|
const configured = variable(env, "COMSPEC");
|
|
31
26
|
const system = variable(env, "SYSTEMROOT");
|
|
32
|
-
const shell = configured
|
|
27
|
+
const shell = configured
|
|
33
28
|
? configured
|
|
34
29
|
: system && win32.isAbsolute(system)
|
|
35
30
|
? win32.join(system, "System32", "cmd.exe")
|
|
36
31
|
: undefined;
|
|
37
32
|
if (!shell)
|
|
38
|
-
|
|
33
|
+
return env;
|
|
39
34
|
const result = { ...env };
|
|
40
35
|
for (const key of Object.keys(result))
|
|
41
36
|
if (key.toUpperCase() === "COMSPEC")
|
package/dist/executable.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executable.js","sourceRoot":"","sources":["../src/executable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAEjC,MAAM,QAAQ,GAAG,CAAC,GAAsB,EAAE,IAAY,EAAE,EAAE,CACxD,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC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,GAAG,CAAA;IACtB,MAAM,MAAM,GAAG,EAAE,GAAG,GAAG,EAAE,CAAA;IACzB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IAC9F,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export { loadConfigFile, saveConfigFile, writeSecurely } from "./config.js";
|
|
2
2
|
export type { CredentialSource, CredentialStorage, CredentialsOptions, StoredCredential } from "./credentials.js";
|
|
3
3
|
export { CREDENTIAL_STORAGE, Credentials, keyringService } from "./credentials.js";
|
|
4
|
+
export { createDeadline, type Deadline, type DeadlineOptions } from "./deadline.js";
|
|
4
5
|
export { CliError, type CliErrorDetails, type ErrorCode, errorCodes, isCliError } from "./errors.js";
|
|
5
6
|
export { EXIT_CODES, exitCodeFor, GENERIC_FAILURE } from "./exit-codes.js";
|
|
6
7
|
export { brokenKeyring, type KeyringStore, memoryKeyring, systemKeyring } from "./keyring.js";
|
|
7
8
|
export { type Logger, noopLogger } from "./logger.js";
|
|
8
9
|
export { createFileLogger, type FileLogger, type FileLoggerOptions, REDACTED_FIELDS } from "./logging.js";
|
|
10
|
+
export { createOutputBuffer, type OutputBuffer, type OutputBufferOptions } from "./output-buffer.js";
|
|
9
11
|
export { configFilePath, type Paths, type PathsOptions, pathsAreOverridden, resolvePaths } from "./paths.js";
|
|
10
12
|
export { indent, type PrettyOptions, renderPretty } from "./pretty.js";
|
|
11
13
|
export { createRenderer, RENDER_FORMATS, type Renderer, type RendererOptions, type RenderFormat, } from "./renderer.js";
|
|
14
|
+
export { fieldsOf, projectFields } from "./result-fields.js";
|
|
12
15
|
export { backoffMs, DEFAULT_RETRY, isTransportFailure, type RetryConfig } from "./retry.js";
|
|
13
16
|
export { singleLine, visibleControls } from "./sanitize.js";
|
|
14
17
|
export { captureStreams, processStreams, type Streams } from "./streams.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3E,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACjH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC7F,OAAO,EAAE,KAAK,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,KAAK,iBAAiB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACzG,OAAO,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC5G,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EACL,cAAc,EACd,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SA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BAAkB,EAAE,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,KAAK,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC5G,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EACL,cAAc,EACd,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAA;AAC3F,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EACL,UAAU,EACV,KAAK,cAAc,EACnB,SAAS,EACT,SAAS,EACT,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,SAAS,GACV,MAAM,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
export { loadConfigFile, saveConfigFile, writeSecurely } from "./config.js";
|
|
2
2
|
export { CREDENTIAL_STORAGE, Credentials, keyringService } from "./credentials.js";
|
|
3
|
+
export { createDeadline } from "./deadline.js";
|
|
3
4
|
export { CliError, errorCodes, isCliError } from "./errors.js";
|
|
4
5
|
export { EXIT_CODES, exitCodeFor, GENERIC_FAILURE } from "./exit-codes.js";
|
|
5
6
|
export { brokenKeyring, memoryKeyring, systemKeyring } from "./keyring.js";
|
|
6
7
|
export { noopLogger } from "./logger.js";
|
|
7
8
|
export { createFileLogger, REDACTED_FIELDS } from "./logging.js";
|
|
9
|
+
export { createOutputBuffer } from "./output-buffer.js";
|
|
8
10
|
export { configFilePath, pathsAreOverridden, resolvePaths } from "./paths.js";
|
|
9
11
|
export { indent, renderPretty } from "./pretty.js";
|
|
10
12
|
export { createRenderer, RENDER_FORMATS, } from "./renderer.js";
|
|
13
|
+
export { fieldsOf, projectFields } from "./result-fields.js";
|
|
11
14
|
export { backoffMs, DEFAULT_RETRY, isTransportFailure } from "./retry.js";
|
|
12
15
|
export { singleLine, visibleControls } from "./sanitize.js";
|
|
13
16
|
export { captureStreams, processStreams } from "./streams.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3E,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAClF,OAAO,EAAE,QAAQ,EAAwC,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACpG,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,aAAa,EAAqB,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC7F,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAA2C,eAAe,EAAE,MAAM,cAAc,CAAA;AACzG,OAAO,EAAE,cAAc,EAAiC,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC5G,OAAO,EAAE,MAAM,EAAsB,YAAY,EAAE,MAAM,aAAa,CAAA;AACtE,OAAO,EACL,cAAc,EACd,cAAc,GAIf,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,kBAAkB,EAAoB,MAAM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AAE,UAAU,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAA;AAC3E,OAAO,EACL,UAAU,EAEV,SAAS,EACT,SAAS,EAIT,SAAS,GACV,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RenderFormat } from "./renderer.js";
|
|
2
|
+
export interface OutputBufferOptions {
|
|
3
|
+
maxOutputBytes?: number;
|
|
4
|
+
fields?: string;
|
|
5
|
+
format?: RenderFormat;
|
|
6
|
+
}
|
|
7
|
+
export interface OutputBuffer {
|
|
8
|
+
readonly bytes: number;
|
|
9
|
+
/** Raw output chunks, including any delimiters. Projection requires complete JSON values/JSONL lines. */
|
|
10
|
+
data(text: string): void;
|
|
11
|
+
/** Consumes the buffer once; the writer receives the exact buffered text, without extra newlines. */
|
|
12
|
+
flush(write: (text: string) => void): void;
|
|
13
|
+
discard(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare const createOutputBuffer: ({ maxOutputBytes, fields, format, }?: OutputBufferOptions) => OutputBuffer;
|
|
16
|
+
//# sourceMappingURL=output-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-buffer.d.ts","sourceRoot":"","sources":["../src/output-buffer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,YAAY,CAAA;CACtB;AACD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,yGAAyG;IACzG,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,qGAAqG;IACrG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAA;IAC1C,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,eAAO,MAAM,kBAAkB,yCAI5B,mBAAmB,KAAQ,YA6D7B,CAAA"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CliError } from "./errors.js";
|
|
2
|
+
import { fieldsOf, projectFields } from "./result-fields.js";
|
|
3
|
+
export const createOutputBuffer = ({ maxOutputBytes = 4 * 1024 * 1024, fields, format, } = {}) => {
|
|
4
|
+
if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 0)
|
|
5
|
+
throw new CliError("validation_error", "maxOutputBytes must be a nonnegative whole byte count");
|
|
6
|
+
const paths = fields === undefined ? undefined : fieldsOf(fields);
|
|
7
|
+
if (paths && format !== "json" && format !== "jsonl")
|
|
8
|
+
throw new CliError("validation_error", "field projection requires an explicit JSON or JSONL format");
|
|
9
|
+
let chunks = [];
|
|
10
|
+
let bytes = 0;
|
|
11
|
+
let finished = false;
|
|
12
|
+
const requireActive = () => {
|
|
13
|
+
if (finished)
|
|
14
|
+
throw new CliError("validation_error", "output buffer is already finished");
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
get bytes() {
|
|
18
|
+
return bytes;
|
|
19
|
+
},
|
|
20
|
+
data(text) {
|
|
21
|
+
requireActive();
|
|
22
|
+
let result = text;
|
|
23
|
+
if (paths) {
|
|
24
|
+
const project = (value) => JSON.stringify(projectFields(JSON.parse(value), paths));
|
|
25
|
+
try {
|
|
26
|
+
result =
|
|
27
|
+
format === "jsonl"
|
|
28
|
+
? text
|
|
29
|
+
.split("\n")
|
|
30
|
+
.map((line) => (line.trim() ? project(line) : line))
|
|
31
|
+
.join("\n")
|
|
32
|
+
: project(text) + (text.endsWith("\n") ? "\n" : "");
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof CliError)
|
|
36
|
+
throw error;
|
|
37
|
+
throw new CliError("invalid_response", "field projection requires complete JSON values or JSONL lines", {
|
|
38
|
+
reason: "projection_unavailable",
|
|
39
|
+
retryable: false,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const size = Buffer.byteLength(result);
|
|
44
|
+
if (!Number.isSafeInteger(bytes + size) || (maxOutputBytes !== 0 && bytes + size > maxOutputBytes))
|
|
45
|
+
throw new CliError("invalid_response", "output exceeds the configured byte limit", {
|
|
46
|
+
reason: "output_limit",
|
|
47
|
+
maxBytes: maxOutputBytes,
|
|
48
|
+
bufferedBytes: bytes,
|
|
49
|
+
retryable: false,
|
|
50
|
+
partialOutput: false,
|
|
51
|
+
});
|
|
52
|
+
bytes += size;
|
|
53
|
+
chunks.push(result);
|
|
54
|
+
},
|
|
55
|
+
flush(write) {
|
|
56
|
+
requireActive();
|
|
57
|
+
finished = true;
|
|
58
|
+
const output = chunks;
|
|
59
|
+
chunks = [];
|
|
60
|
+
for (const text of output)
|
|
61
|
+
write(text);
|
|
62
|
+
},
|
|
63
|
+
discard() {
|
|
64
|
+
finished = true;
|
|
65
|
+
chunks = [];
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=output-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-buffer.js","sourceRoot":"","sources":["../src/output-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAgB5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EAChC,MAAM,EACN,MAAM,GACP,GAAwB,EAAE,EAAgB,EAAE;IAC3C,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,cAAc,GAAG,CAAC;QAC7D,MAAM,IAAI,QAAQ,CAAC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: string) => string[];
|
|
2
|
+
/** Projects item data while retaining the list envelope and operation identifiers. */
|
|
3
|
+
export declare const projectFields: (value: unknown, fields: readonly string[]) => unknown;
|
|
4
|
+
//# sourceMappingURL=result-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-fields.d.ts","sourceRoot":"","sources":["../src/result-fields.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,QAAQ,UAAW,MAAM,KAAG,MAAM,EAI9C,CAAA;AA6BD,sFAAsF;AACtF,eAAO,MAAM,aAAa,UAAW,OAAO,UAAU,SAAS,MAAM,EAAE,KAAG,OAMzE,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CliError } from "./errors.js";
|
|
2
|
+
const forbidden = new Set(["__proto__", "prototype", "constructor"]);
|
|
3
|
+
const validate = (paths) => {
|
|
4
|
+
if (paths.length === 0 ||
|
|
5
|
+
paths.length > 128 ||
|
|
6
|
+
paths.some((path) => path.length > 256 ||
|
|
7
|
+
!/^[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*$/.test(path) ||
|
|
8
|
+
path.split(".").some((part) => forbidden.has(part))))
|
|
9
|
+
throw new CliError("validation_error", "--fields takes comma-separated field paths, for example id,locator,text");
|
|
10
|
+
};
|
|
11
|
+
export const fieldsOf = (value) => {
|
|
12
|
+
const paths = value.split(",").map((one) => one.trim());
|
|
13
|
+
validate(paths);
|
|
14
|
+
return [...new Set(paths)];
|
|
15
|
+
};
|
|
16
|
+
const object = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17
|
+
const select = (value, paths, item = false) => {
|
|
18
|
+
if (!object(value))
|
|
19
|
+
return value;
|
|
20
|
+
const fields = item ? paths.map((path) => (path.startsWith("items.") ? path.slice(6) : path)) : paths;
|
|
21
|
+
const result = {};
|
|
22
|
+
for (const path of fields.filter((one) => !fields.some((parent) => parent !== one && one.startsWith(`${parent}.`)))) {
|
|
23
|
+
const parts = path.split(".");
|
|
24
|
+
let found = value;
|
|
25
|
+
for (const part of parts) {
|
|
26
|
+
if (!object(found) || !Object.hasOwn(found, part)) {
|
|
27
|
+
found = undefined;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
found = found[part];
|
|
31
|
+
}
|
|
32
|
+
if (found === undefined)
|
|
33
|
+
continue;
|
|
34
|
+
let target = result;
|
|
35
|
+
for (const part of parts.slice(0, -1)) {
|
|
36
|
+
if (!object(target[part]))
|
|
37
|
+
target[part] = {};
|
|
38
|
+
target = target[part];
|
|
39
|
+
}
|
|
40
|
+
target[parts.at(-1)] = found;
|
|
41
|
+
}
|
|
42
|
+
for (const name of ["operationId", "sendId"])
|
|
43
|
+
if (Object.hasOwn(value, name))
|
|
44
|
+
result[name] = value[name];
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
/** Projects item data while retaining the list envelope and operation identifiers. */
|
|
48
|
+
export const projectFields = (value, fields) => {
|
|
49
|
+
validate(fields);
|
|
50
|
+
if (Array.isArray(value))
|
|
51
|
+
return value.map((item) => select(item, fields, true));
|
|
52
|
+
if (object(value) && Array.isArray(value.items))
|
|
53
|
+
return { ...value, items: value.items.map((item) => select(item, fields, true)) };
|
|
54
|
+
return select(value, fields, object(value) && !Object.hasOwn(value, "items"));
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=result-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-fields.js","sourceRoot":"","sources":["../src/result-fields.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC,CAAA;AACpE,MAAM,QAAQ,GAAG,CAAC,KAAwB,EAAQ,EAAE;IAClD,IACE,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,MAAM,GAAG,G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KAAK,EAAE,IAAI,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;IACxG,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAE,MAAyB,EAAW,EAAE;IAClF,QAAQ,CAAC,MAAM,CAAC,CAAA;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;IAChF,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;QAC7C,OAAO,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,EAAE,CAAA;IACnF,OAAO,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;AAC/E,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-core",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"description": "The parts every command line tool needs: output modes, terminal rendering, error model, exit codes, credentials, clocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|
|
@@ -87,7 +87,10 @@
|
|
|
87
87
|
"smoke:bun": "bun run scripts/smoke.ts",
|
|
88
88
|
"prepare": "lefthook install || true",
|
|
89
89
|
"secrets:scan": "gitleaks git --no-banner --redact .",
|
|
90
|
-
"prepublishOnly": "pnpm build"
|
|
90
|
+
"prepublishOnly": "pnpm build",
|
|
91
|
+
"standards:check": "node config/wirecat/check.mjs",
|
|
92
|
+
"docs:lint": "markdownlint-cli2",
|
|
93
|
+
"docs:spell": "cspell lint --config cspell.json --no-progress README.md"
|
|
91
94
|
},
|
|
92
95
|
"dependencies": {
|
|
93
96
|
"cli-table3": "^0.6.5",
|
|
@@ -101,14 +104,19 @@
|
|
|
101
104
|
"@napi-rs/keyring": "2.1.0"
|
|
102
105
|
},
|
|
103
106
|
"devDependencies": {
|
|
104
|
-
"@biomejs/biome": "
|
|
107
|
+
"@biomejs/biome": "2.5.15",
|
|
105
108
|
"@types/cross-spawn": "6.0.6",
|
|
106
109
|
"@types/node": "^22.20.4",
|
|
107
110
|
"@vitest/coverage-v8": "^5.0.2",
|
|
108
111
|
"commander": "^15.0.0",
|
|
109
|
-
"lefthook": "
|
|
112
|
+
"lefthook": "2.1.16",
|
|
110
113
|
"typescript": "^7.0.2",
|
|
111
|
-
"vitest": "^5.0.2"
|
|
114
|
+
"vitest": "^5.0.2",
|
|
115
|
+
"@cspell/dict-en-gb": "5.0.34",
|
|
116
|
+
"@cspell/dict-es-es": "3.0.9",
|
|
117
|
+
"@cspell/dict-ru_ru": "2.3.3",
|
|
118
|
+
"cspell": "10.3.6",
|
|
119
|
+
"markdownlint-cli2": "0.23.3"
|
|
112
120
|
},
|
|
113
121
|
"publishConfig": {
|
|
114
122
|
"access": "public"
|