* fix(#142): canonicalize runtime aliases across cjs and sdk * fix(#142): satisfy hand-sync and inventory parity gates * test(#1974): remove record-session lock contention in context monitor spec * test(config): retry transient config-ensure-section failures * docs(context): capture PR #143 CI reliability findings * fix(#142): bump CLI Modules inventory headline to 76 (runtime-name-policy + runtime-slash) docs/INVENTORY.md had the two new .cjs rows listed but the headline count stayed at 75; fs count is 76. inventory-counts.test.cjs caught the drift. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
57
get-shit-done/bin/lib/runtime-name-policy.cjs
Normal file
57
get-shit-done/bin/lib/runtime-name-policy.cjs
Normal file
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const FALLBACK_ALIASES = {
|
||||
claude: ['claude', 'claude-code', 'claude-cli'],
|
||||
opencode: ['opencode', 'open-code', 'opencode-cli'],
|
||||
kilo: ['kilo', 'kilo-cli'],
|
||||
gemini: ['gemini', 'gemini-cli', 'gemini-code'],
|
||||
codex: ['codex', 'codex-app', 'codex-cli', 'codex_desktop', 'codex-desktop'],
|
||||
copilot: ['copilot', 'copilot-cli', 'github-copilot'],
|
||||
antigravity: ['antigravity', 'antigravity-cli', 'antigravity-agent'],
|
||||
cursor: ['cursor', 'cursor-cli', 'cursor-nightly'],
|
||||
windsurf: ['windsurf', 'windsurf-cli', 'windsurf-next'],
|
||||
augment: ['augment', 'augment-code', 'augment-cli'],
|
||||
trae: ['trae', 'trae-cli'],
|
||||
qwen: ['qwen', 'qwen-code', 'qwen-cli'],
|
||||
hermes: ['hermes', 'hermes-agent', 'hermes-cli'],
|
||||
codebuddy: ['codebuddy', 'codebuddy-cli'],
|
||||
cline: ['cline', 'cline-cli'],
|
||||
};
|
||||
|
||||
function normalizeRuntimeToken(value) {
|
||||
return String(value).trim().toLowerCase().replace(/[_\s]+/g, '-');
|
||||
}
|
||||
|
||||
function loadAliasManifest() {
|
||||
try {
|
||||
const manifestPath = path.resolve(__dirname, '../../../sdk/shared/runtime-aliases.manifest.json');
|
||||
const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
if (parsed && typeof parsed === 'object') return parsed;
|
||||
} catch {
|
||||
// Fall through to fallback aliases.
|
||||
}
|
||||
return FALLBACK_ALIASES;
|
||||
}
|
||||
|
||||
const aliasManifest = loadAliasManifest();
|
||||
const aliasToCanonical = new Map();
|
||||
for (const [canonical, aliases] of Object.entries(aliasManifest)) {
|
||||
if (typeof canonical !== 'string' || !Array.isArray(aliases)) continue;
|
||||
aliasToCanonical.set(normalizeRuntimeToken(canonical), normalizeRuntimeToken(canonical));
|
||||
for (const alias of aliases) {
|
||||
if (typeof alias !== 'string') continue;
|
||||
aliasToCanonical.set(normalizeRuntimeToken(alias), normalizeRuntimeToken(canonical));
|
||||
}
|
||||
}
|
||||
|
||||
function canonicalizeRuntimeName(value) {
|
||||
if (typeof value !== 'string') return null;
|
||||
return aliasToCanonical.get(normalizeRuntimeToken(value)) || null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
canonicalizeRuntimeName,
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { canonicalizeRuntimeName } = require('./runtime-name-policy.cjs');
|
||||
|
||||
/**
|
||||
* runtime-slash.cjs — single source of truth for emitting GSD slash-command
|
||||
* references in user-facing runtime output (recommended-actions JSON, persisted
|
||||
@@ -43,7 +45,8 @@ function formatGsdSlash(commandName, runtime) {
|
||||
const token = wsMatch ? wsMatch[1] : bare;
|
||||
const tail = wsMatch && wsMatch[2] ? wsMatch[2] : '';
|
||||
|
||||
const rt = String(runtime || 'claude').toLowerCase();
|
||||
const runtimeText = String(runtime || 'claude').toLowerCase();
|
||||
const rt = canonicalizeRuntimeName(runtimeText) || runtimeText;
|
||||
if (rt === 'codex') {
|
||||
// Codex skills are invoked as $gsd-<cmd> (shell-var syntax). The command
|
||||
// token is lowercased because shell-var identifiers are conventionally
|
||||
@@ -67,7 +70,8 @@ function formatGsdSlash(commandName, runtime) {
|
||||
*/
|
||||
function resolveRuntime(projectDir) {
|
||||
if (process.env.GSD_RUNTIME) {
|
||||
return String(process.env.GSD_RUNTIME).toLowerCase();
|
||||
const rawRuntime = String(process.env.GSD_RUNTIME).toLowerCase();
|
||||
return canonicalizeRuntimeName(rawRuntime) || rawRuntime;
|
||||
}
|
||||
if (projectDir) {
|
||||
try {
|
||||
@@ -83,7 +87,8 @@ function resolveRuntime(projectDir) {
|
||||
const raw = fs.readFileSync(configPath, 'utf-8');
|
||||
const parsed = JSON.parse(raw);
|
||||
if (parsed && typeof parsed === 'object' && parsed.runtime) {
|
||||
return String(parsed.runtime).toLowerCase();
|
||||
const rawRuntime = String(parsed.runtime).toLowerCase();
|
||||
return canonicalizeRuntimeName(rawRuntime) || rawRuntime;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user