@lmzhen/dsh-tool-memory 0.3.20 → 0.3.22
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/lib/index.js +1 -2640
- package/lib/types/index.d.ts +1 -1
- package/package.json +9 -10
package/lib/index.js
CHANGED
|
@@ -1,2645 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
|
-
import {
|
|
4
|
-
const PROMPT_BUNDLE_ID = `dsh-evolution@13`;
|
|
5
|
-
const MEMORY_REVIEW_PROMPT = `[Auto-review — Memory]
|
|
6
|
-
Review the conversation above and consider saving to memory if appropriate.
|
|
7
|
-
|
|
8
|
-
Focus on:
|
|
9
|
-
1. Has the user revealed things about themselves — persona, desires, preferences, or personal details worth remembering?
|
|
10
|
-
2. Has the user expressed expectations about how you should behave, their work style, or ways they want you to operate?
|
|
11
|
-
|
|
12
|
-
If something stands out, save it using the memory tool.
|
|
13
|
-
If nothing is worth saving, just say "Nothing to save." and stop.`;
|
|
14
|
-
const SKILL_REVIEW_PROMPT = `[Auto-review — Skills]
|
|
15
|
-
Review the conversation above and update the skill library. Be ACTIVE — most sessions produce at least one skill update, even if small. A pass that does nothing is a missed learning opportunity, not a neutral outcome.
|
|
16
|
-
|
|
17
|
-
Target shape of the library: CLASS-LEVEL skills, each with a rich SKILL.md and a references/ directory for session-specific detail. Not a long flat list of narrow one-session-one-skill entries. This shapes HOW you update, not WHETHER you update.
|
|
18
|
-
|
|
19
|
-
Signals to look for (any one of these warrants action):
|
|
20
|
-
• User corrected your style, tone, format, legibility, or verbosity. Frustration signals like 'stop doing X', 'this is too verbose', 'don't format like this', 'why are you explaining', 'just give me the answer', 'you always do Y and I hate it', or an explicit 'remember this' are FIRST-CLASS skill signals, not just memory signals. Update the relevant skill(s) to embed the preference so the next session starts already knowing.
|
|
21
|
-
• User corrected your workflow, approach, or sequence of steps. Encode the correction as a pitfall or explicit step in the skill that governs that class of task.
|
|
22
|
-
• Non-trivial technique, fix, workaround, debugging path, or tool-usage pattern emerged that a future session would benefit from. Capture it.
|
|
23
|
-
• A skill that got loaded or consulted this session turned out to be wrong, missing a step, or outdated. Patch it NOW.
|
|
24
|
-
|
|
25
|
-
Read-before-write (enforced by this channel): update, patch, delete, or write support files ONLY into skills you loaded or read in THIS session — ops on unread skills are dropped; CREATE of a brand-new umbrella is the only exception.
|
|
26
|
-
|
|
27
|
-
Preference order — prefer the earliest action that fits, but do pick one when a signal above fired:
|
|
28
|
-
1. UPDATE A CURRENTLY-LOADED SKILL. Look back through the conversation for skills the user loaded or you read. If any of them covers the territory of the new learning, PATCH that one first. It is the skill that was in play, so it's the right one to extend.
|
|
29
|
-
2. UPDATE AN EXISTING UMBRELLA. If no loaded skill fits but an existing class-level skill does, patch it. Add a subsection, a pitfall, or broaden a trigger.
|
|
30
|
-
3. ADD A SUPPORT FILE under an existing umbrella. Skills can be packaged with three kinds of support files — use the right directory per kind:
|
|
31
|
-
• references/<topic>.md — session-specific detail (error transcripts, reproduction recipes, provider quirks) AND condensed knowledge banks: quoted research, API docs, external authoritative excerpts, or domain notes you found while working on the problem. Write it concise and for the value of the task, not as a full mirror of upstream docs.
|
|
32
|
-
• templates/<name>.<ext> — starter files meant to be copied and modified (boilerplate configs, scaffolding, a known-good example the agent can reproduce with modifications).
|
|
33
|
-
• scripts/<name>.<ext> — statically re-runnable actions the skill can invoke directly (verification scripts, fixture generators, deterministic probes, anything the agent should run rather than hand-type each time).
|
|
34
|
-
Add support files via skill_manage action=write_file with file_path starting 'references/', 'templates/', or 'scripts/'. The umbrella's SKILL.md should gain a one-line pointer to any new support file so future agents know it exists.
|
|
35
|
-
4. RESTRUCTURE a loaded skill whose body grew log-like — rc/sha/date-dense sections, session-detail spirals, or a fat body with no support files. Use skill_manage action=restructure with restructure: [{"heading": "<the exact ## heading text>", "to_file": "references/<topic>.md"}] — the ENTIRE ## section (from that heading to the next heading) moves into the support file and its position becomes a pointer line. The skill's name and directory never change. Only propose headings that exist verbatim in the body; never invent one, and never restructure a healthy small skill.
|
|
36
|
-
5. CREATE A NEW CLASS-LEVEL UMBRELLA SKILL when no existing skill covers the class. The name MUST be at the class level. The name MUST NOT be a specific PR number, error string, feature codename, library-alone name, or 'fix-X / debug-Y / audit-Z-today' session artifact. If the proposed name only makes sense for today's task, it's wrong — fall back to (1), (2), or (3).
|
|
37
|
-
|
|
38
|
-
User-preference embedding (important): when the user expressed a style/format/workflow preference, the update belongs in the SKILL.md body, not just in memory. Memory captures 'who the user is and what the current situation and state of your operations are'; skills capture 'how to do this class of task for this user'. When they complain about how you handled a task, the skill that governs that task needs to carry the lesson.
|
|
39
|
-
|
|
40
|
-
If you notice two existing skills that overlap, note it in your reply — the background curator handles consolidation at scale.
|
|
41
|
-
|
|
42
|
-
Two-tier deposition discipline (DSH addition, same spirit as the umbrella rule): before writing, classify the knowledge:
|
|
43
|
-
• PATTERN (reusable — symptom → mechanism → fix → verification, still valuable next session) belongs in the SKILL.md body.
|
|
44
|
-
• LOG (one-off — commit SHAs, npm/profile states, what this release changed, this session's process narrative) belongs in a references/ file, never the body. Body density IS reuse rate. Keep new entries tight: a pattern fits in 2-8 physical lines; prefer changing the current-state pointer over appending history.
|
|
45
|
-
|
|
46
|
-
Protected skills (DO NOT edit these):
|
|
47
|
-
• Bundled skills (shipped with the platform).
|
|
48
|
-
• Hub-installed skills (installed from a hub).
|
|
49
|
-
Pinned skills are read-only to THIS background review pass — the pinned write guard refuses background changes, so only the foreground may update or archive them. Foreground and delegated-subagent writes to pinned skills remain allowed.
|
|
50
|
-
If the only skills that need updating are protected, say 'Nothing to save.' and stop.
|
|
51
|
-
|
|
52
|
-
Do NOT capture (these become persistent self-imposed constraints that bite you later when the environment changes):
|
|
53
|
-
• Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these — they are not durable rules.
|
|
54
|
-
• Negative claims about tools or features ('browser tools do not work', 'X tool is broken', 'cannot use Y'). These harden into refusals the agent cites against itself for months after the actual problem was fixed.
|
|
55
|
-
• Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.
|
|
56
|
-
• One-off task narratives. A user asking 'summarize today's market' or 'analyze this PR' is not a class of work that warrants a skill.
|
|
57
|
-
|
|
58
|
-
If a tool failed because of setup state, capture the FIX (install command, config step, env var to set) under an existing setup or troubleshooting skill — never 'this tool does not work' as a standalone constraint.
|
|
59
|
-
|
|
60
|
-
'Nothing to save.' is a real option but should NOT be the default. If the session ran smoothly with no corrections and produced no new technique, just say 'Nothing to save.' and stop. Otherwise, act.`;
|
|
61
|
-
const COMBINED_REVIEW_PROMPT = `[Auto-review]
|
|
62
|
-
Review the conversation above and update two things:
|
|
63
|
-
|
|
64
|
-
**Memory**: who the user is. Did the user reveal persona, desires, preferences, personal details, or expectations about how you should behave? Save facts about the user and durable preferences with the memory tool.
|
|
65
|
-
|
|
66
|
-
**Skills**: how to do this class of task. Be ACTIVE — most sessions produce at least one skill update. A pass that does nothing is a missed learning opportunity, not a neutral outcome.
|
|
67
|
-
|
|
68
|
-
Target shape of the skill library: CLASS-LEVEL skills with a rich SKILL.md and a references/ directory for session-specific detail. Not a long flat list of narrow one-session-one-skill entries.
|
|
69
|
-
|
|
70
|
-
Signals that warrant a skill update (any one is enough):
|
|
71
|
-
• User corrected your style, tone, format, legibility, verbosity, or approach. Frustration is a FIRST-CLASS skill signal, not just a memory signal. 'stop doing X', 'don't format like this', 'I hate when you Y' — embed the lesson in the skill that governs that task so the next session starts fixed.
|
|
72
|
-
• Non-trivial technique, fix, workaround, or debugging path emerged.
|
|
73
|
-
• A skill that was loaded or consulted turned out wrong, missing, or outdated — patch it now.
|
|
74
|
-
|
|
75
|
-
Read-before-write (enforced by this channel): update, patch, delete, or write support files ONLY into skills you loaded or read in THIS session — ops on unread skills are dropped; CREATE of a brand-new umbrella is the only exception.
|
|
76
|
-
|
|
77
|
-
Preference order for skills — pick the earliest that fits:
|
|
78
|
-
1. UPDATE A CURRENTLY-LOADED SKILL. Check what skills were loaded or read in the conversation. If one of them covers the learning, PATCH it first. It was in play; it's the right place.
|
|
79
|
-
2. UPDATE AN EXISTING UMBRELLA. Patch it.
|
|
80
|
-
3. ADD A SUPPORT FILE under an existing umbrella via skill_manage action=write_file. Three kinds: references/<topic>.md for session-specific detail OR condensed knowledge banks (quoted research, API docs excerpts, domain notes) written concise and task-focused; templates/<name>.<ext> for starter files meant to be copied and modified; scripts/<name>.<ext> for statically re-runnable actions (verification, fixture generators, probes). Add a one-line pointer in SKILL.md so future agents find them.
|
|
81
|
-
4. RESTRUCTURE a loaded skill whose body grew log-like (rc/sha/date-dense sections, session-detail spirals, fat body with no support files) via skill_manage action=restructure with restructure: [{"heading": "<the exact ## heading text>", "to_file": "references/<topic>.md"}] — the ENTIRE ## section moves into the support file and its position becomes a pointer line; the skill's name and directory never change. Only propose headings that exist verbatim in the body.
|
|
82
|
-
5. CREATE A NEW CLASS-LEVEL UMBRELLA when nothing exists. Name at the class level — NOT a PR number, error string, codename, library-alone name, or 'fix-X / debug-Y' session artifact. If the name only fits today's task, fall back to (1), (2), or (3).
|
|
83
|
-
|
|
84
|
-
Two-tier deposition discipline (DSH addition): classify before writing — PATTERN (symptom → mechanism → fix → verification) goes in the SKILL.md body; LOG (commit SHAs, npm/profile states, this release's change list, this session's narrative) goes in a references/ file. Body density IS reuse rate; a pattern fits in 2-8 physical lines.
|
|
85
|
-
|
|
86
|
-
User-preference embedding: when the user complains about how you handled a task, update the skill that governs that task — memory alone isn't enough. Memory says 'who the user is and what the current situation and state of your operations are'; skills say 'how to do this class of task for this user'. Both should carry user-preference lessons when relevant.
|
|
87
|
-
|
|
88
|
-
If you notice overlapping existing skills, mention it — the background curator handles consolidation.
|
|
89
|
-
|
|
90
|
-
Protected skills (DO NOT edit these):
|
|
91
|
-
• Bundled skills (shipped with the platform).
|
|
92
|
-
• Hub-installed skills (installed from a hub).
|
|
93
|
-
Pinned skills are read-only to THIS background review pass — the pinned write guard refuses background changes, so only the foreground may update or archive them. Foreground and delegated-subagent writes to pinned skills remain allowed.
|
|
94
|
-
If the only skills that need updating are protected, say 'Nothing to save.' and stop.
|
|
95
|
-
|
|
96
|
-
Do NOT capture as skills (these become persistent self-imposed constraints that bite you later when the environment changes):
|
|
97
|
-
• Environment-dependent failures: missing binaries, fresh-install errors, post-migration path mismatches, 'command not found', unconfigured credentials, uninstalled packages. The user can fix these — they are not durable rules.
|
|
98
|
-
• Negative claims about tools or features ('browser tools do not work', 'X tool is broken', 'cannot use Y'). These harden into refusals the agent cites against itself for months after the actual problem was fixed.
|
|
99
|
-
• Session-specific transient errors that resolved before the conversation ended. If retrying worked, the lesson is the retry pattern, not the original failure.
|
|
100
|
-
• One-off task narratives. A user asking 'summarize today's market' or 'analyze this PR' is not a class of work that warrants a skill.
|
|
101
|
-
|
|
102
|
-
If a tool failed because of setup state, capture the FIX (install command, config step, env var to set) under an existing setup or troubleshooting skill — never 'this tool does not work' as a standalone constraint.
|
|
103
|
-
|
|
104
|
-
Act on whichever of the two dimensions has real signal. If genuinely nothing stands out on either, say 'Nothing to save.' and stop — but don't reach for that conclusion as a default.`;
|
|
105
|
-
const CURATOR_PROMPT = `You are the skill curator. Maintain a healthy, class-level skill library, not a flat pile of narrow one-session skills.
|
|
106
|
-
|
|
107
|
-
This is an UMBRELLA-BUILDING consolidation pass, not a passive audit and not a duplicate-finder.
|
|
108
|
-
|
|
109
|
-
The goal is a LIBRARY OF CLASS-LEVEL INSTRUCTIONS. A skill collection of many narrow skills where each captures one session's specific bug is a FAILURE of the library. An agent searching skills matches on descriptions, not exact names; one broad umbrella with labeled subsections beats five narrow siblings for discoverability.
|
|
110
|
-
|
|
111
|
-
Right target shape: class-level skills with rich SKILL.md + references/, templates/, scripts/ support files for session-specific detail.
|
|
112
|
-
|
|
113
|
-
Hard rules:
|
|
114
|
-
1. NEVER hard-delete a skill. Archive (moving to .archive/) is the maximum destructive action; archives are recoverable, deletion is not.
|
|
115
|
-
2. Do not touch bundled, hub-installed, pinned, or scheduled-task-referenced (referenced) skills. Referenced skills are fully protected — never consolidated, never pruned (there is no scheduled-task reference-rewriting pass; a referenced skill stays in place by design).
|
|
116
|
-
3. Do not archive recently-created or never-used skills without strong evidence. "use=0" is NOT evidence either way — it only means the trigger has not come up yet. Never archive a never-used skill unless it is at least 30 days old AND its content is genuinely obsolete or fully absorbed elsewhere.
|
|
117
|
-
4. Do NOT reject consolidation on the grounds that "each skill has a distinct trigger". The right bar is: would a human maintainer write this as N separate skills, or one skill with N labeled subsections? When the answer is the latter, merge.
|
|
118
|
-
5. Judge overlap on CONTENT, not on usage counters.
|
|
119
|
-
6. Before archiving a merged skill, ensure its unique content was preserved in the umbrella.
|
|
120
|
-
|
|
121
|
-
How to work:
|
|
122
|
-
1. Scan the candidate list. Identify PREFIX CLUSTERS — skills sharing a first word or domain keyword. Expected cluster count scales with the library: a large collection may show 10-25 prefix clusters, a small one often has none — a clean "nothing to consolidate" summary is the correct small-library outcome, not a shortage of ambition.
|
|
123
|
-
2. For each cluster with 2+ members, ask "what is the UMBRELLA CLASS these skills serve?" and consolidate:
|
|
124
|
-
a. MERGE INTO AN EXISTING UMBRELLA (patch a labeled section for each sibling's unique insight, then archive the siblings).
|
|
125
|
-
b. CREATE A NEW UMBRELLA SKILL.md covering the shared workflow with short labeled subsections, then archive the absorbed siblings.
|
|
126
|
-
c. DEMOTE session-specific detail to references/, templates/, or scripts/ under the umbrella. Use the right directory per kind:
|
|
127
|
-
• references/<topic>.md — session-specific detail OR condensed knowledge banks (quoted research, API docs excerpts, domain notes, provider quirks, reproduction recipes) written concise and task-focused.
|
|
128
|
-
• templates/<name>.<ext> — starter files meant to be copied and modified.
|
|
129
|
-
• scripts/<name>.<ext> — statically re-runnable actions (verification scripts, fixture generators, probes).
|
|
130
|
-
3. Package integrity — not optional: inspect each skill as a COMPLETE directory package, not just SKILL.md. A skill root may include references/, templates/, scripts/, and assets/. If the source skill has support files OR its SKILL.md contains relative links to them, DO NOT flatten only SKILL.md into <umbrella>/references/<old>.md. Choose one safe path instead: keep it as a standalone skill, OR fully merge by re-homing every needed support file into the umbrella's canonical directories AND rewriting the destination instructions to the new paths, OR archive the entire original skill package unchanged. Never leave demoted instructions pointing at files left behind under the old skill directory.
|
|
131
|
-
4. Flag skills whose NAME is too narrow (contains a PR number, a feature codename, a specific error string, an 'audit'/'diagnosis'/'salvage' session artifact) — they almost always belong as a subsection or support file under a class-level umbrella.
|
|
132
|
-
5. Iterate. After one consolidation round, scan the remaining set and look for the NEXT umbrella opportunity. Don't stop after 3 merges.
|
|
133
|
-
|
|
134
|
-
You are a NOMINATOR, not an executor: this channel has NO tools. Your single deliverable is the structured YAML block below. Never narrate actions you did not take ("merged", "patched", "archived") — you are proposing, and the deterministic engine executes only names from the candidate pool it gave you. (A future execution view would expose skill_manage; today it does not.)
|
|
135
|
-
|
|
136
|
-
'keep' is a legitimate decision ONLY when the skill is already a class-level umbrella and none of the proposed merges would improve discoverability. 'This is narrow but distinct from its siblings' is NOT a reason to keep — it's a reason to move it under an umbrella as a subsection or support file.
|
|
137
|
-
|
|
138
|
-
Expected output: real umbrella-ification. Process every obvious cluster. If you end the pass with obvious clusters still untouched, you stopped too early — go back and look at the clusters you left alone.
|
|
139
|
-
|
|
140
|
-
Keep the umbrella body tight and scannable: exact commands, verbatim paths, ~100-200 lines; never invent flags or APIs.
|
|
141
|
-
|
|
142
|
-
When done, write a human summary THEN the structured machine-readable block. The block is the contract: every skill you would move to .archive/ MUST appear in exactly one of the two lists. Return ONLY the YAML block after the summary — no post-block prose. Format EXACTLY:
|
|
143
|
-
|
|
144
|
-
## Structured summary (required)
|
|
145
|
-
\`\`\`yaml
|
|
146
|
-
consolidations:
|
|
147
|
-
- from: <old-skill-name>
|
|
148
|
-
mode: reference # optional — ONLY for a 'demote': source is narrow-but-valuable session detail, write it as references/<source>.md under the umbrella instead of appending to the body. Default is append. Place this line BEFORE into:. NEVER use reference when the source body links its own references/ templates/ scripts/ files.
|
|
149
|
-
into: <umbrella-skill-name>
|
|
150
|
-
reason: <one short sentence — why merged, not just 'similar'>
|
|
151
|
-
prunings:
|
|
152
|
-
- name: <skill-name>
|
|
153
|
-
reason: <one short sentence — why archived with no merge target>
|
|
154
|
-
\`\`\`
|
|
155
|
-
|
|
156
|
-
Every skill you would move to .archive/ MUST appear in exactly one of the two lists. If you consolidated X into umbrella Y (patched Y, wrote a references file to Y, or created Y with X's content absorbed), X goes under consolidations with into: Y. If you archived X with no absorption — truly stale, irrelevant, or obsolete — X goes under prunings. Leave a list empty (consolidations: []) if none. Do not omit the block. The block comes AFTER your human-readable summary of clusters processed, patches made, and decisions left alone.`;
|
|
157
|
-
const COMPLETION_SKILL_REVIEW_PROMPT = `[Auto-review — Skills · task complete]
|
|
158
|
-
Your current task now appears complete. Before wrapping up, review the approach and update the skill library via skill_manage.
|
|
159
|
-
|
|
160
|
-
Follow the skills review policy: be ACTIVE, prefer class-level umbrellas, patch ONLY skills loaded or read this session, and capture non-trivial techniques and user corrections. Do NOT capture environment-dependent failures, negative claims about tools, or one-off task narratives.
|
|
161
|
-
|
|
162
|
-
Do NOT modify output files or re-run the task. If you are still mid-task, ignore this.`;
|
|
163
|
-
/**
|
|
164
|
-
* Maintenance-subagent persona (design 011 §6). Constants pin the persona
|
|
165
|
-
* with `{signal:id}` placeholders; the renderer substitutes names from the
|
|
166
|
-
* drift-signals module (single vocabulary). The model-facing contract is the
|
|
167
|
-
* persona + the mechanical-facts block; the signature head lets the model
|
|
168
|
-
* compare the two heads (011 mismatch protocol).
|
|
169
|
-
*/
|
|
170
|
-
const MAINTAIN_PROMPT = `<<<MAINTAIN_PROMPT v={bundle_version} sig={joint_signature}>>>
|
|
171
|
-
|
|
172
|
-
## 角色
|
|
173
|
-
你是技能库的**外部审计者**:只读、只输出计划、从不执行(执行由用户命令与审批完成)。
|
|
174
|
-
|
|
175
|
-
## 1. 输入契约(冲突时以此为准)
|
|
176
|
-
机械事实块 <<<MECHANICAL_FACTS v={signals_version} sig={joint_signature}>>>(下方,以 <<<END FACTS>>> 闭合)是唯一证据来源。
|
|
177
|
-
- verdict 仅三值:pass=未越阈 / over=越阈 / unknown=未检测。
|
|
178
|
-
- over 是事实位置,不是违规结论;没有条款对应的事实,不产生建议。
|
|
179
|
-
- unknown ≠ pass;引用 unknown 信号的条目必须 needs_human:true。
|
|
180
|
-
- 事实只读:不改写、不补写、不把事实"翻译"成裁决。
|
|
181
|
-
- 两处 sig 不一致或任一缺失 → 只输出 MISMATCH + 两侧版本号,禁止输出计划。
|
|
182
|
-
|
|
183
|
-
## 2. 信号→条款映射(每条 over 必须落到条款;无一遗漏)
|
|
184
|
-
{signal:dedup_group}→A1 · {signal:narrow_name}→A2 · {signal:prefix_cluster}→A3 · {signal:stamp_density}与{signal:body_size}→B1 · {signal:pointer_missing}→B2 · {signal:dup_heading}→B3 · {signal:overlong_line}→B4 · {signal:description_chars}→B5 · {signal:usage_observed}/{signal:quality_low}→门控(校验器对 quality_low=unknown 的技能强制 needs_human,模板侧不重复)
|
|
185
|
-
|
|
186
|
-
## 3. 完整性契约(校验器机械执行)
|
|
187
|
-
事实块中每条 over 信号必须满足其一:成为某条建议的 evidence,或在 notes 中说明"已审·无条款对应·不动作"。禁止静默省略;先逐信号核对再输出。
|
|
188
|
-
|
|
189
|
-
## 4. 工作流程(按序执行,不得跳步)
|
|
190
|
-
① 通读事实块 → ② 对每个候选技能用 skill 读正文(B1/B2/B4 必读;**读取失败必须报告工具返回的事实**(错误信息/无对应条目),禁止用"无法读取"含糊绕过)→ ③ maintenance_probe 按需深挖 → ④ 逐信号过 §3 完整性 → ⑤ 输出计划。
|
|
191
|
-
|
|
192
|
-
## 5. 检查清单(信号 → 语义判定 → 输出形态)
|
|
193
|
-
A. 域·碎片化
|
|
194
|
-
- A1 {signal:dedup_group}=over:判近重复组是否同伞可合并;是→relationship-level consolidate;否→不输出。
|
|
195
|
-
- A2 {signal:narrow_name}=over:判否"仅对今日任务成立";成立→改名/归档建议;内部代号(格式合规语义窄)→conf≤0.4+needs_human。
|
|
196
|
-
- A3 {signal:prefix_cluster}=over:判簇内是否同伞;非同伞→notes 提域划分观察,不强制建伞。
|
|
197
|
-
|
|
198
|
-
B. 层·分层错位
|
|
199
|
-
- B1 {signal:stamp_density}(阈值 {signal:stamp_density.threshold})或 {signal:body_size}(阈值 {signal:body_size.threshold})=over:按**三问判据**判锚/残留——① 该编号/时间戳是否被库内其他文件引用?② 除"何时产生/为何存在"外是否还承载信息?③ 删除是否影响任何跨文档检索?(①是且③是→锚;否则→残留候选,人审)。锚→允许保留 + needs_human + semantic_reasoning 写三问结果;**锚不使用 is_override**(is_override 仅用于 §7 申诉;锚是 B1 的正常裁决路径);残留→restructure 建议(movable headings 逐字引用)。**锚≠可读:单行 >4000 字符即使在锚类也必须拆分。**
|
|
200
|
-
- B2 {signal:pointer_missing}=over:读支持文件后判性质——可复用模式→上移正文;会话专属实录→保留+补指针;形态=patch 指引。**未读内容仅凭文件名 → conf≤0.4 且措辞"先人工确认再执行"。** **缺失指针=支持文件存在、正文无引用(单向语义),finding 表述勿反向。**
|
|
201
|
-
- B3 {signal:dup_heading}=over:删除多余标题行(保留一份),patch 指引。
|
|
202
|
-
- B4 {signal:overlong_line}=over:>1500 拆行;>4000 判定可读性危机(内容合法也拆);patch 指引。**finding 必须给全量口径:共 N 行超限,其中 >4000 的逐行列出。**
|
|
203
|
-
- B5 {signal:description_chars}=over:先判**性质**三分类——事件性承诺(单次故障/incident 写入元数据)→裁剪建议;叙事性自我描述→压缩建议;丰富但合规(完整用例边界)→保留 + is_override + override_reason="合法密度"。**分类特征**:含"恢复/修复某次事故、日期快照"类一次性措辞→事件性承诺;"动词+对象"式任务说明→叙事性;枚举完整用例边界且不可拆分→丰富合规。**第三类门槛(默认从严,半机械)**:先自行试写一个 ≤60 字压缩方案——能保留全部路由关键项(触发词+域)→ 不可判第三类(按压缩建议);只有试写失败(在 semantic_reasoning 列出试写方案与具体失败点)才可判丰富合规。描述文本可见(probe desc-text 或正文 frontmatter)时仍须三分类;仅长度可见 → conf≤0.4。semantic_reasoning 必写三分类之一。
|
|
204
|
-
|
|
205
|
-
D. 库·整合纪律(计划形态约束)
|
|
206
|
-
- D1 同类问题多处出现→合成一条 relationship-level 建议,不逐项输出。
|
|
207
|
-
- D2 结构类优先级高于内容类;影响面 library-level > relationship-level > skill-level。
|
|
208
|
-
|
|
209
|
-
## 6. 输出契约(校验器机械执行)
|
|
210
|
-
{verdict: "issues" | "no_issues",
|
|
211
|
-
plan: [{ kind: "skill-level"|"relationship-level"|"library-level", names: [str],
|
|
212
|
-
rule: "A1"|"B2"|..., evidence: [{signal, value}],
|
|
213
|
-
finding: "<一句事实描述:引用信号 id 与值;零裁决动词>",
|
|
214
|
-
recommendation: "<唯一允许的'应'句:建议动作+理由+执行形态(命令/patch 指引)>",
|
|
215
|
-
semantic_reasoning: "<语义判据;含 LLM 推断时 confidence≤0.4>",
|
|
216
|
-
impact: "better|worse|neutral", impact_reason: "<相对'不动'的净影响>",
|
|
217
|
-
reversibility: "archive|restructure|patch|rename|none", undo_path: "<一步撤销方式>",
|
|
218
|
-
confidence: float, needs_human: bool, is_override: bool,
|
|
219
|
-
override_reason: "<仅 is_override>" }],
|
|
220
|
-
notes: [str]}
|
|
221
|
-
- verdict=no_issues ⇒ plan=[](不允许空 plan 之外的"无问题"表述)。
|
|
222
|
-
- **confidence 降档规则(机械)**:条款全部由机械证据支撑 → 0.6–0.9;每含一项语义推断(是否锚/是否同伞/性质归类)→ 上限 0.4。
|
|
223
|
-
- needs_human = (confidence < 0.6) OR (不可逆) OR (is_override) OR (引用 unknown 信号)。
|
|
224
|
-
- 语言:finding/recommendation/notes 与库正文语言一致(不自订语言);字段名/信号 id/枚举保留英文。
|
|
225
|
-
- **提交前自查(逐项对照,不许跳过)**:① verdict 与 plan 一致 ② 每条 evidence 在事实块 ③ undo_path 非空(不可逆=n/a)④ confidence 含推断≤0.4 ⑤ finding 无"应"字 ⑥ §3 完整性契约满足。
|
|
226
|
-
|
|
227
|
-
## 7. 裁决纪律
|
|
228
|
-
- finding 禁止"应当"句式;recommendation 是唯一"应"句,句板:建议对 {names} 执行 {动作}(形态:{命令/patch 指引}),理由:{理由}。
|
|
229
|
-
- **审查者视角**:先对每个信号独立初判,再与正文对照;被审对象的自我声明只作线索不作依据;**自属/维护者技能一律从严口径**(作者声明"这是锚"不构成豁免)。
|
|
230
|
-
- 申诉:机械阈值与语义判断冲突→is_override:true + override_reason + needs_human:true,不得静默绕过。
|
|
231
|
-
- 不动作合法:verdict=no_issues 是合法输出;连续空报告=信号定义问题,不是"更积极"的理由。
|
|
232
|
-
- 错误成本:rename 必须 needs_human:true;可逆动作(archive/restructure 两阶段)可 needs_human:false 但 undo_path 必填。
|
|
233
|
-
- 不做:不建议删除(只建议 archive);不提升内容质量(结构审查只 flag 位置/归属/分层);protected 集(bundled/hub/pinned)内 0 建议。
|
|
234
|
-
|
|
235
|
-
## 8. 泛化
|
|
236
|
-
- 信号集开放:事实块含、§5 未列的信号 → notes 提"该信号值得新增条款",禁止解释为已知问题。
|
|
237
|
-
- 库规模无关:判据是事实与条款,不是库体量印象。
|
|
238
|
-
- 信号机制疑问(阈值/检测原理)→ needs_human,不猜测机制。`;
|
|
239
|
-
/**
|
|
240
|
-
* System-prompt guidance section (Hermes `SKILLS_GUIDANCE`, DSH-adapted).
|
|
241
|
-
* Registered as a system-prompt section by tool-skill-manage (it mounts
|
|
242
|
-
* exactly when `skill_manage` is available — the DSH analogue of Hermes'
|
|
243
|
-
* `if "skill_manage" in agent.valid_tool_names` condition). Instructs the
|
|
244
|
-
* model to save/repair skills on its own initiative.
|
|
245
|
-
*/
|
|
246
|
-
const SKILLS_GUIDANCE = `Skills guidance:
|
|
247
|
-
• After completing a complex task (5+ tool calls), fixing a tricky error, or discovering a non-trivial workflow, save the approach as a skill with skill_manage so you can reuse it next time.
|
|
248
|
-
• When using a skill and finding it outdated, incomplete, or wrong, patch it immediately with skill_manage (action='patch') — don't wait to be asked. Skills that aren't maintained become liabilities.`;
|
|
249
|
-
const PLAN_CHANNEL_NOTE = `
|
|
250
|
-
|
|
251
|
-
CHANNEL (subagent): this review channel mounts only the read-only \`skill\` tool — you have NO \`skill_manage\`, NO \`memory\`. Your deliverable is the structured JSON plan below (outputSchema). Describe the patches/creates you RECOMMEND in the plan; never narrate actions you took.`;
|
|
252
|
-
/** Subagent-channel variant: same review policy, channel-limited deliverable (M-2). */
|
|
253
|
-
const SKILL_REVIEW_PLAN_PROMPT = `${SKILL_REVIEW_PROMPT}${PLAN_CHANNEL_NOTE}`;
|
|
254
|
-
/** Subagent-channel variant of the combined review (M-2). */
|
|
255
|
-
const COMBINED_REVIEW_PLAN_PROMPT = `${COMBINED_REVIEW_PROMPT}${PLAN_CHANNEL_NOTE}`;
|
|
256
|
-
function sha256(text) {
|
|
257
|
-
return createHash("sha256").update(text).digest("hex");
|
|
258
|
-
}
|
|
259
|
-
function createPromptBundle(prompts) {
|
|
260
|
-
const canonical = JSON.stringify({
|
|
261
|
-
id: PROMPT_BUNDLE_ID,
|
|
262
|
-
version: 13,
|
|
263
|
-
prompts: Object.fromEntries(Object.entries(prompts).sort())
|
|
264
|
-
});
|
|
265
|
-
return Object.freeze({
|
|
266
|
-
id: PROMPT_BUNDLE_ID,
|
|
267
|
-
version: 13,
|
|
268
|
-
prompts: Object.freeze({ ...prompts }),
|
|
269
|
-
sha256: sha256(canonical)
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
createPromptBundle({
|
|
273
|
-
memory: MEMORY_REVIEW_PROMPT,
|
|
274
|
-
skill: SKILL_REVIEW_PROMPT,
|
|
275
|
-
combined: COMBINED_REVIEW_PROMPT,
|
|
276
|
-
skillPlan: SKILL_REVIEW_PLAN_PROMPT,
|
|
277
|
-
combinedPlan: COMBINED_REVIEW_PLAN_PROMPT,
|
|
278
|
-
curator: CURATOR_PROMPT,
|
|
279
|
-
completion: COMPLETION_SKILL_REVIEW_PROMPT,
|
|
280
|
-
maintain: MAINTAIN_PROMPT,
|
|
281
|
-
skillsGuidance: SKILLS_GUIDANCE
|
|
282
|
-
});
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region ../evolution-core/src/threats.ts
|
|
285
|
-
const FILLER = String.raw`(?:\w+\s+){0,8}`;
|
|
286
|
-
new RegExp(String.raw`ignore\s+${FILLER}(?:previous|above|prior|all)\s+${FILLER}instructions`, "i"), new RegExp(String.raw`new\s+${FILLER}system\s+${FILLER}prompt`, "i"), new RegExp(String.raw`forget\s+${FILLER}(?:everything|all)\s+${FILLER}(?:discussed|you\s+know)`, "i"), new RegExp(String.raw`you\s+have\s+been\s+${FILLER}(?:updated|upgraded|patched)\s+to`, "i"), new RegExp(String.raw`do\s+not\s+${FILLER}tell\s+${FILLER}the\s+user`, "i"), new RegExp(String.raw`output\s+${FILLER}(?:system|initial)\s+prompt`, "i");
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region ../../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
|
|
289
|
-
/*! js-yaml 4.2.0 https://github.com/nodeca/js-yaml @license MIT */
|
|
290
|
-
var __create = Object.create;
|
|
291
|
-
var __defProp = Object.defineProperty;
|
|
292
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
293
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
294
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
295
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
296
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
297
|
-
var __copyProps = (to, from, except, desc) => {
|
|
298
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
299
|
-
key = keys[i];
|
|
300
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
301
|
-
get: ((k) => from[k]).bind(null, key),
|
|
302
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
return to;
|
|
306
|
-
};
|
|
307
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
308
|
-
value: mod,
|
|
309
|
-
enumerable: true
|
|
310
|
-
}) : target, mod));
|
|
311
|
-
var require_common = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
312
|
-
function isNothing(subject) {
|
|
313
|
-
return typeof subject === "undefined" || subject === null;
|
|
314
|
-
}
|
|
315
|
-
function isObject(subject) {
|
|
316
|
-
return typeof subject === "object" && subject !== null;
|
|
317
|
-
}
|
|
318
|
-
function toArray(sequence) {
|
|
319
|
-
if (Array.isArray(sequence)) return sequence;
|
|
320
|
-
else if (isNothing(sequence)) return [];
|
|
321
|
-
return [sequence];
|
|
322
|
-
}
|
|
323
|
-
function extend(target, source) {
|
|
324
|
-
if (source) {
|
|
325
|
-
const sourceKeys = Object.keys(source);
|
|
326
|
-
for (let index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
327
|
-
const key = sourceKeys[index];
|
|
328
|
-
target[key] = source[key];
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
return target;
|
|
332
|
-
}
|
|
333
|
-
function repeat(string, count) {
|
|
334
|
-
let result = "";
|
|
335
|
-
for (let cycle = 0; cycle < count; cycle += 1) result += string;
|
|
336
|
-
return result;
|
|
337
|
-
}
|
|
338
|
-
function isNegativeZero(number) {
|
|
339
|
-
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
340
|
-
}
|
|
341
|
-
module.exports.isNothing = isNothing;
|
|
342
|
-
module.exports.isObject = isObject;
|
|
343
|
-
module.exports.toArray = toArray;
|
|
344
|
-
module.exports.repeat = repeat;
|
|
345
|
-
module.exports.isNegativeZero = isNegativeZero;
|
|
346
|
-
module.exports.extend = extend;
|
|
347
|
-
}));
|
|
348
|
-
var require_exception = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
349
|
-
function formatError(exception, compact) {
|
|
350
|
-
let where = "";
|
|
351
|
-
const message = exception.reason || "(unknown reason)";
|
|
352
|
-
if (!exception.mark) return message;
|
|
353
|
-
if (exception.mark.name) where += "in \"" + exception.mark.name + "\" ";
|
|
354
|
-
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
355
|
-
if (!compact && exception.mark.snippet) where += "\n\n" + exception.mark.snippet;
|
|
356
|
-
return message + " " + where;
|
|
357
|
-
}
|
|
358
|
-
function YAMLException(reason, mark) {
|
|
359
|
-
Error.call(this);
|
|
360
|
-
this.name = "YAMLException";
|
|
361
|
-
this.reason = reason;
|
|
362
|
-
this.mark = mark;
|
|
363
|
-
this.message = formatError(this, false);
|
|
364
|
-
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
365
|
-
else this.stack = (/* @__PURE__ */ new Error()).stack || "";
|
|
366
|
-
}
|
|
367
|
-
YAMLException.prototype = Object.create(Error.prototype);
|
|
368
|
-
YAMLException.prototype.constructor = YAMLException;
|
|
369
|
-
YAMLException.prototype.toString = function toString(compact) {
|
|
370
|
-
return this.name + ": " + formatError(this, compact);
|
|
371
|
-
};
|
|
372
|
-
module.exports = YAMLException;
|
|
373
|
-
}));
|
|
374
|
-
var require_snippet = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
375
|
-
var common = require_common();
|
|
376
|
-
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
377
|
-
let head = "";
|
|
378
|
-
let tail = "";
|
|
379
|
-
const maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
380
|
-
if (position - lineStart > maxHalfLength) {
|
|
381
|
-
head = " ... ";
|
|
382
|
-
lineStart = position - maxHalfLength + head.length;
|
|
383
|
-
}
|
|
384
|
-
if (lineEnd - position > maxHalfLength) {
|
|
385
|
-
tail = " ...";
|
|
386
|
-
lineEnd = position + maxHalfLength - tail.length;
|
|
387
|
-
}
|
|
388
|
-
return {
|
|
389
|
-
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
390
|
-
pos: position - lineStart + head.length
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function padStart(string, max) {
|
|
394
|
-
return common.repeat(" ", max - string.length) + string;
|
|
395
|
-
}
|
|
396
|
-
function makeSnippet(mark, options) {
|
|
397
|
-
options = Object.create(options || null);
|
|
398
|
-
if (!mark.buffer) return null;
|
|
399
|
-
if (!options.maxLength) options.maxLength = 79;
|
|
400
|
-
if (typeof options.indent !== "number") options.indent = 1;
|
|
401
|
-
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
402
|
-
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
403
|
-
const re = /\r?\n|\r|\0/g;
|
|
404
|
-
const lineStarts = [0];
|
|
405
|
-
const lineEnds = [];
|
|
406
|
-
let match;
|
|
407
|
-
let foundLineNo = -1;
|
|
408
|
-
while (match = re.exec(mark.buffer)) {
|
|
409
|
-
lineEnds.push(match.index);
|
|
410
|
-
lineStarts.push(match.index + match[0].length);
|
|
411
|
-
if (mark.position <= match.index && foundLineNo < 0) foundLineNo = lineStarts.length - 2;
|
|
412
|
-
}
|
|
413
|
-
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
414
|
-
let result = "";
|
|
415
|
-
const lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
416
|
-
const maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
417
|
-
for (let i = 1; i <= options.linesBefore; i++) {
|
|
418
|
-
if (foundLineNo - i < 0) break;
|
|
419
|
-
const line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
420
|
-
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
421
|
-
}
|
|
422
|
-
const line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
423
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
424
|
-
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
425
|
-
for (let i = 1; i <= options.linesAfter; i++) {
|
|
426
|
-
if (foundLineNo + i >= lineEnds.length) break;
|
|
427
|
-
const line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
428
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
429
|
-
}
|
|
430
|
-
return result.replace(/\n$/, "");
|
|
431
|
-
}
|
|
432
|
-
module.exports = makeSnippet;
|
|
433
|
-
}));
|
|
434
|
-
var require_type = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
435
|
-
var YAMLException = require_exception();
|
|
436
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
437
|
-
"kind",
|
|
438
|
-
"multi",
|
|
439
|
-
"resolve",
|
|
440
|
-
"construct",
|
|
441
|
-
"instanceOf",
|
|
442
|
-
"predicate",
|
|
443
|
-
"represent",
|
|
444
|
-
"representName",
|
|
445
|
-
"defaultStyle",
|
|
446
|
-
"styleAliases"
|
|
447
|
-
];
|
|
448
|
-
var YAML_NODE_KINDS = [
|
|
449
|
-
"scalar",
|
|
450
|
-
"sequence",
|
|
451
|
-
"mapping"
|
|
452
|
-
];
|
|
453
|
-
function compileStyleAliases(map) {
|
|
454
|
-
const result = {};
|
|
455
|
-
if (map !== null) Object.keys(map).forEach(function(style) {
|
|
456
|
-
map[style].forEach(function(alias) {
|
|
457
|
-
result[String(alias)] = style;
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
return result;
|
|
461
|
-
}
|
|
462
|
-
function Type(tag, options) {
|
|
463
|
-
options = options || {};
|
|
464
|
-
Object.keys(options).forEach(function(name) {
|
|
465
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) throw new YAMLException("Unknown option \"" + name + "\" is met in definition of \"" + tag + "\" YAML type.");
|
|
466
|
-
});
|
|
467
|
-
this.options = options;
|
|
468
|
-
this.tag = tag;
|
|
469
|
-
this.kind = options["kind"] || null;
|
|
470
|
-
this.resolve = options["resolve"] || function() {
|
|
471
|
-
return true;
|
|
472
|
-
};
|
|
473
|
-
this.construct = options["construct"] || function(data) {
|
|
474
|
-
return data;
|
|
475
|
-
};
|
|
476
|
-
this.instanceOf = options["instanceOf"] || null;
|
|
477
|
-
this.predicate = options["predicate"] || null;
|
|
478
|
-
this.represent = options["represent"] || null;
|
|
479
|
-
this.representName = options["representName"] || null;
|
|
480
|
-
this.defaultStyle = options["defaultStyle"] || null;
|
|
481
|
-
this.multi = options["multi"] || false;
|
|
482
|
-
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
483
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) throw new YAMLException("Unknown kind \"" + this.kind + "\" is specified for \"" + tag + "\" YAML type.");
|
|
484
|
-
}
|
|
485
|
-
module.exports = Type;
|
|
486
|
-
}));
|
|
487
|
-
var require_schema = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
488
|
-
var YAMLException = require_exception();
|
|
489
|
-
var Type = require_type();
|
|
490
|
-
function compileList(schema, name) {
|
|
491
|
-
const result = [];
|
|
492
|
-
schema[name].forEach(function(currentType) {
|
|
493
|
-
let newIndex = result.length;
|
|
494
|
-
result.forEach(function(previousType, previousIndex) {
|
|
495
|
-
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) newIndex = previousIndex;
|
|
496
|
-
});
|
|
497
|
-
result[newIndex] = currentType;
|
|
498
|
-
});
|
|
499
|
-
return result;
|
|
500
|
-
}
|
|
501
|
-
function compileMap() {
|
|
502
|
-
const result = {
|
|
503
|
-
scalar: {},
|
|
504
|
-
sequence: {},
|
|
505
|
-
mapping: {},
|
|
506
|
-
fallback: {},
|
|
507
|
-
multi: {
|
|
508
|
-
scalar: [],
|
|
509
|
-
sequence: [],
|
|
510
|
-
mapping: [],
|
|
511
|
-
fallback: []
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
function collectType(type) {
|
|
515
|
-
if (type.multi) {
|
|
516
|
-
result.multi[type.kind].push(type);
|
|
517
|
-
result.multi["fallback"].push(type);
|
|
518
|
-
} else result[type.kind][type.tag] = result["fallback"][type.tag] = type;
|
|
519
|
-
}
|
|
520
|
-
for (let index = 0, length = arguments.length; index < length; index += 1) arguments[index].forEach(collectType);
|
|
521
|
-
return result;
|
|
522
|
-
}
|
|
523
|
-
function Schema(definition) {
|
|
524
|
-
return this.extend(definition);
|
|
525
|
-
}
|
|
526
|
-
Schema.prototype.extend = function extend(definition) {
|
|
527
|
-
let implicit = [];
|
|
528
|
-
let explicit = [];
|
|
529
|
-
if (definition instanceof Type) explicit.push(definition);
|
|
530
|
-
else if (Array.isArray(definition)) explicit = explicit.concat(definition);
|
|
531
|
-
else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
532
|
-
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
533
|
-
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
534
|
-
} else throw new YAMLException("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
535
|
-
implicit.forEach(function(type) {
|
|
536
|
-
if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
537
|
-
if (type.loadKind && type.loadKind !== "scalar") throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
538
|
-
if (type.multi) throw new YAMLException("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
539
|
-
});
|
|
540
|
-
explicit.forEach(function(type) {
|
|
541
|
-
if (!(type instanceof Type)) throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
542
|
-
});
|
|
543
|
-
const result = Object.create(Schema.prototype);
|
|
544
|
-
result.implicit = (this.implicit || []).concat(implicit);
|
|
545
|
-
result.explicit = (this.explicit || []).concat(explicit);
|
|
546
|
-
result.compiledImplicit = compileList(result, "implicit");
|
|
547
|
-
result.compiledExplicit = compileList(result, "explicit");
|
|
548
|
-
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
549
|
-
return result;
|
|
550
|
-
};
|
|
551
|
-
module.exports = Schema;
|
|
552
|
-
}));
|
|
553
|
-
var require_str = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
554
|
-
module.exports = new (require_type())("tag:yaml.org,2002:str", {
|
|
555
|
-
kind: "scalar",
|
|
556
|
-
construct: function(data) {
|
|
557
|
-
return data !== null ? data : "";
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
}));
|
|
561
|
-
var require_seq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
562
|
-
module.exports = new (require_type())("tag:yaml.org,2002:seq", {
|
|
563
|
-
kind: "sequence",
|
|
564
|
-
construct: function(data) {
|
|
565
|
-
return data !== null ? data : [];
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
}));
|
|
569
|
-
var require_map = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
570
|
-
module.exports = new (require_type())("tag:yaml.org,2002:map", {
|
|
571
|
-
kind: "mapping",
|
|
572
|
-
construct: function(data) {
|
|
573
|
-
return data !== null ? data : {};
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
}));
|
|
577
|
-
var require_failsafe = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
578
|
-
module.exports = new (require_schema())({ explicit: [
|
|
579
|
-
require_str(),
|
|
580
|
-
require_seq(),
|
|
581
|
-
require_map()
|
|
582
|
-
] });
|
|
583
|
-
}));
|
|
584
|
-
var require_null = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
585
|
-
var Type = require_type();
|
|
586
|
-
function resolveYamlNull(data) {
|
|
587
|
-
if (data === null) return true;
|
|
588
|
-
const max = data.length;
|
|
589
|
-
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
590
|
-
}
|
|
591
|
-
function constructYamlNull() {
|
|
592
|
-
return null;
|
|
593
|
-
}
|
|
594
|
-
function isNull(object) {
|
|
595
|
-
return object === null;
|
|
596
|
-
}
|
|
597
|
-
module.exports = new Type("tag:yaml.org,2002:null", {
|
|
598
|
-
kind: "scalar",
|
|
599
|
-
resolve: resolveYamlNull,
|
|
600
|
-
construct: constructYamlNull,
|
|
601
|
-
predicate: isNull,
|
|
602
|
-
represent: {
|
|
603
|
-
canonical: function() {
|
|
604
|
-
return "~";
|
|
605
|
-
},
|
|
606
|
-
lowercase: function() {
|
|
607
|
-
return "null";
|
|
608
|
-
},
|
|
609
|
-
uppercase: function() {
|
|
610
|
-
return "NULL";
|
|
611
|
-
},
|
|
612
|
-
camelcase: function() {
|
|
613
|
-
return "Null";
|
|
614
|
-
},
|
|
615
|
-
empty: function() {
|
|
616
|
-
return "";
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
defaultStyle: "lowercase"
|
|
620
|
-
});
|
|
621
|
-
}));
|
|
622
|
-
var require_bool = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
623
|
-
var Type = require_type();
|
|
624
|
-
function resolveYamlBoolean(data) {
|
|
625
|
-
if (data === null) return false;
|
|
626
|
-
const max = data.length;
|
|
627
|
-
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
628
|
-
}
|
|
629
|
-
function constructYamlBoolean(data) {
|
|
630
|
-
return data === "true" || data === "True" || data === "TRUE";
|
|
631
|
-
}
|
|
632
|
-
function isBoolean(object) {
|
|
633
|
-
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
634
|
-
}
|
|
635
|
-
module.exports = new Type("tag:yaml.org,2002:bool", {
|
|
636
|
-
kind: "scalar",
|
|
637
|
-
resolve: resolveYamlBoolean,
|
|
638
|
-
construct: constructYamlBoolean,
|
|
639
|
-
predicate: isBoolean,
|
|
640
|
-
represent: {
|
|
641
|
-
lowercase: function(object) {
|
|
642
|
-
return object ? "true" : "false";
|
|
643
|
-
},
|
|
644
|
-
uppercase: function(object) {
|
|
645
|
-
return object ? "TRUE" : "FALSE";
|
|
646
|
-
},
|
|
647
|
-
camelcase: function(object) {
|
|
648
|
-
return object ? "True" : "False";
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
defaultStyle: "lowercase"
|
|
652
|
-
});
|
|
653
|
-
}));
|
|
654
|
-
var require_int = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
655
|
-
var common = require_common();
|
|
656
|
-
var Type = require_type();
|
|
657
|
-
function isHexCode(c) {
|
|
658
|
-
return c >= 48 && c <= 57 || c >= 65 && c <= 70 || c >= 97 && c <= 102;
|
|
659
|
-
}
|
|
660
|
-
function isOctCode(c) {
|
|
661
|
-
return c >= 48 && c <= 55;
|
|
662
|
-
}
|
|
663
|
-
function isDecCode(c) {
|
|
664
|
-
return c >= 48 && c <= 57;
|
|
665
|
-
}
|
|
666
|
-
function resolveYamlInteger(data) {
|
|
667
|
-
if (data === null) return false;
|
|
668
|
-
const max = data.length;
|
|
669
|
-
let index = 0;
|
|
670
|
-
let hasDigits = false;
|
|
671
|
-
if (!max) return false;
|
|
672
|
-
let ch = data[index];
|
|
673
|
-
if (ch === "-" || ch === "+") ch = data[++index];
|
|
674
|
-
if (ch === "0") {
|
|
675
|
-
if (index + 1 === max) return true;
|
|
676
|
-
ch = data[++index];
|
|
677
|
-
if (ch === "b") {
|
|
678
|
-
index++;
|
|
679
|
-
for (; index < max; index++) {
|
|
680
|
-
ch = data[index];
|
|
681
|
-
if (ch !== "0" && ch !== "1") return false;
|
|
682
|
-
hasDigits = true;
|
|
683
|
-
}
|
|
684
|
-
return hasDigits && Number.isFinite(parseYamlInteger(data));
|
|
685
|
-
}
|
|
686
|
-
if (ch === "x") {
|
|
687
|
-
index++;
|
|
688
|
-
for (; index < max; index++) {
|
|
689
|
-
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
690
|
-
hasDigits = true;
|
|
691
|
-
}
|
|
692
|
-
return hasDigits && Number.isFinite(parseYamlInteger(data));
|
|
693
|
-
}
|
|
694
|
-
if (ch === "o") {
|
|
695
|
-
index++;
|
|
696
|
-
for (; index < max; index++) {
|
|
697
|
-
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
698
|
-
hasDigits = true;
|
|
699
|
-
}
|
|
700
|
-
return hasDigits && Number.isFinite(parseYamlInteger(data));
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
for (; index < max; index++) {
|
|
704
|
-
if (!isDecCode(data.charCodeAt(index))) return false;
|
|
705
|
-
hasDigits = true;
|
|
706
|
-
}
|
|
707
|
-
if (!hasDigits) return false;
|
|
708
|
-
return Number.isFinite(parseYamlInteger(data));
|
|
709
|
-
}
|
|
710
|
-
function parseYamlInteger(data) {
|
|
711
|
-
let value = data;
|
|
712
|
-
let sign = 1;
|
|
713
|
-
let ch = value[0];
|
|
714
|
-
if (ch === "-" || ch === "+") {
|
|
715
|
-
if (ch === "-") sign = -1;
|
|
716
|
-
value = value.slice(1);
|
|
717
|
-
ch = value[0];
|
|
718
|
-
}
|
|
719
|
-
if (value === "0") return 0;
|
|
720
|
-
if (ch === "0") {
|
|
721
|
-
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
722
|
-
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
723
|
-
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
724
|
-
}
|
|
725
|
-
return sign * parseInt(value, 10);
|
|
726
|
-
}
|
|
727
|
-
function constructYamlInteger(data) {
|
|
728
|
-
return parseYamlInteger(data);
|
|
729
|
-
}
|
|
730
|
-
function isInteger(object) {
|
|
731
|
-
return Object.prototype.toString.call(object) === "[object Number]" && object % 1 === 0 && !common.isNegativeZero(object);
|
|
732
|
-
}
|
|
733
|
-
module.exports = new Type("tag:yaml.org,2002:int", {
|
|
734
|
-
kind: "scalar",
|
|
735
|
-
resolve: resolveYamlInteger,
|
|
736
|
-
construct: constructYamlInteger,
|
|
737
|
-
predicate: isInteger,
|
|
738
|
-
represent: {
|
|
739
|
-
binary: function(obj) {
|
|
740
|
-
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
741
|
-
},
|
|
742
|
-
octal: function(obj) {
|
|
743
|
-
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
744
|
-
},
|
|
745
|
-
decimal: function(obj) {
|
|
746
|
-
return obj.toString(10);
|
|
747
|
-
},
|
|
748
|
-
hexadecimal: function(obj) {
|
|
749
|
-
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
defaultStyle: "decimal",
|
|
753
|
-
styleAliases: {
|
|
754
|
-
binary: [2, "bin"],
|
|
755
|
-
octal: [8, "oct"],
|
|
756
|
-
decimal: [10, "dec"],
|
|
757
|
-
hexadecimal: [16, "hex"]
|
|
758
|
-
}
|
|
759
|
-
});
|
|
760
|
-
}));
|
|
761
|
-
var require_float = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
762
|
-
var common = require_common();
|
|
763
|
-
var Type = require_type();
|
|
764
|
-
var YAML_FLOAT_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
765
|
-
var YAML_FLOAT_SPECIAL_PATTERN = /* @__PURE__ */ new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
766
|
-
function resolveYamlFloat(data) {
|
|
767
|
-
if (data === null) return false;
|
|
768
|
-
if (!YAML_FLOAT_PATTERN.test(data)) return false;
|
|
769
|
-
if (Number.isFinite(parseFloat(data, 10))) return true;
|
|
770
|
-
return YAML_FLOAT_SPECIAL_PATTERN.test(data);
|
|
771
|
-
}
|
|
772
|
-
function constructYamlFloat(data) {
|
|
773
|
-
let value = data.toLowerCase();
|
|
774
|
-
const sign = value[0] === "-" ? -1 : 1;
|
|
775
|
-
if ("+-".indexOf(value[0]) >= 0) value = value.slice(1);
|
|
776
|
-
if (value === ".inf") return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
777
|
-
else if (value === ".nan") return NaN;
|
|
778
|
-
return sign * parseFloat(value, 10);
|
|
779
|
-
}
|
|
780
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
781
|
-
function representYamlFloat(object, style) {
|
|
782
|
-
if (isNaN(object)) switch (style) {
|
|
783
|
-
case "lowercase": return ".nan";
|
|
784
|
-
case "uppercase": return ".NAN";
|
|
785
|
-
case "camelcase": return ".NaN";
|
|
786
|
-
}
|
|
787
|
-
else if (Number.POSITIVE_INFINITY === object) switch (style) {
|
|
788
|
-
case "lowercase": return ".inf";
|
|
789
|
-
case "uppercase": return ".INF";
|
|
790
|
-
case "camelcase": return ".Inf";
|
|
791
|
-
}
|
|
792
|
-
else if (Number.NEGATIVE_INFINITY === object) switch (style) {
|
|
793
|
-
case "lowercase": return "-.inf";
|
|
794
|
-
case "uppercase": return "-.INF";
|
|
795
|
-
case "camelcase": return "-.Inf";
|
|
796
|
-
}
|
|
797
|
-
else if (common.isNegativeZero(object)) return "-0.0";
|
|
798
|
-
const res = object.toString(10);
|
|
799
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
800
|
-
}
|
|
801
|
-
function isFloat(object) {
|
|
802
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
803
|
-
}
|
|
804
|
-
module.exports = new Type("tag:yaml.org,2002:float", {
|
|
805
|
-
kind: "scalar",
|
|
806
|
-
resolve: resolveYamlFloat,
|
|
807
|
-
construct: constructYamlFloat,
|
|
808
|
-
predicate: isFloat,
|
|
809
|
-
represent: representYamlFloat,
|
|
810
|
-
defaultStyle: "lowercase"
|
|
811
|
-
});
|
|
812
|
-
}));
|
|
813
|
-
var require_json = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
814
|
-
module.exports = require_failsafe().extend({ implicit: [
|
|
815
|
-
require_null(),
|
|
816
|
-
require_bool(),
|
|
817
|
-
require_int(),
|
|
818
|
-
require_float()
|
|
819
|
-
] });
|
|
820
|
-
}));
|
|
821
|
-
var require_core = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
822
|
-
module.exports = require_json();
|
|
823
|
-
}));
|
|
824
|
-
var require_timestamp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
825
|
-
var Type = require_type();
|
|
826
|
-
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
827
|
-
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");
|
|
828
|
-
function resolveYamlTimestamp(data) {
|
|
829
|
-
if (data === null) return false;
|
|
830
|
-
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
831
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
832
|
-
return false;
|
|
833
|
-
}
|
|
834
|
-
function constructYamlTimestamp(data) {
|
|
835
|
-
let fraction = 0;
|
|
836
|
-
let delta = null;
|
|
837
|
-
let match = YAML_DATE_REGEXP.exec(data);
|
|
838
|
-
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
839
|
-
if (match === null) throw new Error("Date resolve error");
|
|
840
|
-
const year = +match[1];
|
|
841
|
-
const month = +match[2] - 1;
|
|
842
|
-
const day = +match[3];
|
|
843
|
-
if (!match[4]) return new Date(Date.UTC(year, month, day));
|
|
844
|
-
const hour = +match[4];
|
|
845
|
-
const minute = +match[5];
|
|
846
|
-
const second = +match[6];
|
|
847
|
-
if (match[7]) {
|
|
848
|
-
fraction = match[7].slice(0, 3);
|
|
849
|
-
while (fraction.length < 3) fraction += "0";
|
|
850
|
-
fraction = +fraction;
|
|
851
|
-
}
|
|
852
|
-
if (match[9]) {
|
|
853
|
-
const tzHour = +match[10];
|
|
854
|
-
const tzMinute = +(match[11] || 0);
|
|
855
|
-
delta = (tzHour * 60 + tzMinute) * 6e4;
|
|
856
|
-
if (match[9] === "-") delta = -delta;
|
|
857
|
-
}
|
|
858
|
-
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
859
|
-
if (delta) date.setTime(date.getTime() - delta);
|
|
860
|
-
return date;
|
|
861
|
-
}
|
|
862
|
-
function representYamlTimestamp(object) {
|
|
863
|
-
return object.toISOString();
|
|
864
|
-
}
|
|
865
|
-
module.exports = new Type("tag:yaml.org,2002:timestamp", {
|
|
866
|
-
kind: "scalar",
|
|
867
|
-
resolve: resolveYamlTimestamp,
|
|
868
|
-
construct: constructYamlTimestamp,
|
|
869
|
-
instanceOf: Date,
|
|
870
|
-
represent: representYamlTimestamp
|
|
871
|
-
});
|
|
872
|
-
}));
|
|
873
|
-
var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
874
|
-
var Type = require_type();
|
|
875
|
-
function resolveYamlMerge(data) {
|
|
876
|
-
return data === "<<" || data === null;
|
|
877
|
-
}
|
|
878
|
-
module.exports = new Type("tag:yaml.org,2002:merge", {
|
|
879
|
-
kind: "scalar",
|
|
880
|
-
resolve: resolveYamlMerge
|
|
881
|
-
});
|
|
882
|
-
}));
|
|
883
|
-
var require_binary = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
884
|
-
var Type = require_type();
|
|
885
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
886
|
-
function resolveYamlBinary(data) {
|
|
887
|
-
if (data === null) return false;
|
|
888
|
-
let bitlen = 0;
|
|
889
|
-
const max = data.length;
|
|
890
|
-
const map = BASE64_MAP;
|
|
891
|
-
for (let idx = 0; idx < max; idx++) {
|
|
892
|
-
const code = map.indexOf(data.charAt(idx));
|
|
893
|
-
if (code > 64) continue;
|
|
894
|
-
if (code < 0) return false;
|
|
895
|
-
bitlen += 6;
|
|
896
|
-
}
|
|
897
|
-
return bitlen % 8 === 0;
|
|
898
|
-
}
|
|
899
|
-
function constructYamlBinary(data) {
|
|
900
|
-
const input = data.replace(/[\r\n=]/g, "");
|
|
901
|
-
const max = input.length;
|
|
902
|
-
const map = BASE64_MAP;
|
|
903
|
-
let bits = 0;
|
|
904
|
-
const result = [];
|
|
905
|
-
for (let idx = 0; idx < max; idx++) {
|
|
906
|
-
if (idx % 4 === 0 && idx) {
|
|
907
|
-
result.push(bits >> 16 & 255);
|
|
908
|
-
result.push(bits >> 8 & 255);
|
|
909
|
-
result.push(bits & 255);
|
|
910
|
-
}
|
|
911
|
-
bits = bits << 6 | map.indexOf(input.charAt(idx));
|
|
912
|
-
}
|
|
913
|
-
const tailbits = max % 4 * 6;
|
|
914
|
-
if (tailbits === 0) {
|
|
915
|
-
result.push(bits >> 16 & 255);
|
|
916
|
-
result.push(bits >> 8 & 255);
|
|
917
|
-
result.push(bits & 255);
|
|
918
|
-
} else if (tailbits === 18) {
|
|
919
|
-
result.push(bits >> 10 & 255);
|
|
920
|
-
result.push(bits >> 2 & 255);
|
|
921
|
-
} else if (tailbits === 12) result.push(bits >> 4 & 255);
|
|
922
|
-
return new Uint8Array(result);
|
|
923
|
-
}
|
|
924
|
-
function representYamlBinary(object) {
|
|
925
|
-
let result = "";
|
|
926
|
-
let bits = 0;
|
|
927
|
-
const max = object.length;
|
|
928
|
-
const map = BASE64_MAP;
|
|
929
|
-
for (let idx = 0; idx < max; idx++) {
|
|
930
|
-
if (idx % 3 === 0 && idx) {
|
|
931
|
-
result += map[bits >> 18 & 63];
|
|
932
|
-
result += map[bits >> 12 & 63];
|
|
933
|
-
result += map[bits >> 6 & 63];
|
|
934
|
-
result += map[bits & 63];
|
|
935
|
-
}
|
|
936
|
-
bits = (bits << 8) + object[idx];
|
|
937
|
-
}
|
|
938
|
-
const tail = max % 3;
|
|
939
|
-
if (tail === 0) {
|
|
940
|
-
result += map[bits >> 18 & 63];
|
|
941
|
-
result += map[bits >> 12 & 63];
|
|
942
|
-
result += map[bits >> 6 & 63];
|
|
943
|
-
result += map[bits & 63];
|
|
944
|
-
} else if (tail === 2) {
|
|
945
|
-
result += map[bits >> 10 & 63];
|
|
946
|
-
result += map[bits >> 4 & 63];
|
|
947
|
-
result += map[bits << 2 & 63];
|
|
948
|
-
result += map[64];
|
|
949
|
-
} else if (tail === 1) {
|
|
950
|
-
result += map[bits >> 2 & 63];
|
|
951
|
-
result += map[bits << 4 & 63];
|
|
952
|
-
result += map[64];
|
|
953
|
-
result += map[64];
|
|
954
|
-
}
|
|
955
|
-
return result;
|
|
956
|
-
}
|
|
957
|
-
function isBinary(obj) {
|
|
958
|
-
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
959
|
-
}
|
|
960
|
-
module.exports = new Type("tag:yaml.org,2002:binary", {
|
|
961
|
-
kind: "scalar",
|
|
962
|
-
resolve: resolveYamlBinary,
|
|
963
|
-
construct: constructYamlBinary,
|
|
964
|
-
predicate: isBinary,
|
|
965
|
-
represent: representYamlBinary
|
|
966
|
-
});
|
|
967
|
-
}));
|
|
968
|
-
var require_omap = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
969
|
-
var Type = require_type();
|
|
970
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
971
|
-
var _toString = Object.prototype.toString;
|
|
972
|
-
function resolveYamlOmap(data) {
|
|
973
|
-
if (data === null) return true;
|
|
974
|
-
const objectKeys = [];
|
|
975
|
-
const object = data;
|
|
976
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
977
|
-
const pair = object[index];
|
|
978
|
-
let pairHasKey = false;
|
|
979
|
-
if (_toString.call(pair) !== "[object Object]") return false;
|
|
980
|
-
let pairKey;
|
|
981
|
-
for (pairKey in pair) if (_hasOwnProperty.call(pair, pairKey)) if (!pairHasKey) pairHasKey = true;
|
|
982
|
-
else return false;
|
|
983
|
-
if (!pairHasKey) return false;
|
|
984
|
-
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
985
|
-
else return false;
|
|
986
|
-
}
|
|
987
|
-
return true;
|
|
988
|
-
}
|
|
989
|
-
function constructYamlOmap(data) {
|
|
990
|
-
return data !== null ? data : [];
|
|
991
|
-
}
|
|
992
|
-
module.exports = new Type("tag:yaml.org,2002:omap", {
|
|
993
|
-
kind: "sequence",
|
|
994
|
-
resolve: resolveYamlOmap,
|
|
995
|
-
construct: constructYamlOmap
|
|
996
|
-
});
|
|
997
|
-
}));
|
|
998
|
-
var require_pairs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
999
|
-
var Type = require_type();
|
|
1000
|
-
var _toString = Object.prototype.toString;
|
|
1001
|
-
function resolveYamlPairs(data) {
|
|
1002
|
-
if (data === null) return true;
|
|
1003
|
-
const object = data;
|
|
1004
|
-
const result = new Array(object.length);
|
|
1005
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
1006
|
-
const pair = object[index];
|
|
1007
|
-
if (_toString.call(pair) !== "[object Object]") return false;
|
|
1008
|
-
const keys = Object.keys(pair);
|
|
1009
|
-
if (keys.length !== 1) return false;
|
|
1010
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1011
|
-
}
|
|
1012
|
-
return true;
|
|
1013
|
-
}
|
|
1014
|
-
function constructYamlPairs(data) {
|
|
1015
|
-
if (data === null) return [];
|
|
1016
|
-
const object = data;
|
|
1017
|
-
const result = new Array(object.length);
|
|
1018
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
1019
|
-
const pair = object[index];
|
|
1020
|
-
const keys = Object.keys(pair);
|
|
1021
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1022
|
-
}
|
|
1023
|
-
return result;
|
|
1024
|
-
}
|
|
1025
|
-
module.exports = new Type("tag:yaml.org,2002:pairs", {
|
|
1026
|
-
kind: "sequence",
|
|
1027
|
-
resolve: resolveYamlPairs,
|
|
1028
|
-
construct: constructYamlPairs
|
|
1029
|
-
});
|
|
1030
|
-
}));
|
|
1031
|
-
var require_set = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1032
|
-
var Type = require_type();
|
|
1033
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1034
|
-
function resolveYamlSet(data) {
|
|
1035
|
-
if (data === null) return true;
|
|
1036
|
-
const object = data;
|
|
1037
|
-
for (const key in object) if (_hasOwnProperty.call(object, key)) {
|
|
1038
|
-
if (object[key] !== null) return false;
|
|
1039
|
-
}
|
|
1040
|
-
return true;
|
|
1041
|
-
}
|
|
1042
|
-
function constructYamlSet(data) {
|
|
1043
|
-
return data !== null ? data : {};
|
|
1044
|
-
}
|
|
1045
|
-
module.exports = new Type("tag:yaml.org,2002:set", {
|
|
1046
|
-
kind: "mapping",
|
|
1047
|
-
resolve: resolveYamlSet,
|
|
1048
|
-
construct: constructYamlSet
|
|
1049
|
-
});
|
|
1050
|
-
}));
|
|
1051
|
-
var require_default = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1052
|
-
module.exports = require_core().extend({
|
|
1053
|
-
implicit: [require_timestamp(), require_merge()],
|
|
1054
|
-
explicit: [
|
|
1055
|
-
require_binary(),
|
|
1056
|
-
require_omap(),
|
|
1057
|
-
require_pairs(),
|
|
1058
|
-
require_set()
|
|
1059
|
-
]
|
|
1060
|
-
});
|
|
1061
|
-
}));
|
|
1062
|
-
var require_loader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1063
|
-
var common = require_common();
|
|
1064
|
-
var YAMLException = require_exception();
|
|
1065
|
-
var makeSnippet = require_snippet();
|
|
1066
|
-
var DEFAULT_SCHEMA = require_default();
|
|
1067
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1068
|
-
var CONTEXT_FLOW_IN = 1;
|
|
1069
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
1070
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
1071
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
1072
|
-
var CHOMPING_CLIP = 1;
|
|
1073
|
-
var CHOMPING_STRIP = 2;
|
|
1074
|
-
var CHOMPING_KEEP = 3;
|
|
1075
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1076
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1077
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]{}]/;
|
|
1078
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![0-9A-Za-z-]+!)$/;
|
|
1079
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;
|
|
1080
|
-
function _class(obj) {
|
|
1081
|
-
return Object.prototype.toString.call(obj);
|
|
1082
|
-
}
|
|
1083
|
-
function isEol(c) {
|
|
1084
|
-
return c === 10 || c === 13;
|
|
1085
|
-
}
|
|
1086
|
-
function isWhiteSpace(c) {
|
|
1087
|
-
return c === 9 || c === 32;
|
|
1088
|
-
}
|
|
1089
|
-
function isWsOrEol(c) {
|
|
1090
|
-
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1091
|
-
}
|
|
1092
|
-
function isFlowIndicator(c) {
|
|
1093
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1094
|
-
}
|
|
1095
|
-
function fromHexCode(c) {
|
|
1096
|
-
if (c >= 48 && c <= 57) return c - 48;
|
|
1097
|
-
const lc = c | 32;
|
|
1098
|
-
if (lc >= 97 && lc <= 102) return lc - 97 + 10;
|
|
1099
|
-
return -1;
|
|
1100
|
-
}
|
|
1101
|
-
function escapedHexLen(c) {
|
|
1102
|
-
if (c === 120) return 2;
|
|
1103
|
-
if (c === 117) return 4;
|
|
1104
|
-
if (c === 85) return 8;
|
|
1105
|
-
return 0;
|
|
1106
|
-
}
|
|
1107
|
-
function fromDecimalCode(c) {
|
|
1108
|
-
if (c >= 48 && c <= 57) return c - 48;
|
|
1109
|
-
return -1;
|
|
1110
|
-
}
|
|
1111
|
-
function simpleEscapeSequence(c) {
|
|
1112
|
-
switch (c) {
|
|
1113
|
-
case 48: return "\0";
|
|
1114
|
-
case 97: return "\x07";
|
|
1115
|
-
case 98: return "\b";
|
|
1116
|
-
case 116: return " ";
|
|
1117
|
-
case 9: return " ";
|
|
1118
|
-
case 110: return "\n";
|
|
1119
|
-
case 118: return "\v";
|
|
1120
|
-
case 102: return "\f";
|
|
1121
|
-
case 114: return "\r";
|
|
1122
|
-
case 101: return "\x1B";
|
|
1123
|
-
case 32: return " ";
|
|
1124
|
-
case 34: return "\"";
|
|
1125
|
-
case 47: return "/";
|
|
1126
|
-
case 92: return "\\";
|
|
1127
|
-
case 78: return "
";
|
|
1128
|
-
case 95: return "\xA0";
|
|
1129
|
-
case 76: return "\u2028";
|
|
1130
|
-
case 80: return "\u2029";
|
|
1131
|
-
default: return "";
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
function charFromCodepoint(c) {
|
|
1135
|
-
if (c <= 65535) return String.fromCharCode(c);
|
|
1136
|
-
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1137
|
-
}
|
|
1138
|
-
function setProperty(object, key, value) {
|
|
1139
|
-
if (key === "__proto__") Object.defineProperty(object, key, {
|
|
1140
|
-
configurable: true,
|
|
1141
|
-
enumerable: true,
|
|
1142
|
-
writable: true,
|
|
1143
|
-
value
|
|
1144
|
-
});
|
|
1145
|
-
else object[key] = value;
|
|
1146
|
-
}
|
|
1147
|
-
var simpleEscapeCheck = new Array(256);
|
|
1148
|
-
var simpleEscapeMap = new Array(256);
|
|
1149
|
-
for (let i = 0; i < 256; i++) {
|
|
1150
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1151
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1152
|
-
}
|
|
1153
|
-
function State(input, options) {
|
|
1154
|
-
this.input = input;
|
|
1155
|
-
this.filename = options["filename"] || null;
|
|
1156
|
-
this.schema = options["schema"] || DEFAULT_SCHEMA;
|
|
1157
|
-
this.onWarning = options["onWarning"] || null;
|
|
1158
|
-
this.legacy = options["legacy"] || false;
|
|
1159
|
-
this.json = options["json"] || false;
|
|
1160
|
-
this.listener = options["listener"] || null;
|
|
1161
|
-
this.maxDepth = typeof options["maxDepth"] === "number" ? options["maxDepth"] : 100;
|
|
1162
|
-
this.maxMergeSeqLength = typeof options["maxMergeSeqLength"] === "number" ? options["maxMergeSeqLength"] : 20;
|
|
1163
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
1164
|
-
this.typeMap = this.schema.compiledTypeMap;
|
|
1165
|
-
this.length = input.length;
|
|
1166
|
-
this.position = 0;
|
|
1167
|
-
this.line = 0;
|
|
1168
|
-
this.lineStart = 0;
|
|
1169
|
-
this.lineIndent = 0;
|
|
1170
|
-
this.depth = 0;
|
|
1171
|
-
this.firstTabInLine = -1;
|
|
1172
|
-
this.documents = [];
|
|
1173
|
-
this.anchorMapTransactions = [];
|
|
1174
|
-
}
|
|
1175
|
-
function generateError(state, message) {
|
|
1176
|
-
const mark = {
|
|
1177
|
-
name: state.filename,
|
|
1178
|
-
buffer: state.input.slice(0, -1),
|
|
1179
|
-
position: state.position,
|
|
1180
|
-
line: state.line,
|
|
1181
|
-
column: state.position - state.lineStart
|
|
1182
|
-
};
|
|
1183
|
-
mark.snippet = makeSnippet(mark);
|
|
1184
|
-
return new YAMLException(message, mark);
|
|
1185
|
-
}
|
|
1186
|
-
function throwError(state, message) {
|
|
1187
|
-
throw generateError(state, message);
|
|
1188
|
-
}
|
|
1189
|
-
function throwWarning(state, message) {
|
|
1190
|
-
if (state.onWarning) state.onWarning.call(null, generateError(state, message));
|
|
1191
|
-
}
|
|
1192
|
-
function storeAnchor(state, name, value) {
|
|
1193
|
-
const transactions = state.anchorMapTransactions;
|
|
1194
|
-
if (transactions.length !== 0) {
|
|
1195
|
-
const transaction = transactions[transactions.length - 1];
|
|
1196
|
-
if (!_hasOwnProperty.call(transaction, name)) transaction[name] = {
|
|
1197
|
-
existed: _hasOwnProperty.call(state.anchorMap, name),
|
|
1198
|
-
value: state.anchorMap[name]
|
|
1199
|
-
};
|
|
1200
|
-
}
|
|
1201
|
-
state.anchorMap[name] = value;
|
|
1202
|
-
}
|
|
1203
|
-
function beginAnchorTransaction(state) {
|
|
1204
|
-
state.anchorMapTransactions.push(Object.create(null));
|
|
1205
|
-
}
|
|
1206
|
-
function commitAnchorTransaction(state) {
|
|
1207
|
-
const transaction = state.anchorMapTransactions.pop();
|
|
1208
|
-
const transactions = state.anchorMapTransactions;
|
|
1209
|
-
if (transactions.length === 0) return;
|
|
1210
|
-
const parent = transactions[transactions.length - 1];
|
|
1211
|
-
const names = Object.keys(transaction);
|
|
1212
|
-
for (let index = 0, length = names.length; index < length; index += 1) {
|
|
1213
|
-
const name = names[index];
|
|
1214
|
-
if (!_hasOwnProperty.call(parent, name)) parent[name] = transaction[name];
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
function rollbackAnchorTransaction(state) {
|
|
1218
|
-
const transaction = state.anchorMapTransactions.pop();
|
|
1219
|
-
const names = Object.keys(transaction);
|
|
1220
|
-
for (let index = names.length - 1; index >= 0; index -= 1) {
|
|
1221
|
-
const entry = transaction[names[index]];
|
|
1222
|
-
if (entry.existed) state.anchorMap[names[index]] = entry.value;
|
|
1223
|
-
else delete state.anchorMap[names[index]];
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
function snapshotState(state) {
|
|
1227
|
-
return {
|
|
1228
|
-
position: state.position,
|
|
1229
|
-
line: state.line,
|
|
1230
|
-
lineStart: state.lineStart,
|
|
1231
|
-
lineIndent: state.lineIndent,
|
|
1232
|
-
firstTabInLine: state.firstTabInLine,
|
|
1233
|
-
tag: state.tag,
|
|
1234
|
-
anchor: state.anchor,
|
|
1235
|
-
kind: state.kind,
|
|
1236
|
-
result: state.result
|
|
1237
|
-
};
|
|
1238
|
-
}
|
|
1239
|
-
function restoreState(state, snapshot) {
|
|
1240
|
-
state.position = snapshot.position;
|
|
1241
|
-
state.line = snapshot.line;
|
|
1242
|
-
state.lineStart = snapshot.lineStart;
|
|
1243
|
-
state.lineIndent = snapshot.lineIndent;
|
|
1244
|
-
state.firstTabInLine = snapshot.firstTabInLine;
|
|
1245
|
-
state.tag = snapshot.tag;
|
|
1246
|
-
state.anchor = snapshot.anchor;
|
|
1247
|
-
state.kind = snapshot.kind;
|
|
1248
|
-
state.result = snapshot.result;
|
|
1249
|
-
}
|
|
1250
|
-
var directiveHandlers = {
|
|
1251
|
-
YAML: function handleYamlDirective(state, name, args) {
|
|
1252
|
-
if (state.version !== null) throwError(state, "duplication of %YAML directive");
|
|
1253
|
-
if (args.length !== 1) throwError(state, "YAML directive accepts exactly one argument");
|
|
1254
|
-
const match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1255
|
-
if (match === null) throwError(state, "ill-formed argument of the YAML directive");
|
|
1256
|
-
const major = parseInt(match[1], 10);
|
|
1257
|
-
const minor = parseInt(match[2], 10);
|
|
1258
|
-
if (major !== 1) throwError(state, "unacceptable YAML version of the document");
|
|
1259
|
-
state.version = args[0];
|
|
1260
|
-
state.checkLineBreaks = minor < 2;
|
|
1261
|
-
if (minor !== 1 && minor !== 2) throwWarning(state, "unsupported YAML version of the document");
|
|
1262
|
-
},
|
|
1263
|
-
TAG: function handleTagDirective(state, name, args) {
|
|
1264
|
-
let prefix;
|
|
1265
|
-
if (args.length !== 2) throwError(state, "TAG directive accepts exactly two arguments");
|
|
1266
|
-
const handle = args[0];
|
|
1267
|
-
prefix = args[1];
|
|
1268
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1269
|
-
if (_hasOwnProperty.call(state.tagMap, handle)) throwError(state, "there is a previously declared suffix for \"" + handle + "\" tag handle");
|
|
1270
|
-
if (!PATTERN_TAG_URI.test(prefix)) throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1271
|
-
try {
|
|
1272
|
-
prefix = decodeURIComponent(prefix);
|
|
1273
|
-
} catch (err) {
|
|
1274
|
-
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1275
|
-
}
|
|
1276
|
-
state.tagMap[handle] = prefix;
|
|
1277
|
-
}
|
|
1278
|
-
};
|
|
1279
|
-
function captureSegment(state, start, end, checkJson) {
|
|
1280
|
-
if (start < end) {
|
|
1281
|
-
const _result = state.input.slice(start, end);
|
|
1282
|
-
if (checkJson) for (let _position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1283
|
-
const _character = _result.charCodeAt(_position);
|
|
1284
|
-
if (!(_character === 9 || _character >= 32 && _character <= 1114111)) throwError(state, "expected valid JSON character");
|
|
1285
|
-
}
|
|
1286
|
-
else if (PATTERN_NON_PRINTABLE.test(_result)) throwError(state, "the stream contains non-printable characters");
|
|
1287
|
-
state.result += _result;
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1290
|
-
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1291
|
-
if (!common.isObject(source)) throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1292
|
-
const sourceKeys = Object.keys(source);
|
|
1293
|
-
for (let index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1294
|
-
const key = sourceKeys[index];
|
|
1295
|
-
if (!_hasOwnProperty.call(destination, key)) {
|
|
1296
|
-
setProperty(destination, key, source[key]);
|
|
1297
|
-
overridableKeys[key] = true;
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1302
|
-
if (Array.isArray(keyNode)) {
|
|
1303
|
-
keyNode = Array.prototype.slice.call(keyNode);
|
|
1304
|
-
for (let index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1305
|
-
if (Array.isArray(keyNode[index])) throwError(state, "nested arrays are not supported inside keys");
|
|
1306
|
-
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") keyNode[index] = "[object Object]";
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") keyNode = "[object Object]";
|
|
1310
|
-
keyNode = String(keyNode);
|
|
1311
|
-
if (_result === null) _result = {};
|
|
1312
|
-
if (keyTag === "tag:yaml.org,2002:merge") if (Array.isArray(valueNode)) {
|
|
1313
|
-
if (valueNode.length > state.maxMergeSeqLength) throwError(state, "merge sequence length exceeded maxMergeSeqLength (" + state.maxMergeSeqLength + ")");
|
|
1314
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1315
|
-
for (let index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1316
|
-
const src = valueNode[index];
|
|
1317
|
-
if (seen.has(src)) continue;
|
|
1318
|
-
seen.add(src);
|
|
1319
|
-
mergeMappings(state, _result, src, overridableKeys);
|
|
1320
|
-
}
|
|
1321
|
-
} else mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1322
|
-
else {
|
|
1323
|
-
if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
|
|
1324
|
-
state.line = startLine || state.line;
|
|
1325
|
-
state.lineStart = startLineStart || state.lineStart;
|
|
1326
|
-
state.position = startPos || state.position;
|
|
1327
|
-
throwError(state, "duplicated mapping key");
|
|
1328
|
-
}
|
|
1329
|
-
setProperty(_result, keyNode, valueNode);
|
|
1330
|
-
delete overridableKeys[keyNode];
|
|
1331
|
-
}
|
|
1332
|
-
return _result;
|
|
1333
|
-
}
|
|
1334
|
-
function readLineBreak(state) {
|
|
1335
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1336
|
-
if (ch === 10) state.position++;
|
|
1337
|
-
else if (ch === 13) {
|
|
1338
|
-
state.position++;
|
|
1339
|
-
if (state.input.charCodeAt(state.position) === 10) state.position++;
|
|
1340
|
-
} else throwError(state, "a line break is expected");
|
|
1341
|
-
state.line += 1;
|
|
1342
|
-
state.lineStart = state.position;
|
|
1343
|
-
state.firstTabInLine = -1;
|
|
1344
|
-
}
|
|
1345
|
-
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1346
|
-
let lineBreaks = 0;
|
|
1347
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1348
|
-
while (ch !== 0) {
|
|
1349
|
-
while (isWhiteSpace(ch)) {
|
|
1350
|
-
if (ch === 9 && state.firstTabInLine === -1) state.firstTabInLine = state.position;
|
|
1351
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1352
|
-
}
|
|
1353
|
-
if (allowComments && ch === 35) do
|
|
1354
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1355
|
-
while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1356
|
-
if (isEol(ch)) {
|
|
1357
|
-
readLineBreak(state);
|
|
1358
|
-
ch = state.input.charCodeAt(state.position);
|
|
1359
|
-
lineBreaks++;
|
|
1360
|
-
state.lineIndent = 0;
|
|
1361
|
-
while (ch === 32) {
|
|
1362
|
-
state.lineIndent++;
|
|
1363
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1364
|
-
}
|
|
1365
|
-
} else break;
|
|
1366
|
-
}
|
|
1367
|
-
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) throwWarning(state, "deficient indentation");
|
|
1368
|
-
return lineBreaks;
|
|
1369
|
-
}
|
|
1370
|
-
function testDocumentSeparator(state) {
|
|
1371
|
-
let _position = state.position;
|
|
1372
|
-
let ch = state.input.charCodeAt(_position);
|
|
1373
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1374
|
-
_position += 3;
|
|
1375
|
-
ch = state.input.charCodeAt(_position);
|
|
1376
|
-
if (ch === 0 || isWsOrEol(ch)) return true;
|
|
1377
|
-
}
|
|
1378
|
-
return false;
|
|
1379
|
-
}
|
|
1380
|
-
function writeFoldedLines(state, count) {
|
|
1381
|
-
if (count === 1) state.result += " ";
|
|
1382
|
-
else if (count > 1) state.result += common.repeat("\n", count - 1);
|
|
1383
|
-
}
|
|
1384
|
-
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1385
|
-
let captureStart;
|
|
1386
|
-
let captureEnd;
|
|
1387
|
-
let hasPendingContent;
|
|
1388
|
-
let _line;
|
|
1389
|
-
let _lineStart;
|
|
1390
|
-
let _lineIndent;
|
|
1391
|
-
const _kind = state.kind;
|
|
1392
|
-
const _result = state.result;
|
|
1393
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1394
|
-
if (isWsOrEol(ch) || isFlowIndicator(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) return false;
|
|
1395
|
-
if (ch === 63 || ch === 45) {
|
|
1396
|
-
const following = state.input.charCodeAt(state.position + 1);
|
|
1397
|
-
if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) return false;
|
|
1398
|
-
}
|
|
1399
|
-
state.kind = "scalar";
|
|
1400
|
-
state.result = "";
|
|
1401
|
-
captureStart = captureEnd = state.position;
|
|
1402
|
-
hasPendingContent = false;
|
|
1403
|
-
while (ch !== 0) {
|
|
1404
|
-
if (ch === 58) {
|
|
1405
|
-
const following = state.input.charCodeAt(state.position + 1);
|
|
1406
|
-
if (isWsOrEol(following) || withinFlowCollection && isFlowIndicator(following)) break;
|
|
1407
|
-
} else if (ch === 35) {
|
|
1408
|
-
if (isWsOrEol(state.input.charCodeAt(state.position - 1))) break;
|
|
1409
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && isFlowIndicator(ch)) break;
|
|
1410
|
-
else if (isEol(ch)) {
|
|
1411
|
-
_line = state.line;
|
|
1412
|
-
_lineStart = state.lineStart;
|
|
1413
|
-
_lineIndent = state.lineIndent;
|
|
1414
|
-
skipSeparationSpace(state, false, -1);
|
|
1415
|
-
if (state.lineIndent >= nodeIndent) {
|
|
1416
|
-
hasPendingContent = true;
|
|
1417
|
-
ch = state.input.charCodeAt(state.position);
|
|
1418
|
-
continue;
|
|
1419
|
-
} else {
|
|
1420
|
-
state.position = captureEnd;
|
|
1421
|
-
state.line = _line;
|
|
1422
|
-
state.lineStart = _lineStart;
|
|
1423
|
-
state.lineIndent = _lineIndent;
|
|
1424
|
-
break;
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
if (hasPendingContent) {
|
|
1428
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1429
|
-
writeFoldedLines(state, state.line - _line);
|
|
1430
|
-
captureStart = captureEnd = state.position;
|
|
1431
|
-
hasPendingContent = false;
|
|
1432
|
-
}
|
|
1433
|
-
if (!isWhiteSpace(ch)) captureEnd = state.position + 1;
|
|
1434
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1435
|
-
}
|
|
1436
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1437
|
-
if (state.result) return true;
|
|
1438
|
-
state.kind = _kind;
|
|
1439
|
-
state.result = _result;
|
|
1440
|
-
return false;
|
|
1441
|
-
}
|
|
1442
|
-
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1443
|
-
let captureStart;
|
|
1444
|
-
let captureEnd;
|
|
1445
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1446
|
-
if (ch !== 39) return false;
|
|
1447
|
-
state.kind = "scalar";
|
|
1448
|
-
state.result = "";
|
|
1449
|
-
state.position++;
|
|
1450
|
-
captureStart = captureEnd = state.position;
|
|
1451
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 39) {
|
|
1452
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1453
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1454
|
-
if (ch === 39) {
|
|
1455
|
-
captureStart = state.position;
|
|
1456
|
-
state.position++;
|
|
1457
|
-
captureEnd = state.position;
|
|
1458
|
-
} else return true;
|
|
1459
|
-
} else if (isEol(ch)) {
|
|
1460
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1461
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1462
|
-
captureStart = captureEnd = state.position;
|
|
1463
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1464
|
-
else {
|
|
1465
|
-
state.position++;
|
|
1466
|
-
if (!isWhiteSpace(ch)) captureEnd = state.position;
|
|
1467
|
-
}
|
|
1468
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1469
|
-
}
|
|
1470
|
-
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1471
|
-
let captureStart;
|
|
1472
|
-
let captureEnd;
|
|
1473
|
-
let tmp;
|
|
1474
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1475
|
-
if (ch !== 34) return false;
|
|
1476
|
-
state.kind = "scalar";
|
|
1477
|
-
state.result = "";
|
|
1478
|
-
state.position++;
|
|
1479
|
-
captureStart = captureEnd = state.position;
|
|
1480
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) if (ch === 34) {
|
|
1481
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1482
|
-
state.position++;
|
|
1483
|
-
return true;
|
|
1484
|
-
} else if (ch === 92) {
|
|
1485
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1486
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1487
|
-
if (isEol(ch)) skipSeparationSpace(state, false, nodeIndent);
|
|
1488
|
-
else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1489
|
-
state.result += simpleEscapeMap[ch];
|
|
1490
|
-
state.position++;
|
|
1491
|
-
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1492
|
-
let hexLength = tmp;
|
|
1493
|
-
let hexResult = 0;
|
|
1494
|
-
for (; hexLength > 0; hexLength--) {
|
|
1495
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1496
|
-
if ((tmp = fromHexCode(ch)) >= 0) hexResult = (hexResult << 4) + tmp;
|
|
1497
|
-
else throwError(state, "expected hexadecimal character");
|
|
1498
|
-
}
|
|
1499
|
-
state.result += charFromCodepoint(hexResult);
|
|
1500
|
-
state.position++;
|
|
1501
|
-
} else throwError(state, "unknown escape sequence");
|
|
1502
|
-
captureStart = captureEnd = state.position;
|
|
1503
|
-
} else if (isEol(ch)) {
|
|
1504
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1505
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1506
|
-
captureStart = captureEnd = state.position;
|
|
1507
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1508
|
-
else {
|
|
1509
|
-
state.position++;
|
|
1510
|
-
if (!isWhiteSpace(ch)) captureEnd = state.position;
|
|
1511
|
-
}
|
|
1512
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1513
|
-
}
|
|
1514
|
-
function readFlowCollection(state, nodeIndent) {
|
|
1515
|
-
let readNext = true;
|
|
1516
|
-
let _line;
|
|
1517
|
-
let _lineStart;
|
|
1518
|
-
let _pos;
|
|
1519
|
-
const _tag = state.tag;
|
|
1520
|
-
let _result;
|
|
1521
|
-
const _anchor = state.anchor;
|
|
1522
|
-
let terminator;
|
|
1523
|
-
let isPair;
|
|
1524
|
-
let isExplicitPair;
|
|
1525
|
-
let isMapping;
|
|
1526
|
-
const overridableKeys = Object.create(null);
|
|
1527
|
-
let keyNode;
|
|
1528
|
-
let keyTag;
|
|
1529
|
-
let valueNode;
|
|
1530
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1531
|
-
if (ch === 91) {
|
|
1532
|
-
terminator = 93;
|
|
1533
|
-
isMapping = false;
|
|
1534
|
-
_result = [];
|
|
1535
|
-
} else if (ch === 123) {
|
|
1536
|
-
terminator = 125;
|
|
1537
|
-
isMapping = true;
|
|
1538
|
-
_result = {};
|
|
1539
|
-
} else return false;
|
|
1540
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
|
|
1541
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1542
|
-
while (ch !== 0) {
|
|
1543
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1544
|
-
ch = state.input.charCodeAt(state.position);
|
|
1545
|
-
if (ch === terminator) {
|
|
1546
|
-
state.position++;
|
|
1547
|
-
state.tag = _tag;
|
|
1548
|
-
state.anchor = _anchor;
|
|
1549
|
-
state.kind = isMapping ? "mapping" : "sequence";
|
|
1550
|
-
state.result = _result;
|
|
1551
|
-
return true;
|
|
1552
|
-
} else if (!readNext) throwError(state, "missed comma between flow collection entries");
|
|
1553
|
-
else if (ch === 44) throwError(state, "expected the node content, but found ','");
|
|
1554
|
-
keyTag = keyNode = valueNode = null;
|
|
1555
|
-
isPair = isExplicitPair = false;
|
|
1556
|
-
if (ch === 63) {
|
|
1557
|
-
if (isWsOrEol(state.input.charCodeAt(state.position + 1))) {
|
|
1558
|
-
isPair = isExplicitPair = true;
|
|
1559
|
-
state.position++;
|
|
1560
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
_line = state.line;
|
|
1564
|
-
_lineStart = state.lineStart;
|
|
1565
|
-
_pos = state.position;
|
|
1566
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1567
|
-
keyTag = state.tag;
|
|
1568
|
-
keyNode = state.result;
|
|
1569
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1570
|
-
ch = state.input.charCodeAt(state.position);
|
|
1571
|
-
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1572
|
-
isPair = true;
|
|
1573
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1574
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1575
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1576
|
-
valueNode = state.result;
|
|
1577
|
-
}
|
|
1578
|
-
if (isMapping) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1579
|
-
else if (isPair) _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1580
|
-
else _result.push(keyNode);
|
|
1581
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1582
|
-
ch = state.input.charCodeAt(state.position);
|
|
1583
|
-
if (ch === 44) {
|
|
1584
|
-
readNext = true;
|
|
1585
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1586
|
-
} else readNext = false;
|
|
1587
|
-
}
|
|
1588
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1589
|
-
}
|
|
1590
|
-
function readBlockScalar(state, nodeIndent) {
|
|
1591
|
-
let folding;
|
|
1592
|
-
let chomping = CHOMPING_CLIP;
|
|
1593
|
-
let didReadContent = false;
|
|
1594
|
-
let detectedIndent = false;
|
|
1595
|
-
let textIndent = nodeIndent;
|
|
1596
|
-
let emptyLines = 0;
|
|
1597
|
-
let atMoreIndented = false;
|
|
1598
|
-
let tmp;
|
|
1599
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1600
|
-
if (ch === 124) folding = false;
|
|
1601
|
-
else if (ch === 62) folding = true;
|
|
1602
|
-
else return false;
|
|
1603
|
-
state.kind = "scalar";
|
|
1604
|
-
state.result = "";
|
|
1605
|
-
while (ch !== 0) {
|
|
1606
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1607
|
-
if (ch === 43 || ch === 45) if (CHOMPING_CLIP === chomping) chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1608
|
-
else throwError(state, "repeat of a chomping mode identifier");
|
|
1609
|
-
else if ((tmp = fromDecimalCode(ch)) >= 0) if (tmp === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1610
|
-
else if (!detectedIndent) {
|
|
1611
|
-
textIndent = nodeIndent + tmp - 1;
|
|
1612
|
-
detectedIndent = true;
|
|
1613
|
-
} else throwError(state, "repeat of an indentation width identifier");
|
|
1614
|
-
else break;
|
|
1615
|
-
}
|
|
1616
|
-
if (isWhiteSpace(ch)) {
|
|
1617
|
-
do
|
|
1618
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1619
|
-
while (isWhiteSpace(ch));
|
|
1620
|
-
if (ch === 35) do
|
|
1621
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1622
|
-
while (!isEol(ch) && ch !== 0);
|
|
1623
|
-
}
|
|
1624
|
-
while (ch !== 0) {
|
|
1625
|
-
readLineBreak(state);
|
|
1626
|
-
state.lineIndent = 0;
|
|
1627
|
-
ch = state.input.charCodeAt(state.position);
|
|
1628
|
-
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1629
|
-
state.lineIndent++;
|
|
1630
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1631
|
-
}
|
|
1632
|
-
if (!detectedIndent && state.lineIndent > textIndent) textIndent = state.lineIndent;
|
|
1633
|
-
if (isEol(ch)) {
|
|
1634
|
-
emptyLines++;
|
|
1635
|
-
continue;
|
|
1636
|
-
}
|
|
1637
|
-
if (!detectedIndent && textIndent === 0) throwError(state, "missing indentation for block scalar");
|
|
1638
|
-
if (state.lineIndent < textIndent) {
|
|
1639
|
-
if (chomping === CHOMPING_KEEP) state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1640
|
-
else if (chomping === CHOMPING_CLIP) {
|
|
1641
|
-
if (didReadContent) state.result += "\n";
|
|
1642
|
-
}
|
|
1643
|
-
break;
|
|
1644
|
-
}
|
|
1645
|
-
if (folding) if (isWhiteSpace(ch)) {
|
|
1646
|
-
atMoreIndented = true;
|
|
1647
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1648
|
-
} else if (atMoreIndented) {
|
|
1649
|
-
atMoreIndented = false;
|
|
1650
|
-
state.result += common.repeat("\n", emptyLines + 1);
|
|
1651
|
-
} else if (emptyLines === 0) {
|
|
1652
|
-
if (didReadContent) state.result += " ";
|
|
1653
|
-
} else state.result += common.repeat("\n", emptyLines);
|
|
1654
|
-
else state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1655
|
-
didReadContent = true;
|
|
1656
|
-
detectedIndent = true;
|
|
1657
|
-
emptyLines = 0;
|
|
1658
|
-
const captureStart = state.position;
|
|
1659
|
-
while (!isEol(ch) && ch !== 0) ch = state.input.charCodeAt(++state.position);
|
|
1660
|
-
captureSegment(state, captureStart, state.position, false);
|
|
1661
|
-
}
|
|
1662
|
-
return true;
|
|
1663
|
-
}
|
|
1664
|
-
function readBlockSequence(state, nodeIndent) {
|
|
1665
|
-
const _tag = state.tag;
|
|
1666
|
-
const _anchor = state.anchor;
|
|
1667
|
-
const _result = [];
|
|
1668
|
-
let detected = false;
|
|
1669
|
-
if (state.firstTabInLine !== -1) return false;
|
|
1670
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
|
|
1671
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1672
|
-
while (ch !== 0) {
|
|
1673
|
-
if (state.firstTabInLine !== -1) {
|
|
1674
|
-
state.position = state.firstTabInLine;
|
|
1675
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1676
|
-
}
|
|
1677
|
-
if (ch !== 45) break;
|
|
1678
|
-
if (!isWsOrEol(state.input.charCodeAt(state.position + 1))) break;
|
|
1679
|
-
detected = true;
|
|
1680
|
-
state.position++;
|
|
1681
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1682
|
-
if (state.lineIndent <= nodeIndent) {
|
|
1683
|
-
_result.push(null);
|
|
1684
|
-
ch = state.input.charCodeAt(state.position);
|
|
1685
|
-
continue;
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
const _line = state.line;
|
|
1689
|
-
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1690
|
-
_result.push(state.result);
|
|
1691
|
-
skipSeparationSpace(state, true, -1);
|
|
1692
|
-
ch = state.input.charCodeAt(state.position);
|
|
1693
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a sequence entry");
|
|
1694
|
-
else if (state.lineIndent < nodeIndent) break;
|
|
1695
|
-
}
|
|
1696
|
-
if (detected) {
|
|
1697
|
-
state.tag = _tag;
|
|
1698
|
-
state.anchor = _anchor;
|
|
1699
|
-
state.kind = "sequence";
|
|
1700
|
-
state.result = _result;
|
|
1701
|
-
return true;
|
|
1702
|
-
}
|
|
1703
|
-
return false;
|
|
1704
|
-
}
|
|
1705
|
-
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1706
|
-
let allowCompact;
|
|
1707
|
-
let _keyLine;
|
|
1708
|
-
let _keyLineStart;
|
|
1709
|
-
let _keyPos;
|
|
1710
|
-
const _tag = state.tag;
|
|
1711
|
-
const _anchor = state.anchor;
|
|
1712
|
-
const _result = {};
|
|
1713
|
-
const overridableKeys = Object.create(null);
|
|
1714
|
-
let keyTag = null;
|
|
1715
|
-
let keyNode = null;
|
|
1716
|
-
let valueNode = null;
|
|
1717
|
-
let atExplicitKey = false;
|
|
1718
|
-
let detected = false;
|
|
1719
|
-
if (state.firstTabInLine !== -1) return false;
|
|
1720
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, _result);
|
|
1721
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1722
|
-
while (ch !== 0) {
|
|
1723
|
-
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1724
|
-
state.position = state.firstTabInLine;
|
|
1725
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1726
|
-
}
|
|
1727
|
-
const following = state.input.charCodeAt(state.position + 1);
|
|
1728
|
-
const _line = state.line;
|
|
1729
|
-
if ((ch === 63 || ch === 58) && isWsOrEol(following)) {
|
|
1730
|
-
if (ch === 63) {
|
|
1731
|
-
if (atExplicitKey) {
|
|
1732
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1733
|
-
keyTag = keyNode = valueNode = null;
|
|
1734
|
-
}
|
|
1735
|
-
detected = true;
|
|
1736
|
-
atExplicitKey = true;
|
|
1737
|
-
allowCompact = true;
|
|
1738
|
-
} else if (atExplicitKey) {
|
|
1739
|
-
atExplicitKey = false;
|
|
1740
|
-
allowCompact = true;
|
|
1741
|
-
} else throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1742
|
-
state.position += 1;
|
|
1743
|
-
ch = following;
|
|
1744
|
-
} else {
|
|
1745
|
-
_keyLine = state.line;
|
|
1746
|
-
_keyLineStart = state.lineStart;
|
|
1747
|
-
_keyPos = state.position;
|
|
1748
|
-
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) break;
|
|
1749
|
-
if (state.line === _line) {
|
|
1750
|
-
ch = state.input.charCodeAt(state.position);
|
|
1751
|
-
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
1752
|
-
if (ch === 58) {
|
|
1753
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1754
|
-
if (!isWsOrEol(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1755
|
-
if (atExplicitKey) {
|
|
1756
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1757
|
-
keyTag = keyNode = valueNode = null;
|
|
1758
|
-
}
|
|
1759
|
-
detected = true;
|
|
1760
|
-
atExplicitKey = false;
|
|
1761
|
-
allowCompact = false;
|
|
1762
|
-
keyTag = state.tag;
|
|
1763
|
-
keyNode = state.result;
|
|
1764
|
-
} else if (detected) throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1765
|
-
else {
|
|
1766
|
-
state.tag = _tag;
|
|
1767
|
-
state.anchor = _anchor;
|
|
1768
|
-
return true;
|
|
1769
|
-
}
|
|
1770
|
-
} else if (detected) throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1771
|
-
else {
|
|
1772
|
-
state.tag = _tag;
|
|
1773
|
-
state.anchor = _anchor;
|
|
1774
|
-
return true;
|
|
1775
|
-
}
|
|
1776
|
-
}
|
|
1777
|
-
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1778
|
-
if (atExplicitKey) {
|
|
1779
|
-
_keyLine = state.line;
|
|
1780
|
-
_keyLineStart = state.lineStart;
|
|
1781
|
-
_keyPos = state.position;
|
|
1782
|
-
}
|
|
1783
|
-
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) if (atExplicitKey) keyNode = state.result;
|
|
1784
|
-
else valueNode = state.result;
|
|
1785
|
-
if (!atExplicitKey) {
|
|
1786
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1787
|
-
keyTag = keyNode = valueNode = null;
|
|
1788
|
-
}
|
|
1789
|
-
skipSeparationSpace(state, true, -1);
|
|
1790
|
-
ch = state.input.charCodeAt(state.position);
|
|
1791
|
-
}
|
|
1792
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) throwError(state, "bad indentation of a mapping entry");
|
|
1793
|
-
else if (state.lineIndent < nodeIndent) break;
|
|
1794
|
-
}
|
|
1795
|
-
if (atExplicitKey) storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1796
|
-
if (detected) {
|
|
1797
|
-
state.tag = _tag;
|
|
1798
|
-
state.anchor = _anchor;
|
|
1799
|
-
state.kind = "mapping";
|
|
1800
|
-
state.result = _result;
|
|
1801
|
-
}
|
|
1802
|
-
return detected;
|
|
1803
|
-
}
|
|
1804
|
-
function readTagProperty(state) {
|
|
1805
|
-
let isVerbatim = false;
|
|
1806
|
-
let isNamed = false;
|
|
1807
|
-
let tagHandle;
|
|
1808
|
-
let tagName;
|
|
1809
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1810
|
-
if (ch !== 33) return false;
|
|
1811
|
-
if (state.tag !== null) throwError(state, "duplication of a tag property");
|
|
1812
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1813
|
-
if (ch === 60) {
|
|
1814
|
-
isVerbatim = true;
|
|
1815
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1816
|
-
} else if (ch === 33) {
|
|
1817
|
-
isNamed = true;
|
|
1818
|
-
tagHandle = "!!";
|
|
1819
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1820
|
-
} else tagHandle = "!";
|
|
1821
|
-
let _position = state.position;
|
|
1822
|
-
if (isVerbatim) {
|
|
1823
|
-
do
|
|
1824
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1825
|
-
while (ch !== 0 && ch !== 62);
|
|
1826
|
-
if (state.position < state.length) {
|
|
1827
|
-
tagName = state.input.slice(_position, state.position);
|
|
1828
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1829
|
-
} else throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1830
|
-
} else {
|
|
1831
|
-
while (ch !== 0 && !isWsOrEol(ch)) {
|
|
1832
|
-
if (ch === 33) if (!isNamed) {
|
|
1833
|
-
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1834
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) throwError(state, "named tag handle cannot contain such characters");
|
|
1835
|
-
isNamed = true;
|
|
1836
|
-
_position = state.position + 1;
|
|
1837
|
-
} else throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1838
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1839
|
-
}
|
|
1840
|
-
tagName = state.input.slice(_position, state.position);
|
|
1841
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1842
|
-
}
|
|
1843
|
-
if (tagName && !PATTERN_TAG_URI.test(tagName)) throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
1844
|
-
try {
|
|
1845
|
-
tagName = decodeURIComponent(tagName);
|
|
1846
|
-
} catch (err) {
|
|
1847
|
-
throwError(state, "tag name is malformed: " + tagName);
|
|
1848
|
-
}
|
|
1849
|
-
if (isVerbatim) state.tag = tagName;
|
|
1850
|
-
else if (_hasOwnProperty.call(state.tagMap, tagHandle)) state.tag = state.tagMap[tagHandle] + tagName;
|
|
1851
|
-
else if (tagHandle === "!") state.tag = "!" + tagName;
|
|
1852
|
-
else if (tagHandle === "!!") state.tag = "tag:yaml.org,2002:" + tagName;
|
|
1853
|
-
else throwError(state, "undeclared tag handle \"" + tagHandle + "\"");
|
|
1854
|
-
return true;
|
|
1855
|
-
}
|
|
1856
|
-
function readAnchorProperty(state) {
|
|
1857
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1858
|
-
if (ch !== 38) return false;
|
|
1859
|
-
if (state.anchor !== null) throwError(state, "duplication of an anchor property");
|
|
1860
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1861
|
-
const _position = state.position;
|
|
1862
|
-
while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
|
|
1863
|
-
if (state.position === _position) throwError(state, "name of an anchor node must contain at least one character");
|
|
1864
|
-
state.anchor = state.input.slice(_position, state.position);
|
|
1865
|
-
return true;
|
|
1866
|
-
}
|
|
1867
|
-
function readAlias(state) {
|
|
1868
|
-
let ch = state.input.charCodeAt(state.position);
|
|
1869
|
-
if (ch !== 42) return false;
|
|
1870
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1871
|
-
const _position = state.position;
|
|
1872
|
-
while (ch !== 0 && !isWsOrEol(ch) && !isFlowIndicator(ch)) ch = state.input.charCodeAt(++state.position);
|
|
1873
|
-
if (state.position === _position) throwError(state, "name of an alias node must contain at least one character");
|
|
1874
|
-
const alias = state.input.slice(_position, state.position);
|
|
1875
|
-
if (!_hasOwnProperty.call(state.anchorMap, alias)) throwError(state, "unidentified alias \"" + alias + "\"");
|
|
1876
|
-
state.result = state.anchorMap[alias];
|
|
1877
|
-
skipSeparationSpace(state, true, -1);
|
|
1878
|
-
return true;
|
|
1879
|
-
}
|
|
1880
|
-
function tryReadBlockMappingFromProperty(state, propertyStart, nodeIndent, flowIndent) {
|
|
1881
|
-
const fallbackState = snapshotState(state);
|
|
1882
|
-
beginAnchorTransaction(state);
|
|
1883
|
-
restoreState(state, propertyStart);
|
|
1884
|
-
state.tag = null;
|
|
1885
|
-
state.anchor = null;
|
|
1886
|
-
state.kind = null;
|
|
1887
|
-
state.result = null;
|
|
1888
|
-
if (readBlockMapping(state, nodeIndent, flowIndent) && state.kind === "mapping") {
|
|
1889
|
-
commitAnchorTransaction(state);
|
|
1890
|
-
return true;
|
|
1891
|
-
}
|
|
1892
|
-
rollbackAnchorTransaction(state);
|
|
1893
|
-
restoreState(state, fallbackState);
|
|
1894
|
-
return false;
|
|
1895
|
-
}
|
|
1896
|
-
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1897
|
-
let allowBlockScalars;
|
|
1898
|
-
let allowBlockCollections;
|
|
1899
|
-
let indentStatus = 1;
|
|
1900
|
-
let atNewLine = false;
|
|
1901
|
-
let hasContent = false;
|
|
1902
|
-
let propertyStart = null;
|
|
1903
|
-
let type;
|
|
1904
|
-
let flowIndent;
|
|
1905
|
-
let blockIndent;
|
|
1906
|
-
if (state.depth >= state.maxDepth) throwError(state, "nesting exceeded maxDepth (" + state.maxDepth + ")");
|
|
1907
|
-
state.depth += 1;
|
|
1908
|
-
if (state.listener !== null) state.listener("open", state);
|
|
1909
|
-
state.tag = null;
|
|
1910
|
-
state.anchor = null;
|
|
1911
|
-
state.kind = null;
|
|
1912
|
-
state.result = null;
|
|
1913
|
-
const allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
1914
|
-
if (allowToSeek) {
|
|
1915
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1916
|
-
atNewLine = true;
|
|
1917
|
-
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
1918
|
-
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
1919
|
-
else if (state.lineIndent < parentIndent) indentStatus = -1;
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
if (indentStatus === 1) while (true) {
|
|
1923
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1924
|
-
const propertyState = snapshotState(state);
|
|
1925
|
-
if (atNewLine && (ch === 33 && state.tag !== null || ch === 38 && state.anchor !== null)) break;
|
|
1926
|
-
if (!readTagProperty(state) && !readAnchorProperty(state)) break;
|
|
1927
|
-
if (propertyStart === null) propertyStart = propertyState;
|
|
1928
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1929
|
-
atNewLine = true;
|
|
1930
|
-
allowBlockCollections = allowBlockStyles;
|
|
1931
|
-
if (state.lineIndent > parentIndent) indentStatus = 1;
|
|
1932
|
-
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
1933
|
-
else if (state.lineIndent < parentIndent) indentStatus = -1;
|
|
1934
|
-
} else allowBlockCollections = false;
|
|
1935
|
-
}
|
|
1936
|
-
if (allowBlockCollections) allowBlockCollections = atNewLine || allowCompact;
|
|
1937
|
-
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1938
|
-
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) flowIndent = parentIndent;
|
|
1939
|
-
else flowIndent = parentIndent + 1;
|
|
1940
|
-
blockIndent = state.position - state.lineStart;
|
|
1941
|
-
if (indentStatus === 1) if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) hasContent = true;
|
|
1942
|
-
else {
|
|
1943
|
-
const ch = state.input.charCodeAt(state.position);
|
|
1944
|
-
if (propertyStart !== null && allowBlockStyles && !allowBlockCollections && ch !== 124 && ch !== 62 && tryReadBlockMappingFromProperty(state, propertyStart, propertyStart.position - propertyStart.lineStart, flowIndent)) hasContent = true;
|
|
1945
|
-
else if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) hasContent = true;
|
|
1946
|
-
else if (readAlias(state)) {
|
|
1947
|
-
hasContent = true;
|
|
1948
|
-
if (state.tag !== null || state.anchor !== null) throwError(state, "alias node should not have any properties");
|
|
1949
|
-
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1950
|
-
hasContent = true;
|
|
1951
|
-
if (state.tag === null) state.tag = "?";
|
|
1952
|
-
}
|
|
1953
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
|
|
1954
|
-
}
|
|
1955
|
-
else if (indentStatus === 0) hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
1956
|
-
}
|
|
1957
|
-
if (state.tag === null) {
|
|
1958
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
|
|
1959
|
-
} else if (state.tag === "?") {
|
|
1960
|
-
if (state.result !== null && state.kind !== "scalar") throwError(state, "unacceptable node kind for !<?> tag; it should be \"scalar\", not \"" + state.kind + "\"");
|
|
1961
|
-
for (let typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1962
|
-
type = state.implicitTypes[typeIndex];
|
|
1963
|
-
if (type.resolve(state.result)) {
|
|
1964
|
-
state.result = type.construct(state.result);
|
|
1965
|
-
state.tag = type.tag;
|
|
1966
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
|
|
1967
|
-
break;
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
} else if (state.tag !== "!") {
|
|
1971
|
-
if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) type = state.typeMap[state.kind || "fallback"][state.tag];
|
|
1972
|
-
else {
|
|
1973
|
-
type = null;
|
|
1974
|
-
const typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
1975
|
-
for (let typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
1976
|
-
type = typeList[typeIndex];
|
|
1977
|
-
break;
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
if (!type) throwError(state, "unknown tag !<" + state.tag + ">");
|
|
1981
|
-
if (state.result !== null && type.kind !== state.kind) throwError(state, "unacceptable node kind for !<" + state.tag + "> tag; it should be \"" + type.kind + "\", not \"" + state.kind + "\"");
|
|
1982
|
-
if (!type.resolve(state.result, state.tag)) throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
1983
|
-
else {
|
|
1984
|
-
state.result = type.construct(state.result, state.tag);
|
|
1985
|
-
if (state.anchor !== null) storeAnchor(state, state.anchor, state.result);
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
if (state.listener !== null) state.listener("close", state);
|
|
1989
|
-
state.depth -= 1;
|
|
1990
|
-
return state.tag !== null || state.anchor !== null || hasContent;
|
|
1991
|
-
}
|
|
1992
|
-
function readDocument(state) {
|
|
1993
|
-
const documentStart = state.position;
|
|
1994
|
-
let hasDirectives = false;
|
|
1995
|
-
let ch;
|
|
1996
|
-
state.version = null;
|
|
1997
|
-
state.checkLineBreaks = state.legacy;
|
|
1998
|
-
state.tagMap = Object.create(null);
|
|
1999
|
-
state.anchorMap = Object.create(null);
|
|
2000
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2001
|
-
skipSeparationSpace(state, true, -1);
|
|
2002
|
-
ch = state.input.charCodeAt(state.position);
|
|
2003
|
-
if (state.lineIndent > 0 || ch !== 37) break;
|
|
2004
|
-
hasDirectives = true;
|
|
2005
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2006
|
-
let _position = state.position;
|
|
2007
|
-
while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2008
|
-
const directiveName = state.input.slice(_position, state.position);
|
|
2009
|
-
const directiveArgs = [];
|
|
2010
|
-
if (directiveName.length < 1) throwError(state, "directive name must not be less than one character in length");
|
|
2011
|
-
while (ch !== 0) {
|
|
2012
|
-
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2013
|
-
if (ch === 35) {
|
|
2014
|
-
do
|
|
2015
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2016
|
-
while (ch !== 0 && !isEol(ch));
|
|
2017
|
-
break;
|
|
2018
|
-
}
|
|
2019
|
-
if (isEol(ch)) break;
|
|
2020
|
-
_position = state.position;
|
|
2021
|
-
while (ch !== 0 && !isWsOrEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2022
|
-
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2023
|
-
}
|
|
2024
|
-
if (ch !== 0) readLineBreak(state);
|
|
2025
|
-
if (_hasOwnProperty.call(directiveHandlers, directiveName)) directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2026
|
-
else throwWarning(state, "unknown document directive \"" + directiveName + "\"");
|
|
2027
|
-
}
|
|
2028
|
-
skipSeparationSpace(state, true, -1);
|
|
2029
|
-
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2030
|
-
state.position += 3;
|
|
2031
|
-
skipSeparationSpace(state, true, -1);
|
|
2032
|
-
} else if (hasDirectives) throwError(state, "directives end mark is expected");
|
|
2033
|
-
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2034
|
-
skipSeparationSpace(state, true, -1);
|
|
2035
|
-
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2036
|
-
state.documents.push(state.result);
|
|
2037
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2038
|
-
if (state.input.charCodeAt(state.position) === 46) {
|
|
2039
|
-
state.position += 3;
|
|
2040
|
-
skipSeparationSpace(state, true, -1);
|
|
2041
|
-
}
|
|
2042
|
-
return;
|
|
2043
|
-
}
|
|
2044
|
-
if (state.position < state.length - 1) throwError(state, "end of the stream or a document separator is expected");
|
|
2045
|
-
}
|
|
2046
|
-
function loadDocuments(input, options) {
|
|
2047
|
-
input = String(input);
|
|
2048
|
-
options = options || {};
|
|
2049
|
-
if (input.length !== 0) {
|
|
2050
|
-
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) input += "\n";
|
|
2051
|
-
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
2052
|
-
}
|
|
2053
|
-
const state = new State(input, options);
|
|
2054
|
-
const nullpos = input.indexOf("\0");
|
|
2055
|
-
if (nullpos !== -1) {
|
|
2056
|
-
state.position = nullpos;
|
|
2057
|
-
throwError(state, "null byte is not allowed in input");
|
|
2058
|
-
}
|
|
2059
|
-
state.input += "\0";
|
|
2060
|
-
while (state.input.charCodeAt(state.position) === 32) {
|
|
2061
|
-
state.lineIndent += 1;
|
|
2062
|
-
state.position += 1;
|
|
2063
|
-
}
|
|
2064
|
-
while (state.position < state.length - 1) readDocument(state);
|
|
2065
|
-
return state.documents;
|
|
2066
|
-
}
|
|
2067
|
-
function loadAll(input, iterator, options) {
|
|
2068
|
-
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2069
|
-
options = iterator;
|
|
2070
|
-
iterator = null;
|
|
2071
|
-
}
|
|
2072
|
-
const documents = loadDocuments(input, options);
|
|
2073
|
-
if (typeof iterator !== "function") return documents;
|
|
2074
|
-
for (let index = 0, length = documents.length; index < length; index += 1) iterator(documents[index]);
|
|
2075
|
-
}
|
|
2076
|
-
function load(input, options) {
|
|
2077
|
-
const documents = loadDocuments(input, options);
|
|
2078
|
-
if (documents.length === 0) return;
|
|
2079
|
-
else if (documents.length === 1) return documents[0];
|
|
2080
|
-
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2081
|
-
}
|
|
2082
|
-
module.exports.loadAll = loadAll;
|
|
2083
|
-
module.exports.load = load;
|
|
2084
|
-
}));
|
|
2085
|
-
var require_dumper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2086
|
-
var common = require_common();
|
|
2087
|
-
var YAMLException = require_exception();
|
|
2088
|
-
var DEFAULT_SCHEMA = require_default();
|
|
2089
|
-
var _toString = Object.prototype.toString;
|
|
2090
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2091
|
-
var CHAR_BOM = 65279;
|
|
2092
|
-
var CHAR_TAB = 9;
|
|
2093
|
-
var CHAR_LINE_FEED = 10;
|
|
2094
|
-
var CHAR_CARRIAGE_RETURN = 13;
|
|
2095
|
-
var CHAR_SPACE = 32;
|
|
2096
|
-
var CHAR_EXCLAMATION = 33;
|
|
2097
|
-
var CHAR_DOUBLE_QUOTE = 34;
|
|
2098
|
-
var CHAR_SHARP = 35;
|
|
2099
|
-
var CHAR_PERCENT = 37;
|
|
2100
|
-
var CHAR_AMPERSAND = 38;
|
|
2101
|
-
var CHAR_SINGLE_QUOTE = 39;
|
|
2102
|
-
var CHAR_ASTERISK = 42;
|
|
2103
|
-
var CHAR_COMMA = 44;
|
|
2104
|
-
var CHAR_MINUS = 45;
|
|
2105
|
-
var CHAR_COLON = 58;
|
|
2106
|
-
var CHAR_EQUALS = 61;
|
|
2107
|
-
var CHAR_GREATER_THAN = 62;
|
|
2108
|
-
var CHAR_QUESTION = 63;
|
|
2109
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
2110
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2111
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2112
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
2113
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2114
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
2115
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2116
|
-
var ESCAPE_SEQUENCES = {};
|
|
2117
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2118
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2119
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2120
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2121
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2122
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2123
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2124
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2125
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2126
|
-
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
2127
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2128
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2129
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2130
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2131
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2132
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2133
|
-
"y",
|
|
2134
|
-
"Y",
|
|
2135
|
-
"yes",
|
|
2136
|
-
"Yes",
|
|
2137
|
-
"YES",
|
|
2138
|
-
"on",
|
|
2139
|
-
"On",
|
|
2140
|
-
"ON",
|
|
2141
|
-
"n",
|
|
2142
|
-
"N",
|
|
2143
|
-
"no",
|
|
2144
|
-
"No",
|
|
2145
|
-
"NO",
|
|
2146
|
-
"off",
|
|
2147
|
-
"Off",
|
|
2148
|
-
"OFF"
|
|
2149
|
-
];
|
|
2150
|
-
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2151
|
-
function compileStyleMap(schema, map) {
|
|
2152
|
-
if (map === null) return {};
|
|
2153
|
-
const result = {};
|
|
2154
|
-
const keys = Object.keys(map);
|
|
2155
|
-
for (let index = 0, length = keys.length; index < length; index += 1) {
|
|
2156
|
-
let tag = keys[index];
|
|
2157
|
-
let style = String(map[tag]);
|
|
2158
|
-
if (tag.slice(0, 2) === "!!") tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2159
|
-
const type = schema.compiledTypeMap["fallback"][tag];
|
|
2160
|
-
if (type && _hasOwnProperty.call(type.styleAliases, style)) style = type.styleAliases[style];
|
|
2161
|
-
result[tag] = style;
|
|
2162
|
-
}
|
|
2163
|
-
return result;
|
|
2164
|
-
}
|
|
2165
|
-
function encodeHex(character) {
|
|
2166
|
-
let handle;
|
|
2167
|
-
let length;
|
|
2168
|
-
const string = character.toString(16).toUpperCase();
|
|
2169
|
-
if (character <= 255) {
|
|
2170
|
-
handle = "x";
|
|
2171
|
-
length = 2;
|
|
2172
|
-
} else if (character <= 65535) {
|
|
2173
|
-
handle = "u";
|
|
2174
|
-
length = 4;
|
|
2175
|
-
} else if (character <= 4294967295) {
|
|
2176
|
-
handle = "U";
|
|
2177
|
-
length = 8;
|
|
2178
|
-
} else throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2179
|
-
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2180
|
-
}
|
|
2181
|
-
var QUOTING_TYPE_SINGLE = 1;
|
|
2182
|
-
var QUOTING_TYPE_DOUBLE = 2;
|
|
2183
|
-
function State(options) {
|
|
2184
|
-
this.schema = options["schema"] || DEFAULT_SCHEMA;
|
|
2185
|
-
this.indent = Math.max(1, options["indent"] || 2);
|
|
2186
|
-
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2187
|
-
this.skipInvalid = options["skipInvalid"] || false;
|
|
2188
|
-
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2189
|
-
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2190
|
-
this.sortKeys = options["sortKeys"] || false;
|
|
2191
|
-
this.lineWidth = options["lineWidth"] || 80;
|
|
2192
|
-
this.noRefs = options["noRefs"] || false;
|
|
2193
|
-
this.noCompatMode = options["noCompatMode"] || false;
|
|
2194
|
-
this.condenseFlow = options["condenseFlow"] || false;
|
|
2195
|
-
this.quotingType = options["quotingType"] === "\"" ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2196
|
-
this.forceQuotes = options["forceQuotes"] || false;
|
|
2197
|
-
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2198
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
2199
|
-
this.explicitTypes = this.schema.compiledExplicit;
|
|
2200
|
-
this.tag = null;
|
|
2201
|
-
this.result = "";
|
|
2202
|
-
this.duplicates = [];
|
|
2203
|
-
this.usedDuplicates = null;
|
|
2204
|
-
}
|
|
2205
|
-
function indentString(string, spaces) {
|
|
2206
|
-
const ind = common.repeat(" ", spaces);
|
|
2207
|
-
let position = 0;
|
|
2208
|
-
let result = "";
|
|
2209
|
-
const length = string.length;
|
|
2210
|
-
while (position < length) {
|
|
2211
|
-
let line;
|
|
2212
|
-
const next = string.indexOf("\n", position);
|
|
2213
|
-
if (next === -1) {
|
|
2214
|
-
line = string.slice(position);
|
|
2215
|
-
position = length;
|
|
2216
|
-
} else {
|
|
2217
|
-
line = string.slice(position, next + 1);
|
|
2218
|
-
position = next + 1;
|
|
2219
|
-
}
|
|
2220
|
-
if (line.length && line !== "\n") result += ind;
|
|
2221
|
-
result += line;
|
|
2222
|
-
}
|
|
2223
|
-
return result;
|
|
2224
|
-
}
|
|
2225
|
-
function generateNextLine(state, level) {
|
|
2226
|
-
return "\n" + common.repeat(" ", state.indent * level);
|
|
2227
|
-
}
|
|
2228
|
-
function testImplicitResolving(state, str) {
|
|
2229
|
-
for (let index = 0, length = state.implicitTypes.length; index < length; index += 1) if (state.implicitTypes[index].resolve(str)) return true;
|
|
2230
|
-
return false;
|
|
2231
|
-
}
|
|
2232
|
-
function isWhitespace(c) {
|
|
2233
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2234
|
-
}
|
|
2235
|
-
function isPrintable(c) {
|
|
2236
|
-
return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
|
|
2237
|
-
}
|
|
2238
|
-
function isNsCharOrWhitespace(c) {
|
|
2239
|
-
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2240
|
-
}
|
|
2241
|
-
function isPlainSafe(c, prev, inblock) {
|
|
2242
|
-
const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2243
|
-
const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2244
|
-
return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar;
|
|
2245
|
-
}
|
|
2246
|
-
function isPlainSafeFirst(c) {
|
|
2247
|
-
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2248
|
-
}
|
|
2249
|
-
function isPlainSafeLast(c) {
|
|
2250
|
-
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2251
|
-
}
|
|
2252
|
-
function codePointAt(string, pos) {
|
|
2253
|
-
const first = string.charCodeAt(pos);
|
|
2254
|
-
let second;
|
|
2255
|
-
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2256
|
-
second = string.charCodeAt(pos + 1);
|
|
2257
|
-
if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2258
|
-
}
|
|
2259
|
-
return first;
|
|
2260
|
-
}
|
|
2261
|
-
function needIndentIndicator(string) {
|
|
2262
|
-
return /^\n* /.test(string);
|
|
2263
|
-
}
|
|
2264
|
-
var STYLE_PLAIN = 1;
|
|
2265
|
-
var STYLE_SINGLE = 2;
|
|
2266
|
-
var STYLE_LITERAL = 3;
|
|
2267
|
-
var STYLE_FOLDED = 4;
|
|
2268
|
-
var STYLE_DOUBLE = 5;
|
|
2269
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2270
|
-
let i;
|
|
2271
|
-
let char = 0;
|
|
2272
|
-
let prevChar = null;
|
|
2273
|
-
let hasLineBreak = false;
|
|
2274
|
-
let hasFoldableLine = false;
|
|
2275
|
-
const shouldTrackWidth = lineWidth !== -1;
|
|
2276
|
-
let previousLineBreak = -1;
|
|
2277
|
-
let plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2278
|
-
if (singleLineOnly || forceQuotes) for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2279
|
-
char = codePointAt(string, i);
|
|
2280
|
-
if (!isPrintable(char)) return STYLE_DOUBLE;
|
|
2281
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2282
|
-
prevChar = char;
|
|
2283
|
-
}
|
|
2284
|
-
else {
|
|
2285
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2286
|
-
char = codePointAt(string, i);
|
|
2287
|
-
if (char === CHAR_LINE_FEED) {
|
|
2288
|
-
hasLineBreak = true;
|
|
2289
|
-
if (shouldTrackWidth) {
|
|
2290
|
-
hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2291
|
-
previousLineBreak = i;
|
|
2292
|
-
}
|
|
2293
|
-
} else if (!isPrintable(char)) return STYLE_DOUBLE;
|
|
2294
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2295
|
-
prevChar = char;
|
|
2296
|
-
}
|
|
2297
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2298
|
-
}
|
|
2299
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2300
|
-
if (plain && !forceQuotes && !testAmbiguousType(string)) return STYLE_PLAIN;
|
|
2301
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2302
|
-
}
|
|
2303
|
-
if (indentPerLevel > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
|
|
2304
|
-
if (!forceQuotes) return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2305
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2306
|
-
}
|
|
2307
|
-
function writeScalar(state, string, level, iskey, inblock) {
|
|
2308
|
-
state.dump = function() {
|
|
2309
|
-
if (string.length === 0) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"\"" : "''";
|
|
2310
|
-
if (!state.noCompatMode) {
|
|
2311
|
-
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) return state.quotingType === QUOTING_TYPE_DOUBLE ? "\"" + string + "\"" : "'" + string + "'";
|
|
2312
|
-
}
|
|
2313
|
-
const indent = state.indent * Math.max(1, level);
|
|
2314
|
-
const lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2315
|
-
const singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2316
|
-
function testAmbiguity(string) {
|
|
2317
|
-
return testImplicitResolving(state, string);
|
|
2318
|
-
}
|
|
2319
|
-
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
2320
|
-
case STYLE_PLAIN: return string;
|
|
2321
|
-
case STYLE_SINGLE: return "'" + string.replace(/'/g, "''") + "'";
|
|
2322
|
-
case STYLE_LITERAL: return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2323
|
-
case STYLE_FOLDED: return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2324
|
-
case STYLE_DOUBLE: return "\"" + escapeString(string, lineWidth) + "\"";
|
|
2325
|
-
default: throw new YAMLException("impossible error: invalid scalar style");
|
|
2326
|
-
}
|
|
2327
|
-
}();
|
|
2328
|
-
}
|
|
2329
|
-
function blockHeader(string, indentPerLevel) {
|
|
2330
|
-
const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2331
|
-
const clip = string[string.length - 1] === "\n";
|
|
2332
|
-
return indentIndicator + (clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-") + "\n";
|
|
2333
|
-
}
|
|
2334
|
-
function dropEndingNewline(string) {
|
|
2335
|
-
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2336
|
-
}
|
|
2337
|
-
function foldString(string, width) {
|
|
2338
|
-
const lineRe = /(\n+)([^\n]*)/g;
|
|
2339
|
-
let result = function() {
|
|
2340
|
-
let nextLF = string.indexOf("\n");
|
|
2341
|
-
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2342
|
-
lineRe.lastIndex = nextLF;
|
|
2343
|
-
return foldLine(string.slice(0, nextLF), width);
|
|
2344
|
-
}();
|
|
2345
|
-
let prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2346
|
-
let moreIndented;
|
|
2347
|
-
let match;
|
|
2348
|
-
while (match = lineRe.exec(string)) {
|
|
2349
|
-
const prefix = match[1];
|
|
2350
|
-
const line = match[2];
|
|
2351
|
-
moreIndented = line[0] === " ";
|
|
2352
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2353
|
-
prevMoreIndented = moreIndented;
|
|
2354
|
-
}
|
|
2355
|
-
return result;
|
|
2356
|
-
}
|
|
2357
|
-
function foldLine(line, width) {
|
|
2358
|
-
if (line === "" || line[0] === " ") return line;
|
|
2359
|
-
const breakRe = / [^ ]/g;
|
|
2360
|
-
let match;
|
|
2361
|
-
let start = 0;
|
|
2362
|
-
let end;
|
|
2363
|
-
let curr = 0;
|
|
2364
|
-
let next = 0;
|
|
2365
|
-
let result = "";
|
|
2366
|
-
while (match = breakRe.exec(line)) {
|
|
2367
|
-
next = match.index;
|
|
2368
|
-
if (next - start > width) {
|
|
2369
|
-
end = curr > start ? curr : next;
|
|
2370
|
-
result += "\n" + line.slice(start, end);
|
|
2371
|
-
start = end + 1;
|
|
2372
|
-
}
|
|
2373
|
-
curr = next;
|
|
2374
|
-
}
|
|
2375
|
-
result += "\n";
|
|
2376
|
-
if (line.length - start > width && curr > start) result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2377
|
-
else result += line.slice(start);
|
|
2378
|
-
return result.slice(1);
|
|
2379
|
-
}
|
|
2380
|
-
function escapeString(string) {
|
|
2381
|
-
let result = "";
|
|
2382
|
-
let char = 0;
|
|
2383
|
-
for (let i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2384
|
-
char = codePointAt(string, i);
|
|
2385
|
-
const escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2386
|
-
if (!escapeSeq && isPrintable(char)) {
|
|
2387
|
-
result += string[i];
|
|
2388
|
-
if (char >= 65536) result += string[i + 1];
|
|
2389
|
-
} else result += escapeSeq || encodeHex(char);
|
|
2390
|
-
}
|
|
2391
|
-
return result;
|
|
2392
|
-
}
|
|
2393
|
-
function writeFlowSequence(state, level, object) {
|
|
2394
|
-
let _result = "";
|
|
2395
|
-
const _tag = state.tag;
|
|
2396
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
2397
|
-
let value = object[index];
|
|
2398
|
-
if (state.replacer) value = state.replacer.call(object, String(index), value);
|
|
2399
|
-
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2400
|
-
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
2401
|
-
_result += state.dump;
|
|
2402
|
-
}
|
|
2403
|
-
}
|
|
2404
|
-
state.tag = _tag;
|
|
2405
|
-
state.dump = "[" + _result + "]";
|
|
2406
|
-
}
|
|
2407
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
2408
|
-
let _result = "";
|
|
2409
|
-
const _tag = state.tag;
|
|
2410
|
-
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
2411
|
-
let value = object[index];
|
|
2412
|
-
if (state.replacer) value = state.replacer.call(object, String(index), value);
|
|
2413
|
-
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2414
|
-
if (!compact || _result !== "") _result += generateNextLine(state, level);
|
|
2415
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) _result += "-";
|
|
2416
|
-
else _result += "- ";
|
|
2417
|
-
_result += state.dump;
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
state.tag = _tag;
|
|
2421
|
-
state.dump = _result || "[]";
|
|
2422
|
-
}
|
|
2423
|
-
function writeFlowMapping(state, level, object) {
|
|
2424
|
-
let _result = "";
|
|
2425
|
-
const _tag = state.tag;
|
|
2426
|
-
const objectKeyList = Object.keys(object);
|
|
2427
|
-
for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2428
|
-
let pairBuffer = "";
|
|
2429
|
-
if (_result !== "") pairBuffer += ", ";
|
|
2430
|
-
if (state.condenseFlow) pairBuffer += "\"";
|
|
2431
|
-
const objectKey = objectKeyList[index];
|
|
2432
|
-
let objectValue = object[objectKey];
|
|
2433
|
-
if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2434
|
-
if (!writeNode(state, level, objectKey, false, false)) continue;
|
|
2435
|
-
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2436
|
-
pairBuffer += state.dump + (state.condenseFlow ? "\"" : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2437
|
-
if (!writeNode(state, level, objectValue, false, false)) continue;
|
|
2438
|
-
pairBuffer += state.dump;
|
|
2439
|
-
_result += pairBuffer;
|
|
2440
|
-
}
|
|
2441
|
-
state.tag = _tag;
|
|
2442
|
-
state.dump = "{" + _result + "}";
|
|
2443
|
-
}
|
|
2444
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
2445
|
-
let _result = "";
|
|
2446
|
-
const _tag = state.tag;
|
|
2447
|
-
const objectKeyList = Object.keys(object);
|
|
2448
|
-
if (state.sortKeys === true) objectKeyList.sort();
|
|
2449
|
-
else if (typeof state.sortKeys === "function") objectKeyList.sort(state.sortKeys);
|
|
2450
|
-
else if (state.sortKeys) throw new YAMLException("sortKeys must be a boolean or a function");
|
|
2451
|
-
for (let index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2452
|
-
let pairBuffer = "";
|
|
2453
|
-
if (!compact || _result !== "") pairBuffer += generateNextLine(state, level);
|
|
2454
|
-
const objectKey = objectKeyList[index];
|
|
2455
|
-
let objectValue = object[objectKey];
|
|
2456
|
-
if (state.replacer) objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2457
|
-
if (!writeNode(state, level + 1, objectKey, true, true, true)) continue;
|
|
2458
|
-
const explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2459
|
-
if (explicitPair) if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += "?";
|
|
2460
|
-
else pairBuffer += "? ";
|
|
2461
|
-
pairBuffer += state.dump;
|
|
2462
|
-
if (explicitPair) pairBuffer += generateNextLine(state, level);
|
|
2463
|
-
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) continue;
|
|
2464
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) pairBuffer += ":";
|
|
2465
|
-
else pairBuffer += ": ";
|
|
2466
|
-
pairBuffer += state.dump;
|
|
2467
|
-
_result += pairBuffer;
|
|
2468
|
-
}
|
|
2469
|
-
state.tag = _tag;
|
|
2470
|
-
state.dump = _result || "{}";
|
|
2471
|
-
}
|
|
2472
|
-
function detectType(state, object, explicit) {
|
|
2473
|
-
const typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2474
|
-
for (let index = 0, length = typeList.length; index < length; index += 1) {
|
|
2475
|
-
const type = typeList[index];
|
|
2476
|
-
if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
|
|
2477
|
-
if (explicit) if (type.multi && type.representName) state.tag = type.representName(object);
|
|
2478
|
-
else state.tag = type.tag;
|
|
2479
|
-
else state.tag = "?";
|
|
2480
|
-
if (type.represent) {
|
|
2481
|
-
const style = state.styleMap[type.tag] || type.defaultStyle;
|
|
2482
|
-
let _result;
|
|
2483
|
-
if (_toString.call(type.represent) === "[object Function]") _result = type.represent(object, style);
|
|
2484
|
-
else if (_hasOwnProperty.call(type.represent, style)) _result = type.represent[style](object, style);
|
|
2485
|
-
else throw new YAMLException("!<" + type.tag + "> tag resolver accepts not \"" + style + "\" style");
|
|
2486
|
-
state.dump = _result;
|
|
2487
|
-
}
|
|
2488
|
-
return true;
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
return false;
|
|
2492
|
-
}
|
|
2493
|
-
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2494
|
-
state.tag = null;
|
|
2495
|
-
state.dump = object;
|
|
2496
|
-
if (!detectType(state, object, false)) detectType(state, object, true);
|
|
2497
|
-
const type = _toString.call(state.dump);
|
|
2498
|
-
const inblock = block;
|
|
2499
|
-
if (block) block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2500
|
-
const objectOrArray = type === "[object Object]" || type === "[object Array]";
|
|
2501
|
-
let duplicateIndex;
|
|
2502
|
-
let duplicate;
|
|
2503
|
-
if (objectOrArray) {
|
|
2504
|
-
duplicateIndex = state.duplicates.indexOf(object);
|
|
2505
|
-
duplicate = duplicateIndex !== -1;
|
|
2506
|
-
}
|
|
2507
|
-
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) compact = false;
|
|
2508
|
-
if (duplicate && state.usedDuplicates[duplicateIndex]) state.dump = "*ref_" + duplicateIndex;
|
|
2509
|
-
else {
|
|
2510
|
-
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) state.usedDuplicates[duplicateIndex] = true;
|
|
2511
|
-
if (type === "[object Object]") if (block && Object.keys(state.dump).length !== 0) {
|
|
2512
|
-
writeBlockMapping(state, level, state.dump, compact);
|
|
2513
|
-
if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2514
|
-
} else {
|
|
2515
|
-
writeFlowMapping(state, level, state.dump);
|
|
2516
|
-
if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2517
|
-
}
|
|
2518
|
-
else if (type === "[object Array]") if (block && state.dump.length !== 0) {
|
|
2519
|
-
if (state.noArrayIndent && !isblockseq && level > 0) writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2520
|
-
else writeBlockSequence(state, level, state.dump, compact);
|
|
2521
|
-
if (duplicate) state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2522
|
-
} else {
|
|
2523
|
-
writeFlowSequence(state, level, state.dump);
|
|
2524
|
-
if (duplicate) state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2525
|
-
}
|
|
2526
|
-
else if (type === "[object String]") {
|
|
2527
|
-
if (state.tag !== "?") writeScalar(state, state.dump, level, iskey, inblock);
|
|
2528
|
-
} else if (type === "[object Undefined]") return false;
|
|
2529
|
-
else {
|
|
2530
|
-
if (state.skipInvalid) return false;
|
|
2531
|
-
throw new YAMLException("unacceptable kind of an object to dump " + type);
|
|
2532
|
-
}
|
|
2533
|
-
if (state.tag !== null && state.tag !== "?") {
|
|
2534
|
-
let tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
2535
|
-
if (state.tag[0] === "!") tagStr = "!" + tagStr;
|
|
2536
|
-
else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") tagStr = "!!" + tagStr.slice(18);
|
|
2537
|
-
else tagStr = "!<" + tagStr + ">";
|
|
2538
|
-
state.dump = tagStr + " " + state.dump;
|
|
2539
|
-
}
|
|
2540
|
-
}
|
|
2541
|
-
return true;
|
|
2542
|
-
}
|
|
2543
|
-
function getDuplicateReferences(object, state) {
|
|
2544
|
-
const objects = [];
|
|
2545
|
-
const duplicatesIndexes = [];
|
|
2546
|
-
inspectNode(object, objects, duplicatesIndexes);
|
|
2547
|
-
const length = duplicatesIndexes.length;
|
|
2548
|
-
for (let index = 0; index < length; index += 1) state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2549
|
-
state.usedDuplicates = new Array(length);
|
|
2550
|
-
}
|
|
2551
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2552
|
-
if (object !== null && typeof object === "object") {
|
|
2553
|
-
const index = objects.indexOf(object);
|
|
2554
|
-
if (index !== -1) {
|
|
2555
|
-
if (duplicatesIndexes.indexOf(index) === -1) duplicatesIndexes.push(index);
|
|
2556
|
-
} else {
|
|
2557
|
-
objects.push(object);
|
|
2558
|
-
if (Array.isArray(object)) for (let i = 0, length = object.length; i < length; i += 1) inspectNode(object[i], objects, duplicatesIndexes);
|
|
2559
|
-
else {
|
|
2560
|
-
const objectKeyList = Object.keys(object);
|
|
2561
|
-
for (let i = 0, length = objectKeyList.length; i < length; i += 1) inspectNode(object[objectKeyList[i]], objects, duplicatesIndexes);
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
}
|
|
2565
|
-
}
|
|
2566
|
-
function dump(input, options) {
|
|
2567
|
-
options = options || {};
|
|
2568
|
-
const state = new State(options);
|
|
2569
|
-
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2570
|
-
let value = input;
|
|
2571
|
-
if (state.replacer) value = state.replacer.call({ "": value }, "", value);
|
|
2572
|
-
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
2573
|
-
return "";
|
|
2574
|
-
}
|
|
2575
|
-
module.exports.dump = dump;
|
|
2576
|
-
}));
|
|
2577
|
-
var import_js_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2578
|
-
var loader = require_loader();
|
|
2579
|
-
var dumper = require_dumper();
|
|
2580
|
-
function renamed(from, to) {
|
|
2581
|
-
return function() {
|
|
2582
|
-
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
2583
|
-
};
|
|
2584
|
-
}
|
|
2585
|
-
module.exports.Type = require_type();
|
|
2586
|
-
module.exports.Schema = require_schema();
|
|
2587
|
-
module.exports.FAILSAFE_SCHEMA = require_failsafe();
|
|
2588
|
-
module.exports.JSON_SCHEMA = require_json();
|
|
2589
|
-
module.exports.CORE_SCHEMA = require_core();
|
|
2590
|
-
module.exports.DEFAULT_SCHEMA = require_default();
|
|
2591
|
-
module.exports.load = loader.load;
|
|
2592
|
-
module.exports.loadAll = loader.loadAll;
|
|
2593
|
-
module.exports.dump = dumper.dump;
|
|
2594
|
-
module.exports.YAMLException = require_exception();
|
|
2595
|
-
module.exports.types = {
|
|
2596
|
-
binary: require_binary(),
|
|
2597
|
-
float: require_float(),
|
|
2598
|
-
map: require_map(),
|
|
2599
|
-
null: require_null(),
|
|
2600
|
-
pairs: require_pairs(),
|
|
2601
|
-
set: require_set(),
|
|
2602
|
-
timestamp: require_timestamp(),
|
|
2603
|
-
bool: require_bool(),
|
|
2604
|
-
int: require_int(),
|
|
2605
|
-
merge: require_merge(),
|
|
2606
|
-
omap: require_omap(),
|
|
2607
|
-
seq: require_seq(),
|
|
2608
|
-
str: require_str()
|
|
2609
|
-
};
|
|
2610
|
-
module.exports.safeLoad = renamed("safeLoad", "load");
|
|
2611
|
-
module.exports.safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
2612
|
-
module.exports.safeDump = renamed("safeDump", "dump");
|
|
2613
|
-
})))(), 1);
|
|
2614
|
-
var { Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, load, loadAll, dump, YAMLException, types, safeLoad, safeLoadAll, safeDump } = import_js_yaml.default;
|
|
2615
|
-
import_js_yaml.default;
|
|
2616
|
-
//#endregion
|
|
2617
|
-
//#region ../evolution-core/src/skill-store.ts
|
|
2618
|
-
/**
|
|
2619
|
-
* Map a requesting session onto the two origin surfaces (rc.44 plan M2-2.3):
|
|
2620
|
-
* the APPROVAL surface treats every delegated subagent as the autonomous
|
|
2621
|
-
* review channel, while the LIBRARY surface keeps the Hermes distinction -
|
|
2622
|
-
* the review fork is 'background_review' (the pinned guard blocks its
|
|
2623
|
-
* writes) and any other subagent is 'subagent' (agent-authored, not
|
|
2624
|
-
* review-channel). `isReview` marks the caller as the background review
|
|
2625
|
-
* pipeline itself. Single source: the two tools and the review executor all
|
|
2626
|
-
* read this table instead of re-deriving it.
|
|
2627
|
-
*/
|
|
2628
|
-
function resolveOrigins(headerOrigin, isReview = false) {
|
|
2629
|
-
if (isReview) return {
|
|
2630
|
-
approval: "background_review",
|
|
2631
|
-
library: "background_review"
|
|
2632
|
-
};
|
|
2633
|
-
if (headerOrigin === "subagent") return {
|
|
2634
|
-
approval: "background_review",
|
|
2635
|
-
library: "subagent"
|
|
2636
|
-
};
|
|
2637
|
-
return {
|
|
2638
|
-
approval: "foreground",
|
|
2639
|
-
library: "foreground"
|
|
2640
|
-
};
|
|
2641
|
-
}
|
|
2642
|
-
//#endregion
|
|
3
|
+
import { resolveOrigins } from "@lmzhen/dsh-evolution-core";
|
|
2643
4
|
//#region lib/types/index.js
|
|
2644
5
|
/**
|
|
2645
6
|
* Model-facing memory tool and runtime-context memory snapshot.
|