nanocoai/nanoclaw / .claude/skills/add-mattermost
add-mattermost
FlaggedAdd a self-hosted or cloud Mattermost bot channel through the Chat SDK bridge, reusing a healthy server when available and linking to official server setup guidance when needed.
| File | Kind | Size |
|---|---|---|
| REMOVE.md | markdown | 1.5 KB |
| SERVER_SETUP.md | markdown | 1.3 KB |
| SKILL.md | skill md | 16.8 KB |
| apply-fixtures.json | config | 5.8 KB |
| scripts/configure.ts | script | 3.2 KB |
| scripts/discover-server.mjs | script | 3.8 KB |
| scripts/read-response.mjs | script | 1.0 KB |
| scripts/remove-base-url.mjsexecutable | script | 335 B |
| scripts/remove-config.mjsexecutable | script | 381 B |
| scripts/select-server.mjs | script | 1020 B |
| scripts/verify-runtime.ts | script | 9.8 KB |
scripts/discover-server.mjs
View on GitHubimport { readFile } from 'node:fs/promises';
import { execFileSync } from 'node:child_process';
const PING_PATH = '/api/v4/system/ping';
function normalize(value) {
try {
const url = new URL(value?.trim() || '');
if (!['http:', 'https:'].includes(url.protocol)) return '';
if (url.username || url.password || url.search || url.hash) return '';
if (!/^\/(?:[A-Za-z0-9._~%+-]+\/)*[A-Za-z0-9._~%+-]*$/.test(url.pathname)) return '';
const path = url.pathname.replace(/\/+$/, '');
return `${url.origin}${path}`;
} catch {
return '';
}
}
async function configuredUrl() {
if (process.env.MATTERMOST_BASE_URL) return normalize(process.env.MATTERMOST_BASE_URL);
try {
const text = await readFile('.env', 'utf8');
for (const line of text.split(/\r?\n/)) {
const match = line.match(/^\s*MATTERMOST_BASE_URL\s*=\s*(.*?)\s*$/);
if (match?.[1]) return normalize(match[1].replace(/^(['"])(.*)\1$/, '$2'));
}
} catch {
// Any .env read failure means no configured URL; discovery must still
// resolve so the operator fallback prompt is offered.
}
return '';
}
async function isMattermost(baseUrl) {
try {
const response = await fetch(`${baseUrl}${PING_PATH}`, { signal: AbortSignal.timeout(2000) });
if (!response.ok) return false;
const body = await response.json();
return body?.status === 'OK';
} catch {
return false;
}
}
function commandWorks(command, args) {
try {
execFileSync(command, args, { stdio: 'ignore', timeout: 3000 });
return true;
} catch {
return false;
}
}
function localConfigAccess(baseUrl) {
let hostname = '';
let port = '';
try {
const parsed = new URL(baseUrl);
hostname = parsed.hostname;
port = parsed.port || (parsed.protocol === 'https:' ? '443' : '80');
} catch {
return { config_access: 'unavailable', mattermost_container: 'none' };
}
if (hostname !== 'localhost' && hostname !== '127.0.0.1' && hostname !== '::1') {
// A canonical DNS name does not prove that an arbitrary host socket or
// container belongs to this server. Prefer manual authenticated guidance
// over risking a configuration change against the wrong local instance.
return { config_access: 'unavailable', mattermost_container: 'none' };
}
if (commandWorks('mmctl', ['config', 'get', 'ServiceSettings.SiteURL', '--local'])) {
return { config_access: 'host', mattermost_container: 'none' };
}
try {
const names = execFileSync('docker', ['ps', '--format', '{{.Names}}\t{{.Image}}\t{{.Ports}}'], {
encoding: 'utf8',
timeout: 3000,
});
for (const row of names.split(/\r?\n/)) {
const [name, image = '', ports = ''] = row.split('\t');
if (!name || !/mattermost/i.test(`${name} ${image}`)) continue;
if (!ports.split(',').some((mapping) => mapping.includes(`:${port}->`))) continue;
if (commandWorks('docker', ['exec', name, 'mmctl', 'config', 'get', 'ServiceSettings.SiteURL', '--local'])) {
return { config_access: 'docker', mattermost_container: name };
}
}
} catch {
// Docker is optional. Lack of access is handled by operator guidance.
}
return { config_access: 'unavailable', mattermost_container: 'none' };
}
try {
const candidates = [...new Set([await configuredUrl(), 'http://localhost:8065', 'http://127.0.0.1:8065'])].filter(
Boolean,
);
for (const baseUrl of candidates) {
if (await isMattermost(baseUrl)) {
process.stdout.write(
`${JSON.stringify({ discovery: 'found', base_url: baseUrl, ...localConfigAccess(baseUrl) })}\n`,
);
process.exit(0);
}
}
} catch {
// Fall through to the not-found result below.
}
process.stdout.write(
`${JSON.stringify({ discovery: 'none', base_url: 'none', config_access: 'unavailable', mattermost_container: 'none' })}\n`,
);
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |