@puzzmo/cli 1.0.88 → 1.0.90

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 (76) hide show
  1. package/lib/agents/claude.js.map +1 -1
  2. package/lib/agents/codex.js.map +1 -1
  3. package/lib/agents/copilot.js.map +1 -1
  4. package/lib/agents/gemini.js.map +1 -1
  5. package/lib/agents/index.js.map +1 -1
  6. package/lib/agents/opencode.js.map +1 -1
  7. package/lib/agents/stream-json-cli.js.map +1 -1
  8. package/lib/agents/types.js.map +1 -1
  9. package/lib/commands/agent-test.js.map +1 -1
  10. package/lib/commands/changed.js.map +1 -1
  11. package/lib/commands/game/create.js.map +1 -1
  12. package/lib/commands/game/detectRepo.js.map +1 -1
  13. package/lib/commands/game/seedImport.js.map +1 -1
  14. package/lib/commands/login.js.map +1 -1
  15. package/lib/commands/migrate.js.map +1 -1
  16. package/lib/commands/puzzles.js +3 -13
  17. package/lib/commands/puzzles.js.map +1 -1
  18. package/lib/commands/rounds.d.ts +13 -0
  19. package/lib/commands/rounds.js +42 -0
  20. package/lib/commands/rounds.js.map +1 -0
  21. package/lib/commands/upload.js +4 -0
  22. package/lib/commands/upload.js.map +1 -1
  23. package/lib/commands/validate.js.map +1 -1
  24. package/lib/download/page-downloader.js.map +1 -1
  25. package/lib/index.js +15 -0
  26. package/lib/index.js.map +1 -1
  27. package/lib/queries/__generated__/cliAddPuzzlesToPoolMutation.graphql.js.map +1 -1
  28. package/lib/queries/__generated__/cliGameRuntimesQuery.graphql.js.map +1 -1
  29. package/lib/queries/__generated__/cliGamesForAccessTokenQuery.graphql.js.map +1 -1
  30. package/lib/queries/__generated__/cliRoundFixturesQuery.graphql.d.ts +29 -0
  31. package/lib/queries/__generated__/cliRoundFixturesQuery.graphql.js +184 -0
  32. package/lib/queries/__generated__/cliRoundFixturesQuery.graphql.js.map +1 -0
  33. package/lib/queries/__generated__/cliTeamForTokenQuery.graphql.js.map +1 -1
  34. package/lib/queries/__generated__/cliValidatePoolPuzzlesQuery.graphql.js.map +1 -1
  35. package/lib/queries/gameRuntimes.js.map +1 -1
  36. package/lib/queries/puzzlePool.js.map +1 -1
  37. package/lib/queries/rounds.d.ts +10 -0
  38. package/lib/queries/rounds.js +30 -0
  39. package/lib/queries/rounds.js.map +1 -0
  40. package/lib/queries/teamForToken.js.map +1 -1
  41. package/lib/skills/context.js.map +1 -1
  42. package/lib/skills/mcp-client.js.map +1 -1
  43. package/lib/skills/registry.js.map +1 -1
  44. package/lib/skills/runner.js.map +1 -1
  45. package/lib/skills/step.js.map +1 -1
  46. package/lib/tui/pipeline.js.map +1 -1
  47. package/lib/util/api.d.ts +2 -0
  48. package/lib/util/api.js +5 -1
  49. package/lib/util/api.js.map +1 -1
  50. package/lib/util/belay.js.map +1 -1
  51. package/lib/util/collapseRepeats.js.map +1 -1
  52. package/lib/util/config.js.map +1 -1
  53. package/lib/util/createGame.js.map +1 -1
  54. package/lib/util/discoverGames.js.map +1 -1
  55. package/lib/util/duration.js.map +1 -1
  56. package/lib/util/exec.js.map +1 -1
  57. package/lib/util/lintDist.js.map +1 -1
  58. package/lib/util/lintPuzzmoFile.js.map +1 -1
  59. package/lib/util/mascot.js.map +1 -1
  60. package/lib/util/slugify.js.map +1 -1
  61. package/lib/util/tokenForGame.d.ts +3 -0
  62. package/lib/util/tokenForGame.js +14 -0
  63. package/lib/util/tokenForGame.js.map +1 -0
  64. package/lib/util/validatePuzzmoFile.js.map +1 -1
  65. package/lib/wizard/agent-detect.js.map +1 -1
  66. package/package.json +1 -1
  67. package/src/commands/puzzles.ts +3 -12
  68. package/src/commands/rounds.ts +56 -0
  69. package/src/commands/upload.test.ts +1 -0
  70. package/src/commands/upload.ts +3 -0
  71. package/src/index.ts +17 -0
  72. package/src/queries/__generated__/cliRoundFixturesQuery.graphql.ts +222 -0
  73. package/src/queries/rounds.ts +32 -0
  74. package/src/util/api.ts +8 -2
  75. package/src/util/tokenForGame.ts +12 -0
  76. package/vitest.config.mts +2 -0
@@ -0,0 +1,222 @@
1
+ /**
2
+ * @generated SignedSource<<ad1e4ca0faf950f8df336622238cda2f>>
3
+ * @lightSyntaxTransform
4
+ */
5
+
6
+ /* tslint:disable */
7
+ /* eslint-disable */
8
+ // @ts-nocheck
9
+
10
+ import { ConcreteRequest } from 'relay-runtime';
11
+ export type cliRoundFixturesQuery$variables = {
12
+ gameSlug: string;
13
+ token: string;
14
+ };
15
+ export type cliRoundFixturesQuery$data = {
16
+ readonly gameAchievementsDebug: {
17
+ readonly members: ReadonlyArray<{
18
+ readonly rounds: ReadonlyArray<{
19
+ readonly at: number;
20
+ readonly fixture: any | null | undefined;
21
+ readonly hasLog: boolean;
22
+ readonly outcome: string;
23
+ readonly verified: boolean;
24
+ }>;
25
+ readonly username: string;
26
+ }>;
27
+ } | null | undefined;
28
+ };
29
+ export type cliRoundFixturesQuery = {
30
+ response: cliRoundFixturesQuery$data;
31
+ variables: cliRoundFixturesQuery$variables;
32
+ };
33
+
34
+ const node: ConcreteRequest = (function(){
35
+ var v0 = {
36
+ "defaultValue": null,
37
+ "kind": "LocalArgument",
38
+ "name": "gameSlug"
39
+ },
40
+ v1 = {
41
+ "defaultValue": null,
42
+ "kind": "LocalArgument",
43
+ "name": "token"
44
+ },
45
+ v2 = [
46
+ {
47
+ "kind": "Variable",
48
+ "name": "gameSlug",
49
+ "variableName": "gameSlug"
50
+ },
51
+ {
52
+ "kind": "Variable",
53
+ "name": "token",
54
+ "variableName": "token"
55
+ }
56
+ ],
57
+ v3 = {
58
+ "alias": null,
59
+ "args": null,
60
+ "kind": "ScalarField",
61
+ "name": "username",
62
+ "storageKey": null
63
+ },
64
+ v4 = {
65
+ "alias": null,
66
+ "args": null,
67
+ "kind": "ScalarField",
68
+ "name": "at",
69
+ "storageKey": null
70
+ },
71
+ v5 = {
72
+ "alias": null,
73
+ "args": null,
74
+ "kind": "ScalarField",
75
+ "name": "outcome",
76
+ "storageKey": null
77
+ },
78
+ v6 = {
79
+ "alias": null,
80
+ "args": null,
81
+ "kind": "ScalarField",
82
+ "name": "verified",
83
+ "storageKey": null
84
+ },
85
+ v7 = {
86
+ "alias": null,
87
+ "args": null,
88
+ "kind": "ScalarField",
89
+ "name": "hasLog",
90
+ "storageKey": null
91
+ },
92
+ v8 = {
93
+ "alias": null,
94
+ "args": null,
95
+ "kind": "ScalarField",
96
+ "name": "fixture",
97
+ "storageKey": null
98
+ };
99
+ return {
100
+ "fragment": {
101
+ "argumentDefinitions": [
102
+ (v0/*:: as any*/),
103
+ (v1/*:: as any*/)
104
+ ],
105
+ "kind": "Fragment",
106
+ "metadata": null,
107
+ "name": "cliRoundFixturesQuery",
108
+ "selections": [
109
+ {
110
+ "alias": null,
111
+ "args": (v2/*:: as any*/),
112
+ "concreteType": "AchievementsDebug",
113
+ "kind": "LinkedField",
114
+ "name": "gameAchievementsDebug",
115
+ "plural": false,
116
+ "selections": [
117
+ {
118
+ "alias": null,
119
+ "args": null,
120
+ "concreteType": "AchievementMemberDebug",
121
+ "kind": "LinkedField",
122
+ "name": "members",
123
+ "plural": true,
124
+ "selections": [
125
+ (v3/*:: as any*/),
126
+ {
127
+ "alias": null,
128
+ "args": null,
129
+ "concreteType": "AchievementRoundTrace",
130
+ "kind": "LinkedField",
131
+ "name": "rounds",
132
+ "plural": true,
133
+ "selections": [
134
+ (v4/*:: as any*/),
135
+ (v5/*:: as any*/),
136
+ (v6/*:: as any*/),
137
+ (v7/*:: as any*/),
138
+ (v8/*:: as any*/)
139
+ ],
140
+ "storageKey": null
141
+ }
142
+ ],
143
+ "storageKey": null
144
+ }
145
+ ],
146
+ "storageKey": null
147
+ }
148
+ ],
149
+ "type": "Query",
150
+ "abstractKey": null
151
+ },
152
+ "kind": "Request",
153
+ "operation": {
154
+ "argumentDefinitions": [
155
+ (v1/*:: as any*/),
156
+ (v0/*:: as any*/)
157
+ ],
158
+ "kind": "Operation",
159
+ "name": "cliRoundFixturesQuery",
160
+ "selections": [
161
+ {
162
+ "alias": null,
163
+ "args": (v2/*:: as any*/),
164
+ "concreteType": "AchievementsDebug",
165
+ "kind": "LinkedField",
166
+ "name": "gameAchievementsDebug",
167
+ "plural": false,
168
+ "selections": [
169
+ {
170
+ "alias": null,
171
+ "args": null,
172
+ "concreteType": "AchievementMemberDebug",
173
+ "kind": "LinkedField",
174
+ "name": "members",
175
+ "plural": true,
176
+ "selections": [
177
+ (v3/*:: as any*/),
178
+ {
179
+ "alias": null,
180
+ "args": null,
181
+ "concreteType": "AchievementRoundTrace",
182
+ "kind": "LinkedField",
183
+ "name": "rounds",
184
+ "plural": true,
185
+ "selections": [
186
+ (v4/*:: as any*/),
187
+ (v5/*:: as any*/),
188
+ (v6/*:: as any*/),
189
+ (v7/*:: as any*/),
190
+ (v8/*:: as any*/),
191
+ {
192
+ "alias": null,
193
+ "args": null,
194
+ "kind": "ScalarField",
195
+ "name": "id",
196
+ "storageKey": null
197
+ }
198
+ ],
199
+ "storageKey": null
200
+ }
201
+ ],
202
+ "storageKey": null
203
+ }
204
+ ],
205
+ "storageKey": null
206
+ }
207
+ ]
208
+ },
209
+ "params": {
210
+ "cacheID": "cb33ad9d9ddc13040962cb0b33f440bc",
211
+ "id": null,
212
+ "metadata": {},
213
+ "name": "cliRoundFixturesQuery",
214
+ "operationKind": "query",
215
+ "text": "query cliRoundFixturesQuery(\n $token: String!\n $gameSlug: String!\n) {\n gameAchievementsDebug(token: $token, gameSlug: $gameSlug) {\n members {\n username\n rounds {\n at\n outcome\n verified\n hasLog\n fixture\n id\n }\n }\n }\n}\n"
216
+ }
217
+ };
218
+ })();
219
+
220
+ (node as any).hash = "8e55ffc09d8cf780e1e136991d939d8f";
221
+
222
+ export default node;
@@ -0,0 +1,32 @@
1
+ import { graphql, query } from "../util/belay.js"
2
+ import type { cliRoundFixturesQuery } from "./__generated__/cliRoundFixturesQuery.graphql.js"
3
+
4
+ const roundFixturesQuery = graphql`
5
+ query cliRoundFixturesQuery($token: String!, $gameSlug: String!) {
6
+ gameAchievementsDebug(token: $token, gameSlug: $gameSlug) {
7
+ members {
8
+ username
9
+ rounds {
10
+ at
11
+ outcome
12
+ verified
13
+ hasLog
14
+ fixture
15
+ }
16
+ }
17
+ }
18
+ }
19
+ `
20
+
21
+ export type TracedRound = { username: string; at: number; outcome: string; verified: boolean; hasLog: boolean; fixture: unknown }
22
+
23
+ /** Every round Puzzmo traced for the game's team (the last ten per member), each with its replay fixture when it kept the log */
24
+ export const fetchTracedRounds = async (apiURL: string, token: string, gameSlug: string): Promise<TracedRound[]> => {
25
+ const { data, errors } = await query<cliRoundFixturesQuery>(roundFixturesQuery, {
26
+ variables: { token, gameSlug },
27
+ url: `${apiURL}/graphql`,
28
+ })
29
+ if (errors?.length) throw new Error(errors.map((e) => e.message).join("; "))
30
+ if (!data?.gameAchievementsDebug) throw new Error(`No game named "${gameSlug}" is accessible with that token.`)
31
+ return data.gameAchievementsDebug.members.flatMap((member) => member.rounds.map((round) => ({ ...round, username: member.username })))
32
+ }
package/src/util/api.ts CHANGED
@@ -58,6 +58,8 @@ type CompleteResponse = {
58
58
  versionsURL: string | null
59
59
  /** What each capability of the build's server bundle offers, by name, when one was uploaded */
60
60
  serverBundle: Record<string, string> | null
61
+ /** What Puzzmo noticed about the server bundle without refusing it, such as a live rule reading a fact it dropped */
62
+ serverBundleWarnings: string[]
61
63
  error?: string
62
64
  }
63
65
 
@@ -216,6 +218,7 @@ export const uploadFiles = async (
216
218
 
217
219
  // Step 3: The server bundle, before completing, so a bundle Puzzmo refuses fails the upload rather than live play
218
220
  let serverBundleResult: Record<string, string> | null = null
221
+ let serverBundleWarnings: string[] = []
219
222
  if (serverBundle) {
220
223
  const step = "server bundle upload"
221
224
  const bundleURL = `${apiURL}/cliUpload/${init.sessionID}/serverBundle?encoding=base64`
@@ -229,13 +232,15 @@ export const uploadFiles = async (
229
232
  step,
230
233
  verbose,
231
234
  )
232
- serverBundleResult = ((await readResponse(res, bundleURL, step, verbose)) as { capabilities: Record<string, string> }).capabilities
235
+ const checked = (await readResponse(res, bundleURL, step, verbose)) as { capabilities: Record<string, string>; warnings?: string[] }
236
+ serverBundleResult = checked.capabilities
237
+ serverBundleWarnings = checked.warnings ?? []
233
238
  }
234
239
 
235
240
  // Step 4: Complete
236
241
  const complete = (await jsonPost(`${apiURL}/cliUpload/${init.sessionID}/complete`, token, {}, "upload complete", verbose)) as Omit<
237
242
  CompleteResponse,
238
- "integrationsChanged" | "iconChanged" | "helpChanged" | "gameURL" | "versionsURL" | "serverBundle"
243
+ "integrationsChanged" | "iconChanged" | "helpChanged" | "gameURL" | "versionsURL" | "serverBundle" | "serverBundleWarnings"
239
244
  >
240
245
  if (verbose) console.log(` Assets base: ${complete.assetsBase}`)
241
246
  return {
@@ -246,5 +251,6 @@ export const uploadFiles = async (
246
251
  gameURL: init.gameURL ?? null,
247
252
  versionsURL: init.versionsURL ?? null,
248
253
  serverBundle: serverBundleResult,
254
+ serverBundleWarnings,
249
255
  }
250
256
  }
@@ -0,0 +1,12 @@
1
+ import { fetchGameSlugsForToken } from "../queries/puzzlePool.js"
2
+ import { getTokens, isServerReachable, sortByServerPriority, sourceToURL, type TokenEntry } from "./config.js"
3
+
4
+ /** Finds the first saved token, in server priority order, whose team owns the game */
5
+ export const findTokenForGame = async (gameSlug: string): Promise<TokenEntry | null> => {
6
+ for (const entry of sortByServerPriority(getTokens())) {
7
+ if (!(await isServerReachable(entry.source))) continue
8
+ const slugs = await fetchGameSlugsForToken(sourceToURL(entry.source), entry.token).catch(() => null)
9
+ if (slugs?.includes(gameSlug)) return entry
10
+ }
11
+ return null
12
+ }
package/vitest.config.mts CHANGED
@@ -4,6 +4,8 @@ import { defineConfig } from "vitest/config"
4
4
  // re-run the compiled .test.js copies (they can't resolve the __fixtures__ files).
5
5
  export default defineConfig({
6
6
  test: {
7
+ // A developer can cap the test workers with VITEST_MAX_WORKERS (a count, or a percentage of cores); unset is Vitest's default
8
+ maxWorkers: process.env.VITEST_MAX_WORKERS,
7
9
  include: ["src/**/*.test.ts"],
8
10
  // Quiet output: console only shown for failing tests, no redrawn task summary
9
11
  silent: "passed-only",