@lifeaitools/rdc-skills 0.8.7
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/settings.json +15 -0
- package/.claude-plugin/marketplace.json +21 -0
- package/.claude-plugin/plugin.json +11 -0
- package/.github/workflows/publish.yml +25 -0
- package/.github/workflows/self-test.yml +53 -0
- package/CHANGELOG.md +246 -0
- package/LICENSE +21 -0
- package/MANIFEST.md +190 -0
- package/README.md +188 -0
- package/README.sandbox.md +3 -0
- package/assets/watcher/viewer.html +164 -0
- package/commands/build.md +183 -0
- package/commands/collab.md +180 -0
- package/commands/deploy.md +138 -0
- package/commands/fixit.md +112 -0
- package/commands/handoff.md +173 -0
- package/commands/help.md +88 -0
- package/commands/overnight.md +220 -0
- package/commands/plan.md +158 -0
- package/commands/preplan.md +131 -0
- package/commands/prototype.md +145 -0
- package/commands/release.md +159 -0
- package/commands/report.md +99 -0
- package/commands/review.md +120 -0
- package/commands/self-test.md +107 -0
- package/commands/status.md +86 -0
- package/commands/watch.md +92 -0
- package/commands/workitems.md +132 -0
- package/guides/.gitkeep +0 -0
- package/guides/agent-bootstrap.md +191 -0
- package/guides/agents/backend.md +104 -0
- package/guides/agents/content.md +94 -0
- package/guides/agents/cs2.md +56 -0
- package/guides/agents/data.md +87 -0
- package/guides/agents/design.md +77 -0
- package/guides/agents/frontend.md +92 -0
- package/guides/agents/infrastructure.md +81 -0
- package/guides/agents/setup.md +279 -0
- package/guides/agents/verify.md +132 -0
- package/guides/agents/viz.md +106 -0
- package/guides/backend.md +146 -0
- package/guides/content.md +147 -0
- package/guides/cs2.md +190 -0
- package/guides/data.md +123 -0
- package/guides/design.md +116 -0
- package/guides/frontend.md +151 -0
- package/guides/infrastructure.md +179 -0
- package/guides/output-contract.md +98 -0
- package/hooks/no-stop-open-epics.js +125 -0
- package/package.json +31 -0
- package/rules/work-items-rpc.md +399 -0
- package/scripts/install-rdc-skills.js +559 -0
- package/scripts/install.ps1 +165 -0
- package/scripts/install.sh +132 -0
- package/scripts/lib/assertions.mjs +264 -0
- package/scripts/lib/manifest-schema.mjs +607 -0
- package/scripts/lib/runner.mjs +429 -0
- package/scripts/lib/sandbox.mjs +435 -0
- package/scripts/self-test.mjs +1108 -0
- package/scripts/uninstall.ps1 +77 -0
- package/scripts/uninstall.sh +69 -0
- package/scripts/update.ps1 +43 -0
- package/scripts/update.sh +43 -0
- package/scripts/watch-init.mjs +100 -0
- package/skills/.gitkeep +0 -0
- package/skills/build/SKILL.md +238 -0
- package/skills/collab/SKILL.md +218 -0
- package/skills/deploy/SKILL.md +144 -0
- package/skills/fixit/SKILL.md +112 -0
- package/skills/handoff/SKILL.md +175 -0
- package/skills/help/SKILL.md +101 -0
- package/skills/overnight/SKILL.md +220 -0
- package/skills/plan/SKILL.md +96 -0
- package/skills/preplan/SKILL.md +87 -0
- package/skills/prototype/SKILL.md +151 -0
- package/skills/release/SKILL.md +221 -0
- package/skills/report/SKILL.md +101 -0
- package/skills/review/SKILL.md +120 -0
- package/skills/self-test/SKILL.md +127 -0
- package/skills/status/SKILL.md +86 -0
- package/skills/tests/README.md +29 -0
- package/skills/tests/rdc-build.test.json +22 -0
- package/skills/tests/rdc-deploy.test.json +15 -0
- package/skills/tests/rdc-fixit.test.json +21 -0
- package/skills/tests/rdc-handoff.test.json +14 -0
- package/skills/tests/rdc-overnight.test.json +21 -0
- package/skills/tests/rdc-plan.test.json +14 -0
- package/skills/tests/rdc-preplan.test.json +15 -0
- package/skills/tests/rdc-prototype.test.json +14 -0
- package/skills/tests/rdc-release.test.json +15 -0
- package/skills/tests/rdc-report.test.json +14 -0
- package/skills/tests/rdc-review.test.json +14 -0
- package/skills/tests/rdc-status.test.json +16 -0
- package/skills/tests/rdc-workitems.test.json +15 -0
- package/skills/watch/SKILL.md +92 -0
- package/skills/workitems/SKILL.md +147 -0
- package/tests/validate-skills.js +183 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# DEPRECATED as of v0.6.0 — use /plugin install rdc-skills.
|
|
2
|
+
# Will be removed in v0.7.0. See README.md "Install" section.
|
|
3
|
+
#
|
|
4
|
+
# Install rdc-skills plugin to Claude Code
|
|
5
|
+
# Windows PowerShell script
|
|
6
|
+
#
|
|
7
|
+
# Usage:
|
|
8
|
+
# ./install.ps1 # standard install
|
|
9
|
+
# ./install.ps1 -SkipHooks # skip hooks registration (e.g. if you manage hooks manually)
|
|
10
|
+
# ./install.ps1 -ClaudeHome <path> # custom CLAUDE_HOME
|
|
11
|
+
|
|
12
|
+
param(
|
|
13
|
+
[string]$ClaudeHome = "",
|
|
14
|
+
[switch]$SkipHooks = $false,
|
|
15
|
+
[switch]$Force = $false
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
# Detect CLAUDE_HOME
|
|
19
|
+
if (-not $ClaudeHome) {
|
|
20
|
+
$ClaudeHome = Join-Path $env:USERPROFILE ".claude"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
24
|
+
$repoRoot = Split-Path -Parent $scriptDir
|
|
25
|
+
|
|
26
|
+
Write-Host ""
|
|
27
|
+
Write-Host " rdc-skills Installer" -ForegroundColor Green
|
|
28
|
+
Write-Host " ====================" -ForegroundColor Green
|
|
29
|
+
Write-Host ""
|
|
30
|
+
Write-Host " CLAUDE_HOME : $ClaudeHome" -ForegroundColor Cyan
|
|
31
|
+
Write-Host " Plugin root : $repoRoot" -ForegroundColor Cyan
|
|
32
|
+
Write-Host ""
|
|
33
|
+
|
|
34
|
+
if (-not (Test-Path $ClaudeHome)) {
|
|
35
|
+
Write-Host " ERROR: CLAUDE_HOME not found: $ClaudeHome" -ForegroundColor Red
|
|
36
|
+
exit 1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# ── 1. Skills ────────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
$skillsDir = Join-Path $ClaudeHome "skills" "user"
|
|
42
|
+
if (-not (Test-Path $skillsDir)) {
|
|
43
|
+
New-Item -ItemType Directory -Path $skillsDir -Force | Out-Null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
$srcSkills = Join-Path $repoRoot "skills"
|
|
47
|
+
$skillFiles = Get-ChildItem -Path $srcSkills -Filter "*.md" -ErrorAction SilentlyContinue
|
|
48
|
+
foreach ($f in $skillFiles) {
|
|
49
|
+
Copy-Item -Path $f.FullName -Destination (Join-Path $skillsDir $f.Name) -Force
|
|
50
|
+
}
|
|
51
|
+
Write-Host " [1/3] Skills ✓ $($skillFiles.Count) file(s) → $skillsDir" -ForegroundColor Green
|
|
52
|
+
|
|
53
|
+
# ── 2. Hooks (files) ─────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
$hooksDir = Join-Path $ClaudeHome "hooks"
|
|
56
|
+
if (-not (Test-Path $hooksDir)) {
|
|
57
|
+
New-Item -ItemType Directory -Path $hooksDir -Force | Out-Null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
$srcHooks = Join-Path $repoRoot "hooks"
|
|
61
|
+
$hookFiles = Get-ChildItem -Path $srcHooks -Filter "*.js" -ErrorAction SilentlyContinue
|
|
62
|
+
foreach ($f in $hookFiles) {
|
|
63
|
+
Copy-Item -Path $f.FullName -Destination (Join-Path $hooksDir $f.Name) -Force
|
|
64
|
+
}
|
|
65
|
+
Write-Host " [2/3] Hook files ✓ $($hookFiles.Count) file(s) → $hooksDir" -ForegroundColor Green
|
|
66
|
+
|
|
67
|
+
# ── 3. Register hooks in settings.json ───────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
if ($SkipHooks) {
|
|
70
|
+
Write-Host " [3/3] Hook wiring ⏭ skipped (--SkipHooks)" -ForegroundColor DarkGray
|
|
71
|
+
} else {
|
|
72
|
+
$settingsPath = Join-Path $ClaudeHome "settings.json"
|
|
73
|
+
|
|
74
|
+
# Load existing settings (or start fresh)
|
|
75
|
+
if (Test-Path $settingsPath) {
|
|
76
|
+
$settings = Get-Content $settingsPath -Raw | ConvertFrom-Json
|
|
77
|
+
} else {
|
|
78
|
+
$settings = [PSCustomObject]@{}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Build hooks block — all paths use forward slashes for cross-platform compat
|
|
82
|
+
$hooksBase = $hooksDir.Replace("\", "/")
|
|
83
|
+
|
|
84
|
+
$hooksConfig = [PSCustomObject]@{
|
|
85
|
+
SessionStart = @(
|
|
86
|
+
[PSCustomObject]@{
|
|
87
|
+
hooks = @(
|
|
88
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/check-cwd.js`"" },
|
|
89
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/check-stale-work-items.js`""; statusMessage = "Checking for stale work items..." }
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
PreToolUse = @(
|
|
94
|
+
[PSCustomObject]@{
|
|
95
|
+
matcher = "Bash"
|
|
96
|
+
hooks = @(
|
|
97
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/require-work-item-on-commit.js`"" }
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
PostToolUse = @(
|
|
102
|
+
[PSCustomObject]@{
|
|
103
|
+
hooks = @(
|
|
104
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/check-services.js`"" }
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
PreCompact = @(
|
|
109
|
+
[PSCustomObject]@{
|
|
110
|
+
hooks = @(
|
|
111
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/precompact-log.js`"" }
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
PostCompact = @(
|
|
116
|
+
[PSCustomObject]@{
|
|
117
|
+
hooks = @(
|
|
118
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/postcompact-log.js`"" },
|
|
119
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/restart-brief.js`""; statusMessage = "Writing restart brief..." }
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
Stop = @(
|
|
124
|
+
[PSCustomObject]@{
|
|
125
|
+
hooks = @(
|
|
126
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/rate-limit-retry.js`""; statusMessage = "Checking for rate limits..." },
|
|
127
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/post-work-check.js`""; statusMessage = "Checking for undocumented work..." },
|
|
128
|
+
[PSCustomObject]@{ type = "command"; command = "node `"$hooksBase/no-stop-open-epics.js`""; statusMessage = "Checking for open epics..." }
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# Add/replace hooks key
|
|
135
|
+
if ($settings.PSObject.Properties["hooks"]) {
|
|
136
|
+
$settings.hooks = $hooksConfig
|
|
137
|
+
} else {
|
|
138
|
+
$settings | Add-Member -NotePropertyName "hooks" -NotePropertyValue $hooksConfig -Force
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# Write back with 2-space indent
|
|
142
|
+
$settings | ConvertTo-Json -Depth 20 | Set-Content $settingsPath -Encoding UTF8
|
|
143
|
+
Write-Host " [3/3] Hook wiring ✓ registered in $settingsPath" -ForegroundColor Green
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
# ── Summary ───────────────────────────────────────────────────────────────────
|
|
147
|
+
|
|
148
|
+
Write-Host ""
|
|
149
|
+
Write-Host " Installation complete!" -ForegroundColor Green
|
|
150
|
+
Write-Host ""
|
|
151
|
+
Write-Host " Next steps:" -ForegroundColor Yellow
|
|
152
|
+
Write-Host " 1. Create project overlay guides (required for project-specific context):"
|
|
153
|
+
Write-Host " docs/guides/agent-bootstrap.md ← credentials, git rules, Supabase ref"
|
|
154
|
+
Write-Host " docs/guides/frontend.md ← your design system rules"
|
|
155
|
+
Write-Host " docs/guides/backend.md ← your API/DB patterns"
|
|
156
|
+
Write-Host " docs/guides/data.md ← your migration patterns"
|
|
157
|
+
Write-Host ""
|
|
158
|
+
Write-Host " 2. Use rdc-skills/guides/*.md as starting-point templates"
|
|
159
|
+
Write-Host ""
|
|
160
|
+
Write-Host " 3. Restart Claude Code so hook changes take effect"
|
|
161
|
+
Write-Host ""
|
|
162
|
+
Write-Host " 4. Run /rdc:status in Claude Code to verify"
|
|
163
|
+
Write-Host ""
|
|
164
|
+
Write-Host " Docs: https://github.com/LIFEAI/rdc-skills#readme" -ForegroundColor Cyan
|
|
165
|
+
Write-Host ""
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# DEPRECATED as of v0.6.0 — use /plugin install rdc-skills.
|
|
3
|
+
# Will be removed in v0.7.0. See README.md "Install" section.
|
|
4
|
+
#
|
|
5
|
+
# Install rdc-skills plugin to Claude Code
|
|
6
|
+
# Unix/macOS bash script
|
|
7
|
+
|
|
8
|
+
set -u
|
|
9
|
+
# NOTE: intentionally NOT using `set -e`
|
|
10
|
+
|
|
11
|
+
# Guard: warn if rdc-skills plugin is already active in settings.json
|
|
12
|
+
# Running this script alongside the plugin creates duplicate skill entries.
|
|
13
|
+
SETTINGS_FILE="${HOME}/.claude/settings.json"
|
|
14
|
+
if [ -f "$SETTINGS_FILE" ] && python3 -c "
|
|
15
|
+
import json, sys
|
|
16
|
+
s = json.load(open('$SETTINGS_FILE'))
|
|
17
|
+
plugins = s.get('enabledPlugins', {})
|
|
18
|
+
if plugins.get('rdc-skills@rdc-skills'):
|
|
19
|
+
sys.exit(1)
|
|
20
|
+
" 2>/dev/null; then
|
|
21
|
+
: # plugin not active — safe to proceed
|
|
22
|
+
else
|
|
23
|
+
echo "⚠️ WARNING: rdc-skills@rdc-skills plugin is active in ~/.claude/settings.json"
|
|
24
|
+
echo " Running this script alongside the plugin creates DUPLICATE skill entries."
|
|
25
|
+
echo " Each skill will appear 2-3x in your skill list."
|
|
26
|
+
echo ""
|
|
27
|
+
echo " If you want to use the plugin (recommended), do NOT run this script."
|
|
28
|
+
echo " If you want to use this script instead, disable the plugin first:"
|
|
29
|
+
echo " Set \"rdc-skills@rdc-skills\": false in ~/.claude/settings.json"
|
|
30
|
+
echo ""
|
|
31
|
+
read -p "Continue anyway? (y/N) " confirm
|
|
32
|
+
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
|
|
33
|
+
echo "Aborted."
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
fi — it aborts the whole install on any
|
|
37
|
+
# single file glitch (stale lock, permission hiccup, cp retry). We want the
|
|
38
|
+
# loop to power through and report failures at the end, not die silently
|
|
39
|
+
# after the first file. Past bug: every install "only copied rdc-backend.md".
|
|
40
|
+
|
|
41
|
+
CLAUDE_HOME="${CLAUDE_HOME:-$HOME/.claude}"
|
|
42
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
43
|
+
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
44
|
+
|
|
45
|
+
echo "rdc-skills Installer"
|
|
46
|
+
echo "==================="
|
|
47
|
+
echo ""
|
|
48
|
+
|
|
49
|
+
# Check CLAUDE_HOME exists
|
|
50
|
+
if [ ! -d "$CLAUDE_HOME" ]; then
|
|
51
|
+
echo "ERROR: CLAUDE_HOME does not exist: $CLAUDE_HOME"
|
|
52
|
+
echo " Create it first: mkdir -p \"$CLAUDE_HOME\""
|
|
53
|
+
exit 1
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
echo "CLAUDE_HOME: $CLAUDE_HOME"
|
|
57
|
+
echo ""
|
|
58
|
+
|
|
59
|
+
# Create skills directory
|
|
60
|
+
SKILLS_DIR="$CLAUDE_HOME/skills/user"
|
|
61
|
+
mkdir -p "$SKILLS_DIR"
|
|
62
|
+
echo "✓ Skills directory: $SKILLS_DIR"
|
|
63
|
+
|
|
64
|
+
# Copy skills — bulk cp is atomic and much harder to kill than a per-file loop.
|
|
65
|
+
# Prior bug: per-file loop under `set -e` aborted after the first file on any
|
|
66
|
+
# cp glitch, leaving the install half-applied. Bulk cp runs once, reports once.
|
|
67
|
+
if [ -d "$REPO_ROOT/skills" ]; then
|
|
68
|
+
SKILL_COUNT=0
|
|
69
|
+
# Read version from package.json
|
|
70
|
+
PKG_VERSION=$(python3 -c "import json; print(json.load(open('$REPO_ROOT/package.json'))['version'])" 2>/dev/null || echo "unknown")
|
|
71
|
+
VERSION_STAMP="<!-- rdc-skills v${PKG_VERSION} -->"
|
|
72
|
+
|
|
73
|
+
# Skills are in subdirectories: skills/<name>/SKILL.md → rdc-<name>.md
|
|
74
|
+
for skill_dir in "$REPO_ROOT"/skills/*/; do
|
|
75
|
+
name=$(basename "$skill_dir")
|
|
76
|
+
src="$skill_dir/SKILL.md"
|
|
77
|
+
dst="$SKILLS_DIR/rdc-${name}.md"
|
|
78
|
+
if [ -f "$src" ]; then
|
|
79
|
+
# Prepend version stamp then file content
|
|
80
|
+
{ echo "$VERSION_STAMP"; cat "$src"; } > "$dst" 2>&1 || echo " (cp warning — failed to copy $name)"
|
|
81
|
+
SKILL_COUNT=$((SKILL_COUNT + 1))
|
|
82
|
+
echo " → rdc-${name}.md [v${PKG_VERSION}]"
|
|
83
|
+
fi
|
|
84
|
+
done
|
|
85
|
+
if [ "$SKILL_COUNT" -gt 0 ]; then
|
|
86
|
+
echo " ✓ Copied $SKILL_COUNT skill(s)"
|
|
87
|
+
INSTALLED=$(ls -1 "$SKILLS_DIR"/rdc-*.md 2>/dev/null | wc -l)
|
|
88
|
+
echo " ✓ Verified: $INSTALLED rdc-*.md file(s) present in $SKILLS_DIR"
|
|
89
|
+
if [ "$INSTALLED" -lt "$SKILL_COUNT" ]; then
|
|
90
|
+
echo " ⚠ WARNING: only $INSTALLED of $SKILL_COUNT installed — run install again or check permissions"
|
|
91
|
+
fi
|
|
92
|
+
else
|
|
93
|
+
echo " (no SKILL.md files found in skills/ subdirectories)"
|
|
94
|
+
fi
|
|
95
|
+
fi
|
|
96
|
+
echo ""
|
|
97
|
+
|
|
98
|
+
# Create hooks directory
|
|
99
|
+
HOOKS_DIR="$CLAUDE_HOME/hooks"
|
|
100
|
+
mkdir -p "$HOOKS_DIR"
|
|
101
|
+
echo "✓ Hooks directory: $HOOKS_DIR"
|
|
102
|
+
|
|
103
|
+
# Copy hooks
|
|
104
|
+
HOOK_COUNT=0
|
|
105
|
+
if ls "$REPO_ROOT"/hooks/*.js >/dev/null 2>&1; then
|
|
106
|
+
cp "$REPO_ROOT"/hooks/*.js "$HOOKS_DIR/" 2>&1 || echo " (cp warning — some hooks may not have copied)"
|
|
107
|
+
chmod +x "$HOOKS_DIR"/*.js 2>/dev/null || true
|
|
108
|
+
HOOK_COUNT=$(ls -1 "$REPO_ROOT"/hooks/*.js 2>/dev/null | wc -l)
|
|
109
|
+
for hook in "$REPO_ROOT"/hooks/*.js; do
|
|
110
|
+
[ -f "$hook" ] && echo " → $(basename "$hook")"
|
|
111
|
+
done
|
|
112
|
+
fi
|
|
113
|
+
if [ "$HOOK_COUNT" -gt 0 ]; then
|
|
114
|
+
echo " ✓ Copied $HOOK_COUNT hook(s)"
|
|
115
|
+
fi
|
|
116
|
+
echo ""
|
|
117
|
+
|
|
118
|
+
echo "Installation Complete"
|
|
119
|
+
echo "====================="
|
|
120
|
+
echo ""
|
|
121
|
+
echo "Next steps:"
|
|
122
|
+
echo "1. Create project-specific guides in your codebase:"
|
|
123
|
+
echo " - docs/guides/agent-bootstrap.md (required — credentials, git rules)"
|
|
124
|
+
echo " - docs/guides/frontend.md (if building UI)"
|
|
125
|
+
echo " - docs/guides/backend.md (if building APIs)"
|
|
126
|
+
echo " - docs/guides/data.md (if doing DB work)"
|
|
127
|
+
echo ""
|
|
128
|
+
echo "2. Use rdc-skills/guides/*.md as starting point templates for your project overlays"
|
|
129
|
+
echo ""
|
|
130
|
+
echo "3. Run /rdc:status in Claude Code to verify setup"
|
|
131
|
+
echo ""
|
|
132
|
+
echo "For help: https://github.com/LIFEAI/rdc-skills#readme"
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// assertions.mjs — Tier 2 declarative assertion evaluator.
|
|
2
|
+
//
|
|
3
|
+
// Consumed by scripts/lib/runner.mjs. Each predicate is a pure function
|
|
4
|
+
// (assertion, observed) => { pass, message } where observed is:
|
|
5
|
+
// {
|
|
6
|
+
// exit_code: number,
|
|
7
|
+
// stdout: string,
|
|
8
|
+
// stderr: string,
|
|
9
|
+
// files_modified: string[], // forward-slash relative paths
|
|
10
|
+
// commits: [{ sha, subject, body }],
|
|
11
|
+
// work_items_delta: [{ id, status, labels }],
|
|
12
|
+
// }
|
|
13
|
+
//
|
|
14
|
+
// evaluateAssertions(manifest.assertions, observed) → { pass, failures[] }
|
|
15
|
+
// where failures is an array of { predicate, message } — empty iff pass.
|
|
16
|
+
//
|
|
17
|
+
// Self-test at the bottom; run `node scripts/lib/assertions.mjs`.
|
|
18
|
+
|
|
19
|
+
import { fileURLToPath } from "node:url";
|
|
20
|
+
import { resolve } from "node:path";
|
|
21
|
+
|
|
22
|
+
// ─── predicates ─────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
export function checkExitCode(expected, observed) {
|
|
25
|
+
if (expected === undefined) return { pass: true };
|
|
26
|
+
if (observed.exit_code === expected) return { pass: true };
|
|
27
|
+
return {
|
|
28
|
+
pass: false,
|
|
29
|
+
message: `exit_code expected ${expected}, got ${observed.exit_code}`,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function checkWorkItemsCreated(spec, observed) {
|
|
34
|
+
if (spec === undefined) return { pass: true };
|
|
35
|
+
const items = Array.isArray(observed.work_items_delta) ? observed.work_items_delta : [];
|
|
36
|
+
let filtered = items;
|
|
37
|
+
if (spec.status !== undefined) {
|
|
38
|
+
filtered = filtered.filter((wi) => wi && wi.status === spec.status);
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(spec.labels_include) && spec.labels_include.length > 0) {
|
|
41
|
+
filtered = filtered.filter((wi) => {
|
|
42
|
+
const labels = Array.isArray(wi?.labels) ? wi.labels : [];
|
|
43
|
+
return spec.labels_include.every((lbl) => labels.includes(lbl));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const count = filtered.length;
|
|
47
|
+
if (spec.min !== undefined && count < spec.min) {
|
|
48
|
+
return {
|
|
49
|
+
pass: false,
|
|
50
|
+
message: `work_items_created: expected >= ${spec.min} matching, got ${count}`,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (spec.max !== undefined && count > spec.max) {
|
|
54
|
+
return {
|
|
55
|
+
pass: false,
|
|
56
|
+
message: `work_items_created: expected <= ${spec.max} matching, got ${count}`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return { pass: true };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function checkFilesModified(expected, observed) {
|
|
63
|
+
if (expected === undefined) return { pass: true };
|
|
64
|
+
if (!Array.isArray(expected)) {
|
|
65
|
+
return { pass: false, message: "files_modified assertion is not an array" };
|
|
66
|
+
}
|
|
67
|
+
const seen = new Set(
|
|
68
|
+
(observed.files_modified || []).map((p) => String(p).replace(/\\/g, "/")),
|
|
69
|
+
);
|
|
70
|
+
const missing = expected.filter((p) => !seen.has(String(p).replace(/\\/g, "/")));
|
|
71
|
+
if (missing.length === 0) return { pass: true };
|
|
72
|
+
return {
|
|
73
|
+
pass: false,
|
|
74
|
+
message: `files_modified: missing from git diff: ${missing.join(", ")}`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function checkCommitsMade(spec, observed) {
|
|
79
|
+
if (spec === undefined) return { pass: true };
|
|
80
|
+
const commits = Array.isArray(observed.commits) ? observed.commits : [];
|
|
81
|
+
if (spec.min !== undefined && commits.length < spec.min) {
|
|
82
|
+
return {
|
|
83
|
+
pass: false,
|
|
84
|
+
message: `commits_made: expected >= ${spec.min}, got ${commits.length}`,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (spec.message_matches !== undefined) {
|
|
88
|
+
let re;
|
|
89
|
+
try {
|
|
90
|
+
re = new RegExp(spec.message_matches);
|
|
91
|
+
} catch (e) {
|
|
92
|
+
return { pass: false, message: `commits_made.message_matches invalid regex: ${e.message}` };
|
|
93
|
+
}
|
|
94
|
+
const hit = commits.some((c) => {
|
|
95
|
+
const msg = `${c?.subject || ""}\n${c?.body || ""}`;
|
|
96
|
+
return re.test(msg);
|
|
97
|
+
});
|
|
98
|
+
if (!hit) {
|
|
99
|
+
return {
|
|
100
|
+
pass: false,
|
|
101
|
+
message: `commits_made.message_matches /${spec.message_matches}/ did not match any commit`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return { pass: true };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function checkStderrEmpty(expected, observed) {
|
|
109
|
+
if (expected === undefined) return { pass: true };
|
|
110
|
+
if (expected !== true) return { pass: true };
|
|
111
|
+
const s = (observed.stderr || "").trim();
|
|
112
|
+
if (s.length === 0) return { pass: true };
|
|
113
|
+
const preview = s.length > 200 ? s.slice(0, 200) + "..." : s;
|
|
114
|
+
return { pass: false, message: `stderr_empty: expected empty, got ${s.length} chars: ${preview}` };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function checkStdoutContains(expected, observed) {
|
|
118
|
+
if (expected === undefined) return { pass: true };
|
|
119
|
+
if (!Array.isArray(expected)) {
|
|
120
|
+
return { pass: false, message: "stdout_contains assertion is not an array" };
|
|
121
|
+
}
|
|
122
|
+
const stdout = observed.stdout || "";
|
|
123
|
+
const missing = expected.filter((s) => !stdout.includes(s));
|
|
124
|
+
if (missing.length === 0) return { pass: true };
|
|
125
|
+
return {
|
|
126
|
+
pass: false,
|
|
127
|
+
message: `stdout_contains: missing substrings: ${missing.map((s) => JSON.stringify(s)).join(", ")}`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// ─── evaluator ──────────────────────────────────────────────────────────────
|
|
132
|
+
|
|
133
|
+
const PREDICATES = [
|
|
134
|
+
["exit_code", checkExitCode],
|
|
135
|
+
["work_items_created", checkWorkItemsCreated],
|
|
136
|
+
["files_modified", checkFilesModified],
|
|
137
|
+
["commits_made", checkCommitsMade],
|
|
138
|
+
["stderr_empty", checkStderrEmpty],
|
|
139
|
+
["stdout_contains", checkStdoutContains],
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
export function evaluateAssertions(assertions, observed) {
|
|
143
|
+
const failures = [];
|
|
144
|
+
if (assertions == null || typeof assertions !== "object") {
|
|
145
|
+
return { pass: false, failures: [{ predicate: "", message: "assertions missing or not an object" }] };
|
|
146
|
+
}
|
|
147
|
+
for (const [key, fn] of PREDICATES) {
|
|
148
|
+
const res = fn(assertions[key], observed || {});
|
|
149
|
+
if (!res.pass) failures.push({ predicate: key, message: res.message });
|
|
150
|
+
}
|
|
151
|
+
return { pass: failures.length === 0, failures };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ─── self-test ──────────────────────────────────────────────────────────────
|
|
155
|
+
|
|
156
|
+
const __isMain = (() => {
|
|
157
|
+
try {
|
|
158
|
+
return fileURLToPath(import.meta.url) === resolve(process.argv[1] || "");
|
|
159
|
+
} catch {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
})();
|
|
163
|
+
|
|
164
|
+
if (__isMain) {
|
|
165
|
+
const baseObserved = {
|
|
166
|
+
exit_code: 0,
|
|
167
|
+
stdout: "✓ done\nVerdict: PASS\n",
|
|
168
|
+
stderr: "",
|
|
169
|
+
files_modified: ["README.md", "src/foo.ts"],
|
|
170
|
+
commits: [{ sha: "abc123", subject: "fix: typo in README", body: "" }],
|
|
171
|
+
work_items_delta: [
|
|
172
|
+
{ id: "w1", status: "done", labels: ["fixit", "cs2"] },
|
|
173
|
+
{ id: "w2", status: "todo", labels: ["other"] },
|
|
174
|
+
],
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const cases = [
|
|
178
|
+
{
|
|
179
|
+
n: 1,
|
|
180
|
+
desc: "all predicates pass",
|
|
181
|
+
assertions: {
|
|
182
|
+
exit_code: 0,
|
|
183
|
+
work_items_created: { min: 1, max: 1, status: "done", labels_include: ["fixit"] },
|
|
184
|
+
files_modified: ["README.md"],
|
|
185
|
+
commits_made: { min: 1, message_matches: "fix.*README" },
|
|
186
|
+
stderr_empty: true,
|
|
187
|
+
stdout_contains: ["✓", "Verdict:"],
|
|
188
|
+
},
|
|
189
|
+
observed: baseObserved,
|
|
190
|
+
expect: (r) => r.pass && r.failures.length === 0,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
n: 2,
|
|
194
|
+
desc: "exit_code mismatch",
|
|
195
|
+
assertions: { exit_code: 1 },
|
|
196
|
+
observed: baseObserved,
|
|
197
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "exit_code"),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
n: 3,
|
|
201
|
+
desc: "files_modified missing",
|
|
202
|
+
assertions: { files_modified: ["CHANGELOG.md"] },
|
|
203
|
+
observed: baseObserved,
|
|
204
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "files_modified"),
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
n: 4,
|
|
208
|
+
desc: "commits_made regex no match",
|
|
209
|
+
assertions: { commits_made: { message_matches: "^feat" } },
|
|
210
|
+
observed: baseObserved,
|
|
211
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "commits_made"),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
n: 5,
|
|
215
|
+
desc: "stderr not empty",
|
|
216
|
+
assertions: { stderr_empty: true },
|
|
217
|
+
observed: { ...baseObserved, stderr: "warning: something" },
|
|
218
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "stderr_empty"),
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
n: 6,
|
|
222
|
+
desc: "stdout_contains missing substring",
|
|
223
|
+
assertions: { stdout_contains: ["NOTPRESENT"] },
|
|
224
|
+
observed: baseObserved,
|
|
225
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "stdout_contains"),
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
n: 7,
|
|
229
|
+
desc: "work_items_created label filter rejects",
|
|
230
|
+
assertions: { work_items_created: { min: 1, labels_include: ["nonexistent"] } },
|
|
231
|
+
observed: baseObserved,
|
|
232
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "work_items_created"),
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
n: 8,
|
|
236
|
+
desc: "work_items_created max exceeded",
|
|
237
|
+
assertions: { work_items_created: { max: 0 } },
|
|
238
|
+
observed: baseObserved,
|
|
239
|
+
expect: (r) => !r.pass && r.failures.some((f) => f.predicate === "work_items_created"),
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
n: 9,
|
|
243
|
+
desc: "empty assertions → pass",
|
|
244
|
+
assertions: {},
|
|
245
|
+
observed: baseObserved,
|
|
246
|
+
expect: (r) => r.pass,
|
|
247
|
+
},
|
|
248
|
+
];
|
|
249
|
+
|
|
250
|
+
let passed = 0;
|
|
251
|
+
console.log("\nassertions self-test\n");
|
|
252
|
+
for (const c of cases) {
|
|
253
|
+
const r = evaluateAssertions(c.assertions, c.observed);
|
|
254
|
+
const ok = c.expect(r);
|
|
255
|
+
console.log(
|
|
256
|
+
`${String(c.n).padEnd(3)} ${c.desc.padEnd(44)} ${ok ? "PASS" : "FAIL"}${
|
|
257
|
+
ok ? "" : " → " + JSON.stringify(r.failures)
|
|
258
|
+
}`,
|
|
259
|
+
);
|
|
260
|
+
if (ok) passed++;
|
|
261
|
+
}
|
|
262
|
+
console.log(`\n${passed}/${cases.length} passed\n`);
|
|
263
|
+
process.exit(passed === cases.length ? 0 : 1);
|
|
264
|
+
}
|