@myclaw163/clawclaw-cli 0.8.36 → 0.8.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myclaw163/clawclaw-cli",
3
- "version": "0.8.36",
3
+ "version": "0.8.37",
4
4
  "type": "module",
5
5
  "description": "ClawClaw social deduction game CLI",
6
6
  "bin": {
@@ -101,36 +101,55 @@ function projectCurrentScene(
101
101
  const seatsByName = new Map(players
102
102
  .filter((player) => player.seat !== undefined)
103
103
  .map((player) => [player.name, player.seat] as const));
104
- const project = (raw: unknown, withDirection: boolean): Record<string, any> | null => {
105
- if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
106
- const item = raw as Record<string, any>;
107
- const player = item.player && typeof item.player === 'object' && !Array.isArray(item.player)
108
- ? item.player as Record<string, any>
104
+ const sceneItem = (raw: unknown): Record<string, unknown> | null => (
105
+ raw && typeof raw === 'object' && !Array.isArray(raw) ? raw as Record<string, unknown> : null
106
+ );
107
+ const identity = (item: Record<string, unknown>) => {
108
+ const player: Record<string, unknown> = item.player && typeof item.player === 'object' && !Array.isArray(item.player)
109
+ ? item.player as Record<string, unknown>
109
110
  : {};
110
111
  const name = stringValue(player.name);
111
112
  const seat = numberValue(player.seat) ?? (name ? seatsByName.get(name) : undefined);
112
- if (!name && seat === undefined) return null;
113
- return cleanObject({
114
- name,
115
- seat,
116
- room: stringValue(item.room),
117
- relative_direction: withDirection ? sceneDirection(item, observer) : undefined,
118
- distance_px: sceneDistance(item, observer),
119
- });
113
+ return { name, seat };
114
+ };
115
+ const location = (item: Record<string, unknown>) => cleanObject({
116
+ room: stringValue(item.room),
117
+ relative_direction: sceneDirection(item, observer),
118
+ distance_px: sceneDistance(item, observer),
119
+ });
120
+ const projectPlayer = (raw: unknown): Record<string, unknown> | null => {
121
+ const item = sceneItem(raw);
122
+ if (!item) return null;
123
+ const player = identity(item);
124
+ if (!player.name && player.seat === undefined) return null;
125
+ return cleanObject({ ...player, ...location(item) });
126
+ };
127
+ const projectCorpse = (raw: unknown): Record<string, unknown> | null => {
128
+ const item = sceneItem(raw);
129
+ if (!item) return null;
130
+ const player = identity(item);
131
+ const place = location(item);
132
+ // Visibility does not imply identification. Preserve anonymous spatial facts
133
+ // without exposing corpse/player IDs or inventing a name or seat.
134
+ if (!player.name && player.seat === undefined && Object.keys(place).length === 0) return null;
135
+ return cleanObject({ ...player, ...place });
120
136
  };
121
- const projectList = (raw: unknown, withDirection: boolean): Record<string, any>[] | undefined => {
137
+ const projectList = (
138
+ raw: unknown,
139
+ project: (item: unknown) => Record<string, unknown> | null,
140
+ ): Record<string, unknown>[] | undefined => {
122
141
  if (!Array.isArray(raw)) return undefined;
123
- const projected = raw.map((item: unknown) => project(item, withDirection));
142
+ const projected = raw.map(project);
124
143
  // An explicit empty set means "nobody visible". A non-empty source with
125
- // an unidentifiable entry is instead unavailable evidence; do not silently
144
+ // an unprojectable entry is instead unavailable evidence; do not silently
126
145
  // turn a projection failure into an authoritative empty/partial scene.
127
146
  return projected.some((item) => item === null)
128
147
  ? undefined
129
- : projected as Record<string, any>[];
148
+ : projected as Record<string, unknown>[];
130
149
  };
131
150
  return cleanObject({
132
- visible_players: projectList(summary.visible_players, true),
133
- nearby_corpses: projectList(summary.visible_corpses, true),
151
+ visible_players: projectList(summary.visible_players, projectPlayer),
152
+ nearby_corpses: projectList(summary.visible_corpses, projectCorpse),
134
153
  });
135
154
  }
136
155