@anhcodo13/lattice 0.2.0 → 0.4.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/README.md +28 -17
- package/dist/cli.js +1875 -192
- package/dist/index.d.ts +269 -1
- package/dist/index.js +1323 -64
- package/governance/policy.json +43 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
# NKLattice
|
|
2
2
|
|
|
3
|
-
NKLattice is an independent, local CLI for
|
|
3
|
+
NKLattice is an independent, local CLI for project governance and architecture analysis across Next.js, Vite + React, and React applications. Version 0.4.0 assesses exact app coverage, dependency policy, architecture, known dependency advisories, code quality, code security and browser/mobile-emulation compatibility in standalone repositories and npm/pnpm workspaces. Its compatibility gate records tested browser versions and mobile user-agent OS versions, then compares them with the central test-environment floors; physical-device support remains outside this scan.
|
|
4
4
|
|
|
5
|
-
**Tiếng Việt:** NKLattice
|
|
5
|
+
**Tiếng Việt:** NKLattice đánh giá danh sách app, dependency, kiến trúc, chất lượng và bảo mật mã cùng tính tương thích trình duyệt theo policy chung cho Next.js, Vite và React. Xem [tài liệu tiếng Việt](https://khuchieunghi.github.io/nklattice/vi/docs/introduction/).
|
|
6
6
|
|
|
7
|
-
## Install
|
|
7
|
+
## Install and run 0.4.0
|
|
8
8
|
|
|
9
|
-
Requires Node.js 24 or newer. The npm package is `@anhcodo13/lattice
|
|
9
|
+
Requires Node.js 24 or newer. The npm package is `@anhcodo13/lattice` and the executable is `lattice`. Install the exact version, commit the package manifest and lockfile, and create the `.nklattice-apps.json` inventory described in the [governance guide](https://khuchieunghi.github.io/nklattice/docs/governance/). The full assessment also needs the listed scanner and test tools in the consuming repository.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install --
|
|
13
|
-
lattice --version
|
|
14
|
-
lattice governance
|
|
12
|
+
npm install --save-dev --save-exact @anhcodo13/lattice@0.4.0
|
|
13
|
+
npx lattice --version
|
|
14
|
+
npx lattice governance run . --policy path/to/reviewed-policy.json \
|
|
15
|
+
--expect-apps 1 --evidence /tmp/lattice-governance-evidence.json
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
The command writes `.nklattice-governance/assessment.json` and an offline HTML report. Use `npm view @anhcodo13/lattice version` to verify what the public registry currently serves before installing.
|
|
19
|
+
|
|
20
|
+
## Verify the source and try the published CLI
|
|
18
21
|
|
|
19
22
|
The source checkout uses pnpm 10.30.3:
|
|
20
23
|
|
|
@@ -22,22 +25,30 @@ The source checkout uses pnpm 10.30.3:
|
|
|
22
25
|
corepack enable
|
|
23
26
|
pnpm install --frozen-lockfile
|
|
24
27
|
pnpm verify
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 doctor examples/governance/apps/vite
|
|
29
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 analyze examples/governance/apps/vite
|
|
30
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 governance check examples/governance \
|
|
28
31
|
--workspace-root examples/governance \
|
|
29
32
|
--policy governance/policy.json --expect-apps 3
|
|
30
33
|
```
|
|
31
34
|
|
|
35
|
+
`pnpm verify` checks the source checkout. The `pnpm dlx` commands invoke the exact published npm package against the included examples. In an app with the package pinned as a dev dependency, use `npx lattice`.
|
|
36
|
+
|
|
32
37
|
The analysis writes `report.html` and `analysis.json` into the app's `.nklattice-report/` directory. The HTML opens offline.
|
|
33
38
|
|
|
39
|
+
## Assess project governance
|
|
40
|
+
|
|
41
|
+
Commit `.nklattice-apps.json` in each consumer scan root with exact app paths/profiles. The centrally reviewed policy sets dependency, architecture, quality, security and compatibility gates; app-local `.nklattice.json` cannot weaken an assessment. Run the combined collector and assessment shown above. The separate `collect` and `assess` commands remain useful for local inspection; the CI gate uses `run` so no editable evidence file is read between collection and verdict.
|
|
42
|
+
|
|
43
|
+
The command evaluates seven domains per app and writes `.nklattice-governance/assessment.json` plus offline `report.html`. Exit 0 means pass, 7 measured policy failure and 3 incomplete evidence or command error. See the [project governance guide](https://khuchieunghi.github.io/nklattice/docs/governance/) for scanner setup, inventory schema, scope and limits.
|
|
44
|
+
|
|
34
45
|
## Architecture analysis
|
|
35
46
|
|
|
36
47
|
NKLattice scans supported JS/TS and JSX/TSX files, resolves local imports, builds a module graph, and reports cycles, dependency concentration, long chains, duplicate imports, unused internal exports, component size, JSX depth, and approximate complexity. Define boundary policies and adjust thresholds or score weights in `.nklattice.json`.
|
|
37
48
|
|
|
38
49
|
```sh
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 init path/to/app
|
|
51
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 analyze path/to/app --output path/to/report
|
|
41
52
|
```
|
|
42
53
|
|
|
43
54
|
The score is an explainable review aid, not a claim about runtime speed or correctness. See [findings](https://khuchieunghi.github.io/nklattice/docs/findings/) and [scoring](https://khuchieunghi.github.io/nklattice/docs/scoring/).
|
|
@@ -46,7 +57,7 @@ The score is an explainable review aid, not a claim about runtime speed or corre
|
|
|
46
57
|
|
|
47
58
|
The versioned [central policy](governance/policy.json) sets minimum versions (`>=X.Y.Z`). For each supported app, the CLI checks that its direct `package.json` range cannot install below the minimum, that the npm/pnpm lockfile specifier matches the declaration, and that the resolved version satisfies both. Exact declarations are allowed when they meet the minimum. It returns exit `7` on drift and exit `3` for invalid input. Findings list the required range, declared range, lockfile specifier, locked version, and reason. A minimum has no upper bound: review framework compatibility and security separately before adopting newer major releases.
|
|
48
59
|
|
|
49
|
-
CLI 0.
|
|
60
|
+
CLI 0.4.0 requires policy schema 2. Existing schema 1 files use exact-version rules and need migration; consumers pinned to an older core SHA or npm package keep their existing behavior until explicitly upgraded.
|
|
50
61
|
|
|
51
62
|
Profiles are `next`, `vite-react`, and `react`. NKLattice can infer them from direct dependencies or read an explicit app profile:
|
|
52
63
|
|
|
@@ -54,11 +65,11 @@ Profiles are `next`, `vite-react`, and `react`. NKLattice can infer them from di
|
|
|
54
65
|
{ "nklattice": { "profile": "next" } }
|
|
55
66
|
```
|
|
56
67
|
|
|
57
|
-
The [reusable governance workflow](.github/workflows/governance-check.yml) requires a reviewed 40-character `core-ref
|
|
68
|
+
The [reusable governance workflow](.github/workflows/governance-check.yml) requires a reviewed 40-character `core-ref`, an exact inventory and an `expected-apps` count. It builds CLI and policy from that commit, installs the scanner toolchain, collects evidence and gates seven domains. The [consumer workflow template](examples/consumer-workflow.yml) pins both the workflow `uses` ref and `core-ref` to the same SHA, with deployment depending on governance. The consumer must keep the two refs equal. For a pnpm monorepo subtree, pass its root as `--workspace-root` when running the CLI directly.
|
|
58
69
|
|
|
59
70
|
```sh
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 governance check ./my-app --policy ./governance/policy.json
|
|
72
|
+
pnpm dlx @anhcodo13/lattice@0.4.0 governance check ./monorepo/apps \
|
|
62
73
|
--workspace-root ./monorepo --policy ./governance/policy.json --expect-apps 3 --json
|
|
63
74
|
```
|
|
64
75
|
|