toolcraft 0.0.388 → 0.0.389
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/composition.json +2 -2
- package/dist/composition.json +2 -2
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +14 -13
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -2
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +4 -4
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +3 -1
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +2 -2
package/composition.json
CHANGED
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "toolcraft",
|
|
116
|
-
"version": "0.0.
|
|
116
|
+
"version": "0.0.389",
|
|
117
117
|
"license": "MIT"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
"name": "toolcraft-schema",
|
|
126
|
-
"version": "0.0.
|
|
126
|
+
"version": "0.0.389",
|
|
127
127
|
"license": "MIT"
|
|
128
128
|
},
|
|
129
129
|
{
|
package/dist/composition.json
CHANGED
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
"name": "toolcraft",
|
|
116
|
-
"version": "0.0.
|
|
116
|
+
"version": "0.0.389",
|
|
117
117
|
"license": "MIT"
|
|
118
118
|
},
|
|
119
119
|
{
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
125
|
"name": "toolcraft-schema",
|
|
126
|
-
"version": "0.0.
|
|
126
|
+
"version": "0.0.389",
|
|
127
127
|
"license": "MIT"
|
|
128
128
|
},
|
|
129
129
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import
|
|
2
|
+
import nativePath from "node:path";
|
|
3
3
|
import { renderTemplate } from "toolcraft-design";
|
|
4
4
|
import { isConfigObject } from "../types.js";
|
|
5
5
|
import { getConfigFormat, detectFormat } from "../formats/index.js";
|
|
@@ -47,6 +47,7 @@ async function assertRegularWriteTarget(context, targetPath) {
|
|
|
47
47
|
// plant one to redirect a credential/config write outside it. Symlinks at or
|
|
48
48
|
// above home are legitimate system links (e.g. /tmp -> /private/tmp on macOS,
|
|
49
49
|
// /var -> /private/var) and must not block writes, so bound the walk at home.
|
|
50
|
+
const path = context.paths ?? nativePath;
|
|
50
51
|
const boundary = path.dirname(path.resolve(context.homeDir));
|
|
51
52
|
let currentPath = path.resolve(targetPath);
|
|
52
53
|
while (currentPath !== boundary) {
|
|
@@ -157,7 +158,7 @@ export function resolveMutationDetails(mutation, context, options) {
|
|
|
157
158
|
};
|
|
158
159
|
}
|
|
159
160
|
try {
|
|
160
|
-
const targetPath = resolvePath(rawTarget, context.homeDir, context.pathMapper);
|
|
161
|
+
const targetPath = resolvePath(rawTarget, context.homeDir, context.pathMapper, context.paths);
|
|
161
162
|
return {
|
|
162
163
|
kind: mutation.kind,
|
|
163
164
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -267,7 +268,7 @@ export async function applyMutation(mutation, context, options) {
|
|
|
267
268
|
// ============================================================================
|
|
268
269
|
async function applyEnsureDirectory(mutation, context, options) {
|
|
269
270
|
const rawPath = resolveValue(mutation.path, options);
|
|
270
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
271
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
271
272
|
const details = {
|
|
272
273
|
kind: mutation.kind,
|
|
273
274
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -289,7 +290,7 @@ async function applyEnsureDirectory(mutation, context, options) {
|
|
|
289
290
|
}
|
|
290
291
|
async function applyRemoveDirectory(mutation, context, options) {
|
|
291
292
|
const rawPath = resolveValue(mutation.path, options);
|
|
292
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
293
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
293
294
|
const details = {
|
|
294
295
|
kind: mutation.kind,
|
|
295
296
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -334,7 +335,7 @@ async function applyRemoveDirectory(mutation, context, options) {
|
|
|
334
335
|
}
|
|
335
336
|
async function applyRemoveFile(mutation, context, options) {
|
|
336
337
|
const rawPath = resolveValue(mutation.target, options);
|
|
337
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
338
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
338
339
|
const details = {
|
|
339
340
|
kind: mutation.kind,
|
|
340
341
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -380,7 +381,7 @@ async function applyRemoveFile(mutation, context, options) {
|
|
|
380
381
|
}
|
|
381
382
|
async function applyChmod(mutation, context, options) {
|
|
382
383
|
const rawPath = resolveValue(mutation.target, options);
|
|
383
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
384
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
384
385
|
const details = {
|
|
385
386
|
kind: mutation.kind,
|
|
386
387
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -422,7 +423,7 @@ async function applyChmod(mutation, context, options) {
|
|
|
422
423
|
}
|
|
423
424
|
async function applyBackup(mutation, context, options) {
|
|
424
425
|
const rawPath = resolveValue(mutation.target, options);
|
|
425
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
426
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
426
427
|
const details = {
|
|
427
428
|
kind: mutation.kind,
|
|
428
429
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -468,7 +469,7 @@ async function applyBackup(mutation, context, options) {
|
|
|
468
469
|
}
|
|
469
470
|
async function applyRestoreBackup(mutation, context, options) {
|
|
470
471
|
const rawPath = resolveValue(mutation.target, options);
|
|
471
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
472
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
472
473
|
const details = {
|
|
473
474
|
kind: mutation.kind,
|
|
474
475
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -551,7 +552,7 @@ function isGeneratedBackupName(entry, targetName) {
|
|
|
551
552
|
// ============================================================================
|
|
552
553
|
async function applyConfigMerge(mutation, context, options) {
|
|
553
554
|
const rawPath = resolveValue(mutation.target, options);
|
|
554
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
555
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
555
556
|
const details = {
|
|
556
557
|
kind: mutation.kind,
|
|
557
558
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -604,7 +605,7 @@ async function applyConfigMerge(mutation, context, options) {
|
|
|
604
605
|
}
|
|
605
606
|
async function applyConfigPrune(mutation, context, options) {
|
|
606
607
|
const rawPath = resolveValue(mutation.target, options);
|
|
607
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
608
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
608
609
|
const details = {
|
|
609
610
|
kind: mutation.kind,
|
|
610
611
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -669,7 +670,7 @@ async function applyConfigPrune(mutation, context, options) {
|
|
|
669
670
|
}
|
|
670
671
|
async function applyConfigTransform(mutation, context, options) {
|
|
671
672
|
const rawPath = resolveValue(mutation.target, options);
|
|
672
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
673
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
673
674
|
const details = {
|
|
674
675
|
kind: mutation.kind,
|
|
675
676
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -745,7 +746,7 @@ async function applyTemplateWrite(mutation, context, options) {
|
|
|
745
746
|
"Provide templates function to runMutations context.");
|
|
746
747
|
}
|
|
747
748
|
const rawPath = resolveValue(mutation.target, options);
|
|
748
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
749
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
749
750
|
const details = {
|
|
750
751
|
kind: mutation.kind,
|
|
751
752
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -776,7 +777,7 @@ async function applyTemplateMerge(mutation, context, options, formatName) {
|
|
|
776
777
|
"Provide templates function to runMutations context.");
|
|
777
778
|
}
|
|
778
779
|
const rawPath = resolveValue(mutation.target, options);
|
|
779
|
-
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper);
|
|
780
|
+
const targetPath = resolvePath(rawPath, context.homeDir, context.pathMapper, context.paths);
|
|
780
781
|
const details = {
|
|
781
782
|
kind: mutation.kind,
|
|
782
783
|
label: mutation.label ?? describeMutation(mutation.kind, targetPath),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import nativePath from "node:path";
|
|
1
2
|
import type { PathMapper } from "../types.js";
|
|
2
3
|
/**
|
|
3
4
|
* Expand ~ shortcut to the provided home directory.
|
|
4
5
|
*/
|
|
5
|
-
export declare function expandHome(targetPath: string, homeDir: string): string;
|
|
6
|
+
export declare function expandHome(targetPath: string, homeDir: string, path?: typeof nativePath): string;
|
|
6
7
|
/**
|
|
7
8
|
* Validate that a path is home-relative (starts with ~).
|
|
8
9
|
* Throws if the path is not home-relative.
|
|
@@ -14,4 +15,4 @@ export declare function validateHomePath(targetPath: string): void;
|
|
|
14
15
|
* 2. Expands ~ to home directory
|
|
15
16
|
* 3. If pathMapper is provided, maps the directory portion and reconstructs the path
|
|
16
17
|
*/
|
|
17
|
-
export declare function resolvePath(rawPath: string, homeDir: string, pathMapper?: PathMapper): string;
|
|
18
|
+
export declare function resolvePath(rawPath: string, homeDir: string, pathMapper?: PathMapper, path?: typeof nativePath): string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import nativePath from "node:path";
|
|
2
2
|
/**
|
|
3
3
|
* Expand ~ shortcut to the provided home directory.
|
|
4
4
|
*/
|
|
5
|
-
export function expandHome(targetPath, homeDir) {
|
|
5
|
+
export function expandHome(targetPath, homeDir, path = nativePath) {
|
|
6
6
|
if (!targetPath?.startsWith("~")) {
|
|
7
7
|
return targetPath;
|
|
8
8
|
}
|
|
@@ -42,9 +42,9 @@ export function validateHomePath(targetPath) {
|
|
|
42
42
|
* 2. Expands ~ to home directory
|
|
43
43
|
* 3. If pathMapper is provided, maps the directory portion and reconstructs the path
|
|
44
44
|
*/
|
|
45
|
-
export function resolvePath(rawPath, homeDir, pathMapper) {
|
|
45
|
+
export function resolvePath(rawPath, homeDir, pathMapper, path = nativePath) {
|
|
46
46
|
validateHomePath(rawPath);
|
|
47
|
-
const expanded = expandHome(rawPath, homeDir);
|
|
47
|
+
const expanded = expandHome(rawPath, homeDir, path);
|
|
48
48
|
const canonicalHome = path.resolve(homeDir);
|
|
49
49
|
const canonicalExpanded = path.resolve(expanded);
|
|
50
50
|
const relative = path.relative(canonicalHome, canonicalExpanded);
|
|
@@ -13,7 +13,7 @@ export interface FileSystem {
|
|
|
13
13
|
}): Promise<void>;
|
|
14
14
|
mkdir(path: string, options?: {
|
|
15
15
|
recursive: boolean;
|
|
16
|
-
}): Promise<
|
|
16
|
+
}): Promise<unknown>;
|
|
17
17
|
rename(oldPath: string, newPath: string): Promise<void>;
|
|
18
18
|
unlink(path: string): Promise<void>;
|
|
19
19
|
rm?(path: string, options?: {
|
|
@@ -52,6 +52,8 @@ export interface PathMapper {
|
|
|
52
52
|
}): string;
|
|
53
53
|
}
|
|
54
54
|
export interface MutationContext {
|
|
55
|
+
/** Path operations for the filesystem namespace; defaults to native host paths. */
|
|
56
|
+
paths?: typeof import("node:path");
|
|
55
57
|
/** Filesystem interface - required */
|
|
56
58
|
fs: FileSystem;
|
|
57
59
|
/** Home directory for ~ expansion - required */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.389",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"yaml"
|
|
163
163
|
],
|
|
164
164
|
"optionalDependencies": {
|
|
165
|
-
"toolcraft-schema": "0.0.
|
|
165
|
+
"toolcraft-schema": "0.0.389",
|
|
166
166
|
"toolcraft-design": "*",
|
|
167
167
|
"@poe-code/frontmatter": "*",
|
|
168
168
|
"@poe-code/agent-mcp-config": "*",
|