@gajae-code/coding-agent 0.1.1
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/CHANGELOG.md +8662 -0
- package/README.md +37 -0
- package/dist/types/async/index.d.ts +2 -0
- package/dist/types/async/job-manager.d.ts +101 -0
- package/dist/types/async/support.d.ts +2 -0
- package/dist/types/autoresearch/dashboard.d.ts +4 -0
- package/dist/types/autoresearch/git.d.ts +36 -0
- package/dist/types/autoresearch/helpers.d.ts +24 -0
- package/dist/types/autoresearch/index.d.ts +2 -0
- package/dist/types/autoresearch/state.d.ts +17 -0
- package/dist/types/autoresearch/storage.d.ts +142 -0
- package/dist/types/autoresearch/tools/init-experiment.d.ts +31 -0
- package/dist/types/autoresearch/tools/log-experiment.d.ts +23 -0
- package/dist/types/autoresearch/tools/run-experiment.d.ts +8 -0
- package/dist/types/autoresearch/tools/update-notes.d.ts +12 -0
- package/dist/types/autoresearch/types.d.ts +154 -0
- package/dist/types/capability/context-file.d.ts +17 -0
- package/dist/types/capability/extension-module.d.ts +15 -0
- package/dist/types/capability/extension.d.ts +28 -0
- package/dist/types/capability/fs.d.ts +20 -0
- package/dist/types/capability/hook.d.ts +19 -0
- package/dist/types/capability/index.d.ts +80 -0
- package/dist/types/capability/instruction.d.ts +17 -0
- package/dist/types/capability/mcp.d.ts +45 -0
- package/dist/types/capability/prompt.d.ts +15 -0
- package/dist/types/capability/rule.d.ts +61 -0
- package/dist/types/capability/settings.d.ts +15 -0
- package/dist/types/capability/skill.d.ts +36 -0
- package/dist/types/capability/slash-command.d.ts +17 -0
- package/dist/types/capability/ssh.d.ts +23 -0
- package/dist/types/capability/system-prompt.d.ts +15 -0
- package/dist/types/capability/tool.d.ts +19 -0
- package/dist/types/capability/types.d.ts +154 -0
- package/dist/types/cli/agents-cli.d.ts +12 -0
- package/dist/types/cli/args.d.ts +53 -0
- package/dist/types/cli/auth-broker-cli.d.ts +25 -0
- package/dist/types/cli/auth-gateway-cli.d.ts +18 -0
- package/dist/types/cli/classify-install-target.d.ts +18 -0
- package/dist/types/cli/commands/init-xdg.d.ts +1 -0
- package/dist/types/cli/config-cli.d.ts +22 -0
- package/dist/types/cli/file-processor.d.ts +11 -0
- package/dist/types/cli/grep-cli.d.ts +17 -0
- package/dist/types/cli/initial-message.d.ts +17 -0
- package/dist/types/cli/list-models.d.ts +30 -0
- package/dist/types/cli/plugin-cli.d.ts +32 -0
- package/dist/types/cli/read-cli.d.ts +4 -0
- package/dist/types/cli/session-picker.d.ts +3 -0
- package/dist/types/cli/setup-cli.d.ts +31 -0
- package/dist/types/cli/shell-cli.d.ts +8 -0
- package/dist/types/cli/ssh-cli.d.ts +21 -0
- package/dist/types/cli/stats-cli.d.ts +17 -0
- package/dist/types/cli/update-cli.d.ts +38 -0
- package/dist/types/cli/web-search-cli.d.ts +20 -0
- package/dist/types/cli/worktree-cli.d.ts +26 -0
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/commands/acp.d.ts +12 -0
- package/dist/types/commands/agents.d.ts +34 -0
- package/dist/types/commands/auth-broker.d.ts +54 -0
- package/dist/types/commands/auth-gateway.d.ts +32 -0
- package/dist/types/commands/codex-native-hook.d.ts +6 -0
- package/dist/types/commands/commit.d.ts +27 -0
- package/dist/types/commands/config.d.ts +30 -0
- package/dist/types/commands/deep-interview.d.ts +7 -0
- package/dist/types/commands/gjc-runtime-bridge.d.ts +6 -0
- package/dist/types/commands/grep.d.ts +42 -0
- package/dist/types/commands/launch.d.ts +121 -0
- package/dist/types/commands/plugin.d.ts +52 -0
- package/dist/types/commands/question.d.ts +7 -0
- package/dist/types/commands/ralplan.d.ts +7 -0
- package/dist/types/commands/read.d.ts +15 -0
- package/dist/types/commands/setup.d.ts +48 -0
- package/dist/types/commands/shell.d.ts +21 -0
- package/dist/types/commands/ssh.d.ts +48 -0
- package/dist/types/commands/state.d.ts +7 -0
- package/dist/types/commands/stats.d.ts +25 -0
- package/dist/types/commands/team.d.ts +24 -0
- package/dist/types/commands/ultragoal.d.ts +7 -0
- package/dist/types/commands/update.d.ts +20 -0
- package/dist/types/commands/web-search.d.ts +33 -0
- package/dist/types/commands/worktree.d.ts +34 -0
- package/dist/types/commit/agentic/agent.d.ts +31 -0
- package/dist/types/commit/agentic/fallback.d.ts +5 -0
- package/dist/types/commit/agentic/index.d.ts +2 -0
- package/dist/types/commit/agentic/state.d.ts +58 -0
- package/dist/types/commit/agentic/tools/analyze-file.d.ts +19 -0
- package/dist/types/commit/agentic/tools/git-file-diff.d.ts +10 -0
- package/dist/types/commit/agentic/tools/git-hunk.d.ts +9 -0
- package/dist/types/commit/agentic/tools/git-overview.d.ts +9 -0
- package/dist/types/commit/agentic/tools/index.d.ts +16 -0
- package/dist/types/commit/agentic/tools/propose-changelog.d.ts +28 -0
- package/dist/types/commit/agentic/tools/propose-commit.d.ts +36 -0
- package/dist/types/commit/agentic/tools/recent-commits.d.ts +7 -0
- package/dist/types/commit/agentic/tools/schemas.d.ts +27 -0
- package/dist/types/commit/agentic/tools/split-commit.d.ts +53 -0
- package/dist/types/commit/agentic/topo-sort.d.ts +4 -0
- package/dist/types/commit/agentic/trivial.d.ts +7 -0
- package/dist/types/commit/agentic/validation.d.ts +20 -0
- package/dist/types/commit/analysis/conventional.d.ts +22 -0
- package/dist/types/commit/analysis/index.d.ts +4 -0
- package/dist/types/commit/analysis/scope.d.ts +6 -0
- package/dist/types/commit/analysis/summary.d.ts +19 -0
- package/dist/types/commit/analysis/validation.d.ts +8 -0
- package/dist/types/commit/changelog/detect.d.ts +2 -0
- package/dist/types/commit/changelog/generate.d.ts +30 -0
- package/dist/types/commit/changelog/index.d.ts +30 -0
- package/dist/types/commit/changelog/parse.d.ts +2 -0
- package/dist/types/commit/cli.d.ts +3 -0
- package/dist/types/commit/git/diff.d.ts +5 -0
- package/dist/types/commit/index.d.ts +4 -0
- package/dist/types/commit/map-reduce/index.d.ts +28 -0
- package/dist/types/commit/map-reduce/map-phase.d.ts +17 -0
- package/dist/types/commit/map-reduce/reduce-phase.d.ts +13 -0
- package/dist/types/commit/map-reduce/utils.d.ts +2 -0
- package/dist/types/commit/message.d.ts +2 -0
- package/dist/types/commit/model-selection.d.ts +15 -0
- package/dist/types/commit/pipeline.d.ts +5 -0
- package/dist/types/commit/shared-llm.d.ts +54 -0
- package/dist/types/commit/types.d.ts +78 -0
- package/dist/types/commit/utils/exclusions.d.ts +4 -0
- package/dist/types/commit/utils.d.ts +20 -0
- package/dist/types/config/config-file.d.ts +58 -0
- package/dist/types/config/file-lock.d.ts +6 -0
- package/dist/types/config/keybindings.d.ts +334 -0
- package/dist/types/config/model-equivalence.d.ts +24 -0
- package/dist/types/config/model-registry.d.ts +390 -0
- package/dist/types/config/model-resolver.d.ts +230 -0
- package/dist/types/config/models-config-schema.d.ts +504 -0
- package/dist/types/config/prompt-templates.d.ts +32 -0
- package/dist/types/config/resolve-config-value.d.ts +17 -0
- package/dist/types/config/settings-schema.d.ts +3337 -0
- package/dist/types/config/settings.d.ts +132 -0
- package/dist/types/config/skill-settings-defaults.d.ts +14 -0
- package/dist/types/config.d.ts +66 -0
- package/dist/types/cursor.d.ts +24 -0
- package/dist/types/dap/client.d.ts +38 -0
- package/dist/types/dap/config.d.ts +6 -0
- package/dist/types/dap/index.d.ts +4 -0
- package/dist/types/dap/session.d.ts +108 -0
- package/dist/types/dap/types.d.ts +524 -0
- package/dist/types/debug/index.d.ts +15 -0
- package/dist/types/debug/log-formatting.d.ts +4 -0
- package/dist/types/debug/log-viewer.d.ts +68 -0
- package/dist/types/debug/profiler.d.ts +24 -0
- package/dist/types/debug/raw-sse-buffer.d.ts +44 -0
- package/dist/types/debug/raw-sse.d.ts +16 -0
- package/dist/types/debug/report-bundle.d.ts +55 -0
- package/dist/types/debug/system-info.d.ts +26 -0
- package/dist/types/defaults/gjc-defaults.d.ts +44 -0
- package/dist/types/discovery/agents-md.d.ts +1 -0
- package/dist/types/discovery/agents.d.ts +12 -0
- package/dist/types/discovery/builtin.d.ts +1 -0
- package/dist/types/discovery/claude-plugins.d.ts +1 -0
- package/dist/types/discovery/claude.d.ts +1 -0
- package/dist/types/discovery/cline.d.ts +1 -0
- package/dist/types/discovery/codex.d.ts +1 -0
- package/dist/types/discovery/cursor.d.ts +16 -0
- package/dist/types/discovery/gemini.d.ts +1 -0
- package/dist/types/discovery/github.d.ts +1 -0
- package/dist/types/discovery/helpers.d.ts +268 -0
- package/dist/types/discovery/index.d.ts +48 -0
- package/dist/types/discovery/mcp-json.d.ts +1 -0
- package/dist/types/discovery/opencode.d.ts +1 -0
- package/dist/types/discovery/plugin-dir-roots.d.ts +15 -0
- package/dist/types/discovery/ssh.d.ts +1 -0
- package/dist/types/discovery/substitute-plugin-root.d.ts +5 -0
- package/dist/types/discovery/vscode.d.ts +1 -0
- package/dist/types/discovery/windsurf.d.ts +13 -0
- package/dist/types/edit/apply-patch/index.d.ts +35 -0
- package/dist/types/edit/apply-patch/parser.d.ts +34 -0
- package/dist/types/edit/diff.d.ts +59 -0
- package/dist/types/edit/file-read-cache.d.ts +25 -0
- package/dist/types/edit/index.d.ts +58 -0
- package/dist/types/edit/modes/apply-patch.d.ts +24 -0
- package/dist/types/edit/modes/patch.d.ts +99 -0
- package/dist/types/edit/modes/replace.d.ts +142 -0
- package/dist/types/edit/normalize.d.ts +43 -0
- package/dist/types/edit/notebook.d.ts +23 -0
- package/dist/types/edit/read-file.d.ts +2 -0
- package/dist/types/edit/renderer.d.ts +110 -0
- package/dist/types/edit/streaming.d.ts +66 -0
- package/dist/types/eval/backend.d.ts +40 -0
- package/dist/types/eval/index.d.ts +4 -0
- package/dist/types/eval/js/context-manager.d.ts +24 -0
- package/dist/types/eval/js/executor.d.ts +28 -0
- package/dist/types/eval/js/index.d.ts +10 -0
- package/dist/types/eval/js/shared/helpers.d.ts +38 -0
- package/dist/types/eval/js/shared/indirect-eval.d.ts +14 -0
- package/dist/types/eval/js/shared/prelude.d.ts +1 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +6 -0
- package/dist/types/eval/js/shared/runtime.d.ts +47 -0
- package/dist/types/eval/js/shared/types.d.ts +24 -0
- package/dist/types/eval/js/tool-bridge.d.ts +18 -0
- package/dist/types/eval/js/worker-core.d.ts +5 -0
- package/dist/types/eval/js/worker-entry.d.ts +1 -0
- package/dist/types/eval/js/worker-protocol.d.ts +77 -0
- package/dist/types/eval/py/display.d.ts +25 -0
- package/dist/types/eval/py/executor.d.ts +83 -0
- package/dist/types/eval/py/index.d.ts +10 -0
- package/dist/types/eval/py/kernel.d.ts +61 -0
- package/dist/types/eval/py/prelude.d.ts +1 -0
- package/dist/types/eval/py/runtime.d.ts +21 -0
- package/dist/types/eval/py/tool-bridge.d.ts +20 -0
- package/dist/types/eval/types.d.ts +52 -0
- package/dist/types/exa/factory.d.ts +13 -0
- package/dist/types/exa/index.d.ts +20 -0
- package/dist/types/exa/mcp-client.d.ts +45 -0
- package/dist/types/exa/render.d.ts +19 -0
- package/dist/types/exa/researcher.d.ts +9 -0
- package/dist/types/exa/search.d.ts +9 -0
- package/dist/types/exa/types.d.ts +155 -0
- package/dist/types/exa/websets.d.ts +9 -0
- package/dist/types/exec/bash-executor.d.ts +41 -0
- package/dist/types/exec/exec.d.ts +25 -0
- package/dist/types/exec/idle-timeout-watchdog.d.ts +18 -0
- package/dist/types/exec/non-interactive-env.d.ts +1 -0
- package/dist/types/export/custom-share.d.ts +20 -0
- package/dist/types/export/html/index.d.ts +10 -0
- package/dist/types/export/html/template.generated.d.ts +1 -0
- package/dist/types/export/html/template.macro.d.ts +5 -0
- package/dist/types/export/ttsr.d.ts +44 -0
- package/dist/types/extensibility/custom-commands/bundled/ci-green/index.d.ts +9 -0
- package/dist/types/extensibility/custom-commands/bundled/review/index.d.ts +10 -0
- package/dist/types/extensibility/custom-commands/index.d.ts +2 -0
- package/dist/types/extensibility/custom-commands/loader.d.ts +29 -0
- package/dist/types/extensibility/custom-commands/types.d.ts +106 -0
- package/dist/types/extensibility/custom-tools/index.d.ts +6 -0
- package/dist/types/extensibility/custom-tools/loader.d.ts +69 -0
- package/dist/types/extensibility/custom-tools/types.d.ts +226 -0
- package/dist/types/extensibility/custom-tools/wrapper.d.ts +23 -0
- package/dist/types/extensibility/extensions/compact-handler.d.ts +26 -0
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +29 -0
- package/dist/types/extensibility/extensions/index.d.ts +8 -0
- package/dist/types/extensibility/extensions/loader.d.ts +43 -0
- package/dist/types/extensibility/extensions/runner.d.ts +134 -0
- package/dist/types/extensibility/extensions/types.d.ts +864 -0
- package/dist/types/extensibility/extensions/wrapper.d.ts +54 -0
- package/dist/types/extensibility/hooks/index.d.ts +5 -0
- package/dist/types/extensibility/hooks/loader.d.ts +89 -0
- package/dist/types/extensibility/hooks/runner.d.ts +126 -0
- package/dist/types/extensibility/hooks/tool-wrapper.d.ts +25 -0
- package/dist/types/extensibility/hooks/types.d.ts +431 -0
- package/dist/types/extensibility/plugins/doctor.d.ts +3 -0
- package/dist/types/extensibility/plugins/git-url.d.ts +34 -0
- package/dist/types/extensibility/plugins/index.d.ts +7 -0
- package/dist/types/extensibility/plugins/installer.d.ts +5 -0
- package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +2 -0
- package/dist/types/extensibility/plugins/loader.d.ts +31 -0
- package/dist/types/extensibility/plugins/manager.d.ts +65 -0
- package/dist/types/extensibility/plugins/marketplace/cache.d.ts +41 -0
- package/dist/types/extensibility/plugins/marketplace/fetcher.d.ts +48 -0
- package/dist/types/extensibility/plugins/marketplace/index.d.ts +6 -0
- package/dist/types/extensibility/plugins/marketplace/manager.d.ts +57 -0
- package/dist/types/extensibility/plugins/marketplace/registry.d.ts +34 -0
- package/dist/types/extensibility/plugins/marketplace/source-resolver.d.ts +28 -0
- package/dist/types/extensibility/plugins/marketplace/types.d.ts +130 -0
- package/dist/types/extensibility/plugins/parser.d.ts +52 -0
- package/dist/types/extensibility/plugins/types.d.ts +149 -0
- package/dist/types/extensibility/shared-events.d.ts +279 -0
- package/dist/types/extensibility/skills.d.ts +74 -0
- package/dist/types/extensibility/slash-commands.d.ts +48 -0
- package/dist/types/extensibility/tool-proxy.d.ts +4 -0
- package/dist/types/extensibility/typebox.d.ts +155 -0
- package/dist/types/extensibility/utils.d.ts +12 -0
- package/dist/types/gjc-runtime/goal-mode-request.d.ts +46 -0
- package/dist/types/gjc-runtime/launch-tmux.d.ts +45 -0
- package/dist/types/gjc-runtime/launch-worktree.d.ts +46 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +204 -0
- package/dist/types/gjc-runtime/ultragoal-runtime.d.ts +85 -0
- package/dist/types/goals/index.d.ts +3 -0
- package/dist/types/goals/runtime.d.ts +68 -0
- package/dist/types/goals/state.d.ts +35 -0
- package/dist/types/goals/tools/goal-tool.d.ts +128 -0
- package/dist/types/hashline/anchors.d.ts +20 -0
- package/dist/types/hashline/apply.d.ts +14 -0
- package/dist/types/hashline/constants.d.ts +19 -0
- package/dist/types/hashline/diff-preview.d.ts +2 -0
- package/dist/types/hashline/diff.d.ts +17 -0
- package/dist/types/hashline/execute.d.ts +4 -0
- package/dist/types/hashline/hash.d.ts +123 -0
- package/dist/types/hashline/index.d.ts +13 -0
- package/dist/types/hashline/input.d.ts +11 -0
- package/dist/types/hashline/parser.d.ts +7 -0
- package/dist/types/hashline/prefixes.d.ts +7 -0
- package/dist/types/hashline/recovery.d.ts +27 -0
- package/dist/types/hashline/stream.d.ts +2 -0
- package/dist/types/hashline/types.d.ts +77 -0
- package/dist/types/hindsight/backend.d.ts +13 -0
- package/dist/types/hindsight/bank.d.ts +54 -0
- package/dist/types/hindsight/client.d.ts +224 -0
- package/dist/types/hindsight/config.d.ts +51 -0
- package/dist/types/hindsight/content.d.ts +70 -0
- package/dist/types/hindsight/index.d.ts +8 -0
- package/dist/types/hindsight/mental-models.d.ts +125 -0
- package/dist/types/hindsight/state.d.ts +99 -0
- package/dist/types/hindsight/transcript.d.ts +28 -0
- package/dist/types/hooks/codex-native-hooks-config.d.ts +29 -0
- package/dist/types/hooks/native-skill-hook.d.ts +16 -0
- package/dist/types/hooks/skill-keywords.d.ts +17 -0
- package/dist/types/hooks/skill-state.d.ts +80 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/internal-urls/agent-protocol.d.ts +12 -0
- package/dist/types/internal-urls/artifact-protocol.d.ts +6 -0
- package/dist/types/internal-urls/docs-index.generated.d.ts +2 -0
- package/dist/types/internal-urls/gjc-protocol.d.ts +12 -0
- package/dist/types/internal-urls/index.d.ts +20 -0
- package/dist/types/internal-urls/issue-pr-protocol.d.ts +17 -0
- package/dist/types/internal-urls/json-query.d.ts +30 -0
- package/dist/types/internal-urls/local-protocol.d.ts +39 -0
- package/dist/types/internal-urls/mcp-protocol.d.ts +12 -0
- package/dist/types/internal-urls/memory-protocol.d.ts +23 -0
- package/dist/types/internal-urls/parse.d.ts +19 -0
- package/dist/types/internal-urls/registry-helpers.d.ts +10 -0
- package/dist/types/internal-urls/router.d.ts +14 -0
- package/dist/types/internal-urls/rule-protocol.d.ts +6 -0
- package/dist/types/internal-urls/skill-protocol.d.ts +13 -0
- package/dist/types/internal-urls/types.d.ts +105 -0
- package/dist/types/lsp/client.d.ts +65 -0
- package/dist/types/lsp/clients/biome-client.d.ts +16 -0
- package/dist/types/lsp/clients/index.d.ts +19 -0
- package/dist/types/lsp/clients/lsp-linter-client.d.ts +16 -0
- package/dist/types/lsp/clients/swiftlint-client.d.ts +20 -0
- package/dist/types/lsp/config.d.ts +65 -0
- package/dist/types/lsp/edits.d.ts +23 -0
- package/dist/types/lsp/index.d.ts +130 -0
- package/dist/types/lsp/lspmux.d.ts +58 -0
- package/dist/types/lsp/render.d.ts +32 -0
- package/dist/types/lsp/startup-events.d.ts +11 -0
- package/dist/types/lsp/types.d.ts +302 -0
- package/dist/types/lsp/utils.d.ts +108 -0
- package/dist/types/main.d.ts +50 -0
- package/dist/types/memories/index.d.ts +28 -0
- package/dist/types/memories/storage.d.ts +110 -0
- package/dist/types/memory-backend/index.d.ts +4 -0
- package/dist/types/memory-backend/local-backend.d.ts +9 -0
- package/dist/types/memory-backend/off-backend.d.ts +7 -0
- package/dist/types/memory-backend/resolve.d.ts +15 -0
- package/dist/types/memory-backend/types.d.ts +61 -0
- package/dist/types/modes/acp/acp-agent.d.ts +61 -0
- package/dist/types/modes/acp/acp-client-bridge.d.ts +9 -0
- package/dist/types/modes/acp/acp-event-mapper.d.ts +32 -0
- package/dist/types/modes/acp/acp-mode.d.ts +5 -0
- package/dist/types/modes/acp/index.d.ts +2 -0
- package/dist/types/modes/acp/terminal-auth.d.ts +6 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +21 -0
- package/dist/types/modes/components/assistant-message.d.ts +16 -0
- package/dist/types/modes/components/bash-execution.d.ts +29 -0
- package/dist/types/modes/components/bordered-loader.d.ts +11 -0
- package/dist/types/modes/components/branch-summary-message.d.ts +13 -0
- package/dist/types/modes/components/btw-panel.d.ts +16 -0
- package/dist/types/modes/components/compaction-summary-message.d.ts +13 -0
- package/dist/types/modes/components/countdown-timer.d.ts +14 -0
- package/dist/types/modes/components/custom-editor.d.ts +47 -0
- package/dist/types/modes/components/custom-message.d.ts +15 -0
- package/dist/types/modes/components/diff.d.ts +11 -0
- package/dist/types/modes/components/dynamic-border.d.ts +14 -0
- package/dist/types/modes/components/eval-execution.d.ts +23 -0
- package/dist/types/modes/components/execution-shared.d.ts +46 -0
- package/dist/types/modes/components/extensions/extension-dashboard.d.ts +26 -0
- package/dist/types/modes/components/extensions/extension-list.d.ts +39 -0
- package/dist/types/modes/components/extensions/index.d.ts +8 -0
- package/dist/types/modes/components/extensions/inspector-panel.d.ts +8 -0
- package/dist/types/modes/components/extensions/state-manager.d.ts +50 -0
- package/dist/types/modes/components/extensions/types.d.ts +151 -0
- package/dist/types/modes/components/footer.d.ts +30 -0
- package/dist/types/modes/components/history-search.d.ts +7 -0
- package/dist/types/modes/components/hook-editor.d.ts +18 -0
- package/dist/types/modes/components/hook-input.d.ts +15 -0
- package/dist/types/modes/components/hook-message.d.ts +15 -0
- package/dist/types/modes/components/hook-selector.d.ts +23 -0
- package/dist/types/modes/components/index.d.ts +35 -0
- package/dist/types/modes/components/keybinding-hints.d.ts +40 -0
- package/dist/types/modes/components/login-dialog.d.ts +32 -0
- package/dist/types/modes/components/message-frame.d.ts +42 -0
- package/dist/types/modes/components/model-selector.d.ts +26 -0
- package/dist/types/modes/components/oauth-selector.d.ts +14 -0
- package/dist/types/modes/components/plugin-selector.d.ts +26 -0
- package/dist/types/modes/components/plugin-settings.d.ts +66 -0
- package/dist/types/modes/components/provider-onboarding-selector.d.ts +7 -0
- package/dist/types/modes/components/queue-mode-selector.d.ts +9 -0
- package/dist/types/modes/components/read-tool-group.d.ts +30 -0
- package/dist/types/modes/components/runtime-mcp-add-wizard.d.ts +25 -0
- package/dist/types/modes/components/session-observer-overlay.d.ts +11 -0
- package/dist/types/modes/components/session-selector.d.ts +30 -0
- package/dist/types/modes/components/settings-defs.d.ts +50 -0
- package/dist/types/modes/components/settings-selector.d.ts +54 -0
- package/dist/types/modes/components/show-images-selector.d.ts +9 -0
- package/dist/types/modes/components/skill-hud/render.d.ts +2 -0
- package/dist/types/modes/components/skill-message.d.ts +9 -0
- package/dist/types/modes/components/status-line/context-thresholds.d.ts +4 -0
- package/dist/types/modes/components/status-line/git-utils.d.ts +22 -0
- package/dist/types/modes/components/status-line/index.d.ts +4 -0
- package/dist/types/modes/components/status-line/presets.d.ts +3 -0
- package/dist/types/modes/components/status-line/segments.d.ts +5 -0
- package/dist/types/modes/components/status-line/separators.d.ts +3 -0
- package/dist/types/modes/components/status-line/token-rate.d.ts +10 -0
- package/dist/types/modes/components/status-line/types.d.ts +80 -0
- package/dist/types/modes/components/status-line.d.ts +80 -0
- package/dist/types/modes/components/theme-selector.d.ts +10 -0
- package/dist/types/modes/components/thinking-selector.d.ts +10 -0
- package/dist/types/modes/components/todo-reminder.d.ts +13 -0
- package/dist/types/modes/components/tool-execution.d.ts +53 -0
- package/dist/types/modes/components/tree-selector.d.ts +31 -0
- package/dist/types/modes/components/ttsr-notification.d.ts +13 -0
- package/dist/types/modes/components/user-message-selector.d.ts +28 -0
- package/dist/types/modes/components/user-message.d.ts +7 -0
- package/dist/types/modes/components/visual-truncate.d.ts +19 -0
- package/dist/types/modes/components/welcome.d.ts +34 -0
- package/dist/types/modes/controllers/btw-controller.d.ts +10 -0
- package/dist/types/modes/controllers/command-controller-shared.d.ts +47 -0
- package/dist/types/modes/controllers/command-controller.d.ts +36 -0
- package/dist/types/modes/controllers/event-controller.d.ts +12 -0
- package/dist/types/modes/controllers/extension-ui-controller.d.ts +80 -0
- package/dist/types/modes/controllers/input-controller.d.ts +35 -0
- package/dist/types/modes/controllers/runtime-mcp-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/selector-controller.d.ts +46 -0
- package/dist/types/modes/controllers/ssh-command-controller.d.ts +10 -0
- package/dist/types/modes/controllers/todo-command-controller.d.ts +7 -0
- package/dist/types/modes/emoji-autocomplete.d.ts +16 -0
- package/dist/types/modes/index.d.ts +9 -0
- package/dist/types/modes/interactive-mode.d.ts +271 -0
- package/dist/types/modes/loop-limit.d.ts +22 -0
- package/dist/types/modes/oauth-manual-input.d.ts +8 -0
- package/dist/types/modes/print-mode.d.ts +27 -0
- package/dist/types/modes/prompt-action-autocomplete.d.ts +46 -0
- package/dist/types/modes/rpc/host-tools.d.ts +16 -0
- package/dist/types/modes/rpc/host-uris.d.ts +38 -0
- package/dist/types/modes/rpc/rpc-client.d.ts +249 -0
- package/dist/types/modes/rpc/rpc-mode.d.ts +17 -0
- package/dist/types/modes/rpc/rpc-types.d.ts +586 -0
- package/dist/types/modes/runtime-init.d.ts +21 -0
- package/dist/types/modes/session-observer-registry.d.ts +26 -0
- package/dist/types/modes/shared.d.ts +15 -0
- package/dist/types/modes/theme/defaults/index.d.ts +9559 -0
- package/dist/types/modes/theme/mermaid-cache.d.ts +9 -0
- package/dist/types/modes/theme/shimmer.d.ts +38 -0
- package/dist/types/modes/theme/theme.d.ts +273 -0
- package/dist/types/modes/types.d.ts +278 -0
- package/dist/types/modes/utils/context-usage.d.ts +47 -0
- package/dist/types/modes/utils/hotkeys-markdown.d.ts +5 -0
- package/dist/types/modes/utils/keybinding-matchers.d.ts +10 -0
- package/dist/types/modes/utils/tools-markdown.d.ts +5 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +53 -0
- package/dist/types/plan-mode/approved-plan.d.ts +49 -0
- package/dist/types/plan-mode/state.d.ts +6 -0
- package/dist/types/registry/agent-registry.d.ts +62 -0
- package/dist/types/runtime-mcp/client.d.ts +74 -0
- package/dist/types/runtime-mcp/config-writer.d.ts +53 -0
- package/dist/types/runtime-mcp/config.d.ts +75 -0
- package/dist/types/runtime-mcp/discoverable-tool-metadata.d.ts +7 -0
- package/dist/types/runtime-mcp/index.d.ts +18 -0
- package/dist/types/runtime-mcp/json-rpc.d.ts +22 -0
- package/dist/types/runtime-mcp/loader.d.ts +43 -0
- package/dist/types/runtime-mcp/manager.d.ts +193 -0
- package/dist/types/runtime-mcp/oauth-discovery.d.ts +40 -0
- package/dist/types/runtime-mcp/oauth-flow.d.ts +59 -0
- package/dist/types/runtime-mcp/render.d.ts +25 -0
- package/dist/types/runtime-mcp/smithery-auth.d.ts +16 -0
- package/dist/types/runtime-mcp/smithery-connect.d.ts +38 -0
- package/dist/types/runtime-mcp/smithery-registry.d.ts +51 -0
- package/dist/types/runtime-mcp/tool-bridge.d.ts +86 -0
- package/dist/types/runtime-mcp/tool-cache.d.ts +8 -0
- package/dist/types/runtime-mcp/transports/http.d.ts +36 -0
- package/dist/types/runtime-mcp/transports/index.d.ts +5 -0
- package/dist/types/runtime-mcp/transports/stdio.d.ts +32 -0
- package/dist/types/runtime-mcp/types.d.ts +333 -0
- package/dist/types/sdk.d.ts +216 -0
- package/dist/types/secrets/index.d.ts +9 -0
- package/dist/types/secrets/obfuscator.d.ts +23 -0
- package/dist/types/secrets/regex.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +930 -0
- package/dist/types/session/agent-storage.d.ts +100 -0
- package/dist/types/session/artifacts.d.ts +61 -0
- package/dist/types/session/auth-broker-config.d.ts +13 -0
- package/dist/types/session/auth-storage.d.ts +6 -0
- package/dist/types/session/blob-store.d.ts +63 -0
- package/dist/types/session/client-bridge.d.ts +88 -0
- package/dist/types/session/history-storage.d.ts +16 -0
- package/dist/types/session/messages.d.ts +162 -0
- package/dist/types/session/session-dump-format.d.ts +22 -0
- package/dist/types/session/session-manager.d.ts +549 -0
- package/dist/types/session/session-storage.d.ts +82 -0
- package/dist/types/session/streaming-output.d.ts +185 -0
- package/dist/types/session/tool-choice-queue.d.ts +78 -0
- package/dist/types/session/yield-queue.d.ts +24 -0
- package/dist/types/setup/model-onboarding-guidance.d.ts +8 -0
- package/dist/types/setup/provider-onboarding.d.ts +28 -0
- package/dist/types/skill-state/active-state.d.ts +50 -0
- package/dist/types/slash-commands/acp-builtins.d.ts +18 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +23 -0
- package/dist/types/slash-commands/helpers/context-report.d.ts +7 -0
- package/dist/types/slash-commands/helpers/format.d.ts +10 -0
- package/dist/types/slash-commands/helpers/mcp.d.ts +3 -0
- package/dist/types/slash-commands/helpers/parse.d.ts +33 -0
- package/dist/types/slash-commands/helpers/ssh.d.ts +3 -0
- package/dist/types/slash-commands/helpers/todo.d.ts +3 -0
- package/dist/types/slash-commands/helpers/usage-report.d.ts +7 -0
- package/dist/types/slash-commands/types.d.ts +118 -0
- package/dist/types/ssh/config-writer.d.ts +49 -0
- package/dist/types/ssh/connection-manager.d.ts +33 -0
- package/dist/types/ssh/ssh-executor.d.ts +37 -0
- package/dist/types/ssh/sshfs-mount.d.ts +6 -0
- package/dist/types/ssh/utils.d.ts +2 -0
- package/dist/types/stt/downloader.d.ts +9 -0
- package/dist/types/stt/index.d.ts +3 -0
- package/dist/types/stt/recorder.d.ts +13 -0
- package/dist/types/stt/setup.d.ts +18 -0
- package/dist/types/stt/stt-controller.d.ts +16 -0
- package/dist/types/stt/transcriber.d.ts +16 -0
- package/dist/types/system-prompt.d.ts +93 -0
- package/dist/types/task/agents.d.ts +28 -0
- package/dist/types/task/commands.d.ts +35 -0
- package/dist/types/task/discovery.d.ts +19 -0
- package/dist/types/task/executor.d.ts +106 -0
- package/dist/types/task/gjc-command.d.ts +7 -0
- package/dist/types/task/index.d.ts +38 -0
- package/dist/types/task/name-generator.d.ts +16 -0
- package/dist/types/task/output-manager.d.ts +36 -0
- package/dist/types/task/parallel.d.ts +34 -0
- package/dist/types/task/render.d.ts +22 -0
- package/dist/types/task/simple-mode.d.ts +8 -0
- package/dist/types/task/subprocess-tool-registry.d.ts +72 -0
- package/dist/types/task/types.d.ts +295 -0
- package/dist/types/task/worktree.d.ts +94 -0
- package/dist/types/thinking.d.ts +30 -0
- package/dist/types/tool-discovery/tool-index.d.ts +112 -0
- package/dist/types/tools/archive-reader.d.ts +40 -0
- package/dist/types/tools/ask.d.ts +109 -0
- package/dist/types/tools/ast-edit.d.ts +77 -0
- package/dist/types/tools/ast-grep.d.ts +69 -0
- package/dist/types/tools/auto-generated-guard.d.ts +17 -0
- package/dist/types/tools/bash-command-fixup.d.ts +11 -0
- package/dist/types/tools/bash-interactive.d.ts +16 -0
- package/dist/types/tools/bash-interceptor.d.ts +24 -0
- package/dist/types/tools/bash-pty-selection.d.ts +7 -0
- package/dist/types/tools/bash-skill-urls.d.ts +31 -0
- package/dist/types/tools/bash.d.ts +130 -0
- package/dist/types/tools/browser/attach.d.ts +34 -0
- package/dist/types/tools/browser/launch.d.ts +62 -0
- package/dist/types/tools/browser/readable.d.ts +17 -0
- package/dist/types/tools/browser/registry.d.ts +42 -0
- package/dist/types/tools/browser/render.d.ts +50 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +144 -0
- package/dist/types/tools/browser/tab-supervisor.d.ts +63 -0
- package/dist/types/tools/browser/tab-worker-entry.d.ts +1 -0
- package/dist/types/tools/browser/tab-worker.d.ts +19 -0
- package/dist/types/tools/browser.d.ts +114 -0
- package/dist/types/tools/calculator.d.ts +76 -0
- package/dist/types/tools/checkpoint.d.ts +63 -0
- package/dist/types/tools/conflict-detect.d.ts +205 -0
- package/dist/types/tools/context.d.ts +19 -0
- package/dist/types/tools/debug.d.ts +209 -0
- package/dist/types/tools/eval.d.ts +108 -0
- package/dist/types/tools/fetch.d.ts +61 -0
- package/dist/types/tools/file-recorder.d.ts +13 -0
- package/dist/types/tools/find.d.ts +95 -0
- package/dist/types/tools/fs-cache-invalidation.d.ts +15 -0
- package/dist/types/tools/gh-format.d.ts +6 -0
- package/dist/types/tools/gh-renderer.d.ts +25 -0
- package/dist/types/tools/gh.d.ts +356 -0
- package/dist/types/tools/github-cache.d.ts +103 -0
- package/dist/types/tools/grouped-file-output.d.ts +36 -0
- package/dist/types/tools/hindsight-recall.d.ts +23 -0
- package/dist/types/tools/hindsight-reflect.d.ts +25 -0
- package/dist/types/tools/hindsight-retain.d.ts +29 -0
- package/dist/types/tools/image-gen.d.ts +78 -0
- package/dist/types/tools/index.d.ts +242 -0
- package/dist/types/tools/inspect-image-renderer.d.ts +26 -0
- package/dist/types/tools/inspect-image.d.ts +31 -0
- package/dist/types/tools/irc.d.ts +79 -0
- package/dist/types/tools/job.d.ts +65 -0
- package/dist/types/tools/json-tree.d.ts +23 -0
- package/dist/types/tools/jtd-to-json-schema.d.ts +29 -0
- package/dist/types/tools/jtd-to-typescript.d.ts +26 -0
- package/dist/types/tools/jtd-utils.d.ts +42 -0
- package/dist/types/tools/list-limit.d.ts +12 -0
- package/dist/types/tools/match-line-format.d.ts +11 -0
- package/dist/types/tools/output-meta.d.ts +204 -0
- package/dist/types/tools/path-utils.d.ts +146 -0
- package/dist/types/tools/plan-mode-guard.d.ts +18 -0
- package/dist/types/tools/read.d.ts +85 -0
- package/dist/types/tools/recipe/index.d.ts +45 -0
- package/dist/types/tools/recipe/render.d.ts +36 -0
- package/dist/types/tools/recipe/runner.d.ts +60 -0
- package/dist/types/tools/recipe/runners/cargo.d.ts +16 -0
- package/dist/types/tools/recipe/runners/index.d.ts +2 -0
- package/dist/types/tools/recipe/runners/just.d.ts +2 -0
- package/dist/types/tools/recipe/runners/make.d.ts +2 -0
- package/dist/types/tools/recipe/runners/pkg.d.ts +2 -0
- package/dist/types/tools/recipe/runners/task.d.ts +2 -0
- package/dist/types/tools/render-mermaid.d.ts +37 -0
- package/dist/types/tools/render-utils.d.ts +158 -0
- package/dist/types/tools/renderers.d.ts +26 -0
- package/dist/types/tools/resolve.d.ts +90 -0
- package/dist/types/tools/review.d.ts +63 -0
- package/dist/types/tools/search-tool-bm25.d.ts +65 -0
- package/dist/types/tools/search.d.ts +93 -0
- package/dist/types/tools/sqlite-reader.d.ts +93 -0
- package/dist/types/tools/ssh.d.ts +67 -0
- package/dist/types/tools/subagent.d.ts +58 -0
- package/dist/types/tools/todo-write.d.ts +120 -0
- package/dist/types/tools/tool-errors.d.ts +33 -0
- package/dist/types/tools/tool-result.d.ts +30 -0
- package/dist/types/tools/tool-timeouts.d.ts +51 -0
- package/dist/types/tools/vim.d.ts +58 -0
- package/dist/types/tools/write.d.ts +59 -0
- package/dist/types/tools/yield.d.ts +25 -0
- package/dist/types/tui/code-cell.d.ts +32 -0
- package/dist/types/tui/file-list.d.ts +22 -0
- package/dist/types/tui/hyperlink.d.ts +42 -0
- package/dist/types/tui/index.d.ts +11 -0
- package/dist/types/tui/output-block.d.ts +28 -0
- package/dist/types/tui/status-line.d.ts +18 -0
- package/dist/types/tui/tree-list.d.ts +19 -0
- package/dist/types/tui/types.d.ts +13 -0
- package/dist/types/tui/utils.d.ts +36 -0
- package/dist/types/utils/changelog.d.ts +20 -0
- package/dist/types/utils/clipboard.d.ts +22 -0
- package/dist/types/utils/command-args.d.ts +9 -0
- package/dist/types/utils/commit-message-generator.d.ts +7 -0
- package/dist/types/utils/edit-mode.d.ts +13 -0
- package/dist/types/utils/event-bus.d.ts +6 -0
- package/dist/types/utils/external-editor.d.ts +17 -0
- package/dist/types/utils/file-display-mode.d.ts +27 -0
- package/dist/types/utils/file-mentions.d.ts +11 -0
- package/dist/types/utils/git.d.ts +361 -0
- package/dist/types/utils/image-loading.d.ts +26 -0
- package/dist/types/utils/image-resize.d.ts +39 -0
- package/dist/types/utils/lang-from-path.d.ts +8 -0
- package/dist/types/utils/markit.d.ts +7 -0
- package/dist/types/utils/open.d.ts +2 -0
- package/dist/types/utils/session-color.d.ts +10 -0
- package/dist/types/utils/shell-snapshot.d.ts +5 -0
- package/dist/types/utils/sixel.d.ts +21 -0
- package/dist/types/utils/title-generator.d.ts +31 -0
- package/dist/types/utils/tool-choice.d.ts +7 -0
- package/dist/types/utils/tools-manager.d.ts +9 -0
- package/dist/types/vim/buffer.d.ts +41 -0
- package/dist/types/vim/commands.d.ts +6 -0
- package/dist/types/vim/engine.d.ts +47 -0
- package/dist/types/vim/parser.d.ts +3 -0
- package/dist/types/vim/render.d.ts +25 -0
- package/dist/types/vim/types.d.ts +182 -0
- package/dist/types/web/kagi.d.ts +23 -0
- package/dist/types/web/parallel.d.ts +58 -0
- package/dist/types/web/scrapers/artifacthub.d.ts +6 -0
- package/dist/types/web/scrapers/arxiv.d.ts +5 -0
- package/dist/types/web/scrapers/aur.d.ts +5 -0
- package/dist/types/web/scrapers/biorxiv.d.ts +5 -0
- package/dist/types/web/scrapers/bluesky.d.ts +5 -0
- package/dist/types/web/scrapers/brew.d.ts +5 -0
- package/dist/types/web/scrapers/cheatsh.d.ts +8 -0
- package/dist/types/web/scrapers/chocolatey.d.ts +5 -0
- package/dist/types/web/scrapers/choosealicense.d.ts +2 -0
- package/dist/types/web/scrapers/cisa-kev.d.ts +5 -0
- package/dist/types/web/scrapers/clojars.d.ts +5 -0
- package/dist/types/web/scrapers/coingecko.d.ts +5 -0
- package/dist/types/web/scrapers/crates-io.d.ts +5 -0
- package/dist/types/web/scrapers/crossref.d.ts +2 -0
- package/dist/types/web/scrapers/devto.d.ts +5 -0
- package/dist/types/web/scrapers/discogs.d.ts +8 -0
- package/dist/types/web/scrapers/discourse.d.ts +5 -0
- package/dist/types/web/scrapers/dockerhub.d.ts +5 -0
- package/dist/types/web/scrapers/docs-rs.d.ts +2 -0
- package/dist/types/web/scrapers/fdroid.d.ts +5 -0
- package/dist/types/web/scrapers/firefox-addons.d.ts +2 -0
- package/dist/types/web/scrapers/flathub.d.ts +2 -0
- package/dist/types/web/scrapers/github-gist.d.ts +5 -0
- package/dist/types/web/scrapers/github.d.ts +12 -0
- package/dist/types/web/scrapers/gitlab.d.ts +5 -0
- package/dist/types/web/scrapers/go-pkg.d.ts +5 -0
- package/dist/types/web/scrapers/hackage.d.ts +5 -0
- package/dist/types/web/scrapers/hackernews.d.ts +2 -0
- package/dist/types/web/scrapers/hex.d.ts +5 -0
- package/dist/types/web/scrapers/huggingface.d.ts +2 -0
- package/dist/types/web/scrapers/iacr.d.ts +5 -0
- package/dist/types/web/scrapers/index.d.ts +84 -0
- package/dist/types/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/dist/types/web/scrapers/lemmy.d.ts +2 -0
- package/dist/types/web/scrapers/lobsters.d.ts +5 -0
- package/dist/types/web/scrapers/mastodon.d.ts +5 -0
- package/dist/types/web/scrapers/maven.d.ts +6 -0
- package/dist/types/web/scrapers/mdn.d.ts +2 -0
- package/dist/types/web/scrapers/metacpan.d.ts +5 -0
- package/dist/types/web/scrapers/musicbrainz.d.ts +5 -0
- package/dist/types/web/scrapers/npm.d.ts +5 -0
- package/dist/types/web/scrapers/nuget.d.ts +5 -0
- package/dist/types/web/scrapers/nvd.d.ts +5 -0
- package/dist/types/web/scrapers/ollama.d.ts +2 -0
- package/dist/types/web/scrapers/open-vsx.d.ts +5 -0
- package/dist/types/web/scrapers/opencorporates.d.ts +5 -0
- package/dist/types/web/scrapers/openlibrary.d.ts +5 -0
- package/dist/types/web/scrapers/orcid.d.ts +5 -0
- package/dist/types/web/scrapers/osv.d.ts +5 -0
- package/dist/types/web/scrapers/packagist.d.ts +5 -0
- package/dist/types/web/scrapers/pub-dev.d.ts +5 -0
- package/dist/types/web/scrapers/pubmed.d.ts +5 -0
- package/dist/types/web/scrapers/pypi.d.ts +5 -0
- package/dist/types/web/scrapers/rawg.d.ts +2 -0
- package/dist/types/web/scrapers/readthedocs.d.ts +2 -0
- package/dist/types/web/scrapers/reddit.d.ts +5 -0
- package/dist/types/web/scrapers/repology.d.ts +5 -0
- package/dist/types/web/scrapers/rfc.d.ts +5 -0
- package/dist/types/web/scrapers/rubygems.d.ts +5 -0
- package/dist/types/web/scrapers/searchcode.d.ts +2 -0
- package/dist/types/web/scrapers/sec-edgar.d.ts +5 -0
- package/dist/types/web/scrapers/semantic-scholar.d.ts +2 -0
- package/dist/types/web/scrapers/snapcraft.d.ts +2 -0
- package/dist/types/web/scrapers/sourcegraph.d.ts +2 -0
- package/dist/types/web/scrapers/spdx.d.ts +5 -0
- package/dist/types/web/scrapers/spotify.d.ts +8 -0
- package/dist/types/web/scrapers/stackoverflow.d.ts +6 -0
- package/dist/types/web/scrapers/terraform.d.ts +5 -0
- package/dist/types/web/scrapers/tldr.d.ts +7 -0
- package/dist/types/web/scrapers/twitter.d.ts +5 -0
- package/dist/types/web/scrapers/types.d.ts +78 -0
- package/dist/types/web/scrapers/utils.d.ts +26 -0
- package/dist/types/web/scrapers/vimeo.d.ts +5 -0
- package/dist/types/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/dist/types/web/scrapers/w3c.d.ts +2 -0
- package/dist/types/web/scrapers/wikidata.d.ts +5 -0
- package/dist/types/web/scrapers/wikipedia.d.ts +5 -0
- package/dist/types/web/scrapers/youtube.d.ts +5 -0
- package/dist/types/web/search/index.d.ts +84 -0
- package/dist/types/web/search/provider.d.ts +21 -0
- package/dist/types/web/search/providers/anthropic.d.ts +32 -0
- package/dist/types/web/search/providers/base.d.ts +67 -0
- package/dist/types/web/search/providers/brave.d.ts +27 -0
- package/dist/types/web/search/providers/codex.d.ts +35 -0
- package/dist/types/web/search/providers/exa.d.ts +52 -0
- package/dist/types/web/search/providers/gemini.d.ts +57 -0
- package/dist/types/web/search/providers/jina.d.ts +26 -0
- package/dist/types/web/search/providers/kagi.d.ts +24 -0
- package/dist/types/web/search/providers/kimi.d.ts +27 -0
- package/dist/types/web/search/providers/parallel.d.ts +15 -0
- package/dist/types/web/search/providers/perplexity.d.ts +38 -0
- package/dist/types/web/search/providers/searxng.d.ts +44 -0
- package/dist/types/web/search/providers/synthetic.d.ts +21 -0
- package/dist/types/web/search/providers/tavily.d.ts +29 -0
- package/dist/types/web/search/providers/utils.d.ts +52 -0
- package/dist/types/web/search/providers/zai.d.ts +28 -0
- package/dist/types/web/search/render.d.ts +35 -0
- package/dist/types/web/search/types.d.ts +344 -0
- package/dist/types/web/search/utils.d.ts +4 -0
- package/dist/types/workspace-tree.d.ts +42 -0
- package/examples/README.md +21 -0
- package/examples/custom-tools/README.md +104 -0
- package/examples/custom-tools/hello/index.ts +20 -0
- package/examples/extensions/README.md +141 -0
- package/examples/extensions/api-demo.ts +79 -0
- package/examples/extensions/chalk-logger.ts +25 -0
- package/examples/extensions/hello.ts +31 -0
- package/examples/extensions/pirate.ts +43 -0
- package/examples/extensions/plan-mode.ts +549 -0
- package/examples/extensions/reload-runtime.ts +38 -0
- package/examples/extensions/tools.ts +144 -0
- package/examples/extensions/with-deps/index.ts +36 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +16 -0
- package/examples/hooks/README.md +56 -0
- package/examples/hooks/auto-commit-on-exit.ts +48 -0
- package/examples/hooks/confirm-destructive.ts +58 -0
- package/examples/hooks/custom-compaction.ts +115 -0
- package/examples/hooks/dirty-repo-guard.ts +51 -0
- package/examples/hooks/file-trigger.ts +40 -0
- package/examples/hooks/git-checkpoint.ts +52 -0
- package/examples/hooks/handoff.ts +149 -0
- package/examples/hooks/permission-gate.ts +33 -0
- package/examples/hooks/protected-paths.ts +29 -0
- package/examples/hooks/qna.ts +118 -0
- package/examples/hooks/status-line.ts +39 -0
- package/examples/sdk/01-minimal.ts +21 -0
- package/examples/sdk/02-custom-model.ts +49 -0
- package/examples/sdk/03-custom-prompt.ts +46 -0
- package/examples/sdk/04-skills.ts +43 -0
- package/examples/sdk/06-extensions.ts +82 -0
- package/examples/sdk/06-hooks.ts +61 -0
- package/examples/sdk/07-context-files.ts +35 -0
- package/examples/sdk/08-prompt-templates.ts +41 -0
- package/examples/sdk/08-slash-commands.ts +46 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +54 -0
- package/examples/sdk/11-sessions.ts +47 -0
- package/examples/sdk/README.md +172 -0
- package/package.json +533 -0
- package/scripts/build-binary.ts +77 -0
- package/scripts/format-prompts.ts +68 -0
- package/scripts/generate-docs-index.ts +71 -0
- package/scripts/generate-template.ts +33 -0
- package/src/async/index.ts +2 -0
- package/src/async/job-manager.ts +586 -0
- package/src/async/support.ts +6 -0
- package/src/autoresearch/command-resume.md +14 -0
- package/src/autoresearch/dashboard.ts +446 -0
- package/src/autoresearch/git.ts +319 -0
- package/src/autoresearch/helpers.ts +218 -0
- package/src/autoresearch/index.ts +536 -0
- package/src/autoresearch/prompt-setup.md +43 -0
- package/src/autoresearch/prompt.md +103 -0
- package/src/autoresearch/resume-message.md +10 -0
- package/src/autoresearch/state.ts +273 -0
- package/src/autoresearch/storage.ts +699 -0
- package/src/autoresearch/tools/init-experiment.ts +272 -0
- package/src/autoresearch/tools/log-experiment.ts +524 -0
- package/src/autoresearch/tools/run-experiment.ts +475 -0
- package/src/autoresearch/tools/update-notes.ts +109 -0
- package/src/autoresearch/types.ts +168 -0
- package/src/bun-imports.d.ts +28 -0
- package/src/capability/context-file.ts +44 -0
- package/src/capability/extension-module.ts +34 -0
- package/src/capability/extension.ts +47 -0
- package/src/capability/fs.ts +107 -0
- package/src/capability/hook.ts +40 -0
- package/src/capability/index.ts +436 -0
- package/src/capability/instruction.ts +37 -0
- package/src/capability/mcp.ts +74 -0
- package/src/capability/prompt.ts +35 -0
- package/src/capability/rule.ts +244 -0
- package/src/capability/settings.ts +34 -0
- package/src/capability/skill.ts +56 -0
- package/src/capability/slash-command.ts +40 -0
- package/src/capability/ssh.ts +41 -0
- package/src/capability/system-prompt.ts +34 -0
- package/src/capability/tool.ts +38 -0
- package/src/capability/types.ts +168 -0
- package/src/cli/agents-cli.ts +138 -0
- package/src/cli/args.ts +269 -0
- package/src/cli/auth-broker-cli.ts +746 -0
- package/src/cli/auth-gateway-cli.ts +411 -0
- package/src/cli/classify-install-target.ts +50 -0
- package/src/cli/commands/init-xdg.ts +27 -0
- package/src/cli/config-cli.ts +418 -0
- package/src/cli/file-processor.ts +123 -0
- package/src/cli/grep-cli.ts +160 -0
- package/src/cli/initial-message.ts +58 -0
- package/src/cli/list-models.ts +194 -0
- package/src/cli/plugin-cli.ts +942 -0
- package/src/cli/read-cli.ts +57 -0
- package/src/cli/session-picker.ts +52 -0
- package/src/cli/setup-cli.ts +433 -0
- package/src/cli/shell-cli.ts +176 -0
- package/src/cli/ssh-cli.ts +179 -0
- package/src/cli/stats-cli.ts +238 -0
- package/src/cli/update-cli.ts +408 -0
- package/src/cli/web-search-cli.ts +133 -0
- package/src/cli/worktree-cli.ts +291 -0
- package/src/cli.ts +99 -0
- package/src/commands/acp.ts +24 -0
- package/src/commands/agents.ts +57 -0
- package/src/commands/auth-broker.ts +96 -0
- package/src/commands/auth-gateway.ts +63 -0
- package/src/commands/codex-native-hook.ts +11 -0
- package/src/commands/commit.ts +46 -0
- package/src/commands/config.ts +51 -0
- package/src/commands/deep-interview.ts +12 -0
- package/src/commands/gjc-runtime-bridge.ts +81 -0
- package/src/commands/grep.ts +48 -0
- package/src/commands/launch.ts +161 -0
- package/src/commands/plugin.ts +78 -0
- package/src/commands/question.ts +12 -0
- package/src/commands/ralplan.ts +12 -0
- package/src/commands/read.ts +35 -0
- package/src/commands/setup.ts +52 -0
- package/src/commands/shell.ts +29 -0
- package/src/commands/ssh.ts +60 -0
- package/src/commands/state.ts +12 -0
- package/src/commands/stats.ts +29 -0
- package/src/commands/team.ts +130 -0
- package/src/commands/ultragoal.ts +32 -0
- package/src/commands/update.ts +21 -0
- package/src/commands/web-search.ts +42 -0
- package/src/commands/worktree.ts +56 -0
- package/src/commit/agentic/agent.ts +316 -0
- package/src/commit/agentic/fallback.ts +96 -0
- package/src/commit/agentic/index.ts +355 -0
- package/src/commit/agentic/prompts/analyze-file.md +22 -0
- package/src/commit/agentic/prompts/session-user.md +25 -0
- package/src/commit/agentic/prompts/split-confirm.md +1 -0
- package/src/commit/agentic/prompts/system.md +38 -0
- package/src/commit/agentic/state.ts +60 -0
- package/src/commit/agentic/tools/analyze-file.ts +127 -0
- package/src/commit/agentic/tools/git-file-diff.ts +191 -0
- package/src/commit/agentic/tools/git-hunk.ts +50 -0
- package/src/commit/agentic/tools/git-overview.ts +81 -0
- package/src/commit/agentic/tools/index.ts +54 -0
- package/src/commit/agentic/tools/propose-changelog.ts +144 -0
- package/src/commit/agentic/tools/propose-commit.ts +109 -0
- package/src/commit/agentic/tools/recent-commits.ts +81 -0
- package/src/commit/agentic/tools/schemas.ts +23 -0
- package/src/commit/agentic/tools/split-commit.ts +238 -0
- package/src/commit/agentic/topo-sort.ts +44 -0
- package/src/commit/agentic/trivial.ts +51 -0
- package/src/commit/agentic/validation.ts +183 -0
- package/src/commit/analysis/conventional.ts +64 -0
- package/src/commit/analysis/index.ts +4 -0
- package/src/commit/analysis/scope.ts +242 -0
- package/src/commit/analysis/summary.ts +105 -0
- package/src/commit/analysis/validation.ts +66 -0
- package/src/commit/changelog/detect.ts +40 -0
- package/src/commit/changelog/generate.ts +97 -0
- package/src/commit/changelog/index.ts +234 -0
- package/src/commit/changelog/parse.ts +44 -0
- package/src/commit/cli.ts +85 -0
- package/src/commit/git/diff.ts +148 -0
- package/src/commit/index.ts +5 -0
- package/src/commit/map-reduce/index.ts +69 -0
- package/src/commit/map-reduce/map-phase.ts +193 -0
- package/src/commit/map-reduce/reduce-phase.ts +49 -0
- package/src/commit/map-reduce/utils.ts +9 -0
- package/src/commit/message.ts +11 -0
- package/src/commit/model-selection.ts +66 -0
- package/src/commit/pipeline.ts +243 -0
- package/src/commit/prompts/analysis-system.md +148 -0
- package/src/commit/prompts/analysis-user.md +38 -0
- package/src/commit/prompts/changelog-system.md +50 -0
- package/src/commit/prompts/changelog-user.md +18 -0
- package/src/commit/prompts/file-observer-system.md +24 -0
- package/src/commit/prompts/file-observer-user.md +8 -0
- package/src/commit/prompts/reduce-system.md +50 -0
- package/src/commit/prompts/reduce-user.md +17 -0
- package/src/commit/prompts/summary-retry.md +3 -0
- package/src/commit/prompts/summary-system.md +38 -0
- package/src/commit/prompts/summary-user.md +13 -0
- package/src/commit/prompts/types-description.md +2 -0
- package/src/commit/shared-llm.ts +77 -0
- package/src/commit/types.ts +118 -0
- package/src/commit/utils/exclusions.ts +42 -0
- package/src/commit/utils.ts +58 -0
- package/src/config/config-file.ts +232 -0
- package/src/config/file-lock.ts +121 -0
- package/src/config/keybindings.ts +493 -0
- package/src/config/mcp-schema.json +230 -0
- package/src/config/model-equivalence.ts +811 -0
- package/src/config/model-registry.ts +2384 -0
- package/src/config/model-resolver.ts +1398 -0
- package/src/config/models-config-schema.ts +175 -0
- package/src/config/prompt-templates.ts +310 -0
- package/src/config/resolve-config-value.ts +94 -0
- package/src/config/settings-schema.ts +2939 -0
- package/src/config/settings.ts +919 -0
- package/src/config/skill-settings-defaults.ts +27 -0
- package/src/config.ts +212 -0
- package/src/cursor.ts +350 -0
- package/src/dap/client.ts +675 -0
- package/src/dap/config.ts +150 -0
- package/src/dap/defaults.json +211 -0
- package/src/dap/index.ts +4 -0
- package/src/dap/session.ts +1306 -0
- package/src/dap/types.ts +600 -0
- package/src/debug/index.ts +459 -0
- package/src/debug/log-formatting.ts +58 -0
- package/src/debug/log-viewer.ts +908 -0
- package/src/debug/profiler.ts +162 -0
- package/src/debug/raw-sse-buffer.ts +270 -0
- package/src/debug/raw-sse.ts +213 -0
- package/src/debug/report-bundle.ts +365 -0
- package/src/debug/system-info.ts +111 -0
- package/src/defaults/gjc/skills/deep-interview/SKILL.md +795 -0
- package/src/defaults/gjc/skills/ralplan/SKILL.md +142 -0
- package/src/defaults/gjc/skills/team/SKILL.md +373 -0
- package/src/defaults/gjc/skills/ultragoal/SKILL.md +176 -0
- package/src/defaults/gjc-defaults.ts +151 -0
- package/src/discovery/agents-md.ts +67 -0
- package/src/discovery/agents.ts +230 -0
- package/src/discovery/builtin.ts +932 -0
- package/src/discovery/claude-plugins.ts +387 -0
- package/src/discovery/claude.ts +313 -0
- package/src/discovery/cline.ts +83 -0
- package/src/discovery/codex.ts +330 -0
- package/src/discovery/cursor.ts +220 -0
- package/src/discovery/gemini.ts +383 -0
- package/src/discovery/github.ts +118 -0
- package/src/discovery/helpers.ts +964 -0
- package/src/discovery/index.ts +76 -0
- package/src/discovery/mcp-json.ts +171 -0
- package/src/discovery/opencode.ts +398 -0
- package/src/discovery/plugin-dir-roots.ts +28 -0
- package/src/discovery/ssh.ts +153 -0
- package/src/discovery/substitute-plugin-root.ts +29 -0
- package/src/discovery/vscode.ts +105 -0
- package/src/discovery/windsurf.ts +147 -0
- package/src/edit/apply-patch/index.ts +87 -0
- package/src/edit/apply-patch/parser.ts +174 -0
- package/src/edit/diff.ts +810 -0
- package/src/edit/file-read-cache.ts +95 -0
- package/src/edit/index.ts +528 -0
- package/src/edit/modes/apply-patch.lark +19 -0
- package/src/edit/modes/apply-patch.ts +53 -0
- package/src/edit/modes/patch.ts +1835 -0
- package/src/edit/modes/replace.ts +1103 -0
- package/src/edit/normalize.ts +375 -0
- package/src/edit/notebook.ts +222 -0
- package/src/edit/read-file.ts +25 -0
- package/src/edit/renderer.ts +683 -0
- package/src/edit/streaming.ts +561 -0
- package/src/eval/backend.ts +43 -0
- package/src/eval/index.ts +4 -0
- package/src/eval/js/context-manager.ts +414 -0
- package/src/eval/js/executor.ts +134 -0
- package/src/eval/js/index.ts +46 -0
- package/src/eval/js/shared/helpers.ts +237 -0
- package/src/eval/js/shared/indirect-eval.ts +30 -0
- package/src/eval/js/shared/prelude.ts +2 -0
- package/src/eval/js/shared/prelude.txt +70 -0
- package/src/eval/js/shared/rewrite-imports.ts +416 -0
- package/src/eval/js/shared/runtime.ts +301 -0
- package/src/eval/js/shared/types.ts +18 -0
- package/src/eval/js/tool-bridge.ts +144 -0
- package/src/eval/js/worker-core.ts +146 -0
- package/src/eval/js/worker-entry.ts +24 -0
- package/src/eval/js/worker-protocol.ts +41 -0
- package/src/eval/py/display.ts +71 -0
- package/src/eval/py/executor.ts +602 -0
- package/src/eval/py/index.ts +58 -0
- package/src/eval/py/kernel.ts +668 -0
- package/src/eval/py/prelude.py +462 -0
- package/src/eval/py/prelude.ts +3 -0
- package/src/eval/py/runner.py +910 -0
- package/src/eval/py/runtime.ts +210 -0
- package/src/eval/py/tool-bridge.ts +137 -0
- package/src/eval/types.ts +48 -0
- package/src/exa/factory.ts +60 -0
- package/src/exa/index.ts +27 -0
- package/src/exa/mcp-client.ts +364 -0
- package/src/exa/render.ts +244 -0
- package/src/exa/researcher.ts +36 -0
- package/src/exa/search.ts +47 -0
- package/src/exa/types.ts +166 -0
- package/src/exa/websets.ts +248 -0
- package/src/exec/bash-executor.ts +309 -0
- package/src/exec/exec.ts +53 -0
- package/src/exec/idle-timeout-watchdog.ts +126 -0
- package/src/exec/non-interactive-env.ts +48 -0
- package/src/export/custom-share.ts +65 -0
- package/src/export/html/index.ts +164 -0
- package/src/export/html/template.css +1060 -0
- package/src/export/html/template.generated.ts +2 -0
- package/src/export/html/template.html +47 -0
- package/src/export/html/template.js +2268 -0
- package/src/export/html/template.macro.ts +25 -0
- package/src/export/html/vendor/highlight.min.js +1213 -0
- package/src/export/html/vendor/marked.min.js +6 -0
- package/src/export/ttsr.ts +434 -0
- package/src/extensibility/custom-commands/bundled/ci-green/index.ts +25 -0
- package/src/extensibility/custom-commands/bundled/review/index.ts +456 -0
- package/src/extensibility/custom-commands/index.ts +2 -0
- package/src/extensibility/custom-commands/loader.ts +238 -0
- package/src/extensibility/custom-commands/types.ts +113 -0
- package/src/extensibility/custom-tools/index.ts +7 -0
- package/src/extensibility/custom-tools/loader.ts +245 -0
- package/src/extensibility/custom-tools/types.ts +254 -0
- package/src/extensibility/custom-tools/wrapper.ts +47 -0
- package/src/extensibility/extensions/compact-handler.ts +40 -0
- package/src/extensibility/extensions/get-commands-handler.ts +80 -0
- package/src/extensibility/extensions/index.ts +15 -0
- package/src/extensibility/extensions/loader.ts +545 -0
- package/src/extensibility/extensions/runner.ts +900 -0
- package/src/extensibility/extensions/types.ts +1259 -0
- package/src/extensibility/extensions/wrapper.ts +189 -0
- package/src/extensibility/hooks/index.ts +5 -0
- package/src/extensibility/hooks/loader.ts +257 -0
- package/src/extensibility/hooks/runner.ts +425 -0
- package/src/extensibility/hooks/tool-wrapper.ts +107 -0
- package/src/extensibility/hooks/types.ts +599 -0
- package/src/extensibility/plugins/doctor.ts +66 -0
- package/src/extensibility/plugins/git-url.ts +281 -0
- package/src/extensibility/plugins/index.ts +9 -0
- package/src/extensibility/plugins/installer.ts +192 -0
- package/src/extensibility/plugins/legacy-pi-compat.ts +336 -0
- package/src/extensibility/plugins/loader.ts +288 -0
- package/src/extensibility/plugins/manager.ts +731 -0
- package/src/extensibility/plugins/marketplace/cache.ts +136 -0
- package/src/extensibility/plugins/marketplace/fetcher.ts +317 -0
- package/src/extensibility/plugins/marketplace/index.ts +6 -0
- package/src/extensibility/plugins/marketplace/manager.ts +770 -0
- package/src/extensibility/plugins/marketplace/registry.ts +196 -0
- package/src/extensibility/plugins/marketplace/source-resolver.ts +147 -0
- package/src/extensibility/plugins/marketplace/types.ts +191 -0
- package/src/extensibility/plugins/parser.ts +105 -0
- package/src/extensibility/plugins/types.ts +194 -0
- package/src/extensibility/shared-events.ts +343 -0
- package/src/extensibility/skills.ts +391 -0
- package/src/extensibility/slash-commands.ts +227 -0
- package/src/extensibility/tool-proxy.ts +25 -0
- package/src/extensibility/typebox.ts +418 -0
- package/src/extensibility/utils.ts +44 -0
- package/src/gjc-runtime/goal-mode-request.ts +212 -0
- package/src/gjc-runtime/launch-tmux.ts +162 -0
- package/src/gjc-runtime/launch-worktree.ts +291 -0
- package/src/gjc-runtime/team-runtime.ts +2025 -0
- package/src/gjc-runtime/ultragoal-runtime.ts +564 -0
- package/src/goals/index.ts +3 -0
- package/src/goals/runtime.ts +524 -0
- package/src/goals/state.ts +37 -0
- package/src/goals/tools/goal-tool.ts +371 -0
- package/src/hashline/anchors.ts +113 -0
- package/src/hashline/apply.ts +737 -0
- package/src/hashline/bigrams.json +649 -0
- package/src/hashline/constants.ts +25 -0
- package/src/hashline/diff-preview.ts +43 -0
- package/src/hashline/diff.ts +56 -0
- package/src/hashline/execute.ts +267 -0
- package/src/hashline/grammar.lark +21 -0
- package/src/hashline/hash.ts +173 -0
- package/src/hashline/index.ts +13 -0
- package/src/hashline/input.ts +130 -0
- package/src/hashline/parser.ts +246 -0
- package/src/hashline/prefixes.ts +101 -0
- package/src/hashline/recovery.ts +113 -0
- package/src/hashline/stream.ts +123 -0
- package/src/hashline/types.ts +68 -0
- package/src/hindsight/backend.ts +205 -0
- package/src/hindsight/bank.ts +131 -0
- package/src/hindsight/client.ts +598 -0
- package/src/hindsight/config.ts +175 -0
- package/src/hindsight/content.ts +210 -0
- package/src/hindsight/index.ts +8 -0
- package/src/hindsight/mental-models.ts +382 -0
- package/src/hindsight/seeds.json +32 -0
- package/src/hindsight/state.ts +469 -0
- package/src/hindsight/transcript.ts +71 -0
- package/src/hooks/codex-native-hooks-config.ts +143 -0
- package/src/hooks/native-skill-hook.ts +279 -0
- package/src/hooks/skill-keywords.ts +86 -0
- package/src/hooks/skill-state.ts +416 -0
- package/src/index.ts +56 -0
- package/src/internal-urls/agent-protocol.ts +129 -0
- package/src/internal-urls/artifact-protocol.ts +80 -0
- package/src/internal-urls/docs-index.generated.ts +81 -0
- package/src/internal-urls/gjc-protocol.ts +83 -0
- package/src/internal-urls/index.ts +21 -0
- package/src/internal-urls/issue-pr-protocol.ts +577 -0
- package/src/internal-urls/json-query.ts +126 -0
- package/src/internal-urls/local-protocol.ts +249 -0
- package/src/internal-urls/mcp-protocol.ts +151 -0
- package/src/internal-urls/memory-protocol.ts +164 -0
- package/src/internal-urls/parse.ts +72 -0
- package/src/internal-urls/registry-helpers.ts +25 -0
- package/src/internal-urls/router.ts +78 -0
- package/src/internal-urls/rule-protocol.ts +38 -0
- package/src/internal-urls/skill-protocol.ts +103 -0
- package/src/internal-urls/types.ts +110 -0
- package/src/lsp/client.ts +951 -0
- package/src/lsp/clients/biome-client.ts +202 -0
- package/src/lsp/clients/index.ts +50 -0
- package/src/lsp/clients/lsp-linter-client.ts +93 -0
- package/src/lsp/clients/swiftlint-client.ts +120 -0
- package/src/lsp/config.ts +492 -0
- package/src/lsp/defaults.json +493 -0
- package/src/lsp/edits.ts +166 -0
- package/src/lsp/index.ts +2282 -0
- package/src/lsp/lspmux.ts +233 -0
- package/src/lsp/render.ts +692 -0
- package/src/lsp/startup-events.ts +13 -0
- package/src/lsp/types.ts +443 -0
- package/src/lsp/utils.ts +678 -0
- package/src/main.ts +961 -0
- package/src/memories/index.ts +1135 -0
- package/src/memories/storage.ts +577 -0
- package/src/memory-backend/index.ts +4 -0
- package/src/memory-backend/local-backend.ts +30 -0
- package/src/memory-backend/off-backend.ts +16 -0
- package/src/memory-backend/resolve.ts +24 -0
- package/src/memory-backend/types.ts +79 -0
- package/src/modes/acp/acp-agent.ts +2170 -0
- package/src/modes/acp/acp-client-bridge.ts +154 -0
- package/src/modes/acp/acp-event-mapper.ts +879 -0
- package/src/modes/acp/acp-mode.ts +23 -0
- package/src/modes/acp/index.ts +2 -0
- package/src/modes/acp/terminal-auth.ts +37 -0
- package/src/modes/components/agent-dashboard.ts +1120 -0
- package/src/modes/components/assistant-message.ts +231 -0
- package/src/modes/components/bash-execution.ts +228 -0
- package/src/modes/components/bordered-loader.ts +41 -0
- package/src/modes/components/branch-summary-message.ts +45 -0
- package/src/modes/components/btw-panel.ts +104 -0
- package/src/modes/components/compaction-summary-message.ts +51 -0
- package/src/modes/components/countdown-timer.ts +75 -0
- package/src/modes/components/custom-editor.ts +237 -0
- package/src/modes/components/custom-message.ts +65 -0
- package/src/modes/components/diff.ts +266 -0
- package/src/modes/components/dynamic-border.ts +25 -0
- package/src/modes/components/eval-execution.ts +164 -0
- package/src/modes/components/execution-shared.ts +102 -0
- package/src/modes/components/extensions/extension-dashboard.ts +350 -0
- package/src/modes/components/extensions/extension-list.ts +492 -0
- package/src/modes/components/extensions/index.ts +9 -0
- package/src/modes/components/extensions/inspector-panel.ts +317 -0
- package/src/modes/components/extensions/state-manager.ts +628 -0
- package/src/modes/components/extensions/types.ts +191 -0
- package/src/modes/components/footer.ts +270 -0
- package/src/modes/components/history-search.ts +158 -0
- package/src/modes/components/hook-editor.ts +151 -0
- package/src/modes/components/hook-input.ts +79 -0
- package/src/modes/components/hook-message.ts +68 -0
- package/src/modes/components/hook-selector.ts +190 -0
- package/src/modes/components/index.ts +36 -0
- package/src/modes/components/keybinding-hints.ts +65 -0
- package/src/modes/components/login-dialog.ts +164 -0
- package/src/modes/components/message-frame.ts +88 -0
- package/src/modes/components/model-selector.ts +794 -0
- package/src/modes/components/oauth-selector.ts +248 -0
- package/src/modes/components/plugin-selector.ts +95 -0
- package/src/modes/components/plugin-settings.ts +488 -0
- package/src/modes/components/provider-onboarding-selector.ts +88 -0
- package/src/modes/components/queue-mode-selector.ts +56 -0
- package/src/modes/components/read-tool-group.ts +267 -0
- package/src/modes/components/runtime-mcp-add-wizard.ts +1341 -0
- package/src/modes/components/session-observer-overlay.ts +839 -0
- package/src/modes/components/session-selector.ts +343 -0
- package/src/modes/components/settings-defs.ts +175 -0
- package/src/modes/components/settings-selector.ts +635 -0
- package/src/modes/components/show-images-selector.ts +45 -0
- package/src/modes/components/skill-hud/render.ts +47 -0
- package/src/modes/components/skill-message.ts +90 -0
- package/src/modes/components/status-line/context-thresholds.ts +68 -0
- package/src/modes/components/status-line/git-utils.ts +42 -0
- package/src/modes/components/status-line/index.ts +4 -0
- package/src/modes/components/status-line/presets.ts +105 -0
- package/src/modes/components/status-line/segments.ts +560 -0
- package/src/modes/components/status-line/separators.ts +55 -0
- package/src/modes/components/status-line/token-rate.ts +66 -0
- package/src/modes/components/status-line/types.ts +93 -0
- package/src/modes/components/status-line.ts +839 -0
- package/src/modes/components/theme-selector.ts +63 -0
- package/src/modes/components/thinking-selector.ts +52 -0
- package/src/modes/components/todo-reminder.ts +40 -0
- package/src/modes/components/tool-execution.ts +830 -0
- package/src/modes/components/tree-selector.ts +930 -0
- package/src/modes/components/ttsr-notification.ts +80 -0
- package/src/modes/components/user-message-selector.ts +141 -0
- package/src/modes/components/user-message.ts +51 -0
- package/src/modes/components/visual-truncate.ts +63 -0
- package/src/modes/components/welcome.ts +389 -0
- package/src/modes/controllers/btw-controller.ts +105 -0
- package/src/modes/controllers/command-controller-shared.ts +108 -0
- package/src/modes/controllers/command-controller.ts +1630 -0
- package/src/modes/controllers/event-controller.ts +786 -0
- package/src/modes/controllers/extension-ui-controller.ts +927 -0
- package/src/modes/controllers/input-controller.ts +858 -0
- package/src/modes/controllers/runtime-mcp-command-controller.ts +1934 -0
- package/src/modes/controllers/selector-controller.ts +1039 -0
- package/src/modes/controllers/ssh-command-controller.ts +384 -0
- package/src/modes/controllers/todo-command-controller.ts +485 -0
- package/src/modes/data/emojis.json +1 -0
- package/src/modes/emoji-autocomplete.ts +285 -0
- package/src/modes/index.ts +34 -0
- package/src/modes/interactive-mode.ts +2756 -0
- package/src/modes/loop-limit.ts +140 -0
- package/src/modes/oauth-manual-input.ts +42 -0
- package/src/modes/print-mode.ts +121 -0
- package/src/modes/prompt-action-autocomplete.ts +345 -0
- package/src/modes/rpc/host-tools.ts +186 -0
- package/src/modes/rpc/host-uris.ts +235 -0
- package/src/modes/rpc/rpc-client.ts +810 -0
- package/src/modes/rpc/rpc-mode.ts +851 -0
- package/src/modes/rpc/rpc-types.ts +378 -0
- package/src/modes/runtime-init.ts +116 -0
- package/src/modes/session-observer-registry.ts +146 -0
- package/src/modes/shared.ts +55 -0
- package/src/modes/theme/dark.json +95 -0
- package/src/modes/theme/defaults/alabaster.json +93 -0
- package/src/modes/theme/defaults/amethyst.json +96 -0
- package/src/modes/theme/defaults/anthracite.json +93 -0
- package/src/modes/theme/defaults/basalt.json +91 -0
- package/src/modes/theme/defaults/birch.json +95 -0
- package/src/modes/theme/defaults/dark-abyss.json +91 -0
- package/src/modes/theme/defaults/dark-arctic.json +104 -0
- package/src/modes/theme/defaults/dark-aurora.json +95 -0
- package/src/modes/theme/defaults/dark-catppuccin.json +107 -0
- package/src/modes/theme/defaults/dark-cavern.json +91 -0
- package/src/modes/theme/defaults/dark-copper.json +95 -0
- package/src/modes/theme/defaults/dark-cosmos.json +90 -0
- package/src/modes/theme/defaults/dark-cyberpunk.json +102 -0
- package/src/modes/theme/defaults/dark-dracula.json +98 -0
- package/src/modes/theme/defaults/dark-eclipse.json +91 -0
- package/src/modes/theme/defaults/dark-ember.json +95 -0
- package/src/modes/theme/defaults/dark-equinox.json +90 -0
- package/src/modes/theme/defaults/dark-forest.json +96 -0
- package/src/modes/theme/defaults/dark-github.json +105 -0
- package/src/modes/theme/defaults/dark-gruvbox.json +112 -0
- package/src/modes/theme/defaults/dark-lavender.json +95 -0
- package/src/modes/theme/defaults/dark-lunar.json +89 -0
- package/src/modes/theme/defaults/dark-midnight.json +95 -0
- package/src/modes/theme/defaults/dark-monochrome.json +94 -0
- package/src/modes/theme/defaults/dark-monokai.json +98 -0
- package/src/modes/theme/defaults/dark-nebula.json +90 -0
- package/src/modes/theme/defaults/dark-nord.json +97 -0
- package/src/modes/theme/defaults/dark-ocean.json +101 -0
- package/src/modes/theme/defaults/dark-one.json +100 -0
- package/src/modes/theme/defaults/dark-poimandres.json +142 -0
- package/src/modes/theme/defaults/dark-rainforest.json +91 -0
- package/src/modes/theme/defaults/dark-reef.json +91 -0
- package/src/modes/theme/defaults/dark-retro.json +92 -0
- package/src/modes/theme/defaults/dark-rose-pine.json +96 -0
- package/src/modes/theme/defaults/dark-sakura.json +95 -0
- package/src/modes/theme/defaults/dark-slate.json +95 -0
- package/src/modes/theme/defaults/dark-solarized.json +97 -0
- package/src/modes/theme/defaults/dark-solstice.json +90 -0
- package/src/modes/theme/defaults/dark-starfall.json +91 -0
- package/src/modes/theme/defaults/dark-sunset.json +99 -0
- package/src/modes/theme/defaults/dark-swamp.json +90 -0
- package/src/modes/theme/defaults/dark-synthwave.json +103 -0
- package/src/modes/theme/defaults/dark-taiga.json +91 -0
- package/src/modes/theme/defaults/dark-terminal.json +95 -0
- package/src/modes/theme/defaults/dark-tokyo-night.json +101 -0
- package/src/modes/theme/defaults/dark-tundra.json +91 -0
- package/src/modes/theme/defaults/dark-twilight.json +91 -0
- package/src/modes/theme/defaults/dark-volcanic.json +91 -0
- package/src/modes/theme/defaults/graphite.json +92 -0
- package/src/modes/theme/defaults/index.ts +201 -0
- package/src/modes/theme/defaults/light-arctic.json +107 -0
- package/src/modes/theme/defaults/light-aurora-day.json +91 -0
- package/src/modes/theme/defaults/light-canyon.json +91 -0
- package/src/modes/theme/defaults/light-catppuccin.json +106 -0
- package/src/modes/theme/defaults/light-cirrus.json +90 -0
- package/src/modes/theme/defaults/light-coral.json +95 -0
- package/src/modes/theme/defaults/light-cyberpunk.json +96 -0
- package/src/modes/theme/defaults/light-dawn.json +90 -0
- package/src/modes/theme/defaults/light-dunes.json +91 -0
- package/src/modes/theme/defaults/light-eucalyptus.json +95 -0
- package/src/modes/theme/defaults/light-forest.json +100 -0
- package/src/modes/theme/defaults/light-frost.json +95 -0
- package/src/modes/theme/defaults/light-github.json +115 -0
- package/src/modes/theme/defaults/light-glacier.json +91 -0
- package/src/modes/theme/defaults/light-gruvbox.json +108 -0
- package/src/modes/theme/defaults/light-haze.json +90 -0
- package/src/modes/theme/defaults/light-honeycomb.json +95 -0
- package/src/modes/theme/defaults/light-lagoon.json +91 -0
- package/src/modes/theme/defaults/light-lavender.json +95 -0
- package/src/modes/theme/defaults/light-meadow.json +91 -0
- package/src/modes/theme/defaults/light-mint.json +95 -0
- package/src/modes/theme/defaults/light-monochrome.json +101 -0
- package/src/modes/theme/defaults/light-ocean.json +99 -0
- package/src/modes/theme/defaults/light-one.json +99 -0
- package/src/modes/theme/defaults/light-opal.json +91 -0
- package/src/modes/theme/defaults/light-orchard.json +91 -0
- package/src/modes/theme/defaults/light-paper.json +95 -0
- package/src/modes/theme/defaults/light-poimandres.json +142 -0
- package/src/modes/theme/defaults/light-prism.json +90 -0
- package/src/modes/theme/defaults/light-retro.json +98 -0
- package/src/modes/theme/defaults/light-sand.json +95 -0
- package/src/modes/theme/defaults/light-savanna.json +91 -0
- package/src/modes/theme/defaults/light-solarized.json +102 -0
- package/src/modes/theme/defaults/light-soleil.json +90 -0
- package/src/modes/theme/defaults/light-sunset.json +99 -0
- package/src/modes/theme/defaults/light-synthwave.json +98 -0
- package/src/modes/theme/defaults/light-tokyo-night.json +111 -0
- package/src/modes/theme/defaults/light-wetland.json +91 -0
- package/src/modes/theme/defaults/light-zenith.json +89 -0
- package/src/modes/theme/defaults/limestone.json +94 -0
- package/src/modes/theme/defaults/mahogany.json +97 -0
- package/src/modes/theme/defaults/marble.json +93 -0
- package/src/modes/theme/defaults/obsidian.json +91 -0
- package/src/modes/theme/defaults/onyx.json +91 -0
- package/src/modes/theme/defaults/pearl.json +93 -0
- package/src/modes/theme/defaults/porcelain.json +91 -0
- package/src/modes/theme/defaults/quartz.json +96 -0
- package/src/modes/theme/defaults/red-claw.json +123 -0
- package/src/modes/theme/defaults/sandstone.json +95 -0
- package/src/modes/theme/defaults/titanium.json +90 -0
- package/src/modes/theme/light.json +93 -0
- package/src/modes/theme/mermaid-cache.ts +29 -0
- package/src/modes/theme/shimmer.ts +219 -0
- package/src/modes/theme/theme-schema.json +429 -0
- package/src/modes/theme/theme.ts +2413 -0
- package/src/modes/types.ts +313 -0
- package/src/modes/utils/context-usage.ts +335 -0
- package/src/modes/utils/hotkeys-markdown.ts +59 -0
- package/src/modes/utils/keybinding-matchers.ts +30 -0
- package/src/modes/utils/tools-markdown.ts +27 -0
- package/src/modes/utils/ui-helpers.ts +741 -0
- package/src/plan-mode/approved-plan.ts +163 -0
- package/src/plan-mode/state.ts +6 -0
- package/src/priority.json +37 -0
- package/src/prompts/agents/architect.md +79 -0
- package/src/prompts/agents/critic.md +55 -0
- package/src/prompts/agents/executor.md +45 -0
- package/src/prompts/agents/explore.md +58 -0
- package/src/prompts/agents/frontmatter.md +12 -0
- package/src/prompts/agents/init.md +34 -0
- package/src/prompts/agents/plan.md +49 -0
- package/src/prompts/agents/planner.md +49 -0
- package/src/prompts/agents/reviewer.md +141 -0
- package/src/prompts/agents/task.md +16 -0
- package/src/prompts/ci-green-request.md +36 -0
- package/src/prompts/commands/orchestrate.md +49 -0
- package/src/prompts/goals/goal-budget-limit.md +16 -0
- package/src/prompts/goals/goal-continuation.md +28 -0
- package/src/prompts/goals/goal-mode-active.md +23 -0
- package/src/prompts/memories/consolidation.md +30 -0
- package/src/prompts/memories/read-path.md +11 -0
- package/src/prompts/memories/stage_one_input.md +6 -0
- package/src/prompts/memories/stage_one_system.md +21 -0
- package/src/prompts/review-request.md +70 -0
- package/src/prompts/system/agent-creation-architect.md +75 -0
- package/src/prompts/system/agent-creation-user.md +6 -0
- package/src/prompts/system/auto-continue.md +1 -0
- package/src/prompts/system/btw-user.md +8 -0
- package/src/prompts/system/commit-message-system.md +2 -0
- package/src/prompts/system/custom-system-prompt.md +64 -0
- package/src/prompts/system/eager-todo.md +13 -0
- package/src/prompts/system/irc-incoming.md +8 -0
- package/src/prompts/system/plan-mode-active.md +116 -0
- package/src/prompts/system/plan-mode-approved.md +28 -0
- package/src/prompts/system/plan-mode-compact-instructions.md +16 -0
- package/src/prompts/system/plan-mode-reference.md +14 -0
- package/src/prompts/system/plan-mode-subagent.md +34 -0
- package/src/prompts/system/plan-mode-tool-decision-reminder.md +9 -0
- package/src/prompts/system/project-prompt.md +46 -0
- package/src/prompts/system/subagent-system-prompt.md +54 -0
- package/src/prompts/system/subagent-user-prompt.md +3 -0
- package/src/prompts/system/subagent-yield-reminder.md +12 -0
- package/src/prompts/system/system-prompt.md +267 -0
- package/src/prompts/system/title-system.md +2 -0
- package/src/prompts/system/ttsr-interrupt.md +7 -0
- package/src/prompts/system/ttsr-tool-reminder.md +5 -0
- package/src/prompts/system/web-search.md +25 -0
- package/src/prompts/tools/apply-patch.md +65 -0
- package/src/prompts/tools/ask.md +29 -0
- package/src/prompts/tools/ast-edit.md +39 -0
- package/src/prompts/tools/ast-grep.md +42 -0
- package/src/prompts/tools/async-result.md +8 -0
- package/src/prompts/tools/bash.md +39 -0
- package/src/prompts/tools/browser.md +70 -0
- package/src/prompts/tools/calculator.md +10 -0
- package/src/prompts/tools/checkpoint.md +16 -0
- package/src/prompts/tools/create-goal.md +3 -0
- package/src/prompts/tools/debug.md +33 -0
- package/src/prompts/tools/eval.md +75 -0
- package/src/prompts/tools/find.md +34 -0
- package/src/prompts/tools/get-goal.md +3 -0
- package/src/prompts/tools/github.md +20 -0
- package/src/prompts/tools/goal.md +18 -0
- package/src/prompts/tools/hashline.md +130 -0
- package/src/prompts/tools/image-gen.md +7 -0
- package/src/prompts/tools/inspect-image-system.md +20 -0
- package/src/prompts/tools/inspect-image.md +32 -0
- package/src/prompts/tools/irc.md +49 -0
- package/src/prompts/tools/job.md +19 -0
- package/src/prompts/tools/lsp.md +42 -0
- package/src/prompts/tools/patch.md +70 -0
- package/src/prompts/tools/read.md +82 -0
- package/src/prompts/tools/recall.md +5 -0
- package/src/prompts/tools/recipe.md +16 -0
- package/src/prompts/tools/reflect.md +5 -0
- package/src/prompts/tools/render-mermaid.md +9 -0
- package/src/prompts/tools/replace.md +36 -0
- package/src/prompts/tools/resolve.md +9 -0
- package/src/prompts/tools/retain.md +6 -0
- package/src/prompts/tools/rewind.md +13 -0
- package/src/prompts/tools/search-tool-bm25.md +33 -0
- package/src/prompts/tools/search.md +25 -0
- package/src/prompts/tools/ssh.md +35 -0
- package/src/prompts/tools/subagent.md +21 -0
- package/src/prompts/tools/task-summary.md +28 -0
- package/src/prompts/tools/task.md +79 -0
- package/src/prompts/tools/todo-write.md +50 -0
- package/src/prompts/tools/update-goal.md +3 -0
- package/src/prompts/tools/vim.md +98 -0
- package/src/prompts/tools/web-search.md +10 -0
- package/src/prompts/tools/write.md +14 -0
- package/src/registry/agent-registry.ts +140 -0
- package/src/runtime-mcp/client.ts +482 -0
- package/src/runtime-mcp/config-writer.ts +225 -0
- package/src/runtime-mcp/config.ts +365 -0
- package/src/runtime-mcp/discoverable-tool-metadata.ts +25 -0
- package/src/runtime-mcp/index.ts +29 -0
- package/src/runtime-mcp/json-rpc.ts +84 -0
- package/src/runtime-mcp/loader.ts +124 -0
- package/src/runtime-mcp/manager.ts +1172 -0
- package/src/runtime-mcp/oauth-discovery.ts +349 -0
- package/src/runtime-mcp/oauth-flow.ts +407 -0
- package/src/runtime-mcp/render.ts +123 -0
- package/src/runtime-mcp/smithery-auth.ts +104 -0
- package/src/runtime-mcp/smithery-connect.ts +145 -0
- package/src/runtime-mcp/smithery-registry.ts +477 -0
- package/src/runtime-mcp/tool-bridge.ts +416 -0
- package/src/runtime-mcp/tool-cache.ts +117 -0
- package/src/runtime-mcp/transports/http.ts +477 -0
- package/src/runtime-mcp/transports/index.ts +6 -0
- package/src/runtime-mcp/transports/stdio.ts +325 -0
- package/src/runtime-mcp/types.ts +423 -0
- package/src/sdk.ts +2064 -0
- package/src/secrets/index.ts +116 -0
- package/src/secrets/obfuscator.ts +277 -0
- package/src/secrets/regex.ts +21 -0
- package/src/session/agent-session.ts +8794 -0
- package/src/session/agent-storage.ts +466 -0
- package/src/session/artifacts.ts +135 -0
- package/src/session/auth-broker-config.ts +102 -0
- package/src/session/auth-storage.ts +23 -0
- package/src/session/blob-store.ts +168 -0
- package/src/session/client-bridge.ts +85 -0
- package/src/session/history-storage.ts +311 -0
- package/src/session/messages.ts +403 -0
- package/src/session/session-dump-format.ts +209 -0
- package/src/session/session-manager.ts +3333 -0
- package/src/session/session-storage.ts +389 -0
- package/src/session/streaming-output.ts +1093 -0
- package/src/session/tool-choice-queue.ts +213 -0
- package/src/session/yield-queue.ts +155 -0
- package/src/setup/model-onboarding-guidance.ts +36 -0
- package/src/setup/provider-onboarding.ts +195 -0
- package/src/skill-state/active-state.ts +272 -0
- package/src/slash-commands/acp-builtins.ts +46 -0
- package/src/slash-commands/builtin-registry.ts +955 -0
- package/src/slash-commands/helpers/context-report.ts +39 -0
- package/src/slash-commands/helpers/format.ts +46 -0
- package/src/slash-commands/helpers/mcp.ts +532 -0
- package/src/slash-commands/helpers/parse.ts +85 -0
- package/src/slash-commands/helpers/ssh.ts +195 -0
- package/src/slash-commands/helpers/todo.ts +279 -0
- package/src/slash-commands/helpers/usage-report.ts +91 -0
- package/src/slash-commands/types.ts +125 -0
- package/src/ssh/config-writer.ts +183 -0
- package/src/ssh/connection-manager.ts +482 -0
- package/src/ssh/ssh-executor.ts +133 -0
- package/src/ssh/sshfs-mount.ts +140 -0
- package/src/ssh/utils.ts +8 -0
- package/src/stt/downloader.ts +71 -0
- package/src/stt/index.ts +3 -0
- package/src/stt/recorder.ts +351 -0
- package/src/stt/setup.ts +52 -0
- package/src/stt/stt-controller.ts +160 -0
- package/src/stt/transcribe.py +70 -0
- package/src/stt/transcriber.ts +91 -0
- package/src/system-prompt.ts +581 -0
- package/src/task/agents.ts +162 -0
- package/src/task/commands.ts +135 -0
- package/src/task/discovery.ts +130 -0
- package/src/task/executor.ts +1564 -0
- package/src/task/gjc-command.ts +26 -0
- package/src/task/index.ts +1366 -0
- package/src/task/name-generator.ts +1577 -0
- package/src/task/output-manager.ts +107 -0
- package/src/task/parallel.ts +116 -0
- package/src/task/render.ts +1136 -0
- package/src/task/simple-mode.ts +27 -0
- package/src/task/subprocess-tool-registry.ts +88 -0
- package/src/task/types.ts +315 -0
- package/src/task/worktree.ts +506 -0
- package/src/thinking.ts +87 -0
- package/src/tool-discovery/tool-index.ts +400 -0
- package/src/tools/archive-reader.ts +321 -0
- package/src/tools/ask.ts +790 -0
- package/src/tools/ast-edit.ts +542 -0
- package/src/tools/ast-grep.ts +423 -0
- package/src/tools/auto-generated-guard.ts +305 -0
- package/src/tools/bash-command-fixup.ts +37 -0
- package/src/tools/bash-interactive.ts +388 -0
- package/src/tools/bash-interceptor.ts +67 -0
- package/src/tools/bash-pty-selection.ts +14 -0
- package/src/tools/bash-skill-urls.ts +248 -0
- package/src/tools/bash.ts +1061 -0
- package/src/tools/browser/attach.ts +175 -0
- package/src/tools/browser/launch.ts +651 -0
- package/src/tools/browser/readable.ts +95 -0
- package/src/tools/browser/registry.ts +194 -0
- package/src/tools/browser/render.ts +212 -0
- package/src/tools/browser/tab-protocol.ts +105 -0
- package/src/tools/browser/tab-supervisor.ts +577 -0
- package/src/tools/browser/tab-worker-entry.ts +21 -0
- package/src/tools/browser/tab-worker.ts +1054 -0
- package/src/tools/browser.ts +301 -0
- package/src/tools/calculator.ts +540 -0
- package/src/tools/checkpoint.ts +134 -0
- package/src/tools/conflict-detect.ts +672 -0
- package/src/tools/context.ts +39 -0
- package/src/tools/debug.ts +1014 -0
- package/src/tools/eval.ts +1101 -0
- package/src/tools/fetch.ts +1482 -0
- package/src/tools/file-recorder.ts +35 -0
- package/src/tools/find.ts +540 -0
- package/src/tools/fs-cache-invalidation.ts +28 -0
- package/src/tools/gh-format.ts +12 -0
- package/src/tools/gh-renderer.ts +428 -0
- package/src/tools/gh.ts +3499 -0
- package/src/tools/github-cache.ts +548 -0
- package/src/tools/grouped-file-output.ts +96 -0
- package/src/tools/hindsight-recall.ts +68 -0
- package/src/tools/hindsight-reflect.ts +57 -0
- package/src/tools/hindsight-retain.ts +56 -0
- package/src/tools/image-gen.ts +1248 -0
- package/src/tools/index.ts +519 -0
- package/src/tools/inspect-image-renderer.ts +103 -0
- package/src/tools/inspect-image.ts +165 -0
- package/src/tools/irc.ts +239 -0
- package/src/tools/job.ts +520 -0
- package/src/tools/json-tree.ts +243 -0
- package/src/tools/jtd-to-json-schema.ts +219 -0
- package/src/tools/jtd-to-typescript.ts +136 -0
- package/src/tools/jtd-utils.ts +102 -0
- package/src/tools/list-limit.ts +40 -0
- package/src/tools/match-line-format.ts +22 -0
- package/src/tools/output-meta.ts +754 -0
- package/src/tools/path-utils.ts +739 -0
- package/src/tools/plan-mode-guard.ts +68 -0
- package/src/tools/puppeteer/00_stealth_tampering.txt +63 -0
- package/src/tools/puppeteer/01_stealth_activity.txt +20 -0
- package/src/tools/puppeteer/02_stealth_hairline.txt +11 -0
- package/src/tools/puppeteer/03_stealth_botd.txt +384 -0
- package/src/tools/puppeteer/04_stealth_iframe.txt +81 -0
- package/src/tools/puppeteer/05_stealth_webgl.txt +75 -0
- package/src/tools/puppeteer/06_stealth_screen.txt +72 -0
- package/src/tools/puppeteer/07_stealth_fonts.txt +97 -0
- package/src/tools/puppeteer/08_stealth_audio.txt +51 -0
- package/src/tools/puppeteer/09_stealth_locale.txt +46 -0
- package/src/tools/puppeteer/10_stealth_plugins.txt +206 -0
- package/src/tools/puppeteer/11_stealth_hardware.txt +8 -0
- package/src/tools/puppeteer/12_stealth_codecs.txt +40 -0
- package/src/tools/puppeteer/13_stealth_worker.txt +74 -0
- package/src/tools/read.ts +2332 -0
- package/src/tools/recipe/index.ts +80 -0
- package/src/tools/recipe/render.ts +19 -0
- package/src/tools/recipe/runner.ts +219 -0
- package/src/tools/recipe/runners/cargo.ts +131 -0
- package/src/tools/recipe/runners/index.ts +8 -0
- package/src/tools/recipe/runners/just.ts +73 -0
- package/src/tools/recipe/runners/make.ts +101 -0
- package/src/tools/recipe/runners/pkg.ts +167 -0
- package/src/tools/recipe/runners/task.ts +72 -0
- package/src/tools/render-mermaid.ts +68 -0
- package/src/tools/render-utils.ts +774 -0
- package/src/tools/renderers.ts +75 -0
- package/src/tools/resolve.ts +258 -0
- package/src/tools/review.ts +252 -0
- package/src/tools/search-tool-bm25.ts +360 -0
- package/src/tools/search.ts +786 -0
- package/src/tools/sqlite-reader.ts +736 -0
- package/src/tools/ssh.ts +310 -0
- package/src/tools/subagent.ts +312 -0
- package/src/tools/todo-write.ts +695 -0
- package/src/tools/tool-errors.ts +62 -0
- package/src/tools/tool-result.ts +86 -0
- package/src/tools/tool-timeouts.ts +30 -0
- package/src/tools/vim.ts +949 -0
- package/src/tools/write.ts +953 -0
- package/src/tools/yield.ts +268 -0
- package/src/tui/code-cell.ts +201 -0
- package/src/tui/file-list.ts +55 -0
- package/src/tui/hyperlink.ts +126 -0
- package/src/tui/index.ts +12 -0
- package/src/tui/output-block.ts +150 -0
- package/src/tui/status-line.ts +39 -0
- package/src/tui/tree-list.ts +84 -0
- package/src/tui/types.ts +15 -0
- package/src/tui/utils.ts +103 -0
- package/src/utils/changelog.ts +98 -0
- package/src/utils/clipboard.ts +156 -0
- package/src/utils/command-args.ts +76 -0
- package/src/utils/commit-message-generator.ts +142 -0
- package/src/utils/edit-mode.ts +42 -0
- package/src/utils/event-bus.ts +33 -0
- package/src/utils/external-editor.ts +65 -0
- package/src/utils/file-display-mode.ts +45 -0
- package/src/utils/file-mentions.ts +376 -0
- package/src/utils/git.ts +1536 -0
- package/src/utils/image-loading.ts +102 -0
- package/src/utils/image-resize.ts +309 -0
- package/src/utils/lang-from-path.ts +239 -0
- package/src/utils/markit.ts +89 -0
- package/src/utils/open.ts +20 -0
- package/src/utils/session-color.ts +43 -0
- package/src/utils/shell-snapshot.ts +187 -0
- package/src/utils/sixel.ts +69 -0
- package/src/utils/title-generator.ts +223 -0
- package/src/utils/tool-choice.ts +33 -0
- package/src/utils/tools-manager.ts +363 -0
- package/src/vim/buffer.ts +309 -0
- package/src/vim/commands.ts +382 -0
- package/src/vim/engine.ts +2409 -0
- package/src/vim/parser.ts +134 -0
- package/src/vim/render.ts +252 -0
- package/src/vim/types.ts +197 -0
- package/src/web/kagi.ts +183 -0
- package/src/web/parallel.ts +349 -0
- package/src/web/scrapers/artifacthub.ts +207 -0
- package/src/web/scrapers/arxiv.ts +83 -0
- package/src/web/scrapers/aur.ts +162 -0
- package/src/web/scrapers/biorxiv.ts +133 -0
- package/src/web/scrapers/bluesky.ts +262 -0
- package/src/web/scrapers/brew.ts +172 -0
- package/src/web/scrapers/cheatsh.ts +68 -0
- package/src/web/scrapers/chocolatey.ts +196 -0
- package/src/web/scrapers/choosealicense.ts +95 -0
- package/src/web/scrapers/cisa-kev.ts +87 -0
- package/src/web/scrapers/clojars.ts +154 -0
- package/src/web/scrapers/coingecko.ts +177 -0
- package/src/web/scrapers/crates-io.ts +97 -0
- package/src/web/scrapers/crossref.ts +136 -0
- package/src/web/scrapers/devto.ts +147 -0
- package/src/web/scrapers/discogs.ts +306 -0
- package/src/web/scrapers/discourse.ts +197 -0
- package/src/web/scrapers/dockerhub.ts +138 -0
- package/src/web/scrapers/docs-rs.ts +653 -0
- package/src/web/scrapers/fdroid.ts +134 -0
- package/src/web/scrapers/firefox-addons.ts +191 -0
- package/src/web/scrapers/flathub.ts +223 -0
- package/src/web/scrapers/github-gist.ts +58 -0
- package/src/web/scrapers/github.ts +452 -0
- package/src/web/scrapers/gitlab.ts +401 -0
- package/src/web/scrapers/go-pkg.ts +266 -0
- package/src/web/scrapers/hackage.ts +140 -0
- package/src/web/scrapers/hackernews.ts +189 -0
- package/src/web/scrapers/hex.ts +105 -0
- package/src/web/scrapers/huggingface.ts +321 -0
- package/src/web/scrapers/iacr.ts +89 -0
- package/src/web/scrapers/index.ts +252 -0
- package/src/web/scrapers/jetbrains-marketplace.ts +159 -0
- package/src/web/scrapers/lemmy.ts +203 -0
- package/src/web/scrapers/lobsters.ts +175 -0
- package/src/web/scrapers/mastodon.ts +292 -0
- package/src/web/scrapers/maven.ts +138 -0
- package/src/web/scrapers/mdn.ts +173 -0
- package/src/web/scrapers/metacpan.ts +222 -0
- package/src/web/scrapers/musicbrainz.ts +250 -0
- package/src/web/scrapers/npm.ts +98 -0
- package/src/web/scrapers/nuget.ts +183 -0
- package/src/web/scrapers/nvd.ts +222 -0
- package/src/web/scrapers/ollama.ts +239 -0
- package/src/web/scrapers/open-vsx.ts +106 -0
- package/src/web/scrapers/opencorporates.ts +292 -0
- package/src/web/scrapers/openlibrary.ts +336 -0
- package/src/web/scrapers/orcid.ts +286 -0
- package/src/web/scrapers/osv.ts +176 -0
- package/src/web/scrapers/packagist.ts +160 -0
- package/src/web/scrapers/pub-dev.ts +143 -0
- package/src/web/scrapers/pubmed.ts +211 -0
- package/src/web/scrapers/pypi.ts +112 -0
- package/src/web/scrapers/rawg.ts +110 -0
- package/src/web/scrapers/readthedocs.ts +120 -0
- package/src/web/scrapers/reddit.ts +95 -0
- package/src/web/scrapers/repology.ts +251 -0
- package/src/web/scrapers/rfc.ts +201 -0
- package/src/web/scrapers/rubygems.ts +103 -0
- package/src/web/scrapers/searchcode.ts +189 -0
- package/src/web/scrapers/sec-edgar.ts +261 -0
- package/src/web/scrapers/semantic-scholar.ts +171 -0
- package/src/web/scrapers/snapcraft.ts +187 -0
- package/src/web/scrapers/sourcegraph.ts +336 -0
- package/src/web/scrapers/spdx.ts +108 -0
- package/src/web/scrapers/spotify.ts +198 -0
- package/src/web/scrapers/stackoverflow.ts +120 -0
- package/src/web/scrapers/terraform.ts +277 -0
- package/src/web/scrapers/tldr.ts +47 -0
- package/src/web/scrapers/twitter.ts +93 -0
- package/src/web/scrapers/types.ts +318 -0
- package/src/web/scrapers/utils.ts +109 -0
- package/src/web/scrapers/vimeo.ts +133 -0
- package/src/web/scrapers/vscode-marketplace.ts +187 -0
- package/src/web/scrapers/w3c.ts +156 -0
- package/src/web/scrapers/wikidata.ts +344 -0
- package/src/web/scrapers/wikipedia.ts +84 -0
- package/src/web/scrapers/youtube.ts +319 -0
- package/src/web/search/index.ts +288 -0
- package/src/web/search/provider.ts +173 -0
- package/src/web/search/providers/anthropic.ts +302 -0
- package/src/web/search/providers/base.ts +71 -0
- package/src/web/search/providers/brave.ts +149 -0
- package/src/web/search/providers/codex.ts +556 -0
- package/src/web/search/providers/exa.ts +193 -0
- package/src/web/search/providers/gemini.ts +455 -0
- package/src/web/search/providers/jina.ts +101 -0
- package/src/web/search/providers/kagi.ts +75 -0
- package/src/web/search/providers/kimi.ts +171 -0
- package/src/web/search/providers/parallel.ts +210 -0
- package/src/web/search/providers/perplexity.ts +575 -0
- package/src/web/search/providers/searxng.ts +309 -0
- package/src/web/search/providers/synthetic.ts +108 -0
- package/src/web/search/providers/tavily.ts +173 -0
- package/src/web/search/providers/utils.ts +128 -0
- package/src/web/search/providers/zai.ts +320 -0
- package/src/web/search/render.ts +299 -0
- package/src/web/search/types.ts +436 -0
- package/src/web/search/utils.ts +17 -0
- package/src/workspace-tree.ts +286 -0
|
@@ -0,0 +1,2025 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import * as fs from "node:fs/promises";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
|
|
5
|
+
export type GjcTeamPhase = "starting" | "running" | "complete" | "failed" | "cancelled";
|
|
6
|
+
export type GjcTeamTaskStatus = "pending" | "blocked" | "in_progress" | "completed" | "failed";
|
|
7
|
+
export type GjcWorkerStatusState = "idle" | "working" | "blocked" | "done" | "failed" | "draining" | "unknown";
|
|
8
|
+
|
|
9
|
+
export const GJC_TEAM_DEFAULT_WORKERS = 3;
|
|
10
|
+
export const GJC_TEAM_MAX_WORKERS = 20;
|
|
11
|
+
|
|
12
|
+
export interface GjcTeamLeader {
|
|
13
|
+
session_id: string;
|
|
14
|
+
pane_id: string;
|
|
15
|
+
cwd: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface GjcTeamWorker {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
index: number;
|
|
22
|
+
agent_type: string;
|
|
23
|
+
role: string;
|
|
24
|
+
pane_id?: string;
|
|
25
|
+
status: "starting" | "idle" | "busy" | "stopped";
|
|
26
|
+
last_heartbeat: string;
|
|
27
|
+
assigned_tasks: string[];
|
|
28
|
+
worktree_repo_root?: string;
|
|
29
|
+
worktree_path?: string;
|
|
30
|
+
worktree_branch?: string | null;
|
|
31
|
+
worktree_detached?: boolean;
|
|
32
|
+
worktree_created?: boolean;
|
|
33
|
+
worktree_base_ref?: string;
|
|
34
|
+
team_state_root?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface GjcTeamTaskClaim {
|
|
38
|
+
owner: string;
|
|
39
|
+
token: string;
|
|
40
|
+
leased_until: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface GjcTeamTask {
|
|
44
|
+
id: string;
|
|
45
|
+
subject: string;
|
|
46
|
+
description: string;
|
|
47
|
+
title: string;
|
|
48
|
+
objective: string;
|
|
49
|
+
status: GjcTeamTaskStatus;
|
|
50
|
+
assignee?: string;
|
|
51
|
+
owner?: string;
|
|
52
|
+
result?: string;
|
|
53
|
+
error?: string;
|
|
54
|
+
blocked_by?: string[];
|
|
55
|
+
depends_on?: string[];
|
|
56
|
+
version: number;
|
|
57
|
+
claim?: GjcTeamTaskClaim;
|
|
58
|
+
created_at: string;
|
|
59
|
+
updated_at: string;
|
|
60
|
+
completed_at?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export type GjcTeamWorktreeMode =
|
|
64
|
+
| { enabled: false }
|
|
65
|
+
| { enabled: true; detached: true; name: null }
|
|
66
|
+
| { enabled: true; detached: false; name: string };
|
|
67
|
+
|
|
68
|
+
export interface GjcTeamConfig {
|
|
69
|
+
team_name: string;
|
|
70
|
+
display_name: string;
|
|
71
|
+
requested_name: string;
|
|
72
|
+
task: string;
|
|
73
|
+
agent_type: string;
|
|
74
|
+
worker_count: number;
|
|
75
|
+
max_workers: number;
|
|
76
|
+
state_root: string;
|
|
77
|
+
worker_command: string;
|
|
78
|
+
tmux_command: string;
|
|
79
|
+
tmux_session: string;
|
|
80
|
+
tmux_session_name: string;
|
|
81
|
+
tmux_target: string;
|
|
82
|
+
workspace_mode: "direct" | "worktree";
|
|
83
|
+
leader: GjcTeamLeader;
|
|
84
|
+
leader_cwd: string;
|
|
85
|
+
team_state_root: string;
|
|
86
|
+
workers: GjcTeamWorker[];
|
|
87
|
+
created_at: string;
|
|
88
|
+
updated_at: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type GjcTeamIntegrationStatus =
|
|
92
|
+
| "idle"
|
|
93
|
+
| "integrated"
|
|
94
|
+
| "integration_failed"
|
|
95
|
+
| "merge_conflict"
|
|
96
|
+
| "cherry_pick_conflict"
|
|
97
|
+
| "rebase_conflict";
|
|
98
|
+
|
|
99
|
+
export interface GjcTeamWorkerIntegrationState {
|
|
100
|
+
last_seen_head?: string;
|
|
101
|
+
last_integrated_head?: string;
|
|
102
|
+
last_leader_head?: string;
|
|
103
|
+
last_rebased_leader_head?: string;
|
|
104
|
+
status?: GjcTeamIntegrationStatus;
|
|
105
|
+
conflict_commit?: string;
|
|
106
|
+
conflict_files?: string[];
|
|
107
|
+
updated_at?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface GjcTeamMonitorSnapshot {
|
|
111
|
+
integration_by_worker: Record<string, GjcTeamWorkerIntegrationState>;
|
|
112
|
+
updated_at: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface GjcTeamSnapshot {
|
|
116
|
+
team_name: string;
|
|
117
|
+
display_name: string;
|
|
118
|
+
phase: GjcTeamPhase;
|
|
119
|
+
state_dir: string;
|
|
120
|
+
tmux_session: string;
|
|
121
|
+
tmux_session_name: string;
|
|
122
|
+
tmux_target: string;
|
|
123
|
+
task_total: number;
|
|
124
|
+
task_counts: Record<GjcTeamTaskStatus, number>;
|
|
125
|
+
workers: GjcTeamWorker[];
|
|
126
|
+
integration_by_worker?: Record<string, GjcTeamWorkerIntegrationState>;
|
|
127
|
+
updated_at: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface GjcTeamStartOptions {
|
|
131
|
+
workerCount: number;
|
|
132
|
+
agentType: string;
|
|
133
|
+
task: string;
|
|
134
|
+
teamName?: string;
|
|
135
|
+
worktreeMode?: GjcTeamWorktreeMode;
|
|
136
|
+
cwd?: string;
|
|
137
|
+
env?: NodeJS.ProcessEnv;
|
|
138
|
+
dryRun?: boolean;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface GjcTeamApiClaimResult {
|
|
142
|
+
ok: boolean;
|
|
143
|
+
task?: GjcTeamTask;
|
|
144
|
+
worker_id?: string;
|
|
145
|
+
claim_token?: string;
|
|
146
|
+
reason?: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface GjcTeamMailboxMessage {
|
|
150
|
+
message_id: string;
|
|
151
|
+
from_worker: string;
|
|
152
|
+
to_worker: string;
|
|
153
|
+
body: string;
|
|
154
|
+
created_at: string;
|
|
155
|
+
delivered_at?: string;
|
|
156
|
+
notified_at?: string;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface FsError {
|
|
160
|
+
code?: string;
|
|
161
|
+
}
|
|
162
|
+
interface GjcTmuxLeaderContext {
|
|
163
|
+
sessionName: string;
|
|
164
|
+
windowIndex: string;
|
|
165
|
+
leaderPaneId: string;
|
|
166
|
+
target: string;
|
|
167
|
+
}
|
|
168
|
+
interface GjcTeamEvent {
|
|
169
|
+
event_id: string;
|
|
170
|
+
ts: string;
|
|
171
|
+
type: string;
|
|
172
|
+
worker?: string;
|
|
173
|
+
task_id?: string;
|
|
174
|
+
message?: string;
|
|
175
|
+
data?: Record<string, unknown>;
|
|
176
|
+
}
|
|
177
|
+
interface WorkerStatusFile {
|
|
178
|
+
state: GjcWorkerStatusState;
|
|
179
|
+
current_task_id?: string;
|
|
180
|
+
reason?: string;
|
|
181
|
+
updated_at: string;
|
|
182
|
+
}
|
|
183
|
+
interface WorkerHeartbeatFile {
|
|
184
|
+
pid: number;
|
|
185
|
+
last_turn_at: string;
|
|
186
|
+
turn_count: number;
|
|
187
|
+
alive: boolean;
|
|
188
|
+
}
|
|
189
|
+
interface GitResult {
|
|
190
|
+
ok: boolean;
|
|
191
|
+
stdout: string;
|
|
192
|
+
stderr: string;
|
|
193
|
+
}
|
|
194
|
+
interface GjcTeamCommitHygieneEntry {
|
|
195
|
+
recorded_at: string;
|
|
196
|
+
operation: "auto_checkpoint" | "integration_merge" | "integration_cherry_pick" | "cross_rebase";
|
|
197
|
+
worker_name: string;
|
|
198
|
+
task_id?: string;
|
|
199
|
+
status: "applied" | "skipped" | "conflict" | "failed";
|
|
200
|
+
operational_commit?: string | null;
|
|
201
|
+
source_commit?: string;
|
|
202
|
+
leader_head_before?: string;
|
|
203
|
+
leader_head_after?: string | null;
|
|
204
|
+
worker_head_before?: string | null;
|
|
205
|
+
worker_head_after?: string | null;
|
|
206
|
+
worktree_path?: string;
|
|
207
|
+
detail: string;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function isGjcTeamTaskStatus(value: string): value is GjcTeamTaskStatus {
|
|
211
|
+
return ["pending", "blocked", "in_progress", "completed", "failed"].includes(value);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function parseGjcTeamTaskStatus(value: unknown, allowLegacyComplete = false): GjcTeamTaskStatus {
|
|
215
|
+
const raw = typeof value === "string" ? value.trim() : "";
|
|
216
|
+
if (allowLegacyComplete && raw === "complete") return "completed";
|
|
217
|
+
if (isGjcTeamTaskStatus(raw)) return raw;
|
|
218
|
+
throw new Error(`invalid_task_status:${raw}`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export const GJC_TEAM_API_OPERATIONS = [
|
|
222
|
+
"send-message",
|
|
223
|
+
"broadcast",
|
|
224
|
+
"mailbox-list",
|
|
225
|
+
"mailbox-mark-delivered",
|
|
226
|
+
"mailbox-mark-notified",
|
|
227
|
+
"create-task",
|
|
228
|
+
"read-task",
|
|
229
|
+
"list-tasks",
|
|
230
|
+
"update-task",
|
|
231
|
+
"claim-task",
|
|
232
|
+
"transition-task-status",
|
|
233
|
+
"transition-task",
|
|
234
|
+
"release-task-claim",
|
|
235
|
+
"read-config",
|
|
236
|
+
"read-manifest",
|
|
237
|
+
"read-worker-status",
|
|
238
|
+
"read-worker-heartbeat",
|
|
239
|
+
"update-worker-heartbeat",
|
|
240
|
+
"write-worker-inbox",
|
|
241
|
+
"write-worker-identity",
|
|
242
|
+
"append-event",
|
|
243
|
+
"read-events",
|
|
244
|
+
"await-event",
|
|
245
|
+
"write-shutdown-request",
|
|
246
|
+
"read-shutdown-ack",
|
|
247
|
+
"read-monitor-snapshot",
|
|
248
|
+
"write-monitor-snapshot",
|
|
249
|
+
"read-task-approval",
|
|
250
|
+
"write-task-approval",
|
|
251
|
+
] as const;
|
|
252
|
+
|
|
253
|
+
function now(): string {
|
|
254
|
+
return new Date().toISOString();
|
|
255
|
+
}
|
|
256
|
+
function isEnoent(error: unknown): error is FsError {
|
|
257
|
+
return typeof error === "object" && error !== null && "code" in error && (error as FsError).code === "ENOENT";
|
|
258
|
+
}
|
|
259
|
+
function isEexist(error: unknown): error is FsError {
|
|
260
|
+
return typeof error === "object" && error !== null && "code" in error && (error as FsError).code === "EEXIST";
|
|
261
|
+
}
|
|
262
|
+
function sanitizeName(value: string): string {
|
|
263
|
+
const sanitized = value
|
|
264
|
+
.toLowerCase()
|
|
265
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
266
|
+
.replace(/-+/g, "-")
|
|
267
|
+
.replace(/^-|-$/g, "")
|
|
268
|
+
.slice(0, 40)
|
|
269
|
+
.replace(/-$/, "");
|
|
270
|
+
return sanitized || "team";
|
|
271
|
+
}
|
|
272
|
+
function shortHash(value: string): string {
|
|
273
|
+
return Bun.hash(value).toString(16).slice(0, 8).padStart(8, "0");
|
|
274
|
+
}
|
|
275
|
+
function makeTeamName(task: string, env: NodeJS.ProcessEnv): string {
|
|
276
|
+
const basis = [task, env.GJC_SESSION_ID, env.CODEX_SESSION_ID, env.TMUX_PANE, env.TMUX, now()]
|
|
277
|
+
.filter(Boolean)
|
|
278
|
+
.join(":");
|
|
279
|
+
const prefix = sanitizeName(task).slice(0, 30).replace(/-$/, "") || "team";
|
|
280
|
+
return `${prefix}-${shortHash(basis)}`;
|
|
281
|
+
}
|
|
282
|
+
function teamDir(stateRoot: string, teamName: string): string {
|
|
283
|
+
return path.join(stateRoot, sanitizeName(teamName));
|
|
284
|
+
}
|
|
285
|
+
function shellQuote(value: string): string {
|
|
286
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
287
|
+
}
|
|
288
|
+
function taskPath(dir: string, taskId: string): string {
|
|
289
|
+
return path.join(dir, "tasks", `${taskId}.json`);
|
|
290
|
+
}
|
|
291
|
+
function mailboxPath(dir: string, worker: string): string {
|
|
292
|
+
return path.join(dir, "mailbox", `${worker}.json`);
|
|
293
|
+
}
|
|
294
|
+
function workerDir(dir: string, worker: string): string {
|
|
295
|
+
return path.join(dir, "workers", worker);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function resolveGjcTeamStateRoot(cwd = process.cwd(), env: NodeJS.ProcessEnv = process.env): string {
|
|
299
|
+
const explicit = env.GJC_TEAM_STATE_ROOT?.trim();
|
|
300
|
+
if (explicit) return path.resolve(cwd, explicit);
|
|
301
|
+
return path.join(cwd, ".gjc", "state", "team");
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
async function readJsonFile<T>(filePath: string): Promise<T | null> {
|
|
305
|
+
try {
|
|
306
|
+
return (await Bun.file(filePath).json()) as T;
|
|
307
|
+
} catch (error) {
|
|
308
|
+
if (isEnoent(error)) return null;
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async function writeJsonFile(filePath: string, value: unknown): Promise<void> {
|
|
313
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
314
|
+
await Bun.write(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
315
|
+
}
|
|
316
|
+
async function appendJsonl(filePath: string, value: unknown): Promise<void> {
|
|
317
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
318
|
+
await fs.appendFile(filePath, `${JSON.stringify(value)}\n`, "utf-8");
|
|
319
|
+
}
|
|
320
|
+
async function appendEvent(dir: string, event: Omit<GjcTeamEvent, "ts" | "event_id">): Promise<GjcTeamEvent> {
|
|
321
|
+
const full = { event_id: `evt-${Date.now()}-${Math.random().toString(16).slice(2)}`, ts: now(), ...event };
|
|
322
|
+
await appendJsonl(path.join(dir, "events.jsonl"), full);
|
|
323
|
+
return full;
|
|
324
|
+
}
|
|
325
|
+
async function appendTelemetry(
|
|
326
|
+
dir: string,
|
|
327
|
+
event: { type: string; message: string; data?: Record<string, unknown> },
|
|
328
|
+
): Promise<void> {
|
|
329
|
+
await appendJsonl(path.join(dir, "telemetry.jsonl"), { ts: now(), ...event });
|
|
330
|
+
}
|
|
331
|
+
async function readConfig(dir: string): Promise<GjcTeamConfig> {
|
|
332
|
+
const config = await readJsonFile<GjcTeamConfig>(path.join(dir, "config.json"));
|
|
333
|
+
if (!config) throw new Error(`team_config_not_found:${dir}`);
|
|
334
|
+
const tmuxSessionName = config.tmux_session_name ?? config.tmux_session?.split(":")[0] ?? "";
|
|
335
|
+
return {
|
|
336
|
+
...config,
|
|
337
|
+
max_workers: config.max_workers ?? GJC_TEAM_MAX_WORKERS,
|
|
338
|
+
tmux_command: config.tmux_command ?? resolveGjcTmuxCommand(),
|
|
339
|
+
tmux_session: tmuxSessionName,
|
|
340
|
+
tmux_session_name: tmuxSessionName,
|
|
341
|
+
tmux_target: config.tmux_target ?? config.tmux_session ?? tmuxSessionName,
|
|
342
|
+
leader_cwd: config.leader_cwd ?? config.leader.cwd,
|
|
343
|
+
team_state_root: config.team_state_root ?? config.state_root,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
async function readPhase(dir: string): Promise<GjcTeamPhase> {
|
|
347
|
+
const phase = await readJsonFile<{ current_phase?: GjcTeamPhase }>(path.join(dir, "phase.json"));
|
|
348
|
+
return phase?.current_phase ?? "running";
|
|
349
|
+
}
|
|
350
|
+
async function writePhase(dir: string, phase: GjcTeamPhase): Promise<void> {
|
|
351
|
+
await writeJsonFile(path.join(dir, "phase.json"), { current_phase: phase, updated_at: now() });
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function normalizeTask(raw: GjcTeamTask): GjcTeamTask {
|
|
355
|
+
const status = raw.status === ("complete" as GjcTeamTaskStatus) ? "completed" : raw.status;
|
|
356
|
+
return {
|
|
357
|
+
...raw,
|
|
358
|
+
status,
|
|
359
|
+
subject: raw.subject ?? raw.title,
|
|
360
|
+
description: raw.description ?? raw.objective,
|
|
361
|
+
title: raw.title ?? raw.subject,
|
|
362
|
+
objective: raw.objective ?? raw.description,
|
|
363
|
+
version: raw.version ?? 1,
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
async function readTasks(dir: string): Promise<GjcTeamTask[]> {
|
|
367
|
+
try {
|
|
368
|
+
const entries = await fs.readdir(path.join(dir, "tasks"), { withFileTypes: true });
|
|
369
|
+
const tasks = await Promise.all(
|
|
370
|
+
entries
|
|
371
|
+
.filter(entry => entry.isFile() && entry.name.endsWith(".json"))
|
|
372
|
+
.map(entry => readJsonFile<GjcTeamTask>(path.join(dir, "tasks", entry.name))),
|
|
373
|
+
);
|
|
374
|
+
return tasks
|
|
375
|
+
.filter((task): task is GjcTeamTask => task != null)
|
|
376
|
+
.map(normalizeTask)
|
|
377
|
+
.sort((a, b) => a.id.localeCompare(b.id));
|
|
378
|
+
} catch (error) {
|
|
379
|
+
if (isEnoent(error)) return [];
|
|
380
|
+
throw error;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
async function writeTask(dir: string, task: GjcTeamTask): Promise<void> {
|
|
384
|
+
await writeJsonFile(taskPath(dir, task.id), normalizeTask(task));
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async function findTeamDir(
|
|
388
|
+
teamName: string,
|
|
389
|
+
cwd = process.cwd(),
|
|
390
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
391
|
+
): Promise<string> {
|
|
392
|
+
const root = resolveGjcTeamStateRoot(cwd, env);
|
|
393
|
+
const exact = teamDir(root, teamName);
|
|
394
|
+
if (await readJsonFile<GjcTeamConfig>(path.join(exact, "config.json"))) return exact;
|
|
395
|
+
const candidates = await listGjcTeams(cwd, env);
|
|
396
|
+
const input = sanitizeName(teamName);
|
|
397
|
+
const matches = candidates.filter(
|
|
398
|
+
candidate => candidate.team_name === input || sanitizeName(candidate.display_name) === input,
|
|
399
|
+
);
|
|
400
|
+
if (matches.length === 1) return matches[0].state_dir;
|
|
401
|
+
if (matches.length > 1)
|
|
402
|
+
throw new Error(`ambiguous_team_name:${teamName}:${matches.map(match => match.team_name).join(",")}`);
|
|
403
|
+
throw new Error(`team_not_found:${teamName}`);
|
|
404
|
+
}
|
|
405
|
+
function buildWorkers(count: number, agentType: string, stateRoot?: string): GjcTeamWorker[] {
|
|
406
|
+
return Array.from({ length: count }, (_, index) => {
|
|
407
|
+
const id = `worker-${index + 1}`;
|
|
408
|
+
return {
|
|
409
|
+
id,
|
|
410
|
+
name: id,
|
|
411
|
+
index: index + 1,
|
|
412
|
+
agent_type: agentType,
|
|
413
|
+
role: agentType,
|
|
414
|
+
status: "starting",
|
|
415
|
+
last_heartbeat: now(),
|
|
416
|
+
assigned_tasks: [],
|
|
417
|
+
team_state_root: stateRoot,
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function sanitizePathToken(value: string): string {
|
|
422
|
+
return sanitizeName(value) || "default";
|
|
423
|
+
}
|
|
424
|
+
function runGitResult(cwd: string, args: string[]): GitResult {
|
|
425
|
+
const result = Bun.spawnSync(["git", ...args], { cwd, stdout: "pipe", stderr: "pipe" });
|
|
426
|
+
return {
|
|
427
|
+
ok: result.exitCode === 0,
|
|
428
|
+
stdout: result.stdout.toString().trim(),
|
|
429
|
+
stderr: result.stderr.toString().trim(),
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function runGit(cwd: string, args: string[]): string {
|
|
433
|
+
const result = runGitResult(cwd, args);
|
|
434
|
+
if (result.ok) return result.stdout;
|
|
435
|
+
throw new Error(result.stderr || `git ${args.join(" ")} failed`);
|
|
436
|
+
}
|
|
437
|
+
function tryRunGit(cwd: string, args: string[]): string | null {
|
|
438
|
+
const result = runGitResult(cwd, args);
|
|
439
|
+
return result.ok ? result.stdout : null;
|
|
440
|
+
}
|
|
441
|
+
function isGitRepository(cwd: string): boolean {
|
|
442
|
+
return tryRunGit(cwd, ["rev-parse", "--show-toplevel"]) != null;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function parseWorktreeMode(args: string[]): { mode: GjcTeamWorktreeMode; remainingArgs: string[] } {
|
|
446
|
+
let mode: GjcTeamWorktreeMode = { enabled: false };
|
|
447
|
+
const remainingArgs: string[] = [];
|
|
448
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
449
|
+
const arg = args[index] ?? "";
|
|
450
|
+
if (arg === "--worktree" || arg === "-w") {
|
|
451
|
+
const next = args[index + 1];
|
|
452
|
+
if (typeof next === "string" && next.length > 0 && !next.startsWith("-") && !next.includes(":")) {
|
|
453
|
+
mode = { enabled: true, detached: false, name: next };
|
|
454
|
+
index += 1;
|
|
455
|
+
} else mode = { enabled: true, detached: true, name: null };
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
if (arg.startsWith("--worktree=")) {
|
|
459
|
+
const name = arg.slice("--worktree=".length).trim();
|
|
460
|
+
mode = name ? { enabled: true, detached: false, name } : { enabled: true, detached: true, name: null };
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
if (arg.startsWith("-w=") || (arg.startsWith("-w") && arg.length > 2)) {
|
|
464
|
+
const name = arg.startsWith("-w=") ? arg.slice("-w=".length).trim() : arg.slice(2).trim();
|
|
465
|
+
mode = name ? { enabled: true, detached: false, name } : { enabled: true, detached: true, name: null };
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
remainingArgs.push(arg);
|
|
469
|
+
}
|
|
470
|
+
return { mode, remainingArgs };
|
|
471
|
+
}
|
|
472
|
+
function resolveDefaultWorktreeMode(mode?: GjcTeamWorktreeMode): GjcTeamWorktreeMode {
|
|
473
|
+
return mode?.enabled ? mode : { enabled: true, detached: true, name: null };
|
|
474
|
+
}
|
|
475
|
+
function branchExists(repoRoot: string, branchName: string): boolean {
|
|
476
|
+
return (
|
|
477
|
+
Bun.spawnSync(["git", "show-ref", "--verify", "--quiet", `refs/heads/${branchName}`], {
|
|
478
|
+
cwd: repoRoot,
|
|
479
|
+
stdout: "ignore",
|
|
480
|
+
stderr: "ignore",
|
|
481
|
+
}).exitCode === 0
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
function worktreeIsDirty(worktreePath: string): boolean {
|
|
485
|
+
return runGit(worktreePath, ["status", "--porcelain"]).trim().length > 0;
|
|
486
|
+
}
|
|
487
|
+
function worktreeHead(worktreePath: string): string {
|
|
488
|
+
return runGit(worktreePath, ["rev-parse", "HEAD"]);
|
|
489
|
+
}
|
|
490
|
+
async function pathExists(filePath: string): Promise<boolean> {
|
|
491
|
+
try {
|
|
492
|
+
await fs.access(filePath);
|
|
493
|
+
return true;
|
|
494
|
+
} catch (error) {
|
|
495
|
+
if (isEnoent(error)) return false;
|
|
496
|
+
throw error;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function findWorktreePath(repoRoot: string, worktreePath: string): string | null {
|
|
500
|
+
const raw = runGit(repoRoot, ["worktree", "list", "--porcelain"]);
|
|
501
|
+
const resolved = path.resolve(worktreePath);
|
|
502
|
+
for (const line of raw.split(/\r?\n/))
|
|
503
|
+
if (line.startsWith("worktree ") && path.resolve(line.slice("worktree ".length)) === resolved) return resolved;
|
|
504
|
+
return null;
|
|
505
|
+
}
|
|
506
|
+
async function ensureWorkerWorktree(
|
|
507
|
+
cwd: string,
|
|
508
|
+
dir: string,
|
|
509
|
+
teamName: string,
|
|
510
|
+
worker: GjcTeamWorker,
|
|
511
|
+
mode: GjcTeamWorktreeMode,
|
|
512
|
+
): Promise<GjcTeamWorker> {
|
|
513
|
+
if (!mode.enabled) return worker;
|
|
514
|
+
if (!isGitRepository(cwd)) throw new Error(`team_worktree_requires_git_repo:${cwd}`);
|
|
515
|
+
const repoRoot = runGit(cwd, ["rev-parse", "--show-toplevel"]);
|
|
516
|
+
const baseRef = runGit(repoRoot, ["rev-parse", "HEAD"]);
|
|
517
|
+
const worktreePath = path.join(dir, "worktrees", worker.id);
|
|
518
|
+
const existing = findWorktreePath(repoRoot, worktreePath);
|
|
519
|
+
let created = false;
|
|
520
|
+
const branchName = mode.detached
|
|
521
|
+
? null
|
|
522
|
+
: `${mode.name}/${sanitizePathToken(teamName)}/${sanitizePathToken(worker.id)}`;
|
|
523
|
+
if (existing) {
|
|
524
|
+
if (worktreeIsDirty(worktreePath)) throw new Error(`worktree_dirty:${worktreePath}`);
|
|
525
|
+
if (mode.detached && worktreeHead(worktreePath) !== baseRef) throw new Error(`worktree_stale:${worktreePath}`);
|
|
526
|
+
} else {
|
|
527
|
+
if (await pathExists(worktreePath)) throw new Error(`worktree_path_conflict:${worktreePath}`);
|
|
528
|
+
await fs.mkdir(path.dirname(worktreePath), { recursive: true });
|
|
529
|
+
const args = mode.detached
|
|
530
|
+
? ["worktree", "add", "--detach", worktreePath, baseRef]
|
|
531
|
+
: branchExists(repoRoot, branchName ?? "")
|
|
532
|
+
? ["worktree", "add", worktreePath, branchName ?? ""]
|
|
533
|
+
: ["worktree", "add", "-b", branchName ?? "", worktreePath, baseRef];
|
|
534
|
+
runGit(repoRoot, args);
|
|
535
|
+
created = true;
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
...worker,
|
|
539
|
+
worktree_repo_root: repoRoot,
|
|
540
|
+
worktree_path: path.resolve(worktreePath),
|
|
541
|
+
worktree_branch: branchName,
|
|
542
|
+
worktree_detached: mode.detached,
|
|
543
|
+
worktree_created: created,
|
|
544
|
+
worktree_base_ref: baseRef,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export function resolveGjcTmuxCommand(env: NodeJS.ProcessEnv = process.env): string {
|
|
549
|
+
return env.GJC_TEAM_TMUX_COMMAND?.trim() || "tmux";
|
|
550
|
+
}
|
|
551
|
+
function readCurrentTmuxLeaderContext(tmuxCommand: string, env: NodeJS.ProcessEnv): GjcTmuxLeaderContext {
|
|
552
|
+
const paneTarget = env.TMUX_PANE?.trim();
|
|
553
|
+
const args = paneTarget
|
|
554
|
+
? ["display-message", "-p", "-t", paneTarget, "#S:#I #{pane_id}"]
|
|
555
|
+
: ["display-message", "-p", "#S:#I #{pane_id}"];
|
|
556
|
+
const result = Bun.spawnSync([tmuxCommand, ...args], { stdout: "pipe", stderr: "pipe" });
|
|
557
|
+
if (result.exitCode !== 0) throw new Error(result.stderr.toString().trim() || "team_requires_current_tmux_context");
|
|
558
|
+
const [sessionAndWindow = "", leaderPaneId = ""] = result.stdout.toString().trim().split(/\s+/);
|
|
559
|
+
const [sessionName = "", windowIndex = ""] = sessionAndWindow.split(":");
|
|
560
|
+
if (!sessionName || !windowIndex || !leaderPaneId.startsWith("%"))
|
|
561
|
+
throw new Error(`invalid_tmux_context:${result.stdout.toString().trim()}`);
|
|
562
|
+
return { sessionName, windowIndex, leaderPaneId, target: `${sessionName}:${windowIndex}` };
|
|
563
|
+
}
|
|
564
|
+
export function resolveGjcWorkerCommand(cwd = process.cwd(), env: NodeJS.ProcessEnv = process.env): string {
|
|
565
|
+
const explicit = env.GJC_TEAM_WORKER_COMMAND?.trim();
|
|
566
|
+
if (explicit) return explicit;
|
|
567
|
+
const entrypoint = process.argv[1];
|
|
568
|
+
if (entrypoint?.endsWith(".ts"))
|
|
569
|
+
return `${shellQuote(process.execPath)} ${shellQuote(path.resolve(cwd, entrypoint))}`;
|
|
570
|
+
if (entrypoint && path.basename(entrypoint).startsWith("gjc")) return shellQuote(path.resolve(cwd, entrypoint));
|
|
571
|
+
return "gjc";
|
|
572
|
+
}
|
|
573
|
+
function buildWorkerCommand(config: GjcTeamConfig, worker: GjcTeamWorker): string {
|
|
574
|
+
const workspace = worker.worktree_path
|
|
575
|
+
? `Worker worktree: ${worker.worktree_path}.`
|
|
576
|
+
: `Worker cwd: ${config.leader.cwd}.`;
|
|
577
|
+
const prompt = [
|
|
578
|
+
`You are ${worker.id} in gjc team ${config.team_name}.`,
|
|
579
|
+
`Team state root: ${config.state_root}.`,
|
|
580
|
+
workspace,
|
|
581
|
+
`Task: ${config.task}`,
|
|
582
|
+
`Use gjc team api claim-task/transition-task-status with this worker id, record evidence, and do not mutate leader-owned goal state.`,
|
|
583
|
+
].join("\n");
|
|
584
|
+
const env = [
|
|
585
|
+
`GJC_TEAM_WORKER=${shellQuote(`${config.team_name}/${worker.id}`)}`,
|
|
586
|
+
`GJC_TEAM_INTERNAL_WORKER=${shellQuote(`${config.team_name}/${worker.id}`)}`,
|
|
587
|
+
`GJC_TEAM_NAME=${shellQuote(config.team_name)}`,
|
|
588
|
+
`GJC_TEAM_WORKER_ID=${shellQuote(worker.id)}`,
|
|
589
|
+
`GJC_TEAM_STATE_ROOT=${shellQuote(config.state_root)}`,
|
|
590
|
+
`GJC_TEAM_LEADER_CWD=${shellQuote(config.leader.cwd)}`,
|
|
591
|
+
`GJC_TEAM_DISPLAY_NAME=${shellQuote(config.display_name)}`,
|
|
592
|
+
...(worker.worktree_path ? [`GJC_TEAM_WORKTREE_PATH=${shellQuote(worker.worktree_path)}`] : []),
|
|
593
|
+
];
|
|
594
|
+
return `${env.join(" ")} ${config.worker_command} ${shellQuote(prompt)}`;
|
|
595
|
+
}
|
|
596
|
+
function buildInitialTasks(task: string, workers: GjcTeamWorker[]): GjcTeamTask[] {
|
|
597
|
+
return workers.map(worker => ({
|
|
598
|
+
id: `task-${worker.index}`,
|
|
599
|
+
subject: `Execute team brief (${worker.id})`,
|
|
600
|
+
description: task,
|
|
601
|
+
title: `Execute team brief (${worker.id})`,
|
|
602
|
+
objective: task,
|
|
603
|
+
status: "pending",
|
|
604
|
+
owner: worker.id,
|
|
605
|
+
version: 1,
|
|
606
|
+
created_at: now(),
|
|
607
|
+
updated_at: now(),
|
|
608
|
+
}));
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
async function startTmuxSession(config: GjcTeamConfig, dir: string, dryRun: boolean): Promise<GjcTeamWorker[]> {
|
|
612
|
+
if (dryRun) return config.workers.map(worker => ({ ...worker, pane_id: `%dry-run-${worker.id}` }));
|
|
613
|
+
const rollbackPaneIds: string[] = [];
|
|
614
|
+
try {
|
|
615
|
+
const workers: GjcTeamWorker[] = [];
|
|
616
|
+
let rightStackRootPaneId: string | null = null;
|
|
617
|
+
for (const worker of config.workers) {
|
|
618
|
+
const splitDirection: string = worker.index === 1 ? "-h" : "-v";
|
|
619
|
+
const splitTarget: string =
|
|
620
|
+
worker.index === 1 ? config.leader.pane_id : (rightStackRootPaneId ?? config.leader.pane_id);
|
|
621
|
+
const split: Bun.SyncSubprocess<"pipe", "pipe"> = Bun.spawnSync(
|
|
622
|
+
[
|
|
623
|
+
config.tmux_command,
|
|
624
|
+
"split-window",
|
|
625
|
+
splitDirection,
|
|
626
|
+
"-t",
|
|
627
|
+
splitTarget,
|
|
628
|
+
"-d",
|
|
629
|
+
"-P",
|
|
630
|
+
"-F",
|
|
631
|
+
"#{pane_id}",
|
|
632
|
+
"-c",
|
|
633
|
+
worker.worktree_path ?? config.leader.cwd,
|
|
634
|
+
buildWorkerCommand(config, worker),
|
|
635
|
+
],
|
|
636
|
+
{ stdout: "pipe", stderr: "pipe" },
|
|
637
|
+
);
|
|
638
|
+
if (split.exitCode !== 0)
|
|
639
|
+
throw new Error(split.stderr.toString().trim() || `tmux_split_failed:${config.tmux_target}:${worker.id}`);
|
|
640
|
+
const paneId: string = split.stdout.toString().trim().split(/\r?\n/)[0]?.trim() ?? "";
|
|
641
|
+
if (!paneId.startsWith("%")) throw new Error(`tmux_split_missing_pane:${config.tmux_target}:${worker.id}`);
|
|
642
|
+
rollbackPaneIds.push(paneId);
|
|
643
|
+
if (worker.index === 1) rightStackRootPaneId = paneId;
|
|
644
|
+
workers.push({ ...worker, pane_id: paneId });
|
|
645
|
+
}
|
|
646
|
+
Bun.spawnSync([config.tmux_command, "select-layout", "-t", config.tmux_target, "main-vertical"], {
|
|
647
|
+
stdout: "ignore",
|
|
648
|
+
stderr: "ignore",
|
|
649
|
+
});
|
|
650
|
+
const widthResult = Bun.spawnSync(
|
|
651
|
+
[config.tmux_command, "display-message", "-p", "-t", config.tmux_target, "#{window_width}"],
|
|
652
|
+
{ stdout: "pipe", stderr: "ignore" },
|
|
653
|
+
);
|
|
654
|
+
const width = Number.parseInt(widthResult.stdout.toString().trim(), 10);
|
|
655
|
+
if (Number.isFinite(width) && width >= 40) {
|
|
656
|
+
Bun.spawnSync(
|
|
657
|
+
[
|
|
658
|
+
config.tmux_command,
|
|
659
|
+
"set-window-option",
|
|
660
|
+
"-t",
|
|
661
|
+
config.tmux_target,
|
|
662
|
+
"main-pane-width",
|
|
663
|
+
String(Math.floor(width / 2)),
|
|
664
|
+
],
|
|
665
|
+
{ stdout: "ignore", stderr: "ignore" },
|
|
666
|
+
);
|
|
667
|
+
Bun.spawnSync([config.tmux_command, "select-layout", "-t", config.tmux_target, "main-vertical"], {
|
|
668
|
+
stdout: "ignore",
|
|
669
|
+
stderr: "ignore",
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
await appendTelemetry(dir, {
|
|
673
|
+
type: "tmux_started",
|
|
674
|
+
message: "Started gjc team worker panes in current tmux window",
|
|
675
|
+
data: { tmux_target: config.tmux_target, panes: workers.map(worker => worker.pane_id).filter(Boolean) },
|
|
676
|
+
});
|
|
677
|
+
return workers;
|
|
678
|
+
} catch (error) {
|
|
679
|
+
for (const paneId of rollbackPaneIds)
|
|
680
|
+
Bun.spawnSync([config.tmux_command, "kill-pane", "-t", paneId], { stdout: "ignore", stderr: "ignore" });
|
|
681
|
+
throw error;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
function paneBelongsToTeamTarget(config: GjcTeamConfig, paneId: string): boolean {
|
|
685
|
+
if (paneId === config.leader.pane_id) return false;
|
|
686
|
+
const result = Bun.spawnSync([config.tmux_command, "display-message", "-p", "-t", paneId, "#S:#I #{pane_id}"], {
|
|
687
|
+
stdout: "pipe",
|
|
688
|
+
stderr: "ignore",
|
|
689
|
+
});
|
|
690
|
+
if (result.exitCode !== 0) return false;
|
|
691
|
+
const [target = "", detectedPaneId = ""] = result.stdout.toString().trim().split(/\s+/);
|
|
692
|
+
return target === config.tmux_target && detectedPaneId === paneId;
|
|
693
|
+
}
|
|
694
|
+
function killWorkerPanes(config: GjcTeamConfig): void {
|
|
695
|
+
for (const worker of config.workers)
|
|
696
|
+
if (worker.pane_id?.startsWith("%") && paneBelongsToTeamTarget(config, worker.pane_id))
|
|
697
|
+
Bun.spawnSync([config.tmux_command, "kill-pane", "-t", worker.pane_id], {
|
|
698
|
+
stdout: "ignore",
|
|
699
|
+
stderr: "ignore",
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
async function rollbackCreatedWorktrees(workers: GjcTeamWorker[]): Promise<void> {
|
|
703
|
+
for (const worker of workers.filter(worker => worker.worktree_created).reverse())
|
|
704
|
+
if (worker.worktree_repo_root && worker.worktree_path)
|
|
705
|
+
Bun.spawnSync(["git", "worktree", "remove", "--force", worker.worktree_path], {
|
|
706
|
+
cwd: worker.worktree_repo_root,
|
|
707
|
+
stdout: "ignore",
|
|
708
|
+
stderr: "ignore",
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
async function removeCleanCreatedWorktrees(workers: GjcTeamWorker[]): Promise<void> {
|
|
712
|
+
for (const worker of workers.filter(worker => worker.worktree_created).reverse())
|
|
713
|
+
if (worker.worktree_repo_root && worker.worktree_path && !worktreeIsDirty(worker.worktree_path))
|
|
714
|
+
Bun.spawnSync(["git", "worktree", "remove", worker.worktree_path], {
|
|
715
|
+
cwd: worker.worktree_repo_root,
|
|
716
|
+
stdout: "ignore",
|
|
717
|
+
stderr: "ignore",
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function monitorSnapshotPath(dir: string): string {
|
|
722
|
+
return path.join(dir, "monitor-snapshot.json");
|
|
723
|
+
}
|
|
724
|
+
function integrationReportPath(dir: string): string {
|
|
725
|
+
return path.join(dir, "integration-report.md");
|
|
726
|
+
}
|
|
727
|
+
function commitHygieneLedgerPath(config: GjcTeamConfig): string {
|
|
728
|
+
return path.join(config.leader_cwd, ".gjc", "reports", "team-commit-hygiene", `${config.team_name}.ledger.json`);
|
|
729
|
+
}
|
|
730
|
+
function integrationNowState(
|
|
731
|
+
status: GjcTeamIntegrationStatus,
|
|
732
|
+
): Pick<GjcTeamWorkerIntegrationState, "status" | "updated_at"> {
|
|
733
|
+
return { status, updated_at: now() };
|
|
734
|
+
}
|
|
735
|
+
async function appendIntegrationReport(
|
|
736
|
+
dir: string,
|
|
737
|
+
entry: { worker: string; operation: "merge" | "cherry-pick" | "rebase"; files: string[]; detail: string },
|
|
738
|
+
): Promise<void> {
|
|
739
|
+
const line = `- [${now()}] ${entry.worker}: ${entry.operation}; files=${entry.files.join(",") || "unknown"}; ${entry.detail}\n`;
|
|
740
|
+
await fs.mkdir(path.dirname(integrationReportPath(dir)), { recursive: true });
|
|
741
|
+
if (await pathExists(integrationReportPath(dir))) await fs.appendFile(integrationReportPath(dir), line, "utf-8");
|
|
742
|
+
else await Bun.write(integrationReportPath(dir), `# Integration Report\n\n${line}`);
|
|
743
|
+
}
|
|
744
|
+
async function appendCommitHygieneEntries(config: GjcTeamConfig, entries: GjcTeamCommitHygieneEntry[]): Promise<void> {
|
|
745
|
+
if (entries.length === 0) return;
|
|
746
|
+
const ledgerPath = commitHygieneLedgerPath(config);
|
|
747
|
+
const existing = (await readJsonFile<{ version: number; entries: GjcTeamCommitHygieneEntry[] }>(ledgerPath)) ?? {
|
|
748
|
+
version: 1,
|
|
749
|
+
entries: [],
|
|
750
|
+
};
|
|
751
|
+
await writeJsonFile(ledgerPath, { version: 1, entries: [...existing.entries, ...entries] });
|
|
752
|
+
}
|
|
753
|
+
function resolveHead(cwd: string): string | null {
|
|
754
|
+
return tryRunGit(cwd, ["rev-parse", "HEAD"]);
|
|
755
|
+
}
|
|
756
|
+
function isAncestor(cwd: string, ancestor: string, descendant: string): boolean {
|
|
757
|
+
return runGitResult(cwd, ["merge-base", "--is-ancestor", ancestor, descendant]).ok;
|
|
758
|
+
}
|
|
759
|
+
function listCommitRange(cwd: string, baseRef: string, headRef: string): string[] {
|
|
760
|
+
const result = runGitResult(cwd, ["rev-list", "--reverse", `${baseRef}..${headRef}`]);
|
|
761
|
+
if (!result.ok || !result.stdout) return [];
|
|
762
|
+
return result.stdout
|
|
763
|
+
.split(/\r?\n/)
|
|
764
|
+
.map(line => line.trim())
|
|
765
|
+
.filter(Boolean);
|
|
766
|
+
}
|
|
767
|
+
function listConflictFiles(cwd: string): string[] {
|
|
768
|
+
const result = runGitResult(cwd, ["diff", "--name-only", "--diff-filter=U"]);
|
|
769
|
+
if (!result.ok || !result.stdout) return [];
|
|
770
|
+
return result.stdout
|
|
771
|
+
.split(/\r?\n/)
|
|
772
|
+
.map(line => line.trim())
|
|
773
|
+
.filter(Boolean);
|
|
774
|
+
}
|
|
775
|
+
async function appendIntegrationEvent(
|
|
776
|
+
dir: string,
|
|
777
|
+
type: string,
|
|
778
|
+
worker: GjcTeamWorker,
|
|
779
|
+
data: Record<string, unknown>,
|
|
780
|
+
): Promise<void> {
|
|
781
|
+
await appendEvent(dir, {
|
|
782
|
+
type,
|
|
783
|
+
worker: worker.id,
|
|
784
|
+
task_id: worker.assigned_tasks[0],
|
|
785
|
+
message: typeof data.summary === "string" ? data.summary : type,
|
|
786
|
+
data,
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
async function notifyLeader(
|
|
790
|
+
config: GjcTeamConfig,
|
|
791
|
+
worker: GjcTeamWorker,
|
|
792
|
+
body: string,
|
|
793
|
+
cwd: string,
|
|
794
|
+
env: NodeJS.ProcessEnv,
|
|
795
|
+
): Promise<void> {
|
|
796
|
+
await sendGjcTeamMessage(config.team_name, worker.id, "leader-fixed", body, cwd, env).catch(() => undefined);
|
|
797
|
+
}
|
|
798
|
+
function autoCommitDirtyWorker(worker: GjcTeamWorker): { committed: boolean; commit: string | null } {
|
|
799
|
+
if (!worker.worktree_path) return { committed: false, commit: null };
|
|
800
|
+
const status = runGitResult(worker.worktree_path, ["status", "--porcelain"]);
|
|
801
|
+
if (!status.ok || !status.stdout.trim()) return { committed: false, commit: null };
|
|
802
|
+
if (!runGitResult(worker.worktree_path, ["add", "-A"]).ok) return { committed: false, commit: null };
|
|
803
|
+
const message = `gjc(team): auto-checkpoint ${worker.id} [${worker.assigned_tasks[0] ?? "unknown"}]`;
|
|
804
|
+
if (!runGitResult(worker.worktree_path, ["commit", "--no-verify", "-m", message]).ok)
|
|
805
|
+
return { committed: false, commit: null };
|
|
806
|
+
return { committed: true, commit: resolveHead(worker.worktree_path) };
|
|
807
|
+
}
|
|
808
|
+
function workerMergeRef(worker: GjcTeamWorker, workerHead: string): string {
|
|
809
|
+
if (!worker.worktree_path) return workerHead;
|
|
810
|
+
const branch = tryRunGit(worker.worktree_path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
811
|
+
return !branch || branch === "HEAD" ? workerHead : branch;
|
|
812
|
+
}
|
|
813
|
+
async function integrateGjcWorkerCommits(
|
|
814
|
+
config: GjcTeamConfig,
|
|
815
|
+
dir: string,
|
|
816
|
+
previous: GjcTeamMonitorSnapshot | null,
|
|
817
|
+
cwd: string,
|
|
818
|
+
env: NodeJS.ProcessEnv,
|
|
819
|
+
): Promise<Record<string, GjcTeamWorkerIntegrationState>> {
|
|
820
|
+
const integrationByWorker: Record<string, GjcTeamWorkerIntegrationState> = {
|
|
821
|
+
...(previous?.integration_by_worker ?? {}),
|
|
822
|
+
};
|
|
823
|
+
const hygieneEntries: GjcTeamCommitHygieneEntry[] = [];
|
|
824
|
+
const leaderCwd = config.leader_cwd || cwd;
|
|
825
|
+
const cycleLeaderHead = resolveHead(leaderCwd);
|
|
826
|
+
for (const worker of config.workers) {
|
|
827
|
+
if (!worker.worktree_path || !worker.worktree_repo_root || !(await pathExists(worker.worktree_path))) continue;
|
|
828
|
+
const { committed, commit } = autoCommitDirtyWorker(worker);
|
|
829
|
+
if (!committed) continue;
|
|
830
|
+
await appendIntegrationEvent(dir, "worker_auto_commit", worker, {
|
|
831
|
+
worker_name: worker.id,
|
|
832
|
+
commit_hash: commit,
|
|
833
|
+
worktree_path: worker.worktree_path,
|
|
834
|
+
summary: `auto-committed dirty worktree for ${worker.id}`,
|
|
835
|
+
});
|
|
836
|
+
hygieneEntries.push({
|
|
837
|
+
recorded_at: now(),
|
|
838
|
+
operation: "auto_checkpoint",
|
|
839
|
+
worker_name: worker.id,
|
|
840
|
+
task_id: worker.assigned_tasks[0],
|
|
841
|
+
status: "applied",
|
|
842
|
+
operational_commit: commit,
|
|
843
|
+
worktree_path: worker.worktree_path,
|
|
844
|
+
detail: "Dirty worker worktree checkpointed before integration.",
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
for (const worker of config.workers) {
|
|
849
|
+
if (!worker.worktree_path || !worker.worktree_repo_root || !(await pathExists(worker.worktree_path))) continue;
|
|
850
|
+
const leaderHead = resolveHead(leaderCwd);
|
|
851
|
+
const workerHead = resolveHead(worker.worktree_path);
|
|
852
|
+
const state: GjcTeamWorkerIntegrationState = {
|
|
853
|
+
...(integrationByWorker[worker.id] ?? {}),
|
|
854
|
+
last_leader_head: leaderHead ?? integrationByWorker[worker.id]?.last_leader_head,
|
|
855
|
+
};
|
|
856
|
+
if (!leaderHead || !workerHead) {
|
|
857
|
+
integrationByWorker[worker.id] = state;
|
|
858
|
+
continue;
|
|
859
|
+
}
|
|
860
|
+
state.last_seen_head = workerHead;
|
|
861
|
+
if (isAncestor(leaderCwd, workerHead, "HEAD")) {
|
|
862
|
+
integrationByWorker[worker.id] = {
|
|
863
|
+
...state,
|
|
864
|
+
last_integrated_head: workerHead,
|
|
865
|
+
...integrationNowState("idle"),
|
|
866
|
+
};
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
if (isAncestor(worker.worktree_path, leaderHead, workerHead)) {
|
|
870
|
+
const mergeRef = workerMergeRef(worker, workerHead);
|
|
871
|
+
const merge = runGitResult(leaderCwd, [
|
|
872
|
+
"merge",
|
|
873
|
+
"--no-ff",
|
|
874
|
+
"-X",
|
|
875
|
+
"theirs",
|
|
876
|
+
"-m",
|
|
877
|
+
`gjc(team): merge ${worker.id}`,
|
|
878
|
+
mergeRef,
|
|
879
|
+
]);
|
|
880
|
+
if (merge.ok) {
|
|
881
|
+
const newLeaderHead = resolveHead(leaderCwd);
|
|
882
|
+
if (newLeaderHead && newLeaderHead !== leaderHead && isAncestor(leaderCwd, workerHead, "HEAD")) {
|
|
883
|
+
integrationByWorker[worker.id] = {
|
|
884
|
+
...state,
|
|
885
|
+
last_integrated_head: workerHead,
|
|
886
|
+
last_leader_head: newLeaderHead,
|
|
887
|
+
conflict_commit: undefined,
|
|
888
|
+
conflict_files: undefined,
|
|
889
|
+
...integrationNowState("integrated"),
|
|
890
|
+
};
|
|
891
|
+
await appendIntegrationEvent(dir, "worker_merge_applied", worker, {
|
|
892
|
+
worker_name: worker.id,
|
|
893
|
+
worker_head: workerHead,
|
|
894
|
+
leader_head_before: leaderHead,
|
|
895
|
+
leader_head_after: newLeaderHead,
|
|
896
|
+
worktree_path: worker.worktree_path,
|
|
897
|
+
summary: `merged ${worker.id} into leader`,
|
|
898
|
+
});
|
|
899
|
+
await notifyLeader(
|
|
900
|
+
config,
|
|
901
|
+
worker,
|
|
902
|
+
`INTEGRATED: merged ${worker.id} ${workerHead.slice(0, 12)} into leader.`,
|
|
903
|
+
cwd,
|
|
904
|
+
env,
|
|
905
|
+
);
|
|
906
|
+
hygieneEntries.push({
|
|
907
|
+
recorded_at: now(),
|
|
908
|
+
operation: "integration_merge",
|
|
909
|
+
worker_name: worker.id,
|
|
910
|
+
task_id: worker.assigned_tasks[0],
|
|
911
|
+
status: "applied",
|
|
912
|
+
operational_commit: newLeaderHead,
|
|
913
|
+
source_commit: workerHead,
|
|
914
|
+
leader_head_before: leaderHead,
|
|
915
|
+
leader_head_after: newLeaderHead,
|
|
916
|
+
worktree_path: worker.worktree_path,
|
|
917
|
+
detail: "Leader created a runtime merge commit to integrate worker history.",
|
|
918
|
+
});
|
|
919
|
+
} else {
|
|
920
|
+
integrationByWorker[worker.id] = { ...state, ...integrationNowState("integration_failed") };
|
|
921
|
+
hygieneEntries.push({
|
|
922
|
+
recorded_at: now(),
|
|
923
|
+
operation: "integration_merge",
|
|
924
|
+
worker_name: worker.id,
|
|
925
|
+
task_id: worker.assigned_tasks[0],
|
|
926
|
+
status: "failed",
|
|
927
|
+
source_commit: workerHead,
|
|
928
|
+
leader_head_before: leaderHead,
|
|
929
|
+
leader_head_after: newLeaderHead,
|
|
930
|
+
worktree_path: worker.worktree_path,
|
|
931
|
+
detail: "Runtime merge succeeded but did not advance the leader head.",
|
|
932
|
+
});
|
|
933
|
+
await notifyLeader(
|
|
934
|
+
config,
|
|
935
|
+
worker,
|
|
936
|
+
`INTEGRATION FAILED: merge for ${worker.id} did not advance leader HEAD.`,
|
|
937
|
+
cwd,
|
|
938
|
+
env,
|
|
939
|
+
);
|
|
940
|
+
}
|
|
941
|
+
} else {
|
|
942
|
+
const conflictFiles = listConflictFiles(leaderCwd);
|
|
943
|
+
runGitResult(leaderCwd, ["merge", "--abort"]);
|
|
944
|
+
integrationByWorker[worker.id] = {
|
|
945
|
+
...state,
|
|
946
|
+
conflict_commit: workerHead,
|
|
947
|
+
conflict_files: conflictFiles,
|
|
948
|
+
...integrationNowState("merge_conflict"),
|
|
949
|
+
};
|
|
950
|
+
await appendIntegrationEvent(dir, "worker_merge_conflict", worker, {
|
|
951
|
+
worker_name: worker.id,
|
|
952
|
+
worker_head: workerHead,
|
|
953
|
+
conflict_files: conflictFiles,
|
|
954
|
+
stderr: merge.stderr || merge.stdout,
|
|
955
|
+
summary: `merge conflict for ${worker.id}`,
|
|
956
|
+
});
|
|
957
|
+
await appendIntegrationReport(dir, {
|
|
958
|
+
worker: worker.id,
|
|
959
|
+
operation: "merge",
|
|
960
|
+
files: conflictFiles,
|
|
961
|
+
detail: `merge --no-ff -X theirs failed and was aborted: ${(merge.stderr || merge.stdout).slice(0, 200)}`,
|
|
962
|
+
});
|
|
963
|
+
await notifyLeader(
|
|
964
|
+
config,
|
|
965
|
+
worker,
|
|
966
|
+
`CONFLICT: merge failed for ${worker.id}; files: ${conflictFiles.join(",") || "unknown"}.`,
|
|
967
|
+
cwd,
|
|
968
|
+
env,
|
|
969
|
+
);
|
|
970
|
+
hygieneEntries.push({
|
|
971
|
+
recorded_at: now(),
|
|
972
|
+
operation: "integration_merge",
|
|
973
|
+
worker_name: worker.id,
|
|
974
|
+
task_id: worker.assigned_tasks[0],
|
|
975
|
+
status: "conflict",
|
|
976
|
+
source_commit: workerHead,
|
|
977
|
+
leader_head_before: leaderHead,
|
|
978
|
+
leader_head_after: resolveHead(leaderCwd),
|
|
979
|
+
worktree_path: worker.worktree_path,
|
|
980
|
+
detail: `Runtime merge failed and was aborted: ${(merge.stderr || merge.stdout).slice(0, 200)}`,
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
continue;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const baseline =
|
|
987
|
+
state.last_integrated_head &&
|
|
988
|
+
tryRunGit(worker.worktree_path, ["rev-parse", "--verify", state.last_integrated_head])
|
|
989
|
+
? state.last_integrated_head
|
|
990
|
+
: leaderHead;
|
|
991
|
+
const commits = listCommitRange(worker.worktree_path, baseline, workerHead);
|
|
992
|
+
for (const commit of commits) {
|
|
993
|
+
const pick = runGitResult(leaderCwd, ["cherry-pick", "--allow-empty", "-X", "theirs", commit]);
|
|
994
|
+
if (!pick.ok) {
|
|
995
|
+
const conflictFiles = listConflictFiles(leaderCwd);
|
|
996
|
+
runGitResult(leaderCwd, ["cherry-pick", "--abort"]);
|
|
997
|
+
integrationByWorker[worker.id] = {
|
|
998
|
+
...state,
|
|
999
|
+
conflict_commit: commit,
|
|
1000
|
+
conflict_files: conflictFiles,
|
|
1001
|
+
...integrationNowState("cherry_pick_conflict"),
|
|
1002
|
+
};
|
|
1003
|
+
await appendIntegrationEvent(dir, "worker_cherry_pick_conflict", worker, {
|
|
1004
|
+
worker_name: worker.id,
|
|
1005
|
+
commit,
|
|
1006
|
+
conflict_files: conflictFiles,
|
|
1007
|
+
stderr: pick.stderr || pick.stdout,
|
|
1008
|
+
summary: `cherry-pick conflict for ${worker.id}`,
|
|
1009
|
+
});
|
|
1010
|
+
await appendIntegrationReport(dir, {
|
|
1011
|
+
worker: worker.id,
|
|
1012
|
+
operation: "cherry-pick",
|
|
1013
|
+
files: conflictFiles,
|
|
1014
|
+
detail: `cherry-pick -X theirs failed and was aborted: ${(pick.stderr || pick.stdout).slice(0, 200)}`,
|
|
1015
|
+
});
|
|
1016
|
+
await notifyLeader(
|
|
1017
|
+
config,
|
|
1018
|
+
worker,
|
|
1019
|
+
`CONFLICT: cherry-pick failed for ${worker.id}; files: ${conflictFiles.join(",") || "unknown"}.`,
|
|
1020
|
+
cwd,
|
|
1021
|
+
env,
|
|
1022
|
+
);
|
|
1023
|
+
hygieneEntries.push({
|
|
1024
|
+
recorded_at: now(),
|
|
1025
|
+
operation: "integration_cherry_pick",
|
|
1026
|
+
worker_name: worker.id,
|
|
1027
|
+
task_id: worker.assigned_tasks[0],
|
|
1028
|
+
status: "conflict",
|
|
1029
|
+
source_commit: commit,
|
|
1030
|
+
leader_head_before: leaderHead,
|
|
1031
|
+
leader_head_after: resolveHead(leaderCwd),
|
|
1032
|
+
worktree_path: worker.worktree_path,
|
|
1033
|
+
detail: `Runtime cherry-pick failed and was aborted: ${(pick.stderr || pick.stdout).slice(0, 200)}`,
|
|
1034
|
+
});
|
|
1035
|
+
break;
|
|
1036
|
+
}
|
|
1037
|
+
const newLeaderHead = resolveHead(leaderCwd);
|
|
1038
|
+
if (!newLeaderHead || newLeaderHead === leaderHead) {
|
|
1039
|
+
integrationByWorker[worker.id] = { ...state, ...integrationNowState("integration_failed") };
|
|
1040
|
+
hygieneEntries.push({
|
|
1041
|
+
recorded_at: now(),
|
|
1042
|
+
operation: "integration_cherry_pick",
|
|
1043
|
+
worker_name: worker.id,
|
|
1044
|
+
task_id: worker.assigned_tasks[0],
|
|
1045
|
+
status: "failed",
|
|
1046
|
+
source_commit: commit,
|
|
1047
|
+
leader_head_before: leaderHead,
|
|
1048
|
+
leader_head_after: newLeaderHead,
|
|
1049
|
+
worktree_path: worker.worktree_path,
|
|
1050
|
+
detail: "Runtime cherry-pick did not advance the leader head.",
|
|
1051
|
+
});
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
1054
|
+
integrationByWorker[worker.id] = {
|
|
1055
|
+
...state,
|
|
1056
|
+
last_integrated_head: commit,
|
|
1057
|
+
last_leader_head: newLeaderHead,
|
|
1058
|
+
conflict_commit: undefined,
|
|
1059
|
+
conflict_files: undefined,
|
|
1060
|
+
...integrationNowState("integrated"),
|
|
1061
|
+
};
|
|
1062
|
+
await appendIntegrationEvent(dir, "worker_cherry_pick_applied", worker, {
|
|
1063
|
+
worker_name: worker.id,
|
|
1064
|
+
commit,
|
|
1065
|
+
leader_head_before: leaderHead,
|
|
1066
|
+
leader_head_after: newLeaderHead,
|
|
1067
|
+
worktree_path: worker.worktree_path,
|
|
1068
|
+
summary: `cherry-picked ${commit.slice(0, 12)} from ${worker.id}`,
|
|
1069
|
+
});
|
|
1070
|
+
await notifyLeader(
|
|
1071
|
+
config,
|
|
1072
|
+
worker,
|
|
1073
|
+
`INTEGRATED: cherry-picked ${commit.slice(0, 12)} from ${worker.id}.`,
|
|
1074
|
+
cwd,
|
|
1075
|
+
env,
|
|
1076
|
+
);
|
|
1077
|
+
hygieneEntries.push({
|
|
1078
|
+
recorded_at: now(),
|
|
1079
|
+
operation: "integration_cherry_pick",
|
|
1080
|
+
worker_name: worker.id,
|
|
1081
|
+
task_id: worker.assigned_tasks[0],
|
|
1082
|
+
status: "applied",
|
|
1083
|
+
operational_commit: newLeaderHead,
|
|
1084
|
+
source_commit: commit,
|
|
1085
|
+
leader_head_before: leaderHead,
|
|
1086
|
+
leader_head_after: newLeaderHead,
|
|
1087
|
+
worktree_path: worker.worktree_path,
|
|
1088
|
+
detail: "Leader cherry-picked diverged worker history.",
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
const newLeaderHead = resolveHead(leaderCwd);
|
|
1094
|
+
if (cycleLeaderHead && newLeaderHead && cycleLeaderHead !== newLeaderHead) {
|
|
1095
|
+
for (const worker of config.workers) {
|
|
1096
|
+
if (!worker.worktree_path || !(await pathExists(worker.worktree_path))) continue;
|
|
1097
|
+
const status = await readGjcWorkerStatus(config.team_name, worker.id, cwd, env);
|
|
1098
|
+
if (!["idle", "done", "failed"].includes(status.state)) {
|
|
1099
|
+
await appendIntegrationEvent(dir, "worker_cross_rebase_skipped", worker, {
|
|
1100
|
+
worker_name: worker.id,
|
|
1101
|
+
worker_state: status.state,
|
|
1102
|
+
leader_head: newLeaderHead,
|
|
1103
|
+
summary: `skipped cross-rebase for ${worker.id}`,
|
|
1104
|
+
});
|
|
1105
|
+
hygieneEntries.push({
|
|
1106
|
+
recorded_at: now(),
|
|
1107
|
+
operation: "cross_rebase",
|
|
1108
|
+
worker_name: worker.id,
|
|
1109
|
+
task_id: worker.assigned_tasks[0],
|
|
1110
|
+
status: "skipped",
|
|
1111
|
+
leader_head_after: newLeaderHead,
|
|
1112
|
+
worktree_path: worker.worktree_path,
|
|
1113
|
+
detail: `Worker state ${status.state} is not eligible for automatic cross-rebase.`,
|
|
1114
|
+
});
|
|
1115
|
+
continue;
|
|
1116
|
+
}
|
|
1117
|
+
if (worktreeIsDirty(worker.worktree_path)) {
|
|
1118
|
+
hygieneEntries.push({
|
|
1119
|
+
recorded_at: now(),
|
|
1120
|
+
operation: "cross_rebase",
|
|
1121
|
+
worker_name: worker.id,
|
|
1122
|
+
task_id: worker.assigned_tasks[0],
|
|
1123
|
+
status: "skipped",
|
|
1124
|
+
leader_head_after: newLeaderHead,
|
|
1125
|
+
worktree_path: worker.worktree_path,
|
|
1126
|
+
detail: "Worker worktree is dirty after integration; automatic cross-rebase skipped.",
|
|
1127
|
+
});
|
|
1128
|
+
continue;
|
|
1129
|
+
}
|
|
1130
|
+
const before = resolveHead(worker.worktree_path);
|
|
1131
|
+
const rebase = runGitResult(worker.worktree_path, ["rebase", "-X", "ours", newLeaderHead]);
|
|
1132
|
+
if (rebase.ok) {
|
|
1133
|
+
const after = resolveHead(worker.worktree_path);
|
|
1134
|
+
integrationByWorker[worker.id] = {
|
|
1135
|
+
...(integrationByWorker[worker.id] ?? {}),
|
|
1136
|
+
last_rebased_leader_head: newLeaderHead,
|
|
1137
|
+
conflict_commit: undefined,
|
|
1138
|
+
conflict_files: undefined,
|
|
1139
|
+
...integrationNowState("idle"),
|
|
1140
|
+
};
|
|
1141
|
+
await appendIntegrationEvent(dir, "worker_cross_rebase_applied", worker, {
|
|
1142
|
+
worker_name: worker.id,
|
|
1143
|
+
leader_head: newLeaderHead,
|
|
1144
|
+
worktree_path: worker.worktree_path,
|
|
1145
|
+
summary: `cross-rebased ${worker.id}`,
|
|
1146
|
+
});
|
|
1147
|
+
hygieneEntries.push({
|
|
1148
|
+
recorded_at: now(),
|
|
1149
|
+
operation: "cross_rebase",
|
|
1150
|
+
worker_name: worker.id,
|
|
1151
|
+
task_id: worker.assigned_tasks[0],
|
|
1152
|
+
status: "applied",
|
|
1153
|
+
operational_commit: after,
|
|
1154
|
+
leader_head_after: newLeaderHead,
|
|
1155
|
+
worker_head_before: before,
|
|
1156
|
+
worker_head_after: after,
|
|
1157
|
+
worktree_path: worker.worktree_path,
|
|
1158
|
+
detail: "Runtime rebase moved worker history onto updated leader head.",
|
|
1159
|
+
});
|
|
1160
|
+
} else {
|
|
1161
|
+
const conflictFiles = listConflictFiles(worker.worktree_path);
|
|
1162
|
+
runGitResult(worker.worktree_path, ["rebase", "--abort"]);
|
|
1163
|
+
integrationByWorker[worker.id] = {
|
|
1164
|
+
...(integrationByWorker[worker.id] ?? {}),
|
|
1165
|
+
conflict_commit: before ?? newLeaderHead,
|
|
1166
|
+
conflict_files: conflictFiles,
|
|
1167
|
+
...integrationNowState("rebase_conflict"),
|
|
1168
|
+
};
|
|
1169
|
+
await appendIntegrationEvent(dir, "worker_cross_rebase_conflict", worker, {
|
|
1170
|
+
worker_name: worker.id,
|
|
1171
|
+
leader_head: newLeaderHead,
|
|
1172
|
+
conflict_files: conflictFiles,
|
|
1173
|
+
stderr: rebase.stderr || rebase.stdout,
|
|
1174
|
+
summary: `cross-rebase conflict for ${worker.id}`,
|
|
1175
|
+
});
|
|
1176
|
+
await appendIntegrationReport(dir, {
|
|
1177
|
+
worker: worker.id,
|
|
1178
|
+
operation: "rebase",
|
|
1179
|
+
files: conflictFiles,
|
|
1180
|
+
detail: `rebase -X ours failed and was aborted: ${(rebase.stderr || rebase.stdout).slice(0, 200)}`,
|
|
1181
|
+
});
|
|
1182
|
+
await notifyLeader(
|
|
1183
|
+
config,
|
|
1184
|
+
worker,
|
|
1185
|
+
`CONFLICT: cross-rebase failed for ${worker.id}; files: ${conflictFiles.join(",") || "unknown"}.`,
|
|
1186
|
+
cwd,
|
|
1187
|
+
env,
|
|
1188
|
+
);
|
|
1189
|
+
hygieneEntries.push({
|
|
1190
|
+
recorded_at: now(),
|
|
1191
|
+
operation: "cross_rebase",
|
|
1192
|
+
worker_name: worker.id,
|
|
1193
|
+
task_id: worker.assigned_tasks[0],
|
|
1194
|
+
status: "conflict",
|
|
1195
|
+
leader_head_after: newLeaderHead,
|
|
1196
|
+
worker_head_before: before,
|
|
1197
|
+
worker_head_after: resolveHead(worker.worktree_path),
|
|
1198
|
+
worktree_path: worker.worktree_path,
|
|
1199
|
+
detail: `Runtime cross-rebase failed and was aborted: ${(rebase.stderr || rebase.stdout).slice(0, 200)}`,
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
await appendCommitHygieneEntries(config, hygieneEntries);
|
|
1205
|
+
return integrationByWorker;
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
async function initializeStateDirs(dir: string, workers: GjcTeamWorker[]): Promise<void> {
|
|
1209
|
+
for (const folder of ["tasks", "claims", "mailbox", "dispatch", "approvals", "workers"])
|
|
1210
|
+
await fs.mkdir(path.join(dir, folder), { recursive: true });
|
|
1211
|
+
for (const worker of workers) {
|
|
1212
|
+
await fs.mkdir(workerDir(dir, worker.id), { recursive: true });
|
|
1213
|
+
await writeJsonFile(mailboxPath(dir, worker.id), { messages: [] });
|
|
1214
|
+
await writeJsonFile(path.join(workerDir(dir, worker.id), "status.json"), { state: "idle", updated_at: now() });
|
|
1215
|
+
await writeJsonFile(path.join(workerDir(dir, worker.id), "heartbeat.json"), {
|
|
1216
|
+
pid: 0,
|
|
1217
|
+
last_turn_at: now(),
|
|
1218
|
+
turn_count: 0,
|
|
1219
|
+
alive: true,
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
await writeJsonFile(mailboxPath(dir, "leader-fixed"), { messages: [] });
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
export async function startGjcTeam(options: GjcTeamStartOptions): Promise<GjcTeamSnapshot> {
|
|
1226
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1227
|
+
const env = options.env ?? process.env;
|
|
1228
|
+
if (!Number.isInteger(options.workerCount) || options.workerCount < 1 || options.workerCount > GJC_TEAM_MAX_WORKERS)
|
|
1229
|
+
throw new Error(`invalid_team_worker_count:${options.workerCount}:expected_1_${GJC_TEAM_MAX_WORKERS}`);
|
|
1230
|
+
const stateRoot = resolveGjcTeamStateRoot(cwd, env);
|
|
1231
|
+
const teamName = sanitizeName(options.teamName ?? makeTeamName(options.task, env));
|
|
1232
|
+
const displayName = sanitizeName(options.teamName ?? options.task).slice(0, 30) || teamName;
|
|
1233
|
+
const dir = teamDir(stateRoot, teamName);
|
|
1234
|
+
const createdAt = now();
|
|
1235
|
+
const worktreeMode = resolveDefaultWorktreeMode(options.worktreeMode);
|
|
1236
|
+
const tmuxCommand = resolveGjcTmuxCommand(env);
|
|
1237
|
+
const tmuxContext = options.dryRun
|
|
1238
|
+
? { sessionName: "dry-run", windowIndex: "0", leaderPaneId: "%dry-run-leader", target: "dry-run:0" }
|
|
1239
|
+
: readCurrentTmuxLeaderContext(tmuxCommand, env);
|
|
1240
|
+
const initialWorkers = buildWorkers(options.workerCount, options.agentType, stateRoot);
|
|
1241
|
+
const workers: GjcTeamWorker[] = [];
|
|
1242
|
+
try {
|
|
1243
|
+
for (const worker of initialWorkers)
|
|
1244
|
+
workers.push(options.dryRun ? worker : await ensureWorkerWorktree(cwd, dir, teamName, worker, worktreeMode));
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
await rollbackCreatedWorktrees(workers);
|
|
1247
|
+
throw error;
|
|
1248
|
+
}
|
|
1249
|
+
const config: GjcTeamConfig = {
|
|
1250
|
+
team_name: teamName,
|
|
1251
|
+
display_name: displayName,
|
|
1252
|
+
requested_name: options.teamName ?? displayName,
|
|
1253
|
+
task: options.task,
|
|
1254
|
+
agent_type: options.agentType,
|
|
1255
|
+
worker_count: options.workerCount,
|
|
1256
|
+
max_workers: GJC_TEAM_MAX_WORKERS,
|
|
1257
|
+
state_root: stateRoot,
|
|
1258
|
+
worker_command: resolveGjcWorkerCommand(cwd, env),
|
|
1259
|
+
tmux_command: tmuxCommand,
|
|
1260
|
+
tmux_session: tmuxContext.sessionName,
|
|
1261
|
+
tmux_session_name: tmuxContext.sessionName,
|
|
1262
|
+
tmux_target: tmuxContext.target,
|
|
1263
|
+
workspace_mode: worktreeMode.enabled ? "worktree" : "direct",
|
|
1264
|
+
leader: { session_id: env.GJC_SESSION_ID ?? env.CODEX_SESSION_ID ?? "", pane_id: tmuxContext.leaderPaneId, cwd },
|
|
1265
|
+
leader_cwd: cwd,
|
|
1266
|
+
team_state_root: stateRoot,
|
|
1267
|
+
workers,
|
|
1268
|
+
created_at: createdAt,
|
|
1269
|
+
updated_at: createdAt,
|
|
1270
|
+
};
|
|
1271
|
+
await initializeStateDirs(dir, config.workers);
|
|
1272
|
+
await writeJsonFile(path.join(dir, "config.json"), config);
|
|
1273
|
+
await writeJsonFile(path.join(dir, "manifest.v2.json"), {
|
|
1274
|
+
version: 2,
|
|
1275
|
+
team_name: config.team_name,
|
|
1276
|
+
display_name: config.display_name,
|
|
1277
|
+
requested_name: config.requested_name,
|
|
1278
|
+
tmux_session: config.tmux_session,
|
|
1279
|
+
tmux_session_name: config.tmux_session_name,
|
|
1280
|
+
tmux_target: config.tmux_target,
|
|
1281
|
+
worker_command: config.worker_command,
|
|
1282
|
+
tmux_command: config.tmux_command,
|
|
1283
|
+
leader: config.leader,
|
|
1284
|
+
workers: config.workers,
|
|
1285
|
+
workspace_mode: config.workspace_mode,
|
|
1286
|
+
created_at: createdAt,
|
|
1287
|
+
updated_at: createdAt,
|
|
1288
|
+
});
|
|
1289
|
+
await writePhase(dir, "starting");
|
|
1290
|
+
for (const task of buildInitialTasks(options.task, config.workers)) await writeTask(dir, task);
|
|
1291
|
+
await appendEvent(dir, {
|
|
1292
|
+
type: "team_started",
|
|
1293
|
+
message: "Started native gjc team runtime",
|
|
1294
|
+
data: { worker_count: options.workerCount, agent_type: options.agentType, workspace_mode: config.workspace_mode },
|
|
1295
|
+
});
|
|
1296
|
+
await appendTelemetry(dir, {
|
|
1297
|
+
type: "team_runtime",
|
|
1298
|
+
message: "Native gjc team runtime initialized",
|
|
1299
|
+
data: { state_root: stateRoot, worker_command: config.worker_command, workspace_mode: config.workspace_mode },
|
|
1300
|
+
});
|
|
1301
|
+
let tmuxWorkers: GjcTeamWorker[];
|
|
1302
|
+
try {
|
|
1303
|
+
tmuxWorkers = await startTmuxSession(config, dir, options.dryRun ?? false);
|
|
1304
|
+
} catch (error) {
|
|
1305
|
+
await writePhase(dir, "failed");
|
|
1306
|
+
await appendEvent(dir, {
|
|
1307
|
+
type: "team_start_failed",
|
|
1308
|
+
message: error instanceof Error ? error.message : String(error),
|
|
1309
|
+
});
|
|
1310
|
+
killWorkerPanes(config);
|
|
1311
|
+
await rollbackCreatedWorktrees(config.workers);
|
|
1312
|
+
throw error;
|
|
1313
|
+
}
|
|
1314
|
+
const runningConfig = {
|
|
1315
|
+
...config,
|
|
1316
|
+
workers: tmuxWorkers.map(worker => ({ ...worker, status: "idle" as const, last_heartbeat: now() })),
|
|
1317
|
+
updated_at: now(),
|
|
1318
|
+
};
|
|
1319
|
+
await writeJsonFile(path.join(dir, "config.json"), runningConfig);
|
|
1320
|
+
await writePhase(dir, "running");
|
|
1321
|
+
return readGjcTeamSnapshot(teamName, cwd, env);
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
export async function readGjcTeamSnapshot(
|
|
1325
|
+
teamName: string,
|
|
1326
|
+
cwd = process.cwd(),
|
|
1327
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1328
|
+
): Promise<GjcTeamSnapshot> {
|
|
1329
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1330
|
+
const config = await readConfig(dir);
|
|
1331
|
+
const phase = await readPhase(dir);
|
|
1332
|
+
const tasks = await readTasks(dir);
|
|
1333
|
+
const taskCounts: Record<GjcTeamTaskStatus, number> = {
|
|
1334
|
+
pending: 0,
|
|
1335
|
+
blocked: 0,
|
|
1336
|
+
in_progress: 0,
|
|
1337
|
+
completed: 0,
|
|
1338
|
+
failed: 0,
|
|
1339
|
+
};
|
|
1340
|
+
for (const task of tasks) taskCounts[task.status] += 1;
|
|
1341
|
+
const monitor = await readJsonFile<GjcTeamMonitorSnapshot>(monitorSnapshotPath(dir));
|
|
1342
|
+
return {
|
|
1343
|
+
team_name: config.team_name,
|
|
1344
|
+
display_name: config.display_name,
|
|
1345
|
+
phase,
|
|
1346
|
+
state_dir: dir,
|
|
1347
|
+
tmux_session: config.tmux_session,
|
|
1348
|
+
tmux_session_name: config.tmux_session_name,
|
|
1349
|
+
tmux_target: config.tmux_target,
|
|
1350
|
+
task_total: tasks.length,
|
|
1351
|
+
task_counts: taskCounts,
|
|
1352
|
+
workers: config.workers,
|
|
1353
|
+
integration_by_worker: monitor?.integration_by_worker,
|
|
1354
|
+
updated_at: config.updated_at,
|
|
1355
|
+
};
|
|
1356
|
+
}
|
|
1357
|
+
export async function monitorGjcTeam(
|
|
1358
|
+
teamName: string,
|
|
1359
|
+
cwd = process.cwd(),
|
|
1360
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1361
|
+
): Promise<GjcTeamSnapshot> {
|
|
1362
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1363
|
+
const config = await readConfig(dir);
|
|
1364
|
+
const previous = await readJsonFile<GjcTeamMonitorSnapshot>(monitorSnapshotPath(dir));
|
|
1365
|
+
const integrationByWorker = await integrateGjcWorkerCommits(config, dir, previous, cwd, env);
|
|
1366
|
+
await writeJsonFile(monitorSnapshotPath(dir), { integration_by_worker: integrationByWorker, updated_at: now() });
|
|
1367
|
+
return readGjcTeamSnapshot(teamName, cwd, env);
|
|
1368
|
+
}
|
|
1369
|
+
export async function listGjcTeams(
|
|
1370
|
+
cwd = process.cwd(),
|
|
1371
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1372
|
+
): Promise<GjcTeamSnapshot[]> {
|
|
1373
|
+
const root = resolveGjcTeamStateRoot(cwd, env);
|
|
1374
|
+
try {
|
|
1375
|
+
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
1376
|
+
const snapshots = await Promise.all(
|
|
1377
|
+
entries
|
|
1378
|
+
.filter(entry => entry.isDirectory())
|
|
1379
|
+
.map(entry => readGjcTeamSnapshot(entry.name, cwd, env).catch(() => null)),
|
|
1380
|
+
);
|
|
1381
|
+
return snapshots.filter((snapshot): snapshot is GjcTeamSnapshot => snapshot != null);
|
|
1382
|
+
} catch (error) {
|
|
1383
|
+
if (isEnoent(error)) return [];
|
|
1384
|
+
throw error;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
export async function shutdownGjcTeam(
|
|
1388
|
+
teamName: string,
|
|
1389
|
+
cwd = process.cwd(),
|
|
1390
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1391
|
+
): Promise<GjcTeamSnapshot> {
|
|
1392
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1393
|
+
const config = await readConfig(dir);
|
|
1394
|
+
killWorkerPanes(config);
|
|
1395
|
+
await removeCleanCreatedWorktrees(config.workers);
|
|
1396
|
+
const stopped = {
|
|
1397
|
+
...config,
|
|
1398
|
+
workers: config.workers.map(worker => ({ ...worker, status: "stopped" as const, last_heartbeat: now() })),
|
|
1399
|
+
updated_at: now(),
|
|
1400
|
+
};
|
|
1401
|
+
await writeJsonFile(path.join(dir, "config.json"), stopped);
|
|
1402
|
+
await writePhase(dir, "complete");
|
|
1403
|
+
await appendEvent(dir, { type: "team_shutdown", message: "Shut down native gjc team runtime" });
|
|
1404
|
+
await appendTelemetry(dir, { type: "team_shutdown", message: "Native gjc team runtime stopped" });
|
|
1405
|
+
return readGjcTeamSnapshot(config.team_name, cwd, env);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
export async function listGjcTeamTasks(
|
|
1409
|
+
teamName: string,
|
|
1410
|
+
cwd = process.cwd(),
|
|
1411
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1412
|
+
): Promise<GjcTeamTask[]> {
|
|
1413
|
+
return readTasks(await findTeamDir(teamName, cwd, env));
|
|
1414
|
+
}
|
|
1415
|
+
export async function readGjcTeamTask(
|
|
1416
|
+
teamName: string,
|
|
1417
|
+
taskId: string,
|
|
1418
|
+
cwd = process.cwd(),
|
|
1419
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1420
|
+
): Promise<GjcTeamTask> {
|
|
1421
|
+
const task = (await listGjcTeamTasks(teamName, cwd, env)).find(candidate => candidate.id === taskId);
|
|
1422
|
+
if (!task) throw new Error(`task_not_found:${taskId}`);
|
|
1423
|
+
return task;
|
|
1424
|
+
}
|
|
1425
|
+
export async function createGjcTeamTask(
|
|
1426
|
+
teamName: string,
|
|
1427
|
+
subject: string,
|
|
1428
|
+
description: string,
|
|
1429
|
+
cwd = process.cwd(),
|
|
1430
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1431
|
+
): Promise<GjcTeamTask> {
|
|
1432
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1433
|
+
const config = await readConfig(dir);
|
|
1434
|
+
const tasks = await readTasks(dir);
|
|
1435
|
+
const next = tasks.length + 1;
|
|
1436
|
+
const task: GjcTeamTask = {
|
|
1437
|
+
id: `task-${next}`,
|
|
1438
|
+
subject,
|
|
1439
|
+
description,
|
|
1440
|
+
title: subject,
|
|
1441
|
+
objective: description,
|
|
1442
|
+
status: "pending",
|
|
1443
|
+
version: 1,
|
|
1444
|
+
created_at: now(),
|
|
1445
|
+
updated_at: now(),
|
|
1446
|
+
};
|
|
1447
|
+
await writeTask(dir, task);
|
|
1448
|
+
config.updated_at = now();
|
|
1449
|
+
await writeJsonFile(path.join(dir, "config.json"), config);
|
|
1450
|
+
await appendEvent(dir, { type: "task_created", task_id: task.id, message: subject });
|
|
1451
|
+
return task;
|
|
1452
|
+
}
|
|
1453
|
+
export async function updateGjcTeamTask(
|
|
1454
|
+
teamName: string,
|
|
1455
|
+
taskId: string,
|
|
1456
|
+
updates: Partial<Pick<GjcTeamTask, "subject" | "description" | "blocked_by" | "depends_on">>,
|
|
1457
|
+
cwd = process.cwd(),
|
|
1458
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1459
|
+
): Promise<GjcTeamTask> {
|
|
1460
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1461
|
+
const task = await readGjcTeamTask(teamName, taskId, cwd, env);
|
|
1462
|
+
const updated = normalizeTask({
|
|
1463
|
+
...task,
|
|
1464
|
+
...updates,
|
|
1465
|
+
title: updates.subject ?? task.title,
|
|
1466
|
+
objective: updates.description ?? task.objective,
|
|
1467
|
+
version: task.version + 1,
|
|
1468
|
+
updated_at: now(),
|
|
1469
|
+
});
|
|
1470
|
+
await writeTask(dir, updated);
|
|
1471
|
+
await appendEvent(dir, { type: "task_updated", task_id: taskId, message: updated.subject });
|
|
1472
|
+
return updated;
|
|
1473
|
+
}
|
|
1474
|
+
export async function claimGjcTeamTask(
|
|
1475
|
+
teamName: string,
|
|
1476
|
+
workerId: string,
|
|
1477
|
+
cwd = process.cwd(),
|
|
1478
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1479
|
+
taskId?: string,
|
|
1480
|
+
): Promise<GjcTeamApiClaimResult> {
|
|
1481
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1482
|
+
const tasks = await readTasks(dir);
|
|
1483
|
+
const task = taskId
|
|
1484
|
+
? tasks.find(candidate => candidate.id === taskId)
|
|
1485
|
+
: tasks.find(candidate => candidate.status === "pending" && (!candidate.owner || candidate.owner === workerId));
|
|
1486
|
+
if (!task) return { ok: false, reason: "no_pending_task" };
|
|
1487
|
+
if (task.status !== "pending") return { ok: false, reason: `task_not_pending:${task.id}` };
|
|
1488
|
+
const token = randomUUID();
|
|
1489
|
+
const claim: GjcTeamTaskClaim = {
|
|
1490
|
+
owner: workerId,
|
|
1491
|
+
token,
|
|
1492
|
+
leased_until: new Date(Date.now() + 30 * 60_000).toISOString(),
|
|
1493
|
+
};
|
|
1494
|
+
const claimPath = path.join(dir, "claims", `${task.id}.json`);
|
|
1495
|
+
await fs.mkdir(path.dirname(claimPath), { recursive: true });
|
|
1496
|
+
let claimFile: fs.FileHandle | undefined;
|
|
1497
|
+
try {
|
|
1498
|
+
claimFile = await fs.open(claimPath, "wx");
|
|
1499
|
+
await claimFile.writeFile(`${JSON.stringify(claim, null, 2)}\n`, "utf-8");
|
|
1500
|
+
} catch (error) {
|
|
1501
|
+
if (isEexist(error)) return { ok: false, reason: `task_already_claimed:${task.id}` };
|
|
1502
|
+
throw error;
|
|
1503
|
+
} finally {
|
|
1504
|
+
await claimFile?.close();
|
|
1505
|
+
}
|
|
1506
|
+
const current = await readGjcTeamTask(teamName, task.id, cwd, env);
|
|
1507
|
+
if (current.status !== "pending") {
|
|
1508
|
+
await fs.rm(claimPath, { force: true });
|
|
1509
|
+
return { ok: false, reason: `task_not_pending:${task.id}` };
|
|
1510
|
+
}
|
|
1511
|
+
const updated: GjcTeamTask = {
|
|
1512
|
+
...current,
|
|
1513
|
+
status: "in_progress",
|
|
1514
|
+
assignee: workerId,
|
|
1515
|
+
owner: workerId,
|
|
1516
|
+
claim,
|
|
1517
|
+
version: current.version + 1,
|
|
1518
|
+
updated_at: now(),
|
|
1519
|
+
};
|
|
1520
|
+
try {
|
|
1521
|
+
await writeTask(dir, updated);
|
|
1522
|
+
} catch (error) {
|
|
1523
|
+
await fs.rm(claimPath, { force: true });
|
|
1524
|
+
throw error;
|
|
1525
|
+
}
|
|
1526
|
+
await appendEvent(dir, {
|
|
1527
|
+
type: "task_claimed",
|
|
1528
|
+
task_id: updated.id,
|
|
1529
|
+
worker: workerId,
|
|
1530
|
+
message: "Worker claimed task",
|
|
1531
|
+
});
|
|
1532
|
+
return { ok: true, task: updated, worker_id: workerId, claim_token: token };
|
|
1533
|
+
}
|
|
1534
|
+
export async function transitionGjcTeamTaskStatus(
|
|
1535
|
+
teamName: string,
|
|
1536
|
+
taskId: string,
|
|
1537
|
+
status: GjcTeamTaskStatus,
|
|
1538
|
+
cwd = process.cwd(),
|
|
1539
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1540
|
+
claimToken?: string,
|
|
1541
|
+
): Promise<GjcTeamTask> {
|
|
1542
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1543
|
+
const task = await readGjcTeamTask(teamName, taskId, cwd, env);
|
|
1544
|
+
if (status === "pending") throw new Error(`invalid_task_transition:${taskId}:pending_requires_release`);
|
|
1545
|
+
if (task.status === "completed" || task.status === "failed") throw new Error(`task_terminal:${taskId}`);
|
|
1546
|
+
if (!task.claim) throw new Error(`claim_token_required:${taskId}`);
|
|
1547
|
+
if (!claimToken) throw new Error(`claim_token_required:${taskId}`);
|
|
1548
|
+
if (task.claim.token !== claimToken) throw new Error(`claim_token_mismatch:${taskId}`);
|
|
1549
|
+
const terminal = status === "completed" || status === "failed";
|
|
1550
|
+
const updated: GjcTeamTask = {
|
|
1551
|
+
...task,
|
|
1552
|
+
status,
|
|
1553
|
+
claim: terminal ? undefined : task.claim,
|
|
1554
|
+
version: task.version + 1,
|
|
1555
|
+
updated_at: now(),
|
|
1556
|
+
...(terminal ? { completed_at: now() } : {}),
|
|
1557
|
+
};
|
|
1558
|
+
await writeTask(dir, updated);
|
|
1559
|
+
if (terminal) await fs.rm(path.join(dir, "claims", `${taskId}.json`), { force: true });
|
|
1560
|
+
await appendEvent(dir, {
|
|
1561
|
+
type: "task_transitioned",
|
|
1562
|
+
task_id: taskId,
|
|
1563
|
+
message: "Task status changed",
|
|
1564
|
+
data: { status },
|
|
1565
|
+
});
|
|
1566
|
+
return updated;
|
|
1567
|
+
}
|
|
1568
|
+
export async function transitionGjcTeamTask(
|
|
1569
|
+
teamName: string,
|
|
1570
|
+
taskId: string,
|
|
1571
|
+
status: GjcTeamTaskStatus | "complete",
|
|
1572
|
+
cwd = process.cwd(),
|
|
1573
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1574
|
+
claimToken?: string,
|
|
1575
|
+
): Promise<GjcTeamTask> {
|
|
1576
|
+
return transitionGjcTeamTaskStatus(teamName, taskId, parseGjcTeamTaskStatus(status, true), cwd, env, claimToken);
|
|
1577
|
+
}
|
|
1578
|
+
export async function releaseGjcTeamTaskClaim(
|
|
1579
|
+
teamName: string,
|
|
1580
|
+
taskId: string,
|
|
1581
|
+
claimToken: string,
|
|
1582
|
+
workerId: string,
|
|
1583
|
+
cwd = process.cwd(),
|
|
1584
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1585
|
+
): Promise<GjcTeamTask> {
|
|
1586
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1587
|
+
const task = await readGjcTeamTask(teamName, taskId, cwd, env);
|
|
1588
|
+
if (!task.claim || task.claim.token !== claimToken || task.claim.owner !== workerId)
|
|
1589
|
+
throw new Error(`claim_token_mismatch:${taskId}`);
|
|
1590
|
+
const updated: GjcTeamTask = {
|
|
1591
|
+
...task,
|
|
1592
|
+
status: "pending",
|
|
1593
|
+
assignee: undefined,
|
|
1594
|
+
claim: undefined,
|
|
1595
|
+
version: task.version + 1,
|
|
1596
|
+
updated_at: now(),
|
|
1597
|
+
};
|
|
1598
|
+
await writeTask(dir, updated);
|
|
1599
|
+
await fs.rm(path.join(dir, "claims", `${taskId}.json`), { force: true });
|
|
1600
|
+
await appendEvent(dir, {
|
|
1601
|
+
type: "task_claim_released",
|
|
1602
|
+
task_id: taskId,
|
|
1603
|
+
worker: workerId,
|
|
1604
|
+
message: "Task claim released",
|
|
1605
|
+
});
|
|
1606
|
+
return updated;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
async function readMailbox(dir: string, worker: string): Promise<{ messages: GjcTeamMailboxMessage[] }> {
|
|
1610
|
+
return (await readJsonFile<{ messages: GjcTeamMailboxMessage[] }>(mailboxPath(dir, worker))) ?? { messages: [] };
|
|
1611
|
+
}
|
|
1612
|
+
async function writeMailbox(
|
|
1613
|
+
dir: string,
|
|
1614
|
+
worker: string,
|
|
1615
|
+
mailbox: { messages: GjcTeamMailboxMessage[] },
|
|
1616
|
+
): Promise<void> {
|
|
1617
|
+
await writeJsonFile(mailboxPath(dir, worker), mailbox);
|
|
1618
|
+
}
|
|
1619
|
+
export async function sendGjcTeamMessage(
|
|
1620
|
+
teamName: string,
|
|
1621
|
+
fromWorker: string,
|
|
1622
|
+
toWorker: string,
|
|
1623
|
+
body: string,
|
|
1624
|
+
cwd = process.cwd(),
|
|
1625
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1626
|
+
): Promise<GjcTeamMailboxMessage> {
|
|
1627
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1628
|
+
const message = {
|
|
1629
|
+
message_id: `msg-${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
|
1630
|
+
from_worker: fromWorker,
|
|
1631
|
+
to_worker: toWorker,
|
|
1632
|
+
body,
|
|
1633
|
+
created_at: now(),
|
|
1634
|
+
};
|
|
1635
|
+
const mailbox = await readMailbox(dir, toWorker);
|
|
1636
|
+
mailbox.messages.push(message);
|
|
1637
|
+
await writeMailbox(dir, toWorker, mailbox);
|
|
1638
|
+
await appendEvent(dir, { type: "message_sent", worker: fromWorker, message: body });
|
|
1639
|
+
return message;
|
|
1640
|
+
}
|
|
1641
|
+
export async function broadcastGjcTeamMessage(
|
|
1642
|
+
teamName: string,
|
|
1643
|
+
fromWorker: string,
|
|
1644
|
+
body: string,
|
|
1645
|
+
cwd = process.cwd(),
|
|
1646
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1647
|
+
): Promise<GjcTeamMailboxMessage[]> {
|
|
1648
|
+
const config = await readConfig(await findTeamDir(teamName, cwd, env));
|
|
1649
|
+
return Promise.all(
|
|
1650
|
+
config.workers.map(worker => sendGjcTeamMessage(teamName, fromWorker, worker.id, body, cwd, env)),
|
|
1651
|
+
);
|
|
1652
|
+
}
|
|
1653
|
+
export async function listGjcTeamMailbox(
|
|
1654
|
+
teamName: string,
|
|
1655
|
+
worker: string,
|
|
1656
|
+
cwd = process.cwd(),
|
|
1657
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1658
|
+
): Promise<GjcTeamMailboxMessage[]> {
|
|
1659
|
+
return (await readMailbox(await findTeamDir(teamName, cwd, env), worker)).messages;
|
|
1660
|
+
}
|
|
1661
|
+
export async function markGjcTeamMailboxMessage(
|
|
1662
|
+
teamName: string,
|
|
1663
|
+
worker: string,
|
|
1664
|
+
messageId: string,
|
|
1665
|
+
field: "delivered_at" | "notified_at",
|
|
1666
|
+
cwd = process.cwd(),
|
|
1667
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1668
|
+
): Promise<GjcTeamMailboxMessage> {
|
|
1669
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1670
|
+
const mailbox = await readMailbox(dir, worker);
|
|
1671
|
+
const index = mailbox.messages.findIndex(message => message.message_id === messageId);
|
|
1672
|
+
if (index < 0) throw new Error(`message_not_found:${messageId}`);
|
|
1673
|
+
mailbox.messages[index] = { ...mailbox.messages[index], [field]: now() };
|
|
1674
|
+
await writeMailbox(dir, worker, mailbox);
|
|
1675
|
+
return mailbox.messages[index];
|
|
1676
|
+
}
|
|
1677
|
+
export async function readGjcWorkerStatus(
|
|
1678
|
+
teamName: string,
|
|
1679
|
+
worker: string,
|
|
1680
|
+
cwd = process.cwd(),
|
|
1681
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1682
|
+
): Promise<WorkerStatusFile> {
|
|
1683
|
+
return (
|
|
1684
|
+
(await readJsonFile<WorkerStatusFile>(
|
|
1685
|
+
path.join(workerDir(await findTeamDir(teamName, cwd, env), worker), "status.json"),
|
|
1686
|
+
)) ?? { state: "unknown", updated_at: now() }
|
|
1687
|
+
);
|
|
1688
|
+
}
|
|
1689
|
+
export async function readGjcWorkerHeartbeat(
|
|
1690
|
+
teamName: string,
|
|
1691
|
+
worker: string,
|
|
1692
|
+
cwd = process.cwd(),
|
|
1693
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1694
|
+
): Promise<WorkerHeartbeatFile | null> {
|
|
1695
|
+
return readJsonFile<WorkerHeartbeatFile>(
|
|
1696
|
+
path.join(workerDir(await findTeamDir(teamName, cwd, env), worker), "heartbeat.json"),
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1699
|
+
export async function updateGjcWorkerHeartbeat(
|
|
1700
|
+
teamName: string,
|
|
1701
|
+
worker: string,
|
|
1702
|
+
heartbeat: WorkerHeartbeatFile,
|
|
1703
|
+
cwd = process.cwd(),
|
|
1704
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1705
|
+
): Promise<WorkerHeartbeatFile> {
|
|
1706
|
+
const value = { ...heartbeat, last_turn_at: heartbeat.last_turn_at || now() };
|
|
1707
|
+
await writeJsonFile(path.join(workerDir(await findTeamDir(teamName, cwd, env), worker), "heartbeat.json"), value);
|
|
1708
|
+
return value;
|
|
1709
|
+
}
|
|
1710
|
+
export async function writeGjcWorkerInbox(
|
|
1711
|
+
teamName: string,
|
|
1712
|
+
worker: string,
|
|
1713
|
+
content: string,
|
|
1714
|
+
cwd = process.cwd(),
|
|
1715
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1716
|
+
): Promise<{ path: string }> {
|
|
1717
|
+
const filePath = path.join(workerDir(await findTeamDir(teamName, cwd, env), worker), "inbox.md");
|
|
1718
|
+
await Bun.write(filePath, content);
|
|
1719
|
+
return { path: filePath };
|
|
1720
|
+
}
|
|
1721
|
+
export async function writeGjcWorkerIdentity(
|
|
1722
|
+
teamName: string,
|
|
1723
|
+
worker: GjcTeamWorker,
|
|
1724
|
+
cwd = process.cwd(),
|
|
1725
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1726
|
+
): Promise<GjcTeamWorker> {
|
|
1727
|
+
await writeJsonFile(path.join(workerDir(await findTeamDir(teamName, cwd, env), worker.id), "identity.json"), worker);
|
|
1728
|
+
return worker;
|
|
1729
|
+
}
|
|
1730
|
+
export async function readGjcTeamEvents(
|
|
1731
|
+
teamName: string,
|
|
1732
|
+
cwd = process.cwd(),
|
|
1733
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1734
|
+
): Promise<GjcTeamEvent[]> {
|
|
1735
|
+
const dir = await findTeamDir(teamName, cwd, env);
|
|
1736
|
+
try {
|
|
1737
|
+
const text = await Bun.file(path.join(dir, "events.jsonl")).text();
|
|
1738
|
+
return text
|
|
1739
|
+
.split(/\r?\n/)
|
|
1740
|
+
.filter(Boolean)
|
|
1741
|
+
.map(line => JSON.parse(line) as GjcTeamEvent);
|
|
1742
|
+
} catch (error) {
|
|
1743
|
+
if (isEnoent(error)) return [];
|
|
1744
|
+
throw error;
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
export async function appendGjcTeamEvent(
|
|
1748
|
+
teamName: string,
|
|
1749
|
+
type: string,
|
|
1750
|
+
worker = "leader-fixed",
|
|
1751
|
+
cwd = process.cwd(),
|
|
1752
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1753
|
+
): Promise<GjcTeamEvent> {
|
|
1754
|
+
return appendEvent(await findTeamDir(teamName, cwd, env), { type, worker });
|
|
1755
|
+
}
|
|
1756
|
+
export async function awaitGjcTeamEvent(
|
|
1757
|
+
teamName: string,
|
|
1758
|
+
_timeoutMs = 0,
|
|
1759
|
+
cwd = process.cwd(),
|
|
1760
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1761
|
+
): Promise<{ status: "event" | "timeout"; event?: GjcTeamEvent }> {
|
|
1762
|
+
const events = await readGjcTeamEvents(teamName, cwd, env);
|
|
1763
|
+
const event = events.at(-1);
|
|
1764
|
+
return event ? { status: "event", event } : { status: "timeout" };
|
|
1765
|
+
}
|
|
1766
|
+
export async function writeGjcMonitorSnapshot(
|
|
1767
|
+
teamName: string,
|
|
1768
|
+
snapshot: unknown,
|
|
1769
|
+
cwd = process.cwd(),
|
|
1770
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1771
|
+
): Promise<unknown> {
|
|
1772
|
+
await writeJsonFile(monitorSnapshotPath(await findTeamDir(teamName, cwd, env)), snapshot);
|
|
1773
|
+
return snapshot;
|
|
1774
|
+
}
|
|
1775
|
+
export async function readGjcMonitorSnapshot(
|
|
1776
|
+
teamName: string,
|
|
1777
|
+
cwd = process.cwd(),
|
|
1778
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1779
|
+
): Promise<unknown> {
|
|
1780
|
+
return readJsonFile<unknown>(monitorSnapshotPath(await findTeamDir(teamName, cwd, env)));
|
|
1781
|
+
}
|
|
1782
|
+
export async function writeGjcTaskApproval(
|
|
1783
|
+
teamName: string,
|
|
1784
|
+
taskId: string,
|
|
1785
|
+
approval: Record<string, unknown>,
|
|
1786
|
+
cwd = process.cwd(),
|
|
1787
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1788
|
+
): Promise<Record<string, unknown>> {
|
|
1789
|
+
await writeJsonFile(path.join(await findTeamDir(teamName, cwd, env), "approvals", `${taskId}.json`), approval);
|
|
1790
|
+
return approval;
|
|
1791
|
+
}
|
|
1792
|
+
export async function readGjcTaskApproval(
|
|
1793
|
+
teamName: string,
|
|
1794
|
+
taskId: string,
|
|
1795
|
+
cwd = process.cwd(),
|
|
1796
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1797
|
+
): Promise<Record<string, unknown> | null> {
|
|
1798
|
+
return readJsonFile<Record<string, unknown>>(
|
|
1799
|
+
path.join(await findTeamDir(teamName, cwd, env), "approvals", `${taskId}.json`),
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
export async function writeGjcShutdownRequest(
|
|
1803
|
+
teamName: string,
|
|
1804
|
+
worker: string,
|
|
1805
|
+
requestedBy: string,
|
|
1806
|
+
cwd = process.cwd(),
|
|
1807
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1808
|
+
): Promise<Record<string, unknown>> {
|
|
1809
|
+
const value = { worker, requested_by: requestedBy, requested_at: now() };
|
|
1810
|
+
await writeJsonFile(
|
|
1811
|
+
path.join(workerDir(await findTeamDir(teamName, cwd, env), worker), "shutdown-request.json"),
|
|
1812
|
+
value,
|
|
1813
|
+
);
|
|
1814
|
+
return value;
|
|
1815
|
+
}
|
|
1816
|
+
export async function readGjcShutdownAck(
|
|
1817
|
+
teamName: string,
|
|
1818
|
+
worker: string,
|
|
1819
|
+
cwd = process.cwd(),
|
|
1820
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1821
|
+
): Promise<Record<string, unknown> | null> {
|
|
1822
|
+
return readJsonFile<Record<string, unknown>>(
|
|
1823
|
+
path.join(workerDir(await findTeamDir(teamName, cwd, env), worker), "shutdown-ack.json"),
|
|
1824
|
+
);
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1827
|
+
export async function executeGjcTeamApiOperation(
|
|
1828
|
+
operation: string,
|
|
1829
|
+
input: Record<string, unknown>,
|
|
1830
|
+
cwd = process.cwd(),
|
|
1831
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
1832
|
+
): Promise<unknown> {
|
|
1833
|
+
const teamName = String(input.team_name ?? input.teamName ?? "").trim();
|
|
1834
|
+
if (!teamName) throw new Error("missing_team_name");
|
|
1835
|
+
const worker = String(input.worker ?? input.worker_id ?? input.workerId ?? "worker-1");
|
|
1836
|
+
switch (operation) {
|
|
1837
|
+
case "list-tasks":
|
|
1838
|
+
return { tasks: await listGjcTeamTasks(teamName, cwd, env) };
|
|
1839
|
+
case "read-task":
|
|
1840
|
+
return { task: await readGjcTeamTask(teamName, String(input.task_id ?? input.taskId), cwd, env) };
|
|
1841
|
+
case "create-task":
|
|
1842
|
+
return {
|
|
1843
|
+
task: await createGjcTeamTask(
|
|
1844
|
+
teamName,
|
|
1845
|
+
String(input.subject ?? "Task"),
|
|
1846
|
+
String(input.description ?? ""),
|
|
1847
|
+
cwd,
|
|
1848
|
+
env,
|
|
1849
|
+
),
|
|
1850
|
+
};
|
|
1851
|
+
case "update-task":
|
|
1852
|
+
return {
|
|
1853
|
+
task: await updateGjcTeamTask(
|
|
1854
|
+
teamName,
|
|
1855
|
+
String(input.task_id ?? input.taskId),
|
|
1856
|
+
{
|
|
1857
|
+
subject: typeof input.subject === "string" ? input.subject : undefined,
|
|
1858
|
+
description: typeof input.description === "string" ? input.description : undefined,
|
|
1859
|
+
},
|
|
1860
|
+
cwd,
|
|
1861
|
+
env,
|
|
1862
|
+
),
|
|
1863
|
+
};
|
|
1864
|
+
case "claim-task":
|
|
1865
|
+
return claimGjcTeamTask(
|
|
1866
|
+
teamName,
|
|
1867
|
+
worker,
|
|
1868
|
+
cwd,
|
|
1869
|
+
env,
|
|
1870
|
+
typeof input.task_id === "string" ? input.task_id : undefined,
|
|
1871
|
+
);
|
|
1872
|
+
case "transition-task":
|
|
1873
|
+
case "transition-task-status":
|
|
1874
|
+
return {
|
|
1875
|
+
ok: true,
|
|
1876
|
+
task: await transitionGjcTeamTaskStatus(
|
|
1877
|
+
teamName,
|
|
1878
|
+
String(input.task_id ?? input.taskId),
|
|
1879
|
+
parseGjcTeamTaskStatus(input.to ?? input.status),
|
|
1880
|
+
cwd,
|
|
1881
|
+
env,
|
|
1882
|
+
typeof input.claim_token === "string" ? input.claim_token : undefined,
|
|
1883
|
+
),
|
|
1884
|
+
};
|
|
1885
|
+
case "release-task-claim":
|
|
1886
|
+
return {
|
|
1887
|
+
ok: true,
|
|
1888
|
+
task: await releaseGjcTeamTaskClaim(
|
|
1889
|
+
teamName,
|
|
1890
|
+
String(input.task_id),
|
|
1891
|
+
String(input.claim_token),
|
|
1892
|
+
worker,
|
|
1893
|
+
cwd,
|
|
1894
|
+
env,
|
|
1895
|
+
),
|
|
1896
|
+
};
|
|
1897
|
+
case "send-message":
|
|
1898
|
+
return {
|
|
1899
|
+
message: await sendGjcTeamMessage(
|
|
1900
|
+
teamName,
|
|
1901
|
+
String(input.from_worker),
|
|
1902
|
+
String(input.to_worker),
|
|
1903
|
+
String(input.body),
|
|
1904
|
+
cwd,
|
|
1905
|
+
env,
|
|
1906
|
+
),
|
|
1907
|
+
};
|
|
1908
|
+
case "broadcast":
|
|
1909
|
+
return {
|
|
1910
|
+
messages: await broadcastGjcTeamMessage(teamName, String(input.from_worker), String(input.body), cwd, env),
|
|
1911
|
+
};
|
|
1912
|
+
case "mailbox-list":
|
|
1913
|
+
return { messages: await listGjcTeamMailbox(teamName, worker, cwd, env) };
|
|
1914
|
+
case "mailbox-mark-delivered":
|
|
1915
|
+
return {
|
|
1916
|
+
message: await markGjcTeamMailboxMessage(
|
|
1917
|
+
teamName,
|
|
1918
|
+
worker,
|
|
1919
|
+
String(input.message_id),
|
|
1920
|
+
"delivered_at",
|
|
1921
|
+
cwd,
|
|
1922
|
+
env,
|
|
1923
|
+
),
|
|
1924
|
+
};
|
|
1925
|
+
case "mailbox-mark-notified":
|
|
1926
|
+
return {
|
|
1927
|
+
message: await markGjcTeamMailboxMessage(
|
|
1928
|
+
teamName,
|
|
1929
|
+
worker,
|
|
1930
|
+
String(input.message_id),
|
|
1931
|
+
"notified_at",
|
|
1932
|
+
cwd,
|
|
1933
|
+
env,
|
|
1934
|
+
),
|
|
1935
|
+
};
|
|
1936
|
+
case "read-config":
|
|
1937
|
+
return await readConfig(await findTeamDir(teamName, cwd, env));
|
|
1938
|
+
case "read-manifest":
|
|
1939
|
+
return readJsonFile(path.join(await findTeamDir(teamName, cwd, env), "manifest.v2.json"));
|
|
1940
|
+
case "read-worker-status":
|
|
1941
|
+
return readGjcWorkerStatus(teamName, worker, cwd, env);
|
|
1942
|
+
case "read-worker-heartbeat":
|
|
1943
|
+
return readGjcWorkerHeartbeat(teamName, worker, cwd, env);
|
|
1944
|
+
case "update-worker-heartbeat":
|
|
1945
|
+
return updateGjcWorkerHeartbeat(
|
|
1946
|
+
teamName,
|
|
1947
|
+
worker,
|
|
1948
|
+
{
|
|
1949
|
+
pid: Number(input.pid ?? 0),
|
|
1950
|
+
last_turn_at: now(),
|
|
1951
|
+
turn_count: Number(input.turn_count ?? 0),
|
|
1952
|
+
alive: Boolean(input.alive ?? true),
|
|
1953
|
+
},
|
|
1954
|
+
cwd,
|
|
1955
|
+
env,
|
|
1956
|
+
);
|
|
1957
|
+
case "write-worker-inbox":
|
|
1958
|
+
return writeGjcWorkerInbox(teamName, worker, String(input.content ?? ""), cwd, env);
|
|
1959
|
+
case "write-worker-identity":
|
|
1960
|
+
return writeGjcWorkerIdentity(
|
|
1961
|
+
teamName,
|
|
1962
|
+
{
|
|
1963
|
+
id: worker,
|
|
1964
|
+
name: worker,
|
|
1965
|
+
index: Number(input.index ?? 1),
|
|
1966
|
+
agent_type: String(input.role ?? "executor"),
|
|
1967
|
+
role: String(input.role ?? "executor"),
|
|
1968
|
+
status: "idle",
|
|
1969
|
+
last_heartbeat: now(),
|
|
1970
|
+
assigned_tasks: Array.isArray(input.assigned_tasks) ? input.assigned_tasks.map(String) : [],
|
|
1971
|
+
},
|
|
1972
|
+
cwd,
|
|
1973
|
+
env,
|
|
1974
|
+
);
|
|
1975
|
+
case "append-event":
|
|
1976
|
+
return appendGjcTeamEvent(teamName, String(input.type ?? "event"), worker, cwd, env);
|
|
1977
|
+
case "read-events":
|
|
1978
|
+
return { events: await readGjcTeamEvents(teamName, cwd, env) };
|
|
1979
|
+
case "await-event":
|
|
1980
|
+
return awaitGjcTeamEvent(teamName, Number(input.timeout_ms ?? 0), cwd, env);
|
|
1981
|
+
case "write-monitor-snapshot":
|
|
1982
|
+
return writeGjcMonitorSnapshot(teamName, input.snapshot ?? {}, cwd, env);
|
|
1983
|
+
case "read-monitor-snapshot":
|
|
1984
|
+
return readGjcMonitorSnapshot(teamName, cwd, env);
|
|
1985
|
+
case "write-task-approval":
|
|
1986
|
+
return writeGjcTaskApproval(teamName, String(input.task_id), input, cwd, env);
|
|
1987
|
+
case "read-task-approval":
|
|
1988
|
+
return readGjcTaskApproval(teamName, String(input.task_id), cwd, env);
|
|
1989
|
+
case "write-shutdown-request":
|
|
1990
|
+
return writeGjcShutdownRequest(teamName, worker, String(input.requested_by ?? "leader-fixed"), cwd, env);
|
|
1991
|
+
case "read-shutdown-ack":
|
|
1992
|
+
return readGjcShutdownAck(teamName, worker, cwd, env);
|
|
1993
|
+
default:
|
|
1994
|
+
throw new Error(`unknown_team_api_operation:${operation}`);
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
|
|
1998
|
+
export function parseTeamLaunchArgs(argv: string[]): GjcTeamStartOptions {
|
|
1999
|
+
const parsedWorktree = parseWorktreeMode(argv);
|
|
2000
|
+
const positionals = parsedWorktree.remainingArgs.filter(arg => !arg.startsWith("--"));
|
|
2001
|
+
const dryRun = argv.includes("--dry-run");
|
|
2002
|
+
let workerCount = GJC_TEAM_DEFAULT_WORKERS;
|
|
2003
|
+
let agentType = "executor";
|
|
2004
|
+
let taskStartIndex = 0;
|
|
2005
|
+
const first = positionals[0] ?? "";
|
|
2006
|
+
const countRole = first.match(/^(\d+):([a-zA-Z][a-zA-Z0-9_-]*)$/);
|
|
2007
|
+
const countOnly = first.match(/^(\d+)$/);
|
|
2008
|
+
const roleOnly = first.match(/^([a-zA-Z][a-zA-Z0-9_-]*)$/);
|
|
2009
|
+
if (countRole) {
|
|
2010
|
+
workerCount = Number.parseInt(countRole[1] ?? "", 10);
|
|
2011
|
+
agentType = countRole[2] ?? "executor";
|
|
2012
|
+
taskStartIndex = 1;
|
|
2013
|
+
} else if (countOnly) {
|
|
2014
|
+
workerCount = Number.parseInt(countOnly[1] ?? "", 10);
|
|
2015
|
+
taskStartIndex = 1;
|
|
2016
|
+
} else if (roleOnly && positionals.length > 1) {
|
|
2017
|
+
agentType = roleOnly[1] ?? "executor";
|
|
2018
|
+
taskStartIndex = 1;
|
|
2019
|
+
}
|
|
2020
|
+
const task = positionals.slice(taskStartIndex).join(" ").trim();
|
|
2021
|
+
if (!task) throw new Error("missing_team_task");
|
|
2022
|
+
if (!Number.isInteger(workerCount) || workerCount < 1 || workerCount > GJC_TEAM_MAX_WORKERS)
|
|
2023
|
+
throw new Error(`invalid_team_worker_count:${workerCount}:expected_1_${GJC_TEAM_MAX_WORKERS}`);
|
|
2024
|
+
return { workerCount, agentType, task, dryRun, worktreeMode: resolveDefaultWorktreeMode(parsedWorktree.mode) };
|
|
2025
|
+
}
|