opencastle 1.10.1 → 1.11.1
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/README.md +1 -1
- package/dist/cli/detect.d.ts.map +1 -1
- package/dist/cli/detect.js +106 -2
- package/dist/cli/detect.js.map +1 -1
- package/dist/cli/detect.test.js +76 -0
- package/dist/cli/detect.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +5 -4
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js +11 -5
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/init-detect.test.js +18 -0
- package/dist/cli/init-detect.test.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +1 -0
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +10 -0
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/mcp-upgrade.test.js +40 -1
- package/dist/cli/mcp-upgrade.test.js.map +1 -1
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +6 -2
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/stack-config-update.test.js +115 -2
- package/dist/cli/stack-config-update.test.js.map +1 -1
- package/dist/cli/stack-config.d.ts +17 -0
- package/dist/cli/stack-config.d.ts.map +1 -1
- package/dist/cli/stack-config.js +137 -3
- package/dist/cli/stack-config.js.map +1 -1
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +6 -0
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync-check.test.js +23 -0
- package/dist/cli/sync-check.test.js.map +1 -1
- package/dist/cli/team-health.d.ts.map +1 -1
- package/dist/cli/team-health.js +14 -3
- package/dist/cli/team-health.js.map +1 -1
- package/dist/cli/team-health.test.d.ts +2 -0
- package/dist/cli/team-health.test.d.ts.map +1 -0
- package/dist/cli/team-health.test.js +44 -0
- package/dist/cli/team-health.test.js.map +1 -0
- package/dist/cli/types.d.ts +3 -1
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +3 -4
- package/dist/cli/update.js.map +1 -1
- package/dist/orchestrator/plugins/github/config.d.ts +3 -0
- package/dist/orchestrator/plugins/github/config.d.ts.map +1 -0
- package/dist/orchestrator/plugins/github/config.js +36 -0
- package/dist/orchestrator/plugins/github/config.js.map +1 -0
- package/dist/orchestrator/plugins/gitlab/config.d.ts +3 -0
- package/dist/orchestrator/plugins/gitlab/config.d.ts.map +1 -0
- package/dist/orchestrator/plugins/gitlab/config.js +26 -0
- package/dist/orchestrator/plugins/gitlab/config.js.map +1 -0
- package/dist/orchestrator/plugins/index.d.ts.map +1 -1
- package/dist/orchestrator/plugins/index.js +4 -0
- package/dist/orchestrator/plugins/index.js.map +1 -1
- package/dist/orchestrator/plugins/types.d.ts +15 -1
- package/dist/orchestrator/plugins/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/cli/detect.test.ts +88 -0
- package/src/cli/detect.ts +100 -3
- package/src/cli/doctor.ts +5 -4
- package/src/cli/explain.ts +10 -5
- package/src/cli/init-detect.test.ts +22 -0
- package/src/cli/init.test.ts +13 -0
- package/src/cli/init.ts +1 -0
- package/src/cli/mcp-upgrade.test.ts +45 -2
- package/src/cli/mcp.ts +10 -4
- package/src/cli/stack-config-update.test.ts +123 -2
- package/src/cli/stack-config.ts +134 -3
- package/src/cli/sync-check.test.ts +29 -0
- package/src/cli/sync-check.ts +5 -0
- package/src/cli/team-health.test.ts +51 -0
- package/src/cli/team-health.ts +11 -2
- package/src/cli/types.ts +3 -1
- package/src/cli/update.ts +3 -4
- package/src/orchestrator/customizations/agents/skill-matrix.json +7 -1
- package/src/orchestrator/plugins/github/config.ts +37 -0
- package/src/orchestrator/plugins/github/mcp.json +9 -0
- package/src/orchestrator/plugins/github/plugin.json +24 -0
- package/src/orchestrator/plugins/github/skills/github-platform/SKILL.md +77 -0
- package/src/orchestrator/plugins/gitlab/config.ts +27 -0
- package/src/orchestrator/plugins/gitlab/mcp.json +9 -0
- package/src/orchestrator/plugins/gitlab/plugin.json +21 -0
- package/src/orchestrator/plugins/gitlab/skills/gitlab-platform/SKILL.md +72 -0
- package/src/orchestrator/plugins/index.ts +4 -0
- package/src/orchestrator/plugins/types.ts +17 -1
package/src/cli/detect.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolve } from 'node:path';
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
2
|
import { readFile, readdir, access } from 'node:fs/promises';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
4
|
import type { IdeChoice, RepoInfo, StackConfig } from './types.js';
|
|
@@ -178,6 +178,18 @@ const CICD: DetectionRule[] = [
|
|
|
178
178
|
{ label: 'travis', files: ['.travis.yml'] },
|
|
179
179
|
];
|
|
180
180
|
|
|
181
|
+
// Files only a code host reads. Not `.github/` as a whole: VS Code's Copilot
|
|
182
|
+
// files live there too — `copilot-instructions.md`, `agents/`, `prompts/` —
|
|
183
|
+
// and this tool writes them for every VS Code target, hosted anywhere.
|
|
184
|
+
const CODE_HOSTS: DetectionRule[] = [
|
|
185
|
+
{
|
|
186
|
+
label: 'github',
|
|
187
|
+
files: ['.github/dependabot.yml', '.github/dependabot.yaml', '.github/CODEOWNERS', '.github/pull_request_template.md', '.github/PULL_REQUEST_TEMPLATE.md', '.github/FUNDING.yml'],
|
|
188
|
+
dirs: ['.github/workflows/', '.github/ISSUE_TEMPLATE/', '.github/PULL_REQUEST_TEMPLATE/'],
|
|
189
|
+
},
|
|
190
|
+
{ label: 'gitlab', files: ['.gitlab-ci.yml'], dirs: ['.gitlab/'] },
|
|
191
|
+
];
|
|
192
|
+
|
|
181
193
|
const STYLING: DetectionRule[] = [
|
|
182
194
|
{ label: 'tailwind', files: ['tailwind.config.js', 'tailwind.config.ts', 'tailwind.config.mjs'] },
|
|
183
195
|
{ label: 'sass', files: [] }, // detected via package.json
|
|
@@ -249,6 +261,14 @@ export const PACKAGE_DETECTIONS: Record<string, { category: string; label: strin
|
|
|
249
261
|
'@linear/sdk': { category: 'pm', label: 'linear' },
|
|
250
262
|
'@slack/web-api': { category: 'notifications', label: 'slack' },
|
|
251
263
|
'@slack/bolt': { category: 'notifications', label: 'slack' },
|
|
264
|
+
// Code hosts (their APIs, and GitHub Actions written in this repository)
|
|
265
|
+
'octokit': { category: 'codeHosts', label: 'github' },
|
|
266
|
+
'@octokit/rest': { category: 'codeHosts', label: 'github' },
|
|
267
|
+
'@octokit/core': { category: 'codeHosts', label: 'github' },
|
|
268
|
+
'@actions/core': { category: 'codeHosts', label: 'github' },
|
|
269
|
+
'@actions/github': { category: 'codeHosts', label: 'github' },
|
|
270
|
+
'@gitbeaker/rest': { category: 'codeHosts', label: 'gitlab' },
|
|
271
|
+
'@gitbeaker/core': { category: 'codeHosts', label: 'gitlab' },
|
|
252
272
|
};
|
|
253
273
|
|
|
254
274
|
// ── Helpers ───────────────────────────────────────────────────
|
|
@@ -294,6 +314,7 @@ interface RepoInfoInternal {
|
|
|
294
314
|
services: string[];
|
|
295
315
|
pm: string[];
|
|
296
316
|
notifications: string[];
|
|
317
|
+
codeHosts: string[];
|
|
297
318
|
mcpConfig?: boolean;
|
|
298
319
|
configFiles: string[];
|
|
299
320
|
}
|
|
@@ -316,6 +337,7 @@ export async function detectRepoInfo(projectRoot: string): Promise<RepoInfo> {
|
|
|
316
337
|
services: [],
|
|
317
338
|
pm: [],
|
|
318
339
|
notifications: [],
|
|
340
|
+
codeHosts: [],
|
|
319
341
|
configFiles: [],
|
|
320
342
|
};
|
|
321
343
|
|
|
@@ -350,8 +372,12 @@ export async function detectRepoInfo(projectRoot: string): Promise<RepoInfo> {
|
|
|
350
372
|
detectCategory(projectRoot, STYLING, info, 'styling'),
|
|
351
373
|
detectCategory(projectRoot, AUTH, info, 'auth'),
|
|
352
374
|
detectCategory(projectRoot, SERVICES, info, 'services'),
|
|
375
|
+
detectCategory(projectRoot, CODE_HOSTS, info, 'codeHosts'),
|
|
353
376
|
]);
|
|
354
377
|
|
|
378
|
+
// ── 3b. Detect the code host from git remotes ───────────────
|
|
379
|
+
await detectCodeHosts(projectRoot, info);
|
|
380
|
+
|
|
355
381
|
// ── 4. Detect from package.json deps ────────────────────────
|
|
356
382
|
await detectFromPackageJson(projectRoot, info);
|
|
357
383
|
|
|
@@ -411,7 +437,7 @@ export async function detectRepoInfo(projectRoot: string): Promise<RepoInfo> {
|
|
|
411
437
|
info.configFiles = [...new Set(info.configFiles)];
|
|
412
438
|
|
|
413
439
|
// Sort arrays for stable output
|
|
414
|
-
for (const key of ['frameworks', 'databases', 'cms', 'deployment', 'testing', 'cicd', 'styling', 'auth', 'services', 'pm', 'notifications', 'configFiles'] as const) {
|
|
440
|
+
for (const key of ['frameworks', 'databases', 'cms', 'deployment', 'testing', 'cicd', 'styling', 'auth', 'services', 'pm', 'notifications', 'codeHosts', 'configFiles'] as const) {
|
|
415
441
|
info[key].sort();
|
|
416
442
|
}
|
|
417
443
|
|
|
@@ -445,6 +471,72 @@ async function detectPythonOrGo(root: string, info: RepoInfoInternal): Promise<v
|
|
|
445
471
|
for (const [re, label] of PYTHON_FRAMEWORKS) if (re.test(text)) addUnique(info.frameworks, label)
|
|
446
472
|
}
|
|
447
473
|
|
|
474
|
+
/**
|
|
475
|
+
* Where the repository is hosted, from what names the host outright: its git
|
|
476
|
+
* remotes, the `repository` in package.json, and a Go module path. The file
|
|
477
|
+
* rules in CODE_HOSTS cover a checkout with no remote.
|
|
478
|
+
*
|
|
479
|
+
* A self-managed GitLab is recognised by `gitlab` in its host name, the usual
|
|
480
|
+
* convention; one under another name is added with `opencastle add gitlab`.
|
|
481
|
+
*/
|
|
482
|
+
async function detectCodeHosts(root: string, info: RepoInfoInternal): Promise<void> {
|
|
483
|
+
const urls: string[] = []
|
|
484
|
+
// Remotes only: a submodule's `url` names where a dependency lives.
|
|
485
|
+
let remote = false
|
|
486
|
+
for (const line of (await readGitConfig(root)).split('\n')) {
|
|
487
|
+
if (/^\s*\[/.test(line)) remote = /^\s*\[remote\s/.test(line)
|
|
488
|
+
const url = remote ? /^\s*url\s*=\s*(\S+)/.exec(line)?.[1] : undefined
|
|
489
|
+
if (url) urls.push(url)
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
const repository = (JSON.parse(await readFile(resolve(root, 'package.json'), 'utf8')) as { repository?: string | { url?: string } }).repository
|
|
493
|
+
const url = typeof repository === 'string' ? repository : repository?.url
|
|
494
|
+
// npm's shorthands: `github:user/repo`, `gitlab:user/repo`, and a bare `user/repo` for GitHub.
|
|
495
|
+
if (url) urls.push(/^[\w.-]+\/[\w.-]+$/.test(url) ? 'github.com/' + url : url.replace(/^(github|gitlab):/, '$1.com/'))
|
|
496
|
+
} catch {
|
|
497
|
+
// No package.json, or not JSON — the other signals still count.
|
|
498
|
+
}
|
|
499
|
+
const goModule = /^module\s+(\S+)/m.exec(await readFile(resolve(root, 'go.mod'), 'utf8').catch(() => ''))?.[1]
|
|
500
|
+
if (goModule) urls.push(goModule)
|
|
501
|
+
for (const url of urls) {
|
|
502
|
+
const host = codeHostOf(url)
|
|
503
|
+
if (host) addUnique(info.codeHosts, host)
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/** `github` or `gitlab` for a URL, scp-style address or module path on one of them. */
|
|
508
|
+
function codeHostOf(url: string): string | null {
|
|
509
|
+
// https://host/…, ssh://git@host/…, git@host:path and host/path.
|
|
510
|
+
const host = /^(?:[a-z][a-z0-9+.-]*:\/\/)?(?:[^@/]+@)?([^:/]+)/i.exec(url)?.[1].toLowerCase() ?? ''
|
|
511
|
+
if (host === 'github.com' || host === 'ssh.github.com') return 'github'
|
|
512
|
+
if (/(^|[.-])gitlab([.-]|$)/.test(host)) return 'gitlab'
|
|
513
|
+
return null
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* The git config of the repository the project is in, following `.git` up
|
|
518
|
+
* through parent directories, as git does — a package in a monorepo has no
|
|
519
|
+
* `.git` of its own — and through a `.git` file, which is a worktree or a
|
|
520
|
+
* submodule.
|
|
521
|
+
*/
|
|
522
|
+
async function readGitConfig(root: string): Promise<string> {
|
|
523
|
+
let dir = resolve(root)
|
|
524
|
+
while (!(await fileExists(resolve(dir, '.git')))) {
|
|
525
|
+
const parent = dirname(dir)
|
|
526
|
+
if (parent === dir) return ''
|
|
527
|
+
dir = parent
|
|
528
|
+
}
|
|
529
|
+
let gitDir = resolve(dir, '.git')
|
|
530
|
+
const pointer = /^gitdir:\s*(.+)$/m.exec(await readFile(gitDir, 'utf8').catch(() => ''))
|
|
531
|
+
if (pointer) {
|
|
532
|
+
gitDir = resolve(dir, pointer[1].trim())
|
|
533
|
+
// A worktree keeps its remotes in the main repository's config.
|
|
534
|
+
const common = (await readFile(resolve(gitDir, 'commondir'), 'utf8').catch(() => '')).trim()
|
|
535
|
+
if (common) gitDir = resolve(gitDir, common)
|
|
536
|
+
}
|
|
537
|
+
return readFile(resolve(gitDir, 'config'), 'utf8').catch(() => '')
|
|
538
|
+
}
|
|
539
|
+
|
|
448
540
|
async function checkFiles(root: string, files: string[]): Promise<string[]> {
|
|
449
541
|
const found: string[] = [];
|
|
450
542
|
for (const f of files) {
|
|
@@ -455,7 +547,7 @@ async function checkFiles(root: string, files: string[]): Promise<string[]> {
|
|
|
455
547
|
return found;
|
|
456
548
|
}
|
|
457
549
|
|
|
458
|
-
type CategoryKey = 'frameworks' | 'databases' | 'cms' | 'deployment' | 'testing' | 'cicd' | 'styling' | 'auth' | 'services' | 'pm' | 'notifications';
|
|
550
|
+
type CategoryKey = 'frameworks' | 'databases' | 'cms' | 'deployment' | 'testing' | 'cicd' | 'styling' | 'auth' | 'services' | 'pm' | 'notifications' | 'codeHosts';
|
|
459
551
|
|
|
460
552
|
async function detectCategory(
|
|
461
553
|
root: string,
|
|
@@ -695,6 +787,7 @@ export function buildDetectedToolsSet(repoInfo: RepoInfo): Set<string> {
|
|
|
695
787
|
...(repoInfo.services ?? []),
|
|
696
788
|
...(repoInfo.pm ?? []),
|
|
697
789
|
...(repoInfo.notifications ?? []),
|
|
790
|
+
...(repoInfo.codeHosts ?? []),
|
|
698
791
|
]);
|
|
699
792
|
}
|
|
700
793
|
|
|
@@ -719,6 +812,7 @@ function cleanEmpty(info: RepoInfoInternal): RepoInfo {
|
|
|
719
812
|
if (info.services.length > 0) result.services = info.services;
|
|
720
813
|
if (info.pm.length > 0) result.pm = info.pm;
|
|
721
814
|
if (info.notifications.length > 0) result.notifications = info.notifications;
|
|
815
|
+
if (info.codeHosts.length > 0) result.codeHosts = info.codeHosts;
|
|
722
816
|
if (info.configFiles.length > 0) result.configFiles = info.configFiles;
|
|
723
817
|
|
|
724
818
|
return result;
|
|
@@ -751,6 +845,8 @@ export function mergeStackIntoRepoInfo(info: RepoInfo, stack: StackConfig): Repo
|
|
|
751
845
|
merged.pm = addUniqueToArray(merged.pm, tool);
|
|
752
846
|
} else if (['slack', 'teams'].includes(tool)) {
|
|
753
847
|
merged.notifications = addUniqueToArray(merged.notifications, tool);
|
|
848
|
+
} else if (['github', 'gitlab'].includes(tool)) {
|
|
849
|
+
merged.codeHosts = addUniqueToArray(merged.codeHosts, tool);
|
|
754
850
|
}
|
|
755
851
|
}
|
|
756
852
|
|
|
@@ -790,6 +886,7 @@ export function formatRepoInfo(info: RepoInfo): string {
|
|
|
790
886
|
if (info.services?.length) lines.push(`Services: ${info.services.join(', ')}`);
|
|
791
887
|
if (info.pm?.length) lines.push(`Project management: ${info.pm.join(', ')}`);
|
|
792
888
|
if (info.notifications?.length) lines.push(`Notifications: ${info.notifications.join(', ')}`);
|
|
889
|
+
if (info.codeHosts?.length) lines.push(`Code hosting: ${info.codeHosts.join(', ')}`);
|
|
793
890
|
if (info.deployment?.length) lines.push(`Deployment: ${info.deployment.join(', ')}`);
|
|
794
891
|
if (info.testing?.length) lines.push(`Testing: ${info.testing.join(', ')}`);
|
|
795
892
|
if (info.cicd?.length) lines.push(`CI/CD: ${info.cicd.join(', ')}`);
|
package/src/cli/doctor.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
|
|
|
2
2
|
import { readdir, readFile } from 'node:fs/promises';
|
|
3
3
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
4
4
|
import { readManifest } from './manifest.js';
|
|
5
|
-
import { getRequiredMcpEnvVars, resolveStack, isEnvVarSatisfied, getIncludedMcpServers } from './stack-config.js';
|
|
5
|
+
import { getRequiredMcpEnvVars, resolveStack, isEnvVarSatisfied, getIncludedMcpServers, envFileTextFor } from './stack-config.js';
|
|
6
6
|
import { IDE_ADAPTERS, VALID_IDES } from './adapters/index.js';
|
|
7
7
|
import { resolveManagedPaths, ROOT_INSTRUCTION_FILES } from './managed-paths.js';
|
|
8
8
|
import {
|
|
@@ -304,8 +304,7 @@ async function checkMcpEnvVars(
|
|
|
304
304
|
if (required.length === 0) {
|
|
305
305
|
return { ok: true, label: 'MCP environment variables', detail: 'No env vars required' };
|
|
306
306
|
}
|
|
307
|
-
const
|
|
308
|
-
const missing = required.filter((r) => !isEnvVarSatisfied(r.envVar, envFile));
|
|
307
|
+
const missing = required.filter((r) => !isEnvVarSatisfied(r.envVar, envFileTextFor(projectRoot, r.server)));
|
|
309
308
|
if (missing.length > 0) {
|
|
310
309
|
const names = missing.map((m) => m.envVar).join(', ');
|
|
311
310
|
return {
|
|
@@ -323,7 +322,9 @@ async function checkDotEnv(projectRoot: string, manifest: Manifest | null): Prom
|
|
|
323
322
|
const envPath = resolve(projectRoot, '.env');
|
|
324
323
|
if (!existsSync(envPath)) {
|
|
325
324
|
if (manifest?.stack) {
|
|
326
|
-
|
|
325
|
+
// Not when every secret is already where its server reads it.
|
|
326
|
+
const required = getRequiredMcpEnvVars(resolveStack(manifest), manifest.repoInfo)
|
|
327
|
+
.filter((r) => !isEnvVarSatisfied(r.envVar, envFileTextFor(projectRoot, r.server)));
|
|
327
328
|
if (required.length > 0) {
|
|
328
329
|
return { ok: true, label: '.env file', detail: 'Not found — consider creating one for MCP secrets', warning: true };
|
|
329
330
|
}
|
package/src/cli/explain.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync, realpathSync } from 'node:fs'
|
|
2
2
|
import { homedir } from 'node:os'
|
|
3
|
-
import { join
|
|
3
|
+
import { join } from 'node:path'
|
|
4
4
|
import { parse as parseToml } from 'smol-toml'
|
|
5
5
|
import { readManifest } from './manifest.js'
|
|
6
|
-
import { resolveStack, isEnvVarSatisfied } from './stack-config.js'
|
|
6
|
+
import { resolveStack, isEnvVarSatisfied, envFileTextFor } from './stack-config.js'
|
|
7
7
|
import { resolveSources, materialize, hasErrors, formatIssues, requiredEnvVars, refuseOlderCli } from './layers.js'
|
|
8
8
|
import { buildLock, type Lock, priorTeam } from './lock.js'
|
|
9
9
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
@@ -80,19 +80,24 @@ async function build(pkgRoot: string, projectRoot: string): Promise<ExplainRepor
|
|
|
80
80
|
})
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const envFile = existsSync(resolve(projectRoot, '.env')) ? readFileSync(resolve(projectRoot, '.env'), 'utf8') : ''
|
|
84
83
|
const setup: ExplainReport['setup'] = []
|
|
85
84
|
for (const req of requiredEnvVars(resolved, stack, manifest.repoInfo)) {
|
|
86
85
|
setup.push({
|
|
87
86
|
server: req.server,
|
|
88
87
|
need: req.envVar,
|
|
89
|
-
ok: isEnvVarSatisfied(req.envVar,
|
|
88
|
+
ok: isEnvVarSatisfied(req.envVar, envFileTextFor(projectRoot, req.server)),
|
|
90
89
|
how: req.hint,
|
|
91
90
|
})
|
|
92
91
|
}
|
|
93
92
|
for (const [key, s] of Object.entries(lock.mcp)) {
|
|
93
|
+
// A server that takes a token elsewhere signs in with OAuth in some targets.
|
|
94
|
+
const plugin = s.from.startsWith('plugin:') ? PLUGINS[s.from.slice(7)] : undefined
|
|
95
|
+
const oauthIn = (plugin?.tokenAuth?.oauthTargets ?? []).filter((t) => ides.includes(t))
|
|
94
96
|
if (s.auth === 'oauth') {
|
|
95
97
|
setup.push({ server: key, need: 'sign-in', ok: true, how: 'your assistant opens a browser to sign in the first time it starts the server' })
|
|
98
|
+
} else if (oauthIn.length > 0) {
|
|
99
|
+
const where = oauthIn.map((t) => IDE_LABELS[t]).join(', ')
|
|
100
|
+
setup.push({ server: key, need: 'sign-in', ok: true, how: `${where} opens a browser to sign in the first time it starts the server` })
|
|
96
101
|
}
|
|
97
102
|
}
|
|
98
103
|
// Codex loads a project's `.codex/config.toml` only once the user has
|
|
@@ -144,6 +144,28 @@ describe('detected selection', () => {
|
|
|
144
144
|
expect(selection.teamTools).toEqual([])
|
|
145
145
|
expect(selection.techTools.length).toBeGreaterThan(0)
|
|
146
146
|
})
|
|
147
|
+
|
|
148
|
+
it.each([
|
|
149
|
+
['github', 'https://github.com/acme/web.git'],
|
|
150
|
+
['gitlab', 'git@gitlab.com:acme/web.git'],
|
|
151
|
+
])('selects %s when the repository is hosted there', async (host, url) => {
|
|
152
|
+
mkdirSync(join(dir, '.git'))
|
|
153
|
+
writeFileSync(join(dir, '.git', 'config'), `[remote "origin"]\n\turl = ${url}\n`)
|
|
154
|
+
writeFileSync(join(dir, 'package.json'), JSON.stringify({ name: 'x' }))
|
|
155
|
+
|
|
156
|
+
const selection = detectSelection(dir, await detectRepoInfo(dir))
|
|
157
|
+
|
|
158
|
+
expect(selection.teamTools).toEqual([host])
|
|
159
|
+
expect(selection.techTools).not.toContain(host)
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
it('selects neither code host for a repository with no sign of one', async () => {
|
|
163
|
+
mkdirSync(join(dir, '.git'))
|
|
164
|
+
writeFileSync(join(dir, '.git', 'config'), '[core]\n\tbare = false\n')
|
|
165
|
+
const selection = detectSelection(dir, await detectRepoInfo(dir))
|
|
166
|
+
expect(selection.teamTools).not.toContain('github')
|
|
167
|
+
expect(selection.teamTools).not.toContain('gitlab')
|
|
168
|
+
})
|
|
147
169
|
})
|
|
148
170
|
|
|
149
171
|
/**
|
package/src/cli/init.test.ts
CHANGED
|
@@ -219,6 +219,19 @@ describe('stack-config: getRequiredMcpEnvVars', () => {
|
|
|
219
219
|
])
|
|
220
220
|
)
|
|
221
221
|
})
|
|
222
|
+
|
|
223
|
+
it('asks for the GitHub token only when a target cannot sign in with OAuth', () => {
|
|
224
|
+
// GitHub's server completes OAuth in VS Code alone; the rest send the token.
|
|
225
|
+
const github = (ides: StackConfig['ides']) =>
|
|
226
|
+
getRequiredMcpEnvVars({ ides, techTools: [], teamTools: ['github'] }).map((v) => v.envVar)
|
|
227
|
+
expect(github(['vscode'])).toEqual([])
|
|
228
|
+
expect(github(['vscode', 'claude-code'])).toEqual(['GITHUB_PERSONAL_ACCESS_TOKEN'])
|
|
229
|
+
expect(github(['cursor'])).toEqual(['GITHUB_PERSONAL_ACCESS_TOKEN'])
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
it('asks for no GitLab token — GitLab’s server signs in with OAuth', () => {
|
|
233
|
+
expect(getRequiredMcpEnvVars({ ides: ['claude-code'], techTools: [], teamTools: ['gitlab'] })).toEqual([])
|
|
234
|
+
})
|
|
222
235
|
})
|
|
223
236
|
|
|
224
237
|
describe('stack-config: getAgentToolInjections', () => {
|
package/src/cli/init.ts
CHANGED
|
@@ -51,6 +51,7 @@ const CATEGORY_STEPS: Array<{ title: string; subCategories: string[]; target: 't
|
|
|
51
51
|
{ title: 'Build Tools', subCategories: ['codebase-tool'], target: 'tech' },
|
|
52
52
|
{ title: 'More Tools', subCategories: ['design', 'email', 'payments', 'observability', 'knowledge-management'], target: 'tech' },
|
|
53
53
|
{ title: 'Project Management', subCategories: ['task-management'], target: 'team' },
|
|
54
|
+
{ title: 'Code Hosting', subCategories: ['source-control'], target: 'team' },
|
|
54
55
|
{ title: 'Notifications', subCategories: ['notifications'], target: 'team' },
|
|
55
56
|
]
|
|
56
57
|
|
|
@@ -11,9 +11,10 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
|
11
11
|
import { mkdtempSync, writeFileSync, readFileSync, rmSync, realpathSync, mkdirSync } from 'node:fs'
|
|
12
12
|
import { join } from 'node:path'
|
|
13
13
|
import { tmpdir } from 'node:os'
|
|
14
|
-
import { upgradeGeneratedServers, rebuildMcpConfig, scaffoldMcpConfig, teamEntryFor } from './mcp.js'
|
|
14
|
+
import { upgradeGeneratedServers, rebuildMcpConfig, scaffoldMcpConfig, teamEntryFor, getMcpConfigRelPath, containerKeyFor } from './mcp.js'
|
|
15
15
|
import { auditMcpConfig } from './mcp-audit.js'
|
|
16
|
-
import
|
|
16
|
+
import { parseMcpConfigText } from './mcp-file.js'
|
|
17
|
+
import type { IdeChoice, StackConfig } from './types.js'
|
|
17
18
|
|
|
18
19
|
describe('upgradeGeneratedServers', () => {
|
|
19
20
|
it('adds the type Claude Code needs to a remote server we wrote without it', () => {
|
|
@@ -158,3 +159,45 @@ describe('rebuildMcpConfig on an install from before the fix', () => {
|
|
|
158
159
|
}
|
|
159
160
|
})
|
|
160
161
|
})
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* GitHub's server completes OAuth in VS Code and nowhere else. VS Code gets the
|
|
165
|
+
* bare URL; every other target sends the token, in its own spelling of "this
|
|
166
|
+
* environment variable" — a `${NAME}` Cursor or OpenCode does not expand would
|
|
167
|
+
* reach GitHub as those characters.
|
|
168
|
+
*/
|
|
169
|
+
describe('a remote server only some targets sign in to with OAuth', () => {
|
|
170
|
+
let root: string
|
|
171
|
+
beforeEach(() => {
|
|
172
|
+
root = realpathSync(mkdtempSync(join(tmpdir(), 'mcp-token-auth-')))
|
|
173
|
+
})
|
|
174
|
+
afterEach(() => {
|
|
175
|
+
rmSync(root, { recursive: true, force: true })
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
const url = 'https://api.githubcopilot.com/mcp/'
|
|
179
|
+
const written = async (ide: IdeChoice): Promise<unknown> => {
|
|
180
|
+
const rel = getMcpConfigRelPath(ide)
|
|
181
|
+
await scaffoldMcpConfig(root, rel, { ides: [ide], techTools: [], teamTools: ['github'] }, undefined, ide)
|
|
182
|
+
const config = parseMcpConfigText(readFileSync(join(root, rel), 'utf8'), rel)
|
|
183
|
+
return (config[containerKeyFor(ide)] as Record<string, unknown>).GitHub
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
it.each([
|
|
187
|
+
['vscode', { type: 'http', url }],
|
|
188
|
+
['claude-code', { type: 'http', url, headers: { Authorization: 'Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}' } }],
|
|
189
|
+
['cursor', { url, headers: { Authorization: 'Bearer ${env:GITHUB_PERSONAL_ACCESS_TOKEN}' } }],
|
|
190
|
+
['windsurf', { url, headers: { Authorization: 'Bearer ${env:GITHUB_PERSONAL_ACCESS_TOKEN}' } }],
|
|
191
|
+
['opencode', { type: 'remote', url, headers: { Authorization: 'Bearer {env:GITHUB_PERSONAL_ACCESS_TOKEN}' } }],
|
|
192
|
+
['codex', { url, bearer_token_env_var: 'GITHUB_PERSONAL_ACCESS_TOKEN' }],
|
|
193
|
+
] as const)('%s', async (ide, entry) => {
|
|
194
|
+
expect(await written(ide)).toEqual(entry)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('writes nothing the audit objects to, and nothing a rebuild changes', async () => {
|
|
198
|
+
const entry = await written('claude-code')
|
|
199
|
+
expect(auditMcpConfig({ mcpServers: { GitHub: entry } }, 'claude-code').findings).toEqual([])
|
|
200
|
+
const stack: StackConfig = { ides: ['claude-code'], techTools: [], teamTools: ['github'] }
|
|
201
|
+
expect(await rebuildMcpConfig(root, 'claude-code', stack)).toEqual({ upgraded: [], removed: [], teamWritten: [], teamRemoved: [] })
|
|
202
|
+
})
|
|
203
|
+
})
|
package/src/cli/mcp.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync } from 'node:fs';
|
|
|
4
4
|
import { getIncludedMcpServers } from './stack-config.js';
|
|
5
5
|
import { PLUGINS } from '../orchestrator/plugins/index.js';
|
|
6
6
|
import { UnreadableConfigError } from './types.js';
|
|
7
|
-
import type { McpInput, McpServerConfig, EnvVarRequirement } from '../orchestrator/plugins/types.js';
|
|
7
|
+
import type { McpInput, McpServerConfig, EnvVarRequirement, PluginConfig } from '../orchestrator/plugins/types.js';
|
|
8
8
|
import type { ScaffoldResult, StackConfig, RepoInfo, IdeChoice, CopyResults } from './types.js';
|
|
9
9
|
import type { TeamMcpPlan } from './layers.js';
|
|
10
10
|
import { EDITOR_VARIABLES, type TeamMcpServer } from './team-config.js';
|
|
@@ -219,14 +219,20 @@ function transformMcpForIde(
|
|
|
219
219
|
|
|
220
220
|
/**
|
|
221
221
|
* One plugin's server as the VS Code–format config, with the env vars other
|
|
222
|
-
* targets need spelled out — they have no `envFile
|
|
222
|
+
* targets need spelled out — they have no `envFile` — and, for a server only
|
|
223
|
+
* some targets can sign in to with OAuth, the token header the others send.
|
|
223
224
|
*/
|
|
224
225
|
function serverFor(
|
|
225
|
-
plugin: { mcpConfig?: McpServerConfig; envVars: EnvVarRequirement[] },
|
|
226
|
+
plugin: { mcpConfig?: McpServerConfig; envVars: EnvVarRequirement[]; tokenAuth?: PluginConfig['tokenAuth'] },
|
|
226
227
|
ide: IdeChoice,
|
|
227
228
|
legacyEnv = false,
|
|
228
229
|
): VsCodeServer {
|
|
229
230
|
const serverConfig = { ...plugin.mcpConfig! } as VsCodeServer;
|
|
231
|
+
if (plugin.tokenAuth && !plugin.tokenAuth.oauthTargets.includes(ide)) {
|
|
232
|
+
serverConfig.headers = Object.fromEntries(
|
|
233
|
+
Object.entries(plugin.tokenAuth.headers).map(([k, v]) => [k, legacyEnv ? v : rewriteRefs(v, ide)]),
|
|
234
|
+
);
|
|
235
|
+
}
|
|
230
236
|
if (ide !== 'vscode' && plugin.envVars.length > 0) {
|
|
231
237
|
const envBlock: Record<string, string> = { ...(serverConfig.env ?? {}) };
|
|
232
238
|
for (const ev of plugin.envVars) {
|
|
@@ -435,7 +441,7 @@ export function upgradeGeneratedServers(
|
|
|
435
441
|
// shape and the env-variable spelling of the time.
|
|
436
442
|
const earlier: unknown[] = [];
|
|
437
443
|
const configs = [
|
|
438
|
-
{ mcpConfig: plugin.mcpConfig, envVars: plugin.envVars },
|
|
444
|
+
{ mcpConfig: plugin.mcpConfig, envVars: plugin.envVars, tokenAuth: plugin.tokenAuth },
|
|
439
445
|
...(plugin.previousMcpConfigs ?? []).map((p) => ({ mcpConfig: p.mcpConfig, envVars: p.envVars })),
|
|
440
446
|
];
|
|
441
447
|
for (const cfg of configs) {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
1
|
+
import { describe, it, expect, afterEach } from 'vitest';
|
|
2
|
+
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join, resolve } from 'node:path';
|
|
5
|
+
import { updateSkillMatrixContent, isEnvVarSatisfied, getExcludedCoreSkills, isPreselected, envFileTextFor, RETIRED_AGENTS, RETIRED_SKILLS } from './stack-config.js';
|
|
6
|
+
import { PLUGINS } from '../orchestrator/plugins/index.js';
|
|
3
7
|
import type { StackConfig } from './types.js';
|
|
4
8
|
import type { SkillMatrixData } from './stack-config.js';
|
|
5
9
|
|
|
@@ -70,6 +74,123 @@ describe('isEnvVarSatisfied', () => {
|
|
|
70
74
|
});
|
|
71
75
|
});
|
|
72
76
|
|
|
77
|
+
/**
|
|
78
|
+
* `source-control` arrived with GitHub and GitLab, after every existing
|
|
79
|
+
* project's matrix was written, and `sync` only filled slots a matrix had —
|
|
80
|
+
* so adding GitHub bound its skill to no agent.
|
|
81
|
+
*/
|
|
82
|
+
describe('a slot a release added', () => {
|
|
83
|
+
const withGithub: StackConfig = { ides: ['vscode'], techTools: [], teamTools: ['github'] };
|
|
84
|
+
const slotsOf = (data: SkillMatrixData, agent: string) => data.agents[agent].slots;
|
|
85
|
+
// A matrix as releases before the slot wrote it.
|
|
86
|
+
const makeOld = (): SkillMatrixData => ({
|
|
87
|
+
...makeTemplate(),
|
|
88
|
+
agents: {
|
|
89
|
+
'Team Lead (OpenCastle)': { slots: ['task-management'], directSkills: [] },
|
|
90
|
+
'DevOps & Release': { slots: ['deployment'], directSkills: [] },
|
|
91
|
+
Developer: { slots: ['framework'], directSkills: [] },
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('reaches an existing matrix once a selected integration fills it, with the agents it belongs to', () => {
|
|
96
|
+
const data: SkillMatrixData = JSON.parse(updateSkillMatrixContent(JSON.stringify(makeOld()), withGithub));
|
|
97
|
+
expect(data.bindings['source-control'].entries).toEqual([{ name: 'GitHub', skill: 'github-platform' }]);
|
|
98
|
+
expect(data.bindings['source-control'].description).toBeTruthy();
|
|
99
|
+
expect(slotsOf(data, 'Team Lead (OpenCastle)')).toContain('source-control');
|
|
100
|
+
expect(slotsOf(data, 'DevOps & Release')).toContain('source-control');
|
|
101
|
+
expect(slotsOf(data, 'Developer')).not.toContain('source-control');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('is not added for a stack that does not use it', () => {
|
|
105
|
+
const data: SkillMatrixData = JSON.parse(updateSkillMatrixContent(JSON.stringify(makeOld()), { ides: ['vscode'], techTools: [], teamTools: [] }));
|
|
106
|
+
expect(data.bindings['source-control']).toBeUndefined();
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('is the team’s once it exists: an agent they took it from does not get it back', () => {
|
|
110
|
+
const first: SkillMatrixData = JSON.parse(updateSkillMatrixContent(JSON.stringify(makeOld()), withGithub));
|
|
111
|
+
first.agents['DevOps & Release'].slots = first.agents['DevOps & Release'].slots.filter((s) => s !== 'source-control');
|
|
112
|
+
const again: SkillMatrixData = JSON.parse(updateSkillMatrixContent(JSON.stringify(first), withGithub));
|
|
113
|
+
expect(slotsOf(again, 'DevOps & Release')).not.toContain('source-control');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Nineteen agents became thirteen, and no matrix written before that was told:
|
|
119
|
+
* each kept eight agents that no longer exist, and the three that replaced
|
|
120
|
+
* them resolved no skills.
|
|
121
|
+
*/
|
|
122
|
+
describe('a matrix from before the agents merged', () => {
|
|
123
|
+
const none: StackConfig = { ides: ['vscode'], techTools: [], teamTools: [] };
|
|
124
|
+
const old = (): SkillMatrixData => ({
|
|
125
|
+
...makeTemplate(),
|
|
126
|
+
agents: {
|
|
127
|
+
'Team Lead': { slots: ['task-management'], directSkills: ['validation-gates', 'team-lead-reference'] },
|
|
128
|
+
'DevOps Expert': { slots: ['deployment'], directSkills: ['validation-gates', 'documentation-standards'] },
|
|
129
|
+
'Release Manager': { slots: ['codebase-tool', 'deployment'], directSkills: ['validation-gates'] },
|
|
130
|
+
'Session Guard': { slots: [], directSkills: ['observability-logging'] },
|
|
131
|
+
'Our Release Bot': { slots: ['deployment'], directSkills: ['our-runbook'] },
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('moves each retired agent to its successor, adds the current ones, and drops skills that are gone', () => {
|
|
136
|
+
const data: SkillMatrixData = JSON.parse(updateSkillMatrixContent(JSON.stringify(old()), none));
|
|
137
|
+
for (const retired of Object.keys(RETIRED_AGENTS)) expect(data.agents[retired], retired).toBeUndefined();
|
|
138
|
+
expect(data.agents['DevOps & Release'].slots).toEqual(expect.arrayContaining(['deployment', 'codebase-tool']));
|
|
139
|
+
expect(data.agents['DevOps & Release'].directSkills).not.toContain('documentation-standards');
|
|
140
|
+
expect(data.agents['Team Lead (OpenCastle)'].directSkills).toEqual(expect.arrayContaining(['validation-gates', 'fast-review']));
|
|
141
|
+
expect(data.agents['Team Lead (OpenCastle)'].directSkills).not.toContain('team-lead-reference');
|
|
142
|
+
for (const current of ['Writer', 'Data Engineer', 'Developer']) expect(data.agents[current], current).toBeDefined();
|
|
143
|
+
// The team's own agent, and its own skill, stay as they were.
|
|
144
|
+
expect(data.agents['Our Release Bot']).toEqual({ slots: ['deployment'], directSkills: ['our-runbook'] });
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('changes nothing the second time', () => {
|
|
148
|
+
const once = updateSkillMatrixContent(JSON.stringify(old()), none);
|
|
149
|
+
expect(updateSkillMatrixContent(once, none)).toBe(once);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('retires no skill that ships today', () => {
|
|
153
|
+
const shipped = new Set([
|
|
154
|
+
...readdirSync(resolve(import.meta.dirname, '..', 'orchestrator', 'skills')),
|
|
155
|
+
...Object.values(PLUGINS).map((p) => p.skillName).filter(Boolean),
|
|
156
|
+
]);
|
|
157
|
+
expect([...RETIRED_SKILLS].filter((s) => shipped.has(s))).toEqual([]);
|
|
158
|
+
const matrix = JSON.parse(readFileSync(resolve(import.meta.dirname, '..', 'orchestrator', 'customizations', 'agents', 'skill-matrix.json'), 'utf8')) as SkillMatrixData;
|
|
159
|
+
for (const now of Object.values(RETIRED_AGENTS)) if (now) expect(matrix.agents[now], now).toBeDefined();
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* VS Code starts a server with the `envFile` its entry names. A project that
|
|
165
|
+
* keeps each server's secrets in its own file was told they were not set.
|
|
166
|
+
*/
|
|
167
|
+
describe('envFileTextFor', () => {
|
|
168
|
+
let dir = '';
|
|
169
|
+
afterEach(() => rmSync(dir, { recursive: true, force: true }));
|
|
170
|
+
|
|
171
|
+
it('reads .env and the env file a server’s VS Code entry names', () => {
|
|
172
|
+
dir = mkdtempSync(join(tmpdir(), 'oc-envfile-'));
|
|
173
|
+
mkdirSync(join(dir, '.vscode'));
|
|
174
|
+
mkdirSync(join(dir, '.env.d'));
|
|
175
|
+
writeFileSync(join(dir, '.env'), 'SHARED_TOKEN=a\n');
|
|
176
|
+
writeFileSync(join(dir, '.env.d', 'mcp-resend.env'), 'OC_TEST_RESEND_KEY=re_x\n');
|
|
177
|
+
writeFileSync(join(dir, '.vscode', 'mcp.json'), JSON.stringify({
|
|
178
|
+
servers: { Resend: { type: 'stdio', command: 'npx', args: ['-y', 'resend-mcp@2.24.0'], envFile: '${workspaceFolder}/.env.d/mcp-resend.env' } },
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
expect(isEnvVarSatisfied('OC_TEST_RESEND_KEY', envFileTextFor(dir, 'Resend'))).toBe(true);
|
|
182
|
+
expect(isEnvVarSatisfied('SHARED_TOKEN', envFileTextFor(dir, 'Resend'))).toBe(true);
|
|
183
|
+
// Another server does not read Resend's file.
|
|
184
|
+
expect(isEnvVarSatisfied('OC_TEST_RESEND_KEY', envFileTextFor(dir, 'Linear'))).toBe(false);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it('reads .env alone when there is no VS Code config', () => {
|
|
188
|
+
dir = mkdtempSync(join(tmpdir(), 'oc-envfile-'));
|
|
189
|
+
writeFileSync(join(dir, '.env'), 'SHARED_TOKEN=a\n');
|
|
190
|
+
expect(isEnvVarSatisfied('SHARED_TOKEN', envFileTextFor(dir, 'Resend'))).toBe(true);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
73
194
|
describe('what a Python or Go project is given', () => {
|
|
74
195
|
const browser = { preselected: true, subCategory: 'e2e-testing' };
|
|
75
196
|
|