@microi.net/cli 5.8.5 → 5.8.6

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 (211) hide show
  1. package/.codebuddy-plugin/marketplace.json +2 -2
  2. package/.codebuddy-plugin/plugin.json +1 -1
  3. package/.codex-plugin/plugin.json +1 -1
  4. package/.mcp.json +1 -1
  5. package/.workbuddy-plugin/marketplace.json +2 -2
  6. package/.workbuddy-plugin/plugin.json +1 -1
  7. package/LICENSE +21 -21
  8. package/README.md +71 -71
  9. package/assets/build-meta.json +6 -6
  10. package/assets/feature-matrix.json +138 -138
  11. package/assets/logo.svg +4 -4
  12. package/cordis.patch.yml +1 -1
  13. package/package.json +1 -1
  14. package/scripts/codex-marketplace.json +20 -20
  15. package/scripts/mcp-codex-stdio-adapter.js +189 -189
  16. package/scripts/mcp-trae-windows-launcher.cmd +21 -21
  17. package/scripts/microi-cli-mcp.js +7 -7
  18. package/scripts/microi-cli.js +66 -65
  19. package/scripts/microi-codex-broker.js +450 -450
  20. package/scripts/microi-codex-router.js +618 -618
  21. package/scripts/microi-skills.meta.json +384 -384
  22. package/skills/.microi-skills-version.json +2 -2
  23. package/skills/.progressive-disclosure-manifest.json +3566 -3566
  24. package/skills/README.md +287 -287
  25. package/skills/ai-engine/SKILL.md +269 -265
  26. package/skills/ai-engine/agents/openai.yaml +4 -4
  27. package/skills/ai-engine/references/ai-employees.md +48 -48
  28. package/skills/ai-engine/references/self-hosted-digital-human.md +59 -59
  29. package/skills/ai-platform-governance/SKILL.md +177 -177
  30. package/skills/ai-platform-governance/references/progressive-01-/345/212/237/350/203/275/345/274/200/345/205/263.md +190 -190
  31. package/skills/app-store/SKILL.md +525 -525
  32. package/skills/app-store/agents/openai.yaml +4 -4
  33. package/skills/business-blueprint/SKILL.md +193 -193
  34. package/skills/datasource-engine/SKILL.md +93 -93
  35. package/skills/datasource-engine/agents/openai.yaml +4 -4
  36. package/skills/dos-orm/SKILL.md +97 -97
  37. package/skills/dos-orm/references/api-reference.md +229 -229
  38. package/skills/email-engine/SKILL.md +81 -81
  39. package/skills/email-engine/references/v8-email.md +34 -34
  40. package/skills/job-engine/SKILL.md +176 -176
  41. package/skills/job-engine/agents/openai.yaml +4 -4
  42. package/skills/message-notification/SKILL.md +156 -156
  43. package/skills/message-notification/agents/openai.yaml +5 -5
  44. package/skills/message-notification/references/contracts.md +102 -102
  45. package/skills/microi/SKILL.md +14 -14
  46. package/skills/microi-ai-app-auth.js +652 -652
  47. package/skills/microi-ai-application/SKILL.md +115 -115
  48. package/skills/microi-ai-application/agents/openai.yaml +4 -4
  49. package/skills/microi-ai-application/references/frontend-baseline.md +164 -164
  50. package/skills/microi-client-frontend/SKILL.md +244 -244
  51. package/skills/microi-client-frontend/references/progressive-01-3-/345/212/250/346/200/201/346/214/211/351/222/256/347/263/273/347/273/237.md +144 -144
  52. package/skills/microi-client-frontend/references/progressive-02-8-/350/277/220/350/241/214/346/227/266/351/253/230/351/242/221/345/235/221/345/244/215/347/233/230.md +196 -196
  53. package/skills/microi-client-frontend/references/progressive-03-vue3-/345/211/215/347/253/257/345/276/256/346/234/215/345/212/241/345/256/277/344/270/273/350/247/204/345/210/231.md +167 -167
  54. package/skills/microi-codex/SKILL.md +102 -102
  55. package/skills/microi-codex-installer/SKILL.md +231 -231
  56. package/skills/microi-codex-installer/agents/openai.yaml +7 -7
  57. package/skills/microi-datasource-mapping/SKILL.md +122 -122
  58. package/skills/microi-db-schema/SKILL.md +175 -175
  59. package/skills/microi-db-schema/agents/openai.yaml +4 -4
  60. package/skills/microi-db-schema/references/core-tables.md +695 -695
  61. package/skills/microi-db-schema/references/form-component-options.md +256 -256
  62. package/skills/microi-db-schema/references/schema-overview.md +202 -202
  63. package/skills/microi-db-schema/references/schema.md +646 -646
  64. package/skills/microi-db-schema/references/table-catalog.md +1599 -1599
  65. package/skills/microi-deployment/SKILL.md +221 -221
  66. package/skills/microi-deployment/references/deployment-matrix.md +109 -109
  67. package/skills/microi-docs-coverage/SKILL.md +133 -133
  68. package/skills/microi-docs-coverage/references/capability-map.md +91 -91
  69. package/skills/microi-docs-coverage/scripts/audit-doc-skill-coverage.mjs +894 -894
  70. package/skills/microi-form-engine/SKILL.md +333 -333
  71. package/skills/microi-form-engine/references/component-catalog.md +218 -218
  72. package/skills/microi-form-engine/references/data-source-events.md +124 -124
  73. package/skills/microi-form-layout/SKILL.md +205 -205
  74. package/skills/microi-form-layout/references/progressive-01-3-/344/270/211/347/247/215/345/210/206/347/273/204/347/232/204/345/255/230/345/202/250/344/270/216/351/205/215/347/275/256.md +235 -235
  75. package/skills/microi-frontend-sdk/SKILL.md +194 -194
  76. package/skills/microi-frontend-sdk/references/progressive-01-token-/345/275/223/345/211/215/347/231/273/345/275/225/347/224/250/346/210/267/344/270/216/345/275/223/345/211/215/347/273/210/347/253/257/347/231/273/345/275/225/345/215/217/350/256/256.md +176 -176
  77. package/skills/microi-left-right-layout/SKILL.md +141 -141
  78. package/skills/microi-microservice/SKILL.md +326 -324
  79. package/skills/microi-microservice/references/runtime-delivery.md +278 -278
  80. package/skills/microi-mobile-app-quality/SKILL.md +185 -185
  81. package/skills/microi-mobile-app-quality/references/progressive-01-4-/351/207/215/350/246/201/346/214/211/351/222/256/345/277/205/351/241/273/345/270/246/345/233/276/346/240/207.md +213 -213
  82. package/skills/microi-mobile-app-quality/references/progressive-02-9-/344/270/273/351/242/230/345/210/207/346/215/242/345/277/205/351/241/273/347/234/237/345/256/236/344/270/224/345/205/250/345/261/200/347/224/237/346/225/210.md +128 -128
  83. package/skills/microi-solution-quotation/SKILL.md +78 -78
  84. package/skills/microi-solution-quotation/agents/openai.yaml +4 -4
  85. package/skills/microi-solution-quotation/scripts/build_solution_quote.py +296 -296
  86. package/skills/microi-sso/SKILL.md +92 -92
  87. package/skills/microi-sso/references/acceptance.md +49 -49
  88. package/skills/microi-sso/references/configuration-and-security.md +53 -53
  89. package/skills/microi-sso/references/inbound.md +53 -53
  90. package/skills/microi-sso/references/outbound.md +39 -39
  91. package/skills/microi-system-delivery/SKILL.md +137 -137
  92. package/skills/microi-system-delivery/references/progressive-01-/346/240/207/345/207/206/345/267/245/344/275/234/346/265/201.md +193 -193
  93. package/skills/microi-system-delivery/references/progressive-02-/350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/345/277/205/351/241/273/350/246/206/347/233/226/347/232/204/345/235/221.md +217 -217
  94. package/skills/microi-ui/SKILL.md +192 -192
  95. package/skills/microi-ui/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/234/272/346/231/257/350/223/235/345/233/276.md +183 -183
  96. package/skills/microi-uniapp-frontend/SKILL.md +193 -193
  97. package/skills/microi-uniapp-frontend/references/progressive-01-/347/247/273/345/212/250/347/253/257/345/210/206/347/261/273-/345/217/214/346/240/217/345/210/227/350/241/250/347/213/254/347/253/213/346/273/232/345/212/250.md +225 -225
  98. package/skills/microi-uniapp-frontend/references/progressive-02-/345/205/263/351/224/256/344/270/232/345/212/241/350/265/204/344/272/247/344/270/215/345/276/227/351/273/230/350/256/244/351/200/211/344/270/255.md +154 -154
  99. package/skills/microi.v8.js +1921 -1921
  100. package/skills/module-engine/SKILL.md +255 -255
  101. package/skills/module-engine/references/module-config.md +204 -204
  102. package/skills/ocr-engine/SKILL.md +113 -113
  103. package/skills/ocr-engine/agents/openai.yaml +4 -4
  104. package/skills/page-engine/SKILL.md +206 -206
  105. package/skills/page-engine/examples/compact-dashboard.json +1444 -1444
  106. package/skills/page-engine/references/progressive-01-/346/211/200/346/234/211/347/273/204/344/273/266/347/261/273/345/236/213.md +234 -234
  107. package/skills/page-engine/references/progressive-02-/347/211/210/346/234/254/345/216/206/345/217/262-/345/271/266/345/217/221/344/277/235/345/255/230/344/270/216/345/233/236/346/273/232.md +60 -60
  108. package/skills/performance-testing/SKILL.md +221 -221
  109. package/skills/playwright-e2e/SKILL.md +196 -196
  110. package/skills/playwright-e2e/references/progressive-01-/345/205/250/350/207/252/345/212/250/347/231/273/345/275/225-/345/205/215/351/252/214/350/257/201/347/240/201-/344/275/206/344/270/215/345/205/215/345/257/206/347/240/201-/345/277/205/350/257/273.md +173 -173
  111. package/skills/playwright-e2e/references/progressive-02-/346/226/207/345/255/227/345/257/271/346/257/224/345/272/246/344/270/216/345/217/257/350/257/273/346/200/247/350/207/252/345/212/250/345/214/226/346/243/200/346/237/245-/345/277/205/345/201/232.md +183 -183
  112. package/skills/playwright-e2e/references/progressive-03-microi-helper-/346/250/241/346/235/277.md +221 -221
  113. package/skills/playwright-e2e/references/progressive-04-ci-/345/273/272/350/256/256.md +115 -115
  114. package/skills/print-engine/SKILL.md +259 -259
  115. package/skills/production-readonly-audit/SKILL.md +41 -41
  116. package/skills/report-engine/SKILL.md +71 -71
  117. package/skills/report-engine/agents/openai.yaml +4 -4
  118. package/skills/scripts/optimize-progressive-disclosure.mjs +204 -204
  119. package/skills/scripts/refresh-progressive-disclosure.mjs +64 -64
  120. package/skills/scripts/sync-embedded-skills.mjs +46 -46
  121. package/skills/scripts/validate-progressive-disclosure.mjs +57 -57
  122. package/skills/search-engine/SKILL.md +75 -75
  123. package/skills/search-engine/agents/openai.yaml +4 -4
  124. package/skills/spider-engine/SKILL.md +190 -190
  125. package/skills/system-observability/SKILL.md +248 -248
  126. package/skills/system-observability/references/memory-incident-triage.md +77 -77
  127. package/skills/translate-engine/SKILL.md +140 -140
  128. package/skills/translate-engine/agents/openai.yaml +4 -4
  129. package/skills/ui-design/SKILL.md +223 -223
  130. package/skills/ui-design/assets/pattern-showcase/app.js +54 -54
  131. package/skills/ui-design/assets/pattern-showcase/index.html +163 -163
  132. package/skills/ui-design/assets/pattern-showcase/styles.css +311 -311
  133. package/skills/ui-design/assets/templates/MCI-DESIGN.md +206 -206
  134. package/skills/ui-design/references/design-pattern-library.md +184 -184
  135. package/skills/ui-design/references/mci-design-contract.md +163 -163
  136. package/skills/ui-design/references/motion-and-media.md +78 -78
  137. package/skills/ui-design/references/product-flow-recipes.md +94 -94
  138. package/skills/ui-design/references/progressive-01-/351/242/234/350/211/262/344/275/223/347/263/273-css-variables-/346/224/257/346/214/201/344/270/273/351/242/230/345/210/207/346/215/242.md +218 -218
  139. package/skills/ui-design/references/progressive-02-/345/255/227/344/275/223.md +164 -164
  140. package/skills/ui-design/references/progressive-03-/345/212/250/346/225/210/350/247/204/350/214/203-/344/270/260/345/257/214/344/275/206/344/270/215/345/215/241.md +235 -235
  141. package/skills/ui-design/references/progressive-04-/347/273/204/344/273/266/351/243/216/346/240/274/351/200/237/346/237/245.md +152 -152
  142. package/skills/ui-design/references/progressive-05-/347/247/273/345/212/250/347/253/257/344/270/223/347/224/250/350/247/204/350/214/203.md +238 -238
  143. package/skills/ui-design/references/progressive-06-/344/270/273/351/242/230/345/210/207/346/215/242/345/256/236/347/216/260.md +194 -194
  144. package/skills/ui-design/references/progressive-07-/351/200/237/346/237/245-/344/273/216/345/244/264/346/220/255/345/273/272/344/270/200/344/270/252/347/247/273/345/212/250/347/253/257/351/241/265/351/235/242.md +207 -207
  145. package/skills/ui-design/references/progressive-08-/350/241/250/345/215/225/345/210/206/347/273/204/350/247/204/350/214/203-tabs-vs-collapsegroup-/345/274/272/345/210/266.md +142 -142
  146. package/skills/uniapp-mall-assets/SKILL.md +176 -176
  147. package/skills/unity-integration/SKILL.md +171 -171
  148. package/skills/unity-integration/agents/openai.yaml +4 -4
  149. package/skills/unity-integration/references/ai-app-delivery.md +119 -119
  150. package/skills/unity-integration/references/sdk-api.md +82 -82
  151. package/skills/unity-integration/references/toolbox-migration.md +66 -66
  152. package/skills/unity-integration/references/webgl-hosting.md +57 -57
  153. package/skills/v8-api-config/SKILL.md +388 -388
  154. package/skills/v8-cache-pattern/SKILL.md +312 -312
  155. package/skills/v8-crud-api/SKILL.md +178 -178
  156. package/skills/v8-crud-api/references/progressive-01-/346/237/245/350/257/242/345/210/227/350/241/250-/345/210/206/351/241/265.md +226 -226
  157. package/skills/v8-crud-api/references/progressive-02-where-/346/235/241/344/273/266/350/257/255/346/263/225/351/200/237/346/237/245.md +49 -49
  158. package/skills/v8-debugging/SKILL.md +284 -284
  159. package/skills/v8-explorer-tree/SKILL.md +228 -228
  160. package/skills/v8-export-import/SKILL.md +219 -219
  161. package/skills/v8-export-import/references/progressive-01-excellayout-/351/253/230/347/272/247/350/207/252/347/224/261/345/270/203/345/261/200.md +211 -211
  162. package/skills/v8-export-import/references/progressive-02-powerpoint-/345/257/274/345/207/272.md +202 -202
  163. package/skills/v8-export-import/references/progressive-03-/345/256/211/345/205/250-/346/200/247/350/203/275/346/263/250/346/204/217.md +42 -42
  164. package/skills/v8-file-upload/SKILL.md +284 -284
  165. package/skills/v8-file-upload/references/progressive-01-/345/205/254/346/234/211/346/241/266-vs-/347/247/201/346/234/211/346/241/266.md +263 -263
  166. package/skills/v8-file-upload/references/progressive-02-office-/346/226/207/344/273/266/345/234/250/347/272/277/347/274/226/350/276/221/347/211/210/346/234/254/345/217/267/350/247/204/345/210/231.md +161 -161
  167. package/skills/v8-formengine-http/SKILL.md +238 -238
  168. package/skills/v8-frontend-events/SKILL.md +180 -180
  169. package/skills/v8-frontend-events/references/bluetooth-print-api.md +135 -135
  170. package/skills/v8-frontend-events/references/bluetooth-print.md +258 -258
  171. package/skills/v8-frontend-events/references/progressive-01-/345/210/227/350/241/250/344/272/213/344/273/266.md +219 -219
  172. package/skills/v8-http-integration/SKILL.md +182 -182
  173. package/skills/v8-http-integration/references/progressive-01-get-/350/257/267/346/261/202.md +220 -220
  174. package/skills/v8-http-integration/references/progressive-02-/351/224/231/350/257/257/345/244/204/347/220/206/346/250/241/345/274/217.md +44 -44
  175. package/skills/v8-image-processing/SKILL.md +190 -190
  176. package/skills/v8-image-processing/agents/openai.yaml +4 -4
  177. package/skills/v8-image-processing/references/api-reference.md +623 -623
  178. package/skills/v8-menu-buttons/SKILL.md +186 -186
  179. package/skills/v8-menu-buttons/references/progressive-01-2-/346/214/211/351/222/256/345/257/271/350/261/241-schema.md +222 -222
  180. package/skills/v8-menu-buttons/references/progressive-02-8-/346/250/241/345/274/217-f-/345/220/216/345/217/260/344/273/273/345/212/241/346/214/211/351/222/256-/351/225/277/344/273/273/345/212/241.md +228 -228
  181. package/skills/v8-menu-buttons/references/progressive-03-10-/345/217/215/346/250/241/345/274/217-/351/201/277/345/205/215.md +104 -104
  182. package/skills/v8-mongodb/SKILL.md +200 -200
  183. package/skills/v8-mq-mqtt/SKILL.md +176 -176
  184. package/skills/v8-mq-mqtt/references/mqtt-production.md +342 -342
  185. package/skills/v8-mq-mqtt/references/progressive-01-v8-mqtt-iot-/347/211/251/350/201/224/347/275/221.md +181 -181
  186. package/skills/v8-mq-mqtt/scripts/check-mqtt-skill-coverage.mjs +203 -203
  187. package/skills/v8-saas-multi-tenant/SKILL.md +305 -305
  188. package/skills/v8-security/SKILL.md +210 -210
  189. package/skills/v8-security/references/progressive-01-2-/346/235/203/351/231/220/346/240/241/351/252/214.md +200 -200
  190. package/skills/v8-security/references/progressive-02-7-/346/227/245/345/277/227/350/256/260/345/275/225.md +160 -160
  191. package/skills/v8-sql-query/SKILL.md +302 -302
  192. package/skills/v8-table-event/SKILL.md +176 -176
  193. package/skills/v8-table-event/references/progressive-01-informv8-js-/350/241/250/345/215/225/346/211/223/345/274/200/344/272/213/344/273/266.md +216 -216
  194. package/skills/v8-table-event/references/progressive-02-/345/211/215/347/253/257/344/272/213/344/273/266/345/220/215-v8-eventname-/345/217/257/350/203/275/347/232/204/345/200/274.md +46 -46
  195. package/skills/v8-tcp-integration/SKILL.md +147 -147
  196. package/skills/v8-tcp-integration/agents/openai.yaml +4 -4
  197. package/skills/v8-template-engine/SKILL.md +167 -167
  198. package/skills/v8-utilities/SKILL.md +104 -104
  199. package/skills/v8-utilities/references/client-api-index.md +143 -143
  200. package/skills/v8-utilities/references/platform-http-routes.md +83 -83
  201. package/skills/v8-utilities/references/server-api-index.md +188 -188
  202. package/skills/v8-workflow/SKILL.md +252 -252
  203. package/skills/v8-workflow/references/progressive-01-/350/212/202/347/202/271/345/274/200/345/247/213-v8-/344/272/213/344/273/266.md +180 -180
  204. package/skills/v8-workflow/references/workflow-configuration.md +49 -49
  205. package/skills/vision-engine/SKILL.md +160 -160
  206. package/skills/vision-engine/agents/openai.yaml +4 -4
  207. package/skills/vision-engine/references/architecture-and-acceptance.md +194 -194
  208. package/skills/workspace-conventions/SKILL.md +273 -273
  209. package/skills/workspace-conventions/references/progressive-01-/347/211/210/346/234/254/346/233/264/346/226/260/346/227/245/345/277/227/344/277/235/346/212/244/350/247/204/345/210/231-/345/274/272/345/210/266.md +209 -209
  210. package/skills/workspace-conventions/references/progressive-02-microi-net-api-/346/234/254/345/234/260/345/220/257/345/212/250/347/272/246/345/256/232.md +217 -217
  211. package/skills/workspace-conventions/references/progressive-03-cli-/344/270/216-ide-/346/217/222/344/273/266/351/224/231/347/211/210/345/205/261/345/255/230/347/272/246/345/256/232.md +27 -27
@@ -1,64 +1,64 @@
1
- import crypto from 'node:crypto'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
- import { fileURLToPath } from 'node:url'
5
-
6
- const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
7
- const manifestPath = path.join(skillsRoot, '.progressive-disclosure-manifest.json')
8
- const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
9
- const requested = process.argv.slice(2)
10
- if (requested.length === 0) {
11
- throw new Error('Pass each intentionally changed skill name explicitly.')
12
- }
13
- const hash = (value) => crypto.createHash('sha256').update(value).digest('hex')
14
-
15
- for (const skillName of requested) {
16
- const skill = manifest.skills[skillName]
17
- if (!skill) throw new Error(`${skillName} is not a progressive-disclosure skill`)
18
- const sources = new Map()
19
- const entryPath = path.join(skillsRoot, skillName, 'SKILL.md')
20
- sources.set(`${skillName}/SKILL.md`, fs.readFileSync(entryPath, 'utf8'))
21
- for (const reference of skill.references) {
22
- const destination = `${skillName}/${reference.path}`
23
- sources.set(destination, fs.readFileSync(path.join(skillsRoot, destination), 'utf8'))
24
- }
25
-
26
- const ordered = []
27
- for (const chunk of skill.chunks) {
28
- let source = sources.get(chunk.destination)
29
- const openPattern = new RegExp(`<!-- microi-progressive:chunk id=${chunk.id} sha256=[a-f0-9]{64} -->`)
30
- const match = source.match(openPattern)
31
- if (!match) throw new Error(`${skillName}: missing chunk ${chunk.id}`)
32
- const markerStart = match.index
33
- const markerEnd = markerStart + match[0].length
34
- const contentStart = markerEnd + (source.startsWith('\r\n', markerEnd) ? 2 : 1)
35
- const close = '<!-- /microi-progressive:chunk -->'
36
- const contentEnd = source.indexOf(close, contentStart)
37
- const raw = source.slice(contentStart, contentEnd)
38
- const digest = hash(raw)
39
- source = source.slice(0, markerStart)
40
- + `<!-- microi-progressive:chunk id=${chunk.id} sha256=${digest} -->`
41
- + source.slice(markerEnd)
42
- sources.set(chunk.destination, source)
43
- chunk.sha256 = digest
44
- chunk.lines = raw.split(/\r?\n/).length
45
- ordered[chunk.ordinal] = raw
46
- }
47
-
48
- for (const [destination, source] of sources) {
49
- fs.writeFileSync(path.join(skillsRoot, destination), source, 'utf8')
50
- }
51
- const entry = sources.get(`${skillName}/SKILL.md`)
52
- const begin = entry.indexOf('<!-- microi-progressive:begin -->')
53
- const prefix = entry.slice(0, begin)
54
- skill.prefixSha256 = hash(prefix)
55
- skill.prefixBytes = Buffer.byteLength(prefix)
56
- skill.originalSha256 = hash(prefix + ordered.join(''))
57
- skill.originalLines = (prefix + ordered.join('')).split(/\r?\n/).length
58
- skill.entryLines = entry.split(/\r?\n/).length
59
- }
60
-
61
- manifest.generatedAt = new Date().toISOString()
62
- fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8')
63
- console.log(`Accepted intentional knowledge updates for: ${requested.join(', ')}`)
64
-
1
+ import crypto from 'node:crypto'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
7
+ const manifestPath = path.join(skillsRoot, '.progressive-disclosure-manifest.json')
8
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
9
+ const requested = process.argv.slice(2)
10
+ if (requested.length === 0) {
11
+ throw new Error('Pass each intentionally changed skill name explicitly.')
12
+ }
13
+ const hash = (value) => crypto.createHash('sha256').update(value).digest('hex')
14
+
15
+ for (const skillName of requested) {
16
+ const skill = manifest.skills[skillName]
17
+ if (!skill) throw new Error(`${skillName} is not a progressive-disclosure skill`)
18
+ const sources = new Map()
19
+ const entryPath = path.join(skillsRoot, skillName, 'SKILL.md')
20
+ sources.set(`${skillName}/SKILL.md`, fs.readFileSync(entryPath, 'utf8'))
21
+ for (const reference of skill.references) {
22
+ const destination = `${skillName}/${reference.path}`
23
+ sources.set(destination, fs.readFileSync(path.join(skillsRoot, destination), 'utf8'))
24
+ }
25
+
26
+ const ordered = []
27
+ for (const chunk of skill.chunks) {
28
+ let source = sources.get(chunk.destination)
29
+ const openPattern = new RegExp(`<!-- microi-progressive:chunk id=${chunk.id} sha256=[a-f0-9]{64} -->`)
30
+ const match = source.match(openPattern)
31
+ if (!match) throw new Error(`${skillName}: missing chunk ${chunk.id}`)
32
+ const markerStart = match.index
33
+ const markerEnd = markerStart + match[0].length
34
+ const contentStart = markerEnd + (source.startsWith('\r\n', markerEnd) ? 2 : 1)
35
+ const close = '<!-- /microi-progressive:chunk -->'
36
+ const contentEnd = source.indexOf(close, contentStart)
37
+ const raw = source.slice(contentStart, contentEnd)
38
+ const digest = hash(raw)
39
+ source = source.slice(0, markerStart)
40
+ + `<!-- microi-progressive:chunk id=${chunk.id} sha256=${digest} -->`
41
+ + source.slice(markerEnd)
42
+ sources.set(chunk.destination, source)
43
+ chunk.sha256 = digest
44
+ chunk.lines = raw.split(/\r?\n/).length
45
+ ordered[chunk.ordinal] = raw
46
+ }
47
+
48
+ for (const [destination, source] of sources) {
49
+ fs.writeFileSync(path.join(skillsRoot, destination), source, 'utf8')
50
+ }
51
+ const entry = sources.get(`${skillName}/SKILL.md`)
52
+ const begin = entry.indexOf('<!-- microi-progressive:begin -->')
53
+ const prefix = entry.slice(0, begin)
54
+ skill.prefixSha256 = hash(prefix)
55
+ skill.prefixBytes = Buffer.byteLength(prefix)
56
+ skill.originalSha256 = hash(prefix + ordered.join(''))
57
+ skill.originalLines = (prefix + ordered.join('')).split(/\r?\n/).length
58
+ skill.entryLines = entry.split(/\r?\n/).length
59
+ }
60
+
61
+ manifest.generatedAt = new Date().toISOString()
62
+ fs.writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8')
63
+ console.log(`Accepted intentional knowledge updates for: ${requested.join(', ')}`)
64
+
@@ -1,46 +1,46 @@
1
- import crypto from 'node:crypto';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import { fileURLToPath } from 'node:url';
5
-
6
- // 后端只持有自包含的知识快照;规则正文仍以 microi.skills 为唯一可编辑事实源。
7
- const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
8
- const serverRoot = path.resolve(skillsRoot, '../Microi.Server/Microi.AI');
9
- const project = fs.readFileSync(path.join(serverRoot, 'Microi.AI.csproj'), 'utf8');
10
- const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, '.progressive-disclosure-manifest.json'), 'utf8'));
11
- const check = process.argv.includes('--check');
12
- const names = process.argv.slice(2).filter(value => value !== '--check');
13
- if (!names.length) throw new Error('请显式指定本次需要同步的 Skill 名称。');
14
- const stripMarkers = text => text.replace(/<!--\s*\/?microi-progressive:[^>]*-->\r?\n?/g, '');
15
- const digest = text => crypto.createHash('sha256').update(text).digest('hex');
16
- const results = [];
17
-
18
- for (const name of names) {
19
- if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) throw new Error(`无效 Skill 名称:${name}`);
20
- const file = `skill-${name}.md`;
21
- // 不擅自新增程序集资源;只有现有项目明确注册的知识快照可以由此脚本刷新。
22
- if (!project.includes(`Resource\\${file}`)) throw new Error(`后端尚未注册 ${file},请先审阅资源归属。`);
23
- let text = fs.readFileSync(path.join(skillsRoot, name, 'SKILL.md'), 'utf8');
24
- const references = manifest.skills[name]?.references || [];
25
- if (references.length) {
26
- const route = text.indexOf('## 详细参考路由(渐进披露)');
27
- const end = text.indexOf('<!-- microi-progressive:end -->', route);
28
- if (route < 0 || end < route) throw new Error(`${name} 缺少受控参考路由,停止覆盖快照。`);
29
- text = text.slice(0, route) + text.slice(end + '<!-- microi-progressive:end -->'.length);
30
- for (const reference of references) {
31
- const source = path.resolve(skillsRoot, name, reference.path);
32
- const relative = path.relative(path.join(skillsRoot, name), source);
33
- if (relative.startsWith('..') || path.isAbsolute(relative)) throw new Error('参考文件越过 Skill 目录。');
34
- // 平台 AI 读取程序集时不能打开工作区相对路径,必须带上渐进参考的完整正文。
35
- text += `\n\n${fs.readFileSync(source, 'utf8')}`;
36
- }
37
- }
38
- text = `${stripMarkers(text).replace(/\r\n/g, '\n').trimEnd()}\n`;
39
- const target = path.join(serverRoot, 'Resource', file);
40
- const before = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : '';
41
- const changed = before.replace(/\r\n/g, '\n') !== text;
42
- if (changed && !check) fs.writeFileSync(target, text, 'utf8');
43
- results.push({ name, changed, sha256: digest(text) });
44
- }
45
- console.log(JSON.stringify({ check, results }, null, 2));
46
- if (check && results.some(item => item.changed)) process.exitCode = 1;
1
+ import crypto from 'node:crypto';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ // 后端只持有自包含的知识快照;规则正文仍以 microi.skills 为唯一可编辑事实源。
7
+ const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
8
+ const serverRoot = path.resolve(skillsRoot, '../Microi.Server/Microi.AI');
9
+ const project = fs.readFileSync(path.join(serverRoot, 'Microi.AI.csproj'), 'utf8');
10
+ const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, '.progressive-disclosure-manifest.json'), 'utf8'));
11
+ const check = process.argv.includes('--check');
12
+ const names = process.argv.slice(2).filter(value => value !== '--check');
13
+ if (!names.length) throw new Error('请显式指定本次需要同步的 Skill 名称。');
14
+ const stripMarkers = text => text.replace(/<!--\s*\/?microi-progressive:[^>]*-->\r?\n?/g, '');
15
+ const digest = text => crypto.createHash('sha256').update(text).digest('hex');
16
+ const results = [];
17
+
18
+ for (const name of names) {
19
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(name)) throw new Error(`无效 Skill 名称:${name}`);
20
+ const file = `skill-${name}.md`;
21
+ // 不擅自新增程序集资源;只有现有项目明确注册的知识快照可以由此脚本刷新。
22
+ if (!project.includes(`Resource\\${file}`)) throw new Error(`后端尚未注册 ${file},请先审阅资源归属。`);
23
+ let text = fs.readFileSync(path.join(skillsRoot, name, 'SKILL.md'), 'utf8');
24
+ const references = manifest.skills[name]?.references || [];
25
+ if (references.length) {
26
+ const route = text.indexOf('## 详细参考路由(渐进披露)');
27
+ const end = text.indexOf('<!-- microi-progressive:end -->', route);
28
+ if (route < 0 || end < route) throw new Error(`${name} 缺少受控参考路由,停止覆盖快照。`);
29
+ text = text.slice(0, route) + text.slice(end + '<!-- microi-progressive:end -->'.length);
30
+ for (const reference of references) {
31
+ const source = path.resolve(skillsRoot, name, reference.path);
32
+ const relative = path.relative(path.join(skillsRoot, name), source);
33
+ if (relative.startsWith('..') || path.isAbsolute(relative)) throw new Error('参考文件越过 Skill 目录。');
34
+ // 平台 AI 读取程序集时不能打开工作区相对路径,必须带上渐进参考的完整正文。
35
+ text += `\n\n${fs.readFileSync(source, 'utf8')}`;
36
+ }
37
+ }
38
+ text = `${stripMarkers(text).replace(/\r\n/g, '\n').trimEnd()}\n`;
39
+ const target = path.join(serverRoot, 'Resource', file);
40
+ const before = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : '';
41
+ const changed = before.replace(/\r\n/g, '\n') !== text;
42
+ if (changed && !check) fs.writeFileSync(target, text, 'utf8');
43
+ results.push({ name, changed, sha256: digest(text) });
44
+ }
45
+ console.log(JSON.stringify({ check, results }, null, 2));
46
+ if (check && results.some(item => item.changed)) process.exitCode = 1;
@@ -1,57 +1,57 @@
1
- import crypto from 'node:crypto'
2
- import fs from 'node:fs'
3
- import path from 'node:path'
4
- import { fileURLToPath } from 'node:url'
5
-
6
- const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
7
- const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, '.progressive-disclosure-manifest.json'), 'utf8'))
8
- const hash = (value) => crypto.createHash('sha256').update(value).digest('hex')
9
- const lineCount = (value) => value.length === 0 ? 0 : value.split(/\r?\n/).length
10
-
11
- // 可只验证显式修改的 Skill;默认仍检查全库,不能为并行工作区的历史漂移改写共同基线。
12
- const requested = process.argv.slice(2)
13
- for (const name of requested) {
14
- if (!Object.hasOwn(manifest.skills, name)) throw new Error(`Unknown progressive-disclosure skill: ${name}`)
15
- }
16
- const selected = Object.entries(manifest.skills).filter(([name]) => requested.length === 0 || requested.includes(name))
17
- let checkedChunks = 0
18
- for (const [skillName, skill] of selected) {
19
- const entryPath = path.join(skillsRoot, skillName, 'SKILL.md')
20
- const entry = fs.readFileSync(entryPath, 'utf8')
21
- const begin = entry.indexOf('<!-- microi-progressive:begin -->')
22
- if (begin < 0) throw new Error(`${skillName}: missing progressive begin marker`)
23
- const prefix = entry.slice(0, begin)
24
- if (hash(prefix) !== skill.prefixSha256) throw new Error(`${skillName}: entry prefix changed`)
25
- if (lineCount(entry) > manifest.policy.maxEntryLines) throw new Error(`${skillName}: entry exceeds line budget`)
26
-
27
- const sources = new Map([[`${skillName}/SKILL.md`, entry]])
28
- for (const reference of skill.references) {
29
- const relative = `${skillName}/${reference.path}`
30
- const content = fs.readFileSync(path.join(skillsRoot, relative), 'utf8')
31
- if (lineCount(content) > 300) throw new Error(`${relative}: reference exceeds 300 lines`)
32
- sources.set(relative, content)
33
- }
34
-
35
- const ordered = []
36
- for (const chunk of skill.chunks) {
37
- const source = sources.get(chunk.destination)
38
- if (source == null) throw new Error(`${skillName}: missing ${chunk.destination}`)
39
- const open = `<!-- microi-progressive:chunk id=${chunk.id} sha256=${chunk.sha256} -->`
40
- const startMarker = source.indexOf(open)
41
- if (startMarker < 0) throw new Error(`${skillName}: missing chunk ${chunk.id}`)
42
- const contentStart = startMarker + open.length + (source.startsWith('\r\n', startMarker + open.length) ? 2 : 1)
43
- const close = '<!-- /microi-progressive:chunk -->'
44
- const contentEnd = source.indexOf(close, contentStart)
45
- if (contentEnd < 0) throw new Error(`${skillName}: unterminated chunk ${chunk.id}`)
46
- const raw = source.slice(contentStart, contentEnd)
47
- if (hash(raw) !== chunk.sha256) throw new Error(`${skillName}: chunk ${chunk.id} changed`)
48
- ordered[chunk.ordinal] = raw
49
- checkedChunks += 1
50
- }
51
- const reconstructed = prefix + ordered.join('')
52
- if (hash(reconstructed) !== skill.originalSha256) {
53
- throw new Error(`${skillName}: reconstructed knowledge differs from original`)
54
- }
55
- }
56
-
57
- console.log(`Validated ${selected.length} skills and ${checkedChunks} lossless chunks${requested.length ? ' (explicit scope)' : ''}.`)
1
+ import crypto from 'node:crypto'
2
+ import fs from 'node:fs'
3
+ import path from 'node:path'
4
+ import { fileURLToPath } from 'node:url'
5
+
6
+ const skillsRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
7
+ const manifest = JSON.parse(fs.readFileSync(path.join(skillsRoot, '.progressive-disclosure-manifest.json'), 'utf8'))
8
+ const hash = (value) => crypto.createHash('sha256').update(value).digest('hex')
9
+ const lineCount = (value) => value.length === 0 ? 0 : value.split(/\r?\n/).length
10
+
11
+ // 可只验证显式修改的 Skill;默认仍检查全库,不能为并行工作区的历史漂移改写共同基线。
12
+ const requested = process.argv.slice(2)
13
+ for (const name of requested) {
14
+ if (!Object.hasOwn(manifest.skills, name)) throw new Error(`Unknown progressive-disclosure skill: ${name}`)
15
+ }
16
+ const selected = Object.entries(manifest.skills).filter(([name]) => requested.length === 0 || requested.includes(name))
17
+ let checkedChunks = 0
18
+ for (const [skillName, skill] of selected) {
19
+ const entryPath = path.join(skillsRoot, skillName, 'SKILL.md')
20
+ const entry = fs.readFileSync(entryPath, 'utf8')
21
+ const begin = entry.indexOf('<!-- microi-progressive:begin -->')
22
+ if (begin < 0) throw new Error(`${skillName}: missing progressive begin marker`)
23
+ const prefix = entry.slice(0, begin)
24
+ if (hash(prefix) !== skill.prefixSha256) throw new Error(`${skillName}: entry prefix changed`)
25
+ if (lineCount(entry) > manifest.policy.maxEntryLines) throw new Error(`${skillName}: entry exceeds line budget`)
26
+
27
+ const sources = new Map([[`${skillName}/SKILL.md`, entry]])
28
+ for (const reference of skill.references) {
29
+ const relative = `${skillName}/${reference.path}`
30
+ const content = fs.readFileSync(path.join(skillsRoot, relative), 'utf8')
31
+ if (lineCount(content) > 300) throw new Error(`${relative}: reference exceeds 300 lines`)
32
+ sources.set(relative, content)
33
+ }
34
+
35
+ const ordered = []
36
+ for (const chunk of skill.chunks) {
37
+ const source = sources.get(chunk.destination)
38
+ if (source == null) throw new Error(`${skillName}: missing ${chunk.destination}`)
39
+ const open = `<!-- microi-progressive:chunk id=${chunk.id} sha256=${chunk.sha256} -->`
40
+ const startMarker = source.indexOf(open)
41
+ if (startMarker < 0) throw new Error(`${skillName}: missing chunk ${chunk.id}`)
42
+ const contentStart = startMarker + open.length + (source.startsWith('\r\n', startMarker + open.length) ? 2 : 1)
43
+ const close = '<!-- /microi-progressive:chunk -->'
44
+ const contentEnd = source.indexOf(close, contentStart)
45
+ if (contentEnd < 0) throw new Error(`${skillName}: unterminated chunk ${chunk.id}`)
46
+ const raw = source.slice(contentStart, contentEnd)
47
+ if (hash(raw) !== chunk.sha256) throw new Error(`${skillName}: chunk ${chunk.id} changed`)
48
+ ordered[chunk.ordinal] = raw
49
+ checkedChunks += 1
50
+ }
51
+ const reconstructed = prefix + ordered.join('')
52
+ if (hash(reconstructed) !== skill.originalSha256) {
53
+ throw new Error(`${skillName}: reconstructed knowledge differs from original`)
54
+ }
55
+ }
56
+
57
+ console.log(`Validated ${selected.length} skills and ${checkedChunks} lossless chunks${requested.length ? ' (explicit scope)' : ''}.`)
@@ -1,75 +1,75 @@
1
- ---
2
- name: search-engine
3
- description: Microi 搜索引擎索引、同步、查询与安全规范。用于 Elasticsearch 表索引、增量同步、字段映射、SearchAfter 分页、租户与菜单数据范围、重建和多节点验收。
4
- ---
5
-
6
- > **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
7
-
8
- # Microi SearchEngine
9
-
10
- ## 能力与事实源
11
-
12
- 搜索引擎提供建索引/全量同步、单文档新增修改删除、字段映射、查询和 `SearchAfter` 深分页。数据库仍是业务事实源,搜索索引是可重建的读模型,不能直接作为权限、余额、库存或审批状态事实。
13
-
14
- ## 租户隔离
15
-
16
- - 索引名必须包含规范化 `OsClient` 和表标识,禁止不同租户共用无过滤索引。
17
- - V8/HTTP 调用的 `OsClient` 必须由 Token/服务端上下文确定,不能信任 Query/Body。
18
- - 搜索服务连接、用户名和密码只从服务端 SaaS 配置读取,不进入前端 `SysConfig`、V8 返回或日志。
19
-
20
- ## 索引流程
21
-
22
- 1. 读取 `diy_table/diy_field` 确定可搜索字段、类型和分词需求。
23
- 2. 先扩展索引映射,再开始双写/增量同步。
24
- 3. 全量回填使用稳定游标或主键分页,记录 checkpoint。
25
- 4. 对账数据库数量、抽样字段和删除记录。
26
- 5. 切换读流量后保留旧索引回滚窗口。
27
-
28
- 可用的服务端方法包括 `AsyncIndex`、`AsyncTableDataToIndex`、`AddDocument`、`UpdateDocument`、`DeleteDocument`、`AddField`、`GetSearchResponse`。
29
-
30
- ## 查询安全
31
-
32
- - 用户关键词作为值参数,不允许决定索引名、任意字段、脚本或原始 DSL。
33
- - 排序字段从白名单映射;限制 `PageSize`、高亮长度和聚合桶数量。
34
- - 普通用户的菜单 `SqlWhere`/行级范围不会天然出现在 Elasticsearch 查询中。必须将服务端计算出的允许记录范围同步为可过滤字段,或先取得授权 Id 集合再查询;不能搜索后再在前端过滤。
35
- - 敏感字段不入索引,或使用独立受控索引;日志只记录 trace id、耗时和计数。
36
-
37
- ## 同步可靠性
38
-
39
- 数据库写成功、索引写失败时使用 outbox 事件,`EventId` 全局唯一。消费端按事件 Id 幂等;删除使用 tombstone。索引更新失败不能回滚已经提交的业务事务,应告警并重试。
40
-
41
- 全量重建和增量消费可能在多个节点同时运行,需分布式租约与 checkpoint 条件更新;本机静态标志不能作为“正在重建”的事实。
42
-
43
- ## 查询示例
44
-
45
- ```csharp
46
- var result = await search.GetSearchResponse(new MicroiSearchEngineParam
47
- {
48
- OsClient = osClient,
49
- TableName = "Diy_Product",
50
- Keyword = keyword,
51
- PageSize = Math.Min(pageSize, 100),
52
- Sorts = new List<MicroiSearchEngineSortModel>
53
- {
54
- new MicroiSearchEngineSortModel { Field = "UpdateTime", Order = "desc" }
55
- }
56
- });
57
- ```
58
-
59
- 字段名与排序必须在进入此对象前经过服务端白名单。
60
-
61
- ## MCP/交付流程
62
-
63
- - 先用 `microi_get_db_schema` 和菜单元数据确认字段与权限。
64
- - 搜索配置写入后回读实际索引名、字段映射和租户连接。
65
- - 用管理员、普通有权限用户、无权限用户和另一个租户验收。
66
- - 覆盖全量重建中断、重复事件、删除、滚动升级、搜索服务短暂故障。
67
-
68
- ## 验收清单
69
-
70
- - [ ] 索引按租户隔离,跨租户搜索为零
71
- - [ ] 菜单/行级范围在查询前生效
72
- - [ ] 字段、排序、分页、聚合均有白名单和上限
73
- - [ ] 数据库与索引可对账、可重建
74
- - [ ] outbox 重试幂等,无永久漏同步
75
- - [ ] 密钥和敏感字段不进入前端/日志/索引
1
+ ---
2
+ name: search-engine
3
+ description: Microi 搜索引擎索引、同步、查询与安全规范。用于 Elasticsearch 表索引、增量同步、字段映射、SearchAfter 分页、租户与菜单数据范围、重建和多节点验收。
4
+ ---
5
+
6
+ > **Microi吾码基础规范(强制):** 任何 AI 模型与宿主每次新建或接续吾码任务,先完整读取 `../workspace-conventions/SKILL.md`,必须执行版本播报、`@microi.net/cli` 后台自动升级、Skills/MCP 同步和进度播报。安装与诊断读取 `../microi-codex-installer/SKILL.md`;更新失败延后重试,不阻断当前工作。
7
+
8
+ # Microi SearchEngine
9
+
10
+ ## 能力与事实源
11
+
12
+ 搜索引擎提供建索引/全量同步、单文档新增修改删除、字段映射、查询和 `SearchAfter` 深分页。数据库仍是业务事实源,搜索索引是可重建的读模型,不能直接作为权限、余额、库存或审批状态事实。
13
+
14
+ ## 租户隔离
15
+
16
+ - 索引名必须包含规范化 `OsClient` 和表标识,禁止不同租户共用无过滤索引。
17
+ - V8/HTTP 调用的 `OsClient` 必须由 Token/服务端上下文确定,不能信任 Query/Body。
18
+ - 搜索服务连接、用户名和密码只从服务端 SaaS 配置读取,不进入前端 `SysConfig`、V8 返回或日志。
19
+
20
+ ## 索引流程
21
+
22
+ 1. 读取 `diy_table/diy_field` 确定可搜索字段、类型和分词需求。
23
+ 2. 先扩展索引映射,再开始双写/增量同步。
24
+ 3. 全量回填使用稳定游标或主键分页,记录 checkpoint。
25
+ 4. 对账数据库数量、抽样字段和删除记录。
26
+ 5. 切换读流量后保留旧索引回滚窗口。
27
+
28
+ 可用的服务端方法包括 `AsyncIndex`、`AsyncTableDataToIndex`、`AddDocument`、`UpdateDocument`、`DeleteDocument`、`AddField`、`GetSearchResponse`。
29
+
30
+ ## 查询安全
31
+
32
+ - 用户关键词作为值参数,不允许决定索引名、任意字段、脚本或原始 DSL。
33
+ - 排序字段从白名单映射;限制 `PageSize`、高亮长度和聚合桶数量。
34
+ - 普通用户的菜单 `SqlWhere`/行级范围不会天然出现在 Elasticsearch 查询中。必须将服务端计算出的允许记录范围同步为可过滤字段,或先取得授权 Id 集合再查询;不能搜索后再在前端过滤。
35
+ - 敏感字段不入索引,或使用独立受控索引;日志只记录 trace id、耗时和计数。
36
+
37
+ ## 同步可靠性
38
+
39
+ 数据库写成功、索引写失败时使用 outbox 事件,`EventId` 全局唯一。消费端按事件 Id 幂等;删除使用 tombstone。索引更新失败不能回滚已经提交的业务事务,应告警并重试。
40
+
41
+ 全量重建和增量消费可能在多个节点同时运行,需分布式租约与 checkpoint 条件更新;本机静态标志不能作为“正在重建”的事实。
42
+
43
+ ## 查询示例
44
+
45
+ ```csharp
46
+ var result = await search.GetSearchResponse(new MicroiSearchEngineParam
47
+ {
48
+ OsClient = osClient,
49
+ TableName = "Diy_Product",
50
+ Keyword = keyword,
51
+ PageSize = Math.Min(pageSize, 100),
52
+ Sorts = new List<MicroiSearchEngineSortModel>
53
+ {
54
+ new MicroiSearchEngineSortModel { Field = "UpdateTime", Order = "desc" }
55
+ }
56
+ });
57
+ ```
58
+
59
+ 字段名与排序必须在进入此对象前经过服务端白名单。
60
+
61
+ ## MCP/交付流程
62
+
63
+ - 先用 `microi_get_db_schema` 和菜单元数据确认字段与权限。
64
+ - 搜索配置写入后回读实际索引名、字段映射和租户连接。
65
+ - 用管理员、普通有权限用户、无权限用户和另一个租户验收。
66
+ - 覆盖全量重建中断、重复事件、删除、滚动升级、搜索服务短暂故障。
67
+
68
+ ## 验收清单
69
+
70
+ - [ ] 索引按租户隔离,跨租户搜索为零
71
+ - [ ] 菜单/行级范围在查询前生效
72
+ - [ ] 字段、排序、分页、聚合均有白名单和上限
73
+ - [ ] 数据库与索引可对账、可重建
74
+ - [ ] outbox 重试幂等,无永久漏同步
75
+ - [ ] 密钥和敏感字段不进入前端/日志/索引
@@ -1,4 +1,4 @@
1
- interface:
2
- display_name: "搜索引擎"
3
- short_description: "配置租户隔离的索引、同步、查询、重建、权限过滤和故障恢复"
4
- default_prompt: "使用 $search-engine 设计并验收当前 Microi 搜索能力。"
1
+ interface:
2
+ display_name: "搜索引擎"
3
+ short_description: "配置租户隔离的索引、同步、查询、重建、权限过滤和故障恢复"
4
+ default_prompt: "使用 $search-engine 设计并验收当前 Microi 搜索能力。"