All AEM as a Cloud Service skills: component development, Workflow model design, development, triggering, launchers, debugging, and triaging, Dispatcher config authoring, advisory, incident response, performance tuning, and security hardening, Rapid Development Environment (RDE) deployment, log inspection, snapshots, and troubleshooting via `aio aem rde`, Jackrabbit Oak query/index tuning (property, Lucene index definitions), and extracting/inventorying JCR queries (XPath, SQL2, QueryBuilder) across a codebase.
85%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
'use strict';
const fs = require('fs');
const path = require('path');
const { execFileSync, spawnSync } = require('child_process');
const TOOL_PKG = '@adobe/aem-cs-source-migration-dispatcher-converter';
const TOOL_DIR = path.join(__dirname, 'dispatcher-tool');
// Modes the content-blind converter may actually run on. resolveExecutor silently routes any
// non-`standard` mode to the on-prem executor, so without this guard `already-cloud` /
// `not-dispatcher` / `unknown` would run the tool on a tree it can't convert. The agent is meant
// to STOP first; runConverter refuses too (defense-in-depth).
const CONVERTIBLE = new Set(['standard', 'flexible', 'ams', 'v1']);
// YAML-safe emission: escape backslashes + double-quotes; quote scalars. Empty → blank (' ')
// so the tool's `if (config.X)` guards still treat it as unset. A path with a YAML indicator
// (` #`, leading `*`/`&`/`!`/`%`/quote) or a Windows backslash otherwise mis-parses unquoted.
const esc = s => String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
const yamlScalar = v => (v == null || v === '') ? ' ' : `"${esc(v)}"`;
function yamlList(items) {
if (!items || !items.length) return ' ';
return '\n' + items.map(i => ` - ${yamlScalar(i)}`).join('\n');
}
// Emit the tool's config.yaml. Keys not applicable to the mode are left blank (the tool ignores them).
// cfg.onPremise.variablesToReplace: array of {from, to} objects → emitted as YAML mapping (flat key: value pairs).
// cfg.onPremise.portsToMap: array of numbers → emitted as YAML list.
function writeToolConfig(workingDir, cfg) {
const op = cfg.onPremise || {};
const variablesToReplaceYaml = (op.variablesToReplace && op.variablesToReplace.length)
? '\n' + op.variablesToReplace.map(v => ` ${yamlScalar(v.from)}: ${yamlScalar(v.to)}`).join('\n')
: ' ';
const lines = [
'dispatcherConverter:',
` sdkSrc: ${yamlScalar(cfg.sdkSrc)}`,
' onPremise:',
` dispatcherAnySrc: ${yamlScalar(op.dispatcherAnySrc)}`,
` httpdSrc: ${yamlScalar(op.httpdSrc)}`,
` vhostsToConvert:${yamlList(op.vhostsToConvert)}`,
` variablesToReplace:${variablesToReplaceYaml}`,
` appendToVhosts: ${yamlScalar(op.appendToVhosts)}`,
` pathToPrepend:${yamlList(op.pathToPrepend)}`,
` portsToMap:${yamlList(op.portsToMap)}`,
' ams:',
` cfg: ${yamlScalar(cfg.ams && cfg.ams.cfg)}`,
'',
];
fs.mkdirSync(workingDir, { recursive: true });
const p = path.join(workingDir, 'config.yaml');
fs.writeFileSync(p, lines.join('\n'));
return p;
}
function resolveExecutor(toolDir, mode) {
const execs = path.join(toolDir, 'node_modules', TOOL_PKG, 'executors');
const entry = (mode === 'standard') ? 'main.js' : 'singleFileMain.js'; // flexible/ams/v1/unknown → on-premise path
return path.join(execs, entry);
}
function isToolInstalled(toolDir) {
return fs.existsSync(path.join(toolDir, 'node_modules', TOOL_PKG, 'executors'));
}
function ensureToolInstalled(toolDir) {
if (isToolInstalled(toolDir)) return { installed: true, alreadyPresent: true };
execFileSync('npm', ['install', '--no-audit', '--no-fund'], { cwd: toolDir, stdio: 'inherit' });
return { installed: isToolInstalled(toolDir), alreadyPresent: false };
}
function runConverter(workingDir, mode, toolDir) {
if (!CONVERTIBLE.has(mode)) {
return {
code: null,
stdout: `runConverter: mode "${mode}" is not convertible (expected standard/flexible/v1) — resolve the mode before converting.`,
outputSrcDir: path.join(workingDir, 'target/dispatcher/src'),
reportPath: path.join(workingDir, 'target/dispatcher/dispatcher-converter-report.md'),
};
}
const executor = resolveExecutor(toolDir, mode);
// timeout guards a hung tool; maxBuffer (64 MiB) prevents a big config's verbose stdout from
// ENOBUFS-ing a successful run (default 1 MB would set r.error and make it look failed).
const r = spawnSync('node', [executor], { cwd: workingDir, encoding: 'utf8', timeout: 600000, maxBuffer: 64 * 1024 * 1024 });
let stdout = (r.stdout || '') + (r.stderr || '');
// On a spawn failure (e.g. node missing, ENOENT) status is null and stdout/stderr are empty;
// fold the error in so callers see the cause instead of an opaque { code: null, stdout: '' }.
if (r.error) stdout += String(r.error.message || r.error);
return {
code: r.status,
stdout,
outputSrcDir: path.join(workingDir, 'target/dispatcher/src'),
reportPath: path.join(workingDir, 'target/dispatcher/dispatcher-converter-report.md'),
};
}
module.exports = { writeToolConfig, resolveExecutor, TOOL_PKG, TOOL_DIR, isToolInstalled, ensureToolInstalled, runConverter };.tessl-plugin
skills
aem-rde
aem-workflow
code-assessment
content-distribution
create-component
assets
references
dispatcher
incident-response
references
dispatcher-foundation
performance-tuning
references
dispatcher-foundation
security-hardening
references
dispatcher-foundation
technical-advisory
references
dispatcher-foundation
workflow-orchestrator
references
dispatcher-foundation
ensure-agents-md
references
migration
references
dispatcher
legacy-ui
template-modernization
validation
scripts
dispatcher-tool
validate-migration