@dxos/plugin-chess 0.8.4-main.c1de068 → 0.8.4-main.c351d160a8
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/ChessArticle-UDSL3OJ4.mjs +59 -0
- package/dist/lib/browser/ChessArticle-UDSL3OJ4.mjs.map +7 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs +21 -0
- package/dist/lib/browser/ChessCard-OIRFQMOJ.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-OSNXLHYU.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +11 -0
- package/dist/lib/browser/blueprints/index.mjs.map +7 -0
- package/dist/lib/browser/chunk-2TJN26DN.mjs +67 -0
- package/dist/lib/browser/chunk-2TJN26DN.mjs.map +7 -0
- package/dist/lib/browser/chunk-6JG4KLVU.mjs +231 -0
- package/dist/lib/browser/chunk-6JG4KLVU.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/chunk-JP6G6VR6.mjs +276 -0
- package/dist/lib/browser/chunk-JP6G6VR6.mjs.map +7 -0
- package/dist/lib/browser/chunk-RGHZ5CDO.mjs +21 -0
- package/dist/lib/browser/chunk-RGHZ5CDO.mjs.map +7 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs +1 -0
- package/dist/lib/browser/chunk-WYUTI2K4.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +28 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +64 -66
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs +50 -0
- package/dist/lib/browser/react-surface-WD7BYDFB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -7
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs +60 -0
- package/dist/lib/node-esm/ChessArticle-76MOXLJM.mjs.map +7 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs +22 -0
- package/dist/lib/node-esm/ChessCard-TKNQP6IO.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-PFZMTCXY.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-PFZMTCXY.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +12 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-46DC6W7W.mjs +232 -0
- package/dist/lib/node-esm/chunk-46DC6W7W.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs +2 -0
- package/dist/lib/node-esm/chunk-7XDEO6IJ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FK7NVSOG.mjs +277 -0
- package/dist/lib/node-esm/chunk-FK7NVSOG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FYPVCMP4.mjs +23 -0
- package/dist/lib/node-esm/chunk-FYPVCMP4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs +68 -0
- package/dist/lib/node-esm/chunk-OIRJVY2R.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +29 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +64 -66
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-TIYEREGW.mjs +51 -0
- package/dist/lib/node-esm/react-surface-TIYEREGW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -7
- package/dist/types/src/ChessPlugin.d.ts +2 -1
- package/dist/types/src/ChessPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/chess-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/chess-blueprint.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.d.ts +15 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +56 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/move.d.ts +16 -0
- package/dist/types/src/blueprints/functions/move.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/play.d.ts +17 -0
- package/dist/types/src/blueprints/functions/play.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/print.d.ts +8 -0
- package/dist/types/src/blueprints/functions/print.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +3 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts +12 -0
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +2 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts +34 -0
- package/dist/types/src/components/Chessboard/Chessboard.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/Info.d.ts +21 -0
- package/dist/types/src/components/Chessboard/Info.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/index.d.ts +2 -0
- package/dist/types/src/components/Chessboard/index.d.ts.map +1 -0
- package/dist/types/src/components/Chessboard/types.d.ts +8 -0
- package/dist/types/src/components/Chessboard/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts +6 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts +47 -0
- package/dist/types/src/containers/ChessArticle/ChessArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts +3 -0
- package/dist/types/src/containers/ChessArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts +6 -0
- package/dist/types/src/containers/ChessCard/ChessCard.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts +15 -0
- package/dist/types/src/containers/ChessCard/ChessCard.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ChessCard/index.d.ts +3 -0
- package/dist/types/src/containers/ChessCard/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +12 -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/index.d.ts +1 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +61 -34
- package/src/ChessPlugin.tsx +29 -52
- package/src/blueprints/chess-blueprint.ts +36 -0
- package/src/blueprints/functions/create.ts +38 -0
- package/src/blueprints/functions/index.ts +17 -0
- package/src/blueprints/functions/move.ts +48 -0
- package/src/blueprints/functions/play.ts +58 -0
- package/src/blueprints/functions/print.ts +42 -0
- package/src/blueprints/index.ts +6 -0
- package/src/capabilities/artifact-definition/artifact-definition.ts +135 -0
- package/src/capabilities/artifact-definition/index.ts +7 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +17 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +2 -5
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +33 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +26 -0
- package/src/components/Chessboard/Chessboard.tsx +186 -0
- package/src/components/Chessboard/Info.tsx +246 -0
- package/src/components/Chessboard/index.ts +5 -0
- package/src/components/Chessboard/types.ts +18 -0
- package/src/components/index.ts +2 -6
- package/src/containers/ChessArticle/ChessArticle.stories.tsx +53 -0
- package/src/containers/ChessArticle/ChessArticle.tsx +72 -0
- package/src/containers/ChessArticle/index.ts +7 -0
- package/src/containers/ChessCard/ChessCard.stories.tsx +42 -0
- package/src/containers/ChessCard/ChessCard.tsx +22 -0
- package/src/containers/ChessCard/index.ts +7 -0
- package/src/containers/index.ts +8 -0
- package/src/index.ts +3 -1
- package/src/meta.ts +9 -7
- package/src/translations.ts +12 -2
- package/src/types/Chess.ts +62 -0
- package/src/types/index.ts +1 -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 +0 -36
- 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 +0 -10
- 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 +0 -37
- package/dist/lib/node-esm/react-surface-NGLNIWN3.mjs.map +0 -7
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- 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/Chessboard.stories.d.ts +0 -8
- package/dist/types/src/components/Chessboard.stories.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/capabilities/artifact-definition.ts +0 -124
- package/src/capabilities/intent-resolver.ts +0 -26
- package/src/capabilities/react-surface.tsx +0 -23
- 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/Chessboard.stories.tsx +0 -41
- package/src/components/PlayerSelector.tsx +0 -82
- package/src/types/schema.ts +0 -34
- package/src/types/types.ts +0 -20
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
9
|
+
import { CardContainer } from '@dxos/react-ui-mosaic/testing';
|
|
10
|
+
|
|
11
|
+
import { meta as pluginMeta } from '../../meta';
|
|
12
|
+
import { Chess } from '../../types';
|
|
13
|
+
|
|
14
|
+
import { ChessCard } from './ChessCard';
|
|
15
|
+
|
|
16
|
+
const SAMPLE_PGN =
|
|
17
|
+
'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 *';
|
|
18
|
+
|
|
19
|
+
const CardStory = () => {
|
|
20
|
+
const game = useMemo(() => Chess.make({ pgn: SAMPLE_PGN }), []);
|
|
21
|
+
return (
|
|
22
|
+
<CardContainer role='popover' icon={pluginMeta.icon}>
|
|
23
|
+
<ChessCard subject={game} />
|
|
24
|
+
</CardContainer>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const meta = {
|
|
29
|
+
title: 'plugins/plugin-chess/containers/ChessCard',
|
|
30
|
+
render: () => <CardStory />,
|
|
31
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
32
|
+
parameters: {
|
|
33
|
+
layout: 'fullscreen',
|
|
34
|
+
},
|
|
35
|
+
tags: ['cards'],
|
|
36
|
+
} satisfies Meta;
|
|
37
|
+
|
|
38
|
+
export default meta;
|
|
39
|
+
|
|
40
|
+
type Story = StoryObj<typeof meta>;
|
|
41
|
+
|
|
42
|
+
export const Popover: Story = {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type SurfaceComponentProps } from '@dxos/app-toolkit/ui';
|
|
8
|
+
|
|
9
|
+
import { Chessboard } from '../../components';
|
|
10
|
+
import { type Chess } from '../../types';
|
|
11
|
+
|
|
12
|
+
export type ChessCardProps = SurfaceComponentProps<Chess.Game>;
|
|
13
|
+
|
|
14
|
+
export const ChessCard = ({ subject: game }: ChessCardProps) => {
|
|
15
|
+
return (
|
|
16
|
+
<Chessboard.Root game={game}>
|
|
17
|
+
<Chessboard.Content>
|
|
18
|
+
<Chessboard.Board />
|
|
19
|
+
</Chessboard.Content>
|
|
20
|
+
</Chessboard.Root>
|
|
21
|
+
);
|
|
22
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
export * from './blueprints';
|
|
5
6
|
export * from './capabilities';
|
|
6
|
-
export * from './components';
|
|
7
|
+
export * from './components/Chessboard';
|
|
7
8
|
export * from './meta';
|
|
9
|
+
export * from './types';
|
|
8
10
|
|
|
9
11
|
export * from './ChessPlugin';
|
package/src/meta.ts
CHANGED
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
export const meta: PluginMeta = {
|
|
10
|
-
id: CHESS_PLUGIN,
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
|
+
id: 'org.dxos.plugin.chess',
|
|
11
10
|
name: 'Chess',
|
|
12
|
-
description:
|
|
13
|
-
|
|
11
|
+
description: trim`
|
|
12
|
+
Full-featured chess game supporting multiplayer matches with friends or practice sessions against AI opponents.
|
|
13
|
+
Track game history and analyze moves in real-time.
|
|
14
|
+
`,
|
|
14
15
|
icon: 'ph--shield-chevron--regular',
|
|
16
|
+
iconHue: 'amber',
|
|
15
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess',
|
|
16
18
|
screenshots: ['https://dxos.network/plugin-details-chess-dark.png'],
|
|
17
19
|
};
|
package/src/translations.ts
CHANGED
|
@@ -5,23 +5,33 @@
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
7
|
import { meta } from './meta';
|
|
8
|
-
import {
|
|
8
|
+
import { Chess } from './types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[
|
|
13
|
+
[Chess.Game.typename]: {
|
|
14
14
|
'typename label': 'Game',
|
|
15
15
|
'typename label_zero': 'Games',
|
|
16
16
|
'typename label_one': 'Game',
|
|
17
17
|
'typename label_other': 'Games',
|
|
18
18
|
'object name placeholder': 'New game',
|
|
19
|
+
'add object label': 'Add game',
|
|
19
20
|
'rename object label': 'Rename game',
|
|
20
21
|
'delete object label': 'Delete game',
|
|
22
|
+
'object deleted label': 'Game deleted',
|
|
21
23
|
},
|
|
22
24
|
[meta.id]: {
|
|
23
25
|
'plugin name': 'Chess',
|
|
24
26
|
'delete game label': 'Delete',
|
|
27
|
+
'game.checkmate label': 'Checkmate',
|
|
28
|
+
'game.stalemate label': 'Stalemate',
|
|
29
|
+
'game.draw label': 'Draw',
|
|
30
|
+
'game.check label': 'Check',
|
|
31
|
+
'select player button': 'Select player',
|
|
32
|
+
'toggle info button': 'Toggle info',
|
|
33
|
+
'close info button': 'Close info',
|
|
34
|
+
'flip board button': 'Flip board',
|
|
25
35
|
},
|
|
26
36
|
},
|
|
27
37
|
},
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Chess as ChessJS } from 'chess.js';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { Annotation, Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { FormInputAnnotation, LabelAnnotation } from '@dxos/echo/internal';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
|
|
12
|
+
export const Game = Schema.Struct({
|
|
13
|
+
name: Schema.optional(Schema.String),
|
|
14
|
+
players: Schema.Struct({
|
|
15
|
+
white: Schema.optional(
|
|
16
|
+
Schema.String.annotations({
|
|
17
|
+
description: 'DID of white player',
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
black: Schema.optional(
|
|
21
|
+
Schema.String.annotations({
|
|
22
|
+
description: 'DID of black player',
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
26
|
+
pgn: Schema.String.annotations({
|
|
27
|
+
description: 'Portable Game Notation.',
|
|
28
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
29
|
+
fen: Schema.String.annotations({
|
|
30
|
+
description: 'Forsyth-Edwards Notation.',
|
|
31
|
+
}).pipe(FormInputAnnotation.set(false), Schema.optional),
|
|
32
|
+
}).pipe(
|
|
33
|
+
Type.object({
|
|
34
|
+
typename: 'org.dxos.type.chess',
|
|
35
|
+
version: '0.1.0',
|
|
36
|
+
}),
|
|
37
|
+
LabelAnnotation.set(['name']),
|
|
38
|
+
Annotation.IconAnnotation.set({
|
|
39
|
+
icon: 'ph--shield-chevron--regular',
|
|
40
|
+
hue: 'amber',
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export interface Game extends Schema.Schema.Type<typeof Game> {}
|
|
45
|
+
|
|
46
|
+
export const make = ({ name, pgn, fen }: { name?: string; pgn?: string; fen?: string } = {}) => {
|
|
47
|
+
const chess = new ChessJS();
|
|
48
|
+
if (pgn) {
|
|
49
|
+
try {
|
|
50
|
+
chess.loadPgn(pgn);
|
|
51
|
+
} catch {
|
|
52
|
+
log.warn(pgn);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return Obj.make(Game, {
|
|
57
|
+
name,
|
|
58
|
+
pgn,
|
|
59
|
+
fen,
|
|
60
|
+
players: {},
|
|
61
|
+
});
|
|
62
|
+
};
|
package/src/types/index.ts
CHANGED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Chess
|
|
3
|
-
} from "./chunk-ZXH3N4NA.mjs";
|
|
4
|
-
|
|
5
|
-
// src/components/ChessContainer.tsx
|
|
6
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
7
|
-
import React2 from "react";
|
|
8
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
9
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
10
|
-
|
|
11
|
-
// src/components/PlayerSelector.tsx
|
|
12
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
13
|
-
import React from "react";
|
|
14
|
-
import { generateName } from "@dxos/display-name";
|
|
15
|
-
import { useMembers } from "@dxos/react-client/echo";
|
|
16
|
-
import { Icon, Input, Select, useThemeContext } from "@dxos/react-ui";
|
|
17
|
-
var PlayerSelector = ({ space, game }) => {
|
|
18
|
-
var _effect = _useSignals();
|
|
19
|
-
try {
|
|
20
|
-
const members = useMembers(space.key);
|
|
21
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
22
|
-
role: "none",
|
|
23
|
-
className: "grid grid-cols-2 gap-8"
|
|
24
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
25
|
-
role: "none",
|
|
26
|
-
className: "flex flex-row-reverse items-center gap-2"
|
|
27
|
-
}, /* @__PURE__ */ React.createElement(PlayerSelect, {
|
|
28
|
-
side: "white",
|
|
29
|
-
value: game.playerWhite,
|
|
30
|
-
onValueChange: (player) => game.playerWhite = player,
|
|
31
|
-
members
|
|
32
|
-
})), /* @__PURE__ */ React.createElement("div", {
|
|
33
|
-
role: "none",
|
|
34
|
-
className: "flex flex-row items-center gap-2"
|
|
35
|
-
}, /* @__PURE__ */ React.createElement(PlayerSelect, {
|
|
36
|
-
side: "black",
|
|
37
|
-
value: game.playerBlack,
|
|
38
|
-
onValueChange: (player) => game.playerBlack = player,
|
|
39
|
-
members
|
|
40
|
-
})));
|
|
41
|
-
} finally {
|
|
42
|
-
_effect.f();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var PlayerSelect = ({ side, value, onValueChange, members }) => {
|
|
46
|
-
var _effect = _useSignals();
|
|
47
|
-
try {
|
|
48
|
-
const { themeMode } = useThemeContext();
|
|
49
|
-
const iconFillMode = side === "black" && themeMode === "light" || side === "white" && themeMode === "dark" ? "fill" : void 0;
|
|
50
|
-
return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Label, null, /* @__PURE__ */ React.createElement(Icon, {
|
|
51
|
-
"aria-label": `Chess icon for side ${side}`,
|
|
52
|
-
icon: `ph--crown-cross--${iconFillMode || "regular"}`,
|
|
53
|
-
size: 6
|
|
54
|
-
})), /* @__PURE__ */ React.createElement(Select.Root, {
|
|
55
|
-
value,
|
|
56
|
-
onValueChange
|
|
57
|
-
}, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
|
|
58
|
-
placeholder: "Select player"
|
|
59
|
-
}), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, members.map((member) => {
|
|
60
|
-
const memberKey = member.identity.identityKey.toHex();
|
|
61
|
-
const displayName = member.identity?.profile?.displayName || generateName(memberKey);
|
|
62
|
-
return /* @__PURE__ */ React.createElement(Select.Option, {
|
|
63
|
-
key: memberKey,
|
|
64
|
-
value: memberKey
|
|
65
|
-
}, displayName);
|
|
66
|
-
}))))));
|
|
67
|
-
} finally {
|
|
68
|
-
_effect.f();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// src/components/ChessContainer.tsx
|
|
73
|
-
var containFragment = "is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]";
|
|
74
|
-
var ChessContainer = ({ game, role }) => {
|
|
75
|
-
var _effect = _useSignals2();
|
|
76
|
-
try {
|
|
77
|
-
const space = getSpace(game);
|
|
78
|
-
if (!space) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
switch (role) {
|
|
82
|
-
case "card--popover": {
|
|
83
|
-
return /* @__PURE__ */ React2.createElement(Chess.Root, {
|
|
84
|
-
game
|
|
85
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
86
|
-
role: "none",
|
|
87
|
-
className: "popover-square size-container"
|
|
88
|
-
}, /* @__PURE__ */ React2.createElement(Chess.Board, {
|
|
89
|
-
classNames: containFragment
|
|
90
|
-
})));
|
|
91
|
-
}
|
|
92
|
-
case "card--extrinsic": {
|
|
93
|
-
return /* @__PURE__ */ React2.createElement(Chess.Root, {
|
|
94
|
-
game
|
|
95
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
96
|
-
role: "none",
|
|
97
|
-
className: "grid is-full bs-full size-container place-content-center"
|
|
98
|
-
}, /* @__PURE__ */ React2.createElement(Chess.Board, {
|
|
99
|
-
classNames: containFragment
|
|
100
|
-
})));
|
|
101
|
-
}
|
|
102
|
-
case "card--intrinsic": {
|
|
103
|
-
return /* @__PURE__ */ React2.createElement(Chess.Root, {
|
|
104
|
-
game
|
|
105
|
-
}, /* @__PURE__ */ React2.createElement(Chess.Board, null));
|
|
106
|
-
}
|
|
107
|
-
default: {
|
|
108
|
-
return /* @__PURE__ */ React2.createElement(StackItem.Content, null, /* @__PURE__ */ React2.createElement("div", {
|
|
109
|
-
role: "none",
|
|
110
|
-
className: "grid grid-rows-[60px_1fr_60px] grow overflow-hidden"
|
|
111
|
-
}, /* @__PURE__ */ React2.createElement("div", null), /* @__PURE__ */ React2.createElement("div", {
|
|
112
|
-
className: "flex m-4 overflow-hidden"
|
|
113
|
-
}, /* @__PURE__ */ React2.createElement(Chess.Root, {
|
|
114
|
-
game
|
|
115
|
-
}, /* @__PURE__ */ React2.createElement(Chess.Content, null, /* @__PURE__ */ React2.createElement(Chess.Board, null)))), /* @__PURE__ */ React2.createElement(PlayerSelector, {
|
|
116
|
-
space,
|
|
117
|
-
game
|
|
118
|
-
})));
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
} finally {
|
|
122
|
-
_effect.f();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var ChessContainer_default = ChessContainer;
|
|
126
|
-
export {
|
|
127
|
-
ChessContainer_default as default
|
|
128
|
-
};
|
|
129
|
-
//# sourceMappingURL=ChessContainer-SC4ZV6XZ.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/ChessContainer.tsx", "../../../src/components/PlayerSelector.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { getSpace } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { Chess } from './Chess';\nimport { PlayerSelector } from './PlayerSelector';\nimport { type ChessType } from '../types';\n\nconst containFragment = 'is-[min(100cqw,100cqh)] bs-[min(100cqw,100cqh)]';\n\nconst ChessContainer = ({ game, role }: { game: ChessType; role?: string }) => {\n const space = getSpace(game);\n\n if (!space) {\n return null;\n }\n\n switch (role) {\n case 'card--popover': {\n return (\n <Chess.Root game={game}>\n <div role='none' className='popover-square size-container'>\n <Chess.Board classNames={containFragment} />\n </div>\n </Chess.Root>\n );\n }\n case 'card--extrinsic': {\n return (\n <Chess.Root game={game}>\n <div role='none' className='grid is-full bs-full size-container place-content-center'>\n <Chess.Board classNames={containFragment} />\n </div>\n </Chess.Root>\n );\n }\n case 'card--intrinsic': {\n return (\n <Chess.Root game={game}>\n <Chess.Board />\n </Chess.Root>\n );\n }\n default: {\n return (\n <StackItem.Content>\n <div role='none' className='grid grid-rows-[60px_1fr_60px] grow overflow-hidden'>\n <div />\n\n <div className='flex m-4 overflow-hidden'>\n <Chess.Root game={game}>\n <Chess.Content>\n <Chess.Board />\n </Chess.Content>\n </Chess.Root>\n </div>\n\n <PlayerSelector space={space} game={game} />\n </div>\n </StackItem.Content>\n );\n }\n }\n};\n\nexport default ChessContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { generateName } from '@dxos/display-name';\nimport { useMembers, type Space, type SpaceMember } from '@dxos/react-client/echo';\nimport { Icon, Input, Select, useThemeContext } from '@dxos/react-ui';\n\nimport { type ChessType } from '../types';\n\nexport const PlayerSelector = ({ space, game }: { space: Space; game: ChessType }) => {\n const members = useMembers(space.key);\n\n return (\n <div role='none' className='grid grid-cols-2 gap-8'>\n <div role='none' className='flex flex-row-reverse items-center gap-2'>\n <PlayerSelect\n side='white'\n value={game.playerWhite}\n onValueChange={(player) => (game.playerWhite = player)}\n members={members}\n />\n </div>\n <div role='none' className='flex flex-row items-center gap-2'>\n <PlayerSelect\n side='black'\n value={game.playerBlack}\n onValueChange={(player) => (game.playerBlack = player)}\n members={members}\n />\n </div>\n </div>\n );\n};\n\nconst PlayerSelect = ({\n side,\n value,\n onValueChange,\n members,\n}: {\n side: 'white' | 'black';\n value: string | undefined;\n onValueChange: (player: string) => void;\n members: SpaceMember[];\n}) => {\n const { themeMode } = useThemeContext();\n const iconFillMode =\n (side === 'black' && themeMode === 'light') || (side === 'white' && themeMode === 'dark') ? 'fill' : undefined;\n\n return (\n <Input.Root>\n <Input.Label>\n <Icon\n aria-label={`Chess icon for side ${side}`}\n icon={`ph--crown-cross--${iconFillMode || 'regular'}`}\n size={6}\n />\n </Input.Label>\n <Select.Root value={value} onValueChange={onValueChange}>\n <Select.TriggerButton placeholder={'Select player'} />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {members.map((member) => {\n const memberKey = member.identity.identityKey.toHex();\n const displayName = member.identity?.profile?.displayName || generateName(memberKey);\n return (\n <Select.Option key={memberKey} value={memberKey}>\n {displayName}\n </Select.Option>\n );\n })}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </Input.Root>\n );\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["React", "getSpace", "StackItem", "React", "generateName", "useMembers", "Icon", "Input", "Select", "useThemeContext", "PlayerSelector", "space", "game", "members", "useMembers", "key", "div", "role", "className", "PlayerSelect", "side", "value", "playerWhite", "onValueChange", "player", "playerBlack", "themeMode", "useThemeContext", "iconFillMode", "undefined", "Input", "Root", "Label", "Icon", "aria-label", "icon", "size", "Select", "TriggerButton", "placeholder", "Portal", "Content", "Viewport", "map", "member", "memberKey", "identity", "identityKey", "toHex", "displayName", "profile", "generateName", "Option", "containFragment", "ChessContainer", "game", "role", "space", "getSpace", "React", "Chess", "Root", "div", "className", "Board", "classNames", "StackItem", "Content", "PlayerSelector"]
|
|
7
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChessAction,
|
|
3
|
-
ChessType,
|
|
4
|
-
meta
|
|
5
|
-
} from "./chunk-A3WEUKPK.mjs";
|
|
6
|
-
|
|
7
|
-
// src/capabilities/artifact-definition.ts
|
|
8
|
-
import { Chess } from "chess.js";
|
|
9
|
-
import { pipe, Schema } from "effect";
|
|
10
|
-
import { createTool, ToolResult } from "@dxos/ai";
|
|
11
|
-
import { Capabilities, chain, contributes, createIntent } from "@dxos/app-framework";
|
|
12
|
-
import { createArtifactElement, VersionPin, ArtifactId } from "@dxos/assistant";
|
|
13
|
-
import { defineArtifact } from "@dxos/blueprints";
|
|
14
|
-
import { Obj } from "@dxos/echo";
|
|
15
|
-
import { invariant } from "@dxos/invariant";
|
|
16
|
-
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
17
|
-
import { Filter } from "@dxos/react-client/echo";
|
|
18
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-chess/src/capabilities/artifact-definition.ts";
|
|
19
|
-
var artifact_definition_default = () => {
|
|
20
|
-
const definition = defineArtifact({
|
|
21
|
-
id: `artifact:${meta.id}`,
|
|
22
|
-
name: meta.name,
|
|
23
|
-
description: "Provides a simple chess engine.",
|
|
24
|
-
instructions: `
|
|
25
|
-
- 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.
|
|
26
|
-
- Always inspect the chess game at the start of every prompt realting to a chess game, as it might have changed since the interaction.
|
|
27
|
-
`,
|
|
28
|
-
schema: ChessType,
|
|
29
|
-
tools: [
|
|
30
|
-
createTool(meta.id, {
|
|
31
|
-
name: "create",
|
|
32
|
-
description: "Create a new chess game. Returns the artifact definition for the game.",
|
|
33
|
-
caption: "Creating chess game...",
|
|
34
|
-
schema: Schema.Struct({
|
|
35
|
-
fen: Schema.String.annotations({
|
|
36
|
-
description: "The state of the chess game in the FEN format."
|
|
37
|
-
})
|
|
38
|
-
}),
|
|
39
|
-
execute: async ({ fen }, { extensions }) => {
|
|
40
|
-
invariant(extensions?.space, "No space", {
|
|
41
|
-
F: __dxlog_file,
|
|
42
|
-
L: 47,
|
|
43
|
-
S: void 0,
|
|
44
|
-
A: [
|
|
45
|
-
"extensions?.space",
|
|
46
|
-
"'No space'"
|
|
47
|
-
]
|
|
48
|
-
});
|
|
49
|
-
invariant(extensions?.dispatch, "No intent dispatcher", {
|
|
50
|
-
F: __dxlog_file,
|
|
51
|
-
L: 48,
|
|
52
|
-
S: void 0,
|
|
53
|
-
A: [
|
|
54
|
-
"extensions?.dispatch",
|
|
55
|
-
"'No intent dispatcher'"
|
|
56
|
-
]
|
|
57
|
-
});
|
|
58
|
-
const intent = pipe(createIntent(ChessAction.Create, {
|
|
59
|
-
fen
|
|
60
|
-
}), chain(SpaceAction.AddObject, {
|
|
61
|
-
target: extensions.space
|
|
62
|
-
}));
|
|
63
|
-
const { data, error } = await extensions.dispatch(intent);
|
|
64
|
-
if (!data || error) {
|
|
65
|
-
return ToolResult.Error(error?.message ?? "Failed to create chess game");
|
|
66
|
-
}
|
|
67
|
-
return ToolResult.Success(createArtifactElement(data.id), [
|
|
68
|
-
VersionPin.createBlock(VersionPin.fromObject(data.object))
|
|
69
|
-
]);
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
72
|
-
createTool(meta.id, {
|
|
73
|
-
name: "list",
|
|
74
|
-
description: "Query all active chess games.",
|
|
75
|
-
caption: "Getting games...",
|
|
76
|
-
schema: Schema.Struct({}),
|
|
77
|
-
execute: async (_, { extensions }) => {
|
|
78
|
-
invariant(extensions?.space, "No space", {
|
|
79
|
-
F: __dxlog_file,
|
|
80
|
-
L: 69,
|
|
81
|
-
S: void 0,
|
|
82
|
-
A: [
|
|
83
|
-
"extensions?.space",
|
|
84
|
-
"'No space'"
|
|
85
|
-
]
|
|
86
|
-
});
|
|
87
|
-
const { objects: games } = await extensions.space.db.query(Filter.type(ChessType)).run();
|
|
88
|
-
invariant(games.length > 0, "No chess games found", {
|
|
89
|
-
F: __dxlog_file,
|
|
90
|
-
L: 71,
|
|
91
|
-
S: void 0,
|
|
92
|
-
A: [
|
|
93
|
-
"games.length > 0",
|
|
94
|
-
"'No chess games found'"
|
|
95
|
-
]
|
|
96
|
-
});
|
|
97
|
-
return ToolResult.Success(games);
|
|
98
|
-
}
|
|
99
|
-
}),
|
|
100
|
-
createTool(meta.id, {
|
|
101
|
-
name: "inspect",
|
|
102
|
-
description: "Get the current state of the chess game.",
|
|
103
|
-
caption: "Inspecting game...",
|
|
104
|
-
schema: Schema.Struct({
|
|
105
|
-
id: ArtifactId
|
|
106
|
-
}),
|
|
107
|
-
execute: async ({ id }, { extensions }) => {
|
|
108
|
-
invariant(extensions?.space, "No space", {
|
|
109
|
-
F: __dxlog_file,
|
|
110
|
-
L: 82,
|
|
111
|
-
S: void 0,
|
|
112
|
-
A: [
|
|
113
|
-
"extensions?.space",
|
|
114
|
-
"'No space'"
|
|
115
|
-
]
|
|
116
|
-
});
|
|
117
|
-
const game = await extensions.space.db.query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString())).first();
|
|
118
|
-
invariant(Obj.instanceOf(ChessType, game), void 0, {
|
|
119
|
-
F: __dxlog_file,
|
|
120
|
-
L: 86,
|
|
121
|
-
S: void 0,
|
|
122
|
-
A: [
|
|
123
|
-
"Obj.instanceOf(ChessType, game)",
|
|
124
|
-
""
|
|
125
|
-
]
|
|
126
|
-
});
|
|
127
|
-
return ToolResult.Success(game.fen);
|
|
128
|
-
}
|
|
129
|
-
}),
|
|
130
|
-
createTool(meta.id, {
|
|
131
|
-
name: "move",
|
|
132
|
-
description: "Make a move in the chess game.",
|
|
133
|
-
caption: "Making chess move...",
|
|
134
|
-
schema: Schema.Struct({
|
|
135
|
-
id: ArtifactId,
|
|
136
|
-
move: Schema.String.annotations({
|
|
137
|
-
description: "The move to make in the chess game.",
|
|
138
|
-
examples: [
|
|
139
|
-
"e4",
|
|
140
|
-
"Bf3"
|
|
141
|
-
]
|
|
142
|
-
})
|
|
143
|
-
}),
|
|
144
|
-
execute: async ({ id, move }, { extensions }) => {
|
|
145
|
-
invariant(extensions?.space, "No space", {
|
|
146
|
-
F: __dxlog_file,
|
|
147
|
-
L: 103,
|
|
148
|
-
S: void 0,
|
|
149
|
-
A: [
|
|
150
|
-
"extensions?.space",
|
|
151
|
-
"'No space'"
|
|
152
|
-
]
|
|
153
|
-
});
|
|
154
|
-
const game = await extensions.space.db.query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString())).first();
|
|
155
|
-
invariant(Obj.instanceOf(ChessType, game), void 0, {
|
|
156
|
-
F: __dxlog_file,
|
|
157
|
-
L: 107,
|
|
158
|
-
S: void 0,
|
|
159
|
-
A: [
|
|
160
|
-
"Obj.instanceOf(ChessType, game)",
|
|
161
|
-
""
|
|
162
|
-
]
|
|
163
|
-
});
|
|
164
|
-
const board = new Chess(game.fen);
|
|
165
|
-
try {
|
|
166
|
-
board.move(move);
|
|
167
|
-
} catch (error) {
|
|
168
|
-
return ToolResult.Error(error.message);
|
|
169
|
-
}
|
|
170
|
-
game.pgn = board.pgn();
|
|
171
|
-
game.fen = board.fen();
|
|
172
|
-
return ToolResult.Success(game.fen);
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
]
|
|
176
|
-
});
|
|
177
|
-
return contributes(Capabilities.ArtifactDefinition, definition);
|
|
178
|
-
};
|
|
179
|
-
export {
|
|
180
|
-
artifact_definition_default as default
|
|
181
|
-
};
|
|
182
|
-
//# sourceMappingURL=artifact-definition-A2FSM255.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/artifact-definition.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Chess } from 'chess.js';\nimport { pipe, Schema } from 'effect';\n\nimport { createTool, ToolResult } from '@dxos/ai';\nimport { Capabilities, chain, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';\nimport { createArtifactElement, VersionPin, ArtifactId } from '@dxos/assistant';\nimport { defineArtifact } from '@dxos/blueprints';\nimport { Obj } from '@dxos/echo';\nimport { invariant } from '@dxos/invariant';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Filter, type Space } from '@dxos/react-client/echo';\n\nimport { meta } from '../meta';\nimport { ChessAction, ChessType } from '../types';\n\n// TODO(burdon): Factor out.\ndeclare global {\n interface ToolContextExtensions {\n space?: Space;\n dispatch?: PromiseIntentDispatcher;\n }\n}\n\nexport default () => {\n const definition = defineArtifact({\n id: `artifact:${meta.id}`,\n name: meta.name,\n description: 'Provides a simple chess engine.',\n instructions: `\n - 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.\n - Always inspect the chess game at the start of every prompt realting to a chess game, as it might have changed since the interaction.\n `,\n schema: ChessType,\n tools: [\n createTool(meta.id, {\n name: 'create',\n description: 'Create a new chess game. Returns the artifact definition for the game.',\n caption: 'Creating chess game...',\n schema: Schema.Struct({\n fen: Schema.String.annotations({ description: 'The state of the chess game in the FEN format.' }),\n }),\n execute: async ({ fen }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n invariant(extensions?.dispatch, 'No intent dispatcher');\n const intent = pipe(\n createIntent(ChessAction.Create, { fen }),\n chain(SpaceAction.AddObject, { target: extensions.space }),\n );\n const { data, error } = await extensions.dispatch(intent);\n if (!data || error) {\n return ToolResult.Error(error?.message ?? 'Failed to create chess game');\n }\n\n return ToolResult.Success(createArtifactElement(data.id), [\n VersionPin.createBlock(VersionPin.fromObject(data.object)),\n ]);\n },\n }),\n createTool(meta.id, {\n name: 'list',\n description: 'Query all active chess games.',\n caption: 'Getting games...',\n schema: Schema.Struct({}),\n execute: async (_, { extensions }) => {\n invariant(extensions?.space, 'No space');\n const { objects: games } = await extensions.space.db.query(Filter.type(ChessType)).run();\n invariant(games.length > 0, 'No chess games found');\n\n return ToolResult.Success(games);\n },\n }),\n createTool(meta.id, {\n name: 'inspect',\n description: 'Get the current state of the chess game.',\n caption: 'Inspecting game...',\n schema: Schema.Struct({ id: ArtifactId }),\n execute: async ({ id }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n const game = await extensions.space.db\n .query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))\n .first();\n invariant(Obj.instanceOf(ChessType, game));\n\n return ToolResult.Success(game.fen);\n },\n }),\n createTool(meta.id, {\n name: 'move',\n description: 'Make a move in the chess game.',\n caption: 'Making chess move...',\n schema: Schema.Struct({\n id: ArtifactId,\n move: Schema.String.annotations({\n description: 'The move to make in the chess game.',\n examples: ['e4', 'Bf3'],\n }),\n }),\n execute: async ({ id, move }, { extensions }) => {\n invariant(extensions?.space, 'No space');\n const game = await extensions.space.db\n .query(Filter.ids(ArtifactId.toDXN(id, extensions.space.id).toString()))\n .first();\n invariant(Obj.instanceOf(ChessType, game));\n\n const board = new Chess(game.fen);\n try {\n board.move(move);\n } catch (error: any) {\n return ToolResult.Error(error.message);\n }\n game.pgn = board.pgn();\n game.fen = board.fen();\n return ToolResult.Success(game.fen);\n },\n }),\n ],\n });\n\n return contributes(Capabilities.ArtifactDefinition, definition);\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["Chess", "pipe", "Schema", "createTool", "ToolResult", "Capabilities", "chain", "contributes", "createIntent", "createArtifactElement", "VersionPin", "ArtifactId", "defineArtifact", "Obj", "invariant", "SpaceAction", "Filter", "definition", "defineArtifact", "id", "meta", "name", "description", "instructions", "schema", "ChessType", "tools", "createTool", "caption", "Schema", "Struct", "fen", "String", "annotations", "execute", "extensions", "invariant", "space", "dispatch", "intent", "pipe", "createIntent", "ChessAction", "Create", "chain", "SpaceAction", "AddObject", "target", "data", "error", "ToolResult", "Error", "message", "Success", "createArtifactElement", "VersionPin", "createBlock", "fromObject", "object", "_", "objects", "games", "db", "query", "Filter", "type", "run", "length", "ArtifactId", "game", "ids", "toDXN", "toString", "first", "Obj", "instanceOf", "move", "examples", "board", "Chess", "pgn", "contributes", "Capabilities", "ArtifactDefinition"]
|
|
7
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// src/types/schema.ts
|
|
2
|
-
import { Schema } from "effect";
|
|
3
|
-
import { Type } from "@dxos/echo";
|
|
4
|
-
var MoveSchema = Schema.mutable(Schema.partial(Schema.Struct({
|
|
5
|
-
source: Schema.String,
|
|
6
|
-
target: Schema.String,
|
|
7
|
-
piece: Schema.String
|
|
8
|
-
})));
|
|
9
|
-
var ChessType = Schema.Struct({
|
|
10
|
-
name: Schema.optional(Schema.String),
|
|
11
|
-
playerWhite: Schema.String,
|
|
12
|
-
playerBlack: Schema.String,
|
|
13
|
-
moves: Schema.mutable(Schema.Array(Schema.String)),
|
|
14
|
-
// TODO(wittjosiah): Remove. Redundant with moves.
|
|
15
|
-
pgn: Schema.String,
|
|
16
|
-
fen: Schema.String
|
|
17
|
-
}).pipe(Schema.partial, Type.Obj({
|
|
18
|
-
typename: "dxos.org/type/Chess",
|
|
19
|
-
version: "0.1.0"
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
// src/types/types.ts
|
|
23
|
-
import { Schema as Schema2 } from "effect";
|
|
24
|
-
|
|
25
|
-
// src/meta.ts
|
|
26
|
-
var CHESS_PLUGIN = "dxos.org/plugin/chess";
|
|
27
|
-
var meta = {
|
|
28
|
-
id: CHESS_PLUGIN,
|
|
29
|
-
name: "Chess",
|
|
30
|
-
description: "Chess is a simple plugin which allows you to render an interactive chessboard inside of a plank. This chessboard can be used for collaborative chess games, or for practice experiments with the LLM. ",
|
|
31
|
-
icon: "ph--shield-chevron--regular",
|
|
32
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-chess",
|
|
33
|
-
screenshots: [
|
|
34
|
-
"https://dxos.network/plugin-details-chess-dark.png"
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// src/types/types.ts
|
|
39
|
-
(function(ChessAction2) {
|
|
40
|
-
class Create extends Schema2.TaggedClass()(`${meta.id}/action/create`, {
|
|
41
|
-
input: Schema2.Struct({
|
|
42
|
-
name: Schema2.optional(Schema2.String),
|
|
43
|
-
fen: Schema2.optional(Schema2.String)
|
|
44
|
-
}),
|
|
45
|
-
output: Schema2.Struct({
|
|
46
|
-
object: ChessType
|
|
47
|
-
})
|
|
48
|
-
}) {
|
|
49
|
-
}
|
|
50
|
-
ChessAction2.Create = Create;
|
|
51
|
-
})(ChessAction || (ChessAction = {}));
|
|
52
|
-
var ChessAction;
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
CHESS_PLUGIN,
|
|
56
|
-
meta,
|
|
57
|
-
MoveSchema,
|
|
58
|
-
ChessType,
|
|
59
|
-
ChessAction
|
|
60
|
-
};
|
|
61
|
-
//# sourceMappingURL=chunk-A3WEUKPK.mjs.map
|