@se-studio/skills 1.10.12 → 1.10.17

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @se-studio/skills
2
2
 
3
+ ## 1.10.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 5350ad5: Add `se-agent-guard core-request`: files a Core request as a `from-customer` issue in se-core-product (one open issue per project and feature, `--dry-run` supported). Customer agents block v4 and `cross-project-handoff.md` say to use it, and `pnpm fleet-audit` lists open Core requests.
8
+
9
+ ## 1.10.16
10
+
11
+ ### Patch Changes
12
+
13
+ - 71fc433: Add `pnpm fleet-audit` in core: a read-only fleet consistency audit that reads each registry project from `origin/<integration branch>` and reports stale agents blocks, restated review rules, manual-deploy and skills-update scripts, non-exact pins, skills older than 1.10.7, packages behind core, and `pushed-through` merges.
14
+
15
+ ## 1.10.15
16
+
17
+ ### Patch Changes
18
+
19
+ - 5cf974b: Merge approval no longer names one person: any authorised human may give the go (an agent records it, never approves). The gate accepts `none, approver override` alongside `none, Nick override`. Reviews by the author are fine.
20
+
21
+ ## 1.10.14
22
+
23
+ ### Patch Changes
24
+
25
+ - 1beb030: Merge gate failure message now says exactly how to fix a missing review link (names the 12-character head and the comment to post) and mentions the promote `CI covers the changes since` line only on a production promote. `AGENTS.md` and the customer block carry one `## Merge approval` template and say to hold a PR with draft or the `do not merge` label.
26
+
27
+ ## 1.10.13
28
+
29
+ ### Patch Changes
30
+
31
+ - 5c8d710: Customer agents block v3: one copy of the review and merge rules (no restated copies), the design-review security trigger and reviewer identity in step 1, and a `## Review (no code change)` note for lint-only follow-up commits.
32
+
3
33
  ## 1.10.12
4
34
 
5
35
  ### Patch Changes
package/README.md CHANGED
@@ -83,6 +83,10 @@ Do not edit `packages/contentful-cms/skills/` directly. See `packages/contentful
83
83
 
84
84
  **Do not use `.claude/skills/` in the repo** as a skill source — it is untracked and local. Use `.agents/skills/` (in this monorepo via `pnpm skills:sync`, in a customer site via `skills-npm`) or `cms-edit skill install`.
85
85
 
86
+ ## Core-only skills
87
+
88
+ `core-only/<skill>/SKILL.md` holds skills for agents working in **this repo** that must not reach customers (for example the `contentful-events-*` skills, which read an internal database). They follow the same frontmatter rules and `pnpm skills:validate` checks them, and `pnpm skills:sync` copies them into `.agents/skills` alongside the published ones. `core-only/` is deliberately absent from this package's `files` list, so it is never published to npm or linked into a customer repo. A name that exists in both `skills/` and `core-only/` fails the sync. A skill meant for customers goes in `skills/`.
89
+
86
90
  ## Vendored pstack (trial)
87
91
 
88
92
  SE Studio may vendor a **subset** of [cursor/plugins pstack](https://github.com/cursor/plugins/tree/main/pstack) skills under `skills/` for a se-core-product-only trial. See [`VENDOR_PSTACK.md`](./VENDOR_PSTACK.md) for the pin, adopt/exclude list, Auto-only adaptations, and MIT attribution (`LICENSE.pstack`). Gate rule: [`.cursor/rules/pstack-trial-gates.mdc`](../../.cursor/rules/pstack-trial-gates.mdc). Do **not** run `/setup-pstack` or install excluded skills (`poteto-mode`, `arena`, `swarm`, Benny, etc.). No npm release of these trial skills until Nick approves a customer rollout.
@@ -6,6 +6,7 @@
6
6
  * se-agent-guard push git pre-push hook (ref lines on stdin)
7
7
  * se-agent-guard claude-pretool Claude Code PreToolUse hook (payload on stdin)
8
8
  * se-agent-guard merge-gate <pr> [--audit]
9
+ * se-agent-guard core-request --from <key> --feature <slug> --why "..." file a tracked Core request
9
10
  * se-agent-guard worktrees-clean [--apply] [--remote] remove merged worktrees and branches
10
11
  */
11
12
  import { spawnSync } from 'node:child_process';
@@ -17,6 +18,7 @@ const SUBCOMMANDS = {
17
18
  push: ['cli.mjs', ['push']],
18
19
  'claude-pretool': ['claude-pretool.mjs', []],
19
20
  'merge-gate': ['merge-gate.mjs', []],
21
+ 'core-request': ['core-request.mjs', []],
20
22
  'worktrees-clean': ['worktrees-clean.mjs', []],
21
23
  };
22
24
 
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * `se-agent-guard core-request`: file a Core request as a tracked issue in se-core-product,
4
+ * so a problem found in a customer repo is fixed in core instead of living in a chat.
5
+ *
6
+ * se-agent-guard core-request --from <project_key> --feature <slug> --why "<one sentence>"
7
+ * [--packages "@se-studio/a,@se-studio/b"] [--pr <customer PR url>] [--dry-run]
8
+ *
9
+ * One open issue per (project, feature): running it twice returns the existing issue.
10
+ * Works from any repo and any agent; it only needs `gh` with access to the core repo.
11
+ */
12
+ import { execFileSync } from 'node:child_process';
13
+ import path from 'node:path';
14
+ import { fileURLToPath } from 'node:url';
15
+
16
+ export const CORE_REPO = 'Something-Else-Studio/se-core-product';
17
+ export const LABEL = 'from-customer';
18
+
19
+ /** @returns {{ title: string, body: string }} */
20
+ export function buildIssue({ from, feature, why, packages, pr }) {
21
+ const missing = Object.entries({ from, feature, why }).filter(([, v]) => !v?.trim());
22
+ if (missing.length) throw new Error(`missing: ${missing.map(([k]) => `--${k}`).join(', ')}`);
23
+ const pkgs = (packages ?? '')
24
+ .split(',')
25
+ .map((p) => p.trim())
26
+ .filter(Boolean);
27
+ return {
28
+ title: `[${from}] ${feature}`,
29
+ body: [
30
+ '## Core request',
31
+ '',
32
+ `**From site:** ${from}`,
33
+ `**Feature:** ${feature}`,
34
+ `**Why core:** ${why.trim()}`,
35
+ ...(pkgs.length ? [`**Suggested packages:** ${pkgs.map((p) => `\`${p}\``).join(', ')}`] : []),
36
+ ...(pr ? [`**Customer PR:** ${pr}`] : []),
37
+ '',
38
+ `**Site status:** parked or working around this until the fix publishes to npm.`,
39
+ '**Do not:** implement this behaviour in the customer repo.',
40
+ '',
41
+ 'Fix in core: changeset, merge to `dev`, promote, then a Site request to bump the customer.',
42
+ ].join('\n'),
43
+ };
44
+ }
45
+
46
+ const gh = (...args) =>
47
+ execFileSync('gh', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
48
+
49
+ function parse(argv) {
50
+ const opts = {};
51
+ for (let i = 0; i < argv.length; i++) {
52
+ const a = argv[i];
53
+ if (a === '--dry-run') opts.dryRun = true;
54
+ else if (a.startsWith('--')) opts[a.slice(2)] = argv[++i];
55
+ }
56
+ return opts;
57
+ }
58
+
59
+ function main() {
60
+ const opts = parse(process.argv.slice(2));
61
+ let issue;
62
+ try {
63
+ issue = buildIssue(opts);
64
+ } catch (error) {
65
+ console.error(`core-request: ${error.message}`);
66
+ process.exit(2);
67
+ }
68
+ if (opts.dryRun) {
69
+ console.log(`${issue.title}\n\n${issue.body}`);
70
+ return;
71
+ }
72
+ const existing = JSON.parse(
73
+ gh(
74
+ 'issue',
75
+ 'list',
76
+ '-R',
77
+ CORE_REPO,
78
+ '--label',
79
+ LABEL,
80
+ '--state',
81
+ 'open',
82
+ '--limit',
83
+ '200',
84
+ '--json',
85
+ 'number,title,url',
86
+ ),
87
+ ).find((i) => i.title === issue.title);
88
+ if (existing) {
89
+ console.log(`core-request: already open as #${existing.number} ${existing.url}`);
90
+ return;
91
+ }
92
+ gh(
93
+ 'label',
94
+ 'create',
95
+ LABEL,
96
+ '-R',
97
+ CORE_REPO,
98
+ '--force',
99
+ '--color',
100
+ '5319E7',
101
+ '--description',
102
+ 'Problem found in a customer repo that is fixed in core',
103
+ );
104
+ console.log(
105
+ gh(
106
+ 'issue',
107
+ 'create',
108
+ '-R',
109
+ CORE_REPO,
110
+ '--label',
111
+ LABEL,
112
+ '--title',
113
+ issue.title,
114
+ '--body',
115
+ issue.body,
116
+ ),
117
+ );
118
+ }
119
+
120
+ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main();
@@ -64,7 +64,7 @@ function linksIn(body) {
64
64
  }
65
65
 
66
66
  /** The approval line `none, Nick override` must stand alone, not sit in a quote or a negation. */
67
- const OVERRIDE_LINE = /^\s*(?:\d+[.)]\s*)?none,\s*nick override\.?\s*$/im;
67
+ const OVERRIDE_LINE = /^\s*(?:\d+[.)]\s*)?none,\s*(?:nick|approver)\s+override\.?\s*$/im;
68
68
 
69
69
  /**
70
70
  * Production promote, and only these pairs: core `dev` → `main`, or a site
@@ -92,7 +92,7 @@ const CI_COVERS_LINE =
92
92
  * Anyone may approve, but the approval has to point at a review that really exists on this PR
93
93
  * at the current head: a review comment (agent or human) naming the head SHA (full, or a
94
94
  * prefix of at least 12 hex characters), with a verdict, posted before the approval.
95
- * `none, Nick override` skips it. A promote may use a whole line `CI covers the changes since`.
95
+ * `none, Nick override` (or `none, approver override`) skips it. A promote may use a whole line `CI covers the changes since`.
96
96
  * Links to PR reviews (#pullrequestreview-N) are
97
97
  * not accepted: gh returns no numeric review id, so such a link cannot be tied to a review.
98
98
  * Cannot detect a review comment edited after the approval (gh returns no updatedAt).
@@ -140,11 +140,15 @@ export function evaluateMergeGate(pr, { ignoreDraft = false } = {}) {
140
140
  'New commits since the approval need a fresh one.',
141
141
  );
142
142
  } else if (!atHead.some((c) => citedReview(c, pr))) {
143
+ const head = pr.headRefOid.slice(0, 12);
143
144
  problems.push(
144
145
  'The `## Merge approval` comment must link a review on this PR (an agent or human review comment ' +
145
- 'naming the current head SHA — the full SHA or a prefix of at least 12 hex characters — with a verdict, posted before the approval), or have a line saying `none, Nick override`. ' +
146
+ 'naming the current head SHA — the full SHA or a prefix of at least 12 hex characters — with a verdict, posted before the approval), or have a line saying `none, Nick override` (or `none, approver override`). ' +
146
147
  'A hex string that is not that prefix does not count. ' +
147
- 'A production promote (`dev` → `main`, or `develop` → `main` / `production`, same repository) may use a whole line `CI covers the changes since` with no review on that PR.',
148
+ (isProductionPromote(pr)
149
+ ? 'This is a production promote: a whole line `CI covers the changes since` also works, with no review on this PR. '
150
+ : '') +
151
+ `Fix: post a review comment headed "## Code review" that names ${head} and gives a verdict (PASS, BLOCKERS, NITs, LGTM or approved), then a \`## Merge approval\` with the line \`Review: <link to that comment>\` (see the template in AGENTS.md).`,
148
152
  );
149
153
  }
150
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@se-studio/skills",
3
- "version": "1.10.12",
3
+ "version": "1.10.17",
4
4
  "description": "SE Studio agent skills for marketing site development with Contentful CMS",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,6 +20,15 @@ Emit when placement says **core**, or the site is blocked on missing package beh
20
20
  **Do not:** implement this behaviour in the customer repo.
21
21
  ```
22
22
 
23
+ File it as a tracked issue, not only in chat (any agent, from any repo):
24
+
25
+ ```bash
26
+ pnpm exec se-agent-guard core-request --from <project_key> --feature <feature-slug> \
27
+ --why "<one sentence>" --packages "@se-studio/<pkg>" --pr <customer PR url>
28
+ ```
29
+
30
+ It opens an issue labelled `from-customer` in `se-core-product` (one open issue per project and feature; a repeat returns the existing one). Paste the block in chat too if the person is waiting. A customer PR that works around core behaviour in the meantime must link that issue in its body.
31
+
23
32
  Then switch to **core-first** (same multi-root chat or a core session), implement, changeset, publish.
24
33
 
25
34
  ## Site request (core → sites)
@@ -1,4 +1,4 @@
1
- <!-- BEGIN:se-core-agents-block v2 -->
1
+ <!-- BEGIN:se-core-agents-block v4 -->
2
2
  ## Next.js docs (version-matched)
3
3
 
4
4
  This site runs **Next.js 16** (the minor is in `package.json`). Before writing Next.js code, read the relevant guide in `node_modules/next/dist/docs/` (in monorepos, resolve from the app that depends on `next`). Keep the managed `<!-- BEGIN:nextjs-agent-rules -->` block in `AGENTS.md`. Do **not** use `npx @next/codemod agents-md`, `.next-docs`, or `NEXT-AGENTS-MD-START` (Next 15 index: Pages Router, `middleware.ts`).
@@ -33,7 +33,7 @@ Before non-trivial code, run the placement checklist (in the skill). Summary:
33
33
  | **Customer shared package** (if monorepo) | Consent/analytics shared across sites in this customer |
34
34
  | **`se-core-product`** (`@se-studio/*`) | Fixes/features needed by 2+ sites, CMS infrastructure |
35
35
 
36
- If the checklist says **core**, stop and emit a **Core request** ([`cross-project-handoff.md`](./cross-project-handoff.md)) — do not patch `@se-studio` behaviour in this repo. Shared converters, Visual/video delivery, cms-edit runtime, sitemap helpers, and site-check assertions belong in core, not a one-site fork. Switch to core-first (or a core session); park the site until npm.
36
+ If the checklist says **core**, stop and emit a **Core request** ([`cross-project-handoff.md`](./cross-project-handoff.md)) — do not patch `@se-studio` behaviour in this repo. File it with `pnpm exec se-agent-guard core-request --from <project_key> --feature <slug> --why "..."` so it is a tracked `from-customer` issue in core, not only a chat message. A PR here that works around core in the meantime links that issue. Shared converters, Visual/video delivery, cms-edit runtime, sitemap helpers, and site-check assertions belong in core, not a one-site fork. Switch to core-first (or a core session); park the site until npm.
37
37
 
38
38
  ### Deploy smoke failed?
39
39
 
@@ -70,12 +70,24 @@ Non-UI changes skip visual gates and go to code review.
70
70
 
71
71
  Before asking to merge to `develop`, run the review in `CODE_REVIEW.md` and stop. Findings: **BLOCKER** / **NIT**. Do not keep a second checklist in `AGENTS.md`. That file only points at `CODE_REVIEW.md`.
72
72
 
73
- One AI review per piece of work, at the end, on the final head SHA. Do not re-review on every push. Lint, typecheck, and tests are CI (the shared site CI workflow). A design review, by someone who did not write the change, is only for schema, forms, analytics, caching, or security. Use skill `architecture-review` and post `## Design review` (PASS / BLOCKERS) as part of that one review.
73
+ The review, design-review triggers and merge steps are in **Review and merge** below. That is the only copy: do not restate it in `.cursor/rules`, `docs/` or another file in this repo.
74
74
 
75
75
  ### Review and merge
76
76
 
77
- 1. **Review.** One review (an agent or a human), when the work is finished. Post it as a PR comment under a heading that says "review", name the **final head SHA** (the full SHA, or a prefix of at least 12 hex characters), and give a verdict (PASS, BLOCKERS, NITs, LGTM or approved). Do not re-review on every push. A later commit that changes schema, forms, analytics, caching, or security gets a review of that delta only. Anything else is CI, and the cited review must still name the current head. A different hex string does not count.
78
- 2. **Approve.** Nick's go in chat is the approval. The agent records it as a PR comment headed `## Merge approval`: who, where, when (Europe/London), the head SHA, and a link to the review comment (`#issuecomment-N` on this PR). Post the review before the approval. Never merge a PR marked **do not merge**.
77
+ 1. **Review.** One review (an agent or a human), when the work is finished. Post it as a PR comment under a heading that says "review", name the **final head SHA** (the full SHA, or a prefix of at least 12 hex characters), and give a verdict (PASS, BLOCKERS, NITs, LGTM or approved). Lint, typecheck and tests are CI (the shared site CI workflow). A change to schema, forms, analytics, caching or security (auth, secrets, headers, access control) also gets a design review in that same review: use skill `architecture-review` and post `## Design review` (PASS / BLOCKERS). Do not re-review on every push. A later commit that changes schema, forms, analytics, caching, or security gets a review of that delta only. Anything else is CI and needs no new code review, but post a one-line `## Review (no code change)` comment at the new head (`PASS at <head SHA, at least 12 hex characters>. Only lint/typecheck/tests/format since <link to earlier review>.`) and link that from the approval. A different hex string does not count.
78
+ 2. **Approve.** Nick's go in chat (or another human the owner has authorised) is the approval; an agent records it but is never the approver. The agent records it as a PR comment headed `## Merge approval`: who, where, when (Europe/London), the head SHA, and a link to the review comment (`#issuecomment-N` on this PR). Post the review before the approval. Never merge a PR marked **do not merge**.
79
+ Template, one comment:
80
+
81
+ ```markdown
82
+ ## Merge approval
83
+ - Who: <name of the person who said go>
84
+ - Where: <chat or agent session, or "GitHub">
85
+ - When: <Europe/London, from `TZ=Europe/London date '+%Y-%m-%d %H:%M %Z'`>
86
+ - Head SHA: <full head SHA>
87
+ - Review: <link to the review comment>
88
+ ```
89
+
90
+ A production promote may use a line that is exactly `CI covers the changes since` instead of the review link; `none, Nick override` or `none, approver override` stands alone on a line. To hold a PR, make it a draft or label it `do not merge`: body prose holds nothing.
79
91
  3. **Check.** `pnpm exec se-agent-guard merge-gate <number>` runs the same gate the Claude hook and the post-merge audit use. Run it before merging; fix what it names.
80
92
  4. **Merge.** `gh pr merge <number> --merge --match-head-commit <approved head sha>`. Merge commits only: never `--squash` or `--rebase`. To undo a merge, `git revert -m 1 <merge commit>`. A merge that skipped the gate is labelled `pushed-through`. That label is the guardrail. It does not start a post-merge AI review.
81
93
  5. **Clean up** (see "Parallel features").
@@ -108,4 +120,4 @@ When **marketing** work is ready, agents **stop** and hand off. Merge `develop`
108
120
 
109
121
  When the promote depends on new/changed Contentful content, complete **release verification** (`release-verification.md` in `@se-studio/skills`): publish state (CDA vs CPA), content smoke (not HTTP-only), preview compare (≥3 pages on published-only build), and no unresolved failed production build. Nick override never skips publish-state or content smoke.
110
122
 
111
- <!-- END:se-core-agents-block v2 -->
123
+ <!-- END:se-core-agents-block v4 -->
@@ -0,0 +1,374 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Fleet consistency audit. Read-only. Reads every registry project from `origin/<integration branch>`
4
+ * (never the local checkout, which is often stale or dirty), plus recent merged PRs via `gh`.
5
+ *
6
+ * node packages/skills/references/agent-session/fleet-audit.mjs [--out report.md] [--prs 20] [--no-prs] [--only om1,hsd]
7
+ *
8
+ * Any agent or human can run it. Output is markdown on stdout (and to --out). It changes nothing.
9
+ * The checks are pure functions (`auditFiles`) so they can be tested without git.
10
+ */
11
+ import { execFileSync } from 'node:child_process';
12
+ import { readFileSync, writeFileSync } from 'node:fs';
13
+ import { homedir } from 'node:os';
14
+ import { dirname, join } from 'node:path';
15
+ import { fileURLToPath } from 'node:url';
16
+
17
+ const here = dirname(fileURLToPath(import.meta.url));
18
+ const repoRoot = join(here, '..', '..', '..', '..');
19
+
20
+ /** First `@se-studio/skills` release that understands the promote line `CI covers the changes since`. */
21
+ export const SKILLS_PROMOTE_LINE_MIN = '1.10.7';
22
+
23
+ /** Compare `1.2.3` style versions; anything unparsable sorts as 0.0.0. */
24
+ export function compareVersions(a, b) {
25
+ const parse = (v) => (String(v).match(/\d+/g) ?? []).slice(0, 3).map(Number);
26
+ const [x, y] = [parse(a), parse(b)];
27
+ for (let i = 0; i < 3; i++) {
28
+ const d = (x[i] ?? 0) - (y[i] ?? 0);
29
+ if (d !== 0) return d < 0 ? -1 : 1;
30
+ }
31
+ return 0;
32
+ }
33
+
34
+ const isExact = (spec) => /^\d+\.\d+\.\d+(?:[-+].*)?$/.test(spec);
35
+ const numeric = (spec) => String(spec).replace(/^[^\d]*/, '');
36
+
37
+ /**
38
+ * @param {{ files: Record<string, string>, coreBlockVersion: number,
39
+ * coreVersions: Record<string, string> }} input
40
+ * files: path -> contents for AGENTS.md, .cursor/rules/*.mdc, docs/*.md and every package.json.
41
+ * @returns {{ findings: {id: string, owner: 'core'|'customer', text: string}[],
42
+ * pins: Record<string, {spec: string, where: string}[]> }}
43
+ */
44
+ export function auditFiles({ files, coreBlockVersion, coreVersions }) {
45
+ const findings = [];
46
+ const add = (id, owner, text) => findings.push({ id, owner, text });
47
+ /** @type {Record<string, {spec: string, where: string}[]>} */
48
+ const pins = {};
49
+
50
+ for (const [path, body] of Object.entries(files)) {
51
+ if (!path.endsWith('package.json')) continue;
52
+ let pkg;
53
+ try {
54
+ pkg = JSON.parse(body);
55
+ } catch {
56
+ continue;
57
+ }
58
+ for (const group of ['dependencies', 'devDependencies', 'peerDependencies']) {
59
+ for (const [name, spec] of Object.entries(pkg[group] ?? {})) {
60
+ if (!name.startsWith('@se-studio/') || String(spec).startsWith('workspace:')) continue;
61
+ pins[name] = [...(pins[name] ?? []), { spec: String(spec), where: path }];
62
+ }
63
+ }
64
+ for (const [script, cmd] of Object.entries(pkg.scripts ?? {})) {
65
+ if (/skills@latest|skills\s+update/.test(cmd) || script === 'skills:update') {
66
+ add(
67
+ 'skills-update-script',
68
+ 'customer',
69
+ `${path}: script \`${script}\` updates skills outside the lockfile pin`,
70
+ );
71
+ }
72
+ if (script === 'cms-edit:deploy' || /vercel\s+deploy/.test(cmd)) {
73
+ add(
74
+ 'manual-deploy-script',
75
+ 'customer',
76
+ `${path}: script \`${script}\` can deploy production by hand (\`${cmd.slice(0, 60)}\`)`,
77
+ );
78
+ }
79
+ }
80
+ }
81
+
82
+ for (const [name, list] of Object.entries(pins)) {
83
+ const ranges = list.filter((p) => !isExact(p.spec));
84
+ if (ranges.length) {
85
+ add(
86
+ 'pin-not-exact',
87
+ 'customer',
88
+ `${name} is not an exact pin: ${[...new Set(ranges.map((p) => p.spec))].join(', ')} (${ranges[0].where})`,
89
+ );
90
+ }
91
+ }
92
+ for (const p of pins['@se-studio/skills'] ?? []) {
93
+ if (compareVersions(numeric(p.spec), SKILLS_PROMOTE_LINE_MIN) < 0) {
94
+ add(
95
+ 'skills-too-old',
96
+ 'customer',
97
+ `@se-studio/skills ${p.spec} (${p.where}) is older than ${SKILLS_PROMOTE_LINE_MIN}: it rejects a valid production promote that uses \`CI covers the changes since\``,
98
+ );
99
+ }
100
+ }
101
+
102
+ const agents = files['AGENTS.md'];
103
+ if (agents === undefined) {
104
+ add('agents-missing', 'customer', 'AGENTS.md not found');
105
+ } else {
106
+ const v = agents.match(/se-core-agents-block v(\d+)/)?.[1];
107
+ if (!v)
108
+ add(
109
+ 'block-missing',
110
+ 'customer',
111
+ 'AGENTS.md has no `se-core-agents-block` (run "refresh process")',
112
+ );
113
+ else if (Number(v) < coreBlockVersion) {
114
+ add(
115
+ 'block-stale',
116
+ 'customer',
117
+ `AGENTS.md block is v${v}, core is v${coreBlockVersion} (run "refresh process")`,
118
+ );
119
+ }
120
+ }
121
+
122
+ for (const [path, body] of Object.entries(files)) {
123
+ if (
124
+ /^\.cursor\/rules\/.*\.mdc$/.test(path) &&
125
+ /merge approval|CI covers the changes since/i.test(body) &&
126
+ body.split('\n').length > 12
127
+ ) {
128
+ add(
129
+ 'review-rule-restated',
130
+ 'customer',
131
+ `${path} restates the review/merge rules (${body.split('\n').length} lines): replace with a pointer to AGENTS.md`,
132
+ );
133
+ }
134
+ if (/^docs\/(merge-approval|design-review)\.md$/.test(path)) {
135
+ add(
136
+ 'review-doc-copy',
137
+ 'customer',
138
+ `${path} is a second copy of rules that live in AGENTS.md`,
139
+ );
140
+ }
141
+ if (path.endsWith('.md') || path.endsWith('.mdc')) {
142
+ if (/squash or merge/i.test(body))
143
+ add(
144
+ 'squash-wording',
145
+ 'customer',
146
+ `${path} says "squash or merge": core uses merge commits only`,
147
+ );
148
+ if (/Cursor Projects/.test(body) && /design review/i.test(body)) {
149
+ add(
150
+ 'cursor-projects-wording',
151
+ 'customer',
152
+ `${path} limits design review to Cursor Projects: any agent or human can do it`,
153
+ );
154
+ }
155
+ }
156
+ }
157
+
158
+ for (const [name, list] of Object.entries(pins)) {
159
+ const core = coreVersions[name];
160
+ if (!core) continue;
161
+ for (const p of list) {
162
+ if (isExact(numeric(p.spec)) && compareVersions(numeric(p.spec), core) < 0) {
163
+ // Behind is information, not a failure: sites update on their own schedule.
164
+ add('behind-core', 'customer', `${name} ${p.spec} is behind core ${core} (${p.where})`);
165
+ break;
166
+ }
167
+ }
168
+ }
169
+
170
+ return { findings, pins };
171
+ }
172
+
173
+ // ---------- git and gh plumbing (not used by tests) ----------
174
+
175
+ const run = (cmd, args, cwd) =>
176
+ execFileSync(cmd, args, {
177
+ cwd,
178
+ encoding: 'utf8',
179
+ stdio: ['ignore', 'pipe', 'pipe'],
180
+ maxBuffer: 64 * 1024 * 1024,
181
+ }).trim();
182
+ const tryRun = (cmd, args, cwd) => {
183
+ try {
184
+ return run(cmd, args, cwd);
185
+ } catch (error) {
186
+ return { error: (error.stderr?.toString() || error.message).split('\n')[0] };
187
+ }
188
+ };
189
+ const expand = (p) => (p.startsWith('~/') ? join(homedir(), p.slice(2)) : p);
190
+
191
+ function readCore() {
192
+ const block = readFileSync(
193
+ join(repoRoot, 'packages/skills/references/agent-session/customer-agents-block.md'),
194
+ 'utf8',
195
+ );
196
+ const coreBlockVersion = Number(block.match(/se-core-agents-block v(\d+)/)?.[1] ?? 0);
197
+ const coreVersions = {};
198
+ for (const dir of [
199
+ 'ab-testing',
200
+ 'cms-seo',
201
+ 'contentful-cms',
202
+ 'contentful-rest-api',
203
+ 'core-data-types',
204
+ 'core-ui',
205
+ 'hubspot',
206
+ 'markdown-renderer',
207
+ 'media-pipeline',
208
+ 'project-build',
209
+ 'search',
210
+ 'site-check',
211
+ 'site-mcp',
212
+ 'site-workflows',
213
+ 'skills',
214
+ ]) {
215
+ try {
216
+ const pkg = JSON.parse(readFileSync(join(repoRoot, 'packages', dir, 'package.json'), 'utf8'));
217
+ coreVersions[pkg.name] = pkg.version;
218
+ } catch {}
219
+ }
220
+ return { coreBlockVersion, coreVersions };
221
+ }
222
+
223
+ function readFromOrigin(path, branch) {
224
+ const ref = `origin/${branch}`;
225
+ const fetched = tryRun('git', ['fetch', '--quiet', 'origin', branch], path);
226
+ if (fetched?.error) return { error: `fetch failed: ${fetched.error}` };
227
+ const list = tryRun('git', ['ls-tree', '-r', '--name-only', ref], path);
228
+ if (list?.error) return { error: list.error };
229
+ const wanted = list.split('\n').filter((f) => {
230
+ if (f.includes('node_modules/')) return false;
231
+ if (f === 'AGENTS.md' || /^\.cursor\/rules\/[^/]+\.mdc$/.test(f) || /^docs\/[^/]+\.md$/.test(f))
232
+ return true;
233
+ return /(^|\/)package\.json$/.test(f) && f.split('/').length <= 4;
234
+ });
235
+ const files = {};
236
+ for (const f of wanted) {
237
+ const body = tryRun('git', ['show', `${ref}:${f}`], path);
238
+ if (typeof body === 'string') files[f] = body;
239
+ }
240
+ return { files };
241
+ }
242
+
243
+ function slugOf(path) {
244
+ const url = tryRun('git', ['remote', 'get-url', 'origin'], path);
245
+ if (typeof url !== 'string') return null;
246
+ return url.replace(/^.*github\.com[:/]/, '').replace(/\.git$/, '');
247
+ }
248
+
249
+ function pushedThrough(slug, count) {
250
+ const out = tryRun(
251
+ 'gh',
252
+ [
253
+ 'pr',
254
+ 'list',
255
+ '-R',
256
+ slug,
257
+ '--state',
258
+ 'merged',
259
+ '--limit',
260
+ String(count),
261
+ '--json',
262
+ 'number,labels,title',
263
+ ],
264
+ undefined,
265
+ );
266
+ if (typeof out !== 'string') return { error: out.error };
267
+ const prs = JSON.parse(out);
268
+ return {
269
+ checked: prs.length,
270
+ breaches: prs
271
+ .filter((p) => p.labels.some((l) => l.name === 'pushed-through'))
272
+ .map((p) => `#${p.number}`),
273
+ };
274
+ }
275
+
276
+ function main() {
277
+ const args = process.argv.slice(2);
278
+ const opt = (name) => {
279
+ const i = args.indexOf(name);
280
+ return i >= 0 ? args[i + 1] : undefined;
281
+ };
282
+ const only = opt('--only')?.split(',');
283
+ const prCount = Number(opt('--prs') ?? 20);
284
+ const registry = JSON.parse(readFileSync(join(here, 'projects.registry.json'), 'utf8'));
285
+ const core = readCore();
286
+ const date = new Date().toISOString().slice(0, 10);
287
+ const out = [
288
+ `# Fleet review ${date}`,
289
+ '',
290
+ `Read from \`origin/<integration branch>\` of each registry project. Core block v${core.coreBlockVersion}. Read-only.`,
291
+ '',
292
+ ];
293
+
294
+ for (const project of registry.projects) {
295
+ if (only && !only.includes(project.key)) continue;
296
+ const path = expand(project.path);
297
+ out.push(`## ${project.key}`);
298
+ const read = readFromOrigin(path, project.branch);
299
+ if (read.error) {
300
+ out.push(
301
+ `- ACCESS NEEDED: could not read \`origin/${project.branch}\` (${read.error}). Not audited.`,
302
+ '',
303
+ );
304
+ continue;
305
+ }
306
+ // Core is the source of the rules, so the customer-copy checks do not apply to it.
307
+ const { findings } =
308
+ project.type === 'core' ? { findings: [] } : auditFiles({ files: read.files, ...core });
309
+ const behind = findings.filter((f) => f.id === 'behind-core');
310
+ const issues = findings.filter((f) => f.id !== 'behind-core');
311
+ if (issues.length === 0)
312
+ out.push(
313
+ project.type === 'core'
314
+ ? '- Source of the rules: customer-copy checks skipped.'
315
+ : '- No policy findings.',
316
+ );
317
+ for (const f of issues) out.push(`- **${f.id}**: ${f.text}`);
318
+ if (behind.length)
319
+ out.push(
320
+ `- _info_ ${behind.length} @se-studio package(s) behind core, e.g. ${behind[0].text}`,
321
+ );
322
+ if (!args.includes('--no-prs')) {
323
+ const slug = slugOf(path);
324
+ const merged = slug ? pushedThrough(slug, prCount) : { error: 'no origin remote' };
325
+ if (merged.error) out.push(`- PRs: could not read (${merged.error})`);
326
+ else if (merged.breaches.length)
327
+ out.push(
328
+ `- **pushed-through**: ${merged.breaches.join(', ')} of the last ${merged.checked} merged PRs skipped the merge gate (history, not necessarily recent)`,
329
+ );
330
+ else
331
+ out.push(
332
+ `- PRs: none of the last ${merged.checked} merged PRs are labelled pushed-through`,
333
+ );
334
+ }
335
+ out.push('');
336
+ }
337
+ const open = tryRun(
338
+ 'gh',
339
+ [
340
+ 'issue',
341
+ 'list',
342
+ '-R',
343
+ 'Something-Else-Studio/se-core-product',
344
+ '--label',
345
+ 'from-customer',
346
+ '--state',
347
+ 'open',
348
+ '--limit',
349
+ '100',
350
+ '--json',
351
+ 'number,title',
352
+ ],
353
+ undefined,
354
+ );
355
+ out.push('## Open Core requests (from-customer)', '');
356
+ if (typeof open !== 'string') out.push(`- could not read (${open.error})`);
357
+ else {
358
+ const issues = JSON.parse(open);
359
+ if (issues.length === 0) out.push('- none open');
360
+ for (const i of issues) out.push(`- #${i.number} ${i.title}`);
361
+ }
362
+ out.push('');
363
+ out.push(
364
+ '## Next',
365
+ '',
366
+ 'Findings with a fix in the customer repo go in a customer PR. Anything that points at core text, the gate or a package belongs in a Core request: `pnpm exec se-agent-guard core-request --from <key> --feature <slug> --why "..."` (see `cross-project-handoff.md`).',
367
+ );
368
+ const text = `${out.join('\n')}\n`;
369
+ const file = opt('--out');
370
+ if (file) writeFileSync(file, text);
371
+ process.stdout.write(text);
372
+ }
373
+
374
+ if (process.argv[1] && join(process.argv[1]) === fileURLToPath(import.meta.url)) main();
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: architecture-review
3
- description: "Review a PR against docs/PHILOSOPHY.md and post a ## Design review with PASS or BLOCKERS. Use only when the diff changes schema, forms, analytics, caching, or security. One review, at the final head SHA. Any agent or human can run it; the author cannot review their own design."
3
+ description: "Review a PR against docs/PHILOSOPHY.md and post a ## Design review with PASS or BLOCKERS. Use only when the diff changes schema, forms, analytics, caching, or security. One review, at the final head SHA. Any agent or human can run it, including the author."
4
4
  ---
5
5
 
6
6
  # Architecture review
@@ -13,7 +13,7 @@ This skill reviews a **PR** at a head SHA. For a proposal that has no PR yet (th
13
13
 
14
14
  ## Who
15
15
 
16
- Any agent or human who did **not** write the change. Check the PR author, the commits' `Co-Authored-By` trailers and the branch history. A fresh session cannot tell whether an earlier session of the same agent wrote it, so if you are unsure, ask.
16
+ Any agent or human, including the one who wrote the change.
17
17
 
18
18
  ## 1. Decide if it applies
19
19