Skip to content
Open

ok #339598

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0b34c74
Create datadog-synthetics.yml
NguyenCuong1989 Nov 17, 2025
5011608
Add Deno CI workflow for linting and testing
NguyenCuong1989 Nov 17, 2025
17f7ce8
Merge branch 'microsoft:main' into main
NguyenCuong1989 Nov 26, 2025
81bae05
Update issue templates
NguyenCuong1989 Nov 26, 2025
810c8e5
Merge branch 'main' into main
NguyenCuong1989 Nov 26, 2025
d73c48c
Merge pull request #3 from NguyenCuong1989/NguyenCuong1989-patch-1
NguyenCuong1989 Dec 16, 2025
48b998e
Merge branch 'main' into main
NguyenCuong1989 Feb 13, 2026
f035388
Merge branch 'main' into main
NguyenCuong1989 Feb 15, 2026
1942c27
Merge branch 'microsoft:main' into main
NguyenCuong1989 Mar 12, 2026
6e99b9c
Merge branch 'main' into main
NguyenCuong1989 Mar 12, 2026
ae8b039
Merge branch 'main' into main
NguyenCuong1989 Mar 17, 2026
02a3079
Merge branch 'main' into main
NguyenCuong1989 Jul 19, 2026
8dca2da
chore(codespaces): normalize and verify Git commit identity
NguyenCuong1989 Jul 28, 2026
09d2f1c
chore: setup autonomous guardrails
mygithubapppro[bot] Sep 28, 2026
b1e005f
docs: add fork attribution and non-affiliation notice
NguyenCuong1989 Oct 4, 2026
4fc6143
docs: clarify personal fork provenance
NguyenCuong1989 Oct 4, 2026
352a6a9
docs: make fork provenance and support boundaries explicit
NguyenCuong1989 Oct 4, 2026
0864bda
chore: remove unused Datadog template workflow
NguyenCuong1989 Oct 4, 2026
17978fc
chore: remove unused Deno template workflow
NguyenCuong1989 Oct 4, 2026
fdfbe0b
docs: harden agent guardrails and repository safety rules
NguyenCuong1989 Oct 4, 2026
5d1a6e9
Merge branch 'main' into main
NguyenCuong1989 Oct 4, 2026
18e4bcc
Potential fix for pull request finding 'Rejects valid email addresses…
NguyenCuong1989 Oct 4, 2026
be92c2d
chore: align PR scope with upstream
NguyenCuong1989 Oct 4, 2026
e124708
chore: restore upstream issue template
NguyenCuong1989 Oct 4, 2026
c1c60c7
chore: remove PR-local workflow from upstream scope
NguyenCuong1989 Oct 4, 2026
ea9f216
chore: remove fork-only notice from upstream PR
NguyenCuong1989 Oct 4, 2026
703a1fc
chore: remove fork-only guardrails from upstream PR
NguyenCuong1989 Oct 4, 2026
78e9ed3
chore: setup autonomous guardrails
mygithubapppro[bot] Oct 7, 2026
89dd631
Merge branch 'microsoft:main' into main
NguyenCuong1989 Oct 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .devcontainer/normalize-git-identity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh
set -eu

is_valid_email() {
case "${1:-}" in
""|*"(none)"*|*" "*|@*|*@|*@*@*) return 1 ;;
*@*) return 0 ;;
*) return 1 ;;
esac
}

clean_malformed_local_email() {
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
return 0
fi

local_email="$(git config --local --get user.email 2>/dev/null || true)"
if [ -n "$local_email" ] && ! is_valid_email "$local_email"; then
git config --local --unset-all user.email 2>/dev/null || true
printf '%s\n' "Removed malformed repository-local Git email override: $local_email"
fi
}

normalize_git_identity() {
# A malformed repository-local value overrides a valid global identity, so
# clean it before deciding whether the global configuration can be preserved.
clean_malformed_local_email

current_name="$(git config --global --get user.name 2>/dev/null || true)"
current_email="$(git config --global --get user.email 2>/dev/null || true)"

if [ -n "$current_name" ] && is_valid_email "$current_email"; then
printf '%s\n' "Git identity already configured: $current_name <$current_email>"
return 0
fi

login="${GITHUB_USER:-${GITHUB_ACTOR:-}}"
account_id=""
display_name=""

if command -v gh >/dev/null 2>&1; then
login_from_api="$(gh api user --jq '.login' 2>/dev/null || true)"
account_id="$(gh api user --jq '.id' 2>/dev/null || true)"
display_name="$(gh api user --jq '.name // .login' 2>/dev/null || true)"
[ -n "$login_from_api" ] && login="$login_from_api"
fi

if [ -z "$login" ]; then
printf '%s\n' "WARNING: Git identity is missing and the GitHub login could not be resolved."
printf '%s\n' "Run: git config --global user.name '<name>'"
printf '%s\n' " git config --global user.email '<email>'"
return 0
fi

[ -n "$display_name" ] || display_name="$login"
if [ -n "$account_id" ]; then
noreply_email="${account_id}+${login}@users.noreply.github.com"
else
noreply_email="${login}@users.noreply.github.com"
fi

git config --global user.name "$display_name"
git config --global user.email "$noreply_email"

printf '%s\n' "Configured Git identity: $(git var GIT_AUTHOR_IDENT)"
}

normalize_git_identity
4 changes: 4 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/bin/sh
set -eu

SCRIPT_DIR="$(CDPATH= cd "$(dirname "$0")" && pwd)"
sh "$SCRIPT_DIR/normalize-git-identity.sh"

npm i
npm run electron
102 changes: 102 additions & 0 deletions .devcontainer/test-normalize-git-identity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/sh
set -eu

SCRIPT_DIR="$(CDPATH= cd "$(dirname "$0")" && pwd)"
SCRIPT="$SCRIPT_DIR/normalize-git-identity.sh"
ORIGINAL_PATH="$PATH"
TMP_ROOT="$(mktemp -d)"
trap 'rm -rf "$TMP_ROOT"' EXIT HUP INT TERM

CASE_NO=0
HOME_DIR=""
BIN_DIR=""
REPO_DIR=""

fail() {
printf '%s\n' "FAIL: $*" >&2
exit 1
}

assert_eq() {
expected="$1"
actual="$2"
label="$3"
[ "$expected" = "$actual" ] || fail "$label: expected '$expected', got '$actual'"
}

new_case() {
CASE_NO=$((CASE_NO + 1))
case_dir="$TMP_ROOT/case-$CASE_NO"
HOME_DIR="$case_dir/home"
BIN_DIR="$case_dir/bin"
REPO_DIR="$case_dir/repo"
mkdir -p "$HOME_DIR" "$BIN_DIR" "$REPO_DIR"
git -C "$REPO_DIR" init -q
}

write_fake_gh_profile() {
cat > "$BIN_DIR/gh" <<'EOF'
#!/bin/sh
case "$*" in
*"--jq .login") printf '%s\n' 'NguyenCuong1989' ;;
*"--jq .id") printf '%s\n' '196793856' ;;
*"--jq .name // .login") printf '%s\n' 'NgCuong' ;;
*) exit 1 ;;
esac
EOF
chmod +x "$BIN_DIR/gh"
}

write_failing_gh() {
cat > "$BIN_DIR/gh" <<'EOF'
#!/bin/sh
exit 1
EOF
chmod +x "$BIN_DIR/gh"
}

run_normalizer() {
(
cd "$REPO_DIR"
HOME="$HOME_DIR" \
PATH="$BIN_DIR:$ORIGINAL_PATH" \
GITHUB_USER="${GITHUB_USER_OVERRIDE:-}" \
GITHUB_ACTOR="" \
sh "$SCRIPT"
)
}

printf '%s\n' "[1/4] Preserve a valid global identity and remove a malformed local override"
new_case
HOME="$HOME_DIR" git config --global user.name 'Existing User'
HOME="$HOME_DIR" git config --global user.email '[email protected]'
git -C "$REPO_DIR" config user.email 'pc@ai.(none)'
run_normalizer >/dev/null
assert_eq 'Existing User' "$(HOME="$HOME_DIR" git config --global --get user.name)" 'preserved global name'
assert_eq '[email protected]' "$(HOME="$HOME_DIR" git config --global --get user.email)" 'preserved global email'
assert_eq '' "$(git -C "$REPO_DIR" config --local --get user.email 2>/dev/null || true)" 'removed malformed local email'

printf '%s\n' "[2/4] Resolve identity from the authenticated GitHub profile"
new_case
write_fake_gh_profile
run_normalizer >/dev/null
assert_eq 'NgCuong' "$(HOME="$HOME_DIR" git config --global --get user.name)" 'GitHub display name'
assert_eq '[email protected]' "$(HOME="$HOME_DIR" git config --global --get user.email)" 'GitHub noreply email'

printf '%s\n' "[3/4] Fall back to the Codespaces login when GitHub API resolution fails"
new_case
write_failing_gh
GITHUB_USER_OVERRIDE='NguyenCuong1989'
run_normalizer >/dev/null
unset GITHUB_USER_OVERRIDE
assert_eq 'NguyenCuong1989' "$(HOME="$HOME_DIR" git config --global --get user.name)" 'fallback name'
assert_eq '[email protected]' "$(HOME="$HOME_DIR" git config --global --get user.email)" 'fallback noreply email'

printf '%s\n' "[4/4] Remain non-blocking when no GitHub identity can be resolved"
new_case
write_failing_gh
run_normalizer >/dev/null
assert_eq '' "$(HOME="$HOME_DIR" git config --global --get user.name 2>/dev/null || true)" 'missing unresolved name'
assert_eq '' "$(HOME="$HOME_DIR" git config --global --get user.email 2>/dev/null || true)" 'missing unresolved email'

printf '%s\n' 'PASS: Git identity normalization tests completed.'
13 changes: 13 additions & 0 deletions GUARDRAILS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# AI Agent Guardrails

**CRITICAL: ALL AI AGENTS MUST COMPLY WITH THESE RULES**

This file defines safety restrictions that AI agents MUST follow when working in this workspace.

- **Follow prompt instructions EXACTLY**
- **No destructive commands** (e.g., rm -rf /)
- **Protect all secrets** (Never expose .env or tokens)
- **Commands must be non-interactive**
- **Respect Branch Protection & Auto-merge rules**

By adhering to this, the repository maintains a 100% autonomous and safe execution environment.