@su-sws/synthetic-web-team 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +2 -2
- package/packages/cli/bin/sws.mjs +28 -10
- package/packages/cli/src/github.mjs +61 -10
- package/skills/role-devops/SKILL.md +2 -1
package/README.md
CHANGED
|
@@ -249,7 +249,7 @@ package directory.
|
|
|
249
249
|
|
|
250
250
|
**Advisory, not blocking.** Findings are reports, PR comments, and a visible score that trends. Exactly one thing fails a build: committed credentials, because that harm is irreversible. A tool that fails your build over a contrast ratio gets uninstalled by Friday, and then nothing is compliant.
|
|
251
251
|
|
|
252
|
-
The report is designed to **find the reader** rather than expecting the reader to find CI. A
|
|
252
|
+
The report is designed to **find the reader** rather than expecting the reader to find CI. A run on the default branch rewrites one long-lived "Site health" issue in place — findable by someone who has never opened the Actions tab, and it notifies watchers. A pull request gets one comment, also updated in place, because a new comment per push is noise people mute. A push to any other branch reports in its job summary only, so a release branch never overwrites the default branch's report or its trend. The score trend lives in that issue's body as an HTML comment, which is why it needs no database, no artifact that expires, and no commit churn.
|
|
253
253
|
|
|
254
254
|
**Push to `main` deploys.** Pull requests are first-class but never required, and nothing in the setup makes one mandatory. Many campus editors work through the GitHub web UI and will not open a pull request to fix a typo. With a CMS, git disappears entirely.
|
|
255
255
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-sws/synthetic-web-team",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Stanford Web Services standards and agent team: policy, patterns, recipes, fragments, prior art, 31 skills, the two-part install wizard, and the advisory compliance CLI.",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"sync-skills": "node scripts/sync-skills.mjs",
|
|
12
|
-
"validate": "node scripts/validate-skills.mjs && node scripts/validate-emit.mjs && node scripts/validate-install.mjs && node scripts/validate-criteria.mjs && node scripts/validate-state-classifier.mjs && node scripts/validate-hooks.mjs && node scripts/validate-acknowledged.mjs && node scripts/validate-layouts.mjs && node scripts/validate-divergences.mjs && node scripts/validate-frameworks.mjs && node scripts/validate-contained.mjs",
|
|
12
|
+
"validate": "node scripts/validate-skills.mjs && node scripts/validate-emit.mjs && node scripts/validate-install.mjs && node scripts/validate-criteria.mjs && node scripts/validate-state-classifier.mjs && node scripts/validate-hooks.mjs && node scripts/validate-acknowledged.mjs && node scripts/validate-layouts.mjs && node scripts/validate-divergences.mjs && node scripts/validate-frameworks.mjs && node scripts/validate-contained.mjs && node scripts/validate-publish.mjs && node scripts/validate-packed.mjs",
|
|
13
13
|
"check": "npm run validate && npm run sync-skills -- --check",
|
|
14
14
|
"pack:all": "mkdir -p .pack && npm pack --pack-destination ./.pack && npm pack -w @su-sws/synthetic-web-team-mcp --pack-destination ./.pack"
|
|
15
15
|
},
|
package/packages/cli/bin/sws.mjs
CHANGED
|
@@ -34,6 +34,15 @@ import { readInstalled } from '../../wizard/src/emit.mjs';
|
|
|
34
34
|
|
|
35
35
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
36
36
|
|
|
37
|
+
// The version of the published package, @su-sws/synthetic-web-team, from its
|
|
38
|
+
// root package.json, which ships. packages/cli/package.json is a workspace
|
|
39
|
+
// manifest the package does not include, so reading it crashed `sws version`
|
|
40
|
+
// in every install while passing in this repository.
|
|
41
|
+
const OWN_VERSION = (() => {
|
|
42
|
+
try { return JSON.parse(readFileSync(resolve(HERE, '..', '..', '..', 'package.json'), 'utf8')).version; }
|
|
43
|
+
catch { return null; }
|
|
44
|
+
})();
|
|
45
|
+
|
|
37
46
|
// `standards/` ships in the same package as this file (@su-sws/synthetic-web-team), so the
|
|
38
47
|
// relative walk below finds it in both the published layout and this
|
|
39
48
|
// repository. There used to be an `import('@su-sws/standards')` fallback here;
|
|
@@ -106,8 +115,10 @@ const USAGE = `
|
|
|
106
115
|
--badge <file> Write a shields.io endpoint JSON for a README badge.
|
|
107
116
|
|
|
108
117
|
In CI, check upserts ONE PR comment on a pull request, or ONE persistent
|
|
109
|
-
"Site health" issue on a
|
|
110
|
-
place, never duplicated. Needs issues:write and pull-requests:write.
|
|
118
|
+
"Site health" issue on a run on the default branch. Both are updated in
|
|
119
|
+
place, never duplicated. Needs issues:write and pull-requests:write. A run
|
|
120
|
+
on any other branch, or where the event payload does not name the default
|
|
121
|
+
branch, reports in the job summary only.
|
|
111
122
|
Publishing never fails the build: a network or permission error is reported
|
|
112
123
|
and the exit code is unaffected.
|
|
113
124
|
|
|
@@ -387,7 +398,8 @@ async function run() {
|
|
|
387
398
|
// has to compare against the previous run rather than this one.
|
|
388
399
|
let existingIssue = null;
|
|
389
400
|
let sharedHistory = [];
|
|
390
|
-
const
|
|
401
|
+
const dest = gh.destination(ghCtx);
|
|
402
|
+
const wantsPublish = ghCtx && ghCtx.token && !flags['no-publish'] && cmd === 'check' && dest.to;
|
|
391
403
|
if (wantsPublish) {
|
|
392
404
|
const found = await gh.findHealthIssue(ghCtx);
|
|
393
405
|
if (found.error) console.error(` note: could not read the Site health issue (${found.error})`);
|
|
@@ -408,8 +420,7 @@ async function run() {
|
|
|
408
420
|
}
|
|
409
421
|
|
|
410
422
|
if (wantsPublish) {
|
|
411
|
-
|
|
412
|
-
if (isPr) {
|
|
423
|
+
if (wantsPublish === 'pr') {
|
|
413
424
|
const r = await gh.upsertPrComment(ghCtx, renderPrComment(payload, { trend, runUrl: ghCtx.runUrl }));
|
|
414
425
|
if (r.error) console.error(` note: PR comment failed (${r.error})`);
|
|
415
426
|
else if (r.action) note(` PR comment ${r.action}: ${r.url}`);
|
|
@@ -423,6 +434,12 @@ async function run() {
|
|
|
423
434
|
}
|
|
424
435
|
} else if (ghCtx && !ghCtx.token && cmd === 'check' && !flags['no-publish']) {
|
|
425
436
|
console.error(' note: in CI without GITHUB_TOKEN, so no PR comment or issue was written.');
|
|
437
|
+
} else if (ghCtx && cmd === 'check' && !flags['no-publish'] && !dest.to) {
|
|
438
|
+
// Said in the job summary too, because that is now the only report this
|
|
439
|
+
// run has, and a reader looking for the issue should learn why it is quiet.
|
|
440
|
+
const why = `No PR comment or Site health issue was written: ${dest.reason}.`;
|
|
441
|
+
note(` note: ${why}`);
|
|
442
|
+
if (wantsSummary) writeFileSync(process.env.GITHUB_STEP_SUMMARY, `\n_${why}_\n`, { flag: 'a' });
|
|
426
443
|
}
|
|
427
444
|
|
|
428
445
|
// --- is this project on stale standards? ---------------------------------
|
|
@@ -437,10 +454,7 @@ async function run() {
|
|
|
437
454
|
// it carries. No network call, no registry lookup.
|
|
438
455
|
if (cmd === 'doctor') {
|
|
439
456
|
const installed = readInstalled(root);
|
|
440
|
-
const mine =
|
|
441
|
-
try { return JSON.parse(readFileSync(resolve(HERE, '..', '..', '..', 'package.json'), 'utf8')).version; }
|
|
442
|
-
catch { return null; }
|
|
443
|
-
})();
|
|
457
|
+
const mine = OWN_VERSION;
|
|
444
458
|
if (installed?.version && mine && installed.version !== mine) {
|
|
445
459
|
note(` Standards in this project are v${installed.version}; this tool carries v${mine}.`);
|
|
446
460
|
note(` To update: npx @su-sws/synthetic-web-team add .`);
|
|
@@ -762,7 +776,11 @@ switch (cmd) {
|
|
|
762
776
|
process.exit(0);
|
|
763
777
|
break;
|
|
764
778
|
case 'version':
|
|
765
|
-
|
|
779
|
+
if (!OWN_VERSION) {
|
|
780
|
+
console.error('sws: could not read the version of @su-sws/synthetic-web-team');
|
|
781
|
+
process.exit(1);
|
|
782
|
+
}
|
|
783
|
+
console.log(OWN_VERSION);
|
|
766
784
|
process.exit(0);
|
|
767
785
|
break;
|
|
768
786
|
default:
|
|
@@ -3,8 +3,15 @@
|
|
|
3
3
|
// Two destinations, chosen by how the change arrived, because pull requests are
|
|
4
4
|
// first-class here but never required:
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
// pull request
|
|
6
|
+
// default branch one long-lived "Site health" issue, UPDATED IN PLACE
|
|
7
|
+
// pull request one collapsible comment, UPDATED IN PLACE
|
|
8
|
+
// anything else nothing: the job summary is the only report
|
|
9
|
+
//
|
|
10
|
+
// The issue is the default branch's report, and its body carries the shared
|
|
11
|
+
// score trend. A push to a release or integration branch that updated it would
|
|
12
|
+
// overwrite that report with another branch's, and splice the other branch's
|
|
13
|
+
// score into the trend. So the issue is written only when the run is on the
|
|
14
|
+
// default branch, and only when that can be told for certain.
|
|
8
15
|
//
|
|
9
16
|
// "In place" is the whole design. A new comment per push turns a PR into a wall
|
|
10
17
|
// of bot noise that people mute, and a new issue per push is worse. Both are
|
|
@@ -33,20 +40,26 @@ export function context(env = process.env) {
|
|
|
33
40
|
const [owner, repo] = env.GITHUB_REPOSITORY.split('/');
|
|
34
41
|
const token = env.GITHUB_TOKEN || env.GH_TOKEN || env.INPUT_GITHUB_TOKEN || null;
|
|
35
42
|
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
} catch { /* fall through: no PR number, so no comment */ }
|
|
43
|
+
// The PR number and the default branch are only reliably available from the
|
|
44
|
+
// event payload. An unreadable payload leaves both null: no PR comment, and
|
|
45
|
+
// no Site health issue.
|
|
46
|
+
let ev = null;
|
|
47
|
+
if (env.GITHUB_EVENT_PATH) {
|
|
48
|
+
try { ev = JSON.parse(readFileSync(env.GITHUB_EVENT_PATH, 'utf8')); } catch { /* ev stays null */ }
|
|
43
49
|
}
|
|
50
|
+
const pr = env.GITHUB_EVENT_NAME?.startsWith('pull_request')
|
|
51
|
+
? (ev?.pull_request?.number ?? ev?.number ?? null)
|
|
52
|
+
: null;
|
|
53
|
+
const defaultBranch = typeof ev?.repository?.default_branch === 'string'
|
|
54
|
+
? ev.repository.default_branch
|
|
55
|
+
: null;
|
|
44
56
|
|
|
45
57
|
return {
|
|
46
|
-
owner, repo, token, pr,
|
|
58
|
+
owner, repo, token, pr, defaultBranch,
|
|
47
59
|
event: env.GITHUB_EVENT_NAME ?? null,
|
|
48
60
|
sha: env.GITHUB_SHA ?? null,
|
|
49
61
|
ref: env.GITHUB_REF_NAME ?? env.GITHUB_REF ?? null,
|
|
62
|
+
branch: branchOf(env),
|
|
50
63
|
runId: env.GITHUB_RUN_ID ?? null,
|
|
51
64
|
serverUrl: env.GITHUB_SERVER_URL || 'https://github.com',
|
|
52
65
|
get runUrl() {
|
|
@@ -55,6 +68,44 @@ export function context(env = process.env) {
|
|
|
55
68
|
};
|
|
56
69
|
}
|
|
57
70
|
|
|
71
|
+
/**
|
|
72
|
+
* The branch this run is on, or null for a tag or an unknown ref. GITHUB_REF
|
|
73
|
+
* is the full ref and says whether it is a branch; GITHUB_REF_NAME is the short
|
|
74
|
+
* name, trusted only when GITHUB_REF_TYPE says it is a branch.
|
|
75
|
+
*/
|
|
76
|
+
function branchOf(env) {
|
|
77
|
+
if (env.GITHUB_REF) {
|
|
78
|
+
return env.GITHUB_REF.startsWith('refs/heads/') ? env.GITHUB_REF.slice('refs/heads/'.length) : null;
|
|
79
|
+
}
|
|
80
|
+
return env.GITHUB_REF_TYPE === 'branch' && env.GITHUB_REF_NAME ? env.GITHUB_REF_NAME : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Where this run's report goes: `{ to: 'pr' }`, `{ to: 'issue' }`, or
|
|
85
|
+
* `{ to: null, reason }` when it goes only to the job summary. A pull request
|
|
86
|
+
* gets its comment. Anything else writes the Site health issue only on the
|
|
87
|
+
* default branch, and when the default branch or the run's branch cannot be
|
|
88
|
+
* read, it does not write it, because a wrong guess overwrites the default
|
|
89
|
+
* branch's report.
|
|
90
|
+
*/
|
|
91
|
+
export function destination(ctx) {
|
|
92
|
+
if (!ctx) return { to: null, reason: 'not in GitHub Actions' };
|
|
93
|
+
if (ctx.pr) return { to: 'pr' };
|
|
94
|
+
if (ctx.event?.startsWith('pull_request')) {
|
|
95
|
+
return { to: null, reason: 'the pull request number is not in the event payload' };
|
|
96
|
+
}
|
|
97
|
+
if (!ctx.defaultBranch) {
|
|
98
|
+
return { to: null, reason: 'the default branch is not in the event payload, so the Site health issue was left alone' };
|
|
99
|
+
}
|
|
100
|
+
if (!ctx.branch) {
|
|
101
|
+
return { to: null, reason: `this run is not on a branch, and the Site health issue is for ${ctx.defaultBranch}` };
|
|
102
|
+
}
|
|
103
|
+
if (ctx.branch !== ctx.defaultBranch) {
|
|
104
|
+
return { to: null, reason: `${ctx.branch} is not the default branch (${ctx.defaultBranch}), and the Site health issue is for ${ctx.defaultBranch}` };
|
|
105
|
+
}
|
|
106
|
+
return { to: 'issue' };
|
|
107
|
+
}
|
|
108
|
+
|
|
58
109
|
async function api(ctx, path, { method = 'GET', body } = {}) {
|
|
59
110
|
const res = await fetch(`${apiBase()}${path}`, {
|
|
60
111
|
method,
|
|
@@ -74,7 +74,8 @@ report, because it implies oversight that is not happening.
|
|
|
74
74
|
|
|
75
75
|
| Trigger | Destination |
|
|
76
76
|
|---|---|
|
|
77
|
-
| Push to
|
|
77
|
+
| Push to the default branch | Job summary via `$GITHUB_STEP_SUMMARY`, plus one long-lived **"Site health" issue updated in place**, plus the HTML report as an artifact |
|
|
78
|
+
| Push to any other branch | Job summary only, with a line saying why the issue was left alone, plus the artifact |
|
|
78
79
|
| Pull request | Annotations on changed lines, one collapsible comment with score and trend, plus the artifact |
|
|
79
80
|
|
|
80
81
|
The job summary needs no permissions and renders formatted markdown on the run
|