@antelopejs/tooling-configs 0.3.1 → 0.3.2

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.
@@ -1,166 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { a as isString, c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
2
+ import { c as object, d as optTime, f as parseJson, h as time, i as isObject, l as optNum, m as strings, n as children, o as list, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
3
3
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
4
4
  import { c as ciRenovateSyncCallers, i as CI_RENOVATE_SYNC_REF, n as CI_NODE_REF, r as CI_PATH, s as ciNodeCallers, t as CI_CONTEXT } from "../ci-workflow-mc0vywUV.mjs";
5
- import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
6
- import { dirname, join } from "node:path";
7
- import { execFileSync, spawnSync } from "node:child_process";
8
- import { homedir, tmpdir } from "node:os";
5
+ import { i as ghToken, n as createApi, t as ApiError } from "../api-CCOiLN3w.mjs";
9
6
  import { parseArgs } from "node:util";
10
7
  import { inflateRawSync } from "node:zlib";
11
- //#region src/garden/api.ts
12
- /** A GitHub or npm answer that is not a success. */
13
- var ApiError = class extends Error {
14
- status;
15
- constructor(status, message) {
16
- super(message);
17
- this.status = status;
18
- }
19
- };
20
- const GITHUB = "https://api.github.com";
21
- const NPM = "https://registry.npmjs.org";
22
- const CREDENTIAL_NAME = /TOKEN|SECRET|PASSW|CREDENTIAL|API_?KEY|PRIVATE_?KEY|ACCESS_?KEY/i;
23
- const MINTED_TOKENS = /* @__PURE__ */ new Set(["GH_TOKEN", "GITHUB_TOKEN"]);
24
- const CREDENTIAL_FILES = [
25
- ".aws/credentials",
26
- ".netrc",
27
- ".pypirc",
28
- ".config/gcloud/application_default_credentials.json",
29
- ".kube/config",
30
- ".ssh/id_rsa",
31
- ".ssh/id_ed25519",
32
- ".ssh/id_ecdsa"
33
- ];
34
- const MAX_ATTEMPTS = 4;
35
- function ghToken() {
36
- return execFileSync("gh", ["auth", "token"], { encoding: "utf8" }).trim();
37
- }
38
- function pause(milliseconds) {
39
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
40
- }
41
- function nextLink(header) {
42
- return header?.match(/<([^>]+)>;\s*rel="next"/)?.[1];
43
- }
44
- function withPaging(path) {
45
- return path.includes("per_page=") ? path : `${path}${path.includes("?") ? "&" : "?"}per_page=100`;
46
- }
47
- function npmrcCarriesToken(home) {
48
- const path = join(home, ".npmrc");
49
- return existsSync(path) && /_auth(?:Token)?\s*=/.test(readFileSync(path, "utf8"));
50
- }
51
- /** Reads variable names only, never values. */
52
- function readSecretSurface(names, home) {
53
- const files = CREDENTIAL_FILES.filter((file) => existsSync(join(home, file)));
54
- if (npmrcCarriesToken(home)) files.push(".npmrc");
55
- return {
56
- variables: names.filter((name) => CREDENTIAL_NAME.test(name) && !MINTED_TOKENS.has(name)).sort(),
57
- files: files.sort()
58
- };
59
- }
60
- /** Runs the released `antelopejs-registry --check` against committed manifests copied to a temporary directory. */
61
- function registryCheck(files) {
62
- const directory = mkdtempSync(join(tmpdir(), "garden-registry-"));
63
- try {
64
- for (const file of files) {
65
- mkdirSync(dirname(join(directory, file.path)), { recursive: true });
66
- writeFileSync(join(directory, file.path), file.content);
67
- }
68
- const result = spawnSync("npx", [
69
- "--yes",
70
- "--package",
71
- "@antelopejs/tooling-configs@latest",
72
- "antelopejs-registry",
73
- "--check",
74
- directory
75
- ], { encoding: "utf8" });
76
- if (result.error) throw result.error;
77
- return result.status !== 0;
78
- } finally {
79
- rmSync(directory, {
80
- recursive: true,
81
- force: true
82
- });
83
- }
84
- }
85
- /** Authenticates with the token `gh` is logged in with and with no other credential. */
86
- function createApi(token) {
87
- const headers = {
88
- Authorization: `Bearer ${token}`,
89
- Accept: "application/vnd.github+json",
90
- "X-GitHub-Api-Version": "2022-11-28",
91
- "User-Agent": "antelopejs-garden"
92
- };
93
- async function request(url, init) {
94
- for (let attempt = 1;; attempt++) {
95
- const response = await fetch(url, {
96
- ...init,
97
- headers: {
98
- ...headers,
99
- ...init.headers
100
- }
101
- });
102
- const retryAfter = Number(response.headers.get("retry-after") ?? 0);
103
- if (!(response.status === 429 || response.status === 403 && retryAfter > 0 || response.status >= 502) || attempt === MAX_ATTEMPTS) return response;
104
- await pause(Math.max(retryAfter, attempt) * 1e3);
105
- }
106
- }
107
- async function get(path, accept) {
108
- const response = await request(path.startsWith("http") ? path : `${GITHUB}${path}`, { headers: accept ? { Accept: accept } : {} });
109
- if (!response.ok) throw new ApiError(response.status, `GET ${path}: HTTP ${response.status} ${(await response.text()).slice(0, 200)}`);
110
- return response;
111
- }
112
- return {
113
- async json(path) {
114
- return parseJson(await (await get(path)).text());
115
- },
116
- async pages(path, key) {
117
- const items = [];
118
- for (let url = `${GITHUB}${withPaging(path)}`; url;) {
119
- const response = await get(url);
120
- const body = parseJson(await response.text());
121
- const page = key === void 0 || !isObject(body) ? body : body[key];
122
- if (Array.isArray(page)) items.push(...page);
123
- url = nextLink(response.headers.get("link"));
124
- }
125
- return items;
126
- },
127
- async text(path) {
128
- return (await get(path, "application/vnd.github.raw+json")).text();
129
- },
130
- async bytes(path) {
131
- return new Uint8Array(await (await get(path)).arrayBuffer());
132
- },
133
- async send(method, path, body) {
134
- const response = await request(`${GITHUB}${path}`, body === void 0 ? { method } : {
135
- method,
136
- body: JSON.stringify(body),
137
- headers: { "Content-Type": "application/json" }
138
- });
139
- if (!response.ok) throw new ApiError(response.status, `${method} ${path}: HTTP ${response.status}`);
140
- },
141
- async npm(name) {
142
- const response = await fetch(`${NPM}/${name.replace("/", "%2F")}`);
143
- if (response.status === 404) return void 0;
144
- if (!response.ok) throw new ApiError(response.status, `npm ${name}: HTTP ${response.status}`);
145
- return parseJson(await response.text());
146
- },
147
- async contentLength(url) {
148
- const response = await fetch(url, { method: "HEAD" });
149
- const length = response.headers.get("content-length");
150
- return response.ok && length !== null && isString(length) ? Number(length) : void 0;
151
- },
152
- async registryDiffers(files) {
153
- return registryCheck(files);
154
- },
155
- secrets() {
156
- return readSecretSurface(Object.keys(process.env), homedir());
157
- },
158
- now() {
159
- return /* @__PURE__ */ new Date();
160
- }
161
- };
162
- }
163
- //#endregion
164
8
  //#region src/garden/decode.ts
165
9
  function orgRepo(value) {
166
10
  const source = object(value, "repository");
@@ -1253,7 +1097,7 @@ const packageSize = {
1253
1097
  //#endregion
1254
1098
  //#region src/garden/semver.ts
1255
1099
  const VERSION = /^v?(\d+)\.(\d+)\.(\d+)/;
1256
- function parse$1(text) {
1100
+ function parse(text) {
1257
1101
  const match = VERSION.exec(text.trim());
1258
1102
  return match ? [
1259
1103
  Number(match[1]),
@@ -1282,7 +1126,7 @@ function caret(floor) {
1282
1126
  }
1283
1127
  function comparator(term, version) {
1284
1128
  const operator = /^(>=|<=|>|<|=|\^|~)?\s*(.*)$/.exec(term.trim());
1285
- const bound = parse$1(operator?.[2] ?? "");
1129
+ const bound = parse(operator?.[2] ?? "");
1286
1130
  if (!operator || !bound) return true;
1287
1131
  switch (operator[1]) {
1288
1132
  case ">=": return compare$1(version, bound) >= 0;
@@ -1300,7 +1144,7 @@ function comparator(term, version) {
1300
1144
  }
1301
1145
  /** Whether a plain npm range (`^`, `~`, comparators, `||`, `*`) admits a release; wildcards and tags admit everything. */
1302
1146
  function admits(range, release) {
1303
- const version = parse$1(release);
1147
+ const version = parse(release);
1304
1148
  if (!version) return true;
1305
1149
  return range.split("||").some((alternative) => {
1306
1150
  return alternative.replace(/(>=|<=|>|<|=|\^|~)\s+/g, "$1").trim().split(/\s+/).every((term) => comparator(term, version));
@@ -1,14 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { c as object, f as parseJson, i as isObject, l as optNum, p as str, s as num, t as child } from "../json-CG2L7YFl.mjs";
3
2
  import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
4
- import { accessSync, closeSync, constants, mkdirSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
5
- import { delimiter, isAbsolute, join } from "node:path";
3
+ import { a as closeServer, c as LOCK_PORT, d as isRole, f as leaseHome, i as claimPort, l as PORT_ROLES, m as parseRecord, n as bindable, o as listenerPids, p as leaseId, r as chooseBlock, s as listensOn, t as accepting, u as isLeaseId } from "../ports-DGP6bPJy.mjs";
4
+ import { accessSync, closeSync, constants, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, rmSync, statSync, utimesSync, writeFileSync } from "node:fs";
5
+ import { delimiter, join } from "node:path";
6
6
  import { execFileSync, spawn } from "node:child_process";
7
- import { createHash } from "node:crypto";
8
7
  import { homedir } from "node:os";
9
8
  import { parseArgs } from "node:util";
10
9
  import { setTimeout } from "node:timers/promises";
11
- import { connect, createServer } from "node:net";
12
10
  //#region src/lease/env.ts
13
11
  function isServerRole(value) {
14
12
  return value === "api" || value === "web";
@@ -152,280 +150,6 @@ function launch(command, env) {
152
150
  ], env) : process.execve(verdict.file, [name, ...args], env);
153
151
  }
154
152
  //#endregion
155
- //#region src/lease/protocol.ts
156
- /**
157
- * The port every antelopejs-lease version listens on, on 127.0.0.1, while it holds the registry lock.
158
- * Each repository pins its own tooling-configs version, so this port, {@link leaseHome} and the v1
159
- * record are a protocol between versions: they may be extended, never changed.
160
- */
161
- const LOCK_PORT = 2e4;
162
- const RECORD_VERSION = 1;
163
- /** The offset of each role's port in its block of ten. Offsets 6 to 9 stay spare for later roles. */
164
- const PORT_ROLES = {
165
- api: 0,
166
- web: 1,
167
- mongo: 2,
168
- smtp: 3,
169
- inspect: 4,
170
- hmr: 5
171
- };
172
- function isRole(value) {
173
- return Object.hasOwn(PORT_ROLES, value);
174
- }
175
- /**
176
- * `ANTELOPEJS_LEASE_HOME`, else `~/.antelopejs/leases`: one registry for every repository of the
177
- * user. A relative `ANTELOPEJS_LEASE_HOME` throws, since each working directory would resolve it to
178
- * another registry.
179
- */
180
- function leaseHome(env) {
181
- const home = env.ANTELOPEJS_LEASE_HOME;
182
- if (!home) return join(homedir(), ".antelopejs", "leases");
183
- if (!isAbsolute(home)) throw new Error(`antelopejs-lease: ANTELOPEJS_LEASE_HOME must be an absolute path, not ${home}`);
184
- return home;
185
- }
186
- function isLeaseId(value) {
187
- return /^[0-9a-f]{10}$/u.test(value);
188
- }
189
- /** The lease id of the worktree whose real path is `worktree`. */
190
- function leaseId(worktree) {
191
- const id = createHash("sha256").update(worktree).digest("hex").slice(0, 10);
192
- if (!isLeaseId(id)) throw new Error(`unexpected digest ${id}`);
193
- return id;
194
- }
195
- /** Builds a value for every role, so a new role is a compile error until each table names it. */
196
- function eachRole(value) {
197
- return {
198
- api: value("api"),
199
- web: value("web"),
200
- mongo: value("mongo"),
201
- smtp: value("smtp"),
202
- inspect: value("inspect"),
203
- hmr: value("hmr")
204
- };
205
- }
206
- function isMongoMode(value) {
207
- return value === "owned" || value === "external";
208
- }
209
- function decodeRecord(value) {
210
- const source = object(value, "lease.json");
211
- if (num(source, "version") !== RECORD_VERSION) return void 0;
212
- const id = str(source, "id");
213
- const mongo = str(source, "mongo");
214
- if (!isLeaseId(id) || !isMongoMode(mongo)) return void 0;
215
- const ports = child(source, "ports");
216
- return {
217
- version: RECORD_VERSION,
218
- id,
219
- worktree: str(source, "worktree"),
220
- gitInode: num(source, "gitInode"),
221
- gitBirth: num(source, "gitBirth"),
222
- ports: eachRole((role) => num(ports, role)),
223
- createdAt: str(source, "createdAt"),
224
- mongo
225
- };
226
- }
227
- function reservedPorts(value) {
228
- if (!isObject(value) || !Object.hasOwn(value, "ports")) return [];
229
- const ports = value.ports;
230
- if (!isObject(ports)) return [];
231
- return Object.keys(ports).map((key) => optNum(ports, key)).filter((port) => port !== void 0);
232
- }
233
- function tryJson(text) {
234
- try {
235
- return parseJson(text);
236
- } catch {
237
- return;
238
- }
239
- }
240
- function tryRecord(value) {
241
- try {
242
- return decodeRecord(value);
243
- } catch {
244
- return;
245
- }
246
- }
247
- /** Reads a `lease.json` leniently: unknown fields are ignored, anything unreadable is `foreign`. */
248
- function parseRecord(text) {
249
- const value = tryJson(text);
250
- if (value === void 0) return {
251
- kind: "foreign",
252
- reserved: []
253
- };
254
- const record = tryRecord(value);
255
- if (record !== void 0) return {
256
- kind: "current",
257
- record
258
- };
259
- return {
260
- kind: "foreign",
261
- reserved: reservedPorts(value)
262
- };
263
- }
264
- //#endregion
265
- //#region src/lease/ports.ts
266
- const BAND_START = 20010;
267
- const BLOCK_SIZE = 10;
268
- const BLOCK_COUNT = 9990 / BLOCK_SIZE;
269
- const DENIED_PORTS = [
270
- 24678,
271
- 27017,
272
- 27018,
273
- 27019
274
- ];
275
- const CONNECT_TIMEOUT_MS = 1e3;
276
- const LISTEN_STATE = "0A";
277
- /**
278
- * The block bases a lease tries, in order: from a block picked by a hash of the id and `uid`
279
- * together, forward and around the band. Each user keeps a registry of its own, so mixing in the
280
- * uid usually starts two users' worktrees at one path on different blocks. The band [20010, 30000)
281
- * sits below the kernel's ephemeral range (32768 and up on Linux, 49152 and up on macOS), so no
282
- * `bind(:0)` caller races for these ports. Blocks holding the Vite HMR default (24678) or a system
283
- * mongod (27017 to 27019) are skipped.
284
- */
285
- function candidateBases(id, uid = process.getuid?.() ?? 0) {
286
- const first = createHash("sha256").update(`${uid}:${id}`).digest().readUInt32BE(0) % BLOCK_COUNT;
287
- return Array.from({ length: BLOCK_COUNT }, (_, step) => BAND_START + (first + step) % BLOCK_COUNT * BLOCK_SIZE).filter((base) => !DENIED_PORTS.some((port) => port >= base && port < base + BLOCK_SIZE));
288
- }
289
- function blockPorts(base) {
290
- return Array.from({ length: BLOCK_SIZE }, (_, offset) => base + offset);
291
- }
292
- async function everyBindable(ports, bindable) {
293
- for (const port of ports) if (!await bindable(port)) return false;
294
- return true;
295
- }
296
- /**
297
- * The first candidate block none of whose ten ports is in `taken` and all of whose ports bind.
298
- * Throws when the band has no such block.
299
- */
300
- async function chooseBlock(id, taken, bindable) {
301
- for (const base of candidateBases(id)) {
302
- const ports = blockPorts(base);
303
- if (ports.some((port) => taken.has(port))) continue;
304
- if (await everyBindable(ports, bindable)) return eachRole((role) => base + PORT_ROLES[role]);
305
- }
306
- throw new Error(`antelopejs-lease: no free port block in ${BAND_START}-29999; run antelopejs-lease gc, then retry`);
307
- }
308
- /** Listens on `host:port`, Node's dual-stack default without `host`. `undefined` when the address is in use. */
309
- function claimPort(port, host) {
310
- return new Promise((resolve, reject) => {
311
- const server = createServer();
312
- server.once("error", (error) => {
313
- if (error.code === "EADDRINUSE") resolve(void 0);
314
- else reject(error);
315
- });
316
- server.listen({
317
- port,
318
- host
319
- }, () => resolve(server));
320
- });
321
- }
322
- function closeServer(server) {
323
- return new Promise((resolve) => server.close(() => resolve()));
324
- }
325
- async function bindsOn(port, host) {
326
- try {
327
- const server = await claimPort(port, host);
328
- if (server === void 0) return false;
329
- await closeServer(server);
330
- return true;
331
- } catch {
332
- return false;
333
- }
334
- }
335
- /**
336
- * True when nothing holds `port`. The dual-stack wildcard bind fails on Linux for a listener on any
337
- * local address; the 127.0.0.1 bind covers systems that let a wildcard sit beside a specific address.
338
- */
339
- async function bindable(port) {
340
- return await bindsOn(port, "127.0.0.1") && bindsOn(port);
341
- }
342
- function acceptsOn(port, host) {
343
- return new Promise((resolve) => {
344
- const socket = connect({
345
- port,
346
- host,
347
- timeout: CONNECT_TIMEOUT_MS
348
- });
349
- const settle = (answer) => {
350
- socket.destroy();
351
- resolve(answer);
352
- };
353
- socket.once("connect", () => settle(true));
354
- socket.once("timeout", () => settle(false));
355
- socket.once("error", () => settle(false));
356
- });
357
- }
358
- /** True when a server accepts connections on `port` on the IPv4 or the IPv6 loopback. */
359
- async function accepting(port) {
360
- return await acceptsOn(port, "127.0.0.1") || acceptsOn(port, "::1");
361
- }
362
- function listenInodes(table, port) {
363
- let text;
364
- try {
365
- text = readFileSync(table, "utf8");
366
- } catch {
367
- return [];
368
- }
369
- return text.split("\n").slice(1).map((line) => line.trim().split(/\s+/u)).filter((columns) => columns[3] === LISTEN_STATE && Number.parseInt(columns[1]?.split(":")[1] ?? "", 16) === port).map((columns) => `socket:[${columns[9]}]`);
370
- }
371
- function holdsSocket(pid, sockets) {
372
- let fds;
373
- try {
374
- fds = readdirSync(`/proc/${pid}/fd`);
375
- } catch {
376
- return false;
377
- }
378
- return fds.some((fd) => {
379
- try {
380
- return sockets.has(readlinkSync(`/proc/${pid}/fd/${fd}`));
381
- } catch {
382
- return false;
383
- }
384
- });
385
- }
386
- function listenSockets(port) {
387
- return /* @__PURE__ */ new Set([...listenInodes("/proc/net/tcp", port), ...listenInodes("/proc/net/tcp6", port)]);
388
- }
389
- function linuxListenerPids(port) {
390
- const sockets = listenSockets(port);
391
- if (sockets.size === 0) return [];
392
- return readdirSync("/proc").filter((name) => /^\d+$/u.test(name) && holdsSocket(name, sockets)).map(Number);
393
- }
394
- function lsofListenerPids(port) {
395
- try {
396
- return execFileSync("lsof", [
397
- "-nP",
398
- "-t",
399
- `-iTCP:${port}`,
400
- "-sTCP:LISTEN"
401
- ], {
402
- encoding: "utf8",
403
- stdio: [
404
- "ignore",
405
- "pipe",
406
- "ignore"
407
- ]
408
- }).split("\n").filter((line) => /^\d+$/u.test(line)).map(Number);
409
- } catch {
410
- return [];
411
- }
412
- }
413
- /** The pids listening on `port` that this user may inspect; empty when none can be read. */
414
- function listenerPids(port) {
415
- if (process.platform === "linux") return linuxListenerPids(port);
416
- if (process.platform === "darwin") return lsofListenerPids(port);
417
- return [];
418
- }
419
- /**
420
- * True when process `pid` listens on `port`. Where the platform gives no way to tell, true when
421
- * anything accepts on `port`.
422
- */
423
- async function listensOn(pid, port) {
424
- if (process.platform === "linux") return holdsSocket(String(pid), listenSockets(port));
425
- if (process.platform === "darwin") return lsofListenerPids(port).includes(pid);
426
- return accepting(port);
427
- }
428
- //#endregion
429
153
  //#region src/lease/mongo.ts
430
154
  const READY_TIMEOUT_MS = 3e4;
431
155
  const KILL_WAIT_MS = 2e3;
package/dist/bin/sync.mjs CHANGED
@@ -749,7 +749,7 @@ const KIND_TEXT = {
749
749
  template: {
750
750
  description: "Drive this AntelopeJS template the way a new user does: scaffold a project with `ajs project init` from an offline interfaces manifest, install it, run its own `pnpm run checks`, run `ajs project dev --watch` and hit its welcome page, endpoint or ready line. Use to prove a change to the template works before merge, to verify a PR, or to run the release canary.",
751
751
  title: "Verify template",
752
- user: "The user of a template is someone running `ajs project init --template`: they get a copy of the whole repository and expect it to install, pass its checks and run.",
752
+ user: "The user of a template is someone running `ajs project init --template`: they get a copy of the repository without `.agents/` and `.claude/skills/` and expect it to install, pass its checks and run.",
753
753
  launch: "`new` copies the working tree, uncommitted changes included, into a local git repository, and lists it in an offline interfaces manifest (`templates`, or `projectTemplates` when `template.project` is set) under `template.name`. Journeys point `ajs config set git` at it, so no step reaches GitHub. Every `services` entry of `verify.config.ts` then starts in its own Docker container on a free loopback port, as for a module.",
754
754
  builtins: `- \`scaffold-dev\`: \`ajs project init <app> --template <name> --pm pnpm --git-init\`, \`pnpm install --frozen-lockfile\`, then \`ajs project dev --watch\` with \`PORT\` set until \`template.probe\` answers: a path and status on that port, or a \`log\` line followed by \`settleMs\` of still running. Ctrl+C must exit 130.
755
755
  - \`scaffold-checks\`: the same scaffold and install, then the project's own \`pnpm run checks\`.`,
@@ -758,7 +758,7 @@ const KIND_TEXT = {
758
758
  - \`services\`: image, port, readiness command and \`reset\`, as for a module. \`new\` starts them in Docker on free ports; a journey reads them with \`context.service(name)\` and \`context.native(...)\` and passes their endpoints to the project it starts through the \`env\` of \`context.dev\`.
759
759
  - \`template.probe\`: \`path\`, \`status\` and \`body\` for an HTTP welcome page or endpoint, or \`log\` and \`settleMs\` for a template that serves nothing.`,
760
760
  smoke: "`scaffold-dev` and `scaffold-checks`",
761
- gotchas: ["`ajs` copies the whole repository, `.agents/` and `.claude/` included, so the scaffolded project carries this skill too.", "Every file a user gets is user-facing here, tests included; only `.agents/`, `.claude/` and `.github/` are not."]
761
+ gotchas: ["`ajs project init` leaves out `.agents/` and `.claude/skills/`, so the scaffolded project carries neither this skill nor anything else under `.agents/`. Never expect either folder there.", "Every file a user gets is user-facing here, tests included; only `.github/` and `.claude/` outside `.claude/skills/` are not."]
762
762
  }
763
763
  };
764
764
  //#endregion
@@ -819,7 +819,7 @@ Each step writes \`<run>/evidence/<feature>/<journey>/<NN-step>/\` with \`comman
819
819
  ${BIN} clean <run>
820
820
  \`\`\`
821
821
 
822
- \`clean\` stops what the run started, by recorded PID and container name, and removes everything but \`evidence/\` and \`run.json\`. Run it after every run, failed ones included.
822
+ Each journey deletes its scratch folder and \`HOME\`, its install included, when it ends: passed, failed or interrupted. Only its evidence stays. \`clean\` stops what the run started, by recorded PID and container name, and removes everything but \`evidence/\` and \`run.json\`. Run it after every run, failed ones included.
823
823
 
824
824
  ## The repository's own layer
825
825
 
@@ -884,7 +884,7 @@ The skill is not Trusted yet. It becomes Trusted when it passes a shadow run of
884
884
  ## Gotchas
885
885
 
886
886
  ${bullets(text.gotchas)}
887
- - Runs live under the system temp folder (\`TMPDIR\`), and the shared caches under \`~/.cache/antelopejs-verify\`.
887
+ - Runs live under the system temp folder (\`TMPDIR\`), and the shared caches under \`~/.cache/antelopejs-verify\`. \`new\` deletes every run no command touched for 7 days, unless a process it recorded is still alive.
888
888
  - A repository that outgrows this skill runs \`antelopejs-sync --verify custom\` and keeps its own \`.agents/skills/verify-<repo>/\`.
889
889
  `;
890
890
  }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ import { c as object, h as time, n as children, p as str, r as flag, s as num, t as child, u as optStr } from "../json-CG2L7YFl.mjs";
3
+ import { n as runCliAsync } from "../cli-4Tv71vYk.mjs";
4
+ import { i as ghToken, r as createGraphql } from "../api-CCOiLN3w.mjs";
5
+ import { parseArgs } from "node:util";
6
+ //#region src/triage/triage.ts
7
+ /** Open, unassigned issues labelled `needs-triage` in the organization's public, non-archived repositories. */
8
+ const SEARCH = "org:AntelopeJS is:issue is:open is:public archived:false label:needs-triage no:assignee";
9
+ const LIMIT = 10;
10
+ const FIRST_LINE_LENGTH = 200;
11
+ const HEADING = /^#{1,6}(?:\s|$)/;
12
+ const KIND_ORDER = {
13
+ bug: 0,
14
+ feature: 1,
15
+ other: 2
16
+ };
17
+ const QUERY = `query($q: String!, $after: String) {
18
+ search(type: ISSUE, query: $q, first: 100, after: $after) {
19
+ pageInfo { hasNextPage endCursor }
20
+ nodes {
21
+ ... on Issue {
22
+ number title url body createdAt
23
+ repository { nameWithOwner }
24
+ labels(first: 20) { nodes { name } }
25
+ issueType { name }
26
+ reactions(content: THUMBS_UP) { totalCount }
27
+ closedByPullRequestsReferences(first: 1, includeClosedPrs: false) { totalCount }
28
+ }
29
+ }
30
+ }
31
+ }`;
32
+ /** The `bug` label, or the `feature` or `enhancement` label, decides; without one, the issue type does. */
33
+ function kind(labels, type) {
34
+ if (labels.includes("bug")) return "bug";
35
+ if (labels.includes("feature") || labels.includes("enhancement")) return "feature";
36
+ if (type === "Bug") return "bug";
37
+ if (type === "Feature") return "feature";
38
+ return "other";
39
+ }
40
+ /** The first line that carries text: blank lines, Markdown headings, HTML comments and an issue form's `_No response_` are skipped. */
41
+ function firstLine(body) {
42
+ const line = body.replace(/<!--[\s\S]*?-->/g, "").split(/\r?\n/).map((entry) => entry.trim()).find((entry) => entry !== "" && !HEADING.test(entry) && entry !== "_No response_");
43
+ return Array.from(line ?? "").slice(0, FIRST_LINE_LENGTH).join("");
44
+ }
45
+ function issue(value) {
46
+ const source = object(value, "issue");
47
+ const labels = children(child(source, "labels"), "nodes").map((label) => str(label, "name"));
48
+ const type = Object.hasOwn(source, "issueType") ? source.issueType : null;
49
+ return {
50
+ ref: `${str(child(source, "repository"), "nameWithOwner")}#${num(source, "number")}`,
51
+ url: str(source, "url"),
52
+ kind: kind(labels, type === null ? void 0 : optStr(object(type, "issueType"), "name")),
53
+ title: str(source, "title"),
54
+ firstLine: firstLine(optStr(source, "body") ?? ""),
55
+ createdAt: time(source, "createdAt"),
56
+ thumbsUp: num(child(source, "reactions"), "totalCount"),
57
+ linkedOpenPulls: num(child(source, "closedByPullRequestsReferences"), "totalCount")
58
+ };
59
+ }
60
+ /** Bugs before features before the rest, then most 👍 first, then oldest first; the reference breaks a tie. */
61
+ function compare(a, b) {
62
+ return KIND_ORDER[a.kind] - KIND_ORDER[b.kind] || b.thumbsUp - a.thumbsUp || a.createdAt - b.createdAt || (a.ref < b.ref ? -1 : a.ref > b.ref ? 1 : 0);
63
+ }
64
+ /** Drops issues an open pull request is linked to, ranks the rest and keeps the first {@link LIMIT}. */
65
+ function rank(issues) {
66
+ const open = issues.filter((entry) => entry.linkedOpenPulls === 0).sort(compare);
67
+ return {
68
+ items: open.slice(0, LIMIT).map((entry) => ({
69
+ ref: entry.ref,
70
+ url: entry.url,
71
+ kind: entry.kind,
72
+ title: entry.title,
73
+ firstLine: entry.firstLine,
74
+ created: new Date(entry.createdAt).toISOString().slice(0, 10)
75
+ })),
76
+ notShown: Math.max(open.length - LIMIT, 0)
77
+ };
78
+ }
79
+ /** Reads every page of the search and ranks it. */
80
+ async function triage(graphql) {
81
+ const issues = [];
82
+ for (let after, more = true; more;) {
83
+ const search = child(object(await graphql(QUERY, after === void 0 ? { q: SEARCH } : {
84
+ q: SEARCH,
85
+ after
86
+ }), "data"), "search");
87
+ issues.push(...children(search, "nodes").filter((node) => Object.keys(node).length > 0).map(issue));
88
+ const page = child(search, "pageInfo");
89
+ after = optStr(page, "endCursor");
90
+ more = flag(page, "hasNextPage") && after !== void 0;
91
+ }
92
+ return rank(issues);
93
+ }
94
+ /** One line per shortlisted issue and one for the rest; nothing when no issue waits. */
95
+ function lines(shortlist) {
96
+ return [...shortlist.items.map((entry) => `${entry.ref} ${entry.kind} ${entry.created} ${entry.title}`), ...shortlist.notShown > 0 ? [`${shortlist.notShown} more not shown`] : []];
97
+ }
98
+ //#endregion
99
+ //#region src/bin/triage.ts
100
+ await runCliAsync(async () => {
101
+ const { values } = parseArgs({ options: { json: { type: "boolean" } } });
102
+ const shortlist = await triage(createGraphql(ghToken()));
103
+ if (values.json) process.stdout.write(`${JSON.stringify(shortlist, null, 2)}\n`);
104
+ else for (const line of lines(shortlist)) process.stdout.write(`${line}\n`);
105
+ return 0;
106
+ });
107
+ //#endregion
108
+ export {};