/**
 * Copyright (c) 2025 TWork Team. All rights reserved.
 * This source code is licensed under the TWork License.
 */

/**
 * bash-parser 模块类型声明
 * 
 * @module bash-parser
 * @see https://www.npmjs.com/package/bash-parser
 */

declare module 'bash-parser' {
  export interface ASTNode {
    type: string;
  }

  export interface ScriptNode extends ASTNode {
    type: 'Script';
    commands: ASTNode[];
  }

  export interface BashAst {
    type: 'script';
    commands: BashCommand[];
  }

  export interface BashCommand {
    type: 'command';
    name: string;
    args?: BashArgument[];
    redirects?: BashRedirect[];
  }

  export interface BashArgument {
    type: 'argument';
    text: string;
  }

  export interface BashRedirect {
    type: 'redirect';
    operation: string;
    fd?: number;
    file: {
      type: string;
      text: string;
    };
  }

  /**
   * 解析bash命令字符串为AST
   * @param command bash命令字符串
   * @returns AST对象
   */
  export default function parse(command: string): ScriptNode;
}
