onlycode 1.18.0 → 1.20.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/bin/{opencode.cjs → onlycode.cjs} +8 -42
- package/package.json +12 -147
- package/src/account/account.ts +0 -463
- package/src/account/repo.ts +0 -173
- package/src/account/schema.ts +0 -99
- package/src/account/url.ts +0 -8
- package/src/acp/agent.ts +0 -95
- package/src/acp/config-option.ts +0 -203
- package/src/acp/content.ts +0 -250
- package/src/acp/directory.ts +0 -210
- package/src/acp/error.ts +0 -90
- package/src/acp/event.ts +0 -342
- package/src/acp/permission.ts +0 -124
- package/src/acp/profile.ts +0 -42
- package/src/acp/service.ts +0 -1048
- package/src/acp/session.ts +0 -231
- package/src/acp/tool.ts +0 -367
- package/src/acp/usage.ts +0 -232
- package/src/agent/agent.ts +0 -459
- package/src/agent/generate.txt +0 -75
- package/src/agent/prompt/compaction.txt +0 -9
- package/src/agent/prompt/explore.txt +0 -18
- package/src/agent/prompt/summary.txt +0 -11
- package/src/agent/prompt/title.txt +0 -44
- package/src/agent/subagent-permissions.ts +0 -27
- package/src/audio.d.ts +0 -14
- package/src/auth/index.ts +0 -99
- package/src/background/job.ts +0 -39
- package/src/bus/global.ts +0 -22
- package/src/cli/bootstrap.ts +0 -11
- package/src/cli/cmd/account.ts +0 -264
- package/src/cli/cmd/acp.ts +0 -73
- package/src/cli/cmd/agent.ts +0 -259
- package/src/cli/cmd/attach.ts +0 -97
- package/src/cli/cmd/cmd.ts +0 -7
- package/src/cli/cmd/db.ts +0 -62
- package/src/cli/cmd/debug/agent.handler.ts +0 -193
- package/src/cli/cmd/debug/agent.ts +0 -27
- package/src/cli/cmd/debug/config.ts +0 -14
- package/src/cli/cmd/debug/file.ts +0 -73
- package/src/cli/cmd/debug/index.ts +0 -87
- package/src/cli/cmd/debug/lsp.ts +0 -50
- package/src/cli/cmd/debug/ripgrep.ts +0 -79
- package/src/cli/cmd/debug/scrap.ts +0 -15
- package/src/cli/cmd/debug/skill.ts +0 -15
- package/src/cli/cmd/debug/snapshot.ts +0 -50
- package/src/cli/cmd/debug/startup.ts +0 -11
- package/src/cli/cmd/debug/v2.ts +0 -44
- package/src/cli/cmd/export.ts +0 -292
- package/src/cli/cmd/generate.ts +0 -54
- package/src/cli/cmd/github.handler.ts +0 -1593
- package/src/cli/cmd/github.shared.ts +0 -30
- package/src/cli/cmd/github.ts +0 -42
- package/src/cli/cmd/import.ts +0 -224
- package/src/cli/cmd/mcp.ts +0 -849
- package/src/cli/cmd/models.ts +0 -66
- package/src/cli/cmd/plug.ts +0 -230
- package/src/cli/cmd/pr.ts +0 -115
- package/src/cli/cmd/prompt-display.ts +0 -1
- package/src/cli/cmd/providers.ts +0 -534
- package/src/cli/cmd/run/demo.ts +0 -1274
- package/src/cli/cmd/run/entry.body.ts +0 -205
- package/src/cli/cmd/run/footer.command.tsx +0 -1064
- package/src/cli/cmd/run/footer.menu.tsx +0 -351
- package/src/cli/cmd/run/footer.permission.tsx +0 -472
- package/src/cli/cmd/run/footer.prompt.tsx +0 -1306
- package/src/cli/cmd/run/footer.question.tsx +0 -573
- package/src/cli/cmd/run/footer.subagent.tsx +0 -173
- package/src/cli/cmd/run/footer.ts +0 -1129
- package/src/cli/cmd/run/footer.view.tsx +0 -943
- package/src/cli/cmd/run/footer.width.ts +0 -27
- package/src/cli/cmd/run/permission.shared.ts +0 -256
- package/src/cli/cmd/run/prompt.editor.ts +0 -157
- package/src/cli/cmd/run/prompt.shared.ts +0 -153
- package/src/cli/cmd/run/question.shared.ts +0 -340
- package/src/cli/cmd/run/runtime.boot.ts +0 -202
- package/src/cli/cmd/run/runtime.lifecycle.ts +0 -406
- package/src/cli/cmd/run/runtime.queue.ts +0 -349
- package/src/cli/cmd/run/runtime.shared.ts +0 -17
- package/src/cli/cmd/run/runtime.stdin.ts +0 -37
- package/src/cli/cmd/run/runtime.ts +0 -814
- package/src/cli/cmd/run/scrollback.shared.ts +0 -92
- package/src/cli/cmd/run/scrollback.surface.ts +0 -431
- package/src/cli/cmd/run/scrollback.writer.tsx +0 -352
- package/src/cli/cmd/run/session-data.ts +0 -1113
- package/src/cli/cmd/run/session-replay.ts +0 -374
- package/src/cli/cmd/run/session.shared.ts +0 -196
- package/src/cli/cmd/run/splash.ts +0 -275
- package/src/cli/cmd/run/stream.transport.ts +0 -1462
- package/src/cli/cmd/run/stream.ts +0 -175
- package/src/cli/cmd/run/subagent-data.ts +0 -876
- package/src/cli/cmd/run/theme.ts +0 -690
- package/src/cli/cmd/run/tool.ts +0 -1489
- package/src/cli/cmd/run/trace.ts +0 -94
- package/src/cli/cmd/run/turn-summary.ts +0 -47
- package/src/cli/cmd/run/types.ts +0 -350
- package/src/cli/cmd/run/variant.shared.ts +0 -215
- package/src/cli/cmd/run.ts +0 -894
- package/src/cli/cmd/serve.ts +0 -24
- package/src/cli/cmd/session.ts +0 -147
- package/src/cli/cmd/stats.ts +0 -393
- package/src/cli/cmd/tui.ts +0 -224
- package/src/cli/cmd/uninstall.ts +0 -353
- package/src/cli/cmd/upgrade.ts +0 -74
- package/src/cli/cmd/web.ts +0 -84
- package/src/cli/effect/prompt.ts +0 -37
- package/src/cli/effect-cmd.ts +0 -96
- package/src/cli/error.ts +0 -130
- package/src/cli/heap.ts +0 -45
- package/src/cli/logo-pixel.ts +0 -35
- package/src/cli/logo.ts +0 -1
- package/src/cli/network.ts +0 -64
- package/src/cli/tui/layer.ts +0 -7
- package/src/cli/tui/validate-session.ts +0 -29
- package/src/cli/tui/worker.ts +0 -71
- package/src/cli/ui.ts +0 -148
- package/src/cli/upgrade.ts +0 -53
- package/src/command/index.ts +0 -184
- package/src/command/template/initialize.txt +0 -66
- package/src/command/template/review.txt +0 -101
- package/src/config/agent.ts +0 -59
- package/src/config/command.ts +0 -39
- package/src/config/config.ts +0 -686
- package/src/config/entry-name.ts +0 -19
- package/src/config/managed.ts +0 -69
- package/src/config/markdown.ts +0 -36
- package/src/config/parse.ts +0 -79
- package/src/config/paths.ts +0 -45
- package/src/config/plugin.ts +0 -79
- package/src/config/tui-cwd.ts +0 -5
- package/src/config/tui-host-attention.ts +0 -21
- package/src/config/tui-migrate.ts +0 -132
- package/src/config/tui.ts +0 -274
- package/src/config/variable.ts +0 -91
- package/src/control-plane/adapters/index.ts +0 -41
- package/src/control-plane/adapters/worktree.ts +0 -96
- package/src/control-plane/dev/README.md +0 -19
- package/src/control-plane/dev/debug-workspace-plugin.ts +0 -73
- package/src/control-plane/types.ts +0 -59
- package/src/control-plane/util.ts +0 -39
- package/src/control-plane/workspace-adapter-runtime.ts +0 -51
- package/src/control-plane/workspace-context.ts +0 -26
- package/src/control-plane/workspace.ts +0 -989
- package/src/effect/app-runtime.ts +0 -132
- package/src/effect/bootstrap-runtime.ts +0 -23
- package/src/effect/bridge.ts +0 -84
- package/src/effect/config-service.ts +0 -67
- package/src/effect/instance-ref.ts +0 -11
- package/src/effect/instance-registry.ts +0 -12
- package/src/effect/instance-state.ts +0 -69
- package/src/effect/promise.ts +0 -17
- package/src/effect/run-service.ts +0 -47
- package/src/effect/runner.ts +0 -217
- package/src/effect/runtime-flags.ts +0 -79
- package/src/env/index.ts +0 -43
- package/src/event-v2-bridge.ts +0 -79
- package/src/format/formatter.ts +0 -404
- package/src/format/index.ts +0 -205
- package/src/git/index.ts +0 -350
- package/src/id/id.ts +0 -80
- package/src/ide/index.ts +0 -61
- package/src/image/image.ts +0 -174
- package/src/index.ts +0 -142
- package/src/installation/index.ts +0 -350
- package/src/lsp/client.ts +0 -650
- package/src/lsp/diagnostic.ts +0 -29
- package/src/lsp/language.ts +0 -121
- package/src/lsp/launch.ts +0 -21
- package/src/lsp/lsp.ts +0 -511
- package/src/lsp/server.ts +0 -1983
- package/src/markdown.d.ts +0 -4
- package/src/mcp/auth.ts +0 -174
- package/src/mcp/catalog.ts +0 -153
- package/src/mcp/index.ts +0 -953
- package/src/mcp/oauth-callback.ts +0 -233
- package/src/mcp/oauth-provider.ts +0 -206
- package/src/node.ts +0 -4
- package/src/patch/index.ts +0 -686
- package/src/permission/arity.ts +0 -163
- package/src/permission/evaluate.ts +0 -1
- package/src/permission/index.ts +0 -230
- package/src/plugin/azure.ts +0 -26
- package/src/plugin/cloudflare.ts +0 -76
- package/src/plugin/digitalocean.ts +0 -383
- package/src/plugin/github-copilot/copilot.ts +0 -414
- package/src/plugin/github-copilot/models.ts +0 -246
- package/src/plugin/index.ts +0 -316
- package/src/plugin/install.ts +0 -439
- package/src/plugin/loader.ts +0 -237
- package/src/plugin/meta.ts +0 -188
- package/src/plugin/openai/README.md +0 -31
- package/src/plugin/openai/codex.ts +0 -641
- package/src/plugin/openai/ws-pool.ts +0 -270
- package/src/plugin/openai/ws.ts +0 -381
- package/src/plugin/pty-environment.ts +0 -24
- package/src/plugin/shared.ts +0 -323
- package/src/plugin/snowflake-cortex.ts +0 -529
- package/src/plugin/tui/internal.ts +0 -10
- package/src/plugin/tui/runtime.ts +0 -1130
- package/src/plugin/xai.ts +0 -716
- package/src/project/bootstrap-service.ts +0 -9
- package/src/project/bootstrap.ts +0 -76
- package/src/project/instance-context.ts +0 -24
- package/src/project/instance-layer.ts +0 -11
- package/src/project/instance-runtime.ts +0 -16
- package/src/project/instance-store.ts +0 -209
- package/src/project/project.ts +0 -519
- package/src/project/vcs.ts +0 -431
- package/src/provider/auth.ts +0 -233
- package/src/provider/error.ts +0 -188
- package/src/provider/model-status.ts +0 -8
- package/src/provider/provider.ts +0 -1975
- package/src/provider/transform.ts +0 -1543
- package/src/question/index.ts +0 -229
- package/src/question/schema.ts +0 -10
- package/src/server/auth.ts +0 -48
- package/src/server/event.ts +0 -13
- package/src/server/global-lifecycle.ts +0 -28
- package/src/server/init-projectors.ts +0 -3
- package/src/server/mdns.ts +0 -47
- package/src/server/projectors.ts +0 -1
- package/src/server/proxy-util.ts +0 -48
- package/src/server/routes/instance/httpapi/AGENTS.md +0 -39
- package/src/server/routes/instance/httpapi/api.ts +0 -78
- package/src/server/routes/instance/httpapi/errors.ts +0 -193
- package/src/server/routes/instance/httpapi/groups/config.ts +0 -65
- package/src/server/routes/instance/httpapi/groups/control-plane.ts +0 -35
- package/src/server/routes/instance/httpapi/groups/control.ts +0 -76
- package/src/server/routes/instance/httpapi/groups/event.ts +0 -29
- package/src/server/routes/instance/httpapi/groups/experimental.ts +0 -275
- package/src/server/routes/instance/httpapi/groups/file.ts +0 -185
- package/src/server/routes/instance/httpapi/groups/global.ts +0 -138
- package/src/server/routes/instance/httpapi/groups/instance.ts +0 -206
- package/src/server/routes/instance/httpapi/groups/mcp.ts +0 -156
- package/src/server/routes/instance/httpapi/groups/metadata.ts +0 -18
- package/src/server/routes/instance/httpapi/groups/permission.ts +0 -61
- package/src/server/routes/instance/httpapi/groups/project-copy.ts +0 -32
- package/src/server/routes/instance/httpapi/groups/project.ts +0 -93
- package/src/server/routes/instance/httpapi/groups/provider.ts +0 -101
- package/src/server/routes/instance/httpapi/groups/pty.ts +0 -172
- package/src/server/routes/instance/httpapi/groups/query.ts +0 -12
- package/src/server/routes/instance/httpapi/groups/question.ts +0 -74
- package/src/server/routes/instance/httpapi/groups/session.ts +0 -462
- package/src/server/routes/instance/httpapi/groups/sync.ts +0 -113
- package/src/server/routes/instance/httpapi/groups/tui.ts +0 -208
- package/src/server/routes/instance/httpapi/groups/workspace.ts +0 -141
- package/src/server/routes/instance/httpapi/handlers/config.ts +0 -34
- package/src/server/routes/instance/httpapi/handlers/control-plane.ts +0 -37
- package/src/server/routes/instance/httpapi/handlers/control.ts +0 -43
- package/src/server/routes/instance/httpapi/handlers/event.ts +0 -99
- package/src/server/routes/instance/httpapi/handlers/experimental.ts +0 -192
- package/src/server/routes/instance/httpapi/handlers/file.ts +0 -139
- package/src/server/routes/instance/httpapi/handlers/global.ts +0 -156
- package/src/server/routes/instance/httpapi/handlers/instance.ts +0 -110
- package/src/server/routes/instance/httpapi/handlers/mcp.ts +0 -111
- package/src/server/routes/instance/httpapi/handlers/permission.ts +0 -41
- package/src/server/routes/instance/httpapi/handlers/project-copy.ts +0 -83
- package/src/server/routes/instance/httpapi/handlers/project.ts +0 -63
- package/src/server/routes/instance/httpapi/handlers/provider.ts +0 -113
- package/src/server/routes/instance/httpapi/handlers/pty.ts +0 -273
- package/src/server/routes/instance/httpapi/handlers/question.ts +0 -54
- package/src/server/routes/instance/httpapi/handlers/session-errors.ts +0 -21
- package/src/server/routes/instance/httpapi/handlers/session.ts +0 -440
- package/src/server/routes/instance/httpapi/handlers/sync.ts +0 -89
- package/src/server/routes/instance/httpapi/handlers/tui.ts +0 -131
- package/src/server/routes/instance/httpapi/handlers/workspace.ts +0 -102
- package/src/server/routes/instance/httpapi/lifecycle.ts +0 -54
- package/src/server/routes/instance/httpapi/middleware/authorization.ts +0 -150
- package/src/server/routes/instance/httpapi/middleware/compression.ts +0 -64
- package/src/server/routes/instance/httpapi/middleware/cors-vary.ts +0 -29
- package/src/server/routes/instance/httpapi/middleware/error.ts +0 -43
- package/src/server/routes/instance/httpapi/middleware/fence.ts +0 -25
- package/src/server/routes/instance/httpapi/middleware/instance-context.ts +0 -43
- package/src/server/routes/instance/httpapi/middleware/proxy.ts +0 -108
- package/src/server/routes/instance/httpapi/middleware/schema-error.ts +0 -41
- package/src/server/routes/instance/httpapi/middleware/workspace-routing.ts +0 -250
- package/src/server/routes/instance/httpapi/public.ts +0 -535
- package/src/server/routes/instance/httpapi/server.ts +0 -298
- package/src/server/routes/instance/httpapi/websocket-tracker.ts +0 -57
- package/src/server/server.ts +0 -225
- package/src/server/shared/fence.ts +0 -60
- package/src/server/shared/pty-ticket.ts +0 -15
- package/src/server/shared/public-ui.ts +0 -12
- package/src/server/shared/tui-control.ts +0 -28
- package/src/server/shared/ui.ts +0 -108
- package/src/server/shared/workspace-routing.ts +0 -38
- package/src/server/tui-event.ts +0 -53
- package/src/session/compaction.ts +0 -620
- package/src/session/instruction.ts +0 -241
- package/src/session/llm/AGENTS.md +0 -90
- package/src/session/llm/ai-sdk.ts +0 -288
- package/src/session/llm/native-request.ts +0 -196
- package/src/session/llm/native-runtime.ts +0 -195
- package/src/session/llm/request.ts +0 -216
- package/src/session/llm.ts +0 -415
- package/src/session/message-error.ts +0 -14
- package/src/session/message-v2.ts +0 -747
- package/src/session/message.ts +0 -148
- package/src/session/overflow.ts +0 -34
- package/src/session/processor.ts +0 -1084
- package/src/session/prompt/anthropic.txt +0 -109
- package/src/session/prompt/beast.txt +0 -151
- package/src/session/prompt/build-switch.txt +0 -9
- package/src/session/prompt/codex.txt +0 -83
- package/src/session/prompt/copilot-gpt-5.txt +0 -147
- package/src/session/prompt/default.txt +0 -99
- package/src/session/prompt/gemini.txt +0 -159
- package/src/session/prompt/gpt.txt +0 -111
- package/src/session/prompt/kimi.txt +0 -99
- package/src/session/prompt/plan-mode.txt +0 -74
- package/src/session/prompt/plan-reminder-anthropic.txt +0 -71
- package/src/session/prompt/plan.txt +0 -30
- package/src/session/prompt/trinity.txt +0 -101
- package/src/session/prompt.ts +0 -1707
- package/src/session/reminders.ts +0 -92
- package/src/session/retry.ts +0 -201
- package/src/session/revert.ts +0 -160
- package/src/session/run-state.ts +0 -156
- package/src/session/schema.ts +0 -26
- package/src/session/session.ts +0 -1119
- package/src/session/status.ts +0 -97
- package/src/session/summary.ts +0 -165
- package/src/session/system.ts +0 -117
- package/src/session/todo.ts +0 -90
- package/src/session/tools.ts +0 -207
- package/src/share/session.ts +0 -61
- package/src/share/share-next.ts +0 -385
- package/src/skill/discovery.ts +0 -109
- package/src/skill/index.ts +0 -366
- package/src/snapshot/index.ts +0 -808
- package/src/sql.d.ts +0 -4
- package/src/storage/schema.ts +0 -5
- package/src/storage/storage.ts +0 -329
- package/src/sync/README.md +0 -179
- package/src/sync/schema.ts +0 -11
- package/src/temporary.ts +0 -31
- package/src/tool/apply_patch.ts +0 -315
- package/src/tool/apply_patch.txt +0 -33
- package/src/tool/apply_patch.zh.txt +0 -33
- package/src/tool/description.ts +0 -100
- package/src/tool/edit.ts +0 -739
- package/src/tool/edit.txt +0 -10
- package/src/tool/edit.zh.txt +0 -10
- package/src/tool/external-directory.ts +0 -49
- package/src/tool/glob.ts +0 -78
- package/src/tool/glob.txt +0 -6
- package/src/tool/glob.zh.txt +0 -6
- package/src/tool/grep.ts +0 -114
- package/src/tool/grep.txt +0 -8
- package/src/tool/grep.zh.txt +0 -8
- package/src/tool/invalid.ts +0 -21
- package/src/tool/json-schema.ts +0 -164
- package/src/tool/lsp.ts +0 -115
- package/src/tool/lsp.txt +0 -24
- package/src/tool/lsp.zh.txt +0 -24
- package/src/tool/mcp-websearch.ts +0 -96
- package/src/tool/plan-enter.txt +0 -14
- package/src/tool/plan-enter.zh.txt +0 -14
- package/src/tool/plan-exit.txt +0 -13
- package/src/tool/plan-exit.zh.txt +0 -13
- package/src/tool/plan.ts +0 -81
- package/src/tool/question.ts +0 -46
- package/src/tool/question.txt +0 -10
- package/src/tool/question.zh.txt +0 -10
- package/src/tool/read.ts +0 -388
- package/src/tool/read.txt +0 -14
- package/src/tool/read.zh.txt +0 -14
- package/src/tool/registry.ts +0 -440
- package/src/tool/schema.ts +0 -14
- package/src/tool/shell/id.ts +0 -19
- package/src/tool/shell/prompt.ts +0 -307
- package/src/tool/shell/shell.txt +0 -21
- package/src/tool/shell.ts +0 -657
- package/src/tool/skill.ts +0 -73
- package/src/tool/skill.txt +0 -5
- package/src/tool/skill.zh.txt +0 -5
- package/src/tool/task.ts +0 -348
- package/src/tool/task.txt +0 -19
- package/src/tool/task.zh.txt +0 -19
- package/src/tool/todo.ts +0 -59
- package/src/tool/todowrite.txt +0 -44
- package/src/tool/todowrite.zh.txt +0 -44
- package/src/tool/tool.ts +0 -183
- package/src/tool/truncate.ts +0 -158
- package/src/tool/truncation-dir.ts +0 -4
- package/src/tool/webfetch.ts +0 -194
- package/src/tool/webfetch.txt +0 -13
- package/src/tool/webfetch.zh.txt +0 -13
- package/src/tool/websearch.ts +0 -145
- package/src/tool/websearch.txt +0 -14
- package/src/tool/websearch.zh.txt +0 -14
- package/src/tool/write.ts +0 -106
- package/src/tool/write.txt +0 -8
- package/src/tool/write.zh.txt +0 -8
- package/src/util/archive.ts +0 -17
- package/src/util/bom.ts +0 -27
- package/src/util/data-url.ts +0 -9
- package/src/util/defer.ts +0 -10
- package/src/util/effect-http-client.ts +0 -11
- package/src/util/error.ts +0 -1
- package/src/util/filesystem.ts +0 -251
- package/src/util/html.ts +0 -8
- package/src/util/iife.ts +0 -3
- package/src/util/lazy.ts +0 -20
- package/src/util/local-context.ts +0 -25
- package/src/util/locale.ts +0 -2
- package/src/util/media.ts +0 -26
- package/src/util/process.ts +0 -177
- package/src/util/proxy-env.ts +0 -72
- package/src/util/queue.ts +0 -32
- package/src/util/record.ts +0 -1
- package/src/util/repository.ts +0 -232
- package/src/util/rpc.ts +0 -66
- package/src/util/signal.ts +0 -12
- package/src/util/timeout.ts +0 -13
- package/src/util/token.ts +0 -1
- package/src/util/wildcard.ts +0 -59
- package/src/worktree/index.ts +0 -654
package/src/tool/skill.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import path from "path"
|
|
2
|
-
import { pathToFileURL } from "url"
|
|
3
|
-
import { Effect, Schema } from "effect"
|
|
4
|
-
import { Ripgrep } from "@opencode-ai/core/ripgrep"
|
|
5
|
-
import { Skill } from "../skill"
|
|
6
|
-
import * as Tool from "./tool"
|
|
7
|
-
import DESCRIPTION from "./skill.txt"
|
|
8
|
-
import DESCRIPTION_ZH from "./skill.zh.txt"
|
|
9
|
-
import { loadDescription } from "./description"
|
|
10
|
-
|
|
11
|
-
export const Parameters = Schema.Struct({
|
|
12
|
-
name: Schema.String.annotate({ description: "The name of the skill from available_skills" }),
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
export const SkillTool = Tool.define(
|
|
16
|
-
"skill",
|
|
17
|
-
Effect.gen(function* () {
|
|
18
|
-
const skill = yield* Skill.Service
|
|
19
|
-
const ripgrep = yield* Ripgrep.Service
|
|
20
|
-
|
|
21
|
-
return {
|
|
22
|
-
description: loadDescription(DESCRIPTION, DESCRIPTION_ZH),
|
|
23
|
-
parameters: Parameters,
|
|
24
|
-
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
|
|
25
|
-
Effect.gen(function* () {
|
|
26
|
-
const info = yield* skill
|
|
27
|
-
.require(params.name)
|
|
28
|
-
.pipe(Effect.catchTag("Skill.NotFoundError", (error) => Effect.die(new Error(error.message))))
|
|
29
|
-
|
|
30
|
-
yield* ctx.ask({
|
|
31
|
-
permission: "skill",
|
|
32
|
-
patterns: [params.name],
|
|
33
|
-
always: [params.name],
|
|
34
|
-
metadata: {},
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
const dir = path.dirname(info.location)
|
|
38
|
-
const base = pathToFileURL(dir).href
|
|
39
|
-
const files = yield* ripgrep.find({
|
|
40
|
-
cwd: dir,
|
|
41
|
-
pattern: "!**/SKILL.md",
|
|
42
|
-
hidden: true,
|
|
43
|
-
follow: false,
|
|
44
|
-
signal: ctx.abort,
|
|
45
|
-
limit: 10,
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
title: `Loaded skill: ${info.name}`,
|
|
50
|
-
output: [
|
|
51
|
-
`<skill_content name="${info.name}">`,
|
|
52
|
-
`# Skill: ${info.name}`,
|
|
53
|
-
"",
|
|
54
|
-
info.content.trim(),
|
|
55
|
-
"",
|
|
56
|
-
`Base directory for this skill: ${base}`,
|
|
57
|
-
"Relative paths in this skill (e.g., scripts/, reference/) are relative to this base directory.",
|
|
58
|
-
"Note: file list is sampled.",
|
|
59
|
-
"",
|
|
60
|
-
"<skill_files>",
|
|
61
|
-
files.map((file) => `<file>${path.resolve(dir, file.path)}</file>`).join("\n"),
|
|
62
|
-
"</skill_files>",
|
|
63
|
-
"</skill_content>",
|
|
64
|
-
].join("\n"),
|
|
65
|
-
metadata: {
|
|
66
|
-
name: info.name,
|
|
67
|
-
dir,
|
|
68
|
-
},
|
|
69
|
-
}
|
|
70
|
-
}).pipe(Effect.orDie),
|
|
71
|
-
}
|
|
72
|
-
}),
|
|
73
|
-
)
|
package/src/tool/skill.txt
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
Load a specialized skill when the task at hand matches one of the skills listed in the system prompt.
|
|
2
|
-
|
|
3
|
-
Use this tool to inject the skill's instructions and resources into current conversation. The output may contain detailed workflow guidance as well as references to scripts, files, etc in the same directory as the skill.
|
|
4
|
-
|
|
5
|
-
The skill name must match one of the skills listed in your system prompt.
|
package/src/tool/skill.zh.txt
DELETED
package/src/tool/task.ts
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
import * as Tool from "./tool"
|
|
2
|
-
import DESCRIPTION from "./task.txt"
|
|
3
|
-
import DESCRIPTION_ZH from "./task.zh.txt"
|
|
4
|
-
import { ToolJsonSchema } from "./json-schema"
|
|
5
|
-
import { SessionV1 } from "@opencode-ai/core/v1/session"
|
|
6
|
-
import { BackgroundJob } from "@/background/job"
|
|
7
|
-
import { Session } from "@/session/session"
|
|
8
|
-
import { SessionID, MessageID } from "../session/schema"
|
|
9
|
-
import { MessageV2 } from "../session/message-v2"
|
|
10
|
-
import { Agent } from "../agent/agent"
|
|
11
|
-
import { deriveSubagentSessionPermission } from "../agent/subagent-permissions"
|
|
12
|
-
import type { SessionPrompt } from "../session/prompt"
|
|
13
|
-
import { Config } from "@/config/config"
|
|
14
|
-
import { Effect, Exit, Schema, Scope } from "effect"
|
|
15
|
-
import { EffectBridge } from "@/effect/bridge"
|
|
16
|
-
import { RuntimeFlags } from "@/effect/runtime-flags"
|
|
17
|
-
import { Database } from "@opencode-ai/core/database/database"
|
|
18
|
-
import { loadDescription } from "./description"
|
|
19
|
-
|
|
20
|
-
export interface TaskPromptOps {
|
|
21
|
-
cancel(sessionID: SessionID): Effect.Effect<void>
|
|
22
|
-
resolvePromptParts(template: string): Effect.Effect<SessionPrompt.PromptInput["parts"]>
|
|
23
|
-
prompt(input: SessionPrompt.PromptInput): Effect.Effect<SessionV1.WithParts>
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const id = "task"
|
|
27
|
-
const BACKGROUND_DESCRIPTION = [
|
|
28
|
-
"Background mode: background=true launches the subagent asynchronously and returns immediately.",
|
|
29
|
-
"Foreground is the default; use it when you need the result before continuing.",
|
|
30
|
-
"Use background only for independent work that can run while you continue elsewhere.",
|
|
31
|
-
"You will be notified automatically when it finishes.",
|
|
32
|
-
].join(" ")
|
|
33
|
-
const BACKGROUND_STARTED = [
|
|
34
|
-
"The task is working in the background. You will be notified automatically when it finishes.",
|
|
35
|
-
"DO NOT sleep, poll for progress, ask the task for status, or duplicate this task's work — avoid working with the same files or topics it is using.",
|
|
36
|
-
"Work on non-overlapping tasks, or briefly tell the user what you launched and end your response.",
|
|
37
|
-
].join("\n")
|
|
38
|
-
const BACKGROUND_UPDATED = [
|
|
39
|
-
"Additional context sent to the running background task.",
|
|
40
|
-
"The task is still working in the background. You will be notified automatically when it finishes.",
|
|
41
|
-
"DO NOT sleep, poll for progress, ask the task for status, or duplicate this task's work — avoid working with the same files or topics it is using.",
|
|
42
|
-
"Work on non-overlapping tasks, or briefly tell the user what you sent and end your response.",
|
|
43
|
-
].join("\n")
|
|
44
|
-
|
|
45
|
-
const BaseParameterFields = {
|
|
46
|
-
description: Schema.String.annotate({ description: "A short (3-5 words) description of the task" }),
|
|
47
|
-
prompt: Schema.String.annotate({ description: "The task for the agent to perform" }),
|
|
48
|
-
subagent_type: Schema.String.annotate({ description: "The type of specialized agent to use for this task" }),
|
|
49
|
-
task_id: Schema.optional(Schema.String).annotate({
|
|
50
|
-
description:
|
|
51
|
-
"This should only be set if you mean to resume a previous task (you can pass a prior task_id and the task will continue the same subagent session as before instead of creating a fresh one)",
|
|
52
|
-
}),
|
|
53
|
-
command: Schema.optional(Schema.String).annotate({ description: "The command that triggered this task" }),
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const BaseParameters = Schema.Struct(BaseParameterFields)
|
|
57
|
-
|
|
58
|
-
export const Parameters = Schema.Struct({
|
|
59
|
-
...BaseParameterFields,
|
|
60
|
-
background: Schema.optional(Schema.Boolean).annotate({
|
|
61
|
-
description:
|
|
62
|
-
"Run the agent in the background. You will be notified when it completes. DO NOT sleep, poll, or proactively check on its progress",
|
|
63
|
-
}),
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
function renderOutput(input: {
|
|
67
|
-
sessionID: SessionID
|
|
68
|
-
state: "running" | "completed" | "error"
|
|
69
|
-
summary?: string
|
|
70
|
-
text: string
|
|
71
|
-
}) {
|
|
72
|
-
const tag = input.state === "error" ? "task_error" : "task_result"
|
|
73
|
-
return [
|
|
74
|
-
`<task id="${input.sessionID}" state="${input.state}">`,
|
|
75
|
-
...(input.summary ? [`<summary>${input.summary}</summary>`] : []),
|
|
76
|
-
`<${tag}>`,
|
|
77
|
-
input.text,
|
|
78
|
-
`</${tag}>`,
|
|
79
|
-
"</task>",
|
|
80
|
-
].join("\n")
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const TaskTool = Tool.define(
|
|
84
|
-
id,
|
|
85
|
-
Effect.gen(function* () {
|
|
86
|
-
const agent = yield* Agent.Service
|
|
87
|
-
const background = yield* BackgroundJob.Service
|
|
88
|
-
const config = yield* Config.Service
|
|
89
|
-
const sessions = yield* Session.Service
|
|
90
|
-
const scope = yield* Scope.Scope
|
|
91
|
-
const flags = yield* RuntimeFlags.Service
|
|
92
|
-
const database = yield* Database.Service
|
|
93
|
-
|
|
94
|
-
const run = Effect.fn("TaskTool.execute")(function* (
|
|
95
|
-
params: Schema.Schema.Type<typeof Parameters>,
|
|
96
|
-
ctx: Tool.Context,
|
|
97
|
-
) {
|
|
98
|
-
const cfg = yield* config.get()
|
|
99
|
-
const runInBackground = params.background === true
|
|
100
|
-
if (runInBackground && !flags.experimentalBackgroundSubagents) {
|
|
101
|
-
return yield* Effect.fail(
|
|
102
|
-
new Error("Background subagents require OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true"),
|
|
103
|
-
)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (!ctx.extra?.bypassAgentCheck) {
|
|
107
|
-
yield* ctx.ask({
|
|
108
|
-
permission: id,
|
|
109
|
-
patterns: [params.subagent_type],
|
|
110
|
-
always: ["*"],
|
|
111
|
-
metadata: {
|
|
112
|
-
description: params.description,
|
|
113
|
-
subagent_type: params.subagent_type,
|
|
114
|
-
},
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const next = yield* agent.get(params.subagent_type)
|
|
119
|
-
if (!next) {
|
|
120
|
-
return yield* Effect.fail(new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`))
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const session = params.task_id
|
|
124
|
-
? yield* sessions.get(SessionID.make(params.task_id)).pipe(Effect.catchCause(() => Effect.succeed(undefined)))
|
|
125
|
-
: undefined
|
|
126
|
-
const parent = yield* sessions.get(ctx.sessionID)
|
|
127
|
-
const childPermission = deriveSubagentSessionPermission({
|
|
128
|
-
parentSessionPermission: parent.permission ?? [],
|
|
129
|
-
subagent: next,
|
|
130
|
-
})
|
|
131
|
-
const childToolDenies = [
|
|
132
|
-
...(next.permission.some((rule) => rule.permission === "todowrite")
|
|
133
|
-
? []
|
|
134
|
-
: [{ permission: "todowrite" as const, pattern: "*" as const, action: "deny" as const }]),
|
|
135
|
-
...(next.permission.some((rule) => rule.permission === id)
|
|
136
|
-
? []
|
|
137
|
-
: [{ permission: id, pattern: "*" as const, action: "deny" as const }]),
|
|
138
|
-
...(cfg.experimental?.primary_tools?.map((permission) => ({
|
|
139
|
-
permission,
|
|
140
|
-
pattern: "*" as const,
|
|
141
|
-
action: "deny" as const,
|
|
142
|
-
})) ?? []),
|
|
143
|
-
]
|
|
144
|
-
const nextSession =
|
|
145
|
-
session ??
|
|
146
|
-
(yield* sessions.create({
|
|
147
|
-
parentID: ctx.sessionID,
|
|
148
|
-
title: params.description + ` (@${next.name} subagent)`,
|
|
149
|
-
agent: next.name,
|
|
150
|
-
permission: [
|
|
151
|
-
...childPermission,
|
|
152
|
-
...childToolDenies.filter(
|
|
153
|
-
(deny) =>
|
|
154
|
-
!childPermission.some(
|
|
155
|
-
(rule) =>
|
|
156
|
-
rule.permission === deny.permission && rule.pattern === deny.pattern && rule.action === deny.action,
|
|
157
|
-
),
|
|
158
|
-
),
|
|
159
|
-
],
|
|
160
|
-
}))
|
|
161
|
-
|
|
162
|
-
const msg = yield* MessageV2.get({ sessionID: ctx.sessionID, messageID: ctx.messageID }).pipe(
|
|
163
|
-
Effect.provideService(Database.Service, database),
|
|
164
|
-
Effect.orDie,
|
|
165
|
-
)
|
|
166
|
-
if (msg.info.role !== "assistant") return yield* Effect.fail(new Error("Not an assistant message"))
|
|
167
|
-
const variant = msg.info.variant
|
|
168
|
-
|
|
169
|
-
const model = next.model ?? {
|
|
170
|
-
modelID: msg.info.modelID,
|
|
171
|
-
providerID: msg.info.providerID,
|
|
172
|
-
}
|
|
173
|
-
const metadata = {
|
|
174
|
-
parentSessionId: ctx.sessionID,
|
|
175
|
-
sessionId: nextSession.id,
|
|
176
|
-
model,
|
|
177
|
-
...(runInBackground ? { background: true } : {}),
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
yield* ctx.metadata({
|
|
181
|
-
title: params.description,
|
|
182
|
-
metadata,
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
const ops = ctx.extra?.promptOps as TaskPromptOps
|
|
186
|
-
if (!ops) return yield* Effect.fail(new Error("TaskTool requires promptOps in ctx.extra"))
|
|
187
|
-
|
|
188
|
-
const runTask = Effect.fn("TaskTool.runTask")(function* () {
|
|
189
|
-
const parts = yield* ops.resolvePromptParts(params.prompt)
|
|
190
|
-
const result = yield* ops.prompt({
|
|
191
|
-
messageID: MessageID.ascending(),
|
|
192
|
-
sessionID: nextSession.id,
|
|
193
|
-
model: {
|
|
194
|
-
modelID: model.modelID,
|
|
195
|
-
providerID: model.providerID,
|
|
196
|
-
},
|
|
197
|
-
variant: next.model ? undefined : variant,
|
|
198
|
-
agent: next.name,
|
|
199
|
-
parts,
|
|
200
|
-
})
|
|
201
|
-
return result.parts.findLast((item) => item.type === "text")?.text ?? ""
|
|
202
|
-
})
|
|
203
|
-
|
|
204
|
-
const inject = Effect.fn("TaskTool.injectBackgroundResult")(function* (
|
|
205
|
-
state: "completed" | "error",
|
|
206
|
-
text: string,
|
|
207
|
-
) {
|
|
208
|
-
const currentParent = yield* sessions.get(ctx.sessionID)
|
|
209
|
-
yield* ops
|
|
210
|
-
.prompt({
|
|
211
|
-
sessionID: ctx.sessionID,
|
|
212
|
-
agent: currentParent.agent ?? ctx.agent,
|
|
213
|
-
variant,
|
|
214
|
-
parts: [
|
|
215
|
-
{
|
|
216
|
-
type: "text",
|
|
217
|
-
synthetic: true,
|
|
218
|
-
text: renderOutput({
|
|
219
|
-
sessionID: nextSession.id,
|
|
220
|
-
state,
|
|
221
|
-
summary:
|
|
222
|
-
state === "completed"
|
|
223
|
-
? `Background task completed: ${params.description}`
|
|
224
|
-
: `Background task failed: ${params.description}`,
|
|
225
|
-
text,
|
|
226
|
-
}),
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
})
|
|
230
|
-
.pipe(Effect.ignore, Effect.forkIn(scope, { startImmediately: true }))
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
const notify = Effect.fn("TaskTool.notifyBackgroundResult")(function* (jobID: string) {
|
|
234
|
-
yield* background.wait({ id: jobID }).pipe(
|
|
235
|
-
Effect.flatMap((result) => {
|
|
236
|
-
if (result.info?.status === "completed") return inject("completed", result.info.output ?? "")
|
|
237
|
-
if (result.info?.status === "error") return inject("error", result.info.error ?? "")
|
|
238
|
-
return Effect.void
|
|
239
|
-
}),
|
|
240
|
-
Effect.forkIn(scope, { startImmediately: true }),
|
|
241
|
-
)
|
|
242
|
-
})
|
|
243
|
-
|
|
244
|
-
if (yield* background.extend({ id: nextSession.id, run: runTask() })) {
|
|
245
|
-
return {
|
|
246
|
-
title: params.description,
|
|
247
|
-
metadata: {
|
|
248
|
-
...metadata,
|
|
249
|
-
background: true,
|
|
250
|
-
jobId: nextSession.id,
|
|
251
|
-
},
|
|
252
|
-
output: renderOutput({
|
|
253
|
-
sessionID: nextSession.id,
|
|
254
|
-
state: "running",
|
|
255
|
-
summary: "Background task updated",
|
|
256
|
-
text: BACKGROUND_UPDATED,
|
|
257
|
-
}),
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const info = yield* background.start({
|
|
262
|
-
id: nextSession.id,
|
|
263
|
-
type: id,
|
|
264
|
-
title: params.description,
|
|
265
|
-
metadata,
|
|
266
|
-
onPromote: Effect.all([
|
|
267
|
-
ctx.metadata({
|
|
268
|
-
title: params.description,
|
|
269
|
-
metadata: { ...metadata, background: true, jobId: nextSession.id },
|
|
270
|
-
}),
|
|
271
|
-
notify(nextSession.id),
|
|
272
|
-
]),
|
|
273
|
-
run: runTask().pipe(Effect.onInterrupt(() => ops.cancel(nextSession.id))),
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
function backgroundResult() {
|
|
277
|
-
return {
|
|
278
|
-
title: params.description,
|
|
279
|
-
metadata: {
|
|
280
|
-
...metadata,
|
|
281
|
-
background: true,
|
|
282
|
-
jobId: info.id,
|
|
283
|
-
},
|
|
284
|
-
output: renderOutput({
|
|
285
|
-
sessionID: nextSession.id,
|
|
286
|
-
state: "running",
|
|
287
|
-
summary: "Background task started",
|
|
288
|
-
text: BACKGROUND_STARTED,
|
|
289
|
-
}),
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
if (runInBackground) {
|
|
294
|
-
yield* notify(info.id)
|
|
295
|
-
return backgroundResult()
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const runCancel = yield* EffectBridge.make()
|
|
299
|
-
const cancel = ops.cancel(nextSession.id)
|
|
300
|
-
|
|
301
|
-
function onAbort() {
|
|
302
|
-
runCancel.fork(cancel)
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return yield* Effect.acquireUseRelease(
|
|
306
|
-
Effect.sync(() => {
|
|
307
|
-
ctx.abort.addEventListener("abort", onAbort)
|
|
308
|
-
}),
|
|
309
|
-
() =>
|
|
310
|
-
Effect.gen(function* () {
|
|
311
|
-
const result = yield* Effect.raceFirst(
|
|
312
|
-
background.wait({ id: nextSession.id }).pipe(Effect.map((waited) => waited.info)),
|
|
313
|
-
background.waitForPromotion(nextSession.id),
|
|
314
|
-
)
|
|
315
|
-
if (result?.metadata?.background === true) return backgroundResult()
|
|
316
|
-
if (result?.status === "error") return yield* Effect.fail(new Error(result.error ?? "Task failed"))
|
|
317
|
-
if (result?.status === "cancelled") return yield* Effect.fail(new Error("Task cancelled"))
|
|
318
|
-
return {
|
|
319
|
-
title: params.description,
|
|
320
|
-
metadata,
|
|
321
|
-
output: renderOutput({ sessionID: nextSession.id, state: "completed", text: result?.output ?? "" }),
|
|
322
|
-
}
|
|
323
|
-
}),
|
|
324
|
-
(_, exit) =>
|
|
325
|
-
Effect.gen(function* () {
|
|
326
|
-
if (Exit.hasInterrupts(exit))
|
|
327
|
-
yield* Effect.all([cancel, background.cancel(nextSession.id)], { discard: true })
|
|
328
|
-
}).pipe(
|
|
329
|
-
Effect.ensuring(
|
|
330
|
-
Effect.sync(() => {
|
|
331
|
-
ctx.abort.removeEventListener("abort", onAbort)
|
|
332
|
-
}),
|
|
333
|
-
),
|
|
334
|
-
),
|
|
335
|
-
)
|
|
336
|
-
})
|
|
337
|
-
|
|
338
|
-
return {
|
|
339
|
-
description: flags.experimentalBackgroundSubagents
|
|
340
|
-
? [loadDescription(DESCRIPTION, DESCRIPTION_ZH), BACKGROUND_DESCRIPTION].join("\n\n")
|
|
341
|
-
: loadDescription(DESCRIPTION, DESCRIPTION_ZH),
|
|
342
|
-
parameters: Parameters,
|
|
343
|
-
jsonSchema: flags.experimentalBackgroundSubagents ? undefined : ToolJsonSchema.fromSchema(BaseParameters),
|
|
344
|
-
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) =>
|
|
345
|
-
run(params, ctx).pipe(Effect.orDie),
|
|
346
|
-
}
|
|
347
|
-
}),
|
|
348
|
-
)
|
package/src/tool/task.txt
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Launch a new agent to handle complex, multistep tasks autonomously.
|
|
2
|
-
|
|
3
|
-
When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
|
|
4
|
-
|
|
5
|
-
When NOT to use the Task tool:
|
|
6
|
-
- If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly
|
|
7
|
-
- If you are searching for a specific class definition like "class Foo", use the Grep tool instead, to find the match more quickly
|
|
8
|
-
- If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
|
|
9
|
-
- If no available agent is a good fit for the task, use other tools directly
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Usage notes:
|
|
13
|
-
1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
|
|
14
|
-
2. Once you have delegated work to an agent, do not duplicate that work yourself. Continue with non-overlapping tasks, or wait for the result. For background tasks, you will be notified automatically when the result is ready.
|
|
15
|
-
3. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result. The output includes a task_id you can reuse later to continue the same subagent session.
|
|
16
|
-
4. Each agent invocation starts with a fresh context unless you provide task_id to resume the same subagent session (which continues with its previous messages and tool outputs). When starting fresh, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
|
|
17
|
-
5. The agent's outputs should generally be trusted
|
|
18
|
-
6. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent. Tell it how to verify its work if possible (e.g., relevant test commands).
|
|
19
|
-
7. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
|
package/src/tool/task.zh.txt
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
启动新智能体以自主处理复杂的多步骤任务。
|
|
2
|
-
|
|
3
|
-
使用 Task 工具时,您必须指定 subagent_type 参数以选择要使用的智能体类型。
|
|
4
|
-
|
|
5
|
-
何时不使用 Task 工具:
|
|
6
|
-
- 如果您想读取特定文件路径,请使用 Read 或 Glob 工具而不是 Task 工具,以更快地找到匹配项
|
|
7
|
-
- 如果您正在搜索特定的类定义(如 "class Foo"),请使用 Grep 工具,以更快地找到匹配项
|
|
8
|
-
- 如果您正在搜索特定文件或 2-3 个文件集中的代码,请使用 Read 工具而不是 Task 工具,以更快地找到匹配项
|
|
9
|
-
- 如果没有可用的智能体适合该任务,请直接使用其他工具
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
使用说明:
|
|
13
|
-
1. 尽可能同时启动多个智能体以最大化性能;为此,请使用包含多个工具调用的单条消息
|
|
14
|
-
2. 将工作委派给智能体后,请勿重复执行该工作。继续执行不重叠的任务,或等待结果。对于后台任务,当结果准备好时,系统会自动通知您。
|
|
15
|
-
3. 智能体完成后,将向您返回一条消息。智能体返回的结果对用户不可见。要向用户显示结果,您应该向用户发送一条文本消息,简要总结结果。输出包含一个 task_id,您可以稍后重用它来继续同一个子智能体会话。
|
|
16
|
-
4. 每次智能体调用都从新的上下文开始,除非您提供 task_id 来恢复同一个子智能体会话(这将继续其之前的消息和工具输出)。当重新开始时,您的提示应包含非常详细的任务描述,以便智能体自主执行,并且您应该明确指定智能体应在其唯一的消息中返回什么信息给您。
|
|
17
|
-
5. 智能体的输出通常应该被信任
|
|
18
|
-
6. 明确告诉智能体您是期望它编写代码还是只进行研究(搜索、文件读取、网页获取等),因为它不知道用户的意图。如果可能,告诉它如何验证其工作(例如,相关的测试命令)。
|
|
19
|
-
7. 如果智能体描述提到应主动使用它,那么您应该尽力在用户不必首先要求的情况下使用它。请自行判断。
|
package/src/tool/todo.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect"
|
|
2
|
-
import * as Tool from "./tool"
|
|
3
|
-
import DESCRIPTION_WRITE from "./todowrite.txt"
|
|
4
|
-
import DESCRIPTION_WRITE_ZH from "./todowrite.zh.txt"
|
|
5
|
-
import { Todo } from "../session/todo"
|
|
6
|
-
import { loadDescription } from "./description"
|
|
7
|
-
|
|
8
|
-
// Todo.Info is still a zod schema (session/todo.ts). Inline the field shape
|
|
9
|
-
// here rather than referencing its `.shape` — the LLM-visible JSON Schema is
|
|
10
|
-
// identical, and it removes the last zod dependency from this tool.
|
|
11
|
-
const TodoItem = Schema.Struct({
|
|
12
|
-
content: Schema.String.annotate({ description: "Brief description of the task" }),
|
|
13
|
-
status: Schema.String.annotate({
|
|
14
|
-
description: "Current status of the task: pending, in_progress, completed, cancelled",
|
|
15
|
-
}),
|
|
16
|
-
priority: Schema.String.annotate({ description: "Priority level of the task: high, medium, low" }),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
export const Parameters = Schema.Struct({
|
|
20
|
-
todos: Schema.mutable(Schema.Array(TodoItem)).annotate({ description: "The updated todo list" }),
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
type Metadata = {
|
|
24
|
-
todos: Todo.Info[]
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const TodoWriteTool = Tool.define<typeof Parameters, Metadata, Todo.Service>(
|
|
28
|
-
"todowrite",
|
|
29
|
-
Effect.gen(function* () {
|
|
30
|
-
const todo = yield* Todo.Service
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
description: loadDescription(DESCRIPTION_WRITE, DESCRIPTION_WRITE_ZH),
|
|
34
|
-
parameters: Parameters,
|
|
35
|
-
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context<Metadata>) =>
|
|
36
|
-
Effect.gen(function* () {
|
|
37
|
-
yield* ctx.ask({
|
|
38
|
-
permission: "todowrite",
|
|
39
|
-
patterns: ["*"],
|
|
40
|
-
always: ["*"],
|
|
41
|
-
metadata: {},
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
yield* todo.update({
|
|
45
|
-
sessionID: ctx.sessionID,
|
|
46
|
-
todos: params.todos,
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
title: `${params.todos.filter((x) => x.status !== "completed").length} todos`,
|
|
51
|
-
output: JSON.stringify(params.todos, null, 2),
|
|
52
|
-
metadata: {
|
|
53
|
-
todos: params.todos,
|
|
54
|
-
},
|
|
55
|
-
}
|
|
56
|
-
}),
|
|
57
|
-
} satisfies Tool.DefWithoutID<typeof Parameters, Metadata>
|
|
58
|
-
}),
|
|
59
|
-
)
|
package/src/tool/todowrite.txt
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
Create and maintain a structured task list for the current coding session. Tracks progress, organizes multi-step work, and surfaces status to the user.
|
|
2
|
-
|
|
3
|
-
## When to use
|
|
4
|
-
Use proactively when:
|
|
5
|
-
- The task requires 3+ distinct steps or actions (not just 3 tool calls for a single conceptual step)
|
|
6
|
-
- The work is non-trivial and benefits from planning
|
|
7
|
-
- The user provides multiple tasks (numbered or comma-separated) or explicitly asks for a todo list
|
|
8
|
-
- New instructions arrive - capture them as todos
|
|
9
|
-
- You start a task - mark it `in_progress` (only one at a time) before working
|
|
10
|
-
- You finish a task - mark it `completed` and add any follow-ups discovered during the work
|
|
11
|
-
|
|
12
|
-
## When NOT to use
|
|
13
|
-
Skip when:
|
|
14
|
-
- The work is a single, straightforward task (or <3 trivial steps)
|
|
15
|
-
- The request is purely informational or conversational
|
|
16
|
-
- Tracking adds no organizational value
|
|
17
|
-
|
|
18
|
-
## States
|
|
19
|
-
- `pending` - not started
|
|
20
|
-
- `in_progress` - actively working (exactly ONE at a time)
|
|
21
|
-
- `completed` - finished successfully
|
|
22
|
-
- `cancelled` - no longer needed
|
|
23
|
-
|
|
24
|
-
## Rules
|
|
25
|
-
- Update status in real time; don't batch completions
|
|
26
|
-
- Mark `completed` only after the required work is actually done, including any required verification. Never based on intent.
|
|
27
|
-
- Keep exactly one `in_progress` while work remains
|
|
28
|
-
- If blocked or partial, keep it `in_progress` and add a follow-up todo describing the blocker
|
|
29
|
-
- Preserve user-provided commands verbatim (flags, args, order)
|
|
30
|
-
- Items should be specific and actionable; break large work into smaller steps
|
|
31
|
-
|
|
32
|
-
## Examples
|
|
33
|
-
|
|
34
|
-
Use it:
|
|
35
|
-
- "Add a dark mode toggle and run the tests" -> multi-step feature + explicit verification
|
|
36
|
-
- "Rename getCwd -> getCurrentWorkingDirectory across the repo" -> grep reveals 15 occurrences in 8 files
|
|
37
|
-
- "Implement registration, catalog, cart, checkout" -> multiple complex features
|
|
38
|
-
|
|
39
|
-
Skip it:
|
|
40
|
-
- "How do I print Hello World in Python?" -> informational
|
|
41
|
-
- "Add a comment to calculateTotal" -> single edit
|
|
42
|
-
- "Run npm install and tell me what happened" -> one command
|
|
43
|
-
|
|
44
|
-
When in doubt, use it.
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
为当前编码会话创建和维护结构化的任务列表。跟踪进度,组织多步骤工作,并向用户展示状态。
|
|
2
|
-
|
|
3
|
-
## 何时使用
|
|
4
|
-
在以下情况下主动使用:
|
|
5
|
-
- 任务需要 3 个或更多不同的步骤或操作(不仅仅是单个概念步骤的 3 个工具调用)
|
|
6
|
-
- 工作不平凡且受益于规划
|
|
7
|
-
- 用户提供多个任务(编号或逗号分隔)或明确要求创建待办事项列表
|
|
8
|
-
- 收到新指令 - 将其捕获为待办事项
|
|
9
|
-
- 开始任务 - 在工作前将其标记为 `in_progress`(一次只能有一个)
|
|
10
|
-
- 完成任务 - 将其标记为 `completed` 并添加在工作中发现的任何后续事项
|
|
11
|
-
|
|
12
|
-
## 何时不使用
|
|
13
|
-
在以下情况下跳过:
|
|
14
|
-
- 工作是单个、直接的任务(或少于 3 个简单步骤)
|
|
15
|
-
- 请求纯粹是信息性或对话性的
|
|
16
|
-
- 跟踪不增加组织价值
|
|
17
|
-
|
|
18
|
-
## 状态
|
|
19
|
-
- `pending` - 未开始
|
|
20
|
-
- `in_progress` - 积极处理中(一次只能有一个)
|
|
21
|
-
- `completed` - 成功完成
|
|
22
|
-
- `cancelled` - 不再需要
|
|
23
|
-
|
|
24
|
-
## 规则
|
|
25
|
-
- 实时更新状态;不要批量完成
|
|
26
|
-
- 仅在实际完成所需工作(包括任何必需的验证)后才标记为 `completed`。切勿基于意图。
|
|
27
|
-
- 在仍有工作时保持恰好一个 `in_progress`
|
|
28
|
-
- 如果被阻止或部分完成,保持 `in_progress` 并添加描述阻止因素的后续待办事项
|
|
29
|
-
- 逐字保留用户提供的命令(标志、参数、顺序)
|
|
30
|
-
- 项目应具体且可操作;将大型工作分解为较小的步骤
|
|
31
|
-
|
|
32
|
-
## 示例
|
|
33
|
-
|
|
34
|
-
使用它:
|
|
35
|
-
- "添加深色模式切换并运行测试" -> 多步骤功能 + 明确验证
|
|
36
|
-
- "在整个仓库中将 getCwd 重命名为 getCurrentWorkingDirectory" -> grep 显示 8 个文件中有 15 处出现
|
|
37
|
-
- "实现注册、目录、购物车、结账" -> 多个复杂功能
|
|
38
|
-
|
|
39
|
-
跳过它:
|
|
40
|
-
- "如何在 Python 中打印 Hello World?" -> 信息性
|
|
41
|
-
- "向 calculateTotal 添加注释" -> 单次编辑
|
|
42
|
-
- "运行 npm install 并告诉我发生了什么" -> 一个命令
|
|
43
|
-
|
|
44
|
-
如有疑问,请使用它。
|