@a2f0/agent-tool 0.1.71 → 0.1.72
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/package.json +1 -1
- package/skills/seo-optimization/SKILL.md +6 -3
- package/src/permissions/catalog.ts +1 -1
- package/src/seo/address.ts +117 -0
- package/src/seo/html.ts +217 -33
- package/src/seo/http.ts +20 -9
- package/src/seo/probe.ts +36 -29
- package/src/skills/bundled.ts +1 -1
package/package.json
CHANGED
|
@@ -66,9 +66,12 @@ lists the page's internal links that do not answer 200 directly; and
|
|
|
66
66
|
`--sitemap` checks every sitemap URL's status, canonical, and robots, and
|
|
67
67
|
reports duplicate titles and descriptions. The mode flag comes first, the
|
|
68
68
|
host is a hostname with an optional port, and each path starts with `/`. The
|
|
69
|
-
probe matches
|
|
70
|
-
raw response before acting on it.
|
|
71
|
-
|
|
69
|
+
probe matches text patterns rather than parsing HTML, so confirm anything
|
|
70
|
+
surprising in the raw response before acting on it. A `000` status means no
|
|
71
|
+
response, including a URL it refused to request: one that is not HTTP or
|
|
72
|
+
HTTPS, or one on a private or local address that a page or redirect, not the
|
|
73
|
+
command line, named. Set `SEO_PROBE_USER_AGENT` to a browser user agent to see
|
|
74
|
+
what a zone injects only for browsers.
|
|
72
75
|
|
|
73
76
|
Check whether the default branch already has merged work that has not been
|
|
74
77
|
deployed, because a deploy ships it too. Deployment listings often do not
|
|
@@ -39,7 +39,7 @@ export const CATALOG: CatalogEntry[] = [
|
|
|
39
39
|
{ command: "openPr", class: "share" },
|
|
40
40
|
];
|
|
41
41
|
// `run`, `run-group`, `push-gate run` and `proc start` execute arbitrary commands, so they stay unclassified and keep the harness default.
|
|
42
|
-
// `seo probe` requests whatever
|
|
42
|
+
// `seo probe` requests whatever host its arguments name, and public hosts its fetched pages name, like curl, so it keeps the harness default too.
|
|
43
43
|
// `bun x` runs only executables that `permissions.executables` classifies; project.ts adds those.
|
|
44
44
|
// Package scripts are not classified, so `bun run` keeps the harness default.
|
|
45
45
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which hosts `seo probe` may request when a URL comes from fetched markup or a
|
|
3
|
+
* redirect rather than the command line: a hostile page could otherwise point
|
|
4
|
+
* the probe at this machine or its network (`og:image` on `169.254.169.254`, a
|
|
5
|
+
* sitemap entry on `localhost`) and print what answers.
|
|
6
|
+
*/
|
|
7
|
+
import { lookup as dnsLookup } from "node:dns/promises";
|
|
8
|
+
import { isIP } from "node:net";
|
|
9
|
+
|
|
10
|
+
/** Every address a hostname resolves to; an unresolvable name has none. */
|
|
11
|
+
export type Lookup = (hostname: string) => Promise<string[]>;
|
|
12
|
+
/** Why a URL must not be requested, or undefined when it may be, deciding within `milliseconds`. */
|
|
13
|
+
export type Guard = (url: URL, milliseconds: number) => Promise<string | undefined>;
|
|
14
|
+
|
|
15
|
+
const systemLookup: Lookup = async hostname => (await dnsLookup(hostname, { all: true, verbatim: true })).map(entry => entry.address);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* IPv4 ranges outside the public internet: this network, private, shared
|
|
19
|
+
* (CGNAT), loopback, link-local, IETF protocol assignments, documentation,
|
|
20
|
+
* benchmarking, and multicast or reserved.
|
|
21
|
+
*/
|
|
22
|
+
const V4_RANGES: [string, number][] = [
|
|
23
|
+
["0.0.0.0", 8], ["10.0.0.0", 8], ["100.64.0.0", 10], ["127.0.0.0", 8], ["169.254.0.0", 16], ["172.16.0.0", 12], ["192.0.0.0", 24],
|
|
24
|
+
["192.0.2.0", 24], ["192.168.0.0", 16], ["198.18.0.0", 15], ["198.51.100.0", 24], ["203.0.113.0", 24], ["224.0.0.0", 3],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function ipv4(address: string): number {
|
|
28
|
+
return address.split(".").reduce((value, part) => value * 256 + Number(part), 0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const inRange = (value: number, [base, bits]: [string, number]) => Math.floor(value / 2 ** (32 - bits)) === Math.floor(ipv4(base) / 2 ** (32 - bits));
|
|
32
|
+
const nonPublicV4 = (address: string) => V4_RANGES.some(range => inRange(ipv4(address), range));
|
|
33
|
+
|
|
34
|
+
/** The eight 16-bit groups of an IPv6 address, with a trailing dotted IPv4 part expanded. */
|
|
35
|
+
function ipv6Groups(address: string): number[] {
|
|
36
|
+
let text = address.replace(/%.*$/, "");
|
|
37
|
+
const dotted = /(\d+\.\d+\.\d+\.\d+)$/.exec(text);
|
|
38
|
+
if (dotted) {
|
|
39
|
+
const value = ipv4(dotted[1]!);
|
|
40
|
+
text = `${text.slice(0, dotted.index)}${Math.floor(value / 65536).toString(16)}:${(value % 65536).toString(16)}`;
|
|
41
|
+
}
|
|
42
|
+
const [head = "", tail] = text.split("::");
|
|
43
|
+
const parse = (part: string) => part ? part.split(":").map(group => parseInt(group, 16)) : [];
|
|
44
|
+
const left = parse(head), right = tail === undefined ? [] : parse(tail);
|
|
45
|
+
return [...left, ...Array<number>(8 - left.length - right.length).fill(0), ...right];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const embeddedV4 = (high: number, low: number) => `${high >> 8}.${high & 255}.${low >> 8}.${low & 255}`;
|
|
49
|
+
|
|
50
|
+
/** Loopback, link-local, private, unspecified, multicast, or reserved: anything that is not a public unicast address. */
|
|
51
|
+
export function isNonPublicAddress(address: string): boolean {
|
|
52
|
+
const family = isIP(address.replace(/%.*$/, ""));
|
|
53
|
+
if (family === 4) return nonPublicV4(address);
|
|
54
|
+
if (family !== 6) return true;
|
|
55
|
+
const groups = ipv6Groups(address);
|
|
56
|
+
const [a = 0, b = 0, , , , f = 0, g = 0, h = 0] = groups;
|
|
57
|
+
const zeros = (count: number) => groups.slice(0, count).every(group => group === 0);
|
|
58
|
+
// IPv4-mapped ::ffff:a.b.c.d and IPv4-translated ::ffff:0:a.b.c.d are that IPv4 address; the rest of ::/96 is unspecified, loopback, or deprecated.
|
|
59
|
+
if ((zeros(5) && f === 0xffff) || (zeros(4) && groups[4] === 0xffff && f === 0)) return nonPublicV4(embeddedV4(g, h));
|
|
60
|
+
if (zeros(6)) return true;
|
|
61
|
+
// NAT64 well-known prefix 64:ff9b::/96, and 6to4 2002::/16, which carry an IPv4 address.
|
|
62
|
+
if (a === 0x64 && b === 0xff9b && groups.slice(2, 6).every(group => group === 0)) return nonPublicV4(embeddedV4(g, h));
|
|
63
|
+
if (a === 0x2002) return nonPublicV4(embeddedV4(b, groups[2] ?? 0));
|
|
64
|
+
// Unique local fc00::/7, link-local fe80::/10, site-local fec0::/10, multicast ff00::/8, local-use NAT64 64:ff9b:1::/48,
|
|
65
|
+
// discard 100::/64, Teredo 2001::/32, and documentation 2001:db8::/32.
|
|
66
|
+
return (a & 0xfe00) === 0xfc00 || (a & 0xffc0) === 0xfe80 || (a & 0xffc0) === 0xfec0 || (a & 0xff00) === 0xff00 || (a === 0x64 && b === 0xff9b && groups[2] === 1)
|
|
67
|
+
|| (a === 0x100 && groups.slice(1, 4).every(group => group === 0)) || (a === 0x2001 && (b === 0 || b === 0xdb8));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The promise's value, or undefined when it takes longer than `milliseconds`. */
|
|
71
|
+
async function within<T>(promise: Promise<T>, milliseconds: number): Promise<T | undefined> {
|
|
72
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
73
|
+
try {
|
|
74
|
+
return await Promise.race([promise, new Promise<undefined>(resolve => { timer = setTimeout(resolve, Math.max(0, milliseconds), undefined); })]);
|
|
75
|
+
} finally { clearTimeout(timer); }
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** How long the named host's own lookup may take before the guard assumes it is public. */
|
|
79
|
+
const NAMED_LOOKUP_MILLISECONDS = 15_000;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The guard for URLs that markup or redirects supply, or undefined when every
|
|
83
|
+
* address of the named host is non-public (probing a local server), since then
|
|
84
|
+
* every target is the user's own network. Otherwise a host that is, or resolves
|
|
85
|
+
* to, any non-public address is refused, except the named host itself, which
|
|
86
|
+
* the user chose: a page cannot switch the guard off, or reach this network
|
|
87
|
+
* through another name, by publishing a private record beside a public one.
|
|
88
|
+
* Names resolve once per run through the system resolver, as `fetch` resolves
|
|
89
|
+
* them. A name that does not resolve is left to the request, which fails or
|
|
90
|
+
* goes through a proxy; one that does not resolve within the request's time
|
|
91
|
+
* limit is refused. The check runs just before each request, so a name that
|
|
92
|
+
* resolves differently by the time `fetch` connects (DNS rebinding) is not
|
|
93
|
+
* caught.
|
|
94
|
+
*/
|
|
95
|
+
export async function addressGuard(namedHost: string, lookup: Lookup = systemLookup, namedMilliseconds = NAMED_LOOKUP_MILLISECONDS): Promise<Guard | undefined> {
|
|
96
|
+
const cache = new Map<string, Promise<string[]>>();
|
|
97
|
+
const bare = (hostname: string) => hostname.replace(/^\[|\]$/g, "");
|
|
98
|
+
const addresses = (hostname: string) => {
|
|
99
|
+
let found = cache.get(hostname);
|
|
100
|
+
if (!found) {
|
|
101
|
+
found = isIP(hostname) ? Promise.resolve([hostname]) : lookup(hostname).catch(() => []);
|
|
102
|
+
cache.set(hostname, found);
|
|
103
|
+
}
|
|
104
|
+
return found;
|
|
105
|
+
};
|
|
106
|
+
const named = bare(new URL(`http://${namedHost}/`).hostname);
|
|
107
|
+
const own = await within(addresses(named), namedMilliseconds);
|
|
108
|
+
if (own?.length && own.every(isNonPublicAddress)) return undefined;
|
|
109
|
+
return async (url, milliseconds) => {
|
|
110
|
+
const hostname = bare(url.hostname);
|
|
111
|
+
if (hostname === named) return undefined;
|
|
112
|
+
const found = await within(addresses(hostname), milliseconds);
|
|
113
|
+
if (found === undefined) return `refused ${hostname}: it did not resolve within the request's time limit`;
|
|
114
|
+
const address = found.find(isNonPublicAddress);
|
|
115
|
+
return address === undefined ? undefined : `refused ${hostname} (${address}): a non-public address that the command line did not name`;
|
|
116
|
+
};
|
|
117
|
+
}
|
package/src/seo/html.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* Markup readers for `seo probe`, over HTML with its newlines, carriage
|
|
3
|
+
* returns, and tabs collapsed to spaces. They match what the original shell
|
|
4
|
+
* probe's `grep -oiE` patterns matched (`<meta[^>]+name="description"[^>]*>`
|
|
5
|
+
* and the like): double-quoted attributes only, ASCII case-insensitive, first
|
|
6
|
+
* match or every match in document order, and no HTML parser, so a surprising
|
|
7
|
+
* result needs a look at the raw response. They scan with `indexOf` instead of
|
|
8
|
+
* regular expressions, reading each character a bounded number of times, since
|
|
9
|
+
* a backtracking pattern takes quadratic time on a hostile page with many
|
|
10
|
+
* unterminated tags.
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
13
|
/** The body as one line: `\n`, `\r`, and `\t` become spaces. */
|
|
@@ -11,57 +15,206 @@ export function collapse(body: string): string {
|
|
|
11
15
|
return body.replace(/[\n\r\t]/g, " ");
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
/** ASCII-only lowercase, so every index still points at the same character of the original. */
|
|
19
|
+
const lower = (text: string) => text.replace(/[A-Z]+/g, run => run.toLowerCase());
|
|
15
20
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
return [...text.matchAll(new RegExp(pattern, "gi"))].map(match => match[0]);
|
|
19
|
-
}
|
|
21
|
+
/** Distinct values in code-unit order, each followed by one space. */
|
|
22
|
+
const spaced = (values: string[]) => [...new Set(values)].sort().map(value => `${value} `).join("");
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
export function first(text: string, pattern: string): string {
|
|
23
|
-
return new RegExp(pattern, "i").exec(text)?.[0] ?? "";
|
|
24
|
-
}
|
|
24
|
+
interface Span { start: number; end: number }
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The tags the pattern `<name[^>]+needle[^>]*>` matches, as spans from `<name`
|
|
28
|
+
* through its first `>`: one of `needles` must start at least one character
|
|
29
|
+
* after the name. Of several `<name` before the same `>`, only the first can
|
|
30
|
+
* match (a later one's text is a suffix of it), so the scan resumes after that
|
|
31
|
+
* `>` whether or not the tag matched.
|
|
32
|
+
*/
|
|
33
|
+
function tags(text: string, name: string, needles: string[], limit = Infinity): Span[] {
|
|
34
|
+
const open = `<${name}`, found: Span[] = [];
|
|
35
|
+
for (let from = 0; found.length < limit;) {
|
|
36
|
+
const start = text.indexOf(open, from);
|
|
37
|
+
if (start < 0) break;
|
|
38
|
+
const end = text.indexOf(">", start + open.length);
|
|
39
|
+
if (end < 0) break;
|
|
40
|
+
const inside = text.slice(start + open.length + 1, end);
|
|
41
|
+
if (needles.some(needle => inside.includes(needle))) found.push({ start, end: end + 1 });
|
|
42
|
+
from = end + 1;
|
|
43
|
+
}
|
|
44
|
+
return found;
|
|
29
45
|
}
|
|
30
46
|
|
|
31
|
-
/** Every `name="value"` value in `text`, in order. */
|
|
47
|
+
/** Every `name="value"` value in `text`, in order, as the pattern `name="[^"]*"` finds them. */
|
|
32
48
|
export function attrValues(text: string, name: string): string[] {
|
|
33
|
-
|
|
49
|
+
const lowered = lower(text), opening = `${name}="`, values: string[] = [];
|
|
50
|
+
for (let at = lowered.indexOf(opening); at >= 0; at = lowered.indexOf(opening, at)) {
|
|
51
|
+
const close = lowered.indexOf('"', at + opening.length);
|
|
52
|
+
if (close < 0) break;
|
|
53
|
+
values.push(text.slice(at + opening.length, close));
|
|
54
|
+
at = close + 1;
|
|
55
|
+
}
|
|
56
|
+
return values;
|
|
34
57
|
}
|
|
35
58
|
|
|
36
59
|
/** The same values, one per line. */
|
|
37
60
|
export const attr = (text: string, name: string) => attrValues(text, name).join("\n");
|
|
38
61
|
|
|
62
|
+
/**
|
|
63
|
+
* The `attribute` values in each tag that the pattern
|
|
64
|
+
* `<name[^>]+attribute="[^"]*"` (`[^>]*` when `gap` is 0) matches, as
|
|
65
|
+
* `attrValues` reads them from the match. The pattern needs no closing `>`, so
|
|
66
|
+
* a tag that never closes runs to the end of the text. Its greedy middle ends
|
|
67
|
+
* at the last value that starts before the tag's first `>` and has a closing
|
|
68
|
+
* quote, which may lie past that `>`; the tag matches when that value starts
|
|
69
|
+
* at least `gap` characters after the name. Of several `<name` before the
|
|
70
|
+
* same `>`, only the first can match.
|
|
71
|
+
*/
|
|
72
|
+
function tagValues(text: string, name: string, attribute: string, gap: 0 | 1, limit = Infinity): string[][] {
|
|
73
|
+
const lowered = lower(text), open = `<${name}`, opening = `${attribute}="`, found: string[][] = [];
|
|
74
|
+
for (let from = 0; found.length < limit;) {
|
|
75
|
+
const start = lowered.indexOf(open, from);
|
|
76
|
+
if (start < 0) break;
|
|
77
|
+
const inside = start + open.length, close = lowered.indexOf(">", inside), end = close < 0 ? text.length : close;
|
|
78
|
+
const segment = lowered.slice(inside, end);
|
|
79
|
+
let last = segment.lastIndexOf(opening);
|
|
80
|
+
// Only the final value can lack a closing quote, and then the one before it has one.
|
|
81
|
+
if (last >= 0 && lowered.indexOf('"', inside + last + opening.length) < 0) last = last > 0 ? segment.lastIndexOf(opening, last - 1) : -1;
|
|
82
|
+
from = end + 1;
|
|
83
|
+
if (last >= gap) {
|
|
84
|
+
const values: string[] = [];
|
|
85
|
+
for (let at = segment.indexOf(opening); at >= 0 && at <= last; at = segment.indexOf(opening, at)) {
|
|
86
|
+
const quote = lowered.indexOf('"', inside + at + opening.length);
|
|
87
|
+
values.push(text.slice(inside + at + opening.length, quote));
|
|
88
|
+
at = quote + 1 - inside;
|
|
89
|
+
}
|
|
90
|
+
found.push(values);
|
|
91
|
+
// The match ends at that last value's closing quote, which can lie past the `>`.
|
|
92
|
+
from = Math.max(from, lowered.indexOf('"', inside + last + opening.length) + 1);
|
|
93
|
+
}
|
|
94
|
+
if (close < 0) break;
|
|
95
|
+
}
|
|
96
|
+
return found;
|
|
97
|
+
}
|
|
98
|
+
|
|
39
99
|
/** Decode the predefined XML entities; `&` goes last so `&lt;` stays `<`. */
|
|
40
100
|
export function unescape(value: string): string {
|
|
41
101
|
return value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(/&/g, "&");
|
|
42
102
|
}
|
|
43
103
|
|
|
44
|
-
/** The content of
|
|
45
|
-
|
|
46
|
-
|
|
104
|
+
/** The `content` values of every `<meta>` whose `name` (or `property`) is one of `keys`. */
|
|
105
|
+
function metaContents(body: string, keys: string[], properties: boolean, limit = Infinity): string[] {
|
|
106
|
+
const needles = keys.flatMap(key => [`name="${key}"`, ...(properties ? [`property="${key}"`] : [])]);
|
|
107
|
+
return tags(lower(body), "meta", needles, limit).flatMap(({ start, end }) => attrValues(body.slice(start, end), "content"));
|
|
47
108
|
}
|
|
48
109
|
|
|
110
|
+
/** The content of the first `<meta>` whose property or name is `key`. */
|
|
111
|
+
export const contentOf = (body: string, key: string) => metaContents(body, [key], true, 1).join("\n");
|
|
112
|
+
|
|
113
|
+
/** The content of each robots and googlebot meta tag, in order. */
|
|
114
|
+
export const robotsMetaContents = (body: string) => metaContents(body, ["robots", "googlebot"], false);
|
|
115
|
+
|
|
49
116
|
/** Every robots and googlebot meta directive, lowercase, joined with spaces. */
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
117
|
+
export const robotsMeta = (body: string) => robotsMetaContents(body).join(" ").toLowerCase();
|
|
118
|
+
|
|
119
|
+
/** Each `theme-color` meta tag's content, each followed by one space. */
|
|
120
|
+
export const themeColors = (body: string) => metaContents(body, ["theme-color"], false).map(value => `${value} `).join("");
|
|
53
121
|
|
|
54
122
|
export function titleOf(body: string): string {
|
|
55
|
-
|
|
123
|
+
const lowered = lower(body);
|
|
124
|
+
for (let from = 0; ;) {
|
|
125
|
+
const start = lowered.indexOf("<title", from);
|
|
126
|
+
if (start < 0) return "";
|
|
127
|
+
const close = lowered.indexOf(">", start + 6);
|
|
128
|
+
if (close < 0) return "";
|
|
129
|
+
const next = lowered.indexOf("<", close + 1);
|
|
130
|
+
if (next < 0) return "";
|
|
131
|
+
if (lowered.startsWith("</title>", next)) return body.slice(close + 1, next);
|
|
132
|
+
from = close + 1;
|
|
133
|
+
}
|
|
56
134
|
}
|
|
57
135
|
|
|
58
136
|
export function canonicalOf(body: string): string {
|
|
59
|
-
|
|
137
|
+
const [tag] = tags(lower(body), "link", ['rel="canonical"'], 1);
|
|
138
|
+
return tag ? unescape(attr(body.slice(tag.start, tag.end), "href")) : "";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** The `lang` values of the first `<html>` tag that has one, one per line. */
|
|
142
|
+
export const langOf = (body: string) => (tagValues(body, "html", "lang", 0, 1)[0] ?? []).join("\n");
|
|
143
|
+
|
|
144
|
+
const isLetter = (code: number) => (code >= 97 && code <= 122) || (code >= 65 && code <= 90);
|
|
145
|
+
|
|
146
|
+
/** The distinct `og:` properties present, as `"og:name"`, each followed by one space: the pattern `property="og:[a-z_:]+"`. */
|
|
147
|
+
export function ogProperties(body: string): string {
|
|
148
|
+
const lowered = lower(body), opening = 'property="og:', found: string[] = [];
|
|
149
|
+
for (let from = 0; ;) {
|
|
150
|
+
const start = lowered.indexOf(opening, from);
|
|
151
|
+
if (start < 0) break;
|
|
152
|
+
let end = start + opening.length;
|
|
153
|
+
for (let code = lowered.charCodeAt(end); isLetter(code) || code === 95 || code === 58; code = lowered.charCodeAt(++end));
|
|
154
|
+
if (end > start + opening.length && lowered[end] === '"') { found.push(body.slice(start, end + 1)); from = end + 1; }
|
|
155
|
+
else from = start + 1;
|
|
156
|
+
}
|
|
157
|
+
return spaced(found).replace(/property=/g, "");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** How many times `needle` occurs, ASCII case-insensitively. */
|
|
161
|
+
function count(body: string, needle: string, after?: (next: string | undefined) => boolean): number {
|
|
162
|
+
const lowered = lower(body);
|
|
163
|
+
let total = 0;
|
|
164
|
+
for (let at = lowered.indexOf(needle); at >= 0; at = lowered.indexOf(needle, at + needle.length)) {
|
|
165
|
+
if (!after || after(lowered[at + needle.length])) total++;
|
|
166
|
+
}
|
|
167
|
+
return total;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export const jsonLdBlocks = (body: string) => count(body, "application/ld+json");
|
|
171
|
+
export const h1Count = (body: string) => count(body, "<h1", next => next === " " || next === ">");
|
|
172
|
+
|
|
173
|
+
/** The distinct JSON-LD `@type` values, as `"Name"` or `["A","B"]`, each followed by one space: the pattern `"@type": *("[A-Za-z]+"|\[[^\]]*\])`. */
|
|
174
|
+
export function jsonLdTypes(body: string): string {
|
|
175
|
+
const lowered = lower(body), opening = '"@type":', found: string[] = [];
|
|
176
|
+
let noBracket = false;
|
|
177
|
+
for (let from = 0; ;) {
|
|
178
|
+
const start = lowered.indexOf(opening, from);
|
|
179
|
+
if (start < 0) break;
|
|
180
|
+
let at = start + opening.length;
|
|
181
|
+
while (body[at] === " ") at++;
|
|
182
|
+
let end = -1;
|
|
183
|
+
if (body[at] === '"') {
|
|
184
|
+
let letters = at + 1;
|
|
185
|
+
while (isLetter(body.charCodeAt(letters))) letters++;
|
|
186
|
+
if (letters > at + 1 && body[letters] === '"') end = letters + 1;
|
|
187
|
+
} else if (body[at] === "[" && !noBracket) {
|
|
188
|
+
const close = body.indexOf("]", at + 1);
|
|
189
|
+
if (close < 0) noBracket = true;
|
|
190
|
+
else end = close + 1;
|
|
191
|
+
}
|
|
192
|
+
if (end > 0) { found.push(body.slice(start, end)); from = end; }
|
|
193
|
+
else from = start + 1;
|
|
194
|
+
}
|
|
195
|
+
return spaced(found).replace(/"@type": */g, "");
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Leading and trailing spaces removed, without a pattern that backtracks over a long run of spaces. */
|
|
199
|
+
function trimSpaces(value: string): string {
|
|
200
|
+
let start = 0, end = value.length;
|
|
201
|
+
while (start < end && value[start] === " ") start++;
|
|
202
|
+
while (end > start && value[end - 1] === " ") end--;
|
|
203
|
+
return value.slice(start, end);
|
|
60
204
|
}
|
|
61
205
|
|
|
62
206
|
/** The `<loc>` values of a sitemap, trimmed and decoded. */
|
|
63
207
|
export function locs(body: string): string[] {
|
|
64
|
-
|
|
208
|
+
const text = collapse(body), found: string[] = [];
|
|
209
|
+
for (let from = 0; ;) {
|
|
210
|
+
const start = text.indexOf("<loc>", from);
|
|
211
|
+
if (start < 0) break;
|
|
212
|
+
const next = text.indexOf("<", start + 5);
|
|
213
|
+
if (next < 0) break;
|
|
214
|
+
if (next > start + 5 && text.startsWith("</loc>", next)) { found.push(unescape(trimSpaces(text.slice(start + 5, next)))); from = next + 6; }
|
|
215
|
+
else from = start + 1;
|
|
216
|
+
}
|
|
217
|
+
return found;
|
|
65
218
|
}
|
|
66
219
|
|
|
67
220
|
/** A sitemap or sitemap index document, by its root element. */
|
|
@@ -89,6 +242,32 @@ export function lines(text: string): string[] {
|
|
|
89
242
|
return all;
|
|
90
243
|
}
|
|
91
244
|
|
|
245
|
+
/** Valued robots directives, whose value can be `none` without blocking indexing. */
|
|
246
|
+
const VALUED_DIRECTIVES = new Set(["max-snippet", "max-image-preview", "max-video-preview", "unavailable_after"]);
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Whether a robots value keeps a page out of search: a whole `noindex` or
|
|
250
|
+
* `none` directive, in a list separated by commas or spaces. A valued
|
|
251
|
+
* directive such as `max-image-preview:none` never counts, nor does its value
|
|
252
|
+
* after a space (`max-image-preview: none`). In an
|
|
253
|
+
* `X-Robots-Tag` header (`agentPrefix`), an element may begin with any other
|
|
254
|
+
* `name:`, which names a crawler, as in `googlebot: none` or
|
|
255
|
+
* `googlebot:noindex`; robots meta tags name the crawler in the tag instead.
|
|
256
|
+
*/
|
|
257
|
+
export function blocksIndexing(value: string, agentPrefix: boolean): boolean {
|
|
258
|
+
return value.toLowerCase().split(",").some(element => {
|
|
259
|
+
const tokens = element.trim().split(/\s+/);
|
|
260
|
+
const colon = tokens[0]!.indexOf(":");
|
|
261
|
+
if (agentPrefix && colon >= 0 && !VALUED_DIRECTIVES.has(tokens[0]!.slice(0, colon))) tokens[0] = tokens[0]!.slice(colon + 1);
|
|
262
|
+
for (let index = 0; index < tokens.length; index++) {
|
|
263
|
+
const token = tokens[index]!;
|
|
264
|
+
if (token.endsWith(":") && VALUED_DIRECTIVES.has(token.slice(0, -1))) index++; // the next token is its value
|
|
265
|
+
else if (token === "noindex" || token === "none") return true;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
92
271
|
/**
|
|
93
272
|
* Resolve a relative reference (no scheme, not protocol-relative) against the
|
|
94
273
|
* final document path: a query-only reference against the page itself, any
|
|
@@ -115,6 +294,11 @@ export function resolvePath(reference: string, page: string): string {
|
|
|
115
294
|
return resolved + query;
|
|
116
295
|
}
|
|
117
296
|
|
|
297
|
+
/** Every `href` value of an `<a>` tag, in order, as the pattern `<a[^>]+href="[^"]*"` finds them. */
|
|
298
|
+
export const hrefValues = (body: string) => tagValues(body, "a", "href", 1).flat();
|
|
299
|
+
|
|
300
|
+
const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&");
|
|
301
|
+
|
|
118
302
|
/**
|
|
119
303
|
* The page's links to its own host, as URLs to request: absolute ones exactly
|
|
120
304
|
* as written, protocol-relative ones with the page's scheme, and relative ones
|
|
@@ -124,14 +308,14 @@ export function resolvePath(reference: string, page: string): string {
|
|
|
124
308
|
export function internalLinks(body: string, finalUrl: URL): string[] {
|
|
125
309
|
const origin = `${finalUrl.protocol}//${finalUrl.host}`;
|
|
126
310
|
const host = escapeRegExp(finalUrl.host);
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
.map(href => unescape(href).
|
|
311
|
+
const absolute = new RegExp(`^https?://${host}(?:[/?]|$)`, "i"), relative = new RegExp(`^//${host}(?:[/?]|$)`, "i");
|
|
312
|
+
const hrefs = hrefValues(body)
|
|
313
|
+
.map(href => { const value = unescape(href), hash = value.indexOf("#"); return hash < 0 ? value : value.slice(0, hash); })
|
|
130
314
|
.filter(href => href !== "");
|
|
131
315
|
const links = new Set<string>();
|
|
132
316
|
for (const href of hrefs) {
|
|
133
|
-
if (
|
|
134
|
-
else if (
|
|
317
|
+
if (absolute.test(href)) links.add(href);
|
|
318
|
+
else if (relative.test(href)) links.add(`${finalUrl.protocol}${href}`);
|
|
135
319
|
else if (!/^[a-zA-Z][a-zA-Z0-9+.-]*:|^\/\//.test(href)) links.add(origin + resolvePath(href, finalUrl.pathname));
|
|
136
320
|
}
|
|
137
321
|
return [...links].sort();
|
package/src/seo/http.ts
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* honors the proxy variables a sandboxed harness sets. Only `http:` and `https:`
|
|
4
4
|
* URLs are ever requested, including redirect targets, because URLs come from
|
|
5
5
|
* remote markup (`og:image`, sitemap entries, links, `Location`), and `fetch`
|
|
6
|
-
* itself would also read `file:` and `s3:` URLs.
|
|
7
|
-
*
|
|
6
|
+
* itself would also read `file:` and `s3:` URLs. A URL the command line did not
|
|
7
|
+
* name, and every redirect target, also passes the address guard. Redirects are
|
|
8
|
+
* followed by hand so each hop is checked and the first one can be reported.
|
|
8
9
|
*/
|
|
10
|
+
import type { Guard } from "./address";
|
|
9
11
|
|
|
10
12
|
export interface Reply {
|
|
11
13
|
/** The URL requested. */
|
|
@@ -31,6 +33,10 @@ export interface RequestOptions {
|
|
|
31
33
|
seconds: number;
|
|
32
34
|
/** Read the body; false cancels it once the headers arrive. */
|
|
33
35
|
body?: boolean;
|
|
36
|
+
/** Refuses non-public hosts that markup or redirects supply. */
|
|
37
|
+
guard?: Guard;
|
|
38
|
+
/** The URL is built from the command line's host and path, so the guard skips it (but not its redirects). */
|
|
39
|
+
named?: boolean;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
/** curl's default `--max-redirs` with `-L`. */
|
|
@@ -76,9 +82,11 @@ async function readBody(response: Response): Promise<Uint8Array> {
|
|
|
76
82
|
return body;
|
|
77
83
|
}
|
|
78
84
|
|
|
79
|
-
async function get(target: string, options: RequestOptions, deadline: number): Promise<Reply> {
|
|
85
|
+
async function get(target: string, options: RequestOptions, deadline: number, guarded: boolean): Promise<Reply> {
|
|
80
86
|
const url = webUrl(target);
|
|
81
87
|
if (!url) return failed(target, `refused a URL that is not HTTP or HTTPS: ${target}`);
|
|
88
|
+
const refused = guarded ? await options.guard?.(url, deadline - performance.now()) : undefined;
|
|
89
|
+
if (refused) return failed(target, refused);
|
|
82
90
|
const remaining = deadline - performance.now();
|
|
83
91
|
if (remaining <= 0) return failed(target, `timed out after ${options.seconds} seconds`);
|
|
84
92
|
try {
|
|
@@ -105,20 +113,23 @@ async function get(target: string, options: RequestOptions, deadline: number): P
|
|
|
105
113
|
|
|
106
114
|
/** One request; redirects are reported, not followed. */
|
|
107
115
|
export function request(target: string, options: RequestOptions): Promise<Reply> {
|
|
108
|
-
return get(target, options, performance.now() + options.seconds * 1000);
|
|
116
|
+
return get(target, options, performance.now() + options.seconds * 1000, !options.named);
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
/**
|
|
112
120
|
* Follow redirects (not 304) up to curl's limit within one deadline. The final
|
|
113
|
-
* reply is the last response received; a redirect to a refused scheme
|
|
114
|
-
* chain at that redirect, and a hop that gets no response ends it
|
|
121
|
+
* reply is the last response received; a redirect to a refused scheme or host
|
|
122
|
+
* ends the chain at that redirect, and a hop that gets no response ends it
|
|
123
|
+
* with "000".
|
|
115
124
|
*/
|
|
116
125
|
export async function follow(target: string, options: RequestOptions): Promise<Followed> {
|
|
117
126
|
const deadline = performance.now() + options.seconds * 1000;
|
|
118
|
-
const first = await get(target, options, deadline);
|
|
127
|
+
const first = await get(target, options, deadline, !options.named);
|
|
119
128
|
let final = first;
|
|
120
|
-
for (let hops = 0; hops < MAX_REDIRECTS && final.location && final.code !== "304"
|
|
121
|
-
|
|
129
|
+
for (let hops = 0; hops < MAX_REDIRECTS && final.location && final.code !== "304"; hops++) {
|
|
130
|
+
const next = webUrl(final.location);
|
|
131
|
+
if (!next || await options.guard?.(next, deadline - performance.now())) break;
|
|
132
|
+
final = await get(final.location, options, deadline, false);
|
|
122
133
|
}
|
|
123
134
|
return { first, final };
|
|
124
135
|
}
|
package/src/seo/probe.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `agent-tool seo probe`: a host's live search and preview metadata, for the
|
|
3
3
|
* seo-optimization skill. It reports what the deployed site serves before
|
|
4
|
-
* JavaScript runs; it changes nothing, but it requests
|
|
5
|
-
*
|
|
4
|
+
* JavaScript runs; it changes nothing, but it requests the URLs its arguments
|
|
5
|
+
* name and those the fetched pages name, the latter only on public addresses
|
|
6
|
+
* unless the named host is itself local.
|
|
6
7
|
*/
|
|
7
8
|
import { writeSync } from "node:fs";
|
|
9
|
+
import { addressGuard, type Guard } from "./address";
|
|
8
10
|
import {
|
|
9
|
-
|
|
10
|
-
length, lines, locs,
|
|
11
|
+
blocksIndexing, canonicalOf, clip, collapse, contentOf, h1Count, internalLinks, isSitemapDocument, jsonLdBlocks,
|
|
12
|
+
jsonLdTypes, langOf, length, lines, locs, ogProperties, pngSize, robotsMeta, robotsMetaContents, themeColors, titleOf,
|
|
11
13
|
} from "./html";
|
|
12
14
|
import { follow, request, type Followed, type Reply, type RequestOptions } from "./http";
|
|
13
15
|
|
|
@@ -31,6 +33,8 @@ exits 1 and a usage error exits 2. Set SEO_PROBE_USER_AGENT to send a browser
|
|
|
31
33
|
user agent; SEO_PROBE_SCHEME (default https) exists for tests.`;
|
|
32
34
|
|
|
33
35
|
type Mode = "full" | "page" | "headers" | "links" | "sitemap";
|
|
36
|
+
/** Whether a URL is built from the command line's host and path, or taken from markup or a redirect. */
|
|
37
|
+
type Source = "named" | "markup";
|
|
34
38
|
const MODES: Record<string, Mode> = { "--page": "page", "--headers": "headers", "--links": "links", "--sitemap": "sitemap" };
|
|
35
39
|
|
|
36
40
|
export interface ProbeOptions {
|
|
@@ -39,6 +43,8 @@ export interface ProbeOptions {
|
|
|
39
43
|
paths: string[];
|
|
40
44
|
scheme: "http" | "https";
|
|
41
45
|
userAgent: string;
|
|
46
|
+
/** Refuses non-public hosts from markup; computed from the named host when absent, never switched off by omission. */
|
|
47
|
+
guard?: Guard;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
class UsageError extends Error {}
|
|
@@ -85,14 +91,16 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
85
91
|
const bust = `seo-probe=${Math.floor(Date.now() / 1000)}`;
|
|
86
92
|
const withBust = (url: string) => `${url}${url.includes("?") ? "&" : "?"}${bust}`;
|
|
87
93
|
const unbust = (url: string) => url.replace(new RegExp(`[?&]${bust}`), "");
|
|
88
|
-
|
|
94
|
+
// URLs built from the command line are "named"; those from markup and redirects pass the guard.
|
|
95
|
+
const guard = options.guard ?? await addressGuard(host);
|
|
96
|
+
const web = (seconds: number, source: Source, body = true): RequestOptions => ({ userAgent: options.userAgent, seconds, body, guard, named: source === "named" });
|
|
89
97
|
|
|
90
|
-
const reachable = await request(`${origin}/`, web(15, false));
|
|
98
|
+
const reachable = await request(`${origin}/`, web(15, "named", false));
|
|
91
99
|
if (reachable.code === "000") { print(`### ${host} does not respond: ${reachable.error ?? ""}`); return 1; }
|
|
92
100
|
|
|
93
101
|
if (mode === "headers") {
|
|
94
102
|
for (const path of paths) {
|
|
95
|
-
const reply = await request(withBust(origin + path), web(20, false));
|
|
103
|
+
const reply = await request(withBust(origin + path), web(20, "named", false));
|
|
96
104
|
const location = unbust(reply.location);
|
|
97
105
|
print(`${host}${path} ${reply.code} x-robots-tag: ${tag(reply)} type: ${reply.contentType || "-"}${location ? ` -> ${location}` : ""}`);
|
|
98
106
|
}
|
|
@@ -101,7 +109,7 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
101
109
|
|
|
102
110
|
if (mode === "links") {
|
|
103
111
|
const path = paths[0] ?? "/";
|
|
104
|
-
const page = await follow(withBust(origin + path), web(20));
|
|
112
|
+
const page = await follow(withBust(origin + path), web(20, "named"));
|
|
105
113
|
const pageResult = describe(page);
|
|
106
114
|
if (!okHtml(pageResult)) { print(`### ${host}${path} page: ${pageResult} (cannot audit its links)`); return 1; }
|
|
107
115
|
const finalUrl = new URL(page.final.url);
|
|
@@ -109,7 +117,7 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
109
117
|
const links = internalLinks(collapse(decode(page.final.body)), finalUrl);
|
|
110
118
|
let bad = 0;
|
|
111
119
|
for (const link of links) {
|
|
112
|
-
const reply = await request(withBust(link), web(20, false));
|
|
120
|
+
const reply = await request(withBust(link), web(20, "markup", false));
|
|
113
121
|
if (reply.code === "200") continue;
|
|
114
122
|
bad++;
|
|
115
123
|
print(` ${link.startsWith(finalOrigin) ? link.slice(finalOrigin.length) : link} ${reply.code}${reply.location ? ` -> ${reply.location}` : ""}`);
|
|
@@ -123,7 +131,7 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
123
131
|
if (mode === "sitemap") return sitemap(host, origin, withBust, web, print);
|
|
124
132
|
|
|
125
133
|
const path = paths[0] ?? "/";
|
|
126
|
-
const page = await follow(withBust(origin + path), web(20));
|
|
134
|
+
const page = await follow(withBust(origin + path), web(20, "named"));
|
|
127
135
|
const body = collapse(decode(page.final.body));
|
|
128
136
|
const title = titleOf(body);
|
|
129
137
|
const description = contentOf(body, "description");
|
|
@@ -133,17 +141,17 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
133
141
|
print(` description (${length(description)} chars): ${clip(description)}`);
|
|
134
142
|
print(` canonical: ${canonicalOf(body)}`);
|
|
135
143
|
print(` robots meta: ${robotsMeta(body)}`);
|
|
136
|
-
print(` lang: ${
|
|
137
|
-
print(` theme-color: ${
|
|
138
|
-
print(` og: ${
|
|
144
|
+
print(` lang: ${langOf(body)}`);
|
|
145
|
+
print(` theme-color: ${themeColors(body)}`);
|
|
146
|
+
print(` og: ${ogProperties(body)}`);
|
|
139
147
|
print(` og:url: ${contentOf(body, "og:url")}`);
|
|
140
148
|
print(` twitter:card: ${contentOf(body, "twitter:card")}`);
|
|
141
|
-
print(` json-ld blocks: ${
|
|
142
|
-
print(` json-ld types (including nested): ${
|
|
143
|
-
print(` h1 count (static HTML, before JavaScript): ${
|
|
149
|
+
print(` json-ld blocks: ${jsonLdBlocks(body)}`);
|
|
150
|
+
print(` json-ld types (including nested): ${jsonLdTypes(body)}`);
|
|
151
|
+
print(` h1 count (static HTML, before JavaScript): ${h1Count(body)}`);
|
|
144
152
|
const image = contentOf(body, "og:image");
|
|
145
153
|
if (image) {
|
|
146
|
-
const fetched = await follow(withBust(image), web(20));
|
|
154
|
+
const fetched = await follow(withBust(image), web(20, "markup"));
|
|
147
155
|
const size = pngSize(fetched.final.body);
|
|
148
156
|
print(` og:image: ${image} [${describe(fetched)}] ${size ? `size ${size}` : ""} x-robots-tag: ${tag(fetched.final)}`);
|
|
149
157
|
} else {
|
|
@@ -151,7 +159,7 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
151
159
|
}
|
|
152
160
|
if (mode === "page") return 0;
|
|
153
161
|
|
|
154
|
-
const robots = await follow(withBust(`${origin}/robots.txt`), web(20));
|
|
162
|
+
const robots = await follow(withBust(`${origin}/robots.txt`), web(20, "named"));
|
|
155
163
|
const robotsText = decode(robots.final.body);
|
|
156
164
|
const robotsLines = lines(robotsText);
|
|
157
165
|
let robotsResult = describe(robots);
|
|
@@ -170,17 +178,17 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
170
178
|
for (const line of sitemaps) print(` | ${line.replace(/\r/g, "")}`);
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
const sitemapReply = await follow(withBust(`${origin}/sitemap.xml`), web(20));
|
|
181
|
+
const sitemapReply = await follow(withBust(`${origin}/sitemap.xml`), web(20, "named"));
|
|
174
182
|
let sitemapResult = describe(sitemapReply);
|
|
175
183
|
if (sitemapResult.includes("text/html")) sitemapResult += " (HTML, not a sitemap)";
|
|
176
184
|
print(` sitemap.xml: ${sitemapResult} urls: ${decode(sitemapReply.final.body).split("<loc>").length - 1}`);
|
|
177
|
-
const missing = await follow(withBust(`${origin}/seo-probe-missing-page`), web(20));
|
|
185
|
+
const missing = await follow(withBust(`${origin}/seo-probe-missing-page`), web(20, "named"));
|
|
178
186
|
print(` missing path: ${describe(missing)} body: ${missing.final.body.length} bytes title: ${titleOf(collapse(decode(missing.final.body)))}`);
|
|
179
|
-
const nested = await follow(withBust(`${origin}/seo-probe/missing/page`), web(20));
|
|
187
|
+
const nested = await follow(withBust(`${origin}/seo-probe/missing/page`), web(20, "named"));
|
|
180
188
|
print(` nested missing path: ${describe(nested)} body: ${nested.final.body.length} bytes`);
|
|
181
|
-
const error = await follow(withBust(`${origin}/404`), web(20));
|
|
189
|
+
const error = await follow(withBust(`${origin}/404`), web(20, "named"));
|
|
182
190
|
print(` /404: ${describe(error)} robots meta: ${robotsMeta(collapse(decode(error.final.body)))} x-robots-tag: ${tag(error.final)}`);
|
|
183
|
-
const http = await request(withBust(`http://${host}/`), web(15, false));
|
|
191
|
+
const http = await request(withBust(`http://${host}/`), web(15, "named", false));
|
|
184
192
|
const httpResult = unbust(`${http.code} ${http.location}`);
|
|
185
193
|
const httpNote = /^30[178] https:\/\//.test(httpResult) ? "redirects to HTTPS" : "does not redirect to HTTPS";
|
|
186
194
|
print(` http:// root: ${httpResult} (${httpNote}) x-robots-tag: ${tag(http)}`);
|
|
@@ -188,8 +196,8 @@ export async function probe(options: ProbeOptions, print: (line: string) => void
|
|
|
188
196
|
}
|
|
189
197
|
|
|
190
198
|
/** Every URL in the sitemap, through one level of sitemap index, without following redirects. */
|
|
191
|
-
async function sitemap(host: string, origin: string, withBust: (url: string) => string, web: (seconds: number, body?: boolean) => RequestOptions, print: (line: string) => void): Promise<number> {
|
|
192
|
-
const index = await follow(withBust(`${origin}/sitemap.xml`), web(20));
|
|
199
|
+
async function sitemap(host: string, origin: string, withBust: (url: string) => string, web: (seconds: number, source: Source, body?: boolean) => RequestOptions, print: (line: string) => void): Promise<number> {
|
|
200
|
+
const index = await follow(withBust(`${origin}/sitemap.xml`), web(20, "named"));
|
|
193
201
|
const indexResult = describe(index);
|
|
194
202
|
const indexBody = decode(index.final.body);
|
|
195
203
|
if (!okStatus(indexResult) || !isSitemapDocument(indexBody)) { print(`### ${host} sitemap.xml: ${indexResult} (not a sitemap document)`); return 1; }
|
|
@@ -198,7 +206,7 @@ async function sitemap(host: string, origin: string, withBust: (url: string) =>
|
|
|
198
206
|
if (indexBody.includes("<sitemapindex")) {
|
|
199
207
|
const children: string[] = [];
|
|
200
208
|
for (const child of urls) {
|
|
201
|
-
const reply = await follow(withBust(child), web(20));
|
|
209
|
+
const reply = await follow(withBust(child), web(20, "markup"));
|
|
202
210
|
const result = describe(reply);
|
|
203
211
|
const body = decode(reply.final.body);
|
|
204
212
|
if (okStatus(result) && isSitemapDocument(body) && body.includes("<urlset")) children.push(...locs(body));
|
|
@@ -208,14 +216,13 @@ async function sitemap(host: string, origin: string, withBust: (url: string) =>
|
|
|
208
216
|
}
|
|
209
217
|
const titles: string[] = [], descriptions: string[] = [];
|
|
210
218
|
for (const url of urls) {
|
|
211
|
-
const reply = await request(withBust(url), web(20));
|
|
219
|
+
const reply = await request(withBust(url), web(20, "markup"));
|
|
212
220
|
const body = collapse(decode(reply.body));
|
|
213
221
|
const canonical = canonicalOf(body);
|
|
214
|
-
const robots = ` ${`${reply.robotsTag} ${robotsMeta(body)}`.toLowerCase()} `;
|
|
215
222
|
let note = "";
|
|
216
223
|
if (reply.code !== "200") note += ` status ${reply.code};`;
|
|
217
224
|
if (canonical !== url) note += ` canonical ${canonical || "missing"};`;
|
|
218
|
-
if (
|
|
225
|
+
if (blocksIndexing(reply.robotsTag, true) || robotsMetaContents(body).some(content => blocksIndexing(content, false))) note += " noindex;";
|
|
219
226
|
if (note) { problems++; print(` ${url}:${note}`); }
|
|
220
227
|
titles.push(titleOf(body));
|
|
221
228
|
descriptions.push(contentOf(body, "description"));
|
package/src/skills/bundled.ts
CHANGED
|
@@ -7,7 +7,7 @@ export const BUNDLED_SKILLS: Readonly<Record<string, string>> = {
|
|
|
7
7
|
"open-issue": "---\nname: open-issue\ndescription: Open a GitHub issue the user explicitly requested, assigned to the authenticated GitHub user, with a reviewable title and body.\n---\n\n# Open Issue\n\nOpen an issue only when the user explicitly asks for one; finding a bug,\nrecording evidence, or following another skill does not authorize it. Follow\nrepository guidance for where issues belong, labels, and templates.\n\nResolve the target repository with `agent-tool repo context` (its `repo`\nfield) from the checkout, or the `owner/repo` the user named; never infer it\nfrom a folder name. Before creating, search open issues for a duplicate:\n\n```sh\ngh issue list --repo <owner/repo> --state open --search '<key words>' --json number,title,url\n```\n\nIf one matches, report it instead of opening another, and assign it with\n`gh issue edit <number> --repo <owner/repo> --add-assignee @me` when the user\nwants it tracked.\n\nWrite a specific title and a body that states the observed behavior, the\nexpected behavior, and reproduction steps or evidence (commands, versions,\nlinks). Never include secret values. Use only labels that already exist\n(`gh label list --repo <owner/repo>`). Put the body in a temporary file, then\ncreate the issue assigned to the authenticated GitHub user:\n\n```sh\ngh issue create --repo <owner/repo> --title '<title>' --body-file /path/to/issue-body.md --assignee @me\n```\n\nAlways pass `--assignee @me`; assign other people only when the user names\nthem, in addition to `@me` unless the user says otherwise. Confirm the result\nwith `gh issue view <url> --json url,assignees` and, if the assignee is missing,\nadd it with `gh issue edit <url> --add-assignee @me`. Report the issue URL and\nits assignees, or the exact error if assignment failed.\n",
|
|
8
8
|
"open-pr": "---\nname: open-pr\ndescription: Open a GitHub pull request for the current feature branch with a validated title and a reviewable description.\n---\n\n# Open PR\n\nUse the installed `agent-tool`. Follow repository policy for validation, commits,\nand branch naming. Resolve the repository and default branch with `agent-tool repo context`;\ndo not assume the branch is named main. Preserve unrelated work and finish\nrequested changes and appropriate checks before publishing them.\n\nEnsure the intended commit is on a feature branch and use\n`agent-tool branch push <reviewed-head> --remote <remote>` through normal hooks.\nIt names the destination explicitly and verifies local/remote HEAD afterward;\na changed result needs another review. Respect existing push authorization.\nIf the user only requested a draft description, prepare it without publishing.\n\nWrite a title that satisfies the data-only `agent-tool.json` subject policy.\nDescribe the concrete resulting behavior and relevant validation. When the\nbranch changes package manifests, run\n`agent-tool dependencies diff --base <base-oid>` and name every `newPackages`\nentry in the body with its manifest and version, so a reviewer sees new\nthird-party code however it was added. Put multiline body text in a temporary\nfile, then run:\n\n```sh\nagent-tool pr open 'feat: describe the change' --body-file /path/to/pr-body.txt\n```\n\nOmitting the title uses the latest commit subject. The tool refuses duplicate\nopen PRs and requires the branch to be pushed at its local HEAD. It does not\npush for you. Resolve a fork's head/base identities explicitly if the repository\nuses fork PRs; the initial open helper supports same-repository branches.\n\nReport the created PR link and any remaining validation or review work. Run\n`agent-tool teardown` first, stop what the work started, and report what remains.\n",
|
|
9
9
|
"reset": "---\nname: reset\ndescription: Return a clean checkout to its updated default branch after confirmed shipping or an explicit checkout cleanup request.\n---\n\n# Reset\n\nThis is checkout cleanup, not a destructive Git reset. Read repository guidance\nfor setup and hooks. Determine the default branch through the repository's\nremote metadata rather than assuming main.\n\nFor post-merge cleanup, preview with\n`agent-tool repo cleanup <PR-number> <shipped-head>`, then run it with `--apply`\nwithin the authorized cleanup scope. It requires a confirmed MERGED PR, refuses\nthe default and `branch.exempt` branches, preserves local edits, checks exact\nlocal/remote feature commits, verifies the merge is on the default branch, and\nfast-forwards that branch. By default it prunes the\nshipped local feature branch and deletes the matching remote branch if present.\nLocal pruning also applies after a squash merge or when GitHub already deleted\nthe remote branch; a missing remote is not evidence that local cleanup is done.\nPass `--keep-branch` when the user asked to preserve both feature refs.\nRead the receipt's completed steps if a later operation fails; do not claim full\ncleanup from a partial result. Verify the final branch and clean worktree, and\ncheck that `git branch --list <feature-branch>` is empty unless keeping the branch.\nIf the feature branch is checked out in another worktree, shared cleanup reports\na partial failure after updating the default branch and leaves both feature refs\nin place; preserve that worktree and report the remaining cleanup.\n\nRemote branch deletion uses GitHub REST after checking the live ref to avoid\npre-push hooks. The API has no atomic expected-OID delete guard; the check and\ndeletion retain a small concurrent-update window. Fork PRs require manual remote\nhandling and are refused by the shared cleanup command.\nUse a repository's stronger cleanup procedure when required, including atomic\nremote deletion or additional local verification; do not weaken it to use the\nshared command. The same local pruning and keep-branch outcomes still apply.\n\nFor an explicit checkout cleanup without a merged PR, preserve all feature refs:\ncheck worktree/index, resolve the default branch with `repo context`, fetch it,\nswitch, and update by fast-forward only. Never discard or automatically stash\nedits, force a diverged default branch, or infer shipping from Git ancestry after\na squash merge.\n\nRun `agent-tool teardown` and stop what the finished work left running\n(`teardown --apply` for recorded processes); report anything that remains.\nRun the repository's documented dependency/hook setup if required. When copied\nhooks are configured, use `agent-tool hooks check` and `hooks install --apply`;\ninspect unmanaged hooks before an explicit `--adopt`, which backs them up.\nDo not assume a package manager. Report final branch, commit, whether the shipped\nlocal branch was pruned or preserved, and unfinished cleanup or setup.\n",
|
|
10
|
-
"seo-optimization": "---\nname: seo-optimization\ndescription: Audit and improve how a repository's websites appear in search results and link previews, covering titles, descriptions, canonical URLs, Open Graph, structured data, robots.txt, sitemaps, status codes, and keeping non-production tiers out of search indexes. Use for an SEO audit or optimization pass, not copywriting or general feature work.\n---\n\n# SEO Optimization\n\nMake every production page say what it is in the HTML that is served\nbefore JavaScript runs, name one canonical URL, and be discoverable through\nrobots.txt and a sitemap. Keep every non-production tier out of search\nindexes. Judge the deployed result, not the source: a correct template that\nnever reaches the live response is not a fix.\n\n## Establish scope\n\nRead the repository's instructions and the docs they point to, including\nsetup, validation, versioning, deployment, and title policy. Use the user's\nscope. A report-only request stays read-only. An optimization pass may make\nreversible changes in the repository and ship them through its normal\nworkflow when shipping is authorized; existing explicit authorization still\napplies, so do not ask for it again. On a repeat pass, read the previous SEO\nchange and its docs, keep the decisions it recorded, and re-check what it\ncalled compliant against the current standard; when it left no change,\naudit from scratch.\n\nThis skill does not by itself authorize DNS changes, zone or CDN settings,\nsearch console registration, store listings, or production content rewrites.\nWrite titles and descriptions from copy the site or repository already has.\nNever invent product claims, platforms, prices, ratings, or reviews, and never\nadd links to store pages that are not live.\n\n## Inventory hosts\n\nList every public hostname the repository serves, by tier, from hosting\nconfiguration (for example `wrangler.jsonc` routes), infrastructure code,\ndeploy workflows, and docs. Classify each one:\n\n- **content**: marketing site, landing page, resume, or documentation that\n should rank. A standalone web tool with no separate marketing site is a\n content host for its landing page.\n- **app**: an interactive application or app shell, often `app.*` or\n `demo.*`, whose marketing lives elsewhere.\n- **internal**: admin dashboard, asset gallery, or API host. A package's\n viewer or demo site, whose pages other sites copy, is internal unless the\n repository or the user says it should rank; ask when it is unclear.\n- **non-production**: staging, preview, or any other tier that is not the\n production site.\n\nFor each host, find how it is built and deployed. Note whether each tier has\nits own build or one artifact is promoted, whether a merge deploys or a\nperson runs a command, and whether a Worker or server script answers some\nresponses itself. These facts decide where a tier-specific header can live.\nInclude hosts the platform adds on its own, such as `*.workers.dev` and\nper-version preview URLs, which serve duplicate copies of the site.\n\nProbe each host's current state with `agent-tool seo probe`, run through the\nrepository's pinned agent-tool: `bun run agent-tool seo probe <host> [path]`,\nor `node_modules/.bin/agent-tool seo probe <host> [path]` where there is no\npackage script. It reports a page's title, description, canonical, robots\nmeta, `X-Robots-Tag`, Open Graph and Twitter tags, preview image, JSON-LD\ntypes, and h1 count, then the site's robots.txt, sitemap, missing path, and\n`http://` behavior. `--page` skips the site files;\n`--headers <host> <path>...` prints one line per path without following\nredirects, for checking headers on assets, redirects, and errors; `--links`\nlists the page's internal links that do not answer 200 directly; and\n`--sitemap` checks every sitemap URL's status, canonical, and robots, and\nreports duplicate titles and descriptions. The mode flag comes first, the\nhost is a hostname with an optional port, and each path starts with `/`. The\nprobe matches
|
|
10
|
+
"seo-optimization": "---\nname: seo-optimization\ndescription: Audit and improve how a repository's websites appear in search results and link previews, covering titles, descriptions, canonical URLs, Open Graph, structured data, robots.txt, sitemaps, status codes, and keeping non-production tiers out of search indexes. Use for an SEO audit or optimization pass, not copywriting or general feature work.\n---\n\n# SEO Optimization\n\nMake every production page say what it is in the HTML that is served\nbefore JavaScript runs, name one canonical URL, and be discoverable through\nrobots.txt and a sitemap. Keep every non-production tier out of search\nindexes. Judge the deployed result, not the source: a correct template that\nnever reaches the live response is not a fix.\n\n## Establish scope\n\nRead the repository's instructions and the docs they point to, including\nsetup, validation, versioning, deployment, and title policy. Use the user's\nscope. A report-only request stays read-only. An optimization pass may make\nreversible changes in the repository and ship them through its normal\nworkflow when shipping is authorized; existing explicit authorization still\napplies, so do not ask for it again. On a repeat pass, read the previous SEO\nchange and its docs, keep the decisions it recorded, and re-check what it\ncalled compliant against the current standard; when it left no change,\naudit from scratch.\n\nThis skill does not by itself authorize DNS changes, zone or CDN settings,\nsearch console registration, store listings, or production content rewrites.\nWrite titles and descriptions from copy the site or repository already has.\nNever invent product claims, platforms, prices, ratings, or reviews, and never\nadd links to store pages that are not live.\n\n## Inventory hosts\n\nList every public hostname the repository serves, by tier, from hosting\nconfiguration (for example `wrangler.jsonc` routes), infrastructure code,\ndeploy workflows, and docs. Classify each one:\n\n- **content**: marketing site, landing page, resume, or documentation that\n should rank. A standalone web tool with no separate marketing site is a\n content host for its landing page.\n- **app**: an interactive application or app shell, often `app.*` or\n `demo.*`, whose marketing lives elsewhere.\n- **internal**: admin dashboard, asset gallery, or API host. A package's\n viewer or demo site, whose pages other sites copy, is internal unless the\n repository or the user says it should rank; ask when it is unclear.\n- **non-production**: staging, preview, or any other tier that is not the\n production site.\n\nFor each host, find how it is built and deployed. Note whether each tier has\nits own build or one artifact is promoted, whether a merge deploys or a\nperson runs a command, and whether a Worker or server script answers some\nresponses itself. These facts decide where a tier-specific header can live.\nInclude hosts the platform adds on its own, such as `*.workers.dev` and\nper-version preview URLs, which serve duplicate copies of the site.\n\nProbe each host's current state with `agent-tool seo probe`, run through the\nrepository's pinned agent-tool: `bun run agent-tool seo probe <host> [path]`,\nor `node_modules/.bin/agent-tool seo probe <host> [path]` where there is no\npackage script. It reports a page's title, description, canonical, robots\nmeta, `X-Robots-Tag`, Open Graph and Twitter tags, preview image, JSON-LD\ntypes, and h1 count, then the site's robots.txt, sitemap, missing path, and\n`http://` behavior. `--page` skips the site files;\n`--headers <host> <path>...` prints one line per path without following\nredirects, for checking headers on assets, redirects, and errors; `--links`\nlists the page's internal links that do not answer 200 directly; and\n`--sitemap` checks every sitemap URL's status, canonical, and robots, and\nreports duplicate titles and descriptions. The mode flag comes first, the\nhost is a hostname with an optional port, and each path starts with `/`. The\nprobe matches text patterns rather than parsing HTML, so confirm anything\nsurprising in the raw response before acting on it. A `000` status means no\nresponse, including a URL it refused to request: one that is not HTTP or\nHTTPS, or one on a private or local address that a page or redirect, not the\ncommand line, named. Set `SEO_PROBE_USER_AGENT` to a browser user agent to see\nwhat a zone injects only for browsers.\n\nCheck whether the default branch already has merged work that has not been\ndeployed, because a deploy ships it too. Deployment listings often do not\nname a commit. The strongest check is to build the default branch with\nproduction settings and compare its files with the live ones byte for byte;\notherwise compare deploy times with merge times (for CI deploys, the head\ncommit of the deploy runs), read a version marker in the live HTML or bundle,\nor run the repository's deploy verifier read-only. A deploy may also apply\ndatabase migrations; list pending ones read-only first.\n\n## Apply the standard\n\nApply [references/standard.md](references/standard.md), which holds the\nchecklist for each host class; read \"Every host\" and the sections for the\nclasses you found. Its outcomes, in one line each:\n\n- **Non-production**: noindex on every response and page, crawlable, no\n canonical or sitemap. Production is never noindexed, except its error page\n and paths deliberately kept out of search.\n- **Content**: complete static head, preview image, structured data,\n robots.txt, sitemap, and real 404s.\n- **App**: descriptive shell metadata and a real robots.txt; a canonical only\n when routes are not distinct public content.\n- **Internal**: noindex for HTML surfaces; API hosts only when trivial.\n\nPlatform specifics live in\n[references/cloudflare-workers.md](references/cloudflare-workers.md) (static\nasset headers, trailing slashes, not-found handling, Cloudflare's managed\nrobots.txt) and [references/frameworks.md](references/frameworks.md) (Astro,\nNext.js static export, Vite single-page apps, Bun's HTML bundler,\nreact-native-web, service workers, and `agent-tool images` for preview\nimages). Read the sections that match the repository.\n\nKeep changes proportionate: metadata, robots, sitemaps, status codes, and\nlight heading or `alt` fixes on pages you touch. Record larger work, such as\nprerendering JavaScript-only content, performance refactors, localized URL\ntrees, or redirects that need DNS, as recommendations.\n\n## Validate and verify\n\nRun the repository's full documented validation. Build every tier you\nchanged and inspect its output: each HTML `<head>`, `_headers` or equivalent,\nrobots.txt, the sitemap, and the preview image. Add tests where the\nrepository has a natural place for them:\n\n- metadata is present in the static HTML with JavaScript disabled;\n- the non-production build carries noindex and the production build does not;\n- every sitemap URL equals the canonical URL of the page it lists;\n- every internal link answers without a redirect;\n- an unknown path returns 404 when served by the real hosting runtime, not a\n development server that answers every path with the app, and the error\n page's own URL (such as `/404`) carries noindex.\n\nBefore changing a title or description, search the tests for the old text.\nShell snippets added to docs must not use `path` as a variable name, because\nzsh ties it to `PATH`.\n\nAfter deploying, probe every host on every tier; the probe adds a\ncache-busting query. Confirm that production carries no noindex in headers or\nmarkup, that the preview image at the URL the page names answers 200 with an\nimage type and the declared size, and that every sitemap URL answers 200\nwithout a redirect. Confirm that each non-production host sends the header\non HTML, assets, fallbacks, and redirects. Record what the CDN did to\nrobots.txt.\n\n## Report\n\nUse the repository's report convention, or put the evidence in the PR and\nthe final summary:\n\n- hosts with their classification and live result, per tier;\n- the changes made, and what was deliberately left unchanged, with reasons;\n- recommendations ordered by impact, with an owner or the decision they need;\n- questions that only the user can answer, such as whether user-generated\n public pages should be indexable, or which URL form legal pages should use.\n\nOut-of-scope items belong in recommendations unless the user authorizes\nthem: search console and Bing Webmaster verification and sitemap submission,\ninfrastructure changes such as `www` redirects and zone settings (see\n[references/cloudflare-workers.md](references/cloudflare-workers.md)), CDN\nrobots and AI-crawler settings, store links and smart app banners before\nstore IDs exist, app association files, and content or performance work.\nKeep reusable procedure in this skill and dated findings in the report.\n\n## Ownership\n\nagent-tool (`a2f0/agent-tool`) owns this skill in `skills/seo-optimization/`,\nand the `seo probe` command with its tests in `src/seo/`. Repositories get\nthe skill from `agent-tool skills install --apply`; do not edit the installed\ncopy. Change it in agent-tool by PR. A repository's hosts, tiers, and deploy\nchecks belong in its own docs.\n",
|
|
11
11
|
"ship-pr": "---\nname: ship-pr\ndescription: Complete an authorized commit, independent review, repair, PR, CI, and squash-merge workflow for a GitHub repository.\n---\n\n# Ship PR\n\nUse the installed `agent-tool`. Read repository guidance and policy first;\nvalidation, versioning, package management, and hook bodies remain project\nconcerns. Use shared branch, hook, check, cleanup, and release commands where\nconfigured; keep application-specific commands in repository guidance. Shipping authorizes this workflow within the user's stated scope.\nPreserve unrelated edits and honor requested stopping points such as open-PR\nonly, report-only review, or keeping the feature branch.\n\nUse `agent-tool run --label <check> -- <command> [args...]` for noisy setup,\nvalidation, builds, and hook-running Git commands. It preserves exit status and\ncomplete private logs, prints one success receipt, and shows a bounded failure\ntail. Inspect more with `agent-tool logs <log> --max-bytes 8192 --tail-lines 80`\nor a targeted search; never dump an entire suite log or pipe checks into `tail`.\nThe receipt proves process completion, not absence of warnings: inspect required\nwarning, coverage, timing, or artifact evidence before accepting a check. Keep\nmachine-readable receipts and review findings visible by running `versions\nprepare`, `review`, `repo base-health`, and other commands whose output drives a\ndecision directly. Prefer documented compact test reporters when they preserve\nrequired evidence; do not reduce test scope, skip checks, silence warnings, or\nmask failures. Start servers, watchers, and other long-running processes with\n`agent-tool proc start --label <name> -- <command>`, never a backgrounded shell\ncommand, so they can be found and stopped.\n\n1. Start from the base branch's health: `agent-tool repo base-health` (with\n `--branch <base-branch>` for another base). `green`, `pending`, and `no-ci`\n need nothing more; report `no-ci` as missing CI on pushes. When it is\n `red`, read the failing jobs' logs (`gh run view <run-id> --log-failed`\n through `agent-tool run`) and relate them to the merges in\n `breakingRange`. Broken logic from combined merges: fix it and add the test\n that would have caught the combination. A flaky or timing-dependent test:\n remove the race, ordering dependence, or shared state. Infrastructure or an\n outside service: record it; rerun only when the log shows the cause was\n external. Never retry until green, skip, or loosen an assertion. When\n `openRepairs` lists a PR, do not duplicate it. Otherwise ship the repair\n through this workflow as its own PR, naming the failing run in its body,\n ahead of the requested change; when the change touches the same code, make\n the repair a separate commit in that PR and say so in its description. A\n red base does not block an unrelated change; stop only when the change\n cannot be validated without the repair. A PR failure with the same job and\n error as on the base is repaired on the base. Reverting the breaking merge\n is allowed when the fix is not small and the break blocks a deploy or\n publish; the revert names the merge and the follow-up that restores it.\n2. Finish the requested change on a feature branch. Use\n `agent-tool branch create <branch> --base <base-branch> --remote <remote>`\n from a clean checkout; it fetches and pins the base, checks naming policy and\n collisions, and creates without a local upstream. Use `branch check` with\n explicit destination names in CI or hooks. Before pushing, validate with the\n repository's push gate and the tests that target the changed code, not the\n full suite: CI runs everything and is the authority. Commit only the\n intended files.\n3. Use `agent-tool repo context --fetch` to resolve the PR's base repository\n and branch, or the default branch when no PR exists, and fetch its exact base.\n Record the returned base/head identities. Integrate the fetched base\n using the repository's normal workflow, resolving conflicts without losing\n user work. If project policy versions packages, prepare versions against the\n pinned base after every integration or repair and before each review, using\n the project's commands or `agent-tool versions prepare <base-oid>`, which\n commits bumped manifests and the refreshed lockfile.\n `agent-tool versions resolve-conflicts` resolves conflicts confined to\n version fields. Review the resulting committed HEAD with an independent\n reviewer using the bundled cross-agent-review skill. Repair blocking findings\n and review every changed HEAD again. Review failure blocks shipping. One\n change keeps a review: after a clean review, a new HEAD that only integrated\n the base and prepared versions (as when another PR took the same version\n first). When `agent-tool review carry <reviewed-head> <new-head>` exits 0\n with `ok: true`, the earlier clean review stands, and the new HEAD is the\n reviewed head from then on; report the review as carried, giving the\n reviewed head and the command's JSON output. Every other changed HEAD,\n including one the command rejects, gets an independent review, and CI\n still runs on the new HEAD.\n4. Run `agent-tool branch push <reviewed-head> --remote <remote>` through\n normal hooks; it verifies local and remote identity afterward. If a hook\n changed content or HEAD, review that result.\n Open the PR using the open-pr skill, or update the existing PR as needed.\n5. Allow configured review bots time to respond, then use\n `agent-tool pr threads list` to fetch review threads and all comments. Follow repository policy for feedback: fix valid findings,\n reply with `pr threads reply <comment-id>` (body file or stdin), and use\n `pr threads resolve <thread-id>` only for fully addressed findings.\n Validate, commit, push, and independently review every feedback or CI repair.\n Wait with `agent-tool pr checks --wait --head <reviewed-head>`, whose limit\n defaults to `agent-tool.json` `merge.checksTimeoutSeconds`. When a job\n fails, read its log with `agent-tool pr logs --head <reviewed-head>`, fix it\n in a new commit, review it, push, and wait on the new head. A base that\n moved (`behind: true`) needs no integration unless GitHub reports a\n conflict, `versions check` fails against the live base, or the repository\n sets `merge.requireStrictBaseFreshness`; under that policy the wait stops\n early, so cancel the stale head's CI with\n `agent-tool pr cancel-runs --head <reviewed-head>`, then integrate,\n validate, review (or carry the review, as in step 3), push, and wait again.\n Then run\n `agent-tool pr preflight <reviewed-head> <base-branch> <reviewed-base>` to\n recheck CI, conflicts, the live base, PR identity, local state, and explicit\n version policy. When versions are managed,\n `agent-tool versions check <live-base-oid>` must pass. Use the squash-merge\n skill to merge the exact reviewed HEAD.\n6. After confirmed MERGED, follow the reset skill: run\n `agent-tool repo cleanup <PR-number> <reviewed-head> --apply` to return to the\n updated default branch and prune the shipped feature branch, honoring\n stronger repository cleanup rules. Never prune with raw `git branch -D` or\n `git push --delete`: the cleanup command checks the merge and both refs\n first, and harness command guards prompt for raw force deletes. If the user requested keep-branch, preserve\n both feature refs. Check the cleanup receipt and verify the local feature ref\n is absent unless preserved; report incomplete cleanup explicitly. Apply\n documented dependency/hook setup.\n7. When the project publishes npm packages, use `agent-tool release verify\n <package> <version> <merge-oid> --workflow <publish-workflow>` to verify the\n exact workflow and tarball, allowing registry propagation time. When the\n project deploys the merged branch, verify that deployment and documented\n live checks. Report deployment failures\n separately from a successful merge; follow project policy for repairs. A\n release that fails because another merge published the same version needs\n a follow-up version bump through this workflow.\n8. Run `agent-tool repo base-health` again until it is no longer `pending` and\n the merge commit, or a newer tip, has runs (`tip.hasRuns`). When no run\n starts within about ten minutes, as with path filters or PR-only CI, or the\n status is `no-ci`, report that and stop waiting. A failure there belongs to\n this session: fix it forward through this workflow before reporting the\n work done.\n\nBefore the final report, run `agent-tool teardown` in each repository this work\ntouched. Stop what the work started (`teardown --apply`, `proc stop`), stop any\nuntracked process it started, and remove worktrees it added. Report what\nremains and why; the work is not done while teardown fails for anything it\nstarted.\n\nNever infer a clean review from process success alone, or carry a review to a\nHEAD that `review carry` does not accept. Do not weaken configured CI policy to\nget a merge through. If a step fails, preserve useful intermediate work and report the concrete\nremaining issue. Report PR link, merged commit, review verdict, validation, final\ncheckout state, the base's health at the start and end and anything repaired or\nhardened, the teardown result, and whether the shipped local branch was pruned\nor preserved.\n",
|
|
12
12
|
"squash-merge": "---\nname: squash-merge\ndescription: Squash-merge a reviewed GitHub pull request while binding the mutation to the reviewed commit and checking CI.\n---\n\n# Squash Merge\n\nUse the installed `agent-tool` and repository merge policy. Merge only within\nthe user's authorized scope. Have the exact reviewed HEAD, base commit, and base\nbranch available, and read the verdict and unresolved findings. BLOCKER or MAJOR\nfindings require repair and a new review before merging.\nFollow the repository's review-bot policy and require all actionable blocking\nreview feedback to be addressed before merging.\n\nWait with `agent-tool pr checks --wait --head <reviewed-head>`, which waits for\nchecks to appear and for every workflow/job/event entry to finish, and reports\n`behind: true` when the live base has moved past the head. A moved base alone\nneeds no integration: integrate, validate, review, and push again only when\nGitHub reports a conflict, when `versions check` fails against the live base,\nor when the repository sets `merge.requireStrictBaseFreshness`. Under that\npolicy the wait stops early at `behind: true`; cancel that head's runs with\n`agent-tool pr cancel-runs --head <reviewed-head>` first. Run\n`agent-tool pr preflight <reviewed-head> <base-branch> <reviewed-base>` immediately\nbefore merging. It checks local and PR identity, that the head contains the\nreviewed base, conflicts and merge readiness, explicit version policy against\nthe live base, configured strict rulesets, and passing checks; under the strict\npolicy the live base must also equal the reviewed one. If an identity changed,\nrefresh, integrate, validate, and review again; a new HEAD that\n`agent-tool review carry <reviewed-head> <new-head>` accepts keeps the earlier\nclean review. Read unresolved feedback with `pr threads list` and follow\nproject review policy.\n\nUse a title that satisfies `agent-tool.json` and pass both reviewed HEAD and\nbase branch:\n\n```sh\nagent-tool pr merge 'feat: describe the change' <reviewed-head-oid> <base-branch>\n```\n\nThe helper enforces HEAD atomically through GitHub's `expectedHeadOid`, checks\nCI, rejects queued or automatic merges, and creates a subject-only squash with\nthe PR reference. GitHub has no atomic expected-base argument in this mutation,\nso a base can move between preflight and merge; without the strict policy that\nis accepted, and a break the combination causes is repaired on the base. With\n`merge.requireStrictBaseFreshness`, the helper refuses to merge unless an\nactive strict status ruleset that the actor cannot bypass protects the base. Do\nnot retarget the PR concurrently with merging.\n\nConfirm GitHub reports MERGED before any cleanup. A failed or uncertain mutation\nis not evidence of a merge. Preserve the branch on failure. After a confirmed\nmerge, perform checkout cleanup only when requested or as part of an authorized\nshipping workflow, with `agent-tool repo cleanup <PR-number> <reviewed-head>\n--apply` rather than raw `git branch -D`. Report the PR and merge result.\n",
|
|
13
13
|
"update-dependencies": "---\nname: update-dependencies\ndescription: Update dependencies or update everything in a repository, including runtimes, tools, and CI pins, with compatibility checks and safe previews; ship through review, CI, merge, and release verification unless a narrower scope is requested.\n---\n\n# Update Dependencies\n\nUse the repository's package managers and installed `agent-tool`. Read `AGENTS.md`,\nREADME, existing dependency-maintenance notes, linked setup/release documents,\nand repository-owned upgrade skills before editing. Follow their hooks, version\npolicy, checks, and requested stopping point.\nUpdate applicable dependencies throughout the repository, including workspaces\nand examples. When asked to perform dependency updates, invoke the installed\n[`ship-pr`](../ship-pr/SKILL.md) to complete review, PR, CI, and merge, then verify\nthe repository's normal merge-triggered publication or deployment. An explicit\nnarrower scope, such as inventory-only, local changes, or open-PR-only, takes\nprecedence. This default does not authorize standalone infrastructure applies,\ndeployments, or global tool changes. Default dependency-update merge subject:\n`chore: update dependencies`, subject to repository title policy and any explicit\nuser subject.\n\nRun noisy installs, checks, tests, and builds with\n`agent-tool run --label <check> -- <command> [args...]` to retain full private\nlogs and return the original status with compact output. Inspect bounded excerpts\nusing `agent-tool logs <log>` and targeted searches for warnings and evidence;\na successful receipt does not establish a warning-free upgrade. Keep structured\naudit/plan results, deployment previews, and review findings directly visible\nwhen they drive a safety decision. Do not dump full suite logs into context,\nsilence warnings at their source, or change check scope to reduce output.\n\n## Checkout setup\n\nThis shared workflow also handles natural-language requests to \"update everything\".\nIf the repository owns an `update-everything` wrapper, read and follow its extra\nrequirements; do not create an alias or overwrite that skill. The workflow works\nfrom a standalone checkout with no workspace coordinator.\n\nAfter a fetch, branch integration, or dependency pin change, check that the local\n`agent-tool --version` matches the repository's declared pin before trusting its\ncommands or generated skills. A stale CLI can reject newer configuration keys.\nAfter screening install scripts and hooks as below, run the documented frozen\ninstall with the repository's pinned runtime. For Bun projects, an already working\nCLI can run `agent-tool bun install`; if it is missing or cannot parse the new\nconfig, run the documented package-manager install directly. A known working\nexecutable may capture it with `agent-tool --repo <checkout> run --label setup --\n<install-command> [args...]`. Do not fetch an unpinned CLI, alter global tools, or\nassume a sibling workspace exists. Verify the installed version afterward; if it\nstill differs, report the mismatch rather than deleting arbitrary dependencies.\n\nAfter upgrading agent-tool, run the repository's skill/permission sync commands.\nFor each ownership manifest they do not refresh, run its installer directly:\n`agent-tool skills install --harness <existing-scope> --apply` for\n`.agent-tool-skills.json`, and\n`agent-tool permissions install --harness <existing-scope> --apply` for\n`.agent-tool-permissions.json`. Preserve each harness scope, and commit the\nownership manifests with any generated files.\nThe manifests record the agent-tool version, so every upgrade changes them, even\nwhen no skill or rule changed, and `skills check` and `permissions check` fail\nuntil the sync records the new version. Hermes reads the shared `.agents/skills`\nin a trusted project; the installer does not grant trust. If discovery is\nunavailable, read those files directly rather than silently using a stale global\ncopy.\n\n## Nonblocking execution\n\nUse the harness's managed background execution for long finite checks, reviews,\npush hooks, CI waits, and release verification; request completion notification\nwhen available and retain its process handle plus agent-tool's log/receipt path.\nRun `run-group` and reviews directly so their reports remain visible. A started\nprocess is not a passed check: read its final status and required evidence before\nshipping, and do not repeatedly poll when completion events are available.\nWithout harness background support, `proc start --label <name> -- agent-tool run\n--label <check> -- <command> [args...]` records the outer process and captures\nits output; inspect `proc list` and `logs` plus the inner run receipt to establish\ncompletion and exit status. An exited process record alone does not prove success.\nUse `proc stop`/`teardown` for owned leftovers; never stop another session's work.\nThese commands need no matrix workspace or global configuration change.\n\nKeep independent compatibility groups moving while a producer release or an\nexternal gate is pending. Only final adoption of that exact published release\nmust wait. Bound CPU/process-heavy concurrency to the machine's available budget;\na failed full suite needs diagnosis and a full-scope rerun, not larger timeouts,\nfewer assertions, or a focused retry presented as suite recovery. Background\nexecution never bypasses an approval, a deployment preview, or exact-head review.\n\n## Safety before execution\n\n**Always dry-run before any infrastructure apply or deployment. Never destroy,\nreplace, or recreate a resource during an upgrade.** This includes Terraform,\nOpenTofu, Wrangler, Ansible, other infrastructure tools, and effects triggered by\ninstallation, tests, hooks, Git push, opening a PR, CI, or merging. Greenfield\nprojects and approval to ship do not waive this rule.\n\nBefore running project commands or pushing, trace their scripts, hooks, workflow\ntriggers, reusable workflows, and deployment commands. A dry-run flag alone is\ninsufficient: inspect tasks, provisioners, plugins, external programs, and actions\nthat can mutate despite preview mode. Avoid such a preview unless its effects\nare proven read-only. Do not run destroy/delete, taint/replace, state removal,\nbackend migration, forced database reset, or an automatic \"repair\" that bypasses\nthe rule. Do not hide destruction with targeting, disabled refresh, ignored\nchanges, new resource identities, or weakened policy.\n\nPreview with the proposed versions and complete configuration for each affected\nenvironment, using its real backend/workspace/account, variables, inventory, and\nresource identities. An empty local state, mocked credentials, validate-only run,\nor bundle build cannot establish safety for production. Check the current baseline\nas well when needed to distinguish existing drift from the upgrade. Keep state,\nbinary plans, JSON plans, and secret-bearing diffs out of Git and public reports.\n\nIf a preview proposes deletion or replacement, fails, is incomplete, omits\naffected resources, or cannot establish safety, skip that dependency and its\ncoupled migrations. Restore only this task's edits to the affected compatibility\ngroup, retain independent safe upgrades, and record the reason and affected\nresources. Never apply to find out. A preview is not deployment authorization.\n\nBefore an authorized apply/deploy, verify the exact validated commit, toolchain,\nconfiguration, environment, and current state still match the preview. Re-preview\nafter relevant changes or drift. CI must enforce the same order and stop on an\nunsafe preview before mutation; a successful local preview does not excuse an\nunguarded push- or merge-triggered deployment. Establish a narrowly scoped guard\nwhen authorized and reviewable, or hold the affected upgrade before triggering\nthat workflow. Do not disable protections to ship. A plan must be inspected before\nthe operation; inspecting deployment logs afterward is too late.\nAn unsafe workflow triggered on every branch push also blocks pushing otherwise\nindependent upgrades until that trigger has a proven safe guard.\n\n### Terraform and OpenTofu\n\nRead core, provider, and module upgrade guides, including intermediate major\nmigrations. Regenerate provider locks with the pinned CLI, preserving supported\nplatform hashes. Backend initialization/migration is also subject to the safety\ngate. Inspect external data programs and provisioners before planning.\n\nUse a full refreshed saved plan with locking and the real variables, for example\n`terraform plan -input=false -out=<private-plan>`; if using `-detailed-exitcode`,\n0 and 2 are success, 1 is failure. Inspect `terraform show -json <private-plan>`.\nRun `agent-tool dependencies check-terraform-plan <private-plan.json>` to check\nsupported JSON resource actions. It fails for every action containing `delete`,\nincluding both replacement orders, unknown actions, incomplete/deferred plans,\nfailed checks, or opaque provider action invocations. It prints actions and\ndiagnostics without resource attribute values; it does not prove that a plan is\nfresh, comprehensive, authentic, or that provider code has no hidden effects.\nOlder/unsupported plan formats that cannot establish completeness are skipped.\nOpenTofu currently omits `complete` in its JSON format and is rejected by this\nhelper; report that limitation rather than adding a synthetic completeness flag.\nAlso inspect resource identity, drift, warnings, provider semantics, and any\neffects outside resource actions. For an authorized apply, consume the exact\napproved saved plan, not an uninspected newly generated plan.\n\nSource: [Terraform JSON plan format](https://developer.hashicorp.com/terraform/internals/json-format).\n\n### Wrangler and other deployment tools\n\nUse the proposed pinned Wrangler for `wrangler deploy --dry-run` with the same\nbuild/configuration/environment used by deployment. This checks bundling, not a\ncomplete remote resource plan. Separately verify account, worker name, routes,\nbindings and resource IDs against the existing deployment and read migration\nsemantics. Review Durable Object deleted/renamed classes, D1 schema/data\nmigrations, storage resources, queues, containers, and deployment integrations.\nNever infer \"no destruction\" from a successful bundle. Resource removals,\nreplacement, or unprovable remote effects skip the affected group. Apply the\nequivalent preview and identity checks to other tools rather than assuming they\nshare Terraform's guarantees.\n\nDo not assume `wrangler d1 migrations list --remote` is read-only. The\nimplementation inspected for this skill initializes migration tracking with\n`CREATE TABLE IF NOT EXISTS`; verify the pinned Wrangler version before using\nthe command. Verify database identity and compare migration files with the\ndatabase's configured migration tracking table through audited read-only\nqueries. A missing table, pending migration, or unverifiable schema/data\neffects hold the affected upgrade/deployment group. Never initialize schema\nmerely to establish preview safety.\n\nWrangler runs a custom `build.command` again during deployment. Use supported\nconfiguration referencing the same validated artifacts for both preview and\ndeployment, preventing another unvalidated build before upload. Bind the\nartifacts, configuration, and pinned tool to the authorized commit, and recheck\ntheir identities before upload and after relevant changes. Hold the affected\ngroup if the pinned Wrangler cannot upload the validated output without\nrebuilding it, or if the upload cannot be proven to match the preview.\n\nSources: [Wrangler command documentation](https://developers.cloudflare.com/workers/wrangler/commands/),\n[D1 migration listing implementation](https://github.com/cloudflare/workers-sdk/blob/e3d186776fcc2e4b5cc4cfd7155591778a375957/packages/wrangler/src/d1/migrations/list.ts),\n[migration table initialization](https://github.com/cloudflare/workers-sdk/blob/e3d186776fcc2e4b5cc4cfd7155591778a375957/packages/wrangler/src/d1/migrations/helpers.ts),\nand [Wrangler custom builds](https://developers.cloudflare.com/workers/wrangler/custom-builds/).\n\n### Ansible\n\nCheck controller Python, ansible-core, collections/roles, and target Python support\ntogether; read porting guides. Inspect all tasks and invoked scripts before\n`ansible-playbook --check --diff` with the real inventory and variables.\n`check_mode: false` forces mutation even with `--check`; unsupported modules and\nconditions based on registered results can omit effects. Inspect deletion,\nrecreation, service/data reset, and package removal semantics beyond the diff.\nSkipped or opaque tasks are a safety gap, not a clean preview. Redact diffs.\n\nSource: [Ansible check mode limits](https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_checkmode.html).\n\n## Inventory and choose compatible targets\n\nRecord each dependency source, current resolved version, latest stable candidate,\nselected target, compatibility constraints, upstream migration links, and checks\nin the run ledger described under Report.\nQuery authoritative registries, official releases, support matrices, and migration\nguides at execution time; do not treat remembered versions or prereleases as\nlatest stable. Inspect runtime requirements, peer dependencies, ABI/API changes,\nplatform availability, maintained release lines, and changed defaults, including\nsecurity, privacy/telemetry, data retention, and postinstall/native behavior.\nCheck transitive dependencies' peer/runtime constraints as well as direct ones. Unsupported\nor unpublished targets stay pinned with an explanation.\n\nInventory manifests, locks, tool configuration, CI/reusable actions, containers,\nscripts, deployment files, and executable documentation. Search duplicate version\npins and aliases, not just filenames; exclude vendored/generated snapshots unless\nthe repository owns their update process. Examples of sources to inspect:\n\n| Ecosystem | Sources and compatibility group |\n| --- | --- |\n| JavaScript/TypeScript | All package.json dependency fields, overrides/resolutions, workspace catalogs, packageManager/engines, npm/Bun/pnpm/Yarn locks, Node/Bun pins, compiler and lint/build/test plugins |\n| Toolchains | mise.toml/.mise.toml, mise.lock, .tool-versions, runtime version files, tool URLs/checksums, CI pins and container images; include every tool declared by mise, not just mise itself |\n| Python/Ansible | pyproject/requirements, uv/Poetry/pip locks, Python pins, ansible-core, collection/role requirements, lint plugins and managed host constraints |\n| Ruby/iOS | .ruby-version, Gemfile/lock, Bundler, CocoaPods, Podfile/lock, podspecs, Swift packages and Xcode/iOS deployment requirements |\n| Infrastructure | Terraform/OpenTofu CLI constraints, provider locks/constraints, module versions/Git refs, Wrangler and Cloudflare integration dependencies |\n| CI/system/native | Actions/reusable workflow refs, Docker tags/digests, OS images/packages, Rust/Cargo toolchain and locks, Go modules, Gradle/AGP/Kotlin/JDK and other repository-specific manifests |\n\nBuild connected compatibility groups before editing. Select the newest supported\ncombination, which can be older than an individual package's latest. Upgrade the\nframework first or keep its compatible toolchain pinned; do not force peer\nresolution, drop compatibility checks, or add blanket overrides to make installs\npass. Preserve source pin policy (exact version, digest, full Git SHA) and resolve\nimmutable pins from verified upstream releases. Preserve intentional runtime\nminimums unless migration requires changing the support contract.\n\nFor React Native, use its version-specific upgrade guide/template diffs and\nrepository upgrade skills. Couple React and its renderer, native modules,\nMetro/Babel, CLI, codegen, Hermes/New Architecture, CocoaPods/Bundler/Ruby,\nXcode/iOS deployment targets, and Android Gradle/AGP/Kotlin/JDK/SDK/NDK. For Expo,\nuse the chosen SDK's supported React Native/dependency matrix and its dependency\nchecks. Do not independently update framework-managed pods or generated native\nfiles; use the framework's regeneration workflow and prove iOS/Android builds.\nPermissive peer ranges alone do not prove native renderer or toolchain compatibility;\ncheck the framework's actual supported versions and native implementation.\nAn unavailable native toolchain is a reported validation limit; do not claim the\ngroup verified. See [React Native upgrading](https://reactnative.dev/docs/upgrading).\n\nCheck developer tools' own dependencies too: a compiler release without its old\nprogrammatic API may break test/lint runners that import it even when `tsc` passes.\nAction runtime upgrades can require newer self-hosted runners; preserve workflow\npermissions, action inputs/outputs, caching, artifact semantics, and job names.\n\nCheck current advisories with read-only ecosystem audits against the baseline and\nproposed lockfiles, using the repository's configured registry/advisory sources.\nDo not send private dependency metadata to an unconfigured or unauthorized service;\nreport the resulting coverage limit. Cover direct and resolved transitive dependencies,\nincluding native/platform-specific binaries. Latest direct packages can still\npin vulnerable transitive versions. Trace each finding to its owning dependency,\nverify affected versions, runtime conditions, and remediation in the maintainer's\nadvisory and fixed release. When the owner's range permits a fixed version, use a\ntargeted refresh with the lockfile's owning manager and preserve unrelated\nresolutions; otherwise prefer a supported owner upgrade.\nIf the owner still pins a vulnerable version, a narrowly scoped security patch\noverride may be used only with API/ABI/runtime compatibility evidence and focused\nregression checks of the actual affected integration. Document its rationale and\nremoval condition; a passing install or bundle alone is insufficient. Do not run\nblind audit fixes or use blanket overrides to bypass compatibility constraints.\nReport unresolved advisories and unavailable audit coverage accurately; current\ndirect pins or a partial clean audit do not\nestablish that the whole dependency graph is safe.\n\n## Migrate and validate\n\nCapture relevant baseline checks and warnings first, after screening their side\neffects. Update one compatibility group at a time. Read the upstream instructions\nfor every breaking step; implement required source/config/schema migrations and\nremoved API replacements. Use the manager that owns each lockfile, on the selected\nruntime, and inspect the resulting diff. For Bun lockfiles, change declared\nversions with `agent-tool bun update <name[@version]>` and drop packages with\n`agent-tool bun remove <name>`; both use the pinned Bun and refuse to add a\npackage. A new dependency goes through `agent-tool bun add <name@version>`, which\nasks for approval; never introduce one by editing `package.json` and\nreinstalling. For existing Bun catalog entries use\n`agent-tool bun update --catalog default <name@version>...` (or the existing named\ncatalog). Name an explicit exact/ranged registry spec; keep `catalog:` references,\nworkspace membership, other entries, and peer compatibility contracts intact.\nThe helper refuses intake and ambiguous layouts and uses the owning manager to\nrefresh the lock; do not replace catalog references with direct versions.\n\nFor an already-resolved transitive registry package with an eligible owner range,\nuse `agent-tool bun update --resolved <name>...` with the owning Bun 1.4.4 or newer.\nIt selects every locked copy of those names, never a requested version or glob,\nand accepts only a result with identical manifests and unchanged non-target lock\nentries/metadata. It preserves release-age, overrides and patches. If an older\nmanager is pinned, or a required new child prevents a target-only result, this\npath is unsupported: prefer an owning-dependency upgrade through the normal\nhelper, or obtain approval for an explicitly reviewed manager workflow. Do not\nsilently substitute a broad refresh or add a transitive package directly. Inspect\nthe receipt/logs and re-audit; a no-op or warning can leave an advisory unresolved.\nNever hand-edit integrity hashes or lock entries.\nReview intentional patches, overrides, and pins before removal; retain them until\nupstream fixes and regression checks demonstrate they are unnecessary.\nAvoid unrelated global installations or environment changes. Use task-local or\nrepository-scoped tools for testing changed runtime pins.\nFor published packages, also validate tarballs and consumer installs with their\ndocumented supported package managers, including manifest/override syntax and\nruntime requirements. A successful owning-manager install does not prove that\npublished metadata works for those consumers.\n\nRun the repository's setup/hooks, frozen installs, lint, typechecks, tests, builds,\npackage/platform smoke checks, and relevant safe integration previews. Resolve\nupgrade-related deprecation warnings at their source. Do not suppress warnings,\nweaken tests, or disable checks; report remaining upstream/pre-existing warnings\nwith evidence and keep a target pinned when migration cannot be completed.\nAdd focused regression coverage when a migration changes behavior; avoid tests\nthat merely assert version strings. Re-run checks after repairs. Report checks\nblocked by missing credentials, platforms, or external services accurately.\nRe-audit the final resolved graph after migrations and repairs.\n\nConfirm every inventory row is upgraded, already current, intentionally constrained,\nor skipped with a concrete reason. Do not present an unresolved group as complete.\nWhen upgrading agent-tool itself, install its managed skills with the same harness\nscope and commit the ownership manifest; never edit generated managed skill copies.\n\nWhen changes depend on another repository's release, ship the producer first and\nconfirm publishing and registry availability before pinning the consumer; include\nits exact version/commit and API migration notes. Independent groups may proceed.\nComplete the installed `ship-pr` workflow within the requested scope, including\nindependent review of every changed HEAD, required CI and review feedback, merge,\nand verification of the merge's normal publication or deployment. Do not stop at\nan open PR unless the user requested that stopping point or a concrete blocker\nprevents continuing. Check deployment safety again before push/open/merge;\nshipping defaults do not waive the preview gates above.\n\n## Report\n\nKeep run-specific evidence in the upgrade PR body or a linked PR comment: the\ninventory and old/selected versions, completed migrations, validation and warnings,\nbaseline/final audits and coverage limits, preview environment/commit/tool versions\nand safe action summary, and skipped/constrained dependencies with reasons. Include\nsecurity overrides, their rationale and removal condition, and unresolved advisories.\nIf the user requested a scope that stops before a PR, provide this ledger in the\ntask report and honor that limit. For a sweep, keep one entry per repository,\nincluding unready and unchanged checkouts, and use an existing tracking issue only\nwhen explicitly requested. Never create an issue merely to store upgrade evidence.\n\nKeep durable repository guidance focused on what the next upgrade needs: current\ncompatibility constraints, intentional pins/overrides, unresolved advisories, and\nreusable repository-specific procedures. Prefer the existing maintenance document;\notherwise create `docs/dependency-upgrades.md` (or the repository's equivalent)\nonly when there is substantive guidance to preserve. For each constraint, record\nits rationale, upstream advisory/migration/issue link or originating PR, and the\ncondition and check for removing or revisiting it. Do not copy version inventories,\naudit output, validation/preview receipts, or dated run journals into that document.\n\nOn every upgrade, reconcile the existing maintenance document against the final\ndependency graph and checks: update constraints in place, remove resolved entries,\nand link the PR for historical evidence. Keep the root README focused on purpose,\nsetup, supported requirements, and normal usage, with a concise maintenance link\nwhen needed. Keep dependency-maintenance guidance in `AGENTS.md` to a short\nrouting rule and link; do not accumulate upgrade reports in either entrypoint\nor duplicate the maintenance document.\n\nFor shipping, report the branch, reviewed commit/verdict, PR, merge, publish/deploy\nresult, and final checkout state. Keep full logs private; never publish credentials,\nstate, or plan contents in any of these locations.\n"
|