yadflow 4.9.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.
Files changed (155) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/README.md +15 -5
  3. package/bin/commands.mjs +11 -1
  4. package/bin/yad.mjs +203 -14
  5. package/cli/agent-guard-worker.mjs +13 -0
  6. package/cli/agent-guard.mjs +1797 -73
  7. package/cli/agent-rules.mjs +64 -5
  8. package/cli/argv-flags.mjs +2 -2
  9. package/cli/brain/vendor/LICENSE-graphology-library.txt +21 -0
  10. package/cli/brain/vendor/LICENSE-graphology.txt +21 -0
  11. package/cli/brain/vendor/LICENSE-sigma.txt +12 -0
  12. package/cli/brain/vendor/graphology-library.min.js +2 -0
  13. package/cli/brain/vendor/graphology.umd.min.js +2 -0
  14. package/cli/brain/vendor/sigma.min.js +1369 -0
  15. package/cli/brain/view/app.js +382 -0
  16. package/cli/brain/view/index.html +63 -0
  17. package/cli/brain/view/live.css +228 -0
  18. package/cli/brain/view/live.html +110 -0
  19. package/cli/brain/view/live.js +884 -0
  20. package/cli/brain/view/style.css +141 -0
  21. package/cli/brain-about.mjs +206 -0
  22. package/cli/brain-activity.mjs +285 -0
  23. package/cli/brain-skills.mjs +118 -0
  24. package/cli/brain-vendor.mjs +71 -0
  25. package/cli/brain-view.mjs +344 -0
  26. package/cli/brain.mjs +810 -0
  27. package/cli/ci-check.mjs +48 -4
  28. package/cli/codeowners-command.mjs +72 -6
  29. package/cli/commit.mjs +17 -3
  30. package/cli/docs.mjs +2 -0
  31. package/cli/doctor.mjs +151 -25
  32. package/cli/epic-state.mjs +186 -4
  33. package/cli/epic.mjs +26 -10
  34. package/cli/errors.mjs +2 -1
  35. package/cli/find-product.mjs +69 -15
  36. package/cli/fold.mjs +31 -6
  37. package/cli/foundation-publish.mjs +256 -0
  38. package/cli/gate.mjs +29 -3
  39. package/cli/git-read.mjs +38 -0
  40. package/cli/guard-stream.mjs +409 -0
  41. package/cli/guide.mjs +3 -1
  42. package/cli/hook.mjs +102 -9
  43. package/cli/issue-links.mjs +61 -0
  44. package/cli/issues-act.mjs +371 -0
  45. package/cli/issues-write.mjs +441 -0
  46. package/cli/issues.mjs +513 -0
  47. package/cli/lib.mjs +37 -2
  48. package/cli/lifecycle.mjs +7 -0
  49. package/cli/local-page.mjs +138 -0
  50. package/cli/machine.mjs +1 -1
  51. package/cli/manifest.mjs +59 -3
  52. package/cli/map/view/app.js +712 -0
  53. package/cli/map/view/index.html +50 -0
  54. package/cli/map/view/style.css +142 -0
  55. package/cli/map-view.mjs +186 -0
  56. package/cli/map.mjs +637 -0
  57. package/cli/members.mjs +9 -15
  58. package/cli/next.mjs +1 -1
  59. package/cli/openpr.mjs +26 -6
  60. package/cli/plan.mjs +127 -0
  61. package/cli/platform.mjs +159 -4
  62. package/cli/product-index.mjs +1 -1
  63. package/cli/protection.mjs +53 -3
  64. package/cli/reconcile.mjs +9 -3
  65. package/cli/report.mjs +9 -3
  66. package/cli/reports-dir.mjs +391 -0
  67. package/cli/reports.mjs +65 -0
  68. package/cli/run-checks.mjs +15 -4
  69. package/cli/scan.mjs +314 -0
  70. package/cli/setup.mjs +42 -8
  71. package/cli/standup.mjs +120 -78
  72. package/cli/status.mjs +6 -5
  73. package/cli/story-frames.mjs +17 -6
  74. package/cli/test-agents-file.mjs +985 -12
  75. package/cli/test-brain-activity.mjs +753 -0
  76. package/cli/test-brain-view.mjs +381 -0
  77. package/cli/test-brain.mjs +795 -0
  78. package/cli/test-build.mjs +25 -0
  79. package/cli/test-ci-check.mjs +469 -10
  80. package/cli/test-guide.mjs +218 -0
  81. package/cli/test-machine.mjs +59 -0
  82. package/cli/test-map.mjs +615 -0
  83. package/cli/test-node.mjs +15 -0
  84. package/cli/test-reports.mjs +382 -0
  85. package/cli/test-run-checks.mjs +21 -0
  86. package/cli/test-setup-agent.mjs +14 -0
  87. package/cli/test-story-frames.mjs +74 -4
  88. package/cli/test-worktree.mjs +24 -3
  89. package/cli/toolbox-connect.mjs +259 -0
  90. package/cli/toolbox.mjs +187 -12
  91. package/cli/update-commit.mjs +101 -9
  92. package/cli/usage.mjs +8 -4
  93. package/package.json +12 -4
  94. package/skills/sdlc/config.yaml +1 -1
  95. package/skills/sdlc/module-help.csv +3 -1
  96. package/skills/yad-analysis/SKILL.md +4 -0
  97. package/skills/yad-architecture/SKILL.md +22 -4
  98. package/skills/yad-backfill/SKILL.md +4 -0
  99. package/skills/yad-change/SKILL.md +7 -1
  100. package/skills/yad-change/references/triage.md +2 -0
  101. package/skills/yad-checks/SKILL.md +15 -7
  102. package/skills/yad-checks/references/check-gates.md +70 -35
  103. package/skills/yad-checks/templates/checks/build-test-lint.sh +7 -0
  104. package/skills/yad-checks/templates/checks/install-deps.sh +6 -0
  105. package/skills/yad-checks/templates/checks/member-check.mjs +3 -2
  106. package/skills/yad-checks/templates/checks/package-manager.sh +42 -0
  107. package/skills/yad-checks/templates/checks/risk-map-check.sh +2 -2
  108. package/skills/yad-checks/templates/checks/verified-commits.sh +3 -3
  109. package/skills/yad-checks/templates/github/yad-checks.yml +358 -69
  110. package/skills/yad-checks/templates/github/yad-pr-text.yml +118 -0
  111. package/skills/yad-checks/templates/github/yad-product-checks.yml +130 -54
  112. package/skills/yad-checks/templates/github/yad-product-pr-text.yml +131 -0
  113. package/skills/yad-checks/templates/github/yad-update-guard.yml +2 -1
  114. package/skills/yad-checks/templates/github/yad-verified-commits.yml +49 -3
  115. package/skills/yad-checks/templates/gitlab/yad-checks.gitlab-ci.yml +80 -20
  116. package/skills/yad-checks/templates/gitlab/yad-product-checks.gitlab-ci.yml +59 -9
  117. package/skills/yad-checks/templates/gitlab/yad-update-guard.gitlab-ci.yml +1 -0
  118. package/skills/yad-checks/templates/gitlab/yad-verified-commits.gitlab-ci.yml +49 -1
  119. package/skills/yad-checks/templates/hooks/agent-guard.mjs +44 -10
  120. package/skills/yad-checks/templates/hooks/ledger-guard-cursor.mjs +12 -6
  121. package/skills/yad-checks/templates/hooks/yad-activity.mjs +238 -0
  122. package/skills/yad-commit/SKILL.md +3 -1
  123. package/skills/yad-connect-design/SKILL.md +42 -10
  124. package/skills/yad-connect-design/references/design-context.md +35 -5
  125. package/skills/yad-connect-design/references/design-registry.md +3 -3
  126. package/skills/yad-connect-learning/SKILL.md +12 -2
  127. package/skills/yad-connect-repos/SKILL.md +18 -0
  128. package/skills/yad-connect-testing/SKILL.md +22 -5
  129. package/skills/yad-connect-testing/references/testing-context.md +1 -1
  130. package/skills/yad-discovery/SKILL.md +11 -0
  131. package/skills/yad-discovery/references/foundation-schema.md +11 -0
  132. package/skills/yad-docs/templates/app/package-lock.json +18 -10
  133. package/skills/yad-docs/templates/app/package.json +6 -1
  134. package/skills/yad-epic/SKILL.md +7 -0
  135. package/skills/yad-epic/references/state-schema.md +50 -1
  136. package/skills/yad-guide/SKILL.md +8 -4
  137. package/skills/yad-implement/SKILL.md +117 -4
  138. package/skills/yad-implement/references/implement-conventions.md +2 -1
  139. package/skills/yad-issues/SKILL.md +54 -0
  140. package/skills/yad-learn/SKILL.md +4 -0
  141. package/skills/yad-open-pr/SKILL.md +6 -0
  142. package/skills/yad-pr-template/SKILL.md +2 -1
  143. package/skills/yad-pr-template/templates/checks/pr-template.sh +8 -4
  144. package/skills/yad-pr-template/templates/checks/pr-title.sh +42 -6
  145. package/skills/yad-product-bridge/references/bridge.md +28 -0
  146. package/skills/yad-product-bridge/templates/github/yad-gate-sync.yml +25 -11
  147. package/skills/yad-product-bridge/templates/gitlab/yad-gate-sync.gitlab-ci.yml +38 -14
  148. package/skills/yad-run/SKILL.md +5 -0
  149. package/skills/yad-scan/SKILL.md +51 -0
  150. package/skills/yad-spec/SKILL.md +32 -2
  151. package/skills/yad-stories/SKILL.md +22 -4
  152. package/skills/yad-stories/references/story-schema.md +1 -1
  153. package/skills/yad-test-cases/SKILL.md +18 -2
  154. package/skills/yad-ui/SKILL.md +43 -8
  155. package/skills/yad-checks/templates/gitlab/.gitlab-ci.yml +0 -49
@@ -0,0 +1,138 @@
1
+ // A page served to this machine only, or written as one self-contained file (E177, shared since E181).
2
+ //
3
+ // `yad brain view` (E177) and `yad map` (E181) both draw a page in the person's browser. The rules that keep
4
+ // that page safe live here, once:
5
+ // - the server binds 127.0.0.1 on a random port; every request needs the one-time key (`?t=`), compared in
6
+ // constant time; the Host header must be the address printed (no DNS rebinding); GET and HEAD only; a
7
+ // fixed route table, so no request path ever reaches the filesystem; strict headers (CSP, no-store,
8
+ // no-referrer, no framing);
9
+ // - the self-contained file holds every script and style inline, allowed by their hashes and nothing else,
10
+ // with the data in a `<script type="application/json">` that no name can close;
11
+ // - a file the person names is written by a temp file and a rename, never through a link, and a warning
12
+ // says when it sits in a git work tree that does not ignore it.
13
+ import fs from 'node:fs';
14
+ import http from 'node:http';
15
+ import path from 'node:path';
16
+ import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
17
+ import { spawnSync } from 'node:child_process';
18
+ import { writePlain } from './brain.mjs';
19
+
20
+ export const CSP = "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'";
21
+ export const BASE_HEADERS = Object.freeze({
22
+ 'Content-Security-Policy': CSP,
23
+ 'X-Content-Type-Options': 'nosniff',
24
+ 'Cache-Control': 'no-store',
25
+ 'Referrer-Policy': 'no-referrer',
26
+ 'Cross-Origin-Resource-Policy': 'same-origin',
27
+ 'Cross-Origin-Opener-Policy': 'same-origin',
28
+ 'X-Frame-Options': 'DENY',
29
+ });
30
+ export const TYPES = Object.freeze({ html: 'text/html; charset=utf-8', js: 'text/javascript; charset=utf-8', css: 'text/css; charset=utf-8', json: 'application/json; charset=utf-8' });
31
+
32
+ // Is `given` the token? A length check first: `timingSafeEqual` throws on buffers of different lengths.
33
+ export function tokenMatches(given, token) {
34
+ if (typeof given !== 'string') return false;
35
+ const a = Buffer.from(given);
36
+ const b = Buffer.from(token);
37
+ return a.length === b.length && timingSafeEqual(a, b);
38
+ }
39
+
40
+ // Start a locked-down page server: { url, token, port, host, server, close() }.
41
+ // routes(token) → Map(pathname → () => { type, body, status? }) — a request path is only ever a KEY.
42
+ // stream optional { path, attach(req, res, headers), close() } — a one-way event stream (SSE).
43
+ export function startPageServer({ routes, stream = null, host = '127.0.0.1', port = 0, failText = 'the page could not read its files' }) {
44
+ const token = randomBytes(24).toString('hex');
45
+ const table = routes(token);
46
+ let expectedHost = null;
47
+ const server = http.createServer((req, res) => {
48
+ const send = (status, type, body, extra = {}) => {
49
+ res.writeHead(status, { ...BASE_HEADERS, 'Content-Type': type, ...extra });
50
+ res.end(req.method === 'HEAD' ? undefined : body);
51
+ };
52
+ const text = (status, msg, extra) => send(status, 'text/plain; charset=utf-8', `${msg}\n`, extra);
53
+ if (req.method !== 'GET' && req.method !== 'HEAD') return text(405, 'method not allowed', { Allow: 'GET, HEAD' });
54
+ if (req.headers.host !== expectedHost) return text(403, 'forbidden');
55
+ let url;
56
+ try { url = new URL(req.url, `http://${expectedHost}`); } catch { return text(400, 'bad request'); }
57
+ if (!tokenMatches(url.searchParams.get('t'), token)) return text(403, 'forbidden');
58
+ if (stream && url.pathname === (stream.path || '/events') && req.method === 'GET') return stream.attach(req, res, BASE_HEADERS);
59
+ const route = table.get(url.pathname);
60
+ if (!route) return text(404, 'not found');
61
+ try {
62
+ const r = route();
63
+ return send(r.status || 200, r.type, r.body);
64
+ } catch {
65
+ return text(500, failText);
66
+ }
67
+ });
68
+ return new Promise((resolve, reject) => {
69
+ server.once('error', reject);
70
+ server.listen(port, host, () => {
71
+ const a = server.address();
72
+ expectedHost = `${host}:${a.port}`;
73
+ resolve({
74
+ url: `http://${expectedHost}/?t=${token}`, token, port: a.port, host, server,
75
+ close: () => new Promise((done) => { stream?.close(); server.closeAllConnections?.(); server.close(() => done()); }),
76
+ });
77
+ });
78
+ });
79
+ }
80
+
81
+ // JSON that can sit inside a <script> element: nothing in it can end the element or start a comment.
82
+ export const scriptSafeJSON = (value) => JSON.stringify(value)
83
+ .replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026')
84
+ .replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
85
+ const sha256b64 = (s) => createHash('sha256').update(s, 'utf8').digest('base64');
86
+
87
+ export const SERVED_START = '<!--SERVED:start-->';
88
+ export const SERVED_END = '<!--SERVED:end-->';
89
+
90
+ // One HTML file with everything inline, and a CSP that allows exactly the inline blocks it holds (by hash)
91
+ // and no network at all. `shell` is the served page: its `<script src>` tags sit between the SERVED markers
92
+ // and are cut out by them (never by matching HTML with a pattern), its stylesheet link becomes a <style>, and
93
+ // `<!--SCRIPTS-->` becomes the data block followed by each script.
94
+ export function inlineSnapshot({ shell, scripts, css, dataId, data }) {
95
+ // A script's own text must not hold `</script`, or the file would end it early: checked here, so a future
96
+ // file that holds one fails loudly instead of breaking the page.
97
+ for (const s of scripts) if (/<\/script/i.test(s)) throw new Error('an inline script holds </script');
98
+ const csp = [
99
+ "default-src 'none'",
100
+ `script-src ${scripts.map((s) => `'sha256-${sha256b64(s)}'`).join(' ')}`,
101
+ `style-src 'sha256-${sha256b64(css)}'`,
102
+ "img-src data:", "base-uri 'none'", "form-action 'none'",
103
+ ].join('; ');
104
+ // The key placeholder goes before anything is spliced in: the data's own names may hold the same text.
105
+ const page = shell.replaceAll('__TOKEN__', '');
106
+ const from = page.indexOf(SERVED_START);
107
+ const to = page.indexOf(SERVED_END);
108
+ if (from < 0 || to < from) throw new Error(`the page has no ${SERVED_START} … ${SERVED_END} block`);
109
+ const body = (page.slice(0, from) + page.slice(to + SERVED_END.length))
110
+ .replace(/<link rel="stylesheet"[^>]*>/, () => `<style>${css}</style>`)
111
+ .replace('<!--SCRIPTS-->', () => [
112
+ `<script type="application/json" id="${dataId}">${scriptSafeJSON(data)}</script>`,
113
+ ...scripts.map((s) => `<script>${s}</script>`),
114
+ ].join('\n'));
115
+ return body
116
+ .replace(/<meta http-equiv="Content-Security-Policy"[^>]*>/, () => `<meta http-equiv="Content-Security-Policy" content="${csp}">`);
117
+ }
118
+
119
+ // Write `data` to the path the person named, by a temp file and a rename, refusing a link at the target (a
120
+ // rename replaces a link, but a person who put one there means the file it points at). → null | problem
121
+ export function writeOwnFile(file, data) {
122
+ let st = null;
123
+ try { st = fs.lstatSync(file); } catch { /* new file */ }
124
+ if (st && !st.isFile()) return `${file} is not a plain file (a link or a folder) — name another path`;
125
+ const dir = path.dirname(file);
126
+ if (!fs.existsSync(dir)) return `the folder ${dir} does not exist`;
127
+ writePlain(dir, path.basename(file), data);
128
+ return null;
129
+ }
130
+
131
+ // Is `file` inside a git work tree, and NOT ignored there? Then committing it is one `git add .` away.
132
+ export function trackedRisk(file, runner = spawnSync) {
133
+ const dir = path.dirname(file);
134
+ const inTree = runner('git', ['-C', dir, 'rev-parse', '--is-inside-work-tree'], { encoding: 'utf8' });
135
+ if (inTree.status !== 0 || String(inTree.stdout).trim() !== 'true') return false;
136
+ const ignored = runner('git', ['-C', dir, 'check-ignore', '-q', '--', path.basename(file)], { encoding: 'utf8' });
137
+ return ignored.status === 1;
138
+ }
package/cli/machine.mjs CHANGED
@@ -8,7 +8,7 @@
8
8
  // need no Docker, so a repo that names none is never asked about.
9
9
  // glab more than one glab config file. glab then reads only one and ignores the other (a login saved
10
10
  // there is not used), and warns on every run, which breaks JSON for a tool that reads its output
11
- // and its errors together.
11
+ // and its errors together. yad's own glab calls drop that warning (`run` in cli/lib.mjs, #509).
12
12
  import fs from 'node:fs';
13
13
  import os from 'node:os';
14
14
  import path from 'node:path';
package/cli/manifest.mjs CHANGED
@@ -63,6 +63,8 @@ export const SKILLS = [
63
63
  'yad-defects',
64
64
  'yad-reconcile',
65
65
  'yad-stub',
66
+ 'yad-issues',
67
+ 'yad-scan',
66
68
  ];
67
69
 
68
70
  // Old skill names. `check`/`update` migrate any install still carrying one: remove the old copy,
@@ -189,7 +191,7 @@ export const MODULE_CONFIG = '.sdlc/config.yaml';
189
191
  // the fallback `registerDesign`/setup use when an unknown tool is named, and `none` is the explicit
190
192
  // markdown-only choice. (doctor does NOT fall back — an unknown tool there is a hard YAD-CFG-002 fail,
191
193
  // mirroring how registerRepo falls back on platform while doctor fails on an unknown Product platform.)
192
- export const DESIGN_TOOLS = ['figma', 'pencil'];
194
+ export const DESIGN_TOOLS = ['figma', 'pencil', 'openpencil'];
193
195
  export const DESIGN_PRIMARY = 'figma';
194
196
 
195
197
  // Supported testing-tool adapters (mirrors skills/sdlc/config.yaml `testing.tools`); `TESTING_PRIMARY`
@@ -492,6 +494,8 @@ export const REPO_WIRING = {
492
494
  ],
493
495
  github: [
494
496
  { src: 'skills/yad-checks/templates/github/yad-checks.yml', dest: '.github/workflows/yad-checks.yml' },
497
+ // pr-title + pr-template, the only checks an edit of the PR text re-runs (#425).
498
+ { src: 'skills/yad-checks/templates/github/yad-pr-text.yml', dest: '.github/workflows/yad-pr-text.yml' },
495
499
  // Integrity gate for direct-to-default pushes (`yad update --push`): verified-commits + commit-message.
496
500
  { src: 'skills/yad-checks/templates/github/yad-update-guard.yml', dest: '.github/workflows/yad-update-guard.yml' },
497
501
  { src: 'skills/yad-pr-template/templates/github/pull_request_template.md', dest: '.github/pull_request_template.md' },
@@ -549,6 +553,7 @@ export const PRODUCT_WIRING = {
549
553
  { src: 'skills/yad-product-bridge/templates/github/yad-gate-sync.yml', dest: '.github/workflows/yad-gate-sync.yml' },
550
554
  { src: 'skills/yad-checks/templates/github/yad-verified-commits.yml', dest: '.github/workflows/yad-verified-commits.yml' },
551
555
  { src: 'skills/yad-checks/templates/github/yad-product-checks.yml', dest: '.github/workflows/yad-product-checks.yml' },
556
+ { src: 'skills/yad-checks/templates/github/yad-product-pr-text.yml', dest: '.github/workflows/yad-product-pr-text.yml' },
552
557
  // Integrity gate for the Product's own direct-to-default pushes (`yad update --push`; the machine-
553
558
  // state `yad checkpoint`/`gate ci` commits carry [skip ci] and are intentionally not re-checked).
554
559
  { src: 'skills/yad-checks/templates/github/yad-update-guard.yml', dest: '.github/workflows/yad-update-guard.yml' },
@@ -574,8 +579,9 @@ export const PROTECTION_GUIDE_URL = 'https://github.com/abdelrahmannasr/yadflow/
574
579
  // check is named after its job (the jobs set no `name:`), on GitLab a job is the job's key. `yad ci check`
575
580
  // reads the GitHub list against the branch's required checks; on GitLab "Pipelines must succeed" covers
576
581
  // every job, so the list there is for the docs only. `productVerified` is the Product's verified-commits
577
- // workflow, required when that file is there. Tests hold this equal to the templates' jobs and to the table
578
- // in docs/branch-protection.md.
582
+ // workflow, required when that file is there. On GitHub, pr-title and pr-template run from their own file
583
+ // (yad-pr-text.yml / yad-product-pr-text.yml, #425). Tests hold each list equal to the jobs of its templates
584
+ // and to the table in docs/branch-protection.md.
579
585
  export const REQUIRED_CHECKS = Object.freeze({
580
586
  github: Object.freeze({
581
587
  product: Object.freeze(['commit-message', 'pr-title', 'pr-template', 'ledger-guard', 'member-check']),
@@ -823,6 +829,56 @@ export const agentGuardAdapters = (dest) => Object.freeze({
823
829
  });
824
830
  export const AGENT_GUARD_ADAPTERS = agentGuardAdapters(AGENT_GUARD_WIRING[0].dest);
825
831
 
832
+ // The live activity record (E178): AFTER each tool an agent uses, `yad-activity.mjs` appends one line to the
833
+ // repo's `<git common dir>/yad-activity.jsonl` — the kind of action (read, search, edit, run), the repo's files
834
+ // it touched, the time — which `yad brain view --live` draws. OFF by default: wired only while the Product
835
+ // config says `"activity": true`, in the Product and in each code repo cloned here. It never starts yad (it
836
+ // fires on every read), writes only allowlisted fields, and always exits 0 with nothing on stdout.
837
+ //
838
+ // A LIST of adapters, not one per target: Cursor needs two events (an edit and a shell command each have their
839
+ // own, and no read event exists that takes no answer — `beforeReadFile` must answer allow/deny), so Cursor
840
+ // sessions show edits and runs only. Each adapter is merged and unmerged on its own event; the two Cursor ones
841
+ // share one command, which `mergeHookSettings` matches per event.
842
+ export const ACTIVITY_WIRING = [
843
+ { src: 'skills/yad-checks/templates/hooks/yad-activity.mjs', dest: 'hooks/yad-activity.mjs' },
844
+ ];
845
+ // In a code repo the script goes in `checks/`, as the agent guard's does (REPO_AGENT_GUARD_DEST).
846
+ export const REPO_ACTIVITY_DEST = 'checks/yad-activity.mjs';
847
+ export const activityAdapters = (dest) => Object.freeze([
848
+ Object.freeze({
849
+ target: '.claude',
850
+ label: 'activity record',
851
+ settings: '.claude/settings.json',
852
+ event: 'PostToolUse',
853
+ nested: true,
854
+ preamble: null,
855
+ // Every tool the live view draws: reads, searches, edits and shell commands.
856
+ matcher: 'Read|Grep|Glob|Edit|Write|MultiEdit|NotebookEdit|Bash',
857
+ projectDirEnv: CLAUDE_PROJECT_DIR_ENV,
858
+ // Quoted and anchored on the project root, and the format said, for the reasons capture's entry gives.
859
+ command: `node "$${CLAUDE_PROJECT_DIR_ENV}/${dest}" --format claude`,
860
+ observe: true,
861
+ wiring: Object.freeze([]),
862
+ legacyCommands: Object.freeze([]),
863
+ }),
864
+ ...['afterFileEdit', 'afterShellExecution'].map((event) => Object.freeze({
865
+ target: '.cursor',
866
+ label: 'activity record',
867
+ settings: '.cursor/hooks.json',
868
+ event,
869
+ nested: false,
870
+ preamble: Object.freeze({ version: 1 }),
871
+ matcher: null,
872
+ projectDirEnv: CURSOR_PROJECT_DIR_ENV,
873
+ // Relative and unquoted, for the reason the ledger guard's Cursor entry is (see above).
874
+ command: `node ${dest} --format cursor`,
875
+ observe: true,
876
+ wiring: Object.freeze([]),
877
+ legacyCommands: Object.freeze([]),
878
+ })),
879
+ ]);
880
+ export const ACTIVITY_ADAPTERS = activityAdapters(ACTIVITY_WIRING[0].dest);
881
+
826
882
  // The Claude adapter's fields under their original names. Kept because they are what the shipped
827
883
  // error text and the existing tests name, and renaming a constant buys nothing; new code should read
828
884
  // the adapter, since these three describe ONE harness and the engine now supports two.