@dxos/plugin-chess 0.8.4-main.b97322e → 0.8.4-main.c4373fc

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 (160) hide show
  1. package/dist/lib/browser/ChessboardContainer-OX6TILWD.mjs +96 -0
  2. package/dist/lib/browser/ChessboardContainer-OX6TILWD.mjs.map +7 -0
  3. package/dist/lib/browser/blueprint-definition-UVRFUJYE.mjs +11 -0
  4. package/dist/lib/browser/blueprint-definition-UVRFUJYE.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-E5NQWXQ7.mjs +306 -0
  6. package/dist/lib/browser/chunk-E5NQWXQ7.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-KQOVCG7Z.mjs +8 -0
  8. package/dist/lib/browser/chunk-KQOVCG7Z.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-M63HYNXU.mjs +84 -0
  10. package/dist/lib/browser/chunk-M63HYNXU.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-VA5TW6SD.mjs +169 -0
  12. package/dist/lib/browser/chunk-VA5TW6SD.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-WSUUPPDK.mjs +26 -0
  14. package/dist/lib/browser/chunk-WSUUPPDK.mjs.map +7 -0
  15. package/dist/lib/browser/index.mjs +52 -27
  16. package/dist/lib/browser/index.mjs.map +3 -3
  17. package/dist/lib/browser/intent-resolver-OQPSVFOB.mjs +25 -0
  18. package/dist/lib/browser/intent-resolver-OQPSVFOB.mjs.map +7 -0
  19. package/dist/lib/browser/meta.json +1 -1
  20. package/dist/lib/browser/{react-surface-PLUCWIYP.mjs → react-surface-OLAZCU2E.mjs} +13 -11
  21. package/dist/lib/browser/react-surface-OLAZCU2E.mjs.map +7 -0
  22. package/dist/lib/browser/types/index.mjs +6 -7
  23. package/dist/lib/node-esm/ChessboardContainer-PGDHBG6F.mjs +97 -0
  24. package/dist/lib/node-esm/ChessboardContainer-PGDHBG6F.mjs.map +7 -0
  25. package/dist/lib/node-esm/blueprint-definition-Z47C4EEX.mjs +12 -0
  26. package/dist/lib/node-esm/blueprint-definition-Z47C4EEX.mjs.map +7 -0
  27. package/dist/lib/node-esm/chunk-5C2OYL2B.mjs +27 -0
  28. package/dist/lib/node-esm/chunk-5C2OYL2B.mjs.map +7 -0
  29. package/dist/lib/node-esm/chunk-7YK5RFHY.mjs +85 -0
  30. package/dist/lib/node-esm/chunk-7YK5RFHY.mjs.map +7 -0
  31. package/dist/lib/node-esm/{chunk-QFINI7CC.mjs → chunk-C55L2OCJ.mjs} +3 -3
  32. package/dist/lib/node-esm/chunk-C55L2OCJ.mjs.map +7 -0
  33. package/dist/lib/node-esm/chunk-DWGG7IGH.mjs +307 -0
  34. package/dist/lib/node-esm/chunk-DWGG7IGH.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-SW5N5XNV.mjs +170 -0
  36. package/dist/lib/node-esm/chunk-SW5N5XNV.mjs.map +7 -0
  37. package/dist/lib/node-esm/index.mjs +52 -27
  38. package/dist/lib/node-esm/index.mjs.map +3 -3
  39. package/dist/lib/node-esm/intent-resolver-KVGTUDXJ.mjs +26 -0
  40. package/dist/lib/node-esm/intent-resolver-KVGTUDXJ.mjs.map +7 -0
  41. package/dist/lib/node-esm/meta.json +1 -1
  42. package/dist/lib/node-esm/{react-surface-NGLNIWN3.mjs → react-surface-FIKCDZ5L.mjs} +13 -11
  43. package/dist/lib/node-esm/react-surface-FIKCDZ5L.mjs.map +7 -0
  44. package/dist/lib/node-esm/types/index.mjs +6 -7
  45. package/dist/types/src/ChessPlugin.d.ts +1 -1
  46. package/dist/types/src/ChessPlugin.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
  48. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  49. package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
  50. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/index.d.ts +4 -3
  52. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  53. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  54. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  55. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  56. package/dist/types/src/components/Card.stories.d.ts +22 -0
  57. package/dist/types/src/components/Card.stories.d.ts.map +1 -0
  58. package/dist/types/src/components/Chessboard.d.ts +38 -0
  59. package/dist/types/src/components/Chessboard.d.ts.map +1 -0
  60. package/dist/types/src/components/Chessboard.stories.d.ts +41 -5
  61. package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
  62. package/dist/types/src/components/ChessboardArticle.d.ts +7 -0
  63. package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -0
  64. package/dist/types/src/components/ChessboardContainer.d.ts +9 -0
  65. package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -0
  66. package/dist/types/src/components/Info.d.ts +21 -0
  67. package/dist/types/src/components/Info.d.ts.map +1 -0
  68. package/dist/types/src/components/index.d.ts +2 -5
  69. package/dist/types/src/components/index.d.ts.map +1 -1
  70. package/dist/types/src/functions/create.d.ts +14 -0
  71. package/dist/types/src/functions/create.d.ts.map +1 -0
  72. package/dist/types/src/functions/index.d.ts +4 -0
  73. package/dist/types/src/functions/index.d.ts.map +1 -0
  74. package/dist/types/src/functions/move.d.ts +8 -0
  75. package/dist/types/src/functions/move.d.ts.map +1 -0
  76. package/dist/types/src/functions/play.d.ts +9 -0
  77. package/dist/types/src/functions/play.d.ts.map +1 -0
  78. package/dist/types/src/index.d.ts +2 -0
  79. package/dist/types/src/index.d.ts.map +1 -1
  80. package/dist/types/src/meta.d.ts +0 -1
  81. package/dist/types/src/meta.d.ts.map +1 -1
  82. package/dist/types/src/translations.d.ts +10 -2
  83. package/dist/types/src/translations.d.ts.map +1 -1
  84. package/dist/types/src/types/Chess.d.ts +27 -0
  85. package/dist/types/src/types/Chess.d.ts.map +1 -0
  86. package/dist/types/src/types/ChessAction.d.ts +24 -0
  87. package/dist/types/src/types/ChessAction.d.ts.map +1 -0
  88. package/dist/types/src/types/index.d.ts +2 -2
  89. package/dist/types/src/types/index.d.ts.map +1 -1
  90. package/dist/types/tsconfig.tsbuildinfo +1 -1
  91. package/package.json +44 -33
  92. package/src/ChessPlugin.tsx +48 -48
  93. package/src/capabilities/artifact-definition.ts +26 -21
  94. package/src/capabilities/blueprint-definition.ts +36 -0
  95. package/src/capabilities/index.ts +3 -1
  96. package/src/capabilities/intent-resolver.ts +3 -7
  97. package/src/capabilities/react-surface.tsx +5 -5
  98. package/src/components/Card.stories.tsx +66 -0
  99. package/src/components/Chessboard.stories.tsx +39 -31
  100. package/src/components/Chessboard.tsx +177 -0
  101. package/src/components/ChessboardArticle.tsx +69 -0
  102. package/src/components/ChessboardContainer.tsx +44 -0
  103. package/src/components/Info.tsx +236 -0
  104. package/src/components/index.ts +2 -2
  105. package/src/functions/create.ts +32 -0
  106. package/src/functions/index.ts +7 -0
  107. package/src/functions/move.ts +45 -0
  108. package/src/functions/play.ts +55 -0
  109. package/src/index.ts +2 -0
  110. package/src/meta.ts +5 -5
  111. package/src/translations.ts +10 -2
  112. package/src/types/Chess.ts +66 -0
  113. package/src/types/ChessAction.ts +19 -0
  114. package/src/types/index.ts +2 -2
  115. package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs +0 -129
  116. package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs.map +0 -7
  117. package/dist/lib/browser/artifact-definition-A2FSM255.mjs +0 -182
  118. package/dist/lib/browser/artifact-definition-A2FSM255.mjs.map +0 -7
  119. package/dist/lib/browser/chunk-A3WEUKPK.mjs +0 -61
  120. package/dist/lib/browser/chunk-A3WEUKPK.mjs.map +0 -7
  121. package/dist/lib/browser/chunk-KDADGLPC.mjs +0 -8
  122. package/dist/lib/browser/chunk-KDADGLPC.mjs.map +0 -7
  123. package/dist/lib/browser/chunk-ZXH3N4NA.mjs +0 -66
  124. package/dist/lib/browser/chunk-ZXH3N4NA.mjs.map +0 -7
  125. package/dist/lib/browser/intent-resolver-KQYYX44R.mjs +0 -28
  126. package/dist/lib/browser/intent-resolver-KQYYX44R.mjs.map +0 -7
  127. package/dist/lib/browser/react-surface-PLUCWIYP.mjs.map +0 -7
  128. package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs +0 -130
  129. package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs.map +0 -7
  130. package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs +0 -183
  131. package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs.map +0 -7
  132. package/dist/lib/node-esm/chunk-27D3JA3K.mjs +0 -68
  133. package/dist/lib/node-esm/chunk-27D3JA3K.mjs.map +0 -7
  134. package/dist/lib/node-esm/chunk-IS3Y25PL.mjs +0 -63
  135. package/dist/lib/node-esm/chunk-IS3Y25PL.mjs.map +0 -7
  136. package/dist/lib/node-esm/chunk-QFINI7CC.mjs.map +0 -7
  137. package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs +0 -29
  138. package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs.map +0 -7
  139. package/dist/lib/node-esm/react-surface-NGLNIWN3.mjs.map +0 -7
  140. package/dist/types/src/components/Chess.d.ts +0 -14
  141. package/dist/types/src/components/Chess.d.ts.map +0 -1
  142. package/dist/types/src/components/ChessContainer.d.ts +0 -8
  143. package/dist/types/src/components/ChessContainer.d.ts.map +0 -1
  144. package/dist/types/src/components/ChessContainer.stories.d.ts +0 -23
  145. package/dist/types/src/components/ChessContainer.stories.d.ts.map +0 -1
  146. package/dist/types/src/components/ChessPanel.d.ts +0 -11
  147. package/dist/types/src/components/ChessPanel.d.ts.map +0 -1
  148. package/dist/types/src/components/PlayerSelector.d.ts +0 -8
  149. package/dist/types/src/components/PlayerSelector.d.ts.map +0 -1
  150. package/dist/types/src/types/schema.d.ts +0 -29
  151. package/dist/types/src/types/schema.d.ts.map +0 -1
  152. package/dist/types/src/types/types.d.ts +0 -32
  153. package/dist/types/src/types/types.d.ts.map +0 -1
  154. package/src/components/Chess.tsx +0 -60
  155. package/src/components/ChessContainer.stories.tsx +0 -110
  156. package/src/components/ChessContainer.tsx +0 -71
  157. package/src/components/ChessPanel.tsx +0 -67
  158. package/src/components/PlayerSelector.tsx +0 -82
  159. package/src/types/schema.ts +0 -34
  160. package/src/types/types.ts +0 -20
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/plugin-chess",
3
- "version": "0.8.4-main.b97322e",
3
+ "version": "0.8.4-main.c4373fc",
4
4
  "description": "Chess for new plugin",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -10,14 +10,22 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
+ "source": "./src/index.ts",
13
14
  "types": "./dist/types/src/index.d.ts",
14
15
  "browser": "./dist/lib/browser/index.mjs",
15
16
  "node": "./dist/lib/node-esm/index.mjs"
16
17
  },
17
18
  "./types": {
19
+ "source": "./src/types/index.ts",
18
20
  "types": "./dist/types/src/types/index.d.ts",
19
21
  "browser": "./dist/lib/browser/types/index.mjs",
20
22
  "node": "./dist/lib/node-esm/types/index.mjs"
23
+ },
24
+ "./functions": {
25
+ "source": "./src/functions/index.ts",
26
+ "types": "./dist/types/src/functions/index.d.ts",
27
+ "browser": "./dist/lib/browser/functions/index.mjs",
28
+ "node": "./dist/lib/node-esm/functions/index.mjs"
21
29
  }
22
30
  },
23
31
  "types": "dist/types/src/index.d.ts",
@@ -34,43 +42,46 @@
34
42
  ],
35
43
  "dependencies": {
36
44
  "@preact-signals/safe-react": "^0.9.0",
37
- "@preact/signals-core": "^1.9.0",
45
+ "@preact/signals-core": "^1.12.1",
38
46
  "chess.js": "^1.0.0",
39
- "effect": "3.17.0",
40
- "@dxos/ai": "0.8.4-main.b97322e",
41
- "@dxos/assistant": "0.8.4-main.b97322e",
42
- "@dxos/app-framework": "0.8.4-main.b97322e",
43
- "@dxos/blueprints": "0.8.4-main.b97322e",
44
- "@dxos/async": "0.8.4-main.b97322e",
45
- "@dxos/echo": "0.8.4-main.b97322e",
46
- "@dxos/display-name": "0.8.4-main.b97322e",
47
- "@dxos/echo-schema": "0.8.4-main.b97322e",
48
- "@dxos/invariant": "0.8.4-main.b97322e",
49
- "@dxos/live-object": "0.8.4-main.b97322e",
50
- "@dxos/log": "0.8.4-main.b97322e",
51
- "@dxos/plugin-client": "0.8.4-main.b97322e",
52
- "@dxos/plugin-graph": "0.8.4-main.b97322e",
53
- "@dxos/plugin-space": "0.8.4-main.b97322e",
54
- "@dxos/react-client": "0.8.4-main.b97322e",
55
- "@dxos/react-ui-gameboard": "0.8.4-main.b97322e",
56
- "@dxos/react-ui-stack": "0.8.4-main.b97322e"
47
+ "effect": "3.18.3",
48
+ "@dxos/ai": "0.8.4-main.c4373fc",
49
+ "@dxos/app-framework": "0.8.4-main.c4373fc",
50
+ "@dxos/blueprints": "0.8.4-main.c4373fc",
51
+ "@dxos/assistant": "0.8.4-main.c4373fc",
52
+ "@dxos/async": "0.8.4-main.c4373fc",
53
+ "@dxos/display-name": "0.8.4-main.c4373fc",
54
+ "@dxos/echo": "0.8.4-main.c4373fc",
55
+ "@dxos/functions": "0.8.4-main.c4373fc",
56
+ "@dxos/live-object": "0.8.4-main.c4373fc",
57
+ "@dxos/invariant": "0.8.4-main.c4373fc",
58
+ "@dxos/plugin-client": "0.8.4-main.c4373fc",
59
+ "@dxos/plugin-graph": "0.8.4-main.c4373fc",
60
+ "@dxos/plugin-space": "0.8.4-main.c4373fc",
61
+ "@dxos/react-client": "0.8.4-main.c4373fc",
62
+ "@dxos/log": "0.8.4-main.c4373fc",
63
+ "@dxos/react-ui-gameboard": "0.8.4-main.c4373fc",
64
+ "@dxos/react-ui-sfx": "0.8.4-main.c4373fc",
65
+ "@dxos/react-ui-stack": "0.8.4-main.c4373fc",
66
+ "@dxos/schema": "0.8.4-main.c4373fc",
67
+ "@dxos/util": "0.8.4-main.c4373fc"
57
68
  },
58
69
  "devDependencies": {
59
- "@types/react": "~18.2.0",
60
- "@types/react-dom": "~18.2.0",
61
- "react": "~18.2.0",
62
- "react-dom": "~18.2.0",
63
- "vite": "5.4.7",
64
- "@dxos/plugin-theme": "0.8.4-main.b97322e",
65
- "@dxos/react-ui": "0.8.4-main.b97322e",
66
- "@dxos/react-ui-theme": "0.8.4-main.b97322e",
67
- "@dxos/storybook-utils": "0.8.4-main.b97322e"
70
+ "@types/react": "~19.2.2",
71
+ "@types/react-dom": "~19.2.1",
72
+ "react": "~19.2.0",
73
+ "react-dom": "~19.2.0",
74
+ "vite": "7.1.9",
75
+ "@dxos/plugin-theme": "0.8.4-main.c4373fc",
76
+ "@dxos/react-ui": "0.8.4-main.c4373fc",
77
+ "@dxos/react-ui-theme": "0.8.4-main.c4373fc",
78
+ "@dxos/storybook-utils": "0.8.4-main.c4373fc"
68
79
  },
69
80
  "peerDependencies": {
70
- "react": "~18.2.0",
71
- "react-dom": "~18.2.0",
72
- "@dxos/react-ui": "0.8.4-main.b97322e",
73
- "@dxos/react-ui-theme": "0.8.4-main.b97322e"
81
+ "react": "^19.0.0",
82
+ "react-dom": "^19.0.0",
83
+ "@dxos/react-ui": "0.8.4-main.c4373fc",
84
+ "@dxos/react-ui-theme": "0.8.4-main.c4373fc"
74
85
  },
75
86
  "publishConfig": {
76
87
  "access": "public"
@@ -2,59 +2,59 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
5
+ import { Capabilities, Events, contributes, createIntent, defineModule, definePlugin } from '@dxos/app-framework';
6
6
  import { ClientEvents } from '@dxos/plugin-client';
7
7
  import { SpaceCapabilities } from '@dxos/plugin-space';
8
8
  import { defineObjectForm } from '@dxos/plugin-space/types';
9
9
 
10
- import { ArtifactDefinition, IntentResolver, ReactSurface } from './capabilities';
10
+ import { BLUEPRINT_KEY, BlueprintDefinition, IntentResolver, ReactSurface } from './capabilities';
11
11
  import { meta } from './meta';
12
12
  import { translations } from './translations';
13
- import { ChessAction, ChessType } from './types';
13
+ import { Chess, ChessAction } from './types';
14
14
 
15
- export const ChessPlugin = () =>
16
- definePlugin(meta, [
17
- defineModule({
18
- id: `${meta.id}/module/translations`,
19
- activatesOn: Events.SetupTranslations,
20
- activate: () => contributes(Capabilities.Translations, translations),
21
- }),
22
- defineModule({
23
- id: `${meta.id}/module/metadata`,
24
- activatesOn: Events.SetupMetadata,
25
- activate: () =>
26
- contributes(Capabilities.Metadata, {
27
- id: ChessType.typename,
28
- metadata: {
29
- icon: 'ph--shield-chevron--regular',
30
- },
15
+ export const ChessPlugin = definePlugin(meta, () => [
16
+ defineModule({
17
+ id: `${meta.id}/module/translations`,
18
+ activatesOn: Events.SetupTranslations,
19
+ activate: () => contributes(Capabilities.Translations, translations),
20
+ }),
21
+ defineModule({
22
+ id: `${meta.id}/module/metadata`,
23
+ activatesOn: Events.SetupMetadata,
24
+ activate: () =>
25
+ contributes(Capabilities.Metadata, {
26
+ id: Chess.Game.typename,
27
+ metadata: {
28
+ icon: 'ph--shield-chevron--regular',
29
+ blueprints: [BLUEPRINT_KEY],
30
+ },
31
+ }),
32
+ }),
33
+ defineModule({
34
+ id: `${meta.id}/module/object-form`,
35
+ activatesOn: ClientEvents.SetupSchema,
36
+ activate: () =>
37
+ contributes(
38
+ SpaceCapabilities.ObjectForm,
39
+ defineObjectForm({
40
+ objectSchema: Chess.Game,
41
+ getIntent: () => createIntent(ChessAction.Create),
31
42
  }),
32
- }),
33
- defineModule({
34
- id: `${meta.id}/module/object-form`,
35
- activatesOn: ClientEvents.SetupSchema,
36
- activate: () =>
37
- contributes(
38
- SpaceCapabilities.ObjectForm,
39
- defineObjectForm({
40
- objectSchema: ChessType,
41
- getIntent: () => createIntent(ChessAction.Create),
42
- }),
43
- ),
44
- }),
45
- defineModule({
46
- id: `${meta.id}/module/react-surface`,
47
- activatesOn: Events.SetupReactSurface,
48
- activate: ReactSurface,
49
- }),
50
- defineModule({
51
- id: `${meta.id}/module/intent-resolver`,
52
- activatesOn: Events.SetupIntentResolver,
53
- activate: IntentResolver,
54
- }),
55
- defineModule({
56
- id: `${meta.id}/module/artifact-definition`,
57
- activatesOn: Events.SetupArtifactDefinition,
58
- activate: ArtifactDefinition,
59
- }),
60
- ]);
43
+ ),
44
+ }),
45
+ defineModule({
46
+ id: `${meta.id}/module/react-surface`,
47
+ activatesOn: Events.SetupReactSurface,
48
+ activate: ReactSurface,
49
+ }),
50
+ defineModule({
51
+ id: `${meta.id}/module/intent-resolver`,
52
+ activatesOn: Events.SetupIntentResolver,
53
+ activate: IntentResolver,
54
+ }),
55
+ defineModule({
56
+ id: `${meta.id}/module/blueprint`,
57
+ activatesOn: Events.SetupArtifactDefinition,
58
+ activate: BlueprintDefinition,
59
+ }),
60
+ ]);
@@ -2,20 +2,25 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Chess } from 'chess.js';
6
- import { pipe, Schema } from 'effect';
5
+ // ISSUE(burdon): defineArtifact
6
+ // @ts-nocheck
7
7
 
8
- import { createTool, ToolResult } from '@dxos/ai';
9
- import { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
10
- import { createArtifactElement, VersionPin, ArtifactId } from '@dxos/assistant';
8
+ import { Chess as ChessJS } from 'chess.js';
9
+ import * as Function from 'effect/Function';
10
+ import * as Schema from 'effect/Schema';
11
+
12
+ import { ToolResult, createTool } from '@dxos/ai';
13
+ import { Capabilities, type PromiseIntentDispatcher, chain, contributes, createIntent } from '@dxos/app-framework';
14
+ import { ArtifactId, VersionPin, createArtifactElement } from '@dxos/assistant';
11
15
  import { defineArtifact } from '@dxos/blueprints';
12
16
  import { Obj } from '@dxos/echo';
13
17
  import { invariant } from '@dxos/invariant';
14
18
  import { SpaceAction } from '@dxos/plugin-space/types';
15
19
  import { Filter, type Space } from '@dxos/react-client/echo';
20
+ import { trim } from '@dxos/util';
16
21
 
17
22
  import { meta } from '../meta';
18
- import { ChessAction, ChessType } from '../types';
23
+ import { Chess, ChessAction } from '../types';
19
24
 
20
25
  // TODO(burdon): Factor out.
21
26
  declare global {
@@ -30,24 +35,24 @@ export default () => {
30
35
  id: `artifact:${meta.id}`,
31
36
  name: meta.name,
32
37
  description: 'Provides a simple chess engine.',
33
- instructions: `
38
+ instructions: trim`
34
39
  - If the user's message relates to a chess game, you must return the chess game inside the artifact tag as a valid FEN string with no additional text.
35
40
  - Always inspect the chess game at the start of every prompt realting to a chess game, as it might have changed since the interaction.
36
41
  `,
37
- schema: ChessType,
42
+ schema: Chess.Game,
38
43
  tools: [
39
44
  createTool(meta.id, {
40
45
  name: 'create',
41
46
  description: 'Create a new chess game. Returns the artifact definition for the game.',
42
47
  caption: 'Creating chess game...',
43
48
  schema: Schema.Struct({
44
- fen: Schema.String.annotations({ description: 'The state of the chess game in the FEN format.' }),
49
+ pgn: Schema.String.annotations({ description: 'The state of the chess game in the PGN format.' }),
45
50
  }),
46
- execute: async ({ fen }, { extensions }) => {
51
+ execute: async ({ pgn }, { extensions }) => {
47
52
  invariant(extensions?.space, 'No space');
48
53
  invariant(extensions?.dispatch, 'No intent dispatcher');
49
- const intent = pipe(
50
- createIntent(ChessAction.Create, { fen }),
54
+ const intent = Function.pipe(
55
+ createIntent(ChessAction.Create, { pgn }),
51
56
  chain(SpaceAction.AddObject, { target: extensions.space }),
52
57
  );
53
58
  const { data, error } = await extensions.dispatch(intent);
@@ -67,7 +72,7 @@ export default () => {
67
72
  schema: Schema.Struct({}),
68
73
  execute: async (_, { extensions }) => {
69
74
  invariant(extensions?.space, 'No space');
70
- const { objects: games } = await extensions.space.db.query(Filter.type(ChessType)).run();
75
+ const { objects: games } = await extensions.space.db.query(Filter.type(Chess.Game)).run();
71
76
  invariant(games.length > 0, 'No chess games found');
72
77
 
73
78
  return ToolResult.Success(games);
@@ -83,9 +88,9 @@ export default () => {
83
88
  const game = await extensions.space.db
84
89
  .query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))
85
90
  .first();
86
- invariant(Obj.instanceOf(ChessType, game));
91
+ invariant(Obj.instanceOf(Chess.Game, game));
87
92
 
88
- return ToolResult.Success(game.fen);
93
+ return ToolResult.Success(game.pgn);
89
94
  },
90
95
  }),
91
96
  createTool(meta.id, {
@@ -104,17 +109,17 @@ export default () => {
104
109
  const game = await extensions.space.db
105
110
  .query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))
106
111
  .first();
107
- invariant(Obj.instanceOf(ChessType, game));
112
+ invariant(Obj.instanceOf(Chess.Game, game));
108
113
 
109
- const board = new Chess(game.fen);
114
+ const chess = new ChessJS(game.pgn);
110
115
  try {
111
- board.move(move);
116
+ chess.move(move);
112
117
  } catch (error: any) {
113
118
  return ToolResult.Error(error.message);
114
119
  }
115
- game.pgn = board.pgn();
116
- game.fen = board.fen();
117
- return ToolResult.Success(game.fen);
120
+
121
+ game.pgn = chess.pgn();
122
+ return ToolResult.Success(game.pgn);
118
123
  },
119
124
  }),
120
125
  ],
@@ -0,0 +1,36 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes } from '@dxos/app-framework';
6
+ import { Blueprint, Template } from '@dxos/blueprints';
7
+ import { type FunctionDefinition } from '@dxos/functions';
8
+ import { trim } from '@dxos/util';
9
+
10
+ import { create, move, play } from '../functions';
11
+
12
+ export const BLUEPRINT_KEY = 'dxos.org/blueprint/chess';
13
+
14
+ const functions: FunctionDefinition[] = [create, move, play];
15
+
16
+ export default () => {
17
+ return [
18
+ contributes(Capabilities.Functions, functions),
19
+ contributes(
20
+ Capabilities.BlueprintDefinition,
21
+ Blueprint.make({
22
+ key: BLUEPRINT_KEY,
23
+ name: 'Chess',
24
+ tools: Blueprint.toolDefinitions({ functions }),
25
+ instructions: Template.make({
26
+ source: trim`
27
+ You are an expert chess player.
28
+ To analyze a game you can access the "pgn" property by loading the context object that represents the current game.
29
+ You could suggest a good next move or offer to play a move.
30
+ Don't actually make a move unless you are asked to.
31
+ `,
32
+ }),
33
+ }),
34
+ ),
35
+ ];
36
+ };
@@ -4,6 +4,8 @@
4
4
 
5
5
  import { lazy } from '@dxos/app-framework';
6
6
 
7
- export const ArtifactDefinition = lazy(() => import('./artifact-definition'));
7
+ export const BlueprintDefinition = lazy(() => import('./blueprint-definition'));
8
8
  export const IntentResolver = lazy(() => import('./intent-resolver'));
9
9
  export const ReactSurface = lazy(() => import('./react-surface'));
10
+
11
+ export * from './blueprint-definition';
@@ -2,23 +2,19 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Chess } from 'chess.js';
6
-
7
5
  import { Capabilities, contributes, createResolver } from '@dxos/app-framework';
8
- import { Obj } from '@dxos/echo';
9
6
 
10
- import { ChessAction, ChessType } from '../types';
7
+ import { Chess, ChessAction } from '../types';
11
8
 
12
9
  export default () =>
13
10
  contributes(
14
11
  Capabilities.IntentResolver,
15
12
  createResolver({
16
13
  intent: ChessAction.Create,
17
- resolve: ({ name, fen }) => {
18
- const pgn = fen ? new Chess(fen).pgn() : undefined;
14
+ resolve: ({ name, pgn }) => {
19
15
  return {
20
16
  data: {
21
- object: Obj.make(ChessType, { name, fen, pgn }),
17
+ object: Chess.makeGame({ name, pgn }),
22
18
  },
23
19
  };
24
20
  },
@@ -7,17 +7,17 @@ import React from 'react';
7
7
  import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
8
8
  import { Obj } from '@dxos/echo';
9
9
 
10
- import { ChessContainer } from '../components';
10
+ import { ChessboardContainer } from '../components';
11
11
  import { meta } from '../meta';
12
- import { ChessType } from '../types';
12
+ import { Chess } from '../types';
13
13
 
14
14
  export default () =>
15
15
  contributes(Capabilities.ReactSurface, [
16
16
  createSurface({
17
17
  id: meta.id,
18
18
  role: ['article', 'section', 'card--intrinsic', 'card--extrinsic', 'card--popover', 'card--transclusion'],
19
- // TODO(burdon): Could this be standardized so that we don't require a subject property (like below)?
20
- filter: (data): data is { subject: ChessType } => Obj.instanceOf(ChessType, data.subject),
21
- component: ({ data, role }) => <ChessContainer game={data.subject} role={role} />,
19
+ // TODO(burdon): Could this be standardized so that we don't require a subject property.
20
+ filter: (data): data is { subject: Chess.Game } => Obj.instanceOf(Chess.Game, data.subject),
21
+ component: ({ data, role }) => <ChessboardContainer game={data.subject} role={role} />,
22
22
  }),
23
23
  ]);
@@ -0,0 +1,66 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import React from 'react';
7
+
8
+ import { withTheme } from '@dxos/react-ui/testing';
9
+ import { CardContainer } from '@dxos/react-ui-stack/testing';
10
+
11
+ import { meta as pluginMeta } from '../meta';
12
+ import { Chess } from '../types';
13
+
14
+ import { Chessboard } from './Chessboard';
15
+
16
+ type DefaultStoryProps = {
17
+ role: 'card--popover' | 'card--intrinsic' | 'card--extrinsic';
18
+ game: Chess.Game;
19
+ };
20
+
21
+ const meta = {
22
+ title: 'plugins/plugin-chess/Card',
23
+ render: ({ role, game }) => (
24
+ <CardContainer icon={pluginMeta.icon} role={role}>
25
+ <Chessboard.Root game={game}>
26
+ <Chessboard.Content role={role}>
27
+ <Chessboard.Board />
28
+ </Chessboard.Content>
29
+ </Chessboard.Root>
30
+ </CardContainer>
31
+ ),
32
+ decorators: [withTheme],
33
+ parameters: {
34
+ layout: 'centered',
35
+ },
36
+ tags: ['cards'],
37
+ } satisfies Meta<DefaultStoryProps>;
38
+
39
+ export default meta;
40
+
41
+ const game = Chess.makeGame({
42
+ pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Qg4 16. e7 Kf7 17. bxc3 Kg6 *',
43
+ });
44
+
45
+ type Story = StoryObj<typeof meta>;
46
+
47
+ export const Popover: Story = {
48
+ args: {
49
+ role: 'card--popover',
50
+ game: game,
51
+ },
52
+ };
53
+
54
+ export const Intrinsic: Story = {
55
+ args: {
56
+ role: 'card--intrinsic',
57
+ game: game,
58
+ },
59
+ };
60
+
61
+ export const Extrinsic: Story = {
62
+ args: {
63
+ role: 'card--extrinsic',
64
+ game: game,
65
+ },
66
+ };
@@ -2,40 +2,48 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import React, { useMemo } from 'react';
9
-
10
- import { Gameboard, Chessboard, ChessModel } from '@dxos/react-ui-gameboard';
11
- import { withLayout, withTheme } from '@dxos/storybook-utils';
12
-
13
- import { ChessPanel } from './ChessPanel';
14
-
15
- const DefaultStory = () => {
16
- const model = useMemo(() => new ChessModel(), []);
17
-
18
- return (
19
- <div className='flex grow mx-8 gap-8 items-center overflow-hidden'>
20
- <Gameboard.Root model={model} onDrop={(move) => model.makeMove(move)}>
21
- <Gameboard.Content>
22
- <Chessboard />
23
- </Gameboard.Content>
24
- </Gameboard.Root>
25
- <ChessPanel model={model} classNames='w-[200px]' />
26
- </div>
27
- );
28
- };
29
6
 
30
- const meta: Meta<typeof Chessboard> = {
31
- title: 'plugins/plugin-chess/Chessboard',
32
- component: Chessboard,
33
- render: DefaultStory,
34
- decorators: [withTheme, withLayout({ fullscreen: true })],
35
- };
7
+ import { withClientProvider } from '@dxos/react-client/testing';
8
+ import { withTheme } from '@dxos/react-ui/testing';
36
9
 
37
- type Story = StoryObj<typeof Chessboard>;
10
+ import { translations } from '../translations';
11
+ import { Chess } from '../types';
12
+
13
+ import { ChessboardArticle } from './ChessboardArticle';
14
+
15
+ const meta = {
16
+ title: 'plugins/plugin-chess/Chessboard',
17
+ component: ChessboardArticle,
18
+ decorators: [withTheme, withClientProvider({ createIdentity: true })],
19
+ parameters: {
20
+ layout: 'fullscreen',
21
+ translations,
22
+ },
23
+ } satisfies Meta<typeof ChessboardArticle>;
38
24
 
39
25
  export default meta;
40
26
 
41
- export const Default: Story = {};
27
+ type Story = StoryObj<typeof meta>;
28
+
29
+ export const Default: Story = {
30
+ args: {
31
+ game: Chess.makeGame(),
32
+ },
33
+ };
34
+
35
+ export const EndGame: Story = {
36
+ args: {
37
+ game: Chess.makeGame({
38
+ pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 *',
39
+ }),
40
+ },
41
+ };
42
+
43
+ export const Promption: Story = {
44
+ args: {
45
+ game: Chess.makeGame({
46
+ pgn: '1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 d5 8. exd5 Nxd5 9. O-O Be6 10. Qb3 Na5 11. Qa4+ c6 12. Bxd5 Bxc3 13. Bxe6 fxe6 14. d5 Qg5 15. dxe6 Qg4 16. e7 Kf7 17. bxc3 Kg6 *',
47
+ }),
48
+ },
49
+ };