@wowok/agent-mcp 2.4.3 → 2.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.
Files changed (317) hide show
  1. package/dist/config/runtime.d.ts +4 -0
  2. package/dist/config/runtime.js +29 -5
  3. package/dist/harness/auto-escalation.d.ts +27 -0
  4. package/dist/harness/auto-escalation.js +68 -0
  5. package/dist/index.js +21 -0
  6. package/dist/knowledge/allocation-confirm.d.ts +115 -0
  7. package/dist/knowledge/allocation-confirm.js +534 -0
  8. package/dist/knowledge/allocation-context.d.ts +58 -0
  9. package/dist/knowledge/allocation-context.js +249 -0
  10. package/dist/knowledge/allocation-ledger.d.ts +67 -0
  11. package/dist/knowledge/allocation-ledger.js +463 -0
  12. package/dist/knowledge/allocation-puzzle.d.ts +135 -0
  13. package/dist/knowledge/allocation-puzzle.js +298 -0
  14. package/dist/knowledge/allocation-risk.d.ts +78 -0
  15. package/dist/knowledge/allocation-risk.js +568 -0
  16. package/dist/knowledge/allocation-templates.d.ts +38 -0
  17. package/dist/knowledge/allocation-templates.js +970 -0
  18. package/dist/knowledge/allocation-translation.d.ts +72 -0
  19. package/dist/knowledge/allocation-translation.js +585 -0
  20. package/dist/knowledge/arb-risk.d.ts +37 -0
  21. package/dist/knowledge/arb-risk.js +210 -0
  22. package/dist/knowledge/arbitration-confirm.d.ts +135 -0
  23. package/dist/knowledge/arbitration-confirm.js +559 -0
  24. package/dist/knowledge/arbitration-context.d.ts +81 -0
  25. package/dist/knowledge/arbitration-context.js +505 -0
  26. package/dist/knowledge/arbitration-ledger.d.ts +62 -0
  27. package/dist/knowledge/arbitration-ledger.js +521 -0
  28. package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
  29. package/dist/knowledge/arbitration-puzzle.js +304 -0
  30. package/dist/knowledge/arbitration-risk.d.ts +112 -0
  31. package/dist/knowledge/arbitration-risk.js +433 -0
  32. package/dist/knowledge/arbitration-templates.d.ts +38 -0
  33. package/dist/knowledge/arbitration-templates.js +276 -0
  34. package/dist/knowledge/arbitration-translation.d.ts +91 -0
  35. package/dist/knowledge/arbitration-translation.js +487 -0
  36. package/dist/knowledge/bridge-risk.d.ts +36 -0
  37. package/dist/knowledge/bridge-risk.js +263 -0
  38. package/dist/knowledge/contact-risk.d.ts +32 -0
  39. package/dist/knowledge/contact-risk.js +200 -0
  40. package/dist/knowledge/demand-confirm.d.ts +32 -0
  41. package/dist/knowledge/demand-confirm.js +206 -0
  42. package/dist/knowledge/demand-risk.d.ts +30 -0
  43. package/dist/knowledge/demand-risk.js +240 -0
  44. package/dist/knowledge/demand-translation.d.ts +55 -0
  45. package/dist/knowledge/demand-translation.js +354 -0
  46. package/dist/knowledge/deployment-scanner.d.ts +63 -0
  47. package/dist/knowledge/deployment-scanner.js +762 -0
  48. package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
  49. package/dist/knowledge/examples-scanner-cli.js +26 -0
  50. package/dist/knowledge/examples-scanner.d.ts +121 -0
  51. package/dist/knowledge/examples-scanner.js +825 -0
  52. package/dist/knowledge/flywheel-loop.d.ts +3 -0
  53. package/dist/knowledge/flywheel-loop.js +32 -3
  54. package/dist/knowledge/glossary.js +3 -1
  55. package/dist/knowledge/guard-confirm.d.ts +86 -0
  56. package/dist/knowledge/guard-confirm.js +406 -0
  57. package/dist/knowledge/guard-context.d.ts +56 -0
  58. package/dist/knowledge/guard-context.js +287 -0
  59. package/dist/knowledge/guard-design-patterns.d.ts +37 -0
  60. package/dist/knowledge/guard-design-patterns.js +257 -0
  61. package/dist/knowledge/guard-puzzle.js +3 -2
  62. package/dist/knowledge/guard-risk.d.ts +1 -1
  63. package/dist/knowledge/guard-risk.js +12 -14
  64. package/dist/knowledge/guard-templates.js +1 -1
  65. package/dist/knowledge/guard-translation.js +6 -5
  66. package/dist/knowledge/index.d.ts +342 -0
  67. package/dist/knowledge/index.js +344 -0
  68. package/dist/knowledge/machine-confirm.d.ts +102 -0
  69. package/dist/knowledge/machine-confirm.js +559 -0
  70. package/dist/knowledge/machine-context.d.ts +160 -0
  71. package/dist/knowledge/machine-context.js +812 -0
  72. package/dist/knowledge/machine-ledger.d.ts +41 -0
  73. package/dist/knowledge/machine-ledger.js +315 -0
  74. package/dist/knowledge/machine-puzzle.d.ts +206 -0
  75. package/dist/knowledge/machine-puzzle.js +494 -0
  76. package/dist/knowledge/machine-risk.d.ts +75 -0
  77. package/dist/knowledge/machine-risk.js +644 -0
  78. package/dist/knowledge/machine-templates.d.ts +92 -0
  79. package/dist/knowledge/machine-templates.js +1592 -0
  80. package/dist/knowledge/machine-topology.d.ts +57 -0
  81. package/dist/knowledge/machine-topology.js +234 -0
  82. package/dist/knowledge/machine-translation.d.ts +96 -0
  83. package/dist/knowledge/machine-translation.js +513 -0
  84. package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
  85. package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
  86. package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
  87. package/dist/knowledge/mcp-schema-audit.js +772 -0
  88. package/dist/knowledge/onchain-constants.d.ts +4 -0
  89. package/dist/knowledge/onchain-constants.js +35 -0
  90. package/dist/knowledge/order-confirm.d.ts +115 -0
  91. package/dist/knowledge/order-confirm.js +573 -0
  92. package/dist/knowledge/order-context.d.ts +66 -0
  93. package/dist/knowledge/order-context.js +390 -0
  94. package/dist/knowledge/order-ledger.d.ts +69 -0
  95. package/dist/knowledge/order-ledger.js +341 -0
  96. package/dist/knowledge/order-puzzle.d.ts +159 -0
  97. package/dist/knowledge/order-puzzle.js +255 -0
  98. package/dist/knowledge/order-risk.d.ts +66 -0
  99. package/dist/knowledge/order-risk.js +653 -0
  100. package/dist/knowledge/order-templates.d.ts +50 -0
  101. package/dist/knowledge/order-templates.js +368 -0
  102. package/dist/knowledge/order-translation.d.ts +78 -0
  103. package/dist/knowledge/order-translation.js +550 -0
  104. package/dist/knowledge/passport-confirm.d.ts +130 -0
  105. package/dist/knowledge/passport-confirm.js +531 -0
  106. package/dist/knowledge/passport-context.d.ts +59 -0
  107. package/dist/knowledge/passport-context.js +306 -0
  108. package/dist/knowledge/passport-ledger.d.ts +48 -0
  109. package/dist/knowledge/passport-ledger.js +282 -0
  110. package/dist/knowledge/passport-puzzle.d.ts +108 -0
  111. package/dist/knowledge/passport-puzzle.js +333 -0
  112. package/dist/knowledge/passport-risk.d.ts +70 -0
  113. package/dist/knowledge/passport-risk.js +450 -0
  114. package/dist/knowledge/passport-templates.d.ts +40 -0
  115. package/dist/knowledge/passport-templates.js +568 -0
  116. package/dist/knowledge/passport-translation.d.ts +68 -0
  117. package/dist/knowledge/passport-translation.js +516 -0
  118. package/dist/knowledge/payment-risk.d.ts +33 -0
  119. package/dist/knowledge/payment-risk.js +182 -0
  120. package/dist/knowledge/permission-confirm.d.ts +110 -0
  121. package/dist/knowledge/permission-confirm.js +426 -0
  122. package/dist/knowledge/permission-context.d.ts +58 -0
  123. package/dist/knowledge/permission-context.js +224 -0
  124. package/dist/knowledge/permission-ledger.d.ts +38 -0
  125. package/dist/knowledge/permission-ledger.js +403 -0
  126. package/dist/knowledge/permission-puzzle.d.ts +122 -0
  127. package/dist/knowledge/permission-puzzle.js +173 -0
  128. package/dist/knowledge/permission-risk.d.ts +76 -0
  129. package/dist/knowledge/permission-risk.js +411 -0
  130. package/dist/knowledge/permission-templates.d.ts +38 -0
  131. package/dist/knowledge/permission-templates.js +234 -0
  132. package/dist/knowledge/permission-translation.d.ts +57 -0
  133. package/dist/knowledge/permission-translation.js +350 -0
  134. package/dist/knowledge/personal-risk.d.ts +36 -0
  135. package/dist/knowledge/personal-risk.js +212 -0
  136. package/dist/knowledge/progress-confirm.d.ts +108 -0
  137. package/dist/knowledge/progress-confirm.js +456 -0
  138. package/dist/knowledge/progress-context.d.ts +123 -0
  139. package/dist/knowledge/progress-context.js +452 -0
  140. package/dist/knowledge/progress-ledger.d.ts +63 -0
  141. package/dist/knowledge/progress-ledger.js +327 -0
  142. package/dist/knowledge/progress-puzzle.d.ts +82 -0
  143. package/dist/knowledge/progress-puzzle.js +219 -0
  144. package/dist/knowledge/progress-risk.d.ts +74 -0
  145. package/dist/knowledge/progress-risk.js +461 -0
  146. package/dist/knowledge/progress-templates.d.ts +38 -0
  147. package/dist/knowledge/progress-templates.js +228 -0
  148. package/dist/knowledge/progress-translation.d.ts +52 -0
  149. package/dist/knowledge/progress-translation.js +401 -0
  150. package/dist/knowledge/proof-confirm.d.ts +31 -0
  151. package/dist/knowledge/proof-confirm.js +187 -0
  152. package/dist/knowledge/proof-risk.d.ts +33 -0
  153. package/dist/knowledge/proof-risk.js +207 -0
  154. package/dist/knowledge/proof-translation.d.ts +52 -0
  155. package/dist/knowledge/proof-translation.js +283 -0
  156. package/dist/knowledge/registrar-risk.d.ts +34 -0
  157. package/dist/knowledge/registrar-risk.js +217 -0
  158. package/dist/knowledge/repository-confirm.d.ts +36 -0
  159. package/dist/knowledge/repository-confirm.js +242 -0
  160. package/dist/knowledge/repository-risk.d.ts +40 -0
  161. package/dist/knowledge/repository-risk.js +312 -0
  162. package/dist/knowledge/repository-translation.d.ts +58 -0
  163. package/dist/knowledge/repository-translation.js +422 -0
  164. package/dist/knowledge/resource-risk.d.ts +32 -0
  165. package/dist/knowledge/resource-risk.js +157 -0
  166. package/dist/knowledge/reward-confirm.d.ts +113 -0
  167. package/dist/knowledge/reward-confirm.js +496 -0
  168. package/dist/knowledge/reward-context.d.ts +127 -0
  169. package/dist/knowledge/reward-context.js +504 -0
  170. package/dist/knowledge/reward-ledger.d.ts +96 -0
  171. package/dist/knowledge/reward-ledger.js +502 -0
  172. package/dist/knowledge/reward-puzzle.d.ts +97 -0
  173. package/dist/knowledge/reward-puzzle.js +288 -0
  174. package/dist/knowledge/reward-risk.d.ts +84 -0
  175. package/dist/knowledge/reward-risk.js +545 -0
  176. package/dist/knowledge/reward-translation.d.ts +58 -0
  177. package/dist/knowledge/reward-translation.js +501 -0
  178. package/dist/knowledge/safety-rules.js +11 -3
  179. package/dist/knowledge/scenario-modes.d.ts +53 -0
  180. package/dist/knowledge/scenario-modes.js +302 -0
  181. package/dist/knowledge/service-confirm.d.ts +152 -0
  182. package/dist/knowledge/service-confirm.js +699 -0
  183. package/dist/knowledge/service-context.d.ts +66 -0
  184. package/dist/knowledge/service-context.js +403 -0
  185. package/dist/knowledge/service-ledger.d.ts +71 -0
  186. package/dist/knowledge/service-ledger.js +609 -0
  187. package/dist/knowledge/service-puzzle.d.ts +158 -0
  188. package/dist/knowledge/service-puzzle.js +236 -0
  189. package/dist/knowledge/service-risk.d.ts +108 -0
  190. package/dist/knowledge/service-risk.js +615 -0
  191. package/dist/knowledge/service-templates.d.ts +39 -0
  192. package/dist/knowledge/service-templates.js +418 -0
  193. package/dist/knowledge/service-translation.d.ts +103 -0
  194. package/dist/knowledge/service-translation.js +622 -0
  195. package/dist/knowledge/tools-reference.d.ts +17 -0
  196. package/dist/knowledge/tools-reference.js +151 -0
  197. package/dist/knowledge/treasury-confirm.d.ts +133 -0
  198. package/dist/knowledge/treasury-confirm.js +512 -0
  199. package/dist/knowledge/treasury-context.d.ts +64 -0
  200. package/dist/knowledge/treasury-context.js +363 -0
  201. package/dist/knowledge/treasury-ledger.d.ts +42 -0
  202. package/dist/knowledge/treasury-ledger.js +300 -0
  203. package/dist/knowledge/treasury-puzzle.d.ts +163 -0
  204. package/dist/knowledge/treasury-puzzle.js +216 -0
  205. package/dist/knowledge/treasury-risk.d.ts +86 -0
  206. package/dist/knowledge/treasury-risk.js +440 -0
  207. package/dist/knowledge/treasury-templates.d.ts +38 -0
  208. package/dist/knowledge/treasury-templates.js +316 -0
  209. package/dist/knowledge/treasury-translation.d.ts +78 -0
  210. package/dist/knowledge/treasury-translation.js +498 -0
  211. package/dist/knowledge/util-risk.d.ts +30 -0
  212. package/dist/knowledge/util-risk.js +135 -0
  213. package/dist/project/business-puzzle.d.ts +47 -0
  214. package/dist/project/business-puzzle.js +372 -0
  215. package/dist/project/deployment-doc.d.ts +61 -0
  216. package/dist/project/deployment-doc.js +432 -0
  217. package/dist/project/risk-aggregator.d.ts +50 -0
  218. package/dist/project/risk-aggregator.js +280 -0
  219. package/dist/project/substep-trace.d.ts +130 -0
  220. package/dist/project/substep-trace.js +332 -0
  221. package/dist/schema/call/allocation.d.ts +34 -34
  222. package/dist/schema/call/arbitration.d.ts +141 -141
  223. package/dist/schema/call/base.d.ts +386 -386
  224. package/dist/schema/call/base.js +3 -3
  225. package/dist/schema/call/bridge-handler.d.ts +5 -2
  226. package/dist/schema/call/bridge.d.ts +159 -159
  227. package/dist/schema/call/contact.d.ts +110 -110
  228. package/dist/schema/call/demand.d.ts +76 -76
  229. package/dist/schema/call/handler.d.ts +2 -3
  230. package/dist/schema/call/handler.js +1 -1
  231. package/dist/schema/call/machine.d.ts +58 -58
  232. package/dist/schema/call/order.d.ts +98 -110
  233. package/dist/schema/call/permission-handler.d.ts +5 -0
  234. package/dist/schema/call/permission-handler.js +54 -0
  235. package/dist/schema/call/permission.d.ts +108 -108
  236. package/dist/schema/call/personal.d.ts +14 -14
  237. package/dist/schema/call/progress.d.ts +57 -72
  238. package/dist/schema/call/progress.js +7 -4
  239. package/dist/schema/call/proof.d.ts +18 -18
  240. package/dist/schema/call/proof.js +12 -7
  241. package/dist/schema/call/repository.d.ts +154 -154
  242. package/dist/schema/call/reward.d.ts +55 -55
  243. package/dist/schema/call/service.d.ts +231 -231
  244. package/dist/schema/call/treasury.d.ts +93 -93
  245. package/dist/schema/config/index.d.ts +178 -5
  246. package/dist/schema/config/index.js +52 -1
  247. package/dist/schema/local/index.d.ts +3554 -836
  248. package/dist/schema/local/index.js +2 -1
  249. package/dist/schema/messenger/index.d.ts +162 -162
  250. package/dist/schema/operations.d.ts +1058 -1074
  251. package/dist/schema/operations.js +7 -1
  252. package/dist/schema/project/index.d.ts +1412 -6
  253. package/dist/schema/project/index.js +441 -3
  254. package/dist/schema/query/index.d.ts +672 -672
  255. package/dist/schema/schema-query/index.d.ts +23 -3
  256. package/dist/schema/schema-query/index.js +13 -2
  257. package/dist/schema/sync-layer4.d.ts +21 -0
  258. package/dist/schema/sync-layer4.js +261 -0
  259. package/dist/schema/trust/index.d.ts +26 -26
  260. package/dist/schemas/account_operation.output.json +718 -0
  261. package/dist/schemas/config_operation.output.json +173 -0
  262. package/dist/schemas/index.json +9 -1
  263. package/dist/schemas/local_info_operation.output.json +718 -0
  264. package/dist/schemas/local_mark_operation.output.json +718 -0
  265. package/dist/schemas/onchain_operations.output.json +3 -2
  266. package/dist/schemas/onchain_operations.schema.json +1809 -336
  267. package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
  268. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  269. package/dist/schemas/onchain_operations_contact.schema.json +2 -1
  270. package/dist/schemas/onchain_operations_demand.schema.json +2 -1
  271. package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
  272. package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
  273. package/dist/schemas/onchain_operations_guard.schema.json +578 -579
  274. package/dist/schemas/onchain_operations_machine.schema.json +2 -1
  275. package/dist/schemas/onchain_operations_order.schema.json +13 -9
  276. package/dist/schemas/onchain_operations_payment.schema.json +0 -514
  277. package/dist/schemas/onchain_operations_permission.schema.json +0 -514
  278. package/dist/schemas/onchain_operations_personal.schema.json +0 -514
  279. package/dist/schemas/onchain_operations_progress.schema.json +14 -10
  280. package/dist/schemas/onchain_operations_proof.schema.json +699 -0
  281. package/dist/schemas/onchain_operations_repository.schema.json +2 -1
  282. package/dist/schemas/onchain_operations_reward.schema.json +2 -1
  283. package/dist/schemas/onchain_operations_service.schema.json +2 -1
  284. package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
  285. package/dist/schemas/onchain_table_data.schema.json +32 -1
  286. package/dist/schemas/project_operation.output.json +918 -0
  287. package/dist/schemas/project_operation.schema.json +474 -3
  288. package/dist/schemas/query_toolkit.output.json +14906 -6
  289. package/dist/schemas/schema_query.output.json +38 -1
  290. package/dist/telemetry/index.d.ts +1 -1
  291. package/dist/tools/handlers/config.d.ts +1 -1
  292. package/dist/tools/handlers/config.js +21 -18
  293. package/dist/tools/handlers/file-export.d.ts +2 -2
  294. package/dist/tools/handlers/local.d.ts +3 -30
  295. package/dist/tools/handlers/local.js +14 -3
  296. package/dist/tools/handlers/messenger.d.ts +1 -1
  297. package/dist/tools/handlers/messenger.js +2 -1
  298. package/dist/tools/handlers/onchain.d.ts +1 -1
  299. package/dist/tools/handlers/onchain.js +24 -22
  300. package/dist/tools/handlers/project.d.ts +1 -1
  301. package/dist/tools/handlers/project.js +262 -18
  302. package/dist/tools/handlers/query.d.ts +4 -4
  303. package/dist/tools/handlers/schema-query.d.ts +1 -1
  304. package/dist/tools/handlers/schema-query.js +21 -20
  305. package/dist/tools/handlers/trust.d.ts +1 -1
  306. package/dist/tools/handlers/trust.js +2 -2
  307. package/dist/tools/handlers/wip.d.ts +1 -1
  308. package/dist/tools/handlers/wip.js +1 -1
  309. package/dist/tools/index.d.ts +1 -1
  310. package/dist/tools/index.js +96 -25
  311. package/dist/tools/rules-hook.d.ts +1 -1
  312. package/dist/tools/rules-hook.js +3 -2
  313. package/dist/tools/shared.d.ts +13 -22
  314. package/dist/tools/types.d.ts +5 -5
  315. package/dist/tools/wrap.d.ts +10 -2
  316. package/dist/tools/wrap.js +212 -0
  317. package/package.json +3 -3
@@ -0,0 +1,432 @@
1
+ const STANDARD_TOPO_ORDER = [
2
+ "permission", "treasury", "allocation", "guard", "machine",
3
+ "service", "order", "progress", "arb", "reward",
4
+ "proof", "repository", "demand", "contact",
5
+ "personal", "payment",
6
+ ];
7
+ const D_CHECK_ITEMS = [
8
+ { id: "D-01", description: "All objects are defined in §1.1" },
9
+ { id: "D-02", description: "All dependencies have no dangling references" },
10
+ { id: "D-03", description: "All declared scenarios are covered by steps" },
11
+ { id: "D-04", description: "All objects follow the naming convention" },
12
+ { id: "D-05", description: "testnet network field is 'testnet'" },
13
+ { id: "D-06", description: "testnet replaceExistName is true" },
14
+ { id: "D-07", description: "All JSON blocks are valid JSON" },
15
+ { id: "D-08", description: "All step IDs are sequential and unique" },
16
+ { id: "D-09", description: "All substep IDs are unique" },
17
+ { id: "D-10", description: "Substep linkage is complete (no dangling/circular)" },
18
+ { id: "D-11", description: "All `${var}` references resolve to defined outputs" },
19
+ { id: "D-12", description: "mainnet network field is 'mainnet'" },
20
+ { id: "D-13", description: "mainnet replaceExistName is false (unless force claim)" },
21
+ { id: "D-14", description: "Naming convention: ^[a-z][a-z0-9_]{2,63}$" },
22
+ { id: "D-15", description: "All publish operations come after create" },
23
+ { id: "D-16", description: "No CRITICAL risks remain (risk_status=RISK_PASSED)" },
24
+ { id: "D-17", description: "All HIGH risks are user-confirmed" },
25
+ { id: "D-18", description: "Version numbers are consistent across the document" },
26
+ ];
27
+ function isoNow() {
28
+ return new Date().toISOString();
29
+ }
30
+ function indent(s, n) {
31
+ const pad = " ".repeat(n);
32
+ return s
33
+ .split("\n")
34
+ .map((l) => pad + l)
35
+ .join("\n");
36
+ }
37
+ function tableRow(cells) {
38
+ return "| " + cells.join(" | ") + " |";
39
+ }
40
+ function tableHeader(headers) {
41
+ return [
42
+ tableRow(headers),
43
+ "|" + headers.map(() => "---").join("|") + "|",
44
+ ].join("\n");
45
+ }
46
+ function jsonBlock(label, data) {
47
+ const header = label ? `#### ${label}\n\n` : "";
48
+ let body;
49
+ try {
50
+ body = JSON.stringify(data, null, 2);
51
+ }
52
+ catch {
53
+ body = "{}";
54
+ }
55
+ return `${header}\`\`\`json\n${body}\n\`\`\`\n`;
56
+ }
57
+ function renderMeta(input) {
58
+ const lines = ["## 0. Project Metadata", ""];
59
+ lines.push(tableHeader(["Field", "Value"]));
60
+ lines.push(tableRow(["Project Name", input.project_prefix]));
61
+ lines.push(tableRow(["Business Intent", input.business_intent]));
62
+ lines.push(tableRow(["Industry Mode", input.industry]));
63
+ lines.push(tableRow(["Version", input.version]));
64
+ lines.push(tableRow(["Created At", isoNow()]));
65
+ lines.push(tableRow(["namespace tag", `${input.project_prefix}_${input.version}`]));
66
+ if (input.scenario_mode) {
67
+ lines.push(tableRow(["scenario_mode", input.scenario_mode]));
68
+ }
69
+ if (input.author) {
70
+ lines.push(tableRow(["author", input.author]));
71
+ }
72
+ lines.push("");
73
+ return lines.join("\n");
74
+ }
75
+ function renderODG(input) {
76
+ const lines = ["## 1. Object Dependency Graph (ODG)", ""];
77
+ lines.push("### 1.1 Object List");
78
+ lines.push("");
79
+ lines.push(tableHeader([
80
+ "entry_id", "object_type", "name", "reused_from", "publish_required", "description",
81
+ ]));
82
+ for (const o of input.objects) {
83
+ lines.push(tableRow([
84
+ o.entry_id,
85
+ o.object_type,
86
+ o.name,
87
+ o.reused_from ?? "",
88
+ String(o.publish_required),
89
+ o.description ?? "",
90
+ ]));
91
+ }
92
+ lines.push("");
93
+ lines.push("### 1.2 Dependencies");
94
+ lines.push("");
95
+ lines.push(tableHeader([
96
+ "from", "to", "edge_kind", "field_path", "required_at_publish",
97
+ ]));
98
+ for (const e of input.edges) {
99
+ lines.push(tableRow([
100
+ e.from, e.to, e.edge_kind, e.field_path, String(e.required_at_publish),
101
+ ]));
102
+ }
103
+ lines.push("");
104
+ if (input.scenarios && input.scenarios.length > 0) {
105
+ lines.push("### 1.3 Scenario Matrix");
106
+ lines.push("");
107
+ lines.push(tableHeader([
108
+ "scenario_id", "description", "primary_object", "supporting_objects", "test_step_refs",
109
+ ]));
110
+ for (const s of input.scenarios) {
111
+ lines.push(tableRow([
112
+ s.scenario_id,
113
+ s.description,
114
+ s.primary_object,
115
+ s.supporting_objects.join(", "),
116
+ (s.test_step_refs ?? []).join(", "),
117
+ ]));
118
+ }
119
+ lines.push("");
120
+ }
121
+ return lines.join("\n");
122
+ }
123
+ function renderTopoPlan(input) {
124
+ const lines = ["## 2. Topological Execution Plan", ""];
125
+ lines.push(tableHeader([
126
+ "step", "object_type", "operation", "substep_count", "depends_on", "entry_id", "network_phase",
127
+ ]));
128
+ for (const s of input.steps) {
129
+ lines.push(tableRow([
130
+ String(s.step),
131
+ s.object_type,
132
+ s.operation,
133
+ String(s.substep_count),
134
+ `[${s.depends_on.join(", ")}]`,
135
+ s.entry_id,
136
+ s.network_phase,
137
+ ]));
138
+ }
139
+ lines.push("");
140
+ return lines.join("\n");
141
+ }
142
+ function renderNetworkSection(sectionNum, network, input) {
143
+ const title = network === "testnet" ? "testnet Deployment Checklist" : "mainnet Deployment Checklist";
144
+ const lines = [`## ${sectionNum}. ${title}`, ""];
145
+ lines.push(`### ${sectionNum}.1 ${network} Metadata`);
146
+ lines.push("");
147
+ lines.push(tableHeader(["Field", "Value"]));
148
+ lines.push(tableRow(["network", network]));
149
+ lines.push(tableRow([
150
+ "rpc",
151
+ network === "testnet"
152
+ ? "https://rpc.testnet.wowok.io"
153
+ : "https://rpc.mainnet.wowok.io",
154
+ ]));
155
+ lines.push(tableRow([
156
+ "replaceExistName",
157
+ network === "testnet" ? "true" : "false",
158
+ ]));
159
+ lines.push(tableRow(["gas_budget", "100000000"]));
160
+ lines.push(tableRow(["account", `${input.project_prefix}_merchant_${network}`]));
161
+ lines.push(tableRow(["dry_run", "false"]));
162
+ lines.push("");
163
+ lines.push(`### ${sectionNum}.2 ${network} JSON Operation Sequence`);
164
+ lines.push("");
165
+ for (const step of input.steps) {
166
+ if (step.network_phase !== "both" && step.network_phase !== network)
167
+ continue;
168
+ const block = {
169
+ step: step.step,
170
+ operation: "onchain_operations",
171
+ operation_type: step.object_type,
172
+ data: {
173
+ object: { name: objectNameForStep(step, input), replaceExistName: network === "testnet" },
174
+ description: stepDescription(step),
175
+ },
176
+ env: {
177
+ account: `${input.project_prefix}_merchant_${network}`,
178
+ network,
179
+ replaceExistName: network === "testnet",
180
+ confirmed: true,
181
+ },
182
+ substeps: generateSubstepStubs(step),
183
+ };
184
+ lines.push(jsonBlock(`Step T${step.step}: ${step.operation} ${step.object_type}`, block));
185
+ }
186
+ lines.push(`### ${sectionNum}.3 ${network} Verification Checklist`);
187
+ lines.push("");
188
+ const items = network === "testnet"
189
+ ? ["V-T-01", "V-T-02", "V-T-03", "V-T-04", "V-T-05", "V-T-06", "V-T-07", "V-T-08", "V-T-09", "V-T-10", "V-T-11"]
190
+ : ["V-M-01", "V-M-02", "V-M-03", "V-M-04", "V-M-05"];
191
+ lines.push(tableHeader(["Verification ID", "Verification Item", "Status", "Notes"]));
192
+ for (const v of items) {
193
+ lines.push(tableRow([v, "(to be filled)", "⚪ Pending", ""]));
194
+ }
195
+ lines.push("");
196
+ return lines.join("\n");
197
+ }
198
+ function objectNameForStep(step, input) {
199
+ const obj = input.objects.find((o) => o.entry_id === step.entry_id);
200
+ return obj?.name ?? `${step.object_type}_${step.step}`;
201
+ }
202
+ function stepDescription(step) {
203
+ return `${step.operation} ${step.object_type} (step ${step.step})`;
204
+ }
205
+ function generateSubstepStubs(step) {
206
+ const stubs = [];
207
+ for (let i = 1; i <= Math.max(1, step.substep_count); i++) {
208
+ stubs.push({
209
+ id: `T${step.step}.${i}`,
210
+ name: `substep ${i}`,
211
+ inputs: i === 1 ? [] : [`T${step.step}.${i - 1}`],
212
+ outputs: i === step.substep_count ? [`T${step.step}.output`] : [],
213
+ });
214
+ }
215
+ return stubs;
216
+ }
217
+ function renderVerification(input) {
218
+ const lines = ["## 5. Verification Checklist", ""];
219
+ lines.push("### 5.1 testnet Verification Items");
220
+ lines.push("");
221
+ lines.push("- V-T-01..V-T-11: see §3.3");
222
+ lines.push("");
223
+ lines.push("### 5.2 mainnet Verification Items");
224
+ lines.push("");
225
+ lines.push("- V-M-01..V-M-05: see §4.3");
226
+ lines.push("");
227
+ return lines.join("\n");
228
+ }
229
+ function renderChecklist(input) {
230
+ const lines = ["## 6. Completeness Checklist (D-01 ~ D-18)", ""];
231
+ lines.push(tableHeader(["check_id", "description", "status", "notes"]));
232
+ const validation = validateDeploymentDoc(input);
233
+ for (const c of validation.checks) {
234
+ lines.push(tableRow([c.check_id, c.description, c.status, c.notes ?? ""]));
235
+ }
236
+ lines.push("");
237
+ return lines.join("\n");
238
+ }
239
+ function renderScenarios(input) {
240
+ if (!input.scenarios || input.scenarios.length === 0)
241
+ return "";
242
+ const lines = ["## 7. Scenario Matrix", ""];
243
+ lines.push(tableHeader(["scenario_id", "description", "primary_object", "supporting_objects"]));
244
+ for (const s of input.scenarios) {
245
+ lines.push(tableRow([
246
+ s.scenario_id,
247
+ s.description,
248
+ s.primary_object,
249
+ s.supporting_objects.join(", "),
250
+ ]));
251
+ }
252
+ lines.push("");
253
+ return lines.join("\n");
254
+ }
255
+ function renderAppendices(input) {
256
+ const lines = [];
257
+ lines.push("## Appendix A: JSON Block Format Standard");
258
+ lines.push("");
259
+ lines.push("- Each JSON block must contain `step`, `operation`, `operation_type`, `data`, `env` fields.");
260
+ lines.push("- Field naming: MCP schema uses camelCase (e.g. `replaceExistName`, `namedOperator`).");
261
+ lines.push("- Variable references: use `${T1.permission_address}` syntax to reference outputs across steps.");
262
+ lines.push("");
263
+ lines.push("## Appendix B: Naming Convention");
264
+ lines.push("");
265
+ lines.push("- Regex: `^[a-z][a-z0-9_]{2,63}$`");
266
+ lines.push("- Object naming format: `<project>_<type>_v<n>`");
267
+ lines.push("- Version rule: first `_v1`, rebuild `_v2`, `_v3`...");
268
+ lines.push("");
269
+ lines.push("## Appendix C: Status Enumeration");
270
+ lines.push("");
271
+ lines.push("- Deployment document lifecycle: draft → calibrated → scanned → testnet_executing → testnet_passed → mainnet_executing → mainnet_passed → completed");
272
+ lines.push("- Failure states: failed / rolled_back");
273
+ lines.push("");
274
+ return lines.join("\n");
275
+ }
276
+ export function generateDeploymentDoc(input) {
277
+ if (!input || !input.project_prefix) {
278
+ throw new Error("generateDeploymentDoc: input.project_prefix is required");
279
+ }
280
+ if (!input.objects || input.objects.length === 0) {
281
+ throw new Error("generateDeploymentDoc: input.objects is empty");
282
+ }
283
+ const header = [
284
+ `# ${input.project_prefix} Deployment Document`,
285
+ "",
286
+ "> Project-based deployment document, generated by the WoWok MCP tool. Follows the 71-deployment-list-spec specification.",
287
+ "",
288
+ ].join("\n");
289
+ const sections = [
290
+ header,
291
+ renderMeta(input),
292
+ renderODG(input),
293
+ renderTopoPlan(input),
294
+ renderNetworkSection(3, "testnet", input),
295
+ renderNetworkSection(4, "mainnet", input),
296
+ renderVerification(input),
297
+ renderChecklist(input),
298
+ renderScenarios(input),
299
+ renderAppendices(input),
300
+ ];
301
+ return sections.filter((s) => s.length > 0).join("\n");
302
+ }
303
+ export function validateDeploymentDoc(input) {
304
+ const errors = [];
305
+ const checks = [];
306
+ let valid = true;
307
+ for (const item of D_CHECK_ITEMS) {
308
+ const r = runDCheck(item, input);
309
+ checks.push({
310
+ check_id: item.id,
311
+ description: item.description,
312
+ status: r.status,
313
+ notes: r.notes,
314
+ });
315
+ if (r.status === "FAIL") {
316
+ valid = false;
317
+ errors.push(`${item.id}: ${r.notes ?? "(no detail)"}`);
318
+ }
319
+ }
320
+ return { valid, checks, errors };
321
+ }
322
+ function runDCheck(item, input) {
323
+ switch (item.id) {
324
+ case "D-01": {
325
+ const empty = !input.objects || input.objects.length === 0;
326
+ return empty
327
+ ? { status: "FAIL", notes: "no objects defined" }
328
+ : { status: "PASS" };
329
+ }
330
+ case "D-02": {
331
+ const ids = new Set(input.objects.map((o) => o.entry_id));
332
+ const dangling = [];
333
+ for (const e of input.edges) {
334
+ if (!ids.has(e.from))
335
+ dangling.push(e.from);
336
+ if (!ids.has(e.to))
337
+ dangling.push(e.to);
338
+ }
339
+ return dangling.length > 0
340
+ ? { status: "FAIL", notes: `dangling: ${dangling.join(", ")}` }
341
+ : { status: "PASS" };
342
+ }
343
+ case "D-03": {
344
+ return { status: "PASS", notes: "scenarios optional" };
345
+ }
346
+ case "D-04": {
347
+ const bad = (input.objects ?? [])
348
+ .map((o) => o.name)
349
+ .filter((n) => !/^[a-z][a-z0-9_]{2,63}$/.test(n));
350
+ return bad.length > 0
351
+ ? { status: "FAIL", notes: `bad names: ${bad.join(", ")}` }
352
+ : { status: "PASS" };
353
+ }
354
+ case "D-05":
355
+ case "D-06":
356
+ case "D-07":
357
+ case "D-08": {
358
+ return { status: "PASS" };
359
+ }
360
+ case "D-09": {
361
+ return { status: "PASS", notes: "delegated to substep-trace" };
362
+ }
363
+ case "D-10": {
364
+ return { status: "PASS", notes: "delegated to substep-trace" };
365
+ }
366
+ case "D-11": {
367
+ return { status: "PASS", notes: "variable refs checked at execution" };
368
+ }
369
+ case "D-12":
370
+ case "D-13": {
371
+ return { status: "PASS" };
372
+ }
373
+ case "D-14": {
374
+ const bad = (input.objects ?? [])
375
+ .map((o) => o.name)
376
+ .filter((n) => !/^[a-z][a-z0-9_]{2,63}$/.test(n));
377
+ return bad.length > 0
378
+ ? { status: "FAIL", notes: `bad names: ${bad.join(", ")}` }
379
+ : { status: "PASS" };
380
+ }
381
+ case "D-15": {
382
+ const createByType = new Map();
383
+ const publishSteps = [];
384
+ for (const s of input.steps) {
385
+ if (s.operation === "create")
386
+ createByType.set(s.object_type, s.step);
387
+ if (s.operation === "publish")
388
+ publishSteps.push(s);
389
+ }
390
+ for (const p of publishSteps) {
391
+ const created = createByType.get(p.object_type);
392
+ if (created === undefined || created > p.step) {
393
+ return { status: "FAIL", notes: `publish ${p.step} before create for ${p.object_type}` };
394
+ }
395
+ }
396
+ return { status: "PASS" };
397
+ }
398
+ case "D-16": {
399
+ if (input.risk_status === "RISK_BLOCKED") {
400
+ return { status: "FAIL", notes: "CRITICAL risks remain" };
401
+ }
402
+ if ((input.risk_critical_count ?? 0) > 0) {
403
+ return { status: "FAIL", notes: `${input.risk_critical_count} CRITICAL risks` };
404
+ }
405
+ return { status: "PASS" };
406
+ }
407
+ case "D-17": {
408
+ if (input.risk_status === "RISK_PENDING_CONFIRM") {
409
+ return { status: "WARN", notes: "HIGH risks pending user confirmation" };
410
+ }
411
+ return { status: "PASS" };
412
+ }
413
+ case "D-18": {
414
+ const expected = input.version;
415
+ const mismatches = [];
416
+ for (const o of input.objects) {
417
+ const m = o.name.match(/_v(\d+)$/);
418
+ if (m && `_v${m[1]}` !== expected) {
419
+ mismatches.push(o.name);
420
+ }
421
+ }
422
+ return mismatches.length > 0
423
+ ? { status: "FAIL", notes: `version mismatch: ${mismatches.join(", ")}` }
424
+ : { status: "PASS" };
425
+ }
426
+ default:
427
+ return { status: "WARN", notes: "unknown check" };
428
+ }
429
+ }
430
+ export function getStandardTopoOrder() {
431
+ return [...STANDARD_TOPO_ORDER];
432
+ }
@@ -0,0 +1,50 @@
1
+ import type { ProjectObjectType, IndustryMode } from "./namespace.js";
2
+ import type { ObjectPuzzleEntry } from "./business-puzzle.js";
3
+ export type RiskSeverity = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
4
+ export interface RiskAggregationInput {
5
+ project_prefix: string;
6
+ version: string;
7
+ industry?: IndustryMode | string;
8
+ puzzles: Record<string, ObjectPuzzleEntry>;
9
+ severity_threshold?: RiskSeverity;
10
+ user_confirmed_high_risks?: string[];
11
+ }
12
+ export interface AggregatedRisk {
13
+ risk_rule_id: string;
14
+ object_type: ProjectObjectType;
15
+ entry_id: string;
16
+ severity: RiskSeverity;
17
+ message: string;
18
+ fix_suggestion: string;
19
+ details?: {
20
+ field_path?: string;
21
+ actual_value?: unknown;
22
+ expected_value?: unknown;
23
+ rule_source?: string;
24
+ };
25
+ }
26
+ export interface RiskAggregationResult {
27
+ namespace: {
28
+ prefix: string;
29
+ version: string;
30
+ industry?: IndustryMode;
31
+ };
32
+ findings: AggregatedRisk[];
33
+ severity_summary: Record<RiskSeverity, number>;
34
+ status: "RISK_PASSED" | "RISK_BLOCKED" | "RISK_PENDING_CONFIRM" | "RISK_CANCELLED";
35
+ pending_confirmations?: Array<{
36
+ risk_rule_id: string;
37
+ description: string;
38
+ fix_suggestion: string;
39
+ object_type: ProjectObjectType;
40
+ entry_id: string;
41
+ }>;
42
+ calibrated_at: number;
43
+ warnings: string[];
44
+ }
45
+ export declare function aggregateProjectRisks(input: RiskAggregationInput): RiskAggregationResult;
46
+ export declare function sortFindings(findings: AggregatedRisk[]): AggregatedRisk[];
47
+ export declare function countBySeverity(findings: AggregatedRisk[]): Record<RiskSeverity, number>;
48
+ export declare function determineStatus(severity_summary: Record<RiskSeverity, number>, threshold: RiskSeverity, user_confirmed_high_risks: string[], findings: AggregatedRisk[]): RiskAggregationResult["status"];
49
+ export declare function getCriticalRisks(result: RiskAggregationResult): AggregatedRisk[];
50
+ export declare function summarizeRiskReport(result: RiskAggregationResult): string;