@aigne/example-afs-git 1.1.0-beta → 1.2.0-beta
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 +47 -3
- package/index.ts +9 -3
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -43,9 +43,12 @@ export OPENAI_API_KEY=YOUR_OPENAI_API_KEY
|
|
|
43
43
|
# Mount current Git repository (read-only by default)
|
|
44
44
|
npx -y @aigne/example-afs-git --interactive
|
|
45
45
|
|
|
46
|
-
# Mount a specific repository
|
|
46
|
+
# Mount a specific local repository
|
|
47
47
|
npx -y @aigne/example-afs-git --path /path/to/repo --interactive
|
|
48
48
|
|
|
49
|
+
# Mount a remote Git repository
|
|
50
|
+
npx -y @aigne/example-afs-git --url https://github.com/user/repo.git --interactive
|
|
51
|
+
|
|
49
52
|
# Ask a specific question
|
|
50
53
|
npx -y @aigne/example-afs-git --input "What files changed in the last commit on main?"
|
|
51
54
|
|
|
@@ -139,9 +142,12 @@ pnpm install
|
|
|
139
142
|
# Run with current repository (read-only by default)
|
|
140
143
|
pnpm start
|
|
141
144
|
|
|
142
|
-
# Run with a specific repository
|
|
145
|
+
# Run with a specific local repository
|
|
143
146
|
pnpm start --path /path/to/repo
|
|
144
147
|
|
|
148
|
+
# Run with a remote repository
|
|
149
|
+
pnpm start --url https://github.com/user/repo.git
|
|
150
|
+
|
|
145
151
|
# Run in interactive chat mode
|
|
146
152
|
pnpm start --interactive
|
|
147
153
|
|
|
@@ -159,13 +165,16 @@ pnpm start --access-mode readwrite --interactive
|
|
|
159
165
|
|
|
160
166
|
| Option | Description | Default | Example |
|
|
161
167
|
|--------|-------------|---------|---------|
|
|
162
|
-
| `--path` | Path to the git repository | Current directory | `--path /path/to/repo` |
|
|
168
|
+
| `--path` | Path to the local git repository | Current directory | `--path /path/to/repo` |
|
|
169
|
+
| `--url` | URL of remote git repository (clones automatically) | - | `--url https://github.com/user/repo.git` |
|
|
163
170
|
| `--branches` | Comma-separated list of branches to access | All branches | `--branches main,develop` |
|
|
164
171
|
| `--access-mode` | Access mode: `readonly` or `readwrite` | `readonly` | `--access-mode readwrite` |
|
|
165
172
|
| `--auto-commit` | Automatically commit changes (requires `readwrite` mode) | `false` | `--auto-commit` |
|
|
166
173
|
| `--interactive` | Run in interactive chat mode | `false` | `--interactive` |
|
|
167
174
|
| `--input` | Single question to ask | - | `--input "What branches exist?"` |
|
|
168
175
|
|
|
176
|
+
**Note:** Either `--path` or `--url` must be provided. When using `--url`, the repository is cloned to a temporary directory automatically.
|
|
177
|
+
|
|
169
178
|
## How It Works: 3 Simple Steps
|
|
170
179
|
|
|
171
180
|
### 1. Create AFSGit Module
|
|
@@ -173,11 +182,19 @@ pnpm start --access-mode readwrite --interactive
|
|
|
173
182
|
```typescript
|
|
174
183
|
import { AFSGit } from "@aigne/afs-git";
|
|
175
184
|
|
|
185
|
+
// Option 1: Mount a local repository
|
|
176
186
|
const afsGit = new AFSGit({
|
|
177
187
|
repoPath: process.cwd(),
|
|
178
188
|
accessMode: 'readonly', // or 'readwrite' for modifications
|
|
179
189
|
branches: ['main', 'develop'] // optional: limit branches
|
|
180
190
|
});
|
|
191
|
+
|
|
192
|
+
// Option 2: Clone and mount a remote repository
|
|
193
|
+
const afsGitRemote = new AFSGit({
|
|
194
|
+
remoteUrl: 'https://github.com/user/repo.git',
|
|
195
|
+
branches: ['main'], // single branch = optimized clone
|
|
196
|
+
depth: 1, // shallow clone (faster)
|
|
197
|
+
});
|
|
181
198
|
```
|
|
182
199
|
|
|
183
200
|
### 2. Mount It as an AFS Module
|
|
@@ -234,6 +251,9 @@ npx -y @aigne/example-afs-git --input "Find all TODO comments in the main branch
|
|
|
234
251
|
# Code review
|
|
235
252
|
npx -y @aigne/example-afs-git --input "Review the authentication code in src/auth/"
|
|
236
253
|
|
|
254
|
+
# Explore a remote repository
|
|
255
|
+
npx -y @aigne/example-afs-git --url https://github.com/octocat/Hello-World.git --input "What's in this repository?"
|
|
256
|
+
|
|
237
257
|
# Interactive mode - ask follow-up questions
|
|
238
258
|
npx -y @aigne/example-afs-git --interactive
|
|
239
259
|
```
|
|
@@ -248,6 +268,18 @@ npx -y @aigne/example-afs-git --interactive
|
|
|
248
268
|
|
|
249
269
|
## Use Cases
|
|
250
270
|
|
|
271
|
+
### Explore Remote Repositories
|
|
272
|
+
Analyze any public GitHub repository without cloning manually:
|
|
273
|
+
```typescript
|
|
274
|
+
const afs = new AFS()
|
|
275
|
+
.mount(new AFSGit({
|
|
276
|
+
remoteUrl: 'https://github.com/octocat/Hello-World.git',
|
|
277
|
+
branches: ['master'], // single branch for fast clone
|
|
278
|
+
depth: 1 // shallow clone
|
|
279
|
+
}));
|
|
280
|
+
// Ask: "What's the structure of this repository?"
|
|
281
|
+
```
|
|
282
|
+
|
|
251
283
|
### Code Review Assistance
|
|
252
284
|
Let AI help review code across branches:
|
|
253
285
|
```typescript
|
|
@@ -324,6 +356,18 @@ const afs = new AFS()
|
|
|
324
356
|
|
|
325
357
|
## Advanced Features
|
|
326
358
|
|
|
359
|
+
### Remote Repository Cloning
|
|
360
|
+
Automatically clone and mount remote repositories:
|
|
361
|
+
```typescript
|
|
362
|
+
const afsGit = new AFSGit({
|
|
363
|
+
remoteUrl: 'https://github.com/user/repo.git',
|
|
364
|
+
branches: ['main'], // Single branch = --single-branch optimization
|
|
365
|
+
depth: 1, // Shallow clone for faster setup
|
|
366
|
+
repoPath: './cache/repo' // Optional: specify clone location
|
|
367
|
+
});
|
|
368
|
+
// Without repoPath, clones to temp directory automatically
|
|
369
|
+
```
|
|
370
|
+
|
|
327
371
|
### Branch Filtering
|
|
328
372
|
Only expose specific branches:
|
|
329
373
|
```typescript
|
package/index.ts
CHANGED
|
@@ -11,7 +11,10 @@ const argv = yargs()
|
|
|
11
11
|
.option("path", {
|
|
12
12
|
type: "string",
|
|
13
13
|
describe: "Path to the git repo to mount",
|
|
14
|
-
|
|
14
|
+
})
|
|
15
|
+
.option("url", {
|
|
16
|
+
type: "string",
|
|
17
|
+
describe: "URL of the remote git repository",
|
|
15
18
|
})
|
|
16
19
|
.option("description", {
|
|
17
20
|
type: "string",
|
|
@@ -29,17 +32,20 @@ const argv = yargs()
|
|
|
29
32
|
default: false,
|
|
30
33
|
describe: "Automatically commit changes to the mounted repo",
|
|
31
34
|
})
|
|
32
|
-
.demandOption("path")
|
|
33
35
|
.strict(false)
|
|
34
36
|
.parseSync(process.argv);
|
|
35
37
|
|
|
38
|
+
// Default to current directory if neither path nor url is provided
|
|
39
|
+
const repoPath = argv.path || (argv.url ? undefined : ".");
|
|
40
|
+
|
|
36
41
|
const aigne = await loadAIGNEWithCmdOptions();
|
|
37
42
|
|
|
38
43
|
const afs = new AFS()
|
|
39
44
|
.mount(new AFSHistory({ storage: { url: ":memory:" } })) // In-memory history for this example
|
|
40
45
|
.mount(
|
|
41
46
|
new AFSGit({
|
|
42
|
-
repoPath: argv.
|
|
47
|
+
repoPath: argv.url ? undefined : repoPath,
|
|
48
|
+
remoteUrl: argv.url,
|
|
43
49
|
description: argv.description,
|
|
44
50
|
accessMode: argv.accessMode as AFSAccessMode,
|
|
45
51
|
autoCommit: argv.autoCommit,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-afs-git",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework with AFS git module",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/afs-git",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"yargs": "^18.0.0",
|
|
20
|
-
"@aigne/afs": "^1.4.0
|
|
21
|
-
"@aigne/afs-history": "^1.
|
|
22
|
-
"@aigne/afs-git": "^1.
|
|
23
|
-
"@aigne/
|
|
24
|
-
"@aigne/
|
|
20
|
+
"@aigne/afs": "^1.4.0",
|
|
21
|
+
"@aigne/afs-history": "^1.3.0-beta",
|
|
22
|
+
"@aigne/afs-git": "^1.2.0-beta",
|
|
23
|
+
"@aigne/core": "^1.73.0-beta",
|
|
24
|
+
"@aigne/cli": "^1.60.0-beta"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/bun": "^1.2.22",
|
|
28
|
-
"@aigne/test-utils": "^0.5.
|
|
28
|
+
"@aigne/test-utils": "^0.5.70-beta"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"start": "bun run index.ts",
|