governance: keep repository root clean; remove marker file; implement repo detection via structure heuristic; update tests and system prompts/templates
This commit is contained in:
23
tests/00_cli_guardrails.sh
Normal file
23
tests/00_cli_guardrails.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
. "$ROOT_DIR/tests/helpers/assert.sh"
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
# 1) Help prints usage and exits 0
|
||||
out="$(bash ./CodexHelper --help 2>&1 || true)"
|
||||
echo "$out" | grep -q "CodexHelper" || { echo "help text missing" >&2; exit 1; }
|
||||
|
||||
# 2) Guardrails: inside helper repo, run/new-project should be blocked
|
||||
if bash ./CodexHelper run 2>run.err 1>run.out; then
|
||||
echo "run should fail in helper repo" >&2; exit 1
|
||||
fi
|
||||
grep -q "Only 'new-mode'" run.err || { echo "missing guardrail message for run" >&2; exit 1; }
|
||||
|
||||
if bash ./CodexHelper new-project --mode Demo --name demo --path /tmp 2>np.err 1>np.out; then
|
||||
echo "new-project should fail in helper repo" >&2; exit 1
|
||||
fi
|
||||
grep -q "Only 'new-mode'" np.err || { echo "missing guardrail message for new-project" >&2; exit 1; }
|
||||
|
||||
exit 0
|
33
tests/01_new_mode.sh
Normal file
33
tests/01_new_mode.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
mode="DemoMode"
|
||||
dir="modes/$mode"
|
||||
|
||||
# Clean up from prior runs
|
||||
rm -rf "$dir"
|
||||
|
||||
# Create new mode
|
||||
if ! bash ./CodexHelper new-mode --name "$mode" >nm.out 2>nm.err; then
|
||||
echo "new-mode failed unexpectedly" >&2; exit 1
|
||||
fi
|
||||
|
||||
[ -f "$dir/mode.md" ] || { echo "missing $dir/mode.md" >&2; exit 1; }
|
||||
[ -f "$dir/defaults.yaml" ] || { echo "missing $dir/defaults.yaml" >&2; exit 1; }
|
||||
|
||||
# Running again without --force should fail
|
||||
if bash ./CodexHelper new-mode --name "$mode" >nm2.out 2>nm2.err; then
|
||||
echo "new-mode should have failed on overwrite without --force" >&2; exit 1
|
||||
fi
|
||||
grep -qi "already exists" nm2.err || { echo "missing overwrite message" >&2; exit 1; }
|
||||
|
||||
# With --force should succeed
|
||||
if ! bash ./CodexHelper new-mode --name "$mode" --force >nm3.out 2>nm3.err; then
|
||||
echo "new-mode --force failed unexpectedly" >&2; exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
24
tests/helpers/assert.sh
Normal file
24
tests/helpers/assert.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
fail() { echo "ASSERTION FAILED: $*" >&2; return 1; }
|
||||
|
||||
assert_eq() {
|
||||
local expected="$1" actual="$2"; shift 2
|
||||
if [ "$expected" != "$actual" ]; then
|
||||
fail "expected='$expected' actual='$actual' $*"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_contains() {
|
||||
local haystack="$1" needle="$2"; shift 2
|
||||
if ! grep -Fq -- "$needle" <<<"$haystack"; then
|
||||
fail "did not find '$needle' in output"
|
||||
fi
|
||||
}
|
||||
|
||||
run_cmd() {
|
||||
local out err rc
|
||||
out="$({ err=$( { "$@"; } 2>&1 1>&3 ); rc=$?; echo "$err" >&2; echo $rc >&4; } 3>&1 4>&1)"
|
||||
}
|
||||
|
Reference in New Issue
Block a user