Skip to content

Commit d95412c

Browse files
author
mike dupont
committed
wip local git starting to load
1 parent 7601691 commit d95412c

13 files changed

+231
-77
lines changed

packages/core/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"moduleDetection": "force",
2222
"allowArbitraryExtensions": true,
2323
"typeRoots":["./node_modules/@types"],
24-
"customConditions": ["@elizaos/source"]
24+
"customConditions": ["@elizaos/source"],
25+
"sourceMap": true
2526
},
2627
"include": ["src/**/*"],
2728
"exclude": ["node_modules", "dist", "src/**/*.d.ts", "types/**/*.test.ts"]
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- SQLite
2+
select * from memories
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# in bash count down from 42 to 1
3+
export GITHUB_ACCESS_TOKEN=`cat ~/.github_pat`
4+
export OPENAI_API_KEY=`cat ~/.secrets/openrouter.sh`
5+
export OPENAI_API_BASE="https://openrouter.ai/api/v1"
6+
export GITHUB_REPOSITORY=eliza
7+
export GITHUB_ACTOR=elizaos
8+
INPUT_PULL_NUMBER=3881
9+
#while [ $INPUT_PULL_NUMBER -gt 0 ]
10+
#do
11+
echo $INPUT_PULL_NUMBER
12+
((INPUT_PULL_NUMBER--))
13+
export INPUT_PULL_NUMBER
14+
pnpm run dbg
15+
#pnpm run ts
16+
#done

scripts/jsdoc-automation/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"langchain": "^0.3.7",
3636
"langsmith": "^0.3.11",
3737
"punycode": "^2.3.1",
38+
"simple-git": "^3.27.0",
3839
"whatwg-url": "^14.1.1",
3940
"yaml": "^2.3.4"
4041
},

scripts/jsdoc-automation/pnpm-lock.yaml

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/jsdoc-automation/src/AIService/AIService.ts

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as dotenv from "dotenv";
2+
import * as crypto from 'crypto';
23
import * as sqliteAdapter from "@elizaos-plugins/adapter-sqlite";
34
const de = dotenv.config();
45
//console.log("DEBUG",de)
@@ -21,7 +22,7 @@ import {
2122

2223

2324
AgentRuntime,
24-
25+
UUID,
2526
// CacheManager,
2627
// CacheStore,
2728
composeContext,
@@ -348,6 +349,20 @@ async function processChunk(prompt: string, manager: string, runtime: AgentRunti
348349
}
349350

350351

352+
353+
function contentToUuid(content:string):UUID {
354+
// Step 1: Create a SHA-1 hash of the content
355+
const hash = crypto.createHash('sha1')
356+
.update(content)
357+
.digest('hex'); // Outputs a 40-character hex string
358+
359+
// Step 2: Format the hash into a UUID-like structure
360+
// UUID format: 8-4-4-4-12 (e.g., 550e8400-e29b-41d4-a716-446655440000)
361+
const uuid = `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
362+
363+
return uuid as `${string}-${string}-${string}-${string}-${string}`;
364+
}
365+
351366
async function process_text(this: any, agentId: string, userName: string, name: string, sUserId: string | undefined,
352367
sRoomId: string, text:string, agents: Map<string, any>) {
353368
const roomId = stringToUuid(
@@ -415,7 +430,7 @@ async function process_text(this: any, agentId: string, userName: string, name:
415430
};
416431

417432
const memory: Memory = {
418-
id: stringToUuid(messageId + "-" + userId),
433+
id: contentToUuid(content.text), // stringToUuid(messageId + "-" + userId),
419434
...userMessage,
420435
agentId: runtime.agentId,
421436
userId,
@@ -424,6 +439,8 @@ async function process_text(this: any, agentId: string, userName: string, name:
424439
createdAt: Date.now(),
425440
};
426441

442+
443+
427444
await runtime.messageManager.addEmbeddingToMemory(memory);
428445
await runtime.messageManager.createMemory(memory);
429446

scripts/jsdoc-automation/src/AIService/Introspector.ts

-53
This file was deleted.

scripts/jsdoc-automation/src/DocumentationGenerator.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
PrModeFileChange,
1111
TodoItem,
1212
} from "./types/index.js";
13-
import type { GitManager } from "./GitManager.js";
13+
import type { IGitManager } from "./IGitManager.js"
1414
import fs from "fs";
1515
import type { Configuration } from "./Configuration.js";
1616
import path from "path";
@@ -49,7 +49,7 @@ export class DocumentationGenerator {
4949
public typeScriptParser: TypeScriptParser,
5050
public jsDocAnalyzer: JsDocAnalyzer,
5151
public jsDocGenerator: JsDocGenerator,
52-
public gitManager: GitManager,
52+
public gitManager: IGitManager,
5353
public configuration: Configuration,
5454
public aiService: AIService
5555
) {
@@ -75,7 +75,7 @@ export class DocumentationGenerator {
7575
if (pullNumber) {
7676
const prFiles =
7777
await this.gitManager.getFilesInPullRequest(pullNumber);
78-
fileChanges = prFiles.filter((file) => {
78+
fileChanges = prFiles.filter((file: { filename: string; }) => {
7979
// Convert PR file path (which is repo-relative) to absolute path
8080
const absolutePath = this.configuration.toAbsolutePath(
8181
file.filename
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
import type { PrModeFileChange, Repository } from "./types/index.js";
3+
4+
export interface CreatePullRequestOptions {
5+
title: string;
6+
body: string;
7+
head: string;
8+
base: string;
9+
labels?: string[];
10+
reviewers?: string[];
11+
}
12+
/**
13+
* Manages operations related to interacting with a Git repository using the GitHub API.
14+
*/
15+
export interface IGitManager {
16+
17+
getFilesInPullRequest(
18+
pullNumber: number
19+
): Promise<PrModeFileChange[]> ;
20+
21+
createBranch(
22+
branchName: string,
23+
baseBranch: string
24+
): Promise<void> ;
25+
26+
27+
commitFile(
28+
branchName: string,
29+
filePath: string,
30+
content: string,
31+
message: string
32+
): Promise<void> ;
33+
34+
createPullRequest(
35+
options: CreatePullRequestOptions
36+
): Promise<void> ;
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
import type {CreatePullRequestOptions } from "./IGitManager.js"
3+
import dotenv from "dotenv";
4+
import * as git from "simple-git";
5+
import type { PrModeFileChange, Repository } from "./types/index.js";
6+
7+
dotenv.config();
8+
9+
/**
10+
* Manages operations related to interacting with a Git repository using the GitHub API.
11+
*/
12+
export class LocalGitManager {
13+
git: git.SimpleGit;
14+
15+
16+
/**
17+
* Constructor for a class that initializes the Octokit instance with the provided Repository and checks if the GITHUB_ACCESS_TOKEN is set in the environment.
18+
* @param {Repository} repository - The repository instance to use
19+
* @throws {Error} Throws an error if the GITHUB_ACCESS_TOKEN is not set
20+
*/
21+
constructor(public repository: Repository) {
22+
23+
this.git = git.simpleGit();
24+
}
25+
26+
/**
27+
* Retrieve files in a specific pull request.
28+
* @param {number} pullNumber - The number of the pull request to get files from.
29+
* @returns {Promise<PrModeFileChange[]>} - Array of objects representing file changes in the pull request.
30+
*/
31+
public async getFilesInPullRequest(
32+
pullNumber: number
33+
): Promise<PrModeFileChange[]> {
34+
const log = await this.git.log({
35+
//from: "main",
36+
// to: `origin/pull/${pullNumber}/head`,
37+
maxCount: 100,
38+
});
39+
40+
console.log(log);
41+
return []
42+
// // return data.map((file: any) => ({
43+
// filename: file.filename,
44+
// status: file.status,
45+
// additions: file.additions,
46+
// deletions: file.deletions,
47+
// changes: file.changes,
48+
// contents_url: file.contents_url,
49+
// }));
50+
}
51+
52+
/**
53+
* Creates a new branch in the GitHub repository using the given branch name and base branch.
54+
*
55+
* @param {string} branchName - The name of the new branch to be created.
56+
* @param {string} baseBranch - The name of the branch to base the new branch off of.
57+
* @returns {Promise<void>} - A Promise that resolves when the branch is successfully created.
58+
*/
59+
public async createBranch(
60+
branchName: string,
61+
baseBranch: string
62+
): Promise<void> {
63+
64+
}
65+
66+
/**
67+
* Asynchronously commits a file to a repository using the GitHub API.
68+
*
69+
* @param {string} branchName - The name of the branch to commit the file to.
70+
* @param {string} filePath - The path of the file to commit.
71+
* @param {string} content - The content of the file to commit.
72+
* @param {string} message - The commit message.
73+
* @returns {Promise<void>} A promise that resolves when the file is successfully committed.
74+
*/
75+
public async commitFile(
76+
branchName: string,
77+
filePath: string,
78+
content: string,
79+
message: string
80+
): Promise<void> {
81+
82+
}
83+
84+
/**
85+
* Create a pull request using the provided options.
86+
* @param {CreatePullRequestOptions} options - The options for creating the pull request.
87+
* @returns {Promise<void>} A Promise that resolves once the pull request is successfully created.
88+
*/
89+
public async createPullRequest(
90+
options: CreatePullRequestOptions
91+
): Promise<void> {
92+
93+
}
94+
}

scripts/jsdoc-automation/src/PluginDocumentationGenerator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
EnvUsage,
66
} from "./types/index.js";
77
import type { AIService } from "./AIService/AIService.js";
8-
import type { GitManager } from "./GitManager.js";
8+
import type { IGitManager } from "./IGitManager.js";
99
import type { Configuration } from "./Configuration.js";
1010
import { FullDocumentationGenerator } from "./AIService/generators/FullDocumentationGenerator.js";
1111
import fs from "fs";
@@ -18,7 +18,7 @@ export class PluginDocumentationGenerator {
1818
private fullDocumentationGenerator: FullDocumentationGenerator;
1919
constructor(
2020
private aiService: AIService,
21-
private gitManager: GitManager,
21+
private gitManager: IGitManager,
2222
private configuration: Configuration
2323
) {
2424
this.fullDocumentationGenerator = new FullDocumentationGenerator(configuration);

0 commit comments

Comments
 (0)