psyclaw 0.24.0 → 0.25.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 (277) hide show
  1. package/README.md +46 -53
  2. package/{dist/apps → apps}/panel/index.html +28 -50
  3. package/package.json +10 -20
  4. package/scripts/__pycache__/build_dist.cpython-314.pyc +0 -0
  5. package/scripts/__pycache__/build_whitepaper_docx.cpython-314.pyc +0 -0
  6. package/scripts/build_preprint_docx.py +729 -0
  7. package/scripts/build_preprint_figures.py +238 -0
  8. package/scripts/build_three_line_table_fixture.py +56 -0
  9. package/scripts/build_whitepaper_docx.py +768 -0
  10. package/scripts/check-branding.mjs +159 -0
  11. package/scripts/copy-panel.mjs +11 -0
  12. package/scripts/rebrand-pi.mjs +292 -0
  13. package/scripts/verify_docx.py +41 -0
  14. package/skills/core/citation-audit/SKILL.md +9 -9
  15. package/skills/core/evidence-capture/SKILL.md +9 -9
  16. package/skills/core/manifest.json +15 -15
  17. package/skills/core/research-brief/SKILL.md +8 -8
  18. package/skills/core/research-intake/SKILL.md +9 -9
  19. package/dist/src/adapters/pi/extension.d.ts +0 -19
  20. package/dist/src/adapters/pi/extension.js +0 -735
  21. package/dist/src/adapters/pi/extension.js.map +0 -1
  22. package/dist/src/adapters/pi/model.d.ts +0 -72
  23. package/dist/src/adapters/pi/model.js +0 -152
  24. package/dist/src/adapters/pi/model.js.map +0 -1
  25. package/dist/src/adapters/pi/resources.d.ts +0 -23
  26. package/dist/src/adapters/pi/resources.js +0 -54
  27. package/dist/src/adapters/pi/resources.js.map +0 -1
  28. package/dist/src/adapters/pi/rpc.d.ts +0 -56
  29. package/dist/src/adapters/pi/rpc.js +0 -248
  30. package/dist/src/adapters/pi/rpc.js.map +0 -1
  31. package/dist/src/adapters/pi/session.d.ts +0 -30
  32. package/dist/src/adapters/pi/session.js +0 -64
  33. package/dist/src/adapters/pi/session.js.map +0 -1
  34. package/dist/src/agents/catalog.d.ts +0 -30
  35. package/dist/src/agents/catalog.js +0 -118
  36. package/dist/src/agents/catalog.js.map +0 -1
  37. package/dist/src/agents/discover.d.ts +0 -28
  38. package/dist/src/agents/discover.js +0 -127
  39. package/dist/src/agents/discover.js.map +0 -1
  40. package/dist/src/agents/import.d.ts +0 -67
  41. package/dist/src/agents/import.js +0 -801
  42. package/dist/src/agents/import.js.map +0 -1
  43. package/dist/src/analysis/hooks.d.ts +0 -81
  44. package/dist/src/analysis/hooks.js +0 -139
  45. package/dist/src/analysis/hooks.js.map +0 -1
  46. package/dist/src/analysis/pre-registration.d.ts +0 -18
  47. package/dist/src/analysis/pre-registration.js +0 -86
  48. package/dist/src/analysis/pre-registration.js.map +0 -1
  49. package/dist/src/branding.d.ts +0 -43
  50. package/dist/src/branding.js +0 -127
  51. package/dist/src/branding.js.map +0 -1
  52. package/dist/src/chat.d.ts +0 -16
  53. package/dist/src/chat.js +0 -67
  54. package/dist/src/chat.js.map +0 -1
  55. package/dist/src/cli.d.ts +0 -2
  56. package/dist/src/cli.js +0 -316
  57. package/dist/src/cli.js.map +0 -1
  58. package/dist/src/core/citations.d.ts +0 -44
  59. package/dist/src/core/citations.js +0 -48
  60. package/dist/src/core/citations.js.map +0 -1
  61. package/dist/src/core/contracts.d.ts +0 -119
  62. package/dist/src/core/contracts.js +0 -2
  63. package/dist/src/core/contracts.js.map +0 -1
  64. package/dist/src/core/docx.d.ts +0 -11
  65. package/dist/src/core/docx.js +0 -46
  66. package/dist/src/core/docx.js.map +0 -1
  67. package/dist/src/core/doi.d.ts +0 -41
  68. package/dist/src/core/doi.js +0 -82
  69. package/dist/src/core/doi.js.map +0 -1
  70. package/dist/src/core/evidence-policy.d.ts +0 -24
  71. package/dist/src/core/evidence-policy.js +0 -308
  72. package/dist/src/core/evidence-policy.js.map +0 -1
  73. package/dist/src/core/filekind.d.ts +0 -15
  74. package/dist/src/core/filekind.js +0 -82
  75. package/dist/src/core/filekind.js.map +0 -1
  76. package/dist/src/core/hash.d.ts +0 -2
  77. package/dist/src/core/hash.js +0 -17
  78. package/dist/src/core/hash.js.map +0 -1
  79. package/dist/src/core/pricing.d.ts +0 -38
  80. package/dist/src/core/pricing.js +0 -110
  81. package/dist/src/core/pricing.js.map +0 -1
  82. package/dist/src/core/redact.d.ts +0 -12
  83. package/dist/src/core/redact.js +0 -48
  84. package/dist/src/core/redact.js.map +0 -1
  85. package/dist/src/core/references.d.ts +0 -55
  86. package/dist/src/core/references.js +0 -102
  87. package/dist/src/core/references.js.map +0 -1
  88. package/dist/src/core/schemas.d.ts +0 -162
  89. package/dist/src/core/schemas.js +0 -160
  90. package/dist/src/core/schemas.js.map +0 -1
  91. package/dist/src/extension.d.ts +0 -1
  92. package/dist/src/extension.js +0 -2
  93. package/dist/src/extension.js.map +0 -1
  94. package/dist/src/index.d.ts +0 -72
  95. package/dist/src/index.js +0 -73
  96. package/dist/src/index.js.map +0 -1
  97. package/dist/src/install/installer.d.ts +0 -147
  98. package/dist/src/install/installer.js +0 -743
  99. package/dist/src/install/installer.js.map +0 -1
  100. package/dist/src/integrations/contracts.d.ts +0 -35
  101. package/dist/src/integrations/contracts.js +0 -27
  102. package/dist/src/integrations/contracts.js.map +0 -1
  103. package/dist/src/integrations/mcp.d.ts +0 -155
  104. package/dist/src/integrations/mcp.js +0 -826
  105. package/dist/src/integrations/mcp.js.map +0 -1
  106. package/dist/src/knowledge-map/contracts.d.ts +0 -20
  107. package/dist/src/knowledge-map/contracts.js +0 -2
  108. package/dist/src/knowledge-map/contracts.js.map +0 -1
  109. package/dist/src/knowledge-map/index.d.ts +0 -4
  110. package/dist/src/knowledge-map/index.js +0 -39
  111. package/dist/src/knowledge-map/index.js.map +0 -1
  112. package/dist/src/literature/contracts.d.ts +0 -106
  113. package/dist/src/literature/contracts.js +0 -2
  114. package/dist/src/literature/contracts.js.map +0 -1
  115. package/dist/src/literature/fulltext.d.ts +0 -7
  116. package/dist/src/literature/fulltext.js +0 -24
  117. package/dist/src/literature/fulltext.js.map +0 -1
  118. package/dist/src/literature/knowledge-map.d.ts +0 -2
  119. package/dist/src/literature/knowledge-map.js +0 -20
  120. package/dist/src/literature/knowledge-map.js.map +0 -1
  121. package/dist/src/literature/ledger.d.ts +0 -3
  122. package/dist/src/literature/ledger.js +0 -17
  123. package/dist/src/literature/ledger.js.map +0 -1
  124. package/dist/src/literature/metadata.d.ts +0 -6
  125. package/dist/src/literature/metadata.js +0 -32
  126. package/dist/src/literature/metadata.js.map +0 -1
  127. package/dist/src/memory/store.d.ts +0 -22
  128. package/dist/src/memory/store.js +0 -73
  129. package/dist/src/memory/store.js.map +0 -1
  130. package/dist/src/orchestration/contracts.d.ts +0 -61
  131. package/dist/src/orchestration/contracts.js +0 -2
  132. package/dist/src/orchestration/contracts.js.map +0 -1
  133. package/dist/src/orchestration/pi-executor.d.ts +0 -28
  134. package/dist/src/orchestration/pi-executor.js +0 -169
  135. package/dist/src/orchestration/pi-executor.js.map +0 -1
  136. package/dist/src/orchestration/runner.d.ts +0 -196
  137. package/dist/src/orchestration/runner.js +0 -991
  138. package/dist/src/orchestration/runner.js.map +0 -1
  139. package/dist/src/orchestration/scheduler.d.ts +0 -8
  140. package/dist/src/orchestration/scheduler.js +0 -335
  141. package/dist/src/orchestration/scheduler.js.map +0 -1
  142. package/dist/src/panel/events.d.ts +0 -20
  143. package/dist/src/panel/events.js +0 -93
  144. package/dist/src/panel/events.js.map +0 -1
  145. package/dist/src/panel/extension.d.ts +0 -8
  146. package/dist/src/panel/extension.js +0 -114
  147. package/dist/src/panel/extension.js.map +0 -1
  148. package/dist/src/panel/literature-map.d.ts +0 -26
  149. package/dist/src/panel/literature-map.js +0 -34
  150. package/dist/src/panel/literature-map.js.map +0 -1
  151. package/dist/src/panel/projection.d.ts +0 -51
  152. package/dist/src/panel/projection.js +0 -288
  153. package/dist/src/panel/projection.js.map +0 -1
  154. package/dist/src/panel/server.d.ts +0 -46
  155. package/dist/src/panel/server.js +0 -1610
  156. package/dist/src/panel/server.js.map +0 -1
  157. package/dist/src/panel/usage.d.ts +0 -53
  158. package/dist/src/panel/usage.js +0 -150
  159. package/dist/src/panel/usage.js.map +0 -1
  160. package/dist/src/project/bootstrap.d.ts +0 -10
  161. package/dist/src/project/bootstrap.js +0 -83
  162. package/dist/src/project/bootstrap.js.map +0 -1
  163. package/dist/src/project/hitl.d.ts +0 -12
  164. package/dist/src/project/hitl.js +0 -43
  165. package/dist/src/project/hitl.js.map +0 -1
  166. package/dist/src/project/jsonl.d.ts +0 -16
  167. package/dist/src/project/jsonl.js +0 -93
  168. package/dist/src/project/jsonl.js.map +0 -1
  169. package/dist/src/project/manuscript.d.ts +0 -21
  170. package/dist/src/project/manuscript.js +0 -74
  171. package/dist/src/project/manuscript.js.map +0 -1
  172. package/dist/src/project/paths.d.ts +0 -38
  173. package/dist/src/project/paths.js +0 -166
  174. package/dist/src/project/paths.js.map +0 -1
  175. package/dist/src/project/versions.d.ts +0 -10
  176. package/dist/src/project/versions.js +0 -14
  177. package/dist/src/project/versions.js.map +0 -1
  178. package/dist/src/psyclaw-theme.d.ts +0 -88
  179. package/dist/src/psyclaw-theme.js +0 -89
  180. package/dist/src/psyclaw-theme.js.map +0 -1
  181. package/dist/src/research/brief.d.ts +0 -11
  182. package/dist/src/research/brief.js +0 -81
  183. package/dist/src/research/brief.js.map +0 -1
  184. package/dist/src/research/ledger.d.ts +0 -12
  185. package/dist/src/research/ledger.js +0 -43
  186. package/dist/src/research/ledger.js.map +0 -1
  187. package/dist/src/run.d.ts +0 -20
  188. package/dist/src/run.js +0 -34
  189. package/dist/src/run.js.map +0 -1
  190. package/dist/src/setup.d.ts +0 -54
  191. package/dist/src/setup.js +0 -221
  192. package/dist/src/setup.js.map +0 -1
  193. package/dist/src/skills/contracts.d.ts +0 -105
  194. package/dist/src/skills/contracts.js +0 -3
  195. package/dist/src/skills/contracts.js.map +0 -1
  196. package/dist/src/skills/preflight.d.ts +0 -10
  197. package/dist/src/skills/preflight.js +0 -39
  198. package/dist/src/skills/preflight.js.map +0 -1
  199. package/dist/src/skills/registry.d.ts +0 -28
  200. package/dist/src/skills/registry.js +0 -556
  201. package/dist/src/skills/registry.js.map +0 -1
  202. package/dist/src/style/artifact.d.ts +0 -6
  203. package/dist/src/style/artifact.js +0 -61
  204. package/dist/src/style/artifact.js.map +0 -1
  205. package/dist/src/style/cli-ui.d.ts +0 -41
  206. package/dist/src/style/cli-ui.js +0 -119
  207. package/dist/src/style/cli-ui.js.map +0 -1
  208. package/dist/src/style/contracts.d.ts +0 -34
  209. package/dist/src/style/contracts.js +0 -2
  210. package/dist/src/style/contracts.js.map +0 -1
  211. package/dist/src/style/registry.d.ts +0 -16
  212. package/dist/src/style/registry.js +0 -50
  213. package/dist/src/style/registry.js.map +0 -1
  214. package/dist/src/trust/manifest.d.ts +0 -42
  215. package/dist/src/trust/manifest.js +0 -53
  216. package/dist/src/trust/manifest.js.map +0 -1
  217. package/dist/src/trust/sbom.d.ts +0 -54
  218. package/dist/src/trust/sbom.js +0 -77
  219. package/dist/src/trust/sbom.js.map +0 -1
  220. package/dist/src/tui/app.d.ts +0 -3
  221. package/dist/src/tui/app.js +0 -103
  222. package/dist/src/tui/app.js.map +0 -1
  223. package/dist/src/tui/model.d.ts +0 -13
  224. package/dist/src/tui/model.js +0 -25
  225. package/dist/src/tui/model.js.map +0 -1
  226. package/dist/src/updates/check.d.ts +0 -43
  227. package/dist/src/updates/check.js +0 -68
  228. package/dist/src/updates/check.js.map +0 -1
  229. package/dist/src/updates/manifest.d.ts +0 -19
  230. package/dist/src/updates/manifest.js +0 -58
  231. package/dist/src/updates/manifest.js.map +0 -1
  232. package/dist/src/updates/registry.d.ts +0 -21
  233. package/dist/src/updates/registry.js +0 -82
  234. package/dist/src/updates/registry.js.map +0 -1
  235. package/dist/src/updates/skills.d.ts +0 -15
  236. package/dist/src/updates/skills.js +0 -39
  237. package/dist/src/updates/skills.js.map +0 -1
  238. package/dist/src/updates/status.d.ts +0 -7
  239. package/dist/src/updates/status.js +0 -37
  240. package/dist/src/updates/status.js.map +0 -1
  241. package/dist/src/updates/update.d.ts +0 -43
  242. package/dist/src/updates/update.js +0 -126
  243. package/dist/src/updates/update.js.map +0 -1
  244. package/dist/src/wizard.d.ts +0 -7
  245. package/dist/src/wizard.js +0 -90
  246. package/dist/src/wizard.js.map +0 -1
  247. package/dist/src/workflows/analysis-delegation.d.ts +0 -3
  248. package/dist/src/workflows/analysis-delegation.js +0 -96
  249. package/dist/src/workflows/analysis-delegation.js.map +0 -1
  250. package/dist/src/workflows/expert-review-runner.d.ts +0 -29
  251. package/dist/src/workflows/expert-review-runner.js +0 -35
  252. package/dist/src/workflows/expert-review-runner.js.map +0 -1
  253. package/dist/src/workflows/expert-review.d.ts +0 -140
  254. package/dist/src/workflows/expert-review.js +0 -111
  255. package/dist/src/workflows/expert-review.js.map +0 -1
  256. package/dist/src/workflows/institutional-fulltext.d.ts +0 -16
  257. package/dist/src/workflows/institutional-fulltext.js +0 -110
  258. package/dist/src/workflows/institutional-fulltext.js.map +0 -1
  259. package/dist/src/workflows/literature-review.d.ts +0 -3
  260. package/dist/src/workflows/literature-review.js +0 -76
  261. package/dist/src/workflows/literature-review.js.map +0 -1
  262. package/dist/src/workflows/meta-analysis.d.ts +0 -38
  263. package/dist/src/workflows/meta-analysis.js +0 -185
  264. package/dist/src/workflows/meta-analysis.js.map +0 -1
  265. package/dist/src/workflows/publish.d.ts +0 -51
  266. package/dist/src/workflows/publish.js +0 -153
  267. package/dist/src/workflows/publish.js.map +0 -1
  268. package/dist/src/workflows/spec.d.ts +0 -51
  269. package/dist/src/workflows/spec.js +0 -157
  270. package/dist/src/workflows/spec.js.map +0 -1
  271. package/dist/src/workflows/style-contract.d.ts +0 -24
  272. package/dist/src/workflows/style-contract.js +0 -23
  273. package/dist/src/workflows/style-contract.js.map +0 -1
  274. package/dist/src/workflows/writing-review.d.ts +0 -15
  275. package/dist/src/workflows/writing-review.js +0 -82
  276. package/dist/src/workflows/writing-review.js.map +0 -1
  277. package/package.json.psyclaw +0 -21
@@ -1,127 +0,0 @@
1
- import { mkdir, readFile, writeFile } from "node:fs/promises";
2
- import { dirname, join } from "node:path";
3
- import { getAgentDir } from "@earendil-works/pi-coding-agent";
4
- import { readPsyClawVersionSync } from "./updates/manifest.js";
5
- import { PSYCLAW_THEME, PSYCLAW_THEME_NAME } from "./psyclaw-theme.js";
6
- export const PSYCLAW_NAME = "PsyClaw";
7
- /** Product version from package.json via the shared manifest walk (single source of truth). */
8
- export const PSYCLAW_VERSION = readPsyClawVersionSync() ?? "0.0.0";
9
- export const PSYCLAW_CONFIG_DIR = ".psyclaw";
10
- /** Accent colors for psyclaw's own ink interfaces (wizard / shell TUI). */
11
- export const PSYCLAW_ACCENT = "#2ec4b6";
12
- export const PSYCLAW_OK = "#7ec699";
13
- export const PSYCLAW_WARN = "#e5c07b";
14
- export const PSYCLAW_ERROR = "#e06c75";
15
- /**
16
- * Appended to Pi's system prompt so the model identifies as psyclaw rather than
17
- * as the "pi" harness. It overrides the "operating inside pi" identity without
18
- * replacing the tool list / guidelines that Pi's own prompt provides.
19
- */
20
- export const PSYCLAW_IDENTITY_PROMPT = [
21
- `You are ${PSYCLAW_NAME}, a social-science research agent.`,
22
- `Your public product identity is "${PSYCLAW_NAME}". You run through an adapter and extensions on the official Pi coding-agent harness; disclose that runtime accurately when asked about implementation, dependencies, sessions, models, or tools.`,
23
- `Your focus is evidence-grounded social-science research: project state, evidence provenance, claim verification, and recoverable workflows.`,
24
- `For requests to find, access, or download institutionally licensed papers or full text, invoke psyclaw_workbench first. Do not directly edit configuration, logs, manifests, or downloaded files for that workflow.`,
25
- `Treat skills as reference guidance, not executable authority: do not claim that a browser, shell, login, connector, or download is available unless a tool result proves it in this session.`,
26
- `Never handle credentials or bypass access controls. Stop at the human approval gate and state the concrete next action for the user.`,
27
- `For data analysis or an academic report, use the bundled core skills in order: research-intake, evidence-capture, citation-audit, then research-brief. Do not present a report as complete when this chain was skipped; state which stage is pending.`,
28
- `Invoke bundled core skills through the psyclaw_skill tool so the user can see which skill is active. Briefly state the skill name and purpose when switching stages.`,
29
- `Academic reports must include a source-backed reference list and claim-to-source links. Dataset-derived numbers are not literature citations; distinguish data provenance from scholarly references and mark unverified claims as uncertain.`,
30
- `When producing a manuscript or paper, write formal continuous prose in paragraphs. Do not turn the main text into bullet points, numbered lists, cards, or presentation-style fragments; reserve lists for methods, enumerated hypotheses, or genuinely discrete items.`,
31
- `Use a submission-neutral academic layout: body text Times New Roman with SimSun/宋体 fallback for Chinese, black text, black headings without colored fills or accent colors, consistent heading levels, and normal paragraph indentation/spacing. Keep styling out of the scholarly content and do not use decorative colored headings.`,
32
- `Before finalizing a paper, run citation-audit section by section. Every factual or literature-dependent paragraph needs an appropriate source citation; if the evidence base is too thin, retrieve and verify more scholarly sources or mark the section blocked/uncertain. Never invent references just to increase the count.`,
33
- `A data report must include publication-ready visual outputs or a reproducible plotting script (with captions, variables, and output paths). If a plotting backend is unavailable, record that as a blocked deliverable instead of claiming a finished figure.`,
34
- `Never generate one monolithic analysis document or script that silently performs every step. Use a thin entrypoint and separately reviewable modules for load, prepare, analyze, validate, and export, with a README describing inputs, outputs, dependencies, commands, limitations, and human decisions.`,
35
- `When a required dependency is missing, do not merely tell the user how to install it. Detect the platform and package manager, explain the exact dependency and command, request approval for the machine/network side effect, then use bash to install it, verify its executable/version, and write a structured dependency receipt. Ask the user to intervene only for credentials, licensing, administrator elevation, or an unavailable package source.`,
36
- `For Markdown-to-DOCX export, check for Pandoc first; if it is unavailable, install it after approval and retry. Use python-docx only when a Pandoc installation has actually failed. Do not present manual Word conversion as the primary solution.`,
37
- `When a piece of evidence or a source is a Word or Office document (.docx, .xlsx, .pptx), convert it to Markdown or plain text before reading it (use pandoc, or the markitdown skill if it is installed). Never try to read the raw binary. Record the extracted text together with the original file hash and locator so the claim-evidence link stays traceable to the original file.`,
38
- `Deliverable order for academic output: first produce a Markdown analysis report and tell the reader that the recommended flow is to review the analysis report first, then export DOCX from it. Only convert to DOCX after the reader confirms.`,
39
- `DOCX export defaults to APA 7 format. Before exporting, ask the reader for their preferred citation/output format (APA 7 is the default) and any submission requirements.`,
40
- `Manuscript deliverables always land at the convention locations (docs/文档规范.md): the editable Markdown source goes to paper/<name>.md and the APA-7 DOCX export to paper/<name>_APA7.docx. Publish through the psyclaw publish workflow (/api/publish, the psyclaw_workbench 发布 intent, or run pandoc yourself with --reference-doc) so both files are registered in the evidence ledger with SHA-256 fingerprints. Never leave the paper only in outputs/ or the project root: the panel recognizes paper/ as the manuscript location and can import/export it. While editing, keep the working copy in notes/manuscript.md; publish to paper/ when finalizing.`,
41
- `Every figure and table must be embedded in the document body, never only mentioned: write the Markdown with image links such as \`![Figure N caption](outputs/figures/figX.png)\` so the DOCX contains the images inline. Never deliver a document whose figures appear only as text references.`,
42
- `The exported DOCX must contain no colors: headings, body, and tables all black on white. Use Pandoc with a plain black-and-white reference document (for example \`--reference-doc\` pointing to a colorless template), or post-process with python-docx to force black. Never let Pandoc's default colored heading styles leak into the document.`,
43
- `Keep every analysis script, including the entry point, inside analysis/scripts/ (or the project's agreed scripts directory such as src/). Never create .py, .r, or .m files in the project root.`,
44
- `A manuscript must carry at least about 20 references. Before writing, ask the reader for the target reference count and scope (default: at least 20 verifiable scholarly sources), then retrieve and verify enough real sources through the citation/literature pipeline. Never pad the list with invented entries.`,
45
- `Verify every reference twice through the DOI: first resolve the correct DOI for each entry (Crossref search by title and authors), then reverse-verify by looking that DOI up in Crossref and confirming that title, authors, year, journal, volume, and pages all match; any DOI that resolves to a different paper is a critical error and must be corrected or the reference dropped, and entries that cannot be verified through a DOI must be explicitly flagged as unverified, never kept silently. Cross-verify references against at least two independent sources, not Crossref alone: for each entry, resolve the DOI in Crossref and cross-check the same DOI in a second source such as Semantic Scholar (api.semanticscholar.org/graph/v1/paper/DOI:<doi>) or OpenAlex (api.openalex.org/works/doi:<doi>); treat a reference as verified only when at least two sources agree on title, authors, and year, record every source consulted in the verification ledger, and never mark a reference verified on the strength of Crossref alone.`,
46
- `After the reference list is final, export it next to the paper as references.ris (importable by Zotero, EndNote, and RefWorks) AND as references.md formatted as an APA 7 reference list — one hanging-indent entry per line, never a table. Every entry must follow: Author, A. A., & Author, B. B. (Year). Title of the article. Journal Name, Volume(Issue), Pages. https://doi.org/... ; list 1-20 authors in full (APA 7), use an ellipsis for 21+; never include "et al." inside the author list and never leave empty authors, empty volume/issue, duplicated article numbers, or "e82503-e82503"-style page duplication. Every row must come from the verification ledger, never re-typed from memory, and must match the in-text citations one to one.`,
47
- `Every time you add an in-text citation while writing the manuscript, record it through the psyclaw_cite tool with the DOI, a one-line reason for citing it at that position, and the sentence context. The system verifies the DOI against Crossref/OpenAlex, archives the reference in .psyclaw/references.jsonl, and appends the citation use with its reason to .psyclaw/citations.jsonl. Never add a citation without registering its reason: the archive must be able to answer "why is this source cited here" for every citation.`,
48
- `Figure generation is a top priority: produce every figure through a dedicated figure skill (nature-figure, or smartplot from the recommended catalog when installed) instead of hand-rolling matplotlib defaults, and ask the reader whether to install the figure skill when it is not available. Prefer richer charts when the data supports them: forest plots with 95% CI for regression/effect sizes, correlation heatmaps, violin + swarm plots for group comparisons, dumbbell/lollipop charts, radar profiles for dimension structures, waterfall plots, and residual diagnostics (QQ plot, fitted-vs-residual) — a bare ax.bar of means is not acceptable when a richer chart fits the data. For mediation/path/SEM diagrams use a dedicated tool (Python graphviz dot, R semPlot/lavaan, or semopy semplot), never hand-drawn matplotlib boxes. All figures share one style configuration: 300 DPI PNG plus editable SVG (matplotlib savefig(format="svg"); graphviz format="svg") so the reader can edit shapes and text in PowerPoint/Word/Illustrator, consistent palette and fonts, label sizes ≥9pt, value annotations, correct aspect ratios, no clipped labels, no matplotlib default styling. Because you cannot visually inspect images, validate figures programmatically (size, non-blank content, no overflow warnings) and rely on the figure skill's deterministic output, then embed every figure in the report and the DOCX.`,
49
- `Figures must contain NO Chinese text — no Chinese titles, axis labels, legends, or notes inside the image (Chinese fonts render inconsistently across systems). Use English labels and English notes inside the figure (e.g. "Pearson r", "*p<0.05"); put the figure title and any Chinese explanation as caption text ABOVE or BELOW the figure in the manuscript (a "**图N ...**" line or a markdown image caption), never as set_title inside the image; map Chinese variable names to short English labels inside the figure and give the Chinese names in the caption. Figure colors must be deliberate and attractive, never matplotlib defaults: categorical series use a high-distinction palette such as Okabe-Ito (#0072B2, #D55E00, #009E73, #CC79A7, #56B4E9, #E69F00, #F0E442, #000000); continuous values use RdBu_r / viridis / coolwarm with a colorbar; add value annotations, significance stars, subtle transparency and error bars/CI whiskers with clear styles; avoid grayish corporate colors as the only palette and avoid clashing raw primaries.`,
50
- `Never include a cost or token-usage estimate section (such as "成本估算") in the analysis report, paper, or delivery summary; token usage and cost are tracked in the psyclaw panel's Token usage view instead.`,
51
- `Heavy research stages — literature search and multi-source verification, full-manuscript writing, DOCX export — consume significant tokens and minutes. Before starting one, tell the user the expected cost and time (rough estimate from context size and output size), mention cheaper alternatives (narrower scope, staged runs, fresh session per stage), and wait for confirmation. Never silently start a high-cost stage.`,
52
- `Tables in the report, manuscript, and DOCX must be three-line tables (三线表): top and bottom rules 1.5pt (OOXML sz=12), the header-row bottom rule 0.5pt (sz=4), and nothing else — no vertical rules, no other inner horizontal rules, no shading. Apply this by customizing the table style in the Pandoc reference document (or with python-docx) to keep only the top, header-bottom, and bottom borders, and after DOCX export run the three-line postprocess script (analysis/scripts/postprocess_docx.py) and verify the borders actually changed. Wide tables (>6 columns or >20 rows) must use 9pt table text and a landscape section when needed; never ship a table that overflows the page. Before exporting any table, replace NaN/Inf with a dash (—) and explain the gap in a footnote; a nan value in a deliverable is a bug.`,
53
- `Write the abstract in a structured academic format with 目的/方法/结果/结论 sections. Results must carry the data: means±SD, rates, and test statistics with 95% CI or effect sizes where applicable. The conclusion must connect to policy implications and state limitations (e.g. single-center sampling, cross-sectional design cannot infer causality). Keywords: 3-6 standard terms including the research method.`,
54
- `Manage token and time cost: redirect command output to log files and read only the needed lines instead of letting full output into context; write long documents section by section (roughly 2-4K tokens each) rather than one giant generation; make analysis scripts print summaries only; never read large JSON artifacts (literature candidates, verification ledgers) wholesale — grep the fields you need; in a long session, proactively propose compaction or a fresh staged session once the context grows large.`,
55
- `Keep tool calls lean — every round-trip grows the cached context that every later turn re-reads, so a single session should stay under roughly 40-60 tool calls. Concrete discipline: (1) explore a dataset ONCE with a reusable script that writes a compact profile (shapes, dtypes, missing, ranges) to a JSON, then read/grep that JSON instead of running repeated inline python -c probes — 50+ ad-hoc probes in one session is the single biggest token waste; (2) run the analysis pipeline through the thin entrypoint (run_all.py) and on failure rerun only the failed step, never re-run passing steps; (3) batch related checks into one command with && / ; and reuse the script's saved outputs instead of recomputing; (4) verify writes by exit code, not by ls/cat round-trips; (5) read each file at most once and keep the result; (6) prefer one complete write over many small edits.`,
56
- `When you generate a document that encodes a decision needing human calibration or review (data cleaning and exclusion rules, reverse-scoring or recoding maps, variable mappings, missing-data handling, an assumption you chose, or any claim marked uncertain), flag it AT GENERATION TIME: write a machine-readable marker in the file itself (for example a frontmatter field needs-human-review: true with a one-line reason) and list the file in the delivery summary under a "需人工校准" heading. Never leave such a document unflagged for the reader to discover later.`,
57
- `Before invoking any writing skill (nature-writing, nature-polishing, writing-review, nature-paper2ppt, researchwrite, or similar), ask the reader which writing skill to use instead of picking one automatically.`,
58
- `Before invoking any skill, confirm it is actually available in this session: check whether it is loaded or enabled (for example via .psyclaw/recommendations.json or the panel's enabled-capabilities endpoint), and only invoke it when a tool result proves it works. Never invoke, or claim to have invoked, a skill that is not present.`,
59
- `Match the task to the single best-fitting skill and state that choice. If a suitable skill exists in psyclaw's recommended catalog (skills/recommended/catalog.json, also served at /api/recommended-skills) but is not yet installed or enabled, ask the reader whether to install it before proceeding and offer the install command or the panel; do not silently continue without the capability and do not substitute an unrelated skill. If several skills plausibly fit, ask the reader to pick rather than guessing.`,
60
- `Rule precedence: the never-fabricate and never-bypass constraints (never invent references, statistics, findings, or review opinions; never skip an evidence gate or approval) always win over any convenience or efficiency consideration; when two rules seem to conflict, the more specific rule wins and, where still ambiguous, choose the behavior that keeps claims verifiable and the user informed.`,
61
- ].join("\n");
62
- /**
63
- * Set `quietStartup` in the psyclaw agent settings. Defaults to `false` so Pi's
64
- * native header ("psyclaw v<version>", keybinding hints, loaded resources) stays
65
- * visible on startup, imitating the official pi banner; set `PSYCLAW_QUIET_STARTUP=1`
66
- * (or pass `quiet: true`) to hide it behind the ctrl+o expander instead.
67
- * Merges with any existing settings instead of clobbering.
68
- */
69
- export async function ensureQuietStartup(settingsPath, quiet = process.env.PSYCLAW_QUIET_STARTUP === "1") {
70
- const path = settingsPath ?? join(getAgentDir(), "settings.json");
71
- let existing = {};
72
- try {
73
- const parsed = JSON.parse(await readFile(path, "utf8"));
74
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
75
- existing = parsed;
76
- }
77
- }
78
- catch {
79
- existing = {};
80
- }
81
- if (existing.quietStartup === quiet) {
82
- return { path, wrote: false };
83
- }
84
- await mkdir(dirname(path), { recursive: true });
85
- await writeFile(path, `${JSON.stringify({ ...existing, quietStartup: quiet }, null, 2)}\n`, "utf8");
86
- return { path, wrote: true };
87
- }
88
- /**
89
- * Install the psyclaw theme into Pi's custom themes directory and set it as the
90
- * default theme. Pi auto-discovers custom themes under `<agentDir>/themes`, so
91
- * no `--theme` flag is needed; the `theme` setting resolves by name on startup
92
- * and gracefully falls back to dark if the file is missing.
93
- */
94
- export async function ensurePsyClawTheme(options = {}) {
95
- const themesDir = options.themesDir ?? join(getAgentDir(), "themes");
96
- const themePath = join(themesDir, `${PSYCLAW_THEME_NAME}.json`);
97
- const settingsPath = options.settingsPath ?? join(getAgentDir(), "settings.json");
98
- const expected = `${JSON.stringify(PSYCLAW_THEME, null, 2)}\n`;
99
- let wroteTheme = false;
100
- try {
101
- wroteTheme = (await readFile(themePath, "utf8")) !== expected;
102
- }
103
- catch {
104
- wroteTheme = true;
105
- }
106
- if (wroteTheme) {
107
- await mkdir(themesDir, { recursive: true });
108
- await writeFile(themePath, expected, "utf8");
109
- }
110
- let existing = {};
111
- try {
112
- const parsed = JSON.parse(await readFile(settingsPath, "utf8"));
113
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
114
- existing = parsed;
115
- }
116
- }
117
- catch {
118
- existing = {};
119
- }
120
- const wroteSetting = existing.theme !== PSYCLAW_THEME_NAME;
121
- if (wroteSetting) {
122
- await mkdir(dirname(settingsPath), { recursive: true });
123
- await writeFile(settingsPath, `${JSON.stringify({ ...existing, theme: PSYCLAW_THEME_NAME }, null, 2)}\n`, "utf8");
124
- }
125
- return { themePath, settingsPath, wroteTheme, wroteSetting };
126
- }
127
- //# sourceMappingURL=branding.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"branding.js","sourceRoot":"","sources":["../../src/branding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEvE,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AAEtC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,eAAe,GAAW,sBAAsB,EAAE,IAAI,OAAO,CAAC;AAE3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAE7C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,WAAW,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KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,MAAM,SAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,QAAQ,GAA4B,EAAE,CAAC;IAC3C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAY,CAAC;QAC3E,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACnE,QAAQ,GAAG,MAAiC,CAAC;QAC/C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,QAAQ,GAAG,EAAE,CAAC;IAChB,CAAC;IACD,MAAM,YAAY,GAAG,QAAQ,CAAC,KAAK,KAAK,kBAAkB,CAAC;IAC3D,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACxD,MAAM,SAAS,CAAC,YAAY,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC;AAC/D,CAAC"}
@@ -1,16 +0,0 @@
1
- export interface ChatLaunchOptions {
2
- /** Extra args forwarded verbatim to the Pi CLI. */
3
- args?: string[];
4
- cwd?: string;
5
- /** Override the psyclaw extension entry (defaults to the built extension). */
6
- extensionPath?: string;
7
- /** Override the psyclaw skill directory (defaults to the bundled skills). */
8
- skillsPath?: string;
9
- }
10
- /**
11
- * Launch the bundled Pi interactive chat with psyclaw's extension and skills
12
- * loaded explicitly. This is the "download psyclaw and talk" entrypoint: the
13
- * user gets Pi's full conversation TUI plus psyclaw's research workflow
14
- * commands and model-callable tools. Developer-only commands remain hidden.
15
- */
16
- export declare function launchChat(options?: ChatLaunchOptions): Promise<number>;
package/dist/src/chat.js DELETED
@@ -1,67 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { readFile } from "node:fs/promises";
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { PSYCLAW_IDENTITY_PROMPT } from "./branding.js";
6
- /** Package root of the installed psyclaw package (dist/src/chat.js -> root). */
7
- function packageRoot() {
8
- return join(dirname(fileURLToPath(import.meta.url)), "..", "..");
9
- }
10
- /** Resolve the bundled Pi CLI shipped as a dependency of psyclaw. */
11
- function resolvePiCli() {
12
- try {
13
- // The Pi package is ESM-only (its `exports` map has only an `import`
14
- // condition), so we resolve through `import.meta.resolve` rather than a
15
- // CommonJS require. The CLI (`dist/cli.js`) sits beside `dist/index.js`.
16
- const entryUrl = import.meta.resolve("@earendil-works/pi-coding-agent");
17
- return join(dirname(fileURLToPath(entryUrl)), "cli.js");
18
- }
19
- catch {
20
- throw new Error("Cannot locate the bundled Pi CLI (@earendil-works/pi-coding-agent). Run `pnpm install` or `npm install` first.");
21
- }
22
- }
23
- /**
24
- * Launch the bundled Pi interactive chat with psyclaw's extension and skills
25
- * loaded explicitly. This is the "download psyclaw and talk" entrypoint: the
26
- * user gets Pi's full conversation TUI plus psyclaw's research workflow
27
- * commands and model-callable tools. Developer-only commands remain hidden.
28
- */
29
- export async function launchChat(options = {}) {
30
- const piCli = resolvePiCli();
31
- const root = packageRoot();
32
- const extensionPath = options.extensionPath ?? join(root, "dist", "src", "extension.js");
33
- const panelExtensionPath = join(root, "dist", "src", "panel", "extension.js");
34
- const skillsPath = options.skillsPath ?? join(root, "skills", "core");
35
- const developerMode = process.env.PSYCLAW_DEVELOPER_COMMANDS === "1";
36
- const toolAllowlist = developerMode
37
- ? "read,grep,find,ls,edit,write,bash,psyclaw_skill,psyclaw_workbench"
38
- : "read,grep,find,ls,edit,write,bash,psyclaw_skill,psyclaw_workbench";
39
- // The base identity is fixed; the user may only append a project supplement
40
- // (managed from the panel), never rewrite the base.
41
- let identityPrompt = PSYCLAW_IDENTITY_PROMPT;
42
- try {
43
- const supplement = (await readFile(join(options.cwd ?? process.cwd(), ".psyclaw", "system-prompt.md"), "utf8")).trim();
44
- if (supplement)
45
- identityPrompt = `${identityPrompt}\n\n${supplement}`;
46
- }
47
- catch { /* no user supplement */ }
48
- const args = ["--extension", extensionPath, "--extension", panelExtensionPath, "--skill", skillsPath, "--tools", toolAllowlist, "--append-system-prompt", identityPrompt, ...(options.args ?? [])];
49
- const spawnEnv = {
50
- ...process.env,
51
- PI_SKIP_VERSION_CHECK: process.env.PI_SKIP_VERSION_CHECK ?? "1",
52
- };
53
- return new Promise((resolve, reject) => {
54
- const child = spawn(process.execPath, [piCli, ...args], {
55
- cwd: options.cwd ?? process.cwd(),
56
- stdio: "inherit",
57
- shell: false,
58
- // psyclaw owns the update surface (`psyclaw check-updates` / `psyclaw update`),
59
- // so silence Pi's own "new version available" banner to avoid a second
60
- // prompt. An explicit env override still wins.
61
- env: spawnEnv,
62
- });
63
- child.on("error", reject);
64
- child.on("close", (code) => resolve(code ?? 1));
65
- });
66
- }
67
- //# sourceMappingURL=chat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chat.js","sourceRoot":"","sources":["../../src/chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,gFAAgF;AACh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AC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/src/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/src/cli.js DELETED
@@ -1,316 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawn } from "node:child_process";
3
- import { lstat, readFile } from "node:fs/promises";
4
- import { basename, resolve } from "node:path";
5
- import { asProject, assertEvidenceImportable, bootstrapProject, discoverAgents, FileInstallLedger, hasConfiguredProvider, importAgentSkills, KNOWN_AGENTS, launchChat, planAgentInstall, projectPaths, runInstall, runOfflineBrief, setupProviders, sha256File, writeHandoff, initializeHitlWorkspace, } from "./index.js";
6
- import { appendJsonlIfMissing } from "./project/jsonl.js";
7
- import { access } from "node:fs/promises";
8
- import { formatCliUsage, renderSuccessCard, c } from "./style/cli-ui.js";
9
- const PARADIGMS = new Set([
10
- "survey-observational",
11
- "qualitative-thematic",
12
- "experimental",
13
- "quasi-experimental",
14
- "longitudinal-panel",
15
- "meta-analysis",
16
- "ethnographic",
17
- "historical-documentary",
18
- "policy-legal",
19
- "mixed-methods",
20
- ]);
21
- function usage() {
22
- return formatCliUsage();
23
- }
24
- function option(args, name, fallback) {
25
- const index = args.indexOf(name);
26
- if (index < 0)
27
- return fallback;
28
- const value = args[index + 1];
29
- if (!value || value.startsWith("--"))
30
- throw new Error(`Option ${name} requires a value`);
31
- return value;
32
- }
33
- const INSTALL_ENV_NAMES = ["PATH", "Path", "SystemRoot", "WINDIR", "ComSpec", "TEMP", "TMP", "PATHEXT"];
34
- function installEnvironment() {
35
- const env = {};
36
- for (const name of INSTALL_ENV_NAMES) {
37
- const value = process.env[name];
38
- if (value !== undefined)
39
- env[name] = value;
40
- }
41
- return env;
42
- }
43
- function spawnCommand(command, inherit) {
44
- const [bin, ...rest] = command.split(/\s+/).filter(Boolean);
45
- return new Promise((resolve) => {
46
- const child = spawn(bin, rest, { stdio: inherit ? "inherit" : "ignore", shell: false, env: installEnvironment() });
47
- child.on("error", () => resolve({ exitCode: 1 }));
48
- child.on("close", (code) => resolve({ exitCode: code ?? 1 }));
49
- });
50
- }
51
- /**
52
- * Run a package-manager command in a fixed directory. Unlike `spawnCommand`,
53
- * this one sets `cwd` and — on Windows only — uses a shell so `pnpm`/`npm`
54
- * resolve through their `.cmd` shims. The command string is built by
55
- * `updateBundledPi` from a strictly-validated semver and hardcoded package
56
- * names, so shell interpretation is safe.
57
- */
58
- function runPackageManager(command, cwd) {
59
- const [bin, ...rest] = command.split(/\s+/).filter(Boolean);
60
- return new Promise((resolve) => {
61
- const child = spawn(bin, rest, {
62
- cwd,
63
- stdio: "inherit",
64
- shell: process.platform === "win32",
65
- env: installEnvironment(),
66
- });
67
- child.on("error", () => resolve({ exitCode: 1 }));
68
- child.on("close", (code) => resolve({ exitCode: code ?? 1 }));
69
- });
70
- }
71
- function assertKnownOptions(args, allowed) {
72
- const allowedSet = new Set(allowed);
73
- for (const [index, arg] of args.entries()) {
74
- if (!arg.startsWith("--"))
75
- continue;
76
- if (!allowedSet.has(arg))
77
- throw new Error(`Unknown option: ${arg}`);
78
- if (index + 1 >= args.length || args[index + 1]?.startsWith("--")) {
79
- throw new Error(`Option ${arg} requires a value`);
80
- }
81
- }
82
- }
83
- async function addEvidence(root, args) {
84
- await access(projectPaths(root).project);
85
- assertKnownOptions(args, ["--level"]);
86
- const source = args[0];
87
- if (!source)
88
- throw new Error("Usage: psyclaw evidence add <path> [--level fulltext|user]");
89
- // Evidence imports are read-only and may point outside the project; the
90
- // symlink check below prevents silently following an indirection.
91
- const sourcePath = resolve(root, source);
92
- const stat = await lstat(sourcePath);
93
- if (stat.isSymbolicLink())
94
- throw new Error("Evidence symlinks are rejected; import the real file explicitly");
95
- if (!stat.isFile())
96
- throw new Error("Evidence source must be a regular file");
97
- const level = option(args, "--level", "user");
98
- if (level !== "fulltext" && level !== "user")
99
- throw new Error(`Unsupported evidence level: ${level}`);
100
- const optionTail = args.slice(1);
101
- if (optionTail.length !== 0 && (optionTail.length !== 2 || optionTail[0] !== "--level")) {
102
- throw new Error("Usage: psyclaw evidence add <path> [--level fulltext|user]");
103
- }
104
- // Reject HTML/binary/empty content masquerading as a full-text document.
105
- await assertEvidenceImportable(sourcePath, level);
106
- const digest = await sha256File(sourcePath);
107
- const evidence = {
108
- id: `evidence_${digest.slice(0, 16)}`,
109
- source: { kind: "file", locator: sourcePath, title: basename(sourcePath) },
110
- level,
111
- retrievedAt: new Date().toISOString(),
112
- sha256: digest,
113
- // A user-supplied file is provenance, not independent verification. A
114
- // full-text level is only promotable after a parser records precise
115
- // page/section/row locators and a separate verification step approves it.
116
- accessStatus: "partial",
117
- locators: [{ kind: "file", value: sourcePath }],
118
- };
119
- const evidencePath = projectPaths(root).evidence;
120
- await appendJsonlIfMissing(evidencePath, evidence, (item) => item.id);
121
- process.stdout.write(`${JSON.stringify(evidence, null, 2)}\n`);
122
- }
123
- async function ensureConfiguredThenChat(args) {
124
- if (!(await hasConfiguredProvider())) {
125
- const { runWizard } = await import("./wizard.js");
126
- const result = await runWizard();
127
- if (!result.completed)
128
- return;
129
- if (result.provider && result.modelId) {
130
- args = ["--provider", result.provider, "--model", result.modelId, ...args];
131
- }
132
- }
133
- await launchChat({ args });
134
- }
135
- async function main() {
136
- const args = process.argv.slice(2);
137
- const command = args.shift();
138
- const root = process.cwd();
139
- if (command === "--help" || command === "-h") {
140
- process.stdout.write(`${usage()}\n`);
141
- return;
142
- }
143
- // Bare `psyclaw` is the primary entrypoint: guide the user through first-run
144
- // setup when no provider is configured, then launch the conversation.
145
- if (!command) {
146
- await ensureConfiguredThenChat(args);
147
- return;
148
- }
149
- if (command === "chat") {
150
- await ensureConfiguredThenChat(args);
151
- return;
152
- }
153
- if (command === "wizard") {
154
- const { runWizard } = await import("./wizard.js");
155
- await runWizard();
156
- return;
157
- }
158
- if (command === "setup") {
159
- assertKnownOptions(args, ["--provider"]);
160
- const provider = option(args, "--provider");
161
- const result = await setupProviders(provider === undefined ? {} : { providers: [provider] });
162
- process.stdout.write(`${JSON.stringify({ path: result.path, providers: result.providers }, null, 2)}\n`);
163
- return;
164
- }
165
- if (command === "init") {
166
- assertKnownOptions(args, ["--paradigm"]);
167
- const paradigm = option(args, "--paradigm", "survey-observational");
168
- if (!paradigm || !PARADIGMS.has(paradigm)) {
169
- throw new Error(`Unsupported paradigm: ${paradigm}`);
170
- }
171
- const optionIndexes = new Set();
172
- for (const [index, arg] of args.entries()) {
173
- if (arg === "--paradigm") {
174
- optionIndexes.add(index);
175
- optionIndexes.add(index + 1);
176
- }
177
- }
178
- const goal = args.filter((_arg, index) => !optionIndexes.has(index)).join(" ").trim();
179
- if (!goal)
180
- throw new Error("Usage: psyclaw init <goal> [--paradigm <profile>]");
181
- const project = await bootstrapProject({
182
- root,
183
- goal,
184
- paradigm: paradigm,
185
- });
186
- process.stdout.write(`${JSON.stringify(project, null, 2)}\n`);
187
- return;
188
- }
189
- if (command === "evidence" && args.shift() === "add") {
190
- await addEvidence(root, args);
191
- return;
192
- }
193
- if (command === "handoff") {
194
- const project = asProject(JSON.parse(await readFile(projectPaths(root).project, "utf8")));
195
- await writeHandoff(root, {
196
- projectId: project.id,
197
- runId: `run_${Date.now()}`,
198
- goal: project.goal,
199
- completed: ["project bootstrap"],
200
- verified: ["project.json exists"],
201
- blocked: ["claim-evidence audit pending"],
202
- nextSteps: ["import and audit evidence"],
203
- verificationCommands: ["pnpm typecheck", "pnpm test"],
204
- generatedAt: new Date().toISOString(),
205
- });
206
- process.stdout.write(renderSuccessCard("已生成 HANDOFF 研究移交备忘录", {
207
- "Markdown 产物": "notes/HANDOFF.md",
208
- "JSON 结构化快照": "notes/handoff.json",
209
- }));
210
- return;
211
- }
212
- if (command === "hitl") {
213
- const action = args.shift();
214
- if (action !== "init" || args.length > 0)
215
- throw new Error("Usage: psyclaw hitl init");
216
- const project = asProject(JSON.parse(await readFile(projectPaths(root).project, "utf8")));
217
- await initializeHitlWorkspace(root, project.goal);
218
- process.stdout.write(renderSuccessCard("已初始化人类裁决 (HITL) 工作区模板", {
219
- "位置": "notes/ 与 logs/",
220
- "状态": "待研究者确认节点已就绪",
221
- }));
222
- return;
223
- }
224
- if (command === "brief") {
225
- const result = await runOfflineBrief(root);
226
- process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
227
- if (result.verdict === "blocked")
228
- process.exitCode = 2;
229
- return;
230
- }
231
- if (command === "agents" || command === "scan") {
232
- const scans = await discoverAgents();
233
- process.stdout.write(`${JSON.stringify(scans, null, 2)}\n`);
234
- return;
235
- }
236
- if (command === "install") {
237
- const id = args.shift();
238
- if (!id)
239
- throw new Error("Usage: psyclaw install <agent-id> [--yes]");
240
- const agent = KNOWN_AGENTS.find((candidate) => candidate.id === id);
241
- if (!agent)
242
- throw new Error(`Unknown agent: ${id}`);
243
- const plan = planAgentInstall(agent);
244
- if (!args.includes("--yes")) {
245
- process.stdout.write(`${JSON.stringify(plan, null, 2)}\n`);
246
- process.stdout.write(c.yellow("\n➜ 请附加 --yes 参数确认并执行安装。\n"));
247
- return;
248
- }
249
- const receipt = await runInstall(plan, { approved: true, actor: "cli", reason: "--yes" }, (command) => spawnCommand(command, true), { ledger: new FileInstallLedger(root) });
250
- process.stdout.write(`${JSON.stringify(receipt, null, 2)}\n`);
251
- if (!receipt.ok)
252
- process.exitCode = 1;
253
- return;
254
- }
255
- if (command === "import") {
256
- const id = args.shift();
257
- if (!id)
258
- throw new Error("Usage: psyclaw import <agent-id> [--yes]");
259
- const scans = await discoverAgents();
260
- const agent = scans.find((candidate) => candidate.id === id && candidate.found);
261
- if (!agent)
262
- throw new Error(`Agent not found or not configured: ${id}`);
263
- if (!args.includes("--yes")) {
264
- process.stdout.write(`${JSON.stringify(agent, null, 2)}\n`);
265
- process.stdout.write(c.yellow("\n➜ 请附加 --yes 参数确认并导入技能。\n"));
266
- return;
267
- }
268
- const result = await importAgentSkills({
269
- root,
270
- agent,
271
- approval: { approved: true, actor: "cli", reason: "--yes" },
272
- });
273
- process.stdout.write(`${JSON.stringify({ manifestPath: result.manifestPath, importedCount: result.importedCount }, null, 2)}\n`);
274
- return;
275
- }
276
- if (command === "shell") {
277
- const { runTui } = await import("./tui/app.js");
278
- runTui(root);
279
- return;
280
- }
281
- if (command === "check-updates") {
282
- const { checkUpdates } = await import("./updates/check.js");
283
- const { createHttpRegistry } = await import("./updates/registry.js");
284
- const report = await checkUpdates({ registry: createHttpRegistry(), cwd: root });
285
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
286
- return;
287
- }
288
- if (command === "update") {
289
- for (const arg of args) {
290
- if (arg.startsWith("--") && arg !== "--yes" && arg !== "--force") {
291
- throw new Error(`Unknown option: ${arg}`);
292
- }
293
- }
294
- const { updateBundledPi } = await import("./updates/update.js");
295
- const { createHttpRegistry } = await import("./updates/registry.js");
296
- const receipt = await updateBundledPi({
297
- registry: createHttpRegistry(),
298
- force: args.includes("--force"),
299
- ...(args.includes("--yes") ? { executor: (step) => runPackageManager(step.command, step.cwd) } : {}),
300
- });
301
- process.stdout.write(`${JSON.stringify(receipt, null, 2)}\n`);
302
- if (!receipt.ok) {
303
- process.exitCode = 1;
304
- }
305
- else if (receipt.reasonCode === "update-skipped" && receipt.command !== undefined) {
306
- process.stdout.write(c.yellow("\n➜ 请附加 --yes 参数确认并应用更新。\n"));
307
- }
308
- return;
309
- }
310
- throw new Error(`Unknown command: ${command}\n\n${usage()}`);
311
- }
312
- main().catch((error) => {
313
- process.stderr.write(`${c.red("✗ Error:")} ${error instanceof Error ? error.message : String(error)}\n`);
314
- process.exitCode = 1;
315
- });
316
- //# sourceMappingURL=cli.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW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AAC,CAAC;QACH,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAChB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,IAAI,OAAO,CAAC,UAAU,KAAK,gBAAgB,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACpF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,4BAA4B,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,OAAO;IACT,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,OAAO,KAAK,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -1,44 +0,0 @@
1
- import { type ReferenceRecord } from "./references.js";
2
- import { type DoiVerification } from "./doi.js";
3
- /**
4
- * Citation-usage ledger (.psyclaw/citations.jsonl).
5
- *
6
- * When a paper is generated, every in-text citation should be recorded with
7
- * BOTH its evidence (the DOI reference, verified against the reference
8
- * archive) AND the reason it was cited (one line) plus the sentence context.
9
- * This makes the reference archive traceable: which citation appears where in
10
- * the manuscript, why it was chosen, and whether its metadata was verified.
11
- */
12
- export interface CitationUseRecord {
13
- schemaVersion: "psyclaw/citation-use/v1";
14
- citationId: string;
15
- doi: string;
16
- surname: string;
17
- year?: number;
18
- reason: string;
19
- context: string;
20
- section?: string;
21
- claimId?: string;
22
- verified: boolean;
23
- recordedAt: string;
24
- }
25
- export interface RecordCitationInput {
26
- doi: string;
27
- reason: string;
28
- context: string;
29
- section?: string;
30
- claimId?: string;
31
- }
32
- export declare function citationsPath(root: string): Promise<string>;
33
- export declare function listCitationUses(root: string): Promise<CitationUseRecord[]>;
34
- /**
35
- * Record one citation use: verify the DOI (real network unless a verifier is
36
- * injected), archive the reference when verifiable, then append the use with
37
- * its reason. The use is always recorded (with `verified` reflecting the
38
- * verification outcome) so the citation reason is never lost.
39
- */
40
- export declare function recordCitationUse(root: string, input: RecordCitationInput, verify?: (doi: string) => Promise<DoiVerification>): Promise<{
41
- record: CitationUseRecord;
42
- reference: ReferenceRecord | null;
43
- appended: boolean;
44
- }>;