yadflow 4.10.0 → 4.11.0
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 +97 -0
- package/README.md +12 -3
- package/bin/commands.mjs +5 -1
- package/bin/yad.mjs +109 -15
- package/cli/agent-guard-worker.mjs +13 -0
- package/cli/agent-guard.mjs +1053 -57
- package/cli/agent-rules.mjs +34 -3
- package/cli/argv-flags.mjs +2 -2
- package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
- package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
- package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
- package/cli/brain/vendor/graphology-library.min.js +2 -0
- package/cli/brain/vendor/graphology.umd.min.js +2 -0
- package/cli/brain/vendor/sigma.min.js +1369 -0
- package/cli/brain/view/app.js +382 -0
- package/cli/brain/view/index.html +63 -0
- package/cli/brain/view/live.css +228 -0
- package/cli/brain/view/live.html +110 -0
- package/cli/brain/view/live.js +884 -0
- package/cli/brain/view/style.css +141 -0
- package/cli/brain-about.mjs +206 -0
- package/cli/brain-activity.mjs +285 -0
- package/cli/brain-skills.mjs +118 -0
- package/cli/brain-vendor.mjs +71 -0
- package/cli/brain-view.mjs +344 -0
- package/cli/brain.mjs +810 -0
- package/cli/ci-check.mjs +3 -3
- package/cli/doctor.mjs +80 -13
- package/cli/epic-state.mjs +93 -1
- package/cli/epic.mjs +15 -3
- package/cli/errors.mjs +2 -1
- package/cli/find-product.mjs +69 -15
- package/cli/foundation-publish.mjs +256 -0
- package/cli/gate.mjs +29 -3
- package/cli/git-read.mjs +38 -0
- package/cli/guard-stream.mjs +409 -0
- package/cli/hook.mjs +59 -9
- package/cli/issues-act.mjs +57 -13
- package/cli/issues-write.mjs +19 -6
- package/cli/issues.mjs +62 -23
- package/cli/lib.mjs +37 -2
- package/cli/local-page.mjs +138 -0
- package/cli/machine.mjs +1 -1
- package/cli/manifest.mjs +50 -0
- package/cli/map/view/app.js +712 -0
- package/cli/map/view/index.html +50 -0
- package/cli/map/view/style.css +142 -0
- package/cli/map-view.mjs +186 -0
- package/cli/map.mjs +637 -0
- package/cli/members.mjs +9 -15
- package/cli/next.mjs +1 -1
- package/cli/openpr.mjs +2 -2
- package/cli/plan.mjs +125 -0
- package/cli/platform.mjs +5 -5
- package/cli/product-index.mjs +1 -1
- package/cli/protection.mjs +32 -0
- package/cli/reconcile.mjs +8 -2
- package/cli/report.mjs +9 -3
- package/cli/reports-dir.mjs +391 -0
- package/cli/reports.mjs +65 -0
- package/cli/run-checks.mjs +5 -2
- package/cli/scan.mjs +1 -1
- package/cli/setup.mjs +30 -5
- package/cli/standup.mjs +87 -71
- package/cli/status.mjs +6 -5
- package/cli/test-agents-file.mjs +614 -8
- package/cli/test-brain-activity.mjs +753 -0
- package/cli/test-brain-view.mjs +381 -0
- package/cli/test-brain.mjs +795 -0
- package/cli/test-guide.mjs +211 -0
- package/cli/test-machine.mjs +59 -0
- package/cli/test-map.mjs +615 -0
- package/cli/test-reports.mjs +382 -0
- package/cli/test-run-checks.mjs +4 -0
- package/cli/test-worktree.mjs +24 -3
- package/cli/toolbox-connect.mjs +21 -6
- package/cli/toolbox.mjs +59 -4
- package/cli/update-commit.mjs +101 -9
- package/cli/usage.mjs +8 -4
- package/package.json +8 -4
- package/skills/yad-architecture/SKILL.md +22 -4
- package/skills/yad-change/SKILL.md +3 -1
- package/skills/yad-change/references/triage.md +2 -0
- package/skills/yad-checks/SKILL.md +2 -0
- package/skills/yad-checks/references/check-gates.md +8 -5
- package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
- package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
- package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
- package/skills/yad-checks/templates/github/yad-checks.yml +3 -2
- package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +3 -2
- package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
- package/skills/yad-connect-repos/SKILL.md +14 -0
- package/skills/yad-discovery/SKILL.md +11 -0
- package/skills/yad-discovery/references/foundation-schema.md +11 -0
- package/skills/yad-docs/templates/app/package-lock.json +18 -10
- package/skills/yad-docs/templates/app/package.json +6 -1
- package/skills/yad-epic/SKILL.md +3 -0
- package/skills/yad-epic/references/state-schema.md +35 -1
- package/skills/yad-guide/SKILL.md +4 -4
- package/skills/yad-implement/SKILL.md +76 -15
- package/skills/yad-issues/SKILL.md +2 -1
- package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
- package/skills/yad-pr-template/templates/checks/pr-title.sh +8 -4
- package/skills/yad-spec/SKILL.md +19 -0
- package/skills/yad-stories/SKILL.md +22 -4
- package/skills/yad-stories/references/story-schema.md +1 -1
package/cli/test-guide.mjs
CHANGED
|
@@ -737,6 +737,21 @@ test('a repo newer than the yadflow running is refused, never rolled back; a fai
|
|
|
737
737
|
assert.match(ran.commits[0].hint, /index\.lock/);
|
|
738
738
|
assert.notEqual(git(A, ['status', '--porcelain']), '', 'the update is in the working tree');
|
|
739
739
|
assert.equal(git(A, ['rev-parse', '--abbrev-ref', 'HEAD']), 'main');
|
|
740
|
+
// #508: a person's own ignore rule hides `.claude/`, whose files the repo tracks. git add refuses; the hint
|
|
741
|
+
// names the rule and the way out — never a lock that is not there.
|
|
742
|
+
process.exitCode = 0;
|
|
743
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'chore: the install, tracked']); git(A, ['push', '-q']);
|
|
744
|
+
const skillFile = git(A, ['ls-files', '.claude/skills']).split('\n').find((f) => f.endsWith('/SKILL.md'));
|
|
745
|
+
assert.ok(skillFile, 'the install tracks a skill');
|
|
746
|
+
fs.appendFileSync(path.join(A, skillFile), '\nedited by hand\n');
|
|
747
|
+
const excludes = path.join(P, 'gitignore_global');
|
|
748
|
+
fs.writeFileSync(excludes, '# mine\n.claude/\n');
|
|
749
|
+
git(A, ['config', 'core.excludesFile', excludes]);
|
|
750
|
+
const hidden = await reconcile(A, { fix: true, scope: 'changed', openPr: true, creator });
|
|
751
|
+
assert.deepEqual(hidden.commits.map((c) => [c.reason, c.committed]), [['add-failed', false]]);
|
|
752
|
+
assert.match(hidden.commits[0].hint, /^git would not stage the update's files under \.claude in \.: an ignore rule hides that folder — .*gitignore_global:2 \(`\.claude\/`\), a rule outside this repo, which CI and the rest of the team do not have\. Remove or narrow that rule, or add `!\/\.claude\/` to this repo's \.gitignore; then run this again: .* \(git said: .+\)$/);
|
|
753
|
+
assert.doesNotMatch(hidden.commits[0].hint, /index\.lock/);
|
|
754
|
+
assert.equal(git(A, ['diff', '--cached', '--name-only']), '', 'nothing left staged');
|
|
740
755
|
} finally { fs.rmSync(P, { recursive: true, force: true }); process.exitCode = 0; }
|
|
741
756
|
});
|
|
742
757
|
|
|
@@ -1110,6 +1125,118 @@ test('yad update --open-pr: the update on its own branch, pushed, a PR/MR opened
|
|
|
1110
1125
|
} finally { fs.rmSync(T, { recursive: true, force: true }); fs.rmSync(R, { recursive: true, force: true }); }
|
|
1111
1126
|
});
|
|
1112
1127
|
|
|
1128
|
+
test('#509: yad update --open-pr with glab warning about two config files says the real reason the MR did not open', { skip: process.platform === 'win32' }, async () => {
|
|
1129
|
+
const { openUpdatePr } = await import('./update-commit.mjs');
|
|
1130
|
+
const { createPr } = await import('./platform.mjs');
|
|
1131
|
+
const T = tmp();
|
|
1132
|
+
const R = tmp();
|
|
1133
|
+
const bin = tmp();
|
|
1134
|
+
fs.writeFileSync(path.join(bin, 'glab'), [
|
|
1135
|
+
'#!/bin/sh',
|
|
1136
|
+
"echo 'Warning: Multiple config files found. Only the first one will be used.' >&2",
|
|
1137
|
+
"echo ' Using: /home/me/.config/glab-cli/config.yml' >&2",
|
|
1138
|
+
"echo ' Ignoring: /home/me/Library/Application Support/glab-cli/config.yml' >&2",
|
|
1139
|
+
"echo 'Consider consolidating to one location to avoid confusion.' >&2",
|
|
1140
|
+
"echo '401 Unauthorized' >&2",
|
|
1141
|
+
'exit 1',
|
|
1142
|
+
].join('\n') + '\n', { mode: 0o755 });
|
|
1143
|
+
const before = process.env.PATH;
|
|
1144
|
+
try {
|
|
1145
|
+
git(R, ['init', '-q', '--bare', '-b', 'main']);
|
|
1146
|
+
git(T, ['init', '-q', '-b', 'main']);
|
|
1147
|
+
git(T, ['config', 'user.name', 'Alice Smith']);
|
|
1148
|
+
git(T, ['config', 'user.email', 'alice@work.com']);
|
|
1149
|
+
git(T, ['config', 'commit.gpgsign', 'false']); git(T, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1150
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
1151
|
+
git(T, ['add', '.sdlc/cli-version.json']);
|
|
1152
|
+
git(T, ['commit', '-q', '-m', 'chore: start']);
|
|
1153
|
+
git(T, ['remote', 'add', 'origin', R]);
|
|
1154
|
+
git(T, ['push', '-q', '-u', 'origin', 'main']);
|
|
1155
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.7.0' });
|
|
1156
|
+
process.env.PATH = `${bin}${path.delimiter}${before}`;
|
|
1157
|
+
const r = openUpdatePr({ root: T, paths: ['.sdlc/cli-version.json'], items: [] }, { productRoot: T, defaultBranch: 'main', platform: 'gitlab', creator: createPr, version: '4.7.0', checked: true });
|
|
1158
|
+
assert.deepEqual([r.pushed, r.opened, r.reason], [true, false, 'pr-not-opened']);
|
|
1159
|
+
assert.match(r.hint, /did not open \(glab reads only one of its two config files, so a login saved in the other is not used \(see `yad doctor`, glab-config\) — 401 Unauthorized\)/);
|
|
1160
|
+
assert.doesNotMatch(r.hint, /Multiple config files/);
|
|
1161
|
+
} finally {
|
|
1162
|
+
process.env.PATH = before;
|
|
1163
|
+
for (const d of [T, R, bin]) fs.rmSync(d, { recursive: true, force: true });
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
// #526: glab as git's login helper prints its two-config-files warning on every git push, and git passes it
|
|
1168
|
+
// through. A `pre-push` hook's stderr reaches yad the same way, so it stands in for the helper here.
|
|
1169
|
+
// A push runs the helper more than once (`get`, then `store` or `erase`), and glab warns each time: two blocks.
|
|
1170
|
+
const GLAB_BLOCK = [
|
|
1171
|
+
"echo 'Warning: Multiple config files found. Only the first one will be used.' >&2",
|
|
1172
|
+
"echo ' Using: /home/me/.config/glab-cli/config.yml' >&2",
|
|
1173
|
+
"echo ' Ignoring: /home/me/Library/Application Support/glab-cli/config.yml' >&2",
|
|
1174
|
+
"echo 'Consider consolidating to one location to avoid confusion.' >&2",
|
|
1175
|
+
];
|
|
1176
|
+
const GLAB_WARNING_HOOK = (exit) => [
|
|
1177
|
+
'#!/bin/sh',
|
|
1178
|
+
...GLAB_BLOCK,
|
|
1179
|
+
...GLAB_BLOCK,
|
|
1180
|
+
...(exit ? ["echo 'remote: HTTP Basic: Access denied' >&2"] : []),
|
|
1181
|
+
`exit ${exit}`,
|
|
1182
|
+
].join('\n') + '\n';
|
|
1183
|
+
function repoWithPushHook(exit) {
|
|
1184
|
+
const T = tmp();
|
|
1185
|
+
const R = tmp();
|
|
1186
|
+
const hooks = tmp();
|
|
1187
|
+
git(R, ['init', '-q', '--bare', '-b', 'main']);
|
|
1188
|
+
git(T, ['init', '-q', '-b', 'main']);
|
|
1189
|
+
git(T, ['config', 'user.name', 'Alice Smith']);
|
|
1190
|
+
git(T, ['config', 'user.email', 'alice@work.com']);
|
|
1191
|
+
git(T, ['config', 'commit.gpgsign', 'false']); git(T, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1192
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.0.0' });
|
|
1193
|
+
git(T, ['add', '.sdlc/cli-version.json']);
|
|
1194
|
+
git(T, ['commit', '-q', '-m', 'chore: start']);
|
|
1195
|
+
git(T, ['remote', 'add', 'origin', R]);
|
|
1196
|
+
git(T, ['push', '-q', '-u', 'origin', 'main']);
|
|
1197
|
+
fs.writeFileSync(path.join(hooks, 'pre-push'), GLAB_WARNING_HOOK(exit), { mode: 0o755 });
|
|
1198
|
+
git(T, ['config', 'core.hooksPath', hooks]);
|
|
1199
|
+
return { T, dirs: [T, R, hooks] };
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
test('#526: a git push that glab, as git\'s login helper, warns on reads the real error first, and a push that works drops the warning', { skip: process.platform === 'win32' }, async () => {
|
|
1203
|
+
const { run } = await import('./lib.mjs');
|
|
1204
|
+
for (const exit of [1, 0]) {
|
|
1205
|
+
const { T, dirs } = repoWithPushHook(exit);
|
|
1206
|
+
try {
|
|
1207
|
+
git(T, ['commit', '-q', '--allow-empty', '-m', 'chore: more']);
|
|
1208
|
+
const r = run('git', ['push', '-q', 'origin', 'main'], { cwd: T });
|
|
1209
|
+
assert.equal(r.ok, exit === 0);
|
|
1210
|
+
assert.doesNotMatch(r.stderr, /Multiple config files|Consider consolidating|Ignoring:/);
|
|
1211
|
+
if (exit) assert.equal(r.stderr.split('\n')[0], 'glab reads only one of its two config files, so a login saved in the other is not used (see `yad doctor`, glab-config) — remote: HTTP Basic: Access denied');
|
|
1212
|
+
else assert.equal(r.stderr, '');
|
|
1213
|
+
} finally { for (const d of dirs) fs.rmSync(d, { recursive: true, force: true }); }
|
|
1214
|
+
}
|
|
1215
|
+
});
|
|
1216
|
+
|
|
1217
|
+
test('#526: yad update --open-pr says the real reason a push failed, not glab\'s warning', { skip: process.platform === 'win32' }, async () => {
|
|
1218
|
+
const { openUpdatePr } = await import('./update-commit.mjs');
|
|
1219
|
+
const { T, dirs } = repoWithPushHook(1);
|
|
1220
|
+
const said = [];
|
|
1221
|
+
const { log: l, error: e } = console;
|
|
1222
|
+
const code = process.exitCode;
|
|
1223
|
+
try {
|
|
1224
|
+
put(path.join(T, '.sdlc/cli-version.json'), { version: '4.7.0' });
|
|
1225
|
+
console.log = (...a) => said.push(a.join(' '));
|
|
1226
|
+
console.error = (...a) => said.push(a.join(' '));
|
|
1227
|
+
const r = openUpdatePr({ root: T, paths: ['.sdlc/cli-version.json'], items: [] }, { productRoot: T, defaultBranch: 'main', platform: 'gitlab', creator: () => ({ ok: true }), version: '4.7.0', checked: true });
|
|
1228
|
+
console.log = l; console.error = e;
|
|
1229
|
+
assert.equal(r.reason, 'push-failed');
|
|
1230
|
+
const line = said.find((x) => /could not push/.test(x));
|
|
1231
|
+
assert.match(line, /could not push \S+ — glab reads only one of its two config files, .* — remote: HTTP Basic: Access denied/);
|
|
1232
|
+
assert.doesNotMatch(said.join('\n'), /Multiple config files/);
|
|
1233
|
+
} finally {
|
|
1234
|
+
console.log = l; console.error = e;
|
|
1235
|
+
process.exitCode = code;
|
|
1236
|
+
for (const d of dirs) fs.rmSync(d, { recursive: true, force: true });
|
|
1237
|
+
}
|
|
1238
|
+
});
|
|
1239
|
+
|
|
1113
1240
|
test('yad update refuses --push and --open-pr together; --open-pr is the agent\'s without asking', async () => {
|
|
1114
1241
|
assert.equal(classify(['update'], ['open-pr']), 'open-pr');
|
|
1115
1242
|
assert.equal(askFor(classify(['update'], ['open-pr'])), 'never');
|
|
@@ -1272,3 +1399,87 @@ test('E167 (#353): yad guide --json hands agents what the agent guard pre-approv
|
|
|
1272
1399
|
assert.deepEqual(g.preapproved, PREAPPROVED);
|
|
1273
1400
|
assert.match(g.preapproved.never, /secrets, tokens/);
|
|
1274
1401
|
});
|
|
1402
|
+
|
|
1403
|
+
// #508 review 1: git refuses a tracked file only over an ignored FOLDER above it — so only folders are named.
|
|
1404
|
+
// A rule on the file itself, a negation, and a repo rule are told apart; `.git/info/exclude` is this clone's.
|
|
1405
|
+
test('#508: hiddenFolders names the ignored folder above a kept path, never a file rule or a negation', async () => {
|
|
1406
|
+
const { hiddenFolders, hiddenFolderText } = await import('./update-commit.mjs');
|
|
1407
|
+
const P = tmp();
|
|
1408
|
+
try {
|
|
1409
|
+
const A = path.join(P, 'a');
|
|
1410
|
+
fs.mkdirSync(A);
|
|
1411
|
+
git(A, ['init', '-q', '-b', 'main']);
|
|
1412
|
+
const excludes = path.join(P, 'mine');
|
|
1413
|
+
fs.writeFileSync(excludes, 'CLAUDE.md\n.claude/skills/\n');
|
|
1414
|
+
git(A, ['config', 'core.excludesFile', excludes]);
|
|
1415
|
+
put(path.join(A, '.gitignore'), '!.claude/settings.json\n');
|
|
1416
|
+
for (const f of ['CLAUDE.md', '.claude/settings.json', '.claude/skills/x/SKILL.md', 'keep.md']) put(path.join(A, f), 'x\n');
|
|
1417
|
+
const got = hiddenFolders(A, ['CLAUDE.md', '.claude/settings.json', '.claude/skills/x/SKILL.md', 'keep.md']);
|
|
1418
|
+
assert.deepEqual(got.map((x) => [x.folder, x.paths, x.pattern, x.line, x.outside]), [['.claude/skills', ['.claude/skills/x/SKILL.md'], '.claude/skills/', 2, true]],
|
|
1419
|
+
'no CLAUDE.md (a file rule never stops git add), no settings.json (a negation re-includes it)');
|
|
1420
|
+
// A rule in .git/info/exclude is this clone's alone: outside, like a global one.
|
|
1421
|
+
fs.writeFileSync(excludes, '');
|
|
1422
|
+
fs.appendFileSync(path.join(A, '.git/info/exclude'), 'vendor/\n');
|
|
1423
|
+
put(path.join(A, 'vendor/lib/a.js'), 'x\n');
|
|
1424
|
+
const local = hiddenFolders(A, ['vendor/lib/a.js']);
|
|
1425
|
+
assert.deepEqual(local.map((x) => [x.folder, x.source, x.outside]), [['vendor', '.git/info/exclude', true]]);
|
|
1426
|
+
// The repo's own rule is not "outside", and no `!` way out is offered for it.
|
|
1427
|
+
put(path.join(A, '.gitignore'), 'build/\n');
|
|
1428
|
+
put(path.join(A, 'build/out.txt'), 'x\n');
|
|
1429
|
+
const own = hiddenFolders(A, ['build/out.txt']);
|
|
1430
|
+
assert.deepEqual(own.map((x) => [x.folder, x.source, x.outside]), [['build', '.gitignore', false]]);
|
|
1431
|
+
assert.doesNotMatch(hiddenFolderText(own, '.', { staged: false }), /outside this repo|add `!/);
|
|
1432
|
+
// The plain push path: git staged the tracked files; only a new file there is left out.
|
|
1433
|
+
const pushed = hiddenFolderText(local, 'api', { staged: true });
|
|
1434
|
+
assert.match(pushed, /^an ignore rule hides vendor in api — \.git\/info\/exclude:\d+ \(`vendor\/`\), a rule outside this repo, which CI and the rest of the team do not have\. Its tracked files were staged, but a new file there is left out of the update: remove or narrow that rule, or add `!\/vendor\/` to this repo's \.gitignore$/);
|
|
1435
|
+
assert.doesNotMatch(pushed, /would not stage|next run/);
|
|
1436
|
+
// Review 2: a folder on disk is asked by its name — a repo `.claude/*` hides the files in `.claude`, not the
|
|
1437
|
+
// folder, so a kept `.claude/settings.json` names nothing; and a deletion names nothing either.
|
|
1438
|
+
put(path.join(A, '.gitignore'), '.claude/*\n!.claude/settings.json\n');
|
|
1439
|
+
assert.deepEqual(hiddenFolders(A, ['.claude/settings.json']), []);
|
|
1440
|
+
// A deletion in an ignored folder still on disk: git stages it but still exits 1, so the folder is named
|
|
1441
|
+
// (review 3). A folder that is gone is never refused, so it is never named — not `.claude` read as matching
|
|
1442
|
+
// `.claude/*`, not `old` beside a real refusal (review 4).
|
|
1443
|
+
assert.deepEqual(hiddenFolders(A, ['vendor/gone.js']).map((x) => x.folder), ['vendor']);
|
|
1444
|
+
put(path.join(A, '.gitignore'), '.claude/*\nold/\n');
|
|
1445
|
+
fs.rmSync(path.join(A, '.claude'), { recursive: true, force: true });
|
|
1446
|
+
assert.deepEqual(hiddenFolders(A, ['.claude/settings.json', 'old/a.md', 'vendor/lib/a.js']).map((x) => x.folder), ['vendor']);
|
|
1447
|
+
// A folder named with glob characters is suggested escaped, so the pattern matches it alone.
|
|
1448
|
+
assert.match(hiddenFolderText([{ folder: 'we ird[1]*', paths: ['we ird[1]*/a'], source: '~/mine', line: 1, pattern: 'x', outside: true }], '.', { staged: false }), /add `!\/we ird\\\[1\\\]\\\*\/` to this repo/);
|
|
1449
|
+
} finally { fs.rmSync(P, { recursive: true, force: true }); }
|
|
1450
|
+
});
|
|
1451
|
+
|
|
1452
|
+
// #508 review 2: a fatal `git add` (exit 128 — a file git cannot read) is said in git's words, even beside an
|
|
1453
|
+
// ignored folder: then nothing was staged, and the rule is not why. Root reads any file, so it is skipped there.
|
|
1454
|
+
test('#508: a git add that fails fatally beside an ignored folder names no ignore rule', { skip: (process.platform === 'win32' || process.getuid?.() === 0) && 'needs a file the user cannot read' }, async () => {
|
|
1455
|
+
const { stageAllowlist } = await import('./update-commit.mjs');
|
|
1456
|
+
const P = tmp();
|
|
1457
|
+
const A = path.join(P, 'a');
|
|
1458
|
+
try {
|
|
1459
|
+
fs.mkdirSync(A);
|
|
1460
|
+
git(A, ['init', '-q', '-b', 'main']);
|
|
1461
|
+
git(A, ['config', 'user.name', 'Alice Smith']); git(A, ['config', 'user.email', 'alice@work.com']); git(A, ['config', 'commit.gpgsign', 'false']);
|
|
1462
|
+
git(A, ['config', 'core.excludesFile', NO_GLOBAL_IGNORE]);
|
|
1463
|
+
put(path.join(A, '.claude/skills/x/SKILL.md'), 'x\n');
|
|
1464
|
+
put(path.join(A, 'keep.md'), 'k\n');
|
|
1465
|
+
git(A, ['add', '-A']); git(A, ['commit', '-q', '-m', 'start']);
|
|
1466
|
+
const excludes = path.join(P, 'mine');
|
|
1467
|
+
fs.writeFileSync(excludes, '.claude/skills/\n');
|
|
1468
|
+
git(A, ['config', 'core.excludesFile', excludes]);
|
|
1469
|
+
fs.appendFileSync(path.join(A, '.claude/skills/x/SKILL.md'), 'y\n');
|
|
1470
|
+
fs.appendFileSync(path.join(A, 'keep.md'), 'y\n');
|
|
1471
|
+
// An ignored folder alone: exit 1, the folder is named.
|
|
1472
|
+
const refused = stageAllowlist(null, A, ['.claude/skills/x/SKILL.md']);
|
|
1473
|
+
assert.deepEqual(refused.ignoredBy.map((x) => x.folder), ['.claude/skills']);
|
|
1474
|
+
git(A, ['reset', '-q']);
|
|
1475
|
+
// Beside a file git cannot read: exit 128, no rule named, git's words kept.
|
|
1476
|
+
fs.chmodSync(path.join(A, 'keep.md'), 0o000);
|
|
1477
|
+
const fatal = stageAllowlist(null, A, ['.claude/skills/x/SKILL.md', 'keep.md']);
|
|
1478
|
+
assert.match(fatal.addError, /Permission denied|keep\.md/);
|
|
1479
|
+
assert.deepEqual(fatal.ignoredBy, []);
|
|
1480
|
+
} finally {
|
|
1481
|
+
try { fs.chmodSync(path.join(A, 'keep.md'), 0o644); } catch { /* gone */ }
|
|
1482
|
+
fs.rmSync(P, { recursive: true, force: true });
|
|
1483
|
+
}
|
|
1484
|
+
});
|
|
1485
|
+
|
package/cli/test-machine.mjs
CHANGED
|
@@ -138,3 +138,62 @@ test('#352: a repo that names no pin and no Docker adds no rows, and Docker is n
|
|
|
138
138
|
assert.equal(asked, 0, 'docker is not asked about');
|
|
139
139
|
} finally { done(T); }
|
|
140
140
|
});
|
|
141
|
+
|
|
142
|
+
// #509 — glab's own words with two config files, as glab 1.125.0 prints them on stderr.
|
|
143
|
+
const GLAB_WARNING = [
|
|
144
|
+
'Warning: Multiple config files found. Only the first one will be used.',
|
|
145
|
+
' Using: /home/me/.config/glab-cli/config.yml',
|
|
146
|
+
' Ignoring: /home/me/Library/Application Support/glab-cli/config.yml',
|
|
147
|
+
'Consider consolidating to one location to avoid confusion.',
|
|
148
|
+
].join('\n');
|
|
149
|
+
const GLAB_401 = 'ERROR\n 1 error occurred:\n * g/p: GET https://gitlab.example/api/v4/projects/g%2Fp: 401\n {message: 401 Unauthorized}';
|
|
150
|
+
|
|
151
|
+
test('#509: glab\'s two-config warning is dropped from what yad reads; a failed run is led by one line that names it', async () => {
|
|
152
|
+
const { withoutGlabConfigWarning } = await import('./lib.mjs');
|
|
153
|
+
assert.equal(withoutGlabConfigWarning(GLAB_WARNING), '', 'a run that worked: nothing left');
|
|
154
|
+
assert.equal(withoutGlabConfigWarning(`${GLAB_WARNING}\nsome note`), 'some note', 'other stderr is kept');
|
|
155
|
+
assert.equal(withoutGlabConfigWarning(GLAB_401, { ok: false }), GLAB_401, 'no warning: unchanged, no hint');
|
|
156
|
+
assert.equal(withoutGlabConfigWarning('Warning: something else'), 'Warning: something else', 'only that exact block');
|
|
157
|
+
const failed = withoutGlabConfigWarning(`${GLAB_WARNING}\n${GLAB_401}`, { ok: false });
|
|
158
|
+
assert.equal(failed, `glab reads only one of its two config files, so a login saved in the other is not used (see \`yad doctor\`, glab-config) — ${GLAB_401}`,
|
|
159
|
+
'the real error, whole, on the hint\'s own line: a caller that shows only the first line still shows it');
|
|
160
|
+
assert.equal(withoutGlabConfigWarning(GLAB_WARNING, { ok: false }).includes('—'), false, 'nothing else: the hint alone');
|
|
161
|
+
assert.ok(!/Multiple config files|Using:|Ignoring:|Consider consolidating/.test(failed));
|
|
162
|
+
// Windows line ends: the same block is found.
|
|
163
|
+
assert.equal(withoutGlabConfigWarning(`${GLAB_WARNING.replaceAll('\n', '\r\n')}\r\nsome note`), 'some note');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// A fake glab on PATH: the warning on stderr, then `body` (shell). Not on Windows (a shell script).
|
|
167
|
+
const withFakeGlab = async (body, fn) => {
|
|
168
|
+
const T = tmp();
|
|
169
|
+
const bin = path.join(T, 'bin');
|
|
170
|
+
fs.mkdirSync(bin);
|
|
171
|
+
fs.writeFileSync(path.join(bin, 'glab'), `#!/bin/sh\ncat >&2 <<'W'\n${GLAB_WARNING}\nW\n${body}\n`, { mode: 0o755 });
|
|
172
|
+
const before = process.env.PATH;
|
|
173
|
+
process.env.PATH = `${bin}${path.delimiter}${before}`;
|
|
174
|
+
try { return await fn(T); } finally { process.env.PATH = before; done(T); }
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
test('#509: an MR glab opened with the warning on stderr is opened, and its address is read past any trailing notice', { skip: process.platform === 'win32' }, async () => {
|
|
178
|
+
const { run } = await import('./lib.mjs');
|
|
179
|
+
const { createPr } = await import('./platform.mjs');
|
|
180
|
+
await withFakeGlab("echo 'Creating merge request for x into main in g/p'\necho\necho 'https://gitlab.example/g/p/-/merge_requests/7'\necho 'A newer glab is available'\nexit 0", () => {
|
|
181
|
+
const r = run('glab', ['version']);
|
|
182
|
+
assert.equal(r.ok, true);
|
|
183
|
+
assert.equal(r.stderr, '', 'the warning is not read');
|
|
184
|
+
const pr = createPr('gitlab', { title: 't', body: 'b', base: 'main', head: 'x' });
|
|
185
|
+
assert.equal(pr.ok, true);
|
|
186
|
+
assert.equal(pr.url, 'https://gitlab.example/g/p/-/merge_requests/7');
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('#509: an MR glab could not open says glab\'s real error, led by the two-config line', { skip: process.platform === 'win32' }, async () => {
|
|
191
|
+
const { createPr } = await import('./platform.mjs');
|
|
192
|
+
await withFakeGlab(`cat >&2 <<'E'\n${GLAB_401}\nE\nexit 1`, () => {
|
|
193
|
+
const pr = createPr('gitlab', { title: 't', body: 'b', base: 'main', head: 'x' });
|
|
194
|
+
assert.equal(pr.ok, false);
|
|
195
|
+
assert.match(pr.reason, /^glab reads only one of its two config files/);
|
|
196
|
+
assert.match(pr.reason, /401 Unauthorized/);
|
|
197
|
+
assert.doesNotMatch(pr.reason, /Multiple config files/);
|
|
198
|
+
});
|
|
199
|
+
});
|