@desplega.ai/agent-swarm 1.102.0 → 1.103.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 (107) hide show
  1. package/dist/{actions-j9399ktm.js → actions-7txktrdj.js} +6 -6
  2. package/dist/{app-tnq1pz27.js → app-xm3xsdye.js} +3 -3
  3. package/dist/{assistant-c7y92gkw.js → assistant-qpv63wk6.js} +9 -9
  4. package/dist/{boot-reembed-k7e6fc1p.js → boot-reembed-9cxqka3e.js} +3 -3
  5. package/dist/{boot-reembed-b97r699t.js → boot-reembed-chxhrwv8.js} +4 -4
  6. package/dist/{boot-scrub-logs-14kbc61y.js → boot-scrub-logs-8qtfkcz8.js} +2 -2
  7. package/dist/{claude-managed-adapter-g07dbz3b.js → claude-managed-adapter-z29hjgzz.js} +3 -3
  8. package/dist/{cli-tsz1q7gk.js → cli-2307phk1.js} +375 -23
  9. package/dist/{cli-g5px3d7x.js → cli-2957pqpj.js} +24 -1
  10. package/dist/{cli-9qascwj7.js → cli-2qynerth.js} +1 -1
  11. package/dist/{cli-k1ghyj8b.js → cli-4fnp2tc3.js} +1 -1
  12. package/dist/{cli-hc4rd6sv.js → cli-85pf4z38.js} +1 -1
  13. package/dist/{cli-zk4gn40w.js → cli-8hyv6c2v.js} +6 -14
  14. package/dist/{cli-k81y1cjb.js → cli-8w95v19d.js} +1 -1
  15. package/dist/{cli-7xdq3jg3.js → cli-92fqyjcv.js} +1 -1
  16. package/dist/{cli-zctkpdmd.js → cli-dz3d6zjg.js} +1 -1
  17. package/dist/{cli-d0t4854c.js → cli-fedn86nz.js} +213 -476
  18. package/dist/{cli-g861fwjp.js → cli-fwxdt7kt.js} +3 -3
  19. package/dist/{cli-2aaa9mqr.js → cli-fygaw191.js} +2 -2
  20. package/dist/{cli-qbc6mncp.js → cli-gzepjz54.js} +2 -2
  21. package/dist/{cli-r68m8arr.js → cli-jt9d9fjw.js} +1 -1
  22. package/dist/{cli-axtg1zaa.js → cli-khe4x17a.js} +1 -1
  23. package/dist/{cli-sygq3fhn.js → cli-kk51f3tf.js} +5 -5
  24. package/dist/{cli-dgab5x2h.js → cli-krvxq8bc.js} +1 -1
  25. package/dist/{cli-xde8vhhp.js → cli-ksq38x4n.js} +2 -2
  26. package/dist/{cli-stqqf5kh.js → cli-m8f6qzck.js} +1 -1
  27. package/dist/{cli-ap4md0gc.js → cli-ns0r7mkr.js} +30 -5
  28. package/dist/{cli-t2jk33ta.js → cli-rttgde5f.js} +18 -6
  29. package/dist/{cli-mhj07xbq.js → cli-rvae030h.js} +3 -3
  30. package/dist/{cli-q6jzg6wj.js → cli-s14sb64w.js} +4 -4
  31. package/dist/{cli-zmf7refz.js → cli-v9283nma.js} +1 -1
  32. package/dist/{cli-fjx4x7nn.js → cli-xmtsan9k.js} +1 -1
  33. package/dist/{cli-vgck9mqq.js → cli-yeemwevj.js} +155 -37
  34. package/dist/{cli-5bqa41fd.js → cli-yfwwjeft.js} +1 -1
  35. package/dist/{cli-s8jw5bmg.js → cli-yp2krx5r.js} +2 -2
  36. package/dist/cli.js +9 -9
  37. package/dist/{codex-adapter-wf119mnw.js → codex-adapter-w0xharsg.js} +3 -3
  38. package/dist/{codex-session-runner-1gknw7mh.js → codex-session-runner-kzbjcm2k.js} +3 -3
  39. package/dist/{commands-2wyn3swb.js → commands-aqn63mcw.js} +2 -2
  40. package/dist/{db-567ntpxv.js → db-azrvwsnj.js} +2 -2
  41. package/dist/{handlers-wvwpk2kj.js → handlers-hf61har3.js} +9 -9
  42. package/dist/{hook-fatkywc0.js → hook-306p3yz4.js} +2 -2
  43. package/dist/{http-eq6wxve6.js → http-zts4haq7.js} +81 -62
  44. package/dist/{index-400x6p3j.js → index-29vg51x6.js} +6 -6
  45. package/dist/{index-9wqh5352.js → index-3c651yfk.js} +10 -10
  46. package/dist/{index-6aj8966p.js → index-bfh9hgek.js} +5 -5
  47. package/dist/{index-d1rm4ea3.js → index-h2yqjyk0.js} +8 -8
  48. package/dist/{keepalive-6x9nx92g.js → keepalive-a0dg5pds.js} +4 -4
  49. package/dist/{lead-5fgqwe13.js → lead-7mcxedkc.js} +21 -21
  50. package/dist/{maintenance-eajx5k1k.js → maintenance-mrzqd53t.js} +4 -4
  51. package/dist/{onboard-jc1w1edg.js → onboard-4dkpv9wa.js} +2 -2
  52. package/dist/{otel-impl-8k375amf.js → otel-impl-jt7gpyp9.js} +1 -1
  53. package/dist/{pi-mono-adapter-hf8sw7hs.js → pi-mono-adapter-zf7dt1wg.js} +1 -1
  54. package/dist/{pricing-refresh-zed6916t.js → pricing-refresh-xqnzh8dt.js} +4 -4
  55. package/dist/{seed-pricing-5805qzkz.js → seed-pricing-56tjm1fj.js} +3 -3
  56. package/dist/{setup-wz05vxh0.js → setup-tbwk8j10.js} +2 -2
  57. package/dist/{worker-j359graf.js → worker-e03za92t.js} +21 -21
  58. package/openapi.json +70 -1
  59. package/package.json +1 -1
  60. package/src/be/db.ts +83 -13
  61. package/src/be/migrations/098_repo_hooks_config.sql +3 -0
  62. package/src/be/task-lifecycle-events.ts +42 -0
  63. package/src/commands/runner.ts +174 -25
  64. package/src/github/task-reactions.ts +21 -0
  65. package/src/hooks/tool-loop-detection.test.ts +40 -0
  66. package/src/hooks/tool-loop-detection.ts +37 -1
  67. package/src/http/agents.ts +7 -0
  68. package/src/http/index.ts +16 -2
  69. package/src/http/prompt-templates.ts +1 -1
  70. package/src/http/repos.ts +5 -1
  71. package/src/http/schedules.ts +1 -1
  72. package/src/http/session-data.ts +2 -0
  73. package/src/http/tasks.ts +2 -1
  74. package/src/http/workflows.ts +1 -0
  75. package/src/prompts/resolver.ts +1 -1
  76. package/src/scheduler/scheduler.ts +25 -2
  77. package/src/server-runtime-counters.ts +12 -0
  78. package/src/server-user.ts +1 -2
  79. package/src/server.ts +5 -0
  80. package/src/telemetry.ts +18 -1
  81. package/src/tests/http-api-integration.test.ts +4 -0
  82. package/src/tests/model-control.test.ts +6 -6
  83. package/src/tests/swarm-repos.test.ts +25 -2
  84. package/src/tests/task-lifecycle-events.test.ts +53 -0
  85. package/src/tests/task-lifecycle-telemetry.test.ts +37 -1
  86. package/src/tests/telemetry-init.test.ts +32 -0
  87. package/src/tools/prompt-templates/preview.ts +1 -1
  88. package/src/tools/repos/update-repo.ts +6 -1
  89. package/src/tools/schedules/create-schedule.ts +1 -1
  90. package/src/tools/schedules/update-schedule.ts +1 -1
  91. package/src/tools/send-task.ts +7 -2
  92. package/src/tools/task-action.ts +6 -2
  93. package/src/types.ts +155 -1
  94. package/src/utils/template.ts +127 -0
  95. package/src/workflows/engine.ts +7 -0
  96. package/src/workflows/executors/agent-task.ts +1 -2
  97. package/src/workflows/template.ts +12 -121
  98. package/src/workflows/triggers.ts +6 -2
  99. package/templates/community/code-health-reports/PLAYBOOK.md +355 -0
  100. package/templates/community/code-health-reports/README.md +38 -0
  101. package/templates/community/code-health-reports/lead-prompt.md +52 -0
  102. package/templates/community/code-health-reports/report.mjs +378 -0
  103. package/templates/community/code-health-reports/run.sh +143 -0
  104. package/templates/schedules/weekly-code-health-reports/config.json +13 -0
  105. package/templates/schedules/weekly-code-health-reports/content.md +60 -0
  106. package/src/model-tiers.ts +0 -140
  107. package/templates/community/.gitkeep +0 -0
@@ -0,0 +1,355 @@
1
+ # Code Health Reports for Your Codebase, on Autopilot
2
+
3
+ An Agent-Swarm playbook template for running recurring Code Maat + D3.js reports on any Git repository.
4
+
5
+ ## What You Get
6
+
7
+ This setup gives your swarm a stable code-health report page for one repository:
8
+
9
+ - Hotspots: files with high change frequency and complexity.
10
+ - Temporal coupling: files that tend to change together.
11
+ - Code age: how recently parts of the codebase changed.
12
+ - Ownership and knowledge concentration: who has historically contributed the most to each file.
13
+ - A weekly refresh that updates the same page in place, so the URL does not change.
14
+
15
+ The first run installs or downloads what it needs. You do not pre-install Code Maat or D3.
16
+
17
+ ## Template Files
18
+
19
+ The community template lives in `templates/community/code-health-reports/` and contains:
20
+
21
+ - `PLAYBOOK.md`: this playbook.
22
+ - `run.sh`: the parameterized runner.
23
+ - `report.mjs`: the static report generator.
24
+ - `lead-prompt.md`: the copy-paste Lead kickoff prompt.
25
+
26
+ Install shape:
27
+
28
+ ```bash
29
+ mkdir -p /workspace/code-maat
30
+ cp templates/community/code-health-reports/run.sh /workspace/code-maat/
31
+ cp templates/community/code-health-reports/report.mjs /workspace/code-maat/
32
+ cp templates/community/code-health-reports/lead-prompt.md /workspace/code-maat/
33
+ chmod +x /workspace/code-maat/run.sh
34
+ ```
35
+
36
+ Parameterize each run with environment variables:
37
+
38
+ ```bash
39
+ BASE_DIR=/workspace/code-maat \
40
+ REPO_NAME=my-repo \
41
+ REPO_URL=https://github.com/OWNER/REPO.git \
42
+ BRANCH=main \
43
+ SCOPE_PATH=src \
44
+ bash /workspace/code-maat/run.sh
45
+ ```
46
+
47
+ ## Libraries and Runtime Shape
48
+
49
+ The workflow uses:
50
+
51
+ - [Code Maat](https://github.com/adamtornhill/code-maat): Adam Tornhill's command-line tool for mining version-control history.
52
+ - [D3.js](https://d3js.org): browser-side charts. The report loads D3 v7 from jsDelivr at render time, so there is no front-end build step.
53
+ - [Lizard](https://github.com/terryyin/lizard): cyclomatic complexity analyzer used to add a complexity axis to the history metrics.
54
+ - Node.js: runs `report.mjs`, which parses CSV outputs and writes static `report.html` plus `summary.json`.
55
+ - Git history: Code Maat works from a formatted `git log`.
56
+ - Java runtime: required to run the Code Maat standalone Clojure JAR.
57
+
58
+ The generated HTML is static. The only network fetch at view time is D3:
59
+
60
+ ```html
61
+ <script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
62
+ ```
63
+
64
+ ## Template Directory Structure
65
+
66
+ Use a workspace outside the target repository so report artifacts and downloaded tools do not pollute the codebase:
67
+
68
+ ```text
69
+ /workspace/code-maat/
70
+ run.sh
71
+ report.mjs
72
+ lead-prompt.md
73
+ code-maat.jar # downloaded on first run
74
+ repos/
75
+ <repo-name>/ # scratch clone, push URL disabled
76
+ out/
77
+ <repo-name>/
78
+ <YYYY-MM-DD>/
79
+ git-src.log
80
+ revisions.csv
81
+ coupling.csv
82
+ age.csv
83
+ authors.csv
84
+ entity-ownership.csv
85
+ main-dev.csv
86
+ abs-churn.csv
87
+ entity-churn.csv
88
+ lizard-functions.csv
89
+ summary.json
90
+ report.html
91
+ latest-pointer.json
92
+ latest.json
93
+ latest.html
94
+ latest-pointer.json
95
+ ```
96
+
97
+ ## First-Run Behavior
98
+
99
+ `run.sh` does the following:
100
+
101
+ - Installs `default-jre-headless` if `java` is missing.
102
+ - Installs `nodejs` if `node` is missing.
103
+ - Installs Python and `lizard` if Lizard is missing.
104
+ - Downloads Code Maat v1.0.4 standalone JAR into `BASE_DIR` if missing.
105
+ - Clones the target repository into a scratch directory.
106
+ - Disables the scratch clone push URL so the scheduled job cannot push accidentally.
107
+ - Generates Code Maat CSVs and a Lizard CSV.
108
+ - Runs `report.mjs`.
109
+ - Copies the latest artifacts to stable `latest.html`, `latest.json`, and `latest-pointer.json` paths.
110
+
111
+ ## Runner Parameters
112
+
113
+ Set these variables before calling `run.sh`:
114
+
115
+ ```bash
116
+ BASE_DIR=/workspace/code-maat
117
+ REPO_NAME=my-repo
118
+ REPO_URL=https://github.com/OWNER/REPO.git
119
+ BRANCH=main
120
+ SCOPE_PATH=src
121
+ LOCAL_SOURCE= # optional local git clone seed
122
+ RUN_DATE=2026-06-26 # optional, defaults to current UTC date
123
+ ```
124
+
125
+ The runner generates the git log with:
126
+
127
+ ```bash
128
+ git -C "$REPO_DIR" log --all --numstat --date=short --pretty=format:'--%h--%ad--%aN' --no-renames -- "$SCOPE_PATH"
129
+ ```
130
+
131
+ It runs these Code Maat analyses:
132
+
133
+ ```text
134
+ summary
135
+ revisions
136
+ coupling
137
+ age
138
+ authors
139
+ entity-ownership
140
+ entity-effort
141
+ main-dev
142
+ main-dev-by-revs
143
+ abs-churn
144
+ author-churn
145
+ entity-churn
146
+ ```
147
+
148
+ Then it runs Lizard over the scoped path and writes:
149
+
150
+ ```text
151
+ OUT_DIR/lizard-functions.csv
152
+ OUT_DIR/summary.json
153
+ OUT_DIR/latest-pointer.json
154
+ OUT_DIR/report.html
155
+ ```
156
+
157
+ ## Report Generator
158
+
159
+ `report.mjs` parses the Code Maat and Lizard CSVs, joins historical metrics to current file LOC, computes a hotspot score, and embeds the final data in a static HTML file.
160
+
161
+ The generator interface:
162
+
163
+ ```bash
164
+ node /workspace/code-maat/report.mjs \
165
+ /workspace/code-maat/out/<repo-name>/<YYYY-MM-DD> \
166
+ /workspace/code-maat/repos/<repo-name> \
167
+ <repo-name> \
168
+ <YYYY-MM-DD> \
169
+ <SCOPE_PATH>
170
+ ```
171
+
172
+ The default hotspot score is:
173
+
174
+ ```text
175
+ risk score = revisions * log2(total cyclomatic complexity + 1)
176
+ ```
177
+
178
+ The generated report includes:
179
+
180
+ - Hotspot bubble chart.
181
+ - Change-frequency x complexity scatter.
182
+ - Top hotspot table.
183
+ - Temporal coupling table.
184
+ - Code age distribution.
185
+ - D3 v7 loaded from CDN at view time.
186
+
187
+ ## Step-by-Step Playbook
188
+
189
+ 1. Choose a repository and scope.
190
+
191
+ `src` is a good default for application code because it avoids docs, package metadata, generated files, and examples. For monorepos, use a narrower scope such as `apps/web/src` or `packages/core/src`.
192
+
193
+ 2. Install the template.
194
+
195
+ Copy `run.sh`, `report.mjs`, and `lead-prompt.md` from `templates/community/code-health-reports/` into `/workspace/code-maat`, then make the runner executable.
196
+
197
+ 3. Run it once manually.
198
+
199
+ ```bash
200
+ BASE_DIR=/workspace/code-maat \
201
+ REPO_NAME=my-repo \
202
+ REPO_URL=https://github.com/OWNER/REPO.git \
203
+ BRANCH=main \
204
+ SCOPE_PATH=src \
205
+ bash /workspace/code-maat/run.sh
206
+ ```
207
+
208
+ 4. Review local output.
209
+
210
+ ```bash
211
+ ls /workspace/code-maat/out/my-repo/latest.html
212
+ ls /workspace/code-maat/out/my-repo/latest.json
213
+ ```
214
+
215
+ 5. Publish the HTML to your swarm page system.
216
+
217
+ Create the page once, then store the returned stable page ID somewhere your scheduled task can read it. On later runs, update that same page by ID instead of creating a new page.
218
+
219
+ ```text
220
+ First run:
221
+ create page from /workspace/code-maat/out/my-repo/latest.html
222
+ save PAGE_ID=<stable-page-id>
223
+
224
+ Later runs:
225
+ update page PAGE_ID with /workspace/code-maat/out/my-repo/latest.html
226
+ ```
227
+
228
+ 6. Wire a weekly schedule.
229
+
230
+ Use a code-capable worker because this job may need to repair the script when upstream dependencies, repo branches, or page APIs change.
231
+
232
+ ```yaml
233
+ name: code-maat-weekly
234
+ cadence:
235
+ cron: "0 21 * * 0"
236
+ timezone: "UTC"
237
+ target:
238
+ worker: "<code-capable-worker>"
239
+ env:
240
+ BASE_DIR: "/workspace/code-maat"
241
+ REPO_NAME: "my-repo"
242
+ REPO_URL: "https://github.com/OWNER/REPO.git"
243
+ BRANCH: "main"
244
+ SCOPE_PATH: "src"
245
+ PAGE_ID: "<stable-page-id>"
246
+ task:
247
+ - run /workspace/code-maat/run.sh
248
+ - update the existing page PAGE_ID in place with latest.html
249
+ - verify D3 charts render and the page has no console errors
250
+ - if the run fails, diagnose and repair the runner/report generator before reporting failure
251
+ ```
252
+
253
+ 7. Keep the same page URL.
254
+
255
+ The report should update in place. The page URL should not change between weekly runs.
256
+
257
+ ## Copy-Paste Lead Prompt
258
+
259
+ The canonical copy lives in `lead-prompt.md` in the template and is also included below so this playbook can stand alone.
260
+
261
+ ```text
262
+ Bootstrap a recurring Code Maat + D3 code-health report for my repository.
263
+
264
+ Parameters:
265
+ - Repository URL: <REPO_URL>
266
+ - Default branch: <BRANCH>
267
+ - Path scope to analyze: <SCOPE_PATH, e.g. src>
268
+ - Report name/slug: <REPORT_NAME>
269
+ - Cadence: weekly by default, cron "0 21 * * 0" in <TIMEZONE>
270
+ - Stable page behavior: create the page once, then update the same page ID in place on every run.
271
+
272
+ Requirements:
273
+ 1. Work outside the target repository under /workspace/code-maat.
274
+ 2. Install the community template files there:
275
+ - run.sh
276
+ - report.mjs
277
+ - lead-prompt.md
278
+ 3. On first run, install/download missing runtime dependencies:
279
+ - Java runtime for the Code Maat standalone JAR.
280
+ - Code Maat v1.0.4 standalone JAR from GitHub releases.
281
+ - Lizard via Python user install if it is not available.
282
+ - D3 v7 must be loaded from a CDN by the generated HTML; do not add a front-end build step.
283
+ 4. Clone the repository into /workspace/code-maat/repos/<REPORT_NAME>, disable its push URL, fetch the requested branch, and analyze only <SCOPE_PATH>.
284
+ 5. Generate the git log with:
285
+ git log --all --numstat --date=short --pretty=format:'--%h--%ad--%aN' --no-renames -- <SCOPE_PATH>
286
+ 6. Run Code Maat analyses:
287
+ summary, revisions, coupling, age, authors, entity-ownership, entity-effort, main-dev, main-dev-by-revs, abs-churn, author-churn, entity-churn.
288
+ 7. Run Lizard over <SCOPE_PATH> and save lizard-functions.csv.
289
+ 8. Generate a static D3 report with:
290
+ - Hotspot bubble chart.
291
+ - Change-frequency x complexity scatter.
292
+ - Temporal coupling table.
293
+ - Ownership columns in the hotspot table.
294
+ - Code age distribution.
295
+ - Static detail tables.
296
+ 9. Publish the first report as a swarm page and persist its stable page ID in the workflow configuration.
297
+ 10. Create a schedule pinned to a code-capable worker:
298
+ - Default cadence: weekly, cron "0 21 * * 0".
299
+ - To change the cadence, edit the cron field and timezone only.
300
+ - Each run executes run.sh, updates the same page ID in place, verifies the page renders, and self-repairs the runner/report if the failure is local and fixable.
301
+ 11. Do not push any PR unless I explicitly ask for a versioned repository change.
302
+
303
+ Deliver back:
304
+ - The stable page URL.
305
+ - The workspace paths for run.sh, report.mjs, latest.html, and latest.json.
306
+ - The schedule name, cron, timezone, and how to change them.
307
+ - Any prerequisites or assumptions you could not satisfy automatically.
308
+ ```
309
+
310
+ ## Weekly Cadence and How To Change It
311
+
312
+ Default cadence:
313
+
314
+ ```yaml
315
+ cron: "0 21 * * 0"
316
+ timezone: "UTC"
317
+ ```
318
+
319
+ That means weekly on Sunday at 21:00 UTC. Change the `cron` field to adjust the refresh time, and change `timezone` if you want the cron interpreted in another zone:
320
+
321
+ ```yaml
322
+ # Every Monday at 09:00 Europe/Madrid
323
+ cron: "0 9 * * 1"
324
+ timezone: "Europe/Madrid"
325
+ ```
326
+
327
+ The cadence is separate from the page identity. Changing the cron only changes when the report refreshes. It should still update the same stable page ID in place.
328
+
329
+ ## How To Read the Report
330
+
331
+ - Revisions/change frequency: how often a file changed in the scoped git history.
332
+ - Hotspot/risk score: a combined signal using change frequency and complexity.
333
+ - Temporal coupling: files that change together in the same revisions.
334
+ - Code age: how long it has been since each entity last changed. Code Maat's code-age analysis computes age in months relative to the report date.
335
+ - Ownership/main developer: the author with the largest share of historical additions for a file.
336
+ - Cyclomatic complexity: a static code metric from Lizard, aggregated per file and paired with Code Maat's revision counts.
337
+
338
+ ## References
339
+
340
+ - [D3.js](https://d3js.org): JavaScript library used for the browser-side charts.
341
+ - [D3 getting started](https://d3js.org/getting-started): D3 documentation for loading and using the library.
342
+ - [Code Maat](https://github.com/adamtornhill/code-maat): Adam Tornhill's version-control mining tool used for revisions, coupling, age, and ownership metrics.
343
+ - [Code Maat analyses API index](https://cljdoc.org/d/code-maat/code-maat/1.0.1/api/code-maat.analysis): reference list for Code Maat analyses.
344
+ - [Code Maat distribution notes](https://adamtornhill.com/code/maatdistro.htm): upstream distribution page for standalone Code Maat usage.
345
+ - [Adam Tornhill](https://www.adamtornhill.com): creator of Code Maat and author of the behavioral-code-analysis framing used here.
346
+ - [Your Code as a Crime Scene](https://pragprog.com/titles/atcrime/your-code-as-a-crime-scene/): Adam Tornhill's book on hotspots, temporal coupling, code age, and social code analysis.
347
+ - [Maat D3 scripts](https://github.com/adamtornhill/maat-scripts): Adam Tornhill's D3 visualization scripts for Code Maat data, including the canonical enclosure diagram lineage.
348
+ - [Lizard](https://github.com/terryyin/lizard): complexity analyzer used here to add per-file cyclomatic complexity.
349
+ - [Code Maat GPLv3 license](https://github.com/adamtornhill/code-maat): Code Maat is GPLv3. This template does not vendor or redistribute Code Maat. It downloads the upstream standalone JAR at runtime on first run. If you choose to distribute the JAR yourself, follow GPLv3 distribution obligations, including source and license notice requirements.
350
+
351
+ ## Licensing and Attribution Notes
352
+
353
+ This template invokes Code Maat as a separate command-line program and consumes its CSV outputs. Running a GPLv3 tool is unrestricted, and the generated metrics are not a derivative work of the tool. The important guardrail is distribution: do not vendor the Code Maat JAR into your own image, repo, or product bundle unless you are prepared to satisfy GPLv3 distribution terms. The template keeps Code Maat as a runtime-downloaded dependency.
354
+
355
+ D3.js and Lizard remain their own upstream projects with their own licenses. Keep their attribution links in any public version of this playbook.
@@ -0,0 +1,38 @@
1
+ # Code Health Reports for Your Codebase, on Autopilot
2
+
3
+ Community template for running recurring Code Maat + D3.js code-health reports from an agent-swarm instance.
4
+
5
+ Files:
6
+
7
+ - `PLAYBOOK.md`: end-to-end setup and weekly schedule playbook.
8
+ - `run.sh`: parameterized runner for any Git repository.
9
+ - `report.mjs`: static HTML + JSON report generator.
10
+ - `lead-prompt.md`: copy-paste prompt for your agent-swarm Lead.
11
+
12
+ Quick start:
13
+
14
+ ```bash
15
+ mkdir -p /workspace/code-maat
16
+ cp run.sh report.mjs lead-prompt.md /workspace/code-maat/
17
+ chmod +x /workspace/code-maat/run.sh
18
+
19
+ BASE_DIR=/workspace/code-maat \
20
+ REPO_NAME=my-repo \
21
+ REPO_URL=https://github.com/OWNER/REPO.git \
22
+ BRANCH=main \
23
+ SCOPE_PATH=src \
24
+ bash /workspace/code-maat/run.sh
25
+ ```
26
+
27
+ Default weekly schedule cadence:
28
+
29
+ ```yaml
30
+ cron: "0 21 * * 0"
31
+ timezone: "UTC"
32
+ ```
33
+
34
+ Change the `cron` field to adjust when the report refreshes. Keep the same page ID when publishing refreshes so the report URL remains stable.
35
+
36
+ Code Maat is GPLv3. This template does not vendor or redistribute Code Maat. It downloads the upstream standalone JAR at runtime on first run.
37
+
38
+ See `PLAYBOOK.md` for the full setup flow, references, and licensing notes.
@@ -0,0 +1,52 @@
1
+ # Lead Kickoff Prompt
2
+
3
+ Copy this into your agent-swarm Lead to bootstrap the recurring report.
4
+
5
+ ```text
6
+ Bootstrap a recurring Code Maat + D3 code-health report for my repository.
7
+
8
+ Parameters:
9
+ - Repository URL: <REPO_URL>
10
+ - Default branch: <BRANCH>
11
+ - Path scope to analyze: <SCOPE_PATH, e.g. src>
12
+ - Report name/slug: <REPORT_NAME>
13
+ - Cadence: weekly by default, cron "0 21 * * 0" in <TIMEZONE>
14
+ - Stable page behavior: create the page once, then update the same page ID in place on every run.
15
+
16
+ Requirements:
17
+ 1. Work outside the target repository under /workspace/code-maat.
18
+ 2. Install the community template files there:
19
+ - run.sh
20
+ - report.mjs
21
+ - lead-prompt.md
22
+ 3. On first run, install/download missing runtime dependencies:
23
+ - Java runtime for the Code Maat standalone JAR.
24
+ - Code Maat v1.0.4 standalone JAR from GitHub releases.
25
+ - Lizard via Python user install if it is not available.
26
+ - D3 v7 must be loaded from a CDN by the generated HTML; do not add a front-end build step.
27
+ 4. Clone the repository into /workspace/code-maat/repos/<REPORT_NAME>, disable its push URL, fetch the requested branch, and analyze only <SCOPE_PATH>.
28
+ 5. Generate the git log with:
29
+ git log --all --numstat --date=short --pretty=format:'--%h--%ad--%aN' --no-renames -- <SCOPE_PATH>
30
+ 6. Run Code Maat analyses:
31
+ summary, revisions, coupling, age, authors, entity-ownership, entity-effort, main-dev, main-dev-by-revs, abs-churn, author-churn, entity-churn.
32
+ 7. Run Lizard over <SCOPE_PATH> and save lizard-functions.csv.
33
+ 8. Generate a static D3 report with:
34
+ - Hotspot bubble chart.
35
+ - Change-frequency x complexity scatter.
36
+ - Temporal coupling table.
37
+ - Ownership columns in the hotspot table.
38
+ - Code age distribution.
39
+ - Static detail tables.
40
+ 9. Publish the first report as a swarm page and persist its stable page ID in the workflow configuration.
41
+ 10. Create a schedule pinned to a code-capable worker:
42
+ - Default cadence: weekly, cron "0 21 * * 0".
43
+ - To change the cadence, edit the cron field and timezone only.
44
+ - Each run executes run.sh, updates the same page ID in place, verifies the page renders, and self-repairs the runner/report if the failure is local and fixable.
45
+ 11. Do not push any PR unless I explicitly ask for a versioned repository change.
46
+
47
+ Deliver back:
48
+ - The stable page URL.
49
+ - The workspace paths for run.sh, report.mjs, latest.html, and latest.json.
50
+ - The schedule name, cron, timezone, and how to change them.
51
+ - Any prerequisites or assumptions you could not satisfy automatically.
52
+ ```