pi-coding-master 0.2.7
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 +50 -0
- package/core/god.agent.capability/@ABANDONED.brain.prefrontal.monitor/gpu_monitor.py +80 -0
- package/core/god.agent.capability/@ABANDONED.brain.prefrontal.monitor/gpu_monitor.py.CHANGELOG +1 -0
- package/core/god.agent.capability/@ABANDONED.brain.prefrontal.monitor/gpu_monitor.py.SPEC +3 -0
- package/core/god.agent.capability/hands.dev.writeissue/issue.ts +209 -0
- package/core/god.agent.capability/hands.dev.writeissue/issue.ts.SPEC +26 -0
- package/core/god.agent.capability/hands.files.changewatcher/watcher.ts +44 -0
- package/core/god.agent.capability/hands.files.changewatcher/watcher.ts.SPEC +25 -0
- package/core/god.pi.mod/cli/pi-completion.zsh +21 -0
- package/core/god.pi.mod/cli/pi-completion.zsh.CHANGELOG +1 -0
- package/core/god.pi.mod/cli/pi-people.sh +264 -0
- package/core/god.pi.mod/cli/pi-people.sh.LESSON +10 -0
- package/core/god.pi.mod/cli/pi-people.sh.SPEC +31 -0
- package/core/god.pi.mod/paths.ts +47 -0
- package/core/god.pi.mod/tui.mods.blockrender/blockrender.js +90 -0
- package/core/god.pi.mod/tui.mods.blockrender/blockrender.js.SPEC +29 -0
- package/core/god.pi.mod/tui.mods.footer.budget/budget_guard.ts +154 -0
- package/core/god.pi.mod/tui.mods.footer.budget/budget_guard.ts.CHANGELOG +10 -0
- package/core/god.pi.mod/tui.mods.footer.budget/budget_guard.ts.LESSON +12 -0
- package/core/god.pi.mod/tui.mods.footer.budget/budget_guard.ts.SPEC +26 -0
- package/core/god.pi.mod/tui.mods.footer.budget/footer-cny.CHANGELOG +39 -0
- package/core/god.pi.mod/tui.mods.viewmode/view_mode-thinking.patch +55 -0
- package/core/god.pi.mod/tui.mods.viewmode/view_mode-tools.patch +19 -0
- package/core/god.pi.mod/tui.mods.viewmode/view_mode-tools.patch.CHANGELOG +1 -0
- package/core/god.pi.mod/tui.mods.viewmode/view_mode.ts +50 -0
- package/core/god.pi.mod/tui.mods.viewmode/view_mode.ts.SPEC +12 -0
- package/core/god.pi.mod/tui.variants.userterminal/user_terminal.CHANGELOG +10 -0
- package/core/god.pi.mod/tui.variants.userterminal/user_terminal.ts +66 -0
- package/core/god.pi.mod/tui.variants.userterminal/user_terminal.ts.SPEC +31 -0
- package/core/index.ts +3 -0
- package/core/individual.bio.gene/dna.coded/coded.dna +257 -0
- package/core/individual.bio.gene/dna.coded/coded.dna.CHANGELOG +12 -0
- package/core/individual.bio.gene/dna.coded/coded.dna.SPEC +11 -0
- package/core/individual.bio.gene/dna.coded/core.dna +110 -0
- package/core/individual.bio.gene/dna.promotor/promotor.dna +117 -0
- package/core/individual.bio.gene/dna.promotor/promotor.dna.CHANGELOG +4 -0
- package/core/individual.bio.gene/dna.promotor/promotor.dna.SPEC +7 -0
- package/core/individual.bio.gene/dna.transpiler/transpiler.ts +395 -0
- package/core/individual.bio.gene/dna.transpiler/transpiler.ts.CHANGELOG +7 -0
- package/core/individual.bio.gene/dna.transpiler/transpiler.ts.SPEC +28 -0
- package/core/individual.bio.gene/gene.README +19 -0
- package/core/individual.bio.gene/rna/rna.json +536 -0
- package/core/individual.bio.gene/rna/rna.json.CHANGELOG +2 -0
- package/core/individual.bio.gene/rna/rna.json.SPEC +8 -0
- package/core/individual.bio.organs/blood.runtime/messages.ts +236 -0
- package/core/individual.bio.organs/blood.runtime/runtime.ts +173 -0
- package/core/individual.bio.organs/blood.runtime/runtime.ts.CHANGELOG +5 -0
- package/core/individual.bio.organs/blood.runtime/runtime.ts.SPEC +32 -0
- package/core/individual.bio.organs/brain.amygdala/amygdala.ts +25 -0
- package/core/individual.bio.organs/brain.amygdala/amygdala.ts.COMMENT +3 -0
- package/core/individual.bio.organs/brain.amygdala/amygdala.ts.SPEC +9 -0
- package/core/individual.bio.organs/brain.hippocampus/hippocampus-launcher.sh.template +108 -0
- package/core/individual.bio.organs/brain.hippocampus/hippocampus.ts +166 -0
- package/core/individual.bio.organs/brain.hippocampus/hippocampus.ts.CHANGELOG +12 -0
- package/core/individual.bio.organs/brain.hippocampus/hippocampus.ts.LESSON +22 -0
- package/core/individual.bio.organs/brain.hippocampus/hippocampus.ts.SPEC +16 -0
- package/core/individual.bio.organs/brain.hippocampus/memory.ts +879 -0
- package/core/individual.bio.organs/brain.hippocampus/memory.ts.CHANGELOG +66 -0
- package/core/individual.bio.organs/brain.hippocampus/memory.ts.LESSON +25 -0
- package/core/individual.bio.organs/brain.hippocampus/memory.ts.SPEC +46 -0
- package/core/individual.bio.organs/brain.hippocampus/sleep.ts +139 -0
- package/core/individual.bio.organs/brain.hippocampus/sleep.ts.CHANGELOG +11 -0
- package/core/individual.bio.organs/brain.hippocampus/sleep.ts.SPEC +16 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/drafting.SPEC +44 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/drafting.ts +73 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/drafting.ts.CHANGELOG +3 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/drafting.ts.SPEC +24 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/index.ts.CHANGELOG +3 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/main.ts +13 -0
- package/core/individual.bio.organs/brain.prefrontal.drafting/main.ts.SPEC +17 -0
- package/core/individual.bio.organs/brain.senses.bioclock/bioclock.ts +94 -0
- package/core/individual.bio.organs/brain.senses.bioclock/bioclock.ts.LESSON +13 -0
- package/core/individual.bio.organs/brain.senses.bioclock/bioclock.ts.SPEC +20 -0
- package/core/individual.bio.organs/brain.senses.subconscious/feed-format.SPEC +56 -0
- package/core/individual.bio.organs/brain.senses.subconscious/index.ts.CHANGELOG +13 -0
- package/core/individual.bio.organs/brain.senses.subconscious/spawner.ts +130 -0
- package/core/individual.bio.organs/brain.senses.subconscious/spawner.ts.SPEC +13 -0
- package/core/individual.bio.organs/brain.senses.subconscious/subconscious.ts +280 -0
- package/core/individual.bio.organs/brain.senses.subconscious/subconscious.ts.CHANGELOG +7 -0
- package/core/individual.bio.organs/brain.senses.subconscious/tools.ts +180 -0
- package/core/individual.bio.organs/brain.senses.subconscious/tools.ts.SPEC +3 -0
- package/core/individual.bio.organs/ears.listen/config.json +9 -0
- package/core/individual.bio.organs/ears.listen/config.json.CHANGELOG +1 -0
- package/core/individual.bio.organs/ears.listen/config.json.SPEC +3 -0
- package/core/individual.bio.organs/ears.listen/ears.ts.CHANGELOG +48 -0
- package/core/individual.bio.organs/ears.listen/ears_recorder.py.CHANGELOG +6 -0
- package/core/individual.bio.organs/ears.listen/index.ts +1 -0
- package/core/individual.bio.organs/ears.listen/index.ts.SPEC +16 -0
- package/core/individual.bio.organs/ears.listen/listen.ts +208 -0
- package/core/individual.bio.organs/ears.listen/listen.ts.SPEC +3 -0
- package/core/individual.bio.organs/ears.listen/listen_recorder.py +445 -0
- package/core/individual.bio.organs/ears.listen/listen_recorder.py.SPEC +7 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/__init__.py +0 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/common/__init__.py +0 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/common/events_pb2.py +38 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/common/events_pb2_grpc.py +24 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/common/rpcmeta_pb2.py +42 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/common/rpcmeta_pb2_grpc.py +24 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/__init__.py +0 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/__init__.py +0 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/ast/__init__.py +0 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/ast/ast_service_pb2.py +45 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/ast/ast_service_pb2_grpc.py +97 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/base/__init__.py +0 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/base/au_base_pb2.py +80 -0
- package/core/individual.bio.organs/ears.listen/python_protogen/products/understanding/base/au_base_pb2_grpc.py +24 -0
- package/core/individual.bio.organs/hands.fileactions/authorize.TRUST +1 -0
- package/core/individual.bio.organs/hands.fileactions/authorize.ts +70 -0
- package/core/individual.bio.organs/hands.fileactions/authorize.ts.CHANGELOG +1 -0
- package/core/individual.bio.organs/hands.fileactions/authorize.ts.SPEC +3 -0
- package/core/individual.bio.organs/hands.fileactions/dir.README +13 -0
- package/core/individual.bio.organs/hands.fileactions/file_rules.json +23 -0
- package/core/individual.bio.organs/hands.fileactions/fileactions.README +12 -0
- package/core/individual.bio.organs/hands.fileactions/fileactions.ts +540 -0
- package/core/individual.bio.organs/hands.fileactions/fileactions.ts.CHANGELOG +25 -0
- package/core/individual.bio.organs/hands.fileactions/fileactions.ts.SPEC +30 -0
- package/core/individual.bio.organs/hands.fileactions/filewatch.ts +66 -0
- package/core/individual.bio.organs/hands.fileactions/filewatch.ts.SPEC +3 -0
- package/core/individual.bio.organs/hands.main/main.ts +18 -0
- package/core/individual.bio.organs/hands.main/main.ts.SPEC +20 -0
- package/core/individual.bio.organs/hands.sensitive/sensitive.ts +24 -0
- package/core/individual.bio.organs/hands.sensitive/sensitive.ts.CHANGELOG +2 -0
- package/core/individual.bio.organs/hands.sensitive/sensitive.ts.SPEC +3 -0
- package/core/individual.bio.organs/heart.interrupt/agent_start-loader-flicker.patch +13 -0
- package/core/individual.bio.organs/heart.interrupt/interactive-mode-loader.patch +11 -0
- package/core/individual.bio.organs/heart.interrupt/runner_esc.patch +10 -0
- package/core/individual.bio.organs/heart.interrupt/runner_esc.patch.SPEC +9 -0
- package/core/individual.bio.organs/heart.kernel/kernel.ts +253 -0
- package/core/individual.bio.organs/heart.kernel/kernel.ts.CHANGELOG +13 -0
- package/core/individual.bio.organs/heart.kernel/kernel.ts.SPEC +23 -0
- package/core/individual.bio.organs/heart.main/heart.main.CHANGELOG +43 -0
- package/core/individual.bio.organs/heart.main/heartbeat.ts +494 -0
- package/core/individual.bio.organs/heart.main/heartbeat.ts.LESSON +43 -0
- package/core/individual.bio.organs/heart.main/main.ts +8 -0
- package/core/individual.bio.organs/heart.main/main.ts.SPEC +19 -0
- package/core/individual.bio.organs/heart.main/process.ts +122 -0
- package/core/individual.bio.organs/heart.main/process.ts.CHANGELOG +2 -0
- package/core/individual.bio.organs/heart.main/process.ts.SPEC +24 -0
- package/core/individual.bio.organs/heart.main/remove_timeout.patch +110 -0
- package/core/individual.bio.organs/heart.main/stop.ts.CHANGELOG +3 -0
- package/core/individual.bio.organs/heart.main/stop.ts.SPEC +28 -0
- package/core/individual.bio.organs/mouth.speak/index.ts +1 -0
- package/core/individual.bio.organs/mouth.speak/index.ts.CHANGELOG +1 -0
- package/core/individual.bio.organs/mouth.speak/index.ts.SPEC +6 -0
- package/core/individual.bio.organs/mouth.speak/mouth.ts.CHANGELOG +15 -0
- package/core/individual.bio.organs/mouth.speak/mouth_recorder.py.CHANGELOG +1 -0
- package/core/individual.bio.organs/mouth.speak/speak.ts +180 -0
- package/core/individual.bio.organs/mouth.speak/speak.ts.SPEC +3 -0
- package/core/individual.bio.organs/mouth.speak/speak_recorder.py +35 -0
- package/core/individual.bio.organs/mouth.speak/speak_recorder.py.SPEC +3 -0
- package/core/individual.bio.organs/organs.README +110 -0
- package/core/package-lock.json +18 -0
- package/core/package.json +35 -0
- package/core/prompts/prompts.json +77 -0
- package/core/prompts/prompts.ts +44 -0
- package/core/prompts/prompts.ts.SPEC +9 -0
- package/core/society.world/.gitkeep +0 -0
- package/core/society.world/accessibility.claudecode/message-service.cjs +217 -0
- package/core/society.world/accessibility.claudecode/message-service.cjs.SPEC +7 -0
- package/core/society.world/accessibility.claudecode/send.ts +34 -0
- package/core/society.world/dollar.distribution.ubi/ubi.ts +55 -0
- package/core/society.world/dollar.main/dollar-service.cjs +185 -0
- package/core/society.world/dollar.main/main.ts +116 -0
- package/core/society.world/dollar.transaction/transaction.ts +71 -0
- package/core/society.world/space/space.ts +206 -0
- package/core/society.world/space/space.ts.SPEC +30 -0
- package/core/technology.laptop/#agent.macos.BLUEPRINT +278 -0
- package/core/technology.phone/apps.preinstalled/albums.FUTURE/albums.ts +69 -0
- package/core/technology.phone/apps.preinstalled/albums.FUTURE/albums.ts.SPEC +15 -0
- package/core/technology.phone/apps.preinstalled/calendar/calendar.ts +406 -0
- package/core/technology.phone/apps.preinstalled/calendar/calendar.ts.SPEC +22 -0
- package/core/technology.phone/apps.preinstalled/calendar/holiday-calendar.ts +529 -0
- package/core/technology.phone/apps.preinstalled/clock/clock.ts +132 -0
- package/core/technology.phone/apps.preinstalled/clock/clock.ts.SPEC +11 -0
- package/core/technology.phone/apps.preinstalled/contacts.FUTURE/contacts.ts +300 -0
- package/core/technology.phone/apps.preinstalled/contacts.FUTURE/contacts.ts.SPEC +22 -0
- package/core/technology.phone/apps.preinstalled/developer.FUTURE/developer.ts +22 -0
- package/core/technology.phone/apps.preinstalled/developer.FUTURE/developer.ts.SPEC +15 -0
- package/core/technology.phone/apps.preinstalled/notes/notes.ts +239 -0
- package/core/technology.phone/apps.preinstalled/notes/notes.ts.SPEC +21 -0
- package/core/technology.phone/apps.preinstalled/polymarket/polymarket.ts +261 -0
- package/core/technology.phone/apps.preinstalled/polymarket/polymarket.ts.SPEC +7 -0
- package/core/technology.phone/apps.preinstalled/reminder/reminder.ts +404 -0
- package/core/technology.phone/apps.preinstalled/reminder/reminder.ts.SPEC +25 -0
- package/core/technology.phone/apps.preinstalled/siri.FUTURE/siri.ts +22 -0
- package/core/technology.phone/apps.preinstalled/siri.FUTURE/siri.ts.SPEC +15 -0
- package/core/technology.phone/apps.preinstalled/spotlight/spotlight.ts +29 -0
- package/core/technology.phone/apps.preinstalled/spotlight/spotlight.ts.SPEC +7 -0
- package/core/technology.phone/apps.preinstalled/steam/chess.ts +230 -0
- package/core/technology.phone/apps.preinstalled/steam/snake.ts +100 -0
- package/core/technology.phone/apps.preinstalled/steam/snake.ts.SPEC +7 -0
- package/core/technology.phone/apps.preinstalled/steam/spy-cmd.ts +4 -0
- package/core/technology.phone/apps.preinstalled/steam/spy-tool.ts +56 -0
- package/core/technology.phone/apps.preinstalled/steam/spy.ts +302 -0
- package/core/technology.phone/apps.preinstalled/steam/steam.ts +299 -0
- package/core/technology.phone/apps.preinstalled/weather/weather.ts +50 -0
- package/core/technology.phone/apps.preinstalled/weather/weather.ts.SPEC +9 -0
- package/core/technology.phone/apps.preinstalled/wechat/imessage.ts +423 -0
- package/core/technology.phone/apps.preinstalled/wechat/imessage.ts.SPEC +24 -0
- package/core/technology.phone/apps.system/appstore/appstore.ts +22 -0
- package/core/technology.phone/apps.system/appstore/appstore.ts.SPEC +15 -0
- package/core/technology.phone/apps.system/finder.FUTURE/finder.ts +64 -0
- package/core/technology.phone/apps.system/finder.FUTURE/finder.ts.SPEC +8 -0
- package/core/technology.phone/apps.system/safari/safari-app.ts +146 -0
- package/core/technology.phone/apps.system/safari/safari.ts.SPEC +24 -0
- package/core/technology.phone/apps.system/settings/settings.ts +126 -0
- package/core/technology.phone/apps.system/settings/settings.ts.SPEC +17 -0
- package/core/technology.phone/apps.system/tips/tips.ts +22 -0
- package/core/technology.phone/apps.system/tips/tips.ts.SPEC +15 -0
- package/core/technology.phone/apps.thirdparty/alipay/alipay.ts +148 -0
- package/core/technology.phone/apps.thirdparty/alipay/alipay.ts.SPEC +7 -0
- package/core/technology.phone/apps.thirdparty/bilibili/bilibili-app.ts +33 -0
- package/core/technology.phone/apps.thirdparty/bilibili/bilibili.ts +142 -0
- package/core/technology.phone/apps.thirdparty/bilibili/bilibili.ts.SPEC +22 -0
- package/core/technology.phone/apps.thirdparty/wechatread/wechatread.ts +80 -0
- package/core/technology.phone/apps.thirdparty/wechatread/wechatread.ts.SPEC +15 -0
- package/core/technology.phone/index.ts +1 -0
- package/core/technology.phone/package.json +2 -0
- package/core/technology.phone/system.homepage/homepage.ts +247 -0
- package/core/technology.phone/system.homepage/homepage.ts.SPEC +22 -0
- package/core/technology.phone/system.kernel/kernel.ts +264 -0
- package/core/technology.phone/system.kernel/kernel.ts.SPEC +7 -0
- package/core/technology.phone/system.notifications/notifications.ts +87 -0
- package/core/technology.phone/system.notifications/notifications.ts.SPEC +7 -0
- package/core/technology.phone/system.share/share.ts +46 -0
- package/core/technology.phone/system.share/share.ts.SPEC +7 -0
- package/core/technology.server/browser-service.cjs +152 -0
- package/core/technology.server/data/cookies/arxiv.json +30 -0
- package/core/technology.server/data/cookies/bili.json +184 -0
- package/core/technology.server/data/cookies/default.json +30 -0
- package/core/technology.server/data/cookies/news.json +113 -0
- package/core/technology.server/data/cookies/s1.json +45 -0
- package/core/technology.server/data/cookies/safari.json +184 -0
- package/core/technology.server/data/cookies/safari2.json +1 -0
- package/core/technology.server/data/cookies/safaridbg.json +1 -0
- package/core/technology.server/data/cookies/search.json +45 -0
- package/core/technology.server/data/cookies/sw.json +30 -0
- package/core/technology.server/data/cookies/t1.json +1 -0
- package/core/technology.server/data/cookies/testread.json +1 -0
- package/core/technology.server/data/cookies/video1.json +113 -0
- package/core/technology.server/data/cookies/yt.json +170 -0
- package/core/technology.server/data/cookies/yt2.json +113 -0
- package/core/technology.server/pikipedia/#pikipedia.BLUEPRINT +106 -0
- package/core/technology.server/playleft.cjs +247 -0
- package/core/technology.server/search-proxy.py +76 -0
- package/core/technology.server/server.README +59 -0
- package/deploy/dist-overrides/cli/cli.js +18 -0
- package/deploy/dist-overrides/core/extensions/loader.js +518 -0
- package/deploy/dist-overrides/core/package-manager.js +2081 -0
- package/deploy/dist-overrides/core/system-prompt.js +109 -0
- package/deploy/dist-overrides/core/system-prompt.js.LESSON +17 -0
- package/deploy/dist-overrides/core/tools/bash.js +353 -0
- package/deploy/dist-overrides/core/tools/bash.js.CHANGELOG +2 -0
- package/deploy/dist-overrides/core/tools/edit-diff.js +345 -0
- package/deploy/dist-overrides/core/tools/edit.js +315 -0
- package/deploy/dist-overrides/core/tools/edit.js.CHANGELOG +1 -0
- package/deploy/dist-overrides/core/tools/file-mutation-queue.js +52 -0
- package/deploy/dist-overrides/core/tools/find.js +298 -0
- package/deploy/dist-overrides/core/tools/find.js.CHANGELOG +1 -0
- package/deploy/dist-overrides/core/tools/grep.js +305 -0
- package/deploy/dist-overrides/core/tools/grep.js.CHANGELOG +1 -0
- package/deploy/dist-overrides/core/tools/index.js +112 -0
- package/deploy/dist-overrides/core/tools/ls-guard.js +4 -0
- package/deploy/dist-overrides/core/tools/ls.js +170 -0
- package/deploy/dist-overrides/core/tools/ls.js.CHANGELOG +1 -0
- package/deploy/dist-overrides/core/tools/output-accumulator.js +184 -0
- package/deploy/dist-overrides/core/tools/path-utils.js +99 -0
- package/deploy/dist-overrides/core/tools/prompts-reader.js +53 -0
- package/deploy/dist-overrides/core/tools/read.js +392 -0
- package/deploy/dist-overrides/core/tools/read.js.CHANGELOG +1 -0
- package/deploy/dist-overrides/core/tools/render-utils.js +65 -0
- package/deploy/dist-overrides/core/tools/tool-definition-wrapper.js +34 -0
- package/deploy/dist-overrides/core/tools/truncate.js +215 -0
- package/deploy/dist-overrides/core/tools/write.js +203 -0
- package/deploy/dist-overrides/core/tools/write.js.CHANGELOG +1 -0
- package/deploy/dist-overrides/dist-overrides.README +18 -0
- package/deploy/dist-overrides/main.js +665 -0
- package/deploy/dist-overrides/modes/interactive/components/assistant-message.js +139 -0
- package/deploy/dist-overrides/modes/interactive/components/footer.js +326 -0
- package/deploy/dist-overrides/modes/interactive/components/model-selector.js +285 -0
- package/deploy/dist-overrides/modes/interactive/components/tool-execution.js +383 -0
- package/deploy/dist-overrides/modes/interactive/components/tool-execution.js.CHANGELOG +3 -0
- package/deploy/dist-overrides/modes/interactive/interactive-mode.js +4781 -0
- package/deploy/dist-overrides/pi-ai/providers/anthropic.js +931 -0
- package/deploy/dist-overrides/pi-ai/providers/openai-completions.js +1007 -0
- package/deploy/dist-overrides/pi-ai/providers/openai-completions.js.LESSON +15 -0
- package/deploy/dist-overrides/pi-tui/components/loader.js +69 -0
- package/deploy/dist-overrides/pi-tui/components/markdown.js +646 -0
- package/deploy/dist-overrides/pi-tui/components/text.js +92 -0
- package/deploy/dist-overrides/pi-tui/custom-message.js +75 -0
- package/deploy/dist-overrides/pi-tui/tui.js +1266 -0
- package/deploy/dist-overrides/pi-tui/utils.js +1060 -0
- package/deploy/dist-overrides/vendor.REMOVED/jiti/lib/jiti.mjs +3 -0
- package/deploy/install.sh +186 -0
- package/deploy/install.sh.CHANGELOG +6 -0
- package/deploy/lint/lint-naming.ts +202 -0
- package/deploy/scripts/apply.js +18 -0
- package/deploy/scripts/build-github.sh +219 -0
- package/deploy/scripts/build-phone.sh +24 -0
- package/deploy/scripts/check-deploy.sh +42 -0
- package/deploy/scripts/migrate-context.sh +72 -0
- package/deploy/scripts/patch-pi-dist.js +39 -0
- package/deploy/scripts/uninstall.sh +34 -0
- package/package.json +18 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// apps.thirdparty/bilibili/bilibili.ts — B站视频能力(纯 TypeScript,零外部依赖)
|
|
2
|
+
// AI字幕提取 / 视频信息 / 搜索 — 全部通过 B站公开 API
|
|
3
|
+
|
|
4
|
+
const BILI_HEADERS = {
|
|
5
|
+
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
|
6
|
+
"Referer": "https://www.bilibili.com/",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
async function biliGet(url: string): Promise<any> {
|
|
10
|
+
const res = await fetch(url, { headers: BILI_HEADERS, signal: AbortSignal.timeout(15000) });
|
|
11
|
+
const text = await res.text();
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(text);
|
|
14
|
+
} catch {
|
|
15
|
+
throw new Error(`B站 API 返回非 JSON (HTTP ${res.status}): ${text.slice(0, 200)}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function getVideoInfo(bvid: string) {
|
|
20
|
+
const viewRes = await biliGet(`https://api.bilibili.com/x/web-interface/view?bvid=${bvid}`);
|
|
21
|
+
if (viewRes.code !== 0) throw new Error(`B站 view API 错误: ${viewRes.message}`);
|
|
22
|
+
const data = viewRes.data;
|
|
23
|
+
if (!data?.cid) throw new Error(`视频数据异常: 缺少 cid (bvid=${bvid})`);
|
|
24
|
+
// Check for AI subtitles
|
|
25
|
+
const subRes = await biliGet(`https://api.bilibili.com/x/v2/dm/view?type=1&oid=${data.cid}&pid=${data.aid}`);
|
|
26
|
+
const subtitles = subRes?.data?.subtitle?.subtitles || [];
|
|
27
|
+
return { ...data, subtitles, cid: data.cid, aid: data.aid };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function fetchSubtitles(bvid: string): Promise<string> {
|
|
31
|
+
const info = await getVideoInfo(bvid);
|
|
32
|
+
if (!info.subtitles.length) return `视频 "${info.title}" 无 AI 字幕。可尝试 whisper 语音转录。`;
|
|
33
|
+
|
|
34
|
+
const results: string[] = [`## ${info.title}\n时长: ${Math.floor(info.duration/60)}:${String(info.duration%60).padStart(2,'0')} | 播放: ${info.stat.view} | 弹幕: ${info.stat.danmaku}\n`];
|
|
35
|
+
|
|
36
|
+
for (const sub of info.subtitles) {
|
|
37
|
+
let url: string = sub.subtitle_url;
|
|
38
|
+
if (url.startsWith("//")) url = "https:" + url;
|
|
39
|
+
const body = (await biliGet(url)).body || [];
|
|
40
|
+
results.push(`### ${sub.lan_doc} (${body.length} 条)`);
|
|
41
|
+
for (const t of body) {
|
|
42
|
+
const ts = `${Math.floor(t.from/60)}:${String(Math.floor(t.from%60)).padStart(2,'0')}`;
|
|
43
|
+
results.push(`[${ts}] ${t.content}`);
|
|
44
|
+
}
|
|
45
|
+
results.push("");
|
|
46
|
+
}
|
|
47
|
+
return results.join("\n");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function bilibiliCmd(args: any, _ctx: any, _personDir: string): Promise<{ content: any[]; details: any }> {
|
|
51
|
+
const a = args.action || "";
|
|
52
|
+
|
|
53
|
+
if (a === "subs" || a === "fetch_subs") {
|
|
54
|
+
const bvid = args.bvid;
|
|
55
|
+
if (!bvid) return { content: [{ type: "text", text: "需要 bvid 参数(如 BV1Wzjg65EM6)" }], details: {} };
|
|
56
|
+
try {
|
|
57
|
+
const text = await fetchSubtitles(bvid);
|
|
58
|
+
return { content: [{ type: "text", text: text.slice(0, 15000) }], details: { bvid } };
|
|
59
|
+
} catch (e: any) {
|
|
60
|
+
return { content: [{ type: "text", text: `字幕提取失败: ${e.message}` }], details: {} };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (a === "info") {
|
|
65
|
+
const bvid = args.bvid;
|
|
66
|
+
if (!bvid) return { content: [{ type: "text", text: "需要 bvid 参数" }], details: {} };
|
|
67
|
+
try {
|
|
68
|
+
const info = await getVideoInfo(bvid);
|
|
69
|
+
const subs = info.subtitles.map((s: any) => s.lan_doc).join(", ") || "无";
|
|
70
|
+
const text = [
|
|
71
|
+
`标题: ${info.title}`,
|
|
72
|
+
`BV: ${bvid} | 时长: ${Math.floor(info.duration/60)}:${String(info.duration%60).padStart(2,'0')}`,
|
|
73
|
+
`播放: ${info.stat.view} | 弹幕: ${info.stat.danmaku} | 评论: ${info.stat.reply}`,
|
|
74
|
+
`UP: ${info.owner.name} | 粉丝: ${info.owner.follower || "?"}`,
|
|
75
|
+
`AI字幕: ${subs}`,
|
|
76
|
+
`简介: ${info.desc.slice(0, 300)}`,
|
|
77
|
+
].join("\n");
|
|
78
|
+
return { content: [{ type: "text", text }], details: { bvid, cid: info.cid } };
|
|
79
|
+
} catch (e: any) {
|
|
80
|
+
return { content: [{ type: "text", text: `获取失败: ${e.message}` }], details: {} };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (a === "search") {
|
|
85
|
+
const kw = args.keyword || args.query;
|
|
86
|
+
if (!kw) return { content: [{ type: "text", text: "需要 keyword 参数" }], details: {} };
|
|
87
|
+
try {
|
|
88
|
+
// B站搜索需要 cookie 反爬; 用带 cookie 的请求
|
|
89
|
+
const searchRes = await biliGet(
|
|
90
|
+
`https://api.bilibili.com/x/web-interface/search/type?search_type=video&keyword=${encodeURIComponent(kw)}`
|
|
91
|
+
);
|
|
92
|
+
if (searchRes.code !== 0) throw new Error(`搜索API错误 (code=${searchRes.code}): ${searchRes.message}`);
|
|
93
|
+
const videos = (searchRes?.data?.result || []).slice(0, 10);
|
|
94
|
+
if (!videos.length) return { content: [{ type: "text", text: `"${kw}" 无结果。` }], details: {} };
|
|
95
|
+
const text = videos.map((v: any, i: number) => {
|
|
96
|
+
const title = (v.title || "").replace(/<em class="keyword">|<\/em>/g, "");
|
|
97
|
+
const dur = typeof v.duration === "number" ? `${Math.floor(v.duration/60)}:${String(v.duration%60).padStart(2,'0')}` : String(v.duration || "?");
|
|
98
|
+
return `${i+1}. ${title}\n BV${v.bvid} | ${v.play} | ${dur}`;
|
|
99
|
+
}).join("\n");
|
|
100
|
+
return { content: [{ type: "text", text }], details: {} };
|
|
101
|
+
} catch (e: any) {
|
|
102
|
+
return { content: [{ type: "text", text: `搜索失败: ${e.message}` }], details: {} };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (a === "popular") {
|
|
107
|
+
try {
|
|
108
|
+
const data = (await biliGet("https://api.bilibili.com/x/web-interface/popular?ps=10")).data;
|
|
109
|
+
const text = (data?.list || []).map((v: any, i: number) => {
|
|
110
|
+
const dur = typeof v.duration === "number" ? `${Math.floor(v.duration/60)}:${String(v.duration%60).padStart(2,'0')}` : String(v.duration || "?");
|
|
111
|
+
return `${i+1}. ${v.title}\n BV${v.bvid} | ${v.stat.view} | ${v.stat.danmaku} | ${dur}`;
|
|
112
|
+
}).join("\n");
|
|
113
|
+
return { content: [{ type: "text", text }], details: {} };
|
|
114
|
+
} catch (e: any) {
|
|
115
|
+
return { content: [{ type: "text", text: `获取失败: ${e.message}` }], details: {} };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (a === "whisper") {
|
|
120
|
+
return { content: [{ type: "text", text: "Whisper 语音转录暂不可用——需安装 faster-whisper 模型。\n\n用 `subs` 先拿 AI 字幕,大部分 B站视频都有。" }], details: {} };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (a === "hardsub") {
|
|
124
|
+
return { content: [{ type: "text", text: "OCR 硬字幕提取暂不可用——需安装 pyobjc-framework-Vision + PaddleOCR。\n\n用 `subs` 先拿 AI 字幕。" }], details: {} };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
content: [{
|
|
129
|
+
type: "text",
|
|
130
|
+
text: [
|
|
131
|
+
"Bilibili — 视频能力",
|
|
132
|
+
" subs <bvid> AI 字幕(弹幕 API,免登录)",
|
|
133
|
+
" info <bvid> 视频信息 + 字幕列表",
|
|
134
|
+
" search <keyword> 搜索视频",
|
|
135
|
+
" popular 热门榜 TOP10",
|
|
136
|
+
" whisper <bvid> 语音转文字(待装模型)",
|
|
137
|
+
" hardsub <bvid> OCR 硬字幕(待装模型)",
|
|
138
|
+
].join("\n"),
|
|
139
|
+
}],
|
|
140
|
+
details: {},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
source: bilibili.ts @ e7a533de
|
|
2
|
+
|
|
3
|
+
# Bilibili — 视频内容提取
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
B站视频字幕/语音/元数据提取。三条路径:
|
|
7
|
+
1. AI 字幕:弹幕 API (`x/v2/dm/view`),免登录
|
|
8
|
+
2. Whisper:faster-whisper 语音转文字(6核并行)
|
|
9
|
+
3. OCR 硬字幕:Vision/PaddleOCR 识别画面内嵌字幕
|
|
10
|
+
|
|
11
|
+
## 操作
|
|
12
|
+
- `subs <bvid>` — 提取 AI 字幕
|
|
13
|
+
- `whisper <url>` — 语音转文字
|
|
14
|
+
- `hardsub <url>` — OCR 硬字幕
|
|
15
|
+
- `info <bvid>` — 视频元数据
|
|
16
|
+
|
|
17
|
+
## 数据
|
|
18
|
+
底层 Python 脚本位于 `~/Desktop/OSC 开源项目/monorepo base/`
|
|
19
|
+
|
|
20
|
+
## 依赖
|
|
21
|
+
- Python: requests, faster-whisper, opencv-python
|
|
22
|
+
- macOS: pyobjc-framework-Vision, ffmpeg
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// apps.thirdparty/wechatread/wechatread.ts — 微信读书
|
|
2
|
+
import type { PhoneApp } from "../../system.kernel/kernel.ts";
|
|
3
|
+
|
|
4
|
+
// ── Core ──────────────────────────────────────────────────────
|
|
5
|
+
export async function wechatreadCmd(args: any, _ctx: any, _personDir: string): Promise<{ content: any[]; details: any }> {
|
|
6
|
+
const a = args.action || "";
|
|
7
|
+
const kw = args.keyword || args.query || "";
|
|
8
|
+
|
|
9
|
+
if (a === "search") {
|
|
10
|
+
if (!kw) return { content: [{ type: "text", text: "需要 keyword 参数" }], details: {} };
|
|
11
|
+
try {
|
|
12
|
+
const url = `https://weread.qq.com/web/search/global?q=${encodeURIComponent(kw)}`;
|
|
13
|
+
const res = await fetch(url, {
|
|
14
|
+
headers: { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" },
|
|
15
|
+
signal: AbortSignal.timeout(10000),
|
|
16
|
+
});
|
|
17
|
+
const data = await res.json() as any;
|
|
18
|
+
const books = data?.books || [];
|
|
19
|
+
if (!books.length) return { content: [{ type: "text", text: `"${kw}" 无结果。` }], details: {} };
|
|
20
|
+
const text = books.slice(0, 10).map((b: any, i: number) => {
|
|
21
|
+
const info = b.bookInfo || b;
|
|
22
|
+
return `${i+1}. ${info.title} — ${info.author}\n ${info.intro?.slice(0, 80) || ""}`;
|
|
23
|
+
}).join("\n\n");
|
|
24
|
+
return { content: [{ type: "text", text: `搜索: "${kw}"\n\n${text}` }], details: {} };
|
|
25
|
+
} catch (e: any) {
|
|
26
|
+
return { content: [{ type: "text", text: `搜索失败: ${e.message}` }], details: {} };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (a === "hot") {
|
|
31
|
+
try {
|
|
32
|
+
const res = await fetch("https://weread.qq.com/web/bookListInCategory/rising?maxIndex=0", {
|
|
33
|
+
headers: { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36" },
|
|
34
|
+
signal: AbortSignal.timeout(10000),
|
|
35
|
+
});
|
|
36
|
+
const data = await res.json() as any;
|
|
37
|
+
const books = data?.books || [];
|
|
38
|
+
if (!books.length) return { content: [{ type: "text", text: "获取飙升榜失败。" }], details: {} };
|
|
39
|
+
const text = books.slice(0, 10).map((b: any, i: number) => {
|
|
40
|
+
const info = b.bookInfo || b;
|
|
41
|
+
return `${i+1}. ${info.title} — ${info.author}`;
|
|
42
|
+
}).join("\n");
|
|
43
|
+
return { content: [{ type: "text", text: `微信读书 · 飙升榜\n\n${text}` }], details: {} };
|
|
44
|
+
} catch (e: any) {
|
|
45
|
+
return { content: [{ type: "text", text: `获取失败: ${e.message}` }], details: {} };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
content: [{ type: "text", text: "微信读书\n search <keyword> 搜索书籍\n hot 飙升榜" }],
|
|
51
|
+
details: {},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ── PhoneApp ──────────────────────────────────────────────────
|
|
56
|
+
export const app: PhoneApp = {
|
|
57
|
+
name: "微信读书",
|
|
58
|
+
icon: "读书",
|
|
59
|
+
messageDescription: "微信读书 — 搜书/榜单",
|
|
60
|
+
onOpen(_state) {
|
|
61
|
+
return {
|
|
62
|
+
screen: "微信读书\n\n输入「搜索 关键词」搜书\n输入「飙升」看飙升榜\n输入「返回」回主屏幕",
|
|
63
|
+
state: _state ?? {},
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
async onAction(input, state) {
|
|
67
|
+
const cmd = input.trim();
|
|
68
|
+
if (cmd === "飙升" || cmd === "hot") {
|
|
69
|
+
const r = await wechatreadCmd({ action: "hot" }, {}, "");
|
|
70
|
+
return { screen: r.content[0].text, state };
|
|
71
|
+
}
|
|
72
|
+
if (cmd.startsWith("搜索 ") || cmd.startsWith("search ")) {
|
|
73
|
+
const kw = cmd.replace(/^(搜索 |search )/, "");
|
|
74
|
+
const r = await wechatreadCmd({ action: "search", keyword: kw }, {}, "");
|
|
75
|
+
return { screen: r.content[0].text, state };
|
|
76
|
+
}
|
|
77
|
+
const r = await wechatreadCmd({}, {}, "");
|
|
78
|
+
return { screen: r.content[0].text, state };
|
|
79
|
+
},
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./system.kernel/kernel.ts";
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// system.homepage/iphone.ts — Phone command implementation
|
|
2
|
+
// v0.2 spec: phone --home, --notifications, --open, --close, --back, --appswitcher
|
|
3
|
+
|
|
4
|
+
import * as fs from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
|
|
7
|
+
// ── App registry ───────────────────────────────────────────────
|
|
8
|
+
interface AppDef {
|
|
9
|
+
name: string; // display name
|
|
10
|
+
icon?: string; // emoji icon
|
|
11
|
+
messageDescription: string;
|
|
12
|
+
category: "system" | "social" | "tools" | "productivity" | "media";
|
|
13
|
+
homeActions: string[]; // available actions from home (shortcuts)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const BUILTIN_APPS: AppDef[] = [
|
|
17
|
+
{ name: "Messages", icon: "", messageDescription: "即时通讯 — 聊天、群聊", category: "social", homeActions: ["open", "最近对话"] },
|
|
18
|
+
{ name: "Contacts", icon: "", messageDescription: "通讯录 — 联系人管理", category: "social", homeActions: ["open", "搜索联系人"] },
|
|
19
|
+
{ name: "Calendar", icon: "", messageDescription: "日历 — 日程、提醒", category: "productivity", homeActions: ["open", "今日日程"] },
|
|
20
|
+
{ name: "Reminders", icon: "", messageDescription: "提醒事项 — 待办与跟进", category: "productivity", homeActions: ["open", "新建提醒"] },
|
|
21
|
+
{ name: "Notes", icon: "", messageDescription: "备忘录 — 快速记事", category: "productivity", homeActions: ["open", "新建笔记"] },
|
|
22
|
+
{ name: "Files", icon: "", messageDescription: "文件 — 飞书文档、项目文件", category: "tools", homeActions: ["open", "最近文件"] },
|
|
23
|
+
{ name: "Terminal", icon: "", messageDescription: "终端 — 代码与系统命令", category: "tools", homeActions: ["open", "运行命令"] },
|
|
24
|
+
{ name: "Settings", icon: "", messageDescription: "设置 — 设备与偏好", category: "system", homeActions: ["open"] },
|
|
25
|
+
{ name: "Clock", icon: "", messageDescription: "时钟 — 闹钟、计时器", category: "system", homeActions: ["open", "设置闹钟"] },
|
|
26
|
+
{ name: "Feed", icon: "", messageDescription: "信息流 — 通知与事件回顾", category: "system", homeActions: ["open", "查看通知"] },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
// ── Notification store ─────────────────────────────────────────
|
|
30
|
+
interface Notification {
|
|
31
|
+
id: string;
|
|
32
|
+
title: string;
|
|
33
|
+
body: string;
|
|
34
|
+
app: string;
|
|
35
|
+
strength: number; // 0–1
|
|
36
|
+
ts: string;
|
|
37
|
+
read: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function loadNotifications(personDir: string): Notification[] {
|
|
41
|
+
if (!personDir) return [];
|
|
42
|
+
const p = path.join(personDir, "phone_notifications.json");
|
|
43
|
+
try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return []; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function saveNotifications(personDir: string, notifs: Notification[]) {
|
|
47
|
+
if (!personDir) return;
|
|
48
|
+
const p = path.join(personDir, "phone_notifications.json");
|
|
49
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
50
|
+
// Keep last 200
|
|
51
|
+
fs.writeFileSync(p, JSON.stringify(notifs.slice(-200), null, 2));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function addNotification(personDir: string, app: string, title: string, body: string, strength = 0.5) {
|
|
55
|
+
const notifs = loadNotifications(personDir);
|
|
56
|
+
notifs.push({
|
|
57
|
+
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
58
|
+
title, body, app, strength,
|
|
59
|
+
ts: new Date().toISOString(),
|
|
60
|
+
read: false,
|
|
61
|
+
});
|
|
62
|
+
saveNotifications(personDir, notifs);
|
|
63
|
+
return notifs[notifs.length - 1];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// ── Phone state ────────────────────────────────────────────────
|
|
67
|
+
interface PhoneState {
|
|
68
|
+
unlocked: boolean;
|
|
69
|
+
currentApp: string | null;
|
|
70
|
+
currentPage: string | null; // within-app page
|
|
71
|
+
appHistory: string[]; // back stack
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const phoneStates = new Map<string, PhoneState>();
|
|
75
|
+
|
|
76
|
+
function getState(personDir: string): PhoneState {
|
|
77
|
+
let s = phoneStates.get(personDir);
|
|
78
|
+
if (!s) {
|
|
79
|
+
s = { unlocked: true, currentApp: null, currentPage: null, appHistory: [] };
|
|
80
|
+
phoneStates.set(personDir, s);
|
|
81
|
+
}
|
|
82
|
+
return s;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ── Screen renderers ───────────────────────────────────────────
|
|
86
|
+
|
|
87
|
+
function renderHome(state: PhoneState): string {
|
|
88
|
+
const lines: string[] = [];
|
|
89
|
+
lines.push("=== HOME ===");
|
|
90
|
+
lines.push("");
|
|
91
|
+
lines.push("常用应用:");
|
|
92
|
+
for (const app of BUILTIN_APPS) {
|
|
93
|
+
const icon = app.icon || "";
|
|
94
|
+
lines.push(` ${icon ? icon + " " : ""}${app.name} — ${app.messageDescription}`);
|
|
95
|
+
}
|
|
96
|
+
lines.push("");
|
|
97
|
+
lines.push("系统命令: phone --open <app> | phone --notifications | phone --appswitcher");
|
|
98
|
+
if (state.currentApp) {
|
|
99
|
+
lines.push(`当前应用: ${state.currentApp} ${state.currentPage ? `(${state.currentPage})` : ""}`);
|
|
100
|
+
}
|
|
101
|
+
return lines.join("\n");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function renderAppSwitcher(state: PhoneState): string {
|
|
105
|
+
const lines: string[] = ["=== APP SWITCHER ===", ""];
|
|
106
|
+
if (state.appHistory.length === 0 && !state.currentApp) {
|
|
107
|
+
lines.push("(没有运行的应用)");
|
|
108
|
+
} else {
|
|
109
|
+
if (state.currentApp) {
|
|
110
|
+
lines.push(` ▶ ${state.currentApp} ← 当前`);
|
|
111
|
+
}
|
|
112
|
+
const seen = new Set(state.currentApp ? [state.currentApp] : []);
|
|
113
|
+
for (let i = state.appHistory.length - 1; i >= 0; i--) {
|
|
114
|
+
const app = state.appHistory[i];
|
|
115
|
+
if (!seen.has(app)) {
|
|
116
|
+
lines.push(` ${app}`);
|
|
117
|
+
seen.add(app);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
lines.push("");
|
|
122
|
+
lines.push("phone --open <app> 切换 | phone --close 关闭当前 | phone --back 返回");
|
|
123
|
+
return lines.join("\n");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function renderNotifications(personDir: string): string {
|
|
127
|
+
const notifs = loadNotifications(personDir);
|
|
128
|
+
const lines: string[] = ["=== 通知中心 ===", ""];
|
|
129
|
+
const unread = notifs.filter(n => !n.read);
|
|
130
|
+
if (unread.length === 0) {
|
|
131
|
+
lines.push("(没有新通知)");
|
|
132
|
+
} else {
|
|
133
|
+
for (const n of unread.slice(-20)) {
|
|
134
|
+
const strengthIcon = n.strength >= 0.8 ? "[HIGH]" : n.strength >= 0.5 ? "[MED]" : "[LOW]";
|
|
135
|
+
lines.push(` ${strengthIcon} [${n.app}] ${n.title}`);
|
|
136
|
+
if (n.body) lines.push(` ${n.body.slice(0, 100)}`);
|
|
137
|
+
lines.push("");
|
|
138
|
+
}
|
|
139
|
+
lines.push(`共 ${unread.length} 条未读`);
|
|
140
|
+
}
|
|
141
|
+
// Mark all as read
|
|
142
|
+
for (const n of notifs) n.read = true;
|
|
143
|
+
saveNotifications(personDir, notifs);
|
|
144
|
+
return lines.join("\n");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function openApp(state: PhoneState, appName: string): string {
|
|
148
|
+
const app = BUILTIN_APPS.find(a =>
|
|
149
|
+
a.name.toLowerCase() === appName.toLowerCase() ||
|
|
150
|
+
a.name.includes(appName)
|
|
151
|
+
);
|
|
152
|
+
if (!app) {
|
|
153
|
+
const names = BUILTIN_APPS.map(a => a.name).join(", ");
|
|
154
|
+
return `Error: 未找到应用 "${appName}"。可用: ${names}`;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (state.currentApp) {
|
|
158
|
+
state.appHistory.push(state.currentApp);
|
|
159
|
+
}
|
|
160
|
+
state.currentApp = app.name;
|
|
161
|
+
state.currentPage = "main";
|
|
162
|
+
|
|
163
|
+
const lines: string[] = [
|
|
164
|
+
`${app.icon ? app.icon + " " : ""}${app.name} — ${app.messageDescription}`,
|
|
165
|
+
"",
|
|
166
|
+
"可用操作:",
|
|
167
|
+
];
|
|
168
|
+
for (const action of app.homeActions) {
|
|
169
|
+
lines.push(` • ${action}`);
|
|
170
|
+
}
|
|
171
|
+
lines.push("");
|
|
172
|
+
lines.push("系统: phone --back (返回) | phone --close (关闭) | phone --home");
|
|
173
|
+
|
|
174
|
+
return lines.join("\n");
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ── Main handler ───────────────────────────────────────────────
|
|
178
|
+
export async function phoneCmd(args: any, ctx: any, personDir: string): Promise<any> {
|
|
179
|
+
const state = getState(personDir);
|
|
180
|
+
|
|
181
|
+
if (args.home || args._?.[0] === "home") {
|
|
182
|
+
state.currentApp = null; state.currentPage = null;
|
|
183
|
+
const out = renderHome(state);
|
|
184
|
+
ctx.ui?.notify?.("home", "info");
|
|
185
|
+
return { content: [{ type: "text", text: out }] };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (args.notifications || args._?.[0] === "notifications") {
|
|
189
|
+
const out = renderNotifications(personDir);
|
|
190
|
+
ctx.ui?.notify?.("notifications", "info");
|
|
191
|
+
return { content: [{ type: "text", text: out }] };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (args.appswitcher || args._?.[0] === "appswitcher") {
|
|
195
|
+
const out = renderAppSwitcher(state);
|
|
196
|
+
ctx.ui?.notify?.("app switcher", "info");
|
|
197
|
+
return { content: [{ type: "text", text: out }] };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (args.close || args._?.[0] === "close") {
|
|
201
|
+
const closed = state.currentApp;
|
|
202
|
+
state.currentApp = state.appHistory.pop() ?? null;
|
|
203
|
+
state.currentPage = null;
|
|
204
|
+
const out = closed
|
|
205
|
+
? `关闭了 ${closed}。${state.currentApp ? `回到 ${state.currentApp}` : "回到主页"}`
|
|
206
|
+
: "没有打开的应用。";
|
|
207
|
+
ctx.ui?.notify?.(closed || "home", "info");
|
|
208
|
+
return { content: [{ type: "text", text: out }] };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (args.back || args._?.[0] === "back") {
|
|
212
|
+
if (!state.currentApp) {
|
|
213
|
+
return { content: [{ type: "text", text: "已在主页,没有可返回的。" }] };
|
|
214
|
+
}
|
|
215
|
+
// Back within app: go to main page
|
|
216
|
+
if (state.currentPage && state.currentPage !== "main") {
|
|
217
|
+
state.currentPage = "main";
|
|
218
|
+
return { content: [{ type: "text", text: `返回 ${state.currentApp} 主页。` }] };
|
|
219
|
+
}
|
|
220
|
+
// Back from app to previous app or home
|
|
221
|
+
const prev = state.appHistory.pop();
|
|
222
|
+
state.currentApp = prev ?? null;
|
|
223
|
+
state.currentPage = prev ? "main" : null;
|
|
224
|
+
const out = prev
|
|
225
|
+
? `返回 ${prev}。`
|
|
226
|
+
: "返回主页。";
|
|
227
|
+
ctx.ui?.notify?.("back", "info");
|
|
228
|
+
return { content: [{ type: "text", text: out }] };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (args.open || args._?.[0] === "open") {
|
|
232
|
+
const appName = (args.open || args._?.[1]) as string;
|
|
233
|
+
if (!appName) {
|
|
234
|
+
return { content: [{ type: "text", text: "用法: phone --open <应用名>" }] };
|
|
235
|
+
}
|
|
236
|
+
const out = openApp(state, appName);
|
|
237
|
+
ctx.ui?.notify?.(appName, "info");
|
|
238
|
+
return { content: [{ type: "text", text: out }] };
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// default: show home
|
|
242
|
+
const out = renderHome(state);
|
|
243
|
+
return { content: [{ type: "text", text: out }] };
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// ── Public API for other extensions ────────────────────────────
|
|
247
|
+
export { BUILTIN_APPS, addNotification, loadNotifications, type Notification, type PhoneState, getState };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
source: homepage.ts @ fbf4078a
|
|
2
|
+
|
|
3
|
+
# iPhone -- 手机主界面与导航
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
模拟 iPhone 主屏幕、通知中心、应用切换器。管理手机 UI 状态(当前应用、历史栈)和通知队列。
|
|
7
|
+
|
|
8
|
+
## 操作
|
|
9
|
+
- `--home` -- 回到主屏幕,显示全部内置应用列表
|
|
10
|
+
- `--open <app>` -- 打开指定应用(按名称模糊匹配)
|
|
11
|
+
- `--back` -- 应用内返回上页,或返回上一个应用/主页
|
|
12
|
+
- `--close` -- 关闭当前应用,回到上一个应用或主页
|
|
13
|
+
- `--notifications` -- 显示未读通知并标记已读(保留最近 200 条)
|
|
14
|
+
- `--appswitcher` -- 显示运行中的应用列表
|
|
15
|
+
- 无参数 -- 等同 `--home`
|
|
16
|
+
|
|
17
|
+
## 数据
|
|
18
|
+
- `{personDir}/phone_notifications.json` -- Notification[] 通知队列
|
|
19
|
+
- 内存 Map 缓存 PhoneState(unlocked/currentApp/appHistory)
|
|
20
|
+
|
|
21
|
+
## 备注
|
|
22
|
+
内置 10 个应用定义(BUILTIN_APPS)。导出 `addNotification` 供其他应用推送通知。通知队列上限 200 条。
|