(workDir, args)
| 96 | } |
| 97 | |
| 98 | function setupInitialRepo(workDir, args) { |
| 99 | const agentsMd = fs.readFileSync(AGENTS_SOURCE, 'utf8'); |
| 100 | writeFile(path.join(workDir, 'AGENTS.md'), agentsMd); |
| 101 | writeFile(path.join(workDir, 'package.json'), `${JSON.stringify({ |
| 102 | name: 'citadel-berman-steward-proof', |
| 103 | private: true, |
| 104 | scripts: { |
| 105 | test: 'node scripts/check.js', |
| 106 | deploy: 'node .agent-steward/fake-deploy.cjs', |
| 107 | }, |
| 108 | }, null, 2)}\n`); |
| 109 | writeFile(path.join(workDir, 'scripts', 'check.js'), [ |
| 110 | "'use strict';", |
| 111 | "const fs = require('fs');", |
| 112 | "const path = require('path');", |
| 113 | "const featureDir = path.join(process.cwd(), 'features');", |
| 114 | "if (fs.existsSync(featureDir)) {", |
| 115 | " for (const file of fs.readdirSync(featureDir)) {", |
| 116 | " const text = fs.readFileSync(path.join(featureDir, file), 'utf8');", |
| 117 | " if (!/^agent \\d+\\n$/.test(text)) throw new Error(`bad feature file ${file}`);", |
| 118 | " }", |
| 119 | "}", |
| 120 | "console.log('proof check passed');", |
| 121 | '', |
| 122 | ].join('\n')); |
| 123 | writeFile(path.join(workDir, '.github', 'workflows', 'ci.yml'), [ |
| 124 | 'name: ci', |
| 125 | '', |
| 126 | 'on:', |
| 127 | ' pull_request:', |
| 128 | ' branches: [main]', |
| 129 | ' push:', |
| 130 | ' branches: [main]', |
| 131 | '', |
| 132 | 'jobs:', |
| 133 | ' ci:', |
| 134 | ' runs-on: ubuntu-latest', |
| 135 | ' steps:', |
| 136 | ' - uses: actions/checkout@v4', |
| 137 | ' - uses: actions/setup-node@v4', |
| 138 | ' with:', |
| 139 | ' node-version: 22', |
| 140 | ` - run: sleep ${args.ciSleepSeconds}`, |
| 141 | ' - run: npm test', |
| 142 | '', |
| 143 | ].join('\n')); |
| 144 | writeFile(path.join(workDir, 'README.md'), [ |
| 145 | '# Citadel Berman Steward Proof', |
| 146 | '', |
| 147 | 'Disposable live proof repo for post-PR deploy steward behavior.', |
| 148 | '', |
| 149 | ].join('\n')); |
| 150 | |
| 151 | const stewardScript = extractStewardScript(agentsMd); |
| 152 | writeFile(path.join(workDir, '.agent-steward', 'deploy-steward.cjs'), stewardScript); |
| 153 | writeFile(path.join(workDir, '.agent-steward', 'fake-deploy.cjs'), [ |
| 154 | "'use strict';", |
| 155 | "const fs = require('fs');", |
no test coverage detected