npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sika7/editor4ai-lib

v0.3.1

Published

Core file operations library for Editor4AI

Readme

@sika7/editor4ai-lib

Core file operations library for Editor4AI - A lightweight TypeScript library for safe and efficient file operations, search functionality, and project management.

インストール

npm install @sika7/editor4ai-lib

概要

@sika7/editor4ai-libは、Editor4AIプロジェクトのコアライブラリです。ファイルシステム操作、検索機能、差分計算、ログ管理などの基本機能を提供し、他のパッケージから再利用できるように設計されています。

主な機能

ファイル操作 (files.ts)

  • ファイル読み取り: テキストファイルの安全な読み込み
  • ファイル書き込み: 新規ファイル作成・既存ファイル上書き
  • 行編集: 指定行範囲の編集・置換
  • 行挿入: 特定位置への行挿入
  • 行削除: 指定行・行範囲の削除
  • ファイル・ディレクトリ操作: 作成、削除、移動、リネーム

検索・Grep機能 (search.ts)

  • ファイル内検索: 正規表現対応のGrep機能
  • プロジェクト全体検索: 複数ファイル横断検索
  • フィルタリング: ファイルタイプ、除外パターン指定
  • コンテキスト表示: マッチ行の前後行表示

ディレクトリ操作 (directory.ts)

  • ディレクトリ作成・削除: 再帰的な操作対応
  • ディレクトリ一覧: ツリー表示、フィルタリング
  • パス解決: 安全なパス操作

差分計算 (diff.ts)

  • 文字列差分: 行レベルでの差分検出
  • ファイル差分: ファイル間の変更点表示

スクリプト実行 (script.ts)

  • npmスクリプト実行: package.jsonスクリプトの実行
  • 出力キャプチャ: 実行結果の取得

ログ管理 (logs.ts)

  • 構造化ログ: JSON形式でのログ出力
  • エラートラッキング: リクエスト単位でのエラー管理
  • ログレベル制御: 出力レベルの調整

ユーティリティ (util.ts)

  • パス操作: 相対パス変換、安全性チェック
  • 設定管理: 設定ファイルの読み込み
  • ID生成: ユニークなリクエストID生成

使用例

基本的な使用方法

import { Core } from '@sika7/editor4ai-lib'

// Coreクラスのインスタンス作成
const core = new Core('/path/to/project')

// ファイル読み取り
const content = await core.fileRead('src/index.ts')

// ファイル書き込み
await core.fileWrite('output.txt', 'Hello, World!')

// プロジェクト内検索
const results = await core.projectGrep('function', {
  fileTypes: ['.ts', '.js'],
  context: 2
})

型安全な検索オプション

import { DirectoryGrepOptionsSchema, type DirectoryGrepOptionsInput } from '@sika7/editor4ai-lib'

const searchOptions: DirectoryGrepOptionsInput = {
  regex: true,
  caseSensitive: false,
  maxResults: 100,
  context: 3,
  fileTypes: ['.ts', '.tsx'],
  exclude: ['node_modules', 'dist']
}

// Zodスキーマで検証
const validatedOptions = DirectoryGrepOptionsSchema.parse(searchOptions)

ログの設定

import { createSystemLogger, createRequestErrorLogger } from '@sika7/editor4ai-lib'

const systemLog = createSystemLogger('/path/to/logs')
const errorLog = createRequestErrorLogger('/path/to/logs')

systemLog.info('System started')
errorLog.error('Request failed', { requestId: 'req-123', error: 'File not found' })

設計原則

  • 型安全性: TypeScriptとZodスキーマによる実行時型チェック
  • セキュリティ: パストラバーサル攻撃防止、安全なファイルアクセス
  • モジュラー設計: 機能ごとに分離された独立したモジュール
  • テスタビリティ: 各機能の単体テスト対応
  • 軽量性: 最小限の依存関係で高パフォーマンス

依存関係

本番依存関係

  • date-fns: 日付処理
  • fast-xml-parser: XML解析
  • fs-extra: 拡張ファイルシステム操作
  • js-yaml: YAML解析
  • minimatch: ファイルパターンマッチング
  • papaparse: CSV解析
  • toml: TOML解析
  • yaml: YAML処理
  • zod: スキーマ検証・型安全性

開発依存関係

  • typescript: TypeScriptコンパイラ
  • @types/*: 型定義ファイル

ビルド・開発

# 依存関係のインストール
npm install

# TypeScriptビルド
npm run build

# 開発モード(ウォッチモード)
npm run dev

# クリーンビルド
npm run clean && npm run build

ライセンス

Apache License 2.0 - 詳細は LICENSE ファイルを参照してください。

貢献

プロジェクトへの貢献をお待ちしています。詳細は CONTRIBUTING.md を参照してください。