@kortix/sandbox 0.4.1

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 (246) hide show
  1. package/config/customize.sh +143 -0
  2. package/config/kortix-env-setup.sh +25 -0
  3. package/kortix-master/package.json +22 -0
  4. package/kortix-master/src/config.ts +22 -0
  5. package/kortix-master/src/index.ts +44 -0
  6. package/kortix-master/src/routes/env.ts +65 -0
  7. package/kortix-master/src/routes/proxy.ts +108 -0
  8. package/kortix-master/src/routes/update.ts +185 -0
  9. package/kortix-master/src/services/proxy.ts +43 -0
  10. package/kortix-master/src/services/secret-store.ts +156 -0
  11. package/kortix-master/tsconfig.json +14 -0
  12. package/opencode/agents/kortix-browser.md +142 -0
  13. package/opencode/agents/kortix-build.md +62 -0
  14. package/opencode/agents/kortix-explore.md +66 -0
  15. package/opencode/agents/kortix-image-gen.md +33 -0
  16. package/opencode/agents/kortix-main.md +450 -0
  17. package/opencode/agents/kortix-plan.md +100 -0
  18. package/opencode/agents/kortix-research.md +84 -0
  19. package/opencode/agents/kortix-sheets.md +61 -0
  20. package/opencode/agents/kortix-slides.md +64 -0
  21. package/opencode/agents/kortix-web-dev.md +572 -0
  22. package/opencode/commands/email.md +36 -0
  23. package/opencode/commands/init.md +43 -0
  24. package/opencode/commands/journal.md +44 -0
  25. package/opencode/commands/memory-init.md +81 -0
  26. package/opencode/commands/memory-search.md +50 -0
  27. package/opencode/commands/memory-status.md +56 -0
  28. package/opencode/commands/research.md +36 -0
  29. package/opencode/commands/search.md +38 -0
  30. package/opencode/commands/slides.md +32 -0
  31. package/opencode/commands/spreadsheet.md +30 -0
  32. package/opencode/memory.json +37 -0
  33. package/opencode/ocx.jsonc +10 -0
  34. package/opencode/opencode.jsonc +103 -0
  35. package/opencode/package.json +25 -0
  36. package/opencode/patches/apply.sh +19 -0
  37. package/opencode/patches/opencode-pty-spawn.txt +49 -0
  38. package/opencode/plugin/background-agents.ts.disabled +483 -0
  39. package/opencode/plugin/kdco-primitives/get-project-id.ts +172 -0
  40. package/opencode/plugin/kdco-primitives/index.ts +26 -0
  41. package/opencode/plugin/kdco-primitives/log-warn.ts +51 -0
  42. package/opencode/plugin/kdco-primitives/mutex.ts +122 -0
  43. package/opencode/plugin/kdco-primitives/shell.ts +138 -0
  44. package/opencode/plugin/kdco-primitives/temp.ts +36 -0
  45. package/opencode/plugin/kdco-primitives/terminal-detect.ts +34 -0
  46. package/opencode/plugin/kdco-primitives/types.ts +13 -0
  47. package/opencode/plugin/kdco-primitives/with-timeout.ts +84 -0
  48. package/opencode/plugin/memory.ts +306 -0
  49. package/opencode/plugin/worktree/state.ts +412 -0
  50. package/opencode/plugin/worktree/terminal.ts +1002 -0
  51. package/opencode/plugin/worktree.ts +861 -0
  52. package/opencode/skills/KORTIX-browser/SKILL.md +478 -0
  53. package/opencode/skills/KORTIX-cron-triggers/SKILL.md +173 -0
  54. package/opencode/skills/KORTIX-deep-research/SKILL.md +278 -0
  55. package/opencode/skills/KORTIX-docx/SKILL.md +398 -0
  56. package/opencode/skills/KORTIX-docx/scripts/__init__.py +1 -0
  57. package/opencode/skills/KORTIX-docx/scripts/accept_changes.py +104 -0
  58. package/opencode/skills/KORTIX-docx/scripts/comment.py +244 -0
  59. package/opencode/skills/KORTIX-docx/scripts/office/helpers/__init__.py +0 -0
  60. package/opencode/skills/KORTIX-docx/scripts/office/helpers/merge_runs.py +199 -0
  61. package/opencode/skills/KORTIX-docx/scripts/office/helpers/simplify_redlines.py +197 -0
  62. package/opencode/skills/KORTIX-docx/scripts/office/pack.py +159 -0
  63. package/opencode/skills/KORTIX-docx/scripts/office/soffice.py +183 -0
  64. package/opencode/skills/KORTIX-docx/scripts/office/unpack.py +132 -0
  65. package/opencode/skills/KORTIX-docx/scripts/office/validate.py +111 -0
  66. package/opencode/skills/KORTIX-docx/scripts/office/validators/__init__.py +15 -0
  67. package/opencode/skills/KORTIX-docx/scripts/office/validators/base.py +847 -0
  68. package/opencode/skills/KORTIX-docx/scripts/office/validators/docx.py +446 -0
  69. package/opencode/skills/KORTIX-docx/scripts/office/validators/pptx.py +275 -0
  70. package/opencode/skills/KORTIX-docx/scripts/office/validators/redlining.py +247 -0
  71. package/opencode/skills/KORTIX-docx/scripts/render_docx.py +179 -0
  72. package/opencode/skills/KORTIX-docx/scripts/templates/comments.xml +3 -0
  73. package/opencode/skills/KORTIX-docx/scripts/templates/commentsExtended.xml +3 -0
  74. package/opencode/skills/KORTIX-docx/scripts/templates/commentsExtensible.xml +3 -0
  75. package/opencode/skills/KORTIX-docx/scripts/templates/commentsIds.xml +3 -0
  76. package/opencode/skills/KORTIX-docx/scripts/templates/people.xml +3 -0
  77. package/opencode/skills/KORTIX-domain-research/SKILL.md +96 -0
  78. package/opencode/skills/KORTIX-domain-research/scripts/domain-lookup.py +810 -0
  79. package/opencode/skills/KORTIX-elevenlabs/SKILL.md +230 -0
  80. package/opencode/skills/KORTIX-elevenlabs/scripts/tts.py +389 -0
  81. package/opencode/skills/KORTIX-email/SKILL.md +145 -0
  82. package/opencode/skills/KORTIX-legal-writer/SKILL.md +409 -0
  83. package/opencode/skills/KORTIX-legal-writer/references/bluebook.md +152 -0
  84. package/opencode/skills/KORTIX-legal-writer/references/document-types.md +416 -0
  85. package/opencode/skills/KORTIX-legal-writer/scripts/courtlistener.py +291 -0
  86. package/opencode/skills/KORTIX-legal-writer/scripts/ecfr_lookup.py +299 -0
  87. package/opencode/skills/KORTIX-legal-writer/scripts/verify-legal.py +507 -0
  88. package/opencode/skills/KORTIX-logo-creator/SKILL.md +293 -0
  89. package/opencode/skills/KORTIX-logo-creator/references/prompt-patterns.md +134 -0
  90. package/opencode/skills/KORTIX-logo-creator/scripts/compose_logo.py +406 -0
  91. package/opencode/skills/KORTIX-logo-creator/scripts/create_logo_sheet.py +258 -0
  92. package/opencode/skills/KORTIX-logo-creator/scripts/remove_bg.py +96 -0
  93. package/opencode/skills/KORTIX-memory/SKILL.md +261 -0
  94. package/opencode/skills/KORTIX-memory/scripts/export-sessions.py +409 -0
  95. package/opencode/skills/KORTIX-paper-creator/SKILL.md +549 -0
  96. package/opencode/skills/KORTIX-paper-creator/assets/template.tex +101 -0
  97. package/opencode/skills/KORTIX-paper-creator/scripts/compile.sh +177 -0
  98. package/opencode/skills/KORTIX-paper-creator/scripts/openalex_to_bibtex.py +220 -0
  99. package/opencode/skills/KORTIX-paper-creator/scripts/verify.sh +354 -0
  100. package/opencode/skills/KORTIX-paper-search/SKILL.md +418 -0
  101. package/opencode/skills/KORTIX-pdf/SKILL.md +232 -0
  102. package/opencode/skills/KORTIX-pdf/forms.md +36 -0
  103. package/opencode/skills/KORTIX-pdf/reference.md +105 -0
  104. package/opencode/skills/KORTIX-pdf/scripts/check_bounding_boxes.py +65 -0
  105. package/opencode/skills/KORTIX-pdf/scripts/check_fillable_fields.py +11 -0
  106. package/opencode/skills/KORTIX-pdf/scripts/convert_pdf_to_images.py +33 -0
  107. package/opencode/skills/KORTIX-pdf/scripts/create_validation_image.py +37 -0
  108. package/opencode/skills/KORTIX-pdf/scripts/extract_form_field_info.py +122 -0
  109. package/opencode/skills/KORTIX-pdf/scripts/extract_form_structure.py +115 -0
  110. package/opencode/skills/KORTIX-pdf/scripts/fill_fillable_fields.py +98 -0
  111. package/opencode/skills/KORTIX-pdf/scripts/fill_pdf_form_with_annotations.py +107 -0
  112. package/opencode/skills/KORTIX-plan/SKILL.md +228 -0
  113. package/opencode/skills/KORTIX-presentation-viewer/SKILL.md +87 -0
  114. package/opencode/skills/KORTIX-presentation-viewer/serve.ts +136 -0
  115. package/opencode/skills/KORTIX-presentation-viewer/viewer.html +559 -0
  116. package/opencode/skills/KORTIX-presentations/SKILL.md +344 -0
  117. package/opencode/skills/KORTIX-remotion/SKILL.md +56 -0
  118. package/opencode/skills/KORTIX-remotion/rules/3d.md +86 -0
  119. package/opencode/skills/KORTIX-remotion/rules/animations.md +29 -0
  120. package/opencode/skills/KORTIX-remotion/rules/assets.md +78 -0
  121. package/opencode/skills/KORTIX-remotion/rules/audio-visualization.md +198 -0
  122. package/opencode/skills/KORTIX-remotion/rules/audio.md +169 -0
  123. package/opencode/skills/KORTIX-remotion/rules/calculate-metadata.md +104 -0
  124. package/opencode/skills/KORTIX-remotion/rules/can-decode.md +75 -0
  125. package/opencode/skills/KORTIX-remotion/rules/charts.md +120 -0
  126. package/opencode/skills/KORTIX-remotion/rules/compositions.md +141 -0
  127. package/opencode/skills/KORTIX-remotion/rules/display-captions.md +184 -0
  128. package/opencode/skills/KORTIX-remotion/rules/extract-frames.md +229 -0
  129. package/opencode/skills/KORTIX-remotion/rules/ffmpeg.md +38 -0
  130. package/opencode/skills/KORTIX-remotion/rules/fonts.md +152 -0
  131. package/opencode/skills/KORTIX-remotion/rules/get-audio-duration.md +58 -0
  132. package/opencode/skills/KORTIX-remotion/rules/get-video-dimensions.md +68 -0
  133. package/opencode/skills/KORTIX-remotion/rules/get-video-duration.md +58 -0
  134. package/opencode/skills/KORTIX-remotion/rules/gifs.md +141 -0
  135. package/opencode/skills/KORTIX-remotion/rules/images.md +130 -0
  136. package/opencode/skills/KORTIX-remotion/rules/import-srt-captions.md +69 -0
  137. package/opencode/skills/KORTIX-remotion/rules/light-leaks.md +73 -0
  138. package/opencode/skills/KORTIX-remotion/rules/lottie.md +68 -0
  139. package/opencode/skills/KORTIX-remotion/rules/maps.md +401 -0
  140. package/opencode/skills/KORTIX-remotion/rules/measuring-dom-nodes.md +35 -0
  141. package/opencode/skills/KORTIX-remotion/rules/measuring-text.md +143 -0
  142. package/opencode/skills/KORTIX-remotion/rules/parameters.md +98 -0
  143. package/opencode/skills/KORTIX-remotion/rules/sequencing.md +118 -0
  144. package/opencode/skills/KORTIX-remotion/rules/subtitles.md +36 -0
  145. package/opencode/skills/KORTIX-remotion/rules/tailwind.md +11 -0
  146. package/opencode/skills/KORTIX-remotion/rules/text-animations.md +20 -0
  147. package/opencode/skills/KORTIX-remotion/rules/timing.md +179 -0
  148. package/opencode/skills/KORTIX-remotion/rules/transcribe-captions.md +70 -0
  149. package/opencode/skills/KORTIX-remotion/rules/transitions.md +197 -0
  150. package/opencode/skills/KORTIX-remotion/rules/transparent-videos.md +106 -0
  151. package/opencode/skills/KORTIX-remotion/rules/trimming.md +53 -0
  152. package/opencode/skills/KORTIX-remotion/rules/videos.md +171 -0
  153. package/opencode/skills/KORTIX-secrets/SKILL.md +280 -0
  154. package/opencode/skills/KORTIX-semantic-search/SKILL.md +213 -0
  155. package/opencode/skills/KORTIX-session-search/SKILL.md +807 -0
  156. package/opencode/skills/KORTIX-session-search/Untitled +1 -0
  157. package/opencode/skills/KORTIX-skill-creator/SKILL.md +163 -0
  158. package/opencode/skills/KORTIX-web-research/SKILL.md +69 -0
  159. package/opencode/skills/KORTIX-xlsx/LICENSE.txt +30 -0
  160. package/opencode/skills/KORTIX-xlsx/SKILL.md +549 -0
  161. package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/__init__.py +0 -0
  162. package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/merge_runs.py +199 -0
  163. package/opencode/skills/KORTIX-xlsx/scripts/office/helpers/simplify_redlines.py +197 -0
  164. package/opencode/skills/KORTIX-xlsx/scripts/office/pack.py +159 -0
  165. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +1499 -0
  166. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +146 -0
  167. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +1085 -0
  168. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +11 -0
  169. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +3081 -0
  170. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +23 -0
  171. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +185 -0
  172. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +287 -0
  173. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +1676 -0
  174. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +28 -0
  175. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +144 -0
  176. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +174 -0
  177. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +25 -0
  178. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +18 -0
  179. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +59 -0
  180. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +56 -0
  181. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +195 -0
  182. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +582 -0
  183. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +25 -0
  184. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +4439 -0
  185. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +570 -0
  186. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +509 -0
  187. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +12 -0
  188. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +108 -0
  189. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +96 -0
  190. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +3646 -0
  191. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +116 -0
  192. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +42 -0
  193. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +50 -0
  194. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +49 -0
  195. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +33 -0
  196. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/mce/mc.xsd +75 -0
  197. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2010.xsd +560 -0
  198. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2012.xsd +67 -0
  199. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-2018.xsd +14 -0
  200. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +20 -0
  201. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +13 -0
  202. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +4 -0
  203. package/opencode/skills/KORTIX-xlsx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +8 -0
  204. package/opencode/skills/KORTIX-xlsx/scripts/office/soffice.py +183 -0
  205. package/opencode/skills/KORTIX-xlsx/scripts/office/unpack.py +132 -0
  206. package/opencode/skills/KORTIX-xlsx/scripts/office/validate.py +111 -0
  207. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/__init__.py +15 -0
  208. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/base.py +847 -0
  209. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/docx.py +446 -0
  210. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/pptx.py +275 -0
  211. package/opencode/skills/KORTIX-xlsx/scripts/office/validators/redlining.py +247 -0
  212. package/opencode/skills/KORTIX-xlsx/scripts/recalc.py +184 -0
  213. package/opencode/tools/image-gen.ts +342 -0
  214. package/opencode/tools/image-search.ts +190 -0
  215. package/opencode/tools/memory-get.ts +168 -0
  216. package/opencode/tools/memory-search.ts +247 -0
  217. package/opencode/tools/presentation-gen.ts +723 -0
  218. package/opencode/tools/scrape-webpage.ts +115 -0
  219. package/opencode/tools/scripts/.python-version +1 -0
  220. package/opencode/tools/scripts/convert_pdf.py +184 -0
  221. package/opencode/tools/scripts/convert_pptx.py +562 -0
  222. package/opencode/tools/scripts/pyproject.toml +11 -0
  223. package/opencode/tools/scripts/uv.lock +287 -0
  224. package/opencode/tools/scripts/validate_slide.py +74 -0
  225. package/opencode/tools/show-user.ts +217 -0
  226. package/opencode/tools/tests/e2e-presentation-fix.ts +277 -0
  227. package/opencode/tools/tests/image-gen.test.ts +215 -0
  228. package/opencode/tools/tests/image-search.test.ts +125 -0
  229. package/opencode/tools/tests/memory-system-benchmark.ts +1076 -0
  230. package/opencode/tools/tests/presentation-gen.test.ts +389 -0
  231. package/opencode/tools/tests/scrape-webpage.test.ts +74 -0
  232. package/opencode/tools/tests/show-user.test.ts +241 -0
  233. package/opencode/tools/tests/video-gen.test.ts +110 -0
  234. package/opencode/tools/tests/web-search.test.ts +106 -0
  235. package/opencode/tools/video-gen.ts +200 -0
  236. package/opencode/tools/web-search.ts +153 -0
  237. package/opencode/tsconfig.json +29 -0
  238. package/package.json +36 -0
  239. package/patch-agent-browser.js +100 -0
  240. package/postinstall.sh +88 -0
  241. package/services/KORTIX-presentation-viewer/run +37 -0
  242. package/services/agent-browser-viewer/run +48 -0
  243. package/services/kortix-master/run +16 -0
  244. package/services/lss-sync/run +22 -0
  245. package/services/opencode-serve/run +25 -0
  246. package/services/opencode-web/run +21 -0
@@ -0,0 +1,354 @@
1
+ #!/usr/bin/env bash
2
+ # TDD Verification Suite for LaTeX papers.
3
+ #
4
+ # Runs a comprehensive checklist against a compiled paper and reports pass/fail.
5
+ # Designed to be run after every section is written.
6
+ #
7
+ # Usage:
8
+ # bash verify.sh <paper-dir>
9
+ # bash verify.sh paper/my-paper/
10
+ # bash verify.sh paper/my-paper/ --strict # treat warnings as failures
11
+ #
12
+ # Expects:
13
+ # <paper-dir>/main.tex
14
+ # <paper-dir>/build/main.log (from compile.sh)
15
+ # <paper-dir>/build/main.aux
16
+ # <paper-dir>/references.bib
17
+ # <paper-dir>/sections/*.tex
18
+ #
19
+ # Exit codes: 0 = all checks pass, 1 = failures found
20
+ # Output: machine-readable checklist (PASS/FAIL/WARN per check)
21
+
22
+ set -uo pipefail
23
+
24
+ # --- Args ---
25
+ if [ $# -lt 1 ]; then
26
+ echo "Usage: verify.sh <paper-dir> [--strict]" >&2
27
+ exit 1
28
+ fi
29
+
30
+ PAPER_DIR="${1%/}"
31
+ STRICT=false
32
+ if [[ "${2:-}" == "--strict" ]]; then
33
+ STRICT=true
34
+ fi
35
+
36
+ # --- Paths ---
37
+ MAIN_TEX="$PAPER_DIR/main.tex"
38
+ BUILD_DIR="$PAPER_DIR/build"
39
+ LOG_FILE="$BUILD_DIR/main.log"
40
+ AUX_FILE="$BUILD_DIR/main.aux"
41
+ BLG_FILE="$BUILD_DIR/main.blg"
42
+ BIB_FILE="$PAPER_DIR/references.bib"
43
+ SECTIONS_DIR="$PAPER_DIR/sections"
44
+ PDF_FILE="$BUILD_DIR/main.pdf"
45
+
46
+ PASS_COUNT=0
47
+ FAIL_COUNT=0
48
+ WARN_COUNT=0
49
+
50
+ # --- Helpers ---
51
+ check_pass() {
52
+ echo " PASS: $1"
53
+ PASS_COUNT=$((PASS_COUNT + 1))
54
+ }
55
+
56
+ check_fail() {
57
+ echo " FAIL: $1"
58
+ FAIL_COUNT=$((FAIL_COUNT + 1))
59
+ }
60
+
61
+ check_warn() {
62
+ echo " WARN: $1"
63
+ WARN_COUNT=$((WARN_COUNT + 1))
64
+ if $STRICT; then
65
+ FAIL_COUNT=$((FAIL_COUNT + 1))
66
+ fi
67
+ }
68
+
69
+ echo "=== Paper Verification: $PAPER_DIR ==="
70
+ echo ""
71
+
72
+ # ===================================================================
73
+ # CHECK 1: PDF exists (paper compiled successfully)
74
+ # ===================================================================
75
+ echo "--- Build Status ---"
76
+ if [ -f "$PDF_FILE" ]; then
77
+ PDF_SIZE=$(wc -c < "$PDF_FILE" | tr -d ' ')
78
+ if [ "$PDF_SIZE" -gt 1000 ]; then
79
+ check_pass "PDF exists ($PDF_SIZE bytes)"
80
+ else
81
+ check_fail "PDF exists but suspiciously small ($PDF_SIZE bytes)"
82
+ fi
83
+ else
84
+ check_fail "PDF not found at $PDF_FILE (run compile.sh first)"
85
+ fi
86
+
87
+ # ===================================================================
88
+ # CHECK 2: Zero LaTeX errors in log
89
+ # ===================================================================
90
+ echo ""
91
+ echo "--- LaTeX Errors ---"
92
+ if [ -f "$LOG_FILE" ]; then
93
+ ERROR_COUNT=$(grep -c "^!" "$LOG_FILE" 2>/dev/null || true)
94
+ if [ "$ERROR_COUNT" -eq 0 ]; then
95
+ check_pass "Zero LaTeX errors"
96
+ else
97
+ check_fail "$ERROR_COUNT LaTeX error(s) found:"
98
+ grep -A2 "^!" "$LOG_FILE" | head -30
99
+ fi
100
+ else
101
+ check_warn "No log file found (compile first)"
102
+ fi
103
+
104
+ # ===================================================================
105
+ # CHECK 3: Undefined references
106
+ # ===================================================================
107
+ echo ""
108
+ echo "--- References ---"
109
+ if [ -f "$LOG_FILE" ]; then
110
+ # Match both "LaTeX Warning: Reference" and package-specific warnings
111
+ UNDEF_REFS=$(grep -c "Warning: Reference .* undefined" "$LOG_FILE" 2>/dev/null || true)
112
+ if [ "$UNDEF_REFS" -eq 0 ]; then
113
+ check_pass "Zero undefined \\ref{} references"
114
+ else
115
+ check_fail "$UNDEF_REFS undefined reference(s):"
116
+ grep "Warning: Reference .* undefined" "$LOG_FILE" | \
117
+ sed "s/.*Reference .\(.*\)..* undefined.*/ \\\\ref{\1}/" | sort -u | head -20
118
+ fi
119
+ fi
120
+
121
+ # ===================================================================
122
+ # CHECK 4: Undefined citations
123
+ # ===================================================================
124
+ if [ -f "$LOG_FILE" ]; then
125
+ # Match per-citation warnings like: Citation `key' ... undefined
126
+ # Filter out summary lines ("There were undefined citations")
127
+ UNDEF_CITES=$(grep "Warning:" "$LOG_FILE" 2>/dev/null | grep "Citation" | grep "undefined" | grep -vc "There were" 2>/dev/null || true)
128
+ if [ "$UNDEF_CITES" -eq 0 ]; then
129
+ check_pass "Zero undefined \\cite{} citations"
130
+ else
131
+ check_fail "$UNDEF_CITES undefined citation(s):"
132
+ grep "Warning:" "$LOG_FILE" | grep "Citation" | grep "undefined" | grep -v "There were" | \
133
+ sed "s/.*Citation .\([^']*\).*/ \\\\cite{\1}/" | sort -u | head -20
134
+ fi
135
+ fi
136
+
137
+ # ===================================================================
138
+ # CHECK 5: BibTeX errors
139
+ # ===================================================================
140
+ echo ""
141
+ echo "--- Bibliography ---"
142
+ if [ -f "$BLG_FILE" ]; then
143
+ # Count real errors (exclude "0 error" summary and benign "no \citation commands" message)
144
+ BIB_ERRORS=$(grep -ci "error" "$BLG_FILE" 2>/dev/null || true)
145
+ BENIGN=$(grep -c -E "(0 error|no \\\\citation commands)" "$BLG_FILE" 2>/dev/null || true)
146
+ REAL_ERRORS=$((BIB_ERRORS - BENIGN))
147
+ if [ "$REAL_ERRORS" -le 0 ]; then
148
+ check_pass "Zero BibTeX errors"
149
+ else
150
+ check_fail "$REAL_ERRORS BibTeX error(s):"
151
+ grep -i "error" "$BLG_FILE" | grep -v -E "(0 error|no \\\\citation)" | head -10
152
+ fi
153
+ elif [ -f "$BIB_FILE" ]; then
154
+ check_warn "No .blg file found (bibtex may not have run)"
155
+ else
156
+ check_warn "No references.bib file found"
157
+ fi
158
+
159
+ # ===================================================================
160
+ # CHECK 6: Overfull boxes (> 10pt)
161
+ # ===================================================================
162
+ echo ""
163
+ echo "--- Box Warnings ---"
164
+ if [ -f "$LOG_FILE" ]; then
165
+ # Count overfull hboxes > 10pt (no grep -P, works on macOS and Linux)
166
+ BAD_OVERFULL=$(grep "Overfull \\\\hbox" "$LOG_FILE" 2>/dev/null | \
167
+ sed 's/.*(\([0-9.]*\)pt.*/\1/' | \
168
+ awk '{if($1+0 > 10) count++} END{print count+0}')
169
+ TOTAL_OVERFULL=$(grep -c "Overfull" "$LOG_FILE" 2>/dev/null || true)
170
+
171
+ if [ "$BAD_OVERFULL" -eq 0 ]; then
172
+ if [ "$TOTAL_OVERFULL" -gt 0 ]; then
173
+ check_warn "$TOTAL_OVERFULL overfull box(es) (all <= 10pt)"
174
+ else
175
+ check_pass "Zero overfull boxes"
176
+ fi
177
+ else
178
+ check_fail "$BAD_OVERFULL overfull box(es) > 10pt"
179
+ fi
180
+ fi
181
+
182
+ # ===================================================================
183
+ # CHECK 7: Missing figure files
184
+ # ===================================================================
185
+ echo ""
186
+ echo "--- Figures ---"
187
+ if [ -d "$PAPER_DIR/figures" ]; then
188
+ # Find all \includegraphics references
189
+ MISSING_FIGS=0
190
+ while IFS= read -r figpath; do
191
+ # Check with and without extension
192
+ if [ ! -f "$PAPER_DIR/figures/$figpath" ] && \
193
+ [ ! -f "$PAPER_DIR/figures/${figpath}.pdf" ] && \
194
+ [ ! -f "$PAPER_DIR/figures/${figpath}.png" ] && \
195
+ [ ! -f "$PAPER_DIR/figures/${figpath}.jpg" ]; then
196
+ echo " Missing: $figpath"
197
+ MISSING_FIGS=$((MISSING_FIGS + 1))
198
+ fi
199
+ done < <(grep -roh '\\includegraphics\(\[.*\]\)\?{[^}]*}' "$SECTIONS_DIR" "$MAIN_TEX" 2>/dev/null | \
200
+ sed 's/.*{\(.*\)}/\1/' | sort -u)
201
+
202
+ if [ "$MISSING_FIGS" -eq 0 ]; then
203
+ check_pass "All referenced figures exist"
204
+ else
205
+ check_fail "$MISSING_FIGS missing figure file(s)"
206
+ fi
207
+ else
208
+ # Only warn if figures are actually referenced
209
+ FIG_REFS=$(grep -rc '\\includegraphics' "$SECTIONS_DIR" "$MAIN_TEX" 2>/dev/null | \
210
+ awk -F: '{s+=$NF} END{print s+0}')
211
+ if [ "$FIG_REFS" -gt 0 ]; then
212
+ check_fail "figures/ directory missing but $FIG_REFS \\includegraphics found"
213
+ else
214
+ check_pass "No figures referenced (none expected)"
215
+ fi
216
+ fi
217
+
218
+ # ===================================================================
219
+ # CHECK 8: Empty sections
220
+ # ===================================================================
221
+ echo ""
222
+ echo "--- Section Content ---"
223
+ EMPTY_SECTIONS=0
224
+ if [ -d "$SECTIONS_DIR" ]; then
225
+ for sec_file in "$SECTIONS_DIR"/*.tex; do
226
+ [ -f "$sec_file" ] || continue
227
+ sec_name="$(basename "$sec_file" .tex)"
228
+ # Count non-empty, non-comment lines (excluding \section, \subsection, \label)
229
+ CONTENT_LINES=$(grep -cvE '^\s*(%|\\section|\\subsection|\\subsubsection|\\label|\s*$)' "$sec_file" 2>/dev/null || true)
230
+ if [ "$CONTENT_LINES" -lt 2 ]; then
231
+ check_warn "Section '$sec_name' appears empty ($CONTENT_LINES content lines)"
232
+ EMPTY_SECTIONS=$((EMPTY_SECTIONS + 1))
233
+ fi
234
+ done
235
+ if [ "$EMPTY_SECTIONS" -eq 0 ]; then
236
+ check_pass "All sections have content"
237
+ fi
238
+ else
239
+ check_warn "No sections/ directory found"
240
+ fi
241
+
242
+ # ===================================================================
243
+ # CHECK 9: Dead bibliography entries (in .bib but never \cite'd)
244
+ # ===================================================================
245
+ echo ""
246
+ echo "--- Citation Hygiene ---"
247
+ if [ -f "$BIB_FILE" ] && [ -d "$SECTIONS_DIR" ]; then
248
+ # Get all cite keys from .bib (POSIX-compatible, no grep -P)
249
+ BIB_KEYS=$(grep -E '^\s*@' "$BIB_FILE" 2>/dev/null | sed 's/^[^{]*{//; s/,.*//' | sed 's/^ *//; s/ *$//' | sort -u)
250
+ # Get all \cite{...} keys from tex files (handles \cite{a,b,c} and \citep, \citet)
251
+ CITE_KEYS=$(grep -roh '\\cite[tp]*{[^}]*}' "$SECTIONS_DIR"/*.tex "$MAIN_TEX" 2>/dev/null | \
252
+ sed 's/\\cite[tp]*{//; s/}//' | tr ',' '\n' | sed 's/^ *//; s/ *$//' | sort -u)
253
+
254
+ DEAD_REFS=0
255
+ while IFS= read -r key; do
256
+ [ -z "$key" ] && continue
257
+ if ! echo "$CITE_KEYS" | grep -qxF "$key"; then
258
+ echo " Dead ref: $key (in .bib but never cited)"
259
+ DEAD_REFS=$((DEAD_REFS + 1))
260
+ fi
261
+ done <<< "$BIB_KEYS"
262
+
263
+ if [ "$DEAD_REFS" -eq 0 ]; then
264
+ check_pass "All .bib entries are cited in the paper"
265
+ else
266
+ check_warn "$DEAD_REFS .bib entry(ies) never cited"
267
+ fi
268
+ fi
269
+
270
+ # ===================================================================
271
+ # CHECK 10: TODOs / FIXMEs remaining
272
+ # ===================================================================
273
+ echo ""
274
+ echo "--- Completeness ---"
275
+ TODO_COUNT=$(grep -rciE '(TODO|FIXME|XXX|HACK)' "$SECTIONS_DIR"/*.tex "$MAIN_TEX" 2>/dev/null | \
276
+ awk -F: '{s+=$NF} END{print s+0}')
277
+ if [ "$TODO_COUNT" -eq 0 ]; then
278
+ check_pass "No TODO/FIXME/XXX comments found"
279
+ else
280
+ check_warn "$TODO_COUNT TODO/FIXME comment(s) remaining:"
281
+ grep -rnE '(TODO|FIXME|XXX|HACK)' "$SECTIONS_DIR"/*.tex "$MAIN_TEX" 2>/dev/null | head -10
282
+ fi
283
+
284
+ # ===================================================================
285
+ # CHECK 11: Abstract word count
286
+ # ===================================================================
287
+ if [ -f "$SECTIONS_DIR/abstract.tex" ]; then
288
+ # Strip LaTeX commands and count words
289
+ ABSTRACT_WORDS=$(sed 's/\\[a-zA-Z]*\({[^}]*}\)\?//g; s/[{}~]//g; s/%.*//; /^\s*$/d' \
290
+ "$SECTIONS_DIR/abstract.tex" | wc -w | tr -d ' ')
291
+ if [ "$ABSTRACT_WORDS" -eq 0 ]; then
292
+ check_warn "Abstract is empty"
293
+ elif [ "$ABSTRACT_WORDS" -lt 50 ]; then
294
+ check_warn "Abstract very short ($ABSTRACT_WORDS words, expected 100-300)"
295
+ elif [ "$ABSTRACT_WORDS" -gt 350 ]; then
296
+ check_warn "Abstract too long ($ABSTRACT_WORDS words, expected 100-300)"
297
+ else
298
+ check_pass "Abstract word count OK ($ABSTRACT_WORDS words)"
299
+ fi
300
+ fi
301
+
302
+ # ===================================================================
303
+ # CHECK 12: Figures/tables referenced in text
304
+ # ===================================================================
305
+ if [ -d "$SECTIONS_DIR" ]; then
306
+ # Find all \label{fig:...} and \label{tab:...} (POSIX-compatible)
307
+ FIG_LABELS=$(grep -roh '\\label{fig:[^}]*}' "$SECTIONS_DIR"/*.tex 2>/dev/null | \
308
+ sed 's/\\label{//; s/}//' | sort -u)
309
+ TAB_LABELS=$(grep -roh '\\label{tab:[^}]*}' "$SECTIONS_DIR"/*.tex 2>/dev/null | \
310
+ sed 's/\\label{//; s/}//' | sort -u)
311
+ ALL_REFS=$(grep -roEh '\\(ref|cref|figref|tabref|eqnref)\{[^}]+\}' "$SECTIONS_DIR"/*.tex 2>/dev/null | \
312
+ sed 's/\\[a-z]*{//; s/}//' | sort -u)
313
+
314
+ UNREFD=0
315
+ for label in $FIG_LABELS $TAB_LABELS; do
316
+ if ! echo "$ALL_REFS" | grep -qxF "$label"; then
317
+ echo " Unreferenced: \\label{$label}"
318
+ UNREFD=$((UNREFD + 1))
319
+ fi
320
+ done
321
+
322
+ if [ "$UNREFD" -eq 0 ]; then
323
+ FT_COUNT=$(echo "$FIG_LABELS $TAB_LABELS" | wc -w | tr -d ' ')
324
+ if [ "$FT_COUNT" -gt 0 ]; then
325
+ check_pass "All $FT_COUNT figure/table labels referenced in text"
326
+ else
327
+ check_pass "No figures/tables to check"
328
+ fi
329
+ else
330
+ check_fail "$UNREFD figure(s)/table(s) defined but never referenced"
331
+ fi
332
+ fi
333
+
334
+ # ===================================================================
335
+ # SUMMARY
336
+ # ===================================================================
337
+ echo ""
338
+ echo "==============================="
339
+ echo " PASS: $PASS_COUNT"
340
+ echo " WARN: $WARN_COUNT"
341
+ echo " FAIL: $FAIL_COUNT"
342
+ echo "==============================="
343
+
344
+ if [ "$FAIL_COUNT" -gt 0 ]; then
345
+ echo " RESULT: FAILED"
346
+ exit 1
347
+ else
348
+ if [ "$WARN_COUNT" -gt 0 ]; then
349
+ echo " RESULT: PASSED (with warnings)"
350
+ else
351
+ echo " RESULT: ALL CHECKS PASSED"
352
+ fi
353
+ exit 0
354
+ fi