@orion-agents/orion-code 0.3.66 → 0.4.4
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 +87 -0
- package/README.md +78 -361
- package/README.zh-CN.md +71 -262
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +35 -0
- package/dist/acp/session-updates.js +183 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +328 -0
- package/dist/acp/stdio.d.ts +3 -0
- package/dist/acp/stdio.js +59 -0
- package/dist/cli.js +136 -185
- package/dist/commands/context-tool-command-handlers.d.ts +1 -1
- package/dist/commands/context-tool-command-handlers.js +24 -3
- package/dist/commands/core-command-handlers.js +10 -18
- package/dist/commands/diagnostic-command-handlers.js +58 -48
- package/dist/commands/diagnostic-commands.js +0 -12
- package/dist/commands/init-command.d.ts +3 -0
- package/dist/commands/init-command.js +131 -0
- package/dist/commands/model-command-handlers.d.ts +1 -2
- package/dist/commands/model-command-handlers.js +15 -100
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/registry.js +1 -19
- package/dist/commands/rsi-command.d.ts +2 -0
- package/dist/commands/rsi-command.js +180 -0
- package/dist/commands/session-command-handlers.js +28 -19
- package/dist/commands/system-commands.js +0 -1
- package/dist/commands/target-command.js +49 -6
- package/dist/commands/tool-commands.js +1 -1
- package/dist/commands/types.d.ts +4 -10
- package/dist/commands/types.js +1 -21
- package/dist/commands/workflow-command-handlers.js +13 -4
- package/dist/commands/workflow-commands.js +2 -2
- package/dist/framework/loop-budget-contract.d.ts +2 -8
- package/dist/framework/loop-budget-contract.js +0 -3
- package/dist/framework/loop-progress.d.ts +18 -0
- package/dist/framework/loop-progress.js +63 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +26 -31
- package/dist/framework/query.js +451 -292
- package/dist/framework/store.d.ts +6 -10
- package/dist/framework/store.js +2 -21
- package/dist/framework/tool-call-orchestrator.d.ts +7 -0
- package/dist/framework/tool-call-orchestrator.js +8 -3
- package/dist/framework/tool-state.d.ts +2 -0
- package/dist/framework/tool.d.ts +0 -23
- package/dist/framework/verification-command.d.ts +15 -0
- package/dist/framework/verification-command.js +32 -0
- package/dist/harness/assembler.d.ts +1 -0
- package/dist/harness/assembler.js +24 -0
- package/dist/harness/capsule.d.ts +1 -1
- package/dist/harness/capsule.js +33 -14
- package/dist/harness/context-harness.d.ts +37 -12
- package/dist/harness/context-harness.js +545 -35
- package/dist/harness/contract.js +1 -1
- package/dist/harness/drift-guard.d.ts +4 -0
- package/dist/harness/drift-guard.js +68 -16
- package/dist/harness/index.d.ts +1 -1
- package/dist/harness/intent.js +21 -0
- package/dist/harness/ledger.d.ts +7 -11
- package/dist/harness/ledger.js +50 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +96 -29
- package/dist/harness/state.js +10 -1
- package/dist/harness/stop-controller.d.ts +0 -5
- package/dist/harness/stop-controller.js +11 -31
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +92 -0
- package/dist/harness/types.d.ts +78 -1
- package/dist/harness/verification.d.ts +19 -1
- package/dist/harness/verification.js +116 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/print-ui/event-stream.d.ts +43 -0
- package/dist/print-ui/event-stream.js +204 -0
- package/dist/print-ui/launch.d.ts +12 -1
- package/dist/print-ui/launch.js +173 -11
- package/dist/product/environment.d.ts +1 -1
- package/dist/product/environment.js +1 -1
- package/dist/product/identity.d.ts +1 -1
- package/dist/product/identity.js +1 -1
- package/dist/product/paths.d.ts +3 -2
- package/dist/product/paths.js +6 -2
- package/dist/runtime/agent-loop.d.ts +12 -2
- package/dist/runtime/agent-loop.js +172 -29
- package/dist/runtime/agent-runtime-controller.d.ts +14 -4
- package/dist/runtime/agent-runtime-controller.js +366 -192
- package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
- package/dist/runtime/agent-runtime-runner.d.ts +10 -0
- package/dist/runtime/builtin-tool-provider.js +5 -1
- package/dist/runtime/capability-receipt-journal.js +1 -0
- package/dist/runtime/durable-tool-receipt-reader.js +2 -1
- package/dist/runtime/first-party-tool-services.d.ts +1 -0
- package/dist/runtime/first-party-tool-services.js +2 -12
- package/dist/runtime/first-party-tool-universe.d.ts +1 -0
- package/dist/runtime/first-party-tool-universe.js +1 -1
- package/dist/runtime/followup-queue-store.d.ts +16 -0
- package/dist/runtime/followup-queue-store.js +75 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +16 -4
- package/dist/runtime/goal-lifecycle-v2.js +217 -39
- package/dist/runtime/goal-runtime-coordinator.d.ts +14 -2
- package/dist/runtime/goal-runtime-coordinator.js +147 -36
- package/dist/runtime/goals/presentation.js +3 -1
- package/dist/runtime/goals/types.d.ts +1 -3
- package/dist/runtime/goals/types.js +0 -3
- package/dist/runtime/loop-budget.d.ts +0 -7
- package/dist/runtime/loop-budget.js +8 -52
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
- package/dist/runtime/model-coordinator.js +2 -5
- package/dist/runtime/orion-runtime-v1.d.ts +18 -2
- package/dist/runtime/orion-runtime-v1.js +183 -46
- package/dist/runtime/orion-session-runner.d.ts +7 -0
- package/dist/runtime/orion-session-runner.js +82 -0
- package/dist/runtime/plan-review.d.ts +1 -0
- package/dist/runtime/plan-review.js +8 -4
- package/dist/runtime/product-bootstrap.d.ts +6 -0
- package/dist/runtime/product-bootstrap.js +41 -51
- package/dist/runtime/product-orion-runtime.js +129 -58
- package/dist/runtime/release-receipts.d.ts +24 -133
- package/dist/runtime/release-receipts.js +129 -693
- package/dist/runtime/rich-text/layout.js +108 -65
- package/dist/runtime/rsi/contracts.d.ts +50 -0
- package/dist/runtime/rsi/contracts.js +17 -0
- package/dist/runtime/rsi/diagnosis.d.ts +46 -0
- package/dist/runtime/rsi/diagnosis.js +98 -0
- package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
- package/dist/runtime/rsi/evaluation-suite.js +141 -0
- package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
- package/dist/runtime/rsi/evaluation-worker.js +64 -0
- package/dist/runtime/rsi/evaluation.d.ts +49 -0
- package/dist/runtime/rsi/evaluation.js +345 -0
- package/dist/runtime/rsi/lifecycle.d.ts +54 -0
- package/dist/runtime/rsi/lifecycle.js +279 -0
- package/dist/runtime/rsi/proposal.d.ts +39 -0
- package/dist/runtime/rsi/proposal.js +312 -0
- package/dist/runtime/rsi/receipt.d.ts +28 -0
- package/dist/runtime/rsi/receipt.js +138 -0
- package/dist/runtime/rsi/skill-state.d.ts +7 -0
- package/dist/runtime/rsi/skill-state.js +50 -0
- package/dist/runtime/rsi/trajectory.d.ts +19 -0
- package/dist/runtime/rsi/trajectory.js +314 -0
- package/dist/runtime/rsi/triage.d.ts +274 -0
- package/dist/runtime/rsi/triage.js +58 -0
- package/dist/runtime/session-composer-control.d.ts +5 -24
- package/dist/runtime/session-composer-control.js +27 -189
- package/dist/runtime/step-snapshot.d.ts +4 -1
- package/dist/runtime/step-snapshot.js +11 -1
- package/dist/runtime/subagent-thread-runtime.js +27 -5
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -5
- package/dist/runtime/subagents/runtime-integration.js +2 -4
- package/dist/runtime/subagents/types.d.ts +0 -5
- package/dist/runtime/subagents/types.js +0 -2
- package/dist/runtime/task-context-recovery.d.ts +55 -0
- package/dist/runtime/task-context-recovery.js +349 -0
- package/dist/runtime/task-context-service.d.ts +20 -10
- package/dist/runtime/task-context-service.js +69 -9
- package/dist/runtime/thread-admission.d.ts +3 -1
- package/dist/runtime/thread-admission.js +21 -7
- package/dist/runtime/thread-event-store.d.ts +2 -2
- package/dist/runtime/thread-event-store.js +7 -2
- package/dist/runtime/thread-projection.js +4 -2
- package/dist/runtime/thread-runtime.d.ts +10 -0
- package/dist/runtime/thread-runtime.js +85 -3
- package/dist/runtime/thread-session-index.d.ts +8 -0
- package/dist/runtime/thread-session-index.js +50 -1
- package/dist/runtime/thread-session-view.d.ts +2 -1
- package/dist/runtime/thread-session-view.js +4 -0
- package/dist/runtime/thread-tool-journal.d.ts +1 -0
- package/dist/runtime/thread-tool-journal.js +6 -2
- package/dist/runtime/thread-ui-adapter.d.ts +1 -0
- package/dist/runtime/thread-ui-adapter.js +89 -22
- package/dist/runtime/tool-gateway.d.ts +9 -0
- package/dist/runtime/tool-gateway.js +24 -0
- package/dist/runtime/tool-receipt-validator.js +4 -0
- package/dist/runtime/tool-transcript-entry.d.ts +16 -0
- package/dist/runtime/tool-transcript-entry.js +73 -0
- package/dist/runtime/turn-commit.d.ts +4 -1
- package/dist/runtime/turn-commit.js +19 -15
- package/dist/runtime/ui-events.d.ts +15 -1
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +78 -61
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- package/dist/runtime/workspace-verification.d.ts +7 -0
- package/dist/runtime/workspace-verification.js +83 -0
- package/dist/services/atomic-write.d.ts +2 -0
- package/dist/services/atomic-write.js +12 -1
- package/dist/services/code-review/format.d.ts +4 -1
- package/dist/services/code-review/format.js +5 -1
- package/dist/services/code-review/runner.d.ts +2 -2
- package/dist/services/code-review/runner.js +86 -64
- package/dist/services/code-review/snapshot.d.ts +9 -9
- package/dist/services/code-review/snapshot.js +182 -166
- package/dist/services/compact/auto-compact.d.ts +21 -6
- package/dist/services/compact/auto-compact.js +148 -22
- package/dist/services/compact/background-candidate.d.ts +33 -0
- package/dist/services/compact/background-candidate.js +184 -0
- package/dist/services/compact/compact.d.ts +4 -1
- package/dist/services/compact/compact.js +30 -3
- package/dist/services/compact/coordinator.d.ts +10 -4
- package/dist/services/compact/coordinator.js +17 -7
- package/dist/services/compact/summary-generator.d.ts +4 -2
- package/dist/services/compact/summary-generator.js +17 -3
- package/dist/services/config.d.ts +5 -5
- package/dist/services/config.js +29 -48
- package/dist/services/doctor.js +85 -13
- package/dist/services/effort.d.ts +5 -5
- package/dist/services/effort.js +5 -11
- package/dist/services/file-lock.d.ts +9 -3
- package/dist/services/file-lock.js +92 -26
- package/dist/services/global-config.d.ts +26 -64
- package/dist/services/global-config.js +233 -193
- package/dist/services/llm.d.ts +42 -4
- package/dist/services/llm.js +177 -45
- package/dist/services/model-client-pool.d.ts +15 -9
- package/dist/services/model-client-pool.js +62 -33
- package/dist/services/model-context.d.ts +2 -1
- package/dist/services/model-context.js +15 -9
- package/dist/services/model-registry.d.ts +4 -15
- package/dist/services/model-registry.js +32 -101
- package/dist/services/provider-diagnostics.d.ts +8 -0
- package/dist/services/provider-diagnostics.js +17 -12
- package/dist/services/provider-resilience/coordinator.d.ts +1 -1
- package/dist/services/provider-resilience/coordinator.js +10 -6
- package/dist/services/provider-resilience/request-gate.d.ts +3 -0
- package/dist/services/provider-resilience/request-gate.js +29 -18
- package/dist/services/provider-resilience/types.d.ts +2 -0
- package/dist/services/session-storage.d.ts +7 -10
- package/dist/services/session-storage.js +57 -30
- package/dist/services/settings-coordinator.d.ts +0 -6
- package/dist/services/settings-coordinator.js +19 -56
- package/dist/services/settings-document-repository.d.ts +3 -10
- package/dist/services/settings-document-repository.js +7 -85
- package/dist/services/usage-state.d.ts +3 -3
- package/dist/services/usage-state.js +11 -42
- package/dist/terminal-ui/answer-format.d.ts +14 -0
- package/dist/terminal-ui/answer-format.js +119 -0
- package/dist/terminal-ui/launch.d.ts +7 -6
- package/dist/terminal-ui/launch.js +160 -70
- package/dist/terminal-ui/output-queue.d.ts +2 -1
- package/dist/terminal-ui/output-queue.js +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +2 -1
- package/dist/terminal-ui/raw-editor.js +56 -15
- package/dist/tools/core/edit-file.js +6 -2
- package/dist/tools/core/write-file.js +9 -2
- package/dist/tools/lsp.d.ts +16 -1
- package/dist/tools/lsp.js +60 -19
- package/dist/tools/sandbox.d.ts +1 -1
- package/dist/tools/sandbox.js +3 -16
- package/dist/tools/todo.d.ts +4 -2
- package/dist/tools/todo.js +91 -30
- package/dist/tui-core/input-parser.d.ts +1 -0
- package/dist/tui-core/input-parser.js +6 -0
- package/dist/tui-core/style.d.ts +1 -8
- package/dist/tui-core/style.js +3 -110
- package/dist/tui-ui/chrome-view-model.d.ts +1 -1
- package/dist/tui-ui/chrome-view-model.js +36 -32
- package/dist/tui-ui/launch.js +14 -14
- package/dist/tui-ui/layout.d.ts +5 -7
- package/dist/tui-ui/layout.js +129 -124
- package/dist/tui-ui/runner.d.ts +11 -12
- package/dist/tui-ui/runner.js +88 -67
- package/dist/tui-ui/state.d.ts +0 -11
- package/dist/tui-ui/state.js +22 -33
- package/dist/tui-ui/terminal-image.js +22 -4
- package/dist/tui-ui/transcript-inspector-layout.js +6 -3
- package/dist/tui-ui/transcript-inspector.d.ts +1 -0
- package/dist/tui-ui/transcript-inspector.js +7 -1
- package/dist/tui-ui/transcript-layout.js +42 -6
- package/dist/utils/terminal-text.d.ts +11 -0
- package/dist/utils/terminal-text.js +114 -0
- package/docs/cli-guide.md +575 -0
- package/docs/orion.example.yaml +43 -0
- package/docs/readme.md +12 -57
- package/npm-shrinkwrap.json +484 -1855
- package/package.json +13 -63
- package/dist/migration/command.d.ts +0 -9
- package/dist/migration/command.js +0 -100
- package/dist/migration/index.d.ts +0 -7
- package/dist/migration/index.js +0 -14
- package/dist/migration/migrate.d.ts +0 -19
- package/dist/migration/migrate.js +0 -406
- package/dist/migration/types.d.ts +0 -55
- package/dist/migration/types.js +0 -6
- package/dist/services/tool-allowlist.d.ts +0 -110
- package/dist/services/tool-allowlist.js +0 -299
- package/dist/services/yaml-config.d.ts +0 -57
- package/dist/services/yaml-config.js +0 -178
- package/dist/web/cli-options.d.ts +0 -17
- package/dist/web/cli-options.js +0 -51
- package/dist/web/code-review-run-service.d.ts +0 -68
- package/dist/web/code-review-run-service.js +0 -228
- package/dist/web/context-text.d.ts +0 -17
- package/dist/web/context-text.js +0 -40
- package/dist/web/errors.d.ts +0 -6
- package/dist/web/errors.js +0 -13
- package/dist/web/event-hub.d.ts +0 -45
- package/dist/web/event-hub.js +0 -370
- package/dist/web/file-read-service.d.ts +0 -101
- package/dist/web/file-read-service.js +0 -593
- package/dist/web/file-write-service.d.ts +0 -16
- package/dist/web/file-write-service.js +0 -103
- package/dist/web/git-compare-service.d.ts +0 -45
- package/dist/web/git-compare-service.js +0 -160
- package/dist/web/git-diff-document.d.ts +0 -102
- package/dist/web/git-diff-document.js +0 -258
- package/dist/web/git-file-source.d.ts +0 -25
- package/dist/web/git-file-source.js +0 -21
- package/dist/web/git-history-service.d.ts +0 -151
- package/dist/web/git-history-service.js +0 -619
- package/dist/web/git-index-transaction.d.ts +0 -45
- package/dist/web/git-index-transaction.js +0 -174
- package/dist/web/git-patch-builder.d.ts +0 -30
- package/dist/web/git-patch-builder.js +0 -138
- package/dist/web/git-read-model-service.d.ts +0 -452
- package/dist/web/git-read-model-service.js +0 -1833
- package/dist/web/git-version-service.d.ts +0 -79
- package/dist/web/git-version-service.js +0 -279
- package/dist/web/host-daemon.d.ts +0 -70
- package/dist/web/host-daemon.js +0 -237
- package/dist/web/index.d.ts +0 -6
- package/dist/web/index.js +0 -28
- package/dist/web/launch.d.ts +0 -12
- package/dist/web/launch.js +0 -89
- package/dist/web/native-directory-picker.d.ts +0 -63
- package/dist/web/native-directory-picker.js +0 -169
- package/dist/web/protocol.d.ts +0 -705
- package/dist/web/protocol.js +0 -639
- package/dist/web/review-service.d.ts +0 -22
- package/dist/web/review-service.js +0 -68
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -1453
- package/dist/web/session-runtime-registry.d.ts +0 -138
- package/dist/web/session-runtime-registry.js +0 -471
- package/dist/web/terminal-manager.d.ts +0 -156
- package/dist/web/terminal-manager.js +0 -779
- package/dist/web/terminal-server.d.ts +0 -8
- package/dist/web/terminal-server.js +0 -304
- package/dist/web/workbench-controller.d.ts +0 -395
- package/dist/web/workbench-controller.js +0 -3077
- package/dist/web/workspace-discovery.d.ts +0 -92
- package/dist/web/workspace-discovery.js +0 -324
- package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
- package/dist/web/workspace-mutation-arbiter.js +0 -267
- package/dist/web/workspace-open-telemetry.d.ts +0 -55
- package/dist/web/workspace-open-telemetry.js +0 -73
- package/dist/web-client/assets/FilesPanel-CPDovK_K.js +0 -1
- package/dist/web-client/assets/GitPanel-DtU_TD61.js +0 -4
- package/dist/web-client/assets/ReviewPanel-vMO7BEA3.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C9vDTAlS.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-CABdwh4l.css +0 -1
- package/dist/web-client/assets/index-KvshfEbl.js +0 -20
- package/dist/web-client/assets/useAutoNotice-IE1g2wcb.js +0 -1
- package/dist/web-client/favicon.svg +0 -9
- package/dist/web-client/index.html +0 -17
- package/docs/architecture/agent-mode-permission-contract.md +0 -87
- package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
- package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
- package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
- package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
- package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
- package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
- package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
- package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
- package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
- package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
- package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
- package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
- package/docs/orion.example.json +0 -86
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
- package/docs/plan/v0.2.0-release-checklist.md +0 -91
- package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
- package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
- package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
- package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
- package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
- package/docs/plan/v0.3.3-plan.md +0 -1113
- package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
- package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
- package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
- package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
- package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runRsiCommand = runRsiCommand;
|
|
4
|
+
const canonical_1 = require("../runtime/protocol/canonical");
|
|
5
|
+
const evaluation_1 = require("../runtime/rsi/evaluation");
|
|
6
|
+
const lifecycle_1 = require("../runtime/rsi/lifecycle");
|
|
7
|
+
const proposal_1 = require("../runtime/rsi/proposal");
|
|
8
|
+
const receipt_1 = require("../runtime/rsi/receipt");
|
|
9
|
+
const trajectory_1 = require("../runtime/rsi/trajectory");
|
|
10
|
+
const triage_1 = require("../runtime/rsi/triage");
|
|
11
|
+
const HELP = `Orion RSI Skill optimization
|
|
12
|
+
|
|
13
|
+
orion rsi triage [--repo <project-root>] [--limit <1–48>]
|
|
14
|
+
orion rsi propose --input <selection.json> --out <run>
|
|
15
|
+
orion rsi run --target skill --input <selection.json> --suite <suite.json> --out <run>
|
|
16
|
+
orion rsi evaluate --run <run> --suite <suite.json>
|
|
17
|
+
orion rsi resume --run <run>
|
|
18
|
+
orion rsi status --run <run> [--json]
|
|
19
|
+
orion rsi apply --run <run> --candidate <digest> --worktree <review-worktree>
|
|
20
|
+
orion rsi accept --run <run> --commit <sha>
|
|
21
|
+
orion rsi observe --run <run> --input <follow-up.json>
|
|
22
|
+
orion rsi rollback --run <run> --worktree <review-worktree> [--commit <sha>]
|
|
23
|
+
|
|
24
|
+
Evaluation stops for manual review. Apply and rollback stage no Git changes.`;
|
|
25
|
+
function readFlags(args, names, optional = []) {
|
|
26
|
+
const flags = new Map();
|
|
27
|
+
for (let index = 0; index < args.length; index += 2) {
|
|
28
|
+
const key = args[index];
|
|
29
|
+
const value = args[index + 1];
|
|
30
|
+
if ((!names.includes(key) && !optional.includes(key)) ||
|
|
31
|
+
!value ||
|
|
32
|
+
value.startsWith('--') ||
|
|
33
|
+
flags.has(key)) {
|
|
34
|
+
throw new Error(`Invalid RSI arguments. Expected ${names.join(' and ')}.`);
|
|
35
|
+
}
|
|
36
|
+
flags.set(key, value);
|
|
37
|
+
}
|
|
38
|
+
if (names.some(name => !flags.has(name)))
|
|
39
|
+
throw new Error(`Required RSI options ${names.join(', ')}.`);
|
|
40
|
+
return flags;
|
|
41
|
+
}
|
|
42
|
+
function formatReceipt(receipt, phase, evaluation) {
|
|
43
|
+
const lines = [
|
|
44
|
+
`RSI ${phase.replace(/_/gu, ' ')}`,
|
|
45
|
+
`Decision ${receipt.proposal.decision}`,
|
|
46
|
+
`Selected turns ${receipt.evidence.length}`,
|
|
47
|
+
`Evaluation ${evaluation}`,
|
|
48
|
+
`Proposal receipt ${receipt.digest}`,
|
|
49
|
+
];
|
|
50
|
+
if ('reason' in receipt.proposal)
|
|
51
|
+
lines.push(`Reason ${receipt.proposal.reason}`);
|
|
52
|
+
if ('diagnosis' in receipt.proposal)
|
|
53
|
+
lines.push(`Evidence ${receipt.proposal.diagnosis}`);
|
|
54
|
+
if ('verification' in receipt.proposal)
|
|
55
|
+
lines.push(`Verify ${receipt.proposal.verification}`);
|
|
56
|
+
if ('path' in receipt.proposal) {
|
|
57
|
+
lines.push(`Skill ${receipt.proposal.path}`, `Candidate ${receipt.proposal.candidateContentDigest}`);
|
|
58
|
+
}
|
|
59
|
+
return lines.join('\n');
|
|
60
|
+
}
|
|
61
|
+
function writeStatus(directory, asJson = false) {
|
|
62
|
+
const receipt = (0, receipt_1.readRsiReceipt)(directory);
|
|
63
|
+
const comparison = (0, evaluation_1.readRsiComparison)(directory, receipt.digest);
|
|
64
|
+
const lifecycle = (0, lifecycle_1.readRsiLifecycle)(directory, receipt.digest, comparison?.digest);
|
|
65
|
+
const phase = lifecycle?.phase ?? comparison?.phase ?? receipt.phase;
|
|
66
|
+
const evaluation = comparison?.verdict ?? comparison?.phase ?? receipt.evaluation;
|
|
67
|
+
const followUp = lifecycle && 'path' in receipt.proposal
|
|
68
|
+
? (0, lifecycle_1.summarizeRsiObservations)(lifecycle, receipt.proposal.category)
|
|
69
|
+
: undefined;
|
|
70
|
+
const summary = [
|
|
71
|
+
formatReceipt(receipt, phase, evaluation),
|
|
72
|
+
...(comparison
|
|
73
|
+
? [
|
|
74
|
+
`Paired evaluation ${comparison.pairs.filter(pair => pair.state === 'complete').length}/${comparison.pairs.length} recorded pairs`,
|
|
75
|
+
]
|
|
76
|
+
: []),
|
|
77
|
+
...(lifecycle?.accepted ? [`Accepted commit ${lifecycle.accepted.commit}`] : []),
|
|
78
|
+
...(lifecycle?.rollback?.commit ? [`Rollback commit ${lifecycle.rollback.commit}`] : []),
|
|
79
|
+
...(followUp
|
|
80
|
+
? [
|
|
81
|
+
`Follow-up recurrences ${followUp.recurrences}/${followUp.turns}, ${followUp.toolCalls} tool calls`,
|
|
82
|
+
]
|
|
83
|
+
: []),
|
|
84
|
+
].join('\n');
|
|
85
|
+
process.stdout.write(`${asJson ? JSON.stringify({ ...receipt, phase, evaluation, comparison, lifecycle, followUp }, null, 2) : summary}\n`);
|
|
86
|
+
}
|
|
87
|
+
async function runEvaluation(directory, suite) {
|
|
88
|
+
const abort = new AbortController();
|
|
89
|
+
const cancel = () => abort.abort();
|
|
90
|
+
process.once('SIGINT', cancel);
|
|
91
|
+
process.once('SIGTERM', cancel);
|
|
92
|
+
try {
|
|
93
|
+
await (0, evaluation_1.evaluateRsi)(directory, suite, abort.signal);
|
|
94
|
+
writeStatus(directory);
|
|
95
|
+
if (abort.signal.aborted)
|
|
96
|
+
process.exitCode = 130;
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
process.off('SIGINT', cancel);
|
|
100
|
+
process.off('SIGTERM', cancel);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function runRsiCommand(args) {
|
|
104
|
+
const [action, ...flags] = args;
|
|
105
|
+
if (!action || action === '--help' || action === '-h') {
|
|
106
|
+
process.stdout.write(`${HELP}\n`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (action === 'triage') {
|
|
110
|
+
const options = readFlags(flags, [], ['--repo', '--limit']);
|
|
111
|
+
const report = (0, triage_1.triageRsiProject)(options.get('--repo'), Number(options.get('--limit') ?? '16'));
|
|
112
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
if (action === 'status') {
|
|
116
|
+
const asJson = flags.includes('--json');
|
|
117
|
+
const options = readFlags(flags.filter(flag => flag !== '--json'), ['--run']);
|
|
118
|
+
writeStatus(options.get('--run'), asJson);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (action === 'evaluate' || action === 'resume') {
|
|
122
|
+
const options = readFlags(flags, action === 'evaluate' ? ['--run', '--suite'] : ['--run']);
|
|
123
|
+
await runEvaluation(options.get('--run'), options.get('--suite'));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (action === 'apply' || action === 'accept' || action === 'observe' || action === 'rollback') {
|
|
127
|
+
const required = {
|
|
128
|
+
apply: ['--candidate', '--worktree'],
|
|
129
|
+
accept: ['--commit'],
|
|
130
|
+
observe: ['--input'],
|
|
131
|
+
rollback: ['--worktree'],
|
|
132
|
+
};
|
|
133
|
+
const options = readFlags(flags, ['--run', ...required[action]], action === 'rollback' ? ['--commit'] : []);
|
|
134
|
+
const directory = options.get('--run');
|
|
135
|
+
switch (action) {
|
|
136
|
+
case 'apply':
|
|
137
|
+
await (0, lifecycle_1.advanceRsi)(directory, {
|
|
138
|
+
action,
|
|
139
|
+
candidate: options.get('--candidate'),
|
|
140
|
+
worktree: options.get('--worktree'),
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
case 'accept':
|
|
144
|
+
await (0, lifecycle_1.advanceRsi)(directory, { action, commit: options.get('--commit') });
|
|
145
|
+
break;
|
|
146
|
+
case 'observe':
|
|
147
|
+
await (0, lifecycle_1.advanceRsi)(directory, { action, input: options.get('--input') });
|
|
148
|
+
break;
|
|
149
|
+
case 'rollback':
|
|
150
|
+
await (0, lifecycle_1.advanceRsi)(directory, {
|
|
151
|
+
action,
|
|
152
|
+
worktree: options.get('--worktree'),
|
|
153
|
+
commit: options.get('--commit'),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
writeStatus(directory);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (action !== 'propose' && action !== 'run')
|
|
160
|
+
throw new Error('Unknown RSI subcommand. Use orion rsi --help.');
|
|
161
|
+
const options = readFlags(flags, action === 'run' ? ['--target', '--input', '--suite', '--out'] : ['--input', '--out']);
|
|
162
|
+
if (action === 'run' && options.get('--target') !== 'skill') {
|
|
163
|
+
throw new Error('RSI supports the skill target.');
|
|
164
|
+
}
|
|
165
|
+
const selection = (0, trajectory_1.parseRsiSelection)((0, receipt_1.readRsiJson)(options.get('--input')));
|
|
166
|
+
const repository = (0, proposal_1.resolveRsiBase)(selection);
|
|
167
|
+
const normalized = { ...selection, repository };
|
|
168
|
+
const evidence = (0, trajectory_1.collectRsiEvidence)(normalized);
|
|
169
|
+
const proposal = await (0, proposal_1.proposeRsiSkill)(repository, selection.baseCommit, evidence);
|
|
170
|
+
const receipt = (0, receipt_1.buildRsiReceipt)(repository, (0, canonical_1.digestRuntimeValue)(normalized), evidence, proposal);
|
|
171
|
+
const directory = options.get('--out');
|
|
172
|
+
(0, receipt_1.writeRsiReceipt)(directory, receipt);
|
|
173
|
+
if (action === 'run' && 'patch' in proposal) {
|
|
174
|
+
await runEvaluation(directory, options.get('--suite'));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
writeStatus(directory);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=rsi-command.js.map
|
|
@@ -14,6 +14,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
14
14
|
const ui_view_model_1 = require("../runtime/ui-view-model");
|
|
15
15
|
const legacy_thread_materializer_1 = require("../runtime/legacy-thread-materializer");
|
|
16
16
|
const thread_session_view_1 = require("../runtime/thread-session-view");
|
|
17
|
+
const thread_session_index_1 = require("../runtime/thread-session-index");
|
|
17
18
|
const format_1 = require("../services/format");
|
|
18
19
|
const session_storage_1 = require("../services/session-storage");
|
|
19
20
|
const session_index_1 = require("../services/session-index");
|
|
@@ -27,7 +28,6 @@ const ERROR = chalk_1.default.red;
|
|
|
27
28
|
const WARN = chalk_1.default.yellow;
|
|
28
29
|
const SUCCESS = chalk_1.default.green;
|
|
29
30
|
const HEADER = chalk_1.default.cyan.bold;
|
|
30
|
-
const RESUME_TRANSCRIPT_WINDOW_MESSAGES = 50;
|
|
31
31
|
const RESUME_TRANSCRIPT_WINDOW_BYTES = 256 * 1024;
|
|
32
32
|
const RESUME_TRANSCRIPT_ENTRY_BYTES = 64 * 1024;
|
|
33
33
|
const RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES = 128;
|
|
@@ -37,29 +37,31 @@ const RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES = 128;
|
|
|
37
37
|
* intentional: one very large tool result must not turn /resume back into an
|
|
38
38
|
* unbounded terminal or JSON operation.
|
|
39
39
|
*/
|
|
40
|
-
function createResumeTranscriptWindow(sessionId, messages) {
|
|
40
|
+
function createResumeTranscriptWindow(sessionId, messages, totalEntries = messages.length) {
|
|
41
41
|
const entries = [];
|
|
42
42
|
let bytes = 0;
|
|
43
43
|
let contentTruncated = false;
|
|
44
|
-
for (let index = messages.length - 1; index >= 0 && entries.length < RESUME_TRANSCRIPT_WINDOW_MESSAGES; index -= 1) {
|
|
44
|
+
for (let index = messages.length - 1; index >= 0 && entries.length < thread_session_index_1.RESUME_TRANSCRIPT_WINDOW_MESSAGES; index -= 1) {
|
|
45
45
|
const remaining = RESUME_TRANSCRIPT_WINDOW_BYTES - bytes - RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES;
|
|
46
46
|
if (remaining < 256)
|
|
47
47
|
break;
|
|
48
48
|
const message = messages[index];
|
|
49
49
|
const projected = truncateUtf8ForResume(message.content, Math.min(remaining, RESUME_TRANSCRIPT_ENTRY_BYTES));
|
|
50
50
|
contentTruncated || (contentTruncated = projected.truncated);
|
|
51
|
+
const display = 'id' in message ? message : undefined;
|
|
51
52
|
const entry = {
|
|
52
53
|
id: `resume:${sessionId}:${index + 1}`,
|
|
53
54
|
role: message.role,
|
|
54
55
|
content: projected.value,
|
|
55
|
-
|
|
56
|
+
title: display?.title ?? (message.role === 'user' ? 'you' : undefined),
|
|
57
|
+
...(display?.toolActivity ? { toolActivity: display.toolActivity } : {}),
|
|
56
58
|
};
|
|
57
59
|
entries.unshift(entry);
|
|
58
60
|
bytes += Buffer.byteLength(projected.value, 'utf8') + RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES;
|
|
59
61
|
}
|
|
60
62
|
return Object.freeze({
|
|
61
63
|
entries: Object.freeze(entries),
|
|
62
|
-
truncated: contentTruncated || entries.length <
|
|
64
|
+
truncated: contentTruncated || entries.length < totalEntries,
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
67
|
function truncateUtf8ForResume(value, maxBytes) {
|
|
@@ -361,7 +363,9 @@ async function handleResume(ctx, args) {
|
|
|
361
363
|
: (0, session_storage_1.listProjectSessions)(scope.projectPath);
|
|
362
364
|
const scopedSessions = (0, session_storage_1.filterSessionsWithRestorableHistory)(allScopedSessions);
|
|
363
365
|
if (!sessionRef) {
|
|
364
|
-
const lastSession =
|
|
366
|
+
const lastSession = scope.last && !scope.allProjects
|
|
367
|
+
? (0, session_storage_1.getLastSession)(scope.projectPath, scopedSessions)
|
|
368
|
+
: scopedSessions[0];
|
|
365
369
|
if (!lastSession) {
|
|
366
370
|
return {
|
|
367
371
|
success: false,
|
|
@@ -421,14 +425,15 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
421
425
|
const history = historyResult.messages.map(message => structuredClone(message));
|
|
422
426
|
const recoveryWarnings = historyResult.diagnostics.map(diagnostic => diagnostic.message);
|
|
423
427
|
const transcriptMessages = restoredView.transcriptMessages;
|
|
424
|
-
const
|
|
428
|
+
const transcriptDisplayCount = restoredView.resumeDisplay?.totalEntries ?? transcriptMessages.length;
|
|
429
|
+
const transcriptWindow = createResumeTranscriptWindow(session.id, restoredView.resumeDisplay?.entries ?? transcriptMessages, restoredView.resumeDisplay?.totalEntries);
|
|
425
430
|
const visibleTranscriptMessages = ctx.uiRenderer === 'web'
|
|
426
|
-
? Math.min(RESUME_TRANSCRIPT_WINDOW_MESSAGES, transcriptMessages.length)
|
|
431
|
+
? Math.min(thread_session_index_1.RESUME_TRANSCRIPT_WINDOW_MESSAGES, transcriptMessages.length)
|
|
427
432
|
: ctx.replaceTranscript
|
|
428
433
|
? transcriptWindow.entries.length
|
|
429
434
|
: 0;
|
|
430
435
|
const transcriptTruncated = ctx.uiRenderer === 'web'
|
|
431
|
-
? transcriptMessages.length > RESUME_TRANSCRIPT_WINDOW_MESSAGES
|
|
436
|
+
? transcriptMessages.length > thread_session_index_1.RESUME_TRANSCRIPT_WINDOW_MESSAGES
|
|
432
437
|
: ctx.replaceTranscript
|
|
433
438
|
? transcriptWindow.truncated
|
|
434
439
|
: transcriptMessages.length > 0;
|
|
@@ -446,11 +451,11 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
446
451
|
throw new Error(`Session ${session.id} did not produce a verified Thread activation.`);
|
|
447
452
|
}
|
|
448
453
|
}
|
|
449
|
-
const
|
|
454
|
+
const selected = (0, session_storage_1.loadSessionMeta)(session.id) ?? { ...session };
|
|
450
455
|
// Swap in the resumed session's transcript BEFORE emitting any command output,
|
|
451
456
|
// so the output is appended after the history rather than wiped by the
|
|
452
457
|
// transcript replacement below.
|
|
453
|
-
ctx.setSession?.(
|
|
458
|
+
ctx.setSession?.(selected);
|
|
454
459
|
// Notify runtime/TUI consumers only after the target view is validated.
|
|
455
460
|
const resumeGeneratedAt = Date.now();
|
|
456
461
|
const summary = checkpoint?.summary.text ?? (history.length > 0 ? generateHistorySummary(history) : '');
|
|
@@ -461,10 +466,16 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
461
466
|
ctx.store.setState({ harnessState: restoredHarnessState });
|
|
462
467
|
}
|
|
463
468
|
if (history.length > 0) {
|
|
464
|
-
const eventSummary = checkpoint?.summary.text ?? generateRestoredSessionEventSummary(history);
|
|
465
469
|
ctx.store.setState({ conversationHistory: history });
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
}
|
|
471
|
+
await ctx.restoreSessionRuntime?.(runtimeActivation);
|
|
472
|
+
// The runner needs the selected ID before it can acquire Thread ownership.
|
|
473
|
+
// A rejected activation leaves the saved session's lifecycle and recent hint intact.
|
|
474
|
+
const resumed = (0, session_storage_1.resumeSession)(selected.id) ?? selected;
|
|
475
|
+
Object.assign(selected, resumed);
|
|
476
|
+
ctx.replaceTranscript?.(transcriptWindow.entries);
|
|
477
|
+
if (history.length > 0) {
|
|
478
|
+
const eventSummary = checkpoint?.summary.text ?? generateRestoredSessionEventSummary(history);
|
|
468
479
|
ctx.sessionRestored?.({
|
|
469
480
|
sessionId: resumed.id,
|
|
470
481
|
projectPath: resumed.projectPath,
|
|
@@ -476,15 +487,13 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
476
487
|
summarySource,
|
|
477
488
|
summaryCoveredMessages,
|
|
478
489
|
checkpointId: checkpoint?.checkpointId,
|
|
479
|
-
transcriptMessages:
|
|
490
|
+
transcriptMessages: transcriptDisplayCount,
|
|
480
491
|
visibleTranscriptMessages,
|
|
481
492
|
transcriptTruncated,
|
|
482
493
|
...(recoveryWarnings.length > 0 ? { warnings: recoveryWarnings } : {}),
|
|
483
494
|
});
|
|
484
495
|
}
|
|
485
496
|
else {
|
|
486
|
-
await ctx.restoreSessionRuntime?.(runtimeActivation);
|
|
487
|
-
ctx.replaceTranscript?.(transcriptWindow.entries);
|
|
488
497
|
ctx.sessionRestored?.({
|
|
489
498
|
sessionId: resumed.id,
|
|
490
499
|
projectPath: resumed.projectPath,
|
|
@@ -495,7 +504,7 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
495
504
|
summarySource,
|
|
496
505
|
summaryCoveredMessages,
|
|
497
506
|
checkpointId: checkpoint?.checkpointId,
|
|
498
|
-
transcriptMessages:
|
|
507
|
+
transcriptMessages: transcriptDisplayCount,
|
|
499
508
|
visibleTranscriptMessages,
|
|
500
509
|
transcriptTruncated,
|
|
501
510
|
...(recoveryWarnings.length > 0 ? { warnings: recoveryWarnings } : {}),
|
|
@@ -517,7 +526,7 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
517
526
|
bannerLines.push(` Summary: ${summary}`);
|
|
518
527
|
bannerLines.push(` Generated: ${new Date(summaryGeneratedAt).toLocaleString()} (${checkpoint ? 'compact checkpoint' : 'generated on resume'})`);
|
|
519
528
|
bannerLines.push(` Covers: ${summaryCoveredMessages} source messages`);
|
|
520
|
-
bannerLines.push(`✔ Restored ${history.length} model-context messages / ${
|
|
529
|
+
bannerLines.push(`✔ Restored ${history.length} model-context messages / ${transcriptDisplayCount} transcript messages`);
|
|
521
530
|
if (transcriptTruncated) {
|
|
522
531
|
bannerLines.push(visibleTranscriptMessages > 0
|
|
523
532
|
? ` Display: showing recent ${visibleTranscriptMessages}; older transcript remains durable`
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseTargetCommand = parseTargetCommand;
|
|
4
4
|
exports.isTargetCommand = isTargetCommand;
|
|
5
5
|
const MAX_GOAL_OBJECTIVE_CHARS = 4000;
|
|
6
|
+
const GOAL_USAGE = 'Usage: /goal [objective|status|pause|resume|budget|clear]';
|
|
7
|
+
const BUDGET_USAGE = 'Usage: /goal budget [--max-tokens N] [--max-elapsed-ms N]';
|
|
6
8
|
/** Parse the v0.2 Goal surface. `/target` and legacy mutations are breaking-cut removed. */
|
|
7
9
|
function parseTargetCommand(rawInput) {
|
|
8
10
|
const input = rawInput.trim();
|
|
9
11
|
if (!/^\/goal(?:\s|$)/u.test(input)) {
|
|
10
|
-
return { ok: false, error:
|
|
12
|
+
return { ok: false, error: GOAL_USAGE };
|
|
11
13
|
}
|
|
12
14
|
const rest = input.slice('/goal'.length).trim();
|
|
13
15
|
if (!rest || rest === 'status') {
|
|
@@ -16,20 +18,61 @@ function parseTargetCommand(rawInput) {
|
|
|
16
18
|
if (rest === 'pause' || rest === 'resume' || rest === 'clear') {
|
|
17
19
|
return { ok: true, input: { type: 'goal_control', action: rest } };
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
if (/^budget(?:\s|$)/u.test(rest)) {
|
|
22
|
+
const budget = parseBudgetFlags(rest.slice('budget'.length));
|
|
23
|
+
return budget
|
|
24
|
+
? { ok: true, input: { type: 'goal_control', action: 'budget', budget } }
|
|
25
|
+
: { ok: false, error: BUDGET_USAGE };
|
|
26
|
+
}
|
|
27
|
+
const removed = /^(?:exit|confirm|edit|replace)(?:\s|$)|^clear\s+/u.test(rest);
|
|
20
28
|
if (removed) {
|
|
21
29
|
return {
|
|
22
30
|
ok: false,
|
|
23
|
-
error:
|
|
31
|
+
error: `Unsupported Goal command. ${GOAL_USAGE}`,
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
|
-
|
|
34
|
+
const withBudget = /^(--(?:max-tokens|max-elapsed-ms)\b[\s\S]*?)\s+--\s+([\s\S]+)$/u.exec(rest);
|
|
35
|
+
const budget = withBudget && parseBudgetFlags(withBudget[1]);
|
|
36
|
+
if (/^--(?:max-tokens|max-elapsed-ms)\b/u.test(rest) && !budget) {
|
|
27
37
|
return {
|
|
28
38
|
ok: false,
|
|
29
|
-
error:
|
|
39
|
+
error: 'Usage: /goal [--max-tokens N] [--max-elapsed-ms N] -- <objective>',
|
|
30
40
|
};
|
|
31
41
|
}
|
|
32
|
-
|
|
42
|
+
const objective = withBudget?.[2].trim() ?? rest;
|
|
43
|
+
if (objective.length > MAX_GOAL_OBJECTIVE_CHARS) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
error: `Objective too long (${objective.length} chars, max ${MAX_GOAL_OBJECTIVE_CHARS}).`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ok: true,
|
|
51
|
+
input: { type: 'goal_control', action: 'create', objective, ...(budget ? { budget } : {}) },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function parseBudgetFlags(raw) {
|
|
55
|
+
const parts = raw.trim().split(/\s+/u);
|
|
56
|
+
if (parts.length !== 2 && parts.length !== 4)
|
|
57
|
+
return undefined;
|
|
58
|
+
const budget = {};
|
|
59
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
60
|
+
const flag = parts[i];
|
|
61
|
+
const key = flag === '--max-tokens'
|
|
62
|
+
? 'maxTokens'
|
|
63
|
+
: flag === '--max-elapsed-ms'
|
|
64
|
+
? 'maxElapsedMs'
|
|
65
|
+
: undefined;
|
|
66
|
+
const amount = Number(parts[i + 1]);
|
|
67
|
+
if (!key ||
|
|
68
|
+
budget[key] !== undefined ||
|
|
69
|
+
!/^[0-9]+$/u.test(parts[i + 1]) ||
|
|
70
|
+
!Number.isSafeInteger(amount) ||
|
|
71
|
+
amount < 1)
|
|
72
|
+
return undefined;
|
|
73
|
+
budget[key] = amount;
|
|
74
|
+
}
|
|
75
|
+
return budget;
|
|
33
76
|
}
|
|
34
77
|
function isTargetCommand(input) {
|
|
35
78
|
return /^\/goal(?:\s|$)/u.test(input.trimStart());
|
|
@@ -33,7 +33,7 @@ exports.TOOL_COMMANDS = [
|
|
|
33
33
|
type: 'builtin',
|
|
34
34
|
execution: 'builtin',
|
|
35
35
|
risk: 'read-only',
|
|
36
|
-
execute:
|
|
36
|
+
execute: () => (0, context_tool_command_handlers_1.showSafety)(),
|
|
37
37
|
},
|
|
38
38
|
];
|
|
39
39
|
//# sourceMappingURL=tool-commands.js.map
|
package/dist/commands/types.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface CommandContext {
|
|
|
26
26
|
compactCoordinator?: CompactCoordinator;
|
|
27
27
|
/** Transactional model/profile switch owner. */
|
|
28
28
|
modelCoordinator?: ModelCoordinator;
|
|
29
|
-
/** Shared
|
|
29
|
+
/** Shared session controls for model and effort selection. */
|
|
30
30
|
sessionComposerControls?: SessionComposerControlServiceV1;
|
|
31
31
|
/** 当前会话 ID(用于记录消息) */
|
|
32
32
|
sessionId?: string;
|
|
@@ -64,6 +64,8 @@ export interface CommandContext {
|
|
|
64
64
|
agentModeLifecycle?: import('../framework/agent-mode').AgentModeLifecycleController;
|
|
65
65
|
/** Read-only v0.2 runtime diagnostics; does not activate lazy Skill or MCP providers. */
|
|
66
66
|
getHarnessDiagnostics?: () => Promise<OrionRuntimeDiagnosticsV1 | undefined>;
|
|
67
|
+
/** Count durable conversation turns in the active Session. */
|
|
68
|
+
getConversationTurnCount?: () => number | undefined;
|
|
67
69
|
/** Product-owned durable Settings authority; commands must never construct their own. */
|
|
68
70
|
settingsCoordinator?: SettingsCoordinatorV1;
|
|
69
71
|
/** Describe effective Settings with current Session overrides. */
|
|
@@ -104,16 +106,8 @@ export interface CommandParam {
|
|
|
104
106
|
export type CommandType = 'builtin' | 'tool' | 'chat';
|
|
105
107
|
/** Command category used by palettes and grouped help output. */
|
|
106
108
|
export type CommandCategory = 'workflow' | 'session' | 'context' | 'tools' | 'model' | 'system' | 'diagnostics' | 'legacy';
|
|
107
|
-
/**
|
|
108
|
-
export type PermissionMode = 'default' | 'acceptEdits' | 'plan' | 'auto';
|
|
109
|
-
/** Agent working mode. This is deliberately independent from tool confirmation policy. */
|
|
109
|
+
/** Agent working mode. */
|
|
110
110
|
export type AgentMode = 'interactive' | 'plan' | 'auto';
|
|
111
|
-
/** Permission mode cycle order */
|
|
112
|
-
export declare const PERMISSION_MODES: PermissionMode[];
|
|
113
|
-
/** Get next permission mode in cycle order */
|
|
114
|
-
export declare function getNextPermissionMode(current: PermissionMode): PermissionMode;
|
|
115
|
-
/** Get the legacy renderer label for the current Agent mode. */
|
|
116
|
-
export declare function getModeDisplayText(mode: AgentMode): string;
|
|
117
111
|
/** Command execution classification. */
|
|
118
112
|
export type CommandExecution = 'builtin' | 'agent-workflow' | 'renderer-local';
|
|
119
113
|
/** Product audience used to keep compatibility and internal commands out of default surfaces. */
|
package/dist/commands/types.js
CHANGED
|
@@ -6,27 +6,7 @@
|
|
|
6
6
|
* 非 `/` 前缀的输入直接作为 chat 消息处理。
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.DEFAULT_COMMAND_RISK = exports.ALL_RENDERER_SCOPES =
|
|
10
|
-
exports.getNextPermissionMode = getNextPermissionMode;
|
|
11
|
-
exports.getModeDisplayText = getModeDisplayText;
|
|
12
|
-
/** Permission mode cycle order */
|
|
13
|
-
exports.PERMISSION_MODES = ['default', 'acceptEdits', 'plan', 'auto'];
|
|
14
|
-
/** Get next permission mode in cycle order */
|
|
15
|
-
function getNextPermissionMode(current) {
|
|
16
|
-
const idx = exports.PERMISSION_MODES.indexOf(current);
|
|
17
|
-
return exports.PERMISSION_MODES[(idx + 1) % exports.PERMISSION_MODES.length];
|
|
18
|
-
}
|
|
19
|
-
/** Get the legacy renderer label for the current Agent mode. */
|
|
20
|
-
function getModeDisplayText(mode) {
|
|
21
|
-
switch (mode) {
|
|
22
|
-
case 'plan':
|
|
23
|
-
return 'plan mode on';
|
|
24
|
-
case 'auto':
|
|
25
|
-
return 'auto mode';
|
|
26
|
-
default:
|
|
27
|
-
return 'interactive mode';
|
|
28
|
-
}
|
|
29
|
-
}
|
|
9
|
+
exports.DEFAULT_COMMAND_RISK = exports.ALL_RENDERER_SCOPES = void 0;
|
|
30
10
|
/** List of renderers that a command scope can apply to. */
|
|
31
11
|
exports.ALL_RENDERER_SCOPES = ['tui', 'terminal', 'print', 'web'];
|
|
32
12
|
/** Default risk when no explicit metadata is present on a command. */
|
|
@@ -28,7 +28,8 @@ async function handlePlan(ctx, args) {
|
|
|
28
28
|
output: `Plan ${state.planDigest.slice(0, 12)} · ${state.status} · revision ${state.revision}`,
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
if (state.status
|
|
31
|
+
if (state.status === 'cancelled' ||
|
|
32
|
+
(subcommand !== 'cancel' && state.status !== 'awaiting_review')) {
|
|
32
33
|
return { success: false, error: `Plan review is already ${state.status}.` };
|
|
33
34
|
}
|
|
34
35
|
const feedback = tail.join(' ').trim();
|
|
@@ -41,6 +42,8 @@ async function handlePlan(ctx, args) {
|
|
|
41
42
|
action,
|
|
42
43
|
...(feedback ? { feedback } : {}),
|
|
43
44
|
});
|
|
45
|
+
if (action === 'cancel')
|
|
46
|
+
ctx.store.setState({ currentPlan: null });
|
|
44
47
|
const nextMode = action === 'approve' ? 'interactive' : action === 'continue' ? 'plan' : null;
|
|
45
48
|
if (nextMode) {
|
|
46
49
|
if (ctx.agentModeLifecycle)
|
|
@@ -114,12 +117,13 @@ async function handleReview(ctx, args) {
|
|
|
114
117
|
};
|
|
115
118
|
}
|
|
116
119
|
const llm = ctx.llm;
|
|
120
|
+
const fileLabels = new Map();
|
|
117
121
|
const outcome = await (0, runner_1.runCodeReview)({
|
|
118
122
|
cwd: ctx.cwd,
|
|
119
123
|
selector: parsed.selector,
|
|
120
124
|
adapter: {
|
|
121
|
-
async complete(messages) {
|
|
122
|
-
const response = await llm.chat(messages.map(message => ({ role: message.role, content: message.content })));
|
|
125
|
+
async complete(messages, abortSignal) {
|
|
126
|
+
const response = await llm.chat(messages.map(message => ({ role: message.role, content: message.content })), undefined, { abortSignal });
|
|
123
127
|
return {
|
|
124
128
|
content: response.content,
|
|
125
129
|
model: response.model,
|
|
@@ -136,6 +140,11 @@ async function handleReview(ctx, args) {
|
|
|
136
140
|
threadId: ctx.sessionId ?? 'pending-session',
|
|
137
141
|
turnId: String(ctx.turnId ?? 'ad-hoc'),
|
|
138
142
|
},
|
|
143
|
+
onSnapshotCaptured(snapshot) {
|
|
144
|
+
for (const file of snapshot.files) {
|
|
145
|
+
fileLabels.set(file.fileKey, { old: file.oldPath ?? file.path, new: file.path });
|
|
146
|
+
}
|
|
147
|
+
},
|
|
139
148
|
...(ctx.abortSignal ? { abortSignal: ctx.abortSignal } : {}),
|
|
140
149
|
});
|
|
141
150
|
if (!outcome.ok) {
|
|
@@ -156,6 +165,6 @@ async function handleReview(ctx, args) {
|
|
|
156
165
|
}
|
|
157
166
|
return { success: false, error: `Review output could not be parsed: ${failure.message}` };
|
|
158
167
|
}
|
|
159
|
-
return { success: true, output: (0, format_1.formatReviewReport)(outcome.result) };
|
|
168
|
+
return { success: true, output: (0, format_1.formatReviewReport)(outcome.result, fileLabels) };
|
|
160
169
|
}
|
|
161
170
|
//# sourceMappingURL=workflow-command-handlers.js.map
|
|
@@ -7,8 +7,8 @@ const context_tool_command_handlers_1 = require("./context-tool-command-handlers
|
|
|
7
7
|
exports.WORKFLOW_COMMANDS = [
|
|
8
8
|
{
|
|
9
9
|
name: 'goal',
|
|
10
|
-
description: 'Create, inspect,
|
|
11
|
-
argumentHint: '[objective | status | pause | resume | clear]',
|
|
10
|
+
description: 'Create, inspect, resume, or adjust the budget of a durable Goal',
|
|
11
|
+
argumentHint: '[objective | status | pause | resume | budget | clear]',
|
|
12
12
|
category: 'workflow',
|
|
13
13
|
priority: 3,
|
|
14
14
|
type: 'builtin',
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
export type LoopBudgetBaseProfile = 'default' | 'complex' | 'release';
|
|
2
2
|
export type LoopBudgetSource = LoopBudgetBaseProfile | 'config';
|
|
3
3
|
export interface LoopBudget {
|
|
4
|
-
/**
|
|
5
|
-
maxLlmRequestsPerUserTurn: number;
|
|
6
|
-
/** Maximum tool calls allowed for one user turn before stopping. */
|
|
7
|
-
maxToolCallsPerUserTurn: number;
|
|
8
|
-
/** Consecutive single read-only tool turns before injecting a batch_read hint. */
|
|
9
|
-
maxReadOnlyFragmentation: number;
|
|
10
|
-
/** Maximum aggregate tool-result bytes exposed to the model in one user turn. */
|
|
4
|
+
/** Shared compression allowance; each result retains up to 2 KiB recovery visibility after exhaustion. */
|
|
11
5
|
maxModelVisibleToolBytes: number;
|
|
12
6
|
/** Budget source after config overrides are applied. */
|
|
13
7
|
profile?: LoopBudgetSource;
|
|
14
|
-
/**
|
|
8
|
+
/** Profile selected before config overrides, when applicable. */
|
|
15
9
|
baseProfile?: LoopBudgetBaseProfile;
|
|
16
10
|
/** Whether user/global/env config changed one or more numeric budget fields. */
|
|
17
11
|
configOverride?: boolean;
|
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_LOOP_BUDGET = void 0;
|
|
4
4
|
exports.DEFAULT_LOOP_BUDGET = Object.freeze({
|
|
5
|
-
maxLlmRequestsPerUserTurn: 24,
|
|
6
|
-
maxToolCallsPerUserTurn: 120,
|
|
7
|
-
maxReadOnlyFragmentation: 3,
|
|
8
5
|
maxModelVisibleToolBytes: 64 * 1024,
|
|
9
6
|
profile: 'default',
|
|
10
7
|
baseProfile: 'default',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolExternalAssertion } from './external-assertion';
|
|
2
|
+
interface LoopObservation {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
5
|
+
readonly output: string;
|
|
6
|
+
readonly fileEdit?: boolean;
|
|
7
|
+
readonly assertion?: ToolExternalAssertion;
|
|
8
|
+
}
|
|
9
|
+
/** Distinct evidence observations for diagnostics. They do not govern sampling or tool execution. */
|
|
10
|
+
export declare class LoopProgress {
|
|
11
|
+
private readonly cwd;
|
|
12
|
+
private readonly seen;
|
|
13
|
+
constructor(cwd: string);
|
|
14
|
+
get observations(): number;
|
|
15
|
+
observe(observation: LoopObservation): void;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=loop-progress.d.ts.map
|