@cogitato/kit-cli 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +34 -2
  3. package/bin/kit.js +4 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +245 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/doctor.d.ts +23 -0
  8. package/dist/doctor.js +86 -0
  9. package/dist/doctor.js.map +1 -0
  10. package/dist/errors.d.ts +8 -0
  11. package/dist/errors.js +9 -0
  12. package/dist/errors.js.map +1 -0
  13. package/dist/export-flows.d.ts +8 -0
  14. package/dist/export-flows.js +15 -0
  15. package/dist/export-flows.js.map +1 -0
  16. package/dist/flows.d.ts +38 -0
  17. package/dist/flows.js +141 -0
  18. package/dist/flows.js.map +1 -0
  19. package/dist/format.d.ts +3 -0
  20. package/dist/format.js +27 -0
  21. package/dist/format.js.map +1 -0
  22. package/dist/gaps.d.ts +21 -0
  23. package/dist/gaps.js +52 -0
  24. package/dist/gaps.js.map +1 -0
  25. package/dist/hook.d.ts +33 -0
  26. package/dist/hook.js +114 -0
  27. package/dist/hook.js.map +1 -0
  28. package/dist/hosting.d.ts +18 -0
  29. package/dist/hosting.js +51 -0
  30. package/dist/hosting.js.map +1 -0
  31. package/dist/index.d.ts +19 -0
  32. package/dist/index.js +21 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/issue.d.ts +17 -0
  35. package/dist/issue.js +65 -0
  36. package/dist/issue.js.map +1 -0
  37. package/dist/links.d.ts +15 -0
  38. package/dist/links.js +60 -0
  39. package/dist/links.js.map +1 -0
  40. package/dist/preview.d.ts +16 -0
  41. package/dist/preview.js +38 -0
  42. package/dist/preview.js.map +1 -0
  43. package/dist/project.d.ts +55 -0
  44. package/dist/project.js +145 -0
  45. package/dist/project.js.map +1 -0
  46. package/dist/registry.d.ts +67 -0
  47. package/dist/registry.js +227 -0
  48. package/dist/registry.js.map +1 -0
  49. package/dist/rules/css-values.d.ts +31 -0
  50. package/dist/rules/css-values.js +185 -0
  51. package/dist/rules/css-values.js.map +1 -0
  52. package/dist/rules/css.d.ts +4 -0
  53. package/dist/rules/css.js +39 -0
  54. package/dist/rules/css.js.map +1 -0
  55. package/dist/rules/tsx.d.ts +26 -0
  56. package/dist/rules/tsx.js +191 -0
  57. package/dist/rules/tsx.js.map +1 -0
  58. package/dist/save.d.ts +30 -0
  59. package/dist/save.js +164 -0
  60. package/dist/save.js.map +1 -0
  61. package/dist/scaffold.d.ts +42 -0
  62. package/dist/scaffold.js +232 -0
  63. package/dist/scaffold.js.map +1 -0
  64. package/dist/snapshots.d.ts +43 -0
  65. package/dist/snapshots.js +140 -0
  66. package/dist/snapshots.js.map +1 -0
  67. package/dist/status.d.ts +14 -0
  68. package/dist/status.js +38 -0
  69. package/dist/status.js.map +1 -0
  70. package/dist/validate.d.ts +18 -0
  71. package/dist/validate.js +72 -0
  72. package/dist/validate.js.map +1 -0
  73. package/dist/workspace.d.ts +18 -0
  74. package/dist/workspace.js +119 -0
  75. package/dist/workspace.js.map +1 -0
  76. package/package.json +52 -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
- # Temporary Holding Version
1
+ # @cogitato/kit-cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../dist/cli.js";
3
+
4
+ process.exitCode = await main(process.argv.slice(2));
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ /** Runs the CLI and returns the exit code. */
2
+ export declare function main(argv: string[]): Promise<number>;
package/dist/cli.js ADDED
@@ -0,0 +1,245 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import mri from "mri";
3
+ import { toReport } from "@cogitato/contract";
4
+ import { doctor, formatDoctor } from "./doctor.js";
5
+ import { exportFlows } from "./export-flows.js";
6
+ import { KitError } from "./errors.js";
7
+ import { formatResult } from "./format.js";
8
+ import { addGap } from "./gaps.js";
9
+ import { runHook } from "./hook.js";
10
+ import { canvasLink, stateLink } from "./links.js";
11
+ import { preview } from "./preview.js";
12
+ import { findWorkspace, listPrototypes, resolvePrototype } from "./project.js";
13
+ import { saveVersion } from "./save.js";
14
+ import { addEdge, addState, createScreen } from "./scaffold.js";
15
+ import { takeSnapshots } from "./snapshots.js";
16
+ import { FRAME_STATUSES, setStatus, statusLabel } from "./status.js";
17
+ import { sortIssues, validate } from "./validate.js";
18
+ import { createPrototype, validateKit, validateWorkspace, workspaceSuccess } from "./workspace.js";
19
+ const HELP = `kit: Cogitato's prototype tools
20
+
21
+ kit validate [--contract] [--files <file>...] [--json]
22
+ Check the prototype against its design contract.
23
+ kit export-flows [--check] [--json]
24
+ Write design/flows.json from the screens and src/flows.ts.
25
+ kit preview [--port <n>] [--no-open]
26
+ Start the prototype if needed and open the design kit page.
27
+ kit doctor [--json] [--quiet] [--port <n>]
28
+ Check this machine is ready to run the prototype.
29
+ kit prototypes
30
+ List the prototypes in this workspace.
31
+ kit new-prototype <name>
32
+ Start a new prototype in prototypes/<name>, with the same setup as the others.
33
+ kit dev [name]
34
+ Run a prototype (the one you're in, or the only one) with its canvas.
35
+
36
+ Commands that work on one prototype take --prototype <name> when you're at the workspace root.
37
+
38
+ kit new-screen <screen id> [--title <t>] [--route </path>] [--from <step>] [--label <l>] [--flow <id>]
39
+ Create a screen with a default state; --from adds an arrow to it.
40
+ kit add-state <screen id> <state> [--title <t>] [--from <step>] [--label <l>] [--flow <id>]
41
+ Add a state to a screen.
42
+ kit add-edge <from step> <to step> [--label <l>] [--flow <id>]
43
+ Connect two states in src/flows.ts.
44
+ kit gap add --kind <component|token|pattern> --name <n> --context <why> [--screen <id>] [--workaround <w>]
45
+ Record something the design needs that the kit doesn't have.
46
+ kit link <step> [--canvas] [--port <n>]
47
+ Print the local address of a screen state, or of its frame on the canvas.
48
+ kit status <step> <status>
49
+ Set a state's review status on the canvas.
50
+ kit snapshots [--dist <folder>] [--port <n>]
51
+ Screenshot every state of the built prototype for the canvas (needs Playwright).
52
+ Uses a free port unless you give one.
53
+ kit save [--message <m>]
54
+ Save a version: commit on a design branch, and share it if there's a remote.
55
+ kit hook <post-edit|session-start>
56
+ Claude Code hook (reads the hook's JSON on stdin). Used by the Cogitato plugin.
57
+
58
+ Steps are "{screen id}.{state}", like "checkout.payment.card-declined". Every command takes --json.
59
+
60
+ Exit codes: 0 all good, 1 problems found, 2 couldn't run.`;
61
+ const out = (text) => {
62
+ if (text)
63
+ process.stdout.write(text + "\n");
64
+ };
65
+ function workspace() {
66
+ const ws = findWorkspace();
67
+ if (!ws)
68
+ throw new UsageError("This folder isn't a Cogitato workspace: there's no design/contract folder here or above it.");
69
+ return ws;
70
+ }
71
+ function project(name) {
72
+ return resolvePrototype(workspace(), name, process.cwd());
73
+ }
74
+ /** True when the working directory is inside one of the workspace's prototypes. */
75
+ const findProjectHere = (ws) => ws.rel(process.cwd()).startsWith("prototypes/");
76
+ class UsageError extends Error {
77
+ }
78
+ /** Runs the CLI and returns the exit code. */
79
+ export async function main(argv) {
80
+ const args = mri(argv, {
81
+ boolean: ["json", "contract", "check", "quiet", "help", "open", "canvas"],
82
+ string: ["files", "port", "title", "route", "from", "to", "label", "flow", "kind", "name", "context", "screen", "workaround", "message", "dist", "prototype"],
83
+ alias: { p: "prototype" },
84
+ default: { open: true },
85
+ });
86
+ const [command, ...rest] = args._;
87
+ const proto = () => project(opt("prototype"));
88
+ const port = args.port ? Number(args.port) : undefined;
89
+ const opt = (key) => (typeof args[key] === "string" && args[key] ? args[key] : undefined);
90
+ const need = (value, what) => {
91
+ if (typeof value !== "string" || !value)
92
+ throw new UsageError(`Missing ${what}.
93
+
94
+ ${HELP}`);
95
+ return value;
96
+ };
97
+ const scaffolded = (r) => {
98
+ if (args.json)
99
+ out(JSON.stringify({ ...toReport(r), files: r.files, node: r.node, link: r.link, canvas: r.canvas }, null, 2));
100
+ else
101
+ out(`Done: ${r.node} (${r.files.join(", ")})\nSee it at ${r.link}\nOn the canvas: ${r.canvas}\n\n${formatResult(r)}`);
102
+ return r.ok ? 0 : 1;
103
+ };
104
+ try {
105
+ switch (command) {
106
+ case "validate": {
107
+ // --files takes the following arguments too: `kit validate --files a.tsx b.css`.
108
+ const files = args.files === undefined ? undefined : [args.files, ...rest].flat().map(String).filter(Boolean);
109
+ const ws = workspace();
110
+ const single = opt("prototype") || files || listPrototypes(ws).length === 1 || findProjectHere(ws);
111
+ // At the root with several prototypes, --contract checks only the shared contract.
112
+ let r = single
113
+ ? validate(proto(), { contractOnly: args.contract, ...(files ? { files } : {}) })
114
+ : validateWorkspace(ws, { contractOnly: Boolean(args.contract) });
115
+ if (single && !files && !args.contract) {
116
+ // A prototype's build runs this from inside it: keep the shared kit checked too.
117
+ const issues = sortIssues([...r.issues, ...validateKit(ws)]);
118
+ r = { ok: !issues.some((i) => i.severity === "error"), issues };
119
+ }
120
+ out(args.json ? JSON.stringify(toReport(r), null, 2) : single ? formatResult(r) : formatResult(r, workspaceSuccess(ws, { contractOnly: Boolean(args.contract) })));
121
+ return r.ok ? 0 : 1;
122
+ }
123
+ case "prototypes":
124
+ out(args.json ? JSON.stringify(listPrototypes(workspace())) : listPrototypes(workspace()).join("\n"));
125
+ return 0;
126
+ case "new-prototype": {
127
+ const r = createPrototype(workspace(), need(rest[0], "the prototype name"));
128
+ out(args.json ? JSON.stringify(r, null, 2) : `Started prototypes/${r.name} with a Home screen. Install its parts with pnpm install, then run it with pnpm dev ${r.name}.`);
129
+ return 0;
130
+ }
131
+ case "dev": {
132
+ const p = project(rest[0] === undefined ? opt("prototype") : String(rest[0]));
133
+ const r = spawnSync("pnpm", ["--filter", `./prototypes/${p.name}`, "dev"], { cwd: p.workspace.root, stdio: "inherit", shell: process.platform === "win32" });
134
+ return r.status ?? 2;
135
+ }
136
+ case "export-flows": {
137
+ const r = exportFlows(proto(), { check: args.check });
138
+ const result = { ok: !r.issues.some((i) => i.severity === "error"), issues: r.issues };
139
+ if (args.json)
140
+ out(JSON.stringify(toReport(result), null, 2));
141
+ else if (!result.ok)
142
+ out(formatResult(result) + "\n\nflows.json wasn't updated.");
143
+ else if (args.check)
144
+ out(r.changed ? "flows.json is out of date. Run kit export-flows." : "flows.json is up to date.");
145
+ else
146
+ out(r.written ? "Updated design/flows.json." : "flows.json is already up to date.");
147
+ return !result.ok || (args.check && r.changed) ? 1 : 0;
148
+ }
149
+ case "preview": {
150
+ const r = await preview(proto(), { ...(port ? { port } : {}), open: args.open, log: out });
151
+ if (r.server) {
152
+ await new Promise((resolve) => r.server.on("exit", () => resolve()));
153
+ }
154
+ return 0;
155
+ }
156
+ case "doctor": {
157
+ const checks = await doctor(proto(), port ? { port } : {});
158
+ out(args.json ? JSON.stringify(checks, null, 2) : formatDoctor(checks, args.quiet));
159
+ return checks.some((c) => c.status === "problem") ? 1 : 0;
160
+ }
161
+ case "new-screen":
162
+ return scaffolded(createScreen(proto(), {
163
+ id: need(rest[0], "the screen id"),
164
+ title: opt("title"), route: opt("route"), from: opt("from"), label: opt("label"), flow: opt("flow"),
165
+ }));
166
+ case "add-state":
167
+ return scaffolded(addState(proto(), {
168
+ screen: need(rest[0], "the screen id"),
169
+ state: need(rest[1], "the state name"),
170
+ title: opt("title"), from: opt("from"), label: opt("label"), flow: opt("flow"),
171
+ }));
172
+ case "add-edge":
173
+ return scaffolded(addEdge(proto(), { 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") }));
174
+ case "gap": {
175
+ if (rest[0] !== "add")
176
+ throw new UsageError(`Use "kit gap add".
177
+
178
+ ${HELP}`);
179
+ const kind = need(opt("kind"), "--kind");
180
+ if (kind !== "component" && kind !== "token" && kind !== "pattern")
181
+ throw new UsageError("--kind is component, token or pattern.");
182
+ const r = addGap(proto(), {
183
+ kind, name: need(opt("name"), "--name"), context: need(opt("context"), "--context"),
184
+ screen: opt("screen"), workaround: opt("workaround"),
185
+ });
186
+ out(args.json ? JSON.stringify(r, null, 2) : r.created ? `Logged ${r.gap.id}: ${r.gap.name}.` : `Already logged as ${r.gap.id}.`);
187
+ return 0;
188
+ }
189
+ case "link": {
190
+ const link = (args.canvas ? canvasLink : stateLink)(proto(), need(rest[0], "the step"), port);
191
+ out(args.json ? JSON.stringify({ link }) : link);
192
+ return 0;
193
+ }
194
+ case "status": {
195
+ const r = setStatus(proto(), need(rest[0], "the step"), need(rest[1], `the status (${FRAME_STATUSES.join(", ")})`));
196
+ out(args.json ? JSON.stringify(r) : `${r.node} is now "${statusLabel(r.status)}" (was "${statusLabel(r.previous)}").`);
197
+ return 0;
198
+ }
199
+ case "snapshots": {
200
+ const r = await takeSnapshots(proto(), { ...(opt("dist") ? { dist: opt("dist") } : {}), ...(port ? { port } : {}), log: out });
201
+ if (args.json)
202
+ out(JSON.stringify(r, null, 2));
203
+ else if (r.skipped)
204
+ out(r.skipped);
205
+ // Snapshots are a nice-to-have: never fail a build over them.
206
+ return 0;
207
+ }
208
+ case "save": {
209
+ const r = saveVersion(workspace(), { message: opt("message") });
210
+ out(args.json ? JSON.stringify(r, null, 2) : r.message);
211
+ return 0;
212
+ }
213
+ case "hook": {
214
+ const event = rest[0];
215
+ if (event !== "post-edit" && event !== "session-start")
216
+ throw new UsageError(`Use "kit hook post-edit" or "kit hook session-start".`);
217
+ const input = await readStdin();
218
+ const r = await runHook(event, input ? JSON.parse(input) : {});
219
+ if (r)
220
+ out(JSON.stringify(r));
221
+ return 0;
222
+ }
223
+ case undefined:
224
+ case "help":
225
+ out(HELP);
226
+ return command ? 0 : args.help ? 0 : 2;
227
+ default:
228
+ out(`"${command}" isn't a kit command.\n\n${HELP}`);
229
+ return 2;
230
+ }
231
+ }
232
+ catch (e) {
233
+ out(e instanceof Error ? e.message : String(e));
234
+ return e instanceof KitError ? 1 : 2;
235
+ }
236
+ }
237
+ async function readStdin() {
238
+ if (process.stdin.isTTY)
239
+ return "";
240
+ const chunks = [];
241
+ for await (const chunk of process.stdin)
242
+ chunks.push(chunk);
243
+ return Buffer.concat(chunks).toString("utf8").trim();
244
+ }
245
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,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,OAAO,EAAkB,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YA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AC;IACnC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,OAAO,CAAC,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,KAAe,CAAC,CAAC;IACtE,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACvD,CAAC"}
@@ -0,0 +1,23 @@
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
+ /** Checks that are the same for every prototype on this computer: Node, pnpm and the dev server's port. */
18
+ export declare function machineChecks(opts?: DoctorOptions): Promise<DoctorCheck[]>;
19
+ /** Checks for one prototype: its installed parts, the contract, flows.json and its .env settings. */
20
+ export declare function prototypeChecks(project: Project): DoctorCheck[];
21
+ /** Machine health check for a prototype. Every message is written for a designer. */
22
+ export declare function doctor(project: Project, opts?: DoctorOptions): Promise<DoctorCheck[]>;
23
+ export declare function formatDoctor(checks: DoctorCheck[], quiet?: boolean): string;
package/dist/doctor.js ADDED
@@ -0,0 +1,86 @@
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, WORKSPACE_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
+ const collector = () => {
26
+ const checks = [];
27
+ const add = (id, status, message) => checks.push({ id, status, message });
28
+ return { checks, add };
29
+ };
30
+ /** Checks that are the same for every prototype on this computer: Node, pnpm and the dev server's port. */
31
+ export async function machineChecks(opts = {}) {
32
+ const { checks, add } = collector();
33
+ const major = Number(process.versions.node.split(".")[0]);
34
+ 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.`);
35
+ if (!opts.offline) {
36
+ const pnpm = spawnSync("pnpm", ["--version"], { encoding: "utf8", shell: true });
37
+ 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.");
38
+ }
39
+ if (!opts.offline) {
40
+ const port = opts.port ?? DEFAULT_PORT;
41
+ const up = await isServerUp(port);
42
+ 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}).`);
43
+ }
44
+ return checks;
45
+ }
46
+ /** Checks for one prototype: its installed parts, the contract, flows.json and its .env settings. */
47
+ export function prototypeChecks(project) {
48
+ const { checks, add } = collector();
49
+ const installed = ["@cogitato/contract", "@cogitato/kit-mcp"].every((p) => existsSync(project.workspace.abs(`node_modules/${p}/package.json`))) &&
50
+ existsSync(project.abs("node_modules/@cogitato/runtime/package.json"));
51
+ 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.");
52
+ const contract = validateProject(project.abs(LAYOUT.design), project.workspace.abs(WORKSPACE_LAYOUT.contract));
53
+ const contractErrors = contract.issues.filter((i) => i.severity === "error").length;
54
+ add("contract", contractErrors ? "problem" : "ok", contractErrors
55
+ ? `The design contract has ${contractErrors} problem${contractErrors === 1 ? "" : "s"}. Run kit validate to see them.`
56
+ : "The design contract is valid.");
57
+ const existing = readFlowsJson(project);
58
+ const registry = readRegistry(project, sourceFiles(project));
59
+ const built = buildManifest(registry);
60
+ add("flows", !existing ? "warning" : sameManifest(existing, built.manifest) ? "ok" : "warning", !existing
61
+ ? "flows.json hasn't been created yet. Run kit export-flows."
62
+ : sameManifest(existing, built.manifest)
63
+ ? "flows.json is up to date."
64
+ : "flows.json is out of date. Run kit export-flows.");
65
+ const needed = envKeys(project.abs(".env.example"));
66
+ const present = new Set(envKeys(project.abs(".env")));
67
+ const missing = needed.filter((k) => !present.has(k));
68
+ add("env", missing.length ? "problem" : "ok", missing.length
69
+ ? `Some settings are missing from .env: ${missing.join(", ")}. Ask a developer for the values.`
70
+ : needed.length
71
+ ? "All settings in .env are present."
72
+ : "No settings are needed.");
73
+ return checks;
74
+ }
75
+ /** Machine health check for a prototype. Every message is written for a designer. */
76
+ export async function doctor(project, opts = {}) {
77
+ return [...(await machineChecks(opts)), ...prototypeChecks(project)];
78
+ }
79
+ export function formatDoctor(checks, quiet = false) {
80
+ const shown = quiet ? checks.filter((c) => c.status === "problem") : checks;
81
+ if (quiet && shown.length === 0)
82
+ return "";
83
+ const mark = { ok: "ok ", warning: "check ", problem: "PROBLEM" };
84
+ return shown.map((c) => `${mark[c.status]} ${c.message}`).join("\n");
85
+ }
86
+ //# sourceMappingURL=doctor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAA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