MarsDawn

エージェントとテーマを作る

MarsDawn のプレビューテーマを作る AI エージェント向けの参考資料です。エージェントは theme.json を1つ書き、コマンドラインツール marsdawn で検証してレンダリングし、リンクを渡します。人は「テーマを作る」ページで見た目を整えて投稿します。下のフィールド表は kit のソースコードから直接読み取ったもので、チェックによって一致が保たれています。

theme.json を書き、終了コードが 0 になるまで marsdawn theme validate theme.json --require-complete --json を実行し、marsdawn theme preview でライトとダークをレンダリングしてから、人にリンクを渡します。テーマはパラメーターだけで、CSS は含みません。

テーマとは

下の表にないキーはエラーで、同じキーを2回書くこともエラーです。ファイルは最大 16,384 バイトです。

検証とレンダリング

theme.json のあるフォルダで実行します。marsdawn ツールが必要です。AI エージェント向け marsdawnを参照してください。

marsdawn theme validate theme.json --require-complete --json
marsdawn theme css theme.json --json
marsdawn theme preview theme.json --appearance light -o light.png
marsdawn theme preview theme.json --appearance dark -o dark.png

組み込みテーマから始める

4つの組み込みテーマのどれかをコピーして変更します。どれも完全で有効なファイルです。

例:Dawn

dawn.json を1バイトも変えずに載せています。スタイルオプションは hr の細いアクセントカラーの線だけです。

{
  "schemaVersion": 1,
  "id": "dawn",
  "version": "1.0.0",
  "name": { "en": "Dawn" },
  "summary": { "en": "Warm Martian sunrise" },
  "fontDesign": "sans",
  "scenarios": ["agent-review"],
  "light": {
    "background": "#FFFDFB", "surface": "#F6F0EC", "text": "#26211F", "muted": "#6F6660",
    "border": "#EADFD8", "heading": "#26211F", "accent": "#C8471B", "link": "#B03C0C", "quote": "#D97A4A",
    "syntax": { "keyword": "#B03C0C", "string": "#2F6F5E", "comment": "#746B66", "number": "#9A5B00", "function": "#5B3E8C", "type": "#1F6FB2" },
    "diagram": { "node": "#FBE9E0", "nodeBorder": "#CA6C3C", "text": "#26211F", "line": "#8A6A5C", "secondary": "#E6F1EE", "tertiary": "#FFF6F1", "note": "#FFF1D6" }
  },
  "dark": {
    "background": "#1C1A1F", "surface": "#262229", "text": "#EBE4DF", "muted": "#A39992",
    "border": "#3A343A", "heading": "#F4EEEA", "accent": "#FF8A50", "link": "#FF9E6B", "quote": "#E08A5C",
    "syntax": { "keyword": "#FF9E6B", "string": "#7FD1B9", "comment": "#938A84", "number": "#F2C572", "function": "#C7A6F5", "type": "#6CB6FF" },
    "diagram": { "node": "#3A2A26", "nodeBorder": "#E08A5C", "text": "#EBE4DF", "line": "#B8A69C", "secondary": "#23332F", "tertiary": "#2B2427", "note": "#3D3322" }
  },
  "style": {
    "hr": { "style": { "type": "line", "color": "accent", "thickness": 1 } }
  }
}

フィールド

下のオブジェクトはどれも同じように読まれます。required はキーが必須という意味で、載っていないキーはエラーです。

型:string、integer、number、boolean、map(言語タグからテキストへ)、enum(挙げた値のいずれか)、role(パレットのロール)、object(リンク先の表)。型の後ろの [] はリストを表します。

theme.json

フィールド型必須か値と備考
schemaVersionintegerrequired常に 1。
idstringrequired1〜32文字:小文字と数字を、単独のハイフンでつないだ区切り。例:calm-green。
versionstringrequiredMAJOR.MINOR.PATCH。例:1.0.0。
namemaprequired言語タグからテキストへ。en は必須で、ほかのキーは zh-Hant のような言語タグです。各テキストは最大48文字で、リンクや改行は使えません。
summarymaprequiredname と同じ形式で、テキストごとに最大120文字。
fontDesignenumrequiredsans, serif, rounded
scenariosenum[]requiredagent-review, technical-docs, formal-output, notes-sharing — 1つまたは2つ、重複不可。テーマが満たすべきコントラストの水準を決めます。
authorobjectoptionalauthor
licensestringoptionalSPDX 識別子。例:Apache-2.0。投稿されたテーマは Apache-2.0 で公開されます。
lightobjectrequiredlight, dark
darkobjectrequiredlight, dark
styleobjectoptionalstyle

author

フィールド型必須か値と備考
namestringrequired最大64文字、リンク不可。
githubstringoptionalGitHub のログイン名。投稿の場合は、投稿する人のものを入れます。

light, dark

フィールド型必須か値と備考
backgroundstringrequired# と16進数6桁。例:#1C1C1C。
surfacestringrequired# と16進数6桁。例:#1C1C1C。
textstringrequired# と16進数6桁。例:#1C1C1C。
mutedstringrequired# と16進数6桁。例:#1C1C1C。
borderstringrequired# と16進数6桁。例:#1C1C1C。
headingstringrequired# と16進数6桁。例:#1C1C1C。
accentstringrequired# と16進数6桁。例:#1C1C1C。
linkstringrequired# と16進数6桁。例:#1C1C1C。
quotestringrequired# と16進数6桁。例:#1C1C1C。
syntaxobjectoptional (公開には必須。--require-complete で検証)syntax
diagramobjectoptional (公開には必須。--require-complete で検証)diagram

syntax

フィールド型必須か値と備考
keywordstringrequired# と16進数6桁。例:#1C1C1C。
stringstringrequired# と16進数6桁。例:#1C1C1C。
commentstringrequired# と16進数6桁。例:#1C1C1C。
numberstringrequired# と16進数6桁。例:#1C1C1C。
functionstringrequired# と16進数6桁。例:#1C1C1C。
typestringrequired# と16進数6桁。例:#1C1C1C。

diagram

フィールド型必須か値と備考
nodestringrequired# と16進数6桁。例:#1C1C1C。
nodeBorderstringrequired# と16進数6桁。例:#1C1C1C。
textstringrequired# と16進数6桁。例:#1C1C1C。
linestringrequired# と16進数6桁。例:#1C1C1C。
secondarystringrequired# と16進数6桁。例:#1C1C1C。
tertiarystringrequired# と16進数6桁。例:#1C1C1C。
notestringrequired# と16進数6桁。例:#1C1C1C。

style

フィールド型必須か値と備考
bodySizenumberoptional範囲
lineHeightnumberoptional範囲
headingWeightnumberoptional範囲
radiusnumberoptional範囲
maxWidthnumberoptional範囲
h1objectoptionalstyle.h1
h2objectoptionalstyle.h2
blockquoteobjectoptionalstyle.blockquote
hrobjectoptionalstyle.hr
tableobjectoptionalstyle.table
listMarkerroleoptionalパレットのロール
inlineCoderoleoptionalパレットのロール — text か構文ロールのみ:keyword、string、comment、number、function、type。
linkobjectoptionalstyle.link
syntaxobjectoptionalstyle.syntax

style.h1

フィールド型必須か値と備考
sizenumberoptional範囲
letterSpacingnumberoptional範囲
alignenumoptionalleft, center
decorationobjectoptionaltype

style.h2

フィールド型必須か値と備考
letterSpacingnumberoptional範囲
decorationobjectoptionaltype
italicbooleanoptionaltrue, false

style.blockquote

フィールド型必須か値と備考
styleobjectoptionaltype
italicbooleanoptionaltrue, false

style.hr

フィールド型必須か値と備考
styleobjectoptionaltype

style.table

フィールド型必須か値と備考
headerobjectoptionaltype
verticalRulesbooleanoptionaltrue, false
roundedbooleanoptionaltrue, false
フィールド型必須か値と備考
underlinebooleanoptionaltrue, false

style.syntax

フィールド型必須か値と備考
boldKeywordsbooleanoptionaltrue, false

type を持つオプション

これらのスタイルオプションは type を持つオブジェクトです。それぞれの type は、そこに挙げたフィールドだけを受け付けます。

オプションtypeフィールド必須か型
style.h1.decorationrule———
style.h1.decorationnone———
style.h1.decorationshortRulecolorrequiredrole
style.h1.decorationgradientBarfromrequiredrole
style.h1.decorationgradientBartorequiredrole
style.h2.decorationrule———
style.h2.decorationnone———
style.h2.decorationdotcolorrequiredrole
style.blockquote.stylebarwidthoptionalnumber 範囲
style.blockquote.stylepanel———
style.hr.stylelinecoloroptionalrole
style.hr.stylelinethicknessoptionalnumber 範囲
style.hr.styleshortCenteredcolorrequiredrole
style.hr.stylegradientcolorsrequiredrole[] ロールを2つまたは3つ。
style.table.headersurface———
style.table.headeraccentRulecolorrequiredrole
style.table.headerfilledbackgroundrequiredrole
style.table.headerfilledtextrequiredrole
style.table.headerfilledborderoptionalrole

パレットのロール

パレットのロールは次の名前のいずれかです。

background, surface, text, muted, border, heading, accent, link, quote, keyword, string, comment, number, function, type

数値

数値は最も近い刻みの倍数に丸められ、最小と最大の間に収まる必要があります。収まらない場合のルールは number.range です。

フィールド最小最大刻み
style.bodySize14181
style.lineHeight1.41.90.05
style.headingWeight40090050
style.radius0161
style.maxWidth60010001
style.h1.size1.82.40.1
style.h1.letterSpacing-0.030.030.005
style.h2.letterSpacing-0.030.030.005
style.blockquote.style.width241
style.hr.style.thickness141

ほかに検証されること

「テーマを作る」ページは、リンクからテーマを開けるので、人が見た目を整えられます。リンクは、そのページのアドレス、#theme=、パディングなしの base64url にしたファイルのバイト列でできています。ファイルは最大 16,384 バイトです。次の1行で、macOS と Linux の zsh と bash でリンクを作れます。

printf 'https://marsdawn.southern-light.dev/ja/themes/new/#theme=%s\n' "$(base64 < theme.json | tr -d '\n=' | tr '+/' '-_')"

テーマはブラウザがサイトに送らない # の後ろに入り、サイトもそれをどこにも送りません。ただしリンクはシェルとブラウザの履歴に残り、リンクを貼った相手はテーマを読めます。

投稿する

エージェントがファイルとリンクを用意し、投稿は人が行います。どちらの方法でも Developer Certificate of Origin と Apache-2.0 での公開への確認が必要で、この確認は人が自分で行います。エージェントがチェックボックスにチェックしたり、代わりに署名したりすることはありません。

投稿されたテーマの作者名、名前、概要、GitHub のログイン名は永久に公開されます。author.name には、その人が公開してよいと考える名前を入れてください。

公開されているテーマ

公開されているテーマの見た目は、テーマギャラリーで確認できます。