@dxos/plugin-chess 0.8.4-main.67995b8 → 0.8.4-main.72ec0f3
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/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs +96 -0
- package/dist/lib/browser/ChessboardContainer-5YXEM4VR.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs +11 -0
- package/dist/lib/browser/blueprint-definition-FD4TL5EE.mjs.map +7 -0
- package/dist/lib/browser/chunk-5DOZV3PW.mjs +294 -0
- package/dist/lib/browser/chunk-5DOZV3PW.mjs.map +7 -0
- package/dist/lib/browser/chunk-DUO4WTAM.mjs +28 -0
- package/dist/lib/browser/chunk-DUO4WTAM.mjs.map +7 -0
- package/dist/lib/browser/chunk-FBLAVAMY.mjs +84 -0
- package/dist/lib/browser/chunk-FBLAVAMY.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q5TZCIH7.mjs +8 -0
- package/dist/lib/browser/chunk-Q5TZCIH7.mjs.map +7 -0
- package/dist/lib/browser/chunk-TIIGNOGK.mjs +169 -0
- package/dist/lib/browser/chunk-TIIGNOGK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +53 -27
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-GXZN2EBT.mjs +25 -0
- package/dist/lib/browser/intent-resolver-GXZN2EBT.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-PLUCWIYP.mjs → react-surface-KTTAUHAA.mjs} +13 -11
- package/dist/lib/browser/react-surface-KTTAUHAA.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -7
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs +97 -0
- package/dist/lib/node-esm/ChessboardContainer-7OQ6TOKB.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs +12 -0
- package/dist/lib/node-esm/blueprint-definition-O7ZM3HUF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs +295 -0
- package/dist/lib/node-esm/chunk-F4C2HVZL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs +29 -0
- package/dist/lib/node-esm/chunk-KNOOJFIR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs +85 -0
- package/dist/lib/node-esm/chunk-MP3A3AGA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs +170 -0
- package/dist/lib/node-esm/chunk-RTCAAOLF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QFINI7CC.mjs → chunk-VVXTAVIS.mjs} +3 -3
- package/dist/lib/node-esm/chunk-VVXTAVIS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +53 -27
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-HK5L6P6Z.mjs +26 -0
- package/dist/lib/node-esm/intent-resolver-HK5L6P6Z.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-NGLNIWN3.mjs → react-surface-VO4PSY6O.mjs} +13 -11
- package/dist/lib/node-esm/react-surface-VO4PSY6O.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -7
- package/dist/types/src/ChessPlugin.d.ts +1 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/components/Card.stories.d.ts +22 -0
- package/dist/types/src/components/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.d.ts +38 -0
- package/dist/types/src/components/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard.stories.d.ts +41 -5
- package/dist/types/src/components/Chessboard.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChessboardArticle.d.ts +7 -0
- package/dist/types/src/components/ChessboardArticle.d.ts.map +1 -0
- package/dist/types/src/components/ChessboardContainer.d.ts +9 -0
- package/dist/types/src/components/ChessboardContainer.d.ts.map +1 -0
- package/dist/types/src/components/Info.d.ts +21 -0
- package/dist/types/src/components/Info.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/create.d.ts +14 -0
- package/dist/types/src/functions/create.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/move.d.ts +8 -0
- package/dist/types/src/functions/move.d.ts.map +1 -0
- package/dist/types/src/functions/play.d.ts +9 -0
- package/dist/types/src/functions/play.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +10 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Chess.d.ts +27 -0
- package/dist/types/src/types/Chess.d.ts.map +1 -0
- package/dist/types/src/types/ChessAction.d.ts +24 -0
- package/dist/types/src/types/ChessAction.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -37
- package/src/ChessPlugin.tsx +49 -48
- package/src/capabilities/artifact-definition.ts +26 -21
- package/src/capabilities/blueprint-definition.ts +36 -0
- package/src/capabilities/index.ts +3 -1
- package/src/capabilities/intent-resolver.ts +3 -7
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/components/Card.stories.tsx +66 -0
- package/src/components/Chessboard.stories.tsx +39 -31
- package/src/components/Chessboard.tsx +177 -0
- package/src/components/ChessboardArticle.tsx +68 -0
- package/src/components/ChessboardContainer.tsx +44 -0
- package/src/components/Info.tsx +236 -0
- package/src/components/index.ts +2 -2
- package/src/functions/create.ts +32 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/move.ts +45 -0
- package/src/functions/play.ts +55 -0
- package/src/index.ts +2 -0
- package/src/meta.ts +7 -5
- package/src/translations.ts +10 -2
- package/src/types/Chess.ts +60 -0
- package/src/types/ChessAction.ts +19 -0
- package/src/types/index.ts +2 -2
- package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs +0 -129
- package/dist/lib/browser/ChessContainer-SC4ZV6XZ.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-A2FSM255.mjs +0 -182
- package/dist/lib/browser/artifact-definition-A2FSM255.mjs.map +0 -7
- package/dist/lib/browser/chunk-A3WEUKPK.mjs +0 -61
- package/dist/lib/browser/chunk-A3WEUKPK.mjs.map +0 -7
- package/dist/lib/browser/chunk-KDADGLPC.mjs +0 -8
- package/dist/lib/browser/chunk-KDADGLPC.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZXH3N4NA.mjs +0 -66
- package/dist/lib/browser/chunk-ZXH3N4NA.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-KQYYX44R.mjs +0 -28
- package/dist/lib/browser/intent-resolver-KQYYX44R.mjs.map +0 -7
- package/dist/lib/browser/react-surface-PLUCWIYP.mjs.map +0 -7
- package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs +0 -130
- package/dist/lib/node-esm/ChessContainer-7GLY5KLY.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs +0 -183
- package/dist/lib/node-esm/artifact-definition-2H7OUBZO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-27D3JA3K.mjs +0 -68
- package/dist/lib/node-esm/chunk-27D3JA3K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IS3Y25PL.mjs +0 -63
- package/dist/lib/node-esm/chunk-IS3Y25PL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QFINI7CC.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs +0 -29
- package/dist/lib/node-esm/intent-resolver-GXK2JROQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-NGLNIWN3.mjs.map +0 -7
- package/dist/types/src/components/Chess.d.ts +0 -14
- package/dist/types/src/components/Chess.d.ts.map +0 -1
- package/dist/types/src/components/ChessContainer.d.ts +0 -8
- package/dist/types/src/components/ChessContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChessContainer.stories.d.ts +0 -23
- package/dist/types/src/components/ChessContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ChessPanel.d.ts +0 -11
- package/dist/types/src/components/ChessPanel.d.ts.map +0 -1
- package/dist/types/src/components/PlayerSelector.d.ts +0 -8
- package/dist/types/src/components/PlayerSelector.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -29
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -32
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/components/Chess.tsx +0 -60
- package/src/components/ChessContainer.stories.tsx +0 -110
- package/src/components/ChessContainer.tsx +0 -71
- package/src/components/ChessPanel.tsx +0 -67
- package/src/components/PlayerSelector.tsx +0 -82
- package/src/types/schema.ts +0 -34
- 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.
|
|
3
|
+
"version": "0.8.4-main.72ec0f3",
|
|
4
4
|
"description": "Chess for new plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,16 +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
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
|
-
"source": "./src/index.ts"
|
|
16
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
17
17
|
},
|
|
18
18
|
"./types": {
|
|
19
|
+
"source": "./src/types/index.ts",
|
|
19
20
|
"types": "./dist/types/src/types/index.d.ts",
|
|
20
21
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
21
|
-
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
22
|
-
|
|
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"
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
31
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -36,43 +42,46 @@
|
|
|
36
42
|
],
|
|
37
43
|
"dependencies": {
|
|
38
44
|
"@preact-signals/safe-react": "^0.9.0",
|
|
39
|
-
"@preact/signals-core": "^1.
|
|
45
|
+
"@preact/signals-core": "^1.12.1",
|
|
40
46
|
"chess.js": "^1.0.0",
|
|
41
|
-
"effect": "3.
|
|
42
|
-
"@dxos/ai": "0.8.4-main.
|
|
43
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
44
|
-
"@dxos/async": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/blueprints": "0.8.4-main.
|
|
48
|
-
"@dxos/echo": "0.8.4-main.
|
|
49
|
-
"@dxos/invariant": "0.8.4-main.
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/live-object": "0.8.4-main.
|
|
52
|
-
"@dxos/log": "0.8.4-main.
|
|
53
|
-
"@dxos/plugin-
|
|
54
|
-
"@dxos/plugin-
|
|
55
|
-
"@dxos/
|
|
56
|
-
"@dxos/react-
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/react-ui-
|
|
47
|
+
"effect": "3.18.3",
|
|
48
|
+
"@dxos/ai": "0.8.4-main.72ec0f3",
|
|
49
|
+
"@dxos/app-framework": "0.8.4-main.72ec0f3",
|
|
50
|
+
"@dxos/async": "0.8.4-main.72ec0f3",
|
|
51
|
+
"@dxos/display-name": "0.8.4-main.72ec0f3",
|
|
52
|
+
"@dxos/assistant": "0.8.4-main.72ec0f3",
|
|
53
|
+
"@dxos/blueprints": "0.8.4-main.72ec0f3",
|
|
54
|
+
"@dxos/echo": "0.8.4-main.72ec0f3",
|
|
55
|
+
"@dxos/invariant": "0.8.4-main.72ec0f3",
|
|
56
|
+
"@dxos/functions": "0.8.4-main.72ec0f3",
|
|
57
|
+
"@dxos/live-object": "0.8.4-main.72ec0f3",
|
|
58
|
+
"@dxos/log": "0.8.4-main.72ec0f3",
|
|
59
|
+
"@dxos/plugin-graph": "0.8.4-main.72ec0f3",
|
|
60
|
+
"@dxos/plugin-client": "0.8.4-main.72ec0f3",
|
|
61
|
+
"@dxos/react-client": "0.8.4-main.72ec0f3",
|
|
62
|
+
"@dxos/react-ui-sfx": "0.8.4-main.72ec0f3",
|
|
63
|
+
"@dxos/schema": "0.8.4-main.72ec0f3",
|
|
64
|
+
"@dxos/react-ui-gameboard": "0.8.4-main.72ec0f3",
|
|
65
|
+
"@dxos/react-ui-stack": "0.8.4-main.72ec0f3",
|
|
66
|
+
"@dxos/plugin-space": "0.8.4-main.72ec0f3",
|
|
67
|
+
"@dxos/util": "0.8.4-main.72ec0f3"
|
|
59
68
|
},
|
|
60
69
|
"devDependencies": {
|
|
61
|
-
"@types/react": "~
|
|
62
|
-
"@types/react-dom": "~
|
|
63
|
-
"react": "~
|
|
64
|
-
"react-dom": "~
|
|
65
|
-
"vite": "
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
+
"@types/react": "~19.2.2",
|
|
71
|
+
"@types/react-dom": "~19.2.2",
|
|
72
|
+
"react": "~19.2.0",
|
|
73
|
+
"react-dom": "~19.2.0",
|
|
74
|
+
"vite": "7.1.9",
|
|
75
|
+
"@dxos/react-ui": "0.8.4-main.72ec0f3",
|
|
76
|
+
"@dxos/react-ui-theme": "0.8.4-main.72ec0f3",
|
|
77
|
+
"@dxos/storybook-utils": "0.8.4-main.72ec0f3",
|
|
78
|
+
"@dxos/plugin-theme": "0.8.4-main.72ec0f3"
|
|
70
79
|
},
|
|
71
80
|
"peerDependencies": {
|
|
72
|
-
"react": "
|
|
73
|
-
"react-dom": "
|
|
74
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
75
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
81
|
+
"react": "^19.0.0",
|
|
82
|
+
"react-dom": "^19.0.0",
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.72ec0f3",
|
|
84
|
+
"@dxos/react-ui-theme": "0.8.4-main.72ec0f3"
|
|
76
85
|
},
|
|
77
86
|
"publishConfig": {
|
|
78
87
|
"access": "public"
|
package/src/ChessPlugin.tsx
CHANGED
|
@@ -2,59 +2,60 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities, contributes, createIntent, defineModule, definePlugin
|
|
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 {
|
|
10
|
+
import { BlueprintDefinition, CHESS_BLUEPRINT_KEY, IntentResolver, ReactSurface } from './capabilities';
|
|
11
11
|
import { meta } from './meta';
|
|
12
12
|
import { translations } from './translations';
|
|
13
|
-
import {
|
|
13
|
+
import { Chess, ChessAction } from './types';
|
|
14
14
|
|
|
15
|
-
export const ChessPlugin = () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
iconHue: 'amber',
|
|
30
|
+
blueprints: [CHESS_BLUEPRINT_KEY],
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
defineModule({
|
|
35
|
+
id: `${meta.id}/module/object-form`,
|
|
36
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
37
|
+
activate: () =>
|
|
38
|
+
contributes(
|
|
39
|
+
SpaceCapabilities.ObjectForm,
|
|
40
|
+
defineObjectForm({
|
|
41
|
+
objectSchema: Chess.Game,
|
|
42
|
+
getIntent: () => createIntent(ChessAction.Create),
|
|
31
43
|
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
]);
|
|
44
|
+
),
|
|
45
|
+
}),
|
|
46
|
+
defineModule({
|
|
47
|
+
id: `${meta.id}/module/react-surface`,
|
|
48
|
+
activatesOn: Events.SetupReactSurface,
|
|
49
|
+
activate: ReactSurface,
|
|
50
|
+
}),
|
|
51
|
+
defineModule({
|
|
52
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
53
|
+
activatesOn: Events.SetupIntentResolver,
|
|
54
|
+
activate: IntentResolver,
|
|
55
|
+
}),
|
|
56
|
+
defineModule({
|
|
57
|
+
id: `${meta.id}/module/blueprint`,
|
|
58
|
+
activatesOn: Events.SetupArtifactDefinition,
|
|
59
|
+
activate: BlueprintDefinition,
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
@@ -2,20 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
// ISSUE(burdon): defineArtifact
|
|
6
|
+
// @ts-nocheck
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
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 {
|
|
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:
|
|
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
|
-
|
|
49
|
+
pgn: Schema.String.annotations({ description: 'The state of the chess game in the PGN format.' }),
|
|
45
50
|
}),
|
|
46
|
-
execute: async ({
|
|
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, {
|
|
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(
|
|
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(
|
|
91
|
+
invariant(Obj.instanceOf(Chess.Game, game));
|
|
87
92
|
|
|
88
|
-
return ToolResult.Success(game.
|
|
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(
|
|
112
|
+
invariant(Obj.instanceOf(Chess.Game, game));
|
|
108
113
|
|
|
109
|
-
const
|
|
114
|
+
const chess = new ChessJS(game.pgn);
|
|
110
115
|
try {
|
|
111
|
-
|
|
116
|
+
chess.move(move);
|
|
112
117
|
} catch (error: any) {
|
|
113
118
|
return ToolResult.Error(error.message);
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
game.
|
|
117
|
-
return ToolResult.Success(game.
|
|
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
|
+
const functions: FunctionDefinition[] = [create, move, play];
|
|
13
|
+
|
|
14
|
+
export const CHESS_BLUEPRINT_KEY = 'dxos.org/blueprint/chess';
|
|
15
|
+
|
|
16
|
+
export default () => {
|
|
17
|
+
return [
|
|
18
|
+
contributes(Capabilities.Functions, functions),
|
|
19
|
+
contributes(
|
|
20
|
+
Capabilities.BlueprintDefinition,
|
|
21
|
+
Blueprint.make({
|
|
22
|
+
key: CHESS_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
|
|
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 {
|
|
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,
|
|
18
|
-
const pgn = fen ? new Chess(fen).pgn() : undefined;
|
|
14
|
+
resolve: ({ name, pgn }) => {
|
|
19
15
|
return {
|
|
20
16
|
data: {
|
|
21
|
-
object:
|
|
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 {
|
|
10
|
+
import { ChessboardContainer } from '../components';
|
|
11
11
|
import { meta } from '../meta';
|
|
12
|
-
import {
|
|
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
|
|
20
|
-
filter: (data): data is { subject:
|
|
21
|
-
component: ({ data, 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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
};
|