@soederpop/luca 0.1.2 → 0.1.3
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/CLAUDE.md +2 -0
- package/assistants/codingAssistant/hooks.ts +1 -5
- package/assistants/inkbot/CORE.md +69 -0
- package/assistants/inkbot/hooks.ts +14 -0
- package/assistants/inkbot/tools.ts +47 -0
- package/commands/inkbot.ts +353 -0
- package/dist/agi/container.server.d.ts +63 -0
- package/dist/agi/container.server.d.ts.map +1 -0
- package/dist/agi/endpoints/ask.d.ts +20 -0
- package/dist/agi/endpoints/ask.d.ts.map +1 -0
- package/dist/agi/endpoints/conversations/[id].d.ts +27 -0
- package/dist/agi/endpoints/conversations/[id].d.ts.map +1 -0
- package/dist/agi/endpoints/conversations.d.ts +18 -0
- package/dist/agi/endpoints/conversations.d.ts.map +1 -0
- package/dist/agi/endpoints/experts.d.ts +8 -0
- package/dist/agi/endpoints/experts.d.ts.map +1 -0
- package/dist/agi/feature.d.ts +9 -0
- package/dist/agi/feature.d.ts.map +1 -0
- package/dist/agi/features/assistant.d.ts +509 -0
- package/dist/agi/features/assistant.d.ts.map +1 -0
- package/dist/agi/features/assistants-manager.d.ts +236 -0
- package/dist/agi/features/assistants-manager.d.ts.map +1 -0
- package/dist/agi/features/autonomous-assistant.d.ts +281 -0
- package/dist/agi/features/autonomous-assistant.d.ts.map +1 -0
- package/dist/agi/features/browser-use.d.ts +479 -0
- package/dist/agi/features/browser-use.d.ts.map +1 -0
- package/dist/agi/features/claude-code.d.ts +824 -0
- package/dist/agi/features/claude-code.d.ts.map +1 -0
- package/dist/agi/features/conversation-history.d.ts +245 -0
- package/dist/agi/features/conversation-history.d.ts.map +1 -0
- package/dist/agi/features/conversation.d.ts +464 -0
- package/dist/agi/features/conversation.d.ts.map +1 -0
- package/dist/agi/features/docs-reader.d.ts +72 -0
- package/dist/agi/features/docs-reader.d.ts.map +1 -0
- package/dist/agi/features/file-tools.d.ts +110 -0
- package/dist/agi/features/file-tools.d.ts.map +1 -0
- package/dist/agi/features/luca-coder.d.ts +323 -0
- package/dist/agi/features/luca-coder.d.ts.map +1 -0
- package/dist/agi/features/openai-codex.d.ts +381 -0
- package/dist/agi/features/openai-codex.d.ts.map +1 -0
- package/dist/agi/features/openapi.d.ts +200 -0
- package/dist/agi/features/openapi.d.ts.map +1 -0
- package/dist/agi/features/skills-library.d.ts +167 -0
- package/dist/agi/features/skills-library.d.ts.map +1 -0
- package/dist/agi/index.d.ts +5 -0
- package/dist/agi/index.d.ts.map +1 -0
- package/dist/agi/lib/interceptor-chain.d.ts +44 -0
- package/dist/agi/lib/interceptor-chain.d.ts.map +1 -0
- package/dist/agi/lib/token-counter.d.ts +13 -0
- package/dist/agi/lib/token-counter.d.ts.map +1 -0
- package/dist/bootstrap/generated.d.ts +5 -0
- package/dist/bootstrap/generated.d.ts.map +1 -0
- package/dist/browser.d.ts +12 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/bus.d.ts +29 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/cli/build-info.d.ts +4 -0
- package/dist/cli/build-info.d.ts.map +1 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/client.d.ts +60 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/clients/civitai/index.d.ts +472 -0
- package/dist/clients/civitai/index.d.ts.map +1 -0
- package/dist/clients/client-template.d.ts +30 -0
- package/dist/clients/client-template.d.ts.map +1 -0
- package/dist/clients/comfyui/index.d.ts +281 -0
- package/dist/clients/comfyui/index.d.ts.map +1 -0
- package/dist/clients/elevenlabs/index.d.ts +197 -0
- package/dist/clients/elevenlabs/index.d.ts.map +1 -0
- package/dist/clients/graph.d.ts +64 -0
- package/dist/clients/graph.d.ts.map +1 -0
- package/dist/clients/openai/index.d.ts +247 -0
- package/dist/clients/openai/index.d.ts.map +1 -0
- package/dist/clients/rest.d.ts +92 -0
- package/dist/clients/rest.d.ts.map +1 -0
- package/dist/clients/supabase/index.d.ts +176 -0
- package/dist/clients/supabase/index.d.ts.map +1 -0
- package/dist/clients/websocket.d.ts +127 -0
- package/dist/clients/websocket.d.ts.map +1 -0
- package/dist/command.d.ts +163 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/commands/bootstrap.d.ts +20 -0
- package/dist/commands/bootstrap.d.ts.map +1 -0
- package/dist/commands/chat.d.ts +37 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/code.d.ts +28 -0
- package/dist/commands/code.d.ts.map +1 -0
- package/dist/commands/console.d.ts +22 -0
- package/dist/commands/console.d.ts.map +1 -0
- package/dist/commands/describe.d.ts +50 -0
- package/dist/commands/describe.d.ts.map +1 -0
- package/dist/commands/eval.d.ts +23 -0
- package/dist/commands/eval.d.ts.map +1 -0
- package/dist/commands/help.d.ts +25 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/index.d.ts +18 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/introspect.d.ts +24 -0
- package/dist/commands/introspect.d.ts.map +1 -0
- package/dist/commands/mcp.d.ts +35 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/prompt.d.ts +38 -0
- package/dist/commands/prompt.d.ts.map +1 -0
- package/dist/commands/run.d.ts +24 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/sandbox-mcp.d.ts +34 -0
- package/dist/commands/sandbox-mcp.d.ts.map +1 -0
- package/dist/commands/save-api-docs.d.ts +21 -0
- package/dist/commands/save-api-docs.d.ts.map +1 -0
- package/dist/commands/scaffold.d.ts +24 -0
- package/dist/commands/scaffold.d.ts.map +1 -0
- package/dist/commands/select.d.ts +22 -0
- package/dist/commands/select.d.ts.map +1 -0
- package/dist/commands/serve.d.ts +29 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/container-describer.d.ts +144 -0
- package/dist/container-describer.d.ts.map +1 -0
- package/dist/container.d.ts +451 -0
- package/dist/container.d.ts.map +1 -0
- package/dist/endpoint.d.ts +113 -0
- package/dist/endpoint.d.ts.map +1 -0
- package/dist/feature.d.ts +47 -0
- package/dist/feature.d.ts.map +1 -0
- package/dist/graft.d.ts +29 -0
- package/dist/graft.d.ts.map +1 -0
- package/dist/hash-object.d.ts +8 -0
- package/dist/hash-object.d.ts.map +1 -0
- package/dist/helper.d.ts +209 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/introspection/generated.node.d.ts +44623 -0
- package/dist/introspection/generated.node.d.ts.map +1 -0
- package/dist/introspection/generated.web.d.ts +1412 -0
- package/dist/introspection/generated.web.d.ts.map +1 -0
- package/dist/introspection/index.d.ts +156 -0
- package/dist/introspection/index.d.ts.map +1 -0
- package/dist/introspection/scan.d.ts +147 -0
- package/dist/introspection/scan.d.ts.map +1 -0
- package/dist/node/container.d.ts +256 -0
- package/dist/node/container.d.ts.map +1 -0
- package/dist/node/feature.d.ts +9 -0
- package/dist/node/feature.d.ts.map +1 -0
- package/dist/node/features/container-link.d.ts +213 -0
- package/dist/node/features/container-link.d.ts.map +1 -0
- package/dist/node/features/content-db.d.ts +354 -0
- package/dist/node/features/content-db.d.ts.map +1 -0
- package/dist/node/features/disk-cache.d.ts +236 -0
- package/dist/node/features/disk-cache.d.ts.map +1 -0
- package/dist/node/features/dns.d.ts +511 -0
- package/dist/node/features/dns.d.ts.map +1 -0
- package/dist/node/features/docker.d.ts +485 -0
- package/dist/node/features/docker.d.ts.map +1 -0
- package/dist/node/features/downloader.d.ts +73 -0
- package/dist/node/features/downloader.d.ts.map +1 -0
- package/dist/node/features/figlet-fonts.d.ts +4 -0
- package/dist/node/features/figlet-fonts.d.ts.map +1 -0
- package/dist/node/features/file-manager.d.ts +177 -0
- package/dist/node/features/file-manager.d.ts.map +1 -0
- package/dist/node/features/fs.d.ts +635 -0
- package/dist/node/features/fs.d.ts.map +1 -0
- package/dist/node/features/git.d.ts +329 -0
- package/dist/node/features/git.d.ts.map +1 -0
- package/dist/node/features/google-auth.d.ts +200 -0
- package/dist/node/features/google-auth.d.ts.map +1 -0
- package/dist/node/features/google-calendar.d.ts +194 -0
- package/dist/node/features/google-calendar.d.ts.map +1 -0
- package/dist/node/features/google-docs.d.ts +138 -0
- package/dist/node/features/google-docs.d.ts.map +1 -0
- package/dist/node/features/google-drive.d.ts +202 -0
- package/dist/node/features/google-drive.d.ts.map +1 -0
- package/dist/node/features/google-mail.d.ts +221 -0
- package/dist/node/features/google-mail.d.ts.map +1 -0
- package/dist/node/features/google-sheets.d.ts +157 -0
- package/dist/node/features/google-sheets.d.ts.map +1 -0
- package/dist/node/features/grep.d.ts +207 -0
- package/dist/node/features/grep.d.ts.map +1 -0
- package/dist/node/features/helpers.d.ts +236 -0
- package/dist/node/features/helpers.d.ts.map +1 -0
- package/dist/node/features/ink.d.ts +332 -0
- package/dist/node/features/ink.d.ts.map +1 -0
- package/dist/node/features/ipc-socket.d.ts +298 -0
- package/dist/node/features/ipc-socket.d.ts.map +1 -0
- package/dist/node/features/json-tree.d.ts +140 -0
- package/dist/node/features/json-tree.d.ts.map +1 -0
- package/dist/node/features/networking.d.ts +373 -0
- package/dist/node/features/networking.d.ts.map +1 -0
- package/dist/node/features/nlp.d.ts +125 -0
- package/dist/node/features/nlp.d.ts.map +1 -0
- package/dist/node/features/opener.d.ts +93 -0
- package/dist/node/features/opener.d.ts.map +1 -0
- package/dist/node/features/os.d.ts +168 -0
- package/dist/node/features/os.d.ts.map +1 -0
- package/dist/node/features/package-finder.d.ts +419 -0
- package/dist/node/features/package-finder.d.ts.map +1 -0
- package/dist/node/features/postgres.d.ts +173 -0
- package/dist/node/features/postgres.d.ts.map +1 -0
- package/dist/node/features/proc.d.ts +285 -0
- package/dist/node/features/proc.d.ts.map +1 -0
- package/dist/node/features/process-manager.d.ts +427 -0
- package/dist/node/features/process-manager.d.ts.map +1 -0
- package/dist/node/features/python.d.ts +477 -0
- package/dist/node/features/python.d.ts.map +1 -0
- package/dist/node/features/redis.d.ts +247 -0
- package/dist/node/features/redis.d.ts.map +1 -0
- package/dist/node/features/repl.d.ts +84 -0
- package/dist/node/features/repl.d.ts.map +1 -0
- package/dist/node/features/runpod.d.ts +527 -0
- package/dist/node/features/runpod.d.ts.map +1 -0
- package/dist/node/features/secure-shell.d.ts +145 -0
- package/dist/node/features/secure-shell.d.ts.map +1 -0
- package/dist/node/features/semantic-search.d.ts +207 -0
- package/dist/node/features/semantic-search.d.ts.map +1 -0
- package/dist/node/features/sqlite.d.ts +180 -0
- package/dist/node/features/sqlite.d.ts.map +1 -0
- package/dist/node/features/telegram.d.ts +173 -0
- package/dist/node/features/telegram.d.ts.map +1 -0
- package/dist/node/features/transpiler.d.ts +51 -0
- package/dist/node/features/transpiler.d.ts.map +1 -0
- package/dist/node/features/tts.d.ts +108 -0
- package/dist/node/features/tts.d.ts.map +1 -0
- package/dist/node/features/ui.d.ts +562 -0
- package/dist/node/features/ui.d.ts.map +1 -0
- package/dist/node/features/vault.d.ts +90 -0
- package/dist/node/features/vault.d.ts.map +1 -0
- package/dist/node/features/vm.d.ts +285 -0
- package/dist/node/features/vm.d.ts.map +1 -0
- package/dist/node/features/yaml-tree.d.ts +118 -0
- package/dist/node/features/yaml-tree.d.ts.map +1 -0
- package/dist/node/features/yaml.d.ts +127 -0
- package/dist/node/features/yaml.d.ts.map +1 -0
- package/dist/node.d.ts +67 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/python/generated.d.ts +2 -0
- package/dist/python/generated.d.ts.map +1 -0
- package/dist/react/index.d.ts +36 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/registry.d.ts +97 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/scaffolds/generated.d.ts +13 -0
- package/dist/scaffolds/generated.d.ts.map +1 -0
- package/dist/scaffolds/template.d.ts +11 -0
- package/dist/scaffolds/template.d.ts.map +1 -0
- package/dist/schemas/base.d.ts +254 -0
- package/dist/schemas/base.d.ts.map +1 -0
- package/dist/selector.d.ts +130 -0
- package/dist/selector.d.ts.map +1 -0
- package/dist/server.d.ts +89 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/servers/express.d.ts +104 -0
- package/dist/servers/express.d.ts.map +1 -0
- package/dist/servers/mcp.d.ts +201 -0
- package/dist/servers/mcp.d.ts.map +1 -0
- package/dist/servers/socket.d.ts +121 -0
- package/dist/servers/socket.d.ts.map +1 -0
- package/dist/state.d.ts +24 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/web/clients/socket.d.ts +37 -0
- package/dist/web/clients/socket.d.ts.map +1 -0
- package/dist/web/container.d.ts +55 -0
- package/dist/web/container.d.ts.map +1 -0
- package/dist/web/extension.d.ts +4 -0
- package/dist/web/extension.d.ts.map +1 -0
- package/dist/web/feature.d.ts +8 -0
- package/dist/web/feature.d.ts.map +1 -0
- package/dist/web/features/asset-loader.d.ts +35 -0
- package/dist/web/features/asset-loader.d.ts.map +1 -0
- package/dist/web/features/container-link.d.ts +167 -0
- package/dist/web/features/container-link.d.ts.map +1 -0
- package/dist/web/features/esbuild.d.ts +51 -0
- package/dist/web/features/esbuild.d.ts.map +1 -0
- package/dist/web/features/helpers.d.ts +140 -0
- package/dist/web/features/helpers.d.ts.map +1 -0
- package/dist/web/features/network.d.ts +69 -0
- package/dist/web/features/network.d.ts.map +1 -0
- package/dist/web/features/speech.d.ts +71 -0
- package/dist/web/features/speech.d.ts.map +1 -0
- package/dist/web/features/vault.d.ts +62 -0
- package/dist/web/features/vault.d.ts.map +1 -0
- package/dist/web/features/vm.d.ts +48 -0
- package/dist/web/features/vm.d.ts.map +1 -0
- package/dist/web/features/voice-recognition.d.ts +96 -0
- package/dist/web/features/voice-recognition.d.ts.map +1 -0
- package/dist/web/shims/isomorphic-vm.d.ts +22 -0
- package/dist/web/shims/isomorphic-vm.d.ts.map +1 -0
- package/docs/apis/features/agi/assistant.md +1 -0
- package/docs/apis/features/agi/assistants-manager.md +62 -2
- package/docs/apis/features/agi/auto-assistant.md +11 -109
- package/docs/apis/features/agi/claude-code.md +138 -0
- package/docs/apis/features/agi/conversation.md +60 -31
- package/docs/apis/features/agi/luca-coder.md +407 -0
- package/docs/apis/features/agi/openapi.md +2 -2
- package/docs/apis/features/agi/skills-library.md +12 -0
- package/docs/apis/features/node/python.md +81 -11
- package/docs/apis/features/node/transpiler.md +74 -0
- package/docs/apis/features/web/esbuild.md +0 -6
- package/docs/apis/servers/mcp.md +2 -2
- package/docs/examples/entity.md +124 -0
- package/package.json +73 -21
- package/src/agi/feature.ts +13 -0
- package/src/agi/features/assistant.ts +36 -25
- package/src/agi/features/assistants-manager.ts +70 -5
- package/src/agi/features/autonomous-assistant.ts +1 -5
- package/src/agi/features/browser-use.ts +2 -2
- package/src/agi/features/claude-code.ts +165 -1
- package/src/agi/features/conversation-history.ts +2 -6
- package/src/agi/features/conversation.ts +95 -3
- package/src/agi/features/docs-reader.ts +2 -1
- package/src/agi/features/file-tools.ts +2 -2
- package/src/agi/features/luca-coder.ts +1 -5
- package/src/agi/features/openai-codex.ts +1 -1
- package/src/agi/features/openapi.ts +3 -3
- package/src/agi/features/skills-library.ts +87 -6
- package/src/agi/lib/interceptor-chain.ts +10 -0
- package/src/agi/lib/token-counter.ts +1 -1
- package/src/bootstrap/generated.ts +126 -1
- package/src/bus.ts +27 -5
- package/src/cli/build-info.ts +2 -2
- package/src/client.ts +2 -2
- package/src/clients/elevenlabs/index.ts +5 -0
- package/src/commands/bootstrap.ts +2 -1
- package/src/commands/chat.ts +1 -0
- package/src/commands/code.ts +4 -2
- package/src/commands/prompt.ts +34 -34
- package/src/commands/sandbox-mcp.ts +69 -163
- package/src/commands/save-api-docs.ts +10 -8
- package/src/commands/select.ts +8 -3
- package/src/container-describer.ts +70 -84
- package/src/container.ts +93 -3
- package/src/endpoint.ts +1 -1
- package/src/entity.ts +173 -0
- package/src/feature.ts +3 -3
- package/src/helper.ts +8 -4
- package/src/introspection/generated.agi.ts +1246 -798
- package/src/introspection/generated.node.ts +892 -798
- package/src/introspection/generated.web.ts +95 -3
- package/src/introspection/scan.ts +1 -1
- package/src/node/container.ts +1 -1
- package/src/node/features/content-db.ts +3 -3
- package/src/node/features/file-manager.ts +10 -9
- package/src/node/features/git.ts +5 -5
- package/src/node/features/helpers.ts +1 -1
- package/src/node/features/json-tree.ts +1 -1
- package/src/node/features/os.ts +3 -3
- package/src/node/features/package-finder.ts +1 -1
- package/src/node/features/process-manager.ts +1 -1
- package/src/node/features/python.ts +3 -3
- package/src/node/features/redis.ts +1 -1
- package/src/node/features/repl.ts +2 -2
- package/src/node/features/transpiler.ts +2 -2
- package/src/node/features/ui.ts +1 -1
- package/src/node/features/vm.ts +3 -3
- package/src/node/features/yaml-tree.ts +1 -1
- package/src/node.ts +1 -0
- package/src/python/generated.ts +1 -1
- package/src/scaffolds/generated.ts +1 -1
- package/src/selector.ts +74 -4
- package/src/server.ts +2 -2
- package/src/servers/mcp.ts +6 -6
- package/src/web/features/helpers.ts +1 -1
- package/src/web/features/network.ts +1 -0
- package/test/conversation.test.ts +220 -0
- package/tsconfig.build.json +12 -0
- package/tsconfig.json +1 -1
- package/scripts/examples/telegram-ink-ui.ts +0 -302
- package/scripts/examples/using-openai-codex.ts +0 -23
- package/scripts/examples/vm-loading-esm-modules.ts +0 -16
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import { Feature } from "../feature.js";
|
|
2
|
+
import { type Stats } from "fs";
|
|
3
|
+
type WalkOptions = {
|
|
4
|
+
directories?: boolean;
|
|
5
|
+
files?: boolean;
|
|
6
|
+
exclude?: string | string[];
|
|
7
|
+
include?: string | string[];
|
|
8
|
+
/** When true, returned paths are relative to `baseDir` instead of absolute. */
|
|
9
|
+
relative?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The FS feature provides methods for interacting with the file system, relative to the
|
|
13
|
+
* container's cwd.
|
|
14
|
+
*
|
|
15
|
+
* @extends Feature
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const fs = container.feature('fs')
|
|
20
|
+
* const content = fs.readFile('package.json')
|
|
21
|
+
* const exists = fs.exists('tsconfig.json')
|
|
22
|
+
* await fs.writeFileAsync('output.txt', 'Hello World')
|
|
23
|
+
* fs.writeFile('sync-output.txt', 'Hello Sync')
|
|
24
|
+
* fs.copy('src', 'backup/src')
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare class FS extends Feature {
|
|
28
|
+
static shortcut: "features.fs";
|
|
29
|
+
static stateSchema: import("zod").ZodObject<{
|
|
30
|
+
enabled: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
31
|
+
}, import("zod/v4/core").$loose>;
|
|
32
|
+
static optionsSchema: import("zod").ZodObject<{
|
|
33
|
+
name: import("zod").ZodOptional<import("zod").ZodString>;
|
|
34
|
+
_cacheKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
35
|
+
cached: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
36
|
+
enable: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
37
|
+
}, import("zod/v4/core").$strip>;
|
|
38
|
+
/**
|
|
39
|
+
* Synchronously reads a file and returns its contents as a string.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} path - The file path relative to the container's working directory
|
|
42
|
+
* @param {BufferEncoding | null} [encoding='utf-8'] - The encoding to use. Pass null to get a raw Buffer.
|
|
43
|
+
* @returns {string | Buffer} The file contents as a string (default) or Buffer if encoding is null
|
|
44
|
+
* @throws {Error} Throws an error if the file doesn't exist or cannot be read
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const content = fs.readFile('README.md')
|
|
49
|
+
* const buffer = fs.readFile('image.png', null)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
readFile(path: string, encoding?: BufferEncoding | null): string | Buffer;
|
|
53
|
+
/**
|
|
54
|
+
* Synchronously reads a file and returns its contents as a string.
|
|
55
|
+
* added this method because AI Assistants are understandly confused by this deviation from 2000's era node style
|
|
56
|
+
* @alias readFile
|
|
57
|
+
*/
|
|
58
|
+
readFileSync(path: string, encoding?: BufferEncoding | null): string | Buffer;
|
|
59
|
+
/**
|
|
60
|
+
* Asynchronously reads a file and returns its contents as a string.
|
|
61
|
+
*
|
|
62
|
+
* @param {string} path - The file path relative to the container's working directory
|
|
63
|
+
* @param {BufferEncoding | null} [encoding='utf-8'] - The encoding to use. Pass null to get a raw Buffer.
|
|
64
|
+
* @returns {Promise<string | Buffer>} A promise that resolves to the file contents as a string (default) or Buffer
|
|
65
|
+
* @throws {Error} Throws an error if the file doesn't exist or cannot be read
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const content = await fs.readFileAsync('data.txt')
|
|
70
|
+
* const buffer = await fs.readFileAsync('image.png', null)
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
readFileAsync(path: string, encoding?: BufferEncoding | null): Promise<string | Buffer>;
|
|
74
|
+
/**
|
|
75
|
+
* Synchronously reads and parses a JSON file.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} path - The path to the JSON file
|
|
78
|
+
* @returns {any} The parsed JSON content
|
|
79
|
+
* @throws {Error} Throws an error if the file doesn't exist, cannot be read, or contains invalid JSON
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const config = fs.readJson('config.json')
|
|
84
|
+
* console.log(config.version)
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
readJson(path: string): any;
|
|
88
|
+
/**
|
|
89
|
+
* Read and parse a JSON file synchronously
|
|
90
|
+
* @alias readJson
|
|
91
|
+
*/
|
|
92
|
+
readJsonSync(path: string): any;
|
|
93
|
+
/**
|
|
94
|
+
* Asynchronously reads and parses a JSON file.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} path - The path to the JSON file
|
|
97
|
+
* @returns {Promise<any>} A promise that resolves to the parsed JSON content
|
|
98
|
+
* @throws {Error} Throws an error if the file doesn't exist, cannot be read, or contains invalid JSON
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const config = await fs.readJsonAsync('config.json')
|
|
103
|
+
* console.log(config.version)
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
readJsonAsync(path: string): Promise<any>;
|
|
107
|
+
/**
|
|
108
|
+
* Synchronously reads the contents of a directory.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} path - The directory path relative to the container's working directory
|
|
111
|
+
* @returns {string[]} An array of file and directory names
|
|
112
|
+
* @throws {Error} Throws an error if the directory doesn't exist or cannot be read
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const entries = fs.readdirSync('src')
|
|
117
|
+
* console.log(entries) // ['index.ts', 'utils.ts', 'components']
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
readdirSync(path: string): string[];
|
|
121
|
+
/**
|
|
122
|
+
* Asynchronously reads the contents of a directory.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} path - The directory path relative to the container's working directory
|
|
125
|
+
* @returns {Promise<string[]>} A promise that resolves to an array of file and directory names
|
|
126
|
+
* @throws {Error} Throws an error if the directory doesn't exist or cannot be read
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const entries = await fs.readdir('src')
|
|
131
|
+
* console.log(entries) // ['index.ts', 'utils.ts', 'components']
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
readdir(path: string): Promise<string[]>;
|
|
135
|
+
/**
|
|
136
|
+
* Synchronously writes content to a file.
|
|
137
|
+
*
|
|
138
|
+
* @param {string} path - The file path where content should be written
|
|
139
|
+
* @param {Buffer | string} content - The content to write to the file
|
|
140
|
+
* @throws {Error} Throws an error if the file cannot be written
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* fs.writeFile('output.txt', 'Hello World')
|
|
145
|
+
* fs.writeFile('data.bin', Buffer.from([1, 2, 3, 4]))
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
writeFile(path: string, content: Buffer | string): void;
|
|
149
|
+
/**
|
|
150
|
+
* Asynchronously writes content to a file.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} path - The file path where content should be written
|
|
153
|
+
* @param {Buffer | string} content - The content to write to the file
|
|
154
|
+
* @returns {Promise<void>} A promise that resolves when the file is written
|
|
155
|
+
* @throws {Error} Throws an error if the file cannot be written
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* await fs.writeFileAsync('output.txt', 'Hello World')
|
|
160
|
+
* await fs.writeFileAsync('data.bin', Buffer.from([1, 2, 3, 4]))
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
writeFileAsync(path: string, content: Buffer | string): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Synchronously writes an object to a file as JSON.
|
|
166
|
+
*
|
|
167
|
+
* @param {string} path - The file path where the JSON should be written
|
|
168
|
+
* @param {any} data - The data to serialize as JSON
|
|
169
|
+
* @param {number} [indent=2] - The number of spaces to use for indentation
|
|
170
|
+
* @throws {Error} Throws an error if the file cannot be written
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* fs.writeJson('config.json', { version: '1.0.0', debug: false })
|
|
175
|
+
* ```
|
|
176
|
+
*/
|
|
177
|
+
writeJson(path: string, data: any, indent?: number): void;
|
|
178
|
+
/**
|
|
179
|
+
* Asynchronously writes an object to a file as JSON.
|
|
180
|
+
*
|
|
181
|
+
* @param {string} path - The file path where the JSON should be written
|
|
182
|
+
* @param {any} data - The data to serialize as JSON
|
|
183
|
+
* @param {number} [indent=2] - The number of spaces to use for indentation
|
|
184
|
+
* @returns {Promise<void>} A promise that resolves when the file is written
|
|
185
|
+
* @throws {Error} Throws an error if the file cannot be written
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* await fs.writeJsonAsync('config.json', { version: '1.0.0', debug: false })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
writeJsonAsync(path: string, data: any, indent?: number): Promise<void>;
|
|
193
|
+
/**
|
|
194
|
+
* Synchronously appends content to a file.
|
|
195
|
+
*
|
|
196
|
+
* @param {string} path - The file path to append to
|
|
197
|
+
* @param {Buffer | string} content - The content to append
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* fs.appendFile('log.txt', 'New line\n')
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
appendFile(path: string, content: Buffer | string): void;
|
|
205
|
+
/**
|
|
206
|
+
* Asynchronously appends content to a file.
|
|
207
|
+
*
|
|
208
|
+
* @param {string} path - The file path to append to
|
|
209
|
+
* @param {Buffer | string} content - The content to append
|
|
210
|
+
* @returns {Promise<void>} A promise that resolves when the content is appended
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* await fs.appendFileAsync('log.txt', 'New line\n')
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
appendFileAsync(path: string, content: Buffer | string): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Synchronously ensures a file exists with the specified content, creating directories as needed.
|
|
220
|
+
*
|
|
221
|
+
* @param {string} path - The file path where the file should be created
|
|
222
|
+
* @param {string} content - The content to write to the file
|
|
223
|
+
* @param {boolean} [overwrite=false] - Whether to overwrite the file if it already exists
|
|
224
|
+
* @returns {string} The resolved file path
|
|
225
|
+
* @throws {Error} Throws an error if the file cannot be created or written
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* fs.ensureFile('logs/app.log', '', false)
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
ensureFile(path: string, content: string, overwrite?: boolean): string;
|
|
233
|
+
/**
|
|
234
|
+
* Asynchronously ensures a file exists with the specified content, creating directories as needed.
|
|
235
|
+
*
|
|
236
|
+
* @param {string} path - The file path where the file should be created
|
|
237
|
+
* @param {string} content - The content to write to the file
|
|
238
|
+
* @param {boolean} [overwrite=false] - Whether to overwrite the file if it already exists
|
|
239
|
+
* @returns {Promise<string>} A promise that resolves to the absolute file path
|
|
240
|
+
* @throws {Error} Throws an error if the file cannot be created or written
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* await fs.ensureFileAsync('config/settings.json', '{}', true)
|
|
245
|
+
* ```
|
|
246
|
+
*/
|
|
247
|
+
ensureFileAsync(path: string, content: string, overwrite?: boolean): Promise<string>;
|
|
248
|
+
/**
|
|
249
|
+
* Synchronously ensures a directory exists, creating parent directories as needed.
|
|
250
|
+
*
|
|
251
|
+
* @param {string} path - The directory path to create
|
|
252
|
+
* @returns {string} The resolved directory path
|
|
253
|
+
* @throws {Error} Throws an error if the directory cannot be created
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* fs.ensureFolder('logs/debug')
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
ensureFolder(path: string): string;
|
|
261
|
+
/**
|
|
262
|
+
* Asynchronously ensures a directory exists, creating parent directories as needed.
|
|
263
|
+
*
|
|
264
|
+
* @param {string} path - The directory path to create
|
|
265
|
+
* @returns {Promise<string>} A promise that resolves to the resolved directory path
|
|
266
|
+
* @throws {Error} Throws an error if the directory cannot be created
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* await fs.ensureFolderAsync('logs/debug')
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
ensureFolderAsync(path: string): Promise<string>;
|
|
274
|
+
/**
|
|
275
|
+
* Alias for ensureFolder. Synchronously creates a directory and all parent directories.
|
|
276
|
+
*
|
|
277
|
+
* @param {string} folder - The directory path to create
|
|
278
|
+
* @returns {string} The resolved directory path
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* fs.mkdirp('deep/nested/path')
|
|
283
|
+
* ```
|
|
284
|
+
*/
|
|
285
|
+
mkdirp(folder: string): string;
|
|
286
|
+
/**
|
|
287
|
+
* Synchronously checks if a file or directory exists.
|
|
288
|
+
*
|
|
289
|
+
* @param {string} path - The path to check for existence
|
|
290
|
+
* @returns {boolean} True if the path exists, false otherwise
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* if (fs.exists('config.json')) {
|
|
295
|
+
* console.log('Config file exists!')
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
exists(path: string): boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Alias for exists. Synchronously checks if a file or directory exists.
|
|
302
|
+
*
|
|
303
|
+
* @param {string} path - The path to check for existence
|
|
304
|
+
* @returns {boolean} True if the path exists, false otherwise
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* ```typescript
|
|
308
|
+
* if (fs.existsSync('config.json')) {
|
|
309
|
+
* console.log('Config file exists!')
|
|
310
|
+
* }
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
existsSync(path: string): boolean;
|
|
314
|
+
/**
|
|
315
|
+
* Asynchronously checks if a file or directory exists.
|
|
316
|
+
*
|
|
317
|
+
* @param {string} path - The path to check for existence
|
|
318
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the path exists, false otherwise
|
|
319
|
+
*
|
|
320
|
+
* @example
|
|
321
|
+
* ```typescript
|
|
322
|
+
* if (await fs.existsAsync('config.json')) {
|
|
323
|
+
* console.log('Config file exists!')
|
|
324
|
+
* }
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
existsAsync(path: string): Promise<boolean>;
|
|
328
|
+
/**
|
|
329
|
+
* Checks if a path is a symbolic link.
|
|
330
|
+
*
|
|
331
|
+
* @param {string} path - The path to check
|
|
332
|
+
* @returns {boolean} True if the path is a symlink
|
|
333
|
+
*/
|
|
334
|
+
isSymlink(path: string): boolean;
|
|
335
|
+
/**
|
|
336
|
+
* Resolves a symlink to its real path. Returns the resolved path as-is if not a symlink.
|
|
337
|
+
*
|
|
338
|
+
* @param {string} path - The path to resolve
|
|
339
|
+
* @returns {string} The real path after resolving all symlinks
|
|
340
|
+
*/
|
|
341
|
+
realpath(path: string): string;
|
|
342
|
+
/**
|
|
343
|
+
* Synchronously returns the stat object for a file or directory.
|
|
344
|
+
*
|
|
345
|
+
* @param {string} path - The path to stat
|
|
346
|
+
* @returns {import('fs').Stats} The Stats object with size, timestamps, and type checks
|
|
347
|
+
* @throws {Error} Throws an error if the path doesn't exist
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* const info = fs.stat('package.json')
|
|
352
|
+
* console.log(info.size, info.mtime)
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
stat(path: string): Stats;
|
|
356
|
+
/**
|
|
357
|
+
* Asynchronously returns the stat object for a file or directory.
|
|
358
|
+
*
|
|
359
|
+
* @param {string} path - The path to stat
|
|
360
|
+
* @returns {Promise<import('fs').Stats>} A promise that resolves to the Stats object
|
|
361
|
+
* @throws {Error} Throws an error if the path doesn't exist
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```typescript
|
|
365
|
+
* const info = await fs.statAsync('package.json')
|
|
366
|
+
* console.log(info.size, info.mtime)
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
statAsync(path: string): Promise<Stats>;
|
|
370
|
+
/**
|
|
371
|
+
* Synchronously checks if a path is a file.
|
|
372
|
+
*
|
|
373
|
+
* @param {string} path - The path to check
|
|
374
|
+
* @returns {boolean} True if the path is a file, false otherwise
|
|
375
|
+
*
|
|
376
|
+
* @example
|
|
377
|
+
* ```typescript
|
|
378
|
+
* if (fs.isFile('package.json')) {
|
|
379
|
+
* console.log('It is a file')
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
isFile(path: string): boolean;
|
|
384
|
+
/**
|
|
385
|
+
* Asynchronously checks if a path is a file.
|
|
386
|
+
*
|
|
387
|
+
* @param {string} path - The path to check
|
|
388
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the path is a file
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* if (await fs.isFileAsync('package.json')) {
|
|
393
|
+
* console.log('It is a file')
|
|
394
|
+
* }
|
|
395
|
+
* ```
|
|
396
|
+
*/
|
|
397
|
+
isFileAsync(path: string): Promise<boolean>;
|
|
398
|
+
/**
|
|
399
|
+
* Synchronously checks if a path is a directory.
|
|
400
|
+
*
|
|
401
|
+
* @param {string} path - The path to check
|
|
402
|
+
* @returns {boolean} True if the path is a directory, false otherwise
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* ```typescript
|
|
406
|
+
* if (fs.isDirectory('src')) {
|
|
407
|
+
* console.log('It is a directory')
|
|
408
|
+
* }
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
isDirectory(path: string): boolean;
|
|
412
|
+
/**
|
|
413
|
+
* Asynchronously checks if a path is a directory.
|
|
414
|
+
*
|
|
415
|
+
* @param {string} path - The path to check
|
|
416
|
+
* @returns {Promise<boolean>} A promise that resolves to true if the path is a directory
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* if (await fs.isDirectoryAsync('src')) {
|
|
421
|
+
* console.log('It is a directory')
|
|
422
|
+
* }
|
|
423
|
+
* ```
|
|
424
|
+
*/
|
|
425
|
+
isDirectoryAsync(path: string): Promise<boolean>;
|
|
426
|
+
/**
|
|
427
|
+
* Synchronously removes a file.
|
|
428
|
+
*
|
|
429
|
+
* @param {string} path - The path of the file to remove
|
|
430
|
+
* @throws {Error} Throws an error if the file cannot be removed or doesn't exist
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* fs.rmSync('temp/cache.tmp')
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
rmSync(path: string): void;
|
|
438
|
+
/**
|
|
439
|
+
* Asynchronously removes a file.
|
|
440
|
+
*
|
|
441
|
+
* @param {string} path - The path of the file to remove
|
|
442
|
+
* @returns {Promise<void>} A promise that resolves when the file is removed
|
|
443
|
+
* @throws {Error} Throws an error if the file cannot be removed or doesn't exist
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* ```typescript
|
|
447
|
+
* await fs.rm('temp/cache.tmp')
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
rm(path: string): Promise<void>;
|
|
451
|
+
/**
|
|
452
|
+
* Synchronously removes a directory and all its contents.
|
|
453
|
+
*
|
|
454
|
+
* @param {string} dirPath - The path of the directory to remove
|
|
455
|
+
* @throws {Error} Throws an error if the directory cannot be removed
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```typescript
|
|
459
|
+
* fs.rmdirSync('temp/cache')
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
rmdirSync(dirPath: string): void;
|
|
463
|
+
/**
|
|
464
|
+
* Asynchronously removes a directory and all its contents.
|
|
465
|
+
*
|
|
466
|
+
* @param {string} dirPath - The path of the directory to remove
|
|
467
|
+
* @returns {Promise<void>} A promise that resolves when the directory is removed
|
|
468
|
+
* @throws {Error} Throws an error if the directory cannot be removed
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```typescript
|
|
472
|
+
* await fs.rmdir('temp/cache')
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
rmdir(dirPath: string): Promise<void>;
|
|
476
|
+
/**
|
|
477
|
+
* Synchronously copies a file or directory. Auto-detects whether the source is a file or directory
|
|
478
|
+
* and handles each appropriately (recursive for directories).
|
|
479
|
+
*
|
|
480
|
+
* @param {string} src - The source path to copy from
|
|
481
|
+
* @param {string} dest - The destination path to copy to
|
|
482
|
+
* @param {object} [options={}] - Copy options
|
|
483
|
+
* @param {boolean} [options.overwrite=true] - Whether to overwrite existing files at the destination
|
|
484
|
+
* @throws {Error} Throws an error if the source doesn't exist or the copy fails
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* fs.copy('src/config.json', 'backup/config.json')
|
|
489
|
+
* fs.copy('src', 'backup/src')
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
copy(src: string, dest: string, options?: {
|
|
493
|
+
overwrite?: boolean;
|
|
494
|
+
}): void;
|
|
495
|
+
/**
|
|
496
|
+
* Asynchronously copies a file or directory. Auto-detects whether the source is a file or directory
|
|
497
|
+
* and handles each appropriately (recursive for directories).
|
|
498
|
+
*
|
|
499
|
+
* @param {string} src - The source path to copy from
|
|
500
|
+
* @param {string} dest - The destination path to copy to
|
|
501
|
+
* @param {object} [options={}] - Copy options
|
|
502
|
+
* @param {boolean} [options.overwrite=true] - Whether to overwrite existing files at the destination
|
|
503
|
+
* @returns {Promise<void>} A promise that resolves when the copy is complete
|
|
504
|
+
* @throws {Error} Throws an error if the source doesn't exist or the copy fails
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* await fs.copyAsync('src/config.json', 'backup/config.json')
|
|
509
|
+
* await fs.copyAsync('src', 'backup/src')
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
copyAsync(src: string, dest: string, options?: {
|
|
513
|
+
overwrite?: boolean;
|
|
514
|
+
}): Promise<void>;
|
|
515
|
+
/**
|
|
516
|
+
* Synchronously moves (renames) a file or directory. Falls back to copy + delete for cross-device moves.
|
|
517
|
+
*
|
|
518
|
+
* @param {string} src - The source path to move from
|
|
519
|
+
* @param {string} dest - The destination path to move to
|
|
520
|
+
* @throws {Error} Throws an error if the source doesn't exist or the move fails
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```typescript
|
|
524
|
+
* fs.move('temp/draft.txt', 'final/document.txt')
|
|
525
|
+
* fs.move('old-dir', 'new-dir')
|
|
526
|
+
* ```
|
|
527
|
+
*/
|
|
528
|
+
move(src: string, dest: string): void;
|
|
529
|
+
/**
|
|
530
|
+
* Asynchronously moves (renames) a file or directory. Falls back to copy + delete for cross-device moves.
|
|
531
|
+
*
|
|
532
|
+
* @param {string} src - The source path to move from
|
|
533
|
+
* @param {string} dest - The destination path to move to
|
|
534
|
+
* @returns {Promise<void>} A promise that resolves when the move is complete
|
|
535
|
+
* @throws {Error} Throws an error if the source doesn't exist or the move fails
|
|
536
|
+
*
|
|
537
|
+
* @example
|
|
538
|
+
* ```typescript
|
|
539
|
+
* await fs.moveAsync('temp/draft.txt', 'final/document.txt')
|
|
540
|
+
* await fs.moveAsync('old-dir', 'new-dir')
|
|
541
|
+
* ```
|
|
542
|
+
*/
|
|
543
|
+
moveAsync(src: string, dest: string): Promise<void>;
|
|
544
|
+
/**
|
|
545
|
+
* Recursively walks a directory and returns arrays of file and directory paths.
|
|
546
|
+
* By default paths are absolute. Pass `relative: true` to get paths relative to `basePath`.
|
|
547
|
+
* Supports filtering with exclude and include glob patterns.
|
|
548
|
+
*
|
|
549
|
+
* @param {string} basePath - The base directory path to start walking from
|
|
550
|
+
* @param {WalkOptions} options - Options to configure the walk behavior
|
|
551
|
+
* @param {boolean} [options.directories=true] - Whether to include directories in results
|
|
552
|
+
* @param {boolean} [options.files=true] - Whether to include files in results
|
|
553
|
+
* @param {string | string[]} [options.exclude=[]] - Glob patterns to exclude (e.g. 'node_modules', '*.log')
|
|
554
|
+
* @param {string | string[]} [options.include=[]] - Glob patterns to include (only matching paths are returned)
|
|
555
|
+
* @param {boolean} [options.relative=false] - When true, returned paths are relative to basePath
|
|
556
|
+
* @returns {{ directories: string[], files: string[] }} Object containing arrays of directory and file paths
|
|
557
|
+
*
|
|
558
|
+
* @example
|
|
559
|
+
* ```typescript
|
|
560
|
+
* const result = fs.walk('src', { files: true, directories: false })
|
|
561
|
+
* const filtered = fs.walk('.', { exclude: ['node_modules', '.git'], include: ['*.ts'] })
|
|
562
|
+
* const relative = fs.walk('inbox', { relative: true }) // => { files: ['contact-1.json', ...] }
|
|
563
|
+
* ```
|
|
564
|
+
*/
|
|
565
|
+
walk(basePath: string, options?: WalkOptions): {
|
|
566
|
+
directories: string[];
|
|
567
|
+
files: string[];
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* Asynchronously and recursively walks a directory and returns arrays of file and directory paths.
|
|
571
|
+
* By default paths are absolute. Pass `relative: true` to get paths relative to `baseDir`.
|
|
572
|
+
* Supports filtering with exclude and include glob patterns.
|
|
573
|
+
*
|
|
574
|
+
* @param {string} baseDir - The base directory path to start walking from
|
|
575
|
+
* @param {WalkOptions} options - Options to configure the walk behavior
|
|
576
|
+
* @param {boolean} [options.directories=true] - Whether to include directories in results
|
|
577
|
+
* @param {boolean} [options.files=true] - Whether to include files in results
|
|
578
|
+
* @param {string | string[]} [options.exclude=[]] - Glob patterns to exclude (e.g. 'node_modules', '.git')
|
|
579
|
+
* @param {string | string[]} [options.include=[]] - Glob patterns to include (only matching paths are returned)
|
|
580
|
+
* @param {boolean} [options.relative=false] - When true, returned paths are relative to baseDir
|
|
581
|
+
* @returns {Promise<{ directories: string[], files: string[] }>} Promise resolving to object with directory and file paths
|
|
582
|
+
* @throws {Error} Throws an error if the directory cannot be accessed
|
|
583
|
+
*
|
|
584
|
+
* @example
|
|
585
|
+
* ```typescript
|
|
586
|
+
* const result = await fs.walkAsync('src', { exclude: ['node_modules'] })
|
|
587
|
+
* const files = await fs.walkAsync('inbox', { relative: true })
|
|
588
|
+
* // files.files => ['contact-1.json', 'subfolder/file.txt', ...]
|
|
589
|
+
* ```
|
|
590
|
+
*/
|
|
591
|
+
walkAsync(baseDir: string, options?: WalkOptions): Promise<{
|
|
592
|
+
directories: string[];
|
|
593
|
+
files: string[];
|
|
594
|
+
}>;
|
|
595
|
+
/**
|
|
596
|
+
* Synchronously finds a file by walking up the directory tree from the current working directory.
|
|
597
|
+
*
|
|
598
|
+
* @param {string} fileName - The name of the file to search for
|
|
599
|
+
* @param {object} [options={}] - Options for the search
|
|
600
|
+
* @param {string} [options.cwd] - The directory to start searching from (defaults to container.cwd)
|
|
601
|
+
* @returns {string | null} The absolute path to the found file, or null if not found
|
|
602
|
+
*
|
|
603
|
+
* @example
|
|
604
|
+
* ```typescript
|
|
605
|
+
* const packageJson = fs.findUp('package.json')
|
|
606
|
+
* if (packageJson) {
|
|
607
|
+
* console.log(`Found package.json at: ${packageJson}`)
|
|
608
|
+
* }
|
|
609
|
+
* ```
|
|
610
|
+
*/
|
|
611
|
+
findUp(fileName: string, options?: {
|
|
612
|
+
cwd?: string;
|
|
613
|
+
}): string | null;
|
|
614
|
+
/**
|
|
615
|
+
* Asynchronously finds a file by walking up the directory tree.
|
|
616
|
+
*
|
|
617
|
+
* @param {string} fileName - The name of the file to search for
|
|
618
|
+
* @param {object} [options={}] - Options for the search
|
|
619
|
+
* @param {string} [options.cwd] - The directory to start searching from (defaults to container.cwd)
|
|
620
|
+
* @param {boolean} [options.multiple=false] - Whether to find multiple instances of the file
|
|
621
|
+
* @returns {Promise<string | string[] | null>} The path(s) to the found file(s), or null if not found
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* ```typescript
|
|
625
|
+
* const packageJson = await fs.findUpAsync('package.json')
|
|
626
|
+
* const allPackageJsons = await fs.findUpAsync('package.json', { multiple: true })
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
findUpAsync(fileName: string, options?: {
|
|
630
|
+
cwd?: string;
|
|
631
|
+
multiple?: boolean;
|
|
632
|
+
}): Promise<string | string[] | null>;
|
|
633
|
+
}
|
|
634
|
+
export default FS;
|
|
635
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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