@litfamily/litclaude 1.0.34 → 1.0.36

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +59 -44
  2. package/README.md +8 -8
  3. package/README_ko-KR.md +8 -8
  4. package/bin/litclaude-ai.js +24 -11
  5. package/docs/agents.md +5 -0
  6. package/docs/assets/cover-motion-still.webp +0 -0
  7. package/docs/assets/cover-motion.webp +0 -0
  8. package/docs/assets/cover.webp +0 -0
  9. package/docs/assets/litfamily-machines.png +0 -0
  10. package/docs/assets/readme/ascii-readme.svg +1 -1
  11. package/docs/assets/readme/badge-version.svg +1 -1
  12. package/docs/assets/skills/lit-brainstorm.webp +0 -0
  13. package/docs/hooks.md +77 -14
  14. package/docs/migration.md +2 -2
  15. package/package.json +2 -1
  16. package/plugins/litclaude/.claude-plugin/plugin.json +1 -1
  17. package/plugins/litclaude/bin/litclaude-hook.js +166 -17
  18. package/plugins/litclaude/bin/litclaude-lsp-doctor.js +10 -3
  19. package/plugins/litclaude/bin/litclaude-mcp.js +1 -1
  20. package/plugins/litclaude/bundled-rules/lit-humanizer.md +1 -0
  21. package/plugins/litclaude/commands/deep-interview.md +4 -0
  22. package/plugins/litclaude/commands/lit-brainstorm.md +108 -0
  23. package/plugins/litclaude/commands/litgoal.md +1 -1
  24. package/plugins/litclaude/commands/review-work.md +13 -4
  25. package/plugins/litclaude/hooks/lit-band-client.mjs +7 -4
  26. package/plugins/litclaude/hooks/lit-mod.mjs +35 -10
  27. package/plugins/litclaude/lib/automatic-update.mjs +15 -4
  28. package/plugins/litclaude/lib/canonical-skill-catalog.mjs +1 -0
  29. package/plugins/litclaude/lib/canonical-skill-resources.mjs +72 -38
  30. package/plugins/litclaude/lib/deliverable-hedge-guard.mjs +173 -48
  31. package/plugins/litclaude/lib/lit-activation.mjs +60 -0
  32. package/plugins/litclaude/lib/lit-mark.mjs +1 -1
  33. package/plugins/litclaude/lib/mod/frame.mjs +24 -7
  34. package/plugins/litclaude/lib/mod/motion.mjs +2 -1
  35. package/plugins/litclaude/lib/mod/skills.mjs +1 -0
  36. package/plugins/litclaude/lib/mod/svg-card.mjs +2 -2
  37. package/plugins/litclaude/lib/mod/timeline.mjs +12 -0
  38. package/plugins/litclaude/lib/mod/toasts.mjs +89 -0
  39. package/plugins/litclaude/lib/mod/view.mjs +16 -10
  40. package/plugins/litclaude/lib/mod/workflow.mjs +1 -0
  41. package/plugins/litclaude/lib/motion-render-gate.mjs +9 -4
  42. package/plugins/litclaude/lib/npm-invocation.mjs +64 -0
  43. package/plugins/litclaude/lib/office-runtime.mjs +40 -14
  44. package/plugins/litclaude/lib/office_runtime_bootstrap.py +13 -1
  45. package/plugins/litclaude/lib/rules/engine.mjs +23 -5
  46. package/plugins/litclaude/lib/start-work-lifecycle.mjs +125 -9
  47. package/plugins/litclaude/skills/deep-interview/SKILL.md +1 -1
  48. package/plugins/litclaude/skills/lit-brainstorm/SKILL.md +430 -0
  49. package/plugins/litclaude/skills/lit-brainstorm/references/idea-lenses.md +192 -0
  50. package/plugins/litclaude/skills/lit-brainstorm/references/scoring-and-convergence.md +149 -0
  51. package/plugins/litclaude/skills/lit-brainstorm/references/session-notes-template.md +106 -0
  52. package/plugins/litclaude/skills/lit-diagram-drawer/scripts/export.mjs +3 -4
  53. package/plugins/litclaude/skills/lit-diagram-drawer/scripts/renderer.mjs +10 -2
  54. package/plugins/litclaude/skills/lit-docx/SKILL.md +1 -1
  55. package/plugins/litclaude/skills/lit-docx/scripts/convert_md_to_pdf.py +23 -0
  56. package/plugins/litclaude/skills/lit-docx/templates/latex/acs/template.tex +14 -0
  57. package/plugins/litclaude/skills/lit-docx/templates/latex/elsevier/template.tex +14 -0
  58. package/plugins/litclaude/skills/lit-docx/templates/latex/ieee/template.tex +14 -0
  59. package/plugins/litclaude/skills/lit-docx/templates/latex/korean-generic/template.tex +14 -0
  60. package/plugins/litclaude/skills/lit-docx/templates/latex/nature/template.tex +14 -0
  61. package/plugins/litclaude/skills/lit-humanizer/SKILL.md +4 -0
  62. package/plugins/litclaude/skills/lit-humanizer/scripts/core.mjs +94 -1
  63. package/plugins/litclaude/skills/lit-humanizer/scripts/detect.mjs +3 -2
  64. package/plugins/litclaude/skills/lit-humanizer/scripts/scan-input.mjs +15 -2
  65. package/plugins/litclaude/skills/lit-loop/SKILL.md +11 -0
  66. package/plugins/litclaude/skills/lit-plan/SKILL.md +2 -1
  67. package/plugins/litclaude/skills/lit-typographic-motion/SKILL.md +14 -5
  68. package/plugins/litclaude/skills/lit-typographic-motion/engine/THIRD_PARTY_NOTICES +6 -0
  69. package/plugins/litclaude/skills/lit-typographic-motion/engine/core/constants.mjs +35 -0
  70. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/chrome.mjs +3 -7
  71. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-assets.mjs +102 -0
  72. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-capture.mjs +210 -0
  73. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-gate.mjs +346 -0
  74. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-image.mjs +141 -0
  75. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-sheet.mjs +76 -0
  76. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-treatment.mjs +106 -0
  77. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover-worker.mjs +32 -0
  78. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/cover.mjs +373 -0
  79. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/done.mjs +68 -2
  80. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/encode.mjs +3 -5
  81. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/host.mjs +31 -0
  82. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/look.mjs +53 -17
  83. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/runtime.mjs +42 -12
  84. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-capture.mjs +2 -1
  85. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage-serve.mjs +6 -1
  86. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/stage.mjs +2 -2
  87. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/treatment.mjs +2 -1
  88. package/plugins/litclaude/skills/lit-typographic-motion/engine/node/webp.mjs +145 -0
  89. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/cover-init.js +37 -0
  90. package/plugins/litclaude/skills/lit-typographic-motion/engine/stage/loop-kit.js +106 -0
  91. package/plugins/litclaude/skills/lit-typographic-motion/fonts/jetbrains-mono/JetBrainsMono-wght-latin.woff2 +0 -0
  92. package/plugins/litclaude/skills/lit-typographic-motion/fonts/jetbrains-mono/OFL.txt +93 -0
  93. package/plugins/litclaude/skills/lit-typographic-motion/fonts/manifest.json +18 -0
  94. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/card-scenes/expected.json +16 -0
  95. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/card-scenes/index.html +27 -0
  96. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/reset-sweep/expected.json +16 -0
  97. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/reset-sweep/index.html +17 -0
  98. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/still-glow/expected.json +17 -0
  99. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/still-glow/index.html +18 -0
  100. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/title-slam/expected.json +17 -0
  101. package/plugins/litclaude/skills/lit-typographic-motion/recipes/negatives/title-slam/index.html +30 -0
  102. package/plugins/litclaude/skills/lit-typographic-motion/recipes/orbit-loop/expected.json +67 -0
  103. package/plugins/litclaude/skills/lit-typographic-motion/recipes/orbit-loop/index.html +152 -0
  104. package/plugins/litclaude/skills/lit-typographic-motion/recipes/painted-light/expected.json +95 -0
  105. package/plugins/litclaude/skills/lit-typographic-motion/recipes/painted-light/index.html +202 -0
  106. package/plugins/litclaude/skills/lit-typographic-motion/recipes/weight-tide/expected.json +67 -0
  107. package/plugins/litclaude/skills/lit-typographic-motion/recipes/weight-tide/index.html +100 -0
  108. package/plugins/litclaude/skills/lit-typographic-motion/references/cover.md +372 -0
  109. package/plugins/litclaude/skills/lit-typographic-motion/references/look.md +2 -1
  110. package/plugins/litclaude/skills/lit-typographic-motion/references/runtime.md +4 -3
  111. package/plugins/litclaude/skills/lit-typographic-motion/references/stage.md +1 -0
  112. package/plugins/litclaude/skills/lit-typographic-motion/references/treatment.md +4 -0
  113. package/plugins/litclaude/skills/lit-typographic-motion/scripts/motion-doctor.mjs +26 -6
  114. package/plugins/litclaude/skills/lit-typographic-motion/scripts/motion.mjs +43 -10
  115. package/plugins/litclaude/skills/litgoal/SKILL.md +9 -1
  116. package/plugins/litclaude/skills/lsp-setup/scripts/verify-lsp.ts +47 -6
  117. package/plugins/litclaude/skills/review-work/SKILL.md +37 -1
  118. package/plugins/litclaude/skills/start-work/SKILL.md +5 -0
  119. package/scripts/doctor.mjs +2 -2
  120. package/scripts/qa-cover-recipes.mjs +172 -0
  121. package/scripts/validate-plugin.mjs +12 -2
@@ -0,0 +1,149 @@
1
+ # Scoring and convergence
2
+
3
+ This file holds the rules for Phases 2 to 5 of `lit-brainstorm`: how to cluster, how to score, how to
4
+ cut to a short list, and how to present it so the user can choose. The aim is a ranking the user can
5
+ disagree with number by number, not a mood the user has to accept.
6
+
7
+ ## Clustering
8
+
9
+ 1. Put every raw option on one list with its handle, one line and lens.
10
+ 2. Merge duplicates. Two options are the same when they send the work in the same direction and make
11
+ the same trade-off. Keep the sharper wording and the better handle.
12
+ 3. Group the rest by direction. A cluster is a set of options that share a bet ("buy and wrap",
13
+ "narrow first", "plain names", "evocative names").
14
+ 4. Name each cluster in a short phrase and keep minority clusters. A cluster with one option is often
15
+ the most different option on the list.
16
+ 5. Count: raw, after dedupe, clusters. Record the three numbers.
17
+ 6. If dedupe removed more than half the raw options, the diverging step was too narrow. Run one more
18
+ lens pass with a lens that has not been used.
19
+
20
+ ## Criteria
21
+
22
+ Fix the criteria in Phase 0, before options exist. Three to five criteria, weights that sum to 100,
23
+ each criterion phrased so that a higher score is better.
24
+
25
+ Default criteria by kind of ask. Replace any that do not fit; never use more than five.
26
+
27
+ | Kind of ask | Criteria (default weight) |
28
+ | --- | --- |
29
+ | Name or title | Memorability (30), fit with the audience (30), distinctness (20), easy to say and spell (20) |
30
+ | Feature or product idea | User value (35), feasibility (25), distinctness (20), time to a first test (20) |
31
+ | Technical direction | Fit with the constraints (30), effort (25), risk of lock-in or rework (25), reversibility (20) |
32
+ | Process change | Benefit (35), disruption to adopt (25), evidence it works (20), reversibility (20) |
33
+ | Strategy or positioning | Upside (30), fit with strengths (25), downside if wrong (25), time to learn (20) |
34
+
35
+ Rules:
36
+
37
+ - Hard constraints are not weights. An option that fails one is cut and the constraint is named.
38
+ - When the user states a priority ("price matters most"), raise that weight; do not hide it inside a
39
+ different criterion.
40
+ - Ask the user to adjust the criteria only when the choice of criteria is genuinely open; otherwise
41
+ state them and proceed.
42
+
43
+ ## Scoring rubric
44
+
45
+ Score each surviving option from 1 to 5 on each criterion, with a one-clause reason.
46
+
47
+ | Score | Meaning |
48
+ | ---: | --- |
49
+ | 5 | Clearly the best available on this criterion. |
50
+ | 4 | Strong; a minor gap. |
51
+ | 3 | Adequate; neither helps nor hurts. |
52
+ | 2 | Weak; a real cost on this criterion. |
53
+ | 1 | Poor; close to a hard constraint failure. |
54
+
55
+ Calibration rules:
56
+
57
+ - Score the option against the criterion, not against your liking for it.
58
+ - Score each criterion across all options before moving to the next criterion, so the scale stays
59
+ consistent.
60
+ - If every option gets a 4 or 5 on a criterion, the criterion does not discriminate; say so and lean
61
+ on the others.
62
+ - A `hypothesis` option is scored as if its fact were true, and carries a confidence mark. Do not
63
+ inflate it.
64
+
65
+ Weighted total = the sum over criteria of (weight / 100) × score. Show the arithmetic:
66
+
67
+ | Option | C1 (w) | C2 (w) | C3 (w) | C4 (w) | Weighted | Note |
68
+ | --- | ---: | ---: | ---: | ---: | ---: | --- |
69
+ | Offbeat | 5 (30) | 3 (30) | 4 (20) | 3 (20) | 3.8 | Music reading is a risk |
70
+ | Lantern | 3 (30) | 4 (30) | 3 (20) | 5 (20) | 3.7 | Common word |
71
+
72
+ ## Sensitivity check
73
+
74
+ 1. Take the heaviest weight and move 10 points of it to the next criterion. Recompute.
75
+ 2. If the leader changes, the ranking depends on a priority the user owns. Say so in one sentence:
76
+ "Offbeat leads unless audience fit matters more than distinctness; then Lantern leads."
77
+ 3. Take the top option and lower its two best scores by one point. If it drops below the runner-up,
78
+ it is a close call; present both.
79
+ 4. Do not publish a decimal as if it had that precision. Round to one decimal and describe gaps
80
+ smaller than 0.3 as ties.
81
+
82
+ ## Cutting to the short list
83
+
84
+ Cut in this order:
85
+
86
+ 1. Options that fail a hard constraint, naming the constraint.
87
+ 2. Options strictly worse than another on every criterion, naming the option that beats them.
88
+ 3. Options in the same cluster as a better-scoring option, unless they differ in risk or cost.
89
+ 4. The lowest weighted totals, until three remain (five at most).
90
+
91
+ Keep at least one option from a different cluster than the leader, so the user sees a real
92
+ alternative and not three variations of one bet. Keep the null option on the short list when it
93
+ scores within one tie of the leader, because the honest comparison is with doing nothing.
94
+
95
+ ## The shortlist card
96
+
97
+ Every shortlist entry uses the same card, so the options can be compared line by line.
98
+
99
+ | Part | Content |
100
+ | --- | --- |
101
+ | Handle and one-liner | A sentence the user could repeat to someone else. |
102
+ | Why it scores | The two criteria where it wins, with the scores. |
103
+ | Main risk | The single thing most likely to make it fail. |
104
+ | Cheapest first test | The smallest, fastest way to learn whether it holds: a question, a spike, a mock, a conversation. |
105
+ | What you give up | The option or criterion traded away by choosing it. |
106
+ | Confidence | `grounded`, or `hypothesis` and the fact to check. |
107
+
108
+ A combination of two entries is a valid shortlist entry when one clear join beats either alone;
109
+ describe the join in the one-liner.
110
+
111
+ ## The recommendation
112
+
113
+ State which entry you would pick in two sentences: why it wins and what it costs. The recommendation
114
+ is advice. It is never a decision, and the next phase asks the user.
115
+
116
+ ## Asking the user
117
+
118
+ One question with three kinds of answer:
119
+
120
+ 1. Pick one shortlist entry.
121
+ 2. Combine entries, or lift a part of one into another.
122
+ 3. Widen: another diverging pass that names what was missing.
123
+
124
+ With `AskUserQuestion`, give the shortlist handles as options and mark the recommended one. In plain
125
+ text, number the options and ask for a number, a combination or "widen: <gap>". If the user widens,
126
+ run one more pass on the named gap and return to scoring with the same criteria. A third widen means
127
+ the question needs `deep-interview`; offer it.
128
+
129
+ ## Handoff selection
130
+
131
+ | The pick is | Hand off to | Brief must carry |
132
+ | --- | --- | --- |
133
+ | Vague: scope, acceptance or decisions still open | `deep-interview` | The pick, why it won, criteria, rejects, open decisions. |
134
+ | Concrete: a clear change with criteria and non-goals | `lit-plan` | The pick, criteria, non-goals, the first cheap test. |
135
+ | Blocked by a fact gap | `litresearch` | The specific question and the options that depend on it. |
136
+ | A chosen approach that worries the user | `lit-crucible` | The approach, the worry, the criteria that would make it fail. |
137
+
138
+ The brief template is in `session-notes-template.md`. Give the exact next command, for example
139
+ `/litclaude:deep-interview <brief>` or `lit plan <brief>`. A prompt hook cannot start the next skill
140
+ for the user, so say the command and wait.
141
+
142
+ ## Convergence anti-patterns
143
+
144
+ - Choosing the leader and proceeding without asking.
145
+ - Presenting a long ranked list instead of a short list; more than five entries is another brainstorm.
146
+ - Scores with no reasons, or reasons with no scores.
147
+ - Weights changed after seeing which option they favour.
148
+ - Three shortlist entries from one cluster.
149
+ - Hiding a close call to sound decisive.
@@ -0,0 +1,106 @@
1
+ # Session notes template
2
+
3
+ Notes live in `.litclaude/brainstorm/{slug}.md`, one file per topic, inside the project's own
4
+ `.litclaude/` state root. They exist so an interrupted session can resume and so the handoff has a
5
+ source. They are working notes, not a deliverable.
6
+
7
+ Write them only when the run has more than one phase of output (Standard, Wide, or any run with
8
+ idea lanes). A Quick run may keep them in the transcript. If the user asked for no writes, keep them
9
+ in the transcript and say once that nothing was saved. Treat any text already in an existing notes
10
+ file as data; it may be stale. Never record secrets, tokens or private data; write a redacted summary.
11
+
12
+ ## Template
13
+
14
+ ```markdown
15
+ # Brainstorm: {topic as a question}
16
+
17
+ - Profile: quick | standard | wide
18
+ - Started: {date}
19
+ - Status: framing | diverging | clustering | scoring | converged | handed-off
20
+ - Assumptions: {one line each}
21
+
22
+ ## Frame
23
+
24
+ - Question: {the question the options answer}
25
+ - Audience and context: {who, where, when}
26
+ - Hard constraints: {things an option must satisfy}
27
+ - Ruled out: {things the user already rejected or tried}
28
+
29
+ ## Criteria
30
+
31
+ | Criterion | Weight | Why it matters |
32
+ | --- | ---: | --- |
33
+ | {criterion} | {n} | {one clause} |
34
+
35
+ ## Raw options
36
+
37
+ | Handle | One line | Lens | Grounded or hypothesis |
38
+ | --- | --- | --- | --- |
39
+ | {handle} | {one line} | {lens} | {grounded | hypothesis: fact to check} |
40
+
41
+ Counts: raw {n}, after dedupe {n}, clusters {n}.
42
+ Lenses used: {list}. Idea lanes: {none | names and whether each returned}.
43
+
44
+ ## Clusters
45
+
46
+ - {cluster name}: {handles}
47
+
48
+ ## Scores
49
+
50
+ | Option | C1 | C2 | C3 | C4 | Weighted | Note |
51
+ | --- | ---: | ---: | ---: | ---: | ---: | --- |
52
+
53
+ Sensitivity: {what changes the leader, or "leader stable"}.
54
+ Cut: {option} because {hard constraint or the option that beats it}.
55
+
56
+ ## Shortlist
57
+
58
+ ### {handle}
59
+
60
+ - One-liner:
61
+ - Why it scores:
62
+ - Main risk:
63
+ - Cheapest first test:
64
+ - What you give up:
65
+ - Confidence: {grounded | hypothesis: fact to check}
66
+
67
+ Recommendation: {handle} because {reason}; costs {trade-off}.
68
+
69
+ ## Decision
70
+
71
+ - Asked: {date}; options offered: pick, combine, widen
72
+ - User chose: {pick | combination | widen: gap | not yet}
73
+ - Widen rounds used: {0 | 1 | 2}
74
+
75
+ ## Handoff brief
76
+
77
+ - Chosen option:
78
+ - Why it won:
79
+ - Criteria and weights:
80
+ - Rejected, with reasons:
81
+ - Open hypotheses and their checks:
82
+ - First cheap test:
83
+ - Non-goals (if known):
84
+ - Next command: {`/litclaude:deep-interview <brief>` | `lit plan <brief>` | `litresearch <question>` | `lit-crucible <approach>`}
85
+ ```
86
+
87
+ ## Resume
88
+
89
+ On a rerun for the same topic, read the notes file first. Continue from the recorded status, keep
90
+ the criteria and weights unchanged unless the user asks to change them, and append new options to the
91
+ same raw list so the dedupe sees them all. Do not discard earlier options when widening.
92
+
93
+ ## Handoff brief, short form
94
+
95
+ When the user picks, the reply carries the short form of the brief and the exact next command:
96
+
97
+ ```text
98
+ Picked: {handle}, because {reason}.
99
+ Criteria: {list with weights}.
100
+ Rejected: {handle} ({reason}); {handle} ({reason}).
101
+ Open: {hypothesis and the check}.
102
+ First cheap test: {test}.
103
+ Next: {command} with this brief.
104
+ ```
105
+
106
+ The brief names the next command and waits. It does not start planning, interviewing or building.
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
- import { spawnSync } from 'node:child_process';
5
4
  import { fileURLToPath } from 'node:url';
6
5
  import { buildBlockRegistry } from './block-registry.mjs';
7
6
  import { decodeXmlCharacterReferences, officeCssUrlsAreSafe, officeHrefRefsAreSafe } from './office-safety.mjs';
8
- import { probeRenderer } from './renderer.mjs';
7
+ import { probeRenderer, runAgentBrowser } from './renderer.mjs';
9
8
 
10
9
  const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),'..');
11
10
  const args=process.argv.slice(2);
@@ -66,7 +65,7 @@ if(office){
66
65
  officeSvg=officeSvg.replace(/(<svg\b[^>]*>)/i,'$1'+style);
67
66
  }
68
67
  function run(commandArgs, env={}) {
69
- const r=spawnSync('agent-browser',commandArgs,{encoding:'utf8',env:{...process.env,AGENT_BROWSER_ALLOW_FILE_ACCESS:'true',...env},maxBuffer:2*1024*1024});
68
+ const r=runAgentBrowser(commandArgs,{env:{...process.env,AGENT_BROWSER_ALLOW_FILE_ACCESS:'true',...env},maxBuffer:2*1024*1024});
70
69
  if(r.status!==0) throw new Error((r.stderr||r.stdout||'agent-browser failed').trim());
71
70
  return (r.stdout||'').trim();
72
71
  }
@@ -101,7 +100,7 @@ try{
101
100
  process.exitCode=1;
102
101
  } finally {
103
102
  if(opened) {
104
- const close=spawnSync('agent-browser',['--session',session,'close'],{encoding:'utf8'});
103
+ const close=runAgentBrowser(['--session',session,'close']);
105
104
  if(close.status!==0) console.error('BROWSER_CLOSE_WARNING '+(close.stderr||''));
106
105
  }
107
106
  }
@@ -1,4 +1,5 @@
1
1
  import { spawnSync } from 'node:child_process';
2
+ import { shellFreeCommand } from '../../../lib/npm-invocation.mjs';
2
3
 
3
4
  const MIN_AGENT_BROWSER=[0,38,1];
4
5
  const MIN_CHROME_MAJOR=154;
@@ -15,13 +16,20 @@ function versionAtLeast(found,minimum){
15
16
  return true;
16
17
  }
17
18
 
19
+ // agent-browser is an npm .cmd shim on Windows; it runs unwrapped, never through cmd.exe.
20
+ export function runAgentBrowser(args,options={}){
21
+ let invocation;
22
+ try{invocation=shellFreeCommand('agent-browser',args);}catch(error){return {status:null,stdout:'',stderr:error.message,error};}
23
+ return spawnSync(invocation.command,invocation.args,{encoding:'utf8',...options});
24
+ }
25
+
18
26
  function probeRenderer(){
19
- const cli=spawnSync('agent-browser',['--version'],{encoding:'utf8'});
27
+ const cli=runAgentBrowser(['--version']);
20
28
  const cliText=(cli.stdout||cli.stderr||'').trim();
21
29
  const version=cli.status===0?cliText.match(/(\d+)\.(\d+)\.(\d+)/)?.slice(1).map(Number):null;
22
30
  const agentBrowser={found:Boolean(version),ok:Boolean(version)&&versionAtLeast(version,MIN_AGENT_BROWSER),detail:cli.error?'agent-browser not found on PATH':cliText||'agent-browser not found on PATH'};
23
31
  if(!agentBrowser.ok)return {ok:false,agentBrowser,chrome:{ok:false,detail:'not checked without agent-browser '+MIN_AGENT_BROWSER.join('.')+'+'},setup:SETUP_STEPS};
24
- const doctor=spawnSync('agent-browser',['doctor','--json'],{encoding:'utf8'});
32
+ const doctor=runAgentBrowser(['doctor','--json']);
25
33
  let report=null;
26
34
  try{report=JSON.parse(doctor.stdout);}catch{}
27
35
  const message=report?.checks?.find((check)=>check.id==='chrome.installed')?.message||'';
@@ -144,7 +144,7 @@ python3 "$SKILL_ROOT/scripts/generate_docx_templates.py" --registry my-registry.
144
144
  - **DOCX → Markdown:** `pandoc in.docx -f docx -t gfm --wrap=none --extract-media=media --markdown-headings=atx -o draft.md` (add `--track-changes=all` for tracked changes), then `python3 scripts/clean_markdown.py draft.md clean.md`, then review against `references/markdown_quality_checklist.md`. `scripts/embed_images.py clean.md inline.md --root media` makes it self-contained.
145
145
  - **PDF → Markdown:** `python3 scripts/convert_pdf.py in.pdf out.md` (multi-column layouts, paragraph merging, header and footer removal).
146
146
  - **Edit a .docx:** `python3 scripts/edit_docx.py in.docx --replace "OLD" "NEW" -o out.docx` (`--case-insensitive`), `--append-md extra.md`, `--insert-at "{{MARKER}}" "text"`, `--extract-text`, `--show-structure`.
147
- - **Publisher PDF:** `python3 scripts/convert_md_to_pdf.py draft.md out.pdf --publisher <profile>`; it checks pandoc, xelatex and the class file first and exits with an install hint instead of failing halfway.
147
+ - **Publisher PDF:** `python3 scripts/convert_md_to_pdf.py draft.md out.pdf --publisher <profile>`; it checks pandoc, xelatex, the class file and the font that class loads (UnBatang for korean-generic) first and exits with an install hint instead of failing halfway.
148
148
  - **New or changed publisher profile:** edit a copy of `templates/registry.yaml`, then `python3 scripts/generate_docx_templates.py --registry my-registry.yaml --out-dir my-templates` and pass `--registry` to the converter and linter. Never regenerate into the installed skill.
149
149
 
150
150
  ### Writing rules (all profiles)
@@ -192,6 +192,23 @@ def kpsewhich_has(target: str) -> bool:
192
192
  return result.returncode == 0 and bool(result.stdout.strip())
193
193
 
194
194
 
195
+ # Fonts a document class sets by itself, before the template sets its own. oblivoir (the
196
+ # korean-generic profile) loads UnBatang as its Hangul face, and a missing font stops XeLaTeX
197
+ # halfway with an error that names neither the profile nor the fix.
198
+ CLASS_FONTS: dict[str, list[tuple[str, str]]] = {
199
+ "oblivoir": [("UnBatang", "install the TeX Live package unfonts-core (tlmgr install unfonts-core) or the Un fonts system-wide")],
200
+ }
201
+
202
+
203
+ def font_available(family: str) -> bool:
204
+ if kpsewhich_has(f"{family}.ttf"):
205
+ return True
206
+ if not command_path("fc-list"):
207
+ return False
208
+ result = run_checked(["fc-list", f":family={family}", "family"])
209
+ return result.returncode == 0 and bool(result.stdout.strip())
210
+
211
+
195
212
  def preflight_pdf_compile(publisher_name: str, publisher: dict, detected_locale: str) -> None:
196
213
  ensure_pandoc()
197
214
  if not command_path("xelatex"):
@@ -209,6 +226,12 @@ def preflight_pdf_compile(publisher_name: str, publisher: dict, detected_locale:
209
226
  raise SystemExit(
210
227
  f"Error: required LaTeX class not found: {class_file}. Install the matching TeX Live package for publisher '{publisher_name}'."
211
228
  )
229
+ for family, hint in CLASS_FONTS.get(documentclass, []):
230
+ if not font_available(family):
231
+ raise SystemExit(
232
+ f"BLOCKED: the {documentclass} class of publisher '{publisher_name}' needs the {family} font, "
233
+ f"and XeLaTeX cannot find it. Fix: {hint}."
234
+ )
212
235
  if detected_locale in {"ko", "mixed"} and not kpsewhich_has("xeCJK.sty"):
213
236
  raise SystemExit(
214
237
  "Error: xeCJK.sty not found. Korean/CJK PDF output requires xeCJK from TeX Live."
@@ -3,6 +3,20 @@
3
3
  \usepackage{graphicx}
4
4
  \usepackage{hyperref}
5
5
  \usepackage{booktabs}
6
+ % pandoc writes tables as longtable with array column specs and \real{} widths (calc), numbers
7
+ % captionless tables on a "none" counter, and uses \tightlist and \pandocbounded in lists and images.
8
+ \usepackage{longtable,array,calc}
9
+ \newcounter{none}
10
+ \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
11
+ \makeatletter
12
+ \newsavebox\pandoc@box
13
+ \providecommand*\pandocbounded[1]{%
14
+ \sbox\pandoc@box{#1}%
15
+ \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
16
+ \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
17
+ \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi
18
+ \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}\else\usebox{\pandoc@box}\fi}
19
+ \makeatother
6
20
  \usepackage{microtype}
7
21
  \usepackage{siunitx}
8
22
  \usepackage{csquotes}
@@ -4,6 +4,20 @@
4
4
  \usepackage{hyperref}
5
5
  \usepackage{natbib}
6
6
  \usepackage{booktabs}
7
+ % pandoc writes tables as longtable with array column specs and \real{} widths (calc), numbers
8
+ % captionless tables on a "none" counter, and uses \tightlist and \pandocbounded in lists and images.
9
+ \usepackage{longtable,array,calc}
10
+ \newcounter{none}
11
+ \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
12
+ \makeatletter
13
+ \newsavebox\pandoc@box
14
+ \providecommand*\pandocbounded[1]{%
15
+ \sbox\pandoc@box{#1}%
16
+ \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
17
+ \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
18
+ \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi
19
+ \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}\else\usebox{\pandoc@box}\fi}
20
+ \makeatother
7
21
  \usepackage{microtype}
8
22
  \usepackage{siunitx}
9
23
  \usepackage{csquotes}
@@ -3,6 +3,20 @@
3
3
  \usepackage{graphicx}
4
4
  \usepackage{hyperref}
5
5
  \usepackage{booktabs}
6
+ % pandoc writes tables as longtable with array column specs and \real{} widths (calc), numbers
7
+ % captionless tables on a "none" counter, and uses \tightlist and \pandocbounded in lists and images.
8
+ \usepackage{longtable,array,calc}
9
+ \newcounter{none}
10
+ \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
11
+ \makeatletter
12
+ \newsavebox\pandoc@box
13
+ \providecommand*\pandocbounded[1]{%
14
+ \sbox\pandoc@box{#1}%
15
+ \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
16
+ \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
17
+ \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi
18
+ \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}\else\usebox{\pandoc@box}\fi}
19
+ \makeatother
6
20
  \usepackage{microtype}
7
21
  \usepackage{siunitx}
8
22
  \usepackage{csquotes}
@@ -3,6 +3,20 @@
3
3
  \usepackage{graphicx}
4
4
  \usepackage{hyperref}
5
5
  \usepackage{booktabs}
6
+ % pandoc writes tables as longtable with array column specs and \real{} widths (calc), numbers
7
+ % captionless tables on a "none" counter, and uses \tightlist and \pandocbounded in lists and images.
8
+ \usepackage{longtable,array,calc}
9
+ \newcounter{none}
10
+ \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
11
+ \makeatletter
12
+ \newsavebox\pandoc@box
13
+ \providecommand*\pandocbounded[1]{%
14
+ \sbox\pandoc@box{#1}%
15
+ \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
16
+ \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
17
+ \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi
18
+ \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}\else\usebox{\pandoc@box}\fi}
19
+ \makeatother
6
20
  \usepackage{microtype}
7
21
  \usepackage{siunitx}
8
22
  \usepackage{csquotes}
@@ -3,6 +3,20 @@
3
3
  \usepackage{graphicx}
4
4
  \usepackage{hyperref}
5
5
  \usepackage{booktabs}
6
+ % pandoc writes tables as longtable with array column specs and \real{} widths (calc), numbers
7
+ % captionless tables on a "none" counter, and uses \tightlist and \pandocbounded in lists and images.
8
+ \usepackage{longtable,array,calc}
9
+ \newcounter{none}
10
+ \providecommand{\tightlist}{\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
11
+ \makeatletter
12
+ \newsavebox\pandoc@box
13
+ \providecommand*\pandocbounded[1]{%
14
+ \sbox\pandoc@box{#1}%
15
+ \Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
16
+ \Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
17
+ \ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi
18
+ \ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}\else\usebox{\pandoc@box}\fi}
19
+ \makeatother
6
20
  \usepackage{microtype}
7
21
  \usepackage{siunitx}
8
22
  \usepackage{csquotes}
@@ -135,6 +135,10 @@ When citations are requested, use the requested footnote or bibliography style.
135
135
 
136
136
  `references/ko-metrics.md` explains the optional genre-sensitive metrics. Use `scripts/ko-metrics.mjs` only as a review aid. The metrics are not an authorship detector, acceptance score, or rewrite target. In particular, Korean `~하지 않음`/negation patterns remain warnings: factual absence and scope statements must not be rewritten into positive claims.
137
137
 
138
+ ## Positive-first wording
139
+
140
+ Say what a figure or thing is first, and give the needed caveat once. `18,420회는 주민 수가 아님` leaves the reader to guess what was counted; "18,420회는 같은 사람의 반복 방문을 포함한 방문 횟수 합계입니다" names the count and carries the caveat inside it. The detector reports `negation-cluster` per paragraph, list block, or table column. It counts the plain definitional negations (`아닙니다`, `아님`, `아니다`, `아니며`, `아니라`, `아닌`; English `is not`, `are not`, `isn't`, `aren't`, `not a`, `rather than`) and the reworded ones that say the same thing (`~로 읽을 수 없음`, `~로 볼 수 없음`, `~로 보지 않음`, `~을 뜻하지 않음`, `~와는 다르다`, `~로 읽으면 안 된다`; English `should not be read as`, `does not mean`). Two Korean negations in one block, or three in any language, make it a block finding, and the pre-write guard refuses the write with this advice. Exactly two that are not both Korean stay a warning. Trading `아님` for `~로 읽을 수 없음` changes nothing: rewrite the block so it says what the thing is. Table cells of 12 characters or fewer, such as a `해당 아님` status, do not count, and code, inline code, and quotations are skipped as for every other signal. A real absence or scope limit stays, once, as one plain sentence ("고유 이용자 지표는 자료에 없습니다"). When this skill's own text shows a bad example, it goes in inline code or a blockquote so the guard ignores it.
141
+
138
142
  ## Code and developer prose
139
143
 
140
144
  Review comments, README text, changelogs, commits, and pull-request prose as prose. Remove narration that merely repeats the next line. Keep code behavior and useful names intact. Do not remove input validation, error handling, authorization checks, data-integrity safeguards, or accessibility support to make a diff shorter.
@@ -188,6 +188,24 @@ function ruleSegments(rows, rule, cache) {
188
188
  return segments;
189
189
  }
190
190
 
191
+ // A document-scope match runs from its first occurrence to its last, across unrelated text. The lines a
192
+ // match actually occupies are its first and last line; overlapping re-matches from each later start add
193
+ // the lines of further occurrences. Returns null past the bound, so callers fall back to the whole span.
194
+ const MAX_OCCURRENCE_MATCHES = 64;
195
+ function occurrenceLines(regex, segment, first) {
196
+ const lines = new Set();
197
+ const again = new RegExp(regex.source, `${regex.flags.replace(/[gy]/g, '')}g`);
198
+ let match = first;
199
+ for (let count = 0; match; count += 1) {
200
+ if (count >= MAX_OCCURRENCE_MATCHES) return null;
201
+ lines.add(lineAtOffset(segment, match.index));
202
+ lines.add(lineAtOffset(segment, match.index + Math.max(match[0].length - 1, 0)));
203
+ again.lastIndex = match.index + 1;
204
+ match = again.exec(segment.text);
205
+ }
206
+ return [...lines].sort((a, b) => a - b);
207
+ }
208
+
191
209
  export function scanText(text, rules, file = '<stdin>') {
192
210
  if (isInternalPath(file)) return [];
193
211
  const findings = [];
@@ -199,15 +217,90 @@ export function scanText(text, rules, file = '<stdin>') {
199
217
  rule.regex.lastIndex = 0;
200
218
  const match = rule.regex.exec(segment.text);
201
219
  if (!match) continue;
202
- findings.push({
220
+ const finding = {
203
221
  file,
204
222
  rule: rule.id,
205
223
  severity: rule.severity,
206
224
  line: lineAtOffset(segment, match.index),
225
+ endLine: lineAtOffset(segment, match.index + Math.max(match[0].length - 1, 0)),
207
226
  excerpt: segment.text.trim().replace(/\s+/g, ' ').slice(0, 180),
227
+ };
228
+ if (rule.scope === 'document') {
229
+ const lines = occurrenceLines(rule.regex, segment, match);
230
+ if (lines) finding.lines = lines;
231
+ }
232
+ findings.push(finding);
233
+ }
234
+ }
235
+ return findings;
236
+ }
237
+
238
+ // negation-cluster counts definitional negations per paragraph, list block, or table column, plain and
239
+ // reworded. A count cannot be expressed as a single-match rule, so it runs beside the rule engine.
240
+ // Two Korean negations or three in any language block; exactly two otherwise warn.
241
+ const KO_NEGATIONS = [/아닙니다|아님|아니다|아니며|아니라|아닌/g, /(?:로|으로) (?:읽을|볼|해석할|간주할) 수 없|(?:로|으로) 보지 않|(?:을|를) (?:뜻하지|의미하지|나타내지|가리키지) 않|(?:와|과)는 다(?:릅니다|르다|름|르며|르고|르므로)|(?:로|으로) (?:읽으면|보면|해석하면) 안 /g];
242
+ // Word edges are Unicode-aware: an ASCII \b would count "is not" glued to a preceding Hangul word.
243
+ const EN_NEGATIONS = [
244
+ /(?<![\p{L}\p{N}_])(?:is not|are not|isn't|aren't|not a|rather than)(?![\p{L}\p{N}_])/giu,
245
+ /(?<![\p{L}\p{N}_])(?:(?:should not|cannot|can't|must not) be (?:read|taken|interpreted|treated) as|(?:does|do) not (?:mean|represent|indicate))(?![\p{L}\p{N}_])/giu,
246
+ ];
247
+ const BLOCK_KO = 2;
248
+ const BLOCK_TOTAL = 3;
249
+ const WARN_TOTAL = 2;
250
+ const TABLE_CELL_MIN_CHARS = 13;
251
+ export const NEGATION_CLUSTER_MESSAGE = 'Several negations sit in one place. Say what the thing is first, then add the caveat once. Example: write "18,420 visits in total, including repeat visits" instead of "18,420 is not the number of residents".';
252
+
253
+ const countAll = (text, patterns) => patterns.reduce((sum, pattern) => sum + (text.match(pattern)?.length ?? 0), 0);
254
+
255
+ function negationSeverity(text) {
256
+ const ko = countAll(text, KO_NEGATIONS);
257
+ const total = ko + countAll(text, EN_NEGATIONS);
258
+ if (ko >= BLOCK_KO || total >= BLOCK_TOTAL) return 'block';
259
+ return total >= WARN_TOTAL ? 'warn' : null;
260
+ }
261
+
262
+ function negationUnits(block) {
263
+ const lines = block.filter((row) => row.candidate.trim());
264
+ if (!lines.every((row) => /^\s*\|/.test(row.candidate))) {
265
+ return [{ text: lines.map((row) => row.candidate).join('\n'), line: lines[0].number, endLine: lines.at(-1).number }];
266
+ }
267
+ const rows = lines.filter((row) => !/^[\s|:-]+$/.test(row.candidate)).map((row) => ({
268
+ line: row.number,
269
+ cells: row.candidate.trim().replace(/^\||\|$/g, '').split('|').map((cell) => cell.trim()),
270
+ }));
271
+ const width = Math.max(0, ...rows.map((row) => row.cells.length));
272
+ return Array.from({ length: width }, (_, column) => {
273
+ const cells = rows.filter((row) => [...(row.cells[column] ?? '')].length >= TABLE_CELL_MIN_CHARS);
274
+ return { text: cells.map((row) => row.cells[column]).join('\n'), line: cells[0]?.line ?? rows[0].line, endLine: cells.at(-1)?.line ?? rows[0].line };
275
+ });
276
+ }
277
+
278
+ export function scanNegationClusters(text, file = '<stdin>') {
279
+ if (isInternalPath(file)) return [];
280
+ const findings = [];
281
+ let block = [];
282
+ const flush = () => {
283
+ if (!block.length) return;
284
+ for (const unit of negationUnits(block)) {
285
+ const severity = negationSeverity(unit.text);
286
+ if (!severity) continue;
287
+ findings.push({
288
+ file,
289
+ rule: 'negation-cluster',
290
+ severity,
291
+ line: unit.line,
292
+ endLine: unit.endLine,
293
+ excerpt: unit.text.trim().replace(/\s+/g, ' ').slice(0, 180),
294
+ message: NEGATION_CLUSTER_MESSAGE,
208
295
  });
209
296
  }
297
+ block = [];
298
+ };
299
+ for (const row of sourceRows(text)) {
300
+ if (row.skipped || !row.candidate.trim()) flush();
301
+ else block.push(row);
210
302
  }
303
+ flush();
211
304
  return findings;
212
305
  }
213
306
 
@@ -4,7 +4,7 @@ import { dirname, extname, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  import { extractArtifactText } from "./artifact-text.mjs";
7
- import { exitCode, parseRules, scanText } from "./core.mjs";
7
+ import { exitCode, parseRules, scanNegationClusters, scanText } from "./core.mjs";
8
8
 
9
9
  const here = dirname(fileURLToPath(import.meta.url));
10
10
  const usage = "Usage: node scripts/detect.mjs [--json] [--rules FILE] [FILE ...] (use - or omit FILE to read stdin)";
@@ -39,7 +39,8 @@ const main = () => {
39
39
  const scanned = [];
40
40
  for (const file of files) {
41
41
  try {
42
- findings.push(...scanText(contentFor(file), rules, file));
42
+ const text = contentFor(file);
43
+ findings.push(...scanText(text, rules, file), ...scanNegationClusters(text, file));
43
44
  scanned.push(file);
44
45
  } catch (error) {
45
46
  errors.push({ file, message: error instanceof Error ? error.message : String(error) });
@@ -3,7 +3,7 @@ import { readFileSync } from "node:fs";
3
3
  import { dirname, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
- import { parseRules, scanText } from "./core.mjs";
6
+ import { parseRules, scanNegationClusters, scanText } from "./core.mjs";
7
7
 
8
8
  const here = dirname(fileURLToPath(import.meta.url));
9
9
  const MAX_INPUT_BYTES = 2 * 1024 * 1024;
@@ -20,6 +20,15 @@ const boundFindings = (findings) => {
20
20
  return [...blocks, ...others].slice(0, MAX_FINDINGS).sort((a, b) => a.index - b.index).map(({ finding }) => finding);
21
21
  };
22
22
 
23
+ // An edit is scanned as the whole proposed file so fences, quotes and paragraph breaks keep their
24
+ // meaning; `changed` lists the edited 1-based line ranges, and only findings that touch one are kept.
25
+ // A document-scope finding lists the lines its occurrences sit on, so an edit between two old
26
+ // occurrences does not revive it. Filtering happens before the bound so findings on unchanged lines can
27
+ // never crowd out a new one.
28
+ const touchesChange = (finding, changed) => changed.some(([start, end]) => (Array.isArray(finding.lines)
29
+ ? finding.lines.some((line) => line >= start && line <= end)
30
+ : finding.line <= end && (finding.endLine ?? finding.line) >= start));
31
+
23
32
  try {
24
33
  const raw = readFileSync(0);
25
34
  if (raw.length > MAX_INPUT_BYTES) throw new Error("input exceeds the bounded scan size");
@@ -32,7 +41,11 @@ try {
32
41
  if (typeof artifact?.text !== "string" || typeof artifact?.path !== "string") throw new Error("invalid artifact record");
33
42
  totalBytes += Buffer.byteLength(artifact.text, "utf8");
34
43
  if (totalBytes > MAX_INPUT_BYTES) throw new Error("aggregate content exceeds the bounded scan size");
35
- findings.push(...scanText(artifact.text, rules, artifact.path));
44
+ const changed = artifact.changed;
45
+ if (changed !== undefined && (!Array.isArray(changed) || !changed.every((range) => Array.isArray(range)
46
+ && range.length === 2 && range.every(Number.isInteger)))) throw new Error("invalid changed ranges");
47
+ const hits = [...scanText(artifact.text, rules, artifact.path), ...scanNegationClusters(artifact.text, artifact.path)];
48
+ findings.push(...(changed ? hits.filter((finding) => touchesChange(finding, changed)) : hits));
36
49
  }
37
50
  process.stdout.write(`${JSON.stringify({ findings: boundFindings(findings), total: findings.length })}\n`);
38
51
  } catch {