egatari 0.6.20 → 0.6.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,10 +18,11 @@
18
18
  // guessSubjects({text, lang}) → [{subject, word}](② の言葉に当たった題材と、当たった言葉。題材の順)
19
19
  // SCHOOL_AUDIENCES・asksSchool(category, sub) 授業(小・中・高)だけ「どの学校向けですか」(小中・高校)
20
20
  // audienceOf(category, sub, school) → 読み手の id | null(授業(小・中・高)は school、大学の講義・研究発表は大学、研修・ビジネスは社会人、手引きは一般、その他はなし)
21
- // rankParts({purposes, subjects, audience, usage, first}) → パーツの順位 [タグ](特殊の段を除くすべて)。
21
+ // rankParts({purposes, subjects, audience, usage, first, category}) → パーツの順位 [タグ](特殊の段を除くすべて)。
22
22
  // ① 伝えたいことが合うか(2 値。札の into も含む)② 題材が合うか ③ 読み手が合うか ④ サンプルで使う数(usage。既定は PACK.tiers.usage)、名前の順。
23
23
  // 題材か読み手のラベルがあって選んだものを含まないパーツは、合わないパーツとして、ほかのパーツの後ろ(伝えたいことが合っても)。
24
24
  // first(サンプルから始めたときのサンプルのパーツ)は、この順のまま一番上に
25
+ // m-predict は、① が授業・研修(category)か「予想してから確かめる」に印なら first のすぐ後、ほかは一番後ろ(handoff #108)
25
26
  // usageOf(samples) → {タグ: サンプルの数}(sample.json の parts から。PACK.tiers.usage と同じ数え方)
26
27
  // AI_PLANS・DEFAULT_PLAN どの AI に貼るか:'free'(無料の AI・わからない=軽量の指示。既定)| 'paid'(有料の AI・ファイルで渡す=詳細の指示)
27
28
  // planOf(choice) → 'free' | 'paid'(ない・知らない値は 'free')
@@ -37,7 +38,7 @@
37
38
  //
38
39
  // 見せ方(variant。format spec §8.4)は名前だけで選ぶ。教材のシード値(data-egatari-seed)はなくなった:書かない。前の原稿にあれば、そのまま残す(誰も読まない)
39
40
  import { updateConfig, merge, configObject } from './config-file.mjs';
40
- import { TIERS, PACK_CAP_KB } from './llm-pack.mjs';
41
+ import { TIERS, PACK_CAP_KB, TEACHING_FULL, teachingFull } from './llm-pack.mjs';
41
42
  import { PACK } from './llm-pack-data.mjs';
42
43
  import { partOrder } from './part-labels.mjs';
43
44
  import { componentsOff } from './purposes.mjs';
@@ -200,7 +201,9 @@ export function usageOf(samples = []) {
200
201
  return n;
201
202
  }
202
203
  // 順位(作者の決定 2026-11-19):合わない(題材か読み手のラベルがあり、選んだものを含まない)パーツは後ろ。その中と外で、伝えたいこと → 題材 → 読み手 → サンプルで使う数 → 名前
203
- export function rankParts({ purposes = [], subjects = [], audience = null, usage = TIERS.usage || {}, first = [] } = {}) {
204
+ // category(① の大分類):授業・研修か、伝えたいこと「予想してから確かめる」に印があれば、m-predict(TEACHING_FULL)を first のすぐ後に上げて説明を載せる。
205
+ // ほかでは m-predict を一番後ろに下げる(first にあればそのまま):説明は上限に余りがあるときだけで、ふつうは言いたいことの表に名前だけ(handoff #108)
206
+ export function rankParts({ purposes = [], subjects = [], audience = null, usage = TIERS.usage || {}, first = [], category = null } = {}) {
204
207
  const want = new Set(purposes);
205
208
  for (const p of known(TIERS.purposes)) if (p.into && want.has(p.into)) want.add(p.id); // 札に入る id(順位 → 比べる)
206
209
  const subs = new Set(subjects);
@@ -215,7 +218,9 @@ export function rankParts({ purposes = [], subjects = [], audience = null, usage
215
218
  const cmp = (a, b) => { for (let i = 0; i < 5; i++) if (keys[a][i] !== keys[b][i]) return keys[a][i] - keys[b][i]; return a < b ? -1 : a > b ? 1 : 0; };
216
219
  const order = tags.sort(cmp);
217
220
  const top = new Set(first);
218
- return [...order.filter((t) => top.has(t)), ...order.filter((t) => !top.has(t))];
221
+ const teach = TEACHING_FULL.filter((t) => order.includes(t) && !top.has(t));
222
+ const rest = order.filter((t) => !top.has(t) && !teach.includes(t));
223
+ return [...order.filter((t) => top.has(t)), ...(teachingFull({ category, purposes }) ? [...teach, ...rest] : [...rest, ...teach])];
219
224
  }
220
225
 
221
226
  const catOf = (id) => CATEGORIES.find((c) => c.id === id) || null;
@@ -1,3 +1,3 @@
1
1
  {
2
- "instruction": "79c82ff6"
2
+ "instruction": "da7ac17a"
3
3
  }
package/kit/llm-pack.mjs CHANGED
@@ -2,6 +2,9 @@
2
2
  // node kit/llm-pack.mjs --sets stats,math --lang ja 共通の本体(標準の部品)+ 束('all' で全部、指定なしで共通の本体だけ)
3
3
  // node kit/llm-pack.mjs --plan paid [--sets …] 有料のプラン(どの部品も詳しく。--sets all --plan paid で指示の全体)
4
4
  // node kit/llm-pack.mjs --no-fit [--sets …] 無料のプランで目安に収めない(下の fit をしない。比べる・調べる用)
5
+ // node kit/llm-pack.mjs --category teaching | --purposes predict [--sets …]
6
+ // 新規作成の ① の大分類・④ の伝えたいこと(無料のプランの詳しさだけに効く):授業・研修か「予想してから確かめる」なら
7
+ // m-predict も中核の 4 つと同じに詳しく書く(kit/core/llm-pack-assemble.mjs の freeFull。handoff #108。毎晩の評価が授業の題材で使う)
5
8
  // node kit/llm-pack.mjs --from-sample <名前> [--request <文|ファイル>] [--plan …] [--lang …]
6
9
  // 「このサンプルを参考に作る」で ② を書いて ④ で写す指示と同じバイト(backlog #130。kit/core/new-deck-pack.mjs の fromSamplePack):
7
10
  // examples/<名前>/sample.json の場面・テーマ・ラベル(伝えたいこと・題材・読み手)と構成。--request の 1 行目は ② のタイトル、
@@ -17,13 +20,15 @@ import fs from 'node:fs';
17
20
  import path from 'node:path';
18
21
  import { fileURLToPath } from 'node:url';
19
22
  import { fromSamplePack, sampleProblems } from './core/new-deck-pack.mjs';
23
+ import { CATEGORIES } from './core/new-deck.mjs';
20
24
  import { readRegularText, READ_LIMITS } from './bounded-read.mjs';
21
- import { buildPack, SETS, membersOfSet, packKb, kbOf, packSize, BRIEF, STANDARD, FREE_CORE, PACK_CAP_KB, FREE_PASTE_UNITS, pasteUnits, fitSize, loadedParts, partsPackOpts, fitPack, normalizeSets, SINGLE_SET_DROP_ORDER } from './core/llm-pack.mjs';
25
+ import { buildPack, SETS, membersOfSet, packKb, kbOf, packSize, BRIEF, STANDARD, FREE_CORE, TEACHING_FULL, freeFull, TIERS, PACK_CAP_KB, FREE_PASTE_UNITS, pasteUnits, fitSize, loadedParts, partsPackOpts, fitPack, normalizeSets, SINGLE_SET_DROP_ORDER } from './core/llm-pack.mjs';
22
26
 
23
27
  // 前の系列 → 束
24
28
  const SERIES_SETS = { academic: ['stats', 'math'], business: ['business'], kokugo: ['kokugo'], english: ['english'], info: [], social: ['maps'], music: ['music'] };
25
29
 
26
30
  const USAGE = `usage: node kit/llm-pack.mjs [--sets <name,…|all>] [--lang en|ja] [--plan free|paid] [--no-fit]
31
+ [--category <id>] [--purposes <id,…>]
27
32
  node kit/llm-pack.mjs --from-sample <name> [--request <text|file>] [--lang en|ja] [--plan free|paid]
28
33
  node kit/llm-pack.mjs --list [--lang en|ja]
29
34
  node kit/llm-pack.mjs --help
@@ -45,6 +50,10 @@ plus the packs of the chosen part sets (${SETS.join(', ')};
45
50
  never the set's own parts; with two or more sets, specialized parts
46
51
  are left out, largest first. stderr says what was shortened or left out
47
52
  --no-fit the light instructions as assembled, without fitting it to the limit
53
+ --category, --purposes the answers to New… step 1 (${CATEGORIES.map((c) => c.id).join(', ')})
54
+ and step 4 (purposes, e.g. predict). They change only the light
55
+ instructions: with --category teaching or --purposes predict,
56
+ ${TEACHING_FULL.join(', ')} is described in full like the core four
48
57
  --from-sample exactly what the editor copies in New… after “Make one based on
49
58
  this sample” (examples/<name>/sample.json): its setting, theme and parts (never
50
59
  suggested for unticking, described in full), plus its structure; fitted to
@@ -73,16 +82,26 @@ const langArg = arg('--lang');
73
82
  if (langArg !== undefined && !['en', 'ja'].includes(langArg)) { console.error(`--lang must be en or ja (got ${langArg})\n\n${USAGE}`); process.exit(2); }
74
83
  const planArg = arg('--plan');
75
84
  if (planArg !== undefined && !['free', 'paid'].includes(planArg)) { console.error(`--plan must be free or paid (got ${planArg})\n\n${USAGE}`); process.exit(2); }
76
- const VALUED = ['--sets', '--series', '--tools', '--lang', '--plan', '--from-sample', '--request'];
85
+ const VALUED = ['--sets', '--series', '--tools', '--lang', '--plan', '--from-sample', '--request', '--category', '--purposes'];
77
86
  const known = new Set([...VALUED, '--list', '--no-fit']);
78
87
  const bad = argv.filter((a, i) => a.startsWith('-') && !known.has(a.split('=')[0]) && !(i > 0 && VALUED.includes(argv[i - 1])));
79
88
  if (bad.length) { console.error(`unknown option ${bad[0]}\n\n${USAGE}`); process.exit(2); }
89
+ // 新規作成の ① の大分類と ④ の伝えたいこと(無料のプランの詳しく書く標準の部品だけに効く。handoff #108)
90
+ const categoryArg = arg('--category');
91
+ if (categoryArg !== undefined && !CATEGORIES.some((c) => c.id === categoryArg)) { console.error(`--category must be one of ${CATEGORIES.map((c) => c.id).join(', ')} (got ${categoryArg})\n\n${USAGE}`); process.exit(2); }
92
+ const purposesArg = arg('--purposes') === undefined ? [] : String(arg('--purposes')).split(',').map((x) => x.trim()).filter(Boolean);
93
+ const purposeIds = (TIERS.purposes || []).map((p) => p.id);
94
+ const badPurpose = purposesArg.find((x) => !purposeIds.includes(x));
95
+ if (badPurpose) { console.error(`--purposes: unknown purpose "${badPurpose}" (known: ${purposeIds.join(', ')})\n\n${USAGE}`); process.exit(2); }
96
+ const FULL = freeFull({ category: categoryArg || null, purposes: purposesArg });
80
97
 
81
- // 無料のプランの指示を目安に収める(編集アプリと同じ fitPack。頼みたいことは記入欄のまま)→ {text, fit}
82
- function fittedPack(sets, lang) {
83
- const sizeOf = (tags, short) => fitSize(buildPack({ ...partsPackOpts(tags, 'free', { short }), lang }), 'free');
98
+ // 無料のプランの指示を目安に収める(編集アプリと同じ fitPack。頼みたいことは記入欄のまま)→ {text, fit}。
99
+ // full:詳しく書く標準の部品(既定は中核の 4 つ。授業なら m-predict も。short のときは中核の 4 つと一緒に短くする)
100
+ function fittedPack(sets, lang, full = null) {
101
+ const opts = (tags, short) => partsPackOpts(tags, 'free', short || !full ? { short } : { full });
102
+ const sizeOf = (tags, short) => fitSize(buildPack({ ...opts(tags, short), lang }), 'free');
84
103
  const fit = fitPack(loadedParts(sets), 'free', { sizeOf, capBytes: PACK_CAP_KB.free * 1024 });
85
- return { text: buildPack({ ...partsPackOpts(fit.tags, 'free', { short: fit.short }), lang }), fit };
104
+ return { text: buildPack({ ...opts(fit.tags, fit.short), lang }), fit };
86
105
  }
87
106
 
88
107
  // 「このサンプルを参考に作る」の指示(編集アプリの新規作成 ④ と同じ組み立て)
@@ -107,7 +126,7 @@ function samplePack(name, lang, plan) {
107
126
 
108
127
  if (argv.includes('--from-sample')) {
109
128
  try {
110
- if (argv.includes('--no-fit') || arg('--sets') !== undefined || argv.includes('--list')) throw new Error('--from-sample cannot be used with --sets, --list or --no-fit');
129
+ if (argv.includes('--no-fit') || arg('--sets') !== undefined || argv.includes('--list') || categoryArg !== undefined || purposesArg.length) throw new Error('--from-sample cannot be used with --sets, --list, --no-fit, --category or --purposes (the sample gives them)');
111
130
  const lang = langArg || 'en', plan = planArg || 'free';
112
131
  const r = samplePack(String(arg('--from-sample') || ''), lang, plan);
113
132
  // 順位で組む(kit/core/new-deck-pack.mjs の newDeckPack):説明つきのパーツと名前だけのパーツの数を stderr に
@@ -145,11 +164,12 @@ if (argv.includes('--from-sample')) {
145
164
  }
146
165
  sets = sets === undefined ? [] : sets;
147
166
  const lang = langArg || 'en', plan = planArg || 'free';
148
- if (plan === 'paid' || argv.includes('--no-fit')) process.stdout.write(buildPack({ sets, lang, plan }));
167
+ if (plan === 'paid') process.stdout.write(buildPack({ sets, lang, plan }));
168
+ else if (argv.includes('--no-fit')) process.stdout.write(buildPack({ sets, lang, plan, full: FULL }));
149
169
  else {
150
- const { text, fit } = fittedPack(sets, lang);
170
+ const { text, fit } = fittedPack(sets, lang, FULL);
151
171
  const limit = `${PACK_CAP_KB.free} KB or a paste length of ${FREE_PASTE_UNITS} (UTF-16 code units + line feeds)`;
152
- if (fit.short) console.error(`note: light instructions: over ${limit}, so the core four (${FREE_CORE.join(', ')}) get only their catalogue line too (--no-fit for the pack as assembled)`);
172
+ if (fit.short) console.error(`note: light instructions: over ${limit}, so the core four (${FREE_CORE.join(', ')})${FULL.length > FREE_CORE.length ? ` and ${FULL.filter((t) => !FREE_CORE.includes(t)).join(', ')}` : ''} get only their catalogue line too (--no-fit for the pack as assembled)`);
153
173
  // 束が 1 つなら中核の 4 つのほかの標準のパーツを決まった順に、2 つ以上なら専門のパーツを大きい順に(kit/core/llm-pack-assemble.mjs の fitPlan)
154
174
  if (fit.dropped.length) console.error(normalizeSets(sets).length === 1
155
175
  ? `note: light instructions: still over ${limit}, so these standard parts were left out, in the fixed order: ${fit.dropped.join(', ')} (the ${normalizeSets(sets)[0]} parts and the core four are kept; --no-fit keeps them all)`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egatari",
3
- "version": "0.6.20",
3
+ "version": "0.6.21",
4
4
  "license": "MIT",
5
5
  "homepage": "https://studio.egatari.org/",
6
6
  "repository": {
@@ -44,6 +44,7 @@
44
44
  "tools/sheet.mjs",
45
45
  "tools/comment-shots.mjs",
46
46
  "tools/video.mjs",
47
+ "tools/narration-json.mjs",
47
48
  "components.lock.json",
48
49
  "components2.lock.json",
49
50
  "themes.lock.json",
@@ -0,0 +1,30 @@
1
+ // 口述原稿(narration.md)を JSON で出す。TTS(tts/synth.py)が parser を二重に持たないための口
2
+ //
3
+ // node tools/narration-json.mjs <narration.md> [--voice '<json>']
4
+ //
5
+ // 出力: {warnings: [文字列…(雛形の仮の行のままの段階も)], segments: [{key, slideKey, stepKey, line, digest, inputHash, bounds, turns:[{role, raw, display, tts, ttsParts, bounds}], ext:[{name, field, value, line}]}]}
6
+ // ext は拡張の行(@x-名前-欄 値)。発言にも digest にも入らない
7
+ // bounds は段階の区切り({cue} と {mark:…})の並び。synth.py が記録する cues と 1 対 1 に対応する(docs/contract.md §4)
8
+ // digest は kit/narration.mjs の segDigest(seg, voice)。voice には声の設定・正規化の目標値・
9
+ // 読み辞書の版など「音声を変えるものすべて」を入れる(呼び出し側が決める)
10
+ import crypto from 'node:crypto';
11
+ import { readNarration, segDigest } from '../kit/narration.mjs';
12
+ import { inputCanonical } from '../kit/core/portable.mjs';
13
+ import { isPlaceholder } from '../kit/core/template-text.mjs';
14
+
15
+ const a = process.argv.slice(2);
16
+ let file = null, voice = {};
17
+ for (let i = 0; i < a.length; i++) {
18
+ if (a[i] === '--voice') voice = JSON.parse(a[++i]);
19
+ else file = a[i];
20
+ }
21
+ if (!file) { console.error('usage: node tools/narration-json.mjs <narration.md> [--voice json]'); process.exit(1); }
22
+ const segs = readNarration(file);
23
+ // inputHash:その段階の口述原稿の hash(format spec §5.4。音声が古いかを決める。synth.py が manifest に書く)
24
+ const out = segs.map((s) => ({ key: `${s.slideKey}:${s.stepKey}`, slideKey: s.slideKey, stepKey: s.stepKey, line: s.line, digest: segDigest(s, voice),
25
+ inputHash: crypto.createHash('sha256').update(inputCanonical(s)).digest('hex'), bounds: s.bounds, turns: s.turns, ext: s.ext || [] }));
26
+ // 雛形の仮の行(「✎ 」で始まる。kit/core/template-text.mjs)が残っている段階:TTS はそのまま読むので、合成の前に知らせる(止めない)
27
+ const warnings = [...(segs.warnings || [])];
28
+ for (const s of segs) if (s.turns.some((t) => isPlaceholder(t.raw))) warnings.push(`narration.md ${s.line} 行目: ステップ「${s.slideKey}:${s.stepKey}」の台本がテンプレートの仮の行(✎)のまま。AI 音声はこのまま読む / still the template placeholder (✎); the AI voice reads it as is`);
29
+ for (const w of warnings) console.error(`⚠ ${w}`);
30
+ process.stdout.write(JSON.stringify({ warnings, segments: out }));
@@ -41,7 +41,7 @@
41
41
  | [`<m-tree>`](sha256/e0daed8338f51de7e86b5980a098394298455972218370ee65331ca48f7f9696/README.md) | 1.13.1 | 階層・分類の木(組織図、生物の分類など)を、根から 1 段ずつ組み立てる。座標は書かず、配置は部品が決める | 節の深さの数(by="level"、既定)か節の数(by="node")。節と edges の step があればその最大 | orient, by, link, size, fade, draw | [demo](sha256/e0daed8338f51de7e86b5980a098394298455972218370ee65331ca48f7f9696/demo.html) |
42
42
  | [`<m-venn>`](sha256/82b2dbc925a4ae4511bb48ccb1777a3932313ac7e18cb91572371d272a930980/README.md) | 1.13.1 | 2 つか 3 つの集合の円(ベン図)。集合を 1 つずつ出し、最後に重なりを強めてその中の項目を出す | 集合の数 + 1(overlaps="each" なら 集合の数 + 項目のある重なりの数) | size, dur, spread, overlaps | [demo](sha256/82b2dbc925a4ae4511bb48ccb1777a3932313ac7e18cb91572371d272a930980/demo.html) |
43
43
 
44
- ## 2.x のパーツ(components2.lock.json の既定の版 2.22.0)
44
+ ## 2.x のパーツ(components2.lock.json の既定の版 2.23.0)
45
45
 
46
46
  1.x の目録にない、2.x 専用の要素パーツ(`kind: "element"`)。土台パーツ(`kind: "library"`:base・boxplot-core・codetree-core・
47
47
  expr・heatmap-core・hist-core・icons・kanbun-core・markup-reader・plot・shape)は教材の作者が直接書かないので一覧には出さない。
@@ -0,0 +1,35 @@
1
+ ---
2
+ summary: Predict, reveal; votes as bars, answer framed
3
+ steps: 0 question, 1 bars, answer-step (2)
4
+ props:
5
+ answer-step: 2 or more (default 2); after the step-1 count
6
+ unit: count unit
7
+ poll: live poll id
8
+ ticks: grid
9
+ example: {"question": "Which falls first?", "choices": [{"label": "Heavy"}, {"label": "Light"}, {"label": "Same"}], "answer": 2, "counts": [14, 3, 9], "note": "No air: same"}
10
+ ---
11
+
12
+ Child JSON: `{"question", "choices": [{"label", "tone"?}], "answer": 0-based, "counts"?: [sample], "note"?: answer line, "labels"?: {"correct"?: mark (default "✓ Correct")}}`
13
+
14
+ - Only for a real vote or guess; not asides or answer-only
15
+ - 2–6 choices. Video/print/start show `counts` (or 0)
16
+ - Script uses `counts`; vote at `{note:hands up}` (parens get read)
17
+ - `poll="p1"`: live poll totals
18
+
19
+ <!-- llm: omit -->
20
+ Notes for authors of parts (check with dev)
21
+
22
+ - Steps: 0 question, choices, ticks (context first); 1 bars and controls; `answer-step` frame, "✓ correct", `note`, others faded, text `--muted` (≥ 4.5:1)
23
+ - Show later steps faintly: nothing ahead shown (`static preview = "none"`, manifest `preview: "none"`)
24
+ - Viewer state (spec §8.4): counts and guess survive step changes on the slide; reset to author values only on `ctx.entered` (since 2.0.0); `ctx.reset` only drops focus
25
+ - Answers (2.2.0, spec §8.4 `ctx.answer`): reaching the answer step with a guess calls `ctx.answer("q", correct, label)` once (again after going back); none without a guess, in video, or without `ctx.answer`. Since 2.3.0 the class declares `static questions = ["q"]`, so players count the question before its slide is shown
26
+ - Hands up; teacher counts ±1 or types. Alone: click = guess. Counts kept while on the slide
27
+ - Print: author values, no guess marks; screen counts restored after
28
+ - Methods: `input(choice, count)` (0–9999 integer, else console.warn; no-op in video); `counts()`
29
+ - On change: `CustomEvent("egatari-input", {bubbles: true, detail: {counts}})`
30
+ - live: `ctx.live?.poll(id)` → `number[] | null`; bars only for arrays, not in video/print
31
+ - `static interactive = true`, `static viewerInput = true` → manifest
32
+ - Keys: `+` `-` `↑` `↓` (buttons also `←` `→`); no digit keys; Esc/Enter leave the field
33
+ - No controls in video; hidden in print
34
+ - UI text (mark, labels, announcements) follows ctx.lang; `labels.correct` overrides the mark
35
+ <!-- llm: end -->