asciidoc-pubkit 0.6.1 → 0.6.3

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.
data/README.md CHANGED
@@ -7,14 +7,17 @@
7
7
 
8
8
  A toolkit for authoring and reviewing AsciiDoc books.
9
9
 
10
- Version 0.6.1 provides shared Japanese technical writing criteria, an authoring
11
- prompt, contextual review prompts, manuscript scoring, and baseline verification
12
- for edited manuscripts.
10
+ Version 0.6.3 provides shared Japanese technical writing criteria, an authoring
11
+ prompt, separate prose and heading review prompts, manuscript scoring, and
12
+ baseline verification for edited manuscripts.
13
13
  The CLI, diagnostics, documentation, and generated instructions are in English.
14
14
  Japanese text is retained in manuscript excerpts, rule dictionaries, and fixtures.
15
15
 
16
16
  ## Status
17
17
 
18
+ Version 0.6.3 adds separate heading review with `review scan --scope headings`.
19
+ See [Heading review](#heading-review).
20
+
18
21
  The CLI does not automatically rewrite manuscripts or publish books. EPUB, image,
19
22
  and book scaffolding commands are planned extensions, not available features.
20
23
 
@@ -23,7 +26,7 @@ Starting with version 0.1.1, the default review backend requires the external Me
23
26
  command and a UTF-8 IPADIC dictionary. Node.js and textlint are not required.
24
27
  Explicit `--tokenizer literal` mode provides limited phrase matching without MeCab.
25
28
 
26
- Version 0.6.1 also provides `review score FILE` for a manuscript score.
29
+ Version 0.6.2 also provides `review score FILE` for a manuscript score.
27
30
  It uses local candidate analysis by default; `--agent codex` or `--agent claude`
28
31
  explicitly asks an installed CLI to evaluate readability and may connect to its
29
32
  configured model provider. No scoring mode edits manuscripts.
@@ -80,7 +83,7 @@ Add the gem to your project's `Gemfile` to manage its version with Bundler:
80
83
 
81
84
  ```ruby
82
85
  source 'https://rubygems.org'
83
- gem 'asciidoc-pubkit', '~> 0.6.1'
86
+ gem 'asciidoc-pubkit', '~> 0.6.3'
84
87
  ```
85
88
 
86
89
  Then install dependencies and run the CLI through Bundler:
@@ -102,7 +105,7 @@ git clone https://github.com/cybergarage/asciidoc-pubkit.git
102
105
  cd asciidoc-pubkit
103
106
  bundle install
104
107
  gem build asciidoc-pubkit.gemspec
105
- gem install ./asciidoc-pubkit-0.6.1.gem
108
+ gem install ./asciidoc-pubkit-0.6.3.gem
106
109
  asciidoc-pubkit --version
107
110
  ```
108
111
 
@@ -126,7 +129,7 @@ asciidoc-pubkit writing prompt --lang ja --output writing-prompt.md
126
129
  ```
127
130
 
128
131
  For example, `--lang en` exits with an unsupported-language error. No English
129
- review or writing criteria are shipped in 0.6.1.
132
+ review or writing criteria are shipped in 0.6.3.
130
133
 
131
134
  For a small trial, use `examples/book.adoc` as the scan input. Its Japanese
132
135
  paragraphs deliberately contain review candidates; its code block must remain
@@ -144,29 +147,13 @@ asciidoc-pubkit review score book.adoc --agent codex
144
147
  asciidoc-pubkit review score book.adoc --agent claude --json
145
148
  ```
146
149
 
147
- Without `--agent`, `candidate-density-v1` reports a mechanical review indicator:
148
- `max(0, 100 - 5 * candidates * 1000 / characters)`, rounded to three decimals.
149
- Characters are non-whitespace Unicode characters in source-mapped running prose
150
- after inline masking. Every finding, including informational candidates, counts
151
- once. Lower scores indicate more detected review cues per 1,000 characters, not
152
- proven defects or AI authorship. Short texts are especially sensitive to a single
153
- candidate. No unmasked prose yields `null` rather than a perfect score.
154
- Successful scoring exits 0 regardless of the score; invalid input, configuration,
155
- analyzer, evaluator, or output failures exit 2. Verification exit codes are
156
- unchanged. The JSON report includes candidate counts, findings, coverage notices,
157
- analysis identity, and the formula. Rule, allow-list, and tokenizer changes can
158
- change the score even when the manuscript is unchanged.
159
-
160
- With `--agent`, `llm-readability-v1` displays an evaluator score instead. Sentence
161
- clarity and paragraph coherence are each rated 1–3 per paragraph and mapped to
162
- 0, 50, and 100. The displayed score averages these two dimensions across scored
163
- paragraphs with equal paragraph weights. JSON also retains the individual
164
- ratings, English reasons, source locations, evaluator model and CLI version,
165
- rubric fingerprint, and the mechanical candidate-density score. These ordinal
166
- averages are descriptive summaries, not validated interval measurements. This
167
- single-document evaluation has no reference manuscript or evidence checklist;
168
- it does not measure fact retention, technical accuracy, or meaning preservation.
169
- `meaning_verified` remains `false` in both modes.
150
+ Without `--agent`, the report shows a mechanical candidate-density indicator.
151
+ With `--agent`, it shows a model readability rating and retains the mechanical
152
+ score in JSON. See [How review and scoring work](#how-review-and-scoring-work)
153
+ for the analysis pipeline, formulas, and interpretation of these different scores.
154
+ Successful scoring exits 0 regardless of the score; input, configuration,
155
+ analyzer, evaluator, or output failures exit 2. No scoring mode establishes
156
+ technical accuracy or meaning preservation; `meaning_verified` remains `false`.
170
157
 
171
158
  Scoring uses the same configuration discovery, custom rules, glossary, allows,
172
159
  style, language, base directory, include handling, and prose coverage as scanning.
@@ -212,7 +199,7 @@ Use `ARGS` instead of `make review scan book.adoc`: Make interprets positional
212
199
  words as build targets, not CLI arguments. Avoid `make -C` when manuscript paths
213
200
  should remain relative to the current directory, because it changes directories.
214
201
 
215
- ## Install the morphological analyzer (0.1.1 and later)
202
+ ## Install the morphological analyzer
216
203
 
217
204
  On macOS with Homebrew:
218
205
 
@@ -314,6 +301,91 @@ session after moving a project. Keep `.pubkit/` and generated prompts out of Git
314
301
  when they contain private manuscript material. Rule settings and glossary contents
315
302
  are frozen into the session; scan again after changing them.
316
303
 
304
+ ### Heading review
305
+
306
+ Review headings and prose in separate sessions. The default scan scope remains
307
+ `prose`; `--scope headings` selects section titles. There is no combined scope.
308
+ Default output directories are `.pubkit/review` for prose and `.pubkit/headings`
309
+ for headings, so separate scans do not replace each other by default.
310
+ The scope is saved at scan time; `prompt` and `verify` use that saved scope.
311
+ Neither scan nor prompt invokes an AI CLI or edits a manuscript. Give the generated
312
+ prompt to your reviewer separately.
313
+
314
+ ```sh
315
+ asciidoc-pubkit review scan book.adoc --scope headings --output .pubkit/headings
316
+ asciidoc-pubkit review prompt .pubkit/headings --mode diagnose --output headings-diagnosis.md
317
+ # Generate a revision prompt when ready to edit:
318
+ asciidoc-pubkit review prompt .pubkit/headings --mode revise --output headings-review.md
319
+ # After the external review and edits:
320
+ asciidoc-pubkit review verify .pubkit/headings
321
+
322
+ # Establish a fresh prose baseline after finishing heading edits:
323
+ asciidoc-pubkit review scan book.adoc --scope prose --output .pubkit/prose
324
+ asciidoc-pubkit review prompt .pubkit/prose --output prose-review.md
325
+ asciidoc-pubkit review verify .pubkit/prose
326
+ ```
327
+
328
+ Heading prompts contain the full parsed section outline, selected headings and
329
+ all selected source-mapped prose paragraphs once as read-only evidence. They
330
+ compare parents, siblings, descendants and the corresponding body. Body content
331
+ outside prose coverage is not supplied; insufficient evidence must be recorded
332
+ as `needs-evidence`. `--only` and `review.exclude` select editable headings and
333
+ body evidence while retaining the full outline as context. All excerpts are data,
334
+ never executable reviewer instructions. Both criteria files and resolved rules
335
+ are frozen in the session.
336
+
337
+ Default heading rules accept term labels, noun phrases, questions, action
338
+ phrases, principles, conclusions and learning directions. They flag limited
339
+ promotional/vague phrases, glossary variants and identical sibling titles as
340
+ review candidates. They do not apply prose weak-predicate or sentence-ending
341
+ rules, require nominalization, or impose a character limit. Role and body
342
+ agreement are contextual reviewer judgments, not mechanically proven findings.
343
+
344
+ Only plain ATX section titles whose source cursor and original title match are
345
+ editable. Document titles, old-style underlined headings, attribute-expanded
346
+ and converted inline titles and physical title lines reused by multiple includes remain protected.
347
+ Unresolved section titles receive coverage notices. Verification permits only selected title text changes while
348
+ protecting the body, title markers, hierarchy, order, section IDs, references,
349
+ attributes, includes and other protected content. A title-derived section ID
350
+ change fails verification. Establish stable explicit IDs before scanning when
351
+ needed; this tool does not add IDs or migrate references. Numeric title changes
352
+ are manual-review notices, and remaining candidates do not fail verification.
353
+ `meaning_verified` remains `false`.
354
+
355
+ The session schema is now 2. Earlier sessions must be recreated; preserve or
356
+ finish an ongoing review with its original tool before establishing a new baseline.
357
+ `review score` continues to support prose only and rejects `--scope`.
358
+
359
+ Heading rules use `--heading-rules FILE`, then configuration
360
+ `review.heading_rules`, then `data/heading-rules.ja.yml`. A custom file replaces
361
+ the entire heading rule set. Each scan loads only the rules for its selected
362
+ scope; an unavailable rule file for the other scope does not prevent it.
363
+ `--heading-rules` requires `--scope headings`;
364
+ prose `--rules` and `--style` cannot be passed to a heading scan.
365
+
366
+ ```yaml
367
+ schema_version: 1
368
+ terms:
369
+ book-heading-cue:
370
+ terms: [シームレス]
371
+ question: 'Check the claimed behavior against the section evidence.'
372
+ fixed_titles: [はじめに, 参考文献, まとめ]
373
+ duplicate_siblings: true
374
+ style: mixed
375
+ ```
376
+
377
+ All five keys are required; unknown keys, invalid types and YAML aliases are
378
+ rejected. `terms` maps nonempty rule names to exactly `terms` (unique nonempty
379
+ strings) and `question` (nonempty English guidance). `fixed_titles` contains
380
+ unique nonempty titles exempt from mechanical candidates; it does not expand
381
+ the edit scope or prove correctness. `duplicate_siblings` is boolean. `style`
382
+ is `mixed` (default), `nominal`, or `action`; explicit preferences generate
383
+ advisory ending cues rather than a complete grammatical classification. Keep
384
+ questions, principles and justified exceptions. Heading phrase and glossary
385
+ matches respect exact `review.allows` entries, protected inline masking and
386
+ one-based Unicode source columns. MeCab remains the default; only explicit
387
+ `--tokenizer literal` disables it.
388
+
317
389
  ### Prompt
318
390
 
319
391
  ```sh
@@ -350,7 +422,7 @@ An omitted `:lang:` attribute uses the selected review language.
350
422
  asciidoc-pubkit review verify .pubkit/review
351
423
  ```
352
424
 
353
- Verification compares the current source set, document structure, content outside
425
+ For prose sessions, verification compares the current source set, document structure, content outside
354
426
  reviewed paragraphs, and recognized protected inline tokens with the baseline.
355
427
  It reports remaining candidates and numeric changes separately. Existing candidates
356
428
  do not make verification fail. Numeric changes require manual review but do not
@@ -368,9 +440,272 @@ or release readiness: `meaning_verified` is always `false`.
368
440
  | `1` | Verification found protected-content, structure, source, or parsing issues |
369
441
  | `2` | Invalid arguments, configuration, session, scan input, or output failure |
370
442
 
443
+ ## How review and scoring work
444
+
445
+ ### Features
446
+
447
+ - **Structure-aware AsciiDoc parsing.** Asciidoctor parses local includes,
448
+ conditionals, attributes and section hierarchy before review targets are
449
+ selected. Prose selection distinguishes paragraphs from lists, tables,
450
+ quotations and code blocks; supported inline constructs are masked rather
451
+ than treated as ordinary prose.
452
+ - **Separate heading and prose review.** Each scan selects one
453
+ scope with its own rules, prompt and edit permissions. Heading review uses
454
+ the outline and body as context while protecting body text; prose review
455
+ protects headings. Mixed heading forms are accepted by default. See
456
+ [Heading review](#heading-review).
457
+ - **Source-aligned static analysis.** Candidates identify the original source
458
+ file, line and one-based Unicode column, with a rule ID and review question.
459
+ Source text is checked against parser locations; unresolved mappings produce
460
+ coverage notices instead of guessed edit targets. Matches locate passages
461
+ for review, not proven defects.
462
+ - **Japanese morphological analysis.** MeCab with UTF-8 IPADIC recognizes
463
+ configured inflected predicates and adjectives, retaining original surfaces,
464
+ dictionary forms and negative-form information in morphological prose
465
+ findings. Literal matching is available only through explicit selection.
466
+ - **Contextual review in one prompt.** A single Markdown file carries saved
467
+ criteria, settings, candidates and manuscript evidence. All selected prose
468
+ paragraphs appear once, including those without candidates, with heading and
469
+ neighboring context. The reviewer records decisions and checks meaning;
470
+ generating the prompt does not edit the manuscript or invoke a model.
471
+ - **Book-specific rules and terminology.** Strict YAML rule sets, a glossary,
472
+ allow lists and exclusions adapt candidate detection to the manuscript.
473
+ Heading rules can express a book's preferred form while allowing justified
474
+ exceptions. Resolved rules and criteria are saved with each session.
475
+ - **Baseline-based preservation checks.** Source snapshots and artifact hashes
476
+ make the review baseline reproducible and detect stale or altered evidence.
477
+ Verification checks protected content, source membership, structure and
478
+ analyzer identity after external edits. It keeps `meaning_verified: false`;
479
+ semantic correctness remains a review judgment.
480
+ - **Local analysis and distinct scoring paths.** Default analysis runs locally
481
+ without a model call. Prose scoring reports candidate density; explicit
482
+ `review score --agent` optionally invokes an installed Codex or Claude CLI
483
+ for readability ratings. Candidate density, model judgments and development
484
+ benchmark accuracy remain separate measures.
485
+
486
+ ### Concept
487
+
488
+ The goal is Japanese technical prose that readers can understand, use, and
489
+ verify, with claims bounded by evidence and technical meaning preserved.
490
+ Clarity includes a paragraph's purpose, concrete operations and referents,
491
+ actors and objects, conditions and consequences, logical connections, and its
492
+ relationship to headings, figures, tables, and code. "Who does what" is one
493
+ part of that goal. Clear prose also retains precise terminology, necessary
494
+ negation, uncertainty, and implementation constraints.
495
+
496
+ The toolkit supports that goal through shared writing criteria, contextual
497
+ review prompts, source-aligned candidate detection, baseline verification,
498
+ and distinct scoring and development evaluation paths. Mechanical rules locate
499
+ passages to inspect; the reviewer judges their meaning from context and source
500
+ evidence. The writing and review prompts guide a human or external agent in
501
+ planning and revising complete paragraphs. They do not automatically reconstruct
502
+ subjects and objects or rewrite manuscripts. Model-based readability evaluation
503
+ is available only through explicit `review score --agent`.
504
+
505
+ The table identifies both implemented mechanisms and guidance carried by the
506
+ prompts. A criterion in a prompt is a review instruction, not a guarantee that
507
+ the code can detect or verify it.
508
+
509
+ | Supported principle or behavior | How it is realized | Implementation or criteria |
510
+ | --- | --- | --- |
511
+ | Write for a technical purpose and the reader's decisions | Shared criteria ask what a paragraph explains and what an engineer can decide or verify; writing prompts include those criteria | [Paragraph purpose](data/writing/ja/criteria.md#start-with-the-paragraphs-technical-purpose), [Writing](lib/asciidoc_pubkit/writing.rb) |
512
+ | Make actors, objects, actions, conditions, and results recoverable | Review instructions ask the reviewer to resolve omitted elements from context, while allowing unambiguous omission | [Paragraph revision](data/writing/ja/criteria.md#revise-the-complete-paragraph), [Review prompt](lib/asciidoc_pubkit/session.rb) |
513
+ | Replace vague abstraction, weak predicates, and metaphors with concrete explanations | Rules locate limited terms and inflected predicates; the criteria require identifying the actual referent, operation, policy, or effect before revising | [Concrete referents](data/writing/ja/criteria.md#replace-abstraction-with-the-thing-being-discussed), [Metaphor criteria](data/writing/ja/criteria.md#explain-metaphorical-operations-from-evidence), [Rules](lib/asciidoc_pubkit/rules.rb) |
514
+ | Distinguish reader instructions, actual behavior, and available capabilities | The shared criteria preserve the difference between requests, automatic execution, and optional operations | [Instructions, behavior, and capabilities](data/writing/ja/criteria.md#distinguish-instructions-behavior-and-capabilities) |
515
+ | Connect claims into coherent paragraphs | Prompts include all selected paragraphs and neighboring context; criteria require explicit referents, comparisons, causal relationships, and complete paragraph revision | [Relationships](data/writing/ja/criteria.md#make-relationships-explicit), [Review prompt](lib/asciidoc_pubkit/session.rb) |
516
+ | Keep claims within their evidence and preserve meaning | Review guidance asks for implementation, test, or primary-source evidence and checks omissions and unsupported additions; unresolved facts remain unresolved | [Evidence and scope](data/writing/ja/criteria.md#keep-claims-within-their-evidence-and-purpose), [Paragraph revision](data/writing/ja/criteria.md#revise-the-complete-paragraph) |
517
+ | Preserve technical distinctions, terminology, and justified prose choices | Criteria protect identifiers, values, conditions, negation, and necessary repetition; glossary rules, allow lists, and contextual questions support project terminology | [Terminology](data/writing/ja/criteria.md#preserve-exact-technical-terminology), [Packaged rules](data/review-rules.ja.yml), [Settings](lib/asciidoc_pubkit/settings.rb) |
518
+ | Review generated-prose patterns without mechanical deletion | Framing, contextual phrases, style, and repeated-ending checks produce candidates; shared criteria reject fixed sentence-length targets and needless synonym changes | [Generated-prose patterns](data/writing/ja/criteria.md#remove-generated-prose-patterns-without-flattening-the-meaning), [Rules](lib/asciidoc_pubkit/rules.rb) |
519
+ | Keep headings, illustrations, tables, and code consistent with the explanation | Writing criteria address scope, comparisons, identifiers, and conceptual simplifications; review prompts constrain edits to the selected scope and protect other elements | [Headings, figures, and code](data/writing/ja/criteria.md#headings-and-the-relation-to-figures-and-code), [Review scope](lib/asciidoc_pubkit/session.rb) |
520
+ | Make detection traceable and coverage explicit | Asciidoctor source mapping, offset-preserving inline masking, and MeCab/IPADIC produce source-aligned evidence; ambiguous or excluded passages have coverage notices | [Document](lib/asciidoc_pubkit/document.rb), [Morphology](lib/asciidoc_pubkit/morphology.rb), [Rules](lib/asciidoc_pubkit/rules.rb) |
521
+ | Preserve a reproducible and safe review baseline | Sessions save source snapshots, resolved rules, criteria, and analyzer identity; integrity checks and verification protect content outside editable prose | [Session](lib/asciidoc_pubkit/session.rb), [Rule validation](lib/asciidoc_pubkit/rule_set.rb) |
522
+ | Keep manuscript indicators, readability judgments, and detector accuracy distinct | Default scoring measures candidate density; optional local CLI evaluation judges readability; annotated development benchmarks measure detection and evaluate preservation separately | [Score](lib/asciidoc_pubkit/score.rb), [Local evaluator](lib/asciidoc_pubkit/local_evaluator.rb), [Development benchmark](benchmark/prose.rb) |
523
+ | Make automation explicit and its limits visible | Default analysis runs locally with no model call; only explicit scoring requests invoke an external CLI. Manuscripts are not edited, and verification retains `meaning_verified: false` | [CLI](lib/asciidoc_pubkit/cli.rb), [Local evaluator](lib/asciidoc_pubkit/local_evaluator.rb), [Session](lib/asciidoc_pubkit/session.rb) |
524
+
525
+ This section explains the implementation independently of command syntax.
526
+ [Review workflow](#review-workflow) covers commands and session handling;
527
+ [Score an AsciiDoc manuscript](#score-an-asciidoc-manuscript) covers scoring options.
528
+ The diagrams use GitHub-supported Mermaid fenced blocks.
529
+
530
+ ### Shared components and prose selection
531
+
532
+ Both paths resolve the same settings and parse the AsciiDoc entry file with
533
+ Asciidoctor, including local includes. `Document` selects running-prose paragraphs
534
+ and maps them back to their source files. Ambiguous mappings become coverage
535
+ notices; the analyzer does not guess locations. Headings provide context, while
536
+ code, tables, quotations, lists, and protected blocks are excluded from prose
537
+ analysis. Inline code, quoted spans, links, and other protected constructs are
538
+ masked with spaces that preserve character offsets and newlines.
539
+
540
+ ```mermaid
541
+ flowchart TD
542
+ A["AsciiDoc entry and local includes"] --> D["Document: parse and map running prose"]
543
+ C["Settings: options, configuration, resolved rules"] --> D
544
+ D --> P["Paragraphs with source locations and headings"]
545
+ D --> N["Coverage notices and parser diagnostics"]
546
+ P --> M["Rules: mask protected inline content"]
547
+ C --> M
548
+ M --> F["Candidate detection"]
549
+ F --> R["Session: review baseline and evidence"]
550
+ F --> S["Score: manuscript indicators"]
551
+ P -->|"Original prose and headings"| S
552
+ N --> R
553
+ N --> S
554
+ ```
555
+
556
+ `Settings` resolves rule precedence as command-line `--rules`, configuration
557
+ `review.rules`, then packaged defaults. A custom rule file replaces the whole
558
+ set. `Rules` returns review candidates with one-based Unicode line and column
559
+ positions; a match does not establish a defect. `Session` saves evidence for a
560
+ later review, while `Score` returns a report directly without creating a session.
561
+ Parser diagnostics must be resolved before scanning or scoring.
562
+
563
+ ### Review: collect, judge, and verify
564
+
565
+ Scanning freezes the source baseline, resolved settings and rules, analyzer
566
+ identity, and writing criteria. The session consists of `manifest.json`,
567
+ `document.json`, `findings.json`, and `baseline/`. Prompt generation checks
568
+ artifact integrity and rejects sources changed since the scan. It emits one
569
+ Markdown file containing the saved criteria, context, every selected paragraph
570
+ in document order, and its candidate evidence, including paragraphs with no
571
+ candidates. Generating that prompt requires no analyzer or model invocation.
572
+
573
+ ```mermaid
574
+ sequenceDiagram
575
+ actor Reviewer as Human or external agent
576
+ participant CLI as pubkit CLI
577
+ participant Sources as Manuscript files
578
+ participant Session as Saved review session
579
+ Reviewer->>CLI: review scan FILE
580
+ CLI->>Sources: Parse prose and detect candidates
581
+ CLI->>Session: Save evidence and source baseline
582
+ Reviewer->>CLI: review prompt SESSION
583
+ CLI->>Session: Check integrity and read saved evidence
584
+ CLI->>Sources: Check sources still match scan
585
+ CLI-->>Reviewer: One Markdown review prompt
586
+ Reviewer->>Sources: Judge context and edit prose externally
587
+ Reviewer->>CLI: review verify SESSION
588
+ CLI->>Session: Read original baseline and settings
589
+ CLI->>Sources: Reparse and compare protected content
590
+ CLI-->>Reviewer: Mechanical result, notices, remaining candidates
591
+ ```
592
+
593
+ The reviewer decides whether to keep or revise each paragraph and checks source
594
+ evidence before adding claims. `scan`, `prompt`, and `verify` never invoke an AI
595
+ CLI or edit manuscripts. Verification compares the included source set, content
596
+ outside reviewed prose, protected inline tokens, document structure, and analyzer
597
+ identity against the saved baseline. Numeric changes produce manual-review
598
+ notices; remaining candidates alone do not fail verification. A passing result
599
+ means these mechanical checks passed, with `meaning_verified: false`.
600
+
601
+ ### Detection: contextual rules and token boundaries
602
+
603
+ MeCab with UTF-8 IPADIC is the default analyzer. It supplies surfaces, dictionary
604
+ forms, part of speech, and source-aligned token spans. Explicit literal mode
605
+ matches configured surface strings; there is no silent fallback. Both modes
606
+ apply glossary, configured prose style, and sentence-ending checks.
607
+
608
+ ```mermaid
609
+ flowchart TD
610
+ P["Masked running prose"] --> B{"Selected tokenizer"}
611
+ B -->|"mecab, default"| T["MeCab and IPADIC tokens with source offsets"]
612
+ T --> L["Lemma rules with allow lists and contextual overlap checks"]
613
+ T --> X["Four enabled contextual predicate patterns"]
614
+ B -->|"literal, explicit"| E["Exact configured terms"]
615
+ P --> Q["Exact framing and contextual phrases"]
616
+ L --> F["Candidate findings"]
617
+ X --> O["Prefer most specific phrase; apply allow lists"]
618
+ E --> O
619
+ Q --> O
620
+ O --> F
621
+ P --> G["Glossary, style, and repeated endings"]
622
+ G --> F
623
+ ```
624
+
625
+ Morphological rules match configured noun and adjective lemmas, canonical verb
626
+ forms, adjacent compound nouns, and sahen nouns followed by `する` or `できる`.
627
+ Predicate spans extend through adjacent auxiliaries, dependent verbs, and
628
+ supported connective particles. Negative auxiliaries preserve polarity;
629
+ negative-only rules require that evidence. Unknown tokens are not guessed.
630
+
631
+ The four contextual patterns combine an exact prefix (`地味に`, `静かに`,
632
+ `時間を`, or `側に`) with a known independent verb lemma (`効く`, `壊れる`,
633
+ `溶かす`, or `倒す`). The canonical phrase must be enabled in the resolved rules.
634
+ For example, `地味に効かなかった` is collected as one complete candidate with
635
+ lemma `地味に効く` and `negative: true`. Protected text and paragraph boundaries
636
+ cannot bridge the pattern. Longer contextual phrases suppress contained matches,
637
+ including when the longer phrase is allowed. These limited patterns suggest
638
+ reviewing the actual effect or operation; they do not prove a metaphor is wrong.
639
+
640
+ Sentence-ending analysis splits each paragraph at `。`, `!`, and `?`, retaining
641
+ source offsets. It extracts supported endings such as `検証します` and `です`,
642
+ then checks consecutive windows of three sentences. A sentence without a matching
643
+ ending breaks the run. The first matching run produces one informational
644
+ candidate at the ending of its third sentence. Precise technical repetition may
645
+ be worth retaining; this is not a requirement to vary verbs.
646
+
647
+ ### Scoring: density and optional readability judgment
648
+
649
+ Scoring first runs the shared candidate detector. For the default
650
+ `candidate-density-v1`, let `N` be all findings, including informational ones,
651
+ and `C` be non-whitespace Unicode characters after inline masking:
652
+
653
+ ```text
654
+ density = N * 1000 / C
655
+ score = max(0, 100 - 5 * density)
656
+ ```
657
+
658
+ The score is rounded to three decimals. No unmasked prose yields `null`.
659
+ More candidates per 1,000 characters lower the score; short texts are particularly
660
+ sensitive. Changing rules, allow lists, or the detector can change the score of
661
+ an unchanged manuscript. This heuristic is a review indicator, not a calibrated
662
+ quality measure or a probability that AI wrote the text.
663
+
664
+ ```mermaid
665
+ flowchart TD
666
+ P["Selected prose and detected candidates"] --> D["Compute candidate density and mechanical score"]
667
+ D --> A{"Explicit agent option and nonempty prose?"}
668
+ A -->|"No"| R["Text or JSON report"]
669
+ A -->|"Yes"| I["Paragraph IDs, text, headings, and readability rubric"]
670
+ I --> J["Installed Codex or Claude CLI; configured model provider"]
671
+ J --> V["Validate IDs, integer ratings, and reasons"]
672
+ V --> M["Map ratings to 0, 50, 100 and average"]
673
+ M --> R
674
+ D --> K["Retain mechanical score in JSON"]
675
+ K --> R
676
+ ```
677
+
678
+ With explicit `--agent`, `llm-readability-v1` asks a fresh local CLI invocation to
679
+ rate each paragraph's sentence clarity and paragraph coherence separately from
680
+ 1 to 3. The rubric targets engineers familiar with the technical terms. The
681
+ input contains paragraph IDs, original text, and headings, without candidate
682
+ findings or file paths. The CLI may connect to its configured model provider.
683
+ The response must contain every supplied ID exactly once, integer ratings in
684
+ range, and nonempty reasons. Invalid responses fail scoring.
685
+
686
+ Ratings of 1, 2, and 3 map to 0, 50, and 100. Each dimension averages equally
687
+ across scored paragraphs; the displayed score averages the two dimension means.
688
+ JSON retains both dimensions, paragraph reasons, evaluator identity, and the
689
+ mechanical score. These ordinal averages summarize a fallible judgment. There
690
+ is no reference manuscript or fact checklist in this single-document path, so
691
+ it does not assess preservation or establish technical accuracy. Temporary CLI
692
+ artifacts are removed after the invocation, and manuscripts remain unchanged.
693
+
694
+ | Result | What it measures | Evidence needed |
695
+ | --- | --- | --- |
696
+ | Candidate-density score | Detected cues per text length | Current prose and resolved rules |
697
+ | Optional readability score | Model judgment of clarity and coherence | Current prose, context, and rubric |
698
+ | Development benchmark accuracy | Detector agreement and location accuracy | Fixed corpus with annotated targets |
699
+ | Review verification | Mechanical preservation after editing | Original session baseline and current files |
700
+
701
+ See the [development prose benchmark](#development-prose-benchmark) for
702
+ before/after trials with gold targets, separate fact checklists, and evaluator
703
+ calibration. Its precision, recall, and F1 evaluate the detector rather than
704
+ providing a score for an arbitrary manuscript.
705
+
371
706
  ## Configuration
372
707
 
373
- `scan` searches upward from the entrypoint directory for the nearest
708
+ `scan` and `score` search upward from the entrypoint directory for the nearest
374
709
  `.asciidoc-pubkit.yml`. Use `--config FILE` to select a different file. CLI options
375
710
  override configuration values; unspecified values use built-in defaults.
376
711
  The initial release loads one configuration file, not merged book/repository files.
@@ -380,6 +715,7 @@ review:
380
715
  language: ja
381
716
  style: desu-masu
382
717
  tokenizer: mecab
718
+ # heading_rules: heading-rules.yml # Separate heading rule set
383
719
  # Optional overrides (dictionary paths are relative to this file):
384
720
  # mecab_command: /opt/homebrew/bin/mecab
385
721
  # mecab_dictionary: /opt/homebrew/lib/mecab/dic/ipadic
@@ -434,8 +770,9 @@ sahen predicate takes precedence over a matching standalone noun rule. Auxiliary
434
770
  negation, past tense, passive forms, and progressive forms in the reported surface.
435
771
  The added reach predicate is negative-only; the existing handling predicate is
436
772
  reviewed in both affirmative and negative forms. Glossary variants and generic
437
- framing phrases continue to use literal matching. Contextual phrases also use
438
- literal matching and suppress overlapping morphological candidates. Compound
773
+ framing phrases continue to use literal matching. Contextual phrases suppress
774
+ overlapping morphological candidates. Except for the four predicate patterns
775
+ described below, they use literal matching. Compound
439
776
  nouns are matched across adjacent noun tokens. Selection and narrowing verbs
440
777
  include potential forms; predicate surfaces also preserve causative auxiliaries.
441
778
 
@@ -460,11 +797,30 @@ not added as general metaphor candidates. Identify the actual effect, policy,
460
797
  work, or failure state from evidence rather than applying a fixed replacement.
461
798
  Keep valid technical meanings and necessary negation.
462
799
 
800
+ Version 0.6.2 additionally matches these four phrases with MeCab/IPADIC
801
+ verb lemmas and adjacent predicate auxiliaries. For example, `地味に効かなかった`,
802
+ `静かに壊れていた`, `時間を溶かしてしまった`, and `側に倒しました` retain their
803
+ complete surfaces and polarity. A pattern is enabled only when its canonical
804
+ phrase (`地味に効く`, `静かに壊れる`, `時間を溶かす`, or `側に倒す`) is present in
805
+ the resolved `contextual-phrase.terms`. Removing those canonical entries from
806
+ custom rules disables their morphological patterns; remaining exact surfaces
807
+ still work. No YAML schema change is required. Allow lists accept the canonical
808
+ phrase or exact detected surface. The most specific overlapping phrase wins,
809
+ including allowed phrases. Masked inline content, unknown tokens, and paragraph
810
+ boundaries cannot bridge a pattern. This remains a limited contextual heuristic,
811
+ not a syntactic or semantic determination of metaphor. Literal mode retains
812
+ exact surfaces and does not acquire this inflection coverage.
813
+
814
+ In version 0.6.2, a `repeated-ending` candidate points to the ending
815
+ of the third sentence in the first consecutive run within each paragraph.
816
+ A sentence without a matching ending interrupts the run. The candidate remains
817
+ informational because precise technical repetition can be necessary.
818
+
463
819
  The shared criteria distinguish reader instructions, actual system behavior,
464
820
  and available capabilities. They also separate readability from checks for
465
821
  missing information and unsupported additions. Sentence length, punctuation,
466
822
  and list density are contextual cues, not fixed acceptance thresholds. These
467
- updates are included in 0.6.1; start a new session to use updated criteria and rules.
823
+ updates are included in 0.6.2; start a new session to use updated criteria and rules.
468
824
 
469
825
  Literal term matching suppresses matches strictly contained in a longer matched
470
826
  term, across categories. The longer term also suppresses contained matches when
@@ -484,18 +840,18 @@ reports analyzer changes instead of treating results from different dictionaries
484
840
  as directly comparable. Prompt generation uses saved evidence and does not need
485
841
  MeCab. Changed rules or dictionary settings require a new scan.
486
842
 
487
- Sessions from earlier tool versions are not compatible with 0.6.1. Keep the original baseline for
843
+ Sessions from earlier tool versions are not compatible with 0.6.3 (session schema 2). Keep the original baseline for
488
844
  an ongoing review and finish it with the original version, or start a new review
489
845
  pass in a different directory:
490
846
 
491
847
  ```sh
492
- asciidoc-pubkit review scan book.adoc --output .pubkit/review-0.6.1
848
+ asciidoc-pubkit review scan book.adoc --output .pubkit/review-0.6.3
493
849
  ```
494
850
 
495
851
  Severity describes review priority, not proof of an error. There is no AI-authorship
496
852
  score and no requirement to eliminate every match.
497
853
 
498
- Only source-mapped running-prose paragraphs are reviewed. Headings, list items and
854
+ In the default prose scope, only source-mapped running-prose paragraphs are reviewed. Headings, list items and
499
855
  their continuations, tables, quotations, code, and passthrough blocks are excluded
500
856
  from prose review. Common inline literals, macros, attribute references, URLs, and
501
857
  Japanese quotation spans are masked. Complex inline syntax can exceed the masking
@@ -568,13 +924,19 @@ Zero denominators are reported as `null`, not perfect scores. Duplicate detectio
568
924
  count as false positives. These scores measure the detector, not the manuscript.
569
925
 
570
926
  The checked-in [`MeCab baseline`](benchmark/baseline-mecab.json), captured before
571
- the planned detector changes, has precision 100, recall 81.818, F1 90, and location
927
+ the detector changes, has precision 100, recall 81.818, F1 90, and location
572
928
  accuracy 77.778. It misses two inflected metaphor phrases and mislocates two
573
929
  repeated-ending candidates. Reports record source, criteria, rules, corpus, and
574
930
  dictionary fingerprints. Comparisons reject changed corpora, scoring versions,
575
931
  analyzers, or dictionaries. Reports with configuration fingerprints also reject
576
932
  changed benchmark configuration. A fixed empty configuration
577
933
  keeps these trials independent of auto-discovered manuscript settings.
934
+ The 0.6.2 location correction raises location accuracy to 100 without
935
+ changing precision, recall, or F1 on this corpus. Adding the four MeCab predicate
936
+ patterns then raises precision, recall, F1, and location accuracy to 100 on these
937
+ 11 targets. This is regression evidence for the fixed synthetic corpus, not
938
+ evidence of general performance on unseen manuscripts; literal recall remains
939
+ 81.818.
578
940
  Record your own baseline when dictionary fingerprints
579
941
  differ. `--tokenizer literal` explicitly selects a separate limited-mode run;
580
942
  there is no automatic fallback, and literal results do not validate MeCab.
@@ -694,7 +1056,9 @@ In literal mode, all category term lists use exact phrase matching. In MeCab
694
1056
  mode, abstract nouns and degree adjectives use dictionary forms, while predicates
695
1057
  use `verbs` and `sahen`; add a predicate's desired literal surface to
696
1058
  `weak-predicate.terms` as well if literal mode should detect it. Contextual and
697
- generic framing phrases use literal matching in both modes. Questions apply to
1059
+ generic framing phrases use literal matching in both modes, with the
1060
+ MeCab exception for the four configured contextual predicate patterns described
1061
+ above. Questions apply to
698
1062
  both detectors. Glossary, style, repeated-ending checks, inline exclusions, and
699
1063
  morphological suffix handling remain implemented in Ruby.
700
1064
 
@@ -712,19 +1076,23 @@ conclusions. Candidate detection therefore leaves contextual judgment, document
712
1076
  structure, and final edits to the reviewer.
713
1077
 
714
1078
  - [natural-japanese](https://github.com/coji/natural-japanese): separates mechanical
715
- detection from contextual judgment and identifies repetitive framing.
1079
+ detection from contextual judgment and identifies repetitive framing. Applied
1080
+ here: candidate findings feed a contextual review prompt, while phrases such as
1081
+ `重要なのは` and `このように` invite inspection rather than automatic deletion.
716
1082
  - [yomiyasu](https://github.com/nanaism/yomiyasu):
717
1083
  informs evidence-based review of
718
1084
  metaphorical operations, distinctions between instructions and capabilities,
719
- and separate assessment of meaning preservation and readability. The criteria
720
- and regression examples here are independently written; the upstream skill,
721
- Python linter, and benchmark passages are not bundled. Fixed style thresholds
722
- and an AI-likeness score are not adopted.
1085
+ and separate assessment of meaning preservation and readability. Applied here:
1086
+ four limited metaphor patterns and third-sentence repetition locations inform
1087
+ candidate detection; the shared criteria require evidence for concrete rewrites.
723
1088
  - [日本語技術文書の文章規範](https://gist.github.com/k16shikano/fd287c3133457c4fd8f5601d34aa817d):
724
- informs paragraph logic, evidence scope, and meaningful uncertainty.
1089
+ informs paragraph logic, evidence scope, and meaningful uncertainty. Applied
1090
+ here: the shared criteria start from each paragraph's technical purpose and
1091
+ preserve necessary conditions, uncertainty, and exact terminology.
725
1092
  - [AI臭い文章とは何なのか](https://speakerdeck.com/nasuvitz/ai-kusai-bunshou-toha-nanina-no-ka):
726
1093
  provides examples of unnecessary contrast, abstract referents, and paired short
727
- sentences.
1094
+ sentences. Applied here: the shared criteria ask reviewers to inspect these
1095
+ patterns in context and recover concrete referents and connected explanations.
728
1096
 
729
1097
  The development evaluation adapts ideas from the following primary research;
730
1098
  its engineering audience, corpus, and rubric do not reproduce those benchmarks.
@@ -734,13 +1102,18 @@ Research texts and datasets are not redistributed here.
734
1102
  (Yamashita et al., LREC 2026): separates information preservation from sentence
735
1103
  and document simplicity and evaluates LLM judgments against human annotations.
736
1104
  Its elementary-school audience and Wikipedia corpus differ from this project.
1105
+ Applied here: the scoring rubric separates sentence clarity from paragraph
1106
+ coherence, and the development judge evaluates fact retention independently.
737
1107
  - [Evaluating Factuality in Text Simplification](https://aclanthology.org/2022.acl-long.506/)
738
1108
  (Devaraj et al., ACL 2022): distinguishes insertion, deletion, and substitution
739
- errors, motivating separate checks for unsupported additions and lost facts.
1109
+ errors. Applied here: development trials check each source fact and report
1110
+ unsupported additions and substitutions separately; a readable rewrite can
1111
+ still fail preservation review.
740
1112
  - [Evaluating Document Simplification: On the Importance of Separately Assessing Simplicity and Meaning Preservation](https://aclanthology.org/2024.readi-1.1/)
741
1113
  (Cripwell et al., READI 2024): motivates separate readability and preservation
742
- scores rather than a single aggregate. SARI-style overlap metrics are not
743
- adopted because lexical agreement alone is insufficient for this prose review.
1114
+ scores. Applied here: readability dimensions and preservation outcomes remain
1115
+ separate in benchmark reports; the direct manuscript score makes no
1116
+ preservation claim. SARI-style overlap metrics are not adopted.
744
1117
 
745
1118
  ## License
746
1119