Skip to content

matthewwong525/WongStack / .agents/plugins/loop/skills/save

scripts/delivery-route.mjs

View on GitHub
#!/usr/bin/env node
// Which way this checkout saves: the profile's `route`, else `github` with a working `gh` and a GitHub origin, else
// `local`. Exit 1 on a RouteError. `run <route> <command…>` runs the profile's `routeRun` for a route it owns.
import { execFileSync, spawnSync } from 'node:child_process';
import { isMain } from '../../../scripts/lib/cli.mjs';
import { originHost, RouteError } from '../../../scripts/lib/origin.mjs';
import { slot } from '../../../scripts/slot.mjs';

export { originHost, RouteError };

const git = (cwd, ...args) => {
  try {
    return execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
  } catch {
    return null;
  }
};

/** `github` for a GitHub origin with a working `gh`, else `local`. */
export function ownRoute(root) {
  const github = originHost(git(root, 'remote', 'get-url', 'origin')) === 'github.com';
  return github && spawnSync('gh', ['--version'], { stdio: 'ignore' }).status === 0 ? 'github' : 'local';
}

/** A checkout's route: `{ route, root }`. */
export async function delivery(cwd = process.cwd()) {
  const root = git(cwd, 'rev-parse', '--show-toplevel') ?? cwd;
  const named = await slot('route', {}, root);
  return { route: (!named.empty && named.value) || ownRoute(root), root };
}

/** Runs one command of a route the profile owns; its exit code, or 2 when no part runs it. */
export async function runRoute(args, root) {
  const found = await slot('routeRun', { args }, root);
  if (found.empty) console.error(`delivery-route: this project runs no ${args[0]} route`);
  return found.empty ? 2 : typeof found.value === 'number' ? found.value : 0;
}

if (isMain(import.meta.url)) {
  const [first, ...rest] = process.argv.slice(2);
  try {
    if (first === 'run') process.exitCode = await runRoute(rest);
    else console.log((await delivery(first || process.cwd())).route);
  } catch (error) {
    if (!(error instanceof RouteError)) throw error;
    console.error(`delivery-route: ${error.message}`);
    process.exitCode = 1;
  }
}
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
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: 194kUpdated Claude CodeCodexVerifiedInstall