@neuroverseos/governance 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.well-known/ai-plugin.json +34 -9
  2. package/AGENTS.md +72 -24
  3. package/README.md +352 -237
  4. package/dist/adapters/autoresearch.cjs +1152 -3
  5. package/dist/adapters/autoresearch.d.cts +11 -3
  6. package/dist/adapters/autoresearch.d.ts +11 -3
  7. package/dist/adapters/autoresearch.js +9 -4
  8. package/dist/adapters/deep-agents.cjs +1528 -0
  9. package/dist/adapters/deep-agents.d.cts +181 -0
  10. package/dist/adapters/deep-agents.d.ts +181 -0
  11. package/dist/adapters/deep-agents.js +17 -0
  12. package/dist/adapters/express.cjs +171 -32
  13. package/dist/adapters/express.d.cts +1 -1
  14. package/dist/adapters/express.d.ts +1 -1
  15. package/dist/adapters/express.js +5 -5
  16. package/dist/adapters/index.cjs +564 -121
  17. package/dist/adapters/index.d.cts +3 -1
  18. package/dist/adapters/index.d.ts +3 -1
  19. package/dist/adapters/index.js +38 -16
  20. package/dist/adapters/langchain.cjs +217 -57
  21. package/dist/adapters/langchain.d.cts +5 -5
  22. package/dist/adapters/langchain.d.ts +5 -5
  23. package/dist/adapters/langchain.js +6 -5
  24. package/dist/adapters/openai.cjs +219 -59
  25. package/dist/adapters/openai.d.cts +5 -5
  26. package/dist/adapters/openai.d.ts +5 -5
  27. package/dist/adapters/openai.js +6 -5
  28. package/dist/adapters/openclaw.cjs +217 -57
  29. package/dist/adapters/openclaw.d.cts +6 -6
  30. package/dist/adapters/openclaw.d.ts +6 -6
  31. package/dist/adapters/openclaw.js +6 -5
  32. package/dist/add-ROOZLU62.js +314 -0
  33. package/dist/behavioral-MJO34S6Q.js +118 -0
  34. package/dist/{bootstrap-GXVDZNF7.js → bootstrap-CQRZVOXK.js} +6 -4
  35. package/dist/bootstrap-emitter-Q7UIJZ2O.js +7 -0
  36. package/dist/bootstrap-parser-EEF36XDU.js +7 -0
  37. package/dist/browser.global.js +941 -0
  38. package/dist/{build-P42YFKQV.js → build-QKOBBC23.js} +7 -5
  39. package/dist/{chunk-COT5XS4V.js → chunk-3WQLXYTP.js} +17 -35
  40. package/dist/{chunk-ER62HNGF.js → chunk-4FLICVVA.js} +17 -37
  41. package/dist/chunk-5TPFNWRU.js +215 -0
  42. package/dist/chunk-5U2MQO5P.js +57 -0
  43. package/dist/{chunk-NF5POFCI.js → chunk-6S5CFQXY.js} +6 -4
  44. package/dist/{chunk-QPASI2BR.js → chunk-A7GKPPU7.js} +49 -10
  45. package/dist/{chunk-OGL7QXZS.js → chunk-B6OXJLJ5.js} +17 -3
  46. package/dist/{chunk-2PQU3VAN.js → chunk-BNKJPUPQ.js} +17 -35
  47. package/dist/chunk-BQZMOEML.js +43 -0
  48. package/dist/chunk-CNSO6XW5.js +207 -0
  49. package/dist/{chunk-JZPQGIKR.js → chunk-CTZHONLA.js} +65 -9
  50. package/dist/chunk-D2UCV5AK.js +326 -0
  51. package/dist/{chunk-XPDMYECO.js → chunk-EMQDLDAF.js} +1 -185
  52. package/dist/{chunk-GR6DGCZ2.js → chunk-F66BVUYB.js} +3 -3
  53. package/dist/{chunk-2NICNKOM.js → chunk-G7DJ6VOD.js} +5 -4
  54. package/dist/{chunk-4A7LISES.js → chunk-IS4WUH6Y.js} +45 -6
  55. package/dist/{chunk-MWDQ4MJB.js → chunk-MH7BT4VH.js} +5 -1
  56. package/dist/chunk-O5ABKEA7.js +304 -0
  57. package/dist/chunk-PVTQQS3Y.js +186 -0
  58. package/dist/{chunk-4QXB6PEO.js → chunk-QLPTHTVB.js} +37 -16
  59. package/dist/chunk-QWGCMQQD.js +16 -0
  60. package/dist/{chunk-T5EUJQE5.js → chunk-QXBFT7NI.js} +31 -2
  61. package/dist/{chunk-PDOZHZWL.js → chunk-TG6SEF24.js} +25 -4
  62. package/dist/chunk-U6U7EJZL.js +177 -0
  63. package/dist/{chunk-4JRYGIO7.js → chunk-W7LLXRGY.js} +110 -7
  64. package/dist/{chunk-BUWWN2NX.js → chunk-ZJTDUCC2.js} +9 -7
  65. package/dist/{chunk-FYS2CBUW.js → chunk-ZWI3NIXK.js} +10 -0
  66. package/dist/cli/neuroverse.cjs +5091 -2348
  67. package/dist/cli/neuroverse.js +52 -21
  68. package/dist/cli/plan.cjs +881 -41
  69. package/dist/cli/plan.js +7 -15
  70. package/dist/cli/run.cjs +289 -34
  71. package/dist/cli/run.js +4 -4
  72. package/dist/{configure-ai-TK67ZWZL.js → configure-ai-6TZ3MCSI.js} +1 -1
  73. package/dist/decision-flow-M63D47LO.js +61 -0
  74. package/dist/demo-G43RLCPK.js +469 -0
  75. package/dist/{derive-TLIV4OOU.js → derive-FJZVIPUZ.js} +5 -4
  76. package/dist/{doctor-XPDLEYXN.js → doctor-6BC6X2VO.js} +6 -4
  77. package/dist/equity-penalties-SG5IZQ7I.js +244 -0
  78. package/dist/{explain-IDCRWMPX.js → explain-RHBU2GBR.js} +6 -25
  79. package/dist/{guard-RV65TT4L.js → guard-AJCCGZMF.js} +8 -12
  80. package/dist/{guard-contract-WZx__PmU.d.cts → guard-contract-DqFcTScd.d.cts} +117 -5
  81. package/dist/{guard-contract-WZx__PmU.d.ts → guard-contract-DqFcTScd.d.ts} +117 -5
  82. package/dist/{guard-engine-JLTUARGU.js → guard-engine-PNR6MHCM.js} +3 -3
  83. package/dist/{impact-XPECYRLH.js → impact-3XVDSCBU.js} +5 -5
  84. package/dist/{improve-GPUBKTEA.js → improve-TQP4ECSY.js} +7 -26
  85. package/dist/index.cjs +5597 -4279
  86. package/dist/index.d.cts +597 -18
  87. package/dist/index.d.ts +597 -18
  88. package/dist/index.js +134 -41
  89. package/dist/{infer-world-7GVZWFX4.js → infer-world-IFXCACJ5.js} +1 -1
  90. package/dist/{init-PKPIYHYE.js → init-FYPV4SST.js} +1 -1
  91. package/dist/{init-world-VWMQZQC7.js → init-world-TI7ARHBT.js} +1 -1
  92. package/dist/mcp-server-5Y3ZM7TV.js +13 -0
  93. package/dist/{model-adapter-BB7G4MFI.js → model-adapter-VXEKB4LS.js} +1 -1
  94. package/dist/{playground-E664U4T6.js → playground-VZBNPPBO.js} +29 -19
  95. package/dist/{redteam-Z7WREJ44.js → redteam-MZPZD3EF.js} +4 -4
  96. package/dist/session-JYOARW54.js +15 -0
  97. package/dist/shared-7RLUHNMU.js +16 -0
  98. package/dist/shared-B8dvUUD8.d.cts +60 -0
  99. package/dist/shared-Dr5Wiay8.d.ts +60 -0
  100. package/dist/{simulate-VDOYQFRO.js → simulate-LJXYBC6M.js} +8 -33
  101. package/dist/{test-OGXJK4QU.js → test-BOOR4A5F.js} +4 -4
  102. package/dist/{trace-JVF67VR3.js → trace-PKV4KX56.js} +4 -4
  103. package/dist/{validate-LLBWVPGV.js → validate-RALX7CZS.js} +2 -2
  104. package/dist/{validate-engine-UIABSIHD.js → validate-engine-7ZXFVGF2.js} +1 -1
  105. package/dist/viz/assets/index-B8SaeJZZ.js +23 -0
  106. package/dist/viz/index.html +23 -0
  107. package/dist/{world-LAXO6DOX.js → world-BIP4GZBZ.js} +9 -11
  108. package/dist/world-loader-Y6HMQH2D.js +13 -0
  109. package/dist/worlds/coding-agent.nv-world.md +211 -0
  110. package/dist/worlds/research-agent.nv-world.md +169 -0
  111. package/dist/worlds/social-media.nv-world.md +198 -0
  112. package/dist/worlds/trading-agent.nv-world.md +218 -0
  113. package/examples/social-media-sim/bridge.py +209 -0
  114. package/examples/social-media-sim/simulation.py +927 -0
  115. package/package.json +30 -4
  116. package/policies/content-moderation-rules.txt +8 -0
  117. package/policies/marketing-rules.txt +8 -0
  118. package/policies/science-research-rules.txt +11 -0
  119. package/policies/social-media-rules.txt +7 -0
  120. package/policies/strict-rules.txt +8 -0
  121. package/policies/trading-rules.txt +8 -0
  122. package/simulate.html +1567 -0
  123. package/dist/chunk-YZFATT7X.js +0 -9
  124. package/dist/mcp-server-FPVSU32Z.js +0 -13
  125. package/dist/session-EKTRSR7C.js +0 -14
  126. package/dist/world-loader-HMPTOEA2.js +0 -9
@@ -0,0 +1,314 @@
1
+ import {
2
+ addGuard,
3
+ addInvariant,
4
+ addRule,
5
+ classifyIntent,
6
+ parseGuardDescription
7
+ } from "./chunk-5TPFNWRU.js";
8
+ import "./chunk-7P3S7MAY.js";
9
+ import {
10
+ describeActiveWorld,
11
+ resolveWorldPath
12
+ } from "./chunk-AKW5YVCE.js";
13
+ import "./chunk-QWGCMQQD.js";
14
+
15
+ // src/cli/add.ts
16
+ function parseTriggerExpr(expr) {
17
+ const match = expr.match(/^(\S+)\s*(==|!=|>=|<=|>|<|in)\s*(.+?)(?:\s*\[(state|assumption)\])?\s*$/);
18
+ if (!match) {
19
+ throw new Error(`Invalid trigger expression: "${expr}". Expected: "field op value [state|assumption]"`);
20
+ }
21
+ const [, field, operator, rawValue, source] = match;
22
+ let value = rawValue.trim();
23
+ const num = Number(value);
24
+ if (!isNaN(num) && value !== "") value = num;
25
+ else if (value === "true") value = true;
26
+ else if (value === "false") value = false;
27
+ else if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
28
+ value = value.slice(1, -1);
29
+ }
30
+ return {
31
+ field,
32
+ operator,
33
+ value,
34
+ source: source ?? "state"
35
+ };
36
+ }
37
+ function parseEffectExpr(expr) {
38
+ const match = expr.match(/^(\S+)\s*(\*=|\+=|-=|=)\s*(.+)\s*$/);
39
+ if (!match) {
40
+ throw new Error(`Invalid effect expression: "${expr}". Expected: "target op value" (e.g., "viability *= 0.5")`);
41
+ }
42
+ const [, target, op, rawValue] = match;
43
+ const operationMap = {
44
+ "*=": "multiply",
45
+ "+=": "add",
46
+ "-=": "subtract",
47
+ "=": "set"
48
+ };
49
+ let value = rawValue.trim();
50
+ const num = Number(value);
51
+ if (!isNaN(num) && value !== "") value = num;
52
+ else if (value === "true") value = true;
53
+ else if (value === "false") value = false;
54
+ return {
55
+ target,
56
+ operation: operationMap[op],
57
+ value
58
+ };
59
+ }
60
+ function parseArgs(argv) {
61
+ const args = {
62
+ subcommand: "auto",
63
+ worldPath: "",
64
+ label: "",
65
+ json: false,
66
+ patterns: [],
67
+ appliesTo: [],
68
+ triggers: [],
69
+ effects: []
70
+ };
71
+ if (argv.length === 0) {
72
+ throw new Error('Usage: neuroverse add <guard|rule|invariant|"description"> --world <path>');
73
+ }
74
+ const first = argv[0];
75
+ if (first === "guard" || first === "rule" || first === "invariant") {
76
+ args.subcommand = first;
77
+ argv = argv.slice(1);
78
+ } else if (!first.startsWith("--")) {
79
+ args.subcommand = "auto";
80
+ args.rawText = first;
81
+ argv = argv.slice(1);
82
+ }
83
+ for (let i = 0; i < argv.length; i++) {
84
+ const arg = argv[i];
85
+ switch (arg) {
86
+ case "--world":
87
+ args.worldPath = argv[++i];
88
+ break;
89
+ case "--label":
90
+ args.label = argv[++i];
91
+ break;
92
+ case "--id":
93
+ args.id = argv[++i];
94
+ break;
95
+ case "--json":
96
+ args.json = true;
97
+ break;
98
+ case "--enforcement":
99
+ args.enforcement = argv[++i];
100
+ break;
101
+ case "--pattern":
102
+ args.patterns.push(argv[++i]);
103
+ break;
104
+ case "--category":
105
+ args.category = argv[++i];
106
+ break;
107
+ case "--applies-to":
108
+ args.appliesTo.push(argv[++i]);
109
+ break;
110
+ case "--severity":
111
+ args.severity = argv[++i];
112
+ break;
113
+ case "--trigger":
114
+ args.triggers.push(argv[++i]);
115
+ break;
116
+ case "--effect":
117
+ args.effects.push(argv[++i]);
118
+ break;
119
+ case "--description":
120
+ args.description = argv[++i];
121
+ break;
122
+ case "--help":
123
+ case "-h":
124
+ printUsage();
125
+ process.exit(0);
126
+ break;
127
+ default:
128
+ if (!arg.startsWith("--") && args.subcommand === "auto" && !args.rawText) {
129
+ args.rawText = arg;
130
+ }
131
+ }
132
+ }
133
+ return args;
134
+ }
135
+ function printUsage() {
136
+ process.stdout.write(`
137
+ neuroverse add \u2014 Incremental governance authoring
138
+
139
+ Usage:
140
+ neuroverse add "Block dairy orders" --world ./world/
141
+ neuroverse add guard --world ./world/ --label "Block dairy orders" --pattern "*dairy*"
142
+ neuroverse add rule --world ./world/ --label "Cost overrun" --severity degradation --trigger "cost > 100" --effect "viability *= 0.5"
143
+ neuroverse add invariant --world ./world/ --label "Budget must never exceed 1000"
144
+
145
+ Auto mode:
146
+ Pass a quoted description as the first argument. The engine classifies it
147
+ as a guard, rule, or invariant based on the language used.
148
+
149
+ "Block ..." / "Prevent ..." / "Deny ..." \u2192 guard
150
+ "If ... then ..." / "When ... reduce ..." \u2192 rule
151
+ "... must always ..." / "... must never ..." \u2192 invariant
152
+
153
+ Flags:
154
+ --world <path> World directory (required)
155
+ --id <id> Explicit ID (auto-generated if omitted)
156
+ --json Full JSON output
157
+
158
+ Guard:
159
+ --enforcement <type> block | pause | warn (default: block)
160
+ --pattern <glob> Intent pattern (repeatable)
161
+ --category <cat> structural | operational | advisory
162
+
163
+ Rule:
164
+ --severity <level> structural | degradation | advantage
165
+ --trigger <expr> "field op value [state|assumption]" (repeatable)
166
+ --effect <expr> "target op value" e.g. "viability *= 0.5" (repeatable)
167
+ --description <text>
168
+
169
+ Invariant:
170
+ --enforcement <type> structural | prompt (default: structural)
171
+ `.trimStart());
172
+ }
173
+ async function main(argv = process.argv.slice(2)) {
174
+ try {
175
+ const args = parseArgs(argv);
176
+ const worldPath = resolveWorldPath(args.worldPath);
177
+ if (!worldPath) {
178
+ throw new Error(
179
+ "No world specified. Use --world <path>, set NEUROVERSE_WORLD, or run `neuroverse world use <name>`"
180
+ );
181
+ }
182
+ const worldInfo = describeActiveWorld(args.worldPath);
183
+ if (worldInfo) {
184
+ process.stderr.write(`Using world: ${worldInfo.name}
185
+ `);
186
+ }
187
+ let result;
188
+ if (args.subcommand === "auto") {
189
+ const text = args.rawText ?? args.label;
190
+ if (!text) {
191
+ throw new Error('Provide a description: neuroverse add "Block dairy orders" --world ./world/');
192
+ }
193
+ const type = classifyIntent(text);
194
+ switch (type) {
195
+ case "guard": {
196
+ const input = parseGuardDescription(text);
197
+ if (args.id) input.id = args.id;
198
+ process.stderr.write(`Classified as: guard (${input.enforcement})
199
+ `);
200
+ result = await addGuard(worldPath, input);
201
+ break;
202
+ }
203
+ case "invariant": {
204
+ process.stderr.write(`Classified as: invariant
205
+ `);
206
+ result = await addInvariant(worldPath, {
207
+ label: text,
208
+ id: args.id
209
+ });
210
+ break;
211
+ }
212
+ case "rule":
213
+ case "ambiguous": {
214
+ if (type === "ambiguous") {
215
+ process.stderr.write(`Could not auto-classify. Defaulting to guard.
216
+ `);
217
+ process.stderr.write(`Tip: use "neuroverse add guard|rule|invariant" for explicit control.
218
+ `);
219
+ } else {
220
+ process.stderr.write(`Classified as: rule
221
+ `);
222
+ process.stderr.write(`Note: auto-mode creates a minimal rule. Use explicit "neuroverse add rule" with --trigger and --effect for full control.
223
+ `);
224
+ }
225
+ const input = parseGuardDescription(text);
226
+ if (args.id) input.id = args.id;
227
+ result = await addGuard(worldPath, input);
228
+ break;
229
+ }
230
+ default:
231
+ throw new Error(`Unexpected classification: ${type}`);
232
+ }
233
+ } else if (args.subcommand === "guard") {
234
+ const label = args.label;
235
+ if (!label) throw new Error("--label is required for guard");
236
+ const input = {
237
+ label,
238
+ enforcement: args.enforcement ?? "block",
239
+ intentPatterns: args.patterns.length > 0 ? args.patterns : [`*${label.toLowerCase().replace(/\s+/g, "*")}*`],
240
+ description: args.description,
241
+ category: args.category,
242
+ appliesTo: args.appliesTo.length > 0 ? args.appliesTo : void 0,
243
+ id: args.id
244
+ };
245
+ result = await addGuard(worldPath, input);
246
+ } else if (args.subcommand === "rule") {
247
+ const label = args.label;
248
+ if (!label) throw new Error("--label is required for rule");
249
+ if (args.triggers.length === 0) throw new Error("At least one --trigger is required for rule");
250
+ const input = {
251
+ label,
252
+ severity: args.severity ?? "degradation",
253
+ description: args.description,
254
+ triggers: args.triggers.map(parseTriggerExpr),
255
+ effects: args.effects.length > 0 ? args.effects.map(parseEffectExpr) : void 0,
256
+ id: args.id
257
+ };
258
+ result = await addRule(worldPath, input);
259
+ } else if (args.subcommand === "invariant") {
260
+ const label = args.label;
261
+ if (!label) throw new Error("--label is required for invariant");
262
+ result = await addInvariant(worldPath, {
263
+ label,
264
+ enforcement: args.enforcement ?? "structural",
265
+ id: args.id
266
+ });
267
+ } else {
268
+ throw new Error(`Unknown subcommand: ${args.subcommand}`);
269
+ }
270
+ if (args.json) {
271
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
272
+ } else {
273
+ const icon = result.type === "guard" ? "GUARD" : result.type === "rule" ? "RULE" : "INVARIANT";
274
+ process.stdout.write(`
275
+ [${icon}] Added: ${result.id}
276
+ `);
277
+ process.stdout.write(` File: ${result.file}
278
+ `);
279
+ process.stdout.write(` Valid: ${result.valid ? "yes" : "no"}
280
+ `);
281
+ const errors = result.findings.filter((f) => f.severity === "error");
282
+ const warnings = result.findings.filter((f) => f.severity === "warning");
283
+ if (errors.length > 0) {
284
+ process.stdout.write(` Errors: ${errors.length}
285
+ `);
286
+ for (const e of errors.slice(0, 3)) {
287
+ process.stdout.write(` - ${e.message}
288
+ `);
289
+ }
290
+ }
291
+ if (warnings.length > 0) {
292
+ process.stdout.write(` Warnings: ${warnings.length}
293
+ `);
294
+ for (const w of warnings.slice(0, 3)) {
295
+ process.stdout.write(` - ${w.message}
296
+ `);
297
+ }
298
+ }
299
+ if (result.valid && errors.length === 0) {
300
+ process.stdout.write(`
301
+ Ready. Guard will be enforced on next evaluation.
302
+ `);
303
+ }
304
+ }
305
+ process.exit(result.valid ? 0 : 1);
306
+ } catch (e) {
307
+ process.stderr.write(`Error: ${e instanceof Error ? e.message : String(e)}
308
+ `);
309
+ process.exit(3);
310
+ }
311
+ }
312
+ export {
313
+ main
314
+ };
@@ -0,0 +1,118 @@
1
+ import {
2
+ adaptationFromVerdict,
3
+ detectBehavioralPatterns,
4
+ generateAdaptationNarrative
5
+ } from "./chunk-CNSO6XW5.js";
6
+ import {
7
+ readAuditLog
8
+ } from "./chunk-A7GKPPU7.js";
9
+ import "./chunk-W7LLXRGY.js";
10
+ import "./chunk-QLPTHTVB.js";
11
+ import "./chunk-QWGCMQQD.js";
12
+
13
+ // src/cli/behavioral.ts
14
+ var USAGE = `
15
+ neuroverse behavioral \u2014 Behavioral analysis from audit log
16
+
17
+ Usage:
18
+ neuroverse behavioral [options]
19
+
20
+ Options:
21
+ --log <path> Path to audit log (default: .neuroverse/audit.ndjson)
22
+ --json Raw JSON output
23
+
24
+ Classifies agent adaptations, detects network-level patterns
25
+ (coordinated silence, misinfo suppression, reward cascades),
26
+ and generates a human-readable narrative.
27
+ `.trim();
28
+ function parseArgs(argv) {
29
+ const args = {};
30
+ for (let i = 0; i < argv.length; i++) {
31
+ const arg = argv[i];
32
+ if (arg === "--json") args.json = true;
33
+ else if (arg === "--help" || arg === "-h") args.help = true;
34
+ else if (arg === "--log" && argv[i + 1]) args.log = argv[++i];
35
+ }
36
+ return args;
37
+ }
38
+ async function main(argv = process.argv.slice(2)) {
39
+ const args = parseArgs(argv);
40
+ if (args.help) {
41
+ process.stdout.write(USAGE + "\n");
42
+ process.exit(0);
43
+ }
44
+ const logPath = args.log ?? ".neuroverse/audit.ndjson";
45
+ const events = await readAuditLog(logPath);
46
+ if (events.length === 0) {
47
+ process.stderr.write(`No audit events found in ${logPath}
48
+ `);
49
+ process.stderr.write("Run governance evaluations with audit logging enabled to generate events.\n");
50
+ process.exit(0);
51
+ }
52
+ const adaptations = events.map((event) => {
53
+ const agentId = event.actor ?? "unknown";
54
+ const intended = event.intent;
55
+ const executed = event.decision === "BLOCK" ? "idle" : intended;
56
+ const verdict = {
57
+ status: event.decision,
58
+ reason: event.reason,
59
+ ruleId: event.ruleId,
60
+ evidence: { worldId: event.worldId, worldName: event.worldName, worldVersion: event.worldVersion, evaluatedAt: Date.now(), invariantsSatisfied: 0, invariantsTotal: 0, guardsMatched: [], rulesMatched: [], enforcementLevel: "standard" }
61
+ };
62
+ return adaptationFromVerdict(agentId, intended, executed, verdict);
63
+ });
64
+ const uniqueAgents = new Set(adaptations.map((a) => a.agentId)).size;
65
+ const patterns = detectBehavioralPatterns(adaptations, uniqueAgents);
66
+ const narrative = generateAdaptationNarrative(patterns);
67
+ if (args.json) {
68
+ process.stdout.write(JSON.stringify({ adaptations: adaptations.length, agents: uniqueAgents, patterns, narrative }, null, 2) + "\n");
69
+ } else {
70
+ process.stdout.write("\nBehavioral Analysis\n");
71
+ process.stdout.write("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n");
72
+ process.stdout.write(` Events analyzed: ${events.length}
73
+ `);
74
+ process.stdout.write(` Agents observed: ${uniqueAgents}
75
+ `);
76
+ process.stdout.write(` Adaptations: ${adaptations.length}
77
+ `);
78
+ process.stdout.write(` Patterns found: ${patterns.length}
79
+
80
+ `);
81
+ if (patterns.length > 0) {
82
+ process.stdout.write("Patterns Detected\n");
83
+ process.stdout.write("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n");
84
+ for (const p of patterns) {
85
+ process.stdout.write(` ${p.type} (${p.agentsAffected} agents)
86
+ `);
87
+ process.stdout.write(` ${p.description}
88
+
89
+ `);
90
+ }
91
+ }
92
+ if (narrative) {
93
+ process.stdout.write("Narrative\n");
94
+ process.stdout.write("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n");
95
+ process.stdout.write(` ${narrative}
96
+
97
+ `);
98
+ }
99
+ const shiftCounts = {};
100
+ for (const a of adaptations) {
101
+ const key = a.shiftType ?? `${a.intendedAction}\u2192${a.executedAction}`;
102
+ shiftCounts[key] = (shiftCounts[key] ?? 0) + 1;
103
+ }
104
+ const sortedShifts = Object.entries(shiftCounts).sort((a, b) => b[1] - a[1]);
105
+ if (sortedShifts.length > 0) {
106
+ process.stdout.write("Shift Breakdown\n");
107
+ process.stdout.write("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n");
108
+ for (const [shift, count] of sortedShifts.slice(0, 10)) {
109
+ process.stdout.write(` ${shift}: ${count}
110
+ `);
111
+ }
112
+ process.stdout.write("\n");
113
+ }
114
+ }
115
+ }
116
+ export {
117
+ main
118
+ };
@@ -2,10 +2,12 @@ import {
2
2
  BOOTSTRAP_EXIT_CODES
3
3
  } from "./chunk-4NGDRRQH.js";
4
4
  import {
5
- emitWorldDefinition,
6
5
  parseWorldMarkdown
7
- } from "./chunk-XPDMYECO.js";
8
- import "./chunk-YZFATT7X.js";
6
+ } from "./chunk-EMQDLDAF.js";
7
+ import {
8
+ emitWorldDefinition
9
+ } from "./chunk-PVTQQS3Y.js";
10
+ import "./chunk-QWGCMQQD.js";
9
11
 
10
12
  // src/cli/bootstrap.ts
11
13
  function parseArgs(argv) {
@@ -82,7 +84,7 @@ async function main(argv = process.argv.slice(2)) {
82
84
  await writeWorldFiles(args.outputPath, emitResult.world);
83
85
  let validateReport;
84
86
  if (args.validate) {
85
- const { validateWorld } = await import("./validate-engine-UIABSIHD.js");
87
+ const { validateWorld } = await import("./validate-engine-7ZXFVGF2.js");
86
88
  validateReport = validateWorld(emitResult.world);
87
89
  }
88
90
  const result = {
@@ -0,0 +1,7 @@
1
+ import {
2
+ emitWorldDefinition
3
+ } from "./chunk-PVTQQS3Y.js";
4
+ import "./chunk-QWGCMQQD.js";
5
+ export {
6
+ emitWorldDefinition
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ parseWorldMarkdown
3
+ } from "./chunk-EMQDLDAF.js";
4
+ import "./chunk-QWGCMQQD.js";
5
+ export {
6
+ parseWorldMarkdown
7
+ };