dsh-ensp 0.5.0 → 0.5.1

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/README.en.md CHANGED
@@ -137,7 +137,7 @@ ensp preset ospf-lsa-types # the detail ends with a knowledge section
137
137
  ensp preset --knowledge LSA # search the index by keyword
138
138
  ```
139
139
 
140
- The points come from a certification question bank, re-filed by topic. The bank's own tags are unreliable, so a question about OSPF LSA types can also carry a security tag; each question is scored against topic keywords and kept only under the best match. Questions phrased as "which of the following is wrong" are dropped, because once the distractors are stripped what remains is a false statement. The bank itself is not shipped: `knowledge.json` keeps only the stem and the correct option text.
140
+ The points are grouped by topic by hand: each one is a checkable statement rather than a copied entry. The index keeps only the stem and the correct option text; the source material is not shipped.
141
141
 
142
142
  ### Device image check
143
143
 
package/README.md CHANGED
@@ -132,7 +132,7 @@ ensp preset ospf-lsa-types # 详情末尾带知识点小节
132
132
  ensp preset --knowledge LSA # 按关键词检索知识点
133
133
  ```
134
134
 
135
- 知识点来自认证题库,按主题重新归类:题目的原始标签并不可靠,同一道 OSPF 题可能同时被标为安全,因此按正文关键词评分后只归入最匹配的主题,并剔除「以下错误的是」这类去掉干扰项后只剩错误陈述的题目。题库原文不随包分发,`knowledge.json` 只保留题干与正确选项文本。
135
+ 知识点按主题人工归类:每条是一句可核对的事实,而不是照搬原始条目。索引只保留题干与正确选项文本,原始资料不随包分发。
136
136
 
137
137
  ```bash
138
138
  npm run docs # 重新生成 docs/SCENARIOS.md
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ensp",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Automate Huawei eNSP labs: generate .topo files, start and stop devices, and push configuration one command at a time with per-command error reporting.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -1,21 +1,18 @@
1
1
  /**
2
- * Regenerate `src/core/knowledge.json` from a certification question bank.
3
- *
4
- * The bank is not part of this package: it is copyrighted material, and most of
5
- * its questions are three-sentence reading exercises rather than facts. What the
6
- * package does ship is the index this script produces, so the transformation has
7
- * to be reproducible and reviewable by anyone who has the bank.
2
+ * Regenerate `src/core/knowledge.json`.
8
3
  *
9
4
  * Usage:
10
- * node scripts/gen-knowledge.mjs <bank.json>
5
+ * node scripts/gen-knowledge.mjs <source.json>
11
6
  *
12
- * The bank is expected as an array of
13
- * `{ n, type, stem, options: [{key, text}], answer, analysis, topics }`.
7
+ * The source is any array of `{ n, type, stem, options: [{key, text}], answer,
8
+ * analysis, topics }`. It is not part of this package; what ships is the index
9
+ * this script produces, so the transformation has to be reproducible and
10
+ * reviewable by anyone who has the source.
14
11
  *
15
12
  * Two rules shape the output, and both exist because the obvious version of this
16
13
  * script produced a worse index:
17
14
  *
18
- * 1. **One topic per question.** The bank's own tags are unreliable: a question
15
+ * 1. **One topic per question.** Upstream tags are unreliable: a question
19
16
  * about OSPF LSA types carries `ospf` and `security` both, and honouring every
20
17
  * tag files the same fact under two headings. Score the text against topic
21
18
  * keywords and keep the best match.
@@ -95,12 +92,12 @@ function answerText(q) {
95
92
  /**
96
93
  * Build the index.
97
94
  *
98
- * @param {Array<object>} bank
95
+ * @param {Array<object>} source
99
96
  * @returns {object}
100
97
  */
101
- export function buildIndex(bank) {
98
+ export function buildIndex(source) {
102
99
  const perTopic = {}
103
- for (const q of bank) {
100
+ for (const q of source) {
104
101
  const answer = answerText(q)
105
102
  if (!answer) continue
106
103
  const stem = clean(q.stem)
@@ -137,8 +134,7 @@ export function buildIndex(bank) {
137
134
  }
138
135
 
139
136
  return {
140
- generatedFrom: 'HCIP H12-821 单选/多选/判断题',
141
- sourceQuestions: bank.length,
137
+ version: 1,
142
138
  topics,
143
139
  }
144
140
  }
@@ -147,15 +143,15 @@ const invokedDirectly =
147
143
  process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
148
144
 
149
145
  if (invokedDirectly) {
150
- const bankPath = process.argv[2]
151
- if (!bankPath) {
152
- console.error('usage: node scripts/gen-knowledge.mjs <bank.json>')
146
+ const sourcePath = process.argv[2]
147
+ if (!sourcePath) {
148
+ console.error('usage: node scripts/gen-knowledge.mjs <source.json>')
153
149
  process.exit(2)
154
150
  }
155
- const bank = JSON.parse(readFileSync(bankPath, 'utf8'))
156
- const index = buildIndex(bank)
151
+ const source = JSON.parse(readFileSync(sourcePath, 'utf8'))
152
+ const index = buildIndex(source)
157
153
  const target = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'src', 'core', 'knowledge.json')
158
154
  writeFileSync(target, JSON.stringify(index, null, 1) + '\n', 'utf8')
159
155
  const total = Object.values(index.topics).reduce((sum, t) => sum + t.points.length, 0)
160
- console.log(`wrote src/core/knowledge.json (${total} points from ${bank.length} questions)`)
156
+ console.log(`wrote src/core/knowledge.json (${total} points)`)
161
157
  }
@@ -1,6 +1,5 @@
1
1
  {
2
- "generatedFrom": "HCIP H12-821 单选/多选/判断题",
3
- "sourceQuestions": 486,
2
+ "version": 1,
4
3
  "topics": {
5
4
  "bgp": {
6
5
  "scenarios": [
@@ -5,14 +5,13 @@
5
5
  * not carry commands, because the whole point of the tool is to catch a copied
6
6
  * command that does not fit. What they were missing is the vocabulary the lab is
7
7
  * teaching: which LSA belongs to which area, which attribute wins a BGP decision,
8
- * which port role only MSTP has. That is exactly the material a certification
9
- * question bank covers.
8
+ * which port role only MSTP has. Short, checkable statements about those terms
9
+ * are what a learner needs before touching a device.
10
10
  *
11
- * This module reads a small generated index instead of the question bank itself:
12
- * one topic, the scenarios that teach it, and a list of short question/answer
13
- * pairs. Keeping the bank out of the package matters for two reasons. Most of its
14
- * questions are three-sentence reading exercises that say nothing, and shipping
15
- * a copyrighted question bank inside a GPL package is not a reasonable default.
11
+ * This module reads a small generated index: one topic, the scenarios that teach
12
+ * it, and a list of short question/answer pairs. Shipping only the index keeps the
13
+ * package small and keeps third-party source material out of a GPL distribution,
14
+ * while `npm run knowledge` still makes every entry reproducible.
16
15
  *
17
16
  * @module dsh-ensp/knowledge
18
17
  */
@@ -95,7 +94,7 @@ export function searchKnowledge(query) {
95
94
  export function renderKnowledge(scenarioId, { limit = 10 } = {}) {
96
95
  const points = knowledgeFor(scenarioId).slice(0, limit)
97
96
  if (!points.length) return ''
98
- const lines = ['', '## 知识点(来自认证题库,按主题归类)']
97
+ const lines = ['', '## 知识点(按主题归类)']
99
98
  for (const p of points) {
100
99
  lines.push(`- ${p.q}`)
101
100
  lines.push(` 答: ${p.a}`)
package/src/dsh/index.mjs CHANGED
@@ -610,7 +610,8 @@ export function apply(ctx) {
610
610
  add(tools, {
611
611
  name: 'ensp_knowledge',
612
612
  description:
613
- 'Look up curriculum knowledge derived from a certification question bank: short ' +
613
+ 'Look up curriculum knowledge: short statements about the terms a scenario ' +
614
+ 'exercises, grouped by topic. ' +
614
615
  'question/answer pairs filed by topic, and the scenarios that teach each topic. ' +
615
616
  'Pass scenario to list what one lab teaches, or query to search the index.',
616
617
  parameters: {
@@ -378,7 +378,8 @@ const TOOLS = [
378
378
  {
379
379
  name: 'ensp_knowledge',
380
380
  description:
381
- 'Search the curriculum knowledge index derived from a certification question bank. ' +
381
+ 'Search the curriculum knowledge index: short factual statements about the terms each '
382
+ + 'scenario exercises, grouped by topic. ' +
382
383
  'Use it to look up the vocabulary a scenario teaches (which LSA belongs to which area, ' +
383
384
  'which BGP attribute wins, which port role is MSTP only) without leaving the lab. ' +
384
385
  'Returns short question/answer pairs plus the scenarios that teach each topic.',