@opensip-cli/contracts 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 +202 -0
- package/NOTICE +8 -0
- package/README.md +31 -0
- package/dist/__tests__/exit-codes.test.d.ts +2 -0
- package/dist/__tests__/exit-codes.test.d.ts.map +1 -0
- package/dist/__tests__/exit-codes.test.js +185 -0
- package/dist/__tests__/exit-codes.test.js.map +1 -0
- package/dist/__tests__/manifest-reexport.test.d.ts +6 -0
- package/dist/__tests__/manifest-reexport.test.d.ts.map +1 -0
- package/dist/__tests__/manifest-reexport.test.js +38 -0
- package/dist/__tests__/manifest-reexport.test.js.map +1 -0
- package/dist/__tests__/types-only.test.d.ts +10 -0
- package/dist/__tests__/types-only.test.d.ts.map +1 -0
- package/dist/__tests__/types-only.test.js +49 -0
- package/dist/__tests__/types-only.test.js.map +1 -0
- package/dist/cli-flags.d.ts +56 -0
- package/dist/cli-flags.d.ts.map +1 -0
- package/dist/cli-flags.js +85 -0
- package/dist/cli-flags.js.map +1 -0
- package/dist/cli-flags.test.d.ts +2 -0
- package/dist/cli-flags.test.d.ts.map +1 -0
- package/dist/cli-flags.test.js +51 -0
- package/dist/cli-flags.test.js.map +1 -0
- package/dist/command-outcome.d.ts +87 -0
- package/dist/command-outcome.d.ts.map +1 -0
- package/dist/command-outcome.js +32 -0
- package/dist/command-outcome.js.map +1 -0
- package/dist/command-outcome.test.d.ts +10 -0
- package/dist/command-outcome.test.d.ts.map +1 -0
- package/dist/command-outcome.test.js +68 -0
- package/dist/command-outcome.test.js.map +1 -0
- package/dist/command-results.d.ts +501 -0
- package/dist/command-results.d.ts.map +1 -0
- package/dist/command-results.js +14 -0
- package/dist/command-results.js.map +1 -0
- package/dist/exit-codes.d.ts +44 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +186 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/graph-catalog.d.ts +143 -0
- package/dist/graph-catalog.d.ts.map +1 -0
- package/dist/graph-catalog.js +13 -0
- package/dist/graph-catalog.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/recipe-default.d.ts +53 -0
- package/dist/recipe-default.d.ts.map +1 -0
- package/dist/recipe-default.js +55 -0
- package/dist/recipe-default.js.map +1 -0
- package/dist/recipe-default.test.d.ts +2 -0
- package/dist/recipe-default.test.d.ts.map +1 -0
- package/dist/recipe-default.test.js +32 -0
- package/dist/recipe-default.test.js.map +1 -0
- package/dist/score.d.ts +26 -0
- package/dist/score.d.ts.map +1 -0
- package/dist/score.js +25 -0
- package/dist/score.js.map +1 -0
- package/dist/score.test.d.ts +2 -0
- package/dist/score.test.d.ts.map +1 -0
- package/dist/score.test.js +22 -0
- package/dist/score.test.js.map +1 -0
- package/dist/session-types.d.ts +132 -0
- package/dist/session-types.d.ts.map +1 -0
- package/dist/session-types.js +11 -0
- package/dist/session-types.js.map +1 -0
- package/dist/signal-envelope.d.ts +118 -0
- package/dist/signal-envelope.d.ts.map +1 -0
- package/dist/signal-envelope.js +84 -0
- package/dist/signal-envelope.js.map +1 -0
- package/dist/signal-envelope.test.d.ts +2 -0
- package/dist/signal-envelope.test.d.ts.map +1 -0
- package/dist/signal-envelope.test.js +168 -0
- package/dist/signal-envelope.test.js.map +1 -0
- package/dist/types.d.ts +78 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/verbose-detail.d.ts +26 -0
- package/dist/verbose-detail.d.ts.map +1 -0
- package/dist/verbose-detail.js +75 -0
- package/dist/verbose-detail.js.map +1 -0
- package/dist/verbose-detail.test.d.ts +2 -0
- package/dist/verbose-detail.test.d.ts.map +1 -0
- package/dist/verbose-detail.test.js +53 -0
- package/dist/verbose-detail.test.js.map +1 -0
- package/dist/verdict-envelope.test.d.ts +8 -0
- package/dist/verdict-envelope.test.d.ts.map +1 -0
- package/dist/verdict-envelope.test.js +67 -0
- package/dist/verdict-envelope.test.js.map +1 -0
- package/package.json +56 -0
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
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
OpenSIP CLI
|
|
2
|
+
Copyright 2026 opensip-ai
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this software except in compliance with the License. A copy of the License is
|
|
6
|
+
included in the LICENSE file and is also available at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- Generated by scripts/build-package-readmes.mjs — do not edit by hand.
|
|
2
|
+
Change the package's "description" (or the generator template) and run
|
|
3
|
+
`pnpm docs:readmes`. CI enforces sync via `pnpm docs:readmes:check`. -->
|
|
4
|
+
|
|
5
|
+
# @opensip-cli/contracts
|
|
6
|
+
|
|
7
|
+
> Shared contract types for OpenSIP CLI — SignalEnvelope / CommandResult shapes, exit codes, session persistence
|
|
8
|
+
|
|
9
|
+
This is an **internal library** of the opensip-cli toolkit. It is published so the CLI and tools can depend on it; most users will not install it directly.
|
|
10
|
+
|
|
11
|
+
Part of [**opensip-cli**](https://github.com/opensip-ai/opensip-cli) — an open-source codebase-analysis toolkit: fitness checks (`fit`), static call-graph analysis (`graph`), and simulation (`sim`).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Most users install the CLI, which bundles the first-party tools:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
curl -fsSL https://opensip.ai/cli/install.sh | bash
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This package is published for the CLI and advanced plugin authors; most users should not install `@opensip-cli/contracts` directly.
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
- 📚 Project docs: https://opensip.ai/docs/opensip-cli/
|
|
26
|
+
- 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.0/docs/public/70-reference/02-package-catalog.md
|
|
27
|
+
- 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.0/packages/contracts
|
|
28
|
+
|
|
29
|
+
## License
|
|
30
|
+
|
|
31
|
+
Apache-2.0 © opensip-ai
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/exit-codes.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { ConfigurationError, NetworkError, NotFoundError, PluginIncompatibleError, SystemError, TimeoutError, ToolError, ValidationError, } from '@opensip-cli/core';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { EXIT_CODES, getErrorSuggestion, mapToolErrorToExitCode, } from '../exit-codes.js';
|
|
4
|
+
describe('EXIT_CODES', () => {
|
|
5
|
+
it('exposes the documented set', () => {
|
|
6
|
+
expect(EXIT_CODES).toEqual({
|
|
7
|
+
SUCCESS: 0,
|
|
8
|
+
RUNTIME_ERROR: 1,
|
|
9
|
+
CONFIGURATION_ERROR: 2,
|
|
10
|
+
CHECK_NOT_FOUND: 3,
|
|
11
|
+
REPORT_FAILED: 4,
|
|
12
|
+
PLUGIN_INCOMPATIBLE: 5,
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
it('gives PLUGIN_INCOMPATIBLE a dedicated, non-colliding value', () => {
|
|
16
|
+
expect(EXIT_CODES.PLUGIN_INCOMPATIBLE).toBe(5);
|
|
17
|
+
const values = Object.values(EXIT_CODES);
|
|
18
|
+
expect(new Set(values).size).toBe(values.length);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe('getErrorSuggestion', () => {
|
|
22
|
+
it('returns null when no pattern matches', () => {
|
|
23
|
+
expect(getErrorSuggestion(new Error('something else entirely'))).toBeNull();
|
|
24
|
+
});
|
|
25
|
+
it('handles non-Error inputs', () => {
|
|
26
|
+
expect(getErrorSuggestion('just a string')).toBeNull();
|
|
27
|
+
expect(getErrorSuggestion(undefined)).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
const RULE_CASES = [
|
|
30
|
+
{
|
|
31
|
+
name: 'check-not-found rule fires for "Check not found: <slug>"',
|
|
32
|
+
input: 'Check not found: foo-check',
|
|
33
|
+
expect: { exitCode: EXIT_CODES.CHECK_NOT_FOUND, messageContains: 'foo-check' },
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
// The fitness engine throws `Recipe not found: <id>` (recipes/service.ts);
|
|
37
|
+
// this must route to CONFIGURATION_ERROR (the recipe name is wrong in
|
|
38
|
+
// config) and not CHECK_NOT_FOUND. The recipe-not-found rule sits
|
|
39
|
+
// ahead of the check-not-found rule precisely for this case.
|
|
40
|
+
name: 'recipe-not-found rule fires for "Recipe not found: <slug>"',
|
|
41
|
+
input: 'Recipe not found: my-recipe',
|
|
42
|
+
expect: { exitCode: EXIT_CODES.CONFIGURATION_ERROR, messageContains: 'my-recipe' },
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
// The `Recipe not found:` substring with no extractable slug — the
|
|
46
|
+
// /Recipe not found: (.+)/ regex fails (nothing after the colon) but the
|
|
47
|
+
// substring fallback still classifies it as a recipe error and the
|
|
48
|
+
// suggest builder substitutes "unknown".
|
|
49
|
+
name: 'recipe-not-found rule falls back to "unknown" when slug missing',
|
|
50
|
+
input: 'Recipe not found:',
|
|
51
|
+
expect: { exitCode: EXIT_CODES.CONFIGURATION_ERROR, messageContains: 'unknown' },
|
|
52
|
+
},
|
|
53
|
+
// NOTE (audit fix): the previous broad "not found: <slug>" / bare "not found"
|
|
54
|
+
// cases were removed from the string suggestion table. They routed too many
|
|
55
|
+
// unrelated "not found" messages to CHECK_NOT_FOUND (3). Generic not-found
|
|
56
|
+
// phrasing now yields no suggestion from getErrorSuggestion (falls to null);
|
|
57
|
+
// the correct exit for real check-not-found is still provided by the typed
|
|
58
|
+
// NotFoundError path in mapToolErrorToExitCode.
|
|
59
|
+
{
|
|
60
|
+
name: 'unknown-recipe rule fires for "Unknown recipe ..."',
|
|
61
|
+
input: 'Unknown recipe foo',
|
|
62
|
+
expect: { exitCode: EXIT_CODES.CONFIGURATION_ERROR, actionContains: '--recipes' },
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'config-file rule fires for opensip-cli.config.yml errors',
|
|
66
|
+
input: 'Failed to parse opensip-cli.config.yml',
|
|
67
|
+
expect: { exitCode: EXIT_CODES.CONFIGURATION_ERROR },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'yaml-parse rule fires for YAML errors',
|
|
71
|
+
input: 'Bad YAML at line 3',
|
|
72
|
+
expect: { exitCode: EXIT_CODES.CONFIGURATION_ERROR },
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'permission rule fires for EACCES',
|
|
76
|
+
input: 'EACCES: permission denied reading /etc',
|
|
77
|
+
expect: { exitCode: EXIT_CODES.RUNTIME_ERROR, actionContains: 'permissions' },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'no-checks rule fires for "No checks registered"',
|
|
81
|
+
input: 'No checks registered',
|
|
82
|
+
expect: { exitCode: EXIT_CODES.RUNTIME_ERROR, actionContains: 'checks-*' },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'no-checks rule fires for "No checks to run"',
|
|
86
|
+
input: 'No checks to run',
|
|
87
|
+
expect: { exitCode: EXIT_CODES.RUNTIME_ERROR },
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'network rule fires for fetch errors',
|
|
91
|
+
input: 'fetch failed',
|
|
92
|
+
expect: { exitCode: EXIT_CODES.REPORT_FAILED },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'network rule fires for ECONNREFUSED',
|
|
96
|
+
input: 'ECONNREFUSED',
|
|
97
|
+
expect: { exitCode: EXIT_CODES.REPORT_FAILED },
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'network rule fires for generic network errors',
|
|
101
|
+
input: 'network unreachable',
|
|
102
|
+
expect: { exitCode: EXIT_CODES.REPORT_FAILED },
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
for (const c of RULE_CASES) {
|
|
106
|
+
it(c.name, () => {
|
|
107
|
+
const out = getErrorSuggestion(new Error(c.input));
|
|
108
|
+
expect(out).not.toBeNull();
|
|
109
|
+
expect(out?.exitCode).toBe(c.expect.exitCode);
|
|
110
|
+
if (c.expect.messageContains !== undefined) {
|
|
111
|
+
expect(out?.message).toContain(c.expect.messageContains);
|
|
112
|
+
}
|
|
113
|
+
if (c.expect.actionContains !== undefined) {
|
|
114
|
+
expect(out?.action).toContain(c.expect.actionContains);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// ---- False-positive narrowing of the old broad 'config' substring ----
|
|
119
|
+
//
|
|
120
|
+
// The previous implementation treated any message containing the
|
|
121
|
+
// literal substring 'config' as a configuration error. That matched
|
|
122
|
+
// common English words like 'configurable', 'reconfigure', and bare
|
|
123
|
+
// 'config invalid'. Phase 1 narrows this into two explicit rules
|
|
124
|
+
// (opensip-cli.config.yml + YAML); inputs that previously matched
|
|
125
|
+
// by accident now fall through to the default null.
|
|
126
|
+
const NARROWED_FALSE_POSITIVES = [
|
|
127
|
+
'config invalid',
|
|
128
|
+
'this option is configurable',
|
|
129
|
+
'reconfigure the engine',
|
|
130
|
+
'unable to reconfig the runtime',
|
|
131
|
+
];
|
|
132
|
+
for (const input of NARROWED_FALSE_POSITIVES) {
|
|
133
|
+
it(`narrowed: bare 'config' substring no longer matches: "${input}"`, () => {
|
|
134
|
+
expect(getErrorSuggestion(new Error(input))).toBeNull();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
// ---- First-match-wins: rule order is load-bearing ----
|
|
138
|
+
it('first-match-wins: "Check not found" beats "YAML" if both substrings present', () => {
|
|
139
|
+
// Constructed so it would match both the check-not-found rule and
|
|
140
|
+
// the YAML rule; the table walks top-down, so the check-not-found
|
|
141
|
+
// arm wins.
|
|
142
|
+
const out = getErrorSuggestion(new Error('Check not found: foo-check (parsing YAML)'));
|
|
143
|
+
expect(out?.exitCode).toBe(EXIT_CODES.CHECK_NOT_FOUND);
|
|
144
|
+
});
|
|
145
|
+
// ---- Regression / behavior parity sanity checks ----
|
|
146
|
+
it('default fall-through returns null', () => {
|
|
147
|
+
expect(getErrorSuggestion(new Error('totally unrelated message'))).toBeNull();
|
|
148
|
+
});
|
|
149
|
+
it('preserves the unknown-recipe message verbatim', () => {
|
|
150
|
+
const out = getErrorSuggestion(new Error('Unknown recipe foo'));
|
|
151
|
+
expect(out?.message).toBe('Unknown recipe foo');
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
describe('mapToolErrorToExitCode (Tool error contract — audit-round-2 Finding C)', () => {
|
|
155
|
+
it('NotFoundError → CHECK_NOT_FOUND', () => {
|
|
156
|
+
expect(mapToolErrorToExitCode(new NotFoundError('missing'))).toBe(EXIT_CODES.CHECK_NOT_FOUND);
|
|
157
|
+
});
|
|
158
|
+
it('ConfigurationError → CONFIGURATION_ERROR', () => {
|
|
159
|
+
expect(mapToolErrorToExitCode(new ConfigurationError('bad config'))).toBe(EXIT_CODES.CONFIGURATION_ERROR);
|
|
160
|
+
});
|
|
161
|
+
it('ValidationError → CONFIGURATION_ERROR', () => {
|
|
162
|
+
expect(mapToolErrorToExitCode(new ValidationError('bad input'))).toBe(EXIT_CODES.CONFIGURATION_ERROR);
|
|
163
|
+
});
|
|
164
|
+
it('NetworkError → REPORT_FAILED', () => {
|
|
165
|
+
expect(mapToolErrorToExitCode(new NetworkError('connection refused'))).toBe(EXIT_CODES.REPORT_FAILED);
|
|
166
|
+
});
|
|
167
|
+
it('PluginIncompatibleError → PLUGIN_INCOMPATIBLE (release 2.8.0 fail-closed)', () => {
|
|
168
|
+
expect(mapToolErrorToExitCode(new PluginIncompatibleError('tool x is incompatible', { diagnostic: 'epoch mismatch' }))).toBe(EXIT_CODES.PLUGIN_INCOMPATIBLE);
|
|
169
|
+
});
|
|
170
|
+
it('TimeoutError → RUNTIME_ERROR', () => {
|
|
171
|
+
expect(mapToolErrorToExitCode(new TimeoutError('took too long'))).toBe(EXIT_CODES.RUNTIME_ERROR);
|
|
172
|
+
});
|
|
173
|
+
it('SystemError → RUNTIME_ERROR', () => {
|
|
174
|
+
expect(mapToolErrorToExitCode(new SystemError('boom'))).toBe(EXIT_CODES.RUNTIME_ERROR);
|
|
175
|
+
});
|
|
176
|
+
it('bare ToolError → RUNTIME_ERROR (fallback)', () => {
|
|
177
|
+
expect(mapToolErrorToExitCode(new ToolError('opaque', 'WHATEVER'))).toBe(EXIT_CODES.RUNTIME_ERROR);
|
|
178
|
+
});
|
|
179
|
+
it('user-defined ToolError subclass routes by its nearest mapped ancestor', () => {
|
|
180
|
+
class GatePolicyError extends ConfigurationError {
|
|
181
|
+
}
|
|
182
|
+
expect(mapToolErrorToExitCode(new GatePolicyError('policy violated'))).toBe(EXIT_CODES.CONFIGURATION_ERROR);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
//# sourceMappingURL=exit-codes.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exit-codes.test.js","sourceRoot":"","sources":["../../src/__tests__/exit-codes.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EA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I,uBAAuB,CAAC,wBAAwB,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC,CACxF,CACF,CAAC,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,sBAAsB,CAAC,IAAI,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CACpE,UAAU,CAAC,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,sBAAsB,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,CAAC,sBAAsB,CAAC,IAAI,SAAS,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CACtE,UAAU,CAAC,aAAa,CACzB,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,MAAM,eAAgB,SAAQ,kBAAkB;SAAG;QACnD,MAAM,CAAC,sBAAsB,CAAC,IAAI,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CACzE,UAAU,CAAC,mBAAmB,CAC/B,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-reexport.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/manifest-reexport.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifies the release-2.8.0 manifest/epoch/compatibility surface is
|
|
3
|
+
* re-exported from the contracts barrel (defined in @opensip-cli/core).
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, it } from 'vitest';
|
|
6
|
+
import { PLUGIN_API_VERSION, checkCompatibility, } from '../index.js';
|
|
7
|
+
describe('contracts manifest re-export', () => {
|
|
8
|
+
it('re-exports the epoch + compatibility gate as runtime values', () => {
|
|
9
|
+
expect(PLUGIN_API_VERSION).toBe(1);
|
|
10
|
+
// 3.0.0: a missing apiVersion is incompatible (the grace window ended).
|
|
11
|
+
expect(checkCompatibility(undefined).kind).toBe('incompatible');
|
|
12
|
+
expect(checkCompatibility(PLUGIN_API_VERSION)).toEqual({ kind: 'compatible' });
|
|
13
|
+
expect(checkCompatibility(PLUGIN_API_VERSION + 1).kind).toBe('incompatible');
|
|
14
|
+
});
|
|
15
|
+
it('re-exports the manifest/provenance types (compile-time shape check)', () => {
|
|
16
|
+
const command = { name: 'fit', description: 'Run fitness checks' };
|
|
17
|
+
const manifest = {
|
|
18
|
+
kind: 'tool',
|
|
19
|
+
id: 'fitness',
|
|
20
|
+
name: 'Fitness',
|
|
21
|
+
version: '2.8.0',
|
|
22
|
+
apiVersion: PLUGIN_API_VERSION,
|
|
23
|
+
commands: [command],
|
|
24
|
+
};
|
|
25
|
+
const source = 'bundled';
|
|
26
|
+
const provenance = {
|
|
27
|
+
source,
|
|
28
|
+
id: manifest.id,
|
|
29
|
+
version: manifest.version,
|
|
30
|
+
manifestHash: 'deadbeef',
|
|
31
|
+
};
|
|
32
|
+
const verdict = checkCompatibility(manifest.apiVersion);
|
|
33
|
+
expect(manifest.commands[0]?.name).toBe('fit');
|
|
34
|
+
expect(provenance.source).toBe('bundled');
|
|
35
|
+
expect(verdict.kind).toBe('compatible');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=manifest-reexport.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest-reexport.test.js","sourceRoot":"","sources":["../../src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F,MAAM,OAAO,GAAyB,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAE9E,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural guard: @opensip-cli/contracts is TYPES-ONLY again (2.10.1,
|
|
3
|
+
* ADR-0023). The `cli:` block loader (`loadCliDefaults`) — a runtime YAML
|
|
4
|
+
* projection — moved to @opensip-cli/config, restoring the charter the
|
|
5
|
+
* package's own docs assert. This test fails if any contracts source reintroduces
|
|
6
|
+
* config-document parsing (a `readYamlFile(...)` / `resolveProjectConfigPath(...)`
|
|
7
|
+
* call), complementing the `no-config-loader-outside-config` fitness guardrail.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=types-only.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-only.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/types-only.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural guard: @opensip-cli/contracts is TYPES-ONLY again (2.10.1,
|
|
3
|
+
* ADR-0023). The `cli:` block loader (`loadCliDefaults`) — a runtime YAML
|
|
4
|
+
* projection — moved to @opensip-cli/config, restoring the charter the
|
|
5
|
+
* package's own docs assert. This test fails if any contracts source reintroduces
|
|
6
|
+
* config-document parsing (a `readYamlFile(...)` / `resolveProjectConfigPath(...)`
|
|
7
|
+
* call), complementing the `no-config-loader-outside-config` fitness guardrail.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync, readdirSync } from 'node:fs';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { describe, it, expect } from 'vitest';
|
|
13
|
+
const SRC = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
14
|
+
/** Recursively collect .ts source files under contracts/src, excluding tests. */
|
|
15
|
+
function sourceFiles(dir) {
|
|
16
|
+
const out = [];
|
|
17
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
18
|
+
if (entry.name === '__tests__' || entry.name === 'dist')
|
|
19
|
+
continue;
|
|
20
|
+
const full = join(dir, entry.name);
|
|
21
|
+
if (entry.isDirectory())
|
|
22
|
+
out.push(...sourceFiles(full));
|
|
23
|
+
else if (entry.name.endsWith('.ts') && !entry.name.endsWith('.test.ts'))
|
|
24
|
+
out.push(full);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
describe('@opensip-cli/contracts is types-only', () => {
|
|
29
|
+
const files = sourceFiles(SRC);
|
|
30
|
+
it('discovers source files (sanity)', () => {
|
|
31
|
+
expect(files.length).toBeGreaterThan(0);
|
|
32
|
+
});
|
|
33
|
+
it('contains no YAML→config projection call (readYamlFile / resolveProjectConfigPath)', () => {
|
|
34
|
+
const offenders = [];
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
const content = readFileSync(file, 'utf8');
|
|
37
|
+
// Match a CALL (identifier followed by `(`), not a mention in prose/strings.
|
|
38
|
+
if (/\breadYamlFile(?:OrThrow)?\s*\(/.test(content) ||
|
|
39
|
+
/\bresolveProjectConfigPath\s*\(/.test(content)) {
|
|
40
|
+
offenders.push(file.slice(SRC.length + 1));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
expect(offenders, `contracts must not parse config: ${offenders.join(', ')}`).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
it('no longer ships a cli-config module', () => {
|
|
46
|
+
expect(files.some((f) => f.endsWith('cli-config.ts'))).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=types-only.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-only.test.js","sourceRoot":"","sources":["../../src/__tests__/types-only.test.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAEhE,iFAAiF;AACjF,SAAS,WAAW,CAAC,GAAW;IAC9B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,KAAK,IAAI,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9D,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,SAAS;QAClE,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,WAAW,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;aACnD,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,C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
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-tool CLI flag currency (ADR-0021).
|
|
3
|
+
*
|
|
4
|
+
* The single source of truth for the common flags every tool's run command
|
|
5
|
+
* shares (`--json`, `--cwd`, `--quiet`, `--verbose`, `--debug`,
|
|
6
|
+
* `--report-to`/`--api-key`, `--open`). Each tool builds its command with
|
|
7
|
+
* `applyCommonFlags(...)` for the shared flags and adds only its
|
|
8
|
+
* genuinely tool-specific options by hand — so a flag's text/short-alias/default
|
|
9
|
+
* is declared once and cannot drift (it already had: `--report-to` read three
|
|
10
|
+
* different ways across the three tools before this registry).
|
|
11
|
+
*
|
|
12
|
+
* `commander` is referenced ONLY as a type (`import type`), matching the rest of
|
|
13
|
+
* contracts: `applyCommonFlags` calls `.option(...)` on a `Command` instance the
|
|
14
|
+
* caller passes in, so no runtime `commander` require lands in `dist`. The
|
|
15
|
+
* package keeps `commander` as an optional peer dependency (see index.ts).
|
|
16
|
+
*/
|
|
17
|
+
import type { CommonFlagKey } from '@opensip-cli/core';
|
|
18
|
+
import type { Command } from 'commander';
|
|
19
|
+
export type { CommonFlagKey } from '@opensip-cli/core';
|
|
20
|
+
/** Canonical declaration of one common flag. */
|
|
21
|
+
export interface CommonFlagSpec {
|
|
22
|
+
/** Commander flag string, including the short alias where canonical (`-v, --verbose`). */
|
|
23
|
+
readonly flags: string;
|
|
24
|
+
/** Canonical description — the one source of truth for this flag's help text. */
|
|
25
|
+
readonly description: string;
|
|
26
|
+
/**
|
|
27
|
+
* Literal default applied via `.option(flags, description, default)`. Omitted
|
|
28
|
+
* for value flags whose default is computed per-invocation (e.g. `cwd`'s
|
|
29
|
+
* `process.cwd()`), which callers supply through `applyCommonFlags`'s
|
|
30
|
+
* `overrides` argument.
|
|
31
|
+
*/
|
|
32
|
+
readonly defaultValue?: string | boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The canonical common-flag registry. Adding a tool means calling
|
|
36
|
+
* {@link applyCommonFlags} with the relevant keys — never re-declaring a flag.
|
|
37
|
+
*/
|
|
38
|
+
export declare const commonFlags: Readonly<Record<CommonFlagKey, CommonFlagSpec>>;
|
|
39
|
+
/**
|
|
40
|
+
* Apply the given common flags to a Commander command in registry order.
|
|
41
|
+
*
|
|
42
|
+
* `overrides` supplies per-invocation defaults for flags whose default is not a
|
|
43
|
+
* literal — notably `cwd`, where callers pass `{ cwd: process.cwd() }`. An
|
|
44
|
+
* override also wins over a spec's `defaultValue` when both are present.
|
|
45
|
+
*
|
|
46
|
+
* Returns the same `command` for chaining. No runtime `commander` dependency is
|
|
47
|
+
* introduced — only methods on the passed-in instance are called.
|
|
48
|
+
*/
|
|
49
|
+
export declare function applyCommonFlags(command: Command, keys: readonly CommonFlagKey[], overrides?: Partial<Record<CommonFlagKey, string | boolean>>): Command;
|
|
50
|
+
/**
|
|
51
|
+
* The flags every tool's run command MUST declare (the parity set enforced by
|
|
52
|
+
* the `cross-tool-flag-parity` fitness check, ADR-0021). `open` is intentionally
|
|
53
|
+
* NOT mandatory — only report-producing tools expose it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const MANDATORY_COMMON_FLAGS: readonly CommonFlagKey[];
|
|
56
|
+
//# sourceMappingURL=cli-flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-flags.d.ts","sourceRoot":"","sources":["../src/cli-flags.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,gDAAgD;AAChD,MAAM,WAAW,cAAc;IAC7B,0FAA0F;IAC1F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CA4B9D,CAAC;AAEX;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,SAAS,aAAa,EAAE,EAC9B,SAAS,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAC3D,OAAO,CAQT;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,aAAa,EAQjD,CAAC"}
|