@1aboveio/core-skills 0.1.7 → 0.1.9
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/package.json +2 -2
- package/skills/distill-writing/SKILL.md +1 -1
- package/skills/distill-writing/release-check.mjs +3 -1
- package/skills/doc-to-md/SKILL.md +1 -1
- package/skills/doc-to-md/release-check.mjs +3 -1
- package/skills/editorial-review/SKILL.md +1 -1
- package/skills/editorial-review/release-check.mjs +3 -1
- package/skills/house-style/SKILL.md +1 -1
- package/skills/house-style/release-check.mjs +3 -1
- package/skills/plain-language/SKILL.md +1 -1
- package/skills/plain-language/release-check.mjs +3 -1
- package/skills/polish-cn/SKILL.md +1 -1
- package/skills/polish-cn/release-check.mjs +3 -1
- package/skills/reg-parser/SKILL.md +1 -1
- package/skills/reg-parser/release-check.mjs +3 -1
- package/skills/terminology/SKILL.md +1 -1
- package/skills/terminology/release-check.mjs +3 -1
- package/skills/write-doc/SKILL.md +1 -1
- package/skills/write-doc/release-check.mjs +3 -1
- package/skills/polish-cn/scripts/polish-cn.test.mjs +0 -244
- package/skills/reg-parser/scripts/reg-parser.test.mjs +0 -165
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1aboveio/core-skills",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Shared writing and document foundation: house style, plain-language replies, editorial review, Chinese polish, terminology, write-doc, distill-writing, doc-to-md and reg-parser.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"id": "core",
|
|
28
28
|
"core": "@1aboveio/core-skills",
|
|
29
29
|
"coreSkills": [],
|
|
30
|
-
"digest": "
|
|
30
|
+
"digest": "1a41caaf8387fce0fc51947835198adf97bcad54060067370824fdf8900b94eb"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: distill-writing
|
|
3
3
|
description: "Learn a house writing style from approved sample documents, or save an explicitly stated project document preference, into WRITING.md and writing/templates/. Use for sample-based style learning, house-style setup or refresh, and requests such as 'remember this for future PRDs' or 'make this our report default', including handoffs from write-doc or plain-language. Preserve manual edits and separate document types. NOT for drafting a document (write-doc) or saving chat-only preferences (plain-language)."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# Distill a writing style
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: doc-to-md
|
|
3
3
|
description: "Convert documents (PDF, DOCX, PPTX, XLSX, images) to Markdown so agents can read them. Use as the preprocessing step whenever binary files need to enter agent context — contract review, compliance audit, document analysis, evidence review."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# doc-to-md
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: editorial-review
|
|
3
3
|
description: "Review a document or generated report for what it says (does the reader get the answer, is the argument sound, is anything unsupported, obvious or repeated), then fix the content. Use to review, tighten or clarify a doc or report, and as the review step of write-doc and the report skills. NOT for Chinese wording (polish-cn) or code review (better-review)."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# Editorial review
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -3,7 +3,7 @@ name: house-style
|
|
|
3
3
|
description: "Shared reference the writing skills read by path: WRITING.md lookup and precedence, template choice, gap markers, template shape, the bundled templates, and the default English and Chinese style guides. Never select or invoke it as a task."
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
user-invocable: false
|
|
6
|
-
release-version: 0.
|
|
6
|
+
release-version: 0.44.0
|
|
7
7
|
---
|
|
8
8
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
9
9
|
# House style
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: plain-language
|
|
3
3
|
description: "Session mode: every reply and status line in plain language — lead with the point, everyday words, full sentences, no filler — in English or Chinese, until turned off. Enable by default when the project has an applicable WRITING.md, even without a slash command. Use for /plain-language, 'talk plainly', '说人话', and explicit requests to remember project reply preferences; /plain-language init persists the default and loading instructions. Save reply rules only under Agent replies; route document preferences to distill-writing. Ordinary mode toggles remain session-only. Turn off with '/plain-language off' or 'normal mode'. NOT for writing a document (write-doc) or reviewing one (editorial-review)."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# Plain language
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: polish-cn
|
|
3
3
|
description: "Polish the Chinese wording of a finished document or report, with a script proving every number, date, identifier, link and protected term is unchanged; prefers a Chinese model and records which ran. Use for '中文润色' or as a report skill's last step. NOT for cutting or restructuring content (editorial-review) or translating (write-doc)."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# Polish Chinese
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: reg-parser
|
|
3
3
|
version: 1.1.0
|
|
4
4
|
description: "Parse regulatory/scheme documents into structured outputs: convert a regulation (AML, VARS, PCI-DSS, KYC, GDPR) into an audit-ready compliance checklist, or trace contract clauses to a mandate source. Suggest proactively when a regulation PDF accompanies a contract review or compliance task. NOT general summarization (doc-to-md), or writing the gap analysis or policy from the checklist (write-doc)."
|
|
5
|
-
release-version: 0.
|
|
5
|
+
release-version: 0.44.0
|
|
6
6
|
---
|
|
7
7
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
8
8
|
# reg-parser
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: terminology
|
|
3
3
|
description: "Build and keep a project's TERMINOLOGY.md: the preferred term per concept in English, 简体 and 繁體, and the terms to avoid. Use to set it up from the project's documents, when the user settles or corrects a term, or when another writing skill needs the format. NOT for writing documents (write-doc) or the code domain model (domain-modeling)."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# Terminology
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: write-doc
|
|
3
3
|
description: "Write or edit documents and compliance reports in the project's house style: BRD, PRD, gap analysis, technical spec, integration guide, proposal, policy, risk procedure, audit report, external assessment, management report or Visa VARS Review Report; English, Chinese or bilingual. Use automatically whenever asked to draft, write, revise or edit a document, without needing a slash command, including 'write up the findings'. Route explicit requests to remember a writing preference to its persistence owner. Markdown by default; export when requested. NOT for ordinary chat replies (plain-language), learning style from samples or preference-only saves (distill-writing), performing an audit (compliance-audit), or WeChat articles (wechat-article-writer)."
|
|
4
|
-
release-version: 0.
|
|
4
|
+
release-version: 0.44.0
|
|
5
5
|
---
|
|
6
6
|
**Updates:** Once/session run `node <skill-base-dir>/release-check.mjs`.
|
|
7
7
|
# Write a document
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
5
|
+
import { dirname, join, resolve } from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
7
|
|
|
8
8
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
@@ -46,6 +46,8 @@ function writeCache(path, value) {
|
|
|
46
46
|
|
|
47
47
|
function main(now = Date.now()) {
|
|
48
48
|
if (process.env.ONEABOVEIO_NO_UPDATE_CHECK) return;
|
|
49
|
+
const bundle = readJson(join(resolve(here, '../../..'), 'package.json'));
|
|
50
|
+
if (bundle.name === '@1aboveio/skills' && bundle.nativeCodex?.schemaVersion === 1) return;
|
|
49
51
|
const skill = readFileSync(join(here, 'SKILL.md'), 'utf8');
|
|
50
52
|
const name = frontmatterValue(skill, 'name');
|
|
51
53
|
const localVersion = stableVersion(frontmatterValue(skill, 'release-version'));
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import test from 'node:test';
|
|
8
|
-
|
|
9
|
-
const script = join(dirname(fileURLToPath(import.meta.url)), 'polish_blocks.py');
|
|
10
|
-
|
|
11
|
-
const REPORT = `---
|
|
12
|
-
title: 月报
|
|
13
|
-
---
|
|
14
|
-
# 2026 年 10 月报告
|
|
15
|
-
|
|
16
|
-
本期授权尝试 4,946 笔,授权成功率 45.79%。0 笔销售未能匹配授权,覆盖六个月。
|
|
17
|
-
详见 [方法说明](method.zh.md)。
|
|
18
|
-
|
|
19
|
-
| 指标 | 值 |
|
|
20
|
-
|---|---|
|
|
21
|
-
| 授权尝试 | 4,946 |
|
|
22
|
-
|
|
23
|
-
- 授权拒绝 1,111 笔,\`C1\` 为高风险。
|
|
24
|
-
- 疑似欺诈响应不是已确认损失。
|
|
25
|
-
|
|
26
|
-
\`\`\`python
|
|
27
|
-
print("本期授权尝试 4,946 笔")
|
|
28
|
-
\`\`\`
|
|
29
|
-
`;
|
|
30
|
-
|
|
31
|
-
function polish(...args) {
|
|
32
|
-
return spawnSync('python3', [script, ...args], { encoding: 'utf8' });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Writes a document, extracts it, and returns helpers. `propose` keeps every block it does not
|
|
36
|
-
// rewrite, so the proposal covers all blocks unless `partial` is set.
|
|
37
|
-
function setup(content = REPORT) {
|
|
38
|
-
const dir = mkdtempSync(join(tmpdir(), 'polish-cn-test-'));
|
|
39
|
-
const doc = join(dir, 'report.zh.md');
|
|
40
|
-
writeFileSync(doc, content);
|
|
41
|
-
const blocksPath = join(dir, 'blocks.json');
|
|
42
|
-
const result = polish('extract', doc, '--out', blocksPath);
|
|
43
|
-
assert.equal(result.status, 0, result.stderr);
|
|
44
|
-
const blocks = JSON.parse(readFileSync(blocksPath, 'utf8')).blocks;
|
|
45
|
-
const byText = (needle) => blocks.find((block) => block.text.includes(needle));
|
|
46
|
-
const propose = (entries, { partial = false } = {}) => {
|
|
47
|
-
const path = join(dir, `proposals-${Math.random().toString(36).slice(2)}.json`);
|
|
48
|
-
const rewritten = {};
|
|
49
|
-
for (const [needle, text] of entries) {
|
|
50
|
-
const block = byText(needle);
|
|
51
|
-
rewritten[block.id] = { sha: block.sha, text };
|
|
52
|
-
}
|
|
53
|
-
const kept = partial ? {} : Object.fromEntries(
|
|
54
|
-
blocks.filter((block) => !rewritten[block.id]).map((block) => [block.id, 'already natural']));
|
|
55
|
-
writeFileSync(path, JSON.stringify({ blocks: rewritten, kept, notes: ['note kept'] }));
|
|
56
|
-
return path;
|
|
57
|
-
};
|
|
58
|
-
return { dir, doc, blocksPath, blocks, byText, propose };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
test('extract returns prose only: front matter, tables and code fences are never blocks', () => {
|
|
62
|
-
const { blocks } = setup();
|
|
63
|
-
assert.deepEqual(blocks.map((block) => block.kind), ['heading', 'paragraph', 'list-item', 'list-item']);
|
|
64
|
-
assert.ok(blocks.every((block) => !block.text.includes('|') && !block.text.includes('print(')));
|
|
65
|
-
assert.equal(blocks[0].prefix, '# ');
|
|
66
|
-
assert.deepEqual(blocks[1].lines, [6, 7]);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('extract skips HTML comments and blocks, indented code, pipe tables without edge pipes, and link definitions', () => {
|
|
70
|
-
const { blocks } = setup([
|
|
71
|
-
'正文一。', '', '<!--', '注释 99', '-->', '', '<div>', '内嵌 HTML 7', '</div>', '',
|
|
72
|
-
' indented_code(3)', '', '指标 | 值', '--- | ---', '尝试 | 12', '', '[ref]: https://example.com/x', '', '正文二。', '',
|
|
73
|
-
].join('\n'));
|
|
74
|
-
assert.deepEqual(blocks.map((block) => block.text), ['正文一。', '正文二。']);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('check accepts a rewrite that keeps every protected token, even in a new order', () => {
|
|
78
|
-
const { blocksPath, propose } = setup();
|
|
79
|
-
const proposals = propose([[
|
|
80
|
-
'本期授权尝试',
|
|
81
|
-
'本期授权成功率为 45.79%,授权尝试共 4,946 笔。0 笔销售未能匹配授权,覆盖六个月。详见 [方法](method.zh.md)。',
|
|
82
|
-
]]);
|
|
83
|
-
const result = polish('check', blocksPath, proposals);
|
|
84
|
-
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
85
|
-
assert.equal(JSON.parse(result.stdout).accepted.length, 1);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('check fails when a block is neither rewritten nor kept, or is both, unless --partial', () => {
|
|
89
|
-
const { dir, blocksPath, byText, propose } = setup();
|
|
90
|
-
const partial = propose([['疑似欺诈', '疑似欺诈响应并非已确认的损失。']], { partial: true });
|
|
91
|
-
const strict = polish('check', blocksPath, partial);
|
|
92
|
-
assert.equal(strict.status, 1);
|
|
93
|
-
assert.equal(JSON.parse(strict.stdout).unreviewed.length, 3);
|
|
94
|
-
assert.equal(polish('check', blocksPath, partial, '--partial').status, 0);
|
|
95
|
-
|
|
96
|
-
const block = byText('疑似欺诈');
|
|
97
|
-
const both = JSON.parse(readFileSync(propose([['疑似欺诈', '疑似欺诈响应并非已确认的损失。']]), 'utf8'));
|
|
98
|
-
both.kept[block.id] = 'also kept';
|
|
99
|
-
const bothPath = join(dir, 'both.json');
|
|
100
|
-
writeFileSync(bothPath, JSON.stringify(both));
|
|
101
|
-
const result = polish('check', blocksPath, bothPath);
|
|
102
|
-
assert.equal(result.status, 1);
|
|
103
|
-
assert.deepEqual(JSON.parse(result.stdout).partitionProblems, [block.id]);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('check rejects changed, added or dropped numbers, signs, currency, links, images, code and protected terms', () => {
|
|
107
|
-
const { blocksPath, propose } = setup();
|
|
108
|
-
const cases = [
|
|
109
|
-
['本期授权尝试', '本期授权尝试 4,964 笔,授权成功率 45.79%。0 笔销售未能匹配授权,覆盖六个月。详见 [方法说明](method.zh.md)。', /number '4,946'/],
|
|
110
|
-
['本期授权尝试', '本期授权尝试 4,946 笔,授权成功率 45.79%。0 笔销售未能匹配授权,覆盖 6 个月。详见 [方法说明](method.zh.md)。', /added number '6'/],
|
|
111
|
-
['本期授权尝试', '本期授权尝试 4,946 笔,授权成功率 45.79%。0 笔销售未能匹配授权,覆盖六个月。', /link 'method\.zh\.md'/],
|
|
112
|
-
['本期授权尝试', '本期授权尝试 4,946 笔,授权成功率 45.79%。0 笔销售未能匹配授权,覆盖六个月。详见 。', /image 'method\.zh\.md'/],
|
|
113
|
-
['本期授权尝试', '本期授权尝试 4,946 笔,授权成功率 +45.79%。0 笔销售未能匹配授权,覆盖六个月。详见 [方法说明](method.zh.md)。', /symbol '\+'/],
|
|
114
|
-
['本期授权尝试', '本期授权尝试 4,946 笔,授权成功率 45.79%,约 ¥0。0 笔销售未能匹配授权,覆盖六个月。详见 [方法说明](method.zh.md)。', /symbol '¥'/],
|
|
115
|
-
['授权拒绝', '拒付 1,111 笔,`C1` 为高风险。', /term '授权拒绝'/],
|
|
116
|
-
['授权拒绝', '授权拒绝 1,111 笔,C2 为高风险。', /code '`C1`'/],
|
|
117
|
-
];
|
|
118
|
-
for (const [needle, text, reason] of cases) {
|
|
119
|
-
const result = polish('check', blocksPath, propose([[needle, text]]), '--protect', '授权拒绝', '--protect', '拒付');
|
|
120
|
-
assert.equal(result.status, 1, `expected rejection for: ${text}`);
|
|
121
|
-
const rejected = Object.values(JSON.parse(result.stdout).rejected);
|
|
122
|
-
assert.match(rejected[0], reason);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test('check reads TERMINOLOGY.md as concepts: mentions are kept, Avoid terms may become preferred but never appear', () => {
|
|
127
|
-
const { dir, blocks, blocksPath, propose } = setup('本月拒绝交易 1 笔,授权拒绝 2 笔。\n\n疑似欺诈响应不是已确认损失。\n');
|
|
128
|
-
const terms = join(dir, 'TERMINOLOGY.md');
|
|
129
|
-
writeFileSync(terms, [
|
|
130
|
-
'# Terminology: test', '', '## Disputes', '',
|
|
131
|
-
'| Concept | English | 简体 | 繁體(港) | Avoid | Meaning | Status | Source |',
|
|
132
|
-
'| --- | --- | --- | --- | --- | --- | --- | --- |',
|
|
133
|
-
'| Decline | decline | 授权拒绝 | 授權拒絕 | 拒绝交易、拒付(指授权拒绝) | Issuer refusal | user, 2026-10-20 | user |',
|
|
134
|
-
'| Chargeback | chargeback | 拒付 | — | 退单(指 Visa 拒付) | Dispute | proposed | a.md |',
|
|
135
|
-
'| Piped | pipe | 甲\\|乙 | — | | Escaped pipe | proposed | a.md |', '',
|
|
136
|
-
'## Sources', '', '| id | Source |', '| --- | --- |', '| a.md | 授权拒绝 |', '',
|
|
137
|
-
].join('\n'));
|
|
138
|
-
const run = (needle, text) => polish('check', blocksPath, propose([[needle, text]]), '--terminology', terms);
|
|
139
|
-
|
|
140
|
-
const normalized = run('拒绝交易', '本月授权拒绝 1 笔,授权拒绝 2 笔。');
|
|
141
|
-
assert.equal(normalized.status, 0, normalized.stdout);
|
|
142
|
-
assert.deepEqual(Object.keys(JSON.parse(normalized.stdout).avoidedTermsInSource), [blocks[0].id]);
|
|
143
|
-
|
|
144
|
-
const added = run('拒绝交易', '本月拒绝交易 1 笔,拒绝交易 2 笔。');
|
|
145
|
-
assert.equal(added.status, 1);
|
|
146
|
-
assert.match(Object.values(JSON.parse(added.stdout).rejected)[0], /avoids: 拒绝交易/);
|
|
147
|
-
|
|
148
|
-
const dropped = run('拒绝交易', '本月有 1 笔,授权拒绝 2 笔。');
|
|
149
|
-
assert.equal(dropped.status, 1);
|
|
150
|
-
assert.match(Object.values(JSON.parse(dropped.stdout).rejected)[0], /concept 'c1'.*c1 = 授权拒绝/);
|
|
151
|
-
|
|
152
|
-
const scopedNote = run('疑似欺诈', '疑似欺诈响应不是已确认损失,与拒付无关。');
|
|
153
|
-
assert.equal(scopedNote.status, 1, 'adding 拒付 adds a mention of the chargeback concept');
|
|
154
|
-
assert.match(Object.values(JSON.parse(scopedNote.stdout).rejected)[0], /c2 = 拒付/);
|
|
155
|
-
|
|
156
|
-
const emDash = run('疑似欺诈', '疑似欺诈响应——不是已确认损失。');
|
|
157
|
-
assert.equal(emDash.status, 0, 'an em dash is not a protected term: — means an empty cell');
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
test('check flags ids in kept that are not blocks', () => {
|
|
161
|
-
const { dir, blocksPath, propose } = setup();
|
|
162
|
-
const proposals = JSON.parse(readFileSync(propose([]), 'utf8'));
|
|
163
|
-
proposals.kept.b999_note = 'invented';
|
|
164
|
-
const path = join(dir, 'unknown.json');
|
|
165
|
-
writeFileSync(path, JSON.stringify(proposals));
|
|
166
|
-
const result = polish('check', blocksPath, path);
|
|
167
|
-
assert.equal(result.status, 1);
|
|
168
|
-
assert.deepEqual(JSON.parse(result.stdout).partitionProblems, ['b999_note (unknown id in kept)']);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
test('check refuses line breaks and new Markdown structure inside a proposal', () => {
|
|
172
|
-
const { blocksPath, propose } = setup();
|
|
173
|
-
for (const text of ['疑似欺诈响应\n# 新标题', '疑似欺诈响应\r# 注入', '# 疑似欺诈响应不是已确认损失。', '- 疑似欺诈响应不是已确认损失。']) {
|
|
174
|
-
const result = polish('check', blocksPath, propose([['疑似欺诈', text]]));
|
|
175
|
-
assert.equal(result.status, 1, `expected rejection for: ${JSON.stringify(text)}`);
|
|
176
|
-
assert.match(Object.values(JSON.parse(result.stdout).rejected)[0], /one line|block syntax/);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test('check refuses deletions, stale blocks and malformed proposal files', () => {
|
|
181
|
-
const { dir, blocksPath, byText, propose } = setup();
|
|
182
|
-
const empty = polish('check', blocksPath, propose([['疑似欺诈', ' ']]));
|
|
183
|
-
assert.equal(empty.status, 1);
|
|
184
|
-
assert.match(empty.stdout, /never deletes a block/);
|
|
185
|
-
|
|
186
|
-
const block = byText('疑似欺诈');
|
|
187
|
-
const stale = JSON.parse(readFileSync(propose([['疑似欺诈', '疑似欺诈响应并非已确认的损失。']]), 'utf8'));
|
|
188
|
-
stale.blocks[block.id].sha = 'old';
|
|
189
|
-
const stalePath = join(dir, 'stale.json');
|
|
190
|
-
writeFileSync(stalePath, JSON.stringify(stale));
|
|
191
|
-
const result = polish('check', blocksPath, stalePath);
|
|
192
|
-
assert.equal(result.status, 1);
|
|
193
|
-
assert.match(result.stdout, /does not match block sha/);
|
|
194
|
-
|
|
195
|
-
const nullPath = join(dir, 'null.json');
|
|
196
|
-
writeFileSync(nullPath, 'null');
|
|
197
|
-
const malformed = polish('check', blocksPath, nullPath);
|
|
198
|
-
assert.equal(malformed.status, 2);
|
|
199
|
-
assert.match(malformed.stderr, /needs an object/);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
test('apply rewrites accepted prose, keeps tables and code byte-identical, and writes the record', () => {
|
|
203
|
-
const { dir, doc, blocksPath, byText, propose } = setup();
|
|
204
|
-
const proposals = propose([
|
|
205
|
-
['疑似欺诈', '疑似欺诈响应并非已确认的损失。'],
|
|
206
|
-
['授权拒绝', '授权拒绝共 1,111 笔,`C1` 列为高风险。'],
|
|
207
|
-
]);
|
|
208
|
-
const record = join(dir, 'record.json');
|
|
209
|
-
const result = polish('apply', doc, blocksPath, proposals, '--reject', byText('授权拒绝').id,
|
|
210
|
-
'--record', record, '--model', 'deepseek/deepseek-flash');
|
|
211
|
-
assert.equal(result.status, 0, result.stderr);
|
|
212
|
-
const after = readFileSync(doc, 'utf8');
|
|
213
|
-
assert.match(after, /^- 疑似欺诈响应并非已确认的损失。$/m);
|
|
214
|
-
assert.match(after, /^- 授权拒绝 1,111 笔,`C1` 为高风险。$/m, 'a caller-rejected block stays unchanged');
|
|
215
|
-
assert.ok(after.includes('| 授权尝试 | 4,946 |\n'));
|
|
216
|
-
assert.ok(after.includes('print("本期授权尝试 4,946 笔")'));
|
|
217
|
-
assert.ok(after.endsWith('```\n'), 'the trailing newline survives');
|
|
218
|
-
const written = JSON.parse(readFileSync(record, 'utf8'));
|
|
219
|
-
assert.equal(written.model, 'deepseek/deepseek-flash');
|
|
220
|
-
assert.equal(written.applied.length, 1);
|
|
221
|
-
assert.deepEqual(written.notes, ['note kept']);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
test('apply keeps CRLF line endings and leaves HTML comments intact', () => {
|
|
225
|
-
const crlf = ['正文 123。', '', '<!--', '注释 99', '-->', '', '结尾。', ''].join('\r\n');
|
|
226
|
-
const { doc, blocksPath, propose } = setup(crlf);
|
|
227
|
-
const result = polish('apply', doc, blocksPath, propose([['正文', '正文为 123。']]));
|
|
228
|
-
assert.equal(result.status, 0, result.stderr);
|
|
229
|
-
assert.equal(readFileSync(doc, 'utf8'), crlf.replace('正文 123。', '正文为 123。'));
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
test('apply refuses an incomplete proposal file and a document changed after extract', () => {
|
|
233
|
-
const { doc, blocksPath, propose } = setup();
|
|
234
|
-
const incomplete = polish('apply', doc, blocksPath, propose([['疑似欺诈', '疑似欺诈响应并非已确认的损失。']], { partial: true }));
|
|
235
|
-
assert.equal(incomplete.status, 1);
|
|
236
|
-
assert.match(incomplete.stderr, /every block needs/);
|
|
237
|
-
|
|
238
|
-
const proposals = propose([['疑似欺诈', '疑似欺诈响应并非已确认的损失。']]);
|
|
239
|
-
writeFileSync(doc, REPORT.replace('疑似欺诈响应不是', '疑似欺诈响应并不是'));
|
|
240
|
-
const result = polish('apply', doc, blocksPath, proposals);
|
|
241
|
-
assert.equal(result.status, 1);
|
|
242
|
-
assert.match(result.stderr, /changed since extract/);
|
|
243
|
-
assert.ok(readFileSync(doc, 'utf8').includes('疑似欺诈响应并不是'));
|
|
244
|
-
});
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict';
|
|
2
|
-
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { mkdtempSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { dirname, join } from 'node:path';
|
|
6
|
-
import { fileURLToPath } from 'node:url';
|
|
7
|
-
import test from 'node:test';
|
|
8
|
-
|
|
9
|
-
const scriptsDir = dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const skillDir = join(scriptsDir, '..');
|
|
11
|
-
const checklistsDir = join(skillDir, 'references', 'checklists');
|
|
12
|
-
const mandatesDir = join(skillDir, 'references', 'mandates');
|
|
13
|
-
|
|
14
|
-
function run(cmd, args) {
|
|
15
|
-
return spawnSync(cmd, args, { encoding: 'utf8' });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function py(script, ...args) {
|
|
19
|
-
return run('python3', [join(scriptsDir, script), ...args]);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function scratch(name, content) {
|
|
23
|
-
const path = join(mkdtempSync(join(tmpdir(), 'reg-parser-test-')), name);
|
|
24
|
-
writeFileSync(path, content);
|
|
25
|
-
return path;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const HEADER = `\`\`\`yaml
|
|
29
|
-
name: "Test Checklist"
|
|
30
|
-
regulation: "Directive 2015/849"
|
|
31
|
-
version: "1.0"
|
|
32
|
-
scope: "Test"
|
|
33
|
-
date: "2026-10-19"
|
|
34
|
-
summary:
|
|
35
|
-
categories: 1
|
|
36
|
-
total_items: 1
|
|
37
|
-
critical: 1
|
|
38
|
-
major: 0
|
|
39
|
-
minor: 0
|
|
40
|
-
\`\`\`
|
|
41
|
-
|
|
42
|
-
## CAT-01: Customer Due Diligence
|
|
43
|
-
|
|
44
|
-
`;
|
|
45
|
-
|
|
46
|
-
// The item template in SKILL.md, filled in. If the template drifts from what
|
|
47
|
-
// the validator accepts, every checklist an agent builds from it fails.
|
|
48
|
-
function templateItem() {
|
|
49
|
-
const skill = readFileSync(join(skillDir, 'SKILL.md'), 'utf8');
|
|
50
|
-
const block = skill.match(/Each obligation from Step 2 becomes one checklist item:\n\n```markdown\n([\s\S]*?)```/)[1];
|
|
51
|
-
return block
|
|
52
|
-
.split('\n')
|
|
53
|
-
.filter((line) => !line.includes('# source-native scheme'))
|
|
54
|
-
.map((line) => line.replace(/\s+# cat scheme$/, ''))
|
|
55
|
-
.join('\n')
|
|
56
|
-
.replace('CAT-XX-NNN', 'CAT-01-001')
|
|
57
|
-
.replace('[Requirement title]', 'Verify identity')
|
|
58
|
-
.replace('[plain-language obligation]', 'Verify customer identity before onboarding.')
|
|
59
|
-
.replace('section [ref], [regulation]', 'Art. 13(1)(a), Directive 2015/849')
|
|
60
|
-
.replace('critical | major | minor', 'critical')
|
|
61
|
-
.replace('[Concrete observable step]', 'ID checked against a reliable source')
|
|
62
|
-
.replace('[Another step]', 'Check date recorded')
|
|
63
|
-
.replace('[Document or record that proves compliance]', 'Verification log');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
test('every bundled checklist validates', () => {
|
|
67
|
-
for (const name of readdirSync(checklistsDir).filter((f) => f.endsWith('.md'))) {
|
|
68
|
-
const result = py('validate_checklist.py', join(checklistsDir, name));
|
|
69
|
-
assert.equal(result.status, 0, `${name}\n${result.stdout}${result.stderr}`);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('every bundled mandate validates', () => {
|
|
74
|
-
for (const name of readdirSync(mandatesDir).filter((f) => f.endsWith('.md'))) {
|
|
75
|
-
const result = py('validate_mandate.py', join(mandatesDir, name));
|
|
76
|
-
assert.equal(result.status, 0, `${name}\n${result.stdout}${result.stderr}`);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('every bundled checklist JSON equals a fresh dump of its markdown', () => {
|
|
81
|
-
for (const name of readdirSync(checklistsDir).filter((f) => f.endsWith('.json'))) {
|
|
82
|
-
const md = join(checklistsDir, name.replace(/\.json$/, '.md'));
|
|
83
|
-
const result = py('dump_checklist.py', md);
|
|
84
|
-
assert.equal(result.status, 0, result.stderr);
|
|
85
|
-
assert.deepEqual(JSON.parse(result.stdout), JSON.parse(readFileSync(join(checklistsDir, name), 'utf8')), name);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('the SKILL.md item template passes the validator', () => {
|
|
90
|
-
const result = py('validate_checklist.py', scratch('ok.md', HEADER + templateItem() + '\n'));
|
|
91
|
-
assert.equal(result.status, 0, result.stdout + result.stderr);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
test('a checklist with colons outside the bold labels fails', () => {
|
|
95
|
-
const item = templateItem().replace(/\*\*(\w+):\*\*/g, '**$1**:');
|
|
96
|
-
const result = py('validate_checklist.py', scratch('bad.md', HEADER + item + '\n'));
|
|
97
|
-
assert.equal(result.status, 1, result.stdout);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('a checklist item with empty fields fails', () => {
|
|
101
|
-
const item = `### CAT-01-001: Empty
|
|
102
|
-
|
|
103
|
-
- **Requirement:**
|
|
104
|
-
- **Source:**
|
|
105
|
-
- **Severity:** critical
|
|
106
|
-
- **Verification:**
|
|
107
|
-
- **Evidence:**
|
|
108
|
-
`;
|
|
109
|
-
const result = py('validate_checklist.py', scratch('empty.md', HEADER + item));
|
|
110
|
-
assert.equal(result.status, 1, result.stdout);
|
|
111
|
-
assert.match(result.stdout + result.stderr, /field Requirement is empty/);
|
|
112
|
-
assert.match(result.stdout + result.stderr, /Verification has no '- \[ \]' steps/);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('a raw preprocess output fails mandate validation', () => {
|
|
116
|
-
const source = scratch('src.md', 'Section 1 The licensee must keep records.\n```\nfenced\n```\n');
|
|
117
|
-
const out = join(dirname(source), 'mandate.md');
|
|
118
|
-
const pre = run('bash', [join(scriptsDir, 'preprocess-mandate.sh'), source, '--source', 'Test', '--out', out]);
|
|
119
|
-
assert.equal(pre.status, 0, pre.stderr);
|
|
120
|
-
const result = py('validate_mandate.py', out);
|
|
121
|
-
assert.equal(result.status, 1, result.stdout);
|
|
122
|
-
assert.match(result.stdout + result.stderr, /Status: RAW/);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('preprocess refuses to overwrite a finished mandate', () => {
|
|
126
|
-
const finished = join(mandatesDir, 'visa-vars.md');
|
|
127
|
-
const copy = scratch('visa-vars.md', readFileSync(finished, 'utf8'));
|
|
128
|
-
const source = scratch('src.md', 'Section 1 must.\n');
|
|
129
|
-
const pre = run('bash', [join(scriptsDir, 'preprocess-mandate.sh'), source, '--source', 'Test', '--out', copy]);
|
|
130
|
-
assert.equal(pre.status, 1, pre.stdout);
|
|
131
|
-
assert.equal(readFileSync(copy, 'utf8'), readFileSync(finished, 'utf8'));
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('a mandate section with only prose or a hollow entry fails', () => {
|
|
135
|
-
const sections = (body) => `# Test — Contract Obligation Extract
|
|
136
|
-
|
|
137
|
-
> **Source:** Test Act 2026
|
|
138
|
-
|
|
139
|
-
## Mandatory Downstream Agreement Clauses
|
|
140
|
-
${body}
|
|
141
|
-
|
|
142
|
-
## Prohibited Conduct
|
|
143
|
-
_None_
|
|
144
|
-
|
|
145
|
-
## Thresholds & Triggers
|
|
146
|
-
_None_
|
|
147
|
-
|
|
148
|
-
## Audit & Oversight Rights
|
|
149
|
-
_None_
|
|
150
|
-
|
|
151
|
-
## Notes
|
|
152
|
-
Jurisdiction: test only. Effective 2026-10-19. Version 1. Caveat: synthetic fixture for the validator.
|
|
153
|
-
`;
|
|
154
|
-
assert.equal(py('validate_mandate.py', scratch('ok.md', sections('**section 4(1) Records**: Keep records five years.'))).status, 0);
|
|
155
|
-
assert.equal(py('validate_mandate.py', scratch('prose.md', sections('This part has no obligations worth noting, n/a mostly.'))).status, 1);
|
|
156
|
-
assert.equal(py('validate_mandate.py', scratch('hollow.md', sections('**section **:'))).status, 1);
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
test('compare_checklist counts item headings, not ID mentions', () => {
|
|
160
|
-
const target = join(skillDir, 'references', 'tests', 'vars-checklist.md');
|
|
161
|
-
const canonical = py('compare_checklist.py', join(checklistsDir, 'visa-vars-checklist.md'), target);
|
|
162
|
-
assert.equal(canonical.status, 0, canonical.stdout);
|
|
163
|
-
const ids = [...new Set(readFileSync(target, 'utf8').match(/\b[A-Z]{4}\.C\d+\.\d+\b/g))].join(' ');
|
|
164
|
-
assert.equal(py('compare_checklist.py', scratch('fake.md', ids), target).status, 1);
|
|
165
|
-
});
|