@sightmap/sightmap 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 +21 -0
- package/README.md +141 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +909 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +279 -0
- package/dist/index.js +650 -0
- package/dist/index.js.map +1 -0
- package/dist/vendored/sightmap.schema.json +141 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Fullstory, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# @sightmap/sightmap
|
|
2
|
+
|
|
3
|
+
Library and CLI for the [Sightmap spec](https://github.com/sightmap/spec).
|
|
4
|
+
|
|
5
|
+
A Sightmap is a YAML description of a web app's views, components, and API requests — the runtime semantics agents need to navigate and interact with the app. This package gives a coding agent a reliable, machine-readable toolkit for curating the `.sightmap/` directory in a customer's repo.
|
|
6
|
+
|
|
7
|
+
## CLI
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
sightmap validate [path] # default path: .sightmap
|
|
11
|
+
sightmap lint [path] [--strict] [--rules <list>]
|
|
12
|
+
sightmap match <url> [path] [--method <m>] [--require-view]
|
|
13
|
+
sightmap explain <query> [path] [--by name|path] [--type view|component|request] [--require-hit]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Every command supports `--json` for machine-readable output and `--cwd <dir>` for invocation from outside the project.
|
|
17
|
+
|
|
18
|
+
### Examples
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Validate the schema of every YAML file under .sightmap/
|
|
22
|
+
$ sightmap validate
|
|
23
|
+
ok .sightmap/views.yaml
|
|
24
|
+
ok .sightmap/components.yaml
|
|
25
|
+
2 file(s) checked.
|
|
26
|
+
|
|
27
|
+
# Lint, asking for JSON
|
|
28
|
+
$ sightmap lint --json
|
|
29
|
+
{
|
|
30
|
+
"ok": true,
|
|
31
|
+
"command": "lint",
|
|
32
|
+
"diagnostics": [
|
|
33
|
+
{ "severity": "warning", "code": "duplicate-route", "message": "Route \"/\" is defined by both ..." }
|
|
34
|
+
],
|
|
35
|
+
"result": {}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Resolve everything an agent needs to drive the URL /list/abc123
|
|
39
|
+
$ sightmap match /list/abc123
|
|
40
|
+
view ListDetailScreen (route /list/*)
|
|
41
|
+
source app/list/[id].tsx
|
|
42
|
+
comp BottomTabBar global selector=[role="tablist"]
|
|
43
|
+
comp ListCard global selector=[data-testid="list-card"]
|
|
44
|
+
...
|
|
45
|
+
|
|
46
|
+
# Find every entry tied to a particular source file
|
|
47
|
+
$ sightmap explain 'app/(tabs)/index.tsx'
|
|
48
|
+
4 hit(s) for "app/(tabs)/index.tsx":
|
|
49
|
+
view ArcList matchedAs=path src=app/(tabs)/index.tsx
|
|
50
|
+
component CreateArcButton matchedAs=path src=app/(tabs)/index.tsx
|
|
51
|
+
component StatusFilter matchedAs=path src=app/(tabs)/index.tsx
|
|
52
|
+
component ArcCard matchedAs=path src=app/(tabs)/index.tsx
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Exit codes
|
|
56
|
+
|
|
57
|
+
- `0` — success
|
|
58
|
+
- `1` — logical failure (validation error, `--strict` warning, `--require-view`/`--require-hit` miss)
|
|
59
|
+
- `2` — usage error
|
|
60
|
+
|
|
61
|
+
For `lint`, default mode exits `0` even with warnings. Pass `--strict` to upgrade all warnings (including merge-time collisions surfaced by `loadDirectory`) to errors.
|
|
62
|
+
|
|
63
|
+
### URL handling for `match`
|
|
64
|
+
|
|
65
|
+
`match` accepts either a pathname (`/foo/bar`) or an absolute URL (`https://example.com/foo/bar`). It strips scheme, host, query string, and fragment before resolving. Trailing slashes are normalized. Matching is case-sensitive.
|
|
66
|
+
|
|
67
|
+
Routes use the spec's glob syntax: `*` matches one segment, `**` matches any depth, `:param` segments normalize to `*`.
|
|
68
|
+
|
|
69
|
+
### `--json` envelope
|
|
70
|
+
|
|
71
|
+
Every command emits the same top-level shape so agents can dispatch on `command`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"ok": true,
|
|
76
|
+
"command": "match",
|
|
77
|
+
"diagnostics": [],
|
|
78
|
+
"result": { "...": "command-specific" }
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Library
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import {
|
|
86
|
+
parse,
|
|
87
|
+
validate,
|
|
88
|
+
merge,
|
|
89
|
+
loadDirectory,
|
|
90
|
+
match,
|
|
91
|
+
explain,
|
|
92
|
+
lint,
|
|
93
|
+
} from "@sightmap/sightmap";
|
|
94
|
+
|
|
95
|
+
const sightmap = await loadDirectory(".sightmap");
|
|
96
|
+
|
|
97
|
+
const r = match(sightmap, { url: "/search" });
|
|
98
|
+
console.log(r.view?.name, r.components.length);
|
|
99
|
+
|
|
100
|
+
const hits = explain(sightmap, "src/components/Foo.tsx");
|
|
101
|
+
const issues = await lint(sightmap, { root: process.cwd() });
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
`parse()` throws on invalid input; `validate()` returns a non-throwing `Result`. **Downstream packages should consume `validate()`,** not `parse()`. `parse()` is sugar for end-user code that knows the input is valid.
|
|
105
|
+
|
|
106
|
+
### Diagnostics
|
|
107
|
+
|
|
108
|
+
Lint and validate share a `Diagnostic` shape:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
type Diagnostic = {
|
|
112
|
+
severity: "error" | "warning" | "info";
|
|
113
|
+
code: string;
|
|
114
|
+
message: string;
|
|
115
|
+
file?: string;
|
|
116
|
+
path?: string; // JSON pointer within the file
|
|
117
|
+
loc?: { line: number; column: number };
|
|
118
|
+
source?: string;
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Codes are stable, kebab-case, and exported as constants:
|
|
123
|
+
|
|
124
|
+
| Code | Severity | Source |
|
|
125
|
+
| ----------------------------- | -------- | ------------------------- |
|
|
126
|
+
| `parse-error` | error | `parse` / `loadDirectory` |
|
|
127
|
+
| `schema-validation-failed` | error | `validate` |
|
|
128
|
+
| `unknown-version` | error | `validate` |
|
|
129
|
+
| `merge-collision-view` | warning | `merge` / `loadDirectory` |
|
|
130
|
+
| `merge-collision-component` | warning | `merge` / `loadDirectory` |
|
|
131
|
+
| `duplicate-view-name` | warning | `lint` |
|
|
132
|
+
| `duplicate-route` | warning | `lint` |
|
|
133
|
+
| `route-shadowing` | warning | `lint` |
|
|
134
|
+
| `unknown-source` | warning | `lint` |
|
|
135
|
+
| `selector-syntax` | warning | `lint` |
|
|
136
|
+
|
|
137
|
+
Renames require an SEP. Future SDK ports (Python, Go) MUST emit identical codes for the same conditions.
|
|
138
|
+
|
|
139
|
+
## License
|
|
140
|
+
|
|
141
|
+
MIT.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|