@erdemtuna/doc-review 0.9.0 → 0.10.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/README.md +52 -227
- package/lib/anchor-text.js +155 -0
- package/lib/atomic-write.js +54 -0
- package/lib/chrome-api.js +78 -0
- package/lib/chrome-client.js +2255 -0
- package/lib/chrome-session.js +76 -0
- package/lib/cli.js +255 -0
- package/lib/click-target.js +28 -0
- package/lib/comment-anchor.js +23 -0
- package/lib/comment-target.js +164 -0
- package/lib/comparison-view.js +380 -0
- package/lib/contracts/feedback.js +1 -0
- package/lib/contracts/frame.js +7 -0
- package/lib/contracts/history.js +1 -0
- package/lib/contracts/index.js +2 -0
- package/lib/contracts/page.js +23 -0
- package/lib/document-execution.js +115 -0
- package/lib/edit-limits.js +24 -0
- package/lib/editing.js +107 -0
- package/lib/execution-client.js +69 -0
- package/lib/feedback-controller.js +106 -0
- package/lib/frame-channel.js +42 -0
- package/lib/frame-controller.js +313 -0
- package/lib/frame-host.js +136 -0
- package/lib/frame-policy.js +50 -0
- package/lib/history-client.js +112 -0
- package/lib/history-coordinator.js +210 -0
- package/lib/history-policy.js +43 -0
- package/lib/history-server.js +464 -0
- package/lib/html-transform.js +52 -0
- package/lib/icons.js +249 -0
- package/{src → lib}/markdown.js +25 -26
- package/lib/paths.js +83 -0
- package/lib/poll-transport.js +220 -0
- package/lib/positioning.js +97 -0
- package/lib/review-controller.js +93 -0
- package/lib/review-mode.js +66 -0
- package/lib/revision-diff.js +482 -0
- package/lib/revision-schema.js +235 -0
- package/lib/revision-store.js +190 -0
- package/lib/save-controller.js +300 -0
- package/lib/sdk.js +2629 -0
- package/lib/semantic-snapshot.js +268 -0
- package/lib/serialize.js +32 -0
- package/lib/server-entry.js +26 -0
- package/lib/server-lock.js +109 -0
- package/lib/server.js +1501 -0
- package/lib/setup-guidance.js +119 -0
- package/{src → lib}/setup.js +44 -55
- package/lib/state.js +733 -0
- package/lib/view-identity.js +112 -0
- package/package.json +24 -14
- package/src/anchor-text.js +0 -160
- package/src/atomic-write.js +0 -53
- package/src/chrome-client.js +0 -2747
- package/src/chrome-session.js +0 -85
- package/src/cli.js +0 -271
- package/src/click-target.js +0 -26
- package/src/comment-anchor.js +0 -22
- package/src/comment-target.js +0 -164
- package/src/comparison-view.js +0 -337
- package/src/document-execution.js +0 -103
- package/src/edit-limits.js +0 -23
- package/src/editing.js +0 -99
- package/src/execution-client.js +0 -63
- package/src/frame-channel.js +0 -44
- package/src/frame-policy.js +0 -54
- package/src/history-client.js +0 -104
- package/src/history-coordinator.js +0 -186
- package/src/history-policy.js +0 -43
- package/src/history-server.js +0 -463
- package/src/html-transform.js +0 -62
- package/src/icons.js +0 -251
- package/src/paths.js +0 -91
- package/src/poll-transport.js +0 -222
- package/src/positioning.js +0 -107
- package/src/review-mode.js +0 -59
- package/src/revision-diff.js +0 -440
- package/src/revision-schema.js +0 -219
- package/src/revision-store.js +0 -177
- package/src/sdk.js +0 -2607
- package/src/semantic-snapshot.js +0 -230
- package/src/serialize.js +0 -32
- package/src/server-entry.js +0 -26
- package/src/server-lock.js +0 -101
- package/src/server.js +0 -1466
- package/src/setup-guidance.js +0 -128
- package/src/state.js +0 -732
- package/src/view-identity.js +0 -99
- /package/{src → lib}/SKILL.md +0 -0
- /package/{src → lib}/chrome.css +0 -0
- /package/{src → lib}/chrome.html +0 -0
- /package/{src → lib}/document-trust.js +0 -0
package/src/setup-guidance.js
DELETED
|
@@ -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
|
-
}
|