@wowok/agent-mcp 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/exposure.d.ts +8 -8
- package/dist/config/judgment.d.ts +20 -20
- package/dist/config/rule-engine.d.ts +20 -20
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/sdk-batch.d.ts +1 -0
- package/dist/graph/onchain/sdk-batch.js +1 -1
- package/dist/graph/onchain/sdk-dataplane.d.ts +1 -0
- package/dist/graph/onchain/sdk-dataplane.js +1 -1
- package/dist/knowledge/allocation-templates.d.ts +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +1 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/discount-threshold.d.ts +15 -0
- package/dist/knowledge/discount-threshold.js +1 -0
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.d.ts +38 -1
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +10 -0
- package/dist/knowledge/strategy-manuals.d.ts +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +20 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/arbitrator-interest.js +1 -1
- package/dist/participation/customer-interest.js +1 -1
- package/dist/participation/merchant-interest.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +12 -1
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.d.ts +1 -0
- package/dist/playbooks/service-build/reverse-mapping-refund-p0-5.spec.js +1 -0
- package/dist/playbooks/service-build/reverse-mapping.js +1 -1
- package/dist/playbooks/service-build/semantic-graph.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/role/types.d.ts +2 -0
- package/dist/role/types.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +7 -7
- package/dist/schema/call/arbitration.d.ts +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +5 -5
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +5 -9
- package/dist/schema/call/bridge.js +1 -1
- package/dist/schema/call/contact.d.ts +1 -1
- package/dist/schema/call/demand.d.ts +1 -1
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +2 -2
- package/dist/schema/call/order.d.ts +1 -1
- package/dist/schema/call/payment.d.ts +1 -1
- package/dist/schema/call/permission.d.ts +1 -1
- package/dist/schema/call/personal.d.ts +1 -1
- package/dist/schema/call/progress.d.ts +1 -1
- package/dist/schema/call/proof.d.ts +2 -2
- package/dist/schema/call/repository.d.ts +1 -1
- package/dist/schema/call/reward.d.ts +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +5 -5
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +6 -2
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +8 -8
- package/dist/schema/goal/planning.d.ts +15 -15
- package/dist/schema/industry-pack/index.d.ts +15 -0
- package/dist/schema/industry-pack/modes.d.ts +15 -0
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +3 -0
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +577 -18
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +140 -20
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +30 -28
- package/dist/schema/operations.js +1 -1
- package/dist/schema/persona/index.d.ts +708 -708
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +20 -6
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +32 -32
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-query/index.d.ts +3 -3
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/watch/index.d.ts +2 -2
- package/dist/schema/workflow/index.d.ts +2 -2
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +6 -2
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.schema.json +2 -10
- package/dist/schemas/evaluation_operation.output.json +2 -0
- package/dist/schemas/evaluation_operation.schema.json +2 -0
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +87 -4
- package/dist/schemas/intent_radar.output.json +2 -0
- package/dist/schemas/intent_radar.schema.json +1 -0
- package/dist/schemas/local_cache_operation.output.json +1536 -0
- package/dist/schemas/local_cache_operation.schema.json +101 -0
- package/dist/schemas/local_mark_operation.output.json +51 -36
- package/dist/schemas/local_mark_operation.schema.json +1 -0
- package/dist/schemas/messenger_operation.schema.json +358 -35
- package/dist/schemas/onchain_operations.schema.json +10 -10
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_payment.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +3 -3
- package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +11 -0
- package/dist/schemas/query_toolkit.output.json +11 -4
- package/dist/schemas/query_toolkit.schema.json +13 -2
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/local.d.ts +1 -0
- package/dist/tools/handlers/local.js +1 -1
- package/dist/tools/handlers/messenger.d.ts +9 -2
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/name-resolution.d.ts +4 -0
- package/dist/tools/handlers/name-resolution.js +1 -0
- package/dist/tools/handlers/name-resolution.spec.d.ts +1 -0
- package/dist/tools/handlers/name-resolution.spec.js +1 -0
- package/dist/tools/handlers/onchain-name-registration.d.ts +37 -0
- package/dist/tools/handlers/onchain-name-registration.js +1 -0
- package/dist/tools/handlers/onchain-name-registration.spec.d.ts +1 -0
- package/dist/tools/handlers/onchain-name-registration.spec.js +1 -0
- package/dist/tools/handlers/onchain.d.ts +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.d.ts +1 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/local.js +1 -1
- package/dist/tools/sanitize-description-roundtrip.spec.d.ts +1 -0
- package/dist/tools/sanitize-description-roundtrip.spec.js +1 -0
- package/dist/tools/sanitize-output.d.ts +1 -0
- package/dist/tools/sanitize-output.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -13,9 +13,9 @@ export declare const ExposurePartyDataSchema: z.ZodObject<{
|
|
|
13
13
|
supplier: "supplier";
|
|
14
14
|
collaborator: "collaborator";
|
|
15
15
|
arbitrator: "arbitrator";
|
|
16
|
-
buyer: "buyer";
|
|
17
|
-
system: "system";
|
|
18
16
|
neutral: "neutral";
|
|
17
|
+
system: "system";
|
|
18
|
+
buyer: "buyer";
|
|
19
19
|
}>;
|
|
20
20
|
basis: z.ZodString;
|
|
21
21
|
}, z.core.$strict>;
|
|
@@ -25,9 +25,9 @@ export declare const GainPathDataSchema: z.ZodObject<{
|
|
|
25
25
|
supplier: "supplier";
|
|
26
26
|
collaborator: "collaborator";
|
|
27
27
|
arbitrator: "arbitrator";
|
|
28
|
-
buyer: "buyer";
|
|
29
|
-
system: "system";
|
|
30
28
|
neutral: "neutral";
|
|
29
|
+
system: "system";
|
|
30
|
+
buyer: "buyer";
|
|
31
31
|
}>;
|
|
32
32
|
path: z.ZodString;
|
|
33
33
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -45,9 +45,9 @@ export declare const ExposureFragmentSchema: z.ZodObject<{
|
|
|
45
45
|
supplier: "supplier";
|
|
46
46
|
collaborator: "collaborator";
|
|
47
47
|
arbitrator: "arbitrator";
|
|
48
|
-
buyer: "buyer";
|
|
49
|
-
system: "system";
|
|
50
48
|
neutral: "neutral";
|
|
49
|
+
system: "system";
|
|
50
|
+
buyer: "buyer";
|
|
51
51
|
}>;
|
|
52
52
|
basis: z.ZodString;
|
|
53
53
|
}, z.core.$strict>>;
|
|
@@ -57,9 +57,9 @@ export declare const ExposureFragmentSchema: z.ZodObject<{
|
|
|
57
57
|
supplier: "supplier";
|
|
58
58
|
collaborator: "collaborator";
|
|
59
59
|
arbitrator: "arbitrator";
|
|
60
|
-
buyer: "buyer";
|
|
61
|
-
system: "system";
|
|
62
60
|
neutral: "neutral";
|
|
61
|
+
system: "system";
|
|
62
|
+
buyer: "buyer";
|
|
63
63
|
}>;
|
|
64
64
|
path: z.ZodString;
|
|
65
65
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -394,9 +394,9 @@ export declare const RulesSectionSchema: z.ZodObject<{
|
|
|
394
394
|
supplier: "supplier";
|
|
395
395
|
collaborator: "collaborator";
|
|
396
396
|
arbitrator: "arbitrator";
|
|
397
|
-
buyer: "buyer";
|
|
398
|
-
system: "system";
|
|
399
397
|
neutral: "neutral";
|
|
398
|
+
system: "system";
|
|
399
|
+
buyer: "buyer";
|
|
400
400
|
}>;
|
|
401
401
|
basis: z.ZodString;
|
|
402
402
|
}, z.core.$strict>>;
|
|
@@ -406,9 +406,9 @@ export declare const RulesSectionSchema: z.ZodObject<{
|
|
|
406
406
|
supplier: "supplier";
|
|
407
407
|
collaborator: "collaborator";
|
|
408
408
|
arbitrator: "arbitrator";
|
|
409
|
-
buyer: "buyer";
|
|
410
|
-
system: "system";
|
|
411
409
|
neutral: "neutral";
|
|
410
|
+
system: "system";
|
|
411
|
+
buyer: "buyer";
|
|
412
412
|
}>;
|
|
413
413
|
path: z.ZodString;
|
|
414
414
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -451,9 +451,9 @@ export declare const RulesSectionInputSchema: z.ZodObject<{
|
|
|
451
451
|
supplier: "supplier";
|
|
452
452
|
collaborator: "collaborator";
|
|
453
453
|
arbitrator: "arbitrator";
|
|
454
|
-
buyer: "buyer";
|
|
455
|
-
system: "system";
|
|
456
454
|
neutral: "neutral";
|
|
455
|
+
system: "system";
|
|
456
|
+
buyer: "buyer";
|
|
457
457
|
}>;
|
|
458
458
|
basis: z.ZodString;
|
|
459
459
|
}, z.core.$strict>>;
|
|
@@ -463,9 +463,9 @@ export declare const RulesSectionInputSchema: z.ZodObject<{
|
|
|
463
463
|
supplier: "supplier";
|
|
464
464
|
collaborator: "collaborator";
|
|
465
465
|
arbitrator: "arbitrator";
|
|
466
|
-
buyer: "buyer";
|
|
467
|
-
system: "system";
|
|
468
466
|
neutral: "neutral";
|
|
467
|
+
system: "system";
|
|
468
|
+
buyer: "buyer";
|
|
469
469
|
}>;
|
|
470
470
|
path: z.ZodString;
|
|
471
471
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -670,9 +670,9 @@ export declare const JudgmentDocSchema: z.ZodObject<{
|
|
|
670
670
|
supplier: "supplier";
|
|
671
671
|
collaborator: "collaborator";
|
|
672
672
|
arbitrator: "arbitrator";
|
|
673
|
-
buyer: "buyer";
|
|
674
|
-
system: "system";
|
|
675
673
|
neutral: "neutral";
|
|
674
|
+
system: "system";
|
|
675
|
+
buyer: "buyer";
|
|
676
676
|
}>;
|
|
677
677
|
basis: z.ZodString;
|
|
678
678
|
}, z.core.$strict>>;
|
|
@@ -682,9 +682,9 @@ export declare const JudgmentDocSchema: z.ZodObject<{
|
|
|
682
682
|
supplier: "supplier";
|
|
683
683
|
collaborator: "collaborator";
|
|
684
684
|
arbitrator: "arbitrator";
|
|
685
|
-
buyer: "buyer";
|
|
686
|
-
system: "system";
|
|
687
685
|
neutral: "neutral";
|
|
686
|
+
system: "system";
|
|
687
|
+
buyer: "buyer";
|
|
688
688
|
}>;
|
|
689
689
|
path: z.ZodString;
|
|
690
690
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -884,9 +884,9 @@ export declare const JudgmentDocInputSchema: z.ZodObject<{
|
|
|
884
884
|
supplier: "supplier";
|
|
885
885
|
collaborator: "collaborator";
|
|
886
886
|
arbitrator: "arbitrator";
|
|
887
|
-
buyer: "buyer";
|
|
888
|
-
system: "system";
|
|
889
887
|
neutral: "neutral";
|
|
888
|
+
system: "system";
|
|
889
|
+
buyer: "buyer";
|
|
890
890
|
}>;
|
|
891
891
|
basis: z.ZodString;
|
|
892
892
|
}, z.core.$strict>>;
|
|
@@ -896,9 +896,9 @@ export declare const JudgmentDocInputSchema: z.ZodObject<{
|
|
|
896
896
|
supplier: "supplier";
|
|
897
897
|
collaborator: "collaborator";
|
|
898
898
|
arbitrator: "arbitrator";
|
|
899
|
-
buyer: "buyer";
|
|
900
|
-
system: "system";
|
|
901
899
|
neutral: "neutral";
|
|
900
|
+
system: "system";
|
|
901
|
+
buyer: "buyer";
|
|
902
902
|
}>;
|
|
903
903
|
path: z.ZodString;
|
|
904
904
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -980,9 +980,9 @@ export declare const JudgmentFragmentSchema: z.ZodObject<{
|
|
|
980
980
|
supplier: "supplier";
|
|
981
981
|
collaborator: "collaborator";
|
|
982
982
|
arbitrator: "arbitrator";
|
|
983
|
-
buyer: "buyer";
|
|
984
|
-
system: "system";
|
|
985
983
|
neutral: "neutral";
|
|
984
|
+
system: "system";
|
|
985
|
+
buyer: "buyer";
|
|
986
986
|
}>;
|
|
987
987
|
basis: z.ZodString;
|
|
988
988
|
}, z.core.$strict>>;
|
|
@@ -992,9 +992,9 @@ export declare const JudgmentFragmentSchema: z.ZodObject<{
|
|
|
992
992
|
supplier: "supplier";
|
|
993
993
|
collaborator: "collaborator";
|
|
994
994
|
arbitrator: "arbitrator";
|
|
995
|
-
buyer: "buyer";
|
|
996
|
-
system: "system";
|
|
997
995
|
neutral: "neutral";
|
|
996
|
+
system: "system";
|
|
997
|
+
buyer: "buyer";
|
|
998
998
|
}>;
|
|
999
999
|
path: z.ZodString;
|
|
1000
1000
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -36,9 +36,9 @@ export declare const RuleCaseSchema: z.ZodObject<{
|
|
|
36
36
|
supplier: "supplier";
|
|
37
37
|
collaborator: "collaborator";
|
|
38
38
|
arbitrator: "arbitrator";
|
|
39
|
-
buyer: "buyer";
|
|
40
|
-
system: "system";
|
|
41
39
|
neutral: "neutral";
|
|
40
|
+
system: "system";
|
|
41
|
+
buyer: "buyer";
|
|
42
42
|
}>;
|
|
43
43
|
basis: z.ZodString;
|
|
44
44
|
}, z.core.$strict>>;
|
|
@@ -48,9 +48,9 @@ export declare const RuleCaseSchema: z.ZodObject<{
|
|
|
48
48
|
supplier: "supplier";
|
|
49
49
|
collaborator: "collaborator";
|
|
50
50
|
arbitrator: "arbitrator";
|
|
51
|
-
buyer: "buyer";
|
|
52
|
-
system: "system";
|
|
53
51
|
neutral: "neutral";
|
|
52
|
+
system: "system";
|
|
53
|
+
buyer: "buyer";
|
|
54
54
|
}>;
|
|
55
55
|
path: z.ZodString;
|
|
56
56
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -84,9 +84,9 @@ export declare const RuleEntrySchema: z.ZodObject<{
|
|
|
84
84
|
supplier: "supplier";
|
|
85
85
|
collaborator: "collaborator";
|
|
86
86
|
arbitrator: "arbitrator";
|
|
87
|
-
buyer: "buyer";
|
|
88
|
-
system: "system";
|
|
89
87
|
neutral: "neutral";
|
|
88
|
+
system: "system";
|
|
89
|
+
buyer: "buyer";
|
|
90
90
|
}>;
|
|
91
91
|
basis: z.ZodString;
|
|
92
92
|
}, z.core.$strict>>;
|
|
@@ -96,9 +96,9 @@ export declare const RuleEntrySchema: z.ZodObject<{
|
|
|
96
96
|
supplier: "supplier";
|
|
97
97
|
collaborator: "collaborator";
|
|
98
98
|
arbitrator: "arbitrator";
|
|
99
|
-
buyer: "buyer";
|
|
100
|
-
system: "system";
|
|
101
99
|
neutral: "neutral";
|
|
100
|
+
system: "system";
|
|
101
|
+
buyer: "buyer";
|
|
102
102
|
}>;
|
|
103
103
|
path: z.ZodString;
|
|
104
104
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -137,9 +137,9 @@ export declare const RuleDomainPackSchema: z.ZodObject<{
|
|
|
137
137
|
supplier: "supplier";
|
|
138
138
|
collaborator: "collaborator";
|
|
139
139
|
arbitrator: "arbitrator";
|
|
140
|
-
buyer: "buyer";
|
|
141
|
-
system: "system";
|
|
142
140
|
neutral: "neutral";
|
|
141
|
+
system: "system";
|
|
142
|
+
buyer: "buyer";
|
|
143
143
|
}>;
|
|
144
144
|
basis: z.ZodString;
|
|
145
145
|
}, z.core.$strict>>;
|
|
@@ -149,9 +149,9 @@ export declare const RuleDomainPackSchema: z.ZodObject<{
|
|
|
149
149
|
supplier: "supplier";
|
|
150
150
|
collaborator: "collaborator";
|
|
151
151
|
arbitrator: "arbitrator";
|
|
152
|
-
buyer: "buyer";
|
|
153
|
-
system: "system";
|
|
154
152
|
neutral: "neutral";
|
|
153
|
+
system: "system";
|
|
154
|
+
buyer: "buyer";
|
|
155
155
|
}>;
|
|
156
156
|
path: z.ZodString;
|
|
157
157
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -191,9 +191,9 @@ export declare const RuleEntryInputSchema: z.ZodObject<{
|
|
|
191
191
|
supplier: "supplier";
|
|
192
192
|
collaborator: "collaborator";
|
|
193
193
|
arbitrator: "arbitrator";
|
|
194
|
-
buyer: "buyer";
|
|
195
|
-
system: "system";
|
|
196
194
|
neutral: "neutral";
|
|
195
|
+
system: "system";
|
|
196
|
+
buyer: "buyer";
|
|
197
197
|
}>;
|
|
198
198
|
basis: z.ZodString;
|
|
199
199
|
}, z.core.$strict>>;
|
|
@@ -203,9 +203,9 @@ export declare const RuleEntryInputSchema: z.ZodObject<{
|
|
|
203
203
|
supplier: "supplier";
|
|
204
204
|
collaborator: "collaborator";
|
|
205
205
|
arbitrator: "arbitrator";
|
|
206
|
-
buyer: "buyer";
|
|
207
|
-
system: "system";
|
|
208
206
|
neutral: "neutral";
|
|
207
|
+
system: "system";
|
|
208
|
+
buyer: "buyer";
|
|
209
209
|
}>;
|
|
210
210
|
path: z.ZodString;
|
|
211
211
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -244,9 +244,9 @@ export declare const RuleDomainPackInputSchema: z.ZodObject<{
|
|
|
244
244
|
supplier: "supplier";
|
|
245
245
|
collaborator: "collaborator";
|
|
246
246
|
arbitrator: "arbitrator";
|
|
247
|
-
buyer: "buyer";
|
|
248
|
-
system: "system";
|
|
249
247
|
neutral: "neutral";
|
|
248
|
+
system: "system";
|
|
249
|
+
buyer: "buyer";
|
|
250
250
|
}>;
|
|
251
251
|
basis: z.ZodString;
|
|
252
252
|
}, z.core.$strict>>;
|
|
@@ -256,9 +256,9 @@ export declare const RuleDomainPackInputSchema: z.ZodObject<{
|
|
|
256
256
|
supplier: "supplier";
|
|
257
257
|
collaborator: "collaborator";
|
|
258
258
|
arbitrator: "arbitrator";
|
|
259
|
-
buyer: "buyer";
|
|
260
|
-
system: "system";
|
|
261
259
|
neutral: "neutral";
|
|
260
|
+
system: "system";
|
|
261
|
+
buyer: "buyer";
|
|
262
262
|
}>;
|
|
263
263
|
path: z.ZodString;
|
|
264
264
|
viability: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{seedBuiltinTemplates}from'../knowledge/template-loader.js';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{STRATEGY_MANUAL_FILENAME,renderStrategyManual,classifyManualFile}from'../knowledge/strategy-manuals.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryBaselines}from'./industry-layers.js';import{validateJudgmentFragment}from'../config/judgment.js';import{getIndustryProfile,registerIndustry}from'../knowledge/industry-registry.js';import{composeIndustries,DEFAULT_TRAITS,inferTraitsFromDescription,synthesizeProfile}from'../knowledge/industry-generalizer.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||typeof a?.['refund_window']?.['days']==='number'&&a['refund_window']['days']>0x0;}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulBaselines(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&Object['keys'](a)['length']>0x0;}const PLAYBOOK_PLACEHOLDER_RE=/\((?:Example|Add|Write)\b/;function isMeaningfulPlaybook(a){if(!a)return![];for(const b of(a['content']??'')['split'](/\r?\n/)){const c=b['trim']();if(c==='')continue;if(c['startsWith']('>'))continue;if(c['startsWith']('#'))continue;if(PLAYBOOK_PLACEHOLDER_RE['test'](c))continue;return!![];}return![];}const TRAIT_BOOLEAN_KEYS=['has_logistics','communication_heavy','pure_digital','long_cycle','deposit_required','multi_tier_allocation'],TRAIT_ENUM_KEYS=['regulatory_intensity','trust_sensitivity','consumption_frequency','avg_ticket_size'];function coerceTraits(a){if(!a||typeof a!=='object')return undefined;const b={...DEFAULT_TRAITS};let c=![];for(const d of TRAIT_BOOLEAN_KEYS){typeof a[d]==='boolean'&&(b[d]=a[d],c=!![]);}for(const e of TRAIT_ENUM_KEYS){typeof a[e]==='string'&&(b[e]=a[e],c=!![]);}return c?b:undefined;}export function ensureIndustryProfile(a,b){const c=a['manifest']['name'];if(getIndustryProfile(c))return;try{const d=(a['manifest']['depends_on']??[])['filter'](g=>typeof g==='string'&&g['length']>0x0);if(d['length']>0x0){const g=composeIndustries(d,c);if(!g)throw new Error('depends_on\x20parents\x20not\x20registered:\x20'+d['join'](',\x20'));g['display_name']=a['manifest']['display_name']||g['display_name'],g['source']='composed',registerIndustry(g);return;}const e=coerceTraits(a['manifest']['traits'])??inferTraitsFromDescription(a['manifest']['display_name']||c)['traits'],f=synthesizeProfile(e,c);f['display_name']=a['manifest']['display_name']||f['display_name'],f['source']='custom',registerIndustry(f);}catch(h){b['push']('industry\x20profile\x20registration\x20failed\x20for\x20\x27'+c+'\x27:\x20'+h['message']);}}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;ensureIndustryProfile(a,c);if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):d['push']('rules');}}if(e['layers']['includes']('baselines')){if(!a['baselines'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27baselines\x27\x20but\x20baselines.json\x20is\x20missing');else{if(!isMeaningfulBaselines(a['baselines'])){}else{const m=validateJudgmentFragment(a['baselines'],e['name']+'.baselines');if(m)c['push'](m);else!registerIndustryBaselines({'category':e['name'],'fragment':a['baselines']},i)?c['push']('baselines\x20for\x20\x27'+e['name']+'\x27\x20already\x20registered'):d['push']('baselines');}}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const q=b['manifest'],r={'layout':'merged','manifest':q};if(b['mode'])r['mode']=b['mode'];if(b['match'])r['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(r['personae']=b['personae']);if(b['dispute'])r['dispute']=b['dispute'];if(b['compliance'])r['compliance']=b['compliance'];if(b['supply'])r['supply']=b['supply'];if(b['rules'])r['rules']=b['rules'];if(b['baselines'])r['baselines']=b['baselines'];const s=join(a,'playbook.md');return existsSync(s)&&(r['playbook']={'category':q['name'],'content':readFileSync(s,'utf-8')}),r;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const t=[];for(const u of readdirSync(j)){if(!u['endsWith']('.json'))continue;t['push'](JSON['parse'](readFileSync(join(j,u),'utf-8')));}if(t['length']>0x0)g['personae']=t;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'baselines.json');existsSync(o)&&(g['baselines']=JSON['parse'](readFileSync(o,'utf-8')));const p=join(a,'playbook.md');return existsSync(p)&&(g['playbook']={'category':e['name'],'content':readFileSync(p,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),seedBuiltinTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export function seedBuiltinStrategyManuals(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();for(const d of a){const e=renderStrategyManual(d);if(!e)continue;const f=join(c,d,STRATEGY_MANUAL_FILENAME);try{const g=join(c,d);if(!existsSync(join(g,'manifest.json'))&&!existsSync(join(g,'pack.json'))){const j=scaffoldIndustryPack(d,c);if(!j['ok']){b['push']({'industry':d,'status':'error','path':f,'detail':j['errors']['join'](';\x20')});continue;}}if(!existsSync(f)){writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'written','path':f});continue;}const h=readFileSync(f,'utf-8'),i=classifyManualFile(d,h);if(i==='outdated')writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'updated','path':f});else{if(i==='current')b['push']({'industry':d,'status':'current','path':f});else i==='user_modified'?b['push']({'industry':d,'status':'skipped_user_modified','path':f,'detail':'strategy-manual.md\x20was\x20edited\x20locally;\x20keeping\x20user\x20content\x20and\x20not\x20upgrading'}):b['push']({'industry':d,'status':'skipped_user_file','path':f,'detail':'strategy-manual.md\x20exists\x20without\x20builtin\x20sentinel;\x20leaving\x20user\x20file\x20untouched'});}}catch(k){b['push']({'industry':d,'status':'error','path':f,'detail':k['message']});}}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode','baselines.json':'baselines'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'not_applicable':!![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'baselines':null,'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20Pack\x20layers\x20are\x20registered\x20into\x20the\x20runtime\x20registry\x20and','>\x20consumed\x20on\x20demand\x20by\x20the\x20build/recommendation\x20tools\x20(merchant_guide,','>\x20recommend_industry,\x20…);\x20a\x20compact\x20strategy\x20summary\x20for\x20the\x20active','>\x20merchant/supplier\x20lens\x20is\x20injected\x20into\x20every\x20chat\x20turn.','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files,\x20plus\x20an\x20optional\x20`templates/`\x20folder:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20Registered\x20on\x20scan\x20and\x20read\x20ON\x20DEMAND\x20via\x20industry_pack_operation','\x20\x20(action=\x27get\x27);\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for\x20this\x20account.','-\x20**`<pack>/templates/*.md`**\x20—\x20archetype\x20templates\x20(see\x20the\x20Templates','\x20\x20section\x20below).\x20The\x2012\x20built-in\x20variants\x20are\x20seeded\x20here\x20automatically.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20registered\x20layers\x20are\x20available\x20to\x20the','\x20\x20\x20on-demand\x20tools\x20(and\x20the\x20merchant/supplier\x20strategy\x20summary\x20is\x20fresh','\x20\x20\x20in\x20the\x20persona\x20context),\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules','\x20\x20\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Legal','\x20\x20layer\x20names:\x20`match`,\x20`personae`,\x20`dispute`,\x20`compliance`,\x20`supply`,','\x20\x20`rules`,\x20`baselines`,\x20`playbook`\x20(plus\x20`mode`\x20when\x20you\x20add\x20a\x20driving','\x20\x20mode).\x20Remove\x20a\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in','\x20\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20baselines\x20—\x20judgment\x20baselines\x20overlay\x20(Q12)','','`baselines`\x20carries\x20a\x20PARTIAL\x20judgment\x20baselines\x20document\x20(same\x20shape\x20as','the\x20user\x27s\x20judgment.json).\x20It\x20is\x20merged\x20into\x20the\x20judgment\x20chain','BETWEEN\x20the\x20factory\x20document\x20and\x20the\x20persona\x20fragment:','','\x20\x20\x20\x20factory\x20<\x20pack\x20baselines\x20<\x20persona\x20fragment\x20<\x20user\x20document\x20<\x20session\x20overrides','','A\x20pack\x20may\x20RETUNE\x20factory\x20parameters\x20or\x20DISABLE\x20factory\x20rules','(`enabled:\x20false`\x20—\x20a\x20disable\x20trace\x20is\x20recorded).\x20It\x20can\x20NEVER\x20invent\x20new','dimensions/rules\x20or\x20delete\x20factory\x20entries:\x20only\x20keys\x20and\x20ids\x20that\x20exist','in\x20the\x20factory\x20document\x20are\x20accepted.\x20Tuning\x20example:','','```json','\x22baselines\x22:\x20{','\x20\x20\x22version\x22:\x201,','\x20\x20\x22evaluation\x22:\x20{\x20\x22severity_deduction\x22:\x20{\x20\x22critical\x22:\x2040\x20}\x20},','\x20\x20\x22monitor\x22:\x20{\x20\x22thresholds\x22:\x20{\x20\x22messenger_timeout_hours\x22:\x2012\x20}\x20}','}','```','','Disabling\x20a\x20factory\x20rule\x20(the\x20rule\x20id\x20must\x20exist,\x20e.g.\x20in\x20the\x20`util`','domain):','','```json','{\x20\x22rules\x22:\x20{\x20\x22domains\x22:\x20{\x20\x22util\x22:\x20{\x20\x22rules\x22:\x20[','\x20\x20{\x20\x22rule_id\x22:\x20\x22R-UTIL-03\x22,\x20\x22enabled\x22:\x20false\x20}',']\x20}\x20}\x20}\x20}','```','','A\x20misspelled\x20dimension\x20or\x20an\x20invented\x20rule\x20id\x20is\x20REJECTED\x20at\x20registration','(and\x20on\x20every\x20scan/rescan)\x20with\x20a\x20visible\x20error\x20—\x20the\x20last\x20good','registration\x20stays\x20in\x20force\x20until\x20the\x20fragment\x20is\x20fixed.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','Registered\x20into\x20`IndustryModeRegistry`\x20on\x20scan\x20(manifest\x20must\x20list\x20the','`mode`\x20layer).\x20A\x20pack\x20mode\x20with\x20the\x20same\x20name\x20as\x20a\x20builtin\x20replaces\x20it\x20when','the\x20pack\x20version\x20changes\x20or\x20on\x20a\x20forced\x20rescan.','','###\x20How\x20the\x20mode\x20is\x20consumed','','-\x20**Service\x20build\x20(priors)**:\x20`merchant_guide`\x20resolves\x20the\x20confirmed','\x20\x20industry\x20to\x20a\x20mode\x20(user\x20mode\x20first,\x20then\x20pack\x20mode,\x20then\x20builtin)\x20and','\x20\x20feeds\x20`machine_shape`\x20/\x20`guards`\x20/\x20`allocator`\x20/\x20`key_risk`\x20into\x20the','\x20\x20SemanticObjectGraph\x20build.','-\x20**Evaluation**:\x20the\x20metric\x20+\x20constraint\x20registries\x20score\x20the\x20mode','\x20\x20(risk/benefit\x200-100,\x20hard\x20violations\x20block\x20adoption).\x20Custom\x20metrics\x20and','\x20\x20constraints\x20registered\x20via\x20`industry_pack_operation`\x20participate\x20too.','-\x20**Recommendation**:\x20`recommend_industry`\x20matches\x20trait\x20similarity\x20and,','\x20\x20when\x20a\x20merchant\x20strategy\x20is\x20given,\x20re-ranks\x20by\x20lever\x20alignment\x20(70%','\x20\x20similarity\x20+\x2030%\x20alignment).','','###\x20Field\x20reference','','-\x20**Identity**:\x20`name`\x20(snake_case),\x20`display_name`,\x20`version`\x20(e.g.\x20`v1`),','\x20\x20`source`\x20(`builtin`\x20|\x20`custom`).','-\x20`traits`:\x2010-dimension\x20industry\x20trait\x20vector\x20(logistics,\x20cycle,\x20deposit,','\x20\x20regulatory\x20intensity,\x20...).\x20Drives\x20`recommend_industry`\x20similarity.','-\x20`machine_shape`:\x20Machine\x20node\x20topology\x20—\x20`[{\x20name,\x20role\x20}]`.\x20Node\x20names\x20are','\x20\x20business\x20states.\x20R-M1-11:\x20NEVER\x20model\x20refund/dispute\x20terminals','\x20\x20(`refunded`,\x20`disputed`,\x20`arb_*`)\x20as\x20nodes\x20—\x20disputes\x20flow\x20through','\x20\x20Service.arbitrations\x20independently;\x20route\x20refunds\x20via\x20the\x20Allocator','\x20\x20triggered\x20by\x20business\x20states\x20(`cancelled`,\x20`returned`).','-\x20`guards`:\x20`[{\x20template_id,\x20host,\x20purpose\x20}]`\x20—\x20guard\x20templates\x20to\x20attach.','\x20\x20`host`\x20is\x20one\x20of\x20`service`\x20|\x20`machine`\x20|\x20`reward`\x20|\x20`repository`\x20|','\x20\x20`arbitration`.','-\x20`allocator`:\x20`{\x20recipient,\x20count,\x20mode,\x20description\x20}`\x20—\x20fund\x20split.','\x20\x20`recipient`:\x20`signer`\x20|\x20`entity`;\x20`count`\x20>\x201\x20switches\x20to\x20multi-party','\x20\x20distribution;\x20`mode`:\x20`surplus`\x20|\x20`rate`\x20|\x20`milestone`.','-\x20`risk_checks`\x20/\x20`needs`:\x20buyer-side\x20due-diligence\x20entries\x20surfaced\x20in','\x20\x20prospect\x20evaluation.','-\x20`flywheel`:\x20acquisition\x20flywheel\x20—\x20`rewardStrategy`\x20/\x20`discountStrategy`','\x20\x20/\x20`trustSellingPoints`.\x20A\x20concrete\x20(non-`User-defined`)\x20strategy\x20turns','\x20\x20the\x20`reward`/`discount`\x20levers\x20on\x20for\x20strategy\x20alignment.','-\x20`key_risk`\x20(string)\x20/\x20`build_notes`\x20(string[]):\x20the\x20headline\x20risk\x20and','\x20\x20actionable\x20build\x20guidance\x20shown\x20to\x20the\x20merchant.','-\x20`capabilities_used`:\x20CapabilityCard\x20IDs\x20(e.g.\x20`guard.validate_buy`,','\x20\x20`machine.node_topology`,\x20`allocation.distribute_milestone`).\x20Powers\x20the','\x20\x20`buy_guard`\x20/\x20`machine_design`\x20levers\x20and\x20constraint\x20checks.','-\x20`config_overrides`:\x20per-object\x20field\x20defaults,\x20e.g.','\x20\x20`{\x20service:\x20{\x20engagement_type:\x20\x27milestone\x27\x20},\x20machine:\x20{\x20wip_required:\x20true\x20}\x20}`.','-\x20`config_override_rules`:\x20conditional\x20overrides\x20—','\x20\x20`{\x20object_type,\x20field_path,\x20value\x20|\x20{\x20intent_contains,\x20then_value,\x20else_value\x20}\x20}`.','-\x20`expected_benefits`:\x20`[{\x20metric,\x20expected_value,\x20evidence\x20}]`\x20—\x20what\x20the','\x20\x20mode\x20is\x20supposed\x20to\x20buy\x20you.','-\x20`risk_appetite`:\x20`conservative`\x20|\x20`balanced`\x20|\x20`aggressive`\x20(thresholds','\x20\x20for\x20the\x20risk/benefit\x20verdict).','-\x20`risk_constraints`:\x20`{\x20require_arbitration,\x20require_compensation_fund,','\x20\x20require_wip_evidence,\x20max_single_transaction?,','\x20\x20compensation_fund_coverage_ratio?,\x20other_constraints?\x20}`.\x20Coverage\x20ratio','\x20\x20multiplies\x20max\x20single\x20order\x20to\x20size\x20the\x20compensation\x20fund\x20(retail\x205,','\x20\x20rental\x2010,\x20subscription\x203;\x20default\x205).','-\x20`applicable_conditions`:\x20`{\x20business_scale,\x20min_daily_orders?,','\x20\x20other_conditions?\x20}`\x20—\x20when\x20the\x20mode\x20fits.','-\x20`similar_industries`\x20/\x20`novel_capabilities`:\x20migration\x20hints.','-\x20`disabled_builtin_constraints`:\x20builtin\x20constraint\x20IDs\x20this\x20mode','\x20\x20deliberately\x20opts\x20out\x20of\x20(e.g.\x20retail_d2c\x20skips\x20`require_arbitration`).','\x20\x20Custom\x20constraints\x20are\x20never\x20skipped.','','###\x20Persona\x20integration\x20(strategy\x20→\x20levers)','','The\x20personae\x20section\x27s\x20`current.strategy`\x20statements\x20are\x20bridged\x20into\x20mode','ranking\x20(value\x20intent\x20↔\x20game\x20path\x20unification).\x20Deterministic\x20mapping\x20—','\x22enumerable\x20→\x20MCP,\x20not\x20prompt\x22:','','-\x20`sales_priority`\x20(volume\x20first)\x20→\x20levers\x20`discount`\x20+\x20`reward`','-\x20`profit_priority`\x20(margin\x20first)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','-\x20`buyer_screening`\x20(qualify\x20buyers)\x20→\x20lever\x20`buy_guard`','-\x20`gross_margin_control`\x20(margin\x20band)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','','A\x20mode\x20supports\x20a\x20lever\x20when\x20its\x20data\x20says\x20so:\x20`guard.validate_buy`','capability\x20or\x20a\x20buy-guard\x20template\x20enables\x20`buy_guard`;\x20a\x20concrete','flywheel\x20reward/discount\x20strategy\x20enables\x20`reward`/`discount`;\x20a','non-empty\x20`machine_shape`\x20with\x20`machine.node_topology`\x20enables','`machine_design`.\x20Pass\x20strategy\x20text\x20to\x20`recommend_industry`\x20and\x20each','recommendation\x20reports\x20`strategy_alignment`\x20(matched/missing\x20levers).','','##\x20custom-registry.json\x20—\x20your\x20custom\x20rules\x20(managed\x20by\x20the\x20AI)','','This\x20file\x20stores\x20customizations\x20that\x20apply\x20to\x20EVERY\x20industry\x20pack:','-\x20`metrics`\x20—\x20extra\x20scoring\x20dimensions\x20you\x20asked\x20the\x20AI\x20to\x20evaluate','\x20\x20(e.g.\x20\x22add\x20an\x20environmental-impact\x20metric\x20to\x20mode\x20evaluation\x22).','-\x20`constraints`\x20—\x20hard\x20rules\x20a\x20mode\x20must\x20satisfy\x20(e.g.\x20\x22must\x20always','\x20\x20include\x20arbitration\x22).','-\x20`user_modes`\x20—\x20your\x20own\x20industry\x20modes\x20derived\x20from\x20the\x20built-ins.','','You\x20normally\x20never\x20touch\x20this\x20file:\x20just\x20ask\x20the\x20AI\x20in\x20chat\x20(for','example\x20\x22register\x20a\x20custom\x20metric\x20...\x22),\x20and\x20it\x20writes\x20the\x20entry','here\x20for\x20you.\x20Deleting\x20an\x20entry\x20removes\x20that\x20customization.\x20If\x20you','edit\x20it\x20by\x20hand\x20anyway,\x20changes\x20take\x20effect\x20without\x20a\x20restart.','An\x20absent\x20or\x20empty\x20file\x20is\x20normal\x20—\x20it\x20simply\x20means\x20you\x20have\x20not','created\x20any\x20custom\x20metrics,\x20constraints\x20or\x20modes\x20yet.','','##\x20Templates\x20(`<pack>/templates/*.md`)','','Each\x20template\x20.md\x20has\x20two\x20parts:','','-\x20**Frontmatter**\x20(the\x20`---\x20...\x20---`\x20block):\x20machine-readable\x20settings\x20—','\x20\x20`id`,\x20`industry`,\x20`variant`,\x20`machine_shape`,\x20`guards`,\x20`allocator`,','\x20\x20`fee_params`,\x20…\x20In\x20the\x20client\x27s\x20VIEW\x20mode\x20these\x20render\x20as\x20a\x20table','\x20\x20(hover\x20a\x20key\x20for\x20its\x20meaning);\x20EDIT\x20mode\x20shows\x20the\x20raw\x20text.','-\x20**Markdown\x20body**:\x20free-form\x20guidance\x20for\x20the\x20AI\x20(Key\x20risk,','\x20\x20Differences,\x20Build\x20notes,\x20…).','','###\x20Impact\x20and\x20risks\x20of\x20editing\x20templates','','-\x20The\x20frontmatter\x20is\x20**strictly\x20validated\x20on\x20every\x20load**\x20by\x20the\x20AI','\x20\x20runtime\x20(allowed\x20keys,\x20value\x20types,\x20ranges,\x20`id`/`industry`/`variant`','\x20\x20consistency\x20with\x20the\x20file\x20location).\x20A\x20template\x20that\x20fails\x20validation','\x20\x20is\x20**skipped\x20with\x20a\x20loud\x20error**\x20—\x20tools\x20that\x20read\x20templates\x20report','\x20\x20the\x20file\x20and\x20the\x20exact\x20field\x20problem\x20until\x20you\x20fix\x20it.\x20Guidance\x20in','\x20\x20the\x20broken\x20template\x20will\x20NOT\x20reach\x20the\x20AI\x20while\x20it\x20is\x20invalid.','-\x20The\x20**client\x20editor\x20validates\x20on\x20save**\x20(same\x20rules)\x20and\x20blocks\x20the','\x20\x20write,\x20so\x20most\x20mistakes\x20never\x20reach\x20disk.\x20Edits\x20made\x20OUTSIDE\x20the','\x20\x20client\x20bypass\x20this\x20gate\x20—\x20run\x20a\x20Scan\x20afterwards\x20and\x20watch\x20for\x20errors.','-\x20Keep\x20the\x20Markdown\x20body\x20free-form\x20—\x20it\x20is\x20never\x20validated.\x20Breaking','\x20\x20the\x20`---`\x20structure\x20is\x20what\x20matters.','','###\x20How\x20to\x20recover\x20a\x20broken\x20template','','1.\x20Fix\x20the\x20field\x20named\x20in\x20the\x20error\x20(type/range/enum\x20mismatch),\x20or','2.\x20**Delete\x20the\x20.md\x20file**\x20—\x20the\x20built-in\x20version\x20is\x20re-seeded','\x20\x20\x20automatically\x20at\x20the\x20next\x20startup\x20/\x20template\x20scan\x20(seeding\x20never','\x20\x20\x20overwrites\x20an\x20existing\x20file,\x20so\x20your\x20other\x20edits\x20survive).','3.\x20Right-click\x20a\x20file\x20in\x20the\x20Industry\x20drawer\x20→\x20*Reset*\x20restores\x20the','\x20\x20\x20pristine\x20seeded\x20version\x20too.','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20assume\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event\x20or\x20charge\x20a\x2015%\x20fee.\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to\x20never\x20concede\x20on.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(Add\x20when\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full\x20evidence\x20+\x20arbitration\x20—\x20call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Add\x20logo,\x20link-out\x20style,\x20forbidden\x20terminology,\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Add\x20non-negotiables.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Add\x20ethical\x20guardrails.\x20Example:\x20\x22If\x20a\x20customer\x20appears\x20intoxicated,\x20refuse\x20service\x20and\x20refer\x20to\x20a\x20supervisor.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
|
|
1
|
+
import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{seedBuiltinTemplates}from'../knowledge/template-loader.js';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{STRATEGY_MANUAL_FILENAME,renderStrategyManual,classifyManualFile}from'../knowledge/strategy-manuals.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryBaselines}from'./industry-layers.js';import{validateJudgmentFragment}from'../config/judgment.js';import{getIndustryProfile,registerIndustry}from'../knowledge/industry-registry.js';import{composeIndustries,DEFAULT_TRAITS,inferTraitsFromDescription,synthesizeProfile}from'../knowledge/industry-generalizer.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||typeof a?.['refund_window']?.['days']==='number'&&a['refund_window']['days']>0x0;}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulBaselines(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&Object['keys'](a)['length']>0x0;}const PLAYBOOK_PLACEHOLDER_RE=/\((?:Example|Add|Write)\b/,PLAYBOOK_SEEDED_BLOCK_HEADINGS=['##\x20Business\x20model\x20—\x20direct\x20sales'];function stripSeededPlaybookBlocks(a){const b=[];let c=![];for(const d of a['split'](/\r?\n/)){const e=d['trim'](),f=e['startsWith']('#');if(f){c=PLAYBOOK_SEEDED_BLOCK_HEADINGS['some'](g=>e===g||e===g['replace'](/^#+\s*/,'#')||normalizeHeading(e)===normalizeHeading(g));if(c)continue;}if(c)continue;b['push'](d);}return b;}function normalizeHeading(a){return a['replace'](/^#+\s*/,'')['trim']()['toLowerCase']()['replace'](/\s+/g,'\x20');}function isMeaningfulPlaybook(a){if(!a)return![];for(const b of stripSeededPlaybookBlocks(a['content']??'')){const c=b['trim']();if(c==='')continue;if(c['startsWith']('>'))continue;if(c['startsWith']('#'))continue;if(PLAYBOOK_PLACEHOLDER_RE['test'](c))continue;return!![];}return![];}const TRAIT_BOOLEAN_KEYS=['has_logistics','communication_heavy','pure_digital','long_cycle','deposit_required','multi_tier_allocation'],TRAIT_ENUM_KEYS=['regulatory_intensity','trust_sensitivity','consumption_frequency','avg_ticket_size'];function coerceTraits(a){if(!a||typeof a!=='object')return undefined;const b={...DEFAULT_TRAITS};let c=![];for(const d of TRAIT_BOOLEAN_KEYS){typeof a[d]==='boolean'&&(b[d]=a[d],c=!![]);}for(const e of TRAIT_ENUM_KEYS){typeof a[e]==='string'&&(b[e]=a[e],c=!![]);}return c?b:undefined;}export function ensureIndustryProfile(a,b){const c=a['manifest']['name'];if(getIndustryProfile(c))return;try{const d=(a['manifest']['depends_on']??[])['filter'](g=>typeof g==='string'&&g['length']>0x0);if(d['length']>0x0){const g=composeIndustries(d,c);if(!g)throw new Error('depends_on\x20parents\x20not\x20registered:\x20'+d['join'](',\x20'));g['display_name']=a['manifest']['display_name']||g['display_name'],g['source']='composed',registerIndustry(g);return;}const e=coerceTraits(a['manifest']['traits'])??inferTraitsFromDescription(a['manifest']['display_name']||c)['traits'],f=synthesizeProfile(e,c);f['display_name']=a['manifest']['display_name']||f['display_name'],f['source']='custom',registerIndustry(f);}catch(h){b['push']('industry\x20profile\x20registration\x20failed\x20for\x20\x27'+c+'\x27:\x20'+h['message']);}}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;ensureIndustryProfile(a,c);if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):d['push']('rules');}}if(e['layers']['includes']('baselines')){if(!a['baselines'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27baselines\x27\x20but\x20baselines.json\x20is\x20missing');else{if(!isMeaningfulBaselines(a['baselines'])){}else{const m=validateJudgmentFragment(a['baselines'],e['name']+'.baselines');if(m)c['push'](m);else!registerIndustryBaselines({'category':e['name'],'fragment':a['baselines']},i)?c['push']('baselines\x20for\x20\x27'+e['name']+'\x27\x20already\x20registered'):d['push']('baselines');}}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const q=b['manifest'],r={'layout':'merged','manifest':q};if(b['mode'])r['mode']=b['mode'];if(b['match'])r['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(r['personae']=b['personae']);if(b['dispute'])r['dispute']=b['dispute'];if(b['compliance'])r['compliance']=b['compliance'];if(b['supply'])r['supply']=b['supply'];if(b['rules'])r['rules']=b['rules'];if(b['baselines'])r['baselines']=b['baselines'];const s=join(a,'playbook.md');return existsSync(s)&&(r['playbook']={'category':q['name'],'content':readFileSync(s,'utf-8')}),r;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const t=[];for(const u of readdirSync(j)){if(!u['endsWith']('.json'))continue;t['push'](JSON['parse'](readFileSync(join(j,u),'utf-8')));}if(t['length']>0x0)g['personae']=t;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'baselines.json');existsSync(o)&&(g['baselines']=JSON['parse'](readFileSync(o,'utf-8')));const p=join(a,'playbook.md');return existsSync(p)&&(g['playbook']={'category':e['name'],'content':readFileSync(p,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),seedBuiltinTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export function seedBuiltinStrategyManuals(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();for(const d of a){const e=renderStrategyManual(d);if(!e)continue;const f=join(c,d,STRATEGY_MANUAL_FILENAME);try{const g=join(c,d);if(!existsSync(join(g,'manifest.json'))&&!existsSync(join(g,'pack.json'))){const j=scaffoldIndustryPack(d,c);if(!j['ok']){b['push']({'industry':d,'status':'error','path':f,'detail':j['errors']['join'](';\x20')});continue;}}if(!existsSync(f)){writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'written','path':f});continue;}const h=readFileSync(f,'utf-8'),i=classifyManualFile(d,h);if(i==='outdated')writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'updated','path':f});else{if(i==='current')b['push']({'industry':d,'status':'current','path':f});else i==='user_modified'?b['push']({'industry':d,'status':'skipped_user_modified','path':f,'detail':'strategy-manual.md\x20was\x20edited\x20locally;\x20keeping\x20user\x20content\x20and\x20not\x20upgrading'}):b['push']({'industry':d,'status':'skipped_user_file','path':f,'detail':'strategy-manual.md\x20exists\x20without\x20builtin\x20sentinel;\x20leaving\x20user\x20file\x20untouched'});}}catch(k){b['push']({'industry':d,'status':'error','path':f,'detail':k['message']});}}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode','baselines.json':'baselines'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'not_applicable':!![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'baselines':null,'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20Pack\x20layers\x20are\x20registered\x20into\x20the\x20runtime\x20registry\x20and','>\x20consumed\x20on\x20demand\x20by\x20the\x20build/recommendation\x20tools\x20(merchant_guide,','>\x20recommend_industry,\x20…);\x20a\x20compact\x20strategy\x20summary\x20for\x20the\x20active','>\x20merchant/supplier\x20lens\x20is\x20injected\x20into\x20every\x20chat\x20turn.','','##\x20Business\x20model\x20—\x20DIRECT\x20SALES,\x20freedom\x20for\x20the\x20merchant','','**WoWok\x20takes\x20no\x20platform\x20commission.\x20A\x20merchant\x20pays\x20only\x20gas.**\x20This\x20is','the\x20product\x27s\x20core\x20positioning,\x20and\x20every\x20template,\x20manual\x20and\x20playbook\x20in','this\x20tree\x20is\x20written\x20under\x20it.','','Three\x20layers,\x20do\x20not\x20conflate\x20them:','','-\x20**L1\x20Protocol\x20—\x20never\x20extracts.**\x20The\x20framework\x20has\x20no\x20platform-take','\x20\x20concept\x20at\x20all:\x20every\x20`order_allocators`\x20sharing\x20item\x20is\x20configured\x20by','\x20\x20the\x20merchant\x20and\x20every\x20recipient\x20is\x20chosen\x20by\x20the\x20merchant.','-\x20**L2\x20Template\x20default\x20—\x20100%\x20to\x20the\x20merchant.**\x20Built-in\x20templates','\x20\x20demonstrate\x20the\x20most\x20efficient\x20P2P\x20form:\x20a\x20single\x20`Rate\x2010000`\x20leg\x20to','\x20\x20the\x20merchant\x27s\x20own\x20Entity,\x20zero\x20platform\x20leg.\x20Never\x20copy\x20an\x20incumbent','\x20\x20marketplace\x20split\x20(host\x20commission\x20+\x20guest\x20service\x20fee)\x20into\x20an','\x20\x20allocator\x20—\x20under\x20this\x20model\x20nobody\x20receives\x20it.','-\x20**L3\x20Merchant\x20freedom\x20—\x20a\x20fee\x20is\x20allowed.**\x20When\x20the\x20merchant\x20IS\x20the','\x20\x20aggregator\x20(a\x20chain,\x20a\x20multi-supplier\x20orchestrator,\x20a\x20consortium),\x20it','\x20\x20may\x20charge\x20its\x20own\x20service\x20fee.\x20Three\x20constraints\x20make\x20that\x20honest:','\x20\x201.\x20**Explicit\x20number.**\x20Never\x20an\x20implicit\x20remainder\x20such\x20as','\x20\x20\x20\x20\x20`commission\x20=\x20order\x20total\x20-\x20segment\x20sums`.\x20A\x20buyer\x20must\x20be\x20able\x20to','\x20\x20\x20\x20\x20compute\x20the\x20take\x20BEFORE\x20ordering.','\x20\x202.\x20**Explicit\x20non-empty\x20recipient\x20Entity**\x20the\x20buyer\x20can\x20see\x20pre-order.','\x20\x20\x20\x20\x20An\x20EMPTY\x20Entity\x20(`\x22\x22`)\x20silently\x20routes\x20the\x20share\x20to\x20the\x20deploying','\x20\x20\x20\x20\x20AI/host\x27s\x20own\x20account\x20(`ts-sdk/w/local/index.ts:81-86`).','\x20\x203.\x20**No\x20mandatory\x20transit.**\x20The\x20organizer\x20pool\x20must\x20not\x20be\x20a\x20required','\x20\x20\x20\x20\x20waypoint\x20for\x20the\x20merchant\x27s\x20own\x20payout,\x20and\x20a\x20`Surplus`\x20leg\x20must','\x20\x20\x20\x20\x20never\x20be\x20how\x20the\x20fee\x20is\x20taken\x20—\x20`Surplus`\x20calls','\x20\x20\x20\x20\x20`balance::withdraw_all`,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool.','','**Why\x20efficiency,\x20not\x20a\x20rate\x20cut.**\x20A\x20legacy\x20marketplace\x27s\x20edge\x20is\x20a\x20rate','cut.\x20WoWok\x27s\x20edge\x20is\x20that\x20a\x20merchant\x20keeps\x20the\x20whole\x20sale\x20AND\x20gets:','escrow\x20that\x20moves\x20only\x20between\x20the\x20two\x20parties,\x20an\x20independent\x20venue,','and\x20a\x20public\x20pre-order\x20outcome\x20ledger.\x20Compete\x20on\x20escrow/arbitration','value,\x20never\x20on\x20price.','','**Merchant-facing\x20audit\x20invariants**\x20(`template_scan`):','','-\x20`R-ECON-01`\x20any\x20`fee_params`\x20platform/commission\x20key\x20!=\x200\x20→\x20ERROR','-\x20`R-ECON-02`\x20fee\x20taken\x20as\x20an\x20implicit\x20remainder\x20/\x20`Surplus`\x20drain\x20→\x20ERROR','-\x20`R-ECON-03`\x20non-zero\x20third-party\x20share\x20with\x20an\x20EMPTY\x20recipient\x20→\x20ERROR','-\x20`R-ECON-04`\x20a\x20mandatory\x20transit\x20pool\x20on\x20the\x20payout\x20path\x20→\x20WARN','-\x20`R-ECON-05`\x20attribution-weighted\x20take\x20(attributed\x20>\x20base)\x20→\x20WARN','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files,\x20plus\x20an\x20optional\x20`templates/`\x20folder:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20Registered\x20on\x20scan\x20and\x20read\x20ON\x20DEMAND\x20via\x20industry_pack_operation','\x20\x20(action=\x27get\x27);\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for\x20this\x20account.','-\x20**`<pack>/templates/*.md`**\x20—\x20archetype\x20templates\x20(see\x20the\x20Templates','\x20\x20section\x20below).\x20The\x2012\x20built-in\x20variants\x20are\x20seeded\x20here\x20automatically.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20registered\x20layers\x20are\x20available\x20to\x20the','\x20\x20\x20on-demand\x20tools\x20(and\x20the\x20merchant/supplier\x20strategy\x20summary\x20is\x20fresh','\x20\x20\x20in\x20the\x20persona\x20context),\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules','\x20\x20\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Legal','\x20\x20layer\x20names:\x20`match`,\x20`personae`,\x20`dispute`,\x20`compliance`,\x20`supply`,','\x20\x20`rules`,\x20`baselines`,\x20`playbook`\x20(plus\x20`mode`\x20when\x20you\x20add\x20a\x20driving','\x20\x20mode).\x20Remove\x20a\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in','\x20\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20baselines\x20—\x20judgment\x20baselines\x20overlay\x20(Q12)','','`baselines`\x20carries\x20a\x20PARTIAL\x20judgment\x20baselines\x20document\x20(same\x20shape\x20as','the\x20user\x27s\x20judgment.json).\x20It\x20is\x20merged\x20into\x20the\x20judgment\x20chain','BETWEEN\x20the\x20factory\x20document\x20and\x20the\x20persona\x20fragment:','','\x20\x20\x20\x20factory\x20<\x20pack\x20baselines\x20<\x20persona\x20fragment\x20<\x20user\x20document\x20<\x20session\x20overrides','','A\x20pack\x20may\x20RETUNE\x20factory\x20parameters\x20or\x20DISABLE\x20factory\x20rules','(`enabled:\x20false`\x20—\x20a\x20disable\x20trace\x20is\x20recorded).\x20It\x20can\x20NEVER\x20invent\x20new','dimensions/rules\x20or\x20delete\x20factory\x20entries:\x20only\x20keys\x20and\x20ids\x20that\x20exist','in\x20the\x20factory\x20document\x20are\x20accepted.\x20Tuning\x20example:','','```json','\x22baselines\x22:\x20{','\x20\x20\x22version\x22:\x201,','\x20\x20\x22evaluation\x22:\x20{\x20\x22severity_deduction\x22:\x20{\x20\x22critical\x22:\x2040\x20}\x20},','\x20\x20\x22monitor\x22:\x20{\x20\x22thresholds\x22:\x20{\x20\x22messenger_timeout_hours\x22:\x2012\x20}\x20}','}','```','','Disabling\x20a\x20factory\x20rule\x20(the\x20rule\x20id\x20must\x20exist,\x20e.g.\x20in\x20the\x20`util`','domain):','','```json','{\x20\x22rules\x22:\x20{\x20\x22domains\x22:\x20{\x20\x22util\x22:\x20{\x20\x22rules\x22:\x20[','\x20\x20{\x20\x22rule_id\x22:\x20\x22R-UTIL-03\x22,\x20\x22enabled\x22:\x20false\x20}',']\x20}\x20}\x20}\x20}','```','','A\x20misspelled\x20dimension\x20or\x20an\x20invented\x20rule\x20id\x20is\x20REJECTED\x20at\x20registration','(and\x20on\x20every\x20scan/rescan)\x20with\x20a\x20visible\x20error\x20—\x20the\x20last\x20good','registration\x20stays\x20in\x20force\x20until\x20the\x20fragment\x20is\x20fixed.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','Registered\x20into\x20`IndustryModeRegistry`\x20on\x20scan\x20(manifest\x20must\x20list\x20the','`mode`\x20layer).\x20A\x20pack\x20mode\x20with\x20the\x20same\x20name\x20as\x20a\x20builtin\x20replaces\x20it\x20when','the\x20pack\x20version\x20changes\x20or\x20on\x20a\x20forced\x20rescan.','','###\x20How\x20the\x20mode\x20is\x20consumed','','-\x20**Service\x20build\x20(priors)**:\x20`merchant_guide`\x20resolves\x20the\x20confirmed','\x20\x20industry\x20to\x20a\x20mode\x20(user\x20mode\x20first,\x20then\x20pack\x20mode,\x20then\x20builtin)\x20and','\x20\x20feeds\x20`machine_shape`\x20/\x20`guards`\x20/\x20`allocator`\x20/\x20`key_risk`\x20into\x20the','\x20\x20SemanticObjectGraph\x20build.','-\x20**Evaluation**:\x20the\x20metric\x20+\x20constraint\x20registries\x20score\x20the\x20mode','\x20\x20(risk/benefit\x200-100,\x20hard\x20violations\x20block\x20adoption).\x20Custom\x20metrics\x20and','\x20\x20constraints\x20registered\x20via\x20`industry_pack_operation`\x20participate\x20too.','-\x20**Recommendation**:\x20`recommend_industry`\x20matches\x20trait\x20similarity\x20and,','\x20\x20when\x20a\x20merchant\x20strategy\x20is\x20given,\x20re-ranks\x20by\x20lever\x20alignment\x20(70%','\x20\x20similarity\x20+\x2030%\x20alignment).','','###\x20Field\x20reference','','-\x20**Identity**:\x20`name`\x20(snake_case),\x20`display_name`,\x20`version`\x20(e.g.\x20`v1`),','\x20\x20`source`\x20(`builtin`\x20|\x20`custom`).','-\x20`traits`:\x2010-dimension\x20industry\x20trait\x20vector\x20(logistics,\x20cycle,\x20deposit,','\x20\x20regulatory\x20intensity,\x20...).\x20Drives\x20`recommend_industry`\x20similarity.','-\x20`machine_shape`:\x20Machine\x20node\x20topology\x20—\x20`[{\x20name,\x20role\x20}]`.\x20Node\x20names\x20are','\x20\x20business\x20states.\x20R-M1-11:\x20NEVER\x20model\x20refund/dispute\x20terminals','\x20\x20(`refunded`,\x20`disputed`,\x20`arb_*`)\x20as\x20nodes\x20—\x20disputes\x20flow\x20through','\x20\x20Service.arbitrations\x20independently;\x20route\x20refunds\x20via\x20the\x20Allocator','\x20\x20triggered\x20by\x20business\x20states\x20(`cancelled`,\x20`returned`).','-\x20`guards`:\x20`[{\x20template_id,\x20host,\x20purpose\x20}]`\x20—\x20guard\x20templates\x20to\x20attach.','\x20\x20`host`\x20is\x20one\x20of\x20`service`\x20|\x20`machine`\x20|\x20`reward`\x20|\x20`repository`\x20|','\x20\x20`arbitration`.','-\x20`allocator`:\x20`{\x20recipient,\x20count,\x20mode,\x20description\x20}`\x20—\x20fund\x20split.','\x20\x20`recipient`:\x20`signer`\x20|\x20`entity`;\x20`count`\x20>\x201\x20switches\x20to\x20multi-party','\x20\x20distribution;\x20`mode`:\x20`surplus`\x20|\x20`rate`\x20|\x20`milestone`.','-\x20`risk_checks`\x20/\x20`needs`:\x20buyer-side\x20due-diligence\x20entries\x20surfaced\x20in','\x20\x20prospect\x20evaluation.','-\x20`flywheel`:\x20acquisition\x20flywheel\x20—\x20`rewardStrategy`\x20/\x20`discountStrategy`','\x20\x20/\x20`trustSellingPoints`.\x20A\x20concrete\x20(non-`User-defined`)\x20strategy\x20turns','\x20\x20the\x20`reward`/`discount`\x20levers\x20on\x20for\x20strategy\x20alignment.','-\x20`key_risk`\x20(string)\x20/\x20`build_notes`\x20(string[]):\x20the\x20headline\x20risk\x20and','\x20\x20actionable\x20build\x20guidance\x20shown\x20to\x20the\x20merchant.','-\x20`capabilities_used`:\x20CapabilityCard\x20IDs\x20(e.g.\x20`guard.validate_buy`,','\x20\x20`machine.node_topology`,\x20`allocation.distribute_milestone`).\x20Powers\x20the','\x20\x20`buy_guard`\x20/\x20`machine_design`\x20levers\x20and\x20constraint\x20checks.','-\x20`config_overrides`:\x20per-object\x20field\x20defaults,\x20e.g.','\x20\x20`{\x20service:\x20{\x20engagement_type:\x20\x27milestone\x27\x20},\x20machine:\x20{\x20wip_required:\x20true\x20}\x20}`.','-\x20`config_override_rules`:\x20conditional\x20overrides\x20—','\x20\x20`{\x20object_type,\x20field_path,\x20value\x20|\x20{\x20intent_contains,\x20then_value,\x20else_value\x20}\x20}`.','-\x20`expected_benefits`:\x20`[{\x20metric,\x20expected_value,\x20evidence\x20}]`\x20—\x20what\x20the','\x20\x20mode\x20is\x20supposed\x20to\x20buy\x20you.','-\x20`risk_appetite`:\x20`conservative`\x20|\x20`balanced`\x20|\x20`aggressive`\x20(thresholds','\x20\x20for\x20the\x20risk/benefit\x20verdict).','-\x20`risk_constraints`:\x20`{\x20require_arbitration,\x20require_compensation_fund,','\x20\x20require_wip_evidence,\x20max_single_transaction?,','\x20\x20compensation_fund_coverage_ratio?,\x20other_constraints?\x20}`.\x20Coverage\x20ratio','\x20\x20multiplies\x20max\x20single\x20order\x20to\x20size\x20the\x20compensation\x20fund\x20(retail\x205,','\x20\x20rental\x2010,\x20subscription\x203;\x20default\x205).','-\x20`applicable_conditions`:\x20`{\x20business_scale,\x20min_daily_orders?,','\x20\x20other_conditions?\x20}`\x20—\x20when\x20the\x20mode\x20fits.','-\x20`similar_industries`\x20/\x20`novel_capabilities`:\x20migration\x20hints.','-\x20`disabled_builtin_constraints`:\x20builtin\x20constraint\x20IDs\x20this\x20mode','\x20\x20deliberately\x20opts\x20out\x20of\x20(e.g.\x20retail_d2c\x20skips\x20`require_arbitration`).','\x20\x20Custom\x20constraints\x20are\x20never\x20skipped.','','###\x20Persona\x20integration\x20(strategy\x20→\x20levers)','','The\x20personae\x20section\x27s\x20`current.strategy`\x20statements\x20are\x20bridged\x20into\x20mode','ranking\x20(value\x20intent\x20↔\x20game\x20path\x20unification).\x20Deterministic\x20mapping\x20—','\x22enumerable\x20→\x20MCP,\x20not\x20prompt\x22:','','-\x20`sales_priority`\x20(volume\x20first)\x20→\x20levers\x20`discount`\x20+\x20`reward`','-\x20`profit_priority`\x20(margin\x20first)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','-\x20`buyer_screening`\x20(qualify\x20buyers)\x20→\x20lever\x20`buy_guard`','-\x20`gross_margin_control`\x20(margin\x20band)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','','A\x20mode\x20supports\x20a\x20lever\x20when\x20its\x20data\x20says\x20so:\x20`guard.validate_buy`','capability\x20or\x20a\x20buy-guard\x20template\x20enables\x20`buy_guard`;\x20a\x20concrete','flywheel\x20reward/discount\x20strategy\x20enables\x20`reward`/`discount`;\x20a','non-empty\x20`machine_shape`\x20with\x20`machine.node_topology`\x20enables','`machine_design`.\x20Pass\x20strategy\x20text\x20to\x20`recommend_industry`\x20and\x20each','recommendation\x20reports\x20`strategy_alignment`\x20(matched/missing\x20levers).','','##\x20custom-registry.json\x20—\x20your\x20custom\x20rules\x20(managed\x20by\x20the\x20AI)','','This\x20file\x20stores\x20customizations\x20that\x20apply\x20to\x20EVERY\x20industry\x20pack:','-\x20`metrics`\x20—\x20extra\x20scoring\x20dimensions\x20you\x20asked\x20the\x20AI\x20to\x20evaluate','\x20\x20(e.g.\x20\x22add\x20an\x20environmental-impact\x20metric\x20to\x20mode\x20evaluation\x22).','-\x20`constraints`\x20—\x20hard\x20rules\x20a\x20mode\x20must\x20satisfy\x20(e.g.\x20\x22must\x20always','\x20\x20include\x20arbitration\x22).','-\x20`user_modes`\x20—\x20your\x20own\x20industry\x20modes\x20derived\x20from\x20the\x20built-ins.','','You\x20normally\x20never\x20touch\x20this\x20file:\x20just\x20ask\x20the\x20AI\x20in\x20chat\x20(for','example\x20\x22register\x20a\x20custom\x20metric\x20...\x22),\x20and\x20it\x20writes\x20the\x20entry','here\x20for\x20you.\x20Deleting\x20an\x20entry\x20removes\x20that\x20customization.\x20If\x20you','edit\x20it\x20by\x20hand\x20anyway,\x20changes\x20take\x20effect\x20without\x20a\x20restart.','An\x20absent\x20or\x20empty\x20file\x20is\x20normal\x20—\x20it\x20simply\x20means\x20you\x20have\x20not','created\x20any\x20custom\x20metrics,\x20constraints\x20or\x20modes\x20yet.','','##\x20Templates\x20(`<pack>/templates/*.md`)','','Each\x20template\x20.md\x20has\x20two\x20parts:','','-\x20**Frontmatter**\x20(the\x20`---\x20...\x20---`\x20block):\x20machine-readable\x20settings\x20—','\x20\x20`id`,\x20`industry`,\x20`variant`,\x20`machine_shape`,\x20`guards`,\x20`allocator`,','\x20\x20`fee_params`,\x20…\x20In\x20the\x20client\x27s\x20VIEW\x20mode\x20these\x20render\x20as\x20a\x20table','\x20\x20(hover\x20a\x20key\x20for\x20its\x20meaning);\x20EDIT\x20mode\x20shows\x20the\x20raw\x20text.','-\x20**Markdown\x20body**:\x20free-form\x20guidance\x20for\x20the\x20AI\x20(Key\x20risk,','\x20\x20Differences,\x20Build\x20notes,\x20…).','','###\x20Impact\x20and\x20risks\x20of\x20editing\x20templates','','-\x20The\x20frontmatter\x20is\x20**strictly\x20validated\x20on\x20every\x20load**\x20by\x20the\x20AI','\x20\x20runtime\x20(allowed\x20keys,\x20value\x20types,\x20ranges,\x20`id`/`industry`/`variant`','\x20\x20consistency\x20with\x20the\x20file\x20location).\x20A\x20template\x20that\x20fails\x20validation','\x20\x20is\x20**skipped\x20with\x20a\x20loud\x20error**\x20—\x20tools\x20that\x20read\x20templates\x20report','\x20\x20the\x20file\x20and\x20the\x20exact\x20field\x20problem\x20until\x20you\x20fix\x20it.\x20Guidance\x20in','\x20\x20the\x20broken\x20template\x20will\x20NOT\x20reach\x20the\x20AI\x20while\x20it\x20is\x20invalid.','-\x20The\x20**client\x20editor\x20validates\x20on\x20save**\x20(same\x20rules)\x20and\x20blocks\x20the','\x20\x20write,\x20so\x20most\x20mistakes\x20never\x20reach\x20disk.\x20Edits\x20made\x20OUTSIDE\x20the','\x20\x20client\x20bypass\x20this\x20gate\x20—\x20run\x20a\x20Scan\x20afterwards\x20and\x20watch\x20for\x20errors.','-\x20Keep\x20the\x20Markdown\x20body\x20free-form\x20—\x20it\x20is\x20never\x20validated.\x20Breaking','\x20\x20the\x20`---`\x20structure\x20is\x20what\x20matters.','','###\x20How\x20to\x20recover\x20a\x20broken\x20template','','1.\x20Fix\x20the\x20field\x20named\x20in\x20the\x20error\x20(type/range/enum\x20mismatch),\x20or','2.\x20**Delete\x20the\x20.md\x20file**\x20—\x20the\x20built-in\x20version\x20is\x20re-seeded','\x20\x20\x20automatically\x20at\x20the\x20next\x20startup\x20/\x20template\x20scan\x20(seeding\x20never','\x20\x20\x20overwrites\x20an\x20existing\x20file,\x20so\x20your\x20other\x20edits\x20survive).','3.\x20Right-click\x20a\x20file\x20in\x20the\x20Industry\x20drawer\x20→\x20*Reset*\x20restores\x20the','\x20\x20\x20pristine\x20seeded\x20version\x20too.','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Business\x20model\x20—\x20direct\x20sales','','WoWok\x20takes\x20no\x20platform\x20commission\x20—\x20a\x20merchant\x20in\x20'+a+'\x20pays\x20only','gas,\x20and\x20the\x20default\x20payout\x20gives\x20the\x20merchant\x20the\x20whole\x20sale.\x20Never\x20copy','an\x20incumbent\x20marketplace\x20split\x20into\x20an\x20allocator:\x20that\x20share\x20is\x20displaced','by\x20design,\x20not\x20a\x20parameter,\x20and\x20nobody\x20would\x20receive\x20it.\x20If\x20the\x20merchant','IS\x20the\x20aggregator\x20(a\x20chain,\x20a\x20multi-supplier\x20orchestrator,\x20a\x20consortium)','it\x20may\x20charge\x20its\x20OWN\x20fee,\x20but\x20only\x20with:\x20an\x20explicit\x20number\x20the\x20buyer','can\x20compute\x20before\x20ordering;\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20(an','empty\x20one\x20silently\x20routes\x20the\x20share\x20to\x20the\x20deploying\x20AI/host\x20—\x20see','`ts-sdk/w/local/index.ts:74-86`);\x20and\x20no\x20mandatory\x20transit\x20pool\x20on\x20the','payout\x20path\x20—\x20never\x20a\x20fee\x20via\x20a\x20`Surplus`\x20leg,\x20which\x20calls','`balance::withdraw_all`\x20and\x20so\x20doubles\x20as\x20draining\x20the\x20pool.\x20Compete\x20on','escrow/arbitration\x20value,\x20not\x20price.','','>\x20Rule\x20of\x20thumb\x20for\x20everything\x20below:\x20any\x20fee,\x20cut\x20or\x20margin\x20recorded\x20in','>\x20the\x20Experience\x20and\x20Strategy\x20sections\x20is\x20MERCHANT\x20REVENUE\x20—\x20an\x20explicit,','>\x20disclosed\x20number\x20in\x20an\x20allocator\x20leg\x20with\x20a\x20non-empty\x20recipient\x20Entity.','>\x20It\x20is\x20never\x20a\x20platform\x20share,\x20and\x20it\x20must\x20never\x20be\x20an\x20implicit\x20remainder','>\x20(order\x20total\x20minus\x20segment\x20sums)\x20or\x20a\x20`Surplus`\x20entry.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20assume\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event,\x20or\x20charge\x20YOUR\x20OWN\x20disclosed\x2015%\x20change\x20fee\x20(merchant\x20revenue,\x20not\x20a\x20platform\x20take;\x20explicit\x20number,\x20non-empty\x20recipient\x20Entity,\x20declared\x20before\x20ordering).\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to\x20never\x20concede\x20on.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(Add\x20when\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full\x20evidence\x20+\x20arbitration\x20—\x20call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Add\x20logo,\x20link-out\x20style,\x20forbidden\x20terminology,\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Add\x20non-negotiables.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Add\x20ethical\x20guardrails.\x20Example:\x20\x22If\x20a\x20customer\x20appears\x20intoxicated,\x20refuse\x20service\x20and\x20refer\x20to\x20a\x20supervisor.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
|