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/stack-config.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { resolve, relative } from 'node:path';
|
|
1
|
+
import { dirname, resolve, relative } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
2
3
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
3
|
-
import { existsSync } from 'node:fs';
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
5
|
import type { TechTool, TeamTool, StackConfig, CopyDirOptions, RepoInfo } from './types.js';
|
|
5
6
|
import { isLegacyStack, migrateStackConfig, UnreadableConfigError } from './types.js';
|
|
6
7
|
import {
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
getSelectedSkillNames,
|
|
14
15
|
} from '../orchestrator/plugins/index.js';
|
|
15
16
|
import type {} from '../orchestrator/plugins/types.js';
|
|
17
|
+
import { parseMcpConfigText } from './mcp-file.js';
|
|
16
18
|
|
|
17
19
|
// ── Tool registries (derived from plugins) ────────────────────
|
|
18
20
|
|
|
@@ -105,6 +107,33 @@ export function isEnvVarSatisfied(envVar: string, envFileContents: string): bool
|
|
|
105
107
|
return false
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
/**
|
|
111
|
+
* The env files a server reads, as one text: the project's `.env`, and the
|
|
112
|
+
* `envFile` its VS Code entry names.
|
|
113
|
+
*
|
|
114
|
+
* A team that keeps each server's secrets apart — `.env.d/mcp-resend.env` —
|
|
115
|
+
* was told by `doctor`, `explain` and `sync` that the key was not set, because
|
|
116
|
+
* they read only `.env`, while VS Code started the server with it.
|
|
117
|
+
*/
|
|
118
|
+
export function envFileTextFor(projectRoot: string, server: string): string {
|
|
119
|
+
const read = (rel: string): string => {
|
|
120
|
+
try {
|
|
121
|
+
return readFileSync(resolve(projectRoot, rel), 'utf8')
|
|
122
|
+
} catch {
|
|
123
|
+
return ''
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let named = ''
|
|
127
|
+
try {
|
|
128
|
+
const config = parseMcpConfigText(read('.vscode/mcp.json'), '.vscode/mcp.json') as { servers?: Record<string, { envFile?: unknown }> }
|
|
129
|
+
const envFile = config.servers?.[server]?.envFile
|
|
130
|
+
if (typeof envFile === 'string' && envFile.startsWith('${workspaceFolder}')) named = read(`.${envFile.slice('${workspaceFolder}'.length)}`)
|
|
131
|
+
} catch {
|
|
132
|
+
// No VS Code config, or one with comments: `.env` is still read.
|
|
133
|
+
}
|
|
134
|
+
return `${read('.env')}\n${named}`
|
|
135
|
+
}
|
|
136
|
+
|
|
108
137
|
export function resolveStack(manifest: {
|
|
109
138
|
ide?: string
|
|
110
139
|
ides?: string[]
|
|
@@ -233,7 +262,23 @@ export function getIncludedMcpServers(stack: StackConfig, repoInfo?: RepoInfo):
|
|
|
233
262
|
*/
|
|
234
263
|
export function getRequiredMcpEnvVars(stack: StackConfig, repoInfo?: RepoInfo): McpEnvRequirement[] {
|
|
235
264
|
const included = getIncludedMcpServers(stack, repoInfo);
|
|
236
|
-
return MCP_ENV_REQUIREMENTS.filter((req) => included.has(req.server));
|
|
265
|
+
return MCP_ENV_REQUIREMENTS.filter((req) => included.has(req.server) && needsToken(req.server, stack));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Targets that sign in to a server with OAuth, by server key. A project that
|
|
270
|
+
* compiles only for those never sends the token, and asking for it in `.env`
|
|
271
|
+
* and in `doctor` would be asking for a secret nothing reads.
|
|
272
|
+
*/
|
|
273
|
+
const OAUTH_TARGETS = new Map(
|
|
274
|
+
Object.values(PLUGINS)
|
|
275
|
+
.filter((p) => p.mcpServerKey && p.tokenAuth)
|
|
276
|
+
.map((p) => [p.mcpServerKey!, p.tokenAuth!.oauthTargets as string[]]),
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
function needsToken(server: string, stack: StackConfig): boolean {
|
|
280
|
+
const oauth = OAUTH_TARGETS.get(server);
|
|
281
|
+
return !oauth || stack.ides.length === 0 || stack.ides.some((ide) => !oauth.includes(ide));
|
|
237
282
|
}
|
|
238
283
|
|
|
239
284
|
// ── Customization file transforms ─────────────────────────────
|
|
@@ -351,6 +396,7 @@ const SUBCATEGORY_TO_SLOT: Record<string, string> = {
|
|
|
351
396
|
'codebase-tool': 'codebase-tool',
|
|
352
397
|
'task-management': 'task-management',
|
|
353
398
|
'knowledge-management': 'knowledge-management',
|
|
399
|
+
'source-control': 'source-control',
|
|
354
400
|
testing: 'testing',
|
|
355
401
|
'e2e-testing': 'e2e-testing',
|
|
356
402
|
design: 'design',
|
|
@@ -410,6 +456,75 @@ const PLUGIN_SKILL_NAMES = new Set(
|
|
|
410
456
|
.filter((s): s is string => Boolean(s)),
|
|
411
457
|
);
|
|
412
458
|
|
|
459
|
+
/**
|
|
460
|
+
* The matrix this package ships, read once: where a slot a release adds is
|
|
461
|
+
* described and which agents it belongs to.
|
|
462
|
+
*/
|
|
463
|
+
let shipped: SkillMatrixData | null | undefined;
|
|
464
|
+
function shippedMatrix(): SkillMatrixData | null {
|
|
465
|
+
if (shipped === undefined) {
|
|
466
|
+
const file = resolve(dirname(fileURLToPath(import.meta.url)), '..', '..', 'src', 'orchestrator', 'customizations', 'agents', 'skill-matrix.json');
|
|
467
|
+
try {
|
|
468
|
+
shipped = JSON.parse(readFileSync(file, 'utf8')) as SkillMatrixData;
|
|
469
|
+
} catch {
|
|
470
|
+
shipped = null;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return shipped;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Agents a release merged into another, under the names older matrices still
|
|
478
|
+
* hold them by: the 19 agents became 13, and the Team Lead took its suffix
|
|
479
|
+
* before that. Session Guard went with the logging regime it policed.
|
|
480
|
+
*/
|
|
481
|
+
export const RETIRED_AGENTS: Readonly<Record<string, string | null>> = {
|
|
482
|
+
'Team Lead': 'Team Lead (OpenCastle)',
|
|
483
|
+
Copywriter: 'Writer',
|
|
484
|
+
'SEO Specialist': 'Writer',
|
|
485
|
+
'Documentation Writer': 'Writer',
|
|
486
|
+
'API Designer': 'Developer',
|
|
487
|
+
'DevOps Expert': 'DevOps & Release',
|
|
488
|
+
'Release Manager': 'DevOps & Release',
|
|
489
|
+
'Data Expert': 'Data Engineer',
|
|
490
|
+
'Database Engineer': 'Data Engineer',
|
|
491
|
+
'Session Guard': null,
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
/** Skills a release removed with nothing of the same name after it. An agent told to load one finds nothing. */
|
|
495
|
+
export const RETIRED_SKILLS: ReadonlySet<string> = new Set([
|
|
496
|
+
'agent-hooks', 'agent-memory', 'backbone-scaffolding', 'code-commenting', 'context-map', 'decomposition',
|
|
497
|
+
'documentation-standards', 'memory-merger', 'nextjs-patterns', 'observability-logging', 'orchestration-protocols',
|
|
498
|
+
'performance-optimization', 'project-consistency', 'react-development', 'session-checkpoints', 'task-management',
|
|
499
|
+
'team-lead-reference',
|
|
500
|
+
]);
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Bring a matrix's agents to the current roster.
|
|
504
|
+
*
|
|
505
|
+
* The matrix is the project's, so a merge of agents never reached one written
|
|
506
|
+
* before it: every such project kept eight agents that no longer exist, and
|
|
507
|
+
* the three that replaced them — Data Engineer, DevOps & Release, Writer —
|
|
508
|
+
* had no entry and resolved no skills. A retired agent's slots and skills move
|
|
509
|
+
* to its successor; a current agent the matrix lacks gets the shipped entry;
|
|
510
|
+
* a skill that no longer exists is dropped. Agents the team added are theirs.
|
|
511
|
+
*/
|
|
512
|
+
function migrateAgents(data: SkillMatrixData, template: SkillMatrixData | null): void {
|
|
513
|
+
const agents = (data.agents ??= {});
|
|
514
|
+
const fresh = (name: string) => structuredClone(template?.agents[name] ?? { slots: [], directSkills: [] });
|
|
515
|
+
for (const [old, now] of Object.entries(RETIRED_AGENTS)) {
|
|
516
|
+
const was = agents[old];
|
|
517
|
+
if (!was) continue;
|
|
518
|
+
delete agents[old];
|
|
519
|
+
if (!now) continue;
|
|
520
|
+
const into = (agents[now] ??= fresh(now));
|
|
521
|
+
for (const slot of was.slots ?? []) if (!into.slots.includes(slot)) into.slots.push(slot);
|
|
522
|
+
for (const skill of was.directSkills ?? []) if (!into.directSkills.includes(skill)) into.directSkills.push(skill);
|
|
523
|
+
}
|
|
524
|
+
for (const name of Object.keys(template?.agents ?? {})) agents[name] ??= fresh(name);
|
|
525
|
+
for (const agent of Object.values(agents)) agent.directSkills = (agent.directSkills ?? []).filter((s) => !RETIRED_SKILLS.has(s));
|
|
526
|
+
}
|
|
527
|
+
|
|
413
528
|
export function updateSkillMatrixContent(content: string, stack: StackConfig): string {
|
|
414
529
|
let data: SkillMatrixData;
|
|
415
530
|
try {
|
|
@@ -420,6 +535,8 @@ export function updateSkillMatrixContent(content: string, stack: StackConfig): s
|
|
|
420
535
|
throw new UnreadableConfigError('.opencastle/agents/skill-matrix.json');
|
|
421
536
|
}
|
|
422
537
|
const allTools = [...stack.techTools, ...stack.teamTools] as string[];
|
|
538
|
+
const template = shippedMatrix();
|
|
539
|
+
migrateAgents(data, template);
|
|
423
540
|
|
|
424
541
|
for (const [subCategory, slotName] of Object.entries(SUBCATEGORY_TO_SLOT)) {
|
|
425
542
|
// Find ALL selected tools matching this subcategory (not just the first)
|
|
@@ -436,6 +553,20 @@ export function updateSkillMatrixContent(content: string, stack: StackConfig): s
|
|
|
436
553
|
})
|
|
437
554
|
.filter((e): e is SkillMatrixEntry => e !== null);
|
|
438
555
|
|
|
556
|
+
// A slot a release added — `source-control`, for GitHub and GitLab — is in
|
|
557
|
+
// no matrix written before it, and the matrix is the project's, so nothing
|
|
558
|
+
// else adds it: the integration's skill reached no agent. Once a selected
|
|
559
|
+
// integration fills it, add it with the agents the shipped matrix gives it
|
|
560
|
+
// to. Only then: from there the slot exists, and what the team does with
|
|
561
|
+
// it is theirs.
|
|
562
|
+
if (!data.bindings[slotName] && entries.length > 0 && template?.bindings[slotName]) {
|
|
563
|
+
data.bindings[slotName] = { entries: [], description: template.bindings[slotName].description };
|
|
564
|
+
for (const [agent, { slots }] of Object.entries(template.agents)) {
|
|
565
|
+
const theirs = data.agents?.[agent];
|
|
566
|
+
if (slots.includes(slotName) && theirs && !theirs.slots.includes(slotName)) theirs.slots.push(slotName);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
439
570
|
if (data.bindings[slotName]) {
|
|
440
571
|
// Merge, not replace. `skill-matrix.md` told users "to switch tech, update
|
|
441
572
|
// only the binding entries", and this ran on every sync, so the edit the
|
|
@@ -14,6 +14,8 @@ import { buildCheckReport } from './sync-check.js'
|
|
|
14
14
|
import { IDE_ADAPTERS } from './adapters/index.js'
|
|
15
15
|
import { writeManifest as writeManifestOnly } from './manifest.js'
|
|
16
16
|
import { recordLockFor } from './lock.js'
|
|
17
|
+
import { renderLesson } from './lessons.js'
|
|
18
|
+
import { refreshLessons } from './lessons-rules.js'
|
|
17
19
|
import type { Manifest } from './types.js'
|
|
18
20
|
|
|
19
21
|
/** A compile writes the manifest and the lock; tests that compile by hand do both. */
|
|
@@ -65,6 +67,33 @@ describe('drift detection', () => {
|
|
|
65
67
|
expect(report.checked).toBeGreaterThan(0)
|
|
66
68
|
})
|
|
67
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The fresh compile runs in an empty directory, which has no lessons, so its
|
|
72
|
+
* lessons rule says "No lessons yet". Every project with a lesson was told its
|
|
73
|
+
* rule differed from that, after every `sync`: a drift no command could clear.
|
|
74
|
+
*/
|
|
75
|
+
it('holds the lessons rule to the lessons, not to a compile that has none', async () => {
|
|
76
|
+
mkdirSync(join(projectRoot, '.opencastle', 'lessons'), { recursive: true })
|
|
77
|
+
writeFileSync(
|
|
78
|
+
join(projectRoot, '.opencastle', 'lessons', '2026-10-07-quote-paths.md'),
|
|
79
|
+
renderLesson({
|
|
80
|
+
id: '2026-10-07-quote-paths', title: 'Quote paths with spaces', category: 'terminal', severity: 'medium',
|
|
81
|
+
added: '2026-10-07', citations: [], status: 'active', body: 'Unquoted paths break.',
|
|
82
|
+
}),
|
|
83
|
+
)
|
|
84
|
+
await install()
|
|
85
|
+
refreshLessons(join(projectRoot, '.opencastle'))
|
|
86
|
+
const rule = join(projectRoot, '.github', 'instructions', 'opencastle-lessons.instructions.md')
|
|
87
|
+
expect(readFileSync(rule, 'utf8')).toContain('Quote paths with spaces')
|
|
88
|
+
|
|
89
|
+
expect((await buildCheckReport(pkgRoot, projectRoot)).drift).toEqual([])
|
|
90
|
+
|
|
91
|
+
// Still held to the lessons: an edit by hand is drift, once, and `sync` clears it.
|
|
92
|
+
appendFileSync(rule, '- a lesson nobody wrote\n')
|
|
93
|
+
const drift = (await buildCheckReport(pkgRoot, projectRoot)).drift.filter((d) => d.path.endsWith('opencastle-lessons.instructions.md'))
|
|
94
|
+
expect(drift.map((d) => d.kind)).toEqual(['outdated'])
|
|
95
|
+
})
|
|
96
|
+
|
|
68
97
|
it('catches a generated file edited in place', async () => {
|
|
69
98
|
await install()
|
|
70
99
|
const target = join(projectRoot, '.github', 'agents', 'developer.agent.md')
|
package/src/cli/sync-check.ts
CHANGED
|
@@ -183,6 +183,11 @@ function comparePath(
|
|
|
183
183
|
const f = join(fresh, rel)
|
|
184
184
|
const a = join(actual, rel)
|
|
185
185
|
const shown = `${managedPath.replace(/\/$/, '')}/${rel}`
|
|
186
|
+
// The compile runs in an empty directory with no lessons, so its lessons
|
|
187
|
+
// rule says there are none. The rule is held to the project's lessons
|
|
188
|
+
// below, like the index; compared here, every project with a lesson
|
|
189
|
+
// drifted after every sync.
|
|
190
|
+
if (isLessonRule(shown)) continue
|
|
186
191
|
checked++
|
|
187
192
|
if (!existsSync(a)) {
|
|
188
193
|
drift.push({ ide, path: shown, kind: 'missing' })
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join, resolve } from 'node:path'
|
|
4
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
|
|
5
|
+
import { checkReferences, teamStateFor } from './team-health.js'
|
|
6
|
+
import type { Manifest } from './types.js'
|
|
7
|
+
|
|
8
|
+
const pkgRoot = resolve(import.meta.dirname, '..', '..')
|
|
9
|
+
const manifest: Manifest = {
|
|
10
|
+
version: '1.0.0',
|
|
11
|
+
ide: 'vscode',
|
|
12
|
+
ides: ['vscode'],
|
|
13
|
+
installedAt: '2026-10-09T00:00:00.000Z',
|
|
14
|
+
updatedAt: '2026-10-09T00:00:00.000Z',
|
|
15
|
+
stack: { ides: ['vscode'], techTools: [], teamTools: [] },
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A Convex project has a `convex/` directory and imports `convex/react`. The
|
|
20
|
+
* check read the import as a path into that directory and told the team its
|
|
21
|
+
* instructions named a file that does not exist.
|
|
22
|
+
*/
|
|
23
|
+
describe('team instructions match this repository', () => {
|
|
24
|
+
let dir: string
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
dir = mkdtempSync(join(tmpdir(), 'oc-team-health-'))
|
|
28
|
+
mkdirSync(join(dir, 'convex'))
|
|
29
|
+
mkdirSync(join(dir, '.opencastle'))
|
|
30
|
+
writeFileSync(join(dir, 'convex', 'schema.ts'), 'export default {}\n')
|
|
31
|
+
writeFileSync(join(dir, 'package.json'), JSON.stringify({ name: 'app', dependencies: { convex: '^1.46.0' } }))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
rmSync(dir, { recursive: true, force: true })
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const check = (instructions: string): string => {
|
|
39
|
+
writeFileSync(join(dir, '.opencastle', 'project.instructions.md'), instructions)
|
|
40
|
+
return checkReferences(teamStateFor(pkgRoot, dir, manifest), dir).detail ?? ''
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
it('reads a dependency and an extensionless subpath as an import, not a path', () => {
|
|
44
|
+
expect(check('# Project\n\nData access is typed hooks over `convex/react`; the schema is `convex/schema.ts`.\n'))
|
|
45
|
+
.toBe('every script and path the team content names exists')
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('still names a file under that directory that is gone', () => {
|
|
49
|
+
expect(check('# Project\n\nThe old resolvers are in `convex/legacy.ts`.\n')).toContain('`convex/legacy.ts`, which does not exist')
|
|
50
|
+
})
|
|
51
|
+
})
|
package/src/cli/team-health.ts
CHANGED
|
@@ -155,8 +155,13 @@ const PATH_SPAN = /`([A-Za-z0-9_.@-][A-Za-z0-9_.@/-]*\/[A-Za-z0-9_.@/-]*[A-Za-z0
|
|
|
155
155
|
*/
|
|
156
156
|
export function checkReferences(state: TeamState, projectRoot: string): HealthResult {
|
|
157
157
|
let scripts: Record<string, string> | null = null
|
|
158
|
+
const dependencies = new Set<string>()
|
|
158
159
|
try {
|
|
159
|
-
|
|
160
|
+
const pkg = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8')) as Record<string, Record<string, string> | undefined>
|
|
161
|
+
scripts = pkg.scripts ?? {}
|
|
162
|
+
for (const field of ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']) {
|
|
163
|
+
for (const name of Object.keys(pkg[field] ?? {})) dependencies.add(name)
|
|
164
|
+
}
|
|
160
165
|
} catch {
|
|
161
166
|
scripts = null
|
|
162
167
|
}
|
|
@@ -189,7 +194,11 @@ export function checkReferences(state: TeamState, projectRoot: string): HealthRe
|
|
|
189
194
|
// a reference.
|
|
190
195
|
const top = resolve(projectRoot, first)
|
|
191
196
|
if (!existsSync(top) || !statSync(top).isDirectory()) continue
|
|
192
|
-
if (
|
|
197
|
+
if (existsSync(resolve(projectRoot, path))) continue
|
|
198
|
+
// A dependency's name and a subpath with no extension is an import —
|
|
199
|
+
// `convex/react` beside a Convex project's own `convex/` directory.
|
|
200
|
+
if (dependencies.has(first) && !/\.[A-Za-z0-9]+$/.test(path)) continue
|
|
201
|
+
dead.push(`${ref} names \`${path}\`, which does not exist`)
|
|
193
202
|
}
|
|
194
203
|
}
|
|
195
204
|
}
|
package/src/cli/types.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { CompileSource } from './layers.js';
|
|
|
5
5
|
|
|
6
6
|
export type IdeChoice = 'vscode' | 'cursor' | 'claude-code' | 'opencode' | 'windsurf' | 'codex' | 'antigravity';
|
|
7
7
|
export type TechTool = 'sanity' | 'contentful' | 'strapi' | 'supabase' | 'convex' | 'vercel' | 'nx' | 'chrome-devtools' | 'nextjs' | 'astro' | 'netlify' | 'turborepo' | 'prisma' | 'cypress' | 'playwright' | 'vitest' | 'figma' | 'resend' | 'stripe' | 'sentry' | 'drizzle' | 'cloudflare' | 'coolify' | 'expo' | 'hetzner';
|
|
8
|
-
export type TeamTool = 'linear' | 'jira' | 'trello' | 'notion' | 'slack' | 'teams';
|
|
8
|
+
export type TeamTool = 'linear' | 'jira' | 'trello' | 'notion' | 'slack' | 'teams' | 'github' | 'gitlab';
|
|
9
9
|
|
|
10
10
|
export interface StackConfig {
|
|
11
11
|
ides: IdeChoice[];
|
|
@@ -134,6 +134,8 @@ export interface RepoInfo {
|
|
|
134
134
|
pm?: string[];
|
|
135
135
|
notifications?: string[];
|
|
136
136
|
services?: string[];
|
|
137
|
+
/** Where the repository is hosted, `github` or `gitlab`: from its remotes, package metadata and files only a host reads. */
|
|
138
|
+
codeHosts?: string[];
|
|
137
139
|
mcpConfig?: boolean;
|
|
138
140
|
configFiles?: string[];
|
|
139
141
|
}
|
package/src/cli/update.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
updateSkillMatrixFile,
|
|
12
12
|
resolveStack,
|
|
13
13
|
getCustomizationsTransform,
|
|
14
|
-
isEnvVarSatisfied, isPreselected } from './stack-config.js'
|
|
14
|
+
isEnvVarSatisfied, isPreselected, envFileTextFor } from './stack-config.js'
|
|
15
15
|
import { rebuildMcpConfig, getMcpConfigRelPath, retireLegacyMcpConfig, LEGACY_MCP_CONFIGS } from './mcp.js'
|
|
16
16
|
import { updateGitignore, LOCAL_DIRS } from './gitignore.js'
|
|
17
17
|
import { resolveManagedPaths, REQUIRED_CUSTOMIZATIONS } from './managed-paths.js'
|
|
@@ -403,7 +403,7 @@ export default async function update({
|
|
|
403
403
|
value: p.id,
|
|
404
404
|
selected: oldStack
|
|
405
405
|
? currentTeam.has(p.id as TeamTool)
|
|
406
|
-
: isPreselected(p, repoInfo),
|
|
406
|
+
: isPreselected(p, repoInfo) || detectedTools.has(p.id),
|
|
407
407
|
}))
|
|
408
408
|
)
|
|
409
409
|
|
|
@@ -959,8 +959,7 @@ export default async function update({
|
|
|
959
959
|
// gate, so `opencastle add sentry` never mentioned the token it now needs.
|
|
960
960
|
if (newStack) {
|
|
961
961
|
const envVars = requiredEnvVars(resolved, newStack, repoInfo)
|
|
962
|
-
const
|
|
963
|
-
const missing = envVars.filter(({ envVar }) => !isEnvVarSatisfied(envVar, envFile))
|
|
962
|
+
const missing = envVars.filter(({ envVar, server }) => !isEnvVarSatisfied(envVar, envFileTextFor(projectRoot, server)))
|
|
964
963
|
if (missing.length > 0) {
|
|
965
964
|
console.log(`\n ${c.yellow('⚠')} Environment variables still needed:\n`)
|
|
966
965
|
for (const { envVar, hint } of missing) {
|
|
@@ -79,6 +79,10 @@
|
|
|
79
79
|
"notifications": {
|
|
80
80
|
"entries": [],
|
|
81
81
|
"description": "Team messaging, alerts, bot integrations, channel management"
|
|
82
|
+
},
|
|
83
|
+
"source-control": {
|
|
84
|
+
"entries": [],
|
|
85
|
+
"description": "Pull and merge requests, code review, repository issues, CI status"
|
|
82
86
|
}
|
|
83
87
|
},
|
|
84
88
|
"agents": {
|
|
@@ -180,6 +184,7 @@
|
|
|
180
184
|
"slots": [
|
|
181
185
|
"deployment",
|
|
182
186
|
"observability",
|
|
187
|
+
"source-control",
|
|
183
188
|
"codebase-tool"
|
|
184
189
|
],
|
|
185
190
|
"directSkills": [
|
|
@@ -198,7 +203,8 @@
|
|
|
198
203
|
"Team Lead (OpenCastle)": {
|
|
199
204
|
"slots": [
|
|
200
205
|
"task-management",
|
|
201
|
-
"knowledge-management"
|
|
206
|
+
"knowledge-management",
|
|
207
|
+
"source-control"
|
|
202
208
|
],
|
|
203
209
|
"directSkills": [
|
|
204
210
|
"validation-gates",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PluginConfig } from '../types.js';
|
|
2
|
+
|
|
3
|
+
export const config: PluginConfig = {
|
|
4
|
+
id: 'github',
|
|
5
|
+
name: 'GitHub',
|
|
6
|
+
category: 'team',
|
|
7
|
+
subCategory: 'source-control',
|
|
8
|
+
label: 'GitHub',
|
|
9
|
+
hint: 'Pull requests, reviews, CI and stacked PRs via GitHub\'s MCP server',
|
|
10
|
+
skillName: 'github-platform',
|
|
11
|
+
mcpServerKey: 'GitHub',
|
|
12
|
+
// GitHub's own remote server. VS Code signs in to it with OAuth; GitHub
|
|
13
|
+
// supports no other client's OAuth, so every other target sends a token.
|
|
14
|
+
mcpConfig: {
|
|
15
|
+
type: 'http',
|
|
16
|
+
url: 'https://api.githubcopilot.com/mcp/',
|
|
17
|
+
},
|
|
18
|
+
tokenAuth: {
|
|
19
|
+
oauthTargets: ['vscode'],
|
|
20
|
+
headers: { Authorization: 'Bearer ${GITHUB_PERSONAL_ACCESS_TOKEN}' },
|
|
21
|
+
},
|
|
22
|
+
authType: 'env-token',
|
|
23
|
+
envVars: [
|
|
24
|
+
{
|
|
25
|
+
name: 'GITHUB_PERSONAL_ACCESS_TOKEN',
|
|
26
|
+
hint: 'Create at github.com → Settings → Developer settings → Personal access tokens (VS Code signs in with OAuth instead)',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
// The whole server: GitHub adds and renames tools between releases, and a
|
|
30
|
+
// named tool that does not exist is silently absent.
|
|
31
|
+
agentToolMap: {
|
|
32
|
+
'team-lead': ['GitHub/*'],
|
|
33
|
+
'devops-expert': ['GitHub/*'],
|
|
34
|
+
},
|
|
35
|
+
docsUrl: 'https://www.opencastle.dev/docs/plugins#github',
|
|
36
|
+
officialDocs: 'https://github.com/github/github-mcp-server',
|
|
37
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "github",
|
|
4
|
+
"description": "GitHub skill and MCP server for AI coding assistants: Pull requests, reviews, CI and stacked PRs via GitHub's MCP server.",
|
|
5
|
+
"homepage": "https://www.opencastle.dev/docs/plugins#github",
|
|
6
|
+
"repository": "https://github.com/monkilabs/opencastle",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"team",
|
|
10
|
+
"source-control"
|
|
11
|
+
],
|
|
12
|
+
"extensions": {
|
|
13
|
+
"dev.opencastle": {
|
|
14
|
+
"label": "GitHub",
|
|
15
|
+
"category": "team",
|
|
16
|
+
"subCategory": "source-control",
|
|
17
|
+
"authType": "env-token",
|
|
18
|
+
"env": [
|
|
19
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN"
|
|
20
|
+
],
|
|
21
|
+
"officialDocs": "https://github.com/github/github-mcp-server"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-platform
|
|
3
|
+
description: "GitHub pull requests, review threads, failing Actions checks and stacked pull requests, through GitHub's MCP server and the gh CLI. Use when opening, reviewing or updating a pull request, fixing a failed check, or splitting a change into a stack."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub Platform
|
|
7
|
+
|
|
8
|
+
Branch, commit and pull request conventions: the **git-workflow** skill. Docs: https://docs.github.com/en/pull-requests
|
|
9
|
+
|
|
10
|
+
## The MCP server
|
|
11
|
+
|
|
12
|
+
GitHub's own remote server, `https://api.githubcopilot.com/mcp/`. VS Code signs in with OAuth. Every other assistant sends `GITHUB_PERSONAL_ACCESS_TOKEN`, so the server acts as that token's user — call `get_me` first to know whose name every comment will carry. Tool names change between releases: read the tool list the server offers instead of assuming a name.
|
|
13
|
+
|
|
14
|
+
- **Toolsets.** On by default: `context`, `repos`, `issues`, `pull_requests`, `users`. An `X-MCP-Toolsets` header on the server entry turns on more (`actions` for CI logs), and `X-MCP-Readonly: true` drops every write tool.
|
|
15
|
+
- **Token.** Fine-grained and limited to the repositories the agents work in: **Contents**, **Pull requests** and **Issues** read and write, **Metadata** and **Actions** read. A 404 on a repository you know exists is the token: its repository list, or an organization that has not approved it.
|
|
16
|
+
- **`gh` covers the rest:** review threads, job logs and stacks, below. It signs in on its own (`gh auth status`).
|
|
17
|
+
|
|
18
|
+
## Gotchas
|
|
19
|
+
|
|
20
|
+
- **A review is pending until submitted.** Comments added to a pending review are invisible to everyone else, and a session that ends before the submit leaves them unsent.
|
|
21
|
+
- **Why a PR cannot merge:** `gh pr view 42 --json mergeStateStatus`. `BEHIND` needs a rebase onto its base, `DIRTY` has conflicts, `BLOCKED` lacks a required review or check, `UNSTABLE` has a non-required check failing.
|
|
22
|
+
- **A person merges**, as git-workflow says. Stop at a reviewed PR with green checks, though both the server and `gh` offer a merge.
|
|
23
|
+
- Open a draft while work remains (`gh pr create --draft`) and mark it ready when it is done (`gh pr ready 42`). `Closes #123` in the body closes the issue only when the PR merges into the default branch.
|
|
24
|
+
- In a review comment, a ```` ```suggestion ```` block replaces the commented lines when the author applies it. Use it for any fix that fits those lines.
|
|
25
|
+
- Search allows 30 requests a minute. Narrow with `repo:` and `is:open` rather than paging.
|
|
26
|
+
|
|
27
|
+
## Review threads
|
|
28
|
+
|
|
29
|
+
The REST API returns review comments without saying which are resolved. GraphQL says.
|
|
30
|
+
|
|
31
|
+
1. List the threads:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
gh api graphql -F owner='{owner}' -F repo='{repo}' -F pr=42 -f query='
|
|
35
|
+
query($owner: String!, $repo: String!, $pr: Int!) {
|
|
36
|
+
repository(owner: $owner, name: $repo) { pullRequest(number: $pr) {
|
|
37
|
+
reviewThreads(first: 100) { nodes { id isResolved isOutdated path line
|
|
38
|
+
comments(first: 20) { nodes { databaseId author { login } body } } } } } } }'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Fix what each unresolved thread asks, then commit and push. An `isOutdated` thread sits on code that has since changed: check that its point still applies.
|
|
42
|
+
3. Reply in the thread with what changed: `gh api repos/{owner}/{repo}/pulls/42/comments/<databaseId>/replies -f body='Fixed in <sha>: …'`
|
|
43
|
+
4. Resolve it: `gh api graphql -F id=<thread id> -f query='mutation($id: ID!) { resolveReviewThread(input: {threadId: $id}) { thread { isResolved } } }'`
|
|
44
|
+
|
|
45
|
+
Done when step 1 shows every thread you fixed as resolved. A point you disagree with gets a reply and stays open for the reviewer.
|
|
46
|
+
|
|
47
|
+
## Failing checks
|
|
48
|
+
|
|
49
|
+
1. `gh pr checks 42` lists every check on the head commit. `--watch --fail-fast` waits, and stops at the first failure.
|
|
50
|
+
2. Read the failure with `gh run view <run-id> --log-failed`, which prints only the failed steps (the run ID is in the check's link). Start at the first error, not the last line.
|
|
51
|
+
3. Reproduce it with the command the step ran, fix it, and push. Done when `gh pr checks 42` passes on the new head commit.
|
|
52
|
+
4. If your diff cannot explain the failure, run `gh run rerun <run-id> --failed` once. A second failure is real.
|
|
53
|
+
|
|
54
|
+
Causes no log names:
|
|
55
|
+
|
|
56
|
+
- A push made with `GITHUB_TOKEN` inside a workflow starts no other workflow, so a bot's commit gets no checks. Push with a GitHub App token or a personal token when it needs them.
|
|
57
|
+
- A required check whose workflow is skipped by a `paths` filter never reports, and the PR waits for it forever. Run the job and exit early instead.
|
|
58
|
+
- A PR from a fork runs `pull_request` workflows with a read-only token and no secrets. `pull_request_target` has both and runs the base branch's workflow, so checking out the PR's code there runs it with your secrets.
|
|
59
|
+
- Set `permissions:` on each workflow rather than inheriting the repository default, which is read and write on older repositories.
|
|
60
|
+
|
|
61
|
+
## Stacked pull requests
|
|
62
|
+
|
|
63
|
+
A change too big for one review becomes a stack: a chain of layers, each its own PR on the branch below, with the bottom one on trunk (the default branch). Dependencies point down: shared types and schema at the bottom, the code that uses them above. Each PR is held to trunk's required reviews and checks, so every layer builds and passes CI on its own. With agents, one task per layer.
|
|
64
|
+
|
|
65
|
+
The `gh stack` extension does the bookkeeping: `gh extension install github/gh-stack`. Name every branch on the command line, because a bare command opens a prompt.
|
|
66
|
+
|
|
67
|
+
1. `gh stack init feat/search-01-schema`, then commit the first layer.
|
|
68
|
+
2. For each next layer, from the top one: `gh stack add feat/search-02-api`, then commit.
|
|
69
|
+
3. `gh stack push`, then `gh stack submit --auto`. This opens one draft PR per branch, each based on the one below, linked as a stack. Give each its title and body with `gh pr edit <n> --title "…" --body-file <file>`. Done when `gh stack view --json` lists every branch with its PR.
|
|
70
|
+
4. To change a lower layer: `gh stack checkout feat/search-01-schema`, commit, then `gh stack rebase --upstack`, `gh stack push` and `gh stack top`.
|
|
71
|
+
5. After a layer merges, `gh stack sync --prune` rebases what remains onto trunk, pushes, and deletes the merged branches.
|
|
72
|
+
|
|
73
|
+
- Merges go bottom up, and a person does them. Merging a PR merges every layer below it.
|
|
74
|
+
- History stays linear. Rebase rather than merging trunk into a layer, and push with `gh stack push`, which uses `--force-with-lease` per branch.
|
|
75
|
+
- A stack lives in one repository; it cannot span forks.
|
|
76
|
+
- Exit code 3 is a rebase conflict: resolve it, `git add`, then `gh stack rebase --continue`, or `--abort` to restore every branch.
|
|
77
|
+
- Exit code 9 means stacks are not enabled for this repository. Open each PR by hand with `gh pr create --draft --base <branch below>`. After a layer is squash-merged, rebase the next one with `git rebase --onto origin/main <merged branch> <next branch>` so the squashed commits are not replayed.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PluginConfig } from '../types.js';
|
|
2
|
+
|
|
3
|
+
export const config: PluginConfig = {
|
|
4
|
+
id: 'gitlab',
|
|
5
|
+
name: 'GitLab',
|
|
6
|
+
category: 'team',
|
|
7
|
+
subCategory: 'source-control',
|
|
8
|
+
label: 'GitLab',
|
|
9
|
+
hint: 'Merge requests, pipelines and stacked MRs via GitLab\'s MCP server',
|
|
10
|
+
skillName: 'gitlab-platform',
|
|
11
|
+
mcpServerKey: 'GitLab',
|
|
12
|
+
// GitLab's own server, signed in with OAuth — it registers each client
|
|
13
|
+
// itself, so no token in .env. A self-managed instance serves the same
|
|
14
|
+
// path on its own host; edit the URL, and `sync` leaves the entry alone.
|
|
15
|
+
mcpConfig: {
|
|
16
|
+
type: 'http',
|
|
17
|
+
url: 'https://gitlab.com/api/v4/mcp',
|
|
18
|
+
},
|
|
19
|
+
authType: 'oauth',
|
|
20
|
+
envVars: [],
|
|
21
|
+
agentToolMap: {
|
|
22
|
+
'team-lead': ['GitLab/*'],
|
|
23
|
+
'devops-expert': ['GitLab/*'],
|
|
24
|
+
},
|
|
25
|
+
docsUrl: 'https://www.opencastle.dev/docs/plugins#gitlab',
|
|
26
|
+
officialDocs: 'https://docs.gitlab.com/user/model_context_protocol/mcp_server/',
|
|
27
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
|
+
"name": "gitlab",
|
|
4
|
+
"description": "GitLab skill and MCP server for AI coding assistants: Merge requests, pipelines and stacked MRs via GitLab's MCP server.",
|
|
5
|
+
"homepage": "https://www.opencastle.dev/docs/plugins#gitlab",
|
|
6
|
+
"repository": "https://github.com/monkilabs/opencastle",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"team",
|
|
10
|
+
"source-control"
|
|
11
|
+
],
|
|
12
|
+
"extensions": {
|
|
13
|
+
"dev.opencastle": {
|
|
14
|
+
"label": "GitLab",
|
|
15
|
+
"category": "team",
|
|
16
|
+
"subCategory": "source-control",
|
|
17
|
+
"authType": "oauth",
|
|
18
|
+
"officialDocs": "https://docs.gitlab.com/user/model_context_protocol/mcp_server/"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|