Skip to content

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

fix(cli): keep the entry file the user wrote, outside the pointer block (#23)

Fajar Hidayat748ad7a111d0
diff --git a/SECURITY.md b/SECURITY.md
index 25f8f1f..a48dee2 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -12,7 +12,7 @@ The report notes that antislop appends a pointer block to an agent entry file su
- is a static markdown reference. It lists the installed skills and carries no executable content.
- is written only after you approve. The picker and the manual wizard both ask first.
-- is appended at the end of the entry file. Existing content is never changed.
+- is added at the end of the entry file on a first install, and replaced where it already sits on later runs. Nothing else in the file is touched, including your own blank lines and code blocks.
- lives in [cli/lib/install.mjs](cli/lib/install.mjs) for the picker, and in the wizard inside [antislop.md](antislop.md) for the manual path.
Removing this behavior would remove the core promise: a filter that is always on, not one you remember to invoke. Any always-on ruleset that writes a reference to an entry file matches this pattern.
diff --git a/cli/lib/install.mjs b/cli/lib/install.mjs
index 9a5da24..2eb2e61 100644
--- a/cli/lib/install.mjs
+++ b/cli/lib/install.mjs
@@ -141,12 +141,17 @@ function writeBlock(entry, block) {
const start = lines.findIndex((l) => l.trim() === POINTER_START)
const end = lines.findIndex((l) => l.trim() === POINTER_END)
const replacing = start !== -1 && end !== -1 && start < end
- const head = replacing ? lines.slice(0, start) : lines
+ const head = replacing ? lines.slice(0, start) : lines.slice()
const tail = replacing ? lines.slice(end + 1) : []
- const body = [...head, '', ...block, '', ...tail]
+ // Tidy the two seams only. Normalising the joined document, which is what a
+ // /\n{3,}/g sweep does, also collapses blank lines the author wrote, including
+ // the ones inside their fenced code blocks.
+ while (head.length && head[head.length - 1].trim() === '') head.pop()
+ while (tail.length && tail[0].trim() === '') tail.shift()
+
+ const body = [...head, '', ...block, ...(tail.length ? ['', ...tail] : [])]
.join('\n')
- .replace(/\n{3,}/g, '\n\n')
.replace(/^\n+/, '')
.trimEnd()