@aigne/afs-json 1.0.0
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/CHANGELOG.md +18 -0
- package/LICENSE.md +93 -0
- package/README.md +304 -0
- package/lib/cjs/index.d.ts +108 -0
- package/lib/cjs/index.js +470 -0
- package/lib/cjs/package.json +3 -0
- package/lib/dts/index.d.ts +108 -0
- package/lib/esm/index.d.ts +108 -0
- package/lib/esm/index.js +466 -0
- package/lib/esm/package.json +3 -0
- package/package.json +70 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-01-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **afs:** add AFSJSON module support mount a JSON/yaml file to AFS ([6adedc6](https://github.com/AIGNE-io/aigne-framework/commit/6adedc624bedb1bc741da8534f2fbb41e1bc6623))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @aigne/afs bumped to 1.4.0-beta.10
|
|
16
|
+
* @aigne/core bumped to 1.72.0-beta.24
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @aigne/test-utils bumped to 0.5.69-beta.24
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Elastic License 2.0
|
|
2
|
+
|
|
3
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
8
|
+
|
|
9
|
+
## Copyright License
|
|
10
|
+
|
|
11
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
12
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
13
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
+
the limitations and conditions below.
|
|
15
|
+
|
|
16
|
+
## Limitations
|
|
17
|
+
|
|
18
|
+
You may not provide the software to third parties as a hosted or managed
|
|
19
|
+
service, where the service provides users with access to any substantial set of
|
|
20
|
+
the features or functionality of the software.
|
|
21
|
+
|
|
22
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
23
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
+
software that is protected by the license key.
|
|
25
|
+
|
|
26
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
27
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
28
|
+
to applicable law.
|
|
29
|
+
|
|
30
|
+
## Patents
|
|
31
|
+
|
|
32
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
33
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
34
|
+
sale, import and have imported the software, in each case subject to the
|
|
35
|
+
limitations and conditions in this license. This license does not cover any
|
|
36
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
37
|
+
the software. If you or your company make any written claim that the software
|
|
38
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
39
|
+
the software granted under these terms ends immediately. If your company makes
|
|
40
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
41
|
+
company.
|
|
42
|
+
|
|
43
|
+
## Notices
|
|
44
|
+
|
|
45
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
46
|
+
also gets a copy of these terms.
|
|
47
|
+
|
|
48
|
+
If you modify the software, you must include in any modified copies of the
|
|
49
|
+
software prominent notices stating that you have modified the software.
|
|
50
|
+
|
|
51
|
+
## No Other Rights
|
|
52
|
+
|
|
53
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
54
|
+
these terms.
|
|
55
|
+
|
|
56
|
+
## Termination
|
|
57
|
+
|
|
58
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
59
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
60
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
61
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
62
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
63
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
64
|
+
to terminate automatically and permanently.
|
|
65
|
+
|
|
66
|
+
## No Liability
|
|
67
|
+
|
|
68
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
69
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
70
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
71
|
+
legal claim.*
|
|
72
|
+
|
|
73
|
+
## Definitions
|
|
74
|
+
|
|
75
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
76
|
+
software the licensor makes available under these terms, including any portion
|
|
77
|
+
of it.
|
|
78
|
+
|
|
79
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
80
|
+
|
|
81
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
82
|
+
organization that you work for, plus all organizations that have control over,
|
|
83
|
+
are under the control of, or are under common control with that
|
|
84
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
85
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
86
|
+
otherwise. Control can be direct or indirect.
|
|
87
|
+
|
|
88
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
89
|
+
these terms.
|
|
90
|
+
|
|
91
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
92
|
+
|
|
93
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/README.md
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# @aigne/afs-json
|
|
2
|
+
|
|
3
|
+
AFS module for mounting JSON and YAML files as virtual file systems.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Mount JSON and YAML files to AFS virtual filesystem
|
|
8
|
+
- Navigate JSON/YAML structure as directories and files
|
|
9
|
+
- Support for nested objects and arrays
|
|
10
|
+
- Read-only and read-write modes
|
|
11
|
+
- Path-based access to JSON/YAML properties
|
|
12
|
+
- Automatic format detection based on file extension (.json, .yaml, .yml)
|
|
13
|
+
- Unified YAML parser supports both JSON and YAML formats
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @aigne/afs-json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Basic Usage
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { AFS } from "@aigne/afs";
|
|
27
|
+
import { AFSJSON } from "@aigne/afs-json";
|
|
28
|
+
|
|
29
|
+
const afs = new AFS();
|
|
30
|
+
|
|
31
|
+
// Mount a JSON file
|
|
32
|
+
afs.mount(
|
|
33
|
+
new AFSJSON({
|
|
34
|
+
name: "config",
|
|
35
|
+
jsonPath: "./config.json",
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Or mount a YAML file
|
|
40
|
+
afs.mount(
|
|
41
|
+
new AFSJSON({
|
|
42
|
+
name: "app-config",
|
|
43
|
+
jsonPath: "./config.yaml",
|
|
44
|
+
})
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Read the entire JSON/YAML
|
|
48
|
+
const result = await afs.read("/config/");
|
|
49
|
+
console.log(result.data?.content);
|
|
50
|
+
|
|
51
|
+
// Access nested properties as paths
|
|
52
|
+
const result2 = await afs.read("/config/database/host");
|
|
53
|
+
console.log(result2.data?.content); // "localhost"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### YAML File Support
|
|
57
|
+
|
|
58
|
+
The module automatically detects file format based on extension and uses the appropriate parser:
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
// Works with .yaml files
|
|
62
|
+
const yamlConfig = new AFSJSON({ jsonPath: "./app.yaml" });
|
|
63
|
+
|
|
64
|
+
// Works with .yml files
|
|
65
|
+
const ymlConfig = new AFSJSON({ jsonPath: "./settings.yml" });
|
|
66
|
+
|
|
67
|
+
// Works with .json files
|
|
68
|
+
const jsonConfig = new AFSJSON({ jsonPath: "./data.json" });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**YAML Example:**
|
|
72
|
+
|
|
73
|
+
```yaml
|
|
74
|
+
# config.yaml
|
|
75
|
+
database:
|
|
76
|
+
host: localhost
|
|
77
|
+
port: 5432
|
|
78
|
+
credentials:
|
|
79
|
+
username: admin
|
|
80
|
+
password: secret
|
|
81
|
+
features:
|
|
82
|
+
- auth
|
|
83
|
+
- api
|
|
84
|
+
- ui
|
|
85
|
+
version: "1.0.0"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
This YAML structure becomes:
|
|
89
|
+
```
|
|
90
|
+
/config/ # Root object
|
|
91
|
+
/config/database/ # Nested object (directory)
|
|
92
|
+
/config/database/host # String value (file): "localhost"
|
|
93
|
+
/config/database/port # Number value (file): 5432
|
|
94
|
+
/config/database/credentials/ # Nested object (directory)
|
|
95
|
+
/config/database/credentials/username # String value (file): "admin"
|
|
96
|
+
/config/features/ # Array (directory)
|
|
97
|
+
/config/features/0 # Array item (file): "auth"
|
|
98
|
+
/config/version # String value (file): "1.0.0"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Format Detection and Persistence:**
|
|
102
|
+
- Format is detected automatically from file extension (.json, .yaml, .yml)
|
|
103
|
+
- When writing to a YAML file, changes are saved in YAML format
|
|
104
|
+
- When writing to a JSON file, changes are saved in JSON format
|
|
105
|
+
- The YAML parser can read both JSON and YAML formats
|
|
106
|
+
|
|
107
|
+
### JSON File Structure Examples
|
|
108
|
+
|
|
109
|
+
#### Example 1: Simple nested structure
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"database": {
|
|
114
|
+
"host": "localhost",
|
|
115
|
+
"port": 5432,
|
|
116
|
+
"credentials": {
|
|
117
|
+
"username": "admin",
|
|
118
|
+
"password": "secret"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"features": ["auth", "api", "ui"],
|
|
122
|
+
"version": "1.0.0"
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
This structure becomes:
|
|
127
|
+
```
|
|
128
|
+
/config/ # Root object
|
|
129
|
+
/config/database/ # Nested object (directory)
|
|
130
|
+
/config/database/host # String value (file)
|
|
131
|
+
/config/database/port # Number value (file)
|
|
132
|
+
/config/database/credentials/ # Nested object (directory)
|
|
133
|
+
/config/features/ # Array (directory)
|
|
134
|
+
/config/features/0 # Array item (file)
|
|
135
|
+
/config/version # String value (file)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
#### Example 2: Array of objects
|
|
139
|
+
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"users": [
|
|
143
|
+
{
|
|
144
|
+
"name": "Alice",
|
|
145
|
+
"email": "alice@example.com",
|
|
146
|
+
"profile": {
|
|
147
|
+
"age": 30,
|
|
148
|
+
"city": "Beijing"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "Bob",
|
|
153
|
+
"email": "bob@example.com",
|
|
154
|
+
"profile": {
|
|
155
|
+
"age": 25,
|
|
156
|
+
"city": "Shanghai"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
This structure becomes:
|
|
164
|
+
```
|
|
165
|
+
/users/ # Array (directory)
|
|
166
|
+
/users/0/ # First user object (directory)
|
|
167
|
+
/users/0/name # String value (file): "Alice"
|
|
168
|
+
/users/0/email # String value (file): "alice@example.com"
|
|
169
|
+
/users/0/profile/ # Nested object (directory)
|
|
170
|
+
/users/0/profile/age # Number value (file): 30
|
|
171
|
+
/users/0/profile/city # String value (file): "Beijing"
|
|
172
|
+
/users/1/ # Second user object (directory)
|
|
173
|
+
/users/1/name # String value (file): "Bob"
|
|
174
|
+
/users/1/email # String value (file): "bob@example.com"
|
|
175
|
+
/users/1/profile/ # Nested object (directory)
|
|
176
|
+
/users/1/profile/age # Number value (file): 25
|
|
177
|
+
/users/1/profile/city # String value (file): "Shanghai"
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Working with array objects:**
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// Read a property from an array object
|
|
184
|
+
const { data } = await afs.read('/modules/users/0/name');
|
|
185
|
+
console.log(data?.content); // "Alice"
|
|
186
|
+
|
|
187
|
+
// Update a nested property in an array object
|
|
188
|
+
await afs.write('/modules/users/0/profile/age', { content: 31 });
|
|
189
|
+
|
|
190
|
+
// Add a new property to an array object
|
|
191
|
+
await afs.write('/modules/users/0/active', { content: true });
|
|
192
|
+
|
|
193
|
+
// List all properties of an array object
|
|
194
|
+
const result = await afs.list('/modules/users/0');
|
|
195
|
+
|
|
196
|
+
// Search within array objects
|
|
197
|
+
const results = await afs.search('/modules/users', 'Beijing');
|
|
198
|
+
|
|
199
|
+
// Delete from an array (shifts subsequent indices)
|
|
200
|
+
await afs.delete('/modules/users/1', { recursive: true });
|
|
201
|
+
// Now users/2 becomes users/1
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Options
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
interface AFSJSONOptions {
|
|
208
|
+
name?: string; // Module name (default: basename of jsonPath without extension)
|
|
209
|
+
jsonPath: string; // Path to JSON or YAML file
|
|
210
|
+
description?: string; // Module description
|
|
211
|
+
accessMode?: "readonly" | "readwrite"; // Access mode (default: "readwrite")
|
|
212
|
+
agentSkills?: boolean; // Enable agent skill scanning
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Note:** File format is automatically detected from the `jsonPath` extension:
|
|
217
|
+
- `.json` files are saved as JSON
|
|
218
|
+
- `.yaml` or `.yml` files are saved as YAML
|
|
219
|
+
|
|
220
|
+
### Read-only Mode
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
afs.mount(
|
|
224
|
+
new AFSJSON({
|
|
225
|
+
name: "readonly-config",
|
|
226
|
+
jsonPath: "./config.json",
|
|
227
|
+
accessMode: "readonly",
|
|
228
|
+
})
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
// Reading is allowed
|
|
232
|
+
await afs.read("/readonly-config/version");
|
|
233
|
+
|
|
234
|
+
// Writing will throw an error
|
|
235
|
+
await afs.write("/readonly-config/version", { content: "2.0.0" }); // Error!
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Writing to JSON/YAML
|
|
239
|
+
|
|
240
|
+
```typescript
|
|
241
|
+
// Mount a JSON file
|
|
242
|
+
afs.mount(
|
|
243
|
+
new AFSJSON({
|
|
244
|
+
name: "settings",
|
|
245
|
+
jsonPath: "./settings.json",
|
|
246
|
+
accessMode: "readwrite",
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
// Or mount a YAML file
|
|
251
|
+
afs.mount(
|
|
252
|
+
new AFSJSON({
|
|
253
|
+
name: "config",
|
|
254
|
+
jsonPath: "./config.yaml",
|
|
255
|
+
accessMode: "readwrite",
|
|
256
|
+
})
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
// Update a value
|
|
260
|
+
await afs.write("/settings/theme", { content: "dark" });
|
|
261
|
+
|
|
262
|
+
// Add a new property
|
|
263
|
+
await afs.write("/settings/notifications/email", { content: true });
|
|
264
|
+
|
|
265
|
+
// Changes are persisted to the file in its original format
|
|
266
|
+
// - JSON files are saved as JSON with 2-space indentation
|
|
267
|
+
// - YAML files are saved as YAML
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## API
|
|
271
|
+
|
|
272
|
+
### `list(path: string, options?: AFSListOptions): Promise<AFSListResult>`
|
|
273
|
+
|
|
274
|
+
List entries at a given path. Objects and arrays are treated as directories.
|
|
275
|
+
|
|
276
|
+
### `read(path: string, options?: AFSReadOptions): Promise<AFSReadResult>`
|
|
277
|
+
|
|
278
|
+
Read content at a given path. Returns the JSON/YAML value at that path.
|
|
279
|
+
|
|
280
|
+
### `write(path: string, entry: AFSWriteEntryPayload, options?: AFSWriteOptions): Promise<AFSWriteResult>`
|
|
281
|
+
|
|
282
|
+
Write content to a path. Updates are persisted to the file in its original format (JSON or YAML).
|
|
283
|
+
|
|
284
|
+
### `delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>`
|
|
285
|
+
|
|
286
|
+
Delete a property from the JSON/YAML structure.
|
|
287
|
+
|
|
288
|
+
### `search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>`
|
|
289
|
+
|
|
290
|
+
Search for values within the JSON/YAML structure.
|
|
291
|
+
|
|
292
|
+
## Use Cases
|
|
293
|
+
|
|
294
|
+
- **Configuration Management**: Mount config files (JSON/YAML) and access settings via paths
|
|
295
|
+
- **Data Exploration**: Navigate complex JSON/YAML structures as a file system
|
|
296
|
+
- **API Testing**: Mount API responses and explore structure
|
|
297
|
+
- **State Management**: Persist application state in JSON or YAML format
|
|
298
|
+
- **Documentation**: Access structured documentation from JSON/YAML files
|
|
299
|
+
- **Kubernetes Config**: Navigate and query YAML configuration files
|
|
300
|
+
- **CI/CD Pipelines**: Access and modify YAML pipeline configurations
|
|
301
|
+
|
|
302
|
+
## License
|
|
303
|
+
|
|
304
|
+
Elastic-2.0
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { AFSAccessMode, AFSDeleteOptions, AFSDeleteResult, AFSListOptions, AFSListResult, AFSModule, AFSModuleLoadParams, AFSReadOptions, AFSReadResult, AFSRenameOptions, AFSRenameResult, AFSSearchOptions, AFSSearchResult, AFSWriteEntryPayload, AFSWriteOptions, AFSWriteResult } from "@aigne/afs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export interface AFSJSONOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
jsonPath: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
/**
|
|
8
|
+
* Access mode for this module.
|
|
9
|
+
* - "readonly": Only read operations are allowed
|
|
10
|
+
* - "readwrite": All operations are allowed (default, unless agentSkills is enabled)
|
|
11
|
+
* @default "readwrite" (or "readonly" when agentSkills is true)
|
|
12
|
+
*/
|
|
13
|
+
accessMode?: AFSAccessMode;
|
|
14
|
+
/**
|
|
15
|
+
* Enable automatic agent skill scanning for this module.
|
|
16
|
+
* When enabled, defaults accessMode to "readonly" if not explicitly set.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
agentSkills?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* AFS module for mounting JSON/YAML files as virtual file systems.
|
|
23
|
+
*
|
|
24
|
+
* JSON/YAML objects are treated as directories, and properties/array items as files.
|
|
25
|
+
* Supports nested structures and path-based access to data values.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AFSJSON implements AFSModule {
|
|
28
|
+
options: AFSJSONOptions & {
|
|
29
|
+
cwd?: string;
|
|
30
|
+
};
|
|
31
|
+
static schema(): z.ZodObject<{
|
|
32
|
+
name: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
33
|
+
jsonPath: z.ZodString;
|
|
34
|
+
description: z.ZodType<string | undefined, z.ZodTypeDef, string | undefined>;
|
|
35
|
+
accessMode: z.ZodType<"readonly" | "readwrite" | undefined, z.ZodTypeDef, "readonly" | "readwrite" | undefined>;
|
|
36
|
+
agentSkills: z.ZodType<boolean | undefined, z.ZodTypeDef, boolean | undefined>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
jsonPath: string;
|
|
39
|
+
name?: string | undefined;
|
|
40
|
+
description?: string | undefined;
|
|
41
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
42
|
+
agentSkills?: boolean | undefined;
|
|
43
|
+
}, {
|
|
44
|
+
jsonPath: string;
|
|
45
|
+
name?: string | undefined;
|
|
46
|
+
description?: string | undefined;
|
|
47
|
+
accessMode?: "readonly" | "readwrite" | undefined;
|
|
48
|
+
agentSkills?: boolean | undefined;
|
|
49
|
+
}>;
|
|
50
|
+
static load({ filepath, parsed }: AFSModuleLoadParams): Promise<AFSJSON>;
|
|
51
|
+
private jsonData;
|
|
52
|
+
private fileStats;
|
|
53
|
+
private fileFormat;
|
|
54
|
+
constructor(options: AFSJSONOptions & {
|
|
55
|
+
cwd?: string;
|
|
56
|
+
});
|
|
57
|
+
name: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
accessMode: AFSAccessMode;
|
|
60
|
+
agentSkills?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Load JSON/YAML data from file. Called lazily on first access.
|
|
63
|
+
* Uses YAML parser which can handle both JSON and YAML formats.
|
|
64
|
+
*/
|
|
65
|
+
private ensureLoaded;
|
|
66
|
+
/**
|
|
67
|
+
* Save JSON/YAML data back to file. Only called in readwrite mode.
|
|
68
|
+
*/
|
|
69
|
+
private saveToFile;
|
|
70
|
+
/**
|
|
71
|
+
* Normalize path to ensure consistent format
|
|
72
|
+
*/
|
|
73
|
+
private normalizePath;
|
|
74
|
+
/**
|
|
75
|
+
* Get path segments from normalized path
|
|
76
|
+
*/
|
|
77
|
+
private getPathSegments;
|
|
78
|
+
/**
|
|
79
|
+
* Navigate to a value in the JSON structure using path segments
|
|
80
|
+
*/
|
|
81
|
+
private getValueAtPath;
|
|
82
|
+
/**
|
|
83
|
+
* Set a value in the JSON structure at the given path
|
|
84
|
+
*/
|
|
85
|
+
private setValueAtPath;
|
|
86
|
+
/**
|
|
87
|
+
* Delete a value from the JSON structure at the given path
|
|
88
|
+
*/
|
|
89
|
+
private deleteValueAtPath;
|
|
90
|
+
/**
|
|
91
|
+
* Check if a value is a "directory" (object or array with children)
|
|
92
|
+
*/
|
|
93
|
+
private isDirectory;
|
|
94
|
+
/**
|
|
95
|
+
* Get children of a directory value
|
|
96
|
+
*/
|
|
97
|
+
private getChildren;
|
|
98
|
+
/**
|
|
99
|
+
* Convert a JSON value to an AFSEntry
|
|
100
|
+
*/
|
|
101
|
+
private valueToAFSEntry;
|
|
102
|
+
list(path: string, options?: AFSListOptions): Promise<AFSListResult>;
|
|
103
|
+
read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult>;
|
|
104
|
+
write(path: string, entry: AFSWriteEntryPayload, _options?: AFSWriteOptions): Promise<AFSWriteResult>;
|
|
105
|
+
delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult>;
|
|
106
|
+
rename(oldPath: string, newPath: string, options?: AFSRenameOptions): Promise<AFSRenameResult>;
|
|
107
|
+
search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult>;
|
|
108
|
+
}
|