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,423 @@
|
|
|
1
|
+
import { registerShareTarget } from "../../system.share/share.ts";
|
|
2
|
+
// apps.preinstalled/imessage/imessage.ts — Talk (对话) system implementation
|
|
3
|
+
// v0.2 spec: talk --to <contact>, --join <talkId>, --end, --list, --leave
|
|
4
|
+
// Each talk has a unique ID, state, participants, and recorded history
|
|
5
|
+
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import * as path from "path";
|
|
8
|
+
import type { PhoneApp } from "../../system.kernel/kernel.ts";
|
|
9
|
+
|
|
10
|
+
// ── Talk types ─────────────────────────────────────────────────
|
|
11
|
+
interface TalkSession {
|
|
12
|
+
id: string;
|
|
13
|
+
type: "f2f" | "group" | "remote"; // f2f=面对面, group=群聊, remote=远程
|
|
14
|
+
participants: string[]; // contact IDs
|
|
15
|
+
initiator: string; // who started
|
|
16
|
+
state: "inviting" | "active" | "ended";
|
|
17
|
+
created: string;
|
|
18
|
+
ended?: string;
|
|
19
|
+
visibility: "private" | "public"; // can others join?
|
|
20
|
+
topic?: string;
|
|
21
|
+
proposals: Proposal[]; // active proposals in this talk
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface TalkState {
|
|
25
|
+
activeTalks: TalkSession[]; // talks I'm in
|
|
26
|
+
currentTalkId: string | null; // which talk I'm focused on
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface Proposal {
|
|
30
|
+
id: string;
|
|
31
|
+
title: string;
|
|
32
|
+
messageDescription?: string;
|
|
33
|
+
proposer: string;
|
|
34
|
+
votes: Record<string, "agree" | "disagree">; // voterId → vote
|
|
35
|
+
rule: "majority" | "unanimous"; // how to decide
|
|
36
|
+
decided: boolean;
|
|
37
|
+
result?: "passed" | "rejected";
|
|
38
|
+
created: string;
|
|
39
|
+
decidedAt?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const talkStates = new Map<string, TalkState>();
|
|
43
|
+
const talkStore = new Map<string, TalkSession[]>(); // personDir → talks
|
|
44
|
+
|
|
45
|
+
function getState(personDir: string): TalkState {
|
|
46
|
+
let s = talkStates.get(personDir);
|
|
47
|
+
if (!s) {
|
|
48
|
+
s = { activeTalks: [], currentTalkId: null };
|
|
49
|
+
talkStates.set(personDir, s);
|
|
50
|
+
}
|
|
51
|
+
return s;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function loadTalks(personDir: string): TalkSession[] {
|
|
55
|
+
let talks = talkStore.get(personDir);
|
|
56
|
+
if (!talks) {
|
|
57
|
+
const p = path.join(personDir, "talks.json");
|
|
58
|
+
try { talks = JSON.parse(fs.readFileSync(p, "utf8")); } catch { talks = []; }
|
|
59
|
+
talkStore.set(personDir, talks);
|
|
60
|
+
}
|
|
61
|
+
return talks!;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function saveTalks(personDir: string) {
|
|
65
|
+
const talks = talkStore.get(personDir) ?? [];
|
|
66
|
+
const p = path.join(personDir, "talks.json");
|
|
67
|
+
fs.mkdirSync(path.dirname(p), { recursive: true });
|
|
68
|
+
fs.writeFileSync(p, JSON.stringify(talks, null, 2));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ── Renderers ──────────────────────────────────────────────────
|
|
72
|
+
function renderTalkList(state: TalkState): string {
|
|
73
|
+
const lines: string[] = ["--- 对话列表 ---", ""];
|
|
74
|
+
if (state.activeTalks.length === 0) {
|
|
75
|
+
lines.push("(没有进行中的对话)");
|
|
76
|
+
} else {
|
|
77
|
+
for (const t of state.activeTalks) {
|
|
78
|
+
const marker = t.id === state.currentTalkId ? "▶" : " ";
|
|
79
|
+
const participants = t.participants.join(", ");
|
|
80
|
+
const status = t.state === "active" ? "进行中" : t.state === "inviting" ? "等待中" : "已结束";
|
|
81
|
+
lines.push(` ${marker} ${t.id} [${t.type}] ${participants} — ${status}`);
|
|
82
|
+
if (t.topic) lines.push(` 主题: ${t.topic}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
lines.push("");
|
|
86
|
+
lines.push("命令: talk --to <contactId> | talk --join <talkId> | talk --end | talk --leave | 「朋友圈」");
|
|
87
|
+
return lines.join("\n");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function renderTalkDetail(state: TalkState): string {
|
|
91
|
+
if (!state.currentTalkId) {
|
|
92
|
+
return "当前没有在对话中。talk --list 查看可用对话,talk --to <id> 发起新对话。";
|
|
93
|
+
}
|
|
94
|
+
const talk = state.activeTalks.find(t => t.id === state.currentTalkId);
|
|
95
|
+
if (!talk) {
|
|
96
|
+
state.currentTalkId = null;
|
|
97
|
+
return "对话已不存在。";
|
|
98
|
+
}
|
|
99
|
+
const lines: string[] = [
|
|
100
|
+
`对话 ${talk.id}`,
|
|
101
|
+
` 类型: ${talk.type} | 状态: ${talk.state}`,
|
|
102
|
+
` 参与者: ${talk.participants.join(", ")}`,
|
|
103
|
+
` 发起人: ${talk.initiator}`,
|
|
104
|
+
` 创建: ${talk.created}`,
|
|
105
|
+
];
|
|
106
|
+
if (talk.topic) lines.push(` 主题: ${talk.topic}`);
|
|
107
|
+
lines.push("");
|
|
108
|
+
lines.push("命令: talk --end (结束) | talk --leave (离开) | talk --list (列表)");
|
|
109
|
+
return lines.join("\n");
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// ── Contacts retrieval ─────────────────────────────────────────
|
|
113
|
+
function loadContacts(personDir: string): any[] {
|
|
114
|
+
const p = path.join(personDir, "contacts.json");
|
|
115
|
+
try { return JSON.parse(fs.readFileSync(p, "utf8")); } catch { return []; }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// ── Main handler ───────────────────────────────────────────────
|
|
119
|
+
export async function talkCmd(args: any, ctx: any, personDir: string): Promise<any> {
|
|
120
|
+
const state = getState(personDir);
|
|
121
|
+
state.activeTalks = loadTalks(personDir).filter(t => t.state !== "ended");
|
|
122
|
+
|
|
123
|
+
// talk --list
|
|
124
|
+
if (args.list || args._?.[0] === "list") {
|
|
125
|
+
const out = renderTalkList(state);
|
|
126
|
+
ctx.ui?.notify?.("对话列表", "info");
|
|
127
|
+
return { content: [{ type: "text", text: out }] };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// talk --to <contactId> [--topic <text>]
|
|
131
|
+
if (args.to || args._?.[0] === "to") {
|
|
132
|
+
const contactId = (args.to || args._?.[1]) as string;
|
|
133
|
+
if (!contactId) {
|
|
134
|
+
return { content: [{ type: "text", text: "用法: talk --to <contactId> [--topic <文本>]" }] };
|
|
135
|
+
}
|
|
136
|
+
// Verify contact exists
|
|
137
|
+
const contacts = loadContacts(personDir);
|
|
138
|
+
const contact = contacts.find((c: any) => c.id === contactId || c.name === contactId);
|
|
139
|
+
if (!contact) {
|
|
140
|
+
return { content: [{ type: "text", text: `未找到联系人 "${contactId}"。先用 contacts --add 添加。` }] };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Check if already in a talk with this contact
|
|
144
|
+
const existing = state.activeTalks.find(t =>
|
|
145
|
+
t.type === "f2f" && t.participants.includes(contactId) && t.state === "active"
|
|
146
|
+
);
|
|
147
|
+
if (existing) {
|
|
148
|
+
state.currentTalkId = existing.id;
|
|
149
|
+
return { content: [{ type: "text", text: `已在与 ${contact.name ?? contactId} 的对话中 (${existing.id})。` }] };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Create new f2f talk
|
|
153
|
+
const talkId = `talk-${Date.now().toString(36)}`;
|
|
154
|
+
const topic = args.topic as string | undefined;
|
|
155
|
+
const talk: TalkSession = {
|
|
156
|
+
id: talkId,
|
|
157
|
+
type: "f2f",
|
|
158
|
+
participants: ["self", contactId],
|
|
159
|
+
initiator: "self",
|
|
160
|
+
state: "active",
|
|
161
|
+
created: new Date().toISOString(),
|
|
162
|
+
visibility: "private",
|
|
163
|
+
topic,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
state.activeTalks.push(talk);
|
|
167
|
+
state.currentTalkId = talkId;
|
|
168
|
+
const allTalks = loadTalks(personDir);
|
|
169
|
+
allTalks.push(talk);
|
|
170
|
+
talkStore.set(personDir, allTalks);
|
|
171
|
+
saveTalks(personDir);
|
|
172
|
+
|
|
173
|
+
ctx.ui?.notify?.(`与 ${contact.name ?? contactId} 发起对话`, "info");
|
|
174
|
+
const out = [
|
|
175
|
+
`开始与 ${contact.name ?? contactId} 的对话`,
|
|
176
|
+
` ID: ${talkId}`,
|
|
177
|
+
topic ? ` 主题: ${topic}` : "",
|
|
178
|
+
` 你现在可以在此对话中交流。`,
|
|
179
|
+
].filter(Boolean).join("\n");
|
|
180
|
+
return { content: [{ type: "text", text: out }] };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// talk --join <talkId>
|
|
184
|
+
if (args.join || args._?.[0] === "join") {
|
|
185
|
+
const talkId = (args.join || args._?.[1]) as string;
|
|
186
|
+
if (!talkId) {
|
|
187
|
+
return { content: [{ type: "text", text: "用法: talk --join <talkId>" }] };
|
|
188
|
+
}
|
|
189
|
+
const allTalks = loadTalks(personDir);
|
|
190
|
+
const talk = allTalks.find(t => t.id === talkId && t.state === "active");
|
|
191
|
+
if (!talk) {
|
|
192
|
+
return { content: [{ type: "text", text: `未找到对话 "${talkId}" 或对话已结束。` }] };
|
|
193
|
+
}
|
|
194
|
+
if (talk.visibility === "private") {
|
|
195
|
+
return { content: [{ type: "text", text: `对话 "${talkId}" 是私密的,无法加入。` }] };
|
|
196
|
+
}
|
|
197
|
+
if (!talk.participants.includes("self")) {
|
|
198
|
+
talk.participants.push("self");
|
|
199
|
+
}
|
|
200
|
+
if (!state.activeTalks.find(t => t.id === talkId)) {
|
|
201
|
+
state.activeTalks.push(talk);
|
|
202
|
+
}
|
|
203
|
+
state.currentTalkId = talkId;
|
|
204
|
+
saveTalks(personDir);
|
|
205
|
+
ctx.ui?.notify?.(`加入对话 ${talkId}`, "info");
|
|
206
|
+
return { content: [{ type: "text", text: `已加入对话 ${talkId}。参与者: ${talk.participants.join(", ")}` }] };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// talk --end
|
|
210
|
+
if (args.end || args._?.[0] === "end") {
|
|
211
|
+
if (!state.currentTalkId) {
|
|
212
|
+
return { content: [{ type: "text", text: "当前没有进行中的对话。" }] };
|
|
213
|
+
}
|
|
214
|
+
const allTalks = loadTalks(personDir);
|
|
215
|
+
const talk = allTalks.find(t => t.id === state.currentTalkId);
|
|
216
|
+
if (talk) {
|
|
217
|
+
talk.state = "ended";
|
|
218
|
+
talk.ended = new Date().toISOString();
|
|
219
|
+
}
|
|
220
|
+
state.activeTalks = state.activeTalks.filter(t => t.id !== state.currentTalkId);
|
|
221
|
+
const endedId = state.currentTalkId;
|
|
222
|
+
state.currentTalkId = state.activeTalks[0]?.id ?? null;
|
|
223
|
+
saveTalks(personDir);
|
|
224
|
+
ctx.ui?.notify?.(`结束对话 ${endedId}`, "info");
|
|
225
|
+
return { content: [{ type: "text", text: `对话 ${endedId} 已结束。` }] };
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// talk --leave
|
|
229
|
+
if (args.leave || args._?.[0] === "leave") {
|
|
230
|
+
if (!state.currentTalkId) {
|
|
231
|
+
return { content: [{ type: "text", text: "当前没有进行中的对话。" }] };
|
|
232
|
+
}
|
|
233
|
+
state.activeTalks = state.activeTalks.filter(t => t.id !== state.currentTalkId);
|
|
234
|
+
const leftId = state.currentTalkId;
|
|
235
|
+
state.currentTalkId = state.activeTalks[0]?.id ?? null;
|
|
236
|
+
ctx.ui?.notify?.(`离开对话 ${leftId}`, "info");
|
|
237
|
+
return { content: [{ type: "text", text: `已离开对话 ${leftId}。` }] };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// talk --propose <title> [--desc <text>] [--rule majority|unanimous]
|
|
241
|
+
if (args.propose || args._?.[0] === "propose") {
|
|
242
|
+
if (!state.currentTalkId) {
|
|
243
|
+
return { content: [{ type: "text", text: "当前没有进行中的对话。先 talk --to <id> 发起对话。" }] };
|
|
244
|
+
}
|
|
245
|
+
const talk = state.activeTalks.find(t => t.id === state.currentTalkId);
|
|
246
|
+
if (!talk) return { content: [{ type: "text", text: "对话状态异常。" }] };
|
|
247
|
+
|
|
248
|
+
const title = (typeof args.propose === "string" ? args.propose : args._?.[1]) as string;
|
|
249
|
+
if (!title) return { content: [{ type: "text", text: "用法: talk --propose <标题> [--desc <描述>] [--rule majority|unanimous]" }] };
|
|
250
|
+
|
|
251
|
+
const proposal: Proposal = {
|
|
252
|
+
id: `prop-${Date.now().toString(36)}`,
|
|
253
|
+
title,
|
|
254
|
+
messageDescription: args.desc as string | undefined,
|
|
255
|
+
proposer: "self",
|
|
256
|
+
votes: { "self": "agree" }, // proposer auto-agrees
|
|
257
|
+
rule: (args.rule as "majority" | "unanimous") || "majority",
|
|
258
|
+
decided: false,
|
|
259
|
+
created: new Date().toISOString(),
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
talk.proposals = talk.proposals || [];
|
|
263
|
+
talk.proposals.push(proposal);
|
|
264
|
+
saveTalks(personDir);
|
|
265
|
+
|
|
266
|
+
const lines = [
|
|
267
|
+
`**提案: ${title}**`,
|
|
268
|
+
` ID: \`${proposal.id}\``,
|
|
269
|
+
` 规则: ${proposal.rule === "unanimous" ? "全票通过" : "多数通过"}`,
|
|
270
|
+
proposal.messageDescription ? ` 描述: ${proposal.messageDescription}` : "",
|
|
271
|
+
` 当前票数: agree=1, disagree=0`,
|
|
272
|
+
` 参与者投票: talk --vote ${proposal.id} agree|disagree`,
|
|
273
|
+
];
|
|
274
|
+
return { content: [{ type: "text", text: lines.filter(Boolean).join("\n") }] };
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// talk --vote <proposalId> agree|disagree
|
|
278
|
+
if (args.vote || args._?.[0] === "vote") {
|
|
279
|
+
if (!state.currentTalkId) {
|
|
280
|
+
return { content: [{ type: "text", text: "当前没有进行中的对话。" }] };
|
|
281
|
+
}
|
|
282
|
+
const talk = state.activeTalks.find(t => t.id === state.currentTalkId);
|
|
283
|
+
if (!talk) return { content: [{ type: "text", text: "对话状态异常。" }] };
|
|
284
|
+
|
|
285
|
+
const propId = (args.vote || args._?.[1]) as string;
|
|
286
|
+
const vote = ((args._?.[2] || args.agree ? "agree" : args.disagree ? "disagree" : null)) as string;
|
|
287
|
+
if (!propId || !vote) return { content: [{ type: "text", text: "用法: talk --vote <proposalId> agree|disagree" }] };
|
|
288
|
+
|
|
289
|
+
const proposal = (talk.proposals || []).find(p => p.id === propId);
|
|
290
|
+
if (!proposal) return { content: [{ type: "text", text: `未找到提案: ${propId}` }] };
|
|
291
|
+
if (proposal.decided) return { content: [{ type: "text", text: `提案已${proposal.result === "passed" ? "通过" : "驳回"}: **${proposal.title}**` }] };
|
|
292
|
+
|
|
293
|
+
proposal.votes["self"] = vote as "agree" | "disagree";
|
|
294
|
+
|
|
295
|
+
// Check if decided
|
|
296
|
+
const agreeCount = Object.values(proposal.votes).filter(v => v === "agree").length;
|
|
297
|
+
const disagreeCount = Object.values(proposal.votes).filter(v => v === "disagree").length;
|
|
298
|
+
const total = talk.participants.length;
|
|
299
|
+
|
|
300
|
+
let decided = false;
|
|
301
|
+
if (proposal.rule === "unanimous") {
|
|
302
|
+
decided = agreeCount === total;
|
|
303
|
+
} else {
|
|
304
|
+
decided = agreeCount > total / 2;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (decided) {
|
|
308
|
+
proposal.decided = true;
|
|
309
|
+
proposal.result = "passed";
|
|
310
|
+
proposal.decidedAt = new Date().toISOString();
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
saveTalks(personDir);
|
|
314
|
+
|
|
315
|
+
const lines = [
|
|
316
|
+
`**投票: ${vote.toUpperCase()}** → ${proposal.title}`,
|
|
317
|
+
` agree: ${agreeCount} disagree: ${disagreeCount}`,
|
|
318
|
+
` 总参与者: ${total}`,
|
|
319
|
+
proposal.decided ? `\n**结果: ${proposal.result === "passed" ? "通过" : "驳回"}**` : ` 还需 ${Math.floor(total / 2) + 1 - agreeCount} 票 agree 通过`,
|
|
320
|
+
];
|
|
321
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// talk --proposals: list active proposals
|
|
325
|
+
if (args.proposals || args._?.[0] === "proposals") {
|
|
326
|
+
if (!state.currentTalkId) {
|
|
327
|
+
return { content: [{ type: "text", text: "当前没有进行中的对话。" }] };
|
|
328
|
+
}
|
|
329
|
+
const talk = state.activeTalks.find(t => t.id === state.currentTalkId);
|
|
330
|
+
if (!talk || !talk.proposals || talk.proposals.length === 0) {
|
|
331
|
+
return { content: [{ type: "text", text: "当前对话无活跃提案。用 talk --propose <标题> 发起。" }] };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const lines = ["**当前对话提案**"];
|
|
335
|
+
for (const p of talk.proposals) {
|
|
336
|
+
const agree = Object.values(p.votes).filter(v => v === "agree").length;
|
|
337
|
+
const disagree = Object.values(p.votes).filter(v => v === "disagree").length;
|
|
338
|
+
const status = p.decided ? (p.result === "passed" ? "通过" : "驳回") : `agree=${agree} disagree=${disagree}`;
|
|
339
|
+
lines.push(` \`${p.id}\` **${p.title}** — ${status} (${p.rule})`);
|
|
340
|
+
}
|
|
341
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// default: show current talk detail or list
|
|
345
|
+
if (state.currentTalkId) {
|
|
346
|
+
const out = renderTalkDetail(state);
|
|
347
|
+
return { content: [{ type: "text", text: out }] };
|
|
348
|
+
}
|
|
349
|
+
const out = renderTalkList(state);
|
|
350
|
+
ctx.ui?.notify?.("Talk", "info");
|
|
351
|
+
return { content: [{ type: "text", text: out }] };
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// ── Public API ─────────────────────────────────────────────────
|
|
355
|
+
export function getCurrentTalk(personDir: string): TalkSession | null {
|
|
356
|
+
const state = getState(personDir);
|
|
357
|
+
state.activeTalks = loadTalks(personDir).filter(t => t.state !== "ended");
|
|
358
|
+
if (!state.currentTalkId) return null;
|
|
359
|
+
return state.activeTalks.find(t => t.id === state.currentTalkId) ?? null;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export { type TalkSession, type TalkState };
|
|
363
|
+
|
|
364
|
+
registerShareTarget("WeChat", { name: "朋友圈", handler: (txt, dir) => { const ms = loadMoments(dir); ms.push({ id: "s" + Date.now(), text: txt, time: new Date().toISOString() }); saveMoments(dir, ms); return "已分享到朋友圈!"; } });
|
|
365
|
+
function renderMoments(personDir: string): string {
|
|
366
|
+
const ms = loadMoments(personDir); const lines = ["--- 朋友圈 ---", ""];
|
|
367
|
+
if (!ms.length) lines.push(" 还没有动态。输入「发动态 <内容>」发布第一条。");
|
|
368
|
+
else for (const m of ms.slice(-20).reverse()) lines.push(` [${m.time.slice(0,16)}]\n ${m.text}\n`);
|
|
369
|
+
lines.push("", "命令: 发动态 <内容> | 删动态 <id> | 返回"); return lines.join("\n");
|
|
370
|
+
}
|
|
371
|
+
export const app: PhoneApp = {
|
|
372
|
+
name: "WeChat",
|
|
373
|
+
icon: "WeChat",
|
|
374
|
+
messageDescription: "即时通讯、朋友圈、联系人",
|
|
375
|
+
onOpen(state, personDir) {
|
|
376
|
+
if ((state as any)?.page === "moments") return { screen: renderMoments(personDir), state };
|
|
377
|
+
const s = getState(personDir);
|
|
378
|
+
s.activeTalks = loadTalks(personDir).filter(t => t.state !== "ended");
|
|
379
|
+
const screen = s.currentTalkId
|
|
380
|
+
? renderTalkDetail(s)
|
|
381
|
+
: renderTalkList(s);
|
|
382
|
+
return { screen, state: state ?? {} };
|
|
383
|
+
},
|
|
384
|
+
async onAction(input, state, personDir) {
|
|
385
|
+
const s = getState(personDir);
|
|
386
|
+
const trimmed = input.trim();
|
|
387
|
+
// if (trimmed === "朋友圈") return { screen: renderMoments(personDir), state: { ...state, page: "moments" } };
|
|
388
|
+
// if ((state as any)?.page === "moments") {
|
|
389
|
+
// if (/^发动态\s+/.test(trimmed)) { const txt = trimmed.replace(/^发动态\s+/, "").trim(); /* loadMoments/saveMoments not implemented */ }
|
|
390
|
+
// if (/^删动态\s+/.test(trimmed)) { /* not implemented */ }
|
|
391
|
+
// if (trimmed === "返回") return { screen: renderTalkList(s), state: { ...state, page: "talk" } };
|
|
392
|
+
// }
|
|
393
|
+
(state as any).page = "talk";
|
|
394
|
+
let args: any = {};
|
|
395
|
+
|
|
396
|
+
if (/^发起对话\s+/.test(trimmed)) {
|
|
397
|
+
const rest = trimmed.replace(/^发起对话\s+/, "").trim();
|
|
398
|
+
args = { to: rest };
|
|
399
|
+
} else if (/^加入\s+/.test(trimmed)) {
|
|
400
|
+
args = { join: trimmed.replace(/^加入\s+/, "").trim() };
|
|
401
|
+
} else if (trimmed === "列表") {
|
|
402
|
+
args = { list: true };
|
|
403
|
+
} else if (trimmed === "结束") {
|
|
404
|
+
args = { end: true };
|
|
405
|
+
} else if (trimmed === "离开") {
|
|
406
|
+
args = { leave: true };
|
|
407
|
+
} else if (/^提案\s+/.test(trimmed)) {
|
|
408
|
+
args = { propose: trimmed.replace(/^提案\s+/, "").trim() };
|
|
409
|
+
} else if (/^投票\s+/.test(trimmed)) {
|
|
410
|
+
const parts = trimmed.replace(/^投票\s+/, "").trim().split(/\s+/);
|
|
411
|
+
args = { vote: parts[0], _: ["vote", parts[0], parts[1] || "agree"] };
|
|
412
|
+
} else if (trimmed === "提案列表") {
|
|
413
|
+
args = { proposals: true };
|
|
414
|
+
} else {
|
|
415
|
+
// default: show current talk or list
|
|
416
|
+
args = {};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const result = await talkCmd(args, {}, personDir);
|
|
420
|
+
const screen = result.content?.[0]?.text ?? "WeChat";
|
|
421
|
+
return { screen, state };
|
|
422
|
+
},
|
|
423
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
source: imessage.ts @ 97784914
|
|
2
|
+
|
|
3
|
+
# iMessage (Talk) -- 对话会话系统
|
|
4
|
+
|
|
5
|
+
## 功能
|
|
6
|
+
管理与联系人的对话会话(f2f/group/remote)。支持发起、加入、离开、结束对话,以及会话内提案投票机制。
|
|
7
|
+
|
|
8
|
+
## 操作
|
|
9
|
+
- `--to <contactId>` -- 发起 f2f 对话(可选 `--topic`)
|
|
10
|
+
- `--join <talkId>` -- 加入公开对话
|
|
11
|
+
- `--end` -- 结束当前对话
|
|
12
|
+
- `--leave` -- 离开当前对话(不结束)
|
|
13
|
+
- `--list` -- 列出所有进行中对话
|
|
14
|
+
- `--propose <title>` -- 发起提案(可选 `--desc`, `--rule majority|unanimous`)
|
|
15
|
+
- `--vote <proposalId> agree|disagree` -- 投票
|
|
16
|
+
- `--proposals` -- 列出当前对话的提案
|
|
17
|
+
- 无参数 -- 显示当前对话详情或列表
|
|
18
|
+
|
|
19
|
+
## 数据
|
|
20
|
+
- `{personDir}/talks.json` -- TalkSession[] 持久化
|
|
21
|
+
- 内存 Map 缓存 TalkState(activeTalks + currentTalkId)
|
|
22
|
+
|
|
23
|
+
## 备注
|
|
24
|
+
依赖 contacts 数据验证联系人。提案自动投 proposer agree 票。导出 `getCurrentTalk` 供外部查询。
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// apps.system/appstore/appstore.ts — AppStore tool (AI) — stub
|
|
2
|
+
import type { PhoneApp } from "../../system.kernel/kernel.ts";
|
|
3
|
+
|
|
4
|
+
export async function appstoreCmd(args: any, _ctx: any, _personDir: string): Promise<{ content: any[]; details: any }> {
|
|
5
|
+
return { content: [{ type: "text", text: "AppStore 功能尚未实现" }], details: {} };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// ── PhoneApp ──────────────────────────────────────────────────
|
|
9
|
+
export const app: PhoneApp = {
|
|
10
|
+
name: "App Store",
|
|
11
|
+
icon: "商店",
|
|
12
|
+
messageDescription: "应用商店",
|
|
13
|
+
onOpen(_state, _personDir) {
|
|
14
|
+
return {
|
|
15
|
+
screen: "App Store\n\n功能开发中...",
|
|
16
|
+
state: _state ?? {},
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
onAction(_input, state, _personDir) {
|
|
20
|
+
return { screen: "App Store\n\n功能开发中...", state };
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// apps.system/finder/finder.ts — Finder tool (AI)
|
|
2
|
+
import { asyncSh } from "#sh";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import type { PhoneApp } from "../../system.kernel/kernel.ts";
|
|
6
|
+
|
|
7
|
+
export async function finderCmd(args: any, _ctx: any, _personDir: string): Promise<{ content: any[]; details: any }> {
|
|
8
|
+
const a = args.action || "";
|
|
9
|
+
const dir = args.path ? args.path.replace("~", homedir()) : homedir();
|
|
10
|
+
|
|
11
|
+
if (a === "search") {
|
|
12
|
+
const name = args.name || "*";
|
|
13
|
+
try {
|
|
14
|
+
const raw = await asyncSh(`find "${dir}" -name "${name}" -maxdepth ${args.maxdepth || 4} 2>/dev/null | head -20`);
|
|
15
|
+
const files = raw.trim().split("\n").filter(Boolean);
|
|
16
|
+
if (files.length === 0) return { content: [{ type: "text", text: `未找到匹配 "${name}" 的文件` }], details: {} };
|
|
17
|
+
return { content: [{ type: "text", text: files.join("\n") }], details: { files } };
|
|
18
|
+
} catch { return { content: [{ type: "text", text: "搜索失败" }], details: {} }; }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (a === "list") {
|
|
22
|
+
try {
|
|
23
|
+
const raw = await asyncSh(`ls -lh "${dir}" 2>/dev/null | head -30`);
|
|
24
|
+
return { content: [{ type: "text", text: raw.trim() || "(空目录)" }], details: { dir } };
|
|
25
|
+
} catch { return { content: [{ type: "text", text: "目录不存在或无法读取" }], details: {} }; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { content: [{ type: "text", text: `未知操作: ${a}。可用: search, list` }], details: {} };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// ── PhoneApp ──────────────────────────────────────────────────
|
|
32
|
+
export const app: PhoneApp = {
|
|
33
|
+
name: "Finder",
|
|
34
|
+
icon: "📂",
|
|
35
|
+
messageDescription: "文件搜索与浏览",
|
|
36
|
+
onOpen(_state, _personDir) {
|
|
37
|
+
return {
|
|
38
|
+
screen: [
|
|
39
|
+
"📂 Finder",
|
|
40
|
+
"",
|
|
41
|
+
"命令:",
|
|
42
|
+
" 搜索 <文件名> — 搜索文件",
|
|
43
|
+
" 列出 [路径] — 列出目录内容",
|
|
44
|
+
].join("\n"),
|
|
45
|
+
state: _state ?? {},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
async onAction(input, state, personDir) {
|
|
49
|
+
const trimmed = input.trim();
|
|
50
|
+
let args: any = {};
|
|
51
|
+
|
|
52
|
+
if (/^搜索\s+/.test(trimmed)) {
|
|
53
|
+
args = { action: "search", name: trimmed.replace(/^搜索\s+/, "").trim() };
|
|
54
|
+
} else if (/^列出/.test(trimmed)) {
|
|
55
|
+
const p = trimmed.replace(/^列出\s*/, "").trim();
|
|
56
|
+
args = { action: "list", path: p || undefined };
|
|
57
|
+
} else {
|
|
58
|
+
args = { action: trimmed };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const result = await finderCmd(args, {}, personDir);
|
|
62
|
+
return { screen: result.content[0].text, state };
|
|
63
|
+
},
|
|
64
|
+
};
|