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,392 @@
|
|
|
1
|
+
import { basename, dirname, isAbsolute, relative, resolve as resolvePath, sep } from "node:path";
|
|
2
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
3
|
+
import { constants } from "fs";
|
|
4
|
+
import { access as fsAccess, readFile as fsreadFile } from "fs/promises";
|
|
5
|
+
import { Type } from "typebox";
|
|
6
|
+
import { getReadmePath } from "../../config.js";
|
|
7
|
+
import { keyHint, keyText } from "../../modes/interactive/components/keybinding-hints.js";
|
|
8
|
+
import { getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.js";
|
|
9
|
+
import { formatDimensionNote, resizeImage } from "../../utils/image-resize.js";
|
|
10
|
+
import { detectSupportedImageMimeTypeFromFile } from "../../utils/mime.js";
|
|
11
|
+
import { formatPathRelativeToCwdOrAbsolute } from "../../utils/paths.js";
|
|
12
|
+
import { resolveReadPathAsync, resolveToCwd } from "./path-utils.js";
|
|
13
|
+
import { getTextOutput, renderToolPath, replaceTabs, str } from "./render-utils.js";
|
|
14
|
+
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
15
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "./truncate.js";
|
|
16
|
+
import { getToolPrompt, getVisionBridgePrompt } from "./prompts-reader.js";
|
|
17
|
+
const ReadSchema = Type.Object({
|
|
18
|
+
path: Type.String({ messageDescription: "Path to the file to READ (relative or absolute)" }),
|
|
19
|
+
offset: Type.Optional(Type.Number({ messageDescription: "Line number to start READing from (1-indexed)" })),
|
|
20
|
+
limit: Type.Optional(Type.Number({ messageDescription: "Maximum number of lines to READ" })),
|
|
21
|
+
});
|
|
22
|
+
const COMPACT_RESOURCE_FILE_NAMES = new Set(["AGENTS.md", "AGENTS.MD", "CLAUDE.md", "CLAUDE.MD"]);
|
|
23
|
+
const defaultReadOperations = {
|
|
24
|
+
readFile: (path) => fsreadFile(path),
|
|
25
|
+
access: (path) => fsAccess(path, constants.R_OK),
|
|
26
|
+
detectImageMimeType: detectSupportedImageMimeTypeFromFile,
|
|
27
|
+
};
|
|
28
|
+
function formatReadLineRange(args, theme) {
|
|
29
|
+
if (args?.offset === undefined && args?.limit === undefined)
|
|
30
|
+
return "";
|
|
31
|
+
const startLine = args.offset ?? 1;
|
|
32
|
+
const endLine = args.limit !== undefined ? startLine + args.limit - 1 : "";
|
|
33
|
+
return theme.fg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
|
|
34
|
+
}
|
|
35
|
+
function formatReadCall(args, theme, cwd) {
|
|
36
|
+
const pathDisplay = renderToolPath(str(args?.file_path ?? args?.path), theme, cwd);
|
|
37
|
+
return theme.fg("success", "● " + theme.bold("Read")) + " " + pathDisplay + formatReadLineRange(args, theme);
|
|
38
|
+
}
|
|
39
|
+
function trimTrailingEmptyLines(lines) {
|
|
40
|
+
let end = lines.length;
|
|
41
|
+
while (end > 0 && lines[end - 1] === "") {
|
|
42
|
+
end--;
|
|
43
|
+
}
|
|
44
|
+
return lines.slice(0, end);
|
|
45
|
+
}
|
|
46
|
+
// pi-coding-master: 主模型不支持图片时,用 glm-5v-turbo 把图片转成文字描述,让纯文本主意识也能"看图"。
|
|
47
|
+
// 主意识固定 GLM-5.2(纯文本),图片由 GLM-5V-Turbo 转文字后代看。
|
|
48
|
+
const VISION_DESCRIBE_TIMEOUT_MS = 45000;
|
|
49
|
+
let _visionConfigCache = null;
|
|
50
|
+
async function getVisionConfig() {
|
|
51
|
+
if (_visionConfigCache)
|
|
52
|
+
return _visionConfigCache;
|
|
53
|
+
const fs = await import("node:fs");
|
|
54
|
+
const os = await import("node:os");
|
|
55
|
+
const path = await import("node:path");
|
|
56
|
+
const modelsPath = path.join(os.homedir(), ".pi", "agent", "models.json");
|
|
57
|
+
let raw;
|
|
58
|
+
try {
|
|
59
|
+
raw = fs.readFileSync(modelsPath, "utf-8");
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
let cfg;
|
|
65
|
+
try {
|
|
66
|
+
cfg = JSON.parse(raw);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const zhipu = cfg?.providers?.zhipu;
|
|
72
|
+
if (!zhipu?.apiKey || !zhipu?.baseUrl)
|
|
73
|
+
return null;
|
|
74
|
+
const visionModel = (zhipu.models || []).find((m) => Array.isArray(m.input) && m.input.includes("image"));
|
|
75
|
+
if (!visionModel)
|
|
76
|
+
return null;
|
|
77
|
+
_visionConfigCache = {
|
|
78
|
+
baseUrl: zhipu.baseUrl.replace(/\/$/, ""),
|
|
79
|
+
apiKey: zhipu.apiKey,
|
|
80
|
+
modelId: visionModel.id,
|
|
81
|
+
};
|
|
82
|
+
return _visionConfigCache;
|
|
83
|
+
}
|
|
84
|
+
// 用 vision 模型把图片(base64)转成文字描述。失败时返回 null,调用方回退到提示文本。
|
|
85
|
+
async function describeImageWithVision(dataBase64, mimeType) {
|
|
86
|
+
const cfg = await getVisionConfig();
|
|
87
|
+
if (!cfg)
|
|
88
|
+
return null;
|
|
89
|
+
const url = `${cfg.baseUrl}/chat/completions`;
|
|
90
|
+
const body = {
|
|
91
|
+
model: cfg.modelId,
|
|
92
|
+
messages: [
|
|
93
|
+
{
|
|
94
|
+
role: "user",
|
|
95
|
+
content: [
|
|
96
|
+
{ type: "text", text: getVisionBridgePrompt() },
|
|
97
|
+
{ type: "image_url", image_url: { url: `data:${mimeType};base64,${dataBase64}` } },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
max_tokens: 2000,
|
|
102
|
+
};
|
|
103
|
+
const controller = new AbortController();
|
|
104
|
+
const timer = setTimeout(() => controller.abort(), VISION_DESCRIBE_TIMEOUT_MS);
|
|
105
|
+
try {
|
|
106
|
+
const resp = await fetch(url, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: {
|
|
109
|
+
"Content-Type": "application/json",
|
|
110
|
+
Authorization: `Bearer ${cfg.apiKey}`,
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify(body),
|
|
113
|
+
signal: controller.signal,
|
|
114
|
+
});
|
|
115
|
+
if (!resp.ok)
|
|
116
|
+
return null;
|
|
117
|
+
const json = await resp.json();
|
|
118
|
+
const text = json?.choices?.[0]?.message?.content;
|
|
119
|
+
return typeof text === "string" && text.trim().length > 0 ? text.trim() : null;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
clearTimeout(timer);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function needsVisionBridge(model) {
|
|
129
|
+
return !!model && !model.input.includes("image");
|
|
130
|
+
}
|
|
131
|
+
function toPosixPath(filePath) {
|
|
132
|
+
return filePath.split(sep).join("/");
|
|
133
|
+
}
|
|
134
|
+
function getPiDocsClassification(absolutePath) {
|
|
135
|
+
// pi-coding-master: 禁用 docs 特殊分类,统一用 Read。
|
|
136
|
+
// 原逻辑:检测 docs/ README.md examples/ 返回 {kind:"docs",label}
|
|
137
|
+
// 现在:所有文件一视同仁,不做 docs 分类。
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
function getCompactReadClassification(args, cwd) {
|
|
141
|
+
const rawPath = str(args?.file_path ?? args?.path);
|
|
142
|
+
if (!rawPath)
|
|
143
|
+
return undefined;
|
|
144
|
+
const absolutePath = resolveToCwd(rawPath, cwd);
|
|
145
|
+
const fileName = basename(absolutePath);
|
|
146
|
+
if (fileName === "SKILL.md") {
|
|
147
|
+
return { kind: "skill", label: basename(dirname(absolutePath)) || fileName };
|
|
148
|
+
}
|
|
149
|
+
const docsClassification = getPiDocsClassification(absolutePath);
|
|
150
|
+
if (docsClassification)
|
|
151
|
+
return docsClassification;
|
|
152
|
+
if (COMPACT_RESOURCE_FILE_NAMES.has(fileName)) {
|
|
153
|
+
return { kind: "resource", label: formatPathRelativeToCwdOrAbsolute(absolutePath, cwd) };
|
|
154
|
+
}
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
function formatCompactReadCall(classification, args, theme) {
|
|
158
|
+
const expandHint = theme.fg("dim", ` (${keyText("app.tools.expand")} to expand)`);
|
|
159
|
+
if (classification.kind === "skill") {
|
|
160
|
+
return (theme.fg("customMessageLabel", `\x1b[1m[skill]\x1b[22m `) +
|
|
161
|
+
theme.fg("customMessageText", classification.label) +
|
|
162
|
+
formatReadLineRange(args, theme) +
|
|
163
|
+
expandHint);
|
|
164
|
+
}
|
|
165
|
+
return (theme.fg("success", theme.bold(`Read ${classification.kind}`)) +
|
|
166
|
+
" " +
|
|
167
|
+
theme.fg("accent", classification.label) +
|
|
168
|
+
formatReadLineRange(args, theme) +
|
|
169
|
+
expandHint);
|
|
170
|
+
}
|
|
171
|
+
function formatReadResult(args, result, options, theme, showImages, _cwd, isError) {
|
|
172
|
+
if (!options.expanded && !isError) {
|
|
173
|
+
return "";
|
|
174
|
+
}
|
|
175
|
+
const rawPath = str(args?.file_path ?? args?.path);
|
|
176
|
+
const output = getTextOutput(result, showImages);
|
|
177
|
+
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
178
|
+
const renderedLines = lang ? highlightCode(replaceTabs(output), lang) : output.split("\n");
|
|
179
|
+
const lines = trimTrailingEmptyLines(renderedLines);
|
|
180
|
+
const maxLines = options.expanded ? lines.length : 10;
|
|
181
|
+
const displayLines = lines.slice(0, maxLines);
|
|
182
|
+
const remaining = lines.length - maxLines;
|
|
183
|
+
const indent = " ";
|
|
184
|
+
let text = `\n${displayLines.map((line) => indent + (lang ? replaceTabs(line) : theme.fg("toolOutput", replaceTabs(line)))).join("\n")}`;
|
|
185
|
+
if (remaining > 0) {
|
|
186
|
+
text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`;
|
|
187
|
+
}
|
|
188
|
+
const truncation = result.details?.truncation;
|
|
189
|
+
if (truncation?.truncated) {
|
|
190
|
+
if (truncation.firstLineExceedsLimit) {
|
|
191
|
+
text += `\n${theme.fg("warning", `[First line exceeds ${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit]`)}`;
|
|
192
|
+
}
|
|
193
|
+
else if (truncation.truncatedBy === "lines") {
|
|
194
|
+
text += `\n${theme.fg("warning", `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines (${truncation.maxLines ?? DEFAULT_MAX_LINES} line limit)]`)}`;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
text += `\n${theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit)]`)}`;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return text;
|
|
201
|
+
}
|
|
202
|
+
export function createReadToolDefinition(cwd, options) {
|
|
203
|
+
const autoResizeImages = options?.autoResizeImages ?? true;
|
|
204
|
+
const ops = options?.operations ?? defaultReadOperations;
|
|
205
|
+
return {
|
|
206
|
+
name: "read",
|
|
207
|
+
label: "Read",
|
|
208
|
+
messageDescription: (getToolPrompt('read', 'messageDescription') || '').replace('{{DEFAULT_MAX_LINES}}', String(DEFAULT_MAX_LINES)).replace('{{DEFAULT_MAX_BYTES_KB}}', String(DEFAULT_MAX_BYTES / 1024)),
|
|
209
|
+
promptSnippet: getToolPrompt('read', 'snippet'),
|
|
210
|
+
promptGuidelines: getToolPrompt('read', 'guidelines'),
|
|
211
|
+
parameters: ReadSchema,
|
|
212
|
+
async execute(_toolCallId, { path, offset, limit }, signal, _onUpdate, ctx) {
|
|
213
|
+
return new Promise((resolve, reject) => {
|
|
214
|
+
if (signal?.aborted) {
|
|
215
|
+
reject(new Error("Operation aborted"));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
let aborted = false;
|
|
219
|
+
const onAbort = () => {
|
|
220
|
+
aborted = true;
|
|
221
|
+
reject(new Error("Operation aborted"));
|
|
222
|
+
};
|
|
223
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
224
|
+
(async () => {
|
|
225
|
+
try {
|
|
226
|
+
const absolutePath = await resolveReadPathAsync(path, cwd);
|
|
227
|
+
if (aborted)
|
|
228
|
+
return;
|
|
229
|
+
// Check if file exists and is READable.
|
|
230
|
+
await ops.access(absolutePath);
|
|
231
|
+
if (aborted)
|
|
232
|
+
return;
|
|
233
|
+
const mimeType = ops.detectImageMimeType ? await ops.detectImageMimeType(absolutePath) : undefined;
|
|
234
|
+
let content;
|
|
235
|
+
let details;
|
|
236
|
+
const visionBridge = needsVisionBridge(ctx?.model);
|
|
237
|
+
if (mimeType) {
|
|
238
|
+
// READ image as binary.
|
|
239
|
+
const buffer = await ops.readFile(absolutePath);
|
|
240
|
+
// pi-coding-master: 主模型不支持图片时,用 vision 模型把图片转成文字描述。
|
|
241
|
+
// 主意识(如 GLM-5.2 纯文本)始终只收到文字,不切换模型。
|
|
242
|
+
if (visionBridge) {
|
|
243
|
+
// 先 resize 拿到适合发送的 base64,再调 vision 模型转文字。
|
|
244
|
+
let imgData = buffer.toString("base64");
|
|
245
|
+
let imgMime = mimeType;
|
|
246
|
+
let dimensionNote = "";
|
|
247
|
+
if (autoResizeImages) {
|
|
248
|
+
const resized = await resizeImage(buffer, mimeType);
|
|
249
|
+
if (resized) {
|
|
250
|
+
imgData = resized.data;
|
|
251
|
+
imgMime = resized.mimeType;
|
|
252
|
+
dimensionNote = formatDimensionNote(resized) || "";
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (aborted)
|
|
256
|
+
return;
|
|
257
|
+
let desc = null;
|
|
258
|
+
try {
|
|
259
|
+
desc = await describeImageWithVision(imgData, imgMime);
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
desc = null;
|
|
263
|
+
}
|
|
264
|
+
if (aborted)
|
|
265
|
+
return;
|
|
266
|
+
let textNote = `READ image file [${mimeType}]`;
|
|
267
|
+
if (dimensionNote)
|
|
268
|
+
textNote += `\n${dimensionNote}`;
|
|
269
|
+
if (desc) {
|
|
270
|
+
textNote += `\n[Image converted to text by glm-5v-turbo]:\n${desc}`;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
textNote += `\n[Image conversion failed. Current model does not support images. Try different methods.]`;
|
|
274
|
+
}
|
|
275
|
+
content = [{ type: "text", text: textNote }];
|
|
276
|
+
}
|
|
277
|
+
else if (autoResizeImages) {
|
|
278
|
+
// Resize image if needed before sending it back to the model.
|
|
279
|
+
const resized = await resizeImage(buffer, mimeType);
|
|
280
|
+
if (!resized) {
|
|
281
|
+
const textNote = `READ image file [${mimeType}]\n[Image omitted: could not be resized below the inline image size limit.]`;
|
|
282
|
+
content = [{ type: "text", text: textNote }];
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
const dimensionNote = formatDimensionNote(resized);
|
|
286
|
+
let textNote = `READ image file [${resized.mimeType}]`;
|
|
287
|
+
if (dimensionNote)
|
|
288
|
+
textNote += `\n${dimensionNote}`;
|
|
289
|
+
content = [
|
|
290
|
+
{ type: "text", text: textNote },
|
|
291
|
+
{ type: "image", data: resized.data, mimeType: resized.mimeType },
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
const textNote = `READ image file [${mimeType}]`;
|
|
297
|
+
content = [
|
|
298
|
+
{ type: "text", text: textNote },
|
|
299
|
+
{ type: "image", data: buffer.toString("base64"), mimeType },
|
|
300
|
+
];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
// READ text content.
|
|
305
|
+
const buffer = await ops.readFile(absolutePath);
|
|
306
|
+
const textContent = buffer.toString("utf-8");
|
|
307
|
+
const allLines = textContent.split("\n");
|
|
308
|
+
const totalFileLines = allLines.length;
|
|
309
|
+
// Apply offset if specified. Convert from 1-indexed input to 0-indexed array access.
|
|
310
|
+
const startLine = offset ? Math.max(0, offset - 1) : 0;
|
|
311
|
+
const startLineDisplay = startLine + 1;
|
|
312
|
+
// Check if offset is out of bounds.
|
|
313
|
+
if (startLine >= allLines.length) {
|
|
314
|
+
throw new Error(`Offset ${offset} is beyond end of file (${allLines.length} lines total)`);
|
|
315
|
+
}
|
|
316
|
+
let selectedContent;
|
|
317
|
+
let userLimitedLines;
|
|
318
|
+
// If limit is specified by the user, honor it first. Otherwise truncateHead decides.
|
|
319
|
+
if (limit !== undefined) {
|
|
320
|
+
const endLine = Math.min(startLine + limit, allLines.length);
|
|
321
|
+
selectedContent = allLines.slice(startLine, endLine).join("\n");
|
|
322
|
+
userLimitedLines = endLine - startLine;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
selectedContent = allLines.slice(startLine).join("\n");
|
|
326
|
+
}
|
|
327
|
+
// Apply truncation, respecting both line and byte limits.
|
|
328
|
+
const truncation = truncateHead(selectedContent);
|
|
329
|
+
let outputText;
|
|
330
|
+
if (truncation.firstLineExceedsLimit) {
|
|
331
|
+
// First line alone exceeds the byte limit. Point the model at a bash fallback.
|
|
332
|
+
const firstLineSize = formatSize(Buffer.byteLength(allLines[startLine], "utf-8"));
|
|
333
|
+
outputText = `[Line ${startLineDisplay} is ${firstLineSize}, exceeds ${formatSize(DEFAULT_MAX_BYTES)} limit. Use bash: sed -n '${startLineDisplay}p' ${path} | head -c ${DEFAULT_MAX_BYTES}]`;
|
|
334
|
+
details = { truncation };
|
|
335
|
+
}
|
|
336
|
+
else if (truncation.truncated) {
|
|
337
|
+
// Truncation occurred. Build an actionable continuation notice.
|
|
338
|
+
const endLineDisplay = startLineDisplay + truncation.outputLines - 1;
|
|
339
|
+
const nextOffset = endLineDisplay + 1;
|
|
340
|
+
outputText = truncation.content;
|
|
341
|
+
if (truncation.truncatedBy === "lines") {
|
|
342
|
+
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines}. Use offset=${nextOffset} to continue.]`;
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
outputText += `\n\n[Showing lines ${startLineDisplay}-${endLineDisplay} of ${totalFileLines} (${formatSize(DEFAULT_MAX_BYTES)} limit). Use offset=${nextOffset} to continue.]`;
|
|
346
|
+
}
|
|
347
|
+
details = { truncation };
|
|
348
|
+
}
|
|
349
|
+
else if (userLimitedLines !== undefined && startLine + userLimitedLines < allLines.length) {
|
|
350
|
+
// User-specified limit stopped early, but the file still has more content.
|
|
351
|
+
const remaining = allLines.length - (startLine + userLimitedLines);
|
|
352
|
+
const nextOffset = startLine + userLimitedLines + 1;
|
|
353
|
+
outputText = `${truncation.content}\n\n[${remaining} more lines in file. Use offset=${nextOffset} to continue.]`;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
// No truncation and no remaining user-limited content.
|
|
357
|
+
outputText = truncation.content;
|
|
358
|
+
}
|
|
359
|
+
content = [{ type: "text", text: outputText }];
|
|
360
|
+
}
|
|
361
|
+
if (aborted)
|
|
362
|
+
return;
|
|
363
|
+
signal?.removeEventListener("abort", onAbort);
|
|
364
|
+
resolve({ content, details });
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
signal?.removeEventListener("abort", onAbort);
|
|
368
|
+
if (!aborted)
|
|
369
|
+
reject(error);
|
|
370
|
+
}
|
|
371
|
+
})();
|
|
372
|
+
});
|
|
373
|
+
},
|
|
374
|
+
renderCall(args, theme, context) {
|
|
375
|
+
const text = context.lastComponent ?? new Text("", 0, 0);
|
|
376
|
+
const classification = !context.expanded ? getCompactReadClassification(args, context.cwd) : undefined;
|
|
377
|
+
text.setText(classification
|
|
378
|
+
? formatCompactReadCall(classification, args, theme)
|
|
379
|
+
: formatReadCall(args, theme, context.cwd));
|
|
380
|
+
return text;
|
|
381
|
+
},
|
|
382
|
+
renderResult(result, options, theme, context) {
|
|
383
|
+
const text = context.lastComponent ?? new Text("", 0, 0);
|
|
384
|
+
text.setText(formatReadResult(context.args, result, options, theme, context.showImages, context.cwd, context.isError));
|
|
385
|
+
return text;
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
export function createReadTool(cwd, options) {
|
|
390
|
+
return wrapToolDefinition(createReadToolDefinition(cwd, options));
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=READ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[2026-06-19] 工具名首字母大写
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as os from "node:os";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { getCapabilities, getImageDimensions, hyperlink, imageFallback } from "@earendil-works/pi-tui";
|
|
4
|
+
import { stripAnsi } from "../../utils/ansi.js";
|
|
5
|
+
import { resolvePath } from "../../utils/paths.js";
|
|
6
|
+
import { sanitizeBinaryOutput } from "../../utils/shell.js";
|
|
7
|
+
export function shortenPath(path) {
|
|
8
|
+
if (typeof path !== "string")
|
|
9
|
+
return "";
|
|
10
|
+
const home = os.homedir();
|
|
11
|
+
if (path.startsWith(home)) {
|
|
12
|
+
return `~${path.slice(home.length)}`;
|
|
13
|
+
}
|
|
14
|
+
return path;
|
|
15
|
+
}
|
|
16
|
+
export function linkPath(styledText, rawPath, cwd) {
|
|
17
|
+
if (!getCapabilities().hyperlinks)
|
|
18
|
+
return styledText;
|
|
19
|
+
const absolutePath = resolvePath(rawPath, cwd);
|
|
20
|
+
return hyperlink(styledText, pathToFileURL(absolutePath).href);
|
|
21
|
+
}
|
|
22
|
+
export function str(value) {
|
|
23
|
+
if (typeof value === "string")
|
|
24
|
+
return value;
|
|
25
|
+
if (value == null)
|
|
26
|
+
return "";
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
export function replaceTabs(text) {
|
|
30
|
+
return text.replace(/\t/g, " ");
|
|
31
|
+
}
|
|
32
|
+
export function normalizeDisplayText(text) {
|
|
33
|
+
return text.replace(/\r/g, "");
|
|
34
|
+
}
|
|
35
|
+
export function getTextOutput(result, showImages) {
|
|
36
|
+
if (!result)
|
|
37
|
+
return "";
|
|
38
|
+
const textBlocks = result.content.filter((c) => c.type === "text");
|
|
39
|
+
const imageBlocks = result.content.filter((c) => c.type === "image");
|
|
40
|
+
let output = textBlocks.map((c) => sanitizeBinaryOutput(stripAnsi(c.text || "")).replace(/\r/g, "")).join("\n");
|
|
41
|
+
const caps = getCapabilities();
|
|
42
|
+
if (imageBlocks.length > 0 && (!caps.images || !showImages)) {
|
|
43
|
+
const imageIndicators = imageBlocks
|
|
44
|
+
.map((img) => {
|
|
45
|
+
const mimeType = img.mimeType ?? "image/unknown";
|
|
46
|
+
const dims = img.data && img.mimeType ? (getImageDimensions(img.data, img.mimeType) ?? undefined) : undefined;
|
|
47
|
+
return imageFallback(mimeType, dims);
|
|
48
|
+
})
|
|
49
|
+
.join("\n");
|
|
50
|
+
output = output ? `${output}\n${imageIndicators}` : imageIndicators;
|
|
51
|
+
}
|
|
52
|
+
return output;
|
|
53
|
+
}
|
|
54
|
+
export function invalidArgText(theme) {
|
|
55
|
+
return theme.fg("error", "[invalid arg]");
|
|
56
|
+
}
|
|
57
|
+
export function renderToolPath(rawPath, theme, cwd, options) {
|
|
58
|
+
if (rawPath === null)
|
|
59
|
+
return invalidArgText(theme);
|
|
60
|
+
const value = rawPath || options?.emptyFallback;
|
|
61
|
+
if (!value)
|
|
62
|
+
return theme.fg("toolOutput", "...");
|
|
63
|
+
return linkPath(theme.fg("accent", shortenPath(value)), value, cwd);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=render-utils.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Wrap a ToolDefinition into an AgentTool for the core runtime. */
|
|
2
|
+
export function wrapToolDefinition(definition, ctxFactory) {
|
|
3
|
+
return {
|
|
4
|
+
name: definition.name,
|
|
5
|
+
label: definition.label,
|
|
6
|
+
messageDescription: definition.messageDescription,
|
|
7
|
+
parameters: definition.parameters,
|
|
8
|
+
prepareArguments: definition.prepareArguments,
|
|
9
|
+
executionMode: definition.executionMode,
|
|
10
|
+
execute: (toolCallId, params, signal, onUpdate) => definition.execute(toolCallId, params, signal, onUpdate, ctxFactory?.()),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */
|
|
14
|
+
export function wrapToolDefinitions(definitions, ctxFactory) {
|
|
15
|
+
return definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Synthesize a minimal ToolDefinition from an AgentTool.
|
|
19
|
+
*
|
|
20
|
+
* This keeps AgentSession's internal registry definition-first even when a caller
|
|
21
|
+
* provides plain AgentTool overrides that do not include prompt metadata or renderers.
|
|
22
|
+
*/
|
|
23
|
+
export function createToolDefinitionFromAgentTool(tool) {
|
|
24
|
+
return {
|
|
25
|
+
name: tool.name,
|
|
26
|
+
label: tool.label,
|
|
27
|
+
messageDescription: tool.messageDescription,
|
|
28
|
+
parameters: tool.parameters,
|
|
29
|
+
prepareArguments: tool.prepareArguments,
|
|
30
|
+
executionMode: tool.executionMode,
|
|
31
|
+
execute: async (toolCallId, params, signal, onUpdate) => tool.execute(toolCallId, params, signal, onUpdate),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=tool-definition-wrapper.js.map
|