Add shared port registry workflow and improve scaffold tooling

This commit is contained in:
2026-05-19 21:22:34 -04:00
parent 107f8a2691
commit 3b668c9ced
33 changed files with 2235 additions and 2 deletions

View File

@@ -205,6 +205,16 @@ function parseJsonc(input, label) {
}
function parseJsoncAst(input, label) {
if (!input.trim()) {
return {
type: "object",
start: 0,
end: 0,
properties: [],
value: {},
};
}
let index = 0;
function fail(message) {
@@ -780,9 +790,10 @@ function main() {
const allManagedServerNames = new Set(Object.keys(managedConfig[options.serverKey]));
const desiredServerNames = new Set(Object.keys(managedServers));
const targetText = fs.existsSync(options.target)
const existingTargetText = fs.existsSync(options.target)
? fs.readFileSync(options.target, "utf8")
: "{}\n";
: "";
const targetText = existingTargetText.trim() ? existingTargetText : "{}\n";
const targetAst = parseJsoncAst(targetText, options.target);
const cleanedTargetText = removeStaleManagedServers(
targetText,

View File

@@ -203,6 +203,25 @@ test("preserves comments and custom servers while pruning stale managed MCP entr
assert.equal(parsed.servers.gitea, undefined);
});
test("creates managed MCP config from an empty target file", () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilot-mcp-"));
const targetFile = path.join(tempDir, "mcp.json");
fs.writeFileSync(targetFile, "", "utf8");
const result = runMerge({
targetFile,
templateFile: vscodeTemplateFile,
serverKey: "servers",
});
assert.equal(result.status, 0, result.stderr);
const output = fs.readFileSync(targetFile, "utf8");
const parsed = parseJsonc(output);
assert.equal(parsed.servers.playwright.command, "npx");
assert.equal(parsed.servers.filesystem.command, "docker");
});
test("renders optional Gitea config when local overrides are complete", () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "copilot-mcp-"));
const targetFile = path.join(tempDir, "mcp-config.json");

View File

@@ -58,7 +58,10 @@ Assert-Path -Label 'hooks link' -Path (Join-Path $CopilotHome 'hooks')
Assert-Path -Label 'session start hook' -Path (Join-Path $CanonicalHome 'resources\hooks\session-audit.json')
Assert-Path -Label 'session start hook script' -Path (Join-Path $CanonicalHome 'resources\scripts\report-hook-event.sh')
Assert-ReadableFile -Label 'session start hook script' -Path (Join-Path $CanonicalHome 'resources\scripts\report-hook-event.sh')
Assert-Path -Label 'port registry updater script' -Path (Join-Path $CanonicalHome 'resources\scripts\update-port-registry.mjs')
Assert-ReadableFile -Label 'port registry updater script' -Path (Join-Path $CanonicalHome 'resources\scripts\update-port-registry.mjs')
Assert-Command -Label 'session start hook shell' -CommandName 'bash'
Assert-Command -Label 'port registry updater runtime' -CommandName 'node'
Assert-Path -Label 'prompts link' -Path (Join-Path $VscodeUserDir 'prompts')
Assert-Path -Label 'VS Code MCP config' -Path (Join-Path $VscodeUserDir 'mcp.json')
Assert-Path -Label 'Copilot CLI MCP config' -Path (Join-Path $CopilotHome 'mcp-config.json')

View File

@@ -75,6 +75,7 @@ main() {
local local_mcp_overrides_file="$canonical_home/.local/mcp.local.jsonc"
local session_start_hook_file="$canonical_home/resources/hooks/session-audit.json"
local session_start_hook_script="$canonical_home/resources/scripts/report-hook-event.sh"
local port_registry_script="$canonical_home/resources/scripts/update-port-registry.mjs"
check_path "repo root" "$repo_root"
check_path "canonical home" "$canonical_home"
@@ -85,7 +86,10 @@ main() {
check_path "session start hook" "$session_start_hook_file"
check_path "session start hook script" "$session_start_hook_script"
check_readable_file "session start hook script" "$session_start_hook_script"
check_path "port registry updater script" "$port_registry_script"
check_readable_file "port registry updater script" "$port_registry_script"
check_command "session start hook shell" "bash"
check_command "port registry updater runtime" "node"
check_path "prompts link" "$vscode_user_dir/prompts"
check_path "VS Code MCP config" "$vscode_mcp_file"
check_path "Copilot CLI MCP config" "$copilot_cli_mcp_file"