gcsdk 1.0.5 → 1.0.7
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/README.md +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +29 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +33 -0
- package/dist/react/ConversationGraph.d.ts +6 -0
- package/dist/react/ConversationGraph.d.ts.map +1 -0
- package/dist/react/ConversationGraph.js +51 -0
- package/package.json +21 -1
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ yarn add gcsdk
|
|
|
37
37
|
If you encounter an error about the native module not being found, ensure you're using the published version from npm. The native module is pre-built and included in the package.
|
|
38
38
|
|
|
39
39
|
If you're developing locally, you'll need Rust installed to build the native module:
|
|
40
|
+
|
|
40
41
|
```bash
|
|
41
42
|
cd native
|
|
42
43
|
npm install
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ interface Message {
|
|
|
2
2
|
role: "user" | "assistant" | "system";
|
|
3
3
|
content: string;
|
|
4
4
|
}
|
|
5
|
+
export interface HistoryNode {
|
|
6
|
+
id: string;
|
|
7
|
+
parentId: string | null;
|
|
8
|
+
role: "user" | "assistant" | "system";
|
|
9
|
+
content: string;
|
|
10
|
+
branchName: string;
|
|
11
|
+
}
|
|
5
12
|
export declare class GitChat {
|
|
6
13
|
private currentBranch;
|
|
7
14
|
private lastCommitId;
|
|
@@ -9,7 +16,7 @@ export declare class GitChat {
|
|
|
9
16
|
commit(message: Message, files: Record<string, string>): Promise<any>;
|
|
10
17
|
merge(branchName: string, baseBranchName: string): void;
|
|
11
18
|
createBranch(branchName: string, baseBranchName: string): void;
|
|
12
|
-
getHistory():
|
|
19
|
+
getHistory(): HistoryNode[];
|
|
13
20
|
checkout(branchName: string): void;
|
|
14
21
|
renderTree(): Promise<any>;
|
|
15
22
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAkBA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAuB;IAE3C,KAAK;IAMC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY5D,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAMhD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAKvD,UAAU;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAkBA,UAAU,OAAO;IACf,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAuB;IAE3C,KAAK;IAMC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAY5D,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAMhD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAKvD,UAAU,IAAI,WAAW,EAAE;IAI3B,QAAQ,CAAC,UAAU,EAAE,MAAM;IAMrB,UAAU;CAGjB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GitChat } from "../index";
|
|
2
|
+
export declare const transformToFlowData: (gitChat: GitChat) => {
|
|
3
|
+
flowNodes: {
|
|
4
|
+
id: string;
|
|
5
|
+
data: {
|
|
6
|
+
label: string;
|
|
7
|
+
};
|
|
8
|
+
position: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
style: {
|
|
13
|
+
background: string;
|
|
14
|
+
color: string;
|
|
15
|
+
borderRadius: string;
|
|
16
|
+
padding: string;
|
|
17
|
+
};
|
|
18
|
+
}[];
|
|
19
|
+
flowEdges: {
|
|
20
|
+
id: string;
|
|
21
|
+
source: string;
|
|
22
|
+
target: string;
|
|
23
|
+
animated: boolean;
|
|
24
|
+
style: {
|
|
25
|
+
stroke: string;
|
|
26
|
+
};
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,mBAAmB,GAAI,SAAS,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BnD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformToFlowData = void 0;
|
|
4
|
+
const transformToFlowData = (gitChat) => {
|
|
5
|
+
const nodes = gitChat.getHistory();
|
|
6
|
+
const flowNodes = nodes.map((node, index) => ({
|
|
7
|
+
id: node.id,
|
|
8
|
+
data: {
|
|
9
|
+
label: `${node.role.toUpperCase()}: ${node.content.slice(0, 20)} ...`,
|
|
10
|
+
},
|
|
11
|
+
position: { x: index * 250, y: 100 },
|
|
12
|
+
style: {
|
|
13
|
+
background: node.role === "user" ? "#667eea" : "#764ba2",
|
|
14
|
+
color: "#fff",
|
|
15
|
+
borderRadius: "8px",
|
|
16
|
+
padding: "10px",
|
|
17
|
+
},
|
|
18
|
+
}));
|
|
19
|
+
const flowEdges = nodes
|
|
20
|
+
.filter((node) => node.parentId)
|
|
21
|
+
.map((node) => ({
|
|
22
|
+
id: `e-${node.parentId}-${node.id}`,
|
|
23
|
+
source: node.parentId,
|
|
24
|
+
target: node.id,
|
|
25
|
+
animated: true,
|
|
26
|
+
style: { stroke: "#999" },
|
|
27
|
+
}));
|
|
28
|
+
return {
|
|
29
|
+
flowNodes,
|
|
30
|
+
flowEdges,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.transformToFlowData = transformToFlowData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationGraph.d.ts","sourceRoot":"","sources":["../../react/ConversationGraph.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,WAAW,GACZ,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC,2CAyBA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConversationGraph = ConversationGraph;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const react_1 = require("react");
|
|
39
|
+
const utils_1 = require("../lib/utils");
|
|
40
|
+
const reactflow_1 = __importStar(require("reactflow"));
|
|
41
|
+
function ConversationGraph({ gitChat, onNodeClick, }) {
|
|
42
|
+
const { flowNodes, flowEdges } = (0, react_1.useMemo)(() => {
|
|
43
|
+
return (0, utils_1.transformToFlowData)(gitChat);
|
|
44
|
+
}, [gitChat]);
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
46
|
+
width: "100%",
|
|
47
|
+
height: "100%",
|
|
48
|
+
borderRadius: "10px",
|
|
49
|
+
overflow: "hidden",
|
|
50
|
+
}, children: (0, jsx_runtime_1.jsxs)(reactflow_1.default, { nodes: flowNodes, edges: flowEdges, onNodeClick: (_, node) => onNodeClick(node), children: [(0, jsx_runtime_1.jsx)(reactflow_1.Background, { color: "#f0f0f0", gap: 10 }), (0, jsx_runtime_1.jsx)(reactflow_1.Controls, {}), (0, jsx_runtime_1.jsx)(reactflow_1.MiniMap, {})] }) }));
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gcsdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Git Chat SDK - A Git-like conversation SDK for managing chat histories with branching support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"require": "./dist/index.js",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./react": {
|
|
14
|
+
"types": "./dist/react/ConversationGraph.d.ts",
|
|
15
|
+
"require": "./dist/react/ConversationGraph.js",
|
|
16
|
+
"import": "./dist/react/ConversationGraph.js"
|
|
12
17
|
}
|
|
13
18
|
},
|
|
14
19
|
"files": [
|
|
@@ -52,8 +57,23 @@
|
|
|
52
57
|
"devDependencies": {
|
|
53
58
|
"@types/bun": "^1.3.5",
|
|
54
59
|
"@types/node": "^20.0.0",
|
|
60
|
+
"@types/react": "^18.0.0",
|
|
61
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
62
|
+
"reactflow": "^11.11.4",
|
|
55
63
|
"typescript": "^5.0.0"
|
|
56
64
|
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
67
|
+
"reactflow": "^11.0.0"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"react": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"reactflow": {
|
|
74
|
+
"optional": true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
57
77
|
"engines": {
|
|
58
78
|
"node": ">=14.0.0"
|
|
59
79
|
}
|