@takagaki/cortex-decisions-viewer 0.12.265 → 0.12.268
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.
- package/dist/build.js +114 -23
- package/dist/render.js +543 -101
- package/dist/source-rows.js +37 -0
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.REFERENCES_SECTIONS = exports.RELATED_MATERIALS_SECTIONS = exports.RELATED_URL_MAX = exports.RELATED_MATERIALS_FIELD = exports.relatedMaterialsRead = exports.isRelatedUrl = exports.GRAPH_RELS = exports.GRAPH_RECORD_TYPES = exports.GUIDE_VIDEO_SOURCES = exports.PROJECT_ICON_EXTS = exports.MIRROR_RELS = void 0;
|
|
39
|
+
exports.REFERENCES_SECTIONS = exports.RELATED_MATERIALS_SECTIONS = exports.SEE_ALSO_SECTIONS = exports.RELATED_URL_MAX = exports.RELATED_MATERIALS_FIELD = exports.relatedMaterialsRead = exports.isRelatedUrl = exports.GRAPH_RELS = exports.GRAPH_RECORD_TYPES = exports.GUIDE_VIDEO_SOURCES = exports.PROJECT_ICON_EXTS = exports.MIRROR_RELS = void 0;
|
|
40
40
|
exports.sanitizeBody = sanitizeBody;
|
|
41
41
|
exports.copyHashedAsset = copyHashedAsset;
|
|
42
42
|
exports.buildGuideAssets = buildGuideAssets;
|
|
@@ -45,6 +45,7 @@ exports.readFleetSources = readFleetSources;
|
|
|
45
45
|
exports.orderRecordsByLedgers = orderRecordsByLedgers;
|
|
46
46
|
exports.rawFrontmatterDate = rawFrontmatterDate;
|
|
47
47
|
exports.attachSupersedes = attachSupersedes;
|
|
48
|
+
exports.homeAboutPreviewOf = homeAboutPreviewOf;
|
|
48
49
|
exports.buildHomeGrounding = buildHomeGrounding;
|
|
49
50
|
exports.collectMeetings = collectMeetings;
|
|
50
51
|
exports.findBacklogDir = findBacklogDir;
|
|
@@ -68,6 +69,8 @@ exports.memoryScheduleOf = memoryScheduleOf;
|
|
|
68
69
|
exports.decisionStrandOf = decisionStrandOf;
|
|
69
70
|
exports.decidedByOf = decidedByOf;
|
|
70
71
|
exports.relatedMaterialsView = relatedMaterialsView;
|
|
72
|
+
exports.seeAlsoView = seeAlsoView;
|
|
73
|
+
exports.attachSeeAlso = attachSeeAlso;
|
|
71
74
|
exports.attachRecordReferences = attachRecordReferences;
|
|
72
75
|
exports.attachRelatedMaterials = attachRelatedMaterials;
|
|
73
76
|
exports.createRefResolver = createRefResolver;
|
|
@@ -951,9 +954,9 @@ function attachSupersedes(decisions, rawDateOf = (d) => d.fm.date, pathOf = () =
|
|
|
951
954
|
* (0.12.66 の事故がまさにこの形だった)。必須から並びを組み立てる向きにしておくと、
|
|
952
955
|
* 任意の節を改名しても必須に昇格しない。
|
|
953
956
|
*/
|
|
954
|
-
const HOME_REQUIRED_GROUNDING_HEADINGS = ["このプロジェクトについて"
|
|
957
|
+
const HOME_REQUIRED_GROUNDING_HEADINGS = ["このプロジェクトについて"];
|
|
955
958
|
/** あれば出すが、無くてよい節(未記入の判定には使わない) */
|
|
956
|
-
const HOME_OPTIONAL_GROUNDING_HEADINGS = ["体制"];
|
|
959
|
+
const HOME_OPTIONAL_GROUNDING_HEADINGS = ["ゴール", "体制"];
|
|
957
960
|
/** 新しい形の自己記述の節。画面の最上部に、この並び順で出す */
|
|
958
961
|
const HOME_GROUNDING_HEADINGS = [...HOME_REQUIRED_GROUNDING_HEADINGS, ...HOME_OPTIONAL_GROUNDING_HEADINGS];
|
|
959
962
|
/** 旧い形。1つの節に「解きたいこと」「達成した状態」が同居していた */
|
|
@@ -998,6 +1001,10 @@ function splitByH2(content) {
|
|
|
998
1001
|
function isUnwritten(body) {
|
|
999
1002
|
return PLACEHOLDER.test(body.replace(/<!--[\s\S]*?-->/g, ""));
|
|
1000
1003
|
}
|
|
1004
|
+
/** 節の中身が、注記(HTML コメント)と雛形の穴 `{{…}}` を除くと空白だけか(空の節・雛形のままの節)。文章が 1 文字でも残れば偽 */
|
|
1005
|
+
function groundingSectionUnwritten(body) {
|
|
1006
|
+
return body.replace(/<!--[\s\S]*?(?:-->|$)/g, "").replace(/\{\{[^{}]*\}\}/g, "").trim() === "";
|
|
1007
|
+
}
|
|
1001
1008
|
/** 記憶の更新の最初の開始の門で見る節(オーナー決定 cortex-engine#2305 6571613360・仕様 `common.memory-start`)。必須はこの節だけ */
|
|
1002
1009
|
const HOME_ABOUT_HEADING = "このプロジェクトについて";
|
|
1003
1010
|
/**
|
|
@@ -1006,7 +1013,7 @@ const HOME_ABOUT_HEADING = "このプロジェクトについて";
|
|
|
1006
1013
|
* 🔴 「ゴール」は見ない(未記入の帯 `unfilled` はゴールも要る。門に使うと決定より厳しくなる)。
|
|
1007
1014
|
* 窓口の門(`infra/lambda/intake/config-intent.mjs` の `homeAboutWritten`)と同じ答え(ビューアは lambda を import しないので写し)
|
|
1008
1015
|
*/
|
|
1009
|
-
function
|
|
1016
|
+
function homeAboutSectionOf(content) {
|
|
1010
1017
|
// 🔴 注記は節を切る前に落とす(注記の中の ``` で囲みに入った扱いにしない)。閉じていない注記は末尾まで注記。先頭の BOM も落とす
|
|
1011
1018
|
const text = content.replace(/^\uFEFF/, "").replace(/<!--[\s\S]*?(?:-->|$)/g, "");
|
|
1012
1019
|
let inFence = false;
|
|
@@ -1027,10 +1034,45 @@ function homeAboutUnfilled(content) {
|
|
|
1027
1034
|
if (state === "in")
|
|
1028
1035
|
lines.push(line);
|
|
1029
1036
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1037
|
+
return state === "before" ? null : lines.join("\n").trim();
|
|
1038
|
+
}
|
|
1039
|
+
function homeAboutUnfilled(content) {
|
|
1040
|
+
const body = homeAboutSectionOf(content);
|
|
1041
|
+
return body === null || !body || PLACEHOLDER.test(body);
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* 「このプロジェクトについて」の先頭 1〜2 行(開始前の確かめの画面の ✓ の下・cortex-engine #2838)。プレーンテキスト(画面は textContent で出す)。
|
|
1045
|
+
* 書かれていない(`homeAboutUnfilled`)なら undefined。コードブロックの行・空行は飛ばし、見出し・箇条書き・引用の記号と太字・リンク・コードの記号を剥がす。
|
|
1046
|
+
* 1 行 80 字まで(サロゲートペアを割らず、切ったら「…」)。何も残らなければ undefined(判じ `aboutUnfilled` は変えない)
|
|
1047
|
+
*/
|
|
1048
|
+
function homeAboutPreviewOf(content) {
|
|
1049
|
+
const body = homeAboutSectionOf(content);
|
|
1050
|
+
if (body === null || !body || PLACEHOLDER.test(body))
|
|
1051
|
+
return undefined;
|
|
1052
|
+
const out = [];
|
|
1053
|
+
let inFence = false;
|
|
1054
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
1055
|
+
if (/^\s*(```|~~~)/.test(raw)) {
|
|
1056
|
+
inFence = !inFence;
|
|
1057
|
+
continue;
|
|
1058
|
+
}
|
|
1059
|
+
if (inFence)
|
|
1060
|
+
continue;
|
|
1061
|
+
const t = raw
|
|
1062
|
+
.replace(/^\s*(?:[-*+]\s+|>\s*|#{1,6}\s+|\d+[.)]\s+)/, "")
|
|
1063
|
+
.replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1")
|
|
1064
|
+
.replace(/[*_`~]/g, "")
|
|
1065
|
+
.replace(/<[^>]*>/g, "")
|
|
1066
|
+
.replace(/\s+/g, " ")
|
|
1067
|
+
.trim();
|
|
1068
|
+
if (!t)
|
|
1069
|
+
continue;
|
|
1070
|
+
const chars = Array.from(t);
|
|
1071
|
+
out.push(chars.length > 80 ? chars.slice(0, 80).join("") + "…" : t);
|
|
1072
|
+
if (out.length >= 2)
|
|
1073
|
+
break;
|
|
1074
|
+
}
|
|
1075
|
+
return out.length ? out.join("\n") : undefined;
|
|
1034
1076
|
}
|
|
1035
1077
|
/**
|
|
1036
1078
|
* Home.md から「案件の自己記述」を取り出し、残りの本文と分ける。
|
|
@@ -1054,9 +1096,15 @@ async function buildHomeGrounding(rawMarkdown) {
|
|
|
1054
1096
|
const sections = [];
|
|
1055
1097
|
for (const h of groundingHeadings) {
|
|
1056
1098
|
const hit = find(h);
|
|
1057
|
-
//
|
|
1058
|
-
if (!hit
|
|
1099
|
+
// 節そのものが無ければ出さない(「体制」「ゴール」のように無くてよい節の空の見出しを並べない)
|
|
1100
|
+
if (!hit)
|
|
1101
|
+
continue;
|
|
1102
|
+
// 見出しはあるが中身が空・注記と雛形の穴 `{{…}}` を除くと何も残らない節は、本文を出さず「まだ書かれていません」を出す(便 DREAMING 指示 8)。
|
|
1103
|
+
// 🔴 穴を除いた残りに文章があれば、今までどおり本文を出す(一部だけ埋めた節・例示の穴を隠さない)
|
|
1104
|
+
if (groundingSectionUnwritten(hit.body)) {
|
|
1105
|
+
sections.push({ heading: h, html: "", unwritten: true });
|
|
1059
1106
|
continue;
|
|
1107
|
+
}
|
|
1060
1108
|
sections.push({
|
|
1061
1109
|
heading: h,
|
|
1062
1110
|
html: await renderGroundingSection(hit.body),
|
|
@@ -1065,10 +1113,14 @@ async function buildHomeGrounding(rawMarkdown) {
|
|
|
1065
1113
|
// 未記入の判定。新形式は「このプロジェクトについて」と「ゴール」の2つ、旧形式は1つの節を見る。
|
|
1066
1114
|
// **どちらの節も無ければ未記入。** 節ごと消えているプロジェクトが実在する
|
|
1067
1115
|
const checkHeadings = hasNew ? HOME_REQUIRED_GROUNDING_HEADINGS : [HOME_LEGACY_GROUNDING_HEADING];
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1116
|
+
// 新形式の帯は「このプロジェクトについて」だけを見る(ゴール・体制は空でよい・便 DREAMING 指示 7)。開始の門と同じ判じ(homeAboutUnfilled)に寄せる。旧形式は今のまま
|
|
1117
|
+
// CRLF などで splitByH2 が見出しを拾えなくても、開始の門と同じ読み(homeAboutSectionOf)が節を見つけたら新形式として判じる
|
|
1118
|
+
const unfilled = hasNew || homeAboutSectionOf(content) !== null
|
|
1119
|
+
? homeAboutUnfilled(content)
|
|
1120
|
+
: checkHeadings.some((h) => {
|
|
1121
|
+
const hit = find(h);
|
|
1122
|
+
return !hit || !hit.body.trim() || isUnwritten(hit.body);
|
|
1123
|
+
});
|
|
1072
1124
|
// 残りの本文=自己記述の節と、旧い使い方の説明を除いたもの
|
|
1073
1125
|
// **旧い自己記述は、新形式へ移ったあとも本文から落とす。** 移行の途中で新旧が並ぶと、
|
|
1074
1126
|
// 新しい節を最上部に出したうえで古い節が本文にも出て、どちらが今の説明か分からなくなる
|
|
@@ -1082,7 +1134,7 @@ async function buildHomeGrounding(rawMarkdown) {
|
|
|
1082
1134
|
.map((p) => (p.heading == null ? p.body : `## ${p.heading}\n${p.body}`))
|
|
1083
1135
|
.join("\n");
|
|
1084
1136
|
const restHtml = await renderRecordBody(rest);
|
|
1085
|
-
return { sections, unfilled, aboutUnfilled: homeAboutUnfilled(content), restHtml };
|
|
1137
|
+
return { sections, unfilled, aboutUnfilled: homeAboutUnfilled(content), aboutPreview: homeAboutPreviewOf(content), restHtml };
|
|
1086
1138
|
}
|
|
1087
1139
|
/** パスがディレクトリとして存在するか */
|
|
1088
1140
|
async function isDirectory(dirAbs) {
|
|
@@ -2812,7 +2864,7 @@ async function buildSite(opts, views) {
|
|
|
2812
2864
|
// 自己記述の節を取り出し、**本文からは抜く**(最上部に出すので、残すと2度出る)。
|
|
2813
2865
|
// 旧い使い方の説明もここで落ちる(説明はビューアが持つようになった)
|
|
2814
2866
|
const grounding = await buildHomeGrounding(raw);
|
|
2815
|
-
homeGrounding = { sections: grounding.sections, unfilled: grounding.unfilled, aboutUnfilled: grounding.aboutUnfilled };
|
|
2867
|
+
homeGrounding = { sections: grounding.sections, unfilled: grounding.unfilled, aboutUnfilled: grounding.aboutUnfilled, ...(grounding.aboutPreview ? { aboutPreview: grounding.aboutPreview } : {}) };
|
|
2816
2868
|
home.bodyHtml = grounding.restHtml;
|
|
2817
2869
|
home.searchText = grounding.sections.map((s) => s.heading).join(" ") + " " + home.searchText;
|
|
2818
2870
|
}
|
|
@@ -2850,6 +2902,8 @@ async function buildSite(opts, views) {
|
|
|
2850
2902
|
}
|
|
2851
2903
|
// 関連の資料(cortex-engine #1094 F8)。ルール・用語だけ・欄の無い記録には何も付かない
|
|
2852
2904
|
attachRelatedMaterials(e.name, records, refs);
|
|
2905
|
+
// 参照(see_also・便 S113-9)。用語・関係者だけ・リンクだけ・欄の無い記録には何も付かない
|
|
2906
|
+
attachSeeAlso(e.name, records, refs);
|
|
2853
2907
|
// 根拠(references)。ルール・用語・関係者を決定と同じリンクにする(用語・関係者の移行前の source は先頭の 1 本)
|
|
2854
2908
|
attachRecordReferences(e.name, records, refs);
|
|
2855
2909
|
// 用語集の並び(活性度・強さ)。**帳簿を持たない案件では並びもそのまま**
|
|
@@ -3162,13 +3216,50 @@ function relatedMaterialsView(fm, refs) {
|
|
|
3162
3216
|
const urls = (0, related_materials_field_1.relatedMaterialsRead)(fm);
|
|
3163
3217
|
if (!urls.length)
|
|
3164
3218
|
return undefined;
|
|
3165
|
-
return urls.map((u) =>
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3219
|
+
return urls.map((u) => resolvedNameOf(u, refs));
|
|
3220
|
+
}
|
|
3221
|
+
/** URL 1 本 → 名前つきのリンク(関連の資料と参照が同じ道を通る)。名前は scheme だけ小文字にして引く(根拠の解決は大文字の `HTTPS://` を URL と読まずパスに落とす)。飛び先は書かれたまま */
|
|
3222
|
+
function resolvedNameOf(u, refs) {
|
|
3223
|
+
const q = u.replace(/^https?:/i, (m) => m.toLowerCase());
|
|
3224
|
+
const r = refs.resolve(q);
|
|
3225
|
+
// 名前が引けなければ(解決が引いた文字をそのまま返した)、書かれた URL のまま出す
|
|
3226
|
+
return { label: r.label && r.label !== q ? r.label : u, url: u };
|
|
3227
|
+
}
|
|
3228
|
+
/** 参照(`see_also`・便 S113-9)を持てる区画。用語と関係者だけ(決定・ルール・ストーリー・Home は持たない) */
|
|
3229
|
+
exports.SEE_ALSO_SECTIONS = new Set(["Glossary", "Members"]);
|
|
3230
|
+
/**
|
|
3231
|
+
* 参照の欄 `see_also` → 画面の行(リンクだけ・引用も日付も持たない)。要素は http(s) の URL(関連の資料と同じ門)だけ、
|
|
3232
|
+
* 同じ URL(scheme の大文字小文字は同じ)は先の 1 本、並びは書かれたまま。通る URL が 0 本・欄が無いなら undefined(キーごと載せない)
|
|
3233
|
+
*/
|
|
3234
|
+
function seeAlsoView(fm, refs) {
|
|
3235
|
+
const v = fm && typeof fm === "object" ? fm.see_also : null;
|
|
3236
|
+
if (!Array.isArray(v))
|
|
3237
|
+
return undefined;
|
|
3238
|
+
const seen = new Set();
|
|
3239
|
+
const out = [];
|
|
3240
|
+
for (const x of v) {
|
|
3241
|
+
if (typeof x !== "string")
|
|
3242
|
+
continue;
|
|
3243
|
+
const u = x.trim();
|
|
3244
|
+
if (!(0, related_materials_field_1.isRelatedUrl)(u))
|
|
3245
|
+
continue;
|
|
3246
|
+
const k = u.replace(/^https?:/i, (m) => m.toLowerCase());
|
|
3247
|
+
if (seen.has(k))
|
|
3248
|
+
continue;
|
|
3249
|
+
seen.add(k);
|
|
3250
|
+
out.push(resolvedNameOf(u, refs));
|
|
3251
|
+
}
|
|
3252
|
+
return out.length ? out : undefined;
|
|
3253
|
+
}
|
|
3254
|
+
/** 区画の記録に参照を載せる(用語・関係者だけ・欄の無い記録にはキーごと付けない) */
|
|
3255
|
+
function attachSeeAlso(section, records, refs) {
|
|
3256
|
+
if (!exports.SEE_ALSO_SECTIONS.has(section))
|
|
3257
|
+
return;
|
|
3258
|
+
for (const r of records) {
|
|
3259
|
+
const view = seeAlsoView(r.fm, refs);
|
|
3260
|
+
if (view)
|
|
3261
|
+
r.seeAlso = view;
|
|
3262
|
+
}
|
|
3172
3263
|
}
|
|
3173
3264
|
/** 関連の資料を持てる汎用の区画(関係者・ストーリーの日・Home の欄は拾わない) */
|
|
3174
3265
|
exports.RELATED_MATERIALS_SECTIONS = new Set(["Rules", "Glossary"]);
|