@brainwav/diagram 1.0.7 → 1.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/.diagram/contracts/machine-command-coverage.json +73 -0
- package/.diagram/migration/finalization-policy.json +20 -0
- package/LICENSE +202 -21
- package/README.md +132 -339
- package/package.json +46 -13
- package/scripts/refresh-diagram-context.sh +274 -182
- package/src/analyzers/default-analyzer.js +11 -0
- package/src/analyzers/index.js +34 -0
- package/src/artifacts/agent-context.js +105 -0
- package/src/artifacts/artifact-budget.js +224 -0
- package/src/artifacts/brief.js +153 -0
- package/src/artifacts/evidence-manifest.js +206 -0
- package/src/artifacts/evidence-summary.js +29 -0
- package/src/commands/analyze.js +125 -0
- package/src/commands/changed.js +185 -0
- package/src/commands/context.js +110 -0
- package/src/commands/diff.js +142 -0
- package/src/commands/doctor.js +335 -0
- package/src/commands/explain.js +273 -0
- package/src/commands/generate-all.js +170 -0
- package/src/commands/generate-animated.js +50 -0
- package/src/commands/generate-video.js +65 -0
- package/src/commands/generate.js +522 -0
- package/src/commands/init.js +123 -0
- package/src/commands/output.js +76 -0
- package/src/commands/scan.js +624 -0
- package/src/commands/shared.js +396 -0
- package/src/commands/validate.js +328 -0
- package/src/commands/video-shared.js +105 -0
- package/src/commands/workflow-pr.js +26 -0
- package/src/confidence/pipeline.js +186 -0
- package/src/config/diagramrc.js +79 -0
- package/src/context/build-context-pack.js +291 -0
- package/src/context/normalize-diagram-manifest.js +282 -0
- package/src/core/analysis-generation-analyze-components.js +102 -0
- package/src/core/analysis-generation-analyze-dependencies.js +33 -0
- package/src/core/analysis-generation-analyze-files.js +48 -0
- package/src/core/analysis-generation-analyze-options.js +73 -0
- package/src/core/analysis-generation-analyze.js +63 -0
- package/src/core/analysis-generation-constants.js +53 -0
- package/src/core/analysis-generation-diagrams-core-architecture.js +105 -0
- package/src/core/analysis-generation-diagrams-core-dependency.js +68 -0
- package/src/core/analysis-generation-diagrams-core-sequence.js +142 -0
- package/src/core/analysis-generation-diagrams-core-shapes.js +104 -0
- package/src/core/analysis-generation-diagrams-core.js +12 -0
- package/src/core/analysis-generation-diagrams-empty.js +68 -0
- package/src/core/analysis-generation-diagrams-erd.js +59 -0
- package/src/core/analysis-generation-diagrams-limit.js +27 -0
- package/src/core/analysis-generation-diagrams-role-ai-agent.js +103 -0
- package/src/core/analysis-generation-diagrams-role-ai-context.js +186 -0
- package/src/core/analysis-generation-diagrams-role-ai.js +11 -0
- package/src/core/analysis-generation-diagrams-role-data.js +182 -0
- package/src/core/analysis-generation-diagrams-role-helpers.js +129 -0
- package/src/core/analysis-generation-diagrams-role-security.js +129 -0
- package/src/core/analysis-generation-diagrams-role.js +25 -0
- package/src/core/analysis-generation-diagrams.js +182 -0
- package/src/core/analysis-generation-role-tags-constants.js +55 -0
- package/src/core/analysis-generation-role-tags-imports.js +32 -0
- package/src/core/analysis-generation-role-tags-infer.js +49 -0
- package/src/core/analysis-generation-role-tags-match.js +19 -0
- package/src/core/analysis-generation-role-tags.js +7 -0
- package/src/core/analysis-generation-utils-core.js +308 -0
- package/src/core/analysis-generation-utils-graph.js +321 -0
- package/src/core/analysis-generation-utils-resolution.js +76 -0
- package/src/core/analysis-generation-utils.js +9 -0
- package/src/core/analysis-generation.js +44 -0
- package/src/diagram.js +180 -1760
- package/src/formatters/console.js +198 -0
- package/src/formatters/index.js +41 -0
- package/src/formatters/json.js +113 -0
- package/src/formatters/junit.js +123 -0
- package/src/graph.js +159 -0
- package/src/incremental/cache.js +210 -0
- package/src/ir/architecture-ir.js +48 -0
- package/src/migration/evidence.js +262 -0
- package/src/migration/finalization-policy.js +35 -0
- package/src/renderers/report-html.js +265 -0
- package/src/rules/factory.js +108 -0
- package/src/rules/types/base.js +54 -0
- package/src/rules/types/import-rule.js +286 -0
- package/src/rules.js +380 -0
- package/src/schema/erd-confidence.js +56 -0
- package/src/schema/erd-extractor.js +504 -0
- package/src/schema/erd-model.js +176 -0
- package/src/schema/rules-schema.js +170 -0
- package/src/utils/suggestions.js +67 -0
- package/src/video.js +4 -5
- package/src/workflow/git-helpers.js +576 -0
- package/src/workflow/pr-command.js +694 -0
- package/src/workflow/pr-impact.js +848 -0
- package/src/workflow/sort-utils.js +16 -0
package/README.md
CHANGED
|
@@ -1,400 +1,186 @@
|
|
|
1
|
-
#
|
|
1
|
+
# archscope
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Architecture evidence for humans and AI coding agents.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
12
|
-
- [
|
|
13
|
-
- [
|
|
14
|
-
- [
|
|
15
|
-
- [Output formats](#output-formats)
|
|
16
|
-
- [Video and animation prerequisites](#video-and-animation-prerequisites)
|
|
17
|
-
- [Architecture Testing](#architecture-testing)
|
|
18
|
-
- [Documentation](#documentation)
|
|
7
|
+
- [Overview](#overview)
|
|
8
|
+
- [Quick Start](#quick-start)
|
|
9
|
+
- [Architecture Evidence Pack](#architecture-evidence-pack)
|
|
10
|
+
- [Human Workflows](#human-workflows)
|
|
11
|
+
- [AI Agent Workflows](#ai-agent-workflows)
|
|
12
|
+
- [Machine Output Contracts](#machine-output-contracts)
|
|
13
|
+
- [Migration State](#migration-state)
|
|
14
|
+
- [Documentation Index](#documentation-index)
|
|
19
15
|
- [Development](#development)
|
|
20
|
-
- [
|
|
16
|
+
- [Distribution](#distribution)
|
|
21
17
|
|
|
22
|
-
##
|
|
18
|
+
## Overview
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
`
|
|
26
|
-
|
|
20
|
+
`archscope` is the canonical CLI identity for the `@brainwav/diagram` package.
|
|
21
|
+
The compatibility command `diagram` remains available during the migration
|
|
22
|
+
window for existing scripts.
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
Before you review a PR, run Archscope. Before an AI agent edits a repo, give it
|
|
25
|
+
Archscope evidence.
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
You point it at a repo.
|
|
32
|
-
It scans files.
|
|
33
|
-
It finds links.
|
|
34
|
-
It prints a clear graph.
|
|
35
|
-
You can save that graph.
|
|
36
|
-
You can save PNG or SVG files.
|
|
37
|
-
You can make short video clips.
|
|
38
|
-
You can test code layer rules.
|
|
39
|
-
You can run it on your laptop.
|
|
40
|
-
You can run it in CI.
|
|
41
|
-
The goal is simple: keep the code map clear and keep rule drift low.
|
|
27
|
+
The CLI scans your repository and produces architecture evidence:
|
|
42
28
|
|
|
43
|
-
|
|
29
|
+
- A default evidence pack (`scan`) for first-run review and agent handoff
|
|
30
|
+
- PR architecture impact reports (`workflow pr`)
|
|
31
|
+
- AI-context artifacts (`context`)
|
|
32
|
+
- Architecture policy validation (`validate`)
|
|
33
|
+
- Mermaid diagrams (`generate`, `generate-all`), including schema-backed ERD output
|
|
44
34
|
|
|
45
|
-
|
|
46
|
-
# Clone and link locally
|
|
47
|
-
git clone https://github.com/jscraik/diagram-cli.git
|
|
48
|
-
cd diagram-cli
|
|
49
|
-
npm install
|
|
50
|
-
npm link
|
|
51
|
-
```
|
|
35
|
+
Default resolution precedence for scan parameters is explicit:
|
|
52
36
|
|
|
53
|
-
|
|
37
|
+
1. CLI flags
|
|
38
|
+
2. `.diagramrc`
|
|
39
|
+
3. command built-ins
|
|
54
40
|
|
|
55
|
-
|
|
56
|
-
# Analyze repository structure
|
|
57
|
-
diagram analyze .
|
|
41
|
+
This applies to `patterns`, `exclude`, `maxFiles`, and `theme` where relevant.
|
|
58
42
|
|
|
59
|
-
|
|
60
|
-
diagram generate .
|
|
61
|
-
|
|
62
|
-
# Generate all diagram types into ./diagrams
|
|
63
|
-
diagram all .
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## First-run checklist
|
|
67
|
-
|
|
68
|
-
Use a small test repo first.
|
|
69
|
-
Run from the repo root.
|
|
70
|
-
Start with `diagram analyze .`.
|
|
71
|
-
Read the file and link count.
|
|
72
|
-
Next, run `diagram generate .`.
|
|
73
|
-
Save one file with `--output`.
|
|
74
|
-
Pick `.mmd` for text output.
|
|
75
|
-
Pick `.svg` for image output.
|
|
76
|
-
Use `diagram all .` for all views.
|
|
77
|
-
Use `--max-files` if runs are slow.
|
|
78
|
-
Keep path globs short and clear.
|
|
79
|
-
Skip build and vendored dirs.
|
|
80
|
-
Try `diagram test --init` for rules.
|
|
81
|
-
Then run `diagram test` to check rules.
|
|
82
|
-
Use `--dry-run` when match sets look odd.
|
|
83
|
-
Use `--verbose` if you need more detail.
|
|
84
|
-
Run `npm test` to check local health.
|
|
85
|
-
Run `npm run test:deep` for deep checks.
|
|
86
|
-
|
|
87
|
-
## Commands
|
|
88
|
-
|
|
89
|
-
### `diagram analyze [path]`
|
|
90
|
-
|
|
91
|
-
Analyze file structure and dependencies without rendering a diagram.
|
|
43
|
+
## Quick Start
|
|
92
44
|
|
|
93
45
|
```bash
|
|
94
|
-
|
|
95
|
-
diagram
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
Options:
|
|
101
|
-
|
|
102
|
-
- `-p, --patterns <list>` file patterns (default: `**/*.ts,**/*.tsx,**/*.js,**/*.jsx,**/*.py,**/*.go,**/*.rs`)
|
|
103
|
-
- `-e, --exclude <list>` exclude patterns
|
|
104
|
-
- `-m, --max-files <n>` max files to analyze (default: `100`)
|
|
105
|
-
- `-j, --json` JSON output
|
|
106
|
-
|
|
107
|
-
### `diagram generate [path]`
|
|
108
|
-
|
|
109
|
-
Generate one Mermaid diagram and print a preview URL.
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
diagram generate .
|
|
113
|
-
diagram generate . --type sequence
|
|
114
|
-
diagram generate . --focus src/api
|
|
115
|
-
diagram generate . --theme dark
|
|
116
|
-
diagram generate . --output diagram.mmd
|
|
117
|
-
diagram generate . --output diagram.svg
|
|
118
|
-
diagram generate . --open
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Options:
|
|
122
|
-
|
|
123
|
-
- `-t, --type <type>` `architecture|sequence|dependency|class|flow|database|user|events|auth|security` (default: `architecture`)
|
|
124
|
-
- `-f, --focus <module>` focus on one module or directory
|
|
125
|
-
- `-o, --output <file>` write `.mmd`, `.svg`, or `.png`
|
|
126
|
-
- `-m, --max-files <n>` max files to analyze
|
|
127
|
-
- `--theme <theme>` `default|dark|forest|neutral`
|
|
128
|
-
- `--open` open generated preview URL
|
|
129
|
-
|
|
130
|
-
### `diagram all [path]`
|
|
131
|
-
|
|
132
|
-
Generate all diagram types in one run.
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
diagram all .
|
|
136
|
-
diagram all . --output-dir ./docs/diagrams
|
|
46
|
+
git clone https://github.com/jscraik/diagram-cli.git
|
|
47
|
+
cd diagram-cli
|
|
48
|
+
npm install
|
|
49
|
+
npm link
|
|
137
50
|
```
|
|
138
51
|
|
|
139
|
-
|
|
52
|
+
After `npm link`, use `archscope ...` for new workflows. Without `npm link`, run
|
|
53
|
+
commands with `node src/diagram.js ...`.
|
|
140
54
|
|
|
141
|
-
|
|
55
|
+
## Architecture Evidence Pack
|
|
142
56
|
|
|
143
|
-
|
|
57
|
+
The default evidence pack gives humans a short architecture brief and gives AI
|
|
58
|
+
coding agents a manifest-first context path.
|
|
144
59
|
|
|
145
|
-
|
|
60
|
+
Use this path for new repositories:
|
|
146
61
|
|
|
147
62
|
```bash
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
63
|
+
archscope init .
|
|
64
|
+
archscope doctor .
|
|
65
|
+
archscope scan .
|
|
151
66
|
```
|
|
152
67
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
- `-d, --manifest-dir <dir>` directory containing `manifest.json` (default: `.diagram`)
|
|
156
|
-
- `-o, --output <file>` write summary JSON to file
|
|
157
|
-
- `--require-types <list>` require specific diagram types, comma-separated
|
|
158
|
-
- `--fail-on-placeholder` fail if any diagram entry is a placeholder
|
|
68
|
+
What this gives you:
|
|
159
69
|
|
|
160
|
-
|
|
70
|
+
- `.architecture.yml` starter rules
|
|
71
|
+
- `.diagramrc` defaults
|
|
72
|
+
- CI step sample at `.diagram/ci/github-actions-step.yml`
|
|
73
|
+
- toolchain diagnostics before CI rollout
|
|
74
|
+
- `.diagram/manifest.json` as the stable artifact index
|
|
75
|
+
- `.diagram/brief.md` as the human architecture brief
|
|
76
|
+
- `.diagram/report.html` as the human architecture report
|
|
77
|
+
- `.diagram/agent-context.json` as the canonical agent handoff
|
|
78
|
+
- `.diagram/architecture.mmd` as the first architecture diagram
|
|
161
79
|
|
|
162
|
-
|
|
80
|
+
For PR review evidence, add git refs:
|
|
163
81
|
|
|
164
82
|
```bash
|
|
165
|
-
|
|
166
|
-
diagram video . --type dependency --output architecture.mp4
|
|
167
|
-
diagram video . --duration 8 --fps 60 --width 1920 --height 1080
|
|
83
|
+
archscope scan . --base origin/main --head HEAD
|
|
168
84
|
```
|
|
169
85
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
- `-o, --output <file>` output file (default: `diagram.mp4`)
|
|
174
|
-
- `-d, --duration <sec>` video duration in seconds (default: `5`)
|
|
175
|
-
- `-f, --fps <n>` frames per second (default: `30`)
|
|
176
|
-
- `--width <n>` output width in pixels (default: `1280`)
|
|
177
|
-
- `--height <n>` output height in pixels (default: `720`)
|
|
178
|
-
- `--theme <theme>` `default|dark|forest|neutral` (default: `dark`)
|
|
179
|
-
- `-m, --max-files <n>` max files to analyze (default: `100`)
|
|
86
|
+
That keeps the same evidence pack and adds `.diagram/pr-impact/pr-impact.json`
|
|
87
|
+
when refs resolve. `.diagram/report.html` is written by default and becomes the
|
|
88
|
+
primary human artifact when report generation succeeds.
|
|
180
89
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
Generate an animated SVG with CSS animations.
|
|
90
|
+
## Human Workflows
|
|
184
91
|
|
|
185
92
|
```bash
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
diagram animate . --theme forest
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
Options:
|
|
192
|
-
|
|
193
|
-
- `-t, --type <type>` `architecture|sequence|dependency|class|flow|database|user|events|auth|security` (default: `architecture`)
|
|
194
|
-
- `-o, --output <file>` output file (default: `diagram-animated.svg`)
|
|
195
|
-
- `--theme <theme>` `default|dark|forest|neutral` (default: `dark`)
|
|
196
|
-
- `-m, --max-files <n>` max files to analyze (default: `100`)
|
|
197
|
-
|
|
198
|
-
## Diagram types
|
|
199
|
-
|
|
200
|
-
| Type | Description | Best for |
|
|
201
|
-
| --- | --- | --- |
|
|
202
|
-
| `architecture` | Component hierarchy by directory | Overall structure |
|
|
203
|
-
| `sequence` | Service or module interactions | API and flow analysis |
|
|
204
|
-
| `dependency` | Internal and external imports | Dependency review |
|
|
205
|
-
| `class` | Class-oriented relationships | OOP-heavy codebases |
|
|
206
|
-
| `flow` | Process/data flow | Control-flow mapping |
|
|
207
|
-
| `database` | Database operations and condition paths | Conditional persistence flows |
|
|
208
|
-
| `user` | User-facing entrypoints and handlers | Interaction flow mapping |
|
|
209
|
-
| `events` | Event streams and async channels | Event-driven architecture |
|
|
210
|
-
| `auth` | Authentication and authorization checks | Credential/identity flow |
|
|
211
|
-
| `security` | Security boundaries and trust paths | Threat/risk analysis |
|
|
212
|
-
|
|
213
|
-
## AI-focused diagram outputs
|
|
214
|
-
|
|
215
|
-
For agent workflows, the Mermaid output is especially useful because it is
|
|
216
|
-
compact, textual, and structured. Feeding `.mmd` into an AI at startup lets it
|
|
217
|
-
understand architecture faster than reading all source files.
|
|
218
|
-
|
|
219
|
-
The generated types cover these high-value areas for automated reasoning:
|
|
220
|
-
|
|
221
|
-
- **Database Operations** — conditional record paths (for example "record exists?"
|
|
222
|
-
/ "not found" branches), storage and mutation decisions.
|
|
223
|
-
- **User Actions and Interactions** — user entrypoints and downstream handler
|
|
224
|
-
chains.
|
|
225
|
-
- **Events and Channels** — internal publishers, workers, listeners, and trigger
|
|
226
|
-
paths.
|
|
227
|
-
- **Authentication Flows** — step-by-step identity and credential checks.
|
|
228
|
-
- **Security and Data Flows** — trust boundaries, sensitive components, and
|
|
229
|
-
integrations to support security review and compliance context.
|
|
230
|
-
|
|
231
|
-
When reviewing PRs, run:
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
diagram all . --output-dir .diagram
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
so `.diagram/` includes the new AI-oriented variants beside the classic ones.
|
|
238
|
-
|
|
239
|
-
The command also writes `.diagram/manifest.json` summarizing what diagrams were
|
|
240
|
-
produced and whether any outputs are placeholder/no-data (helpful for CI and
|
|
241
|
-
agent bootstrap checks).
|
|
242
|
-
|
|
243
|
-
## Output formats
|
|
93
|
+
# Analyze repository structure
|
|
94
|
+
archscope analyze .
|
|
244
95
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
- `.svg`/`.png` rendered images (requires Mermaid CLI)
|
|
248
|
-
- `.mp4`/`.webm`/`.mov` video export (requires Playwright + ffmpeg)
|
|
249
|
-
- Animated `.svg` export (requires Playwright)
|
|
250
|
-
- `.diagram/manifest.json` machine-readable artifact index
|
|
96
|
+
# Generate the default evidence pack
|
|
97
|
+
archscope scan .
|
|
251
98
|
|
|
252
|
-
|
|
99
|
+
# Generate one diagram and open preview
|
|
100
|
+
archscope generate . --type architecture --open
|
|
253
101
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
```
|
|
102
|
+
# Analyze only changed files in your branch
|
|
103
|
+
archscope changed . --base origin/main --head HEAD
|
|
257
104
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
Install Playwright browser dependencies:
|
|
261
|
-
|
|
262
|
-
```bash
|
|
263
|
-
npm install
|
|
264
|
-
npx playwright install chromium
|
|
265
|
-
```
|
|
105
|
+
# Explain a local dependency neighborhood
|
|
106
|
+
archscope explain auth-service .
|
|
266
107
|
|
|
267
|
-
|
|
108
|
+
# PR risk/blast-radius report
|
|
109
|
+
archscope workflow pr . --base origin/main --head HEAD --risk-threshold medium --fail-on-risk
|
|
268
110
|
|
|
269
|
-
|
|
270
|
-
|
|
111
|
+
# PR evidence pack for reviewers and agents
|
|
112
|
+
archscope scan . --base origin/main --head HEAD
|
|
271
113
|
```
|
|
272
114
|
|
|
273
|
-
|
|
115
|
+
Optional advanced media output remains available after the evidence path is
|
|
116
|
+
working:
|
|
274
117
|
|
|
275
118
|
```bash
|
|
276
|
-
|
|
277
|
-
|
|
119
|
+
archscope generate-video .
|
|
120
|
+
archscope generate-animated .
|
|
278
121
|
```
|
|
279
122
|
|
|
280
|
-
##
|
|
281
|
-
|
|
282
|
-
Validate codebase architecture against declarative YAML rules
|
|
283
|
-
to prevent architectural drift.
|
|
284
|
-
|
|
285
|
-
### Architecture test quick start
|
|
123
|
+
## AI Agent Workflows
|
|
286
124
|
|
|
287
125
|
```bash
|
|
288
|
-
#
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
# Preview file matching without validating
|
|
295
|
-
diagram test --dry-run
|
|
296
|
-
|
|
297
|
-
# CI-friendly output
|
|
298
|
-
diagram test --format junit --output test-results.xml
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### Configuration (`.architecture.yml`)
|
|
126
|
+
# Stable machine outputs
|
|
127
|
+
archscope scan . --format json --deterministic
|
|
128
|
+
archscope scan . --base origin/main --head HEAD --format json --deterministic
|
|
129
|
+
archscope generate . --type architecture --format json --deterministic
|
|
130
|
+
archscope workflow pr . --base origin/main --head HEAD --format json --deterministic
|
|
302
131
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
- name: "Domain isolation"
|
|
308
|
-
description: "Domain logic should not depend on UI"
|
|
309
|
-
layer: "src/domain"
|
|
310
|
-
must_not_import_from: ["src/ui", "src/components"]
|
|
311
|
-
|
|
312
|
-
- name: "API contract"
|
|
313
|
-
description: "API routes only use domain and shared"
|
|
314
|
-
layer: "src/api"
|
|
315
|
-
may_import_from: ["src/domain", "src/shared", "src/types"]
|
|
316
|
-
must_not_import_from: ["src/ui"]
|
|
317
|
-
|
|
318
|
-
- name: "Test independence"
|
|
319
|
-
description: "Tests should not import other tests"
|
|
320
|
-
layer: "**/*.test.ts"
|
|
321
|
-
must_not_import_from: ["**/*.test.ts", "**/*.spec.ts"]
|
|
132
|
+
# Canonical agent read order
|
|
133
|
+
cat .diagram/manifest.json
|
|
134
|
+
cat .diagram/brief.md
|
|
135
|
+
cat .diagram/agent-context.json
|
|
322
136
|
```
|
|
323
137
|
|
|
324
|
-
|
|
138
|
+
Agents should read `.diagram/manifest.json` first, then consume only artifacts
|
|
139
|
+
whose manifest status is `written`. The standalone `context` command remains
|
|
140
|
+
available for refreshing the older `.diagram/context` pack when existing
|
|
141
|
+
automation depends on it.
|
|
325
142
|
|
|
326
|
-
|
|
327
|
-
| --- | --- |
|
|
328
|
-
| `must_not_import_from` | Forbidden import patterns |
|
|
329
|
-
| `may_import_from` | Whitelist of allowed imports |
|
|
330
|
-
| `must_import_from` | Required import patterns |
|
|
143
|
+
## Machine Output Contracts
|
|
331
144
|
|
|
332
|
-
|
|
145
|
+
- Use `--format json` for machine output.
|
|
146
|
+
- `--json` is a compatibility alias and is normalized to `--format json`.
|
|
147
|
+
- Covered command outputs use the canonical machine envelope with `schemaVersion`,
|
|
148
|
+
`command`, `status`, `meta`, `data`, `errors`, and optional `agentSummary`.
|
|
149
|
+
- Use `--deterministic` for stable ordering/timestamps in machine payloads.
|
|
150
|
+
- JSON-capable command coverage is tracked in
|
|
151
|
+
`.diagram/contracts/machine-command-coverage.json`.
|
|
152
|
+
- `scan --format json` nests the evidence manifest under `data.evidencePack`
|
|
153
|
+
and includes `data.pr` when PR refs are supplied.
|
|
154
|
+
- PR impact JSON nests its analytical payload under `data.prImpact` and includes
|
|
155
|
+
`agentSummary` with:
|
|
156
|
+
- `changedComponents`
|
|
157
|
+
- `riskReasons`
|
|
158
|
+
- `suggestedReviewerChecks`
|
|
333
159
|
|
|
334
|
-
|
|
335
|
-
diagram test [path] [options]
|
|
336
|
-
|
|
337
|
-
Options:
|
|
338
|
-
-c, --config <file> Config file (default: ".architecture.yml")
|
|
339
|
-
-f, --format <format> Output: console, json, junit
|
|
340
|
-
-o, --output <file> Write output to file
|
|
341
|
-
--dry-run Preview file matching
|
|
342
|
-
--verbose Show detailed output
|
|
343
|
-
--init Generate starter config
|
|
344
|
-
--force Overwrite existing config when used with --init
|
|
345
|
-
```
|
|
160
|
+
## Migration State
|
|
346
161
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
| Code | Meaning |
|
|
350
|
-
| --- | --- |
|
|
351
|
-
| 0 | All rules passed |
|
|
352
|
-
| 1 | One or more rules failed |
|
|
353
|
-
| 2 | Configuration error |
|
|
354
|
-
|
|
355
|
-
### CI Integration
|
|
356
|
-
|
|
357
|
-
```yaml
|
|
358
|
-
# .github/workflows/architecture.yml
|
|
359
|
-
name: Architecture
|
|
360
|
-
on: [push, pull_request]
|
|
361
|
-
jobs:
|
|
362
|
-
test:
|
|
363
|
-
runs-on: ubuntu-latest
|
|
364
|
-
steps:
|
|
365
|
-
- uses: actions/checkout@v4
|
|
366
|
-
- uses: actions/setup-node@v4
|
|
367
|
-
- run: npm ci
|
|
368
|
-
- run: npm test
|
|
369
|
-
- run: npm run test:deep
|
|
370
|
-
- run: npm run ci:artifacts
|
|
371
|
-
- uses: actions/upload-artifact@v4
|
|
372
|
-
with:
|
|
373
|
-
name: diagram-ci-artifacts
|
|
374
|
-
path: .diagram
|
|
375
|
-
- uses: dorny/test-reporter@v1
|
|
376
|
-
if: success() || failure()
|
|
377
|
-
with:
|
|
378
|
-
name: Architecture Tests
|
|
379
|
-
path: .diagram/architecture-results.xml
|
|
380
|
-
reporter: java-junit
|
|
381
|
-
```
|
|
162
|
+
Current migration state: `compatibility`.
|
|
382
163
|
|
|
383
|
-
|
|
164
|
+
- Canonical command: `archscope`
|
|
165
|
+
- Compatibility command: `diagram`
|
|
166
|
+
- Package name: `@brainwav/diagram`
|
|
167
|
+
- Finalization policy: `.diagram/migration/finalization-policy.json`
|
|
168
|
+
- Release readiness evidence: `.diagram/migration/releases/<releaseId>/migration-readiness.json`
|
|
169
|
+
- Latest readiness pointer: `.diagram/migration/migration-readiness.json`
|
|
170
|
+
- Append-only readiness ledger: `.diagram/migration/releases/ledger.json`
|
|
384
171
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
- Contributor guide: [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
389
|
-
- Security policy: [SECURITY.md](SECURITY.md)
|
|
390
|
-
- Support policy: [SUPPORT.md](SUPPORT.md)
|
|
391
|
-
- Code of conduct: [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
|
|
392
|
-
- Maintainer docs index: [docs/README.md](docs/README.md)
|
|
393
|
-
- Release history: [CHANGELOG.md](CHANGELOG.md)
|
|
172
|
+
Do not treat the package as renamed or the compatibility command as removable
|
|
173
|
+
until the finalization policy and release evidence prove the required migration
|
|
174
|
+
window. See [Archscope compatibility migration](docs/migration/archscope-compatibility.md).
|
|
394
175
|
|
|
395
|
-
## Documentation
|
|
176
|
+
## Documentation Index
|
|
396
177
|
|
|
397
|
-
|
|
178
|
+
- [CLI reference](docs/cli-reference.md)
|
|
179
|
+
- [Getting started](docs/getting-started.md)
|
|
180
|
+
- [Architecture testing](docs/architecture-testing.md)
|
|
181
|
+
- [Archscope compatibility migration](docs/migration/archscope-compatibility.md)
|
|
182
|
+
- [Migration from dependency-cruiser](docs/migration-from-dependency-cruiser.md)
|
|
183
|
+
- [Maintainer docs index](docs/README.md)
|
|
398
184
|
|
|
399
185
|
## Development
|
|
400
186
|
|
|
@@ -402,9 +188,16 @@ brAInwav - from demo to duty
|
|
|
402
188
|
npm install
|
|
403
189
|
npm test
|
|
404
190
|
npm run test:deep
|
|
191
|
+
npm run migration:readiness
|
|
405
192
|
node src/diagram.js --help
|
|
406
193
|
```
|
|
407
194
|
|
|
408
195
|
## License
|
|
409
196
|
|
|
410
|
-
|
|
197
|
+
Apache 2.0 - see [LICENSE](LICENSE).
|
|
198
|
+
|
|
199
|
+
## Distribution
|
|
200
|
+
|
|
201
|
+
Official installation instructions are maintained in this repository only.
|
|
202
|
+
|
|
203
|
+
Third-party indexes or mirrors may list this project, but they are not affiliated with, endorsed by, or maintained by this project unless explicitly stated here.
|
package/package.json
CHANGED
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainwav/diagram",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"packageManager": "npm@10.9.2",
|
|
5
|
+
"description": "Generate architecture evidence for humans and AI agents",
|
|
5
6
|
"main": "src/diagram.js",
|
|
6
7
|
"bin": {
|
|
8
|
+
"archscope": "src/diagram.js",
|
|
7
9
|
"diagram": "src/diagram.js"
|
|
8
10
|
},
|
|
9
11
|
"scripts": {
|
|
10
|
-
"test": "
|
|
12
|
+
"test": "mocha",
|
|
13
|
+
"test:watch": "mocha --watch",
|
|
11
14
|
"test:deep": "node scripts/deep-regression.js",
|
|
12
|
-
"
|
|
15
|
+
"migration:readiness": "node scripts/validate-archscope-readiness.js",
|
|
16
|
+
"ci:artifacts": "node scripts/assert-ci-artifacts.js",
|
|
13
17
|
"prepublishOnly": "npm test",
|
|
14
18
|
"release:prepare": "bash scripts/release-npm.sh",
|
|
15
19
|
"release:prepare:initial": "bash scripts/release-npm.sh --initial",
|
|
16
20
|
"release:publish": "bash scripts/release-npm.sh --publish",
|
|
17
|
-
"release:publish:initial": "bash scripts/release-npm.sh --publish --initial"
|
|
21
|
+
"release:publish:initial": "bash scripts/release-npm.sh --publish --initial",
|
|
22
|
+
"harness": "echo 'Harness command is disabled in this repo. Run: npm run harness:check' >&2 && exit 1",
|
|
23
|
+
"harness:pr-gates": "bash scripts/harness-pr-gates.sh",
|
|
24
|
+
"prepare": "simple-git-hooks",
|
|
25
|
+
"harness:check": "bash scripts/harness-check.sh",
|
|
26
|
+
"lint": "echo 'No linter configured (plain JS project)' && exit 0",
|
|
27
|
+
"typecheck": "echo 'No TypeScript configured (plain JS project)' && exit 0",
|
|
28
|
+
"audit": "npm audit --audit-level=high",
|
|
29
|
+
"check": "npm test",
|
|
30
|
+
"secrets:staged": "bash scripts/check-staged-secrets.sh",
|
|
31
|
+
"docs:lint": "echo 'No docs linter configured (plain JS project)' && exit 0",
|
|
32
|
+
"docs:style:changed": "bash scripts/check-doc-style.sh",
|
|
33
|
+
"test:related": "bash scripts/check-related-tests.sh",
|
|
34
|
+
"semgrep:changed": "bash scripts/check-semgrep-changed.sh"
|
|
18
35
|
},
|
|
19
36
|
"keywords": [
|
|
20
37
|
"diagrams",
|
|
@@ -24,15 +41,14 @@
|
|
|
24
41
|
"cli"
|
|
25
42
|
],
|
|
26
43
|
"author": "",
|
|
27
|
-
"license": "
|
|
44
|
+
"license": "Apache-2.0",
|
|
28
45
|
"dependencies": {
|
|
29
46
|
"chalk": "^4.1.2",
|
|
30
|
-
"
|
|
31
|
-
"commander": "^12.0.0",
|
|
47
|
+
"commander": "^14.0.3",
|
|
32
48
|
"glob": "^10.0.0",
|
|
33
49
|
"picomatch": "^4.0.3",
|
|
34
|
-
"yaml": "^2.8.
|
|
35
|
-
"zod": "^4.3
|
|
50
|
+
"yaml": "^2.8.4",
|
|
51
|
+
"zod": "^4.4.3"
|
|
36
52
|
},
|
|
37
53
|
"repository": {
|
|
38
54
|
"type": "git",
|
|
@@ -47,14 +63,31 @@
|
|
|
47
63
|
"registry": "https://registry.npmjs.org/"
|
|
48
64
|
},
|
|
49
65
|
"files": [
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
66
|
+
".diagram/contracts/**/*.json",
|
|
67
|
+
".diagram/migration/finalization-policy.json",
|
|
68
|
+
".diagram/migration/migration-readiness.json",
|
|
69
|
+
".diagram/migration/releases/**/*.json",
|
|
70
|
+
"src/**/*.js",
|
|
53
71
|
"README.md",
|
|
54
72
|
"scripts/refresh-diagram-context.sh",
|
|
55
73
|
"LICENSE"
|
|
56
74
|
],
|
|
57
75
|
"engines": {
|
|
58
76
|
"node": ">=18"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"chai": "^4.5.0",
|
|
80
|
+
"mocha": "^11.3.0",
|
|
81
|
+
"simple-git-hooks": "^2.13.1"
|
|
82
|
+
},
|
|
83
|
+
"overrides": {
|
|
84
|
+
"chai": "^4.5.0",
|
|
85
|
+
"serialize-javascript": "^7.0.0",
|
|
86
|
+
"diff": "^8.0.3"
|
|
87
|
+
},
|
|
88
|
+
"simple-git-hooks": {
|
|
89
|
+
"pre-commit": "make hooks-pre-commit",
|
|
90
|
+
"commit-msg": "node scripts/validate-commit-msg.js $1",
|
|
91
|
+
"pre-push": "make hooks-pre-push"
|
|
59
92
|
}
|
|
60
93
|
}
|