@bonesofspring/ai-rules 0.2.87 → 0.2.91
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 +83 -0
- package/README.md +9 -1
- package/bin/lib/engine-scripts.js +7 -0
- package/bin/lib/seed-ai-local-team.js +40 -0
- package/bin/opencode-install.js +11 -10
- package/docs/OPENCODE-COMPATIBILITY.md +2 -1
- package/docs/OPENCODE.md +27 -5
- package/docs/openapi/team-db.v1.json +2 -2
- package/package.json +1 -1
- package/presets/_shared/ai-local/env.example +54 -0
- package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +34 -5
- package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +25 -22
- package/presets/_shared/ai-local/scripts/process-lease.mjs +3 -2
- package/presets/_shared/ai-local/scripts/processes.mjs +52 -20
- package/presets/_shared/ai-local/scripts/run.mjs +38 -6
- package/presets/_shared/ai-local/scripts/settings.mjs +246 -0
- package/presets/_shared/ai-local/scripts/task-worktree.mjs +364 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +2 -2
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +87 -14
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +102 -12
- package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +35 -0
- package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +10 -1
- package/presets/_shared/ai-local/scripts/verification.mjs +106 -11
- package/presets/_shared/core/agent-team/agent-task-metrics.md +10 -2
- package/presets/_shared/core/agent-team/agent-team-intake.md +2 -0
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +2 -2
- package/presets/_shared/core/meta/preset-writing-style.md +8 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +541 -61
- package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +733 -9
- package/presets/_shared/hooks/prompt-autoroute.mjs.tmpl +153 -0
- package/presets/claude/android-kotlin/CLAUDE.md +2 -4
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/android-kotlin/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/android-kotlin/settings.json +15 -5
- package/presets/claude/go/CLAUDE.md +2 -4
- package/presets/claude/go/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/go/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/go/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/go/settings.json +15 -5
- package/presets/claude/ios-swift/CLAUDE.md +2 -4
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/ios-swift/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/ios-swift/settings.json +15 -5
- package/presets/claude/java/CLAUDE.md +2 -4
- package/presets/claude/java/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/java/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/java/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/java/settings.json +15 -5
- package/presets/claude/mcp-ts/CLAUDE.md +2 -4
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/mcp-ts/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/mcp-ts/settings.json +15 -5
- package/presets/claude/mol/CLAUDE.md +2 -4
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/claude/mol/commands/task-evil.md +8 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/mol/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/mol/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/mol/settings.json +15 -4
- package/presets/claude/next/CLAUDE.md +2 -4
- package/presets/claude/next/REPO_AGENTS.md +2 -0
- package/presets/claude/next/agents/feature-developer.md +1 -1
- package/presets/claude/next/agents/task-analyst.md +1 -7
- package/presets/claude/next/agents/task-router.md +1 -1
- package/presets/claude/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/claude/next/commands/spec-start.md +3 -4
- package/presets/claude/next/commands/task-continue.md +9 -8
- package/presets/claude/next/commands/task-evil.md +8 -0
- package/presets/claude/next/commands/task.md +1 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/next/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/next/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/next/settings.json +15 -4
- package/presets/claude/next/team/README.md +1 -1
- package/presets/claude/nuxt/CLAUDE.md +2 -4
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/nuxt/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/nuxt/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/nuxt/settings.json +15 -4
- package/presets/claude/php-hexagonal/CLAUDE.md +2 -4
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/php-hexagonal/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/php-hexagonal/settings.json +15 -5
- package/presets/claude/php-laravel/CLAUDE.md +2 -4
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/php-laravel/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/php-laravel/settings.json +15 -5
- package/presets/claude/svelte/CLAUDE.md +2 -4
- package/presets/claude/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/svelte/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/svelte/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/svelte/settings.json +15 -4
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/android-kotlin/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/go/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/java/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/cursor/mol/commands/task-evil.md +8 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/next/REPO_AGENTS.md +2 -0
- package/presets/cursor/next/agents/feature-developer.md +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -7
- package/presets/cursor/next/agents/task-router.md +1 -1
- package/presets/cursor/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/cursor/next/commands/spec-start.md +3 -4
- package/presets/cursor/next/commands/task-continue.md +9 -8
- package/presets/cursor/next/commands/task-evil.md +8 -0
- package/presets/cursor/next/commands/task.md +1 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/next/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/next/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/next/team/README.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/nuxt/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/rules/preset-writing-style.mdc +8 -0
- package/presets/mavis/android-kotlin/MAVIS.md +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/mavis/go/MAVIS.md +1 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/go/rules/agent-team-intake.md +2 -0
- package/presets/mavis/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/go/rules/preset-writing-style.md +8 -0
- package/presets/mavis/ios-swift/MAVIS.md +1 -1
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/mavis/java/MAVIS.md +1 -1
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/java/rules/agent-team-intake.md +2 -0
- package/presets/mavis/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/java/rules/preset-writing-style.md +8 -0
- package/presets/mavis/mcp-ts/MAVIS.md +1 -1
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/mavis/mol/MAVIS.md +1 -1
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/mavis/mol/commands/task-evil.md +8 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/mol/native-skills/task-evil/SKILL.md +8 -0
- package/presets/mavis/mol/rules/agent-team-intake.md +2 -0
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/mol/rules/preset-writing-style.md +8 -0
- package/presets/mavis/next/MAVIS.md +1 -1
- package/presets/mavis/next/REPO_AGENTS.md +2 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/agents/feature-developer.md +1 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -7
- package/presets/mavis/next/agents/task-router.md +1 -1
- package/presets/mavis/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/mavis/next/commands/spec-start.md +3 -4
- package/presets/mavis/next/commands/task-continue.md +9 -8
- package/presets/mavis/next/commands/task-evil.md +8 -0
- package/presets/mavis/next/commands/task.md +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/next/native-skills/spec-start/SKILL.md +3 -4
- package/presets/mavis/next/native-skills/task/SKILL.md +1 -1
- package/presets/mavis/next/native-skills/task-continue/SKILL.md +9 -8
- package/presets/mavis/next/native-skills/task-evil/SKILL.md +8 -0
- package/presets/mavis/next/rules/agent-team-intake.md +2 -0
- package/presets/mavis/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/next/rules/preset-writing-style.md +8 -0
- package/presets/mavis/next/team/README.md +1 -1
- package/presets/mavis/nuxt/MAVIS.md +1 -1
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/mavis/php-hexagonal/MAVIS.md +1 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/mavis/php-laravel/MAVIS.md +1 -1
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/mavis/svelte/MAVIS.md +1 -1
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/svelte/rules/agent-team-intake.md +2 -0
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/svelte/rules/preset-writing-style.md +8 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/README.md +6 -5
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/android-kotlin/opencode.json +4 -4
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/README.md +6 -5
- package/presets/opencode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/go/opencode.json +4 -4
- package/presets/opencode/go/rules/agent-team-intake.md +2 -0
- package/presets/opencode/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/go/rules/preset-writing-style.md +8 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/README.md +6 -5
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/ios-swift/opencode.json +4 -4
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/README.md +6 -5
- package/presets/opencode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/java/opencode.json +4 -4
- package/presets/opencode/java/rules/agent-team-intake.md +2 -0
- package/presets/opencode/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/java/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/README.md +6 -5
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/mcp-ts/opencode.json +4 -4
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/mol/commands/task-evil.md +8 -0
- package/presets/opencode/mol/hooks/README.md +6 -5
- package/presets/opencode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/mol/opencode.json +4 -4
- package/presets/opencode/mol/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/mol/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/REPO_AGENTS.md +2 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/agents/feature-developer.md +1 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -7
- package/presets/opencode/next/agents/task-router.md +1 -1
- package/presets/opencode/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/next/commands/spec-start.md +3 -4
- package/presets/opencode/next/commands/task-continue.md +9 -8
- package/presets/opencode/next/commands/task-evil.md +8 -0
- package/presets/opencode/next/commands/task.md +1 -1
- package/presets/opencode/next/hooks/README.md +6 -5
- package/presets/opencode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/next/opencode.json +4 -4
- package/presets/opencode/next/rules/agent-team-intake.md +2 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/next/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/team/README.md +1 -1
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/hooks/README.md +6 -5
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/nuxt/opencode.json +4 -4
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/README.md +6 -5
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/php-hexagonal/opencode.json +4 -4
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/README.md +6 -5
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/php-laravel/opencode.json +4 -4
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/opencode/plugins/output-guard/README.md +4 -3
- package/presets/opencode/plugins/output-guard/index.ts +4 -3
- package/presets/opencode/plugins/output-guard/rewrite.ts +1 -2
- package/presets/opencode/plugins/rule-attach/README.md +1 -1
- package/presets/opencode/plugins/rule-attach/index.ts +23 -4
- package/presets/opencode/plugins/settings-guard/README.md +28 -0
- package/presets/opencode/plugins/settings-guard/index.ts +114 -0
- package/presets/opencode/plugins/settings-guard/package.json +9 -0
- package/presets/opencode/plugins/settings-guard/policy.mjs +85 -0
- package/presets/opencode/plugins/settings-guard/prompt-face.mjs +153 -0
- package/presets/opencode/plugins/task-status/README.md +13 -8
- package/presets/opencode/plugins/task-status/deepseek.ts +23 -8
- package/presets/opencode/plugins/task-status/eta.ts +20 -7
- package/presets/opencode/plugins/task-status/index.ts +14 -1
- package/presets/opencode/plugins/task-status/task-view.ts +168 -9
- package/presets/opencode/plugins/task-status/timing.ts +244 -0
- package/presets/opencode/plugins/task-status/tui.tsx +12 -3
- package/presets/opencode/plugins/task-status/types.ts +6 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/hooks/README.md +6 -5
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/svelte/opencode.json +4 -4
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/svelte/rules/preset-writing-style.md +8 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/go/rules/agent-team-intake.md +2 -0
- package/presets/zcode/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/go/rules/preset-writing-style.md +8 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/java/rules/agent-team-intake.md +2 -0
- package/presets/zcode/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/java/rules/preset-writing-style.md +8 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/zcode/mol/commands/task-evil.md +8 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/mol/rules/agent-team-intake.md +2 -0
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/mol/rules/preset-writing-style.md +8 -0
- package/presets/zcode/next/REPO_AGENTS.md +2 -0
- package/presets/zcode/next/adapter-map.json +1 -1
- package/presets/zcode/next/agents/feature-developer.md +1 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -7
- package/presets/zcode/next/agents/task-router.md +1 -1
- package/presets/zcode/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/zcode/next/commands/spec-start.md +3 -4
- package/presets/zcode/next/commands/task-continue.md +9 -8
- package/presets/zcode/next/commands/task-evil.md +8 -0
- package/presets/zcode/next/commands/task.md +1 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/next/rules/agent-team-intake.md +2 -0
- package/presets/zcode/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/next/rules/preset-writing-style.md +8 -0
- package/presets/zcode/next/team/README.md +1 -1
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/svelte/rules/preset-writing-style.md +8 -0
|
@@ -8,11 +8,12 @@ Modelled on the built-in MCP sidebar plugin (`packages/tui/src/feature-plugins/s
|
|
|
8
8
|
|
|
9
9
|
- header `▼ Task` toggles on click; collapsed it reads `▶ Task (running · 3/7 · 16h 05m)`
|
|
10
10
|
- each row is a flex row of a bold label and a value; the state value is colored by tone (success, warning, error, muted)
|
|
11
|
-
- the
|
|
11
|
+
- the `time` row splits the wall clock: `work 1h 25m · gate 1h 00m · paused 30m · sleep 20m · idle 4m`. `work` is `attempt_finished.activeMs` (older ledgers fall back to `durationMs`, capped at 4h), `gate`/`paused`/`sleep` are interval sums, `idle` is what is left — parent latency, a hung attempt past the cap, anything the ledger cannot attribute. A zero bucket is hidden; `paused` takes the sentinel mtime until the hook writes `task_paused`
|
|
12
|
+
- the step row carries a progress bar, e.g. `3/7 ███░░░░░ · attempt 1 · 3h 35m`; a parallel wave reads `3/7 ███░░░░░ · 3 agents · 42m` and clocks from the oldest start; a `status.json` written before any attempt reads `3/7 · no attempt started` instead of hiding the plan
|
|
12
13
|
- the `eta` row reads `~52m · p90 3h 32m`: estimated time to finish the remaining plan steps. It hides while the run waits on a human gate, is paused, blocked, waiting for a receipt, or is done. A stale run keeps it — the estimate is historical, not live — and with fewer than 3 ledgers the row reads `—` instead of disappearing
|
|
13
14
|
- clicking any row opens a details dialog with 3-cell side padding: `goal.md`, pipeline steps with the current one marked, artifacts from `artifact-manifest.json`, the last manifest entries, the prompt, the last update age and the ETA with its ledger count. The body scrolls with ↑/↓, PgUp/PgDn, Home/End or the mouse wheel; `esc` closes it.
|
|
14
|
-
- a live task shows `■ stop` in the header; click → confirm → writes the task-scoped `.ai.local/team/tasks/<slug>/STOP
|
|
15
|
-
-
|
|
15
|
+
- a live task shows `■ stop` in the header; click → confirm → writes the task-scoped `.ai.local/team/tasks/<slug>/STOP`. If that directory cannot be written, a second confirm asks before the repo-wide `.ai.local/STOP` is written. The in-flight attempt finishes, no next step starts. A task with a stop sentinel shows `▶ resume` instead: confirm clears it. Saying `/task-continue <slug>` (or `продолжай` / `continue`) in a matched session is the keyboard path. <!-- i18n-keep: E4 -->
|
|
16
|
+
- one `[peak]` / `[off-peak]` row per provider in the nearest `.ai.local/models` store (the same `providers` / `links` / `windows` records the team-tasks UI reads). No store, no rows. A weekly window covers `[startHour, endHour)` — the end hour is exclusive — and `startHour > endHour` wraps across midnight. A missing or non-finite hour drops that window. Chinese public holidays are off-peak all day but are not tracked, so a holiday weekday still reads `peak` inside a window
|
|
16
17
|
- a `Z.AI` row reads the same `[peak]`/`[off-peak]` for the GLM Coding Plan: the peak `windows` linked to the `Z.AI` provider in the same store (Monday–Friday 14:00–18:00 Asia/Singapore; weekends deduct at off-peak rates all day). Without a store it falls back to that published schedule. Quota consumption percentages and reset times are intentionally not shown: the plan quota is server-side and no usage API is documented
|
|
17
18
|
- a stale task reads `◌ stale · 8d 17h ago` with a muted tone instead of pretending to run
|
|
18
19
|
- the open flag lives in `context.storage.store("panel", { initial: { open: true } })`, so it survives restarts; the live view stays in `context.storage.memory`
|
|
@@ -20,13 +21,14 @@ Modelled on the built-in MCP sidebar plugin (`packages/tui/src/feature-plugins/s
|
|
|
20
21
|
|
|
21
22
|
## Data
|
|
22
23
|
|
|
23
|
-
Reads the nearest `.ai.local/team/` above the session directory, and the provider peak windows
|
|
24
|
+
Reads the nearest `.ai.local/team/` above the session directory, and the provider peak windows from the nearest `.ai.local/models/` — the same `providers`/`links`/`windows` records `apps/team-tasks-ui` reads (`MODELS_ROOT` points at the models directory; the deprecated `CATALOG_ROOT` still works for one release). The sidebar lists only providers that store names:
|
|
24
25
|
|
|
25
26
|
- `tasks/<slug>/prompt.md` — the original prompt, the session-matching anchor
|
|
26
27
|
- `tasks/<slug>/prompt-log.md` — the follow-up log, shown in the details dialog only
|
|
27
28
|
- `tasks/<slug>/status.json` — state, attempts, gate, timestamps
|
|
28
29
|
- `tasks/<slug>/pipeline.json` — step count and the agent for each remaining step
|
|
29
|
-
- `tasks/<slug>/metrics.json` — task start, role per attempt, attempt durations
|
|
30
|
+
- `tasks/<slug>/metrics.json` — task start, role per attempt, attempt durations; `attempt_finished` carries `agent`, `stepIndex`, `wallMs`, `activeMs`, `idleMs` (and `pausedMs`/`suspendedMs` are folded into `idleMs`), plus `human_gate_started`/`task_paused`/`task_resumed` for the buckets
|
|
31
|
+
- `tasks/<slug>/.suspend.jsonl` — host-suspension intervals appended by the sidebar (`wall clock − monotonic clock` gap > 60s); the chain hook subtracts the same file when it closes an attempt
|
|
30
32
|
- `tasks/<slug>/artifact-manifest.json` — producer receipts that feed the details dialog
|
|
31
33
|
- every `tasks/*/metrics.json` — historical attempt durations that feed the ETA medians
|
|
32
34
|
- `output-guard/results*.jsonl` — tool-byte totals for the economy block, read incrementally
|
|
@@ -35,7 +37,7 @@ Reads the nearest `.ai.local/team/` above the session directory, and the provide
|
|
|
35
37
|
|
|
36
38
|
`eta.ts` estimates the remaining agent work, not wall-clock time:
|
|
37
39
|
|
|
38
|
-
- per-agent median attempt duration and a per-step retry factor (attempts ÷ distinct steps, capped at 1.5) come from every `metrics.json` under the team root; the index is rebuilt with the prompt index, every 30s, through the same mtime cache
|
|
40
|
+
- per-agent median attempt duration and a per-step retry factor (attempts ÷ distinct steps, capped at 1.5) come from every `metrics.json` under the team root; the index is rebuilt with the prompt index, every 30s, through the same mtime cache. Samples use `activeMs` when present (older ledgers: `durationMs` capped at 4h) and skip `stale`/`unknown` closes
|
|
39
41
|
- remaining plan steps are summed, then scaled by 0.65: adding right-skewed per-step medians overestimates the median of the total
|
|
40
42
|
- a running step subtracts what it already spent (finished attempts plus the current attempt's elapsed), floored at 15% of its estimate
|
|
41
43
|
- `p90` is `max(4 × p50, 1.5 × √Σ p90²)` — the quadrature keeps the range from growing linearly with the step count
|
|
@@ -56,6 +58,7 @@ The sidebar renders the session the host passes into the `sidebar.content` slot
|
|
|
56
58
|
- tiers: an exact prompt match wins; otherwise a substring match of at least 40 characters over the remaining messages. A confirmation word is ignored at every tier
|
|
57
59
|
- a `/task-continue <slug>` message maps the tab directly to that slug, case-insensitively; an unknown slug falls back to the prompt match instead of hiding the task
|
|
58
60
|
- the first successful mapping is pinned for the session, so a new message cannot flip the tab; an explicit `/task-continue <other-slug>` re-binds it
|
|
61
|
+
- the pin is written to `.ai.local/team/.session-leases/<sessionID>.json` (the same file the chain hook reads). The server plugin sets `AI_RULES_SESSION_ID` and `OPENCODE_SESSION_ID` on `shell.env` for that tab, so a later hook call still selects this task when `TEAM_TASK_SLUG` is omitted. `active-task.json` stays the list of live slugs and is not a tab binding
|
|
59
62
|
- the match is memoized per prompt-index generation and a fingerprint of every message, so the one-second tick does not re-scan every prompt
|
|
60
63
|
- a `/task ...` prefix on the prompt is stripped on both sides, so a `prompt.md` written with or without the command matches
|
|
61
64
|
- a subagent session maps through `data.session.root(sessionID)`, so its sidebar shows the parent task
|
|
@@ -104,10 +107,12 @@ The sidebar is session-scoped and follows `session.sidebar.toggle` (`ctrl+x b`).
|
|
|
104
107
|
|
|
105
108
|
## Limits
|
|
106
109
|
|
|
107
|
-
- The stop button writes the task-scoped `tasks/<slug>/STOP
|
|
110
|
+
- The stop button writes the task-scoped `tasks/<slug>/STOP`. The repo-wide `.ai.local/STOP` is written only after a second confirm, when the task directory cannot be written. It blocks new steps for every task.
|
|
108
111
|
- The resume intent clears a task-scoped sentinel only for the session's pinned task; a repository-wide `.ai.local/STOP` is lifted only by an explicit `/task-continue <slug>`, never by a text match in an unrelated session. <!-- i18n-keep: E4 -->
|
|
109
112
|
- Mapping relies on prompt text: a task without `prompt.md` cannot be matched, so its tab falls back to the prompt view. A session whose first message is not the prompt (for example a resumed tab opened with a bare `продолжай`) needs `/task-continue <slug>`. <!-- i18n-keep: E4 -->
|
|
110
113
|
- With a remote server, messages come from the server but the prompt files are read from the client filesystem; a failed message fetch keeps the last view and marks it `offline` for a minute.
|
|
111
|
-
- `status.json` timestamps
|
|
114
|
+
- `status.json` and `metrics.json` timestamps drive every bucket; a gap that no event covers lands in `idle`, which is why a long wall clock on a paused run is explained instead of hidden. A suspension is only observable while the TUI process is alive to compare clocks, so a suspend while OpenCode is closed stays inside `idle`.
|
|
115
|
+
- The suspension detector only sees gaps above 60s; shorter timer stalls stay in `work`. An attempt is capped at 4h of work (`AI_RULES_ATTEMPT_MAX_MS` moves the cap for both the hook and the sidebar).
|
|
116
|
+
- A pause interval starts at the sentinel mtime, so the tail of an in-flight attempt — the work it does between the click and its own stop — is charged to `paused`, not to `work`. This is the same choice the UI makes while `stop` is engaged, so the two layers never disagree.
|
|
112
117
|
- A timestamp later than the host clock is ignored; a future `task_started` in agent-written metrics would otherwise freeze the elapsed value at `0s`.
|
|
113
118
|
- The ETA has no per-repository model: the medians are shared by every task under the team root, so a run that differs in size from the history is only as good as the step composition and the profile. It also needs finished attempts — a first run in a fresh repository shows no estimate.
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* covers `[startHour, endHour)` — the end hour is exclusive, so the published
|
|
9
9
|
* "14:00-18:00" schedule ends at 18:00 — and `startHour > endHour` spans
|
|
10
10
|
* midnight; absolute windows match `[startAt, endAt]`. When no store is
|
|
11
|
-
* reachable
|
|
12
|
-
*
|
|
11
|
+
* reachable, `billingRates` returns no rows. `deepseekRate` and `zaiRate`
|
|
12
|
+
* still fall back to the published schedule below for a direct caller.
|
|
13
13
|
*
|
|
14
14
|
* Chinese public holidays are off-peak all day, but a holiday calendar is not
|
|
15
15
|
* shipped here, so a holiday weekday still reads `peak` inside a window.
|
|
@@ -105,14 +105,20 @@ const resolveModelsRoot = (directory: string | undefined): string | undefined =>
|
|
|
105
105
|
return undefined
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
const finiteHour = (value: number | undefined): number | null =>
|
|
109
|
+
typeof value === "number" && Number.isFinite(value) ? value : null
|
|
110
|
+
|
|
108
111
|
const asPeakWindow = (window: CatalogWindow): PeakWindow | null => {
|
|
109
112
|
if (window.kind !== "peak") return null
|
|
110
113
|
if (window.shape === "weekly" && Array.isArray(window.weekdays)) {
|
|
114
|
+
const startHour = finiteHour(window.startHour)
|
|
115
|
+
const endHour = finiteHour(window.endHour)
|
|
116
|
+
if (startHour === null || endHour === null) return null
|
|
111
117
|
return {
|
|
112
118
|
shape: "weekly",
|
|
113
119
|
weekdays: window.weekdays,
|
|
114
|
-
startHour
|
|
115
|
-
endHour
|
|
120
|
+
startHour,
|
|
121
|
+
endHour,
|
|
116
122
|
timezone: window.timezone ?? "UTC",
|
|
117
123
|
}
|
|
118
124
|
}
|
|
@@ -221,7 +227,16 @@ export const deepseekRate = (now: Date, directory?: string): DeepseekRate =>
|
|
|
221
227
|
export const zaiRate = (now: Date, directory?: string): DeepseekRate =>
|
|
222
228
|
providerRate("Z.AI", now, directory)
|
|
223
229
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
]
|
|
230
|
+
/** Providers present in the models store, in name order. No store, no rows. */
|
|
231
|
+
export const billingRates = (at: Date, directory?: string): Array<{ label: string; rate: ProviderRate }> => {
|
|
232
|
+
const root = resolveModelsRoot(directory)
|
|
233
|
+
if (root === undefined) return []
|
|
234
|
+
const names = [
|
|
235
|
+
...new Set(
|
|
236
|
+
readRecords<CatalogProvider>(path.join(root, "providers"))
|
|
237
|
+
.map((provider) => provider?.name)
|
|
238
|
+
.filter((name): name is string => typeof name === "string" && name !== ""),
|
|
239
|
+
),
|
|
240
|
+
].sort((left, right) => left.localeCompare(right))
|
|
241
|
+
return names.map((label) => ({ label, rate: providerRate(label, at, directory) }))
|
|
242
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs"
|
|
2
2
|
import path from "node:path"
|
|
3
|
+
import { MAX_ATTEMPT_MS } from "./timing.ts"
|
|
3
4
|
|
|
4
5
|
export type EtaStat = {
|
|
5
6
|
medianMs: number
|
|
@@ -33,10 +34,18 @@ type MetricEvent = {
|
|
|
33
34
|
type?: string
|
|
34
35
|
attemptId?: string
|
|
35
36
|
durationMs?: number
|
|
37
|
+
activeMs?: number
|
|
38
|
+
outcome?: string
|
|
36
39
|
agent?: string
|
|
37
40
|
stepIndex?: number
|
|
38
41
|
}
|
|
39
42
|
|
|
43
|
+
const attemptMs = (event: MetricEvent): number | undefined => {
|
|
44
|
+
const value = Number.isFinite(event.activeMs) ? event.activeMs : event.durationMs
|
|
45
|
+
if (!Number.isFinite(value) || !value || value <= 0) return undefined
|
|
46
|
+
return Math.min(value, MAX_ATTEMPT_MS)
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
type Reader = <T>(file: string) => T | null
|
|
41
50
|
|
|
42
51
|
const MIN_SAMPLE = 3
|
|
@@ -112,14 +121,18 @@ export const createEtaStats = (root: string, readJson: Reader): EtaStats => {
|
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
for (const event of events) {
|
|
115
|
-
if (event.type !== "attempt_finished"
|
|
124
|
+
if (event.type !== "attempt_finished") continue
|
|
125
|
+
// A reclaimed or unattributed close is not a work sample.
|
|
126
|
+
if (event.outcome === "stale" || event.outcome === "unknown") continue
|
|
127
|
+
const sample = attemptMs(event)
|
|
128
|
+
if (sample === undefined) continue
|
|
116
129
|
const parsed = parseAttempt(event.attemptId)
|
|
117
|
-
const ref = (event.attemptId
|
|
130
|
+
const ref = (event.attemptId ? started.get(event.attemptId) : undefined) ?? parsed
|
|
118
131
|
const agent = ref.agent ?? event.agent ?? "unknown"
|
|
119
132
|
const step = ref.step ?? parsed.step
|
|
120
133
|
if (!durations.has(agent)) durations.set(agent, [])
|
|
121
|
-
durations.get(agent)!.push(
|
|
122
|
-
all.push(
|
|
134
|
+
durations.get(agent)!.push(sample)
|
|
135
|
+
all.push(sample)
|
|
123
136
|
if (!stepKeys.has(agent)) stepKeys.set(agent, new Set())
|
|
124
137
|
stepKeys.get(agent)!.add(`${entry.name}:${step ?? event.attemptId}`)
|
|
125
138
|
}
|
|
@@ -165,15 +178,15 @@ const stepSpent = (
|
|
|
165
178
|
const agents = new Set(running.map((attempt) => attempt.agent).filter(Boolean))
|
|
166
179
|
let spent = 0
|
|
167
180
|
for (const event of events) {
|
|
168
|
-
if (event.type !== "attempt_finished"
|
|
181
|
+
if (event.type !== "attempt_finished") continue
|
|
169
182
|
const parsed = parseAttempt(event.attemptId)
|
|
170
183
|
if (parsed.step !== step) continue
|
|
171
184
|
if (agents.size > 0 && parsed.agent && !agents.has(parsed.agent)) continue
|
|
172
|
-
spent += event
|
|
185
|
+
spent += attemptMs(event) ?? 0
|
|
173
186
|
}
|
|
174
187
|
for (const attempt of running) {
|
|
175
188
|
if (attempt.startedAt === undefined) continue
|
|
176
|
-
spent += Math.max(0, now - attempt.startedAt)
|
|
189
|
+
spent += Math.min(Math.max(0, now - attempt.startedAt), MAX_ATTEMPT_MS)
|
|
177
190
|
}
|
|
178
191
|
return spent
|
|
179
192
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { Plugin } from "@opencode/plugin"
|
|
2
|
+
import { bindShellEnv } from "./task-view.ts"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Put this tab's session id on the shell the chain hook is about to run.
|
|
6
|
+
* The command prefix `TEAM_TASK_SLUG=` still wins over the inherited env.
|
|
7
|
+
*/
|
|
2
8
|
|
|
3
9
|
export default Plugin.define({
|
|
4
10
|
id: "ai-rules.task-status",
|
|
5
|
-
setup() {
|
|
11
|
+
async setup(ctx) {
|
|
12
|
+
try {
|
|
13
|
+
if (typeof ctx.session?.hook !== "function") return
|
|
14
|
+
await ctx.session.hook("shell.env", bindShellEnv)
|
|
15
|
+
} catch {
|
|
16
|
+
/* a host that rejects the name keeps the on-disk pin */
|
|
17
|
+
}
|
|
18
|
+
},
|
|
6
19
|
})
|
|
@@ -8,6 +8,17 @@ import { createEtaStats, estimateEta } from "./eta.ts"
|
|
|
8
8
|
import type { EtaStats } from "./eta.ts"
|
|
9
9
|
import { formatAge, formatDuration, formatEta } from "./format.ts"
|
|
10
10
|
import { normalize, verbatimPrompt } from "./prompt-text.ts"
|
|
11
|
+
import {
|
|
12
|
+
appendSuspendInterval,
|
|
13
|
+
gateIntervals,
|
|
14
|
+
monotonicNow,
|
|
15
|
+
pauseIntervals,
|
|
16
|
+
readSuspendIntervals,
|
|
17
|
+
suspendFile,
|
|
18
|
+
SuspendTracker,
|
|
19
|
+
timeBuckets,
|
|
20
|
+
} from "./timing.ts"
|
|
21
|
+
import type { TimeBuckets } from "./timing.ts"
|
|
11
22
|
import type {
|
|
12
23
|
Metrics,
|
|
13
24
|
MetricEvent,
|
|
@@ -35,6 +46,9 @@ export type TaskWatcherOptions = {
|
|
|
35
46
|
type PromptEntry = { slug: string; texts: string[]; updatedAt: number }
|
|
36
47
|
|
|
37
48
|
const TEAM_REL = path.join(".ai.local", "team")
|
|
49
|
+
const SESSION_ID_RE = /^[A-Za-z0-9_-]{1,128}$/
|
|
50
|
+
const LEASE_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
|
|
51
|
+
const LEASE_TTL_MS = 7 * 24 * 60 * 60 * 1000
|
|
38
52
|
const TICK_MS = 1000
|
|
39
53
|
const SYNC_MS = 5000
|
|
40
54
|
const INDEX_MS = 30000
|
|
@@ -94,6 +108,74 @@ const readJson = <T>(file: string): T | null => {
|
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
|
|
111
|
+
const sessionLeaseFile = (root: string, sessionID: string): string =>
|
|
112
|
+
path.join(root, ".session-leases", `${sessionID}.json`)
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The shell env the chain hook reads. Injected by `shell.env` for the tab
|
|
116
|
+
* that is about to run a command. An id the hook would reject is omitted.
|
|
117
|
+
*/
|
|
118
|
+
export const sessionShellEnv = (sessionID: string | undefined): Record<string, string> | null => {
|
|
119
|
+
if (!sessionID || !SESSION_ID_RE.test(sessionID)) return null
|
|
120
|
+
return { AI_RULES_SESSION_ID: sessionID, OPENCODE_SESSION_ID: sessionID }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const recordOf = (value: unknown): Record<string, unknown> =>
|
|
124
|
+
value !== null && typeof value === "object" ? (value as Record<string, unknown>) : {}
|
|
125
|
+
|
|
126
|
+
/** Fill a `shell.env` output. A prefix already on the command is left alone. */
|
|
127
|
+
export const bindShellEnv = async (input: unknown, output: unknown): Promise<void> => {
|
|
128
|
+
if (output === null || typeof output !== "object") return
|
|
129
|
+
const sessionID = recordOf(input).sessionID
|
|
130
|
+
const bound = sessionShellEnv(typeof sessionID === "string" ? sessionID : undefined)
|
|
131
|
+
if (!bound) return
|
|
132
|
+
const target = output as Record<string, unknown>
|
|
133
|
+
const env = recordOf(target.env)
|
|
134
|
+
for (const [key, value] of Object.entries(bound)) {
|
|
135
|
+
if (typeof env[key] !== "string" || env[key] === "") env[key] = value
|
|
136
|
+
}
|
|
137
|
+
target.env = env
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Persist the tab pin in the same shape the chain hook reads. A second write
|
|
142
|
+
* of the same slug keeps `firstSeenAt`. A different slug starts a new window.
|
|
143
|
+
* Returns false when the id or the slug is one the hook would ignore.
|
|
144
|
+
*/
|
|
145
|
+
export const writeSessionBinding = (root: string, sessionID: string, slug: string): boolean => {
|
|
146
|
+
if (!sessionShellEnv(sessionID)) return false
|
|
147
|
+
if (slug.length > 48 || !LEASE_SLUG_RE.test(slug)) return false
|
|
148
|
+
const file = sessionLeaseFile(root, sessionID)
|
|
149
|
+
const now = new Date().toISOString()
|
|
150
|
+
let firstSeenAt = now
|
|
151
|
+
try {
|
|
152
|
+
if (Date.now() - fs.statSync(file).mtimeMs <= LEASE_TTL_MS) {
|
|
153
|
+
const previous = JSON.parse(fs.readFileSync(file, "utf8")) as {
|
|
154
|
+
slug?: string
|
|
155
|
+
firstSeenAt?: string
|
|
156
|
+
updatedAt?: string
|
|
157
|
+
}
|
|
158
|
+
if (previous.slug === slug) firstSeenAt = previous.firstSeenAt ?? previous.updatedAt ?? now
|
|
159
|
+
}
|
|
160
|
+
} catch {
|
|
161
|
+
/* a missing lease starts a window */
|
|
162
|
+
}
|
|
163
|
+
const body = `${JSON.stringify({ slug, sessionId: sessionID, firstSeenAt, updatedAt: now })}\n`
|
|
164
|
+
fs.mkdirSync(path.dirname(file), { recursive: true })
|
|
165
|
+
const temporary = `${file}.${process.pid}.tmp`
|
|
166
|
+
fs.writeFileSync(temporary, body)
|
|
167
|
+
fs.renameSync(temporary, file)
|
|
168
|
+
return true
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const sessionLeasePresent = (root: string, sessionID: string): boolean => {
|
|
172
|
+
try {
|
|
173
|
+
return fs.statSync(sessionLeaseFile(root, sessionID)).isFile()
|
|
174
|
+
} catch {
|
|
175
|
+
return false
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
97
179
|
const findTeamRoot = (start: string): string | null => {
|
|
98
180
|
let dir = path.resolve(start)
|
|
99
181
|
for (;;) {
|
|
@@ -149,14 +231,39 @@ export const pauseState = (root: string, slug?: string): PauseScope | null => {
|
|
|
149
231
|
const pausePayload = (scope: PauseScope) =>
|
|
150
232
|
JSON.stringify({ reason: "soft stop requested from the task sidebar", scope })
|
|
151
233
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
234
|
+
const fileMtime = (file: string): number | undefined => {
|
|
235
|
+
try {
|
|
236
|
+
return fs.statSync(file).mtimeMs
|
|
237
|
+
} catch {
|
|
238
|
+
return undefined
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* When the current pause started. The hook records `task_paused` on its next
|
|
244
|
+
* run; until then the sentinel mtime is the only honest clock.
|
|
245
|
+
*/
|
|
246
|
+
const pauseStartedAt = (root: string, slug: string | undefined, scope: PauseScope): number | undefined => {
|
|
247
|
+
if (scope === "task") return slug ? fileMtime(taskSentinel(root, slug)) : undefined
|
|
248
|
+
const overlay = overlayDir(root)
|
|
249
|
+
if (!overlay) return undefined
|
|
250
|
+
return [fileMtime(path.join(overlay, "STOP")), fileMtime(path.join(overlay, "ESTOP"))]
|
|
251
|
+
.filter((value): value is number => value !== undefined)
|
|
252
|
+
.sort((left, right) => left - right)[0]
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The scope actually written, or `null` when nothing was written.
|
|
257
|
+
* A slug writes only the task sentinel. The repository sentinel is written
|
|
258
|
+
* when `scope` is `"repo"`, which the sidebar does after a second confirm.
|
|
259
|
+
*/
|
|
260
|
+
export const engagePause = (root: string, slug?: string, scope?: PauseScope): PauseScope | null => {
|
|
261
|
+
if (scope !== "repo" && slug) {
|
|
155
262
|
try {
|
|
156
263
|
fs.writeFileSync(taskSentinel(root, slug), pausePayload("task"), "utf8")
|
|
157
264
|
return "task"
|
|
158
265
|
} catch {
|
|
159
|
-
|
|
266
|
+
return null
|
|
160
267
|
}
|
|
161
268
|
}
|
|
162
269
|
const overlay = overlayDir(root)
|
|
@@ -229,6 +336,16 @@ const progressBar = (value: number, total: number, width = 8): string => {
|
|
|
229
336
|
return `${"█".repeat(filled)}${"░".repeat(width - filled)}`
|
|
230
337
|
}
|
|
231
338
|
|
|
339
|
+
/** Work first, then every non-work bucket that actually happened. */
|
|
340
|
+
const bucketText = (buckets: TimeBuckets): string => {
|
|
341
|
+
const parts = [`work ${formatDuration(buckets.workMs)}`]
|
|
342
|
+
if (buckets.gateMs > 0) parts.push(`gate ${formatDuration(buckets.gateMs)}`)
|
|
343
|
+
if (buckets.pausedMs > 0) parts.push(`paused ${formatDuration(buckets.pausedMs)}`)
|
|
344
|
+
if (buckets.suspendedMs > 0) parts.push(`sleep ${formatDuration(buckets.suspendedMs)}`)
|
|
345
|
+
if (buckets.idleMs > 0) parts.push(`idle ${formatDuration(buckets.idleMs)}`)
|
|
346
|
+
return parts.join(" · ")
|
|
347
|
+
}
|
|
348
|
+
|
|
232
349
|
const TASK_COMMAND = /^\s*\/(?:task|task-evil|task-continue|spec-start)\s+/i
|
|
233
350
|
|
|
234
351
|
const stripCommand = (text: string): string => text.replace(TASK_COMMAND, "").trim()
|
|
@@ -467,6 +584,18 @@ const buildTaskView = (
|
|
|
467
584
|
? Math.min(toMs(events.find((event) => event.type === "task_completed")?.at) ?? updatedAt, now)
|
|
468
585
|
: now
|
|
469
586
|
const elapsed = startedAt === undefined ? undefined : Math.max(0, finishedAt - startedAt)
|
|
587
|
+
const suspend = readSuspendIntervals(suspendFile(taskDir))
|
|
588
|
+
const gates = gateIntervals(events, now)
|
|
589
|
+
if (status.awaitingHumanGate && gateStart !== undefined) gates.push({ from: gateStart, to: now })
|
|
590
|
+
const pauses = pauseIntervals(events, now)
|
|
591
|
+
if (pauseScope) pauses.push({ from: pauseStartedAt(root, slug, pauseScope) ?? updatedAt, to: now })
|
|
592
|
+
const running = attempts
|
|
593
|
+
.map((attempt) => toMs(attempt.startedAt))
|
|
594
|
+
.filter((value): value is number => value !== undefined)
|
|
595
|
+
const buckets =
|
|
596
|
+
elapsed === undefined
|
|
597
|
+
? undefined
|
|
598
|
+
: timeBuckets({ wallMs: elapsed, events, running, gate: gates, pause: pauses, suspend, now })
|
|
470
599
|
|
|
471
600
|
const freshness = currentStart ?? gateStart ?? updatedAt
|
|
472
601
|
// A long real step must not be called stale: the agent's own p90 raises the floor.
|
|
@@ -502,7 +631,7 @@ const buildTaskView = (
|
|
|
502
631
|
|
|
503
632
|
const baseState =
|
|
504
633
|
state === "paused"
|
|
505
|
-
? `⏸ paused${
|
|
634
|
+
? `⏸ paused${buckets && buckets.pausedMs > 0 ? ` · ${formatDuration(buckets.pausedMs)}` : ""}`
|
|
506
635
|
: pauseScope !== null
|
|
507
636
|
? "⏸ stopping · in-flight attempt finishes"
|
|
508
637
|
: stale
|
|
@@ -531,10 +660,15 @@ const buildTaskView = (
|
|
|
531
660
|
const progress = stepNumber
|
|
532
661
|
? `${stepNumber}/${totalSteps ?? "?"} ${progressBar(stepNumber, totalSteps ?? 0)}`
|
|
533
662
|
: "?"
|
|
663
|
+
// A parallel wave runs one clock for every member: the oldest start wins.
|
|
664
|
+
const since =
|
|
665
|
+
attempts.length > 1
|
|
666
|
+
? Math.min(...attempts.map((attempt) => toMs(attempt.startedAt) ?? now))
|
|
667
|
+
: currentStart
|
|
534
668
|
stepLine = [
|
|
535
669
|
progress.trim(),
|
|
536
|
-
current.attempt ? `attempt ${current.attempt}` : null,
|
|
537
|
-
formatDuration(now -
|
|
670
|
+
attempts.length > 1 ? `${attempts.length} agents` : current.attempt ? `attempt ${current.attempt}` : null,
|
|
671
|
+
formatDuration(now - Math.min(since, now)),
|
|
538
672
|
]
|
|
539
673
|
.filter(Boolean)
|
|
540
674
|
.join(" · ")
|
|
@@ -550,7 +684,9 @@ const buildTaskView = (
|
|
|
550
684
|
const progressLabel = !done && totalSteps && stepNumber ? `${stepNumber}/${totalSteps}` : null
|
|
551
685
|
const summary =
|
|
552
686
|
state === "paused"
|
|
553
|
-
? ["paused",
|
|
687
|
+
? ["paused", buckets && buckets.pausedMs > 0 ? formatDuration(buckets.pausedMs) : null]
|
|
688
|
+
.filter(Boolean)
|
|
689
|
+
.join(" · ")
|
|
554
690
|
: pauseScope !== null
|
|
555
691
|
? "stopping"
|
|
556
692
|
: stale
|
|
@@ -563,6 +699,7 @@ const buildTaskView = (
|
|
|
563
699
|
fields: [
|
|
564
700
|
{ label: "task", value: truncate(slug, 34) },
|
|
565
701
|
{ label: "state", value: statusLine, tone: offline ? "muted" : tone },
|
|
702
|
+
...(buckets ? [{ label: "time", value: bucketText(buckets), tone: "muted" as const }] : []),
|
|
566
703
|
{ label: "role", value: actor.role ?? "—" },
|
|
567
704
|
{ label: "agent", value: agentText ?? "—" },
|
|
568
705
|
{ label: "step", value: stepLine },
|
|
@@ -788,6 +925,8 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
|
|
|
788
925
|
let etaAt = 0
|
|
789
926
|
const sessions = new Map<string, SessionState>()
|
|
790
927
|
const bindings = new Map<string, string>()
|
|
928
|
+
const lastSlug = new Map<string, string>()
|
|
929
|
+
const suspendTracker = new SuspendTracker()
|
|
791
930
|
|
|
792
931
|
const sessionState = (id: string): SessionState => {
|
|
793
932
|
const existing = sessions.get(id)
|
|
@@ -803,6 +942,7 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
|
|
|
803
942
|
if (oldest === undefined) break
|
|
804
943
|
sessions.delete(oldest)
|
|
805
944
|
bindings.delete(oldest)
|
|
945
|
+
lastSlug.delete(oldest)
|
|
806
946
|
}
|
|
807
947
|
return created
|
|
808
948
|
}
|
|
@@ -851,6 +991,9 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
|
|
|
851
991
|
const refreshView = () => {
|
|
852
992
|
const start = options.directory()
|
|
853
993
|
const now = Date.now()
|
|
994
|
+
// Read the monotonic clock before anything else: the gap is wall time the
|
|
995
|
+
// process did not run for, and it must not be charged to the agent.
|
|
996
|
+
const gap = suspendTracker.tick(now, monotonicNow())
|
|
854
997
|
const root = start ? cachedTeamRoot(start, now) : null
|
|
855
998
|
if (!root) {
|
|
856
999
|
logTaskDebug(`no team root from ${start ?? "unknown directory"}`)
|
|
@@ -881,6 +1024,13 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
|
|
|
881
1024
|
}
|
|
882
1025
|
const current = sessionState(sessionID)
|
|
883
1026
|
syncSession(sessionID)
|
|
1027
|
+
if (gap) {
|
|
1028
|
+
const slug = bindings.get(sessionID) ?? lastSlug.get(sessionID)
|
|
1029
|
+
const file = slug ? suspendFile(path.join(root, "tasks", slug)) : undefined
|
|
1030
|
+
if (file && appendSuspendInterval(file, gap)) {
|
|
1031
|
+
logTaskDebug(`session=${sessionID} suspend ${Math.round((gap.to - gap.from) / 1000)}s for ${slug}`)
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
884
1034
|
const offline = current.errorAt !== undefined && now - current.errorAt < OFFLINE_MS
|
|
885
1035
|
const pinned = bindings.get(sessionID)
|
|
886
1036
|
const view = buildSessionView(
|
|
@@ -898,7 +1048,16 @@ export const createTaskWatcher = (storage: MemoryStorage, options: TaskWatcherOp
|
|
|
898
1048
|
// Pin the first successful mapping so a later follow-up cannot flip the tab
|
|
899
1049
|
// to another task. An explicit `/task-continue` still re-binds.
|
|
900
1050
|
if (view.slug) {
|
|
901
|
-
|
|
1051
|
+
const changed = pinned !== view.slug
|
|
1052
|
+
if (changed) bindings.set(sessionID, view.slug)
|
|
1053
|
+
if (changed || !sessionLeasePresent(root, sessionID)) {
|
|
1054
|
+
try {
|
|
1055
|
+
writeSessionBinding(root, sessionID, view.slug)
|
|
1056
|
+
} catch (error) {
|
|
1057
|
+
logTaskDebug(`lease write failed for ${sessionID}: ${error instanceof Error ? error.message : String(error)}`)
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
lastSlug.set(sessionID, view.slug)
|
|
902
1061
|
} else if (pinned && !resolveSlug(root, pinned)) {
|
|
903
1062
|
bindings.delete(sessionID)
|
|
904
1063
|
}
|