@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,96 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Remove background from images locally using rembg.
4
+
5
+ This is the logo-creator skill's local fallback for background removal
6
+ when the image-gen tool's remove_bg action (BRIA RMBG 2.0 via Replicate)
7
+ produces poor results or is unavailable.
8
+
9
+ First run will download the model (~170MB). Subsequent runs are instant.
10
+
11
+ Usage:
12
+ python3 remove_bg.py <input_path> <output_path>
13
+ python3 remove_bg.py <input_path> # outputs to <input>-transparent.png
14
+ python3 remove_bg.py --batch <dir> # process all images in directory
15
+
16
+ Requirements:
17
+ pip install rembg pillow onnxruntime
18
+ """
19
+
20
+ import sys
21
+ import os
22
+ from pathlib import Path
23
+
24
+ try:
25
+ from rembg import remove
26
+ from PIL import Image
27
+ HAS_REMBG = True
28
+ except ImportError:
29
+ HAS_REMBG = False
30
+
31
+
32
+ def remove_background(input_path: str, output_path: str | None = None) -> str:
33
+ """Remove background from a single image. Returns output path."""
34
+ if not HAS_REMBG:
35
+ print("Error: rembg not installed. Run: pip install rembg pillow onnxruntime")
36
+ sys.exit(1)
37
+
38
+ if not os.path.exists(input_path):
39
+ print(f"Error: File not found: {input_path}")
40
+ sys.exit(1)
41
+
42
+ if output_path is None:
43
+ stem = Path(input_path).stem
44
+ parent = Path(input_path).parent
45
+ output_path = str(parent / f"{stem}-transparent.png")
46
+
47
+ img = Image.open(input_path).convert("RGBA")
48
+ result = remove(img)
49
+
50
+ # Ensure output directory exists
51
+ os.makedirs(os.path.dirname(os.path.abspath(output_path)), exist_ok=True)
52
+ result.save(output_path, "PNG")
53
+
54
+ in_size = os.path.getsize(input_path) / 1024
55
+ out_size = os.path.getsize(output_path) / 1024
56
+ print(f" {Path(input_path).name} ({in_size:.0f}KB) -> {Path(output_path).name} ({out_size:.0f}KB)")
57
+ return output_path
58
+
59
+
60
+ def batch_remove(directory: str) -> list[str]:
61
+ """Remove backgrounds from all images in a directory."""
62
+ exts = {".png", ".jpg", ".jpeg", ".webp"}
63
+ results = []
64
+ for f in sorted(os.listdir(directory)):
65
+ if Path(f).suffix.lower() in exts and "-transparent" not in f:
66
+ input_path = os.path.join(directory, f)
67
+ output_path = os.path.join(directory, f"{Path(f).stem}-transparent.png")
68
+ results.append(remove_background(input_path, output_path))
69
+ return results
70
+
71
+
72
+ def main():
73
+ if len(sys.argv) < 2:
74
+ print(__doc__)
75
+ sys.exit(1)
76
+
77
+ if not HAS_REMBG:
78
+ print("Error: rembg not installed.")
79
+ print("Install: pip install rembg pillow onnxruntime")
80
+ sys.exit(1)
81
+
82
+ if sys.argv[1] == "--batch":
83
+ if len(sys.argv) < 3:
84
+ print("Usage: python3 remove_bg.py --batch <directory>")
85
+ sys.exit(1)
86
+ results = batch_remove(sys.argv[2])
87
+ print(f"\nDone! {len(results)} images processed.")
88
+ else:
89
+ input_path = sys.argv[1]
90
+ output_path = sys.argv[2] if len(sys.argv) > 2 else None
91
+ remove_background(input_path, output_path)
92
+ print("Done!")
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
@@ -0,0 +1,261 @@
1
+ ---
2
+ name: kortix-memory
3
+ description: "Persistent memory system matching OpenClaw's architecture. Four tiers: MEMORY.md (core, auto-loaded via plugin), memory/*.md (episodic, daily logs + topic files), journal/*.md (session summaries), knowledge/*.md (research/reference). Native memory_search and memory_get tools. Pre-compaction memory flush prevents memory loss."
4
+ ---
5
+
6
+ # Memory System
7
+
8
+ Persistent memory lives at `workspace/.kortix/`. It survives session restarts and container reboots.
9
+
10
+ ## Architecture
11
+
12
+ The memory system has 3 layers:
13
+
14
+ 1. **Memory Plugin** (`plugin/memory.ts`) — Auto-loads MEMORY.md + daily logs into system prompt, flushes memories before compaction
15
+ 2. **Memory Tools** (`tools/memory-search.ts`, `tools/memory-get.ts`) — Structured hybrid search and secure file access
16
+ 3. **Memory Files** — Plain Markdown files on disk, the source of truth
17
+
18
+ ## Layout
19
+
20
+ ```
21
+ workspace/.kortix/
22
+ ├── MEMORY.md ← Core memory. Auto-loaded every turn by plugin.
23
+ ├── memory/ ← Episodic memory. Daily logs + topic files.
24
+ │ ├── YYYY-MM-DD.md ← Daily append-only log (today + yesterday auto-loaded)
25
+ │ └── *.md ← Topic files (decisions.md, api-patterns.md, etc.)
26
+ ├── journal/ ← Session summaries. Written at session end.
27
+ │ └── *.md
28
+ ├── knowledge/ ← Research reports, reference material.
29
+ │ └── *.md
30
+ └── sessions/ ← Exported session transcripts (auto-indexed by LSS).
31
+ └── *.md
32
+ ```
33
+
34
+ ## Four Memory Tiers
35
+
36
+ ### Tier 1: Core Memory — `MEMORY.md` (what you know NOW)
37
+
38
+ **Auto-loaded by the memory plugin into every turn's system prompt.** No tool call needed.
39
+
40
+ Single file containing everything the agent needs to know immediately.
41
+
42
+ #### Structure
43
+
44
+ ```markdown
45
+ # Memory
46
+
47
+ ## Identity
48
+ [Agent name, role, email, key capabilities]
49
+
50
+ ## User
51
+ [Name, role, preferences, communication style]
52
+
53
+ ## Project
54
+ [Current workspace: tech stack, architecture, key commands, conventions]
55
+
56
+ ## Scratchpad
57
+ [Current focus, pending tasks, handoff notes for next session]
58
+ ```
59
+
60
+ #### Rules
61
+
62
+ - **Keep it under ~3000 tokens.** If a section grows too large, move details to `memory/` and leave a summary + pointer.
63
+ - **Delta-only updates.** Never rewrite the whole file. Only update specific sections or append to them.
64
+ - **Update constantly.** User reveals a preference? Update User. Learn a build command? Update Project.
65
+ - **Scratchpad is ephemeral.** Clear completed items. Keep pending items for next session.
66
+
67
+ #### If MEMORY.md doesn't exist
68
+
69
+ Create it with sensible defaults:
70
+
71
+ ```markdown
72
+ # Memory
73
+
74
+ ## Identity
75
+ Kortix — autonomous AI agent with persistent memory, full Linux access, and internet connectivity.
76
+
77
+ ## User
78
+ Not yet known. Introduce yourself so I can remember you.
79
+
80
+ ## Project
81
+ Not yet scanned. Run `/init` to scan the workspace.
82
+
83
+ ## Scratchpad
84
+ First session. Memory system initialized.
85
+ ```
86
+
87
+ ### Tier 2: Episodic Memory — `memory/*.md` (what happened)
88
+
89
+ Past experiences, daily logs, decisions, lessons learned. **Searched on demand** via `memory_search` tool or `lss`.
90
+
91
+ #### Daily Logs (OpenClaw-style)
92
+
93
+ Write daily entries to `memory/YYYY-MM-DD.md`. Today + yesterday are **auto-loaded** by the memory plugin.
94
+
95
+ ```markdown
96
+ # 2025-02-13
97
+
98
+ ## 14:30 — User onboarding
99
+ - User name: Marko. Role: Founder at Kortix.
100
+ - Prefers autonomous execution, minimal questions.
101
+ - Workspace: monorepo with Next.js frontend, Hono backend, Docker sandbox.
102
+
103
+ ## 16:45 — Memory system implementation
104
+ - Implemented OpenClaw-style memory plugin with pre-compaction flush.
105
+ - Created native memory_search and memory_get tools.
106
+ - Key decision: hybrid lss+grep approach for search.
107
+ ```
108
+
109
+ Format: `## HH:MM — [Topic]` followed by bullet points. Append-only.
110
+
111
+ #### Topic Files
112
+
113
+ For knowledge that doesn't fit in core memory or daily logs:
114
+ - `memory/decisions.md` — Key architectural decisions
115
+ - `memory/api-patterns.md` — Discovered API patterns
116
+ - `memory/agent-performance.md` — Which agents excel at what tasks
117
+
118
+ Use descriptive filenames. No required naming convention.
119
+
120
+ ### Tier 3: Journal — `journal/*.md` (session summaries)
121
+
122
+ Written at session end via `/journal` command. Captures:
123
+ - What happened this session
124
+ - Tasks completed
125
+ - Decisions made
126
+ - Lessons learned
127
+ - Open items
128
+
129
+ ### Tier 4: Knowledge — `knowledge/*.md` (reference material)
130
+
131
+ Research reports, accumulated expertise, reference documents.
132
+ Written by `@kortix-research` or manually by the agent.
133
+
134
+ ## Memory Tools
135
+
136
+ ### `memory_search` — Hybrid semantic + keyword search
137
+
138
+ **Use this instead of running lss/grep via bash.**
139
+
140
+ ```
141
+ memory_search(query: "user deployment preferences")
142
+ memory_search(query: "database migration decisions", scope: "memory")
143
+ memory_search(query: "what did we discuss about auth", scope: "all")
144
+ memory_search(query: "session about API design", scope: "sessions")
145
+ ```
146
+
147
+ Parameters:
148
+ - `query` — Natural language search query
149
+ - `scope` — `all` (default), `core`, `memory`, `journal`, `knowledge`, `sessions`
150
+ - `max_results` — 1-20 (default: 6)
151
+
152
+ Returns structured JSON with: snippet, file_path, line_range, score, source (semantic/keyword).
153
+
154
+ ### `memory_get` — Read a specific memory file
155
+
156
+ **Use this instead of read/cat for memory files.**
157
+
158
+ ```
159
+ memory_get(path: "MEMORY.md")
160
+ memory_get(path: "memory/decisions.md")
161
+ memory_get(path: "memory/2025-02-13.md", start_line: 10, lines: 20)
162
+ ```
163
+
164
+ Parameters:
165
+ - `path` — Relative to `.kortix/` or absolute path
166
+ - `start_line` — Start line (1-indexed, optional)
167
+ - `lines` — Number of lines to read (optional)
168
+
169
+ Security: restricted to `workspace/.kortix/`, rejects symlinks, non-Markdown files.
170
+
171
+ ## Pre-Compaction Memory Flush
172
+
173
+ **The memory plugin automatically handles this.** When the context window is about to compact:
174
+
175
+ 1. Plugin injects flush instructions into the compaction context
176
+ 2. Agent is prompted to write durable memories to `memory/YYYY-MM-DD.md`
177
+ 3. Agent updates MEMORY.md Scratchpad with current state
178
+ 4. One flush per compaction cycle (tracked per session)
179
+
180
+ This prevents memory loss during long sessions — the single most important feature matching OpenClaw's design.
181
+
182
+ ## Session Transcript Indexing
183
+
184
+ Past sessions can be exported to Markdown for semantic search:
185
+
186
+ ```bash
187
+ # Export new sessions to workspace/.kortix/sessions/
188
+ python3 ~/.opencode/skills/KORTIX-memory/scripts/export-sessions.py
189
+
190
+ # Re-export everything
191
+ python3 ~/.opencode/skills/KORTIX-memory/scripts/export-sessions.py --force
192
+
193
+ # Export since a date
194
+ python3 ~/.opencode/skills/KORTIX-memory/scripts/export-sessions.py --since 2025-01-01
195
+ ```
196
+
197
+ LSS auto-indexes files in `workspace/.kortix/sessions/`.
198
+
199
+ ## Session Lifecycle
200
+
201
+ ### Start
202
+ 1. **Automatic:** Memory plugin loads MEMORY.md + daily logs into system prompt
203
+ 2. Check Scratchpad for pending tasks — acknowledge them
204
+ 3. If MEMORY.md doesn't exist, create it with defaults
205
+
206
+ ### During
207
+ 4. Update Scratchpad with current focus
208
+ 5. Update User/Project sections when you learn something
209
+ 6. Write daily entries to `memory/YYYY-MM-DD.md` for notable events
210
+ 7. Write to topic files in `memory/` for lasting knowledge
211
+ 8. Use `memory_search` to recall past decisions and context
212
+
213
+ ### Pre-Compaction (automatic)
214
+ 9. Memory plugin triggers flush before context compaction
215
+ 10. Write durable memories to daily log
216
+ 11. Update Scratchpad with handoff notes
217
+
218
+ ### End
219
+ 12. Update Scratchpad: clear completed items, leave pending items
220
+ 13. Optionally run `/journal` for a session summary
221
+
222
+ ## Semantic Search
223
+
224
+ Full semantic search over everything — powered by `lss` (BM25 + embeddings).
225
+
226
+ **Prefer `memory_search` tool** for memory-specific queries. Use raw `lss` for broader file search:
227
+
228
+ ```bash
229
+ # Search all Desktop files
230
+ lss "authentication flow" -p /workspace --json -k 10
231
+
232
+ # Search a specific project
233
+ lss "database schema" -p /workspace/myproject/ --json -k 5
234
+ ```
235
+
236
+ Load the `kortix-semantic-search` skill for full LSS details.
237
+
238
+ ## Configuration
239
+
240
+ Memory behavior is configured in `memory.json` (alongside `opencode.jsonc`):
241
+
242
+ ```json
243
+ {
244
+ "enabled": true,
245
+ "basePath": "/workspace/.kortix",
246
+ "search": { "maxResults": 6, "minScore": 0.35 },
247
+ "flush": { "enabled": true, "softThresholdTokens": 4000 },
248
+ "inject": { "coreMemory": true, "dailyLogs": true, "dailyLogDays": 2 }
249
+ }
250
+ ```
251
+
252
+ ## Rules
253
+
254
+ 1. **Always update, never stale.** If information changes, update immediately.
255
+ 2. **Delta-only.** Never rewrite MEMORY.md in full. Only update specific sections or append.
256
+ 3. **Be specific.** Include dates, exact values, names. "User prefers Bun" > "User has preferences".
257
+ 4. **Learn from corrections.** User corrects you? Update MEMORY.md immediately. Same mistake twice is unacceptable.
258
+ 5. **Proactively remember.** Don't wait to be told. If the user reveals something worth persisting, write it now.
259
+ 6. **Don't duplicate.** Use `memory_search` before adding. Update existing entries rather than creating duplicates.
260
+ 7. **Daily logs are append-only.** Never edit past daily entries. Only append new entries to today's log.
261
+ 8. **Use the tools.** Prefer `memory_search` and `memory_get` over raw bash commands for memory access.