yuelinghuashu/story-cli
📚 story-cli
デプロイ不要、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 statsmake 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。
🌱 ストーリーだけではない
汎用コンテンツガバナンス — 「正規化」できるあらゆるテキスト資産に同じワークフローを適用可能:
テンプレートモード | コンテンツタイプ | 典型的な用途 |
| 小説 / ストーリー | オリジナル、二次創作 |
| 論文 / インタビュー / ブログ / ノート | ナレッジベース、研究ライブラリ |
| チュートリアル / 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 ツール | 説明 |
📖 閲覧 |
| ストーリーライブラリの一覧表示、章の読み取り(オンデマンド読み込みと末尾切り詰めに対応、Token 節約) |
✍️ 執筆 |
| 新規ストーリーの作成、本文のアトミック書き込み(書き込み後のコンプライアンスチェック任意) |
✅ ガバナンス |
| メタデータフィールドの直接変更、README 再構築の実行、設定の妥当性検証 |
📊 統計 |
| 総文字数 / 章数 / シリーズ進捗 / 健全性を取得 |
# 启动 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 はそのまま分類ラベルとして利用可能)を保証しています。追加のクリーニングスクリプトは不要です。
🛠️ よく使うコマンド
コマンド | 説明 |
| リポジトリを初期化(デフォルトはストーリー/ナレッジベース/技術ドキュメントモード) |
| 新規エントリを作成 |
| README をビルド |
| EPUB をエクスポート |
| 複数形式でエクスポート(embeddings はテキストブロック JSONL) |
| JSON から一括インポート |
| 創作統計 |
| コンプライアンスチェック(Story-Repo 仕様) |
| ストーリーの関連付けを管理(弱い関連) |
| MCP Server を起動(AI 接続エントリ) |
全コマンドのエイリアス、サブコマンド、パラメータ、分類の説明は docs/commands.md(中英バイリンガル)を参照してください。
カスタムのストーリータイプ/ステータスとローカライズ済みラベル:
{
"types": ["original", "fanfic", "translation"],
"statuses": ["completed", "ongoing", "planned"],
"typeLabels": { "translation": { "zh": "翻译", "en": "Translation" } }
}組み込みの列挙型にはラベルが組み込まれているため、重複設定は不要です。ファイルを削除するとデフォルトに戻ります。
📚 ドキュメント
ドキュメント | 中国語 | English | 内容 |
設計理念 | プロジェクト哲学 | ||
リポジトリ仕様 | データ仕様 | ||
新規コンテンツの追加方法 | ディレクトリ規約 | ||
コンテンツエクスポート | エクスポートガイド | ||
EPUB / PDF | EPUB エクスポート | ||
CI | GitHub Actions | ||
MCP Server | AI 接続ガイド | ||
アーキテクチャ | モジュール設計 | ||
コマンドリファレンス | 全コマンド一覧 | ||
更新ログ | 変更履歴 |
⚠️ エンコーディング要件
すべてのファイルは UTF-8 エンコーディングを使用する必要があります。GBK/GB2312 を検出した場合は警告しますが、ビルドはブロックしません。
🧪 テスト
make test # 或 pnpm test550+ 件のテストがすべて成功。対象:スキャナー、シリーズグループ化、バリデーション、テンプレートレンダリング、文字数統計、国際化、README 生成、EPUB エクスポート、CLI エンドツーエンド(スモークテストが全コマンドをカバー)、.storyignore、MCP プロトコル、JSON インポート、GitHub Action 構造、コンプライアンスチェック、関連提案、インクリメンタルビルドキャッシュ、embeddings エクスポートなど。
☕ スポンサー支援
⚖️ License
🤝 コントリビューション
Issue の提出を歓迎します(バグ報告 / 機能提案、フォームテンプレートあり)。コードへの貢献を希望される方は CONTRIBUTING.md をお読みいただき、ROADMAP.md でプロジェクトの位置づけをご確認ください。
Available Tools
9 toolsbuildAIdempotent
重建所有 README(等效 story build)。返回构建结果与捕获的输出日志
Inputs: no named parameters.
create_storyA
创建一个新故事(文件夹 + config.json + text.md 草稿)
Inputs: title (required), type, series, status, +3 more.
edit_configAIdempotent
更新故事 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_chapterARead-only
读取指定故事的章节内容(支持按章节索引按需加载)。tailLength 可只返回章节末尾 N 字符用于续写衔接,节省 Token
Inputs: folder (required), tailLength, chapterIndex.
scan_storiesARead-only
列出所有故事及元数据(标题/类型/状态/字数/系列)。默认返回精简列表节省 Token;传 verbose=true 获取完整详情
Inputs: verbose.
statsARead-only
获取故事库写作统计(总字数/章节数/系列分组/健康度/重复短语)
Inputs: no named parameters.
validateARead-only
检查仓库合规性(目录命名/必需文件/config schema/编码),等效 CLI story validate
Inputs: no named parameters.
write_chapterAIdempotent
将正文写入指定故事(原子写入 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
Scored across 9 tools
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.
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.
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.
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
Related MCP Connectors
Linked markdown notes as memory for AI apps: search, read, save and link notes over MCP.
Notes and memory assistant: one Markdown vault that Claude, ChatGPT and any MCP client can share.
Publish and share access-controlled Markdown documents from any MCP-enabled AI tool.
One memory, every AI. A shared, user-owned markdown memory your AI clients read and write over MCP.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceGit-native MCP server for managing AI context across sessions. Enables LLMs to access project and feature context via markdown files, preserving decisions and constraints.1-
- AlicenseAqualityBmaintenanceRepository-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.304MIT
- AlicenseNot gradedqualityBmaintenanceServes 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
- AlicenseNot gradedqualityCmaintenanceEnables 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