@inkeep/agents-cli 0.51.0 → 0.53.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/dist/agents-cli/package.js +6 -0
- package/dist/commands/config.js +1 -1
- package/dist/commands/dev.js +1 -1
- package/dist/commands/init.js +1 -1
- package/dist/commands/{pull-v3 → pull-v4}/component-parser.js +6 -12
- package/dist/commands/{pull-v3/utils → pull-v4}/component-registry.js +1 -1
- package/dist/commands/pull-v4/generators/agent-generator.js +258 -0
- package/dist/commands/pull-v4/generators/artifact-component-generator.js +69 -0
- package/dist/commands/pull-v4/generators/context-config-generator.js +264 -0
- package/dist/commands/pull-v4/generators/credential-generator.js +30 -0
- package/dist/commands/pull-v4/generators/data-component-generator.js +50 -0
- package/dist/commands/pull-v4/generators/environment-generator.js +123 -0
- package/dist/commands/pull-v4/generators/external-agent-generator.js +56 -0
- package/dist/commands/pull-v4/generators/function-tool-generator.js +48 -0
- package/dist/commands/pull-v4/generators/mcp-tool-generator.js +91 -0
- package/dist/commands/pull-v4/generators/project-generator.js +125 -0
- package/dist/commands/{pull-v3/components → pull-v4/generators}/skill-generator.js +1 -1
- package/dist/commands/pull-v4/generators/status-component-generator.js +35 -0
- package/dist/commands/pull-v4/generators/sub-agent-generator.js +269 -0
- package/dist/commands/pull-v4/generators/trigger-generator.js +58 -0
- package/dist/commands/pull-v4/introspect/index.js +365 -0
- package/dist/commands/pull-v4/introspect/test-helpers.js +143 -0
- package/dist/commands/pull-v4/introspect-generator.js +706 -0
- package/dist/commands/pull-v4/module-merge.js +405 -0
- package/dist/commands/pull-v4/utils.js +235 -0
- package/dist/commands/push.js +1 -1
- package/dist/commands/update.js +2 -2
- package/dist/index.js +18 -44
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js +18 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js +180 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/character.js +8 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/css.js +12 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/json.js +60 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/line.js +37 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js +31 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/word.js +118 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/index.js +11 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/patch/create.js +141 -0
- package/dist/node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/util/string.js +63 -0
- package/dist/utils/ci-environment.js +1 -1
- package/dist/utils/config.js +1 -1
- package/dist/utils/environment-loader.js +1 -1
- package/dist/utils/file-finder.js +1 -1
- package/dist/utils/mcp-runner.js +1 -1
- package/dist/utils/profile-config.js +1 -1
- package/dist/utils/profiles/profile-manager.js +1 -1
- package/dist/utils/project-directory.js +1 -1
- package/dist/utils/project-loader.js +1 -1
- package/dist/utils/version-check.js +6 -15
- package/package.json +5 -7
- package/dist/commands/pull-v3/component-updater.js +0 -768
- package/dist/commands/pull-v3/components/agent-generator.js +0 -255
- package/dist/commands/pull-v3/components/artifact-component-generator.js +0 -143
- package/dist/commands/pull-v3/components/context-config-generator.js +0 -190
- package/dist/commands/pull-v3/components/credential-generator.js +0 -89
- package/dist/commands/pull-v3/components/data-component-generator.js +0 -102
- package/dist/commands/pull-v3/components/environment-generator.js +0 -173
- package/dist/commands/pull-v3/components/external-agent-generator.js +0 -75
- package/dist/commands/pull-v3/components/function-tool-generator.js +0 -92
- package/dist/commands/pull-v3/components/mcp-tool-generator.js +0 -86
- package/dist/commands/pull-v3/components/project-generator.js +0 -157
- package/dist/commands/pull-v3/components/status-component-generator.js +0 -92
- package/dist/commands/pull-v3/components/sub-agent-generator.js +0 -295
- package/dist/commands/pull-v3/components/trigger-generator.js +0 -185
- package/dist/commands/pull-v3/index.js +0 -510
- package/dist/commands/pull-v3/introspect-generator.js +0 -286
- package/dist/commands/pull-v3/llm-content-merger.js +0 -192
- package/dist/commands/pull-v3/new-component-generator.js +0 -279
- package/dist/commands/pull-v3/project-comparator.js +0 -914
- package/dist/commands/pull-v3/project-index-generator.js +0 -32
- package/dist/commands/pull-v3/project-validator.js +0 -358
- package/dist/commands/pull-v3/targeted-typescript-placeholders.js +0 -173
- package/dist/commands/pull-v3/utils/component-tracker.js +0 -165
- package/dist/commands/pull-v3/utils/generator-utils.js +0 -146
- package/dist/commands/pull-v3/utils/model-provider-detector.js +0 -50
- package/dist/utils/url.js +0 -26
package/dist/index.js
CHANGED
|
@@ -9,32 +9,28 @@ import { initCommand } from "./commands/init.js";
|
|
|
9
9
|
import { listAgentsCommand } from "./commands/list-agents.js";
|
|
10
10
|
import { logoutCommand } from "./commands/logout.js";
|
|
11
11
|
import { profileAddCommand, profileCurrentCommand, profileListCommand, profileRemoveCommand, profileUseCommand } from "./commands/profile.js";
|
|
12
|
-
import {
|
|
12
|
+
import { PACKAGE_VERSION } from "./utils/version-check.js";
|
|
13
|
+
import { pullV4Command } from "./commands/pull-v4/introspect/index.js";
|
|
13
14
|
import { pushCommand } from "./commands/push.js";
|
|
14
15
|
import { statusCommand } from "./commands/status.js";
|
|
15
16
|
import { updateCommand } from "./commands/update.js";
|
|
16
17
|
import { whoamiCommand } from "./commands/whoami.js";
|
|
17
18
|
import { getLogger } from "@inkeep/agents-core";
|
|
18
|
-
import { readFileSync } from "node:fs";
|
|
19
|
-
import { dirname, join } from "node:path";
|
|
20
|
-
import { fileURLToPath } from "node:url";
|
|
21
19
|
import { Command } from "commander";
|
|
22
20
|
|
|
23
21
|
//#region src/index.ts
|
|
24
22
|
getLogger("config").updateOptions({ level: "silent" });
|
|
25
|
-
const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), "..", "package.json");
|
|
26
|
-
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
27
23
|
const program = new Command();
|
|
28
|
-
program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(
|
|
24
|
+
program.name("inkeep").description("CLI tool for Inkeep Agent Framework").version(PACKAGE_VERSION);
|
|
29
25
|
program.command("add [template]").description("Add a new template to the project").option("--project <template>", "Project template to add").option("--mcp <template>", "MCP template to add").option("--ui [component-id]", "Add UI component(s) to apps/agents-ui/src/ui (omit id to add all)").option("--list", "List available UI components (use with --ui)").option("--target-path <path>", "Target path to add the template to").option("--local-prefix <path_prefix>", "Use local templates from the given path prefix").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for authentication").option("--quiet", "Suppress profile/config logging").action(async (template, options) => {
|
|
30
26
|
await addCommand({
|
|
31
27
|
template,
|
|
32
28
|
...options
|
|
33
29
|
});
|
|
34
30
|
});
|
|
35
|
-
program.command("init [path]").description("Initialize a new Inkeep project (runs cloud onboarding wizard by default)").option("--local", "Use local/self-hosted mode instead of cloud onboarding").option("--no-interactive", "Skip interactive prompts").option("--config <path>", "Path to use as template for new configuration").action(async (path
|
|
31
|
+
program.command("init [path]").description("Initialize a new Inkeep project (runs cloud onboarding wizard by default)").option("--local", "Use local/self-hosted mode instead of cloud onboarding").option("--no-interactive", "Skip interactive prompts").option("--config <path>", "Path to use as template for new configuration").action(async (path, options) => {
|
|
36
32
|
await initCommand({
|
|
37
|
-
path
|
|
33
|
+
path,
|
|
38
34
|
...options
|
|
39
35
|
});
|
|
40
36
|
});
|
|
@@ -48,11 +44,9 @@ configCommand.command("set <key> <value>").description("Set a configuration valu
|
|
|
48
44
|
configCommand.command("list").description("List all configuration values").option("--config <path>", "Path to configuration file").option("--config-file-path <path>", "Path to configuration file (deprecated, use --config)").action(async (options) => {
|
|
49
45
|
await configListCommand({ config: options.config || options.configFilePath });
|
|
50
46
|
});
|
|
51
|
-
program.command("push").description("Push a project configuration to the backend").option("--project <project-id>", "Project ID or path to project directory").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--tenant-id <id>", "Override tenant ID").option("--agents-api-url <url>", "Override agents API URL").option("--env <environment>", "Environment to use for credential resolution (e.g., development, production)").option("--json", "Generate project data JSON file instead of pushing to backend").option("--all", "Push all projects found in current directory tree").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
program.command("pull").description("Pull project configuration with clean, efficient code generation").option("--project <project-id>", "Project ID to pull (or path to project directory). If in project directory, validates against local project ID.").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--env <environment>", "Environment file to generate (development, staging, production). Defaults to development").option("--json", "Output project data as JSON instead of generating files").option("--debug", "Enable debug logging").option("--verbose", "Enable verbose logging").option("--force", "Force regeneration even if no changes detected").option("--introspect", "Completely regenerate all files from scratch (no comparison needed)").option("--all", "Pull all projects for current tenant").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(async (options) => {
|
|
55
|
-
await pullV3Command(options);
|
|
47
|
+
program.command("push").description("Push a project configuration to the backend").option("--project <project-id>", "Project ID or path to project directory").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--tenant-id <id>", "Override tenant ID").option("--agents-api-url <url>", "Override agents API URL").option("--env <environment>", "Environment to use for credential resolution (e.g., development, production)").option("--json", "Generate project data JSON file instead of pushing to backend").option("--all", "Push all projects found in current directory tree").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(pushCommand);
|
|
48
|
+
program.command("pull").description("Pull project configuration with clean, efficient code generation").option("--project <project-id>", "Project ID to pull (or path to project directory). If in project directory, validates against local project ID.").option("--config <path>", "Path to configuration file").option("--profile <name>", "Profile to use for remote URLs and authentication").option("--env <environment>", "Environment file to generate (development, staging, production). Defaults to development").option("--json", "Output project data as JSON instead of generating files").option("--debug", "Enable debug logging").option("--verbose", "Enable verbose logging").option("--force", "Force regeneration even if no changes detected").option("--all", "Pull all projects for current tenant").option("--tag <tag>", "Use tagged config file (e.g., --tag prod loads prod.__inkeep.config.ts__)").option("--quiet", "Suppress profile/config logging").action(async (options) => {
|
|
49
|
+
await pullV4Command(options);
|
|
56
50
|
});
|
|
57
51
|
program.command("list-agent").description("List all available agents for a specific project").requiredOption("--project <project-id>", "Project ID to list agent for").option("--tenant-id <tenant-id>", "Tenant ID").option("--agents-api-url <url>", "Agents API URL").option("--config <path>", "Path to configuration file").option("--config-file-path <path>", "Path to configuration file (deprecated, use --config)").action(async (options) => {
|
|
58
52
|
const config = options.config || options.configFilePath;
|
|
@@ -72,37 +66,17 @@ program.command("dev").description("Start the Inkeep dashboard server").option("
|
|
|
72
66
|
openBrowser: options.openBrowser
|
|
73
67
|
});
|
|
74
68
|
});
|
|
75
|
-
program.command("update").description("Update @inkeep/agents-cli to the latest version").option("--check", "Check for updates without installing").option("--force", "Force update even if already on latest version").action(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
program.command("
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
program.command("logout").description("Log out of Inkeep Cloud").option("--profile <name>", "Profile to log out (defaults to active profile)").action(async (options) => {
|
|
82
|
-
await logoutCommand(options);
|
|
83
|
-
});
|
|
84
|
-
program.command("status").description("Show current profile, authentication state, and remote URLs").option("--profile <name>", "Profile to show status for (defaults to active profile)").action(async (options) => {
|
|
85
|
-
await statusCommand(options);
|
|
86
|
-
});
|
|
87
|
-
program.command("whoami").description("Display current authentication status (alias for status)").action(async () => {
|
|
88
|
-
await whoamiCommand();
|
|
89
|
-
});
|
|
69
|
+
program.command("update").description("Update @inkeep/agents-cli to the latest version").option("--check", "Check for updates without installing").option("--force", "Force update even if already on latest version").action(updateCommand);
|
|
70
|
+
program.command("login").description("Authenticate with Inkeep Cloud").option("--profile <name>", "Profile to authenticate (defaults to active profile)").action(loginCommand);
|
|
71
|
+
program.command("logout").description("Log out of Inkeep Cloud").option("--profile <name>", "Profile to log out (defaults to active profile)").action(logoutCommand);
|
|
72
|
+
program.command("status").description("Show current profile, authentication state, and remote URLs").option("--profile <name>", "Profile to show status for (defaults to active profile)").action(statusCommand);
|
|
73
|
+
program.command("whoami").description("Display current authentication status (alias for status)").action(whoamiCommand);
|
|
90
74
|
const profileCommand = program.command("profile").description("Manage CLI profiles for connecting to different remotes");
|
|
91
|
-
profileCommand.command("list").description("List all profiles").action(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
profileCommand.command("
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
profileCommand.command("use <name>").description("Set the active profile").action(async (name) => {
|
|
98
|
-
await profileUseCommand(name);
|
|
99
|
-
});
|
|
100
|
-
profileCommand.command("current").description("Display the active profile details").action(async () => {
|
|
101
|
-
await profileCurrentCommand();
|
|
102
|
-
});
|
|
103
|
-
profileCommand.command("remove <name>").description("Remove a profile").action(async (name) => {
|
|
104
|
-
await profileRemoveCommand(name);
|
|
105
|
-
});
|
|
75
|
+
profileCommand.command("list").description("List all profiles").action(profileListCommand);
|
|
76
|
+
profileCommand.command("add [name]").description("Add a new profile").action(profileAddCommand);
|
|
77
|
+
profileCommand.command("use <name>").description("Set the active profile").action(profileUseCommand);
|
|
78
|
+
profileCommand.command("current").description("Display the active profile details").action(profileCurrentCommand);
|
|
79
|
+
profileCommand.command("remove <name>").description("Remove a profile").action(profileRemoveCommand);
|
|
106
80
|
program.parse();
|
|
107
81
|
|
|
108
82
|
//#endregion
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Diff from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/array.js
|
|
4
|
+
var ArrayDiff = class extends Diff {
|
|
5
|
+
tokenize(value) {
|
|
6
|
+
return value.slice();
|
|
7
|
+
}
|
|
8
|
+
join(value) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
removeEmpty(value) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const arrayDiff = new ArrayDiff();
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/base.js
|
|
2
|
+
var Diff = class {
|
|
3
|
+
diff(oldStr, newStr, options = {}) {
|
|
4
|
+
let callback;
|
|
5
|
+
if (typeof options === "function") {
|
|
6
|
+
callback = options;
|
|
7
|
+
options = {};
|
|
8
|
+
} else if ("callback" in options) callback = options.callback;
|
|
9
|
+
const oldString = this.castInput(oldStr, options);
|
|
10
|
+
const newString = this.castInput(newStr, options);
|
|
11
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
12
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
13
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
14
|
+
}
|
|
15
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
16
|
+
var _a;
|
|
17
|
+
const done = (value) => {
|
|
18
|
+
value = this.postProcess(value, options);
|
|
19
|
+
if (callback) {
|
|
20
|
+
setTimeout(function() {
|
|
21
|
+
callback(value);
|
|
22
|
+
}, 0);
|
|
23
|
+
return;
|
|
24
|
+
} else return value;
|
|
25
|
+
};
|
|
26
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
27
|
+
let editLength = 1;
|
|
28
|
+
let maxEditLength = newLen + oldLen;
|
|
29
|
+
if (options.maxEditLength != null) maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
30
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
31
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
32
|
+
const bestPath = [{
|
|
33
|
+
oldPos: -1,
|
|
34
|
+
lastComponent: void 0
|
|
35
|
+
}];
|
|
36
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
37
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
38
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
39
|
+
const execEditLength = () => {
|
|
40
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
41
|
+
let basePath;
|
|
42
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
43
|
+
if (removePath) bestPath[diagonalPath - 1] = void 0;
|
|
44
|
+
let canAdd = false;
|
|
45
|
+
if (addPath) {
|
|
46
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
47
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
48
|
+
}
|
|
49
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
50
|
+
if (!canAdd && !canRemove) {
|
|
51
|
+
bestPath[diagonalPath] = void 0;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) basePath = this.addToPath(addPath, true, false, 0, options);
|
|
55
|
+
else basePath = this.addToPath(removePath, false, true, 1, options);
|
|
56
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
57
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
58
|
+
else {
|
|
59
|
+
bestPath[diagonalPath] = basePath;
|
|
60
|
+
if (basePath.oldPos + 1 >= oldLen) maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
61
|
+
if (newPos + 1 >= newLen) minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
editLength++;
|
|
65
|
+
};
|
|
66
|
+
if (callback) (function exec() {
|
|
67
|
+
setTimeout(function() {
|
|
68
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) return callback(void 0);
|
|
69
|
+
if (!execEditLength()) exec();
|
|
70
|
+
}, 0);
|
|
71
|
+
})();
|
|
72
|
+
else while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
73
|
+
const ret = execEditLength();
|
|
74
|
+
if (ret) return ret;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
78
|
+
const last = path.lastComponent;
|
|
79
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) return {
|
|
80
|
+
oldPos: path.oldPos + oldPosInc,
|
|
81
|
+
lastComponent: {
|
|
82
|
+
count: last.count + 1,
|
|
83
|
+
added,
|
|
84
|
+
removed,
|
|
85
|
+
previousComponent: last.previousComponent
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
else return {
|
|
89
|
+
oldPos: path.oldPos + oldPosInc,
|
|
90
|
+
lastComponent: {
|
|
91
|
+
count: 1,
|
|
92
|
+
added,
|
|
93
|
+
removed,
|
|
94
|
+
previousComponent: last
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
99
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
100
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
101
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
102
|
+
newPos++;
|
|
103
|
+
oldPos++;
|
|
104
|
+
commonCount++;
|
|
105
|
+
if (options.oneChangePerToken) basePath.lastComponent = {
|
|
106
|
+
count: 1,
|
|
107
|
+
previousComponent: basePath.lastComponent,
|
|
108
|
+
added: false,
|
|
109
|
+
removed: false
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (commonCount && !options.oneChangePerToken) basePath.lastComponent = {
|
|
113
|
+
count: commonCount,
|
|
114
|
+
previousComponent: basePath.lastComponent,
|
|
115
|
+
added: false,
|
|
116
|
+
removed: false
|
|
117
|
+
};
|
|
118
|
+
basePath.oldPos = oldPos;
|
|
119
|
+
return newPos;
|
|
120
|
+
}
|
|
121
|
+
equals(left, right, options) {
|
|
122
|
+
if (options.comparator) return options.comparator(left, right);
|
|
123
|
+
else return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
124
|
+
}
|
|
125
|
+
removeEmpty(array) {
|
|
126
|
+
const ret = [];
|
|
127
|
+
for (let i = 0; i < array.length; i++) if (array[i]) ret.push(array[i]);
|
|
128
|
+
return ret;
|
|
129
|
+
}
|
|
130
|
+
castInput(value, options) {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
tokenize(value, options) {
|
|
134
|
+
return Array.from(value);
|
|
135
|
+
}
|
|
136
|
+
join(chars) {
|
|
137
|
+
return chars.join("");
|
|
138
|
+
}
|
|
139
|
+
postProcess(changeObjects, options) {
|
|
140
|
+
return changeObjects;
|
|
141
|
+
}
|
|
142
|
+
get useLongestToken() {
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
146
|
+
const components = [];
|
|
147
|
+
let nextComponent;
|
|
148
|
+
while (lastComponent) {
|
|
149
|
+
components.push(lastComponent);
|
|
150
|
+
nextComponent = lastComponent.previousComponent;
|
|
151
|
+
delete lastComponent.previousComponent;
|
|
152
|
+
lastComponent = nextComponent;
|
|
153
|
+
}
|
|
154
|
+
components.reverse();
|
|
155
|
+
const componentLen = components.length;
|
|
156
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
157
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
158
|
+
const component = components[componentPos];
|
|
159
|
+
if (!component.removed) {
|
|
160
|
+
if (!component.added && this.useLongestToken) {
|
|
161
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
162
|
+
value = value.map(function(value$1, i) {
|
|
163
|
+
const oldValue = oldTokens[oldPos + i];
|
|
164
|
+
return oldValue.length > value$1.length ? oldValue : value$1;
|
|
165
|
+
});
|
|
166
|
+
component.value = this.join(value);
|
|
167
|
+
} else component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
168
|
+
newPos += component.count;
|
|
169
|
+
if (!component.added) oldPos += component.count;
|
|
170
|
+
} else {
|
|
171
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
172
|
+
oldPos += component.count;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return components;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
//#endregion
|
|
180
|
+
export { Diff as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Diff from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/css.js
|
|
4
|
+
var CssDiff = class extends Diff {
|
|
5
|
+
tokenize(value) {
|
|
6
|
+
return value.split(/([{}:;,]|\s+)/);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const cssDiff = new CssDiff();
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Diff from "./base.js";
|
|
2
|
+
import { tokenize } from "./line.js";
|
|
3
|
+
|
|
4
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/json.js
|
|
5
|
+
var JsonDiff = class extends Diff {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.tokenize = tokenize;
|
|
9
|
+
}
|
|
10
|
+
get useLongestToken() {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
castInput(value, options) {
|
|
14
|
+
const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
|
|
15
|
+
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
|
|
16
|
+
}
|
|
17
|
+
equals(left, right, options) {
|
|
18
|
+
return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const jsonDiff = new JsonDiff();
|
|
22
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
23
|
+
stack = stack || [];
|
|
24
|
+
replacementStack = replacementStack || [];
|
|
25
|
+
if (replacer) obj = replacer(key === void 0 ? "" : key, obj);
|
|
26
|
+
let i;
|
|
27
|
+
for (i = 0; i < stack.length; i += 1) if (stack[i] === obj) return replacementStack[i];
|
|
28
|
+
let canonicalizedObj;
|
|
29
|
+
if ("[object Array]" === Object.prototype.toString.call(obj)) {
|
|
30
|
+
stack.push(obj);
|
|
31
|
+
canonicalizedObj = new Array(obj.length);
|
|
32
|
+
replacementStack.push(canonicalizedObj);
|
|
33
|
+
for (i = 0; i < obj.length; i += 1) canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
34
|
+
stack.pop();
|
|
35
|
+
replacementStack.pop();
|
|
36
|
+
return canonicalizedObj;
|
|
37
|
+
}
|
|
38
|
+
if (obj && obj.toJSON) obj = obj.toJSON();
|
|
39
|
+
if (typeof obj === "object" && obj !== null) {
|
|
40
|
+
stack.push(obj);
|
|
41
|
+
canonicalizedObj = {};
|
|
42
|
+
replacementStack.push(canonicalizedObj);
|
|
43
|
+
const sortedKeys = [];
|
|
44
|
+
let key$1;
|
|
45
|
+
for (key$1 in obj)
|
|
46
|
+
/* istanbul ignore else */
|
|
47
|
+
if (Object.prototype.hasOwnProperty.call(obj, key$1)) sortedKeys.push(key$1);
|
|
48
|
+
sortedKeys.sort();
|
|
49
|
+
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
50
|
+
key$1 = sortedKeys[i];
|
|
51
|
+
canonicalizedObj[key$1] = canonicalize(obj[key$1], stack, replacementStack, replacer, key$1);
|
|
52
|
+
}
|
|
53
|
+
stack.pop();
|
|
54
|
+
replacementStack.pop();
|
|
55
|
+
} else canonicalizedObj = obj;
|
|
56
|
+
return canonicalizedObj;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { canonicalize };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Diff from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/line.js
|
|
4
|
+
var LineDiff = class extends Diff {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.tokenize = tokenize;
|
|
8
|
+
}
|
|
9
|
+
equals(left, right, options) {
|
|
10
|
+
if (options.ignoreWhitespace) {
|
|
11
|
+
if (!options.newlineIsToken || !left.includes("\n")) left = left.trim();
|
|
12
|
+
if (!options.newlineIsToken || !right.includes("\n")) right = right.trim();
|
|
13
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
14
|
+
if (left.endsWith("\n")) left = left.slice(0, -1);
|
|
15
|
+
if (right.endsWith("\n")) right = right.slice(0, -1);
|
|
16
|
+
}
|
|
17
|
+
return super.equals(left, right, options);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const lineDiff = new LineDiff();
|
|
21
|
+
function diffLines(oldStr, newStr, options) {
|
|
22
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
23
|
+
}
|
|
24
|
+
function tokenize(value, options) {
|
|
25
|
+
if (options.stripTrailingCr) value = value.replace(/\r\n/g, "\n");
|
|
26
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
27
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) linesAndNewlines.pop();
|
|
28
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
29
|
+
const line = linesAndNewlines[i];
|
|
30
|
+
if (i % 2 && !options.newlineIsToken) retLines[retLines.length - 1] += line;
|
|
31
|
+
else retLines.push(line);
|
|
32
|
+
}
|
|
33
|
+
return retLines;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { diffLines, lineDiff, tokenize };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Diff from "./base.js";
|
|
2
|
+
|
|
3
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/sentence.js
|
|
4
|
+
function isSentenceEndPunct(char) {
|
|
5
|
+
return char == "." || char == "!" || char == "?";
|
|
6
|
+
}
|
|
7
|
+
var SentenceDiff = class extends Diff {
|
|
8
|
+
tokenize(value) {
|
|
9
|
+
var _a;
|
|
10
|
+
const result = [];
|
|
11
|
+
let tokenStartI = 0;
|
|
12
|
+
for (let i = 0; i < value.length; i++) {
|
|
13
|
+
if (i == value.length - 1) {
|
|
14
|
+
result.push(value.slice(tokenStartI));
|
|
15
|
+
break;
|
|
16
|
+
}
|
|
17
|
+
if (isSentenceEndPunct(value[i]) && value[i + 1].match(/\s/)) {
|
|
18
|
+
result.push(value.slice(tokenStartI, i + 1));
|
|
19
|
+
i = tokenStartI = i + 1;
|
|
20
|
+
while ((_a = value[i + 1]) === null || _a === void 0 ? void 0 : _a.match(/\s/)) i++;
|
|
21
|
+
result.push(value.slice(tokenStartI, i + 1));
|
|
22
|
+
tokenStartI = i + 1;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const sentenceDiff = new SentenceDiff();
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import Diff from "./base.js";
|
|
2
|
+
import { leadingWs, longestCommonPrefix, longestCommonSuffix, maximumOverlap, removePrefix, removeSuffix, replacePrefix, replaceSuffix, trailingWs } from "../util/string.js";
|
|
3
|
+
|
|
4
|
+
//#region ../node_modules/.pnpm/diff@8.0.3/node_modules/diff/libesm/diff/word.js
|
|
5
|
+
const extendedWordChars = "a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
|
|
6
|
+
const tokenizeIncludingWhitespace = new RegExp(`[${extendedWordChars}]+|\\s+|[^${extendedWordChars}]`, "ug");
|
|
7
|
+
var WordDiff = class extends Diff {
|
|
8
|
+
equals(left, right, options) {
|
|
9
|
+
if (options.ignoreCase) {
|
|
10
|
+
left = left.toLowerCase();
|
|
11
|
+
right = right.toLowerCase();
|
|
12
|
+
}
|
|
13
|
+
return left.trim() === right.trim();
|
|
14
|
+
}
|
|
15
|
+
tokenize(value, options = {}) {
|
|
16
|
+
let parts;
|
|
17
|
+
if (options.intlSegmenter) {
|
|
18
|
+
const segmenter = options.intlSegmenter;
|
|
19
|
+
if (segmenter.resolvedOptions().granularity != "word") throw new Error("The segmenter passed must have a granularity of \"word\"");
|
|
20
|
+
parts = [];
|
|
21
|
+
for (const segmentObj of Array.from(segmenter.segment(value))) {
|
|
22
|
+
const segment = segmentObj.segment;
|
|
23
|
+
if (parts.length && /\s/.test(parts[parts.length - 1]) && /\s/.test(segment)) parts[parts.length - 1] += segment;
|
|
24
|
+
else parts.push(segment);
|
|
25
|
+
}
|
|
26
|
+
} else parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
27
|
+
const tokens = [];
|
|
28
|
+
let prevPart = null;
|
|
29
|
+
parts.forEach((part) => {
|
|
30
|
+
if (/\s/.test(part)) if (prevPart == null) tokens.push(part);
|
|
31
|
+
else tokens.push(tokens.pop() + part);
|
|
32
|
+
else if (prevPart != null && /\s/.test(prevPart)) if (tokens[tokens.length - 1] == prevPart) tokens.push(tokens.pop() + part);
|
|
33
|
+
else tokens.push(prevPart + part);
|
|
34
|
+
else tokens.push(part);
|
|
35
|
+
prevPart = part;
|
|
36
|
+
});
|
|
37
|
+
return tokens;
|
|
38
|
+
}
|
|
39
|
+
join(tokens) {
|
|
40
|
+
return tokens.map((token, i) => {
|
|
41
|
+
if (i == 0) return token;
|
|
42
|
+
else return token.replace(/^\s+/, "");
|
|
43
|
+
}).join("");
|
|
44
|
+
}
|
|
45
|
+
postProcess(changes, options) {
|
|
46
|
+
if (!changes || options.oneChangePerToken) return changes;
|
|
47
|
+
let lastKeep = null;
|
|
48
|
+
let insertion = null;
|
|
49
|
+
let deletion = null;
|
|
50
|
+
changes.forEach((change) => {
|
|
51
|
+
if (change.added) insertion = change;
|
|
52
|
+
else if (change.removed) deletion = change;
|
|
53
|
+
else {
|
|
54
|
+
if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
55
|
+
lastKeep = change;
|
|
56
|
+
insertion = null;
|
|
57
|
+
deletion = null;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
if (insertion || deletion) dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
61
|
+
return changes;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const wordDiff = new WordDiff();
|
|
65
|
+
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
66
|
+
if (deletion && insertion) {
|
|
67
|
+
const oldWsPrefix = leadingWs(deletion.value);
|
|
68
|
+
const oldWsSuffix = trailingWs(deletion.value);
|
|
69
|
+
const newWsPrefix = leadingWs(insertion.value);
|
|
70
|
+
const newWsSuffix = trailingWs(insertion.value);
|
|
71
|
+
if (startKeep) {
|
|
72
|
+
const commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
73
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
74
|
+
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
75
|
+
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
76
|
+
}
|
|
77
|
+
if (endKeep) {
|
|
78
|
+
const commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
79
|
+
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
80
|
+
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
81
|
+
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
82
|
+
}
|
|
83
|
+
} else if (insertion) {
|
|
84
|
+
if (startKeep) {
|
|
85
|
+
const ws = leadingWs(insertion.value);
|
|
86
|
+
insertion.value = insertion.value.substring(ws.length);
|
|
87
|
+
}
|
|
88
|
+
if (endKeep) {
|
|
89
|
+
const ws = leadingWs(endKeep.value);
|
|
90
|
+
endKeep.value = endKeep.value.substring(ws.length);
|
|
91
|
+
}
|
|
92
|
+
} else if (startKeep && endKeep) {
|
|
93
|
+
const newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
|
|
94
|
+
const newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
95
|
+
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
96
|
+
const newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
97
|
+
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
98
|
+
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
99
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
100
|
+
} else if (endKeep) {
|
|
101
|
+
const endKeepWsPrefix = leadingWs(endKeep.value);
|
|
102
|
+
const overlap = maximumOverlap(trailingWs(deletion.value), endKeepWsPrefix);
|
|
103
|
+
deletion.value = removeSuffix(deletion.value, overlap);
|
|
104
|
+
} else if (startKeep) {
|
|
105
|
+
const overlap = maximumOverlap(trailingWs(startKeep.value), leadingWs(deletion.value));
|
|
106
|
+
deletion.value = removePrefix(deletion.value, overlap);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
var WordsWithSpaceDiff = class extends Diff {
|
|
110
|
+
tokenize(value) {
|
|
111
|
+
const regex = new RegExp(`(\\r?\\n)|[${extendedWordChars}]+|[^\\S\\n\\r]+|[^${extendedWordChars}]`, "ug");
|
|
112
|
+
return value.match(regex) || [];
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const wordsWithSpaceDiff = new WordsWithSpaceDiff();
|
|
116
|
+
|
|
117
|
+
//#endregion
|
|
118
|
+
export { };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Diff from "./diff/base.js";
|
|
2
|
+
import "./diff/character.js";
|
|
3
|
+
import "./diff/word.js";
|
|
4
|
+
import { diffLines, lineDiff } from "./diff/line.js";
|
|
5
|
+
import "./diff/sentence.js";
|
|
6
|
+
import "./diff/css.js";
|
|
7
|
+
import { canonicalize } from "./diff/json.js";
|
|
8
|
+
import "./diff/array.js";
|
|
9
|
+
import { INCLUDE_HEADERS, createTwoFilesPatch, formatPatch, structuredPatch } from "./patch/create.js";
|
|
10
|
+
|
|
11
|
+
export { };
|