@wireweave/cli 0.1.1 → 0.2.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -61
- package/dist/index.js +95 -9
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,76 +1,29 @@
|
|
|
1
1
|
# @wireweave/cli
|
|
2
2
|
|
|
3
|
-
The terminal
|
|
3
|
+
The terminal entry point for Wireweave language tools.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The [public tool contract](../../docs/spec/TOOLING.md#4-cli) defines this package's APIs, behavior, configuration and compatibility. The [language contract](../../docs/spec/LANGUAGE.md) defines the DSL. [Package metadata](package.json) owns package versions, exports, dependencies and scripts.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- **Auth commands** (`login`, `logout`, `whoami`) talk to the Wireweave API to verify and persist a key for tools that need one.
|
|
11
|
-
|
|
12
|
-
The persistent token lives at `~/.wireweave/config.json` (`0600`) with shape `{ "token": string, "apiUrl"?: string }`.
|
|
13
|
-
|
|
14
|
-
## Install
|
|
9
|
+
Use Node.js >=22.13.0. Replace `<pinned-version>` with the release selected for your toolchain.
|
|
15
10
|
|
|
16
11
|
```bash
|
|
17
|
-
npm install
|
|
12
|
+
npm install --global '@wireweave/cli@<pinned-version>'
|
|
18
13
|
```
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npx @wireweave/cli parse design.wf
|
|
24
|
-
```
|
|
15
|
+
The installed executable is `wireweave`. Setup, transports and credentials are defined by the tool contract.
|
|
25
16
|
|
|
26
|
-
|
|
17
|
+
## Development
|
|
27
18
|
|
|
28
|
-
|
|
19
|
+
Run from the monorepo root after the [workspace setup](../../README.md).
|
|
29
20
|
|
|
30
21
|
```bash
|
|
31
|
-
|
|
32
|
-
wireweave
|
|
33
|
-
wireweave
|
|
34
|
-
|
|
35
|
-
wireweave
|
|
36
|
-
wireweave diff old.wf new.wf --ignore-order
|
|
37
|
-
wireweave validate-ux design.wf --min-severity warning
|
|
38
|
-
wireweave export-json design.wf -o design.json
|
|
39
|
-
wireweave export-figma design.wf -o design.figma.json
|
|
40
|
-
wireweave list-components --category form
|
|
41
|
-
|
|
42
|
-
# Auth
|
|
43
|
-
wireweave login --api-key <key> # or pipe via stdin / WIREWEAVE_API_KEY
|
|
44
|
-
wireweave whoami
|
|
45
|
-
wireweave logout
|
|
22
|
+
pnpm --filter @wireweave/cli run build
|
|
23
|
+
pnpm --filter @wireweave/cli run typecheck
|
|
24
|
+
pnpm --filter @wireweave/cli run lint
|
|
25
|
+
pnpm --filter @wireweave/cli run test
|
|
26
|
+
pnpm --filter @wireweave/cli run format:check
|
|
46
27
|
```
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
| Command | Network | Description |
|
|
51
|
-
| --------------------- | ------- | ----------------------------------------------------------------------------------------------------------- |
|
|
52
|
-
| `parse <file>` | local | Parse a `.wf`/`.wireframe` file and print its AST as JSON. |
|
|
53
|
-
| `validate <file>` | local | Validate syntax. `--strict` also rejects unknown attributes. |
|
|
54
|
-
| `render <file>` | local | Render to HTML. `--theme light\|dark`, `--full-document`, `-o <path>`. |
|
|
55
|
-
| `analyze <file>` | local | Statistics, accessibility, and complexity. `--format json\|summary`, `--no-*` toggles. |
|
|
56
|
-
| `diff <old> <new>` | local | Compare two wireframes. `--ignore-attributes`, `--ignore-order`, `--format`. |
|
|
57
|
-
| `validate-ux <file>` | local | Check against UX best-practice rules. `--categories`, `--min-severity`, `--max-issues`, `--disabled-rules`. |
|
|
58
|
-
| `export-json <file>` | local | Export as JSON. `--include-locations`, `--no-pretty-print`, `--include-empty-attributes`. |
|
|
59
|
-
| `export-figma <file>` | local | Export to Figma-compatible JSON. |
|
|
60
|
-
| `list-components` | local | List DSL components. `--category`, `--format table\|json`. |
|
|
61
|
-
| `login` | network | Verify an API key and store it. `--api-key`, `--api-url`. |
|
|
62
|
-
| `whoami` | network | Verify the stored key and show the configured account. |
|
|
63
|
-
| `logout` | local | Remove the stored API key from disk. |
|
|
64
|
-
|
|
65
|
-
## Environment
|
|
66
|
-
|
|
67
|
-
| Variable | Default | Purpose |
|
|
68
|
-
| ------------------- | --------------------------- | -------------------------------------- |
|
|
69
|
-
| `WIREWEAVE_API_URL` | `https://api.wireweave.org` | Override the API base. |
|
|
70
|
-
| `WIREWEAVE_API_KEY` | — | Per-shell override of the saved token. |
|
|
71
|
-
|
|
72
|
-
Part of the [Wireweave monorepo](https://github.com/wireweave/wireweave).
|
|
73
|
-
|
|
74
|
-
## License
|
|
75
|
-
|
|
76
|
-
MIT
|
|
29
|
+
License: MIT.
|
package/dist/index.js
CHANGED
|
@@ -663,10 +663,23 @@ async function exportFigmaCommand(opts) {
|
|
|
663
663
|
writeLine12(stderr, `export-figma failed: cannot read ${opts.file}: ${formatError8(err)}`);
|
|
664
664
|
return 1;
|
|
665
665
|
}
|
|
666
|
-
|
|
666
|
+
if (opts.languageVersion !== void 0 && opts.languageVersion !== "4.0.0") {
|
|
667
|
+
writeLine12(stderr, `export-figma failed: unsupported language version ${opts.languageVersion}`);
|
|
668
|
+
return 4;
|
|
669
|
+
}
|
|
670
|
+
const args = opts.languageVersion === "4.0.0" ? {
|
|
671
|
+
source,
|
|
672
|
+
languageVersion: "4.0.0",
|
|
673
|
+
profile: {
|
|
674
|
+
id: "wireweave-figma-mapping-v1",
|
|
675
|
+
target: "figma-plugin-json-v1",
|
|
676
|
+
screens: opts.allScreens === true ? "all" : "selected"
|
|
677
|
+
}
|
|
678
|
+
} : { source };
|
|
679
|
+
const result = await callTool("wireweave_export_figma", args, opts.dispatchParams);
|
|
667
680
|
if (result.isError) {
|
|
668
681
|
writeLine12(stderr, `export-figma failed: ${extractFirstText6(result.content)}`);
|
|
669
|
-
return 1;
|
|
682
|
+
return opts.languageVersion === "4.0.0" ? 2 : 1;
|
|
670
683
|
}
|
|
671
684
|
const payload = parseJsonResult(result);
|
|
672
685
|
if (!payload.success) {
|
|
@@ -695,6 +708,69 @@ function extractFirstText6(content) {
|
|
|
695
708
|
return first?.text ?? "Unknown error";
|
|
696
709
|
}
|
|
697
710
|
|
|
711
|
+
// src/commands/export-svg.ts
|
|
712
|
+
import { promises as fs10 } from "fs";
|
|
713
|
+
var writeLine13 = (stream, text) => {
|
|
714
|
+
stream.write(text);
|
|
715
|
+
stream.write("\n");
|
|
716
|
+
};
|
|
717
|
+
async function exportSvgCommand(opts) {
|
|
718
|
+
const stdout = opts.stdout ?? process.stdout;
|
|
719
|
+
const stderr = opts.stderr ?? process.stderr;
|
|
720
|
+
const fsLike = opts.fsLike ?? fs10;
|
|
721
|
+
let source;
|
|
722
|
+
try {
|
|
723
|
+
source = await fsLike.readFile(opts.file, "utf8");
|
|
724
|
+
} catch (error) {
|
|
725
|
+
writeLine13(stderr, `export-svg failed: cannot read ${opts.file}: ${formatError9(error)}`);
|
|
726
|
+
return 1;
|
|
727
|
+
}
|
|
728
|
+
const profile = {
|
|
729
|
+
id: "wireweave-static-svg-v1",
|
|
730
|
+
screens: opts.allScreens === true ? "all" : "selected",
|
|
731
|
+
...opts.width === void 0 ? {} : { width: opts.width },
|
|
732
|
+
...opts.height === void 0 ? {} : { height: opts.height },
|
|
733
|
+
...opts.gap === void 0 ? {} : { gap: opts.gap },
|
|
734
|
+
...opts.background === void 0 ? {} : { background: opts.background }
|
|
735
|
+
};
|
|
736
|
+
const result = await callTool(
|
|
737
|
+
"wireweave_export_svg",
|
|
738
|
+
{ source, languageVersion: "4.0.0", profile },
|
|
739
|
+
opts.dispatchParams
|
|
740
|
+
);
|
|
741
|
+
if (result.isError) {
|
|
742
|
+
writeLine13(stderr, `export-svg failed: ${extractFirstText7(result.content)}`);
|
|
743
|
+
return 1;
|
|
744
|
+
}
|
|
745
|
+
const payload = parseJsonResult(result);
|
|
746
|
+
if (!payload.success || typeof payload.svg !== "string") {
|
|
747
|
+
writeLine13(
|
|
748
|
+
stderr,
|
|
749
|
+
`export-svg failed: ${payload.error ?? JSON.stringify(payload.diagnostics ?? [])}`
|
|
750
|
+
);
|
|
751
|
+
return 2;
|
|
752
|
+
}
|
|
753
|
+
if (opts.output) {
|
|
754
|
+
try {
|
|
755
|
+
await fsLike.writeFile(opts.output, payload.svg, "utf8");
|
|
756
|
+
writeLine13(stdout, `Wrote ${opts.output}`);
|
|
757
|
+
} catch (error) {
|
|
758
|
+
writeLine13(stderr, `export-svg failed: cannot write ${opts.output}: ${formatError9(error)}`);
|
|
759
|
+
return 1;
|
|
760
|
+
}
|
|
761
|
+
return 0;
|
|
762
|
+
}
|
|
763
|
+
writeLine13(stdout, payload.svg);
|
|
764
|
+
return 0;
|
|
765
|
+
}
|
|
766
|
+
function formatError9(error) {
|
|
767
|
+
return error instanceof Error ? error.message : String(error);
|
|
768
|
+
}
|
|
769
|
+
function extractFirstText7(content) {
|
|
770
|
+
const first = content.find((block) => block.type === "text");
|
|
771
|
+
return first?.text ?? "Unknown error";
|
|
772
|
+
}
|
|
773
|
+
|
|
698
774
|
// src/index.ts
|
|
699
775
|
var program = new Command();
|
|
700
776
|
program.name("wireweave").description(
|
|
@@ -797,13 +873,23 @@ program.command("export-json").argument("<file>", "Path to a .wf or .wireframe f
|
|
|
797
873
|
process.exit(code);
|
|
798
874
|
}
|
|
799
875
|
);
|
|
800
|
-
program.command("export-
|
|
801
|
-
|
|
802
|
-
file,
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
876
|
+
program.command("export-svg").argument("<file>", "Path to a Wireweave 4 application source file").option("-o, --output <path>", "Write raw SVG to a file instead of stdout").option("--all-screens", "Place every linked screen on the exported canvas").option("--width <pixels>", "Board width", (value) => Number(value)).option("--height <pixels>", "Board height", (value) => Number(value)).option("--gap <pixels>", "Gap between boards", (value) => Number(value)).option("--background <color>", "Static board background").description("Export a Wireweave 4 application to deterministic static SVG (local \u2014 no network)").action(
|
|
877
|
+
async (file, opts) => {
|
|
878
|
+
const code = await exportSvgCommand({ file, ...opts });
|
|
879
|
+
process.exit(code);
|
|
880
|
+
}
|
|
881
|
+
);
|
|
882
|
+
program.command("export-figma").argument("<file>", "Path to a .wf or .wireframe file").option("-o, --output <path>", "Write Figma JSON to a file instead of stdout").option("--language-version <version>", "Use the linked Wireweave 4 semantic exporter").option("--all-screens", "Include every linked screen in Wireweave 4 mode").description("Export a wireframe to Figma-compatible JSON (local \u2014 no network)").action(
|
|
883
|
+
async (file, opts) => {
|
|
884
|
+
const code = await exportFigmaCommand({
|
|
885
|
+
file,
|
|
886
|
+
output: opts.output,
|
|
887
|
+
languageVersion: opts.languageVersion,
|
|
888
|
+
allScreens: opts.allScreens
|
|
889
|
+
});
|
|
890
|
+
process.exit(code);
|
|
891
|
+
}
|
|
892
|
+
);
|
|
807
893
|
program.parseAsync(process.argv).catch((err) => {
|
|
808
894
|
const message = err instanceof Error ? err.message : String(err);
|
|
809
895
|
process.stderr.write(`wireweave: ${message}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wireweave/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.15",
|
|
4
4
|
"description": "Wireweave CLI — auth, render, and AI agent for the Wireweave wireframe DSL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
"wireweave": "./dist/index.js"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
|
-
"access": "public"
|
|
16
|
+
"access": "public",
|
|
17
|
+
"tag": "beta"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
20
|
"commander": "^12.1.0",
|
|
20
|
-
"@wireweave/sdk": "0.
|
|
21
|
+
"@wireweave/sdk": "0.2.0-beta.15"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@commitlint/cli": "^21.2.2",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"license": "MIT",
|
|
63
64
|
"scripts": {
|
|
64
65
|
"build": "tsup",
|
|
66
|
+
"postbuild": "node ../../scripts/dist-freshness-gate.mjs --write .",
|
|
65
67
|
"dev": "tsup --watch",
|
|
66
68
|
"start": "node dist/index.js",
|
|
67
69
|
"typecheck": "tsc --noEmit",
|
|
@@ -71,7 +73,6 @@
|
|
|
71
73
|
"format": "prettier --write .",
|
|
72
74
|
"format:check": "prettier --check .",
|
|
73
75
|
"knip": "knip",
|
|
74
|
-
"publint": "publint --strict"
|
|
75
|
-
"postbuild": "node ../../scripts/dist-freshness-gate.mjs --write ."
|
|
76
|
+
"publint": "publint --strict"
|
|
76
77
|
}
|
|
77
78
|
}
|