Skip to content

Commit 8a4d5cd

Browse files
jeremyederclaude
andauthored
Feature/add codebase agent (#337)
draft for discussion. I think we would also want to add something in claude.md that points to this agent. we also need to centralize logic. Should ewe move out of claude.md "entirely", and into an agent(s)? --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 77841b8 commit 8a4d5cd

File tree

16 files changed

+3163
-41
lines changed

16 files changed

+3163
-41
lines changed
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: Amber Knowledge Sync - Dependencies
2+
3+
on:
4+
schedule:
5+
# Run daily at 7 AM UTC
6+
- cron: '0 7 * * *'
7+
8+
workflow_dispatch: # Allow manual triggering
9+
10+
permissions:
11+
contents: write # Required to commit changes
12+
issues: write # Required to create constitution violation issues
13+
14+
jobs:
15+
sync-dependencies:
16+
name: Update Amber's Dependency Knowledge
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v5
22+
with:
23+
ref: main
24+
token: ${{ secrets.GITHUB_TOKEN }}
25+
26+
- name: Setup Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.11'
30+
cache: 'pip'
31+
32+
- name: Install dependencies
33+
run: |
34+
# Install toml parsing library (prefer tomli for Python <3.11 compatibility)
35+
pip install tomli 2>/dev/null || echo "tomli not available, will use manual parsing"
36+
37+
- name: Run dependency sync script
38+
id: sync
39+
run: |
40+
echo "Running Amber dependency sync..."
41+
python scripts/sync-amber-dependencies.py
42+
43+
# Check if agent file was modified
44+
if git diff --quiet agents/amber.md; then
45+
echo "changed=false" >> $GITHUB_OUTPUT
46+
echo "No changes detected - dependency versions are current"
47+
else
48+
echo "changed=true" >> $GITHUB_OUTPUT
49+
echo "Changes detected - will commit update"
50+
fi
51+
52+
- name: Validate sync accuracy
53+
run: |
54+
echo "🧪 Validating dependency extraction..."
55+
56+
# Spot check: Verify K8s version matches
57+
K8S_IN_GOMOD=$(grep "k8s.io/api" components/backend/go.mod | awk '{print $2}' | sed 's/v//')
58+
K8S_IN_AMBER=$(grep "k8s.io/{api" agents/amber.md | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
59+
60+
if [ "$K8S_IN_GOMOD" != "$K8S_IN_AMBER" ]; then
61+
echo "❌ K8s version mismatch: go.mod=$K8S_IN_GOMOD, Amber=$K8S_IN_AMBER"
62+
exit 1
63+
fi
64+
65+
echo "✅ Validation passed: Kubernetes $K8S_IN_GOMOD"
66+
67+
- name: Validate constitution compliance
68+
id: constitution_check
69+
run: |
70+
echo "🔍 Checking Amber's alignment with ACP Constitution..."
71+
72+
# Check if Amber enforces required principles
73+
VIOLATIONS=""
74+
75+
# Principle III: Type Safety - Check for panic() enforcement
76+
if ! grep -q "FORBIDDEN.*panic()" agents/amber.md; then
77+
VIOLATIONS="${VIOLATIONS}\n- Missing Principle III enforcement: No panic() rule"
78+
fi
79+
80+
# Principle IV: TDD - Check for Red-Green-Refactor mention
81+
if ! grep -qi "Red-Green-Refactor\|Test-Driven Development" agents/amber.md; then
82+
VIOLATIONS="${VIOLATIONS}\n- Missing Principle IV enforcement: TDD requirements"
83+
fi
84+
85+
# Principle VI: Observability - Check for structured logging
86+
if ! grep -qi "structured logging" agents/amber.md; then
87+
VIOLATIONS="${VIOLATIONS}\n- Missing Principle VI enforcement: Structured logging"
88+
fi
89+
90+
# Principle VIII: Context Engineering - CRITICAL
91+
if ! grep -q "200K token\|context budget" agents/amber.md; then
92+
VIOLATIONS="${VIOLATIONS}\n- Missing Principle VIII enforcement: Context engineering"
93+
fi
94+
95+
# Principle X: Commit Discipline
96+
if ! grep -qi "conventional commit" agents/amber.md; then
97+
VIOLATIONS="${VIOLATIONS}\n- Missing Principle X enforcement: Commit discipline"
98+
fi
99+
100+
# Security: User token requirement
101+
if ! grep -q "GetK8sClientsForRequest" agents/amber.md; then
102+
VIOLATIONS="${VIOLATIONS}\n- Missing Principle II enforcement: User token authentication"
103+
fi
104+
105+
if [ -n "$VIOLATIONS" ]; then
106+
echo "constitution_violations<<EOF" >> $GITHUB_OUTPUT
107+
echo -e "$VIOLATIONS" >> $GITHUB_OUTPUT
108+
echo "EOF" >> $GITHUB_OUTPUT
109+
echo "violations_found=true" >> $GITHUB_OUTPUT
110+
echo "⚠️ Constitution violations detected (will file issue)"
111+
else
112+
echo "violations_found=false" >> $GITHUB_OUTPUT
113+
echo "✅ Constitution compliance verified"
114+
fi
115+
116+
- name: File constitution violation issue
117+
if: steps.constitution_check.outputs.violations_found == 'true'
118+
uses: actions/github-script@v7
119+
with:
120+
script: |
121+
const violations = `${{ steps.constitution_check.outputs.constitution_violations }}`;
122+
123+
await github.rest.issues.create({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
title: '🚨 Amber Constitution Compliance Violations Detected',
127+
body: `## Constitution Violations in Amber Agent Definition
128+
129+
**Date**: ${new Date().toISOString().split('T')[0]}
130+
**Agent File**: \`agents/amber.md\`
131+
**Constitution**: \`.specify/memory/constitution.md\` (v1.0.0)
132+
133+
### Violations Detected:
134+
135+
${violations}
136+
137+
### Required Actions:
138+
139+
1. Review Amber's agent definition against the ACP Constitution
140+
2. Add missing principle enforcement rules
141+
3. Update Amber's behavior guidelines to include constitution compliance
142+
4. Verify fix by running: \`gh workflow run amber-dependency-sync.yml\`
143+
144+
### Related Documents:
145+
146+
- ACP Constitution: \`.specify/memory/constitution.md\`
147+
- Amber Agent: \`agents/amber.md\`
148+
- Implementation Plan: \`docs/implementation-plans/amber-implementation.md\`
149+
150+
**Priority**: P1 - Amber must follow and enforce the constitution
151+
**Labels**: amber, constitution, compliance
152+
153+
---
154+
*Auto-filed by Amber dependency sync workflow*`,
155+
labels: ['amber', 'constitution', 'compliance', 'automated']
156+
});
157+
158+
- name: Display changes
159+
if: steps.sync.outputs.changed == 'true'
160+
run: |
161+
echo "📝 Changes to Amber's dependency knowledge:"
162+
git diff agents/amber.md
163+
164+
- name: Commit and push changes
165+
if: steps.sync.outputs.changed == 'true'
166+
run: |
167+
git config user.name "github-actions[bot]"
168+
git config user.email "github-actions[bot]@users.noreply.github.com"
169+
170+
git add agents/amber.md
171+
172+
# Generate commit message with timestamp
173+
COMMIT_DATE=$(date +%Y-%m-%d)
174+
175+
git commit -m "chore(amber): sync dependency versions - ${COMMIT_DATE}
176+
177+
🤖 Automated daily knowledge sync
178+
179+
Updated Amber's dependency knowledge with current versions from:
180+
- components/backend/go.mod
181+
- components/operator/go.mod
182+
- components/runners/claude-code-runner/pyproject.toml
183+
- components/frontend/package.json
184+
185+
This ensures Amber has accurate knowledge of our dependency stack
186+
for codebase analysis, security monitoring, and upgrade planning.
187+
188+
Co-Authored-By: Amber <noreply@ambient-code.ai>"
189+
190+
git push
191+
192+
- name: Summary
193+
if: always()
194+
run: |
195+
if [ "${{ steps.sync.outputs.changed }}" == "true" ]; then
196+
echo "## ✅ Amber Knowledge Updated" >> $GITHUB_STEP_SUMMARY
197+
echo "Dependency versions synced from go.mod, pyproject.toml, package.json" >> $GITHUB_STEP_SUMMARY
198+
elif [ "${{ job.status }}" == "failure" ]; then
199+
echo "## ⚠️ Sync Failed" >> $GITHUB_STEP_SUMMARY
200+
echo "Check logs above. Common issues: missing dependency files, AUTO-GENERATED markers" >> $GITHUB_STEP_SUMMARY
201+
else
202+
echo "## ✓ No Changes Needed" >> $GITHUB_STEP_SUMMARY
203+
fi

0 commit comments

Comments
 (0)