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,112 @@
|
|
|
1
|
+
export { createBashTool, createBashToolDefinition, createLocalBashOperations, } from "./bash.js";
|
|
2
|
+
export { createEditTool, createEditToolDefinition, } from "./edit.js";
|
|
3
|
+
export { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
4
|
+
export { createFindTool, createFindToolDefinition, } from "./find.js";
|
|
5
|
+
export { createGrepTool, createGrepToolDefinition, } from "./grep.js";
|
|
6
|
+
export { createLsTool, createLsToolDefinition, } from "./ls.js";
|
|
7
|
+
export { createReadTool, createReadToolDefinition, } from "./read.js";
|
|
8
|
+
export { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead, truncateLine, truncateTail, } from "./truncate.js";
|
|
9
|
+
export { createWriteTool, createWriteToolDefinition, } from "./write.js";
|
|
10
|
+
import { createBashTool, createBashToolDefinition } from "./bash.js";
|
|
11
|
+
import { createEditTool, createEditToolDefinition } from "./edit.js";
|
|
12
|
+
import { createFindTool, createFindToolDefinition } from "./find.js";
|
|
13
|
+
import { createGrepTool, createGrepToolDefinition } from "./grep.js";
|
|
14
|
+
import { createLsTool, createLsToolDefinition } from "./ls.js";
|
|
15
|
+
import { createReadTool, createReadToolDefinition } from "./read.js";
|
|
16
|
+
import { createWriteTool, createWriteToolDefinition } from "./write.js";
|
|
17
|
+
export const allToolNames = new Set(["read", "bash", "edit", "write", "grep", "find", "ls"]);
|
|
18
|
+
export function createToolDefinition(toolName, cwd, options) {
|
|
19
|
+
switch (toolName) {
|
|
20
|
+
case "read":
|
|
21
|
+
return createReadToolDefinition(cwd, options?.read);
|
|
22
|
+
case "bash":
|
|
23
|
+
return createBashToolDefinition(cwd, options?.bash);
|
|
24
|
+
case "edit":
|
|
25
|
+
return createEditToolDefinition(cwd, options?.edit);
|
|
26
|
+
case "write":
|
|
27
|
+
return createWriteToolDefinition(cwd, options?.write);
|
|
28
|
+
case "grep":
|
|
29
|
+
return createGrepToolDefinition(cwd, options?.grep);
|
|
30
|
+
case "find":
|
|
31
|
+
return createFindToolDefinition(cwd, options?.find);
|
|
32
|
+
case "ls":
|
|
33
|
+
return createLsToolDefinition(cwd, options?.ls);
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Unknown tool name: ${toolName}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function createTool(toolName, cwd, options) {
|
|
39
|
+
switch (toolName) {
|
|
40
|
+
case "read":
|
|
41
|
+
return createReadTool(cwd, options?.read);
|
|
42
|
+
case "bash":
|
|
43
|
+
return createBashTool(cwd, options?.bash);
|
|
44
|
+
case "edit":
|
|
45
|
+
return createEditTool(cwd, options?.edit);
|
|
46
|
+
case "write":
|
|
47
|
+
return createWriteTool(cwd, options?.write);
|
|
48
|
+
case "grep":
|
|
49
|
+
return createGrepTool(cwd, options?.grep);
|
|
50
|
+
case "find":
|
|
51
|
+
return createFindTool(cwd, options?.find);
|
|
52
|
+
case "ls":
|
|
53
|
+
return createLsTool(cwd, options?.ls);
|
|
54
|
+
default:
|
|
55
|
+
throw new Error(`Unknown tool name: ${toolName}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function createCodingToolDefinitions(cwd, options) {
|
|
59
|
+
return [
|
|
60
|
+
createReadToolDefinition(cwd, options?.read),
|
|
61
|
+
createBashToolDefinition(cwd, options?.bash),
|
|
62
|
+
createEditToolDefinition(cwd, options?.edit),
|
|
63
|
+
createWriteToolDefinition(cwd, options?.write),
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
export function createReadOnlyToolDefinitions(cwd, options) {
|
|
67
|
+
return [
|
|
68
|
+
createReadToolDefinition(cwd, options?.read),
|
|
69
|
+
createGrepToolDefinition(cwd, options?.grep),
|
|
70
|
+
createFindToolDefinition(cwd, options?.find),
|
|
71
|
+
createLsToolDefinition(cwd, options?.ls),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
export function createAllToolDefinitions(cwd, options) {
|
|
75
|
+
return {
|
|
76
|
+
read: createReadToolDefinition(cwd, options?.read),
|
|
77
|
+
bash: createBashToolDefinition(cwd, options?.bash),
|
|
78
|
+
edit: createEditToolDefinition(cwd, options?.edit),
|
|
79
|
+
write: createWriteToolDefinition(cwd, options?.write),
|
|
80
|
+
grep: createGrepToolDefinition(cwd, options?.grep),
|
|
81
|
+
find: createFindToolDefinition(cwd, options?.find),
|
|
82
|
+
ls: createLsToolDefinition(cwd, options?.ls),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export function createCodingTools(cwd, options) {
|
|
86
|
+
return [
|
|
87
|
+
createReadTool(cwd, options?.read),
|
|
88
|
+
createBashTool(cwd, options?.bash),
|
|
89
|
+
createEditTool(cwd, options?.edit),
|
|
90
|
+
createWriteTool(cwd, options?.write),
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
export function createReadOnlyTools(cwd, options) {
|
|
94
|
+
return [
|
|
95
|
+
createReadTool(cwd, options?.read),
|
|
96
|
+
createGrepTool(cwd, options?.grep),
|
|
97
|
+
createFindTool(cwd, options?.find),
|
|
98
|
+
createLsTool(cwd, options?.ls),
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
export function createAllTools(cwd, options) {
|
|
102
|
+
return {
|
|
103
|
+
read: createReadTool(cwd, options?.read),
|
|
104
|
+
bash: createBashTool(cwd, options?.bash),
|
|
105
|
+
edit: createEditTool(cwd, options?.edit),
|
|
106
|
+
write: createWriteTool(cwd, options?.write),
|
|
107
|
+
grep: createGrepTool(cwd, options?.grep),
|
|
108
|
+
find: createFindTool(cwd, options?.find),
|
|
109
|
+
ls: createLsTool(cwd, options?.ls),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { readdir as fsReaddir, stat as fsStat } from "node:fs/promises";
|
|
2
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
3
|
+
import nodePath from "path";
|
|
4
|
+
import { Type } from "typebox";
|
|
5
|
+
import { keyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
6
|
+
import { getToolPrompt } from "./prompts-reader.js";
|
|
7
|
+
import { markLs } from "./ls-guard.js";
|
|
8
|
+
import { pathExists, resolveToCwd } from "./path-utils.js";
|
|
9
|
+
import { getTextOutput, renderToolPath, str } from "./render-utils.js";
|
|
10
|
+
import { wrapToolDefinition } from "./tool-definition-wrapper.js";
|
|
11
|
+
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
12
|
+
const lsSchema = Type.Object({
|
|
13
|
+
path: Type.Optional(Type.String({ messageDescription: "Directory to list (default: current directory)" })),
|
|
14
|
+
limit: Type.Optional(Type.Number({ messageDescription: "Maximum number of entries to return (default: 500)" })),
|
|
15
|
+
});
|
|
16
|
+
const DEFAULT_LIMIT = 500;
|
|
17
|
+
const defaultLsOperations = {
|
|
18
|
+
exists: pathExists,
|
|
19
|
+
stat: fsStat,
|
|
20
|
+
readdir: fsReaddir,
|
|
21
|
+
};
|
|
22
|
+
function formatLsCall(args, theme, cwd) {
|
|
23
|
+
const limit = args?.limit;
|
|
24
|
+
const pathDisplay = renderToolPath(str(args?.path), theme, cwd, { emptyFallback: "." });
|
|
25
|
+
let text = `${theme.fg("toolTitle", "● " + theme.bold("Ls"))} ${pathDisplay}`;
|
|
26
|
+
if (limit !== undefined) {
|
|
27
|
+
text += theme.fg("toolOutput", ` (limit ${limit})`);
|
|
28
|
+
}
|
|
29
|
+
return text;
|
|
30
|
+
}
|
|
31
|
+
function formatLsResult(result, options, theme, showImages) {
|
|
32
|
+
const output = getTextOutput(result, showImages).trim();
|
|
33
|
+
let text = "";
|
|
34
|
+
if (output) {
|
|
35
|
+
const lines = output.split("\n");
|
|
36
|
+
const maxLines = options.expanded ? lines.length : 20;
|
|
37
|
+
const displayLines = lines.slice(0, maxLines);
|
|
38
|
+
const remaining = lines.length - maxLines;
|
|
39
|
+
text += `\n${displayLines.map((line) => theme.fg("toolOutput", line)).join("\n")}`;
|
|
40
|
+
if (remaining > 0) {
|
|
41
|
+
text += `${theme.fg("muted", `\n... (${remaining} more lines,`)} ${keyHint("app.tools.expand", "to expand")}${theme.fg("muted", ")")}`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const entryLimit = result.details?.entryLimitReached;
|
|
45
|
+
const truncation = result.details?.truncation;
|
|
46
|
+
if (entryLimit || truncation?.truncated) {
|
|
47
|
+
const warnings = [];
|
|
48
|
+
if (entryLimit)
|
|
49
|
+
warnings.push(`${entryLimit} entries limit`);
|
|
50
|
+
if (truncation?.truncated)
|
|
51
|
+
warnings.push(`${formatSize(truncation.maxBytes ?? DEFAULT_MAX_BYTES)} limit`);
|
|
52
|
+
text += `\n${theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`)}`;
|
|
53
|
+
}
|
|
54
|
+
return text;
|
|
55
|
+
}
|
|
56
|
+
export function createLsToolDefinition(cwd, options) {
|
|
57
|
+
const ops = options?.operations ?? defaultLsOperations;
|
|
58
|
+
return {
|
|
59
|
+
name: "ls",
|
|
60
|
+
label: "ls",
|
|
61
|
+
messageDescription: (getToolPrompt('ls', 'messageDescription') || '').replace('{{DEFAULT_LIMIT}}', String(DEFAULT_LIMIT)).replace('{{DEFAULT_MAX_BYTES_KB}}', String(DEFAULT_MAX_BYTES / 1024)),
|
|
62
|
+
promptSnippet: getToolPrompt('ls', 'snippet'),
|
|
63
|
+
parameters: lsSchema,
|
|
64
|
+
async execute(_toolCallId, { path, limit }, signal, _onUpdate, _ctx) {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
if (signal?.aborted) {
|
|
67
|
+
reject(new Error("Operation aborted"));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const onAbort = () => reject(new Error("Operation aborted"));
|
|
71
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
72
|
+
(async () => {
|
|
73
|
+
try {
|
|
74
|
+
const dirPath = resolveToCwd(path || ".", cwd);
|
|
75
|
+
markLs(dirPath); // NORM-009
|
|
76
|
+
const effectiveLimit = limit ?? DEFAULT_LIMIT;
|
|
77
|
+
// Check if path exists.
|
|
78
|
+
if (!(await ops.exists(dirPath))) {
|
|
79
|
+
reject(new Error(`Path not found: ${dirPath}`));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// Check if path is a directory.
|
|
83
|
+
const stat = await ops.stat(dirPath);
|
|
84
|
+
if (!stat.isDirectory()) {
|
|
85
|
+
reject(new Error(`Not a directory: ${dirPath}`));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Read directory entries.
|
|
89
|
+
let entries;
|
|
90
|
+
try {
|
|
91
|
+
entries = await ops.readdir(dirPath);
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
reject(new Error(`Cannot read directory: ${e.message}`));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Sort alphabetically, case-insensitive.
|
|
98
|
+
entries.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
|
|
99
|
+
// Format entries with directory indicators.
|
|
100
|
+
const results = [];
|
|
101
|
+
let entryLimitReached = false;
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
if (results.length >= effectiveLimit) {
|
|
104
|
+
entryLimitReached = true;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
const fullPath = nodePath.join(dirPath, entry);
|
|
108
|
+
let suffix = "";
|
|
109
|
+
try {
|
|
110
|
+
const entryStat = await ops.stat(fullPath);
|
|
111
|
+
if (entryStat.isDirectory())
|
|
112
|
+
suffix = "/";
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
// Skip entries we cannot stat.
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
results.push(entry + suffix);
|
|
119
|
+
}
|
|
120
|
+
signal?.removeEventListener("abort", onAbort);
|
|
121
|
+
if (results.length === 0) {
|
|
122
|
+
resolve({ content: [{ type: "text", text: "(empty directory)" }], details: undefined });
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const rawOutput = results.join("\n");
|
|
126
|
+
// Apply byte truncation. There is no separate line limit because entry count is already capped.
|
|
127
|
+
const truncation = truncateHead(rawOutput, { maxLines: Number.MAX_SAFE_INTEGER });
|
|
128
|
+
let output = truncation.content;
|
|
129
|
+
const details = {};
|
|
130
|
+
// Build actionable notices for truncation and entry limits.
|
|
131
|
+
const notices = [];
|
|
132
|
+
if (entryLimitReached) {
|
|
133
|
+
notices.push(`${effectiveLimit} entries limit reached. Use limit=${effectiveLimit * 2} for more`);
|
|
134
|
+
details.entryLimitReached = effectiveLimit;
|
|
135
|
+
}
|
|
136
|
+
if (truncation.truncated) {
|
|
137
|
+
notices.push(`${formatSize(DEFAULT_MAX_BYTES)} limit reached`);
|
|
138
|
+
details.truncation = truncation;
|
|
139
|
+
}
|
|
140
|
+
if (notices.length > 0) {
|
|
141
|
+
output += `\n\n[${notices.join(". ")}]`;
|
|
142
|
+
}
|
|
143
|
+
resolve({
|
|
144
|
+
content: [{ type: "text", text: output }],
|
|
145
|
+
details: Object.keys(details).length > 0 ? details : undefined,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
signal?.removeEventListener("abort", onAbort);
|
|
150
|
+
reject(e);
|
|
151
|
+
}
|
|
152
|
+
})();
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
renderCall(args, theme, context) {
|
|
156
|
+
const text = context.lastComponent ?? new Text("", 0, 0);
|
|
157
|
+
text.setText(formatLsCall(args, theme, context.cwd));
|
|
158
|
+
return text;
|
|
159
|
+
},
|
|
160
|
+
renderResult(result, options, theme, context) {
|
|
161
|
+
const text = context.lastComponent ?? new Text("", 2, 0);
|
|
162
|
+
text.setText(formatLsResult(result, options, theme, context.showImages));
|
|
163
|
+
return text;
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export function createLsTool(cwd, options) {
|
|
168
|
+
return wrapToolDefinition(createLsToolDefinition(cwd, options));
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[2026-06-19] 工具名首字母大写
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { createWriteStream } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, truncateTail } from "./truncate.js";
|
|
6
|
+
function defaultTempFilePath(prefix) {
|
|
7
|
+
const id = randomBytes(8).toString("hex");
|
|
8
|
+
return join(tmpdir(), `${prefix}-${id}.log`);
|
|
9
|
+
}
|
|
10
|
+
function byteLength(text) {
|
|
11
|
+
return Buffer.byteLength(text, "utf-8");
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Incrementally tracks streaming output with bounded memory.
|
|
15
|
+
*
|
|
16
|
+
* Appends decode chunks with a streaming UTF-8 decoder, keeps only a decoded
|
|
17
|
+
* tail for display snapshots, and opens a temp file when the full output needs
|
|
18
|
+
* to be preserved.
|
|
19
|
+
*/
|
|
20
|
+
export class OutputAccumulator {
|
|
21
|
+
maxLines;
|
|
22
|
+
maxBytes;
|
|
23
|
+
maxRollingBytes;
|
|
24
|
+
tempFilePrefix;
|
|
25
|
+
decoder = new TextDecoder();
|
|
26
|
+
rawChunks = [];
|
|
27
|
+
tailText = "";
|
|
28
|
+
tailBytes = 0;
|
|
29
|
+
tailStartsAtLineBoundary = true;
|
|
30
|
+
totalRawBytes = 0;
|
|
31
|
+
totalDecodedBytes = 0;
|
|
32
|
+
completedLines = 0;
|
|
33
|
+
totalLines = 0;
|
|
34
|
+
currentLineBytes = 0;
|
|
35
|
+
hasOpenLine = false;
|
|
36
|
+
finished = false;
|
|
37
|
+
tempFilePath;
|
|
38
|
+
tempFileStream;
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
this.maxLines = options.maxLines ?? DEFAULT_MAX_LINES;
|
|
41
|
+
this.maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
42
|
+
this.maxRollingBytes = Math.max(this.maxBytes * 2, 1);
|
|
43
|
+
this.tempFilePrefix = options.tempFilePrefix ?? "pi-output";
|
|
44
|
+
}
|
|
45
|
+
append(data) {
|
|
46
|
+
if (this.finished) {
|
|
47
|
+
throw new Error("Cannot append to a finished output accumulator");
|
|
48
|
+
}
|
|
49
|
+
this.totalRawBytes += data.length;
|
|
50
|
+
this.appendDecodedText(this.decoder.decode(data, { stream: true }));
|
|
51
|
+
if (this.tempFileStream || this.shouldUseTempFile()) {
|
|
52
|
+
this.ensureTempFile();
|
|
53
|
+
this.tempFileStream?.write(data);
|
|
54
|
+
}
|
|
55
|
+
else if (data.length > 0) {
|
|
56
|
+
this.rawChunks.push(data);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
finish() {
|
|
60
|
+
if (this.finished) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.finished = true;
|
|
64
|
+
this.appendDecodedText(this.decoder.decode());
|
|
65
|
+
if (this.shouldUseTempFile()) {
|
|
66
|
+
this.ensureTempFile();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
snapshot(options = {}) {
|
|
70
|
+
const tailTruncation = truncateTail(this.getSnapshotText(), {
|
|
71
|
+
maxLines: this.maxLines,
|
|
72
|
+
maxBytes: this.maxBytes,
|
|
73
|
+
});
|
|
74
|
+
const truncated = this.totalLines > this.maxLines || this.totalDecodedBytes > this.maxBytes;
|
|
75
|
+
const truncatedBy = truncated
|
|
76
|
+
? (tailTruncation.truncatedBy ?? (this.totalDecodedBytes > this.maxBytes ? "bytes" : "lines"))
|
|
77
|
+
: null;
|
|
78
|
+
const truncation = {
|
|
79
|
+
...tailTruncation,
|
|
80
|
+
truncated,
|
|
81
|
+
truncatedBy,
|
|
82
|
+
totalLines: this.totalLines,
|
|
83
|
+
totalBytes: this.totalDecodedBytes,
|
|
84
|
+
maxLines: this.maxLines,
|
|
85
|
+
maxBytes: this.maxBytes,
|
|
86
|
+
};
|
|
87
|
+
if (options.persistIfTruncated && truncation.truncated) {
|
|
88
|
+
this.ensureTempFile();
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
content: truncation.content,
|
|
92
|
+
truncation,
|
|
93
|
+
fullOutputPath: this.tempFilePath,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async closeTempFile() {
|
|
97
|
+
if (!this.tempFileStream) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const stream = this.tempFileStream;
|
|
101
|
+
this.tempFileStream = undefined;
|
|
102
|
+
await new Promise((resolve, reject) => {
|
|
103
|
+
const onError = (error) => {
|
|
104
|
+
stream.off("finish", onFinish);
|
|
105
|
+
reject(error);
|
|
106
|
+
};
|
|
107
|
+
const onFinish = () => {
|
|
108
|
+
stream.off("error", onError);
|
|
109
|
+
resolve();
|
|
110
|
+
};
|
|
111
|
+
stream.once("error", onError);
|
|
112
|
+
stream.once("finish", onFinish);
|
|
113
|
+
stream.end();
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
getLastLineBytes() {
|
|
117
|
+
return this.currentLineBytes;
|
|
118
|
+
}
|
|
119
|
+
appendDecodedText(text) {
|
|
120
|
+
if (text.length === 0) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const bytes = byteLength(text);
|
|
124
|
+
this.totalDecodedBytes += bytes;
|
|
125
|
+
this.tailText += text;
|
|
126
|
+
this.tailBytes += bytes;
|
|
127
|
+
if (this.tailBytes > this.maxRollingBytes * 2) {
|
|
128
|
+
this.trimTail();
|
|
129
|
+
}
|
|
130
|
+
let newlines = 0;
|
|
131
|
+
let lastNewline = -1;
|
|
132
|
+
for (let i = text.indexOf("\n"); i !== -1; i = text.indexOf("\n", i + 1)) {
|
|
133
|
+
newlines++;
|
|
134
|
+
lastNewline = i;
|
|
135
|
+
}
|
|
136
|
+
if (newlines === 0) {
|
|
137
|
+
this.currentLineBytes += bytes;
|
|
138
|
+
this.hasOpenLine = true;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.completedLines += newlines;
|
|
142
|
+
const tail = text.slice(lastNewline + 1);
|
|
143
|
+
this.currentLineBytes = byteLength(tail);
|
|
144
|
+
this.hasOpenLine = tail.length > 0;
|
|
145
|
+
}
|
|
146
|
+
this.totalLines = this.completedLines + (this.hasOpenLine ? 1 : 0);
|
|
147
|
+
}
|
|
148
|
+
trimTail() {
|
|
149
|
+
const buffer = Buffer.from(this.tailText, "utf-8");
|
|
150
|
+
if (buffer.length <= this.maxRollingBytes) {
|
|
151
|
+
this.tailBytes = buffer.length;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
let start = buffer.length - this.maxRollingBytes;
|
|
155
|
+
while (start < buffer.length && (buffer[start] & 0xc0) === 0x80) {
|
|
156
|
+
start++;
|
|
157
|
+
}
|
|
158
|
+
this.tailStartsAtLineBoundary = start === 0 ? this.tailStartsAtLineBoundary : buffer[start - 1] === 0x0a;
|
|
159
|
+
this.tailText = buffer.subarray(start).toString("utf-8");
|
|
160
|
+
this.tailBytes = byteLength(this.tailText);
|
|
161
|
+
}
|
|
162
|
+
getSnapshotText() {
|
|
163
|
+
if (this.tailStartsAtLineBoundary) {
|
|
164
|
+
return this.tailText;
|
|
165
|
+
}
|
|
166
|
+
const firstNewline = this.tailText.indexOf("\n");
|
|
167
|
+
return firstNewline === -1 ? this.tailText : this.tailText.slice(firstNewline + 1);
|
|
168
|
+
}
|
|
169
|
+
shouldUseTempFile() {
|
|
170
|
+
return (this.totalRawBytes > this.maxBytes || this.totalDecodedBytes > this.maxBytes || this.totalLines > this.maxLines);
|
|
171
|
+
}
|
|
172
|
+
ensureTempFile() {
|
|
173
|
+
if (this.tempFilePath) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.tempFilePath = defaultTempFilePath(this.tempFilePrefix);
|
|
177
|
+
this.tempFileStream = createWriteStream(this.tempFilePath);
|
|
178
|
+
for (const chunk of this.rawChunks) {
|
|
179
|
+
this.tempFileStream.write(chunk);
|
|
180
|
+
}
|
|
181
|
+
this.rawChunks = [];
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=output-accumulator.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { accessSync, constants } from "node:fs";
|
|
2
|
+
import { access } from "node:fs/promises";
|
|
3
|
+
import { normalizePath, resolvePath } from "../../utils/paths.js";
|
|
4
|
+
const NARROW_NO_BREAK_SPACE = "\u202F";
|
|
5
|
+
function tryMacOSScreenshotPath(filePath) {
|
|
6
|
+
return filePath.replace(/ (AM|PM)\./gi, `${NARROW_NO_BREAK_SPACE}$1.`);
|
|
7
|
+
}
|
|
8
|
+
function tryNFDVariant(filePath) {
|
|
9
|
+
// macOS stores filenames in NFD (decomposed) form, try converting user input to NFD
|
|
10
|
+
return filePath.normalize("NFD");
|
|
11
|
+
}
|
|
12
|
+
function tryCurlyQuoteVariant(filePath) {
|
|
13
|
+
// macOS uses U+2019 (right single quotation mark) in screenshot names like "Capture d'écran"
|
|
14
|
+
// Users typically type U+0027 (straight apostrophe)
|
|
15
|
+
return filePath.replace(/'/g, "\u2019");
|
|
16
|
+
}
|
|
17
|
+
function fileExists(filePath) {
|
|
18
|
+
try {
|
|
19
|
+
accessSync(filePath, constants.F_OK);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function pathExists(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
await access(filePath, constants.F_OK);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function expandPath(filePath) {
|
|
36
|
+
return normalizePath(filePath, { normalizeUnicodeSpaces: true, stripAtPrefix: true });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a path relative to the given cwd.
|
|
40
|
+
* Handles ~ expansion and absolute paths.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveToCwd(filePath, cwd) {
|
|
43
|
+
return resolvePath(filePath, cwd, { normalizeUnicodeSpaces: true, stripAtPrefix: true });
|
|
44
|
+
}
|
|
45
|
+
export function resolveReadPath(filePath, cwd) {
|
|
46
|
+
const resolved = resolveToCwd(filePath, cwd);
|
|
47
|
+
if (fileExists(resolved)) {
|
|
48
|
+
return resolved;
|
|
49
|
+
}
|
|
50
|
+
// Try macOS AM/PM variant (narrow no-break space before AM/PM)
|
|
51
|
+
const amPmVariant = tryMacOSScreenshotPath(resolved);
|
|
52
|
+
if (amPmVariant !== resolved && fileExists(amPmVariant)) {
|
|
53
|
+
return amPmVariant;
|
|
54
|
+
}
|
|
55
|
+
// Try NFD variant (macOS stores filenames in NFD form)
|
|
56
|
+
const nfdVariant = tryNFDVariant(resolved);
|
|
57
|
+
if (nfdVariant !== resolved && fileExists(nfdVariant)) {
|
|
58
|
+
return nfdVariant;
|
|
59
|
+
}
|
|
60
|
+
// Try curly quote variant (macOS uses U+2019 in screenshot names)
|
|
61
|
+
const curlyVariant = tryCurlyQuoteVariant(resolved);
|
|
62
|
+
if (curlyVariant !== resolved && fileExists(curlyVariant)) {
|
|
63
|
+
return curlyVariant;
|
|
64
|
+
}
|
|
65
|
+
// Try combined NFD + curly quote (for French macOS screenshots like "Capture d'écran")
|
|
66
|
+
const nfdCurlyVariant = tryCurlyQuoteVariant(nfdVariant);
|
|
67
|
+
if (nfdCurlyVariant !== resolved && fileExists(nfdCurlyVariant)) {
|
|
68
|
+
return nfdCurlyVariant;
|
|
69
|
+
}
|
|
70
|
+
return resolved;
|
|
71
|
+
}
|
|
72
|
+
export async function resolveReadPathAsync(filePath, cwd) {
|
|
73
|
+
const resolved = resolveToCwd(filePath, cwd);
|
|
74
|
+
if (await pathExists(resolved)) {
|
|
75
|
+
return resolved;
|
|
76
|
+
}
|
|
77
|
+
// Try macOS AM/PM variant (narrow no-break space before AM/PM)
|
|
78
|
+
const amPmVariant = tryMacOSScreenshotPath(resolved);
|
|
79
|
+
if (amPmVariant !== resolved && (await pathExists(amPmVariant))) {
|
|
80
|
+
return amPmVariant;
|
|
81
|
+
}
|
|
82
|
+
// Try NFD variant (macOS stores filenames in NFD form)
|
|
83
|
+
const nfdVariant = tryNFDVariant(resolved);
|
|
84
|
+
if (nfdVariant !== resolved && (await pathExists(nfdVariant))) {
|
|
85
|
+
return nfdVariant;
|
|
86
|
+
}
|
|
87
|
+
// Try curly quote variant (macOS uses U+2019 in screenshot names)
|
|
88
|
+
const curlyVariant = tryCurlyQuoteVariant(resolved);
|
|
89
|
+
if (curlyVariant !== resolved && (await pathExists(curlyVariant))) {
|
|
90
|
+
return curlyVariant;
|
|
91
|
+
}
|
|
92
|
+
// Try combined NFD + curly quote (for French macOS screenshots like "Capture d'écran")
|
|
93
|
+
const nfdCurlyVariant = tryCurlyQuoteVariant(nfdVariant);
|
|
94
|
+
if (nfdCurlyVariant !== resolved && (await pathExists(nfdCurlyVariant))) {
|
|
95
|
+
return nfdCurlyVariant;
|
|
96
|
+
}
|
|
97
|
+
return resolved;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=path-utils.js.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// pi-coding-master 统一提示词读取器 — ESM 版本,供 dist-override JS 文件 import
|
|
2
|
+
// 用法:
|
|
3
|
+
// import { getToolPrompt } from './prompts-reader.js';
|
|
4
|
+
// const snippet = getToolPrompt('read', 'snippet');
|
|
5
|
+
|
|
6
|
+
import { readFileSync } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
|
|
11
|
+
let _cache = null;
|
|
12
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
13
|
+
|
|
14
|
+
function loadPrompts() {
|
|
15
|
+
if (_cache) return _cache;
|
|
16
|
+
// 生产路径:~/.pi/agent/extensions/pi-coding-master/prompts/prompts.json
|
|
17
|
+
const prodPath = join(homedir(), '.pi', 'agent', 'extensions', 'pi-coding-master', 'prompts', 'prompts.json');
|
|
18
|
+
try {
|
|
19
|
+
_cache = JSON.parse(readFileSync(prodPath, 'utf-8'));
|
|
20
|
+
return _cache;
|
|
21
|
+
} catch {
|
|
22
|
+
// 开发路径:Codebase/core/prompts/prompts.json
|
|
23
|
+
try {
|
|
24
|
+
const devPath = join(__dirname, '..', '..', '..', '..', '..', 'core', 'prompts', 'prompts.json');
|
|
25
|
+
_cache = JSON.parse(readFileSync(devPath, 'utf-8'));
|
|
26
|
+
return _cache;
|
|
27
|
+
} catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getToolPrompt(toolName, field) {
|
|
34
|
+
const p = loadPrompts();
|
|
35
|
+
return p?.tools?.[toolName]?.[field] ?? undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function getSystemTemplate() {
|
|
39
|
+
return loadPrompts()?.system?.template ?? null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getDnaPrompt(name) {
|
|
43
|
+
return loadPrompts()?.dna?.[name] ?? null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getProviderMessage(name) {
|
|
47
|
+
return loadPrompts()?.provider?.[name] ?? null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function getVisionBridgePrompt() {
|
|
51
|
+
return loadPrompts()?.vision?.bridgePrompt ?? null;
|
|
52
|
+
}
|
|
53
|
+
|