yadflow 4.10.0 → 4.12.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 +152 -0
- package/README.md +14 -3
- package/bin/commands.mjs +7 -1
- package/bin/yad.mjs +163 -16
- package/cli/agent-guard-worker.mjs +13 -0
- package/cli/agent-guard.mjs +1053 -57
- package/cli/agent-rules.mjs +59 -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 +345 -0
- package/cli/brain.mjs +810 -0
- package/cli/brand-cmd.mjs +326 -0
- package/cli/brand.mjs +327 -0
- package/cli/ci-check.mjs +3 -3
- package/cli/doctor.mjs +145 -14
- 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/guide.mjs +26 -3
- package/cli/hook.mjs +59 -9
- package/cli/issues-act.mjs +57 -13
- package/cli/issues-write.mjs +19 -6
- package/cli/issues.mjs +69 -24
- package/cli/lib.mjs +37 -2
- package/cli/local-page.mjs +138 -0
- package/cli/local-setup-record.mjs +71 -0
- package/cli/local-setup-steps.mjs +186 -0
- package/cli/local-setup.mjs +611 -0
- package/cli/machine.mjs +1 -1
- package/cli/manifest.mjs +55 -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 +190 -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/plain-text.mjs +22 -0
- package/cli/plan.mjs +310 -36
- package/cli/platform.mjs +5 -5
- package/cli/product-index.mjs +1 -1
- package/cli/protection.mjs +32 -0
- package/cli/reconcile.mjs +61 -13
- package/cli/report.mjs +9 -3
- package/cli/reports-dir.mjs +393 -0
- package/cli/reports.mjs +65 -0
- package/cli/run-checks.mjs +5 -2
- package/cli/scan.mjs +4 -6
- package/cli/secret-text.mjs +66 -0
- package/cli/setup.mjs +54 -8
- package/cli/standup.mjs +94 -72
- 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-brand.mjs +558 -0
- package/cli/test-guide.mjs +438 -0
- package/cli/test-local-setup.mjs +1188 -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 +74 -5
- package/cli/update-commit.mjs +118 -9
- package/cli/usage.mjs +17 -7
- package/cli/workspace.mjs +11 -2
- package/package.json +8 -4
- package/skills/sdlc/module-help.csv +1 -0
- package/skills/yad-architecture/SKILL.md +22 -4
- package/skills/yad-brand/SKILL.md +69 -0
- 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/local-setup-notice.mjs +96 -0
- 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 +10 -7
- 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/reports.mjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// `yad reports list | open | prune` (E180) — the saved reports in the local reports folder.
|
|
2
|
+
// See reports-dir.mjs for where the folder is and how a file is named.
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { c, log, ok, info, warn, refuse, emitJSON, forTerminal } from './lib.mjs';
|
|
6
|
+
import { listReports, pruneReports, REPORTS_ENV } from './reports-dir.mjs';
|
|
7
|
+
import { openUrl } from './report.mjs';
|
|
8
|
+
|
|
9
|
+
export const REPORTS_USAGE = 'usage: yad reports [list] [--json] · yad reports open <n|file> · yad reports prune --older-than <days> | --missing [--apply] [--json]';
|
|
10
|
+
|
|
11
|
+
const FRESH = { fresh: 'fresh', stale: 'stale — the Product changed since', unknown: 'unknown' };
|
|
12
|
+
|
|
13
|
+
export async function runReports(root, { action = 'list', args = [], olderThan = null, missing = false, apply = false, json = false, env = process.env, runner = spawnSync, opener = openUrl } = {}) {
|
|
14
|
+
if (action === 'list') {
|
|
15
|
+
if (args.length) return refuse(`yad reports list takes no words (got: ${args.map(forTerminal).join(' ')})`, REPORTS_USAGE, { json });
|
|
16
|
+
const r = listReports(root, { env, runner });
|
|
17
|
+
if (r.problem) return refuse(r.problem, null, { json });
|
|
18
|
+
if (json) return emitJSON({ dir: r.dir, via: r.via, entries: r.entries });
|
|
19
|
+
log(c.bold('\nyad reports'));
|
|
20
|
+
info(`folder: ${forTerminal(r.dir)}${r.via === 'env' ? ` (from ${REPORTS_ENV})` : ''} — on this machine only, never committed`);
|
|
21
|
+
if (!r.entries.length) { info('no reports saved yet'); return r; }
|
|
22
|
+
for (const e of r.entries) {
|
|
23
|
+
const mark = !e.present ? c.red('missing') : e.freshness === 'stale' ? c.yellow(FRESH.stale) : e.freshness === 'fresh' ? c.green(FRESH.fresh) : c.dim(FRESH.unknown);
|
|
24
|
+
log(` ${String(e.n).padStart(3)} ${forTerminal(path.posix.basename(e.file))} ${mark}${e.anonymous ? c.dim(' · anonymous') : ''}`);
|
|
25
|
+
}
|
|
26
|
+
info('open one: yad reports open <n> · the catalog page: index.html in the folder');
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (action === 'open') {
|
|
31
|
+
if (args.length !== 1) return refuse('name one report: its number from `yad reports list`, or its file name', REPORTS_USAGE, { json });
|
|
32
|
+
const r = listReports(root, { env, runner });
|
|
33
|
+
if (r.problem) return refuse(r.problem, null, { json });
|
|
34
|
+
const want = String(args[0]);
|
|
35
|
+
const hit = /^\d+$/.test(want) ? r.entries.find((e) => e.n === Number(want)) : r.entries.find((e) => e.file === want || path.posix.basename(e.file) === want);
|
|
36
|
+
if (!hit) return refuse(`no saved report ${forTerminal(want)}`, 'see them with: yad reports list', { json });
|
|
37
|
+
if (!hit.present) return refuse(`${forTerminal(hit.file)} is in the catalog but its file is gone`, 'drop it from the catalog with: yad reports prune --missing --apply (it deletes no report)', { json });
|
|
38
|
+
const file = path.join(r.dir, hit.file);
|
|
39
|
+
const opened = opener(file);
|
|
40
|
+
if (json) return emitJSON({ file, opened, freshness: hit.freshness });
|
|
41
|
+
if (opened) ok(`opened ${forTerminal(file)}`);
|
|
42
|
+
else info(`no browser opener was found here (open, xdg-open or explorer) — open ${forTerminal(file)} yourself`);
|
|
43
|
+
if (hit.freshness === 'stale') warn('this report is stale: the Product changed since it was made — run the command again for a current one');
|
|
44
|
+
return { file, opened };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (action === 'prune') {
|
|
48
|
+
if (args.length) return refuse(`yad reports prune takes no words (got: ${args.map(forTerminal).join(' ')})`, REPORTS_USAGE, { json });
|
|
49
|
+
if (missing && olderThan !== null) return refuse('pass --older-than <days> or --missing, not both', REPORTS_USAGE, { json });
|
|
50
|
+
const days = missing ? null : Number(olderThan);
|
|
51
|
+
if (!missing && (olderThan === null || olderThan === true || !Number.isInteger(days) || days < 0)) return refuse('say how old: --older-than <days> (a whole number, 0 or more), or --missing to drop only entries whose file is gone', REPORTS_USAGE, { json });
|
|
52
|
+
const r = pruneReports(root, { days, apply, env, runner });
|
|
53
|
+
if (r.problem) return refuse(r.problem, null, { json });
|
|
54
|
+
if (json) return emitJSON({ dir: r.dir, applied: !!apply, removed: r.removed, kept: r.kept });
|
|
55
|
+
log(c.bold(`\nyad reports prune${apply ? '' : ' (dry run)'}`));
|
|
56
|
+
if (!r.removed.length) { info(`${missing ? 'no entry is missing its file' : `nothing older than ${days} day(s)`} — ${r.kept} kept`); return r; }
|
|
57
|
+
for (const e of r.removed) log(` ${apply ? c.red('removed') : 'would remove'} ${forTerminal(e.file)}${e.reason === 'missing' ? c.dim(' (file already gone)') : e.reason === 'outside' ? c.dim(' (not a report path inside the folder — only dropped from the catalog)') : ''}`);
|
|
58
|
+
if (apply) ok(`removed ${r.removed.length}, kept ${r.kept}`);
|
|
59
|
+
else info(`nothing was deleted — add --apply to remove these ${r.removed.length}`);
|
|
60
|
+
return r;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return refuse(`unknown action: yad reports ${forTerminal(action)}`, REPORTS_USAGE, { json });
|
|
64
|
+
}
|
|
65
|
+
|
package/cli/run-checks.mjs
CHANGED
|
@@ -450,8 +450,9 @@ export async function runChecks(dir, opts = {}) {
|
|
|
450
450
|
{ name: 'pr-title', script: 'pr-title.sh', args: ['--profile', profile, title], needs: titleNeeds },
|
|
451
451
|
{ name: 'pr-template', script: 'pr-template.sh', args: ['--profile', profile, bodyFile], needs: bodyNeeds },
|
|
452
452
|
{ name: 'risk-map', script: 'risk-map-check.sh', args: [base] },
|
|
453
|
-
|
|
454
|
-
{ name: '
|
|
453
|
+
// The base, as CI passes it: a Unity project skips both, unless its base has a package.json (#496).
|
|
454
|
+
{ name: 'install-deps', script: 'install-deps.sh', args: [base], build: true },
|
|
455
|
+
{ name: 'build/test/lint', script: 'build-test-lint.sh', args: [base], build: true, after: 'install-deps' },
|
|
455
456
|
{ name: 'contract-check', script: 'contract-check.sh', args: [base] },
|
|
456
457
|
{ name: 'lineage-check', script: 'lineage-check.sh', args: [base] },
|
|
457
458
|
{ name: 'epic-open', script: 'epic-open.sh', args: [base] },
|
|
@@ -539,6 +540,8 @@ export async function runChecks(dir, opts = {}) {
|
|
|
539
540
|
} else {
|
|
540
541
|
r.exit = p.status;
|
|
541
542
|
r.status = p.status === 0 ? 'pass' : 'fail';
|
|
543
|
+
// A gate that passed by skipping says so (#496): a skipped gate is not a pass.
|
|
544
|
+
if (r.status === 'pass' && (g.name === 'install-deps' || g.name === 'build/test/lint') && /^SKIP \[(install-deps|build\/test\/lint)\]: a Unity project/m.test(r.output)) { r.status = 'skip'; r.reason = 'a Unity project: build and test it with Unity\'s own CI'; }
|
|
542
545
|
}
|
|
543
546
|
if (g.name === 'pr-title' && titleNote) info(titleNote);
|
|
544
547
|
if (g.name === 'pr-template' && platform === 'gitlab') {
|
package/cli/scan.mjs
CHANGED
|
@@ -9,6 +9,8 @@ import fs from 'node:fs';
|
|
|
9
9
|
import { createHash } from 'node:crypto';
|
|
10
10
|
import { run, readJSON, forTerminal, c, log, fail, hand, info, warn, emitJSON } from './lib.mjs';
|
|
11
11
|
import { productConfigPath } from './manifest.mjs';
|
|
12
|
+
import { redact, redactTokens } from './secret-text.mjs';
|
|
13
|
+
export { redact, redactTokens };
|
|
12
14
|
import { productIdentity } from './members.mjs';
|
|
13
15
|
import { prTarget } from './pr-list.mjs';
|
|
14
16
|
import { repoSources } from './standup.mjs';
|
|
@@ -68,11 +70,7 @@ export const fingerprint = (f) => createHash('sha256').update(JSON.stringify([f.
|
|
|
68
70
|
|
|
69
71
|
// ---- making text safe to post ------------------------------------------------------------------------
|
|
70
72
|
|
|
71
|
-
|
|
72
|
-
// Text a person wrote keeps its commit hashes and long names: only tokens with a known prefix are redacted.
|
|
73
|
-
const PREFIXED = /(gh[pousr]_[A-Za-z0-9]{10,}|github_pat_[A-Za-z0-9_]{10,}|glpat-[A-Za-z0-9_-]{10,}|AKIA[0-9A-Z]{12,}|xox[abprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9_-]{16,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}(?:\.[A-Za-z0-9_-]+)?|-----BEGIN[^-]*-----)/g;
|
|
74
|
-
export const redactTokens = (s) => String(s ?? '').replace(PREFIXED, '[redacted]');
|
|
75
|
-
export const redact = (s) => String(s ?? '').replace(SECRET, '[redacted]');
|
|
73
|
+
// The patterns live in cli/secret-text.mjs, shared with the local setup script (E185 part 3).
|
|
76
74
|
const plain = (s, max) => { const t = forTerminal(redact(s)).replace(/\s+/g, ' ').trim(); return t.length > max ? `${t.slice(0, max - 1)}…` : t; };
|
|
77
75
|
// An invisible space after each trigger stops a mention or a reference. GitHub reads backslashes and HTML entities as
|
|
78
76
|
// the real character before it looks for one, so neither of those is enough (checked against its renderer).
|
|
@@ -144,7 +142,7 @@ function droppedFrom(stdout, confidential) {
|
|
|
144
142
|
}
|
|
145
143
|
|
|
146
144
|
// Map(title → id), across open and closed. Null if unread. GitHub assigns by number, GitLab by id.
|
|
147
|
-
function readMilestones(t, runner) {
|
|
145
|
+
export function readMilestones(t, runner) {
|
|
148
146
|
const gh = t.platform === 'github';
|
|
149
147
|
const at = gh ? `repos/${t.repo}/milestones?state=all&per_page=${PAGE}` : `projects/${encodeURIComponent(t.repo)}/milestones?per_page=${PAGE}`;
|
|
150
148
|
const map = new Map();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Text that holds a secret (E185 part 3; the patterns are the ones `yad scan` has always used). A module of its
|
|
2
|
+
// own, with no imports, so anything — the local setup script, the scanner — can ask without an import cycle.
|
|
3
|
+
|
|
4
|
+
// Every token yad knows, plus any run of 40 or more key-like characters: for text a machine wrote.
|
|
5
|
+
export const SECRET = /(gh[pousr]_[A-Za-z0-9]{10,}|github_pat_[A-Za-z0-9_]{10,}|glpat-[A-Za-z0-9_-]{10,}|AKIA[0-9A-Z]{12,}|xox[abprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9_-]{16,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}(?:\.[A-Za-z0-9_-]+)?|-----BEGIN[^-]*-----|[A-Za-z0-9+_=-]{40,})/g;
|
|
6
|
+
// Text a person wrote keeps its commit hashes and long names: only tokens with a known prefix count.
|
|
7
|
+
export const PREFIXED = /(gh[pousr]_[A-Za-z0-9]{10,}|github_pat_[A-Za-z0-9_]{10,}|glpat-[A-Za-z0-9_-]{10,}|AKIA[0-9A-Z]{12,}|xox[abprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9_-]{16,}|eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}(?:\.[A-Za-z0-9_-]+)?|-----BEGIN[^-]*-----)/g;
|
|
8
|
+
export const redactTokens = (s) => String(s ?? '').replace(PREFIXED, '[redacted]');
|
|
9
|
+
export const redact = (s) => String(s ?? '').replace(SECRET, '[redacted]');
|
|
10
|
+
|
|
11
|
+
// A secret value written into text (review 1 widened both ways). It counts when:
|
|
12
|
+
// - a known token is there (the list above), or a Stripe key (`sk_live_…`, `rk_test_…`);
|
|
13
|
+
// - a password, secret, token or key NAME is given a literal value (`API_KEY=abcd…`, `password: "…"`) —
|
|
14
|
+
// never when the name is for where or what the value is (`TOKEN_URL`, `PASSWORD_FILE`, `SECRET_NAME`),
|
|
15
|
+
// nor when the value names where it comes from (`$API_KEY`, `${TOKEN}`, `<your key>`, `{{ vault }}`, a path
|
|
16
|
+
// or a URL);
|
|
17
|
+
// - a password sits in a URL (`https://user:pw@host`), or after `--password` / `--token`, after `-p` on a
|
|
18
|
+
// login line (`docker login -p …`, `mysql -p…`), or after `aws configure set` for a secret key.
|
|
19
|
+
const KEYWORD = /password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|private[_-]?key/i;
|
|
20
|
+
const NAME_FOR_WHERE = /[_.-](?:url|uri|file|path|name|header|id|dir|env|endpoint|host|type|length|expiry|ttl|json|yaml|yml)$/i;
|
|
21
|
+
// A name starts where no name character came before — a `-` counts only inside a name, so `--api-key=x` reads
|
|
22
|
+
// `api-key` and `--from-literal=password=x` reads `password` (linear either way; reviews 2, 3). The value is read
|
|
23
|
+
// ahead without being taken, so a name inside a value (`url=https://h/?token=…`) is read on its own too; the value
|
|
24
|
+
// itself keeps `&` and `=`, so a password holding them still counts (a query string may be refused: use $VAR).
|
|
25
|
+
// A quoted value is read to its closing quote, so `TOKEN="abc,defghijk"` counts whole (review 4) — but never one
|
|
26
|
+
// that starts with a space, and one that starts with a shell operator only when it holds no space: in
|
|
27
|
+
// `read -p "Password: " PW` or `echo "Password:";read PW;echo "ok"`, that quote closes the prompt, it opens nothing —
|
|
28
|
+
// while `";x9Kq2mZp7"` is a value (reviews 5–8). A password that starts with ; & or | AND holds a space is missed.
|
|
29
|
+
const NAMED = /(?<![\w.]|[\w.]-)([A-Za-z_][\w.-]*)["']?\s*[=:]\s*(?=("(?:[;&|][^"\s]*|[^"\s;&|][^"\n]*)"|'(?:[;&|][^'\s]*|[^'\s;&|][^'\n]*)'|["']?[^\s"'`,;]+))/g;
|
|
30
|
+
// A value with its quotes taken off. An unquoted one that is `&name=…` is an empty value before the next name in a
|
|
31
|
+
// query (`password=&user=x`); a quoted `&…` is a real value (review 5).
|
|
32
|
+
const literal = (raw) => {
|
|
33
|
+
const quoted = /^["']/.test(raw);
|
|
34
|
+
const v = raw.replace(/^["']|["']$/g, '');
|
|
35
|
+
if (!quoted && /^&[A-Za-z_][\w.-]*(?:[=&]|$)/.test(v)) return false;
|
|
36
|
+
return v.length >= 8 && !/^[$<{%]/.test(v) && !/^(?:\/|\.{1,2}\/|~\/|[a-z][\w+.-]*:\/\/)/i.test(v);
|
|
37
|
+
};
|
|
38
|
+
const OTHER = [
|
|
39
|
+
/\b[sr]k_(?:live|test)_[A-Za-z0-9]{10,}/,
|
|
40
|
+
/(?<![\w+.-])[a-z][\w+.-]*:\/\/[^\s/:@]+:([^\s/@$<{%][^\s/@]*)@/i,
|
|
41
|
+
/(?:^|\s)--(?:password|passwd|token|secret)(?:=|\s+)["']?(?![$<{%])[^\s"'`-][^\s"'`]{5,}/i,
|
|
42
|
+
// `-p` only within the login command itself: never past `&&`, `;` or `|` (`gh auth login && mkdir -p x`).
|
|
43
|
+
/\blogin\b[^\n;&|]*\s-p\s*["']?(?![$<{%])[^\s"'`-][^\s"'`]{5,}/i,
|
|
44
|
+
/\bmysql\b[^\n;&|]*\s-p(?![$<{%\s])[^\s"'`]{6,}/i,
|
|
45
|
+
/\bconfigure\s+set\s+\S*(?:secret|token|key)\S*\s+(?![$<{%])[^\s"'`]{8,}/i,
|
|
46
|
+
];
|
|
47
|
+
// One window of text, at most WINDOW long.
|
|
48
|
+
function windowLooksSecret(s) {
|
|
49
|
+
if (OTHER.some((re) => re.test(s))) return true;
|
|
50
|
+
for (const [, name, value] of s.matchAll(NAMED)) if (KEYWORD.test(name) && !NAME_FOR_WHERE.test(name) && literal(value)) return true;
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
// Long text is read in overlapping windows, so the time grows with its length, never with its square (review 2).
|
|
54
|
+
// A secret sits on one line, and any secret these patterns name is far shorter than the overlap. A step's fields are
|
|
55
|
+
// capped below one window today; the windows keep any later caller (a scanner, say) safe too.
|
|
56
|
+
const WINDOW = 1000;
|
|
57
|
+
const OVERLAP = 200;
|
|
58
|
+
export function looksSecret(s) {
|
|
59
|
+
if (typeof s !== 'string') return false;
|
|
60
|
+
if (redactTokens(s) !== s) return true;
|
|
61
|
+
for (const line of s.split('\n')) {
|
|
62
|
+
if (line.length <= WINDOW) { if (windowLooksSecret(line)) return true; continue; }
|
|
63
|
+
for (let i = 0; i < line.length; i += WINDOW - OVERLAP) if (windowLooksSecret(line.slice(i, i + WINDOW))) return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
package/cli/setup.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { err } from './errors.mjs';
|
|
11
11
|
import { VERSION, IDE_TARGETS, IDE_AGENTS, DEFAULT_IDE_TARGETS, PROJECT_FILES, DESIGN_TOOLS, DESIGN_PRIMARY, TESTING_TOOLS, TESTING_PRIMARY, LEARNING_TOOLS, LEARNING_PRIMARY , productConfigPath } from './manifest.mjs';
|
|
12
12
|
import {
|
|
13
|
-
moduleActions, repoActions, productActions, hookActions, agentFileActions, agentGuardActions, allowListActions, captureHookActions, legacyHookScriptActions, gitHookActions, gitHookState, gitHookAdvice,
|
|
13
|
+
moduleActions, repoActions, productActions, hookActions, agentFileActions, agentGuardActions, allowListActions, captureHookActions, activityHookActions, legacyHookScriptActions, gitHookActions, gitHookState, gitHookAdvice, localSetupNoticeActions, localSetupNoticeAdvice,
|
|
14
14
|
legacyModuleActions, removedModuleActions, legacyRepoActions, legacyProductActions, withoutKeptRenames,
|
|
15
15
|
safeIdeTargetsFor, detectedIdeTargetStateFor, recordManagedWrites, canonicalIdeTargets,
|
|
16
16
|
} from './plan.mjs';
|
|
@@ -18,8 +18,12 @@ import { modeFields, modeOf } from './mode.mjs';
|
|
|
18
18
|
import { recordActor } from './skip.mjs';
|
|
19
19
|
import { loadSkillBindings, stepSkills } from './epic-state.mjs';
|
|
20
20
|
import { offerToolbox, REPOMIX_VERSION } from './toolbox.mjs';
|
|
21
|
+
import { localSetupActions, localSetupSection, hasTeamSteps } from './local-setup.mjs';
|
|
22
|
+
import { LOCAL_SETUP_DOC } from './local-setup-steps.mjs';
|
|
21
23
|
import { readAllowList } from './agent-rules.mjs';
|
|
22
24
|
import { PREAPPROVED } from './agent-guard.mjs';
|
|
25
|
+
import { repoGitUrl } from './protection.mjs';
|
|
26
|
+
import { hostFromGitUrl, plainHost } from './platform.mjs';
|
|
23
27
|
|
|
24
28
|
// Parse a comma/space separated list into a clean, deduped array of trimmed tokens.
|
|
25
29
|
export function parseList(s) {
|
|
@@ -492,8 +496,8 @@ export async function runSetup(root, opts = {}) {
|
|
|
492
496
|
// 0. Profile interview — branch the wizard to the user's situation (solo/team, code, repo layout).
|
|
493
497
|
const { solo, team_size, codebase, repo_layout, configureTools } = await resolveProfile(root, opts);
|
|
494
498
|
// Steps: interview, preflight, install, Product, tools (1 if deferred else 3), repos, wire, coderabbit,
|
|
495
|
-
// toolbox, done.
|
|
496
|
-
const total =
|
|
499
|
+
// toolbox, local setup script (E185), done.
|
|
500
|
+
const total = 10 + (configureTools ? 3 : 1);
|
|
497
501
|
let _n = 0;
|
|
498
502
|
const S = (title) => step(++_n, total, title);
|
|
499
503
|
|
|
@@ -626,15 +630,31 @@ export async function runSetup(root, opts = {}) {
|
|
|
626
630
|
// Strict read for the same reason as the reconfigure write above: a corrupt Product must abort, never
|
|
627
631
|
// fail-open to `{}` and get rewritten with everything else stripped on a plain re-run.
|
|
628
632
|
const cur = readJSONStrict(productPath, {}) || {};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
633
|
+
// A git_url that names only a host is no repo (#513): replaced too — but only by an origin that names one
|
|
634
|
+
// on the SAME host. These settings are shared and committed: a person's own SSH alias (`gitlab-work`) or a
|
|
635
|
+
// fork on another host would send everyone, and CI, to the wrong place (#513 review 1).
|
|
636
|
+
const hostOnly = cur.platform && typeof cur.git_url === 'string' && cur.git_url.trim() && !repoGitUrl(cur.git_url);
|
|
637
|
+
const originUrl = (cur.platform && (!cur.git_url || hostOnly)) ? ((run('git', ['remote', 'get-url', 'origin'], { cwd: root }).stdout || '').trim() || null) : null;
|
|
638
|
+
// A value with no readable host (`gitlab.example.com`, no scheme) has no host to protect: any origin that
|
|
639
|
+
// names a repo replaces it (#513 review 2).
|
|
640
|
+
// Only an origin on a real host: a `file://` or local-path origin is no platform address (review 3).
|
|
641
|
+
const setHost = hostOnly ? plainHost(hostFromGitUrl(cur.git_url)) : null;
|
|
642
|
+
const originHost = originUrl ? plainHost(hostFromGitUrl(originUrl)) : null;
|
|
643
|
+
const fits = !!originUrl && !!repoGitUrl(originUrl) && !!originHost && (!setHost || originHost === setHost);
|
|
644
|
+
const backfillUrl = originUrl && (!hostOnly || fits) ? originUrl : null;
|
|
645
|
+
if (hostOnly && !backfillUrl) {
|
|
646
|
+
const why = !originUrl ? 'this clone has no origin remote'
|
|
647
|
+
: !repoGitUrl(originUrl) ? 'origin names no repo either'
|
|
648
|
+
: !originHost ? 'origin is not on a platform host'
|
|
649
|
+
: 'origin is on another host';
|
|
650
|
+
info(`the Product's git_url names no repo, and ${why} — left as it is: set git_url to the Product's full address`);
|
|
651
|
+
}
|
|
632
652
|
const mode = setupModeFields(root, cur, solo, opts);
|
|
633
653
|
const modeMoved = Object.keys(mode).some((k) => JSON.stringify(cur[k]) !== JSON.stringify(mode[k]));
|
|
634
654
|
if (modeMoved || JSON.stringify(cur.profile || {}) !== JSON.stringify({ codebase, repo_layout, team_size }) || backfillUrl) {
|
|
635
655
|
writeProductConfig(root, { ...cur, ...(backfillUrl ? { git_url: backfillUrl } : {}), ...mode, profile: { codebase, repo_layout, team_size } });
|
|
636
656
|
if (mode.mode_set) info(`mode: ${mode.mode_set.from} → ${mode.mode_set.to} (recorded as mode_set)`);
|
|
637
|
-
if (backfillUrl) info(`backfilled the Product's git_url from origin: ${backfillUrl}`);
|
|
657
|
+
if (backfillUrl) info(hostOnly ? `replaced the Product's git_url, which named no repo, with origin: ${backfillUrl}` : `backfilled the Product's git_url from origin: ${backfillUrl}`);
|
|
638
658
|
else info(`recorded profile: ${solo ? 'solo' : `team(${team_size})`}, ${codebase}, ${repo_layout}`);
|
|
639
659
|
}
|
|
640
660
|
}
|
|
@@ -851,6 +871,15 @@ export async function runSetup(root, opts = {}) {
|
|
|
851
871
|
}
|
|
852
872
|
const gitHookNote = gitHookAdvice(gitHookState(root));
|
|
853
873
|
if (gitHookNote) warn(gitHookNote);
|
|
874
|
+
// E185 part 4: the one-line notice after a pull, in every ledger mode — this clone's own copy of the script, in
|
|
875
|
+
// git's folder, and its hooks. Nothing committed, so nothing is pushed to `wired`.
|
|
876
|
+
const notice = localSetupNoticeActions(root);
|
|
877
|
+
if (notice.length) {
|
|
878
|
+
log(` ${c.bold('product')} ${c.dim('(local setup notice after a pull, this clone)')}`);
|
|
879
|
+
applyActions(notice, { force: true });
|
|
880
|
+
}
|
|
881
|
+
const noticeNote = localSetupNoticeAdvice(root);
|
|
882
|
+
if (noticeNote) info(noticeNote);
|
|
854
883
|
// The post-edit capture hook (E43): every change to an artifact is snapshotted onto the person's private
|
|
855
884
|
// `yad/wip/<name>/<epic>` branches. Both ledger modes; `"capture": false` in the Product config turns it off.
|
|
856
885
|
const captureWiring = captureHookActions(root, ideTargets);
|
|
@@ -859,6 +888,13 @@ export async function runSetup(root, opts = {}) {
|
|
|
859
888
|
applyActions(captureWiring, { force: true });
|
|
860
889
|
wired.push(...captureWiring);
|
|
861
890
|
}
|
|
891
|
+
// E178: the live activity record for `yad brain view --live` — only when the config says `"activity": true`.
|
|
892
|
+
const activityWiring = activityHookActions(root, ideTargets);
|
|
893
|
+
if (activityWiring.length) {
|
|
894
|
+
log(` ${c.bold('product')} ${c.dim('(activity record)')}`);
|
|
895
|
+
applyActions(activityWiring, { force: true });
|
|
896
|
+
wired.push(...activityWiring);
|
|
897
|
+
}
|
|
862
898
|
// E158: the rules block in AGENTS.md (and CLAUDE.md importing it), which an AI agent reads first. The team's
|
|
863
899
|
// own text in these files is kept; only the lines between yad's markers are written.
|
|
864
900
|
const agentFiles = agentFileActions(root, ideTargets);
|
|
@@ -905,6 +941,13 @@ export async function runSetup(root, opts = {}) {
|
|
|
905
941
|
guide(['Each tool is optional and has a fallback. yad installs nothing: it prints how to get each one, and you choose.']);
|
|
906
942
|
const toolbox = offerToolbox(root, root);
|
|
907
943
|
|
|
944
|
+
// E185: the local setup script each team member's agent follows on their machine. AFTER the toolbox step, so
|
|
945
|
+
// the tools chosen there are steps in it. The team's own steps in it are kept; yad's are rewritten.
|
|
946
|
+
S('Local setup script (for each team member\'s machine)');
|
|
947
|
+
guide(['Every team member\'s agent follows this script after they join and after each update. Each step says why it is needed and what it changes, so each person decides.']);
|
|
948
|
+
applyActions(localSetupActions(root), { force: true });
|
|
949
|
+
const localSetup = localSetupSection(root, { invite: true });
|
|
950
|
+
|
|
908
951
|
// Summary + version stamp
|
|
909
952
|
S('Done');
|
|
910
953
|
writeJSON(path.join(root, PROJECT_FILES.version), { version: VERSION, ideTargets, updatedAt: opts.today ?? null });
|
|
@@ -923,10 +966,13 @@ export async function runSetup(root, opts = {}) {
|
|
|
923
966
|
hand(`author your first epic: run \`${epicSkill}\``);
|
|
924
967
|
}
|
|
925
968
|
hand('your single next action, anytime: `yad next`');
|
|
969
|
+
hand(`get this machine ready: \`yad local-setup\` lists the steps in ${LOCAL_SETUP_DOC} that are not done here`);
|
|
926
970
|
if (!solo) hand('reviewers need no setup: anyone with access approves on the platform; a gate needs one approval (not the author\'s own), resolved threads and the merge');
|
|
927
971
|
log('');
|
|
928
972
|
log(c.bold('Then — AI-only steps (run in your AI agent):'));
|
|
929
973
|
if (registry.repos.length) hand('generate code-maps: run `yad-connect-repos` for each connected repo');
|
|
974
|
+
// E185 part 3: the agent proposes this project's own setup steps; the person says yes to each.
|
|
975
|
+
if (!hasTeamSteps(root)) hand('propose this project\'s own setup steps for each member\'s machine (a .env to copy, docker, the Node version): the person says yes to each, then `yad local-setup add --from <step.json>`');
|
|
930
976
|
const design = readJSON(designPath, null);
|
|
931
977
|
if (design && design.tool && design.tool !== 'none') {
|
|
932
978
|
hand(`confirm the design tool: run \`yad-connect-design\` to detect the ${design.tool} MCP (or it degrades to markdown-only)`);
|
|
@@ -949,7 +995,7 @@ export async function runSetup(root, opts = {}) {
|
|
|
949
995
|
// refused (YAD-CLI-001, with `questions`) before anything was written (E159, `assertSetupAnswered`).
|
|
950
996
|
return {
|
|
951
997
|
profile: { solo, team_size, codebase, repo_layout }, ideTargets,
|
|
952
|
-
repos: registry.repos.map((r) => r.name ?? null), next: epicSkill, toolbox,
|
|
998
|
+
repos: registry.repos.map((r) => r.name ?? null), next: epicSkill, toolbox, localSetup,
|
|
953
999
|
...(notes.length ? { notes } : {}),
|
|
954
1000
|
};
|
|
955
1001
|
}
|
package/cli/standup.mjs
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
import fs from 'node:fs';
|
|
34
34
|
import path from 'node:path';
|
|
35
35
|
import { c, log, info, warn, fail, hand, note, readJSON, forTerminal } from './lib.mjs';
|
|
36
|
+
import { brandForPage } from './brand.mjs';
|
|
36
37
|
import { productConfigPath } from './manifest.mjs';
|
|
37
38
|
import { STEPS, epicIds, epicRoot, loadLedger, isPassed, stepStatus, authorStepFor, acceptedHashes, gatePredicate, gateRuleFor, gateRuleSum, optionalStepsFor, readFrontmatter, legacyLogins } from './epic-state.mjs';
|
|
38
39
|
import { isSolo, requireEngagement } from './gate.mjs';
|
|
@@ -43,10 +44,11 @@ import { gitAuthors, personKey } from './people.mjs';
|
|
|
43
44
|
import { isBot } from './riskmap.mjs';
|
|
44
45
|
import { accountId, buildIssues, mdEscape, mdUrl } from './issues.mjs';
|
|
45
46
|
import { readMembers, memberStatuses, memberMatches, productIdentity, ttlDays, accountLabel, accessCheck } from './members.mjs';
|
|
46
|
-
import { ledgerEvents, esc, mdText
|
|
47
|
+
import { ledgerEvents, esc, mdText } from './usage.mjs';
|
|
48
|
+
import { writeOrSave } from './reports-dir.mjs';
|
|
47
49
|
import { readRegistry, judgeRepo, runnable } from './workspace.mjs';
|
|
48
50
|
import { listPrs, prTarget } from './pr-list.mjs';
|
|
49
|
-
import { shown } from './protection.mjs';
|
|
51
|
+
import { shown, configuredGitUrl } from './protection.mjs';
|
|
50
52
|
import { platformLogin } from './platform.mjs';
|
|
51
53
|
|
|
52
54
|
const DAY_MS = 86_400_000;
|
|
@@ -170,8 +172,8 @@ function wipSaves(root, env, startMs) {
|
|
|
170
172
|
// The repos to read: the Product and every registered repo. `dir` is set only when git may run there
|
|
171
173
|
// (judged first, E81); `gitUrl` is what the platform is asked about.
|
|
172
174
|
export function repoSources(root, identity, productConfig, notRead, env, { localPaths = true } = {}) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
+
// A git_url that names only a host is no repo: origin then (#513).
|
|
176
|
+
const productUrl = configuredGitUrl(productConfig?.git_url, () => gitIn(root, env)(['remote', 'get-url', 'origin']).out);
|
|
175
177
|
const out = [{ label: 'Product', dir: root, gitUrl: productUrl, platform: identity.platform }];
|
|
176
178
|
const { registry, problem } = readRegistry(root);
|
|
177
179
|
if (problem) notRead.push(`${safe(problem)} — the code repos are not read`);
|
|
@@ -193,14 +195,14 @@ export function repoSources(root, identity, productConfig, notRead, env, { local
|
|
|
193
195
|
|
|
194
196
|
// The one member a piece of evidence belongs to: `{ member }`, `{ ambiguous: [...] }` when more than one
|
|
195
197
|
// matches, or `{}` when none does.
|
|
196
|
-
function whose(members, e) {
|
|
198
|
+
export function whose(members, e) {
|
|
197
199
|
const hit = members.filter((m) => memberMatches(m, e));
|
|
198
200
|
if (hit.length === 1) return { member: hit[0] };
|
|
199
201
|
return hit.length ? { ambiguous: hit } : {};
|
|
200
202
|
}
|
|
201
203
|
// A git name made branch-safe (an owner file, a claim, a capture branch) — compared with the same form of
|
|
202
204
|
// each name a member file holds.
|
|
203
|
-
function whoseWip(members, w) {
|
|
205
|
+
export function whoseWip(members, w) {
|
|
204
206
|
const hit = members.filter((m) => m.names.some((n) => wipName(n) === w));
|
|
205
207
|
if (hit.length === 1) return { member: hit[0] };
|
|
206
208
|
return hit.length ? { ambiguous: hit } : {};
|
|
@@ -262,6 +264,70 @@ const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
|
262
264
|
const prWord = (platform) => (platform === 'gitlab' ? 'MR !' : 'PR #');
|
|
263
265
|
|
|
264
266
|
// The whole report as data. `now` is epoch milliseconds (injected, so a test can pin the day).
|
|
267
|
+
// WAITING — gates, by the owner of the step they review: the live E47 owner, else the epic's `owner`.
|
|
268
|
+
// Each epic on its own: a shared file that is not what yad writes stops that epic's lines, said in
|
|
269
|
+
// "not read", never the whole report. → { waits: [{ owner: { at, display, key } | null, item }], notRead }
|
|
270
|
+
// Shared by `yad standup` and `yad map` (E181), so the gate rule is read in one place.
|
|
271
|
+
export function gateWaits(root, { ledgers, members, productConfig, identity, places = [] }) {
|
|
272
|
+
const solo = isSolo(productConfig);
|
|
273
|
+
const engagement = requireEngagement(productConfig);
|
|
274
|
+
const waits = [];
|
|
275
|
+
const notRead = [];
|
|
276
|
+
const mergeWord = identity.platform ? `its review ${identity.platform === 'gitlab' ? 'MR' : 'PR'} to merge` : '`yad gate advance` (no platform: the gate moves on when it is advanced)';
|
|
277
|
+
for (const [epic, led] of ledgers) {
|
|
278
|
+
try {
|
|
279
|
+
const state = led.state;
|
|
280
|
+
if (!state?.steps) continue;
|
|
281
|
+
const owners = new Map(readOwners(root, epic).filter((o) => !o.error && o.live).map((o) => [o.step, o]));
|
|
282
|
+
const front = readFrontmatter(path.join(epicRoot(root, epic), 'epic.md')).owner || readFrontmatter(path.join(epicRoot(root, epic), 'roadmap.md')).owner;
|
|
283
|
+
const epicOwner = typeof front === 'string' && front.trim() ? front.trim() : null;
|
|
284
|
+
const ownerOf = (stepId) => {
|
|
285
|
+
const o = owners.get(stepId);
|
|
286
|
+
if (o) return { at: whoseWip(members, o.owner), display: o.name || o.owner, key: `wip:${o.owner}` };
|
|
287
|
+
if (epicOwner) return { at: whose(members, { login: epicOwner, name: epicOwner }), display: epicOwner, key: personKey({ login: epicOwner }) };
|
|
288
|
+
return null;
|
|
289
|
+
};
|
|
290
|
+
const put = (stepId, item) => { waits.push({ owner: ownerOf(stepId), item }); };
|
|
291
|
+
const approvals = records(led.approvals);
|
|
292
|
+
const comments = records(led.comments);
|
|
293
|
+
const reviewPrs = records(led.productPrs);
|
|
294
|
+
// (b) the current step is an author step someone owns, and it is not done.
|
|
295
|
+
const cur = state.steps.find((s) => s?.id === state.currentStep);
|
|
296
|
+
const curDef = STEPS.find((d) => d.id === cur?.id);
|
|
297
|
+
if (cur && !isPassed(cur) && curDef && curDef.kind !== 'review' && cur.type !== 'review+approve' && ownerOf(cur.id)) {
|
|
298
|
+
put(cur.id, { kind: 'next-move', epic, step: cur.id, state: stepStatus(cur), text: `${epic} ${safe(cur.id)} is the current step and theirs to author (${stepStatus(cur) || 'unknown state'})` });
|
|
299
|
+
}
|
|
300
|
+
// (a) an open gate: its author step passed, the review not yet. Read through the gate's own predicate,
|
|
301
|
+
// so this line never says more than `yad gate status` would (engagement, revoked approvals, solo).
|
|
302
|
+
for (const s of state.steps.filter((x) => x?.type === 'review+approve' && !isPassed(x))) {
|
|
303
|
+
const a = authorStepFor(state, s);
|
|
304
|
+
if (!a || !isPassed(a)) continue;
|
|
305
|
+
const verdict = gatePredicate({ step: s, approvals, acceptedHashes: acceptedHashes(epicRoot(root, epic), s.artifact), solo, requireEngagement: engagement, optional: optionalStepsFor(state) });
|
|
306
|
+
const rule = gateRuleFor(s);
|
|
307
|
+
const pr = reviewPrs.find((p) => (typeof p.step === 'string' && p.step === s.id) || (typeof p.artifact === 'string' && p.artifact === s.artifact));
|
|
308
|
+
const prNo = pr && Number.isSafeInteger(pr.number) ? pr.number : null;
|
|
309
|
+
const via = prNo != null ? `${prWord(identity.platform)}${prNo}` : null;
|
|
310
|
+
const asks = rule.riskStep ? `; the count asks ${gateRuleSum(rule)} (risk step advisory)` : '';
|
|
311
|
+
const waitsFor = solo
|
|
312
|
+
? `waits for ${via ? `review ${via} to merge` : mergeWord} (solo mode: approvals waived)`
|
|
313
|
+
: verdict.approvalsSatisfied
|
|
314
|
+
? `has the ${plural(verdict.have ?? 0, 'approval')} it needs to pass; waits for ${via ? `review ${via} to merge` : mergeWord}${asks}`
|
|
315
|
+
: `waits for approval — missing: ${verdict.missing.map(safe).join('; ')}${asks}${via ? `; review ${via}` : ''}`;
|
|
316
|
+
put(a.id, { kind: 'gate', epic, step: s.id, approvals: verdict.have ?? null, needed: rule.base, asks: rule.needed, missing: verdict.missing, pr: prNo, text: `${epic} ${safe(s.id)} ${waitsFor}` });
|
|
317
|
+
const rounds = comments.filter((x) => x.step === s.id && Number.isSafeInteger(x.round) && x.round >= 0);
|
|
318
|
+
if (rounds.length) {
|
|
319
|
+
const round = Math.max(...rounds.map((x) => x.round));
|
|
320
|
+
const count = rounds.filter((x) => x.round === round).reduce((n, x) => n + (Number.isSafeInteger(x.count) && x.count >= 0 && x.count <= 100_000 ? x.count : 1), 0);
|
|
321
|
+
put(a.id, { kind: 'comments', epic, step: s.id, round, count, text: `${epic} ${safe(s.id)}: ${plural(count, 'comment')} recorded in review round ${round} (yad does not know which are answered)` });
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
} catch (e) {
|
|
325
|
+
notRead.push(`${epic}: its gates could not be read (${why(e, places)}) — nothing is said about what waits there`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return { waits, notRead };
|
|
329
|
+
}
|
|
330
|
+
|
|
265
331
|
export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null, env = process.env, runner, fetch = true, access = accessCheck } = {}) {
|
|
266
332
|
const win = windowFor(now, { tz, since });
|
|
267
333
|
if (win.error) return win;
|
|
@@ -425,67 +491,13 @@ export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null,
|
|
|
425
491
|
byWip(w.name, w.name, 'working', { kind: 'drafts', epic: w.epic, last: new Date(w.at).toISOString(), text: `saved drafts on ${safe(w.epic)} (${zoneStamp(w.at, tz)}; nothing unmerged is open now)` });
|
|
426
492
|
}
|
|
427
493
|
|
|
428
|
-
// WAITING — gates, by the owner of the step they review
|
|
429
|
-
// Each epic on its own: a shared file that is not what yad writes stops that epic's lines, said in
|
|
430
|
-
// "not read", never the whole report.
|
|
431
|
-
const solo = isSolo(productConfig);
|
|
432
|
-
const engagement = requireEngagement(productConfig);
|
|
494
|
+
// WAITING — gates, by the owner of the step they review (gateWaits).
|
|
433
495
|
const ownerless = [];
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const owners = new Map(readOwners(root, epic).filter((o) => !o.error && o.live).map((o) => [o.step, o]));
|
|
440
|
-
const front = readFrontmatter(path.join(epicRoot(root, epic), 'epic.md')).owner || readFrontmatter(path.join(epicRoot(root, epic), 'roadmap.md')).owner;
|
|
441
|
-
const epicOwner = typeof front === 'string' && front.trim() ? front.trim() : null;
|
|
442
|
-
const ownerOf = (stepId) => {
|
|
443
|
-
const o = owners.get(stepId);
|
|
444
|
-
if (o) return { at: whoseWip(members, o.owner), display: o.name || o.owner, key: `wip:${o.owner}` };
|
|
445
|
-
if (epicOwner) return { at: whose(members, { login: epicOwner, name: epicOwner }), display: epicOwner, key: personKey({ login: epicOwner }) };
|
|
446
|
-
return null;
|
|
447
|
-
};
|
|
448
|
-
const put = (stepId, item) => {
|
|
449
|
-
const o = ownerOf(stepId);
|
|
450
|
-
if (!o) { ownerless.push(item); return; }
|
|
451
|
-
place(o.at, o.display, o.key, 'waiting', item);
|
|
452
|
-
};
|
|
453
|
-
const approvals = records(led.approvals);
|
|
454
|
-
const comments = records(led.comments);
|
|
455
|
-
const reviewPrs = records(led.productPrs);
|
|
456
|
-
// (b) the current step is an author step someone owns, and it is not done.
|
|
457
|
-
const cur = state.steps.find((s) => s?.id === state.currentStep);
|
|
458
|
-
const curDef = STEPS.find((d) => d.id === cur?.id);
|
|
459
|
-
if (cur && !isPassed(cur) && curDef && curDef.kind !== 'review' && cur.type !== 'review+approve' && ownerOf(cur.id)) {
|
|
460
|
-
put(cur.id, { kind: 'next-move', epic, step: cur.id, state: stepStatus(cur), text: `${epic} ${safe(cur.id)} is the current step and theirs to author (${stepStatus(cur) || 'unknown state'})` });
|
|
461
|
-
}
|
|
462
|
-
// (a) an open gate: its author step passed, the review not yet. Read through the gate's own predicate,
|
|
463
|
-
// so this line never says more than `yad gate status` would (engagement, revoked approvals, solo).
|
|
464
|
-
for (const s of state.steps.filter((x) => x?.type === 'review+approve' && !isPassed(x))) {
|
|
465
|
-
const a = authorStepFor(state, s);
|
|
466
|
-
if (!a || !isPassed(a)) continue;
|
|
467
|
-
const verdict = gatePredicate({ step: s, approvals, acceptedHashes: acceptedHashes(epicRoot(root, epic), s.artifact), solo, requireEngagement: engagement, optional: optionalStepsFor(state) });
|
|
468
|
-
const rule = gateRuleFor(s);
|
|
469
|
-
const pr = reviewPrs.find((p) => (typeof p.step === 'string' && p.step === s.id) || (typeof p.artifact === 'string' && p.artifact === s.artifact));
|
|
470
|
-
const prNo = pr && Number.isSafeInteger(pr.number) ? pr.number : null;
|
|
471
|
-
const via = prNo != null ? `${prWord(identity.platform)}${prNo}` : null;
|
|
472
|
-
const asks = rule.riskStep ? `; the count asks ${gateRuleSum(rule)} (risk step advisory)` : '';
|
|
473
|
-
const waitsFor = solo
|
|
474
|
-
? `waits for ${via ? `review ${via} to merge` : mergeWord} (solo mode: approvals waived)`
|
|
475
|
-
: verdict.approvalsSatisfied
|
|
476
|
-
? `has the ${plural(verdict.have ?? 0, 'approval')} it needs to pass; waits for ${via ? `review ${via} to merge` : mergeWord}${asks}`
|
|
477
|
-
: `waits for approval — missing: ${verdict.missing.map(safe).join('; ')}${asks}${via ? `; review ${via}` : ''}`;
|
|
478
|
-
put(a.id, { kind: 'gate', epic, step: s.id, approvals: verdict.have ?? null, needed: rule.base, asks: rule.needed, missing: verdict.missing, pr: prNo, text: `${epic} ${safe(s.id)} ${waitsFor}` });
|
|
479
|
-
const rounds = comments.filter((x) => x.step === s.id && Number.isSafeInteger(x.round) && x.round >= 0);
|
|
480
|
-
if (rounds.length) {
|
|
481
|
-
const round = Math.max(...rounds.map((x) => x.round));
|
|
482
|
-
const count = rounds.filter((x) => x.round === round).reduce((n, x) => n + (Number.isSafeInteger(x.count) && x.count >= 0 && x.count <= 100_000 ? x.count : 1), 0);
|
|
483
|
-
put(a.id, { kind: 'comments', epic, step: s.id, round, count, text: `${epic} ${safe(s.id)}: ${plural(count, 'comment')} recorded in review round ${round} (yad does not know which are answered)` });
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
} catch (e) {
|
|
487
|
-
notRead.push(`${epic}: its gates could not be read (${why(e, places)}) — nothing is said about what waits there`);
|
|
488
|
-
}
|
|
496
|
+
const gw = gateWaits(root, { ledgers, members, productConfig, identity, places });
|
|
497
|
+
notRead.push(...gw.notRead);
|
|
498
|
+
for (const { owner, item } of gw.waits) {
|
|
499
|
+
if (!owner) ownerless.push(item);
|
|
500
|
+
else place(owner.at, owner.display, owner.key, 'waiting', item);
|
|
489
501
|
}
|
|
490
502
|
// WAITING / WORKING — their own open PRs/MRs.
|
|
491
503
|
for (const p of prRead) {
|
|
@@ -537,6 +549,9 @@ export function buildStandup(root, { now = Date.now(), tz = 'UTC', since = null,
|
|
|
537
549
|
};
|
|
538
550
|
}
|
|
539
551
|
|
|
552
|
+
// How many things wait, across every person in the model — the state word in a saved report's name.
|
|
553
|
+
export const waitingCount = (model) => [...(model.team || []), ...(model.unlisted || []), ...(model.left || [])].reduce((n, p) => n + (Array.isArray(p.waiting) ? p.waiting.length : 0), 0);
|
|
554
|
+
|
|
540
555
|
// Narrow the report to one member: by any of their logins (any account), case-insensitive.
|
|
541
556
|
export function onlyMember(model, login) {
|
|
542
557
|
const want = String(login).toLowerCase();
|
|
@@ -665,7 +680,12 @@ export function renderMarkdown(model) {
|
|
|
665
680
|
return L.join('\n');
|
|
666
681
|
}
|
|
667
682
|
|
|
668
|
-
|
|
683
|
+
// The page with the Product's brand (E184) added after its own CSS, so the brand's colours and fonts win.
|
|
684
|
+
export function renderHtml(model, { brandCss = '' } = {}) {
|
|
685
|
+
const html = renderHtmlPage(model);
|
|
686
|
+
return brandCss ? html.replace('</style>', () => `\n${brandCss}\n</style>`) : html;
|
|
687
|
+
}
|
|
688
|
+
function renderHtmlPage(model) {
|
|
669
689
|
const list = (items, empty) => (items.length ? `<ul>${items.map((it) => `<li>${esc(it.text)}</li>`).join('')}</ul>` : `<p class="none">${esc(empty)}</p>`);
|
|
670
690
|
const block = (b, title, sub = '') => `<section class="member"><h2>${esc(title)}${sub ? ` <span>${esc(sub)}</span>` : ''}</h2>${SECTIONS.map(([k, label]) => `<h3>${label}</h3>${list(b[k], emptyLine(model))}`).join('')}${b.issues ? `<h3>Assigned items</h3>${b.issues.length ? `<ul>${b.issues.map((it) => `<li>${it.url ? `<a href="${esc(it.url)}">${esc(it.ref)}</a>` : esc(it.ref)} ${esc(it.title)} <span class="none">(${esc(itemMeta(it))})</span></li>`).join('')}</ul>` : `<p class="none">${esc(noItems(model))}</p>`}` : ''}</section>`;
|
|
671
691
|
const missing = gapLines(model);
|
|
@@ -724,11 +744,13 @@ export async function runStandup(root, { now = Date.now(), tz = 'UTC', since = n
|
|
|
724
744
|
if (model.error) return refuse(model.error, model.hint);
|
|
725
745
|
if (who) model = onlyMember(model, who);
|
|
726
746
|
if (format) {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
if (
|
|
730
|
-
|
|
731
|
-
|
|
747
|
+
// E180: with no --out, saved in the local reports folder, named by who it covers and how much waits.
|
|
748
|
+
const saved = writeOrSave(root, { out, kind: 'standup', scope: who || 'team', state: `${waitingCount(model)} waiting`, ext: format, content: format === 'md' ? renderMarkdown(model) : renderHtml(model, { brandCss: brandForPage(root, 'standup').css }), command: 'standup', env });
|
|
749
|
+
if (saved.problem) return refuse(saved.problem);
|
|
750
|
+
for (const w of saved.warnings) warn(w);
|
|
751
|
+
if (json) note(`wrote ${format.toUpperCase()} report → ${saved.file}`);
|
|
752
|
+
else info(`wrote ${format.toUpperCase()} report → ${c.bold(saved.file)}`);
|
|
753
|
+
return { ...model, out: saved.file };
|
|
732
754
|
}
|
|
733
755
|
if (!json) renderText(model);
|
|
734
756
|
return { ...model, out: null };
|
package/cli/status.mjs
CHANGED
|
@@ -60,11 +60,12 @@ function finished(root, id, ledger, a) {
|
|
|
60
60
|
const laneSteps = (lane) => (Array.isArray(lane?.steps) ? lane.steps.filter((s) => s && typeof s.id === 'string') : []);
|
|
61
61
|
const real = (p) => { try { return fs.realpathSync(p); } catch { return path.resolve(p); } };
|
|
62
62
|
|
|
63
|
-
// The registered repo this checkout is. A
|
|
64
|
-
// `registryEntryFor`
|
|
65
|
-
//
|
|
66
|
-
//
|
|
67
|
-
//
|
|
63
|
+
// The registered repo this checkout is. A git worktree of a registered repo (agents often work in one) is
|
|
64
|
+
// that repo, and `registryEntryFor` answers it (#515); the branch reported is the worktree's own. This view
|
|
65
|
+
// only reads, so it is more lenient than a command that writes: a worktree moved by hand, whose git
|
|
66
|
+
// back-link is stale (`git worktree repair` not yet run), still names its repo by git's common folder. A
|
|
67
|
+
// monorepo registers the Product's own folder (`path: "."`), which `registryEntryFor` never answers (it is
|
|
68
|
+
// a code-repo command's guard), so that one case is matched here.
|
|
68
69
|
function repoHere(root, cwd, top) {
|
|
69
70
|
const hit = registryEntryFor(root, cwd)?.meta?.name;
|
|
70
71
|
if (typeof hit === 'string') return hit;
|