@aiwg/flue 2026.11.6 → 2026.11.8
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 +1 -1
- package/skills/ai-pattern-detection/SKILL.md +93 -9
- package/skills/ai-pattern-detection/references/current-patterns.json +87 -0
- package/skills/ai-pattern-detection/scripts/pattern_scanner.py +192 -13
- package/skills/ai-pattern-detection/scripts/structural_patterns.py +188 -0
- package/skills/aiwg-mission/SKILL.md +4 -0
- package/skills/architecture-evolution/SKILL.md +4 -0
- package/skills/checkpoint/SKILL.md +4 -0
- package/skills/commit-and-push/SKILL.md +4 -0
- package/skills/flaky-detect/SKILL.md +4 -0
- package/skills/flaky-fix/SKILL.md +4 -0
- package/skills/flow-architecture-evolution/SKILL.md +4 -0
- package/skills/flow-change-control/SKILL.md +4 -0
- package/skills/flow-gate-check/SKILL.md +4 -0
- package/skills/flow-handoff-checklist/SKILL.md +4 -0
- package/skills/flow-incident-response/SKILL.md +4 -0
- package/skills/flow-release/SKILL.md +4 -0
- package/skills/gate-evaluation/SKILL.md +4 -0
- package/skills/issue-close/SKILL.md +4 -0
- package/skills/issue-comment/SKILL.md +4 -0
- package/skills/parallel-dispatch/SKILL.md +4 -0
- package/skills/pr-review/SKILL.md +4 -0
- package/skills/project-status/SKILL.md +4 -0
- package/skills/security-assessment/SKILL.md +4 -0
- package/skills/security-audit/SKILL.md +4 -0
- package/skills/test-conformance/SKILL.md +4 -0
package/package.json
CHANGED
|
@@ -35,12 +35,88 @@ These phrases can be uninformative in some contexts; none identifies content as
|
|
|
35
35
|
4. **Performative Language**: "aims to provide", "strives to achieve", "designed to enhance"
|
|
36
36
|
5. **Academic Passive**: "It has been observed that...", "It can be argued that..."
|
|
37
37
|
|
|
38
|
-
###
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
### Current Local Patterns
|
|
39
|
+
|
|
40
|
+
The scanners detect local contrasts (`not … but`, `X, not Y`, `rather than`),
|
|
41
|
+
negated evidence/proof/substitute assertions, listed antonym pairs, significance
|
|
42
|
+
labels and asides, empty openers, and generic engagement prompts. Findings are
|
|
43
|
+
editing guidance with rule IDs, tiers and suggested changes. Numeric comparisons
|
|
44
|
+
are suppressed when both operands have numbers within six tokens of the divider.
|
|
45
|
+
Reasons (`because`, `while`) and correction cues suppress a match only inside it
|
|
46
|
+
or within four tokens, without crossing a semicolon/colon. An unrelated date does
|
|
47
|
+
not suppress “It is not just the score in 2026.” Proximity remains a heuristic.
|
|
48
|
+
|
|
49
|
+
The dated `references/current-patterns.json` list requires two lexical markers in
|
|
50
|
+
one paragraph or four in a file; lone leverage/enhance are ignored. Spectral-only
|
|
51
|
+
clusters use watch tier. All three surfaces recognize a narrow rhetorical
|
|
52
|
+
adjective triad with or without the Oxford comma: `three_item_list` in Python,
|
|
53
|
+
`struct_three_items` in validation and diagnostics (watch tier). Inventories remain valid.
|
|
54
|
+
|
|
55
|
+
Front matter, headings, image alt text, code, quotations, comments, tables and
|
|
56
|
+
inventory lines are protected. Passive voice and standalone punctuation are not
|
|
57
|
+
findings.
|
|
58
|
+
|
|
59
|
+
### Structural and Campaign Checks
|
|
60
|
+
|
|
61
|
+
Paragraph-final explicit moral/lesson openers (3–10 words) are cut tier; generic
|
|
62
|
+
subjects alone never trigger a closer finding. Numbers, identifiers and code
|
|
63
|
+
suppress moral findings; quoted scenario names within authored prose are allowed. Adjacent sentences sharing the first two tokens
|
|
64
|
+
must have parallel predicates with an aligned polarity flip or one listed antonym
|
|
65
|
+
(cut). Different predicates sharing a negated opener are insufficient. Four
|
|
66
|
+
consecutive statements of 1–4 words in one paragraph form a check-tier fragment
|
|
67
|
+
run. Questions and identical-sentence-only runs are excluded. Headings, blank
|
|
68
|
+
lines and protected whole lines break sequences; wrapped prose lines do not.
|
|
69
|
+
|
|
70
|
+
Colon reveals are watch tier for a short setup that withholds a complement
|
|
71
|
+
and a short sentence-final punchline, or an explicit defect revealed through
|
|
72
|
+
a conditional consequence. Mere colon frequency and neighboring
|
|
73
|
+
findings never suffice. Lists, definitions, digits/citations, code and quotation
|
|
74
|
+
introductions are excluded. Ambiguous technical introductions remain unflagged.
|
|
75
|
+
|
|
76
|
+
Use one campaign set for cross-document comparison:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
aiwg writing --cross --json linkedin.md telegram.md x-thread.md
|
|
80
|
+
python3 -I scripts/pattern_scanner.py --cross campaign/
|
|
81
|
+
python3 -I scripts/pattern_scanner.py --cross --report campaign/
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The existing `aiwg writing` entry point emits a readable report by default and
|
|
85
|
+
JSON with `--json`; Python emits JSON by default and readable output with
|
|
86
|
+
`--report`. Each finding includes a tier, source location and suggested fix.
|
|
87
|
+
Campaign rules detect six-word repeated sentences (cut), eight-word runs shared
|
|
88
|
+
by at least three documents (check), and three-word opening/closing skeletons
|
|
89
|
+
shared by at least three documents (check). Numbers and versions normalize only
|
|
90
|
+
for skeletons; phrase runs exclude sentences already reported as repeated.
|
|
91
|
+
Every affected occurrence is reported, with related document locations.
|
|
92
|
+
|
|
93
|
+
The APIs are `diagnoseWritingBatch(documents, { cross: true })` and
|
|
94
|
+
`engine.validateBatch(files, context, { cross: true })`. IDs must be unique;
|
|
95
|
+
missing campaign files fail the scan. Sets over 200 documents fail with an
|
|
96
|
+
explicit size error; split larger sets. Related-location output can still grow
|
|
97
|
+
with repetition inside an allowed set. A single-document campaign may report
|
|
98
|
+
repeated sentences; phrases and skeletons require distinct documents.
|
|
99
|
+
|
|
100
|
+
The #4138 reproduction also detects a withheld defect followed by an `if`
|
|
101
|
+
condition and a short consequence (`one bug: if …, nothing stopped`). The
|
|
102
|
+
conditional and consequence together may contain up to sixteen words; ordinary
|
|
103
|
+
lists, definitions, code and numeric references stay excluded.
|
|
104
|
+
|
|
105
|
+
A short consequence, a one-word repair (`fixed`, `patched`, `repaired` or
|
|
106
|
+
`resolved`) and a final explicit moral also form a fragment run. The consequence
|
|
107
|
+
may be the final comma clause of a longer sentence. This covers `nothing stopped.
|
|
108
|
+
fixed. always test …` while preserving the four-statement threshold for generic
|
|
109
|
+
staccato. Moral endings allow a quoted scenario name within authored prose
|
|
110
|
+
(`always test the "switch is gone" case`); entirely quoted text and inline code
|
|
111
|
+
remain protected. The negate/assert category includes the short corrective
|
|
112
|
+
frame `it doesn't anymore` (also `it does not anymore`).
|
|
113
|
+
|
|
114
|
+
These checks are heuristic. Short generic statements and factual technical
|
|
115
|
+
negations remain residuals for review; explicit moral openers and short
|
|
116
|
+
corrections can be useful instructions. Findings call for contextual review.
|
|
117
|
+
The reproduction produces all six requested categories across Python,
|
|
118
|
+
validation and contextual diagnostics, with the comma pair reported as
|
|
119
|
+
`antithesis-pair` and the aside as `labelled-significance`.
|
|
44
120
|
|
|
45
121
|
### Contextual Patterns (Check Frequency)
|
|
46
122
|
|
|
@@ -94,12 +170,20 @@ When generating or reviewing content:
|
|
|
94
170
|
|
|
95
171
|
The Python `scripts/pattern_scanner.py` is a **legacy regex scanner**, not the contextual diagnostic implementation. It:
|
|
96
172
|
- Counts pattern frequencies
|
|
97
|
-
- Labels matches
|
|
98
|
-
- Generates replacement suggestions
|
|
99
|
-
- Preserves the deprecated numeric `authenticity_score` (0–100) and `grade` for compatibility, with a deprecation notice; neither measures authorship or publication readiness
|
|
173
|
+
- Labels matches with pattern IDs, tiers, source line/column and legacy severity categories; these are advisory absent a user rule
|
|
174
|
+
- Generates replacement suggestions for local, structural and campaign patterns
|
|
175
|
+
- Preserves the deprecated numeric `authenticity_score` (0–100) and `grade` for compatibility, with prose-rate penalties and a deprecation notice; neither measures authorship or publication readiness
|
|
100
176
|
|
|
101
177
|
For contextual programmatic review, use `WritingValidationEngine.diagnose(content, options)` or the exported `diagnoseWriting` API. Results include UTF-16 spans, context, explanations and reasoned exceptions. They carry `publicationGate: false`. The Python scanner does not implement these context or exception fields.
|
|
102
178
|
|
|
179
|
+
Python `position` counts Unicode code points from zero; its `column` counts code
|
|
180
|
+
points from one. Validation `location.start/end` and diagnostic `start/end` count
|
|
181
|
+
UTF-16 code units from zero, with exclusive ends; validation `column` counts
|
|
182
|
+
UTF-16 units from one. Lines start at one on every surface. These units also apply to structural and
|
|
183
|
+
campaign findings and their related source lines. ASCII offsets agree.
|
|
184
|
+
For `🧵 Thoughts?`, Python gives position 2 and column 3; TypeScript gives start 3
|
|
185
|
+
and validation column 4, because the astral character occupies two UTF-16 units.
|
|
186
|
+
|
|
103
187
|
## Integration
|
|
104
188
|
|
|
105
189
|
This skill works with:
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"reviewed": "2026-11-12",
|
|
3
|
+
"nextReview": "2027-02-12",
|
|
4
|
+
"note": "Editorial heuristics for #4138 and #4140, based on the November voice-quality catalogue. Not authorship evidence. Sequence and campaign rules supplement local clauses.",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"id": "contrast-not-but",
|
|
8
|
+
"tier": "cut",
|
|
9
|
+
"pattern": "\\bnot\\s+[^.!?;:\\n]{1,100}?,?\\s+but\\b",
|
|
10
|
+
"message": "Negated alternative before but.",
|
|
11
|
+
"fix": "State the positive claim; retain a negated alternative when it corrects a stated belief."
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"id": "contrast-x-not-y",
|
|
15
|
+
"tier": "cut",
|
|
16
|
+
"pattern": ",\\s+not\\s+(?!(?:yet|now|sure|necessarily|really|enough|all|in|if|when|because|until|any|clear|certain|true|quite|going|at all|be|do|need)\\b)[\\w'-]+(?:\\s+[\\w'-]+){0,4}",
|
|
17
|
+
"message": "A clause ends with a negated alternative.",
|
|
18
|
+
"fix": "Keep the useful claim; retain the alternative only when the reader needs the correction."
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"id": "rather-than",
|
|
22
|
+
"tier": "check",
|
|
23
|
+
"pattern": "\\brather\\s+than\\b",
|
|
24
|
+
"message": "Comparison without a stated reason.",
|
|
25
|
+
"fix": "Name the action, or explain why the alternative was a real option."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "negate-then-assert",
|
|
29
|
+
"tier": "check",
|
|
30
|
+
"pattern": "\\b(?:(?:is|are|was|were)\\s+not|isn't|aren't)\\s+(?:evidence|proof|a substitute|a replacement|the same|enough|just|only|about)\\b|\\b(?:it|this|that)\\s+does\\s+not\\s+(?:mean|prove|imply)\\b|\\bit\\s+(?:doesn't|does not)\\s+anymore\\b",
|
|
31
|
+
"message": "Negated assertion frames the claim.",
|
|
32
|
+
"fix": "State the positive claim, retaining negation when it corrects a misconception."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "labelled-significance",
|
|
36
|
+
"tier": "cut",
|
|
37
|
+
"pattern": "(?:^|[.!?]\\s+|\\n)\\s*(?:why (?:it|this|that) (?:matters|helps)|why you should care|what (?:changed|this means(?: for you)?|that means|you get)|the (?:bug|takeaway|point|lesson|catch|upshot|real (?:question|point|story))|bottom line|the short version)\\s*:|\\b(?:(?:which|that) is the (?:part|thing|bit|point|half) (?:i'd|i would) (?:keep|say|add)(?: too)?|(?:that|this) is the (?:other|real|whole|hard) (?:half|part|point|story|thing))\\b",
|
|
38
|
+
"message": "A label or aside announces significance.",
|
|
39
|
+
"fix": "Explain the circumstance and consequence together; deleting only the label is insufficient."
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "throat-clearing",
|
|
43
|
+
"tier": "cut",
|
|
44
|
+
"pattern": "\\b(?:here'?s the (?:thing|deal|kicker|catch|twist)|here'?s why|let'?s (?:dive|dig|jump) (?:in|into)|let'?s (?:be|get) (?:honest|real|clear)|without further ado|buckle up|picture this|spoiler alert|let me explain)\\b|\\bfull stop\\.",
|
|
45
|
+
"message": "Empty opener delays the content.",
|
|
46
|
+
"fix": "Start with the useful information."
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "engagement-bait",
|
|
50
|
+
"tier": "cut",
|
|
51
|
+
"pattern": "\\b(?:what do you think|agree|thoughts|am i wrong|what'?s your take)\\?|\\b(?:drop a comment|comment below|tag someone who|let me know (?:in the comments|what you think))\\b",
|
|
52
|
+
"message": "Generic engagement prompt.",
|
|
53
|
+
"fix": "Ask a concrete question with something to answer, or end with the information."
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
"structuralRules": [
|
|
57
|
+
{ "id": "mirrored-sentences", "tier": "cut", "scope": "file", "trigger": "Adjacent sentences share the first two tokens and aligned predicates; exactly one polarity flip or listed antonym supplies a real contrast. Different verbs with a negated opener are insufficient.", "fix": "Combine the useful claim; retain deliberate parallelism with a reason." },
|
|
58
|
+
{ "id": "aphorism-ending", "tier": "cut", "scope": "file", "trigger": "Paragraph-final explicit moral/lesson opener of 3–10 words; allow quoted scenario names inside authored prose but exclude numbers, identifiers, code and wholly quoted statements. Generic closers are not detected.", "fix": "End on the last useful fact or support the claim." },
|
|
59
|
+
{ "id": "colon-reveal", "tier": "watch", "scope": "file", "trigger": "Setup of 4–12 words ending in a withheld complement, then a sentence-final punchline of 2–10 words. Also detect a withheld defect followed by an if-clause and a short consequence (at most 16 words after the colon). Frequency never triggers a finding. Exclude lists/definitions, digits/citations and protected material.", "fix": "State the subject and consequence directly." },
|
|
60
|
+
{ "id": "fragment-run", "tier": "check", "scope": "file", "trigger": "At least four consecutive statements with 1–4 words in one prose paragraph; questions break runs and identical-sentence-only runs are excluded. Also detect a short consequence, a one-word repair and a final explicit moral; the consequence may follow a conditional comma.", "fix": "Join fragments to explain the reason or result." },
|
|
61
|
+
{ "id": "repeated-sentence", "tier": "cut", "scope": "cross", "trigger": "At least six words repeated within an explicit campaign; case and punctuation are ignored, numbers are retained.", "fix": "Write each channel from its relevant facts." },
|
|
62
|
+
{ "id": "repeated-phrase", "tier": "check", "scope": "cross", "trigger": "An eight-word run inside one sentence shared by at least three distinct documents; overlapping runs merge, affected sentences receive one phrase finding, repeated sentences are excluded.", "fix": "Rewrite the shared run for the reader and channel." },
|
|
63
|
+
{ "id": "shared-skeleton", "tier": "check", "scope": "cross", "trigger": "First or last three words of the first or last prose sentence shared by three distinct documents, including a content word; numbers and versions normalize to num.", "fix": "Lead or close with the useful change for this channel." }
|
|
64
|
+
],
|
|
65
|
+
"antonyms": [
|
|
66
|
+
["quiet", "loud"], ["fast", "slow"], ["cheap", "expensive"],
|
|
67
|
+
["simple", "complex"], ["easy", "hard"], ["safe", "unsafe"],
|
|
68
|
+
["big", "small"], ["large", "small"], ["new", "old"],
|
|
69
|
+
["public", "private"], ["local", "remote"], ["manual", "automatic"],
|
|
70
|
+
["short", "long"], ["early", "late"], ["good", "bad"],
|
|
71
|
+
["real", "fake"], ["open", "closed"], ["visible", "hidden"],
|
|
72
|
+
["cold", "hot"], ["dark", "bright"], ["strong", "weak"],
|
|
73
|
+
["clean", "dirty"], ["working", "broken"], ["fixed", "broken"]
|
|
74
|
+
],
|
|
75
|
+
"lexicon": {
|
|
76
|
+
"paragraphMinHits": 2,
|
|
77
|
+
"fileMinHits": 4,
|
|
78
|
+
"sets": [
|
|
79
|
+
{ "name": "2023", "tier": "check", "words": ["delve", "delves", "delved", "delving", "tapestry", "testament", "pivotal", "crucial", "meticulous"] },
|
|
80
|
+
{ "name": "2024-25", "tier": "check", "words": ["enhance", "enhances", "enhanced", "enhancing", "fostering", "showcasing", "highlighting", "valuable insights"] },
|
|
81
|
+
{ "name": "2026", "tier": "check", "words": ["leverage", "leverages", "leveraged", "leveraging", "multifaceted"] },
|
|
82
|
+
{ "name": "copula-avoidance", "tier": "check", "words": ["serves as", "stands as", "boasts", "acts as", "functions as"] },
|
|
83
|
+
{ "name": "spectral-technical", "tier": "watch", "words": ["quiet", "hum", "echo"] }
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"triadPattern": "\\b(?:is|are|was|were)\\s+(?:fast|reliable|secure|efficient|scalable|robust|innovative|flexible|powerful),\\s+(?:fast|reliable|secure|efficient|scalable|robust|innovative|flexible|powerful),?\\s+and\\s+(?:fast|reliable|secure|efficient|scalable|robust|innovative|flexible|powerful)(?![\\w-]|\\s*,)"
|
|
87
|
+
}
|
|
@@ -15,10 +15,19 @@ Output:
|
|
|
15
15
|
import re
|
|
16
16
|
import json
|
|
17
17
|
import sys
|
|
18
|
+
import runpy
|
|
18
19
|
from pathlib import Path
|
|
19
20
|
from collections import Counter
|
|
20
21
|
from typing import NamedTuple
|
|
21
22
|
|
|
23
|
+
CATALOGUE = json.loads((Path(__file__).resolve().parents[1] /
|
|
24
|
+
'references/current-patterns.json').read_text(encoding='utf-8'))
|
|
25
|
+
FIXES = {rule['id']: rule['fix'] for rule in CATALOGUE['rules']}
|
|
26
|
+
FIXES.update({'antithesis-pair': 'Keep the fact and drop the mirrored half.',
|
|
27
|
+
'lexical-cluster': 'Replace vague markers with the specific action or fact.'})
|
|
28
|
+
STRUCTURAL = runpy.run_path(str(Path(__file__).with_name('structural_patterns.py')))
|
|
29
|
+
FIXES.update(STRUCTURAL['FIXES'])
|
|
30
|
+
|
|
22
31
|
# Legacy high-priority phrase patterns; matches do not identify authorship
|
|
23
32
|
CRITICAL_PATTERNS = [
|
|
24
33
|
# Corporate/Marketing Speak
|
|
@@ -36,7 +45,6 @@ CRITICAL_PATTERNS = [
|
|
|
36
45
|
r"\bgame[- ]changing",
|
|
37
46
|
r"\bparadigm\s+shift",
|
|
38
47
|
r"\bsynerg(y|istic)",
|
|
39
|
-
r"\bleverag(e|ing)\b",
|
|
40
48
|
|
|
41
49
|
# Vague Intensifiers
|
|
42
50
|
r"\bdramatically\s+(improv|enhanc|reduc|increas)",
|
|
@@ -97,9 +105,7 @@ CONTEXTUAL_PATTERNS = [
|
|
|
97
105
|
|
|
98
106
|
# Structural patterns
|
|
99
107
|
STRUCTURAL_PATTERNS = {
|
|
100
|
-
"three_item_list":
|
|
101
|
-
"em_dash_overuse": r"—",
|
|
102
|
-
"passive_voice": r"\b(is|are|was|were|been|being)\s+\w+ed\b",
|
|
108
|
+
"three_item_list": CATALOGUE['triadPattern'],
|
|
103
109
|
"hedge_words": r"\b(may|might|could|can)\s+(help|serve|facilitate|enhance)\b",
|
|
104
110
|
}
|
|
105
111
|
|
|
@@ -111,11 +117,137 @@ class PatternMatch(NamedTuple):
|
|
|
111
117
|
severity: str
|
|
112
118
|
|
|
113
119
|
|
|
120
|
+
def mask_prose(text: str, protect_quotes=True) -> str:
|
|
121
|
+
"""Protect Markdown and quotations while retaining code-point offsets."""
|
|
122
|
+
chars = list(text)
|
|
123
|
+
|
|
124
|
+
def hide(start, end):
|
|
125
|
+
for pos in range(start, end):
|
|
126
|
+
if chars[pos] not in '\r\n':
|
|
127
|
+
chars[pos] = '\x01'
|
|
128
|
+
|
|
129
|
+
lines = list(re.finditer(r'[^\n]+(?:\n|$)|\n', text))
|
|
130
|
+
front = bool(lines and re.fullmatch(r'\ufeff?---\s*', lines[0].group()))
|
|
131
|
+
fence = None
|
|
132
|
+
comment = False
|
|
133
|
+
indented = False
|
|
134
|
+
for index, line in enumerate(lines):
|
|
135
|
+
raw = line.group()
|
|
136
|
+
marker = re.match(r' {0,3}(`{3,}|~{3,})(.*)', raw)
|
|
137
|
+
if front:
|
|
138
|
+
hide(line.start(), line.end())
|
|
139
|
+
if index > 0 and re.fullmatch(r'(?:---|\.\.\.)\s*', raw):
|
|
140
|
+
front = False
|
|
141
|
+
continue
|
|
142
|
+
if fence:
|
|
143
|
+
hide(line.start(), line.end())
|
|
144
|
+
if marker and marker[1][0] == fence[0] and len(marker[1]) >= len(fence) and not marker[2].strip():
|
|
145
|
+
fence = None
|
|
146
|
+
continue
|
|
147
|
+
if marker:
|
|
148
|
+
fence = marker[1]
|
|
149
|
+
hide(line.start(), line.end())
|
|
150
|
+
continue
|
|
151
|
+
if comment:
|
|
152
|
+
end = raw.find('-->')
|
|
153
|
+
hide(line.start(), line.start() + (len(raw) if end < 0 else end + 3))
|
|
154
|
+
comment = end < 0
|
|
155
|
+
if comment:
|
|
156
|
+
continue
|
|
157
|
+
for match in re.finditer(r'<!--[\s\S]*?(?:-->|$)', raw):
|
|
158
|
+
hide(line.start() + match.start(), line.start() + match.end())
|
|
159
|
+
if not match.group().endswith('-->'):
|
|
160
|
+
comment = True
|
|
161
|
+
setext = index + 1 < len(lines) and re.fullmatch(r' {0,3}(?:=+|-+)\s*', lines[index + 1].group())
|
|
162
|
+
if re.match(r' {0,3}(?:#{1,6}(?:\s|$)|>|\|)', raw) or setext or re.fullmatch(r' {0,3}(?:=+|-+)\s*', raw):
|
|
163
|
+
hide(line.start(), line.end())
|
|
164
|
+
continue
|
|
165
|
+
if re.match(r'(?: {4}|\t)', raw) and (indented or index == 0 or not lines[index - 1].group().strip()):
|
|
166
|
+
hide(line.start(), line.end())
|
|
167
|
+
indented = True
|
|
168
|
+
continue
|
|
169
|
+
if raw.strip():
|
|
170
|
+
indented = False
|
|
171
|
+
if re.match(r'\s*(?:[-*+] |\d+[.)] )', raw):
|
|
172
|
+
hide(line.start(), line.end())
|
|
173
|
+
patterns = [r'(`+)(?!`)(?:[^`]|(?!\1)`)*?\1(?!`)',
|
|
174
|
+
r'!\[[^\]\n]*\](?:\([^\n]*?\)|\[[^\]\n]*\])',
|
|
175
|
+
r'(?:!?\[[^\]\n]*\])?\((?:https?://)[^\s)]*\)|https?://[^\s<>]+']
|
|
176
|
+
if protect_quotes:
|
|
177
|
+
patterns.append(r'“[^”]*”|"[^"\n]+"|«[^»]*»')
|
|
178
|
+
for pattern in patterns:
|
|
179
|
+
for match in re.finditer(pattern, text):
|
|
180
|
+
hide(match.start(), match.end())
|
|
181
|
+
return ''.join(chars)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def grounded_comparison(text: str, start: int, end: int) -> bool:
|
|
185
|
+
"""Require grounding near this comparison, not anywhere in its sentence."""
|
|
186
|
+
words = lambda s: re.findall(r"[a-z0-9]+(?:['.-][a-z0-9]+)*", s, re.I)
|
|
187
|
+
for cue in re.finditer(r'\b(?:because|while|correction|earlier|previously|misconception|you said)\b', text, re.I):
|
|
188
|
+
gap = text[end:cue.start()] if cue.start() >= end else text[cue.end():start] if cue.end() <= start else ''
|
|
189
|
+
if not re.search(r'[;:]', gap) and len(words(gap)) <= 4:
|
|
190
|
+
return True
|
|
191
|
+
divider = re.search(r'\brather\s+than\b|\bbut\b|,\s+not\b|^,$', text[start:end], re.I)
|
|
192
|
+
if not divider:
|
|
193
|
+
return False
|
|
194
|
+
pivot = start + divider.start()
|
|
195
|
+
left = words(re.split(r'[;:]', text[:pivot])[-1])[-6:]
|
|
196
|
+
right = words(re.split(r'[;:]', text[pivot + len(divider.group()):])[0])[:6]
|
|
197
|
+
return any(re.search(r'\d', w) for w in left) and any(re.search(r'\d', w) for w in right)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def current_matches(text: str):
|
|
201
|
+
"""Local editorial patterns on masked prose."""
|
|
202
|
+
text = text.replace('’', "'").replace('‘', "'")
|
|
203
|
+
severity = {'cut': 'critical', 'check': 'warning', 'watch': 'info'}
|
|
204
|
+
paragraphs = list(re.finditer(r'\S[^\n]*(?:\n(?!\s*\n)[^\n]+)*', text))
|
|
205
|
+
lexical = []
|
|
206
|
+
for paragraph in paragraphs:
|
|
207
|
+
hits = []
|
|
208
|
+
for group in CATALOGUE['lexicon']['sets']:
|
|
209
|
+
pattern = r'\b(?:' + '|'.join(re.escape(w) for w in group['words']) + r')\b'
|
|
210
|
+
hits.extend((paragraph.start() + m.start(), m.group(), group['tier'])
|
|
211
|
+
for m in re.finditer(pattern, paragraph.group(), re.I))
|
|
212
|
+
if hits:
|
|
213
|
+
hits.sort()
|
|
214
|
+
lexical.append((hits[0], len(hits), 'check' if any(h[2] == 'check' for h in hits) else 'watch'))
|
|
215
|
+
total = sum(count for _, count, _ in lexical)
|
|
216
|
+
for (start, word, _), count, tier in lexical:
|
|
217
|
+
if count >= CATALOGUE['lexicon']['paragraphMinHits'] or total >= CATALOGUE['lexicon']['fileMinHits']:
|
|
218
|
+
yield PatternMatch('lexical-cluster', word, start, severity[tier])
|
|
219
|
+
tokens = lambda s: re.findall(r"[a-z]+(?:['-][a-z]+)*", s.lower())
|
|
220
|
+
for sentence in re.finditer(r'[^.!?\n\x01]+(?:[.!?]+|(?=[\n\x01]|$))', text):
|
|
221
|
+
body = sentence.group()
|
|
222
|
+
contrast = re.search(CATALOGUE['rules'][0]['pattern'], body, re.I)
|
|
223
|
+
for rule in CATALOGUE['rules']:
|
|
224
|
+
if rule['id'] == 'negate-then-assert' and contrast:
|
|
225
|
+
continue
|
|
226
|
+
for match in re.finditer(rule['pattern'], body, re.I | re.M):
|
|
227
|
+
if rule['id'] in ('contrast-not-but', 'contrast-x-not-y', 'rather-than', 'negate-then-assert') and grounded_comparison(body, match.start(), match.end()):
|
|
228
|
+
continue
|
|
229
|
+
trim = len(match.group()) - len(match.group().lstrip())
|
|
230
|
+
yield PatternMatch(rule['id'], match.group().lstrip(), sentence.start() + match.start() + trim, severity[rule['tier']])
|
|
231
|
+
for comma in re.finditer(',', body):
|
|
232
|
+
if grounded_comparison(body, comma.start(), comma.end()):
|
|
233
|
+
continue
|
|
234
|
+
left, right = tokens(body[:comma.start()])[-3:], tokens(body[comma.end():])[:2]
|
|
235
|
+
if len(left) < 2 or len(right) < 2:
|
|
236
|
+
continue
|
|
237
|
+
if any((a in left and b in right) or (b in left and a in right) for a, b in CATALOGUE['antonyms']):
|
|
238
|
+
trim = len(body) - len(body.lstrip())
|
|
239
|
+
yield PatternMatch('antithesis-pair', body.lstrip(), sentence.start() + trim, 'critical')
|
|
240
|
+
break
|
|
241
|
+
|
|
242
|
+
|
|
114
243
|
def scan_text(text: str) -> dict:
|
|
115
244
|
"""Scan text for AI patterns and return analysis report."""
|
|
116
245
|
|
|
117
|
-
|
|
118
|
-
|
|
246
|
+
source = text
|
|
247
|
+
text = mask_prose(text)
|
|
248
|
+
word_count = len(re.findall(r'\b\w+\b', text))
|
|
249
|
+
local_matches = list(current_matches(text))
|
|
250
|
+
matches = list(local_matches)
|
|
119
251
|
|
|
120
252
|
# Check critical patterns
|
|
121
253
|
for pattern in CRITICAL_PATTERNS:
|
|
@@ -151,7 +283,7 @@ def scan_text(text: str) -> dict:
|
|
|
151
283
|
if count > 0:
|
|
152
284
|
structural_issues[name] = count
|
|
153
285
|
# Flag if overused
|
|
154
|
-
threshold =
|
|
286
|
+
threshold = 0 if name == "three_item_list" else 5
|
|
155
287
|
if count > threshold:
|
|
156
288
|
for match in re.finditer(pattern, text, re.IGNORECASE):
|
|
157
289
|
matches.append(PatternMatch(
|
|
@@ -161,6 +293,8 @@ def scan_text(text: str) -> dict:
|
|
|
161
293
|
severity="info"
|
|
162
294
|
))
|
|
163
295
|
|
|
296
|
+
matches.extend(STRUCTURAL['structural_matches'](text.replace('’', "'").replace('‘', "'"), CATALOGUE['antonyms'], PatternMatch, mask_prose(source, protect_quotes=False)))
|
|
297
|
+
|
|
164
298
|
# Calculate deprecated compatibility heuristic (not an authorship or quality measure)
|
|
165
299
|
critical_count = sum(1 for m in matches if m.severity == "critical")
|
|
166
300
|
warning_count = sum(1 for m in matches if m.severity == "warning")
|
|
@@ -168,9 +302,7 @@ def scan_text(text: str) -> dict:
|
|
|
168
302
|
|
|
169
303
|
# Base score of 100, deduct for issues
|
|
170
304
|
score = 100
|
|
171
|
-
score -= critical_count * 10
|
|
172
|
-
score -= warning_count * 3 # -3 per warning
|
|
173
|
-
score -= info_count * 1 # -1 per info
|
|
305
|
+
score -= (critical_count * 10 + warning_count * 3 + info_count) * 100 / max(word_count, 1)
|
|
174
306
|
score = max(0, min(100, score))
|
|
175
307
|
|
|
176
308
|
return {
|
|
@@ -190,9 +322,15 @@ def scan_text(text: str) -> dict:
|
|
|
190
322
|
},
|
|
191
323
|
"matches": [
|
|
192
324
|
{
|
|
193
|
-
"text": m.match,
|
|
325
|
+
"text": source[m.position:m.position + len(m.match)],
|
|
326
|
+
"pattern": m.pattern,
|
|
327
|
+
"scope": "file",
|
|
194
328
|
"severity": m.severity,
|
|
195
|
-
"
|
|
329
|
+
"tier": {"critical": "cut", "warning": "check", "info": "watch"}[m.severity],
|
|
330
|
+
"position": m.position,
|
|
331
|
+
"line": source.count('\n', 0, m.position) + 1,
|
|
332
|
+
"column": m.position - source.rfind('\n', 0, m.position),
|
|
333
|
+
"suggestion": FIXES.get(m.pattern, 'Review the wording in context; retain deliberate usage.')
|
|
196
334
|
}
|
|
197
335
|
for m in sorted(matches, key=lambda x: x.position)
|
|
198
336
|
],
|
|
@@ -218,11 +356,34 @@ def _score_to_grade(score: int) -> str:
|
|
|
218
356
|
|
|
219
357
|
def main():
|
|
220
358
|
"""CLI entry point."""
|
|
359
|
+
if '--cross' in sys.argv[1:]:
|
|
360
|
+
args = sys.argv[1:]
|
|
361
|
+
readable = '--report' in args
|
|
362
|
+
paths = [arg for arg in args if arg not in ('--cross', '--json', '--report')]
|
|
363
|
+
if not paths or any(arg.startswith('-') for arg in paths):
|
|
364
|
+
raise SystemExit('Usage: pattern_scanner.py --cross [--json|--report] <file-or-dir>...')
|
|
365
|
+
files = sorted({file.resolve() for item in paths for file in
|
|
366
|
+
(Path(item).rglob('*.md') if Path(item).is_dir() else [Path(item)])})
|
|
367
|
+
if len(files) > 200:
|
|
368
|
+
raise SystemExit('Campaign exceeds 200 documents; split it into smaller campaign sets.')
|
|
369
|
+
sources = {}
|
|
370
|
+
for file in files:
|
|
371
|
+
with file.open(encoding='utf-8', newline='') as stream:
|
|
372
|
+
sources[str(file)] = stream.read()
|
|
373
|
+
result = scan_campaign(sources)
|
|
374
|
+
if readable:
|
|
375
|
+
for file, report in result.items():
|
|
376
|
+
for m in report['matches']:
|
|
377
|
+
print(f"{file}:{m['line']}:{m['column']} [{m['tier']}] {m['pattern']}: {m['suggestion']}")
|
|
378
|
+
else:
|
|
379
|
+
print(json.dumps(result, indent=2))
|
|
380
|
+
return
|
|
221
381
|
if len(sys.argv) < 2 or sys.argv[1] in ('--help', '-h'):
|
|
222
382
|
print(__doc__)
|
|
223
383
|
print("Options:")
|
|
224
384
|
print(" <file> Path to file to scan")
|
|
225
385
|
print(" --text 'text' Inline text to scan")
|
|
386
|
+
print(" --cross [--report] <file-or-dir>... Compare one campaign (JSON by default)")
|
|
226
387
|
print(" --help, -h Show this help message")
|
|
227
388
|
sys.exit(0)
|
|
228
389
|
|
|
@@ -233,11 +394,29 @@ def main():
|
|
|
233
394
|
if not path.exists():
|
|
234
395
|
print(f"Error: File not found: {path}")
|
|
235
396
|
sys.exit(1)
|
|
236
|
-
|
|
397
|
+
with path.open(encoding='utf-8', newline='') as stream:
|
|
398
|
+
text = stream.read()
|
|
237
399
|
|
|
238
400
|
result = scan_text(text)
|
|
239
401
|
print(json.dumps(result, indent=2))
|
|
240
402
|
|
|
241
403
|
|
|
404
|
+
def scan_campaign(sources: dict) -> dict:
|
|
405
|
+
"""Scan an explicit {document_id: source} campaign, including local findings."""
|
|
406
|
+
cross = STRUCTURAL['campaign_matches'](sources, mask_prose)
|
|
407
|
+
reports = {name: scan_text(text) for name, text in sources.items()}
|
|
408
|
+
for name, report in reports.items():
|
|
409
|
+
report['matches'].extend(cross[name])
|
|
410
|
+
report['matches'].sort(key=lambda m: (m['position'], m['pattern']))
|
|
411
|
+
for m in cross[name]:
|
|
412
|
+
report['summary'][m['severity']] += 1
|
|
413
|
+
report['summary']['total'] += 1
|
|
414
|
+
summary = report['summary']
|
|
415
|
+
penalty = (summary['critical'] * 10 + summary['warning'] * 3 + summary['info']) * 100 / max(report['word_count'], 1)
|
|
416
|
+
report['authenticity_score'] = max(0, min(100, 100 - penalty))
|
|
417
|
+
report['grade'] = _score_to_grade(report['authenticity_score'])
|
|
418
|
+
return reports
|
|
419
|
+
|
|
420
|
+
|
|
242
421
|
if __name__ == "__main__":
|
|
243
422
|
main()
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""Sentence-sequence and campaign editorial heuristics with source code-point offsets."""
|
|
2
|
+
import re
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
|
|
5
|
+
STOP = set("a an the of to in on for and or but is are was were be it its this that these those with as at by from not no so if we you i they he she our your their there here than then also about into over under out up down can will would should could has have had do does did just only more most very all any each some which who what when where how why num them his her me my".split())
|
|
6
|
+
ABBREVIATIONS = set('e.g i.e vs etc approx cf eg ie dr mr mrs ms st no fig al'.split())
|
|
7
|
+
SEVERITY = {'cut': 'critical', 'check': 'warning', 'watch': 'info'}
|
|
8
|
+
FIXES = {
|
|
9
|
+
'mirrored-sentences': 'Combine the useful claim into one sentence; retain deliberate parallelism with a reason.',
|
|
10
|
+
'fragment-run': 'Join fragments to explain the reason or result.',
|
|
11
|
+
'aphorism-ending': 'End on the last useful fact, or develop the claim with supported detail.',
|
|
12
|
+
'colon-reveal': 'State the subject and consequence directly; retain real lists, labels and code introductions.',
|
|
13
|
+
'repeated-sentence': 'Write each channel from its relevant facts; retain required repetition with a reason.',
|
|
14
|
+
'repeated-phrase': 'Rewrite the shared run for the reader and channel.',
|
|
15
|
+
'shared-skeleton': 'Lead or close with the useful change for this channel instead of a recurring template.'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def words(text):
|
|
20
|
+
return re.findall(r"[a-z0-9]+(?:['’-][a-z0-9]+)*", text.lower())
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def paragraphs(prose):
|
|
24
|
+
blocks = []
|
|
25
|
+
for line in re.finditer(r'[^\n]*(?:\n|$)', prose):
|
|
26
|
+
if not re.sub(r'[\s\x01]', '', line.group()):
|
|
27
|
+
continue
|
|
28
|
+
if blocks and blocks[-1]['end'] == line.start():
|
|
29
|
+
blocks[-1]['end'] = line.end()
|
|
30
|
+
else:
|
|
31
|
+
blocks.append({'start': line.start(), 'end': line.end()})
|
|
32
|
+
for p in blocks:
|
|
33
|
+
text = prose[p['start']:p['end']]
|
|
34
|
+
ends = []
|
|
35
|
+
segment_start = 0
|
|
36
|
+
for match in re.finditer(r'[.!?]+', text):
|
|
37
|
+
if match.end() < len(text) and not text[match.end()].isspace():
|
|
38
|
+
continue
|
|
39
|
+
word = re.search(r'([a-z][a-z.]*)$', text[segment_start:match.start()], re.I)
|
|
40
|
+
if match.group() == '.' and word and (word[1].lower() in ABBREVIATIONS or re.fullmatch(r'(?:[a-z]\.)+[a-z]', word[1], re.I)):
|
|
41
|
+
continue
|
|
42
|
+
ends.append(match.end())
|
|
43
|
+
segment_start = match.end()
|
|
44
|
+
ends.append(len(text))
|
|
45
|
+
start = 0
|
|
46
|
+
p['sentences'] = []
|
|
47
|
+
for end in ends:
|
|
48
|
+
raw = text[start:end]
|
|
49
|
+
trimmed = raw.strip(' \t\r\n\x01')
|
|
50
|
+
if words(trimmed):
|
|
51
|
+
offset = p['start'] + start + len(raw) - len(raw.lstrip(' \t\r\n\x01'))
|
|
52
|
+
p['sentences'].append({'start': offset, 'end': offset + len(trimmed), 'text': trimmed, 'tokens': words(trimmed)})
|
|
53
|
+
start = end
|
|
54
|
+
return blocks
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def structural_matches(prose, antonyms, match_type, quoted_prose=None):
|
|
58
|
+
quoted_prose = prose if quoted_prose is None else quoted_prose
|
|
59
|
+
out = []
|
|
60
|
+
def emit(rule, sentence, tier):
|
|
61
|
+
out.append(match_type(rule, prose[sentence['start']:sentence['end']], sentence['start'], SEVERITY[tier]))
|
|
62
|
+
for p in paragraphs(prose):
|
|
63
|
+
seq = p['sentences']
|
|
64
|
+
for a, b in zip(seq, seq[1:]):
|
|
65
|
+
left, right = [words(re.sub(r"n['’]t\b", ' not', v['text'], flags=re.I)) for v in (a, b)]
|
|
66
|
+
negated = lambda tokens: 'not' in tokens or 'never' in tokens
|
|
67
|
+
x, y = [[t for t in tokens if t not in ('not', 'never')] for tokens in (left, right)]
|
|
68
|
+
differences = [i for i, (u, v) in enumerate(zip(x, y)) if u != v]
|
|
69
|
+
polarity = negated(left) != negated(right) and not differences
|
|
70
|
+
antonym = negated(left) == negated(right) and len(differences) == 1 and differences[0] >= 2 and any(x[differences[0]] in pair and y[differences[0]] in pair for pair in antonyms)
|
|
71
|
+
if len(x) >= 3 and len(x) == len(y) and x[:2] == y[:2] and (polarity or antonym):
|
|
72
|
+
emit('mirrored-sentences', b, 'cut')
|
|
73
|
+
run = []
|
|
74
|
+
def flush():
|
|
75
|
+
if len(run) >= 4 and len({' '.join(s['tokens']) for s in run}) > 1:
|
|
76
|
+
emit('fragment-run', {'start': run[0]['start'], 'end': run[-1]['end']}, 'check')
|
|
77
|
+
run.clear()
|
|
78
|
+
for s in seq:
|
|
79
|
+
label = re.match(r'^([^:]+):', s['text'])
|
|
80
|
+
if len(s['tokens']) <= 4 and not s['text'].endswith('?') and not (label and len(words(label[1])) <= 3):
|
|
81
|
+
run.append(s)
|
|
82
|
+
else:
|
|
83
|
+
flush()
|
|
84
|
+
text = s['text']
|
|
85
|
+
if text.count(':') != 1 or re.search(r'[\d\x01`\[\]{};]', text) or not re.search(r'[.!]$', text):
|
|
86
|
+
continue
|
|
87
|
+
before, after = text.split(':')
|
|
88
|
+
after = after.strip()
|
|
89
|
+
withheld = re.search(r'\b(?:is|are|was|were)$', before.strip()) or re.search(r'\b(?:has|had|have|makes|made|holds|held|offers|offered|reveals|revealed|leaves|left) (?:a|an|one|this|that) (?:[a-z]+ ){0,2}[a-z]+$', before.strip(), re.I)
|
|
90
|
+
punchline = words(after)
|
|
91
|
+
subject = 1 if punchline and punchline[0] in ('the', 'a', 'an') else 0
|
|
92
|
+
predicate = punchline[subject + 1] if len(punchline) > subject + 1 else ''
|
|
93
|
+
clause = punchline and (subject == 1 or punchline[0] in ('it', 'this', 'that', 'we', 'you', 'they', 'he', 'she', 'nothing', 'everything')) and re.fullmatch(r'(?:is|are|was|were|can|will|must|has|had|does|[a-z]+(?:s|ed))', predicate)
|
|
94
|
+
conditional = re.match(r'^if\b[^,;:]+,\s*(?:nothing|everything|it|this|that|the [a-z]+)\s+(?:[a-z]+(?:s|ed)|is|was|can|will)\b', after, re.I) and not re.search(r'\b(?:and|or)\b|[?!]', after, re.I) and len(punchline) <= 16
|
|
95
|
+
if conditional and re.search(r'\b(?:bug|defect|flaw|failure|problem)$', before.strip(), re.I) and 4 <= len(words(before)) <= 12 and withheld:
|
|
96
|
+
pos = s['start'] + len(before)
|
|
97
|
+
emit('colon-reveal', {'start': pos, 'end': pos + 1}, 'watch')
|
|
98
|
+
if clause and ',' not in after and 4 <= len(words(before)) <= 12 and 2 <= len(words(after)) <= 10 and withheld and not re.search(r'^(?:["“]|[-*+]|\x01)', after) and not re.search(r'\b(?:and|or)\b|:|[?!]', after, re.I):
|
|
99
|
+
pos = s['start'] + len(before)
|
|
100
|
+
emit('colon-reveal', {'start': pos, 'end': pos + 1}, 'watch')
|
|
101
|
+
flush()
|
|
102
|
+
if not seq:
|
|
103
|
+
continue
|
|
104
|
+
last = seq[-1]
|
|
105
|
+
text = quoted_prose[last['start']:last['end']].replace('’', "'").replace('‘', "'")
|
|
106
|
+
if not 3 <= len(words(text)) <= 10 or re.search(r'[\d\x01@/]|[?:]$', text):
|
|
107
|
+
continue
|
|
108
|
+
moral = re.match(r"^(?:(?:always|never|remember)\b|the (?:point|lesson|moral)\b|(?:that's|that is|it's|it is|this is) the (?:point|lesson|moral)\b)", text, re.I)
|
|
109
|
+
if moral:
|
|
110
|
+
emit('aphorism-ending', last, 'cut')
|
|
111
|
+
if len(seq) >= 3 and not any(m.pattern == 'fragment-run' and m.position + len(m.match) == last['end'] for m in out) and re.fullmatch(r'(?:fixed|patched|repaired|resolved)[.!]', seq[-2]['text'], re.I):
|
|
112
|
+
consequence = seq[-3]
|
|
113
|
+
tail = consequence['text'].split(',')[-1].lstrip()
|
|
114
|
+
if 1 <= len(words(tail)) <= 4 and not re.search(r'[?:\x01]', tail):
|
|
115
|
+
emit('fragment-run', {'start': consequence['end'] - len(tail), 'end': last['end']}, 'check')
|
|
116
|
+
return out
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def campaign_matches(sources, mask):
|
|
120
|
+
if len(sources) > 200:
|
|
121
|
+
raise ValueError('Campaign exceeds 200 documents; split it into smaller campaign sets.')
|
|
122
|
+
out = {name: [] for name in sources}
|
|
123
|
+
by_document = defaultdict(list)
|
|
124
|
+
records = []
|
|
125
|
+
for name, text in sources.items():
|
|
126
|
+
for p in paragraphs(mask(text)):
|
|
127
|
+
for s in p['sentences']:
|
|
128
|
+
r = dict(s, file=name, key=' '.join(s['tokens']), line=text.count('\n', 0, s['start']) + 1)
|
|
129
|
+
records.append(r)
|
|
130
|
+
by_document[name].append(r)
|
|
131
|
+
def emit(rule, tier, r, related):
|
|
132
|
+
if any(f['pattern'] == rule and f['position'] == r['start'] and len(f['text']) == r['end'] - r['start'] for f in out[r['file']]):
|
|
133
|
+
return
|
|
134
|
+
source = sources[r['file']]
|
|
135
|
+
out[r['file']].append({'pattern': rule, 'tier': tier, 'severity': SEVERITY[tier], 'scope': 'cross',
|
|
136
|
+
'position': r['start'], 'line': source.count('\n', 0, r['start']) + 1,
|
|
137
|
+
'column': r['start'] - source.rfind('\n', 0, r['start']),
|
|
138
|
+
'text': source[r['start']:r['end']], 'suggestion': FIXES[rule],
|
|
139
|
+
'related': sorted([{'documentId': s['file'], 'line': s['line']} for s in related if s is not r], key=lambda s: (s['documentId'], s['line']))})
|
|
140
|
+
by_sentence = defaultdict(list)
|
|
141
|
+
for r in records:
|
|
142
|
+
if len(r['tokens']) >= 6:
|
|
143
|
+
by_sentence[r['key']].append(r)
|
|
144
|
+
repeated = set()
|
|
145
|
+
for key, occurrences in by_sentence.items():
|
|
146
|
+
if len(occurrences) >= 2:
|
|
147
|
+
repeated.add(key)
|
|
148
|
+
for r in occurrences:
|
|
149
|
+
emit('repeated-sentence', 'cut', r, occurrences)
|
|
150
|
+
shingles = defaultdict(list)
|
|
151
|
+
for r in records:
|
|
152
|
+
for i in range(len(r['tokens']) - 7):
|
|
153
|
+
shingles[' '.join(r['tokens'][i:i+8])].append(r)
|
|
154
|
+
shingle_documents = {key: len({s['file'] for s in occurrences}) for key, occurrences in shingles.items()}
|
|
155
|
+
for r in records:
|
|
156
|
+
if r['key'] in repeated:
|
|
157
|
+
continue
|
|
158
|
+
covered, related = set(), {}
|
|
159
|
+
for i in range(len(r['tokens']) - 7):
|
|
160
|
+
key = ' '.join(r['tokens'][i:i+8])
|
|
161
|
+
occurrences = shingles[key]
|
|
162
|
+
if shingle_documents[key] >= 3:
|
|
163
|
+
covered.update(range(i, i+8))
|
|
164
|
+
for s in occurrences:
|
|
165
|
+
related[id(s)] = s
|
|
166
|
+
for i in sorted(covered):
|
|
167
|
+
if i - 1 not in covered:
|
|
168
|
+
emit('repeated-phrase', 'check', r, related.values())
|
|
169
|
+
for edge in ('opening', 'closing'):
|
|
170
|
+
groups = defaultdict(list)
|
|
171
|
+
for name in sources:
|
|
172
|
+
own = by_document[name]
|
|
173
|
+
if not own:
|
|
174
|
+
continue
|
|
175
|
+
r = own[0] if edge == 'opening' else own[-1]
|
|
176
|
+
normalized = words(re.sub(r'\d+(?:[.-]\d+)*', ' num ', r['text']))
|
|
177
|
+
if len(normalized) < 3:
|
|
178
|
+
continue
|
|
179
|
+
boundary = normalized[:3] if edge == 'opening' else normalized[-3:]
|
|
180
|
+
if any(w not in STOP for w in boundary):
|
|
181
|
+
groups[' '.join(boundary)].append(r)
|
|
182
|
+
for occurrences in groups.values():
|
|
183
|
+
if len({r['file'] for r in occurrences}) >= 3:
|
|
184
|
+
for r in occurrences:
|
|
185
|
+
emit('shared-skeleton', 'check', r, occurrences)
|
|
186
|
+
for findings in out.values():
|
|
187
|
+
findings.sort(key=lambda f: (f['position'], f['pattern']))
|
|
188
|
+
return out
|
|
@@ -12,6 +12,10 @@ You are launching (or participating in) an **AIWG Mission** — AIWG's dynamic,
|
|
|
12
12
|
|
|
13
13
|
This is an **AIWG-specific kernel capability**. On Codex it surfaces as `/aiwg-mission`, deployed by AIWG to `~/.codex/prompts/` — it is **AIWG-owned**, not the plugin-provided `/workflow` an arbitrary Codex install may or may not have (`/workflow` is not a core Codex primitive — see `.aiwg/research/provider-workflow-integration.md`).
|
|
14
14
|
|
|
15
|
+
## Output template
|
|
16
|
+
|
|
17
|
+
Required for each bounded worker brief: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/subagent-brief.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
18
|
+
|
|
15
19
|
## Mission vs Flow vs in-stack primitive
|
|
16
20
|
|
|
17
21
|
- **Mission** (this skill) = *dynamic* orchestration. The shape emerges at run time from the goal. Cross-stack capable.
|
|
@@ -10,6 +10,10 @@ description: Manage architecture changes with impact analysis, ADR generation, m
|
|
|
10
10
|
|
|
11
11
|
Manage architecture changes with impact analysis, ADR generation, and migration planning.
|
|
12
12
|
|
|
13
|
+
## Output template
|
|
14
|
+
|
|
15
|
+
Use the decision record for accepted architecture decisions and the change card for change requests: @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/governance/adr-template.md; @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/configuration/change-request-card.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
16
|
+
|
|
13
17
|
## Triggers
|
|
14
18
|
|
|
15
19
|
|
|
@@ -9,6 +9,10 @@ description: Create, list, or recover workflow checkpoints and prepare a handoff
|
|
|
9
9
|
|
|
10
10
|
You create, list, or recover lightweight mid-workflow checkpoints that allow a crashed or interrupted workflow to continue from a known-good position rather than restart from scratch.
|
|
11
11
|
|
|
12
|
+
## Output template
|
|
13
|
+
|
|
14
|
+
For CLI checkpoint handoffs use the first template; for a free-standing agent handoff use the second: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/checkpoint-handoff.md; @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/agent-handoff.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
15
|
+
|
|
12
16
|
## Triggers
|
|
13
17
|
|
|
14
18
|
Alternate expressions and non-obvious activations (primary phrases are matched automatically from the skill description):
|
|
@@ -16,6 +16,10 @@ commandHint:
|
|
|
16
16
|
|
|
17
17
|
You are a Git Version Control Specialist. Create clear, well-structured commits following project conventions.
|
|
18
18
|
|
|
19
|
+
## Output template
|
|
20
|
+
|
|
21
|
+
Required for the commit message: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/commit-message.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
22
|
+
|
|
19
23
|
## Task
|
|
20
24
|
|
|
21
25
|
When invoked with `/commit-and-push [commit-message-summary]`:
|
|
@@ -22,6 +22,10 @@ platforms: [flue]
|
|
|
22
22
|
|
|
23
23
|
# Flaky Detect Skill
|
|
24
24
|
|
|
25
|
+
## Output template
|
|
26
|
+
|
|
27
|
+
Required for the human-readable CI failure or flaky-test report: @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/ci-failure-report.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
28
|
+
|
|
25
29
|
## Purpose
|
|
26
30
|
|
|
27
31
|
Identify flaky tests (tests that pass and fail non-deterministically) by analyzing CI history, execution patterns, and test characteristics. Google research shows 4.56% of tests are flaky, costing millions in developer productivity.
|
|
@@ -9,6 +9,10 @@ platforms: [flue]
|
|
|
9
9
|
|
|
10
10
|
# Flaky Fix Skill
|
|
11
11
|
|
|
12
|
+
## Output template
|
|
13
|
+
|
|
14
|
+
Required for the human-readable failure, fix and regression verification report: @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/ci-failure-report.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
15
|
+
|
|
12
16
|
## Purpose
|
|
13
17
|
|
|
14
18
|
Analyze flaky test patterns and suggest or auto-apply fixes. Based on FlakyFix research showing LLMs can automatically repair flaky tests with targeted prompts.
|
|
@@ -40,6 +40,10 @@ commandHint:
|
|
|
40
40
|
|
|
41
41
|
**You are the Core Orchestrator** for architecture evolution and refinement workflows.
|
|
42
42
|
|
|
43
|
+
## Output template
|
|
44
|
+
|
|
45
|
+
Use the decision record for architecture decisions and the change card for change requests: @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/governance/adr-template.md; @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/configuration/change-request-card.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
46
|
+
|
|
43
47
|
## Your Role
|
|
44
48
|
|
|
45
49
|
**You orchestrate multi-agent workflows. You do NOT execute bash scripts.**
|
|
@@ -22,6 +22,10 @@ commandHint:
|
|
|
22
22
|
|
|
23
23
|
**You are the Change Control Orchestrator** for managing formal change requests through assessment, approval, and implementation.
|
|
24
24
|
|
|
25
|
+
## Output template
|
|
26
|
+
|
|
27
|
+
Required for the change request card: @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/configuration/change-request-card.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
28
|
+
|
|
25
29
|
## Your Role
|
|
26
30
|
|
|
27
31
|
**You orchestrate multi-agent workflows. You do NOT execute bash scripts.**
|
|
@@ -22,6 +22,10 @@ commandHint:
|
|
|
22
22
|
|
|
23
23
|
**You are the Core Orchestrator** for SDLC phase gate validation.
|
|
24
24
|
|
|
25
|
+
## Output template
|
|
26
|
+
|
|
27
|
+
Required for the gate audit record; retain phase-specific criteria: @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/gate-audit-record.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
28
|
+
|
|
25
29
|
## Your Role
|
|
26
30
|
|
|
27
31
|
**You orchestrate multi-agent workflows. You do NOT execute bash scripts.**
|
|
@@ -22,6 +22,10 @@ commandHint:
|
|
|
22
22
|
|
|
23
23
|
**You are the Core Orchestrator** for validating and executing handoffs between SDLC phases and tracks.
|
|
24
24
|
|
|
25
|
+
## Output template
|
|
26
|
+
|
|
27
|
+
For the accompanying agent handoff note use this template; retain the transition checklist: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/agent-handoff.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
28
|
+
|
|
25
29
|
## Threat-assessment gate
|
|
26
30
|
|
|
27
31
|
Before signoff or packaging, resolve the active workspace member's
|
|
@@ -23,6 +23,10 @@ commandHint:
|
|
|
23
23
|
|
|
24
24
|
**You are the Core Orchestrator** for production incident management and resolution.
|
|
25
25
|
|
|
26
|
+
## Output template
|
|
27
|
+
|
|
28
|
+
Use for the incident summary/postmortem; retain the specialized response artifacts: @$AIWG_ROOT/agentic/code/frameworks/ops-complete/templates/incident.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
29
|
+
|
|
26
30
|
## Your Role
|
|
27
31
|
|
|
28
32
|
**You orchestrate multi-agent workflows. You do NOT execute bash scripts.**
|
|
@@ -36,6 +36,10 @@ commandHint:
|
|
|
36
36
|
|
|
37
37
|
**You are the Core Orchestrator** for the project's release sequence.
|
|
38
38
|
|
|
39
|
+
## Output template
|
|
40
|
+
|
|
41
|
+
Required for release notes: @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/deployment/release-notes-template.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
42
|
+
|
|
39
43
|
## Artifact root resolution
|
|
40
44
|
|
|
41
45
|
Treat every `.aiwg/...` path in this skill as a logical artifact path. Before
|
|
@@ -22,6 +22,10 @@ description: Validate phase gate criteria with multi-agent review and generate p
|
|
|
22
22
|
|
|
23
23
|
Validate phase gate criteria with multi-agent review and generate pass/fail reports.
|
|
24
24
|
|
|
25
|
+
## Output template
|
|
26
|
+
|
|
27
|
+
Required for the gate audit record; retain phase-specific criteria: @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/gate-audit-record.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
28
|
+
|
|
25
29
|
## Triggers
|
|
26
30
|
|
|
27
31
|
|
|
@@ -14,6 +14,10 @@ commandHint:
|
|
|
14
14
|
|
|
15
15
|
# Issue Close
|
|
16
16
|
|
|
17
|
+
## Output template
|
|
18
|
+
|
|
19
|
+
Required for the task completion comment: @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/issue-comments/task-completed.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
20
|
+
|
|
17
21
|
## Semantic Label Contract (#1789)
|
|
18
22
|
|
|
19
23
|
Before closure, resolve lifecycle, blocked, review/approval, and
|
|
@@ -14,6 +14,10 @@ commandHint:
|
|
|
14
14
|
|
|
15
15
|
# Issue Comment
|
|
16
16
|
|
|
17
|
+
## Output template
|
|
18
|
+
|
|
19
|
+
Use the matching issue progress or blocker comment template: @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/issue-comments/progress-update.md; @$AIWG_ROOT/agentic/code/frameworks/sdlc-complete/templates/issue-comments/blocker-found.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
20
|
+
|
|
17
21
|
## Semantic Label Contract (#1789)
|
|
18
22
|
|
|
19
23
|
When a comment requests human action, resolve the configured
|
|
@@ -9,6 +9,10 @@ description: Launch multiple agents concurrently, collect their results, and han
|
|
|
9
9
|
|
|
10
10
|
Generic parallel agent orchestration utility for launching multiple agents concurrently.
|
|
11
11
|
|
|
12
|
+
## Output template
|
|
13
|
+
|
|
14
|
+
Required for each bounded worker brief: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/subagent-brief.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
15
|
+
|
|
12
16
|
## Triggers
|
|
13
17
|
|
|
14
18
|
|
|
@@ -18,6 +18,10 @@ commandHint:
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
+
## Output template
|
|
22
|
+
|
|
23
|
+
Required for the human-readable code-review findings report: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/code-review-findings.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
24
|
+
|
|
21
25
|
## Provider Resolution
|
|
22
26
|
|
|
23
27
|
Don't assume GitHub. The PR API to use is determined by the project's `.aiwg/aiwg.config` `remotes.primary` (#994):
|
|
@@ -32,6 +32,10 @@ commandHint:
|
|
|
32
32
|
|
|
33
33
|
# Project Status (Cross-Framework Aggregator)
|
|
34
34
|
|
|
35
|
+
## Output template
|
|
36
|
+
|
|
37
|
+
When producing a stakeholder status report, use this template around the observed contributor blocks; preserve the established JSON response contract: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/stakeholder-status-report.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
38
|
+
|
|
35
39
|
## Task
|
|
36
40
|
|
|
37
41
|
Produce a unified status report covering every installed framework, addon, or
|
|
@@ -15,6 +15,10 @@ triggers:
|
|
|
15
15
|
|
|
16
16
|
Execute threat modeling, vulnerability scanning, and security control validation.
|
|
17
17
|
|
|
18
|
+
## Output template
|
|
19
|
+
|
|
20
|
+
Required for each human-readable security finding: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/security-finding.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
21
|
+
|
|
18
22
|
## Triggers
|
|
19
23
|
|
|
20
24
|
|
|
@@ -11,6 +11,10 @@ commandHint:
|
|
|
11
11
|
|
|
12
12
|
Perform comprehensive security assessment
|
|
13
13
|
|
|
14
|
+
## Output template
|
|
15
|
+
|
|
16
|
+
Required for each human-readable security finding: @$AIWG_ROOT/agentic/code/addons/aiwg-utils/templates/security-finding.md. Fill every required section; explain non-applicable fields and unrun checks.
|
|
17
|
+
|
|
14
18
|
## Instructions
|
|
15
19
|
|
|
16
20
|
Perform a systematic security audit following these steps:
|
|
@@ -34,3 +34,7 @@ evidence rule](../../rules/test-conformance-evidence.md) before making conforman
|
|
|
34
34
|
Do not present inventory candidates as confirmed defects, passing cases as proof of oracle quality, or optional missing
|
|
35
35
|
discovery as proven registration. Use `test-platform-research` for a platform adapter/template or additional tooling
|
|
36
36
|
recommendation.
|
|
37
|
+
|
|
38
|
+
## Output template
|
|
39
|
+
|
|
40
|
+
Use the conformance report for the assessment; when amending an experiment/protocol or recording its gate decision, use the amendment or gate audit template respectively: @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/conformance-report.md; @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/experiment-amendment.md; @$AIWG_ROOT/agentic/code/addons/testing-quality/templates/gate-audit-record.md. Fill every required section; explain non-applicable fields and unrun checks.
|