@swarp/cli 0.0.3-rc.28 → 0.0.3-rc.30
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/package.json +1 -1
- package/src/init/index.mjs +0 -53
- package/src/init/index.test.mjs +1 -28
package/package.json
CHANGED
package/src/init/index.mjs
CHANGED
|
@@ -93,11 +93,6 @@ function buildRouterYaml() {
|
|
|
93
93
|
registration:
|
|
94
94
|
ttl_minutes: 30
|
|
95
95
|
persist_path: /data/registry.json
|
|
96
|
-
|
|
97
|
-
tls:
|
|
98
|
-
ca_cert_secret: SWARP_MTLS_CA_CERT
|
|
99
|
-
router_cert_secret: SWARP_MTLS_ROUTER_CERT
|
|
100
|
-
router_key_secret: SWARP_MTLS_ROUTER_KEY
|
|
101
96
|
`;
|
|
102
97
|
}
|
|
103
98
|
|
|
@@ -136,51 +131,6 @@ function updateMcpJson(cwd) {
|
|
|
136
131
|
console.log(` update ${mcpPath} — added swarp entry`);
|
|
137
132
|
}
|
|
138
133
|
|
|
139
|
-
// ── GitHub environment setup ──────────────────────────────────────────────────
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Creates the `swarp-certs` GitHub environment with the authenticated user as
|
|
143
|
-
* a required reviewer. Best-effort — logs a skip message if `gh` is unavailable
|
|
144
|
-
* or the API call fails.
|
|
145
|
-
*/
|
|
146
|
-
function createGithubCertsEnvironment() {
|
|
147
|
-
try {
|
|
148
|
-
const repo = execFileSync('gh', ['repo', 'view', '--json', 'nameWithOwner', '-q', '.nameWithOwner'], {
|
|
149
|
-
encoding: 'utf8',
|
|
150
|
-
}).trim();
|
|
151
|
-
|
|
152
|
-
execFileSync(
|
|
153
|
-
'gh',
|
|
154
|
-
['api', `repos/${repo}/environments/swarp-certs`, '-X', 'PUT', '--input', '-'],
|
|
155
|
-
{ input: JSON.stringify({ deployment_branch_policy: null }), encoding: 'utf8' },
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
const userId = execFileSync('gh', ['api', 'user', '-q', '.id'], { encoding: 'utf8' }).trim();
|
|
159
|
-
|
|
160
|
-
execFileSync(
|
|
161
|
-
'gh',
|
|
162
|
-
[
|
|
163
|
-
'api',
|
|
164
|
-
`repos/${repo}/environments/swarp-certs`,
|
|
165
|
-
'-X',
|
|
166
|
-
'PUT',
|
|
167
|
-
'--input',
|
|
168
|
-
'-',
|
|
169
|
-
],
|
|
170
|
-
{
|
|
171
|
-
input: JSON.stringify({
|
|
172
|
-
reviewers: [{ type: 'User', id: Number(userId) }],
|
|
173
|
-
deployment_branch_policy: null,
|
|
174
|
-
}),
|
|
175
|
-
encoding: 'utf8',
|
|
176
|
-
},
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
console.log(' create GitHub environment swarp-certs (required reviewer set)');
|
|
180
|
-
} catch {
|
|
181
|
-
console.log(' skip GitHub environment swarp-certs (gh unavailable or request failed)');
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
134
|
|
|
185
135
|
// ── Main entry point ──────────────────────────────────────────────────────────
|
|
186
136
|
|
|
@@ -223,9 +173,6 @@ export async function runInit({ cwd = process.cwd(), wizardAnswers, input, outpu
|
|
|
223
173
|
// 7. .mcp.json
|
|
224
174
|
updateMcpJson(cwd);
|
|
225
175
|
|
|
226
|
-
// 7b. GitHub swarp-certs environment
|
|
227
|
-
createGithubCertsEnvironment();
|
|
228
|
-
|
|
229
176
|
// 8. .claude/skills/swarp/SKILL.md — generated from agent configs
|
|
230
177
|
const skillContent = generateSkill({
|
|
231
178
|
agentsDir: path.resolve(cwd, agentsDir),
|
package/src/init/index.test.mjs
CHANGED
|
@@ -93,7 +93,7 @@ describe('runInit', () => {
|
|
|
93
93
|
expect(fs.existsSync(p)).toBe(true);
|
|
94
94
|
const content = fs.readFileSync(p, 'utf8');
|
|
95
95
|
expect(content).toContain('grpc_port: 50051');
|
|
96
|
-
expect(content).toContain('
|
|
96
|
+
expect(content).toContain('grpc_port: 50051');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
it('creates .github/workflows/deploy-agents.yml', async () => {
|
|
@@ -187,31 +187,4 @@ describe('runInit', () => {
|
|
|
187
187
|
expect(messages).toContain('/swarp');
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
-
describe('GitHub swarp-certs environment', () => {
|
|
191
|
-
it('calls gh api to create the swarp-certs environment', async () => {
|
|
192
|
-
execFileSyncImpl = (cmd, args) => {
|
|
193
|
-
if (cmd === 'gh' && args[0] === 'repo') return 'myorg/myrepo\n';
|
|
194
|
-
if (cmd === 'gh' && args[0] === 'api' && args[1] === 'user') return '12345\n';
|
|
195
|
-
if (cmd === 'gh' && args[0] === 'api') return '{}';
|
|
196
|
-
// which checks — return empty string (tool found)
|
|
197
|
-
return '';
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
await runInit({ cwd: tmpDir, wizardAnswers: DEFAULT_ANSWERS });
|
|
201
|
-
|
|
202
|
-
const apiCalls = execFileSyncCalls.filter(
|
|
203
|
-
([cmd, args]) => cmd === 'gh' && args[0] === 'api' && args[1]?.includes('swarp-certs'),
|
|
204
|
-
);
|
|
205
|
-
expect(apiCalls.length).toBeGreaterThanOrEqual(1);
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('skips environment creation gracefully when gh fails', async () => {
|
|
209
|
-
execFileSyncImpl = (cmd, args) => {
|
|
210
|
-
if (cmd === 'gh' && args[0] === 'repo') throw new Error('gh not found');
|
|
211
|
-
return '';
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
await expect(runInit({ cwd: tmpDir, wizardAnswers: DEFAULT_ANSWERS })).resolves.toBeUndefined();
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
190
|
});
|