Closing the intent-to-code chasm - specification-driven development with BDD verification chain
94
92%
Does it follow best practices?
Impact
95%
1.82xAverage score across 14 eval scenarios
Advisory
Suggest reviewing before use
#!/usr/bin/env pwsh
[CmdletBinding()] param( [Alias('j')] [switch]$Json, [Alias('c')] [switch]$CommitConstitution, [Alias('h')] [switch]$Help )
$ErrorActionPreference = 'Stop'
if ($Help) { Write-Host "Usage: ./init-project.ps1 [-Json] [-CommitConstitution]" Write-Host "" Write-Host "Initialize a intent-integrity-kit project with git repository." Write-Host "" Write-Host "Options:" Write-Host " -Json Output in JSON format" Write-Host " -CommitConstitution Commit the constitution file after git init" Write-Host " -Help Show this help message" exit 0 }
$projectRoot = Get-Location
if (-not (Test-Path (Join-Path $projectRoot '.specify'))) { if ($Json) { $result = @{ success = $false error = "Not a intent-integrity-kit project: .specify directory not found" git_initialized = $false } $result | ConvertTo-Json -Compress } else { Write-Error "Not a intent-integrity-kit project. Directory .specify not found." } exit 1 }
--is-inside-work-tree is true for linked.git is a file pointing at the realTest-Path .git misses.git -C $projectRoot rev-parse --is-inside-work-tree 2>$null | Out-Null if ($LASTEXITCODE -eq 0) { $gitInitialized = $false $gitStatus = "already_initialized" } else { # Initialize git git init $projectRoot 2>&1 | Out-Null $gitInitialized = $true $gitStatus = "initialized" }
git rev-parse --git-path hooks once and reuse.git/hooks/), so Install-IIKitHook and$hooksRel = git -C $projectRoot rev-parse --git-path hooks 2>$null if ($hooksRel) { if ([System.IO.Path]::IsPathRooted($hooksRel)) { $hooksAbs = $hooksRel } else { $hooksAbs = Join-Path $projectRoot $hooksRel } } else { $hooksAbs = "" }
function Install-IIKitHook { param( [string]$HookType, # e.g., "pre-commit" or "post-commit" [string]$SourceFile, # e.g., "pre-commit-hook.sh" [string]$Marker # e.g., "IIKIT-PRE-COMMIT" )
$result = @{ installed = $false; status = "skipped" }
if (-not $hooksAbs) { return $result }
$bashScriptDir = Join-Path (Split-Path $PSScriptRoot -Parent) "bash"
$hookSource = Join-Path $bashScriptDir $SourceFile
if (-not (Test-Path $hookSource)) {
$result.status = "source_not_found"
return $result
}
$hooksDir = $hooksAbs
if (-not (Test-Path $hooksDir)) {
New-Item -ItemType Directory -Path $hooksDir -Force | Out-Null
}
$existingHook = Join-Path $hooksDir $HookType
if (-not (Test-Path $existingHook)) {
Copy-Item $hookSource $existingHook
$result.installed = $true
$result.status = "installed"
} elseif ((Get-Content $existingHook -Raw -ErrorAction SilentlyContinue) -match $Marker) {
Copy-Item $hookSource $existingHook -Force
$result.installed = $true
$result.status = "updated"
} else {
$iikitHook = Join-Path $hooksDir "iikit-$HookType"
Copy-Item $hookSource $iikitHook
$hookContent = Get-Content $existingHook -Raw -ErrorAction SilentlyContinue
if ($hookContent -notmatch "iikit-$HookType") {
Add-Content -Path $existingHook -Value "`n# IIKit assertion integrity check"
Add-Content -Path $existingHook -Value '"$(dirname "$0")/iikit-' -NoNewline
Add-Content -Path $existingHook -Value "$HookType`""
}
$result.installed = $true
$result.status = "installed_alongside"
}
return $result}
$preHookResult = Install-IIKitHook -HookType "pre-commit" -SourceFile "pre-commit-hook.sh" -Marker "IIKIT-PRE-COMMIT" $hookInstalled = $preHookResult.installed $hookStatus = $preHookResult.status
$postHookResult = Install-IIKitHook -HookType "post-commit" -SourceFile "post-commit-hook.sh" -Marker "IIKIT-POST-COMMIT" $postHookInstalled = $postHookResult.installed $postHookStatus = $postHookResult.status
$hooksAbs as Install-IIKitHook above so the extensiongit rev-parse --git-path hooks resolves correctly for linked worktrees and.git is a file rather than a directory.$preCommitDProvisioned = $false if ($hooksAbs) { $preCommitDDir = Join-Path $hooksAbs "pre-commit.d" if (-not (Test-Path $preCommitDDir)) { New-Item -ItemType Directory -Path $preCommitDDir -Force | Out-Null } $preCommitDReadme = Join-Path $preCommitDDir "README" if (-not (Test-Path $preCommitDReadme)) { $readmeContent = @'
git diff --cached --name-only to'@ Set-Content -Path $preCommitDReadme -Value $readmeContent -NoNewline $preCommitDProvisioned = $true } }
$constitutionCommitted = $false $constitutionPath = Join-Path $projectRoot 'CONSTITUTION.md' if ($CommitConstitution -and (Test-Path $constitutionPath)) { Set-Location $projectRoot git add $constitutionPath
# Also add README if it exists
$readmePath = Join-Path $projectRoot 'README.md'
if (Test-Path $readmePath) {
git add $readmePath
}
# Check if there's anything to commit
$stagedChanges = git diff --cached --name-only 2>$null
if ($stagedChanges) {
git commit -m "Initialize intent-integrity-kit project with constitution" 2>&1 | Out-Null
$constitutionCommitted = $true
}}
function Report-HookStatus { param([string]$HookName, [string]$Status) switch ($Status) { "installed" { Write-Output "[specify] $HookName hook installed" } "updated" { Write-Output "[specify] $HookName hook updated" } "installed_alongside" { Write-Output "[specify] $HookName hook installed alongside existing hook" } "source_not_found" { Write-Warning "[specify] $HookName hook source not found - skipped installation" } } }
if ($Json) {
$result = @{
success = $true
git_initialized = $gitInitialized
git_status = $gitStatus
constitution_committed = $constitutionCommitted
hook_installed = $hookInstalled
hook_status = $hookStatus
post_hook_installed = $postHookInstalled
post_hook_status = $postHookStatus
pre_commit_d_provisioned = $preCommitDProvisioned
project_root = $projectRoot.ToString()
}
$result | ConvertTo-Json -Compress
} else {
if ($gitInitialized) {
Write-Output "[specify] Git repository initialized at $projectRoot"
} else {
Write-Output "[specify] Git repository already exists at $projectRoot"
}
if ($constitutionCommitted) {
Write-Output "[specify] Constitution committed to git"
}
Report-HookStatus "Pre-commit" $hookStatus
Report-HookStatus "Post-commit" $postHookStatus
if ($preCommitDProvisioned) {
# Report the resolved path — in worktrees/submodules this differs from
# .git/hooks/pre-commit.d/ (the hooks dir lives in the main repo /
# .git/modules/<name>/hooks/).
$projectRootStr = $projectRoot.ToString()
if ($preCommitDDir.StartsWith($projectRootStr, [System.StringComparison]::Ordinal)) {
$displayPath = $preCommitDDir.Substring($projectRootStr.Length).TrimStart([char]'/', [char]'')
} else {
$displayPath = $preCommitDDir
}
Write-Output "[specify] Extension point created at $displayPath (drop user-supplied hooks here)"
}
}
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
rules
skills
iikit-00-constitution
scripts
dashboard
iikit-01-specify
iikit-02-plan
iikit-03-checklist
scripts
bash
dashboard
iikit-04-testify
iikit-05-tasks
iikit-06-analyze
iikit-07-implement
iikit-08-taskstoissues
iikit-bugfix
scripts
dashboard
iikit-clarify
iikit-core
scripts
bash
dashboard
powershell
templates