@aigne/afs-json 1.11.0-beta → 1.11.0-beta.2
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/LICENSE.md +17 -84
- package/README.md +0 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/LICENSE.md
CHANGED
|
@@ -1,93 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
# Proprietary License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. Unauthorized copying, modification, distribution, or use of
|
|
7
|
+
this Software, via any medium, is strictly prohibited.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
The Software is provided for internal use only within ArcBlock, Inc. and its
|
|
10
|
+
authorized affiliates.
|
|
8
11
|
|
|
9
|
-
##
|
|
12
|
+
## No License Granted
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
available, and prepare derivative works of the software, in each case subject to
|
|
14
|
-
the limitations and conditions below.
|
|
14
|
+
No license, express or implied, is granted to any party for any purpose.
|
|
15
|
+
All rights are reserved by ArcBlock, Inc.
|
|
15
16
|
|
|
16
|
-
##
|
|
17
|
+
## Public Artifact Distribution
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
Portions of this Software may be released publicly under separate open-source
|
|
20
|
+
licenses (such as MIT License) through designated public repositories. Such
|
|
21
|
+
public releases are governed by their respective licenses and do not affect
|
|
22
|
+
the proprietary nature of this repository.
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
in the software, and you may not remove or obscure any functionality in the
|
|
24
|
-
software that is protected by the license key.
|
|
24
|
+
## Contact
|
|
25
25
|
|
|
26
|
-
|
|
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.
|
|
26
|
+
For licensing inquiries, contact: legal@arcblock.io
|
package/README.md
CHANGED
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UA4BiB,cAAA;EAAA,IAAA;EAAA,QAAA;EAAA,WAAA;EAAA;AAuCjB;;;;;EAvCiB,UAAA,GAUF,aAAA;EAAA;AA6Bf;;;;EA7Be,WAAA;AAAA;AAAA;AA6Bf;;;;;AA7Be,cA6BF,OAAA,YAAmB,SAAA;EAAA,OAAA,EAiBF,cAAA;IAAA,GAAA;EAAA;EAAA,OAAA,OAAA,GAhBf,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;IAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAI2B,mBAAA,GAAmB,OAAA,CAAA,OAAA;EAAA,QAAA,QAAA;EAAA,QAAA,SAAA;EAAA,QAAA,UAAA;EAAA,YAAA,OAAA,EAY/B,cAAA;IAAA,GAAA;EAAA;EAAA,IAAA;EAAA,WAAA;EAAA,UA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2BpD,gBAAA,GACT,OAAA,CAAQ,eAAA;EAAA,OAAA,IAAA,UAAA,KAAA,UAAA,OAAA,GA+ByC,gBAAA,GAAmB,OAAA,CAAQ,eAAA;AAAA"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UA4BiB,cAAA;EAAA,IAAA;EAAA,QAAA;EAAA,WAAA;EAAA;AAuCjB;;;;;EAvCiB,UAAA,GAUF,aAAA;EAAA;AA6Bf;;;;EA7Be,WAAA;AAAA;AAAA;AA6Bf;;;;;AA7Be,cA6BF,OAAA,YAAmB,SAAA;EAAA,OAAA,EAiBF,cAAA;IAAA,GAAA;EAAA;EAAA,OAAA,OAAA,GAhBf,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;IAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAI2B,mBAAA,GAAmB,OAAA,CAAA,OAAA;EAAA,QAAA,QAAA;EAAA,QAAA,SAAA;EAAA,QAAA,UAAA;EAAA,YAAA,OAAA,EAY/B,cAAA;IAAA,GAAA;EAAA;EAAA,IAAA;EAAA,WAAA;EAAA,UAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;UA4BiB,cAAA;EAAA,IAAA;EAAA,QAAA;EAAA,WAAA;EAAA;AAuCjB;;;;;EAvCiB,UAAA,GAUF,aAAA;EAAA;AA6Bf;;;;EA7Be,WAAA;AAAA;AAAA;AA6Bf;;;;;AA7Be,cA6BF,OAAA,YAAmB,SAAA;EAAA,OAAA,EAiBF,cAAA;IAAA,GAAA;EAAA;EAAA,OAAA,OAAA,GAhBf,CAAA,CAAA,UAAA,CAAA,CAAA,CAAA,SAAA;IAAA,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;KAI2B,mBAAA,GAAmB,OAAA,CAAA,OAAA;EAAA,QAAA,QAAA;EAAA,QAAA,SAAA;EAAA,QAAA,UAAA;EAAA,YAAA,OAAA,EAY/B,cAAA;IAAA,GAAA;EAAA;EAAA,IAAA;EAAA,WAAA;EAAA,UAAA,EAuChB,aAAA;EAAA,WAAA;EAAA;;;;EAAA,QAAA,YAAA;EAAA;;;EAAA,QAAA,UAAA;EAAA;;;EAAA,QAAA,aAAA;EAAA;;;EAAA,QAAA,eAAA;EAAA;;;EAAA,QAAA,cAAA;EAAA;;;EAAA,QAAA,cAAA;EAAA;;;EAAA,QAAA,iBAAA;EAAA;;;EAAA,QAAA,WAAA;EAAA;;;EAAA,QAAA,WAAA;EAAA;;;EAAA,QAAA,eAAA;EAAA,KAAA,IAAA,UAAA,OAAA,GAkPuB,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAAA,KAAA,IAAA,UAAA,QAAA,GAmExB,cAAA,GAAiB,OAAA,CAAQ,aAAA;EAAA,MAAA,IAAA,UAAA,KAAA,EAmBpD,oBAAA,EAAA,QAAA,GACI,eAAA,GACV,OAAA,CAAQ,cAAA;EAAA,OAAA,IAAA,UAAA,OAAA,GAqC0B,gBAAA,GAAmB,OAAA,CAAQ,eAAA;EAAA,OAAA,OAAA,UAAA,OAAA,UAAA,OAAA,GA2BpD,gBAAA,GACT,OAAA,CAAQ,eAAA;EAAA,OAAA,IAAA,UAAA,KAAA,UAAA,OAAA,GA+ByC,gBAAA,GAAmB,OAAA,CAAQ,eAAA;AAAA"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["parseYAML","stringifyYAML"],"sources":["../src/index.ts"],"sourcesContent":["import { readFile, stat, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, extname, isAbsolute, join } from \"node:path\";\nimport type {\n AFSAccessMode,\n AFSDeleteOptions,\n AFSDeleteResult,\n AFSEntry,\n AFSListOptions,\n AFSListResult,\n AFSModule,\n AFSModuleClass,\n AFSModuleLoadParams,\n AFSReadOptions,\n AFSReadResult,\n AFSRenameOptions,\n AFSRenameResult,\n AFSSearchOptions,\n AFSSearchResult,\n AFSWriteEntryPayload,\n AFSWriteOptions,\n AFSWriteResult,\n} from \"@aigne/afs\";\nimport { camelize, optionalize, zodParse } from \"@aigne/afs/utils/zod\";\nimport { parse as parseYAML, stringify as stringifyYAML } from \"yaml\";\nimport { z } from \"zod\";\n\nconst LIST_MAX_LIMIT = 1000;\n\nexport interface AFSJSONOptions {\n name?: string;\n jsonPath: string;\n description?: string;\n /**\n * Access mode for this module.\n * - \"readonly\": Only read operations are allowed\n * - \"readwrite\": All operations are allowed (default, unless agentSkills is enabled)\n * @default \"readwrite\" (or \"readonly\" when agentSkills is true)\n */\n accessMode?: AFSAccessMode;\n /**\n * Enable automatic agent skill scanning for this module.\n * When enabled, defaults accessMode to \"readonly\" if not explicitly set.\n * @default false\n */\n agentSkills?: boolean;\n}\n\nconst afsJSONOptionsSchema = camelize(\n z.object({\n name: optionalize(z.string()),\n jsonPath: z.string().describe(\"The path to the JSON/YAML file to mount\"),\n description: optionalize(z.string().describe(\"A description of the JSON module\")),\n accessMode: optionalize(\n z.enum([\"readonly\", \"readwrite\"]).describe(\"Access mode for this module\"),\n ),\n agentSkills: optionalize(\n z.boolean().describe(\"Enable automatic agent skill scanning for this module\"),\n ),\n }),\n);\n\n/**\n * AFS module for mounting JSON/YAML files as virtual file systems.\n *\n * JSON/YAML objects are treated as directories, and properties/array items as files.\n * Supports nested structures and path-based access to data values.\n */\nexport class AFSJSON implements AFSModule {\n static schema() {\n return afsJSONOptionsSchema;\n }\n\n static async load({ filepath, parsed }: AFSModuleLoadParams) {\n const valid = await AFSJSON.schema().parseAsync(parsed);\n return new AFSJSON({ ...valid, cwd: dirname(filepath) });\n }\n\n private jsonData: any = null;\n private fileStats: {\n birthtime?: Date;\n mtime?: Date;\n } = {};\n private fileFormat: \"json\" | \"yaml\" = \"json\";\n\n constructor(public options: AFSJSONOptions & { cwd?: string }) {\n zodParse(afsJSONOptionsSchema, options);\n\n let jsonPath: string;\n\n // biome-ignore lint/suspicious/noTemplateCurlyInString: explicitly replace ${CWD}\n jsonPath = options.jsonPath.replaceAll(\"${CWD}\", process.cwd());\n if (jsonPath.startsWith(\"~/\")) {\n jsonPath = join(process.env.HOME || \"\", jsonPath.slice(2));\n }\n if (!isAbsolute(jsonPath)) {\n jsonPath = join(options.cwd || process.cwd(), jsonPath);\n }\n\n // Detect file format based on extension for writing\n const ext = extname(jsonPath).toLowerCase();\n this.fileFormat = ext === \".yaml\" || ext === \".yml\" ? \"yaml\" : \"json\";\n\n // Extract name without extension\n const extensions = [\".json\", \".yaml\", \".yml\"];\n let name = basename(jsonPath);\n for (const e of extensions) {\n if (name.endsWith(e)) {\n name = name.slice(0, -e.length);\n break;\n }\n }\n\n this.name = options.name || name || \"json\";\n this.description = options.description;\n this.agentSkills = options.agentSkills;\n // Default to \"readwrite\", but \"readonly\" if agentSkills is enabled\n this.accessMode = options.accessMode ?? (options.agentSkills ? \"readonly\" : \"readwrite\");\n this.options.jsonPath = jsonPath;\n }\n\n name: string;\n\n description?: string;\n\n accessMode: AFSAccessMode;\n\n agentSkills?: boolean;\n\n /**\n * Load JSON/YAML data from file. Called lazily on first access.\n * Uses YAML parser which can handle both JSON and YAML formats.\n */\n private async ensureLoaded(): Promise<void> {\n if (this.jsonData !== null) return;\n\n try {\n const stats = await stat(this.options.jsonPath);\n this.fileStats = {\n birthtime: stats.birthtime,\n mtime: stats.mtime,\n };\n\n const content = await readFile(this.options.jsonPath, \"utf8\");\n\n // YAML parser can handle both JSON and YAML formats\n this.jsonData = parseYAML(content);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n // File doesn't exist yet, start with empty object\n this.jsonData = {};\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Save JSON/YAML data back to file. Only called in readwrite mode.\n */\n private async saveToFile(): Promise<void> {\n let content: string;\n\n // Serialize based on file format\n if (this.fileFormat === \"yaml\") {\n content = stringifyYAML(this.jsonData);\n } else {\n content = JSON.stringify(this.jsonData, null, 2);\n }\n\n await writeFile(this.options.jsonPath, content, \"utf8\");\n\n // Update file stats\n const stats = await stat(this.options.jsonPath);\n this.fileStats = {\n birthtime: this.fileStats.birthtime || stats.birthtime,\n mtime: stats.mtime,\n };\n }\n\n /**\n * Normalize path to ensure consistent format\n */\n private normalizePath(path: string): string {\n let normalized = path.startsWith(\"/\") ? path : `/${path}`;\n if (normalized.length > 1 && normalized.endsWith(\"/\")) {\n normalized = normalized.slice(0, -1);\n }\n return normalized;\n }\n\n /**\n * Get path segments from normalized path\n */\n private getPathSegments(path: string): string[] {\n const normalized = this.normalizePath(path);\n if (normalized === \"/\") return [];\n return normalized.slice(1).split(\"/\");\n }\n\n /**\n * Navigate to a value in the JSON structure using path segments\n */\n private getValueAtPath(data: any, segments: string[]): any {\n let current = data;\n for (const segment of segments) {\n if (current == null) return undefined;\n\n // Handle array indices\n if (Array.isArray(current)) {\n const index = Number.parseInt(segment, 10);\n if (Number.isNaN(index) || index < 0 || index >= current.length) {\n return undefined;\n }\n current = current[index];\n } else if (typeof current === \"object\") {\n current = current[segment as keyof typeof current];\n } else {\n return undefined;\n }\n }\n return current;\n }\n\n /**\n * Set a value in the JSON structure at the given path\n */\n private setValueAtPath(data: any, segments: string[], value: any): void {\n if (segments.length === 0) {\n throw new Error(\"Cannot set value at root path\");\n }\n\n let current = data;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i]!;\n const nextSegment = segments[i + 1]!;\n\n if (Array.isArray(current)) {\n const index = Number.parseInt(segment, 10);\n if (Number.isNaN(index) || index < 0) {\n throw new Error(`Invalid array index: ${segment}`);\n }\n\n // Extend array if necessary\n while (current.length <= index) {\n current.push(null);\n }\n\n if (current[index] == null) {\n // Determine if next level should be array or object\n const isNextArray = !Number.isNaN(Number.parseInt(nextSegment, 10));\n current[index] = isNextArray ? [] : {};\n }\n current = current[index];\n } else if (typeof current === \"object\") {\n if (current[segment] == null) {\n // Determine if next level should be array or object\n const isNextArray = !Number.isNaN(Number.parseInt(nextSegment, 10));\n current[segment] = isNextArray ? [] : {};\n }\n current = current[segment];\n } else {\n throw new Error(\n `Cannot set property on non-object at ${segments.slice(0, i + 1).join(\"/\")}`,\n );\n }\n }\n\n const lastSegment = segments[segments.length - 1]!;\n if (Array.isArray(current)) {\n const index = Number.parseInt(lastSegment, 10);\n if (Number.isNaN(index) || index < 0) {\n throw new Error(`Invalid array index: ${lastSegment}`);\n }\n current[index] = value;\n } else if (typeof current === \"object\") {\n current[lastSegment] = value;\n } else {\n throw new Error(\"Cannot set property on non-object\");\n }\n }\n\n /**\n * Delete a value from the JSON structure at the given path\n */\n private deleteValueAtPath(data: any, segments: string[]): boolean {\n if (segments.length === 0) {\n throw new Error(\"Cannot delete root path\");\n }\n\n let current = data;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i]!;\n\n if (Array.isArray(current)) {\n const index = Number.parseInt(segment, 10);\n if (Number.isNaN(index) || index < 0 || index >= current.length) {\n return false;\n }\n current = current[index];\n } else if (typeof current === \"object\") {\n if (!(segment in current)) return false;\n current = current[segment];\n } else {\n return false;\n }\n }\n\n const lastSegment = segments[segments.length - 1]!;\n if (Array.isArray(current)) {\n const index = Number.parseInt(lastSegment, 10);\n if (Number.isNaN(index) || index < 0 || index >= current.length) {\n return false;\n }\n current.splice(index, 1);\n return true;\n }\n if (typeof current === \"object\") {\n if (!(lastSegment in current)) return false;\n delete current[lastSegment];\n return true;\n }\n return false;\n }\n\n /**\n * Check if a value is a \"directory\" (object or array with children)\n */\n private isDirectory(value: any): boolean {\n if (Array.isArray(value)) return true;\n if (typeof value === \"object\" && value !== null) return true;\n return false;\n }\n\n /**\n * Get children of a directory value\n */\n private getChildren(value: any): Array<{ key: string; value: any }> {\n if (Array.isArray(value)) {\n return value.map((item, index) => ({ key: String(index), value: item }));\n }\n if (typeof value === \"object\" && value !== null) {\n return Object.entries(value).map(([key, val]) => ({ key, value: val }));\n }\n return [];\n }\n\n /**\n * Convert a JSON value to an AFSEntry\n */\n private valueToAFSEntry(path: string, value: any): AFSEntry {\n const isDir = this.isDirectory(value);\n const children = isDir ? this.getChildren(value) : [];\n\n return {\n id: path,\n path: path,\n content: isDir ? undefined : value,\n createdAt: this.fileStats.birthtime,\n updatedAt: this.fileStats.mtime,\n metadata: {\n type: isDir ? \"directory\" : \"file\",\n childrenCount: isDir ? children.length : undefined,\n },\n };\n }\n\n async list(path: string, options?: AFSListOptions): Promise<AFSListResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n const maxChildren =\n typeof options?.maxChildren === \"number\" ? options.maxChildren : Number.MAX_SAFE_INTEGER;\n const maxDepth = options?.maxDepth ?? 1;\n\n const segments = this.getPathSegments(normalizedPath);\n const value = this.getValueAtPath(this.jsonData, segments);\n\n if (value === undefined) {\n throw new Error(`Path not found: ${normalizedPath}`);\n }\n\n const entries: AFSEntry[] = [];\n\n interface QueueItem {\n path: string;\n value: any;\n depth: number;\n }\n\n const queue: QueueItem[] = [{ path: normalizedPath, value, depth: 0 }];\n\n while (queue.length > 0) {\n const item = queue.shift();\n if (!item) break;\n\n const { path: itemPath, value: itemValue, depth } = item;\n\n const entry = this.valueToAFSEntry(itemPath, itemValue);\n entries.push(entry);\n\n if (entries.length >= limit) {\n if (entry.metadata) {\n entry.metadata.childrenTruncated = true;\n }\n break;\n }\n\n // Process children if within depth limit\n if (this.isDirectory(itemValue) && depth < maxDepth) {\n const children = this.getChildren(itemValue);\n const childrenToProcess =\n children.length > maxChildren ? children.slice(0, maxChildren) : children;\n const isTruncated = childrenToProcess.length < children.length;\n\n if (isTruncated && entry.metadata) {\n entry.metadata.childrenTruncated = true;\n }\n\n for (const child of childrenToProcess) {\n const childPath = itemPath === \"/\" ? `/${child.key}` : `${itemPath}/${child.key}`;\n queue.push({\n path: childPath,\n value: child.value,\n depth: depth + 1,\n });\n }\n }\n }\n\n return { data: entries };\n }\n\n async read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const segments = this.getPathSegments(normalizedPath);\n const value = this.getValueAtPath(this.jsonData, segments);\n\n if (value === undefined) {\n return {\n data: undefined,\n message: `Path not found: ${normalizedPath}`,\n };\n }\n\n return { data: this.valueToAFSEntry(normalizedPath, value) };\n }\n\n async write(\n path: string,\n entry: AFSWriteEntryPayload,\n _options?: AFSWriteOptions,\n ): Promise<AFSWriteResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const segments = this.getPathSegments(normalizedPath);\n\n // Set the value in the JSON structure\n this.setValueAtPath(this.jsonData, segments, entry.content);\n\n // Save back to file\n await this.saveToFile();\n\n const newValue = this.getValueAtPath(this.jsonData, segments);\n const isDir = this.isDirectory(newValue);\n const children = isDir ? this.getChildren(newValue) : [];\n\n const writtenEntry: AFSEntry = {\n id: normalizedPath,\n path: normalizedPath,\n content: entry.content,\n summary: entry.summary,\n description: entry.description,\n createdAt: this.fileStats.birthtime,\n updatedAt: this.fileStats.mtime,\n metadata: {\n ...entry.metadata,\n type: isDir ? \"directory\" : \"file\",\n childrenCount: isDir ? children.length : undefined,\n },\n userId: entry.userId,\n sessionId: entry.sessionId,\n linkTo: entry.linkTo,\n };\n\n return { data: writtenEntry };\n }\n\n async delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const segments = this.getPathSegments(normalizedPath);\n const value = this.getValueAtPath(this.jsonData, segments);\n\n if (value === undefined) {\n throw new Error(`Path not found: ${normalizedPath}`);\n }\n\n const hasChildren = this.isDirectory(value) && this.getChildren(value).length > 0;\n if (hasChildren && !options?.recursive) {\n throw new Error(\n `Cannot delete directory '${normalizedPath}' without recursive option. Set recursive: true to delete directories.`,\n );\n }\n\n this.deleteValueAtPath(this.jsonData, segments);\n await this.saveToFile();\n\n return { message: `Successfully deleted: ${normalizedPath}` };\n }\n\n async rename(\n oldPath: string,\n newPath: string,\n options?: AFSRenameOptions,\n ): Promise<AFSRenameResult> {\n await this.ensureLoaded();\n\n const normalizedOldPath = this.normalizePath(oldPath);\n const normalizedNewPath = this.normalizePath(newPath);\n\n const oldSegments = this.getPathSegments(normalizedOldPath);\n const newSegments = this.getPathSegments(normalizedNewPath);\n\n const oldValue = this.getValueAtPath(this.jsonData, oldSegments);\n if (oldValue === undefined) {\n throw new Error(`Source path not found: ${normalizedOldPath}`);\n }\n\n const existingNewValue = this.getValueAtPath(this.jsonData, newSegments);\n if (existingNewValue !== undefined && !options?.overwrite) {\n throw new Error(\n `Destination '${normalizedNewPath}' already exists. Set overwrite: true to replace it.`,\n );\n }\n\n // Copy to new location and delete old\n this.setValueAtPath(this.jsonData, newSegments, oldValue);\n this.deleteValueAtPath(this.jsonData, oldSegments);\n await this.saveToFile();\n\n return {\n message: `Successfully renamed '${normalizedOldPath}' to '${normalizedNewPath}'`,\n };\n }\n\n async search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n const caseSensitive = options?.caseSensitive ?? false;\n\n const segments = this.getPathSegments(normalizedPath);\n const rootValue = this.getValueAtPath(this.jsonData, segments);\n\n if (rootValue === undefined) {\n throw new Error(`Path not found: ${normalizedPath}`);\n }\n\n const entries: AFSEntry[] = [];\n const searchQuery = caseSensitive ? query : query.toLowerCase();\n\n const searchInValue = (valuePath: string, value: any): void => {\n if (entries.length >= limit) return;\n\n let matched = false;\n\n // Search in the value itself\n if (!this.isDirectory(value)) {\n const valueStr = typeof value === \"string\" ? value : JSON.stringify(value);\n const searchValue = caseSensitive ? valueStr : valueStr.toLowerCase();\n if (searchValue.includes(searchQuery)) {\n matched = true;\n }\n }\n\n if (matched) {\n entries.push(this.valueToAFSEntry(valuePath, value));\n }\n\n // Recursively search children\n if (this.isDirectory(value)) {\n const children = this.getChildren(value);\n for (const child of children) {\n if (entries.length >= limit) break;\n const childPath = valuePath === \"/\" ? `/${child.key}` : `${valuePath}/${child.key}`;\n searchInValue(childPath, child.value);\n }\n }\n };\n\n searchInValue(normalizedPath, rootValue);\n\n return {\n data: entries,\n message: entries.length >= limit ? `Results truncated to limit ${limit}` : undefined,\n };\n }\n}\n\nconst _typeCheck: AFSModuleClass<AFSJSON, AFSJSONOptions> = AFSJSON;\n"],"mappings":";;;;;;;AA0BA,MAAM,iBAAiB;AAqBvB,MAAM,uBAAuB,SAC3B,EAAE,OAAO;CACP,MAAM,YAAY,EAAE,QAAQ,CAAC;CAC7B,UAAU,EAAE,QAAQ,CAAC,SAAS,0CAA0C;CACxE,aAAa,YAAY,EAAE,QAAQ,CAAC,SAAS,mCAAmC,CAAC;CACjF,YAAY,YACV,EAAE,KAAK,CAAC,YAAY,YAAY,CAAC,CAAC,SAAS,8BAA8B,CAC1E;CACD,aAAa,YACX,EAAE,SAAS,CAAC,SAAS,wDAAwD,CAC9E;CACF,CAAC,CACH;;;;;;;AAQD,IAAa,UAAb,MAAa,QAA6B;CACxC,OAAO,SAAS;AACd,SAAO;;CAGT,aAAa,KAAK,EAAE,UAAU,UAA+B;AAE3D,SAAO,IAAI,QAAQ;GAAE,GADP,MAAM,QAAQ,QAAQ,CAAC,WAAW,OAAO;GACxB,KAAK,QAAQ,SAAS;GAAE,CAAC;;CAG1D,AAAQ,WAAgB;CACxB,AAAQ,YAGJ,EAAE;CACN,AAAQ,aAA8B;CAEtC,YAAY,AAAO,SAA4C;EAA5C;AACjB,WAAS,sBAAsB,QAAQ;EAEvC,IAAI;AAGJ,aAAW,QAAQ,SAAS,WAAW,UAAU,QAAQ,KAAK,CAAC;AAC/D,MAAI,SAAS,WAAW,KAAK,CAC3B,YAAW,KAAK,QAAQ,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAAC;AAE5D,MAAI,CAAC,WAAW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BAAgB,WAAW,MAAM,CAAC;AAItD,OAAI,KAAK,YAAY,MAAM,EAAE;IAC3B,MAAM,WAAW,KAAK,YAAY,MAAM;AACxC,SAAK,MAAM,SAAS,UAAU;AAC5B,SAAI,QAAQ,UAAU,MAAO;AAE7B,mBADkB,cAAc,MAAM,IAAI,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,OACrD,MAAM,MAAM;;;;AAK3C,gBAAc,gBAAgB,UAAU;AAExC,SAAO;GACL,MAAM;GACN,SAAS,QAAQ,UAAU,QAAQ,8BAA8B,UAAU;GAC5E"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["parseYAML","stringifyYAML"],"sources":["../src/index.ts"],"sourcesContent":["import { readFile, stat, writeFile } from \"node:fs/promises\";\nimport { basename, dirname, extname, isAbsolute, join } from \"node:path\";\nimport type {\n AFSAccessMode,\n AFSDeleteOptions,\n AFSDeleteResult,\n AFSEntry,\n AFSListOptions,\n AFSListResult,\n AFSModule,\n AFSModuleClass,\n AFSModuleLoadParams,\n AFSReadOptions,\n AFSReadResult,\n AFSRenameOptions,\n AFSRenameResult,\n AFSSearchOptions,\n AFSSearchResult,\n AFSWriteEntryPayload,\n AFSWriteOptions,\n AFSWriteResult,\n} from \"@aigne/afs\";\nimport { camelize, optionalize, zodParse } from \"@aigne/afs/utils/zod\";\nimport { parse as parseYAML, stringify as stringifyYAML } from \"yaml\";\nimport { z } from \"zod\";\n\nconst LIST_MAX_LIMIT = 1000;\n\nexport interface AFSJSONOptions {\n name?: string;\n jsonPath: string;\n description?: string;\n /**\n * Access mode for this module.\n * - \"readonly\": Only read operations are allowed\n * - \"readwrite\": All operations are allowed (default, unless agentSkills is enabled)\n * @default \"readwrite\" (or \"readonly\" when agentSkills is true)\n */\n accessMode?: AFSAccessMode;\n /**\n * Enable automatic agent skill scanning for this module.\n * When enabled, defaults accessMode to \"readonly\" if not explicitly set.\n * @default false\n */\n agentSkills?: boolean;\n}\n\nconst afsJSONOptionsSchema = camelize(\n z.object({\n name: optionalize(z.string()),\n jsonPath: z.string().describe(\"The path to the JSON/YAML file to mount\"),\n description: optionalize(z.string().describe(\"A description of the JSON module\")),\n accessMode: optionalize(\n z.enum([\"readonly\", \"readwrite\"]).describe(\"Access mode for this module\"),\n ),\n agentSkills: optionalize(\n z.boolean().describe(\"Enable automatic agent skill scanning for this module\"),\n ),\n }),\n);\n\n/**\n * AFS module for mounting JSON/YAML files as virtual file systems.\n *\n * JSON/YAML objects are treated as directories, and properties/array items as files.\n * Supports nested structures and path-based access to data values.\n */\nexport class AFSJSON implements AFSModule {\n static schema() {\n return afsJSONOptionsSchema;\n }\n\n static async load({ filepath, parsed }: AFSModuleLoadParams) {\n const valid = await AFSJSON.schema().parseAsync(parsed);\n return new AFSJSON({ ...valid, cwd: dirname(filepath) });\n }\n\n private jsonData: any = null;\n private fileStats: {\n birthtime?: Date;\n mtime?: Date;\n } = {};\n private fileFormat: \"json\" | \"yaml\" = \"json\";\n\n constructor(public options: AFSJSONOptions & { cwd?: string }) {\n zodParse(afsJSONOptionsSchema, options);\n\n let jsonPath: string;\n\n jsonPath = options.jsonPath.replaceAll(\"${CWD}\", process.cwd());\n if (jsonPath.startsWith(\"~/\")) {\n jsonPath = join(process.env.HOME || \"\", jsonPath.slice(2));\n }\n if (!isAbsolute(jsonPath)) {\n jsonPath = join(options.cwd || process.cwd(), jsonPath);\n }\n\n // Detect file format based on extension for writing\n const ext = extname(jsonPath).toLowerCase();\n this.fileFormat = ext === \".yaml\" || ext === \".yml\" ? \"yaml\" : \"json\";\n\n // Extract name without extension\n const extensions = [\".json\", \".yaml\", \".yml\"];\n let name = basename(jsonPath);\n for (const e of extensions) {\n if (name.endsWith(e)) {\n name = name.slice(0, -e.length);\n break;\n }\n }\n\n this.name = options.name || name || \"json\";\n this.description = options.description;\n this.agentSkills = options.agentSkills;\n // Default to \"readwrite\", but \"readonly\" if agentSkills is enabled\n this.accessMode = options.accessMode ?? (options.agentSkills ? \"readonly\" : \"readwrite\");\n this.options.jsonPath = jsonPath;\n }\n\n name: string;\n\n description?: string;\n\n accessMode: AFSAccessMode;\n\n agentSkills?: boolean;\n\n /**\n * Load JSON/YAML data from file. Called lazily on first access.\n * Uses YAML parser which can handle both JSON and YAML formats.\n */\n private async ensureLoaded(): Promise<void> {\n if (this.jsonData !== null) return;\n\n try {\n const stats = await stat(this.options.jsonPath);\n this.fileStats = {\n birthtime: stats.birthtime,\n mtime: stats.mtime,\n };\n\n const content = await readFile(this.options.jsonPath, \"utf8\");\n\n // YAML parser can handle both JSON and YAML formats\n this.jsonData = parseYAML(content);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n // File doesn't exist yet, start with empty object\n this.jsonData = {};\n } else {\n throw error;\n }\n }\n }\n\n /**\n * Save JSON/YAML data back to file. Only called in readwrite mode.\n */\n private async saveToFile(): Promise<void> {\n let content: string;\n\n // Serialize based on file format\n if (this.fileFormat === \"yaml\") {\n content = stringifyYAML(this.jsonData);\n } else {\n content = JSON.stringify(this.jsonData, null, 2);\n }\n\n await writeFile(this.options.jsonPath, content, \"utf8\");\n\n // Update file stats\n const stats = await stat(this.options.jsonPath);\n this.fileStats = {\n birthtime: this.fileStats.birthtime || stats.birthtime,\n mtime: stats.mtime,\n };\n }\n\n /**\n * Normalize path to ensure consistent format\n */\n private normalizePath(path: string): string {\n let normalized = path.startsWith(\"/\") ? path : `/${path}`;\n if (normalized.length > 1 && normalized.endsWith(\"/\")) {\n normalized = normalized.slice(0, -1);\n }\n return normalized;\n }\n\n /**\n * Get path segments from normalized path\n */\n private getPathSegments(path: string): string[] {\n const normalized = this.normalizePath(path);\n if (normalized === \"/\") return [];\n return normalized.slice(1).split(\"/\");\n }\n\n /**\n * Navigate to a value in the JSON structure using path segments\n */\n private getValueAtPath(data: any, segments: string[]): any {\n let current = data;\n for (const segment of segments) {\n if (current == null) return undefined;\n\n // Handle array indices\n if (Array.isArray(current)) {\n const index = Number.parseInt(segment, 10);\n if (Number.isNaN(index) || index < 0 || index >= current.length) {\n return undefined;\n }\n current = current[index];\n } else if (typeof current === \"object\") {\n current = current[segment as keyof typeof current];\n } else {\n return undefined;\n }\n }\n return current;\n }\n\n /**\n * Set a value in the JSON structure at the given path\n */\n private setValueAtPath(data: any, segments: string[], value: any): void {\n if (segments.length === 0) {\n throw new Error(\"Cannot set value at root path\");\n }\n\n let current = data;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i]!;\n const nextSegment = segments[i + 1]!;\n\n if (Array.isArray(current)) {\n const index = Number.parseInt(segment, 10);\n if (Number.isNaN(index) || index < 0) {\n throw new Error(`Invalid array index: ${segment}`);\n }\n\n // Extend array if necessary\n while (current.length <= index) {\n current.push(null);\n }\n\n if (current[index] == null) {\n // Determine if next level should be array or object\n const isNextArray = !Number.isNaN(Number.parseInt(nextSegment, 10));\n current[index] = isNextArray ? [] : {};\n }\n current = current[index];\n } else if (typeof current === \"object\") {\n if (current[segment] == null) {\n // Determine if next level should be array or object\n const isNextArray = !Number.isNaN(Number.parseInt(nextSegment, 10));\n current[segment] = isNextArray ? [] : {};\n }\n current = current[segment];\n } else {\n throw new Error(\n `Cannot set property on non-object at ${segments.slice(0, i + 1).join(\"/\")}`,\n );\n }\n }\n\n const lastSegment = segments[segments.length - 1]!;\n if (Array.isArray(current)) {\n const index = Number.parseInt(lastSegment, 10);\n if (Number.isNaN(index) || index < 0) {\n throw new Error(`Invalid array index: ${lastSegment}`);\n }\n current[index] = value;\n } else if (typeof current === \"object\") {\n current[lastSegment] = value;\n } else {\n throw new Error(\"Cannot set property on non-object\");\n }\n }\n\n /**\n * Delete a value from the JSON structure at the given path\n */\n private deleteValueAtPath(data: any, segments: string[]): boolean {\n if (segments.length === 0) {\n throw new Error(\"Cannot delete root path\");\n }\n\n let current = data;\n for (let i = 0; i < segments.length - 1; i++) {\n const segment = segments[i]!;\n\n if (Array.isArray(current)) {\n const index = Number.parseInt(segment, 10);\n if (Number.isNaN(index) || index < 0 || index >= current.length) {\n return false;\n }\n current = current[index];\n } else if (typeof current === \"object\") {\n if (!(segment in current)) return false;\n current = current[segment];\n } else {\n return false;\n }\n }\n\n const lastSegment = segments[segments.length - 1]!;\n if (Array.isArray(current)) {\n const index = Number.parseInt(lastSegment, 10);\n if (Number.isNaN(index) || index < 0 || index >= current.length) {\n return false;\n }\n current.splice(index, 1);\n return true;\n }\n if (typeof current === \"object\") {\n if (!(lastSegment in current)) return false;\n delete current[lastSegment];\n return true;\n }\n return false;\n }\n\n /**\n * Check if a value is a \"directory\" (object or array with children)\n */\n private isDirectory(value: any): boolean {\n if (Array.isArray(value)) return true;\n if (typeof value === \"object\" && value !== null) return true;\n return false;\n }\n\n /**\n * Get children of a directory value\n */\n private getChildren(value: any): Array<{ key: string; value: any }> {\n if (Array.isArray(value)) {\n return value.map((item, index) => ({ key: String(index), value: item }));\n }\n if (typeof value === \"object\" && value !== null) {\n return Object.entries(value).map(([key, val]) => ({ key, value: val }));\n }\n return [];\n }\n\n /**\n * Convert a JSON value to an AFSEntry\n */\n private valueToAFSEntry(path: string, value: any): AFSEntry {\n const isDir = this.isDirectory(value);\n const children = isDir ? this.getChildren(value) : [];\n\n return {\n id: path,\n path: path,\n content: isDir ? undefined : value,\n createdAt: this.fileStats.birthtime,\n updatedAt: this.fileStats.mtime,\n metadata: {\n type: isDir ? \"directory\" : \"file\",\n childrenCount: isDir ? children.length : undefined,\n },\n };\n }\n\n async list(path: string, options?: AFSListOptions): Promise<AFSListResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n const maxChildren =\n typeof options?.maxChildren === \"number\" ? options.maxChildren : Number.MAX_SAFE_INTEGER;\n const maxDepth = options?.maxDepth ?? 1;\n\n const segments = this.getPathSegments(normalizedPath);\n const value = this.getValueAtPath(this.jsonData, segments);\n\n if (value === undefined) {\n throw new Error(`Path not found: ${normalizedPath}`);\n }\n\n const entries: AFSEntry[] = [];\n\n interface QueueItem {\n path: string;\n value: any;\n depth: number;\n }\n\n const queue: QueueItem[] = [{ path: normalizedPath, value, depth: 0 }];\n\n while (queue.length > 0) {\n const item = queue.shift();\n if (!item) break;\n\n const { path: itemPath, value: itemValue, depth } = item;\n\n const entry = this.valueToAFSEntry(itemPath, itemValue);\n entries.push(entry);\n\n if (entries.length >= limit) {\n if (entry.metadata) {\n entry.metadata.childrenTruncated = true;\n }\n break;\n }\n\n // Process children if within depth limit\n if (this.isDirectory(itemValue) && depth < maxDepth) {\n const children = this.getChildren(itemValue);\n const childrenToProcess =\n children.length > maxChildren ? children.slice(0, maxChildren) : children;\n const isTruncated = childrenToProcess.length < children.length;\n\n if (isTruncated && entry.metadata) {\n entry.metadata.childrenTruncated = true;\n }\n\n for (const child of childrenToProcess) {\n const childPath = itemPath === \"/\" ? `/${child.key}` : `${itemPath}/${child.key}`;\n queue.push({\n path: childPath,\n value: child.value,\n depth: depth + 1,\n });\n }\n }\n }\n\n return { data: entries };\n }\n\n async read(path: string, _options?: AFSReadOptions): Promise<AFSReadResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const segments = this.getPathSegments(normalizedPath);\n const value = this.getValueAtPath(this.jsonData, segments);\n\n if (value === undefined) {\n return {\n data: undefined,\n message: `Path not found: ${normalizedPath}`,\n };\n }\n\n return { data: this.valueToAFSEntry(normalizedPath, value) };\n }\n\n async write(\n path: string,\n entry: AFSWriteEntryPayload,\n _options?: AFSWriteOptions,\n ): Promise<AFSWriteResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const segments = this.getPathSegments(normalizedPath);\n\n // Set the value in the JSON structure\n this.setValueAtPath(this.jsonData, segments, entry.content);\n\n // Save back to file\n await this.saveToFile();\n\n const newValue = this.getValueAtPath(this.jsonData, segments);\n const isDir = this.isDirectory(newValue);\n const children = isDir ? this.getChildren(newValue) : [];\n\n const writtenEntry: AFSEntry = {\n id: normalizedPath,\n path: normalizedPath,\n content: entry.content,\n summary: entry.summary,\n description: entry.description,\n createdAt: this.fileStats.birthtime,\n updatedAt: this.fileStats.mtime,\n metadata: {\n ...entry.metadata,\n type: isDir ? \"directory\" : \"file\",\n childrenCount: isDir ? children.length : undefined,\n },\n userId: entry.userId,\n sessionId: entry.sessionId,\n linkTo: entry.linkTo,\n };\n\n return { data: writtenEntry };\n }\n\n async delete(path: string, options?: AFSDeleteOptions): Promise<AFSDeleteResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const segments = this.getPathSegments(normalizedPath);\n const value = this.getValueAtPath(this.jsonData, segments);\n\n if (value === undefined) {\n throw new Error(`Path not found: ${normalizedPath}`);\n }\n\n const hasChildren = this.isDirectory(value) && this.getChildren(value).length > 0;\n if (hasChildren && !options?.recursive) {\n throw new Error(\n `Cannot delete directory '${normalizedPath}' without recursive option. Set recursive: true to delete directories.`,\n );\n }\n\n this.deleteValueAtPath(this.jsonData, segments);\n await this.saveToFile();\n\n return { message: `Successfully deleted: ${normalizedPath}` };\n }\n\n async rename(\n oldPath: string,\n newPath: string,\n options?: AFSRenameOptions,\n ): Promise<AFSRenameResult> {\n await this.ensureLoaded();\n\n const normalizedOldPath = this.normalizePath(oldPath);\n const normalizedNewPath = this.normalizePath(newPath);\n\n const oldSegments = this.getPathSegments(normalizedOldPath);\n const newSegments = this.getPathSegments(normalizedNewPath);\n\n const oldValue = this.getValueAtPath(this.jsonData, oldSegments);\n if (oldValue === undefined) {\n throw new Error(`Source path not found: ${normalizedOldPath}`);\n }\n\n const existingNewValue = this.getValueAtPath(this.jsonData, newSegments);\n if (existingNewValue !== undefined && !options?.overwrite) {\n throw new Error(\n `Destination '${normalizedNewPath}' already exists. Set overwrite: true to replace it.`,\n );\n }\n\n // Copy to new location and delete old\n this.setValueAtPath(this.jsonData, newSegments, oldValue);\n this.deleteValueAtPath(this.jsonData, oldSegments);\n await this.saveToFile();\n\n return {\n message: `Successfully renamed '${normalizedOldPath}' to '${normalizedNewPath}'`,\n };\n }\n\n async search(path: string, query: string, options?: AFSSearchOptions): Promise<AFSSearchResult> {\n await this.ensureLoaded();\n\n const normalizedPath = this.normalizePath(path);\n const limit = Math.min(options?.limit || LIST_MAX_LIMIT, LIST_MAX_LIMIT);\n const caseSensitive = options?.caseSensitive ?? false;\n\n const segments = this.getPathSegments(normalizedPath);\n const rootValue = this.getValueAtPath(this.jsonData, segments);\n\n if (rootValue === undefined) {\n throw new Error(`Path not found: ${normalizedPath}`);\n }\n\n const entries: AFSEntry[] = [];\n const searchQuery = caseSensitive ? query : query.toLowerCase();\n\n const searchInValue = (valuePath: string, value: any): void => {\n if (entries.length >= limit) return;\n\n let matched = false;\n\n // Search in the value itself\n if (!this.isDirectory(value)) {\n const valueStr = typeof value === \"string\" ? value : JSON.stringify(value);\n const searchValue = caseSensitive ? valueStr : valueStr.toLowerCase();\n if (searchValue.includes(searchQuery)) {\n matched = true;\n }\n }\n\n if (matched) {\n entries.push(this.valueToAFSEntry(valuePath, value));\n }\n\n // Recursively search children\n if (this.isDirectory(value)) {\n const children = this.getChildren(value);\n for (const child of children) {\n if (entries.length >= limit) break;\n const childPath = valuePath === \"/\" ? `/${child.key}` : `${valuePath}/${child.key}`;\n searchInValue(childPath, child.value);\n }\n }\n };\n\n searchInValue(normalizedPath, rootValue);\n\n return {\n data: entries,\n message: entries.length >= limit ? `Results truncated to limit ${limit}` : undefined,\n };\n }\n}\n\nconst _typeCheck: AFSModuleClass<AFSJSON, AFSJSONOptions> = AFSJSON;\n"],"mappings":";;;;;;;AA0BA,MAAM,iBAAiB;AAqBvB,MAAM,uBAAuB,SAC3B,EAAE,OAAO;CACP,MAAM,YAAY,EAAE,QAAQ,CAAC;CAC7B,UAAU,EAAE,QAAQ,CAAC,SAAS,0CAA0C;CACxE,aAAa,YAAY,EAAE,QAAQ,CAAC,SAAS,mCAAmC,CAAC;CACjF,YAAY,YACV,EAAE,KAAK,CAAC,YAAY,YAAY,CAAC,CAAC,SAAS,8BAA8B,CAC1E;CACD,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/C,MAAM,QAAQ,KAAK,IAAI,SAAS,SAAS,gBAAgB,eAAe;EACxE,MAAM,gBAAgB,SAAS,iBAAiB;EAEhD,MAAM,WAAW,KAAK,gBAAgB,eAAe;EACrD,MAAM,YAAY,KAAK,eAAe,KAAK,UAAU,SAAS;AAE9D,MAAI,cAAc,OAChB,OAAM,IAAI,MAAM,mBAAmB,iBAAiB;EAGtD,MAAM,UAAsB,EAAE;EAC9B,MAAM,cAAc,gBAAgB,QAAQ,MAAM,aAAa;EAE/D,MAAM,iBAAiB,WAAmB,UAAqB;AAC7D,OAAI,QAAQ,UAAU,MAAO;GAE7B,IAAI,UAAU;AAGd,OAAI,CAAC,KAAK,YAAY,MAAM,EAAE;IAC5B,MAAM,WAAW,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,MAAM;AAE1E,SADoB,gBAAgB,WAAW,SAAS,aAAa,EACrD,SAAS,YAAY,CACnC,WAAU;;AAId,OAAI,QACF,SAAQ,KAAK,KAAK,gBAAgB,WAAW,MAAM,CAAC;AAItD,OAAI,KAAK,YAAY,MAAM,EAAE;IAC3B,MAAM,WAAW,KAAK,YAAY,MAAM;AACxC,SAAK,MAAM,SAAS,UAAU;AAC5B,SAAI,QAAQ,UAAU,MAAO;AAE7B,mBADkB,cAAc,MAAM,IAAI,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,OACrD,MAAM,MAAM;;;;AAK3C,gBAAc,gBAAgB,UAAU;AAExC,SAAO;GACL,MAAM;GACN,SAAS,QAAQ,UAAU,QAAQ,8BAA8B,UAAU;GAC5E"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/afs-json",
|
|
3
|
-
"version": "1.11.0-beta",
|
|
3
|
+
"version": "1.11.0-beta.2",
|
|
4
4
|
"description": "AIGNE AFS module for JSON and YAML file storage",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"yaml": "^2.8.1",
|
|
37
37
|
"zod": "^3.25.67",
|
|
38
|
-
"@aigne/afs": "^1.11.0-beta"
|
|
38
|
+
"@aigne/afs": "^1.11.0-beta.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/bun": "^1.3.6",
|