@cogitato/kit-cli 0.0.0-stage → 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/README.md +34 -2
- package/bin/kit.js +4 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +204 -0
- package/dist/cli.js.map +1 -0
- package/dist/doctor.d.ts +19 -0
- package/dist/doctor.js +72 -0
- package/dist/doctor.js.map +1 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/export-flows.d.ts +8 -0
- package/dist/export-flows.js +15 -0
- package/dist/export-flows.js.map +1 -0
- package/dist/flows.d.ts +38 -0
- package/dist/flows.js +141 -0
- package/dist/flows.js.map +1 -0
- package/dist/format.d.ts +3 -0
- package/dist/format.js +27 -0
- package/dist/format.js.map +1 -0
- package/dist/gaps.d.ts +21 -0
- package/dist/gaps.js +52 -0
- package/dist/gaps.js.map +1 -0
- package/dist/hook.d.ts +33 -0
- package/dist/hook.js +78 -0
- package/dist/hook.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/issue.d.ts +17 -0
- package/dist/issue.js +65 -0
- package/dist/issue.js.map +1 -0
- package/dist/links.d.ts +16 -0
- package/dist/links.js +61 -0
- package/dist/links.js.map +1 -0
- package/dist/preview.d.ts +16 -0
- package/dist/preview.js +38 -0
- package/dist/preview.js.map +1 -0
- package/dist/project.d.ts +35 -0
- package/dist/project.js +88 -0
- package/dist/project.js.map +1 -0
- package/dist/registry.d.ts +67 -0
- package/dist/registry.js +224 -0
- package/dist/registry.js.map +1 -0
- package/dist/rules/css-values.d.ts +31 -0
- package/dist/rules/css-values.js +185 -0
- package/dist/rules/css-values.js.map +1 -0
- package/dist/rules/css.d.ts +4 -0
- package/dist/rules/css.js +39 -0
- package/dist/rules/css.js.map +1 -0
- package/dist/rules/tsx.d.ts +24 -0
- package/dist/rules/tsx.js +190 -0
- package/dist/rules/tsx.js.map +1 -0
- package/dist/save.d.ts +27 -0
- package/dist/save.js +125 -0
- package/dist/save.js.map +1 -0
- package/dist/scaffold.d.ts +42 -0
- package/dist/scaffold.js +230 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/snapshots.d.ts +23 -0
- package/dist/snapshots.js +126 -0
- package/dist/snapshots.js.map +1 -0
- package/dist/status.d.ts +14 -0
- package/dist/status.js +38 -0
- package/dist/status.js.map +1 -0
- package/dist/validate.d.ts +14 -0
- package/dist/validate.js +64 -0
- package/dist/validate.js.map +1 -0
- package/package.json +48 -3
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/README.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cogitato/kit-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `kit` command: the deterministic engine behind Cogitato. Hooks, skills and the MCP server call into it ([02-kit-cli.md](../../docs/architecture/components/02-kit-cli.md)).
|
|
4
|
+
|
|
5
|
+
Run it anywhere inside a prototype; it finds the folder holding `design/contract`.
|
|
6
|
+
|
|
7
|
+
| Command | What it does |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `kit validate [--contract] [--files a.tsx b.css] [--json]` | Contract, code and flows against the design contract. `--files` is the fast path for edit hooks. |
|
|
10
|
+
| `kit export-flows [--check] [--json]` | Writes `design/flows.json` from `src/screens/**/screen.tsx` and `src/flows.ts`, read statically. `--check` only reports whether the file is current. |
|
|
11
|
+
| `kit preview [--port n] [--no-open]` | Starts the prototype if it isn't running, then opens `/__kit`. |
|
|
12
|
+
| `kit doctor [--json] [--quiet]` | Node, pnpm, installed parts, contract, flows, dev server, `.env`. `--quiet` prints problems only. |
|
|
13
|
+
| `kit new-screen <id> [--title] [--route] [--from <step>] [--label]` | Creates `src/screens/<id>/screen.tsx` with a default state; `--from` adds an arrow to it. |
|
|
14
|
+
| `kit add-state <screen> <state> [--title] [--from <step>] [--label]` | Adds a state to a screen. |
|
|
15
|
+
| `kit add-edge <from> <to> [--label] [--flow]` | Connects two states in `src/flows.ts`. |
|
|
16
|
+
| `kit gap add --kind --name --context [--screen] [--workaround]` | Records a missing component, token or pattern in `gaps.json`. |
|
|
17
|
+
| `kit link <step> [--canvas]` | Local address of a state, or of its frame on the canvas. |
|
|
18
|
+
| `kit status <step> <status>` | Sets a state's review status (`exploring`, `in-review`, `approved`, `handed-off`) in `flows.json`. |
|
|
19
|
+
| `kit snapshots [--dist dist]` | Screenshots every state of the built prototype for the canvas. Best effort: needs Playwright and Chromium, and otherwise skips. |
|
|
20
|
+
| `kit save [--message]` | Saves a version: commit on a design branch, then push if there's a remote. |
|
|
21
|
+
| `kit hook <post-edit\|session-start>` | Claude Code hook (JSON on stdin), used by the plugin. |
|
|
22
|
+
|
|
23
|
+
Exit codes: 0 all good, 1 problems found (or a request kit refused, with a plain explanation), 2 couldn't run. Scaffolding edits files in place through the TypeScript parser and keeps their formatting ([ADR 011](../../docs/decisions/011-scaffolding-and-saving.md)). `--json` prints a `ValidationReport` (`@cogitato/contract`'s `report.schema.json`).
|
|
24
|
+
|
|
25
|
+
The rules and their codes are listed in [ADR 008](../../docs/decisions/008-token-css-and-validation-report.md). Every message is written for a designer, with a machine `suggestion` where there's an obvious fix.
|
|
26
|
+
|
|
27
|
+
## Library
|
|
28
|
+
```ts
|
|
29
|
+
import { findProject, validate, exportFlows } from "@cogitato/kit-cli";
|
|
30
|
+
const project = findProject()!;
|
|
31
|
+
const { ok, issues } = validate(project, { files: ["src/screens/cart/screen.tsx"] });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Tests
|
|
35
|
+
`pnpm test` runs the rule unit tests, plus the template checks: it validates clean, its exported flows match the Phase 0 reference, and single-file validation is fast. It also runs the seeded bad prototypes in `test/fixtures/bad/`. Each is a set of edits to a temp copy of the template plus the codes they must produce, and message wording is snapshotted.
|
package/bin/kit.js
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import mri from "mri";
|
|
2
|
+
import { toReport } from "@cogitato/contract";
|
|
3
|
+
import { doctor, formatDoctor } from "./doctor.js";
|
|
4
|
+
import { exportFlows } from "./export-flows.js";
|
|
5
|
+
import { KitError } from "./errors.js";
|
|
6
|
+
import { formatResult } from "./format.js";
|
|
7
|
+
import { addGap } from "./gaps.js";
|
|
8
|
+
import { runHook } from "./hook.js";
|
|
9
|
+
import { canvasLink, stateLink } from "./links.js";
|
|
10
|
+
import { preview } from "./preview.js";
|
|
11
|
+
import { findProject } from "./project.js";
|
|
12
|
+
import { saveVersion } from "./save.js";
|
|
13
|
+
import { addEdge, addState, createScreen } from "./scaffold.js";
|
|
14
|
+
import { takeSnapshots } from "./snapshots.js";
|
|
15
|
+
import { FRAME_STATUSES, setStatus, statusLabel } from "./status.js";
|
|
16
|
+
import { validate } from "./validate.js";
|
|
17
|
+
const HELP = `kit: Cogitato's prototype tools
|
|
18
|
+
|
|
19
|
+
kit validate [--contract] [--files <file>...] [--json]
|
|
20
|
+
Check the prototype against its design contract.
|
|
21
|
+
kit export-flows [--check] [--json]
|
|
22
|
+
Write design/flows.json from the screens and src/flows.ts.
|
|
23
|
+
kit preview [--port <n>] [--no-open]
|
|
24
|
+
Start the prototype if needed and open the design kit page.
|
|
25
|
+
kit doctor [--json] [--quiet] [--port <n>]
|
|
26
|
+
Check this machine is ready to run the prototype.
|
|
27
|
+
|
|
28
|
+
kit new-screen <screen id> [--title <t>] [--route </path>] [--from <step>] [--label <l>] [--flow <id>]
|
|
29
|
+
Create a screen with a default state; --from adds an arrow to it.
|
|
30
|
+
kit add-state <screen id> <state> [--title <t>] [--from <step>] [--label <l>] [--flow <id>]
|
|
31
|
+
Add a state to a screen.
|
|
32
|
+
kit add-edge <from step> <to step> [--label <l>] [--flow <id>]
|
|
33
|
+
Connect two states in src/flows.ts.
|
|
34
|
+
kit gap add --kind <component|token|pattern> --name <n> --context <why> [--screen <id>] [--workaround <w>]
|
|
35
|
+
Record something the design needs that the kit doesn't have.
|
|
36
|
+
kit link <step> [--canvas] [--port <n>]
|
|
37
|
+
Print the local address of a screen state, or of its frame on the canvas.
|
|
38
|
+
kit status <step> <status>
|
|
39
|
+
Set a state's review status on the canvas.
|
|
40
|
+
kit snapshots [--dist <folder>] [--port <n>]
|
|
41
|
+
Screenshot every state of the built prototype for the canvas (needs Playwright).
|
|
42
|
+
kit save [--message <m>]
|
|
43
|
+
Save a version: commit on a design branch, and share it if there's a remote.
|
|
44
|
+
kit hook <post-edit|session-start>
|
|
45
|
+
Claude Code hook (reads the hook's JSON on stdin). Used by the Cogitato plugin.
|
|
46
|
+
|
|
47
|
+
Steps are "{screen id}.{state}", like "checkout.payment.card-declined". Every command takes --json.
|
|
48
|
+
|
|
49
|
+
Exit codes: 0 all good, 1 problems found, 2 couldn't run.`;
|
|
50
|
+
const out = (text) => {
|
|
51
|
+
if (text)
|
|
52
|
+
process.stdout.write(text + "\n");
|
|
53
|
+
};
|
|
54
|
+
function project() {
|
|
55
|
+
const p = findProject();
|
|
56
|
+
if (!p)
|
|
57
|
+
throw new UsageError("This folder isn't a Cogitato prototype: there's no design/contract folder here or above it.");
|
|
58
|
+
return p;
|
|
59
|
+
}
|
|
60
|
+
class UsageError extends Error {
|
|
61
|
+
}
|
|
62
|
+
/** Runs the CLI and returns the exit code. */
|
|
63
|
+
export async function main(argv) {
|
|
64
|
+
const args = mri(argv, {
|
|
65
|
+
boolean: ["json", "contract", "check", "quiet", "help", "open", "canvas"],
|
|
66
|
+
string: ["files", "port", "title", "route", "from", "to", "label", "flow", "kind", "name", "context", "screen", "workaround", "message", "dist"],
|
|
67
|
+
default: { open: true },
|
|
68
|
+
});
|
|
69
|
+
const [command, ...rest] = args._;
|
|
70
|
+
const port = args.port ? Number(args.port) : undefined;
|
|
71
|
+
const opt = (key) => (typeof args[key] === "string" && args[key] ? args[key] : undefined);
|
|
72
|
+
const need = (value, what) => {
|
|
73
|
+
if (typeof value !== "string" || !value)
|
|
74
|
+
throw new UsageError(`Missing ${what}.
|
|
75
|
+
|
|
76
|
+
${HELP}`);
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
79
|
+
const scaffolded = (r) => {
|
|
80
|
+
if (args.json)
|
|
81
|
+
out(JSON.stringify({ ...toReport(r), files: r.files, node: r.node, link: r.link, canvas: r.canvas }, null, 2));
|
|
82
|
+
else
|
|
83
|
+
out(`Done: ${r.node} (${r.files.join(", ")})\nSee it at ${r.link}\nOn the canvas: ${r.canvas}\n\n${formatResult(r)}`);
|
|
84
|
+
return r.ok ? 0 : 1;
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
switch (command) {
|
|
88
|
+
case "validate": {
|
|
89
|
+
// --files takes the following arguments too: `kit validate --files a.tsx b.css`.
|
|
90
|
+
const files = args.files === undefined ? undefined : [args.files, ...rest].flat().map(String).filter(Boolean);
|
|
91
|
+
const r = validate(project(), { contractOnly: args.contract, ...(files ? { files } : {}) });
|
|
92
|
+
out(args.json ? JSON.stringify(toReport(r), null, 2) : formatResult(r));
|
|
93
|
+
return r.ok ? 0 : 1;
|
|
94
|
+
}
|
|
95
|
+
case "export-flows": {
|
|
96
|
+
const r = exportFlows(project(), { check: args.check });
|
|
97
|
+
const result = { ok: !r.issues.some((i) => i.severity === "error"), issues: r.issues };
|
|
98
|
+
if (args.json)
|
|
99
|
+
out(JSON.stringify(toReport(result), null, 2));
|
|
100
|
+
else if (!result.ok)
|
|
101
|
+
out(formatResult(result) + "\n\nflows.json wasn't updated.");
|
|
102
|
+
else if (args.check)
|
|
103
|
+
out(r.changed ? "flows.json is out of date. Run kit export-flows." : "flows.json is up to date.");
|
|
104
|
+
else
|
|
105
|
+
out(r.written ? "Updated design/flows.json." : "flows.json is already up to date.");
|
|
106
|
+
return !result.ok || (args.check && r.changed) ? 1 : 0;
|
|
107
|
+
}
|
|
108
|
+
case "preview": {
|
|
109
|
+
const r = await preview(project(), { ...(port ? { port } : {}), open: args.open, log: out });
|
|
110
|
+
if (r.server) {
|
|
111
|
+
await new Promise((resolve) => r.server.on("exit", () => resolve()));
|
|
112
|
+
}
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
case "doctor": {
|
|
116
|
+
const checks = await doctor(project(), port ? { port } : {});
|
|
117
|
+
out(args.json ? JSON.stringify(checks, null, 2) : formatDoctor(checks, args.quiet));
|
|
118
|
+
return checks.some((c) => c.status === "problem") ? 1 : 0;
|
|
119
|
+
}
|
|
120
|
+
case "new-screen":
|
|
121
|
+
return scaffolded(createScreen(project(), {
|
|
122
|
+
id: need(rest[0], "the screen id"),
|
|
123
|
+
title: opt("title"), route: opt("route"), from: opt("from"), label: opt("label"), flow: opt("flow"),
|
|
124
|
+
}));
|
|
125
|
+
case "add-state":
|
|
126
|
+
return scaffolded(addState(project(), {
|
|
127
|
+
screen: need(rest[0], "the screen id"),
|
|
128
|
+
state: need(rest[1], "the state name"),
|
|
129
|
+
title: opt("title"), from: opt("from"), label: opt("label"), flow: opt("flow"),
|
|
130
|
+
}));
|
|
131
|
+
case "add-edge":
|
|
132
|
+
return scaffolded(addEdge(project(), { from: need(rest[0] ?? opt("from"), "the step to start from"), to: need(rest[1] ?? opt("to"), "the step to go to"), label: opt("label"), flow: opt("flow") }));
|
|
133
|
+
case "gap": {
|
|
134
|
+
if (rest[0] !== "add")
|
|
135
|
+
throw new UsageError(`Use "kit gap add".
|
|
136
|
+
|
|
137
|
+
${HELP}`);
|
|
138
|
+
const kind = need(opt("kind"), "--kind");
|
|
139
|
+
if (kind !== "component" && kind !== "token" && kind !== "pattern")
|
|
140
|
+
throw new UsageError("--kind is component, token or pattern.");
|
|
141
|
+
const r = addGap(project(), {
|
|
142
|
+
kind, name: need(opt("name"), "--name"), context: need(opt("context"), "--context"),
|
|
143
|
+
screen: opt("screen"), workaround: opt("workaround"),
|
|
144
|
+
});
|
|
145
|
+
out(args.json ? JSON.stringify(r, null, 2) : r.created ? `Logged ${r.gap.id}: ${r.gap.name}.` : `Already logged as ${r.gap.id}.`);
|
|
146
|
+
return 0;
|
|
147
|
+
}
|
|
148
|
+
case "link": {
|
|
149
|
+
const link = (args.canvas ? canvasLink : stateLink)(project(), need(rest[0], "the step"), port);
|
|
150
|
+
out(args.json ? JSON.stringify({ link }) : link);
|
|
151
|
+
return 0;
|
|
152
|
+
}
|
|
153
|
+
case "status": {
|
|
154
|
+
const r = setStatus(project(), need(rest[0], "the step"), need(rest[1], `the status (${FRAME_STATUSES.join(", ")})`));
|
|
155
|
+
out(args.json ? JSON.stringify(r) : `${r.node} is now "${statusLabel(r.status)}" (was "${statusLabel(r.previous)}").`);
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
case "snapshots": {
|
|
159
|
+
const r = await takeSnapshots(project(), { ...(opt("dist") ? { dist: opt("dist") } : {}), ...(port ? { port } : {}), log: out });
|
|
160
|
+
if (args.json)
|
|
161
|
+
out(JSON.stringify(r, null, 2));
|
|
162
|
+
else if (r.skipped)
|
|
163
|
+
out(r.skipped);
|
|
164
|
+
// Snapshots are a nice-to-have: never fail a build over them.
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
case "save": {
|
|
168
|
+
const r = saveVersion(project(), { message: opt("message") });
|
|
169
|
+
out(args.json ? JSON.stringify(r, null, 2) : r.message);
|
|
170
|
+
return 0;
|
|
171
|
+
}
|
|
172
|
+
case "hook": {
|
|
173
|
+
const event = rest[0];
|
|
174
|
+
if (event !== "post-edit" && event !== "session-start")
|
|
175
|
+
throw new UsageError(`Use "kit hook post-edit" or "kit hook session-start".`);
|
|
176
|
+
const input = await readStdin();
|
|
177
|
+
const r = await runHook(event, input ? JSON.parse(input) : {});
|
|
178
|
+
if (r)
|
|
179
|
+
out(JSON.stringify(r));
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
case undefined:
|
|
183
|
+
case "help":
|
|
184
|
+
out(HELP);
|
|
185
|
+
return command ? 0 : args.help ? 0 : 2;
|
|
186
|
+
default:
|
|
187
|
+
out(`"${command}" isn't a kit command.\n\n${HELP}`);
|
|
188
|
+
return 2;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (e) {
|
|
192
|
+
out(e instanceof Error ? e.message : String(e));
|
|
193
|
+
return e instanceof KitError ? 1 : 2;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
async function readStdin() {
|
|
197
|
+
if (process.stdin.isTTY)
|
|
198
|
+
return "";
|
|
199
|
+
const chunks = [];
|
|
200
|
+
for await (const chunk of process.stdin)
|
|
201
|
+
chunks.push(chunk);
|
|
202
|
+
return Buffer.concat(chunks).toString("utf8").trim();
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,OAA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tE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Project } from "./project.js";
|
|
2
|
+
export type CheckStatus = "ok" | "warning" | "problem";
|
|
3
|
+
export interface DoctorCheck {
|
|
4
|
+
id: string;
|
|
5
|
+
status: CheckStatus;
|
|
6
|
+
/** One plain-language line: what's wrong and how to fix it, or what's fine. */
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DoctorOptions {
|
|
10
|
+
/** Port the prototype's dev server uses. */
|
|
11
|
+
port?: number;
|
|
12
|
+
/** For tests: skip slow checks that touch the network or spawn processes. */
|
|
13
|
+
offline?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const DEFAULT_PORT = 5173;
|
|
16
|
+
export declare function isServerUp(port: number, timeoutMs?: number): Promise<boolean>;
|
|
17
|
+
/** Machine health check for a prototype. Every message is written for a designer. */
|
|
18
|
+
export declare function doctor(project: Project, opts?: DoctorOptions): Promise<DoctorCheck[]>;
|
|
19
|
+
export declare function formatDoctor(checks: DoctorCheck[], quiet?: boolean): string;
|
package/dist/doctor.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
+
import { validateProject } from "@cogitato/contract";
|
|
4
|
+
import { buildManifest, readFlowsJson, sameManifest } from "./flows.js";
|
|
5
|
+
import { LAYOUT, sourceFiles } from "./project.js";
|
|
6
|
+
import { readRegistry } from "./registry.js";
|
|
7
|
+
export const DEFAULT_PORT = 5173;
|
|
8
|
+
export async function isServerUp(port, timeoutMs = 800) {
|
|
9
|
+
try {
|
|
10
|
+
const res = await fetch(`http://localhost:${port}/`, { signal: AbortSignal.timeout(timeoutMs) });
|
|
11
|
+
return res.ok || res.status < 500;
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function envKeys(path) {
|
|
18
|
+
if (!existsSync(path))
|
|
19
|
+
return [];
|
|
20
|
+
return readFileSync(path, "utf8")
|
|
21
|
+
.split(/\r?\n/)
|
|
22
|
+
.map((l) => /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=/.exec(l)?.[1])
|
|
23
|
+
.filter((k) => Boolean(k));
|
|
24
|
+
}
|
|
25
|
+
/** Machine health check for a prototype. Every message is written for a designer. */
|
|
26
|
+
export async function doctor(project, opts = {}) {
|
|
27
|
+
const checks = [];
|
|
28
|
+
const add = (id, status, message) => checks.push({ id, status, message });
|
|
29
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
30
|
+
add("node", major >= 22 ? "ok" : "problem", major >= 22 ? `Node ${process.versions.node} is installed.` : `Node ${process.versions.node} is too old. Cogitato needs Node 22 or newer.`);
|
|
31
|
+
if (!opts.offline) {
|
|
32
|
+
const pnpm = spawnSync("pnpm", ["--version"], { encoding: "utf8", shell: true });
|
|
33
|
+
add("pnpm", pnpm.status === 0 ? "ok" : "problem", pnpm.status === 0 ? `pnpm ${pnpm.stdout.trim()} is installed.` : "pnpm isn't installed. It's needed to install the prototype's parts.");
|
|
34
|
+
}
|
|
35
|
+
const installed = ["@cogitato/runtime", "@cogitato/contract", "@cogitato/kit-mcp"].every((p) => existsSync(project.abs(`node_modules/${p}/package.json`)));
|
|
36
|
+
add("dependencies", installed ? "ok" : "problem", installed ? "The prototype's parts are installed." : "The prototype's parts aren't installed yet. Run the setup (pnpm install) once.");
|
|
37
|
+
const contract = validateProject(project.abs(LAYOUT.design));
|
|
38
|
+
const contractErrors = contract.issues.filter((i) => i.severity === "error").length;
|
|
39
|
+
add("contract", contractErrors ? "problem" : "ok", contractErrors
|
|
40
|
+
? `The design contract has ${contractErrors} problem${contractErrors === 1 ? "" : "s"}. Run kit validate to see them.`
|
|
41
|
+
: "The design contract is valid.");
|
|
42
|
+
const existing = readFlowsJson(project);
|
|
43
|
+
const registry = readRegistry(project, sourceFiles(project));
|
|
44
|
+
const built = buildManifest(registry);
|
|
45
|
+
add("flows", !existing ? "warning" : sameManifest(existing, built.manifest) ? "ok" : "warning", !existing
|
|
46
|
+
? "flows.json hasn't been created yet. Run kit export-flows."
|
|
47
|
+
: sameManifest(existing, built.manifest)
|
|
48
|
+
? "flows.json is up to date."
|
|
49
|
+
: "flows.json is out of date. Run kit export-flows.");
|
|
50
|
+
if (!opts.offline) {
|
|
51
|
+
const port = opts.port ?? DEFAULT_PORT;
|
|
52
|
+
const up = await isServerUp(port);
|
|
53
|
+
add("dev-server", up ? "ok" : "warning", up ? `The prototype is running at http://localhost:${port}.` : `The prototype isn't running. Start it to see your screens (port ${port}).`);
|
|
54
|
+
}
|
|
55
|
+
const needed = envKeys(project.abs(".env.example"));
|
|
56
|
+
const present = new Set(envKeys(project.abs(".env")));
|
|
57
|
+
const missing = needed.filter((k) => !present.has(k));
|
|
58
|
+
add("env", missing.length ? "problem" : "ok", missing.length
|
|
59
|
+
? `Some settings are missing from .env: ${missing.join(", ")}. Ask a developer for the values.`
|
|
60
|
+
: needed.length
|
|
61
|
+
? "All settings in .env are present."
|
|
62
|
+
: "No settings are needed.");
|
|
63
|
+
return checks;
|
|
64
|
+
}
|
|
65
|
+
export function formatDoctor(checks, quiet = false) {
|
|
66
|
+
const shown = quiet ? checks.filter((c) => c.status === "problem") : checks;
|
|
67
|
+
if (quiet && shown.length === 0)
|
|
68
|
+
return "";
|
|
69
|
+
const mark = { ok: "ok ", warning: "check ", problem: "PROBLEM" };
|
|
70
|
+
return shown.map((c) => `${mark[c.status]} ${c.message}`).join("\n");
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"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AAM,CAAC;IAC5E,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC3C,MAAM,IAAI,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAW,CAAC;IAChF,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A request kit can't carry out, with a message written for a designer ("There's already a
|
|
3
|
+
* screen called checkout.review."). The CLI prints it and exits 1; the MCP server returns it
|
|
4
|
+
* as a tool error.
|
|
5
|
+
*/
|
|
6
|
+
export declare class KitError extends Error {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A request kit can't carry out, with a message written for a designer ("There's already a
|
|
3
|
+
* screen called checkout.review."). The CLI prints it and exits 1; the MCP server returns it
|
|
4
|
+
* as a tool error.
|
|
5
|
+
*/
|
|
6
|
+
export class KitError extends Error {
|
|
7
|
+
name = "KitError";
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,GAAG,UAAU,CAAC;CAC5B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ExportResult } from "./flows.js";
|
|
2
|
+
import { type Project } from "./project.js";
|
|
3
|
+
export interface ExportOptions {
|
|
4
|
+
/** Don't write; report whether design/flows.json is up to date. */
|
|
5
|
+
check?: boolean;
|
|
6
|
+
}
|
|
7
|
+
/** Reads every screen and src/flows.ts, and writes design/flows.json for the canvas. */
|
|
8
|
+
export declare function exportFlows(project: Project, opts?: ExportOptions): ExportResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { buildManifest, currentCommit, keptStatus, writeManifest } from "./flows.js";
|
|
2
|
+
import { sourceFiles } from "./project.js";
|
|
3
|
+
import { readRegistry } from "./registry.js";
|
|
4
|
+
/** Reads every screen and src/flows.ts, and writes design/flows.json for the canvas. */
|
|
5
|
+
export function exportFlows(project, opts = {}) {
|
|
6
|
+
const registry = readRegistry(project, sourceFiles(project));
|
|
7
|
+
const built = buildManifest(registry, currentCommit(project));
|
|
8
|
+
// With an unreadable screen, flow-step problems would only repeat it (see Registry.complete).
|
|
9
|
+
const flowIssues = registry.complete ? built.issues : [];
|
|
10
|
+
// Review statuses are set on the canvas, not in code, so they carry over from the current file.
|
|
11
|
+
const status = keptStatus(project, built.manifest);
|
|
12
|
+
const manifest = status ? { ...built.manifest, status } : built.manifest;
|
|
13
|
+
return writeManifest(project, { manifest, issues: [...registry.issues, ...flowIssues] }, opts.check ?? false);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=export-flows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-flows.js","sourceRoot":"","sources":["../src/export-flows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AACxG,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAO7C,wFAAwF;AACxF,MAAM,UAAU,WAAW,CAAC,OAAgB,EAAE,OAAsB,EAAE;IACpE,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,8FAA8F;IAC9F,MAAM,UAAU,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,gGAAgG;IAChG,MAAM,MAAM,GAAG,UAAU,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC;IACzE,OAAO,aAAa,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC;AAChH,CAAC"}
|