@jixo/cli 0.22.0 → 0.23.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/bundle/index.js +251 -133
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +83 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/daemon.d.ts +5 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +20 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/doctor/config.d.ts +3 -0
- package/dist/commands/doctor/config.d.ts.map +1 -0
- package/dist/commands/doctor/config.js +17 -0
- package/dist/commands/doctor/config.js.map +1 -0
- package/dist/commands/doctor/doctor.d.ts +3 -0
- package/dist/commands/doctor/doctor.d.ts.map +1 -0
- package/dist/commands/doctor/doctor.js +158 -0
- package/dist/commands/doctor/doctor.js.map +1 -0
- package/dist/commands/doctor/doctor.test.d.ts +2 -0
- package/dist/commands/doctor/doctor.test.d.ts.map +1 -0
- package/dist/commands/doctor/doctor.test.js +14 -0
- package/dist/commands/doctor/doctor.test.js.map +1 -0
- package/dist/commands/doctor/index.d.ts +2 -0
- package/dist/commands/doctor/index.d.ts.map +1 -0
- package/dist/commands/doctor/index.js +8 -0
- package/dist/commands/doctor/index.js.map +1 -0
- package/dist/commands/doctor/types.d.ts +45 -0
- package/dist/commands/doctor/types.d.ts.map +1 -0
- package/dist/commands/doctor/types.js +3 -0
- package/dist/commands/doctor/types.js.map +1 -0
- package/dist/commands/google-aistudio.d.ts.map +1 -1
- package/dist/commands/google-aistudio.js +29 -4
- package/dist/commands/google-aistudio.js.map +1 -1
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +40 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/tasks/run.d.ts +10 -0
- package/dist/commands/tasks/run.d.ts.map +1 -0
- package/dist/commands/tasks/run.js +44 -0
- package/dist/commands/tasks/run.js.map +1 -0
- package/dist/config.d.ts +15 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +23 -0
- package/dist/config.js.map +1 -0
- package/dist/env.d.ts +6 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +16 -0
- package/dist/env.js.map +1 -0
- package/dist/prompts.json +14 -2
- package/package.json +5 -4
package/bundle/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
import path, { dirname, join } from "node:path";
|
|
4
|
-
import fs, { mkdirSync, promises, readFileSync, readdirSync, realpathSync, statSync, watch, writeFileSync } from "node:fs";
|
|
4
|
+
import fs, { existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, statSync, watch, writeFileSync } from "node:fs";
|
|
5
5
|
import assert3, { notStrictEqual, strictEqual } from "assert";
|
|
6
6
|
import * as path$1 from "path";
|
|
7
7
|
import path10, { basename, dirname as dirname$1, extname, join as join$1, normalize, relative, resolve } from "path";
|
|
@@ -22,7 +22,7 @@ import * as readline from "node:readline";
|
|
|
22
22
|
import { promisify, stripVTControlCharacters } from "node:util";
|
|
23
23
|
import { EventEmitter, on, once } from "node:events";
|
|
24
24
|
import { finished } from "node:stream/promises";
|
|
25
|
-
import fsPromises, { mkdir, rm, writeFile as writeFile$1 } from "node:fs/promises";
|
|
25
|
+
import fsPromises, { copyFile, mkdir, rm, writeFile as writeFile$1 } from "node:fs/promises";
|
|
26
26
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
27
27
|
import { builtinModules, createRequire as createRequire$1 } from "module";
|
|
28
28
|
import v8 from "v8";
|
|
@@ -1769,7 +1769,7 @@ var import_get_caller_file = __toESM$1(require_get_caller_file(), 1);
|
|
|
1769
1769
|
const __dirname$1 = fileURLToPath$1(import.meta.url);
|
|
1770
1770
|
const mainFilename = __dirname$1.substring(0, __dirname$1.lastIndexOf("node_modules"));
|
|
1771
1771
|
const require$2 = createRequire(import.meta.url);
|
|
1772
|
-
var esm_default$
|
|
1772
|
+
var esm_default$3 = {
|
|
1773
1773
|
assert: {
|
|
1774
1774
|
notStrictEqual,
|
|
1775
1775
|
strictEqual
|
|
@@ -4681,18 +4681,22 @@ function isYargsInstance(y$2) {
|
|
|
4681
4681
|
|
|
4682
4682
|
//#endregion
|
|
4683
4683
|
//#region ../../node_modules/.pnpm/yargs@18.0.0/node_modules/yargs/index.mjs
|
|
4684
|
-
const Yargs = YargsFactory(esm_default$
|
|
4684
|
+
const Yargs = YargsFactory(esm_default$3);
|
|
4685
4685
|
var yargs_default = Yargs;
|
|
4686
4686
|
|
|
4687
4687
|
//#endregion
|
|
4688
4688
|
//#region package.json
|
|
4689
4689
|
var name = "@jixo/cli";
|
|
4690
|
-
var version$1 = "0.
|
|
4690
|
+
var version$1 = "0.23.0";
|
|
4691
4691
|
var type = "module";
|
|
4692
4692
|
var bin = { "jixo": "./bundle/index.js" };
|
|
4693
|
-
var files = [
|
|
4693
|
+
var files = [
|
|
4694
|
+
"assets",
|
|
4695
|
+
"bundle",
|
|
4696
|
+
"dist"
|
|
4697
|
+
];
|
|
4694
4698
|
var scripts = {
|
|
4695
|
-
"build": "pnpm run
|
|
4699
|
+
"build": "pnpm run \"/^b\\:.*/\"",
|
|
4696
4700
|
"b:ts": "tsc --build",
|
|
4697
4701
|
"b:bundle": "tsdown",
|
|
4698
4702
|
"gen-prompts": "node ./scripts/gen-prompts.ts"
|
|
@@ -4750,7 +4754,7 @@ var package_default = {
|
|
|
4750
4754
|
};
|
|
4751
4755
|
|
|
4752
4756
|
//#endregion
|
|
4753
|
-
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@
|
|
4757
|
+
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@gau_ac796b2c5c73dab9bab91ba9e75b6834/node_modules/@gaubee/nodekit/esm/_dnt.shims.js
|
|
4754
4758
|
const dntGlobals = {};
|
|
4755
4759
|
const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
4756
4760
|
function createMergeProxy(baseObj, extObj) {
|
|
@@ -4798,7 +4802,7 @@ function createMergeProxy(baseObj, extObj) {
|
|
|
4798
4802
|
}
|
|
4799
4803
|
|
|
4800
4804
|
//#endregion
|
|
4801
|
-
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@
|
|
4805
|
+
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@gau_ac796b2c5c73dab9bab91ba9e75b6834/node_modules/@gaubee/nodekit/esm/deps/jsr.io/@std/fmt/1.0.8/colors.js
|
|
4802
4806
|
const { Deno } = dntGlobalThis;
|
|
4803
4807
|
const noColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : false;
|
|
4804
4808
|
let enabled = !noColor;
|
|
@@ -5235,6 +5239,19 @@ const iter_map_not_null = (values, callbackfn) => {
|
|
|
5235
5239
|
else for (const value of values) if (value != null) result.push(value);
|
|
5236
5240
|
return result;
|
|
5237
5241
|
};
|
|
5242
|
+
/**
|
|
5243
|
+
* 类似与 map not null,但只取第一个
|
|
5244
|
+
*
|
|
5245
|
+
* 支持任何可迭代的对象
|
|
5246
|
+
*/
|
|
5247
|
+
const iter_first_not_null = (values, callbackfn) => {
|
|
5248
|
+
let index$1 = 0;
|
|
5249
|
+
if (callbackfn) for (const value of values) {
|
|
5250
|
+
const r$1 = callbackfn(value, index$1++, values);
|
|
5251
|
+
if (r$1 != null) return r$1;
|
|
5252
|
+
}
|
|
5253
|
+
else for (const value of values) if (value != null) return value;
|
|
5254
|
+
};
|
|
5238
5255
|
|
|
5239
5256
|
//#endregion
|
|
5240
5257
|
//#region ../../node_modules/.pnpm/@gaubee+util@0.34.2/node_modules/@gaubee/util/esm/pure_event.js
|
|
@@ -5777,7 +5794,7 @@ const createResolverByRootFile = (fromPath = process$1.cwd(), rootFilename = "pa
|
|
|
5777
5794
|
};
|
|
5778
5795
|
|
|
5779
5796
|
//#endregion
|
|
5780
|
-
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@
|
|
5797
|
+
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@gau_ac796b2c5c73dab9bab91ba9e75b6834/node_modules/@gaubee/nodekit/esm/deps/jsr.io/@std/jsonc/1.0.2/parse.js
|
|
5781
5798
|
/**
|
|
5782
5799
|
* Converts a JSON with Comments (JSONC) string into an object.
|
|
5783
5800
|
*
|
|
@@ -6003,7 +6020,7 @@ function buildErrorMessage({ type: type$1, sourceText, position: position$1 }) {
|
|
|
6003
6020
|
}
|
|
6004
6021
|
|
|
6005
6022
|
//#endregion
|
|
6006
|
-
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@
|
|
6023
|
+
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@gau_ac796b2c5c73dab9bab91ba9e75b6834/node_modules/@gaubee/nodekit/esm/config_file.js
|
|
6007
6024
|
/**
|
|
6008
6025
|
* read json or jsonc file
|
|
6009
6026
|
*/
|
|
@@ -8907,7 +8924,7 @@ var require_gray_matter = __commonJS$2({ "../../node_modules/.pnpm/gray-matter@4
|
|
|
8907
8924
|
} });
|
|
8908
8925
|
|
|
8909
8926
|
//#endregion
|
|
8910
|
-
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@
|
|
8927
|
+
//#region ../../node_modules/.pnpm/@gaubee+nodekit@0.12.0_@gau_ac796b2c5c73dab9bab91ba9e75b6834/node_modules/@gaubee/nodekit/esm/markdown_file.js
|
|
8911
8928
|
var import_gray_matter = __toESM$1(require_gray_matter(), 1);
|
|
8912
8929
|
|
|
8913
8930
|
//#endregion
|
|
@@ -9665,7 +9682,7 @@ const fallbackSymbols = {
|
|
|
9665
9682
|
};
|
|
9666
9683
|
const shouldUseMain = isUnicodeSupported();
|
|
9667
9684
|
const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
|
|
9668
|
-
var esm_default = figures;
|
|
9685
|
+
var esm_default$1 = figures;
|
|
9669
9686
|
const replacements = Object.entries(specialMainSymbols);
|
|
9670
9687
|
|
|
9671
9688
|
//#endregion
|
|
@@ -9674,7 +9691,7 @@ var import_yoctocolors_cjs$2 = __toESM$1(require_yoctocolors_cjs(), 1);
|
|
|
9674
9691
|
const defaultTheme = {
|
|
9675
9692
|
prefix: {
|
|
9676
9693
|
idle: import_yoctocolors_cjs$2.default.blue("?"),
|
|
9677
|
-
done: import_yoctocolors_cjs$2.default.green(esm_default.tick)
|
|
9694
|
+
done: import_yoctocolors_cjs$2.default.green(esm_default$1.tick)
|
|
9678
9695
|
},
|
|
9679
9696
|
spinner: {
|
|
9680
9697
|
interval: 80,
|
|
@@ -12484,7 +12501,7 @@ var import_yoctocolors_cjs$1 = __toESM$1(require_yoctocolors_cjs(), 1);
|
|
|
12484
12501
|
* Used to space/separate choices group
|
|
12485
12502
|
*/
|
|
12486
12503
|
var Separator = class {
|
|
12487
|
-
separator = import_yoctocolors_cjs$1.default.dim(Array.from({ length: 15 }).join(esm_default.line));
|
|
12504
|
+
separator = import_yoctocolors_cjs$1.default.dim(Array.from({ length: 15 }).join(esm_default$1.line));
|
|
12488
12505
|
type = "separator";
|
|
12489
12506
|
constructor(separator) {
|
|
12490
12507
|
if (separator) this.separator = separator;
|
|
@@ -12500,9 +12517,9 @@ var import_yoctocolors_cjs = __toESM$1(require_yoctocolors_cjs(), 1);
|
|
|
12500
12517
|
var import_ansi_escapes = __toESM$1(require_ansi_escapes(), 1);
|
|
12501
12518
|
const checkboxTheme = {
|
|
12502
12519
|
icon: {
|
|
12503
|
-
checked: import_yoctocolors_cjs.default.green(esm_default.circleFilled),
|
|
12504
|
-
unchecked: esm_default.circle,
|
|
12505
|
-
cursor: esm_default.pointer
|
|
12520
|
+
checked: import_yoctocolors_cjs.default.green(esm_default$1.circleFilled),
|
|
12521
|
+
unchecked: esm_default$1.circle,
|
|
12522
|
+
cursor: esm_default$1.pointer
|
|
12506
12523
|
},
|
|
12507
12524
|
style: {
|
|
12508
12525
|
disabledChoice: (text$2) => import_yoctocolors_cjs.default.dim(`- ${text$2}`),
|
|
@@ -12553,7 +12570,7 @@ function normalizeChoices(choices) {
|
|
|
12553
12570
|
return normalizedChoice;
|
|
12554
12571
|
});
|
|
12555
12572
|
}
|
|
12556
|
-
var esm_default$
|
|
12573
|
+
var esm_default$2 = createPrompt((config$1, done) => {
|
|
12557
12574
|
const { instructions, pageSize = 7, loop = true, required: required$1, validate: validate$1 = () => true } = config$1;
|
|
12558
12575
|
const shortcuts = {
|
|
12559
12576
|
all: "a",
|
|
@@ -12670,6 +12687,47 @@ var esm_default$1 = createPrompt((config$1, done) => {
|
|
|
12670
12687
|
return `${prefix} ${message}${helpTipTop}\n${page}${helpTipBottom}${choiceDescription}${error$41}${import_ansi_escapes.default.cursorHide}`;
|
|
12671
12688
|
});
|
|
12672
12689
|
|
|
12690
|
+
//#endregion
|
|
12691
|
+
//#region ../../node_modules/.pnpm/@inquirer+confirm@5.1.14_@types+node@24.1.0/node_modules/@inquirer/confirm/dist/esm/index.js
|
|
12692
|
+
function getBooleanValue(value, defaultValue) {
|
|
12693
|
+
let answer = defaultValue !== false;
|
|
12694
|
+
if (/^(y|yes)/i.test(value)) answer = true;
|
|
12695
|
+
else if (/^(n|no)/i.test(value)) answer = false;
|
|
12696
|
+
return answer;
|
|
12697
|
+
}
|
|
12698
|
+
function boolToString(value) {
|
|
12699
|
+
return value ? "Yes" : "No";
|
|
12700
|
+
}
|
|
12701
|
+
var esm_default = createPrompt((config$1, done) => {
|
|
12702
|
+
const { transformer = boolToString } = config$1;
|
|
12703
|
+
const [status, setStatus] = useState("idle");
|
|
12704
|
+
const [value, setValue] = useState("");
|
|
12705
|
+
const theme = makeTheme(config$1.theme);
|
|
12706
|
+
const prefix = usePrefix({
|
|
12707
|
+
status,
|
|
12708
|
+
theme
|
|
12709
|
+
});
|
|
12710
|
+
useKeypress((key$1, rl) => {
|
|
12711
|
+
if (isEnterKey(key$1)) {
|
|
12712
|
+
const answer = getBooleanValue(value, config$1.default);
|
|
12713
|
+
setValue(transformer(answer));
|
|
12714
|
+
setStatus("done");
|
|
12715
|
+
done(answer);
|
|
12716
|
+
} else if (key$1.name === "tab") {
|
|
12717
|
+
const answer = boolToString(!getBooleanValue(value, config$1.default));
|
|
12718
|
+
rl.clearLine(0);
|
|
12719
|
+
rl.write(answer);
|
|
12720
|
+
setValue(answer);
|
|
12721
|
+
} else setValue(rl.line);
|
|
12722
|
+
});
|
|
12723
|
+
let formattedValue = value;
|
|
12724
|
+
let defaultValue = "";
|
|
12725
|
+
if (status === "done") formattedValue = theme.style.answer(value);
|
|
12726
|
+
else defaultValue = ` ${theme.style.defaultAnswer(config$1.default === false ? "y/N" : "Y/n")}`;
|
|
12727
|
+
const message = theme.style.message(config$1.message, status);
|
|
12728
|
+
return `${prefix} ${message}${defaultValue} ${formattedValue}`;
|
|
12729
|
+
});
|
|
12730
|
+
|
|
12673
12731
|
//#endregion
|
|
12674
12732
|
//#region ../../node_modules/.pnpm/@sindresorhus+merge-streams@2.3.0/node_modules/@sindresorhus/merge-streams/index.js
|
|
12675
12733
|
function mergeStreams(streams) {
|
|
@@ -40747,7 +40805,7 @@ async function confirmAction(filesToUpdate, options$1) {
|
|
|
40747
40805
|
checked: file$1.safe || !!options$1.allowUnsafe
|
|
40748
40806
|
});
|
|
40749
40807
|
}
|
|
40750
|
-
const selectedFiles = await esm_default$
|
|
40808
|
+
const selectedFiles = await esm_default$2({
|
|
40751
40809
|
message: [options$1.topMessage, "The following files will be overwritten:\n"].filter(Boolean).join("\n"),
|
|
40752
40810
|
choices,
|
|
40753
40811
|
pageSize: process.stdout.rows > 0 ? process.stdout.rows - 4 : filesToUpdate.length
|
|
@@ -41598,6 +41656,12 @@ const reactiveFs = {
|
|
|
41598
41656
|
use: useReactiveFs
|
|
41599
41657
|
};
|
|
41600
41658
|
|
|
41659
|
+
//#endregion
|
|
41660
|
+
//#region ../dev/dist/utils/resolver.js
|
|
41661
|
+
const projectResolver = createResolverByRootFile(import.meta.url, "package.json");
|
|
41662
|
+
const defaultAssetsResolver = createResolver(projectResolver("assets"));
|
|
41663
|
+
let assetsResolver = defaultAssetsResolver;
|
|
41664
|
+
|
|
41601
41665
|
//#endregion
|
|
41602
41666
|
//#region ../dev/dist/gen-prompt/file-tree.js
|
|
41603
41667
|
function buildTree(node$1, indentation, outputLines, expandDirectories) {
|
|
@@ -41700,8 +41764,7 @@ const paramsToGlobbyOptions = (params, defaults$4 = {}) => {
|
|
|
41700
41764
|
//#endregion
|
|
41701
41765
|
//#region ../dev/dist/gen-prompt/replacers/file-replacer.js
|
|
41702
41766
|
const fetchCache = /* @__PURE__ */ new Map();
|
|
41703
|
-
const
|
|
41704
|
-
const GET_JIXO_PROMPT = func_remember(() => readJson(projectResolver("./assets/prompt.json")));
|
|
41767
|
+
const GET_JIXO_PROMPT = func_remember(() => readJson(assetsResolver("prompt.json")));
|
|
41705
41768
|
/**
|
|
41706
41769
|
* A utility function to format the file content output in a standardized way.
|
|
41707
41770
|
* It handles markdown code blocks and optional prefixes.
|
|
@@ -62543,7 +62606,7 @@ const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
62543
62606
|
inst.isFinite = true;
|
|
62544
62607
|
inst.format = bag.format ?? null;
|
|
62545
62608
|
});
|
|
62546
|
-
function number
|
|
62609
|
+
function number(params) {
|
|
62547
62610
|
return _number(ZodNumber, params);
|
|
62548
62611
|
}
|
|
62549
62612
|
const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
|
|
@@ -63173,7 +63236,7 @@ function json(params) {
|
|
|
63173
63236
|
const jsonSchema = lazy(() => {
|
|
63174
63237
|
return union([
|
|
63175
63238
|
string(params),
|
|
63176
|
-
number
|
|
63239
|
+
number(),
|
|
63177
63240
|
boolean(),
|
|
63178
63241
|
_null(),
|
|
63179
63242
|
array(jsonSchema),
|
|
@@ -63221,13 +63284,13 @@ __export$4(coerce_exports, {
|
|
|
63221
63284
|
bigint: () => bigint,
|
|
63222
63285
|
boolean: () => boolean$1,
|
|
63223
63286
|
date: () => date,
|
|
63224
|
-
number: () => number,
|
|
63287
|
+
number: () => number$1,
|
|
63225
63288
|
string: () => string$1
|
|
63226
63289
|
});
|
|
63227
63290
|
function string$1(params) {
|
|
63228
63291
|
return _coercedString(ZodString, params);
|
|
63229
63292
|
}
|
|
63230
|
-
function number(params) {
|
|
63293
|
+
function number$1(params) {
|
|
63231
63294
|
return _coercedNumber(ZodNumber, params);
|
|
63232
63295
|
}
|
|
63233
63296
|
function boolean$1(params) {
|
|
@@ -63397,7 +63460,7 @@ __export$4(external_exports, {
|
|
|
63397
63460
|
null: () => _null,
|
|
63398
63461
|
nullable: () => nullable,
|
|
63399
63462
|
nullish: () => nullish,
|
|
63400
|
-
number: () => number
|
|
63463
|
+
number: () => number,
|
|
63401
63464
|
object: () => object,
|
|
63402
63465
|
optional: () => optional,
|
|
63403
63466
|
overwrite: () => _overwrite,
|
|
@@ -63455,10 +63518,6 @@ __export$4(external_exports, {
|
|
|
63455
63518
|
});
|
|
63456
63519
|
config(en_default());
|
|
63457
63520
|
|
|
63458
|
-
//#endregion
|
|
63459
|
-
//#region ../../node_modules/.pnpm/zod@4.0.10/node_modules/zod/index.js
|
|
63460
|
-
var zod_default = external_exports;
|
|
63461
|
-
|
|
63462
63521
|
//#endregion
|
|
63463
63522
|
//#region ../dev/dist/google-aistudio/node/types.js
|
|
63464
63523
|
const z = {
|
|
@@ -63467,7 +63526,8 @@ const z = {
|
|
|
63467
63526
|
string,
|
|
63468
63527
|
array,
|
|
63469
63528
|
union,
|
|
63470
|
-
unknown
|
|
63529
|
+
unknown,
|
|
63530
|
+
number
|
|
63471
63531
|
};
|
|
63472
63532
|
const zContentSchema = z.object({
|
|
63473
63533
|
generationConfiguration: z.object({
|
|
@@ -63480,71 +63540,135 @@ const zContentSchema = z.object({
|
|
|
63480
63540
|
requiresParts: z.boolean(),
|
|
63481
63541
|
requiresFunctionCalling: z.boolean(),
|
|
63482
63542
|
requiresCodeExecution: z.boolean()
|
|
63483
|
-
}),
|
|
63543
|
+
}).partial(),
|
|
63484
63544
|
generateContentParameters: z.object({
|
|
63485
63545
|
model: z.string(),
|
|
63486
|
-
contents: z.array(z.
|
|
63487
|
-
z.
|
|
63488
|
-
|
|
63489
|
-
|
|
63546
|
+
contents: z.array(z.object({
|
|
63547
|
+
role: z.string(),
|
|
63548
|
+
parts: z.array(z.union([
|
|
63549
|
+
z.object({ isLast: z.boolean() }),
|
|
63550
|
+
z.object({
|
|
63490
63551
|
isLast: z.boolean(),
|
|
63491
63552
|
text: z.string()
|
|
63492
|
-
})
|
|
63493
|
-
|
|
63494
|
-
z.object({
|
|
63495
|
-
role: z.string(),
|
|
63496
|
-
parts: z.array(z.union([z.object({
|
|
63497
|
-
isLast: z.boolean(),
|
|
63498
|
-
text: z.string()
|
|
63499
|
-
}), z.object({
|
|
63553
|
+
}),
|
|
63554
|
+
z.object({
|
|
63500
63555
|
isLast: z.boolean(),
|
|
63501
63556
|
functionCall: z.object({
|
|
63502
63557
|
name: z.string(),
|
|
63503
63558
|
parameters: z.string()
|
|
63504
63559
|
})
|
|
63505
|
-
})
|
|
63506
|
-
|
|
63507
|
-
z.object({
|
|
63508
|
-
role: z.string(),
|
|
63509
|
-
parts: z.array(z.object({
|
|
63560
|
+
}),
|
|
63561
|
+
z.object({
|
|
63510
63562
|
isLast: z.boolean(),
|
|
63511
63563
|
functionResponse: z.object({
|
|
63512
63564
|
name: z.string(),
|
|
63513
63565
|
response: z.string()
|
|
63514
63566
|
})
|
|
63515
|
-
})
|
|
63516
|
-
|
|
63517
|
-
z.object({
|
|
63518
|
-
role: z.string(),
|
|
63519
|
-
parts: z.array(z.union([z.object({
|
|
63567
|
+
}),
|
|
63568
|
+
z.object({
|
|
63520
63569
|
isLast: z.boolean(),
|
|
63521
|
-
|
|
63522
|
-
|
|
63523
|
-
|
|
63570
|
+
inlineData: z.object({
|
|
63571
|
+
data: z.string(),
|
|
63572
|
+
splitData: z.array(z.string()),
|
|
63573
|
+
mimeType: z.string()
|
|
63574
|
+
}),
|
|
63575
|
+
fileData: z.object({
|
|
63576
|
+
mimeType: z.string(),
|
|
63577
|
+
fileIndex: z.number(),
|
|
63578
|
+
fileName: z.string()
|
|
63524
63579
|
})
|
|
63525
|
-
})
|
|
63526
|
-
|
|
63527
|
-
|
|
63528
|
-
|
|
63529
|
-
isLast: z.boolean()
|
|
63530
|
-
})
|
|
63531
|
-
])),
|
|
63580
|
+
})
|
|
63581
|
+
])),
|
|
63582
|
+
isLast: z.boolean().optional()
|
|
63583
|
+
})),
|
|
63532
63584
|
config: z.object({
|
|
63533
63585
|
thinkingConfig: z.object({ thinkingBudget: z.string() }),
|
|
63534
63586
|
stopSequences: z.array(z.unknown()),
|
|
63535
|
-
responseMimeType: z.string(),
|
|
63587
|
+
responseMimeType: z.string().optional(),
|
|
63536
63588
|
responseModalities: z.array(z.unknown()),
|
|
63537
63589
|
safetySettings: z.array(z.unknown()),
|
|
63538
|
-
tools: z.array(z.union([
|
|
63539
|
-
|
|
63540
|
-
|
|
63541
|
-
|
|
63542
|
-
|
|
63543
|
-
|
|
63590
|
+
tools: z.array(z.union([
|
|
63591
|
+
z.object({ googleSearch: z.object({}) }),
|
|
63592
|
+
z.object({ urlContext: z.object({}) }),
|
|
63593
|
+
z.object({ functionDeclarations: z.array(z.object({
|
|
63594
|
+
name: z.string(),
|
|
63595
|
+
description: z.string(),
|
|
63596
|
+
parameters: z.string(),
|
|
63597
|
+
isLast: z.boolean()
|
|
63598
|
+
})) })
|
|
63599
|
+
]))
|
|
63544
63600
|
})
|
|
63545
63601
|
})
|
|
63546
63602
|
}).loose();
|
|
63547
63603
|
|
|
63604
|
+
//#endregion
|
|
63605
|
+
//#region ../dev/dist/google-aistudio/node/index.js
|
|
63606
|
+
const doGoogleAiStudioAutomation = (dir = process.cwd()) => {
|
|
63607
|
+
const watcher$1 = fs.watch(dir);
|
|
63608
|
+
const handle = func_debounce(async () => {
|
|
63609
|
+
const names = fs.readdirSync(dir);
|
|
63610
|
+
const contentNames = names.filter((name$1) => name$1.endsWith(".contents.json"));
|
|
63611
|
+
for (const contentFilename of contentNames) {
|
|
63612
|
+
const contentFilepath = path.join(dir, contentFilename);
|
|
63613
|
+
const basename$1 = contentFilename.replace(".contents.json", "");
|
|
63614
|
+
await parseContent(basename$1, contentFilepath, names).catch(console.error);
|
|
63615
|
+
}
|
|
63616
|
+
}, 200);
|
|
63617
|
+
const parseContent = async (basename$1, contentFilepath, filenames) => {
|
|
63618
|
+
console.log(magenta("开始处理文件"), path.relative(process.cwd(), contentFilepath));
|
|
63619
|
+
const fileData = await zContentSchema.parse(JSON.parse(fs.readFileSync(contentFilepath, "utf-8")));
|
|
63620
|
+
const { contents } = fileData.generateContentParameters;
|
|
63621
|
+
const latestContent = contents.at(-1);
|
|
63622
|
+
if (!latestContent) return;
|
|
63623
|
+
if (latestContent.role !== "user") return;
|
|
63624
|
+
const functionResponsePart = latestContent.parts.find((p$1) => "functionResponse" in p$1);
|
|
63625
|
+
if (!functionResponsePart) return;
|
|
63626
|
+
if (functionResponsePart.functionResponse.response !== "") return;
|
|
63627
|
+
const modelContent = contents.findLast((content$2) => {
|
|
63628
|
+
return content$2.role === "model" && content$2.parts.find((p$1) => "functionCall" in p$1);
|
|
63629
|
+
});
|
|
63630
|
+
if (!modelContent) return;
|
|
63631
|
+
const functionCallPart = modelContent.parts.find((p$1) => "functionCall" in p$1)?.functionCall;
|
|
63632
|
+
if (!functionCallPart) return;
|
|
63633
|
+
const modelIndex = contents.indexOf(modelContent);
|
|
63634
|
+
const hash = createHash("sha256").update(`INDEX:${modelIndex}`).update(JSON.stringify(modelContent)).digest("hex").slice(0, 8);
|
|
63635
|
+
const taskFilename = `${basename$1}.${functionCallPart.name}.${modelIndex}-${hash}.function_call.json`;
|
|
63636
|
+
if (filenames.includes(taskFilename)) return;
|
|
63637
|
+
console.log(blue("收到 functionCallPart 任务请求"), functionCallPart);
|
|
63638
|
+
const scriptFilepath = iter_first_not_null(function* () {
|
|
63639
|
+
for (const scriptFilename of [`${functionCallPart.name}.function_call.js`, `${functionCallPart.name}.function_call.ts`]) yield path.join(dir, scriptFilename);
|
|
63640
|
+
}(), (scriptFilepath$1) => {
|
|
63641
|
+
if (fs.existsSync(scriptFilepath$1)) return scriptFilepath$1;
|
|
63642
|
+
});
|
|
63643
|
+
if (!scriptFilepath) console.warn("找不到任务处理工具");
|
|
63644
|
+
else {
|
|
63645
|
+
const { functionCall } = await import(pathToFileURL(scriptFilepath).href);
|
|
63646
|
+
const input = JSON.parse(functionCallPart.parameters);
|
|
63647
|
+
try {
|
|
63648
|
+
console.log(cyan("开始执行任务"));
|
|
63649
|
+
const output = await functionCall(input);
|
|
63650
|
+
console.log(green("生成任务结果:"), taskFilename);
|
|
63651
|
+
fs.writeFileSync(path.join(dir, taskFilename), JSON.stringify({
|
|
63652
|
+
input,
|
|
63653
|
+
output
|
|
63654
|
+
}, null, 2));
|
|
63655
|
+
} catch (e$1) {
|
|
63656
|
+
console.log(red("任务执行失败:"), e$1);
|
|
63657
|
+
}
|
|
63658
|
+
}
|
|
63659
|
+
};
|
|
63660
|
+
watcher$1.on("change", (eventType) => {
|
|
63661
|
+
if (eventType === "delete" || eventType === "unlink") return;
|
|
63662
|
+
handle();
|
|
63663
|
+
});
|
|
63664
|
+
handle();
|
|
63665
|
+
console.log(gray("\nWatching for file changes... Press Ctrl+C to exit."));
|
|
63666
|
+
};
|
|
63667
|
+
|
|
63668
|
+
//#endregion
|
|
63669
|
+
//#region ../../node_modules/.pnpm/zod@4.0.10/node_modules/zod/index.js
|
|
63670
|
+
var zod_default = external_exports;
|
|
63671
|
+
|
|
63548
63672
|
//#endregion
|
|
63549
63673
|
//#region ../dev/dist/google-aistudio/jixo/sync.js
|
|
63550
63674
|
const sync = async (basePath, outDir) => {
|
|
@@ -63597,64 +63721,6 @@ const sync = async (basePath, outDir) => {
|
|
|
63597
63721
|
await Promise.all(model_files.filter((file$1) => addFileNames.has(file$1.name)).map((file$1) => writeFile$1(path.join(resolvedOutDir, file$1.name), file$1.content)));
|
|
63598
63722
|
console.log(blue((/* @__PURE__ */ new Date()).toLocaleTimeString()), green("sync"), path.relative(process.cwd(), basePath));
|
|
63599
63723
|
};
|
|
63600
|
-
|
|
63601
|
-
//#endregion
|
|
63602
|
-
//#region ../dev/dist/google-aistudio/node/index.js
|
|
63603
|
-
const doGoogleAiStudioAutomation = (dir = process.cwd()) => {
|
|
63604
|
-
const watcher$1 = fs.watch(dir);
|
|
63605
|
-
const handle = func_debounce(async () => {
|
|
63606
|
-
const names = fs.readdirSync(dir);
|
|
63607
|
-
const contentNames = names.filter((name$1) => name$1.endsWith(".contents.json"));
|
|
63608
|
-
for (const contentFilename of contentNames) {
|
|
63609
|
-
const contentFilepath = path.join(dir, contentFilename);
|
|
63610
|
-
const basename$1 = contentFilename.replace(".contents.json", "");
|
|
63611
|
-
await parseContent(basename$1, contentFilepath, names).catch(console.error);
|
|
63612
|
-
}
|
|
63613
|
-
}, 200);
|
|
63614
|
-
const parseContent = async (basename$1, contentFilepath, filenames) => {
|
|
63615
|
-
const fileData = await zContentSchema.parse(JSON.parse(fs.readFileSync(contentFilepath, "utf-8")));
|
|
63616
|
-
const { contents } = fileData.generateContentParameters;
|
|
63617
|
-
const latestContent = contents.at(-1);
|
|
63618
|
-
if (!latestContent) return;
|
|
63619
|
-
if (latestContent.role !== "user") return;
|
|
63620
|
-
console.log("QAQ latestContent", latestContent);
|
|
63621
|
-
const functionResponsePart = latestContent.parts.find((p$1) => "functionResponse" in p$1);
|
|
63622
|
-
if (!functionResponsePart) return;
|
|
63623
|
-
if (functionResponsePart.functionResponse.response !== "") return;
|
|
63624
|
-
const modelContent = contents.findLast((content$2) => {
|
|
63625
|
-
return content$2.role === "model" && content$2.parts.find((p$1) => "functionCall" in p$1);
|
|
63626
|
-
});
|
|
63627
|
-
if (!modelContent) return;
|
|
63628
|
-
const functionCallPart = modelContent.parts.find((p$1) => "functionCall" in p$1)?.functionCall;
|
|
63629
|
-
if (!functionCallPart) return;
|
|
63630
|
-
const modelIndex = contents.indexOf(modelContent);
|
|
63631
|
-
const hash = createHash("sha256").update(`INDEX:${modelIndex}`).update(JSON.stringify(modelContent)).digest("hex").slice(0, 8);
|
|
63632
|
-
const taskFilename = `${basename$1}.${functionCallPart.name}.${modelIndex}-${hash}.function_call.json`;
|
|
63633
|
-
if (filenames.includes(taskFilename)) return;
|
|
63634
|
-
for (const scriptFilename of [`${functionCallPart.name}.function_call.js`, `${functionCallPart.name}.function_call.ts`]) {
|
|
63635
|
-
const scriptFilepath = path.join(dir, scriptFilename);
|
|
63636
|
-
if (fs.existsSync(scriptFilepath)) {
|
|
63637
|
-
const { functionCall } = await import(pathToFileURL(scriptFilepath).href);
|
|
63638
|
-
const input = JSON.parse(functionCallPart.parameters);
|
|
63639
|
-
const output = await functionCall(input);
|
|
63640
|
-
console.log("QAQ output", output);
|
|
63641
|
-
console.log("WRITE TASK FILE:", taskFilename);
|
|
63642
|
-
fs.writeFileSync(path.join(dir, taskFilename), JSON.stringify({
|
|
63643
|
-
input,
|
|
63644
|
-
output
|
|
63645
|
-
}, null, 2));
|
|
63646
|
-
}
|
|
63647
|
-
}
|
|
63648
|
-
};
|
|
63649
|
-
watcher$1.on("change", (eventType) => {
|
|
63650
|
-
if (eventType === "delete" || eventType === "unlink") return;
|
|
63651
|
-
handle();
|
|
63652
|
-
});
|
|
63653
|
-
handle();
|
|
63654
|
-
};
|
|
63655
|
-
|
|
63656
|
-
//#endregion
|
|
63657
|
-
//#region ../dev/dist/google-aistudio/jixo/index.js
|
|
63658
63724
|
/**
|
|
63659
63725
|
* 封装了 sync 命令的核心执行逻辑
|
|
63660
63726
|
* @param args - 命令行参数,符合 yargs 解析后的结构
|
|
@@ -63667,11 +63733,46 @@ const doSync = (args) => {
|
|
|
63667
63733
|
if (args.watch) console.log(gray("\nWatching for file changes... Press Ctrl+C to exit."));
|
|
63668
63734
|
};
|
|
63669
63735
|
|
|
63736
|
+
//#endregion
|
|
63737
|
+
//#region ../dev/dist/google-aistudio/jixo/init.js
|
|
63738
|
+
const doInit = async ({ dir, force }) => {
|
|
63739
|
+
const cpAssets = ["google-aistudio.browser.js"];
|
|
63740
|
+
const sourceEntries = cpAssets.map((entrypath) => ({
|
|
63741
|
+
relativepath: entrypath,
|
|
63742
|
+
fullpath: assetsResolver(`bundle`, entrypath)
|
|
63743
|
+
}));
|
|
63744
|
+
const targetEntries = cpAssets.map((entrypath) => ({
|
|
63745
|
+
relativepath: entrypath,
|
|
63746
|
+
fullpath: path.resolve(dir, entrypath)
|
|
63747
|
+
}));
|
|
63748
|
+
const existEntries = targetEntries.filter((targetEntry) => existsSync(targetEntry.fullpath));
|
|
63749
|
+
if (existEntries.length) {
|
|
63750
|
+
const logPaths = () => existEntries.map((entry) => `${gray("-")} ${blue(entry.relativepath)}`);
|
|
63751
|
+
if (force === false) {
|
|
63752
|
+
console.warn([yellow(`the same file(s) name already exists.`), ...logPaths()].join("\n"));
|
|
63753
|
+
return;
|
|
63754
|
+
}
|
|
63755
|
+
if (force == null) {
|
|
63756
|
+
const overwrite = await esm_default({
|
|
63757
|
+
message: [`the same file(s) name already exists. Are you sure you want to overwrite?`, ...logPaths()].join("\n"),
|
|
63758
|
+
default: false
|
|
63759
|
+
});
|
|
63760
|
+
if (!overwrite) return;
|
|
63761
|
+
}
|
|
63762
|
+
await Promise.all(existEntries.map((entry) => rm(entry.fullpath, { recursive: true })));
|
|
63763
|
+
}
|
|
63764
|
+
await mkdir(dir, { recursive: true });
|
|
63765
|
+
for (const [index$1, sourceEntry] of sourceEntries.entries()) await copyFile(sourceEntry.fullpath, targetEntries[index$1].fullpath);
|
|
63766
|
+
await Promise.all(sourceEntries.map((sourceEntry, index$1) => {
|
|
63767
|
+
return copyFile(sourceEntry.fullpath, targetEntries[index$1].fullpath);
|
|
63768
|
+
}));
|
|
63769
|
+
};
|
|
63770
|
+
|
|
63670
63771
|
//#endregion
|
|
63671
63772
|
//#region src/commands/google-aistudio.ts
|
|
63672
63773
|
const syncCommand = {
|
|
63673
63774
|
command: "sync [path]",
|
|
63674
|
-
aliases: ["S"],
|
|
63775
|
+
aliases: ["S", "s"],
|
|
63675
63776
|
describe: "Sync with aistudio.google.com contents",
|
|
63676
63777
|
builder: (yargs) => yargs.positional("path", {
|
|
63677
63778
|
describe: "Directory or file path to sync",
|
|
@@ -63697,7 +63798,7 @@ const syncCommand = {
|
|
|
63697
63798
|
};
|
|
63698
63799
|
const browserCommand = {
|
|
63699
63800
|
command: "browser [dir]",
|
|
63700
|
-
aliases: ["B"],
|
|
63801
|
+
aliases: ["B", "b"],
|
|
63701
63802
|
describe: "browser-kit for aistudio.google.com",
|
|
63702
63803
|
builder: (yargs) => yargs.positional("dir", {
|
|
63703
63804
|
describe: "Directory for aistudio output contents",
|
|
@@ -63708,6 +63809,23 @@ const browserCommand = {
|
|
|
63708
63809
|
doGoogleAiStudioAutomation(argv.dir);
|
|
63709
63810
|
}
|
|
63710
63811
|
};
|
|
63812
|
+
const initCommand = {
|
|
63813
|
+
command: "init [dir]",
|
|
63814
|
+
aliases: ["i", "I"],
|
|
63815
|
+
describe: "init an browser-kit directory for aistudio.google.com",
|
|
63816
|
+
builder: (yargs) => yargs.positional("dir", {
|
|
63817
|
+
describe: "Directory for aistudio input/output contents",
|
|
63818
|
+
type: "string",
|
|
63819
|
+
default: path.resolve(process.cwd(), ".ai")
|
|
63820
|
+
}).option("force", {
|
|
63821
|
+
alias: "F",
|
|
63822
|
+
type: "boolean",
|
|
63823
|
+
describe: "override exits files"
|
|
63824
|
+
}),
|
|
63825
|
+
handler: async (argv) => {
|
|
63826
|
+
doInit(argv);
|
|
63827
|
+
}
|
|
63828
|
+
};
|
|
63711
63829
|
/**
|
|
63712
63830
|
* @jixo/cli google-aistudio
|
|
63713
63831
|
*
|
|
@@ -63722,7 +63840,7 @@ const googleAistudioCommand = {
|
|
|
63722
63840
|
],
|
|
63723
63841
|
describe: "Commands for Google AI Studio integration",
|
|
63724
63842
|
builder: (yargs) => {
|
|
63725
|
-
return yargs.command(syncCommand).command(browserCommand).demandCommand(1, "You must provide a sub-command for 'google-aistudio'.");
|
|
63843
|
+
return yargs.command(syncCommand).command(browserCommand).command(initCommand).demandCommand(1, "You must provide a sub-command for 'google-aistudio'.");
|
|
63726
63844
|
},
|
|
63727
63845
|
handler: () => {}
|
|
63728
63846
|
};
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,GAAU,OAAM,MAAM,EAAiB,kBA+FzD,CAAC"}
|