@coldtea/pr-lens-agent-skill 0.2.0 → 0.3.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/SKILL.md +72 -7
- package/package.json +3 -3
- package/references/config.md +1 -1
- package/references/example.graph.json +1 -1
- package/references/graph-document.md +35 -2
package/SKILL.md
CHANGED
|
@@ -11,11 +11,13 @@ The diff or code is represented as one JSON document (lanes, nodes, edges, order
|
|
|
11
11
|
|
|
12
12
|
## Operating manual
|
|
13
13
|
|
|
14
|
+
Decide where the diagram lands before you write it: a canvas, or an SVG and a pull request comment. Only a canvas draws `payload`, the sample request and response on a flow step. A late decision costs another pass through steps 2 and 3.
|
|
15
|
+
|
|
14
16
|
1. **Read the diff.** When asked to represent a code change: `git diff --find-renames <base>...<head>`. The base is the merge base, not the tip of the base branch.
|
|
15
17
|
|
|
16
18
|
If not expressing a code diff, read the code to be visually represented
|
|
17
19
|
|
|
18
|
-
2. **Write the document** to `.pr-lens/graph.json`, following `references/graph-document.md`. `references/example.graph.json` is valid reference with three lanes, all four delta states, a hero edge, a seven-step flow, a nested drill-down tree and a six-step walkthrough. Read it before you write your first one. It is quicker than reading the reference.
|
|
20
|
+
2. **Write the document** to `.pr-lens/graph.json`, following `references/graph-document.md`. `references/example.graph.json` is valid reference with three lanes, all four delta states, a hero edge, a seven-step flow, a nested drill-down tree and a six-step walkthrough. Read it before you write your first one. It is quicker than reading the reference. If it is going to a canvas, give every flow step (`messages`) that moves data a `payload` as you write it. "Sample traffic on a flow step" below says what goes in one. Only a flow step carries one. Flows need the `data-flow` lens, so an architecture view draws none.
|
|
19
21
|
|
|
20
22
|
3. **Validate, and fix**
|
|
21
23
|
|
|
@@ -28,10 +30,10 @@ The diff or code is represented as one JSON document (lanes, nodes, edges, order
|
|
|
28
30
|
4. **Render.**
|
|
29
31
|
|
|
30
32
|
```bash
|
|
31
|
-
npx @coldtea/pr-lens-cli@latest render .pr-lens/graph.json --theme
|
|
33
|
+
npx @coldtea/pr-lens-cli@latest render .pr-lens/graph.json --theme light
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
Render
|
|
36
|
+
Render light by default unless the user requests another theme. The SVGs, the manifest and `drawn.graph.json` land in `.pr-lens/`, which the CLI adds to the repository's .gitignore. Do not commit any of it. These files are rebuilt from the diff whenever anyone wants them again. Each SVG is named after its view, the theme and a content hash; `manifest.json` lists them by lens and view, so read the names from there or from the directory.
|
|
35
37
|
|
|
36
38
|
If the user asked for a diagram, an explanation or a picture of the architecture and nothing more, put it on a canvas and hand back the link:
|
|
37
39
|
|
|
@@ -50,12 +52,12 @@ The diff or code is represented as one JSON document (lanes, nodes, edges, order
|
|
|
50
52
|
```markdown
|
|
51
53
|
Moves bulk sending off the per-recipient trigger and onto a batch endpoint.
|
|
52
54
|
|
|
53
|
-

|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
```bash
|
|
57
59
|
gh pr create --title "Batch broadcast sends" --body-file .pr-lens/body.md \
|
|
58
|
-
--attach .pr-lens/overview-
|
|
60
|
+
--attach .pr-lens/overview-light-4f9bd6c1.svg
|
|
59
61
|
```
|
|
60
62
|
|
|
61
63
|
On a pull request that already exists, `gh pr edit <number>` with the same two flags puts the diagram in the description, and `gh pr comment <number>` puts it in a comment. Repeat `--attach` for each diagram the body references.
|
|
@@ -161,6 +163,69 @@ The validator checks:
|
|
|
161
163
|
|
|
162
164
|
The field arrived with contract 0.1.1. A CLI older than 0.4.0 does not know it and rejects the whole document as an invented field, so validate with a current one.
|
|
163
165
|
|
|
166
|
+
## Sample traffic on a flow step
|
|
167
|
+
|
|
168
|
+
A flow step can carry a `payload`: what travels on it. Only the canvas draws it, in the rail that opens when a reader clicks a step. Nothing in an SVG or a pull request comment changes. Write it when the document is going to a canvas (step 4, `canvas push`) and leave it out otherwise. Six payloads on the reference document add half its length again, so this is not a field to fill by default.
|
|
169
|
+
|
|
170
|
+
On a canvas document, add it to a step that moves data: a request body, a job record, a query, a result. Leave it off a step that only signals, such as a trigger with nothing attached.
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"id": "batch-post",
|
|
175
|
+
"from": "send-broadcast-bulk",
|
|
176
|
+
"to": "postmark",
|
|
177
|
+
"label": "POST /email/batch",
|
|
178
|
+
"kind": "sync",
|
|
179
|
+
"delta": "added",
|
|
180
|
+
"repeat": 4,
|
|
181
|
+
"payload": {
|
|
182
|
+
"request": {
|
|
183
|
+
"type": "EmailBatch[500]",
|
|
184
|
+
"shape": "Email[] // max 500\nEmail = { From: string; To: string; Subject: string; HtmlBody: string; MessageStream: \"broadcast\"; Metadata: { campaignId: string; batchId: string } }",
|
|
185
|
+
"sample": [
|
|
186
|
+
{
|
|
187
|
+
"From": "news@example.com",
|
|
188
|
+
"To": "ada@example.com",
|
|
189
|
+
"Subject": "The batching issue, fixed",
|
|
190
|
+
"HtmlBody": "<!doctype html><html><body>…",
|
|
191
|
+
"MessageStream": "broadcast",
|
|
192
|
+
"Metadata": { "campaignId": "cmp_0001", "batchId": "b_0001" }
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"before": [
|
|
196
|
+
{
|
|
197
|
+
"From": "news@example.com",
|
|
198
|
+
"To": "ada@example.com",
|
|
199
|
+
"Subject": "The batching issue, fixed",
|
|
200
|
+
"HtmlBody": "<!doctype html><html><body>…",
|
|
201
|
+
"Metadata": { "campaignId": "cmp_0001" }
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
"source": { "path": "tests/fixtures/postmark-batch.json" }
|
|
205
|
+
},
|
|
206
|
+
"response": {
|
|
207
|
+
"type": "BatchResult[500]",
|
|
208
|
+
"shape": "SendResult[] // one per Email, same order",
|
|
209
|
+
"sample": [{ "ErrorCode": 0, "Message": "OK", "To": "ada@example.com", "MessageID": "b7fa5c1e-…" }]
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
A payload has a `request` side, a `response` side, or both. Each side has:
|
|
216
|
+
|
|
217
|
+
- `type`: the name a reader of the code would recognise. Put the count in it when the step carries a collection: `EmailBatch[500]`, not `EmailBatch`. Write `{ "type": "void" }` for a side that carries nothing, such as the answer to a fire and forget call.
|
|
218
|
+
- `shape`: the type signature as text, taken from the code's own types. Up to 2048 bytes.
|
|
219
|
+
- `sample`: one exemplar instance after the change, written inline as JSON. It is a JSON value, not a JSON string: `"sample": [{ "To": "ada@example.com" }]`, never `"sample": "[{\"To\": ...}]"`. A string here is rejected. Every key once, one element in any array, long strings cut with an ellipsis. At most 8 levels deep and 4096 bytes once serialised. The parser refuses a sample over either cap rather than trimming it.
|
|
220
|
+
- `before`: the same exemplar as it was before the change, when it differs. Same rules as `sample`, and it needs a `sample` to differ from.
|
|
221
|
+
- `source`: the fixture or type the shape and sample came from, as a file reference. It becomes the permalink.
|
|
222
|
+
|
|
223
|
+
Use placeholder values: `ada@example.com`, `cmp_0001`. Never copy a value from a fixture that could belong to a real person or unlock something, even in test data.
|
|
224
|
+
|
|
225
|
+
Do not write `changedPaths`. The paths that differ between `before` and `sample` are worked out when the document is stored. A list you write is discarded.
|
|
226
|
+
|
|
227
|
+
The field arrived with contract 0.2.0. A CLI built before it rejects the whole document as an invented field, so validate with a current one.
|
|
228
|
+
|
|
164
229
|
## What the validator will catch
|
|
165
230
|
|
|
166
231
|
Read `references/graph-document.md` before writing. The four failures that account for nearly everything:
|
|
@@ -172,14 +237,14 @@ Read `references/graph-document.md` before writing. The four failures that accou
|
|
|
172
237
|
| `DUPLICATE_ID` | two nodes, edges or views sharing an id |
|
|
173
238
|
| `UNSUPPORTED_SCHEMA_VERSION` | `schemaVersion` is not the contract version installed |
|
|
174
239
|
|
|
175
|
-
|
|
240
|
+
Seven rules cannot be expressed in JSON Schema and are checked only by the parser, so structured output alone does not make a document valid: referential integrity, a line range that ends before it starts, a `self` message whose endpoints disagree, a patch whose two commits are the same, more views than a render manifest could describe, a walkthrough step focusing flow steps the diagram on its stage does not draw, and sample traffic past its depth or byte caps. Always validate.
|
|
176
241
|
|
|
177
242
|
## Fixing a map instead of writing one
|
|
178
243
|
|
|
179
244
|
When someone says the diagram is wrong (a node is misnamed, a folder should not be on it, something sits in the wrong lane), do not edit the generated document. It is regenerated on every run. Write the correction into `.github/pr-lens.yml`, which is an overlay applied over fresh inference every time:
|
|
180
245
|
|
|
181
246
|
```yaml
|
|
182
|
-
schemaVersion: 0.
|
|
247
|
+
schemaVersion: 0.2.0
|
|
183
248
|
map:
|
|
184
249
|
rename:
|
|
185
250
|
- match: functions/src/broadcast/sendBroadcastBulk.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coldtea/pr-lens-agent-skill",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The PR Lens skill for coding agents: author a graph document from a diff, validate it, render it, and correct a repository's map.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Coldtea AI",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"typescript": "7.0.2",
|
|
35
35
|
"vitest": "4.1.11",
|
|
36
36
|
"yaml": "^2.8.1",
|
|
37
|
-
"@coldtea/pr-lens-
|
|
38
|
-
"@coldtea/pr-lens-
|
|
37
|
+
"@coldtea/pr-lens-schema": "^0.3.0",
|
|
38
|
+
"@coldtea/pr-lens-renderer": "^0.2.5"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"skill:sync": "tsx scripts/sync.ts",
|
package/references/config.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
The generated document is regenerated on every run, so editing it is pointless. Corrections live in `.github/pr-lens.yml`, an overlay applied over fresh inference every time. Inference never writes back into this file, which is why a correction keeps holding as the code moves.
|
|
4
4
|
|
|
5
5
|
```yaml
|
|
6
|
-
schemaVersion: 0.
|
|
6
|
+
schemaVersion: 0.2.0 # required
|
|
7
7
|
lenses: [architecture, data-flow]
|
|
8
8
|
branding: true
|
|
9
9
|
map:
|
|
@@ -10,7 +10,7 @@ Every schema here is **strict**: an unknown key is a rejection, not a warning. A
|
|
|
10
10
|
|
|
11
11
|
```json
|
|
12
12
|
{
|
|
13
|
-
"schemaVersion": "0.
|
|
13
|
+
"schemaVersion": "0.2.0",
|
|
14
14
|
"kind": "graph",
|
|
15
15
|
"title": "Batch broadcast sending through Postmark",
|
|
16
16
|
"summary": "One paragraph answering: what does this change do?",
|
|
@@ -114,6 +114,39 @@ Up to 16, for the data-flow lens.
|
|
|
114
114
|
- `kind` is `sync`, `async`, `return` or `self`. `self` requires `from === to`, and no other kind may have them equal.
|
|
115
115
|
- Both endpoints must be participants of that flow, not merely nodes of the document.
|
|
116
116
|
- `repeat` says a step happens more than once per run, e.g. 4 batched requests.
|
|
117
|
+
- `payload`: what travels on the step. Optional. Only a canvas draws it, so leave it out of a document that is not going to one.
|
|
118
|
+
|
|
119
|
+
### Sample traffic
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"id": "send",
|
|
124
|
+
"from": "send-broadcast-bulk",
|
|
125
|
+
"to": "postmark",
|
|
126
|
+
"label": "POST /email/bulk",
|
|
127
|
+
"kind": "sync",
|
|
128
|
+
"delta": "added",
|
|
129
|
+
"payload": {
|
|
130
|
+
"request": {
|
|
131
|
+
"type": "EmailBatch[500]",
|
|
132
|
+
"shape": "Email[] // max 500\nEmail = { From: string; To: string; Subject: string }",
|
|
133
|
+
"sample": [{ "From": "news@example.com", "To": "ada@example.com", "Subject": "The batching issue, fixed" }],
|
|
134
|
+
"before": [{ "From": "news@example.com", "To": "ada@example.com", "Cc": "ops@example.com", "Subject": "The batching issue, fixed" }],
|
|
135
|
+
"source": { "path": "tests/fixtures/postmark-batch.json" }
|
|
136
|
+
},
|
|
137
|
+
"response": { "type": "void" }
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- A payload has `request`, `response` or both. One with neither is rejected.
|
|
143
|
+
- `type` is required on a side: a name a reader of the code would know, with the count in it for a collection (`EmailBatch[500]`). `void` for a side that carries nothing.
|
|
144
|
+
- `shape` is the type signature as text, up to 2048 bytes.
|
|
145
|
+
- `sample` and `before` are JSON values written inline, not JSON strings. A string where a value belongs is rejected. Each is at most 8 levels deep and 4096 bytes once serialised. The parser refuses a value over either cap rather than truncating it.
|
|
146
|
+
- `before` needs a `sample` to differ from.
|
|
147
|
+
- `source` is a file reference, the fixture or type the side was taken from.
|
|
148
|
+
- `changedPaths` is filled in when the document is stored, from `before` and `sample`. Do not write it. Up to 64 paths of the form `Metadata.batchId`, `[0].Cc` or `headers["Content-Type"]`.
|
|
149
|
+
- Use placeholder values in samples: `ada@example.com`, `cmp_0001`. Never one that could belong to a real person or unlock anything.
|
|
117
150
|
|
|
118
151
|
## Stats
|
|
119
152
|
|
|
@@ -267,7 +300,7 @@ Repository-relative POSIX paths: no leading `/`, no drive letter, no backslash,
|
|
|
267
300
|
|
|
268
301
|
## Length limits
|
|
269
302
|
|
|
270
|
-
Labels 120 characters, summaries 2000, chip values 32. They are display fields: a label that needs 120 characters is a label the diagram cannot draw.
|
|
303
|
+
Labels 120 characters, summaries 2000, chip values 32. They are display fields: a label that needs 120 characters is a label the diagram cannot draw. On a payload side, `shape` 2048 bytes, `sample` and `before` 4096 bytes each once serialised and 8 levels deep, `changedPaths` 64 entries.
|
|
271
304
|
|
|
272
305
|
## Then validate
|
|
273
306
|
|