dominds 0.1.0
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/LICENSE +157 -0
- package/README.md +250 -0
- package/README.zh.md +161 -0
- package/dist/access-control.js +253 -0
- package/dist/cli/create.js +263 -0
- package/dist/cli/read.js +84 -0
- package/dist/cli/tui.js +199 -0
- package/dist/cli/webui.js +169 -0
- package/dist/cli.js +227 -0
- package/dist/dialog-factory.js +53 -0
- package/dist/dialog-global-registry.js +68 -0
- package/dist/dialog-instance-registry.js +78 -0
- package/dist/dialog-run-state.js +198 -0
- package/dist/dialog.js +1024 -0
- package/dist/evt-registry.js +103 -0
- package/dist/index.js +8 -0
- package/dist/llm/client.js +69 -0
- package/dist/llm/defaults.yaml +386 -0
- package/dist/llm/driver.js +3214 -0
- package/dist/llm/gen/anthropic.js +611 -0
- package/dist/llm/gen/codex.js +375 -0
- package/dist/llm/gen/mock.js +326 -0
- package/dist/llm/gen/openai.js +470 -0
- package/dist/llm/gen/registry.js +26 -0
- package/dist/llm/gen.js +2 -0
- package/dist/llm/tools-projection.js +37 -0
- package/dist/log.js +228 -0
- package/dist/mcp/config.js +230 -0
- package/dist/mcp/sdk-client.js +129 -0
- package/dist/mcp/server-runtime.js +57 -0
- package/dist/mcp/stdio-client.js +280 -0
- package/dist/mcp/supervisor.js +979 -0
- package/dist/mcp/tool-names.js +109 -0
- package/dist/minds/builtin/cmdr/persona.md +3 -0
- package/dist/minds/builtin/dijiang/knowledge.md +287 -0
- package/dist/minds/builtin/dijiang/persona.md +7 -0
- package/dist/minds/builtin/fuxi/persona.en.md +59 -0
- package/dist/minds/builtin/fuxi/persona.zh.md +49 -0
- package/dist/minds/builtin/pangu/persona.en.md +78 -0
- package/dist/minds/builtin/pangu/persona.zh.md +71 -0
- package/dist/minds/load.js +617 -0
- package/dist/minds/minds-i18n.js +131 -0
- package/dist/minds/system-prompt.js +281 -0
- package/dist/persistence.js +3128 -0
- package/dist/problems.js +109 -0
- package/dist/server/api-routes.js +1031 -0
- package/dist/server/auth.js +180 -0
- package/dist/server/mime-types.js +32 -0
- package/dist/server/prompts-routes.js +543 -0
- package/dist/server/server-core.js +235 -0
- package/dist/server/setup-routes.js +697 -0
- package/dist/server/static-server.js +132 -0
- package/dist/server/websocket-handler.js +1011 -0
- package/dist/server.js +164 -0
- package/dist/shared/async-fifo-mutex.js +36 -0
- package/dist/shared/diligence.js +20 -0
- package/dist/shared/dotenv.js +144 -0
- package/dist/shared/evt.js +195 -0
- package/dist/shared/i18n/driver-messages.js +267 -0
- package/dist/shared/i18n/text.js +9 -0
- package/dist/shared/i18n/tool-result-messages.js +51 -0
- package/dist/shared/rtws-cli.js +73 -0
- package/dist/shared/runtime-language.js +47 -0
- package/dist/shared/team-mgmt-manual.js +116 -0
- package/dist/shared/types/context-health.js +2 -0
- package/dist/shared/types/dialog.js +11 -0
- package/dist/shared/types/i18n.js +2 -0
- package/dist/shared/types/index.js +26 -0
- package/dist/shared/types/language.js +40 -0
- package/dist/shared/types/problems.js +2 -0
- package/dist/shared/types/prompts.js +2 -0
- package/dist/shared/types/q4h.js +7 -0
- package/dist/shared/types/run-state.js +8 -0
- package/dist/shared/types/setup.js +2 -0
- package/dist/shared/types/storage.js +10 -0
- package/dist/shared/types/tellask.js +8 -0
- package/dist/shared/types/tools-registry.js +2 -0
- package/dist/shared/types/wire.js +12 -0
- package/dist/shared/utils/fmt.js +9 -0
- package/dist/shared/utils/html.js +20 -0
- package/dist/shared/utils/id.js +18 -0
- package/dist/shared/utils/inter-dialog-format.js +101 -0
- package/dist/shared/utils/time.js +13 -0
- package/dist/static/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/static/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/static/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/static/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/static/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/static/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/static/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/static/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/static/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/static/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/static/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/static/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/static/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/static/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/static/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/static/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/static/assets/_baseUniq-Crfl3d5Y.js +661 -0
- package/dist/static/assets/_baseUniq-Crfl3d5Y.js.map +1 -0
- package/dist/static/assets/arc-CbA_x9GD.js +132 -0
- package/dist/static/assets/arc-CbA_x9GD.js.map +1 -0
- package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js +8685 -0
- package/dist/static/assets/architectureDiagram-VXUJARFQ-lcFS8ZQJ.js.map +1 -0
- package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js +3608 -0
- package/dist/static/assets/blockDiagram-VD42YOAC-B3Q36qRc.js.map +1 -0
- package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js +2482 -0
- package/dist/static/assets/c4Diagram-YG6GDRKO-Mt-aq3VH.js.map +1 -0
- package/dist/static/assets/channel-BVr1Yke-.js +8 -0
- package/dist/static/assets/channel-BVr1Yke-.js.map +1 -0
- package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js +17 -0
- package/dist/static/assets/chunk-4BX2VUAB-qCIn5Iic.js.map +1 -0
- package/dist/static/assets/chunk-55IACEB6-q172NeCV.js +14 -0
- package/dist/static/assets/chunk-55IACEB6-q172NeCV.js.map +1 -0
- package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js +1827 -0
- package/dist/static/assets/chunk-B4BG7PRW-CMJmtYzq.js.map +1 -0
- package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js +1916 -0
- package/dist/static/assets/chunk-DI55MBZ5-DiuwwZPL.js.map +1 -0
- package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js +20 -0
- package/dist/static/assets/chunk-FMBD7UC4-06sqZTTn.js.map +1 -0
- package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js +25 -0
- package/dist/static/assets/chunk-QN33PNHL-CnpBNkpP.js.map +1 -0
- package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js +18 -0
- package/dist/static/assets/chunk-QZHKN3VN-CNgjMR-e.js.map +1 -0
- package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js +109 -0
- package/dist/static/assets/chunk-TZMSLE5B-BxtzW6--.js.map +1 -0
- package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js +23 -0
- package/dist/static/assets/classDiagram-2ON5EDUG-29huvmn-.js.map +1 -0
- package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js +23 -0
- package/dist/static/assets/classDiagram-v2-WZHVMYZB-29huvmn-.js.map +1 -0
- package/dist/static/assets/clone-D2OgLSSn.js +9 -0
- package/dist/static/assets/clone-D2OgLSSn.js.map +1 -0
- package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js +4943 -0
- package/dist/static/assets/cose-bilkent-S5V4N54A-BNegDCxl.js.map +1 -0
- package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js +30240 -0
- package/dist/static/assets/cytoscape.esm-Bm8DJGmZ.js.map +1 -0
- package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js +695 -0
- package/dist/static/assets/dagre-6UL2VRFP-f1XrTRSn.js.map +1 -0
- package/dist/static/assets/defaultLocale-DVr69WTU.js +207 -0
- package/dist/static/assets/defaultLocale-DVr69WTU.js.map +1 -0
- package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js +849 -0
- package/dist/static/assets/diagram-PSM6KHXK-8w1WbeDi.js.map +1 -0
- package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js +303 -0
- package/dist/static/assets/diagram-QEK2KX5R-CF4wtMmR.js.map +1 -0
- package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js +213 -0
- package/dist/static/assets/diagram-S2PKOQOG-8p3Avgn2.js.map +1 -0
- package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js +1159 -0
- package/dist/static/assets/erDiagram-Q2GNP2WA-BMKLxlM9.js.map +1 -0
- package/dist/static/assets/favicon-Cmg5RbCj.svg +8 -0
- package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js +2332 -0
- package/dist/static/assets/flowDiagram-NV44I4VS-CgEuPNK2.js.map +1 -0
- package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js +3681 -0
- package/dist/static/assets/ganttDiagram-JELNMOA3-bJkDCf-9.js.map +1 -0
- package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js +1206 -0
- package/dist/static/assets/gitGraphDiagram-NY62KEGX-4QE9kesp.js.map +1 -0
- package/dist/static/assets/graph-CS0Pmm7c.js +597 -0
- package/dist/static/assets/graph-CS0Pmm7c.js.map +1 -0
- package/dist/static/assets/index-BS6HnGzC.js +112303 -0
- package/dist/static/assets/index-BS6HnGzC.js.map +1 -0
- package/dist/static/assets/index-DaIsSzC_.css +483 -0
- package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js +34 -0
- package/dist/static/assets/infoDiagram-WHAUD3N6-ypBcKfUs.js.map +1 -0
- package/dist/static/assets/init-ZxktEp_H.js +17 -0
- package/dist/static/assets/init-ZxktEp_H.js.map +1 -0
- package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js +1255 -0
- package/dist/static/assets/journeyDiagram-XKPGCS4Q-QnrxDowJ.js.map +1 -0
- package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js +1048 -0
- package/dist/static/assets/kanban-definition-3W4ZIXB7-CfvEc4z5.js.map +1 -0
- package/dist/static/assets/layout-8TGxpm23.js +2218 -0
- package/dist/static/assets/layout-8TGxpm23.js.map +1 -0
- package/dist/static/assets/linear-BATBPQQv.js +341 -0
- package/dist/static/assets/linear-BATBPQQv.js.map +1 -0
- package/dist/static/assets/min-B3oVH3AC.js +42 -0
- package/dist/static/assets/min-B3oVH3AC.js.map +1 -0
- package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js +1127 -0
- package/dist/static/assets/mindmap-definition-VGOIOE7T-L7VLwwF8.js.map +1 -0
- package/dist/static/assets/ordinal-CxptdPJm.js +77 -0
- package/dist/static/assets/ordinal-CxptdPJm.js.map +1 -0
- package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js +241 -0
- package/dist/static/assets/pieDiagram-ADFJNKIX-CFW3zIhM.js.map +1 -0
- package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js +1338 -0
- package/dist/static/assets/quadrantDiagram-AYHSOK5B-B7ssen3E.js.map +1 -0
- package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js +1162 -0
- package/dist/static/assets/requirementDiagram-UZGBJVZJ-D0v5BArv.js.map +1 -0
- package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js +1195 -0
- package/dist/static/assets/sankeyDiagram-TZEHDZUN-B7slncJe.js.map +1 -0
- package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js +3875 -0
- package/dist/static/assets/sequenceDiagram-WL72ISMW-oXU2lRh_.js.map +1 -0
- package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js +452 -0
- package/dist/static/assets/stateDiagram-FKZM4ZOC-CFYsEd0x.js.map +1 -0
- package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js +22 -0
- package/dist/static/assets/stateDiagram-v2-4FDKWEC3-C0UWaNA7.js.map +1 -0
- package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js +1223 -0
- package/dist/static/assets/timeline-definition-IT6M3QCI-C3KODUrh.js.map +1 -0
- package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js +18753 -0
- package/dist/static/assets/treemap-KMMF4GRG-DAGDLhj2.js.map +1 -0
- package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js +1888 -0
- package/dist/static/assets/xychartDiagram-PRI3JC2R-C0J9iwTO.js.map +1 -0
- package/dist/static/index.html +71 -0
- package/dist/static/testing/dom-observation-utils.js +425 -0
- package/dist/static/testing/e2e-test-helper.js +3119 -0
- package/dist/team.js +1160 -0
- package/dist/tellask.js +431 -0
- package/dist/tool.js +150 -0
- package/dist/tools/apply-patch.js +542 -0
- package/dist/tools/builtins.js +196 -0
- package/dist/tools/context-health.js +177 -0
- package/dist/tools/ctrl.js +478 -0
- package/dist/tools/diag.js +583 -0
- package/dist/tools/env.js +184 -0
- package/dist/tools/fs.js +818 -0
- package/dist/tools/mcp.js +138 -0
- package/dist/tools/mem.js +349 -0
- package/dist/tools/os.js +751 -0
- package/dist/tools/prompts/team_mgmt.en.md +70 -0
- package/dist/tools/prompts/team_mgmt.zh.md +70 -0
- package/dist/tools/prompts/ws_mod.en.md +86 -0
- package/dist/tools/prompts/ws_mod.zh.md +87 -0
- package/dist/tools/registry-snapshot.js +31 -0
- package/dist/tools/registry.js +121 -0
- package/dist/tools/ripgrep.js +678 -0
- package/dist/tools/team-mgmt.js +3300 -0
- package/dist/tools/txt.js +3178 -0
- package/dist/utils/id.js +72 -0
- package/dist/utils/task-doc.js +236 -0
- package/dist/utils/task-package.js +522 -0
- package/dist/utils/taskdoc-search.js +280 -0
- package/dist/utils/taskdoc.js +400 -0
- package/package.json +69 -0
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Module: tools/ctrl
|
|
4
|
+
*
|
|
5
|
+
* Intrinsic dialog control tools - ALWAYS AVAILABLE TO ALL AGENTS
|
|
6
|
+
*
|
|
7
|
+
* These tools are automatically included for every agent without needing to be
|
|
8
|
+
* explicitly listed in team.yaml toolsets or tools configuration. They provide
|
|
9
|
+
* core functionality for reminder management and mind control that should be
|
|
10
|
+
* universally accessible.
|
|
11
|
+
*
|
|
12
|
+
* INTRINSIC TOOLS:
|
|
13
|
+
* - add_reminder: Add a reminder
|
|
14
|
+
* - delete_reminder: Delete a reminder by number
|
|
15
|
+
* - update_reminder: Update reminder content
|
|
16
|
+
* - clear_mind: Start a new round, optionally add a reminder
|
|
17
|
+
* - change_mind: Update a `.tsk/` task doc section without starting a new round
|
|
18
|
+
* - recall_taskdoc: Read a Taskdoc section from `*.tsk/` by (category, selector)
|
|
19
|
+
*
|
|
20
|
+
* USAGE CONTEXT:
|
|
21
|
+
* Can both be triggered by an agent autonomously, or by human with role='user' msg,
|
|
22
|
+
* both ways treated the same
|
|
23
|
+
*
|
|
24
|
+
* agents always see reminders in llm input, humans should have some sticky UI component to see the reminders
|
|
25
|
+
* agents should see hints of reminder manip syntax
|
|
26
|
+
* humans should better have clickable UI widgets to draft reminder manips
|
|
27
|
+
*/
|
|
28
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
+
if (k2 === undefined) k2 = k;
|
|
30
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
+
}
|
|
34
|
+
Object.defineProperty(o, k2, desc);
|
|
35
|
+
}) : (function(o, m, k, k2) {
|
|
36
|
+
if (k2 === undefined) k2 = k;
|
|
37
|
+
o[k2] = m[k];
|
|
38
|
+
}));
|
|
39
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
+
}) : function(o, v) {
|
|
42
|
+
o["default"] = v;
|
|
43
|
+
});
|
|
44
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
45
|
+
var ownKeys = function(o) {
|
|
46
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
49
|
+
return ar;
|
|
50
|
+
};
|
|
51
|
+
return ownKeys(o);
|
|
52
|
+
};
|
|
53
|
+
return function (mod) {
|
|
54
|
+
if (mod && mod.__esModule) return mod;
|
|
55
|
+
var result = {};
|
|
56
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
57
|
+
__setModuleDefault(result, mod);
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
})();
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.recallTaskdocTool = exports.changeMindTool = exports.clearMindTool = exports.updateReminderTool = exports.addReminderTool = exports.deleteReminderTool = void 0;
|
|
63
|
+
const fs = __importStar(require("fs"));
|
|
64
|
+
const path = __importStar(require("path"));
|
|
65
|
+
const dialog_1 = require("../dialog");
|
|
66
|
+
const tool_result_messages_1 = require("../shared/i18n/tool-result-messages");
|
|
67
|
+
const runtime_language_1 = require("../shared/runtime-language");
|
|
68
|
+
const task_package_1 = require("../utils/task-package");
|
|
69
|
+
function getCtrlMessages(language) {
|
|
70
|
+
if (language === 'zh') {
|
|
71
|
+
return {
|
|
72
|
+
invalidFormatDelete: '错误:参数不正确。用法:delete_reminder({ reminder_no: number })',
|
|
73
|
+
reminderDoesNotExist: (reminderNoHuman, total) => `错误:提醒编号 ${reminderNoHuman} 不存在。可用范围:1-${total}`,
|
|
74
|
+
invalidFormatAdd: '错误:参数不正确。用法:add_reminder({ content: string, position: number })(position=0 表示默认追加)',
|
|
75
|
+
reminderContentEmpty: '错误:提醒内容不能为空',
|
|
76
|
+
invalidReminderPosition: (reminderNoHuman, totalPlusOne) => `错误:提醒插入位置 ${reminderNoHuman} 无效。有效范围:1-${totalPlusOne}`,
|
|
77
|
+
invalidFormatUpdate: '错误:参数不正确。用法:update_reminder({ reminder_no: number, content: string })',
|
|
78
|
+
invalidFormatChangeMind: '错误:参数不正确。用法:change_mind({ selector: string, category?: string, content: string })',
|
|
79
|
+
tooManyArgsChangeMind: '错误:参数不正确。用法:change_mind({ selector: string, category?: string, content: string })',
|
|
80
|
+
invalidFormatRecallTaskdoc: '错误:参数不正确。用法:recall_taskdoc({ category: string, selector: string })',
|
|
81
|
+
taskDocContentRequired: '错误:需要提供差遣牒内容(content)。\n' +
|
|
82
|
+
'可复制示例:\n' +
|
|
83
|
+
'```json\n' +
|
|
84
|
+
'{\n' +
|
|
85
|
+
' "selector": "progress",\n' +
|
|
86
|
+
' "content": "- 关键决策:...\\n- 下一步:..."\n' +
|
|
87
|
+
'}\n' +
|
|
88
|
+
'```',
|
|
89
|
+
noTaskDocPathConfigured: '错误:此对话未配置差遣牒路径',
|
|
90
|
+
pathMustBeWithinWorkspace: '错误:路径必须位于工作区内',
|
|
91
|
+
invalidTaskDocPath: (taskDocPath) => `错误:差遣牒路径 '${taskDocPath}' 无效。期望为 \`*.tsk/\` 目录。`,
|
|
92
|
+
selectorRequired: '错误:需要提供选择器(selector)。',
|
|
93
|
+
categoryRequired: '错误:需要提供章节目录(category)。',
|
|
94
|
+
invalidSelector: (selector) => `错误:选择器 '${selector}' 无效。用法:顶层 goals | constraints | progress;bearinmind 下 contracts | acceptance | grants | runbook | decisions | risks;或任意合法 identifier(例如 \`ux.checklist\`)。`,
|
|
95
|
+
invalidCategory: (category) => `错误:目录名(category)'${category}' 无效。必须匹配 \`^[a-zA-Z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*$\`。`,
|
|
96
|
+
invalidCategorySelector: (selector) => `错误:目录内选择器(selector)'${selector}' 无效。必须匹配 \`^[a-zA-Z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*$\`。`,
|
|
97
|
+
topLevelSelectorRequiresNoCategory: (category, selector) => `错误:选择器 '${selector}' 是顶层保留分段(goals/constraints/progress),不得与 category='${category}' 一起使用。`,
|
|
98
|
+
bearInMindSelectorRequiresBearInMindCategory: (category, selector) => `错误:选择器 '${selector}' 仅允许在 category='bearinmind' 下使用(当前 category='${category}')。`,
|
|
99
|
+
taskDocSectionMissing: (relativePath) => `未找到:\`${relativePath}\`。\n\n可用 \`change_mind\` 创建或更新该章节(它会整段替换):\n- \`change_mind({\"category\":\"<category>\",\"selector\":\"<selector>\",\"content\":\"...\"})\``,
|
|
100
|
+
clearedRoundPrompt: (nextRound) => `这是对话的第 #${nextRound} 轮,你刚清理了思路,请继续执行任务。`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
invalidFormatDelete: 'Error: Invalid args. Use: delete_reminder({ reminder_no: number })',
|
|
105
|
+
reminderDoesNotExist: (reminderNoHuman, total) => `Error: Reminder number ${reminderNoHuman} does not exist. Available reminders: 1-${total}`,
|
|
106
|
+
invalidFormatAdd: 'Error: Invalid args. Use: add_reminder({ content: string, position: number }) (position=0 means append).',
|
|
107
|
+
reminderContentEmpty: 'Error: Reminder content cannot be empty',
|
|
108
|
+
invalidReminderPosition: (reminderNoHuman, totalPlusOne) => `Error: Invalid reminder position ${reminderNoHuman}. Valid range: 1-${totalPlusOne}`,
|
|
109
|
+
invalidFormatUpdate: 'Error: Invalid args. Use: update_reminder({ reminder_no: number, content: string })',
|
|
110
|
+
invalidFormatChangeMind: 'Error: Invalid args. Use: change_mind({ selector: string, category?: string, content: string })',
|
|
111
|
+
tooManyArgsChangeMind: 'Error: Invalid args. Use: change_mind({ selector: string, category?: string, content: string })',
|
|
112
|
+
invalidFormatRecallTaskdoc: 'Error: Invalid args. Use: recall_taskdoc({ category: string, selector: string })',
|
|
113
|
+
taskDocContentRequired: 'Error: Taskdoc content is required (content).\n' +
|
|
114
|
+
'Copy/paste example:\n' +
|
|
115
|
+
'```json\n' +
|
|
116
|
+
'{\n' +
|
|
117
|
+
' "selector": "progress",\n' +
|
|
118
|
+
' "content": "- Key decisions: ...\\n- Next steps: ..."\n' +
|
|
119
|
+
'}\n' +
|
|
120
|
+
'```',
|
|
121
|
+
noTaskDocPathConfigured: 'Error: No task doc path configured for this dialog',
|
|
122
|
+
pathMustBeWithinWorkspace: 'Error: Path must be within workspace',
|
|
123
|
+
invalidTaskDocPath: (taskDocPath) => `Error: Invalid Taskdoc path '${taskDocPath}'. Expected a \`*.tsk/\` directory.`,
|
|
124
|
+
selectorRequired: 'Error: selector is required.',
|
|
125
|
+
categoryRequired: 'Error: category is required.',
|
|
126
|
+
invalidSelector: (selector) => `Error: Invalid selector '${selector}'. Use: top-level goals|constraints|progress; under bearinmind: contracts|acceptance|grants|runbook|decisions|risks; or any identifier (e.g. \`ux.checklist\`).`,
|
|
127
|
+
invalidCategory: (category) => `Error: Invalid category '${category}'. Must match \`^[a-zA-Z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*$\`.`,
|
|
128
|
+
invalidCategorySelector: (selector) => `Error: Invalid category selector '${selector}'. Must match \`^[a-zA-Z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9_-]+)*$\`.`,
|
|
129
|
+
topLevelSelectorRequiresNoCategory: (category, selector) => `Error: Selector '${selector}' is reserved for top-level sections (goals/constraints/progress) and must not be used with category='${category}'.`,
|
|
130
|
+
bearInMindSelectorRequiresBearInMindCategory: (category, selector) => `Error: Selector '${selector}' is only valid under category='bearinmind' (got category='${category}').`,
|
|
131
|
+
taskDocSectionMissing: (relativePath) => `Not found: \`${relativePath}\`.\n\nUse \`change_mind\` to create/update it (whole-section replace):\n- \`change_mind({\"category\":\"<category>\",\"selector\":\"<selector>\",\"content\":\"...\"})\``,
|
|
132
|
+
clearedRoundPrompt: (nextRound) => `This is round #${nextRound} of the dialog, you just cleared your mind and please proceed with the task.`,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
exports.deleteReminderTool = {
|
|
136
|
+
type: 'func',
|
|
137
|
+
name: 'delete_reminder',
|
|
138
|
+
description: 'Delete a reminder by its 1-based number.',
|
|
139
|
+
descriptionI18n: {
|
|
140
|
+
en: 'Delete a reminder by its 1-based number.',
|
|
141
|
+
zh: '按 1-based 编号删除提醒。',
|
|
142
|
+
},
|
|
143
|
+
parameters: {
|
|
144
|
+
type: 'object',
|
|
145
|
+
additionalProperties: false,
|
|
146
|
+
required: ['reminder_no'],
|
|
147
|
+
properties: {
|
|
148
|
+
reminder_no: { type: 'integer', description: 'Reminder number (1-based).' },
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
argsValidation: 'dominds',
|
|
152
|
+
async call(dlg, _caller, args) {
|
|
153
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
154
|
+
const t = getCtrlMessages(language);
|
|
155
|
+
const reminderNoValue = args['reminder_no'];
|
|
156
|
+
if (typeof reminderNoValue !== 'number' || !Number.isInteger(reminderNoValue)) {
|
|
157
|
+
return t.invalidFormatDelete;
|
|
158
|
+
}
|
|
159
|
+
const reminderNo = reminderNoValue - 1; // Convert to 0-based index
|
|
160
|
+
if (reminderNo < 0 || reminderNo >= dlg.reminders.length) {
|
|
161
|
+
return t.reminderDoesNotExist(String(reminderNoValue), dlg.reminders.length);
|
|
162
|
+
}
|
|
163
|
+
dlg.deleteReminder(reminderNo);
|
|
164
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'deleted');
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
exports.addReminderTool = {
|
|
168
|
+
type: 'func',
|
|
169
|
+
name: 'add_reminder',
|
|
170
|
+
description: 'Add a reminder, optionally inserting at a 1-based position.',
|
|
171
|
+
descriptionI18n: {
|
|
172
|
+
en: 'Add a reminder, optionally inserting at a 1-based position.',
|
|
173
|
+
zh: '添加提醒,可选指定 1-based 插入位置。',
|
|
174
|
+
},
|
|
175
|
+
parameters: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
additionalProperties: false,
|
|
178
|
+
required: ['content'],
|
|
179
|
+
properties: {
|
|
180
|
+
content: { type: 'string', description: 'Reminder content.' },
|
|
181
|
+
position: { type: 'integer', description: 'Insert position (1-based). Defaults to append.' },
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
argsValidation: 'dominds',
|
|
185
|
+
async call(dlg, _caller, args) {
|
|
186
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
187
|
+
const t = getCtrlMessages(language);
|
|
188
|
+
const contentValue = args['content'];
|
|
189
|
+
const reminderContent = typeof contentValue === 'string' ? contentValue.trim() : '';
|
|
190
|
+
if (!reminderContent)
|
|
191
|
+
return t.reminderContentEmpty;
|
|
192
|
+
const positionValue = args['position'];
|
|
193
|
+
let insertIndex = dlg.reminders.length;
|
|
194
|
+
// Codex provider requires all func args to be schema-required; we use position=0 as sentinel for "append".
|
|
195
|
+
if (positionValue !== undefined && positionValue !== 0) {
|
|
196
|
+
if (typeof positionValue !== 'number' || !Number.isInteger(positionValue)) {
|
|
197
|
+
return t.invalidFormatAdd;
|
|
198
|
+
}
|
|
199
|
+
insertIndex = positionValue - 1;
|
|
200
|
+
if (insertIndex < 0 || insertIndex > dlg.reminders.length) {
|
|
201
|
+
return t.invalidReminderPosition(String(positionValue), dlg.reminders.length + 1);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
dlg.addReminder(reminderContent, undefined, undefined, insertIndex);
|
|
205
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'added');
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
exports.updateReminderTool = {
|
|
209
|
+
type: 'func',
|
|
210
|
+
name: 'update_reminder',
|
|
211
|
+
description: 'Update an existing reminder by its 1-based number.',
|
|
212
|
+
descriptionI18n: {
|
|
213
|
+
en: 'Update an existing reminder by its 1-based number.',
|
|
214
|
+
zh: '按 1-based 编号更新提醒内容。',
|
|
215
|
+
},
|
|
216
|
+
parameters: {
|
|
217
|
+
type: 'object',
|
|
218
|
+
additionalProperties: false,
|
|
219
|
+
required: ['reminder_no', 'content'],
|
|
220
|
+
properties: {
|
|
221
|
+
reminder_no: { type: 'integer', description: 'Reminder number (1-based).' },
|
|
222
|
+
content: { type: 'string', description: 'New reminder content.' },
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
argsValidation: 'dominds',
|
|
226
|
+
async call(dlg, _caller, args) {
|
|
227
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
228
|
+
const t = getCtrlMessages(language);
|
|
229
|
+
const reminderNoValue = args['reminder_no'];
|
|
230
|
+
if (typeof reminderNoValue !== 'number' || !Number.isInteger(reminderNoValue)) {
|
|
231
|
+
return t.invalidFormatUpdate;
|
|
232
|
+
}
|
|
233
|
+
const reminderNo = reminderNoValue - 1;
|
|
234
|
+
if (reminderNo < 0 || reminderNo >= dlg.reminders.length) {
|
|
235
|
+
return t.reminderDoesNotExist(String(reminderNoValue), dlg.reminders.length);
|
|
236
|
+
}
|
|
237
|
+
const contentValue = args['content'];
|
|
238
|
+
const reminderContent = typeof contentValue === 'string' ? contentValue.trim() : '';
|
|
239
|
+
if (!reminderContent)
|
|
240
|
+
return t.reminderContentEmpty;
|
|
241
|
+
dlg.updateReminder(reminderNo, reminderContent);
|
|
242
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'updated');
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
exports.clearMindTool = {
|
|
246
|
+
type: 'func',
|
|
247
|
+
name: 'clear_mind',
|
|
248
|
+
description: 'Clear dialog mind and start a new round, optionally adding a reminder.',
|
|
249
|
+
descriptionI18n: {
|
|
250
|
+
en: 'Clear dialog mind and start a new round, optionally adding a reminder.',
|
|
251
|
+
zh: '清空思路并开始新一轮,可选添加一条提醒。',
|
|
252
|
+
},
|
|
253
|
+
parameters: {
|
|
254
|
+
type: 'object',
|
|
255
|
+
additionalProperties: false,
|
|
256
|
+
properties: {
|
|
257
|
+
reminder_content: { type: 'string', description: 'Optional reminder content to add.' },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
argsValidation: 'dominds',
|
|
261
|
+
async call(dlg, _caller, args) {
|
|
262
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
263
|
+
const t = getCtrlMessages(language);
|
|
264
|
+
const reminderValue = args['reminder_content'];
|
|
265
|
+
const reminderContent = typeof reminderValue === 'string' ? reminderValue.trim() : '';
|
|
266
|
+
if (reminderContent) {
|
|
267
|
+
dlg.addReminder(reminderContent);
|
|
268
|
+
}
|
|
269
|
+
await dlg.startNewRound(t.clearedRoundPrompt(dlg.currentRound + 1));
|
|
270
|
+
// Context health snapshot is inherently tied to the previous prompt/context.
|
|
271
|
+
// After clearing, invalidate it so the next generation can recompute without
|
|
272
|
+
// stale remediation based on the old (large) context.
|
|
273
|
+
dlg.setLastContextHealth({ kind: 'unavailable', reason: 'usage_unavailable' });
|
|
274
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'mindCleared');
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
exports.changeMindTool = {
|
|
278
|
+
type: 'func',
|
|
279
|
+
name: 'change_mind',
|
|
280
|
+
description: 'Update a shared Taskdoc section (`*.tsk/`) in the main dialog without resetting the round. Each call replaces the entire section; merge carefully and avoid overwriting other contributors.',
|
|
281
|
+
descriptionI18n: {
|
|
282
|
+
en: 'Update a shared Taskdoc section (`*.tsk/`) in the main dialog without resetting the round. Each call replaces the entire section; merge carefully and avoid overwriting other contributors. Note: Taskdoc is injected into context; do not try to read `*.tsk/` via general file tools.',
|
|
283
|
+
zh: '在主对话中更新全队共享差遣牒(`*.tsk/`)的指定章节(不重置轮次)。每次调用会替换该章节全文;更新前必须基于现有内容做合并/压缩,避免覆盖他人条目;建议为自己维护的条目标注责任人(如 `[owner:@<id>]`)。注意:差遣牒内容已被注入到上下文中;不要试图用通用文件工具读取 `*.tsk/` 下的文件(会被拒绝)。',
|
|
284
|
+
},
|
|
285
|
+
parameters: {
|
|
286
|
+
type: 'object',
|
|
287
|
+
additionalProperties: false,
|
|
288
|
+
required: ['selector', 'content'],
|
|
289
|
+
properties: {
|
|
290
|
+
selector: {
|
|
291
|
+
type: 'string',
|
|
292
|
+
description: 'Target section selector. Top-level: goals|constraints|progress. Under category="bearinmind": contracts|acceptance|grants|runbook|decisions|risks. For other categories: any identifier.',
|
|
293
|
+
},
|
|
294
|
+
category: {
|
|
295
|
+
type: 'string',
|
|
296
|
+
description: 'Optional category directory within the Taskdoc package. When present, selector targets <category>/<selector>.md.',
|
|
297
|
+
},
|
|
298
|
+
content: { type: 'string', description: 'New section content.' },
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
argsValidation: 'dominds',
|
|
302
|
+
async call(dlg, caller, args) {
|
|
303
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
304
|
+
const t = getCtrlMessages(language);
|
|
305
|
+
if (dlg.supdialog !== undefined) {
|
|
306
|
+
const maintainerId = dlg instanceof dialog_1.SubDialog ? dlg.rootDialog.agentId : dlg.agentId;
|
|
307
|
+
if (language === 'zh') {
|
|
308
|
+
return (`错误:\`change_mind\` 仅允许在主对话中使用(子对话中不可用)。\n` +
|
|
309
|
+
`请诉请差遣牒维护人 @${maintainerId} 在其对话中执行 \`change_mind\`,并提供你已合并好的“分段全文替换稿”(禁止覆盖/抹掉他人条目)。`);
|
|
310
|
+
}
|
|
311
|
+
return (`Error: \`change_mind\` is only available in the main dialog (not in subdialogs).\n` +
|
|
312
|
+
`Ask the Taskdoc maintainer @${maintainerId} to run \`change_mind\` and provide a fully merged full-section replacement draft (do not overwrite/delete other contributors).`);
|
|
313
|
+
}
|
|
314
|
+
const selectorValue = args['selector'];
|
|
315
|
+
const selector = typeof selectorValue === 'string' ? selectorValue.trim() : '';
|
|
316
|
+
if (!selector)
|
|
317
|
+
return t.selectorRequired;
|
|
318
|
+
const categoryValue = args['category'];
|
|
319
|
+
const category = typeof categoryValue === 'string' ? categoryValue.trim() : undefined;
|
|
320
|
+
const contentValue = args['content'];
|
|
321
|
+
const newTaskDocContent = typeof contentValue === 'string' ? contentValue.trim() : '';
|
|
322
|
+
if (!newTaskDocContent)
|
|
323
|
+
return t.taskDocContentRequired;
|
|
324
|
+
// Task doc path is immutable for the dialog lifecycle.
|
|
325
|
+
const taskDocPath = dlg.taskDocPath;
|
|
326
|
+
if (!taskDocPath)
|
|
327
|
+
return t.noTaskDocPathConfigured;
|
|
328
|
+
const workspaceRoot = path.resolve(process.cwd());
|
|
329
|
+
const fullPath = path.resolve(workspaceRoot, taskDocPath);
|
|
330
|
+
if (!fullPath.startsWith(workspaceRoot))
|
|
331
|
+
return t.pathMustBeWithinWorkspace;
|
|
332
|
+
if (!(0, task_package_1.isTaskPackagePath)(taskDocPath))
|
|
333
|
+
return t.invalidTaskDocPath(taskDocPath);
|
|
334
|
+
const parsed = (0, task_package_1.parseTaskPackageChangeMindTarget)({ selector, category });
|
|
335
|
+
if (parsed.kind !== 'ok') {
|
|
336
|
+
const e = parsed.error;
|
|
337
|
+
switch (e.kind) {
|
|
338
|
+
case 'selector_required':
|
|
339
|
+
return t.selectorRequired;
|
|
340
|
+
case 'invalid_category_name':
|
|
341
|
+
return t.invalidCategory(e.category);
|
|
342
|
+
case 'invalid_category_selector':
|
|
343
|
+
return t.invalidCategorySelector(e.selector);
|
|
344
|
+
case 'invalid_top_level_selector':
|
|
345
|
+
return t.invalidSelector(e.selector);
|
|
346
|
+
case 'invalid_bearinmind_selector':
|
|
347
|
+
return t.invalidSelector(e.selector);
|
|
348
|
+
case 'top_level_selector_requires_no_category':
|
|
349
|
+
return t.topLevelSelectorRequiresNoCategory(e.category, e.selector);
|
|
350
|
+
case 'bearinmind_selector_requires_bearinmind_category':
|
|
351
|
+
return t.bearInMindSelectorRequiresBearInMindCategory(e.category, e.selector);
|
|
352
|
+
default: {
|
|
353
|
+
const _exhaustive = e;
|
|
354
|
+
return String(_exhaustive);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
await (0, task_package_1.updateTaskPackageByChangeMindTarget)({
|
|
359
|
+
taskPackageDirFullPath: fullPath,
|
|
360
|
+
target: parsed.target,
|
|
361
|
+
content: newTaskDocContent,
|
|
362
|
+
updatedBy: caller.id,
|
|
363
|
+
});
|
|
364
|
+
return (0, tool_result_messages_1.formatToolActionResult)(language, 'mindChanged');
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
exports.recallTaskdocTool = {
|
|
368
|
+
type: 'func',
|
|
369
|
+
name: 'recall_taskdoc',
|
|
370
|
+
description: 'Read a Taskdoc section from an encapsulated `*.tsk/` package by (category, selector). Use this when the section is not auto-injected and general file tools cannot access `*.tsk/`.',
|
|
371
|
+
descriptionI18n: {
|
|
372
|
+
en: 'Read a Taskdoc section from an encapsulated `*.tsk/` package by (category, selector). Use this when the section is not auto-injected and general file tools cannot access `*.tsk/`.',
|
|
373
|
+
zh: '按 (category, selector) 读取封装差遣牒(`*.tsk/`)中“不会自动注入上下文”的章节。用于在通用文件工具无法读取 `*.tsk/` 的前提下显式取回章节内容。',
|
|
374
|
+
},
|
|
375
|
+
parameters: {
|
|
376
|
+
type: 'object',
|
|
377
|
+
additionalProperties: false,
|
|
378
|
+
required: ['category', 'selector'],
|
|
379
|
+
properties: {
|
|
380
|
+
category: { type: 'string', description: 'Category directory within the Taskdoc.' },
|
|
381
|
+
selector: { type: 'string', description: 'Section selector within the category.' },
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
argsValidation: 'dominds',
|
|
385
|
+
async call(dlg, _caller, args) {
|
|
386
|
+
const language = (0, runtime_language_1.getWorkLanguage)();
|
|
387
|
+
const t = getCtrlMessages(language);
|
|
388
|
+
const categoryValue = args['category'];
|
|
389
|
+
const category = typeof categoryValue === 'string' ? categoryValue.trim() : '';
|
|
390
|
+
if (category === '')
|
|
391
|
+
return t.categoryRequired;
|
|
392
|
+
const selectorValue = args['selector'];
|
|
393
|
+
const selector = typeof selectorValue === 'string' ? selectorValue.trim() : '';
|
|
394
|
+
if (selector === '')
|
|
395
|
+
return t.selectorRequired;
|
|
396
|
+
// Task doc path is immutable for the dialog lifecycle.
|
|
397
|
+
const taskDocPath = dlg.taskDocPath;
|
|
398
|
+
if (!taskDocPath)
|
|
399
|
+
return t.noTaskDocPathConfigured;
|
|
400
|
+
const workspaceRoot = path.resolve(process.cwd());
|
|
401
|
+
const fullPath = path.resolve(workspaceRoot, taskDocPath);
|
|
402
|
+
if (!fullPath.startsWith(workspaceRoot))
|
|
403
|
+
return t.pathMustBeWithinWorkspace;
|
|
404
|
+
if (!(0, task_package_1.isTaskPackagePath)(taskDocPath))
|
|
405
|
+
return t.invalidTaskDocPath(taskDocPath);
|
|
406
|
+
const parsed = (0, task_package_1.parseTaskPackageChangeMindTarget)({ selector, category });
|
|
407
|
+
if (parsed.kind !== 'ok') {
|
|
408
|
+
const e = parsed.error;
|
|
409
|
+
switch (e.kind) {
|
|
410
|
+
case 'selector_required':
|
|
411
|
+
return t.selectorRequired;
|
|
412
|
+
case 'invalid_category_name':
|
|
413
|
+
return t.invalidCategory(e.category);
|
|
414
|
+
case 'invalid_category_selector':
|
|
415
|
+
return t.invalidCategorySelector(e.selector);
|
|
416
|
+
case 'invalid_top_level_selector':
|
|
417
|
+
return t.invalidSelector(e.selector);
|
|
418
|
+
case 'invalid_bearinmind_selector':
|
|
419
|
+
return t.invalidSelector(e.selector);
|
|
420
|
+
case 'top_level_selector_requires_no_category':
|
|
421
|
+
return t.topLevelSelectorRequiresNoCategory(e.category, e.selector);
|
|
422
|
+
case 'bearinmind_selector_requires_bearinmind_category':
|
|
423
|
+
return t.bearInMindSelectorRequiresBearInMindCategory(e.category, e.selector);
|
|
424
|
+
default: {
|
|
425
|
+
const _exhaustive = e;
|
|
426
|
+
return String(_exhaustive);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
const target = parsed.target;
|
|
431
|
+
const relPath = (() => {
|
|
432
|
+
switch (target.kind) {
|
|
433
|
+
case 'bearinmind':
|
|
434
|
+
return path.join('bearinmind', (0, task_package_1.bearInMindFilenameForSection)(target.section));
|
|
435
|
+
case 'category':
|
|
436
|
+
return path.join(target.category, `${target.selector}.md`);
|
|
437
|
+
case 'top_level':
|
|
438
|
+
return null;
|
|
439
|
+
default: {
|
|
440
|
+
const _exhaustive = target;
|
|
441
|
+
return _exhaustive;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
})();
|
|
445
|
+
if (relPath === null) {
|
|
446
|
+
return t.invalidFormatRecallTaskdoc;
|
|
447
|
+
}
|
|
448
|
+
const sectionPath = path.resolve(fullPath, relPath);
|
|
449
|
+
if (!sectionPath.startsWith(fullPath)) {
|
|
450
|
+
return t.pathMustBeWithinWorkspace;
|
|
451
|
+
}
|
|
452
|
+
try {
|
|
453
|
+
const st = await fs.promises.stat(sectionPath);
|
|
454
|
+
if (!st.isFile()) {
|
|
455
|
+
return t.taskDocSectionMissing(relPath);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
catch (err) {
|
|
459
|
+
if (typeof err === 'object' &&
|
|
460
|
+
err !== null &&
|
|
461
|
+
'code' in err &&
|
|
462
|
+
err.code === 'ENOENT') {
|
|
463
|
+
return t.taskDocSectionMissing(relPath);
|
|
464
|
+
}
|
|
465
|
+
throw err;
|
|
466
|
+
}
|
|
467
|
+
const content = await fs.promises.readFile(sectionPath, 'utf8');
|
|
468
|
+
const bytes = Buffer.byteLength(content, 'utf8');
|
|
469
|
+
const maxSize = 100 * 1024;
|
|
470
|
+
const clipped = bytes > maxSize ? content.slice(0, maxSize) : content;
|
|
471
|
+
const note = bytes > maxSize
|
|
472
|
+
? language === 'zh'
|
|
473
|
+
? `\n\n⚠️ 已截断:内容过大(${bytes} bytes),仅回显前 ${maxSize} bytes。`
|
|
474
|
+
: `\n\n⚠️ Truncated: content is too large (${bytes} bytes); showing first ${maxSize} bytes.`
|
|
475
|
+
: '';
|
|
476
|
+
return `**recall_taskdoc:** \`${relPath}\`\n\n---\n${clipped}\n---${note}`;
|
|
477
|
+
},
|
|
478
|
+
};
|