skillgauntlet 1.3.7 → 1.3.8

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.
Files changed (2) hide show
  1. package/lib/submit.js +24 -4
  2. package/package.json +1 -1
package/lib/submit.js CHANGED
@@ -92,15 +92,36 @@ function prBody(pkg) {
92
92
  ].join('\n');
93
93
  }
94
94
 
95
+ // A fork that was just created is not always cloneable at once; try a few times, a few seconds apart.
96
+ function cloneWithRetry(exec, url, dir, { tries = 5, waitMs = 3000 } = {}) {
97
+ let last;
98
+ for (let i = 0; i < tries; i += 1) {
99
+ try {
100
+ exec('git', ['clone', '--depth', '1', '-c', 'credential.helper=', '-c', 'credential.https://github.com.helper=!gh auth git-credential', url, dir]);
101
+ return;
102
+ } catch (err) {
103
+ last = err;
104
+ fs.rmSync(dir, { recursive: true, force: true });
105
+ if (i < tries - 1) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, waitMs);
106
+ }
107
+ }
108
+ throw last;
109
+ }
110
+
95
111
  // Fork, branch, commit, push, open. Every GitHub call goes through `exec` so tests can fake them.
96
- export function openPullRequest({ pkgDir, pkg, gh, exec = defaultExec, say: out = say }) {
112
+ export function openPullRequest({ pkgDir, pkg, gh, exec = defaultExec, say: out = say, cloneWait = 3000 }) {
97
113
  const work = fs.mkdtempSync(path.join(os.tmpdir(), 'sg-pr-'));
98
114
  try {
99
115
  out(t('submitForking', { upstream: UPSTREAM }));
100
116
  exec('gh', ['repo', 'fork', UPSTREAM, '--clone=false']);
101
117
  out(t('submitPreparing'));
102
118
  const repoDir = path.join(work, 'repo');
103
- exec('git', ['clone', '--depth', '1', `https://github.com/${UPSTREAM}.git`, repoDir]);
119
+ const forkUrl = `https://github.com/${gh.user}/${UPSTREAM.split('/')[1]}.git`;
120
+ // The branch is made from the contributor's own fork, not from upstream's main. A fork made before upstream gained
121
+ // workflow files lacks them, and pushing a branch built on upstream's main would then "create" those workflows in
122
+ // the fork, which GitHub refuses for a token without the `workflow` scope (the default gh sign-in has none). A branch
123
+ // made on the fork adds only the submission, and the pull request's diff against upstream is still just that.
124
+ cloneWithRetry(exec, forkUrl, repoDir, { waitMs: cloneWait });
104
125
  const g = (...a) => exec('git', ['-C', repoDir, ...a]);
105
126
  const branch = `submit/${slug(pkg.files.meta.skill)}-${pkg.files.meta.submission.host.id}-${pkg.path[2].split('-')[0].toLowerCase()}`;
106
127
  g('checkout', '-b', branch);
@@ -115,8 +136,7 @@ export function openPullRequest({ pkgDir, pkg, gh, exec = defaultExec, say: out
115
136
  const ident = ['-c', `user.name=${gh.user}`, '-c', `user.email=${gh.id}+${gh.user}@users.noreply.github.com`];
116
137
  g(...ident, 'commit', '-q', '-F', msg);
117
138
  out(t('submitPushing'));
118
- g('remote', 'add', 'fork', `https://github.com/${gh.user}/${UPSTREAM.split('/')[1]}.git`);
119
- g('-c', 'credential.helper=', '-c', 'credential.https://github.com.helper=!gh auth git-credential', 'push', '-q', 'fork', branch);
139
+ g('-c', 'credential.helper=', '-c', 'credential.https://github.com.helper=!gh auth git-credential', 'push', '-q', 'origin', branch);
120
140
  out(t('submitOpening'));
121
141
  const body = path.join(work, 'body.md');
122
142
  fs.writeFileSync(body, prBody(pkg));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillgauntlet",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "Check an agent skill before you install it: context cost, permission surface, code risk, instruction hijacking, description quality, trigger rate and gain.",
5
5
  "type": "module",
6
6
  "bin": {