Skip to content

Commit 28ea36d

Browse files
πŸ‘Œ IMPROVE: Deployment and memory workflows (#45)
* πŸ‘Œ IMPROVE: Allow deployment even if no pipes * πŸ‘Œ IMPROVE: Memory create logs * πŸ‘Œ IMPROVE: Uncommitted changes command * πŸ‘Œ IMPROVE: contributing guide
1 parent c860fb3 commit 28ea36d

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

β€ŽCONTRIBUTING.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ grlz 'new version'
1313
pnpm release
1414
pnpm update-examples
1515
```
16+
1617
## Testing locally
1718

1819
To test the changes locally, you can run the following command:
1920

20-
- Use an example like the Next.js one
21+
- Navigate to an example's folder like the Next.js one in `examples/nextjs`.
22+
2123
- Change the `package.json` to point to the local package for `baseai` and `@baseai/core` packages.
2224

2325
```json
@@ -31,9 +33,26 @@ To test the changes locally, you can run the following command:
3133
}
3234
```
3335

34-
Now run in the root `pnpm clean-all && pnpm install` and then run `pnpm dev` to start the development server.
36+
- Now run in the root:
37+
38+
```bash
39+
pnpm clean-all && pnpm install
40+
```
41+
42+
Then run the development server:
43+
44+
```bash
45+
pnpm dev
46+
```
47+
48+
- Run the BaseAI local server from the example's folder without using the @latest flag:
49+
50+
```bash
51+
# In examples/nextjs folder
52+
npx baseai dev
53+
```
3554

36-
By doing this, the Next.js app will use the local packages instead of the published ones.
55+
By doing this, the Next.js example will use the local packages instead of the published ones.
3756

3857
---
3958

β€Žpackages/baseai/src/deploy/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ async function deploy({
5454
const pipes = await readPipesDirectory({ spinner, pipesDir });
5555
if (!pipes) {
5656
p.outro(
57-
`No pipes found. Skipping deployment. \nAdd a pipe by running: ${cyan(`npx baseai@latest pipe`)} command`
57+
`No pipes found. Skipping deployment of pipes. \nAdd a pipe by running: ${cyan(`npx baseai@latest pipe`)} command`
5858
);
59-
process.exit(1);
6059
}
6160

6261
const memoryDir = path.join(buildDir, 'memory');
@@ -85,8 +84,7 @@ async function deploy({
8584
overwrite
8685
});
8786
}
88-
89-
await deployPipes({ spinner, pipes, pipesDir, account });
87+
if (pipes) await deployPipes({ spinner, pipes, pipesDir, account });
9088

9189
p.outro(
9290
heading({ text: 'DEPLOYED', sub: 'successfully', green: true })
@@ -100,7 +98,7 @@ async function deploy({
10098

10199
p.log.info(
102100
`${dim(`Successfully deployed:`)}
103-
${dim(`- ${green(pipes?.length)} pipe${pipes.length !== 1 ? 's' : ''}
101+
${dim(`- ${green(pipes?.length)} pipe${pipes?.length !== 1 ? 's' : ''}
104102
- ${green(tools?.length ?? 0)} tool${tools?.length !== 1 ? 's' : ''}
105103
- ${green(memory?.length ?? 0)} memory${memory?.length !== 1 ? 'sets' : ''}`)}`
106104
);

β€Žpackages/baseai/src/memory/create.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const execAsync = promisify(exec);
1616

1717
const defaultConfig = {
1818
name: 'ai-agent-memory',
19-
description: 'My list of docs for an AI agent pipe'
19+
description: 'My list of docs as memory for an AI agent pipe'
2020
};
2121

2222
const MEMORY_CONSTANTS = {
@@ -45,7 +45,7 @@ export async function createMemory() {
4545
}),
4646
description: () =>
4747
p.text({
48-
message: 'Description of the pipe',
48+
message: 'Description of the memory',
4949
placeholder: defaultConfig.description
5050
}),
5151
useGitRepo: () =>
@@ -78,6 +78,7 @@ export async function createMemory() {
7878
memoryFilesDir = (await p.text({
7979
message:
8080
'Enter the path to the directory to track (relative to current directory):',
81+
initialValue: '.',
8182
validate: value => {
8283
if (!value.trim()) {
8384
return 'The path cannot be empty.';
@@ -174,7 +175,7 @@ export default ${memoryNameCamelCase};
174175
p.outro(
175176
heading({
176177
text: memoryNameCamelCase,
177-
sub: `created as a new pipe \n ${dim(figures.pointer)} ${dimItalic(` ${filePath}`)}`,
178+
sub: `created as a new memory \n ${dim(figures.pointer)} ${dimItalic(` ${filePath}`)}`,
178179
green: true
179180
})
180181
);

β€Žpackages/baseai/src/utils/memory/git-sync/handle-git-sync-memories.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ export async function handleGitSyncMemories({
2424

2525
// Check for uncommitted changes
2626
try {
27-
execSync('git diff-index --quiet HEAD --');
27+
const hasChanges = execSync('git status --porcelain').toString().trim();
28+
if (hasChanges) {
29+
p.log.error(
30+
`There are uncommitted changes in the Git repository for ${isEmbed ? 'embedding' : 'deploying'} git-synced memory "${memoryName}".`
31+
);
32+
p.log.info(
33+
`Please commit these changes before ${isEmbed ? 'embedding' : 'deploying'}. Aborting.`
34+
);
35+
process.exit(1);
36+
}
2837
} catch (error) {
2938
p.log.error(
30-
`There are uncommitted changes in the Git repository for ${isEmbed ? 'embedding' : 'deploying'} git-synced memory "${memoryName}".`
31-
);
32-
p.log.info(
33-
`Please commit these changes before ${isEmbed ? 'embedding' : 'deploying'}. Aborting.`
39+
`Failed to check if there are uncommitted changes: ${error}`
3440
);
3541
process.exit(1);
3642
}

0 commit comments

Comments
Β (0)