From 24f1853efc9e45200a3d7f2cca66add0984f4abe Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 17 Feb 2026 18:35:55 +0000 Subject: [PATCH] refactor(cli): move usage text to constants Moved the large usage help text from `src/lib.mjs` to `src/constants.mjs` to improve readability and maintainability of the library file. - Added `USAGE_TEXT` to `src/constants.mjs`. - Updated `src/lib.mjs` to import and use `USAGE_TEXT`. - Removed unused `DEFAULT_DASHBOARD_PORT` import from `src/lib.mjs`. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- src/constants.mjs | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/lib.mjs | 46 ++-------------------------------------------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/constants.mjs b/src/constants.mjs index df8fd95..0c0a7ec 100644 --- a/src/constants.mjs +++ b/src/constants.mjs @@ -13,3 +13,47 @@ export const DEFAULT_MIN_SUCCESSFUL_PUBLISHES = 1; export const DEFAULT_MIN_ACTIVE_RELAY_POOL = 1; export const VALID_CADENCES = new Set(['daily', 'weekly']); export const KIND_APP_DATA = 30078; + +export const USAGE_TEXT = `Usage: torch-lock [options] + +Commands: + check --cadence Check locked agents (JSON) + lock --agent --cadence Claim a lock + complete --agent --cadence Mark task as completed (permanent) + list [--cadence ] Print active lock table + health --cadence Probe relay websocket + publish/read health + dashboard [--port ] [--host ] Serve the dashboard (default: ${DEFAULT_DASHBOARD_PORT}) + init [--force] Initialize torch/ directory in current project + update [--force] Update torch/ configuration (backups, merges) + + list-memories [--agent ] [--type ] [--tags ] [--pinned ] [--full] + inspect-memory --id + pin-memory --id + unpin-memory --id + trigger-prune-dry-run [--retention-ms ] + memory-stats [--window-ms ] + +Options: + --dry-run Build and sign the event but do not publish + --force Overwrite existing files (for init) or all files (for update) + --log-dir Path to task logs directory (default: task-logs) + --ignore-logs Skip checking local logs for completed tasks + --json Emit compact single-line JSON + --json-file Write JSON output to a file path + --quiet Suppress stderr progress logs (pairs well with --json) + +Environment: + NOSTR_LOCK_NAMESPACE Namespace prefix for lock tags (default: torch) + NOSTR_LOCK_RELAYS Comma-separated relay WSS URLs + NOSTR_LOCK_TTL Lock TTL in seconds (default: 7200) + NOSTR_LOCK_QUERY_TIMEOUT_MS Relay query timeout in milliseconds (default: 15000) + NOSTR_LOCK_DAILY_ROSTER Comma-separated daily roster (optional) + NOSTR_LOCK_WEEKLY_ROSTER Comma-separated weekly roster (optional) + TORCH_CONFIG_PATH Optional path to torch-config.json (default: ./torch-config.json) + AGENT_PLATFORM Platform identifier (e.g., codex) + +Exit codes: + 0 Success + 1 Usage error + 2 Relay/network error + 3 Lock denied (already locked or race lost)`; diff --git a/src/lib.mjs b/src/lib.mjs index d9febd4..e002fb5 100644 --- a/src/lib.mjs +++ b/src/lib.mjs @@ -14,10 +14,10 @@ import { getHashtag as _getHashtag, } from './torch-config.mjs'; import { - DEFAULT_DASHBOARD_PORT, VALID_CADENCES, KIND_APP_DATA, RACE_CHECK_DELAY_MS, + USAGE_TEXT, } from './constants.mjs'; import { cmdInit, cmdUpdate } from './ops.mjs'; import { parseArgs } from './cli-parser.mjs'; @@ -492,49 +492,7 @@ export async function cmdComplete(agent, cadence, optionsOrDryRun = false, deps } function usage() { - console.error(`Usage: torch-lock [options] - -Commands: - check --cadence Check locked agents (JSON) - lock --agent --cadence Claim a lock - complete --agent --cadence Mark task as completed (permanent) - list [--cadence ] Print active lock table - health --cadence Probe relay websocket + publish/read health - dashboard [--port ] [--host ] Serve the dashboard (default: ${DEFAULT_DASHBOARD_PORT}) - init [--force] Initialize torch/ directory in current project - update [--force] Update torch/ configuration (backups, merges) - - list-memories [--agent ] [--type ] [--tags ] [--pinned ] [--full] - inspect-memory --id - pin-memory --id - unpin-memory --id - trigger-prune-dry-run [--retention-ms ] - memory-stats [--window-ms ] - -Options: - --dry-run Build and sign the event but do not publish - --force Overwrite existing files (for init) or all files (for update) - --log-dir Path to task logs directory (default: task-logs) - --ignore-logs Skip checking local logs for completed tasks - --json Emit compact single-line JSON - --json-file Write JSON output to a file path - --quiet Suppress stderr progress logs (pairs well with --json) - -Environment: - NOSTR_LOCK_NAMESPACE Namespace prefix for lock tags (default: torch) - NOSTR_LOCK_RELAYS Comma-separated relay WSS URLs - NOSTR_LOCK_TTL Lock TTL in seconds (default: 7200) - NOSTR_LOCK_QUERY_TIMEOUT_MS Relay query timeout in milliseconds (default: 15000) - NOSTR_LOCK_DAILY_ROSTER Comma-separated daily roster (optional) - NOSTR_LOCK_WEEKLY_ROSTER Comma-separated weekly roster (optional) - TORCH_CONFIG_PATH Optional path to torch-config.json (default: ./torch-config.json) - AGENT_PLATFORM Platform identifier (e.g., codex) - -Exit codes: - 0 Success - 1 Usage error - 2 Relay/network error - 3 Lock denied (already locked or race lost)`); + console.error(USAGE_TEXT); } /**