psyclaw 0.28.0 → 0.28.2

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 (167) hide show
  1. package/README.md +5 -5
  2. package/agents/recommended/catalog.json +99 -0
  3. package/dist/apps/panel/index.html +5 -5
  4. package/dist/src/adapters/pi/extension.js +164 -18
  5. package/dist/src/adapters/pi/extension.js.map +1 -1
  6. package/dist/src/adapters/pi/rpc.d.ts +2 -0
  7. package/dist/src/adapters/pi/rpc.js +9 -2
  8. package/dist/src/adapters/pi/rpc.js.map +1 -1
  9. package/dist/src/agents/recommended-personas.d.ts +42 -0
  10. package/dist/src/agents/recommended-personas.js +135 -0
  11. package/dist/src/agents/recommended-personas.js.map +1 -0
  12. package/dist/src/ars/mode-editor.d.ts +20 -0
  13. package/dist/src/ars/mode-editor.js +57 -0
  14. package/dist/src/ars/mode-editor.js.map +1 -0
  15. package/dist/src/ars/profile.d.ts +4 -1
  16. package/dist/src/ars/profile.js +23 -6
  17. package/dist/src/ars/profile.js.map +1 -1
  18. package/dist/src/cli.js +6 -3
  19. package/dist/src/cli.js.map +1 -1
  20. package/dist/src/creation/contracts.d.ts +3 -0
  21. package/dist/src/creation/service.js +17 -5
  22. package/dist/src/creation/service.js.map +1 -1
  23. package/dist/src/index.d.ts +1 -0
  24. package/dist/src/index.js +1 -0
  25. package/dist/src/index.js.map +1 -1
  26. package/dist/src/orchestration/bundled-personas.d.ts +16 -0
  27. package/dist/src/orchestration/bundled-personas.js +101 -0
  28. package/dist/src/orchestration/bundled-personas.js.map +1 -0
  29. package/dist/src/orchestration/effects.d.ts +8 -0
  30. package/dist/src/orchestration/effects.js +39 -0
  31. package/dist/src/orchestration/effects.js.map +1 -0
  32. package/dist/src/orchestration/personas.d.ts +2 -1
  33. package/dist/src/orchestration/personas.js +20 -7
  34. package/dist/src/orchestration/personas.js.map +1 -1
  35. package/dist/src/orchestration/pi-executor.d.ts +9 -5
  36. package/dist/src/orchestration/pi-executor.js +55 -22
  37. package/dist/src/orchestration/pi-executor.js.map +1 -1
  38. package/dist/src/orchestration/research-agents.d.ts +3 -7
  39. package/dist/src/orchestration/research-agents.js +5 -69
  40. package/dist/src/orchestration/research-agents.js.map +1 -1
  41. package/dist/src/panel/server.js +6 -0
  42. package/dist/src/panel/server.js.map +1 -1
  43. package/dist/src/style/cli-ui.d.ts +14 -0
  44. package/dist/src/style/cli-ui.js +45 -0
  45. package/dist/src/style/cli-ui.js.map +1 -1
  46. package/dist/src/tui/skill-manager.js +1 -1
  47. package/dist/src/tui/skill-manager.js.map +1 -1
  48. package/dist/src/updates/update.js +9 -3
  49. package/dist/src/updates/update.js.map +1 -1
  50. package/package.json +11 -3
  51. package/vendor/academic-paper-skills/LICENSE +21 -0
  52. package/vendor/academic-paper-skills/NOTICE.md +7 -0
  53. package/vendor/academic-paper-skills/PSYCLAW_SOURCE.json +14 -0
  54. package/vendor/academic-paper-skills/academic-paper-composer/SKILL.md +840 -0
  55. package/vendor/academic-paper-skills/academic-paper-composer/references/section_guides.md +675 -0
  56. package/vendor/academic-paper-skills/academic-paper-composer/references/writing_standards.md +629 -0
  57. package/vendor/academic-paper-skills/academic-paper-composer/scripts/chapter_quality_check.py +470 -0
  58. package/vendor/academic-paper-skills/academic-paper-composer/scripts/final_evaluation.py +550 -0
  59. package/vendor/academic-paper-skills/academic-paper-strategist/SKILL.md +670 -0
  60. package/vendor/academic-paper-skills/academic-paper-strategist/references/quality_standards.md +336 -0
  61. package/vendor/academic-paper-skills/academic-paper-strategist/references/search_strategy.md +459 -0
  62. package/vendor/academic-paper-skills/academic-paper-strategist/scripts/evaluate_samples.py +300 -0
  63. package/vendor/academic-paper-skills/academic-paper-strategist/scripts/gap_analysis.py +399 -0
  64. package/vendor/ars/pi/wrapper.js +9 -0
  65. package/vendor/nature-skills/LICENSE +201 -0
  66. package/vendor/nature-skills/NOTICE.md +7 -0
  67. package/vendor/nature-skills/PSYCLAW_SOURCE.json +19 -0
  68. package/vendor/nature-skills/skills/nature-figure/README.md +107 -0
  69. package/vendor/nature-skills/skills/nature-figure/README_EN.md +107 -0
  70. package/vendor/nature-skills/skills/nature-figure/SKILL.md +154 -0
  71. package/vendor/nature-skills/skills/nature-figure/agents/openai.yaml +4 -0
  72. package/vendor/nature-skills/skills/nature-figure/evals/evals.json +325 -0
  73. package/vendor/nature-skills/skills/nature-figure/manifest.yaml +103 -0
  74. package/vendor/nature-skills/skills/nature-figure/references/ai-graphical-abstract-workflow.md +129 -0
  75. package/vendor/nature-skills/skills/nature-figure/references/api.md +576 -0
  76. package/vendor/nature-skills/skills/nature-figure/references/asset-adaptation.md +72 -0
  77. package/vendor/nature-skills/skills/nature-figure/references/backend-selection.md +118 -0
  78. package/vendor/nature-skills/skills/nature-figure/references/chart-types.md +348 -0
  79. package/vendor/nature-skills/skills/nature-figure/references/common-patterns.md +371 -0
  80. package/vendor/nature-skills/skills/nature-figure/references/demos.md +58 -0
  81. package/vendor/nature-skills/skills/nature-figure/references/design-theory.md +467 -0
  82. package/vendor/nature-skills/skills/nature-figure/references/figure-contract.md +122 -0
  83. package/vendor/nature-skills/skills/nature-figure/references/figure-legend-conventions.md +90 -0
  84. package/vendor/nature-skills/skills/nature-figure/references/multipanel-evidence-architecture.md +268 -0
  85. package/vendor/nature-skills/skills/nature-figure/references/nature-2026-observations.md +124 -0
  86. package/vendor/nature-skills/skills/nature-figure/references/nature-article-requirements.md +149 -0
  87. package/vendor/nature-skills/skills/nature-figure/references/openrouter-image-generation.md +141 -0
  88. package/vendor/nature-skills/skills/nature-figure/references/qa-contract.md +344 -0
  89. package/vendor/nature-skills/skills/nature-figure/references/r-template-index.md +66 -0
  90. package/vendor/nature-skills/skills/nature-figure/references/r-workflow.md +234 -0
  91. package/vendor/nature-skills/skills/nature-figure/references/template-catalog.md +33 -0
  92. package/vendor/nature-skills/skills/nature-figure/references/tutorials.md +260 -0
  93. package/vendor/nature-skills/skills/nature-figure/requirements.txt +1 -0
  94. package/vendor/nature-skills/skills/nature-figure/scripts/audit_figure_collisions.py +742 -0
  95. package/vendor/nature-skills/skills/nature-figure/scripts/audit_panel_alignment.py +933 -0
  96. package/vendor/nature-skills/skills/nature-figure/scripts/audit_pdf_text.py +152 -0
  97. package/vendor/nature-skills/skills/nature-figure/scripts/figure_safety.py +50 -0
  98. package/vendor/nature-skills/skills/nature-figure/scripts/generate_openrouter_schematic.py +260 -0
  99. package/vendor/nature-skills/skills/nature-figure/scripts/nature_figure_backend.py +93 -0
  100. package/vendor/nature-skills/skills/nature-figure/scripts/panel_alignment.R +188 -0
  101. package/vendor/nature-skills/skills/nature-figure/scripts/plot_templates.py +604 -0
  102. package/vendor/nature-skills/skills/nature-figure/scripts/validate_figure.py +835 -0
  103. package/vendor/nature-skills/skills/nature-figure/static/core/contract.md +55 -0
  104. package/vendor/nature-skills/skills/nature-figure/static/core/stance.md +41 -0
  105. package/vendor/nature-skills/skills/nature-figure/static/fragments/backend/python.md +56 -0
  106. package/vendor/nature-skills/skills/nature-figure/static/fragments/backend/r.md +63 -0
  107. package/vendor/nature-skills/skills/nature-figure/tests/test_figure_safety.py +209 -0
  108. package/vendor/nature-skills/skills/nature-polishing/README.md +58 -0
  109. package/vendor/nature-skills/skills/nature-polishing/README_EN.md +58 -0
  110. package/vendor/nature-skills/skills/nature-polishing/SKILL.md +111 -0
  111. package/vendor/nature-skills/skills/nature-polishing/agents/openai.yaml +4 -0
  112. package/vendor/nature-skills/skills/nature-polishing/manifest.yaml +101 -0
  113. package/vendor/nature-skills/skills/nature-polishing/references/latex-layout.md +211 -0
  114. package/vendor/nature-skills/skills/nature-polishing/references/nat-comms-2025-diction.md +73 -0
  115. package/vendor/nature-skills/skills/nature-polishing/references/phrasebank-playbook.md +175 -0
  116. package/vendor/nature-skills/skills/nature-polishing/references/published-article-patterns.md +126 -0
  117. package/vendor/nature-skills/skills/nature-polishing/references/section-moves.md +252 -0
  118. package/vendor/nature-skills/skills/nature-polishing/references/style-guardrails.md +94 -0
  119. package/vendor/nature-skills/skills/nature-polishing/references/writing-strategy.md +160 -0
  120. package/vendor/nature-skills/skills/nature-polishing/static/core/failure-modes.md +29 -0
  121. package/vendor/nature-skills/skills/nature-polishing/static/core/output-format.md +21 -0
  122. package/vendor/nature-skills/skills/nature-polishing/static/core/stance.md +26 -0
  123. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/generic.md +17 -0
  124. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/nat-comms.md +38 -0
  125. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/nat-mach-intell.md +102 -0
  126. package/vendor/nature-skills/skills/nature-polishing/static/fragments/journal/nature.md +19 -0
  127. package/vendor/nature-skills/skills/nature-polishing/static/fragments/language/en.md +19 -0
  128. package/vendor/nature-skills/skills/nature-polishing/static/fragments/language/zh-to-en.md +19 -0
  129. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/algorithmic.md +18 -0
  130. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/hypothesis.md +17 -0
  131. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/methods.md +35 -0
  132. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/research.md +29 -0
  133. package/vendor/nature-skills/skills/nature-polishing/static/fragments/paper_type/review.md +17 -0
  134. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/abstract.md +26 -0
  135. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/conclusion.md +15 -0
  136. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/discussion.md +48 -0
  137. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/intro.md +33 -0
  138. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/methods.md +26 -0
  139. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/results.md +61 -0
  140. package/vendor/nature-skills/skills/nature-polishing/static/fragments/section/title.md +17 -0
  141. package/vendor/nature-skills/skills/nature-ref-verifier/README.md +44 -0
  142. package/vendor/nature-skills/skills/nature-ref-verifier/README_EN.md +44 -0
  143. package/vendor/nature-skills/skills/nature-ref-verifier/SKILL.md +196 -0
  144. package/vendor/nature-skills/skills/nature-ref-verifier/agents/openai.yaml +4 -0
  145. package/vendor/nature-skills/skills/nature-ref-verifier/manifest.yaml +19 -0
  146. package/vendor/nature-skills/skills/nature-ref-verifier/references/common-patterns.md +96 -0
  147. package/vendor/nature-skills/skills/nature-shared/README.md +43 -0
  148. package/vendor/nature-skills/skills/nature-shared/README_EN.md +43 -0
  149. package/vendor/nature-skills/skills/nature-shared/SKILL.md +33 -0
  150. package/vendor/nature-skills/skills/nature-shared/agents/openai.yaml +6 -0
  151. package/vendor/nature-skills/skills/nature-shared/core/consistency-sweep.md +122 -0
  152. package/vendor/nature-skills/skills/nature-shared/core/discussion-argument-language.md +192 -0
  153. package/vendor/nature-skills/skills/nature-shared/core/ethics.md +88 -0
  154. package/vendor/nature-skills/skills/nature-shared/core/main-text-discipline.md +179 -0
  155. package/vendor/nature-skills/skills/nature-shared/core/nature-abstract.md +171 -0
  156. package/vendor/nature-skills/skills/nature-shared/core/nature-introduction.md +164 -0
  157. package/vendor/nature-skills/skills/nature-shared/core/nature-results-discussion.md +215 -0
  158. package/vendor/nature-skills/skills/nature-shared/core/paper-type-taxonomy.md +41 -0
  159. package/vendor/nature-skills/skills/nature-shared/core/reader-workflow.md +21 -0
  160. package/vendor/nature-skills/skills/nature-shared/core/research-compliance.md +192 -0
  161. package/vendor/nature-skills/skills/nature-shared/core/terminology-ledger.md +58 -0
  162. package/vendor/nature-skills/skills/nature-shared/journal-formats/nat-comms.md +139 -0
  163. package/vendor/nature-skills/skills/nature-shared/journal-formats/nature-machine-intelligence.md +431 -0
  164. package/vendor/nature-skills/skills/nature-shared/journal-formats/nature.md +313 -0
  165. package/vendor/nature-skills/skills/nature-shared/manifest.yaml +52 -0
  166. package/vendor/nature-skills/skills/nature-shared/scripts/check_consistency.py +273 -0
  167. package/vendor/nature-skills/skills/nature-shared/tests/test_check_consistency.py +63 -0
@@ -0,0 +1,188 @@
1
+ # Render-time panel-alignment helper for R patchwork figures.
2
+ #
3
+ # Source this file from the selected R plotting script. It measures patchwork's
4
+ # final panel cells on a device with the same physical dimensions as the export,
5
+ # writes the backend-neutral JSON manifest consumed by audit_panel_alignment.py,
6
+ # and can run the blocking audit in one call.
7
+
8
+ .nature_alignment_groups <- function(groups) {
9
+ if (is.null(groups)) {
10
+ return(NULL)
11
+ }
12
+ lapply(groups, function(group) as.character(unlist(group, use.names = FALSE)))
13
+ }
14
+
15
+ .nature_alignment_panel_rows <- function(grob) {
16
+ rows <- grob$layout[grepl("^panel(?:-[0-9]+)?$", grob$layout$name, perl = TRUE), , drop = FALSE]
17
+ if (nrow(rows) < 2) {
18
+ stop("At least two patchwork panel cells are required for alignment QA", call. = FALSE)
19
+ }
20
+ rows[order(rows$t, rows$l), , drop = FALSE]
21
+ }
22
+
23
+ write_patchwork_panel_layout <- function(
24
+ plot,
25
+ manifest_path,
26
+ width_in,
27
+ height_in,
28
+ panel_ids = NULL,
29
+ row_groups = NULL,
30
+ column_groups = NULL,
31
+ exemptions = list()
32
+ ) {
33
+ for (package in c("patchwork", "grid", "jsonlite")) {
34
+ if (!requireNamespace(package, quietly = TRUE)) {
35
+ stop(sprintf("Package '%s' is required for patchwork alignment QA", package), call. = FALSE)
36
+ }
37
+ }
38
+ if (!is.numeric(width_in) || length(width_in) != 1 || !is.finite(width_in) || width_in <= 0 ||
39
+ !is.numeric(height_in) || length(height_in) != 1 || !is.finite(height_in) || height_in <= 0) {
40
+ stop("width_in and height_in must be positive finite numbers", call. = FALSE)
41
+ }
42
+
43
+ grob <- patchwork::patchworkGrob(plot)
44
+ panel_rows <- .nature_alignment_panel_rows(grob)
45
+ if (is.null(panel_ids)) {
46
+ panel_ids <- vapply(
47
+ seq_len(nrow(panel_rows)),
48
+ function(index) if (index <= length(letters)) letters[index] else paste0("panel-", index),
49
+ character(1)
50
+ )
51
+ }
52
+ panel_ids <- as.character(panel_ids)
53
+ if (length(panel_ids) != nrow(panel_rows) || anyDuplicated(panel_ids) || any(!nzchar(panel_ids))) {
54
+ stop("panel_ids must be unique, non-empty, and match the measured patchwork panels", call. = FALSE)
55
+ }
56
+
57
+ probe_path <- tempfile(fileext = ".pdf")
58
+ grDevices::pdf(probe_path, width = width_in, height = height_in, useDingbats = FALSE)
59
+ device_open <- TRUE
60
+ on.exit({
61
+ if (device_open) {
62
+ grDevices::dev.off()
63
+ }
64
+ unlink(probe_path)
65
+ }, add = TRUE)
66
+ grid::grid.newpage()
67
+ grid::grid.draw(grob)
68
+ grid::grid.force()
69
+
70
+ widths_pt <- grid::convertWidth(grob$widths, "pt", valueOnly = TRUE)
71
+ heights_pt <- grid::convertHeight(grob$heights, "pt", valueOnly = TRUE)
72
+ if (any(!is.finite(widths_pt)) || any(!is.finite(heights_pt))) {
73
+ stop("Patchwork panel dimensions could not be converted to physical points", call. = FALSE)
74
+ }
75
+ x_edges <- c(0, cumsum(widths_pt))
76
+ top_edges <- c(0, cumsum(heights_pt))
77
+ total_height_pt <- sum(heights_pt)
78
+
79
+ panels <- lapply(seq_len(nrow(panel_rows)), function(index) {
80
+ row <- panel_rows[index, ]
81
+ left <- x_edges[row$l]
82
+ right <- x_edges[row$r + 1]
83
+ top <- total_height_pt - top_edges[row$t]
84
+ bottom <- total_height_pt - top_edges[row$b + 1]
85
+ list(
86
+ id = panel_ids[index],
87
+ bbox_pt = unname(c(left, bottom, right, top)),
88
+ grid_id = "patchwork-grid-1",
89
+ row_start = as.integer(row$t - 1),
90
+ row_stop = as.integer(row$b),
91
+ col_start = as.integer(row$l - 1),
92
+ col_stop = as.integer(row$r)
93
+ )
94
+ })
95
+
96
+ manifest <- list(
97
+ schema_version = 1L,
98
+ backend = "r-patchwork",
99
+ figure = list(width_pt = width_in * 72, height_pt = height_in * 72),
100
+ panels = panels,
101
+ exemptions = exemptions
102
+ )
103
+ normalized_rows <- .nature_alignment_groups(row_groups)
104
+ normalized_columns <- .nature_alignment_groups(column_groups)
105
+ if (!is.null(normalized_rows)) {
106
+ manifest$row_groups <- normalized_rows
107
+ }
108
+ if (!is.null(normalized_columns)) {
109
+ manifest$column_groups <- normalized_columns
110
+ }
111
+
112
+ dir.create(dirname(manifest_path), recursive = TRUE, showWarnings = FALSE)
113
+ temporary_path <- tempfile(pattern = ".panel-layout-", tmpdir = dirname(manifest_path), fileext = ".json")
114
+ jsonlite::write_json(manifest, temporary_path, auto_unbox = TRUE, pretty = TRUE, digits = NA)
115
+ if (!file.rename(temporary_path, manifest_path)) {
116
+ unlink(temporary_path)
117
+ stop("Could not activate the patchwork alignment manifest atomically", call. = FALSE)
118
+ }
119
+
120
+ grDevices::dev.off()
121
+ device_open <- FALSE
122
+ unlink(probe_path)
123
+ invisible(manifest)
124
+ }
125
+
126
+ require_patchwork_panel_alignment <- function(
127
+ plot,
128
+ manifest_path,
129
+ report_path,
130
+ width_in,
131
+ height_in,
132
+ panel_ids = NULL,
133
+ row_groups = NULL,
134
+ column_groups = NULL,
135
+ exemptions = list(),
136
+ audit_script = "skills/nature-figure/scripts/audit_panel_alignment.py",
137
+ python = Sys.which("python"),
138
+ overlay_svg = NULL,
139
+ tolerance_pt = 1.5,
140
+ gutter_tolerance_pt = 1.5,
141
+ strict = TRUE
142
+ ) {
143
+ if (!nzchar(python)) {
144
+ stop("Python is required for the backend-neutral panel-alignment JSON audit", call. = FALSE)
145
+ }
146
+ if (!file.exists(audit_script)) {
147
+ stop(sprintf("Panel-alignment audit script not found: %s", audit_script), call. = FALSE)
148
+ }
149
+ write_patchwork_panel_layout(
150
+ plot = plot,
151
+ manifest_path = manifest_path,
152
+ width_in = width_in,
153
+ height_in = height_in,
154
+ panel_ids = panel_ids,
155
+ row_groups = row_groups,
156
+ column_groups = column_groups,
157
+ exemptions = exemptions
158
+ )
159
+
160
+ args <- c(
161
+ shQuote(audit_script),
162
+ shQuote(manifest_path),
163
+ "--json-out", shQuote(report_path),
164
+ "--tolerance-pt", format(tolerance_pt, scientific = FALSE),
165
+ "--gutter-tolerance-pt", format(gutter_tolerance_pt, scientific = FALSE)
166
+ )
167
+ if (!is.null(overlay_svg)) {
168
+ args <- c(args, "--overlay-svg", shQuote(overlay_svg))
169
+ }
170
+ if (isTRUE(strict)) {
171
+ args <- c(args, "--strict")
172
+ }
173
+ output <- suppressWarnings(system2(python, args = args, stdout = TRUE, stderr = TRUE))
174
+ status <- attr(output, "status")
175
+ if (is.null(status)) {
176
+ status <- 0L
177
+ }
178
+ if (length(output)) {
179
+ message(paste(output, collapse = "\n"))
180
+ }
181
+ if (status != 0L) {
182
+ stop(
183
+ sprintf("Panel alignment gate failed with exit code %d; inspect %s", status, report_path),
184
+ call. = FALSE
185
+ )
186
+ }
187
+ invisible(jsonlite::read_json(report_path, simplifyVector = TRUE))
188
+ }