@mmerterden/multi-agent-pipeline 20.37.0 → 20.38.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 (469) hide show
  1. package/CHANGELOG.md +123 -49
  2. package/README.md +12 -10
  3. package/README.tr.md +12 -10
  4. package/docs/adr/0006-skills-core-external-split.md +5 -5
  5. package/docs/adr/0010-own-code-graph.md +6 -7
  6. package/docs/adr/0013-lsp-code-intelligence.md +6 -8
  7. package/docs/adr/0017-change-impact-from-the-graph.md +4 -5
  8. package/docs/adr/0018-cross-repo-links-not-a-global-graph.md +1 -1
  9. package/docs/adr/README.md +1 -1
  10. package/docs/ecosystem.md +53 -41
  11. package/docs/facts.json +15 -13
  12. package/docs/features.md +2 -2
  13. package/docs/recovery-guide.md +1 -1
  14. package/install/_dev-only-files.mjs +3 -0
  15. package/install/_platform-filter.mjs +1 -23
  16. package/install/catalog-history.json +1 -1
  17. package/install/claude.mjs +8 -1
  18. package/install/codex.mjs +0 -2
  19. package/install/copilot.mjs +0 -2
  20. package/install/templates/claude-hooks.json +47 -1
  21. package/manifest.json +455 -332
  22. package/package.json +5 -2
  23. package/pipeline/agents/security-auditor.md +58 -6
  24. package/pipeline/commands/multi-agent/build-optimize/SKILL.md +1 -2
  25. package/pipeline/commands/multi-agent/complaint-analysis/SKILL.md +1 -1
  26. package/pipeline/commands/multi-agent/design-check/SKILL.md +1 -1
  27. package/pipeline/commands/multi-agent/graph/SKILL.md +12 -3
  28. package/pipeline/commands/multi-agent/manual-test/SKILL.md +12 -7
  29. package/pipeline/commands/multi-agent/research/SKILL.md +2 -2
  30. package/pipeline/commands/multi-agent/search/SKILL.md +10 -1
  31. package/pipeline/commands/multi-agent/security-review/SKILL.md +4 -0
  32. package/pipeline/commands/multi-agent/setup/SKILL.md +1 -0
  33. package/pipeline/commands/multi-agent/stack/SKILL.md +8 -0
  34. package/pipeline/commands/multi-agent/store-ready/SKILL.md +1 -1
  35. package/pipeline/commands/sim-test.md +34 -1
  36. package/pipeline/lib/context-budget.mjs +103 -0
  37. package/pipeline/lib/credential-inventory.sh +2 -3
  38. package/pipeline/lib/identifier-scan.mjs +145 -0
  39. package/pipeline/lib/outbound-gate.mjs +28 -1
  40. package/pipeline/lib/unattended-profile-check.mjs +13 -4
  41. package/pipeline/multi-agent-refs/analysis/locked.md +1 -1
  42. package/pipeline/multi-agent-refs/analysis/redesign.md +17 -3
  43. package/pipeline/multi-agent-refs/analysis-template-corporate.md +8 -4
  44. package/pipeline/multi-agent-refs/analysis-template.md +7 -5
  45. package/pipeline/multi-agent-refs/audit-guide.md +20 -0
  46. package/pipeline/multi-agent-refs/complaint-analysis/phases.md +1 -0
  47. package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +1 -1
  48. package/pipeline/multi-agent-refs/features/code-graph.md +25 -0
  49. package/pipeline/multi-agent-refs/features/commit-multi-repo.md +63 -0
  50. package/pipeline/multi-agent-refs/features/design-conformance.md +20 -4
  51. package/pipeline/multi-agent-refs/features/dev-multi-repo.md +51 -0
  52. package/pipeline/multi-agent-refs/features/free-models.md +10 -3
  53. package/pipeline/multi-agent-refs/features/research.md +4 -3
  54. package/pipeline/multi-agent-refs/features/security-audit.md +25 -3
  55. package/pipeline/multi-agent-refs/features/test-gap.md +40 -0
  56. package/pipeline/multi-agent-refs/features/unattended-security.md +20 -0
  57. package/pipeline/multi-agent-refs/features/worktree-finalize.md +1 -1
  58. package/pipeline/multi-agent-refs/help/en.md +15 -9
  59. package/pipeline/multi-agent-refs/help/tr.md +15 -9
  60. package/pipeline/multi-agent-refs/knowledge.md +17 -0
  61. package/pipeline/multi-agent-refs/orchestrator/phase-3-user-test.md +12 -9
  62. package/pipeline/multi-agent-refs/outside-the-pipeline.md +9 -0
  63. package/pipeline/multi-agent-refs/phases/log-format.md +5 -0
  64. package/pipeline/multi-agent-refs/phases/operations.md +3 -5
  65. package/pipeline/multi-agent-refs/phases/phase-1-plan.md +4 -4
  66. package/pipeline/multi-agent-refs/phases/phase-2-dev.md +8 -47
  67. package/pipeline/multi-agent-refs/phases/phase-3-review.md +21 -65
  68. package/pipeline/multi-agent-refs/phases/phase-4-commit.md +9 -59
  69. package/pipeline/multi-agent-refs/phases/phase-5-report.md +0 -31
  70. package/pipeline/multi-agent-refs/picker-contract.md +1 -1
  71. package/pipeline/multi-agent-refs/research/engine.md +2 -1
  72. package/pipeline/multi-agent-refs/rules.md +1 -1
  73. package/pipeline/multi-agent-refs/setup/free-models.md +10 -0
  74. package/pipeline/multi-agent-refs/store-ready/gate-3-policy.md +15 -0
  75. package/pipeline/multi-agent-refs/web-guide.md +2 -1
  76. package/pipeline/office/index.html +8 -9
  77. package/pipeline/office/toolkit.json +1 -1
  78. package/pipeline/rules/figma-pipeline.md +6 -3
  79. package/pipeline/rules/outside-the-pipeline.md +1 -1
  80. package/pipeline/schemas/learnings-ledger.schema.json +7 -2
  81. package/pipeline/schemas/prefs.schema.json +17 -4
  82. package/pipeline/schemas/reviewer-output.schema.json +113 -5
  83. package/pipeline/schemas/secret-patterns.json +49 -0
  84. package/pipeline/schemas/security-finding.schema.json +49 -5
  85. package/pipeline/scripts/_code-graph.mjs +3 -3
  86. package/pipeline/scripts/_graph-analysis.mjs +51 -0
  87. package/pipeline/scripts/_memory-policy.mjs +37 -7
  88. package/pipeline/scripts/_secret-scan.mjs +1 -1
  89. package/pipeline/scripts/_skill-practices.mjs +178 -0
  90. package/pipeline/scripts/_stack-routing.mjs +1 -0
  91. package/pipeline/scripts/autopilot-runner.mjs +8 -3
  92. package/pipeline/scripts/build-stack-plugins.mjs +8 -44
  93. package/pipeline/scripts/capture-resume.sh +19 -0
  94. package/pipeline/scripts/checkpoint-fold.sh +59 -0
  95. package/pipeline/scripts/file-context.mjs +306 -70
  96. package/pipeline/scripts/gate-ledger.mjs +1 -1
  97. package/pipeline/scripts/gen-skills-index.mjs +1 -1
  98. package/pipeline/scripts/graph-hint.mjs +197 -0
  99. package/pipeline/scripts/graph-hint.sh +20 -0
  100. package/pipeline/scripts/graph-query.mjs +306 -11
  101. package/pipeline/scripts/graph-report.mjs +29 -1
  102. package/pipeline/scripts/learnings-ledger.mjs +71 -15
  103. package/pipeline/scripts/note-agent-event.mjs +160 -0
  104. package/pipeline/scripts/note-agent-event.sh +19 -0
  105. package/pipeline/scripts/office-control.mjs +41 -15
  106. package/pipeline/scripts/offload-ref.sh +1 -1
  107. package/pipeline/scripts/parity-score.mjs +139 -0
  108. package/pipeline/scripts/pre-commit-check.sh +25 -4
  109. package/pipeline/scripts/pre-push-check.sh +3 -0
  110. package/pipeline/scripts/repo-recommend.mjs +321 -0
  111. package/pipeline/scripts/rework-rulings.mjs +5 -3
  112. package/pipeline/scripts/scan-agent-config.sh +1 -2
  113. package/pipeline/scripts/scope-check-gate.mjs +15 -2
  114. package/pipeline/scripts/security-evidence-gate.mjs +282 -0
  115. package/pipeline/scripts/unattended_policy.py +3 -2
  116. package/pipeline/scripts/user-test-handoff.sh +203 -0
  117. package/pipeline/scripts/validate-analysis-doc.mjs +17 -1
  118. package/pipeline/scripts/validate-planning.mjs +5 -3
  119. package/pipeline/scripts/validate-triage.mjs +2 -1
  120. package/pipeline/scripts/write-state.mjs +13 -4
  121. package/pipeline/skills/.skill-manifest.json +73 -69
  122. package/pipeline/skills/shared/README.md +41 -40
  123. package/pipeline/skills/shared/core/apple-archive-compliance/SKILL.md +6 -6
  124. package/pipeline/skills/shared/core/apple-archive-compliance/references/examples.md +1 -1
  125. package/pipeline/skills/shared/core/apple-archive-compliance/references/version-history.md +1 -1
  126. package/pipeline/skills/shared/core/google-play-compliance/SKILL.md +1 -1
  127. package/pipeline/skills/shared/core/google-play-compliance/references/notes.md +1 -1
  128. package/pipeline/skills/shared/core/multi-agent/SKILL.md +1 -1
  129. package/pipeline/skills/shared/core/multi-agent-build-optimize/SKILL.md +0 -1
  130. package/pipeline/skills/shared/core/multi-agent-complaint-analysis/SKILL.md +1 -1
  131. package/pipeline/skills/shared/core/multi-agent-design-check/SKILL.md +5 -5
  132. package/pipeline/skills/shared/core/multi-agent-graph/SKILL.md +10 -0
  133. package/pipeline/skills/shared/core/multi-agent-manual-test/SKILL.md +12 -7
  134. package/pipeline/skills/shared/core/multi-agent-research/SKILL.md +2 -2
  135. package/pipeline/skills/shared/core/multi-agent-search/SKILL.md +9 -0
  136. package/pipeline/skills/shared/core/multi-agent-security-review/SKILL.md +3 -2
  137. package/pipeline/skills/shared/core/multi-agent-setup/SKILL.md +1 -0
  138. package/pipeline/skills/shared/core/multi-agent-stack/SKILL.md +8 -0
  139. package/pipeline/skills/shared/core/multi-agent-store-ready/SKILL.md +4 -3
  140. package/pipeline/skills/shared/core/multi-agent-test/SKILL.md +1 -1
  141. package/pipeline/skills/shared/core/multi-agent-test-accessibility/SKILL.md +1 -1
  142. package/pipeline/skills/shared/core/multi-agent-test-dark-mode/SKILL.md +1 -1
  143. package/pipeline/skills/shared/core/multi-agent-test-dynamic-type/SKILL.md +1 -1
  144. package/pipeline/skills/shared/core/multi-agent-test-gen/SKILL.md +1 -1
  145. package/pipeline/skills/shared/core/multi-agent-test-screenshots/SKILL.md +1 -1
  146. package/pipeline/skills/shared/core/multi-agent-testflight-validation/SKILL.md +2 -2
  147. package/pipeline/skills/shared/external/accessibility-compliance-accessibility-audit/evals/evals.json +44 -0
  148. package/pipeline/skills/shared/external/agent-introspection-debugging/evals/evals.json +42 -0
  149. package/pipeline/skills/shared/external/android-architecture/SKILL.md +1 -1
  150. package/pipeline/skills/shared/external/android-architecture/evals/evals.json +45 -0
  151. package/pipeline/skills/shared/external/android-build-quality-gates/evals/evals.json +45 -0
  152. package/pipeline/skills/shared/external/android-datastore/evals/evals.json +45 -0
  153. package/pipeline/skills/shared/external/android-design-tokens-codegen/evals/evals.json +43 -0
  154. package/pipeline/skills/shared/external/android-jetpack-compose-expert/evals/evals.json +43 -0
  155. package/pipeline/skills/shared/external/android-mvi-viewmodel/evals/evals.json +45 -0
  156. package/pipeline/skills/shared/external/android-performance/SKILL.md +1 -1
  157. package/pipeline/skills/shared/external/android-performance/evals/evals.json +44 -0
  158. package/pipeline/skills/shared/external/android-security/SKILL.md +1 -1
  159. package/pipeline/skills/shared/external/android-security/evals/evals.json +45 -0
  160. package/pipeline/skills/shared/external/api-patterns/evals/evals.json +43 -0
  161. package/pipeline/skills/shared/external/api-security-best-practices/evals/evals.json +44 -0
  162. package/pipeline/skills/shared/external/app-store-changelog/SKILL.md +65 -49
  163. package/pipeline/skills/shared/external/app-store-changelog/evals/evals.json +40 -0
  164. package/pipeline/skills/shared/external/app-store-changelog/references/release-notes-guidelines.md +64 -34
  165. package/pipeline/skills/shared/external/app-store-changelog/scripts/collect_release_changes.sh +21 -23
  166. package/pipeline/skills/shared/external/app-store-optimization/SKILL.md +4 -1
  167. package/pipeline/skills/shared/external/app-store-review/SKILL.md +6 -0
  168. package/pipeline/skills/shared/external/architecture/evals/evals.json +42 -0
  169. package/pipeline/skills/shared/external/backlog/evals/evals.json +42 -0
  170. package/pipeline/skills/shared/external/ci-cd-pipelines/evals/evals.json +44 -0
  171. package/pipeline/skills/shared/external/clean-code/evals/evals.json +45 -0
  172. package/pipeline/skills/shared/external/compose-components/SKILL.md +1 -1
  173. package/pipeline/skills/shared/external/compose-components/evals/evals.json +44 -0
  174. package/pipeline/skills/shared/external/compose-navigation/SKILL.md +1 -1
  175. package/pipeline/skills/shared/external/compose-navigation/evals/evals.json +43 -0
  176. package/pipeline/skills/shared/external/compose-testing/SKILL.md +1 -1
  177. package/pipeline/skills/shared/external/compose-testing/evals/evals.json +44 -0
  178. package/pipeline/skills/shared/external/context-compression/evals/evals.json +43 -0
  179. package/pipeline/skills/shared/external/core-data/SKILL.md +1 -1
  180. package/pipeline/skills/shared/external/council/evals/evals.json +41 -0
  181. package/pipeline/skills/shared/external/css-modern/evals/evals.json +44 -0
  182. package/pipeline/skills/shared/external/css-modern/references/code-examples.md +5 -0
  183. package/pipeline/skills/shared/external/database-patterns/evals/evals.json +46 -0
  184. package/pipeline/skills/shared/external/database-patterns/references/orm-examples.md +5 -0
  185. package/pipeline/skills/shared/external/debugging-strategies/evals/evals.json +43 -0
  186. package/pipeline/skills/shared/external/docker-expert/evals/evals.json +45 -0
  187. package/pipeline/skills/shared/external/e2e-testing/SKILL.md +21 -21
  188. package/pipeline/skills/shared/external/e2e-testing/evals/evals.json +44 -0
  189. package/pipeline/skills/shared/external/e2e-testing/references/document-fixtures.md +5 -5
  190. package/pipeline/skills/shared/external/evidence-github/evals/evals.json +41 -0
  191. package/pipeline/skills/shared/external/evidence-registry/SKILL.md +1 -1
  192. package/pipeline/skills/shared/external/evidence-registry/evals/evals.json +41 -0
  193. package/pipeline/skills/shared/external/fastapi-pro/evals/evals.json +57 -0
  194. package/pipeline/skills/shared/external/firebase/SKILL.md +132 -54
  195. package/pipeline/skills/shared/external/firebase/evals/evals.json +42 -0
  196. package/pipeline/skills/shared/external/firebase/references/functions-and-products.md +51 -0
  197. package/pipeline/skills/shared/external/firebase/references/security-rules.md +59 -0
  198. package/pipeline/skills/shared/external/fix-review-verdicts/evals/evals.json +57 -0
  199. package/pipeline/skills/shared/external/free-llm-apis/SKILL.md +70 -0
  200. package/pipeline/skills/shared/external/free-llm-apis/evals/evals.json +44 -0
  201. package/pipeline/skills/shared/external/free-llm-apis/references/providers.md +33 -0
  202. package/pipeline/skills/shared/external/github-actions-templates/evals/evals.json +44 -0
  203. package/pipeline/skills/shared/external/gradle-kotlin-dsl/SKILL.md +1 -1
  204. package/pipeline/skills/shared/external/gradle-kotlin-dsl/evals/evals.json +58 -0
  205. package/pipeline/skills/shared/external/handle-request/SKILL.md +2 -2
  206. package/pipeline/skills/shared/external/handle-request/evals/evals.json +44 -0
  207. package/pipeline/skills/shared/external/hig-app-icons/SKILL.md +2 -2
  208. package/pipeline/skills/shared/external/hig-app-icons/references/icon-workflow.md +1 -1
  209. package/pipeline/skills/shared/external/hig-components-content/evals/evals.json +43 -0
  210. package/pipeline/skills/shared/external/hig-components-status/evals/evals.json +43 -0
  211. package/pipeline/skills/shared/external/hig-components-system/evals/evals.json +43 -0
  212. package/pipeline/skills/shared/external/hig-inputs/evals/evals.json +44 -0
  213. package/pipeline/skills/shared/external/hig-patterns/evals/evals.json +46 -0
  214. package/pipeline/skills/shared/external/hig-platforms/evals/evals.json +45 -0
  215. package/pipeline/skills/shared/external/hig-technologies/evals/evals.json +44 -0
  216. package/pipeline/skills/shared/external/html-semantic/evals/evals.json +46 -0
  217. package/pipeline/skills/shared/external/humanizer/evals/evals.json +46 -0
  218. package/pipeline/skills/shared/external/ios-coding-standard/evals/evals.json +44 -0
  219. package/pipeline/skills/shared/external/ios-debugger-agent/SKILL.md +91 -52
  220. package/pipeline/skills/shared/external/ios-debugger-agent/evals/evals.json +41 -0
  221. package/pipeline/skills/shared/external/ios-design-review/SKILL.md +12 -12
  222. package/pipeline/skills/shared/external/ios-design-review/references/appearance-matrix.md +16 -16
  223. package/pipeline/skills/shared/external/ios-design-review/references/checklist.md +1 -1
  224. package/pipeline/skills/shared/external/ios-iphone-duo/SKILL.md +0 -1
  225. package/pipeline/skills/shared/external/ios-module-structure/evals/evals.json +42 -0
  226. package/pipeline/skills/shared/external/ios-security/SKILL.md +1 -1
  227. package/pipeline/skills/shared/external/ios-security/evals/evals.json +45 -0
  228. package/pipeline/skills/shared/external/kotlin-coroutines-expert/evals/evals.json +43 -0
  229. package/pipeline/skills/shared/external/localization-reuse-map/evals/evals.json +45 -0
  230. package/pipeline/skills/shared/external/macos-menubar-tuist-app/SKILL.md +170 -74
  231. package/pipeline/skills/shared/external/macos-menubar-tuist-app/evals/evals.json +52 -0
  232. package/pipeline/skills/shared/external/macos-spm-app-packaging/SKILL.md +119 -77
  233. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Package.swift +5 -5
  234. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/MyApp.swift +24 -0
  235. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/version.env +2 -0
  236. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/build_icon.sh +46 -39
  237. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/compile_and_run.sh +70 -49
  238. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/launch.sh +24 -17
  239. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/make_appcast.sh +74 -59
  240. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/package_app.sh +201 -170
  241. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/setup_dev_signing.sh +50 -42
  242. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/sign-and-notarize.sh +65 -35
  243. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/version.env +2 -0
  244. package/pipeline/skills/shared/external/macos-spm-app-packaging/evals/evals.json +45 -0
  245. package/pipeline/skills/shared/external/macos-spm-app-packaging/references/packaging.md +49 -17
  246. package/pipeline/skills/shared/external/macos-spm-app-packaging/references/release.md +48 -23
  247. package/pipeline/skills/shared/external/macos-spm-app-packaging/references/scaffold.md +74 -44
  248. package/pipeline/skills/shared/external/monorepo-architect/evals/evals.json +45 -0
  249. package/pipeline/skills/shared/external/nextjs-app-router/SKILL.md +14 -3
  250. package/pipeline/skills/shared/external/nextjs-app-router/evals/evals.json +43 -0
  251. package/pipeline/skills/shared/external/nextjs-app-router/references/app-router-examples.md +3 -0
  252. package/pipeline/skills/shared/external/nodejs-backend-patterns/evals/evals.json +45 -0
  253. package/pipeline/skills/shared/external/observability-engineer/evals/evals.json +45 -0
  254. package/pipeline/skills/shared/external/passkit-wallet/SKILL.md +10 -0
  255. package/pipeline/skills/shared/external/photos-camera-media/evals/evals.json +45 -0
  256. package/pipeline/skills/shared/external/play-store-review/evals/evals.json +45 -0
  257. package/pipeline/skills/shared/external/python-patterns/evals/evals.json +46 -0
  258. package/pipeline/skills/shared/external/react-best-practices/evals/evals.json +43 -0
  259. package/pipeline/skills/shared/external/rest-api-design/evals/evals.json +46 -0
  260. package/pipeline/skills/shared/external/retrofit-networking/SKILL.md +1 -1
  261. package/pipeline/skills/shared/external/retrofit-networking/evals/evals.json +43 -0
  262. package/pipeline/skills/shared/external/room-database/SKILL.md +1 -1
  263. package/pipeline/skills/shared/external/room-database/evals/evals.json +43 -0
  264. package/pipeline/skills/shared/external/scenario-gap-analysis/SKILL.md +1 -1
  265. package/pipeline/skills/shared/external/scenario-gap-analysis/evals/evals.json +43 -0
  266. package/pipeline/skills/shared/external/search-first/evals/evals.json +42 -0
  267. package/pipeline/skills/shared/external/security-review/SKILL.md +14 -3
  268. package/pipeline/skills/shared/external/security-review/evals/evals.json +48 -0
  269. package/pipeline/skills/shared/external/security-review/references/agentic-systems.md +93 -0
  270. package/pipeline/skills/shared/external/security-review/references/firebase-rules.md +100 -0
  271. package/pipeline/skills/shared/external/security-review/references/graphql.md +82 -0
  272. package/pipeline/skills/shared/external/security-review/references/llm-prompt-injection.md +93 -0
  273. package/pipeline/skills/shared/external/security-review/references/oauth-oidc.md +100 -0
  274. package/pipeline/skills/shared/external/security-review/references/owasp-mobile-top10-2024.md +1 -1
  275. package/pipeline/skills/shared/external/security-review/references/owasp-web-api-top10-2021.md +1 -1
  276. package/pipeline/skills/shared/external/security-review/references/supabase.md +73 -0
  277. package/pipeline/skills/shared/external/signal-community/SKILL.md +29 -10
  278. package/pipeline/skills/shared/external/signal-community/evals/evals.json +42 -0
  279. package/pipeline/skills/shared/external/skill-creator/evals/evals.json +43 -0
  280. package/pipeline/skills/shared/external/skill-creator/template.md +1 -3
  281. package/pipeline/skills/shared/external/spm-build-analysis/SKILL.md +80 -61
  282. package/pipeline/skills/shared/external/spm-build-analysis/evals/evals.json +56 -0
  283. package/pipeline/skills/shared/external/spm-build-analysis/references/build-optimization-sources.md +83 -133
  284. package/pipeline/skills/shared/external/spm-build-analysis/references/recommendation-format.md +41 -40
  285. package/pipeline/skills/shared/external/spm-build-analysis/references/spm-analysis-checks.md +89 -87
  286. package/pipeline/skills/shared/external/spm-build-analysis/scripts/check_spm_pins.py +90 -85
  287. package/pipeline/skills/shared/external/swift-concurrency-expert/SKILL.md +78 -69
  288. package/pipeline/skills/shared/external/swift-concurrency-expert/evals/evals.json +54 -0
  289. package/pipeline/skills/shared/external/swift-concurrency-expert/references/approachable-concurrency.md +52 -48
  290. package/pipeline/skills/shared/external/swift-concurrency-expert/references/swift-6-2-concurrency.md +118 -184
  291. package/pipeline/skills/shared/external/swift-concurrency-expert/references/swiftui-concurrency-tour-wwdc.md +68 -22
  292. package/pipeline/skills/shared/external/swift-concurrency-pro/SKILL.md +117 -94
  293. package/pipeline/skills/shared/external/swift-concurrency-pro/evals/evals.json +57 -0
  294. package/pipeline/skills/shared/external/swift-concurrency-pro/references/actors.md +102 -97
  295. package/pipeline/skills/shared/external/swift-concurrency-pro/references/async-streams.md +36 -37
  296. package/pipeline/skills/shared/external/swift-concurrency-pro/references/bridging.md +82 -34
  297. package/pipeline/skills/shared/external/swift-concurrency-pro/references/bug-patterns.md +90 -52
  298. package/pipeline/skills/shared/external/swift-concurrency-pro/references/cancellation.md +55 -55
  299. package/pipeline/skills/shared/external/swift-concurrency-pro/references/diagnostics.md +66 -43
  300. package/pipeline/skills/shared/external/swift-concurrency-pro/references/hotspots.md +39 -23
  301. package/pipeline/skills/shared/external/swift-concurrency-pro/references/interop.md +66 -68
  302. package/pipeline/skills/shared/external/swift-concurrency-pro/references/new-features.md +152 -131
  303. package/pipeline/skills/shared/external/swift-concurrency-pro/references/structured.md +60 -57
  304. package/pipeline/skills/shared/external/swift-concurrency-pro/references/testing.md +131 -118
  305. package/pipeline/skills/shared/external/swift-concurrency-pro/references/unstructured.md +37 -29
  306. package/pipeline/skills/shared/external/swift-formatstyle/evals/evals.json +43 -0
  307. package/pipeline/skills/shared/external/swift-testing-pro/SKILL.md +77 -58
  308. package/pipeline/skills/shared/external/swift-testing-pro/evals/evals.json +59 -0
  309. package/pipeline/skills/shared/external/swift-testing-pro/references/async-tests.md +139 -144
  310. package/pipeline/skills/shared/external/swift-testing-pro/references/core-rules.md +90 -28
  311. package/pipeline/skills/shared/external/swift-testing-pro/references/migrating-from-xctest.md +38 -21
  312. package/pipeline/skills/shared/external/swift-testing-pro/references/new-features.md +139 -156
  313. package/pipeline/skills/shared/external/swift-testing-pro/references/writing-better-tests.md +173 -147
  314. package/pipeline/skills/shared/external/swiftdata-pro/SKILL.md +75 -59
  315. package/pipeline/skills/shared/external/swiftdata-pro/evals/evals.json +50 -0
  316. package/pipeline/skills/shared/external/swiftdata-pro/references/cloudkit.md +34 -7
  317. package/pipeline/skills/shared/external/swiftdata-pro/references/indexing.md +20 -14
  318. package/pipeline/skills/shared/external/swiftdata-pro/references/inheritance.md +127 -0
  319. package/pipeline/skills/shared/external/swiftdata-pro/references/model-rules.md +141 -0
  320. package/pipeline/skills/shared/external/swiftdata-pro/references/predicates.md +37 -44
  321. package/pipeline/skills/shared/external/swiftlint/evals/evals.json +44 -0
  322. package/pipeline/skills/shared/external/swiftui-expert-skill/SKILL.md +89 -88
  323. package/pipeline/skills/shared/external/swiftui-expert-skill/evals/evals.json +55 -0
  324. package/pipeline/skills/shared/external/swiftui-expert-skill/references/accessibility-patterns.md +104 -122
  325. package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-advanced.md +73 -93
  326. package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-basics.md +144 -169
  327. package/pipeline/skills/shared/external/swiftui-expert-skill/references/animation-transitions.md +122 -133
  328. package/pipeline/skills/shared/external/swiftui-expert-skill/references/charts-accessibility.md +141 -99
  329. package/pipeline/skills/shared/external/swiftui-expert-skill/references/charts.md +273 -333
  330. package/pipeline/skills/shared/external/swiftui-expert-skill/references/image-optimization.md +105 -128
  331. package/pipeline/skills/shared/external/swiftui-expert-skill/references/latest-apis.md +199 -312
  332. package/pipeline/skills/shared/external/swiftui-expert-skill/references/layout-best-practices.md +129 -169
  333. package/pipeline/skills/shared/external/swiftui-expert-skill/references/liquid-glass.md +17 -30
  334. package/pipeline/skills/shared/external/swiftui-expert-skill/references/list-patterns.md +198 -258
  335. package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-scenes.md +145 -218
  336. package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-views.md +150 -249
  337. package/pipeline/skills/shared/external/swiftui-expert-skill/references/macos-window-styling.md +109 -208
  338. package/pipeline/skills/shared/external/swiftui-expert-skill/references/performance-patterns.md +225 -271
  339. package/pipeline/skills/shared/external/swiftui-expert-skill/references/scroll-patterns.md +117 -210
  340. package/pipeline/skills/shared/external/swiftui-expert-skill/references/sheet-navigation-patterns.md +171 -237
  341. package/pipeline/skills/shared/external/swiftui-expert-skill/references/state-management.md +196 -260
  342. package/pipeline/skills/shared/external/swiftui-expert-skill/references/view-structure.md +167 -230
  343. package/pipeline/skills/shared/external/swiftui-gestures/evals/evals.json +43 -0
  344. package/pipeline/skills/shared/external/swiftui-layout-components/evals/evals.json +43 -0
  345. package/pipeline/skills/shared/external/swiftui-navigation/evals/evals.json +44 -0
  346. package/pipeline/skills/shared/external/swiftui-navigation/references/navigationstack.md +1 -2
  347. package/pipeline/skills/shared/external/swiftui-patterns/evals/evals.json +43 -0
  348. package/pipeline/skills/shared/external/swiftui-performance/evals/evals.json +44 -0
  349. package/pipeline/skills/shared/external/swiftui-performance-audit/SKILL.md +71 -79
  350. package/pipeline/skills/shared/external/swiftui-performance-audit/evals/evals.json +55 -0
  351. package/pipeline/skills/shared/external/swiftui-performance-audit/references/audit-layout.md +50 -0
  352. package/pipeline/skills/shared/external/swiftui-performance-audit/references/capture-checklist.md +51 -0
  353. package/pipeline/skills/shared/external/swiftui-performance-audit/references/hangs.md +34 -0
  354. package/pipeline/skills/shared/external/swiftui-performance-audit/references/instruments-guide.md +68 -0
  355. package/pipeline/skills/shared/external/swiftui-performance-audit/references/smell-catalog.md +191 -0
  356. package/pipeline/skills/shared/external/swiftui-performance-audit/references/update-model.md +69 -0
  357. package/pipeline/skills/shared/external/swiftui-pro/SKILL.md +65 -63
  358. package/pipeline/skills/shared/external/swiftui-pro/evals/evals.json +45 -0
  359. package/pipeline/skills/shared/external/swiftui-pro/references/accessibility.md +40 -13
  360. package/pipeline/skills/shared/external/swiftui-pro/references/api.md +74 -29
  361. package/pipeline/skills/shared/external/swiftui-pro/references/data.md +44 -24
  362. package/pipeline/skills/shared/external/swiftui-pro/references/design.md +45 -31
  363. package/pipeline/skills/shared/external/swiftui-pro/references/hygiene.md +17 -8
  364. package/pipeline/skills/shared/external/swiftui-pro/references/navigation.md +19 -9
  365. package/pipeline/skills/shared/external/swiftui-pro/references/performance.md +50 -34
  366. package/pipeline/skills/shared/external/swiftui-pro/references/swift.md +73 -45
  367. package/pipeline/skills/shared/external/swiftui-pro/references/views.md +48 -23
  368. package/pipeline/skills/shared/external/swiftui-ui-patterns/SKILL.md +89 -83
  369. package/pipeline/skills/shared/external/swiftui-ui-patterns/evals/evals.json +44 -0
  370. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/app-wiring.md +119 -114
  371. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/async-state.md +76 -61
  372. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/components-index.md +63 -46
  373. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/controls.md +32 -31
  374. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/deeplinks.md +49 -38
  375. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/focus.md +77 -49
  376. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/form.md +61 -44
  377. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/grids.md +40 -42
  378. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/input-toolbar.md +44 -31
  379. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/lightweight-clients.md +90 -64
  380. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/list.md +48 -49
  381. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/loading-placeholders.md +36 -25
  382. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/macos-settings.md +30 -30
  383. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/matched-transitions.md +49 -32
  384. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/media.md +49 -41
  385. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/menu-bar.md +52 -48
  386. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/navigationstack.md +119 -104
  387. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/overlay.md +30 -27
  388. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/performance.md +33 -31
  389. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/previews.md +27 -27
  390. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/scroll-reveal.md +79 -86
  391. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/scrollview.md +47 -40
  392. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/searchable.md +55 -40
  393. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/sheets.md +113 -84
  394. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/split-views.md +37 -34
  395. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/tabview.md +75 -75
  396. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/theming.md +37 -32
  397. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/title-menus.md +41 -51
  398. package/pipeline/skills/shared/external/swiftui-ui-patterns/references/top-bar.md +46 -30
  399. package/pipeline/skills/shared/external/swiftui-uikit-interop/evals/evals.json +44 -0
  400. package/pipeline/skills/shared/external/swiftui-view-refactor/SKILL.md +152 -121
  401. package/pipeline/skills/shared/external/swiftui-view-refactor/evals/evals.json +56 -0
  402. package/pipeline/skills/shared/external/swiftui-view-refactor/references/mv-patterns.md +107 -98
  403. package/pipeline/skills/shared/external/swiftui-webkit/evals/evals.json +44 -0
  404. package/pipeline/skills/shared/external/tailwind-css/evals/evals.json +43 -0
  405. package/pipeline/skills/shared/external/test-result-triage/SKILL.md +2 -2
  406. package/pipeline/skills/shared/external/test-result-triage/evals/evals.json +44 -0
  407. package/pipeline/skills/shared/external/testing-backend/evals/evals.json +42 -0
  408. package/pipeline/skills/shared/external/tipkit/evals/evals.json +44 -0
  409. package/pipeline/skills/shared/external/typescript-patterns/evals/evals.json +42 -0
  410. package/pipeline/skills/shared/external/valven-rules/evals/evals.json +44 -0
  411. package/pipeline/skills/shared/external/vision-framework/evals/evals.json +44 -0
  412. package/pipeline/skills/shared/external/vue-composition/evals/evals.json +42 -0
  413. package/pipeline/skills/shared/external/weatherkit/evals/evals.json +42 -0
  414. package/pipeline/skills/shared/external/web-accessibility/evals/evals.json +43 -0
  415. package/pipeline/skills/shared/external/web-performance/evals/evals.json +44 -0
  416. package/pipeline/skills/shared/external/web-testing/SKILL.md +2 -2
  417. package/pipeline/skills/shared/external/web-testing/evals/evals.json +43 -0
  418. package/pipeline/skills/shared/external/web-testing/references/testing-examples.md +2 -2
  419. package/pipeline/skills/shared/external/widgetkit/evals/evals.json +44 -0
  420. package/pipeline/skills/shared/external/xcode-build-benchmark/SKILL.md +61 -55
  421. package/pipeline/skills/shared/external/xcode-build-benchmark/evals/evals.json +42 -0
  422. package/pipeline/skills/shared/external/xcode-build-benchmark/references/benchmark-artifacts.md +69 -67
  423. package/pipeline/skills/shared/external/xcode-build-benchmark/references/benchmarking-workflow.md +39 -47
  424. package/pipeline/skills/shared/external/xcode-build-benchmark/schemas/build-benchmark.schema.json +72 -154
  425. package/pipeline/skills/shared/external/xcode-build-benchmark/scripts/benchmark_builds.py +207 -245
  426. package/pipeline/skills/shared/external/xcode-build-fixer/SKILL.md +145 -139
  427. package/pipeline/skills/shared/external/xcode-build-fixer/evals/evals.json +54 -0
  428. package/pipeline/skills/shared/external/xcode-build-fixer/references/build-settings-best-practices.md +81 -175
  429. package/pipeline/skills/shared/external/xcode-build-fixer/references/fix-patterns.md +188 -143
  430. package/pipeline/skills/shared/external/xcode-build-fixer/references/recommendation-format.md +41 -40
  431. package/pipeline/skills/shared/external/xcode-build-fixer/scripts/benchmark_builds.py +207 -245
  432. package/pipeline/skills/shared/external/xcode-build-orchestrator/SKILL.md +107 -98
  433. package/pipeline/skills/shared/external/xcode-build-orchestrator/evals/evals.json +54 -0
  434. package/pipeline/skills/shared/external/xcode-build-orchestrator/references/benchmark-artifacts.md +69 -67
  435. package/pipeline/skills/shared/external/xcode-build-orchestrator/references/build-settings-best-practices.md +81 -175
  436. package/pipeline/skills/shared/external/xcode-build-orchestrator/references/orchestration-report-template.md +81 -69
  437. package/pipeline/skills/shared/external/xcode-build-orchestrator/references/recommendation-format.md +41 -40
  438. package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/benchmark_builds.py +207 -245
  439. package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/diagnose_compilation.py +155 -210
  440. package/pipeline/skills/shared/external/xcode-build-orchestrator/scripts/generate_optimization_report.py +355 -480
  441. package/pipeline/skills/shared/external/xcode-compilation-analyzer/SKILL.md +70 -69
  442. package/pipeline/skills/shared/external/xcode-compilation-analyzer/evals/evals.json +54 -0
  443. package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/build-optimization-sources.md +83 -133
  444. package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/code-compilation-checks.md +85 -73
  445. package/pipeline/skills/shared/external/xcode-compilation-analyzer/references/recommendation-format.md +41 -40
  446. package/pipeline/skills/shared/external/xcode-compilation-analyzer/scripts/diagnose_compilation.py +155 -210
  447. package/pipeline/skills/shared/external/xcode-project-analyzer/SKILL.md +54 -52
  448. package/pipeline/skills/shared/external/xcode-project-analyzer/evals/evals.json +54 -0
  449. package/pipeline/skills/shared/external/xcode-project-analyzer/references/build-optimization-sources.md +83 -133
  450. package/pipeline/skills/shared/external/xcode-project-analyzer/references/build-settings-best-practices.md +81 -175
  451. package/pipeline/skills/shared/external/xcode-project-analyzer/references/project-audit-checks.md +115 -83
  452. package/pipeline/skills/shared/external/xcode-project-analyzer/references/recommendation-format.md +41 -40
  453. package/pipeline/scripts/_notices.mjs +0 -171
  454. package/pipeline/skills/shared/external/NOTICE-avdlee-swiftui-agent-skill.md +0 -48
  455. package/pipeline/skills/shared/external/NOTICE-dimillian-skills.md +0 -63
  456. package/pipeline/skills/shared/external/NOTICE-paul-hudson-skills.md +0 -54
  457. package/pipeline/skills/shared/external/NOTICE-vibeship-spawner-skills.md +0 -203
  458. package/pipeline/skills/shared/external/NOTICE-xcode-build-skills.md +0 -60
  459. package/pipeline/skills/shared/external/ios-iphone-duo/NOTICE.md +0 -53
  460. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/bootstrap/Sources/MyApp/main.swift +0 -11
  461. package/pipeline/skills/shared/external/swiftdata-pro/references/class-inheritance.md +0 -104
  462. package/pipeline/skills/shared/external/swiftdata-pro/references/core-rules.md +0 -20
  463. package/pipeline/skills/shared/external/swiftui-performance-audit/references/code-smells.md +0 -158
  464. package/pipeline/skills/shared/external/swiftui-performance-audit/references/demystify-swiftui-performance-wwdc23.md +0 -46
  465. package/pipeline/skills/shared/external/swiftui-performance-audit/references/optimizing-swiftui-performance-instruments.md +0 -29
  466. package/pipeline/skills/shared/external/swiftui-performance-audit/references/profiling-intake.md +0 -44
  467. package/pipeline/skills/shared/external/swiftui-performance-audit/references/report-template.md +0 -47
  468. package/pipeline/skills/shared/external/swiftui-performance-audit/references/understanding-hangs-in-your-app.md +0 -33
  469. package/pipeline/skills/shared/external/swiftui-performance-audit/references/understanding-improving-swiftui-performance.md +0 -52
@@ -1,531 +1,406 @@
1
1
  #!/usr/bin/env python3
2
+ """Render .build-benchmark/optimization-plan.md from the collected artifacts.
2
3
 
3
- """Generate a Markdown optimization report from benchmark and diagnostics artifacts."""
4
+ Inputs: a benchmark artifact (required), optionally a diagnostics artifact, a
5
+ recommendations JSON and an .xcodeproj to audit. Without a recommendations file,
6
+ failing build-setting checks become the recommendation list.
7
+ """
4
8
 
5
9
  import argparse
6
10
  import json
7
11
  import re
8
- from datetime import datetime, timezone
12
+ import shlex
9
13
  from pathlib import Path
10
- from typing import Any, Dict, List, Optional, Tuple
11
14
 
12
-
13
- # ---------------------------------------------------------------------------
14
- # pbxproj helpers
15
- # ---------------------------------------------------------------------------
16
-
17
- _SETTING_RE = re.compile(r"^\s*([A-Z_][A-Z_0-9]*)\s*=\s*(.+?)\s*;", re.MULTILINE)
18
-
19
- _CONFIG_ID_RE = re.compile(r"([0-9A-F]{24})\s*/\*\s*(Debug|Release)\s*\*/")
20
-
21
- _CONFIG_LIST_RE = re.compile(
22
- r"([0-9A-F]{24})\s*/\*\s*Build configuration list for "
23
- r"(?P<kind>PBXProject|PBXNativeTarget)\s+\"(?P<name>[^\"]+)\"\s*\*/"
24
- )
25
-
26
-
27
- def _parse_all_build_configs(pbxproj: str) -> Dict[str, Tuple[str, Dict[str, str]]]:
28
- """Return {config_id: (config_name, {key: value})} for every XCBuildConfiguration."""
29
- configs: Dict[str, Tuple[str, Dict[str, str]]] = {}
30
- for match in re.finditer(
31
- r"([0-9A-F]{24})\s*/\*\s*(Debug|Release)\s*\*/\s*=\s*\{\s*"
32
- r"isa\s*=\s*XCBuildConfiguration;\s*buildSettings\s*=\s*\{([^}]*)\}",
33
- pbxproj,
34
- re.DOTALL,
35
- ):
36
- config_id = match.group(1)
37
- config_name = match.group(2)
38
- body = match.group(3)
39
- settings: Dict[str, str] = {}
40
- for s in _SETTING_RE.finditer(body):
41
- val = s.group(2).strip().strip('"')
42
- settings[s.group(1)] = val
43
- configs[config_id] = (config_name, settings)
44
- return configs
45
-
46
-
47
- def _resolve_config_list(
48
- pbxproj: str, all_configs: Dict[str, Tuple[str, Dict[str, str]]], kind: str
49
- ) -> Dict[str, Dict[str, Dict[str, str]]]:
50
- """Resolve configuration lists for a given kind (PBXProject or PBXNativeTarget)."""
51
- results: Dict[str, Dict[str, Dict[str, str]]] = {}
52
- for list_match in _CONFIG_LIST_RE.finditer(pbxproj):
53
- if list_match.group("kind") != kind:
54
- continue
55
- entity_name = list_match.group("name")
56
- list_id = list_match.group(1)
57
- block_start = pbxproj.find(f"{list_id} /*", list_match.end())
58
- if block_start == -1:
59
- block_start = list_match.start()
60
- block = pbxproj[block_start : block_start + 500]
61
- configs: Dict[str, Dict[str, str]] = {}
62
- for cid_match in _CONFIG_ID_RE.finditer(block):
63
- cid = cid_match.group(1)
64
- if cid in all_configs:
65
- cname, settings = all_configs[cid]
66
- configs[cname] = settings
67
- if configs:
68
- results[entity_name] = configs
69
- return results
70
-
71
-
72
- def _parse_project_level_configs(pbxproj: str) -> Dict[str, Dict[str, str]]:
73
- """Extract project-level Debug and Release build settings."""
74
- all_configs = _parse_all_build_configs(pbxproj)
75
- resolved = _resolve_config_list(pbxproj, all_configs, "PBXProject")
76
- if resolved:
77
- return next(iter(resolved.values()))
78
- return {}
79
-
80
-
81
- def _parse_target_configs(pbxproj: str) -> Dict[str, Dict[str, Dict[str, str]]]:
82
- """Extract per-target Debug and Release build settings."""
83
- all_configs = _parse_all_build_configs(pbxproj)
84
- return _resolve_config_list(pbxproj, all_configs, "PBXNativeTarget")
85
-
86
-
87
- # ---------------------------------------------------------------------------
88
- # Best-practices audit
89
- # ---------------------------------------------------------------------------
90
-
91
- _DEBUG_EXPECTATIONS: List[Tuple[str, str, str]] = [
92
- ("SWIFT_COMPILATION_MODE", "singlefile", "Single-file mode recompiles only changed files (Xcode UI: Incremental)"),
93
- ("SWIFT_OPTIMIZATION_LEVEL", "-Onone", "Optimization passes add compile time without debug benefit"),
94
- ("GCC_OPTIMIZATION_LEVEL", "0", "C/ObjC optimization adds compile time without debug benefit"),
95
- ("ONLY_ACTIVE_ARCH", "YES", "Building all architectures multiplies compile and link time"),
96
- ("DEBUG_INFORMATION_FORMAT", "dwarf", "dwarf-with-dsym generates a separate dSYM, adding overhead"),
97
- ("ENABLE_TESTABILITY", "YES", "Required for @testable import during development"),
98
- ("EAGER_LINKING", "YES", "Allows linker to start before all compilation finishes, reducing wall-clock time"),
99
- ]
100
-
101
- _GENERAL_EXPECTATIONS: List[Tuple[str, str, str]] = [
102
- ("COMPILATION_CACHE_ENABLE_CACHING", "YES", "Caches compilation results so repeat builds of unchanged inputs are served from cache. Measured 5-14% faster clean builds across tested projects; benefit compounds during branch switching and pulling changes"),
15
+ OBJECT_HEADER = re.compile(r"(?P<id>[0-9A-Fa-f]{24})\s*(?:/\*(?P<note>.*?)\*/)?\s*=\s*\{")
16
+ ASSIGNMENT = re.compile(r'(?:"(?P<qkey>[^"]+)"|(?P<key>[A-Za-z_]\w*))\s*=\s*(?P<value>"(?:[^"\\]|\\.)*"|\([^)]*\)|[^;{}]+?)\s*;')
17
+ LIST_OWNER = re.compile(r'Build configuration list for (?P<kind>PBXProject|PBXNativeTarget) "(?P<name>[^"]+)"')
18
+ ID_REF = re.compile(r"[0-9A-Fa-f]{24}")
19
+
20
+ DEBUG_RULES = [
21
+ ("SWIFT_COMPILATION_MODE", "singlefile", "Only edited files recompile in single-file mode (shown as Incremental in Xcode)"),
22
+ ("SWIFT_OPTIMIZATION_LEVEL", "-Onone", "Optimizer passes cost compile time and give a debug build nothing"),
23
+ ("GCC_OPTIMIZATION_LEVEL", "0", "C and Objective-C optimization costs compile time and gives a debug build nothing"),
24
+ ("ONLY_ACTIVE_ARCH", "YES", "Every extra architecture repeats compiling and linking"),
25
+ ("DEBUG_INFORMATION_FORMAT", "dwarf", "dwarf-with-dsym adds a separate dSYM step to every build"),
26
+ ("ENABLE_TESTABILITY", "YES", "@testable import needs it while developing"),
27
+ ("EAGER_LINKING", "YES", "Linking can begin before every compile task is done, which shortens wall-clock time"),
103
28
  ]
104
-
105
- _RELEASE_EXPECTATIONS: List[Tuple[str, str, str]] = [
106
- ("SWIFT_COMPILATION_MODE", "wholemodule", "Whole-module optimization produces faster runtime code"),
107
- ("SWIFT_OPTIMIZATION_LEVEL", "-O", "Optimized binaries for production (-Osize also acceptable)"),
108
- ("GCC_OPTIMIZATION_LEVEL", "s", "Optimizes C/ObjC for size in release"),
109
- ("ONLY_ACTIVE_ARCH", "NO", "Release builds must include all architectures for distribution"),
110
- ("DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym", "dSYM bundles are needed for crash symbolication"),
111
- ("ENABLE_TESTABILITY", "NO", "Removes internal-symbol export overhead from release builds"),
29
+ GENERAL_RULES = [
30
+ ("COMPILATION_CACHE_ENABLE_CACHING", "YES", "Unchanged inputs are served from the compilation cache; clean builds measured 5-14% faster across tested projects, with more gained on branch switches and pulls"),
112
31
  ]
113
-
114
- _CONSISTENCY_KEYS = [
115
- "SWIFT_COMPILATION_MODE",
116
- "SWIFT_OPTIMIZATION_LEVEL",
117
- "ONLY_ACTIVE_ARCH",
118
- "DEBUG_INFORMATION_FORMAT",
32
+ RELEASE_RULES = [
33
+ ("SWIFT_COMPILATION_MODE", "wholemodule", "Whole-module optimization yields faster runtime code"),
34
+ ("SWIFT_OPTIMIZATION_LEVEL", "-O", "Shipping binaries should be optimized (-Osize is accepted too)"),
35
+ ("GCC_OPTIMIZATION_LEVEL", "s", "C and Objective-C are optimized for size in release"),
36
+ ("ONLY_ACTIVE_ARCH", "NO", "Distribution needs every supported architecture"),
37
+ ("DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym", "Crash symbolication needs the dSYM"),
38
+ ("ENABLE_TESTABILITY", "NO", "Release builds should not export internal symbols"),
119
39
  ]
40
+ DRIFT_KEYS = ["SWIFT_COMPILATION_MODE", "SWIFT_OPTIMIZATION_LEVEL", "ONLY_ACTIVE_ARCH", "DEBUG_INFORMATION_FORMAT"]
41
+ HOTSPOT_ROWS = 30
42
+ PARALLEL_NOTE = (
43
+ "> **Note:** Each row sums task time over every core. Xcode overlaps tasks, "
44
+ "so the rows usually add up to more than the wall-clock medians above, and a "
45
+ "big row is a workload signal, not proof that it holds up the build.\n"
46
+ )
120
47
 
121
48
 
122
- def _effective_value(
123
- project: Dict[str, str], target: Dict[str, str], key: str
124
- ) -> Optional[str]:
125
- return target.get(key, project.get(key))
49
+ class PbxIndex:
50
+ """Just enough of a project.pbxproj object graph to resolve build settings."""
51
+
52
+ def __init__(self, text: str):
53
+ self.objects = {}
54
+ for header in OBJECT_HEADER.finditer(text):
55
+ body = self._block(text, header.end() - 1)
56
+ self.objects[header.group("id")] = (header.group("note") or "").strip(), body
57
+ self.text = text
58
+
59
+ @staticmethod
60
+ def _block(text: str, start: int) -> str:
61
+ depth = 0
62
+ for pos in range(start, len(text)):
63
+ ch = text[pos]
64
+ if ch == "{":
65
+ depth += 1
66
+ elif ch == "}":
67
+ depth -= 1
68
+ if depth == 0:
69
+ return text[start + 1 : pos]
70
+ return text[start + 1 :]
71
+
72
+ @staticmethod
73
+ def _assignments(body: str) -> dict:
74
+ out = {}
75
+ for m in ASSIGNMENT.finditer(body):
76
+ value = m.group("value").strip()
77
+ if value.startswith("("):
78
+ value = " ".join(part.strip().strip('"') for part in value[1:-1].split(",") if part.strip())
79
+ out[m.group("qkey") or m.group("key")] = value.strip('"')
80
+ return out
81
+
82
+ def settings_of(self, config_id: str):
83
+ entry = self.objects.get(config_id)
84
+ if not entry or "isa = XCBuildConfiguration" not in entry[1]:
85
+ return None
86
+ body = entry[1]
87
+ start = body.find("buildSettings")
88
+ settings = {}
89
+ if start != -1:
90
+ settings = self._assignments(self._block(body, body.index("{", start)))
91
+ outer = self._assignments(re.sub(r"buildSettings\s*=\s*\{.*?\};", "", body, flags=re.S))
92
+ return outer.get("name", entry[0]), settings
93
+
94
+ def owners(self, kind: str) -> dict:
95
+ resolved = {}
96
+ for list_id, (note, body) in self.objects.items():
97
+ owner = LIST_OWNER.search(note)
98
+ if not owner or owner.group("kind") != kind or "XCConfigurationList" not in body:
99
+ continue
100
+ refs = re.search(r"buildConfigurations\s*=\s*\((?P<ids>[^)]*)\)", body)
101
+ per_config = {}
102
+ for cid in ID_REF.findall(refs.group("ids") if refs else ""):
103
+ found = self.settings_of(cid)
104
+ if found:
105
+ per_config[found[0]] = found[1]
106
+ if per_config:
107
+ resolved[owner.group("name")] = per_config
108
+ return resolved
109
+
110
+
111
+ def passes(actual, expected: str) -> bool:
112
+ if actual is None:
113
+ return expected == "singlefile"
114
+ actual = actual.strip('"')
115
+ if expected == "-O":
116
+ return actual in ("-O", "-Osize")
117
+ return actual == expected
126
118
 
127
119
 
128
- def _check(actual: Optional[str], expected: str) -> bool:
129
- if actual is None:
130
- if expected in ("singlefile",):
131
- return True
132
- return False
133
- if expected == "-O" and actual in ("-O", '"-O"', '"-Osize"', "-Osize"):
134
- return True
135
- return actual.strip('"') == expected
136
-
137
-
138
- def _merged_project_settings(
139
- project_configs: Dict[str, Dict[str, str]],
140
- ) -> Dict[str, str]:
141
- """Return a flat dict of all settings across Debug and Release for general checks."""
142
- merged: Dict[str, str] = {}
143
- for config in project_configs.values():
144
- merged.update(config)
120
+ def flatten(project: dict) -> dict:
121
+ merged = {}
122
+ for settings in project.values():
123
+ merged.update(settings)
145
124
  return merged
146
125
 
147
126
 
148
- def _audit_config(
149
- project_settings: Dict[str, str],
150
- expectations: List[Tuple[str, str, str]],
151
- config_name: str,
152
- ) -> List[str]:
153
- lines: List[str] = []
154
- for key, expected, _reason in expectations:
155
- actual = project_settings.get(key)
156
- display_actual = actual if actual else "(unset)"
157
- passed = _check(actual, expected)
158
- mark = "[x]" if passed else "[ ]"
159
- lines.append(f"- {mark} `{key}`: `{display_actual}` (recommended: `{expected}`)")
160
- return lines
161
-
162
-
163
- def _audit_consistency(
164
- project_configs: Dict[str, Dict[str, str]],
165
- target_configs: Dict[str, Dict[str, Dict[str, str]]],
166
- ) -> List[str]:
167
- lines: List[str] = []
168
- for key in _CONSISTENCY_KEYS:
169
- overrides = []
170
- for target_name, configs in target_configs.items():
171
- for config_name in ("Debug", "Release"):
172
- target_settings = configs.get(config_name, {})
173
- if key in target_settings:
174
- proj_val = project_configs.get(config_name, {}).get(key, "(unset)")
175
- tgt_val = target_settings[key]
176
- if tgt_val != proj_val:
177
- overrides.append(
178
- f"{target_name} ({config_name}): `{tgt_val}` vs project `{proj_val}`"
179
- )
180
- if overrides:
181
- lines.append(f"- [ ] `{key}` has target-level overrides:")
182
- for o in overrides:
183
- lines.append(f" - {o}")
127
+ def checklist(settings: dict, rules: list) -> list:
128
+ rows = []
129
+ for key, expected, _ in rules:
130
+ actual = settings.get(key)
131
+ mark = "[x]" if passes(actual, expected) else "[ ]"
132
+ rows.append(f"- {mark} `{key}`: `{actual or '(unset)'}` (recommended: `{expected}`)")
133
+ return rows
134
+
135
+
136
+ def drift(project: dict, targets: dict) -> list:
137
+ rows = []
138
+ for key in DRIFT_KEYS:
139
+ diffs = []
140
+ for target, configs in targets.items():
141
+ for config in ("Debug", "Release"):
142
+ own = configs.get(config, {})
143
+ if key not in own:
144
+ continue
145
+ inherited = project.get(config, {}).get(key, "(unset)")
146
+ if own[key] != inherited:
147
+ diffs.append(f"{target} ({config}): `{own[key]}` vs project `{inherited}`")
148
+ if diffs:
149
+ rows.append(f"- [ ] `{key}` overridden per target:")
150
+ rows.extend(f" - {d}" for d in diffs)
184
151
  else:
185
- lines.append(f"- [x] `{key}` is consistent across all targets")
186
- return lines
187
-
188
-
189
- # ---------------------------------------------------------------------------
190
- # Auto-generated recommendations from audit
191
- # ---------------------------------------------------------------------------
192
-
193
-
194
- def _auto_recommendations_from_audit(
195
- project_configs: Dict[str, Dict[str, str]],
196
- ) -> Dict[str, Any]:
197
- """Generate basic recommendations from failing build settings audit checks."""
198
- items: List[Dict[str, str]] = []
199
-
200
- debug_settings = project_configs.get("Debug", {})
201
- for key, expected, reason in _DEBUG_EXPECTATIONS:
202
- if not _check(debug_settings.get(key), expected):
203
- actual = debug_settings.get(key, "(unset)")
204
- items.append({
205
- "title": f"Set `{key}` to `{expected}` for Debug",
206
- "category": "build-settings",
207
- "observed_evidence": f"Current value: `{actual}`. {reason}.",
208
- "estimated_impact": "Medium",
209
- "confidence": "High",
210
- "risk_level": "Low",
211
- })
152
+ rows.append(f"- [x] `{key}` same value in every target")
153
+ return rows
212
154
 
213
- merged = {}
214
- for config in project_configs.values():
215
- merged.update(config)
216
- for key, expected, reason in _GENERAL_EXPECTATIONS:
217
- if not _check(merged.get(key), expected):
218
- actual = merged.get(key, "(unset)")
219
- items.append({
220
- "title": f"Enable `{key} = {expected}`",
221
- "category": "build-settings",
222
- "observed_evidence": f"Current value: `{actual}`. {reason}.",
223
- "estimated_impact": "High",
224
- "confidence": "High",
225
- "risk_level": "Low",
226
- })
227
-
228
- release_settings = project_configs.get("Release", {})
229
- for key, expected, reason in _RELEASE_EXPECTATIONS:
230
- if not _check(release_settings.get(key), expected):
231
- actual = release_settings.get(key, "(unset)")
232
- items.append({
233
- "title": f"Set `{key}` to `{expected}` for Release",
234
- "category": "build-settings",
235
- "observed_evidence": f"Current value: `{actual}`. {reason}.",
236
- "estimated_impact": "Medium",
237
- "confidence": "High",
238
- "risk_level": "Low",
239
- })
240
155
 
241
- if not items:
242
- return {"recommendations": []}
243
- return {"recommendations": items}
244
-
245
-
246
- # ---------------------------------------------------------------------------
247
- # Report generation
248
- # ---------------------------------------------------------------------------
249
-
250
-
251
- def _section_context(benchmark: Dict[str, Any]) -> str:
252
- build = benchmark.get("build", {})
253
- env = benchmark.get("environment", {})
254
- lines = [
255
- "## Project Context\n",
256
- f"- **Project:** `{build.get('path', 'unknown')}`",
257
- f"- **Scheme:** `{build.get('scheme', 'unknown')}`",
258
- f"- **Configuration:** `{build.get('configuration', 'unknown')}`",
259
- f"- **Destination:** `{build.get('destination', 'unknown')}`",
260
- f"- **Xcode:** {env.get('xcode_version', 'unknown').replace(chr(10), ' ')}",
261
- f"- **macOS:** {env.get('macos_version', 'unknown')}",
262
- f"- **Date:** {benchmark.get('created_at', 'unknown')}",
263
- f"- **Benchmark artifact:** `{benchmark.get('_artifact_path', 'unknown')}`",
156
+ def audit_recommendations(project: dict) -> list:
157
+ groups = [
158
+ (project.get("Debug", {}), DEBUG_RULES, "Set `{k}` to `{v}` for Debug", "Medium"),
159
+ (flatten(project), GENERAL_RULES, "Enable `{k} = {v}`", "High"),
160
+ (project.get("Release", {}), RELEASE_RULES, "Set `{k}` to `{v}` for Release", "Medium"),
264
161
  ]
265
- return "\n".join(lines)
266
-
267
-
268
- def _section_baseline(benchmark: Dict[str, Any]) -> str:
269
- summary = benchmark.get("summary", {})
270
- clean = summary.get("clean", {})
271
- cached_clean = summary.get("cached_clean", {})
272
- incremental = summary.get("incremental", {})
273
- has_cached = bool(cached_clean and cached_clean.get("count", 0) > 0)
274
-
275
- if has_cached:
276
- lines = [
277
- "## Baseline Benchmarks\n",
278
- "| Metric | Clean | Cached Clean | Incremental |",
279
- "|--------|-------|-------------|-------------|",
280
- f"| Median | {clean.get('median_seconds', 0):.3f}s | {cached_clean.get('median_seconds', 0):.3f}s | {incremental.get('median_seconds', 0):.3f}s |",
281
- f"| Min | {clean.get('min_seconds', 0):.3f}s | {cached_clean.get('min_seconds', 0):.3f}s | {incremental.get('min_seconds', 0):.3f}s |",
282
- f"| Max | {clean.get('max_seconds', 0):.3f}s | {cached_clean.get('max_seconds', 0):.3f}s | {incremental.get('max_seconds', 0):.3f}s |",
283
- f"| Runs | {clean.get('count', 0)} | {cached_clean.get('count', 0)} | {incremental.get('count', 0)} |",
284
- ]
285
- lines.append(
286
- "\n> **Cached Clean** = clean build with a warm compilation cache. "
287
- "This is the realistic scenario for branch switching, pulling changes, or "
288
- "Clean Build Folder. The compilation cache lives outside DerivedData and "
289
- "survives product deletion.\n"
162
+ items = []
163
+ for settings, rules, title, impact in groups:
164
+ for key, expected, why in rules:
165
+ if passes(settings.get(key), expected):
166
+ continue
167
+ items.append(
168
+ {
169
+ "title": title.format(k=key, v=expected),
170
+ "category": "build-settings",
171
+ "observed_evidence": f"Current value: `{settings.get(key, '(unset)')}`. {why}.",
172
+ "estimated_impact": impact,
173
+ "confidence": "High",
174
+ "risk_level": "Low",
175
+ }
176
+ )
177
+ return items
178
+
179
+
180
+ def context_section(bench: dict, artifact_path: str) -> str:
181
+ build = bench.get("build", {})
182
+ env = bench.get("environment", {})
183
+ xcode = str(env.get("xcode_version", "unknown")).replace("\n", " ")
184
+ facts = [
185
+ ("Project", f"`{build.get('path') or 'unknown'}`"),
186
+ ("Scheme", f"`{build.get('scheme') or 'unknown'}`"),
187
+ ("Configuration", f"`{build.get('configuration') or 'unknown'}`"),
188
+ ("Destination", f"`{build.get('destination') or 'scheme default'}`"),
189
+ ("Xcode", xcode),
190
+ ("macOS", env.get("macos_version") or "unknown"),
191
+ ("Measured at", bench.get("created_at") or "unknown"),
192
+ ("Benchmark artifact", f"`{artifact_path}`"),
193
+ ]
194
+ return "\n".join(["## Project Context\n", "| Field | Value |", "|-------|-------|"] + [f"| {k} | {v} |" for k, v in facts])
195
+
196
+
197
+ def incremental_label(bench: dict) -> str:
198
+ kinds = {run.get("build_type") for run in bench.get("runs", {}).get("incremental", [])}
199
+ return "Zero-Change" if kinds == {"zero-change"} else "Incremental"
200
+
201
+
202
+ def baseline_section(bench: dict) -> str:
203
+ summary = bench.get("summary", {})
204
+ phases = ["clean"]
205
+ if summary.get("cached_clean", {}).get("count", 0) > 0:
206
+ phases.append("cached_clean")
207
+ phases.append("incremental")
208
+ names = dict(clean="Clean", cached_clean="Cached Clean")
209
+ names["incremental"] = incremental_label(bench)
210
+
211
+ out = ["## Baseline Benchmarks\n"]
212
+ out.append("| Metric | " + " | ".join(names[p] for p in phases) + " |")
213
+ out.append("|--------|" + "|".join("-" * (len(names[p]) + 2) for p in phases) + "|")
214
+ for label, field, fmt in (
215
+ ("Median", "median_seconds", "{:.3f}s"),
216
+ ("Min", "min_seconds", "{:.3f}s"),
217
+ ("Max", "max_seconds", "{:.3f}s"),
218
+ ("Runs", "count", "{}"),
219
+ ):
220
+ cells = [fmt.format(summary.get(p, {}).get(field, 0)) for p in phases]
221
+ out.append(f"| {label} | " + " | ".join(cells) + " |")
222
+ if "cached_clean" in phases:
223
+ out.append(
224
+ "\n> **Cached Clean**: DerivedData wiped, compilation cache kept warm. That is "
225
+ "what a branch switch, a pull or Clean Build Folder leaves behind, because the "
226
+ "cache lives outside DerivedData.\n"
290
227
  )
291
- else:
292
- lines = [
293
- "## Baseline Benchmarks\n",
294
- "| Metric | Clean | Incremental |",
295
- "|--------|-------|-------------|",
296
- f"| Median | {clean.get('median_seconds', 0):.3f}s | {incremental.get('median_seconds', 0):.3f}s |",
297
- f"| Min | {clean.get('min_seconds', 0):.3f}s | {incremental.get('min_seconds', 0):.3f}s |",
298
- f"| Max | {clean.get('max_seconds', 0):.3f}s | {incremental.get('max_seconds', 0):.3f}s |",
299
- f"| Runs | {clean.get('count', 0)} | {incremental.get('count', 0)} |",
300
- ]
301
228
 
302
- build_types = ["clean", "cached_clean", "incremental"] if has_cached else ["clean", "incremental"]
303
- label_map = {"clean": "Clean", "cached_clean": "Cached Clean", "incremental": "Incremental"}
304
- for build_type in build_types:
305
- runs = benchmark.get("runs", {}).get(build_type, [])
306
- all_cats: Dict[str, Dict] = {}
229
+ for phase in phases:
230
+ runs = bench.get("runs", {}).get(phase, [])
231
+ pooled = {}
307
232
  for run in runs:
308
- for cat in run.get("timing_summary_categories", []):
309
- name = cat["name"]
310
- if name not in all_cats:
311
- all_cats[name] = {"seconds": 0.0, "task_count": 0}
312
- all_cats[name]["seconds"] += cat["seconds"]
313
- all_cats[name]["task_count"] += cat.get("task_count", 0)
314
- if all_cats:
315
- count = len(runs) or 1
316
- ranked = sorted(all_cats.items(), key=lambda x: x[1]["seconds"], reverse=True)
317
- label = label_map.get(build_type, build_type.title())
318
- lines.append(f"\n### {label} Build Timing Summary\n")
319
- lines.append(
320
- "> **Note:** These are aggregated task times across all CPU cores. "
321
- "Because Xcode runs many tasks in parallel, these totals typically exceed "
322
- "the actual build wait time shown above. A large number here does not mean "
323
- "it is blocking your build.\n"
324
- )
325
- lines.append("| Category | Tasks | Seconds |")
326
- lines.append("|----------|------:|--------:|")
327
- for name, data in ranked:
328
- avg_sec = data["seconds"] / count
329
- tasks = data["task_count"] // count if data["task_count"] else ""
330
- lines.append(f"| {name} | {tasks} | {avg_sec:.3f}s |")
331
-
332
- return "\n".join(lines)
333
-
334
-
335
- def _section_settings_audit(
336
- project_configs: Dict[str, Dict[str, str]],
337
- target_configs: Dict[str, Dict[str, Dict[str, str]]],
338
- ) -> str:
339
- lines = ["## Build Settings Audit\n"]
340
-
341
- lines.append("### Debug Configuration\n")
342
- lines.extend(_audit_config(project_configs.get("Debug", {}), _DEBUG_EXPECTATIONS, "Debug"))
343
-
344
- lines.append("\n### General (All Configurations)\n")
345
- merged = _merged_project_settings(project_configs)
346
- lines.extend(_audit_config(merged, _GENERAL_EXPECTATIONS, "General"))
347
-
348
- lines.append("\n### Release Configuration\n")
349
- lines.extend(_audit_config(project_configs.get("Release", {}), _RELEASE_EXPECTATIONS, "Release"))
350
-
351
- lines.append("\n### Cross-Target Consistency\n")
352
- lines.extend(_audit_consistency(project_configs, target_configs))
353
-
354
- return "\n".join(lines)
355
-
356
-
357
- def _section_diagnostics(diagnostics: Optional[Dict[str, Any]]) -> str:
358
- if diagnostics is None:
359
- return "## Compilation Diagnostics\n\nNo diagnostics artifact provided. Run `diagnose_compilation.py` to identify type-checking hotspots."
360
- warnings = diagnostics.get("warnings", [])
361
- summary = diagnostics.get("summary", {})
362
- threshold = diagnostics.get("threshold_ms", 100)
363
- lines = [
233
+ for row in run.get("timing_summary_categories") or []:
234
+ slot = pooled.setdefault(row["name"], [0.0, 0])
235
+ slot[0] += row["seconds"]
236
+ slot[1] += row.get("task_count", 0)
237
+ if not pooled:
238
+ continue
239
+ divisor = len(runs) or 1
240
+ out.append(f"\n### {names[phase]} Build Timing Summary\n")
241
+ out.append(PARALLEL_NOTE)
242
+ out.append("| Category | Tasks | Seconds |")
243
+ out.append("|----------|------:|--------:|")
244
+ for name, (secs, tasks) in sorted(pooled.items(), key=lambda kv: kv[1][0], reverse=True):
245
+ shown_tasks = tasks // divisor if tasks else ""
246
+ out.append(f"| {name} | {shown_tasks} | {secs / divisor:.3f}s |")
247
+ return "\n".join(out)
248
+
249
+
250
+ def settings_section(project: dict, targets: dict) -> str:
251
+ out = ["## Build Settings Audit\n", "### Debug Configuration\n"]
252
+ out += checklist(project.get("Debug", {}), DEBUG_RULES)
253
+ out += ["\n### General (All Configurations)\n"] + checklist(flatten(project), GENERAL_RULES)
254
+ out += ["\n### Release Configuration\n"] + checklist(project.get("Release", {}), RELEASE_RULES)
255
+ out += ["\n### Cross-Target Consistency\n"] + drift(project, targets)
256
+ return "\n".join(out)
257
+
258
+
259
+ def diagnostics_section(diag) -> str:
260
+ if diag is None:
261
+ return (
262
+ "## Compilation Diagnostics\n\nSkipped: no diagnostics artifact was passed. "
263
+ "`diagnose_compilation.py` produces one."
264
+ )
265
+ found = diag.get("warnings", [])
266
+ s = diag.get("summary", {})
267
+ out = [
364
268
  "## Compilation Diagnostics\n",
365
- f"Threshold: {threshold}ms | "
366
- f"Total warnings: {summary.get('total_warnings', 0)} | "
367
- f"Function bodies: {summary.get('function_body_warnings', 0)} | "
368
- f"Expressions: {summary.get('expression_warnings', 0)}\n",
269
+ f"Threshold: {diag.get('threshold_ms', 100)}ms | Total warnings: {s.get('total_warnings', 0)} | "
270
+ f"Function bodies: {s.get('function_body_warnings', 0)} | Expressions: {s.get('expression_warnings', 0)}\n",
369
271
  ]
370
- if warnings:
371
- lines.append("| Duration | Kind | File | Line | Name |")
372
- lines.append("|---------:|------|------|-----:|------|")
373
- for w in warnings[:30]:
374
- short_file = Path(w["file"]).name
375
- name = w.get("name", "") or "(expression)"
376
- lines.append(
377
- f"| {w['duration_ms']}ms | {w['kind']} | {short_file} | {w['line']} | {name} |"
378
- )
379
- if len(warnings) > 30:
380
- lines.append(f"\n*... and {len(warnings) - 30} more warnings (see full artifact)*")
381
- else:
382
- lines.append("No type-checking hotspots found above threshold.")
383
- return "\n".join(lines)
272
+ if not found:
273
+ out.append("Nothing crossed the threshold.")
274
+ return "\n".join(out)
275
+ out += ["| Duration | Kind | File | Line | Name |", "|---------:|------|------|-----:|------|"]
276
+ for w in found[:HOTSPOT_ROWS]:
277
+ label = w.get("name") or "(expression)"
278
+ out.append("| %sms | %s | %s | %s | %s |" % (w["duration_ms"], w["kind"], Path(w["file"]).name, w["line"], label))
279
+ if len(found) > HOTSPOT_ROWS:
280
+ out.append(f"\n*... and {len(found) - HOTSPOT_ROWS} more warnings (see full artifact)*")
281
+ return "\n".join(out)
282
+
283
+
284
+ FIELD_LABELS = [
285
+ ("wait_time_impact", "Wait-Time Impact"),
286
+ ("actionability", "Actionability"),
287
+ ("category", "Category"),
288
+ ("observed_evidence", "Evidence"),
289
+ ("estimated_impact", "Impact"),
290
+ ("confidence", "Confidence"),
291
+ ("risk_level", "Risk"),
292
+ ("scope", "Scope"),
293
+ ]
384
294
 
385
295
 
386
- def _section_recommendations(recommendations: Optional[Dict[str, Any]]) -> str:
387
- if recommendations is None:
388
- return "## Prioritized Recommendations\n\nNo recommendations artifact provided."
389
- items = recommendations.get("recommendations", [])
296
+ def recommendations_section(items) -> str:
297
+ if items is None:
298
+ return "## Prioritized Recommendations\n\nNone yet: no recommendations file and no failing settings check."
390
299
  if not items:
391
- return "## Prioritized Recommendations\n\nNo recommendations found."
392
- lines = ["## Prioritized Recommendations\n"]
393
- for i, item in enumerate(items, 1):
394
- title = item.get("title", "Untitled")
395
- lines.append(f"### {i}. {title}\n")
396
- for field, label in [
397
- ("wait_time_impact", "Wait-Time Impact"),
398
- ("actionability", "Actionability"),
399
- ("category", "Category"),
400
- ("observed_evidence", "Evidence"),
401
- ("estimated_impact", "Impact"),
402
- ("confidence", "Confidence"),
403
- ("risk_level", "Risk"),
404
- ("scope", "Scope"),
405
- ]:
406
- val = item.get(field)
407
- if val is None:
300
+ return "## Prioritized Recommendations\n\nThe recommendations file is empty."
301
+ out = ["## Prioritized Recommendations\n"]
302
+ for n, item in enumerate(items, 1):
303
+ out.append(f"### {n}. {item.get('title', 'Untitled')}\n")
304
+ for field, label in FIELD_LABELS:
305
+ value = item.get(field)
306
+ if value is None:
408
307
  continue
409
- if isinstance(val, list):
410
- lines.append(f"**{label}:**")
411
- for entry in val:
412
- lines.append(f"- {entry}")
308
+ if isinstance(value, list):
309
+ out.append(f"**{label}:**")
310
+ out.extend(f"- {entry}" for entry in value)
413
311
  else:
414
- lines.append(f"**{label}:** {val}")
415
- lines.append("")
416
- return "\n".join(lines)
312
+ out.append(f"**{label}:** {value}")
313
+ out.append("")
314
+ return "\n".join(out)
417
315
 
418
316
 
419
- def _section_approval(recommendations: Optional[Dict[str, Any]]) -> str:
420
- if recommendations is None:
421
- return "## Approval Checklist\n\nNo recommendations to approve."
422
- items = recommendations.get("recommendations", [])
317
+ def approval_section(items) -> str:
423
318
  if not items:
424
- return "## Approval Checklist\n\nNo recommendations to approve."
425
- lines = ["## Approval Checklist\n"]
426
- for i, item in enumerate(items, 1):
427
- title = item.get("title", "Untitled")
428
- wait_impact = item.get("wait_time_impact", "")
429
- impact = item.get("estimated_impact", "")
430
- risk = item.get("risk_level", "")
431
- actionability = item.get("actionability", "")
432
- impact_str = wait_impact if wait_impact else impact
433
- actionability_str = f" | Actionability: {actionability}" if actionability else ""
434
- lines.append(f"- [ ] **{i}. {title}** -- Impact: {impact_str}{actionability_str} | Risk: {risk}")
435
- return "\n".join(lines)
436
-
437
-
438
- def _section_next_steps(benchmark: Dict[str, Any]) -> str:
439
- build = benchmark.get("build", {})
440
- command = build.get("command", "xcodebuild build")
441
- lines = [
442
- "## Next Steps\n",
443
- "After implementing approved changes, re-benchmark with the same inputs:\n",
444
- "```bash",
445
- f"python3 scripts/benchmark_builds.py \\",
319
+ return "## Approval Checklist\n\nNothing awaits approval."
320
+ out = ["## Approval Checklist\n"]
321
+ for n, item in enumerate(items, 1):
322
+ wait = item.get("wait_time_impact")
323
+ impact = f"Wait-Time Impact: {wait}" if wait else f"Impact: {item.get('estimated_impact', '')}"
324
+ action = f" | Actionability: {item['actionability']}" if item.get("actionability") else ""
325
+ out.append(f"- [ ] **{n}. {item.get('title', 'Untitled')}** -- {impact}{action} | Risk: {item.get('risk_level', '')}")
326
+ return "\n".join(out)
327
+
328
+
329
+ def next_steps_section(bench: dict) -> str:
330
+ build = bench.get("build", {})
331
+ flag = "--workspace" if build.get("entrypoint") == "workspace" else "--project"
332
+ fallback = "App.xcworkspace" if flag == "--workspace" else "App.xcodeproj"
333
+ cmd = [
334
+ "python3 scripts/benchmark_builds.py \\",
335
+ f" {flag} {shlex.quote(build.get('path') or fallback)} \\",
336
+ f" --scheme {shlex.quote(build.get('scheme') or 'App')} \\",
337
+ f" --configuration {shlex.quote(build.get('configuration') or 'Debug')} \\",
446
338
  ]
447
- if build.get("entrypoint") == "workspace":
448
- lines.append(f" --workspace {build.get('path', 'App.xcworkspace')} \\")
449
- else:
450
- lines.append(f" --project {build.get('path', 'App.xcodeproj')} \\")
451
- lines.extend([
452
- f" --scheme {build.get('scheme', 'App')} \\",
453
- f" --configuration {build.get('configuration', 'Debug')} \\",
454
- ])
455
339
  if build.get("destination"):
456
- lines.append(f' --destination "{build["destination"]}" \\')
457
- lines.append(" --output-dir .build-benchmark")
458
- lines.append("```\n")
459
- lines.append("Compare the new wall-clock medians against the baseline. Report results as:")
460
- lines.append('"Your [clean/incremental] build now takes X.Xs (was Y.Ys) -- Z.Zs faster/slower."')
461
- return "\n".join(lines)
340
+ cmd.append(f' --destination "{build["destination"]}" \\')
341
+ for note in bench.get("notes") or []:
342
+ if note.startswith("touch-file: "):
343
+ cmd.append(f" --touch-file {shlex.quote(note[len('touch-file: '):])} \\")
344
+ cmd.append(" --output-dir .build-benchmark")
345
+ return "\n".join(
346
+ ["## Next Steps\n", "Once the approved items are in, rerun the benchmark with identical inputs:\n", "```bash"]
347
+ + cmd
348
+ + [
349
+ "```\n",
350
+ "Set the new wall-clock medians against this baseline and lead with one sentence per build type:",
351
+ '"[Clean/Incremental] build: X.Xs now, Y.Ys before (Z.Zs faster/slower)."',
352
+ ]
353
+ )
462
354
 
463
355
 
464
- # ---------------------------------------------------------------------------
465
- # Main
466
- # ---------------------------------------------------------------------------
356
+ def build_cli() -> argparse.ArgumentParser:
357
+ cli = argparse.ArgumentParser(description="Write the Markdown build optimization plan.")
358
+ cli.add_argument("--benchmark", required=True, help="benchmark JSON artifact")
359
+ cli.add_argument("--recommendations", help="recommendations JSON (recommendation-format shape)")
360
+ cli.add_argument("--diagnostics", help="diagnostics JSON from diagnose_compilation.py")
361
+ cli.add_argument("--project-path", help=".xcodeproj to audit for build settings")
362
+ cli.add_argument("--output", help="Markdown destination (default: stdout)")
363
+ return cli
467
364
 
468
365
 
469
- def parse_args() -> argparse.Namespace:
470
- parser = argparse.ArgumentParser(description="Generate a Markdown build optimization report.")
471
- parser.add_argument("--benchmark", required=True, help="Path to benchmark JSON artifact")
472
- parser.add_argument("--recommendations", help="Path to recommendations JSON")
473
- parser.add_argument("--diagnostics", help="Path to diagnostics JSON")
474
- parser.add_argument("--project-path", help="Path to .xcodeproj for build settings audit")
475
- parser.add_argument("--output", help="Output Markdown path (default: stdout)")
476
- return parser.parse_args()
366
+ def load(path):
367
+ return json.loads(Path(path).read_text()) if path else None
477
368
 
478
369
 
479
370
  def main() -> int:
480
- args = parse_args()
481
-
482
- benchmark = json.loads(Path(args.benchmark).read_text())
483
- benchmark["_artifact_path"] = args.benchmark
484
-
485
- recommendations = None
486
- if args.recommendations:
487
- recommendations = json.loads(Path(args.recommendations).read_text())
488
-
489
- diagnostics = None
490
- if args.diagnostics:
491
- diagnostics = json.loads(Path(args.diagnostics).read_text())
492
-
493
- project_configs: Dict[str, Dict[str, str]] = {}
494
- target_configs: Dict[str, Dict[str, Dict[str, str]]] = {}
495
- if args.project_path:
496
- pbxproj_path = Path(args.project_path) / "project.pbxproj"
497
- if pbxproj_path.exists():
498
- pbxproj = pbxproj_path.read_text()
499
- project_configs = _parse_project_level_configs(pbxproj)
500
- target_configs = _parse_target_configs(pbxproj)
501
-
502
- if recommendations is None and project_configs:
503
- auto = _auto_recommendations_from_audit(project_configs)
504
- if auto["recommendations"]:
505
- recommendations = auto
506
-
507
- sections = [
508
- "# Xcode Build Optimization Plan\n",
509
- _section_context(benchmark),
510
- _section_baseline(benchmark),
371
+ opts = build_cli().parse_args()
372
+ bench = load(opts.benchmark)
373
+ diag = load(opts.diagnostics)
374
+ recs = load(opts.recommendations)
375
+ items = recs.get("recommendations", []) if recs is not None else None
376
+
377
+ project, targets = {}, {}
378
+ if opts.project_path:
379
+ pbx = Path(opts.project_path) / "project.pbxproj"
380
+ if pbx.exists():
381
+ index = PbxIndex(pbx.read_text())
382
+ project = next(iter(index.owners("PBXProject").values()), {})
383
+ targets = index.owners("PBXNativeTarget")
384
+
385
+ if items is None and project:
386
+ items = audit_recommendations(project) or None
387
+
388
+ parts = ["# Xcode Build Optimization Plan\n", context_section(bench, opts.benchmark), baseline_section(bench)]
389
+ if project:
390
+ parts.append(settings_section(project, targets))
391
+ parts += [
392
+ diagnostics_section(diag),
393
+ recommendations_section(items),
394
+ approval_section(items),
395
+ next_steps_section(bench),
511
396
  ]
397
+ report = "\n\n".join(parts) + "\n"
512
398
 
513
- if project_configs:
514
- sections.append(_section_settings_audit(project_configs, target_configs))
515
-
516
- sections.append(_section_diagnostics(diagnostics))
517
- sections.append(_section_recommendations(recommendations))
518
- sections.append(_section_approval(recommendations))
519
- sections.append(_section_next_steps(benchmark))
520
-
521
- report = "\n\n".join(sections) + "\n"
522
-
523
- if args.output:
524
- Path(args.output).write_text(report)
525
- print(f"Saved optimization report: {args.output}")
399
+ if opts.output:
400
+ Path(opts.output).write_text(report)
401
+ print(f"Saved optimization report: {opts.output}")
526
402
  else:
527
403
  print(report, end="")
528
-
529
404
  return 0
530
405
 
531
406