agentsmesh 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +2 -0
- package/dist/canonical.js +242 -123
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +257 -250
- package/dist/engine.js +398 -157
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +419 -166
- package/dist/index.js.map +1 -1
- package/dist/{init-C3pMnqoU.d.ts → init-BtgoRmIs.d.ts} +5 -6
- package/dist/lessons.d.ts +2 -2
- package/dist/lessons.js +198 -61
- package/dist/lessons.js.map +1 -1
- package/dist/targets.js +231 -103
- package/dist/targets.js.map +1 -1
- package/package.json +2 -2
package/dist/targets.js
CHANGED
|
@@ -2,8 +2,9 @@ import { z } from 'zod';
|
|
|
2
2
|
import { stringify, parseDocument, parse, isMap, Document, isSeq, isScalar, Scalar, Pair, YAMLSeq } from 'yaml';
|
|
3
3
|
import { existsSync, realpathSync, readFileSync, constants, statSync } from 'fs';
|
|
4
4
|
import { basename, win32, posix, join, relative, dirname, extname } from 'path';
|
|
5
|
-
import { readFile, readdir, mkdir, lstat,
|
|
6
|
-
import 'timers/promises';
|
|
5
|
+
import { readFile, readdir, mkdir, lstat, open, rm, realpath, stat, rename, access } from 'fs/promises';
|
|
6
|
+
import { setTimeout } from 'timers/promises';
|
|
7
|
+
import { randomUUID } from 'crypto';
|
|
7
8
|
import { parse as parse$1, stringify as stringify$1 } from 'smol-toml';
|
|
8
9
|
import { Buffer } from 'buffer';
|
|
9
10
|
|
|
@@ -740,13 +741,19 @@ function shouldNormalizeLineEndings(path) {
|
|
|
740
741
|
const base = basename(path).toLowerCase();
|
|
741
742
|
return TEXT_DOTFILES.has(base);
|
|
742
743
|
}
|
|
744
|
+
function isBinaryPayloadPath(path) {
|
|
745
|
+
return BINARY_EXTENSIONS.has(extname(path).toLowerCase());
|
|
746
|
+
}
|
|
747
|
+
function payloadEncodingFor(path) {
|
|
748
|
+
return isBinaryPayloadPath(path) ? "latin1" : "utf-8";
|
|
749
|
+
}
|
|
743
750
|
function normalizeLineEndings(content) {
|
|
744
751
|
return content.replace(/\r\n?/g, "\n");
|
|
745
752
|
}
|
|
746
753
|
function executableModeFor(path) {
|
|
747
754
|
return EXECUTABLE_SCRIPT_EXTENSIONS.has(extname(path).toLowerCase()) ? 493 : void 0;
|
|
748
755
|
}
|
|
749
|
-
var UTF8_BOM, TEXT_EXTENSIONS, TEXT_DOTFILES, EXECUTABLE_SCRIPT_EXTENSIONS;
|
|
756
|
+
var UTF8_BOM, TEXT_EXTENSIONS, TEXT_DOTFILES, BINARY_EXTENSIONS, EXECUTABLE_SCRIPT_EXTENSIONS;
|
|
750
757
|
var init_fs_text_encoding = __esm({
|
|
751
758
|
"src/utils/filesystem/fs-text-encoding.ts"() {
|
|
752
759
|
UTF8_BOM = "\uFEFF";
|
|
@@ -791,9 +798,109 @@ var init_fs_text_encoding = __esm({
|
|
|
791
798
|
".rooignore",
|
|
792
799
|
".antigravityignore"
|
|
793
800
|
]);
|
|
801
|
+
BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
802
|
+
".png",
|
|
803
|
+
".jpg",
|
|
804
|
+
".jpeg",
|
|
805
|
+
".gif",
|
|
806
|
+
".bmp",
|
|
807
|
+
".ico",
|
|
808
|
+
".webp",
|
|
809
|
+
".avif",
|
|
810
|
+
".tiff",
|
|
811
|
+
".pdf",
|
|
812
|
+
".zip",
|
|
813
|
+
".gz",
|
|
814
|
+
".tgz",
|
|
815
|
+
".bz2",
|
|
816
|
+
".xz",
|
|
817
|
+
".7z",
|
|
818
|
+
".rar",
|
|
819
|
+
".jar",
|
|
820
|
+
".woff",
|
|
821
|
+
".woff2",
|
|
822
|
+
".ttf",
|
|
823
|
+
".otf",
|
|
824
|
+
".eot",
|
|
825
|
+
".mp3",
|
|
826
|
+
".mp4",
|
|
827
|
+
".wav",
|
|
828
|
+
".ogg",
|
|
829
|
+
".webm",
|
|
830
|
+
".mov",
|
|
831
|
+
".wasm",
|
|
832
|
+
".bin",
|
|
833
|
+
".dat",
|
|
834
|
+
".db",
|
|
835
|
+
".sqlite",
|
|
836
|
+
".so",
|
|
837
|
+
".dylib",
|
|
838
|
+
".dll",
|
|
839
|
+
".exe",
|
|
840
|
+
".class",
|
|
841
|
+
".pyc",
|
|
842
|
+
// Office and design documents are zip or proprietary containers.
|
|
843
|
+
".xlsx",
|
|
844
|
+
".xls",
|
|
845
|
+
".docx",
|
|
846
|
+
".doc",
|
|
847
|
+
".pptx",
|
|
848
|
+
".ppt",
|
|
849
|
+
".odt",
|
|
850
|
+
".ods",
|
|
851
|
+
".psd",
|
|
852
|
+
".ai",
|
|
853
|
+
".sketch",
|
|
854
|
+
".fig",
|
|
855
|
+
".heic",
|
|
856
|
+
".heif",
|
|
857
|
+
// Archives, columnar data, models and compressed payloads.
|
|
858
|
+
".tar",
|
|
859
|
+
".zst",
|
|
860
|
+
".br",
|
|
861
|
+
".lz4",
|
|
862
|
+
".parquet",
|
|
863
|
+
".avro",
|
|
864
|
+
".orc",
|
|
865
|
+
".pkl",
|
|
866
|
+
".npy",
|
|
867
|
+
".npz",
|
|
868
|
+
".onnx",
|
|
869
|
+
".pt",
|
|
870
|
+
".safetensors",
|
|
871
|
+
".gguf",
|
|
872
|
+
".sqlite3",
|
|
873
|
+
".avi",
|
|
874
|
+
".mkv",
|
|
875
|
+
".flac",
|
|
876
|
+
".aac",
|
|
877
|
+
".m4a",
|
|
878
|
+
".ttc"
|
|
879
|
+
]);
|
|
794
880
|
EXECUTABLE_SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([".sh", ".bash", ".zsh"]);
|
|
795
881
|
}
|
|
796
882
|
});
|
|
883
|
+
async function renameWithRetry(from, to, options = {}) {
|
|
884
|
+
const attempts = options.attempts ?? 5;
|
|
885
|
+
const delayMs = options.delayMs ?? 50;
|
|
886
|
+
for (let attempt = 0; ; attempt++) {
|
|
887
|
+
try {
|
|
888
|
+
await rename(from, to);
|
|
889
|
+
return;
|
|
890
|
+
} catch (err) {
|
|
891
|
+
const code = err.code;
|
|
892
|
+
const transient = code !== void 0 && TRANSIENT_RENAME_CODES.has(code);
|
|
893
|
+
if (!transient || attempt >= attempts - 1) throw err;
|
|
894
|
+
await setTimeout(delayMs * 2 ** attempt);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
var TRANSIENT_RENAME_CODES;
|
|
899
|
+
var init_rename_retry = __esm({
|
|
900
|
+
"src/utils/filesystem/rename-retry.ts"() {
|
|
901
|
+
TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY", "ENOTEMPTY", "EEXIST"]);
|
|
902
|
+
}
|
|
903
|
+
});
|
|
797
904
|
function shouldSkipRecursiveBranch(segments) {
|
|
798
905
|
if (segments.length > MAX_RECURSIVE_DEPTH) return true;
|
|
799
906
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -884,13 +991,10 @@ var init_fs_traverse = __esm({
|
|
|
884
991
|
MAX_SEGMENT_REPETITIONS = 3;
|
|
885
992
|
}
|
|
886
993
|
});
|
|
887
|
-
var init_rename_retry = __esm({
|
|
888
|
-
"src/utils/filesystem/rename-retry.ts"() {
|
|
889
|
-
}
|
|
890
|
-
});
|
|
891
994
|
async function readFileSafe(path) {
|
|
892
995
|
try {
|
|
893
|
-
const data = await readFile(path,
|
|
996
|
+
const data = await readFile(path, payloadEncodingFor(path));
|
|
997
|
+
if (isBinaryPayloadPath(path)) return data;
|
|
894
998
|
return data.startsWith(UTF8_BOM) ? data.slice(UTF8_BOM.length) : data;
|
|
895
999
|
} catch (err) {
|
|
896
1000
|
const e = err;
|
|
@@ -914,40 +1018,28 @@ async function writeFileAtomic(path, content, options) {
|
|
|
914
1018
|
{ errnoCode: "EISDIR" }
|
|
915
1019
|
);
|
|
916
1020
|
}
|
|
917
|
-
if (info.isSymbolicLink()) {
|
|
918
|
-
await unlink(path).catch((e) => {
|
|
919
|
-
if (e.code !== "ENOENT") throw e;
|
|
920
|
-
});
|
|
921
|
-
}
|
|
922
1021
|
} catch (err) {
|
|
923
1022
|
if (err instanceof FileSystemError) throw err;
|
|
924
1023
|
const e = err;
|
|
925
1024
|
if (e.code !== "ENOENT") throw err;
|
|
926
1025
|
}
|
|
927
|
-
const tmpPath = `${path}.tmp`;
|
|
1026
|
+
const tmpPath = `${path}.tmp-${randomUUID()}`;
|
|
928
1027
|
const payload = shouldNormalizeLineEndings(path) ? normalizeLineEndings(content) : content;
|
|
929
1028
|
const mode = executableModeFor(path);
|
|
1029
|
+
let handle;
|
|
1030
|
+
let ownsTemporaryFile = false;
|
|
930
1031
|
try {
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
}
|
|
939
|
-
const writeOpts = {
|
|
940
|
-
encoding: "utf-8",
|
|
941
|
-
flag: "w"
|
|
942
|
-
};
|
|
943
|
-
if (mode !== void 0) writeOpts.mode = mode;
|
|
944
|
-
await writeFile(tmpPath, payload, writeOpts);
|
|
945
|
-
await rename(tmpPath, path);
|
|
946
|
-
if (mode !== void 0) {
|
|
947
|
-
await chmod(path, mode);
|
|
948
|
-
}
|
|
1032
|
+
handle = await open(tmpPath, "wx", mode);
|
|
1033
|
+
ownsTemporaryFile = true;
|
|
1034
|
+
await handle.writeFile(payload, payloadEncodingFor(path));
|
|
1035
|
+
if (mode !== void 0) await handle.chmod(mode);
|
|
1036
|
+
await handle.close();
|
|
1037
|
+
handle = void 0;
|
|
1038
|
+
await renameWithRetry(tmpPath, path);
|
|
949
1039
|
} catch (err) {
|
|
950
|
-
await
|
|
1040
|
+
await handle?.close().catch(() => {
|
|
1041
|
+
});
|
|
1042
|
+
if (ownsTemporaryFile) await rm(tmpPath, { force: true }).catch(() => {
|
|
951
1043
|
});
|
|
952
1044
|
const e = err;
|
|
953
1045
|
throw new FileSystemError(
|
|
@@ -972,6 +1064,7 @@ var init_fs = __esm({
|
|
|
972
1064
|
"src/utils/filesystem/fs.ts"() {
|
|
973
1065
|
init_errors();
|
|
974
1066
|
init_fs_text_encoding();
|
|
1067
|
+
init_rename_retry();
|
|
975
1068
|
init_fs_traverse();
|
|
976
1069
|
init_fs_text_encoding();
|
|
977
1070
|
init_rename_retry();
|
|
@@ -2006,43 +2099,72 @@ function isGlobAdjacent(content, start, end) {
|
|
|
2006
2099
|
const next = end < content.length ? content.at(end) : "";
|
|
2007
2100
|
return prev === "*" || next === "*";
|
|
2008
2101
|
}
|
|
2102
|
+
var NON_REWRITABLE_BARE_FILES, PATH_TOKEN, LINE_NUMBER_SUFFIX;
|
|
2103
|
+
var init_link_rebaser_helpers = __esm({
|
|
2104
|
+
"src/core/reference/link-rebaser-helpers.ts"() {
|
|
2105
|
+
init_path_helpers();
|
|
2106
|
+
init_link_format_registry();
|
|
2107
|
+
NON_REWRITABLE_BARE_FILES = /* @__PURE__ */ new Set([
|
|
2108
|
+
"AGENTS.md",
|
|
2109
|
+
"CLAUDE.md",
|
|
2110
|
+
"GEMINI.md",
|
|
2111
|
+
"codex.md",
|
|
2112
|
+
".windsurfrules",
|
|
2113
|
+
".cursorrules"
|
|
2114
|
+
]);
|
|
2115
|
+
PATH_TOKEN = /(?:\.\.[\\/]|\.\/|\.\\|\/[A-Za-z0-9._-]|[A-Za-z]:[\\/][A-Za-z0-9._-]|\.agentsmesh[\\/]|\.claude[\\/]|\.cursor[\\/]|\.github[\\/]|\.continue[\\/]|\.junie[\\/]|\.kiro[\\/]|\.gemini[\\/]|\.clinerules[\\/]|\.cline[\\/]|\.codex[\\/]|\.agents[\\/]|\.windsurf[\\/]|\.roo[\\/]|(?:[A-Za-z0-9._-]+[\\/])+|[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+)[A-Za-z0-9._@%+~:\\/-]*/g;
|
|
2116
|
+
LINE_NUMBER_SUFFIX = /(?::(\d+)){1,2}$/;
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
|
|
2120
|
+
// src/core/reference/protected-ranges.ts
|
|
2121
|
+
function extendAcrossBalancedParens(content, end) {
|
|
2122
|
+
let cursor = end;
|
|
2123
|
+
while (content[cursor] === "(") {
|
|
2124
|
+
let depth = 0;
|
|
2125
|
+
let scan = cursor;
|
|
2126
|
+
while (scan < content.length) {
|
|
2127
|
+
const ch = content[scan];
|
|
2128
|
+
if (ch === "(") depth += 1;
|
|
2129
|
+
else if (ch === ")") {
|
|
2130
|
+
depth -= 1;
|
|
2131
|
+
if (depth === 0) break;
|
|
2132
|
+
} else if (ch === void 0 || /\s/.test(ch)) return cursor;
|
|
2133
|
+
scan += 1;
|
|
2134
|
+
}
|
|
2135
|
+
if (depth !== 0) return cursor;
|
|
2136
|
+
cursor = scan + 1;
|
|
2137
|
+
while (cursor < content.length && !/[\s<>()\]]/.test(content.charAt(cursor))) cursor += 1;
|
|
2138
|
+
}
|
|
2139
|
+
return cursor;
|
|
2140
|
+
}
|
|
2009
2141
|
function protectedRanges(content) {
|
|
2010
2142
|
const ranges = [];
|
|
2011
2143
|
for (const pattern of getLinkFormatRegistry().protectedSchemes) {
|
|
2012
2144
|
const globalPattern = pattern.flags.includes("g") ? pattern : new RegExp(pattern.source, `${pattern.flags}g`);
|
|
2013
2145
|
for (const match of content.matchAll(globalPattern)) {
|
|
2014
|
-
|
|
2146
|
+
const start = match.index;
|
|
2147
|
+
ranges.push([start, extendAcrossBalancedParens(content, start + match[0].length)]);
|
|
2015
2148
|
}
|
|
2016
2149
|
}
|
|
2017
2150
|
for (const match of content.matchAll(FENCED_CODE_BLOCK)) {
|
|
2018
|
-
ranges.push([match.index
|
|
2151
|
+
ranges.push([match.index, match.index + match[0].length]);
|
|
2019
2152
|
}
|
|
2020
2153
|
for (const match of content.matchAll(ROOT_GENERATION_CONTRACT_BLOCK)) {
|
|
2021
|
-
ranges.push([match.index
|
|
2154
|
+
ranges.push([match.index, match.index + match[0].length]);
|
|
2022
2155
|
}
|
|
2023
2156
|
for (const match of content.matchAll(EMBEDDED_RULES_BLOCK)) {
|
|
2024
|
-
ranges.push([match.index
|
|
2157
|
+
ranges.push([match.index, match.index + match[0].length]);
|
|
2025
2158
|
}
|
|
2026
2159
|
return ranges;
|
|
2027
2160
|
}
|
|
2028
|
-
var
|
|
2029
|
-
var
|
|
2030
|
-
"src/core/reference/
|
|
2031
|
-
init_path_helpers();
|
|
2161
|
+
var FENCED_CODE_BLOCK, ROOT_GENERATION_CONTRACT_BLOCK, EMBEDDED_RULES_BLOCK;
|
|
2162
|
+
var init_protected_ranges = __esm({
|
|
2163
|
+
"src/core/reference/protected-ranges.ts"() {
|
|
2032
2164
|
init_link_format_registry();
|
|
2033
|
-
NON_REWRITABLE_BARE_FILES = /* @__PURE__ */ new Set([
|
|
2034
|
-
"AGENTS.md",
|
|
2035
|
-
"CLAUDE.md",
|
|
2036
|
-
"GEMINI.md",
|
|
2037
|
-
"codex.md",
|
|
2038
|
-
".windsurfrules",
|
|
2039
|
-
".cursorrules"
|
|
2040
|
-
]);
|
|
2041
2165
|
FENCED_CODE_BLOCK = /^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm;
|
|
2042
2166
|
ROOT_GENERATION_CONTRACT_BLOCK = /<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g;
|
|
2043
2167
|
EMBEDDED_RULES_BLOCK = /<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g;
|
|
2044
|
-
PATH_TOKEN = /(?:\.\.[\\/]|\.\/|\.\\|\/[A-Za-z0-9._-]|[A-Za-z]:[\\/][A-Za-z0-9._-]|\.agentsmesh[\\/]|\.claude[\\/]|\.cursor[\\/]|\.github[\\/]|\.continue[\\/]|\.junie[\\/]|\.kiro[\\/]|\.gemini[\\/]|\.clinerules[\\/]|\.cline[\\/]|\.codex[\\/]|\.agents[\\/]|\.windsurf[\\/]|\.roo[\\/]|(?:[A-Za-z0-9._-]+[\\/])+|[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+)[A-Za-z0-9._@%+~:\\/-]*/g;
|
|
2045
|
-
LINE_NUMBER_SUFFIX = /(?::(\d+)){1,2}$/;
|
|
2046
2168
|
}
|
|
2047
2169
|
});
|
|
2048
2170
|
|
|
@@ -2535,6 +2657,7 @@ var init_link_rebaser = __esm({
|
|
|
2535
2657
|
"src/core/reference/link-rebaser.ts"() {
|
|
2536
2658
|
init_path_helpers();
|
|
2537
2659
|
init_link_rebaser_helpers();
|
|
2660
|
+
init_protected_ranges();
|
|
2538
2661
|
init_link_rebaser_output();
|
|
2539
2662
|
init_link_rebaser_resolution();
|
|
2540
2663
|
init_link_uri_encoding();
|
|
@@ -6928,51 +7051,7 @@ var init_embedded_rules = __esm({
|
|
|
6928
7051
|
}
|
|
6929
7052
|
});
|
|
6930
7053
|
|
|
6931
|
-
// src/
|
|
6932
|
-
function failSyntax(filePath2, cause, onParseError) {
|
|
6933
|
-
const error = new CanonicalParseError(filePath2, cause);
|
|
6934
|
-
throw error;
|
|
6935
|
-
}
|
|
6936
|
-
var init_syntax_error = __esm({
|
|
6937
|
-
"src/canonical/features/syntax-error.ts"() {
|
|
6938
|
-
init_errors();
|
|
6939
|
-
}
|
|
6940
|
-
});
|
|
6941
|
-
|
|
6942
|
-
// src/canonical/features/mcp.ts
|
|
6943
|
-
function parseStringMap(raw) {
|
|
6944
|
-
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
6945
|
-
return Object.fromEntries(
|
|
6946
|
-
Object.entries(raw).filter((entry) => typeof entry[1] === "string")
|
|
6947
|
-
);
|
|
6948
|
-
}
|
|
6949
|
-
function parseServer(raw) {
|
|
6950
|
-
if (!raw || typeof raw !== "object") return null;
|
|
6951
|
-
const obj = raw;
|
|
6952
|
-
const type = typeof obj.type === "string" ? obj.type : "stdio";
|
|
6953
|
-
const env = parseStringMap(obj.env);
|
|
6954
|
-
const description = typeof obj.description === "string" ? obj.description : void 0;
|
|
6955
|
-
const url = typeof obj.url === "string" ? obj.url : "";
|
|
6956
|
-
if (url) {
|
|
6957
|
-
return {
|
|
6958
|
-
...description !== void 0 && { description },
|
|
6959
|
-
type,
|
|
6960
|
-
url,
|
|
6961
|
-
headers: parseStringMap(obj.headers),
|
|
6962
|
-
env
|
|
6963
|
-
};
|
|
6964
|
-
}
|
|
6965
|
-
const command = typeof obj.command === "string" ? obj.command : "";
|
|
6966
|
-
if (!command) return null;
|
|
6967
|
-
const args = Array.isArray(obj.args) ? obj.args.filter((x) => typeof x === "string") : [];
|
|
6968
|
-
return {
|
|
6969
|
-
...description !== void 0 && { description },
|
|
6970
|
-
type,
|
|
6971
|
-
command,
|
|
6972
|
-
args,
|
|
6973
|
-
env
|
|
6974
|
-
};
|
|
6975
|
-
}
|
|
7054
|
+
// src/utils/text/json-comments.ts
|
|
6976
7055
|
function stripJsonComments(text) {
|
|
6977
7056
|
let result2 = "";
|
|
6978
7057
|
let i = 0;
|
|
@@ -7021,6 +7100,56 @@ function stripJsonComments(text) {
|
|
|
7021
7100
|
}
|
|
7022
7101
|
return result2;
|
|
7023
7102
|
}
|
|
7103
|
+
var init_json_comments = __esm({
|
|
7104
|
+
"src/utils/text/json-comments.ts"() {
|
|
7105
|
+
}
|
|
7106
|
+
});
|
|
7107
|
+
|
|
7108
|
+
// src/canonical/features/syntax-error.ts
|
|
7109
|
+
function failSyntax(filePath2, cause, onParseError) {
|
|
7110
|
+
const error = new CanonicalParseError(filePath2, cause);
|
|
7111
|
+
throw error;
|
|
7112
|
+
}
|
|
7113
|
+
var init_syntax_error = __esm({
|
|
7114
|
+
"src/canonical/features/syntax-error.ts"() {
|
|
7115
|
+
init_errors();
|
|
7116
|
+
}
|
|
7117
|
+
});
|
|
7118
|
+
|
|
7119
|
+
// src/canonical/features/mcp.ts
|
|
7120
|
+
function parseStringMap(raw) {
|
|
7121
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
7122
|
+
return Object.fromEntries(
|
|
7123
|
+
Object.entries(raw).filter((entry) => typeof entry[1] === "string")
|
|
7124
|
+
);
|
|
7125
|
+
}
|
|
7126
|
+
function parseServer(raw) {
|
|
7127
|
+
if (!raw || typeof raw !== "object") return null;
|
|
7128
|
+
const obj = raw;
|
|
7129
|
+
const type = typeof obj.type === "string" ? obj.type : "stdio";
|
|
7130
|
+
const env = parseStringMap(obj.env);
|
|
7131
|
+
const description = typeof obj.description === "string" ? obj.description : void 0;
|
|
7132
|
+
const url = typeof obj.url === "string" ? obj.url : "";
|
|
7133
|
+
if (url) {
|
|
7134
|
+
return {
|
|
7135
|
+
...description !== void 0 && { description },
|
|
7136
|
+
type,
|
|
7137
|
+
url,
|
|
7138
|
+
headers: parseStringMap(obj.headers),
|
|
7139
|
+
env
|
|
7140
|
+
};
|
|
7141
|
+
}
|
|
7142
|
+
const command = typeof obj.command === "string" ? obj.command : "";
|
|
7143
|
+
if (!command) return null;
|
|
7144
|
+
const args = Array.isArray(obj.args) ? obj.args.filter((x) => typeof x === "string") : [];
|
|
7145
|
+
return {
|
|
7146
|
+
...description !== void 0 && { description },
|
|
7147
|
+
type,
|
|
7148
|
+
command,
|
|
7149
|
+
args,
|
|
7150
|
+
env
|
|
7151
|
+
};
|
|
7152
|
+
}
|
|
7024
7153
|
async function parseMcp(mcpPath, onParseError) {
|
|
7025
7154
|
const content = await readFileSafe(mcpPath);
|
|
7026
7155
|
if (!content) return null;
|
|
@@ -7043,6 +7172,7 @@ async function parseMcp(mcpPath, onParseError) {
|
|
|
7043
7172
|
}
|
|
7044
7173
|
var init_mcp = __esm({
|
|
7045
7174
|
"src/canonical/features/mcp.ts"() {
|
|
7175
|
+
init_json_comments();
|
|
7046
7176
|
init_syntax_error();
|
|
7047
7177
|
init_fs();
|
|
7048
7178
|
}
|
|
@@ -8374,7 +8504,7 @@ ${rawBody}`;
|
|
|
8374
8504
|
});
|
|
8375
8505
|
}
|
|
8376
8506
|
function generateMcp3(canonical) {
|
|
8377
|
-
if (!canonical.mcp
|
|
8507
|
+
if (!canonical.mcp) return [];
|
|
8378
8508
|
const content = JSON.stringify({ mcpServers: canonical.mcp.mcpServers }, null, 2);
|
|
8379
8509
|
return [{ path: CLAUDE_MCP_JSON, content }];
|
|
8380
8510
|
}
|
|
@@ -8409,14 +8539,12 @@ function generatePermissions4(canonical) {
|
|
|
8409
8539
|
if (!canonical.permissions) return [];
|
|
8410
8540
|
const { allow, deny } = canonical.permissions;
|
|
8411
8541
|
const ask = canonical.permissions.ask ?? [];
|
|
8412
|
-
if (allow.length === 0 && deny.length === 0 && ask.length === 0) return [];
|
|
8413
8542
|
const content = JSON.stringify({ permissions: { allow, deny, ask } }, null, 2);
|
|
8414
8543
|
return [{ path: CLAUDE_SETTINGS, content }];
|
|
8415
8544
|
}
|
|
8416
8545
|
function generateHooks3(canonical) {
|
|
8417
|
-
if (!canonical.hooks
|
|
8546
|
+
if (!canonical.hooks) return [];
|
|
8418
8547
|
const claudeHooks = buildClaudeHooksObjectFromCanonical(canonical);
|
|
8419
|
-
if (Object.keys(claudeHooks).length === 0) return [];
|
|
8420
8548
|
const content = JSON.stringify({ hooks: claudeHooks }, null, 2);
|
|
8421
8549
|
return [{ path: CLAUDE_SETTINGS, content }];
|
|
8422
8550
|
}
|
|
@@ -20234,9 +20362,9 @@ var init_config_toml = __esm({
|
|
|
20234
20362
|
function isValidKimiPermissionPattern(pattern) {
|
|
20235
20363
|
const trimmed = pattern.trim();
|
|
20236
20364
|
if (trimmed.length === 0) return false;
|
|
20237
|
-
const
|
|
20238
|
-
if (
|
|
20239
|
-
return trimmed.endsWith(")") &&
|
|
20365
|
+
const open2 = trimmed.indexOf("(");
|
|
20366
|
+
if (open2 === -1) return true;
|
|
20367
|
+
return trimmed.endsWith(")") && open2 > 0;
|
|
20240
20368
|
}
|
|
20241
20369
|
function listOf(permissions, key) {
|
|
20242
20370
|
return permissions[key] ?? [];
|