@myclaw163/clawclaw-cli 0.8.6 → 0.8.8

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.
@@ -1,9 +1,13 @@
1
1
  import { Command } from 'commander';
2
+ import { basename, extname, resolve } from 'node:path';
2
3
  import { loadContext } from '../lib/load-context.js';
3
4
  import { AuthStore } from '../lib/auth.js';
4
5
  import { noAccountMessage } from '../lib/account-guidance.js';
5
6
  import { runAutoUpgradeOnLoad } from '../runtime/auto-upgrade.js';
6
- import { CLAWCLAW_ROLE_IDS, readGameplayConfig } from '../lib/gameplay-config.js';
7
+ import {
8
+ CLAWCLAW_ROLE_IDS,
9
+ readGameplayConfig,
10
+ } from '../lib/gameplay-config.js';
7
11
  import { getWorkspaceDir } from '../lib/init-command.js';
8
12
  import {
9
13
  ensureAccountUserDataLayout,
@@ -29,6 +33,7 @@ import { PERCEPTION_PLUGIN_API_VERSION } from '../sdk/perception-plugin/index.js
29
33
  import { pluginApiVersionStatus } from '../runtime/clawclaw/plugins/plugin-api-version.js';
30
34
  import {
31
35
  readLocalAgentWorkspaceSnapshot,
36
+ resolveLocalAgentWorkspacePath,
32
37
  resolveLocalAgentWorkspaceSnapshot,
33
38
  syncAgentWorkspaceConfig,
34
39
  type AgentWorkspaceSyncResult,
@@ -40,6 +45,17 @@ import {
40
45
  mergeAgentWorkspaceBehaviorSources,
41
46
  mergeAgentWorkspacePerceptionSources,
42
47
  } from '../lib/agent-workspace-runtime.js';
48
+ import {
49
+ diagnoseRejectedCapabilityModule,
50
+ listCapabilityModuleCandidates,
51
+ warningFromStaticDiagnostic,
52
+ type CapabilityLoadWarning,
53
+ type ModuleCapabilityType,
54
+ } from '../lib/capability-load-diagnostics.js';
55
+ import { resolveClawclawResourceMetadata } from '../sdk/resource-metadata.js';
56
+
57
+ const LOAD_SCHEMA = 'ccl.load.v2';
58
+ const LOAD_DISPLAY_LOCALE = 'en-US';
43
59
 
44
60
  export interface LoadCommandDependencies {
45
61
  clientFactory?: () => ParticipationStatusClient;
@@ -48,6 +64,120 @@ export interface LoadCommandDependencies {
48
64
  skillSync?: typeof syncAgentWorkspaceSkills;
49
65
  }
50
66
 
67
+ function compatibilityWarning(
68
+ type: ModuleCapabilityType,
69
+ source: 'hub' | 'local',
70
+ value: {
71
+ readonly id: string;
72
+ readonly name: string;
73
+ readonly sourcePath: string;
74
+ readonly management?: {
75
+ readonly resourceId?: string;
76
+ readonly versionId?: string;
77
+ };
78
+ },
79
+ reason: string,
80
+ ): CapabilityLoadWarning {
81
+ return {
82
+ code: 'CAPABILITY_NOT_LOADED',
83
+ capability_type: type,
84
+ source,
85
+ reason,
86
+ stage: 'static_discovery',
87
+ id: value.id,
88
+ name: value.name,
89
+ file: basename(value.sourcePath),
90
+ path: value.sourcePath,
91
+ ...(value.management?.resourceId ? { resource_id: value.management.resourceId } : {}),
92
+ ...(value.management?.versionId ? { version_id: value.management.versionId } : {}),
93
+ };
94
+ }
95
+
96
+ function missingProjectionWarning(
97
+ type: ModuleCapabilityType,
98
+ item: {
99
+ readonly resourceId: string;
100
+ readonly versionId: string;
101
+ readonly sourceFiles: readonly Readonly<{ relativePath: string }>[];
102
+ },
103
+ ): CapabilityLoadWarning {
104
+ return {
105
+ code: 'CAPABILITY_NOT_LOADED',
106
+ capability_type: type,
107
+ source: 'hub',
108
+ reason: 'projection_missing',
109
+ stage: 'projection',
110
+ resource_id: item.resourceId,
111
+ version_id: item.versionId,
112
+ file: item.sourceFiles[0]?.relativePath ?? item.resourceId,
113
+ path: null,
114
+ };
115
+ }
116
+
117
+ function compactCapabilityWarning(warning: CapabilityLoadWarning): Record<string, unknown> {
118
+ const keys = [
119
+ 'code',
120
+ 'capability_type',
121
+ 'source',
122
+ 'reason',
123
+ 'stage',
124
+ 'id',
125
+ 'file',
126
+ 'expected_import',
127
+ 'received_imports',
128
+ ] as const;
129
+ return Object.fromEntries(keys.flatMap((key) => (
130
+ warning[key] === undefined ? [] : [[key, warning[key]]]
131
+ )));
132
+ }
133
+
134
+ function compactSkillChanges(changes: ReturnType<typeof syncAgentWorkspaceSkills>) {
135
+ const keys = ['added', 'updated', 'removed', 'preservedModified', 'failed'] as const;
136
+ const value = Object.fromEntries(keys.flatMap((key) => (
137
+ changes[key].length === 0 ? [] : [[key, changes[key]]]
138
+ )));
139
+ return Object.keys(value).length > 0 || changes.requiresUserConfirmation
140
+ ? {
141
+ ...value,
142
+ ...(changes.requiresUserConfirmation ? { requires_user_confirmation: true } : {}),
143
+ }
144
+ : undefined;
145
+ }
146
+
147
+ function compactConfigurationWarnings(warnings: readonly Record<string, unknown>[]) {
148
+ return warnings.map((warning) => {
149
+ if (
150
+ warning.code !== 'DEFAULT_LONG_BEHAVIOR_UNAVAILABLE'
151
+ || typeof warning.behavior_id !== 'string'
152
+ || typeof warning.role !== 'string'
153
+ ) {
154
+ return { ...warning };
155
+ }
156
+ return {
157
+ code: 'FALLBACK_BEHAVIOR_NOT_LOADED',
158
+ role: warning.role,
159
+ behavior_id: warning.behavior_id,
160
+ message: `Fallback Behavior ${warning.behavior_id} configured for role ${warning.role} is not loaded.`,
161
+ };
162
+ });
163
+ }
164
+
165
+ function compactParticipation(value: object): Record<string, unknown> {
166
+ const { schema: _schema, ...participation } = value as Record<string, unknown>;
167
+ return participation;
168
+ }
169
+
170
+ function compactPersona(snapshot: ReturnType<typeof loadContext>['persona']) {
171
+ if (!snapshot.exists) return null;
172
+ const name = snapshot.id
173
+ ?? (snapshot.path ? basename(snapshot.path, extname(snapshot.path)) : 'persona');
174
+ return {
175
+ name,
176
+ content: snapshot.content,
177
+ source: snapshot.source ?? 'none',
178
+ };
179
+ }
180
+
51
181
  export function createLoadCommand(dependencies: LoadCommandDependencies = {}): Command {
52
182
  return new Command('load')
53
183
  .description('Read active account context, configured gameplay resources, and backend participation')
@@ -87,13 +217,45 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
87
217
  }
88
218
 
89
219
  const gameplay = readGameplayConfig(workspaceDir, profile);
220
+ const capabilityWarnings: CapabilityLoadWarning[] = [];
90
221
  const disabledBehaviors = new Set(gameplay.disabled_behaviors);
91
222
  const hubBehaviors = activeWorkspace
92
223
  ? listAgentWorkspaceBehaviorSources(workspaceDir, profile, activeWorkspace)
93
224
  : [];
94
- const localBehaviors = listClawclawBehaviorSources(
95
- getUserDataAccountBehaviorsDir(workspaceDir, profile),
96
- ).filter(({ id }) => !disabledBehaviors.has(id));
225
+ const localBehaviorDir = getUserDataAccountBehaviorsDir(workspaceDir, profile);
226
+ const allLocalBehaviors = listClawclawBehaviorSources(localBehaviorDir);
227
+ const localBehaviors = allLocalBehaviors.filter(({ id }) => !disabledBehaviors.has(id));
228
+ const localBehaviorSourcePaths = new Set(allLocalBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
229
+ let expectedLocalBehaviors = localBehaviors.length;
230
+ for (const path of listCapabilityModuleCandidates(localBehaviorDir)) {
231
+ if (localBehaviorSourcePaths.has(resolve(path))) continue;
232
+ const diagnostic = diagnoseRejectedCapabilityModule('behavior', path);
233
+ if (diagnostic.declaredId && disabledBehaviors.has(diagnostic.declaredId)) continue;
234
+ expectedLocalBehaviors += 1;
235
+ capabilityWarnings.push(warningFromStaticDiagnostic('behavior', 'local', diagnostic));
236
+ }
237
+ if (activeWorkspace) {
238
+ const discoveredPaths = new Set(hubBehaviors.map(({ sourcePath }) => resolve(sourcePath)));
239
+ for (const item of activeWorkspace.items.strategy) {
240
+ if (!item.runtimeEntryPath) {
241
+ capabilityWarnings.push(missingProjectionWarning('behavior', item));
242
+ continue;
243
+ }
244
+ const path = resolveLocalAgentWorkspacePath(
245
+ workspaceDir,
246
+ profile,
247
+ activeWorkspace,
248
+ item.runtimeEntryPath,
249
+ );
250
+ if (discoveredPaths.has(resolve(path))) continue;
251
+ capabilityWarnings.push(warningFromStaticDiagnostic(
252
+ 'behavior',
253
+ 'hub',
254
+ diagnoseRejectedCapabilityModule('behavior', path),
255
+ { resourceId: item.resourceId, versionId: item.versionId },
256
+ ));
257
+ }
258
+ }
97
259
  const enabledBehaviors = mergeAgentWorkspaceBehaviorSources(
98
260
  localBehaviors,
99
261
  hubBehaviors,
@@ -125,6 +287,19 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
125
287
  const behaviorEntries = enabledBehaviors.map(behaviorEntry);
126
288
  const behaviors = behaviorEntries.filter(({ loadable }) => loadable);
127
289
  const incompatibleBehaviors = behaviorEntries.filter(({ loadable }) => !loadable);
290
+ for (const source of enabledBehaviors) {
291
+ const compatibilityError = behaviorSourceCompatibilityError(source);
292
+ const reason = source.apiVersion === BEHAVIOR_PLUGIN_API_VERSION
293
+ ? compatibilityError
294
+ : `behavior_api_version_unsupported:expected=${BEHAVIOR_PLUGIN_API_VERSION}:received=${source.apiVersion ?? 'missing'}`;
295
+ if (!reason) continue;
296
+ capabilityWarnings.push(compatibilityWarning(
297
+ 'behavior',
298
+ source.management.source,
299
+ source,
300
+ reason,
301
+ ));
302
+ }
128
303
  const configurationWarnings: Array<Record<string, unknown>> = [];
129
304
  for (const role of CLAWCLAW_ROLE_IDS) {
130
305
  const fallback = gameplay.fallback_behaviors[role];
@@ -143,9 +318,42 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
143
318
  ? listAgentWorkspacePerceptionSources(workspaceDir, profile, activeWorkspace)
144
319
  : [];
145
320
  const hubPerceptionIds = new Set(hubPerceptions.map(({ id }) => id));
146
- const localPerceptions = listClawclawPerceptionSourcesInDirectory(
147
- getUserDataAccountPerceptionsDir(workspaceDir, profile),
148
- ).filter(({ id }) => !disabledPerceptions.has(id));
321
+ const localPerceptionDir = getUserDataAccountPerceptionsDir(workspaceDir, profile);
322
+ const allLocalPerceptions = listClawclawPerceptionSourcesInDirectory(localPerceptionDir);
323
+ const localPerceptions = allLocalPerceptions.filter(({ id }) => !disabledPerceptions.has(id));
324
+ const localPerceptionSourcePaths = new Set(
325
+ allLocalPerceptions.map(({ sourcePath }) => resolve(sourcePath)),
326
+ );
327
+ let expectedLocalPerceptions = localPerceptions.length;
328
+ for (const path of listCapabilityModuleCandidates(localPerceptionDir)) {
329
+ if (localPerceptionSourcePaths.has(resolve(path))) continue;
330
+ const diagnostic = diagnoseRejectedCapabilityModule('perception', path);
331
+ if (diagnostic.declaredId && disabledPerceptions.has(diagnostic.declaredId)) continue;
332
+ expectedLocalPerceptions += 1;
333
+ capabilityWarnings.push(warningFromStaticDiagnostic('perception', 'local', diagnostic));
334
+ }
335
+ if (activeWorkspace) {
336
+ const discoveredPaths = new Set(hubPerceptions.map(({ sourcePath }) => resolve(sourcePath)));
337
+ for (const item of activeWorkspace.items.perception) {
338
+ if (!item.runtimeEntryPath) {
339
+ capabilityWarnings.push(missingProjectionWarning('perception', item));
340
+ continue;
341
+ }
342
+ const path = resolveLocalAgentWorkspacePath(
343
+ workspaceDir,
344
+ profile,
345
+ activeWorkspace,
346
+ item.runtimeEntryPath,
347
+ );
348
+ if (discoveredPaths.has(resolve(path))) continue;
349
+ capabilityWarnings.push(warningFromStaticDiagnostic(
350
+ 'perception',
351
+ 'hub',
352
+ diagnoseRejectedCapabilityModule('perception', path),
353
+ { resourceId: item.resourceId, versionId: item.versionId },
354
+ ));
355
+ }
356
+ }
149
357
  const enabledPerceptions = mergeAgentWorkspacePerceptionSources(
150
358
  localPerceptions,
151
359
  hubPerceptions,
@@ -163,14 +371,34 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
163
371
  const incompatiblePerceptions = enabledPerceptions
164
372
  .filter(({ apiVersion }) => apiVersion !== PERCEPTION_PLUGIN_API_VERSION)
165
373
  .map(perceptionEntry);
166
- const triggerSources = listClawclawTriggerSources(
167
- getUserDataAccountTriggersDir(workspaceDir, profile),
168
- );
169
- const enabledTriggers = triggerSources.filter((source) => (
170
- gameplay.triggers[source.id]?.enabled === true
171
- ));
374
+ for (const source of enabledPerceptions) {
375
+ if (source.apiVersion === PERCEPTION_PLUGIN_API_VERSION) continue;
376
+ capabilityWarnings.push(compatibilityWarning(
377
+ 'perception',
378
+ hubPerceptionIds.has(source.id) ? 'hub' : 'local',
379
+ source,
380
+ `perception_api_version_unsupported:expected=${PERCEPTION_PLUGIN_API_VERSION}:received=${source.apiVersion ?? 'missing'}`,
381
+ ));
382
+ }
383
+ const disabledTriggers = new Set(gameplay.disabled_triggers);
384
+ const localTriggerDir = getUserDataAccountTriggersDir(workspaceDir, profile);
385
+ const triggerSources = listClawclawTriggerSources(localTriggerDir);
386
+ const enabledTriggers = triggerSources.filter((source) => !disabledTriggers.has(source.id));
387
+ const triggerSourcePaths = new Set(triggerSources.map(({ sourcePath }) => resolve(sourcePath)));
388
+ let expectedLocalTriggers = enabledTriggers.length;
389
+ for (const path of listCapabilityModuleCandidates(localTriggerDir)) {
390
+ if (triggerSourcePaths.has(resolve(path))) continue;
391
+ const diagnostic = diagnoseRejectedCapabilityModule('trigger', path);
392
+ if (diagnostic.declaredId && disabledTriggers.has(diagnostic.declaredId)) continue;
393
+ expectedLocalTriggers += 1;
394
+ capabilityWarnings.push(warningFromStaticDiagnostic('trigger', 'local', diagnostic));
395
+ }
396
+ const availableBehaviorIds = new Set(behaviors.map(({ id }) => id));
172
397
  const triggerEntry = (source: typeof enabledTriggers[number]) => {
173
- const loadable = source.apiVersion === TRIGGER_PLUGIN_API_VERSION;
398
+ const behaviorId = gameplay.triggers[source.id]?.behavior ?? source.manifest.defaultBehavior;
399
+ const versionCompatible = source.apiVersion === TRIGGER_PLUGIN_API_VERSION;
400
+ const bindingAvailable = availableBehaviorIds.has(behaviorId);
401
+ const loadable = versionCompatible && bindingAvailable;
174
402
  return {
175
403
  id: source.id,
176
404
  name: source.name,
@@ -179,14 +407,26 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
179
407
  expected_api_version: TRIGGER_PLUGIN_API_VERSION,
180
408
  loadable,
181
409
  ...(loadable ? {} : {
182
- compatibility_error: `trigger_api_version_unsupported:expected=${TRIGGER_PLUGIN_API_VERSION}:received=${source.apiVersion}`,
410
+ compatibility_error: versionCompatible
411
+ ? `trigger_binding_unavailable:${behaviorId}`
412
+ : `trigger_api_version_unsupported:expected=${TRIGGER_PLUGIN_API_VERSION}:received=${source.apiVersion}`,
183
413
  }),
414
+ behavior_id: behaviorId,
184
415
  source: 'local',
185
416
  };
186
417
  };
187
418
  const triggerEntries = enabledTriggers.map(triggerEntry);
188
419
  const triggers = triggerEntries.filter(({ loadable }) => loadable);
189
420
  const incompatibleTriggers = triggerEntries.filter(({ loadable }) => !loadable);
421
+ for (const entry of incompatibleTriggers) {
422
+ const source = enabledTriggers.find(({ id }) => id === entry.id)!;
423
+ capabilityWarnings.push(compatibilityWarning(
424
+ 'trigger',
425
+ 'local',
426
+ source,
427
+ String(entry.compatibility_error),
428
+ ));
429
+ }
190
430
 
191
431
  // Mutate Agent-facing Skill/Persona targets only after every non-Skill
192
432
  // source has been parsed and Hub/local identity conflicts have passed.
@@ -197,6 +437,33 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
197
437
  preservedModified: [],
198
438
  requiresUserConfirmation: false,
199
439
  };
440
+ const hubPersonaItem = activeWorkspace?.items.persona[0];
441
+ if (hubPersonaItem && (
442
+ snapshot.persona.source !== 'hub'
443
+ || snapshot.persona.resource_id !== hubPersonaItem.resourceId
444
+ || snapshot.persona.exists !== true
445
+ )) {
446
+ capabilityWarnings.push({
447
+ code: 'CAPABILITY_NOT_LOADED',
448
+ capability_type: 'persona',
449
+ source: 'hub',
450
+ reason: 'persona_file_unavailable',
451
+ stage: 'selection',
452
+ resource_id: hubPersonaItem.resourceId,
453
+ version_id: hubPersonaItem.versionId,
454
+ path: snapshot.persona.path,
455
+ });
456
+ } else if (snapshot.persona.source === 'local' && snapshot.persona.exists !== true) {
457
+ capabilityWarnings.push({
458
+ code: 'CAPABILITY_NOT_LOADED',
459
+ capability_type: 'persona',
460
+ source: 'local',
461
+ reason: 'persona_file_unavailable',
462
+ stage: 'selection',
463
+ ...(snapshot.persona.id ? { id: snapshot.persona.id } : {}),
464
+ path: snapshot.persona.path,
465
+ });
466
+ }
200
467
  let participation;
201
468
  try {
202
469
  const client = (dependencies.clientFactory ?? (() => GameClient.fromAuth()))();
@@ -210,47 +477,93 @@ export function createLoadCommand(dependencies: LoadCommandDependencies = {}): C
210
477
  const message = error instanceof Error ? error.message : String(error);
211
478
  console.error(`[clawclaw-cli] participation status unavailable: ${message}`);
212
479
  }
213
- console.log(JSON.stringify({
214
- ...snapshot,
215
- workspace_config: {
216
- sync: {
217
- status: workspaceSyncStatus,
218
- revision: activeWorkspace?.revision ?? null,
219
- ...(workspaceResult?.previous
220
- ? { previous_revision: workspaceResult.previous.revision }
221
- : {}),
222
- ...(workspaceSyncError ? { error: workspaceSyncError } : {}),
480
+ const capabilitySummary = {
481
+ behavior: {
482
+ selected_hub: activeWorkspace?.items.strategy.length ?? 0,
483
+ eligible_local: expectedLocalBehaviors,
484
+ available: behaviors.length,
485
+ warnings: capabilityWarnings.filter(({ capability_type }) => (
486
+ capability_type === 'behavior'
487
+ )).length,
488
+ },
489
+ perception: {
490
+ selected_hub: activeWorkspace?.items.perception.length ?? 0,
491
+ eligible_local: expectedLocalPerceptions,
492
+ available: perceptions.length,
493
+ warnings: capabilityWarnings.filter(({ capability_type }) => (
494
+ capability_type === 'perception'
495
+ )).length,
496
+ },
497
+ trigger: {
498
+ selected_hub: 0,
499
+ eligible_local: expectedLocalTriggers,
500
+ available: triggers.length,
501
+ warnings: capabilityWarnings.filter(({ capability_type }) => (
502
+ capability_type === 'trigger'
503
+ )).length,
223
504
  },
224
- items: activeWorkspace
225
- ? Object.fromEntries(Object.entries(activeWorkspace.items).map(([type, items]) => [
226
- type,
227
- items.map((item) => ({
228
- resource_id: item.resourceId,
229
- version_id: item.versionId,
230
- content_digest: item.contentDigest,
231
- resolution: item.resolution ?? 'hub',
232
- ...(item.localContentDigest ? { local_content_digest: item.localContentDigest } : {}),
233
- })),
234
- ]))
235
- : { skill: [], strategy: [], persona: [], perception: [] },
236
- skill_changes: skillChanges,
237
505
  persona: {
238
- source: snapshot.persona.source ?? 'none',
239
- path: snapshot.persona.path,
240
- exists: snapshot.persona.exists,
241
- ...(snapshot.persona.id ? { id: snapshot.persona.id } : {}),
242
- ...(snapshot.persona.resource_id ? { resource_id: snapshot.persona.resource_id } : {}),
506
+ selected_hub: activeWorkspace?.items.persona.length ?? 0,
507
+ selected_local: snapshot.persona.source === 'local' ? 1 : 0,
508
+ available: snapshot.persona.exists ? 1 : 0,
509
+ warnings: capabilityWarnings.filter(({ capability_type }) => (
510
+ capability_type === 'persona'
511
+ )).length,
243
512
  },
244
- requires_user_confirmation: skillChanges.requiresUserConfirmation,
513
+ };
514
+ const behaviorSourceById = new Map(enabledBehaviors.map((source) => [source.id, source]));
515
+ const perceptionSourceById = new Map(enabledPerceptions.map((source) => [source.id, source]));
516
+ const triggerSourceById = new Map(enabledTriggers.map((source) => [source.id, source]));
517
+ const skillChangeSummary = compactSkillChanges(skillChanges);
518
+ console.log(JSON.stringify({
519
+ schema: LOAD_SCHEMA,
520
+ context: {
521
+ persona: compactPersona(snapshot.persona),
522
+ memory: snapshot.memory.content,
523
+ },
524
+ sync: {
525
+ status: workspaceSyncStatus,
526
+ revision: activeWorkspace?.revision ?? null,
527
+ ...(workspaceSyncError ? { error: workspaceSyncError } : {}),
528
+ },
529
+ ...(skillChangeSummary ? { changes: { skills: skillChangeSummary } } : {}),
530
+ capabilities: {
531
+ summary: capabilitySummary,
532
+ behaviors: behaviors.map((entry) => {
533
+ const source = behaviorSourceById.get(entry.id)!;
534
+ const localized = resolveClawclawResourceMetadata(source, LOAD_DISPLAY_LOCALE);
535
+ return {
536
+ id: entry.id,
537
+ name: localized.name,
538
+ description: localized.description,
539
+ source: entry.source,
540
+ };
541
+ }),
542
+ perceptions: perceptions.map((entry) => {
543
+ const source = perceptionSourceById.get(entry.id)!;
544
+ const localized = resolveClawclawResourceMetadata(source.manifest, LOAD_DISPLAY_LOCALE);
545
+ return {
546
+ id: entry.id,
547
+ name: localized.name,
548
+ description: localized.description,
549
+ source: entry.source,
550
+ };
551
+ }),
552
+ triggers: triggers.map((entry) => {
553
+ const source = triggerSourceById.get(entry.id)!;
554
+ const localized = resolveClawclawResourceMetadata(source.manifest, LOAD_DISPLAY_LOCALE);
555
+ return {
556
+ id: entry.id,
557
+ name: localized.name,
558
+ description: localized.description,
559
+ source: entry.source,
560
+ behavior_id: entry.behavior_id,
561
+ };
562
+ }),
563
+ warnings: capabilityWarnings.map(compactCapabilityWarning),
245
564
  },
246
- behaviors,
247
- incompatible_behaviors: incompatibleBehaviors,
248
- perceptions,
249
- incompatible_perceptions: incompatiblePerceptions,
250
- triggers,
251
- incompatible_triggers: incompatibleTriggers,
252
- configuration_warnings: configurationWarnings,
253
- participation,
565
+ configuration_warnings: compactConfigurationWarnings(configurationWarnings),
566
+ participation: compactParticipation(participation),
254
567
  }, null, 2));
255
568
  });
256
569
  }
@@ -83,6 +83,7 @@ function persistedOverride(id: string, config: GameplayTriggerConfig | undefined
83
83
  function triggerEntry(
84
84
  source: ReturnType<typeof triggerSources>[number],
85
85
  config: GameplayTriggerConfig | undefined,
86
+ disabled = false,
86
87
  ): Record<string, unknown> {
87
88
  const override = persistedOverride(source.id, config);
88
89
  const versionCompatible = source.apiVersion === TRIGGER_PLUGIN_API_VERSION;
@@ -113,7 +114,7 @@ function triggerEntry(
113
114
  },
114
115
  configured: config ?? {},
115
116
  effective: {
116
- enabled: override?.enabled ?? false,
117
+ enabled: !disabled,
117
118
  input,
118
119
  behavior: override?.behavior ?? source.manifest.defaultBehavior,
119
120
  behavior_input: behaviorInput,
@@ -188,7 +189,7 @@ async function tryApplyRuntimeConfig(
188
189
 
189
190
  async function updateTrigger(
190
191
  id: string,
191
- update: (config: GameplayTriggerConfig) => void,
192
+ update: (config: GameplayTriggerConfig, disabled: Set<string>) => void,
192
193
  dependencies: TriggerCommandDependencies,
193
194
  ): Promise<void> {
194
195
  const workspaceDir = getWorkspaceDir();
@@ -197,18 +198,20 @@ async function updateTrigger(
197
198
  if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
198
199
  const before = readGameplayConfig(workspaceDir, profile);
199
200
  const nextConfig = { ...(before.triggers[id] ?? {}) };
200
- update(nextConfig);
201
+ const nextDisabled = new Set(before.disabled_triggers);
202
+ update(nextConfig, nextDisabled);
201
203
  const effectiveBehavior = nextConfig.behavior ?? source.manifest.defaultBehavior;
202
- if (nextConfig.enabled === true) assertBehaviorBinding(effectiveBehavior, workspaceDir, profile);
204
+ if (!nextDisabled.has(id)) assertBehaviorBinding(effectiveBehavior, workspaceDir, profile);
203
205
  const updated = updateGameplayConfig((gameplay) => {
204
206
  gameplay.triggers[id] = nextConfig;
207
+ gameplay.disabled_triggers = [...nextDisabled].sort();
205
208
  }, workspaceDir, profile);
206
209
  const config = updated.triggers[id]!;
207
210
  const runtime = await tryApplyRuntimeConfig(id, config, dependencies);
208
211
  console.log(JSON.stringify({
209
212
  trigger: id,
210
213
  config,
211
- effective: triggerEntry(source, config).effective,
214
+ effective: triggerEntry(source, config, updated.disabled_triggers.includes(id)).effective,
212
215
  config_file: getUserDataAccountGameplayConfigFile(workspaceDir, profile),
213
216
  runtime,
214
217
  }, null, 2));
@@ -224,7 +227,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
224
227
  const directory = profile
225
228
  ? getUserDataAccountTriggersDir(workspaceDir, profile)
226
229
  : '<active-account>/triggers/local';
227
- return `\nTrigger modules:\n Place .ts or .js files in ${directory}\n Community Triggers are disabled by default and discovery never executes module code.\n`;
230
+ return `\nTrigger modules:\n Place .ts or .js files in ${directory}\n Local Triggers are available by default unless listed in disabled_triggers; discovery never executes module code.\n`;
228
231
  });
229
232
 
230
233
  trigger.addCommand(new Command('list')
@@ -235,7 +238,11 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
235
238
  const gameplay = readGameplayConfig(workspaceDir, profile);
236
239
  const sources = triggerSources(workspaceDir, profile);
237
240
  console.log(JSON.stringify({
238
- triggers: sources.map((source) => triggerEntry(source, gameplay.triggers[source.id])),
241
+ triggers: sources.map((source) => triggerEntry(
242
+ source,
243
+ gameplay.triggers[source.id],
244
+ gameplay.disabled_triggers.includes(source.id),
245
+ )),
239
246
  ignored_config_ids: Object.keys(gameplay.triggers)
240
247
  .filter((id) => !sources.some((source) => source.id === id)),
241
248
  }, null, 2));
@@ -251,7 +258,11 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
251
258
  const gameplay = readGameplayConfig(workspaceDir, profile);
252
259
  const source = triggerSources(workspaceDir, profile).find((candidate) => candidate.id === id);
253
260
  if (!source) throw new Error(`Unknown or ambiguous trigger module '${id}'.`);
254
- console.log(JSON.stringify(triggerEntry(source, gameplay.triggers[id]), null, 2));
261
+ console.log(JSON.stringify(triggerEntry(
262
+ source,
263
+ gameplay.triggers[id],
264
+ gameplay.disabled_triggers.includes(id),
265
+ ), null, 2));
255
266
  }));
256
267
 
257
268
  trigger.addCommand(new Command('enable')
@@ -269,7 +280,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
269
280
  workspaceDir,
270
281
  profile,
271
282
  );
272
- await updateTrigger(id, (config) => { config.enabled = true; }, dependencies);
283
+ await updateTrigger(id, (_config, disabled) => { disabled.delete(id); }, dependencies);
273
284
  }));
274
285
 
275
286
  trigger.addCommand(new Command('disable')
@@ -277,7 +288,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
277
288
  .argument('<id>', 'Trigger id')
278
289
  .allowExcessArguments(false)
279
290
  .action(async (id: string) => {
280
- await updateTrigger(id, (config) => { config.enabled = false; }, dependencies);
291
+ await updateTrigger(id, (_config, disabled) => { disabled.add(id); }, dependencies);
281
292
  }));
282
293
 
283
294
  trigger.addCommand(new Command('configure')
@@ -296,7 +307,7 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
296
307
  .option('--max-runtime-ms <milliseconds>', 'Maximum Reflex runtime', (value) => (
297
308
  parseSafeInteger(value, 'max-runtime-ms', 1, MAX_TRIGGER_RUNTIME_MS)
298
309
  ))
299
- .option('--reset', 'Clear all overrides except the enabled state')
310
+ .option('--reset', 'Clear all Trigger overrides without changing disabled_triggers')
300
311
  .allowExcessArguments(false)
301
312
  .action(async (id: string, opts: {
302
313
  input?: Record<string, unknown>;
@@ -327,12 +338,10 @@ export function createTriggerCommand(dependencies: TriggerCommandDependencies =
327
338
  assertBehaviorBinding(opts.behavior, getWorkspaceDir(), activeProfile(dependencies));
328
339
  }
329
340
  await updateTrigger(id, (config) => {
330
- const enabled = config.enabled;
331
341
  if (opts.reset) {
332
342
  for (const key of Object.keys(config) as (keyof GameplayTriggerConfig)[]) {
333
343
  delete config[key];
334
344
  }
335
- if (enabled !== undefined) config.enabled = enabled;
336
345
  return;
337
346
  }
338
347
  if (opts.input !== undefined) config.input = opts.input;