@erdemtuna/doc-review 0.9.0 → 0.11.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.
Files changed (103) hide show
  1. package/README.md +58 -222
  2. package/{src → lib}/SKILL.md +5 -2
  3. package/lib/anchor-text.js +155 -0
  4. package/lib/atomic-write.js +54 -0
  5. package/lib/changes-controller.js +184 -0
  6. package/lib/chrome-api.js +78 -0
  7. package/lib/chrome-client.js +1700 -0
  8. package/lib/chrome-session.js +73 -0
  9. package/lib/chrome.html +53 -0
  10. package/lib/cli.js +255 -0
  11. package/lib/click-target.js +28 -0
  12. package/lib/comment-anchor.js +23 -0
  13. package/lib/comment-target.js +164 -0
  14. package/lib/comments-controller.js +109 -0
  15. package/lib/contextual-controller.js +33 -0
  16. package/lib/contracts/feedback.js +1 -0
  17. package/lib/contracts/frame.js +7 -0
  18. package/lib/contracts/history.js +1 -0
  19. package/lib/contracts/index.js +2 -0
  20. package/lib/contracts/page.js +23 -0
  21. package/lib/controller-store.js +96 -0
  22. package/lib/document-execution.js +115 -0
  23. package/lib/edit-limits.js +24 -0
  24. package/lib/editing.js +107 -0
  25. package/lib/execution-client.js +19 -0
  26. package/lib/feedback-controller.js +113 -0
  27. package/lib/feedback-panel-controller.js +161 -0
  28. package/lib/frame-channel.js +42 -0
  29. package/lib/frame-controller.js +313 -0
  30. package/lib/frame-host.js +136 -0
  31. package/lib/frame-policy.js +50 -0
  32. package/lib/history-client.js +112 -0
  33. package/lib/history-coordinator.js +217 -0
  34. package/lib/history-policy.js +43 -0
  35. package/lib/history-server.js +464 -0
  36. package/lib/html-transform.js +52 -0
  37. package/lib/icons.js +325 -0
  38. package/{src → lib}/markdown.js +25 -26
  39. package/lib/paths.js +83 -0
  40. package/lib/poll-transport.js +220 -0
  41. package/lib/positioning.js +97 -0
  42. package/lib/recovery-controller.js +123 -0
  43. package/lib/review-controller.js +93 -0
  44. package/lib/review-mode.js +66 -0
  45. package/lib/revision-diff.js +482 -0
  46. package/lib/revision-schema.js +235 -0
  47. package/lib/revision-store.js +190 -0
  48. package/lib/save-controller.js +303 -0
  49. package/lib/sdk.js +2629 -0
  50. package/lib/semantic-snapshot.js +268 -0
  51. package/lib/serialize.js +32 -0
  52. package/lib/server-entry.js +26 -0
  53. package/lib/server-lock.js +109 -0
  54. package/lib/server.js +1501 -0
  55. package/lib/setup-guidance.js +119 -0
  56. package/{src → lib}/setup.js +44 -55
  57. package/lib/state.js +733 -0
  58. package/lib/toolbar-controller.js +32 -0
  59. package/lib/ui/THIRD_PARTY_NOTICES.md +1254 -0
  60. package/lib/ui/chrome.css +4881 -0
  61. package/lib/ui/chrome.js +52 -0
  62. package/lib/view-identity.js +112 -0
  63. package/package.json +50 -14
  64. package/src/anchor-text.js +0 -160
  65. package/src/atomic-write.js +0 -53
  66. package/src/chrome-client.js +0 -2747
  67. package/src/chrome-session.js +0 -85
  68. package/src/chrome.css +0 -652
  69. package/src/chrome.html +0 -196
  70. package/src/cli.js +0 -271
  71. package/src/click-target.js +0 -26
  72. package/src/comment-anchor.js +0 -22
  73. package/src/comment-target.js +0 -164
  74. package/src/comparison-view.js +0 -337
  75. package/src/document-execution.js +0 -103
  76. package/src/edit-limits.js +0 -23
  77. package/src/editing.js +0 -99
  78. package/src/execution-client.js +0 -63
  79. package/src/frame-channel.js +0 -44
  80. package/src/frame-policy.js +0 -54
  81. package/src/history-client.js +0 -104
  82. package/src/history-coordinator.js +0 -186
  83. package/src/history-policy.js +0 -43
  84. package/src/history-server.js +0 -463
  85. package/src/html-transform.js +0 -62
  86. package/src/icons.js +0 -251
  87. package/src/paths.js +0 -91
  88. package/src/poll-transport.js +0 -222
  89. package/src/positioning.js +0 -107
  90. package/src/review-mode.js +0 -59
  91. package/src/revision-diff.js +0 -440
  92. package/src/revision-schema.js +0 -219
  93. package/src/revision-store.js +0 -177
  94. package/src/sdk.js +0 -2607
  95. package/src/semantic-snapshot.js +0 -230
  96. package/src/serialize.js +0 -32
  97. package/src/server-entry.js +0 -26
  98. package/src/server-lock.js +0 -101
  99. package/src/server.js +0 -1466
  100. package/src/setup-guidance.js +0 -128
  101. package/src/state.js +0 -732
  102. package/src/view-identity.js +0 -99
  103. /package/{src → lib}/document-trust.js +0 -0
@@ -1,128 +0,0 @@
1
- export const GUIDANCE_BEGIN = "<!-- BEGIN doc-review -->";
2
- export const GUIDANCE_END = "<!-- END doc-review -->";
3
-
4
- // Historical generated text is deliberately independent of the current guidance.
5
- const LEGACY_TAIL = `
6
- \`npx -y @erdemtuna/doc-review <file.html>\`. For a locally running web page, open the real
7
- route with \`npx -y @erdemtuna/doc-review http://localhost:3000/path\` instead of recreating
8
- it as a static file. Then block on
9
- \`npx -y @erdemtuna/doc-review poll <target> --timeout 600\` until they send feedback.
10
- If it prints \`{"status":"timeout"}\`, no feedback arrived yet — run the same
11
- poll command again to keep waiting. When a \`{"status":"feedback"}\` batch
12
- arrives, apply it, then run the exact acknowledgement command in its
13
- \`next_step\`, which uses \`--ack <batch_id>\`.
14
-
15
- Keep the poll command in the foreground and do not end the turn while it waits.
16
- If the shell returns a process or session handle, keep waiting on that handle until
17
- the command exits. \`npx -y @erdemtuna/doc-review status <target>\` reports instantly
18
- whether feedback is already waiting, without blocking.
19
-
20
- The batch groups feedback by page under \`pages\`, so fix every page listed. Items
21
- under \`edits\` are changes the user already made: \`after\` is their exact wording,
22
- so carry it across verbatim and never revert it — and if the HTML was generated
23
- from MDX or Markdown, apply it to the source too. Markdown files open rendered
24
- and are never written by doc-review: apply their comments and edits to the
25
- Markdown source, keeping its syntax. There is no reply channel; the user sees
26
- your work when the page reloads. For a localhost page, direct edits and deletions
27
- arrive with \`kind: "url"\`; find and update the matching MDX, TSX, template, or
28
- component source. Never write the rendered HTTP response over project source.`;
29
-
30
- export const LEGACY_GUIDANCE = Object.freeze([
31
- `## Reviewing files and localhost pages with doc-review
32
-
33
- After writing an HTML or Markdown file the user will read, open it for them with${LEGACY_TAIL}`,
34
- `## Reviewing files and localhost pages with doc-review
35
-
36
- Start only when the user explicitly invokes /doc-review or requests an
37
- interactive browser review. Writing, updating, discussing, or generically reviewing
38
- content does not authorize opening a review or polling. Another skill's automatic
39
- review step is not user permission. Otherwise respond normally.
40
-
41
- After that explicit request, open the requested HTML or Markdown file with${LEGACY_TAIL}`,
42
- ]);
43
-
44
- const migrationMessage = "AGENTS.md contains custom or unrecognized doc-review guidance — left it unchanged. " +
45
- "Manually reconcile that guidance, then wrap only the setup-owned section in " +
46
- `${GUIDANCE_BEGIN} and ${GUIDANCE_END}, or remove it and re-run setup.`;
47
-
48
- function invalidMarkers() {
49
- throw new Error("AGENTS.md has malformed, duplicate, or ambiguous doc-review ownership markers. " +
50
- "Keep exactly one standalone BEGIN/END pair in order, then re-run setup. No setup files were changed.");
51
- }
52
-
53
- function render(body, newline) {
54
- return `${GUIDANCE_BEGIN}\n${body.trim()}\n${GUIDANCE_END}`.replaceAll("\n", newline);
55
- }
56
-
57
- /** Plan the complete edit before setup writes any files. Never normalize user text. */
58
- export function updateGuidance(existing, body) {
59
- const lines = [...existing.matchAll(/[^\n]*(?:\n|$)/g)]
60
- .filter((match) => match[0])
61
- .map((match) => ({
62
- text: match[0].replace(/\r?\n$/, ""),
63
- start: match.index,
64
- end: match.index + match[0].replace(/\r?\n$/, "").length,
65
- }));
66
- const markers = lines.filter(({ text }) => /doc-review/i.test(text) &&
67
- (/\b(?:BEGIN|END)\b/i.test(text) && /<!--|-->|^\s*(?:BEGIN|END)\b/i.test(text)));
68
-
69
- if (markers.length) {
70
- if (markers.length !== 2 || markers[0].text !== GUIDANCE_BEGIN || markers[1].text !== GUIDANCE_END) {
71
- invalidMarkers();
72
- }
73
- const [begin, end] = markers;
74
- const newline = existing.slice(begin.end).startsWith("\r\n") ? "\r\n" : "\n";
75
- return {
76
- contents: existing.slice(0, begin.start) + render(body, newline) + existing.slice(end.end),
77
- message: "Updated setup-owned AGENTS.md guidance (Codex)",
78
- };
79
- }
80
-
81
- const candidates = [];
82
- for (const legacy of LEGACY_GUIDANCE) {
83
- for (const command of ["npx -y @erdemtuna/doc-review", "doc-review"]) {
84
- for (const newline of ["\n", "\r\n"]) {
85
- const text = legacy.replaceAll("npx -y @erdemtuna/doc-review", command).replaceAll("\n", newline);
86
- let start = existing.indexOf(text);
87
- while (start !== -1) {
88
- const end = start + text.length;
89
- const before = existing.slice(0, start);
90
- const after = existing.slice(end);
91
- // A complete generated section, not a substring of customized prose.
92
- if ((start === 0 || before.endsWith("\n") || before === "\uFEFF") &&
93
- /^(?:\r?\n|$)/.test(after) &&
94
- /^(?:\s*$|(?:\r?\n)+(?=#{1,2} ))/.test(after)) {
95
- candidates.push({ start, end, newline });
96
- }
97
- start = existing.indexOf(text, start + text.length);
98
- }
99
- }
100
- }
101
- }
102
- if (candidates.length > 1) {
103
- throw new Error("AGENTS.md contains multiple legacy doc-review sections; ownership is ambiguous. " +
104
- "Reconcile them before re-running setup. No setup files were changed.");
105
- }
106
- if (candidates.length === 1) {
107
- const { start, end, newline } = candidates[0];
108
- const surrounding = existing.slice(0, start) + existing.slice(end);
109
- if (!/doc-review/i.test(surrounding)) {
110
- return {
111
- contents: existing.slice(0, start) + render(body, newline) + existing.slice(end),
112
- message: "Migrated legacy AGENTS.md guidance to setup-owned markers (Codex)",
113
- };
114
- }
115
- }
116
- if (/doc-review/i.test(existing)) {
117
- return { contents: existing, message: migrationMessage };
118
- }
119
-
120
- const newline = existing.includes("\r\n") ? "\r\n" : "\n";
121
- const separator = !existing || existing.endsWith(newline + newline)
122
- ? ""
123
- : existing.endsWith("\n") ? newline : newline + newline;
124
- return {
125
- contents: existing + separator + render(body, newline) + newline,
126
- message: `${existing ? "Updated" : "Created"} AGENTS.md (Codex)`,
127
- };
128
- }