@aigne/example-afs-git 1.1.0 → 1.74.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 CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  <p align="center">
4
4
  <picture>
5
- <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo-dark.svg" media="(prefers-color-scheme: dark)">
6
- <source srcset="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" media="(prefers-color-scheme: light)">
7
- <img src="https://raw.githubusercontent.com/AIGNE-io/aigne-framework/main/logo.svg" alt="AIGNE Logo" width="400" />
5
+ <source srcset="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/logo-dark.svg" media="(prefers-color-scheme: dark)">
6
+ <source srcset="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/logo.svg" media="(prefers-color-scheme: light)">
7
+ <img src="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/logo.svg" alt="AIGNE Logo" width="400" />
8
8
  </picture>
9
9
  </p>
10
10
 
11
- This example demonstrates how to create a chatbot that can interact with Git repositories using the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [AIGNE CLI](https://github.com/AIGNE-io/aigne-framework/blob/main/packages/cli/README.md). The example utilizes the `AFSGit` module to provide Git repository access to AI agents through the **AIGNE File System (AFS)** interface.
11
+ This example demonstrates how to create a chatbot that can interact with Git repositories using the [AIGNE Framework](https://github.com/ArcBlock/aigne-framework) and [AIGNE CLI](https://github.com/ArcBlock/aigne-framework/blob/main/packages/cli/README.md). The example utilizes the `AFSGit` module to provide Git repository access to AI agents through the **AIGNE File System (AFS)** interface.
12
12
 
13
13
  **AIGNE File System (AFS)** is a virtual file system abstraction that provides AI agents with unified access to various storage backends. For comprehensive documentation, see [AFS Documentation](../../afs/README.md).
14
14
 
@@ -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
 
@@ -122,7 +125,7 @@ The `aigne observe` command starts a local web server to monitor and analyze age
122
125
  ### Clone the Repository
123
126
 
124
127
  ```bash
125
- git clone https://github.com/AIGNE-io/aigne-framework
128
+ git clone https://github.com/ArcBlock/aigne-framework
126
129
  ```
127
130
 
128
131
  ### Install Dependencies
@@ -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.test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "bun:test";
2
- import { runExampleTest } from "@aigne/test-utils/run-example-test.js";
2
+ import { runExampleTest } from "@aigne/utils/test-utils/run-example-test";
3
3
 
4
4
  test(
5
5
  "should successfully run the chatbot",
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
- default: ".",
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.path,
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,14 +1,21 @@
1
1
  {
2
2
  "name": "@aigne/example-afs-git",
3
- "version": "1.1.0",
3
+ "version": "1.74.0-beta",
4
4
  "description": "A demonstration of using AIGNE Framework with AFS git module",
5
- "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
6
- "homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/afs-git",
7
5
  "license": "MIT",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
10
+ "homepage": "https://www.aigne.io/framework",
8
11
  "repository": {
9
12
  "type": "git",
10
- "url": "git+https://github.com/AIGNE-io/aigne-framework"
13
+ "url": "git+https://github.com/ArcBlock/aigne-framework"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/ArcBlock/aigne-framework/issues"
11
17
  },
18
+ "type": "module",
12
19
  "bin": "index.ts",
13
20
  "files": [
14
21
  ".env.local.example",
@@ -16,16 +23,17 @@
16
23
  "README.md"
17
24
  ],
18
25
  "dependencies": {
26
+ "@aigne/afs": "^1.11.0-beta.1",
27
+ "@aigne/afs-git": "^1.11.0-beta.1",
19
28
  "yargs": "^18.0.0",
20
- "@aigne/afs": "^1.4.0",
21
- "@aigne/afs-history": "^1.2.0",
22
- "@aigne/afs-git": "^1.1.0",
23
- "@aigne/core": "^1.72.0",
24
- "@aigne/cli": "^1.59.0"
29
+ "@aigne/afs-history": "^1.74.0-beta",
30
+ "@aigne/cli": "^1.74.0-beta",
31
+ "@aigne/core": "^1.74.0-beta"
25
32
  },
26
33
  "devDependencies": {
27
34
  "@types/bun": "^1.2.22",
28
- "@aigne/test-utils": "^0.5.69"
35
+ "@aigne/typescript-config": "0.0.0",
36
+ "@aigne/utils": "^1.74.0-beta"
29
37
  },
30
38
  "scripts": {
31
39
  "start": "bun run index.ts",