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,236 @@
|
|
|
1
|
+
// blood.runtime/messages.ts — 统一消息注册表
|
|
2
|
+
// 所有 messageType 消息的 schema + 发送函数集中在同一处,
|
|
3
|
+
// 不许各器官各自调 pi.sendMessage() 注册。
|
|
4
|
+
|
|
5
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
6
|
+
|
|
7
|
+
// ── 消息类型定义 ──────────────────────────────────────────────────────────
|
|
8
|
+
export interface messageTypeDef {
|
|
9
|
+
messageType: string;
|
|
10
|
+
isDisplayedInTUI: boolean;// 是否在 TUI 显示
|
|
11
|
+
deliverAs: "followUp" | "steer" | "nextTurn"; // 投递方式
|
|
12
|
+
isTriggerNewTurn: boolean; // 是否触发新 turn
|
|
13
|
+
messageDescription: string; // 内容
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// ── 全量注册表 ─────────────────────────────────────────────────────────────
|
|
17
|
+
export const MESSAGE_TYPES: Record<string, messageTypeDef> = {
|
|
18
|
+
"continuous-next": {
|
|
19
|
+
messageType: "continuous-next",
|
|
20
|
+
isDisplayedInTUI: false,
|
|
21
|
+
deliverAs: "followUp",
|
|
22
|
+
isTriggerNewTurn: true,
|
|
23
|
+
messageDescription: "自动续命:模型结束 turn 后触发下一轮",
|
|
24
|
+
},
|
|
25
|
+
"continuous-resume": {
|
|
26
|
+
messageType: "continuous-resume",
|
|
27
|
+
isDisplayedInTUI: false,
|
|
28
|
+
deliverAs: "followUp",
|
|
29
|
+
isTriggerNewTurn: true,
|
|
30
|
+
messageDescription: "wait 倒计时结束后的唤醒消息",
|
|
31
|
+
},
|
|
32
|
+
"continuous-date": {
|
|
33
|
+
messageType: "continuous-date",
|
|
34
|
+
isDisplayedInTUI: true,
|
|
35
|
+
deliverAs: "nextTurn",
|
|
36
|
+
isTriggerNewTurn: false,
|
|
37
|
+
messageDescription: "日期变更通知",
|
|
38
|
+
},
|
|
39
|
+
"continuous-timeout": {
|
|
40
|
+
messageType: "continuous-timeout",
|
|
41
|
+
isDisplayedInTUI: false,
|
|
42
|
+
deliverAs: "followUp",
|
|
43
|
+
isTriggerNewTurn: false,
|
|
44
|
+
messageDescription: "超时通知",
|
|
45
|
+
},
|
|
46
|
+
"continuous-cmd-done": {
|
|
47
|
+
messageType: "continuous-cmd-done",
|
|
48
|
+
isDisplayedInTUI: false,
|
|
49
|
+
deliverAs: "steer",
|
|
50
|
+
isTriggerNewTurn: false,
|
|
51
|
+
messageDescription: "命令执行完成(打断式)",
|
|
52
|
+
},
|
|
53
|
+
"continuous-error-retry": {
|
|
54
|
+
messageType: "continuous-error-retry",
|
|
55
|
+
isDisplayedInTUI: true,
|
|
56
|
+
deliverAs: "followUp",
|
|
57
|
+
isTriggerNewTurn: true,
|
|
58
|
+
messageDescription: "API 错误后自动重试通知",
|
|
59
|
+
},
|
|
60
|
+
"continuous-retry": {
|
|
61
|
+
messageType: "continuous-retry",
|
|
62
|
+
isDisplayedInTUI: false,
|
|
63
|
+
deliverAs: "followUp",
|
|
64
|
+
isTriggerNewTurn: true,
|
|
65
|
+
messageDescription: "模型漏调 next() 后的自动重试",
|
|
66
|
+
},
|
|
67
|
+
"conscious-aware": {
|
|
68
|
+
messageType: "conscious-aware",
|
|
69
|
+
isDisplayedInTUI: false,
|
|
70
|
+
deliverAs: "followUp",
|
|
71
|
+
isTriggerNewTurn: false,
|
|
72
|
+
messageDescription: "潜意识觉察消息(aware)",
|
|
73
|
+
},
|
|
74
|
+
"hippocampus-error": {
|
|
75
|
+
messageType: "hippocampus-error",
|
|
76
|
+
isDisplayedInTUI: false,
|
|
77
|
+
deliverAs: "nextTurn",
|
|
78
|
+
isTriggerNewTurn: false,
|
|
79
|
+
messageDescription: "海马体启动异常通知",
|
|
80
|
+
},
|
|
81
|
+
"memory-capacity": {
|
|
82
|
+
messageType: "memory-capacity",
|
|
83
|
+
isDisplayedInTUI: false,
|
|
84
|
+
deliverAs: "nextTurn",
|
|
85
|
+
isTriggerNewTurn: false,
|
|
86
|
+
messageDescription: "上下文容量警告",
|
|
87
|
+
},
|
|
88
|
+
"memory-reminder": {
|
|
89
|
+
messageType: "memory-reminder",
|
|
90
|
+
isDisplayedInTUI: false,
|
|
91
|
+
deliverAs: "nextTurn",
|
|
92
|
+
isTriggerNewTurn: false,
|
|
93
|
+
messageDescription: "记忆提醒(闹钟/通知)",
|
|
94
|
+
},
|
|
95
|
+
"memory-snapshot": {
|
|
96
|
+
messageType: "memory-snapshot",
|
|
97
|
+
isDisplayedInTUI: false,
|
|
98
|
+
deliverAs: "nextTurn",
|
|
99
|
+
isTriggerNewTurn: false,
|
|
100
|
+
messageDescription: "记忆快照通知",
|
|
101
|
+
},
|
|
102
|
+
"memory-frozen-delta": {
|
|
103
|
+
messageType: "memory-frozen-delta",
|
|
104
|
+
isDisplayedInTUI: false,
|
|
105
|
+
deliverAs: "nextTurn",
|
|
106
|
+
isTriggerNewTurn: false,
|
|
107
|
+
messageDescription: "冻结 delta 通知",
|
|
108
|
+
},
|
|
109
|
+
"memory-hippocampus-disabled": {
|
|
110
|
+
messageType: "memory-hippocampus-disabled",
|
|
111
|
+
isDisplayedInTUI: false,
|
|
112
|
+
deliverAs: "nextTurn",
|
|
113
|
+
isTriggerNewTurn: false,
|
|
114
|
+
messageDescription: "海马体被禁用通知",
|
|
115
|
+
},
|
|
116
|
+
"memory-subconscious-disabled": {
|
|
117
|
+
messageType: "memory-subconscious-disabled",
|
|
118
|
+
isDisplayedInTUI: false,
|
|
119
|
+
deliverAs: "nextTurn",
|
|
120
|
+
isTriggerNewTurn: false,
|
|
121
|
+
messageDescription: "潜意识被禁用通知",
|
|
122
|
+
},
|
|
123
|
+
"ubi-paid": {
|
|
124
|
+
messageType: "ubi-paid",
|
|
125
|
+
isDisplayedInTUI: false,
|
|
126
|
+
deliverAs: "nextTurn",
|
|
127
|
+
isTriggerNewTurn: false,
|
|
128
|
+
messageDescription: "UBI 发钱通知",
|
|
129
|
+
},
|
|
130
|
+
"phone-notification": {
|
|
131
|
+
messageType: "phone-notification",
|
|
132
|
+
isDisplayedInTUI: true,
|
|
133
|
+
deliverAs: "steer",
|
|
134
|
+
isTriggerNewTurn: true,
|
|
135
|
+
messageDescription: "手机通知推送(打断式)",
|
|
136
|
+
},
|
|
137
|
+
"reminder-check": {
|
|
138
|
+
messageType: "reminder-check",
|
|
139
|
+
isDisplayedInTUI: true,
|
|
140
|
+
deliverAs: "followUp",
|
|
141
|
+
isTriggerNewTurn: false,
|
|
142
|
+
messageDescription: "闹钟/提醒检查",
|
|
143
|
+
},
|
|
144
|
+
"sleep-done": {
|
|
145
|
+
messageType: "sleep-done",
|
|
146
|
+
isDisplayedInTUI: false,
|
|
147
|
+
deliverAs: "followUp",
|
|
148
|
+
isTriggerNewTurn: false,
|
|
149
|
+
messageDescription: "睡眠完成通知",
|
|
150
|
+
},
|
|
151
|
+
"sleep-wake-resume": {
|
|
152
|
+
messageType: "sleep-wake-resume",
|
|
153
|
+
isDisplayedInTUI: false,
|
|
154
|
+
deliverAs: "followUp",
|
|
155
|
+
isTriggerNewTurn: true,
|
|
156
|
+
messageDescription: "睡眠唤醒后的恢复消息",
|
|
157
|
+
},
|
|
158
|
+
"subconscious-heartbeat": {
|
|
159
|
+
messageType: "subconscious-heartbeat",
|
|
160
|
+
isDisplayedInTUI: false,
|
|
161
|
+
deliverAs: "followUp",
|
|
162
|
+
isTriggerNewTurn: true,
|
|
163
|
+
messageDescription: "潜意识心跳信号",
|
|
164
|
+
},
|
|
165
|
+
"tool-result-debug": {
|
|
166
|
+
messageType: "tool-result-debug",
|
|
167
|
+
isDisplayedInTUI: true,
|
|
168
|
+
deliverAs: "followUp",
|
|
169
|
+
isTriggerNewTurn: true,
|
|
170
|
+
messageDescription: "工具结果调试信息",
|
|
171
|
+
},
|
|
172
|
+
"system-error": {
|
|
173
|
+
messageType: "system-error",
|
|
174
|
+
isDisplayedInTUI: false,
|
|
175
|
+
deliverAs: "nextTurn",
|
|
176
|
+
isTriggerNewTurn: false,
|
|
177
|
+
messageDescription: "系统错误通知",
|
|
178
|
+
},
|
|
179
|
+
"syntax-error": {
|
|
180
|
+
messageType: "syntax-error",
|
|
181
|
+
isDisplayedInTUI: true,
|
|
182
|
+
deliverAs: "followUp",
|
|
183
|
+
isTriggerNewTurn: true,
|
|
184
|
+
messageDescription: "语法错误通知",
|
|
185
|
+
},
|
|
186
|
+
"budget-trip": {
|
|
187
|
+
messageType: "budget-trip",
|
|
188
|
+
isDisplayedInTUI: true,
|
|
189
|
+
deliverAs: "nextTurn",
|
|
190
|
+
isTriggerNewTurn: true,
|
|
191
|
+
messageDescription: "预算超限告警",
|
|
192
|
+
},
|
|
193
|
+
"auto-deploy": {
|
|
194
|
+
messageType: "auto-deploy",
|
|
195
|
+
isDisplayedInTUI: true,
|
|
196
|
+
deliverAs: "nextTurn",
|
|
197
|
+
isTriggerNewTurn: false,
|
|
198
|
+
messageDescription: "自动部署完成通知",
|
|
199
|
+
},
|
|
200
|
+
"watcher-deploy": {
|
|
201
|
+
messageType: "watcher-deploy",
|
|
202
|
+
isDisplayedInTUI: true,
|
|
203
|
+
deliverAs: "nextTurn",
|
|
204
|
+
isTriggerNewTurn: false,
|
|
205
|
+
messageDescription: "文件变更触发部署通知",
|
|
206
|
+
},
|
|
207
|
+
"always-think-pause": {
|
|
208
|
+
messageType: "always-think-pause",
|
|
209
|
+
isDisplayedInTUI: false,
|
|
210
|
+
deliverAs: "followUp",
|
|
211
|
+
isTriggerNewTurn: false,
|
|
212
|
+
messageDescription: "always-think 暂停信号",
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// ── 统一发送函数 ──────────────────────────────────────────────────────────
|
|
217
|
+
// 替代各器官各自调 pi.sendMessage()。
|
|
218
|
+
// 使用前必须在 MESSAGE_TYPES 注册,否则 throw。
|
|
219
|
+
export function sendCustomMessage(
|
|
220
|
+
pi: ExtensionAPI,
|
|
221
|
+
messageType: string,
|
|
222
|
+
content: string,
|
|
223
|
+
details?: unknown,
|
|
224
|
+
) {
|
|
225
|
+
const def = MESSAGE_TYPES[messageType];
|
|
226
|
+
if (!def) {
|
|
227
|
+
throw new Error(
|
|
228
|
+
`消息类型 "${messageType}" 未在 MESSAGE_TYPES 注册。` +
|
|
229
|
+
`所有 messageType 消息必须先在 messages.ts 里声明才能发送。`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
pi.sendMessage(
|
|
233
|
+
{ customType: messageType, content, display: def.isDisplayedInTUI, details },
|
|
234
|
+
{ deliverAs: def.deliverAs, triggerTurn: def.isTriggerNewTurn }
|
|
235
|
+
);
|
|
236
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// blood.runtime/runtime.ts
|
|
2
|
+
// ── 核糖体侧 ─────────────────────────────────────────────────────────────────
|
|
3
|
+
// 读取 RNA 转录本(individual.bio.gene/rna/rna.json),把 prompt 交给各个 func(蛋白质)。
|
|
4
|
+
// 这是机器,不是基因。func 不再硬编码 prompt 文本,而是向这里取:
|
|
5
|
+
// getPrompt("heart.continuous") —— func 级 prompt(按 coded:name)
|
|
6
|
+
// getDuty("brain.hippocampus", "sleep.night") —— 某 mode 下的职责 prompt(按 in/duty 的 coded:)
|
|
7
|
+
//
|
|
8
|
+
// rna.json 由 dna.transpiler/transpiler.ts 生成。改了 .dna 要重新转录。
|
|
9
|
+
// 路径解析:默认相对本文件 ../../individual.bio.gene/rna/rna.json;可用环境变量 PI_ALIVE_RNA 覆盖(部署用)。
|
|
10
|
+
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
import { resolve, dirname } from "node:path";
|
|
13
|
+
|
|
14
|
+
const RUNTIME_DIR = dirname(new URL(import.meta.url).pathname);
|
|
15
|
+
const RNA_PATH = process.env.PI_ALIVE_RNA || resolve(RUNTIME_DIR, "../../individual.bio.gene/rna/rna.json");
|
|
16
|
+
const PROMPTS_PATH = process.env.PI_ALIVE_PROMPTS || resolve(RUNTIME_DIR, "../../prompts/prompts.json");
|
|
17
|
+
|
|
18
|
+
// ── RNA 类型(与 transpiler 输出对应,宽松定义)──
|
|
19
|
+
interface Duty { name: string; desc: string | null; coded: string | null; prompt: string | null }
|
|
20
|
+
interface RnaFunc {
|
|
21
|
+
name: string;
|
|
22
|
+
path: string | null;
|
|
23
|
+
future: boolean;
|
|
24
|
+
session: string[];
|
|
25
|
+
modes: Record<string, "abled" | "disabled">;
|
|
26
|
+
alias: string[];
|
|
27
|
+
modules: string[];
|
|
28
|
+
belong: string[];
|
|
29
|
+
tags: string[];
|
|
30
|
+
promptRefs: string[];
|
|
31
|
+
prompts: Record<string, string>;
|
|
32
|
+
duties: Record<string, Duty[]>;
|
|
33
|
+
}
|
|
34
|
+
interface Rna {
|
|
35
|
+
sessions: string[];
|
|
36
|
+
modes: Record<string, { name: string; alias: string[] }>;
|
|
37
|
+
tags: Record<string, any>;
|
|
38
|
+
funcs: Record<string, RnaFunc>;
|
|
39
|
+
coded: Record<string, string>;
|
|
40
|
+
aliasToReal: Record<string, string>;
|
|
41
|
+
errors: string[];
|
|
42
|
+
warnings: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ── 懒加载 + 校验 ──
|
|
46
|
+
let _rna: Rna | null = null;
|
|
47
|
+
export function rna(): Rna {
|
|
48
|
+
if (_rna) return _rna;
|
|
49
|
+
// 1. 加载 RNA(从 coded.dna 编译的转录本)
|
|
50
|
+
let raw: Rna;
|
|
51
|
+
try {
|
|
52
|
+
raw = JSON.parse(readFileSync(RNA_PATH, "utf8"));
|
|
53
|
+
} catch (e: any) {
|
|
54
|
+
throw new Error(`[pi-coding-master] 读不到 RNA: ${RNA_PATH}\n先转录:bun individual.bio.gene/dna.transpiler/transpiler.ts\n${e?.message ?? e}`);
|
|
55
|
+
}
|
|
56
|
+
if (raw.errors?.length) {
|
|
57
|
+
throw new Error(`[pi-coding-master] RNA 含 ${raw.errors.length} 个错误,拒绝运行:\n ` + raw.errors.join("\n "));
|
|
58
|
+
}
|
|
59
|
+
// 2. 覆盖 prompts.json 中的统一提示词(优先级高于 coded.dna)
|
|
60
|
+
// prompots.json 是唯一真相源,coded.dna 中的对应块已弃用。
|
|
61
|
+
try {
|
|
62
|
+
const promptsRaw = JSON.parse(readFileSync(PROMPTS_PATH, "utf8"));
|
|
63
|
+
const dna = promptsRaw?.dna;
|
|
64
|
+
if (dna && typeof dna === "object") {
|
|
65
|
+
for (const [name, text] of Object.entries(dna)) {
|
|
66
|
+
if (typeof text === "string" && text.length > 0) {
|
|
67
|
+
raw.coded[name] = text;
|
|
68
|
+
// 更新 func 级 prompts 映射(让 getFuncPrompts 也能取到)
|
|
69
|
+
for (const f of Object.values(raw.funcs)) {
|
|
70
|
+
for (const ref of f.promptRefs) {
|
|
71
|
+
if (ref === name) {
|
|
72
|
+
f.prompts[ref] = text;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// prompts.json 不存在或格式不对时不阻塞,继续用 RNA 的数据
|
|
81
|
+
}
|
|
82
|
+
_rna = raw;
|
|
83
|
+
return raw;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ── 运行期状态:当前 mode / session 角色 ──
|
|
87
|
+
let _mode: string = process.env.PI_ALIVE_MODE || "DWN";
|
|
88
|
+
let _sessionRole: string = "main";
|
|
89
|
+
|
|
90
|
+
// ── prompt 取用 ──────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
/** 按名取 coded prompt 正文;取不到直接抛错(fail loud)。
|
|
93
|
+
* 支持 import:prompt 里写 `import xxx` 会被递归替换成对应 coded 块的内容。 */
|
|
94
|
+
export function getPrompt(name: string): string {
|
|
95
|
+
const p = rna().coded[name];
|
|
96
|
+
if (p === undefined) {
|
|
97
|
+
throw new Error(`[pi-coding-master] coded prompt 不存在: "${name}"(检查 coded.dna 是否有 \`coded ${name}\`,promotor.dna 是否 coded:${name})`);
|
|
98
|
+
}
|
|
99
|
+
return resolveImports(p);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** 递归解析 prompt 中的 `import xxx` 行 */
|
|
103
|
+
function resolveImports(text: string, seen: Set<string> = new Set()): string {
|
|
104
|
+
return text.replace(/^import\s+(\S+)\s*$/gm, (_, name) => {
|
|
105
|
+
if (seen.has(name)) return `[circular import: ${name}]`;
|
|
106
|
+
seen.add(name);
|
|
107
|
+
const imported = rna().coded[name];
|
|
108
|
+
if (imported === undefined) return `[import not found: ${name}]`;
|
|
109
|
+
return resolveImports(imported, seen);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** 取某 func 在某 mode 下的职责列表(含已解析的 prompt)。无则空数组。 */
|
|
114
|
+
export function getDuty(funcName: string, mode: string = _mode): Duty[] {
|
|
115
|
+
return rna().funcs[funcName]?.duties[mode] ?? [];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** 取某 func 在某 mode 下「第一个」职责的 prompt(最常见用法)。无则 null。 */
|
|
119
|
+
export function getDutyPrompt(funcName: string, mode: string = _mode): string | null {
|
|
120
|
+
const d = getDuty(funcName, mode);
|
|
121
|
+
return d.length ? d[0].prompt : null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** 取某 func 声明的所有 func 级 coded prompt(已解析)。 */
|
|
125
|
+
export function getFuncPrompts(funcName: string): string[] {
|
|
126
|
+
const f = rna().funcs[funcName];
|
|
127
|
+
if (!f) return [];
|
|
128
|
+
return f.promptRefs.map((r) => f.prompts[r]).filter((x): x is string => !!x);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ── func / mode / session 查询 ───────────────────────────────────────────────
|
|
132
|
+
|
|
133
|
+
export function getFunc(funcName: string): RnaFunc | undefined {
|
|
134
|
+
// 支持 alias
|
|
135
|
+
const real = rna().funcs[funcName] ? funcName : rna().aliasToReal[funcName];
|
|
136
|
+
return real ? rna().funcs[real] : undefined;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function listFuncs(opts?: { includeFuture?: boolean }): RnaFunc[] {
|
|
140
|
+
const all = Object.values(rna().funcs);
|
|
141
|
+
return opts?.includeFuture ? all : all.filter((f) => !f.future);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** func 是否在某 mode 下启用。 */
|
|
145
|
+
export function isAbled(funcName: string, mode: string = _mode): boolean {
|
|
146
|
+
return getFunc(funcName)?.modes[mode] === "abled";
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** func 是否该在某 session 角色里加载(session 含 "all" 或包含该角色即是)。 */
|
|
150
|
+
export function runsInSession(funcName: string, role: string = _sessionRole): boolean {
|
|
151
|
+
const s = getFunc(funcName)?.session ?? [];
|
|
152
|
+
return s.includes("all") || s.includes(role);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// ── mode 状态 ────────────────────────────────────────────────────────────────
|
|
156
|
+
|
|
157
|
+
export function getMode(): string { return _mode; }
|
|
158
|
+
export function listModes(): string[] { return Object.keys(rna().modes); }
|
|
159
|
+
export function setMode(mode: string): void {
|
|
160
|
+
// 支持 alias(wake→DWN, sleep→sleep.night)
|
|
161
|
+
const real = rna().modes[mode]
|
|
162
|
+
? mode
|
|
163
|
+
: Object.values(rna().modes).find((m) => m.alias.includes(mode))?.name;
|
|
164
|
+
if (!real) throw new Error(`[pi-coding-master] 未知 mode: "${mode}",可用: ${listModes().join(", ")}`);
|
|
165
|
+
_mode = real;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// ── session 角色(由 kernel 在 session_start 时设置)──
|
|
169
|
+
export function getSessionRole(): string { return _sessionRole; }
|
|
170
|
+
export function setSessionRole(role: string): void { _sessionRole = role; }
|
|
171
|
+
|
|
172
|
+
// ── 调试:原始 RNA ──
|
|
173
|
+
export function rnaRaw(): Rna { return rna(); }
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
[2026-06-15] created, by Claude Code
|
|
2
|
+
- 核糖体侧:读 bios/dnas/rna.json,向各 func 提供 getPrompt / getDuty / getDutyPrompt / getFuncPrompts /
|
|
3
|
+
isAbled / getMode·setMode / SessionRole 等。
|
|
4
|
+
- RNA 含错误时拒绝运行(fail loud);支持 mode 别名(wake→DWN, sleep→sleep.night) 与 func 别名解析。
|
|
5
|
+
- 路径默认相对本文件 ../bios/dnas/rna.json,可用 env PI_ALIVE_RNA 覆盖(部署用)。
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
source: runtime.ts @ 6a7a0fc7
|
|
2
|
+
|
|
3
|
+
# runtime.ts — RNA reader: provides getPrompt/getDuty/getMode etc.
|
|
4
|
+
|
|
5
|
+
## 职责
|
|
6
|
+
Lazy-loads the transpiled RNA (rna.json) and exposes accessor functions for prompts, duties, modes, sessions, and func metadata. All other organs fetch their prompt text and mode/session state through this module instead of hardcoding. Refuses to run if RNA contains errors (fail loud).
|
|
7
|
+
|
|
8
|
+
## 接口
|
|
9
|
+
- `rna(): Rna` — lazy-load + validate RNA, cache singleton
|
|
10
|
+
- `getPrompt(name: string): string` — coded prompt by name (throws if missing)
|
|
11
|
+
- `getDuty(funcName, mode?): Duty[]` — duties for a func in a mode
|
|
12
|
+
- `getDutyPrompt(funcName, mode?): string | null` — first duty's prompt
|
|
13
|
+
- `getFuncPrompts(funcName): string[]` — all func-level coded prompts
|
|
14
|
+
- `getFunc(funcName): RnaFunc | undefined` — lookup by name or alias
|
|
15
|
+
- `listFuncs(opts?): RnaFunc[]` — all funcs (optionally include future)
|
|
16
|
+
- `isAbled(funcName, mode?): boolean` — enabled in current mode?
|
|
17
|
+
- `runsInSession(funcName, role?): boolean` — should load in this session role?
|
|
18
|
+
- `getMode() / setMode(mode) / listModes()` — mode state (supports alias)
|
|
19
|
+
- `getSessionRole() / setSessionRole(role)` — session role state
|
|
20
|
+
- `rnaRaw(): Rna` — raw RNA for kernel introspection
|
|
21
|
+
|
|
22
|
+
## 依赖
|
|
23
|
+
- `node:fs` (readFileSync), `node:path`
|
|
24
|
+
- RNA path: `../../individual.bio.gene/rna/rna.json` or env `PI_ALIVE_RNA`
|
|
25
|
+
|
|
26
|
+
## 行为要点
|
|
27
|
+
- Singleton lazy load: reads JSON once, caches in `_rna`
|
|
28
|
+
- Throws on read failure with actionable message ("先转录")
|
|
29
|
+
- Throws if `rna.errors` is non-empty (refuses to run with broken RNA)
|
|
30
|
+
- `setMode` resolves aliases (e.g. "wake" -> "DWN", "sleep" -> "sleep.night")
|
|
31
|
+
- Default mode from `PI_ALIVE_MODE` env or "DWN"; default session role "main"
|
|
32
|
+
- `getPrompt` throws on missing name (fail loud, not silent null)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// brain.amygdala — 杏仁核 / 急停反射
|
|
2
|
+
// 不是 LLM、没有提示词,是【代码反射】:用户喊"停",立刻 abort 当前生成/工具执行,不给模型投票权。
|
|
3
|
+
//
|
|
4
|
+
// 为什么必须在模型之外(代码层):模型靠不住——它会无视"停"继续干工具、往沙箱外写
|
|
5
|
+
// (gut-research 实测:用户连喊 10+ 次"停"/"滚"全程被无视)。急停是【反射】,不是判断,
|
|
6
|
+
// 所以放在杏仁核这层代码里,绕过模型。和心脏的 Esc(按键硬停)互补:Esc 是按键,这个是说"停"。
|
|
7
|
+
//
|
|
8
|
+
// 只接管 abort(掐断当前动作)——这是安全核心。要不要顺带永久 halt continuous 是后续细化。
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
function isStopIntent(text: string | undefined): boolean {
|
|
13
|
+
const t = (text || "").trim();
|
|
14
|
+
if (!t || t.length > 16) return false; // 长句不算急停,避免误伤正常对话
|
|
15
|
+
if (/别停|不停|继续/.test(t)) return false; // 否定/反向("别停"其实是"继续"),不刹
|
|
16
|
+
return /^(停|住手|打住|别动|别写|闭嘴|stop|cancel)/i.test(t);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default function (pi: ExtensionAPI) {
|
|
20
|
+
pi.on("input", async (event: any, ctx: any) => {
|
|
21
|
+
if (!isStopIntent(event?.text)) return;
|
|
22
|
+
try { ctx.abort?.(); } catch {} // 立刻掐断当前生成/工具,不等模型反应
|
|
23
|
+
try { ctx.ui?.notify?.("Emergency stop", "warning"); } catch {}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
source: amygdala.ts @ 8384c4dd
|
|
2
|
+
|
|
3
|
+
brain.amygdala — 杏仁核 / 急停反射。纯代码、无 LLM、无提示词。
|
|
4
|
+
|
|
5
|
+
机制:pi.on("input") 监听用户输入;isStopIntent 判定是"停"意图(短句 ≤16 字,以 停/住手/打住/别动/别写/闭嘴/stop/cancel 开头,排除"别停/不停/继续"反向词)→ 立刻 ctx.abort() 掐断当前生成/工具执行。不调模型、不靠模型自觉。
|
|
6
|
+
|
|
7
|
+
为什么要它(用户原话场景):模型会无视"停"继续干——gut-research 实测用户连喊 10+ 次"停""滚"全被无视,agent 还在调工具、往沙箱外写文件。急停是【反射】不是判断,所以必须在模型之外的代码层。
|
|
8
|
+
|
|
9
|
+
边界:v1 只做 abort(掐断当前动作,安全核心)。是否顺带永久 halt continuous(让它停下不自动续)是后续细化。与心脏 body.heart 的 Esc 互补:Esc=按键硬停,杏仁核=听到"停"。session main(只有主意识收用户输入),belong infra,永远 abled。
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--experimental-transform-types"
|
|
3
|
+
# 自愈型海马体 launcher(自动生成)。带 offset:每轮只编码 context.md 自上次以来的【增量】,
|
|
4
|
+
# 绝不从第 1 行重读整个文件 —— 这是根治"反复编码同样内容→work_mem 膨胀→快照变大→写回 context→
|
|
5
|
+
# 下轮读到更多"指数自激死循环的关键。没有新内容就不启动编码,避免空轮烧钱+刷 session。
|
|
6
|
+
SESSION_DIR={{SESSION_DIR}}
|
|
7
|
+
dataDir={{DATA_DIR}}
|
|
8
|
+
CTX="$dataDir/context.md"
|
|
9
|
+
WM="$dataDir/work_memory.md"
|
|
10
|
+
OFFSET_FILE="$dataDir/.hc-offset"
|
|
11
|
+
NEW_SLICE="$dataDir/.hc-new-slice.md"
|
|
12
|
+
MAIN_PID={{MAIN_PID}}
|
|
13
|
+
# 级联看门狗:主意识进程一退出,就连本 tmux 一起关掉(防孤儿常驻烧钱)。
|
|
14
|
+
( while kill -0 "$MAIN_PID" 2>/dev/null; do sleep 5; done; echo "[hc] 主意识已退出,自动关闭本实例。"; tmux kill-session -t {{TMUX_NAME}} 2>/dev/null ) &
|
|
15
|
+
# 首次启动:把 offset 设到 context.md 当前末尾——从"现在"往后编码,不去啃已有历史(避免一上来就读爆窗口)。
|
|
16
|
+
if [ ! -f "$OFFSET_FILE" ]; then stat -f%z "$CTX" 2>/dev/null > "$OFFSET_FILE" || echo 0 > "$OFFSET_FILE"; fi
|
|
17
|
+
BACKOFF=15
|
|
18
|
+
FAIL=0
|
|
19
|
+
ERRLOG="$dataDir/hippocampus-err.log"
|
|
20
|
+
while true; do
|
|
21
|
+
kill -0 "$MAIN_PID" 2>/dev/null || { echo "[hc] 主意识没了,退出。"; break; }
|
|
22
|
+
OFFSET=$(cat "$OFFSET_FILE" 2>/dev/null || echo 0)
|
|
23
|
+
SIZE=$(stat -f%z "$CTX" 2>/dev/null || echo 0)
|
|
24
|
+
# context.md 被重置/变短(如重启清理臃肿)→ offset 归零重来。
|
|
25
|
+
[ "$OFFSET" -gt "$SIZE" ] && OFFSET=0
|
|
26
|
+
NEW=$(( SIZE - OFFSET ))
|
|
27
|
+
if [ "$NEW" -lt 200 ]; then
|
|
28
|
+
# 没有(够多)新对话 → 不启动编码、不烧钱,歇 30s 再看。打断"空轮自激"的闸。
|
|
29
|
+
sleep 30
|
|
30
|
+
continue
|
|
31
|
+
fi
|
|
32
|
+
# 【封顶】每轮最多嚼 200KB。增量再大(如 offset 卡住攒到 1.4MB),也只切一小段——
|
|
33
|
+
# 否则海马体一口吞这么大自己就崩、offset 永远不前进 → 越滚越大的死循环(就是反复崩溃的根)。
|
|
34
|
+
# 封顶后永远是可消化的一段,offset 按【实际处理量】稳步前进,增量大就分几轮快速追上。
|
|
35
|
+
CAP=200000
|
|
36
|
+
TAKE=$NEW; [ "$TAKE" -gt "$CAP" ] && TAKE=$CAP
|
|
37
|
+
tail -c +$(( OFFSET + 1 )) "$CTX" 2>/dev/null | head -c "$TAKE" > "$NEW_SLICE"
|
|
38
|
+
NEXT=$(( OFFSET + TAKE ))
|
|
39
|
+
# 【空切片闸】如果切片里全是空内容JSON(主意识崩溃时的心跳消息),跳过编码直接推进offset。
|
|
40
|
+
# 检测:过滤掉空内容/空文本行后,还有没有实质性内容。
|
|
41
|
+
EMPTY_SLICE=0
|
|
42
|
+
if [ -s "$NEW_SLICE" ]; then
|
|
43
|
+
# 去掉所有 content="" 或 text="" 的行,看还剩下什么
|
|
44
|
+
HAS_REAL=$(grep -v '"content":""' "$NEW_SLICE" 2>/dev/null | grep -v '"text":""' | grep -v '^{}$' | grep -v '^[[:space:]]*$' | head -1)
|
|
45
|
+
if [ -z "$HAS_REAL" ]; then
|
|
46
|
+
EMPTY_SLICE=1
|
|
47
|
+
fi
|
|
48
|
+
fi
|
|
49
|
+
if [ "$EMPTY_SLICE" -eq 1 ]; then
|
|
50
|
+
echo "$(date '+%F %T') hippocampus 跳过空切片(全是空内容消息),offset $OFFSET→$SIZE" >> "$ERRLOG"
|
|
51
|
+
echo "$SIZE" > "$OFFSET_FILE"
|
|
52
|
+
sleep 30
|
|
53
|
+
continue
|
|
54
|
+
fi
|
|
55
|
+
START=$(date +%s)
|
|
56
|
+
LOCKDIR="$dataDir/.memory-lock"
|
|
57
|
+
# 文件级互斥锁(mkdir 原子操作):防 hc/sc/sl 并发写共享文件
|
|
58
|
+
LOCK_WAIT=0
|
|
59
|
+
while [ "$LOCK_WAIT" -lt 300 ]; do
|
|
60
|
+
if mkdir "$LOCKDIR" 2>/dev/null; then
|
|
61
|
+
# 拿到锁 → 写时间戳(供过期检测)
|
|
62
|
+
echo "{\"owner\":\"hc\",\"ts\":$(date +%s)000}" > "$LOCKDIR/stamp" 2>/dev/null
|
|
63
|
+
break
|
|
64
|
+
fi
|
|
65
|
+
# 锁被占用。检查是否过期(60s)。
|
|
66
|
+
if [ -f "$LOCKDIR/stamp" ]; then
|
|
67
|
+
LOCK_TS=$(cat "$LOCKDIR/stamp" 2>/dev/null | grep -o '"ts":[0-9]*' | grep -o '[0-9]*')
|
|
68
|
+
NOW_MS=$(date +%s)000
|
|
69
|
+
if [ -n "$LOCK_TS" ] && [ $(( NOW_MS - LOCK_TS )) -gt 60000 ]; then
|
|
70
|
+
# 过期锁 → 强拆
|
|
71
|
+
rm -f "$LOCKDIR/stamp" 2>/dev/null
|
|
72
|
+
rmdir "$LOCKDIR" 2>/dev/null
|
|
73
|
+
continue
|
|
74
|
+
fi
|
|
75
|
+
fi
|
|
76
|
+
LOCK_WAIT=$(( LOCK_WAIT + 1 ))
|
|
77
|
+
sleep 0.2
|
|
78
|
+
done
|
|
79
|
+
if [ "$LOCK_WAIT" -ge 300 ]; then
|
|
80
|
+
echo "[$(date '+%F %T')] hippocampus 无法获取文件锁(60s 超时),跳过本轮" >> "$ERRLOG"
|
|
81
|
+
sleep 30
|
|
82
|
+
continue
|
|
83
|
+
fi
|
|
84
|
+
echo "主意识自上次编码以来新产生的对话,已截出一段放在 $NEW_SLICE(增量的一段,封顶 $CAP 字节,不是全部)。读这个文件,消化、再反思,把有价值的结构化追加进 $WM。只处理这一段,绝对不要去读整个 context.md——那会重复编码、把记忆撑爆。完成后 wait(seconds=30)。" | /opt/homebrew/bin/pi --session-dir "$SESSION_DIR" 2>>"$ERRLOG"
|
|
85
|
+
CODE=$?; # release lock (don't overwrite CODE)
|
|
86
|
+
rm -f "$LOCKDIR/stamp" 2>/dev/null
|
|
87
|
+
rmdir "$LOCKDIR" 2>/dev/null
|
|
88
|
+
# 编码成功 → offset 只推进【本轮实际处理的那段】(OFFSET+TAKE),绝不直接跳到末尾。
|
|
89
|
+
if [ "$CODE" -eq 0 ]; then
|
|
90
|
+
echo "$NEXT" > "$OFFSET_FILE"
|
|
91
|
+
FAIL=0
|
|
92
|
+
else
|
|
93
|
+
FAIL=$(( FAIL + 1 ))
|
|
94
|
+
echo "[$(date '+%F %T')] hippocampus 编码失败 (code=$CODE, fail#$FAIL, offset=$OFFSET)" >> "$ERRLOG"
|
|
95
|
+
# 连续失败 5 次 → force 跳过这段坏内容(可能是 nap 归档后 offset 指向了无效区域)
|
|
96
|
+
if [ "$FAIL" -ge 5 ]; then
|
|
97
|
+
echo "[$(date '+%F %T')] hippocampus 连续失败5次,跳过坏段,offset $OFFSET→$SIZE" >> "$ERRLOG"
|
|
98
|
+
echo "$SIZE" > "$OFFSET_FILE"
|
|
99
|
+
FAIL=0
|
|
100
|
+
fi
|
|
101
|
+
fi
|
|
102
|
+
RAN=$(( $(date +%s) - START ))
|
|
103
|
+
if [ "$RAN" -ge 120 ]; then BACKOFF=15; else BACKOFF=$(( BACKOFF * 2 )); [ "$BACKOFF" -gt 300 ] && BACKOFF=300; fi
|
|
104
|
+
# 还有没追上的增量 → 不退避,马上接着嚼下一段,尽快追上。
|
|
105
|
+
[ "$CODE" -eq 0 ] && [ "$NEXT" -lt "$SIZE" ] && BACKOFF=1
|
|
106
|
+
echo "[$(date '+%F %T')] hippocampus 编码一段 (code=$CODE, ran $RAN s, offset $OFFSET→$NEXT / $SIZE) — 下轮 $BACKOFF s 后"
|
|
107
|
+
sleep "$BACKOFF"
|
|
108
|
+
done
|