opencode-azure-devops-pr-review 0.3.1 → 0.3.3

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +128 -86
  3. package/package.json +2 -11
  4. package/src/attribution.mjs +2 -4
  5. package/src/azure.mjs +5 -2
  6. package/src/host.mjs +28 -5
  7. package/src/runtime.mjs +13 -7
  8. package/src/session.mjs +6 -12
  9. package/AGENTS.md +0 -164
  10. package/CODE_OF_CONDUCT.md +0 -83
  11. package/CONTRIBUTING.md +0 -84
  12. package/SECURITY.md +0 -38
  13. package/config/settings.example.json +0 -55
  14. package/config/settings.schema.json +0 -316
  15. package/docs/ARCHITECTURE.md +0 -414
  16. package/docs/AZURE_DEVOPS.md +0 -217
  17. package/docs/COMMENTING.md +0 -399
  18. package/docs/DEBUGGING.md +0 -146
  19. package/docs/DEMO.md +0 -195
  20. package/docs/ENTERPRISE.md +0 -236
  21. package/docs/QUICKSTART.md +0 -238
  22. package/docs/RELEASING.md +0 -95
  23. package/docs/ROADMAP.md +0 -241
  24. package/docs/VALIDATION.md +0 -2127
  25. package/docs/VALIDATION_HISTORY.md +0 -1845
  26. package/docs/VERIFICATION.md +0 -42
  27. package/docs/assets/RECORDING.md +0 -131
  28. package/docs/assets/adjust-findings-teaser.gif +0 -0
  29. package/docs/assets/adjust-preview.png +0 -0
  30. package/docs/assets/adjust-publication.png +0 -0
  31. package/docs/assets/example-comments.md +0 -38
  32. package/docs/assets/generate-demo-gif.py +0 -25
  33. package/docs/assets/generate-demo.mjs +0 -141
  34. package/docs/assets/live-azure-readback.png +0 -0
  35. package/docs/assets/live-preview.png +0 -0
  36. package/docs/assets/live-review-teaser.gif +0 -0
  37. package/docs/assets/live-review.png +0 -0
  38. package/docs/assets/quick-review-demo.gif +0 -0
  39. package/docs/assets/record-terminal.py +0 -124
  40. package/docs/assets/render-terminal-demo.py +0 -168
  41. package/docs/assets/review-example.svg +0 -1
  42. package/docs/assets/walkthrough.svg +0 -1
  43. package/docs/releases/v0.1.0.md +0 -74
  44. package/docs/releases/v0.2.0.md +0 -107
  45. package/docs/releases/v0.2.1.md +0 -65
  46. package/docs/releases/v0.2.2.md +0 -76
  47. package/docs/releases/v0.2.3.md +0 -93
  48. package/docs/releases/v0.3.0.md +0 -125
  49. package/docs/releases/v0.3.1.md +0 -87
  50. package/install.sh +0 -171
  51. package/scripts/merge-settings.py +0 -120
  52. package/uninstall.sh +0 -50
@@ -1,42 +0,0 @@
1
- # Local verification and shell access
2
-
3
- Private reviewers read the remote PR through AZPR's REST-backed tools. The current OpenCode project
4
- does not need a checkout or Git history, and reviews never clone or fetch.
5
-
6
- ## The `shell` setting
7
-
8
- | Value | Behavior |
9
- | --- | --- |
10
- | `deny` (default) | Shell is removed from private reviewers' tool lists and refused if called, regardless of later host rules (enforced through the `permission` hook). Reviewers still read, glob and grep the current project. |
11
- | `ask` | Shell is offered; every command needs your approval in OpenCode. A background review waits while an approval is pending, up to `workflow.stageIdleSeconds` (the stage is then stopped as inactive, `failure=idle`, and retried). |
12
- | `inherit` | Host permission rules decide, as for any agent. |
13
-
14
- The default protects you from prompt injection: reviewers read untrusted PR
15
- content, and an injected instruction must not be able to run commands on your
16
- machine.
17
-
18
- Private reviewers run unattended, so no other request may wait for an approval:
19
- anything the host would ask about (for example a native read, glob or grep
20
- outside the local project, which is what a PR repository path like
21
- `/src/app.ts` looks like to OpenCode) is refused at once with an explanation.
22
- Reviewers read the PR repository only through AZPR's tools.
23
-
24
- When shell is allowed, reviewers may run focused checks — existing tests, a
25
- small reproduction, static analysis — in a fresh temporary directory with files
26
- copied from AZPR tool reads at the exact commit. Commands run with real host
27
- authority; this is not a filesystem, process or network sandbox. Native edit,
28
- write and patch tools stay denied, but those denials do not stop an approved
29
- shell command from writing files. A command that runs longer than
30
- `workflow.stageIdleSeconds` counts as inactivity and stops its stage; raise the
31
- setting (or set `0`) if reviewers need longer checks.
32
-
33
- Execution is optional. Failed tests, missing dependencies or unavailable
34
- execution are observations in the report, not a gate on a source-supported
35
- finding.
36
-
37
- ## Cancellation
38
-
39
- `/pr-stop`, a configured `runTimeoutSeconds` and plugin unload revoke grants and
40
- ask OpenCode to interrupt and settle the sessions; the stage inactivity watchdog
41
- does the same for one stalled stage. They do not roll back command side effects
42
- or terminate detached background processes.
@@ -1,131 +0,0 @@
1
- # Recording a real demonstration
2
-
3
- The capture tools record an actual terminal. They do not generate review
4
- findings, replay a fixture provider, or imitate the Azure DevOps web interface.
5
- They are optional documentation tools, not plugin dependencies.
6
-
7
- ## Prepare a dedicated test
8
-
9
- Use a test repository and a pull request containing a small, deliberate defect.
10
- A pagination change from `items.slice(start, start + size)` to
11
- `items.slice(start, size)` is easy to understand and reproduce. Record the exact
12
- source commit, plugin revision, OpenCode version, selected model IDs, and date.
13
- The model may find the defect, miss it, or find additional issues; show what it
14
- actually returns.
15
-
16
- Use an isolated OpenCode configuration and state directory, set
17
- `outputLanguage` to `en`, and close unrelated conversations. Keep the PAT in an
18
- owner-only file outside the recording directory. Do not print configuration,
19
- provider credentials, host authorization, or personal session history.
20
- Starting the review uses the configured model service. Publishing writes to
21
- Azure DevOps. Confirm that those actions are within the operator's authorized
22
- scope before running them.
23
-
24
- ## Capture the terminal
25
-
26
- `record-terminal.py` needs Python 3 on a POSIX system. Supply the real OpenCode
27
- binary, host URL, and session ID. Set any host authentication in the environment,
28
- not in the command line or recording metadata. This attaches to an existing
29
- OpenCode session; it does not start a review by itself.
30
-
31
- ```sh
32
- python3 docs/assets/record-terminal.py \
33
- --output .local/live-demo/session.cast \
34
- --control .local/live-demo/control.jsonl \
35
- --columns 144 --rows 32 \
36
- --cwd /absolute/path/to/the/test-project \
37
- -- /absolute/path/to/opencode --server http://127.0.0.1:PORT --session SESSION_ID
38
- ```
39
-
40
- Append one JSON object per line to the private control file when a command or
41
- navigation is needed. This sends real terminal input. `submit` sends OpenCode's
42
- extended Enter key; a slash completion may first need Enter to accept it, then
43
- another Enter to submit. Observe the recording or session before submitting a
44
- second time. Do not put passwords or tokens in this file.
45
-
46
- ```json
47
- {"text":"/pr-review https://dev.azure.com/ORG/PROJECT/_git/REPO/pullrequest/NUMBER"}
48
- {"key":"submit"}
49
- ```
50
-
51
- Capture the same conversation through this sequence, waiting for each receipt:
52
-
53
- 1. `/pr-check <test-pr-url>` — configuration and access readiness.
54
- 2. `/pr-review <test-pr-url>` — two reviewers and independent verification.
55
- 3. `/pr-comment <review-id>` — the saved comment preview.
56
- 4. `/pr-comment <review-id> --publish` — the publication receipt.
57
- 5. Repeat the publication command — existing comments return `ALREADY_PRESENT`.
58
- 6. Read the published comments back from Azure DevOps, showing the actual
59
- response. A terminal readback is labeled as such; it is not a browser
60
- screenshot. Keep the successful test comments for inspection.
61
-
62
- Stop the recorder with SIGINT or SIGTERM. This closes its attached terminal;
63
- operate the underlying host and any active review separately. The private cast
64
- has mode `0600`, but it still contains everything that appeared in the terminal.
65
- Inspect every frame and remove sensitive content before publishing it.
66
-
67
- ## Edit timing, not findings
68
-
69
- The renderer needs optional installations of **Pillow**, **pyte**, and either
70
- **FFmpeg** or **imageio-ffmpeg**. For example, install them in a separate Python
71
- virtual environment; they must not be added to the plugin package. The default
72
- font is DejaVu Sans Mono. If it lacks the comment icons, provide an existing
73
- emoji-capable font with `--emoji-font /absolute/path/to/font.ttf`; fonts are not
74
- copied into the media or distributed with this project. Use `--crop-bottom 2`
75
- when the last two terminal rows contain only the local status/path bar and a
76
- blank margin. This crops the rendered viewport, adds a visible crop disclosure,
77
- and leaves the original cast untouched; the rendered image omits the cropped
78
- rows. Crop the empty input box too when it names a chat model that the AZPR run
79
- did not use. Inspect the rows first; never crop a finding or result.
80
-
81
- OpenCode 2.1.4's TUI shows a sidebar on wide terminals. Hide it before the
82
- segments you show by sending its toggle through the control file
83
- (`{"text":"\u0018"}`, then `{"text":"b"}`). Receipts name the private debug
84
- directory, which includes the local path; leave frames that show it out of the
85
- edit.
86
-
87
- Create an edit manifest describing the portions of the original recording to
88
- show. `start` and `end` are seconds in the cast. `seconds` is the output duration.
89
- Use a 60–90 second walkthrough and a separate 10–15 second teaser. Keep the
90
- review, preview, publication, and repeat-publication results readable. Do not
91
- replace model text with hand-written findings. The renderer always labels the
92
- result as an edited terminal replay with shortened waiting time.
93
-
94
- ```json
95
- {
96
- "segments": [
97
- {"start": 2, "end": 7, "seconds": 5, "title": "Review a test PR with a seeded pagination defect"},
98
- {"start": 30, "end": 150, "seconds": 8, "title": "Two reviewers, followed by independent verification"},
99
- {"start": 151, "end": 155, "seconds": 12, "title": "Read the actual review result"}
100
- ],
101
- "screenshots": [
102
- {"at": 155, "name": "live-review.png", "title": "Actual OpenCode review result"}
103
- ]
104
- }
105
- ```
106
-
107
- The example times above are placeholders, not measurements. Select times from
108
- an actual completed recording before rendering:
109
-
110
- ```sh
111
- python3 docs/assets/render-terminal-demo.py \
112
- .local/live-demo/session.cast .local/live-demo/walkthrough-edit.json \
113
- --output .local/live-demo/azpr-live-demo.mp4
114
-
115
- python3 docs/assets/render-terminal-demo.py \
116
- .local/live-demo/session.cast .local/live-demo/teaser-edit.json \
117
- --output docs/assets/live-review-teaser.gif --gif --fps 5
118
- ```
119
-
120
- Upload the inspected MP4 as a release attachment; keep large raw recordings
121
- out of Git. Copy only the inspected PNG frames and short GIF into `docs/assets/`.
122
-
123
- The renderer consumes only recorded output in source order. Titles and the
124
- editing disclosure appear outside the terminal content. It does not start
125
- OpenCode, contact a model or Azure DevOps, or alter the recording. Screenshots
126
- are faithful rendered terminal frames, not captures of a desktop browser.
127
-
128
- Before distribution, verify the finished video, GIF, and screenshots, and scan
129
- them and their extracted text for secrets and unrelated private content. Keep
130
- raw casts, host connection files, private evidence and edit manifests under
131
- `.local/`. Publish only inspected media and a concise, redacted evidence note.
Binary file
Binary file
@@ -1,38 +0,0 @@
1
- # Illustrative example / synthetic PR
2
-
3
- These comment bodies are assembled by the project renderer from a hand-written fixture, not a model review. `example/model` is a placeholder. No Azure thread was created. Hidden publication markers are omitted.
4
-
5
- ## Inline thread
6
-
7
- 🟡 medium: Later pages are empty
8
-
9
- **📝 Summary**
10
-
11
- The second and later pages return no items.
12
-
13
- **🔎 Evidence**
14
-
15
- page([1, 2, 3, 4], 2, 1) returns [] instead of [3, 4].
16
-
17
- **💡 Suggested fix**
18
-
19
- Use start + size as the exclusive end of the slice.
20
-
21
- ---
22
- AI-generated review; not human review or approval. Review method: quick review, not independently verified. Models: `example/model`
23
-
24
- ## Summary thread
25
-
26
- 🤖 AI-generated review; not human review or approval. Review method: quick review, not independently verified. Models: `example/model`
27
-
28
- ## PR Review Summary
29
-
30
- **Review notes**
31
-
32
- Adds pagination for a list of items.
33
-
34
- high: 0 · medium: 1 · low: 0
35
-
36
- | Severity | Summary | Location |
37
- | --- | --- | --- |
38
- | 🟡 medium | Q-1 — Later pages are empty | head:/src/pagination.js:3 |
@@ -1,25 +0,0 @@
1
- """Build the optional synthetic walkthrough GIF from generate-demo.mjs --frames.
2
-
3
- Requires an existing Pillow installation; never installs project dependencies.
4
- Run: python3 docs/assets/generate-demo-gif.py
5
- """
6
- from pathlib import Path
7
- from PIL import Image
8
-
9
- assets = Path(__file__).resolve().parent
10
- frames_dir = assets.parent.parent / ".local" / "project-launch-demo-assets"
11
- frames = []
12
- for number in range(1, 5):
13
- with Image.open(frames_dir / f"step-{number}.png") as source:
14
- frames.append(source.convert("RGB"))
15
- assert all(frame.size == (1200, 660) for frame in frames)
16
- frames[0].save(
17
- assets / "quick-review-demo.gif",
18
- save_all=True,
19
- append_images=frames[1:],
20
- duration=[4500, 5500, 5500, 5500],
21
- loop=1, # Play twice, then stop. A static alternative is linked in DEMO.md.
22
- optimize=True,
23
- disposal=2,
24
- )
25
- print("Generated quick-review-demo.gif from four synthetic illustration frames.")
@@ -1,141 +0,0 @@
1
- // Rebuild documentation examples using synthetic data only. No network or model calls.
2
- // Run: node docs/assets/generate-demo.mjs
3
- // Optional PNG frames: AZPR_DEMO_SHARP=/path/to/sharp node ... --frames
4
- import assert from 'node:assert/strict';
5
- import { writeFile, mkdir } from 'node:fs/promises';
6
- import { createRequire } from 'node:module';
7
- import { fileURLToPath } from 'node:url';
8
- import { join } from 'node:path';
9
- import { assemblePlan, evaluatePlanPage } from '../../src/comments.mjs';
10
- import { commentAttribution } from '../../src/attribution.mjs';
11
- import { parsePullRequestUrl } from '../../src/azure.mjs';
12
-
13
- const directory = fileURLToPath(new URL('.', import.meta.url));
14
- const source = ['export function page(items, size, offset) {', ' const start = offset * size;', ' return items.slice(start, size);', '}'];
15
- const finding = {
16
- id: 'Q-1', severity: 'medium', summary: 'Later pages are empty',
17
- location: 'head:/src/pagination.js:3',
18
- evidence: 'page([1, 2, 3, 4], 2, 1) returns [] instead of [3, 4].',
19
- counterevidence: 'The first page works because its start is zero.',
20
- suggestion: 'Use start + size as the exclusive end of the slice.',
21
- };
22
- const sections = [
23
- ['📝 Summary', 'The second and later pages return no items.'],
24
- ['🔎 Evidence', finding.evidence],
25
- ['💡 Suggested fix', finding.suggestion],
26
- ];
27
- const attribution = commentAttribution({ stages: [{ model: 'example/model' }] }, 'en', 'example/model', { verification: 'none' });
28
- const review = {
29
- id: 'synthetic-demo', profile: 'quick', verification: 'none', outputLanguage: 'en', attribution,
30
- target: parsePullRequestUrl('https://dev.azure.com/example-org/example-project/_git/example-repo/pullrequest/42'),
31
- snapshot: { head: '1'.repeat(40), base: '0'.repeat(40), files: ['/src/pagination.js'] },
32
- final: { dispositions: [{ id: finding.id, status: 'REPORTED', finding, inline: true }], newFindings: [] },
33
- toolText: [{ input: { commit: '1'.repeat(40), path: '/src/pagination.js' }, output: source.join('\n') }],
34
- };
35
- const title = `🟡 medium: ${finding.summary}`;
36
- const body = [title, ...sections.map(([heading, text]) => `**${heading}**\n\n${text}`)].join('\n\n');
37
- const page = evaluatePlanPage(JSON.stringify({
38
- status: 'READY', summary: 'Adds pagination for a list of items.', skipped: [],
39
- comments: [{ findingId: finding.id, severity: finding.severity, path: '/src/pagination.js', startLine: 3, endLine: 3, anchor: source[2], body }],
40
- }), { review, assigned: [finding], sources: [{ path: '/src/pagination.js' }] });
41
- assert.deepEqual(page.issues, []);
42
- const plan = assemblePlan(review, [page.result]);
43
- assert.equal(plan.comments.length, 1);
44
- assert.match(plan.comments[0].content, /not independently verified/);
45
- assert.match(plan.summary.content, /Q-1 — Later pages are empty/);
46
- const withoutMarker = value => value.replace(/\n\n<!-- azpr-comment:[a-f0-9]+ -->$/, '');
47
- await writeFile(join(directory, 'example-comments.md'), '# Illustrative example / synthetic PR\n\n' +
48
- 'These comment bodies are assembled by the project renderer from a hand-written fixture, not a model review. `example/model` is a placeholder. No Azure thread was created. Hidden publication markers are omitted.\n\n' +
49
- '## Inline thread\n\n' + withoutMarker(plan.comments[0].content) + '\n\n## Summary thread\n\n' + withoutMarker(plan.summary.content) + '\n');
50
-
51
- const colors = { ink: '#172b4d', muted: '#52637b', blue: '#005a9e', pale: '#edf5fd', line: '#dce5ef', bg: '#f2f6fb', white: '#ffffff', green: '#176b48', yellow: '#8a5900' };
52
- const esc = value => String(value).replace(/[&<>"']/g, char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&apos;' })[char]);
53
- const text = (x, y, value, size = 20, fill = colors.ink, weight = 400, family = 'Arial, sans-serif') => `<text x="${x}" y="${y}" fill="${fill}" font-family="${family}" font-size="${size}" font-weight="${weight}">${esc(value)}</text>`;
54
- const rect = (x, y, w, h, fill = colors.white, radius = 12, stroke = 'none') => `<rect x="${x}" y="${y}" width="${w}" height="${h}" rx="${radius}" fill="${fill}" stroke="${stroke}"/>`;
55
- const line = (x1, y1, x2) => `<path d="M${x1} ${y1}H${x2}" stroke="${colors.line}"/>`;
56
- const svg = (height, title, description, body) => `<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="${height}" viewBox="0 0 1200 ${height}" role="img" aria-labelledby="title desc"><title id="title">${esc(title)}</title><desc id="desc">${esc(description)}</desc>${body}</svg>\n`;
57
- const label = (y = 47) => text(42, y, 'ILLUSTRATIVE EXAMPLE / SYNTHETIC PR', 14, colors.blue, 700);
58
- const wrap = (value, limit) => {
59
- const rows = []; let row = '';
60
- for (const word of value.split(/\s+/)) {
61
- if (row && (row + ' ' + word).length > limit) { rows.push(row); row = word; }
62
- else row += (row ? ' ' : '') + word;
63
- }
64
- if (row) rows.push(row);
65
- return rows;
66
- };
67
- const paragraph = (value, x, y, limit, size = 20, fill = colors.ink, spacing = 28) => wrap(value, limit).map((row, i) => text(x, y + i * spacing, row, size, fill)).join('');
68
- const plainDisclosure = attribution.replaceAll('`', '');
69
- const renderedTitle = plan.comments[0].body.split('\n')[0].replace('🟡 ', '');
70
- const summaryLines = plan.summary.content.split('\n');
71
- const summaryCounts = summaryLines.find(row => row.startsWith('high:'));
72
- const [, severityCell, summaryCell, locationCell] = summaryLines.find(row => row.startsWith('| 🟡')).split('|').map(cell => cell.trim());
73
- const hero = svg(1088, 'Azure DevOps comment format: synthetic quick-review example',
74
- 'Illustrative layout, not an Azure screenshot. One medium finding about pagination is shown as an inline comment and a summary index. Quick review is explicitly not independently verified. Exact accessible comment text is linked in the demo guide.',
75
- rect(0, 0, 1200, 1088, colors.bg, 0) + label() +
76
- text(42, 94, 'Review findings, where your team works.', 34, colors.ink, 700) +
77
- text(42, 128, 'Azure DevOps-style layout · Real comment renderer · Hand-written fixture', 19, colors.muted) +
78
- rect(40, 156, 1120, 552, colors.white, 14, colors.line) +
79
- rect(40, 156, 1120, 46, colors.blue, 12) + rect(40, 184, 1120, 18, colors.blue, 0) +
80
- text(64, 186, 'Example project / Pull request #42 / Files', 19, colors.white, 700) +
81
- text(64, 236, 'src/pagination.js', 19, colors.ink, 700, 'Consolas, monospace') +
82
- rect(64, 254, 1072, 118, '#f6f8fa', 8) + rect(64, 312, 1072, 26, '#e7f4ec', 0) +
83
- source.map((row, i) => text(82, 279 + i * 26, `${i + 1} ${row}`, 18, colors.ink, 400, 'Consolas, monospace')).join('') +
84
- `<circle cx="77" cy="409" r="8" fill="#b87900"/>` +
85
- text(96, 416, renderedTitle, 24, colors.ink, 700) +
86
- sections.map(([heading, detail], i) => text(64, 460 + i * 65, heading.slice(3).trim(), 17, colors.blue, 700) + text(64, 486 + i * 65, detail, 20)).join('') +
87
- line(64, 635, 1136, 635) + paragraph(plainDisclosure, 64, 659, 106, 16, colors.muted, 23) +
88
- rect(40, 730, 1120, 288, colors.white, 14, colors.line) +
89
- text(64, 770, 'PR Review Summary', 27, colors.ink, 700) +
90
- text(64, 804, page.result.summary, 20) +
91
- text(64, 838, summaryCounts, 18, colors.muted) +
92
- rect(64, 856, 1072, 37, colors.pale, 5) +
93
- text(80, 881, 'Severity', 17, colors.blue, 700) + text(232, 881, 'Summary', 17, colors.blue, 700) + text(776, 881, 'Location', 17, colors.blue, 700) +
94
- text(80, 923, severityCell.replace('🟡 ', ''), 19, colors.yellow, 700) + text(232, 923, summaryCell, 19) + text(776, 923, locationCell, 17, colors.ink, 400, 'Consolas, monospace') +
95
- paragraph(plainDisclosure, 64, 963, 106, 16, colors.muted, 23) +
96
- text(42, 1059, 'No live model call or Azure publication. Colors and spacing are illustrative; comment text is renderer-generated.', 16, colors.muted));
97
- await writeFile(join(directory, 'review-example.svg'), hero);
98
-
99
- const steps = [
100
- { name: 'Check setup', command: '/pr-check <azure-pr-url>', status: 'PR access and model readiness', color: colors.blue, lines: ['Check PR, source and discussion access,', 'plus plugin configuration and model readiness.'], detail: 'Resolve errors and inspect warnings before starting a review.', note: 'This command does not call a review model.' },
101
- { name: 'Run a quick review', command: '/pr-quick <azure-pr-url>', status: 'REPORTED · verification: none', color: colors.yellow, lines: ['One reviewer per shard covers function and risk.', 'The example finding: later pages are empty.'], detail: 'Inspect the report and any coverage gaps.', note: 'No independent verifier. A session can make several model requests.' },
102
- { name: 'Preview comments', command: '/pr-comment', status: 'Preview · no Azure write', color: colors.blue, lines: ['A model plans the inline comment and summary.', 'Review the proposed text before publishing.'], detail: 'The saved preview includes the quick-review disclosure.', note: 'Comment planning is additional model work.' },
103
- { name: 'Publish when ready', command: '/pr-comment --publish', status: 'Optional · explicit Azure write', color: colors.green, lines: ['The runtime rechecks the PR and publishes', 'the saved preview, skipping existing markers.'], detail: 'The receipt reports which items were published or skipped.', note: 'Shown as a workflow step only. Nothing was published for this demo.' },
104
- ];
105
- function frame(step, index) {
106
- return svg(660, `Illustrative quick review: step ${index + 1}, ${step.name}`, 'Synthetic workflow illustration, not a live OpenCode recording. No timing or review-accuracy claim.',
107
- rect(0, 0, 1200, 660, colors.bg, 0) + label() + text(42, 99, 'From setup to a comment preview', 34, colors.ink, 700) +
108
- text(42, 133, 'A synthetic walkthrough. Your report and runtime notices will differ.', 19, colors.muted) +
109
- steps.map((item, n) => rect(42 + n * 284, 164, 268, 48, n === index ? colors.blue : '#e4ebf4', 9) + text(58 + n * 284, 195, `${n + 1}. ${item.name}`, 18, n === index ? colors.white : colors.muted, 700)).join('') +
110
- rect(42, 240, 1118, 343, colors.white, 14, colors.line) +
111
- text(68, 282, `STEP ${index + 1} / 4`, 15, colors.blue, 700) +
112
- rect(66, 305, 1070, 63, '#172b4d', 9) + text(88, 346, '> ' + step.command, 25, colors.white, 400, 'Consolas, monospace') +
113
- text(68, 410, step.status, 24, step.color, 700) +
114
- step.lines.map((value, n) => text(68, 453 + n * 33, value, 24)).join('') +
115
- text(68, 546, step.detail, 20, colors.muted) +
116
- text(42, 622, step.note, 18, colors.muted));
117
- }
118
- const frames = steps.map(frame);
119
- const walkthrough = svg(1100, 'Four-step quick review walkthrough',
120
- 'Synthetic example: run pr-check and pr-quick with an Azure pull request URL, preview with pr-comment, then optionally publish with pr-comment --publish. No model call or Azure publication was made for this illustration.',
121
- rect(0, 0, 1200, 1100, colors.bg, 0) + label() + text(42, 99, 'Your first review, step by step', 34, colors.ink, 700) +
122
- steps.map((step, index) => {
123
- const y = 142 + index * 228;
124
- return rect(42, y, 1118, 204, colors.white, 12, colors.line) +
125
- text(66, y + 36, `${index + 1}. ${step.name}`, 24, colors.ink, 700) +
126
- text(66, y + 76, step.command, 24, colors.blue, 700, 'Consolas, monospace') +
127
- text(66, y + 116, step.status, 20, step.color, 700) +
128
- text(66, y + 153, step.lines.join(' '), 20) + text(66, y + 184, step.note, 17, colors.muted);
129
- }).join('') + text(42, 1080, 'Illustrative example / synthetic PR. No live model call or Azure publication.', 17, colors.muted));
130
- await writeFile(join(directory, 'walkthrough.svg'), walkthrough);
131
- if (process.argv.includes('--frames')) {
132
- // Optional documentation tooling, never a plugin dependency. Uses an already installed Sharp package.
133
- const require = createRequire(import.meta.url);
134
- const sharp = require(process.env.AZPR_DEMO_SHARP || 'sharp');
135
- const frameDirectory = fileURLToPath(new URL('../../.local/project-launch-demo-assets/', import.meta.url));
136
- await mkdir(frameDirectory, { recursive: true });
137
- await sharp(Buffer.from(hero)).png().toFile(join(frameDirectory, 'review-example.png'));
138
- await sharp(Buffer.from(walkthrough)).png().toFile(join(frameDirectory, 'walkthrough.png'));
139
- for (let i = 0; i < frames.length; i++) await sharp(Buffer.from(frames[i])).png().toFile(join(frameDirectory, `step-${i + 1}.png`));
140
- }
141
- console.log('Generated synthetic comment text, review-example.svg and walkthrough.svg.');
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Record an actual terminal as asciicast v2 without changing its output.
3
-
4
- Optional control JSONL: {"text": "/pr-check ..."}, {"key": "submit"}.
5
- No credentials, environment, or command arguments are copied into the cast.
6
- The recording itself can contain private data; inspect it before publication.
7
- """
8
- import argparse
9
- import codecs
10
- import errno
11
- import fcntl
12
- import json
13
- import os
14
- from pathlib import Path
15
- import pty
16
- import select
17
- import signal
18
- import struct
19
- import termios
20
- import time
21
-
22
- parser = argparse.ArgumentParser(description=__doc__)
23
- parser.add_argument('--output', required=True, type=Path)
24
- parser.add_argument('--control', type=Path, help='Private append-only JSONL control file')
25
- parser.add_argument('--cwd', type=Path, default=Path.cwd())
26
- parser.add_argument('--columns', type=int, default=128)
27
- parser.add_argument('--rows', type=int, default=38)
28
- parser.add_argument('command', nargs=argparse.REMAINDER)
29
- args = parser.parse_args()
30
- command = args.command[1:] if args.command[:1] == ['--'] else args.command
31
- if not command:
32
- parser.error('Supply the terminal command after --')
33
- if not 40 <= args.columns <= 240 or not 10 <= args.rows <= 100:
34
- parser.error('Unsupported terminal dimensions')
35
- os.umask(0o077)
36
- args.output.parent.mkdir(parents=True, exist_ok=True)
37
- recording = args.output.open('x', encoding='utf-8')
38
- recording.write(json.dumps({'version': 2, 'width': args.columns, 'height': args.rows,
39
- 'timestamp': int(time.time()),
40
- 'env': {'TERM': 'xterm-256color', 'SHELL': '/bin/sh'}}) + '\n')
41
- recording.flush()
42
- started = time.monotonic()
43
- pid, descriptor = pty.fork()
44
- if pid == 0:
45
- os.chdir(args.cwd)
46
- env = {**os.environ, 'TERM': 'xterm-256color', 'COLORTERM': 'truecolor',
47
- 'COLUMNS': str(args.columns), 'LINES': str(args.rows)}
48
- os.execvpe(command[0], command, env)
49
- fcntl.ioctl(descriptor, termios.TIOCSWINSZ, struct.pack('HHHH', args.rows, args.columns, 0, 0))
50
- stop = False
51
-
52
-
53
- def stopping(_number, _frame):
54
- global stop
55
- stop = True
56
-
57
-
58
- signal.signal(signal.SIGINT, stopping)
59
- signal.signal(signal.SIGTERM, stopping)
60
- decoder = codecs.getincrementaldecoder('utf-8')('replace')
61
- control_offset = 0
62
- control_pending = b''
63
- keys = {'submit': b'\x1b[13u', 'enter': b'\r', 'escape': b'\x1b',
64
- 'page-up': b'\x1b[5~', 'page-down': b'\x1b[6~', 'clear-input': b'\x15'}
65
- print(json.dumps({'status': 'recording', 'pid': os.getpid(), 'terminalPid': pid}), flush=True)
66
- try:
67
- while not stop:
68
- if select.select([descriptor], [], [], 0.1)[0]:
69
- try:
70
- chunk = os.read(descriptor, 65536)
71
- except OSError as error:
72
- if error.errno == errno.EIO:
73
- break
74
- raise
75
- if not chunk:
76
- break
77
- text = decoder.decode(chunk)
78
- if text:
79
- recording.write(json.dumps([round(time.monotonic() - started, 6), 'o', text]) + '\n')
80
- recording.flush()
81
- # Answer terminal capability queries, exactly as a terminal does.
82
- if b'\x1b[6n' in chunk:
83
- os.write(descriptor, b'\x1b[1;1R')
84
- if b'\x1b[c' in chunk:
85
- os.write(descriptor, b'\x1b[?1;2c')
86
- if args.control and args.control.exists():
87
- with args.control.open('rb') as control:
88
- control.seek(control_offset)
89
- addition = control.read()
90
- control_offset = control.tell()
91
- control_pending += addition
92
- while b'\n' in control_pending:
93
- line, control_pending = control_pending.split(b'\n', 1)
94
- if not line.strip():
95
- continue
96
- action = json.loads(line)
97
- if set(action) == {'text'} and isinstance(action['text'], str):
98
- os.write(descriptor, action['text'].encode())
99
- elif set(action) == {'key'} and action['key'] in keys:
100
- os.write(descriptor, keys[action['key']])
101
- else:
102
- raise ValueError('Unknown terminal control action')
103
- finally:
104
- try:
105
- os.kill(pid, signal.SIGTERM)
106
- except ProcessLookupError:
107
- pass
108
- deadline = time.monotonic() + 5
109
- while True:
110
- waited, child_status = os.waitpid(pid, os.WNOHANG)
111
- if waited:
112
- break
113
- if time.monotonic() >= deadline:
114
- os.kill(pid, signal.SIGKILL)
115
- _, child_status = os.waitpid(pid, 0)
116
- break
117
- time.sleep(0.05)
118
- os.close(descriptor)
119
- tail = decoder.decode(b'', final=True)
120
- if tail:
121
- recording.write(json.dumps([round(time.monotonic() - started, 6), 'o', tail]) + '\n')
122
- recording.close()
123
- print(json.dumps({'status': 'stopped', 'seconds': round(time.monotonic() - started, 3),
124
- 'terminalExitCode': os.waitstatus_to_exitcode(child_status)}), flush=True)