Files
coder/scripts/check_emdash.sh
T
Dean Sheather e57525002c chore: remove agents experiment flag and mark feature as beta (#24432)
Remove the `ExperimentAgents` feature flag so the Agents feature is
always available without requiring `--experiments=agents`. The feature
is now in beta.

Existing deployments that still pass `--experiments=agents` will get a
harmless "ignoring unknown experiment" warning on startup.

### Changes

**Backend:**
- Remove `RequireExperimentWithDevBypass` middleware from chat and MCP
server routes
- Always include `AgentsAccessRole` in assignable site roles (later
refactored to org-scoped on main; rebase keeps that)
- Always set `AgentsTabVisible = true`, then drop the entire dead
`AgentsTabVisible` metadata pipeline (Go htmlState field,
populateHTMLState goroutine, HTML meta tag, useEmbeddedMetadata
registration, mock); no production consumer reads it. `AgentsNavItem`
already gates on `permissions.createChat`.
- Make `blob:` CSP `img-src` addition unconditional
- Remove `ExperimentAgents` constant, `DisplayName` case, and
`ExperimentsKnown` entry

**CLI:**
- Graduate the agents TUI from `coder exp agents` to `coder agents`
(moved from `AGPLExperimental()` to `CoreSubcommands()`)
- Drop the `agent` alias so it does not collide with the hidden
workspace-agent command
- Rename implementation files `cli/exp_agents_*.go` -> `cli/agents_*.go`
and internal identifiers (`expChatsTUIModel` -> `chatsTUIModel`,
`newExpChatsTUIModel` -> `newChatsTUIModel`, `setupExpAgentsBackend` ->
`setupAgentsBackend`, `startExpAgentsSession` -> `startAgentsSession`,
`expAgentsPtr` -> `agentsPtr`, `expAgentsSession` -> `agentsSession`,
`TestExpAgents*` -> `TestAgents*`). `expClient` (the
`*codersdk.ExperimentalClient` local) is kept; `coderd/exp_chats*.go`
and other still-experimental `cli/exp_*.go` commands are intentionally
untouched.

**Frontend:**
- Remove experiment check from `AgentsNavItem` - render when
`canCreateChat` is true
- Remove `agentsEnabled` experiment check from `WorkspacesPage`, then
gate `chatsByWorkspace` on `permissions.createChat` so users without
chat access don't trigger the per-page DB query (Copilot review
feedback)
- Add `FeatureStageBadge` (beta) next to the Coder logo in the Agents
sidebar (desktop + mobile)

**Docs:**
- Remove experiment flag setup instructions from `early-access.md` and
`getting-started.md` (and rename `early-access.md`'s "Enable Coder
Agents" heading to "Set up Coder Agents", since there is no enablement
step left)
- Update `chats-api.md` and `getting-started.md`'s Chats API note to say
"beta" instead of "experimental"
- `docs/manifest.json`: drop "experimental" from the Chats API sidebar
description
- `make gen` regenerated `docs/reference/cli/agents.md` and the CLI
index
- `scripts/check_emdash.sh`: exclude `cli/testdata/*.golden` and
`enterprise/cli/testdata/*.golden` from the new repo-wide emdash lint,
since serpent emits emdash borders in every generated `--help` golden
file

**Tests:**
- Remove `ExperimentAgents` setup from all test files (14 occurrences
across 7 files)
- Update stale "with the agents experiment" comments in
`coderd/x/chatd/integration_test.go` and `coderd/mcp_test.go`


<img width="1185" height="900" alt="image"
src="https://github.com/user-attachments/assets/b420bc8f-41d6-42c6-abd8-ad572533d651"
/>


> 🤖 Generated by Coder Agents
2026-05-01 01:49:00 +10:00

122 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# shellcheck source=scripts/lib.sh
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
cdroot
echo "--- check for emdash/endash characters"
mode="changed"
for arg in "$@"; do
if [[ "$arg" == "--all" ]]; then
mode="all"
fi
done
# Build the pattern from raw bytes so the script itself does not
# contain literal emdash/endash characters (which would trigger
# the check when the script is in the diff).
emdash=$'\xE2\x80\x94'
endash=$'\xE2\x80\x93'
pattern="${emdash}|${endash}"
# Git exclude_pathspecs excluded from the check. Used in both ls-files and diff comparison.
exclude_pathspecs=(
":(exclude)aibridge/fixtures/**/*.txtar"
# Generated CLI golden files embed serpent's emdash-bordered footer.
":(exclude)cli/testdata/*.golden"
":(exclude)enterprise/cli/testdata/*.golden"
)
scan_all_files() {
local output
output=$(git ls-files -z -- "${exclude_pathspecs[@]}" | xargs -0 grep -IEn "$pattern" 2>/dev/null || true)
if [[ -n "$output" ]]; then
echo "$output"
found=1
else
found=0
fi
}
if [[ "$mode" == "all" ]]; then
scan_all_files
else
base=""
if [[ -n "${GITHUB_BASE_REF:-}" ]]; then
base="origin/${GITHUB_BASE_REF}"
elif git rev-parse --verify origin/main >/dev/null 2>&1; then
base=$(git merge-base HEAD origin/main 2>/dev/null || echo "origin/main")
fi
if [[ -z "$base" ]]; then
echo "WARNING: no base ref found, scanning all tracked files."
scan_all_files
else
# Ensure the base ref is fetchable. CI shallow clones
# (fetch-depth: 1) may not have the base branch available.
if ! git rev-parse --verify "$base" >/dev/null 2>&1; then
ref="${base#origin/}"
echo "Base ref $base not found locally, fetching $ref..."
git fetch origin "$ref" --depth=1 2>/dev/null || true
if ! git rev-parse --verify "$base" >/dev/null 2>&1; then
echo "ERROR: could not fetch base ref $base."
exit 1
fi
fi
found=0
if ! diff_output=$(git diff "$base" -U0 -- . "${exclude_pathspecs[@]}" 2>&1); then
echo "ERROR: git diff against $base failed:"
echo "$diff_output"
exit 1
fi
if [[ -z "$diff_output" ]]; then
echo "OK: no changes to check."
exit 0
fi
# Parse the diff to check only added lines for emdash/endash.
current_file=""
current_line=0
while IFS= read -r diff_line; do
if [[ "$diff_line" =~ ^\+\+\+\ b/(.*) ]]; then
current_file="${BASH_REMATCH[1]}"
fi
# Anchored to hunk header structure to avoid matching
# digits from trailing function context.
if [[ "$diff_line" =~ ^@@\ -[0-9,]+\ \+([0-9]+) ]]; then
current_line=${BASH_REMATCH[1]}
continue
fi
if [[ "$diff_line" =~ ^\+ ]] && [[ ! "$diff_line" =~ ^\+\+\+\ [ab/] ]]; then
if echo "$diff_line" | grep -Eq "$pattern"; then
echo "${current_file}:${current_line}:${diff_line:1}"
found=1
fi
((current_line++)) || true
fi
done <<<"$diff_output"
fi
fi
if [[ "$found" -ne 0 ]]; then
echo ""
echo "ERROR: Found emdash (U+2014) or endash (U+2013) characters."
echo ""
echo " Do not use emdash or endash in code, comments, string literals,"
echo " or documentation. Use commas, semicolons, or periods instead."
echo " Restructure the sentence if needed. Do not replace them with"
echo " ' -- ' either."
echo ""
echo " Example:"
echo " Bad: This is slow [emdash] we should cache it."
echo " Good: This is slow. We should cache it."
echo " Good: This is slow, so we should cache it."
echo ""
exit 1
fi
echo "OK: no emdash or endash characters found."