@whyshu/argent-engine 0.8.0-rc.7 → 0.8.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.json +17 -16
- package/engine/VERSION +1 -1
- package/engine/core/contracts/argent.contracts.json +2 -2
- package/engine/core/contracts/verbs.schema.json +64 -1
- package/engine/core/lib/contract.mjs +30 -0
- package/engine/core/mcp/server.mjs +171 -2
- package/engine/scripts/build-doc-index.mjs +68 -0
- package/engine/scripts/capability-packs.lock.json +24 -24
- package/engine/scripts/check-docs-drift.mjs +51 -4
- package/engine/scripts/ci-run.sh +2 -2
- package/engine/scripts/doc-status.mjs +212 -0
- package/engine/scripts/flow-requirements.json +4 -4
- package/engine/scripts/ml-ads.mjs +181 -0
- package/engine/scripts/ml-oauth-setup.mjs +1 -1
- package/engine/scripts/orchestrator.py +4 -4
- package/engine/scripts/s1-audit.mjs +4 -1
- package/engine/scripts/ziniao-auth-probe.sh +5 -5
- package/engine/version.mjs +1 -1
- package/engine/verticals/_engine-words.baseline.txt +16 -2
- package/package.json +1 -1
- package/engine/scripts/huangwei-preflight.sh +0 -42
- package/engine/scripts/publish-release-0.8.0-rc.4.sh +0 -18
- package/engine/scripts/verify-release-0.8.0-rc.4.sh +0 -16
package/MANIFEST.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@whyshu/argent-engine",
|
|
4
4
|
"files": {
|
|
5
|
-
"VERSION": "
|
|
5
|
+
"VERSION": "1598d36aed9b1a07bac85dcb4e6da51a895c346f2e03a55861906e6c92ee8c62",
|
|
6
6
|
"agents/catalog.json": "5356a812f2554dfd3115370363d4c3f787a82c9e5928a85d05b2a07c9e4b324d",
|
|
7
7
|
"configs/_aliases.proposed.json": "3a59edf80563bcc20d410d488decad6fd787bd3de9489321367b0783904cd3e5",
|
|
8
8
|
"configs/_migration-plan.proposed.json": "dd9f90b0b9b2f217dd23367a618402e57997d44f7fddcfa88a7cadf52e056c0d",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"configs/hr.json": "59c0ea732139e7f54f04dce7595825b778b36f450e5ae5049d1326562388f7b8",
|
|
13
13
|
"configs/notify.json": "cb9ef11c1c498fcf99af99ec50271b8a2598061b77ed73a6099032e837474ef0",
|
|
14
14
|
"core/cli/argent.mjs": "9a8977324c238ca4e20435f9817eb7ec76157da32b1d510977dc03e0feb416a9",
|
|
15
|
-
"core/contracts/argent.contracts.json": "
|
|
16
|
-
"core/contracts/verbs.schema.json": "
|
|
15
|
+
"core/contracts/argent.contracts.json": "8dba5b21612f2cf1d8fe56b34cb4e5b08ea7daae5e2f3308afb4912b6a618ff4",
|
|
16
|
+
"core/contracts/verbs.schema.json": "54d726181c11536eb30bd25090584a7af103e4c0462f8ef078053c8177e19dcb",
|
|
17
17
|
"core/lib/argent-datadir.mjs": "1fdd799c933382c4f9e36bd4af33d51b8ac4a466a9d67a8f2296bb267b5251ac",
|
|
18
18
|
"core/lib/audit.mjs": "b57c233b1926e4ce4686604bbd2fdda33fdd432083828e589c5652606c63ba75",
|
|
19
19
|
"core/lib/claim.mjs": "0ab5cfa554446c2c870931e58a2eb51930eb9a136afde01a9de962ac1b2d4287",
|
|
20
20
|
"core/lib/config-catalog.mjs": "26fe694a466b8980a1e678a7112e0eb87f61a80ed012b2e509ec10ed21706ebe",
|
|
21
|
+
"core/lib/contract.mjs": "3c7493ebd793fc0f997e2d829e4d2b3756f08002a114183939aac93f1278deab",
|
|
21
22
|
"core/lib/doctor-customer.mjs": "e5de767218dacaf5fc2ac8d385c3adbfefa82848dfc6acf2bd3124c1755581e9",
|
|
22
23
|
"core/lib/flow-list.mjs": "8f91b3c796d6724cf05ee938fb4f40da04a12831b896be94a6f3ec66998edfea",
|
|
23
24
|
"core/lib/flow-registry.mjs": "5c4203016cad7bebb39ab87296f87f17390c48a52ab47256d6c595b3c76012ab",
|
|
@@ -41,7 +42,7 @@
|
|
|
41
42
|
"core/lib/versions.mjs": "9e9fda66d9ad63913604d50407565311081453830fe181be096f106d0f3903a7",
|
|
42
43
|
"core/mcp/client.mjs": "291b891b51f512de808f512d245a02ca0370afc643bf1acac7a3e20cf217d5a1",
|
|
43
44
|
"core/mcp/http.mjs": "4388cdb18128844a45313ed4721cbb6ecfcfa683b59ca91b45c9a84ccaeec437",
|
|
44
|
-
"core/mcp/server.mjs": "
|
|
45
|
+
"core/mcp/server.mjs": "c4a6e1dbfecd5a476ddd9b0266546d89e0011d8d6518a5dc9a3889d748c01ff5",
|
|
45
46
|
"scripts/_engine_rules_probe.py": "ad8f45dc0f37852259461a25fb648b11df818089ba40f980dfa72b7e201a03d9",
|
|
46
47
|
"scripts/analyze-full-day.py": "2ee87f3f27929cd9407109121e670b56c296f39b0a3e18b075524b54a7d4471c",
|
|
47
48
|
"scripts/appointment-create.mjs": "3448966cebc767160cb151a27ccf2b6f6439c80f970f769621058871f95433cc",
|
|
@@ -63,8 +64,9 @@
|
|
|
63
64
|
"scripts/audit-all.mjs": "54c21512dc7c192fba21e45aab19502e070fecc4d0686fabb1fbdba0d7140794",
|
|
64
65
|
"scripts/base-bootstrap.sh": "d44361618f808533fc11e8acdbccf5dfa53822a745e7c7a84bbd09885f6d6c2e",
|
|
65
66
|
"scripts/billing-mode-daily.sh": "830e2dca9f362d1098239111479794a68d4a34071242daaeb04c36cf858cd175",
|
|
67
|
+
"scripts/build-doc-index.mjs": "cc8fc3b4defff20df345c377229101ffd6efef028e4b6a27232de6d3246789ec",
|
|
66
68
|
"scripts/build-engine-package.mjs": "de31b4441ad5e19262cde3d6258f0abc05cd065219165586b0e6c1343f5df544",
|
|
67
|
-
"scripts/capability-packs.lock.json": "
|
|
69
|
+
"scripts/capability-packs.lock.json": "dc7325bf351394d86cc9432567d510b94a8b76001f62df040ffa5fda1ee3ddce",
|
|
68
70
|
"scripts/capability_pack.py": "d21bca70deadab6bb818a3f2e12721c7eeb1c690bb382daae752620db8db5cb3",
|
|
69
71
|
"scripts/check-1.0-criteria.mjs": "8fe145a83c4060c51a678eb2586b87a78b66d1456cebc95c52f7789aeb181c66",
|
|
70
72
|
"scripts/check-agent-catalog.mjs": "340be84cfad2f3cd7049545e6c953c9ce54523bdf6ad60dff1ad7925293821bc",
|
|
@@ -72,7 +74,7 @@
|
|
|
72
74
|
"scripts/check-billing-mode.sh": "223bdec2370adbd0ee626e645a240bda7a806343c5bc19139b09df01f71ff918",
|
|
73
75
|
"scripts/check-child-sessions.mjs": "eed280e629c87a581d1520fdab4eb5fec544e17a064ea38f174be450678e8eee",
|
|
74
76
|
"scripts/check-config-catalog.mjs": "0032fd3fcddf7b9e429df990036b536ee361f6b7a6d05982028a177d670ee70a",
|
|
75
|
-
"scripts/check-docs-drift.mjs": "
|
|
77
|
+
"scripts/check-docs-drift.mjs": "e6b0c5a2261d52a546dad5ec24d647a2de7b0cc714bf4b86a94f00f14f293e5e",
|
|
76
78
|
"scripts/check-dsh-web-expose.sh": "5e7bc6e844925b3a90605e3466419671ae46bfe418246fdef97ef28fabeb20db",
|
|
77
79
|
"scripts/check-judgment-drift.mjs": "7f9b8ddbdc08b492c45f6a14a6608a35b78a93f0de05fbbf235a4309e7976293",
|
|
78
80
|
"scripts/check-license.mjs": "87b651ecb49f806725e56a589f674386e07f6f7b2ae68e752f4d8b6e1586f42f",
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
"scripts/check-sop-consistency.mjs": "81b85e31b3436895cfdbea54fd06345f8e53354d3b3b6426d337e4268fe47220",
|
|
88
90
|
"scripts/check-test-env-safety.mjs": "7050d08972277a4d8b5c01e2ae16b96c6f45ad289e12d039948e3b6b3a2d95cc",
|
|
89
91
|
"scripts/check-version-consistency.mjs": "621b4f58c0f7e3689fa663173f13830fa82fe5690b63fb64b3891553ae9b22e9",
|
|
90
|
-
"scripts/ci-run.sh": "
|
|
92
|
+
"scripts/ci-run.sh": "9c0562c37963a86f4229f9864c12fafbd192a33c6cef1ef9f976aa0193dbe541",
|
|
91
93
|
"scripts/collect-evidence.mjs": "92cfcd5a940f77c00bd710884012b79503dd6887d3ed5e0c0dff2d4f90f8c9d7",
|
|
92
94
|
"scripts/config-explain.mjs": "7d17980ab2fb17cad0deacc529650554e09b50d37af0aa43b7b29af3ffa8fffc",
|
|
93
95
|
"scripts/configure-provider.rb": "cc84e2a714885a1f3ccaef9c4042cf72072d49a5b4538f1681fe7df2ab037315",
|
|
@@ -108,6 +110,7 @@
|
|
|
108
110
|
"scripts/delivery-faces.txt": "385fc67bbd8100b6e7ecc870f2ae95d8bdf18b34e18df6b60589a98a332e4f7d",
|
|
109
111
|
"scripts/desktop-trial.sh": "fde663b5b94f934d4f71769ed1d6876141022f264753862997126fd8f7b8fab2",
|
|
110
112
|
"scripts/dev-window.sh": "09a98babff27d2f30048326339603cc926571a2e52befabbda186ed14ff14b16",
|
|
113
|
+
"scripts/doc-status.mjs": "8bc295b2252487464b8785e77d11fa970310873b2b4f431f6580728c7697a34b",
|
|
111
114
|
"scripts/drill-clean-room.sh": "e835d24d5762a6bb5a06e880fb05ca2f561de8c451b5f28f0ec74217b92dd395",
|
|
112
115
|
"scripts/drill-handover.sh": "d6210a68612656604edbb2745f5084f73e4f0069e5f8109c203b76e1e08981ed",
|
|
113
116
|
"scripts/dsh-api-client.mjs": "5065560c8f2f8e77ad44ac6f300bb79417047a54cc7f3796ce4e926d6a4fc389",
|
|
@@ -137,7 +140,7 @@
|
|
|
137
140
|
"scripts/final-check.mjs": "45e2004e778c83fe08b35921a555b2ca57ddb375672cc965544ef1bb6ff10aa8",
|
|
138
141
|
"scripts/fix-skill-frontmatter.py": "c77cb8d389bd96bc40655bbdd712435bfb06f74453a2f54dad58013f615ea748",
|
|
139
142
|
"scripts/flow-auto-retry.py": "2474e649e2e7c2803c3140b5c0780648059d3aadae299ea77a706a552b1fab63",
|
|
140
|
-
"scripts/flow-requirements.json": "
|
|
143
|
+
"scripts/flow-requirements.json": "11aac2fa16a49ecdebe211c9b30bfed6b40ee1cce179411d00a383c2f64f5ee6",
|
|
141
144
|
"scripts/flow-scaffold.py": "d886e4e5d5cf0e80991d1d1a40e54a7281d87fec7c781c89101277795e401ae1",
|
|
142
145
|
"scripts/flow-session-retention.mjs": "a9a2d261dce959bcd0eb26361413b9fc10fd1cbd562f86c614face66861c9793",
|
|
143
146
|
"scripts/flow-timers-plist.sh": "a7b1007526fe21923566a002ef4e50fade5cbcdef38799f1a52e50c7b9c21131",
|
|
@@ -172,7 +175,6 @@
|
|
|
172
175
|
"scripts/gen-agent-bundles.mjs": "3ab452fb7b1026a1bfab02977c85229985b390db4bc8458ce974b94bc207ed17",
|
|
173
176
|
"scripts/gen-preset-rows.mjs": "86f291eef79174c9946df758e6a4f546b9dd1b8f96e8a8e1fb502a219b5981e1",
|
|
174
177
|
"scripts/handover-sheet.mjs": "4e27095ccdd79586391abf7a7d5eb7aabbc3f0d7d9a1dd5161e9af8e8a9338de",
|
|
175
|
-
"scripts/huangwei-preflight.sh": "755bdd49b29d542c699379ac99cd30923263505de50b074fa132f45545666e3f",
|
|
176
178
|
"scripts/init-ml.sh": "c5a04fc723a4b254d7d92990ca31adb1100de666821e3a236285aaf3516453f7",
|
|
177
179
|
"scripts/install-license.mjs": "6bac5b31647f1e84300fb54711e6852f978ce056d5b0c9ad706a25003ff2d4f9",
|
|
178
180
|
"scripts/integration_contract.py": "d44690ef41769999db2dbdaac6294ff6655678c2f60f134b9ee3b4776dcb73c8",
|
|
@@ -237,7 +239,8 @@
|
|
|
237
239
|
"scripts/login-readiness.py": "5e920dddc669bb2d93540283c0ead7e8d7f9a260c765600f656d108d1e934875",
|
|
238
240
|
"scripts/migrate-providers.mjs": "1effa539f8d23054f18c0de5219b111a4fe2da55f2ee873ca8dac6d4418578cb",
|
|
239
241
|
"scripts/migrate-skills.sh": "2ff1f12b80135d27d275d9809e8f1721b6f0f725b1a951c62f3d8a03b3bec5fa",
|
|
240
|
-
"scripts/ml-
|
|
242
|
+
"scripts/ml-ads.mjs": "3ab5204f70b72cfe1f3e0dee18016d1e6db082d998af46d3f7a9772344eacaed",
|
|
243
|
+
"scripts/ml-oauth-setup.mjs": "bbeed80575f075e292953970831e25d634e662ab374cf00e0a8c88ee65acfc13",
|
|
241
244
|
"scripts/ml-store-ids.json": "0c5d8672ff451bc84eb833f644ef67fc46ec45a5e057cb57a6934202add60964",
|
|
242
245
|
"scripts/ml_artifact_attribution.py": "e7aa6c87b24c8532f34151cc95bb7e937fcebebd00ad414c95549e0a0cc6cb22",
|
|
243
246
|
"scripts/ml_capacity_probe.py": "1000b23070ede4a21d918f60023be13a3df934d2c99ef03ee99ece49d0998b35",
|
|
@@ -246,7 +249,7 @@
|
|
|
246
249
|
"scripts/ml_store_ids.py": "133e520e0019fae03a3daa5766352a390cf104ddbaaf228a51264a6a5fdd2493",
|
|
247
250
|
"scripts/npm-publish-argent.mjs": "f3068945bcd6e659414bcd396d08940ed4b80f7ed296dd0cebf9138325526d26",
|
|
248
251
|
"scripts/npm-publish-argent.sh": "9e54b17b011bbaaffdc9dfdded18196d83fc00363c405179e5ec45beb712c555",
|
|
249
|
-
"scripts/orchestrator.py": "
|
|
252
|
+
"scripts/orchestrator.py": "b959f67e217c38cdc79de9ff995c6bf4e5b944538e91c570fb2558789c5d6c86",
|
|
250
253
|
"scripts/orchestrator_br.py": "502737d260eb9054b71968fa99076d15dde2b654470697be82ff0dd872034db7",
|
|
251
254
|
"scripts/p2-report-run.mjs": "86bd6b3005f1a5fca3f808f4ea77dcce43a11a4a9be7ee814a029daaae201fb5",
|
|
252
255
|
"scripts/pack-plugins.mjs": "b1b42fb30ebd27f320af72bc28b5b8e2b76e54031b4ac1ba5c3909374990b38b",
|
|
@@ -270,7 +273,6 @@
|
|
|
270
273
|
"scripts/provider-select.sh": "329067c03cd30ba5f05a72e0319087f4e803dd18d9acf2dc790a5ab7410c209b",
|
|
271
274
|
"scripts/provider-switch.sh": "42b369100d8a190741efab34c68e4d8488ce70f142251d994b4a8db560905a0a",
|
|
272
275
|
"scripts/provider-sync-target.check.mjs": "f4a1fcb2724724f895053d2401b6f3701a76594f8dbec3f3045db66901f3f135",
|
|
273
|
-
"scripts/publish-release-0.8.0-rc.4.sh": "e7a76f72c3743d5d6ca473fb2161712be90f92f35921723b5288c302bf903ae0",
|
|
274
276
|
"scripts/python-runtime.sh": "7831db3ec43e8f9a5cdf519aa50960918c2f7126992494626b7886e219db4967",
|
|
275
277
|
"scripts/query_runner.py": "9bc16e2c3b030cde901a7f680e68499d15f412ef3317e7936fbaeab021412a16",
|
|
276
278
|
"scripts/release-argent.sh": "f6cec78ce4c5c4ecd18dc66771148a3780c90ac427c9fac3742e84cabf3a2b3c",
|
|
@@ -278,7 +280,7 @@
|
|
|
278
280
|
"scripts/repair-unresolved-tools.mjs": "bcdeb4a1fe9544a304248880804e29a0dccf251d93eeea1a7608e2aa4e03f10a",
|
|
279
281
|
"scripts/retire-inventory.mjs": "c9dda33d9ac741a45459bbf8088e3a50f8eb2bed83cc819ef850e780d7bf8c09",
|
|
280
282
|
"scripts/run-tests.sh": "4297f8d5309a6c2ee15e9db1a894c43051c1a5bbe0e1a9fcfef36f2773ff2bcd",
|
|
281
|
-
"scripts/s1-audit.mjs": "
|
|
283
|
+
"scripts/s1-audit.mjs": "dca6dba62a23456d950667cbbdfe94f349554c2cb2770992ffbe2261e74ab2b4",
|
|
282
284
|
"scripts/self-sign-license.mjs": "c43327da00d69ca316e7b06f2ca0259a5cc730151d90b6d6316f345358b69cbe",
|
|
283
285
|
"scripts/session-handoff.mjs": "fba664be803195a5c64b7f64f6a58bcfc7836c91a290b35fee778119b3dcb262",
|
|
284
286
|
"scripts/session-health-scan.mjs": "2afa85fa60f788ff93d7cd41822f1309fd5e26e433cfe80bbcbf52cf6951ef4a",
|
|
@@ -296,7 +298,6 @@
|
|
|
296
298
|
"scripts/usage-anchor.sh": "20b9b4eb6815ed057bcdde06d1284780b7d5a383c62de9eb48ac7182dfbd4536",
|
|
297
299
|
"scripts/usage_report.py": "ad1ee4e92c3e33a040a84a15818570eab3a0e94d627b9be78df5615b58257e59",
|
|
298
300
|
"scripts/validate-preset-schema.mjs": "2bb5fda6eab5bef7780fed77c3c914b52bc22e640e902507a96397ff03e9ace9",
|
|
299
|
-
"scripts/verify-release-0.8.0-rc.4.sh": "f06681d24b69e02469eac5b37ee521b47f36c353cbd5b366db67d8febf6055d8",
|
|
300
301
|
"scripts/vertical-init.mjs": "b4f63d71152a84b095cf011d680abbe50a7bf8d6a9f925cd38d2874a71995e09",
|
|
301
302
|
"scripts/vertical-lint.mjs": "c171a5cf7862c00e7db650094a2e33a5174b5b237c17a1ca7792f76b09cf2550",
|
|
302
303
|
"scripts/wenyao-browser.sh": "89d079ee636a234cafc06ead9cc83833216197b73b85138f6c51ec9b1c13a715",
|
|
@@ -317,7 +318,7 @@
|
|
|
317
318
|
"scripts/win/dsh-web-autostart.ps1": "ade472a02d9feb42f56dc6cd1759aff2472d410e7c8b25031b82d5b59e9559ab",
|
|
318
319
|
"scripts/xzh-browser.sh": "fd56f59d3a1ade6924cf3fc9dc6e5598b4872d7ba3a8653f843b208b8c32a810",
|
|
319
320
|
"scripts/xzh_browser.py": "aad77b4ba617cf6fff84d8b9239672336d2a5aa81f99c4f71941345fdf9a7cb9",
|
|
320
|
-
"scripts/ziniao-auth-probe.sh": "
|
|
321
|
+
"scripts/ziniao-auth-probe.sh": "a3332aa24039d4df4e14d24e597ffdd57486c1dcc33cc56879346217281da1ac",
|
|
321
322
|
"scripts/ziniao-keepalive.sh": "2e22f07972e3e2eab4dc65aaacbf570c0975dbd2f90cd2c9a886575221a24c49",
|
|
322
323
|
"scripts/ziniao-post-upgrade-check.sh": "d61c4fae39ab2e1bf4ffc3c7732305a1a600652a79df6b204864601feb5d3a31",
|
|
323
324
|
"scripts/ziniao-windows.sh": "6bbc218e216ec23b7ecc90f318f09535a76bb4c330475168da5d2512da8bd5ad",
|
|
@@ -357,7 +358,7 @@
|
|
|
357
358
|
"tools/agentic/mcp_server.py": "4c3e66e6a8f8a4571339045dc4ccc255288557115a06ff42bd60a4c79b696feb",
|
|
358
359
|
"tools/agentic/ml_agent_tools.py": "b080d439ababf0ea375ae498a534f6c9761f8fce799b79d44991e830e6ca8dbc",
|
|
359
360
|
"verticals/README.md": "5618cb80cd8db5cda216ebbed913e03bf640b8460650fb2f99e86c58c773604e",
|
|
360
|
-
"verticals/_engine-words.baseline.txt": "
|
|
361
|
+
"verticals/_engine-words.baseline.txt": "e5a871722f1fab58e69830469d301fd59ff075bf471233119770b31292651073",
|
|
361
362
|
"verticals/_engine-words.json": "656f2b306a83d65da58f0fe28cd4032e55fffc1cf93398aa36c126aa5686f06b",
|
|
362
363
|
"verticals/mercadolibre/README.md": "b25b243ee925cb1ce8331ce550d3b41a706e0b62d42343025160ad5d68a80d24",
|
|
363
364
|
"verticals/mercadolibre/brazil-full-sop.json": "722630b859d7a1c42ab3a243cae75598bf92a562663d9ebe376afd093f02bbfb",
|
package/engine/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.0-rc.
|
|
1
|
+
0.8.0-rc.9
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"argentVersion": "0.8.0-rc.
|
|
2
|
+
"argentVersion": "0.8.0-rc.9",
|
|
3
3
|
"_syncNote": "argentVersion 必须与仓库根 VERSION 同批更新:发布前置校验 scripts/release-argent.sh(1a2)+ CI 判据 `contracts`/`version-consistency`;2026-10-21 已按当前 VERSION 校正(修复前曾停在旧版本)。",
|
|
4
4
|
"principle": "宿主无关:宿主只依赖 `argent <verb>`;确定性逻辑在 CLI/MCP,不在提示词里。",
|
|
5
5
|
"verbs": {
|
|
@@ -1070,4 +1070,4 @@
|
|
|
1070
1070
|
},
|
|
1071
1071
|
"gate": "compareShadow(flow, fixture=true).verified == true ⇒ 才允许真写;否则 gated 拒绝"
|
|
1072
1072
|
}
|
|
1073
|
-
}
|
|
1073
|
+
}
|
|
@@ -1981,6 +1981,64 @@
|
|
|
1981
1981
|
"mcp"
|
|
1982
1982
|
]
|
|
1983
1983
|
},
|
|
1984
|
+
"skuflow_run": {
|
|
1985
|
+
"name": "skuflow_run",
|
|
1986
|
+
"mcpOnly": true,
|
|
1987
|
+
"args": ["--record-json", "--generate-only", "--template"],
|
|
1988
|
+
"exitCodes": [],
|
|
1989
|
+
"dryRun": {
|
|
1990
|
+
"supported": true,
|
|
1991
|
+
"default": true,
|
|
1992
|
+
"note": "默认 --generate-only(只生成不传);MCP 的 confirm=true 才真上传"
|
|
1993
|
+
},
|
|
1994
|
+
"jsonFields": { "mcpNote": "MCP 面用 isError + JSON;默认 dryRun:true 回显" },
|
|
1995
|
+
"a2": { "compliant": null, "note": "MCP 专属面(2026-11-02 方案 C · P2:把宿主壳直接 spawn 脚本的路径收进协议)" },
|
|
1996
|
+
"surface": ["mcp"]
|
|
1997
|
+
},
|
|
1998
|
+
"orchestrator_run": {
|
|
1999
|
+
"name": "orchestrator_run",
|
|
2000
|
+
"mcpOnly": true,
|
|
2001
|
+
"args": ["--mode", "--step", "--record-json", "--no-lip", "--allow-write"],
|
|
2002
|
+
"exitCodes": [],
|
|
2003
|
+
"dryRun": {
|
|
2004
|
+
"supported": true,
|
|
2005
|
+
"default": true,
|
|
2006
|
+
"note": "默认 --mode dry-run + --no-lip;MCP 的 confirm=true 才 --allow-write(真写飞书/门户)"
|
|
2007
|
+
},
|
|
2008
|
+
"jsonFields": { "mcpNote": "MCP 面用 isError + JSON;默认 dryRun:true、step 可为 null" },
|
|
2009
|
+
"a2": { "compliant": null, "note": "MCP 专属面(2026-11-02 方案 C · P2)" },
|
|
2010
|
+
"surface": ["mcp"]
|
|
2011
|
+
},
|
|
2012
|
+
"job_start": {
|
|
2013
|
+
"name": "job_start",
|
|
2014
|
+
"mcpOnly": true,
|
|
2015
|
+
"args": ["kind", "record", "confirm", "step", "timeoutMs"],
|
|
2016
|
+
"exitCodes": [],
|
|
2017
|
+
"dryRun": { "supported": true, "default": true, "note": "默认 dry-run / --generate-only;confirm=true 才真跑" },
|
|
2018
|
+
"jsonFields": { "mcpNote": "返回 {ok, jobId, pid, dryRun, startedAt};后续用 job_status 轮询" },
|
|
2019
|
+
"a2": { "compliant": null, "note": "MCP 专属面(2026-11-02):给宿主壳提供**可取消**的长任务,替代直接 spawn" },
|
|
2020
|
+
"surface": ["mcp"]
|
|
2021
|
+
},
|
|
2022
|
+
"job_status": {
|
|
2023
|
+
"name": "job_status",
|
|
2024
|
+
"mcpOnly": true,
|
|
2025
|
+
"args": ["jobId"],
|
|
2026
|
+
"exitCodes": [],
|
|
2027
|
+
"dryRun": { "supported": false, "default": false, "note": "只读:查状态/结果,不触发侧效应" },
|
|
2028
|
+
"jsonFields": { "mcpNote": "state ∈ running|cancelling|done|failed|cancelled;终态带 result(最后一行 JSON)" },
|
|
2029
|
+
"a2": { "compliant": null, "note": "MCP 专属面(2026-11-02):只读" },
|
|
2030
|
+
"surface": ["mcp"]
|
|
2031
|
+
},
|
|
2032
|
+
"job_cancel": {
|
|
2033
|
+
"name": "job_cancel",
|
|
2034
|
+
"mcpOnly": true,
|
|
2035
|
+
"args": ["jobId"],
|
|
2036
|
+
"exitCodes": [],
|
|
2037
|
+
"dryRun": { "supported": false, "default": false, "note": "写类:发 SIGTERM(5s 后 SIGKILL);幂等" },
|
|
2038
|
+
"jsonFields": { "mcpNote": "返回 {ok, jobId, state};已结束的任务原样返回终态" },
|
|
2039
|
+
"a2": { "compliant": null, "note": "MCP 专属面(2026-11-02):替代插件直接 kill 子进程" },
|
|
2040
|
+
"surface": ["mcp"]
|
|
2041
|
+
},
|
|
1984
2042
|
"preflight": {
|
|
1985
2043
|
"name": "preflight",
|
|
1986
2044
|
"mcpOnly": true,
|
|
@@ -2520,7 +2578,12 @@
|
|
|
2520
2578
|
"gap",
|
|
2521
2579
|
"notify",
|
|
2522
2580
|
"init",
|
|
2523
|
-
"audit"
|
|
2581
|
+
"audit",
|
|
2582
|
+
"skuflow_run",
|
|
2583
|
+
"orchestrator_run",
|
|
2584
|
+
"job_start",
|
|
2585
|
+
"job_status",
|
|
2586
|
+
"job_cancel"
|
|
2524
2587
|
],
|
|
2525
2588
|
"account": [
|
|
2526
2589
|
"version",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 宿主 ↔ 引擎契约(方案 C · P1)
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要:插件曾靠"猜路径"找引擎(4 个候选 + 相对路径),版本错配时**静默降级**
|
|
5
|
+
* (2026-11-02 实测:仓库 0.8.0-rc.8 vs 本机 ~/.argent-dsh 0.7.12,插件只是把 ERP 连接器关掉)。
|
|
6
|
+
* 本文件把"引擎对外承诺什么"变成可读、可比对的数字。
|
|
7
|
+
*
|
|
8
|
+
* 规则:
|
|
9
|
+
* · **加性变更不升 CONTRACT**(新增 tool / 新增可选字段);
|
|
10
|
+
* · **破坏性变更才 +1**(tool 改名、参数形状变、路径语义变);
|
|
11
|
+
* · 升之前必须先让旧壳能**明确拒绝启动**,否则就退化成今天这种静默降级。
|
|
12
|
+
*/
|
|
13
|
+
import { readFileSync } from 'node:fs'
|
|
14
|
+
|
|
15
|
+
/** 引擎契约版本(宿主按此判断兼容性) */
|
|
16
|
+
export const CONTRACT = 1
|
|
17
|
+
|
|
18
|
+
/** 引擎版本(唯一真源 = 引擎根的 VERSION 文件,⛔ 不要在本文件写死) */
|
|
19
|
+
export const ENGINE_VERSION = (() => {
|
|
20
|
+
try {
|
|
21
|
+
return readFileSync(new URL('../../VERSION', import.meta.url), 'utf8').trim()
|
|
22
|
+
} catch {
|
|
23
|
+
return 'unknown'
|
|
24
|
+
}
|
|
25
|
+
})()
|
|
26
|
+
|
|
27
|
+
/** 一次性取全,供 `argent doctor` / 兼容性矩阵使用 */
|
|
28
|
+
export function contractInfo() {
|
|
29
|
+
return { contract: CONTRACT, engineVersion: ENGINE_VERSION }
|
|
30
|
+
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* 写类 `readOnlyHint:false + destructiveHint:true`),让宿主能在**协议层**分辨只读与写类、
|
|
20
20
|
* 从而收窄授权面;分类与理由见下方 {@link annotationsFor} 上方的注释块。
|
|
21
21
|
*/
|
|
22
|
-
import { execFileSync } from 'node:child_process'
|
|
22
|
+
import { execFileSync, spawn } from 'node:child_process'
|
|
23
23
|
import { cpSync, existsSync as fExists, mkdirSync, mkdtempSync, readdirSync, writeFileSync } from 'node:fs'
|
|
24
24
|
import { tmpdir } from 'node:os'
|
|
25
25
|
import { existsSync, readFileSync } from 'node:fs'
|
|
@@ -282,14 +282,19 @@ export function toolScope(name) {
|
|
|
282
282
|
* · **未登记的名字 ⇒ 一律按写类回**(fail-safe:宁可多要一次确认,不可少要)。
|
|
283
283
|
*
|
|
284
284
|
* ⛔ 纪律:本段只被 `tools/list` 读;**不改**任何 tool 的 handler / `inputSchema` / 返回形状,
|
|
285
|
-
*
|
|
285
|
+
* 也**不增删**工具(2026-11-02 起 19 个:新增 `argent_skuflow_run` / `argent_orchestrator_run` 与 job 三件套)。
|
|
286
286
|
*/
|
|
287
287
|
export const READ_ONLY_TOOLS = Object.freeze([
|
|
288
288
|
'argent_version', 'argent_license', 'argent_ledger', 'argent_report', 'argent_failures',
|
|
289
289
|
'argent_sop', 'argent_doctor', 'argent_preflight', 'argent_writeback_audit',
|
|
290
|
+
'argent_job_status',
|
|
290
291
|
])
|
|
291
292
|
export const WRITE_TOOLS = Object.freeze([
|
|
292
293
|
'argent_claim', 'argent_writeback', 'argent_shadow_compare', 'argent_writeback_shadow', 'argent_claim_shadow',
|
|
294
|
+
// 2026-11-02(方案 C · P2):把"宿主壳直接 spawn 脚本"的两条路径收进协议;
|
|
295
|
+
// 默认 dry-run/只生成,真跑必须 confirm=true。
|
|
296
|
+
'argent_skuflow_run', 'argent_orchestrator_run',
|
|
297
|
+
'argent_job_start', 'argent_job_cancel',
|
|
293
298
|
])
|
|
294
299
|
const READ_ONLY_SET = new Set(READ_ONLY_TOOLS)
|
|
295
300
|
const WRITE_SET = new Set(WRITE_TOOLS)
|
|
@@ -301,6 +306,94 @@ export function annotationsFor(name) {
|
|
|
301
306
|
return { readOnlyHint: false, destructiveHint: true }
|
|
302
307
|
}
|
|
303
308
|
|
|
309
|
+
// ── 异步 job(2026-11-02,方案 C · P2 第二步)──────────────────────────────
|
|
310
|
+
// 为什么有:宿主壳原先是自己 spawn python 并持有 child ⇒ 能 kill。
|
|
311
|
+
// 切到 MCP 后同步 `execFileSync` **无法中途取消** ⇒ task_cancel 会退化成"杀连接不杀进程"。
|
|
312
|
+
// 这里补一套最小 job 协议(start / status / cancel),内存态:随 server 进程生灭,不落盘。
|
|
313
|
+
const JOBS = new Map()
|
|
314
|
+
const JOB_MAX_KEEP = 20
|
|
315
|
+
const JOB_OUTPUT_CAP = 64 * 1024
|
|
316
|
+
const JOB_KILL_GRACE_MS = 5000
|
|
317
|
+
|
|
318
|
+
const JOB_KINDS = {
|
|
319
|
+
skuflow: (record, { confirm }) => {
|
|
320
|
+
const argv = ['scripts/skuflow_invoice_runner.py', '--record-json', JSON.stringify(record)]
|
|
321
|
+
if (!confirm) argv.push('--generate-only')
|
|
322
|
+
return argv
|
|
323
|
+
},
|
|
324
|
+
orchestrator: (record, { confirm, step }) => {
|
|
325
|
+
const argv = ['scripts/orchestrator.py', '--record-json', JSON.stringify(record), '--no-lip']
|
|
326
|
+
if (step) argv.push('--mode', 'step', '--step', String(step))
|
|
327
|
+
else argv.push('--mode', confirm ? 'full' : 'dry-run')
|
|
328
|
+
if (confirm) argv.push('--allow-write')
|
|
329
|
+
return argv
|
|
330
|
+
},
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** 任务的"最后一行 JSON"(与插件原先解析 stdout 的口径一致) */
|
|
334
|
+
function jobResult(job) {
|
|
335
|
+
const line = String(job.out || '').split('\n').map((x) => x.trim()).filter((x) => x.startsWith('{')).pop() || ''
|
|
336
|
+
if (!line) return null
|
|
337
|
+
try { return JSON.parse(line) } catch { return null }
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function jobView(job, { withResult = false } = {}) {
|
|
341
|
+
const view = {
|
|
342
|
+
ok: true, jobId: job.id, kind: job.kind, state: job.state, code: job.code,
|
|
343
|
+
dryRun: job.dryRun, startedAt: job.startedAt, endedAt: job.endedAt || null,
|
|
344
|
+
outputTail: String(job.out || '').slice(-2000), errorTail: String(job.err || '').slice(-1000),
|
|
345
|
+
}
|
|
346
|
+
if (withResult && job.state !== 'running') view.result = jobResult(job)
|
|
347
|
+
return view
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function pruneJobs() {
|
|
351
|
+
const done = [...JOBS.values()].filter((j) => j.state !== 'running' && j.state !== 'cancelling')
|
|
352
|
+
for (const j of done.slice(0, Math.max(0, done.length - JOB_MAX_KEEP))) JOBS.delete(j.id)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function startJob({ kind, record, confirm = false, step = null, timeoutMs = 0 }) {
|
|
356
|
+
if (PY_FAILURE) return { ok: false, code: 2, reason: 'python_unavailable', error: PY_FAILURE }
|
|
357
|
+
const build = JOB_KINDS[kind]
|
|
358
|
+
if (!build) return { ok: false, code: 2, error: `未知 kind:${kind}(可选:${Object.keys(JOB_KINDS).join(' / ')})` }
|
|
359
|
+
if (!record || typeof record !== 'object') return { ok: false, code: 2, error: 'record 必须是对象' }
|
|
360
|
+
const argv = [join(REPO, build(record, { confirm, step })[0]), ...build(record, { confirm, step }).slice(1)]
|
|
361
|
+
const id = `job-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`
|
|
362
|
+
const child = spawn(PY, argv, { cwd: REPO, env: { ...process.env, PYTHONPATH: 'scripts' }, stdio: ['ignore', 'pipe', 'pipe'] })
|
|
363
|
+
const job = { id, kind, argv, child, state: 'running', code: null, out: '', err: '', dryRun: !confirm, startedAt: new Date().toISOString(), endedAt: '', timer: null }
|
|
364
|
+
child.stdout.on('data', (b) => { job.out = (job.out + b.toString()).slice(-JOB_OUTPUT_CAP) })
|
|
365
|
+
child.stderr.on('data', (b) => { job.err = (job.err + b.toString()).slice(-JOB_OUTPUT_CAP) })
|
|
366
|
+
child.on('error', (e) => { job.state = 'failed'; job.err += String(e && e.message || e); job.endedAt = new Date().toISOString(); clearTimeout(job.timer) })
|
|
367
|
+
child.on('close', (code, signal) => {
|
|
368
|
+
job.code = code
|
|
369
|
+
job.state = signal ? 'cancelled' : (code === 0 ? 'done' : 'failed')
|
|
370
|
+
job.endedAt = new Date().toISOString()
|
|
371
|
+
clearTimeout(job.timer)
|
|
372
|
+
setTimeout(() => { try { job.child.kill('SIGKILL') } catch { /* noop */ } }, 0).unref?.()
|
|
373
|
+
pruneJobs()
|
|
374
|
+
})
|
|
375
|
+
if (timeoutMs > 0) { job.timer = setTimeout(() => cancelJob(id), Math.min(Number(timeoutMs), 30 * 60 * 1000)); job.timer.unref?.() }
|
|
376
|
+
JOBS.set(id, job)
|
|
377
|
+
return { ok: true, jobId: id, kind, pid: child.pid, dryRun: !confirm, startedAt: job.startedAt }
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function statusJob({ jobId }) {
|
|
381
|
+
const job = JOBS.get(String(jobId || ''))
|
|
382
|
+
if (!job) return { ok: false, code: 2, error: `未知 jobId:${jobId}` }
|
|
383
|
+
return jobView(job, { withResult: true })
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function cancelJob(jobId) {
|
|
387
|
+
const job = JOBS.get(String(jobId || ''))
|
|
388
|
+
if (!job) return { ok: false, code: 2, error: `未知 jobId:${jobId}` }
|
|
389
|
+
if (job.state !== 'running') return { ok: true, jobId: job.id, state: job.state }
|
|
390
|
+
job.state = 'cancelling'
|
|
391
|
+
try { job.child.kill('SIGTERM') } catch { /* 已退出 */ }
|
|
392
|
+
const t = setTimeout(() => { try { job.child.kill('SIGKILL') } catch { /* noop */ } }, JOB_KILL_GRACE_MS)
|
|
393
|
+
t.unref?.()
|
|
394
|
+
return { ok: true, jobId: job.id, state: 'cancelling' }
|
|
395
|
+
}
|
|
396
|
+
|
|
304
397
|
const TOOLS = {
|
|
305
398
|
argent_version: {
|
|
306
399
|
description: 'Argent 与宿主 dsh 的版本(诊断用)',
|
|
@@ -646,8 +739,84 @@ const TOOLS = {
|
|
|
646
739
|
: { ok: false, code: r.code, output: r.output.slice(-4000), error: r.error.slice(0, 300) }
|
|
647
740
|
},
|
|
648
741
|
},
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* SKU 流程发票(原 `office-runtime.js` 的 `spawn(scripts/skuflow_invoice_runner.py)`)。
|
|
745
|
+
* 默认 `--generate-only`(只生成不传),真上传必须 `confirm: true`。
|
|
746
|
+
*/
|
|
747
|
+
argent_skuflow_run: {
|
|
748
|
+
description: 'SKU 流程发票:默认只生成(--generate-only);confirm=true 才上传。输入 = ERP 记录对象',
|
|
749
|
+
inputSchema: {
|
|
750
|
+
type: 'object',
|
|
751
|
+
properties: { record: { type: 'object' }, confirm: { type: 'boolean' } },
|
|
752
|
+
required: ['record'], additionalProperties: false,
|
|
753
|
+
},
|
|
754
|
+
handler: ({ record, confirm = false }) => {
|
|
755
|
+
const argv = [join(REPO, 'scripts', 'skuflow_invoice_runner.py'), '--record-json', JSON.stringify(record)]
|
|
756
|
+
if (!confirm) argv.push('--generate-only')
|
|
757
|
+
const r = runPy(argv)
|
|
758
|
+
if (r.reason === 'python_unavailable') return { ok: false, code: 2, reason: 'python_unavailable', error: r.error }
|
|
759
|
+
return { ok: r.ok, code: r.code, dryRun: !confirm, output: String(r.output || '').slice(-4000), error: String(r.error || '').slice(0, 400) }
|
|
760
|
+
},
|
|
761
|
+
},
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* FULL 编排器(原 `office-runtime.js` 的 `spawn(scripts/orchestrator.py)`)。
|
|
765
|
+
* 默认 `--mode dry-run --no-lip`(只推演、不写 lip);真跑必须 `confirm: true`(`--allow-write`)。
|
|
766
|
+
*/
|
|
767
|
+
argent_orchestrator_run: {
|
|
768
|
+
description: 'FULL 编排器:默认 dry-run + no-lip;confirm=true 才 --allow-write(真写飞书/门户)',
|
|
769
|
+
inputSchema: {
|
|
770
|
+
type: 'object',
|
|
771
|
+
properties: { record: { type: 'object' }, step: { type: 'integer', minimum: 1, maximum: 8 }, confirm: { type: 'boolean' } },
|
|
772
|
+
required: ['record'], additionalProperties: false,
|
|
773
|
+
},
|
|
774
|
+
handler: ({ record, step, confirm = false }) => {
|
|
775
|
+
const argv = [join(REPO, 'scripts', 'orchestrator.py'), '--record-json', JSON.stringify(record), '--no-lip']
|
|
776
|
+
if (step) argv.push('--mode', 'step', '--step', String(step))
|
|
777
|
+
else argv.push('--mode', confirm ? 'full' : 'dry-run')
|
|
778
|
+
if (confirm) argv.push('--allow-write')
|
|
779
|
+
const r = runPy(argv)
|
|
780
|
+
if (r.reason === 'python_unavailable') return { ok: false, code: 2, reason: 'python_unavailable', error: r.error }
|
|
781
|
+
return { ok: r.ok, code: r.code, dryRun: !confirm, step: step || null, output: String(r.output || '').slice(-4000), error: String(r.error || '').slice(0, 400) }
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
|
|
785
|
+
/** 异步任务:启动(宿主壳用它替代直接 spawn;可取消) */
|
|
786
|
+
argent_job_start: {
|
|
787
|
+
description: '异步任务:启动 skuflow / orchestrator(返回 jobId,可 status/cancel;默认 dry-run,confirm=true 才真跑)',
|
|
788
|
+
inputSchema: {
|
|
789
|
+
type: 'object',
|
|
790
|
+
properties: {
|
|
791
|
+
kind: { type: 'string', enum: ['skuflow', 'orchestrator'] },
|
|
792
|
+
record: { type: 'object' },
|
|
793
|
+
confirm: { type: 'boolean' },
|
|
794
|
+
step: { type: 'integer', minimum: 1, maximum: 8 },
|
|
795
|
+
timeoutMs: { type: 'integer' },
|
|
796
|
+
},
|
|
797
|
+
required: ['kind', 'record'], additionalProperties: false,
|
|
798
|
+
},
|
|
799
|
+
handler: (a) => startJob(a),
|
|
800
|
+
},
|
|
801
|
+
|
|
802
|
+
/** 异步任务:查状态(只读) */
|
|
803
|
+
argent_job_status: {
|
|
804
|
+
description: '异步任务状态:state / code / outputTail / result(done|failed|cancelled|running|cancelling)',
|
|
805
|
+
inputSchema: { type: 'object', properties: { jobId: { type: 'string' } }, required: ['jobId'], additionalProperties: false },
|
|
806
|
+
handler: (a) => statusJob(a),
|
|
807
|
+
},
|
|
808
|
+
|
|
809
|
+
/** 异步任务:取消(写类:会发信号) */
|
|
810
|
+
argent_job_cancel: {
|
|
811
|
+
description: '异步任务取消:SIGTERM,5s 后 SIGKILL(幂等:已结束的任务返回其终态)',
|
|
812
|
+
inputSchema: { type: 'object', properties: { jobId: { type: 'string' } }, required: ['jobId'], additionalProperties: false },
|
|
813
|
+
handler: (a) => cancelJob(a.jobId),
|
|
814
|
+
},
|
|
649
815
|
}
|
|
650
816
|
|
|
817
|
+
/** 工具名的只读清单(给宿主做兼容性矩阵/契约校验用;⛔ 不要手写第二份) */
|
|
818
|
+
export const TOOL_NAMES = Object.freeze(Object.keys(TOOLS))
|
|
819
|
+
|
|
651
820
|
const send = (msg) => process.stdout.write(`${JSON.stringify(msg)}\n`)
|
|
652
821
|
const reply = (id, result) => send({ jsonrpc: '2.0', id, result })
|
|
653
822
|
const fail = (id, code, message) => send({ jsonrpc: '2.0', id, error: { code, message } })
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* build-doc-index.mjs —— 把 docs 的状态分布写进 INDEX.md 的自动区块(幂等)
|
|
4
|
+
*
|
|
5
|
+
* 背景(2026-11-02):索引里手写的"当前有效/历史"两份清单会漂(曾写死 0.7.6)。
|
|
6
|
+
* 本脚本只生成**状态总览**,手写清单仍保留(下一步再整体替换)。
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* node scripts/build-doc-index.mjs # 写入(默认)
|
|
10
|
+
* node scripts/build-doc-index.mjs --check # 只校验是否最新(CI/门禁用,不同步则 exit 1)
|
|
11
|
+
*/
|
|
12
|
+
import { readFileSync, writeFileSync } from 'node:fs'
|
|
13
|
+
import { execFileSync } from 'node:child_process'
|
|
14
|
+
|
|
15
|
+
const ROOT = new URL('..', import.meta.url).pathname
|
|
16
|
+
const INDEX = ROOT + 'docs/INDEX.md'
|
|
17
|
+
const CHECK = process.argv.includes('--check')
|
|
18
|
+
const BEGIN = '<!-- BEGIN:DOC-STATUS(自动生成:node scripts/build-doc-index.mjs,勿手改) -->'
|
|
19
|
+
const END = '<!-- END:DOC-STATUS -->'
|
|
20
|
+
|
|
21
|
+
const out = execFileSync(process.execPath, [ROOT + 'scripts/doc-status.mjs', '--json'], { encoding: 'utf8' })
|
|
22
|
+
const { version, counts, rows } = JSON.parse(out)
|
|
23
|
+
const total = rows.length
|
|
24
|
+
const label = {
|
|
25
|
+
current: '现行口径(照它做)',
|
|
26
|
+
superseded: '已被取代(跟指针走)',
|
|
27
|
+
historical: '仅作证据(不构成操作依据)',
|
|
28
|
+
draft: '未定稿(禁止据此操作)',
|
|
29
|
+
'needs-review': '⚠️ 待人工判定(尚无 status)',
|
|
30
|
+
}
|
|
31
|
+
const order = ['current', 'superseded', 'historical', 'draft', 'needs-review']
|
|
32
|
+
const pending = rows.filter((r) => r.status === 'needs-review')
|
|
33
|
+
|
|
34
|
+
const lines = [
|
|
35
|
+
BEGIN,
|
|
36
|
+
`> 自动生成于 \`VERSION=${version}\`;共 **${total}** 篇。手改会被下次生成覆盖。`,
|
|
37
|
+
'',
|
|
38
|
+
'| status | 篇数 | 含义 |',
|
|
39
|
+
'|---|---:|---|',
|
|
40
|
+
...order.filter((k) => counts[k]).map((k) => `| \`${k}\` | ${counts[k]} | ${label[k]} |`),
|
|
41
|
+
'',
|
|
42
|
+
]
|
|
43
|
+
if (pending.length) {
|
|
44
|
+
lines.push('<details><summary>待判定的 ' + pending.length + ' 篇(点开)</summary>', '')
|
|
45
|
+
for (const r of pending) lines.push(`- \`${r.file}\``)
|
|
46
|
+
lines.push('', '</details>')
|
|
47
|
+
}
|
|
48
|
+
lines.push(END)
|
|
49
|
+
const block = lines.join('\n')
|
|
50
|
+
|
|
51
|
+
const text = readFileSync(INDEX, 'utf8')
|
|
52
|
+
const i = text.indexOf(BEGIN)
|
|
53
|
+
const j = text.indexOf(END)
|
|
54
|
+
if (i < 0 || j < 0) {
|
|
55
|
+
console.error('❌ INDEX.md 缺少 DOC-STATUS 标记,先补标记再运行')
|
|
56
|
+
process.exit(2)
|
|
57
|
+
}
|
|
58
|
+
const next = text.slice(0, i) + block + text.slice(j + END.length)
|
|
59
|
+
if (next === text) {
|
|
60
|
+
console.log('✓ 状态总览已是最新')
|
|
61
|
+
process.exit(0)
|
|
62
|
+
}
|
|
63
|
+
if (CHECK) {
|
|
64
|
+
console.error('❌ INDEX.md 的状态总览过期:请运行 node scripts/build-doc-index.mjs')
|
|
65
|
+
process.exit(1)
|
|
66
|
+
}
|
|
67
|
+
writeFileSync(INDEX, next)
|
|
68
|
+
console.log(`✓ 已更新 INDEX.md 状态总览(${total} 篇)`)
|