Skip to main content
Glama
yuelinghuashu/story-cli

yuelinghuashu/story-cli

📚 story-cli

中文 English License Node CI npm version npm downloads

デプロイ不要、Git ネイティブな Markdown コンテンツ管理 CLI。 シンプルなディレクトリ規約でストーリー/論文/ノート/チュートリアルを管理し、README を自動生成、EPUB をエクスポート、中英バイリンガル対応。


✨ 機能特性

  • シンプルなディレクトリ規約 — コンテンツはフォルダのまま:NN-名称/ に config.json + text.md を含む

  • README 自動生成 — 各エントリとルートディレクトリのインデックスを自動生成(テンプレート駆動、カスタマイズ可能)

  • シリーズグループ化・並び替え — series / seriesOrder で表示順を制御、任意の挿入で並べ替え不要

  • 実行時バリデーション — ビルド前に設定をチェック(必須フィールド、列挙値、形式)

  • コンプライアンスチェック — story validate が Story-Repo 仕様に基づき検証(ディレクトリ命名 / UTF-8 / 重複番号 / schema)

  • ストーリー関連付け — story link で弱い関連を管理;story build が同シリーズの候補関連を自動提案

  • バイリンガル対応 — 中英コンテンツ + ローカライズ済み README を自動生成

  • 章 + 文字数 — 章タイトルの自動抽出と言語を認識した文字数統計

  • 多形式エクスポート — EPUB(表紙レンダリング/組版スタイル/シリーズメタデータ)/ HTML / TXT / JSON / Markdown / embeddings、--stdout パイプ対応

  • 汎用コンテンツ基盤 — ナレッジベースモード(論文/インタビュー/ノート)、技術ドキュメントモード(チュートリアル/API)

  • MCP Server — AI クライアント(Claude / Cursor)がコンテンツライブラリを直接読み書き可能

  • GitHub Action — ゼロ設定の CI エントリ(yuelinghuashu/story-cli@v1)、ワンクリックで「Push → Build → 公開」を実現

  • Watch モード — ファイル変更で自動再ビルド


Related MCP server: Workfile

🚀 クイックスタート

# 安装(需要 Node.js >= 22)
npm install -g @yuelinghuashu/story-cli

# 创建示例仓库并查看效果
story demo

# 初始化仓库
story init

# 创建内容并编写
story new "我的新故事"

# 构建所有 README
story build

# 导出 EPUB / 统计
story epub --all
story stats
make init                 # 初始化
make new TITLE="我的故事"  # 新建并自动构建
make commit               # 构建 + 提交
make push                 # 构建 + 提交 + 推送
make stats                # 查看创作统计
make analyze              # 写作质量分析(重复短语 / 字数过期 / 章节趋势,需 jq)

Windows ユーザーは story init が生成する story.ps1(PowerShell 版ワークフロー)も利用可能:.\story.ps1 init / .\story.ps1 new -Title '我的故事' / .\story.ps1 build。


🌱 ストーリーだけではない

汎用コンテンツガバナンス — 「正規化」できるあらゆるテキスト資産に同じワークフローを適用可能:

テンプレートモード

コンテンツタイプ

典型的な用途

--template=story(デフォルト)

小説 / ストーリー

オリジナル、二次創作

--template=knowledge

論文 / インタビュー / ブログ / ノート

ナレッジベース、研究ライブラリ

--template=tech

チュートリアル / API ドキュメント / チェンジログ

技術ブログ、プロジェクトドキュメント

story init --template=knowledge
story init --template=tech

🤖 AI にコンテンツライブラリを管理させる

story-cli には MCP Server が内蔵されており、AI クライアント(Claude Desktop / Cursor / VSCode Copilot Chat)がコンテンツライブラリを直接読み書きできます。AI は「作成 → 執筆 → ビルド → 統計」の完全なサイクルを単独で完了でき、ターミナルで手動コマンドを実行する必要はありません。

💡 Token 経済性:MCP ツールは設計当初から AI 呼び出しコストの削減を中核原則としています。scan_stories はデフォルトで簡潔な出力(ディレクトリ閲覧で ~80-95% 削減)、read_chapter はオンデマンドの切り詰めに対応(続き書きのシナリオで ~95%+ 削減)、stats は一度の呼び出しで全データを取得(~99%)——あらゆる細部が AI ワークフローの Token 消費を抑えます。

機能

MCP ツール

説明

📖 閲覧

scan_stories / read_chapter

ストーリーライブラリの一覧表示、章の読み取り(オンデマンド読み込みと末尾切り詰めに対応、Token 節約)

✍️ 執筆

write_chapter / create_story

新規ストーリーの作成、本文のアトミック書き込み(書き込み後のコンプライアンスチェック任意)

✅ ガバナンス

edit_config / build / validate

メタデータフィールドの直接変更、README 再構築の実行、設定の妥当性検証

📊 統計

stats

総文字数 / 章数 / シリーズ進捗 / 健全性を取得

# 启动 MCP Server(需在故事仓库根目录;--root 可从任意目录指定仓库)
story mcp-server

💡 詳細な設定と例は docs/mcp.md を参照してください。MCP Server は現在の作業ディレクトリ内のすべてのファイルを読み書きします。信頼できるリポジトリでのみ実行してください。

🎯 ファインチューニング用データ準備(SFT / Embedding)

ストーリーライブラリの構造化出力は大規模言語モデルのトレーニングデータソースとして自然に適しています——config.json には分類ラベルが組み込まれ、export json は章単位で正確にスライスし、export embeddings はプレーンテキストブロックを出力します。--stdout + Unix ツールチェーンと組み合わせれば、1行のパイプで標準的なファインチューニング形式に変換できます:

# 导出为指令微调 JSONL(summary → instruction,正文 → output)
story export json --stdout | jq -c '.stories[] | {messages: [{role: "user", content: .summary}, {role: "assistant", content: .content}]}' > sft_data.jsonl

# 导出为 Embedding 训练格式
story export embeddings --stdout | jq -c '{text: .content, metadata: {title: .title, series: .series}}' > embedding_data.jsonl

# 快速分析数据配比(总字数/章节分布/重复短语)
story stats --json | jq '{words: .totalWords, chapters: .totalChapters, repeated: .analysis.repeated}'

💡 story-cli は UTF-8 エンコーディング(GBK は自動検出して警告)、章レベルのスライス(意味の途切れを回避)、メタデータの完全性(type/series/summary はそのまま分類ラベルとして利用可能)を保証しています。追加のクリーニングスクリプトは不要です。


🛠️ よく使うコマンド

コマンド

説明

story init [--template=story|knowledge|tech]

リポジトリを初期化(デフォルトはストーリー/ナレッジベース/技術ドキュメントモード)

story new "标题" [--type] [--lang] [--author] [--creator]

新規エントリを作成

story build [--validate-only] [--save-counts] [--watch]

README をビルド

story epub "标题" [--all] [--split-by-volume] [--output=dir] [--css=path]

EPUB をエクスポート

story export html / txt / json / md / embeddings [--stdout]

複数形式でエクスポート(embeddings はテキストブロック JSONL)

story import json --file=xxx.json

JSON から一括インポート

story stats [--json]

創作統計

story validate [--json]

コンプライアンスチェック(Story-Repo 仕様)

story link "A" "B" [--remove=...] [--list]

ストーリーの関連付けを管理(弱い関連)

story mcp-server

MCP Server を起動(AI 接続エントリ)

全コマンドのエイリアス、サブコマンド、パラメータ、分類の説明は docs/commands.md(中英バイリンガル)を参照してください。

カスタムのストーリータイプ/ステータスとローカライズ済みラベル:

{
  "types": ["original", "fanfic", "translation"],
  "statuses": ["completed", "ongoing", "planned"],
  "typeLabels": { "translation": { "zh": "翻译", "en": "Translation" } }
}

組み込みの列挙型にはラベルが組み込まれているため、重複設定は不要です。ファイルを削除するとデフォルトに戻ります。


📚 ドキュメント

ドキュメント

中国語

English

内容

設計理念

design.md

design.en.md

プロジェクト哲学

リポジトリ仕様

specification.md

specification.en.md

データ仕様

新規コンテンツの追加方法

add-story.md

add-story.en.md

ディレクトリ規約

コンテンツエクスポート

export.md

export.en.md

エクスポートガイド

EPUB / PDF

epub.md

epub.en.md

EPUB エクスポート

CI

ci.md

ci.en.md

GitHub Actions

MCP Server

mcp.md

mcp.en.md

AI 接続ガイド

アーキテクチャ

architecture.md

architecture.en.md

モジュール設計

コマンドリファレンス

commands.md

commands.en.md

全コマンド一覧

更新ログ

CHANGELOG.md

CHANGELOG.en.md

変更履歴


⚠️ エンコーディング要件

すべてのファイルは UTF-8 エンコーディングを使用する必要があります。GBK/GB2312 を検出した場合は警告しますが、ビルドはブロックしません。


🧪 テスト

make test         # 或 pnpm test

550+ 件のテストがすべて成功。対象:スキャナー、シリーズグループ化、バリデーション、テンプレートレンダリング、文字数統計、国際化、README 生成、EPUB エクスポート、CLI エンドツーエンド(スモークテストが全コマンドをカバー)、.storyignore、MCP プロトコル、JSON インポート、GitHub Action 構造、コンプライアンスチェック、関連提案、インクリメンタルビルドキャッシュ、embeddings エクスポートなど。


☕ スポンサー支援


⚖️ License

MIT


🤝 コントリビューション

Issue の提出を歓迎します(バグ報告 / 機能提案、フォームテンプレートあり)。コードへの貢献を希望される方は CONTRIBUTING.md をお読みいただき、ROADMAP.md でプロジェクトの位置づけをご確認ください。

Available Tools

9 tools
buildA
Idempotent

重建所有 README(等效 story build)。返回构建结果与捕获的输出日志

Inputs: no named parameters.

create_storyA

创建一个新故事(文件夹 + config.json + text.md 草稿)

Inputs: title (required), type, series, status, +3 more.

edit_configA
Idempotent

更新故事 config.json 的元数据字段。可编辑:summary/status/series/seriesOrder/volume/links/author/originalWork/originalAuthor/cover/language/wordCount。字段值传 null 表示移除该可选字段。title/type/created/isMultiChapter 为身份或审计字段,禁止修改。写入前经仓库级 schema 校验,校验失败不写盘。修改后请运行 build 更新 README

Inputs: fields (required), folder (required).

import_jsonA

从结构化 JSON 批量导入故事(与 CLI import json 同构)

Inputs: stories (required).

read_chapterA
Read-only

读取指定故事的章节内容(支持按章节索引按需加载)。tailLength 可只返回章节末尾 N 字符用于续写衔接,节省 Token

Inputs: folder (required), tailLength, chapterIndex.

scan_storiesA
Read-only

列出所有故事及元数据(标题/类型/状态/字数/系列)。默认返回精简列表节省 Token;传 verbose=true 获取完整详情

Inputs: verbose.

statsA
Read-only

获取故事库写作统计(总字数/章节数/系列分组/健康度/重复短语)

Inputs: no named parameters.

validateA
Read-only

检查仓库合规性(目录命名/必需文件/config schema/编码),等效 CLI story validate

Inputs: no named parameters.

write_chapterA
Idempotent

将正文写入指定故事(原子写入 text.md)。validate=true 时写入后立即执行仓库合规检查并返回结果(不阻断写入)

Inputs: folder (required), content (required), validate.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool targets a distinct operation or resource: creating/importing stories, reading/writing chapters, editing config, validating, building, stats, and scanning. There is no real overlap, and the descriptions clarify boundaries even where purposes are adjacent, such as create_story vs import_json.

    Naming Consistency4/5

    Most tools follow a clear verb_noun snake_case pattern (create_story, scan_stories, read_chapter, write_chapter, edit_config, import_json). validate, build, and stats are shorter imperative/noun names but are still intuitive and do not break the overall predictability.

    Tool Count5/5

    Nine tools is well-scoped for a story authoring workflow. Each tool has a clearly defined role, and none feel redundant or unnecessary for the server's purpose.

    Completeness3/5

    The core authoring loop is covered: create, read/write chapters, edit metadata, validate, build, and get stats. However, there is no delete story/chapter operation and no explicit chapter listing tool, leaving lifecycle management incomplete. Agents could work around some gaps, but deletion is a notable missing capability.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Repository-native protocol and MCP server for coordinating work items, documentation, changelogs, and project memory between humans and AI agents, using Markdown files in a Git repository as the canonical data source.
      30
      4
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Serves a git-backed folder of Markdown notes over MCP so AI agents can search, read, write, move and delete them, with every write recorded as a git commit attributed to the calling client. Supports full-text section search with snippets, wikilinks and typed relations, LFS-backed searchable attachments, optimistic concurrency for multiple agents, and per-client token or OAuth 2.1 access.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables an AI assistant to read and write a git-versioned personal markdown knowledge base through MCP tools, with deterministic validation, lifecycle enforcement, local hybrid search, and corpus auditing.
      MIT