dsh-eplan 0.0.0-stage → 0.14.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.
Files changed (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +219 -3
  3. package/cordis.patch.yml +182 -0
  4. package/docs/INSTALL.md +86 -0
  5. package/docs/LESSONS.md +224 -0
  6. package/docs/interfaces.md +183 -0
  7. package/docs/merged-skills/eplan-setup.md +63 -0
  8. package/docs/merged-skills/eplan-troubleshooting.md +149 -0
  9. package/icon.png +0 -0
  10. package/icon.svg +13 -0
  11. package/knowledge/KNOWLEDGE.md +413 -0
  12. package/knowledge/symbols/BP.png +0 -0
  13. package/knowledge/symbols/CDPST.png +0 -0
  14. package/knowledge/symbols/CO.png +0 -0
  15. package/knowledge/symbols/FA3.png +0 -0
  16. package/knowledge/symbols/TLRO.png +0 -0
  17. package/knowledge/symbols/TLRU.png +0 -0
  18. package/knowledge/symbols/TOUL.png +0 -0
  19. package/knowledge/symbols/TOUR.png +0 -0
  20. package/knowledge/symbols/manifest.json +91 -0
  21. package/locale/en.json +6 -0
  22. package/locale/zh.json +6 -0
  23. package/native/bridge/build.ps1 +73 -0
  24. package/native/bridge/src/Json.cs +383 -0
  25. package/native/bridge/src/Program.cs +1133 -0
  26. package/native/host/build.ps1 +74 -0
  27. package/native/host/src/ActionsTool.cs +225 -0
  28. package/native/host/src/BoxTool.cs +196 -0
  29. package/native/host/src/CheckTool.cs +186 -0
  30. package/native/host/src/Context.cs +169 -0
  31. package/native/host/src/DarkScheme.cs +111 -0
  32. package/native/host/src/DiagnoseTool.cs +115 -0
  33. package/native/host/src/Dispatcher.cs +51 -0
  34. package/native/host/src/DrawTool.cs +316 -0
  35. package/native/host/src/Entry.cs +111 -0
  36. package/native/host/src/ExportTool.cs +213 -0
  37. package/native/host/src/InspectTool.cs +367 -0
  38. package/native/host/src/KnowledgeTool.cs +166 -0
  39. package/native/host/src/LookTool.cs +257 -0
  40. package/native/host/src/OpLog.cs +289 -0
  41. package/native/host/src/PageCreateTool.cs +521 -0
  42. package/native/host/src/PageOpenTool.cs +62 -0
  43. package/native/host/src/PagesTool.cs +95 -0
  44. package/native/host/src/Paths.cs +91 -0
  45. package/native/host/src/PlacementEditTool.cs +234 -0
  46. package/native/host/src/ProbePropsTool.cs +152 -0
  47. package/native/host/src/ProjectCreateTool.cs +176 -0
  48. package/native/host/src/ProjectTool.cs +167 -0
  49. package/native/host/src/PropWriter.cs +70 -0
  50. package/native/host/src/PropsTool.cs +257 -0
  51. package/native/host/src/StatusTool.cs +168 -0
  52. package/native/host/src/SymbolInfoTool.cs +144 -0
  53. package/native/host/src/SymbolInsertTool.cs +261 -0
  54. package/native/host/src/SymbolsTool.cs +94 -0
  55. package/native/host/src/TagLocTool.cs +108 -0
  56. package/native/script/EplanMcpBootstrap.cs +221 -0
  57. package/native/script/build-symbol-gallery.mjs +231 -0
  58. package/native/script/prepare-install.ps1 +57 -0
  59. package/native/script/prune.mjs +132 -0
  60. package/native/script/verify-bootstrap.ps1 +62 -0
  61. package/package.json +53 -4
  62. package/preset/bootstrap.js +498 -0
  63. package/preset/experience-nudge.js +47 -0
  64. package/preset/image-budget.js +175 -0
  65. package/preset/knowledge-tool.js +180 -0
  66. package/preset/mcp-link.js +100 -0
  67. package/preset/prompt-surface.js +76 -0
  68. package/preset/restrict-tools.js +141 -0
  69. package/preset/skill-docs.js +181 -0
  70. package/preset/video-digest.js +294 -0
  71. package/preset/video-tool.js +92 -0
  72. package/server/compact.mjs +623 -0
  73. package/server/edit-args.mjs +67 -0
  74. package/server/fuzzy.mjs +57 -0
  75. package/server/launch-decision.mjs +26 -0
  76. package/server/measure.mjs +320 -0
  77. package/server/pdf.mjs +185 -0
  78. package/server/pdf2png.ps1 +99 -0
  79. package/server/server.mjs +3797 -0
  80. package/server/video.mjs +857 -0
  81. package/setup.mjs +223 -0
  82. package/skills/eplan-annotations/SKILL.md +55 -0
  83. package/skills/eplan-drawing/SKILL.md +206 -0
  84. package/skills/eplan-project/SKILL.md +41 -0
  85. package/skills/eplan-review/SKILL.md +80 -0
  86. package/skills/eplan-symbols/SKILL.md +142 -0
  87. package/test/check-docs.mjs +106 -0
  88. package/test/foreground.ps1 +21 -0
  89. package/test/smoke-all.mjs +229 -0
@@ -0,0 +1,383 @@
1
+ // 极简 JSON:桥接器和 EPLAN 内宿主共用。
2
+ //
3
+ // 为什么自己写:EPLAN 的 AppDomain 里不保证有 System.Web.Extensions,
4
+ // 而 .NET 自带的 DataContractJsonSerializer 在 C# 5 下用起来又太啰嗦。
5
+ // 这里只做本项目需要的事:对象、数组、字符串、数字、布尔、null。
6
+ using System;
7
+ using System.Collections.Generic;
8
+ using System.Globalization;
9
+ using System.Text;
10
+
11
+ namespace EplanMcp
12
+ {
13
+ public enum JsonKind { Null, Bool, Number, String, Array, Object }
14
+
15
+ public class JsonValue
16
+ {
17
+ public JsonKind Kind;
18
+ public bool BoolValue;
19
+ public double NumberValue;
20
+ public string StringValue;
21
+ public List<JsonValue> Items;
22
+ public Dictionary<string, JsonValue> Members;
23
+
24
+ public static JsonValue NewNull() { JsonValue v = new JsonValue(); v.Kind = JsonKind.Null; return v; }
25
+ public static JsonValue NewBool(bool b) { JsonValue v = new JsonValue(); v.Kind = JsonKind.Bool; v.BoolValue = b; return v; }
26
+ public static JsonValue NewNumber(double d) { JsonValue v = new JsonValue(); v.Kind = JsonKind.Number; v.NumberValue = d; return v; }
27
+ public static JsonValue NewString(string s)
28
+ {
29
+ JsonValue v = new JsonValue();
30
+ if (s == null) { v.Kind = JsonKind.Null; return v; }
31
+ v.Kind = JsonKind.String; v.StringValue = s; return v;
32
+ }
33
+ public static JsonValue NewObject()
34
+ {
35
+ JsonValue v = new JsonValue();
36
+ v.Kind = JsonKind.Object;
37
+ v.Members = new Dictionary<string, JsonValue>(StringComparer.Ordinal);
38
+ return v;
39
+ }
40
+ public static JsonValue NewArray()
41
+ {
42
+ JsonValue v = new JsonValue();
43
+ v.Kind = JsonKind.Array;
44
+ v.Items = new List<JsonValue>();
45
+ return v;
46
+ }
47
+
48
+ public bool IsNull { get { return Kind == JsonKind.Null; } }
49
+ public bool IsObject { get { return Kind == JsonKind.Object; } }
50
+ public bool IsArray { get { return Kind == JsonKind.Array; } }
51
+
52
+ /// <summary>缺省值:所有 As* 都返回各自的 fallback,链式取成员也不会抛。</summary>
53
+ private static readonly JsonValue Missing = NewNull();
54
+
55
+ /// <summary>
56
+ /// 取成员;不存在或不是对象时返回一个 Null 值对象(不是 C# null)。
57
+ ///
58
+ /// 返回嵌入的 null 而不是 C# null,是为了支持 args["filter"].AsString(null) 这种写法:
59
+ /// 写工具时少一层判空,也就少一类 NullReferenceException。这是踩过的坑——
60
+ /// PagesTool 里 args["filter"] 一开始就崩在这里。
61
+ /// </summary>
62
+ public JsonValue this[string key]
63
+ {
64
+ get
65
+ {
66
+ if (Kind != JsonKind.Object || Members == null) return Missing;
67
+ JsonValue v;
68
+ return Members.TryGetValue(key, out v) ? (v ?? Missing) : Missing;
69
+ }
70
+ set
71
+ {
72
+ if (Kind != JsonKind.Object) return;
73
+ Members[key] = value ?? Missing;
74
+ }
75
+ }
76
+
77
+
78
+ public JsonValue this[int index]
79
+ {
80
+ get
81
+ {
82
+ if (Kind != JsonKind.Array || Items == null) return Missing;
83
+ if (index < 0 || index >= Items.Count) return Missing;
84
+ return Items[index] ?? Missing;
85
+ }
86
+ }
87
+
88
+ public int Count
89
+ {
90
+ get
91
+ {
92
+ if (Kind == JsonKind.Array) return Items == null ? 0 : Items.Count;
93
+ if (Kind == JsonKind.Object) return Members == null ? 0 : Members.Count;
94
+ return 0;
95
+ }
96
+ }
97
+
98
+ public bool Has(string key) { return this[key] != null; }
99
+
100
+ public string AsString(string fallback)
101
+ {
102
+ if (Kind == JsonKind.String) return StringValue;
103
+ if (Kind == JsonKind.Number) return NumberValue.ToString(CultureInfo.InvariantCulture);
104
+ if (Kind == JsonKind.Bool) return BoolValue ? "true" : "false";
105
+ return fallback;
106
+ }
107
+
108
+ public double AsDouble(double fallback)
109
+ {
110
+ if (Kind == JsonKind.Number) return NumberValue;
111
+ if (Kind == JsonKind.String)
112
+ {
113
+ double d;
114
+ if (double.TryParse(StringValue, NumberStyles.Float, CultureInfo.InvariantCulture, out d)) return d;
115
+ }
116
+ return fallback;
117
+ }
118
+
119
+ public int AsInt(int fallback)
120
+ {
121
+ double d = AsDouble(double.NaN);
122
+ if (double.IsNaN(d)) return fallback;
123
+ return (int)Math.Round(d);
124
+ }
125
+
126
+ public bool AsBool(bool fallback)
127
+ {
128
+ if (Kind == JsonKind.Bool) return BoolValue;
129
+ if (Kind == JsonKind.String) return string.Equals(StringValue, "true", StringComparison.OrdinalIgnoreCase);
130
+ if (Kind == JsonKind.Number) return NumberValue != 0;
131
+ return fallback;
132
+ }
133
+
134
+ public void Add(JsonValue item)
135
+ {
136
+ if (Kind != JsonKind.Array) return;
137
+ Items.Add(item ?? NewNull());
138
+ }
139
+
140
+ public void Set(string key, JsonValue value)
141
+ {
142
+ if (Kind != JsonKind.Object) return;
143
+ Members[key] = value ?? NewNull();
144
+ }
145
+
146
+ public void Set(string key, string value) { Set(key, NewString(value)); }
147
+ public void Set(string key, double value) { Set(key, NewNumber(value)); }
148
+ public void Set(string key, int value) { Set(key, NewNumber(value)); }
149
+ public void Set(string key, bool value) { Set(key, NewBool(value)); }
150
+
151
+ public IEnumerable<string> Keys
152
+ {
153
+ get
154
+ {
155
+ if (Kind != JsonKind.Object || Members == null) return new string[0];
156
+ return Members.Keys;
157
+ }
158
+ }
159
+
160
+ public override string ToString() { return Json.Write(this); }
161
+ }
162
+
163
+ public static class Json
164
+ {
165
+ public static string Write(JsonValue value)
166
+ {
167
+ StringBuilder sb = new StringBuilder();
168
+ WriteValue(sb, value);
169
+ return sb.ToString();
170
+ }
171
+
172
+ private static void WriteValue(StringBuilder sb, JsonValue v)
173
+ {
174
+ if (v == null) { sb.Append("null"); return; }
175
+ switch (v.Kind)
176
+ {
177
+ case JsonKind.Null: sb.Append("null"); break;
178
+ case JsonKind.Bool: sb.Append(v.BoolValue ? "true" : "false"); break;
179
+ case JsonKind.Number:
180
+ double d = v.NumberValue;
181
+ if (double.IsNaN(d) || double.IsInfinity(d)) { sb.Append("null"); break; }
182
+ if (d == Math.Floor(d) && Math.Abs(d) < 1e15) sb.Append(((long)d).ToString(CultureInfo.InvariantCulture));
183
+ else sb.Append(d.ToString("R", CultureInfo.InvariantCulture));
184
+ break;
185
+ case JsonKind.String: WriteString(sb, v.StringValue); break;
186
+ case JsonKind.Array:
187
+ sb.Append('[');
188
+ if (v.Items != null)
189
+ {
190
+ for (int i = 0; i < v.Items.Count; i++)
191
+ {
192
+ if (i > 0) sb.Append(',');
193
+ WriteValue(sb, v.Items[i]);
194
+ }
195
+ }
196
+ sb.Append(']');
197
+ break;
198
+ case JsonKind.Object:
199
+ sb.Append('{');
200
+ if (v.Members != null)
201
+ {
202
+ bool first = true;
203
+ foreach (KeyValuePair<string, JsonValue> kv in v.Members)
204
+ {
205
+ if (!first) sb.Append(',');
206
+ first = false;
207
+ WriteString(sb, kv.Key);
208
+ sb.Append(':');
209
+ WriteValue(sb, kv.Value);
210
+ }
211
+ }
212
+ sb.Append('}');
213
+ break;
214
+ }
215
+ }
216
+
217
+ private static void WriteString(StringBuilder sb, string s)
218
+ {
219
+ if (s == null) { sb.Append("null"); return; }
220
+ sb.Append('"');
221
+ for (int i = 0; i < s.Length; i++)
222
+ {
223
+ char c = s[i];
224
+ switch (c)
225
+ {
226
+ case '"': sb.Append("\\\""); break;
227
+ case '\\': sb.Append("\\\\"); break;
228
+ case '\b': sb.Append("\\b"); break;
229
+ case '\f': sb.Append("\\f"); break;
230
+ case '\n': sb.Append("\\n"); break;
231
+ case '\r': sb.Append("\\r"); break;
232
+ case '\t': sb.Append("\\t"); break;
233
+ default:
234
+ if (c < 0x20 || c == '\u2028' || c == '\u2029')
235
+ {
236
+ sb.Append("\\u").Append(((int)c).ToString("x4", CultureInfo.InvariantCulture));
237
+ }
238
+ else sb.Append(c);
239
+ break;
240
+ }
241
+ }
242
+ sb.Append('"');
243
+ }
244
+
245
+ public static JsonValue Parse(string text)
246
+ {
247
+ if (text == null) throw new FormatException("JSON 文本为 null");
248
+ int i = 0;
249
+ JsonValue v = ParseValue(text, ref i);
250
+ SkipWs(text, ref i);
251
+ if (i < text.Length) throw new FormatException("JSON 结尾有多余内容,位置 " + i);
252
+ return v;
253
+ }
254
+
255
+ private static void SkipWs(string s, ref int i)
256
+ {
257
+ while (i < s.Length)
258
+ {
259
+ char c = s[i];
260
+ if (c == ' ' || c == '\t' || c == '\n' || c == '\r') { i++; continue; }
261
+ break;
262
+ }
263
+ }
264
+
265
+ private static JsonValue ParseValue(string s, ref int i)
266
+ {
267
+ SkipWs(s, ref i);
268
+ if (i >= s.Length) throw new FormatException("JSON 提前结束");
269
+ char c = s[i];
270
+ switch (c)
271
+ {
272
+ case '{': return ParseObject(s, ref i);
273
+ case '[': return ParseArray(s, ref i);
274
+ case '"': return JsonValue.NewString(ParseString(s, ref i));
275
+ case 't':
276
+ Expect(s, ref i, "true"); return JsonValue.NewBool(true);
277
+ case 'f':
278
+ Expect(s, ref i, "false"); return JsonValue.NewBool(false);
279
+ case 'n':
280
+ Expect(s, ref i, "null"); return JsonValue.NewNull();
281
+ default:
282
+ return ParseNumber(s, ref i);
283
+ }
284
+ }
285
+
286
+ private static void Expect(string s, ref int i, string literal)
287
+ {
288
+ if (i + literal.Length > s.Length || string.CompareOrdinal(s, i, literal, 0, literal.Length) != 0)
289
+ throw new FormatException("位置 " + i + " 处期待 " + literal);
290
+ i += literal.Length;
291
+ }
292
+
293
+ private static JsonValue ParseObject(string s, ref int i)
294
+ {
295
+ JsonValue obj = JsonValue.NewObject();
296
+ i++; // {
297
+ SkipWs(s, ref i);
298
+ if (i < s.Length && s[i] == '}') { i++; return obj; }
299
+ while (true)
300
+ {
301
+ SkipWs(s, ref i);
302
+ if (i >= s.Length || s[i] != '"') throw new FormatException("位置 " + i + " 处期待对象键");
303
+ string key = ParseString(s, ref i);
304
+ SkipWs(s, ref i);
305
+ if (i >= s.Length || s[i] != ':') throw new FormatException("位置 " + i + " 处期待 ':'");
306
+ i++;
307
+ obj.Members[key] = ParseValue(s, ref i);
308
+ SkipWs(s, ref i);
309
+ if (i >= s.Length) throw new FormatException("对象未闭合");
310
+ if (s[i] == ',') { i++; continue; }
311
+ if (s[i] == '}') { i++; return obj; }
312
+ throw new FormatException("位置 " + i + " 处期待 ',' 或 '}'");
313
+ }
314
+ }
315
+
316
+ private static JsonValue ParseArray(string s, ref int i)
317
+ {
318
+ JsonValue arr = JsonValue.NewArray();
319
+ i++; // [
320
+ SkipWs(s, ref i);
321
+ if (i < s.Length && s[i] == ']') { i++; return arr; }
322
+ while (true)
323
+ {
324
+ arr.Items.Add(ParseValue(s, ref i));
325
+ SkipWs(s, ref i);
326
+ if (i >= s.Length) throw new FormatException("数组未闭合");
327
+ if (s[i] == ',') { i++; continue; }
328
+ if (s[i] == ']') { i++; return arr; }
329
+ throw new FormatException("位置 " + i + " 处期待 ',' 或 ']'");
330
+ }
331
+ }
332
+
333
+ private static string ParseString(string s, ref int i)
334
+ {
335
+ StringBuilder sb = new StringBuilder();
336
+ i++; // "
337
+ while (i < s.Length)
338
+ {
339
+ char c = s[i++];
340
+ if (c == '"') return sb.ToString();
341
+ if (c != '\\') { sb.Append(c); continue; }
342
+ if (i >= s.Length) break;
343
+ char e = s[i++];
344
+ switch (e)
345
+ {
346
+ case '"': sb.Append('"'); break;
347
+ case '\\': sb.Append('\\'); break;
348
+ case '/': sb.Append('/'); break;
349
+ case 'b': sb.Append('\b'); break;
350
+ case 'f': sb.Append('\f'); break;
351
+ case 'n': sb.Append('\n'); break;
352
+ case 'r': sb.Append('\r'); break;
353
+ case 't': sb.Append('\t'); break;
354
+ case 'u':
355
+ if (i + 4 > s.Length) throw new FormatException("\\u 转义不完整");
356
+ sb.Append((char)int.Parse(s.Substring(i, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture));
357
+ i += 4;
358
+ break;
359
+ default: throw new FormatException("未知转义 \\" + e);
360
+ }
361
+ }
362
+ throw new FormatException("字符串未闭合");
363
+ }
364
+
365
+ private static JsonValue ParseNumber(string s, ref int i)
366
+ {
367
+ int start = i;
368
+ if (i < s.Length && (s[i] == '-' || s[i] == '+')) i++;
369
+ while (i < s.Length)
370
+ {
371
+ char c = s[i];
372
+ if ((c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-') { i++; continue; }
373
+ break;
374
+ }
375
+ if (i == start) throw new FormatException("位置 " + start + " 处期待值");
376
+ string token = s.Substring(start, i - start);
377
+ double d;
378
+ if (!double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out d))
379
+ throw new FormatException("无法解析数字: " + token);
380
+ return JsonValue.NewNumber(d);
381
+ }
382
+ }
383
+ }