@laitszkin/apollo-toolkit 3.13.2 → 3.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/AGENTS.md +7 -7
  2. package/CHANGELOG.md +27 -0
  3. package/CLAUDE.md +8 -8
  4. package/analyse-app-logs/SKILL.md +3 -3
  5. package/bin/apollo-toolkit.ts +7 -0
  6. package/codex/codex-memory-manager/SKILL.md +2 -2
  7. package/codex/learn-skill-from-conversations/SKILL.md +3 -3
  8. package/dist/bin/apollo-toolkit.d.ts +2 -0
  9. package/dist/bin/apollo-toolkit.js +7 -0
  10. package/dist/lib/cli.d.ts +41 -0
  11. package/dist/lib/cli.js +655 -0
  12. package/dist/lib/installer.d.ts +59 -0
  13. package/dist/lib/installer.js +404 -0
  14. package/dist/lib/tool-runner.d.ts +19 -0
  15. package/dist/lib/tool-runner.js +536 -0
  16. package/dist/lib/tools/architecture.d.ts +2 -0
  17. package/dist/lib/tools/architecture.js +34 -0
  18. package/dist/lib/tools/create-specs.d.ts +2 -0
  19. package/dist/lib/tools/create-specs.js +175 -0
  20. package/dist/lib/tools/docs-to-voice.d.ts +2 -0
  21. package/dist/lib/tools/docs-to-voice.js +705 -0
  22. package/dist/lib/tools/enforce-video-aspect-ratio.d.ts +2 -0
  23. package/dist/lib/tools/enforce-video-aspect-ratio.js +312 -0
  24. package/dist/lib/tools/extract-conversations.d.ts +2 -0
  25. package/dist/lib/tools/extract-conversations.js +105 -0
  26. package/dist/lib/tools/extract-pdf-text.d.ts +2 -0
  27. package/dist/lib/tools/extract-pdf-text.js +92 -0
  28. package/dist/lib/tools/filter-logs.d.ts +2 -0
  29. package/dist/lib/tools/filter-logs.js +94 -0
  30. package/dist/lib/tools/find-github-issues.d.ts +2 -0
  31. package/dist/lib/tools/find-github-issues.js +176 -0
  32. package/dist/lib/tools/generate-storyboard-images.d.ts +2 -0
  33. package/dist/lib/tools/generate-storyboard-images.js +419 -0
  34. package/dist/lib/tools/log-cli-utils.d.ts +35 -0
  35. package/dist/lib/tools/log-cli-utils.js +233 -0
  36. package/dist/lib/tools/open-github-issue.d.ts +2 -0
  37. package/dist/lib/tools/open-github-issue.js +750 -0
  38. package/dist/lib/tools/read-github-issue.d.ts +2 -0
  39. package/dist/lib/tools/read-github-issue.js +134 -0
  40. package/dist/lib/tools/render-error-book.d.ts +2 -0
  41. package/dist/lib/tools/render-error-book.js +265 -0
  42. package/dist/lib/tools/render-katex.d.ts +2 -0
  43. package/dist/lib/tools/render-katex.js +294 -0
  44. package/dist/lib/tools/review-threads.d.ts +2 -0
  45. package/dist/lib/tools/review-threads.js +491 -0
  46. package/dist/lib/tools/search-logs.d.ts +2 -0
  47. package/dist/lib/tools/search-logs.js +164 -0
  48. package/dist/lib/tools/sync-memory-index.d.ts +2 -0
  49. package/dist/lib/tools/sync-memory-index.js +113 -0
  50. package/dist/lib/tools/validate-openai-agent-config.d.ts +2 -0
  51. package/dist/lib/tools/validate-openai-agent-config.js +184 -0
  52. package/dist/lib/tools/validate-skill-frontmatter.d.ts +2 -0
  53. package/dist/lib/tools/validate-skill-frontmatter.js +118 -0
  54. package/dist/lib/types.d.ts +82 -0
  55. package/dist/lib/types.js +2 -0
  56. package/dist/lib/updater.d.ts +34 -0
  57. package/dist/lib/updater.js +112 -0
  58. package/dist/lib/utils/format.d.ts +2 -0
  59. package/dist/lib/utils/format.js +6 -0
  60. package/dist/lib/utils/terminal.d.ts +12 -0
  61. package/dist/lib/utils/terminal.js +26 -0
  62. package/docs-to-voice/SKILL.md +0 -1
  63. package/generate-spec/SKILL.md +1 -1
  64. package/katex/SKILL.md +1 -2
  65. package/lib/cli.ts +780 -0
  66. package/lib/installer.ts +466 -0
  67. package/lib/tool-runner.ts +561 -0
  68. package/lib/tools/architecture.ts +34 -0
  69. package/lib/tools/create-specs.ts +204 -0
  70. package/lib/tools/docs-to-voice.ts +799 -0
  71. package/lib/tools/enforce-video-aspect-ratio.ts +368 -0
  72. package/lib/tools/extract-conversations.ts +114 -0
  73. package/lib/tools/extract-pdf-text.ts +99 -0
  74. package/lib/tools/filter-logs.ts +118 -0
  75. package/lib/tools/find-github-issues.ts +211 -0
  76. package/lib/tools/generate-storyboard-images.ts +455 -0
  77. package/lib/tools/log-cli-utils.ts +262 -0
  78. package/lib/tools/open-github-issue.ts +930 -0
  79. package/lib/tools/read-github-issue.ts +179 -0
  80. package/lib/tools/render-error-book.ts +300 -0
  81. package/lib/tools/render-katex.ts +325 -0
  82. package/lib/tools/review-threads.ts +590 -0
  83. package/lib/tools/search-logs.ts +200 -0
  84. package/lib/tools/sync-memory-index.ts +114 -0
  85. package/lib/tools/validate-openai-agent-config.ts +209 -0
  86. package/lib/tools/validate-skill-frontmatter.ts +124 -0
  87. package/lib/types.ts +90 -0
  88. package/lib/updater.ts +165 -0
  89. package/lib/utils/format.ts +7 -0
  90. package/lib/utils/terminal.ts +22 -0
  91. package/open-github-issue/SKILL.md +2 -2
  92. package/optimise-skill/SKILL.md +1 -1
  93. package/package.json +13 -4
  94. package/resources/project-architecture/assets/architecture.css +764 -0
  95. package/resources/project-architecture/assets/viewer.client.js +144 -0
  96. package/resources/project-architecture/index.html +42 -0
  97. package/review-spec-related-changes/SKILL.md +1 -1
  98. package/solve-issues-found-during-review/SKILL.md +2 -1
  99. package/tsconfig.json +28 -0
  100. package/analyse-app-logs/scripts/__pycache__/filter_logs_by_time.cpython-312.pyc +0 -0
  101. package/analyse-app-logs/scripts/__pycache__/log_cli_utils.cpython-312.pyc +0 -0
  102. package/analyse-app-logs/scripts/__pycache__/search_logs.cpython-312.pyc +0 -0
  103. package/analyse-app-logs/scripts/filter_logs_by_time.py +0 -64
  104. package/analyse-app-logs/scripts/log_cli_utils.py +0 -112
  105. package/analyse-app-logs/scripts/search_logs.py +0 -137
  106. package/analyse-app-logs/tests/test_filter_logs_by_time.py +0 -95
  107. package/analyse-app-logs/tests/test_search_logs.py +0 -100
  108. package/codex/codex-memory-manager/scripts/extract_recent_conversations.py +0 -369
  109. package/codex/codex-memory-manager/scripts/sync_memory_index.py +0 -130
  110. package/codex/codex-memory-manager/tests/test_extract_recent_conversations.py +0 -177
  111. package/codex/codex-memory-manager/tests/test_memory_template.py +0 -37
  112. package/codex/codex-memory-manager/tests/test_sync_memory_index.py +0 -84
  113. package/codex/learn-skill-from-conversations/scripts/extract_recent_conversations.py +0 -369
  114. package/codex/learn-skill-from-conversations/tests/test_extract_recent_conversations.py +0 -177
  115. package/docs-to-voice/scripts/__pycache__/docs_to_voice.cpython-312.pyc +0 -0
  116. package/docs-to-voice/scripts/docs_to_voice.py +0 -1385
  117. package/docs-to-voice/scripts/docs_to_voice.sh +0 -11
  118. package/docs-to-voice/tests/test_docs_to_voice_api_max_chars.py +0 -210
  119. package/docs-to-voice/tests/test_docs_to_voice_sentence_timeline.py +0 -115
  120. package/docs-to-voice/tests/test_docs_to_voice_settings.py +0 -43
  121. package/docs-to-voice/tests/test_docs_to_voice_shell_wrapper.py +0 -51
  122. package/docs-to-voice/tests/test_docs_to_voice_speech_rate.py +0 -57
  123. package/generate-spec/scripts/__pycache__/create-specscpython-312.pyc +0 -0
  124. package/generate-spec/scripts/create-specs +0 -215
  125. package/generate-spec/tests/test_create_specs.py +0 -200
  126. package/init-project-html/scripts/architecture-bootstrap-render.js +0 -16
  127. package/init-project-html/scripts/architecture.js +0 -296
  128. package/katex/scripts/__pycache__/render_katex.cpython-312.pyc +0 -0
  129. package/katex/scripts/render_katex.py +0 -247
  130. package/katex/scripts/render_katex.sh +0 -11
  131. package/katex/tests/test_render_katex.py +0 -174
  132. package/learning-error-book/scripts/render_error_book_json_to_pdf.py +0 -590
  133. package/learning-error-book/tests/test_render_error_book_json_to_pdf.py +0 -134
  134. package/open-github-issue/scripts/__pycache__/open_github_issue.cpython-312.pyc +0 -0
  135. package/open-github-issue/scripts/open_github_issue.py +0 -705
  136. package/open-github-issue/tests/test_open_github_issue.py +0 -381
  137. package/openai-text-to-image-storyboard/scripts/generate_storyboard_images.py +0 -763
  138. package/openai-text-to-image-storyboard/tests/test_generate_storyboard_images.py +0 -177
  139. package/read-github-issue/scripts/__pycache__/find_issues.cpython-312.pyc +0 -0
  140. package/read-github-issue/scripts/__pycache__/read_issue.cpython-312.pyc +0 -0
  141. package/read-github-issue/scripts/find_issues.py +0 -148
  142. package/read-github-issue/scripts/read_issue.py +0 -108
  143. package/read-github-issue/tests/test_find_issues.py +0 -127
  144. package/read-github-issue/tests/test_read_issue.py +0 -109
  145. package/resolve-review-comments/scripts/__pycache__/review_threads.cpython-312.pyc +0 -0
  146. package/resolve-review-comments/scripts/review_threads.py +0 -425
  147. package/resolve-review-comments/tests/test_review_threads.py +0 -74
  148. package/scripts/validate_openai_agent_config.py +0 -209
  149. package/scripts/validate_skill_frontmatter.py +0 -131
  150. package/text-to-short-video/scripts/__pycache__/enforce_video_aspect_ratio.cpython-312.pyc +0 -0
  151. package/text-to-short-video/scripts/enforce_video_aspect_ratio.py +0 -350
  152. package/text-to-short-video/tests/test_enforce_video_aspect_ratio.py +0 -194
  153. package/weekly-financial-event-report/scripts/extract_pdf_text_pdfkit.swift +0 -99
  154. package/weekly-financial-event-report/tests/test_extract_pdf_text_pdfkit.py +0 -64
@@ -0,0 +1,325 @@
1
+ import { execSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import type { ToolContext } from '../types';
5
+
6
+ interface KatexArgs {
7
+ tex: string | null;
8
+ inputFile: string | null;
9
+ outputFormat: string;
10
+ katexFormat: string;
11
+ displayMode: boolean;
12
+ leqno: boolean;
13
+ fleqn: boolean;
14
+ colorIsTextColor: boolean;
15
+ noThrowOnError: boolean;
16
+ outputFile: string | null;
17
+ cssHref: string;
18
+ title: string;
19
+ lang: string;
20
+ help: boolean;
21
+ macro: string[];
22
+ macroFile: string | null;
23
+ errorColor: string | null;
24
+ strict: string | null;
25
+ trust: string | null;
26
+ maxSize: number | null;
27
+ maxExpand: number | null;
28
+ minRuleThickness: number | null;
29
+ }
30
+
31
+ function parseArgs(args: string[]): KatexArgs {
32
+ const parsed: KatexArgs = {
33
+ tex: null,
34
+ inputFile: null,
35
+ outputFormat: 'html-fragment',
36
+ katexFormat: 'htmlAndMathml',
37
+ displayMode: false,
38
+ leqno: false,
39
+ fleqn: false,
40
+ colorIsTextColor: false,
41
+ noThrowOnError: false,
42
+ outputFile: null,
43
+ cssHref: 'https://cdn.jsdelivr.net/npm/katex@0.16.25/dist/katex.min.css',
44
+ title: 'KaTeX Render',
45
+ lang: 'en',
46
+ help: false,
47
+ macro: [],
48
+ macroFile: null,
49
+ errorColor: null,
50
+ strict: null,
51
+ trust: null,
52
+ maxSize: null,
53
+ maxExpand: null,
54
+ minRuleThickness: null,
55
+ };
56
+
57
+ for (let i = 0; i < args.length; i++) {
58
+ const arg = args[i];
59
+ if (arg === '--help' || arg === '-h') {
60
+ parsed.help = true;
61
+ continue;
62
+ }
63
+
64
+ if (arg.startsWith('--')) {
65
+ const eqIndex = arg.indexOf('=');
66
+ let key: string;
67
+ let value: string | boolean | null;
68
+
69
+ if (eqIndex !== -1) {
70
+ key = arg.slice(2, eqIndex);
71
+ value = arg.slice(eqIndex + 1);
72
+ } else {
73
+ key = arg.slice(2);
74
+ const next = args[i + 1];
75
+ if (next !== undefined && !next.startsWith('--')) {
76
+ value = next;
77
+ i++;
78
+ } else {
79
+ value = true;
80
+ }
81
+ }
82
+
83
+ switch (key) {
84
+ case 'tex':
85
+ parsed.tex = String(value);
86
+ break;
87
+ case 'input-file':
88
+ parsed.inputFile = String(value);
89
+ break;
90
+ case 'output-format':
91
+ if (['html-fragment', 'html-page', 'markdown-inline', 'markdown-block', 'json'].includes(String(value))) {
92
+ parsed.outputFormat = String(value);
93
+ }
94
+ break;
95
+ case 'katex-format':
96
+ if (['html', 'mathml', 'htmlAndMathml'].includes(String(value))) {
97
+ parsed.katexFormat = String(value);
98
+ }
99
+ break;
100
+ case 'display-mode':
101
+ parsed.displayMode = value === true || value === 'true';
102
+ break;
103
+ case 'leqno':
104
+ parsed.leqno = value === true || value === 'true';
105
+ break;
106
+ case 'fleqn':
107
+ parsed.fleqn = value === true || value === 'true';
108
+ break;
109
+ case 'color-is-text-color':
110
+ parsed.colorIsTextColor = value === true || value === 'true';
111
+ break;
112
+ case 'no-throw-on-error':
113
+ parsed.noThrowOnError = value === true || value === 'true';
114
+ break;
115
+ case 'output-file':
116
+ parsed.outputFile = String(value);
117
+ break;
118
+ case 'css-href':
119
+ parsed.cssHref = String(value);
120
+ break;
121
+ case 'title':
122
+ parsed.title = String(value);
123
+ break;
124
+ case 'lang':
125
+ parsed.lang = String(value);
126
+ break;
127
+ case 'macro':
128
+ parsed.macro.push(String(value));
129
+ break;
130
+ case 'macro-file':
131
+ parsed.macroFile = String(value);
132
+ break;
133
+ case 'error-color':
134
+ parsed.errorColor = String(value);
135
+ break;
136
+ case 'strict':
137
+ parsed.strict = String(value);
138
+ break;
139
+ case 'trust':
140
+ parsed.trust = String(value);
141
+ break;
142
+ case 'max-size':
143
+ parsed.maxSize = Number(value);
144
+ break;
145
+ case 'max-expand':
146
+ parsed.maxExpand = Number(value);
147
+ break;
148
+ case 'min-rule-thickness':
149
+ parsed.minRuleThickness = Number(value);
150
+ break;
151
+ }
152
+ }
153
+ }
154
+
155
+ return parsed;
156
+ }
157
+
158
+ function loadTex(opts: KatexArgs): string {
159
+ if (opts.inputFile) {
160
+ const inputPath = path.resolve(opts.inputFile);
161
+ if (!fs.existsSync(inputPath)) {
162
+ throw new Error(`Input file not found: ${inputPath}`);
163
+ }
164
+ return fs.readFileSync(inputPath, 'utf-8').trim();
165
+ }
166
+ return (opts.tex || '').trim();
167
+ }
168
+
169
+ function buildHtmlPage(renderedHtml: string, opts: KatexArgs): string {
170
+ const cssLink = opts.cssHref
171
+ ? ` <link rel="stylesheet" href="${opts.cssHref}">\n`
172
+ : '';
173
+ return (
174
+ '<!DOCTYPE html>\n' +
175
+ `<html lang="${opts.lang}">\n` +
176
+ '<head>\n' +
177
+ ' <meta charset="utf-8">\n' +
178
+ ` <title>${opts.title}</title>\n` +
179
+ cssLink +
180
+ '</head>\n' +
181
+ '<body>\n' +
182
+ `${renderedHtml}\n` +
183
+ '</body>\n' +
184
+ '</html>\n'
185
+ );
186
+ }
187
+
188
+ function wrapOutput(renderedHtml: string, tex: string, opts: KatexArgs): string {
189
+ switch (opts.outputFormat) {
190
+ case 'html-fragment':
191
+ return `${renderedHtml}\n`;
192
+ case 'html-page':
193
+ return buildHtmlPage(renderedHtml, opts);
194
+ case 'markdown-inline':
195
+ return `${renderedHtml}\n`;
196
+ case 'markdown-block':
197
+ return `\n${renderedHtml}\n`;
198
+ case 'json':
199
+ return JSON.stringify(
200
+ {
201
+ tex,
202
+ displayMode: opts.displayMode,
203
+ katexFormat: opts.katexFormat,
204
+ cssHref: opts.cssHref,
205
+ content: renderedHtml,
206
+ },
207
+ null,
208
+ 2,
209
+ ) + '\n';
210
+ default:
211
+ throw new Error(`Unsupported output format: ${opts.outputFormat}`);
212
+ }
213
+ }
214
+
215
+ function writeOutput(content: string, outputFile: string | null, stdout: NodeJS.WriteStream): void {
216
+ if (!outputFile) {
217
+ stdout.write(content);
218
+ return;
219
+ }
220
+ const outputPath = path.resolve(outputFile);
221
+ fs.mkdirSync(path.dirname(outputPath), { recursive: true });
222
+ fs.writeFileSync(outputPath, content, 'utf-8');
223
+ stdout.write(`${outputPath}\n`);
224
+ }
225
+
226
+ export async function renderKatexHandler(args: string[], context: ToolContext): Promise<number> {
227
+ const stdout = context.stdout || process.stdout;
228
+ const stderr = context.stderr || process.stderr;
229
+
230
+ try {
231
+ const opts = parseArgs(args);
232
+
233
+ if (opts.help) {
234
+ stdout.write(`Usage: apltk render-katex [options]
235
+
236
+ Render TeX with KaTeX and emit insertion-ready output.
237
+
238
+ Options:
239
+ --tex <string> Raw TeX expression without delimiters
240
+ --input-file <path> Path to a text file containing raw TeX
241
+ --output-format <format> html-fragment (default) | html-page | markdown-inline | markdown-block | json
242
+ --katex-format <format> html | mathml | htmlAndMathml (default)
243
+ --display-mode Render in display mode
244
+ --output-file <path> Write output to a file
245
+ --css-href <url> Stylesheet href (default: KaTeX CDN)
246
+ --title <text> Document title for html-page
247
+ --lang <code> HTML lang attribute (default: en)
248
+ `);
249
+ return 0;
250
+ }
251
+
252
+ const tex = loadTex(opts);
253
+ if (!tex) {
254
+ stderr.write('Error: Input TeX is empty.\n');
255
+ return 1;
256
+ }
257
+
258
+ // Build npx katex command
259
+ const cmdArgs: string[] = [
260
+ 'npx',
261
+ '--yes',
262
+ '--package',
263
+ 'katex',
264
+ 'katex',
265
+ '--format',
266
+ opts.katexFormat,
267
+ ];
268
+
269
+ if (opts.displayMode) cmdArgs.push('--display-mode');
270
+ if (opts.leqno === true) cmdArgs.push('--leqno');
271
+ if (opts.fleqn === true) cmdArgs.push('--fleqn');
272
+ if (opts.colorIsTextColor === true) cmdArgs.push('--color-is-text-color');
273
+ if (opts.noThrowOnError === true) cmdArgs.push('--no-throw-on-error');
274
+
275
+ if (opts.errorColor) cmdArgs.push('--error-color', opts.errorColor);
276
+ if (opts.strict) cmdArgs.push('--strict', opts.strict);
277
+ if (opts.trust) cmdArgs.push('--trust', opts.trust);
278
+ if (opts.maxSize !== null) cmdArgs.push('--max-size', String(opts.maxSize));
279
+ if (opts.maxExpand !== null) cmdArgs.push('--max-expand', String(opts.maxExpand));
280
+ if (opts.minRuleThickness !== null) cmdArgs.push('--min-rule-thickness', String(opts.minRuleThickness));
281
+ // Handle macro args
282
+ for (const macro of opts.macro) {
283
+ cmdArgs.push('--macro', macro);
284
+ }
285
+ if (opts.macroFile) cmdArgs.push('--macro-file', opts.macroFile);
286
+
287
+ // Write tex to temp file and pass it to katex
288
+ const tmpFile = path.join(
289
+ fs.mkdtempSync('katex-'),
290
+ 'input.tex',
291
+ );
292
+ fs.mkdirSync(path.dirname(tmpFile), { recursive: true });
293
+ fs.writeFileSync(tmpFile, tex + '\n', 'utf-8');
294
+ cmdArgs.push('--input', tmpFile);
295
+
296
+ let renderedHtml: string;
297
+ try {
298
+ const result = execSync(cmdArgs.join(' '), {
299
+ encoding: 'utf-8',
300
+ maxBuffer: 10 * 1024 * 1024,
301
+ timeout: 60000,
302
+ });
303
+ renderedHtml = result.trim();
304
+ } catch (err: unknown) {
305
+ const message = err instanceof Error ? err.message : 'KaTeX CLI failed.';
306
+ stderr.write(`Error: ${message}\n`);
307
+ return 1;
308
+ } finally {
309
+ try {
310
+ fs.unlinkSync(tmpFile);
311
+ fs.rmdirSync(path.dirname(tmpFile));
312
+ } catch {
313
+ // ignore cleanup errors
314
+ }
315
+ }
316
+
317
+ const wrapped = wrapOutput(renderedHtml, tex, opts);
318
+ writeOutput(wrapped, opts.outputFile, stdout);
319
+ return 0;
320
+ } catch (err: unknown) {
321
+ const message = err instanceof Error ? err.message : 'Unknown error';
322
+ stderr.write(`Error: ${message}\n`);
323
+ return 1;
324
+ }
325
+ }