Skip to content

Rules for an AI coding agent to filter out generic AI-generated UI designs, text, and code.

fix(cli): preserve fenced pointer examples with info strings (#40)

CBOSSX30029b09b6e2
diff --git a/cli/lib/install.mjs b/cli/lib/install.mjs
index e6c8099..f5d8d13 100644
--- a/cli/lib/install.mjs
+++ b/cli/lib/install.mjs
@@ -168,7 +168,7 @@ function scanMarkers(lines) {
mark = m[1][0]
len = m[1].length
from = i
- } else if (m[1][0] === mark && m[1].length >= len) {
+ } else if (m[1][0] === mark && m[1].length >= len && /^[ \t]*$/.test(line.slice(m[0].length))) {
mark = null
from = -1
}
diff --git a/cli/scripts/smoke-worker.mjs b/cli/scripts/smoke-worker.mjs
index a6d341a..0b27ad6 100644
--- a/cli/scripts/smoke-worker.mjs
+++ b/cli/scripts/smoke-worker.mjs
@@ -169,6 +169,18 @@ write('# Mine\n\n````md\n```md\n<!-- antislop:start -->\n<!-- antislop:end -->\n
updatePointers({ targets, skills })
check('J four-backtick example untouched', read().includes('````md\n```md\n<!-- antislop:start -->'), true)
+// A fence-like line with trailing text is code, not a closing fence.
+for (const fence of ['```', '~~~']) {
+ const example = `${fence}md\n${fence}js\n<!-- antislop:start -->\nKeep this example.\n<!-- antislop:end -->\n${fence}`
+ write(`# Mine\n\n${example}\n`)
+ updatePointers({ targets, skills })
+ check(`J ${fence} with info string keeps the example`, read().includes(example), true)
+ check(`J ${fence} real block added outside the example`, (read().match(/antislop:start/g) || []).length, 2)
+ const first = read()
+ updatePointers({ targets, skills })
+ check(`J ${fence} example stays intact on reinstall`, read(), first)
+}
+
// A stray end marker below the block is ours too, and must not survive.
write('# Mine\n<!-- antislop:start -->\nold\n<!-- antislop:end -->\nTail text\n<!-- antislop:end -->\n')
updatePointers({ targets, skills })