ai-core-framework 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +21 -0
- package/.codex-plugin/plugin.json +35 -0
- package/.cursor-plugin/plugin.json +22 -0
- package/README.md +173 -0
- package/bin/ai-core-framework.js +110 -0
- package/core/README.md +162 -0
- package/core/agents/README.md +32 -0
- package/core/agents/business-analyst.md +269 -0
- package/core/agents/developer.md +375 -0
- package/core/agents/qa-tester.md +477 -0
- package/core/agents/scrum-master.md +136 -0
- package/core/agents/tech-lead.md +345 -0
- package/core/config/backlog.schema.json +38 -0
- package/core/config/docs-policy.default.json +37 -0
- package/core/config/release.schema.json +120 -0
- package/core/config/ticket.schema.json +253 -0
- package/core/rules/00-global-rules.md +373 -0
- package/core/rules/01-git-workflow.md +388 -0
- package/core/rules/02-code-quality.md +77 -0
- package/core/rules/03-security.md +78 -0
- package/core/rules/04-documentation.md +72 -0
- package/core/rules/05-testing-mandatory.md +374 -0
- package/core/rules/06-approval-gates.md +388 -0
- package/core/rules/07-definition-of-ready.md +112 -0
- package/core/rules/08-definition-of-done.md +149 -0
- package/core/scripts/ai-core.sh +456 -0
- package/core/scripts/generate-views.sh +210 -0
- package/core/scripts/install-codex-prompts.sh +127 -0
- package/core/scripts/log-user-request.sh +113 -0
- package/core/scripts/setup-project.sh +183 -0
- package/core/scripts/sync-platforms.sh +322 -0
- package/core/scripts/validate-audit-log.sh +73 -0
- package/core/scripts/validate-docs.sh +365 -0
- package/core/scripts/validate-permissions.sh +132 -0
- package/core/scripts/validate-state.sh +611 -0
- package/core/scripts/workflow.sh +513 -0
- package/core/skills/README.md +21 -0
- package/core/skills/ai-core-commands/SKILL.md +86 -0
- package/core/skills/brainstorming/SKILL.md +40 -0
- package/core/skills/development-implement-task/SKILL.md +308 -0
- package/core/skills/executing-ticket/SKILL.md +28 -0
- package/core/skills/git-branch-status/SKILL.md +56 -0
- package/core/skills/git-cleanup-branches/SKILL.md +57 -0
- package/core/skills/git-scan-untracked/SKILL.md +50 -0
- package/core/skills/meta-generate-views/SKILL.md +54 -0
- package/core/skills/meta-request-log/SKILL.md +61 -0
- package/core/skills/meta-sprint-report/SKILL.md +59 -0
- package/core/skills/meta-sync-platforms/SKILL.md +53 -0
- package/core/skills/meta-ticket-health/SKILL.md +61 -0
- package/core/skills/meta-validate-audit-log/SKILL.md +42 -0
- package/core/skills/meta-validate-docs/SKILL.md +58 -0
- package/core/skills/meta-validate-permissions/SKILL.md +53 -0
- package/core/skills/meta-validate-state/SKILL.md +58 -0
- package/core/skills/planning-analyze-requirements/SKILL.md +471 -0
- package/core/skills/planning-backlog-status/SKILL.md +57 -0
- package/core/skills/planning-document-existing-requirements/SKILL.md +246 -0
- package/core/skills/planning-estimate-task/SKILL.md +60 -0
- package/core/skills/planning-groom-ticket/SKILL.md +442 -0
- package/core/skills/planning-mark-ready/SKILL.md +111 -0
- package/core/skills/planning-plan-refactor/SKILL.md +66 -0
- package/core/skills/planning-plan-sprint/SKILL.md +112 -0
- package/core/skills/planning-prioritize-backlog/SKILL.md +62 -0
- package/core/skills/planning-write-plan/SKILL.md +68 -0
- package/core/skills/project-detect-stack/SKILL.md +71 -0
- package/core/skills/project-discover-codebase/SKILL.md +74 -0
- package/core/skills/project-setup-project/SKILL.md +113 -0
- package/core/skills/qa-bug-status/SKILL.md +52 -0
- package/core/skills/qa-report-bug/SKILL.md +518 -0
- package/core/skills/qa-smoke-test/SKILL.md +387 -0
- package/core/skills/qa-triage-bug/SKILL.md +62 -0
- package/core/skills/qa-verify-fix/SKILL.md +446 -0
- package/core/skills/release-hotfix/SKILL.md +117 -0
- package/core/skills/release-release/SKILL.md +123 -0
- package/core/skills/release-rollback/SKILL.md +62 -0
- package/core/skills/review-create-pr/SKILL.md +418 -0
- package/core/skills/review-merge-pr/SKILL.md +425 -0
- package/core/skills/review-techlead-review/SKILL.md +547 -0
- package/core/skills/using-ai-core/SKILL.md +72 -0
- package/core/skills/verification-before-done/SKILL.md +35 -0
- package/core/skills/writing-implementation-plan/SKILL.md +45 -0
- package/core/templates/ci/ai-core-governance.yml +112 -0
- package/core/templates/ci/node-pnpm.yml +35 -0
- package/core/templates/pm/retrospective-template.md +47 -0
- package/core/templates/pm/sprint-plan-template.md +45 -0
- package/core/templates/pr/pull-request-template.md +247 -0
- package/core/templates/project/CODEOWNERS +11 -0
- package/core/templates/project/docs-policy.json +3 -0
- package/core/templates/project/project-config.yaml +137 -0
- package/core/templates/project/project-structure.yaml +76 -0
- package/core/templates/qa/bug-report-template.md +371 -0
- package/core/templates/qa/test-plan-template.md +57 -0
- package/core/templates/release/release-record-template.json +67 -0
- package/core/templates/requirements/PRD-template.md +58 -0
- package/core/templates/requirements/user-story-template.md +381 -0
- package/core/templates/technical/ADR-template.md +46 -0
- package/core/templates/technical/refactor-plan-template.md +84 -0
- package/core/templates/technical/tech-design-template.md +71 -0
- package/core/workflows/bug-lifecycle.md +56 -0
- package/core/workflows/feature-lifecycle.md +347 -0
- package/core/workflows/hotfix-lifecycle.md +65 -0
- package/core/workflows/sprint-lifecycle.md +56 -0
- package/lib/install-codex.js +85 -0
- package/package.json +36 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ============================================================================
|
|
3
|
+
# sync-platforms.sh
|
|
4
|
+
# Sync core/ content sang Claude Code, Cursor, Windsurf format.
|
|
5
|
+
# Usage: bash core/scripts/sync-platforms.sh
|
|
6
|
+
# ============================================================================
|
|
7
|
+
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
AI_CORE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
11
|
+
PROJECT_ROOT="$(dirname "$AI_CORE_DIR")"
|
|
12
|
+
|
|
13
|
+
echo "🔄 Syncing core/ to AI platforms..."
|
|
14
|
+
echo " Source: $AI_CORE_DIR"
|
|
15
|
+
echo " Target: $PROJECT_ROOT"
|
|
16
|
+
|
|
17
|
+
# ============================================================================
|
|
18
|
+
# 1. CLAUDE CODE (.claude/)
|
|
19
|
+
# ============================================================================
|
|
20
|
+
# Claude Code uses:
|
|
21
|
+
# .claude/agents/<name>.md — subagents
|
|
22
|
+
# .claude/commands/<name>.md — slash commands (flat)
|
|
23
|
+
# CLAUDE.md — project-level instructions
|
|
24
|
+
# ============================================================================
|
|
25
|
+
|
|
26
|
+
sync_claude_code() {
|
|
27
|
+
echo ""
|
|
28
|
+
echo "📦 [1/3] Claude Code..."
|
|
29
|
+
|
|
30
|
+
local claude_dir="$PROJECT_ROOT/.claude"
|
|
31
|
+
mkdir -p "$claude_dir/agents" "$claude_dir/commands" "$claude_dir/skills"
|
|
32
|
+
|
|
33
|
+
# --- Sync agents ---
|
|
34
|
+
for agent_file in "$AI_CORE_DIR"/agents/*.md; do
|
|
35
|
+
[ -f "$agent_file" ] || continue
|
|
36
|
+
local basename
|
|
37
|
+
basename=$(basename "$agent_file")
|
|
38
|
+
[[ "$basename" == "README.md" ]] && continue
|
|
39
|
+
cp "$agent_file" "$claude_dir/agents/$basename"
|
|
40
|
+
echo " ✓ agent: $basename"
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
# --- Sync commands (flatten from subdirs) ---
|
|
44
|
+
find "$AI_CORE_DIR/commands" -name "*.md" -type f | while read -r cmd_file; do
|
|
45
|
+
local basename
|
|
46
|
+
basename=$(basename "$cmd_file")
|
|
47
|
+
# Skip README files
|
|
48
|
+
[[ "$basename" == "README.md" ]] && continue
|
|
49
|
+
cp "$cmd_file" "$claude_dir/commands/$basename"
|
|
50
|
+
echo " ✓ command: $basename"
|
|
51
|
+
done
|
|
52
|
+
|
|
53
|
+
# --- Sync skills ---
|
|
54
|
+
for skill_file in "$AI_CORE_DIR"/skills/*/SKILL.md; do
|
|
55
|
+
[ -f "$skill_file" ] || continue
|
|
56
|
+
local skill_name
|
|
57
|
+
skill_name=$(basename "$(dirname "$skill_file")")
|
|
58
|
+
mkdir -p "$claude_dir/skills/$skill_name"
|
|
59
|
+
cp "$skill_file" "$claude_dir/skills/$skill_name/SKILL.md"
|
|
60
|
+
echo " ✓ skill: $skill_name"
|
|
61
|
+
done
|
|
62
|
+
|
|
63
|
+
# --- Generate CLAUDE.md (project-level instructions) ---
|
|
64
|
+
cat > "$PROJECT_ROOT/CLAUDE.md" <<'EOF'
|
|
65
|
+
# Project Instructions for Claude Code
|
|
66
|
+
|
|
67
|
+
This project uses `core/` framework for structured Agile/Scrum development.
|
|
68
|
+
|
|
69
|
+
## 🚨 CRITICAL: Read these first
|
|
70
|
+
|
|
71
|
+
1. **Rules**: See `core/rules/00-global-rules.md` — **MUST follow**
|
|
72
|
+
2. **Agents**: See `core/agents/` — pick correct agent for task
|
|
73
|
+
3. **Skills**: See `core/skills/using-ai-core/SKILL.md` — chat-first bootstrap
|
|
74
|
+
4. **Commands**: See `core/commands/` — use slash commands for workflows
|
|
75
|
+
5. **Workflows**: See `core/workflows/feature-lifecycle.md`
|
|
76
|
+
|
|
77
|
+
## Quick reference
|
|
78
|
+
|
|
79
|
+
### User interface
|
|
80
|
+
The normal user interface is the AI chat window. When the user types `/command ...`,
|
|
81
|
+
`guide /command ...`, or `next TICKET-XXX`, interpret it as an AI Core workflow
|
|
82
|
+
request. Do not ask the user to run `bash core/scripts/ai-core.sh` or set
|
|
83
|
+
`AI_AGENT`; use those executable scripts internally only when helpful.
|
|
84
|
+
|
|
85
|
+
### Before any code change
|
|
86
|
+
- [ ] There's an active ticket in `project/tickets/` with `status: IN_PROGRESS`
|
|
87
|
+
- [ ] You're on the correct feature branch
|
|
88
|
+
- [ ] You're playing the correct agent role inferred from command metadata
|
|
89
|
+
|
|
90
|
+
### State machine
|
|
91
|
+
```
|
|
92
|
+
DRAFT → GROOMED → READY → IN_PROGRESS → IN_REVIEW → QA → DONE
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Commit convention
|
|
96
|
+
`<type>(TICKET-XXX): <description>`
|
|
97
|
+
|
|
98
|
+
### Branch naming
|
|
99
|
+
`feature/TICKET-XXX-slug` | `bugfix/TICKET-XXX-slug` | `hotfix/TICKET-XXX-slug`
|
|
100
|
+
|
|
101
|
+
## ❌ Absolute prohibitions
|
|
102
|
+
|
|
103
|
+
See `core/rules/00-global-rules.md` → G-011
|
|
104
|
+
|
|
105
|
+
## 🎭 Your current role
|
|
106
|
+
|
|
107
|
+
Before responding, identify which agent you're playing based on the task or command metadata:
|
|
108
|
+
- BA request (analyze requirement) → `business-analyst`
|
|
109
|
+
- Technical design / review → `tech-lead`
|
|
110
|
+
- Coding → `developer`
|
|
111
|
+
- Testing → `qa-tester`
|
|
112
|
+
- Planning / release → `scrum-master`
|
|
113
|
+
|
|
114
|
+
Read the agent file to understand your boundaries.
|
|
115
|
+
|
|
116
|
+
## Skill bootstrap
|
|
117
|
+
|
|
118
|
+
At session start or before any workflow request, read `core/skills/using-ai-core/SKILL.md`.
|
|
119
|
+
For feature discovery use `core/skills/brainstorming/SKILL.md`.
|
|
120
|
+
For implementation plans use `core/skills/writing-implementation-plan/SKILL.md`.
|
|
121
|
+
For completion claims use `core/skills/verification-before-done/SKILL.md`.
|
|
122
|
+
EOF
|
|
123
|
+
echo " ✓ CLAUDE.md"
|
|
124
|
+
|
|
125
|
+
echo " ✅ Claude Code sync complete: $claude_dir/"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
# ============================================================================
|
|
129
|
+
# 2. CURSOR (.cursor/rules/*.mdc)
|
|
130
|
+
# ============================================================================
|
|
131
|
+
# Cursor uses:
|
|
132
|
+
# .cursor/rules/<name>.mdc — rules with YAML frontmatter
|
|
133
|
+
# Set alwaysApply: true to apply to all requests
|
|
134
|
+
# ============================================================================
|
|
135
|
+
|
|
136
|
+
sync_cursor() {
|
|
137
|
+
echo ""
|
|
138
|
+
echo "📦 [2/3] Cursor..."
|
|
139
|
+
|
|
140
|
+
local cursor_dir="$PROJECT_ROOT/.cursor/rules"
|
|
141
|
+
mkdir -p "$cursor_dir"
|
|
142
|
+
|
|
143
|
+
# --- Main project rule (alwaysApply) ---
|
|
144
|
+
cat > "$cursor_dir/00-project-rules.mdc" <<'EOF'
|
|
145
|
+
---
|
|
146
|
+
description: Global project rules - Agile/Scrum enforcement
|
|
147
|
+
alwaysApply: true
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
# Project Rules
|
|
151
|
+
|
|
152
|
+
This project uses `core/` framework. Read these files for full context:
|
|
153
|
+
|
|
154
|
+
- `core/rules/00-global-rules.md` — Hard rules (MUST follow)
|
|
155
|
+
- `core/agents/` — Agent personas
|
|
156
|
+
- `core/commands/` — Workflow commands
|
|
157
|
+
- `core/workflows/feature-lifecycle.md` — End-to-end process
|
|
158
|
+
|
|
159
|
+
## Top 10 Rules (summary)
|
|
160
|
+
|
|
161
|
+
1. **No code without ticket** (G-001): Active ticket in `project/tickets/` with status IN_PROGRESS
|
|
162
|
+
2. **State machine**: DRAFT → GROOMED → READY → IN_PROGRESS → IN_REVIEW → QA → DONE. No skipping.
|
|
163
|
+
3. **TDD mandatory**: Tests before code
|
|
164
|
+
4. **Coverage ≥ 80%** on diff
|
|
165
|
+
5. **Conventional Commits**: `<type>(TICKET-XXX): <description>`
|
|
166
|
+
6. **Branch naming**: `feature/TICKET-XXX-slug`
|
|
167
|
+
7. **No direct push** to main/develop
|
|
168
|
+
8. **No secrets** committed
|
|
169
|
+
9. **No self-approval** of PRs
|
|
170
|
+
10. **Follow agent boundaries** in `core/agents/<agent>.md`
|
|
171
|
+
|
|
172
|
+
## Before any task
|
|
173
|
+
|
|
174
|
+
Ask yourself:
|
|
175
|
+
1. Which agent role does the command metadata imply?
|
|
176
|
+
2. Is there an active ticket?
|
|
177
|
+
3. Am I on the right branch?
|
|
178
|
+
4. Does this follow the state machine?
|
|
179
|
+
|
|
180
|
+
If any answer is unclear → STOP and ask user.
|
|
181
|
+
|
|
182
|
+
## Chat-first workflow
|
|
183
|
+
|
|
184
|
+
Users should type workflow commands in chat, for example:
|
|
185
|
+
|
|
186
|
+
- `/analyze-requirements "User can reset password"`
|
|
187
|
+
- `/groom-ticket TICKET-001 5`
|
|
188
|
+
- `guide /mark-ready TICKET-001`
|
|
189
|
+
- `next TICKET-001`
|
|
190
|
+
|
|
191
|
+
Do not require users to type shell commands such as `bash core/scripts/ai-core.sh`
|
|
192
|
+
or environment variables such as `AI_AGENT=...`. Shell scripts are internal tools
|
|
193
|
+
for deterministic execution, validation, and CI.
|
|
194
|
+
EOF
|
|
195
|
+
echo " ✓ 00-project-rules.mdc (alwaysApply)"
|
|
196
|
+
|
|
197
|
+
# --- Per-agent rule (scoped) ---
|
|
198
|
+
for agent_file in "$AI_CORE_DIR"/agents/*.md; do
|
|
199
|
+
[ -f "$agent_file" ] || continue
|
|
200
|
+
local name
|
|
201
|
+
name=$(basename "$agent_file" .md)
|
|
202
|
+
[[ "$name" == "README" ]] && continue
|
|
203
|
+
local mdc_file="$cursor_dir/agent-$name.mdc"
|
|
204
|
+
|
|
205
|
+
cat > "$mdc_file" <<EOF
|
|
206
|
+
---
|
|
207
|
+
description: "Agent: $name"
|
|
208
|
+
alwaysApply: false
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
EOF
|
|
212
|
+
# Append agent content (skip frontmatter)
|
|
213
|
+
awk '/^---$/{count++; next} count>=2' "$agent_file" >> "$mdc_file"
|
|
214
|
+
echo " ✓ agent-$name.mdc"
|
|
215
|
+
done
|
|
216
|
+
|
|
217
|
+
# --- Rules files ---
|
|
218
|
+
for rule_file in "$AI_CORE_DIR"/rules/*.md; do
|
|
219
|
+
[ -f "$rule_file" ] || continue
|
|
220
|
+
local name
|
|
221
|
+
name=$(basename "$rule_file" .md)
|
|
222
|
+
cat > "$cursor_dir/rule-$name.mdc" <<EOF
|
|
223
|
+
---
|
|
224
|
+
description: "Rule: $name"
|
|
225
|
+
alwaysApply: true
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
EOF
|
|
229
|
+
cat "$rule_file" >> "$cursor_dir/rule-$name.mdc"
|
|
230
|
+
echo " ✓ rule-$name.mdc"
|
|
231
|
+
done
|
|
232
|
+
|
|
233
|
+
# --- Skills files ---
|
|
234
|
+
for skill_file in "$AI_CORE_DIR"/skills/*/SKILL.md; do
|
|
235
|
+
[ -f "$skill_file" ] || continue
|
|
236
|
+
local skill_name
|
|
237
|
+
skill_name=$(basename "$(dirname "$skill_file")")
|
|
238
|
+
cat > "$cursor_dir/skill-$skill_name.mdc" <<EOF
|
|
239
|
+
---
|
|
240
|
+
description: "AI Core skill: $skill_name"
|
|
241
|
+
alwaysApply: false
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
EOF
|
|
245
|
+
cat "$skill_file" >> "$cursor_dir/skill-$skill_name.mdc"
|
|
246
|
+
echo " ✓ skill-$skill_name.mdc"
|
|
247
|
+
done
|
|
248
|
+
|
|
249
|
+
echo " ✅ Cursor sync complete: $cursor_dir/"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
# ============================================================================
|
|
253
|
+
# 3. WINDSURF (.windsurfrules)
|
|
254
|
+
# ============================================================================
|
|
255
|
+
# Windsurf uses a single .windsurfrules file (flat markdown)
|
|
256
|
+
# ============================================================================
|
|
257
|
+
|
|
258
|
+
sync_windsurf() {
|
|
259
|
+
echo ""
|
|
260
|
+
echo "📦 [3/3] Windsurf..."
|
|
261
|
+
|
|
262
|
+
local windsurf_file="$PROJECT_ROOT/.windsurfrules"
|
|
263
|
+
|
|
264
|
+
cat > "$windsurf_file" <<'EOF'
|
|
265
|
+
# Windsurf Project Rules
|
|
266
|
+
|
|
267
|
+
This project uses core/ framework for Agile/Scrum enforcement.
|
|
268
|
+
|
|
269
|
+
## Required Reading
|
|
270
|
+
|
|
271
|
+
Before ANY task, read:
|
|
272
|
+
1. `core/rules/00-global-rules.md` — hard rules
|
|
273
|
+
2. `core/agents/` — role definitions
|
|
274
|
+
3. `core/skills/using-ai-core/SKILL.md` — chat-first bootstrap
|
|
275
|
+
4. `core/workflows/feature-lifecycle.md` — process
|
|
276
|
+
|
|
277
|
+
## Non-negotiable rules
|
|
278
|
+
|
|
279
|
+
EOF
|
|
280
|
+
|
|
281
|
+
# Append global rules content
|
|
282
|
+
cat "$AI_CORE_DIR/rules/00-global-rules.md" >> "$windsurf_file"
|
|
283
|
+
|
|
284
|
+
echo "" >> "$windsurf_file"
|
|
285
|
+
echo "## Available commands" >> "$windsurf_file"
|
|
286
|
+
echo "" >> "$windsurf_file"
|
|
287
|
+
find "$AI_CORE_DIR/commands" -name "*.md" -type f | while read -r cmd_file; do
|
|
288
|
+
local basename
|
|
289
|
+
basename=$(basename "$cmd_file" .md)
|
|
290
|
+
[[ "$basename" == "README" ]] && continue
|
|
291
|
+
echo "- /$basename" >> "$windsurf_file"
|
|
292
|
+
done
|
|
293
|
+
|
|
294
|
+
echo "" >> "$windsurf_file"
|
|
295
|
+
echo "## Available skills" >> "$windsurf_file"
|
|
296
|
+
echo "" >> "$windsurf_file"
|
|
297
|
+
find "$AI_CORE_DIR/skills" -name "SKILL.md" -type f | while read -r skill_file; do
|
|
298
|
+
local skill_name
|
|
299
|
+
skill_name=$(basename "$(dirname "$skill_file")")
|
|
300
|
+
echo "- $skill_name: core/skills/$skill_name/SKILL.md" >> "$windsurf_file"
|
|
301
|
+
done
|
|
302
|
+
|
|
303
|
+
echo " ✓ .windsurfrules generated"
|
|
304
|
+
echo " ✅ Windsurf sync complete"
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
# ============================================================================
|
|
308
|
+
# RUN
|
|
309
|
+
# ============================================================================
|
|
310
|
+
|
|
311
|
+
sync_claude_code
|
|
312
|
+
sync_cursor
|
|
313
|
+
sync_windsurf
|
|
314
|
+
|
|
315
|
+
echo ""
|
|
316
|
+
echo "✅ All platforms synced!"
|
|
317
|
+
echo ""
|
|
318
|
+
echo "📋 Next steps:"
|
|
319
|
+
echo " 1. Review generated files"
|
|
320
|
+
echo " 2. Commit: git add .claude/ .cursor/ .windsurfrules CLAUDE.md"
|
|
321
|
+
echo " 3. Test in Claude Code: try /setup-project"
|
|
322
|
+
echo " 4. Test in Cursor: open composer and check rules applied"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# core/scripts/validate-audit-log.sh
|
|
3
|
+
#
|
|
4
|
+
# Validates append-only audit log hash chaining.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
AUDIT_FILE="project/audit-log.jsonl"
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m'
|
|
13
|
+
|
|
14
|
+
log_info() { echo -e "${BLUE}i${NC} $1"; }
|
|
15
|
+
log_pass() { echo -e "${GREEN}+${NC} $1"; }
|
|
16
|
+
log_fail() { echo -e "${RED}x${NC} $1"; }
|
|
17
|
+
|
|
18
|
+
hash_value() {
|
|
19
|
+
local value="$1"
|
|
20
|
+
if command -v sha256sum >/dev/null 2>&1; then
|
|
21
|
+
printf '%s' "$value" | sha256sum | awk '{print $1}'
|
|
22
|
+
else
|
|
23
|
+
printf '%s' "$value" | shasum -a 256 | awk '{print $1}'
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if [ ! -f "$AUDIT_FILE" ]; then
|
|
28
|
+
log_info "No audit log found; skipping"
|
|
29
|
+
exit 0
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
if ! command -v jq >/dev/null 2>&1; then
|
|
33
|
+
log_fail "jq not installed. Install with: brew install jq"
|
|
34
|
+
exit 2
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
previous=""
|
|
38
|
+
line_no=0
|
|
39
|
+
errors=0
|
|
40
|
+
|
|
41
|
+
while IFS= read -r line; do
|
|
42
|
+
line_no=$((line_no + 1))
|
|
43
|
+
|
|
44
|
+
if ! printf '%s' "$line" | jq empty >/dev/null 2>&1; then
|
|
45
|
+
log_fail "Audit line $line_no is not valid JSON"
|
|
46
|
+
errors=$((errors + 1))
|
|
47
|
+
continue
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
actual_prev=$(printf '%s' "$line" | jq -r '.prev_hash // empty')
|
|
51
|
+
actual_hash=$(printf '%s' "$line" | jq -r '.hash // empty')
|
|
52
|
+
payload=$(printf '%s' "$line" | jq -c 'del(.hash)')
|
|
53
|
+
expected_hash=$(hash_value "$payload")
|
|
54
|
+
|
|
55
|
+
if [ "$actual_prev" != "$previous" ]; then
|
|
56
|
+
log_fail "Audit line $line_no prev_hash mismatch"
|
|
57
|
+
errors=$((errors + 1))
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
if [ "$actual_hash" != "$expected_hash" ]; then
|
|
61
|
+
log_fail "Audit line $line_no hash mismatch"
|
|
62
|
+
errors=$((errors + 1))
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
previous="$actual_hash"
|
|
66
|
+
done < "$AUDIT_FILE"
|
|
67
|
+
|
|
68
|
+
if [ "$errors" -gt 0 ]; then
|
|
69
|
+
log_fail "Audit log validation failed: $errors issue(s)"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
log_pass "Audit log hash chain valid"
|