-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
152 lines (130 loc) · 4.75 KB
/
Copy pathsetup.ps1
File metadata and controls
152 lines (130 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#Requires -Version 5.1
<#
.SYNOPSIS
Factory setup script for Windows hosts.
.DESCRIPTION
Run this from the HOST PROJECT ROOT after adding factory as a submodule:
git submodule add https://github.com/custodyzero/factory.git .factory
.\.factory\setup.ps1
Layout after setup:
.factory\ - tooling (git submodule, hidden)
factory\ - artifacts (features, packets, completions)
What this script does:
1. Installs factory dependencies (inside .factory/)
2. Copies template files to host project root (no-clobber)
3. Creates artifact directories under factory/
4. Seeds host-project memory + cache directories
5. Configures git hooks
#>
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$ProjectRoot = Split-Path -Parent $ScriptDir
$FactoryDir = Split-Path -Leaf $ScriptDir
$ArtifactDir = 'factory'
Write-Host ''
Write-Host 'Factory Setup'
Write-Host '============='
Write-Host " Project root: $ProjectRoot"
Write-Host " Tooling dir: $FactoryDir/ (submodule)"
Write-Host " Artifact dir: $ArtifactDir/ (features, packets, completions)"
Write-Host ''
# -- 1. Install factory dependencies ------------------------------------------
Write-Host 'Installing factory dependencies...'
Push-Location $ScriptDir
try {
if (Get-Command pnpm -ErrorAction SilentlyContinue) {
pnpm install --frozen-lockfile 2>$null
if ($LASTEXITCODE -ne 0) { pnpm install }
}
elseif (Get-Command npm -ErrorAction SilentlyContinue) {
npm ci 2>$null
if ($LASTEXITCODE -ne 0) { npm install }
}
else {
Write-Error 'Neither pnpm nor npm found. Node.js is required for factory tooling.'
}
}
finally {
Pop-Location
}
# -- 2. Copy template files (no-clobber) --------------------------------------
function Copy-Template {
param([string]$Source, [string]$Destination)
if (Test-Path $Destination) {
Write-Host " SKIP $Destination (already exists)"
}
else {
Copy-Item $Source $Destination
Write-Host " COPY $Destination"
}
}
Write-Host ''
Write-Host 'Copying template files...'
Push-Location $ProjectRoot
try {
Copy-Template "$FactoryDir/templates/factory.config.json" 'factory.config.json'
Copy-Template "$FactoryDir/templates/CLAUDE.md" 'CLAUDE.md'
Copy-Template "$FactoryDir/templates/AGENTS.md" 'AGENTS.md'
# -- 3. Create artifact directories ----------------------------------------
Write-Host ''
Write-Host 'Creating artifact directories...'
foreach ($subdir in @('intents', 'features', 'packets', 'completions')) {
$path = "$ArtifactDir/$subdir"
if (-not (Test-Path $path)) { New-Item -ItemType Directory -Path $path | Out-Null }
Write-Host " MKDIR $path/"
}
# -- 4. Seed host-project memory + cache directories -----------------------
Write-Host ''
Write-Host 'Creating memory and cache directories...'
foreach ($subdir in @(
'memory',
'memory/architectural-facts',
'memory/recurring-failures',
'memory/project-conventions',
'memory/code-patterns',
'memory/suggestions',
'cache'
)) {
$path = "$ArtifactDir/$subdir"
if (-not (Test-Path $path)) { New-Item -ItemType Directory -Path $path | Out-Null }
Write-Host " MKDIR $path/"
}
Copy-Template "$FactoryDir/templates/memory.md" "$ArtifactDir/memory/MEMORY.md"
if (Test-Path '.gitignore') {
$ignoreLine = "$ArtifactDir/cache/"
$gitignore = Get-Content '.gitignore'
if ($gitignore -notcontains $ignoreLine) {
Add-Content '.gitignore' "`n$ignoreLine"
Write-Host " APPEND .gitignore -> $ignoreLine"
}
else {
Write-Host " SKIP .gitignore ($ignoreLine already present)"
}
}
}
finally {
Pop-Location
}
# -- 5. Configure git hooks ---------------------------------------------------
Write-Host ''
Write-Host 'Configuring git hooks...'
Push-Location $ProjectRoot
try {
git config core.hooksPath "$FactoryDir/hooks"
Write-Host " Set core.hooksPath = $FactoryDir/hooks"
}
finally {
Pop-Location
}
# -- Done ---------------------------------------------------------------------
Write-Host ''
Write-Host 'Factory setup complete.'
Write-Host ''
Write-Host 'Next steps:'
Write-Host " 1. Edit factory.config.json - set project_name and verification commands"
Write-Host ' 2. Edit CLAUDE.md - customize for your project'
Write-Host " 3. Create a spec under specs/<spec-id>.md and run:"
Write-Host " npx tsx $FactoryDir/tools/run.ts <spec-id>"
Write-Host " (hand-authored intents under $ArtifactDir/intents/ remain supported for back-compat)"
Write-Host ''