From abb6a7120968c91a6ce1f76e7cc32a1da31230a1 Mon Sep 17 00:00:00 2001 From: thomas Date: Sat, 18 Jul 2026 01:06:41 +0800 Subject: [PATCH 1/3] fix(core): complete deepagent pipeline restructure downstream sync (#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Completes the downstream sync left over from the deepagent context pipeline restructure (f578e4f / eeeac7e), and fixes two regressions found while verifying the Wave 2–5 CLI commands against a live daemon. - Drop orphaned `oversight`/`webhook` HTTP API modules whose service layers were removed by the restructure; the orphaned files broke typecheck and the CLI `oversight` command targeted endpoints that no longer exist. - Fix `dacode run` hanging after completion: the session event stream is now aborted on `session.status idle`, cancelling the underlying SSE fetch connection (the generated SSE client never cancels the fetch in its generator `finally`, leaking the socket and pinning the event loop). - Default missing `apiKey` in the provider discovery cache fetch wrapper. - Restore 6 V4 feature flags (`v4PanelAutoConvene`, `v4AgentPushEnabled`, `v4EventDrivenIm`, `v4MultiAgentRuntime`, `v4EventDrivenArchive`, `v4Steering`) still consumed by app capabilities and test RuntimeFlags overrides. - Complete the goal-driver API sync started in eeeac7e: inline the single-tick logic in `goal-tick-port` (pause/stop check + `loop.tick` + status publish), remove dead steer-relay wiring and dead `maxFilesChanged` / `maxTokensPerHour` gates, and delete/prune tests that targeted removed APIs (`goal-steer`, `overflow`, `plan-status-cache`, `httpapi-webhook`, plus pruned blocks in `steer`, `multi-agent-runtime`, `model-discovery`, `goal-tick-cold-recovery`). ## Test plan - `bun typecheck` across the workspace: deepagent-code package 75 → 0 errors, turbo typecheck 15/15 green. - Manual CLI verification (Wave 2–5 commands): `serve --register` starts and registers cleanly; `run` exits normally (~36s, previously hung past 150s); `debug agents`, `agent list`, `models`, `session list`, `packs list`, `service status` all pass. - Affected tests (`steer`, `goal-tick-cold-recovery`, `multi-agent-runtime`, `model-discovery`): 41 pass / 4 fail — the 4 failures are pre-existing runtime-behavior leftovers from the restructure (baseline was 8 failures on the same files), unrelated to typecheck errors and noted for follow-up. --- .gitignore | 4 - README.md | 211 +- README.zh.md | 206 +- bun.lock | 9 +- design/README.md | 310 +-- .../components/deepagent-settings-ux.test.ts | 20 +- .../components/deepagent/approval-control.tsx | 66 - .../deepagent/goal-plan-edit-dialog.tsx | 164 -- .../deepagent/goal-start-button.tsx | 123 -- .../components/deepagent/goal-status-bar.tsx | 63 +- .../src/components/deepagent/panel-button.tsx | 144 +- .../deepagent/panel-goal-contract.test.ts | 62 +- .../components/deepagent/panel-goal.api.ts | 101 +- .../deepagent/panel-verdict-dialog.tsx | 25 +- .../components/dialog-connect-provider.tsx | 7 +- .../components/dialog-custom-provider-form.ts | 265 +-- .../components/dialog-custom-provider.test.ts | 312 +-- .../src/components/dialog-custom-provider.tsx | 312 +-- .../src/components/im/group-chat-panel.tsx | 58 +- .../src/components/im/message-composer.tsx | 43 +- .../app/src/components/im/message-item.tsx | 12 - .../app/src/components/im/message-list.tsx | 3 - .../app/src/components/im/message-search.tsx | 98 - .../app/src/components/im/thread-view.tsx | 113 -- packages/app/src/components/im/types.ts | 16 - packages/app/src/components/prompt-input.tsx | 147 +- .../prompt-input/scenario-toggle.tsx | 2 +- .../components/prompt-input/submit.test.ts | 93 +- .../app/src/components/prompt-input/submit.ts | 79 +- .../components/review/dialog-review.api.ts | 3 - .../src/components/review/dialog-review.tsx | 37 +- .../src/components/session/session-header.tsx | 6 +- .../src/components/settings-v2/general.tsx | 38 + .../components/settings-v2/import-history.tsx | 30 +- .../src/components/settings-v2/providers.tsx | 30 +- .../src/components/settings-v2/servers.tsx | 24 +- .../components/settings-v2/settings-v2.css | 13 - .../src/components/status-popover-body.tsx | 119 +- .../app/src/components/status-popover.tsx | 76 +- packages/app/src/components/terminal.tsx | 14 +- packages/app/src/context/directory-sync.ts | 2 +- .../app/src/context/global-sync/bootstrap.ts | 14 +- .../app/src/context/global-sync/queue.test.ts | 20 - packages/app/src/context/global-sync/queue.ts | 2 - packages/app/src/context/layout.tsx | 41 +- packages/app/src/context/notification.tsx | 30 +- .../context/permission-auto-respond.test.ts | 35 +- .../src/context/permission-auto-respond.ts | 16 - packages/app/src/context/permission.tsx | 138 +- packages/app/src/context/server-sync.tsx | 26 +- packages/app/src/context/server.test.ts | 17 - packages/app/src/context/server.tsx | 36 +- packages/app/src/i18n/ar.ts | 6 - packages/app/src/i18n/br.ts | 6 - packages/app/src/i18n/bs.ts | 6 - packages/app/src/i18n/da.ts | 6 - packages/app/src/i18n/de.ts | 6 - packages/app/src/i18n/en.ts | 165 +- packages/app/src/i18n/es.ts | 6 - packages/app/src/i18n/fr.ts | 6 - packages/app/src/i18n/ja.ts | 6 - packages/app/src/i18n/ko.ts | 6 - packages/app/src/i18n/no.ts | 6 - packages/app/src/i18n/pl.ts | 6 - packages/app/src/i18n/ru.ts | 6 - packages/app/src/i18n/th.ts | 6 - packages/app/src/i18n/tr.ts | 6 - packages/app/src/i18n/uk.ts | 6 - packages/app/src/i18n/zh.ts | 161 +- packages/app/src/i18n/zht.ts | 154 -- packages/app/src/pages/directory-layout.tsx | 56 +- packages/app/src/pages/error.tsx | 27 +- packages/app/src/pages/layout.tsx | 37 +- .../app/src/pages/layout/sidebar-shell.tsx | 24 +- packages/app/src/pages/session.tsx | 14 +- .../composer/session-composer-region.tsx | 16 - .../pages/session/im-panel-helpers.test.ts | 4 +- .../app/src/pages/session/im-panel-helpers.ts | 29 +- .../src/pages/session/session-side-panel.tsx | 559 +++--- .../app/src/pages/session/side-panel-im.tsx | 112 +- .../src/pages/session/side-panel-plugins.tsx | 6 +- .../src/pages/session/side-panel-profile.tsx | 2 +- .../pages/session/use-session-commands.tsx | 3 +- packages/app/src/utils/agent.ts | 4 - packages/app/src/utils/im-client.ts | 76 +- packages/cli/package.json | 7 +- packages/cli/src/ambient.d.ts | 8 + packages/cli/src/commands/commands.ts | 221 ++- packages/cli/src/commands/handlers/acp.ts | 55 + .../cli/src/commands/handlers/agent/list.ts | 25 + packages/cli/src/commands/handlers/attach.ts | 48 + .../cli/src/commands/handlers/auth/list.ts | 45 + .../cli/src/commands/handlers/auth/login.ts | 82 + .../cli/src/commands/handlers/auth/logout.ts | 30 + packages/cli/src/commands/handlers/db.ts | 33 + packages/cli/src/commands/handlers/db/path.ts | 10 + .../commands/handlers/deepagent/env-facts.ts | 49 + .../src/commands/handlers/deepagent/goal.ts | 40 + .../src/commands/handlers/deepagent/packs.ts | 35 + .../src/commands/handlers/deepagent/panel.ts | 25 + .../src/commands/handlers/deepagent/review.ts | 40 + .../src/commands/handlers/deepagent/util.ts | 47 + .../src/commands/handlers/deepagent/wiki.ts | 56 + packages/cli/src/commands/handlers/default.ts | 42 +- packages/cli/src/commands/handlers/export.ts | 103 + packages/cli/src/commands/handlers/github.ts | 19 + packages/cli/src/commands/handlers/import.ts | 83 + packages/cli/src/commands/handlers/mcp/add.ts | 52 + .../cli/src/commands/handlers/mcp/list.ts | 63 + packages/cli/src/commands/handlers/models.ts | 37 + packages/cli/src/commands/handlers/pr.ts | 60 + packages/cli/src/commands/handlers/run.ts | 216 ++ packages/cli/src/commands/handlers/serve.ts | 60 +- .../src/commands/handlers/session/delete.ts | 14 + .../cli/src/commands/handlers/session/list.ts | 78 + packages/cli/src/commands/handlers/stats.ts | 57 + .../cli/src/commands/handlers/uninstall.ts | 93 + packages/cli/src/commands/handlers/upgrade.ts | 43 + packages/cli/src/commands/handlers/web.ts | 37 + packages/cli/src/index.ts | 38 + packages/cli/src/services/daemon.ts | 2 +- packages/cli/src/services/session-client.ts | 50 + packages/cli/src/tui.ts | 97 +- packages/cli/tsconfig.json | 5 +- packages/core/src/agent-gateway.ts | 23 +- packages/core/src/agent.ts | 10 +- .../core/src/control-plane/move-session.ts | 42 +- .../core/src/deepagent/background-learning.ts | 16 +- packages/core/src/deepagent/code-indexer.ts | 19 - .../core/src/deepagent/context-admission.ts | 5 +- packages/core/src/deepagent/context/config.ts | 8 + .../core/src/deepagent/context/curator.ts | 122 ++ packages/core/src/deepagent/context/index.ts | 12 +- packages/core/src/deepagent/context/ingest.ts | 249 +++ .../core/src/deepagent/context/token-meter.ts | 67 + .../core/src/deepagent/context/working-set.ts | 139 ++ packages/core/src/deepagent/document-store.ts | 34 +- packages/core/src/deepagent/graph-query.ts | 6 - .../core/src/deepagent/knowledge-source.ts | 16 - packages/core/src/deepagent/orchestration.ts | 34 +- packages/core/src/deepagent/prompt-policy.ts | 149 +- packages/core/src/global.ts | 40 +- packages/core/src/im/agent-executor.ts | 8 +- packages/core/src/im/agent-list-provider.ts | 10 +- packages/core/src/im/agent-orchestrator.ts | 27 +- packages/core/src/im/builtin-agents.ts | 4 +- packages/core/src/im/id.ts | 10 - packages/core/src/im/mention-parser.ts | 12 - packages/core/src/im/repository.ts | 533 +---- packages/core/src/im/sql.ts | 50 +- packages/core/src/im/websocket.ts | 4 +- packages/core/src/plugin/skill.ts | 2 +- .../plugin/skill/customize-deepagent-code.md | 6 +- packages/core/src/public/deepagent-code.ts | 130 ++ packages/core/src/public/index.ts | 1 + packages/core/src/session/compaction.ts | 40 +- packages/core/src/session/runner/llm.ts | 7 - packages/core/src/session/sql.ts | 9 - packages/core/src/util/identifier.ts | 33 +- packages/core/src/v1/config/config.ts | 18 + packages/core/src/v1/config/migrate.ts | 2 +- packages/core/src/v1/config/provider.ts | 9 +- packages/core/test/agent.test.ts | 2 +- packages/core/test/database-migration.test.ts | 90 - .../deepagent/background-learning.test.ts | 47 - .../core/test/deepagent/code-indexer.test.ts | 42 +- packages/core/test/deepagent/context.test.ts | 278 ++- .../deepagent/domain-pack-registry.test.ts | 15 - .../core/test/deepagent/graph-query.test.ts | 25 - .../core/test/deepagent/orchestration.test.ts | 54 +- .../core/test/deepagent/prompt-policy.test.ts | 189 -- .../session-state-panel-goal.test.ts | 28 - .../core/test/deepagent/world-state.test.ts | 40 - packages/core/test/global.test.ts | 8 - .../core/test/im-agent-reply-sink.test.ts | 2 +- packages/core/test/im-b3.test.ts | 385 ---- packages/core/test/im-e2e.test.ts | 19 +- packages/core/test/im-integration.test.ts | 2 - packages/core/test/im-orchestrator.test.ts | 158 +- .../test/im-unified-context-graph.test.ts | 6 +- packages/core/test/move-session.test.ts | 62 - .../core/test/public-deepagent-code.test.ts | 177 ++ packages/core/test/security-resolvers.test.ts | 6 - packages/core/test/session-compaction.test.ts | 19 - .../core/test/session-runner-recorded.test.ts | 8 +- packages/core/test/session-runner.test.ts | 14 +- packages/deepagent-code/package.json | 5 - packages/deepagent-code/script/build-node.ts | 16 +- packages/deepagent-code/specs/v2/api.ts | 67 + packages/deepagent-code/src/acp/service.ts | 2 +- packages/deepagent-code/src/agent/agent.ts | 72 +- .../src/cli/cmd/run/runtime.lifecycle.ts | 2 +- .../deepagent-code/src/cli/cmd/uninstall.ts | 21 +- packages/deepagent-code/src/config/config.ts | 38 +- .../deepagent-code/src/config/tui-migrate.ts | 3 - .../src/effect/runtime-flags.ts | 140 +- .../src/im/agent-executor-server.ts | 93 +- .../src/im/agent-reply-sink-server.ts | 13 +- .../deepagent-code/src/import/map/events.ts | 2 +- packages/deepagent-code/src/panel/arbiter.ts | 4 +- .../deepagent-code/src/plugin/openai/codex.ts | 15 +- .../src/provider/discovery-cache.ts | 3 +- .../src/provider/model-discovery.ts | 68 +- .../deepagent-code/src/provider/provider.ts | 177 +- .../deepagent-code/src/provider/transform.ts | 10 +- .../src/server/routes/instance/httpapi/api.ts | 4 - .../instance/httpapi/groups/deepagent.ts | 214 +- .../routes/instance/httpapi/groups/global.ts | 9 - .../routes/instance/httpapi/groups/im.ts | 185 +- .../instance/httpapi/groups/oversight.ts | 212 -- .../instance/httpapi/groups/provider.ts | 17 - .../routes/instance/httpapi/groups/session.ts | 16 +- .../routes/instance/httpapi/groups/webhook.ts | 178 -- .../instance/httpapi/handlers/deepagent.ts | 197 +- .../instance/httpapi/handlers/global.ts | 8 - .../routes/instance/httpapi/handlers/im.ts | 406 +--- .../instance/httpapi/handlers/oversight.ts | 159 -- .../instance/httpapi/handlers/provider.ts | 28 +- .../instance/httpapi/handlers/session.ts | 88 +- .../instance/httpapi/handlers/webhook.ts | 234 --- .../server/routes/instance/httpapi/server.ts | 66 - .../src/session/code-index-trigger.ts | 47 +- .../deepagent-code/src/session/compaction.ts | 7 +- .../deepagent-code/src/session/llm/request.ts | 143 +- .../src/session/multi-agent-runtime.ts | 57 - .../deepagent-code/src/session/overflow.ts | 199 +- .../deepagent-code/src/session/processor.ts | 7 - packages/deepagent-code/src/session/prompt.ts | 605 +----- .../deepagent-code/src/session/reminders.ts | 45 +- .../deepagent-code/src/session/run-state.ts | 12 +- packages/deepagent-code/src/session/tools.ts | 139 +- packages/deepagent-code/src/settings/store.ts | 26 +- packages/deepagent-code/src/skill/index.ts | 2 +- packages/deepagent-code/src/tool/plan.ts | 2 +- .../deepagent-code/src/tool/shell/prompt.ts | 4 +- .../src/wiki/execution-archiver.ts | 160 ++ .../deepagent-code/src/wiki/search-index.ts | 51 +- .../src/wiki/session-archive.ts | 88 +- .../deepagent-code/test/agent/agent.test.ts | 99 +- .../test/agent/goal-mode-agent.test.ts | 25 +- .../test/cli/cmd/tui/attention.test.ts | 6 +- .../deepagent-code/test/cli/error.test.ts | 2 +- .../test/cli/github-remote.test.ts | 21 +- .../__snapshots__/help-snapshots.test.ts.snap | 2 - .../test/cli/serve/prompt-prepare.test.ts | 50 +- .../deepagent-code/test/config/config.test.ts | 12 +- .../test/deepagent/debug-tool-d3-d4.test.ts | 6 +- .../test/deepagent/plan-status-cache.test.ts | 293 --- .../test/deepagent/request-prep.test.ts | 83 +- .../test/effect/runtime-flags.test.ts | 64 - .../test/im/agent-executor-server.test.ts | 5 - .../im/agent-list-provider-server.test.ts | 221 +-- .../deepagent-code/test/plugin/codex.test.ts | 20 - packages/deepagent-code/test/preload.ts | 9 - .../test/provider/model-discovery.test.ts | 54 +- .../test/provider/provider.test.ts | 195 +- .../test/provider/transform.test.ts | 29 - .../test/server/httpapi-im-agent.test.ts | 8 +- .../test/server/httpapi-instance.test.ts | 114 -- .../test/server/httpapi-listen.test.ts | 7 +- .../test/server/httpapi-sdk.test.ts | 31 +- .../test/server/httpapi-ui.test.ts | 18 +- .../test/server/httpapi-webhook.test.ts | 324 --- .../test/server/session-actions.test.ts | 9 +- .../test/session/code-index-trigger.test.ts | 26 +- .../test/session/context-ledger.test.ts | 21 - .../test/session/goal-driver.test.ts | 89 +- .../session/goal-loop-bcd-integration.test.ts | 24 +- .../test/session/goal-steer.test.ts | 335 ---- .../session/goal-tick-cold-recovery.test.ts | 5 +- .../test/session/llm-native-recorded.test.ts | 20 - .../deepagent-code/test/session/llm.test.ts | 678 +++---- .../test/session/multi-agent-runtime.test.ts | 72 - .../test/session/overflow.test.ts | 298 --- .../test/session/processor-effect.test.ts | 4 +- .../test/session/prompt.test.ts | 49 +- .../test/session/snapshot-tool-race.test.ts | 2 - .../deepagent-code/test/session/steer.test.ts | 240 --- .../test/session/v4-integration.test.ts | 2 - .../test/settings/store.test.ts | 27 - .../deepagent-code/test/tool/skill.test.ts | 7 - .../test/wiki/execution-archiver.test.ts | 145 ++ .../test/wiki/search-index.test.ts | 15 - .../test/wiki/session-archive-wiring.test.ts | 109 - packages/desktop/electron-builder.config.ts | 11 +- packages/desktop/package.json | 2 +- packages/desktop/scripts/prebuild.ts | 8 - .../domain-packs/code/architecture/README.md | 2 +- .../architecture-astronomy.json | 2 +- .../failure_dossiers/shared-everything.json | 2 +- .../documents/knowledge/adr-not-spec.json | 2 +- .../architecture-is-change-cost.json | 2 +- .../knowledge/shared-kernel-risk.json | 2 +- .../methodologies/adr-materialization.json | 2 +- .../methodologies/architecture-scan.json | 2 +- .../methodologies/cycle-risk-review.json | 2 +- .../skills/produce-architecture-map.json | 2 +- .../strategies/boundary-ownership.json | 2 +- .../documents/strategies/decision-record.json | 2 +- .../strategies/dependency-direction.json | 2 +- .../strategies/small-surface-integration.json | 2 +- .../domain-packs/code/benchmarking/README.md | 2 +- .../changed-workload-comparison.json | 2 +- .../failure_dossiers/single-run-claim.json | 2 +- .../benchmark-needs-correctness.json | 2 +- .../environment-is-part-of-result.json | 2 +- .../knowledge/thresholds-prevent-noise.json | 2 +- .../bench-harness-validation.json | 2 +- .../benchmark-regression-protocol.json | 2 +- .../methodologies/outlier-review.json | 2 +- .../skills/run-benchmark-protocol.json | 2 +- .../documents/strategies/baseline-lock.json | 2 +- .../strategies/regression-threshold.json | 2 +- .../strategies/repeat-and-variance.json | 2 +- .../documents/strategies/warmup-control.json | 2 +- packages/domain-packs/code/c/README.md | 2 +- .../knowledge/manual-memory-contract.json | 2 +- .../domain-packs/code/ci-triage/README.md | 2 +- .../failure_dossiers/last-error-only.json | 2 +- .../rerun-without-evidence.json | 2 +- .../knowledge/ci-is-evidence-source.json | 2 +- .../knowledge/skipped-checks-are-risk.json | 2 +- .../knowledge/workflow-changes-are-code.json | 2 +- .../methodologies/ci-evidence-adapter.json | 2 +- .../methodologies/matrix-failure-slice.json | 2 +- .../regression-classification.json | 2 +- .../documents/skills/classify-ci-failure.json | 2 +- .../documents/skills/parse-ci-log.json | 2 +- .../strategies/ci-diff-correlation.json | 2 +- .../strategies/first-failing-command.json | 2 +- .../strategies/provider-neutral-status.json | 2 +- .../strategies/retry-once-for-flake.json | 2 +- packages/domain-packs/code/cpp/README.md | 2 +- .../knowledge/abi-and-ownership.json | 2 +- .../strategy-before-diagnosis.json | 2 +- .../diagnosis-result-normalization.json | 2 +- .../evidence-first-diagnosis.json | 2 +- .../skills/collect-diagnostic-evidence.json | 2 +- .../domain-packs/code/environment/README.md | 2 +- .../failure_dossiers/fix-without-check.json | 2 +- .../failure_dossiers/hung-health-check.json | 2 +- .../knowledge/auto-fix-needs-retest.json | 2 +- .../knowledge/environment-evidence-local.json | 2 +- .../documents/knowledge/skip-not-fail.json | 2 +- .../environment-drift-check.json | 2 +- .../methodologies/restart-health-check.json | 2 +- .../methodologies/smoke-test-loop.json | 2 +- .../documents/skills/run-smoke-check.json | 2 +- .../strategies/doctor-before-fix.json | 2 +- .../strategies/idempotent-bootstrap.json | 2 +- .../strategies/test-before-auto-fix.json | 2 +- .../strategies/timeout-external-checks.json | 2 +- .../code/frontend.accessibility/README.md | 2 +- .../failure_dossiers/aria-coverup.json | 2 +- .../failure_dossiers/focus-lost-on-close.json | 2 +- .../knowledge/accessible-name-source.json | 2 +- .../knowledge/aria-does-not-add-behavior.json | 2 +- .../knowledge/focus-visible-required.json | 2 +- .../accessibility-runtime-pass.json | 2 +- .../contrast-and-motion-check.json | 2 +- .../methodologies/focus-management-check.json | 2 +- .../documents/skills/run-a11y-smoke.json | 2 +- .../a11y-regression-in-browser.json | 2 +- .../strategies/keyboard-complete.json | 2 +- .../documents/strategies/name-role-state.json | 2 +- .../strategies/prefer-native-semantics.json | 2 +- .../code/frontend.performance/README.md | 2 +- .../failure_dossiers/bundle-only-claim.json | 2 +- .../unbounded-third-party.json | 2 +- .../documents/knowledge/hydration-cost.json | 2 +- .../knowledge/layout-shift-user-impact.json | 2 +- .../knowledge/third-party-script-risk.json | 2 +- .../methodologies/bundle-delta-review.json | 2 +- .../methodologies/frontend-profile-pass.json | 2 +- .../methodologies/web-vitals-regression.json | 2 +- .../skills/capture-browser-performance.json | 2 +- .../documents/strategies/asset-budget.json | 2 +- .../strategies/avoid-render-churn.json | 2 +- .../strategies/measure-user-path.json | 2 +- .../strategies/profile-long-tasks.json | 2 +- packages/domain-packs/code/go/README.md | 2 +- .../knowledge/context-cancellation.json | 2 +- packages/domain-packs/code/java-jvm/README.md | 2 +- .../documents/knowledge/build-tool-scope.json | 2 +- packages/domain-packs/code/mcp/README.md | 2 +- .../tool-with-broad-shell.json | 2 +- .../unstructured-tool-result.json | 2 +- .../knowledge/external-tool-supply-chain.json | 2 +- .../tool-output-needs-structure.json | 2 +- .../knowledge/tool-schema-is-contract.json | 2 +- .../methodologies/external-tool-review.json | 2 +- .../methodologies/mcp-server-validation.json | 2 +- .../methodologies/tool-audit-flow.json | 2 +- .../documents/skills/validate-mcp-tool.json | 2 +- .../strategies/artifact-backed-tools.json | 2 +- .../strategies/lazy-load-external-tools.json | 2 +- .../strategies/permission-minimal-tools.json | 2 +- .../strategies/tool-contract-first.json | 2 +- .../domain-packs/code/migration/README.md | 2 +- .../failure_dossiers/big-bang-migration.json | 2 +- .../codemod-without-review.json | 2 +- .../knowledge/codemods-overmatch.json | 2 +- .../knowledge/migration-is-stateful.json | 2 +- .../version-upgrade-breaks-transitives.json | 2 +- .../methodologies/codemod-safety-loop.json | 2 +- .../methodologies/compat-cleanup-gate.json | 2 +- .../migration-precheck-plan-execute.json | 2 +- .../skills/run-migration-inventory.json | 2 +- .../documents/strategies/compat-first.json | 2 +- .../strategies/deprecation-window.json | 2 +- .../strategies/inventory-before-codemod.json | 2 +- .../documents/strategies/phase-upgrade.json | 2 +- packages/domain-packs/code/mobile/README.md | 2 +- .../failure_dossiers/online-only-mobile.json | 2 +- .../permission-happy-path-only.json | 2 +- .../app-lifecycle-breaks-assumptions.json | 2 +- .../knowledge/device-data-privacy.json | 2 +- .../mobile-permissions-are-state.json | 2 +- .../methodologies/mobile-smoke-matrix.json | 2 +- .../methodologies/offline-sync-check.json | 2 +- .../methodologies/permission-flow-check.json | 2 +- .../skills/run-mobile-flow-check.json | 2 +- .../strategies/lifecycle-aware-state.json | 2 +- .../strategies/offline-and-retry.json | 2 +- .../strategies/permission-before-use.json | 2 +- .../strategies/privacy-by-device-data.json | 2 +- .../domain-packs/code/observability/README.md | 2 +- .../failure_dossiers/log-everything.json | 2 +- .../metric-without-action.json | 2 +- .../knowledge/high-cardinality-cost.json | 2 +- .../documents/knowledge/logs-can-leak.json | 2 +- .../documents/knowledge/traces-show-path.json | 2 +- .../methodologies/incident-evidence-pack.json | 2 +- .../methodologies/instrumentation-review.json | 2 +- .../methodologies/trace-search-flow.json | 2 +- .../skills/build-diagnostic-timeline.json | 2 +- .../strategies/correlation-first.json | 2 +- .../strategies/metric-with-owner.json | 2 +- .../documents/strategies/safe-telemetry.json | 2 +- .../documents/strategies/structured-logs.json | 2 +- .../domain-packs/code/performance/README.md | 2 +- .../average-only-performance.json | 2 +- .../optimize-without-baseline.json | 2 +- .../cache-invalidates-complexity.json | 2 +- .../knowledge/io-bound-vs-cpu-bound.json | 2 +- .../knowledge/microbench-not-product.json | 2 +- .../allocation-regression-check.json | 2 +- .../methodologies/latency-budget-review.json | 2 +- .../profile-baseline-patch-compare.json | 2 +- .../skills/compare-performance-result.json | 2 +- .../documents/skills/run-profile-pass.json | 2 +- .../strategies/hot-path-minimality.json | 2 +- .../strategies/measure-before-optimizing.json | 2 +- .../strategies/tail-latency-awareness.json | 2 +- .../strategies/tradeoff-explicitness.json | 2 +- packages/domain-packs/code/python/README.md | 2 +- .../documents/knowledge/venv-is-boundary.json | 2 +- packages/domain-packs/code/refactor/README.md | 2 +- .../behavior-change-called-refactor.json | 2 +- .../failure_dossiers/extract-everything.json | 2 +- .../documents/knowledge/abstraction-cost.json | 2 +- .../refactor-can-change-behavior.json | 2 +- .../tests-define-refactor-safety.json | 2 +- .../methodologies/caller-impact-scan.json | 2 +- .../methodologies/refactor-safety-loop.json | 2 +- .../methodologies/rename-move-check.json | 2 +- .../skills/scan-refactor-callers.json | 2 +- .../behavior-preserving-contract.json | 2 +- .../strategies/call-graph-before-move.json | 2 +- .../strategies/name-real-concept.json | 2 +- .../strategies/small-batch-refactor.json | 2 +- packages/domain-packs/code/release/README.md | 2 +- .../failure_dossiers/no-rollback-plan.json | 2 +- .../publish-before-artifact-check.json | 2 +- .../knowledge/changelog-user-impact.json | 2 +- .../knowledge/green-tests-not-release.json | 2 +- .../published-artifacts-persist.json | 2 +- .../methodologies/artifact-validation.json | 2 +- .../methodologies/post-release-monitor.json | 2 +- .../methodologies/pre-release-gate.json | 2 +- .../skills/build-release-evidence.json | 2 +- .../strategies/release-evidence-bundle.json | 2 +- .../strategies/rollback-before-publish.json | 2 +- .../strategies/supply-chain-release-gate.json | 2 +- .../strategies/version-contract.json | 2 +- .../review-without-evidence-audit.json | 2 +- .../independent-review-worker-profile.json | 2 +- .../skills/produce-blocker-summary.json | 2 +- .../evidence-completeness-review.json | 2 +- packages/domain-packs/code/rust/README.md | 2 +- .../documents/knowledge/ownership-is-api.json | 2 +- packages/domain-packs/code/sdk/README.md | 2 +- .../breaking-change-as-fix.json | 2 +- .../hand-edit-generated-sdk.json | 2 +- .../knowledge/defaults-are-contract.json | 2 +- .../knowledge/generated-do-not-hand-edit.json | 2 +- .../knowledge/sdk-errors-are-api.json | 2 +- .../sdk-breaking-change-review.json | 2 +- .../methodologies/sdk-contract-test.json | 2 +- .../methodologies/sdk-doc-example-pass.json | 2 +- .../skills/validate-sdk-contract.json | 2 +- .../compat-shim-before-removal.json | 2 +- .../documents/strategies/example-as-test.json | 2 +- .../strategies/generated-client-contract.json | 2 +- .../documents/strategies/semver-surface.json | 2 +- packages/domain-packs/code/shell/README.md | 2 +- .../knowledge/quoting-is-correctness.json | 2 +- packages/domain-packs/code/sql/README.md | 2 +- .../knowledge/query-plan-matters.json | 2 +- packages/domain-packs/code/swift/README.md | 2 +- .../knowledge/main-actor-boundary.json | 2 +- .../validation-without-artifacts.json | 2 +- .../acceptance-criteria-gate.json | 2 +- .../executable-validation-contract.json | 2 +- .../replayable-scenario-task.json | 2 +- .../skills/normalize-validation-result.json | 2 +- .../old-effect-api-memory.json | 2 +- .../knowledge/effect-source-of-truth.json | 2 +- .../effect-service-validation-loop.json | 2 +- .../documents/skills/run-effect-test.json | 2 +- .../strategies/effect-schema-boundaries.json | 2 +- .../domain-packs/platform/cloud/README.md | 2 +- .../failure_dossiers/broad-iam-fix.json | 2 +- .../failure_dossiers/deploy-to-debug.json | 2 +- .../knowledge/cloud-errors-often-policy.json | 2 +- .../knowledge/cloud-logs-sensitive.json | 2 +- .../resource-names-are-contract.json | 2 +- .../methodologies/cloud-failure-triage.json | 2 +- .../methodologies/cloud-preflight.json | 2 +- .../documents/methodologies/iac-review.json | 2 +- .../skills/cloud-preflight-report.json | 2 +- .../strategies/cost-and-quota-awareness.json | 2 +- .../strategies/diagnostic-query-record.json | 2 +- .../strategies/iam-least-privilege.json | 2 +- .../strategies/preflight-before-deploy.json | 2 +- .../domain-packs/platform/docker/README.md | 2 +- .../failure_dossiers/copy-dot-root.json | 2 +- .../failure_dossiers/secret-in-arg.json | 2 +- .../knowledge/dockerignore-security.json | 2 +- .../knowledge/layers-retain-secrets.json | 2 +- .../knowledge/root-container-risk.json | 2 +- .../methodologies/compose-dev-check.json | 2 +- .../methodologies/dockerfile-review.json | 2 +- .../methodologies/image-smoke-test.json | 2 +- .../skills/validate-docker-build.json | 2 +- .../strategies/healthcheck-meaningful.json | 2 +- .../strategies/multi-stage-runtime.json | 2 +- .../strategies/no-secrets-in-image.json | 2 +- .../strategies/small-build-context.json | 2 +- .../domain-packs/platform/local-dev/README.md | 2 +- .../production-secret-local.json | 2 +- .../failure_dossiers/server-left-running.json | 2 +- .../env-defaults-help-onboarding.json | 2 +- .../generated-files-need-command.json | 2 +- .../knowledge/localhost-not-production.json | 2 +- .../methodologies/dev-server-startup.json | 2 +- .../methodologies/local-bootstrap-check.json | 2 +- .../methodologies/port-conflict-triage.json | 2 +- .../documents/skills/start-dev-smoke.json | 2 +- .../strategies/env-file-boundary.json | 2 +- .../strategies/port-and-process-check.json | 2 +- .../documents/strategies/watcher-scope.json | 2 +- .../domain-packs/risk/supply-chain/README.md | 2 +- .../failure_dossiers/blind-install.json | 2 +- .../failure_dossiers/license-ignored.json | 2 +- .../script-hidden-in-lockfile.json | 2 +- .../knowledge/generated-low-provenance.json | 2 +- .../knowledge/license-missing-is-risk.json | 2 +- .../knowledge/scripts-are-execution.json | 2 +- .../dependency-incident-check.json | 2 +- .../external-skill-promotion.json | 2 +- .../supply-chain-rereview-gate.json | 2 +- .../skills/review-dependency-delta.json | 2 +- .../strategies/lockfile-delta-review.json | 2 +- .../strategies/rereview-external-change.json | 2 +- .../strategies/script-permission-gate.json | 2 +- .../strategies/source-trust-tier.json | 2 +- packages/sdk/js/script/build.ts | 4 +- packages/sdk/js/src/gen/client/client.gen.ts | 260 +-- packages/sdk/js/src/gen/client/types.gen.ts | 16 +- packages/sdk/js/src/gen/client/utils.gen.ts | 20 +- .../sdk/js/src/gen/core/bodySerializer.gen.ts | 12 +- packages/sdk/js/src/gen/core/params.gen.ts | 10 +- .../js/src/gen/core/serverSentEvents.gen.ts | 7 +- packages/sdk/js/src/gen/core/types.gen.ts | 2 +- packages/sdk/js/src/gen/core/utils.gen.ts | 2 +- packages/sdk/js/src/gen/sdk.gen.ts | 1683 ++-------------- packages/sdk/js/src/gen/types.gen.ts | 1756 ++--------------- .../sdk/js/src/v2/gen/client/client.gen.ts | 260 +-- .../sdk/js/src/v2/gen/client/types.gen.ts | 14 +- .../sdk/js/src/v2/gen/client/utils.gen.ts | 20 +- .../js/src/v2/gen/core/bodySerializer.gen.ts | 12 +- packages/sdk/js/src/v2/gen/core/params.gen.ts | 10 +- .../src/v2/gen/core/serverSentEvents.gen.ts | 7 +- packages/sdk/js/src/v2/gen/core/types.gen.ts | 2 +- packages/sdk/js/src/v2/gen/core/utils.gen.ts | 2 +- packages/sdk/js/src/v2/gen/sdk.gen.ts | 1683 ++-------------- packages/sdk/js/src/v2/gen/types.gen.ts | 1756 ++--------------- .../src/feature-plugins/home/tips-view.tsx | 2 +- .../src/feature-plugins/sidebar/footer.tsx | 5 +- packages/tui/src/routes/session/index.tsx | 2 +- packages/ui/src/components/icon.tsx | 22 +- packages/ui/src/components/session-retry.tsx | 6 - packages/ui/src/i18n/ar.ts | 2 - packages/ui/src/i18n/br.ts | 2 - packages/ui/src/i18n/bs.ts | 2 - packages/ui/src/i18n/da.ts | 2 - packages/ui/src/i18n/de.ts | 2 - packages/ui/src/i18n/en.ts | 2 - packages/ui/src/i18n/es.ts | 2 - packages/ui/src/i18n/fr.ts | 2 - packages/ui/src/i18n/ja.ts | 2 - packages/ui/src/i18n/ko.ts | 2 - packages/ui/src/i18n/no.ts | 2 - packages/ui/src/i18n/pl.ts | 2 - packages/ui/src/i18n/ru.ts | 2 - packages/ui/src/i18n/th.ts | 2 - packages/ui/src/i18n/tr.ts | 2 - packages/ui/src/i18n/uk.ts | 2 - packages/ui/src/i18n/zh.ts | 1 - packages/ui/src/i18n/zht.ts | 1 - packages/ui/src/v2/components/icon.tsx | 66 +- 622 files changed, 6928 insertions(+), 20650 deletions(-) delete mode 100644 packages/app/src/components/deepagent/approval-control.tsx delete mode 100644 packages/app/src/components/deepagent/goal-plan-edit-dialog.tsx delete mode 100644 packages/app/src/components/deepagent/goal-start-button.tsx delete mode 100644 packages/app/src/components/im/message-search.tsx delete mode 100644 packages/app/src/components/im/thread-view.tsx create mode 100644 packages/cli/src/ambient.d.ts create mode 100644 packages/cli/src/commands/handlers/acp.ts create mode 100644 packages/cli/src/commands/handlers/agent/list.ts create mode 100644 packages/cli/src/commands/handlers/attach.ts create mode 100644 packages/cli/src/commands/handlers/auth/list.ts create mode 100644 packages/cli/src/commands/handlers/auth/login.ts create mode 100644 packages/cli/src/commands/handlers/auth/logout.ts create mode 100644 packages/cli/src/commands/handlers/db.ts create mode 100644 packages/cli/src/commands/handlers/db/path.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/env-facts.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/goal.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/packs.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/panel.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/review.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/util.ts create mode 100644 packages/cli/src/commands/handlers/deepagent/wiki.ts create mode 100644 packages/cli/src/commands/handlers/export.ts create mode 100644 packages/cli/src/commands/handlers/github.ts create mode 100644 packages/cli/src/commands/handlers/import.ts create mode 100644 packages/cli/src/commands/handlers/mcp/add.ts create mode 100644 packages/cli/src/commands/handlers/mcp/list.ts create mode 100644 packages/cli/src/commands/handlers/models.ts create mode 100644 packages/cli/src/commands/handlers/pr.ts create mode 100644 packages/cli/src/commands/handlers/run.ts create mode 100644 packages/cli/src/commands/handlers/session/delete.ts create mode 100644 packages/cli/src/commands/handlers/session/list.ts create mode 100644 packages/cli/src/commands/handlers/stats.ts create mode 100644 packages/cli/src/commands/handlers/uninstall.ts create mode 100644 packages/cli/src/commands/handlers/upgrade.ts create mode 100644 packages/cli/src/commands/handlers/web.ts create mode 100644 packages/cli/src/services/session-client.ts create mode 100644 packages/core/src/deepagent/context/curator.ts create mode 100644 packages/core/src/deepagent/context/ingest.ts create mode 100644 packages/core/src/deepagent/context/token-meter.ts create mode 100644 packages/core/src/deepagent/context/working-set.ts create mode 100644 packages/core/src/public/deepagent-code.ts delete mode 100644 packages/core/test/deepagent/prompt-policy.test.ts delete mode 100644 packages/core/test/im-b3.test.ts create mode 100644 packages/core/test/public-deepagent-code.test.ts create mode 100644 packages/deepagent-code/specs/v2/api.ts delete mode 100644 packages/deepagent-code/src/server/routes/instance/httpapi/groups/oversight.ts delete mode 100644 packages/deepagent-code/src/server/routes/instance/httpapi/groups/webhook.ts delete mode 100644 packages/deepagent-code/src/server/routes/instance/httpapi/handlers/oversight.ts delete mode 100644 packages/deepagent-code/src/server/routes/instance/httpapi/handlers/webhook.ts create mode 100644 packages/deepagent-code/src/wiki/execution-archiver.ts delete mode 100644 packages/deepagent-code/test/deepagent/plan-status-cache.test.ts delete mode 100644 packages/deepagent-code/test/server/httpapi-webhook.test.ts delete mode 100644 packages/deepagent-code/test/session/goal-steer.test.ts delete mode 100644 packages/deepagent-code/test/session/overflow.test.ts create mode 100644 packages/deepagent-code/test/wiki/execution-archiver.test.ts delete mode 100644 packages/deepagent-code/test/wiki/session-archive-wiring.test.ts diff --git a/.gitignore b/.gitignore index b3452621..2a77479a 100644 --- a/.gitignore +++ b/.gitignore @@ -13,10 +13,6 @@ tmp dist ts-dist .turbo -# Web/edge build artifacts (nitro .output, cloudflare .wrangler) — e.g. packages/console, packages/stats -.output -.wrangler -packages/console/app/public/sitemap.xml **/.serena .serena/ **/.omo diff --git a/README.md b/README.md index 3e8d672f..da24d381 100644 --- a/README.md +++ b/README.md @@ -6,102 +6,68 @@

-

The AI coding agent that remembers, plans, collaborates, and finishes

+

AI coding agent with persistent memory and control plane

English | - 简体中文 | - Enterprise + 简体中文

-

Desktop 1.4.1 · DeepAgent Core V4.1

- --- -DeepAgent Code is an AI coding workspace for work that lasts longer than one prompt. It combines a production coding-agent runtime with durable sessions, connected project memory, live planning, code intelligence, multi-agent collaboration, and human oversight. - -You can ask for a small edit, guide a running task without interrupting it, hand over a migration with objective completion criteria, or bring several specialist agents into a decision. DeepAgent keeps the work coherent across turns, restarts, tools, people, and projects. - -## One Workspace, Three Ways to Work - -Choose the collaboration style that fits the task: - -| Mode | You provide | DeepAgent does | -|---|---|---| -| **Auto** | A request | Defines the objective, designs and plans as needed, then executes end to end | -| **Loop** | A goal | Writes an editable `goal+plan.md` and advances it through plan, execute, verify, and iterate ticks | -| **Design** | Your `goal+plan.md` | Executes your design faithfully without redefining its objective or completion criteria | - -Autonomy and permission are independent. Use **Read-only**, **Request approval**, or **Full access** without changing the collaboration mode. +DeepAgent Code is an AI coding agent built on persistent document memory. It keeps [opencode](https://github.com/sst/opencode)'s runtime foundations and adds a control plane so the agent behaves less like a one-shot chat and more like a teammate that remembers your project, sharpens vague asks, and goes deep on hard problems. -## Stay in Control While It Works +The features below start from a real need — something a plain coding agent, opencode included, leaves on the table — and work down to the architecture we built to serve it. -DeepAgent is built for active collaboration, not fire-and-forget automation. +## What You Can Do -- **Live steering:** send new guidance while a model turn or tool is running. The message is durably admitted and absorbed at the next safe provider-turn boundary without aborting in-flight work. -- **Goal steering:** guidance sent to an active goal is folded into the next tick, preserving the current tool and plan state. -- **Hot plan editing:** edit a running or paused goal. Stable step IDs, evidence, completed work, and the new plan version carry into the next tick. -- **Explicit queueing:** queue a future activity when the instruction should begin after the current activity instead of changing it. -- **Pause, resume, take over, or roll back:** every long-running workflow has a human control path and a durable audit trail. +### Bring your history over — switch tools without starting from zero -## Memory You Can Inspect and Govern +**The need:** You've built up months of context in another agent — Codex or Claude Code — and switching tools normally means abandoning all of it: the conversations, the accumulated memory, the skills you tuned. That cost alone keeps people on tools they've outgrown. -DeepAgent does not hide memory in an opaque prompt. Project state lives in typed, versioned documents with provenance, confidence, scope, status, and links. +**What DeepAgent does:** One-click import of your existing history. Point it at a Codex or Claude Code installation and it hot-imports your chat sessions, memory, and skills straight into DeepAgent — reading each tool's on-disk format, normalizing it, and replaying it into the document graph so imported conversations behave like native ones. Secrets are redacted on the way in, imported projects stay isolated so nothing collides with your active work, and re-running an import converges instead of duplicating. Available from the Settings "Import history" panel, a History view in the sidebar, or the `import-history` CLI command. Migration is a few minutes, not a fresh start. -- Session-private working context stays with the current conversation. -- Project-shared facts and decisions follow the repository. -- User-global preferences can travel across projects. -- Built-in skills and domain packs remain versioned system knowledge. -- Sealed evaluator material stays audit-only and never enters model context. +### Keep one conversation going indefinitely -Learning follows a governed lifecycle: evidence creates a candidate, isolated review or a human decision changes its status, and regression/ablation gates publish a reproducible knowledge snapshot. Rejection reasons remain durable so discarded patterns are not silently relearned. +**The need:** Long tasks overflow the context window. Most agents respond by truncating history or summarizing everything at a threshold — so mid-task the agent forgets a decision you made an hour ago, or the window fills with stale tool output and quality falls off a cliff. -The **Repo & Wiki** view makes this system readable. Browse knowledge and execution archives, search across the repository, follow docs-to-code links, inspect lineage, and promote useful run evidence into governed knowledge. +**What DeepAgent does:** Your conversation is treated as a continuously maintained work state, not a growing chat log. Before every turn, the agent rebuilds a working set — the task anchor, the most recent exchanges verbatim, active file references, and only the older facts that are relevant right now — while the full history is archived durably and stays queryable. The working set is held to a hard fraction of the model window, so there's always room for the model to actually think and respond. You just keep talking; the agent keeps focus. -## Connected Context, Not a Larger Prompt +### Switch windows, fork freely, never lose memory -DeepAgent connects four views of the project: +**The need:** You want to try two approaches, or hand the work to a fresh conversation, without starting from amnesia and without polluting the original thread. -1. **Code graph:** files, symbols, imports, calls, diagnostics, and references. -2. **Knowledge graph:** strategies, methodologies, facts, skills, and failure dossiers. -3. **Project memory:** decisions, constraints, environment facts, and learned conventions. -4. **Document graph:** plans, designs, worklogs, evaluations, run context, and evidence. +**What DeepAgent does:** Fork any conversation from a chosen message. The fork opens carrying the parent's memory up to that point, shows a full-width "derived from" marker at the top of its transcript, and nests folder-style under its origin in the session tree (subagents and forks alike, up to three levels deep). Knowledge flows up a scope hierarchy — what one session learns can be promoted to the whole project, and cross-project preferences live at the user-global layer — so switching windows is a clean handoff, not a reset. -The Session V2 runner assembles context from explicit sources under a durable Context Epoch. It selects linked evidence within budget, records why each reference was admitted or rejected, and preserves the current goal, constraints, decisions, open questions, next steps, and relevant files during compaction. +### Ask roughly, and let the agent sharpen it -Prompt caching remains effective across long runs: stable system instructions stay byte-stable, while plans, steering, budgets, round results, and other volatile state are appended in a dedicated tail block. +**The need:** A half-formed prompt gets a half-useful answer, and you don't always know how to phrase what you want. -## Built for Difficult Work +**What DeepAgent does:** Two scenario modes on the composer. **Direct** sends your prompt as-is — you own the wording. **Intelligence** refines a rough ask into a sharper prompt, surfaces a draft plan and decision suggestions, and waits for your confirmation before it automates anything. You decide how much the agent shapes the request. -### AI IDE +### Go deep on genuinely hard problems -Query code by symbol and intent instead of guessing file locations. DeepAgent combines LSP definitions, references, call chains, type information, diagnostics, rename previews, and cross-file evidence. Unsaved editor buffers participate in LSP updates, so analysis follows the code you are actually editing. +**The need:** Complex work — an architecture decision, a tricky migration, a subtle bug — needs more than a single confident pass. It needs research, a second opinion, and someone actively trying to poke holes. -### Domain packs +**What DeepAgent does:** At higher work strengths the primary agent decomposes the task, fans it out to focused subagents that research modules in parallel, synthesizes their findings, and then runs independent reviewers whose job is to *break* the plan rather than agree with it. Fan-out is bounded by a configurable concurrency ceiling, and live subagents surface in a session side panel and inline in the transcript so you can watch and jump into any of them. -Composable domain packs add language, framework, platform, hardware, business, and risk expertise without hardcoding it into the core. Packs activate from the problem profile, resolve conflicts with stricter-policy-wins semantics, and are snapshot-locked for reproducible runs. +### Chat with your team and your agents in one place -### Specialist agents and Expert Panel +**The need:** Coordinating with teammates and driving agents usually happens in two different tools. -DeepAgent can partition independent work across bounded, isolated workers. Write-capable subagents receive dedicated worktrees, return compact summaries and artifact references, and leave their full transcripts available for inspection. +**What DeepAgent does:** A per-project group chat lives in the session side panel. @mention an agent as a chat member and it runs the full agent loop — query code, generate, fix — pulling project knowledge and recent messages for context, then replies inline with live progress streaming. -For high-risk decisions, convene an **Expert Panel**. Correctness, security, performance, architecture, and reproducibility lenses review the same frozen question, debate anonymously for up to three rounds, and feed a deterministic arbiter that preserves minority opinions and fails closed to human review. +## How It Works -### Team and agent messaging +Each capability above is served by a control-plane primitive underneath. These are the parts a plain runtime doesn't have. -Project IM brings people and agents into the same thread. Mention an agent to start a scoped run with project context, stream its progress, inspect its artifacts, and keep the answer attached to the conversation that requested it. +**Four-graph unification** — Code, knowledge, project memory, and the document graph are unified into one typed, bidirectionally-linked store. When the agent pulls context, a change to a symbol surfaces the design decisions, past diagnoses, and knowledge actually linked to it — connected context, not four disconnected keyword searches. -## DeepAgent Core V4.1 +**Domain packs** — 140+ composable knowledge packages spanning languages, frameworks, platforms (cloud, Kubernetes, CI), hardware, and business/risk domains (security, privacy, compliance). Each pack bundles typed documents (strategies, methodologies, knowledge, skills, failure dossiers) with detectors that auto-activate the right packs for your task; conflicts resolve stricter-policy-wins, and the active set is version-locked so a run is reproducible. Core stays domain-neutral — expertise is data on disk, not hardcoded. -V4.1 brings the complete DeepAgent control plane together: +**Tiered knowledge invocation** — A monotonic strength ladder (`general → high → xhigh → max → ultra`) gates how much control-plane machinery engages. `general` stays close to the plain runtime — fast and cheap. Higher rungs progressively unlock durable knowledge, project handoff summaries, heavier strategy/methodology tiers, and multi-agent orchestration. You pay for depth only when you dial it up. -- **Durable Session V2:** prompt admission is persisted before execution; exact retries do not duplicate user intent; same-session wakes coalesce safely. -- **One provider-turn contract:** native and AI SDK providers share the same budget, permission, artifact, audit, learning, and close lifecycle. -- **Single durable truth:** DocumentStore owns documents, plans, learning candidates, governance state, and version conflicts through atomic, recoverable writes. -- **Event-driven Agent OS:** durable events, priority routing, backpressure, worker claims, leases, handoffs, retries, dead-letter recovery, and distributed placement coordinate autonomous work. -- **Consumer-driven goals:** `goal.tick.requested` claims and executes one idempotent tick, records facts, and schedules the next tick only when the durable goal remains eligible. -- **Human oversight:** approval queues, trace correlation, takeover, rollback, Wiki archives, notifications, and organization/workspace isolation remain part of the execution path. -- **Secure integrations:** MCP credentials use environment references or native OS secret storage; catalog risk, runtime permissions, trusted sources, and tool capability checks fail closed. +**Self-learning** — After work lands, the agent proposes candidate knowledge, facts, and methodologies. Promotion is evidence-gated (a test passed, a diagnostic cleared, a validation confirmed) and user-controllable — durable knowledge is carried over deliberately, not silently guessed. Session-stable conclusions consolidate into project memory over time, so the next session starts smarter about *your* codebase. ## Installation @@ -117,67 +83,6 @@ deepagent-code deepagent ``` -## Adding a Provider - -Before you can run a task, DeepAgent Code needs at least one model provider. It -supports 75+ providers through the [AI SDK](https://ai-sdk.dev/) and -[models.dev](https://models.dev), plus any OpenAI- or Anthropic-compatible -endpoint. Pick whichever path fits how you work. - -### Desktop app (recommended) - -Open **Settings → Providers**: - -- **Official providers** (OpenAI, Anthropic, DeepSeek, Google, xAI, ZhipuAI/GLM): - click **Connect**, paste your API key. -- **Any other provider or gateway**: click **Connect** on *Custom provider*, paste - the **Base URL** and **API key**. DeepAgent Code auto-detects the protocol - (OpenAI-compatible or Anthropic) and discovers the available models from the - endpoint's `/models` list — you don't have to fill anything else. - -Model specs (context window, reasoning) are auto-filled by matching each model -against the models.dev catalog. You can reopen a custom provider to override a -model's context/reasoning/temperature; those overrides are best-effort and not -guaranteed to keep the model working. - -### Terminal - -```bash -# Log in to a provider (official providers, or a plugin auth flow) -deepagent auth login - -# See what's connected -deepagent auth list -``` - -### Config file - -Providers also live in `~/.deepagent/code/config.jsonc`. A custom -OpenAI-compatible endpoint looks like this — set `discovery: true` to have models -refreshed from the endpoint at runtime, or list them explicitly under `models`: - -```jsonc -{ - "$schema": "https://deepagent-code.ai/config.json", - "provider": { - "myprovider": { - "name": "My Provider", - "npm": "@ai-sdk/openai-compatible", - "discovery": true, - "options": { - "baseURL": "https://api.myprovider.com/v1", - "apiKey": "sk-..." - } - } - } -} -``` - -Official-provider keys added via the app/CLI are stored separately in -`~/.deepagent/code/auth.json`, not in the config file. See the -[providers guide](https://deepagent-code.ai/docs/providers/) for the full -reference (base URL overrides, headers, per-model config, gateways). - ## Quick Example Start the agent and give it a task: @@ -210,7 +115,7 @@ On your next session, when you ask to add rate limiting elsewhere, the agent alr ## Architecture -```text +``` ┌─────────────────────────────────────────────────────────────┐ │ Control Plane (DeepAgent additions) │ │ • Four-graph unified store (code + knowledge + memory + doc)│ @@ -218,7 +123,6 @@ On your next session, when you ask to add rate limiting elsewhere, the agent alr │ • Domain pack system (composable, auto-activating knowledge)│ │ • Context assembly & admission gates │ │ • Multi-agent orchestration & adversarial review │ -│ • Supervised goal loop & expert panel (event-driven) │ │ • Evidence-gated learning & work-strength ladder │ └─────────────────────────────────────────────────────────────┘ │ @@ -239,57 +143,24 @@ On your next session, when you ask to add rate limiting elsewhere, the agent alr └─────────────────────────────────────────────────────────────┘ ``` -The full architecture and its invariants are documented in [Architecture & Design](design/README.md). - -## Build From Source - -DeepAgent Code uses Bun 1.3.14. - -```bash -git clone https://github.com/deepagent-ltd/deepagent-code.git -cd deepagent-code -bun install -``` - -Start the Desktop app: - -```bash -bun run dev:desktop -``` - -Start the terminal experience: - -```bash -bun run dev -``` - -Run a one-shot task: - -```bash -bun run --cwd packages/deepagent-code dev run "add rate limiting to /api/users" -``` - -Import existing Codex or Claude Code history: - -```bash -bun run --cwd packages/deepagent-code dev import-history --from codex --dry-run -``` +DeepAgent's control plane operates at provider-turn boundaries: it selects context before each model call and writes evidence back into the document graph afterward. It does not replace opencode's runtime — it layers on top. ## Documentation -- [Providers & Models](https://deepagent-code.ai/docs/providers/) -- [Architecture & Design](design/README.md) -- [Security Policy](SECURITY.md) -- [Privacy Policy](PRIVACY.md) -- [Contributing](CONTRIBUTING.md) -- [Changelog](CHANGELOG.md) +- [Architecture & Design](design/README.md) — Control plane, code intelligence, MCP security model +- [Security Policy](SECURITY.md) — Vulnerability reporting, known limitations +- [Privacy Policy](PRIVACY.md) — Data handling and storage +- [Contributing](CONTRIBUTING.md) — Development setup and guidelines +- [Changelog](CHANGELOG.md) — Release history ## License & Attribution -DeepAgent Code is licensed under **AGPL-3.0-or-later**. If you modify and run it as a network service, you must make the corresponding source available to its users. +DeepAgent Code is licensed under **AGPL-3.0-or-later**. If you modify and run it as a network service, you must make your source code available to users. -DeepAgent Code is derived from [opencode](https://github.com/sst/opencode) under the MIT License. See [NOTICE](NOTICE) for upstream attribution. No endorsement by opencode or its contributors is implied. +This project is derived from [opencode](https://github.com/sst/opencode) (MIT License). See [NOTICE](NOTICE) for the upstream license and attribution. No endorsement by opencode or its contributors is implied. --- -

Built by DeepAgent

+

+ Built by DeepAgent +

diff --git a/README.zh.md b/README.zh.md index 15a1714d..9d1618ab 100644 --- a/README.zh.md +++ b/README.zh.md @@ -6,102 +6,68 @@

-

会记忆、会规划、会协作,也能把工作真正做完的 AI 编程智能体

+

具备持久记忆与控制平面的 AI 编程智能体

English | - 简体中文 | - Enterprise 版本 + 简体中文

-

桌面版 1.4.1 · DeepAgent Core V4.1

- --- -DeepAgent Code 是一套面向长期工作的 AI 编程工作区。它把生产级编程智能体运行时与持久会话、相互连通的项目记忆、实时计划、代码智能、多智能体协作和人类监督组合在一起。 - -你可以让它完成一次小改动,在任务运行中继续补充指令,把一场迁移交给带客观完成判据的目标回路,或者召集多位专家共同审阅一项决策。DeepAgent 会让工作在多轮对话、进程重启、工具调用、团队成员和不同项目之间保持连贯。 - -## 一个工作区,三种协作方式 - -按任务选择最合适的协作方式: - -| 模式 | 你提供 | DeepAgent 负责 | -|---|---|---| -| **自动(Auto)** | 一项需求 | 自行明确目标,按需设计和规划,再端到端执行 | -| **循环(Loop)** | 一个目标 | 生成可编辑的 `goal+plan.md`,按计划、执行、校验、迭代逐 tick 推进 | -| **设计(Design)** | 你编写的 `goal+plan.md` | 忠实执行你的设计,不重新定义目标或完成判据 | - -自主程度和权限相互独立。你可以在不改变协作模式的情况下选择**只读**、**请求批准**或**完全访问**。 +DeepAgent Code 是一个构建在持久文档记忆之上的 AI 编程智能体。它保留了 [opencode](https://github.com/sst/opencode) 的运行时基座,并在其上叠加了一层控制平面——让智能体不再像一次性的对话工具,而更像一位记得住你项目、会替你打磨模糊需求、能对硬骨头深挖到底的队友。 -## 它在工作,你仍然掌控全局 +下面的每一项特性,都从一个真实的需求出发——一个普通编程智能体(包括 opencode)尚未满足的需求——再向下讲到我们为满足它而构建的底层架构。 -DeepAgent 为持续协作而设计,不是一个发出指令后只能等待的黑盒。 +## 你可以做什么 -- **实时 Steering:** 模型或工具仍在运行时继续发送指导。消息会先持久化,再在下一个安全的供应商轮次边界被吸收,不会中断在飞工作。 -- **Goal Steering:** 发给活跃目标的指导会进入下一个 tick,同时保留当前工具状态和计划状态。 -- **运行中计划热编辑:** 编辑正在运行或已暂停的目标。稳定的步骤 ID、证据、已完成工作和新计划版本会一起进入下一 tick。 -- **显式排队:** 当一条指令应该在当前 activity 结束后独立开始时,把它放入未来队列,而不是改变当前工作。 -- **暂停、恢复、接管或回滚:** 每个长跑流程都有清晰的人类控制路径和持久审计记录。 +### 把历史一起带过来——换工具不必从零开始 -## 看得见、管得住的记忆 +**需求:** 你已经在另一个智能体里——Codex 或 Claude Code——积累了几个月的上下文,而换工具通常意味着把这一切统统丢下:那些对话、沉淀下来的记忆、你调好的技能。单是这份代价,就足以把人留在早该告别的工具上。 -DeepAgent 不会把记忆藏在不可见的提示词里。项目状态保存在带类型、版本、来源、置信度、作用域、状态和链接的文档中。 +**DeepAgent 的做法:** 一键导入你已有的历史。把它指向一个 Codex 或 Claude Code 的安装目录,它就会把你的会话、记忆和技能热导入 DeepAgent——读取各工具的本地格式,归一化后重放进文档图,让导入的对话表现得和原生对话一样。导入过程中会对密钥做脱敏,导入的项目彼此隔离、不会和你正在进行的工作冲突,重复导入会收敛而不是产生重复。入口有三处:设置里的"导入历史"面板、侧栏的历史视图,以及 `import-history` 命令行。迁移只需几分钟,而不是推倒重来。 -- 会话私有工作上下文只属于当前对话。 -- 项目共享事实与决策跟随代码仓库。 -- 用户全局偏好可以跨项目使用。 -- 内置技能与领域包保持系统级版本管理。 -- 封存的评测材料仅用于审计,永不进入模型上下文。 +### 一直对话下去,不必换新 -学习遵循可治理的生命周期:证据生成候选,隔离审阅或人工决策改变候选状态,回归与消融门发布可复现的知识快照。拒绝理由会持久保存,因此被淘汰的模式不会在后台被悄悄重新学习。 +**需求:** 长任务会撑爆上下文窗口。多数智能体的应对方式是截断历史,或在阈值处一刀切地整体摘要——于是任务进行到一半,智能体忘了你一小时前拍的板,或者窗口被陈旧的工具输出塞满,质量断崖式下跌。 -**仓库与百科(Repo & Wiki)** 让这套系统对人可读。你可以浏览知识与执行档案、搜索整个仓库、沿文档到代码的链接探索上下文、检查来源链,并把有价值的运行证据升格为受治理知识。 +**DeepAgent 的做法:** 你的对话被当作一份持续维护的工作状态,而不是不断变长的聊天记录。每一轮开始前,智能体都会重建一份工作面——任务锚点、最近若干轮的原文、活跃的文件引用,以及此刻真正相关的旧事实——同时完整历史被持久归档、随时可查。工作面被严格控制在模型窗口的一个固定比例以内,永远给模型留足思考和作答的余地。你只管一直说,智能体替你保持专注。 -## 相互连接的上下文,而不是更长的提示词 +### 随手分叉、切换窗口,记忆不丢 -DeepAgent 把项目的四个视图连接在一起: +**需求:** 你想同时试两条思路,或把工作交给一个全新的对话,却不想从头失忆重来,也不想把原来的线程搅乱。 -1. **代码图:** 文件、符号、导入、调用、诊断与引用。 -2. **知识图:** 策略、方法论、事实、技能与故障档案。 -3. **项目记忆:** 决策、约束、环境事实与已学习的项目约定。 -4. **文档图:** 计划、设计、工作日志、评测、运行上下文与证据。 +**DeepAgent 的做法:** 从任意一条消息分叉当前对话。分叉出的新对话会继承父对话到该点为止的记忆,在时间线顶部显示一条贯穿窗口的"从对话派生"分割线,并像文件夹一样嵌套挂在来源对话之下(子 agent 与分叉同理,最多三层深)。知识沿作用域层级向上流动——单个会话学到的东西可提升到整个项目,跨项目的偏好则沉淀在用户全局层——所以换窗口是一次干净的交接,而非一次清零重来。 -Session V2 运行器在持久 Context Epoch 下从明确的 Context Source 装配上下文。它在预算内选择相互关联的证据,记录每条引用为什么被准入或拒绝,并在压缩时保留当前目标、约束、决策、开放问题、后续步骤与相关文件。 +### 想到哪问到哪,让智能体替你打磨 -长跑任务也能持续命中提示词缓存:稳定 system 指令保持字节级稳定,计划、Steering、预算、轮次结果等易变状态只追加到独立的尾部区块。 +**需求:** 半成品的提问只能换来半有用的回答,而你未必总知道该怎么把想要的东西说清楚。 -## 为困难工作而生 +**DeepAgent 的做法:** 输入框上有两种情景模式。**直接**模式原样发送你的提示——措辞由你做主。**智能**模式会把粗糙的想法打磨成更精准的提示,给出草拟的方案和决策建议,并在自动执行任何操作前等你确认。智能体替你塑形到什么程度,由你决定。 -### AI IDE +### 对真正的难题深挖到底 -按符号和意图查询代码,不再猜文件位置。DeepAgent 组合 LSP 定义、引用、调用链、类型信息、诊断、重命名预览与跨文件证据。未保存的编辑器 buffer 也会实时进入 LSP,因此分析看到的是你正在编辑的代码。 +**需求:** 复杂的工作——一个架构决策、一次棘手的迁移、一个隐蔽的 bug——需要的不止一次自信的单程作答。它需要调研、需要第二意见、需要有人主动来挑刺。 -### 领域包 +**DeepAgent 的做法:** 在更高的工作强度下,主智能体会拆解任务,扇出给专注的子 agent 并行调研各个模块,综合它们的发现,再运行独立的审阅者——审阅者的职责是"击破"方案,而不是附和。扇出受可配置的并发上限约束;运行中的子 agent 会出现在会话侧栏面板和时间线内联卡片里,你可以旁观并随时跳进任意一个。 -可组合的领域包提供语言、框架、平台、硬件、业务与风险知识,而不把专业逻辑硬编码进内核。领域包根据问题画像自动激活,以“更严格策略优先”解决冲突,并锁定快照以保证运行可复现。 +### 团队与智能体,在同一处协作 -### 专业子智能体与 Expert Panel +**需求:** 和队友协调、驱动智能体,通常发生在两个不同的工具里。 -DeepAgent 可以把独立工作拆分给数量有界、相互隔离的 Worker。具备写权限的子智能体获得独立 worktree,只向父会话返回紧凑摘要和工件引用,完整执行记录仍可随时查看。 +**DeepAgent 的做法:** 每个项目的群聊就在会话侧栏里。把某个智能体 @ 进来当作聊天成员,它便会跑完整的智能体回路——查代码、生成、修复——拉取项目知识与最近消息作为上下文,然后带着实时进度在群里内联回复。 -高风险决策可以召集 **Expert Panel**。正确性、安全、性能、架构与可复现性等专家视角审阅同一个冻结问题,进行最多三轮匿名辩论,再由确定性仲裁器生成裁定。少数派意见会被保留,无法安全达成一致时会失败关闭并交给人类。 +## 它是怎么做到的 -### 团队与智能体消息 +上面每一项能力,底层都由一个控制平面原语来支撑。这些正是普通运行时所没有的部分。 -项目 IM 把团队成员和智能体放进同一条讨论。@ 某个智能体即可启动有明确作用域的运行,使用项目上下文、流式展示进度、关联执行工件,并把答案留在发起任务的对话里。 +**四图合一** — 代码图、知识图、项目记忆、文档图被统一进同一个带类型、双向链接的存储。当智能体拉取上下文时,对某个符号的改动会连带浮现出与它真正相连的设计决策、过往诊断和知识——是连通的上下文,而不是四次互不相干的关键词检索。 -## DeepAgent Core V4.1 +**领域包** — 140+ 个可组合的知识包,覆盖编程语言、框架、平台(云、Kubernetes、CI)、硬件,以及业务/风险领域(安全、隐私、合规)。每个包捆绑了带类型的文档(策略、方法论、知识、技能、故障档案)与探测器,能为你的任务自动激活相应的包;冲突按"更严策略优先"消解,激活的集合会被版本锁定,从而让一次运行可复现。内核保持领域中立——专业能力是磁盘上的数据,而非写死的代码。 -V4.1 把完整的 DeepAgent 控制平面汇聚在一起: +**知识分级调用** — 一条单调递增的强度阶梯(`general → high → xhigh → max → ultra`)决定控制平面机器启动到什么程度。`general` 贴近原生运行时——又快又省。越往上,逐级解锁持久知识、项目交接摘要、更重的策略/方法论层,以及多智能体编排。只有当你上调档位时,才为深度付费。 -- **持久 Session V2:** prompt 先持久准入、再调度执行;精确重试不会复制用户意图;同一 Session 的唤醒会安全合并。 -- **统一供应商轮次合同:** native 与 AI SDK provider 共享预算、权限、工件、审计、学习和关闭生命周期。 -- **单一持久真相:** DocumentStore 通过原子、可恢复写入统一管理文档、计划、学习候选、治理状态和版本冲突。 -- **事件驱动 Agent OS:** 持久事件、优先级路由、回压、Worker claim、租约、handoff、重试、死信恢复与分布式 placement 协调自主工作。 -- **消费者驱动 Goal:** `goal.tick.requested` 每次认领并执行一个幂等 tick,记录事实,并只在持久目标仍满足条件时调度下一 tick。 -- **人类监督:** 审批队列、全链路 trace、接管、回滚、Wiki 档案、通知,以及组织和 workspace 隔离始终位于执行路径上。 -- **安全集成:** MCP 凭据使用环境变量引用或原生操作系统 secret storage;目录风险、运行时权限、可信来源和工具 capability 逐层失败关闭。 +**自学习** — 工作落地后,智能体会提出候选的知识、事实与方法论。晋升是证据门控的(一项测试通过、一条诊断清零、一次校验确认)且由用户掌控——持久知识是被有意结转的,而非后台悄悄猜出来的。会话中稳定的结论会随时间巩固进项目记忆,于是下一次会话对*你的*代码库上手更聪明。 ## 安装 @@ -117,62 +83,6 @@ deepagent-code deepagent ``` -## 添加供应商 - -在运行任务之前,DeepAgent Code 至少需要一个模型供应商。它通过 -[AI SDK](https://ai-sdk.dev/) 和 [models.dev](https://models.dev) 支持 75+ 家供应商, -以及任意 OpenAI 或 Anthropic 兼容的接口。按你习惯的方式选一种即可。 - -### 桌面应用(推荐) - -打开 **设置 → 供应商(Settings → Providers)**: - -- **官方供应商**(OpenAI、Anthropic、DeepSeek、Google、xAI、智谱/GLM):点击 - **连接**,粘贴你的 API Key。 -- **其他供应商或网关**:在「自定义供应商」上点击 **连接**,填入 **Base URL** 和 - **API Key**。DeepAgent Code 会自动探测协议(OpenAI 兼容或 Anthropic),并从接口的 - `/models` 列表自动发现可用模型——其余字段无需填写。 - -模型规格(上下文窗口、推理能力)会通过与 models.dev 目录按模型 id 匹配来自动补全。 -你可以再次打开自定义供应商,覆盖某个模型的上下文/推理/温度;这些覆盖为尽力而为的默认值, -修改后不保证模型仍能正常使用。 - -### 终端 - -```bash -# 登录供应商(官方供应商,或插件鉴权流程) -deepagent auth login - -# 查看已连接的供应商 -deepagent auth list -``` - -### 配置文件 - -供应商也保存在 `~/.deepagent/code/config.jsonc` 中。一个自定义 OpenAI 兼容接口如下—— -设 `discovery: true` 让模型在运行时从接口刷新,或在 `models` 下显式列出: - -```jsonc -{ - "$schema": "https://deepagent-code.ai/config.json", - "provider": { - "myprovider": { - "name": "My Provider", - "npm": "@ai-sdk/openai-compatible", - "discovery": true, - "options": { - "baseURL": "https://api.myprovider.com/v1", - "apiKey": "sk-..." - } - } - } -} -``` - -通过应用/CLI 添加的官方供应商密钥单独存放在 `~/.deepagent/code/auth.json`,不在配置文件里。 -完整参考(Base URL 覆盖、请求头、逐模型配置、网关)见 -[供应商文档](https://deepagent-code.ai/docs/providers/)。 - ## 快速示例 启动智能体并交给它一个任务: @@ -205,7 +115,7 @@ deepagent-code "为 /api/users 端点添加限流" ## 架构 -```text +``` ┌─────────────────────────────────────────────────────────────┐ │ 控制平面(DeepAgent 新增) │ │ • 四图合一存储(代码 + 知识 + 记忆 + 文档) │ @@ -213,7 +123,6 @@ deepagent-code "为 /api/users 端点添加限流" │ • 领域包系统(可组合、自动激活的知识) │ │ • 上下文装配与准入门 │ │ • 多智能体编排与对抗式审阅 │ -│ • 受监督的目标回路与专家团(事件驱动) │ │ • 证据门控的学习 + 工作强度阶梯 │ └─────────────────────────────────────────────────────────────┘ │ @@ -234,57 +143,24 @@ deepagent-code "为 /api/users 端点添加限流" └─────────────────────────────────────────────────────────────┘ ``` -完整架构与不变量见 [架构与设计](design/README.md)。 - -## 从源码运行 - -DeepAgent Code 使用 Bun 1.3.14。 - -```bash -git clone https://github.com/deepagent-ltd/deepagent-code.git -cd deepagent-code -bun install -``` - -启动桌面应用: - -```bash -bun run dev:desktop -``` - -启动终端界面: - -```bash -bun run dev -``` - -执行一次性任务: - -```bash -bun run --cwd packages/deepagent-code dev run "为 /api/users 添加限流" -``` - -导入已有 Codex 或 Claude Code 历史: - -```bash -bun run --cwd packages/deepagent-code dev import-history --from codex --dry-run -``` +DeepAgent 的控制平面在供应商轮次的边界上运作:在每次模型调用前挑选上下文,调用后把证据写回文档图。它不替换 opencode 的运行时——只是叠加在其之上。 ## 文档 -- [供应商与模型](https://deepagent-code.ai/docs/providers/) -- [架构与设计](design/README.md) -- [安全策略](SECURITY.md) -- [隐私策略](PRIVACY.md) -- [贡献指南](CONTRIBUTING.md) -- [更新日志](CHANGELOG.md) +- [架构与设计](design/README.md) — 控制平面、代码智能、MCP 安全模型 +- [安全策略](SECURITY.md) — 漏洞上报、已知限制 +- [隐私政策](PRIVACY.md) — 数据处理与存储 +- [贡献指南](CONTRIBUTING.md) — 开发环境与规范 +- [更新日志](CHANGELOG.md) — 发布历史 ## 许可与署名 -DeepAgent Code 使用 **AGPL-3.0-or-later** 许可。如果你修改本项目并将其作为网络服务运行,必须向服务用户提供对应源代码。 +DeepAgent Code 采用 **AGPL-3.0-or-later** 许可。如果你修改并将其作为网络服务运行,必须向用户提供你的源代码。 -DeepAgent Code 基于 [opencode](https://github.com/sst/opencode) 的 MIT 许可代码演进而来。上游署名见 [NOTICE](NOTICE)。本项目不暗示 opencode 或其贡献者的任何背书。 +本项目衍生自 [opencode](https://github.com/sst/opencode)(MIT 许可)。完整的上游许可与署名见 [NOTICE](NOTICE)。本项目不暗示 opencode 或其贡献者的任何背书。 --- -

Built by DeepAgent

+

+ 由 DeepAgent 打造 +

diff --git a/bun.lock b/bun.lock index 82ed0bd7..5e95c744 100644 --- a/bun.lock +++ b/bun.lock @@ -29,7 +29,7 @@ }, "packages/app": { "name": "@deepagent-code/app", - "version": "1.4.0", + "version": "1.0.0-beta", "dependencies": { "@codemirror/autocomplete": "6", "@codemirror/commands": "6", @@ -109,15 +109,20 @@ "lildax": "./bin/lildax.cjs", }, "dependencies": { + "@agentclientprotocol/sdk": "^0.21.0", "@deepagent-code/core": "workspace:*", "@deepagent-code/sdk": "workspace:*", "@deepagent-code/server": "workspace:*", "@deepagent-code/tui": "workspace:*", "@effect/platform-node": "catalog:", "@opentui/core": "catalog:", + "@opentui/keymap": "catalog:", "@opentui/solid": "catalog:", "@parcel/watcher": "2.5.1", + "deepagent-code": "workspace:*", + "drizzle-orm": "catalog:", "effect": "catalog:", + "jsonc-parser": "^3.3.1", "solid-js": "catalog:", }, "devDependencies": { @@ -344,7 +349,7 @@ }, "packages/desktop": { "name": "@deepagent-code/desktop", - "version": "1.4.0", + "version": "1.2.0", "dependencies": { "@zip.js/zip.js": "2.7.62", "effect": "catalog:", diff --git a/design/README.md b/design/README.md index bd41fcfb..86c26ebc 100644 --- a/design/README.md +++ b/design/README.md @@ -1,266 +1,120 @@ -# DeepAgent Code Architecture & Design +# DeepAgent Code — Architecture & Design -> Public architecture baseline for DeepAgent Core V4.1. +> **Public design overview.** Internal implementation details and roadmap docs live in the private `docs/` tree (not version-controlled). This directory contains the publicly visible architectural narrative. -DeepAgent Code is a document-centered, event-driven AI coding system. It combines a coding-agent runtime with a durable control plane that owns context, planning, learning, collaboration, safety, and human oversight. +--- -The architecture is designed around one requirement: a long-running agent must remain correct and governable after many model turns, tool calls, user interventions, process restarts, and worker handoffs. +## What is DeepAgent Code? -## Design Principles +DeepAgent Code is an AI coding agent that adds a **control plane** on top of the [opencode](https://github.com/sst/opencode) runtime. It keeps the proven opencode foundations (runtime, tool, MCP, session, provider stack) and layers in: -### One durable truth per concept +- **Durable document memory** — knowledge base with retrieval gates, dedup, and merge +- **Context assembly** — selective, evidence-backed context building (not raw file dumps) +- **Plan system** — structured task planning with staleness detection and rollback +- **Failure triage** — three-tier classifier (auto-fixable / needs-narrowing / not-auto-fixable) +- **Domain adapters** — pluggable domain packs for specialized workflows +- **AI IDE microservice** — LSP-backed semantic code navigation via `code_intel` +- **MCP catalog** — curated, one-click-enable MCP servers with safety tiers -Sessions, inputs, plans, documents, goals, events, approvals, and learning decisions each have one authoritative durable representation. In-memory state is a cache or an ownership hint, never a competing source of truth. +--- -### Admission is separate from execution +## Architectural Principles -A user instruction is durably admitted before execution is scheduled. A successful API response therefore means the instruction is recorded, not merely present in a process-local queue. +### 1. Enhance, don't replace -### One provider-turn contract +DeepAgent is built **on top of** the opencode agent/runtime/session/tool/MCP stack. It does not rewrite the execution engine, tool system, or provider layer. The default agent behavior is not degraded. The lower-strength `general` mode stays close to the inherited runtime contract. -Native and AI SDK providers pass through the same model-turn boundary. Budget, permissions, tool policy, prompt assembly, artifacts, audit, learning, and close semantics cannot be bypassed by selecting another provider implementation. +### 2. Control-plane only -### Context is selected, not accumulated +DeepAgent is responsible for **strategy / context / budget / audit / verification / document graph**. It does not directly spawn LSP processes or execute MCP tools — those go through the existing `LSP.Service` and `MCP.Service` respectively. -The model receives a bounded working set assembled from explicit Context Sources. Full tool output and durable history remain referenceable artifacts; only admitted summaries, evidence, and snippets enter the active context. +### 3. Full tool output does not enter context -### Safety fails closed +Per the deterministic task control contract: raw LSP results, diagnostic dumps, and capability indexes are written to **evidence artifacts** (ref-linked, tool-only visibility). Only summaries and `file:line` snippets appear in the model context. -External events, credentials, tools, paths, autonomy, worker placement, and outbound messages are checked at their execution boundaries. Missing identity, trust, capability, or approval never widens access. +### 4. Fail-closed on safety -### Humans can always intervene +MCP catalog entries default to **not connected** (zero startup overhead). Dangerous write operations (force-push, DROP, file delete) require explicit approval. Read-only DB connections enforce restricted-mode at the server level. -Steering, plan editing, approval, pause, resume, takeover, rollback, and review are part of the runtime contract. They are not dashboard-only controls layered over an autonomous black box. +--- -## System Map +## Component Map -```text -┌─────────────────────────────────────────────────────────────────────┐ -│ Experience │ -│ Desktop · Web · TUI · IM · Repo & Wiki · Expert Panel · Oversight │ -└──────────────────────────────┬──────────────────────────────────────┘ - │ -┌──────────────────────────────▼──────────────────────────────────────┐ -│ Durable Session Runtime │ -│ Session V2 · System Context · Context Epoch · Steering · Queue │ -│ Prompt cache policy · Provider-turn lifecycle · Tool materialization│ -└──────────────────────────────┬──────────────────────────────────────┘ - │ -┌──────────────────────────────▼──────────────────────────────────────┐ -│ DeepAgent Control Plane │ -│ PlanController · GoalController · Context Graph · Learning │ -│ Event Router · Scheduler · Worker Pool · Handoff · Security gates │ -└──────────────────────────────┬──────────────────────────────────────┘ - │ -┌──────────────────────────────▼──────────────────────────────────────┐ -│ Durable State │ -│ DocumentStore · Session/Event database · Event Bus · Audit/Artifacts│ -└──────────────────────────────┬──────────────────────────────────────┘ - │ -┌──────────────────────────────▼──────────────────────────────────────┐ -│ Execution Services │ -│ Provider · Tool · LSP · MCP · Git/Worktree · Debug · Profile │ -└─────────────────────────────────────────────────────────────────────┘ +``` +┌─────────────────────────────────────────────────────────────┐ +│ DeepAgent Control Plane │ +│ │ +│ ┌──────────────┐ ┌─────────────┐ ┌───────────────────┐ │ +│ │ Plan System │ │ Doc Memory │ │ Failure Triage │ │ +│ │ (task/plan) │ │ (knowledge │ │ (3-tier classify)│ │ +│ └──────┬───────┘ │ store) │ └─────────┬─────────┘ │ +│ │ └──────┬──────┘ │ │ +│ ┌──────▼──────────────────▼──────────────────▼───────────┐ │ +│ │ Agent Gateway (core) │ │ +│ │ audit · budget · permission · capability index │ │ +│ └──────┬─────────────────────────────────────────────────┘ │ +└─────────│───────────────────────────────────────────────────┘ + │ +┌─────────▼──────────────────────────────────────────────────┐ +│ opencode Foundation (unchanged) │ +│ │ +│ Session ─── Tool Registry ─── MCP Service │ +│ │ │ │ │ +│ Provider LSP Service 38 lang servers │ +│ (Claude/…) code_intel tool + MCP catalog │ +└────────────────────────────────────────────────────────────┘ ``` -## Session V2 - -Session V2 separates durable prompt admission from model execution. - -### Prompt admission - -- Each prompt creates one durable `session_input` before scheduling work. -- Reusing a Session ID adopts that Session rather than creating a parallel execution entity. -- Reusing a prompt message ID is accepted only for an exact retry with the same Session, content, and delivery mode. -- Conflicting ID reuse fails instead of silently reconciling different user intent. -- A prompt can be admitted without waking execution when the caller requests admit-only behavior. - -### Delivery vocabulary - -| Delivery | Meaning | -|---|---| -| normal turn | Start a normal activity when the Session is idle | -| `steer` | Add guidance to the active activity at the next safe provider-turn boundary | -| `goal_steer` | Add guidance to the next Goal tick | -| `queue` | Open a future FIFO activity after the active activity settles | -| interrupt | Target the active process-local ownership chain immediately | - -Steering never aborts an in-flight tool or stream. The input is persisted first, absorbed in stable order, and materialized into history exactly once. - -### Execution ownership - -`SessionExecution` is process-global and keyed by Session ID. A drain discovers placement from durable Session location only when it starts. SessionRunner, model resolution, tools, permissions, and filesystem services remain Location-scoped. - -Same-Session resumes join one coordinator; advisory wakes coalesce; different Sessions can run concurrently. Every provider turn performs one explicit `llm.stream(request)` call and reloads projected history before durable continuation. - -### Prompt cache invariant - -The system prompt is split into a byte-stable prefix and one append-only volatile tail: - -- Agent instructions, stable policy, and System Context baseline stay in the prefix. -- Round state, budgets, plan snapshots, prior results, fan-out decisions, and steering stay in the tail. -- OpenAI-compatible providers use a stable Session cache key; providers with cache markers use their protocol-native breakpoint. -- Prefix hash and cache outcomes distinguish normal compaction misses from accidental prefix drift. - -## Document System - -DocumentStore is the durable body for DeepAgent state. Documents carry: - -- a stable ID and monotonic version; -- type, scope, status, domain, tags, and description; -- provenance and evidence references; -- confidence, sensitivity, and approval risk; -- typed links such as `supports`, `blocks`, `conflicts`, `validates`, `supersedes`, `contains`, `imports`, and `calls`. - -Writes use atomic replacement and conflict detection. Concurrent handles observe one authority, process-level writers coordinate through lock/CAS semantics, and migrations are incremental, restartable, and integrity-checked. - -### Scope - -| Scope | Purpose | -|---|---| -| `session-private` | Current conversation and run-local state | -| `project-shared` | Knowledge and decisions shared by one project | -| `user-global` | Cross-project preferences and explicitly promoted knowledge | -| `public-system` | Built-in skills and domain-pack documents | -| `sealed` | Audit/evaluator material that cannot enter model context | - -Plans, run context, worklogs, designs, diagnoses, evaluations, knowledge, memory, strategies, methodologies, skills, and failure dossiers share this document algebra instead of maintaining separate storage models. - -## System Context and the Four Graphs - -The Context System connects four projections over the same durable knowledge surface: - -1. **Code:** files, symbols, imports, calls, definitions, references, diagnostics. -2. **Knowledge:** facts, strategies, methodologies, skills, and failure dossiers. -3. **Memory:** decisions, constraints, project conventions, environment facts, and handoffs. -4. **Documents:** plans, designs, run context, evidence, worklogs, and evaluations. - -Context Sources produce typed observations from their domains. Session-owned selection applies budget, relevance, scope, sensitivity, evidence strength, conflict, and snapshot rules. A Context Epoch records the selected baseline so a provider turn is reproducible and observable. - -The Event Router can attach a context strategy to an event. SessionRunner executes that strategy in the target Location, records query and admission decisions in trace, and degrades safely when an optional source is unavailable. - -Compaction preserves a stable structure: goal, constraints, completed and active work, blockers, decisions, next steps, critical facts/open questions, and relevant files. Durable references remain outside the prose summary and can be reloaded when needed. - -## Planning and Goal Execution - -### Plan authority - -A structural plan is a versioned DocumentStore document. Session hot state keeps only its plan pointer/version and stale latch. The model plan tool, human plan editor, Goal worker, UI, Grader, and archive all read and update the same plan through version-aware writes. - -The runtime derives plan staleness from facts it already observes: - -- the user adds new guidance; -- a tool or execution step fails; -- validation fails; -- repeated work makes no progress; -- the active domain-pack snapshot changes. - -Read and diagnosis tools remain available while stale. Mutating tools require the plan to be synchronized, with bounded anti-deadlock behavior. - -### Goal Loop - -A Goal has objective completion criteria, a plan, a durable run context, a budget ledger, and a bounded controller. Each tick: - -1. claims the expected durable Goal/plan version; -2. applies pending user plan edits and steering; -3. executes one coherent step; -4. records tools, tokens, cost, time, evidence, and progress; -5. evaluates objective criteria and stall state; -6. emits facts and schedules the next tick only when eligible. - -`goal.tick.requested` is a durable command, not a post-hoc trace marker. Duplicate delivery cannot repeat provider or tool side effects. Pause, stop, takeover, hard limits, quiet hours, needs-human, and terminal state all stop self-continuation. - -Hot plan edits preserve reusable step IDs and completed evidence, increment the plan version, and reset progress/stall baselines without interrupting the in-flight tick. - -## Event-Driven Agent Runtime - -The Event Bus provides persist-before-dispatch delivery, idempotency, priority, retry, acknowledgement, dead-letter handling, retention, replay, and correlation. Local deployments use the embedded backend; distributed deployments use Redis Streams or Kafka through the same backend contract. - -The Router combines event type, trusted source, actor identity, Agent trigger/capability metadata, autonomy ceiling, approval intent, context strategy, deduplication, priority, and workspace backpressure into one traceable route decision. - -The Worker Pool owns bounded concurrency, placement, claims, leases, renewal, recovery, and handoff. Independent DAG nodes run concurrently; dependency edges remain ordered. File and symbol claims are shared across Workers so conflicting writes cannot run together. - -Write-capable Agents use isolated worktrees by default. Parent Agents receive bounded summaries, status, artifact/session references, and necessary diffs; complete child transcripts remain in their own Sessions. - -## Human Collaboration and Oversight - -### Repo & Wiki - -Repo & Wiki is a human-facing projection, never a second source of truth. It exposes document and code navigation, full-text search, docs-to-code links, knowledge governance, and execution archives. Organization and workspace identity are enforced on query, index, archive, and promotion paths. - -### Expert Panel - -Panelists receive the same frozen question and evidence under differentiated lenses. Anonymous multi-round debate avoids identity anchoring. A deterministic Arbiter applies quorum, preserves minority opinions, and routes unsafe ambiguity to the Approval Queue. Distributed panelists run through the Worker Pool. - -### IM and proactive delivery - -Project IM supports groups, direct conversations, threads, search, attachments, agent mentions, progress streaming, and permission revalidation when project bindings change. Event-driven notifications and digests pass through content safety, path ACL, external-link, rate, and quiet-hours policies before delivery. - -### Oversight - -Correlation IDs connect event, route, context, worker claim, Session, provider turn, tool, artifact, approval, and outbound action. Operators can inspect Approval Queue items, dead letters, budgets, conflicts, takeovers, rollbacks, and final delivery without reconstructing state from logs. - -## Learning and Knowledge Governance - -Learning runs outside the interactive turn on idle, pause, project switch, and Session finalization triggers. Candidates enter the same DocumentStore lifecycle used by human governance. - -- Low-risk project candidates can pass deterministic auto-review. -- Medium-risk/global candidates use an isolated blank-thread reviewer with no Session history. -- Sensitive, strategic, regulated, or irreversible candidates require human review. -- Rejection status, reason, and fingerprint remain authoritative in DocumentStore; auxiliary indexes are rebuildable projections. -- Promotion changes the same document's status/version instead of copying it into a second identity. -- Released retrieval sets name a snapshot and carry evaluation matrix, baseline, repeats, and ablation verdict. +--- -A failed release gate restores the previous knowledge snapshot. Selected and rejected refs remain reproducible in run artifacts. +## code_intel — AI IDE Microservice -## Code Intelligence +The `code_intel` tool wraps the LSP stack as a **symbol-driven semantic API**. The agent specifies a symbol name and an intent; `code_intel` resolves line/column coordinates internally and returns `file:line` + code snippets. -The AI IDE surface combines: +```typescript +code_intel({ symbol: "AgentGateway.open", intent: "overview" }) +// → definition + type + references + callers + callees + doc summary +// full detail → evidence artifact (ref only in context) +``` -- semantic symbol lookup and intent-oriented `code_intel` queries; -- definitions, references, calls, imports, type hierarchy, diagnostics, and rename preview; -- unsaved-buffer `textDocument/didOpen`, `didChange`, `didSave`, and `didClose` synchronization; -- incremental code indexing with exact mtime I/O hints and content-SHA correctness authority; -- deterministic fallback to repository search/read when a language server is unavailable. +Supported intents: `definition · references · implementations · type · calls_in · calls_out · supertypes · subtypes · type_hints · hover · rename_preview · quick_fix · outline · diagnostics · overview` -Full LSP output stays in evidence artifacts. The model receives bounded summaries and precise source references. +Graceful degradation: if no LSP server is configured for the file type, returns a hint to use `grep/read`. Capability only grows, never drops. -## MCP and Credential Security +--- -MCP servers can be added from the curated catalog or configured manually through Desktop, HTTP, or CLI. Catalog risk tiers are derived from trusted templates rather than mutable user configuration. Servers default to disconnected; writes, external fetches, and privileged actions pass through runtime permission gates. +## MCP Catalog — Safety Model -Credentials use indirection rather than plaintext project configuration: +Each catalog entry carries a **risk tier** derived at load time from the catalog template. The tier is **not user-writable** — it is computed from the entry definition, preventing config-injection attacks. -- `${VAR}` and `${VAR:-default}` resolve at connection time; -- `secret://` handles resolve through macOS Keychain, Linux Secret Service, or Windows Credential Manager/DPAPI; -- environments without a native keyring require explicit approval for an audited local fallback outside the project repository; -- logs, artifacts, outbound messages, and config views redact resolved values. +| Tier | Examples | Default behavior | +|------|----------|-----------------| +| `read_only` | postgres-readonly | All ops auto-allowed | +| `write_guarded` | filesystem, github, git | Write ops require explicit approval | +| `external_fetch` | fetch, browser (Playwright) | External requests require explicit approval | -## Security Boundaries +**Credentials** are declared by key name in the catalog template (`CredentialSpec`). Values are filled at enable-time. -Autonomous execution passes four independent gates: +> **Known limitation (V3.4):** credential values are stored in plaintext in the local config file. Do not commit config files containing credentials to version control. A secure-storage mechanism (OS keyring, aligned with the codex approach) is planned for V3.5. -1. the event source is trusted for the workspace; -2. the actor has permission for the project and resource; -3. the Agent descriptor permits the trigger, capability, and autonomy level; -4. the runtime permits the concrete tool, path, network target, and side effect. +--- -Additional controls include durable budgets, rate limits, quiet hours, secret/path/link filtering, worktree isolation, hardened read-only Git, human approval, takeover, rollback, and complete audit correlation. +## Security Model Summary -## Repository Map +| Mechanism | Status | +|-----------|--------| +| MCP risk tier — catalog-derived, not config-injectable | ✅ V3.4 | +| MCP catalog defaults to not connected | ✅ V3.4 | +| Dangerous writes: approval gate (`ctx.ask`) | ✅ V3.4 | +| Read-only DB: restricted-mode enforced at server | ✅ V3.4 | +| Credential secure storage (OS keyring) | ⏳ V3.5 M-CRED | -| Area | Path | -|---|---| -| Core Session, documents, context, event, and policy algebra | `packages/core/src/` | -| CLI/server runtime, tools, Goal and event wiring | `packages/deepagent-code/src/` | -| Desktop/Web application UI | `packages/app/src/` | -| Electron host and isolated browser views | `packages/desktop/src/` | -| Provider abstraction | `packages/llm/` | -| Domain knowledge packs | `packages/domain-packs/` | -| Generated JavaScript SDK | `packages/sdk/js/` | +--- -## License and Source +## License -DeepAgent Code is licensed under **AGPL-3.0-or-later**. The canonical repository is [github.com/deepagent-ltd/deepagent-code](https://github.com/deepagent-ltd/deepagent-code). +DeepAgent Code is licensed under **AGPL-3.0-or-later**. +Source code: [github.com/lessweb/deepagent-code](https://github.com/lessweb/deepagent-code) -The project is derived from [opencode](https://github.com/sst/opencode) under the MIT License. Upstream attribution is preserved in [NOTICE](../NOTICE). +DeepAgent Code is derived from [opencode](https://github.com/sst/opencode) (MIT). +See `NOTICE` in the repository root for the full upstream attribution. diff --git a/packages/app/src/components/deepagent-settings-ux.test.ts b/packages/app/src/components/deepagent-settings-ux.test.ts index f2e218fc..870cab56 100644 --- a/packages/app/src/components/deepagent-settings-ux.test.ts +++ b/packages/app/src/components/deepagent-settings-ux.test.ts @@ -23,23 +23,9 @@ describe("DeepAgent settings UX", () => { expect(v2.indexOf('data-action="settings-deepagent-prompt-mode"')).toBeLessThan( v2.indexOf('data-action="settings-deepagent-intelligence-model"'), ) - }) - - test("moves the permission approval control out of settings into the composer toolbar", async () => { - const v2 = await readFile(path.join(here, "settings-v2/general.tsx"), "utf8") - const composer = await readFile(path.join(here, "prompt-input.tsx"), "utf8") - const control = await readFile(path.join(here, "deepagent/approval-control.tsx"), "utf8") - - // The auto-accept toggle no longer lives in settings… - expect(v2).not.toContain('data-action="settings-auto-accept-permissions"') - // …it is a composer control next to the agent selector, backed by directory-level auto-accept. - expect(composer).toContain("ApprovalControl") - expect(control).toContain('"data-action": "prompt-approval"') - // Tri-state Read-Only / Request / Full-Access selector backed by the permission context. - expect(control).toContain("setDirectoryApprovalMode") - expect(control).toContain("composer.approval.request") - expect(control).toContain("composer.approval.readOnly") - expect(control).toContain("composer.approval.fullAccess") + expect(v2.indexOf('data-action="settings-deepagent-intelligence-model"')).toBeLessThan( + v2.indexOf('data-action="settings-auto-accept-permissions"'), + ) }) test("routes the legacy settings dialog import to the unified settings page", async () => { diff --git a/packages/app/src/components/deepagent/approval-control.tsx b/packages/app/src/components/deepagent/approval-control.tsx deleted file mode 100644 index cabd2b57..00000000 --- a/packages/app/src/components/deepagent/approval-control.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { createMemo, type JSX } from "solid-js" -import { Select } from "@deepagent-code/ui/select" -import { useLanguage } from "@/context/language" -import { usePermission, type DirectoryApprovalMode } from "@/context/permission" - -/** - * Approval-mode control for the composer toolbar, next to the agent (build/plan) selector. - * - * Mirrors Codex's approval selector UX: it collapses the approval×sandbox space into three named - * presets. The button shows the CURRENT mode; clicking opens a small picker to switch: - * - "Read-Only" — the agent may read/search but write/edit/bash requests are auto-rejected. - * - "Request" (default) — normal permission flow; the agent asks before write/execute. - * - "Full-Access" — auto-approve everything (the old directory-level auto-accept). - * - * The mode is DIRECTORY-scoped (persists across sessions in the same workspace), backed by the - * permission context tri-state (directoryApprovalMode / setDirectoryApprovalMode). Full-Access maps - * onto the existing isAutoAcceptingDirectory / toggleAutoAcceptDirectory state the old settings - * toggle drove, now surfaced where the user acts. - */ - -type ApprovalMode = DirectoryApprovalMode - -export function ApprovalControl(props: { directory: string; triggerStyle?: JSX.CSSProperties; onAfter?: () => void }) { - const language = useLanguage() - const permission = usePermission() - - const current = createMemo(() => - props.directory ? permission.directoryApprovalMode(props.directory) : "request", - ) - - const options: ApprovalMode[] = ["read-only", "request", "full-access"] - const label = (mode: ApprovalMode) => { - switch (mode) { - case "read-only": - return language.t("composer.approval.readOnly") - case "full-access": - return language.t("composer.approval.fullAccess") - default: - return language.t("composer.approval.request") - } - } - - const onSelect = (mode: ApprovalMode | undefined) => { - if (!mode || !props.directory) return - if (mode === current()) return - permission.setDirectoryApprovalMode(props.directory, mode) - props.onAfter?.() - } - - return ( -