shortcutxl 0.2.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.
- package/README.md +59 -0
- package/agent-docs/README.md +397 -0
- package/agent-docs/docs/compaction.md +390 -0
- package/agent-docs/docs/custom-provider.md +580 -0
- package/agent-docs/docs/development.md +69 -0
- package/agent-docs/docs/extensions.md +1971 -0
- package/agent-docs/docs/json.md +79 -0
- package/agent-docs/docs/keybindings.md +174 -0
- package/agent-docs/docs/models.md +293 -0
- package/agent-docs/docs/packages.md +209 -0
- package/agent-docs/docs/prompt-templates.md +67 -0
- package/agent-docs/docs/providers.md +186 -0
- package/agent-docs/docs/rpc.md +1317 -0
- package/agent-docs/docs/sdk.md +962 -0
- package/agent-docs/docs/session.md +412 -0
- package/agent-docs/docs/settings.md +223 -0
- package/agent-docs/docs/shell-aliases.md +13 -0
- package/agent-docs/docs/skills.md +231 -0
- package/agent-docs/docs/terminal-setup.md +70 -0
- package/agent-docs/docs/termux.md +127 -0
- package/agent-docs/docs/themes.md +295 -0
- package/agent-docs/docs/tree.md +219 -0
- package/agent-docs/docs/tui.md +887 -0
- package/agent-docs/docs/windows.md +17 -0
- package/agent-docs/examples/README.md +25 -0
- package/agent-docs/examples/extensions/README.md +205 -0
- package/agent-docs/examples/extensions/antigravity-image-gen.ts +447 -0
- package/agent-docs/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/agent-docs/examples/extensions/bash-spawn-hook.ts +30 -0
- package/agent-docs/examples/extensions/bookmark.ts +50 -0
- package/agent-docs/examples/extensions/built-in-tool-renderer.ts +256 -0
- package/agent-docs/examples/extensions/claude-rules.ts +86 -0
- package/agent-docs/examples/extensions/commands.ts +75 -0
- package/agent-docs/examples/extensions/confirm-destructive.ts +59 -0
- package/agent-docs/examples/extensions/custom-compaction.ts +126 -0
- package/agent-docs/examples/extensions/custom-footer.ts +63 -0
- package/agent-docs/examples/extensions/custom-header.ts +73 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/index.ts +660 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/agent-docs/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/index.ts +362 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/agent-docs/examples/extensions/custom-provider-gitlab-duo/test.ts +88 -0
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/index.ts +349 -0
- package/agent-docs/examples/extensions/custom-provider-qwen-cli/package.json +16 -0
- package/agent-docs/examples/extensions/dirty-repo-guard.ts +56 -0
- package/agent-docs/examples/extensions/doom-overlay/README.md +46 -0
- package/agent-docs/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/agent-docs/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-engine.ts +186 -0
- package/agent-docs/examples/extensions/doom-overlay/doom-keys.ts +108 -0
- package/agent-docs/examples/extensions/doom-overlay/index.ts +74 -0
- package/agent-docs/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/agent-docs/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/agent-docs/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/agent-docs/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/agent-docs/examples/extensions/dynamic-resources/index.ts +15 -0
- package/agent-docs/examples/extensions/dynamic-tools.ts +77 -0
- package/agent-docs/examples/extensions/event-bus.ts +43 -0
- package/agent-docs/examples/extensions/file-trigger.ts +41 -0
- package/agent-docs/examples/extensions/git-checkpoint.ts +53 -0
- package/agent-docs/examples/extensions/handoff.ts +155 -0
- package/agent-docs/examples/extensions/hello.ts +25 -0
- package/agent-docs/examples/extensions/inline-bash.ts +94 -0
- package/agent-docs/examples/extensions/input-transform.ts +43 -0
- package/agent-docs/examples/extensions/interactive-shell.ts +209 -0
- package/agent-docs/examples/extensions/mac-system-theme.ts +47 -0
- package/agent-docs/examples/extensions/message-renderer.ts +59 -0
- package/agent-docs/examples/extensions/minimal-mode.ts +430 -0
- package/agent-docs/examples/extensions/modal-editor.ts +90 -0
- package/agent-docs/examples/extensions/model-status.ts +31 -0
- package/agent-docs/examples/extensions/notify.ts +55 -0
- package/agent-docs/examples/extensions/overlay-qa-tests.ts +936 -0
- package/agent-docs/examples/extensions/overlay-test.ts +159 -0
- package/agent-docs/examples/extensions/permission-gate.ts +37 -0
- package/agent-docs/examples/extensions/pirate.ts +47 -0
- package/agent-docs/examples/extensions/plan-mode/README.md +65 -0
- package/agent-docs/examples/extensions/plan-mode/index.ts +363 -0
- package/agent-docs/examples/extensions/plan-mode/utils.ts +173 -0
- package/agent-docs/examples/extensions/preset.ts +418 -0
- package/agent-docs/examples/extensions/protected-paths.ts +30 -0
- package/agent-docs/examples/extensions/qna.ts +122 -0
- package/agent-docs/examples/extensions/question.ts +278 -0
- package/agent-docs/examples/extensions/questionnaire.ts +440 -0
- package/agent-docs/examples/extensions/rainbow-editor.ts +90 -0
- package/agent-docs/examples/extensions/reload-runtime.ts +37 -0
- package/agent-docs/examples/extensions/rpc-demo.ts +124 -0
- package/agent-docs/examples/extensions/sandbox/index.ts +324 -0
- package/agent-docs/examples/extensions/sandbox/package-lock.json +92 -0
- package/agent-docs/examples/extensions/sandbox/package.json +19 -0
- package/agent-docs/examples/extensions/send-user-message.ts +97 -0
- package/agent-docs/examples/extensions/session-name.ts +27 -0
- package/agent-docs/examples/extensions/shutdown-command.ts +69 -0
- package/agent-docs/examples/extensions/snake.ts +343 -0
- package/agent-docs/examples/extensions/space-invaders.ts +566 -0
- package/agent-docs/examples/extensions/ssh.ts +233 -0
- package/agent-docs/examples/extensions/status-line.ts +40 -0
- package/agent-docs/examples/extensions/subagent/README.md +172 -0
- package/agent-docs/examples/extensions/subagent/agents/planner.md +37 -0
- package/agent-docs/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/agent-docs/examples/extensions/subagent/agents/scout.md +50 -0
- package/agent-docs/examples/extensions/subagent/agents/worker.md +24 -0
- package/agent-docs/examples/extensions/subagent/agents.ts +130 -0
- package/agent-docs/examples/extensions/subagent/index.ts +1068 -0
- package/agent-docs/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/agent-docs/examples/extensions/subagent/prompts/implement.md +10 -0
- package/agent-docs/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/agent-docs/examples/extensions/summarize.ts +206 -0
- package/agent-docs/examples/extensions/system-prompt-header.ts +17 -0
- package/agent-docs/examples/extensions/timed-confirm.ts +72 -0
- package/agent-docs/examples/extensions/titlebar-spinner.ts +58 -0
- package/agent-docs/examples/extensions/todo.ts +314 -0
- package/agent-docs/examples/extensions/tool-override.ts +146 -0
- package/agent-docs/examples/extensions/tools.ts +145 -0
- package/agent-docs/examples/extensions/trigger-compact.ts +40 -0
- package/agent-docs/examples/extensions/truncated-tool.ts +194 -0
- package/agent-docs/examples/extensions/widget-placement.ts +17 -0
- package/agent-docs/examples/extensions/with-deps/index.ts +37 -0
- package/agent-docs/examples/extensions/with-deps/package-lock.json +31 -0
- package/agent-docs/examples/extensions/with-deps/package.json +22 -0
- package/agent-docs/examples/rpc-extension-ui.ts +654 -0
- package/agent-docs/examples/sdk/01-minimal.ts +22 -0
- package/agent-docs/examples/sdk/02-custom-model.ts +48 -0
- package/agent-docs/examples/sdk/03-custom-prompt.ts +55 -0
- package/agent-docs/examples/sdk/04-skills.ts +53 -0
- package/agent-docs/examples/sdk/05-tools.ts +56 -0
- package/agent-docs/examples/sdk/06-extensions.ts +88 -0
- package/agent-docs/examples/sdk/07-context-files.ts +40 -0
- package/agent-docs/examples/sdk/08-prompt-templates.ts +47 -0
- package/agent-docs/examples/sdk/09-api-keys-and-oauth.ts +48 -0
- package/agent-docs/examples/sdk/10-settings.ts +54 -0
- package/agent-docs/examples/sdk/11-sessions.ts +48 -0
- package/agent-docs/examples/sdk/12-full-control.ts +82 -0
- package/agent-docs/examples/sdk/README.md +144 -0
- package/agent-docs/xll-skill.md +61 -0
- package/agent-docs/xll-spec.md +110 -0
- package/dist/cli/args.js +290 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/file-processor.js +79 -0
- package/dist/cli/list-models.js +92 -0
- package/dist/cli/package-commands.js +210 -0
- package/dist/cli/report-settings-errors.js +11 -0
- package/dist/cli/session-picker.js +34 -0
- package/dist/cli.js +19 -0
- package/dist/config.js +288 -0
- package/dist/core/abort.js +15 -0
- package/dist/core/agent-loop.js +352 -0
- package/dist/core/agent-session.js +2019 -0
- package/dist/core/agent.js +410 -0
- package/dist/core/auth-storage.js +456 -0
- package/dist/core/bash-executor.js +222 -0
- package/dist/core/compaction/branch-summarization.js +242 -0
- package/dist/core/compaction/compaction.js +610 -0
- package/dist/core/compaction/index.js +7 -0
- package/dist/core/compaction/utils.js +139 -0
- package/dist/core/defaults.js +6 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/exec.js +71 -0
- package/dist/core/export-html/ansi-to-html.js +256 -0
- package/dist/core/export-html/index.js +238 -0
- package/dist/core/export-html/session-view-model.js +342 -0
- package/dist/core/export-html/template.css +1110 -0
- package/dist/core/export-html/template.html +76 -0
- package/dist/core/export-html/template.js +1990 -0
- package/dist/core/export-html/tool-renderer.js +63 -0
- package/dist/core/export-html/vendor/highlight.min.js +7725 -0
- package/dist/core/export-html/vendor/marked.min.js +1803 -0
- package/dist/core/extensions/index.js +9 -0
- package/dist/core/extensions/loader.js +422 -0
- package/dist/core/extensions/runner.js +651 -0
- package/dist/core/extensions/types.js +35 -0
- package/dist/core/extensions/wrapper.js +102 -0
- package/dist/core/footer-data-provider.js +162 -0
- package/dist/core/index.js +9 -0
- package/dist/core/keybindings.js +153 -0
- package/dist/core/messages.js +133 -0
- package/dist/core/model-registry.js +539 -0
- package/dist/core/model-resolver.js +370 -0
- package/dist/core/package-manager.js +1485 -0
- package/dist/core/prompt-templates.js +253 -0
- package/dist/core/resolve-config-value.js +59 -0
- package/dist/core/resource-loader.js +700 -0
- package/dist/core/sdk.js +197 -0
- package/dist/core/session-bash.js +99 -0
- package/dist/core/session-compaction.js +165 -0
- package/dist/core/session-manager.js +1153 -0
- package/dist/core/session-models.js +99 -0
- package/dist/core/session-retry.js +155 -0
- package/dist/core/settings-manager.js +572 -0
- package/dist/core/skills.js +382 -0
- package/dist/core/slash-commands.js +31 -0
- package/dist/core/system-prompt.js +161 -0
- package/dist/core/theme.js +770 -0
- package/dist/core/timings.js +26 -0
- package/dist/core/tools/bash.js +258 -0
- package/dist/core/tools/edit-diff.js +245 -0
- package/dist/core/tools/edit.js +148 -0
- package/dist/core/tools/find.js +208 -0
- package/dist/core/tools/grep.js +246 -0
- package/dist/core/tools/index.js +67 -0
- package/dist/core/tools/ls.js +123 -0
- package/dist/core/tools/path-utils.js +81 -0
- package/dist/core/tools/read.js +160 -0
- package/dist/core/tools/truncate.js +70 -0
- package/dist/core/tools/write.js +82 -0
- package/dist/custom/agents/action.js +13 -0
- package/dist/custom/agents/document-reader.js +70 -0
- package/dist/custom/agents/general.js +26 -0
- package/dist/custom/agents/index.js +49 -0
- package/dist/custom/agents/installation.js +13 -0
- package/dist/custom/agents/types.js +7 -0
- package/dist/custom/auth/refresh-timer.js +33 -0
- package/dist/custom/auth/shortcut-oauth.js +145 -0
- package/dist/custom/constants.js +21 -0
- package/dist/custom/context/workbook-summary.js +73 -0
- package/dist/custom/credits/shortcut-credits.js +29 -0
- package/dist/custom/cron/cron-daemon-entry.js +18 -0
- package/dist/custom/cron/daemon-ipc.js +131 -0
- package/dist/custom/cron/daemon.js +224 -0
- package/dist/custom/cron/jobs.js +226 -0
- package/dist/custom/cron/run-log.js +51 -0
- package/dist/custom/cron/schedule.js +72 -0
- package/dist/custom/cron/status-line.js +98 -0
- package/dist/custom/cron/store.js +87 -0
- package/dist/custom/cron/types.js +8 -0
- package/dist/custom/dev/index.js +59 -0
- package/dist/custom/dev/trace-export.js +58 -0
- package/dist/custom/ensure-excel.js +63 -0
- package/dist/custom/excel-config.js +36 -0
- package/dist/custom/preflight.js +422 -0
- package/dist/custom/prompts/action.js +100 -0
- package/dist/custom/prompts/api.js +66 -0
- package/dist/custom/prompts/installation.js +124 -0
- package/dist/custom/prompts/shared.js +138 -0
- package/dist/custom/providers/llm-usage.js +42 -0
- package/dist/custom/providers/message-converter.js +74 -0
- package/dist/custom/providers/provider-ids.js +9 -0
- package/dist/custom/providers/register-openai-codex-provider.js +27 -0
- package/dist/custom/providers/register-shortcut-provider.js +52 -0
- package/dist/custom/providers/shortcut-invoke.js +117 -0
- package/dist/custom/providers/shortcut-stream.js +252 -0
- package/dist/custom/providers/sse-protocol.js +38 -0
- package/dist/custom/sync-xll.js +130 -0
- package/dist/custom/tools/cron.js +413 -0
- package/dist/custom/tools/excel-exec.js +167 -0
- package/dist/custom/tools/excel-range.js +50 -0
- package/dist/custom/tools/llm-analysis.js +265 -0
- package/dist/custom/tools/render-helpers.js +38 -0
- package/dist/custom/tools/switch-mode.js +94 -0
- package/dist/custom/tools/task/agents.js +6 -0
- package/dist/custom/tools/task/index.js +8 -0
- package/dist/custom/tools/task/render.js +348 -0
- package/dist/custom/tools/task/subprocess.js +320 -0
- package/dist/custom/tools/task/task.js +205 -0
- package/dist/custom/tools/todo-list.js +195 -0
- package/dist/custom/tracing/session-upload.js +93 -0
- package/dist/index.js +45 -0
- package/dist/main.js +613 -0
- package/dist/migrations.js +265 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/interactive/components/armin.js +337 -0
- package/dist/modes/interactive/components/assistant-message.js +94 -0
- package/dist/modes/interactive/components/bash-execution.js +171 -0
- package/dist/modes/interactive/components/bordered-loader.js +51 -0
- package/dist/modes/interactive/components/branch-summary-message.js +45 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
- package/dist/modes/interactive/components/config-selector.js +488 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/custom-editor.js +93 -0
- package/dist/modes/interactive/components/custom-message.js +81 -0
- package/dist/modes/interactive/components/daxnuts.js +140 -0
- package/dist/modes/interactive/components/diff.js +133 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/extension-editor.js +105 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-selector.js +78 -0
- package/dist/modes/interactive/components/footer.js +309 -0
- package/dist/modes/interactive/components/index.js +33 -0
- package/dist/modes/interactive/components/keybinding-hints.js +61 -0
- package/dist/modes/interactive/components/layout.js +64 -0
- package/dist/modes/interactive/components/login-dialog.js +148 -0
- package/dist/modes/interactive/components/model-selector.js +237 -0
- package/dist/modes/interactive/components/oauth-selector.js +111 -0
- package/dist/modes/interactive/components/session-selector-search.js +157 -0
- package/dist/modes/interactive/components/session-selector.js +860 -0
- package/dist/modes/interactive/components/settings-selector.js +123 -0
- package/dist/modes/interactive/components/show-images-selector.js +35 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
- package/dist/modes/interactive/components/theme-selector.js +47 -0
- package/dist/modes/interactive/components/thinking-selector.js +47 -0
- package/dist/modes/interactive/components/tool-execution.js +789 -0
- package/dist/modes/interactive/components/tool-group.js +106 -0
- package/dist/modes/interactive/components/tree-selector.js +962 -0
- package/dist/modes/interactive/components/user-message-selector.js +115 -0
- package/dist/modes/interactive/components/user-message.js +48 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/file-attachments.js +135 -0
- package/dist/modes/interactive/interactive-mode.js +3775 -0
- package/dist/modes/interactive/theme/dark.json +85 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.js +177 -0
- package/dist/modes/print-mode.js +101 -0
- package/dist/modes/rpc/rpc-client.js +387 -0
- package/dist/modes/rpc/rpc-mode.js +509 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/subagent-entry.js +145 -0
- package/dist/tool-names.js +34 -0
- package/dist/tui/autocomplete.js +596 -0
- package/dist/tui/components/box.js +104 -0
- package/dist/tui/components/cancellable-loader.js +35 -0
- package/dist/tui/components/editor.js +1679 -0
- package/dist/tui/components/image.js +69 -0
- package/dist/tui/components/input.js +433 -0
- package/dist/tui/components/loader.js +49 -0
- package/dist/tui/components/markdown.js +629 -0
- package/dist/tui/components/select-list.js +152 -0
- package/dist/tui/components/settings-list.js +185 -0
- package/dist/tui/components/spacer.js +23 -0
- package/dist/tui/components/text.js +89 -0
- package/dist/tui/components/truncated-text.js +51 -0
- package/dist/tui/editor-component.js +2 -0
- package/dist/tui/fuzzy.js +107 -0
- package/dist/tui/get-east-asian-width/index.js +32 -0
- package/dist/tui/get-east-asian-width/lookup.js +404 -0
- package/dist/tui/index.js +32 -0
- package/dist/tui/keybindings.js +114 -0
- package/dist/tui/keys.js +959 -0
- package/dist/tui/kill-ring.js +44 -0
- package/dist/tui/stdin-buffer.js +317 -0
- package/dist/tui/terminal-image.js +288 -0
- package/dist/tui/terminal.js +249 -0
- package/dist/tui/tui/autocomplete.js +596 -0
- package/dist/tui/tui/components/box.js +106 -0
- package/dist/tui/tui/components/cancellable-loader.js +35 -0
- package/dist/tui/tui/components/editor.js +1679 -0
- package/dist/tui/tui/components/image.js +69 -0
- package/dist/tui/tui/components/input.js +433 -0
- package/dist/tui/tui/components/loader.js +49 -0
- package/dist/tui/tui/components/markdown.js +629 -0
- package/dist/tui/tui/components/select-list.js +152 -0
- package/dist/tui/tui/components/settings-list.js +185 -0
- package/dist/tui/tui/components/spacer.js +23 -0
- package/dist/tui/tui/components/text.js +91 -0
- package/dist/tui/tui/components/truncated-text.js +51 -0
- package/dist/tui/tui/editor-component.js +2 -0
- package/dist/tui/tui/fuzzy.js +107 -0
- package/dist/tui/tui/get-east-asian-width/index.js +32 -0
- package/dist/tui/tui/get-east-asian-width/lookup.js +404 -0
- package/dist/tui/tui/index.js +32 -0
- package/dist/tui/tui/keybindings.js +114 -0
- package/dist/tui/tui/keys.js +959 -0
- package/dist/tui/tui/kill-ring.js +44 -0
- package/dist/tui/tui/stdin-buffer.js +317 -0
- package/dist/tui/tui/terminal-image.js +288 -0
- package/dist/tui/tui/terminal.js +249 -0
- package/dist/tui/tui/tui.js +955 -0
- package/dist/tui/tui/undo-stack.js +25 -0
- package/dist/tui/tui/utils.js +800 -0
- package/dist/tui/tui.js +955 -0
- package/dist/tui/undo-stack.js +25 -0
- package/dist/tui/utils.js +800 -0
- package/dist/utils/changelog.js +87 -0
- package/dist/utils/clipboard-image.js +164 -0
- package/dist/utils/clipboard-native.js +14 -0
- package/dist/utils/clipboard.js +67 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/git.js +166 -0
- package/dist/utils/image-convert.js +35 -0
- package/dist/utils/image-resize.js +183 -0
- package/dist/utils/mime.js +26 -0
- package/dist/utils/photon.js +121 -0
- package/dist/utils/shell.js +217 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/tools-manager.js +259 -0
- package/package.json +78 -0
- package/skills/excel-com-api/SKILL.md +74 -0
- package/skills/excel-com-api/excel-type-library.py +27767 -0
- package/skills/excel-com-api/office-type-library.py +10867 -0
- package/skills/integrations/SKILL.md +138 -0
- package/skills/integrations/alphasense.md +457 -0
- package/skills/integrations/bloomberg.md +803 -0
- package/skills/integrations/calcbench.md +315 -0
- package/skills/integrations/capiq.md +848 -0
- package/skills/integrations/dynamics-365-finance.md +354 -0
- package/skills/integrations/earnings_transcripts.md +387 -0
- package/skills/integrations/factset.md +758 -0
- package/skills/integrations/ice-fixed-income.md +344 -0
- package/skills/integrations/moodys-analytics.md +313 -0
- package/skills/integrations/morningstar.md +433 -0
- package/skills/integrations/nasdaq-data-link.md +249 -0
- package/skills/integrations/pitchbook.md +413 -0
- package/skills/integrations/preqin.md +422 -0
- package/skills/integrations/quickbooks.md +289 -0
- package/skills/integrations/quickfs.md +314 -0
- package/skills/integrations/refinitiv.md +473 -0
- package/skills/integrations/sage-intacct.md +401 -0
- package/skills/integrations/visible-alpha.md +320 -0
- package/skills/integrations/xero.md +393 -0
- package/skills/integrations/ycharts.md +306 -0
- package/skills/pdf-creation/SKILL.md +93 -0
- package/skills/pdf-extraction/SKILL.md +32 -0
- package/skills/powerpoint-creation/SKILL.md +110 -0
- package/skills/sec-edgar/SKILL.md +127 -0
- package/skills/sec-edgar/sec_to_pdf.py +109 -0
- package/xll/ShortcutXL.xll +0 -0
- package/xll/modules/debug_render.py +272 -0
- package/xll/modules/gameboy.py +241 -0
- package/xll/modules/pong.py +188 -0
- package/xll/modules/shortcut_xl/__init__.py +18 -0
- package/xll/modules/shortcut_xl/_categorize.py +200 -0
- package/xll/modules/shortcut_xl/_com.py +108 -0
- package/xll/modules/shortcut_xl/_format.py +252 -0
- package/xll/modules/shortcut_xl/_log.py +12 -0
- package/xll/modules/shortcut_xl/_managed.py +116 -0
- package/xll/modules/shortcut_xl/_registry.py +44 -0
- package/xll/modules/shortcut_xl/_threading.py +161 -0
- package/xll/modules/shortcut_xl/_tracking.py +283 -0
- package/xll/modules/stocks.py +100 -0
- package/xll/python3.dll +0 -0
- package/xll/python312.dll +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""
|
|
2
|
+
SEC EDGAR HTML to PDF converter.
|
|
3
|
+
Uses Playwright + Chrome to render filings with images.
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
python sec_to_pdf.py <filing_url> <output_path>
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
python sec_to_pdf.py "https://www.sec.gov/Archives/edgar/data/320193/000032019324000123/aapl-20240928.htm" "/workspace/aapl_10k.pdf"
|
|
10
|
+
|
|
11
|
+
Why Chrome?
|
|
12
|
+
SEC.gov blocks headless Chromium with 403 errors (bot detection).
|
|
13
|
+
Using channel='chrome' with Playwright uses real Google Chrome which bypasses this.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
|
|
20
|
+
from playwright.async_api import async_playwright
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async def convert_sec_filing_to_pdf(url: str, output_path: str) -> dict:
|
|
24
|
+
"""
|
|
25
|
+
Convert SEC EDGAR filing to PDF with images.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
url: Full URL to SEC filing HTML
|
|
29
|
+
output_path: Where to save the PDF
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
dict with status, pdf_size, and image_count
|
|
33
|
+
"""
|
|
34
|
+
async with async_playwright() as p:
|
|
35
|
+
# MUST use channel='chrome' - regular Chromium gets 403 blocked by SEC
|
|
36
|
+
browser = await p.chromium.launch(headless=True, channel="chrome")
|
|
37
|
+
context = await browser.new_context(
|
|
38
|
+
user_agent="ShortcutAgent/1.0 (support@shortcut.ai)"
|
|
39
|
+
)
|
|
40
|
+
page = await context.new_page()
|
|
41
|
+
|
|
42
|
+
# Navigate to filing (networkidle waits for no network activity for 500ms)
|
|
43
|
+
response = await page.goto(url, wait_until="networkidle", timeout=20000)
|
|
44
|
+
|
|
45
|
+
if response is None or response.status != 200:
|
|
46
|
+
await browser.close()
|
|
47
|
+
return {
|
|
48
|
+
"status": "error",
|
|
49
|
+
"code": response.status if response else 0,
|
|
50
|
+
"message": "SEC blocked request or navigation failed",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Count images for verification
|
|
54
|
+
images = await page.query_selector_all("img")
|
|
55
|
+
image_count = len(images)
|
|
56
|
+
|
|
57
|
+
# Generate PDF
|
|
58
|
+
pdf_bytes = await page.pdf(format="A4", print_background=True)
|
|
59
|
+
|
|
60
|
+
# Ensure output directory exists and save
|
|
61
|
+
output_dir = os.path.dirname(output_path)
|
|
62
|
+
if output_dir:
|
|
63
|
+
os.makedirs(output_dir, exist_ok=True)
|
|
64
|
+
with open(output_path, "wb") as f:
|
|
65
|
+
f.write(pdf_bytes)
|
|
66
|
+
|
|
67
|
+
await browser.close()
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
"status": "success",
|
|
71
|
+
"pdf_path": output_path,
|
|
72
|
+
"pdf_size_bytes": len(pdf_bytes),
|
|
73
|
+
"image_count": image_count,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
async def main():
|
|
78
|
+
if len(sys.argv) != 3:
|
|
79
|
+
print("Usage: python sec_to_pdf.py <filing_url> <output_path>")
|
|
80
|
+
print()
|
|
81
|
+
print("Example:")
|
|
82
|
+
print(
|
|
83
|
+
' python sec_to_pdf.py "https://www.sec.gov/Archives/edgar/data/320193/000032019324000123/aapl-20240928.htm" "/workspace/aapl_10k.pdf"'
|
|
84
|
+
)
|
|
85
|
+
sys.exit(1)
|
|
86
|
+
|
|
87
|
+
url = sys.argv[1]
|
|
88
|
+
output_path = sys.argv[2]
|
|
89
|
+
|
|
90
|
+
print("Converting SEC filing to PDF...")
|
|
91
|
+
print(f" URL: {url}")
|
|
92
|
+
print(f" Output: {output_path}")
|
|
93
|
+
print()
|
|
94
|
+
|
|
95
|
+
result = await convert_sec_filing_to_pdf(url, output_path)
|
|
96
|
+
|
|
97
|
+
if result["status"] == "success":
|
|
98
|
+
size_mb = result["pdf_size_bytes"] / (1024 * 1024)
|
|
99
|
+
print("Success!")
|
|
100
|
+
print(f" PDF saved to: {result['pdf_path']}")
|
|
101
|
+
print(f" PDF size: {result['pdf_size_bytes']:,} bytes ({size_mb:.2f} MB)")
|
|
102
|
+
print(f" Images rendered: {result['image_count']}")
|
|
103
|
+
else:
|
|
104
|
+
print(f"Error: {result['message']} (code: {result['code']})")
|
|
105
|
+
sys.exit(1)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
asyncio.run(main())
|
|
Binary file
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
"""
|
|
2
|
+
debug_render.py — Progressive rendering tests for isolating display issues.
|
|
3
|
+
|
|
4
|
+
Type these in Excel cells to test each layer of the rendering pipeline:
|
|
5
|
+
|
|
6
|
+
=debug_write_test() Layer 1: Can we write to a cell at all via COM?
|
|
7
|
+
=debug_batch_test() Layer 2: Does xl_batch() work?
|
|
8
|
+
=debug_grid_test() Layer 3: Can we write a 2D grid?
|
|
9
|
+
=debug_format_pong() Layer 4: Set column/row sizes for pong display
|
|
10
|
+
=debug_frame() Layer 5: Render one static pong frame
|
|
11
|
+
=debug_counter() Layer 6: Animated counter (1 cell, 1Hz)
|
|
12
|
+
=debug_stop() Stop any running animation
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import shortcut_xl
|
|
16
|
+
from shortcut_xl import xl_func, xl_log
|
|
17
|
+
|
|
18
|
+
_counter_running = False
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# === Layer 1: Basic COM write ===
|
|
22
|
+
|
|
23
|
+
@xl_func
|
|
24
|
+
def debug_write_test():
|
|
25
|
+
"""Write a value to Z1 via xl_app() COM. Simplest possible test."""
|
|
26
|
+
try:
|
|
27
|
+
def _do(app):
|
|
28
|
+
app.ActiveSheet.Range("Z1").Value = "WRITE_OK"
|
|
29
|
+
shortcut_xl.xl_batch(_do)
|
|
30
|
+
return "Wrote 'WRITE_OK' to Z1 — check Z1"
|
|
31
|
+
except Exception as e:
|
|
32
|
+
xl_log(f"debug_write_test FAILED: {e}")
|
|
33
|
+
return f"FAILED: {e}"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# === Layer 2: xl_batch with ScreenUpdating toggle ===
|
|
37
|
+
|
|
38
|
+
@xl_func
|
|
39
|
+
def debug_batch_test():
|
|
40
|
+
"""Write 3 cells in one batch. Tests ScreenUpdating toggle + PumpWaitingMessages."""
|
|
41
|
+
try:
|
|
42
|
+
def _do(app):
|
|
43
|
+
sheet = app.ActiveSheet
|
|
44
|
+
sheet.Range("Z1").Value = "BATCH"
|
|
45
|
+
sheet.Range("Z2").Value = "TEST"
|
|
46
|
+
sheet.Range("Z3").Value = "OK"
|
|
47
|
+
shortcut_xl.xl_batch(_do)
|
|
48
|
+
return "Wrote Z1:Z3 — check those cells"
|
|
49
|
+
except Exception as e:
|
|
50
|
+
xl_log(f"debug_batch_test FAILED: {e}")
|
|
51
|
+
return f"FAILED: {e}"
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# === Layer 3: 2D grid write via Resize().Value ===
|
|
55
|
+
|
|
56
|
+
@xl_func
|
|
57
|
+
def debug_grid_test():
|
|
58
|
+
"""Write a small 5x5 grid using the same Resize().Value pattern as pong."""
|
|
59
|
+
try:
|
|
60
|
+
grid = []
|
|
61
|
+
for r in range(5):
|
|
62
|
+
row = []
|
|
63
|
+
for c in range(5):
|
|
64
|
+
if r == 0 or r == 4 or c == 0 or c == 4:
|
|
65
|
+
row.append("#") # border
|
|
66
|
+
elif r == 2 and c == 2:
|
|
67
|
+
row.append("X") # center
|
|
68
|
+
else:
|
|
69
|
+
row.append("") # empty (same as pong does)
|
|
70
|
+
grid.append(row)
|
|
71
|
+
|
|
72
|
+
def _do(app):
|
|
73
|
+
sheet = app.ActiveSheet
|
|
74
|
+
top = sheet.Range("Z5").Cells(1, 1)
|
|
75
|
+
sheet.Range("Z5:AD9").Value = grid
|
|
76
|
+
|
|
77
|
+
shortcut_xl.xl_batch(_do)
|
|
78
|
+
xl_log(f"debug_grid_test: wrote 5x5 grid to Z5:AD9, data={grid}")
|
|
79
|
+
return "Wrote 5x5 grid to Z5:AD9 — check those cells"
|
|
80
|
+
except Exception as e:
|
|
81
|
+
xl_log(f"debug_grid_test FAILED: {e}")
|
|
82
|
+
return f"FAILED: {e}"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# === Layer 3b: Grid with tuples (test COM conversion) ===
|
|
86
|
+
|
|
87
|
+
@xl_func
|
|
88
|
+
def debug_grid_tuple_test():
|
|
89
|
+
"""Same as grid_test but converts to tuple-of-tuples for COM.
|
|
90
|
+
If this works but debug_grid_test doesn't, it's a list-vs-tuple issue."""
|
|
91
|
+
try:
|
|
92
|
+
grid = []
|
|
93
|
+
for r in range(5):
|
|
94
|
+
row = []
|
|
95
|
+
for c in range(5):
|
|
96
|
+
if r == 0 or r == 4 or c == 0 or c == 4:
|
|
97
|
+
row.append("#")
|
|
98
|
+
elif r == 2 and c == 2:
|
|
99
|
+
row.append("X")
|
|
100
|
+
else:
|
|
101
|
+
row.append("")
|
|
102
|
+
grid.append(tuple(row))
|
|
103
|
+
grid = tuple(grid)
|
|
104
|
+
|
|
105
|
+
def _do(app):
|
|
106
|
+
sheet = app.ActiveSheet
|
|
107
|
+
sheet.Range("Z5:AD9").Value = grid
|
|
108
|
+
|
|
109
|
+
shortcut_xl.xl_batch(_do)
|
|
110
|
+
xl_log(f"debug_grid_tuple_test: wrote tuple grid to Z5:AD9")
|
|
111
|
+
return "Wrote tuple-of-tuples 5x5 to Z5:AD9"
|
|
112
|
+
except Exception as e:
|
|
113
|
+
xl_log(f"debug_grid_tuple_test FAILED: {e}")
|
|
114
|
+
return f"FAILED: {e}"
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# === Layer 4: Format cells for pong display ===
|
|
118
|
+
|
|
119
|
+
@xl_func
|
|
120
|
+
def debug_format_pong():
|
|
121
|
+
"""Set up column widths and row heights so pong grid looks right.
|
|
122
|
+
This is what pong.py is missing — without it, the grid is spread across
|
|
123
|
+
the entire screen and looks like nothing."""
|
|
124
|
+
try:
|
|
125
|
+
def _do(app):
|
|
126
|
+
sheet = app.ActiveSheet
|
|
127
|
+
# Columns A-AD (1-30): narrow width for character grid
|
|
128
|
+
cols = sheet.Range("A:AD")
|
|
129
|
+
cols.ColumnWidth = 2.0
|
|
130
|
+
cols.HorizontalAlignment = -4108 # xlCenter
|
|
131
|
+
|
|
132
|
+
# Rows 3-22 (pong grid area): compact height
|
|
133
|
+
rows = sheet.Range("3:22")
|
|
134
|
+
rows.RowHeight = 15
|
|
135
|
+
|
|
136
|
+
# Monospace font for the grid
|
|
137
|
+
grid_range = sheet.Range("A3:AD22")
|
|
138
|
+
grid_range.Font.Name = "Consolas"
|
|
139
|
+
grid_range.Font.Size = 11
|
|
140
|
+
|
|
141
|
+
# Scoreboard formatting
|
|
142
|
+
sheet.Range("A1").Font.Name = "Consolas"
|
|
143
|
+
sheet.Range("A1").Font.Size = 14
|
|
144
|
+
sheet.Range("A1").Font.Bold = True
|
|
145
|
+
|
|
146
|
+
shortcut_xl.xl_batch(_do)
|
|
147
|
+
return "Formatted A:AD for pong display"
|
|
148
|
+
except Exception as e:
|
|
149
|
+
xl_log(f"debug_format_pong FAILED: {e}")
|
|
150
|
+
return f"FAILED: {e}"
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
# === Layer 5: Static pong frame ===
|
|
154
|
+
|
|
155
|
+
@xl_func
|
|
156
|
+
def debug_frame():
|
|
157
|
+
"""Render exactly one pong frame. No animation, no schedule_call.
|
|
158
|
+
If this shows up, the rendering works and the issue is in the animation loop."""
|
|
159
|
+
try:
|
|
160
|
+
WIDTH, HEIGHT, PADDLE_H = 30, 20, 4
|
|
161
|
+
grid = []
|
|
162
|
+
ball_x, ball_y = 15, 10
|
|
163
|
+
paddle_l, paddle_r = 8, 8
|
|
164
|
+
|
|
165
|
+
for r in range(HEIGHT):
|
|
166
|
+
row = []
|
|
167
|
+
for c in range(WIDTH):
|
|
168
|
+
ch = ""
|
|
169
|
+
if c == 0 and paddle_l <= r < paddle_l + PADDLE_H:
|
|
170
|
+
ch = chr(9608) # full block
|
|
171
|
+
elif c == WIDTH - 1 and paddle_r <= r < paddle_r + PADDLE_H:
|
|
172
|
+
ch = chr(9608)
|
|
173
|
+
elif r == ball_y and c == ball_x:
|
|
174
|
+
ch = chr(9679) # black circle
|
|
175
|
+
elif c == WIDTH // 2 and r % 2 == 0:
|
|
176
|
+
ch = chr(9474) # light vertical
|
|
177
|
+
row.append(ch)
|
|
178
|
+
grid.append(row)
|
|
179
|
+
|
|
180
|
+
def _do(app):
|
|
181
|
+
sheet = app.ActiveSheet
|
|
182
|
+
sheet.Range("A3:AD22").Value = grid
|
|
183
|
+
sheet.Range("A1").Value = "PONG 0 : 0"
|
|
184
|
+
sheet.Range("A2").Value = "Static frame test"
|
|
185
|
+
|
|
186
|
+
shortcut_xl.xl_batch(_do)
|
|
187
|
+
xl_log("debug_frame: wrote static pong frame")
|
|
188
|
+
return "Wrote static pong frame to A3:AD22"
|
|
189
|
+
except Exception as e:
|
|
190
|
+
xl_log(f"debug_frame FAILED: {e}")
|
|
191
|
+
return f"FAILED: {e}"
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# === Layer 5b: Static frame with ASCII (no Unicode) ===
|
|
195
|
+
|
|
196
|
+
@xl_func
|
|
197
|
+
def debug_frame_ascii():
|
|
198
|
+
"""Same as debug_frame but uses ASCII chars only.
|
|
199
|
+
If this renders but debug_frame doesn't, it's a Unicode/font issue."""
|
|
200
|
+
try:
|
|
201
|
+
WIDTH, HEIGHT, PADDLE_H = 30, 20, 4
|
|
202
|
+
grid = []
|
|
203
|
+
ball_x, ball_y = 15, 10
|
|
204
|
+
paddle_l, paddle_r = 8, 8
|
|
205
|
+
|
|
206
|
+
for r in range(HEIGHT):
|
|
207
|
+
row = []
|
|
208
|
+
for c in range(WIDTH):
|
|
209
|
+
ch = "." # visible empty (not "")
|
|
210
|
+
if c == 0 and paddle_l <= r < paddle_l + PADDLE_H:
|
|
211
|
+
ch = "|"
|
|
212
|
+
elif c == WIDTH - 1 and paddle_r <= r < paddle_r + PADDLE_H:
|
|
213
|
+
ch = "|"
|
|
214
|
+
elif r == ball_y and c == ball_x:
|
|
215
|
+
ch = "O"
|
|
216
|
+
elif c == WIDTH // 2 and r % 2 == 0:
|
|
217
|
+
ch = ":"
|
|
218
|
+
row.append(ch)
|
|
219
|
+
grid.append(row)
|
|
220
|
+
|
|
221
|
+
def _do(app):
|
|
222
|
+
sheet = app.ActiveSheet
|
|
223
|
+
sheet.Range("A3:AD22").Value = grid
|
|
224
|
+
sheet.Range("A1").Value = "PONG 0 : 0"
|
|
225
|
+
sheet.Range("A2").Value = "Static ASCII frame test"
|
|
226
|
+
|
|
227
|
+
shortcut_xl.xl_batch(_do)
|
|
228
|
+
xl_log("debug_frame_ascii: wrote ASCII pong frame")
|
|
229
|
+
return "Wrote ASCII pong frame to A3:AD22"
|
|
230
|
+
except Exception as e:
|
|
231
|
+
xl_log(f"debug_frame_ascii FAILED: {e}")
|
|
232
|
+
return f"FAILED: {e}"
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
# === Layer 6: Animated counter (simplest animation) ===
|
|
236
|
+
|
|
237
|
+
@xl_func
|
|
238
|
+
def debug_counter():
|
|
239
|
+
"""Increment a single cell once per second. Simplest animation test.
|
|
240
|
+
If this works, schedule_call + xl_batch animation pipeline is fine."""
|
|
241
|
+
global _counter_running
|
|
242
|
+
if _counter_running:
|
|
243
|
+
return "Already running! =debug_stop() first"
|
|
244
|
+
|
|
245
|
+
_counter_running = True
|
|
246
|
+
_count = [0]
|
|
247
|
+
|
|
248
|
+
def _tick():
|
|
249
|
+
if not _counter_running:
|
|
250
|
+
return
|
|
251
|
+
_count[0] += 1
|
|
252
|
+
xl_log(f"debug_counter tick: {_count[0]}")
|
|
253
|
+
try:
|
|
254
|
+
def _do(app):
|
|
255
|
+
app.ActiveSheet.Range("Z1").Value = f"Count: {_count[0]}"
|
|
256
|
+
shortcut_xl.xl_batch(_do)
|
|
257
|
+
except Exception as e:
|
|
258
|
+
xl_log(f"debug_counter error: {e}")
|
|
259
|
+
|
|
260
|
+
if _counter_running and _count[0] < 30:
|
|
261
|
+
shortcut_xl.schedule_call(_tick, 1.0)
|
|
262
|
+
|
|
263
|
+
shortcut_xl.schedule_call(_tick, 0.1)
|
|
264
|
+
return "Counting in Z1 (1/sec, 30 max)"
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
@xl_func
|
|
268
|
+
def debug_stop():
|
|
269
|
+
"""Stop the debug counter."""
|
|
270
|
+
global _counter_running
|
|
271
|
+
_counter_running = False
|
|
272
|
+
return "Stopped"
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Game Boy emulator in Excel — type =gb_start() to play Pokemon Red!
|
|
3
|
+
|
|
4
|
+
Runs a Game Boy ROM via PyBoy at full 160x144 resolution.
|
|
5
|
+
Colors are auto-detected from the game's actual palette.
|
|
6
|
+
|
|
7
|
+
Arrow keys + Z (A) + X (B) + Enter (Start) + Backspace (Select).
|
|
8
|
+
Type =gb_stop() to end.
|
|
9
|
+
"""
|
|
10
|
+
import shortcut_xl
|
|
11
|
+
from shortcut_xl import xl_func, xl_log
|
|
12
|
+
import ctypes
|
|
13
|
+
import os
|
|
14
|
+
import time
|
|
15
|
+
|
|
16
|
+
WIDTH = 160
|
|
17
|
+
HEIGHT = 144
|
|
18
|
+
TARGET_EMU_FPS = 60 # Game Boy runs at ~60 FPS
|
|
19
|
+
|
|
20
|
+
# Column letter helper
|
|
21
|
+
def _col_letter(n):
|
|
22
|
+
s = ""
|
|
23
|
+
while n > 0:
|
|
24
|
+
n, rem = divmod(n - 1, 26)
|
|
25
|
+
s = chr(65 + rem) + s
|
|
26
|
+
return s
|
|
27
|
+
|
|
28
|
+
_GRID_RANGE = f"A3:{_col_letter(WIDTH)}{2 + HEIGHT}"
|
|
29
|
+
|
|
30
|
+
# Key mappings: Windows VK code -> PyBoy button name
|
|
31
|
+
_KEY_MAP = {
|
|
32
|
+
0x25: 'left',
|
|
33
|
+
0x26: 'up',
|
|
34
|
+
0x27: 'right',
|
|
35
|
+
0x28: 'down',
|
|
36
|
+
0x5A: 'a', # Z
|
|
37
|
+
0x58: 'b', # X
|
|
38
|
+
0x0D: 'start', # Enter
|
|
39
|
+
0x08: 'select', # Backspace
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_state = {
|
|
43
|
+
'pyboy': None,
|
|
44
|
+
'running': False,
|
|
45
|
+
'_formatted': False,
|
|
46
|
+
'_keys_held': set(),
|
|
47
|
+
'_palette_bgr': None,
|
|
48
|
+
'_last_tick': 0.0,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Excel OnKey strings to suppress during gameplay
|
|
52
|
+
_ONKEY_SUPPRESS = [
|
|
53
|
+
"z", "Z", "x", "X",
|
|
54
|
+
"{LEFT}", "{RIGHT}", "{UP}", "{DOWN}",
|
|
55
|
+
"~", "{BS}",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _suppress_keys(app):
|
|
60
|
+
for k in _ONKEY_SUPPRESS:
|
|
61
|
+
app.OnKey(k, "")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _restore_keys(app):
|
|
65
|
+
for k in _ONKEY_SUPPRESS:
|
|
66
|
+
app.OnKey(k)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _poll_keys():
|
|
70
|
+
pb = _state['pyboy']
|
|
71
|
+
if not pb:
|
|
72
|
+
return
|
|
73
|
+
currently_held = set()
|
|
74
|
+
for vk in _KEY_MAP:
|
|
75
|
+
if ctypes.windll.user32.GetAsyncKeyState(vk) & 0x8000:
|
|
76
|
+
currently_held.add(vk)
|
|
77
|
+
prev = _state['_keys_held']
|
|
78
|
+
for vk in currently_held - prev:
|
|
79
|
+
pb.button_press(_KEY_MAP[vk])
|
|
80
|
+
for vk in prev - currently_held:
|
|
81
|
+
pb.button_release(_KEY_MAP[vk])
|
|
82
|
+
_state['_keys_held'] = currently_held
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _detect_palette():
|
|
86
|
+
"""Scan screen for unique colors, build sorted palette."""
|
|
87
|
+
import numpy as np
|
|
88
|
+
screen = _state['pyboy'].screen.ndarray[:, :, :3]
|
|
89
|
+
unique = np.unique(screen.reshape(-1, 3), axis=0)
|
|
90
|
+
brightness = np.sum(unique, axis=1)
|
|
91
|
+
order = np.argsort(brightness)
|
|
92
|
+
palette = [tuple(unique[i]) for i in order]
|
|
93
|
+
_state['_palette_bgr'] = [
|
|
94
|
+
int(b) * 65536 + int(g) * 256 + int(r) for r, g, b in palette
|
|
95
|
+
]
|
|
96
|
+
# Build threshold list from midpoints between palette brightness levels
|
|
97
|
+
b_sorted = sorted(brightness)
|
|
98
|
+
thresholds = []
|
|
99
|
+
for i in range(len(b_sorted) - 1):
|
|
100
|
+
thresholds.append((b_sorted[i] + b_sorted[i + 1]) / 2.0 / 3.0) # per-channel avg
|
|
101
|
+
_state['_thresholds'] = thresholds
|
|
102
|
+
xl_log(f"gb palette: {len(palette)} colors, thresholds={thresholds}")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _grab_frame():
|
|
106
|
+
"""Fast frame grab: threshold-based, returns list-of-lists (no tuple conversion)."""
|
|
107
|
+
import numpy as np
|
|
108
|
+
screen = _state['pyboy'].screen.ndarray[:, :, 0] # R channel (GB is grayscale R=G=B)
|
|
109
|
+
thresholds = _state.get('_thresholds', [64, 128, 192])
|
|
110
|
+
|
|
111
|
+
indices = np.zeros(screen.shape, dtype=np.uint8)
|
|
112
|
+
for i, t in enumerate(thresholds):
|
|
113
|
+
indices[screen >= t] = i + 1
|
|
114
|
+
|
|
115
|
+
return indices.tolist() # list-of-lists — fast C-level conversion
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _render(grid):
|
|
119
|
+
def _paint(app):
|
|
120
|
+
app.Calculation = -4135 # xlCalculationManual
|
|
121
|
+
sheet = app.ActiveSheet
|
|
122
|
+
|
|
123
|
+
if not _state['_formatted']:
|
|
124
|
+
_state['_formatted'] = True
|
|
125
|
+
area = sheet.Range(_GRID_RANGE)
|
|
126
|
+
area.ColumnWidth = 0.75
|
|
127
|
+
area.RowHeight = 5
|
|
128
|
+
area.NumberFormat = ";;;"
|
|
129
|
+
|
|
130
|
+
# Conditional formatting from detected palette
|
|
131
|
+
area.FormatConditions.Delete()
|
|
132
|
+
for val, bgr in enumerate(_state['_palette_bgr']):
|
|
133
|
+
fc = area.FormatConditions.Add(1, 3, str(val))
|
|
134
|
+
fc.Interior.Color = bgr
|
|
135
|
+
fc.Font.Color = bgr
|
|
136
|
+
fc.StopIfTrue = False
|
|
137
|
+
|
|
138
|
+
_suppress_keys(app)
|
|
139
|
+
|
|
140
|
+
sheet.Range(_GRID_RANGE).Value = grid
|
|
141
|
+
sheet.Range("A1").Value = "GAME BOY"
|
|
142
|
+
sheet.Range("A2").Value = (
|
|
143
|
+
chr(8592) + chr(8593) + chr(8594) + chr(8595)
|
|
144
|
+
+ " Z=A X=B Enter=Start Back=Select gb_stop() to end"
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
shortcut_xl.xl_batch(_paint)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def _tick():
|
|
151
|
+
if not _state['running']:
|
|
152
|
+
return
|
|
153
|
+
try:
|
|
154
|
+
pb = _state['pyboy']
|
|
155
|
+
now = time.perf_counter()
|
|
156
|
+
elapsed = now - _state['_last_tick']
|
|
157
|
+
_state['_last_tick'] = now
|
|
158
|
+
|
|
159
|
+
# Advance emulator to keep game at real speed
|
|
160
|
+
# Even if rendering is slow, the game plays at correct pace
|
|
161
|
+
frames_to_run = max(1, min(int(elapsed * TARGET_EMU_FPS), 10))
|
|
162
|
+
_poll_keys()
|
|
163
|
+
for _ in range(frames_to_run - 1):
|
|
164
|
+
pb.tick(1, False) # advance without rendering
|
|
165
|
+
pb.tick(1, True) # render last frame only
|
|
166
|
+
|
|
167
|
+
# Re-detect palette every ~2 seconds of game time
|
|
168
|
+
if pb.frame_count % 120 == 0:
|
|
169
|
+
_detect_palette()
|
|
170
|
+
_state['_formatted'] = False
|
|
171
|
+
|
|
172
|
+
grid = _grab_frame()
|
|
173
|
+
_render(grid)
|
|
174
|
+
except Exception as e:
|
|
175
|
+
xl_log(f"gameboy tick error: {e}")
|
|
176
|
+
import traceback
|
|
177
|
+
xl_log(traceback.format_exc())
|
|
178
|
+
_state['running'] = False
|
|
179
|
+
shortcut_xl.schedule_call(_restore_calc, 0.3)
|
|
180
|
+
return
|
|
181
|
+
# Schedule next tick immediately — render as fast as COM allows
|
|
182
|
+
shortcut_xl.schedule_call(_tick, 0.001)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def _restore_calc():
|
|
186
|
+
def _do(app):
|
|
187
|
+
_restore_keys(app)
|
|
188
|
+
app.Calculation = -4105 # xlCalculationAutomatic
|
|
189
|
+
shortcut_xl.xl_batch(_do)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
@xl_func
|
|
193
|
+
def gb_start(rom_path=""):
|
|
194
|
+
if _state['running']:
|
|
195
|
+
return "Already running! gb_stop() first"
|
|
196
|
+
|
|
197
|
+
if not rom_path or rom_path is None:
|
|
198
|
+
rom_path = "pokemon_red"
|
|
199
|
+
|
|
200
|
+
if not os.path.isfile(rom_path):
|
|
201
|
+
modules_dir = os.path.dirname(os.path.abspath(__file__))
|
|
202
|
+
roms_dir = os.path.join(os.path.dirname(modules_dir), "roms")
|
|
203
|
+
candidate = os.path.join(roms_dir, rom_path if rom_path.endswith(".gb") else rom_path + ".gb")
|
|
204
|
+
if os.path.isfile(candidate):
|
|
205
|
+
rom_path = candidate
|
|
206
|
+
|
|
207
|
+
if not os.path.isfile(rom_path):
|
|
208
|
+
return f"ROM not found: {rom_path}"
|
|
209
|
+
|
|
210
|
+
try:
|
|
211
|
+
from pyboy import PyBoy
|
|
212
|
+
pb = PyBoy(rom_path, window='null')
|
|
213
|
+
for _ in range(200):
|
|
214
|
+
pb.tick(1, True)
|
|
215
|
+
_state['pyboy'] = pb
|
|
216
|
+
except Exception as e:
|
|
217
|
+
xl_log(f"gb_start error: {e}")
|
|
218
|
+
return f"Failed: {e}"
|
|
219
|
+
|
|
220
|
+
_detect_palette()
|
|
221
|
+
|
|
222
|
+
_state['running'] = True
|
|
223
|
+
_state['_formatted'] = False
|
|
224
|
+
_state['_keys_held'] = set()
|
|
225
|
+
_state['_last_tick'] = time.perf_counter()
|
|
226
|
+
shortcut_xl.schedule_call(_tick, 0.1)
|
|
227
|
+
return "GAME BOY!"
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
@xl_func
|
|
231
|
+
def gb_stop():
|
|
232
|
+
_state['running'] = False
|
|
233
|
+
pb = _state.get('pyboy')
|
|
234
|
+
if pb:
|
|
235
|
+
try:
|
|
236
|
+
pb.stop(False)
|
|
237
|
+
except Exception:
|
|
238
|
+
pass
|
|
239
|
+
_state['pyboy'] = None
|
|
240
|
+
shortcut_xl.schedule_call(_restore_calc, 0.3)
|
|
241
|
+
return "Stopped"
|