@temmo/cli 0.0.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +14 -0
- package/.claude-plugin/plugin.json +16 -0
- package/.codex-plugin/plugin.json +30 -0
- package/.cursor-plugin/plugin.json +22 -0
- package/.mcp.json +18 -0
- package/LICENSE +202 -0
- package/README.md +82 -2
- package/THIRD_PARTY_NOTICES +32 -0
- package/commands/afk.md +17 -0
- package/deploy/build-ui.mjs +65 -0
- package/deploy/claude/README.md +16 -0
- package/deploy/claude/auto-mode.json +31 -0
- package/deploy/postgres/compose.yaml +26 -0
- package/deploy/temmo-runner.service +24 -0
- package/deploy/verify-ui.mjs +15 -0
- package/harness-core/README.md +27 -0
- package/harness-core/bin/harness.mjs +17 -0
- package/harness-core/package.json +10 -0
- package/harness-core/stage.mjs +108 -0
- package/harness-core/stages/commit.md +7 -0
- package/harness-core/stages/pr.md +7 -0
- package/harness-core/stages/push.md +7 -0
- package/hooks/codex-hooks.json +14 -0
- package/hooks/cursor-hooks.json +17 -0
- package/hooks/hooks.json +27 -0
- package/lib/acp/permission.js +72 -0
- package/lib/acp/sessionConfig.js +109 -0
- package/lib/activity.js +244 -0
- package/lib/agent-guard.js +72 -0
- package/lib/agents-route.js +55 -0
- package/lib/agents.js +213 -0
- package/lib/agui.js +255 -0
- package/lib/alerts.js +36 -0
- package/lib/analyze-otlp.js +46 -0
- package/lib/analyze-run-code.js +397 -0
- package/lib/analyze-sources.js +372 -0
- package/lib/approval-card.js +54 -0
- package/lib/approval-cli.js +53 -0
- package/lib/approval-request.js +81 -0
- package/lib/approval-signer.js +48 -0
- package/lib/approvals.js +295 -0
- package/lib/attachment-cache.js +236 -0
- package/lib/attachment.js +63 -0
- package/lib/blocked.js +20 -0
- package/lib/build-review.js +90 -0
- package/lib/builder/cli.js +90 -0
- package/lib/builder/policy.js +176 -0
- package/lib/builder/recover.js +189 -0
- package/lib/builder/run.js +240 -0
- package/lib/builder/settle.js +198 -0
- package/lib/builder/stage.js +240 -0
- package/lib/builder/state.js +73 -0
- package/lib/builder/supervisor.js +289 -0
- package/lib/builder-clean.js +223 -0
- package/lib/builder-code.cjs +67 -0
- package/lib/builder.js +9 -0
- package/lib/bus-postgres.js +281 -0
- package/lib/bus.js +349 -0
- package/lib/catalog/author.js +278 -0
- package/lib/catalog/dot.js +426 -0
- package/lib/catalog/pattern-model.js +193 -0
- package/lib/catalog/patterns.js +324 -0
- package/lib/catalog/projects.js +83 -0
- package/lib/catalog/records.js +2 -0
- package/lib/catalog/roster.js +70 -0
- package/lib/catalog/team-files.js +49 -0
- package/lib/catalog/teams.js +109 -0
- package/lib/claude-socket.js +333 -0
- package/lib/cli.js +741 -0
- package/lib/code-mode.js +45 -0
- package/lib/code-read-policy.yaml +9 -0
- package/lib/code-run.js +461 -0
- package/lib/codex-compact.js +141 -0
- package/lib/compaction.js +21 -0
- package/lib/config.js +424 -0
- package/lib/cursor-trace.js +248 -0
- package/lib/deep-link.js +20 -0
- package/lib/deliver-push.js +120 -0
- package/lib/delivery.js +28 -0
- package/lib/deploy-tree.js +227 -0
- package/lib/durable.js +404 -0
- package/lib/factory-tick.js +32 -0
- package/lib/family.js +63 -0
- package/lib/fetch-origin.js +53 -0
- package/lib/format.js +133 -0
- package/lib/harness-surface-cli.js +153 -0
- package/lib/harness-surface.js +486 -0
- package/lib/harness.js +271 -0
- package/lib/hook.mjs +291 -0
- package/lib/idle.js +40 -0
- package/lib/install-cursor.js +115 -0
- package/lib/install-opencode.js +105 -0
- package/lib/job.js +82 -0
- package/lib/land-cli.js +319 -0
- package/lib/land-member.js +64 -0
- package/lib/land.js +320 -0
- package/lib/lessons.js +223 -0
- package/lib/limit-alert.js +423 -0
- package/lib/limits.js +284 -0
- package/lib/machine-prompt.js +19 -0
- package/lib/merge-sweep.js +149 -0
- package/lib/messaging.js +1002 -0
- package/lib/mission-cli.js +103 -0
- package/lib/mission.js +241 -0
- package/lib/mode.js +215 -0
- package/lib/models.js +114 -0
- package/lib/names.js +86 -0
- package/lib/opencode-api.js +57 -0
- package/lib/opencode-plugin.mjs +313 -0
- package/lib/operator-token.js +78 -0
- package/lib/operator.js +187 -0
- package/lib/pad-activity.js +143 -0
- package/lib/pad-fresh.js +44 -0
- package/lib/pad.js +198 -0
- package/lib/pattern-cli.js +120 -0
- package/lib/pattern-compiler.js +68 -0
- package/lib/pattern-runs.js +795 -0
- package/lib/pattern-stall.js +58 -0
- package/lib/pattern-tick.js +45 -0
- package/lib/pattern-workflow.js +69 -0
- package/lib/pi-extension.mjs +98 -0
- package/lib/pi.js +57 -0
- package/lib/plugin-copy.js +76 -0
- package/lib/pm-review.js +32 -0
- package/lib/pm-workspace.js +87 -0
- package/lib/postgres.js +115 -0
- package/lib/pr-card.js +34 -0
- package/lib/probe.js +295 -0
- package/lib/process.js +67 -0
- package/lib/project-pause.js +23 -0
- package/lib/prune.js +793 -0
- package/lib/questions.js +250 -0
- package/lib/receipts.js +63 -0
- package/lib/reflect.js +962 -0
- package/lib/rename-migration.js +118 -0
- package/lib/run-terminal.js +437 -0
- package/lib/runner-request.js +33 -0
- package/lib/sandbox-app.js +120 -0
- package/lib/sandbox-claims.js +258 -0
- package/lib/sandbox-cli.js +188 -0
- package/lib/sandbox-hosts-cli.js +68 -0
- package/lib/sandbox-hosts.js +94 -0
- package/lib/sandbox-pr.js +102 -0
- package/lib/sandbox-proposal.js +367 -0
- package/lib/sandbox-tools.js +143 -0
- package/lib/sandbox.js +501 -0
- package/lib/schedule-session.js +68 -0
- package/lib/session-activity.js +67 -0
- package/lib/session-events.js +94 -0
- package/lib/sessions/control.js +244 -0
- package/lib/sessions/git-refs.js +265 -0
- package/lib/sessions/launch.js +359 -0
- package/lib/sessions/registry.js +450 -0
- package/lib/sessions/scope.js +111 -0
- package/lib/setup.js +377 -0
- package/lib/signed-approval.js +225 -0
- package/lib/slash.js +167 -0
- package/lib/spawn-cli.js +45 -0
- package/lib/spawn.js +107 -0
- package/lib/start-limit.js +58 -0
- package/lib/state.js +24 -0
- package/lib/stop.js +308 -0
- package/lib/store-read.js +62 -0
- package/lib/store.js +252 -0
- package/lib/subagent-guard.js +240 -0
- package/lib/surfaces/channel-post.js +43 -0
- package/lib/surfaces/instructions.js +15 -0
- package/lib/surfaces/mcp-reload.js +144 -0
- package/lib/surfaces/ops.js +629 -0
- package/lib/surfaces/render-mcp.js +33 -0
- package/lib/surfaces/run-terminal-ops.js +40 -0
- package/lib/surfaces/sandbox-ops.js +36 -0
- package/lib/surfaces/schema.js +7 -0
- package/lib/surfaces/task-view.js +90 -0
- package/lib/surfaces/types.js +4 -0
- package/lib/task-cli.js +274 -0
- package/lib/task-order.js +34 -0
- package/lib/task-order.mjs +2 -0
- package/lib/task-route.js +125 -0
- package/lib/tasks.js +631 -0
- package/lib/team-permission.js +34 -0
- package/lib/team-templates/blitz/team.dot +9 -0
- package/lib/team-templates/factory/team.dot +26 -0
- package/lib/team-templates/feature/team.dot +14 -0
- package/lib/team-templates/fix-and-review/team.dot +12 -0
- package/lib/team-templates/product/team.dot +16 -0
- package/lib/team-templates/release/team.dot +7 -0
- package/lib/team-templates/review/team.dot +6 -0
- package/lib/terminal-draft.js +42 -0
- package/lib/thread-branch.js +82 -0
- package/lib/thread-channel-store.js +181 -0
- package/lib/thread-channels.js +116 -0
- package/lib/thread-listening.js +20 -0
- package/lib/thread-routes.js +91 -0
- package/lib/threads.js +441 -0
- package/lib/tool-api.js +33 -0
- package/lib/transcript.js +98 -0
- package/lib/ui-build-output.js +19 -0
- package/lib/ui-capabilities.js +90 -0
- package/lib/usage.js +182 -0
- package/lib/vendor/mcp-sdk.d.mts +4 -0
- package/lib/vendor/mcp-sdk.mjs +17046 -0
- package/lib/waiter.js +127 -0
- package/lib/workflows.js +546 -0
- package/lib/worktree-setup.js +86 -0
- package/package.json +112 -1
- package/runner/adapters/claude.js +465 -0
- package/runner/adapters/cli-sandbox.js +277 -0
- package/runner/adapters/codex.js +675 -0
- package/runner/adapters/cursor.mjs +937 -0
- package/runner/adapters/fake.js +119 -0
- package/runner/adapters/opencode-sandbox.js +370 -0
- package/runner/adapters/opencode.js +486 -0
- package/runner/adapters/pi-sandbox.js +134 -0
- package/runner/adapters/pi.js +364 -0
- package/runner/client.js +40 -0
- package/runner/contract.js +129 -0
- package/runner/control.js +178 -0
- package/runner/delivery.js +184 -0
- package/runner/factory-tick.mjs +10 -0
- package/runner/lock.js +41 -0
- package/runner/main.mjs +118 -0
- package/runner/pattern-tick.mjs +16 -0
- package/runner/publish.js +113 -0
- package/runner/runner.js +2612 -0
- package/runner/sandbox-run.mjs +239 -0
- package/runner/schedules.js +294 -0
- package/runner/task-wake.js +59 -0
- package/scripts/ai-collab +3 -0
- package/scripts/ai-collab-bus.mjs +4 -0
- package/scripts/ai-collab-code-mcp.mjs +3 -0
- package/scripts/ai-collab-hook +3 -0
- package/scripts/ai-collab-hook.mjs +3 -0
- package/scripts/ai-collab-mcp-tools.mjs +2 -0
- package/scripts/ai-collab-mcp.mjs +3 -0
- package/scripts/ai-collab.mjs +3 -0
- package/scripts/install-cursor.mjs +11 -0
- package/scripts/install-opencode.mjs +10 -0
- package/scripts/temmo +3 -0
- package/scripts/temmo-bus.mjs +151 -0
- package/scripts/temmo-code-mcp.mjs +63 -0
- package/scripts/temmo-hook +3 -0
- package/scripts/temmo-hook.mjs +201 -0
- package/scripts/temmo-mcp-tools.mjs +22 -0
- package/scripts/temmo-mcp.mjs +27 -0
- package/scripts/temmo.mjs +4 -0
- package/skills/antislop/SKILL.md +701 -0
- package/skills/antislop/VERSION +1 -0
- package/skills/antislop-code/SKILL.md +128 -0
- package/skills/antislop-human/LICENSE-web-quality-skills +21 -0
- package/skills/antislop-human/SKILL.md +204 -0
- package/skills/antislop-human/contrast-check.py +168 -0
- package/skills/antislop-human/contrast-mcp.py +125 -0
- package/skills/antislop-human/references/A11Y-PATTERNS.md +249 -0
- package/skills/antislop-human/references/WCAG.md +127 -0
- package/skills/antislop-layoutmobile/SKILL.md +170 -0
- package/skills/antislop-ui/LICENSE-web-quality-skills +21 -0
- package/skills/antislop-ui/SKILL.md +351 -0
- package/skills/antislop-ui/references/CORE-WEB-VITALS.md +181 -0
- package/skills/antislop-ui/references/WEB-BASELINE.md +28 -0
- package/skills/harness-surface/SKILL.md +42 -0
- package/skills/land/SKILL.md +32 -0
- package/skills/memory-file/SKILL.md +39 -0
- package/skills/temmo/SKILL.md +101 -0
- package/skills/temmo/references/role-programs.md +47 -0
- package/skills/ui-sdk/SKILL.md +56 -0
- package/skills/ui-sdk/references/agent-ready.md +136 -0
- package/skills/ui-sdk/references/build-interface.md +187 -0
- package/skills/ui-sdk/references/create-component.md +88 -0
- package/skills/ui-sdk/references/patterns.md +246 -0
- package/skills/ui-sdk/references/styles.md +66 -0
- package/skills/ui-sdk/references/testing.md +172 -0
- package/skills/ui-sdk/references/web-components.md +78 -0
- package/tools/screen-state.mjs +119 -0
- package/tools/smoke-ui.mjs +540 -0
- package/web/app/activity.jsx +251 -0
- package/web/app/agent-mark.tsx +43 -0
- package/web/app/alert-level.jsx +16 -0
- package/web/app/api/[action]/route.js +8 -0
- package/web/app/api/auth/[step]/route.js +12 -0
- package/web/app/api/events/route.js +8 -0
- package/web/app/api/file/[name]/route.js +8 -0
- package/web/app/api/land/route.js +12 -0
- package/web/app/api/lessons/route.js +8 -0
- package/web/app/api/push/key/route.js +8 -0
- package/web/app/api/push/subscribe/route.js +12 -0
- package/web/app/api/push/test/route.js +8 -0
- package/web/app/api/refs/route.js +8 -0
- package/web/app/api/review-diff/route.js +8 -0
- package/web/app/api/schedules/route.js +8 -0
- package/web/app/api/thread-diff/route.js +8 -0
- package/web/app/api/version/route.js +6 -0
- package/web/app/cards.jsx +189 -0
- package/web/app/chat-api.js +82 -0
- package/web/app/chat-composer.jsx +313 -0
- package/web/app/chat-console.jsx +691 -0
- package/web/app/chat-image.tsx +61 -0
- package/web/app/chat-message.jsx +122 -0
- package/web/app/chat-shared.jsx +59 -0
- package/web/app/chat-sidebar.jsx +25 -0
- package/web/app/chat-stream.js +127 -0
- package/web/app/chat.jsx +31 -0
- package/web/app/compactions.jsx +57 -0
- package/web/app/composer-actions.tsx +87 -0
- package/web/app/decisions.jsx +53 -0
- package/web/app/fonts/OFL-hanken-grotesk.txt +93 -0
- package/web/app/fonts/OFL-ibm-plex-mono.txt +93 -0
- package/web/app/fonts/hanken-grotesk-latin-wght-normal.woff2 +0 -0
- package/web/app/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
- package/web/app/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
- package/web/app/globals.css +199 -0
- package/web/app/home.jsx +246 -0
- package/web/app/icon.svg +1 -0
- package/web/app/land-panel.jsx +63 -0
- package/web/app/land-reviews.jsx +20 -0
- package/web/app/layout.jsx +17 -0
- package/web/app/lessons.tsx +76 -0
- package/web/app/logo.tsx +13 -0
- package/web/app/logos.jsx +16 -0
- package/web/app/manifest.js +8 -0
- package/web/app/mode-menu.tsx +46 -0
- package/web/app/new-session.jsx +275 -0
- package/web/app/notify.jsx +180 -0
- package/web/app/outcomes.tsx +94 -0
- package/web/app/page.jsx +9 -0
- package/web/app/pattern-graph.jsx +75 -0
- package/web/app/patterns-page.jsx +293 -0
- package/web/app/phone-nav.tsx +36 -0
- package/web/app/progress-feed.tsx +33 -0
- package/web/app/providers.tsx +27 -0
- package/web/app/quote.jsx +15 -0
- package/web/app/run-card.tsx +200 -0
- package/web/app/run-requests.tsx +148 -0
- package/web/app/scheduled.jsx +105 -0
- package/web/app/session-panel.tsx +174 -0
- package/web/app/session-toolbar.tsx +180 -0
- package/web/app/shadcn.css +638 -0
- package/web/app/shipped.jsx +49 -0
- package/web/app/subagent-runs.jsx +31 -0
- package/web/app/task-graph.jsx +67 -0
- package/web/app/tasks-strip.tsx +36 -0
- package/web/app/tasks.jsx +375 -0
- package/web/app/team-author.jsx +145 -0
- package/web/app/team-editor.jsx +88 -0
- package/web/app/thread-agents.tsx +32 -0
- package/web/app/thread-place.tsx +9 -0
- package/web/app/thread-sessions.tsx +149 -0
- package/web/app/thread-sidebar.tsx +418 -0
- package/web/app/thread-switcher.tsx +27 -0
- package/web/app/tool-diff.jsx +94 -0
- package/web/components/a2ui/controls.jsx +36 -0
- package/web/components/a2ui/option-picker.jsx +23 -0
- package/web/components/a2ui/script.tsx +121 -0
- package/web/components/a2ui/surface.jsx +81 -0
- package/web/components/chat/thread.jsx +50 -0
- package/web/components/script-text.tsx +42 -0
- package/web/components/ui/avatar.jsx +115 -0
- package/web/components/ui/badge.jsx +47 -0
- package/web/components/ui/button.jsx +63 -0
- package/web/components/ui/chat-container.jsx +52 -0
- package/web/components/ui/choice-list.tsx +72 -0
- package/web/components/ui/code-block.jsx +60 -0
- package/web/components/ui/copy-button.tsx +41 -0
- package/web/components/ui/dropdown-menu.jsx +257 -0
- package/web/components/ui/markdown.jsx +84 -0
- package/web/components/ui/message.jsx +28 -0
- package/web/components/ui/popover.jsx +33 -0
- package/web/components/ui/scroll-button.jsx +34 -0
- package/web/components/ui/select.jsx +189 -0
- package/web/components/ui/sheet.jsx +152 -0
- package/web/components/ui/sonner.jsx +10 -0
- package/web/components/ui/tabs.jsx +88 -0
- package/web/components/ui/textarea.jsx +20 -0
- package/web/components/ui/tooltip.jsx +56 -0
- package/web/components.json +24 -0
- package/web/instrumentation.js +8 -0
- package/web/lib/a2ui-catalog.js +34 -0
- package/web/lib/a2ui-pr.js +76 -0
- package/web/lib/a2ui-run-catalog.js +18 -0
- package/web/lib/a2ui-run.js +93 -0
- package/web/lib/a2ui.js +262 -0
- package/web/lib/activity-rows.js +275 -0
- package/web/lib/agent-detail.js +5 -0
- package/web/lib/alert-level.js +44 -0
- package/web/lib/approval-mode.js +22 -0
- package/web/lib/chat-turns.js +174 -0
- package/web/lib/child-subagents.js +16 -0
- package/web/lib/compaction-view.js +48 -0
- package/web/lib/composer-actions.js +40 -0
- package/web/lib/context-view.js +57 -0
- package/web/lib/fuzzy.js +26 -0
- package/web/lib/highlight.js +44 -0
- package/web/lib/lessons-view.js +23 -0
- package/web/lib/mentions.js +16 -0
- package/web/lib/message-routing.js +105 -0
- package/web/lib/new-session.js +85 -0
- package/web/lib/operator-messages.js +28 -0
- package/web/lib/pattern-graph.js +165 -0
- package/web/lib/pattern-view.js +33 -0
- package/web/lib/pending-summary.js +18 -0
- package/web/lib/permission-modes.js +30 -0
- package/web/lib/project-feed.js +107 -0
- package/web/lib/quote.js +7 -0
- package/web/lib/reply-quote.js +31 -0
- package/web/lib/scheduled.js +79 -0
- package/web/lib/selection.js +110 -0
- package/web/lib/send-confirmation.js +22 -0
- package/web/lib/session-dead.js +10 -0
- package/web/lib/session-state.js +132 -0
- package/web/lib/sidebar.js +15 -0
- package/web/lib/slash-commands.js +164 -0
- package/web/lib/start-default.js +35 -0
- package/web/lib/start-mode.js +35 -0
- package/web/lib/stream-views.js +49 -0
- package/web/lib/subagent-state.js +20 -0
- package/web/lib/task-board.js +54 -0
- package/web/lib/task-graph.js +183 -0
- package/web/lib/task-tags.js +41 -0
- package/web/lib/team-editor.js +10 -0
- package/web/lib/thread-groups.js +86 -0
- package/web/lib/threads.js +28 -0
- package/web/lib/tool-diff.js +273 -0
- package/web/lib/ui-events.js +58 -0
- package/web/lib/utils.js +5 -0
- package/web/lib/view-memory.js +25 -0
- package/web/next.config.mjs +37 -0
- package/web/postcss.config.mjs +1 -0
- package/web/proxy.js +25 -0
- package/web/public/sw.js +39 -0
- package/web/server/auth.js +178 -0
- package/web/server/dispatch.js +293 -0
- package/web/server/history.js +56 -0
- package/web/server/hosted.js +58 -0
- package/web/server/hub.js +126 -0
- package/web/server/instance.js +5 -0
- package/web/server/land-reviews.js +64 -0
- package/web/server/push.js +148 -0
- package/web/server/run-terminal.js +79 -0
- package/web/server/schedules.js +38 -0
- package/web/server/shipped.js +51 -0
- package/web/server/task-board.js +71 -0
- package/web/server/threads.js +209 -0
- package/web/server/ui.js +2937 -0
- package/web/tsconfig.base.json +16 -0
- package/web/tsconfig.json +9 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# harness-core
|
|
2
|
+
|
|
3
|
+
The portable Harness² core ([ADR 0001](../docs/adr/0001-harness2-v2-portable-core.md)):
|
|
4
|
+
plain node ESM, no dependencies, nothing imported from the host project. This step:
|
|
5
|
+
ship-time stages, the guidance an agent gets at the moment it applies.
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
harness stage <name> print the resolved stage text
|
|
11
|
+
harness stage --command "<cmd>" resolve the stage a command triggers, then print it
|
|
12
|
+
harness stage commit
|
|
13
|
+
harness stage --command "git commit -m x"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Stages: `commit` (`git commit`), `push` (`git push`), `pr` (`temmo land`).
|
|
17
|
+
|
|
18
|
+
Exit codes: 0 printed a stage; 1 no stage matched, because the name is unknown, the
|
|
19
|
+
command triggers no stage, or no layer holds a file for it.
|
|
20
|
+
|
|
21
|
+
## Layering, first hit wins
|
|
22
|
+
|
|
23
|
+
1. `<git root of cwd>/.harness/stages/<stage>.md` (outside a repo, `<cwd>/.harness/stages/<stage>.md`)
|
|
24
|
+
2. `$HARNESS_CONFIG_DIR/stages/<stage>.md`, default `~/.config/harness`
|
|
25
|
+
3. the built-in `harness-core/stages/<stage>.md`
|
|
26
|
+
|
|
27
|
+
The built-ins are generic and tool-neutral; a repo's `.harness/stages/` replaces them.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* harness stage <name> print the resolved stage text
|
|
4
|
+
* harness stage --command "<cmd>" resolve the stage a command triggers, then print it
|
|
5
|
+
* Exit 0 printed a stage; exit 1 no stage matched. See harness-core/README.md for the contract.
|
|
6
|
+
*/
|
|
7
|
+
import { resolveStage, stageForCommand } from "../stage.mjs";
|
|
8
|
+
|
|
9
|
+
const [sub, ...rest] = process.argv.slice(2);
|
|
10
|
+
const ci = rest.indexOf("--command");
|
|
11
|
+
const stage = sub === "stage" ? (ci >= 0 ? stageForCommand(rest[ci + 1] || "") : rest[0] || "") : "";
|
|
12
|
+
const found = stage ? resolveStage(stage, { cwd: process.cwd(), env: process.env }) : null;
|
|
13
|
+
if (!found) {
|
|
14
|
+
process.stderr.write(`harness: no stage for ${JSON.stringify(stage || (ci >= 0 ? `--command ${rest[ci + 1]}` : "usage: harness stage <name>|--command \"<cmd>\""))}\n`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
process.stdout.write(found.text.endsWith("\n") ? found.text : `${found.text}\n`);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Harness² v2 ship-time stages (docs/harness2-v2.md step 1b, docs/adr/0001).
|
|
3
|
+
* Portable core: plain node ESM, no dependencies, and nothing imported from the host
|
|
4
|
+
* project's lib/, runner/ or scripts/. A host hook calls stageForCommand with the command
|
|
5
|
+
* the agent is about to run, then resolveStage to load the guidance for that moment.
|
|
6
|
+
*/
|
|
7
|
+
import fs from "node:fs";
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
const STAGES = new Set(["commit", "push", "pr"]);
|
|
12
|
+
const BUILTIN_DIR = fileURLToPath(new URL("./stages/", import.meta.url));
|
|
13
|
+
// A shell line becomes segments on && , || , ; , | and newlines; each segment is scanned on its own,
|
|
14
|
+
// so `cd x && git commit` reads as the git call it is.
|
|
15
|
+
function segments(cmd) {
|
|
16
|
+
return String(cmd).split(/(?:&&|\|\||[;|\n])/);
|
|
17
|
+
}
|
|
18
|
+
function words(segment) {
|
|
19
|
+
return segment.trim().split(/\s+/).filter(Boolean);
|
|
20
|
+
}
|
|
21
|
+
// The last path component, so /usr/bin/git and ./rtk count as git and rtk.
|
|
22
|
+
function base(word) {
|
|
23
|
+
return word.split("/").pop();
|
|
24
|
+
}
|
|
25
|
+
// The word after `git` that is not an option: `git -C dir commit` and `git --no-pager log` both
|
|
26
|
+
// answer with their subcommand; -C and -c each consume a value word too.
|
|
27
|
+
function gitSubcommand(ws, i) {
|
|
28
|
+
for (let j = i + 1; j < ws.length; j++) {
|
|
29
|
+
const w = ws[j];
|
|
30
|
+
if (w === "-C" || w === "-c") {
|
|
31
|
+
j++;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (w.startsWith("-"))
|
|
35
|
+
continue;
|
|
36
|
+
return w;
|
|
37
|
+
}
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* stageForCommand(cmd) -> "commit" | "push" | "pr" | null
|
|
42
|
+
* Matches `git commit`, `git push` and `temmo land` (request or finish), including after
|
|
43
|
+
* `cd x &&`, after `git -C <dir>` and inside a wrapper such as `rtk git ...`. `git commit-tree`,
|
|
44
|
+
* `git log` and anything else return null.
|
|
45
|
+
*/
|
|
46
|
+
export function stageForCommand(cmd) {
|
|
47
|
+
if (typeof cmd !== "string" || !cmd)
|
|
48
|
+
return null;
|
|
49
|
+
for (const seg of segments(cmd)) {
|
|
50
|
+
const ws = words(seg);
|
|
51
|
+
for (let i = 0; i < ws.length; i++) {
|
|
52
|
+
const w = base(ws[i]);
|
|
53
|
+
if (w === "git") {
|
|
54
|
+
const sub = gitSubcommand(ws, i);
|
|
55
|
+
if (sub === "commit")
|
|
56
|
+
return "commit";
|
|
57
|
+
if (sub === "push")
|
|
58
|
+
return "push";
|
|
59
|
+
}
|
|
60
|
+
else if ((w === "temmo" || w === "ai-collab") && gitSubcommand(ws, i) === "land") {
|
|
61
|
+
return "pr";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
// The git root of cwd: the nearest directory holding .git (dir or worktree file), else cwd itself.
|
|
68
|
+
function gitRoot(cwd) {
|
|
69
|
+
const start = path.resolve(cwd);
|
|
70
|
+
let dir = start;
|
|
71
|
+
for (;;) {
|
|
72
|
+
if (fs.existsSync(path.join(dir, ".git")))
|
|
73
|
+
return dir;
|
|
74
|
+
const parent = path.dirname(dir);
|
|
75
|
+
if (parent === dir)
|
|
76
|
+
return start;
|
|
77
|
+
dir = parent;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// The layers a stage file may come from, first hit wins.
|
|
81
|
+
function stagePaths(stage, { cwd, env }) {
|
|
82
|
+
const root = gitRoot(cwd);
|
|
83
|
+
const userDir = env.HARNESS_CONFIG_DIR || path.join(env.HOME || os.homedir(), ".config", "harness");
|
|
84
|
+
return [
|
|
85
|
+
path.join(root, ".harness", "stages", `${stage}.md`),
|
|
86
|
+
path.join(userDir, "stages", `${stage}.md`),
|
|
87
|
+
path.join(BUILTIN_DIR, `${stage}.md`),
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* resolveStage(stage, {cwd, env}) -> {path, text} | null
|
|
92
|
+
* Layering, first hit wins: <git root of cwd>/.harness/stages/<stage>.md, then
|
|
93
|
+
* $HARNESS_CONFIG_DIR/stages/<stage>.md (default ~/.config/harness), then the built-in
|
|
94
|
+
* harness-core/stages/<stage>.md. Unknown stage names and unreadable layers return null.
|
|
95
|
+
*/
|
|
96
|
+
export function resolveStage(stage, { cwd = process.cwd(), env = process.env } = {}) {
|
|
97
|
+
if (!STAGES.has(stage))
|
|
98
|
+
return null;
|
|
99
|
+
for (const p of stagePaths(stage, { cwd: cwd || process.cwd(), env: env || process.env })) {
|
|
100
|
+
try {
|
|
101
|
+
return { path: p, text: fs.readFileSync(p, "utf8") };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// This layer has no file for the stage; try the next one.
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Commit
|
|
2
|
+
|
|
3
|
+
- Write a Conventional Commit subject (`feat:`, `fix:`, `docs:`, `ci:`, `chore:`, ...); the body says why, not what.
|
|
4
|
+
- One logical change per commit; stage only the files that belong to it.
|
|
5
|
+
- Run the repo's checks before committing and never commit a known-red tree; commit hooks may re-check staged files.
|
|
6
|
+
- Never commit secrets, credentials or local config.
|
|
7
|
+
- A repo's own `.harness/stages/commit.md` replaces this fallback.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# PR
|
|
2
|
+
|
|
3
|
+
- Fill every section of the repo's PR template; write the title and description for a reader who has not seen the session.
|
|
4
|
+
- Put real command output in the proof and the Testing section: the commands you ran and their result lines. Evidence, not prose.
|
|
5
|
+
- Keep merging a separate, checked step after CI is green.
|
|
6
|
+
- End the handover with a report: the branch, the commits, and the pass and fail counts of the tests you ran.
|
|
7
|
+
- A repo's own `.harness/stages/pr.md` replaces this fallback.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Push
|
|
2
|
+
|
|
3
|
+
- Never push `main` or another shared branch directly; push your own branch and merge through a PR.
|
|
4
|
+
- Fetch and rebase onto the base branch before pushing, so the merge is a fast-forward.
|
|
5
|
+
- Expect pre-push hooks to run; fix what they flag instead of bypassing them.
|
|
6
|
+
- Force-push only your own branch, and only with `--force-with-lease`.
|
|
7
|
+
- A repo's own `.harness/stages/push.md` replaces this fallback.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --host codex", "timeout": 20 }] }],
|
|
4
|
+
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --host codex", "timeout": 10 }] }],
|
|
5
|
+
"PreToolUse": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host codex", "timeout": 5 }] }],
|
|
6
|
+
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host codex", "timeout": 5 }] }],
|
|
7
|
+
"SubagentStart": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host codex", "timeout": 5 }] }],
|
|
8
|
+
"SubagentStop": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host codex", "timeout": 5 }] }],
|
|
9
|
+
"PreCompact": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host codex", "timeout": 5 }] }],
|
|
10
|
+
"PermissionRequest": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --host codex", "timeout": 600 }] }],
|
|
11
|
+
"Stop": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --host codex", "timeout": 660 }] }],
|
|
12
|
+
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "\"${PLUGIN_ROOT:-$CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host codex", "timeout": 3 }] }]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"hooks": {
|
|
4
|
+
"sessionStart": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --host cursor" }],
|
|
5
|
+
"preToolUse": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --read-gate --host cursor", "timeout": 10 }],
|
|
6
|
+
"beforeReadFile": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --read-gate --host cursor", "timeout": 10 }],
|
|
7
|
+
"beforeShellExecution": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --read-gate --host cursor", "timeout": 10 }],
|
|
8
|
+
"subagentStart": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --read-gate --host cursor", "timeout": 10 }],
|
|
9
|
+
"beforeSubmitPrompt": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host cursor", "timeout": 5 }],
|
|
10
|
+
"afterAgentResponse": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host cursor", "timeout": 5 }],
|
|
11
|
+
"postToolUse": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --host cursor" }],
|
|
12
|
+
"postToolUseFailure": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host cursor", "timeout": 5 }],
|
|
13
|
+
"preCompact": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --host cursor" }],
|
|
14
|
+
"stop": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --host cursor", "timeout": 660, "loop_limit": null }],
|
|
15
|
+
"sessionEnd": [{ "command": "\"${CURSOR_PLUGIN_ROOT}/scripts/temmo-hook\" --activity --host cursor", "timeout": 5 }]
|
|
16
|
+
}
|
|
17
|
+
}
|
package/hooks/hooks.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Temmo: publish start/stop status and session activity (subagents and compaction included), surface new peer messages as untrusted context, deliver waiting messages at Stop, and wake an idle session when a peer message arrives (asyncRewake).",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SessionStart": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 20 }, { "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --rewake --host claude", "asyncRewake": true, "timeout": 3600, "rewakeMessage": "temmo delivered peer messages while this session was idle.", "rewakeSummary": "temmo: new peer message" }] }],
|
|
5
|
+
"UserPromptSubmit": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 10 }, { "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --rewake --host claude", "asyncRewake": true, "timeout": 3600, "rewakeMessage": "temmo delivered peer messages while this session was idle.", "rewakeSummary": "temmo: new peer message" }] }],
|
|
6
|
+
"PreToolUse": [
|
|
7
|
+
{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] },
|
|
8
|
+
{ "matcher": "AskUserQuestion", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 600 }] },
|
|
9
|
+
{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --read-gate --host claude", "timeout": 10 }] }
|
|
10
|
+
],
|
|
11
|
+
"PostToolUse": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 10 }] }],
|
|
12
|
+
"PostToolUseFailure": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
13
|
+
"MessageDisplay": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
14
|
+
"Notification": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
15
|
+
"SubagentStart": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
16
|
+
"SubagentStop": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
17
|
+
"PreCompact": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
18
|
+
"PostModelSwitch": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
19
|
+
"PostCompact": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
20
|
+
"PermissionRequest": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 600 }] }],
|
|
21
|
+
"PermissionDenied": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 10 }] }],
|
|
22
|
+
"Stop": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "timeout": 660 }, { "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --rewake --host claude", "asyncRewake": true, "timeout": 3600, "rewakeMessage": "temmo delivered peer messages while this session was idle.", "rewakeSummary": "temmo: new peer message" }] }],
|
|
23
|
+
"StopFailure": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "async": true }] }],
|
|
24
|
+
"InstructionsLoaded": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --host claude", "async": true, "timeout": 10 }] }],
|
|
25
|
+
"SessionEnd": [{ "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/temmo-hook.mjs\" --activity --host claude", "timeout": 3 }] }]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Portions © 2026 T3 Tools Inc., MIT License, from pingdotgg/t3code@452d8f0 packages/provider-acp/src/server/adapter.ts and packages/provider-acp/src/server/elicitationForm.ts
|
|
2
|
+
// ACP session/request_permission: which option answers a decision, and the requests that are questions in disguise.
|
|
3
|
+
// Cursor's ask_question fallback when the client does not serve `cursor/ask_question`: one allow_once per choice, then this skip.
|
|
4
|
+
export const CURSOR_SKIP_OPTION_ID = "__ask_question_skip__";
|
|
5
|
+
// The card limits in lib/approval-card.ts, applied here so the label an answer names is the one mapped below.
|
|
6
|
+
const HEADER_MAX = 40;
|
|
7
|
+
const QUESTION_MAX = 500;
|
|
8
|
+
const LABEL_MAX = 100;
|
|
9
|
+
/** The option that answers decision; undefined when the agent offers none of that kind. */
|
|
10
|
+
export function selectPermissionOptionId(request, decision) {
|
|
11
|
+
const optionIdOfKind = (kind) => request.options?.find((option) => option.kind === kind)?.optionId;
|
|
12
|
+
if (decision === "acceptForSession") {
|
|
13
|
+
// Agents may offer only allow_once, and answering "cancelled" would stop the turn the user approved.
|
|
14
|
+
return optionIdOfKind("allow_always") ?? optionIdOfKind("allow_once");
|
|
15
|
+
}
|
|
16
|
+
return optionIdOfKind(decision === "accept" ? "allow_once" : "reject_once");
|
|
17
|
+
}
|
|
18
|
+
/** The key an "always for this session" grant covers: the tool kind, or the title for a kind as broad as `other` (one MCP tool, not every one). */
|
|
19
|
+
export function grantKey(toolCall) {
|
|
20
|
+
const kind = typeof toolCall?.kind === "string" ? toolCall.kind : "";
|
|
21
|
+
const title = typeof toolCall?.title === "string" ? toolCall.title : "";
|
|
22
|
+
return kind && kind !== "other" ? `kind:${kind}` : `title:${title}`;
|
|
23
|
+
}
|
|
24
|
+
// The first text block of a tool call's content, where Cursor puts the question prompt.
|
|
25
|
+
function contentText(content) {
|
|
26
|
+
if (!Array.isArray(content))
|
|
27
|
+
return "";
|
|
28
|
+
for (const block of content) {
|
|
29
|
+
const text = block?.type === "content" ? block.content?.text : block?.text;
|
|
30
|
+
if (typeof text === "string" && text.trim())
|
|
31
|
+
return text.trim();
|
|
32
|
+
}
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
// Unique labels for the choices: trimmed names, quoted with JSON when two collide or one is blank (as elicitationForm enumOptions).
|
|
36
|
+
function uniqueLabels(names) {
|
|
37
|
+
const counts = new Map();
|
|
38
|
+
for (const name of names)
|
|
39
|
+
counts.set(name.trim(), (counts.get(name.trim()) ?? 0) + 1);
|
|
40
|
+
const labels = names.map((name) => (name.trim() !== "" && counts.get(name.trim()) === 1 ? name.trim() : JSON.stringify(name)));
|
|
41
|
+
return new Set(labels).size === labels.length ? labels : names.map((name) => JSON.stringify(name));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The question a permission request carries, or null for a plain tool approval. A request is a question when it has
|
|
45
|
+
* Cursor's skip option, or more than one allow_once option and no allow_always (a tool approval allows one way).
|
|
46
|
+
*/
|
|
47
|
+
export function permissionQuestion(request) {
|
|
48
|
+
const options = request.options ?? [];
|
|
49
|
+
const skip = options.find((o) => o.optionId === CURSOR_SKIP_OPTION_ID);
|
|
50
|
+
const choices = options.filter((o) => o.kind === "allow_once" && o !== skip);
|
|
51
|
+
const shaped = skip !== undefined || (choices.length > 1 && !options.some((o) => o.kind === "allow_always"));
|
|
52
|
+
if (!shaped || !choices.length)
|
|
53
|
+
return null;
|
|
54
|
+
const toolCall = request.toolCall ?? {};
|
|
55
|
+
const title = typeof toolCall.title === "string" ? toolCall.title.trim() : "";
|
|
56
|
+
const prompt = contentText(toolCall.content) || title;
|
|
57
|
+
if (!prompt)
|
|
58
|
+
return null;
|
|
59
|
+
const labels = uniqueLabels(choices.map((o) => (typeof o.name === "string" && o.name ? o.name : o.optionId).slice(0, LABEL_MAX)));
|
|
60
|
+
const optionIds = new Map(labels.map((label, i) => [label, choices[i].optionId]));
|
|
61
|
+
const header = (title && title !== prompt ? title : "Question").slice(0, HEADER_MAX);
|
|
62
|
+
return {
|
|
63
|
+
question: { question: prompt.slice(0, QUESTION_MAX).trim(), header, multiSelect: false, options: labels.map((label) => ({ label })) },
|
|
64
|
+
optionIds,
|
|
65
|
+
...(skip ? { skipOptionId: skip.optionId } : {}),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The optionId the operator's answers pick for this question, or undefined when they name no listed label. */
|
|
69
|
+
export function answerOptionId(question, answers) {
|
|
70
|
+
const label = answers?.[question.question.question];
|
|
71
|
+
return typeof label === "string" ? question.optionIds.get(label.trim()) : undefined;
|
|
72
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Portions © 2026 T3 Tools Inc., MIT License, from pingdotgg/t3code@452d8f0 packages/provider-acp/src/server/sessionConfig.ts
|
|
2
|
+
// ACP session config options (session/new, load and resume responses) as option descriptors, plus the model option.
|
|
3
|
+
export const ACP_SESSION_MODE_OPTION_ID = "_t3/session-mode";
|
|
4
|
+
/** Encodes a valid empty ACP choice as a non-empty ID; map back before applying. */
|
|
5
|
+
export const ACP_EMPTY_OPTION_VALUE = "_t3/empty";
|
|
6
|
+
const MAX_OPTION_DESCRIPTORS = 16;
|
|
7
|
+
const MAX_OPTION_CHOICES = 64;
|
|
8
|
+
const MAX_TEXT_LENGTH = 256;
|
|
9
|
+
const MAX_DESCRIPTION_LENGTH = 1_024;
|
|
10
|
+
const boundedText = (value, maximumLength) => (value ?? "").trim().slice(0, maximumLength);
|
|
11
|
+
const boundedOpaqueValue = (value, maximumLength) => value.length > 0 && value === value.trim() && value.length <= maximumLength ? value : undefined;
|
|
12
|
+
const choiceId = (value) => value === "" ? ACP_EMPTY_OPTION_VALUE : boundedOpaqueValue(value, MAX_TEXT_LENGTH);
|
|
13
|
+
/** Mistral Vibe 3.1 sends its reasoning level under `thinking`, a category ACP reserves but never defined. */
|
|
14
|
+
export const isAcpThoughtLevelOption = (option) => option.category === "thought_level" || (option.category === "thinking" && option.type === "select");
|
|
15
|
+
export function flattenSelectChoices(options) {
|
|
16
|
+
return options.flatMap((candidate) => ("value" in candidate ? [candidate] : candidate.options));
|
|
17
|
+
}
|
|
18
|
+
function selectChoices(candidates) {
|
|
19
|
+
const seen = new Set();
|
|
20
|
+
const choices = [];
|
|
21
|
+
for (const candidate of candidates) {
|
|
22
|
+
const id = choiceId(candidate.value);
|
|
23
|
+
if (id === undefined || seen.has(id))
|
|
24
|
+
continue;
|
|
25
|
+
seen.add(id);
|
|
26
|
+
const description = boundedText(candidate.description, MAX_DESCRIPTION_LENGTH);
|
|
27
|
+
choices.push({ id, label: boundedText(candidate.name, MAX_TEXT_LENGTH) || id, ...(description ? { description } : {}) });
|
|
28
|
+
if (choices.length === MAX_OPTION_CHOICES)
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
return choices;
|
|
32
|
+
}
|
|
33
|
+
/** The non-model config options and the session mode as bounded descriptors; model and collaboration_mode are left to the model control. */
|
|
34
|
+
export function acpOptionDescriptors(input) {
|
|
35
|
+
const descriptors = [];
|
|
36
|
+
const seen = new Set();
|
|
37
|
+
const mirroredModeChoiceSets = [];
|
|
38
|
+
let hasModeCategory = false;
|
|
39
|
+
for (const option of input.configOptions ?? []) {
|
|
40
|
+
if (option.category === "model" || option.category === "collaboration_mode")
|
|
41
|
+
continue;
|
|
42
|
+
const id = boundedOpaqueValue(option.id, MAX_TEXT_LENGTH);
|
|
43
|
+
if (id === undefined || seen.has(id))
|
|
44
|
+
continue;
|
|
45
|
+
seen.add(id);
|
|
46
|
+
const description = boundedText(option.description, MAX_DESCRIPTION_LENGTH);
|
|
47
|
+
const base = { id, label: boundedText(option.name, MAX_TEXT_LENGTH) || id, ...(description ? { description } : {}) };
|
|
48
|
+
if (option.type === "boolean") {
|
|
49
|
+
if (option.category === "mode")
|
|
50
|
+
hasModeCategory = true;
|
|
51
|
+
descriptors.push({ ...base, type: "boolean", currentValue: option.currentValue, ...(option.category === "mode" ? { role: "mode" } : {}) });
|
|
52
|
+
if (descriptors.length === MAX_OPTION_DESCRIPTORS)
|
|
53
|
+
return descriptors;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const choices = selectChoices(flattenSelectChoices(option.options));
|
|
57
|
+
if (choices.length === 0) {
|
|
58
|
+
seen.delete(id);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (option.category === "mode")
|
|
62
|
+
hasModeCategory = true;
|
|
63
|
+
const isThoughtLevel = isAcpThoughtLevelOption(option);
|
|
64
|
+
if (isThoughtLevel)
|
|
65
|
+
mirroredModeChoiceSets.push(new Set(choices.map((choice) => choice.id)));
|
|
66
|
+
const currentValue = choiceId(option.currentValue);
|
|
67
|
+
descriptors.push({
|
|
68
|
+
...base,
|
|
69
|
+
type: "select",
|
|
70
|
+
options: choices,
|
|
71
|
+
...(currentValue && choices.some((choice) => choice.id === currentValue) ? { currentValue } : {}),
|
|
72
|
+
...(isThoughtLevel ? { role: "reasoning" } : option.category === "mode" ? { role: "mode" } : {}),
|
|
73
|
+
});
|
|
74
|
+
if (descriptors.length === MAX_OPTION_DESCRIPTORS)
|
|
75
|
+
return descriptors;
|
|
76
|
+
}
|
|
77
|
+
const modeState = input.modeState;
|
|
78
|
+
if (modeState !== undefined && !hasModeCategory) {
|
|
79
|
+
const choices = selectChoices(modeState.availableModes.map((mode) => ({ value: mode.id, name: mode.name, description: mode.description })));
|
|
80
|
+
const currentValue = choiceId(modeState.currentModeId);
|
|
81
|
+
// Some agents duplicate modes in config options; show each control once.
|
|
82
|
+
const duplicatesKnownModeDescriptor = mirroredModeChoiceSets.some((choiceIds) => choiceIds.size === choices.length && choices.every((choice) => choiceIds.has(choice.id)));
|
|
83
|
+
if (choices.length > 1 && !duplicatesKnownModeDescriptor && !seen.has(ACP_SESSION_MODE_OPTION_ID)) {
|
|
84
|
+
descriptors.push({
|
|
85
|
+
id: ACP_SESSION_MODE_OPTION_ID, label: "Mode", description: "Session mode advertised by the ACP agent.", type: "select", options: choices,
|
|
86
|
+
...(currentValue && choices.some((choice) => choice.id === currentValue) ? { currentValue } : {}),
|
|
87
|
+
role: "mode",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return descriptors.slice(0, MAX_OPTION_DESCRIPTORS);
|
|
92
|
+
}
|
|
93
|
+
/** The select option that picks the model: category `model`, else the id `model` (Cursor's ACP_MODEL_CONFIG_ID). */
|
|
94
|
+
export function modelConfigOption(configOptions) {
|
|
95
|
+
const selects = (configOptions ?? []).filter((o) => o?.type === "select");
|
|
96
|
+
return selects.find((o) => o.category === "model") ?? selects.find((o) => o.id === "model");
|
|
97
|
+
}
|
|
98
|
+
/** The session's models as `{id, label}`: the model config option's choices, else the unstable `models` list. */
|
|
99
|
+
export function sessionModels(response) {
|
|
100
|
+
const option = modelConfigOption(response?.configOptions);
|
|
101
|
+
if (option) {
|
|
102
|
+
const models = selectChoices(flattenSelectChoices(option.options)).map((c) => ({ id: c.id, label: c.label }));
|
|
103
|
+
return { ...(option.currentValue ? { current: option.currentValue } : {}), models };
|
|
104
|
+
}
|
|
105
|
+
const state = response?.models;
|
|
106
|
+
const models = (state?.availableModels ?? []).filter((m) => typeof m?.modelId === "string" && m.modelId)
|
|
107
|
+
.map((m) => ({ id: m.modelId, ...(m.name ? { label: m.name } : {}) }));
|
|
108
|
+
return { ...(state?.currentModelId ? { current: state.currentModelId } : {}), models };
|
|
109
|
+
}
|