truthmark 1.6.0 → 1.6.1
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/README.de.md +2 -0
- package/README.es.md +2 -0
- package/README.md +2 -0
- package/README.ru.md +2 -0
- package/README.zh.md +2 -0
- package/dist/main.js +333 -88
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/README.de.md
CHANGED
|
@@ -155,6 +155,8 @@ Das installiert oder aktualisiert:
|
|
|
155
155
|
- verwaltete Instruktionsblöcke
|
|
156
156
|
- KI-orientierte Workflow-Oberflächen für konfigurierte Plattformen
|
|
157
157
|
|
|
158
|
+
Die Standardvorlagen für Truth-Dokumente werden in [Template Standards](docs/standards/template-standards.md) begründet. Dort werden sie anerkannten Software-Engineering-Referenzen wie ISO/IEC/IEEE 42010, ISO/IEC/IEEE 29148, ISO/IEC/IEEE 12207, ISO/IEC 25010, C4, arc42, OpenAPI, SemVer, Google SRE und Diátaxis zugeordnet.
|
|
159
|
+
|
|
158
160
|
### Das Setup validieren
|
|
159
161
|
|
|
160
162
|
```bash
|
package/README.es.md
CHANGED
|
@@ -155,6 +155,8 @@ Esto instala o refresca:
|
|
|
155
155
|
- bloques de instrucciones administrados
|
|
156
156
|
- superficies de flujo orientadas a IA para las plataformas configuradas
|
|
157
157
|
|
|
158
|
+
Las plantillas predeterminadas de documentos de verdad se justifican en [Template Standards](docs/standards/template-standards.md), que las mapea a referencias reconocidas de ingeniería de software como ISO/IEC/IEEE 42010, ISO/IEC/IEEE 29148, ISO/IEC/IEEE 12207, ISO/IEC 25010, C4, arc42, OpenAPI, SemVer, Google SRE y Diátaxis.
|
|
159
|
+
|
|
158
160
|
### Validar la configuración
|
|
159
161
|
|
|
160
162
|
```bash
|
package/README.md
CHANGED
|
@@ -155,6 +155,8 @@ This installs or refreshes:
|
|
|
155
155
|
- managed instruction blocks
|
|
156
156
|
- AI-facing workflow surfaces for configured platforms
|
|
157
157
|
|
|
158
|
+
Default truth-doc templates are justified in [Template Standards](docs/standards/template-standards.md), which maps them to recognized software engineering references such as ISO/IEC/IEEE 42010, ISO/IEC/IEEE 29148, ISO/IEC/IEEE 12207, ISO/IEC 25010, C4, arc42, OpenAPI, SemVer, Google SRE, and Diátaxis.
|
|
159
|
+
|
|
158
160
|
### Validate the setup
|
|
159
161
|
|
|
160
162
|
```bash
|
package/README.ru.md
CHANGED
|
@@ -155,6 +155,8 @@ truthmark init
|
|
|
155
155
|
- управляемые блоки инструкций
|
|
156
156
|
- поверхности рабочих процессов для ИИ для настроенных платформ
|
|
157
157
|
|
|
158
|
+
Обоснование стандартных шаблонов документов истины находится в [Template Standards](docs/standards/template-standards.md). В документе показано, как они соотносятся с признанными источниками по инженерии ПО, включая ISO/IEC/IEEE 42010, ISO/IEC/IEEE 29148, ISO/IEC/IEEE 12207, ISO/IEC 25010, C4, arc42, OpenAPI, SemVer, Google SRE и Diátaxis.
|
|
159
|
+
|
|
158
160
|
### Проверить настройку
|
|
159
161
|
|
|
160
162
|
```bash
|
package/README.zh.md
CHANGED
|
@@ -155,6 +155,8 @@ truthmark init
|
|
|
155
155
|
- 受管说明块
|
|
156
156
|
- 已配置平台的面向 AI 工作流表面
|
|
157
157
|
|
|
158
|
+
默认事实文档模板的依据见 [Template Standards](docs/standards/template-standards.md)。该文档说明这些模板如何对齐 ISO/IEC/IEEE 42010、ISO/IEC/IEEE 29148、ISO/IEC/IEEE 12207、ISO/IEC 25010、C4、arc42、OpenAPI、SemVer、Google SRE 和 Diátaxis 等公认软件工程参考。
|
|
159
|
+
|
|
158
160
|
### 验证设置
|
|
159
161
|
|
|
160
162
|
```bash
|
package/dist/main.js
CHANGED
|
@@ -884,6 +884,102 @@ var ARCHITECTURE_DOC_TEMPLATE_PATH = "docs/templates/architecture-doc.md";
|
|
|
884
884
|
var WORKFLOW_DOC_TEMPLATE_PATH = "docs/templates/workflow-doc.md";
|
|
885
885
|
var OPERATIONS_DOC_TEMPLATE_PATH = "docs/templates/operations-doc.md";
|
|
886
886
|
var TEST_BEHAVIOR_DOC_TEMPLATE_PATH = "docs/templates/test-behavior-doc.md";
|
|
887
|
+
var renderTemplateSection = (section) => {
|
|
888
|
+
return [
|
|
889
|
+
section.heading,
|
|
890
|
+
"",
|
|
891
|
+
"<!--",
|
|
892
|
+
...section.guidance,
|
|
893
|
+
"-->",
|
|
894
|
+
"",
|
|
895
|
+
`{{${section.placeholder}}}`,
|
|
896
|
+
""
|
|
897
|
+
];
|
|
898
|
+
};
|
|
899
|
+
var titleToPlaceholder = (title) => {
|
|
900
|
+
return title.replace(/^#+\s+/u, "").toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
901
|
+
};
|
|
902
|
+
var findTemplateSectionHeadings = (template) => {
|
|
903
|
+
const matches = [];
|
|
904
|
+
let fencedCodeMarker = null;
|
|
905
|
+
let fencedCodeLength = 0;
|
|
906
|
+
for (const lineMatch of template.matchAll(/^.*(?:\r?\n|$)/gm)) {
|
|
907
|
+
const rawLine = lineMatch[0];
|
|
908
|
+
if (rawLine.length === 0) {
|
|
909
|
+
continue;
|
|
910
|
+
}
|
|
911
|
+
const line = rawLine.replace(/\r?\n$/u, "");
|
|
912
|
+
const fenceMatch = /^(?: {0,3})(`{3,}|~{3,})/u.exec(line);
|
|
913
|
+
if (fenceMatch) {
|
|
914
|
+
const marker = fenceMatch[1]?.[0];
|
|
915
|
+
const length = fenceMatch[1]?.length ?? 0;
|
|
916
|
+
if (fencedCodeMarker === null) {
|
|
917
|
+
fencedCodeMarker = marker;
|
|
918
|
+
fencedCodeLength = length;
|
|
919
|
+
} else if (marker === fencedCodeMarker && length >= fencedCodeLength) {
|
|
920
|
+
fencedCodeMarker = null;
|
|
921
|
+
fencedCodeLength = 0;
|
|
922
|
+
}
|
|
923
|
+
continue;
|
|
924
|
+
}
|
|
925
|
+
if (fencedCodeMarker === null && /^## .+$/u.test(line)) {
|
|
926
|
+
matches.push({ heading: line.trim(), index: lineMatch.index });
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return matches;
|
|
930
|
+
};
|
|
931
|
+
var parseTemplateSections = (template) => {
|
|
932
|
+
const matches = findTemplateSectionHeadings(template);
|
|
933
|
+
if (matches.length === 0) {
|
|
934
|
+
return { preamble: template.trimEnd(), sections: [] };
|
|
935
|
+
}
|
|
936
|
+
const sections = matches.map((match, index) => {
|
|
937
|
+
const start = match.index;
|
|
938
|
+
const next = matches[index + 1];
|
|
939
|
+
const end = next?.index ?? template.length;
|
|
940
|
+
return {
|
|
941
|
+
heading: match.heading,
|
|
942
|
+
block: template.slice(start, end).trimEnd()
|
|
943
|
+
};
|
|
944
|
+
});
|
|
945
|
+
return {
|
|
946
|
+
preamble: template.slice(0, matches[0]?.index ?? 0).trimEnd(),
|
|
947
|
+
sections
|
|
948
|
+
};
|
|
949
|
+
};
|
|
950
|
+
var mergeTruthDocTemplate = (existingTemplate, defaultTemplate) => {
|
|
951
|
+
if (existingTemplate.trim().length === 0) {
|
|
952
|
+
return defaultTemplate;
|
|
953
|
+
}
|
|
954
|
+
const defaultParsed = parseTemplateSections(defaultTemplate);
|
|
955
|
+
const existingParsed = parseTemplateSections(existingTemplate);
|
|
956
|
+
const defaultHeadings = new Set(defaultParsed.sections.map((section) => section.heading));
|
|
957
|
+
const customBeforeDefault = /* @__PURE__ */ new Map();
|
|
958
|
+
const trailingCustomSections = [];
|
|
959
|
+
existingParsed.sections.forEach((section, index) => {
|
|
960
|
+
if (defaultHeadings.has(section.heading)) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
const nextDefaultSection = existingParsed.sections.slice(index + 1).find((candidate) => defaultHeadings.has(candidate.heading));
|
|
964
|
+
if (nextDefaultSection) {
|
|
965
|
+
const bucket = customBeforeDefault.get(nextDefaultSection.heading) ?? [];
|
|
966
|
+
bucket.push(section);
|
|
967
|
+
customBeforeDefault.set(nextDefaultSection.heading, bucket);
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
trailingCustomSections.push(section);
|
|
971
|
+
});
|
|
972
|
+
const mergedSections = defaultParsed.sections.flatMap((section) => [
|
|
973
|
+
...customBeforeDefault.get(section.heading) ?? [],
|
|
974
|
+
section
|
|
975
|
+
]);
|
|
976
|
+
return [
|
|
977
|
+
existingParsed.preamble,
|
|
978
|
+
...mergedSections.map((section) => section.block),
|
|
979
|
+
...trailingCustomSections.map((section) => section.block),
|
|
980
|
+
""
|
|
981
|
+
].filter((block) => block.length > 0).join("\n\n");
|
|
982
|
+
};
|
|
887
983
|
var renderBehaviorDocTemplateFile = () => {
|
|
888
984
|
return [
|
|
889
985
|
"---",
|
|
@@ -899,81 +995,130 @@ var renderBehaviorDocTemplateFile = () => {
|
|
|
899
995
|
"",
|
|
900
996
|
"## Purpose",
|
|
901
997
|
"",
|
|
902
|
-
"<!--
|
|
998
|
+
"<!--",
|
|
999
|
+
"State the user/system outcome this behavior protects and why it exists.",
|
|
1000
|
+
"Include the problem boundary and durable value; exclude roadmap, implementation plan, and historical narrative.",
|
|
1001
|
+
"List the code, config, docs, or tests that support the claim in source_of_truth rather than prose-only assertion.",
|
|
1002
|
+
"-->",
|
|
903
1003
|
"",
|
|
904
1004
|
"{{purpose}}",
|
|
905
1005
|
"",
|
|
906
1006
|
"## Scope",
|
|
907
1007
|
"",
|
|
908
|
-
"{{scope}}",
|
|
909
|
-
"",
|
|
910
1008
|
"<!--",
|
|
911
|
-
"
|
|
912
|
-
"
|
|
913
|
-
"
|
|
914
|
-
"- a separate lifecycle or state machine",
|
|
915
|
-
"- an unrelated rule family",
|
|
916
|
-
"- a different external contract",
|
|
917
|
-
"- code that should route through a different owner",
|
|
1009
|
+
"Define the one coherent behavior surface this document owns.",
|
|
1010
|
+
"Include in-scope actors, entrypoints, state/data owned by this doc, and explicit handoffs to neighboring truth docs.",
|
|
1011
|
+
"Split into another leaf doc when content introduces a distinct outcome, state machine, rule family, external contract, or route owner.",
|
|
918
1012
|
"Keep README.md files as indexes only.",
|
|
919
1013
|
"-->",
|
|
920
1014
|
"",
|
|
1015
|
+
"{{scope}}",
|
|
1016
|
+
"",
|
|
921
1017
|
"This doc was created from the editable behavior-doc template at {{template_path}}.",
|
|
922
1018
|
"",
|
|
923
1019
|
"## Current Behavior",
|
|
924
1020
|
"",
|
|
925
|
-
"<!--
|
|
1021
|
+
"<!--",
|
|
1022
|
+
"Describe only current implemented behavior in present tense.",
|
|
1023
|
+
"Cover observable behavior, important defaults, and user/system-visible effects; exclude desired future behavior and speculative design.",
|
|
1024
|
+
"Every non-obvious claim should be checkable from source_of_truth evidence.",
|
|
1025
|
+
"-->",
|
|
926
1026
|
"",
|
|
927
1027
|
"{{current_behavior}}",
|
|
928
1028
|
"",
|
|
929
1029
|
"## Core Rules",
|
|
930
1030
|
"",
|
|
931
|
-
"<!--
|
|
1031
|
+
"<!--",
|
|
1032
|
+
"Capture stable business rules, invariants, precedence rules, validation rules, and must-never constraints.",
|
|
1033
|
+
"Separate rules from incidental implementation details; cite current implementation or tests for rule enforcement.",
|
|
1034
|
+
"-->",
|
|
932
1035
|
"",
|
|
933
1036
|
"{{core_rules}}",
|
|
934
1037
|
"",
|
|
935
1038
|
"## Flows And States",
|
|
936
1039
|
"",
|
|
937
|
-
"<!--
|
|
1040
|
+
"<!--",
|
|
1041
|
+
"Document state transitions, lifecycle stages, retries, fallbacks, route switches, and important error paths.",
|
|
1042
|
+
"State 'None beyond current behavior.' when this behavior has no distinct flow or state model.",
|
|
1043
|
+
"-->",
|
|
938
1044
|
"",
|
|
939
1045
|
"{{flows_and_states}}",
|
|
940
1046
|
"",
|
|
941
1047
|
"## Contracts",
|
|
942
1048
|
"",
|
|
943
|
-
"<!--
|
|
1049
|
+
"<!--",
|
|
1050
|
+
"Capture user-visible or integration contracts: CLI/API shape, inputs, outputs, diagnostics, files, events, permissions, or links to canonical contract docs.",
|
|
1051
|
+
"Avoid duplicating a separate canonical contract doc; link to it when contract ownership lives elsewhere.",
|
|
1052
|
+
"-->",
|
|
944
1053
|
"",
|
|
945
1054
|
"{{contracts}}",
|
|
946
1055
|
"",
|
|
947
1056
|
"## Product Decisions",
|
|
948
1057
|
"",
|
|
949
|
-
"<!--
|
|
1058
|
+
"<!--",
|
|
1059
|
+
"Keep active decisions only, dated inline when added or changed.",
|
|
1060
|
+
"Explain decisions that shape behavior, boundaries, rejected alternatives, or migration constraints; replace stale decisions instead of appending historical logs.",
|
|
1061
|
+
"-->",
|
|
950
1062
|
"",
|
|
951
1063
|
"{{decision}}",
|
|
952
1064
|
"",
|
|
953
1065
|
"## Rationale",
|
|
954
1066
|
"",
|
|
955
|
-
"<!--
|
|
1067
|
+
"<!--",
|
|
1068
|
+
"Explain why the current behavior and active decisions are this way, including tradeoffs and constraints.",
|
|
1069
|
+
"Tie rationale to evidence-backed behavior; do not use this as a changelog.",
|
|
1070
|
+
"-->",
|
|
956
1071
|
"",
|
|
957
1072
|
"{{rationale}}",
|
|
958
1073
|
"",
|
|
959
1074
|
"## Non-Goals",
|
|
960
1075
|
"",
|
|
961
|
-
"<!--
|
|
1076
|
+
"<!--",
|
|
1077
|
+
"Name adjacent behavior this doc intentionally does not own, especially tempting future expansions or neighboring route owners.",
|
|
1078
|
+
"Use this section to prevent scope creep and duplicate truth ownership.",
|
|
1079
|
+
"-->",
|
|
962
1080
|
"",
|
|
963
1081
|
"{{non_goals}}",
|
|
964
1082
|
"",
|
|
965
1083
|
"## Maintenance Notes",
|
|
966
1084
|
"",
|
|
967
|
-
"<!--
|
|
1085
|
+
"<!--",
|
|
1086
|
+
"List related tests, routing cautions, migration notes, evidence drift risks, and review triggers for future maintainers or agents.",
|
|
1087
|
+
"Keep this operational and current-state focused, not historical.",
|
|
1088
|
+
"-->",
|
|
968
1089
|
"",
|
|
969
1090
|
"{{maintenance_notes}}",
|
|
970
1091
|
""
|
|
971
1092
|
].join("\n");
|
|
972
1093
|
};
|
|
1094
|
+
var sectionSpec = (heading, guidance, placeholder = titleToPlaceholder(heading)) => ({ heading, guidance, placeholder });
|
|
1095
|
+
var PURPOSE_SECTION = sectionSpec("## Purpose", [
|
|
1096
|
+
"State the software-engineering outcome this document protects and why the documented surface exists.",
|
|
1097
|
+
"Include durable value, impacted users/systems, and the problem boundary; exclude roadmap, implementation plans, and historical narrative.",
|
|
1098
|
+
"Keep claims traceable to source_of_truth evidence rather than prose-only assertion."
|
|
1099
|
+
]);
|
|
1100
|
+
var SCOPE_SECTION = sectionSpec("## Scope", [
|
|
1101
|
+
"Define the one coherent surface this document owns, including actors, entrypoints, owned state/data, and handoffs to neighboring truth docs.",
|
|
1102
|
+
"Call out important out-of-scope boundaries here or in Non-Goals; split the doc when it mixes distinct outcomes, lifecycles, contracts, or owners."
|
|
1103
|
+
]);
|
|
1104
|
+
var PRODUCT_DECISIONS_SECTION = sectionSpec("## Product Decisions", [
|
|
1105
|
+
"Keep active decisions only, dated inline when added or changed.",
|
|
1106
|
+
"Capture decisions that shape behavior, interfaces, boundaries, compatibility, risk acceptance, or migration constraints.",
|
|
1107
|
+
"Replace stale decisions instead of appending historical logs."
|
|
1108
|
+
], "decision");
|
|
1109
|
+
var RATIONALE_SECTION = sectionSpec("## Rationale", [
|
|
1110
|
+
"Explain why the current behavior, structure, or contract is this way, including tradeoffs and constraints.",
|
|
1111
|
+
"Tie rationale to evidence-backed facts and active decisions; do not use this as a changelog."
|
|
1112
|
+
]);
|
|
1113
|
+
var NON_GOALS_SECTION = sectionSpec("## Non-Goals", [
|
|
1114
|
+
"Name adjacent behavior, responsibilities, interfaces, or future expansions this doc intentionally does not own.",
|
|
1115
|
+
"Use this section to prevent scope creep and duplicate truth ownership."
|
|
1116
|
+
]);
|
|
1117
|
+
var MAINTENANCE_NOTES_SECTION = sectionSpec("## Maintenance Notes", [
|
|
1118
|
+
"List related tests, routing cautions, migration notes, compatibility risks, evidence drift risks, and review triggers for future maintainers or agents.",
|
|
1119
|
+
"Keep this operational and current-state focused, not historical."
|
|
1120
|
+
]);
|
|
973
1121
|
var renderTypedTruthDocTemplate = (truthKind, docType, title, sections) => {
|
|
974
|
-
const placeholderNameForSection = (section) => {
|
|
975
|
-
return section.replace(/^#+\s+/u, "").toLowerCase().replaceAll(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
976
|
-
};
|
|
977
1122
|
return [
|
|
978
1123
|
"---",
|
|
979
1124
|
"status: active",
|
|
@@ -986,86 +1131,153 @@ var renderTypedTruthDocTemplate = (truthKind, docType, title, sections) => {
|
|
|
986
1131
|
"",
|
|
987
1132
|
`# ${title}`,
|
|
988
1133
|
"",
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
"",
|
|
997
|
-
...sections.flatMap((section) => [
|
|
998
|
-
section,
|
|
999
|
-
"",
|
|
1000
|
-
`{{${placeholderNameForSection(section)}}}`,
|
|
1001
|
-
""
|
|
1002
|
-
]),
|
|
1003
|
-
"## Product Decisions",
|
|
1004
|
-
"",
|
|
1005
|
-
"{{decision}}",
|
|
1006
|
-
"",
|
|
1007
|
-
"## Rationale",
|
|
1008
|
-
"",
|
|
1009
|
-
"{{rationale}}",
|
|
1010
|
-
"",
|
|
1011
|
-
"## Non-Goals",
|
|
1012
|
-
"",
|
|
1013
|
-
"{{non_goals}}",
|
|
1014
|
-
"",
|
|
1015
|
-
"## Maintenance Notes",
|
|
1016
|
-
"",
|
|
1017
|
-
"{{maintenance_notes}}",
|
|
1018
|
-
""
|
|
1134
|
+
...renderTemplateSection(PURPOSE_SECTION),
|
|
1135
|
+
...renderTemplateSection(SCOPE_SECTION),
|
|
1136
|
+
...sections.flatMap(renderTemplateSection),
|
|
1137
|
+
...renderTemplateSection(PRODUCT_DECISIONS_SECTION),
|
|
1138
|
+
...renderTemplateSection(RATIONALE_SECTION),
|
|
1139
|
+
...renderTemplateSection(NON_GOALS_SECTION),
|
|
1140
|
+
...renderTemplateSection(MAINTENANCE_NOTES_SECTION)
|
|
1019
1141
|
].join("\n");
|
|
1020
1142
|
};
|
|
1021
1143
|
var renderContractDocTemplateFile = () => {
|
|
1022
1144
|
return renderTypedTruthDocTemplate("contract", "contract", "{{title}}", [
|
|
1023
|
-
"## Contract Surface",
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
"##
|
|
1028
|
-
|
|
1145
|
+
sectionSpec("## Contract Surface", [
|
|
1146
|
+
"Identify the owned API, CLI, file format, event, protocol, permission boundary, or integration surface.",
|
|
1147
|
+
"State consumers/producers, stability level, and the source files/tests that define the contract."
|
|
1148
|
+
]),
|
|
1149
|
+
sectionSpec("## Inputs", [
|
|
1150
|
+
"Document accepted parameters, payloads, files, environment/config keys, permissions, and validation rules.",
|
|
1151
|
+
"Include required/optional status, defaults, constraints, and normalization behavior."
|
|
1152
|
+
]),
|
|
1153
|
+
sectionSpec("## Outputs", [
|
|
1154
|
+
"Document returned values, emitted files/events, state changes, side effects, and success diagnostics.",
|
|
1155
|
+
"Make externally observable behavior explicit enough for compatibility review."
|
|
1156
|
+
]),
|
|
1157
|
+
sectionSpec("## Errors And Diagnostics", [
|
|
1158
|
+
"List error classes, exit/status codes, user-facing diagnostics, retries, and recoverability expectations.",
|
|
1159
|
+
"Distinguish validation errors, dependency failures, authorization failures, and internal faults when applicable."
|
|
1160
|
+
]),
|
|
1161
|
+
sectionSpec("## Compatibility Rules", [
|
|
1162
|
+
"State backward/forward compatibility guarantees, tolerated inputs, deprecation rules, and breaking-change triggers.",
|
|
1163
|
+
"Include compatibility tests or review gates that protect the contract."
|
|
1164
|
+
]),
|
|
1165
|
+
sectionSpec("## Versioning And Migration", [
|
|
1166
|
+
"Document version negotiation, schema/API version fields, rollout requirements, migration steps, and rollback expectations.",
|
|
1167
|
+
"State 'Not versioned' only when the implementation truly has no versioning or migration surface."
|
|
1168
|
+
])
|
|
1029
1169
|
]);
|
|
1030
1170
|
};
|
|
1031
1171
|
var renderArchitectureDocTemplateFile = () => {
|
|
1032
1172
|
return renderTypedTruthDocTemplate("architecture", "architecture", "{{title}}", [
|
|
1033
|
-
"## System Role",
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
"##
|
|
1038
|
-
|
|
1173
|
+
sectionSpec("## System Role", [
|
|
1174
|
+
"Describe the current architectural role of this subsystem/component in the larger system.",
|
|
1175
|
+
"State the primary responsibilities, consumers, providers, and why this boundary exists now."
|
|
1176
|
+
]),
|
|
1177
|
+
sectionSpec("## Boundaries", [
|
|
1178
|
+
"Define owned code/config/data, external dependencies, trust boundaries, and interfaces crossed by this architecture.",
|
|
1179
|
+
"Name what is deliberately outside the boundary and link neighboring architecture or contract docs when they own it."
|
|
1180
|
+
]),
|
|
1181
|
+
sectionSpec("## Components", [
|
|
1182
|
+
"List the major runtime/build-time components, modules, services, jobs, or generated artifacts and their responsibilities.",
|
|
1183
|
+
"Keep the component list current and evidence-backed; avoid speculative target architecture."
|
|
1184
|
+
]),
|
|
1185
|
+
sectionSpec("## Data And Control Flow", [
|
|
1186
|
+
"Describe important data movement, command/control paths, synchronization points, state ownership, and failure paths.",
|
|
1187
|
+
"Call out persistence, queues, caches, external calls, and security-sensitive transitions where relevant."
|
|
1188
|
+
]),
|
|
1189
|
+
sectionSpec("## Ownership", [
|
|
1190
|
+
"Document team/module ownership, review responsibility, operational responsibility, and escalation paths if known.",
|
|
1191
|
+
"If ownership is inferred from codeowners, config, or repository structure, cite that evidence."
|
|
1192
|
+
]),
|
|
1193
|
+
sectionSpec("## Cross-Cutting Constraints", [
|
|
1194
|
+
"Record active constraints such as security, privacy, reliability, performance, portability, maintainability, compliance, and cost.",
|
|
1195
|
+
"Tie constraints to source evidence, tests, standards, or operational requirements where available."
|
|
1196
|
+
])
|
|
1039
1197
|
]);
|
|
1040
1198
|
};
|
|
1041
1199
|
var renderWorkflowDocTemplateFile = () => {
|
|
1042
1200
|
return renderTypedTruthDocTemplate("workflow", "behavior", "{{title}}", [
|
|
1043
|
-
"## Triggers",
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
"##
|
|
1048
|
-
|
|
1201
|
+
sectionSpec("## Triggers", [
|
|
1202
|
+
"List events, commands, schedules, user actions, webhooks, or dependency signals that start this workflow.",
|
|
1203
|
+
"Include preconditions, authorization requirements, debounce/coalescing behavior, and disabled states when applicable."
|
|
1204
|
+
]),
|
|
1205
|
+
sectionSpec("## Inputs", [
|
|
1206
|
+
"Document data, files, config, context, credentials, and environmental assumptions consumed by the workflow.",
|
|
1207
|
+
"Include validation, defaults, and normalization that happen before execution."
|
|
1208
|
+
]),
|
|
1209
|
+
sectionSpec("## Execution Model", [
|
|
1210
|
+
"Describe synchronous/asynchronous execution, concurrency, locking, leases, batching, ordering, and idempotency behavior.",
|
|
1211
|
+
"State whether the workflow is user-blocking, background, distributed, or delegated to another system."
|
|
1212
|
+
]),
|
|
1213
|
+
sectionSpec("## Steps", [
|
|
1214
|
+
"Capture the current ordered steps or phases at a level useful for maintenance and review.",
|
|
1215
|
+
"Reference implementation entrypoints instead of duplicating line-by-line code behavior."
|
|
1216
|
+
]),
|
|
1217
|
+
sectionSpec("## State, Retry, And Failure Behavior", [
|
|
1218
|
+
"Document state transitions, retries, timeouts, compensation, fallback, partial-success, and terminal-failure behavior.",
|
|
1219
|
+
"Make externally visible failure semantics and recovery responsibilities clear."
|
|
1220
|
+
]),
|
|
1221
|
+
sectionSpec("## Outputs", [
|
|
1222
|
+
"List artifacts, state changes, notifications, logs, metrics, diagnostics, and downstream triggers produced by the workflow.",
|
|
1223
|
+
"Include success criteria and handoff points to other truth docs or systems."
|
|
1224
|
+
])
|
|
1049
1225
|
]);
|
|
1050
1226
|
};
|
|
1051
1227
|
var renderOperationsDocTemplateFile = () => {
|
|
1052
1228
|
return renderTypedTruthDocTemplate("operations", "behavior", "{{title}}", [
|
|
1053
|
-
"## Operational Surface",
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
"##
|
|
1058
|
-
|
|
1229
|
+
sectionSpec("## Operational Surface", [
|
|
1230
|
+
"Describe what operators, maintainers, or automated systems can observe or control for this surface.",
|
|
1231
|
+
"Include commands, dashboards, alerts, runbooks, jobs, or operational APIs that define current operations."
|
|
1232
|
+
]),
|
|
1233
|
+
sectionSpec("## Runtime Topology", [
|
|
1234
|
+
"Document services, processes, containers, hosts, regions, dependencies, queues, stores, and network boundaries involved at runtime.",
|
|
1235
|
+
"State single-node/local behavior explicitly when there is no distributed topology."
|
|
1236
|
+
]),
|
|
1237
|
+
sectionSpec("## Configuration", [
|
|
1238
|
+
"List operational config, environment variables, feature flags, secrets references, defaults, and reload/restart requirements.",
|
|
1239
|
+
"Do not include secret values; describe storage and rotation expectations instead."
|
|
1240
|
+
]),
|
|
1241
|
+
sectionSpec("## Permissions", [
|
|
1242
|
+
"Document required identities, roles, scopes, filesystem/network permissions, and least-privilege boundaries.",
|
|
1243
|
+
"Include user-facing authorization behavior and operator access requirements when relevant."
|
|
1244
|
+
]),
|
|
1245
|
+
sectionSpec("## Deployment And Rollback", [
|
|
1246
|
+
"Describe deployment mechanism, migration ordering, compatibility windows, rollback path, and known irreversible operations.",
|
|
1247
|
+
"Call out manual gates, smoke checks, and post-deploy verification responsibilities."
|
|
1248
|
+
]),
|
|
1249
|
+
sectionSpec("## Availability And Observability", [
|
|
1250
|
+
"Capture availability expectations, health checks, metrics, logs, traces, alerts, SLO/error-budget signals, and known blind spots.",
|
|
1251
|
+
"Include what maintainers should inspect first during incidents or degraded behavior."
|
|
1252
|
+
])
|
|
1059
1253
|
]);
|
|
1060
1254
|
};
|
|
1061
1255
|
var renderTestBehaviorDocTemplateFile = () => {
|
|
1062
1256
|
return renderTypedTruthDocTemplate("test-behavior", "behavior", "{{title}}", [
|
|
1063
|
-
"## Test Surface",
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
"##
|
|
1068
|
-
|
|
1257
|
+
sectionSpec("## Test Surface", [
|
|
1258
|
+
"Define the behavior, contract, architecture, or workflow surface these tests verify.",
|
|
1259
|
+
"Link the canonical truth docs and code paths the tests are meant to protect."
|
|
1260
|
+
]),
|
|
1261
|
+
sectionSpec("## Fixtures And Data Model", [
|
|
1262
|
+
"Document fixtures, factories, seeds, mocks/fakes, test repositories, external-service substitutes, and data lifecycle rules.",
|
|
1263
|
+
"Include cleanup, determinism, privacy, and cross-test contamination constraints."
|
|
1264
|
+
]),
|
|
1265
|
+
sectionSpec("## Execution Model", [
|
|
1266
|
+
"Describe how tests run: command, framework, parallelism, isolation, network/filesystem assumptions, and required services.",
|
|
1267
|
+
"State whether tests are unit, integration, e2e, contract, smoke, regression, or generated checks."
|
|
1268
|
+
]),
|
|
1269
|
+
sectionSpec("## Assertions And Invariants", [
|
|
1270
|
+
"List the critical assertions, invariants, failure modes, and negative cases that make the tests meaningful.",
|
|
1271
|
+
"Tie assertions to product/contract rules rather than incidental implementation details."
|
|
1272
|
+
]),
|
|
1273
|
+
sectionSpec("## Isolation Rules", [
|
|
1274
|
+
"Document transaction boundaries, temp directories, fake clocks, network blocking, shared resources, and teardown rules.",
|
|
1275
|
+
"Call out known order dependencies or flake risks and how they are controlled."
|
|
1276
|
+
]),
|
|
1277
|
+
sectionSpec("## Reporting And Failure Semantics", [
|
|
1278
|
+
"Describe diagnostics, snapshots, logs, coverage signals, retry policy, and how maintainers should interpret failures.",
|
|
1279
|
+
"Include escalation or quarantine criteria for flaky or environment-sensitive tests."
|
|
1280
|
+
])
|
|
1069
1281
|
]);
|
|
1070
1282
|
};
|
|
1071
1283
|
var renderTemplate = (template, values) => {
|
|
@@ -1394,6 +1606,15 @@ var readBehaviorDocTemplate = async (rootDir) => {
|
|
|
1394
1606
|
throw error;
|
|
1395
1607
|
}
|
|
1396
1608
|
};
|
|
1609
|
+
var ensureOrUpdateTruthDocTemplate = async (rootDir, templatePath, defaultTemplate) => {
|
|
1610
|
+
const seededResult = await ensureRepoFile(rootDir, templatePath, defaultTemplate);
|
|
1611
|
+
if (seededResult.status !== "unchanged") {
|
|
1612
|
+
return seededResult;
|
|
1613
|
+
}
|
|
1614
|
+
const existingTemplate = await fs5.readFile(resolveRepoPath(rootDir, templatePath), "utf8");
|
|
1615
|
+
const mergedTemplate = mergeTruthDocTemplate(existingTemplate, defaultTemplate);
|
|
1616
|
+
return writeRepoFile(rootDir, templatePath, mergedTemplate);
|
|
1617
|
+
};
|
|
1397
1618
|
var scaffoldHierarchy = async (rootDir, config) => {
|
|
1398
1619
|
const results = [];
|
|
1399
1620
|
const truthDocsRoot = truthRoot2(config);
|
|
@@ -1424,26 +1645,42 @@ var scaffoldHierarchy = async (rootDir, config) => {
|
|
|
1424
1645
|
)
|
|
1425
1646
|
);
|
|
1426
1647
|
results.push(
|
|
1427
|
-
await
|
|
1648
|
+
await ensureOrUpdateTruthDocTemplate(
|
|
1649
|
+
rootDir,
|
|
1650
|
+
BEHAVIOR_DOC_TEMPLATE_PATH,
|
|
1651
|
+
renderBehaviorDocTemplateFile()
|
|
1652
|
+
)
|
|
1428
1653
|
);
|
|
1429
1654
|
results.push(
|
|
1430
|
-
await
|
|
1655
|
+
await ensureOrUpdateTruthDocTemplate(
|
|
1656
|
+
rootDir,
|
|
1657
|
+
CONTRACT_DOC_TEMPLATE_PATH,
|
|
1658
|
+
renderContractDocTemplateFile()
|
|
1659
|
+
)
|
|
1431
1660
|
);
|
|
1432
1661
|
results.push(
|
|
1433
|
-
await
|
|
1662
|
+
await ensureOrUpdateTruthDocTemplate(
|
|
1434
1663
|
rootDir,
|
|
1435
1664
|
ARCHITECTURE_DOC_TEMPLATE_PATH,
|
|
1436
1665
|
renderArchitectureDocTemplateFile()
|
|
1437
1666
|
)
|
|
1438
1667
|
);
|
|
1439
1668
|
results.push(
|
|
1440
|
-
await
|
|
1669
|
+
await ensureOrUpdateTruthDocTemplate(
|
|
1670
|
+
rootDir,
|
|
1671
|
+
WORKFLOW_DOC_TEMPLATE_PATH,
|
|
1672
|
+
renderWorkflowDocTemplateFile()
|
|
1673
|
+
)
|
|
1441
1674
|
);
|
|
1442
1675
|
results.push(
|
|
1443
|
-
await
|
|
1676
|
+
await ensureOrUpdateTruthDocTemplate(
|
|
1677
|
+
rootDir,
|
|
1678
|
+
OPERATIONS_DOC_TEMPLATE_PATH,
|
|
1679
|
+
renderOperationsDocTemplateFile()
|
|
1680
|
+
)
|
|
1444
1681
|
);
|
|
1445
1682
|
results.push(
|
|
1446
|
-
await
|
|
1683
|
+
await ensureOrUpdateTruthDocTemplate(
|
|
1447
1684
|
rootDir,
|
|
1448
1685
|
TEST_BEHAVIOR_DOC_TEMPLATE_PATH,
|
|
1449
1686
|
renderTestBehaviorDocTemplateFile()
|
|
@@ -1523,7 +1760,8 @@ var REPOSITORY_INTELLIGENCE_INSTRUCTIONS = [
|
|
|
1523
1760
|
var FEATURE_DOC_TEMPLATE_INSTRUCTIONS = [
|
|
1524
1761
|
"When creating or updating a truth doc, inspect the routed truth kind and use the matching `docs/templates/<kind>-doc.md` template.",
|
|
1525
1762
|
"Supported kinds: behavior, contract, architecture, workflow, operations, and test-behavior.",
|
|
1526
|
-
"
|
|
1763
|
+
"Treat the HTML comments under each template section as normative authoring guidance for that section.",
|
|
1764
|
+
"Align existing docs to that template and write or repair section content so it satisfies the comment guidance while preserving accurate authored content.",
|
|
1527
1765
|
"If the template is missing, use Scope, Product Decisions, Rationale, and the kind-specific current-truth section.",
|
|
1528
1766
|
"Teams may edit the template files under docs/templates/ to define their local truth-doc standards."
|
|
1529
1767
|
].join("\n");
|
|
@@ -7508,14 +7746,21 @@ var runContext = async (options) => {
|
|
|
7508
7746
|
};
|
|
7509
7747
|
|
|
7510
7748
|
// src/cli/program.ts
|
|
7749
|
+
var markFailedWhenErrorDiagnosticsExist = (result) => {
|
|
7750
|
+
if (result.diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
7751
|
+
process.exitCode = 1;
|
|
7752
|
+
}
|
|
7753
|
+
};
|
|
7511
7754
|
var writeResult = (result, options) => {
|
|
7512
7755
|
const output = options.json ? renderJson(result) : renderHuman(result);
|
|
7513
7756
|
process.stdout.write(`${output}
|
|
7514
7757
|
`);
|
|
7758
|
+
markFailedWhenErrorDiagnosticsExist(result);
|
|
7515
7759
|
};
|
|
7516
7760
|
var writeContextResult = (result, options) => {
|
|
7517
7761
|
if (!options.json && options.format === "markdown" && typeof result.data?.markdown === "string") {
|
|
7518
7762
|
process.stdout.write(result.data.markdown);
|
|
7763
|
+
markFailedWhenErrorDiagnosticsExist(result);
|
|
7519
7764
|
return;
|
|
7520
7765
|
}
|
|
7521
7766
|
writeResult(result, options);
|