@ansonlai/docx-redline-js 0.7.0 → 0.7.2
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/AGENTS.md +22 -27
- package/CHANGELOG.md +21 -1
- package/README.md +43 -22
- package/dist/docx-redline-js.esm.js +3 -4
- package/dist/docx-redline-js.esm.js.map +2 -2
- package/dist/docx-redline-js.esm.min.js +51 -51
- package/dist/docx-redline-js.esm.min.js.map +2 -2
- package/docs/AGENT_FAST_START.md +31 -33
- package/docs/AGENT_KNOWLEDGE_BASE.md +67 -55
- package/docs/SKILL_AUTHORING.md +82 -100
- package/docs/releases/0.7.0.md +56 -36
- package/docs/schemas/document-operations.schema.json +1 -1
- package/docs/validation-reports/2026-09-14-agent-surface-simplification.md +75 -0
- package/node/cli-help.js +8 -6
- package/node/cli.js +57 -9
- package/package.json +4 -1
- package/services/document-inspection.js +2 -3
- package/services/document-operation-applier.js +12 -2
- package/services/document-operation-contract.js +49 -2
- package/services/document-operation-mutations.js +36 -36
- package/services/localized-replacement-compiler.js +73 -7
- package/services/operation-batch-compiler.js +9 -0
- package/services/standalone-operation-runner.d.ts +25 -4
package/docs/AGENT_FAST_START.md
CHANGED
|
@@ -1,57 +1,55 @@
|
|
|
1
1
|
# Agent Fast Start
|
|
2
2
|
|
|
3
|
-
Use this page for ordinary `.docx` edits. For
|
|
3
|
+
Use this page for ordinary `.docx` edits. For unusual Word structures or optional shortcuts, follow the links at the end.
|
|
4
4
|
|
|
5
5
|
## Structured agent tool
|
|
6
6
|
|
|
7
|
-
If
|
|
7
|
+
If the host provides a document-session wrapper:
|
|
8
8
|
|
|
9
|
-
1. Inspect
|
|
10
|
-
2. Apply with the revision-bound handle
|
|
11
|
-
3.
|
|
9
|
+
1. Inspect once with enough surrounding context to draft the change.
|
|
10
|
+
2. Apply once with the returned revision-bound handle.
|
|
11
|
+
3. Accept only the wrapper's complete-success result; refresh failed handles.
|
|
12
12
|
|
|
13
|
-
The repository's `examples/agent-session-wrapper.mjs`
|
|
14
|
-
It is a development sample, not a package API.
|
|
13
|
+
The repository's `examples/agent-session-wrapper.mjs` is a development sample, not a package API.
|
|
15
14
|
|
|
16
|
-
## CLI
|
|
15
|
+
## CLI workflow
|
|
17
16
|
|
|
18
|
-
1.
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
docx-redline apply contract.docx --find "thirty (30) days" --replace "sixty (60) days" --profile agent --output reviewed.docx
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
The source must occur in one eligible paragraph. For text after a heading, add `--search "Section 4.1" --context-range 1:3`.
|
|
25
|
-
`--around 3` is symmetric; use it only when either side is eligible.
|
|
26
|
-
|
|
27
|
-
2. For semantic drafting such as “make this provision mutual,” extract enough
|
|
28
|
-
context, then copy `exactText` with `paragraphId` or `fingerprint`:
|
|
17
|
+
1. Extract the relevant clause or range:
|
|
29
18
|
|
|
30
19
|
```bash
|
|
31
20
|
docx-redline extract contract.docx --search "termination" --around 3
|
|
32
21
|
```
|
|
33
22
|
|
|
34
|
-
Search is case-insensitive
|
|
23
|
+
Search is case-insensitive. Follow `selection.nextAfter` when truncated. Preserve `selection`, `humanReference`, target descriptors, and revision cues when reshaping output. Report `humanReference`, not a machine paragraph number.
|
|
24
|
+
|
|
25
|
+
2. Retain inspected `exactText` for drafting and target with its `paragraphId` plus `fingerprint`, then apply once with a UTF-8 operations file or serializer-backed stdin:
|
|
35
26
|
|
|
36
27
|
```bash
|
|
37
28
|
node emit-operations.mjs | docx-redline apply contract.docx --operations - --profile agent --compact --output reviewed.docx
|
|
38
29
|
```
|
|
39
30
|
|
|
40
|
-
Use `
|
|
31
|
+
Use complete `modified` text for a broad semantic revision. For a small literal change in that inspected target, use
|
|
32
|
+
`replacements: [{ "find": "old text", "replace": "new text" }]` instead.
|
|
33
|
+
Use `JSON.stringify`; never interpolate document text through shell quoting. Preserve intentionally relative wording unless the user asks for a concrete value.
|
|
34
|
+
|
|
35
|
+
## Restore branch
|
|
41
36
|
|
|
42
|
-
|
|
37
|
+
If the user requests deleted text, search with `--view rejected` first. Otherwise follow `selection.hint` only when it identifies an alternate revision view. Restore the inspected strong target; do not infer adjacent content. Run `docx-redline apply --help` for canonical restore shapes.
|
|
43
38
|
|
|
44
|
-
##
|
|
39
|
+
## Completion and recovery
|
|
45
40
|
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
-
|
|
41
|
+
- Require `completion: true` and a non-null `outputPath`; the CLI computes this from write, operation, commit, and localized-verification results.
|
|
42
|
+
- On failure, follow `error.recovery.action`; never retry unchanged arguments.
|
|
43
|
+
- Use `retryPlan.base: "original"` to replay a batch and `"output"` to retain
|
|
44
|
+
committed progressive work and retry the reported indexes.
|
|
45
|
+
- The source is not overwritten unless `--in-place` is explicit.
|
|
46
|
+
- Never accept/reject revisions or remove comments without authorization.
|
|
47
|
+
- Add `--atomic` or a non-default revision policy only when deliberately needed;
|
|
48
|
+
confirm `effectiveOptions`.
|
|
49
|
+
- Strong inspected targets bind to batch start. Consolidate writes to one source
|
|
50
|
+
and use captures only for intentional created-content dependencies.
|
|
55
51
|
|
|
56
|
-
Advanced
|
|
52
|
+
Advanced speculative apply, directional scoping, operation constraints, and
|
|
53
|
+
recovery: [Agent Knowledge Base](AGENT_KNOWLEDGE_BASE.md). Canonical schema:
|
|
54
|
+
[document-operations.schema.json](schemas/document-operations.schema.json).
|
|
57
55
|
Wrapper design: [README](../README.md#example-agent-session-wrapper-development-only)
|
|
@@ -476,63 +476,41 @@ The canonical machine-readable contract is
|
|
|
476
476
|
`docs/schemas/document-operations.schema.json`. Read that schema or the examples
|
|
477
477
|
here instead of grepping bundled implementation code.
|
|
478
478
|
|
|
479
|
-
#### Standard Workflow (
|
|
480
|
-
|
|
481
|
-
Use this for
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
1.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
evidence and positive accepted-view verification.
|
|
504
|
-
6. Run a focused `extract` on changed clauses only when placement or list/table
|
|
505
|
-
structure needs confirmation.
|
|
506
|
-
|
|
507
|
-
Do not probe operation behavior with disposable apply commands or read a vendor
|
|
508
|
-
bundle before this route. If `apply` returns an error, use the recovery matrix
|
|
509
|
-
below and make one cause-specific correction.
|
|
510
|
-
|
|
511
|
-
```bash
|
|
512
|
-
# 1. Globally unique mechanical edit in one call
|
|
513
|
-
docx-redline apply contract.docx --find "thirty (30) days" --replace "sixty (60) days" --profile agent --output reviewed.docx
|
|
479
|
+
#### Standard Workflow (Extract Then Apply)
|
|
480
|
+
|
|
481
|
+
Use this for ordinary edits. `apply` validates the resulting package and
|
|
482
|
+
revision markup internally before writing, so do not add `preflight` or baseline
|
|
483
|
+
`validate` merely for reassurance.
|
|
484
|
+
|
|
485
|
+
1. Run one focused `extract`. Add `--around 3` when surrounding context is
|
|
486
|
+
needed. Retain `exactText` for drafting and target with `paragraphId` plus
|
|
487
|
+
`fingerprint`.
|
|
488
|
+
2. Build one final operation per target. Use complete `modified` text for broad
|
|
489
|
+
semantic revisions or localized `replacements` for small literal changes in
|
|
490
|
+
an inspected target. Consolidate multiple changes to one paragraph.
|
|
491
|
+
3. Run `apply` once per stable batch. Independent strong targets bind against
|
|
492
|
+
the batch-start document and do not need bottom-up sorting. Use captures only
|
|
493
|
+
for intentional created-content dependencies.
|
|
494
|
+
4. Require `completion: true` and a non-null `outputPath`. The CLI derives
|
|
495
|
+
completion from write status, operation outcomes, commit disposition, and
|
|
496
|
+
localized accepted-view verification.
|
|
497
|
+
5. Run a focused post-apply extraction only when placement or structural output
|
|
498
|
+
needs confirmation.
|
|
499
|
+
|
|
500
|
+
If `apply` returns an error, follow the recovery envelope below and make one
|
|
501
|
+
cause-specific correction. Do not probe behavior with disposable mutations or
|
|
502
|
+
read a vendor bundle.
|
|
514
503
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
# 3. Focused contextual discovery for semantic drafting
|
|
504
|
+
```bash
|
|
505
|
+
# 1. Focused contextual discovery
|
|
519
506
|
docx-redline extract contract.docx --search "termination" --around 3
|
|
520
507
|
|
|
521
|
-
#
|
|
522
|
-
docx-redline apply contract.docx --target "Original clause" --modified "New clause" --output reviewed.docx
|
|
523
|
-
|
|
524
|
-
# 5. Direct edit without tracked changes (clean text, no revision clutter)
|
|
525
|
-
docx-redline apply contract.docx --target "Typo fix" --modified "Fixed typo" --no-redlines --output clean.docx
|
|
526
|
-
|
|
527
|
-
# 6. Cross-author edit inside another reviewer's pending insertion
|
|
528
|
-
docx-redline apply contract.docx --target "Pending clause text" --modified "Updated clause text" --existing-revisions slice-cross-author --output reviewed.docx
|
|
529
|
-
|
|
530
|
-
# 7. Batch operations with ops.json
|
|
531
|
-
docx-redline apply contract.docx --operations operations.json --output reviewed.docx
|
|
532
|
-
|
|
533
|
-
# 8. Serializer-backed stdin with compact stdout
|
|
508
|
+
# 2. Serializer-backed apply against the inspected target
|
|
534
509
|
node emit-operations.mjs | docx-redline apply contract.docx --operations - --profile agent --compact --output reviewed.docx
|
|
535
|
-
|
|
510
|
+
|
|
511
|
+
# Optional clean edit without tracked changes
|
|
512
|
+
docx-redline apply contract.docx --target "Typo fix" --modified "Fixed typo" --no-redlines --output clean.docx
|
|
513
|
+
```
|
|
536
514
|
|
|
537
515
|
Key CLI defaults and behaviors:
|
|
538
516
|
- **Author**: Automatically defaults to `'AI Redliner'` (overridable via `--author` or `DOCX_REDLINE_AUTHOR` environment variable).
|
|
@@ -544,9 +522,36 @@ Key CLI defaults and behaviors:
|
|
|
544
522
|
- **Agent profile**: `--profile agent` enables complete-success exit behavior but preserves progressive execution and the ordinary revision policy. Compose it with `--atomic` or an explicit `--existing-revisions` choice when intended; resolved values appear in `effectiveOptions`.
|
|
545
523
|
- **Operation transport**: A UTF-8 operations file and serializer-backed `--operations -` are peers. Use whichever the host can construct without interpolating legal text in the shell.
|
|
546
524
|
- **Compact mutation JSON**: `apply`, `accept`, `reject`, and `delete-comments` omit document/package XML, full validation arrays, and duplicate nested receipts. Top-level `receipts` is authoritative. Pass `--compact` for one-line JSON; run `validate` for full issue records.
|
|
547
|
-
- Check `completion: true
|
|
525
|
+
- Check `completion: true` and a non-null `outputPath` on stdout. Failed,
|
|
526
|
+
partial, rolled-back, unverified, and unwritten work cannot appear complete.
|
|
527
|
+
If an error occurs, follow `error.recovery.action` before correcting the cause.
|
|
548
528
|
|
|
549
|
-
For multi-clause or multi-page reviews,
|
|
529
|
+
For multi-clause or multi-page reviews, use focused batches rather than one
|
|
530
|
+
massive batch. This keeps context compact and simplifies error diagnosis.
|
|
531
|
+
|
|
532
|
+
#### Optional Speculative Localized Apply
|
|
533
|
+
|
|
534
|
+
Targetless localized apply remains available to expert users and harnesses with
|
|
535
|
+
a measured confidence policy. It is not the ordinary agent workflow:
|
|
536
|
+
|
|
537
|
+
```bash
|
|
538
|
+
# Globally unique literal
|
|
539
|
+
docx-redline apply contract.docx --find "thirty (30) days" --replace "sixty (60) days" --profile agent --output reviewed.docx
|
|
540
|
+
|
|
541
|
+
# Optional directional scope using a longer, fairly unique phrase
|
|
542
|
+
docx-redline apply contract.docx --search "distinctive nearby heading or phrase" --context-range 1:3 --find "thirty (30) days" --replace "sixty (60) days" --profile agent --output reviewed.docx
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
Omitting a target asks the CLI to resolve one eligible paragraph. Generic or
|
|
546
|
+
repeated anchors union their windows and may produce `AMBIGUOUS_TARGET`, costing
|
|
547
|
+
a recovery turn. `--around 3` is symmetric; `--occurrence` disambiguates only
|
|
548
|
+
inside an already selected paragraph. `anchorMatchCount > 1` signals a repeated
|
|
549
|
+
anchor even after a successful edit. Matching is exact and case-sensitive first,
|
|
550
|
+
then permits only ASCII-space/NBSP equivalence; ambiguity still fails closed.
|
|
551
|
+
|
|
552
|
+
Localized `change` evidence retains bounded before/after excerpts, commit
|
|
553
|
+
disposition, and accepted-view verification for audit consumers. Ordinary
|
|
554
|
+
agents rely on the computed top-level `completion` signal.
|
|
550
555
|
|
|
551
556
|
#### High-Assurance / Staged Verification Workflow (Optional)
|
|
552
557
|
|
|
@@ -590,6 +595,13 @@ Paragraph indexes are 1-based. Inspection filters are `--index 12`,
|
|
|
590
595
|
case-insensitive. When a search returns 0 matches in the active view but matches
|
|
591
596
|
exist in the alternate view (such as searching for a deleted clause to restore),
|
|
592
597
|
`selection.hint` provides immediate guidance to re-run with `--view rejected`.
|
|
598
|
+
Compact `extract --revised` results retain `hasRevisions`, `revisionAuthors`,
|
|
599
|
+
and `deleted`/`inserted` cues, so an empty `exactText` is identifiable as content
|
|
600
|
+
hidden by the selected revision view rather than a failed filter.
|
|
601
|
+
For one strongly identified rejected-view paragraph, `apply --restore
|
|
602
|
+
--target-id ID` restores the rejected text verbatim. One exact
|
|
603
|
+
`--find`/`--replace` pair may adjust it without restating the paragraph. The
|
|
604
|
+
shortcut refuses ranges, captures, weak targets, and inferred adjacent content.
|
|
593
605
|
Add `--around N` (`--context N` or `-C N`) to a search;
|
|
594
606
|
context records are labeled separately and do not consume the direct-hit
|
|
595
607
|
`--limit`. Continue a bounded result with `--after <paragraph-index>`. Ordinary
|
package/docs/SKILL_AUTHORING.md
CHANGED
|
@@ -1,86 +1,76 @@
|
|
|
1
1
|
# Skill and Harness Authoring Contract
|
|
2
2
|
|
|
3
|
-
Use this page
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Use this page to create or update an agent skill, MCP server, or custom harness
|
|
4
|
+
for `@ansonlai/docx-redline-js`. Ordinary editing agents should load
|
|
5
|
+
[Agent Fast Start](AGENT_FAST_START.md), not this design contract.
|
|
6
6
|
|
|
7
7
|
> [!WARNING]
|
|
8
|
-
> Before 1.0, every
|
|
9
|
-
>
|
|
10
|
-
>
|
|
8
|
+
> Before 1.0, every integration must identify and pin its exact tested library
|
|
9
|
+
> release and required CLI contract/capabilities. Treat any different release or
|
|
10
|
+
> contract as unverified until compatibility tests pass.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Example declaration for a contract-8 shell integration that uses localized
|
|
13
|
+
operations over stdin:
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
17
|
-
"testedLibraryRelease": "0.7.
|
|
17
|
+
"testedLibraryRelease": "0.7.1",
|
|
18
18
|
"requiredCliContractVersion": 8,
|
|
19
19
|
"requiredCapabilities": [
|
|
20
|
-
"
|
|
20
|
+
"operations-stdin",
|
|
21
|
+
"agent-safety-profile-v2",
|
|
21
22
|
"recovery-envelope-v1",
|
|
22
|
-
"localized-replacements-v1"
|
|
23
|
-
"speculative-search-apply-v1",
|
|
24
|
-
"localized-change-summary-v1"
|
|
23
|
+
"localized-replacements-v1"
|
|
25
24
|
]
|
|
26
25
|
}
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
The package pin anchors the release; runtime negotiation proves the executable
|
|
30
|
-
exposes the required contract. A new release cannot inherit an old claim.
|
|
31
|
-
|
|
32
28
|
## Runtime negotiation
|
|
33
29
|
|
|
34
|
-
Run
|
|
35
|
-
the
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
docx-redline version
|
|
39
|
-
```
|
|
30
|
+
Run `docx-redline version` before the first document operation. Require CLI
|
|
31
|
+
contract version 8 and only the capabilities the integration actually uses. Check once per stable
|
|
32
|
+
runtime, fail closed when a requirement is absent, and never inspect bundles or
|
|
33
|
+
ZIP parts as a fallback.
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`recovery-envelope-v1`. Require other capabilities only when used. Fail closed
|
|
45
|
-
when one is absent; never inspect bundles or ZIP parts as a fallback.
|
|
35
|
+
Do not expose negotiated but unused capabilities as choices in the editing
|
|
36
|
+
prompt. `command-help-v1`, restore shortcuts, speculative apply, and localized
|
|
37
|
+
change summaries are optional requirements only for integrations that use them.
|
|
46
38
|
|
|
47
39
|
## Safety invariants
|
|
48
40
|
|
|
49
|
-
Every generated integration must
|
|
41
|
+
Every generated integration must:
|
|
50
42
|
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
-
|
|
56
|
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
- inspect narrowly, retain `exactText`, and target with `paragraphId` plus
|
|
44
|
+
`fingerprint`;
|
|
45
|
+
- use strict targeting, package validation, and a derived output path;
|
|
46
|
+
- never overwrite the source unless `--in-place` is explicitly requested;
|
|
47
|
+
- require `completion: true` and a non-null `outputPath` before reporting
|
|
48
|
+
success;
|
|
49
|
+
- follow `error.recovery.action` and never retry unchanged failed arguments; and
|
|
50
|
+
- require explicit authorization before accepting/rejecting another reviewer's
|
|
51
|
+
work or deleting comments.
|
|
60
52
|
|
|
61
|
-
The `
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
The CLI computes `completion` from write status, operation outcomes, commit
|
|
54
|
+
disposition, and localized accepted-view verification. Preserve the detailed
|
|
55
|
+
results for audit and recovery, but do not make the editing agent re-evaluate
|
|
56
|
+
those fields during ordinary success handling.
|
|
65
57
|
|
|
66
58
|
## Workflow policy choices
|
|
67
59
|
|
|
68
|
-
|
|
60
|
+
Keep these exceptions separate from the default workflow:
|
|
69
61
|
|
|
70
|
-
| Choice |
|
|
62
|
+
| Choice | Default | Override only when |
|
|
71
63
|
|---|---|---|
|
|
72
|
-
| Transaction | progressive
|
|
73
|
-
| Existing revisions | `merge-same-author`
|
|
74
|
-
| Reviewer identity |
|
|
75
|
-
| Output
|
|
64
|
+
| Transaction | progressive | Partial output is unacceptable (`--atomic`). |
|
|
65
|
+
| Existing revisions | `merge-same-author` | Editing inside another reviewer's pending insertion is intended (`slice-cross-author`). |
|
|
66
|
+
| Reviewer identity | `AI Redliner` is a valid visible fallback | The host supplies a preferred flag, operation author, or environment value. |
|
|
67
|
+
| Output | derived sibling | The caller deliberately selects another destination. |
|
|
76
68
|
|
|
77
|
-
Check `effectiveOptions`
|
|
78
|
-
revision, author, or redline policy.
|
|
69
|
+
Check `effectiveOptions` when an integration deliberately sets a policy.
|
|
79
70
|
|
|
80
71
|
## Transport choices
|
|
81
72
|
|
|
82
|
-
A UTF-8 operations file and serializer-backed stdin are peer transports
|
|
83
|
-
the form the host can construct safely:
|
|
73
|
+
A UTF-8 operations file and serializer-backed stdin are peer transports:
|
|
84
74
|
|
|
85
75
|
```bash
|
|
86
76
|
docx-redline apply input.docx --operations operations.json --profile agent --output reviewed.docx
|
|
@@ -88,45 +78,46 @@ node emit-operations.mjs | docx-redline apply input.docx --operations - --profil
|
|
|
88
78
|
```
|
|
89
79
|
|
|
90
80
|
Use `JSON.stringify` or a structured tool API. Never demonstrate `echo`, a
|
|
91
|
-
heredoc, or shell-interpolated
|
|
92
|
-
|
|
93
|
-
|
|
81
|
+
heredoc, or shell-interpolated document text. A Node byte-oriented wrapper should
|
|
82
|
+
call `openDocx` and return the structured result instead of recreating CLI
|
|
83
|
+
serialization, ZIP handling, targeting, validation, or rollback.
|
|
94
84
|
|
|
95
85
|
## Ordinary generated workflow
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
The first executable editing example in a generated skill must be focused
|
|
88
|
+
extraction:
|
|
99
89
|
|
|
100
90
|
```bash
|
|
101
|
-
docx-redline
|
|
91
|
+
docx-redline extract input.docx --search "renewal notice" --around 3
|
|
102
92
|
```
|
|
103
93
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Require the returned localized `change` evidence, including `committed: true`
|
|
109
|
-
and `verification.acceptedViewMatchesCompiledText: true`.
|
|
94
|
+
Then apply once using the inspected strong target. Use complete `modified` text
|
|
95
|
+
for a broad semantic revision or `replacements` for a small literal change in
|
|
96
|
+
that target. Keep requested relative wording relative unless the user asks for
|
|
97
|
+
a concrete value.
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
99
|
+
Follow `selection.nextAfter` when extraction is truncated. Output projections must retain
|
|
100
|
+
`selection`, target descriptors, `humanReference`, and revision
|
|
101
|
+
cues.
|
|
114
102
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
103
|
+
### Observed restore branch
|
|
104
|
+
|
|
105
|
+
If the user requests restoration, search `--view rejected` first. Otherwise
|
|
106
|
+
follow an alternate-view `selection.hint` when returned. Restore only the
|
|
107
|
+
inspected strong target. Require `restore-shortcuts-v1` only if the integration
|
|
108
|
+
uses inline `--restore`; canonical operations remain available.
|
|
109
|
+
|
|
110
|
+
### Optional speculative execution
|
|
118
111
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
GitHub URLs. The operation schema remains
|
|
125
|
-
[document-operations.schema.json](schemas/document-operations.schema.json).
|
|
112
|
+
Do not make speculative apply part of an ordinary generated workflow. A harness
|
|
113
|
+
may opt into `speculative-search-apply-v1` only when it owns a measured confidence
|
|
114
|
+
policy and accepts the recovery cost of a miss. Keep anchor selection,
|
|
115
|
+
directional windows, occurrence handling, and exact matching semantics out of
|
|
116
|
+
the ordinary editing prompt; link to the knowledge base or CLI help instead.
|
|
126
117
|
|
|
127
118
|
## Recovery contract
|
|
128
119
|
|
|
129
|
-
Lead
|
|
120
|
+
Lead failure handling with these runtime fields:
|
|
130
121
|
|
|
131
122
|
1. `error.recovery.action`
|
|
132
123
|
2. `error.recovery.requiresReinspection`
|
|
@@ -134,32 +125,23 @@ Lead error handling with exactly these runtime fields:
|
|
|
134
125
|
4. `error.recovery.sameArgumentsSafe`
|
|
135
126
|
|
|
136
127
|
Use `retryPlan.base` and its operation indexes to select the original or partial
|
|
137
|
-
output package. Do not
|
|
138
|
-
code; error messages and bounded diagnostics explain the cause, while the four
|
|
139
|
-
fields above determine the next action.
|
|
128
|
+
output package. Do not reproduce an error-code decision tree in the skill.
|
|
140
129
|
|
|
141
130
|
## Presentation rules
|
|
142
131
|
|
|
143
|
-
Use `humanReference`, `provision`, or `nearestHeading` in
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
When no formal heading exists, use the returned short text lead. Never replace
|
|
147
|
-
an exact machine target with a human-facing reference.
|
|
132
|
+
Use `humanReference`, `provision`, or `nearestHeading` in completion reports.
|
|
133
|
+
Paragraph indexes and `P55`-style references are machine coordinates, not
|
|
134
|
+
locations a document user can follow. Keep the exact machine target internally.
|
|
148
135
|
|
|
149
136
|
## Generation checklist
|
|
150
137
|
|
|
151
|
-
-
|
|
152
|
-
|
|
153
|
-
- The
|
|
154
|
-
|
|
155
|
-
-
|
|
156
|
-
-
|
|
157
|
-
|
|
158
|
-
-
|
|
159
|
-
|
|
160
|
-
-
|
|
161
|
-
- Operations-file and stdin examples use structured serialization.
|
|
162
|
-
- The four-field recovery contract precedes any diagnostic commentary.
|
|
163
|
-
- Completion prose uses legal references rather than machine ordinals.
|
|
164
|
-
- The wrapper delegates mutation, validation, rollback, comments, numbering,
|
|
165
|
-
receipts, and OOXML packaging to the library.
|
|
138
|
+
- Exact tested release, contract 8, and the minimum capability set are pinned.
|
|
139
|
+
- Runtime compatibility is checked once.
|
|
140
|
+
- The first ordinary command is focused extraction.
|
|
141
|
+
- Apply uses the inspected target with `modified` or localized `replacements`.
|
|
142
|
+
- Restore appears only as a user-requested or observed-view branch.
|
|
143
|
+
- Speculative execution is absent unless the harness owns a measured policy.
|
|
144
|
+
- Ordinary success requires `completion: true` and a non-null `outputPath`.
|
|
145
|
+
- Recovery, authorization, source immutability, and structured serialization
|
|
146
|
+
invariants are preserved.
|
|
147
|
+
- Wrappers delegate mutation and OOXML packaging to the library.
|