zed/script/new-crate
morgankrey 27c566c212
Relicense Zed source code under GPL (#57948)
## Summary

This moves the remaining first-party AGPL surface to GPL, a less
restrictive license for these components. Apache-2.0 components are
unchanged.

Changes:
- Updates the `collab` crate from `AGPL-3.0-or-later` to
`GPL-3.0-or-later`
- Removes the root AGPL license file and first-party crate AGPL symlinks
- Updates web, documentation, Flatpak, README, and terms references to
reflect the GPL/Apache licensing split
- Updates the open-source component example list in the terms and
regenerates the RTF copy; no other terms changes are intended
- Adds guardrails so first-party crates cannot declare AGPL licensing or
carry `LICENSE-AGPL` files

Release timing: preview during the week of June 1, 2026; stable during
the week of June 8, 2026.

## Residual AGPL/Affero references

- `LICENSE-GPL`: GPLv3's own compatibility clause; unchanged official
license text.
- `crates/json_schema_store/src/schemas/package.json`: generic npm
package-license schema value, not Zed licensing.
- `script/check-licenses`, `script/new-crate`,
`script/licenses/zed-licenses.toml`: guardrails that reject or warn
against reintroducing AGPL.

## Verification

- `script/check-licenses`
- `script/generate-licenses`
- `script/generate-terms-rtf`
- `script/new-crate license_probe_for_gpl`, then discarded generated
crate
- `script/new-crate license_probe_for_agpl agpl` fails as expected
- `mdbook build docs`
- `./script/clippy`
- `git grep -n -I -E "AGPL|Affero"`
- `git diff --check`

Release Notes:

- The `collab` crate, used to implement Zed's collaboration backend, is
now licensed under the GPL instead of the AGPL. The AGPL license is no
longer used in the zed repository.
2026-05-28 20:19:17 +00:00

86 lines
2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Try to make sure we are in the zed repo root
if [ ! -d "crates" ] || [ ! -d "script" ]; then
echo "Error: Run from the \`zed\` repo root"
exit 1
fi
if [ ! -f "Cargo.toml" ]; then
echo "Error: Run from the \`zed\` repo root"
exit 1
fi
if [ $# -eq 0 ]; then
echo "Usage: $0 <crate_name> [optional_license_flag]"
exit 1
fi
CRATE_NAME="$1"
LICENSE_FLAG=$(echo "${2:-}" | tr '[:upper:]' '[:lower:]')
if [[ "$LICENSE_FLAG" == *"apache"* ]]; then
LICENSE_MODE="Apache-2.0"
LICENSE_FILE="LICENSE-APACHE"
elif [[ "$LICENSE_FLAG" == *"agpl"* ]]; then
echo "Error: New first-party crates cannot use AGPL. Use GPL or Apache."
exit 1
else
LICENSE_MODE="GPL-3.0-or-later"
LICENSE_FILE="LICENSE-GPL"
fi
if [[ ! "$CRATE_NAME" =~ ^[a-z0-9_]+$ ]]; then
echo "Error: Crate name must be lowercase and contain only alphanumeric characters and underscores"
exit 1
fi
CRATE_PATH="crates/$CRATE_NAME"
mkdir -p "$CRATE_PATH/src"
# Symlink the license
ln -sf "../../$LICENSE_FILE" "$CRATE_PATH/$LICENSE_FILE"
CARGO_TOML_TEMPLATE=$(cat << 'EOF'
[package]
name = "$CRATE_NAME"
version = "0.1.0"
edition.workspace = true
publish.workspace = true
license = "$LICENSE_MODE"
[lints]
workspace = true
[lib]
path = "src/$CRATE_NAME.rs"
[features]
default = []
[dependencies]
anyhow.workspace = true
gpui.workspace = true
ui.workspace = true
util.workspace = true
# Uncomment other workspace dependencies as needed
# assistant.workspace = true
# client.workspace = true
# project.workspace = true
# settings.workspace = true
EOF
)
# Populate template
CARGO_TOML_CONTENT=$(echo "$CARGO_TOML_TEMPLATE" | sed \
-e "s/\$CRATE_NAME/$CRATE_NAME/g" \
-e "s/\$LICENSE_MODE/$LICENSE_MODE/g")
echo "$CARGO_TOML_CONTENT" > "$CRATE_PATH/Cargo.toml"
echo "//! # $CRATE_NAME" > "$CRATE_PATH/src/$CRATE_NAME.rs"
echo "Created new crate: $CRATE_NAME in $CRATE_PATH"
echo "License: $LICENSE_MODE (symlinked from $LICENSE_FILE)"
echo "Don't forget to add the new crate to the workspace!"