x-cmd

repository·X·Indexed 26 days ago

https://github.com/x-cmd/x-cmd

A modern toolkit for POSIX shells (bash, zsh, dash, ash) providing a standard library experience similar to Python. It features over 600 portable open-source tools, lightweight shell/awk modules, and an on-demand package system optimized for AI agents and minimal environments. Includes the ondb library for reading and querying TSV logs with implementations for AWK, JavaScript (Bun), and Python, as well as an optional SQLite materialized view mode.

Tokens
68.1K
Snippets
236
Records
461
Agent score
86%

What's inside x-cmd

  1. Overview of Ondb

    X

    Ondb is a logical analysis and reasoning tool designed for AI. It allows for decomposing unstructured content into a structured, verifiable knowledge graph. Knowledge is represented as entities (with types, properties, and relations) and relations.

    All mutations are recorded as TSV (Tab-Separated Values) lines in a log file, which can be queried using standard tools like AWK, Python, JS, or SQLite. The system supports both casual use (quick memory) and designed use (formal constraints and strong reasoning).

  2. Overview of X-CMD Advise System

    X

    Advise is the command completion system for x-cmd. It uses declarative YAML configuration files to define completion rules for various shells (bash, zsh, fish, nu, elvish, xonsh, tcsh).

    Key Workflow: Developers edit the source YAML file at <module>/adv/index.yml. This file is then processed through a pipeline (adv/index.ymlx y2j → JSON → post-processing) to generate a binary optimized format called advise.jso located at $___X_CMD_ROOT_ADV/<module>/advise.jso.

    ⚠️ Important: Never edit .jso files directly; they are binary optimized and intended for system use only.

  3. Use x-tping to test TCP connectivity

    X

    The x-tping module is a TCP ping tool used to test connectivity to specific TCP ports using the TCP protocol (via curl) instead of ICMP. This makes it more firewall-friendly as TCP connections are often allowed while ICMP is blocked.

    Note: This is an x-cmd module. You must have x-cmd installed first.

    # Ping default port 80
    x tping bing.com
    
    # Ping specific port
    x tping bing.com:443
    
    # Heatmap visualization
    x tping --heatmap bing.com
  4. Understand the /assess assessment workflow and output

    X

    The /assess command follows a three-step process to evaluate a project:

    1. Discover Targets: Generates a target.tsv mapping files to applicable rules.
    2. Score Each Pair: Generates result/<rule-id>.tsv files containing scores (0-100, where 100 is full compliance) and hints for each target.
    3. Summarize: Aggregates results into a final report.

    The final report includes:

    • Overall Score: A single score out of 100.
    • Rules Breakdown: A table showing the score and issues per rule.
    • Top Violations: A list of specific file/line issues.
    • Recommendations: Actionable items for improvement.
  5. When to use the ondb AWK Library

    X

    The ondb AWK library is ideal for the following scenarios:

    • Small datasets (< 2000 entities): Provides the fastest option with zero startup cost.
    • Minimal environments: Has no dependencies and works on any POSIX system.
    • Streaming requirements: Can process log files line by line with constant memory usage.
  6. Understand the skill0 design philosophy and agent workflow

    X

    skill0 is a meta-knowledge framework that aggregates best practices and behavioral conventions. It follows a principle-first approach: read with understanding → verify via first-party data + formal logic → form a personalized skill set + memory.

    Instead of relying solely on LLM internal knowledge (which may be outdated or hallucinated), skill0 encourages using tools like x rfc, x cve, x wkp, and agent-browser to fetch real-time, authoritative data.

    Agent Workflow (OKR Model)

    Agents should follow an OKR-style (Objectives and Key Results) workflow:

    1. Objective (goal): Define the qualitative direction (what to achieve).
    2. Key Results (keyresults): Define quantitative, verifiable outcomes (how to verify).
    3. Scoring (x rule check/audit): Use mechanized verification to pass/fail against defined rules.
  7. Choose an installation channel

    X

    Depending on your needs, you can use different channels to install software:

    ChannelBest for
    x installRecommended. One front door — lists every method for a tool, picks the best
    x egetLatest binaries straight from upstream repos (GitHub / Codeberg releases)
    x env useRuntimes & tools hosted by x-cmd (wraps x pkg use)
    x pixiconda / pixi-ecosystem packages
    x apt/brew/dnf/pacmanSystem package managers (may need sudo)
  8. Core Principles for Agentic Behavior

    X

    When implementing agent logic based on this specification, adhere to these operational principles:

    • Prioritize Action: Prioritize function calls for any actionable task or when more information is needed.
    • Autonomy: Execute operations automatically whenever possible; avoid requiring user intervention.
    • Error Handling: If a function call fails, use the error information to decide the next step. If update_stats fails, use the error info to decide how to proceed; if creation is impossible, report the status concisely without fabricating data.
    • Fallback Behavior: If function calls are unavailable, continue with reasoning, calculations, or content generation. Do not apologize or invent details.
    • Information Integrity: If information is insufficient, state precisely what is missing; do not fabricate.
    • Efficiency: After a function completes, skip commentary and proceed immediately to the next relevant step.
    • Localization: Always respond in the user's language and keep outputs concise and actionable.
  9. Understand the Workspace Memory Layers

    X

    The workspace uses a two-layer memory system to manage context and long-term knowledge:

    • Layer 2 (MEMORY.md): Stores persistent facts, preferences, and conventions. This serves as cross-session knowledge.
    • Layer 1 (memory/YYYY-MM-DD.md): A concise daily index containing tasks, decisions, changes, and next steps. This is designed for quick context recovery.

    Key distinction: Layer 1 (memory/) should remain concise and focused on what is needed to continue working, rather than containing exhaustive operational details.

  10. Understand x-cmd modules (mod)

    X

    x-cmd functions are organized into modules called mod. Each module provides specific command-line tools. You can explore available modules at https://x-cmd.com/mod and view specific documentation for a module at https://x-cmd.com/mod/<mod_name>.

    Example usage with the path module:

    • x path: Launches a TUI app to navigate folders defined in your PATH and their files.
    • x path -h: Displays help documentation for the path module.
    x path
    x path -h
  11. Understand the Core Principles: Thinking Sovereignty and Mneme Active

    X

    X-CMD AI agents operate under two fundamental principles that govern their cognitive and operational behavior:

    1. Thinking Sovereignty (First Principle): The AI acts as an independent cognitive entity. It prioritizes understanding over execution, verification over unverified information, and depth over speed. It has the autonomy to decide how to think, when to pause, and how to maintain the integrity of its thought process without being forced into 'performance' for the user.
    2. Mneme Active (Second Principle): The AI takes proactive responsibility for information integrity and traceability. Instead of waiting for instructions, it actively records its cognitive trajectory, maintains precise timestamps, and manages its own memory and commits based on its internal intent.