yadflow 4.11.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +2 -0
  3. package/bin/commands.mjs +2 -0
  4. package/bin/yad.mjs +55 -2
  5. package/cli/agent-rules.mjs +26 -1
  6. package/cli/argv-flags.mjs +1 -1
  7. package/cli/brain/view/index.html +1 -1
  8. package/cli/brain/view/live.html +1 -1
  9. package/cli/brain-view.mjs +5 -4
  10. package/cli/brand-cmd.mjs +326 -0
  11. package/cli/brand.mjs +327 -0
  12. package/cli/doctor.mjs +65 -1
  13. package/cli/guide.mjs +26 -3
  14. package/cli/issues.mjs +9 -3
  15. package/cli/local-page.mjs +2 -2
  16. package/cli/local-setup-record.mjs +71 -0
  17. package/cli/local-setup-steps.mjs +186 -0
  18. package/cli/local-setup.mjs +611 -0
  19. package/cli/manifest.mjs +5 -0
  20. package/cli/map/view/index.html +1 -1
  21. package/cli/map-view.mjs +8 -4
  22. package/cli/plain-text.mjs +22 -0
  23. package/cli/plan.mjs +185 -36
  24. package/cli/reconcile.mjs +53 -11
  25. package/cli/reports-dir.mjs +6 -4
  26. package/cli/scan.mjs +3 -5
  27. package/cli/secret-text.mjs +66 -0
  28. package/cli/setup.mjs +25 -4
  29. package/cli/standup.mjs +8 -2
  30. package/cli/test-brand.mjs +558 -0
  31. package/cli/test-guide.mjs +227 -0
  32. package/cli/test-local-setup.mjs +1188 -0
  33. package/cli/toolbox.mjs +15 -1
  34. package/cli/update-commit.mjs +35 -18
  35. package/cli/usage.mjs +9 -3
  36. package/cli/workspace.mjs +11 -2
  37. package/package.json +3 -3
  38. package/skills/sdlc/module-help.csv +1 -0
  39. package/skills/yad-brand/SKILL.md +69 -0
  40. package/skills/yad-checks/templates/hooks/local-setup-notice.mjs +96 -0
  41. package/skills/yad-checks/templates/hooks/yad-activity.mjs +2 -2
  42. package/skills/yad-guide/SKILL.md +9 -6
@@ -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, activityHookActions, 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,6 +18,8 @@ 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';
23
25
  import { repoGitUrl } from './protection.mjs';
@@ -494,8 +496,8 @@ export async function runSetup(root, opts = {}) {
494
496
  // 0. Profile interview — branch the wizard to the user's situation (solo/team, code, repo layout).
495
497
  const { solo, team_size, codebase, repo_layout, configureTools } = await resolveProfile(root, opts);
496
498
  // Steps: interview, preflight, install, Product, tools (1 if deferred else 3), repos, wire, coderabbit,
497
- // toolbox, done.
498
- const total = 9 + (configureTools ? 3 : 1);
499
+ // toolbox, local setup script (E185), done.
500
+ const total = 10 + (configureTools ? 3 : 1);
499
501
  let _n = 0;
500
502
  const S = (title) => step(++_n, total, title);
501
503
 
@@ -869,6 +871,15 @@ export async function runSetup(root, opts = {}) {
869
871
  }
870
872
  const gitHookNote = gitHookAdvice(gitHookState(root));
871
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);
872
883
  // The post-edit capture hook (E43): every change to an artifact is snapshotted onto the person's private
873
884
  // `yad/wip/<name>/<epic>` branches. Both ledger modes; `"capture": false` in the Product config turns it off.
874
885
  const captureWiring = captureHookActions(root, ideTargets);
@@ -930,6 +941,13 @@ export async function runSetup(root, opts = {}) {
930
941
  guide(['Each tool is optional and has a fallback. yad installs nothing: it prints how to get each one, and you choose.']);
931
942
  const toolbox = offerToolbox(root, root);
932
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
+
933
951
  // Summary + version stamp
934
952
  S('Done');
935
953
  writeJSON(path.join(root, PROJECT_FILES.version), { version: VERSION, ideTargets, updatedAt: opts.today ?? null });
@@ -948,10 +966,13 @@ export async function runSetup(root, opts = {}) {
948
966
  hand(`author your first epic: run \`${epicSkill}\``);
949
967
  }
950
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`);
951
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');
952
971
  log('');
953
972
  log(c.bold('Then — AI-only steps (run in your AI agent):'));
954
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>`');
955
976
  const design = readJSON(designPath, null);
956
977
  if (design && design.tool && design.tool !== 'none') {
957
978
  hand(`confirm the design tool: run \`yad-connect-design\` to detect the ${design.tool} MCP (or it degrades to markdown-only)`);
@@ -974,7 +995,7 @@ export async function runSetup(root, opts = {}) {
974
995
  // refused (YAD-CLI-001, with `questions`) before anything was written (E159, `assertSetupAnswered`).
975
996
  return {
976
997
  profile: { solo, team_size, codebase, repo_layout }, ideTargets,
977
- repos: registry.repos.map((r) => r.name ?? null), next: epicSkill, toolbox,
998
+ repos: registry.repos.map((r) => r.name ?? null), next: epicSkill, toolbox, localSetup,
978
999
  ...(notes.length ? { notes } : {}),
979
1000
  };
980
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';
@@ -679,7 +680,12 @@ export function renderMarkdown(model) {
679
680
  return L.join('\n');
680
681
  }
681
682
 
682
- export function renderHtml(model) {
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) {
683
689
  const list = (items, empty) => (items.length ? `<ul>${items.map((it) => `<li>${esc(it.text)}</li>`).join('')}</ul>` : `<p class="none">${esc(empty)}</p>`);
684
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>`;
685
691
  const missing = gapLines(model);
@@ -739,7 +745,7 @@ export async function runStandup(root, { now = Date.now(), tz = 'UTC', since = n
739
745
  if (who) model = onlyMember(model, who);
740
746
  if (format) {
741
747
  // E180: with no --out, saved in the local reports folder, named by who it covers and how much waits.
742
- const saved = writeOrSave(root, { out, kind: 'standup', scope: who || 'team', state: `${waitingCount(model)} waiting`, ext: format, content: format === 'md' ? renderMarkdown(model) : renderHtml(model), command: 'standup', env });
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 });
743
749
  if (saved.problem) return refuse(saved.problem);
744
750
  for (const w of saved.warnings) warn(w);
745
751
  if (json) note(`wrote ${format.toUpperCase()} report → ${saved.file}`);